(()=>{"use strict";const e=class{constructor(e,t=!1){this.element=e;const i=e?.getAttribute("data-menu-device");this.menuDevice=i,this.menu=e?.querySelector(`.ablocks-menu-${i}`),this.newMenu=this.menu?.cloneNode(!0),this.mainMenu=this.newMenu?.querySelector(".ablocks-main-menu"),this.initMenuTriggers(t),this.initMenuItems(t),this.editorDiv=document?.querySelector(".interface-navigable-region.interface-interface-skeleton__content"),this.menuLists=this.element.querySelectorAll(".ablocks-block--menu-item")}initMenuTriggers(e){const t=this.element?.querySelector(`.ablocks-menu-${this.menuDevice}__trigger`);this.toggleButton=t,t?.addEventListener("click",()=>this.toggleMenu(e))}initMenuItems(e){if(!e||!this.mainMenu)return;const t=this.mainMenu?.querySelectorAll(".ablocks-menu-item");t.forEach(e=>{e?.addEventListener("click",t=>{t.stopPropagation(),this.toggleMenuItem(e,t)})})}toggleMenuItem(e,t){t.target.closest(".ablocks-menu-child-mega")||e.classList.toggle("ablocks-sub-menu--active")}toggleMenu=e=>{const t=this.newMenu,i=this.toggleButton.getBoundingClientRect();e||this.menu.classList.toggle(`ablocks-menu-${this.menuDevice}--active`),t.style.position="absolute",t.style.top=`${i.bottom+window.scrollY}px`,t.style.right=window.innerWidth-i.right+"px",t.classList.add("ablocks-menu--outside"),t?.classList.toggle(`ablocks-menu-${this.menuDevice}--active`),e&&document.body.appendChild(t)};toggleSubMenu(e){e.classList.toggle("ablocks-menu-child-sub--active")}toggleMegaMenu(e,t){t.target.closest(".ablocks-menu-child-mega--active")||e.classList.toggle("ablocks-menu-child-mega--active")}handleListClick(e){const t=e.target.closest(".ablocks-block--menu-item");t&&(this.menuLists.forEach(e=>e.classList.remove("ablocks-block--menu-item-active")),t.classList.add("ablocks-block--menu-item-active"))}init(){this.menuLists.forEach(e=>{e.addEventListener("click",e=>{this.handleListClick(e)})})}};document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll(".ablocks-block--menu").forEach(t=>{new e(t,!0).init()})})})();