const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/getBestPrice-BCuLTYaE.js","assets/bestPriceFragment-C1AoXVUX.js"])))=>i.map(i=>d[i]); import{i as w,B as Q,aI as I,k as j,m as R,_ as V,J as A,r as d,o as i,a as c,w as p,b as n,l as b,q as r,u as _,v as a,F as f,p as l,n as P,Z as E,aB as D}from"./main-DHoZdmBw.js";import{A as F}from"./AvailabilityStatus-CtiMbHse.js";import{B as U}from"./BasePriceFi-CzwlUspB.js";import{E as H}from"./ErrorMessage-CQomG8MU.js";import{P as N}from"./PriceSavingsFi-CSqgoGfk.js";import{P as G}from"./ProductPartialsFi-qeoeNaKw.js";import{Q as J}from"./QuantityModificationHintFi-BBSdjnBX.js";import{A as Z}from"./AddToMemoListDialogFi-BcZWYsaK.js";import{P as z,Q as W}from"./QuantitySteps-C4blGfD3.js";import{_ as X}from"./sellingUnitMixin-BqI7WVPQ.js";import{_ as Y}from"./shoppingcartMixin-DGdiTU0m.js";import{_ as K}from"./userMixin-DTZNvHsb.js";const $=e=>{var s;return(s=e==null?void 0:e.surcharges)==null?void 0:s.find(u=>(u==null?void 0:u.code)==="ZECO")},B=()=>A(()=>import("./getBestPrice-BCuLTYaE.js"),__vite__mapDeps([0,1])),ee={name:"BuyBoxModule",components:{AddToMemoListDialogFi:Z,AvailabilityStatus:F,ComponentWrapper:w,ErrorMessage:H,LoadingIndicator:Q,PriceRowsSavingsFi:z,ProductPartialsFi:G,QuantityModificationHintFi:J,QuantitySteps:W,SnackbarFi:I,BasePriceFi:U,PriceSavingsFi:N},mixins:[j,Y,X,K],emits:["added-to-memolist"],data(){return{quantity:0,initialQuantity:null,initialPrice:null,shippingDialog:!1,haveErrors:!1,addToCartLoading:!1,getBestPrice:null,haveBestPrice:!0,quantityModificationHint:"",quantityDataTest2:null,current:!0,GETBESTPRICE:null,isMounted:!1}},computed:{...R({productDetailHeadMounted:"layout/getProductDetailHeadMounted"}),priceSavingsClass(){return{"buy-box-module__buy-box__price-saving":!0,"buy-box-module__buy-box__price-saving--outdated":!this.current}},bestpriceVariables(){return{baseSiteId:this.$fischer.baseSiteId(),accessToken:this.accessToken,productCode:this.productCode,qty:this.quantity!==this.initialQuantity?this.quantity:0,language:this.$fischer.siteLanguage(),expired:!0,userId:this.$fischer.user.id()}},ecoContributionFormatted(){var u,y,o;if(!this.$fischer.shop.useEco())return null;const e=(o=(y=(u=$(this.getBestPrice))==null?void 0:u.price)==null?void 0:y.basePrices)==null?void 0:o[0];if(!e)return null;const s=this.$dict.get("online-Shop.Product.Product-Eco",[e.qty,e.unit,e.valueFormatted]);return this.getSellingUnitInString(s)},stockLevels(){var e;return((e=this.resultObject)==null?void 0:e.stockLevels)||null},showBuyBox(){return(this.$fischer.shop.isClosedShop()||this.$fischer.shop.isOnlineShop())&&this.accessToken&&this.productCode},accessToken(){return this.$fischer.user.accessToken()},isLoading(){var e;return(e=this.$apolloData)==null?void 0:e.loading},productCode(){return this.$fischer.query("article")?this.$fischer.query("article"):this.$fischer.catalogId("040390")},resultObject(){return this.getBestPrice},resultPriceRowsSavings(){if(this.resultObject){let e=0;const s=JSON.parse(JSON.stringify([{...this.initialPrice,minQty:this.resultObject.initialQuantity,priceQty:this.resultObject.initialQuantity,savingsInformation:null},...this.resultObject.priceRowsIncludingSavings||[]]));return s.forEach((u,y)=>{u.active=!1,u.minQty<=this.quantity&&(e=y)}),s[e].active=!0,s}return null},isAvailable(){var e;return((e=this.resultObject)==null?void 0:e.deliverySpeed)&&this.resultObject.deliverySpeed!=="NODELIVERY"},isExpired(){var e;return((e=this.resultObject)==null?void 0:e.articleStatus)&&this.resultObject.articleStatus==="EXPIRED"}},watch:{getBestPrice(e){this.initialQuantity||this.initialPrice||this.canOrderItem(e)&&(this.initialQuantity=e.initialQuantity,this.initialPrice=e.price,this.quantity=this.initialQuantity)}},async mounted(){this.GETBESTPRICE=(await B()).default,this.isMounted=!0},apollo:{getBestPrice:{query(){return this.GETBESTPRICE},errorPolicy:"all",variables(){return this.bestpriceVariables},skip(){var e;return!this.GETBESTPRICE||!this.productCode||this.initialQuantity===this.quantity&&((e=this.getBestPrice)==null?void 0:e.requestedQuantity)===0},async error(e){await this.logoutIfTokenInvalid(e),this.haveBestPrice=!1,this.enterErrorState("error getting best price",e)},result({data:e}){var s;this.getBestPrice=e==null?void 0:e.getBestPrice,(s=this.getBestPrice)!=null&&s.price||(this.haveBestPrice=!1)}}},methods:{onValueRounded(e,s){this.quantityModificationHint=e,this.quantityDataTest2=s},onBlur(e,s){var y,o,t,h,g,m,v,x;const u=s==null?void 0:s.explicitOriginalTarget;u&&((u===((y=this.$refs.addProductDesktop)==null?void 0:y.$el)||u.parentNode===((o=this.$refs.addProductDesktop)==null?void 0:o.$el)||u===((t=this.$refs.addProductMobile)==null?void 0:t.$el)||u.parentNode===((h=this.$refs.addProductMobile)==null?void 0:h.$el))&&this.addProduct(),(u===((g=this.$refs.addMemoListDesktop)==null?void 0:g.$el)||u.parentNode===((m=this.$refs.addMemoListDesktop)==null?void 0:m.$el)||u===((v=this.$refs.addMemoListMobile)==null?void 0:v.$el)||u.parentNode===((x=this.$refs.addMemoListMobile)==null?void 0:x.$el))&&this.addToMemoList())},addToMemoList(){this.quantityModificationHint="",this.$refs.addToMemoListDialog.show()},canOrderItem(e){var s;return((s=e==null?void 0:e.quantityStepRanges)==null?void 0:s.length)&&e.quantityStepRanges[0].rangeValue},updateQuantity(e){this.quantity=parseInt(e,10),this.quantityModificationHint="",this.current=!0},async backgroundUpdateQuantity(e){var y,o,t;if(!e){this.current=!1;return}const s=Number.parseInt(e);if(this.lastInputValue===s||this.quantity===s)return;this.lastInputValue=s;const u=(y=this.getBestPrice)==null?void 0:y.initialQuantity;if(!(!u||s<u))try{const h=(await B()).default;((t=(o=(await this.$apollo.query({query:h,errorPolicy:"all",variables:{...this.bestpriceVariables,qty:s}})).data)==null?void 0:o.getBestPrice)==null?void 0:t.requestedQuantity)===this.lastInputValue&&this.updateQuantity(s)}catch{}},enterErrorState(...e){this.haveErrors=!0,console.error(...e)},addProduct(){this.addToCartLoading||(this.addToCartLoading=!0,this.quantity!==Number(this.$refs.quantitySteps.getRawValue(this.$refs.quantitySteps.quantityInputValue))&&this.$refs.quantitySteps.triggerInput(),this.addProductToCart({productID:this.productCode,productRequestedQuantity:this.quantity,productInitialQuantity:this.resultObject.initialQuantity}).then(e=>{e!=null&&e.success&&(this.addToCartLoading=!1)}))},scrollToSavings(){const e=document.querySelectorAll(".sticky-actions-intersector");e&&this.$smoothScroll({scrollTo:e.length>1?e[1]:e[0],duration:500,updateHistory:!1,offset:-120})}}},te={key:0,class:"buy-box-module__snackbar"},ie={key:2,class:"buy-box-module__buy-box","data-test":"buy-box"},se={key:0,class:"buy-box-module__buy-box--mobile"},oe={class:"buy-box-module__buy-box__col"},ae={key:0,class:"fi-flex fi-flex-col"},re={class:"buy-box-module__eco"},ue={key:2,class:"buy-box-module__buy-box__quantity-steps"},le={class:"buy-box-module__buy-box__quantity-per-package"},ne={class:"buy-box-module__buy-box__info"},de={class:"buy-box-module__buy-box__info__text"},ce={class:"buy-box-module__buy-box__vat"},be={class:"buy-box-module__buy-box__basic-prices"},_e={class:"buy-box-module__buy-box__basic-price"},ye={key:0,class:"buy-box-module__eco"},he={key:1,class:"buy-box-module__expired-info"},me={"data-test":"buy-box-expired",class:"buy-box-module__expired-info__text"},pe={key:1,class:"buy-box-module__buy-box--desktop"},fe={class:"buy-box-module__buy-box__left"},ge={key:0,class:"buy-box-module__eco"},ve={class:"buy-box-module__buy-box__info"},xe={class:"buy-box-module__buy-box__info__text"},ke={class:"buy-box-module__buy-box__vat"},Se={class:"buy-box-module__buy-box__basic-prices"},Pe={class:"buy-box-module__buy-box__basic-prices__label"},qe={class:"buy-box-module__buy-box__basic-price"},Ce={key:0,class:"buy-box-module__eco"},Ee={key:2,class:"buy-box-module__expired-info"},Be={"data-test":"buy-box-expired",class:"buy-box-module__expired-info__text"},Te={key:0,class:"buy-box-module__buy-box__right"},Me={key:1,class:"buy-box-module__buy-box__quantity-per-package"},Oe={key:3,class:"buy-box-module__buy-box buy-box-module__buy-box__expired"},Le={class:"buy-box-module__buy-box__expired__text","data-test":"buy-box-expired"},we={class:"price-rows-savings--mobile"};function Qe(e,s,u,y,o,t){const h=d("snackbar-fi"),g=d("error-message"),m=d("price-savings-fi"),v=d("quantity-steps"),x=d("product-partials-fi"),k=d("availability-status"),q=d("base-price-fi"),C=d("quantity-modification-hint-fi"),S=d("button-fi"),T=d("loading-indicator"),M=d("price-rows-savings-fi"),O=d("add-to-memo-list-dialog-fi"),L=d("component-wrapper");return t.showBuyBox?(i(),c(L,{key:0,class:P({"buy-box-module":!0,"buy-box-module--unavailable":!t.isAvailable,"buy-box-module--expired":t.isExpired})},{default:p(()=>[e.isAppView?(i(),n("div",te,[b(h,{"top-position":""})])):r("",!0),o.haveErrors?(i(),c(g,{key:1,"trigger-on-creation":"",class:"buy-box-module__error"},{default:p(()=>[_(a(e.$dict.get("online-Shop.Checkout.Errors.Title")),1)]),_:1})):r("",!0),t.resultObject?(i(),n("div",ie,[e.isSM?(i(),n("div",pe,[l("div",fe,[t.isLoading&&!o.haveErrors||o.addToCartLoading?(i(),c(T,{key:0,variant:"spinnerLocal",spinoff:"buy-box-module__buy-box--left",dark:""})):r("",!0),t.isExpired?(i(),n("div",Ee,[l("span",Be,a(e.$dict.get("online-Shop.Product.Expired")),1)])):(i(),n(f,{key:1},[t.ecoContributionFormatted?(i(),n("div",ge,[l("span",null,a(e.$dict.get("checkout.Cart.Sum")),1)])):r("",!0),b(m,{class:P(t.priceSavingsClass),"best-price":o.getBestPrice},null,8,["class","best-price"]),l("div",ve,[b(k,{class:"buy-box-module__buy-box__availability","delivery-speed":t.resultObject.deliverySpeed,"stock-levels":t.stockLevels,"disable-tooltip":!0,theme:"buy-box"},null,8,["delivery-speed","stock-levels"]),l("div",xe,[l("div",ke,[t.resultObject.taxRate!==0?(i(),n(f,{key:0},[_(a(e.$dict.get("online-Shop.Product.Vat-excluded"))+", ",1)],64)):r("",!0),_(" "+a(e.$dict.get("online-Shop.Product.Plus-Shipping")),1)]),l("div",Se,[l("div",Pe,a(e.$dict.get("online-Shop.Product.Base-Price"))+": ",1),l("div",qe,[b(q,{"best-price":t.resultObject},null,8,["best-price"])]),t.ecoContributionFormatted?(i(),n("div",Ce,[l("span",null,a(t.ecoContributionFormatted),1)])):r("",!0)])])]),b(k,{class:"buy-box-module__buy-box__availability","delivery-speed":t.resultObject.deliverySpeed,"stock-levels":t.stockLevels,"disable-tooltip":!0,theme:"buy-box"},null,8,["delivery-speed","stock-levels"])],64))]),t.isExpired?r("",!0):(i(),n("div",Te,[t.resultObject.price&&t.isAvailable?(i(),c(v,{key:0,ref:"quantitySteps",class:"theme--blocked",template:"article","requested-quantity":o.quantity,item:t.resultObject,"price-rows-savings":t.resultPriceRowsSavings.length>1?t.resultPriceRowsSavings:null,light:"",large:"",onBlur:t.onBlur,onUpdateQuantity:t.updateQuantity,onUserInput:t.backgroundUpdateQuantity,onScrollToElement:t.scrollToSavings,onValueRounded:t.onValueRounded},null,8,["requested-quantity","item","price-rows-savings","onBlur","onUpdateQuantity","onUserInput","onScrollToElement","onValueRounded"])):r("",!0),t.isAvailable?(i(),n("div",Me,[_(a(e.$dict.get("online-Shop.Product.Graduated-Prices.Quantity-Headline"))+" ",1),t.resultObject?(i(),n(f,{key:0},[_(" ( "+a(t.resultObject.initialQuantity)+" "+a(e.getSellingUnit(t.resultObject.price.unit))+" / "+a(e.$dict.get("online-Shop.Product.Pack"))+" ) ",1)],64)):r("",!0)])):r("",!0),t.isAvailable?(i(),c(x,{key:2,class:"buy-box-module__allow-partials","best-price":t.resultObject},null,8,["best-price"])):r("",!0),b(C,{class:"buy-box-module__quantity-modification-hint",hint:o.quantityModificationHint,"data-test-2":o.quantityDataTest2,icon:"info"},null,8,["hint","data-test-2"]),t.isAvailable?(i(),c(S,{key:3,ref:"addProductDesktop",type:"button",class:"buy-box-module__buy-box__add-to-cart button-fi__primary buy-box-module__action-button button__add-to-cart button-fi--large","data-test":"add-to-cart","data-test-2":t.isLoading||o.addToCartLoading?"add-to-cart-disabled":null,disabled:!!(t.isLoading||o.addToCartLoading),onClick:E(t.addProduct,["prevent"])},{default:p(()=>[_(a(e.$dict.get("online-Shop.Product.Add-to-Cart")),1)]),_:1},8,["data-test-2","disabled","onClick"])):r("",!0),e.useMemoList&&!e.isAppView&&t.isAvailable?(i(),c(S,{key:4,ref:"addMemoListDesktop",type:"button",class:"button-fi__tertiary buy-box-module__action-button button__add-to-memolist button-fi--large","data-test":"add-to-wish-list",onClick:t.addToMemoList},{default:p(()=>[_(a(e.$dict.get("online-Shop.Product.Add-to-Memo-List")),1)]),_:1},8,["onClick"])):r("",!0)]))])):(i(),n("div",se,[t.isExpired?(i(),n("div",he,[l("span",me,a(e.$dict.get("online-Shop.Product.Expired")),1)])):(i(),n(f,{key:0},[l("div",oe,[t.ecoContributionFormatted?(i(),n("div",ae,[l("div",re,a(e.$dict.get("checkout.Cart.Sum")),1),b(m,{class:P(t.priceSavingsClass),"best-price":o.getBestPrice,"is-mobile":""},null,8,["class","best-price"])])):(i(),c(m,{key:1,class:P(t.priceSavingsClass),"best-price":o.getBestPrice,"is-mobile":""},null,8,["class","best-price"])),t.isAvailable?(i(),n("div",ue,[t.resultObject.price?(i(),c(v,{key:0,ref:"quantitySteps",class:"theme--blocked",template:"article","requested-quantity":o.quantity,item:t.resultObject,"price-rows-savings":t.resultPriceRowsSavings.length>1?t.resultPriceRowsSavings:null,small:"",light:"",onBlur:t.onBlur,onUpdateQuantity:t.updateQuantity,onUserInput:t.backgroundUpdateQuantity,onScrollToElement:t.scrollToSavings,onValueRounded:t.onValueRounded},null,8,["requested-quantity","item","price-rows-savings","onBlur","onUpdateQuantity","onUserInput","onScrollToElement","onValueRounded"])):r("",!0),l("div",le,[_(a(e.$dict.get("online-Shop.Product.Graduated-Prices.Quantity-Headline"))+" ",1),t.resultObject?(i(),n(f,{key:0},[_(" ( "+a(t.resultObject.initialQuantity)+" "+a(e.getSellingUnit(t.resultObject.price.unit))+" / "+a(e.$dict.get("online-Shop.Product.Pack"))+" ) ",1)],64)):r("",!0)]),b(x,{class:"buy-box-module__allow-partials","best-price":t.resultObject},null,8,["best-price"])])):r("",!0)]),l("div",ne,[b(k,{class:"buy-box-module__buy-box__availability","delivery-speed":t.resultObject.deliverySpeed,"stock-levels":t.stockLevels,"disable-tooltip":!0,theme:"buy-box"},null,8,["delivery-speed","stock-levels"]),l("div",de,[l("div",ce,[t.resultObject.taxRate!==0?(i(),n(f,{key:0},[_(a(e.$dict.get("online-Shop.Product.Vat-excluded"))+", ",1)],64)):r("",!0),_(" "+a(e.$dict.get("online-Shop.Product.Plus-Shipping"))+" "+a(e.$dict.get("online-Shop.Product.Base-Price"))+": ",1)]),l("div",be,[l("div",_e,[b(q,{"best-price":t.resultObject,small:""},null,8,["best-price"])])]),t.ecoContributionFormatted?(i(),n("div",ye,a(t.ecoContributionFormatted),1)):r("",!0)])]),b(k,{class:"buy-box-module__buy-box__availability","delivery-speed":t.resultObject.deliverySpeed,"stock-levels":t.stockLevels,"disable-tooltip":!0,theme:"buy-box"},null,8,["delivery-speed","stock-levels"])],64)),b(C,{class:"buy-box-module__quantity-modification-hint",hint:o.quantityModificationHint,"data-test-2":o.quantityDataTest2,icon:"info"},null,8,["hint","data-test-2"]),t.isAvailable?(i(),c(S,{key:2,ref:"addProductMobile",type:"button",class:"button-fi__primary buy-box-module__action-button button__add-to-cart","data-test":"add-to-cart",disabled:t.isLoading||o.addToCartLoading,onClick:E(t.addProduct,["prevent"])},{default:p(()=>[_(a(e.$dict.get("online-Shop.Product.Add-to-Cart")),1)]),_:1},8,["disabled","onClick"])):r("",!0),e.useMemoList&&!t.isExpired&&!e.isAppView&&t.isAvailable?(i(),c(S,{key:3,ref:"addMemoListMobile",type:"button",class:"button-fi__tertiary buy-box-module__action-button button__add-to-memolist","data-test":"add-to-wish-list",onClick:t.addToMemoList},{default:p(()=>[_(a(e.$dict.get("online-Shop.Product.Add-to-Memo-List")),1)]),_:1},8,["onClick"])):r("",!0)]))])):r("",!0),o.haveBestPrice?r("",!0):(i(),n("div",Oe,[l("span",Le,a(e.$dict.get("online-Shop.Product.Expired")),1)])),o.isMounted&&e.productDetailHeadMounted&&t.resultPriceRowsSavings&&t.resultPriceRowsSavings.length>1&&!t.isExpired&&!e.isMD?(i(),c(D,{key:4,to:"#price-row-savings"},[l("div",we,[b(M,{ref:"savings",mobile:"",savings:t.resultPriceRowsSavings},null,8,["savings"])])])):r("",!0),e.isAppView?r("",!0):(i(),c(O,{key:5,ref:"addToMemoListDialog",product:t.productCode,quantity:o.quantity,multiple:"",onErrorOccured:t.enterErrorState,onAddedToMemolist:s[0]||(s[0]=Ie=>e.$emit("added-to-memolist"))},null,8,["product","quantity","onErrorOccured"]))]),_:1},8,["class"])):r("",!0)}const ze=V(ee,[["render",Qe],["__scopeId","data-v-6d46ca17"]]);export{ze as B};