const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/getMultipleBestPrices-D92KLkiC.js","assets/bestPriceFragment-C1AoXVUX.js"])))=>i.map(i=>d[i]);
import{J as V,d as y,o as l,b as c,e as b,n as C,Z as P,p as F,u as v,v as u,l as g,K as S,I,F as m,_ as p,T as M,r as f,aJ as w,b4 as E,N as T,O as D,a as _,bg as A,af as O,bf as q,w as N,q as k}from"./main-BDtKGhFI.js";import{h as $}from"./index-BmigA8Zv.js";const B=()=>V(()=>import("./getMultipleBestPrices-D92KLkiC.js"),__vite__mapDeps([0,1])),ce={data(){return{bestPrices:{},loadingPrices:!1,pricesNotFound:!1,throttle:1e3}},computed:{productIds(){return console.error("implement productIds"),[]},requiresPrices(){return this.productIds.filter(e=>this.bestPrices[e]===void 0)}},watch:{requiresPrices(){this.updatePriceRequests()},loadingPrices(){this.updatePriceRequests()}},methods:{async updatePriceRequests(){if(!(this.loadingPrices||this.pricesNotFound||!(this.$fischer.shop.isOnlineShop()||this.$fischer.shop.isClosedShop())||this.requiresPrices.length===0))try{this.loadingPrices=!0;const e=this.requiresPrices.slice(0,20).map(s=>({productCode:s})),{data:t}=await this.$apollo.query({query:(await B()).default,variables:{baseSiteId:this.$fischer.baseSiteId(),language:this.$fischer.siteLanguage(),userId:this.$fischer.user.id(),accessToken:this.$fischer.user.accessToken(),queries:e}});if(!t.getMultipleBestPrices){console.error("Did not receive best prices"),this.pricesNotFound=!0;return}t.getMultipleBestPrices.forEach(s=>{s&&(this.bestPrices[s.productCode]=s)}),e.forEach(({productCode:s})=>{this.bestPrices[s]===void 0&&(this.bestPrices[s]=null)})}finally{await new Promise(e=>setTimeout(e,this.throttle)),this.throttle=Math.min(3e3,this.throttle+200),this.loadingPrices=!1}}}},oe={data(){return{useAutoFilters:!0}},computed:{autoFilters(){if(this.filters.length===0&&this.useAutoFilters){const e=this.$fischer.user.isDiy(),t=this.$fischer.user.isProfi();if(e&&!t)return[{associatedFieldName:"Profi / DIY_A",name:"DIY~~~!Profi",displayField:"Profi / DIY (DIY)",fakeValue:"DIY"}];if(!e&&t)return[{associatedFieldName:"Profi / DIY_A",name:"Profi~~~!DIY",displayField:"Profi / DIY (Profi)",fakeValue:"Profi"}]}return null}},methods:{applyChanges(...e){let t=this.useAutoFilters?(this.autoFilters||[]).map(s=>({...s,name:s.fakeValue||s.name})):this.filters;e.forEach(({element:s,value:r})=>{const n=t.length;t=t.filter(i=>i.associatedFieldName!==s.associatedFieldName),n!==t.length&&this.disableAutoFilters(),r&&(t.push(s),this.disableAutoFilters())}),this.useAutoFilters||(t.sort((s,r)=>s.associatedFieldName.localeCompare(r.associatedFieldName)),this.filters=t)},enableAutoFilters(){this.useAutoFilters=!0},disableAutoFilters(){this.useAutoFilters=!1}}},L=["aria-checked","onClickCapture"],Y=y({__name:"FactFinderFiteCheckboxFi",props:{facet:{}},emits:["change"],setup(e,{emit:t}){const s=t,r=n=>{n.disabled||s("change",{element:n,value:!n.selected})};return(n,i)=>(l(!0),c(m,null,b(n.facet.elements,(a,o)=>(l(),c("div",{key:o,role:"radio","aria-checked":a.selected,class:C({"fact-finder-fite-checkbox-fi":!0,"fact-finder-fite-checkbox-fi--disabled":a.disabled,"fact-finder-fite-checkbox-fi--selected":a.selected}),onClickCapture:P(h=>r(a),["stop"])},[F("label",{class:C(["fact-finder-fite-checkbox-fi__label",{"fact-finder-fite-checkbox-fi__label-selected":a.selected,"fact-finder-fite-checkbox-fi__label-disabled":a.disabled}])},[v(u(a.text)+" "+u(n.facet.unit)+" ",1),g(S(I),{icon:a.selected?"radio-btn-on":"radio-btn-off",class:C({"fact-finder-fite-checkbox-fi__checkbox":!0,"fact-finder-fite-checkbox-fi__checkbox--disabled":a.disabled})},null,8,["icon","class"])],2)],42,L))),128))}}),R=p(Y,[["__scopeId","data-v-1ad6804e"]]),j={name:"SliderElement",components:{TextInputFi:M,RangeSliderFi:$},props:{element:{type:Object,default:()=>({})},group:{type:Object,default:()=>({})}},emits:["change"],data(){return{lower:0,upper:0}},computed:{lowerAsString:{get(){return String(this.lower)},set(e){this.lower=Number(e)}},upperAsString:{get(){return String(this.upper)},set(e){this.upper=Number(e)}},disabled(){return this.element.disabled||this.minValue+1>=this.maxValue},minValue(){return Math.floor(Number(this.element.absoluteMinValue))},maxValue(){return Math.ceil(Number(this.element.absoluteMaxValue))},interval(){const{decimalPlaces:e}=this.group;return e?10**-e:1}},created(){this.lower=this.element.selectedMinValue===this.element.absoluteMinValue?this.minValue:Number(this.element.selectedMinValue),this.upper=this.element.selectedMaxValue===this.element.absoluteMaxValue?this.maxValue:Number(this.element.selectedMaxValue)},methods:{onDragEndSlider(e){if(!(e!=null&&e.length)){console.error("invalid newValue",e);return}[this.lower,this.upper]=e,this.$emit("change")},onChangeSlider(e){[this.lower,this.upper]=e},onInputLower(e){const t=Number(e);Number.isNaN(t)||!Number.isInteger(t)||t<this.minValue||t>this.maxValue||t>this.upper||(this.lower=t,this.$emit("change"))},onInputUpper(e){const t=Number(e);e===""||Number.isNaN(t)||!Number.isInteger(t)||t>this.maxValue||t<this.minValue||t<this.lower||(this.upper=t,this.$emit("change"))}}},U={class:"slider-element"},z={class:"slider-element__text-input"};function G(e,t,s,r,n,i){const a=f("range-slider-fi"),o=f("text-input-fi");return l(),c("div",U,[g(a,{class:"fi-px-6",min:i.minValue,max:i.maxValue,value:[n.lower,n.upper],disabled:i.disabled,interval:i.interval,onDragEnd:i.onDragEndSlider,onChange:i.onChangeSlider},null,8,["min","max","value","disabled","interval","onDragEnd","onChange"]),F("div",z,[g(o,{"model-value":i.lowerAsString,label:`[${s.group.unit}]`,disabled:i.disabled,min:i.minValue,max:i.maxValue,"data-test":"range-value-lower","show-localized-values":"",onChange:i.onInputLower},null,8,["model-value","label","disabled","min","max","onChange"]),t[0]||(t[0]=F("div",{class:"fi-px-12"},"-",-1)),g(o,{"model-value":i.upperAsString,label:`[${s.group.unit}]`,disabled:i.disabled,min:i.minValue,max:i.maxValue,"data-test":"range-value-upper","show-localized-values":"",onChange:i.onInputUpper},null,8,["model-value","label","disabled","min","max","onChange"])])])}const J=p(j,[["render",G],["__scopeId","data-v-ec2c707a"]]),X={name:"FactFinderSliderFacet",components:{SliderElement:J},directives:{clickOutside:w.directive},props:{group:{type:Object,default:()=>({})}},emits:["change"],data(){return{elements:[]}},created(){this.elements=this.group.elements},methods:{onClickOutside(){this.changeThrottle&&this.changeThrottle.cancel(),this.onApply()},onChange(){this.changeThrottle||(this.changeThrottle=E(400,async()=>{this.onApply()})),this.changeThrottle()},onApply(){const e=this.$refs.sliderElement.map(t=>{const{element:{name:s,absoluteMinValue:r,absoluteMaxValue:n,unit:i},lower:a,upper:o}=t,{associatedFieldName:h}=this.group,x=String(a),d=String(o);return Number(a)<=Number(r)&&Number(o)>=Number(n)?{value:!1,element:{name:s,associatedFieldName:h,selected:!1,absoluteMinValue:r,absoluteMaxValue:n,unit:i}}:{value:!0,element:{name:s,associatedFieldName:h,selected:!0,selectedMinValue:x,selectedMaxValue:d}}}).filter(t=>t!==null);e.length&&this.$emit("change",...e)}}},H={class:"fact-finder-slider-facet"};function K(e,t,s,r,n,i){const a=f("slider-element"),o=T("click-outside");return D((l(),c("div",H,[(l(!0),c(m,null,b(n.elements,h=>(l(),_(a,{key:h.name,ref_for:!0,ref:"sliderElement",element:h,group:s.group,onChange:i.onChange},null,8,["element","group","onChange"]))),128))])),[[o,i.onClickOutside]])}const Z=p(X,[["render",K],["__scopeId","data-v-82232e6c"]]),Q={name:"FactFinderTextFacet",components:{FacetListFi:A},props:{facet:{type:Object,default:()=>({})},unselectedFacet:{type:Object,default:null}},emits:["close","change"],computed:{elements(){const{elements:e}=this.unselectedFacet||this.facet;return e.map(t=>({name:t.text,key:`${t.text}${this.unselectedFacet?"_r":""}`,associatedFieldName:this.facet.associatedFieldName,selected:this.isChecked(t),count:t.totalHits,disabled:t.disabled}))}},methods:{close(){this.$refs.facet?this.$refs.facet.close():this.$emit("close")},clearSelection(){this.facet.elements.forEach(e=>{this.$emit("change",{value:!1,element:{...e,selected:!1}})}),this.close()},isChecked(e){if(e.selectedBool)return!0;if(this.unselectedFacet){const t=this.facet.elements.find(s=>s.text===e.text);return t==null?void 0:t.selectedBool}return!1},isEnabled(e){return this.unselectedFacet?this.facet.elements.some(t=>t.name===e.name):e.recordCount>0},change({value:e,element:t}){const s={name:this.facet.name,elements:[...this.facet.elements.filter(r=>r.selected&&r.name!==t.name)]};e&&s.elements.push({associatedFieldName:t.associatedFieldName,name:t.name,selected:!0}),this.$emit("change",{value:e,element:{associatedFieldName:t.associatedFieldName,name:t.name,selected:e}}),this.close()}}};function W(e,t,s,r,n,i){const a=f("facet-list-fi");return l(),_(a,{ref:"facet",name:s.facet.name,elements:i.elements,unit:s.facet.unit,class:"fact-finder-text-facet",onClose:t[0]||(t[0]=o=>e.$emit("close")),onChange:i.change,onClearSelection:i.clearSelection},null,8,["name","elements","unit","onChange","onClearSelection"])}const ee=p(Q,[["render",W],["__scopeId","data-v-4f36565d"]]),te={name:"FactFinderFacetFi",components:{FactFinderSliderFacet:Z,FactFinderTextFacet:ee,SelectFi:O,FactFinderFiteCheckboxFi:R},props:{facet:{type:Object,required:!0},open:{type:Boolean},idx:{type:Number,default:null},registerDomElement:{type:Function,default:null}},emits:["change","close","toggle-open"],data(){return{wrapperStyle:{},internalOpen:!1}},computed:{isSliderFacet(){const{facet:{type:e}}=this;return["FLOAT","INTEGER"].includes(e)},name(){return q(this.facet.name)}},watch:{idx(e){this.registerElement(e)}},mounted(){this.registerElement(this.idx)},methods:{registerElement(e){e===0&&this.registerDomElement&&this.registerDomElement(this.$el)},onClose(){this.$emit("close")},toggleOpen(){this.$emit("toggle-open")},onChange(...e){this.$emit("change",...e)}}},se={key:2},ie={key:1,class:"fact-finder-facet-fi"},ae={class:"fact-finder-facet-fi__label"};function ne(e,t,s,r,n,i){const a=f("fact-finder-text-facet"),o=f("fact-finder-slider-facet"),h=f("select-fi"),x=f("fact-finder-fite-checkbox-fi");return e.isFite?(l(),c("div",ie,[F("div",ae,u(i.name),1),g(x,{facet:s.facet,onChange:i.onChange},null,8,["facet","onChange"])])):(l(),_(h,{key:0,class:"fact-finder-facet-fi",open:s.open,name:i.name,disabled:s.facet.disabled,"mobile-inline":i.isSliderFacet,large:"",onToggleOpen:i.toggleOpen,onClose:t[0]||(t[0]=d=>e.$emit("close")),onChange:t[1]||(t[1]=(...d)=>e.$emit("change",...d))},{selectionMobile:N(()=>[s.facet.type==="TEXT"?(l(!0),c(m,{key:0},b(s.facet.elements,d=>(l(),c(m,null,[d.selected?(l(),c(m,{key:0},[v(u(d.text),1)],64)):k("",!0)],64))),256)):(l(!0),c(m,{key:1},b(s.facet.elements,d=>(l(),c(m,null,[d.selected?(l(),c("span",{key:d.name},u(d.selectedMinValue)+" "+u(s.facet.unit)+" - "+u(d.selectedMaxValue)+" "+u(s.facet.unit),1)):k("",!0)],64))),256))]),default:N(()=>[s.facet.type==="TEXT"?(l(),_(a,{key:0,facet:s.facet,onChange:i.onChange,onClose:i.onClose},null,8,["facet","onChange","onClose"])):i.isSliderFacet?(l(),_(o,{key:1,group:s.facet,onChange:i.onChange,onClose:i.onClose},null,8,["group","onChange","onClose"])):(l(),c("div",se,u(s.facet.name)+" "+u(s.facet.type),1))]),_:1},8,["open","name","disabled","mobile-inline","onToggleOpen"]))}const de=p(te,[["render",ne]]),ue=e=>e.selectedMaxValue?`${e.selectedMinValue}-${e.selectedMaxValue}`:e.name||e.text,he=e=>e.selectedMaxValue?{associatedFieldName:e.associatedFieldName,selectedMinValue:e.selectedMinValue,selectedMaxValue:e.selectedMaxValue}:{associatedFieldName:e.associatedFieldName,name:e.name};export{de as F,ce as _,oe as a,ue as s,he as t};