@ikas/storefront 5.0.5 → 5.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t,__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{IkasCartCreatedBy as o,IkasCouponCodeRequirement as a,IkasPaymentMethodType as c,IkasPaymentGatewayType as d,IkasOrderShippingMethod 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 P}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"../../models/data/product/campaign-offer/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 I}from"../../models/data/product/variant/price/index.js";import{IkasProductVariant as A}from"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as E}from"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import{LocalizedAddressModel as w}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 R from"./components/credit-card-form/model.js";import O from"../../store/customer/api.js";import N from"../../store/checkout/index.js";import j from"../../store/cart/api.js";import D,{MFS_ELEMENT_ID as T,MFS_SCRIPT_URL as L}from"./modelMasterPass.js";import x from"../../store/product/index.js";import{TransactionCardAssociationEnum as M,SaveCartInput as G,CheckStocksLineInput as _}from"@ikas/storefront-api";import{IkasBaseStore as U}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as V}from"@ikas/storefront-config";import{Analytics as F}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import B from"../../models/data/order/address/ikas-localized-order-address.js";import K from"../../store/location/index.js";import{getCookieValue as Z}from"../../utils/helper.js";var Y,H,q=/^\d+$/,W="undefined"==typeof localStorage,Q=function(){function q(o,b,P,q,Q,$,J,ee,te,ie){var se=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=Y.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.stripeError=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.klarnaError=null,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(se,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,U.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(se,void 0,void 0,(function(){var e,s,n,r,o,c,d;return t(this,(function(t){switch(t.label){case 0:if(V.getIsEditor())return this.step=Y.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===Y.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(Y.INFO)];if(this.step!==Y.PAYMENT||this.canProceedToPayment){if(this.step===Y.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(Y.INFO)];if(![Y.INFO,Y.SUCCESS,Y.SHIPPING,Y.PAYMENT].includes(this.step))return[2,this.changeStep(Y.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings?[2,this.changeStep(Y.INFO)]:[2,this.changeStep(Y.SHIPPING)];this.deliveryMethod="in-store"}}return[4,this.createCampaignOffer()];case 1:return t.sent(),n&&(this.error={type:H.PAYMENT_ERROR,data:r||null}),this.step!==Y.SHIPPING&&this.step!==Y.PAYMENT||this.isCouponCodeRequirementInvisible||(this.checkoutSettings=new S(i(i({},this.checkoutSettings),{couponCodeRequirement:a.DEFAULT}))),this.step!==Y.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!==Y.SHIPPING||1!==(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=Y.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==Y.SHIPPING||(null===(d=this.checkout.availableShippingMethods)||void 0===d?void 0:d.length)?this.step!==Y.SUCCESS||this.checkout.orderPaymentStatus!==l.PAID?[3,9]:[4,this.listProductFile()]:(this.error={type:H.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 8:t.sent(),t.label=9;case 9:return this.step!==Y.PAYMENT&&this.step!==Y.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:H.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];t.label=13;case 13:return this.step===Y.SUCCESS?[3,17]:this.checkout.isComplete?[2,this.changeStep(Y.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&&(o=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===o}))),t.label=19;case 19:return this.isCheckoutLoaded=!0,F.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return e(se,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(se,void 0,void 0,(function(){var e,i,s,n,r;return t(this,(function(t){switch(t.label){case 0:return e=new G(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!==Y.INFO&&this.step!==Y.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,j.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:H.CUSTOMER_LOGIN_REQUIRED_ERROR}:"CUSTOMER_ACCOUNT_DISABLED"===(null===(r=s.extensions)||void 0===r?void 0:r.code)?{type:H.CUSTOMER_ACCOUNT_DISABLED_ERROR}:{type:H.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return e(se,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(se,void 0,void 0,(function(){var e,i,s,n,r,o,a,c,d,l,h,p;return t(this,(function(t){switch(t.label){case 0:return this.isManualOrder?[2]:(e=this.checkout.stockLocationId&&this.checkout.shippingMethod===u.CLICK_AND_COLLECT?[this.checkout.stockLocationId]:(null===(l=V.getStockLocationIds())||void 0===l?void 0:l.length)?V.getStockLocationIds():null,[4,N.checkCartStocks({cartId:this.checkout.id,stockLocationIdList:e})]);case 1:if(!(i=t.sent()).isSuccess)throw{type:H.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++)d=c[a],r(d);throw{type:H.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return e(se,void 0,void 0,(function(){return t(this,(function(e){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return e(se,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,U.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(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,N.getAvailableShippingCountries({salesChannelId:V.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return e(se,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return V.getPickupStockLocationIds()?[4,N.listStockLocation({id:{in:V.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:H.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,t.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return e(se,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return V.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 _(e)})),stockLocationIdList:V.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=t.sent()).isSuccess)return this.error={type:H.API_ERROR},[2];this.availableStockLocations=i.data||[],t.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var e;(null===(e=se.shippingCountryIds)||void 0===e?void 0:e.length)||(se.error={type:H.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){var t;se.deliveryMethod!==e&&("address"===e&&(se.checkout.stockLocationId=null,(null===(t=se.customerAddresses)||void 0===t?void 0:t.length)?se.onSelectedShippingAddressIdChange(se.customerAddresses[0].id||"-1"):(se.checkout.shippingAddress=new B,se.checkout.shippingAddress.countrySettings=se.countrySettings,se.checkout.shippingAddress.checkoutSettings=se.checkoutSettings,se.checkout.shippingAddress.shippingZones=se.shippingZones)),se.deliveryMethod=e,se.isErrorsVisible=!1)},this.initialStockCheck=function(){return e(se,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:H.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return e(se,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=V.getPaymentGateways().map((function(e){return e.id})),[4,N.listPaymentGateway({cartId:this.isUpsellOrder?this.checkout.id:void 0,id:e?void 0:{in:i},locale:V.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===Y.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(V.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===Y.PAYMENT&&(c=n.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id=T,d.src=L,d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout,store:U.getInstance()})},document.head.appendChild(d)),[2]):(this.error={type:H.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return e(se,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;se.store.customerStore.customer?(null===(e=se.customerAddresses)||void 0===e||e.forEach((function(e){e.checkoutSettings=se.checkoutSettings,e.shippingZones=se.shippingZones})),se.checkout.customer=new C(se.store.customerStore.customer)):se.checkout.customer=new C(se.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){se.checkout.shippingAddress&&(se.checkout.shippingAddress.checkoutSettings=se.checkoutSettings,se.checkout.shippingAddress.shippingZones=se.shippingZones,se.checkout.shippingAddress.countrySettings=se.countrySettings,se.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){se.checkout.billingAddress&&(se.checkout.billingAddress.checkoutSettings=se.checkoutSettings,se.checkout.billingAddress.shippingZones=se.shippingZones,se.checkout.billingAddress.countrySettings=se.countrySettings,se.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!se.isDigitalOnly)if(se.isInStoreDelivery)se.setCheckoutShippingAddressSettings();else if(se.checkout.shippingAddress){if(se.store.customerStore.customer){var e=null==(t=se.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=se.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return se.onSelectedShippingAddressIdChange(e.id||"-1"),void se.setCheckoutShippingAddressSettings()}se.checkout.shippingAddress=new B(n(se.checkout.shippingAddress)||{}),se.setCheckoutShippingAddressSettings()}else if(se.store.customerStore.customer){var t=se.customerAddresses;se.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else se.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(se.useDifferentAddress=!!localStorage.getItem("sAddr"),se.checkout.billingAddress){if(se.store.customerStore.customer){var e=null==(t=se.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=se.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return se.onSelectedBillingAddressIdChange(e.id||"-1"),void se.setCheckoutBillingAddressSettings()}se.checkout.billingAddress=new B(n(se.checkout.billingAddress)||{}),se.setCheckoutBillingAddressSettings()}else if(se.store.customerStore.customer){var t=se.customerAddresses;se.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||se.useDifferentAddress||!se.checkout.shippingAddress||se.isInStoreDelivery||(se.checkout.billingAddress=new B(n(se.checkout.shippingAddress)),se.setCheckoutBillingAddressSettings())}else se.onSelectedBillingAddressIdChange("-1"),se.useDifferentAddress||!se.checkout.shippingAddress||se.isInStoreDelivery||(se.checkout.billingAddress=new B(n(se.checkout.shippingAddress)),se.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(i){return e(se,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(se,void 0,void 0,(function(){return t(this,(function(e){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return e(se,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,j.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===Y.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(se,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:V.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(se.selectedShippingAddressId=e,"-1"===e)se.checkout.shippingAddress=new B,se.checkout.shippingAddress.countrySettings=se.countrySettings;else{var i=null===(t=se.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(se.checkout.shippingAddress=new B(i),se.checkout.shippingAddress.countrySettings=se.countrySettings)}se.checkout.shippingAddress&&(se.checkout.shippingAddress.checkoutSettings=se.checkoutSettings,se.checkout.shippingAddress.shippingZones=se.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(se.selectedBillingAddressId=e,"-1"===e)se.checkout.billingAddress=new B,se.checkout.billingAddress.countrySettings=se.countrySettings;else{var i=null===(t=se.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(se.checkout.billingAddress=new B(i),se.checkout.billingAddress.countrySettings=se.countrySettings)}se.checkout.billingAddress&&(se.checkout.billingAddress.checkoutSettings=se.checkoutSettings,se.checkout.billingAddress.shippingZones=se.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){se.isTermsAndConditionsChecked=e},this.onCardNumberChange=function(e){var t;if(se.cardData&&(!(e.length>se.cardData.cardNumber.length)||X(e))){var i=(se.cardData.cardNumber||"").split(" ").join(""),s=e.split(" ").join("");s.length>16||(i.length<6&&s.length>=6&&!se.installmentInfo?se.getRetrieveInstallmentInfo(s):s.length<6&&i.length>s.length&&(se.cardData.installmentCount=1,se.installmentInfo=void 0),(null===(t=se.installmentInfo)||void 0===t?void 0:t.cardAssociation)===M.AMERICAN_EXPRESS?se.cardData.cardNumber=function(e){var t=[],i=e.slice(0,4),s=e.slice(4,10),n=e.slice(10,15);i&&t.push(i);s&&t.push(s);n&&t.push(n);return t}(s).join(" "):se.cardData.cardNumber=z(s,4).join(" "))}},this.getRetrieveInstallmentInfo=function(i){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,this.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:this.checkout.totalFinalPrice,currencyCode:this.checkout.currencyCode}})];case 1:return t.sent(),(null===(e=this.cardData)||void 0===e?void 0:e.cardNumber)&&this.onCardNumberChange(this.cardData.cardNumber),[2]}}))}))},this.onCardHolderNameChange=function(e){se.cardData&&(se.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(se.cardData&&(!(e.length>se.cardData.expirationDate.length)||X(e))){if(0===(null===(t=se.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(se.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(se.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(se.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(se.cardData.expirationDate=z(d,2).join(" / "))}},this.onCvcChange=function(e){if(se.cardData&&(!(e.length>se.cardData.cvv.length)||X(e))){if(se.installmentInfo){if(se.installmentInfo.cardAssociation===M.AMERICAN_EXPRESS&&e.length>4)return;if(se.installmentInfo.cardAssociation!==M.AMERICAN_EXPRESS&&e.length>3)return}else if(e.length>3)return;se.cardData.cvv=e}},this.saveAddress=function(s){return e(se,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(){se.router.push("/cart")},this.onBackToShoppingClick=function(){se.router.push("/")},this.onGoToLoginClick=function(){se.router.push("/account/login")},this.onProceedToShippingClick=function(){return e(se,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(),this.isManualOrderWithShippingLines?[2,this.changeStep(Y.PAYMENT)]:("address"===this.deliveryMethod?this.changeStep(Y.SHIPPING):this.changeStep(Y.PAYMENT),[3,7]);case 6:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:H.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return e(se,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(Y.PAYMENT),[3,5];case 4:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:H.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return e(se,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(Y.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:H.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!se.canPerformPayment||(se.isErrorsVisible=!0,!1)},this.handlePaymentError=function(e,t){se.error={type:e,data:t}},this.onCompletePaymentClick=function(){return e(se,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:H.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return e(se,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:H.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return e(se,void 0,void 0,(function(){var e,i,s,n,r,o,a,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,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:Z("_fbp"),_fbc:Z("_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===c.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===d.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),a=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(!a||!(null===(S=null==s?void 0:s.data)||void 0===S?void 0:S.returnSlug))throw{data:s.firstErrorMessage,type:H.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(se,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(Y.SUCCESS,i),[2]}}))}))},this.onBackToInfoClick=function(){se.changeStep(Y.INFO)},this.onBackToShippingClick=function(){se.changeStep(Y.SHIPPING)},this.setCustomerConsentGranted=function(e){se.checkout.customer&&(se.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(e){se.useDifferentAddress=e,se.useDifferentAddress?(localStorage.setItem("sAddr","1"),se.checkout.billingAddress=se.checkout.billingAddress||new B,se.checkout.billingAddress.countrySettings=se.countrySettings):(localStorage.removeItem("sAddr"),se.checkout.billingAddress=se.checkout.shippingAddress)},this.setShouldSaveAddress=function(e){se.shouldSaveAddress=e},this.setAddressTitle=function(e){se.addressTitle=e},this.reInitPaymentMethod=function(){return e(se,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.createAdyenBalancePlatformPaymentSession(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(se,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,this.stripeError=null):this.stripeError={type:H.API_ERROR,data:e.firstErrorMessage},[2]}}))}))},this.createKlarnaClientToken=function(i){return e(se,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,this.klarnaError=null):this.klarnaError={type:H.API_ERROR,data:e.firstErrorMessage},[2]}}))}))},this.createAdyenBalancePlatformPaymentSession=function(i){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,N.createAdyenBalancePlatformPaymentSession({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(se,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(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.paymentGateways.length?"STRIPE"!==(e=this.paymentGateways[i]).code||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_PLATFORM"!==e.code||this.adyenResponse?[3,6]:[4,this.createAdyenBalancePlatformPaymentSession(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!==Y.SUCCESS&&(e.paymentMethodType===c.CREDIT_CARD&&e.type===d.INTERNAL&&(this.cardData=new R,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){se.cardData&&(se.cardData.installmentCount=e)},this.changeStep=function(i,s){return e(se,void 0,void 0,(function(){return t(this,(function(e){return W||window.location.replace("".concat(window.location.pathname,"?id=").concat(s||this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return e(se,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){se.isContactModalVisible=e},this.getCampaignOffer=function(s,n){return e(se,void 0,void 0,(function(){var r,o,a=this;return t(this,(function(c){switch(c.label){case 0:return(null==n?void 0:n.length)?(r=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})))})),o=r.map((function(s){return e(a,void 0,void 0,(function(){var e,n,r,o,a,c,d,u,l;return t(this,(function(t){switch(t.label){case 0:return(e=null===(d=s.campaignOffer)||void 0===d?void 0:d.offers.find((function(e){return e.id===s.campaignOfferProductId})))?(n=[e.productId],[4,x.searchProducts({input:{productIdList:n,priceListId:V.getPriceListId(),salesChannelId:V.getSalesChannelId()}})]):[2,Promise.reject()];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(t){return t.hasStock&&!(e.excludedVariantIdList||[]).some((function(e){return e===t.id}))})).map((function(t){return e.discountAmount?new A(i(i({},t),{prices:t.prices.map((function(t){var s=t.finalPrice,n=t.finalPrice-t.finalPrice*e.discountAmount/100;return e.applicablePrice===v.SELL_PRICE&&(s=t.sellPrice,n=t.sellPrice-t.sellPrice*e.discountAmount/100),new I(i(i({},t),{sellPrice:s,discountPrice:n}))}))})):t}))).length?(c=a.find((function(e){return e.isActive})),[2,{product:new E(i(i({},o),{selectedVariantValues:(c||a[0]).variantValues,variants:a})),offer:e,campaignOffer:s}]):[2,Promise.reject()]):[2,Promise.reject()]}}))}))})),[4,Promise.allSettled(o)]):[2,[]];case 1:return[2,c.sent().filter((function(e){return"fulfilled"===e.status&&e.value})).map((function(e){return e.value}))]}}))}))},this.createCampaignOffer=function(){return e(se,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===Y.SUCCESS?m.POST_CHECKOUT:m.CHECKOUT,this.checkout.campaignOffers)];case 1:return e.campaignOffers=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return e(se,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,j.updateCartCampaignOffer({input:i})];case 1:return(e=t.sent()).isSuccess?i.accepted?(this.changeStep(this.step===Y.SUCCESS?Y.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(se,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(se,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(se,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=o,this.checkoutSettings=b,this.router=P,this.returnPolicy=q,this.privacyPolicy=Q,this.termsOfService=$,this.imprint=J,this.shippingPolicy=ee,this.t=te,this.customizationProps=ie,this.mpVM=new D,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new w({currentLocale:V.getCurrentLocale()}),this.init(),s(this)}return Object.defineProperty(q.prototype,"merchantSettings",{get:function(){return new P(V.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(q.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(q.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(q.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=U.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(q.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(q.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"finalPrice",{get:function(){return this.step===Y.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===H.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(q.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)!==H.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(q.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(q.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isValidShippingSettings",{get:function(){var e,t=this;return!!(this.isInStoreDelivery||this.isDigitalOnly||this.isManualOrderWithShippingLines)||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(q.prototype,"isManualOrderWithShippingLines",{get:function(){var e,t;return this.checkout.createdBy===o.ADMIN&&(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.length)&&!(null===(t=this.checkout.availableShippingMethods)||void 0===t?void 0:t.length)},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(q.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(q.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"adyenPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(q.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(q.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isCustomFlowStripe",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"STRIPE"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN_PLATFORM"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"store",{get:function(){return U.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isCouponCodeRequirementDefult",{get:function(){return this.checkoutSettings.couponCodeRequirement===a.DEFAULT||null===this.checkoutSettings.couponCodeRequirement},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isCouponCodeRequirementOpen",{get:function(){return this.checkoutSettings.couponCodeRequirement===a.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isCouponCodeRequirementInvisible",{get:function(){return this.checkoutSettings.couponCodeRequirement===a.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isCouponCodeVisible",{get:function(){return this.isCouponCodeRequirementDefult&&!this.isCouponCodeRequirementInvisible},enumerable:!1,configurable:!0}),Object.defineProperty(q.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)===c.CREDIT_CARD&&i.type===d.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(q.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===u.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"customerAddresses",{get:function(){var e,t,s,n=this,r=null===(e=V.getCurrentRouting())||void 0===e?void 0:e.countryCodes;return null===(s=null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===s?void 0:s.filter((function(e){var t;return!(null==r?void 0:r.length)||(null===(t=e.country)||void 0===t?void 0:t.iso2)&&r.includes(e.country.iso2)})).map((function(e){var t=new b(i({countrySettings:n.countrySettings},e));return t.checkoutSettings=n.checkoutSettings,t.shippingZones=n.shippingZones,t.getValidatedCustomerAddress(),t}))},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===o.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isUpsellOrder",{get:function(){return this.checkout.createdBy===o.UPSELL},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isEPayKolayEnabled",{get:function(){var e=V.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isPoweredByHidden",{get:function(){var e=V.getCustom();return!!e&&!!e.hidePoweredBy},enumerable:!1,configurable:!0}),q.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},q}();function z(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function X(e){return e&&q.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(Y||(Y={})),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",e[e.CUSTOMER_ACCOUNT_DISABLED_ERROR=6]="CUSTOMER_ACCOUNT_DISABLED_ERROR"}(H||(H={}));export{Y as CheckoutStep,H as ErrorType,Q 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{IkasCartCreatedBy as o,IkasCouponCodeRequirement as a,IkasPaymentMethodType as c,IkasPaymentGatewayType as d,IkasOrderShippingMethod 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 P}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"../../models/data/product/campaign-offer/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 I}from"../../models/data/product/variant/price/index.js";import{IkasProductVariant as A}from"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as E}from"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import{LocalizedAddressModel as w}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 R from"./components/credit-card-form/model.js";import O from"../../store/customer/api.js";import N from"../../store/checkout/index.js";import j from"../../store/cart/api.js";import D,{MFS_ELEMENT_ID as T,MFS_SCRIPT_URL as L}from"./modelMasterPass.js";import x from"../../store/product/index.js";import{TransactionCardAssociationEnum as M,SaveCartInput as G,CheckStocksLineInput as _}from"@ikas/storefront-api";import{IkasBaseStore as U}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as V}from"@ikas/storefront-config";import{Analytics as F}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import B from"../../models/data/order/address/ikas-localized-order-address.js";import K from"../../store/location/index.js";import{getCookieValue as Z}from"../../utils/helper.js";var Y,H,q=/^\d+$/,W="undefined"==typeof localStorage,Q=function(){function q(o,b,P,q,Q,$,J,ee,te,ie){var se=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=Y.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.stripeError=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.klarnaError=null,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(se,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,U.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(se,void 0,void 0,(function(){var e,s,n,r,o,c,d;return t(this,(function(t){switch(t.label){case 0:if(V.getIsEditor())return this.step=Y.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===Y.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(Y.INFO)];if(this.step!==Y.PAYMENT||this.canProceedToPayment){if(this.step===Y.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(Y.INFO)];if(![Y.INFO,Y.SUCCESS,Y.SHIPPING,Y.PAYMENT].includes(this.step))return[2,this.changeStep(Y.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings?[2,this.changeStep(Y.INFO)]:[2,this.changeStep(Y.SHIPPING)];this.deliveryMethod="in-store"}}return[4,this.createCampaignOffer()];case 1:return t.sent(),n&&(this.error={type:H.PAYMENT_ERROR,data:r||null}),this.step!==Y.SHIPPING&&this.step!==Y.PAYMENT||this.isCouponCodeRequirementInvisible||(this.checkoutSettings=new S(i(i({},this.checkoutSettings),{couponCodeRequirement:a.DEFAULT}))),this.step!==Y.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!==Y.SHIPPING||1!==(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=Y.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==Y.SHIPPING||(null===(d=this.checkout.availableShippingMethods)||void 0===d?void 0:d.length)?this.step!==Y.SUCCESS||this.checkout.orderPaymentStatus!==l.PAID?[3,9]:[4,this.listProductFile()]:(this.error={type:H.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 8:t.sent(),t.label=9;case 9:return this.step!==Y.PAYMENT&&this.step!==Y.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:H.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];t.label=13;case 13:return this.step===Y.SUCCESS?[3,17]:this.checkout.isComplete?[2,this.changeStep(Y.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&&(o=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===o}))),t.label=19;case 19:return this.isCheckoutLoaded=!0,F.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return e(se,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(se,void 0,void 0,(function(){var e,i,s,n,r;return t(this,(function(t){switch(t.label){case 0:return e=new G(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!==Y.INFO&&this.step!==Y.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,j.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:H.CUSTOMER_LOGIN_REQUIRED_ERROR}:"CUSTOMER_ACCOUNT_DISABLED"===(null===(r=s.extensions)||void 0===r?void 0:r.code)?{type:H.CUSTOMER_ACCOUNT_DISABLED_ERROR}:{type:H.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return e(se,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(se,void 0,void 0,(function(){var e,i,s,n,r,o,a,c,d,l,h,p;return t(this,(function(t){switch(t.label){case 0:return this.isManualOrder?[2]:(e=this.checkout.stockLocationId&&this.checkout.shippingMethod===u.CLICK_AND_COLLECT?[this.checkout.stockLocationId]:(null===(l=V.getStockLocationIds())||void 0===l?void 0:l.length)?V.getStockLocationIds():null,[4,N.checkCartStocks({cartId:this.checkout.id,stockLocationIdList:e})]);case 1:if(!(i=t.sent()).isSuccess)throw{type:H.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++)d=c[a],r(d);throw{type:H.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return e(se,void 0,void 0,(function(){return t(this,(function(e){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return e(se,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,U.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(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,N.getAvailableShippingCountries({salesChannelId:V.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return e(se,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return V.getPickupStockLocationIds()?[4,N.listStockLocation({id:{in:V.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:H.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,t.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return e(se,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return V.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 _(e)})),stockLocationIdList:V.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=t.sent()).isSuccess)return this.error={type:H.API_ERROR},[2];this.availableStockLocations=i.data||[],t.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var e;(null===(e=se.shippingCountryIds)||void 0===e?void 0:e.length)||(se.error={type:H.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){var t;se.deliveryMethod!==e&&("address"===e&&(se.checkout.stockLocationId=null,(null===(t=se.customerAddresses)||void 0===t?void 0:t.length)?se.onSelectedShippingAddressIdChange(se.customerAddresses[0].id||"-1"):(se.checkout.shippingAddress=new B,se.checkout.shippingAddress.countrySettings=se.countrySettings,se.checkout.shippingAddress.checkoutSettings=se.checkoutSettings,se.checkout.shippingAddress.shippingZones=se.shippingZones)),se.deliveryMethod=e,se.isErrorsVisible=!1)},this.initialStockCheck=function(){return e(se,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:H.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return e(se,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=V.getPaymentGateways().map((function(e){return e.id})),[4,N.listPaymentGateway({cartId:this.isUpsellOrder?this.checkout.id:void 0,id:e?void 0:{in:i},locale:V.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===Y.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(V.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===Y.PAYMENT&&(c=n.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id=T,d.src=L,d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout,store:U.getInstance()})},document.head.appendChild(d)),[2]):(this.error={type:H.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return e(se,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;se.store.customerStore.customer?(null===(e=se.customerAddresses)||void 0===e||e.forEach((function(e){e.checkoutSettings=se.checkoutSettings,e.shippingZones=se.shippingZones})),se.checkout.customer=new C(se.store.customerStore.customer)):se.checkout.customer=new C(se.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){se.checkout.shippingAddress&&(se.checkout.shippingAddress.checkoutSettings=se.checkoutSettings,se.checkout.shippingAddress.shippingZones=se.shippingZones,se.checkout.shippingAddress.countrySettings=se.countrySettings,se.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){se.checkout.billingAddress&&(se.checkout.billingAddress.checkoutSettings=se.checkoutSettings,se.checkout.billingAddress.shippingZones=se.shippingZones,se.checkout.billingAddress.countrySettings=se.countrySettings,se.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!se.isDigitalOnly)if(se.isInStoreDelivery)se.setCheckoutShippingAddressSettings();else if(se.checkout.shippingAddress){if(se.store.customerStore.customer){var e=null==(t=se.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=se.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return se.onSelectedShippingAddressIdChange(e.id||"-1"),void se.setCheckoutShippingAddressSettings()}se.checkout.shippingAddress=new B(n(se.checkout.shippingAddress)||{}),se.setCheckoutShippingAddressSettings()}else if(se.store.customerStore.customer){var t=se.customerAddresses;se.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else se.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(se.useDifferentAddress=!!localStorage.getItem("sAddr"),se.checkout.billingAddress){if(se.store.customerStore.customer){var e=null==(t=se.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=se.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return se.onSelectedBillingAddressIdChange(e.id||"-1"),void se.setCheckoutBillingAddressSettings()}se.checkout.billingAddress=new B(n(se.checkout.billingAddress)||{}),se.setCheckoutBillingAddressSettings()}else if(se.store.customerStore.customer){var t=se.customerAddresses;se.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||se.useDifferentAddress||!se.checkout.shippingAddress||se.isInStoreDelivery||(se.checkout.billingAddress=new B(n(se.checkout.shippingAddress)),se.setCheckoutBillingAddressSettings())}else se.onSelectedBillingAddressIdChange("-1"),se.useDifferentAddress||!se.checkout.shippingAddress||se.isInStoreDelivery||(se.checkout.billingAddress=new B(n(se.checkout.shippingAddress)),se.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(i){return e(se,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(se,void 0,void 0,(function(){return t(this,(function(e){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return e(se,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,j.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===Y.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(se,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:V.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(se.selectedShippingAddressId=e,"-1"===e)se.checkout.shippingAddress=new B,se.checkout.shippingAddress.countrySettings=se.countrySettings;else{var i=null===(t=se.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(se.checkout.shippingAddress=new B(i),se.checkout.shippingAddress.countrySettings=se.countrySettings)}se.checkout.shippingAddress&&(se.checkout.shippingAddress.checkoutSettings=se.checkoutSettings,se.checkout.shippingAddress.shippingZones=se.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(se.selectedBillingAddressId=e,"-1"===e)se.checkout.billingAddress=new B,se.checkout.billingAddress.countrySettings=se.countrySettings;else{var i=null===(t=se.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(se.checkout.billingAddress=new B(i),se.checkout.billingAddress.countrySettings=se.countrySettings)}se.checkout.billingAddress&&(se.checkout.billingAddress.checkoutSettings=se.checkoutSettings,se.checkout.billingAddress.shippingZones=se.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){se.isTermsAndConditionsChecked=e},this.onCardNumberChange=function(e){var t;if(se.cardData&&(!(e.length>se.cardData.cardNumber.length)||X(e))){var i=(se.cardData.cardNumber||"").split(" ").join(""),s=e.split(" ").join("");s.length>16||(i.length<6&&s.length>=6&&!se.installmentInfo?se.getRetrieveInstallmentInfo(s):s.length<6&&i.length>s.length&&(se.cardData.installmentCount=1,se.installmentInfo=void 0),(null===(t=se.installmentInfo)||void 0===t?void 0:t.cardAssociation)===M.AMERICAN_EXPRESS?se.cardData.cardNumber=function(e){var t=[],i=e.slice(0,4),s=e.slice(4,10),n=e.slice(10,15);i&&t.push(i);s&&t.push(s);n&&t.push(n);return t}(s).join(" "):se.cardData.cardNumber=z(s,4).join(" "))}},this.getRetrieveInstallmentInfo=function(i){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,this.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:this.checkout.totalFinalPrice,currencyCode:this.checkout.currencyCode}})];case 1:return t.sent(),(null===(e=this.cardData)||void 0===e?void 0:e.cardNumber)&&this.onCardNumberChange(this.cardData.cardNumber),[2]}}))}))},this.onCardHolderNameChange=function(e){se.cardData&&(se.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(se.cardData&&(!(e.length>se.cardData.expirationDate.length)||X(e))){if(0===(null===(t=se.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(se.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(se.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(se.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(se.cardData.expirationDate=z(d,2).join(" / "))}},this.onCvcChange=function(e){if(se.cardData&&(!(e.length>se.cardData.cvv.length)||X(e))){if(se.installmentInfo){if(se.installmentInfo.cardAssociation===M.AMERICAN_EXPRESS&&e.length>4)return;if(se.installmentInfo.cardAssociation!==M.AMERICAN_EXPRESS&&e.length>3)return}else if(e.length>3)return;se.cardData.cvv=e}},this.saveAddress=function(s){return e(se,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(){se.router.push("/cart")},this.onBackToShoppingClick=function(){se.router.push("/")},this.onGoToLoginClick=function(){se.router.push("/account/login")},this.onProceedToShippingClick=function(){return e(se,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(),this.isManualOrderWithShippingLines?[2,this.changeStep(Y.PAYMENT)]:("address"===this.deliveryMethod?this.changeStep(Y.SHIPPING):this.changeStep(Y.PAYMENT),[3,7]);case 6:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:H.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return e(se,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(Y.PAYMENT),[3,5];case 4:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:H.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return e(se,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(Y.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:H.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!se.canPerformPayment||(se.isErrorsVisible=!0,!1)},this.handlePaymentError=function(e,t){se.error={type:e,data:t}},this.onCompletePaymentClick=function(){return e(se,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:H.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return e(se,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:H.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return e(se,void 0,void 0,(function(){var e,i,s,n,r,o,a,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,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:Z("_fbp"),_fbc:Z("_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===c.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===d.INTERNAL&&this.cardData?this.cardData.toInput():void 0,metadata:{_fbp:Z("_fbp"),_fbc:Z("_fbc")}}})]:[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),a=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(!a||!(null===(S=null==s?void 0:s.data)||void 0===S?void 0:S.returnSlug))throw{data:s.firstErrorMessage,type:H.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(se,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(Y.SUCCESS,i),[2]}}))}))},this.onBackToInfoClick=function(){se.changeStep(Y.INFO)},this.onBackToShippingClick=function(){se.changeStep(Y.SHIPPING)},this.setCustomerConsentGranted=function(e){se.checkout.customer&&(se.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(e){se.useDifferentAddress=e,se.useDifferentAddress?(localStorage.setItem("sAddr","1"),se.checkout.billingAddress=se.checkout.billingAddress||new B,se.checkout.billingAddress.countrySettings=se.countrySettings):(localStorage.removeItem("sAddr"),se.checkout.billingAddress=new B(i({},se.checkout.shippingAddress)))},this.setShouldSaveAddress=function(e){se.shouldSaveAddress=e},this.setAddressTitle=function(e){se.addressTitle=e},this.reInitPaymentMethod=function(){return e(se,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.createAdyenBalancePlatformPaymentSession(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(se,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,this.stripeError=null):this.stripeError={type:H.API_ERROR,data:e.firstErrorMessage},[2]}}))}))},this.createKlarnaClientToken=function(i){return e(se,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,this.klarnaError=null):this.klarnaError={type:H.API_ERROR,data:e.firstErrorMessage},[2]}}))}))},this.createAdyenBalancePlatformPaymentSession=function(i){return e(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,N.createAdyenBalancePlatformPaymentSession({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(se,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(se,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.paymentGateways.length?"STRIPE"!==(e=this.paymentGateways[i]).code||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_PLATFORM"!==e.code||this.adyenResponse?[3,6]:[4,this.createAdyenBalancePlatformPaymentSession(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!==Y.SUCCESS&&(e.paymentMethodType===c.CREDIT_CARD&&e.type===d.INTERNAL&&(this.cardData=new R,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){se.cardData&&(se.cardData.installmentCount=e)},this.changeStep=function(i,s){return e(se,void 0,void 0,(function(){return t(this,(function(e){return W||window.location.replace("".concat(window.location.pathname,"?id=").concat(s||this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return e(se,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){se.isContactModalVisible=e},this.getCampaignOffer=function(s,n){return e(se,void 0,void 0,(function(){var r,o,a=this;return t(this,(function(c){switch(c.label){case 0:return(null==n?void 0:n.length)?(r=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})))})),o=r.map((function(s){return e(a,void 0,void 0,(function(){var e,n,r,o,a,c,d,u,l;return t(this,(function(t){switch(t.label){case 0:return(e=null===(d=s.campaignOffer)||void 0===d?void 0:d.offers.find((function(e){return e.id===s.campaignOfferProductId})))?(n=[e.productId],[4,x.searchProducts({input:{productIdList:n,priceListId:V.getPriceListId(),salesChannelId:V.getSalesChannelId()}})]):[2,Promise.reject()];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(t){return t.hasStock&&!(e.excludedVariantIdList||[]).some((function(e){return e===t.id}))})).map((function(t){return e.discountAmount?new A(i(i({},t),{prices:t.prices.map((function(t){var s=t.finalPrice,n=t.finalPrice-t.finalPrice*e.discountAmount/100;return e.applicablePrice===v.SELL_PRICE&&(s=t.sellPrice,n=t.sellPrice-t.sellPrice*e.discountAmount/100),new I(i(i({},t),{sellPrice:s,discountPrice:n}))}))})):t}))).length?(c=a.find((function(e){return e.isActive})),[2,{product:new E(i(i({},o),{selectedVariantValues:(c||a[0]).variantValues,variants:a})),offer:e,campaignOffer:s}]):[2,Promise.reject()]):[2,Promise.reject()]}}))}))})),[4,Promise.allSettled(o)]):[2,[]];case 1:return[2,c.sent().filter((function(e){return"fulfilled"===e.status&&e.value})).map((function(e){return e.value}))]}}))}))},this.createCampaignOffer=function(){return e(se,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===Y.SUCCESS?m.POST_CHECKOUT:m.CHECKOUT,this.checkout.campaignOffers)];case 1:return e.campaignOffers=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return e(se,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,j.updateCartCampaignOffer({input:i})];case 1:return(e=t.sent()).isSuccess?i.accepted?(this.changeStep(this.step===Y.SUCCESS?Y.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(se,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(se,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(se,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=o,this.checkoutSettings=b,this.router=P,this.returnPolicy=q,this.privacyPolicy=Q,this.termsOfService=$,this.imprint=J,this.shippingPolicy=ee,this.t=te,this.customizationProps=ie,this.mpVM=new D,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new w({currentLocale:V.getCurrentLocale()}),this.init(),s(this)}return Object.defineProperty(q.prototype,"merchantSettings",{get:function(){return new P(V.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(q.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(q.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(q.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=U.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(q.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(q.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"finalPrice",{get:function(){return this.step===Y.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===H.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(q.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)!==H.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(q.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(q.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isValidShippingSettings",{get:function(){var e,t=this;return!!(this.isInStoreDelivery||this.isDigitalOnly||this.isManualOrderWithShippingLines)||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(q.prototype,"isManualOrderWithShippingLines",{get:function(){var e,t;return this.checkout.createdBy===o.ADMIN&&(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.length)&&!(null===(t=this.checkout.availableShippingMethods)||void 0===t?void 0:t.length)},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(q.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(q.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"adyenPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(q.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(q.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isCustomFlowStripe",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"STRIPE"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN_PLATFORM"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"store",{get:function(){return U.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isCouponCodeRequirementDefult",{get:function(){return this.checkoutSettings.couponCodeRequirement===a.DEFAULT||null===this.checkoutSettings.couponCodeRequirement},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isCouponCodeRequirementOpen",{get:function(){return this.checkoutSettings.couponCodeRequirement===a.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isCouponCodeRequirementInvisible",{get:function(){return this.checkoutSettings.couponCodeRequirement===a.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isCouponCodeVisible",{get:function(){return this.isCouponCodeRequirementDefult&&!this.isCouponCodeRequirementInvisible},enumerable:!1,configurable:!0}),Object.defineProperty(q.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)===c.CREDIT_CARD&&i.type===d.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(q.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===u.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"customerAddresses",{get:function(){var e,t,s,n=this,r=null===(e=V.getCurrentRouting())||void 0===e?void 0:e.countryCodes;return null===(s=null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===s?void 0:s.filter((function(e){var t;return!(null==r?void 0:r.length)||(null===(t=e.country)||void 0===t?void 0:t.iso2)&&r.includes(e.country.iso2)})).map((function(e){var t=new b(i({countrySettings:n.countrySettings},e));return t.checkoutSettings=n.checkoutSettings,t.shippingZones=n.shippingZones,t.getValidatedCustomerAddress(),t}))},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===o.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isUpsellOrder",{get:function(){return this.checkout.createdBy===o.UPSELL},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isEPayKolayEnabled",{get:function(){var e=V.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isPoweredByHidden",{get:function(){var e=V.getCustom();return!!e&&!!e.hidePoweredBy},enumerable:!1,configurable:!0}),q.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},q}();function z(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function X(e){return e&&q.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(Y||(Y={})),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",e[e.CUSTOMER_ACCOUNT_DISABLED_ERROR=6]="CUSTOMER_ACCOUNT_DISABLED_ERROR"}(H||(H={}));export{Y as CheckoutStep,H as ErrorType,Q as default};
@@ -1 +1 @@
1
- import{__assign as e}from'./../../ext/tslib/tslib.es6.js';import*as t from"react";import{observer as o}from"mobx-react-lite";import i from"next/head.js";import{useRouter as a}from"next/router";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 r}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/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import{IkasIndexPageSeoSetting as n}from"../../models/data/storefront/index-page-seo-setting/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{IkasProductList as s}from"../../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{IkasStorefrontConfig as d}from"@ikas/storefront-config";import"../../analytics/analytics.js";import"../../analytics/head/index.js";import"./index.js";import"next/image.js";import"@ikas/storefront-model-functions";import"../link/index.js";import"../page-editor/loader/style.module.scss.js";import"../google-captcha/index.js";import"../../pages/home.js";import"../../pages/_slug_/index.js";import"../../pages/pages/_slug_.js";import"../../pages/checkout.js";import"../../pages/account/index.js";import"../../pages/account/addresses.js";import"../../pages/account/orders/index.js";import"../../pages/account/orders/_id_.js";import"../../pages/account/login.js";import"../../pages/account/register.js";import"../../pages/account/forgot-password.js";import"../../pages/account/recover-password.js";import"../../pages/cart.js";import"../../pages/editor.js";import"../../pages/account/favorite-products.js";import"../../pages/search.js";import"next/error.js";import"../../pages/blog/index.js";import"../../pages/blog/_slug_.js";import"../../pages/raffle/_slug_.js";import"../../pages/raffle/index.js";import"../../pages/account/raffles.js";import"../../pages/account/activate.js";import{IkasBaseStore as c}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import"lodash/get";var l=o((function(o){var s,l,g,v=o.pageType,f=o.pageTitle,h=o.pageDescription,j=o.canonicals,x=o.disableIndex,y=o.pageSpecificData,b=o.merchantSettings,C=o.addOgpMetas,k=o.productReviewSummary,D=o.pageComponentPropValues,T=a(),w="undefined"!=typeof window,L="local"===process.env.NEXT_PUBLIC_ENV,P=T.asPath.split("?")[0].replace("/",""),E=(P="/"===P.charAt(P.length-1)?P.slice(0,-1):P).startsWith("pages/"),R=d.getCurrentRouting(),O=(null==R?void 0:R.path)?"/"+R.path:"",_=L?"http://localhost:3333":"https://"+d.getDomain(),I=null===(s=d.getIndexPageSeoSettings())||void 0===s?void 0:s.find((function(e){return e.locale===d.getCurrentLocale()})),S=I?new n(I):null;t.useEffect((function(){document.documentElement.lang=d.getCurrentLocale()}),[v,y]);var V=t.useMemo((function(){if(y&&y.href)return"".concat(_).concat(y.href)}),[y]),A=t.useMemo((function(){var e,t,o=[];if(C){if(o.push({property:"og:type",content:"website"}),o.push({property:"og:site_name",content:"https://"+d.getDomain()}),f&&o.push({property:"og:title",content:f}),h&&o.push({property:"og:description",content:h}),v===r.INDEX){var i=null,a=null;!f&&(null==S?void 0:S.pageTitle)&&(i=S.pageTitle),!h&&(null==S?void 0:S.description)&&(a=S.description);var n=null===(e=d.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===d.getCurrentLocale()&&e.pageType===v}));n&&(i=u(y,v,n.titleTemplate||""),a=u(y,v,n.descriptionTemplate||"")),i&&o.push({property:"og:title",content:i}),a&&o.push({property:"og:description",content:a})}if(o.push({property:"og:url",content:V||(w?window.location.href:"")||"https://".concat(d.getDomain())}),y&&v===r.PRODUCT){var s=y.selectedVariant.mainImage;(null==s?void 0:s.image)&&o.push({property:"og:image",content:s.image.src.replace(".webp",".jpg")})}else(null==S?void 0:S.icon)?o.push({property:"og:image",content:null===(t=null==S?void 0:S.icon)||void 0===t?void 0:t.src.replace(".webp",".jpg")}):(null==b?void 0:b.logo)&&o.push({property:"og:image",content:b.logo.src.replace(".webp",".jpg")});if(y&&v===r.CATEGORY){var c=y;c.image&&o.push({property:"og:image",content:c.image.src.replace(".webp",".jpg")})}if(y&&v===r.BRAND){var l=y;l.image&&o.push({property:"og:image",content:l.image.src.replace(".webp",".jpg")})}}return o}),[f,y,V,h,b,C,b]),N=t.useMemo((function(){var t=[];if(b){var o={"@context":"https://schema.org","@type":"Website",url:"https://"+d.getDomain()},i=function(t){var o,i,a,r,n,s,c=(null==t?void 0:t.logo)?t.logo.src:void 0;return{"@context":"https://schema.org","@type":"Store",name:null==t?void 0:t.merchantName,logo:c,image:c,url:"https://"+d.getDomain(),telephone:null==t?void 0:t.phone,address:e(e({"@type":"PostalAddress",streetAddress:null===(o=t.address)||void 0===o?void 0:o.addressLine1,addressLocality:null===(a=null===(i=t.address)||void 0===i?void 0:i.city)||void 0===a?void 0:a.name},t.address&&t.address.state&&{addressRegion:t.address.state.code}),{postalCode:null===(r=t.address)||void 0===r?void 0:r.postalCode,addressCountry:null===(s=null===(n=t.address)||void 0===n?void 0:n.country)||void 0===s?void 0:s.code})}}(b);t.push(o),t.push(i)}if(y&&v===r.PRODUCT){var a=y,n=function(t,o){var i,a,r,n,s;try{var c=d.getCurrentRouting(),l=null==c?void 0:c.path,m=function(e){return l?"https://".concat(d.getDomain(),"/").concat(l).concat(e):"https://".concat(d.getDomain()).concat(e)},p=t.selectedVariant;return e(e({"@context":"https://schema.org/","@type":"Product",name:t.name,description:null===(i=t.metaData)||void 0===i?void 0:i.description,image:null===(a=p.images)||void 0===a?void 0:a.map((function(e){return e.image?e.image.src:""})),productId:p.id,sku:p.sku,mpn:(null===(r=p.barcodeList)||void 0===r?void 0:r.length)?p.barcodeList[0]:"",brand:{"@type":"Brand",name:null===(n=t.brand)||void 0===n?void 0:n.name}},o&&{aggregateRating:{"@type":"AggregateRating",ratingValue:o.averageStar,reviewCount:o.totalReview}}),{offers:{"@type":"Offer",url:m(t.href),priceCurrency:p.price.currency||"TRY",price:(null!==(s=p.campaignPrice)&&void 0!==s?s:p.price.finalPrice).toFixed(2),priceValidUntil:"",itemCondition:"https://schema.org/NewCondition",availability:p.stock>0||p.sellIfOutOfStock?"https://schema.org/InStock":"https://schema.org/OutOfStock"}})}catch(e){}}(a,k||null);if(n&&t.push(n),a.categories.length)(c=m(a.categories[0],a))&&t.push(c)}if(y&&v===r.CATEGORY){var s=function(e){var t,o;try{var i=d.getCurrentRouting(),a=null==i?void 0:i.path,r=function(e){return a?"https://".concat(d.getDomain(),"/").concat(a).concat(e):"https://".concat(d.getDomain()).concat(e)};return{"@context":"http://schema.org","@type":"CollectionPage",url:r(e.href),name:null===(t=e.metaData)||void 0===t?void 0:t.pageTitle,description:null===(o=e.metaData)||void 0===o?void 0:o.description,image:e.image?e.image.src:void 0}}catch(e){}}(y),c=m(y),l=p(D);s&&t.push(s),c&&t.push(c),l&&t.push(l)}y&&v===r.BRAND&&((l=p(D))&&t.push(l));if(y&&v===r.BLOG){var u=function(t){var o;try{var i="https://".concat(d.getDomain()).concat(t.href),a=function(e){var t=new Date(e),o=t.getFullYear(),i=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getDate().toString().padStart(2,"0");return"".concat(o,"-").concat(i,"-").concat(a)},r="".concat(t.writer.firstName," ").concat(t.writer.lastName),n=(new DOMParser).parseFromString(t.blogContent.content,"text/html").body.textContent;return e(e({"@context":"https://schema.org","@type":"BlogPosting",headline:t.title,image:null===(o=t.image)||void 0===o?void 0:o.src},t.category&&{genre:t.category.name}),{url:i,datePublished:a(t.createdAt),dateCreated:a(t.createdAt),dateModified:a(t.updatedAt),description:t.shortDescription,articleBody:n,author:{"@type":"Person",name:r}})}catch(e){}}(y);u&&t.push(u)}return t}),[y,b]),M=t.useMemo((function(){var e,t=null===(e=d.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===d.getCurrentLocale()&&e.pageType===v}));return t?u(y,v,t.titleTemplate||""):null}),[v,y]),B=t.useMemo((function(){var e,t=null===(e=d.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===d.getCurrentLocale()&&e.pageType===v}));return t?u(y,v,t.descriptionTemplate||""):null}),[v,y]),U=t.useMemo((function(){var e,t=null===(e=d.getFavicon())||void 0===e?void 0:e.id;return(null==S?void 0:S.favIcon)&&(t=S.favIcon),t||null}),[]),F=t.useCallback((function(){var e=d.getCustom();return!!e&&!!e.isEPayKolayEnabled}),[]),G=[];d.getRoutings().forEach((function(e){var t;(null===(t=e.countryCodes)||void 0===t?void 0:t.length)?e.countryCodes.forEach((function(t){G.push({routing:e,hrefLang:e.locale+"-"+t})})):G.push({routing:e,hrefLang:e.locale})}));var Y=function(e){var t,o,i,a,r,n=y,s=null===(o=null===(t=null==n?void 0:n.metaData)||void 0===t?void 0:t.translations)||void 0===o?void 0:o.find((function(t){return t.locale===e.locale}));if(s&&(null==s?void 0:s.slug))return s.slug;var d=G.find((function(e){return!e.routing.path}));return d&&(null===(r=null===(a=null===(i=null==n?void 0:n.metaData)||void 0===i?void 0:i.translations)||void 0===a?void 0:a.find((function(e){return e.locale===d.routing.locale})))||void 0===r?void 0:r.slug)||""},H=c.getInstance();return t.createElement(i,null,t.createElement("title",null,f||M||(null==S?void 0:S.pageTitle)||""),t.createElement("meta",{name:"description",content:h||B||(null==S?void 0:S.description)||""}),v===r.CHECKOUT&&F()&&t.createElement("script",{type:"text/javascript",src:"https://cdn-epeykolay.mncdn.com/".concat((null===(l=d.getApiUrl())||void 0===l?void 0:l.includes("myikas.com"))?"epay":"epay-uat","/").concat((null===(g=d.getApiUrl())||void 0===g?void 0:g.includes("myikas.com"))?"containerServices":"containerServicesTest",".js")}),G.length>1&&G.filter((function(e){return!E||e.routing.id===(null==R?void 0:R.id)})).map((function(e){return t.createElement("link",{key:e.routing.id+e.hrefLang,rel:"alternate",hrefLang:e.hrefLang,href:"".concat(_+(e.routing.path?"/"+e.routing.path:""),"/").concat(Y(e.routing))})})),!!x&&t.createElement("meta",{name:"robots",content:"noindex"}),!!C&&A.map((function(e,o){return t.createElement("meta",{key:"".concat(e.content,"-").concat(o),property:e.property,content:e.content})})),!!j&&j.map((function(e,o){return t.createElement("link",{key:o+"url",rel:"canonical",href:"".concat(_).concat(O).concat(e)})})),U&&t.createElement("link",{rel:"shortcut icon",href:"".concat(process.env.NEXT_PUBLIC_CDN_URL,"images/").concat(U,"/image_180.webp"),type:"image/webp"}),!j&&H.currentPageType!==r.NOT_FOUND&&t.createElement("link",{rel:"canonical",href:"".concat(_).concat(O,"/").concat(P)}),!!N.length&&N.map((function(e,o){return t.createElement("script",{key:o,type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(e)}})})))}));function m(e,t){try{var o=c.getInstance(),i=d.getCurrentRouting(),a=null==i?void 0:i.path,n=function(e){return a?"https://".concat(d.getDomain(),"/").concat(a).concat(e):"https://".concat(d.getDomain()).concat(e)},s=e.categoryPathItems.map((function(e,t){return{"@type":"ListItem",position:t+1,name:e.name,item:n(e.href)}}));return s.push({"@type":"ListItem",position:e.categoryPathItems.length+1,name:e.name,item:n(e.href)}),o.currentPageType===r.PRODUCT&&t&&s.push({"@type":"ListItem",position:s.length+1,name:t.name,item:n(t.productHref)}),{"@context":"http://schema.org","@type":"BreadcrumbList",itemListElement:s}}catch(e){}}function p(e){try{var t=d.getCurrentRouting(),o=null==t?void 0:t.path;if(e){var i=(e.filter((function(e){return!e.component.isHeader&&!e.component.isFooter}))||[]).find((function(e){return Object.values(e.propValues).find((function(e){var t;return e instanceof s&&(null===(t=e._productListPropValue)||void 0===t?void 0:t.usePageFilter)}))}));if(i){var a=Object.values(i.propValues).find((function(e){var t;return e instanceof s&&(null===(t=e._productListPropValue)||void 0===t?void 0:t.usePageFilter)}));if(a)return{"@context":"http://schema.org","@type":"ItemList",itemListElement:(a.data||[]).slice(0,10).map((function(e,t){var i,a,r,n;return{"@type":"ListItem",position:t+1,item:{"@type":"Product",name:e.name,image:(null===(a=null===(i=e.selectedVariant.mainImage)||void 0===i?void 0:i.image)||void 0===a?void 0:a.src)||"",offers:{"@type":"Offer",url:(n=e.href,o?"https://".concat(d.getDomain(),"/").concat(o).concat(n):"https://".concat(d.getDomain()).concat(n)),priceCurrency:e.selectedVariant.price.currency||"TRY",price:(null!==(r=e.selectedVariant.campaignPrice)&&void 0!==r?r:e.selectedVariant.finalPrice).toFixed(2)}}}}))}}}}catch(e){}}function u(e,t,o){var i,a,n=o;try{switch(t){case r.PRODUCT:var s=e,d=s.name,c=(null===(i=s.brand)||void 0===i?void 0:i.name)||"",l=s.selectedVariant.sku||"",m=(null===(a=s.selectedVariant.barcodeList)||void 0===a?void 0:a.length)?s.selectedVariant.barcodeList[0]:"",p=s.selectedVariant.campaignPrice?s.selectedVariant.formattedCampaignPrice:s.selectedVariant.formattedFinalPrice;n.includes("{{name}}")&&(n=g(n,"{{name}}",d)),n.includes("{{brand}}")&&(n=g(n,"{{brand}}",c)),n.includes("{{sku}}")&&(n=g(n,"{{sku}}",l)),n.includes("{{barcode}}")&&(n=g(n,"{{barcode}}",m)),n.includes("{{price}}")&&(n=g(n,"{{price}}",p.toString()));break;case r.BRAND:case r.CATEGORY:case r.BLOG_CATEGORY:var u=e.name||"";n.includes("{{name}}")&&(n=g(n,"{{name}}",u));break;case r.BLOG:var v=e.title;n.includes("{{name}}")&&(n=g(n,"{{name}}",v))}}catch(e){}return n.trimEnd()}function g(e,t,o){var i=new RegExp(t,"g");return e.replace(i,o)}export{l as IkasPageHead};
1
+ import{__assign as e}from'./../../ext/tslib/tslib.es6.js';import*as t from"react";import{observer as o}from"mobx-react-lite";import i from"next/head.js";import{useRouter as a}from"next/router";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 r}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/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import{IkasIndexPageSeoSetting as n}from"../../models/data/storefront/index-page-seo-setting/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{IkasProductList as s}from"../../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{IkasStorefrontConfig as d}from"@ikas/storefront-config";import"../../analytics/analytics.js";import"../../analytics/head/index.js";import"./index.js";import"next/image.js";import"@ikas/storefront-model-functions";import"../link/index.js";import"../page-editor/loader/style.module.scss.js";import"../google-captcha/index.js";import"../../pages/home.js";import"../../pages/_slug_/index.js";import"../../pages/pages/_slug_.js";import"../../pages/checkout.js";import"../../pages/account/index.js";import"../../pages/account/addresses.js";import"../../pages/account/orders/index.js";import"../../pages/account/orders/_id_.js";import"../../pages/account/login.js";import"../../pages/account/register.js";import"../../pages/account/forgot-password.js";import"../../pages/account/recover-password.js";import"../../pages/cart.js";import"../../pages/editor.js";import"../../pages/account/favorite-products.js";import"../../pages/search.js";import"next/error.js";import"../../pages/blog/index.js";import"../../pages/blog/_slug_.js";import"../../pages/raffle/_slug_.js";import"../../pages/raffle/index.js";import"../../pages/account/raffles.js";import"../../pages/account/activate.js";import{IkasBaseStore as c}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import"lodash/get";var l=o((function(o){var s,l,g,v=o.pageType,f=o.pageTitle,h=o.pageDescription,j=o.canonicals,x=o.disableIndex,y=o.pageSpecificData,b=o.merchantSettings,C=o.addOgpMetas,k=o.productReviewSummary,D=o.pageComponentPropValues,T=a(),w="undefined"!=typeof window,L="local"===process.env.NEXT_PUBLIC_ENV,P=T.asPath.split("?")[0].replace("/",""),E=(P="/"===P.charAt(P.length-1)?P.slice(0,-1):P).startsWith("pages/"),R=d.getCurrentRouting(),O=(null==R?void 0:R.path)?"/"+R.path:"",_=L?"http://localhost:3333":"https://"+d.getDomain(),I=null===(s=d.getIndexPageSeoSettings())||void 0===s?void 0:s.find((function(e){return e.locale===d.getCurrentLocale()})),S=I?new n(I):null;t.useEffect((function(){document.documentElement.lang=d.getCurrentLocale()}),[v,y]);var V=t.useMemo((function(){if(y&&y.href)return"".concat(_).concat(y.href)}),[y]),A=t.useMemo((function(){var e,t,o=[];if(C){if(o.push({property:"og:type",content:"website"}),o.push({property:"og:site_name",content:"https://"+d.getDomain()}),f&&o.push({property:"og:title",content:f}),h&&o.push({property:"og:description",content:h}),v===r.INDEX){var i=null,a=null;!f&&(null==S?void 0:S.pageTitle)&&(i=S.pageTitle),!h&&(null==S?void 0:S.description)&&(a=S.description);var n=null===(e=d.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===d.getCurrentLocale()&&e.pageType===v}));n&&(i=u(y,v,n.titleTemplate||""),a=u(y,v,n.descriptionTemplate||"")),i&&o.push({property:"og:title",content:i}),a&&o.push({property:"og:description",content:a})}if(o.push({property:"og:url",content:V||(w?window.location.href:"")||"https://".concat(d.getDomain())}),y&&v===r.PRODUCT){var s=y.selectedVariant.mainImage;(null==s?void 0:s.image)&&o.push({property:"og:image",content:s.image.src.replace(".webp",".jpg")})}else(null==S?void 0:S.icon)?o.push({property:"og:image",content:null===(t=null==S?void 0:S.icon)||void 0===t?void 0:t.src.replace(".webp",".jpg")}):(null==b?void 0:b.logo)&&o.push({property:"og:image",content:b.logo.src.replace(".webp",".jpg")});if(y&&v===r.CATEGORY){var c=y;c.image&&o.push({property:"og:image",content:c.image.src.replace(".webp",".jpg")})}if(y&&v===r.BRAND){var l=y;l.image&&o.push({property:"og:image",content:l.image.src.replace(".webp",".jpg")})}}return o}),[f,y,V,h,b,C,b]),N=t.useMemo((function(){var t=[];if(b){var o={"@context":"https://schema.org","@type":"Website",url:"https://"+d.getDomain()},i=function(t){var o,i,a,r,n,s,c=(null==t?void 0:t.logo)?t.logo.src:void 0;return{"@context":"https://schema.org","@type":"Store",name:null==t?void 0:t.merchantName,logo:c,image:c,url:"https://"+d.getDomain(),telephone:null==t?void 0:t.phone,address:e(e({"@type":"PostalAddress",streetAddress:null===(o=t.address)||void 0===o?void 0:o.addressLine1,addressLocality:null===(a=null===(i=t.address)||void 0===i?void 0:i.city)||void 0===a?void 0:a.name},t.address&&t.address.state&&{addressRegion:t.address.state.code}),{postalCode:null===(r=t.address)||void 0===r?void 0:r.postalCode,addressCountry:null===(s=null===(n=t.address)||void 0===n?void 0:n.country)||void 0===s?void 0:s.code})}}(b);t.push(o),t.push(i)}if(y&&v===r.PRODUCT){var a=y,n=function(t,o){var i,a,r,n,s;try{var c=d.getCurrentRouting(),l=null==c?void 0:c.path,m=function(e){return l?"https://".concat(d.getDomain(),"/").concat(l).concat(e):"https://".concat(d.getDomain()).concat(e)},p=t.selectedVariant;return e(e({"@context":"https://schema.org/","@type":"Product",name:t.name,description:null===(i=t.metaData)||void 0===i?void 0:i.description,image:null===(a=p.images)||void 0===a?void 0:a.map((function(e){return e.image?e.image.src:""})),productId:p.id,sku:p.sku,mpn:(null===(r=p.barcodeList)||void 0===r?void 0:r.length)?p.barcodeList[0]:"",brand:{"@type":"Brand",name:null===(n=t.brand)||void 0===n?void 0:n.name}},o&&{aggregateRating:{"@type":"AggregateRating",ratingValue:o.averageStar,reviewCount:o.totalReview}}),{offers:{"@type":"Offer",url:m(t.href),priceCurrency:p.price.currency||"TRY",price:(null!==(s=p.campaignPrice)&&void 0!==s?s:p.price.finalPrice).toFixed(2),priceValidUntil:"",itemCondition:"https://schema.org/NewCondition",availability:p.stock>0||p.sellIfOutOfStock?"https://schema.org/InStock":"https://schema.org/OutOfStock"}})}catch(e){}}(a,k||null);if(n&&t.push(n),a.categories.length)(c=m(a.categories[0],a))&&t.push(c)}if(y&&v===r.CATEGORY){var s=function(e){var t,o;try{var i=d.getCurrentRouting(),a=null==i?void 0:i.path,r=function(e){return a?"https://".concat(d.getDomain(),"/").concat(a).concat(e):"https://".concat(d.getDomain()).concat(e)};return{"@context":"http://schema.org","@type":"CollectionPage",url:r(e.href),name:null===(t=e.metaData)||void 0===t?void 0:t.pageTitle,description:null===(o=e.metaData)||void 0===o?void 0:o.description,image:e.image?e.image.src:void 0}}catch(e){}}(y),c=m(y),l=p(D);s&&t.push(s),c&&t.push(c),l&&t.push(l)}y&&v===r.BRAND&&((l=p(D))&&t.push(l));if(y&&v===r.BLOG){var u=function(t){var o;try{var i="https://".concat(d.getDomain()).concat(t.href),a=function(e){var t=new Date(e),o=t.getFullYear(),i=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getDate().toString().padStart(2,"0");return"".concat(o,"-").concat(i,"-").concat(a)},r="".concat(t.writer.firstName," ").concat(t.writer.lastName),n=(new DOMParser).parseFromString(t.blogContent.content,"text/html").body.textContent;return e(e({"@context":"https://schema.org","@type":"BlogPosting",headline:t.title,image:null===(o=t.image)||void 0===o?void 0:o.src},t.category&&{genre:t.category.name}),{url:i,datePublished:a(t.createdAt),dateCreated:a(t.createdAt),dateModified:a(t.updatedAt),description:t.shortDescription,articleBody:n,author:{"@type":"Person",name:r}})}catch(e){}}(y);u&&t.push(u)}return t}),[y,b]),M=t.useMemo((function(){var e,t=null===(e=d.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===d.getCurrentLocale()&&e.pageType===v}));return t?u(y,v,t.titleTemplate||""):null}),[v,y]),B=t.useMemo((function(){var e,t=null===(e=d.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===d.getCurrentLocale()&&e.pageType===v}));return t?u(y,v,t.descriptionTemplate||""):null}),[v,y]),U=t.useMemo((function(){return!d.getFavicon()&&(null==S?void 0:S.favIcon)?S.favIcon:null}),[]),F=t.useCallback((function(){var e=d.getCustom();return!!e&&!!e.isEPayKolayEnabled}),[]),G=[];d.getRoutings().forEach((function(e){var t;(null===(t=e.countryCodes)||void 0===t?void 0:t.length)?e.countryCodes.forEach((function(t){G.push({routing:e,hrefLang:e.locale+"-"+t})})):G.push({routing:e,hrefLang:e.locale})}));var Y=function(e){var t,o,i,a,r,n=y,s=null===(o=null===(t=null==n?void 0:n.metaData)||void 0===t?void 0:t.translations)||void 0===o?void 0:o.find((function(t){return t.locale===e.locale}));if(s&&(null==s?void 0:s.slug))return s.slug;var d=G.find((function(e){return!e.routing.path}));return d&&(null===(r=null===(a=null===(i=null==n?void 0:n.metaData)||void 0===i?void 0:i.translations)||void 0===a?void 0:a.find((function(e){return e.locale===d.routing.locale})))||void 0===r?void 0:r.slug)||""},H=c.getInstance();return t.createElement(i,null,t.createElement("title",null,f||M||(null==S?void 0:S.pageTitle)||""),t.createElement("meta",{name:"description",content:h||B||(null==S?void 0:S.description)||""}),v===r.CHECKOUT&&F()&&t.createElement("script",{type:"text/javascript",src:"https://cdn-epeykolay.mncdn.com/".concat((null===(l=d.getApiUrl())||void 0===l?void 0:l.includes("myikas.com"))?"epay":"epay-uat","/").concat((null===(g=d.getApiUrl())||void 0===g?void 0:g.includes("myikas.com"))?"containerServices":"containerServicesTest",".js")}),G.length>1&&G.filter((function(e){return!E||e.routing.id===(null==R?void 0:R.id)})).map((function(e){return t.createElement("link",{key:e.routing.id+e.hrefLang,rel:"alternate",hrefLang:e.hrefLang,href:"".concat(_+(e.routing.path?"/"+e.routing.path:""),"/").concat(Y(e.routing))})})),!!x&&t.createElement("meta",{name:"robots",content:"noindex"}),!!C&&A.map((function(e,o){return t.createElement("meta",{key:"".concat(e.content,"-").concat(o),property:e.property,content:e.content})})),!!j&&j.map((function(e,o){return t.createElement("link",{key:o+"url",rel:"canonical",href:"".concat(_).concat(O).concat(e)})})),U&&t.createElement("link",{rel:"shortcut icon",href:"".concat(process.env.NEXT_PUBLIC_CDN_URL,"images/").concat(U,"/image_180.webp"),type:"image/webp"}),!j&&H.currentPageType!==r.NOT_FOUND&&t.createElement("link",{rel:"canonical",href:"".concat(_).concat(O,"/").concat(P)}),!!N.length&&N.map((function(e,o){return t.createElement("script",{key:o,type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(e)}})})))}));function m(e,t){try{var o=c.getInstance(),i=d.getCurrentRouting(),a=null==i?void 0:i.path,n=function(e){return a?"https://".concat(d.getDomain(),"/").concat(a).concat(e):"https://".concat(d.getDomain()).concat(e)},s=e.categoryPathItems.map((function(e,t){return{"@type":"ListItem",position:t+1,name:e.name,item:n(e.href)}}));return s.push({"@type":"ListItem",position:e.categoryPathItems.length+1,name:e.name,item:n(e.href)}),o.currentPageType===r.PRODUCT&&t&&s.push({"@type":"ListItem",position:s.length+1,name:t.name,item:n(t.productHref)}),{"@context":"http://schema.org","@type":"BreadcrumbList",itemListElement:s}}catch(e){}}function p(e){try{var t=d.getCurrentRouting(),o=null==t?void 0:t.path;if(e){var i=(e.filter((function(e){return!e.component.isHeader&&!e.component.isFooter}))||[]).find((function(e){return Object.values(e.propValues).find((function(e){var t;return e instanceof s&&(null===(t=e._productListPropValue)||void 0===t?void 0:t.usePageFilter)}))}));if(i){var a=Object.values(i.propValues).find((function(e){var t;return e instanceof s&&(null===(t=e._productListPropValue)||void 0===t?void 0:t.usePageFilter)}));if(a)return{"@context":"http://schema.org","@type":"ItemList",itemListElement:(a.data||[]).slice(0,10).map((function(e,t){var i,a,r,n;return{"@type":"ListItem",position:t+1,item:{"@type":"Product",name:e.name,image:(null===(a=null===(i=e.selectedVariant.mainImage)||void 0===i?void 0:i.image)||void 0===a?void 0:a.src)||"",offers:{"@type":"Offer",url:(n=e.href,o?"https://".concat(d.getDomain(),"/").concat(o).concat(n):"https://".concat(d.getDomain()).concat(n)),priceCurrency:e.selectedVariant.price.currency||"TRY",price:(null!==(r=e.selectedVariant.campaignPrice)&&void 0!==r?r:e.selectedVariant.finalPrice).toFixed(2)}}}}))}}}}catch(e){}}function u(e,t,o){var i,a,n=o;try{switch(t){case r.PRODUCT:var s=e,d=s.name,c=(null===(i=s.brand)||void 0===i?void 0:i.name)||"",l=s.selectedVariant.sku||"",m=(null===(a=s.selectedVariant.barcodeList)||void 0===a?void 0:a.length)?s.selectedVariant.barcodeList[0]:"",p=s.selectedVariant.campaignPrice?s.selectedVariant.formattedCampaignPrice:s.selectedVariant.formattedFinalPrice;n.includes("{{name}}")&&(n=g(n,"{{name}}",d)),n.includes("{{brand}}")&&(n=g(n,"{{brand}}",c)),n.includes("{{sku}}")&&(n=g(n,"{{sku}}",l)),n.includes("{{barcode}}")&&(n=g(n,"{{barcode}}",m)),n.includes("{{price}}")&&(n=g(n,"{{price}}",p.toString()));break;case r.BRAND:case r.CATEGORY:case r.BLOG_CATEGORY:var u=e.name||"";n.includes("{{name}}")&&(n=g(n,"{{name}}",u));break;case r.BLOG:var v=e.title;n.includes("{{name}}")&&(n=g(n,"{{name}}",v))}}catch(e){}return n.trimEnd()}function g(e,t,o){var i=new RegExp(t,"g");return e.replace(i,o)}export{l as IkasPageHead};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t}from'./../../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import{IkasBlogMetaDataTargetType as o}from"../../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 n}from"@ikas/storefront-models";import{reaction as a,makeAutoObservable as s,runInAction as r}from"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{IkasHTMLMetaDataTargetType as d}from"../../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/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import{IkasThemeJson as p}from"../../models/data/theme-json/index.js";import{IkasStorefront as c}from"../../models/data/storefront/index.js";import{IkasThemeJsonComponent as l}from"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import{IkasThemeJsonPageComponent as m}from"../../models/data/theme-json/page/component/index.js";import{IkasThemeJsonSettings as u}from"../../models/data/theme-json/settings/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"../../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{IkasPageDataProvider as g}from"@ikas/storefront-providers";import{IkasPageDataInit as h}from"../../page-data-init/index.js";import"../../analytics/analytics.js";import"../../analytics/head/index.js";import"../page/index.js";import"../page/head.js";import"react";import"next/image.js";import"@ikas/storefront-model-functions";import"../link/index.js";import"./loader/style.module.scss.js";import"../google-captcha/index.js";import"../../pages/home.js";import"../../pages/_slug_/index.js";import"../../pages/pages/_slug_.js";import"../../pages/checkout.js";import"../../pages/account/index.js";import"../../pages/account/addresses.js";import"../../pages/account/orders/index.js";import"../../pages/account/orders/_id_.js";import"../../pages/account/login.js";import"../../pages/account/register.js";import"../../pages/account/forgot-password.js";import"../../pages/account/recover-password.js";import"../../pages/cart.js";import"../../pages/editor.js";import"../../pages/account/favorite-products.js";import"../../pages/search.js";import"next/error.js";import"../../pages/blog/index.js";import"../../pages/blog/_slug_.js";import"../../pages/raffle/_slug_.js";import"../../pages/raffle/index.js";import"../../pages/account/raffles.js";import"../../pages/account/activate.js";import{IkasBaseStore as f}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import"lodash/get";import E from"../../store/html-meta-data/index.js";import v from"../../store/blog/index.js";import P from"../../store/raffle/index.js";import O from"../../store/product/index.js";import{setAPIClientConfig as T,listCustomerSettings as C}from"@ikas/storefront-api";var _,j=function(){function j(a){var O=this;this.theme=null,this.page=null,this.selectedPageComponentId=null,this.hoveredPageComponentId=null,this.componentRefs={},this.isLoading=!1,this.updateId="",this.locale="en",this.pageParams={},this.apiKey=null,this.pageDataProvider=null,this.initializedPropValues=[],this.startMessaging=function(){window.addEventListener("message",O.onMessage,!1),O.sendMessage(_.FRAME_DID_LOAD,"5.0.0"),O.createLoadingListener()},this.onMessage=function(i){return e(O,void 0,void 0,(function(){var e,o;return t(this,(function(t){switch(t.label){case 0:switch(e=i.data.type,o=i.data.data,e){case _.UPDATE_FRAME_DATA:return[3,1];case _.UPDATE_THEME_JSON:return[3,3];case _.UPDATE_PROP_VALUE:return[3,5];case _.UPDATE_PAGE_PARAMS:return[3,7];case _.UPDATE_PAGE_COMPONENT_ORDER:return[3,9];case _.ADD_COMPONENT:return[3,11];case _.DELETE_COMPONENT:return[3,12];case _.UPDATE_COMPONENT:return[3,13];case _.ADD_PAGE_COMPONENT:return[3,14];case _.DELETE_PAGE_COMPONENT:return[3,16];case _.SET_SELECTED_COMPONENT:return[3,17];case _.SET_HOVERED_COMPONENT:return[3,18];case _.SCROLL_TO_COMPONENT:return[3,19];case _.EDITOR_RELOAD:return[3,20];case _.UPDATE_THEME_SETTINGS:return[3,21]}return[3,22];case 1:return[4,this.handleUpdateFrameData(o)];case 2:case 4:case 6:case 8:case 10:case 15:return t.sent(),[3,23];case 3:return[4,this.handleUpdateThemeJson(o)];case 5:return[4,this.handleUpdatePropValue(o)];case 7:return[4,this.handleUpdatePageParams(o)];case 9:return[4,this.handleUpdatePageComponentOrder(o)];case 11:return this.handleAddNewComponent(o),[3,23];case 12:return this.handleDeleteComponent(o),[3,23];case 13:return this.handleUpdateComponent(o),[3,23];case 14:return[4,this.handleAddNewPageComponent(o)];case 16:return this.handleDeletePageComponent(o),[3,23];case 17:return this.handleSetSelectedComponent(o),[3,23];case 18:return this.handleSetHoveredComponent(o),[3,23];case 19:return this.handleScrollToComponent(o),[3,23];case 20:return this.handleEditorReload(),[3,23];case 21:return this.updateThemeSettings(o),[3,23];case 22:return[3,23];case 23:return[2]}}))}))},this.onClick=function(e){O.sendMessage(_.COMPONENT_CLICK,{componentId:e})},this.onMouseOver=function(e){O.sendMessage(_.COMPONENT_MOUSE_OVER,{componentId:e})},this.onMouseLeave=function(e){O.sendMessage(_.COMPONENT_MOUSE_LEAVE,{componentId:e})},this.onPageChange=function(i){return e(O,void 0,void 0,(function(){var e,a,s,p,c,l,m,u,g,h,O,T,C,j=this;return t(this,(function(t){switch(t.label){case 0:return e=i.slice(1),a=e.split("?"),e=a[0],s=a[1],this.pageParams={},i.startsWith("/account/orders/")?p=n.ORDER_DETAIL:i.startsWith("/account/orders")?p=n.ORDERS:i.startsWith("/account/addresses")?p=n.ADDRESSES:i.startsWith("/account/favorite-products")?p=n.FAVORITE_PRODUCTS:i.startsWith("/account/forgot-password")?p=n.FORGOT_PASSWORD:i.startsWith("/account/login")?p=n.LOGIN:i.startsWith("/account/raffles")?p=n.RAFFLE_ACCOUNT:i.startsWith("/account/recover-password")?p=n.RECOVER_PASSWORD:i.startsWith("/account/activate")?p=n.ACTIVATE_CUSTOMER:i.startsWith("/account/register")?p=n.REGISTER:i.startsWith("/account")?p=n.ACCOUNT:i.startsWith("/blog/")?p=n.BLOG:i.startsWith("/blog")?p=n.BLOG_INDEX:i.startsWith("/pages")?(p=n.CUSTOM,this.pageParams={slug:e.split("/")[1]}):p=i.startsWith("/raffle/")?n.RAFFLE_DETAIL:i.startsWith("/raffle")?n.RAFFLE:i.startsWith("/404")?n.NOT_FOUND:i.startsWith("/cart")?n.CART:i.startsWith("/checkout")?n.CHECKOUT:"/"===i?n.INDEX:i.startsWith("/search")?n.SEARCH:n.PRODUCT,p!==n.PRODUCT?[3,6]:[4,E.listHTMLMetaData({slug:{eq:e}})];case 1:return(l=t.sent()).isSuccess&&(null===(g=l.data)||void 0===g?void 0:g.length)?(m=l.data[0]).targetType!==d.PRODUCT?[3,3]:[4,this.getVariantIdFromParams(m.targetId,s)]:[3,5];case 2:return c=t.sent(),this.pageParams={productId:m.targetId,variantId:c,slug:e},[3,4];case 3:if(m.targetType===d.CATEGORY)p=n.CATEGORY,this.pageParams={categoryId:m.targetId,slug:e};else{if(m.targetType!==d.BRAND)return[2];p=n.BRAND,this.pageParams={brandId:m.targetId,slug:e}}t.label=4;case 4:return[3,6];case 5:return[2];case 6:return p!==n.BLOG?[3,8]:[4,v.listBlogMetaData({slug:{eq:e}})];case 7:if(!(l=t.sent()).isSuccess||!(null===(O=null===(h=l.data)||void 0===h?void 0:h.data)||void 0===O?void 0:O.length))return[2];if((m=l.data.data[0]).targetType===o.BLOG)this.pageParams={blogId:m.targetId,slug:e};else{if(m.targetType!==o.BLOG_CATEGORY)return[2];p=n.BLOG_CATEGORY,this.pageParams={blogCategoryId:m.targetId,slug:e}}t.label=8;case 8:return p!==n.RAFFLE_DETAIL?[3,10]:[4,P.listRaffleMetaData({slug:{eq:e}})];case 9:if(!(l=t.sent()).isSuccess||!(null===(T=l.data)||void 0===T?void 0:T.length))return[2];m=l.data[0],this.pageParams={raffleId:m.targetId,slug:e},t.label=10;case 10:return this.isLoading=!0,[4,this.getPagePropValues(this.theme,p,this.pageParams)];case 11:return u=t.sent(),r((function(){var e,t;f.getInstance().currentPageType=p,j.pageDataProvider=u,p===n.CUSTOM?j.page=null===(e=j.theme)||void 0===e?void 0:e.pages.find((function(e){return e.type===p&&e.slug===j.pageParams.slug})):j.page=null===(t=j.theme)||void 0===t?void 0:t.pages.find((function(e){return e.type===p})),j.setCurrentPageType(),requestAnimationFrame((function(){document.body.scrollTop=0,document.scrollingElement&&(document.scrollingElement.scrollTop=0)}))})),this.sendMessage(_.EDITOR_PAGE_CHANGE,{pageType:p,pageParams:this.pageParams,pageSpecificData:(null===(C=this.pageDataProvider)||void 0===C?void 0:C.pageSpecificData)||null}),this.isLoading=!1,[2]}}))}))},this.onLoadingChange=function(){O.sendMessage(_.EDITOR_LOADING_CHANGE,{isLoading:O.isLoading})},this.sendMessage=function(e,t){window.parent.postMessage({type:e,data:JSON.parse(JSON.stringify(t))},"*")},this.getPagePropValues=function(i,o,a){return e(O,void 0,void 0,(function(){var e,s,r;return t(this,(function(t){switch(t.label){case 0:return e=new g(i,a,o),(a.blogId||a.blogCategoryId)&&(e.possiblePageTypes=[n.BLOG,n.BLOG_CATEGORY]),a.raffleId&&(e.possiblePageTypes=[n.RAFFLE_DETAIL]),[4,e.getPageData()];case 1:return t.sent(),e.pageSpecificData?(h.setPageSpecificData(e.pageSpecificData,o,!0),o===n.PRODUCT&&h.pageSpecificData&&(s=h.pageSpecificData,(r=s.variants.find((function(e){return e.id===a.variantId})))&&(s.selectedVariantValues=r.variantValues))):h.pageSpecificData=void 0,this.initializedPropValues=h.initPagePropValues(e.$pageComponentPropValues,i.components,i.customData,i.settings,!1),[2,e]}}))}))},this.setComponentRef=function(e,t){O.componentRefs[t.id]=e},this.isScrolledIntoView=function(e){var t=e.getBoundingClientRect(),i=t.top,o=t.bottom;return i<window.innerHeight&&o>=0&&o<window.innerHeight&&i>0},this.handleUpdateFrameData=function(o){return e(O,void 0,void 0,(function(){var e,n,a,s,r,d,l=this;return t(this,(function(t){switch(t.label){case 0:return this.theme=new p(o.theme),this.page=null===(r=this.theme)||void 0===r?void 0:r.pages.find((function(e){return e.id===o.selectedPage.id})),this.pageParams=o.pageParams,this.apiKey=o.apiKey,this.locale=o.locale||"en",this.translations=o.translations||void 0,this.setCurrentPageType(),this.page?((e=o.storefront?new c(o.storefront):null)&&(n=e.routings.find((function(e){return e.locale===l.locale})),i.init({storefrontId:e.id,storefrontRoutingId:null==n?void 0:n.id,storefrontThemeId:e.mainStorefrontThemeId||void 0,salesChannelId:e.salesChannelId||void 0,priceListId:(null==n?void 0:n.priceListId)||void 0,routings:e.routings,stockPreference:null===(d=this.theme)||void 0===d?void 0:d.settings.stockPreference,translations:this.translations||i.getTranslations(),isEditor:!0,apiKey:o.apiKey,apiUrl:o.apiUrl,cdnUrl:o.cdnUrl,merchantSettings:o.merchantSettings}),T(),this.setCustomerSettings()),a=Date.now()+"",this.updateId=a,this.isLoading=!0,[4,this.getPagePropValues(this.theme,this.page.type,this.pageParams||{})]):[2];case 1:return s=t.sent(),this.updateId===a&&(this.pageDataProvider=s,this.isLoading=!1),[2]}}))}))},this.setCustomerSettings=function(){return e(O,void 0,void 0,(function(){var e,o,n;return t(this,(function(t){switch(t.label){case 0:return i.getCustomerSettings()?[3,2]:[4,C({storefrontId:{eq:i.getStorefrontId()}})];case 1:(e=t.sent()).isSuccess&&(null===(n=e.data)||void 0===n?void 0:n.data.length)&&(o=e.data.data[0],i.init({customerSettings:o})),t.label=2;case 2:return[2]}}))}))},this.handleUpdateThemeJson=function(i){return e(O,void 0,void 0,(function(){return t(this,(function(e){return this.theme=new p(i.theme),[2]}))}))},this.handleUpdatePropValue=function(i){return e(O,void 0,void 0,(function(){var e,o,n,a,s,r,d,p=this;return t(this,(function(t){switch(t.label){case 0:return e=i.propName,o=i.value,(n=null===(d=null===(r=this.selectedComponent)||void 0===r?void 0:r.props)||void 0===d?void 0:d.find((function(t){return t.name===e})))&&this.selectedPageComponent?(a=this.initializedPropValues.find((function(e){return e.pageComponent.id===p.selectedPageComponentId})),this.pageDataProvider&&a?(this.selectedPageComponent.propValues[e]=o,[4,this.pageDataProvider.getPageComponentPropValue(this.selectedPageComponent,n)]):[2]):[2];case 1:return(s=t.sent())&&JSON.stringify(s).includes("href")?[4,this.pageDataProvider.setLinkSlugs()]:[3,3];case 2:t.sent(),t.label=3;case 3:return a.propValues[e]=h.initPropValue(n,s,this.theme.settings,!0),[2]}}))}))},this.handleUpdatePageParams=function(i){return e(O,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.pageParams=i.pageParams,this.isLoading=!0,[4,this.getPagePropValues(this.theme,this.page.type,this.pageParams||{})];case 1:return e=t.sent(),this.pageDataProvider=e,this.isLoading=!1,[2]}}))}))},this.handleUpdatePageComponentOrder=function(i){return e(O,void 0,void 0,(function(){return t(this,(function(e){return this.specification?this.specification.components=i.pageComponents.map((function(e){return new m(e)})):this.page.components=i.pageComponents.map((function(e){return new m(e)})),[2]}))}))},this.handleAddNewComponent=function(e){var t,i=new l(e.component);null===(t=O.theme)||void 0===t||t.components.push(i)},this.handleDeleteComponent=function(e){var t,i;(null===(t=O.theme)||void 0===t?void 0:t.components)&&(O.theme.components=O.theme.components.filter((function(t){return t.id!==e.componentId})));var o=O.pageComponents.filter((function(t){return t.componentId!==e.componentId}))||[];O.specification&&O.specification.components&&(O.specification.components=o),!O.specification&&(null===(i=O.page)||void 0===i?void 0:i.components)&&(O.page.components=o)},this.handleUpdateComponent=function(e){var t=O.theme.components.findIndex((function(t){return t.id===e.component.id}));-1!==t&&(O.theme.components[t]=new l(e.component))},this.handleAddNewPageComponent=function(i){return e(O,void 0,void 0,(function(){var e,o,a,s,r,d,p;return t(this,(function(t){switch(t.label){case 0:return e=new m(i.pageComponent),this.pageComponents.some((function(t){return t.id===e.id}))?[2]:[4,this.pageDataProvider.getPageComponentPropValues(e)];case 1:return o=t.sent(),a=h.initPageComponentPropValue(o,[o.component],this.theme.settings,!0),this.initializedPropValues.push(a),(null===(d=this.page)||void 0===d?void 0:d.type)===n.CHECKOUT?[2]:(s=null===(p=this.theme)||void 0===p?void 0:p.components.find((function(t){return t.id===e.componentId})),r=this.pageComponents.find((function(e){return e.componentId===(null==s?void 0:s.id)})),(null==s?void 0:s.isCommon)&&r||(i.customIndex?this.pageComponents.splice(i.customIndex,0,e):this.pageComponents.push(e)),[2])}}))}))},this.handleDeletePageComponent=function(e){O.specification?O.specification.components=O.pageComponents.filter((function(t){return t.id!==e.pageComponentId})):O.page.components=O.pageComponents.filter((function(t){return t.id!==e.pageComponentId}))},this.handleSetSelectedComponent=function(e){O.selectedPageComponentId=e.componentId},this.handleSetHoveredComponent=function(e){O.hoveredPageComponentId=e.componentId},this.handleScrollToComponent=function(e){var t=e.componentId,i=O.componentRefs[t];i&&(O.isScrolledIntoView(i)||window.scrollTo({top:i.offsetTop,behavior:"smooth"}))},this.handleEditorReload=function(){window.location.reload()},this.updateThemeSettings=function(e){var t=e.settings;O.theme&&(O.theme.settings=new u(t))},this.router=a,s(this),this.startMessaging()}return Object.defineProperty(j.prototype,"specification",{get:function(){var e,t,i,o,a,s,r,d=this,p=this.page;return(null==p?void 0:p.type)===n.PRODUCT&&(r=null===(e=p.specifications)||void 0===e?void 0:e.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.productId)}))),(null==p?void 0:p.type)===n.CATEGORY&&(r=null===(t=p.specifications)||void 0===t?void 0:t.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.categoryId)}))),(null==p?void 0:p.type)===n.BRAND&&(r=null===(i=p.specifications)||void 0===i?void 0:i.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.brandId)}))),(null==p?void 0:p.type)===n.BLOG&&(r=null===(o=p.specifications)||void 0===o?void 0:o.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.blogId)}))),(null==p?void 0:p.type)===n.BLOG_CATEGORY&&(r=null===(a=p.specifications)||void 0===a?void 0:a.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.blogCategoryId)}))),(null==p?void 0:p.type)===n.RAFFLE_DETAIL&&(r=null===(s=p.specifications)||void 0===s?void 0:s.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.raffleId)}))),r},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"pageComponents",{get:function(){var e;return this.specification?this.specification.components:(null===(e=this.page)||void 0===e?void 0:e.components)||[]},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"selectedPageComponent",{get:function(){var e=this;return this.pageComponents.find((function(t){return t.id===e.selectedPageComponentId}))},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"selectedComponent",{get:function(){var e,t=this;return null===(e=this.theme)||void 0===e?void 0:e.components.find((function(e){var i;return e.id===(null===(i=t.selectedPageComponent)||void 0===i?void 0:i.componentId)}))},enumerable:!1,configurable:!0}),j.prototype.createLoadingListener=function(){var e=this;a((function(){return e.isLoading}),(function(){e.onLoadingChange()}))},j.prototype.getVariantIdFromParams=function(o,n){var a,s;return e(this,void 0,void 0,(function(){var e,r,d,p,c,l,m;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=new URLSearchParams("?"+n),[4,O.searchProducts({input:{productIdList:[o],priceListId:i.getPriceListId(),salesChannelId:i.getSalesChannelId()}})];case 1:return(r=t.sent()).isSuccess&&!(null===(s=null===(a=null==r?void 0:r.data)||void 0===a?void 0:a.data)||void 0===s?void 0:s.length)?[2]:(d=r.data.data[0],p=d.variantTypes.map((function(e){return e.variantType.slug})),c=[],p.forEach((function(t,i){var o=d.variantTypes[i],n=e.get(t);if(n){var a=o.variantType.values.find((function(e){return e.slug===n}));a&&c.push(a)}})),(l=d.variants.find((function(e){return e.variantValues.every((function(e){return c.some((function(t){return t.id===e.id}))}))})))?[2,l.id]:[3,3]);case 2:return m=t.sent(),console.error(m),[3,3];case 3:return[2]}}))}))},j.prototype.setCurrentPageType=function(){this.page&&(f.getInstance().currentPageType=this.page.type)},j}();!function(e){e.FRAME_DID_LOAD="FRAME_DID_LOAD",e.UPDATE_FRAME_DATA="UPDATE_FRAME_DATA",e.UPDATE_THEME_JSON="UPDATE_THEME_JSON",e.UPDATE_PROP_VALUE="UPDATE_PROP_VALUE",e.UPDATE_PAGE_PARAMS="UPDATE_PAGE_PARAMS",e.UPDATE_PAGE_COMPONENT_ORDER="UPDATE_PAGE_COMPONENT_ORDER",e.ADD_COMPONENT="ADD_COMPONENT",e.DELETE_COMPONENT="DELETE_COMPONENT",e.UPDATE_COMPONENT="UPDATE_COMPONENT",e.ADD_PAGE_COMPONENT="ADD_PAGE_COMPONENT",e.DELETE_PAGE_COMPONENT="DELETE_PAGE_COMPONENT",e.COMPONENT_MOUSE_OVER="COMPONENT_MOUSE_OVER",e.COMPONENT_MOUSE_LEAVE="COMPONENT_MOUSE_LEAVE",e.COMPONENT_CLICK="COMPONENT_CLICK",e.SET_SELECTED_COMPONENT="SET_SELECTED_COMPONENT",e.SET_HOVERED_COMPONENT="SET_HOVERED_COMPONENT",e.SCROLL_TO_COMPONENT="SCROLL_TO_COMPONENT",e.UPDATE_THEME_SETTINGS="UPDATE_THEME_SETTINGS",e.EDITOR_PAGE_CHANGE="EDITOR_PAGE_CHANGE",e.EDITOR_LOADING_CHANGE="EDITOR_LOADING_CHANGE",e.EDITOR_RELOAD="EDITOR_RELOAD"}(_||(_={}));export{_ as BridgeMessageType,j as default};
1
+ import{__awaiter as e,__generator as t}from'./../../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import{IkasBlogMetaDataTargetType as o}from"../../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 n}from"@ikas/storefront-models";import{reaction as a,makeAutoObservable as s,runInAction as r}from"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{IkasHTMLMetaDataTargetType as d}from"../../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/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import{IkasThemeJson as p}from"../../models/data/theme-json/index.js";import{IkasStorefront as c}from"../../models/data/storefront/index.js";import{IkasThemeJsonComponent as l}from"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import{IkasThemeJsonPageComponent as m}from"../../models/data/theme-json/page/component/index.js";import{IkasThemeJsonSettings as u}from"../../models/data/theme-json/settings/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"../../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{IkasPageDataProvider as g}from"@ikas/storefront-providers";import{IkasPageDataInit as h}from"../../page-data-init/index.js";import"../../analytics/analytics.js";import"../../analytics/head/index.js";import"../page/index.js";import"../page/head.js";import"react";import"next/image.js";import"@ikas/storefront-model-functions";import"../link/index.js";import"./loader/style.module.scss.js";import"../google-captcha/index.js";import"../../pages/home.js";import"../../pages/_slug_/index.js";import"../../pages/pages/_slug_.js";import"../../pages/checkout.js";import"../../pages/account/index.js";import"../../pages/account/addresses.js";import"../../pages/account/orders/index.js";import"../../pages/account/orders/_id_.js";import"../../pages/account/login.js";import"../../pages/account/register.js";import"../../pages/account/forgot-password.js";import"../../pages/account/recover-password.js";import"../../pages/cart.js";import"../../pages/editor.js";import"../../pages/account/favorite-products.js";import"../../pages/search.js";import"next/error.js";import"../../pages/blog/index.js";import"../../pages/blog/_slug_.js";import"../../pages/raffle/_slug_.js";import"../../pages/raffle/index.js";import"../../pages/account/raffles.js";import"../../pages/account/activate.js";import{IkasBaseStore as f}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import"lodash/get";import E from"../../store/html-meta-data/index.js";import v from"../../store/blog/index.js";import P from"../../store/raffle/index.js";import O from"../../store/product/index.js";import{setAPIClientConfig as T,listCustomerSettings as C}from"@ikas/storefront-api";var _,j=function(){function j(a){var O=this;this.theme=null,this.page=null,this.selectedPageComponentId=null,this.hoveredPageComponentId=null,this.componentRefs={},this.isLoading=!1,this.updateId="",this.locale="en",this.pageParams={},this.apiKey=null,this.pageDataProvider=null,this.initializedPropValues=[],this.startMessaging=function(){window.addEventListener("message",O.onMessage,!1),O.sendMessage(_.FRAME_DID_LOAD,"5.0.0"),O.createLoadingListener()},this.onMessage=function(i){return e(O,void 0,void 0,(function(){var e,o;return t(this,(function(t){switch(t.label){case 0:switch(e=i.data.type,o=i.data.data,e){case _.UPDATE_FRAME_DATA:return[3,1];case _.UPDATE_THEME_JSON:return[3,3];case _.UPDATE_PROP_VALUE:return[3,5];case _.UPDATE_PAGE_PARAMS:return[3,7];case _.UPDATE_PAGE_COMPONENT_ORDER:return[3,9];case _.ADD_COMPONENT:return[3,11];case _.DELETE_COMPONENT:return[3,12];case _.UPDATE_COMPONENT:return[3,13];case _.ADD_PAGE_COMPONENT:return[3,14];case _.DELETE_PAGE_COMPONENT:return[3,16];case _.SET_SELECTED_COMPONENT:return[3,17];case _.SET_HOVERED_COMPONENT:return[3,18];case _.SCROLL_TO_COMPONENT:return[3,19];case _.EDITOR_RELOAD:return[3,20];case _.UPDATE_THEME_SETTINGS:return[3,21]}return[3,22];case 1:return[4,this.handleUpdateFrameData(o)];case 2:case 4:case 6:case 8:case 10:case 15:return t.sent(),[3,23];case 3:return[4,this.handleUpdateThemeJson(o)];case 5:return[4,this.handleUpdatePropValue(o)];case 7:return[4,this.handleUpdatePageParams(o)];case 9:return[4,this.handleUpdatePageComponentOrder(o)];case 11:return this.handleAddNewComponent(o),[3,23];case 12:return this.handleDeleteComponent(o),[3,23];case 13:return this.handleUpdateComponent(o),[3,23];case 14:return[4,this.handleAddNewPageComponent(o)];case 16:return this.handleDeletePageComponent(o),[3,23];case 17:return this.handleSetSelectedComponent(o),[3,23];case 18:return this.handleSetHoveredComponent(o),[3,23];case 19:return this.handleScrollToComponent(o),[3,23];case 20:return this.handleEditorReload(),[3,23];case 21:return this.updateThemeSettings(o),[3,23];case 22:return[3,23];case 23:return[2]}}))}))},this.onClick=function(e){O.sendMessage(_.COMPONENT_CLICK,{componentId:e})},this.onMouseOver=function(e){O.sendMessage(_.COMPONENT_MOUSE_OVER,{componentId:e})},this.onMouseLeave=function(e){O.sendMessage(_.COMPONENT_MOUSE_LEAVE,{componentId:e})},this.onPageChange=function(i){return e(O,void 0,void 0,(function(){var e,a,s,p,c,l,m,u,g,h,O,T,C,j=this;return t(this,(function(t){switch(t.label){case 0:return e=i.slice(1),a=e.split("?"),e=a[0],s=a[1],this.pageParams={},i.startsWith("/account/orders/")?p=n.ORDER_DETAIL:i.startsWith("/account/orders")?p=n.ORDERS:i.startsWith("/account/addresses")?p=n.ADDRESSES:i.startsWith("/account/favorite-products")?p=n.FAVORITE_PRODUCTS:i.startsWith("/account/forgot-password")?p=n.FORGOT_PASSWORD:i.startsWith("/account/login")?p=n.LOGIN:i.startsWith("/account/raffles")?p=n.RAFFLE_ACCOUNT:i.startsWith("/account/recover-password")?p=n.RECOVER_PASSWORD:i.startsWith("/account/activate")?p=n.ACTIVATE_CUSTOMER:i.startsWith("/account/register")?p=n.REGISTER:i.startsWith("/account")?p=n.ACCOUNT:i.startsWith("/blog/")?p=n.BLOG:i.startsWith("/blog")?p=n.BLOG_INDEX:i.startsWith("/pages")?(p=n.CUSTOM,this.pageParams={slug:e.split("/")[1]}):p=i.startsWith("/raffle/")?n.RAFFLE_DETAIL:i.startsWith("/raffle")?n.RAFFLE:i.startsWith("/404")?n.NOT_FOUND:"/cart"===i||"/cart/"===i?n.CART:i.startsWith("/checkout")?n.CHECKOUT:"/"===i?n.INDEX:i.startsWith("/search")?n.SEARCH:n.PRODUCT,p!==n.PRODUCT?[3,6]:[4,E.listHTMLMetaData({slug:{eq:e}})];case 1:return(l=t.sent()).isSuccess&&(null===(g=l.data)||void 0===g?void 0:g.length)?(m=l.data[0]).targetType!==d.PRODUCT?[3,3]:[4,this.getVariantIdFromParams(m.targetId,s)]:[3,5];case 2:return c=t.sent(),this.pageParams={productId:m.targetId,variantId:c,slug:e},[3,4];case 3:if(m.targetType===d.CATEGORY)p=n.CATEGORY,this.pageParams={categoryId:m.targetId,slug:e};else{if(m.targetType!==d.BRAND)return[2];p=n.BRAND,this.pageParams={brandId:m.targetId,slug:e}}t.label=4;case 4:return[3,6];case 5:return[2];case 6:return p!==n.BLOG?[3,8]:[4,v.listBlogMetaData({slug:{eq:e}})];case 7:if(!(l=t.sent()).isSuccess||!(null===(O=null===(h=l.data)||void 0===h?void 0:h.data)||void 0===O?void 0:O.length))return[2];if((m=l.data.data[0]).targetType===o.BLOG)this.pageParams={blogId:m.targetId,slug:e};else{if(m.targetType!==o.BLOG_CATEGORY)return[2];p=n.BLOG_CATEGORY,this.pageParams={blogCategoryId:m.targetId,slug:e}}t.label=8;case 8:return p!==n.RAFFLE_DETAIL?[3,10]:[4,P.listRaffleMetaData({slug:{eq:e}})];case 9:if(!(l=t.sent()).isSuccess||!(null===(T=l.data)||void 0===T?void 0:T.length))return[2];m=l.data[0],this.pageParams={raffleId:m.targetId,slug:e},t.label=10;case 10:return this.isLoading=!0,[4,this.getPagePropValues(this.theme,p,this.pageParams)];case 11:return u=t.sent(),r((function(){var e,t;f.getInstance().currentPageType=p,j.pageDataProvider=u,p===n.CUSTOM?j.page=null===(e=j.theme)||void 0===e?void 0:e.pages.find((function(e){return e.type===p&&e.slug===j.pageParams.slug})):j.page=null===(t=j.theme)||void 0===t?void 0:t.pages.find((function(e){return e.type===p})),j.setCurrentPageType(),requestAnimationFrame((function(){document.body.scrollTop=0,document.scrollingElement&&(document.scrollingElement.scrollTop=0)}))})),this.sendMessage(_.EDITOR_PAGE_CHANGE,{pageType:p,pageParams:this.pageParams,pageSpecificData:(null===(C=this.pageDataProvider)||void 0===C?void 0:C.pageSpecificData)||null}),this.isLoading=!1,[2]}}))}))},this.onLoadingChange=function(){O.sendMessage(_.EDITOR_LOADING_CHANGE,{isLoading:O.isLoading})},this.sendMessage=function(e,t){window.parent.postMessage({type:e,data:JSON.parse(JSON.stringify(t))},"*")},this.getPagePropValues=function(i,o,a){return e(O,void 0,void 0,(function(){var e,s,r;return t(this,(function(t){switch(t.label){case 0:return e=new g(i,a,o),(a.blogId||a.blogCategoryId)&&(e.possiblePageTypes=[n.BLOG,n.BLOG_CATEGORY]),a.raffleId&&(e.possiblePageTypes=[n.RAFFLE_DETAIL]),[4,e.getPageData()];case 1:return t.sent(),e.pageSpecificData?(h.setPageSpecificData(e.pageSpecificData,o,!0),o===n.PRODUCT&&h.pageSpecificData&&(s=h.pageSpecificData,(r=s.variants.find((function(e){return e.id===a.variantId})))&&(s.selectedVariantValues=r.variantValues))):h.pageSpecificData=void 0,this.initializedPropValues=h.initPagePropValues(e.$pageComponentPropValues,i.components,i.customData,i.settings,!1),[2,e]}}))}))},this.setComponentRef=function(e,t){O.componentRefs[t.id]=e},this.isScrolledIntoView=function(e){var t=e.getBoundingClientRect(),i=t.top,o=t.bottom;return i<window.innerHeight&&o>=0&&o<window.innerHeight&&i>0},this.handleUpdateFrameData=function(o){return e(O,void 0,void 0,(function(){var e,n,a,s,r,d,l=this;return t(this,(function(t){switch(t.label){case 0:return this.theme=new p(o.theme),this.page=null===(r=this.theme)||void 0===r?void 0:r.pages.find((function(e){return e.id===o.selectedPage.id})),this.pageParams=o.pageParams,this.apiKey=o.apiKey,this.locale=o.locale||"en",this.translations=o.translations||void 0,this.setCurrentPageType(),this.page?((e=o.storefront?new c(o.storefront):null)&&(n=e.routings.find((function(e){return e.locale===l.locale})),i.init({storefrontId:e.id,storefrontRoutingId:null==n?void 0:n.id,storefrontThemeId:e.mainStorefrontThemeId||void 0,salesChannelId:e.salesChannelId||void 0,priceListId:(null==n?void 0:n.priceListId)||void 0,routings:e.routings,stockPreference:null===(d=this.theme)||void 0===d?void 0:d.settings.stockPreference,translations:this.translations||i.getTranslations(),isEditor:!0,apiKey:o.apiKey,apiUrl:o.apiUrl,cdnUrl:o.cdnUrl,merchantSettings:o.merchantSettings}),T(),this.setCustomerSettings()),a=Date.now()+"",this.updateId=a,this.isLoading=!0,[4,this.getPagePropValues(this.theme,this.page.type,this.pageParams||{})]):[2];case 1:return s=t.sent(),this.updateId===a&&(this.pageDataProvider=s,this.isLoading=!1),[2]}}))}))},this.setCustomerSettings=function(){return e(O,void 0,void 0,(function(){var e,o,n;return t(this,(function(t){switch(t.label){case 0:return i.getCustomerSettings()?[3,2]:[4,C({storefrontId:{eq:i.getStorefrontId()}})];case 1:(e=t.sent()).isSuccess&&(null===(n=e.data)||void 0===n?void 0:n.data.length)&&(o=e.data.data[0],i.init({customerSettings:o})),t.label=2;case 2:return[2]}}))}))},this.handleUpdateThemeJson=function(i){return e(O,void 0,void 0,(function(){return t(this,(function(e){return this.theme=new p(i.theme),[2]}))}))},this.handleUpdatePropValue=function(i){return e(O,void 0,void 0,(function(){var e,o,n,a,s,r,d,p=this;return t(this,(function(t){switch(t.label){case 0:return e=i.propName,o=i.value,(n=null===(d=null===(r=this.selectedComponent)||void 0===r?void 0:r.props)||void 0===d?void 0:d.find((function(t){return t.name===e})))&&this.selectedPageComponent?(a=this.initializedPropValues.find((function(e){return e.pageComponent.id===p.selectedPageComponentId})),this.pageDataProvider&&a?(this.selectedPageComponent.propValues[e]=o,[4,this.pageDataProvider.getPageComponentPropValue(this.selectedPageComponent,n)]):[2]):[2];case 1:return(s=t.sent())&&JSON.stringify(s).includes("href")?[4,this.pageDataProvider.setLinkSlugs()]:[3,3];case 2:t.sent(),t.label=3;case 3:return a.propValues[e]=h.initPropValue(n,s,this.theme.settings,!0),[2]}}))}))},this.handleUpdatePageParams=function(i){return e(O,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.pageParams=i.pageParams,this.isLoading=!0,[4,this.getPagePropValues(this.theme,this.page.type,this.pageParams||{})];case 1:return e=t.sent(),this.pageDataProvider=e,this.isLoading=!1,[2]}}))}))},this.handleUpdatePageComponentOrder=function(i){return e(O,void 0,void 0,(function(){return t(this,(function(e){return this.specification?this.specification.components=i.pageComponents.map((function(e){return new m(e)})):this.page.components=i.pageComponents.map((function(e){return new m(e)})),[2]}))}))},this.handleAddNewComponent=function(e){var t,i=new l(e.component);null===(t=O.theme)||void 0===t||t.components.push(i)},this.handleDeleteComponent=function(e){var t,i;(null===(t=O.theme)||void 0===t?void 0:t.components)&&(O.theme.components=O.theme.components.filter((function(t){return t.id!==e.componentId})));var o=O.pageComponents.filter((function(t){return t.componentId!==e.componentId}))||[];O.specification&&O.specification.components&&(O.specification.components=o),!O.specification&&(null===(i=O.page)||void 0===i?void 0:i.components)&&(O.page.components=o)},this.handleUpdateComponent=function(e){var t=O.theme.components.findIndex((function(t){return t.id===e.component.id}));-1!==t&&(O.theme.components[t]=new l(e.component))},this.handleAddNewPageComponent=function(i){return e(O,void 0,void 0,(function(){var e,o,a,s,r,d,p;return t(this,(function(t){switch(t.label){case 0:return e=new m(i.pageComponent),this.pageComponents.some((function(t){return t.id===e.id}))?[2]:[4,this.pageDataProvider.getPageComponentPropValues(e)];case 1:return o=t.sent(),a=h.initPageComponentPropValue(o,[o.component],this.theme.settings,!0),this.initializedPropValues.push(a),(null===(d=this.page)||void 0===d?void 0:d.type)===n.CHECKOUT?[2]:(s=null===(p=this.theme)||void 0===p?void 0:p.components.find((function(t){return t.id===e.componentId})),r=this.pageComponents.find((function(e){return e.componentId===(null==s?void 0:s.id)})),(null==s?void 0:s.isCommon)&&r||(i.customIndex?this.pageComponents.splice(i.customIndex,0,e):this.pageComponents.push(e)),[2])}}))}))},this.handleDeletePageComponent=function(e){O.specification?O.specification.components=O.pageComponents.filter((function(t){return t.id!==e.pageComponentId})):O.page.components=O.pageComponents.filter((function(t){return t.id!==e.pageComponentId}))},this.handleSetSelectedComponent=function(e){O.selectedPageComponentId=e.componentId},this.handleSetHoveredComponent=function(e){O.hoveredPageComponentId=e.componentId},this.handleScrollToComponent=function(e){var t=e.componentId,i=O.componentRefs[t];i&&(O.isScrolledIntoView(i)||window.scrollTo({top:i.offsetTop,behavior:"smooth"}))},this.handleEditorReload=function(){window.location.reload()},this.updateThemeSettings=function(e){var t=e.settings;O.theme&&(O.theme.settings=new u(t))},this.router=a,s(this),this.startMessaging()}return Object.defineProperty(j.prototype,"specification",{get:function(){var e,t,i,o,a,s,r,d=this,p=this.page;return(null==p?void 0:p.type)===n.PRODUCT&&(r=null===(e=p.specifications)||void 0===e?void 0:e.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.productId)}))),(null==p?void 0:p.type)===n.CATEGORY&&(r=null===(t=p.specifications)||void 0===t?void 0:t.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.categoryId)}))),(null==p?void 0:p.type)===n.BRAND&&(r=null===(i=p.specifications)||void 0===i?void 0:i.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.brandId)}))),(null==p?void 0:p.type)===n.BLOG&&(r=null===(o=p.specifications)||void 0===o?void 0:o.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.blogId)}))),(null==p?void 0:p.type)===n.BLOG_CATEGORY&&(r=null===(a=p.specifications)||void 0===a?void 0:a.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.blogCategoryId)}))),(null==p?void 0:p.type)===n.RAFFLE_DETAIL&&(r=null===(s=p.specifications)||void 0===s?void 0:s.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.raffleId)}))),r},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"pageComponents",{get:function(){var e;return this.specification?this.specification.components:(null===(e=this.page)||void 0===e?void 0:e.components)||[]},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"selectedPageComponent",{get:function(){var e=this;return this.pageComponents.find((function(t){return t.id===e.selectedPageComponentId}))},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"selectedComponent",{get:function(){var e,t=this;return null===(e=this.theme)||void 0===e?void 0:e.components.find((function(e){var i;return e.id===(null===(i=t.selectedPageComponent)||void 0===i?void 0:i.componentId)}))},enumerable:!1,configurable:!0}),j.prototype.createLoadingListener=function(){var e=this;a((function(){return e.isLoading}),(function(){e.onLoadingChange()}))},j.prototype.getVariantIdFromParams=function(o,n){var a,s;return e(this,void 0,void 0,(function(){var e,r,d,p,c,l,m;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=new URLSearchParams("?"+n),[4,O.searchProducts({input:{productIdList:[o],priceListId:i.getPriceListId(),salesChannelId:i.getSalesChannelId()}})];case 1:return(r=t.sent()).isSuccess&&!(null===(s=null===(a=null==r?void 0:r.data)||void 0===a?void 0:a.data)||void 0===s?void 0:s.length)?[2]:(d=r.data.data[0],p=d.variantTypes.map((function(e){return e.variantType.slug})),c=[],p.forEach((function(t,i){var o=d.variantTypes[i],n=e.get(t);if(n){var a=o.variantType.values.find((function(e){return e.slug===n}));a&&c.push(a)}})),(l=d.variants.find((function(e){return e.variantValues.every((function(e){return c.some((function(t){return t.id===e.id}))}))})))?[2,l.id]:[3,3]);case 2:return m=t.sent(),console.error(m),[3,3];case 3:return[2]}}))}))},j.prototype.setCurrentPageType=function(){this.page&&(f.getInstance().currentPageType=this.page.type)},j}();!function(e){e.FRAME_DID_LOAD="FRAME_DID_LOAD",e.UPDATE_FRAME_DATA="UPDATE_FRAME_DATA",e.UPDATE_THEME_JSON="UPDATE_THEME_JSON",e.UPDATE_PROP_VALUE="UPDATE_PROP_VALUE",e.UPDATE_PAGE_PARAMS="UPDATE_PAGE_PARAMS",e.UPDATE_PAGE_COMPONENT_ORDER="UPDATE_PAGE_COMPONENT_ORDER",e.ADD_COMPONENT="ADD_COMPONENT",e.DELETE_COMPONENT="DELETE_COMPONENT",e.UPDATE_COMPONENT="UPDATE_COMPONENT",e.ADD_PAGE_COMPONENT="ADD_PAGE_COMPONENT",e.DELETE_PAGE_COMPONENT="DELETE_PAGE_COMPONENT",e.COMPONENT_MOUSE_OVER="COMPONENT_MOUSE_OVER",e.COMPONENT_MOUSE_LEAVE="COMPONENT_MOUSE_LEAVE",e.COMPONENT_CLICK="COMPONENT_CLICK",e.SET_SELECTED_COMPONENT="SET_SELECTED_COMPONENT",e.SET_HOVERED_COMPONENT="SET_HOVERED_COMPONENT",e.SCROLL_TO_COMPONENT="SCROLL_TO_COMPONENT",e.UPDATE_THEME_SETTINGS="UPDATE_THEME_SETTINGS",e.EDITOR_PAGE_CHANGE="EDITOR_PAGE_CHANGE",e.EDITOR_LOADING_CHANGE="EDITOR_LOADING_CHANGE",e.EDITOR_RELOAD="EDITOR_RELOAD"}(_||(_={}));export{_ as BridgeMessageType,j as default};
@@ -1 +1 @@
1
- import{__extends as e,__assign as t}from'./../../../ext/tslib/tslib.es6.js';import{IkasCart as r}from"../cart/index.js";import{IkasCheckoutFunctions as i,IkasOrderFunctions as a}from"@ikas/storefront-model-functions";import{formatCurrency as n}from"../../../utils/currency.js";import{makeObservable as o,observable as l,computed as s}from"mobx";import{formatDate as d}from"../../../utils/helper.js";import c from"../order/address/ikas-localized-order-address.js";var u=function(r){function u(e,i){var a=r.call(this,e,!0)||this;return a.appliedCouponCode=null,a.selectedPaymentGateway=null,a.masterPassPaymentGateway=null,a.billingAddress=null,a.shippingAddress=null,a.appliedCouponCode=e.couponCode,a.selectedPaymentGateway=e.selectedPaymentGateway,a.masterPassPaymentGateway=e.masterPassPaymentGateway,a.billingAddress=e.billingAddress?new c(t({countrySettings:i},e.billingAddress)):null,a.shippingAddress=e.shippingAddress?new c(t({countrySettings:i},e.shippingAddress)):null,o(a,{appliedCouponCode:l,selectedPaymentGateway:l,masterPassPaymentGateway:l,billingAddress:l,shippingAddress:l,isComplete:s,$totalFinalPrice:s,$totalFinalPriceTaxModifier:s,$totalTax:s,$formattedTotalTax:s,$formattedTotalFinalPrice:s}),a}return e(u,r),Object.defineProperty(u.prototype,"isComplete",{get:function(){return i.isComplete(this)},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"$totalFinalPrice",{get:function(){return this.selectedPaymentGateway?i.getTotalFinalPrice(this,this.selectedPaymentGateway):this.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"$totalFinalPriceTaxModifier",{get:function(){return this.$totalFinalPrice/this.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"$totalTax",{get:function(){return a.getTotalTax(this)*this.$totalFinalPriceTaxModifier},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"$formattedTotalTax",{get:function(){return n(this.$totalTax,this.currencyCode,this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"$formattedTotalFinalPrice",{get:function(){return n(this.$totalFinalPrice,this.currencyCode,this.currencySymbol)},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"dateStr",{get:function(){var e=new Date;return e.setTime(this.updatedAt),d(e)},enumerable:!1,configurable:!0}),u}(r);export{u as IkasCheckout};
1
+ import{__extends as e,__assign as t}from'./../../../ext/tslib/tslib.es6.js';import{IkasCart as r}from"../cart/index.js";import{IkasCheckoutFunctions as i,IkasOrderFunctions as a}from"@ikas/storefront-model-functions";import{formatCurrency as o}from"../../../utils/currency.js";import{makeObservable as n,observable as l,computed as s}from"mobx";import{formatDate as d}from"../../../utils/helper.js";import c from"../order/address/ikas-localized-order-address.js";var u=function(r){function u(e,i){var a=r.call(this,e,!0)||this;return a.appliedCouponCode=null,a.selectedPaymentGateway=null,a.masterPassPaymentGateway=null,a.billingAddress=null,a.shippingAddress=null,a.appliedCouponCode=e.couponCode,a.selectedPaymentGateway=e.selectedPaymentGateway,a.masterPassPaymentGateway=e.masterPassPaymentGateway,a.billingAddress=e.billingAddress?new c(t({countrySettings:i},e.billingAddress)):null,a.shippingAddress=e.shippingAddress?new c(t({countrySettings:i},e.shippingAddress)):null,n(a,{appliedCouponCode:l,selectedPaymentGateway:l,masterPassPaymentGateway:l,billingAddress:l,shippingAddress:l,isComplete:s,$totalFinalPrice:s,$totalFinalPriceTaxModifier:s,$totalTax:s,$formattedTotalTax:s,$formattedTotalFinalPrice:s}),a}return e(u,r),Object.defineProperty(u.prototype,"isComplete",{get:function(){return i.isComplete(this)},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"$totalFinalPrice",{get:function(){return this.selectedPaymentGateway?i.getTotalFinalPrice(this,this.selectedPaymentGateway):this.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"$totalFinalPriceTaxModifier",{get:function(){return this.$totalFinalPrice/this.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"$totalTax",{get:function(){return a.getTotalTax(this)*this.$totalFinalPriceTaxModifier},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"$formattedTotalTax",{get:function(){return o(this.$totalTax,this.currencyCode,this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"$formattedTotalFinalPrice",{get:function(){return o(this.$totalFinalPrice,this.currencyCode,this.currencySymbol)},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"dateStr",{get:function(){var e=new Date;return e.setTime(this.orderedAt||this.updatedAt),d(e)},enumerable:!1,configurable:!0}),u}(r);export{u as IkasCheckout};
@@ -1,10 +1,12 @@
1
1
  import { IkasProductGroup as IProductGroup } from "@ikas/storefront-models";
2
+ import { IkasProductGroupOrder } from "./order";
2
3
  import { IkasProductGroupTranslation } from "./translation";
3
4
  import { IkasProductGroupValue } from "./value";
4
5
  export declare class IkasProductGroup implements IProductGroup {
5
6
  groupKey: string;
6
7
  id: string;
7
8
  name: string;
9
+ order?: IkasProductGroupOrder | null;
8
10
  translations?: IkasProductGroupTranslation[] | null;
9
11
  values: IkasProductGroupValue[];
10
12
  constructor(data: IProductGroup);
@@ -1 +1 @@
1
- import{IkasProductGroupTranslation as n}from"./translation/index.js";import{IkasProductGroupValue as i}from"./value/index.js";var t=function(t){var r;this.groupKey=t.groupKey,this.id=t.id,this.name=t.name,this.translations=(null===(r=t.translations)||void 0===r?void 0:r.map((function(i){return new n(i)})))||null,this.values=t.values.map((function(n){return new i(n)}))};export{t as IkasProductGroup};
1
+ import{IkasProductGroupOrder as r}from"./order/index.js";import{IkasProductGroupTranslation as n}from"./translation/index.js";import{IkasProductGroupValue as i}from"./value/index.js";var o=function(o){var t;this.groupKey=o.groupKey,this.id=o.id,this.name=o.name,this.order=o.order?new r(o.order):null,this.translations=(null===(t=o.translations)||void 0===t?void 0:t.map((function(r){return new n(r)})))||null,this.values=o.values.map((function(r){return new i(r)}))};export{o as IkasProductGroup};
@@ -0,0 +1,6 @@
1
+ import { IkasProductGroupOrder as IProductGroupOrder } from "@ikas/storefront-models";
2
+ export declare class IkasProductGroupOrder implements IProductGroupOrder {
3
+ orderAttributeId: string;
4
+ value: string;
5
+ constructor(data: IProductGroupOrder);
6
+ }
@@ -0,0 +1 @@
1
+ var t=function(t){this.orderAttributeId=t.orderAttributeId,this.value=t.value};export{t as IkasProductGroupOrder};