1import{c as h,S as m,a as I}from"../main-IQqeOzm7.js";import{H as R}from"./Header-CzerSYeI.js";import{B as b}from"./Btn-mNwuUIh4.js";import{W as D}from"./Wysiwyg-Dty2g2dl.js";import"./baguetteBox-Blr6zO0w.js";import"./_commonjsHelpers-CqkleIqs.js";import"./AssetUrl-B5-qCeML.js";import"./Scroller-RoBd6nFi.js";import"./jquery-BoRPd-fL.js";import"./plyr-player-config-DZLxEWYB.js";class w{}const y=h(w,".label");class B{}const F=h(B,".chip"),n={CARD:"[data-card]",CARDS_LIST:"[data-cards-list]",LABEL:"[data-label]",LABEL_FILTER:"[data-label-filter]",LABEL_FILTER_ALL:"[data-label-filter-all]",NOT_FOUND:"[data-not-found]",SEARCH_INPUT:"[data-search-input]",SHOW_MORE_BTN:"[data-show-more-btn]",LINK_BTN:"[data-link-btn]"},a={LABEL_FILTER_ACTIVE:"chip--active",CARDS_LIST_COLLAPSED:"cards-with-filtering__list--collapsed",CARD_HIDE:"cards-with-filtering__card-wrapper--hide",NOT_FOUND_HIDE:"cards-with-filtering__not-found--hide"};class N{constructor(e,t){this.initController(e,t)}initController(e,t){const r={allCards:e.querySelectorAll(n.CARD),allFilterLabels:e.querySelectorAll(n.LABEL_FILTER),filterAllLabel:e.querySelector(n.LABEL_FILTER_ALL),notFound:e.querySelector(n.NOT_FOUND),spinner:t.find(l=>l instanceof I),searchInput:e.querySelector(n.SEARCH_INPUT),showMoreBtn:e.querySelector(n.SHOW_MORE_BTN),linkBtn:e.querySelector(n.LINK_BTN),cardsList:e.querySelector(n.CARDS_LIST),widget:e},i={activeLabelFilterValue:"",searchInputValue:"",showMoreBtnClicked:!1,rowsDisplayedNumber:this.getRowsDisplayedNumber(r)};this.labelFilterController(r,i),this.inputSearchController(r,i),this.addBtnClickHandler(r,i),this.initializeVisibleCards(r,i),this.addResponsiveEventListeners(r,i)}addBtnClickHandler(e,t){const{showMoreBtn:r,linkBtn:s}=e;!r||s||r.addEventListener("click",()=>{t.showMoreBtnClicked=!t.showMoreBtnClicked,this.filterAndRenderCards(e,t)})}labelFilterController(e,t){const{allFilterLabels:r,widget:s}=e;r.length!==0&&r.forEach(i=>{i.addEventListener("click",()=>{this.changeFilterLabel(this.getActiveLabelFilter(s),i),t.activeLabelFilterValue=i.textContent,this.filterAndRenderCards(e,t)})})}inputSearchController(e,t){const{searchInput:r,spinner:s}=e;if(!r)return;let i;const l=500;r.addEventListener("keyup",o=>{const c=o.currentTarget.value.trim();t.searchInputValue=c,s.show(),clearTimeout(i),i=setTimeout(()=>{this.filterAndRenderCards(e,t),s.hide()},l)})}filterAndRenderCards(e,t){const{allCards:r,showMoreBtn:s,linkBtn:i,notFound:l,widget:o,filterAllLabel:c}=e,_=this.isDisplayAllFilter(c),S=t.searchInputValue.length>0;let L=0,C=0,p=t.showMoreBtnClicked?null:this.calculateMaxVisibleCards(r,t.rowsDisplayedNumber);r.forEach(d=>{const E=this.getCardLabels(d),f=_||E.some(T=>T.textContent.trim()===t.activeLabelFilterValue.trim()),A=(!S||this.isCardMatchToSearchInputValue(d,t.searchInputValue))&&f;A&&(p===null||L<p)?(this.showCard(d),L++):this.hideCard(d),A&&C++}),this.updateShowMoreBtn(s,i,t,C,r),this.notFoundController(o,l)}updateShowMoreBtn(e,t,r,s,i){if(!e||t)return;const{showLabel:l,hideLabel:o}=e.dataset;s>this.calculateMaxVisibleCards(i,r.rowsDisplayedNumber)?(e.innerText=r.showMoreBtnClicked?o:l,this.showShowMoreBtn(e)):this.hideShowMoreBtn(e)}notFoundController(e,t){if(!t)return;if(e.querySelectorAll(`${n.CARD}:not(.${a.CARD_HIDE})`).length>0){t.classList.add(a.NOT_FOUND_HIDE);return}t.classList.remove(a.NOT_FOUND_HIDE)}initializeVisibleCards(e,t){this.filterAndRenderCards(e,t)}hideCard(e){e.classList.add(a.CARD_HIDE)}showCard(e){e.classList.remove(a.CARD_HIDE)}isDisplayAllFilter(e){return e?e.classList.contains(a.LABEL_FILTER_ACTIVE):!0}getSearchInputValue(e){return e?e.value.trim():""}isCardMatchToSearchInputValue(e,t){return e.textContent.toUpperCase().includes(t.toUpperCase())}isSkipSearchInput(e){return e.length===0}changeFilterLabel(e,t){e.classList.remove(a.LABEL_FILTER_ACTIVE),t.classList.add(a.LABEL_FILTER_ACTIVE)}getActiveLabelFilter(e){return e.querySelector(`.${a.LABEL_FILTER_ACTIVE}`)}getCardLabels(e){return Array.from(e.querySelectorAll(n.LABEL))}isDisplayCollapsedList(e){return e.classList.contains(a.CARDS_LIST_COLLAPSED)}hideShowMoreBtn(e){e.style.display="none"}showShowMoreBtn(e){e.style.display="inline-flex"}getRowsDisplayedNumber(e){return Number(e.cardsList.getAttribute("data-rows-displayed-number"))}addResponsiveEventListeners(e,t){let r;window.addEventListener("resize",()=>{clearTimeout(r),r=setTimeout(()=>{this.filterAndRenderCards(e,t)},100)})}calculateMaxVisibleCards(e,t){if(!Array.isArray(e)&&!(e instanceof NodeList)||e.length===0||typeof t!="number"||t<=0)return null;const r="grid__col--",s=e[0],i=Array.from(s.classList).find(o=>o.startsWith(r));if(!i)return null;let l=parseInt(i.replace(r,""),10);return window.innerWidth<=991&&window.innerWidth>768?l=6:window.innerWidth<=768&&(l=12),isNaN(l)?null:12/l*t}}const z=h(N,"[data-js='cards-with-filtering']",[R,m,b,y,F,D]);export{N as CardsWithFilteringWidget,z as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.