@ikas/storefront 4.12.0-beta.8 → 4.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/analytics/facebookPixel.js +1 -1
- package/build/components/checkout/components/offer-product/index.js +1 -1
- package/build/components/checkout/index.js +1 -1
- package/build/components/checkout/model.d.ts +11 -12
- package/build/components/checkout/model.js +1 -1
- package/build/components/checkout/steps/step-success/index.js +1 -1
- package/build/components/page/head.js +1 -1
- package/build/components/page/index.js +1 -1
- package/build/models/data/order/line-item/variant/bundle-product/index.d.ts +1 -0
- package/build/models/data/order/line-item/variant/bundle-product/index.js +1 -1
- package/build/models/data/product/index.js +1 -1
- package/build/models/data/product/variant/bundle-settings/bundle-product/index.d.ts +1 -0
- package/build/models/data/product/variant/bundle-settings/bundle-product/index.js +1 -1
- package/build/models/data/product/variant/index.d.ts +2 -0
- package/build/models/data/product/variant/index.js +1 -1
- package/build/models/ui/product-list/index.d.ts +1 -0
- package/build/models/ui/product-list/index.js +1 -1
- package/build/models/ui/validator/form/login.d.ts +7 -4
- package/build/models/ui/validator/form/login.js +1 -1
- package/build/page-data-init/index.js +1 -1
- package/build/store/cart/index.d.ts +3 -1
- package/build/store/cart/index.js +1 -1
- package/build/store/customer/index.d.ts +9 -1
- package/build/store/customer/index.js +1 -1
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
import{makeAutoObservable as t}from"mobx";import{IkasStorefrontConfig as n}from"@ikas/storefront-config";var e="undefined"==typeof window,r=function(){function r(){t(this)}return Object.defineProperty(r,"fbpId",{get:function(){return n.getFbpId()},enumerable:!1,configurable:!0}),r.productView=function(t){try{return void(!e&&this.fbpId&&window.fbq&&window.fbq("track","ViewContent",(n=t,{content_name:n.name,content_category:n.categories.length>0?n.categories[0].path.map((function(t){return t.name})).join(" > "):"",content_ids:[n.selectedVariant.id],content_type:"product",value:n.selectedVariant.price.finalPrice,currency:""===n.selectedVariant.price.currency?"TRY":n.selectedVariant.price.currency})))}catch(t){console.error(t)}var n},r.addToCart=function(t,n,r){try{return void(!e&&this.fbpId&&window.fbq&&window.fbq("track","AddToCart",function(t,n){var e,r=[];t.variant.categories&&(null===(
|
|
1
|
+
import{makeAutoObservable as t}from"mobx";import{IkasStorefrontConfig as n}from"@ikas/storefront-config";var e="undefined"==typeof window,r=function(){function r(){t(this)}return Object.defineProperty(r,"fbpId",{get:function(){return n.getFbpId()},enumerable:!1,configurable:!0}),r.productView=function(t){try{return void(!e&&this.fbpId&&window.fbq&&window.fbq("track","ViewContent",(n=t,{content_name:n.name,content_category:n.categories.length>0?n.categories[0].path.map((function(t){return t.name})).join(" > "):"",content_ids:[n.selectedVariant.id],content_type:"product",value:n.selectedVariant.price.finalPrice,currency:""===n.selectedVariant.price.currency?"TRY":n.selectedVariant.price.currency})))}catch(t){console.error(t)}var n},r.addToCart=function(t,n,r){try{return void(!e&&this.fbpId&&window.fbq&&window.fbq("track","AddToCart",function(t,n){var e,r,o=[];(null===(e=t.variant.categories)||void 0===e?void 0:e.length)&&(null===(r=t.variant.categories[0].categoryPath)||void 0===r||r.map((function(t){return o.push(t.name)}))),t.variant.categories&&t.variant.categories.length>0&&o.push(t.variant.categories[0].name);var i=o.length>0?o.join(" > "):"";return{content_name:t.variant.name,content_category:i,content_ids:[t.variant.id],content_type:"product",value:t.finalPrice,currency:t.currencyCode}}(t),{eventID:r}))}catch(t){console.error(t)}},r.beginCheckout=function(t){try{return void(!e&&this.fbpId&&window.fbq&&window.fbq("track","InitiateCheckout",o(t)))}catch(t){console.error(t)}},r.purchase=function(t,n){try{return void(!e&&this.fbpId&&window.fbq&&window.fbq("track","Purchase",o(t),{eventID:n}))}catch(t){console.error(t)}},r.addToWishlist=function(t){try{return void(!e&&this.fbpId&&window.fbq&&window.fbq("track","AddToWishlist",{content_ids:[t]}))}catch(t){console.error(t)}},r.search=function(t){try{return void(!e&&this.fbpId&&window.fbq&&window.fbq("track","Search",{search_string:t}))}catch(t){console.error(t)}},r.completeRegistration=function(){try{return void(!e&&this.fbpId&&window.fbq&&window.fbq("track","CompleteRegistration",{status:!0,value:0,currency:"TRY"}))}catch(t){console.error(t)}},r.viewCart=function(t){try{return void(!e&&this.fbpId&&window.fbq&&window.fbq("track","ViewCart",function(t){var n=[],e=[];return t.items.map((function(t){n.push(t.variant.id||""),e.push({id:t.variant.id,quantity:t.quantity})})),{contents:e,content_type:"product_group",content_ids:n,currency:t.items[0].currencyCode,value:t.totalPrice,num_items:t.items.length}}(t)))}catch(t){console.error(t)}},r.viewCategory=function(t){try{return void(!e&&this.fbpId&&window.fbq&&window.fbq("track","ViewCategory",{content_name:t}))}catch(t){console.error(t)}},r.contactForm=function(){try{return void(!e&&this.fbpId&&window.fbq&&window.fbq("track","ContactForm",{}))}catch(t){console.error(t)}},r}();function o(t){var n=[],e=[];return t.items.map((function(t){n.push(t.variant.id||""),e.push({id:t.variant.id,quantity:t.quantity})})),{contents:e,content_category:"",content_type:"product",content_ids:n,currency:t.items[0].currencyCode,value:t.totalFinalPrice,num_items:t.items.length}}export{r as FacebookPixel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import{observer as t}from"mobx-react-lite";import{Button as a}from"../button/index.js";import
|
|
1
|
+
import*as e from"react";import{observer as t}from"mobx-react-lite";import{Button as a}from"../button/index.js";import n from"./select/index.js";import r from"../svg/cross.js";import{useTranslation as i}from"../../../../utils/i18n.js";import c from"./style.module.scss.js";var o=function(t){var a=t.seconds,n=t.onFinish,r=i().t,o=e.useState(a),s=o[0],m=o[1];return e.useEffect((function(){m(a)}),[a]),e.useEffect((function(){var e=setInterval((function(){s>0?m(s-1):(clearInterval(e),n())}),1e3);return function(){return clearInterval(e)}}),[s]),e.createElement("div",{className:c.CountdownContainer},e.createElement("div",{className:c.CountdownText},r("checkout-page:timeRemaining",{value:l(s)})))},l=function(e){var t=Math.floor(e/60/60),a=Math.floor(e/60)-60*t,n=e%60;return 0!==t?t.toString().padStart(2,"0")+":":a.toString().padStart(2,"0")+":"+n.toString().padStart(2,"0")},s=t((function(t){var l=t.vm,s=t.campaignOffer,m=i().t,d=s.product,u=e.useMemo((function(){var e,t,a,n,r,i=null===(e=d.selectedVariant.images)||void 0===e?void 0:e.filter((function(e){return!e.isVideo}));return(null===(t=d.selectedVariant.mainImage)||void 0===t?void 0:t.isVideo)&&(null==i?void 0:i.length)?null===(a=i[0].image)||void 0===a?void 0:a.thumbnailSrc:null===(r=null===(n=d.selectedVariant.mainImage)||void 0===n?void 0:n.image)||void 0===r?void 0:r.thumbnailSrc}),[d.selectedVariant]),f=e.useMemo((function(){if(!s.offer.countdownMinutes||!s.campaignOffer.offerStartDate)return 0;var e=Math.round(((new Date).getTime()-new Date(s.campaignOffer.offerStartDate).getTime())/1e3);return e>60*s.offer.countdownMinutes?0:60*s.offer.countdownMinutes-e}),[s]),v=function(e){l.updateCartCampaignOffer({accepted:e,cartId:l.checkout.id,campaignOfferId:s.campaignOffer.campaignOfferId,campaignOfferProductId:s.offer.id,productId:s.offer.productId,variantId:d.selectedVariant.id})},p=function(){v(!1)};return e.createElement("div",{className:c.Container},s.offer.countdownMinutes&&e.createElement(o,{seconds:f,onFinish:p}),e.createElement("div",{className:c.ContentContainer},e.createElement("div",{className:c.Header},e.createElement("div",{className:c.Title},s.offer.title),e.createElement("div",{className:c.RejectButton,onClick:p},e.createElement(r,null))),e.createElement("div",{className:c.ProductContainer},e.createElement("div",{className:c.ImageContainer},e.createElement("img",{className:c.Image,src:u})),e.createElement("div",{className:c.ProductDetails},e.createElement("div",{className:c.ProductName},d.name),d.hasVariant&&1===d.variants.length&&e.createElement("div",{className:c.VariantName},d.selectedVariant.variantValues.map((function(e){return e.name})).join(", ")),d.brand&&e.createElement("div",{className:c.Brand},d.brand.name),e.createElement("div",{className:c.ProductPrice},d.selectedVariant.price.hasDiscount&&e.createElement("span",{className:c.Discount},d.selectedVariant.price.formattedSellPrice," "),d.selectedVariant.price.formattedFinalPrice),e.createElement("div",{className:c.Actions},d.variants.length>1&&e.createElement(n,{value:d.selectedVariant.id,onSelectChange:function(e){var t=null;d.displayedVariantTypes.forEach((function(a){a.displayedVariantValues.forEach((function(a){a.variant.id===e&&(t=a.variantValue)}))})),t&&d.selectVariantValue(t,!0)},options:d.variants.map((function(e){return{label:e.variantValues.map((function(e){return e.name})).join(", "),value:e.id}}))}),e.createElement(a,{style:{width:"100%",height:44,fontSize:14},text:m("checkout-page:actions.addToCart"),onClick:function(){v(!0)}}))))))}));export{s as default};
|
|
@@ -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 n from"react-tooltip";import s,{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 u from"./steps/step-info/index.js";import{CheckoutStepShipping as p}from"./steps/step-shipping/index.js";import{CheckoutStepPayment as v}from"./steps/step-payment/index.js";import{CouponErrorCode as h,Coupon as g,CartSummary as y}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 E}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/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/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 f}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 k}from"./steps/step-success/index.js";import{Modal as x}from"./components/modal/index.js";import j from"./components/master-pass/modal-otp/index.js";import C from"./components/master-pass/modal-response/index.js";import b from"./components/master-pass/modal-success/index.js";import{Image as N}from"../image/index.js";import P,{Step as F}from"./components/step-container/index.js";import{StockError as T}from"./components/error/stock-error/index.js";import{FullscreenLoading as S}from"./components/fullscreen-loading/index.js";import M from"./components/notification-box/index.js";import{FormItem as w}from"./components/form-item/index.js";import{FormItemType as A}from"./components/form-item/model.js";import{Button as O}from"./components/button/index.js";import{IkasPageHead as I}from"../page/head.js";import B from"./components/offer-product/index.js";import L from"./components/svg/ikas.js";import V from"./style.module.scss.js";import{Analytics as U}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import R from"./components/epaykolay-button/index.js";var _=i((function(i){var a,m,u,p=i.checkout,v=i.checkoutSettings,h=i.customizationProps,g=i.returnPolicy,f=i.privacyPolicy,N=i.termsOfService,P=i.imprint,F=i.shippingPolicy,M=d().t,w=r(),A=o.useState((function(){return new s(p,v,w,g,f,N,P,F,M,h||{})}))[0],O=o.useMemo((function(){return Date.now()}),[]);A.step===c.PAYMENT&&U.disableHTML();var _=function(o,i,r,a,n){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:A.checkout.id,customerNumber:o,sessionsState:O,addressDto:r,paymentType:a,totalPrice:n})})];case 1:return[2,t.sent().json()]}}))}))};o.useEffect((function(){A.checkoutSettings.isAccountRequired&&!A.checkout.hasCustomer&&w.push("/account/login?redirect="+encodeURIComponent(A.checkoutUrl)),U.beginCheckout(A.checkout),U.pageView(E.CHECKOUT)}),[]),o.useEffect((function(){A.customizationProps=h,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")}(h)}),[h]),o.useEffect((function(){if(A.isEPayKolayEnabled)var o=setInterval((function(){var i,r;window.setContainerService&&A.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"),A.isEPayKolayPayment=!0}),"https://cdn-epeykolay.mncdn.com/".concat((null===(r=l.getApiUrl())||void 0===r?void 0:r.includes("myikas.com"))?"epay":"epay-uat","/")),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:A.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(A.checkout.id,"&step=").concat(e.success?"success":"info"),orderId:e.orderNumber||null}]}}))}))}),[]);if(!A.isCheckoutLoaded||!A.store.customerStore.initialized)return o.createElement(S,null);if(A.checkout.hasCustomer&&(null===(a=A.store.customerStore.customer)||void 0===a?void 0:a.id)!==(null===(m=A.checkout.customer)||void 0===m?void 0:m.id))return w.push("/account/login?redirect="+encodeURIComponent(A.checkoutUrl)),null;return o.createElement(o.Fragment,null,o.createElement(I,{pageType:E.CHECKOUT,pageTitle:((null===(u=A.merchantSettings)||void 0===u?void 0:u.merchantName)||"")+" - "+M("checkout-page:securePayment"),pageDescription:M("checkout-page:securePayment")}),o.createElement("div",{id:"Checkout",className:V.CheckoutPage},o.createElement(n,{place:"top",type:"dark",effect:"solid",arrowColor:"transparent",multiline:!0,className:V.ReactTooltipWrap,globalEventOff:"touchstart"}),o.createElement("div",{className:[V.Left,A.isEPayKolayPayment?V.epaykolay:""].join(" ")},A.isEPayKolayEnabled&&o.createElement("div",{id:"plateau_ui_placeholder",style:{width:"100%"}}),!A.isEPayKolayPayment&&o.createElement("div",{className:V.LeftContent},o.createElement("div",null,o.createElement(D,{vm:A}),A.hasStockError&&o.createElement("div",{className:V.ErrorContainer},o.createElement(T,{vm:A,error:A.error})),!A.hasStockError&&o.createElement(o.Fragment,null,o.createElement(y,{vm:A,allowExpand:!0}),o.createElement("div",null,A.step!==c.SUCCESS&&A.isEPayKolayEnabled&&o.createElement(R,{onClick:function(){window.frictionless()}})),A.step===c.SUCCESS?o.createElement(k,{vm:A}):o.createElement(o.Fragment,null,A.checkoutCampaignOffer&&o.createElement(B,{vm:A,campaignOffer:A.checkoutCampaignOffer}),A.isCouponCodeRequirementOpen&&o.createElement(z,{vm:A}),o.createElement(H,{vm:A}))),o.createElement("div",{className:V.Space})),o.createElement(Y,{vm:A}))),o.createElement("div",{className:V.Right},o.createElement("div",{className:V.RightContent},o.createElement(y,{vm:A}),!A.isPoweredByHidden&&o.createElement("div",{className:V.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===l.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(L,null))))),!!A.policyModalText&&o.createElement(x,{title:A.policyModalTitle,modalContent:A.policyModalText,onClose:function(){A.policyModalText=""}}),A.isContactModalVisible&&o.createElement(X,{vm:A,setVisible:A.setContactModalVisible}),A.mpVM.isOtpModalVisible&&o.createElement(j,{vm:A,visible:A.mpVM.isOtpModalVisible,type:A.mpVM.otpModalType,onClose:A.mpVM.hideOtpModal}),A.mpVM.isResponseModalVisible&&o.createElement(C,{visible:A.mpVM.isResponseModalVisible,text:A.mpVM.mfsResponseModalText,onClose:A.mpVM.onResponseModalClose}),A.mpVM.isSuccessModalVisible&&o.createElement(b,{visible:A.mpVM.isSuccessModalVisible,type:A.mpVM.successModalType,onClose:A.mpVM.onSuccessModalClose})))})),D=i((function(e){var t,i,r,n,s=e.vm,c=d().t;return o.createElement("div",{className:V.Header},o.createElement(a,{href:"/",passHref:!0},o.createElement("a",null,(null===(t=s.customizationProps)||void 0===t?void 0:t.logo)?o.createElement("div",{className:V.Logo},o.createElement(N,{layout:"fill",image:s.customizationProps.logo,sizes:"360px"})):(null===(i=s.merchantSettings)||void 0===i?void 0:i.logo)?o.createElement("div",{className:V.Logo},o.createElement(N,{layout:"fill",image:s.merchantSettings.logo,sizes:"360px"})):(null===(r=s.merchantSettings)||void 0===r?void 0:r.merchantName)||"")),!s.checkout.hasCustomer&&o.createElement("div",{className:V.LoginText},o.createElement("span",{className:V.LoginCta},c("checkout-page:alreadyHaveAnAccount")),o.createElement(a,{href:"/account/login?redirect="+encodeURIComponent(s.checkoutUrl),passHref:!0},o.createElement("a",{className:V.LoginBtn},c("checkout-page:actions.login")))),s.checkout.hasCustomer&&o.createElement("div",{className:V.CustomerInfo},o.createElement("div",{className:V.Name},s.checkout.customerFullName),o.createElement("div",{className:V.Email},null===(n=s.checkout.customer)||void 0===n?void 0:n.email)))})),z=i((function(e){var t=e.vm,i=d().t,r=o.useState(!1),a=r[0],n=r[1],s=o.useState(null),c=s[0],l=s[1],m=o.useMemo((function(){switch(c){case h.COUPON_CODE_NOT_EXIST:return i("checkout-page:giftCodeErrorDescription");case h.COUPON_CODE_NOT_EXIST_FOR_GUESS:return i("checkout-page:mustBeSignInToApplyCampaign");default:return""}}),[c]);return o.createElement("div",{className:V.CouponContainer},a&&o.createElement("div",{className:V.NotificationContainer},o.createElement(M,{type:"warning",title:i("checkout-page:giftCodeErrorTitle"),content:m,onClose:function(){n(!1),l(null)},ignoreScroll:!0})),o.createElement("div",{style:{marginTop:a?12:0}},o.createElement(g,{vm:t,isOpenCouponCode:!0,isAddingCoupon:!0,setAddingCoupon:function(){},setCouponError:n,setCouponErrorCode:l})))})),H=i((function(e){var t=e.vm,i=d().t,r=o.useMemo((function(){switch(t.step){case c.INFO:return o.createElement(u,{vm:t});case c.SHIPPING:return o.createElement(p,{vm:t});case c.PAYMENT:return o.createElement(v,{vm:t});case c.SUCCESS:return o.createElement(k,{vm:t})}}),[t,t.step]),a=[new F(i("checkout-page:address"),t.step===c.INFO,t.step!==c.INFO,t.step!==c.INFO?o.createElement("div",{className:V.AdressStepInfo},o.createElement(K,{vm:t}),o.createElement("div",{className:V.EditBtn,onClick:t.onBackToInfoClick},i("checkout-page:actions.edit"))):void 0,t.step!==c.INFO?o.createElement("div",{className:V.AddressStepInfoMobile},o.createElement(K,{vm:t})):void 0),new F(i("checkout-page:payment"),t.step===c.PAYMENT,!1)];return"address"!==t.deliveryMethod||t.isDigitalOnly||a.splice(1,0,new F(i("checkout-page:shipping"),t.step===c.SHIPPING,t.step===c.PAYMENT,t.step===c.PAYMENT?o.createElement("div",{className:V.AdressStepInfo},o.createElement(G,{vm:t}),(t.checkout.availableShippingMethods&&t.checkout.availableShippingMethods.length>1||t.checkoutSettings.isGiftPackageEnabled)&&o.createElement("div",{className:V.EditBtn,onClick:t.onBackToShippingClick},i("checkout-page:actions.edit"))):void 0,t.step===c.PAYMENT?o.createElement("div",{className:V.AddressStepInfoMobile},o.createElement(G,{vm:t})):void 0)),o.createElement(P,{steps:a,stepContent:r})})),K=i((function(e){var t,i,r,a,n,s,c,l,m,u=e.vm,p=d().t,v=u.isDigitalOnly?((null===(t=u.checkout.billingAddress)||void 0===t?void 0:t.firstName)||"")+" "+((null===(i=u.checkout.billingAddress)||void 0===i?void 0:i.lastName)||""):((null===(r=u.checkout.shippingAddress)||void 0===r?void 0:r.firstName)||"")+" "+((null===(a=u.checkout.shippingAddress)||void 0===a?void 0:a.lastName)||"");return o.createElement("div",{className:V.Address},o.createElement("div",{className:[V.Text,V.WithMBottom].join(" ")},(null===(n=u.checkout.customer)||void 0===n?void 0:n.email)||""),"address"===u.deliveryMethod?o.createElement("div",{className:V.Text},v):o.createElement(o.Fragment,null,o.createElement("div",{className:V.Text},p("checkout-page:receiver")),o.createElement("div",{className:[V.Text,V.Gray].join(" ")},v)),o.createElement("div",{className:[V.Text,V.Gray].join(" ")},u.isDigitalOnly?null===(s=u.checkout.billingAddress)||void 0===s?void 0:s.phone:null===(c=u.checkout.shippingAddress)||void 0===c?void 0:c.phone),"in-store"===u.deliveryMethod&&o.createElement(o.Fragment,null,o.createElement("div",{className:[V.Text,V.WithMTop].join(" ")},p("checkout-page:pickUpLocation"))),o.createElement("div",{className:[V.Text,V.Gray].join(" ")},u.isDigitalOnly?null===(l=u.checkout.billingAddress)||void 0===l?void 0:l.addressText:null===(m=u.checkout.shippingAddress)||void 0===m?void 0:m.addressText))})),G=i((function(e){var t=e.vm,i=d().t;return o.createElement("div",{className:V.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:V.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"))})),Y=i((function(e){var t=e.vm,i=d().t;return o.createElement("div",{className:V.Footer},o.createElement("div",{className:V.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:returnPolicy"),t.policyModalText=t.returnPolicy}},i("checkout-page:returnPolicy")),o.createElement("div",{className:V.FooterBullet},"•"),o.createElement("div",{className:V.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:privacyPolicy"),t.policyModalText=t.privacyPolicy}},i("checkout-page:privacyPolicy")),o.createElement("div",{className:V.FooterBullet},"•"),o.createElement("div",{className:V.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:V.FooterBullet},"•"),o.createElement("div",{className:V.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:V.FooterBullet},"•"),o.createElement("div",{className:V.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:shippingPolicy"),t.policyModalText=t.shippingPolicy}},i("checkout-page:shippingPolicy"))))})),X=i((function(i){var r,a,n,s=i.vm,c=i.setVisible,l=d().t,m=o.useState(!1),u=m[0],p=m[1],v=o.useState(!1),h=v[0],g=v[1],y=o.useState(new f({message:{requiredRule:"",emailRule:"",minRule:""}}))[0];y.email=(null===(r=s.checkout.customer)||void 0===r?void 0:r.email)||"",y.firstName=(null===(a=s.checkout.customer)||void 0===a?void 0:a.firstName)||"",y.lastName=(null===(n=s.checkout.customer)||void 0===n?void 0:n.lastName)||"";var E=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)]:(p(!0),[4,y.saveContactForm()]);case 1:return e.sent()&&g(!0),p(!1),[2]}}))}))}),[u]);return o.createElement(x,{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(w,{type:A.TEXT_AREA,label:"",value:y.message||"",onChange:y.onMessageChange,textAreaPlaceholder:l("checkout-page:contactFormCta")}),o.createElement(O,{style:{width:"100%",marginTop:"24px"},text:l(h?"checkout-page:actions.close":"checkout-page:actions.sendMessage"),isLoading:u,isDisabled:!y.message,onClick:E})),onClose:function(){return c(!1)}})}));export{_ 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 n from"react-tooltip";import s,{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{CouponErrorCode as g,Coupon as h,CartSummary as y}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 E}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/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/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 f}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 k}from"./steps/step-success/index.js";import{Modal as x}from"./components/modal/index.js";import j from"./components/master-pass/modal-otp/index.js";import C from"./components/master-pass/modal-response/index.js";import b from"./components/master-pass/modal-success/index.js";import{Image as N}from"../image/index.js";import P,{Step as F}from"./components/step-container/index.js";import{StockError as T}from"./components/error/stock-error/index.js";import{FullscreenLoading as S}from"./components/fullscreen-loading/index.js";import M from"./components/notification-box/index.js";import{FormItem as w}from"./components/form-item/index.js";import{FormItemType as O}from"./components/form-item/model.js";import{Button as A}from"./components/button/index.js";import{IkasPageHead as I}from"../page/head.js";import B from"./components/offer-product/index.js";import L from"./components/svg/ikas.js";import U from"./style.module.scss.js";import{Analytics as V}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import R from"./components/epaykolay-button/index.js";var _=i((function(i){var a,m,p,u=i.checkout,v=i.checkoutSettings,g=i.customizationProps,h=i.returnPolicy,f=i.privacyPolicy,N=i.termsOfService,P=i.imprint,F=i.shippingPolicy,M=d().t,w=r(),O=o.useState((function(){return new s(u,v,w,h,f,N,P,F,M,g||{})}))[0],A=o.useMemo((function(){return Date.now()}),[]);O.step===c.PAYMENT&&V.disableHTML();var _=function(o,i,r,a,n){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:O.checkout.id,customerNumber:o,sessionsState:A,addressDto:r,paymentType:a,totalPrice:n})})];case 1:return[2,t.sent().json()]}}))}))};o.useEffect((function(){O.checkoutSettings.isAccountRequired&&!O.checkout.hasCustomer&&w.push("/account/login?redirect="+encodeURIComponent(O.checkoutUrl)),V.beginCheckout(O.checkout),V.pageView(E.CHECKOUT)}),[]),o.useEffect((function(){O.customizationProps=g,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")}(g)}),[g]),o.useEffect((function(){if(O.isEPayKolayEnabled)var o=setInterval((function(){var i,r;window.setContainerService&&O.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"),O.isEPayKolayPayment=!0}),"https://cdn-epeykolay.mncdn.com/".concat((null===(r=l.getApiUrl())||void 0===r?void 0:r.includes("myikas.com"))?"epay":"epay-uat","/")),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:O.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(O.checkout.id,"&step=").concat(e.success?"success":"info"),orderId:e.orderNumber||null}]}}))}))}),[]);if(!O.isCheckoutLoaded||!O.store.customerStore.initialized)return o.createElement(S,null);if(O.checkout.hasCustomer&&(null===(a=O.store.customerStore.customer)||void 0===a?void 0:a.id)!==(null===(m=O.checkout.customer)||void 0===m?void 0:m.id))return w.push("/account/login?redirect="+encodeURIComponent(O.checkoutUrl)),null;return o.createElement(o.Fragment,null,o.createElement(I,{pageType:E.CHECKOUT,pageTitle:((null===(p=O.merchantSettings)||void 0===p?void 0:p.merchantName)||"")+" - "+M("checkout-page:securePayment"),pageDescription:M("checkout-page:securePayment")}),o.createElement("div",{id:"Checkout",className:U.CheckoutPage},o.createElement(n,{place:"top",type:"dark",effect:"solid",arrowColor:"transparent",multiline:!0,className:U.ReactTooltipWrap,globalEventOff:"touchstart"}),o.createElement("div",{className:[U.Left,O.isEPayKolayPayment?U.epaykolay:""].join(" ")},O.isEPayKolayEnabled&&o.createElement("div",{id:"plateau_ui_placeholder",style:{width:"100%"}}),!O.isEPayKolayPayment&&o.createElement("div",{className:U.LeftContent},o.createElement("div",null,o.createElement(D,{vm:O}),O.hasStockError&&o.createElement("div",{className:U.ErrorContainer},o.createElement(T,{vm:O,error:O.error})),!O.hasStockError&&o.createElement(o.Fragment,null,o.createElement(y,{vm:O,allowExpand:!0}),o.createElement("div",null,O.step!==c.SUCCESS&&O.isEPayKolayEnabled&&o.createElement(R,{onClick:function(){window.frictionless()}})),O.step===c.SUCCESS?o.createElement(k,{vm:O}):o.createElement(o.Fragment,null,O.campaignOffer&&O.isCampaignOfferLoaded&&o.createElement(B,{vm:O,campaignOffer:O.campaignOffer}),O.isCouponCodeRequirementOpen&&o.createElement(z,{vm:O}),o.createElement(H,{vm:O}))),o.createElement("div",{className:U.Space})),o.createElement(Y,{vm:O}))),o.createElement("div",{className:U.Right},o.createElement("div",{className:U.RightContent},o.createElement(y,{vm:O}),!O.isPoweredByHidden&&o.createElement("div",{className:U.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===l.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(L,null))))),!!O.policyModalText&&o.createElement(x,{title:O.policyModalTitle,modalContent:O.policyModalText,onClose:function(){O.policyModalText=""}}),O.isContactModalVisible&&o.createElement(X,{vm:O,setVisible:O.setContactModalVisible}),O.mpVM.isOtpModalVisible&&o.createElement(j,{vm:O,visible:O.mpVM.isOtpModalVisible,type:O.mpVM.otpModalType,onClose:O.mpVM.hideOtpModal}),O.mpVM.isResponseModalVisible&&o.createElement(C,{visible:O.mpVM.isResponseModalVisible,text:O.mpVM.mfsResponseModalText,onClose:O.mpVM.onResponseModalClose}),O.mpVM.isSuccessModalVisible&&o.createElement(b,{visible:O.mpVM.isSuccessModalVisible,type:O.mpVM.successModalType,onClose:O.mpVM.onSuccessModalClose})))})),D=i((function(e){var t,i,r,n,s=e.vm,c=d().t;return o.createElement("div",{className:U.Header},o.createElement(a,{href:"/",passHref:!0},o.createElement("a",null,(null===(t=s.customizationProps)||void 0===t?void 0:t.logo)?o.createElement("div",{className:U.Logo},o.createElement(N,{layout:"fill",image:s.customizationProps.logo,sizes:"360px"})):(null===(i=s.merchantSettings)||void 0===i?void 0:i.logo)?o.createElement("div",{className:U.Logo},o.createElement(N,{layout:"fill",image:s.merchantSettings.logo,sizes:"360px"})):(null===(r=s.merchantSettings)||void 0===r?void 0:r.merchantName)||"")),!s.checkout.hasCustomer&&o.createElement("div",{className:U.LoginText},o.createElement("span",{className:U.LoginCta},c("checkout-page:alreadyHaveAnAccount")),o.createElement(a,{href:"/account/login?redirect="+encodeURIComponent(s.checkoutUrl),passHref:!0},o.createElement("a",{className:U.LoginBtn},c("checkout-page:actions.login")))),s.checkout.hasCustomer&&o.createElement("div",{className:U.CustomerInfo},o.createElement("div",{className:U.Name},s.checkout.customerFullName),o.createElement("div",{className:U.Email},null===(n=s.checkout.customer)||void 0===n?void 0:n.email)))})),z=i((function(e){var t=e.vm,i=d().t,r=o.useState(!1),a=r[0],n=r[1],s=o.useState(null),c=s[0],l=s[1],m=o.useMemo((function(){switch(c){case g.COUPON_CODE_NOT_EXIST:return i("checkout-page:giftCodeErrorDescription");case g.COUPON_CODE_NOT_EXIST_FOR_GUESS:return i("checkout-page:mustBeSignInToApplyCampaign");default:return""}}),[c]);return o.createElement("div",{className:U.CouponContainer},a&&o.createElement("div",{className:U.NotificationContainer},o.createElement(M,{type:"warning",title:i("checkout-page:giftCodeErrorTitle"),content:m,onClose:function(){n(!1),l(null)},ignoreScroll:!0})),o.createElement("div",{style:{marginTop:a?12:0}},o.createElement(h,{vm:t,isOpenCouponCode:!0,isAddingCoupon:!0,setAddingCoupon:function(){},setCouponError:n,setCouponErrorCode:l})))})),H=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(k,{vm:t})}}),[t,t.step]),a=[new F(i("checkout-page:address"),t.step===c.INFO,t.step!==c.INFO,t.step!==c.INFO?o.createElement("div",{className:U.AdressStepInfo},o.createElement(K,{vm:t}),!t.isUpsellOrder&&o.createElement("div",{className:U.EditBtn,onClick:t.onBackToInfoClick},i("checkout-page:actions.edit"))):void 0,t.step!==c.INFO?o.createElement("div",{className:U.AddressStepInfoMobile},o.createElement(K,{vm:t})):void 0),new F(i("checkout-page:payment"),t.step===c.PAYMENT,!1)];return"address"!==t.deliveryMethod||t.isDigitalOnly||a.splice(1,0,new F(i("checkout-page:shipping"),t.step===c.SHIPPING,t.step===c.PAYMENT,t.step===c.PAYMENT?o.createElement("div",{className:U.AdressStepInfo},o.createElement(G,{vm:t}),!t.isUpsellOrder&&(t.checkout.availableShippingMethods&&t.checkout.availableShippingMethods.length>1||t.checkoutSettings.isGiftPackageEnabled)&&o.createElement("div",{className:U.EditBtn,onClick:t.onBackToShippingClick},i("checkout-page:actions.edit"))):void 0,t.step===c.PAYMENT?o.createElement("div",{className:U.AddressStepInfoMobile},o.createElement(G,{vm:t})):void 0)),o.createElement(P,{steps:a,stepContent:r})})),K=i((function(e){var t,i,r,a,n,s,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:U.Address},o.createElement("div",{className:[U.Text,U.WithMBottom].join(" ")},(null===(n=p.checkout.customer)||void 0===n?void 0:n.email)||""),"address"===p.deliveryMethod?o.createElement("div",{className:U.Text},v):o.createElement(o.Fragment,null,o.createElement("div",{className:U.Text},u("checkout-page:receiver")),o.createElement("div",{className:[U.Text,U.Gray].join(" ")},v)),o.createElement("div",{className:[U.Text,U.Gray].join(" ")},p.isDigitalOnly?null===(s=p.checkout.billingAddress)||void 0===s?void 0:s.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:[U.Text,U.WithMTop].join(" ")},u("checkout-page:pickUpLocation"))),o.createElement("div",{className:[U.Text,U.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))})),G=i((function(e){var t=e.vm,i=d().t;return o.createElement("div",{className:U.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:U.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"))})),Y=i((function(e){var t=e.vm,i=d().t;return o.createElement("div",{className:U.Footer},o.createElement("div",{className:U.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:returnPolicy"),t.policyModalText=t.returnPolicy}},i("checkout-page:returnPolicy")),o.createElement("div",{className:U.FooterBullet},"•"),o.createElement("div",{className:U.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:privacyPolicy"),t.policyModalText=t.privacyPolicy}},i("checkout-page:privacyPolicy")),o.createElement("div",{className:U.FooterBullet},"•"),o.createElement("div",{className:U.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:U.FooterBullet},"•"),o.createElement("div",{className:U.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:U.FooterBullet},"•"),o.createElement("div",{className:U.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:shippingPolicy"),t.policyModalText=t.shippingPolicy}},i("checkout-page:shippingPolicy"))))})),X=i((function(i){var r,a,n,s=i.vm,c=i.setVisible,l=d().t,m=o.useState(!1),p=m[0],u=m[1],v=o.useState(!1),g=v[0],h=v[1],y=o.useState(new f({message:{requiredRule:"",emailRule:"",minRule:""}}))[0];y.email=(null===(r=s.checkout.customer)||void 0===r?void 0:r.email)||"",y.firstName=(null===(a=s.checkout.customer)||void 0===a?void 0:a.firstName)||"",y.lastName=(null===(n=s.checkout.customer)||void 0===n?void 0:n.lastName)||"";var E=o.useCallback((function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return g?[2,c(!1)]:(u(!0),[4,y.saveContactForm()]);case 1:return e.sent()&&h(!0),u(!1),[2]}}))}))}),[p]);return o.createElement(x,{title:l("checkout-page:contactForm"),modalContent:o.createElement("div",null,g&&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(w,{type:O.TEXT_AREA,label:"",value:y.message||"",onChange:y.onMessageChange,textAreaPlaceholder:l("checkout-page:contactFormCta")}),o.createElement(A,{style:{width:"100%",marginTop:"24px"},text:l(g?"checkout-page:actions.close":"checkout-page:actions.sendMessage"),isLoading:p,isDisabled:!y.message,onClick:E})),onClose:function(){return c(!1)}})}));export{_ as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NextRouter } from "next/router.js";
|
|
2
|
-
import { IkasMerchantSettings, IkasAvailableShippingMethod, IkasOrderLineItem, IkasOrderTransaction, IkasProduct,
|
|
2
|
+
import { IkasMerchantSettings, IkasAvailableShippingMethod, IkasOrderLineItem, IkasOrderTransaction, IkasProduct, IkasCartCampaignOffer, IkasCheckout, IkasStockLocation, IkasAvailableStockLocation, IkasCampaignOfferTargetPageType, IkasCampaignOfferProduct, IkasLocalizedCustomerAddress, IkasShippingZone, IkasProductFile } from "../../models";
|
|
3
3
|
import { IkasPaymentGateway } from "../../models/data/payment-gateway";
|
|
4
4
|
import { IkasOrderLineVariant } from "../../models/data/order/line-item/variant";
|
|
5
5
|
import { IkasStorefront } from "../../models/data/storefront";
|
|
@@ -51,8 +51,8 @@ export default class CheckoutViewModel {
|
|
|
51
51
|
adyenDropinElement: any;
|
|
52
52
|
payPalClientIdResponse: GetPaypalClientIdResponse | null;
|
|
53
53
|
paypalOrderResponse: CreatePaypalOrderResponse | null;
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
campaignOffer: CampaignOfferType | undefined;
|
|
55
|
+
isCampaignOfferLoaded: boolean;
|
|
56
56
|
countrySettings: LocalizedAddressModel;
|
|
57
57
|
shippingZones: IkasShippingZone[] | null;
|
|
58
58
|
returnPolicy: string;
|
|
@@ -111,6 +111,7 @@ export default class CheckoutViewModel {
|
|
|
111
111
|
get isDigitalOnly(): boolean;
|
|
112
112
|
get customerAddresses(): IkasLocalizedCustomerAddress[] | undefined;
|
|
113
113
|
get isManualOrder(): boolean;
|
|
114
|
+
get isUpsellOrder(): boolean;
|
|
114
115
|
get isEPayKolayEnabled(): boolean;
|
|
115
116
|
get isPoweredByHidden(): boolean;
|
|
116
117
|
saveCart: () => Promise<import("../../models").IkasCart | null | undefined>;
|
|
@@ -153,7 +154,7 @@ export default class CheckoutViewModel {
|
|
|
153
154
|
onCompletePaymentClick: () => Promise<void>;
|
|
154
155
|
onCompleteDigitalOnlyPaymentClick: () => Promise<void>;
|
|
155
156
|
createSaleTransaction: () => Promise<void>;
|
|
156
|
-
onCheckoutTransactionSuccess: () => Promise<void>;
|
|
157
|
+
onCheckoutTransactionSuccess: (checkoutId?: string) => Promise<void>;
|
|
157
158
|
onBackToInfoClick: () => void;
|
|
158
159
|
onBackToShippingClick: () => void;
|
|
159
160
|
setCustomerConsentGranted: (value: boolean) => void;
|
|
@@ -167,17 +168,16 @@ export default class CheckoutViewModel {
|
|
|
167
168
|
getPayPalClientId: (paymentGateway: IkasPaymentGateway) => Promise<void>;
|
|
168
169
|
setPaymentGateway: (index: number) => Promise<void>;
|
|
169
170
|
setInstallmentCount: (count: number) => void;
|
|
170
|
-
changeStep: (step: CheckoutStep) => Promise<void>;
|
|
171
|
+
changeStep: (step: CheckoutStep, checkoutId?: string) => Promise<void>;
|
|
171
172
|
logout: () => Promise<void>;
|
|
172
173
|
setContactModalVisible: (value: boolean) => void;
|
|
173
|
-
|
|
174
|
+
getCampaignOffer: (targetPage: IkasCampaignOfferTargetPageType, campaignOffers?: IkasCartCampaignOffer[] | null) => Promise<{
|
|
174
175
|
product: IkasProduct;
|
|
175
|
-
variants: IkasProductVariant[];
|
|
176
|
-
campaignOffer: IkasCartCampaignOffer;
|
|
177
176
|
offer: IkasCampaignOfferProduct;
|
|
177
|
+
campaignOffer: IkasCartCampaignOffer;
|
|
178
178
|
} | undefined>;
|
|
179
|
-
|
|
180
|
-
updateCartCampaignOffer: (
|
|
179
|
+
createCampaignOffer: () => Promise<void>;
|
|
180
|
+
updateCartCampaignOffer: (input: UpdateCartCampaignOfferInput) => Promise<void>;
|
|
181
181
|
registerCustomer: (password: string) => Promise<APIResponse<{
|
|
182
182
|
customer: import("../../models").IkasCustomer | null;
|
|
183
183
|
token: string;
|
|
@@ -211,7 +211,6 @@ export declare type StockErrorData = {
|
|
|
211
211
|
};
|
|
212
212
|
export declare type CampaignOfferType = {
|
|
213
213
|
product: IkasProduct;
|
|
214
|
-
variants: IkasProductVariant[];
|
|
215
|
-
campaignOffer: IkasCartCampaignOffer;
|
|
216
214
|
offer: IkasCampaignOfferProduct;
|
|
215
|
+
campaignOffer: IkasCartCampaignOffer;
|
|
217
216
|
};
|
|
@@ -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{IkasCouponCodeRequirement as o,IkasPaymentMethodType as a,IkasPaymentGatewayType as c,IkasOrderShippingMethod as d,IkasCartCreatedBy as u,IkasOrderPaymentStatus as l,IkasTransactionStatus as h,IkasCartCampaignOfferStatus as p,IkasCampaignOfferTargetPageType as m,IkasOrderLineItemStatus as f,IkasCustomerEmailSubscriptionStatus as g}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 v}from"../../models/data/checkout/index.js";import{IkasCheckoutSettings as y}from"../../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 k}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as S}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 b}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 C}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{IkasProduct as P}from"../../models/data/product/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/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 I}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 A from"./components/credit-card-form/model.js";import w from"../../store/customer/api.js";import N from"../../store/checkout/index.js";import E from"../../store/cart/api.js";import O,{MFS_ELEMENT_ID as j,MFS_SCRIPT_URL as R}from"./modelMasterPass.js";import D from"../../store/product/index.js";import{IkasBaseStore as x}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as T}from"@ikas/storefront-config";import{Analytics as G}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as L,CheckStocksLineInput as M}from"@ikas/storefront-api";import _ from"../../models/data/order/address/ikas-localized-order-address.js";import V from"../../store/location/index.js";import{getCookieValue as U}from"../../utils/helper.js";var F,K,B=/^\d+$/,Z="undefined"==typeof localStorage,Y=function(){function B(u,S,b,B,Y,W,Q,z,X,$){var J=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=F.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.productFiles=[],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(J,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,x.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(J,void 0,void 0,(function(){var e,s,n,r,a,c,d;return t(this,(function(t){switch(t.label){case 0:if(T.getIsEditor())return this.step=F.INFO,this.isCheckoutLoaded=!0,[2];if(e=new URLSearchParams(window.location.search),s=e.get("step"),n=e.get("failed"),r=e.get("error"),s){if(this.step=s,this.step===F.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(F.INFO)];if(this.step!==F.PAYMENT||this.canProceedToPayment){if(this.step===F.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(F.INFO)];if(![F.INFO,F.SUCCESS,F.SHIPPING,F.PAYMENT].includes(this.step))return[2,this.changeStep(F.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings?[2,this.changeStep(F.INFO)]:[2,this.changeStep(F.SHIPPING)];this.deliveryMethod="in-store"}}return n&&(this.error={type:K.PAYMENT_ERROR,data:r||null}),this.step!==F.SHIPPING&&this.step!==F.PAYMENT||this.isCouponCodeRequirementInvisible||(this.checkoutSettings=new y(i(i({},this.checkoutSettings),{couponCodeRequirement:o.DEFAULT}))),this.step!==F.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!==F.SHIPPING||1!==(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=F.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==F.SHIPPING||(null===(d=this.checkout.availableShippingMethods)||void 0===d?void 0:d.length)?this.step!==F.SUCCESS||this.checkout.orderPaymentStatus!==l.PAID?[3,8]:[4,this.listProductFile()]:(this.error={type:K.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 7:t.sent(),t.label=8;case 8:return this.step!==F.PAYMENT&&this.step!==F.SUCCESS?[3,12]:[4,this.listPaymentGateways()];case 9:return t.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,11];case 10:t.sent(),t.label=11;case 11:if(!this.paymentGateways.length)return this.error={type:K.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];t.label=12;case 12:return this.step===F.SUCCESS?[3,16]:this.checkout.isComplete?[2,this.changeStep(F.SUCCESS)]:[3,13];case 13:return[4,this.initialStockCheck()];case 14:t.sent(),t.label=15;case 15:return[3,18];case 16:return[4,this.getSuccessTransaction()];case 17:t.sent(),this.successTransaction&&(a=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===a}))),t.label=18;case 18:return this.isCheckoutLoaded=!0,G.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return e(J,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return[4,w.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(J,void 0,void 0,(function(){var e,i,s,n;return t(this,(function(t){switch(t.label){case 0:return e=new L(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!==F.INFO&&this.step!==F.SHIPPING||this.isDigitalOnly||(e.billingAddress=null),this.isDigitalOnly&&(e.shippingAddress=null),e.customer&&(this.store.customerStore.customer?e.customer.notificationsAccepted=this.store.customerStore.customer.subscriptionStatus===g.SUBSCRIBED:this.checkout.customer&&(e.customer.notificationsAccepted=this.checkout.customer.notificationsAccepted||!1)),[4,E.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:K.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:K.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return e(J,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(J,void 0,void 0,(function(){var e,i,s,n,r,o,a,c,u,l,h,p;return t(this,(function(t){switch(t.label){case 0:return this.isManualOrder?[2]:(e=this.checkout.stockLocationId&&this.checkout.shippingMethod===d.CLICK_AND_COLLECT?[this.checkout.stockLocationId]:(null===(l=T.getStockLocationIds())||void 0===l?void 0:l.length)?T.getStockLocationIds():null,[4,N.checkCartStocks({cartId:this.checkout.id,stockLocationIdList:e})]);case 1:if(!(i=t.sent()).isSuccess)throw{type:K.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(p=null===(h=i.data)||void 0===h?void 0:h.lines)||void 0===p?void 0:p.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++)u=c[a],r(u);throw{type:K.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return e(J,void 0,void 0,(function(){return t(this,(function(e){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return e(J,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,x.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(J,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,N.getAvailableShippingCountries({salesChannelId:T.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return e(J,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return T.getPickupStockLocationIds()?[4,N.listStockLocation({id:{in:T.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:K.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,t.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return e(J,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return T.getPickupStockLocationIds()?(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,N.getAvailableStockLocations({lines:e.map((function(e){return new M(e)})),stockLocationIdList:T.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=t.sent()).isSuccess)return this.error={type:K.API_ERROR},[2];this.availableStockLocations=i.data||[],t.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var e;(null===(e=J.shippingCountryIds)||void 0===e?void 0:e.length)||(J.error={type:K.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){"address"===e&&(J.checkout.stockLocationId=null,J.checkout.shippingAddress=new _,J.checkout.shippingAddress.countrySettings=J.countrySettings,J.checkout.shippingAddress.checkoutSettings=J.checkoutSettings,J.checkout.shippingAddress.shippingZones=J.shippingZones),J.deliveryMethod=e,J.isErrorsVisible=!1},this.initialStockCheck=function(){return e(J,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:K.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return e(J,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=T.getPaymentGateways().map((function(e){return e.id})),[4,N.listPaymentGateway({id:e?void 0:{in:i},locale:T.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===F.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(T.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===F.PAYMENT&&(c=n.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id=j,d.src=R,d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout,store:x.getInstance()})},document.head.appendChild(d)),[2]):(this.error={type:K.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return e(J,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:return[4,N.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;J.store.customerStore.customer?(null===(e=J.customerAddresses)||void 0===e||e.forEach((function(e){e.checkoutSettings=J.checkoutSettings,e.shippingZones=J.shippingZones})),J.checkout.customer=new C(J.store.customerStore.customer)):J.checkout.customer=new C(J.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){J.checkout.shippingAddress&&(J.checkout.shippingAddress.checkoutSettings=J.checkoutSettings,J.checkout.shippingAddress.shippingZones=J.shippingZones,J.checkout.shippingAddress.countrySettings=J.countrySettings,J.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){J.checkout.billingAddress&&(J.checkout.billingAddress.checkoutSettings=J.checkoutSettings,J.checkout.billingAddress.shippingZones=J.shippingZones,J.checkout.billingAddress.countrySettings=J.countrySettings,J.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!J.isDigitalOnly)if(J.isInStoreDelivery)J.setCheckoutShippingAddressSettings();else if(J.checkout.shippingAddress){if(J.store.customerStore.customer){var e=null==(t=J.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=J.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return J.onSelectedShippingAddressIdChange(e.id||"-1"),void J.setCheckoutShippingAddressSettings()}J.checkout.shippingAddress=new _(n(J.checkout.shippingAddress)||{}),J.setCheckoutShippingAddressSettings()}else if(J.store.customerStore.customer){var t=J.customerAddresses;J.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else J.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(J.useDifferentAddress=!!localStorage.getItem("sAddr"),J.checkout.billingAddress){if(J.store.customerStore.customer){var e=null==(t=J.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=J.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return J.onSelectedBillingAddressIdChange(e.id||"-1"),void J.setCheckoutBillingAddressSettings()}J.checkout.billingAddress=new _(n(J.checkout.billingAddress)||{}),J.setCheckoutBillingAddressSettings()}else if(J.store.customerStore.customer){var t=J.customerAddresses;J.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||J.useDifferentAddress||!J.checkout.shippingAddress||J.isInStoreDelivery||(J.checkout.billingAddress=new _(n(J.checkout.shippingAddress)),J.setCheckoutBillingAddressSettings())}else J.onSelectedBillingAddressIdChange("-1"),J.useDifferentAddress||!J.checkout.shippingAddress||J.isInStoreDelivery||(J.checkout.billingAddress=new _(n(J.checkout.shippingAddress)),J.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(i){return e(J,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 v(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(J,void 0,void 0,(function(){return t(this,(function(e){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return e(J,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,E.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===F.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,currencyCode:this.checkout.currencyCode}}),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,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,4];case 2:t.sent(),t.label=3;case 3:s&&(r=this.checkout,this.checkout=new v(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(J,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,V.getAvailableShippingZones({salesChannelId:T.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(J.selectedShippingAddressId=e,"-1"===e)J.checkout.shippingAddress=new _,J.checkout.shippingAddress.countrySettings=J.countrySettings;else{var i=null===(t=J.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(J.checkout.shippingAddress=new _(i),J.checkout.shippingAddress.countrySettings=J.countrySettings)}J.checkout.shippingAddress&&(J.checkout.shippingAddress.checkoutSettings=J.checkoutSettings,J.checkout.shippingAddress.shippingZones=J.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(J.selectedBillingAddressId=e,"-1"===e)J.checkout.billingAddress=new _,J.checkout.billingAddress.countrySettings=J.countrySettings;else{var i=null===(t=J.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(J.checkout.billingAddress=new _(i),J.checkout.billingAddress.countrySettings=J.countrySettings)}J.checkout.billingAddress&&(J.checkout.billingAddress.checkoutSettings=J.checkoutSettings,J.checkout.billingAddress.shippingZones=J.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){J.isTermsAndConditionsChecked=e},this.onCardNumberChange=function(e){if(J.cardData&&(!(e.length>J.cardData.cardNumber.length)||q(e))){var t=(J.cardData.cardNumber||"").split(" ").join(""),i=e.split(" ").join("");i.length>16||(t.length<6&&i.length>=6&&!J.installmentInfo?J.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:J.checkout.selectedPaymentGateway.id,price:J.checkout.totalFinalPrice,currencyCode:J.checkout.currencyCode}}):i.length<6&&t.length>i.length&&(J.cardData.installmentCount=1,J.installmentInfo=void 0),J.cardData.cardNumber=H(i,4).join(" "))}},this.onCardHolderNameChange=function(e){J.cardData&&(J.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(J.cardData&&(!(e.length>J.cardData.expirationDate.length)||q(e))){if(0===(null===(t=J.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(J.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(J.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(J.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(J.cardData.expirationDate=H(d,2).join(" / "))}},this.onCvcChange=function(e){J.cardData&&(e.length>J.cardData.cvv.length&&!q(e)||e.length>4||(J.cardData.cvv=e))},this.saveAddress=function(s){return e(J,void 0,void 0,(function(){var e,r,o,a,c,d,u,l,h,p,m,f,g=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 k(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===(m=this.customerAddresses)||void 0===m||m.forEach((function(e){e.checkoutSettings=g.checkoutSettings,e.shippingZones=g.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(){J.router.push("/cart")},this.onBackToShoppingClick=function(){J.router.push("/")},this.onGoToLoginClick=function(){J.router.push("/account/login")},this.onProceedToShippingClick=function(){return e(J,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(F.SHIPPING):this.changeStep(F.PAYMENT),[3,7];case 6:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:K.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return e(J,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(F.PAYMENT),[3,5];case 4:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:K.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return e(J,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(F.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:K.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!J.canPerformPayment||(J.isErrorsVisible=!0,!1)},this.onCompletePaymentClick=function(){return e(J,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.isFree||!this.isKlarna?[3,2]:[4,this.saveCart()]):(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.isFree&&this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):!this.isFree&&this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):!this.isFree&&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:K.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return e(J,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:K.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return e(J,void 0,void 0,(function(){var e,i,s,n,r,o,d,u,l,p,m,f,g,v,y;return t(this,(function(t){switch(t.label){case 0:return i=this.mpVM.selectedCard,!this.isFree&&i&&(null===(u=this.mpVM.selectedCard)||void 0===u?void 0:u.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(e=n),void 0===(null===(l=this.cardData)||void 0===l?void 0:l.installmentCount)?[2]:[4,N.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===(f=this.cardData)||void 0===f?void 0:f.threeDSecure)},metadata:{_fbp:U("_fbp"),_fbc:U("_fbc")}}})]):[3,2];case 1:return s=t.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,N.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:this.isFree?void 0:i&&e?{phoneNumber:e,savedCardName:null===(g=this.mpVM.selectedCard)||void 0===g?void 0:g.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:this.isFree||i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===a.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===c.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,o=r&&[h.SUCCESS,h.AUTHORIZED].includes(r),d=r===h.PENDING,o?[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:K.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(J,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(F.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){J.changeStep(F.INFO)},this.onBackToShippingClick=function(){J.changeStep(F.SHIPPING)},this.setCustomerConsentGranted=function(e){J.checkout.customer&&(J.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(e){J.useDifferentAddress=e,J.useDifferentAddress?(localStorage.setItem("sAddr","1"),J.checkout.billingAddress=J.checkout.billingAddress||new _,J.checkout.billingAddress.countrySettings=J.countrySettings):(localStorage.removeItem("sAddr"),J.checkout.billingAddress=J.checkout.shippingAddress)},this.setShouldSaveAddress=function(e){J.shouldSaveAddress=e},this.setAddressTitle=function(e){J.addressTitle=e},this.reInitPaymentMethod=function(){return e(J,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(J,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,N.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(J,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,N.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(J,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,N.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(J,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,N.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(J,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!==F.SUCCESS&&(e.paymentMethodType===a.CREDIT_CARD&&e.type===c.INTERNAL&&(this.cardData=new A,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){J.cardData&&(J.cardData.installmentCount=e)},this.changeStep=function(i){return e(J,void 0,void 0,(function(){return t(this,(function(e){return Z||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return e(J,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){J.isContactModalVisible=e},this.getCampaignOfferProducts=function(i){return e(J,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===p.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,D.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 P(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(J,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return e=this,[4,this.getCampaignOfferProducts(m.CHECKOUT)];case 1:return e.checkoutCampaignOffer=t.sent(),i=this,[4,this.getCampaignOfferProducts(m.POST_CHECKOUT)];case 2:return i.postCheckoutCampaignOffer=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return e(J,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.isCheckoutLoaded=!1,[4,E.updateCartCampaignOffer({input:i})];case 1:return(e=t.sent())&&e.isSuccess&&e.data&&(this.checkout=new v(e.data,this.countrySettings),i.accepted&&this.step===F.SUCCESS?this.changeStep(F.INFO):this.changeStep(this.step)),[2]}}))}))},this.registerCustomer=function(i){return e(J,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,w.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.listProductFile=function(){return e(J,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return(e=this.checkout.orderLineItems.filter((function(e){return!!e.variant.fileId&&e.status!==f.REFUNDED})).map((function(e){return e.variant.fileId}))).length?[4,N.listProductFile({id:{in:e}})]:[3,2];case 1:(i=t.sent()).isSuccess&&(this.productFiles=i.data||[]),t.label=2;case 2:return[2]}}))}))},this.getDigitalProductFileDownloadUrl=function(i){return e(J,void 0,void 0,(function(){var e,s,n,r,o;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),(e=this.checkout.orderLineItems.find((function(e){return e.variant.id===i.variantId})))?[4,N.getDigitalProductFileDownloadUrl({orderId:this.checkout.id,orderLineItemId:e.id})]:[3,2];case 1:s=t.sent(),(n=s.data)&&((r=document.createElement("a")).href=n,r.download=function(e){try{return decodeURIComponent(e.split("/")[e.split("/").length-1])}catch(e){return""}}(i.name),r.click(),r.remove()),t.label=2;case 2:return[3,4];case 3:return o=t.sent(),console.error(o),[3,4];case 4:return[2]}}))}))},this.checkout=u,this.checkoutSettings=S,this.router=b,this.returnPolicy=B,this.privacyPolicy=Y,this.termsOfService=W,this.imprint=Q,this.shippingPolicy=z,this.t=X,this.customizationProps=$,this.mpVM=new O,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new I({currentLocale:T.getCurrentLocale()}),this.init(),s(this)}return Object.defineProperty(B.prototype,"merchantSettings",{get:function(){return new b(T.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(B.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(B.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(B.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(B.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=x.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(B.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(B.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(B.prototype,"finalPrice",{get:function(){return this.step===F.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(B.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===K.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(B.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(B.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(B.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)!==K.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(B.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(B.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(B.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(B.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(B.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(B.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(B.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(B.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(B.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(B.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(B.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(B.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(B.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(B.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(B.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(B.prototype,"store",{get:function(){return x.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(B.prototype,"isCouponCodeRequirementDefult",{get:function(){return this.checkoutSettings.couponCodeRequirement===o.DEFAULT||null===this.checkoutSettings.couponCodeRequirement},enumerable:!1,configurable:!0}),Object.defineProperty(B.prototype,"isCouponCodeRequirementOpen",{get:function(){return this.checkoutSettings.couponCodeRequirement===o.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(B.prototype,"isCouponCodeRequirementInvisible",{get:function(){return this.checkoutSettings.couponCodeRequirement===o.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(B.prototype,"isCouponCodeVisible",{get:function(){return this.isCouponCodeRequirementDefult&&!this.isCouponCodeRequirementInvisible},enumerable:!1,configurable:!0}),Object.defineProperty(B.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)===a.CREDIT_CARD&&i.type===c.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(B.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===d.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(B.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 S(i({countrySettings:s.countrySettings},e));return t.checkoutSettings=s.checkoutSettings,t.shippingZones=s.shippingZones,t.getValidatedCustomerAddress(),t}))},enumerable:!1,configurable:!0}),Object.defineProperty(B.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===u.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(B.prototype,"isEPayKolayEnabled",{get:function(){var e=T.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(B.prototype,"isPoweredByHidden",{get:function(){var e=T.getCustom();return!!e&&!!e.hidePoweredBy},enumerable:!1,configurable:!0}),B.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},B}();function H(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function q(e){return e&&B.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(F||(F={})),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"}(K||(K={}));export{F as CheckoutStep,K as ErrorType,Y 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{IkasCouponCodeRequirement as o,IkasPaymentMethodType as a,IkasPaymentGatewayType as c,IkasOrderShippingMethod as d,IkasCartCreatedBy as u,IkasOrderPaymentStatus as l,IkasTransactionStatus as h,IkasCartCampaignOfferStatus as p,IkasCampaignOfferTargetPageType as m,IkasOrderLineItemStatus as f,IkasCustomerEmailSubscriptionStatus as g,IkasCampaignOfferProductApplicablePriceEnum as v}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 y}from"../../models/data/checkout/index.js";import{IkasCheckoutSettings as S}from"../../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 k}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as b}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 C}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 P}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{IkasProduct as I}from"../../models/data/product/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{IkasProductPrice as A}from"../../models/data/product/variant/price/index.js";import{IkasProductVariant as w}from"../../models/data/product/variant/index.js";import"../../models/data/variant-type/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 E}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 N from"./components/credit-card-form/model.js";import O from"../../store/customer/api.js";import j from"../../store/checkout/index.js";import R from"../../store/cart/api.js";import D,{MFS_ELEMENT_ID as T,MFS_SCRIPT_URL as x}from"./modelMasterPass.js";import L from"../../store/product/index.js";import{IkasBaseStore as G}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as M}from"@ikas/storefront-config";import{Analytics as _}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as V,CheckStocksLineInput as U}from"@ikas/storefront-api";import F from"../../models/data/order/address/ikas-localized-order-address.js";import K from"../../store/location/index.js";import{getCookieValue as B}from"../../utils/helper.js";var Z,Y,H=/^\d+$/,q="undefined"==typeof localStorage,W=function(){function H(u,b,C,H,W,X,$,J,ee,te){var ie=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=Z.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.productFiles=[],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.isCampaignOfferLoaded=!0,this.shippingZones=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.showTestModal=!1,this.init=function(){return e(ie,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,G.getInstance().customerStore.waitUntilInitialized()];case 2:return e.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.initStep()];case 3:return e.sent(),[2]}}))}))},this.initStep=function(){return e(ie,void 0,void 0,(function(){var e,s,n,r,a,c,d;return t(this,(function(t){switch(t.label){case 0:if(M.getIsEditor())return this.step=Z.INFO,this.isCheckoutLoaded=!0,[2];if(e=new URLSearchParams(window.location.search),s=e.get("step"),n=e.get("failed"),r=e.get("error"),s){if(this.step=s,this.step===Z.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(Z.INFO)];if(this.step!==Z.PAYMENT||this.canProceedToPayment){if(this.step===Z.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(Z.INFO)];if(![Z.INFO,Z.SUCCESS,Z.SHIPPING,Z.PAYMENT].includes(this.step))return[2,this.changeStep(Z.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings?[2,this.changeStep(Z.INFO)]:[2,this.changeStep(Z.SHIPPING)];this.deliveryMethod="in-store"}}return[4,this.createCampaignOffer()];case 1:return t.sent(),n&&(this.error={type:Y.PAYMENT_ERROR,data:r||null}),this.step!==Z.SHIPPING&&this.step!==Z.PAYMENT||this.isCouponCodeRequirementInvisible||(this.checkoutSettings=new S(i(i({},this.checkoutSettings),{couponCodeRequirement:o.DEFAULT}))),this.step!==Z.INFO?[3,7]:this.isDigitalOnly?[3,4]:[4,this.getAvailableShippingZones()];case 2:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getShippingCountries()];case 3:t.sent(),this.checkShippingCountries(),t.label=4;case 4:return[4,this.getStockLocations()];case 5:return t.sent(),[4,this.getAvailableStockLocations()];case 6:t.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),t.label=7;case 7:return this.step!==Z.SHIPPING||1!==(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=Z.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==Z.SHIPPING||(null===(d=this.checkout.availableShippingMethods)||void 0===d?void 0:d.length)?this.step!==Z.SUCCESS||this.checkout.orderPaymentStatus!==l.PAID?[3,9]:[4,this.listProductFile()]:(this.error={type:Y.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 8:t.sent(),t.label=9;case 9:return this.step!==Z.PAYMENT&&this.step!==Z.SUCCESS?[3,13]:[4,this.listPaymentGateways()];case 10:return t.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,12];case 11:t.sent(),t.label=12;case 12:if(!this.paymentGateways.length)return this.error={type:Y.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];t.label=13;case 13:return this.step===Z.SUCCESS?[3,17]:this.checkout.isComplete?[2,this.changeStep(Z.SUCCESS)]:[3,14];case 14:return[4,this.initialStockCheck()];case 15:t.sent(),t.label=16;case 16:return[3,19];case 17:return[4,this.getSuccessTransaction()];case 18:t.sent(),this.successTransaction&&(a=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===a}))),t.label=19;case 19:return this.isCheckoutLoaded=!0,_.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return e(ie,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return[4,O.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(ie,void 0,void 0,(function(){var e,i,s,n;return t(this,(function(t){switch(t.label){case 0:return e=new V(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!==Z.INFO&&this.step!==Z.SHIPPING||this.isDigitalOnly||(e.billingAddress=null),this.isDigitalOnly&&(e.shippingAddress=null),e.customer&&(this.store.customerStore.customer?e.customer.notificationsAccepted=this.store.customerStore.customer.subscriptionStatus===g.SUBSCRIBED:this.checkout.customer&&(e.customer.notificationsAccepted=this.checkout.customer.notificationsAccepted||!1)),[4,R.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:Y.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:Y.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return e(ie,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(ie,void 0,void 0,(function(){var e,i,s,n,r,o,a,c,u,l,h,p;return t(this,(function(t){switch(t.label){case 0:return this.isManualOrder?[2]:(e=this.checkout.stockLocationId&&this.checkout.shippingMethod===d.CLICK_AND_COLLECT?[this.checkout.stockLocationId]:(null===(l=M.getStockLocationIds())||void 0===l?void 0:l.length)?M.getStockLocationIds():null,[4,j.checkCartStocks({cartId:this.checkout.id,stockLocationIdList:e})]);case 1:if(!(i=t.sent()).isSuccess)throw{type:Y.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(p=null===(h=i.data)||void 0===h?void 0:h.lines)||void 0===p?void 0:p.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++)u=c[a],r(u);throw{type:Y.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return e(ie,void 0,void 0,(function(){return t(this,(function(e){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return e(ie,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,G.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(ie,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,j.getAvailableShippingCountries({salesChannelId:M.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return e(ie,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return M.getPickupStockLocationIds()?[4,j.listStockLocation({id:{in:M.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:Y.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,t.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return e(ie,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return M.getPickupStockLocationIds()?(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,j.getAvailableStockLocations({lines:e.map((function(e){return new U(e)})),stockLocationIdList:M.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=t.sent()).isSuccess)return this.error={type:Y.API_ERROR},[2];this.availableStockLocations=i.data||[],t.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var e;(null===(e=ie.shippingCountryIds)||void 0===e?void 0:e.length)||(ie.error={type:Y.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){"address"===e&&(ie.checkout.stockLocationId=null,ie.checkout.shippingAddress=new F,ie.checkout.shippingAddress.countrySettings=ie.countrySettings,ie.checkout.shippingAddress.checkoutSettings=ie.checkoutSettings,ie.checkout.shippingAddress.shippingZones=ie.shippingZones),ie.deliveryMethod=e,ie.isErrorsVisible=!1},this.initialStockCheck=function(){return e(ie,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:Y.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return e(ie,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=M.getPaymentGateways().map((function(e){return e.id})),[4,j.listPaymentGateway({cartId:this.isUpsellOrder?this.checkout.id:void 0,id:e?void 0:{in:i},locale:M.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===Z.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(M.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===Z.PAYMENT&&(c=n.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id=T,d.src=x,d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout,store:G.getInstance()})},document.head.appendChild(d)),[2]):(this.error={type:Y.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return e(ie,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:return[4,j.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;ie.store.customerStore.customer?(null===(e=ie.customerAddresses)||void 0===e||e.forEach((function(e){e.checkoutSettings=ie.checkoutSettings,e.shippingZones=ie.shippingZones})),ie.checkout.customer=new P(ie.store.customerStore.customer)):ie.checkout.customer=new P(ie.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){ie.checkout.shippingAddress&&(ie.checkout.shippingAddress.checkoutSettings=ie.checkoutSettings,ie.checkout.shippingAddress.shippingZones=ie.shippingZones,ie.checkout.shippingAddress.countrySettings=ie.countrySettings,ie.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){ie.checkout.billingAddress&&(ie.checkout.billingAddress.checkoutSettings=ie.checkoutSettings,ie.checkout.billingAddress.shippingZones=ie.shippingZones,ie.checkout.billingAddress.countrySettings=ie.countrySettings,ie.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!ie.isDigitalOnly)if(ie.isInStoreDelivery)ie.setCheckoutShippingAddressSettings();else if(ie.checkout.shippingAddress){if(ie.store.customerStore.customer){var e=null==(t=ie.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=ie.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return ie.onSelectedShippingAddressIdChange(e.id||"-1"),void ie.setCheckoutShippingAddressSettings()}ie.checkout.shippingAddress=new F(n(ie.checkout.shippingAddress)||{}),ie.setCheckoutShippingAddressSettings()}else if(ie.store.customerStore.customer){var t=ie.customerAddresses;ie.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else ie.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(ie.useDifferentAddress=!!localStorage.getItem("sAddr"),ie.checkout.billingAddress){if(ie.store.customerStore.customer){var e=null==(t=ie.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=ie.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return ie.onSelectedBillingAddressIdChange(e.id||"-1"),void ie.setCheckoutBillingAddressSettings()}ie.checkout.billingAddress=new F(n(ie.checkout.billingAddress)||{}),ie.setCheckoutBillingAddressSettings()}else if(ie.store.customerStore.customer){var t=ie.customerAddresses;ie.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||ie.useDifferentAddress||!ie.checkout.shippingAddress||ie.isInStoreDelivery||(ie.checkout.billingAddress=new F(n(ie.checkout.shippingAddress)),ie.setCheckoutBillingAddressSettings())}else ie.onSelectedBillingAddressIdChange("-1"),ie.useDifferentAddress||!ie.checkout.shippingAddress||ie.isInStoreDelivery||(ie.checkout.billingAddress=new F(n(ie.checkout.shippingAddress)),ie.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(i){return e(ie,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 y(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(ie,void 0,void 0,(function(){return t(this,(function(e){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return e(ie,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,R.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===Z.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,currencyCode:this.checkout.currencyCode}}),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,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,4];case 2:t.sent(),t.label=3;case 3:s&&(r=this.checkout,this.checkout=new y(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(ie,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,K.getAvailableShippingZones({salesChannelId:M.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(ie.selectedShippingAddressId=e,"-1"===e)ie.checkout.shippingAddress=new F,ie.checkout.shippingAddress.countrySettings=ie.countrySettings;else{var i=null===(t=ie.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(ie.checkout.shippingAddress=new F(i),ie.checkout.shippingAddress.countrySettings=ie.countrySettings)}ie.checkout.shippingAddress&&(ie.checkout.shippingAddress.checkoutSettings=ie.checkoutSettings,ie.checkout.shippingAddress.shippingZones=ie.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(ie.selectedBillingAddressId=e,"-1"===e)ie.checkout.billingAddress=new F,ie.checkout.billingAddress.countrySettings=ie.countrySettings;else{var i=null===(t=ie.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(ie.checkout.billingAddress=new F(i),ie.checkout.billingAddress.countrySettings=ie.countrySettings)}ie.checkout.billingAddress&&(ie.checkout.billingAddress.checkoutSettings=ie.checkoutSettings,ie.checkout.billingAddress.shippingZones=ie.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){ie.isTermsAndConditionsChecked=e},this.onCardNumberChange=function(e){if(ie.cardData&&(!(e.length>ie.cardData.cardNumber.length)||z(e))){var t=(ie.cardData.cardNumber||"").split(" ").join(""),i=e.split(" ").join("");i.length>16||(t.length<6&&i.length>=6&&!ie.installmentInfo?ie.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:ie.checkout.selectedPaymentGateway.id,price:ie.checkout.totalFinalPrice,currencyCode:ie.checkout.currencyCode}}):i.length<6&&t.length>i.length&&(ie.cardData.installmentCount=1,ie.installmentInfo=void 0),ie.cardData.cardNumber=Q(i,4).join(" "))}},this.onCardHolderNameChange=function(e){ie.cardData&&(ie.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(ie.cardData&&(!(e.length>ie.cardData.expirationDate.length)||z(e))){if(0===(null===(t=ie.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(ie.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(ie.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(ie.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(ie.cardData.expirationDate=Q(d,2).join(" / "))}},this.onCvcChange=function(e){ie.cardData&&(e.length>ie.cardData.cvv.length&&!z(e)||e.length>4||(ie.cardData.cvv=e))},this.saveAddress=function(s){return e(ie,void 0,void 0,(function(){var e,r,o,a,c,d,u,l,h,p,m,f,g=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 k(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===(m=this.customerAddresses)||void 0===m||m.forEach((function(e){e.checkoutSettings=g.checkoutSettings,e.shippingZones=g.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(){ie.router.push("/cart")},this.onBackToShoppingClick=function(){ie.router.push("/")},this.onGoToLoginClick=function(){ie.router.push("/account/login")},this.onProceedToShippingClick=function(){return e(ie,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(Z.SHIPPING):this.changeStep(Z.PAYMENT),[3,7];case 6:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:Y.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return e(ie,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(Z.PAYMENT),[3,5];case 4:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:Y.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return e(ie,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(Z.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:Y.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!ie.canPerformPayment||(ie.isErrorsVisible=!0,!1)},this.onCompletePaymentClick=function(){return e(ie,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.isFree||!this.isKlarna?[3,2]:[4,this.saveCart()]):(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.isFree&&this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):!this.isFree&&this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):!this.isFree&&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:Y.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return e(ie,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:Y.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return e(ie,void 0,void 0,(function(){var e,i,s,n,r,o,d,u,l,p,m,f,g,v,y,S;return t(this,(function(t){switch(t.label){case 0:return i=this.mpVM.selectedCard,!this.isFree&&i&&(null===(u=this.mpVM.selectedCard)||void 0===u?void 0:u.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(e=n),void 0===(null===(l=this.cardData)||void 0===l?void 0:l.installmentCount)?[2]:[4,j.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===(f=this.cardData)||void 0===f?void 0:f.threeDSecure)},metadata:{_fbp:B("_fbp"),_fbc:B("_fbc")}}})]):[3,2];case 1:return s=t.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,j.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:this.isFree?void 0:i&&e?{phoneNumber:e,savedCardName:null===(g=this.mpVM.selectedCard)||void 0===g?void 0:g.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:this.isFree||i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===a.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===c.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,o=r&&[h.SUCCESS,h.AUTHORIZED].includes(r),d=r===h.PENDING,o?[4,this.getSuccessTransaction()]:[3,7];case 5:return t.sent(),[4,this.onCheckoutTransactionSuccess((null===(y=null==s?void 0:s.data)||void 0===y?void 0:y.orderId)||void 0)];case 6:return t.sent(),[3,8];case 7:if(!d||!(null===(S=null==s?void 0:s.data)||void 0===S?void 0:S.returnSlug))throw{data:s.firstErrorMessage,type:Y.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,t.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(i){return e(ie,void 0,void 0,(function(){var e,s;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===(s=this.checkout.customer)||void 0===s?void 0:s.email)||"")]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.changeStep(Z.SUCCESS,i),[2]}}))}))},this.onBackToInfoClick=function(){ie.changeStep(Z.INFO)},this.onBackToShippingClick=function(){ie.changeStep(Z.SHIPPING)},this.setCustomerConsentGranted=function(e){ie.checkout.customer&&(ie.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(e){ie.useDifferentAddress=e,ie.useDifferentAddress?(localStorage.setItem("sAddr","1"),ie.checkout.billingAddress=ie.checkout.billingAddress||new F,ie.checkout.billingAddress.countrySettings=ie.countrySettings):(localStorage.removeItem("sAddr"),ie.checkout.billingAddress=ie.checkout.shippingAddress)},this.setShouldSaveAddress=function(e){ie.shouldSaveAddress=e},this.setAddressTitle=function(e){ie.addressTitle=e},this.reInitPaymentMethod=function(){return e(ie,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(ie,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,j.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(ie,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,j.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(ie,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,j.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(ie,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,j.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(ie,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!==Z.SUCCESS&&(e.paymentMethodType===a.CREDIT_CARD&&e.type===c.INTERNAL&&(this.cardData=new N,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){ie.cardData&&(ie.cardData.installmentCount=e)},this.changeStep=function(i,s){return e(ie,void 0,void 0,(function(){return t(this,(function(e){return q||window.location.replace("".concat(window.location.pathname,"?id=").concat(s||this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return e(ie,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){ie.isContactModalVisible=e},this.getCampaignOffer=function(s,n){return e(ie,void 0,void 0,(function(){var e,r,o,a,c,d,u,l;return t(this,(function(h){switch(h.label){case 0:if(!(null==n?void 0:n.length))return[2];e=n.filter((function(e){var t;return e.status===p.WAITING_FOR_ACTION&&(null===(t=e.campaignOffer)||void 0===t?void 0:t.targetPageTypes.some((function(e){return e===s})))})),r=function(e){var s,n,r,o,a,c;return t(this,(function(t){switch(t.label){case 0:return(null==e?void 0:e.campaignOffer)&&(s=e.campaignOffer.offers.find((function(t){return t.id===e.campaignOfferProductId})))?(n=[s.productId],[4,L.searchProducts({input:{productIdList:n,priceListId:M.getPriceListId(),salesChannelId:M.getSalesChannelId()}})]):[2,{value:void 0}];case 1:return(r=t.sent()).isSuccess&&(null===(l=null===(u=r.data)||void 0===u?void 0:u.data)||void 0===l?void 0:l.length)&&(o=r.data.data[0],(a=o.variants.filter((function(e){return e.hasStock&&!(s.excludedVariantIdList||[]).some((function(t){return t===e.id}))})).map((function(e){return s.discountAmount?new w(i(i({},e),{prices:e.prices.map((function(e){var t=e.finalPrice,n=e.finalPrice-e.finalPrice*s.discountAmount/100;return s.applicablePrice===v.SELL_PRICE&&(t=e.sellPrice,n=e.sellPrice-e.sellPrice*s.discountAmount/100),new A(i(i({},e),{sellPrice:t,discountPrice:n}))}))})):e}))).length)?(c=a.find((function(e){return e.isActive})),[2,{value:{product:new I(i(i({},o),{selectedVariantValues:(c||a[0]).variantValues,variants:a})),offer:s,campaignOffer:e}}]):[2]}}))},o=0,a=e,h.label=1;case 1:return o<a.length?(c=a[o],[5,r(c)]):[3,4];case 2:if("object"==typeof(d=h.sent()))return[2,d.value];h.label=3;case 3:return o++,[3,1];case 4:return[2,void 0]}}))}))},this.createCampaignOffer=function(){return e(ie,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return e=this,[4,this.getCampaignOffer(this.step===Z.SUCCESS?m.POST_CHECKOUT:m.CHECKOUT,this.checkout.campaignOffers)];case 1:return e.campaignOffer=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return e(ie,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:return i.accepted?this.isCheckoutLoaded=!1:this.isCampaignOfferLoaded=!1,[4,R.updateCartCampaignOffer({input:i})];case 1:return(e=t.sent()).isSuccess?i.accepted?(this.changeStep(this.step===Z.SUCCESS?Z.PAYMENT:this.step,null===(s=e.data)||void 0===s?void 0:s.id),[3,4]):[3,2]:[3,4];case 2:return this.checkout.campaignOffers=(null===(n=e.data)||void 0===n?void 0:n.campaignOffers)||[],[4,this.createCampaignOffer()];case 3:t.sent(),this.isCampaignOfferLoaded=!0,t.label=4;case 4:return[2]}}))}))},this.registerCustomer=function(i){return e(ie,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,O.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.listProductFile=function(){return e(ie,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return(e=this.checkout.orderLineItems.filter((function(e){return!!e.variant.fileId&&e.status!==f.REFUNDED})).map((function(e){return e.variant.fileId}))).length?[4,j.listProductFile({id:{in:e}})]:[3,2];case 1:(i=t.sent()).isSuccess&&(this.productFiles=i.data||[]),t.label=2;case 2:return[2]}}))}))},this.getDigitalProductFileDownloadUrl=function(i){return e(ie,void 0,void 0,(function(){var e,s,n,r,o;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),(e=this.checkout.orderLineItems.find((function(e){return e.variant.id===i.variantId})))?[4,j.getDigitalProductFileDownloadUrl({orderId:this.checkout.id,orderLineItemId:e.id})]:[3,2];case 1:s=t.sent(),(n=s.data)&&((r=document.createElement("a")).href=n,r.download=function(e){try{return decodeURIComponent(e.split("/")[e.split("/").length-1])}catch(e){return""}}(i.name),r.click(),r.remove()),t.label=2;case 2:return[3,4];case 3:return o=t.sent(),console.error(o),[3,4];case 4:return[2]}}))}))},this.checkout=u,this.checkoutSettings=b,this.router=C,this.returnPolicy=H,this.privacyPolicy=W,this.termsOfService=X,this.imprint=$,this.shippingPolicy=J,this.t=ee,this.customizationProps=te,this.mpVM=new D,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new E({currentLocale:M.getCurrentLocale()}),this.init(),s(this)}return Object.defineProperty(H.prototype,"merchantSettings",{get:function(){return new C(M.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.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(H.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=G.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(H.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(H.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"finalPrice",{get:function(){return this.step===Z.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===Y.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(H.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)!==Y.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"store",{get:function(){return G.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isCouponCodeRequirementDefult",{get:function(){return this.checkoutSettings.couponCodeRequirement===o.DEFAULT||null===this.checkoutSettings.couponCodeRequirement},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isCouponCodeRequirementOpen",{get:function(){return this.checkoutSettings.couponCodeRequirement===o.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isCouponCodeRequirementInvisible",{get:function(){return this.checkoutSettings.couponCodeRequirement===o.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isCouponCodeVisible",{get:function(){return this.isCouponCodeRequirementDefult&&!this.isCouponCodeRequirementInvisible},enumerable:!1,configurable:!0}),Object.defineProperty(H.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)===a.CREDIT_CARD&&i.type===c.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(H.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===d.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(H.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 b(i({countrySettings:s.countrySettings},e));return t.checkoutSettings=s.checkoutSettings,t.shippingZones=s.shippingZones,t.getValidatedCustomerAddress(),t}))},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===u.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isUpsellOrder",{get:function(){return this.checkout.createdBy===u.UPSELL},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isEPayKolayEnabled",{get:function(){var e=M.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isPoweredByHidden",{get:function(){var e=M.getCustom();return!!e&&!!e.hidePoweredBy},enumerable:!1,configurable:!0}),H.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},H}();function Q(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function z(e){return e&&H.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(Z||(Z={})),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"}(Y||(Y={}));export{Z as CheckoutStep,Y as ErrorType,W as default};
|