const gcfiltersortBtns=document.querySelectorAll(".gspb_filtersort_btn");gcfiltersortBtns.forEach(e=>{e.addEventListener("click",function(t){if(e.classList.contains("active"))t.target.closest(".gspb_filter_panel").querySelectorAll("ul.gspb_filter_ul span").forEach(e=>{e.classList.toggle("showfiltermobile")});else{let s=t.target;s.closest(".gspb_filtersort_btn")&&(s=s.closest(".gspb_filtersort_btn"));let a=s.dataset.containerid,r=document.getElementById(a),o=r.querySelector(".pagination");o&&(s.classList.contains("resort_0")?o.style.display="block":o.style.display="none"),parseInt(r.dataset.perpage);let i=s.dataset.sorttype,l=s.dataset.offset,n=r.parentElement.querySelector(".gspb_filter_panel"),c=n.querySelector(".gspb_tax_dropdown .gspb_choosed_tax"),p;null!==c&&""!=c.innerHTML&&(p=c.getAttribute("data-taxdata"));let d=r.dataset.filterargs,g=r.dataset.innerargs,f=r.dataset.template,u=r.getAttribute("id").replace(/-/g,"_"),b=void 0!==window[u]?window[u]:"",y=r.querySelector(".wp-block-post-template");s.closest("ul").classList.add("activeul"),s.classList.add("gspb_loadingbefore"),r.classList.add("sortingloading"),null==r.querySelector(".gspb_query_preloader")&&r.insertAdjacentHTML("beforeend",'<div class="gspb_query_preloader"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="60" viewBox="0 0 100 100" fill="#2184f9"><path d="M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50"><animateTransform attributeName="transform" attributeType="XML" type="rotate" dur="1s" from="0 50 50" to="360 50 50" repeatCount="indefinite"></animateTransform></path></svg></div>');let $=new XMLHttpRequest;$.open("POST",gspbfiltervars.ajax_url,!0),$.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),$.responseType="json",$.onload=function(){if(this.status>=200&&this.status<400){let e=this.response.data,t=Math.floor(1e5*Math.random());if(y){let a=e.replace(/gspbgrid_item /g,"gspbgrid_item gspb_grid"+t+" ");y.innerHTML="",y.insertAdjacentHTML("beforeend",a)}else r.innerHTML="",r.insertAdjacentHTML("beforeend",e);if(s.closest(".gspb_filter_panel").querySelectorAll("span").forEach(function(e){e.classList.remove("active")}),s.classList.remove("gspb_loadingbefore"),s.classList.add("active"),r.classList.remove("sortingloading"),s.closest("ul").classList.remove("activeul"),s.closest("ul").classList.contains("gspb_tax_dropdown")){var o=s.closest(".gspb_tax_dropdown");o.querySelector(".gspb_choosed_tax").innerHTML=s.innerHTML,o.querySelector(".gspb_choosed_tax").style.display="block",o.querySelector(".gspb_choosed_tax").setAttribute("data-taxdata",s.getAttribute("data-sorttype")),o.querySelector(".gspb_tax_placeholder").style.display="none",n.querySelector(".gspb_filter_ul li:first-child span").classList.add("active"),o.classList.remove("active")}if(s.closest(".gs-swiper-init")){s.closest(".gs-swiper-init").querySelector(".swiper").swiper.destroy();GSPB_render_Swiper(s.closest(".gs-swiper-init"))}if(r.classList.contains("gspb_aj_pag_auto_wrap")&&(null!==r.querySelector(".gspb_ajax_pagination_outer")&&r.querySelector(".gspb_ajax_pagination_outer").remove(),gspbInfiniteScrollObserver()),y&&s.closest(".gs-gsap-wrap")){let i=s.closest(".gs-gsap-wrap");"batch"==i.getAttribute("data-triggertype")&&"undefined"!=typeof gsap&&gsap.matchMedia().add({isDesktop:"(min-width: 768px)",isMobile:"(max-width: 767px)"},e=>{let t=GSGetBasicTween(i,e);GSBatchScrollTrigger(i,t,y.querySelectorAll(".gspbgrid_item"),"","",e)})}let l=r.querySelectorAll(".gspb_grid"+t);l&&l.length>0&&l.forEach(e=>{"function"==typeof GSPBSlidingPanelInit&&GSPBSlidingPanelInit(e),"function"==typeof gsInitTabs&&gsInitTabs(".gspb-tabs",e),"function"==typeof GSPB_Swiper_Init&&GSPB_Swiper_Init(e),"function"==typeof GS_Videos_Init&&GS_Videos_Init(e),"function"==typeof GSPB_Toggler_Init&&GSPB_Toggler_Init(e),"function"==typeof GSPB_quantityInput&&GSPB_quantityInput(e);let t=new CustomEvent("gsAjaxFilterSuccess",{detail:e});document.dispatchEvent(t)})}},$.onerror=function(){},$.send("action=gspb_filterpost&security="+gspbfiltervars.filternonce+"&sorttype="+i+"&filterargs="+d+"&template="+f+"&tax="+p+"&containerid="+a+"&offset="+l+"&innerargs="+g+"&blockinstance="+b)}},!1)});const gctaxsortBtns=document.querySelectorAll(".gspb_tax_dropdown .label");gctaxsortBtns.forEach(e=>{e.addEventListener("click",function(e){e.stopPropagation(),e.preventDefault(),e.target.closest(".gspb_tax_dropdown").classList.toggle("active")})});