document.addEventListener("DOMContentLoaded",function(){if(/iPad|iPhone|Macintosh/.test(navigator.userAgent)){const e=document.querySelectorAll(".hextra-search-wrapper kbd");e.forEach(e=>{e.innerHTML='<span class="hx:text-xs">⌘</span>K'})}}),function(){const f="/de.search-data.json",h="%d Ergebnisse gefunden",c=document.querySelectorAll(".hextra-search-input");for(const e of c)e.addEventListener("focus",o),e.addEventListener("keyup",g),e.addEventListener("keydown",i),e.addEventListener("input",m);const u=document.querySelectorAll(".hextra-search-wrapper kbd");function n(e){u.forEach(t=>{t.style.opacity=e})}function m(e){const t=e.target.value.length>0?0:100;n(t)}function e(){const e=Array.from(document.querySelectorAll(".hextra-search-wrapper")).filter(e=>e.clientHeight>0);return e.length===1?{wrapper:e[0],inputElement:e[0].querySelector(".hextra-search-input"),resultsElement:e[0].querySelector(".hextra-search-results")}:0[0]}const l=["input","select","button","textarea"];document.addEventListener("keydown",function(t){const{inputElement:n}=e();if(!n)return;const s=document.activeElement,o=s&&s.tagName;if(n===s||!o||l.includes(o)||s&&s.isContentEditable)return;t.key==="/"||t.key==="k"&&(t.metaKey||t.ctrlKey)?(t.preventDefault(),n.focus()):t.key==="Escape"&&n.value&&n.blur()}),document.addEventListener("mousedown",function(s){const{inputElement:i,resultsElement:o}=e();if(!i||!o)return;s.target!==i&&s.target!==o&&!o.contains(s.target)&&(n(100),t())});function s(){const{resultsElement:n}=e();if(!n)return{result:0[0],index:-1};const t=n.querySelector(".hextra-search-active");if(!t)return{result:0[0],index:-1};const s=parseInt(t.dataset.index,10);return{result:t,index:s}}function r(t){const{resultsElement:o}=e();if(!o)return;const{result:i}=s();i&&i.classList.remove("hextra-search-active");const n=o.querySelector(`[data-index="${t}"]`);n&&(n.classList.add("hextra-search-active"),n.focus())}function d(){const{resultsElement:t}=e();return t?t.dataset.count:0}function a(){const{inputElement:n}=e();if(!n)return;t(),n.value="",n.blur()}function t(){const{resultsElement:t}=e();if(!t)return;t.classList.add("hx:hidden")}function i(n){const{inputElement:o}=e();if(!o)return;const{result:c,index:i}=s(),l=d();switch(n.key){case"ArrowUp":n.preventDefault(),i>0&&r(i-1);break;case"ArrowDown":n.preventDefault(),i+1<l&&r(i+1);break;case"Enter":n.preventDefault(),c&&c.click(),a();case"Escape":n.preventDefault(),t(),o.value="",o.dispatchEvent(new Event("input")),o.blur();break}}function o(e){e.target.removeEventListener("focus",o),window.pageIndex&&window.sectionIndex||p()}async function p(){const n="forward",o=new RegExp(`[一-鿿぀-ゟ゠-ヿ가-힣㐀-䶿𠀀-𪛟𪜀-𫜿𫝀-𫠟𫠠-𬺯𬺰-𮯯𰀀-𱍏𱍐-𲎯𮯰-𮹟豈-﫿丽-𯨟]|[0-9A-Za-zа-яÀ-ſЀ-ӿ؀-ۿঀ-৿Ḁ-ỿ֐-׿]+`,"mug"),s=e=>(""+e).toLowerCase().match(o)??[];window.pageIndex=new FlexSearch.Document({tokenize:n,encode:s,cache:100,document:{id:"id",store:["title","crumb"],index:"content"}}),window.sectionIndex=new FlexSearch.Document({tokenize:n,encode:s,cache:100,document:{id:"id",store:["title","content","url","display","crumb"],index:"content",tag:[{field:"pageId"}]}});const i=await fetch(f),e=await i.json();let t=0;for(const n in e){let a="";++t;const i=n.split("/").filter(e=>e!=""&&!e.startsWith("#"));let s="",o="/";for(let t=0;t<i.length;t++){const r=i[t];o+=r+"/";const c=e[o];if(!c){console.debug("Excluded page",o,"- will not be included for search result breadcrumb for",n);continue}let a=e[o].title;a=="_index"&&(a=r.split("-").map(e=>e).join(" ")),s+=a,t<i.length-1&&(s+=" > ")}for(const c in e[n].data){const[l,u]=c.split("#"),o=n.trimEnd("/")+(l?"#"+l:""),i=u||e[n].title,d=e[n].data[c]||"",r=d.split(`
`).filter(Boolean);sectionIndex.add({id:o,url:o,title:i,crumb:s,pageId:`page_${t}`,content:i,...r[0]&&{display:r[0]}});for(let e=0;e<r.length;e++)sectionIndex.add({id:`${o}_${e}`,url:o,title:i,crumb:s,pageId:`page_${t}`,content:r[e]});a+=` ${i} ${d}`}window.pageIndex.add({id:t,title:e[n].title,crumb:s,content:a})}}function g(n){const i=n.target.value;if(!n.target.value){t();return}const{resultsElement:o}=e();for(;o.firstChild;)o.removeChild(o.firstChild);o.classList.remove("hx:hidden");const c=parseInt("20",10),l=parseInt("10",10),a=window.pageIndex.search(i,c,{enrich:!0,suggest:!0})[0]?.result||[],r=[],s={};for(let e=0;e<a.length;e++){const t=a[e];s[e]=0;const n=window.sectionIndex.search(i,{enrich:!0,suggest:!0,tag:{pageId:`page_${t.id}`}})[0]?.result||[];let o=!0;const c={},d=Math.min(n.length,l);for(let i=0;i<d;i++){const{doc:a}=n[i],h=a.display!==0[0];h&&s[e]++;const{url:l,title:m}=a,u=a.display||a.content;if(c[l+"@"+u])continue;c[l+"@"+u]=!0,r.push({_page_rk:e,_section_rk:i,route:l,prefix:o?t.doc.crumb:0[0],children:{title:m,content:u}}),o=!1}}const d=r.sort((e,t)=>e._page_rk===t._page_rk?e._section_rk-t._section_rk:s[e._page_rk]!==s[t._page_rk]?s[t._page_rk]-s[e._page_rk]:e._page_rk-t._page_rk).map(e=>({id:`${e._page_rk}_${e._section_rk}`,route:e.route,prefix:e.prefix,children:e.children}));v(d,i)}function v(t,n){const{resultsElement:s}=e();if(!s)return;if(!t.length){s.innerHTML=`<span class="hextra-search-no-result">Keine Ergebnisse gefunden.</span>`;const e=s.closest(".hextra-search-wrapper"),t=e?e.querySelector(".hextra-search-status"):null;t&&(t.textContent="Keine Ergebnisse gefunden.");return}function r(e,t,n){if(!t)return;if(!n){e.textContent=t;return}const i=n.replace(/[-\\^$*+?.()|[\]{}]/g,"\\$&");if(!i){e.textContent=t;return}const a=new RegExp(i,"gi");let o=0,s;for(;(s=a.exec(t))!==null;){s.index>o&&e.appendChild(document.createTextNode(t.slice(o,s.index)));const n=document.createElement("span");n.className="hextra-search-match",n.textContent=s[0],e.appendChild(n),o=s.index+s[0].length}o<t.length&&e.appendChild(document.createTextNode(t.slice(o)))}function d(e){const t=e.target.closest("a");if(t){const e=s.querySelector("a.hextra-search-active");e&&e.classList.remove("hextra-search-active"),t.classList.add("hextra-search-active")}}const o=document.createDocumentFragment();for(let c=0;c<t.length;c++){const s=t[c];if(s.prefix){const e=document.createElement("div");e.className="hextra-search-prefix",e.textContent=s.prefix,o.appendChild(e)}const l=document.createElement("li"),e=document.createElement("a");e.dataset.index=c,e.href=s.route,c===0&&e.classList.add("hextra-search-active");const u=document.createElement("div");if(u.className="hextra-search-title",r(u,s.children.title,n),e.appendChild(u),s.children.content){const t=document.createElement("div");t.className="hextra-search-excerpt",r(t,s.children.content,n),e.appendChild(t)}l.appendChild(e),l.addEventListener("mousemove",d),l.addEventListener("keydown",i),e.addEventListener("click",a),o.appendChild(l)}s.appendChild(o),s.dataset.count=t.length;const c=s.closest(".hextra-search-wrapper"),l=c?c.querySelector(".hextra-search-status"):null;l&&(l.textContent=t.length>0?h.replace("%d",t.length.toString()):"Keine Ergebnisse gefunden.")}}()