@zonos/elements 1.3.4 → 1.3.5-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{cart-f31374d4.js → cart-f038cf46.js} +6 -1
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/zonos-address_2.cjs.entry.js +36 -26
- package/dist/cjs/zonos-cart-items_10.cjs.entry.js +1 -1
- package/dist/cjs/zonos-checkout.cjs.entry.js +1 -1
- package/dist/cjs/zonos-controller.cjs.entry.js +1 -1
- package/dist/cjs/zonos-payment.cjs.entry.js +1 -1
- package/dist/collection/components/stripe/zonos-address/zonos-address.js +35 -25
- package/dist/collection/components/utils/api/calculateLandedCost.js +6 -1
- package/dist/components/cart.js +6 -1
- package/dist/components/zonos-address2.js +35 -25
- package/dist/esm/{cart-c9124cc3.js → cart-ba9b0d4c.js} +6 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/zonos-address_2.entry.js +36 -26
- package/dist/esm/zonos-cart-items_10.entry.js +1 -1
- package/dist/esm/zonos-checkout.entry.js +1 -1
- package/dist/esm/zonos-controller.entry.js +1 -1
- package/dist/esm/zonos-payment.entry.js +1 -1
- package/dist/esm-es5/cart-ba9b0d4c.js +1 -0
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/zonos-address_2.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_10.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-payment.entry.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/scripts/zonosBase.js +1 -1
- package/dist/types/components/stripe/zonos-address/zonos-address.d.ts +1 -0
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-ffc91e42.entry.js → p-1165b6e5.entry.js} +1 -1
- package/dist/zonos-elements/{p-741a1402.system.entry.js → p-12c19be6.system.entry.js} +1 -1
- package/dist/zonos-elements/p-245997d9.js +1 -0
- package/dist/zonos-elements/{p-c134eecd.system.js → p-59343e23.system.js} +1 -1
- package/dist/zonos-elements/{p-f7b1dfd0.system.entry.js → p-7beaee33.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-43220d68.entry.js → p-824ebf9d.entry.js} +1 -1
- package/dist/zonos-elements/p-839f6cd9.entry.js +1 -0
- package/dist/zonos-elements/{p-62851827.system.entry.js → p-8970e202.system.entry.js} +1 -1
- package/dist/zonos-elements/p-b035f9e5.system.js +1 -1
- package/dist/zonos-elements/{p-b494d540.entry.js → p-be4bc6bc.entry.js} +1 -1
- package/dist/zonos-elements/p-c3d75f4f.system.js +1 -0
- package/dist/zonos-elements/{p-d170748c.system.entry.js → p-da2387d2.system.entry.js} +1 -1
- package/dist/zonos-elements/p-dcf1e1b4.system.entry.js +1 -0
- package/dist/zonos-elements/{p-139fc767.entry.js → p-fdb9568e.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/esm-es5/cart-c9124cc3.js +0 -1
- package/dist/zonos-elements/p-2ac66cea.system.entry.js +0 -1
- package/dist/zonos-elements/p-51a40ddf.system.js +0 -1
- package/dist/zonos-elements/p-97e659b7.entry.js +0 -1
- package/dist/zonos-elements/p-e59b6648.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export{c as cartStore,a as cartStoreApplySubtotals,b as cartStoreGetShippingTransitInfo,d as cartStoreNextStep,e as cartStorePreviousStep,f as cartStoreReCalculateTotal,g as cartStoreReset,h as cartStoreUpdateItems,i as cartStoreUpdateSelectedShippingOption,j as cartStoreUpdateToErrorState}from"./p-
|
|
1
|
+
export{c as cartStore,a as cartStoreApplySubtotals,b as cartStoreGetShippingTransitInfo,d as cartStoreNextStep,e as cartStorePreviousStep,f as cartStoreReCalculateTotal,g as cartStoreReset,h as cartStoreUpdateItems,i as cartStoreUpdateSelectedShippingOption,j as cartStoreUpdateToErrorState}from"./p-245997d9.js";import"./p-e8da4463.js";import"./p-4d8545e1.js";import"./p-8ebc0b64.js";import"./p-0024f8c2.js";import"./p-f2733cc7.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,h as n,H as s,d as t}from"./p-4d8545e1.js";import{s as e}from"./p-
|
|
1
|
+
import{r as o,h as n,H as s,d as t}from"./p-4d8545e1.js";import{s as e}from"./p-245997d9.js";import"./p-e8da4463.js";import"./p-8ebc0b64.js";import"./p-0024f8c2.js";import"./p-f2733cc7.js";const a=class{constructor(n){o(this,n),this.titleText=void 0,this.stripe=e.stripe,this.stripeElements=e.stripeElements}watchInitStripe(){if(!this.stripeElements)return;const o=e.stripePaymentElement||this.stripeElements.create("payment",{layout:"tabs"}),n=this.el.querySelector(".zonos--payment-component");n?(o.mount(n),o.on("change",(o=>{e.stripePaymentEventData=o})),e.stripePaymentElement=o):console.error("Cannot find container element for paymentElement")}componentDidLoad(){this.watchInitStripe()}render(){return n(s,{key:"8a674f72e9235f9b6afcc8d8e0374639423e0bb3",class:"zonos--payment zonos--elements"},this.titleText&&n("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),n("div",{key:"94a0a064e6f6d8058bc11d114ecc4c3ab495e802",class:"zonos--payment-component"}))}get el(){return t(this)}static get watchers(){return{stripeElements:["watchInitStripe"],stripe:["watchInitStripe"]}}};a.style=".sc-zonos-payment-h{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-payment-h *.sc-zonos-payment{font-family:var(--font-family, Inter), Inter}.sc-zonos-payment-h img.sc-zonos-payment{max-width:100%}.sc-zonos-payment-h dl.sc-zonos-payment,.sc-zonos-payment-h dd.sc-zonos-payment,.sc-zonos-payment-h h1.sc-zonos-payment,.sc-zonos-payment-h h2.sc-zonos-payment,.sc-zonos-payment-h h3.sc-zonos-payment,.sc-zonos-payment-h h4.sc-zonos-payment,.sc-zonos-payment-h h5.sc-zonos-payment,.sc-zonos-payment-h h6.sc-zonos-payment,.sc-zonos-payment-h hr.sc-zonos-payment,.sc-zonos-payment-h figure.sc-zonos-payment,.sc-zonos-payment-h p.sc-zonos-payment,.sc-zonos-payment-h pre.sc-zonos-payment{margin:0}.sc-zonos-payment-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-payment-h .zonos--title.sc-zonos-payment{margin-bottom:var(--amino-space-16)}";export{a as zonos_payment}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(o,n,e,t){function c(o){return o instanceof e?o:new e((function(n){n(o)}))}return new(e||(e=Promise))((function(e,s){function r(o){try{a(t.next(o))}catch(o){s(o)}}function i(o){try{a(t["throw"](o))}catch(o){s(o)}}function a(o){o.done?e(o.value):c(o.value).then(r,i)}a((t=t.apply(o,n||[])).next())}))};var __generator=this&&this.__generator||function(o,n){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},t,c,s,r;return r={next:i(0),throw:i(1),return:i(2)},typeof Symbol==="function"&&(r[Symbol.iterator]=function(){return this}),r;function i(o){return function(n){return a([o,n])}}function a(i){if(t)throw new TypeError("Generator is already executing.");while(r&&(r=0,i[0]&&(e=0)),e)try{if(t=1,c&&(s=i[0]&2?c["return"]:i[0]?c["throw"]||((s=c["return"])&&s.call(c),0):c.next)&&!(s=s.call(c,i[1])).done)return s;if(c=0,s)i=[i[0]&2,s.value];switch(i[0]){case 0:case 1:s=i;break;case 4:e.label++;return{value:i[1],done:false};case 5:e.label++;c=i[1];i=[0];continue;case 7:i=e.ops.pop();e.trys.pop();continue;default:if(!(s=e.trys,s=s.length>0&&s[s.length-1])&&(i[0]===6||i[0]===2)){e=0;continue}if(i[0]===3&&(!s||i[1]>s[0]&&i[1]<s[3])){e.label=i[1];break}if(i[0]===6&&e.label<s[1]){e.label=s[1];s=i;break}if(s&&e.label<s[2]){e.label=s[2];e.ops.push(i);break}if(s[2])e.ops.pop();e.trys.pop();continue}i=n.call(o,e)}catch(o){i=[6,o];c=0}finally{t=s=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};System.register(["./p-4d39efb6.system.js","./p-51a40ddf.system.js","./p-a6f2e282.system.js","./p-dc09ca69.system.js","./p-ee8b44c0.system.js","./p-23e7c655.system.js","./p-12ecf765.system.js","./p-7f68c103.system.js"],(function(o){"use strict";var n,e,t,c,s,r,i,a,u,h,l,d,f,z,m,v,k,p,g,b,w,y,x,_,C,B;return{setters:[function(o){n=o.r;e=o.h;t=o.F;c=o.H},function(o){s=o.k;r=o.c;i=o.h;a=o.g;u=o.s;h=o.l;l=o.j;d=o.m;f=o.d;z=o.n;m=o.o;v=o.e},function(o){k=o.a;p=o.l;g=o.t},function(o){b=o.z;w=o.m},function(o){y=o.s;x=o.i},function(o){_=o.c},function(o){C=o.g},function(o){B=o.i}],execute:function(){var j='<svg color="var(--amino-gray-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M9.707 16.707a1 1 0 0 1-1.414 0l-3.647-3.646a1.5 1.5 0 0 1 0-2.122l3.647-3.646a1 1 0 0 1 1.414 1.414L7.414 11H19a1 1 0 1 1 0 2H7.414l2.293 2.293a1 1 0 0 1 0 1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>';var L='<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="https://www.w3.org/2000/svg">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M2.25 4.5C2.25 3.25736 3.25736 2.25 4.5 2.25H13.5C14.7426 2.25 15.75 3.25736 15.75 4.5V10.5C15.75 11.7426 14.7426 12.75 13.5 12.75H8.25C8.01393 12.75 7.79164 12.8611 7.65 13.05L6.3 14.85C5.87508 15.4166 5.2082 15.75 4.5 15.75C3.25736 15.75 2.25 14.7426 2.25 13.5V4.5ZM4.5 3.75C4.08579 3.75 3.75 4.08579 3.75 4.5V13.5C3.75 13.9142 4.08579 14.25 4.5 14.25C4.73607 14.25 4.95836 14.1389 5.1 13.95L6.45 12.15C6.87492 11.5834 7.5418 11.25 8.25 11.25H13.5C13.9142 11.25 14.25 10.9142 14.25 10.5V4.5C14.25 4.08579 13.9142 3.75 13.5 3.75H4.5ZM5.25 6C5.25 5.58579 5.58579 5.25 6 5.25H12C12.4142 5.25 12.75 5.58579 12.75 6C12.75 6.41421 12.4142 6.75 12 6.75H6C5.58579 6.75 5.25 6.41421 5.25 6ZM5.25 9C5.25 8.58579 5.58579 8.25 6 8.25H8.25C8.66421 8.25 9 8.58579 9 9C9 9.41421 8.66421 9.75 8.25 9.75H6C5.58579 9.75 5.25 9.41421 5.25 9Z" fill="#4D505A"/>\n</svg>\n';var I='<svg color="var(--amino-gray-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" data-is-secondary-color="true" fill="var(--amino-gray-200)" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>';var S=".sc-zonos-checkout-h{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-checkout-h *.sc-zonos-checkout{font-family:var(--font-family, Inter), Inter}.sc-zonos-checkout-h img.sc-zonos-checkout{max-width:100%}.sc-zonos-checkout-h dl.sc-zonos-checkout,.sc-zonos-checkout-h dd.sc-zonos-checkout,.sc-zonos-checkout-h h1.sc-zonos-checkout,.sc-zonos-checkout-h h2.sc-zonos-checkout,.sc-zonos-checkout-h h3.sc-zonos-checkout,.sc-zonos-checkout-h h4.sc-zonos-checkout,.sc-zonos-checkout-h h5.sc-zonos-checkout,.sc-zonos-checkout-h h6.sc-zonos-checkout,.sc-zonos-checkout-h hr.sc-zonos-checkout,.sc-zonos-checkout-h figure.sc-zonos-checkout,.sc-zonos-checkout-h p.sc-zonos-checkout,.sc-zonos-checkout-h pre.sc-zonos-checkout{margin:0}.sc-zonos-checkout-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar{width:10px}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-track{background:var(--amino-gray-50)}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb{border-radius:10px;background:#cccccc;border:3px solid transparent;background-clip:content-box}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb:hover{background:#d6d6d6}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;height:100%;overflow:hidden;border-radius:var(--border-radius, var(--amino-radius-10))}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex:1;flex:1;padding:var(--amino-space-48) var(--amino-space-56)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{background-color:var(--primary-color, var(--amino-gray-0));border-right:1px solid var(--amino-gray-200)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{background-color:var(--amino-gray-0);padding-bottom:var(--amino-space-80)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:100%;max-height:100%;height:100%;overflow:auto;-ms-flex-direction:column;flex-direction:column;background-color:var(--amino-gray-0);-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:var(--amino-space-24);padding-bottom:50px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;width:100%}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout img.sc-zonos-checkout{width:150px;min-width:150px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--logo.sc-zonos-checkout{margin-bottom:0}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout zonos-checkout-finish.sc-zonos-checkout{-ms-flex:1;flex:1}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--back-button.sc-zonos-checkout{margin-bottom:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{padding:0 var(--amino-space-8) var(--amino-space-8)}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--payment-error-banner.sc-zonos-checkout{margin-top:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout{position:relative}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout .zonos--close-button.sc-zonos-checkout{position:absolute;right:var(--amino-space-24);top:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--footer.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-pack:end;justify-content:flex-end;-ms-flex-align:center;align-items:center;position:absolute;bottom:var(--amino-space-32);right:var(--amino-space-56);gap:var(--amino-space-8)}.sc-zonos-checkout-h .zonos--wrapper.sc-zonos-checkout{overflow:auto;max-height:100%;position:relative}.sc-zonos-checkout-h .flex--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;max-height:100%}.sc-zonos-checkout-h .zonos--logo.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.sc-zonos-checkout-h .zonos--checkout-default-message.sc-zonos-checkout{margin-left:var(--amino-space-76);margin-bottom:var(--amino-space-8)}.preview.sc-zonos-checkout-h{min-width:500px;margin:auto}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{border:var(--amino-border)}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{padding:var(--amino-space-32)}.mobile.sc-zonos-checkout-h{min-width:auto}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:auto;border-radius:0;max-height:100%;height:100%;border:0}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{padding:var(--amino-space-12)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{-ms-flex-order:2;order:2}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex-order:1;order:1;padding-top:var(--amino-space-16)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:var(--amino-space-16);margin-top:var(--amino-space-24);border:var(--amino-border);border-radius:var(--border-radius, var(--amino-radius-10));background-color:var(--amino-gray-50);padding:var(--amino-space-12);margin-top:var(--amino-space-32)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{max-height:100%}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--footer.sc-zonos-checkout{-ms-flex-order:3;order:3}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:auto}.mobile.sc-zonos-checkout-h .zonos--cart-subtotal.sc-zonos-checkout{margin:0}.mobile.sc-zonos-checkout-h .zonos--footer.sc-zonos-checkout{bottom:0;left:0;padding:var(--amino-space-12);position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;background-color:var(--amino-gray-0)}";var H=S;var T=o("zonos_checkout",function(){function o(o){var e=this;n(this,o);this.applyStripeTheme=function(){return __awaiter(e,void 0,void 0,(function(){var o,n,e,t;return __generator(this,(function(c){switch(c.label){case 0:t=((o=this.appearanceSettingsOverride)===null||o===void 0?void 0:o.theme)||b.appearance.theme;return[4,s({overrideBorderRaidus:(n=this.appearanceSettingsOverride)===null||n===void 0?void 0:n.style,overridePrimaryColor:(e=this.appearanceSettingsOverride)===null||e===void 0?void 0:e.colorPrimary,overrideTheme:this.isMobile?t:undefined})];case 1:c.sent();return[2]}}))}))};this.isShippableCountry=function(o){if(o===void 0){o=true}if(!k.localizationLoaded){return false}if(!k.isShippableCountry){if(o){p("Checkout: not shippable country")}return false}return true};this.getCurrentLocalePageEnum=function(){switch(r.step){case"customer-info":return"checkout_customer_info";case"shipping":return"checkout_shipping_info";case"payment":return"checkout_payment_info";default:return null}};this.appearanceSettingsOverride=undefined;this.preview=false;this.mobile=false;this.defaultAddress=null;this.forceDialogOpen=false;this.open=this.forceDialogOpen;this.stripe=window.Zonos.stripe;this.submitLoading=false;this.paymentError=false;this.collapseReviewMobile=false;this.isAttachError=false;this.isMobile=false;this.zonosReviewRef=undefined;this.storybookPaymentStatusOverride=undefined}o.prototype.initCartInfoHandler=function(o){return __awaiter(this,void 0,void 0,(function(){var n;return __generator(this,(function(e){n=o.detail;void i(n);return[2]}))}))};o.prototype.closeDialogHandler=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){y("zonos-checkout-close");this.open=this.forceDialogOpen||false;if(!this.preview&&r.step==="finish"){a()}r.step="customer-info";return[2]}))}))};o.prototype.buildCartAndInit=function(){return __awaiter(this,void 0,void 0,(function(){var o,n;return __generator(this,(function(e){switch(e.label){case 0:if(!b.checkoutSettings.buildCartDetail)return[3,3];p("build cart detail");return[4,b.checkoutSettings.buildCartDetail()];case 1:o=e.sent();return[4,i(o)];case 2:e.sent();e.label=3;case 3:if(!!u.clientSecret)return[3,5];return[4,h()];case 4:n=e.sent();p("stripeStoreInitCheckoutSession: ".concat(n));if(!n){return[2,false]}e.label=5;case 5:return[4,this.applyStripeTheme()];case 6:e.sent();return[2,true]}}))}))};o.prototype.attachCheckout=function(){var o=this;var n=b.checkoutSettings.placeOrderButtonSelector;if(!n){return}var e=document.querySelectorAll(n);e.forEach((function(n){var e=n.getAttribute("data-zonos-checkout-attached");if(e){return}n.addEventListener("click",(function(n){return __awaiter(o,void 0,void 0,(function(){var o,e;return __generator(this,(function(t){switch(t.label){case 0:if(!this.isShippableCountry()){return[2]}n.preventDefault();n.stopPropagation();p("zonos checkout button clicked");u.isFetchingSession=true;this.open=true;t.label=1;case 1:t.trys.push([1,3,,4]);return[4,this.buildCartAndInit()];case 2:o=t.sent();if(!o){throw new Error("Error building cart")}y("zonos-checkout-start");return[3,4];case 3:e=t.sent();u.isFetchingSession=false;l({messages:[g("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:g("Error creating Checkout")});return[3,4];case 4:return[2]}}))}))}));n.removeAttribute("disabled");n.setAttribute("data-zonos-checkout-attached","true")}))};o.prototype.appearanceSettingsOverrideChanged=function(){if(!this.appearanceSettingsOverride){return}void this.applyStripeTheme()};o.prototype.init=function(){return __awaiter(this,void 0,void 0,(function(){var o,n;var e=this;return __generator(this,(function(t){u.stripe=window.Zonos.stripe;this.stripe=window.Zonos.stripe;o=setInterval((function(){var n=window.Zonos.internationalHideSelector;if(!n){clearInterval(o);return}var t=e.isShippableCountry(false);var c=document.querySelectorAll(n);if(!t){c===null||c===void 0?void 0:c.forEach((function(o){var n=o;var e=n.getAttribute("data-zonos-checkout-original-display")||getComputedStyle(n).display;n.style.display=e||"initial"}));return}c===null||c===void 0?void 0:c.forEach((function(o){var n=o;var e=n.style.display;n.setAttribute("data-zonos-checkout-original-display",e);n.style.display="none"}))}),100);n=setInterval((function(){u.stripe=window.Zonos.stripe;e.stripe=window.Zonos.stripe;if(!e.stripe){p("waiting for stripe to be loaded");return}if(e.storybookPaymentStatusOverride){clearInterval(n);return}p("init checkout");if(e.preview||e.forceDialogOpen){void e.buildCartAndInit()}else{e.attachCheckout();var o=new MutationObserver((function(){e.attachCheckout()}));o.observe(document.body,{childList:true,subtree:true})}clearInterval(n)}),50);setTimeout((function(){clearInterval(n)}),1e4);return[2]}))}))};o.prototype.setToFinishStep=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){r.step="finish";this.storybookPaymentStatusOverride=o;return[2]}))}))};o.prototype.handleCustomerInfoContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o;var n=this;return __generator(this,(function(e){switch(e.label){case 0:this.submitLoading=true;return[4,d()];case 1:e.sent();o=setInterval((function(){if(r.landedCostData||!u.isFetchingLandedCost){if(r.landedCostData){f()}n.submitLoading=false;clearInterval(o)}}),500);return[2]}}))}))};o.prototype.handleShippingContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o=this;return __generator(this,(function(n){this.submitLoading=true;setTimeout((function(){f();o.submitLoading=false}),500);return[2]}))}))};o.prototype.handleCheckoutPaymentContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o;return __generator(this,(function(n){switch(n.label){case 0:this.paymentError=false;this.submitLoading=true;n.label=1;case 1:n.trys.push([1,3,,4]);return[4,z()];case 2:n.sent();f();return[3,4];case 3:o=n.sent();console.error(o);this.paymentError=true;return[3,4];case 4:this.submitLoading=false;return[2]}}))}))};o.prototype.handleFinishClick=function(){return __awaiter(this,void 0,void 0,(function(){var o,n;return __generator(this,(function(e){switch(e.label){case 0:m();if(!this.preview)return[3,2];r.step="customer-info";return[4,this.init()];case 1:e.sent();return[2];case 2:a();o=window.location.href;n=o.split("?")[0];window.history.replaceState({},document.title,n);this.open=false;window.location.reload();return[2]}}))}))};o.prototype.handleBackClick=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){switch(o.label){case 0:if(!(r.step==="customer-info"))return[3,2];return[4,this.closeDialogHandler()];case 1:o.sent();return[2];case 2:v();return[2]}}))}))};o.prototype.handleWindowResize=function(){this.isMobile=x(this.mobile);void this.applyStripeTheme();p("mobile: ".concat(this.isMobile))};o.prototype.handleMobileChange=function(){this.isMobile=x(this.mobile);void this.applyStripeTheme();p("mobile: ".concat(this.isMobile))};o.prototype.componentWillLoad=function(){void this.init();this.isMobile=x(this.mobile);p("mobile: ".concat(this.isMobile))};o.prototype.disconnectedCallback=function(){m();a()};o.prototype.render=function(){var o=this;var n;var s=r.step!=="finish"&&r.step!=="error"&&!u.stripeElements||u.isFetchingSession;var i=w(b.appearance,this.appearanceSettingsOverride),a=i.colorPrimary,h=i.colorSecondary,l=i.logoUrl,d=i.style;var f=b.appearance.zonosAttribution==="ENABLED";var z=b.appearance.theme;var m=a&&B(a)?"DARK":"LIGHT";var v=this.isMobile?z:m;var p=!this.isMobile?h:undefined;var y=k.customMessages;var x=((n=y.find((function(o){return o.pageName==="checkout_default"})))===null||n===void 0?void 0:n.message)||"Know about duties and taxes before you buy. Shop with confidence!";var S=this.getCurrentLocalePageEnum();var H=y.filter((function(o){return o.pageName===S}));var T=function(){return e("div",{class:"zonos--logo"},l&&e("img",{alt:"".concat(b.organizationName," logo"),src:l,width:100}))};var M=function(){return e("zonos-v-stack",null,T(),H.map((function(o){return e("zonos-custom-message",{icon:L,message:o.message})})),e("div",null,e("zonos-button",{class:"zonos--back-button",icon:e("zonos-icon",{content:j}),noBackground:true,noPaddingLeft:true,noPaddingRight:true,onClick:function(){return o.handleBackClick()},theme:v},g("Back"))))};var O=function(){return f&&e("div",{class:"zonos--footer","data-theme":z},e("zonos-text",{type:"hintText"},g("Powered by")),e("zonos-logo",{theme:z,width:"100px"}))};var E=function(){var n;var c=o.isMobile?"primary":undefined;var s=(n=o.zonosReviewRef)===null||n===void 0?void 0:n.scrollHeight;return e("div",{class:"zonos--content",style:{"--border-radius":C(d)}},r.step!=="finish"&&r.step!=="error"&&e(t,null,e("div",{class:"zonos--left","data-theme":v,style:{"--primary-color":!o.isMobile?a:""}},!o.isMobile&&M(),r.step==="customer-info"&&e("zonos-customer-info",{continueLoading:o.submitLoading,defaultAddress:o.defaultAddress,onContinueClicked:function(){return o.handleCustomerInfoContinue()},submitBtnColor:p,submitBtnType:c}),r.step==="shipping"&&e("zonos-shipping",{continueLoading:o.submitLoading,onContinueClicked:function(){return o.handleShippingContinue()},submitBtnColor:p,submitBtnType:c}),r.step==="payment"&&e("zonos-checkout-payment",{continueLoading:o.submitLoading,onContinueClicked:function(){return o.handleCheckoutPaymentContinue()},paymentError:o.paymentError,submitBtnColor:p,submitBtnType:c})),e("div",{class:"zonos--right","data-theme":z},o.isMobile&&M(),!o.isMobile&&e("zonos-button",{class:"zonos--close-button",icon:e("zonos-icon",{content:I}),noBackground:true,onClick:function(){return o.closeDialogHandler()}}),e("div",{class:"flex--wrapper"},e("div",{class:"zonos--wrapper"},e("zonos-collapse",{collapseSize:s,collapsed:o.collapseReviewMobile&&o.isMobile},e("zonos-review",{collapsed:o.collapseReviewMobile,mobile:o.isMobile,onClick:function(){if(!o.isMobile){return}o.collapseReviewMobile=!o.collapseReviewMobile},ref:function(n){return o.zonosReviewRef=n}}),e("zonos-cart-items",null))),e("zonos-v-stack",{spacing:16},e("zonos-cart-subtotal",null),e("zonos-custom-message",{class:"zonos--checkout-default-message",icon:L,message:x}))),!o.isMobile&&O()),o.isMobile&&O()),(r.step==="finish"||r.step==="error")&&e("div",{class:"zonos--done","data-theme":z},e("div",{class:"zonos--header"},T(),e("zonos-button",{class:"zonos--close-button",icon:e("zonos-icon",{content:I}),noBackground:true,onClick:function(){return o.handleFinishClick()},theme:z})),e("zonos-checkout-finish",{borderRadius:d,onCloseClick:function(){return o.handleFinishClick()},overrideNotification:r.step==="error"&&!!r.error?Object.assign(Object.assign({},r.error),{type:"error"}):undefined,storybookForceStatus:o.storybookPaymentStatusOverride})))};return e(c,{class:_(["zonos--checkout zonos--elements",f&&"has-footer",this.preview&&"preview",this.isMobile&&"mobile"])},this.preview?E():e("zonos-dialog",{borderStyle:d,"data-theme":z,height:"980px",isLoading:s,mobile:this.isMobile,noBodyPadding:true,noBorder:true,noClickOutside:true,noCloseButton:true,onCloseDialog:function(){return o.closeDialogHandler()},open:this.open,width:"1200px"},E()))};Object.defineProperty(o,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});Object.defineProperty(o,"watchers",{get:function(){return{appearanceSettingsOverride:["appearanceSettingsOverrideChanged"],mobile:["handleMobileChange"]}},enumerable:false,configurable:true});return o}());T.style=H}}}));
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(o,n,e,t){function c(o){return o instanceof e?o:new e((function(n){n(o)}))}return new(e||(e=Promise))((function(e,s){function r(o){try{a(t.next(o))}catch(o){s(o)}}function i(o){try{a(t["throw"](o))}catch(o){s(o)}}function a(o){o.done?e(o.value):c(o.value).then(r,i)}a((t=t.apply(o,n||[])).next())}))};var __generator=this&&this.__generator||function(o,n){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},t,c,s,r;return r={next:i(0),throw:i(1),return:i(2)},typeof Symbol==="function"&&(r[Symbol.iterator]=function(){return this}),r;function i(o){return function(n){return a([o,n])}}function a(i){if(t)throw new TypeError("Generator is already executing.");while(r&&(r=0,i[0]&&(e=0)),e)try{if(t=1,c&&(s=i[0]&2?c["return"]:i[0]?c["throw"]||((s=c["return"])&&s.call(c),0):c.next)&&!(s=s.call(c,i[1])).done)return s;if(c=0,s)i=[i[0]&2,s.value];switch(i[0]){case 0:case 1:s=i;break;case 4:e.label++;return{value:i[1],done:false};case 5:e.label++;c=i[1];i=[0];continue;case 7:i=e.ops.pop();e.trys.pop();continue;default:if(!(s=e.trys,s=s.length>0&&s[s.length-1])&&(i[0]===6||i[0]===2)){e=0;continue}if(i[0]===3&&(!s||i[1]>s[0]&&i[1]<s[3])){e.label=i[1];break}if(i[0]===6&&e.label<s[1]){e.label=s[1];s=i;break}if(s&&e.label<s[2]){e.label=s[2];e.ops.push(i);break}if(s[2])e.ops.pop();e.trys.pop();continue}i=n.call(o,e)}catch(o){i=[6,o];c=0}finally{t=s=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};System.register(["./p-4d39efb6.system.js","./p-c3d75f4f.system.js","./p-a6f2e282.system.js","./p-dc09ca69.system.js","./p-ee8b44c0.system.js","./p-23e7c655.system.js","./p-12ecf765.system.js","./p-7f68c103.system.js"],(function(o){"use strict";var n,e,t,c,s,r,i,a,u,h,l,d,f,z,m,v,k,p,g,b,w,y,x,_,C,B;return{setters:[function(o){n=o.r;e=o.h;t=o.F;c=o.H},function(o){s=o.k;r=o.c;i=o.h;a=o.g;u=o.s;h=o.l;l=o.j;d=o.m;f=o.d;z=o.n;m=o.o;v=o.e},function(o){k=o.a;p=o.l;g=o.t},function(o){b=o.z;w=o.m},function(o){y=o.s;x=o.i},function(o){_=o.c},function(o){C=o.g},function(o){B=o.i}],execute:function(){var j='<svg color="var(--amino-gray-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M9.707 16.707a1 1 0 0 1-1.414 0l-3.647-3.646a1.5 1.5 0 0 1 0-2.122l3.647-3.646a1 1 0 0 1 1.414 1.414L7.414 11H19a1 1 0 1 1 0 2H7.414l2.293 2.293a1 1 0 0 1 0 1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>';var L='<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="https://www.w3.org/2000/svg">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M2.25 4.5C2.25 3.25736 3.25736 2.25 4.5 2.25H13.5C14.7426 2.25 15.75 3.25736 15.75 4.5V10.5C15.75 11.7426 14.7426 12.75 13.5 12.75H8.25C8.01393 12.75 7.79164 12.8611 7.65 13.05L6.3 14.85C5.87508 15.4166 5.2082 15.75 4.5 15.75C3.25736 15.75 2.25 14.7426 2.25 13.5V4.5ZM4.5 3.75C4.08579 3.75 3.75 4.08579 3.75 4.5V13.5C3.75 13.9142 4.08579 14.25 4.5 14.25C4.73607 14.25 4.95836 14.1389 5.1 13.95L6.45 12.15C6.87492 11.5834 7.5418 11.25 8.25 11.25H13.5C13.9142 11.25 14.25 10.9142 14.25 10.5V4.5C14.25 4.08579 13.9142 3.75 13.5 3.75H4.5ZM5.25 6C5.25 5.58579 5.58579 5.25 6 5.25H12C12.4142 5.25 12.75 5.58579 12.75 6C12.75 6.41421 12.4142 6.75 12 6.75H6C5.58579 6.75 5.25 6.41421 5.25 6ZM5.25 9C5.25 8.58579 5.58579 8.25 6 8.25H8.25C8.66421 8.25 9 8.58579 9 9C9 9.41421 8.66421 9.75 8.25 9.75H6C5.58579 9.75 5.25 9.41421 5.25 9Z" fill="#4D505A"/>\n</svg>\n';var I='<svg color="var(--amino-gray-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" data-is-secondary-color="true" fill="var(--amino-gray-200)" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>';var S=".sc-zonos-checkout-h{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-checkout-h *.sc-zonos-checkout{font-family:var(--font-family, Inter), Inter}.sc-zonos-checkout-h img.sc-zonos-checkout{max-width:100%}.sc-zonos-checkout-h dl.sc-zonos-checkout,.sc-zonos-checkout-h dd.sc-zonos-checkout,.sc-zonos-checkout-h h1.sc-zonos-checkout,.sc-zonos-checkout-h h2.sc-zonos-checkout,.sc-zonos-checkout-h h3.sc-zonos-checkout,.sc-zonos-checkout-h h4.sc-zonos-checkout,.sc-zonos-checkout-h h5.sc-zonos-checkout,.sc-zonos-checkout-h h6.sc-zonos-checkout,.sc-zonos-checkout-h hr.sc-zonos-checkout,.sc-zonos-checkout-h figure.sc-zonos-checkout,.sc-zonos-checkout-h p.sc-zonos-checkout,.sc-zonos-checkout-h pre.sc-zonos-checkout{margin:0}.sc-zonos-checkout-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar{width:10px}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-track{background:var(--amino-gray-50)}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb{border-radius:10px;background:#cccccc;border:3px solid transparent;background-clip:content-box}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb:hover{background:#d6d6d6}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;height:100%;overflow:hidden;border-radius:var(--border-radius, var(--amino-radius-10))}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex:1;flex:1;padding:var(--amino-space-48) var(--amino-space-56)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{background-color:var(--primary-color, var(--amino-gray-0));border-right:1px solid var(--amino-gray-200)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{background-color:var(--amino-gray-0);padding-bottom:var(--amino-space-80)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:100%;max-height:100%;height:100%;overflow:auto;-ms-flex-direction:column;flex-direction:column;background-color:var(--amino-gray-0);-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:var(--amino-space-24);padding-bottom:50px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;width:100%}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout img.sc-zonos-checkout{width:150px;min-width:150px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--logo.sc-zonos-checkout{margin-bottom:0}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout zonos-checkout-finish.sc-zonos-checkout{-ms-flex:1;flex:1}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--back-button.sc-zonos-checkout{margin-bottom:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{padding:0 var(--amino-space-8) var(--amino-space-8)}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--payment-error-banner.sc-zonos-checkout{margin-top:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout{position:relative}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout .zonos--close-button.sc-zonos-checkout{position:absolute;right:var(--amino-space-24);top:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--footer.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-pack:end;justify-content:flex-end;-ms-flex-align:center;align-items:center;position:absolute;bottom:var(--amino-space-32);right:var(--amino-space-56);gap:var(--amino-space-8)}.sc-zonos-checkout-h .zonos--wrapper.sc-zonos-checkout{overflow:auto;max-height:100%;position:relative}.sc-zonos-checkout-h .flex--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;max-height:100%}.sc-zonos-checkout-h .zonos--logo.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.sc-zonos-checkout-h .zonos--checkout-default-message.sc-zonos-checkout{margin-left:var(--amino-space-76);margin-bottom:var(--amino-space-8)}.preview.sc-zonos-checkout-h{min-width:500px;margin:auto}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{border:var(--amino-border)}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{padding:var(--amino-space-32)}.mobile.sc-zonos-checkout-h{min-width:auto}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:auto;border-radius:0;max-height:100%;height:100%;border:0}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{padding:var(--amino-space-12)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{-ms-flex-order:2;order:2}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex-order:1;order:1;padding-top:var(--amino-space-16)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:var(--amino-space-16);margin-top:var(--amino-space-24);border:var(--amino-border);border-radius:var(--border-radius, var(--amino-radius-10));background-color:var(--amino-gray-50);padding:var(--amino-space-12);margin-top:var(--amino-space-32)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{max-height:100%}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--footer.sc-zonos-checkout{-ms-flex-order:3;order:3}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:auto}.mobile.sc-zonos-checkout-h .zonos--cart-subtotal.sc-zonos-checkout{margin:0}.mobile.sc-zonos-checkout-h .zonos--footer.sc-zonos-checkout{bottom:0;left:0;padding:var(--amino-space-12);position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;background-color:var(--amino-gray-0)}";var H=S;var T=o("zonos_checkout",function(){function o(o){var e=this;n(this,o);this.applyStripeTheme=function(){return __awaiter(e,void 0,void 0,(function(){var o,n,e,t;return __generator(this,(function(c){switch(c.label){case 0:t=((o=this.appearanceSettingsOverride)===null||o===void 0?void 0:o.theme)||b.appearance.theme;return[4,s({overrideBorderRaidus:(n=this.appearanceSettingsOverride)===null||n===void 0?void 0:n.style,overridePrimaryColor:(e=this.appearanceSettingsOverride)===null||e===void 0?void 0:e.colorPrimary,overrideTheme:this.isMobile?t:undefined})];case 1:c.sent();return[2]}}))}))};this.isShippableCountry=function(o){if(o===void 0){o=true}if(!k.localizationLoaded){return false}if(!k.isShippableCountry){if(o){p("Checkout: not shippable country")}return false}return true};this.getCurrentLocalePageEnum=function(){switch(r.step){case"customer-info":return"checkout_customer_info";case"shipping":return"checkout_shipping_info";case"payment":return"checkout_payment_info";default:return null}};this.appearanceSettingsOverride=undefined;this.preview=false;this.mobile=false;this.defaultAddress=null;this.forceDialogOpen=false;this.open=this.forceDialogOpen;this.stripe=window.Zonos.stripe;this.submitLoading=false;this.paymentError=false;this.collapseReviewMobile=false;this.isAttachError=false;this.isMobile=false;this.zonosReviewRef=undefined;this.storybookPaymentStatusOverride=undefined}o.prototype.initCartInfoHandler=function(o){return __awaiter(this,void 0,void 0,(function(){var n;return __generator(this,(function(e){n=o.detail;void i(n);return[2]}))}))};o.prototype.closeDialogHandler=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){y("zonos-checkout-close");this.open=this.forceDialogOpen||false;if(!this.preview&&r.step==="finish"){a()}r.step="customer-info";return[2]}))}))};o.prototype.buildCartAndInit=function(){return __awaiter(this,void 0,void 0,(function(){var o,n;return __generator(this,(function(e){switch(e.label){case 0:if(!b.checkoutSettings.buildCartDetail)return[3,3];p("build cart detail");return[4,b.checkoutSettings.buildCartDetail()];case 1:o=e.sent();return[4,i(o)];case 2:e.sent();e.label=3;case 3:if(!!u.clientSecret)return[3,5];return[4,h()];case 4:n=e.sent();p("stripeStoreInitCheckoutSession: ".concat(n));if(!n){return[2,false]}e.label=5;case 5:return[4,this.applyStripeTheme()];case 6:e.sent();return[2,true]}}))}))};o.prototype.attachCheckout=function(){var o=this;var n=b.checkoutSettings.placeOrderButtonSelector;if(!n){return}var e=document.querySelectorAll(n);e.forEach((function(n){var e=n.getAttribute("data-zonos-checkout-attached");if(e){return}n.addEventListener("click",(function(n){return __awaiter(o,void 0,void 0,(function(){var o,e;return __generator(this,(function(t){switch(t.label){case 0:if(!this.isShippableCountry()){return[2]}n.preventDefault();n.stopPropagation();p("zonos checkout button clicked");u.isFetchingSession=true;this.open=true;t.label=1;case 1:t.trys.push([1,3,,4]);return[4,this.buildCartAndInit()];case 2:o=t.sent();if(!o){throw new Error("Error building cart")}y("zonos-checkout-start");return[3,4];case 3:e=t.sent();u.isFetchingSession=false;l({messages:[g("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:g("Error creating Checkout")});return[3,4];case 4:return[2]}}))}))}));n.removeAttribute("disabled");n.setAttribute("data-zonos-checkout-attached","true")}))};o.prototype.appearanceSettingsOverrideChanged=function(){if(!this.appearanceSettingsOverride){return}void this.applyStripeTheme()};o.prototype.init=function(){return __awaiter(this,void 0,void 0,(function(){var o,n;var e=this;return __generator(this,(function(t){u.stripe=window.Zonos.stripe;this.stripe=window.Zonos.stripe;o=setInterval((function(){var n=window.Zonos.internationalHideSelector;if(!n){clearInterval(o);return}var t=e.isShippableCountry(false);var c=document.querySelectorAll(n);if(!t){c===null||c===void 0?void 0:c.forEach((function(o){var n=o;var e=n.getAttribute("data-zonos-checkout-original-display")||getComputedStyle(n).display;n.style.display=e||"initial"}));return}c===null||c===void 0?void 0:c.forEach((function(o){var n=o;var e=n.style.display;n.setAttribute("data-zonos-checkout-original-display",e);n.style.display="none"}))}),100);n=setInterval((function(){u.stripe=window.Zonos.stripe;e.stripe=window.Zonos.stripe;if(!e.stripe){p("waiting for stripe to be loaded");return}if(e.storybookPaymentStatusOverride){clearInterval(n);return}p("init checkout");if(e.preview||e.forceDialogOpen){void e.buildCartAndInit()}else{e.attachCheckout();var o=new MutationObserver((function(){e.attachCheckout()}));o.observe(document.body,{childList:true,subtree:true})}clearInterval(n)}),50);setTimeout((function(){clearInterval(n)}),1e4);return[2]}))}))};o.prototype.setToFinishStep=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){r.step="finish";this.storybookPaymentStatusOverride=o;return[2]}))}))};o.prototype.handleCustomerInfoContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o;var n=this;return __generator(this,(function(e){switch(e.label){case 0:this.submitLoading=true;return[4,d()];case 1:e.sent();o=setInterval((function(){if(r.landedCostData||!u.isFetchingLandedCost){if(r.landedCostData){f()}n.submitLoading=false;clearInterval(o)}}),500);return[2]}}))}))};o.prototype.handleShippingContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o=this;return __generator(this,(function(n){this.submitLoading=true;setTimeout((function(){f();o.submitLoading=false}),500);return[2]}))}))};o.prototype.handleCheckoutPaymentContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o;return __generator(this,(function(n){switch(n.label){case 0:this.paymentError=false;this.submitLoading=true;n.label=1;case 1:n.trys.push([1,3,,4]);return[4,z()];case 2:n.sent();f();return[3,4];case 3:o=n.sent();console.error(o);this.paymentError=true;return[3,4];case 4:this.submitLoading=false;return[2]}}))}))};o.prototype.handleFinishClick=function(){return __awaiter(this,void 0,void 0,(function(){var o,n;return __generator(this,(function(e){switch(e.label){case 0:m();if(!this.preview)return[3,2];r.step="customer-info";return[4,this.init()];case 1:e.sent();return[2];case 2:a();o=window.location.href;n=o.split("?")[0];window.history.replaceState({},document.title,n);this.open=false;window.location.reload();return[2]}}))}))};o.prototype.handleBackClick=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){switch(o.label){case 0:if(!(r.step==="customer-info"))return[3,2];return[4,this.closeDialogHandler()];case 1:o.sent();return[2];case 2:v();return[2]}}))}))};o.prototype.handleWindowResize=function(){this.isMobile=x(this.mobile);void this.applyStripeTheme();p("mobile: ".concat(this.isMobile))};o.prototype.handleMobileChange=function(){this.isMobile=x(this.mobile);void this.applyStripeTheme();p("mobile: ".concat(this.isMobile))};o.prototype.componentWillLoad=function(){void this.init();this.isMobile=x(this.mobile);p("mobile: ".concat(this.isMobile))};o.prototype.disconnectedCallback=function(){m();a()};o.prototype.render=function(){var o=this;var n;var s=r.step!=="finish"&&r.step!=="error"&&!u.stripeElements||u.isFetchingSession;var i=w(b.appearance,this.appearanceSettingsOverride),a=i.colorPrimary,h=i.colorSecondary,l=i.logoUrl,d=i.style;var f=b.appearance.zonosAttribution==="ENABLED";var z=b.appearance.theme;var m=a&&B(a)?"DARK":"LIGHT";var v=this.isMobile?z:m;var p=!this.isMobile?h:undefined;var y=k.customMessages;var x=((n=y.find((function(o){return o.pageName==="checkout_default"})))===null||n===void 0?void 0:n.message)||"Know about duties and taxes before you buy. Shop with confidence!";var S=this.getCurrentLocalePageEnum();var H=y.filter((function(o){return o.pageName===S}));var T=function(){return e("div",{class:"zonos--logo"},l&&e("img",{alt:"".concat(b.organizationName," logo"),src:l,width:100}))};var M=function(){return e("zonos-v-stack",null,T(),H.map((function(o){return e("zonos-custom-message",{icon:L,message:o.message})})),e("div",null,e("zonos-button",{class:"zonos--back-button",icon:e("zonos-icon",{content:j}),noBackground:true,noPaddingLeft:true,noPaddingRight:true,onClick:function(){return o.handleBackClick()},theme:v},g("Back"))))};var O=function(){return f&&e("div",{class:"zonos--footer","data-theme":z},e("zonos-text",{type:"hintText"},g("Powered by")),e("zonos-logo",{theme:z,width:"100px"}))};var E=function(){var n;var c=o.isMobile?"primary":undefined;var s=(n=o.zonosReviewRef)===null||n===void 0?void 0:n.scrollHeight;return e("div",{class:"zonos--content",style:{"--border-radius":C(d)}},r.step!=="finish"&&r.step!=="error"&&e(t,null,e("div",{class:"zonos--left","data-theme":v,style:{"--primary-color":!o.isMobile?a:""}},!o.isMobile&&M(),r.step==="customer-info"&&e("zonos-customer-info",{continueLoading:o.submitLoading,defaultAddress:o.defaultAddress,onContinueClicked:function(){return o.handleCustomerInfoContinue()},submitBtnColor:p,submitBtnType:c}),r.step==="shipping"&&e("zonos-shipping",{continueLoading:o.submitLoading,onContinueClicked:function(){return o.handleShippingContinue()},submitBtnColor:p,submitBtnType:c}),r.step==="payment"&&e("zonos-checkout-payment",{continueLoading:o.submitLoading,onContinueClicked:function(){return o.handleCheckoutPaymentContinue()},paymentError:o.paymentError,submitBtnColor:p,submitBtnType:c})),e("div",{class:"zonos--right","data-theme":z},o.isMobile&&M(),!o.isMobile&&e("zonos-button",{class:"zonos--close-button",icon:e("zonos-icon",{content:I}),noBackground:true,onClick:function(){return o.closeDialogHandler()}}),e("div",{class:"flex--wrapper"},e("div",{class:"zonos--wrapper"},e("zonos-collapse",{collapseSize:s,collapsed:o.collapseReviewMobile&&o.isMobile},e("zonos-review",{collapsed:o.collapseReviewMobile,mobile:o.isMobile,onClick:function(){if(!o.isMobile){return}o.collapseReviewMobile=!o.collapseReviewMobile},ref:function(n){return o.zonosReviewRef=n}}),e("zonos-cart-items",null))),e("zonos-v-stack",{spacing:16},e("zonos-cart-subtotal",null),e("zonos-custom-message",{class:"zonos--checkout-default-message",icon:L,message:x}))),!o.isMobile&&O()),o.isMobile&&O()),(r.step==="finish"||r.step==="error")&&e("div",{class:"zonos--done","data-theme":z},e("div",{class:"zonos--header"},T(),e("zonos-button",{class:"zonos--close-button",icon:e("zonos-icon",{content:I}),noBackground:true,onClick:function(){return o.handleFinishClick()},theme:z})),e("zonos-checkout-finish",{borderRadius:d,onCloseClick:function(){return o.handleFinishClick()},overrideNotification:r.step==="error"&&!!r.error?Object.assign(Object.assign({},r.error),{type:"error"}):undefined,storybookForceStatus:o.storybookPaymentStatusOverride})))};return e(c,{class:_(["zonos--checkout zonos--elements",f&&"has-footer",this.preview&&"preview",this.isMobile&&"mobile"])},this.preview?E():e("zonos-dialog",{borderStyle:d,"data-theme":z,height:"980px",isLoading:s,mobile:this.isMobile,noBodyPadding:true,noBorder:true,noClickOutside:true,noCloseButton:true,onCloseDialog:function(){return o.closeDialogHandler()},open:this.open,width:"1200px"},E()))};Object.defineProperty(o,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});Object.defineProperty(o,"watchers",{get:function(){return{appearanceSettingsOverride:["appearanceSettingsOverrideChanged"],mobile:["handleMobileChange"]}},enumerable:false,configurable:true});return o}());T.style=H}}}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as e,c as t}from"./p-e8da4463.js";import{h as n,l as o,a as s,b as r,t as i}from"./p-8ebc0b64.js";import{i as a}from"./p-0024f8c2.js";import{g as l}from"./p-f2733cc7.js";const d=()=>{const e=m.stripeLinkEventData,t=m.stripeAddressEventData;if(!t||!t.complete)throw new Error("Missing stripe address data");return{checkoutSessionId:E.checkoutSessionId||"",contact:{email:(null==e?void 0:e.value.email)||"",firstName:t.value.firstName||"",lastName:t.value.lastName||"",phone:t.value.phone||""},items:E.items.map((e=>e)),shippingAddress:{addressLine1:t.value.address.line1,addressLine2:t.value.address.line2||"",city:t.value.address.city,country:t.value.address.country,postalCode:t.value.address.postal_code,state:t.value.address.state}}},c=({borderStyle:e,theme:t})=>"DARK"===t?{borderRadius:l(e),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"}:{borderRadius:l(e)},{onChange:u,reset:p,state:m}=t((()=>({clientSecret:sessionStorage.getItem("zonos--client-secret")||null,fetchingLandedCostAbordController:null,isFetchingLandedCost:!1,isFetchingSession:!1,stripe:null,stripeAddressElement:null,stripeAddressEventData:null,stripeAddressUsedWhenFetchingLC:null,stripeBillingAddressElement:null,stripeElements:null,stripeElementsOptions:null,stripeLinkElement:null,stripeLinkEventData:null,stripeLinkUsedWhenFetchingLC:null,stripePaymentElement:null,stripePaymentEventData:null}))),h=async t=>{var n;const r=m.clientSecret;if(m.stripe){if(r){const i=(({clientSecret:t,overrideBorderRaidus:n,overridePrimaryColor:o,overrideTheme:r})=>{const i=o||e.appearance.colorPrimary,l=i&&a(i)?"night":"flat",d="DARK"===r?"night":"flat";return{appearance:{labels:"floating",rules:Object.assign({},{".Input":{padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"}}),theme:r?d:l,variables:Object.assign({},c({borderStyle:n,theme:"LIGHT"}))},clientSecret:t,locale:s.selectedLocale}})({clientSecret:r,overrideBorderRaidus:null==t?void 0:t.overrideBorderRaidus,overridePrimaryColor:null==t?void 0:t.overridePrimaryColor,overrideTheme:null==t?void 0:t.overrideTheme}),l=JSON.stringify(i)===JSON.stringify(m.stripeElementsOptions);if(!m.stripeElements)return m.stripeElements=null===(n=m.stripe)||void 0===n?void 0:n.elements(i),m.stripeElementsOptions=i,void o("Stripe elements initialized");l||(m.stripeElements.update(i),m.stripeElementsOptions=i),o("Stripe elements initialized")}}else o("Skip. Stripe is not initialized")},v=()=>{sessionStorage.removeItem("zonos--client-secret"),p(),m.stripe=window.Zonos.stripe},g=async()=>{var t,o,s,i;const a=!!(null===(t=m.stripeAddressEventData)||void 0===t?void 0:t.complete),l=!!(null===(o=m.stripeLinkEventData)||void 0===o?void 0:o.complete),c=(()=>{var e,t,n,o;if(!m.fetchingLandedCostAbordController)return!1;const s=JSON.stringify(null===(e=m.stripeLinkUsedWhenFetchingLC)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=m.stripeLinkEventData)||void 0===t?void 0:t.value),r=JSON.stringify(null===(n=m.stripeAddressUsedWhenFetchingLC)||void 0===n?void 0:n.value)!==JSON.stringify(null===(o=m.stripeAddressEventData)||void 0===o?void 0:o.value);return s||r})();if(c&&(null===(s=m.fetchingLandedCostAbordController)||void 0===s||s.abort(),m.fetchingLandedCostAbordController=null),a&&l&&(c||!m.isFetchingLandedCost)){m.isFetchingLandedCost=!0,m.stripeAddressEventData&&(m.stripeAddressUsedWhenFetchingLC=Object.assign({},m.stripeAddressEventData)),m.stripeLinkEventData&&(m.stripeLinkUsedWhenFetchingLC=Object.assign({},m.stripeLinkEventData));try{const t=new AbortController;m.fetchingLandedCostAbordController=t;const{checkoutSessionWorkflow:o,shipmentRatingCalculateWorkflow:s}=await(async t=>{var o;const s=e.checkoutSettings.buildLandedCost;if(s){const e=await(async e=>{var t;const o=d(),s=await e(o.checkoutSessionId,o.contact,o.shippingAddress);if(!s)throw new Error("Failed to build landed cost");const{errors:r,json:i}=await n("https://v1.route.js.zonos.com/api/zonos-elements/validate-landed-cost",{body:s,headers:{"Content-Type":"application/json"},method:"POST"});if(!i||r.length)throw new Error(`Invalid landed cost object: ${(null===(t=r.find(Boolean))||void 0===t?void 0:t.message)||"Unknown error"}`);return s})(s);return e}const{errors:r,json:i}=await n("https://v1.route.js.zonos.com/api/zonos-elements/calculate-landed-cost",{body:d(),method:"POST",signal:null==t?void 0:t.signal});if(r.length||!i){const e="The user aborted a request."===(null===(o=r[0])||void 0===o?void 0:o.message);throw new Error(e?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost")}return i})(t);m.fetchingLandedCostAbordController=null,E.landedCostData=(null==o?void 0:o.filter(Boolean))||null,E.shippingData=(null==s?void 0:s.filter(Boolean))||null;const r=null===(i=E.landedCostData)||void 0===i?void 0:i.find(Boolean),a=r?r.subtotals:null;a&&A({exchangeRate:a.exchangeRate,items:a.items,landedCostTotal:0,presentmentCurrencyCode:a.presentmentCurrencyCode,shipping:0,total:a.items})}catch(e){r(e)}m.isFetchingLandedCost=!1}},y=e=>{let t=[],n=!0;switch(e){case"succeeded":t=[i("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."),"","",i("We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.")],n=!1;break;case"requires_capture":case"processing":t=[i("Payment processing. We'll update you when payment is received.")],n=!1;break;case"requires_payment_method":t=[i("Payment failed. Please try another payment method.")];break;default:t=[i("Something went wrong.")]}return{isError:n,messages:t}},f=async({clientSecret:e,storybookForceStatus:t})=>{if(t){const{isError:e,messages:n}=y(t);return{error:e,messages:n}}const n=e||m.clientSecret;if(!m.stripe||!n)return r("Failed to retrieve payment intent. Stripe is not initialized"),{error:!0,message:[i("Something went wrong.")]};const{paymentIntent:o}=await m.stripe.retrievePaymentIntent(n),s=null==o?void 0:o.status,{isError:a,messages:l}=y(s);return{error:a,messages:l}},w=async()=>{var e,t,n;const o=!!(null===(e=m.stripePaymentEventData)||void 0===e?void 0:e.complete),s=m.stripeElements,r=m.stripe;if(r&&s&&o&&m.clientSecret){const{error:e}=await r.confirmPayment({confirmParams:{receipt_email:null===(n=null===(t=m.stripeLinkEventData)||void 0===t?void 0:t.value)||void 0===n?void 0:n.email,return_url:window.location.href},elements:s,redirect:"if_required"});if(e){if("card_error"===e.type||"validation_error"===e.type)throw new Error(e.message);if("invalid_request_error"===e.type&&"payment_intent_unexpected_state"===e.code)return;throw new Error("An unexpected error occurred.")}}},S=async()=>{var e;const t=E.items.reduce(((e,t)=>e+t.amount*t.quantity),0);if(!t||!s.targetCurrency)return r("Fail to create checkout session - invalid total or currency"),!1;m.isFetchingSession=!0;const{errors:i,json:a}=await n("https://v1.route.js.zonos.com/api/zonos-elements/create-checkout-session",{body:{currency:(null===(e=E.items.find(Boolean))||void 0===e?void 0:e.currencyCode)||"",itemsAmount:t,presentmentCountryCode:s.selectedCountryCode||null},method:"POST"});if(m.isFetchingSession=!1,i.length||!a)return r("Error occurs when creating checkout session",JSON.stringify(i,null,2)),!1;const l=a.checkoutSessionCreate;return m.clientSecret=l.clientSecret,E.checkoutSessionId=l.id,A(Object.assign(Object.assign({},l.subtotals),{landedCostTotal:0,shipping:0,total:l.subtotals.items})),o("Exchange rate updated for cart items (checkout session create)","info",E.exchangeRate),o("done-init-checkout-session"),!0};u("clientSecret",(e=>{e&&m.stripe&&sessionStorage.setItem("zonos--client-secret",e),e||sessionStorage.removeItem("zonos--client-secret")}));const C=e=>{const t=new Date,n=e.getTime()-t.getTime();return Math.floor(n/864e5)},{onChange:k,reset:b,state:E}=t((()=>({checkoutSessionId:sessionStorage.getItem("zonos--checkout-session-id")||null,currency:"USD",dutiesTaxFees:0,error:null,exchangeRate:null,isSelectedShippingAboveDeminimis:!1,isSelectedShippingGuarantee:!1,items:[],landedCostData:null,selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,step:"customer-info",subtotal:0,total:0}))),T=e=>{const t=e.minTransitAt?C(new Date(e.minTransitAt)):"",n=e.maxTransitAt?C(new Date(e.maxTransitAt)):"";return{expectedDate:e.minTransitAt?(({date:e,formatOptions:t={day:"numeric",weekday:"long",year:"numeric"}})=>new Intl.DateTimeFormat("en-US",t).format(e))({date:new Date(e.minTransitAt)}):"",maxTransit:n,minTransit:t}},O=()=>{sessionStorage.removeItem("zonos--checkout-session-id"),b()},j=({messages:e,title:t})=>{E.step="error",E.error={messages:e,title:t}},A=e=>{E.exchangeRate=e.exchangeRate,E.dutiesTaxFees=e.landedCostTotal,E.subtotal=e.items,E.total=e.total,E.currency=e.presentmentCurrencyCode},x=async({currency:e,itemsAmount:t,landedCostId:a})=>{if(a&&E.selectedLandedCost&&(A(E.selectedLandedCost.subtotals),o("Exchange rate updated for cart items (landed cost subtotal)","info",E.exchangeRate)),!E.checkoutSessionId)return r("Could not update cart total without checkout session id"),!1;const{json:l}=await(async({currency:e,id:t,itemsAmount:o,landedCostId:s,presentmentCountryCode:i})=>{const{errors:a,json:l}=await n("https://v1.route.js.zonos.com/api/zonos-elements/update-checkout-session",{body:{currency:e,id:t,itemsAmount:o,landedCostId:s,presentmentCountryCode:i},method:"POST"});return a.length||!l?(r("Error occurs when updating checkout session",JSON.stringify(a,null,2)),{errors:a,json:l}):{errors:[],json:l}})({currency:e,id:E.checkoutSessionId,itemsAmount:t,landedCostId:a,presentmentCountryCode:s.selectedCountryCode});return l?(a||(A(l.checkoutSessionUpdate.subtotals),o("Exchange rate updated for cart items (checkout session update)","info",E.exchangeRate)),!0):(r("Error occurs when updating checkout session"),j({messages:[i("There's been an error updating your checkout session. Please reload and try again or contact support if the error persists")],title:i("Error updating Checkout")}),!1)},z=async e=>{var t,n,o,s,r;E.selectedShippingOption=e;const{expectedDate:i,maxTransit:a,minTransit:l}=T(E.selectedShippingOption);E.selectedShippingOptionExpectedDate=i,E.selectedShippingOptionTransitTime=l&&a?`${l}-${a}`:`${l||a}`;const d=null===(t=E.landedCostData)||void 0===t?void 0:t.find((e=>{var t,n,o;return(null===(n=null===(t=e.landedCost)||void 0===t?void 0:t.shipmentRating)||void 0===n?void 0:n.id)===(null===(o=E.selectedShippingOption)||void 0===o?void 0:o.id)}));if(E.selectedLandedCost=d||null,!d)return!1;E.shipping=d.subtotals.shipping;const c="ZONOS"===(null===(n=null==d?void 0:d.landedCost)||void 0===n?void 0:n.landedCostGuaranteeCode),u=!!(null===(s=null===(o=null==d?void 0:d.landedCost)||void 0===o?void 0:o.deMinimis)||void 0===s?void 0:s.find((e=>["DUTY","TAX"].includes(e.type)&&"ABOVE"===e.threshold)));return E.isSelectedShippingAboveDeminimis=u,E.isSelectedShippingGuarantee=c,await x({landedCostId:null===(r=d.landedCost)||void 0===r?void 0:r.id})};k("checkoutSessionId",(()=>{E.checkoutSessionId?sessionStorage.setItem("zonos--checkout-session-id",E.checkoutSessionId):sessionStorage.removeItem("zonos--checkout-session-id")}));const D=async e=>{var t;E.items=e;const n=null===(t=e.find(Boolean))||void 0===t?void 0:t.currencyCode,o=e.reduce(((e,t)=>e+t.amount*t.quantity),0);n&&o&&(E.currency=n,m.isFetchingSession=!0,await x({currency:n,itemsAmount:o}),m.isFetchingSession=!1)},P=()=>{"customer-info"===E.step?E.step="shipping":"shipping"===E.step?E.step="payment":"payment"===E.step&&(E.step="finish")},B=()=>{"payment"===E.step?E.step="shipping":"shipping"===E.step&&(E.step="customer-info",E.selectedShippingOption=null,E.isSelectedShippingAboveDeminimis=!1,E.isSelectedShippingGuarantee=!1,E.selectedShippingOptionExpectedDate="",E.selectedShippingOptionTransitTime="",E.shipping=0)};export{A as a,T as b,E as c,P as d,B as e,x as f,O as g,D as h,z as i,j,h as k,S as l,g as m,w as n,v as o,f as p,m as s}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
System.register(["./p-
|
|
1
|
+
System.register(["./p-c3d75f4f.system.js","./p-dc09ca69.system.js","./p-4d39efb6.system.js","./p-a6f2e282.system.js","./p-7f68c103.system.js","./p-12ecf765.system.js"],(function(s){"use strict";return{setters:[function(t){var e={};e.cartStore=t.c;e.cartStoreApplySubtotals=t.a;e.cartStoreGetShippingTransitInfo=t.b;e.cartStoreNextStep=t.d;e.cartStorePreviousStep=t.e;e.cartStoreReCalculateTotal=t.f;e.cartStoreReset=t.g;e.cartStoreUpdateItems=t.h;e.cartStoreUpdateSelectedShippingOption=t.i;e.cartStoreUpdateToErrorState=t.j;s(e)},function(){},function(){},function(){},function(){},function(){}],execute:function(){}}}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
System.register(["./p-4d39efb6.system.js","./p-
|
|
1
|
+
System.register(["./p-4d39efb6.system.js","./p-c3d75f4f.system.js","./p-dc09ca69.system.js","./p-a6f2e282.system.js","./p-7f68c103.system.js","./p-12ecf765.system.js"],(function(n){"use strict";var t,s,e,o,a;return{setters:[function(n){t=n.r;s=n.h;e=n.H;o=n.d},function(n){a=n.s},function(){},function(){},function(){},function(){}],execute:function(){var c=".sc-zonos-payment-h{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-payment-h *.sc-zonos-payment{font-family:var(--font-family, Inter), Inter}.sc-zonos-payment-h img.sc-zonos-payment{max-width:100%}.sc-zonos-payment-h dl.sc-zonos-payment,.sc-zonos-payment-h dd.sc-zonos-payment,.sc-zonos-payment-h h1.sc-zonos-payment,.sc-zonos-payment-h h2.sc-zonos-payment,.sc-zonos-payment-h h3.sc-zonos-payment,.sc-zonos-payment-h h4.sc-zonos-payment,.sc-zonos-payment-h h5.sc-zonos-payment,.sc-zonos-payment-h h6.sc-zonos-payment,.sc-zonos-payment-h hr.sc-zonos-payment,.sc-zonos-payment-h figure.sc-zonos-payment,.sc-zonos-payment-h p.sc-zonos-payment,.sc-zonos-payment-h pre.sc-zonos-payment{margin:0}.sc-zonos-payment-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-payment-h .zonos--title.sc-zonos-payment{margin-bottom:var(--amino-space-16)}";var m=c;var i=n("zonos_payment",function(){function n(n){t(this,n);this.titleText=undefined;this.stripe=a.stripe;this.stripeElements=a.stripeElements}n.prototype.watchInitStripe=function(){if(!this.stripeElements){return}var n=a.stripePaymentElement||this.stripeElements.create("payment",{layout:"tabs"});var t=this.el.querySelector(".zonos--payment-component");if(!t){console.error("Cannot find container element for paymentElement");return}n.mount(t);n.on("change",(function(n){a.stripePaymentEventData=n}));a.stripePaymentElement=n};n.prototype.componentDidLoad=function(){this.watchInitStripe()};n.prototype.render=function(){return s(e,{key:"8a674f72e9235f9b6afcc8d8e0374639423e0bb3",class:"zonos--payment zonos--elements"},this.titleText&&s("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),s("div",{key:"94a0a064e6f6d8058bc11d114ecc4c3ab495e802",class:"zonos--payment-component"}))};Object.defineProperty(n.prototype,"el",{get:function(){return o(this)},enumerable:false,configurable:true});Object.defineProperty(n,"watchers",{get:function(){return{stripeElements:["watchInitStripe"],stripe:["watchInitStripe"]}},enumerable:false,configurable:true});return n}());i.style=m}}}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,c as t,h as n,H as e}from"./p-4d8545e1.js";import{s}from"./p-
|
|
1
|
+
import{r as o,c as t,h as n,H as e}from"./p-4d8545e1.js";import{s}from"./p-245997d9.js";import{h as i,b as r,i as a,l as c,c as l,d}from"./p-8ebc0b64.js";import{z as h,b as u,d as f}from"./p-e8da4463.js";import"./p-0024f8c2.js";import"./p-f2733cc7.js";const m=class{constructor(n){o(this,n),this.stripeInitEvent=t(this,"stripeInitEvent",7),this.config=void 0,this.zonosApiKey=void 0}async initCheckoutElement(o){var t;o?(s.stripe=o,(t=h.checkoutSettings).placeOrderButtonSelector&&(a(t.placeOrderButtonSelector)?(()=>{if(!document.querySelector("zonos-checkout")){const o=document.createElement("zonos-checkout");document.body.appendChild(o)}})():r(`Selector checkoutButtonAnchor "${t.placeOrderButtonSelector}" is not a valid selector`)),c("init checkout element")):c("Stripe is not loaded yet - cannot init checkout element","warn")}initZonosNotification(){if(document.querySelector("zonos-notification"))return;const o=document.createElement("zonos-notification");document.body.appendChild(o)}async setupGoogleFont(o){var t,n;const e=o||f();if("Inter"===e){if(!o)return;c("[FONT] Just applied Inter , but no need to inject since we already inject Inter on start","warn"),h.appearance=Object.assign(Object.assign({},h.appearance),{fontFamily:o})}const{errors:s,json:r}=await i(`https://v1.route.js.zonos.com/api/zonos-elements/get-font-detail?family=${e}`);s.length>0||!r?c(`Failed to load font ${e}`,"warn"):(null===(n=(t=window.Zonos).injectSupportGoogleFont)||void 0===n||n.call(t,r.fontUrl),o&&(c(`[FONT] ${o} font override applied`),h.appearance=Object.assign(Object.assign({},h.appearance),{fontFamily:o})))}async componentWillLoad(){h.zonosApiKey=this.zonosApiKey,(async()=>{var o,t;const{errors:n,json:e}=await(async()=>{const{errors:o,json:t}=await i("https://v1.route.js.zonos.com/api/zonos-elements/zonos-settings");return o.length?(r("Error occurred when getting zonos settings. If this is not an unauthorized error, it will use user settings or default settings"),{errors:o,json:null}):{errors:[],json:t}})();if("403"===(null===(o=n[0])||void 0===o?void 0:o.type.toString()))return void c("Failed to load zonos settings. This domain may not have access","warn");this.initZonosNotification(),u({overrideSettings:this.config,zonosSettings:e}),this.setupGoogleFont(),h.helloSettings&&(async o=>{const{anchorElementSelector:t}=o;if(!t||!a(t))return void r(`Selector anchorElementSelector "${o.anchorElementSelector}" is not a valid selector.`);const n=document.querySelector(t);c("Hello init complete"),(o=>{if(!document.querySelector("zonos-hello")&&o){const t=document.createElement("zonos-hello");o.appendChild(t)}})(n)})(h.helloSettings),await l();const s=(null===(t=null==e?void 0:e.checkoutSettings)||void 0===t?void 0:t.externalServiceTokens.find((o=>"STRIPE_PUBLISHABLE_TOKEN"===o.type)))||null;if(s&&this.stripeInitEvent){if("INACTIVE"===h.checkoutSettings.subscriptionStatus)return c('=== Checkout subscription is "INACTIVE" - Cancel initializing for Checkout ===',"warn"),void c("zonos controller loaded");if("DISABLED"===h.checkoutSettings.visibilityStatus)return c("=== Checkout is disabled by store owner ===","warn"),void c("zonos controller loaded");this.stripeInitEvent.emit({publishableKey:s.token}),c("zonos controller loaded")}else c("Checkout failed to load -- missing publishable key","warn")})()}async showNotification(o){const t=document.querySelector("zonos-notification");t?t.showNotification(o):c("Failed to show notification - zonos-notification not found","warn")}async overrideConfig(o){u({overrideSettings:o,zonosSettings:null})}async overrideCountry(o){d(o)}async getAppearanceSetting(){return h.appearance}async updateOrganizationName(o){h.organizationName=o}render(){return n(e,{key:"a94fb7ff23c45a9813ce5da857cda14c8455ff79",class:"zonos--elements"})}};m.style=":host{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--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{visibility:hidden;opacity:0;height:0}";export{m as zonos_controller}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as s,h as o,H as n,d as t}from"./p-4d8545e1.js";import{s as i,m as e}from"./p-245997d9.js";import{b as a,a as c}from"./p-8ebc0b64.js";import"./p-e8da4463.js";import"./p-0024f8c2.js";import"./p-f2733cc7.js";const d=class{constructor(o){s(this,o),this.type=void 0,this.titleText=void 0,this.defaultAddress=null,this.stripe=window.Zonos.stripe}async watchInitStripe(){var s,o,n,t,d,h,l;if(this.stripe=window.Zonos.stripe,!this.stripe||!i.stripeElements)return void a("Stripe is not initialized. Couldn't load stripe element.");(null===(s=this.defaultAddress)||void 0===s?void 0:s.phone)||null===(o=this.defaultAddress)||void 0===o||delete o.phone;const r=c.shippingZoneCountries,z=i.stripeElements.create("address",{allowedCountries:r?Object.values(r).map((s=>s.code)):[],autocomplete:{mode:"automatic"},contacts:this.defaultAddress?[this.defaultAddress]:[],defaultValues:{address:Object.assign(Object.assign({},null===(n=i.stripeAddressEventData)||void 0===n?void 0:n.value.address),{country:(null===(t=i.stripeAddressEventData)||void 0===t?void 0:t.value.address.country)||c.selectedCountryCode||"AL"}),firstName:null===(d=i.stripeAddressEventData)||void 0===d?void 0:d.value.firstName,lastName:null===(h=i.stripeAddressEventData)||void 0===h?void 0:h.value.lastName,phone:null===(l=i.stripeAddressEventData)||void 0===l?void 0:l.value.phone},display:{name:"split"},fields:{phone:"always"},mode:this.type,validation:{phone:{required:"always"}}});z.mount(this.el.querySelector(".zonos--address-component")),z.on("change",(s=>{const o=s.value;i.stripeAddressEventData=Object.assign(Object.assign({},s),{elementMode:"shipping",elementType:"address",empty:!1,value:Object.assign(Object.assign({},o),{firstName:o.firstName||o.name.split(" ")[0],lastName:o.lastName||o.name.split(" ").pop()})}),e()})),i.stripeAddressElement=z}disconnectedCallback(){var s;null===(s=i.stripeAddressElement)||void 0===s||s.destroy()}componentDidLoad(){this.watchInitStripe()}render(){return o(n,{key:"f376a81e62581bff4ac25d53f11c8e53408f9e7e",class:"zonos--address zonos--elements"},o("zonos-text",{key:"bdc1a8b7414cae0e79c90e0685700590cd920468",class:"zonos--title",type:"semiBoldLabel"},this.titleText),o("div",{key:"fe384f4c0e508a9f8ddff8fa579c504c3f18e7bb",class:"zonos--address-component"}))}get el(){return t(this)}static get watchers(){return{stripe:["watchInitStripe"]}}};d.style=".sc-zonos-address-h{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-address-h *.sc-zonos-address{font-family:var(--font-family, Inter), Inter}.sc-zonos-address-h img.sc-zonos-address{max-width:100%}.sc-zonos-address-h dl.sc-zonos-address,.sc-zonos-address-h dd.sc-zonos-address,.sc-zonos-address-h h1.sc-zonos-address,.sc-zonos-address-h h2.sc-zonos-address,.sc-zonos-address-h h3.sc-zonos-address,.sc-zonos-address-h h4.sc-zonos-address,.sc-zonos-address-h h5.sc-zonos-address,.sc-zonos-address-h h6.sc-zonos-address,.sc-zonos-address-h hr.sc-zonos-address,.sc-zonos-address-h figure.sc-zonos-address,.sc-zonos-address-h p.sc-zonos-address,.sc-zonos-address-h pre.sc-zonos-address{margin:0}.sc-zonos-address-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-address-h .zonos--title.sc-zonos-address{margin-bottom:var(--amino-space-16)}";const h=class{constructor(o){s(this,o),this.titleText=void 0,this.stripe=i.stripe}watchInitStripe(){if(!this.stripe||!i.stripeElements)return;const s=i.stripeLinkElement||i.stripeElements.create("linkAuthentication"),o=this.el.querySelector(".zonos--link-authentication-component");o?(s.mount(o),s.on("change",(s=>{i.stripeLinkEventData=s,e()})),i.stripeLinkElement=s):console.error("Cannot find container element for linkAuthenticationElement")}componentDidLoad(){this.watchInitStripe()}render(){return o(n,{key:"48ec92ca8a1500c3b8e85222c3df069c32074e72",class:"zonos--link-authentication zonos--elements"},o("zonos-text",{key:"9060fab8ab9f88157ee6951af830e106e6ff9509",class:"zonos--title",type:"semiBoldLabel"},this.titleText),o("div",{key:"dac7e96170d15faa8c1013fb298ae86e2ce99f0b",class:"zonos--link-authentication-component"}))}get el(){return t(this)}static get watchers(){return{stripe:["watchInitStripe"]}}};h.style=".sc-zonos-link-authentication-h{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-link-authentication-h *.sc-zonos-link-authentication{font-family:var(--font-family, Inter), Inter}.sc-zonos-link-authentication-h img.sc-zonos-link-authentication{max-width:100%}.sc-zonos-link-authentication-h dl.sc-zonos-link-authentication,.sc-zonos-link-authentication-h dd.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h1.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h2.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h3.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h4.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h5.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h6.sc-zonos-link-authentication,.sc-zonos-link-authentication-h hr.sc-zonos-link-authentication,.sc-zonos-link-authentication-h figure.sc-zonos-link-authentication,.sc-zonos-link-authentication-h p.sc-zonos-link-authentication,.sc-zonos-link-authentication-h pre.sc-zonos-link-authentication{margin:0}.sc-zonos-link-authentication-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-link-authentication-h .zonos--title.sc-zonos-link-authentication{margin-bottom:var(--amino-space-16)}";export{d as zonos_address,h as zonos_link_authentication}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(t,n,o,e){function i(t){return t instanceof o?t:new o((function(n){n(t)}))}return new(o||(o=Promise))((function(o,r){function s(t){try{a(e.next(t))}catch(t){r(t)}}function u(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?o(t.value):i(t.value).then(s,u)}a((e=e.apply(t,n||[])).next())}))};var __generator=this&&this.__generator||function(t,n){var o={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},e,i,r,s;return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(t){return function(n){return a([t,n])}}function a(u){if(e)throw new TypeError("Generator is already executing.");while(s&&(s=0,u[0]&&(o=0)),o)try{if(e=1,i&&(r=u[0]&2?i["return"]:u[0]?i["throw"]||((r=i["return"])&&r.call(i),0):i.next)&&!(r=r.call(i,u[1])).done)return r;if(i=0,r)u=[u[0]&2,r.value];switch(u[0]){case 0:case 1:r=u;break;case 4:o.label++;return{value:u[1],done:false};case 5:o.label++;i=u[1];u=[0];continue;case 7:u=o.ops.pop();o.trys.pop();continue;default:if(!(r=o.trys,r=r.length>0&&r[r.length-1])&&(u[0]===6||u[0]===2)){o=0;continue}if(u[0]===3&&(!r||u[1]>r[0]&&u[1]<r[3])){o.label=u[1];break}if(u[0]===6&&o.label<r[1]){o.label=r[1];r=u;break}if(r&&o.label<r[2]){o.label=r[2];o.ops.push(u);break}if(r[2])o.ops.pop();o.trys.pop();continue}u=n.call(t,o)}catch(t){u=[6,t];i=0}finally{e=r=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};System.register(["./p-4d39efb6.system.js","./p-
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(t,n,o,e){function i(t){return t instanceof o?t:new o((function(n){n(t)}))}return new(o||(o=Promise))((function(o,r){function s(t){try{a(e.next(t))}catch(t){r(t)}}function u(t){try{a(e["throw"](t))}catch(t){r(t)}}function a(t){t.done?o(t.value):i(t.value).then(s,u)}a((e=e.apply(t,n||[])).next())}))};var __generator=this&&this.__generator||function(t,n){var o={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},e,i,r,s;return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(t){return function(n){return a([t,n])}}function a(u){if(e)throw new TypeError("Generator is already executing.");while(s&&(s=0,u[0]&&(o=0)),o)try{if(e=1,i&&(r=u[0]&2?i["return"]:u[0]?i["throw"]||((r=i["return"])&&r.call(i),0):i.next)&&!(r=r.call(i,u[1])).done)return r;if(i=0,r)u=[u[0]&2,r.value];switch(u[0]){case 0:case 1:r=u;break;case 4:o.label++;return{value:u[1],done:false};case 5:o.label++;i=u[1];u=[0];continue;case 7:u=o.ops.pop();o.trys.pop();continue;default:if(!(r=o.trys,r=r.length>0&&r[r.length-1])&&(u[0]===6||u[0]===2)){o=0;continue}if(u[0]===3&&(!r||u[1]>r[0]&&u[1]<r[3])){o.label=u[1];break}if(u[0]===6&&o.label<r[1]){o.label=r[1];r=u;break}if(r&&o.label<r[2]){o.label=r[2];o.ops.push(u);break}if(r[2])o.ops.pop();o.trys.pop();continue}u=n.call(t,o)}catch(t){u=[6,t];i=0}finally{e=r=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};System.register(["./p-4d39efb6.system.js","./p-c3d75f4f.system.js","./p-a6f2e282.system.js","./p-dc09ca69.system.js","./p-7f68c103.system.js","./p-12ecf765.system.js"],(function(t){"use strict";var n,o,e,i,r,s,u,a,c,f,h,d,l,v;return{setters:[function(t){n=t.r;o=t.c;e=t.h;i=t.H},function(t){r=t.s},function(t){s=t.h;u=t.b;a=t.i;c=t.l;f=t.c;h=t.d},function(t){d=t.z;l=t.b;v=t.d},function(){},function(){}],execute:function(){var _=this;var m=function(){return __awaiter(_,void 0,void 0,(function(){var t,n,o,e;return __generator(this,(function(i){switch(i.label){case 0:t="".concat("https://v1.route.js.zonos.com","/api/zonos-elements/zonos-settings");return[4,s(t)];case 1:n=i.sent(),o=n.errors,e=n.json;if(o.length){u("Error occurred when getting zonos settings. If this is not an unauthorized error, it will use user settings or default settings");return[2,{errors:o,json:null}]}return[2,{errors:[],json:e}]}}))}))};var w=function(){var t=document.querySelector("zonos-checkout");if(!t){var n=document.createElement("zonos-checkout");document.body.appendChild(n)}};var y=function(t){if(!t.placeOrderButtonSelector){return}if(!a(t.placeOrderButtonSelector)){u('Selector checkoutButtonAnchor "'.concat(t.placeOrderButtonSelector,'" is not a valid selector'));return}w()};var g=function(t){var n=document.querySelector("zonos-hello");if(!n&&t){var o=document.createElement("zonos-hello");t.appendChild(o)}};var p=function(t){return __awaiter(_,void 0,void 0,(function(){var n,o;return __generator(this,(function(e){n=t.anchorElementSelector;if(!n||!a(n)){u('Selector anchorElementSelector "'.concat(t.anchorElementSelector,'" is not a valid selector.'));return[2]}o=document.querySelector(n);c("Hello init complete");g(o);return[2]}))}))};var z=":host{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--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{visibility:hidden;opacity:0;height:0}";var b=z;var k=t("zonos_controller",function(){function t(t){n(this,t);this.stripeInitEvent=o(this,"stripeInitEvent",7);this.config=undefined;this.zonosApiKey=undefined}t.prototype.initCheckoutElement=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){if(!t){c("Stripe is not loaded yet - cannot init checkout element","warn");return[2]}r.stripe=t;void y(d.checkoutSettings);c("init checkout element");return[2]}))}))};t.prototype.initZonosNotification=function(){var t=document.querySelector("zonos-notification");if(t){return}var n=document.createElement("zonos-notification");document.body.appendChild(n)};t.prototype.setupGoogleFont=function(t){return __awaiter(this,void 0,void 0,(function(){var n,o,e,i,r,u,a,f;return __generator(this,(function(h){switch(h.label){case 0:e=t||v();if(e==="Inter"){if(!t){return[2]}c("[FONT] Just applied Inter , but no need to inject since we already inject Inter on start","warn");d.appearance=Object.assign(Object.assign({},d.appearance),{fontFamily:t})}i="https://v1.route.js.zonos.com";return[4,s("".concat(i,"/api/zonos-elements/get-font-detail?family=").concat(e))];case 1:r=h.sent(),u=r.errors,a=r.json;if(u.length>0||!a){c("Failed to load font ".concat(e),"warn");return[2]}f=a.fontUrl;(o=(n=window.Zonos).injectSupportGoogleFont)===null||o===void 0?void 0:o.call(n,f);if(!t){return[2]}c("[FONT] ".concat(t," font override applied"));d.appearance=Object.assign(Object.assign({},d.appearance),{fontFamily:t});return[2]}}))}))};t.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(n){d.zonosApiKey=this.zonosApiKey;(function(){return __awaiter(t,void 0,void 0,(function(){var t,n,o,e,i,r;return __generator(this,(function(s){switch(s.label){case 0:return[4,m()];case 1:o=s.sent(),e=o.errors,i=o.json;if(((t=e[0])===null||t===void 0?void 0:t.type.toString())==="403"){c("Failed to load zonos settings. This domain may not have access","warn");return[2]}this.initZonosNotification();l({overrideSettings:this.config,zonosSettings:i});void this.setupGoogleFont();if(d.helloSettings){void p(d.helloSettings)}return[4,f()];case 2:s.sent();r=((n=i===null||i===void 0?void 0:i.checkoutSettings)===null||n===void 0?void 0:n.externalServiceTokens.find((function(t){return t.type==="STRIPE_PUBLISHABLE_TOKEN"})))||null;if(!r||!this.stripeInitEvent){c("Checkout failed to load -- missing publishable key","warn");return[2]}if(d.checkoutSettings.subscriptionStatus==="INACTIVE"){c('=== Checkout subscription is "INACTIVE" - Cancel initializing for Checkout ===',"warn");c("zonos controller loaded");return[2]}if(d.checkoutSettings.visibilityStatus==="DISABLED"){c("=== Checkout is disabled by store owner ===","warn");c("zonos controller loaded");return[2]}this.stripeInitEvent.emit({publishableKey:r.token});c("zonos controller loaded");return[2]}}))}))})();return[2]}))}))};t.prototype.showNotification=function(t){return __awaiter(this,void 0,void 0,(function(){var n;return __generator(this,(function(o){n=document.querySelector("zonos-notification");if(!n){c("Failed to show notification - zonos-notification not found","warn");return[2]}void n.showNotification(t);return[2]}))}))};t.prototype.overrideConfig=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){l({overrideSettings:t,zonosSettings:null});return[2]}))}))};t.prototype.overrideCountry=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){void h(t);return[2]}))}))};t.prototype.getAppearanceSetting=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,d.appearance]}))}))};t.prototype.updateOrganizationName=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){d.organizationName=t;return[2]}))}))};t.prototype.render=function(){return e(i,{key:"a94fb7ff23c45a9813ce5da857cda14c8455ff79",class:"zonos--elements"})};return t}());k.style=b}}}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
System.register(["./p-4d39efb6.system.js"],(function(e,o){"use strict";var t,i;return{setters:[function(o){t=o.p;i=o.b;e("setNonce",o.s)}],execute:function(){var e=function(){var e=o.meta.url;var i={};if(e!==""){i.resourcesUrl=new URL(".",e).href}return t(i)};e().then((function(e){return i([["p-5a0264e8.system",[[1,"zonos-text",{class:[1],color:[1],size:[1],type:[1],weight:[2],content:[1],ready:[32]}]]],["p-
|
|
1
|
+
System.register(["./p-4d39efb6.system.js"],(function(e,o){"use strict";var t,i;return{setters:[function(o){t=o.p;i=o.b;e("setNonce",o.s)}],execute:function(){var e=function(){var e=o.meta.url;var i={};if(e!==""){i.resourcesUrl=new URL(".",e).href}return t(i)};e().then((function(e){return i([["p-5a0264e8.system",[[1,"zonos-text",{class:[1],color:[1],size:[1],type:[1],weight:[2],content:[1],ready:[32]}]]],["p-12c19be6.system",[[2,"zonos-checkout",{appearanceSettingsOverride:[16],preview:[4],mobile:[4],defaultAddress:[16],forceDialogOpen:[4,"force-dialog-open"],open:[32],stripe:[32],submitLoading:[32],paymentError:[32],collapseReviewMobile:[32],isAttachError:[32],isMobile:[32],zonosReviewRef:[32],storybookPaymentStatusOverride:[32],closeDialogHandler:[64],init:[64],setToFinishStep:[64]},[[16,"zonos--init-cart-info","initCartInfoHandler"],[9,"resize","handleWindowResize"]],{appearanceSettingsOverride:["appearanceSettingsOverrideChanged"],mobile:["handleMobileChange"]}]]],["p-f82e000f.system",[[1,"zonos-hello",{mobileLocationOverride:[1,"mobile-location-override"],animateFromLeftOverride:[4,"animate-from-left-override"],appearanceSettingsOverride:[16],showPeekMessage:[32],zonosStoreHelloSettings:[32],showDialog:[32],peekMessage:[32],initialUrl:[32],allRestrictedItems:[32],allFoundProducts:[32],productsOnPage:[32],displayCurrency:[64],convertAndFormat:[64],convert:[64],format:[64]},[[9,"resize","handleResize"]]]]],["p-8970e202.system",[[1,"zonos-controller",{config:[16],zonosApiKey:[1,"zonos-api-key"],initCheckoutElement:[64],setupGoogleFont:[64],showNotification:[64],overrideConfig:[64],overrideCountry:[64],getAppearanceSetting:[64],updateOrganizationName:[64]}]]],["p-7cae86a0.system",[[1,"zonos-component",{first:[1],middle:[1],last:[1]}]]],["p-83bb8727.system",[[1,"zonos-country-select",{closeCountrySelect:[16],inputValue:[32]}],[1,"zonos-hello-dialog-footer",{appearanceSettings:[16],setShowCountrySelect:[16]}],[1,"zonos-custom-message",{icon:[1],message:[1]}],[1,"zonos-country-flag",{class:[1],countryCode:[1,"country-code"],size:[2]}]]],["p-eb96f893.system",[[1,"zonos-hello-dialog",{isOpen:[4,"is-open"],setIsOpen:[16],mobileLocationOverride:[1,"mobile-location-override"],animateFromLeftOverride:[4,"animate-from-left-override"],appearanceSettings:[16],restrictedItems:[16],welcomeMessage:[32],showCountrySelect:[32]},[[4,"click","globalClickHandler"]],{isOpen:["isOpenHandler"]}]]],["p-73174d0c.system",[[1,"zonos-notification",{class:[1],notificationArray:[32],showNotification:[64]}]]],["p-bea31a7b.system",[[1,"zonos-badge",{bold:[4],color:[1],icon:[16],iconRight:[4,"icon-right"],size:[1],rounded:[4],class:[1]}]]],["p-7beaee33.system",[[2,"zonos-payment",{titleText:[1,"title-text"],stripe:[32],stripeElements:[32]},null,{stripeElements:["watchInitStripe"],stripe:["watchInitStripe"]}]]],["p-be23cc91.system",[[1,"zonos-shipping-rich-radio",{items:[16],borderColor:[1,"border-color"],borderStyle:[1,"border-style"],theme:[1],selectedItem:[32]}]]],["p-dcf1e1b4.system",[[2,"zonos-address",{type:[1],titleText:[1,"title-text"],defaultAddress:[16],stripe:[32]},null,{stripe:["watchInitStripe"]}],[2,"zonos-link-authentication",{titleText:[1,"title-text"],stripe:[32]},null,{stripe:["watchInitStripe"]}]]],["p-1c00ffea.system",[[1,"zonos-banner",{bannerTitle:[1,"banner-title"],intent:[1],class:[1],hasContent:[32]}]]],["p-26edde4d.system",[[1,"zonos-card",{actions:[16],class:[1],footerActions:[16],footerContent:[16],footerHeight:[2,"footer-height"],label:[16],spacing:[1]}],[1,"zonos-v-stack",{spacing:[2],class:[1]}]]],["p-410045c5.system",[[1,"zonos-icon",{autoHeight:[4,"auto-height"],color:[1],content:[1],size:[2]}]]],["p-efd1544b.system",[[1,"zonos-button",{class:[1],color:[1],backgroundColor:[1,"background-color"],borderStyle:[1,"border-style"],isDisabled:[4,"is-disabled"],icon:[16],iconRight:[4,"icon-right"],size:[1],variant:[1],noBackground:[4,"no-background"],noPaddingLeft:[4,"no-padding-left"],noPaddingRight:[4,"no-padding-right"],loading:[4],theme:[1],hasIcon:[32],hasContent:[32]},[[2,"click","clickHandler"]],{icon:["iconChangeHandler"]}],[1,"zonos-spinner",{size:[2],color:[1]}]]],["p-da2387d2.system",[[2,"zonos-checkout-payment",{paymentError:[4,"payment-error"],submitBtnType:[1,"submit-btn-type"],continueLoading:[4,"continue-loading"],submitBtnColor:[1,"submit-btn-color"],disabled:[32]},null,{disabled:["watchFormComplete"]}],[2,"zonos-customer-info",{continueLoading:[4,"continue-loading"],submitBtnType:[1,"submit-btn-type"],submitBtnColor:[1,"submit-btn-color"],defaultAddress:[16],disabled:[32]},null,{disabled:["watchFormComplete"]}],[2,"zonos-shipping",{continueLoading:[4,"continue-loading"],submitBtnColor:[1,"submit-btn-color"],submitBtnType:[1,"submit-btn-type"],selectedShippingMethod:[32],disabled:[32]},null,{disabled:["watchFormComplete"]}],[1,"zonos-checkout-finish",{borderRadius:[1,"border-radius"],storybookForceStatus:[1,"storybook-force-status"],overrideNotification:[16],isLoading:[32],notificationType:[32],notificationTitle:[32],notificationMessages:[32],order:[32]}],[1,"zonos-cart-subtotal"],[1,"zonos-dialog",{open:[4],headerText:[1,"header-text"],width:[1],height:[1],noHeader:[4,"no-header"],noBodyPadding:[4,"no-body-padding"],noBorder:[4,"no-border"],footerRightAction:[16],borderStyle:[1,"border-style"],noCloseButton:[4,"no-close-button"],noClickOutside:[4,"no-click-outside"],mobile:[4],isLoading:[4,"is-loading"],isMobile:[32]},[[9,"resize","handleWindowResize"]]],[1,"zonos-review",{mobile:[4],collapsed:[4],isMobile:[32]},[[9,"resize","handleWindowResize"]]],[1,"zonos-cart-items",{errorImages:[32]}],[1,"zonos-collapse",{collapsed:[4],collapseSize:[2,"collapse-size"],height:[32]}],[1,"zonos-logo",{theme:[1],width:[1],class:[1]}]]]],e)}))}}}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,h as s,F as t,H as c}from"./p-4d8545e1.js";import{k as e,c as n,h as i,g as a,s as h,l as r,j as l,m as u,d,n as z,o as m,e as k}from"./p-e59b6648.js";import{a as p,l as g,t as f}from"./p-8ebc0b64.js";import{z as v,m as b}from"./p-e8da4463.js";import{s as w,i as y}from"./p-b87fa3a1.js";import{c as x}from"./p-b4b7f705.js";import{g as C}from"./p-f2733cc7.js";import{i as B}from"./p-0024f8c2.js";const j='<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="https://www.w3.org/2000/svg">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M2.25 4.5C2.25 3.25736 3.25736 2.25 4.5 2.25H13.5C14.7426 2.25 15.75 3.25736 15.75 4.5V10.5C15.75 11.7426 14.7426 12.75 13.5 12.75H8.25C8.01393 12.75 7.79164 12.8611 7.65 13.05L6.3 14.85C5.87508 15.4166 5.2082 15.75 4.5 15.75C3.25736 15.75 2.25 14.7426 2.25 13.5V4.5ZM4.5 3.75C4.08579 3.75 3.75 4.08579 3.75 4.5V13.5C3.75 13.9142 4.08579 14.25 4.5 14.25C4.73607 14.25 4.95836 14.1389 5.1 13.95L6.45 12.15C6.87492 11.5834 7.5418 11.25 8.25 11.25H13.5C13.9142 11.25 14.25 10.9142 14.25 10.5V4.5C14.25 4.08579 13.9142 3.75 13.5 3.75H4.5ZM5.25 6C5.25 5.58579 5.58579 5.25 6 5.25H12C12.4142 5.25 12.75 5.58579 12.75 6C12.75 6.41421 12.4142 6.75 12 6.75H6C5.58579 6.75 5.25 6.41421 5.25 6ZM5.25 9C5.25 8.58579 5.58579 8.25 6 8.25H8.25C8.66421 8.25 9 8.58579 9 9C9 9.41421 8.66421 9.75 8.25 9.75H6C5.58579 9.75 5.25 9.41421 5.25 9Z" fill="#4D505A"/>\n</svg>\n',I='<svg color="var(--amino-gray-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" data-is-secondary-color="true" fill="var(--amino-gray-200)" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>',L=class{constructor(s){o(this,s),this.applyStripeTheme=async()=>{var o,s,t;const c=(null===(o=this.appearanceSettingsOverride)||void 0===o?void 0:o.theme)||v.appearance.theme;await e({overrideBorderRaidus:null===(s=this.appearanceSettingsOverride)||void 0===s?void 0:s.style,overridePrimaryColor:null===(t=this.appearanceSettingsOverride)||void 0===t?void 0:t.colorPrimary,overrideTheme:this.isMobile?c:void 0})},this.isShippableCountry=(o=!0)=>!(!p.localizationLoaded||!p.isShippableCountry&&(o&&g("Checkout: not shippable country"),1)),this.getCurrentLocalePageEnum=()=>{switch(n.step){case"customer-info":return"checkout_customer_info";case"shipping":return"checkout_shipping_info";case"payment":return"checkout_payment_info";default:return null}},this.appearanceSettingsOverride=void 0,this.preview=!1,this.mobile=!1,this.defaultAddress=null,this.forceDialogOpen=!1,this.open=this.forceDialogOpen,this.stripe=window.Zonos.stripe,this.submitLoading=!1,this.paymentError=!1,this.collapseReviewMobile=!1,this.isAttachError=!1,this.isMobile=!1,this.zonosReviewRef=void 0,this.storybookPaymentStatusOverride=void 0}async initCartInfoHandler(o){i(o.detail)}async closeDialogHandler(){w("zonos-checkout-close"),this.open=this.forceDialogOpen||!1,this.preview||"finish"!==n.step||a(),n.step="customer-info"}async buildCartAndInit(){if(v.checkoutSettings.buildCartDetail){g("build cart detail");const o=await v.checkoutSettings.buildCartDetail();await i(o)}if(!h.clientSecret){const o=await r();if(g(`stripeStoreInitCheckoutSession: ${o}`),!o)return!1}return await this.applyStripeTheme(),!0}attachCheckout(){const o=v.checkoutSettings.placeOrderButtonSelector;o&&document.querySelectorAll(o).forEach((o=>{o.getAttribute("data-zonos-checkout-attached")||(o.addEventListener("click",(async o=>{if(this.isShippableCountry()){o.preventDefault(),o.stopPropagation(),g("zonos checkout button clicked"),h.isFetchingSession=!0,this.open=!0;try{if(!await this.buildCartAndInit())throw new Error("Error building cart");w("zonos-checkout-start")}catch(o){h.isFetchingSession=!1,l({messages:[f("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:f("Error creating Checkout")})}}})),o.removeAttribute("disabled"),o.setAttribute("data-zonos-checkout-attached","true"))}))}appearanceSettingsOverrideChanged(){this.appearanceSettingsOverride&&this.applyStripeTheme()}async init(){h.stripe=window.Zonos.stripe,this.stripe=window.Zonos.stripe;const o=setInterval((()=>{const s=window.Zonos.internationalHideSelector;if(!s)return void clearInterval(o);const t=this.isShippableCountry(!1),c=document.querySelectorAll(s);t?null==c||c.forEach((o=>{const s=o;s.setAttribute("data-zonos-checkout-original-display",s.style.display),s.style.display="none"})):null==c||c.forEach((o=>{const s=o,t=s.getAttribute("data-zonos-checkout-original-display")||getComputedStyle(s).display;s.style.display=t||"initial"}))}),100),s=setInterval((()=>{h.stripe=window.Zonos.stripe,this.stripe=window.Zonos.stripe,this.stripe?(this.storybookPaymentStatusOverride||(g("init checkout"),this.preview||this.forceDialogOpen?this.buildCartAndInit():(this.attachCheckout(),new MutationObserver((()=>{this.attachCheckout()})).observe(document.body,{childList:!0,subtree:!0}))),clearInterval(s)):g("waiting for stripe to be loaded")}),50);setTimeout((()=>{clearInterval(s)}),1e4)}async setToFinishStep(o){n.step="finish",this.storybookPaymentStatusOverride=o}async handleCustomerInfoContinue(){this.submitLoading=!0,await u();const o=setInterval((()=>{!n.landedCostData&&h.isFetchingLandedCost||(n.landedCostData&&d(),this.submitLoading=!1,clearInterval(o))}),500)}async handleShippingContinue(){this.submitLoading=!0,setTimeout((()=>{d(),this.submitLoading=!1}),500)}async handleCheckoutPaymentContinue(){this.paymentError=!1,this.submitLoading=!0;try{await z(),d()}catch(o){console.error(o),this.paymentError=!0}this.submitLoading=!1}async handleFinishClick(){if(m(),this.preview)return n.step="customer-info",void await this.init();a();const o=window.location.href.split("?")[0];window.history.replaceState({},document.title,o),this.open=!1,window.location.reload()}async handleBackClick(){"customer-info"!==n.step?k():await this.closeDialogHandler()}handleWindowResize(){this.isMobile=y(this.mobile),this.applyStripeTheme(),g(`mobile: ${this.isMobile}`)}handleMobileChange(){this.isMobile=y(this.mobile),this.applyStripeTheme(),g(`mobile: ${this.isMobile}`)}componentWillLoad(){this.init(),this.isMobile=y(this.mobile),g(`mobile: ${this.isMobile}`)}disconnectedCallback(){m(),a()}render(){var o;const e="finish"!==n.step&&"error"!==n.step&&!h.stripeElements||h.isFetchingSession,{colorPrimary:i,colorSecondary:a,logoUrl:r,style:l}=b(v.appearance,this.appearanceSettingsOverride),u="ENABLED"===v.appearance.zonosAttribution,d=v.appearance.theme,z=i&&B(i)?"DARK":"LIGHT",m=this.isMobile?d:z,k=this.isMobile?void 0:a,{customMessages:g}=p,w=(null===(o=g.find((o=>"checkout_default"===o.pageName)))||void 0===o?void 0:o.message)||"Know about duties and taxes before you buy. Shop with confidence!",y=this.getCurrentLocalePageEnum(),L=g.filter((o=>o.pageName===y)),H=()=>s("div",{class:"zonos--logo"},r&&s("img",{alt:`${v.organizationName} logo`,src:r,width:100})),S=()=>s("zonos-v-stack",null,H(),L.map((o=>s("zonos-custom-message",{icon:j,message:o.message}))),s("div",null,s("zonos-button",{class:"zonos--back-button",icon:s("zonos-icon",{content:'<svg color="var(--amino-gray-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M9.707 16.707a1 1 0 0 1-1.414 0l-3.647-3.646a1.5 1.5 0 0 1 0-2.122l3.647-3.646a1 1 0 0 1 1.414 1.414L7.414 11H19a1 1 0 1 1 0 2H7.414l2.293 2.293a1 1 0 0 1 0 1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>'}),noBackground:!0,noPaddingLeft:!0,noPaddingRight:!0,onClick:()=>this.handleBackClick(),theme:m},f("Back")))),M=()=>u&&s("div",{class:"zonos--footer","data-theme":d},s("zonos-text",{type:"hintText"},f("Powered by")),s("zonos-logo",{theme:d,width:"100px"})),T=()=>{var o;const c=this.isMobile?"primary":void 0,e=null===(o=this.zonosReviewRef)||void 0===o?void 0:o.scrollHeight;return s("div",{class:"zonos--content",style:{"--border-radius":C(l)}},"finish"!==n.step&&"error"!==n.step&&s(t,null,s("div",{class:"zonos--left","data-theme":m,style:{"--primary-color":this.isMobile?"":i}},!this.isMobile&&S(),"customer-info"===n.step&&s("zonos-customer-info",{continueLoading:this.submitLoading,defaultAddress:this.defaultAddress,onContinueClicked:()=>this.handleCustomerInfoContinue(),submitBtnColor:k,submitBtnType:c}),"shipping"===n.step&&s("zonos-shipping",{continueLoading:this.submitLoading,onContinueClicked:()=>this.handleShippingContinue(),submitBtnColor:k,submitBtnType:c}),"payment"===n.step&&s("zonos-checkout-payment",{continueLoading:this.submitLoading,onContinueClicked:()=>this.handleCheckoutPaymentContinue(),paymentError:this.paymentError,submitBtnColor:k,submitBtnType:c})),s("div",{class:"zonos--right","data-theme":d},this.isMobile&&S(),!this.isMobile&&s("zonos-button",{class:"zonos--close-button",icon:s("zonos-icon",{content:I}),noBackground:!0,onClick:()=>this.closeDialogHandler()}),s("div",{class:"flex--wrapper"},s("div",{class:"zonos--wrapper"},s("zonos-collapse",{collapseSize:e,collapsed:this.collapseReviewMobile&&this.isMobile},s("zonos-review",{collapsed:this.collapseReviewMobile,mobile:this.isMobile,onClick:()=>{this.isMobile&&(this.collapseReviewMobile=!this.collapseReviewMobile)},ref:o=>this.zonosReviewRef=o}),s("zonos-cart-items",null))),s("zonos-v-stack",{spacing:16},s("zonos-cart-subtotal",null),s("zonos-custom-message",{class:"zonos--checkout-default-message",icon:j,message:w}))),!this.isMobile&&M()),this.isMobile&&M()),("finish"===n.step||"error"===n.step)&&s("div",{class:"zonos--done","data-theme":d},s("div",{class:"zonos--header"},H(),s("zonos-button",{class:"zonos--close-button",icon:s("zonos-icon",{content:I}),noBackground:!0,onClick:()=>this.handleFinishClick(),theme:d})),s("zonos-checkout-finish",{borderRadius:l,onCloseClick:()=>this.handleFinishClick(),overrideNotification:"error"===n.step&&n.error?Object.assign(Object.assign({},n.error),{type:"error"}):void 0,storybookForceStatus:this.storybookPaymentStatusOverride})))};return s(c,{class:x(["zonos--checkout zonos--elements",u&&"has-footer",this.preview&&"preview",this.isMobile&&"mobile"])},this.preview?T():s("zonos-dialog",{borderStyle:l,"data-theme":d,height:"980px",isLoading:e,mobile:this.isMobile,noBodyPadding:!0,noBorder:!0,noClickOutside:!0,noCloseButton:!0,onCloseDialog:()=>this.closeDialogHandler(),open:this.open,width:"1200px"},T()))}static get assetsDirs(){return["assets"]}static get watchers(){return{appearanceSettingsOverride:["appearanceSettingsOverrideChanged"],mobile:["handleMobileChange"]}}};L.style=".sc-zonos-checkout-h{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-checkout-h *.sc-zonos-checkout{font-family:var(--font-family, Inter), Inter}.sc-zonos-checkout-h img.sc-zonos-checkout{max-width:100%}.sc-zonos-checkout-h dl.sc-zonos-checkout,.sc-zonos-checkout-h dd.sc-zonos-checkout,.sc-zonos-checkout-h h1.sc-zonos-checkout,.sc-zonos-checkout-h h2.sc-zonos-checkout,.sc-zonos-checkout-h h3.sc-zonos-checkout,.sc-zonos-checkout-h h4.sc-zonos-checkout,.sc-zonos-checkout-h h5.sc-zonos-checkout,.sc-zonos-checkout-h h6.sc-zonos-checkout,.sc-zonos-checkout-h hr.sc-zonos-checkout,.sc-zonos-checkout-h figure.sc-zonos-checkout,.sc-zonos-checkout-h p.sc-zonos-checkout,.sc-zonos-checkout-h pre.sc-zonos-checkout{margin:0}.sc-zonos-checkout-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar{width:10px}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-track{background:var(--amino-gray-50)}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb{border-radius:10px;background:#cccccc;border:3px solid transparent;background-clip:content-box}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb:hover{background:#d6d6d6}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;height:100%;overflow:hidden;border-radius:var(--border-radius, var(--amino-radius-10))}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex:1;flex:1;padding:var(--amino-space-48) var(--amino-space-56)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{background-color:var(--primary-color, var(--amino-gray-0));border-right:1px solid var(--amino-gray-200)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{background-color:var(--amino-gray-0);padding-bottom:var(--amino-space-80)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:100%;max-height:100%;height:100%;overflow:auto;-ms-flex-direction:column;flex-direction:column;background-color:var(--amino-gray-0);-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:var(--amino-space-24);padding-bottom:50px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;width:100%}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout img.sc-zonos-checkout{width:150px;min-width:150px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--logo.sc-zonos-checkout{margin-bottom:0}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout zonos-checkout-finish.sc-zonos-checkout{-ms-flex:1;flex:1}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--back-button.sc-zonos-checkout{margin-bottom:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{padding:0 var(--amino-space-8) var(--amino-space-8)}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--payment-error-banner.sc-zonos-checkout{margin-top:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout{position:relative}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout .zonos--close-button.sc-zonos-checkout{position:absolute;right:var(--amino-space-24);top:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--footer.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-pack:end;justify-content:flex-end;-ms-flex-align:center;align-items:center;position:absolute;bottom:var(--amino-space-32);right:var(--amino-space-56);gap:var(--amino-space-8)}.sc-zonos-checkout-h .zonos--wrapper.sc-zonos-checkout{overflow:auto;max-height:100%;position:relative}.sc-zonos-checkout-h .flex--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;max-height:100%}.sc-zonos-checkout-h .zonos--logo.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.sc-zonos-checkout-h .zonos--checkout-default-message.sc-zonos-checkout{margin-left:var(--amino-space-76);margin-bottom:var(--amino-space-8)}.preview.sc-zonos-checkout-h{min-width:500px;margin:auto}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{border:var(--amino-border)}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{padding:var(--amino-space-32)}.mobile.sc-zonos-checkout-h{min-width:auto}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:auto;border-radius:0;max-height:100%;height:100%;border:0}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{padding:var(--amino-space-12)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{-ms-flex-order:2;order:2}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex-order:1;order:1;padding-top:var(--amino-space-16)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:var(--amino-space-16);margin-top:var(--amino-space-24);border:var(--amino-border);border-radius:var(--border-radius, var(--amino-radius-10));background-color:var(--amino-gray-50);padding:var(--amino-space-12);margin-top:var(--amino-space-32)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{max-height:100%}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--footer.sc-zonos-checkout{-ms-flex-order:3;order:3}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:auto}.mobile.sc-zonos-checkout-h .zonos--cart-subtotal.sc-zonos-checkout{margin:0}.mobile.sc-zonos-checkout-h .zonos--footer.sc-zonos-checkout{bottom:0;left:0;padding:var(--amino-space-12);position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;background-color:var(--amino-gray-0)}";export{L as zonos_checkout}
|
|
1
|
+
import{r as o,h as s,F as t,H as c}from"./p-4d8545e1.js";import{k as e,c as n,h as i,g as a,s as h,l as r,j as l,m as u,d,n as z,o as m,e as k}from"./p-245997d9.js";import{a as p,l as g,t as f}from"./p-8ebc0b64.js";import{z as v,m as b}from"./p-e8da4463.js";import{s as w,i as y}from"./p-b87fa3a1.js";import{c as x}from"./p-b4b7f705.js";import{g as C}from"./p-f2733cc7.js";import{i as B}from"./p-0024f8c2.js";const j='<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="https://www.w3.org/2000/svg">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M2.25 4.5C2.25 3.25736 3.25736 2.25 4.5 2.25H13.5C14.7426 2.25 15.75 3.25736 15.75 4.5V10.5C15.75 11.7426 14.7426 12.75 13.5 12.75H8.25C8.01393 12.75 7.79164 12.8611 7.65 13.05L6.3 14.85C5.87508 15.4166 5.2082 15.75 4.5 15.75C3.25736 15.75 2.25 14.7426 2.25 13.5V4.5ZM4.5 3.75C4.08579 3.75 3.75 4.08579 3.75 4.5V13.5C3.75 13.9142 4.08579 14.25 4.5 14.25C4.73607 14.25 4.95836 14.1389 5.1 13.95L6.45 12.15C6.87492 11.5834 7.5418 11.25 8.25 11.25H13.5C13.9142 11.25 14.25 10.9142 14.25 10.5V4.5C14.25 4.08579 13.9142 3.75 13.5 3.75H4.5ZM5.25 6C5.25 5.58579 5.58579 5.25 6 5.25H12C12.4142 5.25 12.75 5.58579 12.75 6C12.75 6.41421 12.4142 6.75 12 6.75H6C5.58579 6.75 5.25 6.41421 5.25 6ZM5.25 9C5.25 8.58579 5.58579 8.25 6 8.25H8.25C8.66421 8.25 9 8.58579 9 9C9 9.41421 8.66421 9.75 8.25 9.75H6C5.58579 9.75 5.25 9.41421 5.25 9Z" fill="#4D505A"/>\n</svg>\n',I='<svg color="var(--amino-gray-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" data-is-secondary-color="true" fill="var(--amino-gray-200)" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>',L=class{constructor(s){o(this,s),this.applyStripeTheme=async()=>{var o,s,t;const c=(null===(o=this.appearanceSettingsOverride)||void 0===o?void 0:o.theme)||v.appearance.theme;await e({overrideBorderRaidus:null===(s=this.appearanceSettingsOverride)||void 0===s?void 0:s.style,overridePrimaryColor:null===(t=this.appearanceSettingsOverride)||void 0===t?void 0:t.colorPrimary,overrideTheme:this.isMobile?c:void 0})},this.isShippableCountry=(o=!0)=>!(!p.localizationLoaded||!p.isShippableCountry&&(o&&g("Checkout: not shippable country"),1)),this.getCurrentLocalePageEnum=()=>{switch(n.step){case"customer-info":return"checkout_customer_info";case"shipping":return"checkout_shipping_info";case"payment":return"checkout_payment_info";default:return null}},this.appearanceSettingsOverride=void 0,this.preview=!1,this.mobile=!1,this.defaultAddress=null,this.forceDialogOpen=!1,this.open=this.forceDialogOpen,this.stripe=window.Zonos.stripe,this.submitLoading=!1,this.paymentError=!1,this.collapseReviewMobile=!1,this.isAttachError=!1,this.isMobile=!1,this.zonosReviewRef=void 0,this.storybookPaymentStatusOverride=void 0}async initCartInfoHandler(o){i(o.detail)}async closeDialogHandler(){w("zonos-checkout-close"),this.open=this.forceDialogOpen||!1,this.preview||"finish"!==n.step||a(),n.step="customer-info"}async buildCartAndInit(){if(v.checkoutSettings.buildCartDetail){g("build cart detail");const o=await v.checkoutSettings.buildCartDetail();await i(o)}if(!h.clientSecret){const o=await r();if(g(`stripeStoreInitCheckoutSession: ${o}`),!o)return!1}return await this.applyStripeTheme(),!0}attachCheckout(){const o=v.checkoutSettings.placeOrderButtonSelector;o&&document.querySelectorAll(o).forEach((o=>{o.getAttribute("data-zonos-checkout-attached")||(o.addEventListener("click",(async o=>{if(this.isShippableCountry()){o.preventDefault(),o.stopPropagation(),g("zonos checkout button clicked"),h.isFetchingSession=!0,this.open=!0;try{if(!await this.buildCartAndInit())throw new Error("Error building cart");w("zonos-checkout-start")}catch(o){h.isFetchingSession=!1,l({messages:[f("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:f("Error creating Checkout")})}}})),o.removeAttribute("disabled"),o.setAttribute("data-zonos-checkout-attached","true"))}))}appearanceSettingsOverrideChanged(){this.appearanceSettingsOverride&&this.applyStripeTheme()}async init(){h.stripe=window.Zonos.stripe,this.stripe=window.Zonos.stripe;const o=setInterval((()=>{const s=window.Zonos.internationalHideSelector;if(!s)return void clearInterval(o);const t=this.isShippableCountry(!1),c=document.querySelectorAll(s);t?null==c||c.forEach((o=>{const s=o;s.setAttribute("data-zonos-checkout-original-display",s.style.display),s.style.display="none"})):null==c||c.forEach((o=>{const s=o,t=s.getAttribute("data-zonos-checkout-original-display")||getComputedStyle(s).display;s.style.display=t||"initial"}))}),100),s=setInterval((()=>{h.stripe=window.Zonos.stripe,this.stripe=window.Zonos.stripe,this.stripe?(this.storybookPaymentStatusOverride||(g("init checkout"),this.preview||this.forceDialogOpen?this.buildCartAndInit():(this.attachCheckout(),new MutationObserver((()=>{this.attachCheckout()})).observe(document.body,{childList:!0,subtree:!0}))),clearInterval(s)):g("waiting for stripe to be loaded")}),50);setTimeout((()=>{clearInterval(s)}),1e4)}async setToFinishStep(o){n.step="finish",this.storybookPaymentStatusOverride=o}async handleCustomerInfoContinue(){this.submitLoading=!0,await u();const o=setInterval((()=>{!n.landedCostData&&h.isFetchingLandedCost||(n.landedCostData&&d(),this.submitLoading=!1,clearInterval(o))}),500)}async handleShippingContinue(){this.submitLoading=!0,setTimeout((()=>{d(),this.submitLoading=!1}),500)}async handleCheckoutPaymentContinue(){this.paymentError=!1,this.submitLoading=!0;try{await z(),d()}catch(o){console.error(o),this.paymentError=!0}this.submitLoading=!1}async handleFinishClick(){if(m(),this.preview)return n.step="customer-info",void await this.init();a();const o=window.location.href.split("?")[0];window.history.replaceState({},document.title,o),this.open=!1,window.location.reload()}async handleBackClick(){"customer-info"!==n.step?k():await this.closeDialogHandler()}handleWindowResize(){this.isMobile=y(this.mobile),this.applyStripeTheme(),g(`mobile: ${this.isMobile}`)}handleMobileChange(){this.isMobile=y(this.mobile),this.applyStripeTheme(),g(`mobile: ${this.isMobile}`)}componentWillLoad(){this.init(),this.isMobile=y(this.mobile),g(`mobile: ${this.isMobile}`)}disconnectedCallback(){m(),a()}render(){var o;const e="finish"!==n.step&&"error"!==n.step&&!h.stripeElements||h.isFetchingSession,{colorPrimary:i,colorSecondary:a,logoUrl:r,style:l}=b(v.appearance,this.appearanceSettingsOverride),u="ENABLED"===v.appearance.zonosAttribution,d=v.appearance.theme,z=i&&B(i)?"DARK":"LIGHT",m=this.isMobile?d:z,k=this.isMobile?void 0:a,{customMessages:g}=p,w=(null===(o=g.find((o=>"checkout_default"===o.pageName)))||void 0===o?void 0:o.message)||"Know about duties and taxes before you buy. Shop with confidence!",y=this.getCurrentLocalePageEnum(),L=g.filter((o=>o.pageName===y)),H=()=>s("div",{class:"zonos--logo"},r&&s("img",{alt:`${v.organizationName} logo`,src:r,width:100})),S=()=>s("zonos-v-stack",null,H(),L.map((o=>s("zonos-custom-message",{icon:j,message:o.message}))),s("div",null,s("zonos-button",{class:"zonos--back-button",icon:s("zonos-icon",{content:'<svg color="var(--amino-gray-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M9.707 16.707a1 1 0 0 1-1.414 0l-3.647-3.646a1.5 1.5 0 0 1 0-2.122l3.647-3.646a1 1 0 0 1 1.414 1.414L7.414 11H19a1 1 0 1 1 0 2H7.414l2.293 2.293a1 1 0 0 1 0 1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>'}),noBackground:!0,noPaddingLeft:!0,noPaddingRight:!0,onClick:()=>this.handleBackClick(),theme:m},f("Back")))),M=()=>u&&s("div",{class:"zonos--footer","data-theme":d},s("zonos-text",{type:"hintText"},f("Powered by")),s("zonos-logo",{theme:d,width:"100px"})),T=()=>{var o;const c=this.isMobile?"primary":void 0,e=null===(o=this.zonosReviewRef)||void 0===o?void 0:o.scrollHeight;return s("div",{class:"zonos--content",style:{"--border-radius":C(l)}},"finish"!==n.step&&"error"!==n.step&&s(t,null,s("div",{class:"zonos--left","data-theme":m,style:{"--primary-color":this.isMobile?"":i}},!this.isMobile&&S(),"customer-info"===n.step&&s("zonos-customer-info",{continueLoading:this.submitLoading,defaultAddress:this.defaultAddress,onContinueClicked:()=>this.handleCustomerInfoContinue(),submitBtnColor:k,submitBtnType:c}),"shipping"===n.step&&s("zonos-shipping",{continueLoading:this.submitLoading,onContinueClicked:()=>this.handleShippingContinue(),submitBtnColor:k,submitBtnType:c}),"payment"===n.step&&s("zonos-checkout-payment",{continueLoading:this.submitLoading,onContinueClicked:()=>this.handleCheckoutPaymentContinue(),paymentError:this.paymentError,submitBtnColor:k,submitBtnType:c})),s("div",{class:"zonos--right","data-theme":d},this.isMobile&&S(),!this.isMobile&&s("zonos-button",{class:"zonos--close-button",icon:s("zonos-icon",{content:I}),noBackground:!0,onClick:()=>this.closeDialogHandler()}),s("div",{class:"flex--wrapper"},s("div",{class:"zonos--wrapper"},s("zonos-collapse",{collapseSize:e,collapsed:this.collapseReviewMobile&&this.isMobile},s("zonos-review",{collapsed:this.collapseReviewMobile,mobile:this.isMobile,onClick:()=>{this.isMobile&&(this.collapseReviewMobile=!this.collapseReviewMobile)},ref:o=>this.zonosReviewRef=o}),s("zonos-cart-items",null))),s("zonos-v-stack",{spacing:16},s("zonos-cart-subtotal",null),s("zonos-custom-message",{class:"zonos--checkout-default-message",icon:j,message:w}))),!this.isMobile&&M()),this.isMobile&&M()),("finish"===n.step||"error"===n.step)&&s("div",{class:"zonos--done","data-theme":d},s("div",{class:"zonos--header"},H(),s("zonos-button",{class:"zonos--close-button",icon:s("zonos-icon",{content:I}),noBackground:!0,onClick:()=>this.handleFinishClick(),theme:d})),s("zonos-checkout-finish",{borderRadius:l,onCloseClick:()=>this.handleFinishClick(),overrideNotification:"error"===n.step&&n.error?Object.assign(Object.assign({},n.error),{type:"error"}):void 0,storybookForceStatus:this.storybookPaymentStatusOverride})))};return s(c,{class:x(["zonos--checkout zonos--elements",u&&"has-footer",this.preview&&"preview",this.isMobile&&"mobile"])},this.preview?T():s("zonos-dialog",{borderStyle:l,"data-theme":d,height:"980px",isLoading:e,mobile:this.isMobile,noBodyPadding:!0,noBorder:!0,noClickOutside:!0,noCloseButton:!0,onCloseDialog:()=>this.closeDialogHandler(),open:this.open,width:"1200px"},T()))}static get assetsDirs(){return["assets"]}static get watchers(){return{appearanceSettingsOverride:["appearanceSettingsOverrideChanged"],mobile:["handleMobileChange"]}}};L.style=".sc-zonos-checkout-h{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-checkout-h *.sc-zonos-checkout{font-family:var(--font-family, Inter), Inter}.sc-zonos-checkout-h img.sc-zonos-checkout{max-width:100%}.sc-zonos-checkout-h dl.sc-zonos-checkout,.sc-zonos-checkout-h dd.sc-zonos-checkout,.sc-zonos-checkout-h h1.sc-zonos-checkout,.sc-zonos-checkout-h h2.sc-zonos-checkout,.sc-zonos-checkout-h h3.sc-zonos-checkout,.sc-zonos-checkout-h h4.sc-zonos-checkout,.sc-zonos-checkout-h h5.sc-zonos-checkout,.sc-zonos-checkout-h h6.sc-zonos-checkout,.sc-zonos-checkout-h hr.sc-zonos-checkout,.sc-zonos-checkout-h figure.sc-zonos-checkout,.sc-zonos-checkout-h p.sc-zonos-checkout,.sc-zonos-checkout-h pre.sc-zonos-checkout{margin:0}.sc-zonos-checkout-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar{width:10px}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-track{background:var(--amino-gray-50)}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb{border-radius:10px;background:#cccccc;border:3px solid transparent;background-clip:content-box}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb:hover{background:#d6d6d6}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;height:100%;overflow:hidden;border-radius:var(--border-radius, var(--amino-radius-10))}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex:1;flex:1;padding:var(--amino-space-48) var(--amino-space-56)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{background-color:var(--primary-color, var(--amino-gray-0));border-right:1px solid var(--amino-gray-200)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{background-color:var(--amino-gray-0);padding-bottom:var(--amino-space-80)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:100%;max-height:100%;height:100%;overflow:auto;-ms-flex-direction:column;flex-direction:column;background-color:var(--amino-gray-0);-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:var(--amino-space-24);padding-bottom:50px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;width:100%}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout img.sc-zonos-checkout{width:150px;min-width:150px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--logo.sc-zonos-checkout{margin-bottom:0}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout zonos-checkout-finish.sc-zonos-checkout{-ms-flex:1;flex:1}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--back-button.sc-zonos-checkout{margin-bottom:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{padding:0 var(--amino-space-8) var(--amino-space-8)}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--payment-error-banner.sc-zonos-checkout{margin-top:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout{position:relative}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout .zonos--close-button.sc-zonos-checkout{position:absolute;right:var(--amino-space-24);top:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--footer.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-pack:end;justify-content:flex-end;-ms-flex-align:center;align-items:center;position:absolute;bottom:var(--amino-space-32);right:var(--amino-space-56);gap:var(--amino-space-8)}.sc-zonos-checkout-h .zonos--wrapper.sc-zonos-checkout{overflow:auto;max-height:100%;position:relative}.sc-zonos-checkout-h .flex--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;max-height:100%}.sc-zonos-checkout-h .zonos--logo.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.sc-zonos-checkout-h .zonos--checkout-default-message.sc-zonos-checkout{margin-left:var(--amino-space-76);margin-bottom:var(--amino-space-8)}.preview.sc-zonos-checkout-h{min-width:500px;margin:auto}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{border:var(--amino-border)}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{padding:var(--amino-space-32)}.mobile.sc-zonos-checkout-h{min-width:auto}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:auto;border-radius:0;max-height:100%;height:100%;border:0}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{padding:var(--amino-space-12)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{-ms-flex-order:2;order:2}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex-order:1;order:1;padding-top:var(--amino-space-16)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:var(--amino-space-16);margin-top:var(--amino-space-24);border:var(--amino-border);border-radius:var(--border-radius, var(--amino-radius-10));background-color:var(--amino-gray-50);padding:var(--amino-space-12);margin-top:var(--amino-space-32)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{max-height:100%}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--footer.sc-zonos-checkout{-ms-flex-order:3;order:3}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:auto}.mobile.sc-zonos-checkout-h .zonos--cart-subtotal.sc-zonos-checkout{margin:0}.mobile.sc-zonos-checkout-h .zonos--footer.sc-zonos-checkout{bottom:0;left:0;padding:var(--amino-space-12);position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;background-color:var(--amino-gray-0)}";export{L as zonos_checkout}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,n,t,r){function i(e){return e instanceof t?e:new t((function(n){n(e)}))}return new(t||(t=Promise))((function(t,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r["throw"](e))}catch(e){o(e)}}function u(e){e.done?t(e.value):i(e.value).then(a,s)}u((r=r.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(n){return u([e,n])}}function u(s){if(r)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(t=0)),t)try{if(r=1,i&&(o=s[0]&2?i["return"]:s[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;if(i=0,o)s=[s[0]&2,o.value];switch(s[0]){case 0:case 1:o=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;i=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(o=t.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){t.label=s[1];break}if(s[0]===6&&t.label<o[1]){t.label=o[1];o=s;break}if(o&&t.label<o[2]){t.label=o[2];t.ops.push(s);break}if(o[2])t.ops.pop();t.trys.pop();continue}s=n.call(e,t)}catch(e){s=[6,e];i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};System.register(["./p-dc09ca69.system.js","./p-a6f2e282.system.js","./p-7f68c103.system.js","./p-12ecf765.system.js"],(function(e){"use strict";var n,t,r,i,o,a,s,u,c;return{setters:[function(e){n=e.z;t=e.c},function(e){r=e.h;i=e.l;o=e.a;a=e.b;s=e.t},function(e){u=e.i},function(e){c=e.g}],execute:function(){var l=this;var d=function(){var e=y.stripeLinkEventData;var n=y.stripeAddressEventData;if(!n||!n.complete){throw new Error("Missing stripe address data")}return{checkoutSessionId:B.checkoutSessionId||"",contact:{email:(e===null||e===void 0?void 0:e.value.email)||"",firstName:n.value.firstName||"",lastName:n.value.lastName||"",phone:n.value.phone||""},items:B.items.map((function(e){return e})),shippingAddress:{addressLine1:n.value.address.line1,addressLine2:n.value.address.line2||"",city:n.value.address.city,country:n.value.address.country,postalCode:n.value.address.postal_code,state:n.value.address.state}}};var v=function(e){return __awaiter(l,void 0,void 0,(function(){var n,t,i,o,a,s;return __generator(this,(function(u){switch(u.label){case 0:t=d();return[4,e(t.checkoutSessionId,t.contact,t.shippingAddress)];case 1:i=u.sent();if(!i){throw new Error("Failed to build landed cost")}return[4,r("".concat("https://v1.route.js.zonos.com","/api/zonos-elements/validate-landed-cost"),{body:i,headers:{"Content-Type":"application/json"},method:"POST"})];case 2:o=u.sent(),a=o.errors,s=o.json;if(!s||a.length){throw new Error("Invalid landed cost object: ".concat(((n=a.find(Boolean))===null||n===void 0?void 0:n.message)||"Unknown error"))}return[2,i]}}))}))};var f=function(e){return __awaiter(l,void 0,void 0,(function(){var t,i,o,a,s,u,c,l,f;return __generator(this,(function(h){switch(h.label){case 0:i=n.checkoutSettings.buildLandedCost;if(!i)return[3,2];return[4,v(i)];case 1:o=h.sent();return[2,o];case 2:a="".concat("https://v1.route.js.zonos.com","/api/zonos-elements/calculate-landed-cost");return[4,r(a,{body:d(),method:"POST",signal:e===null||e===void 0?void 0:e.signal})];case 3:s=h.sent(),u=s.errors,c=s.json;if(u.length||!c){l=((t=u[0])===null||t===void 0?void 0:t.message)==="The user aborted a request.";f=l?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost";throw new Error(f)}return[2,c]}}))}))};var h=function(e){var n=e.theme;switch(n){default:return{".Input":{padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"}}}};var p=function(e){var n=e.borderStyle,t=e.theme;switch(t){case"DARK":return{borderRadius:c(n),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"};default:return{borderRadius:c(n)}}};var m=t((function(){return{clientSecret:sessionStorage.getItem("zonos--client-secret")||null,fetchingLandedCostAbordController:null,isFetchingLandedCost:false,isFetchingSession:false,stripe:null,stripeAddressElement:null,stripeAddressEventData:null,stripeAddressUsedWhenFetchingLC:null,stripeBillingAddressElement:null,stripeElements:null,stripeElementsOptions:null,stripeLinkElement:null,stripeLinkEventData:null,stripeLinkUsedWhenFetchingLC:null,stripePaymentElement:null,stripePaymentEventData:null}})),g=m.onChange,w=m.reset,y=m.state;e("s",y);var _=function(e){var t=e.clientSecret,r=e.overrideBorderRaidus,i=e.overridePrimaryColor,a=e.overrideTheme;var s=i||n.appearance.colorPrimary;var c=s&&u(s)?"night":"flat";var l=a==="DARK"?"night":"flat";return{appearance:{labels:"floating",rules:Object.assign({},h({theme:"LIGHT"})),theme:a?l:c,variables:Object.assign({},p({borderStyle:r,theme:"LIGHT"}))},clientSecret:t,locale:o.selectedLocale}};var S=e("k",(function(e){return __awaiter(l,void 0,void 0,(function(){var n,t,r,o;return __generator(this,(function(a){t=y.clientSecret;if(!y.stripe){i("Skip. Stripe is not initialized");return[2]}if(t){r=_({clientSecret:t,overrideBorderRaidus:e===null||e===void 0?void 0:e.overrideBorderRaidus,overridePrimaryColor:e===null||e===void 0?void 0:e.overridePrimaryColor,overrideTheme:e===null||e===void 0?void 0:e.overrideTheme});o=JSON.stringify(r)===JSON.stringify(y.stripeElementsOptions);if(!y.stripeElements){y.stripeElements=(n=y.stripe)===null||n===void 0?void 0:n.elements(r);y.stripeElementsOptions=r;i("Stripe elements initialized");return[2]}if(!o){y.stripeElements.update(r);y.stripeElementsOptions=r}i("Stripe elements initialized")}return[2]}))}))}));var b=e("o",(function(){sessionStorage.removeItem("zonos--client-secret");w();y.stripe=window.Zonos.stripe}));var k=function(){var e,n,t,r;var i=y.fetchingLandedCostAbordController;if(!i){return false}var o=JSON.stringify((e=y.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((n=y.stripeLinkEventData)===null||n===void 0?void 0:n.value);var a=JSON.stringify((t=y.stripeAddressUsedWhenFetchingLC)===null||t===void 0?void 0:t.value)!==JSON.stringify((r=y.stripeAddressEventData)===null||r===void 0?void 0:r.value);return o||a};var C=e("m",(function(){return __awaiter(l,void 0,void 0,(function(){var e,n,t,r,i,o,s,u,c,l,d,v,h,p;return __generator(this,(function(m){switch(m.label){case 0:i=!!((e=y.stripeAddressEventData)===null||e===void 0?void 0:e.complete);o=!!((n=y.stripeLinkEventData)===null||n===void 0?void 0:n.complete);s=k();if(s){(t=y.fetchingLandedCostAbordController)===null||t===void 0?void 0:t.abort();y.fetchingLandedCostAbordController=null}if(!(i&&o&&(s||!y.isFetchingLandedCost)))return[3,5];y.isFetchingLandedCost=true;if(y.stripeAddressEventData){y.stripeAddressUsedWhenFetchingLC=Object.assign({},y.stripeAddressEventData)}if(y.stripeLinkEventData){y.stripeLinkUsedWhenFetchingLC=Object.assign({},y.stripeLinkEventData)}m.label=1;case 1:m.trys.push([1,3,,4]);u=new AbortController;y.fetchingLandedCostAbordController=u;return[4,f(u)];case 2:c=m.sent(),l=c.checkoutSessionWorkflow,d=c.shipmentRatingCalculateWorkflow;y.fetchingLandedCostAbordController=null;B.landedCostData=(l===null||l===void 0?void 0:l.filter(Boolean))||null;B.shippingData=(d===null||d===void 0?void 0:d.filter(Boolean))||null;v=(r=B.landedCostData)===null||r===void 0?void 0:r.find(Boolean);h=!!v?v.subtotals:null;if(h){J({exchangeRate:h.exchangeRate,items:h.items,landedCostTotal:0,presentmentCurrencyCode:h.presentmentCurrencyCode,shipping:0,total:h.items})}return[3,4];case 3:p=m.sent();a(p);return[3,4];case 4:y.isFetchingLandedCost=false;m.label=5;case 5:return[2]}}))}))}));var E=function(e){var n=[];var t=true;switch(e){case"succeeded":{n=[s("Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us."),"","",s("We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.")];t=false;break}case"requires_capture":case"processing":{n=[s("Payment processing. We'll update you when payment is received.")];t=false;break}case"requires_payment_method":{n=[s("Payment failed. Please try another payment method.")];break}default:{n=[s("Something went wrong.")];break}}return{isError:t,messages:n}};var T=e("p",(function(e){var n=e.clientSecret,t=e.storybookForceStatus;return __awaiter(l,void 0,void 0,(function(){var e,r,i,o,u,c,l,d,v;return __generator(this,(function(f){switch(f.label){case 0:if(t){e=E(t),r=e.isError,i=e.messages;return[2,{error:r,messages:i}]}o=n||y.clientSecret;if(!y.stripe||!o){a("Failed to retrieve payment intent. Stripe is not initialized");return[2,{error:true,message:[s("Something went wrong.")]}]}return[4,y.stripe.retrievePaymentIntent(o)];case 1:u=f.sent().paymentIntent;c=u===null||u===void 0?void 0:u.status;l=E(c),d=l.isError,v=l.messages;return[2,{error:d,messages:v}]}}))}))}));var O=e("n",(function(){return __awaiter(l,void 0,void 0,(function(){var e,n,t,r,i,o,a,s;return __generator(this,(function(u){switch(u.label){case 0:r=!!((e=y.stripePaymentEventData)===null||e===void 0?void 0:e.complete);i=y.stripeElements;o=y.stripe;a=y.clientSecret;if(!(o&&i&&r&&a))return[3,2];return[4,o.confirmPayment({confirmParams:{receipt_email:(t=(n=y.stripeLinkEventData)===null||n===void 0?void 0:n.value)===null||t===void 0?void 0:t.email,return_url:window.location.href},elements:i,redirect:"if_required"})];case 1:s=u.sent().error;if(s){if(s.type==="card_error"||s.type==="validation_error"){throw new Error(s.message)}if(s.type==="invalid_request_error"){if(s.code==="payment_intent_unexpected_state"){return[2]}}throw new Error("An unexpected error occurred.")}u.label=2;case 2:return[2]}}))}))}));var x=e("l",(function(){return __awaiter(l,void 0,void 0,(function(){var e,n,t,s,u,c;return __generator(this,(function(l){switch(l.label){case 0:n=B.items.reduce((function(e,n){return e+n.amount*n.quantity}),0);if(!n||!o.targetCurrency){a("Fail to create checkout session - invalid total or currency");return[2,false]}y.isFetchingSession=true;return[4,r("".concat("https://v1.route.js.zonos.com","/api/zonos-elements/create-checkout-session"),{body:{currency:((e=B.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"",itemsAmount:n,presentmentCountryCode:o.selectedCountryCode||null},method:"POST"})];case 1:t=l.sent(),s=t.errors,u=t.json;y.isFetchingSession=false;if(s.length||!u){a("Error occurs when creating checkout session",JSON.stringify(s,null,2));return[2,false]}c=u.checkoutSessionCreate;y.clientSecret=c.clientSecret;B.checkoutSessionId=c.id;J(Object.assign(Object.assign({},c.subtotals),{landedCostTotal:0,shipping:0,total:c.subtotals.items}));i("Exchange rate updated for cart items (checkout session create)","info",B.exchangeRate);i("done-init-checkout-session");return[2,true]}}))}))}));var A=function(e){var n=e.currency,t=e.id,i=e.itemsAmount,o=e.landedCostId,s=e.presentmentCountryCode;return __awaiter(l,void 0,void 0,(function(){var e,u,c;return __generator(this,(function(l){switch(l.label){case 0:return[4,r("".concat("https://v1.route.js.zonos.com","/api/zonos-elements/update-checkout-session"),{body:{currency:n,id:t,itemsAmount:i,landedCostId:o,presentmentCountryCode:s},method:"POST"})];case 1:e=l.sent(),u=e.errors,c=e.json;if(u.length||!c){a("Error occurs when updating checkout session",JSON.stringify(u,null,2));return[2,{errors:u,json:c}]}return[2,{errors:[],json:c}]}}))}))};g("clientSecret",(function(e){if(e&&y.stripe){sessionStorage.setItem("zonos--client-secret",e)}if(!e){sessionStorage.removeItem("zonos--client-secret")}}));var j=function(e){var n=e.date,t=e.formatOptions,r=t===void 0?{day:"numeric",weekday:"long",year:"numeric"}:t;return new Intl.DateTimeFormat("en-US",r).format(n)};var z=function(e){var n=new Date;var t=e.getTime()-n.getTime();var r=Math.floor(t/(1e3*60*60*24));return r};var D=t((function(){return{checkoutSessionId:sessionStorage.getItem("zonos--checkout-session-id")||null,currency:"USD",dutiesTaxFees:0,error:null,exchangeRate:null,isSelectedShippingAboveDeminimis:false,isSelectedShippingGuarantee:false,items:[],landedCostData:null,selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,step:"customer-info",subtotal:0,total:0}})),P=D.onChange,L=D.reset,B=D.state;e("c",B);var I=e("b",(function(e){var n=e.minTransitAt?z(new Date(e.minTransitAt)):"";var t=e.maxTransitAt?z(new Date(e.maxTransitAt)):"";var r=e.minTransitAt?j({date:new Date(e.minTransitAt)}):"";return{expectedDate:r,maxTransit:t,minTransit:n}}));var N=e("g",(function(){sessionStorage.removeItem("zonos--checkout-session-id");L()}));var F=e("j",(function(e){var n=e.messages,t=e.title;B.step="error";B.error={messages:n,title:t}}));var J=e("a",(function(e){B.exchangeRate=e.exchangeRate;B.dutiesTaxFees=e.landedCostTotal;B.subtotal=e.items;B.total=e.total;B.currency=e.presentmentCurrencyCode}));var R=e("f",(function(e){var n=e.currency,t=e.itemsAmount,r=e.landedCostId;return __awaiter(l,void 0,void 0,(function(){var e,u;return __generator(this,(function(c){switch(c.label){case 0:if(r&&B.selectedLandedCost){e=B.selectedLandedCost.subtotals;J(e);i("Exchange rate updated for cart items (landed cost subtotal)","info",B.exchangeRate)}if(!B.checkoutSessionId){a("Could not update cart total without checkout session id");return[2,false]}return[4,A({currency:n,id:B.checkoutSessionId,itemsAmount:t,landedCostId:r,presentmentCountryCode:o.selectedCountryCode})];case 1:u=c.sent().json;if(!u){a("Error occurs when updating checkout session");F({messages:[s("There's been an error updating your checkout session. Please reload and try again or contact support if the error persists")],title:s("Error updating Checkout")});return[2,false]}if(!r){J(u.checkoutSessionUpdate.subtotals);i("Exchange rate updated for cart items (checkout session update)","info",B.exchangeRate)}return[2,true]}}))}))}));var q=e("i",(function(e){return __awaiter(l,void 0,void 0,(function(){var n,t,r,i,o,a,s,u,c,l,d,v,f;return __generator(this,(function(h){switch(h.label){case 0:B.selectedShippingOption=e;a=I(B.selectedShippingOption),s=a.expectedDate,u=a.maxTransit,c=a.minTransit;B.selectedShippingOptionExpectedDate=s;B.selectedShippingOptionTransitTime=c&&u?"".concat(c,"-").concat(u):"".concat(c||u);l=(n=B.landedCostData)===null||n===void 0?void 0:n.find((function(e){var n,t,r;return((t=(n=e.landedCost)===null||n===void 0?void 0:n.shipmentRating)===null||t===void 0?void 0:t.id)===((r=B.selectedShippingOption)===null||r===void 0?void 0:r.id)}));B.selectedLandedCost=l||null;if(!l){return[2,false]}B.shipping=l.subtotals.shipping;d=((t=l===null||l===void 0?void 0:l.landedCost)===null||t===void 0?void 0:t.landedCostGuaranteeCode)==="ZONOS";v=!!((i=(r=l===null||l===void 0?void 0:l.landedCost)===null||r===void 0?void 0:r.deMinimis)===null||i===void 0?void 0:i.find((function(e){return["DUTY","TAX"].includes(e.type)&&e.threshold==="ABOVE"})));B.isSelectedShippingAboveDeminimis=v;B.isSelectedShippingGuarantee=d;return[4,R({landedCostId:(o=l.landedCost)===null||o===void 0?void 0:o.id})];case 1:f=h.sent();return[2,f]}}))}))}));P("checkoutSessionId",(function(){if(!B.checkoutSessionId){sessionStorage.removeItem("zonos--checkout-session-id");return}sessionStorage.setItem("zonos--checkout-session-id",B.checkoutSessionId)}));var U=e("h",(function(e){return __awaiter(l,void 0,void 0,(function(){var n,t,r;return __generator(this,(function(i){switch(i.label){case 0:B.items=e;t=(n=e.find(Boolean))===null||n===void 0?void 0:n.currencyCode;r=e.reduce((function(e,n){return e+n.amount*n.quantity}),0);if(!t||!r){return[2]}B.currency=t;y.isFetchingSession=true;return[4,R({currency:t,itemsAmount:r})];case 1:i.sent();y.isFetchingSession=false;return[2]}}))}))}));var W=function(){B.selectedShippingOption=null;B.isSelectedShippingAboveDeminimis=false;B.isSelectedShippingGuarantee=false;B.selectedShippingOptionExpectedDate="";B.selectedShippingOptionTransitTime="";B.shipping=0};var G=e("d",(function(){if(B.step==="customer-info"){B.step="shipping"}else if(B.step==="shipping"){B.step="payment"}else if(B.step==="payment"){B.step="finish"}}));var H=e("e",(function(){if(B.step==="payment"){B.step="shipping"}else if(B.step==="shipping"){B.step="customer-info";W()}}))}}}));
|