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 p="/de.search-data.json",f="%d results found",l=/<\/?(?:code|strong|em|span|a|p|br|div|ul|ol|li|h[1-6]|pre|blockquote|table|tr|td|th|thead|tbody|sup|sub|del|ins|img|hr|dl|dt|dd|figure|figcaption|section|nav|header|footer|main|article|aside|details|summary|mark|small|b|i|u|s|q|abbr|cite|dfn|kbd|samp|var|time|wbr)\b[^>]*>/gi;function e(e){if(!e)return"";e=e.replace(l," ");const t=document.createElement("textarea");return t.innerHTML=e,t.value.replace(/\s+/g," ").trim()}const u=document.querySelectorAll(".hextra-search-input");for(const e of u)e.addEventListener("focus",i),e.addEventListener("keyup",b),e.addEventListener("keydown",s),e.addEventListener("input",m);const g=document.querySelectorAll(".hextra-search-wrapper kbd");function a(e){g.forEach(t=>{t.style.opacity=e})}function m(e){const t=e.target.value.length>0?0:100;a(t)}function t(){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 d=["input","select","button","textarea"];document.addEventListener("keydown",function(e){const{inputElement:n}=t();if(!n)return;const s=document.activeElement,o=s&&s.tagName;if(n===s||!o||d.includes(o)||s&&s.isContentEditable)return;e.key==="/"||e.key==="k"&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),n.focus()):e.key==="Escape"&&n.value&&n.blur()}),document.addEventListener("mousedown",function(e){const{inputElement:o,resultsElement:s}=t();if(!o||!s)return;e.target!==o&&e.target!==s&&!s.contains(e.target)&&(a(100),n())});function o(){const{resultsElement:n}=t();if(!n)return{result:0[0],index:-1};const e=n.querySelector(".hextra-search-active");if(!e)return{result:0[0],index:-1};const s=parseInt(e.dataset.index,10);return{result:e,index:s}}function c(e){const{resultsElement:s}=t();if(!s)return;const{result:i}=o();i&&i.classList.remove("hextra-search-active");const n=s.querySelector(`[data-index="${e}"]`);n&&(n.classList.add("hextra-search-active"),n.focus())}function h(){const{resultsElement:e}=t();return e?e.dataset.count:0}function r(){const{inputElement:e}=t();if(!e)return;n(),e.value="",e.blur()}function n(){const{resultsElement:e}=t();if(!e)return;e.classList.add("hx:hidden")}function s(e){const{inputElement:s}=t();if(!s)return;const{result:a,index:i}=o(),l=h();switch(e.key){case"ArrowUp":e.preventDefault(),i>0&&c(i-1);break;case"ArrowDown":e.preventDefault(),i+1<l&&c(i+1);break;case"Enter":e.preventDefault(),a&&a.click(),r();case"Escape":e.preventDefault(),n(),s.value="",s.dispatchEvent(new Event("input")),s.blur();break}}function i(e){e.target.removeEventListener("focus",i),window.pageIndex&&window.sectionIndex||v()}async function v(){const s="forward",i=new RegExp(`[一-鿿぀-ゟ゠-ヿ가-힣㐀-䶿𠀀-𪛟𪜀-𫜿𫝀-𫠟𫠠-𬺯𬺰-𮯯𰀀-𱍏𱍐-𲎯𮯰-𮹟豈-﫿丽-𯨟]|[0-9A-Za-zа-яÀ-ſЀ-ӿ؀-ۿঀ-৿Ḁ-ỿ֐-׿-]+`,"mug"),o=e=>(""+e).toLowerCase().match(i)??[];window.pageIndex=new FlexSearch.Document({tokenize:s,encode:o,cache:100,document:{id:"id",store:["title","crumb"],index:"content"}}),window.sectionIndex=new FlexSearch.Document({tokenize:s,encode:o,cache:100,document:{id:"id",store:["title","content","url","display","crumb"],index:"content",tag:[{field:"pageId"}]}});const a=await fetch(p),t=await a.json();window.searchData=t,window.pageIdToRoute={};let n=0;for(const s in t){let r="";++n;const a=s.split("/").filter(e=>e!=""&&!e.startsWith("#"));let o="",i="/";for(let e=0;e<a.length;e++){const r=a[e];i+=r+"/";const c=t[i];if(!c){console.debug("Excluded page",i,"- will not be included for search result breadcrumb for",s);continue}let n=t[i].title;n=="_index"&&(n=r.split("-").map(e=>e).join(" ")),o+=n,e<a.length-1&&(o+=" > ")}for(const d in t[s].data){const[u,l]=d.split("#"),i=s.trimEnd("/")+(u?"#"+u:""),f=l&&e(l.replace(/HAHAHUGOSHORTCODE.*?HBHB/g,"")),a=e(f||t[s].title),h=t[s].data[d]||"",p=h.split(`
`).filter(Boolean),m=e(h),c=m.split(`
`).filter(Boolean);sectionIndex.add({id:i,url:i,title:a,crumb:o,pageId:`page_${n}`,content:a,...c[0]&&{display:c[0]}});for(let e=0;e<c.length;e++)sectionIndex.add({id:`${i}_${e}`,url:i,title:a,crumb:o,pageId:`page_${n}`,content:c[e]});r+=` ${a} ${m}`}window.pageIdToRoute[n]=s,window.pageIndex.add({id:n,title:e(t[s].title),crumb:o,content:r})}}function b(s){const i=s.target.value;if(!s.target.value){n();return}const{resultsElement:a}=t();for(;a.firstChild;)a.removeChild(a.firstChild);a.classList.remove("hx:hidden");const u=parseInt("20",10),o=i.toLowerCase(),c=[],r=window.pageIndex.search(i,u,{enrich:!0,suggest:!0})[0]?.result||[],l={};for(const e in window.pageIdToRoute)l[window.pageIdToRoute[e]]=Number(e);const d=new Set(r.map(e=>e.id));for(const s in window.searchData){const n=e(window.searchData[s].title||"");if(!n||!n.toLowerCase().includes(o))continue;const t=l[s];if(t==null||d.has(t))continue;d.add(t),r.push({id:t,doc:{title:n,crumb:""}})}for(let d=0;d<r.length;d++){const h=r[d],f=e(h.doc.title||""),g=h.doc.crumb||"";let n="",t="",l="",u=!1;const m=window.pageIdToRoute[h.id]||"",a=m?window.searchData[m]:null;if(a)for(const s in a.data){const[c,i]=s.split("#"),d=m.replace(/\/$/,"")+(c?"#"+c:""),h=i&&e(i.replace(/HAHAHUGOSHORTCODE.*?HBHB/g,"")),r=e(h||a.title);if(r.toLowerCase().includes(o)&&!u){n=r,t=d;const o=(a.data[s]||"").split(`
`).filter(Boolean);l=e(o[0]||"")}const f=e(a.data[s]||"").split(`
`).filter(Boolean);for(const e of f){const s=e.toLowerCase().indexOf(o);if(s!==-1){n=r,t=d;const i=Math.max(0,e.lastIndexOf(" ",Math.max(0,s-1))+1),a=Math.min(e.length,e.indexOf(". ",s+o.length)+1||e.length);l=(i>0?"…":"")+e.substring(i,a).trim(),u=!0;break}}if(u)break}if(!t){const s=window.sectionIndex.search(i,5,{enrich:!0,suggest:!0,tag:{pageId:`page_${h.id}`}})[0]?.result||[];if(s.length>0){const o=s[0].doc;n=e(o.title||""),t=o.url||"",l=e(o.display||o.content||"")}}const v=n&&n!==f?n:f,p=f.toLowerCase();let s=0;p===o?s=3:p.includes(o)&&(s=2),u&&(s+=1),t&&t.includes("/reference/")&&p!==o&&(s-=2),t&&t.includes("/changelog/")&&(s-=5),c.push({_boost:s,_page_rk:d,route:t||g,prefix:g,children:{title:v,content:l}})}const h=c.sort((e,t)=>e._boost!==t._boost?t._boost-e._boost:e._page_rk-t._page_rk).map((e)=>({id:`${e._page_rk}_0`,route:e.route,prefix:e.prefix,children:e.children}));j(h,i)}function j(e,n){const{resultsElement:o}=t();if(!o)return;if(!e.length){o.innerHTML=`<span class="hextra-search-no-result">No results found.</span>`;const e=o.closest(".hextra-search-wrapper"),t=e?e.querySelector(".hextra-search-status"):null;t&&(t.textContent="No results found.");return}function a(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=o.querySelector("a.hextra-search-active");e&&e.classList.remove("hextra-search-active"),t.classList.add("hextra-search-active")}}const i=document.createDocumentFragment();for(let c=0;c<e.length;c++){const o=e[c];if(o.prefix){const e=document.createElement("div");e.className="hextra-search-prefix",e.textContent=o.prefix,i.appendChild(e)}const l=document.createElement("li"),t=document.createElement("a");t.dataset.index=c,t.href=o.route,c===0&&t.classList.add("hextra-search-active");const u=document.createElement("div");if(u.className="hextra-search-title",a(u,o.children.title,n),t.appendChild(u),o.children.content){const e=document.createElement("div");e.className="hextra-search-excerpt",a(e,o.children.content,n),t.appendChild(e)}l.appendChild(t),l.addEventListener("mousemove",d),l.addEventListener("keydown",s),t.addEventListener("click",r),i.appendChild(l)}o.appendChild(i),o.dataset.count=e.length;const c=o.closest(".hextra-search-wrapper"),l=c?c.querySelector(".hextra-search-status"):null;l&&(l.textContent=e.length>0?f.replace("%d",e.length.toString()):"No results found.")}}()