1class PredictiveSearch extends HTMLElement{constructor(){super()}debounce(fn,wait){const that=this;let t;return(...args)=>{clearTimeout(t),t=setTimeout(()=>fn.apply(that,args),wait)}}setEventListeners(){const resouce_tab_titles=this.querySelectorAll(".resource-tab-title"),resouce_tab_contents=this.querySelectorAll(".resource-tab-content");resouce_tab_titles.forEach(tab_title=>{tab_title.addEventListener("click",event=>{const for_attrib=tab_title.getAttribute("for"),content=this.querySelector(`#${for_attrib}`);resouce_tab_contents.forEach(tab_content=>{tab_content.classList.remove("active")}),resouce_tab_titles.forEach(other_tab_title=>{other_tab_title.classList.remove("active")}),content?.classList.add("active"),tab_title.classList.add("active"),window.dispatchEvent(new CustomEvent("predictive-search:updated"))})})}connectedCallback(){const that=this;this.searchForm=document.querySelector(`#${this.getAttribute("for")}`),this.searchInput=this.searchForm.querySelector('[name="q"]'),this.form=this.querySelector("form"),this.predictiveSearchInput=this.form.querySelector('[name="q"]'),this.searchInput.addEventListener("input",this.debounce(this.updatePrediction.bind(this),300)),this.updatePrediction()}updatePrediction(){const that=this;this.predictiveSearchInput.value=this.searchInput.value;const fetchURL=new URL(this.form.action);this.isDrawer=!1,fetchURL.search=="?is_drawer"&&(this.isDrawer=!0);const formData=new FormData(this.form),searchParams=new URLSearchParams(formData);let requestResponse=null;if(searchParams.get("q")&&searchParams.get("q")!=="")fetchURL.search=searchParams.toString(),fetch(fetchURL.href).then(response=>(requestResponse=response,response.text())).then(text=>{if(!requestResponse.ok)throw new Error(`${requestResponse.status}: ${text}`);const template=document.createElement("template");template.innerHTML=text.trim();const oldPredictiveSearch=that.querySelector(`${this.isDrawer?".predictive-search-results--drawer":".predictive-search-results--desktop"}`),newPredictiveSearch=template.content.querySelector(`predictive-search ${this.isDrawer?".predictive-search-results--drawer":".predictive-search-results--desktop"}`);oldPredictiveSearch.replaceWith(newPredictiveSearch),that.setEventListeners.bind(that)(),window.dispatchEvent(new CustomEvent("predictive-search:updated"))}).catch(error=>{console.error(error)});else{const initial_view=this.querySelector(".predictive-search-initial"),no_results_view=this.querySelector(".predictive-search-no-results"),results_view=this.querySelector(".predictive-search-tabs");initial_view?.classList.remove("hidden"),no_results_view?.classList.add("hidden"),results_view?.classList.add("hidden"),window.dispatchEvent(new CustomEvent("predictive-search:updated"))}}}customElements.define("predictive-search",PredictiveSearch); 2//# sourceMappingURL=/cdn/shop/t/676/assets/predictive-search-component.js.map?v=22728313339358598011756296077
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.