let humburgerButton=document.querySelector(".navbar-toggler");const searchapp=Vue.createApp({data(){return{solrConfigUrl:"/chunk-fields/search-config?async=1",solrAPISetting:null,searchData:[],searchFeaturedData:[],searchFecetData:[],searchAutocompleteData:[],searchDocumentTypeContent:[],searchOtpToolFeedContent:[],searchDocumentTypeData:[],searchOtpToolFeedData:[],popularKeyData:[],searchMetaDomain:[],searchMetaSite:[],searchMetaDomainData:[],searchMetaSiteData:[],totalResultCount:null,facetResultCount:0,hasFacetQuery:!1,displayMetaFacetNumber:4,resultTime:"",searchResultList:[],searchFeaturedList:[],searchResultText:[],searchFeaturedText:[],query:null,facet:null,autoCompleteInput:"",summaryKey:"",autoCompleteDataObject:{},showAutocompleteData:!1,focusedItemIndex:-1,checkQueryParameter:null,focusedItemIndex:-1,selectedDate:"",startDate:"",endDate:"",dateError:!1,dateErrorMessage:"End date must be after the start date",selectedSortBy:"score",isDisabledPublishedDateCta:!0,activeDoctypeItems:{},activeOTPFeedItems:{},paginationIndex:0,currentPage:1,itemsPerPage:15,totalItems:0,fileSizeInBytes:1024,loading:!0}},async created(){if(this.cleanAndReplaceURL(),await this.solrConfig(),this.removeQueryParam("fq"),this.removeQueryParam("startdate"),this.removeQueryParam("enddate"),this.removeQueryParam("otpfeed"),this.removeQueryParam("doctype"),this.removeQueryParam("metasite"),this.removeQueryParam("metadomain"),this.pushQueryParam("querytype","exact"),this.checkQueryParameter=this.getQueryParam("q"),this.checkQueryParameter!=null)if(this.solrAPISetting){let n=this.solrAPISetting.SolrGlobalConfig.USDATEFORMAT?"m/d/Y":"d/m/Y";flatpickr(".date-picker",{dateFormat:n,disableMobile:!0,onChange:this.onDateChange});await this.searchRequest();this.setInputValueFromQueryParam();this.solrAPISetting.SolrTabsConfig.ENABLEMETATAGSEARCH&&(await this.fecetRequest(),this.searchFecetData.length>4&&this.initializeSwiper());this.solrAPISetting.SolrFeaturedSearchConfig.ENABLEFEATUREDSEARCH&&await this.featuredSearchRequest();this.solrAPISetting.SolrPopularSearchConfig.ENABLEPOPULARSEARCH&&await this.popularSearch()}else console.error("Solr config data is not available");this.processQueryParam()},computed:{showLoadMoreButton(){return this.searchResultList.length<this.totalItems},totalPages(){return Math.ceil(this.totalItems/this.itemsPerPage)},paginatedPages(){const r=[];let t,i;const n=Math.ceil(this.totalItems/this.itemsPerPage);n<=5?(t=1,i=n):this.currentPage<=3?(t=1,i=5):this.currentPage+2>=n?(t=n-4,i=n):(t=this.currentPage-2,i=this.currentPage+2);for(let n=t;n<=i;n++)r.push(n);return t>1&&(r.unshift(1),t>2&&r.splice(1,0,"...")),i<n&&(i<n-1&&r.push("..."),r.push(n)),r}},mounted(){document.addEventListener("click",()=>{this.showAutocompleteData=!1})},beforeDestroy(){document.addEventListener("click",()=>{this.showAutocompleteData=!0})},watch:{startDate(){this.updatePublishedButtonState()},endDate(){this.updatePublishedButtonState()}},methods:{delay(n){return new Promise(t=>setTimeout(t,n))},processQueryParam(){const n=new URLSearchParams(window.location.search),t=n.get("param");this.safeContent=DOMPurify.sanitize(t)},delay(n){return new Promise(t=>setTimeout(t,n))},async solrConfig(){try{const n=await axios.get(this.solrConfigUrl);if(n.status!==200)throw new Error(`Failed to fetch data from API. Status: ${n.status}`);this.solrAPISetting=n.data}catch(n){console.error("Error getting Solr config:",n)}},async searchRequest(n=false){try{this.loading=!0;humburgerButton.style.pointerEvents="none";const i={Handler:"query",Query:this.buildSearchParams(this.checkQueryTypeParameter(),this.getQueryParam("fq"),0,!1)},r=new URLSearchParams(Object.entries(i)),t=await axios.post(this.solrAPISetting.SolrGlobalConfig.APIURI,r,{headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(t.status!==200)throw new Error(`HTTP error! Status: ${t.status}`);const u=t.data;this.searchData=JSON.parse(u);this.totalItems=this.searchData.response.numFound;this.totalItems=="0"?setTimeout(function(){var n=document.querySelector(".search__noresults--wrapper");n.classList.remove("d-none")},300):setTimeout(function(){var n=document.querySelector(".search__results__data--wrapper");n.classList.remove("d-none")},300);this.searchResultList=this.searchData.response.docs;this.searchResultList.forEach(n=>{const t=this.searchData.highlighting[n.id];t&&(Array.isArray(n.text)||(n.text=[],n.text.push(...t.text)))});n||(this.totalResultCount=this.searchData.response.numFound);this.facetResultCount=this.searchData.response.numFound;this.resultTime=this.searchData.responseHeader.QTime;this.searchDocumentTypeContent=this.searchData.facet_counts.facet_fields.solrdocumenttype;this.searchOtpToolFeedContent=this.searchData.facet_counts.facet_fields.otptoolname;this.searchMetaDomain=this.searchData.facet_counts.facet_fields.meta_domain;this.searchMetaSite=this.searchData.facet_counts.facet_fields.meta_site;this.searchDocumentTypeData=this.arrayToObject(this.searchDocumentTypeContent);this.searchOtpToolFeedData=this.arrayToObject(this.searchOtpToolFeedContent);this.searchMetaDomainData=this.arrayToObject(this.searchMetaDomain);this.searchMetaSiteData=this.arrayToObject(this.searchMetaSite);this.paginationDataRequest(1);this.summaryKey=this.getQueryParam("q");this.loading=!1;humburgerButton.style.pointerEvents="auto"}catch(t){console.error("Error sending request:",t)}},async showMoreDataRequest(){try{this.loading=!0;humburgerButton.style.pointerEvents="none";this.paginationIndex+=15;const t={Handler:"query",Query:this.buildSearchParams(this.checkQueryTypeParameter(),this.getQueryParam("fq"),this.paginationIndex,!1,this.getQueryParam("startdate"),this.getQueryParam("enddate"),this.getQueryParam("doctype"),this.getQueryParam("otpfeed"))},i=new URLSearchParams(Object.entries(t)),n=await axios.post(this.solrAPISetting.SolrGlobalConfig.APIURI,i,{headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(n.status!==200)throw new Error(`HTTP error! Status: ${n.status}`);this.searchData=JSON.parse(n.data);this.totalItems=this.searchData.response.numFound;this.searchResultList=[...this.searchResultList,...this.searchData.response.docs];this.searchResultList.forEach(n=>{const t=this.searchData.highlighting[n.id];t&&(Array.isArray(n.text)||(n.text=[],n.text.push(...t.text)))});this.loading=!1;humburgerButton.style.pointerEvents="auto"}catch(n){console.error("Error sending request:",n)}},async paginationDataRequest(n=this.currentPage){try{this.loading=!0;humburgerButton.style.pointerEvents="none";this.paginationIndex=(n-1)*this.itemsPerPage;const i={Handler:"query",Query:this.buildSearchParams(this.checkQueryTypeParameter(),this.getQueryParam("fq"),this.paginationIndex,!1,this.getQueryParam("startdate"),this.getQueryParam("enddate"),this.getQueryParam("doctype"),this.getQueryParam("otpfeed"))},r=new URLSearchParams(Object.entries(i)),t=await axios.post(this.solrAPISetting.SolrGlobalConfig.APIURI,r,{headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(t.status!==200)throw new Error(`HTTP error! Status: ${t.status}`);this.searchData=JSON.parse(t.data);this.totalItems=this.searchData.response.numFound;this.searchResultList=this.searchData.response.docs;this.searchResultList.forEach(n=>{const t=this.searchData.highlighting[n.id];t&&(Array.isArray(n.text)||(n.text=[],n.text.push(...t.text)))});this.currentPage=n;this.loading=!1;humburgerButton.style.pointerEvents="auto"}catch(t){console.error("Error sending request:",t)}},formatTextWithEllipsis(n){let t=this.sanitizeHtml(n,this.highlightTerm),i=350;return t.length>i?t.substring(0,i)+"...":t+"..."},goToFirstPage(){this.paginationDataRequest(1)},goToLastPage(){this.paginationDataRequest(this.totalPages)},goToPrevPage(){this.currentPage>1&&this.paginationDataRequest(this.currentPage-1)},goToNextPage(){this.currentPage<this.totalPages&&this.paginationDataRequest(this.currentPage+1)},goToPage(n){this.paginationDataRequest(n)},async searchButtonRequest(){const n=this.autoCompleteInput;this.pushQueryParam("q",n);this.showAutocompleteData=!1;this.checkQueryParameter=this.getQueryParam("q");this.solrAPISetting?(this.removeQueryParam("fq"),this.updateFacetClassBasedOnQueryParam("fq","selected"),this.removeQueryParam("startdate"),this.removeQueryParam("enddate"),this.removeQueryParam("otpfeed"),this.removeQueryParam("doctype"),this.removeQueryParam("metasite"),this.removeQueryParam("metadomain"),this.pushQueryParam("querytype","exact"),await this.searchRequest(),this.solrAPISetting.SolrTabsConfig.ENABLEMETATAGSEARCH&&await this.fecetRequest(),this.solrAPISetting.SolrFeaturedSearchConfig.ENABLEFEATUREDSEARCH&&await this.featuredSearchRequest(),this.solrAPISetting.SolrPopularSearchConfig.ENABLEPOPULARSEARCH&&await this.popularSearch()):console.error("Solr config data is not available")},handleArrowNavigation(n){if(n.key==="ArrowDown")n.preventDefault(),this.focusedItemIndex<Object.keys(this.autoCompleteDataObject).length-1&&this.focusedItemIndex++;else if(n.key==="ArrowUp")n.preventDefault(),this.focusedItemIndex>-1&&this.focusedItemIndex--;else if(n.key==="Enter"&&this.focusedItemIndex!==-1){n.preventDefault();const t=Object.keys(this.autoCompleteDataObject),i=t[this.focusedItemIndex];this.autoCompleteInput=i;this.searchButtonRequest()}},selectItem(n){this.autoCompleteInput=n;this.searchButtonRequest()},async featuredSearchRequest(){try{const t={Handler:"query",Query:this.buildSearchParams(this.checkQueryTypeParameter(),this.getQueryParam("fq"),0,this.solrAPISetting.SolrFeaturedSearchConfig.ENABLEFEATUREDSEARCH,this.getQueryParam("startdate"),this.getQueryParam("enddate"),this.getQueryParam("doctype"),this.getQueryParam("otpfeed"),this.getQueryParam("metasite"),this.getQueryParam("metadomain"))},i=new URLSearchParams(Object.entries(t)),n=await axios.post(this.solrAPISetting.SolrGlobalConfig.APIURI,i,{headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(n.status!==200)throw new Error(`HTTP error! Status: ${n.status}`);this.searchFeaturedData=JSON.parse(n.data);this.searchFeaturedList=this.searchFeaturedData.response.docs;this.searchFeaturedText=this.searchFeaturedData.highlighting}catch(n){console.error("Error sending request:",n)}},async popularSearch(){try{const t={Handler:"select",Query:this.buildPopularkeyParams()},i=new URLSearchParams(Object.entries(t)),n=await axios.post(this.solrAPISetting.SolrPopularSearchConfig.APIPOPULARSEARCH,i,{headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(n.status!==200)throw new Error(`HTTP error! Status: ${n.status}`);this.popularKeyData=n.data}catch(n){console.error("Error sending request:",n)}},async fecetRequest(){this.loading=!0;humburgerButton.style.pointerEvents="none";const t={Handler:"facet",Query:this.buildFecetParams(this.getQueryParam("q"),this.getQueryParam("fq"),this.getQueryParam("startdate"),this.getQueryParam("enddate"),this.getQueryParam("doctype"),this.getQueryParam("otpfeed"),this.getQueryParam("metasite"),this.getQueryParam("metadomain"))},i=new URLSearchParams(Object.entries(t)),n=await axios.post(this.solrAPISetting.SolrGlobalConfig.APIURI,i,{headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(n.status!==200)throw new Error(`HTTP error! Status: ${n.status}`);const r=JSON.parse(n.data).facet_counts.facet_fields.meta_section;this.searchFecetData=this.transformFacetData(this.solrAPISetting.SolrTabsConfig.TABS_TITLES,r);this.displayMetaFacetNumber=this.solrAPISetting.SolrTabsConfig.DISPLAY_META_TAB_COUNT;this.loading=!1;humburgerButton.style.pointerEvents="auto"},getMatchingFecetTitle(n){let t="";return this.searchFecetData.forEach(i=>{i.id===n&&(t=i.title)}),t},async autocompleteRequest(){const n=new URLSearchParams({Handler:"autocomplete",Query:this.buildAutocompleteParams()});try{const t=await axios.post(this.solrAPISetting.SolrGlobalConfig.APIURI,n,{headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(t.status!==200)throw new Error(`HTTP error! Status: ${t.status}`);this.searchAutocompleteData=JSON.parse(t.data);const i=this.searchAutocompleteData.facet_counts.facet_fields.tnt_txt_en;let r={};for(let n=0;n<i.length;n+=2)r[i[n]]=i[n+1];this.autoCompleteDataObject=r}catch(t){console.error("Error in autocomplete request:",t)}},async handleAutocompleteKeyup(){this.autoCompleteInput.length>3&&(this.showAutocompleteData=!0,await this.autocompleteRequest())},async keywordQuerySelector(n){const t=n.currentTarget.querySelector(".key").textContent;this.pushQueryParam("q",t);this.showAutocompleteData=!1;this.checkQueryParameter=this.getQueryParam("q");this.solrAPISetting?(this.removeQueryParam("fq"),this.updateFacetClassBasedOnQueryParam("fq","selected"),await this.searchRequest(),this.solrAPISetting.SolrTabsConfig.ENABLEMETATAGSEARCH&&await this.fecetRequest(),this.solrAPISetting.SolrFeaturedSearchConfig.ENABLEFEATUREDSEARCH&&await this.featuredSearchRequest()):console.error("Solr config data is not available")},async updateQueryWithFacet(n,t){if(this.solrAPISetting){if(n.getAttribute("data-metacontent")==="*")this.removeQueryParam("fq"),await this.searchRequest();else{const i=n.getAttribute("data-metacontent");this.pushQueryParam("fq",i);await this.searchRequest(t)}this.solrAPISetting.SolrFeaturedSearchConfig.ENABLEFEATUREDSEARCH&&await this.featuredSearchRequest()}else console.error("Solr config data is not available")},async submitDates(){let n=`${this.formatDate(this.startDate)}T00:00:00Z`,t=`${this.formatDate(this.endDate)}T23:59:59Z`;n&&this.pushQueryParam("startdate",n);t&&this.pushQueryParam("enddate",t);(this.getQueryParam("startdate")||this.getQueryParam("enddate"))&&(this.solrAPISetting?(this.removeQueryParam("fq"),this.updateFacetClassBasedOnQueryParam("fq","selected"),await this.searchRequest(),this.solrAPISetting.SolrTabsConfig.ENABLEMETATAGSEARCH&&await this.fecetRequest(),this.solrAPISetting.SolrFeaturedSearchConfig.ENABLEFEATUREDSEARCH&&await this.featuredSearchRequest()):console.error("Solr config data is not available"))},async resetDates(){this.startDate="";this.endDate="";(this.getQueryParam("startdate")||this.getQueryParam("enddate"))&&(this.solrAPISetting?(this.removeQueryParam("startdate"),this.removeQueryParam("enddate"),await this.searchRequest(),this.solrAPISetting.SolrTabsConfig.ENABLEMETATAGSEARCH&&await this.fecetRequest(),this.solrAPISetting.SolrFeaturedSearchConfig.ENABLEFEATUREDSEARCH&&await this.featuredSearchRequest()):console.error("Solr config data is not available"))},async getSelectedQueryType(){this.pushQueryParam("querytype",this.selectedText.toLowerCase());this.solrAPISetting?(this.removeQueryParam("fq"),this.updateFacetClassBasedOnQueryParam("fq","selected"),await this.searchRequest(),this.solrAPISetting.SolrTabsConfig.ENABLEMETATAGSEARCH&&await this.fecetRequest(),this.solrAPISetting.SolrFeaturedSearchConfig.ENABLEFEATUREDSEARCH&&await this.featuredSearchRequest()):console.error("Solr config data is not available")},async sortByList(){this.pushQueryParam("sort",`${this.selectedSortBy} DESC`);this.solrAPISetting?(this.removeQueryParam("fq"),this.updateFacetClassBasedOnQueryParam("fq","selected"),await this.searchRequest(),this.solrAPISetting.SolrTabsConfig.ENABLEMETATAGSEARCH&&await this.fecetRequest(),this.solrAPISetting.SolrFeaturedSearchConfig.ENABLEFEATUREDSEARCH&&await this.featuredSearchRequest()):console.error("Solr config data is not available")},async doctypeSearch(n){this.activeDoctypeItems=this.activeDoctypeItems===n?null:n;this.activeDoctypeItems?this.pushQueryParam("doctype",n):this.removeQueryParam("doctype");this.solrAPISetting&&(this.removeQueryParam("fq"),this.updateFacetClassBasedOnQueryParam("fq","selected"),await this.searchRequest(),await this.fecetRequest(),this.solrAPISetting.SolrFeaturedSearchConfig.ENABLEFEATUREDSEARCH&&await this.featuredSearchRequest())},async otpfeedsSearch(n){this.activeOTPFeedItems=this.activeOTPFeedItems===n?null:n;this.activeOTPFeedItems?this.pushQueryParam("otpfeed",n):this.removeQueryParam("otpfeed");this.solrAPISetting&&(this.removeQueryParam("fq"),this.updateFacetClassBasedOnQueryParam("fq","selected"),await this.searchRequest(),this.solrAPISetting.SolrTabsConfig.ENABLEMETATAGSEARCH&&await this.fecetRequest(),this.solrAPISetting.SolrFeaturedSearchConfig.ENABLEFEATUREDSEARCH&&await this.featuredSearchRequest())},async metaDomainfeedsSearch(n){this.activeMetaDomainFeedItems=this.activeMetaDomainFeedItems===n?null:n;this.activeMetaDomainFeedItems?this.pushQueryParam("metadomain",n):this.removeQueryParam("metadomain");this.solrAPISetting&&(this.removeQueryParam("fq"),this.updateFacetClassBasedOnQueryParam("fq","selected"),await this.searchRequest(),this.solrAPISetting.SolrTabsConfig.ENABLEMETATAGSEARCH&&await this.fecetRequest(),this.solrAPISetting.SolrFeaturedSearchConfig.ENABLEFEATUREDSEARCH&&await this.featuredSearchRequest())},async metaSitefeedsSearch(n){this.activeMetaSiteFeedItems=this.activeMetaSiteFeedItems===n?null:n;this.activeMetaSiteFeedItems?this.pushQueryParam("metasite",n):this.removeQueryParam("metasite");this.solrAPISetting&&(this.removeQueryParam("fq"),this.updateFacetClassBasedOnQueryParam("fq","selected"),await this.searchRequest(),this.solrAPISetting.SolrTabsConfig.ENABLEMETATAGSEARCH&&await this.fecetRequest(),this.solrAPISetting.SolrFeaturedSearchConfig.ENABLEFEATUREDSEARCH&&await this.featuredSearchRequest())},async trandingKeywordSearch(n){this.autoCompleteInput=n;this.pushQueryParam("q",n);this.solrAPISetting&&(this.removeQueryParam("fq"),this.updateFacetClassBasedOnQueryParam("fq","selected"),await this.searchRequest(),this.solrAPISetting.SolrTabsConfig.ENABLEMETATAGSEARCH&&await this.fecetRequest(),this.solrAPISetting.SolrFeaturedSearchConfig.ENABLEFEATUREDSEARCH&&await this.featuredSearchRequest(),this.solrAPISetting.SolrPopularSearchConfig.ENABLEPOPULARSEARCH&&await this.popularSearch())},arrayToObject(n){let t={};for(let i=0;i<n.length;i+=2)t[n[i]]=n[i+1];return t},handleFacetEvent(n){const t=n.target,i=t.classList.contains("meta-facet-rest-link");document.querySelectorAll(".meta-facets-tab-link").forEach(n=>{n.classList.remove("selected")});n.target.classList.add("selected");this.updateQueryWithFacet(t,i)},decodeHtml(n){var t=document.createElement("textarea");return t.innerHTML=n,t.value},transformFacetData(n,t){const i={};for(let n=0;n<t.length;n+=2)i[t[n]]=t[n+1];return Object.keys(n).map(t=>({id:t,title:this.decodeHtml(n[t]),count:i[t]?i[t].toString():"0"}))},fillInput(n){const t=n.currentTarget.querySelector(".key").textContent;this.autoCompleteInput=t},setInputValueFromQueryParam(){this.checkQueryParameter=this.getQueryParam("q");this.checkQueryParameter&&(this.autoCompleteInput=this.checkQueryParameter)},buildSearchParams(n,t,i,r){let u={query:n,language:this.solrAPISetting.SolrGlobalConfig.LANGUAGE,mergeotp:this.solrAPISetting.SolrOtpToolsSearchConfig.OTPENABLED,otplanguage:this.solrAPISetting.SolrOtpToolsSearchConfig.OTPLANGUAGE,start:i,rows:this.solrAPISetting.SolrPaginationConfig.HITSPERPAGE,keywordtracking:"1",fq:this.getFilterQuery(r)};return this.solrAPISetting.SolrGlobalConfig.FIELDS!==""&&(u.fl=this.solrAPISetting.SolrGlobalConfig.FIELDS),this.solrAPISetting.SolrFacetingConfig.FACETS.length>0&&(u={...u,facet:"true","facet.field":this.solrAPISetting.SolrFacetingConfig.FACETS,"facet.mincount":1,"facet.pivot":"otptoolname,otpcatname","facet.pivot.mincount":1,"facet.sort":"index"}),this.solrAPISetting.SolrHighlightConfig.HL&&(u={...u,hl:"on","hl.fl":this.solrAPISetting.SolrHighlightConfig.HL_FL,"hl.fragsize":this.solrAPISetting.SolrHighlightConfig.HL_FRAGSIZE,"hl.snippet":this.solrAPISetting.SolrHighlightConfig.HL_SNIPPETS,"hl.simple.pre":this.solrAPISetting.SolrHighlightConfig.HL_SIMPLE_PRE,"hl.simple.post":this.solrAPISetting.SolrHighlightConfig.HL_SIMPLE_POST,"hl.alternateField":this.solrAPISetting.SolrHighlightConfig.HL_FL,"hl.maxAlternateFieldLength":this.solrAPISetting.SolrHighlightConfig.HL_FRAGSIZE,"h1.usePhraseHighlighter":!0,"hl.maxAnalyzedChars":-1}),this.getSortQuery(n,u),this.getAutoQueryType(),JSON.stringify(u)},buildFecetParams(n,t,i,r,u,f,e,o){const s=[`client:${this.solrAPISetting.SolrGlobalConfig.CLIENT}`],h=t,c=i,l=r,a=u,v=f,y=e,p=o;return h!==null&&s.push(`${this.solrAPISetting.SolrTabsConfig.TAB_METATAG}:${h}`),(c||l)&&s.push(`${this.solrAPISetting.SolrGlobalVariables.HITPUBLISHDATE}:[${this.getQueryParam("startdate")} TO ${this.getQueryParam("enddate")}]`),a&&s.push(`solrdocumenttype:${this.getQueryParam("doctype")}`),v&&s.push(`otptoolname:${this.getQueryParam("otpfeed")}`),y&&s.push(`meta_site:${this.getQueryParam("metasite")}`),p&&s.push(`meta_domain:${this.getQueryParam("metadomain")}`),n=this.getQueryParam("querytype")=="exact"?'"'+n+'"':n,JSON.stringify({query:n,language:this.solrAPISetting.SolrGlobalConfig.LANGUAGE,mergeotp:this.solrAPISetting.SolrOtpToolsSearchConfig.OTPENABLED,otplanguage:this.solrAPISetting.SolrOtpToolsSearchConfig.OTPLANGUAGE,"facet.field":this.solrAPISetting.SolrTabsConfig.TAB_METATAG,fq:s,"facet.mincount":0})},buildAutocompleteParams(){return JSON.stringify({q:`(client:${this.solrAPISetting.SolrGlobalConfig.CLIENT} AND (otplanguage:${this.solrAPISetting.SolrOtpToolsSearchConfig.OTPLANGUAGE} OR language:${this.solrAPISetting.SolrGlobalConfig.LANGUAGE}))`,"facet.prefix":this.autoCompleteInput,"facet.method":"enum","facet.limit":"10"})},buildPopularkeyParams(){return JSON.stringify({language:this.solrAPISetting.SolrGlobalConfig.LANGUAGE,keyword:"("+this.getQueryParam("q")+")"})},getFilterQuery(n){const t=[`client:${this.solrAPISetting.SolrGlobalConfig.CLIENT}`],i=this.getQueryParam("fq"),r=this.getQueryParam("startdate"),u=this.getQueryParam("enddate"),f=this.getQueryParam("doctype"),e=this.getQueryParam("otpfeed"),o=this.getQueryParam("metasite"),s=this.getQueryParam("metadomain");return i!==null&&t.push(`${this.solrAPISetting.SolrTabsConfig.TAB_METATAG}:${i}`),(r||u)&&t.push(`${this.solrAPISetting.SolrGlobalVariables.HITPUBLISHDATE}:[${this.getQueryParam("startdate")} TO ${this.getQueryParam("enddate")}]`),f&&t.push(`solrdocumenttype:${this.getQueryParam("doctype")}`),e&&t.push(`otptoolname:${this.getQueryParam("otpfeed")}`),o&&t.push(`meta_site:${this.getQueryParam("metasite")}`),s&&t.push(`meta_domain:${this.getQueryParam("metadomain")}`),n&&t.push("meta_isfeatured:1"),t},getSortQuery(n,t){let i=this.getQueryParam("sort");if(!i&&this.getQueryParam("q")&&(i=`${this.selectedSortBy} DESC`,this.pushQueryParam("sort",i)),i){const r=i.split(" ")[0];this.solrAPISetting.SolrBoostingConfig.ENABLEBOOSTING?this.getBoostingQuery(r,t,n):t.sort=i}},getAutoQueryType(){let n=this.getQueryParam("querytype");!n&&this.getQueryParam("q")&&this.pushQueryParam("querytype","exact")},getBoostingQuery(n,t,i){t.defType="edismax";t.bq=Object.entries(this.solrAPISetting.SolrBoosting).map(([n,t])=>n.startsWith("host")?`${n}^${t}`:`${n}:${i}^${t}`).join(" ");n.includes("header_date_publish-date")&&(t.bf=`recip(abs(ms(NOW/HOUR,${n})),3.16e-11,1000000000000,1)`)},pushQueryParam(n,t){const i=new URLSearchParams(window.location.search);n==="q"&&t.length>30&&(t=t.substring(0,30),console.warn(`Query parameter '${n}' truncated to: ${t}`));i.set(n,t);const r=`${window.location.pathname}?${i.toString()}`;window.history.pushState({path:r},"",r)},sanitizeHtml(n){const t=n.replace(new RegExp(this.getQueryParam("q"),"gi"),`<strong>${this.getQueryParam("q")}</strong>`);return DOMPurify.sanitize(t)},sanitizeInput(){this.autoCompleteInput=this.autoCompleteInput.replace(/[^a-zA-Z0-9 ]/g,"")},getQueryParam(n){const t=new URLSearchParams(window.location.search).get(n);return n==="q"&&t&&t.length>30?t.substring(0,30):t},updateFacetClassBasedOnQueryParam(n,t){const i=this.getQueryParam(n);if(i===null){document.querySelectorAll(`.${t}`).forEach(n=>{n.classList.remove(t)});const n=document.querySelector(".meta-facet-all-link");n&&n.classList.add(t)}},removeQueryParam(n){const i=new URL(window.location.href),t=new URLSearchParams(i.search);t.has(n)&&(t.delete(n),window.history.replaceState(null,null,i.pathname+"?"+t.toString()))},onDateChange(n,t){this.selectedDate=t},formatDate(n){if(!n)return"";if(this.solrAPISetting.SolrGlobalConfig.USDATEFORMAT){const t=new Date(n);return t.toISOString().split("T")[0]}else{const t=n.split("/");if(t.length===3){const r=`${t[2]}-${t[1]}-${t[0]}`,i=new Date(r);return isNaN(i.getTime())?(console.error("Invalid date:",n),""):i.toISOString().split("T")[0]}}},checkQueryTypeParameter(){let n=this.getQueryParam("q");return this.getQueryParam("querytype")=="exact"?n=`"${this.getQueryParam("q")}"`:this.getQueryParam("querytype")=="all"&&(n=this.getQueryParam("q")),n},updatePublishedButtonState(){const n=new Date(this.startDate),t=new Date(this.endDate);this.startDate&&this.endDate?t<n?(this.isDisabledPublishedDateCta=!0,this.dateError=!0):(this.isDisabledPublishedDateCta=!1,this.dateError=!1):(this.isDisabledPublishedDateCta=!0,this.dateError=!1)},bytesToSize(n){var t;return n===0?"0 Bytes":(t=parseInt(Math.floor(Math.log(n)/Math.log(1024))),Math.round(n/Math.pow(1024,t),2)+" "+["Bytes","KB","MB","GB","TB"][t])},formatPublishedDate(n){const t=this.solrAPISetting.SolrGlobalConfig.USDATEFORMAT?"en-US":"en-GB",i=new Date(n);return i.toLocaleDateString(t,{day:"2-digit",month:"short",year:"numeric"})},getFileImageUrl(n){if(n.solrdocumenttype==="File"){const t=n.absoluteurl.toLowerCase();if(t.includes(".pdf"))return this.solrAPISetting.SolrPresentationConfig.solrPDFimg;if(t.includes(".xls"))return this.solrAPISetting.SolrPresentationConfig.solrXLSimg;if(t.includes(".doc"))return this.solrAPISetting.SolrPresentationConfig.solrDOCimg;if(t.includes(".ppt"))return this.solrAPISetting.SolrPresentationConfig.solrPPTimg}return""},removeTagsFromString(n){return n.replace(/<[^>]+>/g,"")},removePrototypePollution(n){for(const t in n)n.hasOwnProperty(t)&&(t.includes("__proto__")||t.includes("prototype")||t.includes("constructor"))&&delete n[t]},removeEmptyObjects(n){for(const t in n)typeof n[t]=="object"&&Object.keys(n[t]).length===0&&delete n[t]},cleanURL(n){const t=new URL(n);let i=t.pathname.replace(/\/+/g,"/");const r=t.search;if(r){const u=decodeURIComponent(r),f=this.removeTagsFromString(u),n=Object.fromEntries(new URLSearchParams(f).entries());this.removePrototypePollution(n);this.removeEmptyObjects(n);const t=decodeURIComponent(new URLSearchParams(n).toString());t&&(i+="?"+t)}return i},cleanAndReplaceURL(){const i=window.location.href,t=new URL(i),n=new URLSearchParams(t.search);if(n.has("q")&&n.get("q").length>30){const t=n.get("q").substring(0,30);n.set("q",t);console.warn(`Query parameter 'q' truncated to: ${t}`)}const r=`${t.pathname}?${n.toString()}`;window.history.replaceState({},"",r)},initializeSwiper(){new Swiper(".swiper-container",{loop:!0,slidesPerView:this.displayMetaFacetNumber,spaceBetween:0,navigation:{nextEl:".swiper-button-next",prevEl:".swiper-button-prev"},breakpoints:{320:{slidesPerView:1},768:{slidesPerView:2},998:{slidesPerView:3},1200:{slidesPerView:this.displayMetaFacetNumber}}})}}}),svm=searchapp.mount("#searchapp")