import{Component}from"@theme/component";import{trapFocus,removeTrapFocus}from"@theme/focus";import{onAnimationEnd}from"@theme/utilities";class HeaderDrawer extends Component{requiredRefs=["details"];connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this.#onKeyUp)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keyup",this.#onKeyUp)}#onKeyUp=event=>{event.key==="Escape"&&this.#close(this.#getDetailsElement(event))};get isOpen(){return this.refs.details.hasAttribute("open")}#getDetailsElement(event){return event?.target instanceof Element?event.target.closest("details")??this.refs.details:this.refs.details}toggle(){return this.isOpen?this.close():this.open()}open(event){const details=this.#getDetailsElement(event),summary=details.querySelector("summary");summary&&(summary.setAttribute("aria-expanded","true"),requestAnimationFrame(()=>details.classList.add("menu-open")),trapFocus(details))}back(event){this.#close(this.#getDetailsElement(event))}close(){this.#close(this.refs.details)}#close(details){const summary=details.querySelector("summary");summary&&(summary.setAttribute("aria-expanded","false"),details.classList.remove("menu-open"),onAnimationEnd(details,()=>{reset(details),details===this.refs.details?(removeTrapFocus(),this.querySelectorAll("details[open]").forEach(reset)):trapFocus(this.refs.details)}))}}customElements.get("header-drawer")||customElements.define("header-drawer",HeaderDrawer);function reset(element){element.classList.remove("menu-open"),element.removeAttribute("open"),element.querySelector("summary")?.setAttribute("aria-expanded","false")}
//# sourceMappingURL=/s/files/1/0677/1399/0759/t/1/assets/header-drawer.js.map?v=1783128500
