@zonos/elements 1.3.257 → 1.3.259
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-cd0a054b.js → cart-c618fd5b.js} +1 -1
- package/dist/cjs/{hasInclusivePrice-3650109c.js → hasInclusivePrice-58a9f15d.js} +1 -1
- package/dist/cjs/index.cjs.js +7 -7
- package/dist/cjs/{invoice-1cea739b.js → invoice-c9cb6683.js} +2 -2
- package/dist/cjs/{isCollectMobileTablet-65c71740.js → isCollectMobileTablet-93a5194a.js} +2 -2
- package/dist/cjs/{localization-adaab93f.js → localization-5994d4de.js} +25 -3
- package/dist/cjs/{paypal-326d7bc5.js → paypal-091e089e.js} +2 -2
- package/dist/cjs/{placeTestOrder-53f2fe97.js → placeTestOrder-b07f8edb.js} +2 -2
- package/dist/cjs/{renderCheckoutCurrency-cf2e3b93.js → renderCheckoutCurrency-7876a1d4.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 +442 -17
- 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-hello-dialog.cjs.entry.js +45 -12
- 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 +72 -0
- package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog.js +43 -10
- package/dist/collection/components/store/hello/localization.js +25 -3
- package/dist/collection/components/utils/checkout/bigcommerceStorefrontApi.js +6 -0
- package/dist/collection/components/utils/checkout/buildBigcommerceLoginUrl.js +65 -0
- package/dist/collection/components/utils/checkout/checkBigCommerceBypassCustomerGroup.js +12 -7
- package/dist/collection/components/utils/checkout/checkBigCommerceForceLogin.js +116 -0
- package/dist/collection/components/utils/checkout/fetchBigCommerceCheckoutSettings.js +92 -0
- package/dist/collection/components/utils/checkout/fixBigCommerceLoginCreateAccountLink.js +53 -0
- package/dist/collection/components/utils/checkout/watchImmediateBigcommerceDomesticCheckoutRedirect.js +40 -7
- package/dist/collection/types/checkout/api/BigCommerceCheckoutSettings.js +1 -0
- package/dist/collection/types/generated/graphql.frontend.types.js +2 -0
- package/dist/collection/types/generated/graphql.internal.types.js +39 -0
- package/dist/collection/types/index.js +1 -0
- package/dist/esm/{cart-4cd47a1b.js → cart-76fb528f.js} +1 -1
- package/dist/esm/{hasInclusivePrice-7a3dc4c3.js → hasInclusivePrice-275b1048.js} +1 -1
- package/dist/esm/index.js +7 -7
- package/dist/esm/{invoice-03ff7bbb.js → invoice-9efcb941.js} +2 -2
- package/dist/esm/{isCollectMobileTablet-9eb77c9a.js → isCollectMobileTablet-a7e5b909.js} +2 -2
- package/dist/esm/{localization-79e08480.js → localization-76ce3e29.js} +25 -3
- package/dist/esm/{paypal-67c86683.js → paypal-75c5c66d.js} +2 -2
- package/dist/esm/{placeTestOrder-e81fff15.js → placeTestOrder-22633bf2.js} +2 -2
- package/dist/esm/{renderCheckoutCurrency-1fc00db4.js → renderCheckoutCurrency-d27b0082.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 +443 -18
- 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-hello-dialog.entry.js +45 -12
- 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-4cd47a1b.js → cart-76fb528f.js} +1 -1
- package/dist/esm-es5/{hasInclusivePrice-7a3dc4c3.js → hasInclusivePrice-275b1048.js} +1 -1
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{invoice-03ff7bbb.js → invoice-9efcb941.js} +1 -1
- package/dist/esm-es5/{isCollectMobileTablet-9eb77c9a.js → isCollectMobileTablet-a7e5b909.js} +1 -1
- package/dist/esm-es5/{localization-79e08480.js → localization-76ce3e29.js} +1 -1
- package/dist/esm-es5/{paypal-67c86683.js → paypal-75c5c66d.js} +2 -2
- package/dist/esm-es5/{placeTestOrder-e81fff15.js → placeTestOrder-22633bf2.js} +1 -1
- package/dist/esm-es5/{renderCheckoutCurrency-1fc00db4.js → renderCheckoutCurrency-d27b0082.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-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 +21 -5
- 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 +16 -0
- package/dist/types/components/hello/zonos-hello-dialog/zonos-hello-dialog.d.ts +6 -0
- package/dist/types/components/utils/api/getLocaleMessages.d.ts +1 -1
- package/dist/types/components/utils/checkout/bigcommerceStorefrontApi.d.ts +6 -0
- package/dist/types/components/utils/checkout/buildBigcommerceLoginUrl.d.ts +27 -0
- package/dist/types/components/utils/checkout/checkBigCommerceBypassCustomerGroup.d.ts +12 -0
- package/dist/types/components/utils/checkout/checkBigCommerceForceLogin.d.ts +50 -0
- package/dist/types/components/utils/checkout/fetchBigCommerceCheckoutSettings.d.ts +18 -0
- package/dist/types/components/utils/checkout/fixBigCommerceLoginCreateAccountLink.d.ts +17 -0
- package/dist/types/scripts/cart/_setupCartDataWithSettings.d.ts +6 -5
- package/dist/types/types/checkout/CheckoutConfig.d.ts +9 -0
- package/dist/types/types/checkout/api/BigCommerceCheckoutSettings.d.ts +12 -0
- package/dist/types/types/generated/graphql.frontend.types.d.ts +3 -1
- package/dist/types/types/generated/graphql.frontend.types.ts +3 -1
- package/dist/types/types/generated/graphql.internal.types.d.ts +58 -9
- package/dist/types/types/generated/graphql.internal.types.ts +69 -9
- package/dist/types/types/index.d.ts +1 -0
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-aa3e3438.system.entry.js → p-055c8d6c.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-ce2fd652.entry.js → p-0a9741f7.entry.js} +1 -1
- package/dist/zonos-elements/{p-3fc43187.system.entry.js → p-10da499b.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-2c1c6d60.system.entry.js → p-14d35979.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-271eebd3.system.js → p-1523f6a8.system.js} +1 -1
- package/dist/zonos-elements/{p-c585d169.entry.js → p-1661f938.entry.js} +1 -1
- package/dist/zonos-elements/{p-3092ec40.system.entry.js → p-1e9e284e.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-7559c494.js → p-1ebb59a3.js} +1 -1
- package/dist/zonos-elements/{p-4e2262e8.js → p-24f41959.js} +1 -1
- package/dist/zonos-elements/p-29b60bf3.system.js +1 -1
- package/dist/zonos-elements/{p-0ca6ee9b.entry.js → p-29d16ad0.entry.js} +1 -1
- package/dist/zonos-elements/{p-0f4822cc.system.entry.js → p-2b2b1c8c.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-91eeccaa.entry.js → p-2d854a75.entry.js} +1 -1
- package/dist/zonos-elements/{p-a90c977a.system.js → p-2ec799e4.system.js} +1 -1
- package/dist/zonos-elements/{p-d0690cdc.system.js → p-3600280d.system.js} +1 -1
- package/dist/zonos-elements/p-3ee8496e.js +1 -0
- package/dist/zonos-elements/{p-21519ebe.entry.js → p-425f747b.entry.js} +1 -1
- package/dist/zonos-elements/p-439dc620.system.entry.js +1 -0
- package/dist/zonos-elements/{p-9f3aab4e.system.entry.js → p-4b138a6e.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-7aeb496e.entry.js → p-5262f6e8.entry.js} +1 -1
- package/dist/zonos-elements/{p-b53856bf.system.js → p-567abb43.system.js} +1 -1
- package/dist/zonos-elements/{p-9d435f12.system.entry.js → p-5fa3d1c8.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-e9f36d6b.system.entry.js → p-6cf8fe49.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-8adc0a13.system.js → p-6d36b307.system.js} +1 -1
- package/dist/zonos-elements/{p-380143db.entry.js → p-6e50f6f5.entry.js} +1 -1
- package/dist/zonos-elements/{p-80ba5f70.entry.js → p-7157a5a3.entry.js} +1 -1
- package/dist/zonos-elements/{p-3675766a.entry.js → p-788c6839.entry.js} +1 -1
- package/dist/zonos-elements/{p-a7b0345b.entry.js → p-791e13e7.entry.js} +1 -1
- package/dist/zonos-elements/{p-e173fbd1.system.entry.js → p-8585c761.system.entry.js} +1 -1
- package/dist/zonos-elements/p-868a8667.js +1 -0
- package/dist/zonos-elements/{p-c2139758.entry.js → p-9460919d.entry.js} +1 -1
- package/dist/zonos-elements/{p-6b83ac7f.entry.js → p-99d92a84.entry.js} +1 -1
- package/dist/zonos-elements/{p-0740f8a4.system.entry.js → p-9a9c9441.system.entry.js} +1 -1
- package/dist/zonos-elements/p-9cbac993.entry.js +1 -0
- package/dist/zonos-elements/{p-a60544cc.entry.js → p-9cff66a7.entry.js} +1 -1
- package/dist/zonos-elements/{p-b3824361.entry.js → p-a0f6910c.entry.js} +1 -1
- package/dist/zonos-elements/{p-7caa75bb.js → p-a18adf27.js} +1 -1
- package/dist/zonos-elements/{p-8b35e475.system.entry.js → p-a4b6865d.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-c23e2501.system.entry.js → p-a89096d6.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-e3f9779a.system.entry.js → p-afca19b0.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-429c1d0c.entry.js → p-afdb4445.entry.js} +1 -1
- package/dist/zonos-elements/{p-4a84387a.system.entry.js → p-b34f1336.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-5818f4a7.entry.js → p-bba9af4c.entry.js} +1 -1
- package/dist/zonos-elements/{p-e62342c3.js → p-bd938f80.js} +1 -1
- package/dist/zonos-elements/{p-8ed0fad5.js → p-bdb3f7a2.js} +2 -2
- package/dist/zonos-elements/p-c85e988d.system.js +1 -0
- package/dist/zonos-elements/{p-e5f5b086.system.js → p-cc645667.system.js} +1 -1
- package/dist/zonos-elements/p-d13120f6.entry.js +1 -0
- package/dist/zonos-elements/{p-e80832cb.system.entry.js → p-e5f48239.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-22bb7836.system.js → p-e6168c82.system.js} +1 -1
- package/dist/zonos-elements/{p-e56f5954.system.js → p-e8a68ce7.system.js} +1 -1
- package/dist/zonos-elements/p-ed03b7fd.js +1 -0
- package/dist/zonos-elements/{p-b414b484.system.entry.js → p-edb0306c.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-e6feafc1.system.entry.js → p-f4e54f09.system.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/zonos-elements/p-0e83d193.js +0 -1
- package/dist/zonos-elements/p-6bcbe651.js +0 -1
- package/dist/zonos-elements/p-7cbbf483.system.js +0 -1
- package/dist/zonos-elements/p-ac7b93c9.js +0 -1
- package/dist/zonos-elements/p-da7e1143.system.entry.js +0 -1
- package/dist/zonos-elements/p-ddb27b4a.entry.js +0 -1
- package/dist/zonos-elements/p-fed19033.entry.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(o,e,t,n){function i(o){return o instanceof t?o:new t((function(e){e(o)}))}return new(t||(t=Promise))((function(t,r){function s(o){try{a(n.next(o))}catch(o){r(o)}}function l(o){try{a(n["throw"](o))}catch(o){r(o)}}function a(o){o.done?t(o.value):i(o.value).then(s,l)}a((n=n.apply(o,e||[])).next())}))};var __generator=this&&this.__generator||function(o,e){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,i,r,s;return s={next:l(0),throw:l(1),return:l(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function l(o){return function(e){return a([o,e])}}function a(l){if(n)throw new TypeError("Generator is already executing.");while(s&&(s=0,l[0]&&(t=0)),t)try{if(n=1,i&&(r=l[0]&2?i["return"]:l[0]?i["throw"]||((r=i["return"])&&r.call(i),0):i.next)&&!(r=r.call(i,l[1])).done)return r;if(i=0,r)l=[l[0]&2,r.value];switch(l[0]){case 0:case 1:r=l;break;case 4:t.label++;return{value:l[1],done:false};case 5:t.label++;i=l[1];l=[0];continue;case 7:l=t.ops.pop();t.trys.pop();continue;default:if(!(r=t.trys,r=r.length>0&&r[r.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!r||l[1]>r[0]&&l[1]<r[3])){t.label=l[1];break}if(l[0]===6&&t.label<r[1]){t.label=r[1];r=l;break}if(r&&t.label<r[2]){t.label=r[2];t.ops.push(l);break}if(r[2])t.ops.pop();t.trys.pop();continue}l=e.call(o,t)}catch(o){l=[6,o];i=0}finally{n=r=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:true}}};System.register(["./p-7261e245.system.js","./p-e25e0b4b.system.js","./p-271eebd3.system.js","./p-15ef7644.system.js","./p-23e7c655.system.js","./p-01174496.system.js","./p-bc7bf53e.system.js","./p-d938f42f.system.js"],(function(o){"use strict";var e,t,n,i,r,s,l,a,h,d,u,f,c,w,v,g,m,p,z,b,x,y;return{setters:[function(o){e=o.r;t=o.h;n=o.a;i=o.g},function(o){r=o.d},function(o){s=o.l;l=o.i;a=o.t;h=o.g;d=o.j;u=o.k;f=o.m;c=o.n;w=o.d},function(o){v=o.z;g=o.g;m=o.m},function(o){p=o.c},function(o){z=o.h;b=o.l},function(o){x=o.g},function(o){y=o.l}],execute:function(){var k=this;var _=function(o){return __awaiter(k,[o],void 0,(function(o){var e,t,n,i,r;var s=o.items,l=o.shipFrom,a=o.shipTo;return __generator(this,(function(o){switch(o.label){case 0:t={items:s,shipFrom:l,shipTo:a};return[4,z("/api/zonos-elements/check-item-restrictions",{body:t,method:"POST"})];case 1:n=o.sent(),i=n.errors,r=n.json;if(i.length||!r){b("Error fetching item restrictions: ".concat((e=i.find(Boolean))===null||e===void 0?void 0:e.message));return[2,[]]}return[2,r.filter(Boolean)]}}))}))};var L=function(o){return __awaiter(k,void 0,void 0,(function(){var e,t,n,i;return __generator(this,(function(r){switch(r.label){case 0:if(!o.length){return[2,[]]}e=s.selectedCountryCode;if(!e){b("Hello could not check item restrictions - No country code selected");return[2,[]]}t=o.map((function(o){return{description:o.description,name:o.title}}));return[4,_({items:t,shipFrom:"AD",shipTo:e})];case 1:n=r.sent();i=n.map((function(o){var e;var n=((e=t.filter((function(e){return e.description===o.itemDescription})).find(Boolean))===null||e===void 0?void 0:e.name)||"";return Object.assign(Object.assign({},o),{name:n})}));return[2,i]}}))}))};var O=function(o){var e=o===null||o===void 0?void 0:o.replace("www.","").replace("https://","");return e&&new RegExp(e).test(window.location.href)};var T=function(){var o=v.helloSettings,e=o.cartUrlPattern,t=o.homepageUrlPattern,n=o.productDetailUrlPattern,i=o.productListUrlPattern;if(O(e)){return"cart"}if(O(n)){return"productDetail"}if(O(i)){return"productList"}if(O(t)){return"home"}return""};var j=function(){var o,e;var t=v.helloSettings,n=t.productAddToCartElementSelector,i=t.productDescriptionElementSelector,r=t.productTitleElementSelector,s=t.restrictionBehavior;if(!r||!i){y("Hello could not check item restrictions - must provide title and description selectors.")}var a=r&&l(r)&&document.querySelectorAll(r)||[];var h=i&&l(i)&&document.querySelectorAll(i)||[];if(a.length!==h.length){y("Hello could not check item restrictions - Title and description selectors do not match");return[]}var d=s==="RESTRICT_AND_BLOCK";var u=d&&n&&l(n)&&document.querySelectorAll(n)||[];if(d&&u.length!==h.length){y('Hello could not disable "Add to cart" buttons - Title and add to cart selectors do not match')}var f=[];for(var c=0;c<a.length;c++){var w=a[c];var g=h[c];var m=u[c];if(w&&g){var p={cartButtonNode:m||null,description:((o=g.textContent)===null||o===void 0?void 0:o.trim())||"",title:((e=w.textContent)===null||e===void 0?void 0:e.trim())||""};f.push(p)}}return f};var D=":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}";var E=D;var S=3e3;var I=o("zonos_hello",function(){function o(o){var t=this;e(this,o);this.showPeekMessage=false;this.zonosStoreHelloSettings=v.helloSettings;this.showDialog=false;this.peekMessage="";this.initialUrl="";this.allRestrictedItems=[];this.allFoundProducts=[];this.productsOnPage=[];this.isHelloWidgetRendered=false;this.isMobile=false;this.getHelloPeekMessage=function(o){var e=v.currentHelloPage==="productDetail"||v.currentHelloPage==="productList";if(e&&t.allRestrictedItems.length){var n=a("click to learn more");var i=v.currentHelloPage==="productDetail"?a("Restricted item"):a("Restricted items found");return"".concat(i," - ").concat(n)}switch(v.currentHelloPage){case"cart":return a("Prepay duties and taxes at checkout");case"productList":case"productDetail":return a("See duty and tax thresholds");default:return a("Welcome to [storeName]",{storeName:o})}};this.enableShowPeekMessage=function(){if(t.peekMessage){t.showPeekMessage=true}};this.getNewItemRestrictions=function(o){return __awaiter(t,void 0,void 0,(function(){var e,t;return __generator(this,(function(n){switch(n.label){case 0:e=v.currentHelloPage==="productDetail"||v.currentHelloPage==="productList";if(!e||v.helloSettings.restrictionBehavior==="DISABLED"){return[2,[]]}return[4,L(o)];case 1:t=n.sent();return[2,t]}}))}))};this.triggerShowPeekMessage=function(){t.peekMessage=t.getHelloPeekMessage(v.organizationName);var o=v.helloSettings,e=o.peekMessageBehavior,n=o.peekMessageDelay;var i=n*1e3;if(e==="ENABLED"){setTimeout((function(){t.enableShowPeekMessage();var o=t.allRestrictedItems.some((function(o){return t.productsOnPage.some((function(e){return e.description===o.itemDescription}))}));if(!o){setTimeout((function(){t.showPeekMessage=false}),S)}}),i)}};this.disableAddToCartButtons=function(){if(t.productsOnPage.length){t.productsOnPage.forEach((function(o){var e,n;var i=t.allRestrictedItems.some((function(e){return e.itemDescription===o.description}));if(i){(e=o.cartButtonNode)===null||e===void 0?void 0:e.setAttribute("disabled","disabled")}else{(n=o.cartButtonNode)===null||n===void 0?void 0:n.removeAttribute("disabled")}}))}};this.handleItemRestrictions=function(){return __awaiter(t,void 0,void 0,(function(){var o,e;var t,n;var i=this;return __generator(this,(function(r){switch(r.label){case 0:this.productsOnPage=j();o=this.productsOnPage.filter((function(o){return!i.allFoundProducts.some((function(e){return e.title===o.title}))}));return[4,this.getNewItemRestrictions(o)];case 1:e=r.sent();(t=this.allRestrictedItems).push.apply(t,e);(n=this.allFoundProducts).push.apply(n,o);this.disableAddToCartButtons();return[2]}}))}))};this.reloadHelloData=function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(o){switch(o.label){case 0:return[4,this.handleItemRestrictions()];case 1:o.sent();this.triggerShowPeekMessage();return[2]}}))}))};this.handleProductCountChange=r((function(){var o=v.helloSettings.productTitleElementSelector;if(o){var e=j();if(t.allFoundProducts.length!==e.length&&window.location.href===t.initialUrl){if(!t.allFoundProducts.length){return}void t.reloadHelloData()}}}),1e3);this.watchProductCountChange=function(){var o;var e=new MutationObserver(t.handleProductCountChange);e.observe(document.body,{childList:true,subtree:true});(o=t.observerWatcher)===null||o===void 0?void 0:o.push(e)};this.watchPriceChange=function(){var o;var e=new MutationObserver((function(){return void t.displayCurrency()}));e.observe(document.body,{attributes:true,childList:true,subtree:true});(o=t.observerWatcher)===null||o===void 0?void 0:o.push(e)};this.updateHelloOnPageChange=function(){t.watchProductCountChange();setInterval((function(){if(window.location.href!==t.initialUrl){var o=t.initialUrl&&new URL(t.initialUrl);var e=o&&h(o.searchParams);if(e!==s.selectedCountryCode){t.allFoundProducts=[];t.allRestrictedItems=[];t.productsOnPage=[]}t.initialUrl=window.location.href;v.currentHelloPage=T();var n=new URL(window.location.href);var i=h(n.searchParams);if(!i){d(s.selectedCountryCode);return}void t.reloadHelloData()}}),1e3)};this.changeShowDialog=function(o){t.showDialog=o};this.shouldAnimateLeftDesktop=function(){var o=t.helloRef&&getComputedStyle(t.helloRef).position;if(t.helloRef&&o==="relative"){var e=x(t.helloRef);return e}};this.shouldRenderHello=function(o){if(o===void 0){o=true}var e,t;if(!s.localizationLoaded){return false}var n=v.helloSettings,i=n.countryDisplayRules,r=n.showForCountries;var l=i===null||i===void 0?void 0:i.widgetVisibility;var a=s.selectedCountryCode;var h=Array.isArray(r)?r:r!==null&&r!==void 0?r:l===null||l===void 0?void 0:l.behavior;if(o&&!s.isShippableCountry){y("Hello: not shippable country - Show for countries: ".concat(h))}if(Array.isArray(h)){return!!a&&h.includes(a)}var d;if(h==="ALL"){d=true}else{d=s.isShippableCountry}if(!d&&a&&((e=l===null||l===void 0?void 0:l.includedCountries)===null||e===void 0?void 0:e.includes(a))){d=true}if(d&&a&&((t=l===null||l===void 0?void 0:l.excludedCountries)===null||t===void 0?void 0:t.includes(a))){d=false}return d}}o.prototype.showDialogHandler=function(o){var e;if(o){var t=(e=this.helloElement)===null||e===void 0?void 0:e.parentElement;if(t&&t.parentElement===document.body){t.style.zIndex="2147483647";document.body.appendChild(t)}}};o.prototype.getCountryList=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){return[2,s.helloCountryList]}))}))};o.prototype.componentWillLoad=function(){var o=this;var e=setInterval((function(){return __awaiter(o,void 0,void 0,(function(){return __generator(this,(function(o){if(!this.helloRef){return[2]}if(v.loadedConfig){this.helloRef.setAttribute("data-zonos-hello-loaded","");this.updateHelloOnPageChange();this.watchPriceChange();this.handleAppearanceSettingsOverrideChange();clearInterval(e)}return[2]}))}))}),100)};o.prototype.disconnectedCallback=function(){var o;(o=this.observerWatcher)===null||o===void 0?void 0:o.forEach((function(o){return o.disconnect()}))};o.prototype.displayCurrency=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){if(v.helloSettings.currencyBehavior==="DISABLED"){return[2]}if(!s.exchangeRate){y("Could not display currency. Exchange rate and format data is not available.","warn");return[2]}u();return[2]}))}))};o.prototype.convertAndFormat=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,f(o)]}))}))};o.prototype.convert=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,c(o)]}))}))};o.prototype.format=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,w({amount:o})]}))}))};o.prototype.openHelloDialog=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.changeShowDialog(o);return[2]}))}))};o.prototype.handleResize=function(){this.isMobile=window.innerWidth<=768};o.prototype.handleHelloWidgetInitializedState=function(o){var e=o.countryCode,t=o.currencyCode;var n,i;if(this.isHelloWidgetRendered){return}if(s.selectedCountryCode&&typeof v.helloSettings.onInitSuccess==="function"){this.isHelloWidgetRendered=true;void((i=(n=v.helloSettings).onInitSuccess)===null||i===void 0?void 0:i.call(n,{countryCode:e,currencyCode:t}))}};o.prototype.getHelloLocation=function(){var o=this.mobileLocationOverride||v.helloSettings.mobileLocation;var e=v.helloSettings.desktopLocation;var t=this.isMobile;switch(true){case t:{var n=this.animateFromLeftOverride||(o===null||o===void 0?void 0:o.includes("LEFT"));var i=o===null||o===void 0?void 0:o.includes("TOP");return{isMobileWindow:t,isOnLeft:n,isOnTop:i,shouldFloat:!!o}}default:case!t:{var r=!v.helloSettings.anchorElementSelector&&!!e;var n=this.animateFromLeftOverride||(e===null||e===void 0?void 0:e.includes("LEFT"))||this.shouldAnimateLeftDesktop();var i=e===null||e===void 0?void 0:e.includes("TOP");return{isMobileWindow:t,isOnLeft:n,isOnTop:i,shouldFloat:r}}}};o.prototype.handleAppearanceSettingsOverrideChange=function(){var o;if((o=this.appearanceSettingsOverride)===null||o===void 0?void 0:o.theme){this.appearanceSettingsOverride.theme=g(this.appearanceSettingsOverride.theme)}};o.prototype.componentDidLoad=function(){this.isMobile=window.innerWidth<=768};o.prototype.render=function(){var o=this;var e,i;var r=(e=v.helloSettings.excludedUrlPatterns)===null||e===void 0?void 0:e.some((function(o){return o&&new RegExp(o).test(window.location.href)}));if(r){y("Hello is excluded on this url","warn");return null}var l=s.selectedCountryCode,a=s.targetCurrency;var h=this.getHelloLocation(),d=h.isOnLeft,u=h.isOnTop,f=h.shouldFloat;var c=m(v.appearance,this.appearanceSettingsOverride||null);var w=c.theme;var g=(i=this.allRestrictedItems)===null||i===void 0?void 0:i.filter((function(e){return o.productsOnPage.some((function(o){return o.description===e.itemDescription}))}));this.peekMessage=this.getHelloPeekMessage(v.organizationName);var z=this.shouldRenderHello()&&!!l;if(z&&!this.isHelloWidgetRendered){this.handleHelloWidgetInitializedState({countryCode:l,currencyCode:a})}return t(n,{class:"zonos--hello zonos--elements","data-theme":w},z&&t("div",{class:p(["zonos--hello-wrapper",f&&"zonos--hello-widget-float"])},t("button",{class:p(["zonos--hello-widget",this.showPeekMessage&&"zonos--hello-show-peek-message",this.mobileLocationOverride&&"zonos--hello-mobile-override",d&&"zonos--hello-widget-left zonos--hello-widget-animate-from-left",u&&"zonos--hello-widget-top",!!this.allRestrictedItems.length&&"zonos--hello-has-restrictions",f&&"zonos--hello-widget-float"]),onClick:function(){void o.changeShowDialog(!o.showDialog)},onMouseEnter:function(){return o.enableShowPeekMessage()},onMouseLeave:function(){return o.showPeekMessage=false},ref:function(e){return e&&(o.helloRef=e)},type:"button"},t("zonos-text",{class:"zonos--hello-message"},this.peekMessage),l&&t("div",{class:"zonos--hello-country-flag-wrapper"},t("zonos-country-flag",{class:"zonos--hello-country-flag",countryCode:l}))),t("div",{class:p(["zonos--hello-dialog-wrapper",this.mobileLocationOverride&&"zonos--hello-dialog-wrapper-mobile-override",d&&"zonos--hello-widget-left zonos--hello-widget-animate-from-left",u&&"zonos--hello-widget-top",f&&"zonos--hello-widget-float"]),style:{height:this.showDialog?"fit-content":"0px"}},t("zonos-hello-dialog",{animateFromLeftOverride:this.animateFromLeftOverride,appearanceSettings:c,isOpen:this.showDialog,mobileLocationOverride:this.mobileLocationOverride,restrictedItems:g,setIsOpen:this.changeShowDialog}))))};Object.defineProperty(o.prototype,"helloElement",{get:function(){return i(this)},enumerable:false,configurable:true});Object.defineProperty(o,"watchers",{get:function(){return{showDialog:["showDialogHandler"],appearanceSettingsOverride:["handleAppearanceSettingsOverrideChange"]}},enumerable:false,configurable:true});return o}());I.style=E}}}));
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(o,e,t,n){function i(o){return o instanceof t?o:new t((function(e){e(o)}))}return new(t||(t=Promise))((function(t,r){function s(o){try{a(n.next(o))}catch(o){r(o)}}function l(o){try{a(n["throw"](o))}catch(o){r(o)}}function a(o){o.done?t(o.value):i(o.value).then(s,l)}a((n=n.apply(o,e||[])).next())}))};var __generator=this&&this.__generator||function(o,e){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,i,r,s;return s={next:l(0),throw:l(1),return:l(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function l(o){return function(e){return a([o,e])}}function a(l){if(n)throw new TypeError("Generator is already executing.");while(s&&(s=0,l[0]&&(t=0)),t)try{if(n=1,i&&(r=l[0]&2?i["return"]:l[0]?i["throw"]||((r=i["return"])&&r.call(i),0):i.next)&&!(r=r.call(i,l[1])).done)return r;if(i=0,r)l=[l[0]&2,r.value];switch(l[0]){case 0:case 1:r=l;break;case 4:t.label++;return{value:l[1],done:false};case 5:t.label++;i=l[1];l=[0];continue;case 7:l=t.ops.pop();t.trys.pop();continue;default:if(!(r=t.trys,r=r.length>0&&r[r.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!r||l[1]>r[0]&&l[1]<r[3])){t.label=l[1];break}if(l[0]===6&&t.label<r[1]){t.label=r[1];r=l;break}if(r&&t.label<r[2]){t.label=r[2];t.ops.push(l);break}if(r[2])t.ops.pop();t.trys.pop();continue}l=e.call(o,t)}catch(o){l=[6,o];i=0}finally{n=r=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:true}}};System.register(["./p-7261e245.system.js","./p-e25e0b4b.system.js","./p-1523f6a8.system.js","./p-15ef7644.system.js","./p-23e7c655.system.js","./p-01174496.system.js","./p-bc7bf53e.system.js","./p-d938f42f.system.js"],(function(o){"use strict";var e,t,n,i,r,s,l,a,h,d,u,f,c,w,v,g,m,p,z,b,x,y;return{setters:[function(o){e=o.r;t=o.h;n=o.a;i=o.g},function(o){r=o.d},function(o){s=o.l;l=o.i;a=o.t;h=o.g;d=o.j;u=o.k;f=o.m;c=o.n;w=o.d},function(o){v=o.z;g=o.g;m=o.m},function(o){p=o.c},function(o){z=o.h;b=o.l},function(o){x=o.g},function(o){y=o.l}],execute:function(){var k=this;var _=function(o){return __awaiter(k,[o],void 0,(function(o){var e,t,n,i,r;var s=o.items,l=o.shipFrom,a=o.shipTo;return __generator(this,(function(o){switch(o.label){case 0:t={items:s,shipFrom:l,shipTo:a};return[4,z("/api/zonos-elements/check-item-restrictions",{body:t,method:"POST"})];case 1:n=o.sent(),i=n.errors,r=n.json;if(i.length||!r){b("Error fetching item restrictions: ".concat((e=i.find(Boolean))===null||e===void 0?void 0:e.message));return[2,[]]}return[2,r.filter(Boolean)]}}))}))};var L=function(o){return __awaiter(k,void 0,void 0,(function(){var e,t,n,i;return __generator(this,(function(r){switch(r.label){case 0:if(!o.length){return[2,[]]}e=s.selectedCountryCode;if(!e){b("Hello could not check item restrictions - No country code selected");return[2,[]]}t=o.map((function(o){return{description:o.description,name:o.title}}));return[4,_({items:t,shipFrom:"AD",shipTo:e})];case 1:n=r.sent();i=n.map((function(o){var e;var n=((e=t.filter((function(e){return e.description===o.itemDescription})).find(Boolean))===null||e===void 0?void 0:e.name)||"";return Object.assign(Object.assign({},o),{name:n})}));return[2,i]}}))}))};var O=function(o){var e=o===null||o===void 0?void 0:o.replace("www.","").replace("https://","");return e&&new RegExp(e).test(window.location.href)};var T=function(){var o=v.helloSettings,e=o.cartUrlPattern,t=o.homepageUrlPattern,n=o.productDetailUrlPattern,i=o.productListUrlPattern;if(O(e)){return"cart"}if(O(n)){return"productDetail"}if(O(i)){return"productList"}if(O(t)){return"home"}return""};var j=function(){var o,e;var t=v.helloSettings,n=t.productAddToCartElementSelector,i=t.productDescriptionElementSelector,r=t.productTitleElementSelector,s=t.restrictionBehavior;if(!r||!i){y("Hello could not check item restrictions - must provide title and description selectors.")}var a=r&&l(r)&&document.querySelectorAll(r)||[];var h=i&&l(i)&&document.querySelectorAll(i)||[];if(a.length!==h.length){y("Hello could not check item restrictions - Title and description selectors do not match");return[]}var d=s==="RESTRICT_AND_BLOCK";var u=d&&n&&l(n)&&document.querySelectorAll(n)||[];if(d&&u.length!==h.length){y('Hello could not disable "Add to cart" buttons - Title and add to cart selectors do not match')}var f=[];for(var c=0;c<a.length;c++){var w=a[c];var g=h[c];var m=u[c];if(w&&g){var p={cartButtonNode:m||null,description:((o=g.textContent)===null||o===void 0?void 0:o.trim())||"",title:((e=w.textContent)===null||e===void 0?void 0:e.trim())||""};f.push(p)}}return f};var D=":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}";var E=D;var S=3e3;var I=o("zonos_hello",function(){function o(o){var t=this;e(this,o);this.showPeekMessage=false;this.zonosStoreHelloSettings=v.helloSettings;this.showDialog=false;this.peekMessage="";this.initialUrl="";this.allRestrictedItems=[];this.allFoundProducts=[];this.productsOnPage=[];this.isHelloWidgetRendered=false;this.isMobile=false;this.getHelloPeekMessage=function(o){var e=v.currentHelloPage==="productDetail"||v.currentHelloPage==="productList";if(e&&t.allRestrictedItems.length){var n=a("click to learn more");var i=v.currentHelloPage==="productDetail"?a("Restricted item"):a("Restricted items found");return"".concat(i," - ").concat(n)}switch(v.currentHelloPage){case"cart":return a("Prepay duties and taxes at checkout");case"productList":case"productDetail":return a("See duty and tax thresholds");default:return a("Welcome to [storeName]",{storeName:o})}};this.enableShowPeekMessage=function(){if(t.peekMessage){t.showPeekMessage=true}};this.getNewItemRestrictions=function(o){return __awaiter(t,void 0,void 0,(function(){var e,t;return __generator(this,(function(n){switch(n.label){case 0:e=v.currentHelloPage==="productDetail"||v.currentHelloPage==="productList";if(!e||v.helloSettings.restrictionBehavior==="DISABLED"){return[2,[]]}return[4,L(o)];case 1:t=n.sent();return[2,t]}}))}))};this.triggerShowPeekMessage=function(){t.peekMessage=t.getHelloPeekMessage(v.organizationName);var o=v.helloSettings,e=o.peekMessageBehavior,n=o.peekMessageDelay;var i=n*1e3;if(e==="ENABLED"){setTimeout((function(){t.enableShowPeekMessage();var o=t.allRestrictedItems.some((function(o){return t.productsOnPage.some((function(e){return e.description===o.itemDescription}))}));if(!o){setTimeout((function(){t.showPeekMessage=false}),S)}}),i)}};this.disableAddToCartButtons=function(){if(t.productsOnPage.length){t.productsOnPage.forEach((function(o){var e,n;var i=t.allRestrictedItems.some((function(e){return e.itemDescription===o.description}));if(i){(e=o.cartButtonNode)===null||e===void 0?void 0:e.setAttribute("disabled","disabled")}else{(n=o.cartButtonNode)===null||n===void 0?void 0:n.removeAttribute("disabled")}}))}};this.handleItemRestrictions=function(){return __awaiter(t,void 0,void 0,(function(){var o,e;var t,n;var i=this;return __generator(this,(function(r){switch(r.label){case 0:this.productsOnPage=j();o=this.productsOnPage.filter((function(o){return!i.allFoundProducts.some((function(e){return e.title===o.title}))}));return[4,this.getNewItemRestrictions(o)];case 1:e=r.sent();(t=this.allRestrictedItems).push.apply(t,e);(n=this.allFoundProducts).push.apply(n,o);this.disableAddToCartButtons();return[2]}}))}))};this.reloadHelloData=function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(o){switch(o.label){case 0:return[4,this.handleItemRestrictions()];case 1:o.sent();this.triggerShowPeekMessage();return[2]}}))}))};this.handleProductCountChange=r((function(){var o=v.helloSettings.productTitleElementSelector;if(o){var e=j();if(t.allFoundProducts.length!==e.length&&window.location.href===t.initialUrl){if(!t.allFoundProducts.length){return}void t.reloadHelloData()}}}),1e3);this.watchProductCountChange=function(){var o;var e=new MutationObserver(t.handleProductCountChange);e.observe(document.body,{childList:true,subtree:true});(o=t.observerWatcher)===null||o===void 0?void 0:o.push(e)};this.watchPriceChange=function(){var o;var e=new MutationObserver((function(){return void t.displayCurrency()}));e.observe(document.body,{attributes:true,childList:true,subtree:true});(o=t.observerWatcher)===null||o===void 0?void 0:o.push(e)};this.updateHelloOnPageChange=function(){t.watchProductCountChange();setInterval((function(){if(window.location.href!==t.initialUrl){var o=t.initialUrl&&new URL(t.initialUrl);var e=o&&h(o.searchParams);if(e!==s.selectedCountryCode){t.allFoundProducts=[];t.allRestrictedItems=[];t.productsOnPage=[]}t.initialUrl=window.location.href;v.currentHelloPage=T();var n=new URL(window.location.href);var i=h(n.searchParams);if(!i){d(s.selectedCountryCode);return}void t.reloadHelloData()}}),1e3)};this.changeShowDialog=function(o){t.showDialog=o};this.shouldAnimateLeftDesktop=function(){var o=t.helloRef&&getComputedStyle(t.helloRef).position;if(t.helloRef&&o==="relative"){var e=x(t.helloRef);return e}};this.shouldRenderHello=function(o){if(o===void 0){o=true}var e,t;if(!s.localizationLoaded){return false}var n=v.helloSettings,i=n.countryDisplayRules,r=n.showForCountries;var l=i===null||i===void 0?void 0:i.widgetVisibility;var a=s.selectedCountryCode;var h=Array.isArray(r)?r:r!==null&&r!==void 0?r:l===null||l===void 0?void 0:l.behavior;if(o&&!s.isShippableCountry){y("Hello: not shippable country - Show for countries: ".concat(h))}if(Array.isArray(h)){return!!a&&h.includes(a)}var d;if(h==="ALL"){d=true}else{d=s.isShippableCountry}if(!d&&a&&((e=l===null||l===void 0?void 0:l.includedCountries)===null||e===void 0?void 0:e.includes(a))){d=true}if(d&&a&&((t=l===null||l===void 0?void 0:l.excludedCountries)===null||t===void 0?void 0:t.includes(a))){d=false}return d}}o.prototype.showDialogHandler=function(o){var e;if(o){var t=(e=this.helloElement)===null||e===void 0?void 0:e.parentElement;if(t&&t.parentElement===document.body){t.style.zIndex="2147483647";document.body.appendChild(t)}}};o.prototype.getCountryList=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){return[2,s.helloCountryList]}))}))};o.prototype.componentWillLoad=function(){var o=this;var e=setInterval((function(){return __awaiter(o,void 0,void 0,(function(){return __generator(this,(function(o){if(!this.helloRef){return[2]}if(v.loadedConfig){this.helloRef.setAttribute("data-zonos-hello-loaded","");this.updateHelloOnPageChange();this.watchPriceChange();this.handleAppearanceSettingsOverrideChange();clearInterval(e)}return[2]}))}))}),100)};o.prototype.disconnectedCallback=function(){var o;(o=this.observerWatcher)===null||o===void 0?void 0:o.forEach((function(o){return o.disconnect()}))};o.prototype.displayCurrency=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){if(v.helloSettings.currencyBehavior==="DISABLED"){return[2]}if(!s.exchangeRate){y("Could not display currency. Exchange rate and format data is not available.","warn");return[2]}u();return[2]}))}))};o.prototype.convertAndFormat=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,f(o)]}))}))};o.prototype.convert=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,c(o)]}))}))};o.prototype.format=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,w({amount:o})]}))}))};o.prototype.openHelloDialog=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.changeShowDialog(o);return[2]}))}))};o.prototype.handleResize=function(){this.isMobile=window.innerWidth<=768};o.prototype.handleHelloWidgetInitializedState=function(o){var e=o.countryCode,t=o.currencyCode;var n,i;if(this.isHelloWidgetRendered){return}if(s.selectedCountryCode&&typeof v.helloSettings.onInitSuccess==="function"){this.isHelloWidgetRendered=true;void((i=(n=v.helloSettings).onInitSuccess)===null||i===void 0?void 0:i.call(n,{countryCode:e,currencyCode:t}))}};o.prototype.getHelloLocation=function(){var o=this.mobileLocationOverride||v.helloSettings.mobileLocation;var e=v.helloSettings.desktopLocation;var t=this.isMobile;switch(true){case t:{var n=this.animateFromLeftOverride||(o===null||o===void 0?void 0:o.includes("LEFT"));var i=o===null||o===void 0?void 0:o.includes("TOP");return{isMobileWindow:t,isOnLeft:n,isOnTop:i,shouldFloat:!!o}}default:case!t:{var r=!v.helloSettings.anchorElementSelector&&!!e;var n=this.animateFromLeftOverride||(e===null||e===void 0?void 0:e.includes("LEFT"))||this.shouldAnimateLeftDesktop();var i=e===null||e===void 0?void 0:e.includes("TOP");return{isMobileWindow:t,isOnLeft:n,isOnTop:i,shouldFloat:r}}}};o.prototype.handleAppearanceSettingsOverrideChange=function(){var o;if((o=this.appearanceSettingsOverride)===null||o===void 0?void 0:o.theme){this.appearanceSettingsOverride.theme=g(this.appearanceSettingsOverride.theme)}};o.prototype.componentDidLoad=function(){this.isMobile=window.innerWidth<=768};o.prototype.render=function(){var o=this;var e,i;var r=(e=v.helloSettings.excludedUrlPatterns)===null||e===void 0?void 0:e.some((function(o){return o&&new RegExp(o).test(window.location.href)}));if(r){y("Hello is excluded on this url","warn");return null}var l=s.selectedCountryCode,a=s.targetCurrency;var h=this.getHelloLocation(),d=h.isOnLeft,u=h.isOnTop,f=h.shouldFloat;var c=m(v.appearance,this.appearanceSettingsOverride||null);var w=c.theme;var g=(i=this.allRestrictedItems)===null||i===void 0?void 0:i.filter((function(e){return o.productsOnPage.some((function(o){return o.description===e.itemDescription}))}));this.peekMessage=this.getHelloPeekMessage(v.organizationName);var z=this.shouldRenderHello()&&!!l;if(z&&!this.isHelloWidgetRendered){this.handleHelloWidgetInitializedState({countryCode:l,currencyCode:a})}return t(n,{class:"zonos--hello zonos--elements","data-theme":w},z&&t("div",{class:p(["zonos--hello-wrapper",f&&"zonos--hello-widget-float"])},t("button",{class:p(["zonos--hello-widget",this.showPeekMessage&&"zonos--hello-show-peek-message",this.mobileLocationOverride&&"zonos--hello-mobile-override",d&&"zonos--hello-widget-left zonos--hello-widget-animate-from-left",u&&"zonos--hello-widget-top",!!this.allRestrictedItems.length&&"zonos--hello-has-restrictions",f&&"zonos--hello-widget-float"]),onClick:function(){void o.changeShowDialog(!o.showDialog)},onMouseEnter:function(){return o.enableShowPeekMessage()},onMouseLeave:function(){return o.showPeekMessage=false},ref:function(e){return e&&(o.helloRef=e)},type:"button"},t("zonos-text",{class:"zonos--hello-message"},this.peekMessage),l&&t("div",{class:"zonos--hello-country-flag-wrapper"},t("zonos-country-flag",{class:"zonos--hello-country-flag",countryCode:l}))),t("div",{class:p(["zonos--hello-dialog-wrapper",this.mobileLocationOverride&&"zonos--hello-dialog-wrapper-mobile-override",d&&"zonos--hello-widget-left zonos--hello-widget-animate-from-left",u&&"zonos--hello-widget-top",f&&"zonos--hello-widget-float"]),style:{height:this.showDialog?"fit-content":"0px"}},t("zonos-hello-dialog",{animateFromLeftOverride:this.animateFromLeftOverride,appearanceSettings:c,isOpen:this.showDialog,mobileLocationOverride:this.mobileLocationOverride,restrictedItems:g,setIsOpen:this.changeShowDialog}))))};Object.defineProperty(o.prototype,"helloElement",{get:function(){return i(this)},enumerable:false,configurable:true});Object.defineProperty(o,"watchers",{get:function(){return{showDialog:["showDialogHandler"],appearanceSettingsOverride:["handleAppearanceSettingsOverrideChange"]}},enumerable:false,configurable:true});return o}());I.style=E}}}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,h as s,a as t,g as i}from"./p-ce75b047.js";import{l as a}from"./p-
|
|
1
|
+
import{r as o,h as s,a as t,g as i}from"./p-ce75b047.js";import{l as a}from"./p-a18adf27.js";import{f as e}from"./p-ed9385f4.js";import{c as n}from"./p-b4b7f705.js";import"./p-41dd1cb8.js";import"./p-0a377722.js";const h=class{constructor(s){o(this,s),this.countryCode=a.selectedCountryCode}render(){if(!this.el.shadowRoot||!this.countryCode)return null;const o=`https://zonos-store-assets.s3.amazonaws.com/images/elements-flags/${this.countryCode}.svg`,i=e();return s(t,{class:"zonos--elements",style:this.size?{"--zonos--font-family":i,height:`${this.size}px`,width:`${this.size}px`}:{"--zonos--font-family":i}},s("div",{class:n(["flag-container"])},s("div",{class:"flag-icon",style:{backgroundImage:`url(${o})`}})))}get el(){return i(this)}};h.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:-ms-inline-flexbox;display:inline-flex}:host .flag-container{position:relative;overflow:hidden;width:100%;height:100%}:host .flag-icon{position:absolute;top:0;left:0;width:100%;height:100%;background-position:center;background-repeat:no-repeat;background-size:cover}";export{h as zonos_country_flag}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,r,n,t){function o(e){return e instanceof n?e:new n((function(r){r(e)}))}return new(n||(n=Promise))((function(n,i){function a(e){try{u(t.next(e))}catch(e){i(e)}}function s(e){try{u(t["throw"](e))}catch(e){i(e)}}function u(e){e.done?n(e.value):o(e.value).then(a,s)}u((t=t.apply(e,r||[])).next())}))};var __generator=this&&this.__generator||function(e,r){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,o,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(n=0)),n)try{if(t=1,o&&(i=s[0]&2?o["return"]:s[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;if(o=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:n.label++;return{value:s[1],done:false};case 5:n.label++;o=s[1];s=[0];continue;case 7:s=n.ops.pop();n.trys.pop();continue;default:if(!(i=n.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){n.label=s[1];break}if(s[0]===6&&n.label<i[1]){n.label=i[1];i=s;break}if(i&&n.label<i[2]){n.label=i[2];n.ops.push(s);break}if(i[2])n.ops.pop();n.trys.pop();continue}s=r.call(e,n)}catch(e){s=[6,e];o=0}finally{t=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,r,n){if(n||arguments.length===2)for(var t=0,o=r.length,i;t<o;t++){if(i||!(t in r)){if(!i)i=Array.prototype.slice.call(r,0,t);i[t]=r[t]}}return e.concat(i||Array.prototype.slice.call(r))};System.register(["./p-15ef7644.system.js","./p-271eebd3.system.js","./p-d938f42f.system.js","./p-01174496.system.js","./p-61be7d98.system.js","./p-8bce79f4.system.js"],(function(e){"use strict";var r,n,t,o,i,a,s,u,d,l,c,v,f,m,p,h,w,g,y;return{setters:[function(e){r=e.c;n=e.z},function(e){t=e.s;o=e.l;i=e.e;a=e.t;s=e.f;u=e.b},function(e){d=e.l;l=e.b},function(e){c=e.h;v=e.l;f=e.f;m=e.g;p=e.a;h=e.s;w=e.j},function(e){g=e.i},function(e){y=e.g}],execute:function(){var b=this;var _=function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o;return __generator(this,(function(i){switch(i.label){case 0:if(!t.checkoutSessionId){return[2,{errors:[{message:"No checkout session id found"}],json:null}]}e=new URLSearchParams;e.set("checkoutSessionId",t.checkoutSessionId);return[4,c("/api/zonos-elements/get-checkout-session?".concat(e.toString()))];case 1:r=i.sent(),n=r.errors,o=r.json;return[2,{errors:n,json:o}]}}))}))};var S=r((function(){return{amountToApply:null,appliedAmount:null,availableBalance:null,error:null,isApplying:false,isEnabled:false,orderIdCreated:null,remainingBalance:null,useFullBalance:true}})),O=S.onChange,A=S.reset,C=S.state;e("N",C);var k=e("O",(function(){A()}));var I=function(e){d("Store credit balance from session","info",e);C.availableBalance=e};var T=e("Z",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,t,o,i;return __generator(this,(function(a){switch(a.label){case 0:return[4,_()];case 1:n=a.sent(),t=n.errors,o=n.json;if(t.length||!o){v("Failed to refresh store credit balance");return[2]}i=(r=(e=o.checkoutSession.customerProfile)===null||e===void 0?void 0:e.storeCreditBalance)!==null&&r!==void 0?r:null;I(i);return[2]}}))}))}));var E=e("w",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o,i,a,s,u,s;return __generator(this,(function(l){switch(l.label){case 0:r=t.checkoutSessionId;if(!r){n="No checkout session found";v(n);C.error=n;return[2,{error:n,success:false}]}d("Applying store credit","info",{checkoutSessionId:r});C.isApplying=true;C.error=null;l.label=1;case 1:l.trys.push([1,3,,4]);return[4,c("/api/zonos-elements/store-credit/apply",{body:{checkoutSessionId:r},method:"POST"})];case 2:o=l.sent(),i=o.errors,a=o.json;if(i.length>0||!a){s=((e=i[0])===null||e===void 0?void 0:e.message)||"Failed to apply store credit";v(s);C.error=s;C.isApplying=false;return[2,{error:s,success:false}]}C.appliedAmount=a.amountApplied;C.remainingBalance=a.remainingBalance;C.isApplying=false;d("Store credit applied","info",{amountApplied:a.amountApplied,remainingBalance:a.remainingBalance});return[2,{error:null,success:true}];case 3:u=l.sent();s=u instanceof Error?u.message:"Failed to apply store credit";v(s);C.error=s;C.isApplying=false;return[2,{error:s,success:false}];case 4:return[2]}}))}))}));var N=e("V",(function(e){C.isEnabled=e;C.error=null;if(!e){C.amountToApply=null}}));var j=e("Y",(function(e){if(e===null){C.amountToApply=null;C.error=null;return}if(e<=0){C.error="Amount must be greater than zero";return}if(C.availableBalance!==null&&e>C.availableBalance){C.error="Amount exceeds available balance";return}var r=ze.total+(ze.storeCredit||0);if(e>r){C.error="Amount exceeds order total";return}C.error=null;C.amountToApply=e}));var P=e("W",(function(e){C.useFullBalance=e;C.error=null;if(e&&C.availableBalance!==null){var r=ze.total+(ze.storeCredit||0);var n=Math.min(C.availableBalance,r);C.amountToApply=n}else if(!e){C.amountToApply=null}}));var D=function(){if(!C.isEnabled||C.amountToApply===null){return{mode:"NONE"}}if(C.useFullBalance){return{mode:"FULL"}}return{amount:C.amountToApply,mode:"PARTIAL"}};var L=e("F",(function(){if(!C.isEnabled||C.availableBalance===null){return 0}if(C.useFullBalance){return Math.min(C.availableBalance,ze.total+(ze.storeCredit||0))}return C.amountToApply||0}));var x=e("x",(function(){return C.amountToApply!==null&&C.amountToApply>0&&ze.storeCredit>0&&ze.total<=0}));var R=e("z",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o,i,a,s,u,l,f,m,l;return __generator(this,(function(p){switch(p.label){case 0:o=t.checkoutSessionId;if(!o){i="No checkout session found";v(i);C.error=i;return[2,{error:i,orderId:null,success:false}]}d("Creating store credit order","info",{checkoutSessionId:o});p.label=1;case 1:p.trys.push([1,3,,4]);return[4,c("/api/zonos-elements/store-credit/order-create",{body:{checkoutSessionId:o},method:"POST"})];case 2:a=p.sent(),s=a.errors,u=a.json;if(s.length>0||!u){l=((e=s[0])===null||e===void 0?void 0:e.message)||"Failed to create store credit order";v(l);C.error=l;return[2,{error:l,orderId:null,success:false}]}f=((n=(r=u.checkoutSessionStoreCreditOrderCreate)===null||r===void 0?void 0:r.order)===null||n===void 0?void 0:n.id)||null;C.orderIdCreated=f;d("Store credit order created","info",{orderId:f});return[2,{error:null,orderId:f,success:true}];case 3:m=p.sent();l=m instanceof Error?m.message:"Failed to create store credit order";v(l);C.error=l;return[2,{error:l,orderId:null,success:false}];case 4:return[2]}}))}))}));var U=e("Q",(function(e){var r=e.firstName,n=e.lastName,t=e.name;var o;if(!t&&!r&&!n){return{firstName:"",lastName:""}}var i=(t===null||t===void 0?void 0:t.split(/\s+/))||[];var a=(r===null||r===void 0?void 0:r.trim())||((o=i[0])===null||o===void 0?void 0:o.trim())||"";var s=(n===null||n===void 0?void 0:n.trim())||i.slice(1).join(" ").trim()||"";return{firstName:a,lastName:s}}));var z=function(e){var r=e.currentAddress,n=e.translatedAddress;var t,o,i,a,s,u;var d=r.value.address,l=d.city,c=d.country,v=d.line1,f=d.line2,m=d.postal_code,p=d.state;var h=r.value.name||[r.value.firstName,r.value.lastName].join(" ");return{city:((t=n.city)===null||t===void 0?void 0:t[l])||l,country:c,line1:((o=n.line1)===null||o===void 0?void 0:o[v])||v,line2:((i=n.line2)===null||i===void 0?void 0:i[f||""])||f||"",name:((a=n.name)===null||a===void 0?void 0:a[h])||h,phone:r.value.phone||"",postal_code:((s=n.postal_code)===null||s===void 0?void 0:s[m])||m,state:((u=n.state)===null||u===void 0?void 0:u[p])||p}};var B=function(e){var r;var n=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";var a=ne.stripeLinkEventData;var s=ne.stripeAddressEventData;var u=ne.stripeShippingSameAsBilling?ne.stripeAddressEventData:ne.stripeBillingAddressEventData;if(!s||!u){throw new Error("Missing stripe address data")}var d=z({currentAddress:s,translatedAddress:ne.translatedAddress.address});var l=U({name:d.name}),c=l.firstName,v=l.lastName;var f=z({currentAddress:u,translatedAddress:ne.translatedAddress.address});var m=U({name:f.name}),p=m.firstName,h=m.lastName;var w=i()||"US";return{billingAddress:{addressLine1:f.line1,addressLine2:f.line2||"",city:f.city,country:f.country,postalCode:f.postal_code,state:f.state},billingContact:{firstName:p,lastName:h,phone:f.phone},cartCurrencyCode:(r=ze.items[0])===null||r===void 0?void 0:r.currencyCode,cartId:e,checkoutSessionCountry:w||o.selectedCountryCode||undefined,checkoutSessionId:t.checkoutSessionId||"",contact:{companyName:ne.companyName,email:a===null||a===void 0?void 0:a.value.email,firstName:c,lastName:v,phone:d.phone},isTest:!!n,landedCostAdjustments:ze.promoCode?[{amount:0,productId:null,promoCode:ze.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToShortAddressCode:ne.shortAddressCode,shipToTaxId:ne.taxId,shippingAddress:{addressLine1:d.line1,addressLine2:d.line2,city:d.city,country:d.country,postalCode:d.postal_code,state:d.state}}};var F=function(){var e=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";var r=ne.stripeLinkEventData;var n=ne.stripeAddressEventData;var o=ne.stripeShippingSameAsBilling?ne.stripeAddressEventData:ne.stripeBillingAddressEventData;d({stripeAddressData:n,stripeBillingAddressData:o},"info");if(!n||!o){throw new Error("Missing stripe address data")}var i=z({currentAddress:n,translatedAddress:ne.translatedAddress.address});var a=U({name:i.name}),s=a.firstName,u=a.lastName;var l=z({currentAddress:o,translatedAddress:ne.translatedAddress.address});var c=U({name:l.name}),v=c.firstName,f=c.lastName;var m=ze.adjustments.map((function(e){return{amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}}));var p=ze.promoCode?__spreadArray([{amount:0,productId:null,promoCode:ze.promoCode,sku:null,type:"PROMO_CODE"}],m,true):m;return{billingAddress:{addressLine1:l.line1,addressLine2:l.line2||"",city:l.city,country:l.country,postalCode:l.postal_code,state:l.state},billingContact:{firstName:v,lastName:f,phone:l.phone},checkoutSessionId:t.checkoutSessionId||"",contact:{companyName:ne.companyName,email:r===null||r===void 0?void 0:r.value.email,firstName:s,lastName:u,phone:i.phone},isTest:e,items:ze.items,landedCostAdjustments:p,shipToShortAddressCode:ne.shortAddressCode,shipToTaxId:ne.taxId,shippingAddress:{addressLine1:i.line1,addressLine2:i.line2,city:i.city,country:i.country,postalCode:i.postal_code,state:i.state}}};var J=function(e){return __awaiter(b,void 0,void 0,(function(){var r,n,t,o,i,a,s,u,d,l;return __generator(this,(function(v){switch(v.label){case 0:a=F();return[4,e({billingAddress:a.billingAddress,billingContact:a.billingContact,checkoutSessionId:a.checkoutSessionId,contact:a.contact,landedCostAdjustments:a.landedCostAdjustments,publicCredential:window.Zonos.zonosApiKey||"",shippingAddress:a.shippingAddress,zonosApiRoute:f["vercel"]},{promoCode:ze.promoCode})];case 1:s=v.sent();if(!s||!((r=s.checkoutSessionWorkflow)===null||r===void 0?void 0:r.length)&&((n=s.errors)===null||n===void 0?void 0:n.length)){throw new Error("Failed to build landed cost: ".concat(((o=(t=s===null||s===void 0?void 0:s.errors)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.message)||"Unknown error"))}return[4,c("/api/zonos-elements/validate-landed-cost",{body:s,headers:{"Content-Type":"application/json"},method:"POST"})];case 2:u=v.sent(),d=u.errors,l=u.json;if(!l||d.length){throw new Error("Invalid landed cost object: ".concat(((i=d.find(Boolean))===null||i===void 0?void 0:i.message)||"Unknown error"))}return[2,s]}}))}))};var M=function(e){return __awaiter(b,void 0,void 0,(function(){var r,t,o,i,a,s,u;return __generator(this,(function(d){switch(d.label){case 0:t=n.checkoutSettings.buildLandedCost;if(!t)return[3,2];return[4,J(t)];case 1:o=d.sent();return[2,o];case 2:return[4,c("/api/zonos-elements/calculate-landed-cost",{body:F(),method:"POST",signal:e===null||e===void 0?void 0:e.signal})];case 3:i=d.sent(),a=i.errors,s=i.json;if(a.length||!s){u=((r=a[0])===null||r===void 0?void 0:r.message)==="The user aborted a request.";if(u){throw new Error("The landed cost calculation request was aborted to initiate a new one.")}a.forEach((function(e){console.warn("Error calculating landed cost: ".concat(e.message))}));if(!s){throw new Error("Failed to calculate landed cost")}return[2,s]}return[2,s]}}))}))};var q=function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,t,o,i,a,s,u,d,l;var v=e.abortController,f=e.cartId;return __generator(this,(function(e){switch(e.label){case 0:return[4,c("/api/zonos-elements/cart-calculate-landed-cost",{body:B(f),method:"POST",signal:v===null||v===void 0?void 0:v.signal})];case 1:a=e.sent(),s=a.errors,u=a.json;if(s.length||!u){d=typeof((r=s[0])===null||r===void 0?void 0:r.message)==="string"&&(((n=s[0])===null||n===void 0?void 0:n.message)==="The user aborted a request."||((t=s[0])===null||t===void 0?void 0:t.message.includes("signal is aborted"))||((o=s[0])===null||o===void 0?void 0:o.message.includes("The operation was aborted"))||((i=s[0])===null||i===void 0?void 0:i.message.includes("Fetch is aborted")));l=d?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost";throw new Error(l)}return[2,u]}}))}))};var W=undefined&&undefined.__rest||function(e,r){var n={};for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0)n[t]=e[t];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var o=0,t=Object.getOwnPropertySymbols(e);o<t.length;o++){if(r.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o]))n[t[o]]=e[t[o]]}return n};var Y=function(e){return __awaiter(b,void 0,void 0,(function(){var r,n,t,o,i;return __generator(this,(function(a){switch(a.label){case 0:r=window.Zonos.cartId;if(!!r)return[3,2];return[4,M(e)];case 1:n=a.sent();return[2,n];case 2:return[4,q({abortController:e,cartId:r})];case 3:t=a.sent(),o=t.cartWorkflow,i=W(t,["cartWorkflow"]);return[2,Object.assign(Object.assign({},i),{itemCreateWorkflow:o.items})]}}))}))};var H=e("t",(function(e){return __awaiter(b,[e],void 0,(function(e){var r,t,i,a,s,u,d,v,f;var w=e.checkoutSessionId,g=e.eventName,y=e.metadata;return __generator(this,(function(e){switch(e.label){case 0:i=Date.now();a=__spreadArray([],window.Zonos.trackEventLogs,true);window.Zonos.trackEventLogs.push({checkoutSessionId:w,eventCreated:i,eventName:g});s=window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!((r=window.Zonos)===null||r===void 0?void 0:r.zonosQaUrl)||!!((t=window.Zonos)===null||t===void 0?void 0:t.debug);u=m()||p();if((u||s)&&!window.Zonos.zonosConversionTest){return[2]}d=o.selectedCountryCode;v=n.organizationId;if(!w){void h({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(g,'" - No checkout session id found')],metadata:{allLogs:l,checkoutSessionId:w,eventName:g,metadata:y,organizationId:v,trackEventLogs:a}});return[2]}if(!v){void h({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(g,'" - No organization id found')],metadata:{allLogs:l,checkoutSessionId:w,eventName:g,metadata:y,organizationId:v,trackEventLogs:a}})}f={checkoutSessionId:w,countryCode:d,eventCreated:i,eventName:g,metadata:Object.assign(Object.assign({},y),{trackEventLogs:a}),organizationId:v};return[4,c("/api/zonos-elements/track-conversion-event",{body:f,method:"POST"})];case 1:e.sent();return[2]}}))}))}));var K=function(e){var r=e.address,n=e.invalidAdddressList;if(!r){return}if(!n){return}var t={};if(n.city){t.city=r.city}if(n.line1){t.line1=r.line1}if(n.line2){t.line2=r.line2}if(n.postal_code){t.postal_code=r.postal_code}if(n.state){t.state=r.state}if(n.name){t.name=r.name}return Object.keys(t).length?t:undefined};var G=function(e){var r=e.addressInvalidCharactersList,n=e.billingAddressInvalidCharactersList,t=e.stripeAddressEventData,o=e.stripeBillingAddressEventData,i=e.stripeShippingSameAsBilling;var a=!!(t===null||t===void 0?void 0:t.complete);var s=i?a:!!(o===null||o===void 0?void 0:o.complete);if(!a||!s){return null}if(!r&&!n){return null}var u=t.value;var d=(o===null||o===void 0?void 0:o.value)||null;var l=U({firstName:u.firstName,lastName:u.lastName,name:u.name}),c=l.firstName,v=l.lastName;var f="".concat(c," ").concat(v);var m=U({firstName:d===null||d===void 0?void 0:d.firstName,lastName:d===null||d===void 0?void 0:d.lastName,name:(d===null||d===void 0?void 0:d.name)||""}),p=m.firstName,h=m.lastName;var w=p&&h?"".concat(p," ").concat(h):"";var g=u.address;var y=d===null||d===void 0?void 0:d.address;return{address:K({address:Object.assign(Object.assign({},g),{name:f}),invalidAdddressList:r}),billingAddress:!i?K({address:y?Object.assign(Object.assign({},y),{name:w}):null,invalidAdddressList:n}):undefined,destinationCountry:g.country}};var V=e("U",(function(e){var r=e.sort((function(e,r){return e.amount-r.amount}));return r}));var Z=e("y",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,t;return __generator(this,(function(o){switch(o.label){case 0:return[4,_()];case 1:r=o.sent(),n=r.errors,t=r.json;if(n.length||!t){v("Failed to retrieve checkout session info before confirming payment ",n);void h({endpoint:"validateCheckoutSession",errors:n.map((function(e){return e.message})),metadata:{allLogs:l}});return[2,{errorMessage:a("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:false}]}if(!((e=t.checkoutSession.landedCost)===null||e===void 0?void 0:e.id)){v("Landed cost is not found in the checkout session before confirming payment.");void h({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:l}});return[2,{errorMessage:a('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:false}]}return[2,{errorMessage:"",valid:true}]}}))}))}));var Q=function(e){var r=e.theme;var t={".AccordionItem":{color:"var(--colorText)"},".AccordionItem--selected":{color:"var(--colorText)"},".Action":{color:"var(--colorText)"},".Input":{boxShadow:"none",fontSize:n.appearance.fontSizeInputValue?"".concat(n.appearance.fontSizeInputValue,"px"):undefined,padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"},".Label--resting":{fontSize:n.appearance.fontSizeInputLabel?"".concat(n.appearance.fontSizeInputLabel,"px"):undefined},".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"}};switch(r){case"DARK":{return Object.assign(Object.assign({},t),{".Action":Object.assign(Object.assign({},t[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},t[".PickerItem--new"]),{color:"white"})})}default:return t}};var X=function(e){var r=e.borderStyle,n=e.theme;switch(n){case"DARK":return{borderRadius:y({overrideBorderStyle:r}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"};default:return{borderRadius:y({overrideBorderStyle:r}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"}}};var $=r((function(){return{checkoutSettlementCurrency:"USD",clientSecret:sessionStorage.getItem("zonos--client-secret")||"",companyName:"",companyNameUsedWhenAsyncAddressUpdate:"",customAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:false,state:""},customBillingAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:false,state:""},customErrorMessage:null,customerProfile:null,fetchingLandedCostAbortController:null,hasPaymentError:false,isFetchingLandedCost:false,isFetchingSession:false,partyBillingId:null,partyShippingId:null,shortAddressCode:"",shouldInventoryRefund:false,shouldRenderPayInUsdButton:false,skipPaymentIntent:new URLSearchParams(window.location.search).get("skipPaymentIntent")==="0"?false:true,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:true,taxId:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}})),ee=$.onChange,re=$.reset,ne=$.state;e({E:ee,b:ne});var te=function(e){var r=e.clientSecret,t=e.overrideBorderRadius,i=e.overridePrimaryColor,a=e.overrideSecondaryColor,s=e.overrideTheme,u=e.paypalEnabled;var d=i||n.appearance.colorPrimary;var l=a||n.appearance.colorSecondary;var c=window.Zonos.isCollect||window.Zonos.isInvoice?n.appearance.theme==="DARK":d&&g(d);var v=c?"night":"flat";var f=s==="DARK"?"night":"flat";var m=u?["external_paypal"]:[];return{appearance:{labels:"floating",rules:Object.assign({},Q({theme:s||"LIGHT"})),theme:s?f:v,variables:Object.assign(Object.assign({},X({borderStyle:t,theme:"LIGHT"})),{colorPrimary:l})},clientSecret:r||undefined,customerSessionClientSecret:ne.stripeCustomerSessionClientSecret||undefined,externalPaymentMethodTypes:__spreadArray([],m,true),locale:o.selectedLocale}};var oe=e("o",(function(){window.sessionStorage.removeItem("zonos--bigcommerce-domestic-checkout-shipping")}));var ie=e("a",(function(e){window.sessionStorage.setItem("zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))}));var ae=e("s",(function(){var e=window.sessionStorage.getItem("zonos--bigcommerce-domestic-checkout-shipping");return w(e)}));var se=e("i",(function(e){return __awaiter(b,void 0,void 0,(function(){var r,n,t,o,i;return __generator(this,(function(a){t=ne.clientSecret;if(!ne.stripe){d("Skip. Stripe is not initialized");return[2]}o=te({clientSecret:t,overrideBorderRadius:e===null||e===void 0?void 0:e.overrideBorderRadius,overridePrimaryColor:e===null||e===void 0?void 0:e.overridePrimaryColor,overrideSecondaryColor:e===null||e===void 0?void 0:e.overrideSecondaryColor,overrideTheme:e===null||e===void 0?void 0:e.overrideTheme,paypalEnabled:e===null||e===void 0?void 0:e.paypalEnabled});i=JSON.stringify(o)===JSON.stringify(ne.stripeElementsOptions);if(!ne.stripeElements||!ne.stripeElementsForBillingAddress){ne.stripeElementsForBillingAddress=(r=ne.stripe)===null||r===void 0?void 0:r.elements(o);d("Stripe elements for billing address initialized");ne.stripeElements=(n=ne.stripe)===null||n===void 0?void 0:n.elements(o);ne.stripeElementsOptions=o;d("Stripe elements initialized");return[2]}if(!i){ne.stripeElements.update(o);ne.stripeElementsForBillingAddress.update(o);ne.stripeElementsOptions=o;void ne.stripeElements.fetchUpdates()}d("Stripe elements updated");return[2]}))}))}));var ue=e("C",(function(){sessionStorage.removeItem("zonos--client-secret");re();ne.stripe=window.Zonos.stripe}));var de=function(){var e,r,n,t;var o=JSON.stringify((e=ne.stripeAddressUsedWhenValidatingAddress)===null||e===void 0?void 0:e.value)!==JSON.stringify((r=ne.stripeAddressEventData)===null||r===void 0?void 0:r.value);var i=!ne.stripeShippingSameAsBilling&&JSON.stringify((n=ne.stripeBillingAddressEventData)===null||n===void 0?void 0:n.value)!==JSON.stringify((t=ne.stripeBillingAddressUsedWhenValidatingAddress)===null||t===void 0?void 0:t.value);return o||i};var le=function(){var e,r,n,t,o,i,a,s;var u=(e=ze.partiesData.find((function(e){return e.type==="DESTINATION"})))===null||e===void 0?void 0:e.id;var d=(r=ze.partiesData.find((function(e){return e.type==="PAYOR"})))===null||r===void 0?void 0:r.id;if(!u||!d){return false}if(ne.partyShippingId!==u||ne.partyBillingId!==d){return true}var l=JSON.stringify((n=ne.stripeLinkUsedWhenFetchingLC)===null||n===void 0?void 0:n.value)!==JSON.stringify((t=ne.stripeLinkEventData)===null||t===void 0?void 0:t.value);var c=JSON.stringify((o=ne.stripeAddressUsedWhenAsyncAddressUpdate)===null||o===void 0?void 0:o.value)!==JSON.stringify((i=ne.stripeAddressEventData)===null||i===void 0?void 0:i.value);var v=!ne.stripeShippingSameAsBilling&&JSON.stringify((a=ne.stripeBillingAddressUsedWhenAsyncAddressUpdate)===null||a===void 0?void 0:a.value)!==JSON.stringify((s=ne.stripeBillingAddressEventData)===null||s===void 0?void 0:s.value);var f=ne.taxIdUsedWhenAsyncAddressUpdate!==ne.taxId;var m=ne.companyNameUsedWhenAsyncAddressUpdate!==ne.companyName;return l||c||v||f||m};var ce=e("G",(function(e){var r=e.address,n=e.firstName,o=e.lastName,i=e.name,a=e.phone;var s=U({firstName:n,lastName:o,name:i}),u=s.firstName,d=s.lastName;if(!u||!d){void h({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:t.checkoutSessionId,firstName:n,lastName:o,name:i}})}if(!a){void h({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:t.checkoutSessionId,phone:a}})}return{city:r.city,country:r.country,firstName:u,lastName:d,line1:r.line1,line2:r.line2,phone:a||"",postal_code:r.postal_code,state:r.state}}));var ve=e("R",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o,i,a,s,u,d,f,m,p;return __generator(this,(function(w){switch(w.label){case 0:if(!((e=ne.stripeAddressEventData)===null||e===void 0?void 0:e.complete)||!ne.stripeShippingSameAsBilling&&!((r=ne.stripeBillingAddressEventData)===null||r===void 0?void 0:r.complete)||!ne.stripeBillingAddressEventData){return[2,{partiesCreated:false}]}if(!ze.landedCostData){return[2,{partiesCreated:false}]}i=(n=ze.landedCostData.find(Boolean))===null||n===void 0?void 0:n.landedCost.rootId;if(!i){void h({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:t.checkoutSessionId}});return[2,{partiesCreated:false}]}a=le();if(!a){return[2,{partiesCreated:false}]}s=ce({address:ne.stripeAddressEventData.value.address,firstName:ne.stripeAddressEventData.value.firstName,lastName:ne.stripeAddressEventData.value.lastName,name:ne.stripeAddressEventData.value.name,phone:ne.stripeAddressEventData.value.phone});u=ne.stripeShippingSameAsBilling?s:ce({address:ne.stripeBillingAddressEventData.value.address,firstName:ne.stripeBillingAddressEventData.value.firstName,lastName:ne.stripeBillingAddressEventData.value.lastName,name:ne.stripeBillingAddressEventData.value.name,phone:ne.stripeBillingAddressEventData.value.phone});d=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";return[4,c("/api/zonos-elements/create-parties",{body:{address:s,billingAddress:u,companyName:ne.companyName,email:((o=ne.stripeLinkEventData)===null||o===void 0?void 0:o.value.email)||"",isTest:d,rootId:i,shortAddressCode:ne.shortAddressCode,taxId:ne.taxId},method:"POST"})];case 1:f=w.sent(),m=f.errors,p=f.json;if(m.length||!p){v("Error occurs when creating parties",JSON.stringify(m,null,2));void h({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:t.checkoutSessionId,errors:m,json:p}});return[2,{partiesCreated:false}]}ne.companyNameUsedWhenAsyncAddressUpdate=ne.companyName;ne.stripeAddressUsedWhenAsyncAddressUpdate=ne.stripeAddressEventData;ne.stripeBillingAddressUsedWhenAsyncAddressUpdate=ne.stripeBillingAddressEventData;ne.taxIdUsedWhenAsyncAddressUpdate=ne.taxId;ne.partyBillingId=p.billToPartyId;ne.partyShippingId=p.shipToPartyId;ze.partiesData=ze.partiesData.map((function(e){if(e.type==="DESTINATION"&&e.id!==p.shipToPartyId){return Object.assign(Object.assign({},e),{id:p.shipToPartyId})}if(e.type==="PAYOR"&&e.id!==p.billToPartyId){return Object.assign(Object.assign({},e),{id:p.billToPartyId})}return e}));return[2,{partiesCreated:true}]}}))}))}));var fe=function(e){return{countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}};var me=function(){var e,r;var n=JSON.stringify((e=ne.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((r=ne.stripeLinkEventData)===null||r===void 0?void 0:r.value);var t=ne.stripeAddressEventData&&JSON.stringify(fe(ne.stripeAddressEventData.value))!==JSON.stringify(ne.stripeAddressUsedWhenFetchingLC);var o=!ne.stripeShippingSameAsBilling&&ne.stripeBillingAddressEventData&&JSON.stringify(fe(ne.stripeBillingAddressEventData.value))!==JSON.stringify(ne.stripeBillingAddressUsedWhenFetchingLC);return n||t||o};var pe=function(){var e;var r=ze.landedCostData&&((e=ze.landedCostData.find(Boolean))===null||e===void 0?void 0:e.subtotals.items)!==ze.subtotal;var n=me();d("isPrefetchInfoOutdated","info",{isAddressOutdated:n});return!ze.landedCostData&&!ne.isFetchingLandedCost||n||r};var he=function(e){var r,t;var o=(r=n.genericSettings)===null||r===void 0?void 0:r.countryFields;var i=(t=n.genericSettings)===null||t===void 0?void 0:t.stripeCountryFieldLabels;var a=i&&e in i?i[e]:null;var s=o&&e in o?o[e]:null;if(ze.addressFormRenderType==="stripe"){return a||s}return s};var we=function(){var e,r,n,t;var o=!!((e=ne.stripeLinkEventData)===null||e===void 0?void 0:e.complete);var i=!!((r=ne.stripeAddressEventData)===null||r===void 0?void 0:r.complete);var a=ne.stripeShippingSameAsBilling?i:!!((n=ne.stripeBillingAddressEventData)===null||n===void 0?void 0:n.complete);var s=((t=ne.stripeAddressEventData)===null||t===void 0?void 0:t.value.address.country)||"US";var u=he(s);if(i&&a&&o){return true}if(!u||!ne.stripeAddressEventData){return i&&a&&o}var d=ne.stripeAddressEventData.value.address.line1.length>0;var l=ne.stripeAddressEventData.value.firstName&&ne.stripeAddressEventData.value.lastName;var c=!u.stateRequired||u.stateRequired&&ne.stripeAddressEventData.value.address.state.length>0;var v=!u.zipRequired||u.zipRequired&&ne.stripeAddressEventData.value.address.postal_code.length>=3;var f=ne.stripeAddressEventData.value.phone&&ne.stripeAddressEventData.value.phone.length>0;return o&&l&&d&&c&&v&&f};var ge=function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o,i,a,s,u,d,l,c;return __generator(this,(function(v){switch(v.label){case 0:r=new AbortController;ne.fetchingLandedCostAbortController=r;rr();return[4,Y(r)];case 1:n=v.sent(),o=n.checkoutSessionWorkflow,i=n.errors,a=n.itemCreateWorkflow,s=n.landedCostCalculateWorkflow,u=n.partyCreateWorkflow,d=n.shipmentRatingCalculateWorkflow;ze.customQuotingError=((e=i===null||i===void 0?void 0:i.find((function(e){var r;return((r=e.extensions)===null||r===void 0?void 0:r.ruleMessageType)==="CUSTOM"})))===null||e===void 0?void 0:e.message)||null;ze.shippingData=V((d===null||d===void 0?void 0:d.filter(Boolean))||[]);Me(a);ne.fetchingLandedCostAbortController=null;ze.partiesData=(u===null||u===void 0?void 0:u.filter(Boolean))||[];ze.landedCostData=(o===null||o===void 0?void 0:o.map((function(e){var r=s===null||s===void 0?void 0:s.find((function(r){return(r===null||r===void 0?void 0:r.id)===e.landedCostId}));if(!r){return null}return Object.assign(Object.assign({},e),{landedCost:r})})).filter(Boolean))||[];l=t.checkoutSessionId;if(o===null||o===void 0?void 0:o.length){void H({checkoutSessionId:l,eventName:"checkout_quoteReceived"})}c=ze.promoCodeApplied&&!ze.landedCostData.find((function(e){var r;return(r=e.landedCost.appliedAdjustments)===null||r===void 0?void 0:r.find((function(e){return e.type==="PROMO_CODE"}))}));ze.promoCodeError=c;if(!c){sessionStorage.setItem("zonos--promo-code",ze.promoCode)}return[2]}}))}))};var ye=e("q",(function(e){return __awaiter(b,void 0,void 0,(function(){var r,n,t,o,i,a,s,u,d,l,c,f,m,p;return __generator(this,(function(w){switch(w.label){case 0:i=(e===null||e===void 0?void 0:e.retries)||0;a=!!(e===null||e===void 0?void 0:e.applyingPromocode);s=pe();u=we();if(!u){return[2,{isRequestNotReady:true}]}if(s){(r=ne.fetchingLandedCostAbortController)===null||r===void 0?void 0:r.abort();ne.fetchingLandedCostAbortController=null}if(!s&&!a){return[2,{isRequestNotReady:false}]}if(i){ne.isFetchingLandedCost=false;setTimeout((function(){ne.isFetchingLandedCost=true}),300)}else{ne.isFetchingLandedCost=true}if(ne.stripeAddressEventData){ne.stripeAddressUsedWhenFetchingLC={countryCode:ne.stripeAddressEventData.value.address.country,postalCode:ne.stripeAddressEventData.value.address.postal_code,state:ne.stripeAddressEventData.value.address.state}}if(ne.stripeBillingAddressEventData){ne.stripeBillingAddressUsedWhenFetchingLC={countryCode:ne.stripeBillingAddressEventData.value.address.country,postalCode:ne.stripeBillingAddressEventData.value.address.postal_code,state:ne.stripeBillingAddressEventData.value.address.state}}if(ne.stripeLinkEventData){ne.stripeLinkUsedWhenFetchingLC=Object.assign({},ne.stripeLinkEventData)}w.label=1;case 1:w.trys.push([1,3,,7]);rr();return[4,ge()];case 2:w.sent();d=(n=ze.shippingData)===null||n===void 0?void 0:n.find(Boolean);l=(t=ze.landedCostData)===null||t===void 0?void 0:t.find((function(e){return e.landedCost.shipmentRating.id===(d===null||d===void 0?void 0:d.id)}));c=!!l?l.subtotals:null;if(c){He({method:(l===null||l===void 0?void 0:l.landedCost.method)||"DDP",subtotals:c})}return[3,7];case 3:f=w.sent();ze.landedCostData=[];ze.shippingData=[];m=["The landed cost calculation request was aborted to initiate a new one."];if(!(f instanceof Error&&f.message&&!m.includes(f.message)))return[3,6];if(!(i<1))return[3,5];return[4,ye(Object.assign(Object.assign({},e),{retries:(i||0)+1}))];case 4:w.sent();return[2,{isRequestNotReady:false}];case 5:p=(o=ne.stripeAddressEventData)===null||o===void 0?void 0:o.value;void h({endpoint:"Failed to fetch landed cost (".concat(i," retries)"),errors:[f.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:p}});w.label=6;case 6:v(f);return[3,7];case 7:ne.isFetchingLandedCost=false;return[2,{isRequestNotReady:false}]}}))}))}));var be=e("J",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,t;return __generator(this,(function(o){switch(o.label){case 0:return[4,ye({applyingPromocode:true})];case 1:o.sent();if(ze.step==="payment"){or()}return[4,ve()];case 2:o.sent();n=(e=ze.shippingData)===null||e===void 0?void 0:e.find(Boolean);t=(r=ze.landedCostData)===null||r===void 0?void 0:r.find((function(e){return e.landedCost.id===(n===null||n===void 0?void 0:n.id)}));if(!n||!t){return[2]}return[4,Qe({applySubtotalsOnly:false,landedCostId:t.landedCostId,selectedShippingOption:n})];case 3:o.sent();return[2]}}))}))}));var _e=e("L",(function(){ze.promoCode="";sessionStorage.removeItem("zonos--promo-code");ze.promoCodeError=false;ze.promoCodeApplied=false}));var Se=e("K",(function(){return __awaiter(b,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:if(ze.step==="payment"){or()}_e();return[4,be()];case 1:e.sent();return[2]}}))}))}));var Oe=e("M",(function(e){var r=[];var n=true;var t=window.Zonos.isCollect;var o=window.Zonos.isInvoice;switch(e){case"succeeded":{r=[a("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."),"",a("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.")];if(t||o){r=[a("Thank you for submitting your payment. We appreciate your prompt attention."),"",a("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.")]}n=false;break}case"requires_capture":case"processing":{r=[a("Payment processing. We'll update you when payment is received.")];n=false;break}case"requires_payment_method":{r=[a("Payment failed. Please try another payment method.")];if(t){r=[a("Payment failed. Please reload the page and try another payment method.")]}break}case"requires_action":{n=false;r=[a("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")]}default:{r=[a("Something went wrong.")];break}}return{isError:n,messages:r}}));var Ae=e("v",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,t,o,i,s,u,d,l,d;return __generator(this,(function(m){switch(m.label){case 0:t=n.checkoutSettings.onInventoryCheck;o=!!((r=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||r===void 0?void 0:r.value);if(!(window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&o))return[3,2];return[4,c("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:i=m.sent(),s=i.errors,u=i.json;if(s.length||!u){v("Error occurs when handling inventory refund","warn",JSON.stringify(s));return[2,null]}if(!u.available||u.status===204){return[2,a("The item you're looking for is currently unavailable in our inventory. Please check back later or contact support for assistance with availability.")]}if(u.available||u.status===200){ne.shouldInventoryRefund=true;return[2,null]}return[2,null];case 2:if(typeof t!=="function"){return[2,null]}m.label=3;case 3:m.trys.push([3,5,,6]);return[4,t({items:ze.items},{translate:a,zonosApiRoute:f["vercel"]})];case 4:d=m.sent();return[2,d];case 5:l=m.sent();d=l instanceof Error?l.message:"Unknown error";void h({endpoint:"onInventoryCheck",errors:["cartId: ".concat(window.Zonos.cartId," - ").concat(d)],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:ze.items}});throw l;case 6:return[2]}}))}))}));var Ce=e("B",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n;return __generator(this,(function(t){switch(t.label){case 0:n=!!((r=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||r===void 0?void 0:r.value);if(!window.Zonos.isLegacyCheckout||!window.Zonos.cartData||!n){return[2]}return[4,c("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:t.sent();return[2]}}))}))}));var ke=e("c",(function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,t,o,i,s,u,d,l;var c=e.clientSecret,f=e.storybookForceStatus;return __generator(this,(function(e){switch(e.label){case 0:if(f){r=Oe(f),n=r.isError,t=r.messages;return[2,{error:n,messages:t}]}o=c||ne.clientSecret;if(!ne.stripe||!o){v("Failed to retrieve payment intent. Stripe is not initialized");return[2,{error:true,message:[a("Something went wrong.")]}]}return[4,ne.stripe.retrievePaymentIntent(o)];case 1:i=e.sent().paymentIntent;s=i===null||i===void 0?void 0:i.status;u=Oe(s),d=u.isError,l=u.messages;return[2,{amount:i===null||i===void 0?void 0:i.amount,currency:i===null||i===void 0?void 0:i.currency,error:d,messages:l,paymentIntentId:i===null||i===void 0?void 0:i.id,paymentMethod:i===null||i===void 0?void 0:i.payment_method,status:s}]}}))}))}));var Ie=e("A",(function(e){return __awaiter(b,void 0,void 0,(function(){var r,n,o,i,s,u,l,c,v,f,m,p;return __generator(this,(function(h){switch(h.label){case 0:o=!!((r=ne.stripePaymentEventData)===null||r===void 0?void 0:r.complete);i=ne.stripeElements;s=ne.stripe;u=ne.clientSecret;ne.customErrorMessage=null;if(!((n=ze.selectedLandedCost)===null||n===void 0?void 0:n.landedCost.id)&&!(e===null||e===void 0?void 0:e.noLandedCostCheck)){throw new Error("Attempted to confirm the payment when no landed cost is found in store")}return[4,Z()];case 1:l=h.sent();if(!l.valid){ne.customErrorMessage=l.errorMessage;throw new Error(l.errorMessage)}c=t.checkoutSessionId;if(!(s&&i&&o&&u&&c))return[3,3];v=new URL(window.location.href);v.searchParams.set("payment_intent_client_secret",u);v.searchParams.set("zonosCheckoutSessionId",c);void H({checkoutSessionId:c,eventName:"checkout_paymentInfoCompleted"});return[4,s.confirmPayment({confirmParams:{return_url:v.toString()},elements:i,redirect:"if_required"})];case 2:f=h.sent(),m=f.error,p=f.paymentIntent;d("Payment intent confirmed","info",{error:m,paymentIntent:p});if((p===null||p===void 0?void 0:p.status)==="requires_action"){throw new Error(a("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction."))}if(m){if(m.type==="card_error"||m.type==="validation_error"){throw new Error(m.message)}if(m.type==="invalid_request_error"){if(m.code==="payment_intent_unexpected_state"){return[2]}}throw new Error("An unexpected error occurred.")}if(p.status==="requires_payment_method"){throw new Error(a("Payment failed. Please try another payment method."))}h.label=3;case 3:return[2]}}))}))}));var Te=e("m",(function(){var e;var r=ze.items.reduce((function(e,r){return e+r.amount*r.quantity}),0);var n=t.enabledVariantTestKeys||[];var i={adjustmentsAmount:ze.adjustments.reduce((function(e,r){return e+r.amount}),0),cartId:window.Zonos.cartId,currency:((e=ze.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"",customerAuthenticationToken:ze.customerAuthenticationToken||undefined,isCollect:!!window.Zonos.isCollect,isInvoice:!!window.Zonos.isInvoice,itemsAmount:r,metadata:[{key:"language",value:o.selectedLocale}],presentmentCountryCode:o.selectedCountryCode,skipPaymentIntent:ne.skipPaymentIntent,varianceTestInput:n};return i}));var Ee=e("k",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o,i;return __generator(this,(function(s){switch(s.label){case 0:if(!t.checkoutSessionId){void h({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:l,cartId:window.Zonos.cartId}});Ye({messages:[a("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:a("Error creating Checkout")});return[2]}return[4,c("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:t.checkoutSessionId},method:"POST"})];case 1:r=s.sent(),n=r.errors,o=r.json;i=(e=o===null||o===void 0?void 0:o.checkoutSessionPaymentIntentCreate)===null||e===void 0?void 0:e.clientSecret;if(n.length||!i){v("Error occurs when getting payment intent",JSON.stringify(n,null,2));void h({endpoint:"Error creating payment intent",errors:n.map((function(e){return e.message})),metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:t.checkoutSessionId,clientSecret:i}});Ye({messages:[a("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:a("Error creating Checkout")});return[2]}Ge(o.checkoutSessionPaymentIntentCreate);return[2]}}))}))}));var Ne=e("j",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,t,i,a,s,u;return __generator(this,(function(l){switch(l.label){case 0:if(!o.targetCurrency){v("Failed to create checkout session - missing localizationStore.targetCurrency");return[2,false]}ne.isFetchingSession=true;n=Te();d("Checkout session body","info",n);return[4,c("/api/zonos-elements/create-checkout-session",{body:n,method:"POST"})];case 1:t=l.sent(),i=t.errors,a=t.json;ne.isFetchingSession=false;if(i.length||!a){s=(e=i.find((function(e){return e.message})))===null||e===void 0?void 0:e.message;if(Array.isArray(s)&&s.some((function(e){return e.message==="Cart is expired."}))){throw new Error("Cart is expired.")}v("Error occurred when creating checkout session",JSON.stringify(i,null,2));return[2,false]}u=a.checkoutSessionCreate;Ge(u);He({method:((r=u.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:u.subtotals});d("Exchange rate updated for cart items (checkout session create)","info",ze.exchangeRate);d("done-init-checkout-session");return[2,true]}}))}))}));var je=e("u",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,o;return __generator(this,(function(i){switch(i.label){case 0:e=t.checkoutSessionId;if(!e){v("Failed to update checkout session base currency");return[2,false]}if(n.checkoutSettings.allowedSettlementCurrencies==="LOCAL"){d('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency');return[2,true]}return[4,c("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:e,currencyCode:ne.checkoutSettlementCurrency},method:"POST"})];case 1:r=i.sent().json;o=r===null||r===void 0?void 0:r.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;if(!r||o!==ne.checkoutSettlementCurrency){v("Failed to update checkout session base currency");return[2,false]}d('Updated checkout session to settlement currency "'.concat(o,'".'));return[2,true]}}))}))}));var Pe=function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,i,a;var s=e.adjustmentsAmount,u=e.cartId,d=e.currency,l=e.id,f=e.itemsAmount,m=e.landedCostId,p=e.presentmentCountryCode,h=e.storeCreditApplication;return __generator(this,(function(e){switch(e.label){case 0:r=t.enabledVariantTestKeys||[];return[4,c("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:s,billToPartyId:ne.partyBillingId,cartId:u,currency:d,customerAuthenticationToken:ze.customerAuthenticationToken||undefined,id:l,itemsAmount:f,landedCostId:m,metadata:[{key:"language",value:o.selectedLocale}],presentmentCountryCode:p,shipToPartyId:ne.partyShippingId,skipPaymentIntent:ne.skipPaymentIntent,storeCreditApplication:h,varianceTestInput:r},method:"POST"})];case 1:n=e.sent(),i=n.errors,a=n.json;if(i.length||!a){v("Error occurs when updating checkout session",JSON.stringify(i,null,2));return[2,{errors:i,json:a}]}return[2,{errors:[],json:a}]}}))}))};var De=function(e){var r,n,t,o,i,a;var s=e.currentAddress,u=e.translatedAddressResult;var d={};if(!u){return d}var l=u.city,c=u.line1,v=u.line2,f=u.name,m=u.postal_code,p=u.state;if(s.city&&l){d.city=(r={},r[s.city]=l,r)}if(s.line1&&c){d.line1=(n={},n[s.line1]=c,n)}if(s.line2&&v){d.line2=(t={},t[s.line2]=v,t)}if(s.postal_code&&m){d.postal_code=(o={},o[s.postal_code]=m,o)}if(s.state&&p){d.state=(i={},i[s.state]=p,i)}if(s.name&&f){d.name=(a={},a[s.name]=f,a)}return d};var Le=e("P",(function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,t,o,i,a,s,u,d,l,f;var m=e.addressInvalidCharactersList,p=e.billingAddressInvalidCharactersList;return __generator(this,(function(e){switch(e.label){case 0:i=G({addressInvalidCharactersList:m,billingAddressInvalidCharactersList:p,stripeAddressEventData:ne.stripeAddressEventData,stripeBillingAddressEventData:ne.stripeBillingAddressEventData,stripeShippingSameAsBilling:ne.stripeShippingSameAsBilling});if(!i){ne.translatedAddress={address:{},billingAddress:{}};return[2]}a=de();if(!a){return[2]}return[4,c("/api/zonos-elements/validate-address",{body:i,method:"POST"})];case 1:s=e.sent(),u=s.errors,d=s.json;if(u.length||!d){v("Error occurs when translating address to latin",JSON.stringify(u,null,2));ne.translatedAddress={address:{},billingAddress:{}};return[2]}ne.stripeAddressUsedWhenValidatingAddress=ne.stripeAddressEventData;ne.stripeBillingAddressUsedWhenValidatingAddress=ne.stripeBillingAddressEventData;l=(r=ne.stripeAddressEventData)===null||r===void 0?void 0:r.value.address;f=(n=ne.stripeBillingAddressEventData)===null||n===void 0?void 0:n.value.address;ne.translatedAddress={address:l?De({currentAddress:Object.assign(Object.assign({},l),{name:(t=ne.stripeAddressEventData)===null||t===void 0?void 0:t.value.name}),translatedAddressResult:d.address||null}):{},billingAddress:!ne.stripeShippingSameAsBilling?De({currentAddress:Object.assign(Object.assign({},f),{name:(o=ne.stripeBillingAddressEventData)===null||o===void 0?void 0:o.value.name}),translatedAddressResult:d.billingAddress||null}):{}};return[2]}}))}))}));ee("clientSecret",(function(e){if(e&&ne.stripe){sessionStorage.setItem("zonos--client-secret",e)}if(!e){sessionStorage.removeItem("zonos--client-secret")}}));var xe=r((function(){return{addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:false,checkoutTimeoutInterval:null,currency:"USD",customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:false,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:false,isSelectedShippingGuarantee:false,isStagingMode:p(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:sessionStorage.getItem("zonos--promo-code")||"",promoCodeApplied:!!sessionStorage.getItem("zonos--promo-code"),promoCodeError:false,restrictedItems:[],selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,shouldHideDiscountInput:false,step:"customer-info",storeCredit:0,subtotal:0,tabItems:{"customer-info":{index:1,isDone:false,label:"Customer",value:"customer-info"},shipping:{index:2,isDone:false,label:"Shipping",value:"shipping"},payment:{index:3,isDone:false,label:"Payment",value:"payment"}},total:0}})),Re=xe.onChange,Ue=xe.reset,ze=xe.state;e({D:Re,d:ze});var Be=function(e){switch(e){case"DAYS":return a("days");case"WEEKS":return a("weeks");case"BUSINESS_DAYS":default:return a("business days")}};var Fe=e("S",(function(e){var r;var n=(r=e.shippingProfile)===null||r===void 0?void 0:r.transitTime;if(!(n===null||n===void 0?void 0:n.min)||!(n===null||n===void 0?void 0:n.max)||!(n===null||n===void 0?void 0:n.type)){return null}return{maxTransit:n.max,minTransit:n.min,unit:Be(n.type)}}));var Je=function(e){var r=e.item1,n=e.item2;if(!r||!n){return false}return n.sku&&r.sku&&r.sku===n.sku||n.description&&r.description&&r.description===n.description||r.name&&n.name&&r.name===n.name};var Me=function(e){d("Checking item restrictions");var r=e.map((function(e){if(!e.restriction){return null}var r=e.restriction;var n=ze.items.find((function(r){return Je({item1:r,item2:e})}));return Object.assign(Object.assign({matchedItem:n},e),{restriction:r})})).filter(Boolean);ze.restrictedItems=r;ze.items=ze.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:!!r.find((function(r){return Je({item1:r,item2:e})}))})}));return{cartItems:ze.items,restrictedItems:r}};var qe=null;var We=e("f",(function(){t.checkoutSessionId=null;if(qe){clearTimeout(qe);qe=null}k();Ue()}));var Ye=e("n",(function(e){var r=e.messages,n=e.title;We();ue();ze.step="error";ze.error={messages:r,title:n}}));var He=function(e){var r=e.dutiesTaxesFeesEstimate,n=e.method,t=e.subtotals;var o;ze.exchangeRate=t.exchangeRate;ze.adjustmentTotal=t.adjustments;ze.dutiesTaxesFees=n==="DAP"?null:t.landedCostTotal;ze.storeCredit=(o=t.storeCredit)!==null&&o!==void 0?o:0;ze.subtotal=t.items;ze.total=t.total;ze.currency=t.presentmentCurrencyCode;ze.dutiesTaxesFeesEstimate=r||null};var Ke=e("I",(function(){var e=ze.items.filter((function(e){return e.amount>0}));return!!e.find((function(e){return!e.isRestricted}))}));var Ge=e("p",(function(e){var r,n,o,i,a,c,v;ne.clientSecret=e.clientSecret;ne.stripeCustomerSessionClientSecret=e.customerSessionClientSecret;ne.customerProfile=e.customerProfile;ze.checkoutSession=e;I((n=(r=e.customerProfile)===null||r===void 0?void 0:r.storeCreditBalance)!==null&&n!==void 0?n:null);if(!e.id){void h({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:l,checkoutSession:e}})}if(e.id){t.checkoutSessionId=e.id}var f=s(e.varianceTestResults||[]);u(f);var m=((a=(i=(o=ze.checkoutSession)===null||o===void 0?void 0:o.metadata)===null||i===void 0?void 0:i.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||a===void 0?void 0:a.value)||((v=(c=window.Zonos.cartData)===null||c===void 0?void 0:c.metadata.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||v===void 0?void 0:v.value)||null;if(m){d("Found externalConfirmationPageURL: ".concat(m));ze.externalConfirmationPageURL=m}}));var Ve=function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,i,s,u,l;var c=e.adjustmentsAmount,f=e.cartId,m=e.currency,p=e.dutiesTaxesFeesEstimate,h=e.itemsAmount,w=e.landedCostId,g=e.shouldInitSessionOnFailure;return __generator(this,(function(e){switch(e.label){case 0:if(w&&ze.selectedLandedCost){n=ze.selectedLandedCost.subtotals;He({dutiesTaxesFeesEstimate:p,method:ze.landedCostMethod,subtotals:n});d("Exchange rate updated for cart items (landed cost subtotal)","info",ze.exchangeRate)}if(!t.checkoutSessionId){d("Could not update cart total without checkout session id","info");return[2,false]}return[4,Pe({adjustmentsAmount:c,billToPartyId:ne.partyBillingId,cartId:f,currency:m,id:t.checkoutSessionId,itemsAmount:h,landedCostId:w,presentmentCountryCode:o.selectedCountryCode,shipToPartyId:ne.partyShippingId,varianceTestInput:t.enabledVariantTestKeys||[]})];case 1:i=e.sent(),s=i.errors,u=i.json;if(!(s.length>0||!u))return[3,4];v("Error occurs when updating checkout session.");if(!g)return[3,3];d("Initiating checkout session on failure","info");return[4,Ne()];case 2:l=e.sent();d("stripeStoreInitCheckoutSession: ".concat(l));if(!l){Ye({messages:[a("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:a("Error creating Checkout")});return[2,false]}return[2,true];case 3:return[2,false];case 4:if(!w){He({method:((r=u.checkoutSessionUpdate.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:u.checkoutSessionUpdate.subtotals});d("Exchange rate updated for cart items (checkout session update)","info",ze.exchangeRate)}Ge(u.checkoutSessionUpdate);return[2,true]}}))}))};var Ze=e("T",(function(e){var r,t,o;if(e.method==="DAP"&&((t=(r=n.genericSettings)===null||r===void 0?void 0:r.domesticCountries)===null||t===void 0?void 0:t.includes(((o=ne.stripeAddressEventData)===null||o===void 0?void 0:o.value.address.country)||"US"))){return"DDP"}if(e.method==="DAP"&&e.remittance.length&&e.landedCostGuaranteeCode==="ZONOS"){return"DDP"}return e.method}));var Qe=e("H",(function(e){return __awaiter(b,[e],void 0,(function(e){var r,o,i,a,s,u,l,c,v,f,m,p,h,w,g,y,b,_,S,O,A,C,k,I,T;var E=e.applySubtotalsOnly,N=e.landedCostId,j=e.selectedShippingOption;return __generator(this,(function(e){switch(e.label){case 0:d("Updating selected shipping option","info",{landedCostId:N,selectedShippingOption:j});ze.selectedShippingOption=j;p=Fe(ze.selectedShippingOption);if(p){h=p.maxTransit,w=p.minTransit,g=p.unit;ze.selectedShippingOptionTransitTime="".concat(w,"-").concat(h," ").concat(g)}else{ze.selectedShippingOptionTransitTime=""}y=(r=ze.landedCostData)===null||r===void 0?void 0:r.find((function(e){return e.landedCostId===N}));ze.selectedLandedCost=y||null;if(!y){return[2,false]}b=((o=y.landedCost.amountSubtotals)===null||o===void 0?void 0:o.landedCostTotal)||0;_=y.subtotals.exchangeRate.rate;S=b*_;if(S){d("DAP quote, using estimate: ".concat(S),"info")}ze.landedCostMethod=Ze(y.landedCost);ze.shipping=y.subtotals.shipping;O=((i=y===null||y===void 0?void 0:y.landedCost)===null||i===void 0?void 0:i.landedCostGuaranteeCode)==="ZONOS";A=!!((s=(a=y===null||y===void 0?void 0:y.landedCost)===null||a===void 0?void 0:a.deMinimis)===null||s===void 0?void 0:s.find((function(e){return["DUTY","TAX"].includes(e.type)&&e.threshold==="ABOVE"})));ze.isSelectedShippingAboveDeminimis=A;ze.isSelectedShippingGuarantee=O;C=false;if(!E)return[3,1];k=y.subtotals;He({dutiesTaxesFeesEstimate:S,method:ze.landedCostMethod,subtotals:k});d("Exchange rate updated for cart items (landed cost subtotal)","info",ze.exchangeRate);C=true;return[3,3];case 1:return[4,Ve({adjustmentsAmount:ze.adjustmentTotal,billToPartyId:ne.partyBillingId,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:S,landedCostId:(u=y.landedCost)===null||u===void 0?void 0:u.id,shipToPartyId:ne.partyShippingId,varianceTestInput:t.enabledVariantTestKeys||[]})];case 2:C=e.sent();e.label=3;case 3:I=(l=ze.items.find(Boolean))===null||l===void 0?void 0:l.currencyCode;T=((c=ne.stripeAddressEventData)===null||c===void 0?void 0:c.value.address.country)||"US";ne.shouldRenderPayInUsdButton=I==="USD"&&n.checkoutSettings.allowedSettlementCurrencies==="LOCAL_AND_USD"&&((v=ze.checkoutSession)===null||v===void 0?void 0:v.subtotals.presentmentCurrencyCode)!=="USD"&&!!((m=(f=n.genericSettings)===null||f===void 0?void 0:f.usdSettlementCountryEnabled)===null||m===void 0?void 0:m.includes(T));return[2,C]}}))}))}));var Xe=e("l",(function(e){var r=e.isPreview,n=e.sessionTimeout;if(r){return}var t=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout");var o=t&&!isNaN(parseInt(t,10))?parseInt(t,10):n;d("==START CHECKOUT TIMEOUT - ".concat(o,"=="));ze.checkoutTimeoutInterval=setTimeout((function(){ze.checkoutSessionTimeoutShow=true}),o)}));var $e=e("h",(function(){if(ze.checkoutTimeoutInterval){clearTimeout(ze.checkoutTimeoutInterval);ze.checkoutTimeoutInterval=null}}));var er=function(e){return e.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}))};var rr=function(){ze.items=ze.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}));ze.restrictedItems=[]};var nr=e("e",(function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,o,i;var a=e.adjustments,s=e.cartItems,u=e.landedCostId,d=e.shouldInitSessionOnFailure,l=d===void 0?true:d;return __generator(this,(function(e){switch(e.label){case 0:ze.adjustments=a;ze.items=er(s);n=(r=s.find(Boolean))===null||r===void 0?void 0:r.currencyCode;o=s.reduce((function(e,r){return e+r.amount*r.quantity}),0);i=a.reduce((function(e,r){return e+r.amount}),0);if(!n||!o){return[2]}ze.currency=n;ne.isFetchingSession=true;return[4,Ve({adjustmentsAmount:i,billToPartyId:ne.partyBillingId,cartId:window.Zonos.cartId,currency:n,dutiesTaxesFeesEstimate:0,itemsAmount:o,landedCostId:u,shipToPartyId:ne.partyShippingId,shouldInitSessionOnFailure:l,varianceTestInput:t.enabledVariantTestKeys||[]})];case 1:e.sent();ne.isFetchingSession=false;return[2]}}))}))}));var tr=function(){ze.selectedShippingOption=null;ze.isSelectedShippingAboveDeminimis=false;ze.isSelectedShippingGuarantee=false;ze.selectedShippingOptionTransitTime="";ze.dutiesTaxesFees=0;ze.dutiesTaxesFeesEstimate=0;ze.shipping=0;ze.total=ze.subtotal};var or=function(){if(ze.step==="shipping"){ze.step="customer-info";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{"customer-info":Object.assign(Object.assign({},ze.tabItems.shipping),{isDone:false})})}else if(ze.step==="payment"){ze.step="shipping";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{shipping:Object.assign(Object.assign({},ze.tabItems.shipping),{isDone:false})})}else if(ze.step==="finish"){ze.step="payment";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{payment:Object.assign(Object.assign({},ze.tabItems.payment),{isDone:false})})}};var ir=e("r",(function(){if(ze.step==="customer-info"){ze.step="shipping";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{"customer-info":Object.assign(Object.assign({},ze.tabItems["customer-info"]),{isDone:true})})}else if(ze.step==="shipping"){ze.step="payment";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{shipping:Object.assign(Object.assign({},ze.tabItems.shipping),{isDone:true})})}else if(ze.step==="payment"){ze.step="finish"}}));var ar=e("g",(function(){ze.step="customer-info";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{"customer-info":Object.assign(Object.assign({},ze.tabItems["customer-info"]),{isDone:false}),payment:Object.assign(Object.assign({},ze.tabItems.payment),{isDone:false}),shipping:Object.assign(Object.assign({},ze.tabItems.shipping),{isDone:false})});tr()}));var sr=function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,i,a,s,u,l,c;return __generator(this,(function(f){switch(f.label){case 0:if(!t.checkoutSessionId){d("Could not update store credit without checkout session id","info");return[2]}n=ze.selectedLandedCost;i=ze.currency||((e=ze.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"";a=ze.adjustments.reduce((function(e,r){return e+r.amount}),0);s=ze.items.reduce((function(e,r){return e+r.amount*r.quantity}),0);return[4,Pe({adjustmentsAmount:a,cartId:window.Zonos.cartId,currency:i,id:t.checkoutSessionId,itemsAmount:s,landedCostId:n===null||n===void 0?void 0:n.landedCostId,presentmentCountryCode:o.selectedCountryCode,storeCreditApplication:D()})];case 1:u=f.sent(),l=u.errors,c=u.json;if(l.length>0||!c){v("Error updating checkout session with store credit");return[2]}He({method:((r=c.checkoutSessionUpdate.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:c.checkoutSessionUpdate.subtotals});Ge(c.checkoutSessionUpdate);return[2]}}))}))};var ur=e("X",(function(){if(qe){clearTimeout(qe)}qe=setTimeout((function(){qe=null;void sr()}),300)}))}}}));
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,r,n,t){function o(e){return e instanceof n?e:new n((function(r){r(e)}))}return new(n||(n=Promise))((function(n,i){function a(e){try{u(t.next(e))}catch(e){i(e)}}function s(e){try{u(t["throw"](e))}catch(e){i(e)}}function u(e){e.done?n(e.value):o(e.value).then(a,s)}u((t=t.apply(e,r||[])).next())}))};var __generator=this&&this.__generator||function(e,r){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,o,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(n=0)),n)try{if(t=1,o&&(i=s[0]&2?o["return"]:s[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;if(o=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:n.label++;return{value:s[1],done:false};case 5:n.label++;o=s[1];s=[0];continue;case 7:s=n.ops.pop();n.trys.pop();continue;default:if(!(i=n.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){n.label=s[1];break}if(s[0]===6&&n.label<i[1]){n.label=i[1];i=s;break}if(i&&n.label<i[2]){n.label=i[2];n.ops.push(s);break}if(i[2])n.ops.pop();n.trys.pop();continue}s=r.call(e,n)}catch(e){s=[6,e];o=0}finally{t=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,r,n){if(n||arguments.length===2)for(var t=0,o=r.length,i;t<o;t++){if(i||!(t in r)){if(!i)i=Array.prototype.slice.call(r,0,t);i[t]=r[t]}}return e.concat(i||Array.prototype.slice.call(r))};System.register(["./p-15ef7644.system.js","./p-1523f6a8.system.js","./p-d938f42f.system.js","./p-01174496.system.js","./p-61be7d98.system.js","./p-8bce79f4.system.js"],(function(e){"use strict";var r,n,t,o,i,a,s,u,d,l,c,v,f,m,p,h,w,g,y;return{setters:[function(e){r=e.c;n=e.z},function(e){t=e.s;o=e.l;i=e.e;a=e.t;s=e.f;u=e.b},function(e){d=e.l;l=e.b},function(e){c=e.h;v=e.l;f=e.f;m=e.g;p=e.a;h=e.s;w=e.j},function(e){g=e.i},function(e){y=e.g}],execute:function(){var b=this;var _=function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o;return __generator(this,(function(i){switch(i.label){case 0:if(!t.checkoutSessionId){return[2,{errors:[{message:"No checkout session id found"}],json:null}]}e=new URLSearchParams;e.set("checkoutSessionId",t.checkoutSessionId);return[4,c("/api/zonos-elements/get-checkout-session?".concat(e.toString()))];case 1:r=i.sent(),n=r.errors,o=r.json;return[2,{errors:n,json:o}]}}))}))};var S=r((function(){return{amountToApply:null,appliedAmount:null,availableBalance:null,error:null,isApplying:false,isEnabled:false,orderIdCreated:null,remainingBalance:null,useFullBalance:true}})),O=S.onChange,A=S.reset,C=S.state;e("N",C);var k=e("O",(function(){A()}));var I=function(e){d("Store credit balance from session","info",e);C.availableBalance=e};var T=e("Z",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,t,o,i;return __generator(this,(function(a){switch(a.label){case 0:return[4,_()];case 1:n=a.sent(),t=n.errors,o=n.json;if(t.length||!o){v("Failed to refresh store credit balance");return[2]}i=(r=(e=o.checkoutSession.customerProfile)===null||e===void 0?void 0:e.storeCreditBalance)!==null&&r!==void 0?r:null;I(i);return[2]}}))}))}));var E=e("w",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o,i,a,s,u,s;return __generator(this,(function(l){switch(l.label){case 0:r=t.checkoutSessionId;if(!r){n="No checkout session found";v(n);C.error=n;return[2,{error:n,success:false}]}d("Applying store credit","info",{checkoutSessionId:r});C.isApplying=true;C.error=null;l.label=1;case 1:l.trys.push([1,3,,4]);return[4,c("/api/zonos-elements/store-credit/apply",{body:{checkoutSessionId:r},method:"POST"})];case 2:o=l.sent(),i=o.errors,a=o.json;if(i.length>0||!a){s=((e=i[0])===null||e===void 0?void 0:e.message)||"Failed to apply store credit";v(s);C.error=s;C.isApplying=false;return[2,{error:s,success:false}]}C.appliedAmount=a.amountApplied;C.remainingBalance=a.remainingBalance;C.isApplying=false;d("Store credit applied","info",{amountApplied:a.amountApplied,remainingBalance:a.remainingBalance});return[2,{error:null,success:true}];case 3:u=l.sent();s=u instanceof Error?u.message:"Failed to apply store credit";v(s);C.error=s;C.isApplying=false;return[2,{error:s,success:false}];case 4:return[2]}}))}))}));var N=e("V",(function(e){C.isEnabled=e;C.error=null;if(!e){C.amountToApply=null}}));var j=e("Y",(function(e){if(e===null){C.amountToApply=null;C.error=null;return}if(e<=0){C.error="Amount must be greater than zero";return}if(C.availableBalance!==null&&e>C.availableBalance){C.error="Amount exceeds available balance";return}var r=ze.total+(ze.storeCredit||0);if(e>r){C.error="Amount exceeds order total";return}C.error=null;C.amountToApply=e}));var P=e("W",(function(e){C.useFullBalance=e;C.error=null;if(e&&C.availableBalance!==null){var r=ze.total+(ze.storeCredit||0);var n=Math.min(C.availableBalance,r);C.amountToApply=n}else if(!e){C.amountToApply=null}}));var D=function(){if(!C.isEnabled||C.amountToApply===null){return{mode:"NONE"}}if(C.useFullBalance){return{mode:"FULL"}}return{amount:C.amountToApply,mode:"PARTIAL"}};var L=e("F",(function(){if(!C.isEnabled||C.availableBalance===null){return 0}if(C.useFullBalance){return Math.min(C.availableBalance,ze.total+(ze.storeCredit||0))}return C.amountToApply||0}));var x=e("x",(function(){return C.amountToApply!==null&&C.amountToApply>0&&ze.storeCredit>0&&ze.total<=0}));var R=e("z",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o,i,a,s,u,l,f,m,l;return __generator(this,(function(p){switch(p.label){case 0:o=t.checkoutSessionId;if(!o){i="No checkout session found";v(i);C.error=i;return[2,{error:i,orderId:null,success:false}]}d("Creating store credit order","info",{checkoutSessionId:o});p.label=1;case 1:p.trys.push([1,3,,4]);return[4,c("/api/zonos-elements/store-credit/order-create",{body:{checkoutSessionId:o},method:"POST"})];case 2:a=p.sent(),s=a.errors,u=a.json;if(s.length>0||!u){l=((e=s[0])===null||e===void 0?void 0:e.message)||"Failed to create store credit order";v(l);C.error=l;return[2,{error:l,orderId:null,success:false}]}f=((n=(r=u.checkoutSessionStoreCreditOrderCreate)===null||r===void 0?void 0:r.order)===null||n===void 0?void 0:n.id)||null;C.orderIdCreated=f;d("Store credit order created","info",{orderId:f});return[2,{error:null,orderId:f,success:true}];case 3:m=p.sent();l=m instanceof Error?m.message:"Failed to create store credit order";v(l);C.error=l;return[2,{error:l,orderId:null,success:false}];case 4:return[2]}}))}))}));var U=e("Q",(function(e){var r=e.firstName,n=e.lastName,t=e.name;var o;if(!t&&!r&&!n){return{firstName:"",lastName:""}}var i=(t===null||t===void 0?void 0:t.split(/\s+/))||[];var a=(r===null||r===void 0?void 0:r.trim())||((o=i[0])===null||o===void 0?void 0:o.trim())||"";var s=(n===null||n===void 0?void 0:n.trim())||i.slice(1).join(" ").trim()||"";return{firstName:a,lastName:s}}));var z=function(e){var r=e.currentAddress,n=e.translatedAddress;var t,o,i,a,s,u;var d=r.value.address,l=d.city,c=d.country,v=d.line1,f=d.line2,m=d.postal_code,p=d.state;var h=r.value.name||[r.value.firstName,r.value.lastName].join(" ");return{city:((t=n.city)===null||t===void 0?void 0:t[l])||l,country:c,line1:((o=n.line1)===null||o===void 0?void 0:o[v])||v,line2:((i=n.line2)===null||i===void 0?void 0:i[f||""])||f||"",name:((a=n.name)===null||a===void 0?void 0:a[h])||h,phone:r.value.phone||"",postal_code:((s=n.postal_code)===null||s===void 0?void 0:s[m])||m,state:((u=n.state)===null||u===void 0?void 0:u[p])||p}};var B=function(e){var r;var n=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";var a=ne.stripeLinkEventData;var s=ne.stripeAddressEventData;var u=ne.stripeShippingSameAsBilling?ne.stripeAddressEventData:ne.stripeBillingAddressEventData;if(!s||!u){throw new Error("Missing stripe address data")}var d=z({currentAddress:s,translatedAddress:ne.translatedAddress.address});var l=U({name:d.name}),c=l.firstName,v=l.lastName;var f=z({currentAddress:u,translatedAddress:ne.translatedAddress.address});var m=U({name:f.name}),p=m.firstName,h=m.lastName;var w=i()||"US";return{billingAddress:{addressLine1:f.line1,addressLine2:f.line2||"",city:f.city,country:f.country,postalCode:f.postal_code,state:f.state},billingContact:{firstName:p,lastName:h,phone:f.phone},cartCurrencyCode:(r=ze.items[0])===null||r===void 0?void 0:r.currencyCode,cartId:e,checkoutSessionCountry:w||o.selectedCountryCode||undefined,checkoutSessionId:t.checkoutSessionId||"",contact:{companyName:ne.companyName,email:a===null||a===void 0?void 0:a.value.email,firstName:c,lastName:v,phone:d.phone},isTest:!!n,landedCostAdjustments:ze.promoCode?[{amount:0,productId:null,promoCode:ze.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToShortAddressCode:ne.shortAddressCode,shipToTaxId:ne.taxId,shippingAddress:{addressLine1:d.line1,addressLine2:d.line2,city:d.city,country:d.country,postalCode:d.postal_code,state:d.state}}};var F=function(){var e=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";var r=ne.stripeLinkEventData;var n=ne.stripeAddressEventData;var o=ne.stripeShippingSameAsBilling?ne.stripeAddressEventData:ne.stripeBillingAddressEventData;d({stripeAddressData:n,stripeBillingAddressData:o},"info");if(!n||!o){throw new Error("Missing stripe address data")}var i=z({currentAddress:n,translatedAddress:ne.translatedAddress.address});var a=U({name:i.name}),s=a.firstName,u=a.lastName;var l=z({currentAddress:o,translatedAddress:ne.translatedAddress.address});var c=U({name:l.name}),v=c.firstName,f=c.lastName;var m=ze.adjustments.map((function(e){return{amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}}));var p=ze.promoCode?__spreadArray([{amount:0,productId:null,promoCode:ze.promoCode,sku:null,type:"PROMO_CODE"}],m,true):m;return{billingAddress:{addressLine1:l.line1,addressLine2:l.line2||"",city:l.city,country:l.country,postalCode:l.postal_code,state:l.state},billingContact:{firstName:v,lastName:f,phone:l.phone},checkoutSessionId:t.checkoutSessionId||"",contact:{companyName:ne.companyName,email:r===null||r===void 0?void 0:r.value.email,firstName:s,lastName:u,phone:i.phone},isTest:e,items:ze.items,landedCostAdjustments:p,shipToShortAddressCode:ne.shortAddressCode,shipToTaxId:ne.taxId,shippingAddress:{addressLine1:i.line1,addressLine2:i.line2,city:i.city,country:i.country,postalCode:i.postal_code,state:i.state}}};var J=function(e){return __awaiter(b,void 0,void 0,(function(){var r,n,t,o,i,a,s,u,d,l;return __generator(this,(function(v){switch(v.label){case 0:a=F();return[4,e({billingAddress:a.billingAddress,billingContact:a.billingContact,checkoutSessionId:a.checkoutSessionId,contact:a.contact,landedCostAdjustments:a.landedCostAdjustments,publicCredential:window.Zonos.zonosApiKey||"",shippingAddress:a.shippingAddress,zonosApiRoute:f["vercel"]},{promoCode:ze.promoCode})];case 1:s=v.sent();if(!s||!((r=s.checkoutSessionWorkflow)===null||r===void 0?void 0:r.length)&&((n=s.errors)===null||n===void 0?void 0:n.length)){throw new Error("Failed to build landed cost: ".concat(((o=(t=s===null||s===void 0?void 0:s.errors)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.message)||"Unknown error"))}return[4,c("/api/zonos-elements/validate-landed-cost",{body:s,headers:{"Content-Type":"application/json"},method:"POST"})];case 2:u=v.sent(),d=u.errors,l=u.json;if(!l||d.length){throw new Error("Invalid landed cost object: ".concat(((i=d.find(Boolean))===null||i===void 0?void 0:i.message)||"Unknown error"))}return[2,s]}}))}))};var M=function(e){return __awaiter(b,void 0,void 0,(function(){var r,t,o,i,a,s,u;return __generator(this,(function(d){switch(d.label){case 0:t=n.checkoutSettings.buildLandedCost;if(!t)return[3,2];return[4,J(t)];case 1:o=d.sent();return[2,o];case 2:return[4,c("/api/zonos-elements/calculate-landed-cost",{body:F(),method:"POST",signal:e===null||e===void 0?void 0:e.signal})];case 3:i=d.sent(),a=i.errors,s=i.json;if(a.length||!s){u=((r=a[0])===null||r===void 0?void 0:r.message)==="The user aborted a request.";if(u){throw new Error("The landed cost calculation request was aborted to initiate a new one.")}a.forEach((function(e){console.warn("Error calculating landed cost: ".concat(e.message))}));if(!s){throw new Error("Failed to calculate landed cost")}return[2,s]}return[2,s]}}))}))};var q=function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,t,o,i,a,s,u,d,l;var v=e.abortController,f=e.cartId;return __generator(this,(function(e){switch(e.label){case 0:return[4,c("/api/zonos-elements/cart-calculate-landed-cost",{body:B(f),method:"POST",signal:v===null||v===void 0?void 0:v.signal})];case 1:a=e.sent(),s=a.errors,u=a.json;if(s.length||!u){d=typeof((r=s[0])===null||r===void 0?void 0:r.message)==="string"&&(((n=s[0])===null||n===void 0?void 0:n.message)==="The user aborted a request."||((t=s[0])===null||t===void 0?void 0:t.message.includes("signal is aborted"))||((o=s[0])===null||o===void 0?void 0:o.message.includes("The operation was aborted"))||((i=s[0])===null||i===void 0?void 0:i.message.includes("Fetch is aborted")));l=d?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost";throw new Error(l)}return[2,u]}}))}))};var W=undefined&&undefined.__rest||function(e,r){var n={};for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0)n[t]=e[t];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var o=0,t=Object.getOwnPropertySymbols(e);o<t.length;o++){if(r.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o]))n[t[o]]=e[t[o]]}return n};var Y=function(e){return __awaiter(b,void 0,void 0,(function(){var r,n,t,o,i;return __generator(this,(function(a){switch(a.label){case 0:r=window.Zonos.cartId;if(!!r)return[3,2];return[4,M(e)];case 1:n=a.sent();return[2,n];case 2:return[4,q({abortController:e,cartId:r})];case 3:t=a.sent(),o=t.cartWorkflow,i=W(t,["cartWorkflow"]);return[2,Object.assign(Object.assign({},i),{itemCreateWorkflow:o.items})]}}))}))};var H=e("t",(function(e){return __awaiter(b,[e],void 0,(function(e){var r,t,i,a,s,u,d,v,f;var w=e.checkoutSessionId,g=e.eventName,y=e.metadata;return __generator(this,(function(e){switch(e.label){case 0:i=Date.now();a=__spreadArray([],window.Zonos.trackEventLogs,true);window.Zonos.trackEventLogs.push({checkoutSessionId:w,eventCreated:i,eventName:g});s=window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!((r=window.Zonos)===null||r===void 0?void 0:r.zonosQaUrl)||!!((t=window.Zonos)===null||t===void 0?void 0:t.debug);u=m()||p();if((u||s)&&!window.Zonos.zonosConversionTest){return[2]}d=o.selectedCountryCode;v=n.organizationId;if(!w){void h({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(g,'" - No checkout session id found')],metadata:{allLogs:l,checkoutSessionId:w,eventName:g,metadata:y,organizationId:v,trackEventLogs:a}});return[2]}if(!v){void h({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(g,'" - No organization id found')],metadata:{allLogs:l,checkoutSessionId:w,eventName:g,metadata:y,organizationId:v,trackEventLogs:a}})}f={checkoutSessionId:w,countryCode:d,eventCreated:i,eventName:g,metadata:Object.assign(Object.assign({},y),{trackEventLogs:a}),organizationId:v};return[4,c("/api/zonos-elements/track-conversion-event",{body:f,method:"POST"})];case 1:e.sent();return[2]}}))}))}));var K=function(e){var r=e.address,n=e.invalidAdddressList;if(!r){return}if(!n){return}var t={};if(n.city){t.city=r.city}if(n.line1){t.line1=r.line1}if(n.line2){t.line2=r.line2}if(n.postal_code){t.postal_code=r.postal_code}if(n.state){t.state=r.state}if(n.name){t.name=r.name}return Object.keys(t).length?t:undefined};var G=function(e){var r=e.addressInvalidCharactersList,n=e.billingAddressInvalidCharactersList,t=e.stripeAddressEventData,o=e.stripeBillingAddressEventData,i=e.stripeShippingSameAsBilling;var a=!!(t===null||t===void 0?void 0:t.complete);var s=i?a:!!(o===null||o===void 0?void 0:o.complete);if(!a||!s){return null}if(!r&&!n){return null}var u=t.value;var d=(o===null||o===void 0?void 0:o.value)||null;var l=U({firstName:u.firstName,lastName:u.lastName,name:u.name}),c=l.firstName,v=l.lastName;var f="".concat(c," ").concat(v);var m=U({firstName:d===null||d===void 0?void 0:d.firstName,lastName:d===null||d===void 0?void 0:d.lastName,name:(d===null||d===void 0?void 0:d.name)||""}),p=m.firstName,h=m.lastName;var w=p&&h?"".concat(p," ").concat(h):"";var g=u.address;var y=d===null||d===void 0?void 0:d.address;return{address:K({address:Object.assign(Object.assign({},g),{name:f}),invalidAdddressList:r}),billingAddress:!i?K({address:y?Object.assign(Object.assign({},y),{name:w}):null,invalidAdddressList:n}):undefined,destinationCountry:g.country}};var V=e("U",(function(e){var r=e.sort((function(e,r){return e.amount-r.amount}));return r}));var Z=e("y",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,t;return __generator(this,(function(o){switch(o.label){case 0:return[4,_()];case 1:r=o.sent(),n=r.errors,t=r.json;if(n.length||!t){v("Failed to retrieve checkout session info before confirming payment ",n);void h({endpoint:"validateCheckoutSession",errors:n.map((function(e){return e.message})),metadata:{allLogs:l}});return[2,{errorMessage:a("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:false}]}if(!((e=t.checkoutSession.landedCost)===null||e===void 0?void 0:e.id)){v("Landed cost is not found in the checkout session before confirming payment.");void h({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:l}});return[2,{errorMessage:a('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:false}]}return[2,{errorMessage:"",valid:true}]}}))}))}));var Q=function(e){var r=e.theme;var t={".AccordionItem":{color:"var(--colorText)"},".AccordionItem--selected":{color:"var(--colorText)"},".Action":{color:"var(--colorText)"},".Input":{boxShadow:"none",fontSize:n.appearance.fontSizeInputValue?"".concat(n.appearance.fontSizeInputValue,"px"):undefined,padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"},".Label--resting":{fontSize:n.appearance.fontSizeInputLabel?"".concat(n.appearance.fontSizeInputLabel,"px"):undefined},".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"}};switch(r){case"DARK":{return Object.assign(Object.assign({},t),{".Action":Object.assign(Object.assign({},t[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},t[".PickerItem--new"]),{color:"white"})})}default:return t}};var X=function(e){var r=e.borderStyle,n=e.theme;switch(n){case"DARK":return{borderRadius:y({overrideBorderStyle:r}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"};default:return{borderRadius:y({overrideBorderStyle:r}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"}}};var $=r((function(){return{checkoutSettlementCurrency:"USD",clientSecret:sessionStorage.getItem("zonos--client-secret")||"",companyName:"",companyNameUsedWhenAsyncAddressUpdate:"",customAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:false,state:""},customBillingAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:false,state:""},customErrorMessage:null,customerProfile:null,fetchingLandedCostAbortController:null,hasPaymentError:false,isFetchingLandedCost:false,isFetchingSession:false,partyBillingId:null,partyShippingId:null,shortAddressCode:"",shouldInventoryRefund:false,shouldRenderPayInUsdButton:false,skipPaymentIntent:new URLSearchParams(window.location.search).get("skipPaymentIntent")==="0"?false:true,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:true,taxId:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}})),ee=$.onChange,re=$.reset,ne=$.state;e({E:ee,b:ne});var te=function(e){var r=e.clientSecret,t=e.overrideBorderRadius,i=e.overridePrimaryColor,a=e.overrideSecondaryColor,s=e.overrideTheme,u=e.paypalEnabled;var d=i||n.appearance.colorPrimary;var l=a||n.appearance.colorSecondary;var c=window.Zonos.isCollect||window.Zonos.isInvoice?n.appearance.theme==="DARK":d&&g(d);var v=c?"night":"flat";var f=s==="DARK"?"night":"flat";var m=u?["external_paypal"]:[];return{appearance:{labels:"floating",rules:Object.assign({},Q({theme:s||"LIGHT"})),theme:s?f:v,variables:Object.assign(Object.assign({},X({borderStyle:t,theme:"LIGHT"})),{colorPrimary:l})},clientSecret:r||undefined,customerSessionClientSecret:ne.stripeCustomerSessionClientSecret||undefined,externalPaymentMethodTypes:__spreadArray([],m,true),locale:o.selectedLocale}};var oe=e("o",(function(){window.sessionStorage.removeItem("zonos--bigcommerce-domestic-checkout-shipping")}));var ie=e("a",(function(e){window.sessionStorage.setItem("zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))}));var ae=e("s",(function(){var e=window.sessionStorage.getItem("zonos--bigcommerce-domestic-checkout-shipping");return w(e)}));var se=e("i",(function(e){return __awaiter(b,void 0,void 0,(function(){var r,n,t,o,i;return __generator(this,(function(a){t=ne.clientSecret;if(!ne.stripe){d("Skip. Stripe is not initialized");return[2]}o=te({clientSecret:t,overrideBorderRadius:e===null||e===void 0?void 0:e.overrideBorderRadius,overridePrimaryColor:e===null||e===void 0?void 0:e.overridePrimaryColor,overrideSecondaryColor:e===null||e===void 0?void 0:e.overrideSecondaryColor,overrideTheme:e===null||e===void 0?void 0:e.overrideTheme,paypalEnabled:e===null||e===void 0?void 0:e.paypalEnabled});i=JSON.stringify(o)===JSON.stringify(ne.stripeElementsOptions);if(!ne.stripeElements||!ne.stripeElementsForBillingAddress){ne.stripeElementsForBillingAddress=(r=ne.stripe)===null||r===void 0?void 0:r.elements(o);d("Stripe elements for billing address initialized");ne.stripeElements=(n=ne.stripe)===null||n===void 0?void 0:n.elements(o);ne.stripeElementsOptions=o;d("Stripe elements initialized");return[2]}if(!i){ne.stripeElements.update(o);ne.stripeElementsForBillingAddress.update(o);ne.stripeElementsOptions=o;void ne.stripeElements.fetchUpdates()}d("Stripe elements updated");return[2]}))}))}));var ue=e("C",(function(){sessionStorage.removeItem("zonos--client-secret");re();ne.stripe=window.Zonos.stripe}));var de=function(){var e,r,n,t;var o=JSON.stringify((e=ne.stripeAddressUsedWhenValidatingAddress)===null||e===void 0?void 0:e.value)!==JSON.stringify((r=ne.stripeAddressEventData)===null||r===void 0?void 0:r.value);var i=!ne.stripeShippingSameAsBilling&&JSON.stringify((n=ne.stripeBillingAddressEventData)===null||n===void 0?void 0:n.value)!==JSON.stringify((t=ne.stripeBillingAddressUsedWhenValidatingAddress)===null||t===void 0?void 0:t.value);return o||i};var le=function(){var e,r,n,t,o,i,a,s;var u=(e=ze.partiesData.find((function(e){return e.type==="DESTINATION"})))===null||e===void 0?void 0:e.id;var d=(r=ze.partiesData.find((function(e){return e.type==="PAYOR"})))===null||r===void 0?void 0:r.id;if(!u||!d){return false}if(ne.partyShippingId!==u||ne.partyBillingId!==d){return true}var l=JSON.stringify((n=ne.stripeLinkUsedWhenFetchingLC)===null||n===void 0?void 0:n.value)!==JSON.stringify((t=ne.stripeLinkEventData)===null||t===void 0?void 0:t.value);var c=JSON.stringify((o=ne.stripeAddressUsedWhenAsyncAddressUpdate)===null||o===void 0?void 0:o.value)!==JSON.stringify((i=ne.stripeAddressEventData)===null||i===void 0?void 0:i.value);var v=!ne.stripeShippingSameAsBilling&&JSON.stringify((a=ne.stripeBillingAddressUsedWhenAsyncAddressUpdate)===null||a===void 0?void 0:a.value)!==JSON.stringify((s=ne.stripeBillingAddressEventData)===null||s===void 0?void 0:s.value);var f=ne.taxIdUsedWhenAsyncAddressUpdate!==ne.taxId;var m=ne.companyNameUsedWhenAsyncAddressUpdate!==ne.companyName;return l||c||v||f||m};var ce=e("G",(function(e){var r=e.address,n=e.firstName,o=e.lastName,i=e.name,a=e.phone;var s=U({firstName:n,lastName:o,name:i}),u=s.firstName,d=s.lastName;if(!u||!d){void h({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:t.checkoutSessionId,firstName:n,lastName:o,name:i}})}if(!a){void h({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:t.checkoutSessionId,phone:a}})}return{city:r.city,country:r.country,firstName:u,lastName:d,line1:r.line1,line2:r.line2,phone:a||"",postal_code:r.postal_code,state:r.state}}));var ve=e("R",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o,i,a,s,u,d,f,m,p;return __generator(this,(function(w){switch(w.label){case 0:if(!((e=ne.stripeAddressEventData)===null||e===void 0?void 0:e.complete)||!ne.stripeShippingSameAsBilling&&!((r=ne.stripeBillingAddressEventData)===null||r===void 0?void 0:r.complete)||!ne.stripeBillingAddressEventData){return[2,{partiesCreated:false}]}if(!ze.landedCostData){return[2,{partiesCreated:false}]}i=(n=ze.landedCostData.find(Boolean))===null||n===void 0?void 0:n.landedCost.rootId;if(!i){void h({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:t.checkoutSessionId}});return[2,{partiesCreated:false}]}a=le();if(!a){return[2,{partiesCreated:false}]}s=ce({address:ne.stripeAddressEventData.value.address,firstName:ne.stripeAddressEventData.value.firstName,lastName:ne.stripeAddressEventData.value.lastName,name:ne.stripeAddressEventData.value.name,phone:ne.stripeAddressEventData.value.phone});u=ne.stripeShippingSameAsBilling?s:ce({address:ne.stripeBillingAddressEventData.value.address,firstName:ne.stripeBillingAddressEventData.value.firstName,lastName:ne.stripeBillingAddressEventData.value.lastName,name:ne.stripeBillingAddressEventData.value.name,phone:ne.stripeBillingAddressEventData.value.phone});d=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";return[4,c("/api/zonos-elements/create-parties",{body:{address:s,billingAddress:u,companyName:ne.companyName,email:((o=ne.stripeLinkEventData)===null||o===void 0?void 0:o.value.email)||"",isTest:d,rootId:i,shortAddressCode:ne.shortAddressCode,taxId:ne.taxId},method:"POST"})];case 1:f=w.sent(),m=f.errors,p=f.json;if(m.length||!p){v("Error occurs when creating parties",JSON.stringify(m,null,2));void h({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:t.checkoutSessionId,errors:m,json:p}});return[2,{partiesCreated:false}]}ne.companyNameUsedWhenAsyncAddressUpdate=ne.companyName;ne.stripeAddressUsedWhenAsyncAddressUpdate=ne.stripeAddressEventData;ne.stripeBillingAddressUsedWhenAsyncAddressUpdate=ne.stripeBillingAddressEventData;ne.taxIdUsedWhenAsyncAddressUpdate=ne.taxId;ne.partyBillingId=p.billToPartyId;ne.partyShippingId=p.shipToPartyId;ze.partiesData=ze.partiesData.map((function(e){if(e.type==="DESTINATION"&&e.id!==p.shipToPartyId){return Object.assign(Object.assign({},e),{id:p.shipToPartyId})}if(e.type==="PAYOR"&&e.id!==p.billToPartyId){return Object.assign(Object.assign({},e),{id:p.billToPartyId})}return e}));return[2,{partiesCreated:true}]}}))}))}));var fe=function(e){return{countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}};var me=function(){var e,r;var n=JSON.stringify((e=ne.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((r=ne.stripeLinkEventData)===null||r===void 0?void 0:r.value);var t=ne.stripeAddressEventData&&JSON.stringify(fe(ne.stripeAddressEventData.value))!==JSON.stringify(ne.stripeAddressUsedWhenFetchingLC);var o=!ne.stripeShippingSameAsBilling&&ne.stripeBillingAddressEventData&&JSON.stringify(fe(ne.stripeBillingAddressEventData.value))!==JSON.stringify(ne.stripeBillingAddressUsedWhenFetchingLC);return n||t||o};var pe=function(){var e;var r=ze.landedCostData&&((e=ze.landedCostData.find(Boolean))===null||e===void 0?void 0:e.subtotals.items)!==ze.subtotal;var n=me();d("isPrefetchInfoOutdated","info",{isAddressOutdated:n});return!ze.landedCostData&&!ne.isFetchingLandedCost||n||r};var he=function(e){var r,t;var o=(r=n.genericSettings)===null||r===void 0?void 0:r.countryFields;var i=(t=n.genericSettings)===null||t===void 0?void 0:t.stripeCountryFieldLabels;var a=i&&e in i?i[e]:null;var s=o&&e in o?o[e]:null;if(ze.addressFormRenderType==="stripe"){return a||s}return s};var we=function(){var e,r,n,t;var o=!!((e=ne.stripeLinkEventData)===null||e===void 0?void 0:e.complete);var i=!!((r=ne.stripeAddressEventData)===null||r===void 0?void 0:r.complete);var a=ne.stripeShippingSameAsBilling?i:!!((n=ne.stripeBillingAddressEventData)===null||n===void 0?void 0:n.complete);var s=((t=ne.stripeAddressEventData)===null||t===void 0?void 0:t.value.address.country)||"US";var u=he(s);if(i&&a&&o){return true}if(!u||!ne.stripeAddressEventData){return i&&a&&o}var d=ne.stripeAddressEventData.value.address.line1.length>0;var l=ne.stripeAddressEventData.value.firstName&&ne.stripeAddressEventData.value.lastName;var c=!u.stateRequired||u.stateRequired&&ne.stripeAddressEventData.value.address.state.length>0;var v=!u.zipRequired||u.zipRequired&&ne.stripeAddressEventData.value.address.postal_code.length>=3;var f=ne.stripeAddressEventData.value.phone&&ne.stripeAddressEventData.value.phone.length>0;return o&&l&&d&&c&&v&&f};var ge=function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o,i,a,s,u,d,l,c;return __generator(this,(function(v){switch(v.label){case 0:r=new AbortController;ne.fetchingLandedCostAbortController=r;rr();return[4,Y(r)];case 1:n=v.sent(),o=n.checkoutSessionWorkflow,i=n.errors,a=n.itemCreateWorkflow,s=n.landedCostCalculateWorkflow,u=n.partyCreateWorkflow,d=n.shipmentRatingCalculateWorkflow;ze.customQuotingError=((e=i===null||i===void 0?void 0:i.find((function(e){var r;return((r=e.extensions)===null||r===void 0?void 0:r.ruleMessageType)==="CUSTOM"})))===null||e===void 0?void 0:e.message)||null;ze.shippingData=V((d===null||d===void 0?void 0:d.filter(Boolean))||[]);Me(a);ne.fetchingLandedCostAbortController=null;ze.partiesData=(u===null||u===void 0?void 0:u.filter(Boolean))||[];ze.landedCostData=(o===null||o===void 0?void 0:o.map((function(e){var r=s===null||s===void 0?void 0:s.find((function(r){return(r===null||r===void 0?void 0:r.id)===e.landedCostId}));if(!r){return null}return Object.assign(Object.assign({},e),{landedCost:r})})).filter(Boolean))||[];l=t.checkoutSessionId;if(o===null||o===void 0?void 0:o.length){void H({checkoutSessionId:l,eventName:"checkout_quoteReceived"})}c=ze.promoCodeApplied&&!ze.landedCostData.find((function(e){var r;return(r=e.landedCost.appliedAdjustments)===null||r===void 0?void 0:r.find((function(e){return e.type==="PROMO_CODE"}))}));ze.promoCodeError=c;if(!c){sessionStorage.setItem("zonos--promo-code",ze.promoCode)}return[2]}}))}))};var ye=e("q",(function(e){return __awaiter(b,void 0,void 0,(function(){var r,n,t,o,i,a,s,u,d,l,c,f,m,p;return __generator(this,(function(w){switch(w.label){case 0:i=(e===null||e===void 0?void 0:e.retries)||0;a=!!(e===null||e===void 0?void 0:e.applyingPromocode);s=pe();u=we();if(!u){return[2,{isRequestNotReady:true}]}if(s){(r=ne.fetchingLandedCostAbortController)===null||r===void 0?void 0:r.abort();ne.fetchingLandedCostAbortController=null}if(!s&&!a){return[2,{isRequestNotReady:false}]}if(i){ne.isFetchingLandedCost=false;setTimeout((function(){ne.isFetchingLandedCost=true}),300)}else{ne.isFetchingLandedCost=true}if(ne.stripeAddressEventData){ne.stripeAddressUsedWhenFetchingLC={countryCode:ne.stripeAddressEventData.value.address.country,postalCode:ne.stripeAddressEventData.value.address.postal_code,state:ne.stripeAddressEventData.value.address.state}}if(ne.stripeBillingAddressEventData){ne.stripeBillingAddressUsedWhenFetchingLC={countryCode:ne.stripeBillingAddressEventData.value.address.country,postalCode:ne.stripeBillingAddressEventData.value.address.postal_code,state:ne.stripeBillingAddressEventData.value.address.state}}if(ne.stripeLinkEventData){ne.stripeLinkUsedWhenFetchingLC=Object.assign({},ne.stripeLinkEventData)}w.label=1;case 1:w.trys.push([1,3,,7]);rr();return[4,ge()];case 2:w.sent();d=(n=ze.shippingData)===null||n===void 0?void 0:n.find(Boolean);l=(t=ze.landedCostData)===null||t===void 0?void 0:t.find((function(e){return e.landedCost.shipmentRating.id===(d===null||d===void 0?void 0:d.id)}));c=!!l?l.subtotals:null;if(c){He({method:(l===null||l===void 0?void 0:l.landedCost.method)||"DDP",subtotals:c})}return[3,7];case 3:f=w.sent();ze.landedCostData=[];ze.shippingData=[];m=["The landed cost calculation request was aborted to initiate a new one."];if(!(f instanceof Error&&f.message&&!m.includes(f.message)))return[3,6];if(!(i<1))return[3,5];return[4,ye(Object.assign(Object.assign({},e),{retries:(i||0)+1}))];case 4:w.sent();return[2,{isRequestNotReady:false}];case 5:p=(o=ne.stripeAddressEventData)===null||o===void 0?void 0:o.value;void h({endpoint:"Failed to fetch landed cost (".concat(i," retries)"),errors:[f.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:p}});w.label=6;case 6:v(f);return[3,7];case 7:ne.isFetchingLandedCost=false;return[2,{isRequestNotReady:false}]}}))}))}));var be=e("J",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,t;return __generator(this,(function(o){switch(o.label){case 0:return[4,ye({applyingPromocode:true})];case 1:o.sent();if(ze.step==="payment"){or()}return[4,ve()];case 2:o.sent();n=(e=ze.shippingData)===null||e===void 0?void 0:e.find(Boolean);t=(r=ze.landedCostData)===null||r===void 0?void 0:r.find((function(e){return e.landedCost.id===(n===null||n===void 0?void 0:n.id)}));if(!n||!t){return[2]}return[4,Qe({applySubtotalsOnly:false,landedCostId:t.landedCostId,selectedShippingOption:n})];case 3:o.sent();return[2]}}))}))}));var _e=e("L",(function(){ze.promoCode="";sessionStorage.removeItem("zonos--promo-code");ze.promoCodeError=false;ze.promoCodeApplied=false}));var Se=e("K",(function(){return __awaiter(b,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:if(ze.step==="payment"){or()}_e();return[4,be()];case 1:e.sent();return[2]}}))}))}));var Oe=e("M",(function(e){var r=[];var n=true;var t=window.Zonos.isCollect;var o=window.Zonos.isInvoice;switch(e){case"succeeded":{r=[a("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."),"",a("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.")];if(t||o){r=[a("Thank you for submitting your payment. We appreciate your prompt attention."),"",a("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.")]}n=false;break}case"requires_capture":case"processing":{r=[a("Payment processing. We'll update you when payment is received.")];n=false;break}case"requires_payment_method":{r=[a("Payment failed. Please try another payment method.")];if(t){r=[a("Payment failed. Please reload the page and try another payment method.")]}break}case"requires_action":{n=false;r=[a("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")]}default:{r=[a("Something went wrong.")];break}}return{isError:n,messages:r}}));var Ae=e("v",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,t,o,i,s,u,d,l,d;return __generator(this,(function(m){switch(m.label){case 0:t=n.checkoutSettings.onInventoryCheck;o=!!((r=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||r===void 0?void 0:r.value);if(!(window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&o))return[3,2];return[4,c("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:i=m.sent(),s=i.errors,u=i.json;if(s.length||!u){v("Error occurs when handling inventory refund","warn",JSON.stringify(s));return[2,null]}if(!u.available||u.status===204){return[2,a("The item you're looking for is currently unavailable in our inventory. Please check back later or contact support for assistance with availability.")]}if(u.available||u.status===200){ne.shouldInventoryRefund=true;return[2,null]}return[2,null];case 2:if(typeof t!=="function"){return[2,null]}m.label=3;case 3:m.trys.push([3,5,,6]);return[4,t({items:ze.items},{translate:a,zonosApiRoute:f["vercel"]})];case 4:d=m.sent();return[2,d];case 5:l=m.sent();d=l instanceof Error?l.message:"Unknown error";void h({endpoint:"onInventoryCheck",errors:["cartId: ".concat(window.Zonos.cartId," - ").concat(d)],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:ze.items}});throw l;case 6:return[2]}}))}))}));var Ce=e("B",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n;return __generator(this,(function(t){switch(t.label){case 0:n=!!((r=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||r===void 0?void 0:r.value);if(!window.Zonos.isLegacyCheckout||!window.Zonos.cartData||!n){return[2]}return[4,c("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:t.sent();return[2]}}))}))}));var ke=e("c",(function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,t,o,i,s,u,d,l;var c=e.clientSecret,f=e.storybookForceStatus;return __generator(this,(function(e){switch(e.label){case 0:if(f){r=Oe(f),n=r.isError,t=r.messages;return[2,{error:n,messages:t}]}o=c||ne.clientSecret;if(!ne.stripe||!o){v("Failed to retrieve payment intent. Stripe is not initialized");return[2,{error:true,message:[a("Something went wrong.")]}]}return[4,ne.stripe.retrievePaymentIntent(o)];case 1:i=e.sent().paymentIntent;s=i===null||i===void 0?void 0:i.status;u=Oe(s),d=u.isError,l=u.messages;return[2,{amount:i===null||i===void 0?void 0:i.amount,currency:i===null||i===void 0?void 0:i.currency,error:d,messages:l,paymentIntentId:i===null||i===void 0?void 0:i.id,paymentMethod:i===null||i===void 0?void 0:i.payment_method,status:s}]}}))}))}));var Ie=e("A",(function(e){return __awaiter(b,void 0,void 0,(function(){var r,n,o,i,s,u,l,c,v,f,m,p;return __generator(this,(function(h){switch(h.label){case 0:o=!!((r=ne.stripePaymentEventData)===null||r===void 0?void 0:r.complete);i=ne.stripeElements;s=ne.stripe;u=ne.clientSecret;ne.customErrorMessage=null;if(!((n=ze.selectedLandedCost)===null||n===void 0?void 0:n.landedCost.id)&&!(e===null||e===void 0?void 0:e.noLandedCostCheck)){throw new Error("Attempted to confirm the payment when no landed cost is found in store")}return[4,Z()];case 1:l=h.sent();if(!l.valid){ne.customErrorMessage=l.errorMessage;throw new Error(l.errorMessage)}c=t.checkoutSessionId;if(!(s&&i&&o&&u&&c))return[3,3];v=new URL(window.location.href);v.searchParams.set("payment_intent_client_secret",u);v.searchParams.set("zonosCheckoutSessionId",c);void H({checkoutSessionId:c,eventName:"checkout_paymentInfoCompleted"});return[4,s.confirmPayment({confirmParams:{return_url:v.toString()},elements:i,redirect:"if_required"})];case 2:f=h.sent(),m=f.error,p=f.paymentIntent;d("Payment intent confirmed","info",{error:m,paymentIntent:p});if((p===null||p===void 0?void 0:p.status)==="requires_action"){throw new Error(a("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction."))}if(m){if(m.type==="card_error"||m.type==="validation_error"){throw new Error(m.message)}if(m.type==="invalid_request_error"){if(m.code==="payment_intent_unexpected_state"){return[2]}}throw new Error("An unexpected error occurred.")}if(p.status==="requires_payment_method"){throw new Error(a("Payment failed. Please try another payment method."))}h.label=3;case 3:return[2]}}))}))}));var Te=e("m",(function(){var e;var r=ze.items.reduce((function(e,r){return e+r.amount*r.quantity}),0);var n=t.enabledVariantTestKeys||[];var i={adjustmentsAmount:ze.adjustments.reduce((function(e,r){return e+r.amount}),0),cartId:window.Zonos.cartId,currency:((e=ze.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"",customerAuthenticationToken:ze.customerAuthenticationToken||undefined,isCollect:!!window.Zonos.isCollect,isInvoice:!!window.Zonos.isInvoice,itemsAmount:r,metadata:[{key:"language",value:o.selectedLocale}],presentmentCountryCode:o.selectedCountryCode,skipPaymentIntent:ne.skipPaymentIntent,varianceTestInput:n};return i}));var Ee=e("k",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o,i;return __generator(this,(function(s){switch(s.label){case 0:if(!t.checkoutSessionId){void h({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:l,cartId:window.Zonos.cartId}});Ye({messages:[a("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:a("Error creating Checkout")});return[2]}return[4,c("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:t.checkoutSessionId},method:"POST"})];case 1:r=s.sent(),n=r.errors,o=r.json;i=(e=o===null||o===void 0?void 0:o.checkoutSessionPaymentIntentCreate)===null||e===void 0?void 0:e.clientSecret;if(n.length||!i){v("Error occurs when getting payment intent",JSON.stringify(n,null,2));void h({endpoint:"Error creating payment intent",errors:n.map((function(e){return e.message})),metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:t.checkoutSessionId,clientSecret:i}});Ye({messages:[a("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:a("Error creating Checkout")});return[2]}Ge(o.checkoutSessionPaymentIntentCreate);return[2]}}))}))}));var Ne=e("j",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,t,i,a,s,u;return __generator(this,(function(l){switch(l.label){case 0:if(!o.targetCurrency){v("Failed to create checkout session - missing localizationStore.targetCurrency");return[2,false]}ne.isFetchingSession=true;n=Te();d("Checkout session body","info",n);return[4,c("/api/zonos-elements/create-checkout-session",{body:n,method:"POST"})];case 1:t=l.sent(),i=t.errors,a=t.json;ne.isFetchingSession=false;if(i.length||!a){s=(e=i.find((function(e){return e.message})))===null||e===void 0?void 0:e.message;if(Array.isArray(s)&&s.some((function(e){return e.message==="Cart is expired."}))){throw new Error("Cart is expired.")}v("Error occurred when creating checkout session",JSON.stringify(i,null,2));return[2,false]}u=a.checkoutSessionCreate;Ge(u);He({method:((r=u.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:u.subtotals});d("Exchange rate updated for cart items (checkout session create)","info",ze.exchangeRate);d("done-init-checkout-session");return[2,true]}}))}))}));var je=e("u",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,o;return __generator(this,(function(i){switch(i.label){case 0:e=t.checkoutSessionId;if(!e){v("Failed to update checkout session base currency");return[2,false]}if(n.checkoutSettings.allowedSettlementCurrencies==="LOCAL"){d('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency');return[2,true]}return[4,c("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:e,currencyCode:ne.checkoutSettlementCurrency},method:"POST"})];case 1:r=i.sent().json;o=r===null||r===void 0?void 0:r.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;if(!r||o!==ne.checkoutSettlementCurrency){v("Failed to update checkout session base currency");return[2,false]}d('Updated checkout session to settlement currency "'.concat(o,'".'));return[2,true]}}))}))}));var Pe=function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,i,a;var s=e.adjustmentsAmount,u=e.cartId,d=e.currency,l=e.id,f=e.itemsAmount,m=e.landedCostId,p=e.presentmentCountryCode,h=e.storeCreditApplication;return __generator(this,(function(e){switch(e.label){case 0:r=t.enabledVariantTestKeys||[];return[4,c("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:s,billToPartyId:ne.partyBillingId,cartId:u,currency:d,customerAuthenticationToken:ze.customerAuthenticationToken||undefined,id:l,itemsAmount:f,landedCostId:m,metadata:[{key:"language",value:o.selectedLocale}],presentmentCountryCode:p,shipToPartyId:ne.partyShippingId,skipPaymentIntent:ne.skipPaymentIntent,storeCreditApplication:h,varianceTestInput:r},method:"POST"})];case 1:n=e.sent(),i=n.errors,a=n.json;if(i.length||!a){v("Error occurs when updating checkout session",JSON.stringify(i,null,2));return[2,{errors:i,json:a}]}return[2,{errors:[],json:a}]}}))}))};var De=function(e){var r,n,t,o,i,a;var s=e.currentAddress,u=e.translatedAddressResult;var d={};if(!u){return d}var l=u.city,c=u.line1,v=u.line2,f=u.name,m=u.postal_code,p=u.state;if(s.city&&l){d.city=(r={},r[s.city]=l,r)}if(s.line1&&c){d.line1=(n={},n[s.line1]=c,n)}if(s.line2&&v){d.line2=(t={},t[s.line2]=v,t)}if(s.postal_code&&m){d.postal_code=(o={},o[s.postal_code]=m,o)}if(s.state&&p){d.state=(i={},i[s.state]=p,i)}if(s.name&&f){d.name=(a={},a[s.name]=f,a)}return d};var Le=e("P",(function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,t,o,i,a,s,u,d,l,f;var m=e.addressInvalidCharactersList,p=e.billingAddressInvalidCharactersList;return __generator(this,(function(e){switch(e.label){case 0:i=G({addressInvalidCharactersList:m,billingAddressInvalidCharactersList:p,stripeAddressEventData:ne.stripeAddressEventData,stripeBillingAddressEventData:ne.stripeBillingAddressEventData,stripeShippingSameAsBilling:ne.stripeShippingSameAsBilling});if(!i){ne.translatedAddress={address:{},billingAddress:{}};return[2]}a=de();if(!a){return[2]}return[4,c("/api/zonos-elements/validate-address",{body:i,method:"POST"})];case 1:s=e.sent(),u=s.errors,d=s.json;if(u.length||!d){v("Error occurs when translating address to latin",JSON.stringify(u,null,2));ne.translatedAddress={address:{},billingAddress:{}};return[2]}ne.stripeAddressUsedWhenValidatingAddress=ne.stripeAddressEventData;ne.stripeBillingAddressUsedWhenValidatingAddress=ne.stripeBillingAddressEventData;l=(r=ne.stripeAddressEventData)===null||r===void 0?void 0:r.value.address;f=(n=ne.stripeBillingAddressEventData)===null||n===void 0?void 0:n.value.address;ne.translatedAddress={address:l?De({currentAddress:Object.assign(Object.assign({},l),{name:(t=ne.stripeAddressEventData)===null||t===void 0?void 0:t.value.name}),translatedAddressResult:d.address||null}):{},billingAddress:!ne.stripeShippingSameAsBilling?De({currentAddress:Object.assign(Object.assign({},f),{name:(o=ne.stripeBillingAddressEventData)===null||o===void 0?void 0:o.value.name}),translatedAddressResult:d.billingAddress||null}):{}};return[2]}}))}))}));ee("clientSecret",(function(e){if(e&&ne.stripe){sessionStorage.setItem("zonos--client-secret",e)}if(!e){sessionStorage.removeItem("zonos--client-secret")}}));var xe=r((function(){return{addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:false,checkoutTimeoutInterval:null,currency:"USD",customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:false,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:false,isSelectedShippingGuarantee:false,isStagingMode:p(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:sessionStorage.getItem("zonos--promo-code")||"",promoCodeApplied:!!sessionStorage.getItem("zonos--promo-code"),promoCodeError:false,restrictedItems:[],selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,shouldHideDiscountInput:false,step:"customer-info",storeCredit:0,subtotal:0,tabItems:{"customer-info":{index:1,isDone:false,label:"Customer",value:"customer-info"},shipping:{index:2,isDone:false,label:"Shipping",value:"shipping"},payment:{index:3,isDone:false,label:"Payment",value:"payment"}},total:0}})),Re=xe.onChange,Ue=xe.reset,ze=xe.state;e({D:Re,d:ze});var Be=function(e){switch(e){case"DAYS":return a("days");case"WEEKS":return a("weeks");case"BUSINESS_DAYS":default:return a("business days")}};var Fe=e("S",(function(e){var r;var n=(r=e.shippingProfile)===null||r===void 0?void 0:r.transitTime;if(!(n===null||n===void 0?void 0:n.min)||!(n===null||n===void 0?void 0:n.max)||!(n===null||n===void 0?void 0:n.type)){return null}return{maxTransit:n.max,minTransit:n.min,unit:Be(n.type)}}));var Je=function(e){var r=e.item1,n=e.item2;if(!r||!n){return false}return n.sku&&r.sku&&r.sku===n.sku||n.description&&r.description&&r.description===n.description||r.name&&n.name&&r.name===n.name};var Me=function(e){d("Checking item restrictions");var r=e.map((function(e){if(!e.restriction){return null}var r=e.restriction;var n=ze.items.find((function(r){return Je({item1:r,item2:e})}));return Object.assign(Object.assign({matchedItem:n},e),{restriction:r})})).filter(Boolean);ze.restrictedItems=r;ze.items=ze.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:!!r.find((function(r){return Je({item1:r,item2:e})}))})}));return{cartItems:ze.items,restrictedItems:r}};var qe=null;var We=e("f",(function(){t.checkoutSessionId=null;if(qe){clearTimeout(qe);qe=null}k();Ue()}));var Ye=e("n",(function(e){var r=e.messages,n=e.title;We();ue();ze.step="error";ze.error={messages:r,title:n}}));var He=function(e){var r=e.dutiesTaxesFeesEstimate,n=e.method,t=e.subtotals;var o;ze.exchangeRate=t.exchangeRate;ze.adjustmentTotal=t.adjustments;ze.dutiesTaxesFees=n==="DAP"?null:t.landedCostTotal;ze.storeCredit=(o=t.storeCredit)!==null&&o!==void 0?o:0;ze.subtotal=t.items;ze.total=t.total;ze.currency=t.presentmentCurrencyCode;ze.dutiesTaxesFeesEstimate=r||null};var Ke=e("I",(function(){var e=ze.items.filter((function(e){return e.amount>0}));return!!e.find((function(e){return!e.isRestricted}))}));var Ge=e("p",(function(e){var r,n,o,i,a,c,v;ne.clientSecret=e.clientSecret;ne.stripeCustomerSessionClientSecret=e.customerSessionClientSecret;ne.customerProfile=e.customerProfile;ze.checkoutSession=e;I((n=(r=e.customerProfile)===null||r===void 0?void 0:r.storeCreditBalance)!==null&&n!==void 0?n:null);if(!e.id){void h({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:l,checkoutSession:e}})}if(e.id){t.checkoutSessionId=e.id}var f=s(e.varianceTestResults||[]);u(f);var m=((a=(i=(o=ze.checkoutSession)===null||o===void 0?void 0:o.metadata)===null||i===void 0?void 0:i.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||a===void 0?void 0:a.value)||((v=(c=window.Zonos.cartData)===null||c===void 0?void 0:c.metadata.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||v===void 0?void 0:v.value)||null;if(m){d("Found externalConfirmationPageURL: ".concat(m));ze.externalConfirmationPageURL=m}}));var Ve=function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,i,s,u,l;var c=e.adjustmentsAmount,f=e.cartId,m=e.currency,p=e.dutiesTaxesFeesEstimate,h=e.itemsAmount,w=e.landedCostId,g=e.shouldInitSessionOnFailure;return __generator(this,(function(e){switch(e.label){case 0:if(w&&ze.selectedLandedCost){n=ze.selectedLandedCost.subtotals;He({dutiesTaxesFeesEstimate:p,method:ze.landedCostMethod,subtotals:n});d("Exchange rate updated for cart items (landed cost subtotal)","info",ze.exchangeRate)}if(!t.checkoutSessionId){d("Could not update cart total without checkout session id","info");return[2,false]}return[4,Pe({adjustmentsAmount:c,billToPartyId:ne.partyBillingId,cartId:f,currency:m,id:t.checkoutSessionId,itemsAmount:h,landedCostId:w,presentmentCountryCode:o.selectedCountryCode,shipToPartyId:ne.partyShippingId,varianceTestInput:t.enabledVariantTestKeys||[]})];case 1:i=e.sent(),s=i.errors,u=i.json;if(!(s.length>0||!u))return[3,4];v("Error occurs when updating checkout session.");if(!g)return[3,3];d("Initiating checkout session on failure","info");return[4,Ne()];case 2:l=e.sent();d("stripeStoreInitCheckoutSession: ".concat(l));if(!l){Ye({messages:[a("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:a("Error creating Checkout")});return[2,false]}return[2,true];case 3:return[2,false];case 4:if(!w){He({method:((r=u.checkoutSessionUpdate.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:u.checkoutSessionUpdate.subtotals});d("Exchange rate updated for cart items (checkout session update)","info",ze.exchangeRate)}Ge(u.checkoutSessionUpdate);return[2,true]}}))}))};var Ze=e("T",(function(e){var r,t,o;if(e.method==="DAP"&&((t=(r=n.genericSettings)===null||r===void 0?void 0:r.domesticCountries)===null||t===void 0?void 0:t.includes(((o=ne.stripeAddressEventData)===null||o===void 0?void 0:o.value.address.country)||"US"))){return"DDP"}if(e.method==="DAP"&&e.remittance.length&&e.landedCostGuaranteeCode==="ZONOS"){return"DDP"}return e.method}));var Qe=e("H",(function(e){return __awaiter(b,[e],void 0,(function(e){var r,o,i,a,s,u,l,c,v,f,m,p,h,w,g,y,b,_,S,O,A,C,k,I,T;var E=e.applySubtotalsOnly,N=e.landedCostId,j=e.selectedShippingOption;return __generator(this,(function(e){switch(e.label){case 0:d("Updating selected shipping option","info",{landedCostId:N,selectedShippingOption:j});ze.selectedShippingOption=j;p=Fe(ze.selectedShippingOption);if(p){h=p.maxTransit,w=p.minTransit,g=p.unit;ze.selectedShippingOptionTransitTime="".concat(w,"-").concat(h," ").concat(g)}else{ze.selectedShippingOptionTransitTime=""}y=(r=ze.landedCostData)===null||r===void 0?void 0:r.find((function(e){return e.landedCostId===N}));ze.selectedLandedCost=y||null;if(!y){return[2,false]}b=((o=y.landedCost.amountSubtotals)===null||o===void 0?void 0:o.landedCostTotal)||0;_=y.subtotals.exchangeRate.rate;S=b*_;if(S){d("DAP quote, using estimate: ".concat(S),"info")}ze.landedCostMethod=Ze(y.landedCost);ze.shipping=y.subtotals.shipping;O=((i=y===null||y===void 0?void 0:y.landedCost)===null||i===void 0?void 0:i.landedCostGuaranteeCode)==="ZONOS";A=!!((s=(a=y===null||y===void 0?void 0:y.landedCost)===null||a===void 0?void 0:a.deMinimis)===null||s===void 0?void 0:s.find((function(e){return["DUTY","TAX"].includes(e.type)&&e.threshold==="ABOVE"})));ze.isSelectedShippingAboveDeminimis=A;ze.isSelectedShippingGuarantee=O;C=false;if(!E)return[3,1];k=y.subtotals;He({dutiesTaxesFeesEstimate:S,method:ze.landedCostMethod,subtotals:k});d("Exchange rate updated for cart items (landed cost subtotal)","info",ze.exchangeRate);C=true;return[3,3];case 1:return[4,Ve({adjustmentsAmount:ze.adjustmentTotal,billToPartyId:ne.partyBillingId,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:S,landedCostId:(u=y.landedCost)===null||u===void 0?void 0:u.id,shipToPartyId:ne.partyShippingId,varianceTestInput:t.enabledVariantTestKeys||[]})];case 2:C=e.sent();e.label=3;case 3:I=(l=ze.items.find(Boolean))===null||l===void 0?void 0:l.currencyCode;T=((c=ne.stripeAddressEventData)===null||c===void 0?void 0:c.value.address.country)||"US";ne.shouldRenderPayInUsdButton=I==="USD"&&n.checkoutSettings.allowedSettlementCurrencies==="LOCAL_AND_USD"&&((v=ze.checkoutSession)===null||v===void 0?void 0:v.subtotals.presentmentCurrencyCode)!=="USD"&&!!((m=(f=n.genericSettings)===null||f===void 0?void 0:f.usdSettlementCountryEnabled)===null||m===void 0?void 0:m.includes(T));return[2,C]}}))}))}));var Xe=e("l",(function(e){var r=e.isPreview,n=e.sessionTimeout;if(r){return}var t=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout");var o=t&&!isNaN(parseInt(t,10))?parseInt(t,10):n;d("==START CHECKOUT TIMEOUT - ".concat(o,"=="));ze.checkoutTimeoutInterval=setTimeout((function(){ze.checkoutSessionTimeoutShow=true}),o)}));var $e=e("h",(function(){if(ze.checkoutTimeoutInterval){clearTimeout(ze.checkoutTimeoutInterval);ze.checkoutTimeoutInterval=null}}));var er=function(e){return e.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}))};var rr=function(){ze.items=ze.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}));ze.restrictedItems=[]};var nr=e("e",(function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,o,i;var a=e.adjustments,s=e.cartItems,u=e.landedCostId,d=e.shouldInitSessionOnFailure,l=d===void 0?true:d;return __generator(this,(function(e){switch(e.label){case 0:ze.adjustments=a;ze.items=er(s);n=(r=s.find(Boolean))===null||r===void 0?void 0:r.currencyCode;o=s.reduce((function(e,r){return e+r.amount*r.quantity}),0);i=a.reduce((function(e,r){return e+r.amount}),0);if(!n||!o){return[2]}ze.currency=n;ne.isFetchingSession=true;return[4,Ve({adjustmentsAmount:i,billToPartyId:ne.partyBillingId,cartId:window.Zonos.cartId,currency:n,dutiesTaxesFeesEstimate:0,itemsAmount:o,landedCostId:u,shipToPartyId:ne.partyShippingId,shouldInitSessionOnFailure:l,varianceTestInput:t.enabledVariantTestKeys||[]})];case 1:e.sent();ne.isFetchingSession=false;return[2]}}))}))}));var tr=function(){ze.selectedShippingOption=null;ze.isSelectedShippingAboveDeminimis=false;ze.isSelectedShippingGuarantee=false;ze.selectedShippingOptionTransitTime="";ze.dutiesTaxesFees=0;ze.dutiesTaxesFeesEstimate=0;ze.shipping=0;ze.total=ze.subtotal};var or=function(){if(ze.step==="shipping"){ze.step="customer-info";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{"customer-info":Object.assign(Object.assign({},ze.tabItems.shipping),{isDone:false})})}else if(ze.step==="payment"){ze.step="shipping";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{shipping:Object.assign(Object.assign({},ze.tabItems.shipping),{isDone:false})})}else if(ze.step==="finish"){ze.step="payment";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{payment:Object.assign(Object.assign({},ze.tabItems.payment),{isDone:false})})}};var ir=e("r",(function(){if(ze.step==="customer-info"){ze.step="shipping";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{"customer-info":Object.assign(Object.assign({},ze.tabItems["customer-info"]),{isDone:true})})}else if(ze.step==="shipping"){ze.step="payment";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{shipping:Object.assign(Object.assign({},ze.tabItems.shipping),{isDone:true})})}else if(ze.step==="payment"){ze.step="finish"}}));var ar=e("g",(function(){ze.step="customer-info";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{"customer-info":Object.assign(Object.assign({},ze.tabItems["customer-info"]),{isDone:false}),payment:Object.assign(Object.assign({},ze.tabItems.payment),{isDone:false}),shipping:Object.assign(Object.assign({},ze.tabItems.shipping),{isDone:false})});tr()}));var sr=function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,i,a,s,u,l,c;return __generator(this,(function(f){switch(f.label){case 0:if(!t.checkoutSessionId){d("Could not update store credit without checkout session id","info");return[2]}n=ze.selectedLandedCost;i=ze.currency||((e=ze.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"";a=ze.adjustments.reduce((function(e,r){return e+r.amount}),0);s=ze.items.reduce((function(e,r){return e+r.amount*r.quantity}),0);return[4,Pe({adjustmentsAmount:a,cartId:window.Zonos.cartId,currency:i,id:t.checkoutSessionId,itemsAmount:s,landedCostId:n===null||n===void 0?void 0:n.landedCostId,presentmentCountryCode:o.selectedCountryCode,storeCreditApplication:D()})];case 1:u=f.sent(),l=u.errors,c=u.json;if(l.length>0||!c){v("Error updating checkout session with store credit");return[2]}He({method:((r=c.checkoutSessionUpdate.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:c.checkoutSessionUpdate.subtotals});Ge(c.checkoutSessionUpdate);return[2]}}))}))};var ur=e("X",(function(){if(qe){clearTimeout(qe)}qe=setTimeout((function(){qe=null;void sr()}),300)}))}}}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
System.register(["./p-
|
|
1
|
+
System.register(["./p-2ec799e4.system.js","./p-1523f6a8.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 f=n.currency;var d=(o=n.items[0])===null||o===void 0?void 0:o.currencyCode;if(d===f){return u({amount:s,currency:f})}var l=n.displayBaseCurrency;var m=t();if(e){var y=l?s/c:s;return u({amount:y,currency:m})}var j=l?s:s*c;return u({amount:j,currency:m})}))}}}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{l as o}from"./p-a18adf27.js";const r="gkjqw123",a="Kq93wqw3",v=()=>{var v;return null===(v=o.inclusivePricingConfigurations)||void 0===v?void 0:v.some((o=>{var v,d;return"ENABLED"===(null===(v=o.configurations[r])||void 0===v?void 0:v.status)||"ENABLED"===(null===(d=o.configurations[a])||void 0===d?void 0:d.status)}))};export{r as D,a as T,v as h}
|