@ikas/storefront 5.0.0-beta.20 → 5.0.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as i}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s,observable as n}from"mobx";import r from"lodash/cloneDeep";import o from"lodash/sortBy";import{IkasPaymentMethodType as a,IkasPaymentGatewayType as c,IkasOrderShippingMethod as d,IkasCartCreatedBy as u,IkasTransactionStatus as l,IkasCartCampaignOfferStatus as h,IkasCampaignOfferTargetPageType as p}from"@ikas/storefront-models";import{LocalizedAddressModel as f}from"@ikas/localized-address";import{createIkasLocalizedOrderAddress as m,isValidAddress as g}from"../../models/data/localized-order-address/functions.js";import{listOrderTransactions as v,saveCart as y,SaveCartInput as k,checkStocks as S,CheckStocksLineInput as b,getAvailableShippingCountries as P,listStockLocations as C,getAvailableStockLocations as A,listPaymentGateway as I,retrieveInstallmentInfo as w,saveCartCouponCode as N,createSaleTransactionWithCart as E,createStripePaymentIntent as O,searchProducts as D,updateCartCampaignOffer as G,register as T,getPayPalClientId as R,createAdyenClientToken as L,createKlarnaClientToken as j}from"@ikas/storefront-api";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import{IkasStorefrontConfig as M}from"@ikas/storefront-config";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/product-list/functions.js";import"../../models/ui/product-list/index.js";import"@ikas/storefront-providers";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 x from"./components/credit-card-form/model.js";import V,{MFS_ELEMENT_ID as _,MFS_SCRIPT_URL as U}from"./modelMasterPass.js";import"../../store/base/index.js";import"lodash/flatten";import{IkasCustomerAddressFunctions as K,IkasCheckoutFunctions as B,IkasOrderFunctions as F,IkasProductVariantFunctions as Y}from"@ikas/storefront-model-functions";import{waitForCustomerStoreInit as H}from"../../store/customer/functions.js";import{checkoutStep as W}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasCustomerStore as q}from"../../store/customer/index.js";import{saveCustomer as Q,logout as z}from"../../store/customer/account-auth/functions.js";import"../../store/customer/captcha/data.js";import"../../store/customer/consent/data.js";import{createEmailSubscription as Z}from"../../store/customer/marketing/functions.js";import"../../store/customer/order/data.js";import"../../store/customer/product/data.js";import"lodash/xorBy";import"../../store/cart/index.js";import{changeItemQuantity as X}from"../../store/cart/functions.js";import{CheckoutStep as $,ErrorType as J}from"./types.js";var tt=/^\d+$/,et="undefined"==typeof localStorage,it=function(){function tt(n,d,u,g,K,F,tt,it,rt,ot){var at=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=$.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.adyenResponse=null,this.payPalClientIdResponse=null,this.paypalOrderResponse=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.showTestModal=!1,this.init=function(){return t(at,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.countrySettings.waitUntilInitialized()];case 1:return t.sent(),[4,H()];case 2:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getCampaignOffer()];case 3:return t.sent(),[4,this.initStep()];case 4:return t.sent(),[2]}}))}))},this.initStep=function(){return t(at,void 0,void 0,(function(){var t,i,s,n,r,o,a,c;return e(this,(function(e){switch(e.label){case 0:if(M.getIsEditor())return this.step=$.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),i=t.get("step"),s=t.get("failed"),n=t.get("error"),i){if(this.step=i,this.step===$.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep($.INFO)];if(this.step!==$.PAYMENT||this.canProceedToPayment){if(this.step===$.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep($.INFO)];if(![$.INFO,$.SUCCESS,$.SHIPPING,$.PAYMENT].includes(this.step))return[2,this.changeStep($.INFO)]}else{if(!this.isInStoreDelivery)return[2,this.changeStep($.INFO)];this.deliveryMethod="in-store"}}return s&&(this.error={type:J.PAYMENT_ERROR,data:n||null}),this.step!==$.INFO?[3,4]:[4,this.getShippingCountries()];case 1:return e.sent(),this.checkShippingCountries(),[4,this.getStockLocations()];case 2:return e.sent(),[4,this.getAvailableStockLocations()];case 3:e.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),e.label=4;case 4:return this.step!==$.SHIPPING||1!==(null===(a=this.checkout.availableShippingMethods)||void 0===a?void 0:a.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=$.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==$.SHIPPING||(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)?this.step!==$.PAYMENT&&this.step!==$.SUCCESS?[3,8]:[4,this.listPaymentGateways()]:(this.error={type:J.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 5:return e.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,7];case 6:e.sent(),e.label=7;case 7:if(!this.paymentGateways.length)return this.error={type:J.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=8;case 8:return r=B.isCheckoutComplete,this.step===$.SUCCESS?[3,12]:r(this.checkout)?[2,this.changeStep($.SUCCESS)]:[3,9];case 9:return[4,this.initialStockCheck()];case 10:e.sent(),e.label=11;case 11:return[3,14];case 12:return[4,this.getSuccessTransaction()];case 13:e.sent(),this.successTransaction&&(o=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(t){return t.id===o}))),e.label=14;case 14:return this.isCheckoutLoaded=!0,W(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return t(at,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,v({orderId:{eq:this.checkout.id}})];case 1:return t=e.sent(),this.successTransaction=t.isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?t.data[t.data.length-1]:void 0,[2]}}))}))},this.saveCart=function(){return t(at,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return t=new k(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(t)];case 1:t=e.sent(),e.label=2;case 2:return this.step!==$.INFO&&this.step!==$.SHIPPING||this.isDigitalOnly||(t.billingAddress=null),this.isDigitalOnly&&(t.shippingAddress=null),[4,y({input:t})];case 3:if((null==(i=e.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:J.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:J.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return t(at,void 0,void 0,(function(){var t,s,n=this;return e(this,(function(e){return t=i,(s=this.stockLocations.find((function(t){return t.id===n.checkout.stockLocationId})))&&t.shippingAddress&&s.address&&(t.shippingAddress.country=s.address.country,t.shippingAddress.city=s.address.city,t.shippingAddress.state=s.address.state,t.shippingAddress.district=s.address.district,t.shippingAddress.postalCode=s.address.postalCode,t.shippingAddress.addressLine1=s.address.address||"",t.shippingAddress.addressLine2=null),[2,t]}))}))},this.checkStocks=function(){return t(at,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,l,h;return e(this,(function(e){switch(e.label){case 0:return this.isManualOrder?[2]:(t=this.checkout.orderLineItems.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,S({lines:t.map((function(t){return new b(t)})),stockLocationIdList:(null===(u=M.getStockLocationIds())||void 0===u?void 0:u.length)?M.getStockLocationIds():null})]);case 1:if(!(i=e.sent()).isSuccess)throw{type:J.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(h=null===(l=i.data)||void 0===l?void 0:l.lines)||void 0===h?void 0:h.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=o.checkout.orderLineItems.find((function(e){return e.variant.id===t.variantId}));e&&n.push({item:e,stockCount:t.stockCount})},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:J.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return t(at,void 0,void 0,(function(){return e(this,(function(t){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return t(at,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:t=0,s=i,e.label=1;case 1:return t<s.length?(n=s[t],[4,X(n.item,n.stockCount<0?0:n.stockCount)]):[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(at,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,P({salesChannelId:M.getSalesChannelId()})];case 1:return t=e.sent(),this.shippingCountryIds=t.data,[2]}}))}))},this.getStockLocations=function(){return t(at,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return M.getPickupStockLocationIds()?[4,C({id:{in:M.getPickupStockLocationIds()}})]:[3,2];case 1:if(!(t=e.sent()).isSuccess||!(null===(i=t.data)||void 0===i?void 0:i.length))return this.error={type:J.API_ERROR,data:t.firstErrorMessage},[2];this.stockLocations=t.data,e.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(at,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return M.getPickupStockLocationIds()?(t=this.checkout.orderLineItems.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,A({lines:t.map((function(t){return new b(t)})),stockLocationIdList:M.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=e.sent()).isSuccess)return this.error={type:J.API_ERROR},[2];this.availableStockLocations=i.data||[],e.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=at.shippingCountryIds)||void 0===t?void 0:t.length)||(at.error={type:J.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(t){"address"===t&&(at.checkout.stockLocationId=null),at.deliveryMethod=t,at.isErrorsVisible=!1},this.initialStockCheck=function(){return t(at,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return e.sent(),[3,3];case 2:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:J.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(at,void 0,void 0,(function(){var t,i,s,n,r,a,c,d,u,l,h=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=M.getPaymentGateways().map((function(t){return t.id})),[4,I({id:t?void 0:{in:i},locale:M.getCurrentLocale(),transactionAmount:this.checkout.totalFinalPrice})];case 1:return(s=e.sent()).isSuccess&&(null===(u=s.data)||void 0===u?void 0:u.length)?(n=s.data,this.step===$.PAYMENT&&(n=n.filter((function(t){var e;return!(null===(e=t.supportedCurrencies)||void 0===e?void 0:e.length)||t.supportedCurrencies.includes(h.checkout.currencyCode)})),(r=null===(l=this.checkout.shippingAddress)||void 0===l?void 0:l.country)&&r.iso2&&(n=n.filter((function(t){var e;return!(null===(e=t.availableCountries)||void 0===e?void 0:e.length)||t.availableCountries.includes(r.iso2||"")})))),a=[],o(M.getPaymentGateways(),"order").forEach((function(t){var e=null==n?void 0:n.find((function(e){return e.id===t.id}));e&&a.push(e)})),this.paymentGateways=t?n:a,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),this.step===$.PAYMENT&&(c=n.find((function(t){return!!t.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id=_,d.src=U,d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout})},document.head.appendChild(d)),[2]):(this.error={type:J.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(at,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return[4,w(i)];case 1:return t=e.sent(),s=t.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(t,e){return(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var t;q.customer?(null===(t=at.customerAddresses)||void 0===t||t.forEach((function(t){return t.checkoutSettings=at.checkoutSettings})),at.checkout.customer=r(q.customer)):at.checkout.customer=r(at.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){at.checkout.shippingAddress&&(at.checkout.shippingAddress.checkoutSettings=at.checkoutSettings,at.checkout.shippingAddress.countrySettings=at.countrySettings)},this.setCheckoutBillingAddressSettings=function(){at.checkout.billingAddress&&(at.checkout.billingAddress.checkoutSettings=at.checkoutSettings,at.checkout.billingAddress.countrySettings=at.countrySettings)},this.createShippingAddress=function(){if(!at.isDigitalOnly)if(at.isInStoreDelivery)at.setCheckoutShippingAddressSettings();else if(at.checkout.shippingAddress){if(q.customer){var t=null==(e=at.customerAddresses)?void 0:e.find((function(t){var e;return t.id===(null===(e=at.checkout.shippingAddress)||void 0===e?void 0:e.id)}));if(t)return at.onSelectedShippingAddressIdChange(t.id||"-1"),void at.setCheckoutShippingAddressSettings()}at.checkout.shippingAddress=r(at.checkout.shippingAddress)||{},at.setCheckoutShippingAddressSettings()}else if(q.customer){var e=at.customerAddresses;at.onSelectedShippingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}else at.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(at.useDifferentAddress=!!localStorage.getItem("sAddr"),at.checkout.billingAddress){if(q.customer){var t=null==(e=at.customerAddresses)?void 0:e.find((function(t){var e;return t.id===(null===(e=at.checkout.billingAddress)||void 0===e?void 0:e.id)}));if(t)return at.onSelectedBillingAddressIdChange(t.id||"-1"),void at.setCheckoutBillingAddressSettings()}at.checkout.billingAddress=r(at.checkout.billingAddress)||{},at.setCheckoutBillingAddressSettings()}else if(q.customer){var e=at.customerAddresses;at.onSelectedBillingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1"),(null==e?void 0:e.length)||at.useDifferentAddress||!at.checkout.shippingAddress||at.isInStoreDelivery||(at.checkout.billingAddress=r(at.checkout.shippingAddress),at.setCheckoutBillingAddressSettings())}else at.onSelectedBillingAddressIdChange("-1"),at.useDifferentAddress||!at.checkout.shippingAddress||at.isInStoreDelivery||(at.checkout.billingAddress=r(at.checkout.shippingAddress),at.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(s){return t(at,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=s.shippingSettingsId,this.checkout.shippingZoneRateId=s.shippingZoneRateId,[4,this.saveCart()]);case 1:return(t=e.sent())&&(this.checkout=i(i({},t),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,customer:this.checkout.customer,selectedPaymentGateway:this.checkout.selectedPaymentGateway})),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return t(at,void 0,void 0,(function(){return e(this,(function(t){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return t(at,void 0,void 0,(function(){var t,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,N({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=e.sent()).isSuccess&&t.data?(s=t.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===$.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{binNumber:this.mpVM.selectedCard.Value1.slice(0,6),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:s.totalFinalPrice}})]:[3,3]):[3,4];case 2:e.sent(),e.label=3;case 3:s&&(r=this.checkout,this.checkout=i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway})),e.label=4;case 4:return t.isSuccess||(this.couponError=t.errorCodes[0]),[3,6];case 5:return e.sent(),[3,6];case 6:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e;if(at.selectedShippingAddressId=t,"-1"===t)at.checkout.shippingAddress=m({},at.checkoutSettings,at.countrySettings),at.checkout.shippingAddress.countrySettings=at.countrySettings;else{var i=null===(e=at.customerAddresses)||void 0===e?void 0:e.find((function(e){return e.id===t}));i&&(at.checkout.shippingAddress=m(i,at.checkoutSettings,at.countrySettings))}at.checkout.shippingAddress&&(at.checkout.shippingAddress.checkoutSettings=at.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e;if(at.selectedBillingAddressId=t,"-1"===t)at.checkout.billingAddress=m({},at.checkoutSettings,at.countrySettings);else{var i=null===(e=at.customerAddresses)||void 0===e?void 0:e.find((function(e){return e.id===t}));i&&(at.checkout.billingAddress=m(i,at.checkoutSettings,at.countrySettings))}at.checkout.billingAddress&&(at.checkout.billingAddress.checkoutSettings=at.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){at.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(at.cardData&&(!(t.length>at.cardData.cardNumber.length)||nt(t))){var e=(at.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!at.installmentInfo?at.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:at.checkout.selectedPaymentGateway.id,price:at.checkout.totalFinalPrice}}):i.length<6&&e.length>i.length&&(at.cardData.installmentCount=1,at.installmentInfo=void 0),at.cardData.cardNumber=st(i,4).join(" "))}},this.onCardHolderNameChange=function(t){at.cardData&&(at.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(at.cardData&&(!(t.length>at.cardData.expirationDate.length)||nt(t))){if(0===(null===(e=at.cardData.expirationDate)||void 0===e?void 0:e.length)){var i=t.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(at.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(at.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(at.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=t.split(" / ").join("");d.length>4||(at.cardData.expirationDate=st(d,2).join(" / "))}},this.onCvcChange=function(t){at.cardData&&(t.length>at.cardData.cvv.length&&!nt(t)||t.length>4||(at.cardData.cvv=t))},this.saveAddress=function(s){return t(at,void 0,void 0,(function(){var t,n,o,a,c,d,u,l,h,p,f,m,g=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.shouldSaveAddress&&q.customer?(t="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(h=this.customerAddresses)||void 0===h?void 0:h.find((function(e){return e.id===(null==t?void 0:t.id)})))?[2]:(n=null===(p=this.customerAddresses)||void 0===p?void 0:p.map((function(t){return t.id})),o=i(i({},t),{title:this.addressTitle||this.t("checkout-page:newAddress")}),(a=r(q.customer)).addresses||(a.addresses=[]),a.addresses.push(o),[4,Q(a)])):[3,2];case 1:e.sent(),null===(f=this.customerAddresses)||void 0===f||f.forEach((function(t){return t.checkoutSettings=g.checkoutSettings})),c=null===(m=this.customerAddresses)||void 0===m?void 0:m.map((function(t){return t.id})),d=null==c?void 0:c.filter((function(t){return!(null==n?void 0:n.includes(t))})),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"),e.label=2;case 2:return[3,4];case 3:return l=e.sent(),console.error(l),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){at.router.push("/cart")},this.onBackToShoppingClick=function(){at.router.push("/")},this.onGoToLoginClick=function(){at.router.push("/account/login")},this.onProceedToShippingClick=function(){return t(at,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.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,e.label=1;case 1:return e.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:e.sent(),e.label=3;case 3:return[4,this.checkStocks()];case 4:return e.sent(),[4,this.saveCart()];case 5:return e.sent(),"address"===this.deliveryMethod?this.changeStep($.SHIPPING):this.changeStep($.PAYMENT),[3,7];case 6:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:J.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return t(at,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCart()];case 3:return e.sent(),this.changeStep($.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:J.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(at,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCart()];case 3:return e.sent(),this.error=void 0,this.changeStep($.PAYMENT),[3,5];case 4:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:J.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!at.canPerformPayment||(at.isErrorsVisible=!0,!1)},this.onCompletePaymentClick=function(){return t(at,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return this.canPerformPayment?(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isKlarna?[4,this.saveCart()]:[3,2]):(this.isErrorsVisible=!0,[2]);case 1:return e.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return e.trys.push([2,8,,9]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return e.sent(),"address"===this.deliveryMethod&&this.useDifferentAddress?[4,this.saveAddress("billing")]:[3,5];case 4:e.sent(),e.label=5;case 5:return[4,this.saveCart()];case 6:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):this.isPayPal?[2]:[4,this.createSaleTransaction()];case 7:return e.sent(),[3,9];case 8:return void 0!==typeof(i=e.sent()).type?this.error=i:this.error={type:J.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return t(at,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.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 e.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return e.trys.push([2,6,,7]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return e.sent(),[4,this.saveCart()];case 4:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):this.isPayPal?[2]:[4,this.createSaleTransaction()];case 5:return e.sent(),[3,7];case 6:return(i=e.sent()).type?this.error=i:this.error={type:J.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return t(at,void 0,void 0,(function(){var t,i,s,n,r,o,d,u,h,p,f,m,g,v,y;return e(this,(function(e){switch(e.label){case 0:return(i=this.mpVM.selectedCard)&&(null===(u=this.mpVM.selectedCard)||void 0===u?void 0:u.Name)?((n=this.mpVM.phoneNumber({checkout:this.checkout}))&&(t=n),void 0===(null===(h=this.cardData)||void 0===h?void 0:h.installmentCount)?[2]:[4,E({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name},paymentGatewayId:null===(f=this.mpVM.selectedCard)||void 0===f?void 0:f.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===(m=this.cardData)||void 0===m?void 0:m.threeDSecure)}}})]):[3,2];case 1:return s=e.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,E({input:{cartId:this.checkout.id,masterPassDetail:i&&t?{phoneNumber:t,savedCardName:null===(g=this.mpVM.selectedCard)||void 0===g?void 0:g.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail: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=e.sent(),e.label=4;case 4:return r=null===(v=null==s?void 0:s.data)||void 0===v?void 0:v.transactionStatus,o=r&&[l.SUCCESS,l.AUTHORIZED].includes(r),d=r===l.PENDING,o?[4,this.getSuccessTransaction()]:[3,7];case 5:return e.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return e.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:J.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,e.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return t(at,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return localStorage.removeItem("sAddr"),(null===(t=this.checkout.customer)||void 0===t?void 0:t.notificationsAccepted)?[4,Z((null===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.changeStep($.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){at.changeStep($.INFO)},this.onBackToShippingClick=function(){at.changeStep($.SHIPPING)},this.setCustomerConsentGranted=function(t){at.checkout.customer&&(at.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){at.useDifferentAddress=t,at.useDifferentAddress?(localStorage.setItem("sAddr","1"),at.checkout.billingAddress=at.checkout.billingAddress||m({},at.checkoutSettings,at.countrySettings),at.checkout.billingAddress.countrySettings=at.countrySettings):(localStorage.removeItem("sAddr"),at.checkout.billingAddress=at.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){at.shouldSaveAddress=t},this.setAddressTitle=function(t){at.addressTitle=t},this.setPaymentGateway=function(i){return t(at,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return this.paymentGateways.length?"STRIPE"!==(t=this.paymentGateways[i]).code||!(null===(n=t.settings)||void 0===n?void 0:n.find((function(t){return"allow_custom_flow"===t.label&&"1"===t.value})))||this.stripeResponse?[3,2]:[4,O({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})]:[2];case 1:(s=e.sent()).isSuccess&&s.data&&(this.stripeResponse=s.data),e.label=2;case 2:return"KLARNA"!==t.code||this.klarnaResponse?[3,4]:[4,j({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})];case 3:(s=e.sent()).isSuccess&&s.data&&(this.klarnaResponse=s.data),e.label=4;case 4:return"ADYEN"!==t.code||this.adyenResponse?[3,6]:[4,L({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})];case 5:(s=e.sent()).isSuccess&&s.data&&(this.adyenResponse=s.data),e.label=6;case 6:return"PAYPAL"!==t.code||this.payPalClientIdResponse?[3,8]:[4,R({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})];case 7:(s=e.sent()).isSuccess&&s.data&&(this.payPalClientIdResponse=s.data),e.label=8;case 8:return this.checkout.selectedPaymentGateway=t,this.step!==$.SUCCESS&&(t.paymentMethodType===a.CREDIT_CARD&&t.type===c.INTERNAL&&(this.cardData=new x,t.masterPassClientId&&(console.log("called 1511 ikas log"),this.mpVM.checkMasterPass({checkout:this.checkout}))),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(t){at.cardData&&(at.cardData.installmentCount=t)},this.changeStep=function(i){return t(at,void 0,void 0,(function(){return e(this,(function(t){return et||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return t(at,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:this.checkout.customer=null,z(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return t.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(t){at.isContactModalVisible=t},this.getCampaignOfferProducts=function(i){return t(at,void 0,void 0,(function(){var t,s,n,r;return e(this,(function(o){switch(o.label){case 0:if(!this.checkout.campaignOffers||!this.checkout.campaignOffers.length)return[3,4];if(t=this.checkout.campaignOffers.filter((function(t){var e;return t.status===h.WAITING_FOR_ACTION&&(null===(e=t.campaignOffer)||void 0===e?void 0:e.targetPageTypes.some((function(t){return t===i})))})),!t.length)return[3,4];s=function(i){var s,n,r,o,a,c;return e(this,(function(e){switch(e.label){case 0:return(s=t[i]).campaignOffer&&(n=s.campaignOffer.offers.find((function(t){return t.id===s.campaignOfferProductId})))?[4,D({input:{productIdList:[n.productId]}})]:[3,2];case 1:if((r=e.sent()).isSuccess&&r.data&&r.data.data&&r.data.data.length&&(o=r.data.data[0],a=[],c=Y.hasVariantStock,n.excludedVariantIdList&&n.excludedVariantIdList.length?o.variants.map((function(t){var e;c(t)&&!(null===(e=n.excludedVariantIdList)||void 0===e?void 0:e.some((function(e){return e===t.id})))&&a.push(t)})):a.push.apply(a,o.variants.filter((function(t){return c(t)}))),a.length))return[2,{value:{product:o,variants:a,campaignOffer:s,offer:n}}];e.label=2;case 2:return[2]}}))},n=0,o.label=1;case 1:return n<t.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 t(at,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getCampaignOfferProducts(p.CHECKOUT)];case 1:return t.checkoutCampaignOffer=e.sent(),i=this,[4,this.getCampaignOfferProducts(p.POST_CHECKOUT)];case 2:return i.postCheckoutCampaignOffer=e.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(s){return t(at,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isCheckoutLoaded=!1,[4,G({input:s})];case 1:return(t=e.sent())&&t.isSuccess&&t.data&&(this.checkout=i(i({},t.data),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,selectedPaymentGateway:this.checkout.selectedPaymentGateway}),s.accepted&&this.step===$.SUCCESS?this.changeStep($.INFO):this.changeStep(this.step)),[2]}}))}))},this.registerCustomer=function(i){return t(at,void 0,void 0,(function(){var t,s,n,r;return e(this,(function(e){switch(e.label){case 0:return this.checkout.customer?(t=this.checkout.customer,s=t.firstName,n=t.lastName,r=t.email,s&&n&&r?[4,T({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:i})]:[3,2]):[3,2];case 1:return[2,e.sent()];case 2:return[2]}}))}))},this.checkout=n,this.checkoutSettings=d,this.router=u,this.returnPolicy=g,this.privacyPolicy=K,this.termsOfService=F,this.imprint=tt,this.shippingPolicy=it,this.t=rt,this.customizationProps=ot,this.mpVM=new V,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new f({currentLocale:M.getCurrentLocale()}),this.init(),s(this)}return Object.defineProperty(tt.prototype,"merchantSettings",{get:function(){return M.getMerchantSettings()},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"selectedPaymentGatewayIndex",{get:function(){var t=this;return this.paymentGateways.findIndex((function(e){var i;return e.id===(null===(i=t.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"selectedInstallmentIndex",{get:function(){var t,e,i=this;return(null===(e=null===(t=this.installmentInfo)||void 0===t?void 0:t.installmentPrices)||void 0===e?void 0:e.findIndex((function(t){var e;return t.installmentCount===(null===(e=i.cardData)||void 0===e?void 0:e.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"customerAddressOptions",{get:function(){var t,e,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=K.getCustomerAddressText,n=(null===(e=null===(t=q.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.map((function(t){return{label:t.title+" - "+s(t),value:t.id}})))||[];return[i].concat(n)},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"installmentPrice",{get:function(){var t,e,i,s=this;if(this.installmentInfo&&(null===(t=this.cardData)||void 0===t?void 0:t.installmentCount))return null===(i=null===(e=this.installmentInfo.installmentPrices)||void 0===e?void 0:e.find((function(t){var e;return t.installmentCount===(null===(e=s.cardData)||void 0===e?void 0:e.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"finalPrice",{get:function(){if(this.step===$.SUCCESS)return this.checkout.totalFinalPrice;var t=B.getCheckoutTotalFinalPrice;return this.installmentPrice||t(this.checkout)},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===J.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"canProceedToShipping",{get:function(){var t,e=g,i=F.hasValidCustomerEmail;return(this.isDigitalOnly?!!this.checkout.billingAddress&&e(this.checkout.billingAddress):this.checkout.shippingAddress&&e(this.checkout.shippingAddress))&&i(this.checkout)&&(null===(t=this.error)||void 0===t?void 0:t.type)!==J.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"canProceedToInStoreDelivery",{get:function(){var t,e,i;return!!((null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.firstName)&&(null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"klarnaPaymentGateway",{get:function(){var t=this.paymentGateways.findIndex((function(t){return"KLARNA"===t.code}));if(-1!==t)return this.paymentGateways[t]},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(t){return"KLARNA"===t.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"adyenPaymentGateway",{get:function(){var t=this.paymentGateways.findIndex((function(t){return"ADYEN"===t.code}));if(-1!==t)return this.paymentGateways[t]},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(t){return"ADYEN"===t.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"payPalPaymentGateway",{get:function(){var t=this.paymentGateways.findIndex((function(t){return"PAYPAL"===t.code}));if(-1!==t)return this.paymentGateways[t]},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(t){return"PAYPAL"===t.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"isCustomFlowStripe",{get:function(){var t,e=this.checkout.selectedPaymentGateway;return e&&"STRIPE"===e.code&&(null===(t=e.settings)||void 0===t?void 0:t.find((function(t){return"allow_custom_flow"===t.label&&"1"===t.value})))},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"isKlarna",{get:function(){var t=this.checkout.selectedPaymentGateway;return t&&"KLARNA"===t.code},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"isAdyen",{get:function(){var t=this.checkout.selectedPaymentGateway;return t&&"ADYEN"===t.code},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"isPayPal",{get:function(){var t=this.checkout.selectedPaymentGateway;return t&&"PAYPAL"===t.code},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"canPerformPayment",{get:function(){var t;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var e=g,i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!this.checkout.billingAddress&&!!e(this.checkout.billingAddress),r=!!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(tt.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===d.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"customerAddresses",{get:function(){var t,e,s=this;return null===(e=null===(t=q.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.map((function(t){return n(i({countrySettings:s.countrySettings,checkoutSettings:s.checkoutSettings},t))}))},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===u.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(tt.prototype,"isEPayKolayEnabled",{get:function(){var t=M.getCustom();return!!t&&!!t.isEPayKolayEnabled},enumerable:!1,configurable:!0}),tt.prototype.setAdyenDropinElement=function(t){this.adyenDropinElement=t},tt}();function st(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function nt(t){return t&&tt.test(t.charAt(t.length-1))}export{it as default};
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as i}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s,observable as n}from"mobx";import r from"lodash/cloneDeep";import o from"lodash/sortBy";import{IkasPaymentMethodType as a,IkasPaymentGatewayType as c,IkasOrderShippingMethod as d,IkasCartCreatedBy as u,IkasTransactionStatus as l,IkasCartCampaignOfferStatus as h,IkasCampaignOfferTargetPageType as p}from"@ikas/storefront-models";import{LocalizedAddressModel as f}from"@ikas/localized-address";import{createIkasLocalizedOrderAddress as m,isValidAddress as g}from"../../models/data/localized-order-address/functions.js";import{listOrderTransactions as v,saveCart as y,SaveCartInput as k,checkStocks as S,CheckStocksLineInput as b,getAvailableShippingCountries as P,listStockLocations as C,getAvailableStockLocations as A,listPaymentGateway as I,retrieveInstallmentInfo as w,saveCartCouponCode as N,createSaleTransactionWithCart as E,createStripePaymentIntent as O,searchProducts as D,updateCartCampaignOffer as G,register as T,getPayPalClientId as R,createAdyenClientToken as L,createKlarnaClientToken as j}from"@ikas/storefront-api";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import{IkasStorefrontConfig as M}from"@ikas/storefront-config";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/product-list/functions.js";import"../../models/ui/product-list/index.js";import"@ikas/storefront-providers";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 x from"./components/credit-card-form/model.js";import V,{MFS_ELEMENT_ID as _,MFS_SCRIPT_URL as U}from"./modelMasterPass.js";import"../../store/base/index.js";import"lodash/flatten";import{IkasCustomerAddressFunctions as K,IkasCheckoutFunctions as B,IkasOrderFunctions as F,IkasProductVariantFunctions as Y}from"@ikas/storefront-model-functions";import{waitForCustomerStoreInit as H,initCustomerStore as W}from"../../store/customer/functions.js";import{checkoutStep as q}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasCustomerStore as Q}from"../../store/customer/index.js";import{saveCustomer as z,logout as Z}from"../../store/customer/account-auth/functions.js";import"../../store/customer/captcha/data.js";import"../../store/customer/consent/data.js";import{createEmailSubscription as X}from"../../store/customer/marketing/functions.js";import"../../store/customer/order/data.js";import"../../store/customer/product/data.js";import"lodash/xorBy";import"../../store/cart/index.js";import{changeItemQuantity as $}from"../../store/cart/functions.js";import{CheckoutStep as J,ErrorType as tt}from"./types.js";var et=/^\d+$/,it="undefined"==typeof localStorage,st=function(){function et(n,d,u,g,K,F,et,st,ot,at){var ct=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=J.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.adyenResponse=null,this.payPalClientIdResponse=null,this.paypalOrderResponse=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.showTestModal=!1,this.init=function(){return t(ct,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.countrySettings.waitUntilInitialized()];case 1:return t.sent(),[4,W()];case 2:return t.sent(),[4,H()];case 3:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getCampaignOffer()];case 4:return t.sent(),[4,this.initStep()];case 5:return t.sent(),[2]}}))}))},this.initStep=function(){return t(ct,void 0,void 0,(function(){var t,i,s,n,r,o,a,c;return e(this,(function(e){switch(e.label){case 0:if(M.getIsEditor())return this.step=J.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),i=t.get("step"),s=t.get("failed"),n=t.get("error"),i){if(this.step=i,this.step===J.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(J.INFO)];if(this.step!==J.PAYMENT||this.canProceedToPayment){if(this.step===J.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(J.INFO)];if(![J.INFO,J.SUCCESS,J.SHIPPING,J.PAYMENT].includes(this.step))return[2,this.changeStep(J.INFO)]}else{if(!this.isInStoreDelivery)return[2,this.changeStep(J.INFO)];this.deliveryMethod="in-store"}}return s&&(this.error={type:tt.PAYMENT_ERROR,data:n||null}),this.step!==J.INFO?[3,4]:[4,this.getShippingCountries()];case 1:return e.sent(),this.checkShippingCountries(),[4,this.getStockLocations()];case 2:return e.sent(),[4,this.getAvailableStockLocations()];case 3:e.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),e.label=4;case 4:return this.step!==J.SHIPPING||1!==(null===(a=this.checkout.availableShippingMethods)||void 0===a?void 0:a.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=J.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==J.SHIPPING||(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)?this.step!==J.PAYMENT&&this.step!==J.SUCCESS?[3,8]:[4,this.listPaymentGateways()]:(this.error={type:tt.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 5:return e.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,7];case 6:e.sent(),e.label=7;case 7:if(!this.paymentGateways.length)return this.error={type:tt.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=8;case 8:return r=B.isCheckoutComplete,this.step===J.SUCCESS?[3,12]:r(this.checkout)?[2,this.changeStep(J.SUCCESS)]:[3,9];case 9:return[4,this.initialStockCheck()];case 10:e.sent(),e.label=11;case 11:return[3,14];case 12:return[4,this.getSuccessTransaction()];case 13:e.sent(),this.successTransaction&&(o=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(t){return t.id===o}))),e.label=14;case 14:return this.isCheckoutLoaded=!0,q(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return t(ct,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,v({orderId:{eq:this.checkout.id}})];case 1:return t=e.sent(),this.successTransaction=t.isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?t.data[t.data.length-1]:void 0,[2]}}))}))},this.saveCart=function(){return t(ct,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return t=new k(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(t)];case 1:t=e.sent(),e.label=2;case 2:return this.step!==J.INFO&&this.step!==J.SHIPPING||this.isDigitalOnly||(t.billingAddress=null),this.isDigitalOnly&&(t.shippingAddress=null),[4,y({input:t})];case 3:if((null==(i=e.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:tt.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:tt.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return t(ct,void 0,void 0,(function(){var t,s,n=this;return e(this,(function(e){return t=i,(s=this.stockLocations.find((function(t){return t.id===n.checkout.stockLocationId})))&&t.shippingAddress&&s.address&&(t.shippingAddress.country=s.address.country,t.shippingAddress.city=s.address.city,t.shippingAddress.state=s.address.state,t.shippingAddress.district=s.address.district,t.shippingAddress.postalCode=s.address.postalCode,t.shippingAddress.addressLine1=s.address.address||"",t.shippingAddress.addressLine2=null),[2,t]}))}))},this.checkStocks=function(){return t(ct,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,l,h;return e(this,(function(e){switch(e.label){case 0:return this.isManualOrder?[2]:(t=this.checkout.orderLineItems.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,S({lines:t.map((function(t){return new b(t)})),stockLocationIdList:(null===(u=M.getStockLocationIds())||void 0===u?void 0:u.length)?M.getStockLocationIds():null})]);case 1:if(!(i=e.sent()).isSuccess)throw{type:tt.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(h=null===(l=i.data)||void 0===l?void 0:l.lines)||void 0===h?void 0:h.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=o.checkout.orderLineItems.find((function(e){return e.variant.id===t.variantId}));e&&n.push({item:e,stockCount:t.stockCount})},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:tt.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return t(ct,void 0,void 0,(function(){return e(this,(function(t){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return t(ct,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:t=0,s=i,e.label=1;case 1:return t<s.length?(n=s[t],[4,$(n.item,n.stockCount<0?0:n.stockCount)]):[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(ct,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,P({salesChannelId:M.getSalesChannelId()})];case 1:return t=e.sent(),this.shippingCountryIds=t.data,[2]}}))}))},this.getStockLocations=function(){return t(ct,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return M.getPickupStockLocationIds()?[4,C({id:{in:M.getPickupStockLocationIds()}})]:[3,2];case 1:if(!(t=e.sent()).isSuccess||!(null===(i=t.data)||void 0===i?void 0:i.length))return this.error={type:tt.API_ERROR,data:t.firstErrorMessage},[2];this.stockLocations=t.data,e.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(ct,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return M.getPickupStockLocationIds()?(t=this.checkout.orderLineItems.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,A({lines:t.map((function(t){return new b(t)})),stockLocationIdList:M.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=e.sent()).isSuccess)return this.error={type:tt.API_ERROR},[2];this.availableStockLocations=i.data||[],e.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=ct.shippingCountryIds)||void 0===t?void 0:t.length)||(ct.error={type:tt.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(t){"address"===t&&(ct.checkout.stockLocationId=null),ct.deliveryMethod=t,ct.isErrorsVisible=!1},this.initialStockCheck=function(){return t(ct,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return e.sent(),[3,3];case 2:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:tt.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(ct,void 0,void 0,(function(){var t,i,s,n,r,a,c,d,u,l,h=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=M.getPaymentGateways().map((function(t){return t.id})),[4,I({id:t?void 0:{in:i},locale:M.getCurrentLocale(),transactionAmount:this.checkout.totalFinalPrice})];case 1:return(s=e.sent()).isSuccess&&(null===(u=s.data)||void 0===u?void 0:u.length)?(n=s.data,this.step===J.PAYMENT&&(n=n.filter((function(t){var e;return!(null===(e=t.supportedCurrencies)||void 0===e?void 0:e.length)||t.supportedCurrencies.includes(h.checkout.currencyCode)})),(r=null===(l=this.checkout.shippingAddress)||void 0===l?void 0:l.country)&&r.iso2&&(n=n.filter((function(t){var e;return!(null===(e=t.availableCountries)||void 0===e?void 0:e.length)||t.availableCountries.includes(r.iso2||"")})))),a=[],o(M.getPaymentGateways(),"order").forEach((function(t){var e=null==n?void 0:n.find((function(e){return e.id===t.id}));e&&a.push(e)})),this.paymentGateways=t?n:a,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),this.step===J.PAYMENT&&(c=n.find((function(t){return!!t.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id=_,d.src=U,d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout})},document.head.appendChild(d)),[2]):(this.error={type:tt.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(ct,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return[4,w(i)];case 1:return t=e.sent(),s=t.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(t,e){return(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var t;Q.customer?(null===(t=ct.customerAddresses)||void 0===t||t.forEach((function(t){return t.checkoutSettings=ct.checkoutSettings})),ct.checkout.customer=r(Q.customer)):ct.checkout.customer=r(ct.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){ct.checkout.shippingAddress&&(ct.checkout.shippingAddress.checkoutSettings=ct.checkoutSettings,ct.checkout.shippingAddress.countrySettings=ct.countrySettings)},this.setCheckoutBillingAddressSettings=function(){ct.checkout.billingAddress&&(ct.checkout.billingAddress.checkoutSettings=ct.checkoutSettings,ct.checkout.billingAddress.countrySettings=ct.countrySettings)},this.createShippingAddress=function(){if(!ct.isDigitalOnly)if(ct.isInStoreDelivery)ct.setCheckoutShippingAddressSettings();else if(ct.checkout.shippingAddress){if(Q.customer){var t=null==(e=ct.customerAddresses)?void 0:e.find((function(t){var e;return t.id===(null===(e=ct.checkout.shippingAddress)||void 0===e?void 0:e.id)}));if(t)return ct.onSelectedShippingAddressIdChange(t.id||"-1"),void ct.setCheckoutShippingAddressSettings()}ct.checkout.shippingAddress=r(ct.checkout.shippingAddress)||{},ct.setCheckoutShippingAddressSettings()}else if(Q.customer){var e=ct.customerAddresses;ct.onSelectedShippingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}else ct.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(ct.useDifferentAddress=!!localStorage.getItem("sAddr"),ct.checkout.billingAddress){if(Q.customer){var t=null==(e=ct.customerAddresses)?void 0:e.find((function(t){var e;return t.id===(null===(e=ct.checkout.billingAddress)||void 0===e?void 0:e.id)}));if(t)return ct.onSelectedBillingAddressIdChange(t.id||"-1"),void ct.setCheckoutBillingAddressSettings()}ct.checkout.billingAddress=r(ct.checkout.billingAddress)||{},ct.setCheckoutBillingAddressSettings()}else if(Q.customer){var e=ct.customerAddresses;ct.onSelectedBillingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1"),(null==e?void 0:e.length)||ct.useDifferentAddress||!ct.checkout.shippingAddress||ct.isInStoreDelivery||(ct.checkout.billingAddress=r(ct.checkout.shippingAddress),ct.setCheckoutBillingAddressSettings())}else ct.onSelectedBillingAddressIdChange("-1"),ct.useDifferentAddress||!ct.checkout.shippingAddress||ct.isInStoreDelivery||(ct.checkout.billingAddress=r(ct.checkout.shippingAddress),ct.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(s){return t(ct,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=s.shippingSettingsId,this.checkout.shippingZoneRateId=s.shippingZoneRateId,[4,this.saveCart()]);case 1:return(t=e.sent())&&(this.checkout=i(i({},t),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,customer:this.checkout.customer,selectedPaymentGateway:this.checkout.selectedPaymentGateway})),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return t(ct,void 0,void 0,(function(){return e(this,(function(t){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return t(ct,void 0,void 0,(function(){var t,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,N({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=e.sent()).isSuccess&&t.data?(s=t.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===J.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{binNumber:this.mpVM.selectedCard.Value1.slice(0,6),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:s.totalFinalPrice}})]:[3,3]):[3,4];case 2:e.sent(),e.label=3;case 3:s&&(r=this.checkout,this.checkout=i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway})),e.label=4;case 4:return t.isSuccess||(this.couponError=t.errorCodes[0]),[3,6];case 5:return e.sent(),[3,6];case 6:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e;if(ct.selectedShippingAddressId=t,"-1"===t)ct.checkout.shippingAddress=m({},ct.checkoutSettings,ct.countrySettings),ct.checkout.shippingAddress.countrySettings=ct.countrySettings;else{var i=null===(e=ct.customerAddresses)||void 0===e?void 0:e.find((function(e){return e.id===t}));i&&(ct.checkout.shippingAddress=m(i,ct.checkoutSettings,ct.countrySettings))}ct.checkout.shippingAddress&&(ct.checkout.shippingAddress.checkoutSettings=ct.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e;if(ct.selectedBillingAddressId=t,"-1"===t)ct.checkout.billingAddress=m({},ct.checkoutSettings,ct.countrySettings);else{var i=null===(e=ct.customerAddresses)||void 0===e?void 0:e.find((function(e){return e.id===t}));i&&(ct.checkout.billingAddress=m(i,ct.checkoutSettings,ct.countrySettings))}ct.checkout.billingAddress&&(ct.checkout.billingAddress.checkoutSettings=ct.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){ct.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(ct.cardData&&(!(t.length>ct.cardData.cardNumber.length)||rt(t))){var e=(ct.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!ct.installmentInfo?ct.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:ct.checkout.selectedPaymentGateway.id,price:ct.checkout.totalFinalPrice}}):i.length<6&&e.length>i.length&&(ct.cardData.installmentCount=1,ct.installmentInfo=void 0),ct.cardData.cardNumber=nt(i,4).join(" "))}},this.onCardHolderNameChange=function(t){ct.cardData&&(ct.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(ct.cardData&&(!(t.length>ct.cardData.expirationDate.length)||rt(t))){if(0===(null===(e=ct.cardData.expirationDate)||void 0===e?void 0:e.length)){var i=t.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(ct.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(ct.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(ct.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=t.split(" / ").join("");d.length>4||(ct.cardData.expirationDate=nt(d,2).join(" / "))}},this.onCvcChange=function(t){ct.cardData&&(t.length>ct.cardData.cvv.length&&!rt(t)||t.length>4||(ct.cardData.cvv=t))},this.saveAddress=function(s){return t(ct,void 0,void 0,(function(){var t,n,o,a,c,d,u,l,h,p,f,m,g=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.shouldSaveAddress&&Q.customer?(t="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(h=this.customerAddresses)||void 0===h?void 0:h.find((function(e){return e.id===(null==t?void 0:t.id)})))?[2]:(n=null===(p=this.customerAddresses)||void 0===p?void 0:p.map((function(t){return t.id})),o=i(i({},t),{title:this.addressTitle||this.t("checkout-page:newAddress")}),(a=r(Q.customer)).addresses||(a.addresses=[]),a.addresses.push(o),[4,z(a)])):[3,2];case 1:e.sent(),null===(f=this.customerAddresses)||void 0===f||f.forEach((function(t){return t.checkoutSettings=g.checkoutSettings})),c=null===(m=this.customerAddresses)||void 0===m?void 0:m.map((function(t){return t.id})),d=null==c?void 0:c.filter((function(t){return!(null==n?void 0:n.includes(t))})),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"),e.label=2;case 2:return[3,4];case 3:return l=e.sent(),console.error(l),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){ct.router.push("/cart")},this.onBackToShoppingClick=function(){ct.router.push("/")},this.onGoToLoginClick=function(){ct.router.push("/account/login")},this.onProceedToShippingClick=function(){return t(ct,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.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,e.label=1;case 1:return e.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:e.sent(),e.label=3;case 3:return[4,this.checkStocks()];case 4:return e.sent(),[4,this.saveCart()];case 5:return e.sent(),"address"===this.deliveryMethod?this.changeStep(J.SHIPPING):this.changeStep(J.PAYMENT),[3,7];case 6:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:tt.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return t(ct,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCart()];case 3:return e.sent(),this.changeStep(J.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:tt.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(ct,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCart()];case 3:return e.sent(),this.error=void 0,this.changeStep(J.PAYMENT),[3,5];case 4:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:tt.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!ct.canPerformPayment||(ct.isErrorsVisible=!0,!1)},this.onCompletePaymentClick=function(){return t(ct,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return this.canPerformPayment?(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isKlarna?[4,this.saveCart()]:[3,2]):(this.isErrorsVisible=!0,[2]);case 1:return e.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return e.trys.push([2,8,,9]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return e.sent(),"address"===this.deliveryMethod&&this.useDifferentAddress?[4,this.saveAddress("billing")]:[3,5];case 4:e.sent(),e.label=5;case 5:return[4,this.saveCart()];case 6:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):this.isPayPal?[2]:[4,this.createSaleTransaction()];case 7:return e.sent(),[3,9];case 8:return void 0!==typeof(i=e.sent()).type?this.error=i:this.error={type:tt.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return t(ct,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.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 e.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return e.trys.push([2,6,,7]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return e.sent(),[4,this.saveCart()];case 4:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):this.isPayPal?[2]:[4,this.createSaleTransaction()];case 5:return e.sent(),[3,7];case 6:return(i=e.sent()).type?this.error=i:this.error={type:tt.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return t(ct,void 0,void 0,(function(){var t,i,s,n,r,o,d,u,h,p,f,m,g,v,y;return e(this,(function(e){switch(e.label){case 0:return(i=this.mpVM.selectedCard)&&(null===(u=this.mpVM.selectedCard)||void 0===u?void 0:u.Name)?((n=this.mpVM.phoneNumber({checkout:this.checkout}))&&(t=n),void 0===(null===(h=this.cardData)||void 0===h?void 0:h.installmentCount)?[2]:[4,E({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name},paymentGatewayId:null===(f=this.mpVM.selectedCard)||void 0===f?void 0:f.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===(m=this.cardData)||void 0===m?void 0:m.threeDSecure)}}})]):[3,2];case 1:return s=e.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,E({input:{cartId:this.checkout.id,masterPassDetail:i&&t?{phoneNumber:t,savedCardName:null===(g=this.mpVM.selectedCard)||void 0===g?void 0:g.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail: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=e.sent(),e.label=4;case 4:return r=null===(v=null==s?void 0:s.data)||void 0===v?void 0:v.transactionStatus,o=r&&[l.SUCCESS,l.AUTHORIZED].includes(r),d=r===l.PENDING,o?[4,this.getSuccessTransaction()]:[3,7];case 5:return e.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return e.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:tt.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,e.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return t(ct,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return localStorage.removeItem("sAddr"),(null===(t=this.checkout.customer)||void 0===t?void 0:t.notificationsAccepted)?[4,X((null===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.changeStep(J.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){ct.changeStep(J.INFO)},this.onBackToShippingClick=function(){ct.changeStep(J.SHIPPING)},this.setCustomerConsentGranted=function(t){ct.checkout.customer&&(ct.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){ct.useDifferentAddress=t,ct.useDifferentAddress?(localStorage.setItem("sAddr","1"),ct.checkout.billingAddress=ct.checkout.billingAddress||m({},ct.checkoutSettings,ct.countrySettings),ct.checkout.billingAddress.countrySettings=ct.countrySettings):(localStorage.removeItem("sAddr"),ct.checkout.billingAddress=ct.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){ct.shouldSaveAddress=t},this.setAddressTitle=function(t){ct.addressTitle=t},this.setPaymentGateway=function(i){return t(ct,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return this.paymentGateways.length?"STRIPE"!==(t=this.paymentGateways[i]).code||!(null===(n=t.settings)||void 0===n?void 0:n.find((function(t){return"allow_custom_flow"===t.label&&"1"===t.value})))||this.stripeResponse?[3,2]:[4,O({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})]:[2];case 1:(s=e.sent()).isSuccess&&s.data&&(this.stripeResponse=s.data),e.label=2;case 2:return"KLARNA"!==t.code||this.klarnaResponse?[3,4]:[4,j({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})];case 3:(s=e.sent()).isSuccess&&s.data&&(this.klarnaResponse=s.data),e.label=4;case 4:return"ADYEN"!==t.code||this.adyenResponse?[3,6]:[4,L({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})];case 5:(s=e.sent()).isSuccess&&s.data&&(this.adyenResponse=s.data),e.label=6;case 6:return"PAYPAL"!==t.code||this.payPalClientIdResponse?[3,8]:[4,R({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})];case 7:(s=e.sent()).isSuccess&&s.data&&(this.payPalClientIdResponse=s.data),e.label=8;case 8:return this.checkout.selectedPaymentGateway=t,this.step!==J.SUCCESS&&(t.paymentMethodType===a.CREDIT_CARD&&t.type===c.INTERNAL&&(this.cardData=new x,t.masterPassClientId&&(console.log("called 1511 ikas log"),this.mpVM.checkMasterPass({checkout:this.checkout}))),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(t){ct.cardData&&(ct.cardData.installmentCount=t)},this.changeStep=function(i){return t(ct,void 0,void 0,(function(){return e(this,(function(t){return it||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return t(ct,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:this.checkout.customer=null,Z(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return t.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(t){ct.isContactModalVisible=t},this.getCampaignOfferProducts=function(i){return t(ct,void 0,void 0,(function(){var t,s,n,r;return e(this,(function(o){switch(o.label){case 0:if(!this.checkout.campaignOffers||!this.checkout.campaignOffers.length)return[3,4];if(t=this.checkout.campaignOffers.filter((function(t){var e;return t.status===h.WAITING_FOR_ACTION&&(null===(e=t.campaignOffer)||void 0===e?void 0:e.targetPageTypes.some((function(t){return t===i})))})),!t.length)return[3,4];s=function(i){var s,n,r,o,a,c;return e(this,(function(e){switch(e.label){case 0:return(s=t[i]).campaignOffer&&(n=s.campaignOffer.offers.find((function(t){return t.id===s.campaignOfferProductId})))?[4,D({input:{productIdList:[n.productId]}})]:[3,2];case 1:if((r=e.sent()).isSuccess&&r.data&&r.data.data&&r.data.data.length&&(o=r.data.data[0],a=[],c=Y.hasVariantStock,n.excludedVariantIdList&&n.excludedVariantIdList.length?o.variants.map((function(t){var e;c(t)&&!(null===(e=n.excludedVariantIdList)||void 0===e?void 0:e.some((function(e){return e===t.id})))&&a.push(t)})):a.push.apply(a,o.variants.filter((function(t){return c(t)}))),a.length))return[2,{value:{product:o,variants:a,campaignOffer:s,offer:n}}];e.label=2;case 2:return[2]}}))},n=0,o.label=1;case 1:return n<t.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 t(ct,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getCampaignOfferProducts(p.CHECKOUT)];case 1:return t.checkoutCampaignOffer=e.sent(),i=this,[4,this.getCampaignOfferProducts(p.POST_CHECKOUT)];case 2:return i.postCheckoutCampaignOffer=e.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(s){return t(ct,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isCheckoutLoaded=!1,[4,G({input:s})];case 1:return(t=e.sent())&&t.isSuccess&&t.data&&(this.checkout=i(i({},t.data),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,selectedPaymentGateway:this.checkout.selectedPaymentGateway}),s.accepted&&this.step===J.SUCCESS?this.changeStep(J.INFO):this.changeStep(this.step)),[2]}}))}))},this.registerCustomer=function(i){return t(ct,void 0,void 0,(function(){var t,s,n,r;return e(this,(function(e){switch(e.label){case 0:return this.checkout.customer?(t=this.checkout.customer,s=t.firstName,n=t.lastName,r=t.email,s&&n&&r?[4,T({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:i})]:[3,2]):[3,2];case 1:return[2,e.sent()];case 2:return[2]}}))}))},this.checkout=n,this.checkoutSettings=d,this.router=u,this.returnPolicy=g,this.privacyPolicy=K,this.termsOfService=F,this.imprint=et,this.shippingPolicy=st,this.t=ot,this.customizationProps=at,this.mpVM=new V,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new f({currentLocale:M.getCurrentLocale()}),this.init(),s(this)}return Object.defineProperty(et.prototype,"merchantSettings",{get:function(){return M.getMerchantSettings()},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"selectedPaymentGatewayIndex",{get:function(){var t=this;return this.paymentGateways.findIndex((function(e){var i;return e.id===(null===(i=t.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"selectedInstallmentIndex",{get:function(){var t,e,i=this;return(null===(e=null===(t=this.installmentInfo)||void 0===t?void 0:t.installmentPrices)||void 0===e?void 0:e.findIndex((function(t){var e;return t.installmentCount===(null===(e=i.cardData)||void 0===e?void 0:e.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"customerAddressOptions",{get:function(){var t,e,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=K.getCustomerAddressText,n=(null===(e=null===(t=Q.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.map((function(t){return{label:t.title+" - "+s(t),value:t.id}})))||[];return[i].concat(n)},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"installmentPrice",{get:function(){var t,e,i,s=this;if(this.installmentInfo&&(null===(t=this.cardData)||void 0===t?void 0:t.installmentCount))return null===(i=null===(e=this.installmentInfo.installmentPrices)||void 0===e?void 0:e.find((function(t){var e;return t.installmentCount===(null===(e=s.cardData)||void 0===e?void 0:e.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"finalPrice",{get:function(){if(this.step===J.SUCCESS)return this.checkout.totalFinalPrice;var t=B.getCheckoutTotalFinalPrice;return this.installmentPrice||t(this.checkout)},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===tt.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"canProceedToShipping",{get:function(){var t,e=g,i=F.hasValidCustomerEmail;return(this.isDigitalOnly?!!this.checkout.billingAddress&&e(this.checkout.billingAddress):this.checkout.shippingAddress&&e(this.checkout.shippingAddress))&&i(this.checkout)&&(null===(t=this.error)||void 0===t?void 0:t.type)!==tt.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"canProceedToInStoreDelivery",{get:function(){var t,e,i;return!!((null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.firstName)&&(null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"klarnaPaymentGateway",{get:function(){var t=this.paymentGateways.findIndex((function(t){return"KLARNA"===t.code}));if(-1!==t)return this.paymentGateways[t]},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(t){return"KLARNA"===t.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"adyenPaymentGateway",{get:function(){var t=this.paymentGateways.findIndex((function(t){return"ADYEN"===t.code}));if(-1!==t)return this.paymentGateways[t]},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(t){return"ADYEN"===t.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"payPalPaymentGateway",{get:function(){var t=this.paymentGateways.findIndex((function(t){return"PAYPAL"===t.code}));if(-1!==t)return this.paymentGateways[t]},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(t){return"PAYPAL"===t.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"isCustomFlowStripe",{get:function(){var t,e=this.checkout.selectedPaymentGateway;return e&&"STRIPE"===e.code&&(null===(t=e.settings)||void 0===t?void 0:t.find((function(t){return"allow_custom_flow"===t.label&&"1"===t.value})))},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"isKlarna",{get:function(){var t=this.checkout.selectedPaymentGateway;return t&&"KLARNA"===t.code},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"isAdyen",{get:function(){var t=this.checkout.selectedPaymentGateway;return t&&"ADYEN"===t.code},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"isPayPal",{get:function(){var t=this.checkout.selectedPaymentGateway;return t&&"PAYPAL"===t.code},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"canPerformPayment",{get:function(){var t;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var e=g,i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!this.checkout.billingAddress&&!!e(this.checkout.billingAddress),r=!!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(et.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===d.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"customerAddresses",{get:function(){var t,e,s=this;return null===(e=null===(t=Q.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.map((function(t){return n(i({countrySettings:s.countrySettings,checkoutSettings:s.checkoutSettings},t))}))},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===u.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(et.prototype,"isEPayKolayEnabled",{get:function(){var t=M.getCustom();return!!t&&!!t.isEPayKolayEnabled},enumerable:!1,configurable:!0}),et.prototype.setAdyenDropinElement=function(t){this.adyenDropinElement=t},et}();function nt(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function rt(t){return t&&et.test(t.charAt(t.length-1))}export{st as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.21",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "ikas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"build": "rm -rf build && rollup -c"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@ikas/storefront-api": "^5.0.0-beta.
|
|
21
|
-
"@ikas/storefront-config": "^5.0.0-beta.
|
|
22
|
-
"@ikas/storefront-model-functions": "^5.0.0-beta.
|
|
23
|
-
"@ikas/storefront-models": "^5.0.0-beta.
|
|
24
|
-
"@ikas/storefront-providers": "^5.0.0-beta.
|
|
20
|
+
"@ikas/storefront-api": "^5.0.0-beta.21",
|
|
21
|
+
"@ikas/storefront-config": "^5.0.0-beta.21",
|
|
22
|
+
"@ikas/storefront-model-functions": "^5.0.0-beta.21",
|
|
23
|
+
"@ikas/storefront-models": "^5.0.0-beta.21",
|
|
24
|
+
"@ikas/storefront-providers": "^5.0.0-beta.21",
|
|
25
25
|
"@ikas/localized-address": "^1.0.0-beta.2",
|
|
26
26
|
"@adyen/adyen-web": "^5.28.2",
|
|
27
27
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@ikas/localized-address": "^1.0.0-beta.2",
|
|
58
|
-
"@ikas/storefront-api": "^5.0.0-beta.
|
|
59
|
-
"@ikas/storefront-config": "^5.0.0-beta.
|
|
60
|
-
"@ikas/storefront-model-functions": "^5.0.0-beta.
|
|
61
|
-
"@ikas/storefront-models": "^5.0.0-beta.
|
|
62
|
-
"@ikas/storefront-providers": "^5.0.0-beta.
|
|
58
|
+
"@ikas/storefront-api": "^5.0.0-beta.21",
|
|
59
|
+
"@ikas/storefront-config": "^5.0.0-beta.21",
|
|
60
|
+
"@ikas/storefront-model-functions": "^5.0.0-beta.21",
|
|
61
|
+
"@ikas/storefront-models": "^5.0.0-beta.21",
|
|
62
|
+
"@ikas/storefront-providers": "^5.0.0-beta.21",
|
|
63
63
|
"mobx": "^6.1.3",
|
|
64
64
|
"mobx-react-lite": "^3.1.5",
|
|
65
65
|
"next": "12.2.0",
|