Liferay.Loader.define("@liferay/fragment-renderer-collection-filter-impl@1.0.21/js/CollectionAppliedFilters",["module","exports","require","frontend-js-web"],(function(e,t,n){window;Object.defineProperty(t,"__esModule",{value:!0}),t.default=function CollectionAppliedFilters({filterPrefix:e,fragmentEntryLinkNamespace:t}){const n=document.getElementById("".concat(t,"_filterList")),i=document.getElementById("".concat(t,"_removeAllFilters")),r=document.getElementById("".concat(t,"_toggleExpand")),a=r.querySelector(".lexicon-icon-angle-up-small"),l=r.querySelector(".lexicon-icon-angle-down-small"),s=r.firstElementChild,handleRemoveAllFiltersClick=()=>{const t=new URL(window.location.href);Array.from(t.searchParams).forEach((([n])=>{n.startsWith(e)&&t.searchParams.delete(n)})),window.location.href=t.toString()},handleToggleExpandFiltersButtonClick=()=>{n.style.maxHeight?(n.style.maxHeight="",s.textContent=r.dataset.showLessLabel,a.classList.remove("d-none"),l.classList.add("d-none")):(n.style.maxHeight="4em",s.textContent=r.dataset.showMoreLabel,a.classList.add("d-none"),l.classList.remove("d-none"))},handleWindowResize=()=>{const e=n.getBoundingClientRect().height;handleToggleExpandFiltersButtonClick(),requestAnimationFrame((()=>{const t=n.getBoundingClientRect().height;r.classList.toggle("d-none",e===t),handleToggleExpandFiltersButtonClick()}))},c=(0,o.delegate)(document.body,"click","#".concat(t," .remove-filter-button"),(t=>{const{filterFragmentEntryLinkId:n,filterType:o,filterValue:i}=t.delegateTarget.dataset,r="".concat(e).concat(o,"_").concat(n),a=[],l=new URL(window.location.href);l.searchParams.forEach(((e,t)=>{e===i&&t===r||a.push([t,e])})),l.search="",a.forEach((([e,t])=>{l.searchParams.append(e,t)})),window.location.href=l.toString()}));return r.addEventListener("click",handleToggleExpandFiltersButtonClick),null==i||i.addEventListener("click",handleRemoveAllFiltersClick),window.addEventListener("resize",handleWindowResize),handleWindowResize(),{dispose(){null==i||i.removeEventListener("click",handleRemoveAllFiltersClick),r.removeEventListener("click",handleToggleExpandFiltersButtonClick),window.removeEventListener("resize",handleWindowResize),c.dispose()}}};var o=n("frontend-js-web")}));
//# sourceMappingURL=CollectionAppliedFilters.js.map