document.addEventListener("DOMContentLoaded",()=>{const e=window.location.origin;document.querySelectorAll(".scn-nav__link").forEach(t=>{const n=t.getAttribute("href")||"";if(!n||n.startsWith("#")||n.startsWith("mailto:")||n.startsWith("tel:"))return;let r=!1;try{r=new URL(n,e).origin!==e}catch(e){}if(r){t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer"),t.classList.add("scn-nav__link--external");const e=document.createElement("span");for(e.className="scn-nav__label";t.firstChild;)e.appendChild(t.firstChild);t.appendChild(e);const n=document.createElement("span");n.className="screen-reader-text",n.textContent=" (opens in a new tab)",e.appendChild(n);const r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("class","scn-nav__icon scn-nav__icon--external"),r.setAttribute("viewBox","0 0 24 24"),r.setAttribute("fill","none"),r.setAttribute("stroke","currentColor"),r.setAttribute("stroke-width","1.5"),r.setAttribute("stroke-linecap","round"),r.setAttribute("stroke-linejoin","round"),r.setAttribute("aria-hidden","true"),r.setAttribute("focusable","false"),r.innerHTML='<line x1="7" y1="17" x2="17" y2="7"/><polyline points="7 7 17 7 17 17"/>',e.appendChild(r)}}),document.querySelectorAll(".scn-nav__trigger--l1").forEach(e=>{e.addEventListener("click",()=>{const t="true"===e.getAttribute("aria-expanded"),n=document.getElementById(e.getAttribute("aria-controls"));e.setAttribute("aria-expanded",String(!t)),n&&(n.hidden=t),e.closest(".scn-nav__item--l1").classList.toggle("is-open",!t)})}),document.querySelectorAll(".scn-nav__trigger--l2").forEach(e=>{e.addEventListener("click",()=>{const t="true"===e.getAttribute("aria-expanded"),n=document.getElementById(e.getAttribute("aria-controls"));e.setAttribute("aria-expanded",String(!t)),n&&(n.hidden=t),e.closest(".scn-nav__item--l2").classList.toggle("is-open",!t)})}),document.querySelectorAll(".scn-block").forEach(e=>{const t=e.querySelector(".scn-filter__input");if(!t)return;const n=e.querySelector(".scn-filter__status"),r=e.querySelectorAll(".scn-nav__item"),s=Array.from(r).filter(e=>!e.querySelector(":scope > .scn-nav__children")),i=new Map;r.forEach(e=>{const t=e.querySelector(":scope > .scn-nav__link, :scope > .scn-nav__trigger"),n=(t?.textContent||"").trim().toLowerCase(),r=e.querySelector(":scope > .scn-nav__children"),s=e.querySelector(":scope > .scn-nav__trigger");i.set(e,{text:n,wasOpen:e.classList.contains("is-open"),childrenHidden:r?r.hidden:null,triggerExpanded:s?s.getAttribute("aria-expanded"):null})});let c=null;const o=t=>{const o=t.trim().toLowerCase();if(o.length<3)return r.forEach(e=>{const t=i.get(e);e.classList.remove("is-hidden"),e.classList.toggle("is-open",t.wasOpen);const n=e.querySelector(":scope > .scn-nav__children");n&&null!==t.childrenHidden&&(n.hidden=t.childrenHidden);const r=e.querySelector(":scope > .scn-nav__trigger");r&&null!==t.triggerExpanded&&r.setAttribute("aria-expanded",t.triggerExpanded)}),e.classList.remove("is-filter-empty"),void(n&&(n.textContent=""));const a=new Set;r.forEach(e=>{i.get(e).text.includes(o)&&a.add(e)});const l=e=>{let t=0,n=e.parentElement?.closest(".scn-nav__item");for(;n;)t++,n=n.parentElement?.closest(".scn-nav__item");return t};Array.from(r).filter(e=>!!e.querySelector(":scope > .scn-nav__children")).sort((e,t)=>l(t)-l(e)).forEach(e=>{const t=e.querySelector(":scope > .scn-nav__children");Array.from(t.querySelectorAll(".scn-nav__item")).some(e=>a.has(e))||a.delete(e)}),a.forEach(e=>{let t=e.parentElement?.closest(".scn-nav__item");for(;t;)a.add(t),t=t.parentElement?.closest(".scn-nav__item")}),r.forEach(e=>{const t=a.has(e);if(e.classList.toggle("is-hidden",!t),t){const t=e.querySelector(":scope > .scn-nav__children"),n=e.querySelector(":scope > .scn-nav__trigger");t&&(t.hidden=!1),n&&n.setAttribute("aria-expanded","true"),e.classList.add("is-open")}});const d=s.filter(e=>a.has(e)).length;var u;e.classList.toggle("is-filter-empty",0===d),u=0===d?"No matches found.":1===d?"1 result.":`${d} results.`,n&&(clearTimeout(c),c=setTimeout(()=>{n.textContent="",requestAnimationFrame(()=>{n.textContent=u})},300))};t.addEventListener("input",e=>o(e.target.value)),t.addEventListener("keydown",e=>{"Escape"===e.key&&(t.value="",o(""))})})});