import{q as N,w as q,o as R,X as A,a as v,y as c,P as L,R as Y,a5 as G,A as b,H as s,i as _,a6 as T,D as n,L as P,z as l,C as w,S as h,J as U,K as J,Q as E,I as f,U as K}from"./EchoChannel-Bg1-kez_.js";import{c as O}from"./Cross-ShJx5ME4.js";import Q from"./FilterValues-uNqSL8B0.js";import{o as a,d as X,r as g,i as Z,a as ee,b as y,c as te}from"./search-VYKRAp0q.js";import{_ as se}from"./FormSwitch.vue_vue_type_script_setup_true_lang-BrO_vy9n.js";import re from"./SpinnerLoader-WkHXMWXk.js";import{_ as le}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./Search-CK7cDv2i.js";import"./FilterValue.vue_vue_type_script_setup_true_lang-CylUfQaY.js";import"./Tick-DwQKjUFm.js";const oe={class:"pl-8 pr-4 py-6"},ne={class:"px-4 flex justify-between items-center font-semibold text-2xl sm:text-4xl"},ae=["innerHTML"],ie={class:"px-4"},de={class:"px-4 mt-8"},ue={class:"bg-white z-10 md:rounded-bl-lg w-full px-8 py-4 flex justify-between shadow-[0px_-3px_8px_-2px_rgba(0,_0,_0,_0.25)]"},ce=["disabled"],pe=["disabled"],fe={class:"flex gap-2"},me={key:0},ve=N({__name:"FilterWindow",props:{displayedFilters:{},loading:{type:Boolean}},setup(B){const V=B,S=_("throttle"),$=_("debounce"),j=_("searchForFacetValues");q(a,e=>{e&&window.history.pushState({popupIsOpen:!0},"")}),R(()=>{window.addEventListener("popstate",x),V.displayedFilters.forEach(e=>{e!=null&&e.fetchFromAlgolia&&z(e.key)})}),A(()=>{window.removeEventListener("popstate",x)});const x=e=>(a.value&&d(),e),z=async e=>{X.value[e]=await j("posts_sorted_date_desc",e)},k=v(null),H=e=>{e.classList.add("backdrop-brightness-90"),e.classList.add("backdrop-blur")},I=e=>{e.classList.remove("backdrop-brightness-90"),e.classList.remove("backdrop-blur")};q(k,(e,t)=>{e&&H(e.parentElement),!e&&t&&I(t.parentElement)});const o=v(!1),d=()=>(o.value=!1,a.value=null);let u=0;const i=v(null),M=e=>{u=e.touches[0].clientY},F=S(e=>{if(!u||!i.value)return null;const t=e.touches[0].clientY;if(t-u>0){const p=Math.round(t/10)*10;if(i.value.style.transform=`translateY(${p}px)`,p>window.innerHeight/4)return o.value=!1,d(),u=null}else return o.value=!0,i.value.style.transform="translateY(0px)",u=null},25e-6),C=$(e=>{if(!a.value)return null;e.target.scrollTop!==0?(o.value=!0,i.value.style.transform="translateY(0px)"):(o.value=!1,i.value.style.transform="translateY(5rem)")},25),D=()=>{te()},W=()=>d();return(e,t)=>{const m=T("scroll-lock"),p=T("click-outside");return n(),c("section",{class:b(["fixed inset-0 z-40 md:backdrop-blur-none",{"pointer-events-none":!s(a)}])},[L(G,{name:"slide"},{default:Y(()=>[s(a)?P((n(),c("div",{key:0,ref_key:"aboveCurtain",ref:k,class:"pointer-events-auto bg-transparent fixed inset-x-0 inset-y-0 md:inset-x-auto md:right-0 md:min-w-[32rem] md:w-1/4 flex flex-col justify-between"},[l("div",{ref_key:"scrollableFilters",ref:i,id:"scrollable__filters",class:b(["relative transition-all bg-white pb-6 w-full h-[calc(100%+152px)] translate-y-20 md:!translate-y-0 overflow-y-scroll md:!rounded-tl",{"rounded-t":!o.value}]),onScroll:t[3]||(t[3]=w((...r)=>s(C)&&s(C)(...r),["prevent"]))},[l("div",{class:b(["sticky top-0 left-0 bg-white w-full z-10",{"shadow-[0px_3px_8px_-2px_rgba(0,_0,_0,_0.25)]":o.value}]),onTouchstart:M,onTouchmove:t[1]||(t[1]=w((...r)=>s(F)&&s(F)(...r),["prevent"]))},[l("div",oe,[l("p",ne,[t[6]||(t[6]=h(" Filters ")),l("span",{innerHTML:s(O),onClick:t[0]||(t[0]=w(r=>d(),["prevent"])),class:"h-10 w-10 md:h-12 md:w-12 cursor-pointer hover:bg-qorus-purple/5 active:bg-qorus-purple/10 rounded-full p-2"},null,8,ae)])])],34),(n(!0),c(U,null,J(e.displayedFilters,r=>(n(),c("div",ie,[L(Q,{"displayed-filter":r,request:s(g)},null,8,["displayed-filter","request"])]))),256)),l("div",de,[s(Z)?(n(),E(se,{key:0,selected:s(g).winner,onChange:t[2]||(t[2]=r=>s(g).winner=r),errors:[]},{default:Y(()=>t[7]||(t[7]=[h(" Winners only ")])),_:1},8,["selected"])):f("",!0)])],34),l("div",ue,[l("button",{onClick:t[4]||(t[4]=r=>D()),disabled:s(ee)(),class:"w-2/5 mr-2 py-2 disabled:text-qorus-grey-mid enabled:hover:underline"}," Clear all ",8,ce),l("button",{onClick:t[5]||(t[5]=r=>W()),disabled:e.loading,class:"bg-qorus-purple disabled:bg-qorus-grey-mid disabled:cursor-not-allowed text-white w-3/5 hover:brightness-90 flex gap-2 justify-center items-center"},[l("span",fe,[t[8]||(t[8]=h("Apply ")),e.loading?(n(),E(re,{key:0})):f("",!0)]),!e.loading&&s(y)>0?(n(),c("span",me," ("+K(s(y)>100?"100+":s(y))+") ",1)):f("",!0)],8,pe)])])),[[m,s(a)],[p,()=>d()]]):f("",!0)]),_:1})],2)}}}),qe=le(ve,[["__scopeId","data-v-46f0a70b"]]);export{qe as default};