@zonos/elements 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{cart-d4b52ae8.js → cart-55512e32.js} +11 -1
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/zonos-address_2.cjs.entry.js +1 -1
- package/dist/cjs/zonos-cart-items_10.cjs.entry.js +1 -1
- package/dist/cjs/zonos-checkout.cjs.entry.js +5 -1
- package/dist/cjs/zonos-controller.cjs.entry.js +48 -2
- package/dist/cjs/zonos-payment.cjs.entry.js +1 -1
- package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +1 -1
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +4 -0
- package/dist/collection/components/common/zonos-shipping-rich-radio/zonos-shipping-rich-radio.css +1 -0
- package/dist/collection/components/main/zonos-controller.js +46 -0
- package/dist/collection/components/store/checkout/stripe.js +11 -1
- package/dist/collection/components/utils/checkout/initCheckout.js +1 -1
- package/dist/collection/environment.js +22 -13
- package/dist/collection/scripts/zonos.js +84 -3
- package/dist/collection/utils/generateVercelDeployUrl.js +3 -2
- package/dist/components/cart.js +11 -1
- package/dist/components/zonos-checkout.js +4 -0
- package/dist/components/zonos-controller.js +47 -1
- package/dist/components/zonos-shipping-rich-radio2.js +1 -1
- package/dist/esm/{cart-e1b93711.js → cart-17650017.js} +11 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/zonos-address_2.entry.js +1 -1
- package/dist/esm/zonos-cart-items_10.entry.js +1 -1
- package/dist/esm/zonos-checkout.entry.js +5 -1
- package/dist/esm/zonos-controller.entry.js +48 -2
- package/dist/esm/zonos-payment.entry.js +1 -1
- package/dist/esm/zonos-shipping-rich-radio.entry.js +1 -1
- package/dist/esm-es5/cart-17650017.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/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
- package/dist/scripts/loadZonos.js +86 -5
- package/dist/scripts/zonos.js +86 -5
- package/dist/types/components/main/zonos-controller.d.ts +1 -0
- package/dist/types/components/store/checkout/stripe.d.ts +2 -1
- package/dist/types/components/utils/changeDeepProperty.d.ts +1 -1
- package/dist/types/components/utils/changeDeepPropertyAtIndex.d.ts +1 -1
- package/dist/types/components/utils/checkout/initCheckout.d.ts +1 -1
- package/dist/types/environment.d.ts +6 -1
- package/dist/types/scripts/zonos.d.ts +3 -0
- package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/p-0ed3bb9f.system.entry.js +1 -0
- package/dist/zonos-elements/{p-a3641931.system.entry.js → p-224125da.system.entry.js} +1 -1
- package/dist/zonos-elements/p-3a56c240.entry.js +1 -0
- package/dist/zonos-elements/p-8378d94e.js +1 -0
- package/dist/zonos-elements/{p-05256415.system.entry.js → p-84b00605.system.entry.js} +1 -1
- package/dist/zonos-elements/p-8b415737.system.entry.js +1 -0
- package/dist/zonos-elements/{p-40778e43.entry.js → p-9202375f.entry.js} +1 -1
- package/dist/zonos-elements/p-a1fa50fb.entry.js +1 -0
- package/dist/zonos-elements/{p-60821b2a.entry.js → p-bc2c42f5.entry.js} +1 -1
- package/dist/zonos-elements/{p-365970ff.entry.js → p-cd71e41e.entry.js} +1 -1
- package/dist/zonos-elements/{p-81c699f7.system.entry.js → p-cf97cc68.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-40083e93.system.entry.js → p-d6b8563b.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-96a3c767.entry.js → p-e5908de2.entry.js} +1 -1
- package/dist/zonos-elements/p-f6add79c.system.js +1 -0
- package/dist/zonos-elements/p-f8491335.system.js +1 -1
- package/dist/zonos-elements/{p-53649e16.system.js → p-f95ac9ec.system.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +3 -3
- package/dist/esm-es5/cart-e1b93711.js +0 -1
- package/dist/zonos-elements/p-25db3885.js +0 -1
- package/dist/zonos-elements/p-34a49bce.entry.js +0 -1
- package/dist/zonos-elements/p-5d7ffddb.entry.js +0 -1
- package/dist/zonos-elements/p-8db8cc05.system.js +0 -1
- package/dist/zonos-elements/p-914ce305.system.entry.js +0 -1
- package/dist/zonos-elements/p-de9d8a4f.system.entry.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(o,e,t,n){function s(o){return o instanceof t?o:new t((function(e){e(o)}))}return new(t||(t=Promise))((function(t,r){function i(o){try{a(n.next(o))}catch(o){r(o)}}function c(o){try{a(n["throw"](o))}catch(o){r(o)}}function a(o){o.done?t(o.value):s(o.value).then(i,c)}a((n=n.apply(o,e||[])).next())}))};var __generator=this&&this.__generator||function(o,e){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,s,r,i;return i={next:c(0),throw:c(1),return:c(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(o){return function(e){return a([o,e])}}function a(c){if(n)throw new TypeError("Generator is already executing.");while(i&&(i=0,c[0]&&(t=0)),t)try{if(n=1,s&&(r=c[0]&2?s["return"]:c[0]?s["throw"]||((r=s["return"])&&r.call(s),0):s.next)&&!(r=r.call(s,c[1])).done)return r;if(s=0,r)c=[c[0]&2,r.value];switch(c[0]){case 0:case 1:r=c;break;case 4:t.label++;return{value:c[1],done:false};case 5:t.label++;s=c[1];c=[0];continue;case 7:c=t.ops.pop();t.trys.pop();continue;default:if(!(r=t.trys,r=r.length>0&&r[r.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!r||c[1]>r[0]&&c[1]<r[3])){t.label=c[1];break}if(c[0]===6&&t.label<r[1]){t.label=r[1];r=c;break}if(r&&t.label<r[2]){t.label=r[2];t.ops.push(c);break}if(r[2])t.ops.pop();t.trys.pop();continue}c=e.call(o,t)}catch(o){c=[6,o];s=0}finally{n=r=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}};import{r as registerInstance,h,F as Fragment,H as Host}from"./index-d1aa9293.js";import{k as initStripeElements,c as cartStore,h as cartStoreUpdateItems,g as cartStoreReset,s as stripeStore,l as stripeStoreInitCheckoutSession,j as cartStoreUpdateToErrorState,m as stripeStorePrefetchLandedCost,d as cartStoreNextStep,n as stripeStoreConfirmPayment,o as stripeStoreReset,e as cartStorePreviousStep}from"./cart-e1b93711.js";import{a as localizationStore,l as log,t as translate}from"./localization-f3828793.js";import{z as zonosStore,m as mergeConfig}from"./zonosStore-05a62104.js";import{s as submitGtag,i as isCheckoutMobile}from"./submitGtag-a901ece5.js";import{c as classes}from"./classes-0d95c529.js";import{g as getBorderRadius}from"./getBorderRadius-45764ad7.js";import{i as isDarkColor}from"./isDarkColor-6fbb9b14.js";var LeftArrow='<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 MessageIcon='<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 RemoveIcon='<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 zonosCheckoutCss=".sc-zonos-checkout-h{font-family:Inter;display:block}.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 ZonosCheckout=function(){function o(o){var e=this;registerInstance(this,o);this.applyStripeTheme=function(){return __awaiter(e,void 0,void 0,(function(){var o,e,t,n;return __generator(this,(function(s){switch(s.label){case 0:n=((o=this.appearanceSettingsOverride)===null||o===void 0?void 0:o.theme)||zonosStore.appearance.theme;return[4,initStripeElements({overrideBorderRaidus:(e=this.appearanceSettingsOverride)===null||e===void 0?void 0:e.style,overridePrimaryColor:(t=this.appearanceSettingsOverride)===null||t===void 0?void 0:t.colorPrimary,overrideTheme:this.isMobile?n:undefined})];case 1:s.sent();return[2]}}))}))};this.isShippableCountry=function(o){if(o===void 0){o=true}if(!localizationStore.localizationLoaded){return false}if(!localizationStore.isShippableCountry){if(o){log("Checkout: not shippable country")}return false}return true};this.getCurrentLocalePageEnum=function(){switch(cartStore.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 e;return __generator(this,(function(t){e=o.detail;void cartStoreUpdateItems(e);return[2]}))}))};o.prototype.closeDialogHandler=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){submitGtag("zonos-checkout-close");this.open=this.forceDialogOpen||false;if(!this.preview&&cartStore.step==="finish"){cartStoreReset()}cartStore.step="customer-info";return[2]}))}))};o.prototype.buildCartAndInit=function(){return __awaiter(this,void 0,void 0,(function(){var o,e;return __generator(this,(function(t){switch(t.label){case 0:if(!zonosStore.checkoutSettings.buildCartDetail)return[3,3];log("build cart detail");return[4,zonosStore.checkoutSettings.buildCartDetail()];case 1:o=t.sent();return[4,cartStoreUpdateItems(o)];case 2:t.sent();t.label=3;case 3:if(!!stripeStore.clientSecret)return[3,5];return[4,stripeStoreInitCheckoutSession()];case 4:e=t.sent();log("stripeStoreInitCheckoutSession: ".concat(e));if(!e){return[2,false]}t.label=5;case 5:return[4,this.applyStripeTheme()];case 6:t.sent();return[2,true]}}))}))};o.prototype.attachCheckout=function(){var o=this;var e=zonosStore.checkoutSettings.placeOrderButtonSelector;if(!e){return}var t=document.querySelectorAll(e);t.forEach((function(e){var t=e.getAttribute("data-zonos-checkout-attached");if(t){return}e.addEventListener("click",(function(e){return __awaiter(o,void 0,void 0,(function(){var o,t;return __generator(this,(function(n){switch(n.label){case 0:if(!this.isShippableCountry()){return[2]}e.preventDefault();e.stopPropagation();log("zonos checkout button clicked");this.open=true;n.label=1;case 1:n.trys.push([1,3,,4]);return[4,this.buildCartAndInit()];case 2:o=n.sent();if(!o){throw new Error("Error building cart")}submitGtag("zonos-checkout-start");return[3,4];case 3:t=n.sent();cartStoreUpdateToErrorState({messages:[translate("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:translate("Error creating Checkout")});return[3,4];case 4:return[2]}}))}))}));e.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,e;var t=this;return __generator(this,(function(n){stripeStore.stripe=window.Zonos.stripe;this.stripe=window.Zonos.stripe;o=setInterval((function(){var e=window.Zonos.internationalHideSelector;if(!e){clearInterval(o);return}var n=t.isShippableCountry(false);var s=document.querySelectorAll(e);if(!n){s===null||s===void 0?void 0:s.forEach((function(o){var e=o;var t=e.getAttribute("data-zonos-checkout-original-display")||getComputedStyle(e).display;e.style.display=t||"initial"}));return}s===null||s===void 0?void 0:s.forEach((function(o){var e=o;var t=e.style.display;e.setAttribute("data-zonos-checkout-original-display",t);e.style.display="none"}))}),100);e=setInterval((function(){stripeStore.stripe=window.Zonos.stripe;t.stripe=window.Zonos.stripe;if(!t.stripe){log("waiting for stripe to be loaded");return}if(t.storybookPaymentStatusOverride){clearInterval(e);return}log("init checkout");if(t.preview||t.forceDialogOpen){void t.buildCartAndInit()}else{t.attachCheckout();setInterval((function(){t.attachCheckout()}),50)}clearInterval(e)}),50);setTimeout((function(){clearInterval(e)}),1e4);return[2]}))}))};o.prototype.setToFinishStep=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){cartStore.step="finish";this.storybookPaymentStatusOverride=o;return[2]}))}))};o.prototype.handleCustomerInfoContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o;var e=this;return __generator(this,(function(t){switch(t.label){case 0:this.submitLoading=true;return[4,stripeStorePrefetchLandedCost()];case 1:t.sent();o=setInterval((function(){if(cartStore.landedCostData||!stripeStore.isFetchingLandedCost){if(cartStore.landedCostData){cartStoreNextStep()}e.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(e){this.submitLoading=true;setTimeout((function(){cartStoreNextStep();o.submitLoading=false}),500);return[2]}))}))};o.prototype.handleCheckoutPaymentContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o;return __generator(this,(function(e){switch(e.label){case 0:this.paymentError=false;this.submitLoading=true;e.label=1;case 1:e.trys.push([1,3,,4]);return[4,stripeStoreConfirmPayment()];case 2:e.sent();cartStoreNextStep();return[3,4];case 3:o=e.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,e;return __generator(this,(function(t){switch(t.label){case 0:stripeStoreReset();if(!this.preview)return[3,2];cartStore.step="customer-info";return[4,this.init()];case 1:t.sent();return[2];case 2:cartStoreReset();o=window.location.href;e=o.split("?")[0];window.history.replaceState({},document.title,e);this.open=false;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(!(cartStore.step==="customer-info"))return[3,2];return[4,this.closeDialogHandler()];case 1:o.sent();return[2];case 2:cartStorePreviousStep();return[2]}}))}))};o.prototype.handleWindowResize=function(){this.isMobile=isCheckoutMobile(this.mobile);void this.applyStripeTheme();log("mobile: ".concat(this.isMobile))};o.prototype.handleMobileChange=function(){this.isMobile=isCheckoutMobile(this.mobile);void this.applyStripeTheme();log("mobile: ".concat(this.isMobile))};o.prototype.componentWillLoad=function(){void this.init();this.isMobile=isCheckoutMobile(this.mobile);log("mobile: ".concat(this.isMobile))};o.prototype.disconnectedCallback=function(){stripeStoreReset();cartStoreReset()};o.prototype.render=function(){var o=this;var e;var t=cartStore.step!=="finish"&&cartStore.step!=="error"&&!stripeStore.stripeElements||stripeStore.isFetchingSession;var n=mergeConfig(zonosStore.appearance,this.appearanceSettingsOverride),s=n.colorPrimary,r=n.colorSecondary,i=n.logoUrl,c=n.style;var a=zonosStore.appearance.zonosAttribution==="ENABLED";var u=zonosStore.appearance.theme;var l=s&&isDarkColor(s)?"DARK":"LIGHT";var d=this.isMobile?u:l;var p=!this.isMobile?r:undefined;var f=localizationStore.customMessages;var m=((e=f.find((function(o){return o.pageName==="checkout_default"})))===null||e===void 0?void 0:e.message)||"Know about duties and taxes before you buy. Shop with confidence!";var z=this.getCurrentLocalePageEnum();var g=f.filter((function(o){return o.pageName===z}));var k=function(){return h("div",{class:"zonos--logo"},i&&h("img",{alt:"".concat(zonosStore.organizationName," logo"),src:i,width:100}))};var v=function(){return h("zonos-v-stack",null,k(),g.map((function(o){return h("zonos-custom-message",{icon:MessageIcon,message:o.message})})),h("div",null,h("zonos-button",{class:"zonos--back-button",icon:h("zonos-icon",{content:LeftArrow}),noBackground:true,noPaddingLeft:true,noPaddingRight:true,onClick:function(){return o.handleBackClick()},theme:d},translate("Back"))))};var b=function(){return a&&h("div",{class:"zonos--footer","data-theme":u},h("zonos-text",{type:"hintText"},translate("Powered by")),h("zonos-logo",{theme:u,width:"100px"}))};var y=function(){var e;var t=o.isMobile?"primary":undefined;var n=(e=o.zonosReviewRef)===null||e===void 0?void 0:e.scrollHeight;return h("div",{class:"zonos--content",style:{"--border-radius":getBorderRadius(c)}},cartStore.step!=="finish"&&cartStore.step!=="error"&&h(Fragment,null,h("div",{class:"zonos--left","data-theme":d,style:{"--primary-color":!o.isMobile?s:""}},!o.isMobile&&v(),cartStore.step==="customer-info"&&h("zonos-customer-info",{continueLoading:o.submitLoading,defaultAddress:o.defaultAddress,onContinueClicked:function(){return o.handleCustomerInfoContinue()},submitBtnColor:p,submitBtnType:t}),cartStore.step==="shipping"&&h("zonos-shipping",{continueLoading:o.submitLoading,onContinueClicked:function(){return o.handleShippingContinue()},submitBtnColor:p,submitBtnType:t}),cartStore.step==="payment"&&h("zonos-checkout-payment",{continueLoading:o.submitLoading,onContinueClicked:function(){return o.handleCheckoutPaymentContinue()},paymentError:o.paymentError,submitBtnColor:p,submitBtnType:t})),h("div",{class:"zonos--right","data-theme":u},o.isMobile&&v(),!o.isMobile&&h("zonos-button",{class:"zonos--close-button",icon:h("zonos-icon",{content:RemoveIcon}),noBackground:true,onClick:function(){return o.closeDialogHandler()}}),h("div",{class:"flex--wrapper"},h("div",{class:"zonos--wrapper"},h("zonos-collapse",{collapseSize:n,collapsed:o.collapseReviewMobile&&o.isMobile},h("zonos-review",{collapsed:o.collapseReviewMobile,mobile:o.isMobile,onClick:function(){if(!o.isMobile){return}o.collapseReviewMobile=!o.collapseReviewMobile},ref:function(e){return o.zonosReviewRef=e}}),h("zonos-cart-items",null))),h("zonos-v-stack",{spacing:16},h("zonos-cart-subtotal",null),h("zonos-custom-message",{class:"zonos--checkout-default-message",icon:MessageIcon,message:m}))),!o.isMobile&&b()),o.isMobile&&b()),(cartStore.step==="finish"||cartStore.step==="error")&&h("div",{class:"zonos--done","data-theme":u},h("div",{class:"zonos--header"},k(),h("zonos-button",{class:"zonos--close-button",icon:h("zonos-icon",{content:RemoveIcon}),noBackground:true,onClick:function(){return o.handleFinishClick()},theme:u})),h("zonos-checkout-finish",{borderRadius:c,onCloseClick:function(){return o.handleFinishClick()},overrideNotification:cartStore.step==="error"&&!!cartStore.error?Object.assign(Object.assign({},cartStore.error),{type:"error"}):undefined,storybookForceStatus:o.storybookPaymentStatusOverride})))};return h(Host,{class:classes(["zonos--checkout zonos--elements",a&&"has-footer",this.preview&&"preview",this.isMobile&&"mobile"])},this.preview?y():h("zonos-dialog",{borderStyle:c,"data-theme":u,height:"980px",isLoading:t,mobile:this.isMobile,noBodyPadding:true,noBorder:true,noClickOutside:true,noCloseButton:true,onCloseDialog:function(){return o.closeDialogHandler()},open:this.open,width:"1200px"},y()))};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}();ZonosCheckout.style=zonosCheckoutCss;export{ZonosCheckout as zonos_checkout};
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(o,e,t,n){function s(o){return o instanceof t?o:new t((function(e){e(o)}))}return new(t||(t=Promise))((function(t,r){function i(o){try{a(n.next(o))}catch(o){r(o)}}function c(o){try{a(n["throw"](o))}catch(o){r(o)}}function a(o){o.done?t(o.value):s(o.value).then(i,c)}a((n=n.apply(o,e||[])).next())}))};var __generator=this&&this.__generator||function(o,e){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,s,r,i;return i={next:c(0),throw:c(1),return:c(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(o){return function(e){return a([o,e])}}function a(c){if(n)throw new TypeError("Generator is already executing.");while(i&&(i=0,c[0]&&(t=0)),t)try{if(n=1,s&&(r=c[0]&2?s["return"]:c[0]?s["throw"]||((r=s["return"])&&r.call(s),0):s.next)&&!(r=r.call(s,c[1])).done)return r;if(s=0,r)c=[c[0]&2,r.value];switch(c[0]){case 0:case 1:r=c;break;case 4:t.label++;return{value:c[1],done:false};case 5:t.label++;s=c[1];c=[0];continue;case 7:c=t.ops.pop();t.trys.pop();continue;default:if(!(r=t.trys,r=r.length>0&&r[r.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!r||c[1]>r[0]&&c[1]<r[3])){t.label=c[1];break}if(c[0]===6&&t.label<r[1]){t.label=r[1];r=c;break}if(r&&t.label<r[2]){t.label=r[2];t.ops.push(c);break}if(r[2])t.ops.pop();t.trys.pop();continue}c=e.call(o,t)}catch(o){c=[6,o];s=0}finally{n=r=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}};import{r as registerInstance,h,F as Fragment,H as Host}from"./index-d1aa9293.js";import{k as initStripeElements,c as cartStore,h as cartStoreUpdateItems,g as cartStoreReset,s as stripeStore,l as stripeStoreInitCheckoutSession,j as cartStoreUpdateToErrorState,m as stripeStorePrefetchLandedCost,d as cartStoreNextStep,n as stripeStoreConfirmPayment,o as stripeStoreReset,e as cartStorePreviousStep}from"./cart-17650017.js";import{a as localizationStore,l as log,t as translate}from"./localization-f3828793.js";import{z as zonosStore,m as mergeConfig}from"./zonosStore-05a62104.js";import{s as submitGtag,i as isCheckoutMobile}from"./submitGtag-a901ece5.js";import{c as classes}from"./classes-0d95c529.js";import{g as getBorderRadius}from"./getBorderRadius-45764ad7.js";import{i as isDarkColor}from"./isDarkColor-6fbb9b14.js";var LeftArrow='<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 MessageIcon='<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 RemoveIcon='<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 zonosCheckoutCss=".sc-zonos-checkout-h{font-family:Inter;display:block}.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 ZonosCheckout=function(){function o(o){var e=this;registerInstance(this,o);this.applyStripeTheme=function(){return __awaiter(e,void 0,void 0,(function(){var o,e,t,n;return __generator(this,(function(s){switch(s.label){case 0:n=((o=this.appearanceSettingsOverride)===null||o===void 0?void 0:o.theme)||zonosStore.appearance.theme;return[4,initStripeElements({overrideBorderRaidus:(e=this.appearanceSettingsOverride)===null||e===void 0?void 0:e.style,overridePrimaryColor:(t=this.appearanceSettingsOverride)===null||t===void 0?void 0:t.colorPrimary,overrideTheme:this.isMobile?n:undefined})];case 1:s.sent();return[2]}}))}))};this.isShippableCountry=function(o){if(o===void 0){o=true}if(!localizationStore.localizationLoaded){return false}if(!localizationStore.isShippableCountry){if(o){log("Checkout: not shippable country")}return false}return true};this.getCurrentLocalePageEnum=function(){switch(cartStore.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 e;return __generator(this,(function(t){e=o.detail;void cartStoreUpdateItems(e);return[2]}))}))};o.prototype.closeDialogHandler=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){submitGtag("zonos-checkout-close");this.open=this.forceDialogOpen||false;if(!this.preview&&cartStore.step==="finish"){cartStoreReset()}cartStore.step="customer-info";return[2]}))}))};o.prototype.buildCartAndInit=function(){return __awaiter(this,void 0,void 0,(function(){var o,e;return __generator(this,(function(t){switch(t.label){case 0:if(!zonosStore.checkoutSettings.buildCartDetail)return[3,3];log("build cart detail");return[4,zonosStore.checkoutSettings.buildCartDetail()];case 1:o=t.sent();return[4,cartStoreUpdateItems(o)];case 2:t.sent();t.label=3;case 3:if(!!stripeStore.clientSecret)return[3,5];return[4,stripeStoreInitCheckoutSession()];case 4:e=t.sent();log("stripeStoreInitCheckoutSession: ".concat(e));if(!e){return[2,false]}t.label=5;case 5:return[4,this.applyStripeTheme()];case 6:t.sent();return[2,true]}}))}))};o.prototype.attachCheckout=function(){var o=this;var e=zonosStore.checkoutSettings.placeOrderButtonSelector;if(!e){return}var t=document.querySelectorAll(e);t.forEach((function(e){var t=e.getAttribute("data-zonos-checkout-attached");if(t){return}e.addEventListener("click",(function(e){return __awaiter(o,void 0,void 0,(function(){var o,t;return __generator(this,(function(n){switch(n.label){case 0:if(!this.isShippableCountry()){return[2]}e.preventDefault();e.stopPropagation();log("zonos checkout button clicked");stripeStore.isFetchingSession=true;this.open=true;n.label=1;case 1:n.trys.push([1,3,,4]);return[4,this.buildCartAndInit()];case 2:o=n.sent();if(!o){throw new Error("Error building cart")}submitGtag("zonos-checkout-start");return[3,4];case 3:t=n.sent();stripeStore.isFetchingSession=false;cartStoreUpdateToErrorState({messages:[translate("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:translate("Error creating Checkout")});return[3,4];case 4:return[2]}}))}))}));e.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,e;var t=this;return __generator(this,(function(n){stripeStore.stripe=window.Zonos.stripe;this.stripe=window.Zonos.stripe;o=setInterval((function(){var e=window.Zonos.internationalHideSelector;if(!e){clearInterval(o);return}var n=t.isShippableCountry(false);var s=document.querySelectorAll(e);if(!n){s===null||s===void 0?void 0:s.forEach((function(o){var e=o;var t=e.getAttribute("data-zonos-checkout-original-display")||getComputedStyle(e).display;e.style.display=t||"initial"}));return}s===null||s===void 0?void 0:s.forEach((function(o){var e=o;var t=e.style.display;e.setAttribute("data-zonos-checkout-original-display",t);e.style.display="none"}))}),100);e=setInterval((function(){stripeStore.stripe=window.Zonos.stripe;t.stripe=window.Zonos.stripe;if(!t.stripe){log("waiting for stripe to be loaded");return}if(t.storybookPaymentStatusOverride){clearInterval(e);return}log("init checkout");if(t.preview||t.forceDialogOpen){void t.buildCartAndInit()}else{t.attachCheckout();setInterval((function(){t.attachCheckout()}),50)}clearInterval(e)}),50);setTimeout((function(){clearInterval(e)}),1e4);return[2]}))}))};o.prototype.setToFinishStep=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){cartStore.step="finish";this.storybookPaymentStatusOverride=o;return[2]}))}))};o.prototype.handleCustomerInfoContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o;var e=this;return __generator(this,(function(t){switch(t.label){case 0:this.submitLoading=true;return[4,stripeStorePrefetchLandedCost()];case 1:t.sent();o=setInterval((function(){if(cartStore.landedCostData||!stripeStore.isFetchingLandedCost){if(cartStore.landedCostData){cartStoreNextStep()}e.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(e){this.submitLoading=true;setTimeout((function(){cartStoreNextStep();o.submitLoading=false}),500);return[2]}))}))};o.prototype.handleCheckoutPaymentContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o;return __generator(this,(function(e){switch(e.label){case 0:this.paymentError=false;this.submitLoading=true;e.label=1;case 1:e.trys.push([1,3,,4]);return[4,stripeStoreConfirmPayment()];case 2:e.sent();cartStoreNextStep();return[3,4];case 3:o=e.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,e;return __generator(this,(function(t){switch(t.label){case 0:stripeStoreReset();if(!this.preview)return[3,2];cartStore.step="customer-info";return[4,this.init()];case 1:t.sent();return[2];case 2:cartStoreReset();o=window.location.href;e=o.split("?")[0];window.history.replaceState({},document.title,e);this.open=false;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(!(cartStore.step==="customer-info"))return[3,2];return[4,this.closeDialogHandler()];case 1:o.sent();return[2];case 2:cartStorePreviousStep();return[2]}}))}))};o.prototype.handleWindowResize=function(){this.isMobile=isCheckoutMobile(this.mobile);void this.applyStripeTheme();log("mobile: ".concat(this.isMobile))};o.prototype.handleMobileChange=function(){this.isMobile=isCheckoutMobile(this.mobile);void this.applyStripeTheme();log("mobile: ".concat(this.isMobile))};o.prototype.componentWillLoad=function(){void this.init();this.isMobile=isCheckoutMobile(this.mobile);log("mobile: ".concat(this.isMobile))};o.prototype.disconnectedCallback=function(){stripeStoreReset();cartStoreReset()};o.prototype.render=function(){var o=this;var e;var t=cartStore.step!=="finish"&&cartStore.step!=="error"&&!stripeStore.stripeElements||stripeStore.isFetchingSession;var n=mergeConfig(zonosStore.appearance,this.appearanceSettingsOverride),s=n.colorPrimary,r=n.colorSecondary,i=n.logoUrl,c=n.style;var a=zonosStore.appearance.zonosAttribution==="ENABLED";var u=zonosStore.appearance.theme;var l=s&&isDarkColor(s)?"DARK":"LIGHT";var d=this.isMobile?u:l;var p=!this.isMobile?r:undefined;var f=localizationStore.customMessages;var m=((e=f.find((function(o){return o.pageName==="checkout_default"})))===null||e===void 0?void 0:e.message)||"Know about duties and taxes before you buy. Shop with confidence!";var z=this.getCurrentLocalePageEnum();var g=f.filter((function(o){return o.pageName===z}));var k=function(){return h("div",{class:"zonos--logo"},i&&h("img",{alt:"".concat(zonosStore.organizationName," logo"),src:i,width:100}))};var v=function(){return h("zonos-v-stack",null,k(),g.map((function(o){return h("zonos-custom-message",{icon:MessageIcon,message:o.message})})),h("div",null,h("zonos-button",{class:"zonos--back-button",icon:h("zonos-icon",{content:LeftArrow}),noBackground:true,noPaddingLeft:true,noPaddingRight:true,onClick:function(){return o.handleBackClick()},theme:d},translate("Back"))))};var b=function(){return a&&h("div",{class:"zonos--footer","data-theme":u},h("zonos-text",{type:"hintText"},translate("Powered by")),h("zonos-logo",{theme:u,width:"100px"}))};var y=function(){var e;var t=o.isMobile?"primary":undefined;var n=(e=o.zonosReviewRef)===null||e===void 0?void 0:e.scrollHeight;return h("div",{class:"zonos--content",style:{"--border-radius":getBorderRadius(c)}},cartStore.step!=="finish"&&cartStore.step!=="error"&&h(Fragment,null,h("div",{class:"zonos--left","data-theme":d,style:{"--primary-color":!o.isMobile?s:""}},!o.isMobile&&v(),cartStore.step==="customer-info"&&h("zonos-customer-info",{continueLoading:o.submitLoading,defaultAddress:o.defaultAddress,onContinueClicked:function(){return o.handleCustomerInfoContinue()},submitBtnColor:p,submitBtnType:t}),cartStore.step==="shipping"&&h("zonos-shipping",{continueLoading:o.submitLoading,onContinueClicked:function(){return o.handleShippingContinue()},submitBtnColor:p,submitBtnType:t}),cartStore.step==="payment"&&h("zonos-checkout-payment",{continueLoading:o.submitLoading,onContinueClicked:function(){return o.handleCheckoutPaymentContinue()},paymentError:o.paymentError,submitBtnColor:p,submitBtnType:t})),h("div",{class:"zonos--right","data-theme":u},o.isMobile&&v(),!o.isMobile&&h("zonos-button",{class:"zonos--close-button",icon:h("zonos-icon",{content:RemoveIcon}),noBackground:true,onClick:function(){return o.closeDialogHandler()}}),h("div",{class:"flex--wrapper"},h("div",{class:"zonos--wrapper"},h("zonos-collapse",{collapseSize:n,collapsed:o.collapseReviewMobile&&o.isMobile},h("zonos-review",{collapsed:o.collapseReviewMobile,mobile:o.isMobile,onClick:function(){if(!o.isMobile){return}o.collapseReviewMobile=!o.collapseReviewMobile},ref:function(e){return o.zonosReviewRef=e}}),h("zonos-cart-items",null))),h("zonos-v-stack",{spacing:16},h("zonos-cart-subtotal",null),h("zonos-custom-message",{class:"zonos--checkout-default-message",icon:MessageIcon,message:m}))),!o.isMobile&&b()),o.isMobile&&b()),(cartStore.step==="finish"||cartStore.step==="error")&&h("div",{class:"zonos--done","data-theme":u},h("div",{class:"zonos--header"},k(),h("zonos-button",{class:"zonos--close-button",icon:h("zonos-icon",{content:RemoveIcon}),noBackground:true,onClick:function(){return o.handleFinishClick()},theme:u})),h("zonos-checkout-finish",{borderRadius:c,onCloseClick:function(){return o.handleFinishClick()},overrideNotification:cartStore.step==="error"&&!!cartStore.error?Object.assign(Object.assign({},cartStore.error),{type:"error"}):undefined,storybookForceStatus:o.storybookPaymentStatusOverride})))};return h(Host,{class:classes(["zonos--checkout zonos--elements",a&&"has-footer",this.preview&&"preview",this.isMobile&&"mobile"])},this.preview?y():h("zonos-dialog",{borderStyle:c,"data-theme":u,height:"980px",isLoading:t,mobile:this.isMobile,noBodyPadding:true,noBorder:true,noClickOutside:true,noCloseButton:true,onCloseDialog:function(){return o.closeDialogHandler()},open:this.open,width:"1200px"},y()))};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}();ZonosCheckout.style=zonosCheckoutCss;export{ZonosCheckout as zonos_checkout};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(t,o,
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(t,e,o,n){function r(t){return t instanceof o?t:new o((function(e){e(t)}))}return new(o||(o=Promise))((function(o,i){function s(t){try{l(n.next(t))}catch(t){i(t)}}function a(t){try{l(n["throw"](t))}catch(t){i(t)}}function l(t){t.done?o(t.value):r(t.value).then(s,a)}l((n=n.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,r,i,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(t){return function(e){return l([t,e])}}function l(a){if(n)throw new TypeError("Generator is already executing.");while(s&&(s=0,a[0]&&(o=0)),o)try{if(n=1,r&&(i=a[0]&2?r["return"]:a[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;if(r=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:o.label++;return{value:a[1],done:false};case 5:o.label++;r=a[1];a=[0];continue;case 7:a=o.ops.pop();o.trys.pop();continue;default:if(!(i=o.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){o=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(a[0]===6&&o.label<i[1]){o.label=i[1];i=a;break}if(i&&o.label<i[2]){o.label=i[2];o.ops.push(a);break}if(i[2])o.ops.pop();o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t];r=0}finally{n=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{r as registerInstance,c as createEvent,h,H as Host}from"./index-d1aa9293.js";import{s as stripeStore}from"./cart-17650017.js";import{h as handleFetch,b as logError,i as isValidSelector,l as log,c as initLocalizationStore,d as localizationStoreUpdateSelectedCountryCode}from"./localization-f3828793.js";import{z as zonosStore,d as zonosStoreInitSetting}from"./zonosStore-05a62104.js";import"./isDarkColor-6fbb9b14.js";import"./getBorderRadius-45764ad7.js";var getZonosSetting=function(){return __awaiter(void 0,void 0,void 0,(function(){var t,e,o,n;return __generator(this,(function(r){switch(r.label){case 0:t="".concat("https://v1.route.js.zonos.com","/api/zonos-setting");return[4,handleFetch(t)];case 1:e=r.sent(),o=e.errors,n=e.json;if(o.length){logError("Error occurs when getting zonos settings. If this is not an unauthorized error, it will use user setting or default setting");return[2,{errors:o,json:null}]}return[2,{errors:[],json:n}]}}))}))};var injectCheckoutElement=function(){var t=document.querySelector("zonos-checkout");if(!t){var e=document.createElement("zonos-checkout");document.body.appendChild(e)}};var initCheckout=function(t){if(!t.placeOrderButtonSelector){return}if(!isValidSelector(t.placeOrderButtonSelector)){logError('Selector checkoutButtonAnchor "'.concat(t.placeOrderButtonSelector,'" is not a valid selector'));return}injectCheckoutElement()};var injectHelloComponent=function(t){var e=document.querySelector("zonos-hello");if(!e&&t){var o=document.createElement("zonos-hello");t.appendChild(o)}};var initHello=function(t){return __awaiter(void 0,void 0,void 0,(function(){var e,o;return __generator(this,(function(n){e=t.anchorElementSelector;if(!e||!isValidSelector(e)){logError('Selector anchorElementSelector "'.concat(t.anchorElementSelector,'" is not a valid selector.'));return[2]}o=document.querySelector(e);log("Hello init complete");injectHelloComponent(o);return[2]}))}))};var zonosControllerCss=":host{font-family:Inter;display:block}: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 ZonosController=function(){function t(t){registerInstance(this,t);this.stripeInitEvent=createEvent(this,"stripeInitEvent",7);this.disablePlaceOrderButtons=function(t){var e=t.disable;var o=zonosStore.checkoutSettings.placeOrderButtonSelector;if(!o){return}var n=function(t){var e=t.target;if(e.getAttribute("disabled")){t.preventDefault();t.stopPropagation()}};var r=document.querySelectorAll(o);r.forEach((function(t){if(e){t.setAttribute("disabled","true");t.addEventListener("click",n)}else{t.removeAttribute("disabled");t.removeEventListener("click",n)}}));if(e){setTimeout((function(){r.forEach((function(t){t.removeAttribute("disabled");t.removeEventListener("click",n)}))}),5e3)}};this.config=undefined;this.zonosApiKey=undefined}t.prototype.initCheckoutElement=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){if(!t){log("Stripe is not loaded yet - cannot init checkout element","warn");return[2]}stripeStore.stripe=t;void initCheckout(zonosStore.checkoutSettings);log("init checkout element");this.disablePlaceOrderButtons({disable:false});return[2]}))}))};t.prototype.initZonosNotification=function(){var t=document.querySelector("zonos-notification");if(t){return}var e=document.createElement("zonos-notification");document.body.appendChild(e)};t.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(e){zonosStore.zonosApiKey=this.zonosApiKey;(function(){return __awaiter(t,void 0,void 0,(function(){var t,e,o,n,r,i;return __generator(this,(function(s){switch(s.label){case 0:return[4,getZonosSetting()];case 1:o=s.sent(),n=o.errors,r=o.json;if(((t=n[0])===null||t===void 0?void 0:t.type.toString())==="403"){log("Failed to load zonos settings. This domain may not have access","warn");return[2]}this.disablePlaceOrderButtons({disable:true});this.initZonosNotification();zonosStoreInitSetting({overrideSettings:this.config,zonosSettings:r});if(zonosStore.helloSettings){void initHello(zonosStore.helloSettings)}return[4,initLocalizationStore()];case 2:s.sent();i=((e=r===null||r===void 0?void 0:r.checkoutSettings)===null||e===void 0?void 0:e.externalServiceTokens.find((function(t){return t.type==="STRIPE_PUBLISHABLE_TOKEN"})))||null;if(!i||!this.stripeInitEvent){log("Checkout failed to load -- missing publishable key","warn");return[2]}if(zonosStore.checkoutSettings.subscriptionStatus==="INACTIVE"){log('=== Checkout subscription is "INACTIVE" - Cancel initializing for Checkout ===',"warn");log("zonos controller loaded");return[2]}if(zonosStore.checkoutSettings.visibilityStatus==="DISABLED"){log("=== Checkout is disabled by store owner ===","warn");log("zonos controller loaded");return[2]}this.stripeInitEvent.emit({publishableKey:i.token});log("zonos controller loaded");return[2]}}))}))})();return[2]}))}))};t.prototype.showNotification=function(t){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(o){e=document.querySelector("zonos-notification");if(!e){log("Failed to show notification - zonos-notification not found","warn");return[2]}void e.showNotification(t);return[2]}))}))};t.prototype.overrideConfig=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){zonosStoreInitSetting({overrideSettings:t,zonosSettings:null});return[2]}))}))};t.prototype.overrideCountry=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){void localizationStoreUpdateSelectedCountryCode(t);return[2]}))}))};t.prototype.render=function(){return h(Host,{class:"zonos--elements"})};return t}();ZonosController.style=zonosControllerCss;export{ZonosController as zonos_controller};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as registerInstance,h,H as Host,d as getElement}from"./index-d1aa9293.js";import{s as stripeStore}from"./cart-
|
|
1
|
+
import{r as registerInstance,h,H as Host,d as getElement}from"./index-d1aa9293.js";import{s as stripeStore}from"./cart-17650017.js";import"./zonosStore-05a62104.js";import"./localization-f3828793.js";import"./isDarkColor-6fbb9b14.js";import"./getBorderRadius-45764ad7.js";var zonosPaymentCss=".sc-zonos-payment-h{font-family:Inter;display:block}.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 ZonosPayment=function(){function t(t){registerInstance(this,t);this.titleText=undefined;this.stripe=stripeStore.stripe;this.stripeElements=stripeStore.stripeElements}t.prototype.watchInitStripe=function(){if(!this.stripeElements){return}var t=stripeStore.stripePaymentElement||this.stripeElements.create("payment",{layout:"tabs"});var e=this.el.querySelector(".zonos--payment-component");if(!e){console.error("Cannot find container element for paymentElement");return}t.mount(e);t.on("change",(function(t){stripeStore.stripePaymentEventData=t}));stripeStore.stripePaymentElement=t};t.prototype.componentDidLoad=function(){this.watchInitStripe()};t.prototype.render=function(){return h(Host,{class:"zonos--payment zonos--elements"},this.titleText&&h("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),h("div",{class:"zonos--payment-component"}))};Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{stripeElements:["watchInitStripe"],stripe:["watchInitStripe"]}},enumerable:false,configurable:true});return t}();ZonosPayment.style=zonosPaymentCss;export{ZonosPayment as zonos_payment};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as registerInstance,c as createEvent,h,H as Host}from"./index-d1aa9293.js";import{z as zonosStore}from"./zonosStore-05a62104.js";import{c as classes}from"./classes-0d95c529.js";import{g as getBorderRadius}from"./getBorderRadius-45764ad7.js";import{i as isColorVariable}from"./isColorVariable-4cda28c9.js";var zonosShippingRichRadioCss=":host{font-family:Inter;display:block}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}:host input{margin:0;accent-color:var(--selected-border-color, var(--amino-blue-600))}:host .zonos--shipping-rich-radio-item{display:-ms-flexbox;display:flex;-ms-flex:1;flex:1;padding:var(--amino-space-16);-ms-flex-align:center;align-items:center;gap:var(--amino-space-16);cursor:pointer;border:1px solid var(--amino-gray-200)}:host .zonos--shipping-rich-radio-item:first-child{border-top-left-radius:var(--border-radius, var(--amino-radius-10));border-top-right-radius:var(--border-radius, var(--amino-radius-10))}:host .zonos--shipping-rich-radio-item:last-child{border-bottom-right-radius:var(--border-radius, var(--amino-radius-10))}:host .zonos--shipping-rich-radio-item:not(:last-child){border-bottom:none}:host .zonos--shipping-rich-radio-item.selected{outline:1px solid var(--selected-border-color, var(--amino-blue-600));outline-offset:-1px}:host .zonos--shipping-info{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex:1;flex:1}:host .zonos--shipping-detail{-ms-flex:1;flex:1}:host .zonos--sub-detail{display:-ms-inline-flexbox;display:inline-flex;gap:8px;-ms-flex-wrap:wrap;flex-wrap:wrap}";var ZonosShippingRichRadio=function(){function o(o){var i=this;registerInstance(this,o);this.radioSelected=createEvent(this,"radioSelected",7);this.handleRichRadioSelect=function(o){var e;i.selectedItem=o;(e=i.radioSelected)===null||e===void 0?void 0:e.emit(o)};this.getRadioItemStyleVariables=function(){var o=i.borderColor||zonosStore.appearance.colorSecondary;var e=isColorVariable(o)?"var(--amino-".concat(o,")"):o;return{"--border-radius":getBorderRadius(i.borderStyle),"--selected-border-color":e||"unset"}};this.items=undefined;this.borderColor=undefined;this.borderStyle=undefined;this.theme=undefined;this.selectedItem=null}o.prototype.render=function(){var o=this;var i;return h(Host,{class:"zonos--shipping-rich-radio zonos--elements","data-theme":this.theme,style:this.getRadioItemStyleVariables()},(i=this.items)===null||i===void 0?void 0:i.map((function(i){var e;var s=((e=o.selectedItem)===null||e===void 0?void 0:e.value)===i.value;return h("div",{"aria-hidden":"true",class:classes(["zonos--shipping-rich-radio-item",s&&"selected"]),onClick:function(){return o.handleRichRadioSelect(i)}},h("input",{checked:s,class:"zonos--shipping-rich-radio-input",name:"zonos--shipping-rich-radio",type:"radio",value:i.value}),h("div",{class:"zonos--shipping-info"},h("div",{class:"zonos--shipping-detail"},h("zonos-text",{class:"zonos--shipping-label",type:"label"},i.label),(i.sublabel||i.caption)&&h("div",{class:"zonos--sub-detail"},i.sublabel&&h("zonos-text",{color:"gray-800"},i.sublabel),i.caption&&h("zonos-text",{color:"gray-400"},i.caption))),h("zonos-text",{type:"semiBoldLabel"},i.price)))})))};return o}();ZonosShippingRichRadio.style=zonosShippingRichRadioCss;export{ZonosShippingRichRadio as zonos_shipping_rich_radio};
|
|
1
|
+
import{r as registerInstance,c as createEvent,h,H as Host}from"./index-d1aa9293.js";import{z as zonosStore}from"./zonosStore-05a62104.js";import{c as classes}from"./classes-0d95c529.js";import{g as getBorderRadius}from"./getBorderRadius-45764ad7.js";import{i as isColorVariable}from"./isColorVariable-4cda28c9.js";var zonosShippingRichRadioCss=":host{font-family:Inter;display:block}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}:host input{margin:0;accent-color:var(--selected-border-color, var(--amino-blue-600))}:host .zonos--shipping-rich-radio-item{display:-ms-flexbox;display:flex;-ms-flex:1;flex:1;padding:var(--amino-space-16);-ms-flex-align:center;align-items:center;gap:var(--amino-space-16);cursor:pointer;border:1px solid var(--amino-gray-200)}:host .zonos--shipping-rich-radio-item:first-child{border-top-left-radius:var(--border-radius, var(--amino-radius-10));border-top-right-radius:var(--border-radius, var(--amino-radius-10))}:host .zonos--shipping-rich-radio-item:last-child{border-bottom-right-radius:var(--border-radius, var(--amino-radius-10));border-bottom-left-radius:var(--border-radius, var(--amino-radius-10))}:host .zonos--shipping-rich-radio-item:not(:last-child){border-bottom:none}:host .zonos--shipping-rich-radio-item.selected{outline:1px solid var(--selected-border-color, var(--amino-blue-600));outline-offset:-1px}:host .zonos--shipping-info{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex:1;flex:1}:host .zonos--shipping-detail{-ms-flex:1;flex:1}:host .zonos--sub-detail{display:-ms-inline-flexbox;display:inline-flex;gap:8px;-ms-flex-wrap:wrap;flex-wrap:wrap}";var ZonosShippingRichRadio=function(){function o(o){var i=this;registerInstance(this,o);this.radioSelected=createEvent(this,"radioSelected",7);this.handleRichRadioSelect=function(o){var e;i.selectedItem=o;(e=i.radioSelected)===null||e===void 0?void 0:e.emit(o)};this.getRadioItemStyleVariables=function(){var o=i.borderColor||zonosStore.appearance.colorSecondary;var e=isColorVariable(o)?"var(--amino-".concat(o,")"):o;return{"--border-radius":getBorderRadius(i.borderStyle),"--selected-border-color":e||"unset"}};this.items=undefined;this.borderColor=undefined;this.borderStyle=undefined;this.theme=undefined;this.selectedItem=null}o.prototype.render=function(){var o=this;var i;return h(Host,{class:"zonos--shipping-rich-radio zonos--elements","data-theme":this.theme,style:this.getRadioItemStyleVariables()},(i=this.items)===null||i===void 0?void 0:i.map((function(i){var e;var s=((e=o.selectedItem)===null||e===void 0?void 0:e.value)===i.value;return h("div",{"aria-hidden":"true",class:classes(["zonos--shipping-rich-radio-item",s&&"selected"]),onClick:function(){return o.handleRichRadioSelect(i)}},h("input",{checked:s,class:"zonos--shipping-rich-radio-input",name:"zonos--shipping-rich-radio",type:"radio",value:i.value}),h("div",{class:"zonos--shipping-info"},h("div",{class:"zonos--shipping-detail"},h("zonos-text",{class:"zonos--shipping-label",type:"label"},i.label),(i.sublabel||i.caption)&&h("div",{class:"zonos--sub-detail"},i.sublabel&&h("zonos-text",{color:"gray-800"},i.sublabel),i.caption&&h("zonos-text",{color:"gray-400"},i.caption))),h("zonos-text",{type:"semiBoldLabel"},i.price)))})))};return o}();ZonosShippingRichRadio.style=zonosShippingRichRadioCss;export{ZonosShippingRichRadio as zonos_shipping_rich_radio};
|
|
@@ -141,8 +141,43 @@ const zonosLoadStripe = async (...args) => {
|
|
|
141
141
|
};
|
|
142
142
|
|
|
143
143
|
var _a;
|
|
144
|
-
|
|
145
|
-
const
|
|
144
|
+
// 3 hours
|
|
145
|
+
const EXPIRED_QA_TIME = 3 * 60 * 60 * 1000;
|
|
146
|
+
// validate the time format (yyyymmddhhmmss) in the qa params if exceeds 1 hour, don't use qa
|
|
147
|
+
const isZonosQa = (() => {
|
|
148
|
+
const zonosQaTime = window.location.search.match(/\?.*(&*)zonosQa=(\d+)/);
|
|
149
|
+
if (!zonosQaTime) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
const [, , zonosQaTimeExtracted] = zonosQaTime;
|
|
153
|
+
if (!zonosQaTimeExtracted) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
const zonosQaTimeValue = parseInt(zonosQaTimeExtracted, 10);
|
|
157
|
+
const now = new Date();
|
|
158
|
+
const nowTime = now.getTime();
|
|
159
|
+
const isValid = nowTime - zonosQaTimeValue < EXPIRED_QA_TIME;
|
|
160
|
+
if (isValid) {
|
|
161
|
+
// Zonos class is not available in here yet, so we use console.warn instead of log util
|
|
162
|
+
// eslint-disable-next-line no-console
|
|
163
|
+
console.warn(`[ZONOS-WARNING] USING DEBUG DOMAIN, THIS IS ONLY FOR ZONOS DEVELOPER TO DEBUG, PLEASE REMOVE zonosQa=xxx OUT OF URL IF YOU DON'T KNOW WHAT YOU'RE DOING`);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
// Zonos class is not available in here yet, so we use console.warn instead of log util
|
|
167
|
+
// eslint-disable-next-line no-console
|
|
168
|
+
console.warn(`[ZONOS-WARNING] QA DOMAIN IS EXPIRED, USING PRODUCTION DOMAIN NOW`);
|
|
169
|
+
// remove the zonosQa param from url
|
|
170
|
+
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
171
|
+
urlSearchParams.delete('zonosQa');
|
|
172
|
+
const newUrl = `${window.location.pathname}?${urlSearchParams.toString()}`;
|
|
173
|
+
window.history.replaceState({}, '', newUrl);
|
|
174
|
+
}
|
|
175
|
+
return isValid;
|
|
176
|
+
})();
|
|
177
|
+
const ZONOS_URL = isZonosQa
|
|
178
|
+
? 'https://debug.js.zonos.com'
|
|
179
|
+
: "https://v1.2.3.js.zonos.com";
|
|
180
|
+
const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.2.3";
|
|
146
181
|
const INTER_FONT_URL = 'https://rsms.me';
|
|
147
182
|
const INTER_FONT_REGEX = /^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;
|
|
148
183
|
class Zonos {
|
|
@@ -153,7 +188,8 @@ Zonos.doneInit = false;
|
|
|
153
188
|
Zonos.debug = !!window.location.search.match(/\?.*(&*)zonosDebug=1/);
|
|
154
189
|
Zonos.isBigCommerce = false;
|
|
155
190
|
Zonos.internationalHideSelector = '';
|
|
156
|
-
Zonos.version = `v${"1.2.
|
|
191
|
+
Zonos.version = `v${"1.2.3"}`;
|
|
192
|
+
Zonos.getCurrentTimestamp = () => new Date().getTime();
|
|
157
193
|
Zonos.init = async ({ appearance, checkoutSettings, currencyConverter, helloSettings, zonosApiKey, }) => {
|
|
158
194
|
if (Zonos.doneInit) {
|
|
159
195
|
// do nothing if zonos is already initializeds
|
|
@@ -165,7 +201,6 @@ Zonos.init = async ({ appearance, checkoutSettings, currencyConverter, helloSett
|
|
|
165
201
|
return;
|
|
166
202
|
}
|
|
167
203
|
_a.zonosApiKey = zonosApiKey;
|
|
168
|
-
// eslint-disable-next-line no-console
|
|
169
204
|
log('init zonos');
|
|
170
205
|
// inject zonos cdn
|
|
171
206
|
Zonos.injectZonosCdn();
|
|
@@ -195,10 +230,56 @@ Zonos.showNotification = (notification) => {
|
|
|
195
230
|
const zonosController = document.querySelector('zonos-controller');
|
|
196
231
|
void (zonosController === null || zonosController === void 0 ? void 0 : zonosController.showNotification(notification));
|
|
197
232
|
};
|
|
233
|
+
Zonos.disablePlaceOrderButtons = ({ autoEnable = true, disable, placeOrderButtonSelector, }) => {
|
|
234
|
+
// if placeOrderAnchor is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
|
|
235
|
+
if (placeOrderButtonSelector) {
|
|
236
|
+
const placeOrderButton = document.querySelectorAll(placeOrderButtonSelector);
|
|
237
|
+
const disableEvent = (e) => {
|
|
238
|
+
const target = e.target;
|
|
239
|
+
// prevent default and propagation when the item has disabled attribute
|
|
240
|
+
if (target.getAttribute('disabled')) {
|
|
241
|
+
e.preventDefault();
|
|
242
|
+
e.stopPropagation();
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
placeOrderButton.forEach(button => {
|
|
246
|
+
if (disable) {
|
|
247
|
+
button.setAttribute('disabled', 'true');
|
|
248
|
+
// prevent the selector to perform default action when it's disabled
|
|
249
|
+
button.addEventListener('click', disableEvent);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
button.removeAttribute('disabled');
|
|
253
|
+
// clean up the event listener
|
|
254
|
+
button.removeEventListener('click', disableEvent);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
// only auto enable if autoEnable is true and we are setting button disable
|
|
258
|
+
if (autoEnable && disable) {
|
|
259
|
+
setTimeout(() => {
|
|
260
|
+
// release it if zonos is not initialized after 5 seconds (this is to prevent the place order button from being disabled forever due to api)
|
|
261
|
+
placeOrderButton.forEach(button => {
|
|
262
|
+
button.removeAttribute('disabled');
|
|
263
|
+
// clean up the event listener if exists
|
|
264
|
+
button.removeEventListener('click', disableEvent);
|
|
265
|
+
});
|
|
266
|
+
}, 5000);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
};
|
|
198
270
|
Zonos.injectController = ({ config, zonosApiKey, }) => {
|
|
271
|
+
var _b;
|
|
199
272
|
if (document.querySelector('zonos-controller')) {
|
|
200
273
|
return;
|
|
201
274
|
}
|
|
275
|
+
// if placeOrderAnchor is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
|
|
276
|
+
if ((_b = config.checkoutSettings) === null || _b === void 0 ? void 0 : _b.placeOrderButtonSelector) {
|
|
277
|
+
const placeOrderButtonSelector = config.checkoutSettings.placeOrderButtonSelector;
|
|
278
|
+
_a.disablePlaceOrderButtons({
|
|
279
|
+
disable: true,
|
|
280
|
+
placeOrderButtonSelector,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
202
283
|
const zonosController = document.createElement('zonos-controller');
|
|
203
284
|
zonosController.config = config;
|
|
204
285
|
zonosController.zonosApiKey = zonosApiKey;
|
|
@@ -306,7 +387,7 @@ Zonos.injectStylesheet = ({ fallBackDomain, stylesheetDomain, theRestUrl, }) =>
|
|
|
306
387
|
};
|
|
307
388
|
Zonos.injectZonosCss = () => {
|
|
308
389
|
const findStyleLink = () => {
|
|
309
|
-
return !!document.querySelector(`link[rel="stylesheet"][href
|
|
390
|
+
return !!document.querySelector(`link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]`);
|
|
310
391
|
};
|
|
311
392
|
if (findStyleLink()) {
|
|
312
393
|
// eslint-disable-next-line no-console
|
package/dist/scripts/zonos.js
CHANGED
|
@@ -141,8 +141,43 @@ const zonosLoadStripe = async (...args) => {
|
|
|
141
141
|
};
|
|
142
142
|
|
|
143
143
|
var _a;
|
|
144
|
-
|
|
145
|
-
const
|
|
144
|
+
// 3 hours
|
|
145
|
+
const EXPIRED_QA_TIME = 3 * 60 * 60 * 1000;
|
|
146
|
+
// validate the time format (yyyymmddhhmmss) in the qa params if exceeds 1 hour, don't use qa
|
|
147
|
+
const isZonosQa = (() => {
|
|
148
|
+
const zonosQaTime = window.location.search.match(/\?.*(&*)zonosQa=(\d+)/);
|
|
149
|
+
if (!zonosQaTime) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
const [, , zonosQaTimeExtracted] = zonosQaTime;
|
|
153
|
+
if (!zonosQaTimeExtracted) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
const zonosQaTimeValue = parseInt(zonosQaTimeExtracted, 10);
|
|
157
|
+
const now = new Date();
|
|
158
|
+
const nowTime = now.getTime();
|
|
159
|
+
const isValid = nowTime - zonosQaTimeValue < EXPIRED_QA_TIME;
|
|
160
|
+
if (isValid) {
|
|
161
|
+
// Zonos class is not available in here yet, so we use console.warn instead of log util
|
|
162
|
+
// eslint-disable-next-line no-console
|
|
163
|
+
console.warn(`[ZONOS-WARNING] USING DEBUG DOMAIN, THIS IS ONLY FOR ZONOS DEVELOPER TO DEBUG, PLEASE REMOVE zonosQa=xxx OUT OF URL IF YOU DON'T KNOW WHAT YOU'RE DOING`);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
// Zonos class is not available in here yet, so we use console.warn instead of log util
|
|
167
|
+
// eslint-disable-next-line no-console
|
|
168
|
+
console.warn(`[ZONOS-WARNING] QA DOMAIN IS EXPIRED, USING PRODUCTION DOMAIN NOW`);
|
|
169
|
+
// remove the zonosQa param from url
|
|
170
|
+
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
171
|
+
urlSearchParams.delete('zonosQa');
|
|
172
|
+
const newUrl = `${window.location.pathname}?${urlSearchParams.toString()}`;
|
|
173
|
+
window.history.replaceState({}, '', newUrl);
|
|
174
|
+
}
|
|
175
|
+
return isValid;
|
|
176
|
+
})();
|
|
177
|
+
const ZONOS_URL = isZonosQa
|
|
178
|
+
? 'https://debug.js.zonos.com'
|
|
179
|
+
: "https://v1.2.3.js.zonos.com";
|
|
180
|
+
const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.2.3";
|
|
146
181
|
const INTER_FONT_URL = 'https://rsms.me';
|
|
147
182
|
const INTER_FONT_REGEX = /^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;
|
|
148
183
|
class Zonos {
|
|
@@ -153,7 +188,8 @@ Zonos.doneInit = false;
|
|
|
153
188
|
Zonos.debug = !!window.location.search.match(/\?.*(&*)zonosDebug=1/);
|
|
154
189
|
Zonos.isBigCommerce = false;
|
|
155
190
|
Zonos.internationalHideSelector = '';
|
|
156
|
-
Zonos.version = `v${"1.2.
|
|
191
|
+
Zonos.version = `v${"1.2.3"}`;
|
|
192
|
+
Zonos.getCurrentTimestamp = () => new Date().getTime();
|
|
157
193
|
Zonos.init = async ({ appearance, checkoutSettings, currencyConverter, helloSettings, zonosApiKey, }) => {
|
|
158
194
|
if (Zonos.doneInit) {
|
|
159
195
|
// do nothing if zonos is already initializeds
|
|
@@ -165,7 +201,6 @@ Zonos.init = async ({ appearance, checkoutSettings, currencyConverter, helloSett
|
|
|
165
201
|
return;
|
|
166
202
|
}
|
|
167
203
|
_a.zonosApiKey = zonosApiKey;
|
|
168
|
-
// eslint-disable-next-line no-console
|
|
169
204
|
log('init zonos');
|
|
170
205
|
// inject zonos cdn
|
|
171
206
|
Zonos.injectZonosCdn();
|
|
@@ -195,10 +230,56 @@ Zonos.showNotification = (notification) => {
|
|
|
195
230
|
const zonosController = document.querySelector('zonos-controller');
|
|
196
231
|
void (zonosController === null || zonosController === void 0 ? void 0 : zonosController.showNotification(notification));
|
|
197
232
|
};
|
|
233
|
+
Zonos.disablePlaceOrderButtons = ({ autoEnable = true, disable, placeOrderButtonSelector, }) => {
|
|
234
|
+
// if placeOrderAnchor is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
|
|
235
|
+
if (placeOrderButtonSelector) {
|
|
236
|
+
const placeOrderButton = document.querySelectorAll(placeOrderButtonSelector);
|
|
237
|
+
const disableEvent = (e) => {
|
|
238
|
+
const target = e.target;
|
|
239
|
+
// prevent default and propagation when the item has disabled attribute
|
|
240
|
+
if (target.getAttribute('disabled')) {
|
|
241
|
+
e.preventDefault();
|
|
242
|
+
e.stopPropagation();
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
placeOrderButton.forEach(button => {
|
|
246
|
+
if (disable) {
|
|
247
|
+
button.setAttribute('disabled', 'true');
|
|
248
|
+
// prevent the selector to perform default action when it's disabled
|
|
249
|
+
button.addEventListener('click', disableEvent);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
button.removeAttribute('disabled');
|
|
253
|
+
// clean up the event listener
|
|
254
|
+
button.removeEventListener('click', disableEvent);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
// only auto enable if autoEnable is true and we are setting button disable
|
|
258
|
+
if (autoEnable && disable) {
|
|
259
|
+
setTimeout(() => {
|
|
260
|
+
// release it if zonos is not initialized after 5 seconds (this is to prevent the place order button from being disabled forever due to api)
|
|
261
|
+
placeOrderButton.forEach(button => {
|
|
262
|
+
button.removeAttribute('disabled');
|
|
263
|
+
// clean up the event listener if exists
|
|
264
|
+
button.removeEventListener('click', disableEvent);
|
|
265
|
+
});
|
|
266
|
+
}, 5000);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
};
|
|
198
270
|
Zonos.injectController = ({ config, zonosApiKey, }) => {
|
|
271
|
+
var _b;
|
|
199
272
|
if (document.querySelector('zonos-controller')) {
|
|
200
273
|
return;
|
|
201
274
|
}
|
|
275
|
+
// if placeOrderAnchor is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
|
|
276
|
+
if ((_b = config.checkoutSettings) === null || _b === void 0 ? void 0 : _b.placeOrderButtonSelector) {
|
|
277
|
+
const placeOrderButtonSelector = config.checkoutSettings.placeOrderButtonSelector;
|
|
278
|
+
_a.disablePlaceOrderButtons({
|
|
279
|
+
disable: true,
|
|
280
|
+
placeOrderButtonSelector,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
202
283
|
const zonosController = document.createElement('zonos-controller');
|
|
203
284
|
zonosController.config = config;
|
|
204
285
|
zonosController.zonosApiKey = zonosApiKey;
|
|
@@ -306,7 +387,7 @@ Zonos.injectStylesheet = ({ fallBackDomain, stylesheetDomain, theRestUrl, }) =>
|
|
|
306
387
|
};
|
|
307
388
|
Zonos.injectZonosCss = () => {
|
|
308
389
|
const findStyleLink = () => {
|
|
309
|
-
return !!document.querySelector(`link[rel="stylesheet"][href
|
|
390
|
+
return !!document.querySelector(`link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]`);
|
|
310
391
|
};
|
|
311
392
|
if (findStyleLink()) {
|
|
312
393
|
// eslint-disable-next-line no-console
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PaymentIntent, Stripe, StripeAddressElement, StripeAddressElementChangeEvent, StripeElements, StripeLinkAuthenticationElement, StripeLinkAuthenticationElementChangeEvent, StripePaymentElement, StripePaymentElementChangeEvent } from '@stripe/stripe-js';
|
|
1
|
+
import type { PaymentIntent, Stripe, StripeAddressElement, StripeAddressElementChangeEvent, StripeElements, StripeElementsOptions, StripeLinkAuthenticationElement, StripeLinkAuthenticationElementChangeEvent, StripePaymentElement, StripePaymentElementChangeEvent } from '@stripe/stripe-js';
|
|
2
2
|
import type { CheckoutSessionUpdateMutation, CountryCode, ElementsUiStyle, ElementsUiTheme } from "../../../types/generated/graphql.customer.types";
|
|
3
3
|
export type ContactOption = {
|
|
4
4
|
address: {
|
|
@@ -22,6 +22,7 @@ type StripeStore = {
|
|
|
22
22
|
stripeAddressEventData: StripeAddressElementChangeEvent | null;
|
|
23
23
|
stripeAddressUsedWhenFetchingLC: StripeAddressElementChangeEvent | null;
|
|
24
24
|
stripeElements: StripeElements | null;
|
|
25
|
+
stripeElementsOptions: StripeElementsOptions | null;
|
|
25
26
|
stripeLinkElement: StripeLinkAuthenticationElement | null;
|
|
26
27
|
stripeLinkEventData: StripeLinkAuthenticationElementChangeEvent | null;
|
|
27
28
|
stripeLinkUsedWhenFetchingLC: StripeLinkAuthenticationElementChangeEvent | null;
|
|
@@ -37,7 +37,7 @@ import type { IDeepKeyof, IDeepPropertyType } from "../../types/index";
|
|
|
37
37
|
},
|
|
38
38
|
};
|
|
39
39
|
*/
|
|
40
|
-
export declare const changeDeepProperty: <T extends Record<string, unknown>, P extends IDeepKeyof<T, Depth>, Depth extends 0 | 8 | 1 | 2 | 5 | 3 | 4 |
|
|
40
|
+
export declare const changeDeepProperty: <T extends Record<string, unknown>, P extends IDeepKeyof<T, Depth>, Depth extends 0 | 8 | 1 | 2 | 6 | 5 | 3 | 4 | 7 | 9 = 4>({ obj, propertyPath, value, }: {
|
|
41
41
|
obj: T;
|
|
42
42
|
propertyPath: P;
|
|
43
43
|
value: IDeepPropertyType<T, P, Depth>;
|
|
@@ -60,7 +60,7 @@ import type { IDeepKeyofAtIndex, IDeepPropertyTypeAtIndex } from "../../types/in
|
|
|
60
60
|
},
|
|
61
61
|
};
|
|
62
62
|
*/
|
|
63
|
-
export declare const changeDeepPropertyAtIndex: <T extends object, P extends IDeepKeyofAtIndex<T, Depth>, Depth extends 0 | 8 | 1 | 2 | 5 | 3 | 4 |
|
|
63
|
+
export declare const changeDeepPropertyAtIndex: <T extends object, P extends IDeepKeyofAtIndex<T, Depth>, Depth extends 0 | 8 | 1 | 2 | 6 | 5 | 3 | 4 | 7 | 9 = 4>({ index, obj, propertyPath, value, }: {
|
|
64
64
|
index: number;
|
|
65
65
|
obj: T;
|
|
66
66
|
propertyPath: P;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { CheckoutConfig } from "../../../types/checkout/CheckoutConfig";
|
|
2
|
-
export declare const initCheckout: (config: Partial<CheckoutConfig>) =>
|
|
2
|
+
export declare const initCheckout: (config: Partial<CheckoutConfig>) => void;
|
|
@@ -45,9 +45,14 @@ export declare const env: {
|
|
|
45
45
|
NEXT_PUBLIC_ZONOS_UNPKG_CDN_URL: string;
|
|
46
46
|
};
|
|
47
47
|
type Keys = keyof typeof env;
|
|
48
|
+
type Props = {
|
|
49
|
+
override?: {
|
|
50
|
+
[key in Keys]: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
48
53
|
/**
|
|
49
54
|
* Env object that has all of native env variable used in code to replace them with
|
|
50
55
|
* actual values from .env
|
|
51
56
|
*/
|
|
52
|
-
export declare const getReplaceEnv: () => Record<`process.env.${Keys}`, string>;
|
|
57
|
+
export declare const getReplaceEnv: (props?: Props) => Record<`process.env.${Keys}`, string>;
|
|
53
58
|
export {};
|
|
@@ -27,6 +27,7 @@ export interface Zonos {
|
|
|
27
27
|
version: string;
|
|
28
28
|
zonosApiKey: string;
|
|
29
29
|
displayCurrency: () => void;
|
|
30
|
+
getCurrentTimestamp: () => number;
|
|
30
31
|
init: (params: LoadZonosParams) => Promise<void>;
|
|
31
32
|
showNotification: (props: NotificationInit) => void;
|
|
32
33
|
}
|
|
@@ -38,9 +39,11 @@ export declare abstract class Zonos {
|
|
|
38
39
|
static isBigCommerce: boolean;
|
|
39
40
|
static internationalHideSelector: string;
|
|
40
41
|
static version: string;
|
|
42
|
+
static getCurrentTimestamp: () => number;
|
|
41
43
|
static init: ({ appearance, checkoutSettings, currencyConverter, helloSettings, zonosApiKey, }: LoadZonosParams) => Promise<void>;
|
|
42
44
|
static displayCurrency: () => void;
|
|
43
45
|
static showNotification: (notification: NotificationInit) => void;
|
|
46
|
+
private static disablePlaceOrderButtons;
|
|
44
47
|
private static injectController;
|
|
45
48
|
private static injectScript;
|
|
46
49
|
private static injectZonosCdn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg color="var(--amino-
|
|
1
|
+
<svg color="var(--amino-red-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-red-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>
|
|
@@ -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-8378d94e.js";import"./p-08695f4e.js";import"./p-dc8d7000.js";import"./p-770c959e.js";import"./p-bf070bf6.js";import"./p-0e0b46a5.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(t,e,n,o){function r(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,i){function s(t){try{u(o.next(t))}catch(t){i(t)}}function c(t){try{u(o["throw"](t))}catch(t){i(t)}}function u(t){t.done?n(t.value):r(t.value).then(s,c)}u((o=o.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,r,i,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(t){return function(e){return u([t,e])}}function u(c){if(o)throw new TypeError("Generator is already executing.");while(s&&(s=0,c[0]&&(n=0)),n)try{if(o=1,r&&(i=c[0]&2?r["return"]:c[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;if(r=0,i)c=[c[0]&2,i.value];switch(c[0]){case 0:case 1:i=c;break;case 4:n.label++;return{value:c[1],done:false};case 5:n.label++;r=c[1];c=[0];continue;case 7:c=n.ops.pop();n.trys.pop();continue;default:if(!(i=n.trys,i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){n.label=c[1];break}if(c[0]===6&&n.label<i[1]){n.label=i[1];i=c;break}if(i&&n.label<i[2]){n.label=i[2];n.ops.push(c);break}if(i[2])n.ops.pop();n.trys.pop();continue}c=e.call(t,n)}catch(t){c=[6,t];r=0}finally{o=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}};System.register(["./p-68d06767.system.js","./p-f6add79c.system.js","./p-164fae93.system.js","./p-6dcd752e.system.js","./p-85ab35c9.system.js","./p-8c867835.system.js"],(function(t){"use strict";var e,n,o,r,i,s,c,u,a,l,f,d,h;return{setters:[function(t){e=t.r;n=t.c;o=t.h;r=t.H},function(t){i=t.s},function(t){s=t.h;c=t.b;u=t.i;a=t.l;l=t.c;f=t.d},function(t){d=t.z;h=t.d},function(){},function(){}],execute:function(){var v=this;var p=function(){return __awaiter(v,void 0,void 0,(function(){var t,e,n,o;return __generator(this,(function(r){switch(r.label){case 0:t="".concat("https://v1.route.js.zonos.com","/api/zonos-setting");return[4,s(t)];case 1:e=r.sent(),n=e.errors,o=e.json;if(n.length){c("Error occurs when getting zonos settings. If this is not an unauthorized error, it will use user setting or default setting");return[2,{errors:n,json:null}]}return[2,{errors:[],json:o}]}}))}))};var y=function(){var t=document.querySelector("zonos-checkout");if(!t){var e=document.createElement("zonos-checkout");document.body.appendChild(e)}};var m=function(t){if(!t.placeOrderButtonSelector){return}if(!u(t.placeOrderButtonSelector)){c('Selector checkoutButtonAnchor "'.concat(t.placeOrderButtonSelector,'" is not a valid selector'));return}y()};var g=function(t){var e=document.querySelector("zonos-hello");if(!e&&t){var n=document.createElement("zonos-hello");t.appendChild(n)}};var b=function(t){return __awaiter(v,void 0,void 0,(function(){var e,n;return __generator(this,(function(o){e=t.anchorElementSelector;if(!e||!u(e)){c('Selector anchorElementSelector "'.concat(t.anchorElementSelector,'" is not a valid selector.'));return[2]}n=document.querySelector(e);a("Hello init complete");g(n);return[2]}))}))};var _=":host{font-family:Inter;display:block}: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 w=t("zonos_controller",function(){function t(t){e(this,t);this.stripeInitEvent=n(this,"stripeInitEvent",7);this.disablePlaceOrderButtons=function(t){var e=t.disable;var n=d.checkoutSettings.placeOrderButtonSelector;if(!n){return}var o=function(t){var e=t.target;if(e.getAttribute("disabled")){t.preventDefault();t.stopPropagation()}};var r=document.querySelectorAll(n);r.forEach((function(t){if(e){t.setAttribute("disabled","true");t.addEventListener("click",o)}else{t.removeAttribute("disabled");t.removeEventListener("click",o)}}));if(e){setTimeout((function(){r.forEach((function(t){t.removeAttribute("disabled");t.removeEventListener("click",o)}))}),5e3)}};this.config=undefined;this.zonosApiKey=undefined}t.prototype.initCheckoutElement=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){if(!t){a("Stripe is not loaded yet - cannot init checkout element","warn");return[2]}i.stripe=t;void m(d.checkoutSettings);a("init checkout element");this.disablePlaceOrderButtons({disable:false});return[2]}))}))};t.prototype.initZonosNotification=function(){var t=document.querySelector("zonos-notification");if(t){return}var e=document.createElement("zonos-notification");document.body.appendChild(e)};t.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(e){d.zonosApiKey=this.zonosApiKey;(function(){return __awaiter(t,void 0,void 0,(function(){var t,e,n,o,r,i;return __generator(this,(function(s){switch(s.label){case 0:return[4,p()];case 1:n=s.sent(),o=n.errors,r=n.json;if(((t=o[0])===null||t===void 0?void 0:t.type.toString())==="403"){a("Failed to load zonos settings. This domain may not have access","warn");return[2]}this.disablePlaceOrderButtons({disable:true});this.initZonosNotification();h({overrideSettings:this.config,zonosSettings:r});if(d.helloSettings){void b(d.helloSettings)}return[4,l()];case 2:s.sent();i=((e=r===null||r===void 0?void 0:r.checkoutSettings)===null||e===void 0?void 0:e.externalServiceTokens.find((function(t){return t.type==="STRIPE_PUBLISHABLE_TOKEN"})))||null;if(!i||!this.stripeInitEvent){a("Checkout failed to load -- missing publishable key","warn");return[2]}if(d.checkoutSettings.subscriptionStatus==="INACTIVE"){a('=== Checkout subscription is "INACTIVE" - Cancel initializing for Checkout ===',"warn");a("zonos controller loaded");return[2]}if(d.checkoutSettings.visibilityStatus==="DISABLED"){a("=== Checkout is disabled by store owner ===","warn");a("zonos controller loaded");return[2]}this.stripeInitEvent.emit({publishableKey:i.token});a("zonos controller loaded");return[2]}}))}))})();return[2]}))}))};t.prototype.showNotification=function(t){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(n){e=document.querySelector("zonos-notification");if(!e){a("Failed to show notification - zonos-notification not found","warn");return[2]}void e.showNotification(t);return[2]}))}))};t.prototype.overrideConfig=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){h({overrideSettings:t,zonosSettings:null});return[2]}))}))};t.prototype.overrideCountry=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){void f(t);return[2]}))}))};t.prototype.render=function(){return o(r,{class:"zonos--elements"})};return t}());w.style=_}}}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
System.register(["./p-68d06767.system.js","./p-
|
|
1
|
+
System.register(["./p-68d06767.system.js","./p-f6add79c.system.js","./p-6dcd752e.system.js","./p-164fae93.system.js","./p-85ab35c9.system.js","./p-8c867835.system.js"],(function(t){"use strict";var e,n,s,o,a;return{setters:[function(t){e=t.r;n=t.h;s=t.H;o=t.d},function(t){a=t.s},function(){},function(){},function(){},function(){}],execute:function(){var i=".sc-zonos-payment-h{font-family:Inter;display:block}.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 c=t("zonos_payment",function(){function t(t){e(this,t);this.titleText=undefined;this.stripe=a.stripe;this.stripeElements=a.stripeElements}t.prototype.watchInitStripe=function(){if(!this.stripeElements){return}var t=a.stripePaymentElement||this.stripeElements.create("payment",{layout:"tabs"});var e=this.el.querySelector(".zonos--payment-component");if(!e){console.error("Cannot find container element for paymentElement");return}t.mount(e);t.on("change",(function(t){a.stripePaymentEventData=t}));a.stripePaymentElement=t};t.prototype.componentDidLoad=function(){this.watchInitStripe()};t.prototype.render=function(){return n(s,{class:"zonos--payment zonos--elements"},this.titleText&&n("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),n("div",{class:"zonos--payment-component"}))};Object.defineProperty(t.prototype,"el",{get:function(){return o(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{stripeElements:["watchInitStripe"],stripe:["watchInitStripe"]}},enumerable:false,configurable:true});return t}());c.style=i}}}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as o,c as t,h as s,H as i}from"./p-dc8d7000.js";import{s as n}from"./p-8378d94e.js";import{h as e,b as r,i as c,l as a,c as l,d}from"./p-770c959e.js";import{z as h,d as u}from"./p-08695f4e.js";import"./p-bf070bf6.js";import"./p-0e0b46a5.js";const m=class{constructor(s){o(this,s),this.stripeInitEvent=t(this,"stripeInitEvent",7),this.disablePlaceOrderButtons=({disable:o})=>{const t=h.checkoutSettings.placeOrderButtonSelector;if(!t)return;const s=o=>{o.target.getAttribute("disabled")&&(o.preventDefault(),o.stopPropagation())},i=document.querySelectorAll(t);i.forEach((t=>{o?(t.setAttribute("disabled","true"),t.addEventListener("click",s)):(t.removeAttribute("disabled"),t.removeEventListener("click",s))})),o&&setTimeout((()=>{i.forEach((o=>{o.removeAttribute("disabled"),o.removeEventListener("click",s)}))}),5e3)},this.config=void 0,this.zonosApiKey=void 0}async initCheckoutElement(o){var t;o?(n.stripe=o,(t=h.checkoutSettings).placeOrderButtonSelector&&(c(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`)),a("init checkout element"),this.disablePlaceOrderButtons({disable:!1})):a("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 componentWillLoad(){h.zonosApiKey=this.zonosApiKey,(async()=>{var o,t;const{errors:s,json:i}=await(async()=>{const{errors:o,json:t}=await e("https://v1.route.js.zonos.com/api/zonos-setting");return o.length?(r("Error occurs when getting zonos settings. If this is not an unauthorized error, it will use user setting or default setting"),{errors:o,json:null}):{errors:[],json:t}})();if("403"===(null===(o=s[0])||void 0===o?void 0:o.type.toString()))return void a("Failed to load zonos settings. This domain may not have access","warn");this.disablePlaceOrderButtons({disable:!0}),this.initZonosNotification(),u({overrideSettings:this.config,zonosSettings:i}),h.helloSettings&&(async o=>{const{anchorElementSelector:t}=o;if(!t||!c(t))return void r(`Selector anchorElementSelector "${o.anchorElementSelector}" is not a valid selector.`);const s=document.querySelector(t);a("Hello init complete"),(o=>{if(!document.querySelector("zonos-hello")&&o){const t=document.createElement("zonos-hello");o.appendChild(t)}})(s)})(h.helloSettings),await l();const n=(null===(t=null==i?void 0:i.checkoutSettings)||void 0===t?void 0:t.externalServiceTokens.find((o=>"STRIPE_PUBLISHABLE_TOKEN"===o.type)))||null;if(n&&this.stripeInitEvent){if("INACTIVE"===h.checkoutSettings.subscriptionStatus)return a('=== Checkout subscription is "INACTIVE" - Cancel initializing for Checkout ===',"warn"),void a("zonos controller loaded");if("DISABLED"===h.checkoutSettings.visibilityStatus)return a("=== Checkout is disabled by store owner ===","warn"),void a("zonos controller loaded");this.stripeInitEvent.emit({publishableKey:n.token}),a("zonos controller loaded")}else a("Checkout failed to load -- missing publishable key","warn")})()}async showNotification(o){const t=document.querySelector("zonos-notification");t?t.showNotification(o):a("Failed to show notification - zonos-notification not found","warn")}async overrideConfig(o){u({overrideSettings:o,zonosSettings:null})}async overrideCountry(o){d(o)}render(){return s(i,{class:"zonos--elements"})}};m.style=":host{font-family:Inter;display:block}: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}
|