@ikas/storefront 4.7.7 → 4.7.9
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t}from'./../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as i}from"mobx-react-lite";import{useRouter as r}from"next/router.js";import a from"next/link.js";import s from"react-tooltip";import n,{CheckoutStep as c}from"./model.js";import{IkasStorefrontConfig as l}from"@ikas/storefront-config";import{formatCurrency as m}from"../../utils/currency.js";import{useTranslation as d}from"../../utils/i18n.js";import p from"./steps/step-info/index.js";import{CheckoutStepShipping as u}from"./steps/step-shipping/index.js";import{CheckoutStepPayment as v}from"./steps/step-payment/index.js";import{CartSummary as h}from"./components/cart-summary/index.js";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasThemeJsonPageType as g}from"@ikas/storefront-models";import"mobx";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/region/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/ikas-address.js";import"../../models/ui/validator/form/register.js";import{ContactForm as y}from"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import{StepSuccess as f}from"./steps/step-success/index.js";import{Modal as E}from"./components/modal/index.js";import k from"./components/master-pass/modal-otp/index.js";import x from"./components/master-pass/modal-response/index.js";import j from"./components/master-pass/modal-success/index.js";import{Image as C}from"../image/index.js";import b,{Step as N}from"./components/step-container/index.js";import{StockError as F}from"./components/error/stock-error/index.js";import{FullscreenLoading as M}from"./components/fullscreen-loading/index.js";import P from"./components/notification-box/index.js";import{FormItem as T}from"./components/form-item/index.js";import{FormItemType as S}from"./components/form-item/model.js";import{Button as w}from"./components/button/index.js";import{IkasPageHead as A}from"../page/head.js";import I from"./components/offer-product/index.js";import O from"./components/svg/ikas.js";import B from"./style.module.scss.js";import{Analytics as L}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import V from"./components/epaykolay-button/index.js";var R=i((function(i){var a,m,p,u=i.checkout,v=i.checkoutSettings,y=i.customizationProps,C=i.returnPolicy,b=i.privacyPolicy,N=i.termsOfService,P=i.imprint,T=i.shippingPolicy,S=d().t,w=r(),R=o.useState((function(){return new n(u,v,w,C,b,N,P,T,S,y||{})}))[0];R.step===c.PAYMENT&&L.disableHTML();var _=function(o){return e(void 0,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return e="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/os/e-pay-kolay/get-basket"),[4,fetch(e,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":l.getApiKey()},body:JSON.stringify({cartId:R.checkout.id,customerNumber:o,sessionsState:Date.now()})})];case 1:return[2,t.sent().json()]}}))}))};o.useEffect((function(){R.checkoutSettings.isAccountRequired&&!R.checkout.hasCustomer&&w.push("/account/login?redirect="+encodeURIComponent(R.checkoutUrl)),L.beginCheckout(R.checkout),L.pageView(g.CHECKOUT)}),[]),o.useEffect((function(){R.customizationProps=y,function(e){document.documentElement.style.setProperty("--checkout-button-bg-color",(null==e?void 0:e.buttonBgColor)||"#272727"),document.documentElement.style.setProperty("--checkout-button-text-color",(null==e?void 0:e.buttonTextColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-button-disabled-bg-color",(null==e?void 0:e.buttonDisabledBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-button-disabled-text-color",(null==e?void 0:e.buttonDisabledTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-text-color",(null==e?void 0:e.primaryTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-text-color",(null==e?void 0:e.secondaryTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-bg-color",(null==e?void 0:e.primaryBgColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-secondary-bg-color",(null==e?void 0:e.secondaryBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-border-color",(null==e?void 0:e.borderColor)||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-card-bg-color",(null==e?void 0:e.cardBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-error-color",(null==e?void 0:e.errorColor)||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-error-light-color",(null==e?void 0:e.errorLightColor)||"#FCF3F4"),document.documentElement.style.setProperty("--checkout-warning-color",(null==e?void 0:e.warningColor)||"#FFBC1F"),document.documentElement.style.setProperty("--checkout-warning-light-color",(null==e?void 0:e.warningLightColor)||"#FFFAEE"),document.documentElement.style.setProperty("--checkout-success-color",(null==e?void 0:e.successColor)||"#2DCA73"),document.documentElement.style.setProperty("--checkout-success-light-color",(null==e?void 0:e.successLightColor)||"#F6FFED")}(y)}),[y]),o.useEffect((function(){if(R.isEPayKolayEnabled)var o=setInterval((function(){var i;window.setContainerService&&R.isCheckoutLoaded&&(window.setContainerService(null===(i=l.getMerchantSettings())||void 0===i?void 0:i.merchantId,_,(function(o){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,K(o)];case 1:return[2,e.sent()]}}))}))}),(function(){console.log("Switching to epaykolay"),R.isEPayKolayPayment=!0}),"https://cdn-epeykolay.mncdn.com/epay/"),clearInterval(o))}),100)}),[]);var K=o.useCallback((function(o){return e(void 0,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,fetch("".concat(process.env.NEXT_PUBLIC_BASE_URL,"/os/e-pay-kolay/complete-payment"),{method:"POST",body:JSON.stringify({data:o,cartId:R.checkout.id}),headers:{"Content-Type":"application/json","x-api-key":l.getApiKey()}})];case 1:return[4,t.sent().json()];case 2:return e=t.sent(),[2,{redirectUrl:"".concat(window.location.pathname,"?id=").concat(R.checkout.id,"&step=").concat(e.success?"success":"info"),orderId:R.checkout.id}]}}))}))}),[]);if(!R.isCheckoutLoaded||!R.store.customerStore.initialized)return o.createElement(M,null);if(R.checkout.hasCustomer&&(null===(a=R.store.customerStore.customer)||void 0===a?void 0:a.id)!==(null===(m=R.checkout.customer)||void 0===m?void 0:m.id))return w.push("/account/login?redirect="+encodeURIComponent(R.checkoutUrl)),null;return o.createElement(o.Fragment,null,o.createElement(A,{pageType:g.CHECKOUT,pageTitle:((null===(p=R.merchantSettings)||void 0===p?void 0:p.merchantName)||"")+" - "+S("checkout-page:securePayment"),pageDescription:S("checkout-page:securePayment")}),o.createElement("div",{id:"Checkout",className:B.CheckoutPage},o.createElement(s,{place:"top",type:"dark",effect:"solid",arrowColor:"transparent",multiline:!0,className:B.ReactTooltipWrap,globalEventOff:"touchstart"}),o.createElement("div",{className:[B.Left,R.isEPayKolayPayment?B.epaykolay:""].join(" ")},R.isEPayKolayEnabled&&o.createElement("div",{id:"plateau_ui_placeholder",style:{width:"100%"}}),!R.isEPayKolayPayment&&o.createElement("div",{className:B.LeftContent},o.createElement("div",null,o.createElement(U,{vm:R}),R.hasStockError&&o.createElement("div",{className:B.ErrorContainer},o.createElement(F,{vm:R,error:R.error})),!R.hasStockError&&o.createElement(o.Fragment,null,o.createElement(h,{vm:R,allowExpand:!0}),o.createElement("div",null,R.step!==c.SUCCESS&&R.isEPayKolayEnabled&&o.createElement(V,{onClick:function(){window.frictionless()}})),R.step===c.SUCCESS?o.createElement(f,{vm:R}):o.createElement(o.Fragment,null,R.checkoutCampaignOffer&&o.createElement(I,{vm:R,campaignOffer:R.checkoutCampaignOffer}),o.createElement(D,{vm:R}))),o.createElement("div",{className:B.Space})),o.createElement(H,{vm:R}))),o.createElement("div",{className:B.Right},o.createElement("div",{className:B.RightContent},o.createElement(h,{vm:R}),o.createElement("div",{className:B.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===l.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(O,null))))),!!R.policyModalText&&o.createElement(E,{title:R.policyModalTitle,modalContent:R.policyModalText,onClose:function(){R.policyModalText=""}}),R.isContactModalVisible&&o.createElement(z,{vm:R,setVisible:R.setContactModalVisible}),R.mpVM.isOtpModalVisible&&o.createElement(k,{vm:R,visible:R.mpVM.isOtpModalVisible,type:R.mpVM.otpModalType,onClose:R.mpVM.hideOtpModal}),R.mpVM.isResponseModalVisible&&o.createElement(x,{visible:R.mpVM.isResponseModalVisible,text:R.mpVM.mfsResponseModalText,onClose:R.mpVM.onResponseModalClose}),R.mpVM.isSuccessModalVisible&&o.createElement(j,{visible:R.mpVM.isSuccessModalVisible,type:R.mpVM.successModalType,onClose:R.mpVM.onSuccessModalClose})))})),U=i((function(e){var t,i,r,s=e.vm,n=d().t;return o.createElement("div",{className:B.Header},o.createElement(a,{href:"/",passHref:!0},o.createElement("a",null,(null===(t=s.merchantSettings)||void 0===t?void 0:t.logo)?o.createElement("div",{className:B.Logo},o.createElement(C,{layout:"fill",image:s.merchantSettings.logo,sizes:"360px"})):(null===(i=s.merchantSettings)||void 0===i?void 0:i.merchantName)||"")),!s.checkout.hasCustomer&&o.createElement("div",{className:B.LoginText},o.createElement("span",{className:B.LoginCta},n("checkout-page:alreadyHaveAnAccount")),o.createElement(a,{href:"/account/login?redirect="+encodeURIComponent(s.checkoutUrl),passHref:!0},o.createElement("a",{className:B.LoginBtn},n("checkout-page:actions.login")))),s.checkout.hasCustomer&&o.createElement("div",{className:B.CustomerInfo},o.createElement("div",{className:B.Name},s.checkout.customerFullName),o.createElement("div",{className:B.Email},null===(r=s.checkout.customer)||void 0===r?void 0:r.email)))})),D=i((function(e){var t=e.vm,i=d().t,r=o.useMemo((function(){switch(t.step){case c.INFO:return o.createElement(p,{vm:t});case c.SHIPPING:return o.createElement(u,{vm:t});case c.PAYMENT:return o.createElement(v,{vm:t});case c.SUCCESS:return o.createElement(f,{vm:t})}}),[t,t.step]),a=[new N(i("checkout-page:address"),t.step===c.INFO,t.step!==c.INFO,t.step!==c.INFO?o.createElement("div",{className:B.AdressStepInfo},o.createElement(_,{vm:t}),o.createElement("div",{className:B.EditBtn,onClick:t.onBackToInfoClick},i("checkout-page:actions.edit"))):void 0,t.step!==c.INFO?o.createElement("div",{className:B.AddressStepInfoMobile},o.createElement(_,{vm:t})):void 0),new N(i("checkout-page:payment"),t.step===c.PAYMENT,!1)];return"address"!==t.deliveryMethod||t.isDigitalOnly||a.splice(1,0,new N(i("checkout-page:shipping"),t.step===c.SHIPPING,t.step===c.PAYMENT,t.step===c.PAYMENT?o.createElement("div",{className:B.AdressStepInfo},o.createElement(K,{vm:t}),(t.checkout.availableShippingMethods&&t.checkout.availableShippingMethods.length>1||t.checkoutSettings.isGiftPackageEnabled)&&o.createElement("div",{className:B.EditBtn,onClick:t.onBackToShippingClick},i("checkout-page:actions.edit"))):void 0,t.step===c.PAYMENT?o.createElement("div",{className:B.AddressStepInfoMobile},o.createElement(K,{vm:t})):void 0)),o.createElement(b,{steps:a,stepContent:r})})),_=i((function(e){var t,i,r,a,s,n,c,l,m,p=e.vm,u=d().t,v=p.isDigitalOnly?((null===(t=p.checkout.billingAddress)||void 0===t?void 0:t.firstName)||"")+" "+((null===(i=p.checkout.billingAddress)||void 0===i?void 0:i.lastName)||""):((null===(r=p.checkout.shippingAddress)||void 0===r?void 0:r.firstName)||"")+" "+((null===(a=p.checkout.shippingAddress)||void 0===a?void 0:a.lastName)||"");return o.createElement("div",{className:B.Address},o.createElement("div",{className:[B.Text,B.WithMBottom].join(" ")},(null===(s=p.checkout.customer)||void 0===s?void 0:s.email)||""),"address"===p.deliveryMethod?o.createElement("div",{className:B.Text},v):o.createElement(o.Fragment,null,o.createElement("div",{className:B.Text},u("checkout-page:receiver")),o.createElement("div",{className:[B.Text,B.Gray].join(" ")},v)),o.createElement("div",{className:[B.Text,B.Gray].join(" ")},p.isDigitalOnly?null===(n=p.checkout.billingAddress)||void 0===n?void 0:n.phone:null===(c=p.checkout.shippingAddress)||void 0===c?void 0:c.phone),"in-store"===p.deliveryMethod&&o.createElement(o.Fragment,null,o.createElement("div",{className:[B.Text,B.WithMTop].join(" ")},u("checkout-page:pickUpLocation"))),o.createElement("div",{className:[B.Text,B.Gray].join(" ")},p.isDigitalOnly?null===(l=p.checkout.billingAddress)||void 0===l?void 0:l.addressText:null===(m=p.checkout.shippingAddress)||void 0===m?void 0:m.addressText))})),K=i((function(e){var t=e.vm,i=d().t;return o.createElement("div",{className:B.Address},t.checkout.shippingLines&&t.checkout.shippingLines.length?o.createElement(o.Fragment,null,o.createElement("span",null,t.checkout.shippingLines[0].title),o.createElement("span",{className:B.LightText}," / "+(0===t.checkout.shippingLines[0].price?i("checkout-page:free"):m(t.checkout.shippingLines[0].price,t.checkout.currencyCode,t.checkout.currencySymbol)))):i("checkout-page:standartShipping"))})),H=i((function(e){var t=e.vm,i=d().t;return o.createElement("div",{className:B.Footer},o.createElement("div",{className:B.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:returnPolicy"),t.policyModalText=t.returnPolicy}},i("checkout-page:returnPolicy")),o.createElement("div",{className:B.FooterBullet},"•"),o.createElement("div",{className:B.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:privacyPolicy"),t.policyModalText=t.privacyPolicy}},i("checkout-page:privacyPolicy")),o.createElement("div",{className:B.FooterBullet},"•"),o.createElement("div",{className:B.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:termsOfService"),t.policyModalText=t.termsOfService}},i("checkout-page:termsOfService")),t.imprint&&o.createElement(o.Fragment,null,o.createElement("div",{className:B.FooterBullet},"•"),o.createElement("div",{className:B.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:imprint"),t.policyModalText=t.imprint}},i("checkout-page:imprint"))),t.shippingPolicy&&o.createElement(o.Fragment,null,o.createElement("div",{className:B.FooterBullet},"•"),o.createElement("div",{className:B.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:shippingPolicy"),t.policyModalText=t.shippingPolicy}},i("checkout-page:shippingPolicy"))))})),z=i((function(i){var r,a,s,n=i.vm,c=i.setVisible,l=d().t,m=o.useState(!1),p=m[0],u=m[1],v=o.useState(!1),h=v[0],g=v[1],f=o.useState(new y({message:{requiredRule:"",emailRule:"",minRule:""}}))[0];f.email=(null===(r=n.checkout.customer)||void 0===r?void 0:r.email)||"",f.firstName=(null===(a=n.checkout.customer)||void 0===a?void 0:a.firstName)||"",f.lastName=(null===(s=n.checkout.customer)||void 0===s?void 0:s.lastName)||"";var k=o.useCallback((function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return h?[2,c(!1)]:(u(!0),[4,f.saveContactForm()]);case 1:return e.sent()&&g(!0),u(!1),[2]}}))}))}),[p]);return o.createElement(E,{title:l("checkout-page:contactForm"),modalContent:o.createElement("div",null,h&&o.createElement("div",{style:{marginBottom:"12px",maxWidth:"352px"}},o.createElement(P,{type:"success",title:l("checkout-page:contactFormSent"),content:l("checkout-page:contactFormDescription")})),o.createElement(T,{type:S.TEXT_AREA,label:"",value:f.message||"",onChange:f.onMessageChange,textAreaPlaceholder:l("checkout-page:contactFormCta")}),o.createElement(w,{style:{width:"100%",marginTop:"24px"},text:l(h?"checkout-page:actions.close":"checkout-page:actions.sendMessage"),isLoading:p,isDisabled:!f.message,onClick:k})),onClose:function(){return c(!1)}})}));export{R as default};
|
|
1
|
+
import{__awaiter as e,__generator as t}from'./../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as i}from"mobx-react-lite";import{useRouter as r}from"next/router.js";import a from"next/link.js";import s from"react-tooltip";import n,{CheckoutStep as c}from"./model.js";import{IkasStorefrontConfig as l}from"@ikas/storefront-config";import{formatCurrency as m}from"../../utils/currency.js";import{useTranslation as d}from"../../utils/i18n.js";import p from"./steps/step-info/index.js";import{CheckoutStepShipping as u}from"./steps/step-shipping/index.js";import{CheckoutStepPayment as v}from"./steps/step-payment/index.js";import{CartSummary as h}from"./components/cart-summary/index.js";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasThemeJsonPageType as g}from"@ikas/storefront-models";import"mobx";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/region/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/ikas-address.js";import"../../models/ui/validator/form/register.js";import{ContactForm as y}from"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import{StepSuccess as f}from"./steps/step-success/index.js";import{Modal as E}from"./components/modal/index.js";import k from"./components/master-pass/modal-otp/index.js";import x from"./components/master-pass/modal-response/index.js";import j from"./components/master-pass/modal-success/index.js";import{Image as C}from"../image/index.js";import b,{Step as N}from"./components/step-container/index.js";import{StockError as F}from"./components/error/stock-error/index.js";import{FullscreenLoading as P}from"./components/fullscreen-loading/index.js";import M from"./components/notification-box/index.js";import{FormItem as T}from"./components/form-item/index.js";import{FormItemType as S}from"./components/form-item/model.js";import{Button as w}from"./components/button/index.js";import{IkasPageHead as A}from"../page/head.js";import I from"./components/offer-product/index.js";import B from"./components/svg/ikas.js";import O from"./style.module.scss.js";import{Analytics as L}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import V from"./components/epaykolay-button/index.js";var R=i((function(i){var a,m,p,u=i.checkout,v=i.checkoutSettings,y=i.customizationProps,C=i.returnPolicy,b=i.privacyPolicy,N=i.termsOfService,M=i.imprint,T=i.shippingPolicy,S=d().t,w=r(),R=o.useState((function(){return new n(u,v,w,C,b,N,M,T,S,y||{})}))[0];R.step===c.PAYMENT&&L.disableHTML();var _=function(o){return e(void 0,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return e="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/os/e-pay-kolay/get-basket"),[4,fetch(e,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":l.getApiKey()},body:JSON.stringify({cartId:R.checkout.id,customerNumber:o,sessionsState:Date.now()})})];case 1:return[2,t.sent().json()]}}))}))};o.useEffect((function(){R.checkoutSettings.isAccountRequired&&!R.checkout.hasCustomer&&w.push("/account/login?redirect="+encodeURIComponent(R.checkoutUrl)),L.beginCheckout(R.checkout),L.pageView(g.CHECKOUT)}),[]),o.useEffect((function(){R.customizationProps=y,function(e){document.documentElement.style.setProperty("--checkout-button-bg-color",(null==e?void 0:e.buttonBgColor)||"#272727"),document.documentElement.style.setProperty("--checkout-button-text-color",(null==e?void 0:e.buttonTextColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-button-disabled-bg-color",(null==e?void 0:e.buttonDisabledBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-button-disabled-text-color",(null==e?void 0:e.buttonDisabledTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-text-color",(null==e?void 0:e.primaryTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-text-color",(null==e?void 0:e.secondaryTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-bg-color",(null==e?void 0:e.primaryBgColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-secondary-bg-color",(null==e?void 0:e.secondaryBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-border-color",(null==e?void 0:e.borderColor)||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-card-bg-color",(null==e?void 0:e.cardBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-error-color",(null==e?void 0:e.errorColor)||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-error-light-color",(null==e?void 0:e.errorLightColor)||"#FCF3F4"),document.documentElement.style.setProperty("--checkout-warning-color",(null==e?void 0:e.warningColor)||"#FFBC1F"),document.documentElement.style.setProperty("--checkout-warning-light-color",(null==e?void 0:e.warningLightColor)||"#FFFAEE"),document.documentElement.style.setProperty("--checkout-success-color",(null==e?void 0:e.successColor)||"#2DCA73"),document.documentElement.style.setProperty("--checkout-success-light-color",(null==e?void 0:e.successLightColor)||"#F6FFED")}(y)}),[y]),o.useEffect((function(){if(R.isEPayKolayEnabled)var o=setInterval((function(){var i;window.setContainerService&&R.isCheckoutLoaded&&(window.setContainerService(null===(i=l.getMerchantSettings())||void 0===i?void 0:i.merchantId,_,(function(o){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,H(o)];case 1:return[2,e.sent()]}}))}))}),(function(){console.log("Switching to epaykolay"),R.isEPayKolayPayment=!0}),"https://cdn-epeykolay.mncdn.com/epay/"),clearInterval(o))}),100)}),[]);var H=o.useCallback((function(o){return e(void 0,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,fetch("".concat(process.env.NEXT_PUBLIC_BASE_URL,"/os/e-pay-kolay/complete-payment"),{method:"POST",body:JSON.stringify({data:o,cartId:R.checkout.id}),headers:{"Content-Type":"application/json","x-api-key":l.getApiKey()}})];case 1:return[4,t.sent().json()];case 2:return e=t.sent(),[2,{redirectUrl:"".concat(window.location.pathname,"?id=").concat(R.checkout.id,"&step=").concat(e.success?"success":"info"),orderId:R.checkout.id}]}}))}))}),[]);if(!R.isCheckoutLoaded||!R.store.customerStore.initialized)return o.createElement(P,null);if(R.checkout.hasCustomer&&(null===(a=R.store.customerStore.customer)||void 0===a?void 0:a.id)!==(null===(m=R.checkout.customer)||void 0===m?void 0:m.id))return w.push("/account/login?redirect="+encodeURIComponent(R.checkoutUrl)),null;return o.createElement(o.Fragment,null,o.createElement(A,{pageType:g.CHECKOUT,pageTitle:((null===(p=R.merchantSettings)||void 0===p?void 0:p.merchantName)||"")+" - "+S("checkout-page:securePayment"),pageDescription:S("checkout-page:securePayment")}),o.createElement("div",{id:"Checkout",className:O.CheckoutPage},o.createElement(s,{place:"top",type:"dark",effect:"solid",arrowColor:"transparent",multiline:!0,className:O.ReactTooltipWrap,globalEventOff:"touchstart"}),o.createElement("div",{className:[O.Left,R.isEPayKolayPayment?O.epaykolay:""].join(" ")},R.isEPayKolayEnabled&&o.createElement("div",{id:"plateau_ui_placeholder",style:{width:"100%"}}),!R.isEPayKolayPayment&&o.createElement("div",{className:O.LeftContent},o.createElement("div",null,o.createElement(U,{vm:R}),R.hasStockError&&o.createElement("div",{className:O.ErrorContainer},o.createElement(F,{vm:R,error:R.error})),!R.hasStockError&&o.createElement(o.Fragment,null,o.createElement(h,{vm:R,allowExpand:!0}),o.createElement("div",null,R.step!==c.SUCCESS&&R.isEPayKolayEnabled&&o.createElement(V,{onClick:function(){window.frictionless()}})),R.step===c.SUCCESS?o.createElement(f,{vm:R}):o.createElement(o.Fragment,null,R.checkoutCampaignOffer&&o.createElement(I,{vm:R,campaignOffer:R.checkoutCampaignOffer}),o.createElement(D,{vm:R}))),o.createElement("div",{className:O.Space})),o.createElement(K,{vm:R}))),o.createElement("div",{className:O.Right},o.createElement("div",{className:O.RightContent},o.createElement(h,{vm:R}),!R.isPoweredByHidden&&o.createElement("div",{className:O.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===l.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(B,null))))),!!R.policyModalText&&o.createElement(E,{title:R.policyModalTitle,modalContent:R.policyModalText,onClose:function(){R.policyModalText=""}}),R.isContactModalVisible&&o.createElement(z,{vm:R,setVisible:R.setContactModalVisible}),R.mpVM.isOtpModalVisible&&o.createElement(k,{vm:R,visible:R.mpVM.isOtpModalVisible,type:R.mpVM.otpModalType,onClose:R.mpVM.hideOtpModal}),R.mpVM.isResponseModalVisible&&o.createElement(x,{visible:R.mpVM.isResponseModalVisible,text:R.mpVM.mfsResponseModalText,onClose:R.mpVM.onResponseModalClose}),R.mpVM.isSuccessModalVisible&&o.createElement(j,{visible:R.mpVM.isSuccessModalVisible,type:R.mpVM.successModalType,onClose:R.mpVM.onSuccessModalClose})))})),U=i((function(e){var t,i,r,s=e.vm,n=d().t;return o.createElement("div",{className:O.Header},o.createElement(a,{href:"/",passHref:!0},o.createElement("a",null,(null===(t=s.merchantSettings)||void 0===t?void 0:t.logo)?o.createElement("div",{className:O.Logo},o.createElement(C,{layout:"fill",image:s.merchantSettings.logo,sizes:"360px"})):(null===(i=s.merchantSettings)||void 0===i?void 0:i.merchantName)||"")),!s.checkout.hasCustomer&&o.createElement("div",{className:O.LoginText},o.createElement("span",{className:O.LoginCta},n("checkout-page:alreadyHaveAnAccount")),o.createElement(a,{href:"/account/login?redirect="+encodeURIComponent(s.checkoutUrl),passHref:!0},o.createElement("a",{className:O.LoginBtn},n("checkout-page:actions.login")))),s.checkout.hasCustomer&&o.createElement("div",{className:O.CustomerInfo},o.createElement("div",{className:O.Name},s.checkout.customerFullName),o.createElement("div",{className:O.Email},null===(r=s.checkout.customer)||void 0===r?void 0:r.email)))})),D=i((function(e){var t=e.vm,i=d().t,r=o.useMemo((function(){switch(t.step){case c.INFO:return o.createElement(p,{vm:t});case c.SHIPPING:return o.createElement(u,{vm:t});case c.PAYMENT:return o.createElement(v,{vm:t});case c.SUCCESS:return o.createElement(f,{vm:t})}}),[t,t.step]),a=[new N(i("checkout-page:address"),t.step===c.INFO,t.step!==c.INFO,t.step!==c.INFO?o.createElement("div",{className:O.AdressStepInfo},o.createElement(_,{vm:t}),o.createElement("div",{className:O.EditBtn,onClick:t.onBackToInfoClick},i("checkout-page:actions.edit"))):void 0,t.step!==c.INFO?o.createElement("div",{className:O.AddressStepInfoMobile},o.createElement(_,{vm:t})):void 0),new N(i("checkout-page:payment"),t.step===c.PAYMENT,!1)];return"address"!==t.deliveryMethod||t.isDigitalOnly||a.splice(1,0,new N(i("checkout-page:shipping"),t.step===c.SHIPPING,t.step===c.PAYMENT,t.step===c.PAYMENT?o.createElement("div",{className:O.AdressStepInfo},o.createElement(H,{vm:t}),(t.checkout.availableShippingMethods&&t.checkout.availableShippingMethods.length>1||t.checkoutSettings.isGiftPackageEnabled)&&o.createElement("div",{className:O.EditBtn,onClick:t.onBackToShippingClick},i("checkout-page:actions.edit"))):void 0,t.step===c.PAYMENT?o.createElement("div",{className:O.AddressStepInfoMobile},o.createElement(H,{vm:t})):void 0)),o.createElement(b,{steps:a,stepContent:r})})),_=i((function(e){var t,i,r,a,s,n,c,l,m,p=e.vm,u=d().t,v=p.isDigitalOnly?((null===(t=p.checkout.billingAddress)||void 0===t?void 0:t.firstName)||"")+" "+((null===(i=p.checkout.billingAddress)||void 0===i?void 0:i.lastName)||""):((null===(r=p.checkout.shippingAddress)||void 0===r?void 0:r.firstName)||"")+" "+((null===(a=p.checkout.shippingAddress)||void 0===a?void 0:a.lastName)||"");return o.createElement("div",{className:O.Address},o.createElement("div",{className:[O.Text,O.WithMBottom].join(" ")},(null===(s=p.checkout.customer)||void 0===s?void 0:s.email)||""),"address"===p.deliveryMethod?o.createElement("div",{className:O.Text},v):o.createElement(o.Fragment,null,o.createElement("div",{className:O.Text},u("checkout-page:receiver")),o.createElement("div",{className:[O.Text,O.Gray].join(" ")},v)),o.createElement("div",{className:[O.Text,O.Gray].join(" ")},p.isDigitalOnly?null===(n=p.checkout.billingAddress)||void 0===n?void 0:n.phone:null===(c=p.checkout.shippingAddress)||void 0===c?void 0:c.phone),"in-store"===p.deliveryMethod&&o.createElement(o.Fragment,null,o.createElement("div",{className:[O.Text,O.WithMTop].join(" ")},u("checkout-page:pickUpLocation"))),o.createElement("div",{className:[O.Text,O.Gray].join(" ")},p.isDigitalOnly?null===(l=p.checkout.billingAddress)||void 0===l?void 0:l.addressText:null===(m=p.checkout.shippingAddress)||void 0===m?void 0:m.addressText))})),H=i((function(e){var t=e.vm,i=d().t;return o.createElement("div",{className:O.Address},t.checkout.shippingLines&&t.checkout.shippingLines.length?o.createElement(o.Fragment,null,o.createElement("span",null,t.checkout.shippingLines[0].title),o.createElement("span",{className:O.LightText}," / "+(0===t.checkout.shippingLines[0].price?i("checkout-page:free"):m(t.checkout.shippingLines[0].price,t.checkout.currencyCode,t.checkout.currencySymbol)))):i("checkout-page:standartShipping"))})),K=i((function(e){var t=e.vm,i=d().t;return o.createElement("div",{className:O.Footer},o.createElement("div",{className:O.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:returnPolicy"),t.policyModalText=t.returnPolicy}},i("checkout-page:returnPolicy")),o.createElement("div",{className:O.FooterBullet},"•"),o.createElement("div",{className:O.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:privacyPolicy"),t.policyModalText=t.privacyPolicy}},i("checkout-page:privacyPolicy")),o.createElement("div",{className:O.FooterBullet},"•"),o.createElement("div",{className:O.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:termsOfService"),t.policyModalText=t.termsOfService}},i("checkout-page:termsOfService")),t.imprint&&o.createElement(o.Fragment,null,o.createElement("div",{className:O.FooterBullet},"•"),o.createElement("div",{className:O.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:imprint"),t.policyModalText=t.imprint}},i("checkout-page:imprint"))),t.shippingPolicy&&o.createElement(o.Fragment,null,o.createElement("div",{className:O.FooterBullet},"•"),o.createElement("div",{className:O.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:shippingPolicy"),t.policyModalText=t.shippingPolicy}},i("checkout-page:shippingPolicy"))))})),z=i((function(i){var r,a,s,n=i.vm,c=i.setVisible,l=d().t,m=o.useState(!1),p=m[0],u=m[1],v=o.useState(!1),h=v[0],g=v[1],f=o.useState(new y({message:{requiredRule:"",emailRule:"",minRule:""}}))[0];f.email=(null===(r=n.checkout.customer)||void 0===r?void 0:r.email)||"",f.firstName=(null===(a=n.checkout.customer)||void 0===a?void 0:a.firstName)||"",f.lastName=(null===(s=n.checkout.customer)||void 0===s?void 0:s.lastName)||"";var k=o.useCallback((function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return h?[2,c(!1)]:(u(!0),[4,f.saveContactForm()]);case 1:return e.sent()&&g(!0),u(!1),[2]}}))}))}),[p]);return o.createElement(E,{title:l("checkout-page:contactForm"),modalContent:o.createElement("div",null,h&&o.createElement("div",{style:{marginBottom:"12px",maxWidth:"352px"}},o.createElement(M,{type:"success",title:l("checkout-page:contactFormSent"),content:l("checkout-page:contactFormDescription")})),o.createElement(T,{type:S.TEXT_AREA,label:"",value:f.message||"",onChange:f.onMessageChange,textAreaPlaceholder:l("checkout-page:contactFormCta")}),o.createElement(w,{style:{width:"100%",marginTop:"24px"},text:l(h?"checkout-page:actions.close":"checkout-page:actions.sendMessage"),isLoading:p,isDisabled:!f.message,onClick:k})),onClose:function(){return c(!1)}})}));export{R as default};
|
|
@@ -107,6 +107,7 @@ export default class CheckoutViewModel {
|
|
|
107
107
|
get customerAddresses(): IkasLocalizedCustomerAddress[] | undefined;
|
|
108
108
|
get isManualOrder(): boolean;
|
|
109
109
|
get isEPayKolayEnabled(): boolean;
|
|
110
|
+
get isPoweredByHidden(): boolean;
|
|
110
111
|
saveCart: () => Promise<import("../../models").IkasCart | null | undefined>;
|
|
111
112
|
inStockDeliveryInputData: (input: SaveCartInput) => Promise<SaveCartInput>;
|
|
112
113
|
checkStocks: () => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t,__assign as i}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import n from"lodash/cloneDeep";import r from"lodash/sortBy";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasPaymentMethodType as o,IkasPaymentGatewayType as a,IkasOrderShippingMethod as c,IkasCartCreatedBy as d,IkasTransactionStatus as u,IkasCartCampaignOfferStatus as l,IkasCampaignOfferTargetPageType as h}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import{IkasCheckout as p}from"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/region/index.js";import{IkasCustomerAddress as m}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as g}from"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import{IkasMerchantSettings as f}from"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import{IkasOrderCustomer as v}from"../../models/data/order/customer/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as y}from"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import{LocalizedAddressModel as k}from"@ikas/localized-address";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/ikas-address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import S from"./components/credit-card-form/model.js";import b from"../../store/customer/api.js";import P from"../../store/checkout/index.js";import C from"../../store/cart/api.js";import I,{MFS_ELEMENT_ID as A,MFS_SCRIPT_URL as w}from"./modelMasterPass.js";import N from"../../store/product/index.js";import{IkasBaseStore as j}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as O}from"@ikas/storefront-config";import{Analytics as E}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as R,CheckStocksLineInput as x}from"@ikas/storefront-api";import D from"../../models/data/order/address/ikas-localized-order-address.js";import T from"../../store/location/index.js";var G,L,M=/^\d+$/,V="undefined"==typeof localStorage,_=function(){function M(c,d,g,f,M,_,F,Z,B,Y){var H=this;this.storefront=null,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.isEPayKolayPayment=!1,this.step=G.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.adyenResponse=null,this.payPalClientIdResponse=null,this.paypalOrderResponse=null,this.shippingZones=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.showTestModal=!1,this.init=function(){return e(H,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this.countrySettings.waitUntilInitialized()];case 1:return e.sent(),[4,j.getInstance().customerStore.waitUntilInitialized()];case 2:return e.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getCampaignOffer()];case 3:return e.sent(),[4,this.initStep()];case 4:return e.sent(),[2]}}))}))},this.initStep=function(){return e(H,void 0,void 0,(function(){var e,i,s,n,r,o,a;return t(this,(function(t){switch(t.label){case 0:if(O.getIsEditor())return this.step=G.INFO,this.isCheckoutLoaded=!0,[2];if(e=new URLSearchParams(window.location.search),i=e.get("step"),s=e.get("failed"),n=e.get("error"),i){if(this.step=i,this.step===G.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(G.INFO)];if(this.step!==G.PAYMENT||this.canProceedToPayment){if(this.step===G.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(G.INFO)];if(![G.INFO,G.SUCCESS,G.SHIPPING,G.PAYMENT].includes(this.step))return[2,this.changeStep(G.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings?[2,this.changeStep(G.INFO)]:[2,this.changeStep(G.SHIPPING)];this.deliveryMethod="in-store"}}return s&&(this.error={type:L.PAYMENT_ERROR,data:n||null}),this.step!==G.INFO?[3,6]:this.isDigitalOnly?[3,3]:[4,this.getAvailableShippingZones()];case 1:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getShippingCountries()];case 2:t.sent(),this.checkShippingCountries(),t.label=3;case 3:return[4,this.getStockLocations()];case 4:return t.sent(),[4,this.getAvailableStockLocations()];case 5:t.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),t.label=6;case 6:return this.step!==G.SHIPPING||1!==(null===(o=this.checkout.availableShippingMethods)||void 0===o?void 0:o.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=G.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==G.SHIPPING||(null===(a=this.checkout.availableShippingMethods)||void 0===a?void 0:a.length)?this.step!==G.PAYMENT&&this.step!==G.SUCCESS?[3,10]:[4,this.listPaymentGateways()]:(this.error={type:L.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 7:return t.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,9];case 8:t.sent(),t.label=9;case 9:if(!this.paymentGateways.length)return this.error={type:L.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];t.label=10;case 10:return this.step===G.SUCCESS?[3,14]:this.checkout.isComplete?[2,this.changeStep(G.SUCCESS)]:[3,11];case 11:return[4,this.initialStockCheck()];case 12:t.sent(),t.label=13;case 13:return[3,16];case 14:return[4,this.getSuccessTransaction()];case 15:t.sent(),this.successTransaction&&(r=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===r}))),t.label=16;case 16:return this.isCheckoutLoaded=!0,E.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return[4,b.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return e=t.sent(),this.successTransaction=e.isSuccess&&(null===(i=e.data)||void 0===i?void 0:i.length)?e.data[e.data.length-1]:void 0,[2]}}))}))},this.saveCart=function(){return e(H,void 0,void 0,(function(){var e,i,s,n;return t(this,(function(t){switch(t.label){case 0:return e=new R(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(e)];case 1:e=t.sent(),t.label=2;case 2:return this.step!==G.INFO&&this.step!==G.SHIPPING||this.isDigitalOnly||(e.billingAddress=null),this.isDigitalOnly&&(e.shippingAddress=null),[4,C.saveCart({input:e})];case 3:if((null==(i=t.sent())?void 0:i.graphQLErrors)&&i.graphQLErrors.length)throw s=i.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(n=s.extensions)||void 0===n?void 0:n.code)?{type:L.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:L.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return e(H,void 0,void 0,(function(){var e,s,n=this;return t(this,(function(t){return e=i,(s=this.stockLocations.find((function(e){return e.id===n.checkout.stockLocationId})))&&e.shippingAddress&&s.address&&(e.shippingAddress.country=s.address.country,e.shippingAddress.city=s.address.city,e.shippingAddress.state=s.address.state,e.shippingAddress.district=s.address.district,e.shippingAddress.postalCode=s.address.postalCode,e.shippingAddress.addressLine1=s.address.address||"",e.shippingAddress.addressLine2=null),[2,e]}))}))},this.checkStocks=function(){return e(H,void 0,void 0,(function(){var e,i,s,n,r,o,a,c,d,u,l,h;return t(this,(function(t){switch(t.label){case 0:return this.isManualOrder?[2]:(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,P.checkStocks({lines:e.map((function(e){return new x(e)})),stockLocationIdList:(null===(u=O.getStockLocationIds())||void 0===u?void 0:u.length)?O.getStockLocationIds():null})]);case 1:if(!(i=t.sent()).isSuccess)throw{type:L.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(h=null===(l=i.data)||void 0===l?void 0:l.lines)||void 0===h?void 0:h.filter((function(e){return!e.isAvailable})))?void 0:s.length){for(n=[],r=function(e){var t=o.checkout.items.find((function(t){return t.variant.id===e.variantId}));t&&n.push({item:t,stockCount:e.stockCount})},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:L.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return e(H,void 0,void 0,(function(){return t(this,(function(e){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return e(H,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:e=0,s=i,t.label=1;case 1:return e<s.length?(n=s[e],[4,j.getInstance().cartStore.changeItemQuantity(n.item,n.stockCount<0?0:n.stockCount)]):[3,4];case 2:t.sent(),t.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,P.getAvailableShippingCountries({salesChannelId:O.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return O.getPickupStockLocationIds()?[4,P.listStockLocation({id:{in:O.getPickupStockLocationIds()}})]:[3,2];case 1:if(!(e=t.sent()).isSuccess||!(null===(i=e.data)||void 0===i?void 0:i.length))return this.error={type:L.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,t.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return O.getPickupStockLocationIds()?(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,P.getAvailableStockLocations({lines:e.map((function(e){return new x(e)})),stockLocationIdList:O.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=t.sent()).isSuccess)return this.error={type:L.API_ERROR},[2];this.availableStockLocations=i.data||[],t.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var e;(null===(e=H.shippingCountryIds)||void 0===e?void 0:e.length)||(H.error={type:L.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){"address"===e&&(H.checkout.stockLocationId=null),H.deliveryMethod=e,H.isErrorsVisible=!1},this.initialStockCheck=function(){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return t.sent(),[3,3];case 2:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:L.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return e(H,void 0,void 0,(function(){var e,i,s,n,o,a,c,d,u,l,h=this;return t(this,(function(t){switch(t.label){case 0:return e="local"===process.env.NEXT_PUBLIC_ENV,i=O.getPaymentGateways().map((function(e){return e.id})),[4,P.listPaymentGateway({id:e?void 0:{in:i},locale:O.getCurrentLocale(),transactionAmount:this.checkout.totalFinalPrice})];case 1:return(s=t.sent()).isSuccess&&(null===(u=s.data)||void 0===u?void 0:u.length)?(n=s.data,this.step===G.PAYMENT&&(n=n.filter((function(e){var t;return!(null===(t=e.supportedCurrencies)||void 0===t?void 0:t.length)||e.supportedCurrencies.includes(h.checkout.currencyCode)})),(o=null===(l=this.checkout.shippingAddress)||void 0===l?void 0:l.country)&&o.iso2&&(n=n.filter((function(e){var t;return!(null===(t=e.availableCountries)||void 0===t?void 0:t.length)||e.availableCountries.includes(o.iso2||"")})))),a=[],r(O.getPaymentGateways(),"order").forEach((function(e){var t=null==n?void 0:n.find((function(t){return t.id===e.id}));t&&a.push(t)})),this.paymentGateways=e?n:a,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),this.step===G.PAYMENT&&(c=n.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id=A,d.src=w,d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout,store:j.getInstance()})},document.head.appendChild(d)),[2]):(this.error={type:L.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return e(H,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:return[4,P.retrieveInstallmentInfo(i)];case 1:return e=t.sent(),s=e.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(e,t){return(e.installmentCount||-1)>(t.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var e;H.store.customerStore.customer?(null===(e=H.customerAddresses)||void 0===e||e.forEach((function(e){e.checkoutSettings=H.checkoutSettings,e.shippingZones=H.shippingZones})),H.checkout.customer=new v(H.store.customerStore.customer)):H.checkout.customer=new v(H.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){H.checkout.shippingAddress&&(H.checkout.shippingAddress.checkoutSettings=H.checkoutSettings,H.checkout.shippingAddress.shippingZones=H.shippingZones,H.checkout.shippingAddress.countrySettings=H.countrySettings,H.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){H.checkout.billingAddress&&(H.checkout.billingAddress.checkoutSettings=H.checkoutSettings,H.checkout.billingAddress.shippingZones=H.shippingZones,H.checkout.billingAddress.countrySettings=H.countrySettings,H.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!H.isDigitalOnly)if(H.isInStoreDelivery)H.setCheckoutShippingAddressSettings();else if(H.checkout.shippingAddress){if(H.store.customerStore.customer){var e=null==(t=H.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=H.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return H.onSelectedShippingAddressIdChange(e.id||"-1"),void H.setCheckoutShippingAddressSettings()}H.checkout.shippingAddress=new D(n(H.checkout.shippingAddress)||{}),H.setCheckoutShippingAddressSettings()}else if(H.store.customerStore.customer){var t=H.customerAddresses;H.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else H.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(H.useDifferentAddress=!!localStorage.getItem("sAddr"),H.checkout.billingAddress){if(H.store.customerStore.customer){var e=null==(t=H.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=H.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return H.onSelectedBillingAddressIdChange(e.id||"-1"),void H.setCheckoutBillingAddressSettings()}H.checkout.billingAddress=new D(n(H.checkout.billingAddress)||{}),H.setCheckoutBillingAddressSettings()}else if(H.store.customerStore.customer){var t=H.customerAddresses;H.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||H.useDifferentAddress||!H.checkout.shippingAddress||H.isInStoreDelivery||(H.checkout.billingAddress=new D(n(H.checkout.shippingAddress)),H.setCheckoutBillingAddressSettings())}else H.onSelectedBillingAddressIdChange("-1"),H.useDifferentAddress||!H.checkout.shippingAddress||H.isInStoreDelivery||(H.checkout.billingAddress=new D(n(H.checkout.shippingAddress)),H.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(i){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=i.shippingSettingsId,this.checkout.shippingZoneRateId=i.shippingZoneRateId,[4,this.saveCart()]);case 1:return(e=t.sent())&&(this.checkout=new p(e,this.countrySettings)),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings,this.checkout.shippingAddress.shippingZones=this.shippingZones),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return e(H,void 0,void 0,(function(){return t(this,(function(e){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return e(H,void 0,void 0,(function(){var e,s,n,r,o,a;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,5,,6]),[4,C.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(e=t.sent()).isSuccess&&e.data?(s=e.data,n=null===(a=null===(o=this.cardData)||void 0===o?void 0:o.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.couponError=null,this.step===G.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{binNumber:this.mpVM.selectedCard.Value1.slice(0,6),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:s.totalFinalPrice}})]:[3,3]):[3,4];case 2:t.sent(),t.label=3;case 3:s&&(r=this.checkout,this.checkout=new p(i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway}),this.countrySettings)),t.label=4;case 4:return e.isSuccess||(this.couponError=e.errorCodes[0]),[3,6];case 5:return t.sent(),[3,6];case 6:return[2]}}))}))},this.getAvailableShippingZones=function(){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,T.getAvailableShippingZones({salesChannelId:O.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingZones=e.data||null,[3,3];case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(e){var t;if(H.selectedShippingAddressId=e,"-1"===e)H.checkout.shippingAddress=new D,H.checkout.shippingAddress.countrySettings=H.countrySettings;else{var i=null===(t=H.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(H.checkout.shippingAddress=new D(i),H.checkout.shippingAddress.countrySettings=H.countrySettings)}H.checkout.shippingAddress&&(H.checkout.shippingAddress.checkoutSettings=H.checkoutSettings,H.checkout.shippingAddress.shippingZones=H.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(H.selectedBillingAddressId=e,"-1"===e)H.checkout.billingAddress=new D,H.checkout.billingAddress.countrySettings=H.countrySettings;else{var i=null===(t=H.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(H.checkout.billingAddress=new D(i),H.checkout.billingAddress.countrySettings=H.countrySettings)}H.checkout.billingAddress&&(H.checkout.billingAddress.checkoutSettings=H.checkoutSettings,H.checkout.billingAddress.shippingZones=H.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){H.isTermsAndConditionsChecked=e},this.onCardNumberChange=function(e){if(H.cardData&&(!(e.length>H.cardData.cardNumber.length)||K(e))){var t=(H.cardData.cardNumber||"").split(" ").join(""),i=e.split(" ").join("");i.length>16||(t.length<6&&i.length>=6&&!H.installmentInfo?H.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:H.checkout.selectedPaymentGateway.id,price:H.checkout.totalFinalPrice}}):i.length<6&&t.length>i.length&&(H.cardData.installmentCount=1,H.installmentInfo=void 0),H.cardData.cardNumber=U(i,4).join(" "))}},this.onCardHolderNameChange=function(e){H.cardData&&(H.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(H.cardData&&(!(e.length>H.cardData.expirationDate.length)||K(e))){if(0===(null===(t=H.cardData.expirationDate)||void 0===t?void 0:t.length)){var i=e.replace(".","/").split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(H.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&4===n.length){o=parseInt(s),r=parseInt(n.slice(2));if(!isNaN(r)&&!isNaN(o))return void(H.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&2===n.length){var a=parseInt(s),c=parseInt(n);o=a<=12?a:c,r=c>12?c:a;if(!isNaN(r)&&!isNaN(o))return void(H.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(H.cardData.expirationDate=U(d,2).join(" / "))}},this.onCvcChange=function(e){H.cardData&&(e.length>H.cardData.cvv.length&&!K(e)||e.length>4||(H.cardData.cvv=e))},this.saveAddress=function(s){return e(H,void 0,void 0,(function(){var e,r,o,a,c,d,u,l,h,p,g,f,v=this;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(e="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(h=this.customerAddresses)||void 0===h?void 0:h.find((function(t){return t.id===(null==e?void 0:e.id)})))?[2]:(r=null===(p=this.customerAddresses)||void 0===p?void 0:p.map((function(e){return e.id})),o=new m(i(i({},e),{title:this.addressTitle||this.t("checkout-page:newAddress")})),(a=n(this.store.customerStore.customer)).addresses||(a.addresses=[]),a.addresses.push(o),[4,this.store.customerStore.saveCustomer(a)])):[3,2];case 1:t.sent(),null===(g=this.customerAddresses)||void 0===g||g.forEach((function(e){e.checkoutSettings=v.checkoutSettings,e.shippingZones=v.shippingZones})),c=null===(f=this.customerAddresses)||void 0===f?void 0:f.map((function(e){return e.id})),d=null==c?void 0:c.filter((function(e){return!(null==r?void 0:r.includes(e))})),u=(null==d?void 0:d.length)?d[0]:void 0,"shipping"===s?(this.checkout.shippingAddress.id=u||"",this.selectedShippingAddressId=u||"-1"):(this.checkout.billingAddress.id=u||"",this.selectedBillingAddressId=u||"-1"),t.label=2;case 2:return[3,4];case 3:return l=t.sent(),console.error(l),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){H.router.push("/cart")},this.onBackToShoppingClick=function(){H.router.push("/")},this.onGoToLoginClick=function(){H.router.push("/account/login")},this.onProceedToShippingClick=function(){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2]}else if(!this.canProceedToInStoreDelivery)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:t.sent(),t.label=3;case 3:return[4,this.checkStocks()];case 4:return t.sent(),[4,this.saveCart()];case 5:return t.sent(),"address"===this.deliveryMethod?this.changeStep(G.SHIPPING):this.changeStep(G.PAYMENT),[3,7];case 6:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:L.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return t.sent(),[4,this.saveCart()];case 3:return t.sent(),this.changeStep(G.PAYMENT),[3,5];case 4:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:L.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return t.sent(),[4,this.saveCart()];case 3:return t.sent(),this.error=void 0,this.changeStep(G.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:L.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!H.canPerformPayment||(H.isErrorsVisible=!0,!1)},this.onCompletePaymentClick=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return this.canPerformPayment?(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isKlarna?[4,this.saveCart()]:[3,2]):(this.isErrorsVisible=!0,[2]);case 1:return t.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return t.trys.push([2,8,,9]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return t.sent(),"address"===this.deliveryMethod&&this.useDifferentAddress?[4,this.saveAddress("billing")]:[3,5];case 4:t.sent(),t.label=5;case 5:return[4,this.saveCart()];case 6:return t.sent(),this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):this.isPayPal?[2]:[4,this.createSaleTransaction()];case 7:return t.sent(),[3,9];case 8:return void 0!==typeof(i=t.sent()).type?this.error=i:this.error={type:L.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return!this.canProceedToPayment||this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked?(this.isErrorsVisible=!0,[2]):this.isKlarna?[4,this.saveCart()]:[3,2];case 1:return t.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return t.trys.push([2,6,,7]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return t.sent(),[4,this.saveCart()];case 4:return t.sent(),this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):this.isPayPal?[2]:[4,this.createSaleTransaction()];case 5:return t.sent(),[3,7];case 6:return(i=t.sent()).type?this.error=i:this.error={type:L.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return e(H,void 0,void 0,(function(){var e,i,s,n,r,c,d,l,h,p,m,g,f,v,y;return t(this,(function(t){switch(t.label){case 0:return i=this.mpVM.selectedCard,!this.isFree&&i&&(null===(l=this.mpVM.selectedCard)||void 0===l?void 0:l.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(e=n),void 0===(null===(h=this.cardData)||void 0===h?void 0:h.installmentCount)?[2]:[4,P.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:e,savedCardName:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name},paymentGatewayId:null===(m=this.mpVM.selectedCard)||void 0===m?void 0:m.paymentGatewayId,paymentMethodDetail:{cardNumber:this.mpVM.selectedCard.Value1,cardHolderName:this.mpVM.selectedCard.Name,cvv:this.mpVM.selectedCard.Value2,expiredMonth:11,expiredYear:11,installmentCount:this.cardData.installmentCount,threeDSecure:!!(null===(g=this.cardData)||void 0===g?void 0:g.threeDSecure)}}})]):[3,2];case 1:return s=t.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,P.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:this.isFree?void 0:i&&e?{phoneNumber:e,savedCardName:null===(f=this.mpVM.selectedCard)||void 0===f?void 0:f.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:this.isFree||i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===o.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===a.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})]:[2];case 3:s=t.sent(),t.label=4;case 4:return r=null===(v=null==s?void 0:s.data)||void 0===v?void 0:v.transactionStatus,c=r&&[u.SUCCESS,u.AUTHORIZED].includes(r),d=r===u.PENDING,c?[4,this.getSuccessTransaction()]:[3,7];case 5:return t.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return t.sent(),[3,8];case 7:if(!d||!(null===(y=null==s?void 0:s.data)||void 0===y?void 0:y.returnSlug))throw{data:s.firstErrorMessage,type:L.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,t.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return localStorage.removeItem("sAddr"),(null===(e=this.checkout.customer)||void 0===e?void 0:e.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.changeStep(G.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){H.changeStep(G.INFO)},this.onBackToShippingClick=function(){H.changeStep(G.SHIPPING)},this.setCustomerConsentGranted=function(e){H.checkout.customer&&(H.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(e){H.useDifferentAddress=e,H.useDifferentAddress?(localStorage.setItem("sAddr","1"),H.checkout.billingAddress=H.checkout.billingAddress||new D,H.checkout.billingAddress.countrySettings=H.countrySettings):(localStorage.removeItem("sAddr"),H.checkout.billingAddress=H.checkout.shippingAddress)},this.setShouldSaveAddress=function(e){H.shouldSaveAddress=e},this.setAddressTitle=function(e){H.addressTitle=e},this.reInitPaymentMethod=function(){return e(H,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return this.checkout.selectedPaymentGateway?this.isCustomFlowStripe?[4,this.createStripePaymentIntent(this.checkout.selectedPaymentGateway)]:[3,2]:[3,6];case 1:e.sent(),e.label=2;case 2:return this.isKlarna&&window.location.reload(),this.isAdyen?[4,this.createAdyenClientToken(this.checkout.selectedPaymentGateway)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.isPayPal?[4,this.getPayPalClientId(this.checkout.selectedPaymentGateway)]:[3,6];case 5:e.sent(),e.label=6;case 6:return[2]}}))}))},this.createStripePaymentIntent=function(i){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,P.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.stripeResponse=e.data),[2]}}))}))},this.createKlarnaClientToken=function(i){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,P.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.klarnaResponse=e.data),[2]}}))}))},this.createAdyenClientToken=function(i){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,P.createAdyenClientToken({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.adyenResponse=e.data),[2]}}))}))},this.getPayPalClientId=function(i){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,P.getPayPalClientId({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.payPalClientIdResponse=e.data),[2]}}))}))},this.setPaymentGateway=function(i){return e(H,void 0,void 0,(function(){var e,s;return t(this,(function(t){switch(t.label){case 0:return this.paymentGateways.length?"STRIPE"!==(e=this.paymentGateways[i]).code||!(null===(s=e.settings)||void 0===s?void 0:s.find((function(e){return"allow_custom_flow"===e.label&&"1"===e.value})))||this.stripeResponse?[3,2]:[4,this.createStripePaymentIntent(e)]:[2];case 1:t.sent(),t.label=2;case 2:return"KLARNA"!==e.code||this.klarnaResponse?[3,4]:[4,this.createKlarnaClientToken(e)];case 3:t.sent(),t.label=4;case 4:return"ADYEN"!==e.code||this.adyenResponse?[3,6]:[4,this.createAdyenClientToken(e)];case 5:t.sent(),t.label=6;case 6:return"PAYPAL"!==e.code||this.payPalClientIdResponse?[3,8]:[4,this.getPayPalClientId(e)];case 7:t.sent(),t.label=8;case 8:return this.checkout.selectedPaymentGateway=e,this.step!==G.SUCCESS&&(e.paymentMethodType===o.CREDIT_CARD&&e.type===a.INTERNAL&&(this.cardData=new S,e.masterPassClientId&&(console.log("called 1511 ikas log"),this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store}))),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(e){H.cardData&&(H.cardData.installmentCount=e)},this.changeStep=function(i){return e(H,void 0,void 0,(function(){return t(this,(function(e){return V||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return e(H,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return e.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(e){H.isContactModalVisible=e},this.getCampaignOfferProducts=function(i){return e(H,void 0,void 0,(function(){var e,s,n,r;return t(this,(function(o){switch(o.label){case 0:if(!this.checkout.campaignOffers||!this.checkout.campaignOffers.length)return[3,4];if(e=this.checkout.campaignOffers.filter((function(e){var t;return e.status===l.WAITING_FOR_ACTION&&(null===(t=e.campaignOffer)||void 0===t?void 0:t.targetPageTypes.some((function(e){return e===i})))})),!e.length)return[3,4];s=function(i){var s,n,r,o,a;return t(this,(function(t){switch(t.label){case 0:return(s=e[i]).campaignOffer&&(n=s.campaignOffer.offers.find((function(e){return e.id===s.campaignOfferProductId})))?[4,N.searchProducts({input:{productIdList:[n.productId]}})]:[3,2];case 1:if((r=t.sent()).isSuccess&&r.data&&r.data.data&&r.data.data.length&&(o=r.data.data[0],a=[],n.excludedVariantIdList&&n.excludedVariantIdList.length?o.variants.map((function(e){var t;e.hasStock&&!(null===(t=n.excludedVariantIdList)||void 0===t?void 0:t.some((function(t){return t===e.id})))&&a.push(e)})):a.push.apply(a,o.variants.filter((function(e){return e.hasStock}))),a.length))return[2,{value:{product:new y(o),variants:a,campaignOffer:s,offer:n}}];t.label=2;case 2:return[2]}}))},n=0,o.label=1;case 1:return n<e.length?[5,s(n)]:[3,4];case 2:if("object"==typeof(r=o.sent()))return[2,r.value];o.label=3;case 3:return n++,[3,1];case 4:return[2,void 0]}}))}))},this.getCampaignOffer=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return e=this,[4,this.getCampaignOfferProducts(h.CHECKOUT)];case 1:return e.checkoutCampaignOffer=t.sent(),i=this,[4,this.getCampaignOfferProducts(h.POST_CHECKOUT)];case 2:return i.postCheckoutCampaignOffer=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.isCheckoutLoaded=!1,[4,C.updateCartCampaignOffer({input:i})];case 1:return(e=t.sent())&&e.isSuccess&&e.data&&(this.checkout=new p(e.data,this.countrySettings),i.accepted&&this.step===G.SUCCESS?this.changeStep(G.INFO):this.changeStep(this.step)),[2]}}))}))},this.registerCustomer=function(i){return e(H,void 0,void 0,(function(){var e,s,n,r;return t(this,(function(t){switch(t.label){case 0:return this.checkout.customer?(e=this.checkout.customer,s=e.firstName,n=e.lastName,r=e.email,s&&n&&r?[4,b.register({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:i})]:[3,2]):[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.checkout=c,this.checkoutSettings=d,this.router=g,this.returnPolicy=f,this.privacyPolicy=M,this.termsOfService=_,this.imprint=F,this.shippingPolicy=Z,this.t=B,this.customizationProps=Y,this.mpVM=new I,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new k({currentLocale:O.getCurrentLocale()}),this.init(),s(this)}return Object.defineProperty(M.prototype,"merchantSettings",{get:function(){return new f(O.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"selectedPaymentGatewayIndex",{get:function(){var e=this;return this.paymentGateways.findIndex((function(t){var i;return t.id===(null===(i=e.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"selectedInstallmentIndex",{get:function(){var e,t,i=this;return(null===(t=null===(e=this.installmentInfo)||void 0===e?void 0:e.installmentPrices)||void 0===t?void 0:t.findIndex((function(e){var t;return e.installmentCount===(null===(t=i.cardData)||void 0===t?void 0:t.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=j.getInstance().customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===t?void 0:t.map((function(e){return{label:e.title+" - "+e.addressText,value:e.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"installmentPrice",{get:function(){var e,t,i,s=this;if(this.installmentInfo&&(null===(e=this.cardData)||void 0===e?void 0:e.installmentCount))return null===(i=null===(t=this.installmentInfo.installmentPrices)||void 0===t?void 0:t.find((function(e){var t;return e.installmentCount===(null===(t=s.cardData)||void 0===t?void 0:t.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"finalPrice",{get:function(){return this.step===G.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===L.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"canProceedToShipping",{get:function(){var e,t,i;return(this.isDigitalOnly?null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress:null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValidAddress)&&this.checkout.hasValidCustomerEmail&&(null===(i=this.error)||void 0===i?void 0:i.type)!==L.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"canProceedToInStoreDelivery",{get:function(){var e,t,i;return!!((null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.firstName)&&(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isValidShippingSettings",{get:function(){var e,t=this;return!(!this.isInStoreDelivery&&!this.isDigitalOnly)||this.checkout.shippingSettingsId&&this.checkout.shippingZoneRateId&&(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.some((function(e){return e.shippingSettingsId===t.checkout.shippingSettingsId&&e.shippingZoneRateId===t.checkout.shippingZoneRateId})))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"klarnaPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"adyenPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"ADYEN"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"payPalPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isCustomFlowStripe",{get:function(){var e,t=this.checkout.selectedPaymentGateway;return t&&"STRIPE"===t.code&&(null===(e=t.settings)||void 0===e?void 0:e.find((function(e){return"allow_custom_flow"===e.label&&"1"===e.value})))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"store",{get:function(){return j.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"canPerformPayment",{get:function(){var e,t;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!(null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress),r=!!this.isFree||(!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===o.CREDIT_CARD&&i.type===a.INTERNAL?!!this.isCustomFlowStripe||(!(!this.isKlarna&&!this.isPayPal)||(null===(t=this.cardData)||void 0===t?void 0:t.isValid)):!!i));return s&&n&&r},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===c.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"customerAddresses",{get:function(){var e,t,s=this;return null===(t=null===(e=this.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===t?void 0:t.map((function(e){var t=new g(i({countrySettings:s.countrySettings},e));return t.checkoutSettings=s.checkoutSettings,t.shippingZones=s.shippingZones,t.getValidatedCustomerAddress(),t}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===d.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isEPayKolayEnabled",{get:function(){var e=O.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),M.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},M}();function U(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function K(e){return e&&M.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(G||(G={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.API_ERROR=1]="API_ERROR",e[e.STOCK_ERROR=2]="STOCK_ERROR",e[e.PAYMENT_ERROR=3]="PAYMENT_ERROR",e[e.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",e[e.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR"}(L||(L={}));export{G as CheckoutStep,L as ErrorType,_ as default};
|
|
1
|
+
import{__awaiter as e,__generator as t,__assign as i}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import n from"lodash/cloneDeep";import r from"lodash/sortBy";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasPaymentMethodType as o,IkasPaymentGatewayType as a,IkasOrderShippingMethod as c,IkasCartCreatedBy as d,IkasTransactionStatus as u,IkasCartCampaignOfferStatus as l,IkasCampaignOfferTargetPageType as h}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import{IkasCheckout as p}from"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/region/index.js";import{IkasCustomerAddress as m}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as g}from"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import{IkasMerchantSettings as f}from"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import{IkasOrderCustomer as v}from"../../models/data/order/customer/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as y}from"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import{LocalizedAddressModel as k}from"@ikas/localized-address";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/ikas-address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import S from"./components/credit-card-form/model.js";import b from"../../store/customer/api.js";import P from"../../store/checkout/index.js";import C from"../../store/cart/api.js";import I,{MFS_ELEMENT_ID as A,MFS_SCRIPT_URL as w}from"./modelMasterPass.js";import N from"../../store/product/index.js";import{IkasBaseStore as j}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as O}from"@ikas/storefront-config";import{Analytics as E}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as R,CheckStocksLineInput as x}from"@ikas/storefront-api";import D from"../../models/data/order/address/ikas-localized-order-address.js";import T from"../../store/location/index.js";var G,L,M=/^\d+$/,V="undefined"==typeof localStorage,_=function(){function M(c,d,g,f,M,_,F,Z,B,Y){var H=this;this.storefront=null,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.isEPayKolayPayment=!1,this.step=G.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.adyenResponse=null,this.payPalClientIdResponse=null,this.paypalOrderResponse=null,this.shippingZones=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.showTestModal=!1,this.init=function(){return e(H,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this.countrySettings.waitUntilInitialized()];case 1:return e.sent(),[4,j.getInstance().customerStore.waitUntilInitialized()];case 2:return e.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getCampaignOffer()];case 3:return e.sent(),[4,this.initStep()];case 4:return e.sent(),[2]}}))}))},this.initStep=function(){return e(H,void 0,void 0,(function(){var e,i,s,n,r,o,a;return t(this,(function(t){switch(t.label){case 0:if(O.getIsEditor())return this.step=G.INFO,this.isCheckoutLoaded=!0,[2];if(e=new URLSearchParams(window.location.search),i=e.get("step"),s=e.get("failed"),n=e.get("error"),i){if(this.step=i,this.step===G.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(G.INFO)];if(this.step!==G.PAYMENT||this.canProceedToPayment){if(this.step===G.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(G.INFO)];if(![G.INFO,G.SUCCESS,G.SHIPPING,G.PAYMENT].includes(this.step))return[2,this.changeStep(G.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings?[2,this.changeStep(G.INFO)]:[2,this.changeStep(G.SHIPPING)];this.deliveryMethod="in-store"}}return s&&(this.error={type:L.PAYMENT_ERROR,data:n||null}),this.step!==G.INFO?[3,6]:this.isDigitalOnly?[3,3]:[4,this.getAvailableShippingZones()];case 1:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getShippingCountries()];case 2:t.sent(),this.checkShippingCountries(),t.label=3;case 3:return[4,this.getStockLocations()];case 4:return t.sent(),[4,this.getAvailableStockLocations()];case 5:t.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),t.label=6;case 6:return this.step!==G.SHIPPING||1!==(null===(o=this.checkout.availableShippingMethods)||void 0===o?void 0:o.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=G.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==G.SHIPPING||(null===(a=this.checkout.availableShippingMethods)||void 0===a?void 0:a.length)?this.step!==G.PAYMENT&&this.step!==G.SUCCESS?[3,10]:[4,this.listPaymentGateways()]:(this.error={type:L.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 7:return t.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,9];case 8:t.sent(),t.label=9;case 9:if(!this.paymentGateways.length)return this.error={type:L.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];t.label=10;case 10:return this.step===G.SUCCESS?[3,14]:this.checkout.isComplete?[2,this.changeStep(G.SUCCESS)]:[3,11];case 11:return[4,this.initialStockCheck()];case 12:t.sent(),t.label=13;case 13:return[3,16];case 14:return[4,this.getSuccessTransaction()];case 15:t.sent(),this.successTransaction&&(r=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===r}))),t.label=16;case 16:return this.isCheckoutLoaded=!0,E.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return[4,b.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return e=t.sent(),this.successTransaction=e.isSuccess&&(null===(i=e.data)||void 0===i?void 0:i.length)?e.data[e.data.length-1]:void 0,[2]}}))}))},this.saveCart=function(){return e(H,void 0,void 0,(function(){var e,i,s,n;return t(this,(function(t){switch(t.label){case 0:return e=new R(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(e)];case 1:e=t.sent(),t.label=2;case 2:return this.step!==G.INFO&&this.step!==G.SHIPPING||this.isDigitalOnly||(e.billingAddress=null),this.isDigitalOnly&&(e.shippingAddress=null),[4,C.saveCart({input:e})];case 3:if((null==(i=t.sent())?void 0:i.graphQLErrors)&&i.graphQLErrors.length)throw s=i.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(n=s.extensions)||void 0===n?void 0:n.code)?{type:L.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:L.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return e(H,void 0,void 0,(function(){var e,s,n=this;return t(this,(function(t){return e=i,(s=this.stockLocations.find((function(e){return e.id===n.checkout.stockLocationId})))&&e.shippingAddress&&s.address&&(e.shippingAddress.country=s.address.country,e.shippingAddress.city=s.address.city,e.shippingAddress.state=s.address.state,e.shippingAddress.district=s.address.district,e.shippingAddress.postalCode=s.address.postalCode,e.shippingAddress.addressLine1=s.address.address||"",e.shippingAddress.addressLine2=null),[2,e]}))}))},this.checkStocks=function(){return e(H,void 0,void 0,(function(){var e,i,s,n,r,o,a,c,d,u,l,h;return t(this,(function(t){switch(t.label){case 0:return this.isManualOrder?[2]:(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,P.checkStocks({lines:e.map((function(e){return new x(e)})),stockLocationIdList:(null===(u=O.getStockLocationIds())||void 0===u?void 0:u.length)?O.getStockLocationIds():null})]);case 1:if(!(i=t.sent()).isSuccess)throw{type:L.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(h=null===(l=i.data)||void 0===l?void 0:l.lines)||void 0===h?void 0:h.filter((function(e){return!e.isAvailable})))?void 0:s.length){for(n=[],r=function(e){var t=o.checkout.items.find((function(t){return t.variant.id===e.variantId}));t&&n.push({item:t,stockCount:e.stockCount})},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:L.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return e(H,void 0,void 0,(function(){return t(this,(function(e){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return e(H,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:e=0,s=i,t.label=1;case 1:return e<s.length?(n=s[e],[4,j.getInstance().cartStore.changeItemQuantity(n.item,n.stockCount<0?0:n.stockCount)]):[3,4];case 2:t.sent(),t.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,P.getAvailableShippingCountries({salesChannelId:O.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return O.getPickupStockLocationIds()?[4,P.listStockLocation({id:{in:O.getPickupStockLocationIds()}})]:[3,2];case 1:if(!(e=t.sent()).isSuccess||!(null===(i=e.data)||void 0===i?void 0:i.length))return this.error={type:L.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,t.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return O.getPickupStockLocationIds()?(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,P.getAvailableStockLocations({lines:e.map((function(e){return new x(e)})),stockLocationIdList:O.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=t.sent()).isSuccess)return this.error={type:L.API_ERROR},[2];this.availableStockLocations=i.data||[],t.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var e;(null===(e=H.shippingCountryIds)||void 0===e?void 0:e.length)||(H.error={type:L.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){"address"===e&&(H.checkout.stockLocationId=null),H.deliveryMethod=e,H.isErrorsVisible=!1},this.initialStockCheck=function(){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return t.sent(),[3,3];case 2:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:L.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return e(H,void 0,void 0,(function(){var e,i,s,n,o,a,c,d,u,l,h=this;return t(this,(function(t){switch(t.label){case 0:return e="local"===process.env.NEXT_PUBLIC_ENV,i=O.getPaymentGateways().map((function(e){return e.id})),[4,P.listPaymentGateway({id:e?void 0:{in:i},locale:O.getCurrentLocale(),transactionAmount:this.checkout.totalFinalPrice})];case 1:return(s=t.sent()).isSuccess&&(null===(u=s.data)||void 0===u?void 0:u.length)?(n=s.data,this.step===G.PAYMENT&&(n=n.filter((function(e){var t;return!(null===(t=e.supportedCurrencies)||void 0===t?void 0:t.length)||e.supportedCurrencies.includes(h.checkout.currencyCode)})),(o=null===(l=this.checkout.shippingAddress)||void 0===l?void 0:l.country)&&o.iso2&&(n=n.filter((function(e){var t;return!(null===(t=e.availableCountries)||void 0===t?void 0:t.length)||e.availableCountries.includes(o.iso2||"")})))),a=[],r(O.getPaymentGateways(),"order").forEach((function(e){var t=null==n?void 0:n.find((function(t){return t.id===e.id}));t&&a.push(t)})),this.paymentGateways=e?n:a,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),this.step===G.PAYMENT&&(c=n.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id=A,d.src=w,d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout,store:j.getInstance()})},document.head.appendChild(d)),[2]):(this.error={type:L.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return e(H,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:return[4,P.retrieveInstallmentInfo(i)];case 1:return e=t.sent(),s=e.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(e,t){return(e.installmentCount||-1)>(t.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var e;H.store.customerStore.customer?(null===(e=H.customerAddresses)||void 0===e||e.forEach((function(e){e.checkoutSettings=H.checkoutSettings,e.shippingZones=H.shippingZones})),H.checkout.customer=new v(H.store.customerStore.customer)):H.checkout.customer=new v(H.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){H.checkout.shippingAddress&&(H.checkout.shippingAddress.checkoutSettings=H.checkoutSettings,H.checkout.shippingAddress.shippingZones=H.shippingZones,H.checkout.shippingAddress.countrySettings=H.countrySettings,H.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){H.checkout.billingAddress&&(H.checkout.billingAddress.checkoutSettings=H.checkoutSettings,H.checkout.billingAddress.shippingZones=H.shippingZones,H.checkout.billingAddress.countrySettings=H.countrySettings,H.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!H.isDigitalOnly)if(H.isInStoreDelivery)H.setCheckoutShippingAddressSettings();else if(H.checkout.shippingAddress){if(H.store.customerStore.customer){var e=null==(t=H.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=H.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return H.onSelectedShippingAddressIdChange(e.id||"-1"),void H.setCheckoutShippingAddressSettings()}H.checkout.shippingAddress=new D(n(H.checkout.shippingAddress)||{}),H.setCheckoutShippingAddressSettings()}else if(H.store.customerStore.customer){var t=H.customerAddresses;H.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else H.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(H.useDifferentAddress=!!localStorage.getItem("sAddr"),H.checkout.billingAddress){if(H.store.customerStore.customer){var e=null==(t=H.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=H.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return H.onSelectedBillingAddressIdChange(e.id||"-1"),void H.setCheckoutBillingAddressSettings()}H.checkout.billingAddress=new D(n(H.checkout.billingAddress)||{}),H.setCheckoutBillingAddressSettings()}else if(H.store.customerStore.customer){var t=H.customerAddresses;H.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||H.useDifferentAddress||!H.checkout.shippingAddress||H.isInStoreDelivery||(H.checkout.billingAddress=new D(n(H.checkout.shippingAddress)),H.setCheckoutBillingAddressSettings())}else H.onSelectedBillingAddressIdChange("-1"),H.useDifferentAddress||!H.checkout.shippingAddress||H.isInStoreDelivery||(H.checkout.billingAddress=new D(n(H.checkout.shippingAddress)),H.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(i){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=i.shippingSettingsId,this.checkout.shippingZoneRateId=i.shippingZoneRateId,[4,this.saveCart()]);case 1:return(e=t.sent())&&(this.checkout=new p(e,this.countrySettings)),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings,this.checkout.shippingAddress.shippingZones=this.shippingZones),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return e(H,void 0,void 0,(function(){return t(this,(function(e){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return e(H,void 0,void 0,(function(){var e,s,n,r,o,a;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,5,,6]),[4,C.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(e=t.sent()).isSuccess&&e.data?(s=e.data,n=null===(a=null===(o=this.cardData)||void 0===o?void 0:o.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.couponError=null,this.step===G.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{binNumber:this.mpVM.selectedCard.Value1.slice(0,6),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:s.totalFinalPrice}})]:[3,3]):[3,4];case 2:t.sent(),t.label=3;case 3:s&&(r=this.checkout,this.checkout=new p(i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway}),this.countrySettings)),t.label=4;case 4:return e.isSuccess||(this.couponError=e.errorCodes[0]),[3,6];case 5:return t.sent(),[3,6];case 6:return[2]}}))}))},this.getAvailableShippingZones=function(){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,T.getAvailableShippingZones({salesChannelId:O.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingZones=e.data||null,[3,3];case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(e){var t;if(H.selectedShippingAddressId=e,"-1"===e)H.checkout.shippingAddress=new D,H.checkout.shippingAddress.countrySettings=H.countrySettings;else{var i=null===(t=H.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(H.checkout.shippingAddress=new D(i),H.checkout.shippingAddress.countrySettings=H.countrySettings)}H.checkout.shippingAddress&&(H.checkout.shippingAddress.checkoutSettings=H.checkoutSettings,H.checkout.shippingAddress.shippingZones=H.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(H.selectedBillingAddressId=e,"-1"===e)H.checkout.billingAddress=new D,H.checkout.billingAddress.countrySettings=H.countrySettings;else{var i=null===(t=H.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(H.checkout.billingAddress=new D(i),H.checkout.billingAddress.countrySettings=H.countrySettings)}H.checkout.billingAddress&&(H.checkout.billingAddress.checkoutSettings=H.checkoutSettings,H.checkout.billingAddress.shippingZones=H.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){H.isTermsAndConditionsChecked=e},this.onCardNumberChange=function(e){if(H.cardData&&(!(e.length>H.cardData.cardNumber.length)||K(e))){var t=(H.cardData.cardNumber||"").split(" ").join(""),i=e.split(" ").join("");i.length>16||(t.length<6&&i.length>=6&&!H.installmentInfo?H.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:H.checkout.selectedPaymentGateway.id,price:H.checkout.totalFinalPrice}}):i.length<6&&t.length>i.length&&(H.cardData.installmentCount=1,H.installmentInfo=void 0),H.cardData.cardNumber=U(i,4).join(" "))}},this.onCardHolderNameChange=function(e){H.cardData&&(H.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(H.cardData&&(!(e.length>H.cardData.expirationDate.length)||K(e))){if(0===(null===(t=H.cardData.expirationDate)||void 0===t?void 0:t.length)){var i=e.replace(".","/").split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(H.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&4===n.length){o=parseInt(s),r=parseInt(n.slice(2));if(!isNaN(r)&&!isNaN(o))return void(H.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&2===n.length){var a=parseInt(s),c=parseInt(n);o=a<=12?a:c,r=c>12?c:a;if(!isNaN(r)&&!isNaN(o))return void(H.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(H.cardData.expirationDate=U(d,2).join(" / "))}},this.onCvcChange=function(e){H.cardData&&(e.length>H.cardData.cvv.length&&!K(e)||e.length>4||(H.cardData.cvv=e))},this.saveAddress=function(s){return e(H,void 0,void 0,(function(){var e,r,o,a,c,d,u,l,h,p,g,f,v=this;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(e="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(h=this.customerAddresses)||void 0===h?void 0:h.find((function(t){return t.id===(null==e?void 0:e.id)})))?[2]:(r=null===(p=this.customerAddresses)||void 0===p?void 0:p.map((function(e){return e.id})),o=new m(i(i({},e),{title:this.addressTitle||this.t("checkout-page:newAddress")})),(a=n(this.store.customerStore.customer)).addresses||(a.addresses=[]),a.addresses.push(o),[4,this.store.customerStore.saveCustomer(a)])):[3,2];case 1:t.sent(),null===(g=this.customerAddresses)||void 0===g||g.forEach((function(e){e.checkoutSettings=v.checkoutSettings,e.shippingZones=v.shippingZones})),c=null===(f=this.customerAddresses)||void 0===f?void 0:f.map((function(e){return e.id})),d=null==c?void 0:c.filter((function(e){return!(null==r?void 0:r.includes(e))})),u=(null==d?void 0:d.length)?d[0]:void 0,"shipping"===s?(this.checkout.shippingAddress.id=u||"",this.selectedShippingAddressId=u||"-1"):(this.checkout.billingAddress.id=u||"",this.selectedBillingAddressId=u||"-1"),t.label=2;case 2:return[3,4];case 3:return l=t.sent(),console.error(l),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){H.router.push("/cart")},this.onBackToShoppingClick=function(){H.router.push("/")},this.onGoToLoginClick=function(){H.router.push("/account/login")},this.onProceedToShippingClick=function(){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2]}else if(!this.canProceedToInStoreDelivery)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:t.sent(),t.label=3;case 3:return[4,this.checkStocks()];case 4:return t.sent(),[4,this.saveCart()];case 5:return t.sent(),"address"===this.deliveryMethod?this.changeStep(G.SHIPPING):this.changeStep(G.PAYMENT),[3,7];case 6:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:L.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return t.sent(),[4,this.saveCart()];case 3:return t.sent(),this.changeStep(G.PAYMENT),[3,5];case 4:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:L.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return t.sent(),[4,this.saveCart()];case 3:return t.sent(),this.error=void 0,this.changeStep(G.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:L.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!H.canPerformPayment||(H.isErrorsVisible=!0,!1)},this.onCompletePaymentClick=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return this.canPerformPayment?(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isKlarna?[4,this.saveCart()]:[3,2]):(this.isErrorsVisible=!0,[2]);case 1:return t.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return t.trys.push([2,8,,9]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return t.sent(),"address"===this.deliveryMethod&&this.useDifferentAddress?[4,this.saveAddress("billing")]:[3,5];case 4:t.sent(),t.label=5;case 5:return[4,this.saveCart()];case 6:return t.sent(),this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):this.isPayPal?[2]:[4,this.createSaleTransaction()];case 7:return t.sent(),[3,9];case 8:return void 0!==typeof(i=t.sent()).type?this.error=i:this.error={type:L.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return!this.canProceedToPayment||this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked?(this.isErrorsVisible=!0,[2]):this.isKlarna?[4,this.saveCart()]:[3,2];case 1:return t.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return t.trys.push([2,6,,7]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return t.sent(),[4,this.saveCart()];case 4:return t.sent(),this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):this.isPayPal?[2]:[4,this.createSaleTransaction()];case 5:return t.sent(),[3,7];case 6:return(i=t.sent()).type?this.error=i:this.error={type:L.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return e(H,void 0,void 0,(function(){var e,i,s,n,r,c,d,l,h,p,m,g,f,v,y;return t(this,(function(t){switch(t.label){case 0:return i=this.mpVM.selectedCard,!this.isFree&&i&&(null===(l=this.mpVM.selectedCard)||void 0===l?void 0:l.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(e=n),void 0===(null===(h=this.cardData)||void 0===h?void 0:h.installmentCount)?[2]:[4,P.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:e,savedCardName:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name},paymentGatewayId:null===(m=this.mpVM.selectedCard)||void 0===m?void 0:m.paymentGatewayId,paymentMethodDetail:{cardNumber:this.mpVM.selectedCard.Value1,cardHolderName:this.mpVM.selectedCard.Name,cvv:this.mpVM.selectedCard.Value2,expiredMonth:11,expiredYear:11,installmentCount:this.cardData.installmentCount,threeDSecure:!!(null===(g=this.cardData)||void 0===g?void 0:g.threeDSecure)}}})]):[3,2];case 1:return s=t.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,P.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:this.isFree?void 0:i&&e?{phoneNumber:e,savedCardName:null===(f=this.mpVM.selectedCard)||void 0===f?void 0:f.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:this.isFree||i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===o.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===a.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})]:[2];case 3:s=t.sent(),t.label=4;case 4:return r=null===(v=null==s?void 0:s.data)||void 0===v?void 0:v.transactionStatus,c=r&&[u.SUCCESS,u.AUTHORIZED].includes(r),d=r===u.PENDING,c?[4,this.getSuccessTransaction()]:[3,7];case 5:return t.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return t.sent(),[3,8];case 7:if(!d||!(null===(y=null==s?void 0:s.data)||void 0===y?void 0:y.returnSlug))throw{data:s.firstErrorMessage,type:L.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,t.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return localStorage.removeItem("sAddr"),(null===(e=this.checkout.customer)||void 0===e?void 0:e.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.changeStep(G.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){H.changeStep(G.INFO)},this.onBackToShippingClick=function(){H.changeStep(G.SHIPPING)},this.setCustomerConsentGranted=function(e){H.checkout.customer&&(H.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(e){H.useDifferentAddress=e,H.useDifferentAddress?(localStorage.setItem("sAddr","1"),H.checkout.billingAddress=H.checkout.billingAddress||new D,H.checkout.billingAddress.countrySettings=H.countrySettings):(localStorage.removeItem("sAddr"),H.checkout.billingAddress=H.checkout.shippingAddress)},this.setShouldSaveAddress=function(e){H.shouldSaveAddress=e},this.setAddressTitle=function(e){H.addressTitle=e},this.reInitPaymentMethod=function(){return e(H,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return this.checkout.selectedPaymentGateway?this.isCustomFlowStripe?[4,this.createStripePaymentIntent(this.checkout.selectedPaymentGateway)]:[3,2]:[3,6];case 1:e.sent(),e.label=2;case 2:return this.isKlarna&&window.location.reload(),this.isAdyen?[4,this.createAdyenClientToken(this.checkout.selectedPaymentGateway)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.isPayPal?[4,this.getPayPalClientId(this.checkout.selectedPaymentGateway)]:[3,6];case 5:e.sent(),e.label=6;case 6:return[2]}}))}))},this.createStripePaymentIntent=function(i){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,P.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.stripeResponse=e.data),[2]}}))}))},this.createKlarnaClientToken=function(i){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,P.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.klarnaResponse=e.data),[2]}}))}))},this.createAdyenClientToken=function(i){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,P.createAdyenClientToken({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.adyenResponse=e.data),[2]}}))}))},this.getPayPalClientId=function(i){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,P.getPayPalClientId({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.payPalClientIdResponse=e.data),[2]}}))}))},this.setPaymentGateway=function(i){return e(H,void 0,void 0,(function(){var e,s;return t(this,(function(t){switch(t.label){case 0:return this.paymentGateways.length?"STRIPE"!==(e=this.paymentGateways[i]).code||!(null===(s=e.settings)||void 0===s?void 0:s.find((function(e){return"allow_custom_flow"===e.label&&"1"===e.value})))||this.stripeResponse?[3,2]:[4,this.createStripePaymentIntent(e)]:[2];case 1:t.sent(),t.label=2;case 2:return"KLARNA"!==e.code||this.klarnaResponse?[3,4]:[4,this.createKlarnaClientToken(e)];case 3:t.sent(),t.label=4;case 4:return"ADYEN"!==e.code||this.adyenResponse?[3,6]:[4,this.createAdyenClientToken(e)];case 5:t.sent(),t.label=6;case 6:return"PAYPAL"!==e.code||this.payPalClientIdResponse?[3,8]:[4,this.getPayPalClientId(e)];case 7:t.sent(),t.label=8;case 8:return this.checkout.selectedPaymentGateway=e,this.step!==G.SUCCESS&&(e.paymentMethodType===o.CREDIT_CARD&&e.type===a.INTERNAL&&(this.cardData=new S,e.masterPassClientId&&(console.log("called 1511 ikas log"),this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store}))),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(e){H.cardData&&(H.cardData.installmentCount=e)},this.changeStep=function(i){return e(H,void 0,void 0,(function(){return t(this,(function(e){return V||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return e(H,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return e.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(e){H.isContactModalVisible=e},this.getCampaignOfferProducts=function(i){return e(H,void 0,void 0,(function(){var e,s,n,r;return t(this,(function(o){switch(o.label){case 0:if(!this.checkout.campaignOffers||!this.checkout.campaignOffers.length)return[3,4];if(e=this.checkout.campaignOffers.filter((function(e){var t;return e.status===l.WAITING_FOR_ACTION&&(null===(t=e.campaignOffer)||void 0===t?void 0:t.targetPageTypes.some((function(e){return e===i})))})),!e.length)return[3,4];s=function(i){var s,n,r,o,a;return t(this,(function(t){switch(t.label){case 0:return(s=e[i]).campaignOffer&&(n=s.campaignOffer.offers.find((function(e){return e.id===s.campaignOfferProductId})))?[4,N.searchProducts({input:{productIdList:[n.productId]}})]:[3,2];case 1:if((r=t.sent()).isSuccess&&r.data&&r.data.data&&r.data.data.length&&(o=r.data.data[0],a=[],n.excludedVariantIdList&&n.excludedVariantIdList.length?o.variants.map((function(e){var t;e.hasStock&&!(null===(t=n.excludedVariantIdList)||void 0===t?void 0:t.some((function(t){return t===e.id})))&&a.push(e)})):a.push.apply(a,o.variants.filter((function(e){return e.hasStock}))),a.length))return[2,{value:{product:new y(o),variants:a,campaignOffer:s,offer:n}}];t.label=2;case 2:return[2]}}))},n=0,o.label=1;case 1:return n<e.length?[5,s(n)]:[3,4];case 2:if("object"==typeof(r=o.sent()))return[2,r.value];o.label=3;case 3:return n++,[3,1];case 4:return[2,void 0]}}))}))},this.getCampaignOffer=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return e=this,[4,this.getCampaignOfferProducts(h.CHECKOUT)];case 1:return e.checkoutCampaignOffer=t.sent(),i=this,[4,this.getCampaignOfferProducts(h.POST_CHECKOUT)];case 2:return i.postCheckoutCampaignOffer=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.isCheckoutLoaded=!1,[4,C.updateCartCampaignOffer({input:i})];case 1:return(e=t.sent())&&e.isSuccess&&e.data&&(this.checkout=new p(e.data,this.countrySettings),i.accepted&&this.step===G.SUCCESS?this.changeStep(G.INFO):this.changeStep(this.step)),[2]}}))}))},this.registerCustomer=function(i){return e(H,void 0,void 0,(function(){var e,s,n,r;return t(this,(function(t){switch(t.label){case 0:return this.checkout.customer?(e=this.checkout.customer,s=e.firstName,n=e.lastName,r=e.email,s&&n&&r?[4,b.register({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:i})]:[3,2]):[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.checkout=c,this.checkoutSettings=d,this.router=g,this.returnPolicy=f,this.privacyPolicy=M,this.termsOfService=_,this.imprint=F,this.shippingPolicy=Z,this.t=B,this.customizationProps=Y,this.mpVM=new I,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new k({currentLocale:O.getCurrentLocale()}),this.init(),s(this)}return Object.defineProperty(M.prototype,"merchantSettings",{get:function(){return new f(O.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"selectedPaymentGatewayIndex",{get:function(){var e=this;return this.paymentGateways.findIndex((function(t){var i;return t.id===(null===(i=e.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"selectedInstallmentIndex",{get:function(){var e,t,i=this;return(null===(t=null===(e=this.installmentInfo)||void 0===e?void 0:e.installmentPrices)||void 0===t?void 0:t.findIndex((function(e){var t;return e.installmentCount===(null===(t=i.cardData)||void 0===t?void 0:t.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=j.getInstance().customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===t?void 0:t.map((function(e){return{label:e.title+" - "+e.addressText,value:e.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"installmentPrice",{get:function(){var e,t,i,s=this;if(this.installmentInfo&&(null===(e=this.cardData)||void 0===e?void 0:e.installmentCount))return null===(i=null===(t=this.installmentInfo.installmentPrices)||void 0===t?void 0:t.find((function(e){var t;return e.installmentCount===(null===(t=s.cardData)||void 0===t?void 0:t.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"finalPrice",{get:function(){return this.step===G.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===L.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"canProceedToShipping",{get:function(){var e,t,i;return(this.isDigitalOnly?null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress:null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValidAddress)&&this.checkout.hasValidCustomerEmail&&(null===(i=this.error)||void 0===i?void 0:i.type)!==L.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"canProceedToInStoreDelivery",{get:function(){var e,t,i;return!!((null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.firstName)&&(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isValidShippingSettings",{get:function(){var e,t=this;return!(!this.isInStoreDelivery&&!this.isDigitalOnly)||this.checkout.shippingSettingsId&&this.checkout.shippingZoneRateId&&(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.some((function(e){return e.shippingSettingsId===t.checkout.shippingSettingsId&&e.shippingZoneRateId===t.checkout.shippingZoneRateId})))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"klarnaPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"adyenPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"ADYEN"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"payPalPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isCustomFlowStripe",{get:function(){var e,t=this.checkout.selectedPaymentGateway;return t&&"STRIPE"===t.code&&(null===(e=t.settings)||void 0===e?void 0:e.find((function(e){return"allow_custom_flow"===e.label&&"1"===e.value})))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"store",{get:function(){return j.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"canPerformPayment",{get:function(){var e,t;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!(null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress),r=!!this.isFree||(!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===o.CREDIT_CARD&&i.type===a.INTERNAL?!!this.isCustomFlowStripe||(!(!this.isKlarna&&!this.isPayPal)||(null===(t=this.cardData)||void 0===t?void 0:t.isValid)):!!i));return s&&n&&r},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===c.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"customerAddresses",{get:function(){var e,t,s=this;return null===(t=null===(e=this.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===t?void 0:t.map((function(e){var t=new g(i({countrySettings:s.countrySettings},e));return t.checkoutSettings=s.checkoutSettings,t.shippingZones=s.shippingZones,t.getValidatedCustomerAddress(),t}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===d.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isEPayKolayEnabled",{get:function(){var e=O.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isPoweredByHidden",{get:function(){var e=O.getCustom();return!!e&&!!e.hidePoweredBy},enumerable:!1,configurable:!0}),M.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},M}();function U(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function K(e){return e&&M.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(G||(G={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.API_ERROR=1]="API_ERROR",e[e.STOCK_ERROR=2]="STOCK_ERROR",e[e.PAYMENT_ERROR=3]="PAYMENT_ERROR",e[e.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",e[e.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR"}(L||(L={}));export{G as CheckoutStep,L as ErrorType,_ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as
|
|
1
|
+
import{__rest as e,__assign as r}from'./../../ext/tslib/tslib.es6.js';import t,{useState as o}from"react";import i from"next/link";import{observer as n}from"mobx-react-lite";import{IkasBaseStore as s}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as a}from"@ikas/storefront-config";var f=n((function(n){var f,c=n.prefetch,m=e(n,["prefetch"]),l=o(!1),p=l[0],u=l[1],d=s.getInstance();if(t.useEffect((function(){var e="string"==typeof m.href,r=d.spaLinksDisabled;u(r&&e)}),[d.spaLinksDisabled]),p){var h=null===(f=a.getCurrentRouting())||void 0===f?void 0:f.path,b=m.href,v=b;return h&&(v=b.replace("/","/".concat(h,"/"))),t.createElement("a",{href:v},m.children)}return t.createElement(i,r({prefetch:null!=c&&c},m),m.children)}));export{f as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "4.7.
|
|
3
|
+
"version": "4.7.9",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "ikas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"build": "rm -rf build && rollup -c"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@ikas/storefront-api": "^4.7.
|
|
21
|
-
"@ikas/storefront-config": "^4.7.
|
|
22
|
-
"@ikas/storefront-model-functions": "^4.7.
|
|
23
|
-
"@ikas/storefront-models": "^4.7.
|
|
24
|
-
"@ikas/storefront-providers": "^4.7.
|
|
20
|
+
"@ikas/storefront-api": "^4.7.9",
|
|
21
|
+
"@ikas/storefront-config": "^4.7.9",
|
|
22
|
+
"@ikas/storefront-model-functions": "^4.7.9",
|
|
23
|
+
"@ikas/storefront-models": "^4.7.9",
|
|
24
|
+
"@ikas/storefront-providers": "^4.7.9",
|
|
25
25
|
"@ikas/localized-address": "^1.0.0-beta.3",
|
|
26
26
|
"@adyen/adyen-web": "^5.28.2",
|
|
27
27
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@ikas/localized-address": "^1.0.0-beta.3",
|
|
58
|
-
"@ikas/storefront-api": "^4.7.
|
|
59
|
-
"@ikas/storefront-config": "^4.7.
|
|
60
|
-
"@ikas/storefront-model-functions": "^4.7.
|
|
61
|
-
"@ikas/storefront-models": "^4.7.
|
|
62
|
-
"@ikas/storefront-providers": "^4.7.
|
|
58
|
+
"@ikas/storefront-api": "^4.7.9",
|
|
59
|
+
"@ikas/storefront-config": "^4.7.9",
|
|
60
|
+
"@ikas/storefront-model-functions": "^4.7.9",
|
|
61
|
+
"@ikas/storefront-models": "^4.7.9",
|
|
62
|
+
"@ikas/storefront-providers": "^4.7.9",
|
|
63
63
|
"mobx": "^6.1.3",
|
|
64
64
|
"mobx-react-lite": "^3.1.5",
|
|
65
65
|
"next": "12.2.0",
|