accessible-menu-bootstrap-5
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -1,3 +0,3 @@ | ||
"use strict";var K=Object.defineProperty;var V=(n,e,t)=>e in n?K(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var r=(n,e,t)=>(V(n,typeof e!="symbol"?e+"":e,t),t);function m(n,e){typeof n=="string"?e.classList.add(n):e.classList.add(...n)}function d(n,e){typeof n=="string"?e.classList.remove(n):e.classList.remove(...n)}function v(n,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof n)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${n.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function c(n,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==n)throw new TypeError(`${t} must be a ${n}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function A(n){try{if(typeof n!="object"){const e=typeof n;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${e}" given.`)}for(const e in n)try{if(n[e]===null)throw new Error;document.querySelector(n[e])}catch{throw new TypeError(`${e} must be a valid query selector. "${n[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function g(n){try{if(typeof n!="object"||Array.isArray(n)){const e=typeof n;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in n){const t=typeof n[e];if(t!=="string")if(Array.isArray(n[e]))n[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=n[e],A(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function B(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function H(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function O(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function P(n,e){if(c("string",{tagName:n}).status&&v(HTMLElement,e).status){const t=n.toLowerCase();let s=!0;for(const i in e)e[i].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class F{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i=null}){r(this,"_dom",{toggle:null,parent:null});r(this,"_elements",{controlledMenu:null,parentMenu:null});r(this,"_open",!1);r(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));r(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=i}initialize(){this._setIds(),this._setAriaAttributes(),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){c("boolean",{value:e}),this._open=e}_setIds(){var e;if(this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",i=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),i=`${s}-${i}`),this.dom.toggle.id=this.dom.toggle.id||`menu-button-${i}`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`menu-${i}`}}_setAriaAttributes(){this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),P("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id)}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),i!==""?(m(i,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&d(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&m(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{d(i,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&m(s,this.elements.controlledMenu.dom.menu),t!==""&&d(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),i!==""?(m(i,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&d(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&m(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{d(i,this.elements.controlledMenu.dom.menu)})})})):(t!==""&&m(t,this.elements.controlledMenu.dom.menu),s!==""&&d(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class x{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:o=null,toggle:l=null}){r(this,"_dom",{item:null,link:null});r(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});r(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=o,this._elements.toggle=l,this._submenu=i}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function w(n){try{const e=n.key||n.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function a(n){n.preventDefault(),n.stopPropagation()}class D{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:i="",submenuToggleSelector:o="a",submenuSelector:l="ul",controllerElement:h=null,containerElement:f=null,openClass:u="show",closeClass:_="hide",transitionClass:y="transitioning",isTopLevel:p=!0,parentMenu:b=null,hoverType:C="off",hoverDelay:E=250,enterDelay:M=-1,leaveDelay:T=-1}){r(this,"_MenuType",D);r(this,"_MenuItemType",x);r(this,"_MenuToggleType",F);r(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});r(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});r(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});r(this,"_openClass","show");r(this,"_closeClass","hide");r(this,"_transitionClass","transitioning");r(this,"_root",!0);r(this,"_currentChild",0);r(this,"_focusState","none");r(this,"_currentEvent","none");r(this,"_hoverType","off");r(this,"_hoverDelay",250);r(this,"_enterDelay",-1);r(this,"_leaveDelay",-1);r(this,"_hoverTimeout",null);r(this,"_errors",[]);this._dom.menu=e,this._dom.controller=h,this._dom.container=f,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=i,this._selectors.submenuToggles=o,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=b,this._elements.rootMenu=p?this:null,this._openClass=u||"",this._closeClass=_||"",this._transitionClass=y||"",this._root=p,this._hoverType=C,this._hoverDelay=E,this._enterDelay=M,this._leaveDelay=T}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
"use strict";var U=Object.defineProperty;var Z=(n,e,t)=>e in n?U(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var r=(n,e,t)=>Z(n,typeof e!="symbol"?e+"":e,t);function a(n,e){n===""||n.length===0||(typeof n=="string"?e.classList.add(n):e.classList.add(...n))}function m(n,e){n===""||n.length===0||(typeof n=="string"?e.classList.remove(n):e.classList.remove(...n))}function k(n,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof n)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${n.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function u(n,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==n)throw new TypeError(`${t} must be a ${n}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function x(n){try{if(typeof n!="object"){const e=typeof n;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${e}" given.`)}for(const e in n)try{if(n[e]===null)throw new Error;document.querySelector(n[e])}catch{throw new TypeError(`${e} must be a valid query selector. "${n[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function C(n){try{if(typeof n!="object"||Array.isArray(n)){const e=typeof n;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in n){const t=typeof n[e];if(t!=="string")if(Array.isArray(n[e]))n[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=n[e],x(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function Q(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function W(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function z(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function j(n,e){if(u("string",{tagName:n}).status&&k(HTMLElement,e).status){const t=n.toLowerCase();let s=!0;for(const i in e)e[i].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class K{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i=null}){r(this,"_dom",{toggle:null,parent:null});r(this,"_elements",{controlledMenu:null,parentMenu:null});r(this,"_open",!1);r(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));r(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=i}initialize(){this._setIds(),this._setAriaAttributes(),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){u("boolean",{value:e}),this._open=e}_setIds(){var e;if(this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",i=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),i=`${s}-${i}`),this.dom.toggle.id=this.dom.toggle.id||`menu-button-${i}`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`menu-${i}`}}_setAriaAttributes(){this.dom.toggle.setAttribute("aria-expanded","false"),this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id)}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:i,openDuration:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),this.elements.controlledMenu.elements.rootMenu.hasOpened=!0,i!==""?(a(i,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{m(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{a(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{setTimeout(()=>{m(i,this.elements.controlledMenu.dom.menu)},o)})})})):(a(s,this.elements.controlledMenu.dom.menu),m(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:i,closeDuration:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),i!==""?(a(i,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{m(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{a(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{setTimeout(()=>{m(i,this.elements.controlledMenu.dom.menu)},o)})})})):(a(t,this.elements.controlledMenu.dom.menu),m(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this.isOpen||(this._expand(),this.isOpen=!0)}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this.isOpen||(this._expand(),this.isOpen=!0)}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class V{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:o=null,toggle:l=null}){r(this,"_dom",{item:null,link:null});r(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});r(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=o,this._elements.toggle=l,this._submenu=i}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&requestAnimationFrame(()=>{this.dom.link.focus()})}blur(){this.elements.parentMenu.shouldFocus&&requestAnimationFrame(()=>{this.dom.link.blur()})}}function A(n){try{const e=n.key||n.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function d(n){n.preventDefault(),n.stopPropagation()}class L{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:i="li:has(ul)",submenuToggleSelector:o="a",submenuSelector:l="ul",controllerElement:h=null,containerElement:p=null,openClass:f="show",closeClass:g="hide",transitionClass:_="transitioning",transitionDuration:y=250,openDuration:c=-1,closeDuration:E=-1,isTopLevel:b=!0,parentMenu:T=null,hoverType:M="off",hoverDelay:D=250,enterDelay:v=-1,leaveDelay:w=-1,prefix:S="am-"}){r(this,"_MenuType",L);r(this,"_MenuItemType",V);r(this,"_MenuToggleType",K);r(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});r(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});r(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});r(this,"_openClass","show");r(this,"_closeClass","hide");r(this,"_transitionClass","transitioning");r(this,"_transitionDuration",250);r(this,"_openDuration",-1);r(this,"_closeDuration",-1);r(this,"_root",!0);r(this,"_currentChild",0);r(this,"_focusState","none");r(this,"_currentEvent","none");r(this,"_hoverType","off");r(this,"_hoverDelay",250);r(this,"_enterDelay",-1);r(this,"_leaveDelay",-1);r(this,"_prefix","am-");r(this,"_hoverTimeout",null);r(this,"_hasOpened",!1);r(this,"_errors",[]);this._dom.menu=e,this._dom.controller=h,this._dom.container=p,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=i,this._selectors.submenuToggles=o,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=T,this._elements.rootMenu=b?this:null,this._openClass=f||"",this._closeClass=g||"",this._transitionClass=_||"",this._transitionDuration=y,this._openDuration=c,this._closeDuration=E,this._prefix=S||"",this._root=b,this._hoverType=M,this._hoverDelay=D,this._enterDelay=v,this._leaveDelay=w}initialize(){if(!this._validate())throw new Error(`AccessibleMenu: cannot initialize menu. The following errors have been found: | ||
- ${this.errors.join(` | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){g({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set currentChild(e){c("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let o=0,l=!1;for(;!l&&o<s.elements.parentMenu.elements.menuItems.length;){const h=s.elements.parentMenu.elements.menuItems[o];h.isSubmenuItem&&h.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=o),o++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){B({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){H({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){O({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){c("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){c("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){c("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=v(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=v(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=A({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=A({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const u=g({openClass:this._openClass});u.status||(this._errors.push(u.error.message),e=!1)}if(this._closeClass!==""){const u=g({closeClass:this._closeClass});u.status||(this._errors.push(u.error.message),e=!1)}if(this._transitionClass!==""){const u=g({transitionClass:this._transitionClass});u.status||(this._errors.push(u.error.message),e=!1)}const i=c("boolean",{isTopLevel:this._root});if(i.status||(this._errors.push(i.error.message),e=!1),this._elements.parentMenu!==null){const u=v(D,{parentMenu:this._elements.parentMenu});u.status||(this._errors.push(u.error.message),e=!1)}const o=O({hoverType:this._hoverType});o.status||(this._errors.push(o.error.message),e=!1);const l=c("number",{hoverDelay:this._hoverDelay});l.status||(this._errors.push(l.error.message),e=!1);const h=c("number",{enterDelay:this._enterDelay});h.status||(this._errors.push(h.error.message),e=!1);const f=c("number",{leaveDelay:this._leaveDelay});return f.status||(this._errors.push(f.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&v(HTMLElement,{base:t});const o=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=o:this._dom[e]=[...this._dom[e],...o]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),i=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:i,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,i){a(i),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",i=>{this.currentEvent="mouse",e(this,t.elements.toggle,i)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t),e.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview());else if(this.hoverType==="dynamic"){const i=this.elements.submenuToggles.some(o=>o.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||i)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&a(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&(a(e),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class z extends x{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:o=null,toggle:l=null,initialize:h=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i,childMenu:o,toggle:l}),h&&this.initialize()}}class j extends F{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i=null,initialize:o=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i}),o&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class L extends D{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:i="a",submenuItemSelector:o="",submenuToggleSelector:l="button",submenuSelector:h="ul",controllerElement:f=null,containerElement:u=null,openClass:_="show",closeClass:y="hide",transitionClass:p="transitioning",isTopLevel:b=!0,parentMenu:C=null,hoverType:E="off",hoverDelay:M=250,enterDelay:T=-1,leaveDelay:S=-1,optionalKeySupport:k=!1,initialize:I=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:i,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:h,controllerElement:f,containerElement:u,openClass:_,closeClass:y,transitionClass:p,isTopLevel:b,parentMenu:C,hoverType:E,hoverDelay:M,enterDelay:T,leaveDelay:S});r(this,"_MenuType",L);r(this,"_MenuItemType",z);r(this,"_MenuToggleType",j);r(this,"_currentChild",-1);r(this,"_optionalSupport",!1);this._optionalSupport=k,I&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(t){c("boolean",{optionalKeySupport:t}),this._optionalSupport=t}_validate(){let t=super._validate();const s=c("boolean",{optionalKeySupport:this._optionalSupport});return s.status||(this._errors.push(s.error.message),t=!1),t}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=w(t);if(this.focusState==="self"){const i=["Space","Enter"],o=["Escape"],l=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&a(t):(this.currentMenuItem.isSubmenuItem&&i.includes(s)||this.elements.controller&&o.includes(s)||this.elements.parentMenu&&l.includes(s))&&a(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=w(t);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(a(t),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(o=>o.isOpen)?(a(t),this.closeChildren()):this.elements.parentMenu?(a(t),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.closeChildren(),this.elements.parentMenu.focusCurrentChild()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(a(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(a(t),this.focusPreviousChild()):s==="Home"?(a(t),this.focusFirstChild()):s==="End"&&(a(t),this.focusLastChild())))})}}class R extends z{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:o=null,toggle:l=null,initialize:h=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i,childMenu:o,toggle:l,initialize:!1}),h&&this.initialize()}}class U extends j{constructor({menuToggleElement:t,parentElement:s,controlledMenu:i,parentMenu:o=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:i,parentMenu:o,initialize:!1});r(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=i.isTopLevel?i.dom.container:i.dom.menu,l&&this.initialize()}_expand(t=!0){const{openClass:s,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),i!==""?(m(i,this.dom.container),requestAnimationFrame(()=>{m(s,this.dom.container),requestAnimationFrame(()=>{d(i,this.dom.container)})})):s!==""&&m(s,this.dom.container),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:i,transitionClass:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),o!==""?(m(o,this.dom.container),requestAnimationFrame(()=>{i!==""&&d(i,this.dom.container),requestAnimationFrame(()=>{s!==""&&m(s,this.dom.container),requestAnimationFrame(()=>{d(o,this.dom.container)})})})):(s!==""&&m(s,this.dom.container),i!==""&&d(i,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class $ extends L{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:i=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:h=".dropdown-menu",controllerElement:f=null,containerElement:u=null,openClass:_="show",closeClass:y="collapse",transitionClass:p="transitioning",isTopLevel:b=!0,parentMenu:C=null,hoverType:E="off",hoverDelay:M=250,enterDelay:T=-1,leaveDelay:S=-1,optionalKeySupport:k=!1,disableBootstrap:I=!0,initialize:q=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:i,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:h,controllerElement:f,containerElement:u,openClass:_,closeClass:y,transitionClass:p,isTopLevel:b,parentMenu:C,hoverType:E,hoverDelay:M,enterDelay:T,leaveDelay:S,optionalKeySupport:k,initialize:!1});r(this,"_MenuType",$);r(this,"_MenuItemType",R);r(this,"_MenuToggleType",U);r(this,"_disableBootstrap",!0);r(this,"_pseudoDropdownElement",document.createElement("div"));r(this,"_bootstrapEvents",["show.bs.dropdown","shown.bs.dropdown","hide.bs.dropdown","hidden.bs.dropdown"]);this._disableBootstrap=I,q&&this.initialize()}initialize(){super.initialize(),this.bootstrapDisabled&&this._disableBootstrapDropdownBehaviour()}get bootstrapDisabled(){return this._disableBootstrap}get bootstrapPseudoDropdownElement(){return this._pseudoDropdownElement}get bootstrapEvents(){return this._bootstrapEvents}_validate(){let t=super._validate();const s=c("boolean",{disableBootstrap:this._disableBootstrap});return s.status||(this._errors.push(s.error.message),t=!1),t}_disableBootstrapDropdownBehaviour(){this.elements.submenuToggles.forEach(t=>{this.bootstrapEvents.forEach(s=>{t.dom.toggle.addEventListener(s,i=>{a(i);const o=bootstrap.Dropdown.getInstance(i.target);o&&o._menu!==this.bootstrapPseudoDropdownElement&&(o._menu=this.bootstrapPseudoDropdownElement)},{once:!0})})})}}module.exports=$; | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});j("button",{toggle:e.dom.toggle})||e.dom.toggle.setAttribute("role","button"),e.dom.toggle.setAttribute("aria-controls",this.dom.menu.id),this._elements.controller=e}this._createChildElements(),this._setTransitionDurations(),this.isTopLevel&&(window.AccessibleMenu=window.AccessibleMenu||{menus:{}},window.AccessibleMenu.menus[this.dom.menu.id]=this)}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get transitionDuration(){return this.isTopLevel?this._transitionDuration:this.elements.rootMenu.transitionDuration}get openDuration(){return this._openDuration===-1?this.transitionDuration:this.isTopLevel?this._openDuration:this.elements.rootMenu.openDuration}get closeDuration(){return this._closeDuration===-1?this.transitionDuration:this.isTopLevel?this._closeDuration:this.elements.rootMenu.closeDuration}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get prefix(){return this._root?this._prefix:this.elements.rootMenu.prefix}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get hasOpened(){return this._root?this._hasOpened:this.elements.rootMenu.hasOpened}get errors(){return this._errors}set openClass(e){C({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){C({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){C({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set transitionDuration(e){u("number",{value:e}),this._transitionDuration!==e&&(this._transitionDuration=e,this._setTransitionDurations())}set openDuration(e){u("number",{value:e}),this._openDuration!==e&&(this._openDuration=e,this._setTransitionDurations())}set closeDuration(e){u("number",{value:e}),this._closeDuration!==e&&(this._closeDuration=e,this._setTransitionDurations())}set currentChild(e){u("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let o=0,l=!1;for(;!l&&o<s.elements.parentMenu.elements.menuItems.length;){const h=s.elements.parentMenu.elements.menuItems[o];h.isSubmenuItem&&h.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=o),o++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){Q({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){W({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){z({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){u("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){u("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){u("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}set prefix(e){u("string",{value:e}),this._prefix!==e&&(this._prefix=e)}set hasOpened(e){u("boolean",{value:e}),this._hasOpened!==e&&(this._hasOpened=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=k(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=k(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=x({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=x({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const c=C({openClass:this._openClass});c.status||(this._errors.push(c.error.message),e=!1)}if(this._closeClass!==""){const c=C({closeClass:this._closeClass});c.status||(this._errors.push(c.error.message),e=!1)}if(this._transitionClass!==""){const c=C({transitionClass:this._transitionClass});c.status||(this._errors.push(c.error.message),e=!1)}const i=u("number",{transitionDuration:this._transitionDuration});i.status||(this._errors.push(i.error.message),e=!1);const o=u("number",{openDuration:this._openDuration});o.status||(this._errors.push(o.error.message),e=!1);const l=u("number",{closeDuration:this._closeDuration});l.status||(this._errors.push(l.error.message),e=!1);const h=u("boolean",{isTopLevel:this._root});if(h.status||(this._errors.push(h.error.message),e=!1),this._elements.parentMenu!==null){const c=k(L,{parentMenu:this._elements.parentMenu});c.status||(this._errors.push(c.error.message),e=!1)}const p=z({hoverType:this._hoverType});p.status||(this._errors.push(p.error.message),e=!1);const f=u("number",{hoverDelay:this._hoverDelay});f.status||(this._errors.push(f.error.message),e=!1);const g=u("number",{enterDelay:this._enterDelay});g.status||(this._errors.push(g.error.message),e=!1);const _=u("number",{leaveDelay:this._leaveDelay});_.status||(this._errors.push(_.error.message),e=!1);const y=u("string",{prefix:this._prefix});return y.status||(this._errors.push(y.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&k(HTMLElement,{base:t});const o=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=o:this._dom[e]=[...this._dom[e],...o]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),i=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:i,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,transitionDuration:this.transitionDuration,openDuration:this.openDuration,closeDuration:this.closeDuration,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_clearTimeout(){clearTimeout(this._hoverTimeout)}_setTimeout(e,t){u("function",{callback:e}),u("number",{delay:t}),this._hoverTimeout=setTimeout(e,t)}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})}),this.dom.menu.addEventListener("focusout",e=>{this.currentEvent!=="keyboard"||e.relatedTarget===null||this.dom.menu.contains(e.relatedTarget)||(this.focusState="none",this.closeChildren())})}_handleClick(){function e(t,s,i){d(i),i.button===0&&(s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none"))}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this._clearTimeout(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",i=>{this.currentEvent="mouse",e(this,t.elements.toggle,i)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)}),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.elements.rootMenu.hasOpened=this.elements.submenuToggles.some(s=>s.isOpen)))})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t),e.isSubmenuItem&&(this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay)):e.elements.toggle.preview())):this.hoverType==="dynamic"&&(this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),(!this.isTopLevel||this.hasOpened)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),e.isSubmenuItem?this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay)):e.elements.toggle.preview():this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.closeChildren()},this.enterDelay)):this.closeChildren())))}),e.isSubmenuItem&&(e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse"},this.leaveDelay)):this.currentEvent="mouse"))}),e.dom.item.addEventListener("pointerenter",s=>{s.pointerType==="pen"||s.pointerType==="touch"||e.isSubmenuItem&&(this.hoverType==="on"||this.hoverType==="dynamic")&&this.leaveDelay>0&&this._clearTimeout()}))})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=A(e);(t==="Space"||t==="Enter")&&d(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=A(e);(t==="Space"||t==="Enter")&&(d(e),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}_setTransitionDurations(){this.dom.menu.style.setProperty(`--${this.prefix}transition-duration`,`${this.transitionDuration}ms`),this.dom.menu.style.setProperty(`--${this.prefix}open-transition-duration`,`${this.openDuration}ms`),this.dom.menu.style.setProperty(`--${this.prefix}close-transition-duration`,`${this.closeDuration}ms`)}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class P extends V{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:o=null,toggle:l=null,initialize:h=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i,childMenu:o,toggle:l}),h&&this.initialize()}}class B extends K{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i=null,initialize:o=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i}),o&&this.initialize()}_setAriaAttributes(){super._setAriaAttributes(),j("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id)}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class F extends L{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:i="a",submenuItemSelector:o="li:has(ul)",submenuToggleSelector:l="button",submenuSelector:h="ul",controllerElement:p=null,containerElement:f=null,openClass:g="show",closeClass:_="hide",transitionClass:y="transitioning",transitionDuration:c=250,openDuration:E=-1,closeDuration:b=-1,isTopLevel:T=!0,parentMenu:M=null,hoverType:D="off",hoverDelay:v=250,enterDelay:w=-1,leaveDelay:S=-1,optionalKeySupport:I=!1,prefix:$="am-",initialize:O=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:i,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:h,controllerElement:p,containerElement:f,openClass:g,closeClass:_,transitionClass:y,transitionDuration:c,openDuration:E,closeDuration:b,isTopLevel:T,parentMenu:M,hoverType:D,hoverDelay:v,enterDelay:w,leaveDelay:S,prefix:$});r(this,"_MenuType",F);r(this,"_MenuItemType",P);r(this,"_MenuToggleType",B);r(this,"_currentChild",-1);r(this,"_optionalSupport",!1);this._optionalSupport=I,O&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(t){u("boolean",{optionalKeySupport:t}),this._optionalSupport=t}_validate(){let t=super._validate();const s=u("boolean",{optionalKeySupport:this._optionalSupport});return s.status||(this._errors.push(s.error.message),t=!1),t}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close(),this.elements.rootMenu.hasOpened=!1))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=A(t);if(this.focusState==="self"){const i=["Space","Enter"],o=["Escape"],l=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&d(t):(this.currentMenuItem.isSubmenuItem&&i.includes(s)||this.elements.controller&&o.includes(s)||this.elements.parentMenu&&l.includes(s))&&d(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=A(t);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(d(t),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(o=>o.isOpen)?(d(t),this.closeChildren()):this.elements.parentMenu?(d(t),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.closeChildren(),this.elements.parentMenu.focusCurrentChild()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(d(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(d(t),this.focusPreviousChild()):s==="Home"?(d(t),this.focusFirstChild()):s==="End"&&(d(t),this.focusLastChild())))})}}class G extends P{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:o=null,toggle:l=null,initialize:h=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i,childMenu:o,toggle:l,initialize:!1}),h&&this.initialize()}}class J extends B{constructor({menuToggleElement:t,parentElement:s,controlledMenu:i,parentMenu:o=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:i,parentMenu:o,initialize:!1});r(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=i.isTopLevel?i.dom.container:i.dom.menu,l&&this.initialize()}initialize(){super.initialize(),this.elements.controlledMenu.bootstrapTransitions&&this.elements.controlledMenu.isTopLevel&&(this.dom.container.style.transition="height var(--am-transition-duration) ease")}_expand(t=!0){const{openClass:s,closeClass:i,transitionClass:o,openDuration:l,bootstrapTransitions:h,isTopLevel:p}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),this.elements.controlledMenu.elements.rootMenu.hasOpened=!0,o!==""?h?p?(a(o,this.dom.container),m(i,this.dom.container),this.dom.container.style.height=`${this.dom.container.scrollHeight}px`,requestAnimationFrame(()=>{setTimeout(()=>{a(s,this.dom.container),a(i,this.dom.container),m(o,this.dom.container),this.dom.container.style.height=""},l)})):(a(s,this.dom.container),m(i,this.dom.container)):(a(o,this.dom.container),requestAnimationFrame(()=>{m(i,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{setTimeout(()=>{m(o,this.dom.container)},l)})})})):(a(s,this.dom.container),m(i,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:i,transitionClass:o,closeDuration:l,bootstrapTransitions:h,isTopLevel:p}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),o!==""?h?p?(this.dom.container.style.height=`${this.dom.container.offsetHeight}px`,requestAnimationFrame(()=>{a(o,this.dom.container),requestAnimationFrame(()=>{m(i,this.dom.container),m(s,this.dom.container),this.dom.container.style.height="",requestAnimationFrame(()=>{setTimeout(()=>{m(o,this.dom.container),a(s,this.dom.container)},l)})})})):(a(s,this.dom.container),m(i,this.dom.container)):(a(o,this.dom.container),requestAnimationFrame(()=>{m(i,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{setTimeout(()=>{m(o,this.dom.container)},l)})})})):(a(s,this.dom.container),m(i,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class q extends F{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:i=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:h=".dropdown-menu",controllerElement:p=null,containerElement:f=null,openClass:g="show",closeClass:_="collapse",transitionClass:y="collapsing",transitionDuration:c=350,openDuration:E=-1,closeDuration:b=-1,isTopLevel:T=!0,parentMenu:M=null,hoverType:D="off",hoverDelay:v=250,enterDelay:w=-1,leaveDelay:S=-1,optionalKeySupport:I=!1,prefix:$="am-",bootstrapTransitions:O=!0,disableBootstrap:H=!0,initialize:R=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:i,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:h,controllerElement:p,containerElement:f,openClass:g,closeClass:_,transitionClass:y,transitionDuration:c,openDuration:E,closeDuration:b,isTopLevel:T,parentMenu:M,hoverType:D,hoverDelay:v,enterDelay:w,leaveDelay:S,optionalKeySupport:I,prefix:$,initialize:!1});r(this,"_MenuType",q);r(this,"_MenuItemType",G);r(this,"_MenuToggleType",J);r(this,"_disableBootstrap",!0);r(this,"_pseudoDropdownElement",document.createElement("div"));r(this,"_bootstrapDropdownEvents",["show.bs.dropdown","shown.bs.dropdown","hide.bs.dropdown","hidden.bs.dropdown"]);r(this,"_pseudoCollapseElement",document.createElement("div"));r(this,"_bootstrapCollapseEvents",["show.bs.collapse","shown.bs.collapse","hide.bs.collapse","hidden.bs.collapse"]);r(this,"_bootstrapTransitions",!0);this._disableBootstrap=H,this._bootstrapTransitions=O,R&&this.initialize()}initialize(){super.initialize(),this.bootstrapDisabled&&(this._disableBootstrapDropdownBehaviour(),this._disableBootstrapCollapseBehaviour())}get bootstrapTransitions(){return this.isTopLevel?this._bootstrapTransitions:this.elements.rootMenu.bootstrapTransitions}get bootstrapDisabled(){return this._disableBootstrap}get bootstrapPseudoDropdownElement(){return this._pseudoDropdownElement}get bootstrapDropdownEvents(){return this._bootstrapDropdownEvents}get bootstrapPseudoCollapseElement(){return this._pseudoCollapseElement}get bootstrapCollapseEvents(){return this._bootstrapCollapseEvents}_validate(){let t=super._validate();const s=u("boolean",{bootstrapTransitions:this._bootstrapTransitions});s.status||(this._errors.push(s.error.message),t=!1);const i=u("boolean",{disableBootstrap:this._disableBootstrap});return i.status||(this._errors.push(i.error.message),t=!1),t}_disableBootstrapDropdownBehaviour(){this.elements.submenuToggles.forEach(t=>{this.bootstrapDropdownEvents.forEach(s=>{t.dom.toggle.addEventListener(s,i=>{d(i);const o=bootstrap.Dropdown.getInstance(i.target);o&&o._menu!==this.bootstrapPseudoDropdownElement&&(o._menu=this.bootstrapPseudoDropdownElement)},{once:!0})})})}_disableBootstrapCollapseBehaviour(){this.elements.controller&&this.bootstrapCollapseEvents.forEach(t=>{this.dom.container.addEventListener(t,s=>{d(s);const i=bootstrap.Collapse.getInstance(s.target);i&&i._element!==this.bootstrapPseudoCollapseElement&&(i._element=this.bootstrapPseudoCollapseElement)},{once:!0})})}_setTransitionDurations(){super._setTransitionDurations(),this.isTopLevel&&this.elements.controller&&(this.elements.controller.dom.container.style.setProperty(`--${this.prefix}transition-duration`,`${this.transitionDuration}ms`),this.elements.controller.dom.container.style.setProperty(`--${this.prefix}open-transition-duration`,`${this.openDuration}ms`),this.elements.controller.dom.container.style.setProperty(`--${this.prefix}close-transition-duration`,`${this.closeDuration}ms`))}}module.exports=q; |
@@ -1,3 +0,3 @@ | ||
var Bootstrap5DisclosureMenu=function(){"use strict";var R=Object.defineProperty;var U=(u,h,f)=>h in u?R(u,h,{enumerable:!0,configurable:!0,writable:!0,value:f}):u[h]=f;var r=(u,h,f)=>(U(u,typeof h!="symbol"?h+"":h,f),f);function u(i,e){typeof i=="string"?e.classList.add(i):e.classList.add(...i)}function h(i,e){typeof i=="string"?e.classList.remove(i):e.classList.remove(...i)}function f(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function d(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function S(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid query selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function g(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],S(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function q(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function K(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function O(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function V(i,e){if(d("string",{tagName:i}).status&&f(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class F{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){r(this,"_dom",{toggle:null,parent:null});r(this,"_elements",{controlledMenu:null,parentMenu:null});r(this,"_open",!1);r(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));r(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){this._setIds(),this._setAriaAttributes(),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){d("boolean",{value:e}),this._open=e}_setIds(){var e;if(this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`menu-button-${n}`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`menu-${n}`}}_setAriaAttributes(){this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),V("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id)}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(u(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&h(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&u(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{h(n,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&u(s,this.elements.controlledMenu.dom.menu),t!==""&&h(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(u(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&h(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&u(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{h(n,this.elements.controlledMenu.dom.menu)})})})):(t!==""&&u(t,this.elements.controlledMenu.dom.menu),s!==""&&h(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class x{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:l=null}){r(this,"_dom",{item:null,link:null});r(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});r(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=o,this._elements.toggle=l,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function w(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function m(i){i.preventDefault(),i.stopPropagation()}class D{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="",submenuToggleSelector:o="a",submenuSelector:l="ul",controllerElement:c=null,containerElement:p=null,openClass:a="show",closeClass:y="hide",transitionClass:b="transitioning",isTopLevel:_=!0,parentMenu:C=null,hoverType:E="off",hoverDelay:M=250,enterDelay:v=-1,leaveDelay:T=-1}){r(this,"_MenuType",D);r(this,"_MenuItemType",x);r(this,"_MenuToggleType",F);r(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});r(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});r(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});r(this,"_openClass","show");r(this,"_closeClass","hide");r(this,"_transitionClass","transitioning");r(this,"_root",!0);r(this,"_currentChild",0);r(this,"_focusState","none");r(this,"_currentEvent","none");r(this,"_hoverType","off");r(this,"_hoverDelay",250);r(this,"_enterDelay",-1);r(this,"_leaveDelay",-1);r(this,"_hoverTimeout",null);r(this,"_errors",[]);this._dom.menu=e,this._dom.controller=c,this._dom.container=p,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=o,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=C,this._elements.rootMenu=_?this:null,this._openClass=a||"",this._closeClass=y||"",this._transitionClass=b||"",this._root=_,this._hoverType=E,this._hoverDelay=M,this._enterDelay=v,this._leaveDelay=T}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
var Bootstrap5DisclosureMenu=function(){"use strict";var G=Object.defineProperty;var J=(h,u,f)=>u in h?G(h,u,{enumerable:!0,configurable:!0,writable:!0,value:f}):h[u]=f;var r=(h,u,f)=>J(h,typeof u!="symbol"?u+"":u,f);function h(i,e){i===""||i.length===0||(typeof i=="string"?e.classList.add(i):e.classList.add(...i))}function u(i,e){i===""||i.length===0||(typeof i=="string"?e.classList.remove(i):e.classList.remove(...i))}function f(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function a(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function I(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid query selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function C(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],I(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function H(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function R(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function z(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function j(i,e){if(a("string",{tagName:i}).status&&f(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class K{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){r(this,"_dom",{toggle:null,parent:null});r(this,"_elements",{controlledMenu:null,parentMenu:null});r(this,"_open",!1);r(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));r(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){this._setIds(),this._setAriaAttributes(),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){a("boolean",{value:e}),this._open=e}_setIds(){var e;if(this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`menu-button-${n}`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`menu-${n}`}}_setAriaAttributes(){this.dom.toggle.setAttribute("aria-expanded","false"),this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id)}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n,openDuration:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),this.elements.controlledMenu.elements.rootMenu.hasOpened=!0,n!==""?(h(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{u(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{h(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{setTimeout(()=>{u(n,this.elements.controlledMenu.dom.menu)},o)})})})):(h(s,this.elements.controlledMenu.dom.menu),u(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n,closeDuration:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(h(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{u(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{h(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{setTimeout(()=>{u(n,this.elements.controlledMenu.dom.menu)},o)})})})):(h(t,this.elements.controlledMenu.dom.menu),u(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this.isOpen||(this._expand(),this.isOpen=!0)}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this.isOpen||(this._expand(),this.isOpen=!0)}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class V{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:l=null}){r(this,"_dom",{item:null,link:null});r(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});r(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=o,this._elements.toggle=l,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&requestAnimationFrame(()=>{this.dom.link.focus()})}blur(){this.elements.parentMenu.shouldFocus&&requestAnimationFrame(()=>{this.dom.link.blur()})}}function A(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function d(i){i.preventDefault(),i.stopPropagation()}class L{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="li:has(ul)",submenuToggleSelector:o="a",submenuSelector:l="ul",controllerElement:m=null,containerElement:p=null,openClass:g="show",closeClass:_="hide",transitionClass:y="transitioning",transitionDuration:b=250,openDuration:c=-1,closeDuration:T=-1,isTopLevel:E=!0,parentMenu:M=null,hoverType:D="off",hoverDelay:v=250,enterDelay:w=-1,leaveDelay:S=-1,prefix:k="am-"}){r(this,"_MenuType",L);r(this,"_MenuItemType",V);r(this,"_MenuToggleType",K);r(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});r(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});r(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});r(this,"_openClass","show");r(this,"_closeClass","hide");r(this,"_transitionClass","transitioning");r(this,"_transitionDuration",250);r(this,"_openDuration",-1);r(this,"_closeDuration",-1);r(this,"_root",!0);r(this,"_currentChild",0);r(this,"_focusState","none");r(this,"_currentEvent","none");r(this,"_hoverType","off");r(this,"_hoverDelay",250);r(this,"_enterDelay",-1);r(this,"_leaveDelay",-1);r(this,"_prefix","am-");r(this,"_hoverTimeout",null);r(this,"_hasOpened",!1);r(this,"_errors",[]);this._dom.menu=e,this._dom.controller=m,this._dom.container=p,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=o,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=M,this._elements.rootMenu=E?this:null,this._openClass=g||"",this._closeClass=_||"",this._transitionClass=y||"",this._transitionDuration=b,this._openDuration=c,this._closeDuration=T,this._prefix=k||"",this._root=E,this._hoverType=D,this._hoverDelay=v,this._enterDelay=w,this._leaveDelay=S}initialize(){if(!this._validate())throw new Error(`AccessibleMenu: cannot initialize menu. The following errors have been found: | ||
- ${this.errors.join(` | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){g({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set currentChild(e){d("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let o=0,l=!1;for(;!l&&o<s.elements.parentMenu.elements.menuItems.length;){const c=s.elements.parentMenu.elements.menuItems[o];c.isSubmenuItem&&c.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=o),o++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){q({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){K({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){O({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){d("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){d("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){d("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=f(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=f(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const a=g({openClass:this._openClass});a.status||(this._errors.push(a.error.message),e=!1)}if(this._closeClass!==""){const a=g({closeClass:this._closeClass});a.status||(this._errors.push(a.error.message),e=!1)}if(this._transitionClass!==""){const a=g({transitionClass:this._transitionClass});a.status||(this._errors.push(a.error.message),e=!1)}const n=d("boolean",{isTopLevel:this._root});if(n.status||(this._errors.push(n.error.message),e=!1),this._elements.parentMenu!==null){const a=f(D,{parentMenu:this._elements.parentMenu});a.status||(this._errors.push(a.error.message),e=!1)}const o=O({hoverType:this._hoverType});o.status||(this._errors.push(o.error.message),e=!1);const l=d("number",{hoverDelay:this._hoverDelay});l.status||(this._errors.push(l.error.message),e=!1);const c=d("number",{enterDelay:this._enterDelay});c.status||(this._errors.push(c.error.message),e=!1);const p=d("number",{leaveDelay:this._leaveDelay});return p.status||(this._errors.push(p.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&f(HTMLElement,{base:t});const o=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=o:this._dom[e]=[...this._dom[e],...o]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,n){m(n),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t),e.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview());else if(this.hoverType==="dynamic"){const n=this.elements.submenuToggles.some(o=>o.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||n)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&m(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&(m(e),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class z extends x{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:l=null,initialize:c=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:o,toggle:l}),c&&this.initialize()}}class j extends F{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:o=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),o&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class k extends D{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:o="",submenuToggleSelector:l="button",submenuSelector:c="ul",controllerElement:p=null,containerElement:a=null,openClass:y="show",closeClass:b="hide",transitionClass:_="transitioning",isTopLevel:C=!0,parentMenu:E=null,hoverType:M="off",hoverDelay:v=250,enterDelay:T=-1,leaveDelay:A=-1,optionalKeySupport:L=!1,initialize:$=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:c,controllerElement:p,containerElement:a,openClass:y,closeClass:b,transitionClass:_,isTopLevel:C,parentMenu:E,hoverType:M,hoverDelay:v,enterDelay:T,leaveDelay:A});r(this,"_MenuType",k);r(this,"_MenuItemType",z);r(this,"_MenuToggleType",j);r(this,"_currentChild",-1);r(this,"_optionalSupport",!1);this._optionalSupport=L,$&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(t){d("boolean",{optionalKeySupport:t}),this._optionalSupport=t}_validate(){let t=super._validate();const s=d("boolean",{optionalKeySupport:this._optionalSupport});return s.status||(this._errors.push(s.error.message),t=!1),t}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=w(t);if(this.focusState==="self"){const n=["Space","Enter"],o=["Escape"],l=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&m(t):(this.currentMenuItem.isSubmenuItem&&n.includes(s)||this.elements.controller&&o.includes(s)||this.elements.parentMenu&&l.includes(s))&&m(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=w(t);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(m(t),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(o=>o.isOpen)?(m(t),this.closeChildren()):this.elements.parentMenu?(m(t),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.closeChildren(),this.elements.parentMenu.focusCurrentChild()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(m(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(m(t),this.focusPreviousChild()):s==="Home"?(m(t),this.focusFirstChild()):s==="End"&&(m(t),this.focusLastChild())))})}}class B extends z{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:l=null,initialize:c=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:o,toggle:l,initialize:!1}),c&&this.initialize()}}class H extends j{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o,initialize:!1});r(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,l&&this.initialize()}_expand(t=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(u(n,this.dom.container),requestAnimationFrame(()=>{u(s,this.dom.container),requestAnimationFrame(()=>{h(n,this.dom.container)})})):s!==""&&u(s,this.dom.container),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),o!==""?(u(o,this.dom.container),requestAnimationFrame(()=>{n!==""&&h(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&u(s,this.dom.container),requestAnimationFrame(()=>{h(o,this.dom.container)})})})):(s!==""&&u(s,this.dom.container),n!==""&&h(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class I extends k{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:c=".dropdown-menu",controllerElement:p=null,containerElement:a=null,openClass:y="show",closeClass:b="collapse",transitionClass:_="transitioning",isTopLevel:C=!0,parentMenu:E=null,hoverType:M="off",hoverDelay:v=250,enterDelay:T=-1,leaveDelay:A=-1,optionalKeySupport:L=!1,disableBootstrap:$=!0,initialize:P=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:c,controllerElement:p,containerElement:a,openClass:y,closeClass:b,transitionClass:_,isTopLevel:C,parentMenu:E,hoverType:M,hoverDelay:v,enterDelay:T,leaveDelay:A,optionalKeySupport:L,initialize:!1});r(this,"_MenuType",I);r(this,"_MenuItemType",B);r(this,"_MenuToggleType",H);r(this,"_disableBootstrap",!0);r(this,"_pseudoDropdownElement",document.createElement("div"));r(this,"_bootstrapEvents",["show.bs.dropdown","shown.bs.dropdown","hide.bs.dropdown","hidden.bs.dropdown"]);this._disableBootstrap=$,P&&this.initialize()}initialize(){super.initialize(),this.bootstrapDisabled&&this._disableBootstrapDropdownBehaviour()}get bootstrapDisabled(){return this._disableBootstrap}get bootstrapPseudoDropdownElement(){return this._pseudoDropdownElement}get bootstrapEvents(){return this._bootstrapEvents}_validate(){let t=super._validate();const s=d("boolean",{disableBootstrap:this._disableBootstrap});return s.status||(this._errors.push(s.error.message),t=!1),t}_disableBootstrapDropdownBehaviour(){this.elements.submenuToggles.forEach(t=>{this.bootstrapEvents.forEach(s=>{t.dom.toggle.addEventListener(s,n=>{m(n);const o=bootstrap.Dropdown.getInstance(n.target);o&&o._menu!==this.bootstrapPseudoDropdownElement&&(o._menu=this.bootstrapPseudoDropdownElement)},{once:!0})})})}}return I}(); | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});j("button",{toggle:e.dom.toggle})||e.dom.toggle.setAttribute("role","button"),e.dom.toggle.setAttribute("aria-controls",this.dom.menu.id),this._elements.controller=e}this._createChildElements(),this._setTransitionDurations(),this.isTopLevel&&(window.AccessibleMenu=window.AccessibleMenu||{menus:{}},window.AccessibleMenu.menus[this.dom.menu.id]=this)}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get transitionDuration(){return this.isTopLevel?this._transitionDuration:this.elements.rootMenu.transitionDuration}get openDuration(){return this._openDuration===-1?this.transitionDuration:this.isTopLevel?this._openDuration:this.elements.rootMenu.openDuration}get closeDuration(){return this._closeDuration===-1?this.transitionDuration:this.isTopLevel?this._closeDuration:this.elements.rootMenu.closeDuration}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get prefix(){return this._root?this._prefix:this.elements.rootMenu.prefix}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get hasOpened(){return this._root?this._hasOpened:this.elements.rootMenu.hasOpened}get errors(){return this._errors}set openClass(e){C({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){C({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){C({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set transitionDuration(e){a("number",{value:e}),this._transitionDuration!==e&&(this._transitionDuration=e,this._setTransitionDurations())}set openDuration(e){a("number",{value:e}),this._openDuration!==e&&(this._openDuration=e,this._setTransitionDurations())}set closeDuration(e){a("number",{value:e}),this._closeDuration!==e&&(this._closeDuration=e,this._setTransitionDurations())}set currentChild(e){a("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let o=0,l=!1;for(;!l&&o<s.elements.parentMenu.elements.menuItems.length;){const m=s.elements.parentMenu.elements.menuItems[o];m.isSubmenuItem&&m.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=o),o++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){H({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){R({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){z({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){a("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){a("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){a("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}set prefix(e){a("string",{value:e}),this._prefix!==e&&(this._prefix=e)}set hasOpened(e){a("boolean",{value:e}),this._hasOpened!==e&&(this._hasOpened=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=f(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=f(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=I({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=I({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const c=C({openClass:this._openClass});c.status||(this._errors.push(c.error.message),e=!1)}if(this._closeClass!==""){const c=C({closeClass:this._closeClass});c.status||(this._errors.push(c.error.message),e=!1)}if(this._transitionClass!==""){const c=C({transitionClass:this._transitionClass});c.status||(this._errors.push(c.error.message),e=!1)}const n=a("number",{transitionDuration:this._transitionDuration});n.status||(this._errors.push(n.error.message),e=!1);const o=a("number",{openDuration:this._openDuration});o.status||(this._errors.push(o.error.message),e=!1);const l=a("number",{closeDuration:this._closeDuration});l.status||(this._errors.push(l.error.message),e=!1);const m=a("boolean",{isTopLevel:this._root});if(m.status||(this._errors.push(m.error.message),e=!1),this._elements.parentMenu!==null){const c=f(L,{parentMenu:this._elements.parentMenu});c.status||(this._errors.push(c.error.message),e=!1)}const p=z({hoverType:this._hoverType});p.status||(this._errors.push(p.error.message),e=!1);const g=a("number",{hoverDelay:this._hoverDelay});g.status||(this._errors.push(g.error.message),e=!1);const _=a("number",{enterDelay:this._enterDelay});_.status||(this._errors.push(_.error.message),e=!1);const y=a("number",{leaveDelay:this._leaveDelay});y.status||(this._errors.push(y.error.message),e=!1);const b=a("string",{prefix:this._prefix});return b.status||(this._errors.push(b.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&f(HTMLElement,{base:t});const o=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=o:this._dom[e]=[...this._dom[e],...o]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,transitionDuration:this.transitionDuration,openDuration:this.openDuration,closeDuration:this.closeDuration,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_clearTimeout(){clearTimeout(this._hoverTimeout)}_setTimeout(e,t){a("function",{callback:e}),a("number",{delay:t}),this._hoverTimeout=setTimeout(e,t)}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})}),this.dom.menu.addEventListener("focusout",e=>{this.currentEvent!=="keyboard"||e.relatedTarget===null||this.dom.menu.contains(e.relatedTarget)||(this.focusState="none",this.closeChildren())})}_handleClick(){function e(t,s,n){d(n),n.button===0&&(s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none"))}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this._clearTimeout(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)}),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.elements.rootMenu.hasOpened=this.elements.submenuToggles.some(s=>s.isOpen)))})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t),e.isSubmenuItem&&(this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay)):e.elements.toggle.preview())):this.hoverType==="dynamic"&&(this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),(!this.isTopLevel||this.hasOpened)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),e.isSubmenuItem?this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay)):e.elements.toggle.preview():this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.closeChildren()},this.enterDelay)):this.closeChildren())))}),e.isSubmenuItem&&(e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse"},this.leaveDelay)):this.currentEvent="mouse"))}),e.dom.item.addEventListener("pointerenter",s=>{s.pointerType==="pen"||s.pointerType==="touch"||e.isSubmenuItem&&(this.hoverType==="on"||this.hoverType==="dynamic")&&this.leaveDelay>0&&this._clearTimeout()}))})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=A(e);(t==="Space"||t==="Enter")&&d(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=A(e);(t==="Space"||t==="Enter")&&(d(e),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}_setTransitionDurations(){this.dom.menu.style.setProperty(`--${this.prefix}transition-duration`,`${this.transitionDuration}ms`),this.dom.menu.style.setProperty(`--${this.prefix}open-transition-duration`,`${this.openDuration}ms`),this.dom.menu.style.setProperty(`--${this.prefix}close-transition-duration`,`${this.closeDuration}ms`)}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class B extends V{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:l=null,initialize:m=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:o,toggle:l}),m&&this.initialize()}}class P extends K{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:o=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),o&&this.initialize()}_setAriaAttributes(){super._setAriaAttributes(),j("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id)}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class $ extends L{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:o="li:has(ul)",submenuToggleSelector:l="button",submenuSelector:m="ul",controllerElement:p=null,containerElement:g=null,openClass:_="show",closeClass:y="hide",transitionClass:b="transitioning",transitionDuration:c=250,openDuration:T=-1,closeDuration:E=-1,isTopLevel:M=!0,parentMenu:D=null,hoverType:v="off",hoverDelay:w=250,enterDelay:S=-1,leaveDelay:k=-1,optionalKeySupport:x=!1,prefix:F="am-",initialize:q=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:m,controllerElement:p,containerElement:g,openClass:_,closeClass:y,transitionClass:b,transitionDuration:c,openDuration:T,closeDuration:E,isTopLevel:M,parentMenu:D,hoverType:v,hoverDelay:w,enterDelay:S,leaveDelay:k,prefix:F});r(this,"_MenuType",$);r(this,"_MenuItemType",B);r(this,"_MenuToggleType",P);r(this,"_currentChild",-1);r(this,"_optionalSupport",!1);this._optionalSupport=x,q&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(t){a("boolean",{optionalKeySupport:t}),this._optionalSupport=t}_validate(){let t=super._validate();const s=a("boolean",{optionalKeySupport:this._optionalSupport});return s.status||(this._errors.push(s.error.message),t=!1),t}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close(),this.elements.rootMenu.hasOpened=!1))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=A(t);if(this.focusState==="self"){const n=["Space","Enter"],o=["Escape"],l=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&d(t):(this.currentMenuItem.isSubmenuItem&&n.includes(s)||this.elements.controller&&o.includes(s)||this.elements.parentMenu&&l.includes(s))&&d(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=A(t);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(d(t),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(o=>o.isOpen)?(d(t),this.closeChildren()):this.elements.parentMenu?(d(t),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.closeChildren(),this.elements.parentMenu.focusCurrentChild()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(d(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(d(t),this.focusPreviousChild()):s==="Home"?(d(t),this.focusFirstChild()):s==="End"&&(d(t),this.focusLastChild())))})}}class U extends B{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:l=null,initialize:m=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:o,toggle:l,initialize:!1}),m&&this.initialize()}}class Z extends P{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o,initialize:!1});r(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,l&&this.initialize()}initialize(){super.initialize(),this.elements.controlledMenu.bootstrapTransitions&&this.elements.controlledMenu.isTopLevel&&(this.dom.container.style.transition="height var(--am-transition-duration) ease")}_expand(t=!0){const{openClass:s,closeClass:n,transitionClass:o,openDuration:l,bootstrapTransitions:m,isTopLevel:p}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),this.elements.controlledMenu.elements.rootMenu.hasOpened=!0,o!==""?m?p?(h(o,this.dom.container),u(n,this.dom.container),this.dom.container.style.height=`${this.dom.container.scrollHeight}px`,requestAnimationFrame(()=>{setTimeout(()=>{h(s,this.dom.container),h(n,this.dom.container),u(o,this.dom.container),this.dom.container.style.height=""},l)})):(h(s,this.dom.container),u(n,this.dom.container)):(h(o,this.dom.container),requestAnimationFrame(()=>{u(n,this.dom.container),requestAnimationFrame(()=>{h(s,this.dom.container),requestAnimationFrame(()=>{setTimeout(()=>{u(o,this.dom.container)},l)})})})):(h(s,this.dom.container),u(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:o,closeDuration:l,bootstrapTransitions:m,isTopLevel:p}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),o!==""?m?p?(this.dom.container.style.height=`${this.dom.container.offsetHeight}px`,requestAnimationFrame(()=>{h(o,this.dom.container),requestAnimationFrame(()=>{u(n,this.dom.container),u(s,this.dom.container),this.dom.container.style.height="",requestAnimationFrame(()=>{setTimeout(()=>{u(o,this.dom.container),h(s,this.dom.container)},l)})})})):(h(s,this.dom.container),u(n,this.dom.container)):(h(o,this.dom.container),requestAnimationFrame(()=>{u(n,this.dom.container),requestAnimationFrame(()=>{h(s,this.dom.container),requestAnimationFrame(()=>{setTimeout(()=>{u(o,this.dom.container)},l)})})})):(h(s,this.dom.container),u(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class O extends ${constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:m=".dropdown-menu",controllerElement:p=null,containerElement:g=null,openClass:_="show",closeClass:y="collapse",transitionClass:b="collapsing",transitionDuration:c=350,openDuration:T=-1,closeDuration:E=-1,isTopLevel:M=!0,parentMenu:D=null,hoverType:v="off",hoverDelay:w=250,enterDelay:S=-1,leaveDelay:k=-1,optionalKeySupport:x=!1,prefix:F="am-",bootstrapTransitions:q=!0,disableBootstrap:Q=!0,initialize:W=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:m,controllerElement:p,containerElement:g,openClass:_,closeClass:y,transitionClass:b,transitionDuration:c,openDuration:T,closeDuration:E,isTopLevel:M,parentMenu:D,hoverType:v,hoverDelay:w,enterDelay:S,leaveDelay:k,optionalKeySupport:x,prefix:F,initialize:!1});r(this,"_MenuType",O);r(this,"_MenuItemType",U);r(this,"_MenuToggleType",Z);r(this,"_disableBootstrap",!0);r(this,"_pseudoDropdownElement",document.createElement("div"));r(this,"_bootstrapDropdownEvents",["show.bs.dropdown","shown.bs.dropdown","hide.bs.dropdown","hidden.bs.dropdown"]);r(this,"_pseudoCollapseElement",document.createElement("div"));r(this,"_bootstrapCollapseEvents",["show.bs.collapse","shown.bs.collapse","hide.bs.collapse","hidden.bs.collapse"]);r(this,"_bootstrapTransitions",!0);this._disableBootstrap=Q,this._bootstrapTransitions=q,W&&this.initialize()}initialize(){super.initialize(),this.bootstrapDisabled&&(this._disableBootstrapDropdownBehaviour(),this._disableBootstrapCollapseBehaviour())}get bootstrapTransitions(){return this.isTopLevel?this._bootstrapTransitions:this.elements.rootMenu.bootstrapTransitions}get bootstrapDisabled(){return this._disableBootstrap}get bootstrapPseudoDropdownElement(){return this._pseudoDropdownElement}get bootstrapDropdownEvents(){return this._bootstrapDropdownEvents}get bootstrapPseudoCollapseElement(){return this._pseudoCollapseElement}get bootstrapCollapseEvents(){return this._bootstrapCollapseEvents}_validate(){let t=super._validate();const s=a("boolean",{bootstrapTransitions:this._bootstrapTransitions});s.status||(this._errors.push(s.error.message),t=!1);const n=a("boolean",{disableBootstrap:this._disableBootstrap});return n.status||(this._errors.push(n.error.message),t=!1),t}_disableBootstrapDropdownBehaviour(){this.elements.submenuToggles.forEach(t=>{this.bootstrapDropdownEvents.forEach(s=>{t.dom.toggle.addEventListener(s,n=>{d(n);const o=bootstrap.Dropdown.getInstance(n.target);o&&o._menu!==this.bootstrapPseudoDropdownElement&&(o._menu=this.bootstrapPseudoDropdownElement)},{once:!0})})})}_disableBootstrapCollapseBehaviour(){this.elements.controller&&this.bootstrapCollapseEvents.forEach(t=>{this.dom.container.addEventListener(t,s=>{d(s);const n=bootstrap.Collapse.getInstance(s.target);n&&n._element!==this.bootstrapPseudoCollapseElement&&(n._element=this.bootstrapPseudoCollapseElement)},{once:!0})})}_setTransitionDurations(){super._setTransitionDurations(),this.isTopLevel&&this.elements.controller&&(this.elements.controller.dom.container.style.setProperty(`--${this.prefix}transition-duration`,`${this.transitionDuration}ms`),this.elements.controller.dom.container.style.setProperty(`--${this.prefix}open-transition-duration`,`${this.openDuration}ms`),this.elements.controller.dom.container.style.setProperty(`--${this.prefix}close-transition-duration`,`${this.closeDuration}ms`))}}return O}(); |
@@ -1,3 +0,3 @@ | ||
"use strict";var j=Object.defineProperty;var V=(i,e,t)=>e in i?j(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var o=(i,e,t)=>(V(i,typeof e!="symbol"?e+"":e,t),t);function a(i,e){typeof i=="string"?e.classList.add(i):e.classList.add(...i)}function f(i,e){typeof i=="string"?e.classList.remove(i):e.classList.remove(...i)}function w(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function d(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function S(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid query selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function g(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],S(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function H(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function K(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function x(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function B(i,e){if(d("string",{tagName:i}).status&&w(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class ${constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){o(this,"_dom",{toggle:null,parent:null});o(this,"_elements",{controlledMenu:null,parentMenu:null});o(this,"_open",!1);o(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));o(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){this._setIds(),this._setAriaAttributes(),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){d("boolean",{value:e}),this._open=e}_setIds(){var e;if(this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`menu-button-${n}`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`menu-${n}`}}_setAriaAttributes(){this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),B("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id)}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&f(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&a(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{f(n,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&a(s,this.elements.controlledMenu.dom.menu),t!==""&&f(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(a(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&f(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&a(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{f(n,this.elements.controlledMenu.dom.menu)})})})):(t!==""&&a(t,this.elements.controlledMenu.dom.menu),s!==""&&f(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class F{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null}){o(this,"_dom",{item:null,link:null});o(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});o(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=r,this._elements.toggle=l,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function v(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function u(i){i.preventDefault(),i.stopPropagation()}class I{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="",submenuToggleSelector:r="a",submenuSelector:l="ul",controllerElement:m=null,containerElement:c=null,openClass:h="show",closeClass:_="hide",transitionClass:y="transitioning",isTopLevel:p=!0,parentMenu:b=null,hoverType:M="off",hoverDelay:C=250,enterDelay:E=-1,leaveDelay:T=-1}){o(this,"_MenuType",I);o(this,"_MenuItemType",F);o(this,"_MenuToggleType",$);o(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});o(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});o(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});o(this,"_openClass","show");o(this,"_closeClass","hide");o(this,"_transitionClass","transitioning");o(this,"_root",!0);o(this,"_currentChild",0);o(this,"_focusState","none");o(this,"_currentEvent","none");o(this,"_hoverType","off");o(this,"_hoverDelay",250);o(this,"_enterDelay",-1);o(this,"_leaveDelay",-1);o(this,"_hoverTimeout",null);o(this,"_errors",[]);this._dom.menu=e,this._dom.controller=m,this._dom.container=c,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=r,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=b,this._elements.rootMenu=p?this:null,this._openClass=h||"",this._closeClass=_||"",this._transitionClass=y||"",this._root=p,this._hoverType=M,this._hoverDelay=C,this._enterDelay=E,this._leaveDelay=T}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
"use strict";var K=Object.defineProperty;var R=(i,e,t)=>e in i?K(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var r=(i,e,t)=>R(i,typeof e!="symbol"?e+"":e,t);function m(i,e){i===""||i.length===0||(typeof i=="string"?e.classList.add(i):e.classList.add(...i))}function c(i,e){i===""||i.length===0||(typeof i=="string"?e.classList.remove(i):e.classList.remove(...i))}function A(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function h(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function L(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid query selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function C(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],L(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function U(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function W(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function O(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function Z(i,e){if(h("string",{tagName:i}).status&&A(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class F{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){r(this,"_dom",{toggle:null,parent:null});r(this,"_elements",{controlledMenu:null,parentMenu:null});r(this,"_open",!1);r(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));r(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){this._setIds(),this._setAriaAttributes(),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){h("boolean",{value:e}),this._open=e}_setIds(){var e;if(this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`menu-button-${n}`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`menu-${n}`}}_setAriaAttributes(){this.dom.toggle.setAttribute("aria-expanded","false"),this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id)}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n,openDuration:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),this.elements.controlledMenu.elements.rootMenu.hasOpened=!0,n!==""?(m(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{c(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{m(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{setTimeout(()=>{c(n,this.elements.controlledMenu.dom.menu)},o)})})})):(m(s,this.elements.controlledMenu.dom.menu),c(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n,closeDuration:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(m(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{c(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{m(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{setTimeout(()=>{c(n,this.elements.controlledMenu.dom.menu)},o)})})})):(m(t,this.elements.controlledMenu.dom.menu),c(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this.isOpen||(this._expand(),this.isOpen=!0)}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this.isOpen||(this._expand(),this.isOpen=!0)}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class q{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:l=null}){r(this,"_dom",{item:null,link:null});r(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});r(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=o,this._elements.toggle=l,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&requestAnimationFrame(()=>{this.dom.link.focus()})}blur(){this.elements.parentMenu.shouldFocus&&requestAnimationFrame(()=>{this.dom.link.blur()})}}function k(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function u(i){i.preventDefault(),i.stopPropagation()}class S{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="li:has(ul)",submenuToggleSelector:o="a",submenuSelector:l="ul",controllerElement:a=null,containerElement:d=null,openClass:f="show",closeClass:g="hide",transitionClass:_="transitioning",transitionDuration:b=250,openDuration:p=-1,closeDuration:M=-1,isTopLevel:y=!0,parentMenu:E=null,hoverType:T="off",hoverDelay:D=250,enterDelay:w=-1,leaveDelay:v=-1,prefix:I="am-"}){r(this,"_MenuType",S);r(this,"_MenuItemType",q);r(this,"_MenuToggleType",F);r(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});r(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});r(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});r(this,"_openClass","show");r(this,"_closeClass","hide");r(this,"_transitionClass","transitioning");r(this,"_transitionDuration",250);r(this,"_openDuration",-1);r(this,"_closeDuration",-1);r(this,"_root",!0);r(this,"_currentChild",0);r(this,"_focusState","none");r(this,"_currentEvent","none");r(this,"_hoverType","off");r(this,"_hoverDelay",250);r(this,"_enterDelay",-1);r(this,"_leaveDelay",-1);r(this,"_prefix","am-");r(this,"_hoverTimeout",null);r(this,"_hasOpened",!1);r(this,"_errors",[]);this._dom.menu=e,this._dom.controller=a,this._dom.container=d,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=o,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=E,this._elements.rootMenu=y?this:null,this._openClass=f||"",this._closeClass=g||"",this._transitionClass=_||"",this._transitionDuration=b,this._openDuration=p,this._closeDuration=M,this._prefix=I||"",this._root=y,this._hoverType=T,this._hoverDelay=D,this._enterDelay=w,this._leaveDelay=v}initialize(){if(!this._validate())throw new Error(`AccessibleMenu: cannot initialize menu. The following errors have been found: | ||
- ${this.errors.join(` | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){g({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set currentChild(e){d("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let r=0,l=!1;for(;!l&&r<s.elements.parentMenu.elements.menuItems.length;){const m=s.elements.parentMenu.elements.menuItems[r];m.isSubmenuItem&&m.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=r),r++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){H({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){K({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){x({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){d("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){d("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){d("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=w(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=w(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const h=g({openClass:this._openClass});h.status||(this._errors.push(h.error.message),e=!1)}if(this._closeClass!==""){const h=g({closeClass:this._closeClass});h.status||(this._errors.push(h.error.message),e=!1)}if(this._transitionClass!==""){const h=g({transitionClass:this._transitionClass});h.status||(this._errors.push(h.error.message),e=!1)}const n=d("boolean",{isTopLevel:this._root});if(n.status||(this._errors.push(n.error.message),e=!1),this._elements.parentMenu!==null){const h=w(I,{parentMenu:this._elements.parentMenu});h.status||(this._errors.push(h.error.message),e=!1)}const r=x({hoverType:this._hoverType});r.status||(this._errors.push(r.error.message),e=!1);const l=d("number",{hoverDelay:this._hoverDelay});l.status||(this._errors.push(l.error.message),e=!1);const m=d("number",{enterDelay:this._enterDelay});m.status||(this._errors.push(m.error.message),e=!1);const c=d("number",{leaveDelay:this._leaveDelay});return c.status||(this._errors.push(c.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&w(HTMLElement,{base:t});const r=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=r:this._dom[e]=[...this._dom[e],...r]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),r=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:r,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:r,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,n){u(n),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t),e.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview());else if(this.hoverType==="dynamic"){const n=this.elements.submenuToggles.some(r=>r.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||n)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=v(e);(t==="Space"||t==="Enter")&&u(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=v(e);(t==="Space"||t==="Enter")&&(u(e),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class O extends F{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:m=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l}),m&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","menuitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=0)}blur(){super.blur(),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=-1)}}class q extends ${constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),r&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&(this.closeChildren(),this.elements.parentMenu&&this.elements.parentMenu.focusCurrentChild()),super.close()}}class A extends I{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:r="",submenuToggleSelector:l="a",submenuSelector:m="ul",controllerElement:c=null,containerElement:h=null,openClass:_="show",closeClass:y="hide",transitionClass:p="transitioning",isTopLevel:b=!0,parentMenu:M=null,hoverType:C="off",hoverDelay:E=250,enterDelay:T=-1,leaveDelay:k=-1,initialize:D=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:m,controllerElement:c,containerElement:h,openClass:_,closeClass:y,transitionClass:p,isTopLevel:b,parentMenu:M,hoverType:C,hoverDelay:E,enterDelay:T,leaveDelay:k});o(this,"_MenuType",A);o(this,"_MenuItemType",O);o(this,"_MenuToggleType",q);D&&this.initialize()}initialize(){try{super.initialize(),this.isTopLevel?this.dom.menu.setAttribute("role","menubar"):this.dom.menu.setAttribute("role","menu"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup(),this.isTopLevel&&(this.elements.menuItems[0].dom.link.tabIndex=0)}catch(t){console.error(t)}}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=v(t);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?(this.elements.rootMenu.blur(),this.elements.rootMenu.closeChildren()):this.elements.rootMenu.focus()),s==="Character")u(t);else if(this.isTopLevel){if(this.focusState==="self"){const n=["ArrowRight","ArrowLeft","Home","End"],r=["Space","Enter","ArrowDown","ArrowUp"],l=["Escape"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&r.includes(s)||this.elements.controller&&l.includes(s))&&u(t)}}else{const n=["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"],r=["Space","Enter"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&r.includes(s))&&u(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=v(t),{altKey:n,crtlKey:r,metaKey:l}=t;if(s==="Character"&&!(n||r||l))u(t),this.elements.rootMenu.currentEvent="character",this.focusNextChildWithCharacter(t.key);else if(this.isTopLevel){if(this.focusState==="self")if(s==="Space"||s==="Enter")this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click();else if(s==="ArrowRight"){u(t);const c=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusNextChild(),c&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if(s==="ArrowLeft"){u(t);const c=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusPreviousChild(),c&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else s==="ArrowDown"?this.currentMenuItem.isSubmenuItem&&(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):s==="ArrowUp"?this.currentMenuItem.isSubmenuItem&&(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusLastChild()})):s==="Home"?(u(t),this.focusFirstChild()):s==="End"?(u(t),this.focusLastChild()):s==="Escape"&&(this.elements.submenuToggles.some(h=>h.isOpen)?(u(t),this.closeChildren()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(u(t),this.elements.controller.close(),this.focusController()))}else s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click():s==="Escape"?(u(t),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusCurrentChild()):s==="ArrowRight"?this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):(u(t),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusNextChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&this.elements.rootMenu.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?this.elements.parentMenu.currentMenuItem.isSubmenuItem&&(u(t),this.elements.parentMenu.currentMenuItem.elements.toggle.close(),this.elements.parentMenu.focusCurrentChild(),this.elements.parentMenu===this.elements.rootMenu&&(this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusPreviousChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&(this.elements.rootMenu.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.elements.rootMenu.currentMenuItem.elements.toggle.preview()))):s==="ArrowDown"?(u(t),this.focusNextChild()):s==="ArrowUp"?(u(t),this.focusPreviousChild()):s==="Home"?(u(t),this.focusFirstChild()):s==="End"&&(u(t),this.focusLastChild())})}focusNextChild(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}focusPreviousChild(){this.currentChild===0?this.focusLastChild():this.focusChild(this.currentChild-1)}focusNextChildWithCharacter(t){const s=t.toLowerCase();let n=this.currentChild+1,r=!1;for(;!r&&n<this.elements.menuItems.length;){let l="";this.elements.menuItems[n].dom.item.innerText?l=this.elements.menuItems[n].dom.item.innerText:l=this.elements.menuItems[n].dom.item.textContent,l=l.replace(/[\s]/g,"").toLowerCase().charAt(0),l===s&&(r=!0,this.focusChild(n)),n++}}}class P extends O{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:m=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l,initialize:!1}),m&&this.initialize()}}class R extends q{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r,initialize:!1});o(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,l&&this.initialize()}_expand(t=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{f(n,this.dom.container)})})):s!==""&&a(s,this.dom.container),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:r}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),r!==""?(a(r,this.dom.container),requestAnimationFrame(()=>{n!==""&&f(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&a(s,this.dom.container),requestAnimationFrame(()=>{f(r,this.dom.container)})})})):(s!==""&&a(s,this.dom.container),n!==""&&f(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class L extends A{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:r=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:m=".dropdown-menu",controllerElement:c=null,containerElement:h=null,openClass:_="show",closeClass:y="collapse",transitionClass:p="transitioning",isTopLevel:b=!0,parentMenu:M=null,hoverType:C="off",hoverDelay:E=250,enterDelay:T=-1,leaveDelay:k=-1,disableBootstrap:D=!0,initialize:z=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:m,controllerElement:c,containerElement:h,openClass:_,closeClass:y,transitionClass:p,isTopLevel:b,parentMenu:M,hoverType:C,hoverDelay:E,enterDelay:T,leaveDelay:k,initialize:!1});o(this,"_MenuType",L);o(this,"_MenuItemType",P);o(this,"_MenuToggleType",R);o(this,"_disableBootstrap",!0);o(this,"_pseudoDropdownElement",document.createElement("div"));o(this,"_bootstrapEvents",["show.bs.dropdown","shown.bs.dropdown","hide.bs.dropdown","hidden.bs.dropdown"]);this._disableBootstrap=D,z&&this.initialize()}initialize(){super.initialize(),this.bootstrapDisabled&&this._disableBootstrapDropdownBehaviour()}get bootstrapDisabled(){return this._disableBootstrap}get bootstrapPseudoDropdownElement(){return this._pseudoDropdownElement}get bootstrapEvents(){return this._bootstrapEvents}_validate(){let t=super._validate();const s=d("boolean",{disableBootstrap:this._disableBootstrap});return s.status||(this._errors.push(s.error.message),t=!1),t}_disableBootstrapDropdownBehaviour(){this.elements.submenuToggles.forEach(t=>{this.bootstrapEvents.forEach(s=>{t.dom.toggle.addEventListener(s,n=>{u(n);const r=bootstrap.Dropdown.getInstance(n.target);r&&r._menu!==this.bootstrapPseudoDropdownElement&&(r._menu=this.bootstrapPseudoDropdownElement)},{once:!0})})})}}module.exports=L; | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});Z("button",{toggle:e.dom.toggle})||e.dom.toggle.setAttribute("role","button"),e.dom.toggle.setAttribute("aria-controls",this.dom.menu.id),this._elements.controller=e}this._createChildElements(),this._setTransitionDurations(),this.isTopLevel&&(window.AccessibleMenu=window.AccessibleMenu||{menus:{}},window.AccessibleMenu.menus[this.dom.menu.id]=this)}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get transitionDuration(){return this.isTopLevel?this._transitionDuration:this.elements.rootMenu.transitionDuration}get openDuration(){return this._openDuration===-1?this.transitionDuration:this.isTopLevel?this._openDuration:this.elements.rootMenu.openDuration}get closeDuration(){return this._closeDuration===-1?this.transitionDuration:this.isTopLevel?this._closeDuration:this.elements.rootMenu.closeDuration}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get prefix(){return this._root?this._prefix:this.elements.rootMenu.prefix}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get hasOpened(){return this._root?this._hasOpened:this.elements.rootMenu.hasOpened}get errors(){return this._errors}set openClass(e){C({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){C({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){C({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set transitionDuration(e){h("number",{value:e}),this._transitionDuration!==e&&(this._transitionDuration=e,this._setTransitionDurations())}set openDuration(e){h("number",{value:e}),this._openDuration!==e&&(this._openDuration=e,this._setTransitionDurations())}set closeDuration(e){h("number",{value:e}),this._closeDuration!==e&&(this._closeDuration=e,this._setTransitionDurations())}set currentChild(e){h("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let o=0,l=!1;for(;!l&&o<s.elements.parentMenu.elements.menuItems.length;){const a=s.elements.parentMenu.elements.menuItems[o];a.isSubmenuItem&&a.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=o),o++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){U({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){W({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){O({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){h("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){h("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){h("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}set prefix(e){h("string",{value:e}),this._prefix!==e&&(this._prefix=e)}set hasOpened(e){h("boolean",{value:e}),this._hasOpened!==e&&(this._hasOpened=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=A(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=A(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=L({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=L({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const p=C({openClass:this._openClass});p.status||(this._errors.push(p.error.message),e=!1)}if(this._closeClass!==""){const p=C({closeClass:this._closeClass});p.status||(this._errors.push(p.error.message),e=!1)}if(this._transitionClass!==""){const p=C({transitionClass:this._transitionClass});p.status||(this._errors.push(p.error.message),e=!1)}const n=h("number",{transitionDuration:this._transitionDuration});n.status||(this._errors.push(n.error.message),e=!1);const o=h("number",{openDuration:this._openDuration});o.status||(this._errors.push(o.error.message),e=!1);const l=h("number",{closeDuration:this._closeDuration});l.status||(this._errors.push(l.error.message),e=!1);const a=h("boolean",{isTopLevel:this._root});if(a.status||(this._errors.push(a.error.message),e=!1),this._elements.parentMenu!==null){const p=A(S,{parentMenu:this._elements.parentMenu});p.status||(this._errors.push(p.error.message),e=!1)}const d=O({hoverType:this._hoverType});d.status||(this._errors.push(d.error.message),e=!1);const f=h("number",{hoverDelay:this._hoverDelay});f.status||(this._errors.push(f.error.message),e=!1);const g=h("number",{enterDelay:this._enterDelay});g.status||(this._errors.push(g.error.message),e=!1);const _=h("number",{leaveDelay:this._leaveDelay});_.status||(this._errors.push(_.error.message),e=!1);const b=h("string",{prefix:this._prefix});return b.status||(this._errors.push(b.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&A(HTMLElement,{base:t});const o=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=o:this._dom[e]=[...this._dom[e],...o]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,transitionDuration:this.transitionDuration,openDuration:this.openDuration,closeDuration:this.closeDuration,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_clearTimeout(){clearTimeout(this._hoverTimeout)}_setTimeout(e,t){h("function",{callback:e}),h("number",{delay:t}),this._hoverTimeout=setTimeout(e,t)}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})}),this.dom.menu.addEventListener("focusout",e=>{this.currentEvent!=="keyboard"||e.relatedTarget===null||this.dom.menu.contains(e.relatedTarget)||(this.focusState="none",this.closeChildren())})}_handleClick(){function e(t,s,n){u(n),n.button===0&&(s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none"))}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this._clearTimeout(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)}),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.elements.rootMenu.hasOpened=this.elements.submenuToggles.some(s=>s.isOpen)))})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t),e.isSubmenuItem&&(this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay)):e.elements.toggle.preview())):this.hoverType==="dynamic"&&(this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),(!this.isTopLevel||this.hasOpened)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),e.isSubmenuItem?this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay)):e.elements.toggle.preview():this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.closeChildren()},this.enterDelay)):this.closeChildren())))}),e.isSubmenuItem&&(e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse"},this.leaveDelay)):this.currentEvent="mouse"))}),e.dom.item.addEventListener("pointerenter",s=>{s.pointerType==="pen"||s.pointerType==="touch"||e.isSubmenuItem&&(this.hoverType==="on"||this.hoverType==="dynamic")&&this.leaveDelay>0&&this._clearTimeout()}))})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=k(e);(t==="Space"||t==="Enter")&&u(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=k(e);(t==="Space"||t==="Enter")&&(u(e),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}_setTransitionDurations(){this.dom.menu.style.setProperty(`--${this.prefix}transition-duration`,`${this.transitionDuration}ms`),this.dom.menu.style.setProperty(`--${this.prefix}open-transition-duration`,`${this.openDuration}ms`),this.dom.menu.style.setProperty(`--${this.prefix}close-transition-duration`,`${this.closeDuration}ms`)}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class z extends q{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:l=null,initialize:a=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:o,toggle:l}),a&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","menuitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=0)}blur(){super.blur(),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=-1)}}class j extends F{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:o=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),o&&this.initialize()}_setAriaAttributes(){super._setAriaAttributes(),this.dom.toggle.setAttribute("aria-haspopup","true")}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&(this.closeChildren(),this.elements.parentMenu&&this.elements.parentMenu.focusCurrentChild()),super.close()}}class x extends S{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:o="li:has(ul)",submenuToggleSelector:l="a",submenuSelector:a="ul",controllerElement:d=null,containerElement:f=null,openClass:g="show",closeClass:_="hide",transitionClass:b="transitioning",transitionDuration:p=250,isTopLevel:M=!0,parentMenu:y=null,hoverType:E="off",hoverDelay:T=250,enterDelay:D=-1,leaveDelay:w=-1,prefix:v="am-",initialize:I=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:a,controllerElement:d,containerElement:f,openClass:g,closeClass:_,transitionClass:b,transitionDuration:p,isTopLevel:M,parentMenu:y,hoverType:E,hoverDelay:T,enterDelay:D,leaveDelay:w,prefix:v});r(this,"_MenuType",x);r(this,"_MenuItemType",z);r(this,"_MenuToggleType",j);I&&this.initialize()}initialize(){try{super.initialize(),this.isTopLevel?this.dom.menu.setAttribute("role","menubar"):this.dom.menu.setAttribute("role","menu"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup(),this.isTopLevel&&(this.elements.menuItems[0].dom.link.tabIndex=0,this.elements.controller&&this.elements.controller.dom.toggle.removeAttribute("aria-haspopup"))}catch(t){console.error(t)}}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close(),this.elements.rootMenu.hasOpened=!1))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=k(t);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?(this.elements.rootMenu.blur(),this.elements.rootMenu.closeChildren()):this.elements.rootMenu.focus()),s==="Character")u(t);else if(this.isTopLevel){if(this.focusState==="self"){const n=["ArrowRight","ArrowLeft","Home","End"],o=["Space","Enter","ArrowDown","ArrowUp"],l=["Escape"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&o.includes(s)||this.elements.controller&&l.includes(s))&&u(t)}}else{const n=["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"],o=["Space","Enter"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&o.includes(s))&&u(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=k(t),{altKey:n,crtlKey:o,metaKey:l}=t;if(s==="Character"&&!(n||o||l))u(t),this.elements.rootMenu.currentEvent="character",this.focusNextChildWithCharacter(t.key);else if(this.isTopLevel){if(this.focusState==="self")if(s==="Space"||s==="Enter")this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click();else if(s==="ArrowRight"){u(t);const d=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusNextChild(),d&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if(s==="ArrowLeft"){u(t);const d=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusPreviousChild(),d&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else s==="ArrowDown"?this.currentMenuItem.isSubmenuItem&&(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):s==="ArrowUp"?this.currentMenuItem.isSubmenuItem&&(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusLastChild()})):s==="Home"?(u(t),this.focusFirstChild()):s==="End"?(u(t),this.focusLastChild()):s==="Escape"&&(this.elements.submenuToggles.some(f=>f.isOpen)?(u(t),this.closeChildren()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(u(t),this.elements.controller.close(),this.focusController()))}else s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click():s==="Escape"?(u(t),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusCurrentChild()):s==="ArrowRight"?this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):(u(t),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusNextChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&this.elements.rootMenu.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?this.elements.parentMenu.currentMenuItem.isSubmenuItem&&(u(t),this.elements.parentMenu.currentMenuItem.elements.toggle.close(),this.elements.parentMenu.focusCurrentChild(),this.elements.parentMenu===this.elements.rootMenu&&(this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusPreviousChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&(this.elements.rootMenu.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.elements.rootMenu.currentMenuItem.elements.toggle.preview()))):s==="ArrowDown"?(u(t),this.focusNextChild()):s==="ArrowUp"?(u(t),this.focusPreviousChild()):s==="Home"?(u(t),this.focusFirstChild()):s==="End"&&(u(t),this.focusLastChild())})}focusNextChild(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}focusPreviousChild(){this.currentChild===0?this.focusLastChild():this.focusChild(this.currentChild-1)}focusNextChildWithCharacter(t){const s=t.toLowerCase();let n=this.currentChild+1,o=!1;for(;!o&&n<this.elements.menuItems.length;){let l="";this.elements.menuItems[n].dom.item.innerText?l=this.elements.menuItems[n].dom.item.innerText:l=this.elements.menuItems[n].dom.item.textContent,l=l.replace(/[\s]/g,"").toLowerCase().charAt(0),l===s&&(o=!0,this.focusChild(n)),n++}}}class Q extends z{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:l=null,initialize:a=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:o,toggle:l,initialize:!1}),a&&this.initialize()}}class N extends j{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o,initialize:!1});r(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,l&&this.initialize()}initialize(){super.initialize(),this.elements.controlledMenu.bootstrapTransitions&&this.elements.controlledMenu.isTopLevel&&(this.dom.container.style.transition="height var(--am-transition-duration) ease")}_expand(t=!0){const{openClass:s,closeClass:n,transitionClass:o,openDuration:l,bootstrapTransitions:a,isTopLevel:d}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),this.elements.controlledMenu.elements.rootMenu.hasOpened=!0,o!==""?a?d?(m(o,this.dom.container),c(n,this.dom.container),this.dom.container.style.height=`${this.dom.container.scrollHeight}px`,requestAnimationFrame(()=>{setTimeout(()=>{m(s,this.dom.container),m(n,this.dom.container),c(o,this.dom.container),this.dom.container.style.height=""},l)})):(m(s,this.dom.container),c(n,this.dom.container)):(m(o,this.dom.container),requestAnimationFrame(()=>{c(n,this.dom.container),requestAnimationFrame(()=>{m(s,this.dom.container),requestAnimationFrame(()=>{setTimeout(()=>{c(o,this.dom.container)},l)})})})):(m(s,this.dom.container),c(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:o,closeDuration:l,bootstrapTransitions:a,isTopLevel:d}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),o!==""?a?d?(this.dom.container.style.height=`${this.dom.container.offsetHeight}px`,requestAnimationFrame(()=>{m(o,this.dom.container),requestAnimationFrame(()=>{c(n,this.dom.container),c(s,this.dom.container),this.dom.container.style.height="",requestAnimationFrame(()=>{setTimeout(()=>{c(o,this.dom.container),m(s,this.dom.container)},l)})})})):(m(s,this.dom.container),c(n,this.dom.container)):(m(o,this.dom.container),requestAnimationFrame(()=>{c(n,this.dom.container),requestAnimationFrame(()=>{m(s,this.dom.container),requestAnimationFrame(()=>{setTimeout(()=>{c(o,this.dom.container)},l)})})})):(m(s,this.dom.container),c(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class $ extends x{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:a=".dropdown-menu",controllerElement:d=null,containerElement:f=null,openClass:g="show",closeClass:_="collapse",transitionClass:b="collapsing",transitionDuration:p=350,openDuration:M=-1,closeDuration:y=-1,isTopLevel:E=!0,parentMenu:T=null,hoverType:D="off",hoverDelay:w=250,enterDelay:v=-1,leaveDelay:I=-1,prefix:P="am-",bootstrapTransitions:V=!0,disableBootstrap:B=!0,initialize:H=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:a,controllerElement:d,containerElement:f,openClass:g,closeClass:_,transitionClass:b,transitionDuration:p,openDuration:M,closeDuration:y,isTopLevel:E,parentMenu:T,hoverType:D,hoverDelay:w,enterDelay:v,leaveDelay:I,prefix:P,initialize:!1});r(this,"_MenuType",$);r(this,"_MenuItemType",Q);r(this,"_MenuToggleType",N);r(this,"_disableBootstrap",!0);r(this,"_pseudoDropdownElement",document.createElement("div"));r(this,"_bootstrapDropdownEvents",["show.bs.dropdown","shown.bs.dropdown","hide.bs.dropdown","hidden.bs.dropdown"]);r(this,"_pseudoCollapseElement",document.createElement("div"));r(this,"_bootstrapCollapseEvents",["show.bs.collapse","shown.bs.collapse","hide.bs.collapse","hidden.bs.collapse"]);r(this,"_bootstrapTransitions",!0);this._disableBootstrap=B,this._bootstrapTransitions=V,H&&this.initialize()}initialize(){super.initialize(),this.bootstrapDisabled&&(this._disableBootstrapDropdownBehaviour(),this._disableBootstrapCollapseBehaviour())}get bootstrapTransitions(){return this.isTopLevel?this._bootstrapTransitions:this.elements.rootMenu.bootstrapTransitions}get bootstrapDisabled(){return this._disableBootstrap}get bootstrapPseudoDropdownElement(){return this._pseudoDropdownElement}get bootstrapDropdownEvents(){return this._bootstrapDropdownEvents}get bootstrapPseudoCollapseElement(){return this._pseudoCollapseElement}get bootstrapCollapseEvents(){return this._bootstrapCollapseEvents}_validate(){let t=super._validate();const s=h("boolean",{bootstrapTransitions:this._bootstrapTransitions});s.status||(this._errors.push(s.error.message),t=!1);const n=h("boolean",{disableBootstrap:this._disableBootstrap});return n.status||(this._errors.push(n.error.message),t=!1),t}_disableBootstrapDropdownBehaviour(){this.elements.submenuToggles.forEach(t=>{this.bootstrapDropdownEvents.forEach(s=>{t.dom.toggle.addEventListener(s,n=>{u(n);const o=bootstrap.Dropdown.getInstance(n.target);o&&o._menu!==this.bootstrapPseudoDropdownElement&&(o._menu=this.bootstrapPseudoDropdownElement)},{once:!0})})})}_disableBootstrapCollapseBehaviour(){this.elements.controller&&this.bootstrapCollapseEvents.forEach(t=>{this.dom.container.addEventListener(t,s=>{u(s);const n=bootstrap.Collapse.getInstance(s.target);n&&n._element!==this.bootstrapPseudoCollapseElement&&(n._element=this.bootstrapPseudoCollapseElement)},{once:!0})})}_setTransitionDurations(){super._setTransitionDurations(),this.isTopLevel&&this.elements.controller&&(this.elements.controller.dom.container.style.setProperty(`--${this.prefix}transition-duration`,`${this.transitionDuration}ms`),this.elements.controller.dom.container.style.setProperty(`--${this.prefix}open-transition-duration`,`${this.openDuration}ms`),this.elements.controller.dom.container.style.setProperty(`--${this.prefix}close-transition-duration`,`${this.closeDuration}ms`))}}module.exports=$; |
@@ -1,3 +0,3 @@ | ||
var Bootstrap5Menubar=function(){"use strict";var P=Object.defineProperty;var R=(m,c,f)=>c in m?P(m,c,{enumerable:!0,configurable:!0,writable:!0,value:f}):m[c]=f;var o=(m,c,f)=>(R(m,typeof c!="symbol"?c+"":c,f),f);function m(i,e){typeof i=="string"?e.classList.add(i):e.classList.add(...i)}function c(i,e){typeof i=="string"?e.classList.remove(i):e.classList.remove(...i)}function f(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function p(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function k(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid query selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function g(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],k(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function z(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function j(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function $(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function V(i,e){if(p("string",{tagName:i}).status&&f(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class x{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){o(this,"_dom",{toggle:null,parent:null});o(this,"_elements",{controlledMenu:null,parentMenu:null});o(this,"_open",!1);o(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));o(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){this._setIds(),this._setAriaAttributes(),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){p("boolean",{value:e}),this._open=e}_setIds(){var e;if(this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`menu-button-${n}`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`menu-${n}`}}_setAriaAttributes(){this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),V("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id)}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(m(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&c(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&m(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{c(n,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&m(s,this.elements.controlledMenu.dom.menu),t!==""&&c(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(m(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&c(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&m(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{c(n,this.elements.controlledMenu.dom.menu)})})})):(t!==""&&m(t,this.elements.controlledMenu.dom.menu),s!==""&&c(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class F{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null}){o(this,"_dom",{item:null,link:null});o(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});o(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=r,this._elements.toggle=l,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function v(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function u(i){i.preventDefault(),i.stopPropagation()}class I{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="",submenuToggleSelector:r="a",submenuSelector:l="ul",controllerElement:a=null,containerElement:d=null,openClass:h="show",closeClass:b="hide",transitionClass:y="transitioning",isTopLevel:_=!0,parentMenu:M=null,hoverType:C="off",hoverDelay:E=250,enterDelay:T=-1,leaveDelay:w=-1}){o(this,"_MenuType",I);o(this,"_MenuItemType",F);o(this,"_MenuToggleType",x);o(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});o(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});o(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});o(this,"_openClass","show");o(this,"_closeClass","hide");o(this,"_transitionClass","transitioning");o(this,"_root",!0);o(this,"_currentChild",0);o(this,"_focusState","none");o(this,"_currentEvent","none");o(this,"_hoverType","off");o(this,"_hoverDelay",250);o(this,"_enterDelay",-1);o(this,"_leaveDelay",-1);o(this,"_hoverTimeout",null);o(this,"_errors",[]);this._dom.menu=e,this._dom.controller=a,this._dom.container=d,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=r,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=M,this._elements.rootMenu=_?this:null,this._openClass=h||"",this._closeClass=b||"",this._transitionClass=y||"",this._root=_,this._hoverType=C,this._hoverDelay=E,this._enterDelay=T,this._leaveDelay=w}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
var Bootstrap5Menubar=function(){"use strict";var Q=Object.defineProperty;var N=(a,h,f)=>h in a?Q(a,h,{enumerable:!0,configurable:!0,writable:!0,value:f}):a[h]=f;var r=(a,h,f)=>N(a,typeof h!="symbol"?h+"":h,f);function a(i,e){i===""||i.length===0||(typeof i=="string"?e.classList.add(i):e.classList.add(...i))}function h(i,e){i===""||i.length===0||(typeof i=="string"?e.classList.remove(i):e.classList.remove(...i))}function f(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function m(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function L(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid query selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function M(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],L(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function P(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function V(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function O(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function B(i,e){if(m("string",{tagName:i}).status&&f(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class F{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){r(this,"_dom",{toggle:null,parent:null});r(this,"_elements",{controlledMenu:null,parentMenu:null});r(this,"_open",!1);r(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));r(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){this._setIds(),this._setAriaAttributes(),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){m("boolean",{value:e}),this._open=e}_setIds(){var e;if(this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`menu-button-${n}`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`menu-${n}`}}_setAriaAttributes(){this.dom.toggle.setAttribute("aria-expanded","false"),this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id)}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n,openDuration:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),this.elements.controlledMenu.elements.rootMenu.hasOpened=!0,n!==""?(a(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{h(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{a(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{setTimeout(()=>{h(n,this.elements.controlledMenu.dom.menu)},o)})})})):(a(s,this.elements.controlledMenu.dom.menu),h(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n,closeDuration:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(a(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{h(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{a(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{setTimeout(()=>{h(n,this.elements.controlledMenu.dom.menu)},o)})})})):(a(t,this.elements.controlledMenu.dom.menu),h(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this.isOpen||(this._expand(),this.isOpen=!0)}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this.isOpen||(this._expand(),this.isOpen=!0)}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class q{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:l=null}){r(this,"_dom",{item:null,link:null});r(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});r(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=o,this._elements.toggle=l,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&requestAnimationFrame(()=>{this.dom.link.focus()})}blur(){this.elements.parentMenu.shouldFocus&&requestAnimationFrame(()=>{this.dom.link.blur()})}}function k(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function u(i){i.preventDefault(),i.stopPropagation()}class S{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="li:has(ul)",submenuToggleSelector:o="a",submenuSelector:l="ul",controllerElement:c=null,containerElement:d=null,openClass:g="show",closeClass:_="hide",transitionClass:b="transitioning",transitionDuration:y=250,openDuration:p=-1,closeDuration:E=-1,isTopLevel:C=!0,parentMenu:T=null,hoverType:D="off",hoverDelay:w=250,enterDelay:v=-1,leaveDelay:I=-1,prefix:A="am-"}){r(this,"_MenuType",S);r(this,"_MenuItemType",q);r(this,"_MenuToggleType",F);r(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});r(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});r(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});r(this,"_openClass","show");r(this,"_closeClass","hide");r(this,"_transitionClass","transitioning");r(this,"_transitionDuration",250);r(this,"_openDuration",-1);r(this,"_closeDuration",-1);r(this,"_root",!0);r(this,"_currentChild",0);r(this,"_focusState","none");r(this,"_currentEvent","none");r(this,"_hoverType","off");r(this,"_hoverDelay",250);r(this,"_enterDelay",-1);r(this,"_leaveDelay",-1);r(this,"_prefix","am-");r(this,"_hoverTimeout",null);r(this,"_hasOpened",!1);r(this,"_errors",[]);this._dom.menu=e,this._dom.controller=c,this._dom.container=d,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=o,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=T,this._elements.rootMenu=C?this:null,this._openClass=g||"",this._closeClass=_||"",this._transitionClass=b||"",this._transitionDuration=y,this._openDuration=p,this._closeDuration=E,this._prefix=A||"",this._root=C,this._hoverType=D,this._hoverDelay=w,this._enterDelay=v,this._leaveDelay=I}initialize(){if(!this._validate())throw new Error(`AccessibleMenu: cannot initialize menu. The following errors have been found: | ||
- ${this.errors.join(` | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){g({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set currentChild(e){p("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let r=0,l=!1;for(;!l&&r<s.elements.parentMenu.elements.menuItems.length;){const a=s.elements.parentMenu.elements.menuItems[r];a.isSubmenuItem&&a.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=r),r++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){z({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){j({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){$({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){p("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){p("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){p("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=f(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=f(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=k({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=k({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const h=g({openClass:this._openClass});h.status||(this._errors.push(h.error.message),e=!1)}if(this._closeClass!==""){const h=g({closeClass:this._closeClass});h.status||(this._errors.push(h.error.message),e=!1)}if(this._transitionClass!==""){const h=g({transitionClass:this._transitionClass});h.status||(this._errors.push(h.error.message),e=!1)}const n=p("boolean",{isTopLevel:this._root});if(n.status||(this._errors.push(n.error.message),e=!1),this._elements.parentMenu!==null){const h=f(I,{parentMenu:this._elements.parentMenu});h.status||(this._errors.push(h.error.message),e=!1)}const r=$({hoverType:this._hoverType});r.status||(this._errors.push(r.error.message),e=!1);const l=p("number",{hoverDelay:this._hoverDelay});l.status||(this._errors.push(l.error.message),e=!1);const a=p("number",{enterDelay:this._enterDelay});a.status||(this._errors.push(a.error.message),e=!1);const d=p("number",{leaveDelay:this._leaveDelay});return d.status||(this._errors.push(d.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&f(HTMLElement,{base:t});const r=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=r:this._dom[e]=[...this._dom[e],...r]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),r=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:r,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:r,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,n){u(n),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t),e.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview());else if(this.hoverType==="dynamic"){const n=this.elements.submenuToggles.some(r=>r.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||n)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=v(e);(t==="Space"||t==="Enter")&&u(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=v(e);(t==="Space"||t==="Enter")&&(u(e),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class O extends F{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:a=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l}),a&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","menuitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=0)}blur(){super.blur(),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=-1)}}class q extends x{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),r&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&(this.closeChildren(),this.elements.parentMenu&&this.elements.parentMenu.focusCurrentChild()),super.close()}}class D extends I{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:r="",submenuToggleSelector:l="a",submenuSelector:a="ul",controllerElement:d=null,containerElement:h=null,openClass:b="show",closeClass:y="hide",transitionClass:_="transitioning",isTopLevel:M=!0,parentMenu:C=null,hoverType:E="off",hoverDelay:T=250,enterDelay:w=-1,leaveDelay:A=-1,initialize:L=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:a,controllerElement:d,containerElement:h,openClass:b,closeClass:y,transitionClass:_,isTopLevel:M,parentMenu:C,hoverType:E,hoverDelay:T,enterDelay:w,leaveDelay:A});o(this,"_MenuType",D);o(this,"_MenuItemType",O);o(this,"_MenuToggleType",q);L&&this.initialize()}initialize(){try{super.initialize(),this.isTopLevel?this.dom.menu.setAttribute("role","menubar"):this.dom.menu.setAttribute("role","menu"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup(),this.isTopLevel&&(this.elements.menuItems[0].dom.link.tabIndex=0)}catch(t){console.error(t)}}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=v(t);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?(this.elements.rootMenu.blur(),this.elements.rootMenu.closeChildren()):this.elements.rootMenu.focus()),s==="Character")u(t);else if(this.isTopLevel){if(this.focusState==="self"){const n=["ArrowRight","ArrowLeft","Home","End"],r=["Space","Enter","ArrowDown","ArrowUp"],l=["Escape"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&r.includes(s)||this.elements.controller&&l.includes(s))&&u(t)}}else{const n=["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"],r=["Space","Enter"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&r.includes(s))&&u(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=v(t),{altKey:n,crtlKey:r,metaKey:l}=t;if(s==="Character"&&!(n||r||l))u(t),this.elements.rootMenu.currentEvent="character",this.focusNextChildWithCharacter(t.key);else if(this.isTopLevel){if(this.focusState==="self")if(s==="Space"||s==="Enter")this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click();else if(s==="ArrowRight"){u(t);const d=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusNextChild(),d&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if(s==="ArrowLeft"){u(t);const d=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusPreviousChild(),d&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else s==="ArrowDown"?this.currentMenuItem.isSubmenuItem&&(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):s==="ArrowUp"?this.currentMenuItem.isSubmenuItem&&(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusLastChild()})):s==="Home"?(u(t),this.focusFirstChild()):s==="End"?(u(t),this.focusLastChild()):s==="Escape"&&(this.elements.submenuToggles.some(h=>h.isOpen)?(u(t),this.closeChildren()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(u(t),this.elements.controller.close(),this.focusController()))}else s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click():s==="Escape"?(u(t),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusCurrentChild()):s==="ArrowRight"?this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):(u(t),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusNextChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&this.elements.rootMenu.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?this.elements.parentMenu.currentMenuItem.isSubmenuItem&&(u(t),this.elements.parentMenu.currentMenuItem.elements.toggle.close(),this.elements.parentMenu.focusCurrentChild(),this.elements.parentMenu===this.elements.rootMenu&&(this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusPreviousChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&(this.elements.rootMenu.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.elements.rootMenu.currentMenuItem.elements.toggle.preview()))):s==="ArrowDown"?(u(t),this.focusNextChild()):s==="ArrowUp"?(u(t),this.focusPreviousChild()):s==="Home"?(u(t),this.focusFirstChild()):s==="End"&&(u(t),this.focusLastChild())})}focusNextChild(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}focusPreviousChild(){this.currentChild===0?this.focusLastChild():this.focusChild(this.currentChild-1)}focusNextChildWithCharacter(t){const s=t.toLowerCase();let n=this.currentChild+1,r=!1;for(;!r&&n<this.elements.menuItems.length;){let l="";this.elements.menuItems[n].dom.item.innerText?l=this.elements.menuItems[n].dom.item.innerText:l=this.elements.menuItems[n].dom.item.textContent,l=l.replace(/[\s]/g,"").toLowerCase().charAt(0),l===s&&(r=!0,this.focusChild(n)),n++}}}class H extends O{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:a=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l,initialize:!1}),a&&this.initialize()}}class K extends q{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r,initialize:!1});o(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,l&&this.initialize()}_expand(t=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(m(n,this.dom.container),requestAnimationFrame(()=>{m(s,this.dom.container),requestAnimationFrame(()=>{c(n,this.dom.container)})})):s!==""&&m(s,this.dom.container),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:r}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),r!==""?(m(r,this.dom.container),requestAnimationFrame(()=>{n!==""&&c(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&m(s,this.dom.container),requestAnimationFrame(()=>{c(r,this.dom.container)})})})):(s!==""&&m(s,this.dom.container),n!==""&&c(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class S extends D{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:r=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:a=".dropdown-menu",controllerElement:d=null,containerElement:h=null,openClass:b="show",closeClass:y="collapse",transitionClass:_="transitioning",isTopLevel:M=!0,parentMenu:C=null,hoverType:E="off",hoverDelay:T=250,enterDelay:w=-1,leaveDelay:A=-1,disableBootstrap:L=!0,initialize:B=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:a,controllerElement:d,containerElement:h,openClass:b,closeClass:y,transitionClass:_,isTopLevel:M,parentMenu:C,hoverType:E,hoverDelay:T,enterDelay:w,leaveDelay:A,initialize:!1});o(this,"_MenuType",S);o(this,"_MenuItemType",H);o(this,"_MenuToggleType",K);o(this,"_disableBootstrap",!0);o(this,"_pseudoDropdownElement",document.createElement("div"));o(this,"_bootstrapEvents",["show.bs.dropdown","shown.bs.dropdown","hide.bs.dropdown","hidden.bs.dropdown"]);this._disableBootstrap=L,B&&this.initialize()}initialize(){super.initialize(),this.bootstrapDisabled&&this._disableBootstrapDropdownBehaviour()}get bootstrapDisabled(){return this._disableBootstrap}get bootstrapPseudoDropdownElement(){return this._pseudoDropdownElement}get bootstrapEvents(){return this._bootstrapEvents}_validate(){let t=super._validate();const s=p("boolean",{disableBootstrap:this._disableBootstrap});return s.status||(this._errors.push(s.error.message),t=!1),t}_disableBootstrapDropdownBehaviour(){this.elements.submenuToggles.forEach(t=>{this.bootstrapEvents.forEach(s=>{t.dom.toggle.addEventListener(s,n=>{u(n);const r=bootstrap.Dropdown.getInstance(n.target);r&&r._menu!==this.bootstrapPseudoDropdownElement&&(r._menu=this.bootstrapPseudoDropdownElement)},{once:!0})})})}}return S}(); | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});B("button",{toggle:e.dom.toggle})||e.dom.toggle.setAttribute("role","button"),e.dom.toggle.setAttribute("aria-controls",this.dom.menu.id),this._elements.controller=e}this._createChildElements(),this._setTransitionDurations(),this.isTopLevel&&(window.AccessibleMenu=window.AccessibleMenu||{menus:{}},window.AccessibleMenu.menus[this.dom.menu.id]=this)}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get transitionDuration(){return this.isTopLevel?this._transitionDuration:this.elements.rootMenu.transitionDuration}get openDuration(){return this._openDuration===-1?this.transitionDuration:this.isTopLevel?this._openDuration:this.elements.rootMenu.openDuration}get closeDuration(){return this._closeDuration===-1?this.transitionDuration:this.isTopLevel?this._closeDuration:this.elements.rootMenu.closeDuration}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get prefix(){return this._root?this._prefix:this.elements.rootMenu.prefix}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get hasOpened(){return this._root?this._hasOpened:this.elements.rootMenu.hasOpened}get errors(){return this._errors}set openClass(e){M({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){M({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){M({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set transitionDuration(e){m("number",{value:e}),this._transitionDuration!==e&&(this._transitionDuration=e,this._setTransitionDurations())}set openDuration(e){m("number",{value:e}),this._openDuration!==e&&(this._openDuration=e,this._setTransitionDurations())}set closeDuration(e){m("number",{value:e}),this._closeDuration!==e&&(this._closeDuration=e,this._setTransitionDurations())}set currentChild(e){m("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let o=0,l=!1;for(;!l&&o<s.elements.parentMenu.elements.menuItems.length;){const c=s.elements.parentMenu.elements.menuItems[o];c.isSubmenuItem&&c.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=o),o++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){P({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){V({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){O({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){m("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){m("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){m("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}set prefix(e){m("string",{value:e}),this._prefix!==e&&(this._prefix=e)}set hasOpened(e){m("boolean",{value:e}),this._hasOpened!==e&&(this._hasOpened=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=f(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=f(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=L({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=L({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const p=M({openClass:this._openClass});p.status||(this._errors.push(p.error.message),e=!1)}if(this._closeClass!==""){const p=M({closeClass:this._closeClass});p.status||(this._errors.push(p.error.message),e=!1)}if(this._transitionClass!==""){const p=M({transitionClass:this._transitionClass});p.status||(this._errors.push(p.error.message),e=!1)}const n=m("number",{transitionDuration:this._transitionDuration});n.status||(this._errors.push(n.error.message),e=!1);const o=m("number",{openDuration:this._openDuration});o.status||(this._errors.push(o.error.message),e=!1);const l=m("number",{closeDuration:this._closeDuration});l.status||(this._errors.push(l.error.message),e=!1);const c=m("boolean",{isTopLevel:this._root});if(c.status||(this._errors.push(c.error.message),e=!1),this._elements.parentMenu!==null){const p=f(S,{parentMenu:this._elements.parentMenu});p.status||(this._errors.push(p.error.message),e=!1)}const d=O({hoverType:this._hoverType});d.status||(this._errors.push(d.error.message),e=!1);const g=m("number",{hoverDelay:this._hoverDelay});g.status||(this._errors.push(g.error.message),e=!1);const _=m("number",{enterDelay:this._enterDelay});_.status||(this._errors.push(_.error.message),e=!1);const b=m("number",{leaveDelay:this._leaveDelay});b.status||(this._errors.push(b.error.message),e=!1);const y=m("string",{prefix:this._prefix});return y.status||(this._errors.push(y.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&f(HTMLElement,{base:t});const o=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=o:this._dom[e]=[...this._dom[e],...o]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,transitionDuration:this.transitionDuration,openDuration:this.openDuration,closeDuration:this.closeDuration,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_clearTimeout(){clearTimeout(this._hoverTimeout)}_setTimeout(e,t){m("function",{callback:e}),m("number",{delay:t}),this._hoverTimeout=setTimeout(e,t)}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})}),this.dom.menu.addEventListener("focusout",e=>{this.currentEvent!=="keyboard"||e.relatedTarget===null||this.dom.menu.contains(e.relatedTarget)||(this.focusState="none",this.closeChildren())})}_handleClick(){function e(t,s,n){u(n),n.button===0&&(s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none"))}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this._clearTimeout(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)}),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.elements.rootMenu.hasOpened=this.elements.submenuToggles.some(s=>s.isOpen)))})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t),e.isSubmenuItem&&(this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay)):e.elements.toggle.preview())):this.hoverType==="dynamic"&&(this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),(!this.isTopLevel||this.hasOpened)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),e.isSubmenuItem?this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay)):e.elements.toggle.preview():this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.closeChildren()},this.enterDelay)):this.closeChildren())))}),e.isSubmenuItem&&(e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse"},this.leaveDelay)):this.currentEvent="mouse"))}),e.dom.item.addEventListener("pointerenter",s=>{s.pointerType==="pen"||s.pointerType==="touch"||e.isSubmenuItem&&(this.hoverType==="on"||this.hoverType==="dynamic")&&this.leaveDelay>0&&this._clearTimeout()}))})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=k(e);(t==="Space"||t==="Enter")&&u(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=k(e);(t==="Space"||t==="Enter")&&(u(e),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}_setTransitionDurations(){this.dom.menu.style.setProperty(`--${this.prefix}transition-duration`,`${this.transitionDuration}ms`),this.dom.menu.style.setProperty(`--${this.prefix}open-transition-duration`,`${this.openDuration}ms`),this.dom.menu.style.setProperty(`--${this.prefix}close-transition-duration`,`${this.closeDuration}ms`)}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class z extends q{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:l=null,initialize:c=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:o,toggle:l}),c&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","menuitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=0)}blur(){super.blur(),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=-1)}}class j extends F{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:o=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),o&&this.initialize()}_setAriaAttributes(){super._setAriaAttributes(),this.dom.toggle.setAttribute("aria-haspopup","true")}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&(this.closeChildren(),this.elements.parentMenu&&this.elements.parentMenu.focusCurrentChild()),super.close()}}class x extends S{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:o="li:has(ul)",submenuToggleSelector:l="a",submenuSelector:c="ul",controllerElement:d=null,containerElement:g=null,openClass:_="show",closeClass:b="hide",transitionClass:y="transitioning",transitionDuration:p=250,isTopLevel:E=!0,parentMenu:C=null,hoverType:T="off",hoverDelay:D=250,enterDelay:w=-1,leaveDelay:v=-1,prefix:I="am-",initialize:A=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:c,controllerElement:d,containerElement:g,openClass:_,closeClass:b,transitionClass:y,transitionDuration:p,isTopLevel:E,parentMenu:C,hoverType:T,hoverDelay:D,enterDelay:w,leaveDelay:v,prefix:I});r(this,"_MenuType",x);r(this,"_MenuItemType",z);r(this,"_MenuToggleType",j);A&&this.initialize()}initialize(){try{super.initialize(),this.isTopLevel?this.dom.menu.setAttribute("role","menubar"):this.dom.menu.setAttribute("role","menu"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup(),this.isTopLevel&&(this.elements.menuItems[0].dom.link.tabIndex=0,this.elements.controller&&this.elements.controller.dom.toggle.removeAttribute("aria-haspopup"))}catch(t){console.error(t)}}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close(),this.elements.rootMenu.hasOpened=!1))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=k(t);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?(this.elements.rootMenu.blur(),this.elements.rootMenu.closeChildren()):this.elements.rootMenu.focus()),s==="Character")u(t);else if(this.isTopLevel){if(this.focusState==="self"){const n=["ArrowRight","ArrowLeft","Home","End"],o=["Space","Enter","ArrowDown","ArrowUp"],l=["Escape"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&o.includes(s)||this.elements.controller&&l.includes(s))&&u(t)}}else{const n=["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"],o=["Space","Enter"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&o.includes(s))&&u(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=k(t),{altKey:n,crtlKey:o,metaKey:l}=t;if(s==="Character"&&!(n||o||l))u(t),this.elements.rootMenu.currentEvent="character",this.focusNextChildWithCharacter(t.key);else if(this.isTopLevel){if(this.focusState==="self")if(s==="Space"||s==="Enter")this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click();else if(s==="ArrowRight"){u(t);const d=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusNextChild(),d&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if(s==="ArrowLeft"){u(t);const d=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusPreviousChild(),d&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else s==="ArrowDown"?this.currentMenuItem.isSubmenuItem&&(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):s==="ArrowUp"?this.currentMenuItem.isSubmenuItem&&(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusLastChild()})):s==="Home"?(u(t),this.focusFirstChild()):s==="End"?(u(t),this.focusLastChild()):s==="Escape"&&(this.elements.submenuToggles.some(g=>g.isOpen)?(u(t),this.closeChildren()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(u(t),this.elements.controller.close(),this.focusController()))}else s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click():s==="Escape"?(u(t),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusCurrentChild()):s==="ArrowRight"?this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):(u(t),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusNextChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&this.elements.rootMenu.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?this.elements.parentMenu.currentMenuItem.isSubmenuItem&&(u(t),this.elements.parentMenu.currentMenuItem.elements.toggle.close(),this.elements.parentMenu.focusCurrentChild(),this.elements.parentMenu===this.elements.rootMenu&&(this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusPreviousChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&(this.elements.rootMenu.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.elements.rootMenu.currentMenuItem.elements.toggle.preview()))):s==="ArrowDown"?(u(t),this.focusNextChild()):s==="ArrowUp"?(u(t),this.focusPreviousChild()):s==="Home"?(u(t),this.focusFirstChild()):s==="End"&&(u(t),this.focusLastChild())})}focusNextChild(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}focusPreviousChild(){this.currentChild===0?this.focusLastChild():this.focusChild(this.currentChild-1)}focusNextChildWithCharacter(t){const s=t.toLowerCase();let n=this.currentChild+1,o=!1;for(;!o&&n<this.elements.menuItems.length;){let l="";this.elements.menuItems[n].dom.item.innerText?l=this.elements.menuItems[n].dom.item.innerText:l=this.elements.menuItems[n].dom.item.textContent,l=l.replace(/[\s]/g,"").toLowerCase().charAt(0),l===s&&(o=!0,this.focusChild(n)),n++}}}class H extends z{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:l=null,initialize:c=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:o,toggle:l,initialize:!1}),c&&this.initialize()}}class K extends j{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o,initialize:!1});r(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,l&&this.initialize()}initialize(){super.initialize(),this.elements.controlledMenu.bootstrapTransitions&&this.elements.controlledMenu.isTopLevel&&(this.dom.container.style.transition="height var(--am-transition-duration) ease")}_expand(t=!0){const{openClass:s,closeClass:n,transitionClass:o,openDuration:l,bootstrapTransitions:c,isTopLevel:d}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),this.elements.controlledMenu.elements.rootMenu.hasOpened=!0,o!==""?c?d?(a(o,this.dom.container),h(n,this.dom.container),this.dom.container.style.height=`${this.dom.container.scrollHeight}px`,requestAnimationFrame(()=>{setTimeout(()=>{a(s,this.dom.container),a(n,this.dom.container),h(o,this.dom.container),this.dom.container.style.height=""},l)})):(a(s,this.dom.container),h(n,this.dom.container)):(a(o,this.dom.container),requestAnimationFrame(()=>{h(n,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{setTimeout(()=>{h(o,this.dom.container)},l)})})})):(a(s,this.dom.container),h(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:o,closeDuration:l,bootstrapTransitions:c,isTopLevel:d}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),o!==""?c?d?(this.dom.container.style.height=`${this.dom.container.offsetHeight}px`,requestAnimationFrame(()=>{a(o,this.dom.container),requestAnimationFrame(()=>{h(n,this.dom.container),h(s,this.dom.container),this.dom.container.style.height="",requestAnimationFrame(()=>{setTimeout(()=>{h(o,this.dom.container),a(s,this.dom.container)},l)})})})):(a(s,this.dom.container),h(n,this.dom.container)):(a(o,this.dom.container),requestAnimationFrame(()=>{h(n,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{setTimeout(()=>{h(o,this.dom.container)},l)})})})):(a(s,this.dom.container),h(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class $ extends x{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:c=".dropdown-menu",controllerElement:d=null,containerElement:g=null,openClass:_="show",closeClass:b="collapse",transitionClass:y="collapsing",transitionDuration:p=350,openDuration:E=-1,closeDuration:C=-1,isTopLevel:T=!0,parentMenu:D=null,hoverType:w="off",hoverDelay:v=250,enterDelay:I=-1,leaveDelay:A=-1,prefix:R="am-",bootstrapTransitions:U=!0,disableBootstrap:W=!0,initialize:Z=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:c,controllerElement:d,containerElement:g,openClass:_,closeClass:b,transitionClass:y,transitionDuration:p,openDuration:E,closeDuration:C,isTopLevel:T,parentMenu:D,hoverType:w,hoverDelay:v,enterDelay:I,leaveDelay:A,prefix:R,initialize:!1});r(this,"_MenuType",$);r(this,"_MenuItemType",H);r(this,"_MenuToggleType",K);r(this,"_disableBootstrap",!0);r(this,"_pseudoDropdownElement",document.createElement("div"));r(this,"_bootstrapDropdownEvents",["show.bs.dropdown","shown.bs.dropdown","hide.bs.dropdown","hidden.bs.dropdown"]);r(this,"_pseudoCollapseElement",document.createElement("div"));r(this,"_bootstrapCollapseEvents",["show.bs.collapse","shown.bs.collapse","hide.bs.collapse","hidden.bs.collapse"]);r(this,"_bootstrapTransitions",!0);this._disableBootstrap=W,this._bootstrapTransitions=U,Z&&this.initialize()}initialize(){super.initialize(),this.bootstrapDisabled&&(this._disableBootstrapDropdownBehaviour(),this._disableBootstrapCollapseBehaviour())}get bootstrapTransitions(){return this.isTopLevel?this._bootstrapTransitions:this.elements.rootMenu.bootstrapTransitions}get bootstrapDisabled(){return this._disableBootstrap}get bootstrapPseudoDropdownElement(){return this._pseudoDropdownElement}get bootstrapDropdownEvents(){return this._bootstrapDropdownEvents}get bootstrapPseudoCollapseElement(){return this._pseudoCollapseElement}get bootstrapCollapseEvents(){return this._bootstrapCollapseEvents}_validate(){let t=super._validate();const s=m("boolean",{bootstrapTransitions:this._bootstrapTransitions});s.status||(this._errors.push(s.error.message),t=!1);const n=m("boolean",{disableBootstrap:this._disableBootstrap});return n.status||(this._errors.push(n.error.message),t=!1),t}_disableBootstrapDropdownBehaviour(){this.elements.submenuToggles.forEach(t=>{this.bootstrapDropdownEvents.forEach(s=>{t.dom.toggle.addEventListener(s,n=>{u(n);const o=bootstrap.Dropdown.getInstance(n.target);o&&o._menu!==this.bootstrapPseudoDropdownElement&&(o._menu=this.bootstrapPseudoDropdownElement)},{once:!0})})})}_disableBootstrapCollapseBehaviour(){this.elements.controller&&this.bootstrapCollapseEvents.forEach(t=>{this.dom.container.addEventListener(t,s=>{u(s);const n=bootstrap.Collapse.getInstance(s.target);n&&n._element!==this.bootstrapPseudoCollapseElement&&(n._element=this.bootstrapPseudoCollapseElement)},{once:!0})})}_setTransitionDurations(){super._setTransitionDurations(),this.isTopLevel&&this.elements.controller&&(this.elements.controller.dom.container.style.setProperty(`--${this.prefix}transition-duration`,`${this.transitionDuration}ms`),this.elements.controller.dom.container.style.setProperty(`--${this.prefix}open-transition-duration`,`${this.openDuration}ms`),this.elements.controller.dom.container.style.setProperty(`--${this.prefix}close-transition-duration`,`${this.closeDuration}ms`))}}return $}(); |
@@ -1,3 +0,3 @@ | ||
"use strict";var V=Object.defineProperty;var H=(i,e,t)=>e in i?V(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var r=(i,e,t)=>(H(i,typeof e!="symbol"?e+"":e,t),t);function d(i,e){typeof i=="string"?e.classList.add(i):e.classList.add(...i)}function p(i,e){typeof i=="string"?e.classList.remove(i):e.classList.remove(...i)}function M(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function c(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function w(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid query selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function g(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],w(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function B(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function P(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function F(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function R(i,e){if(c("string",{tagName:i}).status&&M(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class x{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){r(this,"_dom",{toggle:null,parent:null});r(this,"_elements",{controlledMenu:null,parentMenu:null});r(this,"_open",!1);r(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));r(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){this._setIds(),this._setAriaAttributes(),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){c("boolean",{value:e}),this._open=e}_setIds(){var e;if(this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`menu-button-${n}`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`menu-${n}`}}_setAriaAttributes(){this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),R("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id)}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(d(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&p(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&d(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{p(n,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&d(s,this.elements.controlledMenu.dom.menu),t!==""&&p(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(d(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&p(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&d(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{p(n,this.elements.controlledMenu.dom.menu)})})})):(t!==""&&d(t,this.elements.controlledMenu.dom.menu),s!==""&&p(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class j{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:l=null}){r(this,"_dom",{item:null,link:null});r(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});r(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=o,this._elements.toggle=l,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function S(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function m(i){i.preventDefault(),i.stopPropagation()}class D{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="",submenuToggleSelector:o="a",submenuSelector:l="ul",controllerElement:h=null,containerElement:a=null,openClass:u="show",closeClass:_="hide",transitionClass:y="transitioning",isTopLevel:f=!0,parentMenu:b=null,hoverType:C="off",hoverDelay:E=250,enterDelay:T=-1,leaveDelay:v=-1}){r(this,"_MenuType",D);r(this,"_MenuItemType",j);r(this,"_MenuToggleType",x);r(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});r(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});r(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});r(this,"_openClass","show");r(this,"_closeClass","hide");r(this,"_transitionClass","transitioning");r(this,"_root",!0);r(this,"_currentChild",0);r(this,"_focusState","none");r(this,"_currentEvent","none");r(this,"_hoverType","off");r(this,"_hoverDelay",250);r(this,"_enterDelay",-1);r(this,"_leaveDelay",-1);r(this,"_hoverTimeout",null);r(this,"_errors",[]);this._dom.menu=e,this._dom.controller=h,this._dom.container=a,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=o,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=b,this._elements.rootMenu=f?this:null,this._openClass=u||"",this._closeClass=_||"",this._transitionClass=y||"",this._root=f,this._hoverType=C,this._hoverDelay=E,this._enterDelay=T,this._leaveDelay=v}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
"use strict";var Z=Object.defineProperty;var Q=(i,e,t)=>e in i?Z(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var r=(i,e,t)=>Q(i,typeof e!="symbol"?e+"":e,t);function m(i,e){i===""||i.length===0||(typeof i=="string"?e.classList.add(i):e.classList.add(...i))}function c(i,e){i===""||i.length===0||(typeof i=="string"?e.classList.remove(i):e.classList.remove(...i))}function k(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function u(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function L(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid query selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function T(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],L(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function W(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function G(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function q(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function z(i,e){if(u("string",{tagName:i}).status&&k(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class j{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){r(this,"_dom",{toggle:null,parent:null});r(this,"_elements",{controlledMenu:null,parentMenu:null});r(this,"_open",!1);r(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));r(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){this._setIds(),this._setAriaAttributes(),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){u("boolean",{value:e}),this._open=e}_setIds(){var e;if(this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`menu-button-${n}`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`menu-${n}`}}_setAriaAttributes(){this.dom.toggle.setAttribute("aria-expanded","false"),this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id)}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n,openDuration:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),this.elements.controlledMenu.elements.rootMenu.hasOpened=!0,n!==""?(m(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{c(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{m(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{setTimeout(()=>{c(n,this.elements.controlledMenu.dom.menu)},o)})})})):(m(s,this.elements.controlledMenu.dom.menu),c(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n,closeDuration:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(m(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{c(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{m(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{setTimeout(()=>{c(n,this.elements.controlledMenu.dom.menu)},o)})})})):(m(t,this.elements.controlledMenu.dom.menu),c(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this.isOpen||(this._expand(),this.isOpen=!0)}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this.isOpen||(this._expand(),this.isOpen=!0)}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class K{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:l=null}){r(this,"_dom",{item:null,link:null});r(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});r(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=o,this._elements.toggle=l,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&requestAnimationFrame(()=>{this.dom.link.focus()})}blur(){this.elements.parentMenu.shouldFocus&&requestAnimationFrame(()=>{this.dom.link.blur()})}}function I(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function d(i){i.preventDefault(),i.stopPropagation()}class A{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="li:has(ul)",submenuToggleSelector:o="a",submenuSelector:l="ul",controllerElement:h=null,containerElement:a=null,openClass:f="show",closeClass:g="hide",transitionClass:_="transitioning",transitionDuration:y=250,openDuration:p=-1,closeDuration:C=-1,isTopLevel:b=!0,parentMenu:E=null,hoverType:M="off",hoverDelay:v=250,enterDelay:D=-1,leaveDelay:w=-1,prefix:S="am-"}){r(this,"_MenuType",A);r(this,"_MenuItemType",K);r(this,"_MenuToggleType",j);r(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});r(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});r(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});r(this,"_openClass","show");r(this,"_closeClass","hide");r(this,"_transitionClass","transitioning");r(this,"_transitionDuration",250);r(this,"_openDuration",-1);r(this,"_closeDuration",-1);r(this,"_root",!0);r(this,"_currentChild",0);r(this,"_focusState","none");r(this,"_currentEvent","none");r(this,"_hoverType","off");r(this,"_hoverDelay",250);r(this,"_enterDelay",-1);r(this,"_leaveDelay",-1);r(this,"_prefix","am-");r(this,"_hoverTimeout",null);r(this,"_hasOpened",!1);r(this,"_errors",[]);this._dom.menu=e,this._dom.controller=h,this._dom.container=a,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=o,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=E,this._elements.rootMenu=b?this:null,this._openClass=f||"",this._closeClass=g||"",this._transitionClass=_||"",this._transitionDuration=y,this._openDuration=p,this._closeDuration=C,this._prefix=S||"",this._root=b,this._hoverType=M,this._hoverDelay=v,this._enterDelay=D,this._leaveDelay=w}initialize(){if(!this._validate())throw new Error(`AccessibleMenu: cannot initialize menu. The following errors have been found: | ||
- ${this.errors.join(` | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){g({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set currentChild(e){c("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let o=0,l=!1;for(;!l&&o<s.elements.parentMenu.elements.menuItems.length;){const h=s.elements.parentMenu.elements.menuItems[o];h.isSubmenuItem&&h.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=o),o++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){B({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){P({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){F({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){c("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){c("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){c("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=M(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=M(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=w({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=w({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const u=g({openClass:this._openClass});u.status||(this._errors.push(u.error.message),e=!1)}if(this._closeClass!==""){const u=g({closeClass:this._closeClass});u.status||(this._errors.push(u.error.message),e=!1)}if(this._transitionClass!==""){const u=g({transitionClass:this._transitionClass});u.status||(this._errors.push(u.error.message),e=!1)}const n=c("boolean",{isTopLevel:this._root});if(n.status||(this._errors.push(n.error.message),e=!1),this._elements.parentMenu!==null){const u=M(D,{parentMenu:this._elements.parentMenu});u.status||(this._errors.push(u.error.message),e=!1)}const o=F({hoverType:this._hoverType});o.status||(this._errors.push(o.error.message),e=!1);const l=c("number",{hoverDelay:this._hoverDelay});l.status||(this._errors.push(l.error.message),e=!1);const h=c("number",{enterDelay:this._enterDelay});h.status||(this._errors.push(h.error.message),e=!1);const a=c("number",{leaveDelay:this._leaveDelay});return a.status||(this._errors.push(a.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&M(HTMLElement,{base:t});const o=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=o:this._dom[e]=[...this._dom[e],...o]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,n){m(n),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t),e.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview());else if(this.hoverType==="dynamic"){const n=this.elements.submenuToggles.some(o=>o.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||n)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=S(e);(t==="Space"||t==="Enter")&&m(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=S(e);(t==="Space"||t==="Enter")&&(m(e),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class q extends j{constructor({menuItemElement:t,menuLinkElement:s,parentMenu:n,isSubmenuItem:o=!1,childMenu:l=null,toggle:h=null,initialize:a=!0,submenuSibling:u=null}){super({menuItemElement:t,menuLinkElement:s,parentMenu:n,isSubmenuItem:o,childMenu:l,toggle:h});r(this,"_elements",{parentMenu:null,childMenu:null,toggle:null,sibling:null});this._elements.parentMenu=n,this._elements.childMenu=l,this._elements.toggle=h,this._elements.sibling=u,a&&this.initialize()}}class z extends x{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:o=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),o&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class $ extends D{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:o="",submenuToggleSelector:l="button",submenuSelector:h="ul",submenuSubtoggleSelector:a="a",controllerElement:u=null,containerElement:_=null,openClass:y="show",closeClass:f="hide",transitionClass:b="transitioning",isTopLevel:C=!0,parentMenu:E=null,hoverType:T="off",hoverDelay:v=250,enterDelay:k=-1,leaveDelay:I=-1,optionalKeySupport:L=!1,initialize:A=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuSelector:h,submenuToggleSelector:l,controllerElement:u,containerElement:_,openClass:y,closeClass:f,transitionClass:b,isTopLevel:C,parentMenu:E,hoverType:T,hoverDelay:v,enterDelay:k,leaveDelay:I});r(this,"_MenuType",$);r(this,"_MenuItemType",q);r(this,"_MenuToggleType",z);r(this,"_currentChild",-1);r(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:"",submenuSubtoggles:""});r(this,"_optionalSupport",!1);this._optionalSupport=L,this._selectors.menuItems=s,this._selectors.submenuItems=o,this._selectors.submenuToggles=l,this._selectors.submenus=h,this._selectors.submenuSubtoggles=a,this._selectors.menuLinks=[...new Set([n,l])].join(","),A&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(t){c("boolean",{optionalKeySupport:t}),this._optionalSupport=t}_createChildElements(){this.dom.menuItems.forEach(t=>{let s,n;const o=t.querySelector(this.selectors.menuLinks);if(this.dom.submenuItems.includes(t)){const l=t.querySelector(this.selectors.submenuToggles),h=t.querySelector(this.selectors.submenus),a=new this._MenuType({menuElement:h,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuSubtoggles,submenuSelector:this.selectors.submenus,submenuSubtoggleSelector:this.selectors.submenuSubtoggles,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),u=new this._MenuToggleType({menuToggleElement:l,parentElement:t,controlledMenu:a,parentMenu:this});this._elements.submenuToggles.push(u),l!==o?(n=new this._MenuItemType({menuItemElement:t,menuLinkElement:l,parentMenu:this,isSubmenuItem:!0,childMenu:a,toggle:u}),s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this,submenuSibling:n})):s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this,isSubmenuItem:!0,childMenu:a,toggle:u})}else s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this});this._elements.menuItems.push(s),typeof n<"u"&&this._elements.menuItems.push(n)})}_validate(){let t=super._validate();const s=w({submenuSubtoggleSelector:this._selectors.submenuSubtoggles});s.status||(this._errors.push(s.error.message),t=!1);const n=c("boolean",{optionalKeySupport:this._optionalSupport});return n.status||(this._errors.push(n.error.message),t=!1),t}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleHover(){this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerenter",n=>{if(!(n.pointerType==="pen"||n.pointerType==="touch")){if(this.hoverType==="on"){this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s);let o=t.isSubmenuItem?t.elements.toggle:null;if(t.elements.sibling!==null&&(o=t.elements.sibling.elements.toggle),o===null)return;this.enterDelay>0?(clearTimeout(this._hoverTimeout),this._hoverTimeout=setTimeout(()=>{o.preview()},this.enterDelay)):o.preview()}else if(this.hoverType==="dynamic"){const o=this.elements.submenuToggles.some(l=>l.isOpen);if(this.currentChild=s,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),!this.isTopLevel||o){this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild();let l=t.isSubmenuItem?t.elements.toggle:null;if(t.elements.sibling!==null&&(l=t.elements.sibling.elements.toggle),l===null)return;this.enterDelay>0?(clearTimeout(this._hoverTimeout),this._hoverTimeout=setTimeout(()=>{l.preview()},this.enterDelay)):l.preview()}}}}),t.isSubmenuItem&&t.dom.item.addEventListener("pointerleave",n=>{n.pointerType==="pen"||n.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",t.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",t.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",t.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",t.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=S(t);if(this.focusState==="self"){const n=["Space","Enter"],o=["Escape"],l=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&m(t):(this.currentMenuItem.isSubmenuItem&&n.includes(s)||this.elements.controller&&o.includes(s)||this.elements.parentMenu&&l.includes(s))&&m(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=S(t);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(m(t),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(o=>o.isOpen)?(m(t),this.closeChildren()):this.elements.parentMenu?(m(t),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.closeChildren(),this.elements.parentMenu.focusCurrentChild()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(m(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(m(t),this.focusPreviousChild()):s==="Home"?(m(t),this.focusFirstChild()):s==="End"&&(m(t),this.focusLastChild())))})}}class U extends q{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:l=null,initialize:h=!0,submenuSibling:a=null}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:o,toggle:l,initialize:!1,submenuSibling:a}),h&&this.initialize()}}class Z extends z{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o,initialize:!1});r(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,l&&this.initialize()}_expand(t=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(d(n,this.dom.container),requestAnimationFrame(()=>{d(s,this.dom.container),requestAnimationFrame(()=>{p(n,this.dom.container)})})):s!==""&&d(s,this.dom.container),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),o!==""?(d(o,this.dom.container),requestAnimationFrame(()=>{n!==""&&p(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&d(s,this.dom.container),requestAnimationFrame(()=>{p(o,this.dom.container)})})})):(s!==""&&d(s,this.dom.container),n!==""&&p(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class O extends ${constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:h=".dropdown-menu",submenuSubtoggleSelector:a=".dropdown-toggle",controllerElement:u=null,containerElement:_=null,openClass:y="show",closeClass:f="collapse",transitionClass:b="transitioning",isTopLevel:C=!0,parentMenu:E=null,hoverType:T="off",hoverDelay:v=250,enterDelay:k=-1,leaveDelay:I=-1,optionalKeySupport:L=!1,disableBootstrap:A=!0,initialize:K=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:h,submenuSubtoggleSelector:a,controllerElement:u,containerElement:_,openClass:y,closeClass:f,transitionClass:b,isTopLevel:C,parentMenu:E,hoverType:T,hoverDelay:v,enterDelay:k,leaveDelay:I,optionalKeySupport:L,initialize:!1});r(this,"_MenuType",O);r(this,"_MenuItemType",U);r(this,"_MenuToggleType",Z);r(this,"_disableBootstrap",!0);r(this,"_pseudoDropdownElement",document.createElement("div"));r(this,"_bootstrapEvents",["show.bs.dropdown","shown.bs.dropdown","hide.bs.dropdown","hidden.bs.dropdown"]);this._disableBootstrap=A,K&&this.initialize()}initialize(){super.initialize(),this.bootstrapDisabled&&this._disableBootstrapDropdownBehaviour()}get bootstrapDisabled(){return this._disableBootstrap}get bootstrapPseudoDropdownElement(){return this._pseudoDropdownElement}get bootstrapEvents(){return this._bootstrapEvents}_validate(){let t=super._validate();const s=c("boolean",{disableBootstrap:this._disableBootstrap});return s.status||(this._errors.push(s.error.message),t=!1),t}_disableBootstrapDropdownBehaviour(){this.elements.submenuToggles.forEach(t=>{this.bootstrapEvents.forEach(s=>{t.dom.toggle.addEventListener(s,n=>{m(n);const o=bootstrap.Dropdown.getInstance(n.target);o&&o._menu!==this.bootstrapPseudoDropdownElement&&(o._menu=this.bootstrapPseudoDropdownElement)},{once:!0})})})}}module.exports=O; | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});z("button",{toggle:e.dom.toggle})||e.dom.toggle.setAttribute("role","button"),e.dom.toggle.setAttribute("aria-controls",this.dom.menu.id),this._elements.controller=e}this._createChildElements(),this._setTransitionDurations(),this.isTopLevel&&(window.AccessibleMenu=window.AccessibleMenu||{menus:{}},window.AccessibleMenu.menus[this.dom.menu.id]=this)}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get transitionDuration(){return this.isTopLevel?this._transitionDuration:this.elements.rootMenu.transitionDuration}get openDuration(){return this._openDuration===-1?this.transitionDuration:this.isTopLevel?this._openDuration:this.elements.rootMenu.openDuration}get closeDuration(){return this._closeDuration===-1?this.transitionDuration:this.isTopLevel?this._closeDuration:this.elements.rootMenu.closeDuration}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get prefix(){return this._root?this._prefix:this.elements.rootMenu.prefix}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get hasOpened(){return this._root?this._hasOpened:this.elements.rootMenu.hasOpened}get errors(){return this._errors}set openClass(e){T({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){T({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){T({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set transitionDuration(e){u("number",{value:e}),this._transitionDuration!==e&&(this._transitionDuration=e,this._setTransitionDurations())}set openDuration(e){u("number",{value:e}),this._openDuration!==e&&(this._openDuration=e,this._setTransitionDurations())}set closeDuration(e){u("number",{value:e}),this._closeDuration!==e&&(this._closeDuration=e,this._setTransitionDurations())}set currentChild(e){u("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let o=0,l=!1;for(;!l&&o<s.elements.parentMenu.elements.menuItems.length;){const h=s.elements.parentMenu.elements.menuItems[o];h.isSubmenuItem&&h.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=o),o++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){W({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){G({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){q({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){u("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){u("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){u("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}set prefix(e){u("string",{value:e}),this._prefix!==e&&(this._prefix=e)}set hasOpened(e){u("boolean",{value:e}),this._hasOpened!==e&&(this._hasOpened=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=k(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=k(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=L({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=L({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const p=T({openClass:this._openClass});p.status||(this._errors.push(p.error.message),e=!1)}if(this._closeClass!==""){const p=T({closeClass:this._closeClass});p.status||(this._errors.push(p.error.message),e=!1)}if(this._transitionClass!==""){const p=T({transitionClass:this._transitionClass});p.status||(this._errors.push(p.error.message),e=!1)}const n=u("number",{transitionDuration:this._transitionDuration});n.status||(this._errors.push(n.error.message),e=!1);const o=u("number",{openDuration:this._openDuration});o.status||(this._errors.push(o.error.message),e=!1);const l=u("number",{closeDuration:this._closeDuration});l.status||(this._errors.push(l.error.message),e=!1);const h=u("boolean",{isTopLevel:this._root});if(h.status||(this._errors.push(h.error.message),e=!1),this._elements.parentMenu!==null){const p=k(A,{parentMenu:this._elements.parentMenu});p.status||(this._errors.push(p.error.message),e=!1)}const a=q({hoverType:this._hoverType});a.status||(this._errors.push(a.error.message),e=!1);const f=u("number",{hoverDelay:this._hoverDelay});f.status||(this._errors.push(f.error.message),e=!1);const g=u("number",{enterDelay:this._enterDelay});g.status||(this._errors.push(g.error.message),e=!1);const _=u("number",{leaveDelay:this._leaveDelay});_.status||(this._errors.push(_.error.message),e=!1);const y=u("string",{prefix:this._prefix});return y.status||(this._errors.push(y.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&k(HTMLElement,{base:t});const o=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=o:this._dom[e]=[...this._dom[e],...o]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,transitionDuration:this.transitionDuration,openDuration:this.openDuration,closeDuration:this.closeDuration,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_clearTimeout(){clearTimeout(this._hoverTimeout)}_setTimeout(e,t){u("function",{callback:e}),u("number",{delay:t}),this._hoverTimeout=setTimeout(e,t)}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})}),this.dom.menu.addEventListener("focusout",e=>{this.currentEvent!=="keyboard"||e.relatedTarget===null||this.dom.menu.contains(e.relatedTarget)||(this.focusState="none",this.closeChildren())})}_handleClick(){function e(t,s,n){d(n),n.button===0&&(s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none"))}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this._clearTimeout(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)}),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.elements.rootMenu.hasOpened=this.elements.submenuToggles.some(s=>s.isOpen)))})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t),e.isSubmenuItem&&(this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay)):e.elements.toggle.preview())):this.hoverType==="dynamic"&&(this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),(!this.isTopLevel||this.hasOpened)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),e.isSubmenuItem?this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay)):e.elements.toggle.preview():this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.closeChildren()},this.enterDelay)):this.closeChildren())))}),e.isSubmenuItem&&(e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse"},this.leaveDelay)):this.currentEvent="mouse"))}),e.dom.item.addEventListener("pointerenter",s=>{s.pointerType==="pen"||s.pointerType==="touch"||e.isSubmenuItem&&(this.hoverType==="on"||this.hoverType==="dynamic")&&this.leaveDelay>0&&this._clearTimeout()}))})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=I(e);(t==="Space"||t==="Enter")&&d(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=I(e);(t==="Space"||t==="Enter")&&(d(e),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}_setTransitionDurations(){this.dom.menu.style.setProperty(`--${this.prefix}transition-duration`,`${this.transitionDuration}ms`),this.dom.menu.style.setProperty(`--${this.prefix}open-transition-duration`,`${this.openDuration}ms`),this.dom.menu.style.setProperty(`--${this.prefix}close-transition-duration`,`${this.closeDuration}ms`)}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class V extends K{constructor({menuItemElement:t,menuLinkElement:s,parentMenu:n,isSubmenuItem:o=!1,childMenu:l=null,toggle:h=null,initialize:a=!0,submenuSibling:f=null}){super({menuItemElement:t,menuLinkElement:s,parentMenu:n,isSubmenuItem:o,childMenu:l,toggle:h});r(this,"_elements",{parentMenu:null,childMenu:null,toggle:null,sibling:null});this._elements.parentMenu=n,this._elements.childMenu=l,this._elements.toggle=h,this._elements.sibling=f,a&&this.initialize()}}class P extends j{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:o=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),o&&this.initialize()}_setAriaAttributes(){super._setAriaAttributes(),z("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id)}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class x extends A{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:o="li:has(ul)",submenuToggleSelector:l="button",submenuSelector:h="ul",submenuSubtoggleSelector:a="a",controllerElement:f=null,containerElement:g=null,openClass:_="show",closeClass:y="hide",transitionClass:p="transitioning",transitionDuration:C=250,isTopLevel:b=!0,parentMenu:E=null,hoverType:M="off",hoverDelay:v=250,enterDelay:D=-1,leaveDelay:w=-1,optionalKeySupport:S=!1,prefix:$="am-",initialize:O=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuSelector:h,submenuToggleSelector:l,controllerElement:f,containerElement:g,openClass:_,closeClass:y,transitionClass:p,transitionDuration:C,isTopLevel:b,parentMenu:E,hoverType:M,hoverDelay:v,enterDelay:D,leaveDelay:w,prefix:$});r(this,"_MenuType",x);r(this,"_MenuItemType",V);r(this,"_MenuToggleType",P);r(this,"_currentChild",-1);r(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:"",submenuSubtoggles:""});r(this,"_optionalSupport",!1);this._optionalSupport=S,this._selectors.menuItems=s,this._selectors.submenuItems=o,this._selectors.submenuToggles=l,this._selectors.submenus=h,this._selectors.submenuSubtoggles=a,this._selectors.menuLinks=[...new Set([n,l])].join(","),O&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(t){u("boolean",{optionalKeySupport:t}),this._optionalSupport=t}_createChildElements(){this.dom.menuItems.forEach(t=>{let s,n;const o=t.querySelector(this.selectors.menuLinks);if(this.dom.submenuItems.includes(t)){const l=t.querySelector(this.selectors.submenuToggles),h=t.querySelector(this.selectors.submenus),a=new this._MenuType({menuElement:h,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuSubtoggles,submenuSelector:this.selectors.submenus,submenuSubtoggleSelector:this.selectors.submenuSubtoggles,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),f=new this._MenuToggleType({menuToggleElement:l,parentElement:t,controlledMenu:a,parentMenu:this});this._elements.submenuToggles.push(f),l!==o?(n=new this._MenuItemType({menuItemElement:t,menuLinkElement:l,parentMenu:this,isSubmenuItem:!0,childMenu:a,toggle:f}),s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this,submenuSibling:n})):s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this,isSubmenuItem:!0,childMenu:a,toggle:f})}else s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this});this._elements.menuItems.push(s),typeof n<"u"&&this._elements.menuItems.push(n)})}_validate(){let t=super._validate();const s=L({submenuSubtoggleSelector:this._selectors.submenuSubtoggles});s.status||(this._errors.push(s.error.message),t=!1);const n=u("boolean",{optionalKeySupport:this._optionalSupport});return n.status||(this._errors.push(n.error.message),t=!1),t}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close(),this.elements.rootMenu.hasOpened=!1))})}_handleHover(){this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerenter",n=>{if(!(n.pointerType==="pen"||n.pointerType==="touch")){if(this.hoverType==="on"){this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s);let o=t.isSubmenuItem?t.elements.toggle:null;if(t.elements.sibling!==null&&(o=t.elements.sibling.elements.toggle),o===null)return;this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{o.preview()},this.enterDelay)):o.preview()}else if(this.hoverType==="dynamic"&&(this.currentChild=s,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),!this.isTopLevel||this.hasOpened)){this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild();let o=t.isSubmenuItem?t.elements.toggle:null;t.elements.sibling!==null&&(o=t.elements.sibling.elements.toggle),o!==null?this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{o.preview()},this.enterDelay)):o.preview():this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.closeChildren()},this.enterDelay)):this.closeChildren()}}}),t.isSubmenuItem&&(t.dom.item.addEventListener("pointerleave",n=>{n.pointerType==="pen"||n.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse",t.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",t.elements.toggle.close()):this.hoverType==="dynamic"&&(this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse"},this.leaveDelay)):this.currentEvent="mouse"))}),t.dom.item.addEventListener("pointerenter",n=>{n.pointerType==="pen"||n.pointerType==="touch"||t.isSubmenuItem&&(this.hoverType==="on"||this.hoverType==="dynamic")&&this.leaveDelay>0&&this._clearTimeout()}))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=I(t);if(this.focusState==="self"){const n=["Space","Enter"],o=["Escape"],l=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&d(t):(this.currentMenuItem.isSubmenuItem&&n.includes(s)||this.elements.controller&&o.includes(s)||this.elements.parentMenu&&l.includes(s))&&d(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=I(t);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(d(t),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(o=>o.isOpen)?(d(t),this.closeChildren()):this.elements.parentMenu?(d(t),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.closeChildren(),this.elements.parentMenu.focusCurrentChild()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(d(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(d(t),this.focusPreviousChild()):s==="Home"?(d(t),this.focusFirstChild()):s==="End"&&(d(t),this.focusLastChild())))})}}class J extends V{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:l=null,initialize:h=!0,submenuSibling:a=null}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:o,toggle:l,initialize:!1,submenuSibling:a}),h&&this.initialize()}}class X extends P{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o,initialize:!1});r(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,l&&this.initialize()}initialize(){super.initialize(),this.elements.controlledMenu.bootstrapTransitions&&this.elements.controlledMenu.isTopLevel&&(this.dom.container.style.transition="height var(--am-transition-duration) ease")}_expand(t=!0){const{openClass:s,closeClass:n,transitionClass:o,openDuration:l,bootstrapTransitions:h,isTopLevel:a}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),this.elements.controlledMenu.elements.rootMenu.hasOpened=!0,o!==""?h?a?(m(o,this.dom.container),c(n,this.dom.container),this.dom.container.style.height=`${this.dom.container.scrollHeight}px`,requestAnimationFrame(()=>{setTimeout(()=>{m(s,this.dom.container),m(n,this.dom.container),c(o,this.dom.container),this.dom.container.style.height=""},l)})):(m(s,this.dom.container),c(n,this.dom.container)):(m(o,this.dom.container),requestAnimationFrame(()=>{c(n,this.dom.container),requestAnimationFrame(()=>{m(s,this.dom.container),requestAnimationFrame(()=>{setTimeout(()=>{c(o,this.dom.container)},l)})})})):(m(s,this.dom.container),c(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:o,closeDuration:l,bootstrapTransitions:h,isTopLevel:a}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),o!==""?h?a?(this.dom.container.style.height=`${this.dom.container.offsetHeight}px`,requestAnimationFrame(()=>{m(o,this.dom.container),requestAnimationFrame(()=>{c(n,this.dom.container),c(s,this.dom.container),this.dom.container.style.height="",requestAnimationFrame(()=>{setTimeout(()=>{c(o,this.dom.container),m(s,this.dom.container)},l)})})})):(m(s,this.dom.container),c(n,this.dom.container)):(m(o,this.dom.container),requestAnimationFrame(()=>{c(n,this.dom.container),requestAnimationFrame(()=>{m(s,this.dom.container),requestAnimationFrame(()=>{setTimeout(()=>{c(o,this.dom.container)},l)})})})):(m(s,this.dom.container),c(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class F extends x{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:h=".dropdown-menu",submenuSubtoggleSelector:a=".dropdown-toggle",controllerElement:f=null,containerElement:g=null,openClass:_="show",closeClass:y="collapse",transitionClass:p="collapsing",transitionDuration:C=350,openDuration:b=-1,closeDuration:E=-1,isTopLevel:M=!0,parentMenu:v=null,hoverType:D="off",hoverDelay:w=250,enterDelay:S=-1,leaveDelay:$=-1,optionalKeySupport:O=!1,prefix:B="am-",bootstrapTransitions:H=!0,disableBootstrap:R=!0,initialize:U=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:h,submenuSubtoggleSelector:a,controllerElement:f,containerElement:g,openClass:_,closeClass:y,transitionClass:p,transitionDuration:C,openDuration:b,closeDuration:E,isTopLevel:M,parentMenu:v,hoverType:D,hoverDelay:w,enterDelay:S,leaveDelay:$,optionalKeySupport:O,prefix:B,initialize:!1});r(this,"_MenuType",F);r(this,"_MenuItemType",J);r(this,"_MenuToggleType",X);r(this,"_disableBootstrap",!0);r(this,"_pseudoDropdownElement",document.createElement("div"));r(this,"_bootstrapDropdownEvents",["show.bs.dropdown","shown.bs.dropdown","hide.bs.dropdown","hidden.bs.dropdown"]);r(this,"_pseudoCollapseElement",document.createElement("div"));r(this,"_bootstrapCollapseEvents",["show.bs.collapse","shown.bs.collapse","hide.bs.collapse","hidden.bs.collapse"]);r(this,"_bootstrapTransitions",!0);this._disableBootstrap=R,this._bootstrapTransitions=H,U&&this.initialize()}initialize(){super.initialize(),this.bootstrapDisabled&&(this._disableBootstrapDropdownBehaviour(),this._disableBootstrapCollapseBehaviour())}get bootstrapTransitions(){return this.isTopLevel?this._bootstrapTransitions:this.elements.rootMenu.bootstrapTransitions}get bootstrapDisabled(){return this._disableBootstrap}get bootstrapPseudoDropdownElement(){return this._pseudoDropdownElement}get bootstrapDropdownEvents(){return this._bootstrapDropdownEvents}get bootstrapPseudoCollapseElement(){return this._pseudoCollapseElement}get bootstrapCollapseEvents(){return this._bootstrapCollapseEvents}_validate(){let t=super._validate();const s=u("boolean",{bootstrapTransitions:this._bootstrapTransitions});s.status||(this._errors.push(s.error.message),t=!1);const n=u("boolean",{disableBootstrap:this._disableBootstrap});return n.status||(this._errors.push(n.error.message),t=!1),t}_disableBootstrapDropdownBehaviour(){this.elements.submenuToggles.forEach(t=>{this.bootstrapDropdownEvents.forEach(s=>{t.dom.toggle.addEventListener(s,n=>{d(n);const o=bootstrap.Dropdown.getInstance(n.target);o&&o._menu!==this.bootstrapPseudoDropdownElement&&(o._menu=this.bootstrapPseudoDropdownElement)},{once:!0})})})}_disableBootstrapCollapseBehaviour(){this.elements.controller&&this.bootstrapCollapseEvents.forEach(t=>{this.dom.container.addEventListener(t,s=>{d(s);const n=bootstrap.Collapse.getInstance(s.target);n&&n._element!==this.bootstrapPseudoCollapseElement&&(n._element=this.bootstrapPseudoCollapseElement)},{once:!0})})}_setTransitionDurations(){super._setTransitionDurations(),this.isTopLevel&&this.elements.controller&&(this.elements.controller.dom.container.style.setProperty(`--${this.prefix}transition-duration`,`${this.transitionDuration}ms`),this.elements.controller.dom.container.style.setProperty(`--${this.prefix}open-transition-duration`,`${this.openDuration}ms`),this.elements.controller.dom.container.style.setProperty(`--${this.prefix}close-transition-duration`,`${this.closeDuration}ms`))}}module.exports=F; |
@@ -1,3 +0,3 @@ | ||
var Bootstrap5TopLinkDisclosureMenu=function(){"use strict";var U=Object.defineProperty;var Z=(a,m,f)=>m in a?U(a,m,{enumerable:!0,configurable:!0,writable:!0,value:f}):a[m]=f;var r=(a,m,f)=>(Z(a,typeof m!="symbol"?m+"":m,f),f);function a(i,e){typeof i=="string"?e.classList.add(i):e.classList.add(...i)}function m(i,e){typeof i=="string"?e.classList.remove(i):e.classList.remove(...i)}function f(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function p(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function w(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid query selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function g(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],w(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function K(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function V(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function F(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function B(i,e){if(p("string",{tagName:i}).status&&f(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class j{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){r(this,"_dom",{toggle:null,parent:null});r(this,"_elements",{controlledMenu:null,parentMenu:null});r(this,"_open",!1);r(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));r(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){this._setIds(),this._setAriaAttributes(),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){p("boolean",{value:e}),this._open=e}_setIds(){var e;if(this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`menu-button-${n}`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`menu-${n}`}}_setAriaAttributes(){this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),B("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id)}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&m(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&a(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{m(n,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&a(s,this.elements.controlledMenu.dom.menu),t!==""&&m(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(a(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&m(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&a(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{m(n,this.elements.controlledMenu.dom.menu)})})})):(t!==""&&a(t,this.elements.controlledMenu.dom.menu),s!==""&&m(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class q{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:l=null}){r(this,"_dom",{item:null,link:null});r(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});r(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=o,this._elements.toggle=l,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function S(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function d(i){i.preventDefault(),i.stopPropagation()}class D{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="",submenuToggleSelector:o="a",submenuSelector:l="ul",controllerElement:h=null,containerElement:c=null,openClass:u="show",closeClass:y="hide",transitionClass:b="transitioning",isTopLevel:_=!0,parentMenu:C=null,hoverType:E="off",hoverDelay:T=250,enterDelay:v=-1,leaveDelay:M=-1}){r(this,"_MenuType",D);r(this,"_MenuItemType",q);r(this,"_MenuToggleType",j);r(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});r(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});r(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});r(this,"_openClass","show");r(this,"_closeClass","hide");r(this,"_transitionClass","transitioning");r(this,"_root",!0);r(this,"_currentChild",0);r(this,"_focusState","none");r(this,"_currentEvent","none");r(this,"_hoverType","off");r(this,"_hoverDelay",250);r(this,"_enterDelay",-1);r(this,"_leaveDelay",-1);r(this,"_hoverTimeout",null);r(this,"_errors",[]);this._dom.menu=e,this._dom.controller=h,this._dom.container=c,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=o,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=C,this._elements.rootMenu=_?this:null,this._openClass=u||"",this._closeClass=y||"",this._transitionClass=b||"",this._root=_,this._hoverType=E,this._hoverDelay=T,this._enterDelay=v,this._leaveDelay=M}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
var Bootstrap5TopLinkDisclosureMenu=function(){"use strict";var J=Object.defineProperty;var X=(h,u,g)=>u in h?J(h,u,{enumerable:!0,configurable:!0,writable:!0,value:g}):h[u]=g;var r=(h,u,g)=>X(h,typeof u!="symbol"?u+"":u,g);function h(o,e){o===""||o.length===0||(typeof o=="string"?e.classList.add(o):e.classList.add(...o))}function u(o,e){o===""||o.length===0||(typeof o=="string"?e.classList.remove(o):e.classList.remove(...o))}function g(o,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof o)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${o.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function a(o,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==o)throw new TypeError(`${t} must be a ${o}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function L(o){try{if(typeof o!="object"){const e=typeof o;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${e}" given.`)}for(const e in o)try{if(o[e]===null)throw new Error;document.querySelector(o[e])}catch{throw new TypeError(`${e} must be a valid query selector. "${o[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function T(o){try{if(typeof o!="object"||Array.isArray(o)){const e=typeof o;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in o){const t=typeof o[e];if(t!=="string")if(Array.isArray(o[e]))o[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=o[e],L(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function P(o){try{if(typeof o!="object"){const t=typeof o;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in o)if(!e.includes(o[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${o[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function H(o){try{if(typeof o!="object"){const t=typeof o;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in o)if(!e.includes(o[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${o[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function q(o){try{if(typeof o!="object"){const t=typeof o;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in o)if(!e.includes(o[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${o[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function z(o,e){if(a("string",{tagName:o}).status&&g(HTMLElement,e).status){const t=o.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class j{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){r(this,"_dom",{toggle:null,parent:null});r(this,"_elements",{controlledMenu:null,parentMenu:null});r(this,"_open",!1);r(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));r(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){this._setIds(),this._setAriaAttributes(),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){a("boolean",{value:e}),this._open=e}_setIds(){var e;if(this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`menu-button-${n}`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`menu-${n}`}}_setAriaAttributes(){this.dom.toggle.setAttribute("aria-expanded","false"),this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id)}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n,openDuration:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),this.elements.controlledMenu.elements.rootMenu.hasOpened=!0,n!==""?(h(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{u(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{h(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{setTimeout(()=>{u(n,this.elements.controlledMenu.dom.menu)},i)})})})):(h(s,this.elements.controlledMenu.dom.menu),u(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n,closeDuration:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(h(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{u(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{h(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{setTimeout(()=>{u(n,this.elements.controlledMenu.dom.menu)},i)})})})):(h(t,this.elements.controlledMenu.dom.menu),u(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this.isOpen||(this._expand(),this.isOpen=!0)}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this.isOpen||(this._expand(),this.isOpen=!0)}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class K{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:l=null}){r(this,"_dom",{item:null,link:null});r(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});r(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=i,this._elements.toggle=l,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&requestAnimationFrame(()=>{this.dom.link.focus()})}blur(){this.elements.parentMenu.shouldFocus&&requestAnimationFrame(()=>{this.dom.link.blur()})}}function I(o){try{const e=o.key||o.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function d(o){o.preventDefault(),o.stopPropagation()}class A{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="li:has(ul)",submenuToggleSelector:i="a",submenuSelector:l="ul",controllerElement:m=null,containerElement:c=null,openClass:f="show",closeClass:_="hide",transitionClass:y="transitioning",transitionDuration:b=250,openDuration:p=-1,closeDuration:E=-1,isTopLevel:C=!0,parentMenu:M=null,hoverType:v="off",hoverDelay:D=250,enterDelay:w=-1,leaveDelay:S=-1,prefix:k="am-"}){r(this,"_MenuType",A);r(this,"_MenuItemType",K);r(this,"_MenuToggleType",j);r(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});r(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});r(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});r(this,"_openClass","show");r(this,"_closeClass","hide");r(this,"_transitionClass","transitioning");r(this,"_transitionDuration",250);r(this,"_openDuration",-1);r(this,"_closeDuration",-1);r(this,"_root",!0);r(this,"_currentChild",0);r(this,"_focusState","none");r(this,"_currentEvent","none");r(this,"_hoverType","off");r(this,"_hoverDelay",250);r(this,"_enterDelay",-1);r(this,"_leaveDelay",-1);r(this,"_prefix","am-");r(this,"_hoverTimeout",null);r(this,"_hasOpened",!1);r(this,"_errors",[]);this._dom.menu=e,this._dom.controller=m,this._dom.container=c,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=i,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=M,this._elements.rootMenu=C?this:null,this._openClass=f||"",this._closeClass=_||"",this._transitionClass=y||"",this._transitionDuration=b,this._openDuration=p,this._closeDuration=E,this._prefix=k||"",this._root=C,this._hoverType=v,this._hoverDelay=D,this._enterDelay=w,this._leaveDelay=S}initialize(){if(!this._validate())throw new Error(`AccessibleMenu: cannot initialize menu. The following errors have been found: | ||
- ${this.errors.join(` | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){g({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set currentChild(e){p("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let o=0,l=!1;for(;!l&&o<s.elements.parentMenu.elements.menuItems.length;){const h=s.elements.parentMenu.elements.menuItems[o];h.isSubmenuItem&&h.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=o),o++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){K({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){V({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){F({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){p("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){p("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){p("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=f(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=f(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=w({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=w({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const u=g({openClass:this._openClass});u.status||(this._errors.push(u.error.message),e=!1)}if(this._closeClass!==""){const u=g({closeClass:this._closeClass});u.status||(this._errors.push(u.error.message),e=!1)}if(this._transitionClass!==""){const u=g({transitionClass:this._transitionClass});u.status||(this._errors.push(u.error.message),e=!1)}const n=p("boolean",{isTopLevel:this._root});if(n.status||(this._errors.push(n.error.message),e=!1),this._elements.parentMenu!==null){const u=f(D,{parentMenu:this._elements.parentMenu});u.status||(this._errors.push(u.error.message),e=!1)}const o=F({hoverType:this._hoverType});o.status||(this._errors.push(o.error.message),e=!1);const l=p("number",{hoverDelay:this._hoverDelay});l.status||(this._errors.push(l.error.message),e=!1);const h=p("number",{enterDelay:this._enterDelay});h.status||(this._errors.push(h.error.message),e=!1);const c=p("number",{leaveDelay:this._leaveDelay});return c.status||(this._errors.push(c.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&f(HTMLElement,{base:t});const o=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=o:this._dom[e]=[...this._dom[e],...o]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,n){d(n),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t),e.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview());else if(this.hoverType==="dynamic"){const n=this.elements.submenuToggles.some(o=>o.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||n)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=S(e);(t==="Space"||t==="Enter")&&d(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=S(e);(t==="Space"||t==="Enter")&&(d(e),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class x extends q{constructor({menuItemElement:t,menuLinkElement:s,parentMenu:n,isSubmenuItem:o=!1,childMenu:l=null,toggle:h=null,initialize:c=!0,submenuSibling:u=null}){super({menuItemElement:t,menuLinkElement:s,parentMenu:n,isSubmenuItem:o,childMenu:l,toggle:h});r(this,"_elements",{parentMenu:null,childMenu:null,toggle:null,sibling:null});this._elements.parentMenu=n,this._elements.childMenu=l,this._elements.toggle=h,this._elements.sibling=u,c&&this.initialize()}}class z extends j{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:o=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),o&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class k extends D{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:o="",submenuToggleSelector:l="button",submenuSelector:h="ul",submenuSubtoggleSelector:c="a",controllerElement:u=null,containerElement:y=null,openClass:b="show",closeClass:_="hide",transitionClass:C="transitioning",isTopLevel:E=!0,parentMenu:T=null,hoverType:v="off",hoverDelay:M=250,enterDelay:I=-1,leaveDelay:A=-1,optionalKeySupport:$=!1,initialize:O=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuSelector:h,submenuToggleSelector:l,controllerElement:u,containerElement:y,openClass:b,closeClass:_,transitionClass:C,isTopLevel:E,parentMenu:T,hoverType:v,hoverDelay:M,enterDelay:I,leaveDelay:A});r(this,"_MenuType",k);r(this,"_MenuItemType",x);r(this,"_MenuToggleType",z);r(this,"_currentChild",-1);r(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:"",submenuSubtoggles:""});r(this,"_optionalSupport",!1);this._optionalSupport=$,this._selectors.menuItems=s,this._selectors.submenuItems=o,this._selectors.submenuToggles=l,this._selectors.submenus=h,this._selectors.submenuSubtoggles=c,this._selectors.menuLinks=[...new Set([n,l])].join(","),O&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(t){p("boolean",{optionalKeySupport:t}),this._optionalSupport=t}_createChildElements(){this.dom.menuItems.forEach(t=>{let s,n;const o=t.querySelector(this.selectors.menuLinks);if(this.dom.submenuItems.includes(t)){const l=t.querySelector(this.selectors.submenuToggles),h=t.querySelector(this.selectors.submenus),c=new this._MenuType({menuElement:h,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuSubtoggles,submenuSelector:this.selectors.submenus,submenuSubtoggleSelector:this.selectors.submenuSubtoggles,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),u=new this._MenuToggleType({menuToggleElement:l,parentElement:t,controlledMenu:c,parentMenu:this});this._elements.submenuToggles.push(u),l!==o?(n=new this._MenuItemType({menuItemElement:t,menuLinkElement:l,parentMenu:this,isSubmenuItem:!0,childMenu:c,toggle:u}),s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this,submenuSibling:n})):s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this,isSubmenuItem:!0,childMenu:c,toggle:u})}else s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this});this._elements.menuItems.push(s),typeof n<"u"&&this._elements.menuItems.push(n)})}_validate(){let t=super._validate();const s=w({submenuSubtoggleSelector:this._selectors.submenuSubtoggles});s.status||(this._errors.push(s.error.message),t=!1);const n=p("boolean",{optionalKeySupport:this._optionalSupport});return n.status||(this._errors.push(n.error.message),t=!1),t}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleHover(){this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerenter",n=>{if(!(n.pointerType==="pen"||n.pointerType==="touch")){if(this.hoverType==="on"){this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s);let o=t.isSubmenuItem?t.elements.toggle:null;if(t.elements.sibling!==null&&(o=t.elements.sibling.elements.toggle),o===null)return;this.enterDelay>0?(clearTimeout(this._hoverTimeout),this._hoverTimeout=setTimeout(()=>{o.preview()},this.enterDelay)):o.preview()}else if(this.hoverType==="dynamic"){const o=this.elements.submenuToggles.some(l=>l.isOpen);if(this.currentChild=s,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),!this.isTopLevel||o){this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild();let l=t.isSubmenuItem?t.elements.toggle:null;if(t.elements.sibling!==null&&(l=t.elements.sibling.elements.toggle),l===null)return;this.enterDelay>0?(clearTimeout(this._hoverTimeout),this._hoverTimeout=setTimeout(()=>{l.preview()},this.enterDelay)):l.preview()}}}}),t.isSubmenuItem&&t.dom.item.addEventListener("pointerleave",n=>{n.pointerType==="pen"||n.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",t.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",t.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",t.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",t.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=S(t);if(this.focusState==="self"){const n=["Space","Enter"],o=["Escape"],l=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&d(t):(this.currentMenuItem.isSubmenuItem&&n.includes(s)||this.elements.controller&&o.includes(s)||this.elements.parentMenu&&l.includes(s))&&d(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=S(t);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(d(t),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(o=>o.isOpen)?(d(t),this.closeChildren()):this.elements.parentMenu?(d(t),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.closeChildren(),this.elements.parentMenu.focusCurrentChild()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(d(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(d(t),this.focusPreviousChild()):s==="Home"?(d(t),this.focusFirstChild()):s==="End"&&(d(t),this.focusLastChild())))})}}class H extends x{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:l=null,initialize:h=!0,submenuSibling:c=null}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:o,toggle:l,initialize:!1,submenuSibling:c}),h&&this.initialize()}}class P extends z{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o,initialize:!1});r(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,l&&this.initialize()}_expand(t=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{m(n,this.dom.container)})})):s!==""&&a(s,this.dom.container),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),o!==""?(a(o,this.dom.container),requestAnimationFrame(()=>{n!==""&&m(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&a(s,this.dom.container),requestAnimationFrame(()=>{m(o,this.dom.container)})})})):(s!==""&&a(s,this.dom.container),n!==""&&m(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class L extends k{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:h=".dropdown-menu",submenuSubtoggleSelector:c=".dropdown-toggle",controllerElement:u=null,containerElement:y=null,openClass:b="show",closeClass:_="collapse",transitionClass:C="transitioning",isTopLevel:E=!0,parentMenu:T=null,hoverType:v="off",hoverDelay:M=250,enterDelay:I=-1,leaveDelay:A=-1,optionalKeySupport:$=!1,disableBootstrap:O=!0,initialize:R=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:h,submenuSubtoggleSelector:c,controllerElement:u,containerElement:y,openClass:b,closeClass:_,transitionClass:C,isTopLevel:E,parentMenu:T,hoverType:v,hoverDelay:M,enterDelay:I,leaveDelay:A,optionalKeySupport:$,initialize:!1});r(this,"_MenuType",L);r(this,"_MenuItemType",H);r(this,"_MenuToggleType",P);r(this,"_disableBootstrap",!0);r(this,"_pseudoDropdownElement",document.createElement("div"));r(this,"_bootstrapEvents",["show.bs.dropdown","shown.bs.dropdown","hide.bs.dropdown","hidden.bs.dropdown"]);this._disableBootstrap=O,R&&this.initialize()}initialize(){super.initialize(),this.bootstrapDisabled&&this._disableBootstrapDropdownBehaviour()}get bootstrapDisabled(){return this._disableBootstrap}get bootstrapPseudoDropdownElement(){return this._pseudoDropdownElement}get bootstrapEvents(){return this._bootstrapEvents}_validate(){let t=super._validate();const s=p("boolean",{disableBootstrap:this._disableBootstrap});return s.status||(this._errors.push(s.error.message),t=!1),t}_disableBootstrapDropdownBehaviour(){this.elements.submenuToggles.forEach(t=>{this.bootstrapEvents.forEach(s=>{t.dom.toggle.addEventListener(s,n=>{d(n);const o=bootstrap.Dropdown.getInstance(n.target);o&&o._menu!==this.bootstrapPseudoDropdownElement&&(o._menu=this.bootstrapPseudoDropdownElement)},{once:!0})})})}}return L}(); | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});z("button",{toggle:e.dom.toggle})||e.dom.toggle.setAttribute("role","button"),e.dom.toggle.setAttribute("aria-controls",this.dom.menu.id),this._elements.controller=e}this._createChildElements(),this._setTransitionDurations(),this.isTopLevel&&(window.AccessibleMenu=window.AccessibleMenu||{menus:{}},window.AccessibleMenu.menus[this.dom.menu.id]=this)}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get transitionDuration(){return this.isTopLevel?this._transitionDuration:this.elements.rootMenu.transitionDuration}get openDuration(){return this._openDuration===-1?this.transitionDuration:this.isTopLevel?this._openDuration:this.elements.rootMenu.openDuration}get closeDuration(){return this._closeDuration===-1?this.transitionDuration:this.isTopLevel?this._closeDuration:this.elements.rootMenu.closeDuration}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get prefix(){return this._root?this._prefix:this.elements.rootMenu.prefix}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get hasOpened(){return this._root?this._hasOpened:this.elements.rootMenu.hasOpened}get errors(){return this._errors}set openClass(e){T({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){T({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){T({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set transitionDuration(e){a("number",{value:e}),this._transitionDuration!==e&&(this._transitionDuration=e,this._setTransitionDurations())}set openDuration(e){a("number",{value:e}),this._openDuration!==e&&(this._openDuration=e,this._setTransitionDurations())}set closeDuration(e){a("number",{value:e}),this._closeDuration!==e&&(this._closeDuration=e,this._setTransitionDurations())}set currentChild(e){a("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let i=0,l=!1;for(;!l&&i<s.elements.parentMenu.elements.menuItems.length;){const m=s.elements.parentMenu.elements.menuItems[i];m.isSubmenuItem&&m.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=i),i++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){P({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){H({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){q({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){a("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){a("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){a("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}set prefix(e){a("string",{value:e}),this._prefix!==e&&(this._prefix=e)}set hasOpened(e){a("boolean",{value:e}),this._hasOpened!==e&&(this._hasOpened=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=g(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=g(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=L({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=L({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const p=T({openClass:this._openClass});p.status||(this._errors.push(p.error.message),e=!1)}if(this._closeClass!==""){const p=T({closeClass:this._closeClass});p.status||(this._errors.push(p.error.message),e=!1)}if(this._transitionClass!==""){const p=T({transitionClass:this._transitionClass});p.status||(this._errors.push(p.error.message),e=!1)}const n=a("number",{transitionDuration:this._transitionDuration});n.status||(this._errors.push(n.error.message),e=!1);const i=a("number",{openDuration:this._openDuration});i.status||(this._errors.push(i.error.message),e=!1);const l=a("number",{closeDuration:this._closeDuration});l.status||(this._errors.push(l.error.message),e=!1);const m=a("boolean",{isTopLevel:this._root});if(m.status||(this._errors.push(m.error.message),e=!1),this._elements.parentMenu!==null){const p=g(A,{parentMenu:this._elements.parentMenu});p.status||(this._errors.push(p.error.message),e=!1)}const c=q({hoverType:this._hoverType});c.status||(this._errors.push(c.error.message),e=!1);const f=a("number",{hoverDelay:this._hoverDelay});f.status||(this._errors.push(f.error.message),e=!1);const _=a("number",{enterDelay:this._enterDelay});_.status||(this._errors.push(_.error.message),e=!1);const y=a("number",{leaveDelay:this._leaveDelay});y.status||(this._errors.push(y.error.message),e=!1);const b=a("string",{prefix:this._prefix});return b.status||(this._errors.push(b.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&g(HTMLElement,{base:t});const i=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=i:this._dom[e]=[...this._dom[e],...i]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),i=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,transitionDuration:this.transitionDuration,openDuration:this.openDuration,closeDuration:this.closeDuration,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:i,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:i,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_clearTimeout(){clearTimeout(this._hoverTimeout)}_setTimeout(e,t){a("function",{callback:e}),a("number",{delay:t}),this._hoverTimeout=setTimeout(e,t)}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})}),this.dom.menu.addEventListener("focusout",e=>{this.currentEvent!=="keyboard"||e.relatedTarget===null||this.dom.menu.contains(e.relatedTarget)||(this.focusState="none",this.closeChildren())})}_handleClick(){function e(t,s,n){d(n),n.button===0&&(s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none"))}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this._clearTimeout(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)}),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.elements.rootMenu.hasOpened=this.elements.submenuToggles.some(s=>s.isOpen)))})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t),e.isSubmenuItem&&(this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay)):e.elements.toggle.preview())):this.hoverType==="dynamic"&&(this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),(!this.isTopLevel||this.hasOpened)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),e.isSubmenuItem?this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay)):e.elements.toggle.preview():this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.closeChildren()},this.enterDelay)):this.closeChildren())))}),e.isSubmenuItem&&(e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse"},this.leaveDelay)):this.currentEvent="mouse"))}),e.dom.item.addEventListener("pointerenter",s=>{s.pointerType==="pen"||s.pointerType==="touch"||e.isSubmenuItem&&(this.hoverType==="on"||this.hoverType==="dynamic")&&this.leaveDelay>0&&this._clearTimeout()}))})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=I(e);(t==="Space"||t==="Enter")&&d(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=I(e);(t==="Space"||t==="Enter")&&(d(e),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}_setTransitionDurations(){this.dom.menu.style.setProperty(`--${this.prefix}transition-duration`,`${this.transitionDuration}ms`),this.dom.menu.style.setProperty(`--${this.prefix}open-transition-duration`,`${this.openDuration}ms`),this.dom.menu.style.setProperty(`--${this.prefix}close-transition-duration`,`${this.closeDuration}ms`)}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class V extends K{constructor({menuItemElement:t,menuLinkElement:s,parentMenu:n,isSubmenuItem:i=!1,childMenu:l=null,toggle:m=null,initialize:c=!0,submenuSibling:f=null}){super({menuItemElement:t,menuLinkElement:s,parentMenu:n,isSubmenuItem:i,childMenu:l,toggle:m});r(this,"_elements",{parentMenu:null,childMenu:null,toggle:null,sibling:null});this._elements.parentMenu=n,this._elements.childMenu=l,this._elements.toggle=m,this._elements.sibling=f,c&&this.initialize()}}class B extends j{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:i=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),i&&this.initialize()}_setAriaAttributes(){super._setAriaAttributes(),z("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id)}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class $ extends A{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:i="li:has(ul)",submenuToggleSelector:l="button",submenuSelector:m="ul",submenuSubtoggleSelector:c="a",controllerElement:f=null,containerElement:_=null,openClass:y="show",closeClass:b="hide",transitionClass:p="transitioning",transitionDuration:E=250,isTopLevel:C=!0,parentMenu:M=null,hoverType:v="off",hoverDelay:D=250,enterDelay:w=-1,leaveDelay:S=-1,optionalKeySupport:k=!1,prefix:x="am-",initialize:F=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuSelector:m,submenuToggleSelector:l,controllerElement:f,containerElement:_,openClass:y,closeClass:b,transitionClass:p,transitionDuration:E,isTopLevel:C,parentMenu:M,hoverType:v,hoverDelay:D,enterDelay:w,leaveDelay:S,prefix:x});r(this,"_MenuType",$);r(this,"_MenuItemType",V);r(this,"_MenuToggleType",B);r(this,"_currentChild",-1);r(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:"",submenuSubtoggles:""});r(this,"_optionalSupport",!1);this._optionalSupport=k,this._selectors.menuItems=s,this._selectors.submenuItems=i,this._selectors.submenuToggles=l,this._selectors.submenus=m,this._selectors.submenuSubtoggles=c,this._selectors.menuLinks=[...new Set([n,l])].join(","),F&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(t){a("boolean",{optionalKeySupport:t}),this._optionalSupport=t}_createChildElements(){this.dom.menuItems.forEach(t=>{let s,n;const i=t.querySelector(this.selectors.menuLinks);if(this.dom.submenuItems.includes(t)){const l=t.querySelector(this.selectors.submenuToggles),m=t.querySelector(this.selectors.submenus),c=new this._MenuType({menuElement:m,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuSubtoggles,submenuSelector:this.selectors.submenus,submenuSubtoggleSelector:this.selectors.submenuSubtoggles,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),f=new this._MenuToggleType({menuToggleElement:l,parentElement:t,controlledMenu:c,parentMenu:this});this._elements.submenuToggles.push(f),l!==i?(n=new this._MenuItemType({menuItemElement:t,menuLinkElement:l,parentMenu:this,isSubmenuItem:!0,childMenu:c,toggle:f}),s=new this._MenuItemType({menuItemElement:t,menuLinkElement:i,parentMenu:this,submenuSibling:n})):s=new this._MenuItemType({menuItemElement:t,menuLinkElement:i,parentMenu:this,isSubmenuItem:!0,childMenu:c,toggle:f})}else s=new this._MenuItemType({menuItemElement:t,menuLinkElement:i,parentMenu:this});this._elements.menuItems.push(s),typeof n<"u"&&this._elements.menuItems.push(n)})}_validate(){let t=super._validate();const s=L({submenuSubtoggleSelector:this._selectors.submenuSubtoggles});s.status||(this._errors.push(s.error.message),t=!1);const n=a("boolean",{optionalKeySupport:this._optionalSupport});return n.status||(this._errors.push(n.error.message),t=!1),t}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close(),this.elements.rootMenu.hasOpened=!1))})}_handleHover(){this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerenter",n=>{if(!(n.pointerType==="pen"||n.pointerType==="touch")){if(this.hoverType==="on"){this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s);let i=t.isSubmenuItem?t.elements.toggle:null;if(t.elements.sibling!==null&&(i=t.elements.sibling.elements.toggle),i===null)return;this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{i.preview()},this.enterDelay)):i.preview()}else if(this.hoverType==="dynamic"&&(this.currentChild=s,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),!this.isTopLevel||this.hasOpened)){this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild();let i=t.isSubmenuItem?t.elements.toggle:null;t.elements.sibling!==null&&(i=t.elements.sibling.elements.toggle),i!==null?this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{i.preview()},this.enterDelay)):i.preview():this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.closeChildren()},this.enterDelay)):this.closeChildren()}}}),t.isSubmenuItem&&(t.dom.item.addEventListener("pointerleave",n=>{n.pointerType==="pen"||n.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse",t.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",t.elements.toggle.close()):this.hoverType==="dynamic"&&(this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse"},this.leaveDelay)):this.currentEvent="mouse"))}),t.dom.item.addEventListener("pointerenter",n=>{n.pointerType==="pen"||n.pointerType==="touch"||t.isSubmenuItem&&(this.hoverType==="on"||this.hoverType==="dynamic")&&this.leaveDelay>0&&this._clearTimeout()}))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=I(t);if(this.focusState==="self"){const n=["Space","Enter"],i=["Escape"],l=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&d(t):(this.currentMenuItem.isSubmenuItem&&n.includes(s)||this.elements.controller&&i.includes(s)||this.elements.parentMenu&&l.includes(s))&&d(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=I(t);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(d(t),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(i=>i.isOpen)?(d(t),this.closeChildren()):this.elements.parentMenu?(d(t),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.closeChildren(),this.elements.parentMenu.focusCurrentChild()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(d(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(d(t),this.focusPreviousChild()):s==="Home"?(d(t),this.focusFirstChild()):s==="End"&&(d(t),this.focusLastChild())))})}}class R extends V{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:l=null,initialize:m=!0,submenuSibling:c=null}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:l,initialize:!1,submenuSibling:c}),m&&this.initialize()}}class U extends B{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:i=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:i,initialize:!1});r(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,l&&this.initialize()}initialize(){super.initialize(),this.elements.controlledMenu.bootstrapTransitions&&this.elements.controlledMenu.isTopLevel&&(this.dom.container.style.transition="height var(--am-transition-duration) ease")}_expand(t=!0){const{openClass:s,closeClass:n,transitionClass:i,openDuration:l,bootstrapTransitions:m,isTopLevel:c}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),this.elements.controlledMenu.elements.rootMenu.hasOpened=!0,i!==""?m?c?(h(i,this.dom.container),u(n,this.dom.container),this.dom.container.style.height=`${this.dom.container.scrollHeight}px`,requestAnimationFrame(()=>{setTimeout(()=>{h(s,this.dom.container),h(n,this.dom.container),u(i,this.dom.container),this.dom.container.style.height=""},l)})):(h(s,this.dom.container),u(n,this.dom.container)):(h(i,this.dom.container),requestAnimationFrame(()=>{u(n,this.dom.container),requestAnimationFrame(()=>{h(s,this.dom.container),requestAnimationFrame(()=>{setTimeout(()=>{u(i,this.dom.container)},l)})})})):(h(s,this.dom.container),u(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:i,closeDuration:l,bootstrapTransitions:m,isTopLevel:c}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),i!==""?m?c?(this.dom.container.style.height=`${this.dom.container.offsetHeight}px`,requestAnimationFrame(()=>{h(i,this.dom.container),requestAnimationFrame(()=>{u(n,this.dom.container),u(s,this.dom.container),this.dom.container.style.height="",requestAnimationFrame(()=>{setTimeout(()=>{u(i,this.dom.container),h(s,this.dom.container)},l)})})})):(h(s,this.dom.container),u(n,this.dom.container)):(h(i,this.dom.container),requestAnimationFrame(()=>{u(n,this.dom.container),requestAnimationFrame(()=>{h(s,this.dom.container),requestAnimationFrame(()=>{setTimeout(()=>{u(i,this.dom.container)},l)})})})):(h(s,this.dom.container),u(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class O extends ${constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:m=".dropdown-menu",submenuSubtoggleSelector:c=".dropdown-toggle",controllerElement:f=null,containerElement:_=null,openClass:y="show",closeClass:b="collapse",transitionClass:p="collapsing",transitionDuration:E=350,openDuration:C=-1,closeDuration:M=-1,isTopLevel:v=!0,parentMenu:D=null,hoverType:w="off",hoverDelay:S=250,enterDelay:k=-1,leaveDelay:x=-1,optionalKeySupport:F=!1,prefix:Z="am-",bootstrapTransitions:Q=!0,disableBootstrap:W=!0,initialize:G=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:l,submenuSelector:m,submenuSubtoggleSelector:c,controllerElement:f,containerElement:_,openClass:y,closeClass:b,transitionClass:p,transitionDuration:E,openDuration:C,closeDuration:M,isTopLevel:v,parentMenu:D,hoverType:w,hoverDelay:S,enterDelay:k,leaveDelay:x,optionalKeySupport:F,prefix:Z,initialize:!1});r(this,"_MenuType",O);r(this,"_MenuItemType",R);r(this,"_MenuToggleType",U);r(this,"_disableBootstrap",!0);r(this,"_pseudoDropdownElement",document.createElement("div"));r(this,"_bootstrapDropdownEvents",["show.bs.dropdown","shown.bs.dropdown","hide.bs.dropdown","hidden.bs.dropdown"]);r(this,"_pseudoCollapseElement",document.createElement("div"));r(this,"_bootstrapCollapseEvents",["show.bs.collapse","shown.bs.collapse","hide.bs.collapse","hidden.bs.collapse"]);r(this,"_bootstrapTransitions",!0);this._disableBootstrap=W,this._bootstrapTransitions=Q,G&&this.initialize()}initialize(){super.initialize(),this.bootstrapDisabled&&(this._disableBootstrapDropdownBehaviour(),this._disableBootstrapCollapseBehaviour())}get bootstrapTransitions(){return this.isTopLevel?this._bootstrapTransitions:this.elements.rootMenu.bootstrapTransitions}get bootstrapDisabled(){return this._disableBootstrap}get bootstrapPseudoDropdownElement(){return this._pseudoDropdownElement}get bootstrapDropdownEvents(){return this._bootstrapDropdownEvents}get bootstrapPseudoCollapseElement(){return this._pseudoCollapseElement}get bootstrapCollapseEvents(){return this._bootstrapCollapseEvents}_validate(){let t=super._validate();const s=a("boolean",{bootstrapTransitions:this._bootstrapTransitions});s.status||(this._errors.push(s.error.message),t=!1);const n=a("boolean",{disableBootstrap:this._disableBootstrap});return n.status||(this._errors.push(n.error.message),t=!1),t}_disableBootstrapDropdownBehaviour(){this.elements.submenuToggles.forEach(t=>{this.bootstrapDropdownEvents.forEach(s=>{t.dom.toggle.addEventListener(s,n=>{d(n);const i=bootstrap.Dropdown.getInstance(n.target);i&&i._menu!==this.bootstrapPseudoDropdownElement&&(i._menu=this.bootstrapPseudoDropdownElement)},{once:!0})})})}_disableBootstrapCollapseBehaviour(){this.elements.controller&&this.bootstrapCollapseEvents.forEach(t=>{this.dom.container.addEventListener(t,s=>{d(s);const n=bootstrap.Collapse.getInstance(s.target);n&&n._element!==this.bootstrapPseudoCollapseElement&&(n._element=this.bootstrapPseudoCollapseElement)},{once:!0})})}_setTransitionDurations(){super._setTransitionDurations(),this.isTopLevel&&this.elements.controller&&(this.elements.controller.dom.container.style.setProperty(`--${this.prefix}transition-duration`,`${this.transitionDuration}ms`),this.elements.controller.dom.container.style.setProperty(`--${this.prefix}open-transition-duration`,`${this.openDuration}ms`),this.elements.controller.dom.container.style.setProperty(`--${this.prefix}close-transition-duration`,`${this.closeDuration}ms`))}}return O}(); |
@@ -1,3 +0,3 @@ | ||
"use strict";var q=Object.defineProperty;var V=(n,e,t)=>e in n?q(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var o=(n,e,t)=>(V(n,typeof e!="symbol"?e+"":e,t),t);function p(n,e){typeof n=="string"?e.classList.add(n):e.classList.add(...n)}function _(n,e){typeof n=="string"?e.classList.remove(n):e.classList.remove(...n)}function T(n,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof n)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${n.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function g(n,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==n)throw new TypeError(`${t} must be a ${n}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function S(n){try{if(typeof n!="object"){const e=typeof n;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${e}" given.`)}for(const e in n)try{if(n[e]===null)throw new Error;document.querySelector(n[e])}catch{throw new TypeError(`${e} must be a valid query selector. "${n[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function b(n){try{if(typeof n!="object"||Array.isArray(n)){const e=typeof n;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in n){const t=typeof n[e];if(t!=="string")if(Array.isArray(n[e]))n[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=n[e],S(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function N(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function K(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function x(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function B(n,e){if(g("string",{tagName:n}).status&&T(HTMLElement,e).status){const t=n.toLowerCase();let s=!0;for(const i in e)e[i].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class O{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i=null}){o(this,"_dom",{toggle:null,parent:null});o(this,"_elements",{controlledMenu:null,parentMenu:null});o(this,"_open",!1);o(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));o(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=i}initialize(){this._setIds(),this._setAriaAttributes(),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){g("boolean",{value:e}),this._open=e}_setIds(){var e;if(this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",i=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),i=`${s}-${i}`),this.dom.toggle.id=this.dom.toggle.id||`menu-button-${i}`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`menu-${i}`}}_setAriaAttributes(){this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),B("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id)}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),i!==""?(p(i,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&_(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&p(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{_(i,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&p(s,this.elements.controlledMenu.dom.menu),t!==""&&_(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),i!==""?(p(i,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&_(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&p(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{_(i,this.elements.controlledMenu.dom.menu)})})})):(t!==""&&p(t,this.elements.controlledMenu.dom.menu),s!==""&&_(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class ${constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:l=null}){o(this,"_dom",{item:null,link:null});o(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});o(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=r,this._elements.toggle=l,this._submenu=i}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function w(n){try{const e=n.key||n.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function c(n){n.preventDefault(),n.stopPropagation()}class I{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:l="ul",controllerElement:u=null,containerElement:h=null,openClass:m="show",closeClass:a="hide",transitionClass:d="transitioning",isTopLevel:f=!0,parentMenu:y=null,hoverType:C="off",hoverDelay:M=250,enterDelay:E=-1,leaveDelay:v=-1}){o(this,"_MenuType",I);o(this,"_MenuItemType",$);o(this,"_MenuToggleType",O);o(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});o(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});o(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});o(this,"_openClass","show");o(this,"_closeClass","hide");o(this,"_transitionClass","transitioning");o(this,"_root",!0);o(this,"_currentChild",0);o(this,"_focusState","none");o(this,"_currentEvent","none");o(this,"_hoverType","off");o(this,"_hoverDelay",250);o(this,"_enterDelay",-1);o(this,"_leaveDelay",-1);o(this,"_hoverTimeout",null);o(this,"_errors",[]);this._dom.menu=e,this._dom.controller=u,this._dom.container=h,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=i,this._selectors.submenuToggles=r,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=y,this._elements.rootMenu=f?this:null,this._openClass=m||"",this._closeClass=a||"",this._transitionClass=d||"",this._root=f,this._hoverType=C,this._hoverDelay=M,this._enterDelay=E,this._leaveDelay=v}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
"use strict";var K=Object.defineProperty;var N=(i,e,t)=>e in i?K(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var o=(i,e,t)=>N(i,typeof e!="symbol"?e+"":e,t);function m(i,e){i===""||i.length===0||(typeof i=="string"?e.classList.add(i):e.classList.add(...i))}function c(i,e){i===""||i.length===0||(typeof i=="string"?e.classList.remove(i):e.classList.remove(...i))}function L(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function a(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function S(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid query selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function C(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],S(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function R(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function U(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function O(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function W(i,e){if(a("string",{tagName:i}).status&&L(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class F{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){o(this,"_dom",{toggle:null,parent:null});o(this,"_elements",{controlledMenu:null,parentMenu:null});o(this,"_open",!1);o(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));o(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){this._setIds(),this._setAriaAttributes(),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){a("boolean",{value:e}),this._open=e}_setIds(){var e;if(this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`menu-button-${n}`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`menu-${n}`}}_setAriaAttributes(){this.dom.toggle.setAttribute("aria-expanded","false"),this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id)}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n,openDuration:r}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),this.elements.controlledMenu.elements.rootMenu.hasOpened=!0,n!==""?(m(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{c(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{m(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{setTimeout(()=>{c(n,this.elements.controlledMenu.dom.menu)},r)})})})):(m(s,this.elements.controlledMenu.dom.menu),c(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n,closeDuration:r}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(m(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{c(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{m(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{setTimeout(()=>{c(n,this.elements.controlledMenu.dom.menu)},r)})})})):(m(t,this.elements.controlledMenu.dom.menu),c(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this.isOpen||(this._expand(),this.isOpen=!0)}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this.isOpen||(this._expand(),this.isOpen=!0)}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class z{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null}){o(this,"_dom",{item:null,link:null});o(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});o(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=r,this._elements.toggle=l,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&requestAnimationFrame(()=>{this.dom.link.focus()})}blur(){this.elements.parentMenu.shouldFocus&&requestAnimationFrame(()=>{this.dom.link.blur()})}}function A(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function p(i){i.preventDefault(),i.stopPropagation()}class k{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="li:has(ul)",submenuToggleSelector:r="a",submenuSelector:l="ul",controllerElement:u=null,containerElement:h=null,openClass:b="show",closeClass:f="hide",transitionClass:g="transitioning",transitionDuration:_=250,openDuration:d=-1,closeDuration:T=-1,isTopLevel:y=!0,parentMenu:M=null,hoverType:E="off",hoverDelay:v=250,enterDelay:D=-1,leaveDelay:w=-1,prefix:I="am-"}){o(this,"_MenuType",k);o(this,"_MenuItemType",z);o(this,"_MenuToggleType",F);o(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});o(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});o(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});o(this,"_openClass","show");o(this,"_closeClass","hide");o(this,"_transitionClass","transitioning");o(this,"_transitionDuration",250);o(this,"_openDuration",-1);o(this,"_closeDuration",-1);o(this,"_root",!0);o(this,"_currentChild",0);o(this,"_focusState","none");o(this,"_currentEvent","none");o(this,"_hoverType","off");o(this,"_hoverDelay",250);o(this,"_enterDelay",-1);o(this,"_leaveDelay",-1);o(this,"_prefix","am-");o(this,"_hoverTimeout",null);o(this,"_hasOpened",!1);o(this,"_errors",[]);this._dom.menu=e,this._dom.controller=u,this._dom.container=h,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=r,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=M,this._elements.rootMenu=y?this:null,this._openClass=b||"",this._closeClass=f||"",this._transitionClass=g||"",this._transitionDuration=_,this._openDuration=d,this._closeDuration=T,this._prefix=I||"",this._root=y,this._hoverType=E,this._hoverDelay=v,this._enterDelay=D,this._leaveDelay=w}initialize(){if(!this._validate())throw new Error(`AccessibleMenu: cannot initialize menu. The following errors have been found: | ||
- ${this.errors.join(` | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){b({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){b({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){b({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set currentChild(e){g("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let r=0,l=!1;for(;!l&&r<s.elements.parentMenu.elements.menuItems.length;){const u=s.elements.parentMenu.elements.menuItems[r];u.isSubmenuItem&&u.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=r),r++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){N({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){K({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){x({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){g("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){g("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){g("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=T(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=T(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const m=b({openClass:this._openClass});m.status||(this._errors.push(m.error.message),e=!1)}if(this._closeClass!==""){const m=b({closeClass:this._closeClass});m.status||(this._errors.push(m.error.message),e=!1)}if(this._transitionClass!==""){const m=b({transitionClass:this._transitionClass});m.status||(this._errors.push(m.error.message),e=!1)}const i=g("boolean",{isTopLevel:this._root});if(i.status||(this._errors.push(i.error.message),e=!1),this._elements.parentMenu!==null){const m=T(I,{parentMenu:this._elements.parentMenu});m.status||(this._errors.push(m.error.message),e=!1)}const r=x({hoverType:this._hoverType});r.status||(this._errors.push(r.error.message),e=!1);const l=g("number",{hoverDelay:this._hoverDelay});l.status||(this._errors.push(l.error.message),e=!1);const u=g("number",{enterDelay:this._enterDelay});u.status||(this._errors.push(u.error.message),e=!1);const h=g("number",{leaveDelay:this._leaveDelay});return h.status||(this._errors.push(h.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&T(HTMLElement,{base:t});const r=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=r:this._dom[e]=[...this._dom[e],...r]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),i=e.querySelector(this.selectors.submenus),r=new this._MenuType({menuElement:i,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:r,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:r,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,i){c(i),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",i=>{this.currentEvent="mouse",e(this,t.elements.toggle,i)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t),e.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview());else if(this.hoverType==="dynamic"){const i=this.elements.submenuToggles.some(r=>r.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||i)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&c(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&(c(e),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class F extends ${constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:l=null,initialize:u=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i,childMenu:r,toggle:l}),u&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","treeitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.dom.link.tabIndex=0}blur(){super.blur(),this.dom.link.tabIndex=-1}}class z extends O{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i}),r&&this.initialize()}}class L extends I{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:i="a",submenuItemSelector:r="",submenuToggleSelector:l="a",submenuSelector:u="ul",controllerElement:h=null,containerElement:m=null,openClass:a="show",closeClass:d="hide",transitionClass:f="transitioning",isTopLevel:y=!0,parentMenu:C=null,hoverType:M="off",hoverDelay:E=250,enterDelay:v=-1,leaveDelay:D=-1,initialize:k=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:i,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:u,controllerElement:h,containerElement:m,openClass:a,closeClass:d,transitionClass:f,isTopLevel:y,parentMenu:C,hoverType:M,hoverDelay:E,enterDelay:v,leaveDelay:D});o(this,"_MenuType",L);o(this,"_MenuItemType",F);o(this,"_MenuToggleType",z);k&&this.initialize()}initialize(){try{super.initialize(),this.isTopLevel?(this.dom.menu.setAttribute("role","tree"),this.elements.menuItems[0].dom.link.tabIndex=0):this.dom.menu.setAttribute("role","group"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=w(t);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?this.elements.rootMenu.blur():this.elements.rootMenu.focus()),this.focusState==="self"){const i=["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"],r=["Enter","ArrowRight"],l=["Escape"];(i.includes(s)||this.currentMenuItem.isSubmenuItem&&r.includes(s)||this.elements.controller&&l.includes(s))&&c(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=w(t),{altKey:i,crtlKey:r,metaKey:l}=t;if(s==="Character"&&!(i||r||l))c(t),this.elements.rootMenu.currentEvent="character",this.focusNextNodeWithCharacter(t.key);else if(this.focusState==="self")if(s==="Enter"||s==="Space")c(t),this.currentMenuItem.isSubmenuItem?this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview():this.currentMenuItem.dom.link.click();else if(s==="Escape")this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController());else if(s==="ArrowDown")c(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):!this.isTopLevel&&this.currentChild===this.elements.menuItems.length-1?this.focusParentsNextChild():this.focusNextChild();else if(s==="ArrowUp"){c(t);const h=this.elements.menuItems[this.currentChild-1];h&&h.isSubmenuItem&&h.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentChild=this.currentChild-1,this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.focusChildsLastNode()):!this.isTopLevel&&this.currentChild===0?(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild()):this.focusPreviousChild()}else s==="ArrowRight"?this.currentMenuItem.isSubmenuItem&&(c(t),this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):this.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?(c(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.toggle.close()):this.isTopLevel||(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild())):s==="Home"?(c(t),this.blurCurrentChild(),this.elements.rootMenu.focusFirstChild()):s==="End"?(c(t),this.blurCurrentChild(),this.elements.rootMenu.focusLastNode()):s==="Asterisk"&&(c(t),this.openChildren())})}focusLastNode(){const t=this.elements.menuItems.length-1,s=this.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.isOpen?(this.currentChild=t,s.elements.childMenu.currentEvent=this.currentEvent,s.elements.childMenu.focusLastNode()):this.focusLastChild()}openChildren(){this.elements.submenuToggles.forEach(t=>t.preview())}focusNextNodeWithCharacter(t){function s(a){let d=[];return a.elements.menuItems.forEach(f=>{d.push(f),f.isSubmenuItem&&f.elements.toggle.isOpen&&(d=[...d,...s(f.elements.toggle.elements.controlledMenu)])}),d}const i=t.toLowerCase(),r=s(this.elements.rootMenu),l=r.indexOf(this.currentMenuItem)+1,u=[...r.slice(l),...r.slice(0,l)];let h=0,m=!1;for(;!m&&h<u.length;){let a="";if(u[h].dom.item.innerText?a=u[h].dom.item.innerText:a=u[h].dom.item.textContent,a=a.replace(/[\s]/g,"").toLowerCase().charAt(0),a===i){m=!0;const d=u[h].elements.parentMenu,f=d.elements.menuItems.indexOf(u[h]);this.elements.rootMenu.blurChildren(),d.focusChild(f)}h++}}focusParentsNextChild(){this.elements.parentMenu&&(this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.currentChild===this.elements.parentMenu.elements.menuItems.length-1?(this.elements.parentMenu.blurCurrentChild(),this.elements.parentMenu.focusParentsNextChild()):(this.blurChildren(),this.elements.parentMenu.focusNextChild()))}focusChildsLastNode(){this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusLastChild(),this.currentMenuItem.elements.childMenu.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.childMenu.currentMenuItem.elements.toggle.isOpen&&(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.childMenu.focusChildsLastNode())}}class H extends F{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:l=null,initialize:u=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i,childMenu:r,toggle:l,initialize:!1}),u&&this.initialize()}}class P extends z{constructor({menuToggleElement:t,parentElement:s,controlledMenu:i,parentMenu:r=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:i,parentMenu:r,initialize:!1});o(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=i.isTopLevel?i.dom.container:i.dom.menu,l&&this.initialize()}_expand(t=!0){const{openClass:s,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),i!==""?(p(i,this.dom.container),requestAnimationFrame(()=>{p(s,this.dom.container),requestAnimationFrame(()=>{_(i,this.dom.container)})})):s!==""&&p(s,this.dom.container),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:i,transitionClass:r}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),r!==""?(p(r,this.dom.container),requestAnimationFrame(()=>{i!==""&&_(i,this.dom.container),requestAnimationFrame(()=>{s!==""&&p(s,this.dom.container),requestAnimationFrame(()=>{_(r,this.dom.container)})})})):(s!==""&&p(s,this.dom.container),i!==""&&_(i,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class A extends L{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:i=".nav-link,.dropdown-item",submenuItemSelector:r=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:u=".dropdown-menu",controllerElement:h=null,containerElement:m=null,openClass:a="show",closeClass:d="collapse",transitionClass:f="transitioning",isTopLevel:y=!0,parentMenu:C=null,hoverType:M="off",hoverDelay:E=250,enterDelay:v=-1,leaveDelay:D=-1,disableBootstrap:k=!0,initialize:j=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:i,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:u,controllerElement:h,containerElement:m,openClass:a,closeClass:d,transitionClass:f,isTopLevel:y,parentMenu:C,hoverType:M,hoverDelay:E,enterDelay:v,leaveDelay:D,initialize:!1});o(this,"_MenuType",A);o(this,"_MenuItemType",H);o(this,"_MenuToggleType",P);o(this,"_disableBootstrap",!0);o(this,"_pseudoDropdownElement",document.createElement("div"));o(this,"_bootstrapEvents",["show.bs.dropdown","shown.bs.dropdown","hide.bs.dropdown","hidden.bs.dropdown"]);this._disableBootstrap=k,j&&this.initialize()}initialize(){super.initialize(),this.bootstrapDisabled&&this._disableBootstrapDropdownBehaviour()}get bootstrapDisabled(){return this._disableBootstrap}get bootstrapPseudoDropdownElement(){return this._pseudoDropdownElement}get bootstrapEvents(){return this._bootstrapEvents}_validate(){let t=super._validate();const s=g("boolean",{disableBootstrap:this._disableBootstrap});return s.status||(this._errors.push(s.error.message),t=!1),t}_disableBootstrapDropdownBehaviour(){this.elements.submenuToggles.forEach(t=>{this.bootstrapEvents.forEach(s=>{t.dom.toggle.addEventListener(s,i=>{c(i);const r=bootstrap.Dropdown.getInstance(i.target);r&&r._menu!==this.bootstrapPseudoDropdownElement&&(r._menu=this.bootstrapPseudoDropdownElement)},{once:!0})})})}}module.exports=A; | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});W("button",{toggle:e.dom.toggle})||e.dom.toggle.setAttribute("role","button"),e.dom.toggle.setAttribute("aria-controls",this.dom.menu.id),this._elements.controller=e}this._createChildElements(),this._setTransitionDurations(),this.isTopLevel&&(window.AccessibleMenu=window.AccessibleMenu||{menus:{}},window.AccessibleMenu.menus[this.dom.menu.id]=this)}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get transitionDuration(){return this.isTopLevel?this._transitionDuration:this.elements.rootMenu.transitionDuration}get openDuration(){return this._openDuration===-1?this.transitionDuration:this.isTopLevel?this._openDuration:this.elements.rootMenu.openDuration}get closeDuration(){return this._closeDuration===-1?this.transitionDuration:this.isTopLevel?this._closeDuration:this.elements.rootMenu.closeDuration}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get prefix(){return this._root?this._prefix:this.elements.rootMenu.prefix}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get hasOpened(){return this._root?this._hasOpened:this.elements.rootMenu.hasOpened}get errors(){return this._errors}set openClass(e){C({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){C({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){C({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set transitionDuration(e){a("number",{value:e}),this._transitionDuration!==e&&(this._transitionDuration=e,this._setTransitionDurations())}set openDuration(e){a("number",{value:e}),this._openDuration!==e&&(this._openDuration=e,this._setTransitionDurations())}set closeDuration(e){a("number",{value:e}),this._closeDuration!==e&&(this._closeDuration=e,this._setTransitionDurations())}set currentChild(e){a("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let r=0,l=!1;for(;!l&&r<s.elements.parentMenu.elements.menuItems.length;){const u=s.elements.parentMenu.elements.menuItems[r];u.isSubmenuItem&&u.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=r),r++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){R({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){U({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){O({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){a("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){a("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){a("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}set prefix(e){a("string",{value:e}),this._prefix!==e&&(this._prefix=e)}set hasOpened(e){a("boolean",{value:e}),this._hasOpened!==e&&(this._hasOpened=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=L(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=L(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const d=C({openClass:this._openClass});d.status||(this._errors.push(d.error.message),e=!1)}if(this._closeClass!==""){const d=C({closeClass:this._closeClass});d.status||(this._errors.push(d.error.message),e=!1)}if(this._transitionClass!==""){const d=C({transitionClass:this._transitionClass});d.status||(this._errors.push(d.error.message),e=!1)}const n=a("number",{transitionDuration:this._transitionDuration});n.status||(this._errors.push(n.error.message),e=!1);const r=a("number",{openDuration:this._openDuration});r.status||(this._errors.push(r.error.message),e=!1);const l=a("number",{closeDuration:this._closeDuration});l.status||(this._errors.push(l.error.message),e=!1);const u=a("boolean",{isTopLevel:this._root});if(u.status||(this._errors.push(u.error.message),e=!1),this._elements.parentMenu!==null){const d=L(k,{parentMenu:this._elements.parentMenu});d.status||(this._errors.push(d.error.message),e=!1)}const h=O({hoverType:this._hoverType});h.status||(this._errors.push(h.error.message),e=!1);const b=a("number",{hoverDelay:this._hoverDelay});b.status||(this._errors.push(b.error.message),e=!1);const f=a("number",{enterDelay:this._enterDelay});f.status||(this._errors.push(f.error.message),e=!1);const g=a("number",{leaveDelay:this._leaveDelay});g.status||(this._errors.push(g.error.message),e=!1);const _=a("string",{prefix:this._prefix});return _.status||(this._errors.push(_.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&L(HTMLElement,{base:t});const r=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=r:this._dom[e]=[...this._dom[e],...r]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),r=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,transitionDuration:this.transitionDuration,openDuration:this.openDuration,closeDuration:this.closeDuration,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:r,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:r,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_clearTimeout(){clearTimeout(this._hoverTimeout)}_setTimeout(e,t){a("function",{callback:e}),a("number",{delay:t}),this._hoverTimeout=setTimeout(e,t)}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})}),this.dom.menu.addEventListener("focusout",e=>{this.currentEvent!=="keyboard"||e.relatedTarget===null||this.dom.menu.contains(e.relatedTarget)||(this.focusState="none",this.closeChildren())})}_handleClick(){function e(t,s,n){p(n),n.button===0&&(s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none"))}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this._clearTimeout(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)}),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.elements.rootMenu.hasOpened=this.elements.submenuToggles.some(s=>s.isOpen)))})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t),e.isSubmenuItem&&(this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay)):e.elements.toggle.preview())):this.hoverType==="dynamic"&&(this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),(!this.isTopLevel||this.hasOpened)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),e.isSubmenuItem?this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay)):e.elements.toggle.preview():this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.closeChildren()},this.enterDelay)):this.closeChildren())))}),e.isSubmenuItem&&(e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse"},this.leaveDelay)):this.currentEvent="mouse"))}),e.dom.item.addEventListener("pointerenter",s=>{s.pointerType==="pen"||s.pointerType==="touch"||e.isSubmenuItem&&(this.hoverType==="on"||this.hoverType==="dynamic")&&this.leaveDelay>0&&this._clearTimeout()}))})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=A(e);(t==="Space"||t==="Enter")&&p(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=A(e);(t==="Space"||t==="Enter")&&(p(e),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}_setTransitionDurations(){this.dom.menu.style.setProperty(`--${this.prefix}transition-duration`,`${this.transitionDuration}ms`),this.dom.menu.style.setProperty(`--${this.prefix}open-transition-duration`,`${this.openDuration}ms`),this.dom.menu.style.setProperty(`--${this.prefix}close-transition-duration`,`${this.closeDuration}ms`)}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class q extends z{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:u=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l}),u&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","treeitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.dom.link.tabIndex=0}blur(){super.blur(),this.dom.link.tabIndex=-1}}class j extends F{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),r&&this.initialize()}initialize(){this._setIds(),this._setAriaAttributes(),this.dom.toggle.getAttribute("aria-expanded")==="true"?this.open():this._collapse(!1)}_setAriaAttributes(){this.dom.toggle.getAttribute("aria-expanded")!=="true"&&this.dom.toggle.setAttribute("aria-expanded","false"),this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-owns",this.elements.controlledMenu.dom.menu.id)}}class x extends k{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:r="li:has(ul)",submenuToggleSelector:l="a",submenuSelector:u="ul",controllerElement:h=null,containerElement:b=null,openClass:f="show",closeClass:g="hide",transitionClass:_="transitioning",transitionDuration:d=250,isTopLevel:T=!0,parentMenu:y=null,hoverType:M="off",hoverDelay:E=250,enterDelay:v=-1,leaveDelay:D=-1,prefix:w="am-",initialize:I=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:u,controllerElement:h,containerElement:b,openClass:f,closeClass:g,transitionClass:_,transitionDuration:d,isTopLevel:T,parentMenu:y,hoverType:M,hoverDelay:E,enterDelay:v,leaveDelay:D,prefix:w});o(this,"_MenuType",x);o(this,"_MenuItemType",q);o(this,"_MenuToggleType",j);I&&this.initialize()}initialize(){try{super.initialize(),this.isTopLevel?(this.dom.menu.setAttribute("role","tree"),this.elements.menuItems[0].dom.link.tabIndex=0):this.dom.menu.setAttribute("role","group"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup(),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.removeAttribute("aria-owns")}catch(t){console.error(t)}}_handleHover(){this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerenter",n=>{n.pointerType==="pen"||n.pointerType==="touch"||(this.hoverType==="on"?(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s),t.isSubmenuItem&&(this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{t.elements.toggle.preview()},this.enterDelay)):t.elements.toggle.preview())):this.hoverType==="dynamic"&&(this.currentChild=s,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),(!this.isTopLevel||this.hasOpened)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),t.isSubmenuItem?this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{t.elements.toggle.preview()},this.enterDelay)):t.elements.toggle.preview():this.enterDelay>0&&this._clearTimeout())))}),t.isSubmenuItem&&(t.dom.item.addEventListener("pointerleave",n=>{n.pointerType==="pen"||n.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0&&this._clearTimeout():this.hoverType==="dynamic"&&(this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse"},this.leaveDelay)):this.currentEvent="mouse"))}),t.dom.item.addEventListener("pointerenter",n=>{n.pointerType==="pen"||n.pointerType==="touch"||t.isSubmenuItem&&(this.hoverType==="on"||this.hoverType==="dynamic")&&this.leaveDelay>0&&this._clearTimeout()})),this.isTopLevel&&this.dom.menu.addEventListener("pointerleave",n=>{n.pointerType==="pen"||n.pointerType==="touch"||this.hoverType==="on"&&(this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.closeChildren(),this.blur()},this.leaveDelay)):(this.closeChildren(),this.blur()))})})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=A(t);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?this.elements.rootMenu.blur():this.elements.rootMenu.focus()),this.focusState==="self"){const n=["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"],r=["Enter","ArrowRight"],l=["Escape"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&r.includes(s)||this.elements.controller&&l.includes(s))&&p(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=A(t),{altKey:n,crtlKey:r,metaKey:l}=t;if(s==="Character"&&!(n||r||l))p(t),this.elements.rootMenu.currentEvent="character",this.focusNextNodeWithCharacter(t.key);else if(this.focusState==="self")if(s==="Enter"||s==="Space")p(t),this.currentMenuItem.isSubmenuItem?this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview():this.currentMenuItem.dom.link.click();else if(s==="Escape")this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController());else if(s==="ArrowDown")p(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):!this.isTopLevel&&this.currentChild===this.elements.menuItems.length-1?this.focusParentsNextChild():this.focusNextChild();else if(s==="ArrowUp"){p(t);const h=this.elements.menuItems[this.currentChild-1];h&&h.isSubmenuItem&&h.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentChild=this.currentChild-1,this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.focusChildsLastNode()):!this.isTopLevel&&this.currentChild===0?(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild()):this.focusPreviousChild()}else s==="ArrowRight"?this.currentMenuItem.isSubmenuItem&&(p(t),this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):this.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?(p(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.toggle.close()):this.isTopLevel||(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild())):s==="Home"?(p(t),this.blurCurrentChild(),this.elements.rootMenu.focusFirstChild()):s==="End"?(p(t),this.blurCurrentChild(),this.elements.rootMenu.focusLastNode()):s==="Asterisk"&&(p(t),this.openChildren())})}focusLastNode(){const t=this.elements.menuItems.length-1,s=this.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.isOpen?(this.currentChild=t,s.elements.childMenu.currentEvent=this.currentEvent,s.elements.childMenu.focusLastNode()):this.focusLastChild()}openChildren(){this.elements.submenuToggles.forEach(t=>t.preview())}focusNextNodeWithCharacter(t){function s(f){let g=[];return f.elements.menuItems.forEach(_=>{g.push(_),_.isSubmenuItem&&_.elements.toggle.isOpen&&(g=[...g,...s(_.elements.toggle.elements.controlledMenu)])}),g}const n=t.toLowerCase(),r=s(this.elements.rootMenu),l=r.indexOf(this.currentMenuItem)+1,u=[...r.slice(l),...r.slice(0,l)];let h=0,b=!1;for(;!b&&h<u.length;){let f="";if(u[h].dom.item.innerText?f=u[h].dom.item.innerText:f=u[h].dom.item.textContent,f=f.replace(/[\s]/g,"").toLowerCase().charAt(0),f===n){b=!0;const g=u[h].elements.parentMenu,_=g.elements.menuItems.indexOf(u[h]);this.elements.rootMenu.blurChildren(),g.focusChild(_)}h++}}focusParentsNextChild(){this.elements.parentMenu&&(this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.currentChild===this.elements.parentMenu.elements.menuItems.length-1?(this.elements.parentMenu.blurCurrentChild(),this.elements.parentMenu.focusParentsNextChild()):(this.blurChildren(),this.elements.parentMenu.focusNextChild()))}focusChildsLastNode(){this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusLastChild(),this.currentMenuItem.elements.childMenu.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.childMenu.currentMenuItem.elements.toggle.isOpen&&(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.childMenu.focusChildsLastNode())}}class Z extends q{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:u=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l,initialize:!1}),u&&this.initialize()}}class Q extends j{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r,initialize:!1});o(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,l&&this.initialize()}initialize(){super.initialize(),this.elements.controlledMenu.bootstrapTransitions&&this.elements.controlledMenu.isTopLevel&&(this.dom.container.style.transition="height var(--am-transition-duration) ease")}_expand(t=!0){const{openClass:s,closeClass:n,transitionClass:r,openDuration:l,bootstrapTransitions:u,isTopLevel:h}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),this.elements.controlledMenu.elements.rootMenu.hasOpened=!0,r!==""?u?h?(m(r,this.dom.container),c(n,this.dom.container),this.dom.container.style.height=`${this.dom.container.scrollHeight}px`,requestAnimationFrame(()=>{setTimeout(()=>{m(s,this.dom.container),m(n,this.dom.container),c(r,this.dom.container),this.dom.container.style.height=""},l)})):(m(s,this.dom.container),c(n,this.dom.container)):(m(r,this.dom.container),requestAnimationFrame(()=>{c(n,this.dom.container),requestAnimationFrame(()=>{m(s,this.dom.container),requestAnimationFrame(()=>{setTimeout(()=>{c(r,this.dom.container)},l)})})})):(m(s,this.dom.container),c(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:r,closeDuration:l,bootstrapTransitions:u,isTopLevel:h}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),r!==""?u?h?(this.dom.container.style.height=`${this.dom.container.offsetHeight}px`,requestAnimationFrame(()=>{m(r,this.dom.container),requestAnimationFrame(()=>{c(n,this.dom.container),c(s,this.dom.container),this.dom.container.style.height="",requestAnimationFrame(()=>{setTimeout(()=>{c(r,this.dom.container),m(s,this.dom.container)},l)})})})):(m(s,this.dom.container),c(n,this.dom.container)):(m(r,this.dom.container),requestAnimationFrame(()=>{c(n,this.dom.container),requestAnimationFrame(()=>{m(s,this.dom.container),requestAnimationFrame(()=>{setTimeout(()=>{c(r,this.dom.container)},l)})})})):(m(s,this.dom.container),c(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class $ extends x{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:r=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:u=".dropdown-menu",controllerElement:h=null,containerElement:b=null,openClass:f="show",closeClass:g="collapse",transitionClass:_="collapsing",transitionDuration:d=350,openDuration:T=-1,closeDuration:y=-1,isTopLevel:M=!0,parentMenu:E=null,hoverType:v="off",hoverDelay:D=250,enterDelay:w=-1,leaveDelay:I=-1,prefix:P="am-",bootstrapTransitions:V=!0,disableBootstrap:B=!0,initialize:H=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:u,controllerElement:h,containerElement:b,openClass:f,closeClass:g,transitionClass:_,transitionDuration:d,openDuration:T,closeDuration:y,isTopLevel:M,parentMenu:E,hoverType:v,hoverDelay:D,enterDelay:w,leaveDelay:I,prefix:P,initialize:!1});o(this,"_MenuType",$);o(this,"_MenuItemType",Z);o(this,"_MenuToggleType",Q);o(this,"_disableBootstrap",!0);o(this,"_pseudoDropdownElement",document.createElement("div"));o(this,"_bootstrapDropdownEvents",["show.bs.dropdown","shown.bs.dropdown","hide.bs.dropdown","hidden.bs.dropdown"]);o(this,"_pseudoCollapseElement",document.createElement("div"));o(this,"_bootstrapCollapseEvents",["show.bs.collapse","shown.bs.collapse","hide.bs.collapse","hidden.bs.collapse"]);o(this,"_bootstrapTransitions",!0);this._disableBootstrap=B,this._bootstrapTransitions=V,H&&this.initialize()}initialize(){super.initialize(),this.bootstrapDisabled&&(this._disableBootstrapDropdownBehaviour(),this._disableBootstrapCollapseBehaviour())}get bootstrapTransitions(){return this.isTopLevel?this._bootstrapTransitions:this.elements.rootMenu.bootstrapTransitions}get bootstrapDisabled(){return this._disableBootstrap}get bootstrapPseudoDropdownElement(){return this._pseudoDropdownElement}get bootstrapDropdownEvents(){return this._bootstrapDropdownEvents}get bootstrapPseudoCollapseElement(){return this._pseudoCollapseElement}get bootstrapCollapseEvents(){return this._bootstrapCollapseEvents}_validate(){let t=super._validate();const s=a("boolean",{bootstrapTransitions:this._bootstrapTransitions});s.status||(this._errors.push(s.error.message),t=!1);const n=a("boolean",{disableBootstrap:this._disableBootstrap});return n.status||(this._errors.push(n.error.message),t=!1),t}_disableBootstrapDropdownBehaviour(){this.elements.submenuToggles.forEach(t=>{this.bootstrapDropdownEvents.forEach(s=>{t.dom.toggle.addEventListener(s,n=>{p(n);const r=bootstrap.Dropdown.getInstance(n.target);r&&r._menu!==this.bootstrapPseudoDropdownElement&&(r._menu=this.bootstrapPseudoDropdownElement)},{once:!0})})})}_disableBootstrapCollapseBehaviour(){this.elements.controller&&this.bootstrapCollapseEvents.forEach(t=>{this.dom.container.addEventListener(t,s=>{p(s);const n=bootstrap.Collapse.getInstance(s.target);n&&n._element!==this.bootstrapPseudoCollapseElement&&(n._element=this.bootstrapPseudoCollapseElement)},{once:!0})})}_setTransitionDurations(){super._setTransitionDurations(),this.isTopLevel&&this.elements.controller&&(this.elements.controller.dom.container.style.setProperty(`--${this.prefix}transition-duration`,`${this.transitionDuration}ms`),this.elements.controller.dom.container.style.setProperty(`--${this.prefix}open-transition-duration`,`${this.openDuration}ms`),this.elements.controller.dom.container.style.setProperty(`--${this.prefix}close-transition-duration`,`${this.closeDuration}ms`))}}module.exports=$; |
@@ -1,3 +0,3 @@ | ||
var Bootstrap5Treeview=function(){"use strict";var H=Object.defineProperty;var P=(c,a,_)=>a in c?H(c,a,{enumerable:!0,configurable:!0,writable:!0,value:_}):c[a]=_;var o=(c,a,_)=>(P(c,typeof a!="symbol"?a+"":a,_),_);function c(i,e){typeof i=="string"?e.classList.add(i):e.classList.add(...i)}function a(i,e){typeof i=="string"?e.classList.remove(i):e.classList.remove(...i)}function _(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function b(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function D(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid query selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function y(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],D(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function j(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function q(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function x(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function V(i,e){if(b("string",{tagName:i}).status&&_(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class O{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){o(this,"_dom",{toggle:null,parent:null});o(this,"_elements",{controlledMenu:null,parentMenu:null});o(this,"_open",!1);o(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));o(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){this._setIds(),this._setAriaAttributes(),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){b("boolean",{value:e}),this._open=e}_setIds(){var e;if(this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`menu-button-${n}`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`menu-${n}`}}_setAriaAttributes(){this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),V("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id)}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(c(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&a(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&c(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{a(n,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&c(s,this.elements.controlledMenu.dom.menu),t!==""&&a(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(c(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&a(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&c(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{a(n,this.elements.controlledMenu.dom.menu)})})})):(t!==""&&c(t,this.elements.controlledMenu.dom.menu),s!==""&&a(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class ${constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null}){o(this,"_dom",{item:null,link:null});o(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});o(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=r,this._elements.toggle=l,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function w(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function d(i){i.preventDefault(),i.stopPropagation()}class I{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="",submenuToggleSelector:r="a",submenuSelector:l="ul",controllerElement:u=null,containerElement:h=null,openClass:m="show",closeClass:f="hide",transitionClass:p="transitioning",isTopLevel:g=!0,parentMenu:C=null,hoverType:M="off",hoverDelay:E=250,enterDelay:v=-1,leaveDelay:T=-1}){o(this,"_MenuType",I);o(this,"_MenuItemType",$);o(this,"_MenuToggleType",O);o(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});o(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});o(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});o(this,"_openClass","show");o(this,"_closeClass","hide");o(this,"_transitionClass","transitioning");o(this,"_root",!0);o(this,"_currentChild",0);o(this,"_focusState","none");o(this,"_currentEvent","none");o(this,"_hoverType","off");o(this,"_hoverDelay",250);o(this,"_enterDelay",-1);o(this,"_leaveDelay",-1);o(this,"_hoverTimeout",null);o(this,"_errors",[]);this._dom.menu=e,this._dom.controller=u,this._dom.container=h,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=r,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=C,this._elements.rootMenu=g?this:null,this._openClass=m||"",this._closeClass=f||"",this._transitionClass=p||"",this._root=g,this._hoverType=M,this._hoverDelay=E,this._enterDelay=v,this._leaveDelay=T}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
var Bootstrap5Treeview=function(){"use strict";var Z=Object.defineProperty;var Q=(a,u,y)=>u in a?Z(a,u,{enumerable:!0,configurable:!0,writable:!0,value:y}):a[u]=y;var o=(a,u,y)=>Q(a,typeof u!="symbol"?u+"":u,y);function a(i,e){i===""||i.length===0||(typeof i=="string"?e.classList.add(i):e.classList.add(...i))}function u(i,e){i===""||i.length===0||(typeof i=="string"?e.classList.remove(i):e.classList.remove(...i))}function y(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function c(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function S(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid query selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function C(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],S(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function P(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function V(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function O(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function B(i,e){if(c("string",{tagName:i}).status&&y(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class F{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){o(this,"_dom",{toggle:null,parent:null});o(this,"_elements",{controlledMenu:null,parentMenu:null});o(this,"_open",!1);o(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));o(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){this._setIds(),this._setAriaAttributes(),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){c("boolean",{value:e}),this._open=e}_setIds(){var e;if(this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`menu-button-${n}`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`menu-${n}`}}_setAriaAttributes(){this.dom.toggle.setAttribute("aria-expanded","false"),this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id)}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n,openDuration:r}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),this.elements.controlledMenu.elements.rootMenu.hasOpened=!0,n!==""?(a(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{u(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{a(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{setTimeout(()=>{u(n,this.elements.controlledMenu.dom.menu)},r)})})})):(a(s,this.elements.controlledMenu.dom.menu),u(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n,closeDuration:r}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(a(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{u(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{a(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{setTimeout(()=>{u(n,this.elements.controlledMenu.dom.menu)},r)})})})):(a(t,this.elements.controlledMenu.dom.menu),u(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this.isOpen||(this._expand(),this.isOpen=!0)}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this.isOpen||(this._expand(),this.isOpen=!0)}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class z{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null}){o(this,"_dom",{item:null,link:null});o(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});o(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=r,this._elements.toggle=l,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&requestAnimationFrame(()=>{this.dom.link.focus()})}blur(){this.elements.parentMenu.shouldFocus&&requestAnimationFrame(()=>{this.dom.link.blur()})}}function A(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function d(i){i.preventDefault(),i.stopPropagation()}class k{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="li:has(ul)",submenuToggleSelector:r="a",submenuSelector:l="ul",controllerElement:h=null,containerElement:m=null,openClass:b="show",closeClass:f="hide",transitionClass:g="transitioning",transitionDuration:_=250,openDuration:p=-1,closeDuration:M=-1,isTopLevel:T=!0,parentMenu:E=null,hoverType:v="off",hoverDelay:D=250,enterDelay:w=-1,leaveDelay:I=-1,prefix:L="am-"}){o(this,"_MenuType",k);o(this,"_MenuItemType",z);o(this,"_MenuToggleType",F);o(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});o(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});o(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});o(this,"_openClass","show");o(this,"_closeClass","hide");o(this,"_transitionClass","transitioning");o(this,"_transitionDuration",250);o(this,"_openDuration",-1);o(this,"_closeDuration",-1);o(this,"_root",!0);o(this,"_currentChild",0);o(this,"_focusState","none");o(this,"_currentEvent","none");o(this,"_hoverType","off");o(this,"_hoverDelay",250);o(this,"_enterDelay",-1);o(this,"_leaveDelay",-1);o(this,"_prefix","am-");o(this,"_hoverTimeout",null);o(this,"_hasOpened",!1);o(this,"_errors",[]);this._dom.menu=e,this._dom.controller=h,this._dom.container=m,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=r,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=E,this._elements.rootMenu=T?this:null,this._openClass=b||"",this._closeClass=f||"",this._transitionClass=g||"",this._transitionDuration=_,this._openDuration=p,this._closeDuration=M,this._prefix=L||"",this._root=T,this._hoverType=v,this._hoverDelay=D,this._enterDelay=w,this._leaveDelay=I}initialize(){if(!this._validate())throw new Error(`AccessibleMenu: cannot initialize menu. The following errors have been found: | ||
- ${this.errors.join(` | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){y({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){y({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){y({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set currentChild(e){b("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let r=0,l=!1;for(;!l&&r<s.elements.parentMenu.elements.menuItems.length;){const u=s.elements.parentMenu.elements.menuItems[r];u.isSubmenuItem&&u.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=r),r++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){j({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){q({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){x({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){b("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){b("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){b("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=_(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=_(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=D({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=D({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const m=y({openClass:this._openClass});m.status||(this._errors.push(m.error.message),e=!1)}if(this._closeClass!==""){const m=y({closeClass:this._closeClass});m.status||(this._errors.push(m.error.message),e=!1)}if(this._transitionClass!==""){const m=y({transitionClass:this._transitionClass});m.status||(this._errors.push(m.error.message),e=!1)}const n=b("boolean",{isTopLevel:this._root});if(n.status||(this._errors.push(n.error.message),e=!1),this._elements.parentMenu!==null){const m=_(I,{parentMenu:this._elements.parentMenu});m.status||(this._errors.push(m.error.message),e=!1)}const r=x({hoverType:this._hoverType});r.status||(this._errors.push(r.error.message),e=!1);const l=b("number",{hoverDelay:this._hoverDelay});l.status||(this._errors.push(l.error.message),e=!1);const u=b("number",{enterDelay:this._enterDelay});u.status||(this._errors.push(u.error.message),e=!1);const h=b("number",{leaveDelay:this._leaveDelay});return h.status||(this._errors.push(h.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&_(HTMLElement,{base:t});const r=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=r:this._dom[e]=[...this._dom[e],...r]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),r=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:r,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:r,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,n){d(n),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t),e.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview());else if(this.hoverType==="dynamic"){const n=this.elements.submenuToggles.some(r=>r.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||n)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&d(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&(d(e),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class F extends ${constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:u=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l}),u&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","treeitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.dom.link.tabIndex=0}blur(){super.blur(),this.dom.link.tabIndex=-1}}class z extends O{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),r&&this.initialize()}}class k extends I{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:r="",submenuToggleSelector:l="a",submenuSelector:u="ul",controllerElement:h=null,containerElement:m=null,openClass:f="show",closeClass:p="hide",transitionClass:g="transitioning",isTopLevel:C=!0,parentMenu:M=null,hoverType:E="off",hoverDelay:v=250,enterDelay:T=-1,leaveDelay:L=-1,initialize:A=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:u,controllerElement:h,containerElement:m,openClass:f,closeClass:p,transitionClass:g,isTopLevel:C,parentMenu:M,hoverType:E,hoverDelay:v,enterDelay:T,leaveDelay:L});o(this,"_MenuType",k);o(this,"_MenuItemType",F);o(this,"_MenuToggleType",z);A&&this.initialize()}initialize(){try{super.initialize(),this.isTopLevel?(this.dom.menu.setAttribute("role","tree"),this.elements.menuItems[0].dom.link.tabIndex=0):this.dom.menu.setAttribute("role","group"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=w(t);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?this.elements.rootMenu.blur():this.elements.rootMenu.focus()),this.focusState==="self"){const n=["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"],r=["Enter","ArrowRight"],l=["Escape"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&r.includes(s)||this.elements.controller&&l.includes(s))&&d(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=w(t),{altKey:n,crtlKey:r,metaKey:l}=t;if(s==="Character"&&!(n||r||l))d(t),this.elements.rootMenu.currentEvent="character",this.focusNextNodeWithCharacter(t.key);else if(this.focusState==="self")if(s==="Enter"||s==="Space")d(t),this.currentMenuItem.isSubmenuItem?this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview():this.currentMenuItem.dom.link.click();else if(s==="Escape")this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController());else if(s==="ArrowDown")d(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):!this.isTopLevel&&this.currentChild===this.elements.menuItems.length-1?this.focusParentsNextChild():this.focusNextChild();else if(s==="ArrowUp"){d(t);const h=this.elements.menuItems[this.currentChild-1];h&&h.isSubmenuItem&&h.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentChild=this.currentChild-1,this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.focusChildsLastNode()):!this.isTopLevel&&this.currentChild===0?(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild()):this.focusPreviousChild()}else s==="ArrowRight"?this.currentMenuItem.isSubmenuItem&&(d(t),this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):this.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?(d(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.toggle.close()):this.isTopLevel||(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild())):s==="Home"?(d(t),this.blurCurrentChild(),this.elements.rootMenu.focusFirstChild()):s==="End"?(d(t),this.blurCurrentChild(),this.elements.rootMenu.focusLastNode()):s==="Asterisk"&&(d(t),this.openChildren())})}focusLastNode(){const t=this.elements.menuItems.length-1,s=this.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.isOpen?(this.currentChild=t,s.elements.childMenu.currentEvent=this.currentEvent,s.elements.childMenu.focusLastNode()):this.focusLastChild()}openChildren(){this.elements.submenuToggles.forEach(t=>t.preview())}focusNextNodeWithCharacter(t){function s(f){let p=[];return f.elements.menuItems.forEach(g=>{p.push(g),g.isSubmenuItem&&g.elements.toggle.isOpen&&(p=[...p,...s(g.elements.toggle.elements.controlledMenu)])}),p}const n=t.toLowerCase(),r=s(this.elements.rootMenu),l=r.indexOf(this.currentMenuItem)+1,u=[...r.slice(l),...r.slice(0,l)];let h=0,m=!1;for(;!m&&h<u.length;){let f="";if(u[h].dom.item.innerText?f=u[h].dom.item.innerText:f=u[h].dom.item.textContent,f=f.replace(/[\s]/g,"").toLowerCase().charAt(0),f===n){m=!0;const p=u[h].elements.parentMenu,g=p.elements.menuItems.indexOf(u[h]);this.elements.rootMenu.blurChildren(),p.focusChild(g)}h++}}focusParentsNextChild(){this.elements.parentMenu&&(this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.currentChild===this.elements.parentMenu.elements.menuItems.length-1?(this.elements.parentMenu.blurCurrentChild(),this.elements.parentMenu.focusParentsNextChild()):(this.blurChildren(),this.elements.parentMenu.focusNextChild()))}focusChildsLastNode(){this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusLastChild(),this.currentMenuItem.elements.childMenu.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.childMenu.currentMenuItem.elements.toggle.isOpen&&(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.childMenu.focusChildsLastNode())}}class N extends F{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:u=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l,initialize:!1}),u&&this.initialize()}}class B extends z{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r,initialize:!1});o(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,l&&this.initialize()}_expand(t=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(c(n,this.dom.container),requestAnimationFrame(()=>{c(s,this.dom.container),requestAnimationFrame(()=>{a(n,this.dom.container)})})):s!==""&&c(s,this.dom.container),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:r}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),r!==""?(c(r,this.dom.container),requestAnimationFrame(()=>{n!==""&&a(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&c(s,this.dom.container),requestAnimationFrame(()=>{a(r,this.dom.container)})})})):(s!==""&&c(s,this.dom.container),n!==""&&a(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class S extends k{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:r=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:u=".dropdown-menu",controllerElement:h=null,containerElement:m=null,openClass:f="show",closeClass:p="collapse",transitionClass:g="transitioning",isTopLevel:C=!0,parentMenu:M=null,hoverType:E="off",hoverDelay:v=250,enterDelay:T=-1,leaveDelay:L=-1,disableBootstrap:A=!0,initialize:K=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:u,controllerElement:h,containerElement:m,openClass:f,closeClass:p,transitionClass:g,isTopLevel:C,parentMenu:M,hoverType:E,hoverDelay:v,enterDelay:T,leaveDelay:L,initialize:!1});o(this,"_MenuType",S);o(this,"_MenuItemType",N);o(this,"_MenuToggleType",B);o(this,"_disableBootstrap",!0);o(this,"_pseudoDropdownElement",document.createElement("div"));o(this,"_bootstrapEvents",["show.bs.dropdown","shown.bs.dropdown","hide.bs.dropdown","hidden.bs.dropdown"]);this._disableBootstrap=A,K&&this.initialize()}initialize(){super.initialize(),this.bootstrapDisabled&&this._disableBootstrapDropdownBehaviour()}get bootstrapDisabled(){return this._disableBootstrap}get bootstrapPseudoDropdownElement(){return this._pseudoDropdownElement}get bootstrapEvents(){return this._bootstrapEvents}_validate(){let t=super._validate();const s=b("boolean",{disableBootstrap:this._disableBootstrap});return s.status||(this._errors.push(s.error.message),t=!1),t}_disableBootstrapDropdownBehaviour(){this.elements.submenuToggles.forEach(t=>{this.bootstrapEvents.forEach(s=>{t.dom.toggle.addEventListener(s,n=>{d(n);const r=bootstrap.Dropdown.getInstance(n.target);r&&r._menu!==this.bootstrapPseudoDropdownElement&&(r._menu=this.bootstrapPseudoDropdownElement)},{once:!0})})})}}return S}(); | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});B("button",{toggle:e.dom.toggle})||e.dom.toggle.setAttribute("role","button"),e.dom.toggle.setAttribute("aria-controls",this.dom.menu.id),this._elements.controller=e}this._createChildElements(),this._setTransitionDurations(),this.isTopLevel&&(window.AccessibleMenu=window.AccessibleMenu||{menus:{}},window.AccessibleMenu.menus[this.dom.menu.id]=this)}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get transitionDuration(){return this.isTopLevel?this._transitionDuration:this.elements.rootMenu.transitionDuration}get openDuration(){return this._openDuration===-1?this.transitionDuration:this.isTopLevel?this._openDuration:this.elements.rootMenu.openDuration}get closeDuration(){return this._closeDuration===-1?this.transitionDuration:this.isTopLevel?this._closeDuration:this.elements.rootMenu.closeDuration}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get prefix(){return this._root?this._prefix:this.elements.rootMenu.prefix}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get hasOpened(){return this._root?this._hasOpened:this.elements.rootMenu.hasOpened}get errors(){return this._errors}set openClass(e){C({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){C({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){C({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set transitionDuration(e){c("number",{value:e}),this._transitionDuration!==e&&(this._transitionDuration=e,this._setTransitionDurations())}set openDuration(e){c("number",{value:e}),this._openDuration!==e&&(this._openDuration=e,this._setTransitionDurations())}set closeDuration(e){c("number",{value:e}),this._closeDuration!==e&&(this._closeDuration=e,this._setTransitionDurations())}set currentChild(e){c("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let r=0,l=!1;for(;!l&&r<s.elements.parentMenu.elements.menuItems.length;){const h=s.elements.parentMenu.elements.menuItems[r];h.isSubmenuItem&&h.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=r),r++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){P({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){V({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){O({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){c("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){c("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){c("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}set prefix(e){c("string",{value:e}),this._prefix!==e&&(this._prefix=e)}set hasOpened(e){c("boolean",{value:e}),this._hasOpened!==e&&(this._hasOpened=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=y(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=y(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const p=C({openClass:this._openClass});p.status||(this._errors.push(p.error.message),e=!1)}if(this._closeClass!==""){const p=C({closeClass:this._closeClass});p.status||(this._errors.push(p.error.message),e=!1)}if(this._transitionClass!==""){const p=C({transitionClass:this._transitionClass});p.status||(this._errors.push(p.error.message),e=!1)}const n=c("number",{transitionDuration:this._transitionDuration});n.status||(this._errors.push(n.error.message),e=!1);const r=c("number",{openDuration:this._openDuration});r.status||(this._errors.push(r.error.message),e=!1);const l=c("number",{closeDuration:this._closeDuration});l.status||(this._errors.push(l.error.message),e=!1);const h=c("boolean",{isTopLevel:this._root});if(h.status||(this._errors.push(h.error.message),e=!1),this._elements.parentMenu!==null){const p=y(k,{parentMenu:this._elements.parentMenu});p.status||(this._errors.push(p.error.message),e=!1)}const m=O({hoverType:this._hoverType});m.status||(this._errors.push(m.error.message),e=!1);const b=c("number",{hoverDelay:this._hoverDelay});b.status||(this._errors.push(b.error.message),e=!1);const f=c("number",{enterDelay:this._enterDelay});f.status||(this._errors.push(f.error.message),e=!1);const g=c("number",{leaveDelay:this._leaveDelay});g.status||(this._errors.push(g.error.message),e=!1);const _=c("string",{prefix:this._prefix});return _.status||(this._errors.push(_.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&y(HTMLElement,{base:t});const r=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=r:this._dom[e]=[...this._dom[e],...r]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),r=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,transitionDuration:this.transitionDuration,openDuration:this.openDuration,closeDuration:this.closeDuration,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:r,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:r,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_clearTimeout(){clearTimeout(this._hoverTimeout)}_setTimeout(e,t){c("function",{callback:e}),c("number",{delay:t}),this._hoverTimeout=setTimeout(e,t)}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})}),this.dom.menu.addEventListener("focusout",e=>{this.currentEvent!=="keyboard"||e.relatedTarget===null||this.dom.menu.contains(e.relatedTarget)||(this.focusState="none",this.closeChildren())})}_handleClick(){function e(t,s,n){d(n),n.button===0&&(s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none"))}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this._clearTimeout(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)}),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.elements.rootMenu.hasOpened=this.elements.submenuToggles.some(s=>s.isOpen)))})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t),e.isSubmenuItem&&(this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay)):e.elements.toggle.preview())):this.hoverType==="dynamic"&&(this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),(!this.isTopLevel||this.hasOpened)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),e.isSubmenuItem?this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay)):e.elements.toggle.preview():this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.closeChildren()},this.enterDelay)):this.closeChildren())))}),e.isSubmenuItem&&(e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse"},this.leaveDelay)):this.currentEvent="mouse"))}),e.dom.item.addEventListener("pointerenter",s=>{s.pointerType==="pen"||s.pointerType==="touch"||e.isSubmenuItem&&(this.hoverType==="on"||this.hoverType==="dynamic")&&this.leaveDelay>0&&this._clearTimeout()}))})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=A(e);(t==="Space"||t==="Enter")&&d(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=A(e);(t==="Space"||t==="Enter")&&(d(e),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}_setTransitionDurations(){this.dom.menu.style.setProperty(`--${this.prefix}transition-duration`,`${this.transitionDuration}ms`),this.dom.menu.style.setProperty(`--${this.prefix}open-transition-duration`,`${this.openDuration}ms`),this.dom.menu.style.setProperty(`--${this.prefix}close-transition-duration`,`${this.closeDuration}ms`)}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class q extends z{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:h=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l}),h&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","treeitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.dom.link.tabIndex=0}blur(){super.blur(),this.dom.link.tabIndex=-1}}class j extends F{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),r&&this.initialize()}initialize(){this._setIds(),this._setAriaAttributes(),this.dom.toggle.getAttribute("aria-expanded")==="true"?this.open():this._collapse(!1)}_setAriaAttributes(){this.dom.toggle.getAttribute("aria-expanded")!=="true"&&this.dom.toggle.setAttribute("aria-expanded","false"),this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-owns",this.elements.controlledMenu.dom.menu.id)}}class x extends k{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:r="li:has(ul)",submenuToggleSelector:l="a",submenuSelector:h="ul",controllerElement:m=null,containerElement:b=null,openClass:f="show",closeClass:g="hide",transitionClass:_="transitioning",transitionDuration:p=250,isTopLevel:M=!0,parentMenu:T=null,hoverType:E="off",hoverDelay:v=250,enterDelay:D=-1,leaveDelay:w=-1,prefix:I="am-",initialize:L=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:h,controllerElement:m,containerElement:b,openClass:f,closeClass:g,transitionClass:_,transitionDuration:p,isTopLevel:M,parentMenu:T,hoverType:E,hoverDelay:v,enterDelay:D,leaveDelay:w,prefix:I});o(this,"_MenuType",x);o(this,"_MenuItemType",q);o(this,"_MenuToggleType",j);L&&this.initialize()}initialize(){try{super.initialize(),this.isTopLevel?(this.dom.menu.setAttribute("role","tree"),this.elements.menuItems[0].dom.link.tabIndex=0):this.dom.menu.setAttribute("role","group"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup(),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.removeAttribute("aria-owns")}catch(t){console.error(t)}}_handleHover(){this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerenter",n=>{n.pointerType==="pen"||n.pointerType==="touch"||(this.hoverType==="on"?(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s),t.isSubmenuItem&&(this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{t.elements.toggle.preview()},this.enterDelay)):t.elements.toggle.preview())):this.hoverType==="dynamic"&&(this.currentChild=s,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),(!this.isTopLevel||this.hasOpened)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),t.isSubmenuItem?this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{t.elements.toggle.preview()},this.enterDelay)):t.elements.toggle.preview():this.enterDelay>0&&this._clearTimeout())))}),t.isSubmenuItem&&(t.dom.item.addEventListener("pointerleave",n=>{n.pointerType==="pen"||n.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0&&this._clearTimeout():this.hoverType==="dynamic"&&(this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.currentEvent="mouse"},this.leaveDelay)):this.currentEvent="mouse"))}),t.dom.item.addEventListener("pointerenter",n=>{n.pointerType==="pen"||n.pointerType==="touch"||t.isSubmenuItem&&(this.hoverType==="on"||this.hoverType==="dynamic")&&this.leaveDelay>0&&this._clearTimeout()})),this.isTopLevel&&this.dom.menu.addEventListener("pointerleave",n=>{n.pointerType==="pen"||n.pointerType==="touch"||this.hoverType==="on"&&(this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.closeChildren(),this.blur()},this.leaveDelay)):(this.closeChildren(),this.blur()))})})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=A(t);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?this.elements.rootMenu.blur():this.elements.rootMenu.focus()),this.focusState==="self"){const n=["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"],r=["Enter","ArrowRight"],l=["Escape"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&r.includes(s)||this.elements.controller&&l.includes(s))&&d(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=A(t),{altKey:n,crtlKey:r,metaKey:l}=t;if(s==="Character"&&!(n||r||l))d(t),this.elements.rootMenu.currentEvent="character",this.focusNextNodeWithCharacter(t.key);else if(this.focusState==="self")if(s==="Enter"||s==="Space")d(t),this.currentMenuItem.isSubmenuItem?this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview():this.currentMenuItem.dom.link.click();else if(s==="Escape")this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController());else if(s==="ArrowDown")d(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):!this.isTopLevel&&this.currentChild===this.elements.menuItems.length-1?this.focusParentsNextChild():this.focusNextChild();else if(s==="ArrowUp"){d(t);const m=this.elements.menuItems[this.currentChild-1];m&&m.isSubmenuItem&&m.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentChild=this.currentChild-1,this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.focusChildsLastNode()):!this.isTopLevel&&this.currentChild===0?(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild()):this.focusPreviousChild()}else s==="ArrowRight"?this.currentMenuItem.isSubmenuItem&&(d(t),this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):this.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?(d(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.toggle.close()):this.isTopLevel||(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild())):s==="Home"?(d(t),this.blurCurrentChild(),this.elements.rootMenu.focusFirstChild()):s==="End"?(d(t),this.blurCurrentChild(),this.elements.rootMenu.focusLastNode()):s==="Asterisk"&&(d(t),this.openChildren())})}focusLastNode(){const t=this.elements.menuItems.length-1,s=this.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.isOpen?(this.currentChild=t,s.elements.childMenu.currentEvent=this.currentEvent,s.elements.childMenu.focusLastNode()):this.focusLastChild()}openChildren(){this.elements.submenuToggles.forEach(t=>t.preview())}focusNextNodeWithCharacter(t){function s(f){let g=[];return f.elements.menuItems.forEach(_=>{g.push(_),_.isSubmenuItem&&_.elements.toggle.isOpen&&(g=[...g,...s(_.elements.toggle.elements.controlledMenu)])}),g}const n=t.toLowerCase(),r=s(this.elements.rootMenu),l=r.indexOf(this.currentMenuItem)+1,h=[...r.slice(l),...r.slice(0,l)];let m=0,b=!1;for(;!b&&m<h.length;){let f="";if(h[m].dom.item.innerText?f=h[m].dom.item.innerText:f=h[m].dom.item.textContent,f=f.replace(/[\s]/g,"").toLowerCase().charAt(0),f===n){b=!0;const g=h[m].elements.parentMenu,_=g.elements.menuItems.indexOf(h[m]);this.elements.rootMenu.blurChildren(),g.focusChild(_)}m++}}focusParentsNextChild(){this.elements.parentMenu&&(this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.currentChild===this.elements.parentMenu.elements.menuItems.length-1?(this.elements.parentMenu.blurCurrentChild(),this.elements.parentMenu.focusParentsNextChild()):(this.blurChildren(),this.elements.parentMenu.focusNextChild()))}focusChildsLastNode(){this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusLastChild(),this.currentMenuItem.elements.childMenu.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.childMenu.currentMenuItem.elements.toggle.isOpen&&(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.childMenu.focusChildsLastNode())}}class H extends q{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:h=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l,initialize:!1}),h&&this.initialize()}}class K extends j{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r,initialize:!1});o(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,l&&this.initialize()}initialize(){super.initialize(),this.elements.controlledMenu.bootstrapTransitions&&this.elements.controlledMenu.isTopLevel&&(this.dom.container.style.transition="height var(--am-transition-duration) ease")}_expand(t=!0){const{openClass:s,closeClass:n,transitionClass:r,openDuration:l,bootstrapTransitions:h,isTopLevel:m}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),this.elements.controlledMenu.elements.rootMenu.hasOpened=!0,r!==""?h?m?(a(r,this.dom.container),u(n,this.dom.container),this.dom.container.style.height=`${this.dom.container.scrollHeight}px`,requestAnimationFrame(()=>{setTimeout(()=>{a(s,this.dom.container),a(n,this.dom.container),u(r,this.dom.container),this.dom.container.style.height=""},l)})):(a(s,this.dom.container),u(n,this.dom.container)):(a(r,this.dom.container),requestAnimationFrame(()=>{u(n,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{setTimeout(()=>{u(r,this.dom.container)},l)})})})):(a(s,this.dom.container),u(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:r,closeDuration:l,bootstrapTransitions:h,isTopLevel:m}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),r!==""?h?m?(this.dom.container.style.height=`${this.dom.container.offsetHeight}px`,requestAnimationFrame(()=>{a(r,this.dom.container),requestAnimationFrame(()=>{u(n,this.dom.container),u(s,this.dom.container),this.dom.container.style.height="",requestAnimationFrame(()=>{setTimeout(()=>{u(r,this.dom.container),a(s,this.dom.container)},l)})})})):(a(s,this.dom.container),u(n,this.dom.container)):(a(r,this.dom.container),requestAnimationFrame(()=>{u(n,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{setTimeout(()=>{u(r,this.dom.container)},l)})})})):(a(s,this.dom.container),u(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class $ extends x{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:r=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:h=".dropdown-menu",controllerElement:m=null,containerElement:b=null,openClass:f="show",closeClass:g="collapse",transitionClass:_="collapsing",transitionDuration:p=350,openDuration:M=-1,closeDuration:T=-1,isTopLevel:E=!0,parentMenu:v=null,hoverType:D="off",hoverDelay:w=250,enterDelay:I=-1,leaveDelay:L=-1,prefix:N="am-",bootstrapTransitions:R=!0,disableBootstrap:U=!0,initialize:W=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:h,controllerElement:m,containerElement:b,openClass:f,closeClass:g,transitionClass:_,transitionDuration:p,openDuration:M,closeDuration:T,isTopLevel:E,parentMenu:v,hoverType:D,hoverDelay:w,enterDelay:I,leaveDelay:L,prefix:N,initialize:!1});o(this,"_MenuType",$);o(this,"_MenuItemType",H);o(this,"_MenuToggleType",K);o(this,"_disableBootstrap",!0);o(this,"_pseudoDropdownElement",document.createElement("div"));o(this,"_bootstrapDropdownEvents",["show.bs.dropdown","shown.bs.dropdown","hide.bs.dropdown","hidden.bs.dropdown"]);o(this,"_pseudoCollapseElement",document.createElement("div"));o(this,"_bootstrapCollapseEvents",["show.bs.collapse","shown.bs.collapse","hide.bs.collapse","hidden.bs.collapse"]);o(this,"_bootstrapTransitions",!0);this._disableBootstrap=U,this._bootstrapTransitions=R,W&&this.initialize()}initialize(){super.initialize(),this.bootstrapDisabled&&(this._disableBootstrapDropdownBehaviour(),this._disableBootstrapCollapseBehaviour())}get bootstrapTransitions(){return this.isTopLevel?this._bootstrapTransitions:this.elements.rootMenu.bootstrapTransitions}get bootstrapDisabled(){return this._disableBootstrap}get bootstrapPseudoDropdownElement(){return this._pseudoDropdownElement}get bootstrapDropdownEvents(){return this._bootstrapDropdownEvents}get bootstrapPseudoCollapseElement(){return this._pseudoCollapseElement}get bootstrapCollapseEvents(){return this._bootstrapCollapseEvents}_validate(){let t=super._validate();const s=c("boolean",{bootstrapTransitions:this._bootstrapTransitions});s.status||(this._errors.push(s.error.message),t=!1);const n=c("boolean",{disableBootstrap:this._disableBootstrap});return n.status||(this._errors.push(n.error.message),t=!1),t}_disableBootstrapDropdownBehaviour(){this.elements.submenuToggles.forEach(t=>{this.bootstrapDropdownEvents.forEach(s=>{t.dom.toggle.addEventListener(s,n=>{d(n);const r=bootstrap.Dropdown.getInstance(n.target);r&&r._menu!==this.bootstrapPseudoDropdownElement&&(r._menu=this.bootstrapPseudoDropdownElement)},{once:!0})})})}_disableBootstrapCollapseBehaviour(){this.elements.controller&&this.bootstrapCollapseEvents.forEach(t=>{this.dom.container.addEventListener(t,s=>{d(s);const n=bootstrap.Collapse.getInstance(s.target);n&&n._element!==this.bootstrapPseudoCollapseElement&&(n._element=this.bootstrapPseudoCollapseElement)},{once:!0})})}_setTransitionDurations(){super._setTransitionDurations(),this.isTopLevel&&this.elements.controller&&(this.elements.controller.dom.container.style.setProperty(`--${this.prefix}transition-duration`,`${this.transitionDuration}ms`),this.elements.controller.dom.container.style.setProperty(`--${this.prefix}open-transition-duration`,`${this.openDuration}ms`),this.elements.controller.dom.container.style.setProperty(`--${this.prefix}close-transition-duration`,`${this.closeDuration}ms`))}}return $}(); |
{ | ||
"name": "accessible-menu-bootstrap-5", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "A JavaScript library to help you generate WAI-ARIA accessible menus with in the DOM using Bootstrap 5.", | ||
@@ -78,3 +78,3 @@ "type": "module", | ||
"scripts": { | ||
"prepare": "husky install", | ||
"prepare": "husky || true", | ||
"commit": "git-cz", | ||
@@ -121,3 +121,3 @@ "lint": "npm run eslint -- --fix && npm run prettier -- --write", | ||
"dependencies": { | ||
"accessible-menu": "^4.0.1" | ||
"accessible-menu": "^4.2.0" | ||
}, | ||
@@ -130,15 +130,14 @@ "devDependencies": { | ||
"@commitlint/config-conventional": "^19.0.3", | ||
"@eslint/js": "^8.50.0", | ||
"@vitest/ui": "^1.2.2", | ||
"@eslint/js": "^9.1.1", | ||
"@vitest/ui": "^2.1.4", | ||
"commitizen": "^4.3.0", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"eslint": "^8.43.0", | ||
"eslint": "^9.14.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-config-standard": "^17.1.0", | ||
"eslint-plugin-jsdoc": "^48.1.0", | ||
"globals": "^14.0.0", | ||
"husky": "^9.0.11", | ||
"eslint-plugin-jsdoc": "^50.4.3", | ||
"globals": "^15.0.0", | ||
"husky": "^9.1.1", | ||
"jsdoc": "^4.0.2", | ||
"jsdoc-typeof-plugin": "^1.0.0", | ||
"jsdom": "^24.0.0", | ||
"jsdom": "^25.0.1", | ||
"lint-staged": "^15.2.0", | ||
@@ -148,6 +147,5 @@ "prettier": "^3.0.3", | ||
"vite": "^5.1.3", | ||
"vite-plugin-browser-sync": "^3.0.0", | ||
"vitest": "^1.2.2", | ||
"vitest": "^2.1.4", | ||
"vitest-axe": "^0.1.0" | ||
} | ||
} |
@@ -44,3 +44,3 @@ # accessible-menu-bootstrap-5 | ||
The following codepens are available as examples of how to use `accessible-menu`: | ||
The following codepens are available as examples of how to use `accessible-menu-bootstrap-5`: | ||
@@ -47,0 +47,0 @@ - [Disclosure Navigation Menu](https://codepen.io/nickdjm/pen/MWRaEoV) |
@@ -61,3 +61,3 @@ import DisclosureMenu from "accessible-menu/src/disclosureMenu.js"; | ||
/** | ||
* Bootstrap events that need to be intercepted to disbaled dropdowns. | ||
* Bootstrap events that need to be intercepted to disable dropdowns. | ||
* | ||
@@ -68,3 +68,3 @@ * @type {string[]} | ||
*/ | ||
_bootstrapEvents = [ | ||
_bootstrapDropdownEvents = [ | ||
"show.bs.dropdown", | ||
@@ -77,2 +77,38 @@ "shown.bs.dropdown", | ||
/** | ||
* The DOM element to use as a fake target for bootstrap's collapse events. | ||
* | ||
* @type {HTMLElement} | ||
* | ||
* @protected | ||
*/ | ||
_pseudoCollapseElement = document.createElement("div"); | ||
/** | ||
* Bootstrap events that need to be intercepted to disable collapses. | ||
* | ||
* @type {string[]} | ||
* | ||
* @protected | ||
*/ | ||
_bootstrapCollapseEvents = [ | ||
"show.bs.collapse", | ||
"shown.bs.collapse", | ||
"hide.bs.collapse", | ||
"hidden.bs.collapse", | ||
]; | ||
/** | ||
* A flag to emulate bootstrap's transitions for dropdowns and collapses. | ||
* | ||
* This will add an inline style for height to the submenu when it is transitioning | ||
* between "open" and "closed" states. This is to emulate the same behaviour as | ||
* Bootstrap's dropdowns and collapses. | ||
* | ||
* @type {boolean} | ||
* | ||
* @protected | ||
*/ | ||
_bootstrapTransitions = true; | ||
/** | ||
* Constructs the menu. | ||
@@ -91,10 +127,15 @@ * | ||
* @param {(string|string[]|null)} [options.closeClass = collapse] - The class to apply when a menu is "closed". | ||
* @param {?(string|string[])} [options.transitionClass = transitioning] - The class to apply when a menu is transitioning between "open" and "closed" states. | ||
* @param {?(string|string[])} [options.transitionClass = collapsing] - The class to apply when a menu is transitioning between "open" and "closed" states. | ||
* @param {number} [options.transitionDuration = 350] - The duration of the transition between "open" and "closed" states (in milliseconds). | ||
* @param {boolean} [options.openDuration = -1] - The duration of the transition from "closed" to "open" states (in milliseconds). | ||
* @param {boolean} [options.closeDuration = -1] - The duration of the transition from "open" to "closed" states (in milliseconds). | ||
* @param {boolean} [options.isTopLevel = false] - A flag to mark the root menu. | ||
* @param {(Bootstrap5DisclosureMenu|null)} [options.parentMenu = null] - The parent menu to this menu. | ||
* @param {string} [options.hoverType = off] - The type of hoverability a menu has. | ||
* @param {number} [options.hoverDelay = 250] - The delay for closing menus if the menu is hoverable (in miliseconds). | ||
* @param {number} [options.enterDelay = -1] - The delay for opening a menu if the menu is focusable (in miliseconds). | ||
* @param {number} [options.leaveDelay = -1] - The delay for closing a menu if the menu is focusable (in miliseconds). | ||
* @param {number} [options.hoverDelay = 250] - The delay for closing menus if the menu is hoverable (in milliseconds). | ||
* @param {number} [options.enterDelay = -1] - The delay for opening a menu if the menu is focusable (in milliseconds). | ||
* @param {number} [options.leaveDelay = -1] - The delay for closing a menu if the menu is focusable (in milliseconds). | ||
* @param {boolean} [options.optionalKeySupport = false] - A flag to add optional keyboard support (Arrow keys, Home, and End) to the menu. | ||
* @param {?string} [options.prefix = am-] - The prefix to use for CSS custom properties. | ||
* @param {boolean} [options.bootstrapTransitions = true] - A flag to emulate bootstrap's transitions for dropdowns and collapses. | ||
* @param {boolean} [options.disableBootstrap = true] - A flag to disable bootstrap's dropdown behaviour by making their events target a pseudo element. | ||
@@ -114,3 +155,6 @@ * @param {boolean} [options.initialize = true] - A flag to initialize the menu immediately upon creation. | ||
closeClass = "collapse", | ||
transitionClass = "transitioning", | ||
transitionClass = "collapsing", | ||
transitionDuration = 350, | ||
openDuration = -1, | ||
closeDuration = -1, | ||
isTopLevel = true, | ||
@@ -123,2 +167,4 @@ parentMenu = null, | ||
optionalKeySupport = false, | ||
prefix = "am-", | ||
bootstrapTransitions = true, | ||
disableBootstrap = true, | ||
@@ -139,2 +185,5 @@ initialize = true, | ||
transitionClass, | ||
transitionDuration, | ||
openDuration, | ||
closeDuration, | ||
isTopLevel, | ||
@@ -147,2 +196,3 @@ parentMenu, | ||
optionalKeySupport, | ||
prefix, | ||
initialize: false, | ||
@@ -153,2 +203,4 @@ }); | ||
this._bootstrapTransitions = bootstrapTransitions; | ||
if (initialize) { | ||
@@ -163,3 +215,4 @@ this.initialize(); | ||
* Initialize will call the {@link DisclosureMenu#initialize|DisclosureMenu's initialize method} | ||
* as well as the {@link Bootstrap5DisclosureMenu#_disableBootstrapDropdownBehaviour|disableBootstrapDropdown} event | ||
* as well as the {@link Bootstrap5DisclosureMenu#_disableBootstrapDropdownBehaviour|disableBootstrapDropdown} | ||
* and {@link Bootstrap5DisclosureMenu#_disableBootstrapCollapseBehaviour|disableBootstrapCollapseBehaviour} methods | ||
* for the menu. | ||
@@ -172,2 +225,3 @@ */ | ||
this._disableBootstrapDropdownBehaviour(); | ||
this._disableBootstrapCollapseBehaviour(); | ||
} | ||
@@ -177,2 +231,20 @@ } | ||
/** | ||
* A flag to emulate bootstrap's transitions for dropdowns and collapses. | ||
* | ||
* This functions differently for root vs. submenus. | ||
* Submenus will always inherit their root menu's bootstrap transition state. | ||
* | ||
* @readonly | ||
* | ||
* @type {boolean} | ||
* | ||
* @see _bootstrapTransitions | ||
*/ | ||
get bootstrapTransitions() { | ||
return this.isTopLevel | ||
? this._bootstrapTransitions | ||
: this.elements.rootMenu.bootstrapTransitions; | ||
} | ||
/** | ||
* A flag to disable bootstrap's dropdown behaviour. | ||
@@ -204,3 +276,3 @@ * | ||
/** | ||
* Bootstrap events that need to be intercepted to disbaled dropdowns. | ||
* Bootstrap events that need to be intercepted to disable dropdowns. | ||
* | ||
@@ -211,9 +283,35 @@ * @readonly | ||
* | ||
* @see _bootstrapEvents | ||
* @see _bootstrapDropdownEvents | ||
*/ | ||
get bootstrapEvents() { | ||
return this._bootstrapEvents; | ||
get bootstrapDropdownEvents() { | ||
return this._bootstrapDropdownEvents; | ||
} | ||
/** | ||
* The DOM element to use as a fake target for bootstrap's collapse events. | ||
* | ||
* @readonly | ||
* | ||
* @type {HTMLElement} | ||
* | ||
* @see _pseudoCollapseElement | ||
*/ | ||
get bootstrapPseudoCollapseElement() { | ||
return this._pseudoCollapseElement; | ||
} | ||
/** | ||
* Bootstrap events that need to be intercepted to disable collapses. | ||
* | ||
* @readonly | ||
* | ||
* @type {string[]} | ||
* | ||
* @see _bootstrapCollapseEvents | ||
*/ | ||
get bootstrapCollapseEvents() { | ||
return this._bootstrapCollapseEvents; | ||
} | ||
/** | ||
* Validates all aspects of the menu to ensure proper functionality. | ||
@@ -228,2 +326,12 @@ * | ||
// Bootstrap transitions check. | ||
const bootstrapTransitionsCheck = isValidType("boolean", { | ||
bootstrapTransitions: this._bootstrapTransitions, | ||
}); | ||
if (!bootstrapTransitionsCheck.status) { | ||
this._errors.push(bootstrapTransitionsCheck.error.message); | ||
check = false; | ||
} | ||
// Bootstrap disabled check. | ||
@@ -259,3 +367,3 @@ const bootstrapDisabledCheck = isValidType("boolean", { | ||
// Intercept each bootstrap dropdown event once. | ||
this.bootstrapEvents.forEach((eventType) => { | ||
this.bootstrapDropdownEvents.forEach((eventType) => { | ||
submenuToggle.dom.toggle.addEventListener( | ||
@@ -285,4 +393,80 @@ eventType, | ||
} | ||
/** | ||
* Disable bootstrap's collapse behaviour. | ||
* | ||
* This is done by intercepting the bootstrap collapse events (once) to get the | ||
* collapse instance and then setting the collapse instance's menu to an empty | ||
* element. | ||
* | ||
* We have to wait for the events because it's possible just selecting the | ||
* DOM elements will happen before Bootstrap initializes it's collapse behaviour. | ||
* | ||
* This is a pretty brute-force method, but it works. | ||
* | ||
* @protected | ||
*/ | ||
_disableBootstrapCollapseBehaviour() { | ||
if (!this.elements.controller) { | ||
return; | ||
} | ||
// Intercept each bootstrap collapse event once. | ||
this.bootstrapCollapseEvents.forEach((eventType) => { | ||
this.dom.container.addEventListener( | ||
eventType, | ||
(event) => { | ||
preventEvent(event); | ||
const collapseInstance = bootstrap.Collapse.getInstance(event.target); | ||
if (!collapseInstance) return; | ||
if ( | ||
collapseInstance._element !== this.bootstrapPseudoCollapseElement | ||
) { | ||
collapseInstance._element = this.bootstrapPseudoCollapseElement; | ||
} | ||
}, | ||
{ | ||
once: true, | ||
} | ||
); | ||
}); | ||
} | ||
/** | ||
* Sets the transition durations of the menu as a CSS custom properties. | ||
* | ||
* The custom properties are: | ||
* - `--am-transition-duration`, | ||
* - `--am-open-transition-duration`, and | ||
* - `--am-close-transition-duration`. | ||
* | ||
* The prefix of `am-` can be changed by setting the menu's prefix value. | ||
* | ||
* @protected | ||
*/ | ||
_setTransitionDurations() { | ||
super._setTransitionDurations(); | ||
if (this.isTopLevel && this.elements.controller) { | ||
this.elements.controller.dom.container.style.setProperty( | ||
`--${this.prefix}transition-duration`, | ||
`${this.transitionDuration}ms` | ||
); | ||
this.elements.controller.dom.container.style.setProperty( | ||
`--${this.prefix}open-transition-duration`, | ||
`${this.openDuration}ms` | ||
); | ||
this.elements.controller.dom.container.style.setProperty( | ||
`--${this.prefix}close-transition-duration`, | ||
`${this.closeDuration}ms` | ||
); | ||
} | ||
} | ||
} | ||
export default Bootstrap5DisclosureMenu; |
@@ -17,3 +17,3 @@ /* eslint-disable jsdoc/no-undefined-types */ | ||
* @property {HTMLElement} parent - The menu containing this toggle. | ||
* @property {HTMLElement} container - The element that controlls the visibility of the child menu. | ||
* @property {HTMLElement} container - The element that controls the visibility of the child menu. | ||
* @protected | ||
@@ -65,2 +65,14 @@ */ | ||
initialize() { | ||
super.initialize(); | ||
if ( | ||
this.elements.controlledMenu.bootstrapTransitions && | ||
this.elements.controlledMenu.isTopLevel | ||
) { | ||
this.dom.container.style.transition = | ||
"height var(--am-transition-duration) ease"; | ||
} | ||
} | ||
/** | ||
@@ -74,21 +86,71 @@ * Expands the controlled menu. | ||
_expand(emit = true) { | ||
const { openClass, transitionClass } = this.elements.controlledMenu; | ||
const { | ||
openClass, | ||
closeClass, | ||
transitionClass, | ||
openDuration, | ||
bootstrapTransitions, | ||
isTopLevel, | ||
} = this.elements.controlledMenu; | ||
this.dom.toggle.setAttribute("aria-expanded", "true"); | ||
this.elements.controlledMenu.elements.rootMenu.hasOpened = true; | ||
// If we're dealing with transition classes, then we need to utilize | ||
// requestAnimationFrame to add the transition class, add the open class, | ||
// and then remove the transition class. | ||
// requestAnimationFrame to add the transition class, remove the close class, | ||
// add the open class, and finally remove the transition class. | ||
// | ||
// Depending on if you're using bootstrap transitions or not, the process for | ||
// expanding the menu will differ. | ||
// | ||
// If the menu is emulating bootstrap dropdown/collapse behaviour, | ||
// we need to remove the inline style for the height of the menu | ||
// as well as the transition class. | ||
if (transitionClass !== "") { | ||
addClass(transitionClass, this.dom.container); | ||
if (bootstrapTransitions) { | ||
if (isTopLevel) { | ||
addClass(transitionClass, this.dom.container); | ||
removeClass(closeClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
addClass(openClass, this.dom.container); | ||
this.dom.container.style.height = `${this.dom.container.scrollHeight}px`; | ||
requestAnimationFrame(() => { | ||
setTimeout(() => { | ||
addClass(openClass, this.dom.container); | ||
addClass(closeClass, this.dom.container); | ||
removeClass(transitionClass, this.dom.container); | ||
this.dom.container.style.height = ""; | ||
}, openDuration); | ||
}); | ||
} else { | ||
// Add the open class | ||
addClass(openClass, this.dom.container); | ||
// Remove the close class. | ||
removeClass(closeClass, this.dom.container); | ||
} | ||
} else { | ||
addClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
removeClass(closeClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
addClass(openClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
setTimeout(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
}, openDuration); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} else if (openClass !== "") { | ||
} | ||
} else { | ||
// Add the open class | ||
addClass(openClass, this.dom.container); | ||
// Remove the close class. | ||
removeClass(closeClass, this.dom.container); | ||
} | ||
@@ -109,4 +171,10 @@ | ||
_collapse(emit = true) { | ||
const { closeClass, openClass, transitionClass } = | ||
this.elements.controlledMenu; | ||
const { | ||
closeClass, | ||
openClass, | ||
transitionClass, | ||
closeDuration, | ||
bootstrapTransitions, | ||
isTopLevel, | ||
} = this.elements.controlledMenu; | ||
@@ -118,30 +186,60 @@ this.dom.toggle.setAttribute("aria-expanded", "false"); | ||
// add the close class, and finally remove the transition class. | ||
// | ||
// Depending on if you're using bootstrap transitions or not, the process for | ||
// collapsing the menu will differ. | ||
// | ||
// If the menu is emulating bootstrap dropdown/collapse behaviour, | ||
// we need to add the inline style for the height of the menu | ||
// as well as the transition class. | ||
if (transitionClass !== "") { | ||
addClass(transitionClass, this.dom.container); | ||
if (bootstrapTransitions) { | ||
if (isTopLevel) { | ||
this.dom.container.style.height = `${this.dom.container.offsetHeight}px`; | ||
requestAnimationFrame(() => { | ||
if (openClass !== "") { | ||
requestAnimationFrame(() => { | ||
addClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
removeClass(openClass, this.dom.container); | ||
removeClass(closeClass, this.dom.container); | ||
this.dom.container.style.height = ""; | ||
requestAnimationFrame(() => { | ||
setTimeout(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
addClass(closeClass, this.dom.container); | ||
}, closeDuration); | ||
}); | ||
}); | ||
}); | ||
} else { | ||
// Add the close class | ||
addClass(closeClass, this.dom.container); | ||
// Remove the open class. | ||
removeClass(openClass, this.dom.container); | ||
} | ||
} else { | ||
addClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
if (closeClass !== "") { | ||
removeClass(openClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
addClass(closeClass, this.dom.container); | ||
} | ||
requestAnimationFrame(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
setTimeout(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
}, closeDuration); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
} else { | ||
// Add the close class | ||
if (closeClass !== "") { | ||
addClass(closeClass, this.dom.container); | ||
} | ||
addClass(closeClass, this.dom.container); | ||
// Remove the open class. | ||
if (openClass !== "") { | ||
removeClass(openClass, this.dom.container); | ||
} | ||
removeClass(openClass, this.dom.container); | ||
} | ||
@@ -148,0 +246,0 @@ |
@@ -59,3 +59,3 @@ import Menubar from "accessible-menu/src/menubar.js"; | ||
/** | ||
* Bootstrap events that need to be intercepted to disbaled dropdowns. | ||
* Bootstrap events that need to be intercepted to disable dropdowns. | ||
* | ||
@@ -66,3 +66,3 @@ * @type {string[]} | ||
*/ | ||
_bootstrapEvents = [ | ||
_bootstrapDropdownEvents = [ | ||
"show.bs.dropdown", | ||
@@ -75,2 +75,38 @@ "shown.bs.dropdown", | ||
/** | ||
* The DOM element to use as a fake target for bootstrap's collapse events. | ||
* | ||
* @type {HTMLElement} | ||
* | ||
* @protected | ||
*/ | ||
_pseudoCollapseElement = document.createElement("div"); | ||
/** | ||
* Bootstrap events that need to be intercepted to disable collapses. | ||
* | ||
* @type {string[]} | ||
* | ||
* @protected | ||
*/ | ||
_bootstrapCollapseEvents = [ | ||
"show.bs.collapse", | ||
"shown.bs.collapse", | ||
"hide.bs.collapse", | ||
"hidden.bs.collapse", | ||
]; | ||
/** | ||
* A flag to emulate bootstrap's transitions for dropdowns and collapses. | ||
* | ||
* This will add an inline style for height to the submenu when it is transitioning | ||
* between "open" and "closed" states. This is to emulate the same behaviour as | ||
* Bootstrap's dropdowns and collapses. | ||
* | ||
* @type {boolean} | ||
* | ||
* @protected | ||
*/ | ||
_bootstrapTransitions = true; | ||
/** | ||
* Constructs the menu. | ||
@@ -89,10 +125,15 @@ * | ||
* @param {(string|string[]|null)} [options.closeClass = collapse] - The class to apply when a menu is "closed". | ||
* @param {?(string|string[])} [options.transitionClass = transitioning] - The class to apply when a menu is transitioning between "open" and "closed" states. | ||
* @param {?(string|string[])} [options.transitionClass = collapsing] - The class to apply when a menu is transitioning between "open" and "closed" states. | ||
* @param {number} [options.transitionDuration = 350] - The duration of the transition between "open" and "closed" states (in milliseconds). | ||
* @param {boolean} [options.openDuration = -1] - The duration of the transition from "closed" to "open" states (in milliseconds). | ||
* @param {boolean} [options.closeDuration = -1] - The duration of the transition from "open" to "closed" states (in milliseconds). | ||
* @param {boolean} [options.isTopLevel = false] - A flag to mark the root menu. | ||
* @param {(Bootstrap5Menubar|null)} [options.parentMenu = null] - The parent menu to this menu. | ||
* @param {string} [options.hoverType = off] - The type of hoverability a menu has. | ||
* @param {number} [options.hoverDelay = 250] - The delay for closing menus if the menu is hoverable (in miliseconds). | ||
* @param {number} [options.enterDelay = -1] - The delay for opening a menu if the menu is focusable (in miliseconds). | ||
* @param {number} [options.leaveDelay = -1] - The delay for closing a menu if the menu is focusable (in miliseconds). | ||
* @param {boolean} [options.disableBootstrap = true] - A flag to disable bootstrap's dropdown behaviour by making their events target a pseudo element. | ||
* @param {number} [options.hoverDelay = 250] - The delay for closing menus if the menu is hoverable (in milliseconds). | ||
* @param {number} [options.enterDelay = -1] - The delay for opening a menu if the menu is focusable (in milliseconds). | ||
* @param {number} [options.leaveDelay = -1] - The delay for closing a menu if the menu is focusable (in milliseconds). | ||
* @param {?string} [options.prefix = am-] - The prefix to use for CSS custom properties. | ||
* @param {boolean} [options.bootstrapTransitions = true] - A flag to emulate bootstrap's transitions for dropdowns and collapses. | ||
* @param {boolean} [options.disableBootstrap = true] - A flag to disable bootstrap's dropdown behaviour by making their events target a pseudo element. | ||
* @param {boolean} [options.initialize = true] - A flag to initialize the menu immediately upon creation. | ||
@@ -111,3 +152,6 @@ */ | ||
closeClass = "collapse", | ||
transitionClass = "transitioning", | ||
transitionClass = "collapsing", | ||
transitionDuration = 350, | ||
openDuration = -1, | ||
closeDuration = -1, | ||
isTopLevel = true, | ||
@@ -119,2 +163,4 @@ parentMenu = null, | ||
leaveDelay = -1, | ||
prefix = "am-", | ||
bootstrapTransitions = true, | ||
disableBootstrap = true, | ||
@@ -135,2 +181,5 @@ initialize = true, | ||
transitionClass, | ||
transitionDuration, | ||
openDuration, | ||
closeDuration, | ||
isTopLevel, | ||
@@ -142,2 +191,3 @@ parentMenu, | ||
leaveDelay, | ||
prefix, | ||
initialize: false, | ||
@@ -148,2 +198,4 @@ }); | ||
this._bootstrapTransitions = bootstrapTransitions; | ||
if (initialize) { | ||
@@ -158,3 +210,4 @@ this.initialize(); | ||
* Initialize will call the {@link Menubar#initialize|Menubar's initialize method} | ||
* as well as the {@link Bootstrap5Menubar#_disableBootstrapDropdownBehaviour|disableBootstrapDropdown} event | ||
* as well as the {@link Bootstrap5Menubar#_disableBootstrapDropdownBehaviour|disableBootstrapDropdown} | ||
* and {@link Bootstrap5Menubar#_disableBootstrapCollapseBehaviour|disableBootstrapCollapseBehaviour} methods | ||
* for the menu. | ||
@@ -167,2 +220,3 @@ */ | ||
this._disableBootstrapDropdownBehaviour(); | ||
this._disableBootstrapCollapseBehaviour(); | ||
} | ||
@@ -172,2 +226,20 @@ } | ||
/** | ||
* A flag to emulate bootstrap's transitions for dropdowns and collapses. | ||
* | ||
* This functions differently for root vs. submenus. | ||
* Submenus will always inherit their root menu's bootstrap transition state. | ||
* | ||
* @readonly | ||
* | ||
* @type {boolean} | ||
* | ||
* @see _bootstrapTransitions | ||
*/ | ||
get bootstrapTransitions() { | ||
return this.isTopLevel | ||
? this._bootstrapTransitions | ||
: this.elements.rootMenu.bootstrapTransitions; | ||
} | ||
/** | ||
* A flag to disable bootstrap's dropdown behaviour. | ||
@@ -199,3 +271,3 @@ * | ||
/** | ||
* Bootstrap events that need to be intercepted to disbaled dropdowns. | ||
* Bootstrap events that need to be intercepted to disable dropdowns. | ||
* | ||
@@ -206,9 +278,35 @@ * @readonly | ||
* | ||
* @see _bootstrapEvents | ||
* @see _bootstrapDropdownEvents | ||
*/ | ||
get bootstrapEvents() { | ||
return this._bootstrapEvents; | ||
get bootstrapDropdownEvents() { | ||
return this._bootstrapDropdownEvents; | ||
} | ||
/** | ||
* The DOM element to use as a fake target for bootstrap's collapse events. | ||
* | ||
* @readonly | ||
* | ||
* @type {HTMLElement} | ||
* | ||
* @see _pseudoCollapseElement | ||
*/ | ||
get bootstrapPseudoCollapseElement() { | ||
return this._pseudoCollapseElement; | ||
} | ||
/** | ||
* Bootstrap events that need to be intercepted to disable collapses. | ||
* | ||
* @readonly | ||
* | ||
* @type {string[]} | ||
* | ||
* @see _bootstrapCollapseEvents | ||
*/ | ||
get bootstrapCollapseEvents() { | ||
return this._bootstrapCollapseEvents; | ||
} | ||
/** | ||
* Validates all aspects of the menu to ensure proper functionality. | ||
@@ -223,2 +321,12 @@ * | ||
// Bootstrap transitions check. | ||
const bootstrapTransitionsCheck = isValidType("boolean", { | ||
bootstrapTransitions: this._bootstrapTransitions, | ||
}); | ||
if (!bootstrapTransitionsCheck.status) { | ||
this._errors.push(bootstrapTransitionsCheck.error.message); | ||
check = false; | ||
} | ||
// Bootstrap disabled check. | ||
@@ -254,3 +362,3 @@ const bootstrapDisabledCheck = isValidType("boolean", { | ||
// Intercept each bootstrap dropdown event once. | ||
this.bootstrapEvents.forEach((eventType) => { | ||
this.bootstrapDropdownEvents.forEach((eventType) => { | ||
submenuToggle.dom.toggle.addEventListener( | ||
@@ -280,4 +388,80 @@ eventType, | ||
} | ||
/** | ||
* Disable bootstrap's collapse behaviour. | ||
* | ||
* This is done by intercepting the bootstrap collapse events (once) to get the | ||
* collapse instance and then setting the collapse instance's menu to an empty | ||
* element. | ||
* | ||
* We have to wait for the events because it's possible just selecting the | ||
* DOM elements will happen before Bootstrap initializes it's collapse behaviour. | ||
* | ||
* This is a pretty brute-force method, but it works. | ||
* | ||
* @protected | ||
*/ | ||
_disableBootstrapCollapseBehaviour() { | ||
if (!this.elements.controller) { | ||
return; | ||
} | ||
// Intercept each bootstrap collapse event once. | ||
this.bootstrapCollapseEvents.forEach((eventType) => { | ||
this.dom.container.addEventListener( | ||
eventType, | ||
(event) => { | ||
preventEvent(event); | ||
const collapseInstance = bootstrap.Collapse.getInstance(event.target); | ||
if (!collapseInstance) return; | ||
if ( | ||
collapseInstance._element !== this.bootstrapPseudoCollapseElement | ||
) { | ||
collapseInstance._element = this.bootstrapPseudoCollapseElement; | ||
} | ||
}, | ||
{ | ||
once: true, | ||
} | ||
); | ||
}); | ||
} | ||
/** | ||
* Sets the transition durations of the menu as a CSS custom properties. | ||
* | ||
* The custom properties are: | ||
* - `--am-transition-duration`, | ||
* - `--am-open-transition-duration`, and | ||
* - `--am-close-transition-duration`. | ||
* | ||
* The prefix of `am-` can be changed by setting the menu's prefix value. | ||
* | ||
* @protected | ||
*/ | ||
_setTransitionDurations() { | ||
super._setTransitionDurations(); | ||
if (this.isTopLevel && this.elements.controller) { | ||
this.elements.controller.dom.container.style.setProperty( | ||
`--${this.prefix}transition-duration`, | ||
`${this.transitionDuration}ms` | ||
); | ||
this.elements.controller.dom.container.style.setProperty( | ||
`--${this.prefix}open-transition-duration`, | ||
`${this.openDuration}ms` | ||
); | ||
this.elements.controller.dom.container.style.setProperty( | ||
`--${this.prefix}close-transition-duration`, | ||
`${this.closeDuration}ms` | ||
); | ||
} | ||
} | ||
} | ||
export default Bootstrap5Menubar; |
@@ -17,3 +17,3 @@ /* eslint-disable jsdoc/no-undefined-types */ | ||
* @property {HTMLElement} parent - The menu containing this toggle. | ||
* @property {HTMLElement} container - The element that controlls the visibility of the child menu. | ||
* @property {HTMLElement} container - The element that controls the visibility of the child menu. | ||
* @protected | ||
@@ -65,2 +65,14 @@ */ | ||
initialize() { | ||
super.initialize(); | ||
if ( | ||
this.elements.controlledMenu.bootstrapTransitions && | ||
this.elements.controlledMenu.isTopLevel | ||
) { | ||
this.dom.container.style.transition = | ||
"height var(--am-transition-duration) ease"; | ||
} | ||
} | ||
/** | ||
@@ -74,21 +86,71 @@ * Expands the controlled menu. | ||
_expand(emit = true) { | ||
const { openClass, transitionClass } = this.elements.controlledMenu; | ||
const { | ||
openClass, | ||
closeClass, | ||
transitionClass, | ||
openDuration, | ||
bootstrapTransitions, | ||
isTopLevel, | ||
} = this.elements.controlledMenu; | ||
this.dom.toggle.setAttribute("aria-expanded", "true"); | ||
this.elements.controlledMenu.elements.rootMenu.hasOpened = true; | ||
// If we're dealing with transition classes, then we need to utilize | ||
// requestAnimationFrame to add the transition class, add the open class, | ||
// and then remove the transition class. | ||
// requestAnimationFrame to add the transition class, remove the close class, | ||
// add the open class, and finally remove the transition class. | ||
// | ||
// Depending on if you're using bootstrap transitions or not, the process for | ||
// expanding the menu will differ. | ||
// | ||
// If the menu is emulating bootstrap dropdown/collapse behaviour, | ||
// we need to remove the inline style for the height of the menu | ||
// as well as the transition class. | ||
if (transitionClass !== "") { | ||
addClass(transitionClass, this.dom.container); | ||
if (bootstrapTransitions) { | ||
if (isTopLevel) { | ||
addClass(transitionClass, this.dom.container); | ||
removeClass(closeClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
addClass(openClass, this.dom.container); | ||
this.dom.container.style.height = `${this.dom.container.scrollHeight}px`; | ||
requestAnimationFrame(() => { | ||
setTimeout(() => { | ||
addClass(openClass, this.dom.container); | ||
addClass(closeClass, this.dom.container); | ||
removeClass(transitionClass, this.dom.container); | ||
this.dom.container.style.height = ""; | ||
}, openDuration); | ||
}); | ||
} else { | ||
// Add the open class | ||
addClass(openClass, this.dom.container); | ||
// Remove the close class. | ||
removeClass(closeClass, this.dom.container); | ||
} | ||
} else { | ||
addClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
removeClass(closeClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
addClass(openClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
setTimeout(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
}, openDuration); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} else if (openClass !== "") { | ||
} | ||
} else { | ||
// Add the open class | ||
addClass(openClass, this.dom.container); | ||
// Remove the close class. | ||
removeClass(closeClass, this.dom.container); | ||
} | ||
@@ -109,4 +171,10 @@ | ||
_collapse(emit = true) { | ||
const { closeClass, openClass, transitionClass } = | ||
this.elements.controlledMenu; | ||
const { | ||
closeClass, | ||
openClass, | ||
transitionClass, | ||
closeDuration, | ||
bootstrapTransitions, | ||
isTopLevel, | ||
} = this.elements.controlledMenu; | ||
@@ -118,30 +186,60 @@ this.dom.toggle.setAttribute("aria-expanded", "false"); | ||
// add the close class, and finally remove the transition class. | ||
// | ||
// Depending on if you're using bootstrap transitions or not, the process for | ||
// collapsing the menu will differ. | ||
// | ||
// If the menu is emulating bootstrap dropdown/collapse behaviour, | ||
// we need to add the inline style for the height of the menu | ||
// as well as the transition class. | ||
if (transitionClass !== "") { | ||
addClass(transitionClass, this.dom.container); | ||
if (bootstrapTransitions) { | ||
if (isTopLevel) { | ||
this.dom.container.style.height = `${this.dom.container.offsetHeight}px`; | ||
requestAnimationFrame(() => { | ||
if (openClass !== "") { | ||
requestAnimationFrame(() => { | ||
addClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
removeClass(openClass, this.dom.container); | ||
removeClass(closeClass, this.dom.container); | ||
this.dom.container.style.height = ""; | ||
requestAnimationFrame(() => { | ||
setTimeout(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
addClass(closeClass, this.dom.container); | ||
}, closeDuration); | ||
}); | ||
}); | ||
}); | ||
} else { | ||
// Add the close class | ||
addClass(closeClass, this.dom.container); | ||
// Remove the open class. | ||
removeClass(openClass, this.dom.container); | ||
} | ||
} else { | ||
addClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
if (closeClass !== "") { | ||
removeClass(openClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
addClass(closeClass, this.dom.container); | ||
} | ||
requestAnimationFrame(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
setTimeout(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
}, closeDuration); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
} else { | ||
// Add the close class | ||
if (closeClass !== "") { | ||
addClass(closeClass, this.dom.container); | ||
} | ||
addClass(closeClass, this.dom.container); | ||
// Remove the open class. | ||
if (openClass !== "") { | ||
removeClass(openClass, this.dom.container); | ||
} | ||
removeClass(openClass, this.dom.container); | ||
} | ||
@@ -148,0 +246,0 @@ |
@@ -61,3 +61,3 @@ import TopLinkDisclosureMenu from "accessible-menu/src/topLinkDisclosureMenu.js"; | ||
/** | ||
* Bootstrap events that need to be intercepted to disbaled dropdowns. | ||
* Bootstrap events that need to be intercepted to disable dropdowns. | ||
* | ||
@@ -68,3 +68,3 @@ * @type {string[]} | ||
*/ | ||
_bootstrapEvents = [ | ||
_bootstrapDropdownEvents = [ | ||
"show.bs.dropdown", | ||
@@ -77,2 +77,38 @@ "shown.bs.dropdown", | ||
/** | ||
* The DOM element to use as a fake target for bootstrap's collapse events. | ||
* | ||
* @type {HTMLElement} | ||
* | ||
* @protected | ||
*/ | ||
_pseudoCollapseElement = document.createElement("div"); | ||
/** | ||
* Bootstrap events that need to be intercepted to disable collapses. | ||
* | ||
* @type {string[]} | ||
* | ||
* @protected | ||
*/ | ||
_bootstrapCollapseEvents = [ | ||
"show.bs.collapse", | ||
"shown.bs.collapse", | ||
"hide.bs.collapse", | ||
"hidden.bs.collapse", | ||
]; | ||
/** | ||
* A flag to emulate bootstrap's transitions for dropdowns and collapses. | ||
* | ||
* This will add an inline style for height to the submenu when it is transitioning | ||
* between "open" and "closed" states. This is to emulate the same behaviour as | ||
* Bootstrap's dropdowns and collapses. | ||
* | ||
* @type {boolean} | ||
* | ||
* @protected | ||
*/ | ||
_bootstrapTransitions = true; | ||
/** | ||
* Constructs the menu. | ||
@@ -92,11 +128,16 @@ * | ||
* @param {(string|string[]|null)} [options.closeClass = collapse] - The class to apply when a menu is "closed". | ||
* @param {?(string|string[])} [options.transitionClass = transitioning] - The class to apply when a menu is transitioning between "open" and "closed" states. | ||
* @param {?(string|string[])} [options.transitionClass = collapsing] - The class to apply when a menu is transitioning between "open" and "closed" states. | ||
* @param {number} [options.transitionDuration = 350] - The duration of the transition between "open" and "closed" states (in milliseconds). | ||
* @param {boolean} [options.openDuration = -1] - The duration of the transition from "closed" to "open" states (in milliseconds). | ||
* @param {boolean} [options.closeDuration = -1] - The duration of the transition from "open" to "closed" states (in milliseconds). | ||
* @param {boolean} [options.isTopLevel = false] - A flag to mark the root menu. | ||
* @param {(Bootstrap5TopLinkDisclosureMenu|null)} [options.parentMenu = null] - The parent menu to this menu. | ||
* @param {string} [options.hoverType = off] - The type of hoverability a menu has. | ||
* @param {number} [options.hoverDelay = 250] - The delay for closing menus if the menu is hoverable (in miliseconds). | ||
* @param {number} [options.enterDelay = -1] - The delay for opening a menu if the menu is focusable (in miliseconds). | ||
* @param {number} [options.leaveDelay = -1] - The delay for closing a menu if the menu is focusable (in miliseconds). | ||
* @param {number} [options.hoverDelay = 250] - The delay for closing menus if the menu is hoverable (in milliseconds). | ||
* @param {number} [options.enterDelay = -1] - The delay for opening a menu if the menu is focusable (in milliseconds). | ||
* @param {number} [options.leaveDelay = -1] - The delay for closing a menu if the menu is focusable (in milliseconds). | ||
* @param {boolean} [options.optionalKeySupport = false] - A flag to add optional keyboard support (Arrow keys, Home, and End) to the menu. | ||
* @param {boolean} [options.disableBootstrap = true] - A flag to disable bootstrap's dropdown behaviour by making their events target a pseudo element. | ||
* @param {?string} [options.prefix = am-] - The prefix to use for CSS custom properties. | ||
* @param {boolean} [options.disableBootstrap = true] - A flag to disable bootstrap's dropdown behaviour by making their events target a pseudo element. | ||
* @param {boolean} [options.bootstrapTransitions = true] - A flag to emulate bootstrap's transitions for dropdowns and collapses. | ||
* @param {boolean} [options.initialize = true] - A flag to initialize the menu immediately upon creation. | ||
@@ -116,3 +157,6 @@ */ | ||
closeClass = "collapse", | ||
transitionClass = "transitioning", | ||
transitionClass = "collapsing", | ||
transitionDuration = 350, | ||
openDuration = -1, | ||
closeDuration = -1, | ||
isTopLevel = true, | ||
@@ -125,2 +169,4 @@ parentMenu = null, | ||
optionalKeySupport = false, | ||
prefix = "am-", | ||
bootstrapTransitions = true, | ||
disableBootstrap = true, | ||
@@ -142,2 +188,5 @@ initialize = true, | ||
transitionClass, | ||
transitionDuration, | ||
openDuration, | ||
closeDuration, | ||
isTopLevel, | ||
@@ -150,2 +199,3 @@ parentMenu, | ||
optionalKeySupport, | ||
prefix, | ||
initialize: false, | ||
@@ -156,2 +206,4 @@ }); | ||
this._bootstrapTransitions = bootstrapTransitions; | ||
if (initialize) { | ||
@@ -166,3 +218,4 @@ this.initialize(); | ||
* Initialize will call the {@link TopLinkDisclosureMenu#initialize|TopLinkDisclosureMenu's initialize method} | ||
* as well as the {@link Bootstrap5TopLinkDisclosureMenu#_disableBootstrapDropdownBehaviour|disableBootstrapDropdown} event | ||
* as well as the {@link Bootstrap5TopLinkDisclosureMenu#_disableBootstrapDropdownBehaviour|disableBootstrapDropdown} | ||
* and {@link Bootstrap5TopLinkDisclosureMenu#_disableBootstrapCollapseBehaviour|disableBootstrapCollapseBehaviour} methods | ||
* for the menu. | ||
@@ -175,2 +228,3 @@ */ | ||
this._disableBootstrapDropdownBehaviour(); | ||
this._disableBootstrapCollapseBehaviour(); | ||
} | ||
@@ -180,2 +234,20 @@ } | ||
/** | ||
* A flag to emulate bootstrap's transitions for dropdowns and collapses. | ||
* | ||
* This functions differently for root vs. submenus. | ||
* Submenus will always inherit their root menu's bootstrap transition state. | ||
* | ||
* @readonly | ||
* | ||
* @type {boolean} | ||
* | ||
* @see _bootstrapTransitions | ||
*/ | ||
get bootstrapTransitions() { | ||
return this.isTopLevel | ||
? this._bootstrapTransitions | ||
: this.elements.rootMenu.bootstrapTransitions; | ||
} | ||
/** | ||
* A flag to disable bootstrap's dropdown behaviour. | ||
@@ -207,3 +279,3 @@ * | ||
/** | ||
* Bootstrap events that need to be intercepted to disbaled dropdowns. | ||
* Bootstrap events that need to be intercepted to disable dropdowns. | ||
* | ||
@@ -214,9 +286,35 @@ * @readonly | ||
* | ||
* @see _bootstrapEvents | ||
* @see _bootstrapDropdownEvents | ||
*/ | ||
get bootstrapEvents() { | ||
return this._bootstrapEvents; | ||
get bootstrapDropdownEvents() { | ||
return this._bootstrapDropdownEvents; | ||
} | ||
/** | ||
* The DOM element to use as a fake target for bootstrap's collapse events. | ||
* | ||
* @readonly | ||
* | ||
* @type {HTMLElement} | ||
* | ||
* @see _pseudoCollapseElement | ||
*/ | ||
get bootstrapPseudoCollapseElement() { | ||
return this._pseudoCollapseElement; | ||
} | ||
/** | ||
* Bootstrap events that need to be intercepted to disable collapses. | ||
* | ||
* @readonly | ||
* | ||
* @type {string[]} | ||
* | ||
* @see _bootstrapCollapseEvents | ||
*/ | ||
get bootstrapCollapseEvents() { | ||
return this._bootstrapCollapseEvents; | ||
} | ||
/** | ||
* Validates all aspects of the menu to ensure proper functionality. | ||
@@ -231,2 +329,12 @@ * | ||
// Bootstrap transitions check. | ||
const bootstrapTransitionsCheck = isValidType("boolean", { | ||
bootstrapTransitions: this._bootstrapTransitions, | ||
}); | ||
if (!bootstrapTransitionsCheck.status) { | ||
this._errors.push(bootstrapTransitionsCheck.error.message); | ||
check = false; | ||
} | ||
// Bootstrap disabled check. | ||
@@ -262,3 +370,3 @@ const bootstrapDisabledCheck = isValidType("boolean", { | ||
// Intercept each bootstrap dropdown event once. | ||
this.bootstrapEvents.forEach((eventType) => { | ||
this.bootstrapDropdownEvents.forEach((eventType) => { | ||
submenuToggle.dom.toggle.addEventListener( | ||
@@ -288,4 +396,80 @@ eventType, | ||
} | ||
/** | ||
* Disable bootstrap's collapse behaviour. | ||
* | ||
* This is done by intercepting the bootstrap collapse events (once) to get the | ||
* collapse instance and then setting the collapse instance's menu to an empty | ||
* element. | ||
* | ||
* We have to wait for the events because it's possible just selecting the | ||
* DOM elements will happen before Bootstrap initializes it's collapse behaviour. | ||
* | ||
* This is a pretty brute-force method, but it works. | ||
* | ||
* @protected | ||
*/ | ||
_disableBootstrapCollapseBehaviour() { | ||
if (!this.elements.controller) { | ||
return; | ||
} | ||
// Intercept each bootstrap collapse event once. | ||
this.bootstrapCollapseEvents.forEach((eventType) => { | ||
this.dom.container.addEventListener( | ||
eventType, | ||
(event) => { | ||
preventEvent(event); | ||
const collapseInstance = bootstrap.Collapse.getInstance(event.target); | ||
if (!collapseInstance) return; | ||
if ( | ||
collapseInstance._element !== this.bootstrapPseudoCollapseElement | ||
) { | ||
collapseInstance._element = this.bootstrapPseudoCollapseElement; | ||
} | ||
}, | ||
{ | ||
once: true, | ||
} | ||
); | ||
}); | ||
} | ||
/** | ||
* Sets the transition durations of the menu as a CSS custom properties. | ||
* | ||
* The custom properties are: | ||
* - `--am-transition-duration`, | ||
* - `--am-open-transition-duration`, and | ||
* - `--am-close-transition-duration`. | ||
* | ||
* The prefix of `am-` can be changed by setting the menu's prefix value. | ||
* | ||
* @protected | ||
*/ | ||
_setTransitionDurations() { | ||
super._setTransitionDurations(); | ||
if (this.isTopLevel && this.elements.controller) { | ||
this.elements.controller.dom.container.style.setProperty( | ||
`--${this.prefix}transition-duration`, | ||
`${this.transitionDuration}ms` | ||
); | ||
this.elements.controller.dom.container.style.setProperty( | ||
`--${this.prefix}open-transition-duration`, | ||
`${this.openDuration}ms` | ||
); | ||
this.elements.controller.dom.container.style.setProperty( | ||
`--${this.prefix}close-transition-duration`, | ||
`${this.closeDuration}ms` | ||
); | ||
} | ||
} | ||
} | ||
export default Bootstrap5TopLinkDisclosureMenu; |
@@ -17,3 +17,3 @@ /* eslint-disable jsdoc/no-undefined-types */ | ||
* @property {HTMLElement} parent - The menu containing this toggle. | ||
* @property {HTMLElement} container - The element that controlls the visibility of the child menu. | ||
* @property {HTMLElement} container - The element that controls the visibility of the child menu. | ||
* @protected | ||
@@ -65,2 +65,14 @@ */ | ||
initialize() { | ||
super.initialize(); | ||
if ( | ||
this.elements.controlledMenu.bootstrapTransitions && | ||
this.elements.controlledMenu.isTopLevel | ||
) { | ||
this.dom.container.style.transition = | ||
"height var(--am-transition-duration) ease"; | ||
} | ||
} | ||
/** | ||
@@ -74,21 +86,71 @@ * Expands the controlled menu. | ||
_expand(emit = true) { | ||
const { openClass, transitionClass } = this.elements.controlledMenu; | ||
const { | ||
openClass, | ||
closeClass, | ||
transitionClass, | ||
openDuration, | ||
bootstrapTransitions, | ||
isTopLevel, | ||
} = this.elements.controlledMenu; | ||
this.dom.toggle.setAttribute("aria-expanded", "true"); | ||
this.elements.controlledMenu.elements.rootMenu.hasOpened = true; | ||
// If we're dealing with transition classes, then we need to utilize | ||
// requestAnimationFrame to add the transition class, add the open class, | ||
// and then remove the transition class. | ||
// requestAnimationFrame to add the transition class, remove the close class, | ||
// add the open class, and finally remove the transition class. | ||
// | ||
// Depending on if you're using bootstrap transitions or not, the process for | ||
// expanding the menu will differ. | ||
// | ||
// If the menu is emulating bootstrap dropdown/collapse behaviour, | ||
// we need to remove the inline style for the height of the menu | ||
// as well as the transition class. | ||
if (transitionClass !== "") { | ||
addClass(transitionClass, this.dom.container); | ||
if (bootstrapTransitions) { | ||
if (isTopLevel) { | ||
addClass(transitionClass, this.dom.container); | ||
removeClass(closeClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
addClass(openClass, this.dom.container); | ||
this.dom.container.style.height = `${this.dom.container.scrollHeight}px`; | ||
requestAnimationFrame(() => { | ||
setTimeout(() => { | ||
addClass(openClass, this.dom.container); | ||
addClass(closeClass, this.dom.container); | ||
removeClass(transitionClass, this.dom.container); | ||
this.dom.container.style.height = ""; | ||
}, openDuration); | ||
}); | ||
} else { | ||
// Add the open class | ||
addClass(openClass, this.dom.container); | ||
// Remove the close class. | ||
removeClass(closeClass, this.dom.container); | ||
} | ||
} else { | ||
addClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
removeClass(closeClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
addClass(openClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
setTimeout(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
}, openDuration); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} else if (openClass !== "") { | ||
} | ||
} else { | ||
// Add the open class | ||
addClass(openClass, this.dom.container); | ||
// Remove the close class. | ||
removeClass(closeClass, this.dom.container); | ||
} | ||
@@ -109,4 +171,10 @@ | ||
_collapse(emit = true) { | ||
const { closeClass, openClass, transitionClass } = | ||
this.elements.controlledMenu; | ||
const { | ||
closeClass, | ||
openClass, | ||
transitionClass, | ||
closeDuration, | ||
bootstrapTransitions, | ||
isTopLevel, | ||
} = this.elements.controlledMenu; | ||
@@ -118,30 +186,60 @@ this.dom.toggle.setAttribute("aria-expanded", "false"); | ||
// add the close class, and finally remove the transition class. | ||
// | ||
// Depending on if you're using bootstrap transitions or not, the process for | ||
// collapsing the menu will differ. | ||
// | ||
// If the menu is emulating bootstrap dropdown/collapse behaviour, | ||
// we need to add the inline style for the height of the menu | ||
// as well as the transition class. | ||
if (transitionClass !== "") { | ||
addClass(transitionClass, this.dom.container); | ||
if (bootstrapTransitions) { | ||
if (isTopLevel) { | ||
this.dom.container.style.height = `${this.dom.container.offsetHeight}px`; | ||
requestAnimationFrame(() => { | ||
if (openClass !== "") { | ||
requestAnimationFrame(() => { | ||
addClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
removeClass(openClass, this.dom.container); | ||
removeClass(closeClass, this.dom.container); | ||
this.dom.container.style.height = ""; | ||
requestAnimationFrame(() => { | ||
setTimeout(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
addClass(closeClass, this.dom.container); | ||
}, closeDuration); | ||
}); | ||
}); | ||
}); | ||
} else { | ||
// Add the close class | ||
addClass(closeClass, this.dom.container); | ||
// Remove the open class. | ||
removeClass(openClass, this.dom.container); | ||
} | ||
} else { | ||
addClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
if (closeClass !== "") { | ||
removeClass(openClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
addClass(closeClass, this.dom.container); | ||
} | ||
requestAnimationFrame(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
setTimeout(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
}, closeDuration); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
} else { | ||
// Add the close class | ||
if (closeClass !== "") { | ||
addClass(closeClass, this.dom.container); | ||
} | ||
addClass(closeClass, this.dom.container); | ||
// Remove the open class. | ||
if (openClass !== "") { | ||
removeClass(openClass, this.dom.container); | ||
} | ||
removeClass(openClass, this.dom.container); | ||
} | ||
@@ -148,0 +246,0 @@ |
@@ -59,3 +59,3 @@ import Treeview from "accessible-menu/src/treeview.js"; | ||
/** | ||
* Bootstrap events that need to be intercepted to disbaled dropdowns. | ||
* Bootstrap events that need to be intercepted to disable dropdowns. | ||
* | ||
@@ -66,3 +66,3 @@ * @type {string[]} | ||
*/ | ||
_bootstrapEvents = [ | ||
_bootstrapDropdownEvents = [ | ||
"show.bs.dropdown", | ||
@@ -75,2 +75,38 @@ "shown.bs.dropdown", | ||
/** | ||
* The DOM element to use as a fake target for bootstrap's collapse events. | ||
* | ||
* @type {HTMLElement} | ||
* | ||
* @protected | ||
*/ | ||
_pseudoCollapseElement = document.createElement("div"); | ||
/** | ||
* Bootstrap events that need to be intercepted to disable collapses. | ||
* | ||
* @type {string[]} | ||
* | ||
* @protected | ||
*/ | ||
_bootstrapCollapseEvents = [ | ||
"show.bs.collapse", | ||
"shown.bs.collapse", | ||
"hide.bs.collapse", | ||
"hidden.bs.collapse", | ||
]; | ||
/** | ||
* A flag to emulate bootstrap's transitions for dropdowns and collapses. | ||
* | ||
* This will add an inline style for height to the submenu when it is transitioning | ||
* between "open" and "closed" states. This is to emulate the same behaviour as | ||
* Bootstrap's dropdowns and collapses. | ||
* | ||
* @type {boolean} | ||
* | ||
* @protected | ||
*/ | ||
_bootstrapTransitions = true; | ||
/** | ||
* Constructs the menu. | ||
@@ -89,10 +125,15 @@ * | ||
* @param {(string|string[]|null)} [options.closeClass = collapse] - The class to apply when a menu is "closed". | ||
* @param {?(string|string[])} [options.transitionClass = transitioning] - The class to apply when a menu is transitioning between "open" and "closed" states. | ||
* @param {?(string|string[])} [options.transitionClass = collapsing] - The class to apply when a menu is transitioning between "open" and "closed" states. | ||
* @param {number} [options.transitionDuration = 350] - The duration of the transition between "open" and "closed" states (in milliseconds). | ||
* @param {boolean} [options.openDuration = -1] - The duration of the transition from "closed" to "open" states (in milliseconds). | ||
* @param {boolean} [options.closeDuration = -1] - The duration of the transition from "open" to "closed" states (in milliseconds). | ||
* @param {boolean} [options.isTopLevel = false] - A flag to mark the root menu. | ||
* @param {(Bootstrap5Treeview|null)} [options.parentMenu = null] - The parent menu to this menu. | ||
* @param {string} [options.hoverType = off] - The type of hoverability a menu has. | ||
* @param {number} [options.hoverDelay = 250] - The delay for closing menus if the menu is hoverable (in miliseconds). | ||
* @param {number} [options.enterDelay = -1] - The delay for opening a menu if the menu is focusable (in miliseconds). | ||
* @param {number} [options.leaveDelay = -1] - The delay for closing a menu if the menu is focusable (in miliseconds). | ||
* @param {boolean} [options.disableBootstrap = true] - A flag to disable bootstrap's dropdown behaviour by making their events target a pseudo element. | ||
* @param {number} [options.hoverDelay = 250] - The delay for closing menus if the menu is hoverable (in milliseconds). | ||
* @param {number} [options.enterDelay = -1] - The delay for opening a menu if the menu is focusable (in milliseconds). | ||
* @param {number} [options.leaveDelay = -1] - The delay for closing a menu if the menu is focusable (in milliseconds). | ||
* @param {?string} [options.prefix = am-] - The prefix to use for CSS custom properties. | ||
* @param {boolean} [options.bootstrapTransitions = true] - A flag to emulate bootstrap's transitions for dropdowns and collapses. | ||
* @param {boolean} [options.disableBootstrap = true] - A flag to disable bootstrap's dropdown behaviour by making their events target a pseudo element. | ||
* @param {boolean} [options.initialize = true] - A flag to initialize the menu immediately upon creation. | ||
@@ -111,3 +152,6 @@ */ | ||
closeClass = "collapse", | ||
transitionClass = "transitioning", | ||
transitionClass = "collapsing", | ||
transitionDuration = 350, | ||
openDuration = -1, | ||
closeDuration = -1, | ||
isTopLevel = true, | ||
@@ -119,2 +163,4 @@ parentMenu = null, | ||
leaveDelay = -1, | ||
prefix = "am-", | ||
bootstrapTransitions = true, | ||
disableBootstrap = true, | ||
@@ -135,2 +181,5 @@ initialize = true, | ||
transitionClass, | ||
transitionDuration, | ||
openDuration, | ||
closeDuration, | ||
isTopLevel, | ||
@@ -142,2 +191,3 @@ parentMenu, | ||
leaveDelay, | ||
prefix, | ||
initialize: false, | ||
@@ -148,2 +198,4 @@ }); | ||
this._bootstrapTransitions = bootstrapTransitions; | ||
if (initialize) { | ||
@@ -166,2 +218,3 @@ this.initialize(); | ||
this._disableBootstrapDropdownBehaviour(); | ||
this._disableBootstrapCollapseBehaviour(); | ||
} | ||
@@ -171,2 +224,20 @@ } | ||
/** | ||
* A flag to emulate bootstrap's transitions for dropdowns and collapses. | ||
* | ||
* This functions differently for root vs. submenus. | ||
* Submenus will always inherit their root menu's bootstrap transition state. | ||
* | ||
* @readonly | ||
* | ||
* @type {boolean} | ||
* | ||
* @see _bootstrapTransitions | ||
*/ | ||
get bootstrapTransitions() { | ||
return this.isTopLevel | ||
? this._bootstrapTransitions | ||
: this.elements.rootMenu.bootstrapTransitions; | ||
} | ||
/** | ||
* A flag to disable bootstrap's dropdown behaviour. | ||
@@ -198,3 +269,3 @@ * | ||
/** | ||
* Bootstrap events that need to be intercepted to disbaled dropdowns. | ||
* Bootstrap events that need to be intercepted to disable dropdowns. | ||
* | ||
@@ -205,9 +276,35 @@ * @readonly | ||
* | ||
* @see _bootstrapEvents | ||
* @see _bootstrapDropdownEvents | ||
*/ | ||
get bootstrapEvents() { | ||
return this._bootstrapEvents; | ||
get bootstrapDropdownEvents() { | ||
return this._bootstrapDropdownEvents; | ||
} | ||
/** | ||
* The DOM element to use as a fake target for bootstrap's collapse events. | ||
* | ||
* @readonly | ||
* | ||
* @type {HTMLElement} | ||
* | ||
* @see _pseudoCollapseElement | ||
*/ | ||
get bootstrapPseudoCollapseElement() { | ||
return this._pseudoCollapseElement; | ||
} | ||
/** | ||
* Bootstrap events that need to be intercepted to disable collapses. | ||
* | ||
* @readonly | ||
* | ||
* @type {string[]} | ||
* | ||
* @see _bootstrapCollapseEvents | ||
*/ | ||
get bootstrapCollapseEvents() { | ||
return this._bootstrapCollapseEvents; | ||
} | ||
/** | ||
* Validates all aspects of the menu to ensure proper functionality. | ||
@@ -222,2 +319,12 @@ * | ||
// Bootstrap transitions check. | ||
const bootstrapTransitionsCheck = isValidType("boolean", { | ||
bootstrapTransitions: this._bootstrapTransitions, | ||
}); | ||
if (!bootstrapTransitionsCheck.status) { | ||
this._errors.push(bootstrapTransitionsCheck.error.message); | ||
check = false; | ||
} | ||
// Bootstrap disabled check. | ||
@@ -253,3 +360,3 @@ const bootstrapDisabledCheck = isValidType("boolean", { | ||
// Intercept each bootstrap dropdown event once. | ||
this.bootstrapEvents.forEach((eventType) => { | ||
this.bootstrapDropdownEvents.forEach((eventType) => { | ||
submenuToggle.dom.toggle.addEventListener( | ||
@@ -279,4 +386,80 @@ eventType, | ||
} | ||
/** | ||
* Disable bootstrap's collapse behaviour. | ||
* | ||
* This is done by intercepting the bootstrap collapse events (once) to get the | ||
* collapse instance and then setting the collapse instance's menu to an empty | ||
* element. | ||
* | ||
* We have to wait for the events because it's possible just selecting the | ||
* DOM elements will happen before Bootstrap initializes it's collapse behaviour. | ||
* | ||
* This is a pretty brute-force method, but it works. | ||
* | ||
* @protected | ||
*/ | ||
_disableBootstrapCollapseBehaviour() { | ||
if (!this.elements.controller) { | ||
return; | ||
} | ||
// Intercept each bootstrap collapse event once. | ||
this.bootstrapCollapseEvents.forEach((eventType) => { | ||
this.dom.container.addEventListener( | ||
eventType, | ||
(event) => { | ||
preventEvent(event); | ||
const collapseInstance = bootstrap.Collapse.getInstance(event.target); | ||
if (!collapseInstance) return; | ||
if ( | ||
collapseInstance._element !== this.bootstrapPseudoCollapseElement | ||
) { | ||
collapseInstance._element = this.bootstrapPseudoCollapseElement; | ||
} | ||
}, | ||
{ | ||
once: true, | ||
} | ||
); | ||
}); | ||
} | ||
/** | ||
* Sets the transition durations of the menu as a CSS custom properties. | ||
* | ||
* The custom properties are: | ||
* - `--am-transition-duration`, | ||
* - `--am-open-transition-duration`, and | ||
* - `--am-close-transition-duration`. | ||
* | ||
* The prefix of `am-` can be changed by setting the menu's prefix value. | ||
* | ||
* @protected | ||
*/ | ||
_setTransitionDurations() { | ||
super._setTransitionDurations(); | ||
if (this.isTopLevel && this.elements.controller) { | ||
this.elements.controller.dom.container.style.setProperty( | ||
`--${this.prefix}transition-duration`, | ||
`${this.transitionDuration}ms` | ||
); | ||
this.elements.controller.dom.container.style.setProperty( | ||
`--${this.prefix}open-transition-duration`, | ||
`${this.openDuration}ms` | ||
); | ||
this.elements.controller.dom.container.style.setProperty( | ||
`--${this.prefix}close-transition-duration`, | ||
`${this.closeDuration}ms` | ||
); | ||
} | ||
} | ||
} | ||
export default Bootstrap5Treeview; |
@@ -17,3 +17,3 @@ /* eslint-disable jsdoc/no-undefined-types */ | ||
* @property {HTMLElement} parent - The menu containing this toggle. | ||
* @property {HTMLElement} container - The element that controlls the visibility of the child menu. | ||
* @property {HTMLElement} container - The element that controls the visibility of the child menu. | ||
* @protected | ||
@@ -65,2 +65,14 @@ */ | ||
initialize() { | ||
super.initialize(); | ||
if ( | ||
this.elements.controlledMenu.bootstrapTransitions && | ||
this.elements.controlledMenu.isTopLevel | ||
) { | ||
this.dom.container.style.transition = | ||
"height var(--am-transition-duration) ease"; | ||
} | ||
} | ||
/** | ||
@@ -74,21 +86,71 @@ * Expands the controlled menu. | ||
_expand(emit = true) { | ||
const { openClass, transitionClass } = this.elements.controlledMenu; | ||
const { | ||
openClass, | ||
closeClass, | ||
transitionClass, | ||
openDuration, | ||
bootstrapTransitions, | ||
isTopLevel, | ||
} = this.elements.controlledMenu; | ||
this.dom.toggle.setAttribute("aria-expanded", "true"); | ||
this.elements.controlledMenu.elements.rootMenu.hasOpened = true; | ||
// If we're dealing with transition classes, then we need to utilize | ||
// requestAnimationFrame to add the transition class, add the open class, | ||
// and then remove the transition class. | ||
// requestAnimationFrame to add the transition class, remove the close class, | ||
// add the open class, and finally remove the transition class. | ||
// | ||
// Depending on if you're using bootstrap transitions or not, the process for | ||
// expanding the menu will differ. | ||
// | ||
// If the menu is emulating bootstrap dropdown/collapse behaviour, | ||
// we need to remove the inline style for the height of the menu | ||
// as well as the transition class. | ||
if (transitionClass !== "") { | ||
addClass(transitionClass, this.dom.container); | ||
if (bootstrapTransitions) { | ||
if (isTopLevel) { | ||
addClass(transitionClass, this.dom.container); | ||
removeClass(closeClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
addClass(openClass, this.dom.container); | ||
this.dom.container.style.height = `${this.dom.container.scrollHeight}px`; | ||
requestAnimationFrame(() => { | ||
setTimeout(() => { | ||
addClass(openClass, this.dom.container); | ||
addClass(closeClass, this.dom.container); | ||
removeClass(transitionClass, this.dom.container); | ||
this.dom.container.style.height = ""; | ||
}, openDuration); | ||
}); | ||
} else { | ||
// Add the open class | ||
addClass(openClass, this.dom.container); | ||
// Remove the close class. | ||
removeClass(closeClass, this.dom.container); | ||
} | ||
} else { | ||
addClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
removeClass(closeClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
addClass(openClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
setTimeout(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
}, openDuration); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} else if (openClass !== "") { | ||
} | ||
} else { | ||
// Add the open class | ||
addClass(openClass, this.dom.container); | ||
// Remove the close class. | ||
removeClass(closeClass, this.dom.container); | ||
} | ||
@@ -109,4 +171,10 @@ | ||
_collapse(emit = true) { | ||
const { closeClass, openClass, transitionClass } = | ||
this.elements.controlledMenu; | ||
const { | ||
closeClass, | ||
openClass, | ||
transitionClass, | ||
closeDuration, | ||
bootstrapTransitions, | ||
isTopLevel, | ||
} = this.elements.controlledMenu; | ||
@@ -118,30 +186,60 @@ this.dom.toggle.setAttribute("aria-expanded", "false"); | ||
// add the close class, and finally remove the transition class. | ||
// | ||
// Depending on if you're using bootstrap transitions or not, the process for | ||
// collapsing the menu will differ. | ||
// | ||
// If the menu is emulating bootstrap dropdown/collapse behaviour, | ||
// we need to add the inline style for the height of the menu | ||
// as well as the transition class. | ||
if (transitionClass !== "") { | ||
addClass(transitionClass, this.dom.container); | ||
if (bootstrapTransitions) { | ||
if (isTopLevel) { | ||
this.dom.container.style.height = `${this.dom.container.offsetHeight}px`; | ||
requestAnimationFrame(() => { | ||
if (openClass !== "") { | ||
requestAnimationFrame(() => { | ||
addClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
removeClass(openClass, this.dom.container); | ||
removeClass(closeClass, this.dom.container); | ||
this.dom.container.style.height = ""; | ||
requestAnimationFrame(() => { | ||
setTimeout(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
addClass(closeClass, this.dom.container); | ||
}, closeDuration); | ||
}); | ||
}); | ||
}); | ||
} else { | ||
// Add the close class | ||
addClass(closeClass, this.dom.container); | ||
// Remove the open class. | ||
removeClass(openClass, this.dom.container); | ||
} | ||
} else { | ||
addClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
if (closeClass !== "") { | ||
removeClass(openClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
addClass(closeClass, this.dom.container); | ||
} | ||
requestAnimationFrame(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
setTimeout(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
}, closeDuration); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
} else { | ||
// Add the close class | ||
if (closeClass !== "") { | ||
addClass(closeClass, this.dom.container); | ||
} | ||
addClass(closeClass, this.dom.container); | ||
// Remove the open class. | ||
if (openClass !== "") { | ||
removeClass(openClass, this.dom.container); | ||
} | ||
removeClass(openClass, this.dom.container); | ||
} | ||
@@ -148,0 +246,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1205315
23
21613
Updatedaccessible-menu@^4.2.0