var module_106587573732=function(){var hsSearch=function(_instance){var func,wait,immediate,timeout,KEYS_TAB="Tab",KEYS_ESC="Esc",KEYS_ESCAPE="Escape",KEYS_UP="Up",KEYS_ARROW_UP="ArrowUp",KEYS_DOWN="Down",KEYS_ARROW_DOWN="ArrowDown",searchTerm="",searchForm=_instance,searchField=_instance.querySelector(".hs-search-field__input"),searchResults=_instance.querySelector(".hs-search-field__suggestions"),emptySearchResults=function(){searchResults.innerHTML="",searchField.focus(),searchForm.classList.remove("hs-search-field--open")},getSearchResults=function(){var request=new XMLHttpRequest,requestUrl="/_hcms/search?&term="+encodeURIComponent(searchTerm)+"&limit="+encodeURIComponent(3)+"&autocomplete=true&analytics=true&"+function(){for(var formParams=[],form=_instance.querySelector("form"),i=0;i<form.querySelectorAll("input[type=hidden]").length;i++){var e=form.querySelectorAll("input[type=hidden]")[i];"limit"!==e.name&&formParams.push(encodeURIComponent(e.name)+"="+encodeURIComponent(e.value))}return formParams.join("&")}();request.open("GET",requestUrl,!0),request.onload=function(){if(request.status>=200&&request.status<400){var data=JSON.parse(request.responseText);data.total>0?((items=[]).push("<li id='results-for'>Results for \""+(response=data).searchTerm+'"</li>'),response.results.forEach((function(val,index){items.push("<li id='result"+index+"'><a href='"+val.url+"'>"+val.title+"</a></li>")})),emptySearchResults(),searchResults.innerHTML=items.join(""),searchForm.classList.add("hs-search-field--open"),trapFocus()):emptySearchResults()}else console.error("Server reached, error retrieving results.");var response,items},request.onerror=function(){console.error("Could not reach the server.")},request.send()},trapFocus=function(){var tabbable=[];tabbable.push(searchField);for(var tabbables=searchResults.getElementsByTagName("A"),i=0;i<tabbables.length;i++)tabbable.push(tabbables[i]);var firstTabbable=tabbable[0],lastTabbable=tabbable[tabbable.length-1];searchForm.addEventListener("keydown",(function(e){switch(e.key){case KEYS_TAB:!function(e){e.target!=lastTabbable||e.shiftKey?e.target==firstTabbable&&e.shiftKey&&(e.preventDefault(),lastTabbable.focus()):(e.preventDefault(),firstTabbable.focus())}(e);break;case KEYS_ESC:case KEYS_ESCAPE:emptySearchResults();break;case KEYS_UP:case KEYS_ARROW_UP:!function(e){e.preventDefault(),e.target==firstTabbable?lastTabbable.focus():tabbable.forEach((function(el){el==e.target&&tabbable[tabbable.indexOf(el)-1].focus()}))}(e);break;case KEYS_DOWN:case KEYS_ARROW_DOWN:!function(e){e.preventDefault(),e.target==lastTabbable?firstTabbable.focus():tabbable.forEach((function(el){el==e.target&&tabbable[tabbable.indexOf(el)+1].focus()}))}(e)}}))},isSearchTermPresent=(func=function(){(searchTerm=searchField.value).length>2?getSearchResults():0==searchTerm.length&&emptySearchResults()},wait=250,function(){var context=this,args=arguments,callNow=immediate&&!timeout;clearTimeout(timeout),timeout=setTimeout((function(){timeout=null,immediate||func.apply(context,args)}),wait||200),callNow&&func.apply(context,args)});searchField.addEventListener("input",(function(e){searchTerm!=searchField.value&&isSearchTermPresent()}))};if(document.attachEvent?"complete"===document.readyState:"loading"!==document.readyState){var searchResults=document.querySelectorAll(".hs-search-field");Array.prototype.forEach.call(searchResults,(function(el){hsSearch(el)}))}else document.addEventListener("DOMContentLoaded",(function(){var searchResults=document.querySelectorAll(".hs-search-field");Array.prototype.forEach.call(searchResults,(function(el){hsSearch(el)}))}))}();