Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

accessible-menu-bootstrap-5

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

accessible-menu-bootstrap-5 - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

dist/accessible-menu-bs5.min.js

@@ -1,2 +0,2 @@

var AccessibleMenuBootstrap5=function(){"use strict";function e(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ${typeof t} given.`)}for(const n in t)if(!(t[n]instanceof e)){const s=typeof t[n];throw new TypeError(`AccessibleMenu: ${n} must be an instance of ${e.name}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function t(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Values given to isValidType() must be inside of an object. ${typeof t} given.`)}for(const n in t){const s=typeof t[n];if(s!==e)throw new TypeError(`AccessibleMenu: ${n} must be a ${e}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function n(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ${typeof e} given.`)}for(const t in e)try{if(null===e[t])throw new Error;document.querySelector(e[t])}catch(n){throw new TypeError(`AccessibleMenu: ${t} must be a valid CSS selector. "${e[t]}" given.`)}return!0}catch(e){return console.error(e),!1}}function s(e){try{if("object"!=typeof e||Array.isArray(e)){throw new TypeError(`AccessibleMenu: Values given to isValidClassList() must be inside of an object. ${typeof e} given.`)}for(const t in e){const s=typeof e[t];if("string"!==s){if(!Array.isArray(e[t]))throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. ${s} given.`);e[t].forEach((e=>{if("string"!=typeof e)throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. An array containing non-strings given.`)}))}else{const s={};s[t]=e[t],n(s)}}return!0}catch(e){return console.error(e),!1}}function i(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ${typeof e} given.`)}const t=["off","on","dynamic"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}function r(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class l{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i=null}=e;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=t,this._dom.parent=n,this._elements.controlledMenu=s,this._elements.parentMenu=i}initialize(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(n,s){if(t("string",{tagName:n})&&e(HTMLElement,s)){const e=n.toLowerCase();let t=!0;for(const n in s)s[n].tagName.toLowerCase()!==e&&(t=!1);return t}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){const e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&(t=t.toLowerCase().replace(/\s+/g,"-"),t.startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n=`${t}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){t("boolean",{value:e}),this._open=e}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.add(n):this.elements.controlledMenu.dom.menu.classList.add(...n)),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.remove(t):this.elements.controlledMenu.dom.menu.classList.remove(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.add(t):this.elements.controlledMenu.dom.menu.classList.add(...t)),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.remove(n):this.elements.controlledMenu.dom.menu.classList.remove(...n)),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.currentChild=0,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()))}}function o(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class u{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:l=null}=e;o(this,"_dom",{item:null,link:null}),o(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),o(this,"_submenu",!1),this._dom.item=t,this._dom.link=n,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 m(e){try{const t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((e=>!0===n[e]))||""}catch(e){return""}}function h(e){e.preventDefault(),e.stopPropagation()}function c(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class a{constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:o="ul",controllerElement:m=null,containerElement:h=null,openClass:d="show",closeClass:p="hide",isTopLevel:g=!0,parentMenu:f=null,hoverType:b="off",hoverDelay:v=250}=e;c(this,"_MenuType",a),c(this,"_MenuItemType",u),c(this,"_MenuToggleType",l),c(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null}),c(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""}),c(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null}),c(this,"_openClass","show"),c(this,"_closeClass","hide"),c(this,"_root",!0),c(this,"_currentChild",0),c(this,"_focusState","none"),c(this,"_currentEvent","none"),c(this,"_hoverType","off"),c(this,"_hoverDelay",250),this._dom.menu=t,this._dom.controller=m,this._dom.container=h,this._selectors.menuItems=n,this._selectors.menuLinks=s,this._selectors.submenuItems=i,this._selectors.submenuToggles=r,this._selectors.submenus=o,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=f,this._elements.rootMenu=g?this:null,this._openClass=d||"",this._closeClass=p||"",this._root=g,this._hoverType=b,this._hoverDelay=v}initialize(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&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 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 shouldFocus(){let e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}set openClass(e){s({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){s({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set currentChild(e){function n(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu){let t=0,n=!1;for(;!n&&t<e.elements.parentMenu.elements.menuItems.length;){const s=e.elements.parentMenu.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}}t("number",{value:e}),e<-1?(this._currentChild=-1,n(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,n(this)):this.focusChild!==e&&(this._currentChild=e,n(this))}set focusState(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidState() must be inside of an object. ${typeof e} given.`);const t=["none","self","child"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&("self"===e||"none"===e)&&this.elements.submenuToggles.forEach((e=>{e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==e&&"child"!==e||(this.elements.parentMenu.focusState="child")}set currentEvent(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidEvent() must be inside of an object. ${typeof e} given.`);const t=["none","mouse","keyboard","character"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({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){i({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){t("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}_validate(){let r=!0;return null!==this._dom.container||null!==this._dom.controller?e(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(r=!1):e(HTMLElement,{menuElement:this._dom.menu})||(r=!1),""!==this._selectors.submenuItems?n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(r=!1):n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(r=!1),""===this._openClass||s({openClass:this._openClass})||(r=!1),""===this._closeClass||s({closeClass:this._closeClass})||(r=!1),t("boolean",{isTopLevel:this._root})||(r=!1),null===this._elements.parentMenu||e(a,{parentMenu:this._elements.parentMenu})||(r=!1),i({hoverType:this._hoverType})||(r=!1),t("number",{hoverDelay:this._hoverDelay})||(r=!1),r}_setDOMElementType(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[t])throw new Error(`AccessibleMenu: "${t}" is not a valid element type within the menu.`);{if(!Array.isArray(this.dom[t]))throw new Error(`AccessibleMenu: The "${t}" element cannot be set through _setDOMElementType.`);n!==this.dom.menu&&e(HTMLElement,{base:n});const i=Array.from(n.querySelectorAll(this.selectors[t])).filter((e=>e.parentElement===n));this._dom[t]=s?i:[...this._dom[t],...i]}}_resetDOMElementType(e){if(void 0===this.dom[e])throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`);if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}_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(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}_createChildElements(){this.dom.menuItems.forEach((e=>{let t;if(this.dom.submenuItems.includes(e)){const n=e.querySelector(this.selectors.submenuToggles),s=e.querySelector(this.selectors.submenus),i=new this._MenuType({menuElement:s,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,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),r=new this._MenuToggleType({menuToggleElement:n,parentElement:e,controlledMenu:i,parentMenu:this});this._elements.submenuToggles.push(r),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,parentMenu:this,isSubmenuItem:!0,childMenu:i,toggle:r})}else{const n=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,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(e,t,n){h(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach(((t,n)=>{t.dom.link.addEventListener("pointerdown",(()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(n)}),{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",(n=>{if("pen"!==n.pointerType&&"touch"!==n.pointerType)if("on"===this.hoverType)this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&e.elements.toggle.preview();else if("dynamic"===this.hoverType){const n=this.elements.submenuToggles.some((e=>e.isOpen));this.currentChild=t,this.isTopLevel&&"none"===this.focusState||(this.currentEvent="mouse",this.focusCurrentChild()),!e.isSubmenuItem||this.isTopLevel&&!n||(this.currentEvent="mouse",e.elements.toggle.preview())}})),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",(t=>{"pen"!==t.pointerType&&"touch"!==t.pointerType&&("on"===this.hoverType?this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close()}),this.hoverDelay):(this.currentEvent="mouse",e.elements.toggle.close()):"dynamic"===this.hoverType&&(this.isTopLevel||(this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()}),this.hoverDelay):(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=m(e);"Space"!==t&&"Enter"!==t||h(e)}))}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=m(e);"Space"!==t&&"Enter"!==t||(h(e),this.elements.controller.open(),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",-1!==this.currentChild&&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",-1!==this.currentChild&&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 d extends u{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:l=null,initialize:o=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i,childMenu:r,toggle:l}),o&&this.initialize()}}class p extends l{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i=null,initialize:r=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i}),r&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}function g(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class f extends a{constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:l="ul",controllerElement:o=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:b="off",hoverDelay:v=250,optionalKeySupport:M=!1,initialize:y=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:l,controllerElement:o,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:b,hoverDelay:v}),g(this,"_MenuType",f),g(this,"_MenuItemType",d),g(this,"_MenuToggleType",p),g(this,"_currentChild",-1),g(this,"_optionalSupport",!1),this._optionalSupport=M,y&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(e){console.error(e)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(e){t("boolean",{optionalKeySupport:e}),this._optionalSupport=e}_validate(){let e=super._validate();return t("boolean",{optionalKeySupport:this._optionalSupport})||(e=!1),e}_handleClick(){super._handleClick(),document.addEventListener("pointerup",(e=>{"none"!==this.focusState&&(this.currentEvent="mouse",this.dom.menu.contains(e.target)||!this.dom.menu===e.target||(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))}))}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",(e=>{this.currentEvent="keyboard";const t=m(e);if("self"===this.focusState){const n=["Space","Enter"],s=["Escape"],i=["Escape"];if(this.optionalKeySupport){["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(t)&&h(e)}else(this.currentMenuItem.isSubmenuItem&&n.includes(t)||this.elements.controller&&s.includes(t)||this.elements.parentMenu&&i.includes(t))&&h(e)}}))}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=m(e);if("self"===this.focusState)if("Space"===t||"Enter"===t)this.currentMenuItem.isSubmenuItem?(h(e),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click();else if("Escape"===t){this.elements.submenuToggles.some((e=>e.isOpen))?(h(e),this.closeChildren()):this.elements.parentMenu?(h(e),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())}else this.optionalKeySupport&&("ArrowDown"===t||"ArrowRight"===t?(h(e),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):"ArrowUp"===t||"ArrowLeft"===t?(h(e),this.focusPreviousChild()):"Home"===t?(h(e),this.focusFirstChild()):"End"===t&&(h(e),this.focusLastChild()))}))}}class b extends d{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:l=null,initialize:o=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i,childMenu:r,toggle:l,initialize:!1}),o&&this.initialize()}}function v(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class M extends p{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i=null,initialize:r=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i,initialize:!1}),v(this,"_dom",{toggle:null,parent:null,container:null}),this._dom.toggle=t,this._dom.parent=n,this._dom.container=s.isTopLevel?s.dom.container:s.dom.menu,r&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),""!==n&&("string"==typeof n?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}function y(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class E extends f{constructor(e){let{menuElement:t,menuItemSelector:n=".nav-item,li",menuLinkSelector:s=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:l=".dropdown-menu",controllerElement:o=null,containerElement:u=null,openClass:m="show",closeClass:h="collapse",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,optionalKeySupport:g=!1,initialize:f=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:l,controllerElement:o,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p,optionalKeySupport:g,initialize:!1}),y(this,"_MenuType",E),y(this,"_MenuItemType",b),y(this,"_MenuToggleType",M),f&&this.initialize()}}class C extends u{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:l=null,initialize:o=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i,childMenu:r,toggle:l}),o&&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 I extends l{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i=null,initialize:r=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i}),r&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}function S(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class _ extends a{constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:l="ul",controllerElement:o=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,initialize:g=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:l,controllerElement:o,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p}),S(this,"_MenuType",_),S(this,"_MenuItemType",C),S(this,"_MenuToggleType",I),g&&this.initialize()}initialize(){try{super.initialize(),this.dom.menu.setAttribute("role","menubar"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup(),this.isTopLevel&&(this.elements.menuItems[0].dom.link.tabIndex=0)}catch(e){console.error(e)}}_handleClick(){super._handleClick(),document.addEventListener("pointerup",(e=>{"none"!==this.focusState&&(this.currentEvent="mouse",this.dom.menu.contains(e.target)||!this.dom.menu===e.target||(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))}))}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",(e=>{this.currentEvent="keyboard";const t=m(e);if("Tab"===t&&("none"!==this.elements.rootMenu.focusState?(this.elements.rootMenu.blur(),this.elements.rootMenu.closeChildren()):this.elements.rootMenu.focus()),"Character"===t)h(e);else if(this.isTopLevel){if("self"===this.focusState){const n=["Space","Enter","ArrowDown","ArrowUp"],s=["Escape"];(["ArrowRight","ArrowLeft","Home","End"].includes(t)||this.currentMenuItem.isSubmenuItem&&n.includes(t)||this.elements.controller&&s.includes(t))&&h(e)}}else{const n=["Space","Enter"];(["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"].includes(t)||this.currentMenuItem.isSubmenuItem&&n.includes(t))&&h(e)}}))}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=m(e),{altKey:n,crtlKey:s,metaKey:i}=e;if("Character"!==t||(n||s||i))if(this.isTopLevel){if("self"===this.focusState)if("Space"===t||"Enter"===t)this.currentMenuItem.isSubmenuItem?(h(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()}))):this.currentMenuItem.dom.link.click();else if("ArrowRight"===t){h(e);const t=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusNextChild(),t&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if("ArrowLeft"===t){h(e);const t=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusPreviousChild(),t&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if("ArrowDown"===t)this.currentMenuItem.isSubmenuItem&&(h(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})));else if("ArrowUp"===t)this.currentMenuItem.isSubmenuItem&&(h(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusLastChild()})));else if("Home"===t)h(e),this.focusFirstChild();else if("End"===t)h(e),this.focusLastChild();else if("Escape"===t){this.elements.submenuToggles.some((e=>e.isOpen))?(h(e),this.closeChildren()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(h(e),this.elements.controller.close(),this.focusController())}}else"Space"===t||"Enter"===t?this.currentMenuItem.isSubmenuItem?(h(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()}))):this.currentMenuItem.dom.link.click():"Escape"===t?(h(e),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusCurrentChild()):"ArrowRight"===t?this.currentMenuItem.isSubmenuItem?(h(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()}))):(h(e),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusNextChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&this.elements.rootMenu.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===t?this.elements.parentMenu.currentMenuItem.isSubmenuItem&&(h(e),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()))):"ArrowDown"===t?(h(e),this.focusNextChild()):"ArrowUp"===t?(h(e),this.focusPreviousChild()):"Home"===t?(h(e),this.focusFirstChild()):"End"===t&&(h(e),this.focusLastChild());else h(e),this.elements.rootMenu.currentEvent="character",this.focusNextChildWithCharacter(e.key)}))}focusNextChild(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}focusPreviousChild(){0===this.currentChild?this.focusLastChild():this.focusChild(this.currentChild-1)}focusNextChildWithCharacter(e){const t=e.toLowerCase();let n=this.currentChild+1,s=!1;for(;!s&&n<this.elements.menuItems.length;){let e="";e=this.elements.menuItems[n].dom.item.innerText?this.elements.menuItems[n].dom.item.innerText:this.elements.menuItems[n].dom.item.textContent,e=e.replace(/[\s]/g,"").toLowerCase().charAt(0),e===t&&(s=!0,this.focusChild(n)),n++}}}class T extends C{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:l=null,initialize:o=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i,childMenu:r,toggle:l,initialize:!1}),o&&this.initialize()}}function w(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class L extends I{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i=null,initialize:r=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i,initialize:!1}),w(this,"_dom",{toggle:null,parent:null,container:null}),this._dom.toggle=t,this._dom.parent=n,this._dom.container=s.isTopLevel?s.dom.container:s.dom.menu,r&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),""!==n&&("string"==typeof n?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}function A(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class k extends _{constructor(e){let{menuElement:t,menuItemSelector:n=".nav-item,li",menuLinkSelector:s=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:l=".dropdown-menu",controllerElement:o=null,containerElement:u=null,openClass:m="show",closeClass:h="collapse",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,initialize:g=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:l,controllerElement:o,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p,initialize:!1}),A(this,"_MenuType",k),A(this,"_MenuItemType",T),A(this,"_MenuToggleType",L),g&&this.initialize()}}class x extends u{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:l=null,initialize:o=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i,childMenu:r,toggle:l}),o&&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 l{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i=null,initialize:r=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i}),r&&this.initialize()}}function O(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class j extends a{constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:l="ul",controllerElement:o=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,initialize:g=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:l,controllerElement:o,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p}),O(this,"_MenuType",j),O(this,"_MenuItemType",x),O(this,"_MenuToggleType",z),g&&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(e){console.error(e)}}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",(e=>{this.currentEvent="keyboard";const t=m(e);if("Tab"===t&&("none"!==this.elements.rootMenu.focusState?this.elements.rootMenu.blur():this.elements.rootMenu.focus()),"self"===this.focusState){const n=["Enter","ArrowRight"],s=["Escape"];(["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"].includes(t)||this.currentMenuItem.isSubmenuItem&&n.includes(t)||this.elements.controller&&s.includes(t))&&h(e)}}))}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=m(e),{altKey:n,crtlKey:s,metaKey:i}=e;if("Character"!==t||(n||s||i)){if("self"===this.focusState)if("Enter"===t||"Space"===t)h(e),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("Escape"===t)this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController());else if("ArrowDown"===t)h(e),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.focusNextChild():this.focusParentsNextChild();else if("ArrowUp"===t){h(e);const t=this.elements.menuItems[this.currentChild-1];t&&t.isSubmenuItem&&t.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentChild=this.currentChild-1,this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.focusChildsLastNode()):this.isTopLevel||0!==this.currentChild?this.focusPreviousChild():(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild())}else"ArrowRight"===t?this.currentMenuItem.isSubmenuItem&&(h(e),this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):this.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===t?(h(e),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())):"Home"===t?(h(e),this.blurCurrentChild(),this.elements.rootMenu.focusFirstChild()):"End"===t?(h(e),this.blurCurrentChild(),this.elements.rootMenu.focusLastNode()):"Asterisk"===t&&(h(e),this.openChildren())}else h(e),this.elements.rootMenu.currentEvent="character",this.focusNextNodeWithCharacter(e.key)}))}focusLastNode(){const e=this.elements.menuItems.length-1,t=this.elements.menuItems[e];t.isSubmenuItem&&t.elements.toggle.isOpen?(this.currentChild=e,t.elements.childMenu.currentEvent=this.currentEvent,t.elements.childMenu.focusLastNode()):this.focusLastChild()}openChildren(){this.elements.submenuToggles.forEach((e=>e.preview()))}focusNextNodeWithCharacter(e){const t=e.toLowerCase(),n=function e(t){let n=[];return t.elements.menuItems.forEach((t=>{n.push(t),t.isSubmenuItem&&t.elements.toggle.isOpen&&(n=[...n,...e(t.elements.toggle.elements.controlledMenu)])})),n}(this.elements.rootMenu),s=n.indexOf(this.currentMenuItem)+1,i=[...n.slice(s),...n.slice(0,s)];let r=0,l=!1;for(;!l&&r<i.length;){let e="";if(e=i[r].dom.item.innerText?i[r].dom.item.innerText:i[r].dom.item.textContent,e=e.replace(/[\s]/g,"").toLowerCase().charAt(0),e===t){l=!0;const e=i[r].elements.parentMenu,t=e.elements.menuItems.indexOf(i[r]);this.elements.rootMenu.blurChildren(),e.focusChild(t)}r++}}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 D extends x{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:l=null,initialize:o=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i,childMenu:r,toggle:l,initialize:!1}),o&&this.initialize()}}function P(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class N extends z{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i=null,initialize:r=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i,initialize:!1}),P(this,"_dom",{toggle:null,parent:null,container:null}),this._dom.toggle=t,this._dom.parent=n,this._dom.container=s.isTopLevel?s.dom.container:s.dom.menu,r&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),""!==n&&("string"==typeof n?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}function K(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class $ extends j{constructor(e){let{menuElement:t,menuItemSelector:n=".nav-item,li",menuLinkSelector:s=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:l=".dropdown-menu",controllerElement:o=null,containerElement:u=null,openClass:m="show",closeClass:h="collapse",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,initialize:g=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:l,controllerElement:o,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p,initialize:!1}),K(this,"_MenuType",$),K(this,"_MenuItemType",D),K(this,"_MenuToggleType",N),g&&this.initialize()}}return{Bootstrap5DisclosureMenu:E,Bootstrap5Menubar:k,Bootstrap5Treeview:$}}();
var AccessibleMenuBootstrap5=function(){"use strict";function e(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ${typeof t} given.`)}for(const n in t)if(!(t[n]instanceof e)){const s=typeof t[n];throw new TypeError(`AccessibleMenu: ${n} must be an instance of ${e.name}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function t(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Values given to isValidType() must be inside of an object. ${typeof t} given.`)}for(const n in t){const s=typeof t[n];if(s!==e)throw new TypeError(`AccessibleMenu: ${n} must be a ${e}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function n(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ${typeof e} given.`)}for(const t in e)try{if(null===e[t])throw new Error;document.querySelector(e[t])}catch(n){throw new TypeError(`AccessibleMenu: ${t} must be a valid CSS selector. "${e[t]}" given.`)}return!0}catch(e){return console.error(e),!1}}function s(e){try{if("object"!=typeof e||Array.isArray(e)){throw new TypeError(`AccessibleMenu: Values given to isValidClassList() must be inside of an object. ${typeof e} given.`)}for(const t in e){const s=typeof e[t];if("string"!==s){if(!Array.isArray(e[t]))throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. ${s} given.`);e[t].forEach((e=>{if("string"!=typeof e)throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. An array containing non-strings given.`)}))}else{const s={};s[t]=e[t],n(s)}}return!0}catch(e){return console.error(e),!1}}function l(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ${typeof e} given.`)}const t=["off","on","dynamic"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}class i{_dom={toggle:null,parent:null};_elements={controlledMenu:null,parentMenu:null};_open=!1;_expandEvent=new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}});_collapseEvent=new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}});constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l=null}=e;this._dom.toggle=t,this._dom.parent=n,this._elements.controlledMenu=s,this._elements.parentMenu=l}initialize(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(n,s){if(t("string",{tagName:n})&&e(HTMLElement,s)){const e=n.toLowerCase();let t=!0;for(const n in s)s[n].tagName.toLowerCase()!==e&&(t=!1);return t}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){const e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&(t=t.toLowerCase().replace(/\s+/g,"-"),t.startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n=`${t}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){t("boolean",{value:e}),this._open=e}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.add(n):this.elements.controlledMenu.dom.menu.classList.add(...n)),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.remove(t):this.elements.controlledMenu.dom.menu.classList.remove(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.add(t):this.elements.controlledMenu.dom.menu.classList.add(...t)),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.remove(n):this.elements.controlledMenu.dom.menu.classList.remove(...n)),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.currentChild=0,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 o{_dom={item:null,link:null};_elements={parentMenu:null,childMenu:null,toggle:null};_submenu=!1;constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l=!1,childMenu:i=null,toggle:o=null}=e;this._dom.item=t,this._dom.link=n,this._elements.parentMenu=s,this._elements.childMenu=i,this._elements.toggle=o,this._submenu=l}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 r(e){try{const t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((e=>!0===n[e]))||""}catch(e){return""}}function u(e){e.preventDefault(),e.stopPropagation()}class m{_MenuType=m;_MenuItemType=o;_MenuToggleType=i;_dom={menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null};_selectors={menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""};_elements={menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null};_openClass="show";_closeClass="hide";_root=!0;_currentChild=0;_focusState="none";_currentEvent="none";_hoverType="off";_hoverDelay=250;constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:l="",submenuToggleSelector:i="a",submenuSelector:o="ul",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250}=e;this._dom.menu=t,this._dom.controller=r,this._dom.container=u,this._selectors.menuItems=n,this._selectors.menuLinks=s,this._selectors.submenuItems=l,this._selectors.submenuToggles=i,this._selectors.submenus=o,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=a,this._elements.rootMenu=c?this:null,this._openClass=m||"",this._closeClass=h||"",this._root=c,this._hoverType=d,this._hoverDelay=p}initialize(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&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 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 shouldFocus(){let e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}set openClass(e){s({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){s({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set currentChild(e){function n(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu){let t=0,n=!1;for(;!n&&t<e.elements.parentMenu.elements.menuItems.length;){const s=e.elements.parentMenu.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}}t("number",{value:e}),e<-1?(this._currentChild=-1,n(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,n(this)):this.focusChild!==e&&(this._currentChild=e,n(this))}set focusState(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidState() must be inside of an object. ${typeof e} given.`);const t=["none","self","child"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&("self"===e||"none"===e)&&this.elements.submenuToggles.forEach((e=>{e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==e&&"child"!==e||(this.elements.parentMenu.focusState="child")}set currentEvent(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidEvent() must be inside of an object. ${typeof e} given.`);const t=["none","mouse","keyboard","character"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({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){l({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){t("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}_validate(){let i=!0;return null!==this._dom.container||null!==this._dom.controller?e(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(i=!1):e(HTMLElement,{menuElement:this._dom.menu})||(i=!1),""!==this._selectors.submenuItems?n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(i=!1):n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(i=!1),""===this._openClass||s({openClass:this._openClass})||(i=!1),""===this._closeClass||s({closeClass:this._closeClass})||(i=!1),t("boolean",{isTopLevel:this._root})||(i=!1),null===this._elements.parentMenu||e(m,{parentMenu:this._elements.parentMenu})||(i=!1),l({hoverType:this._hoverType})||(i=!1),t("number",{hoverDelay:this._hoverDelay})||(i=!1),i}_setDOMElementType(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[t])throw new Error(`AccessibleMenu: "${t}" is not a valid element type within the menu.`);{if(!Array.isArray(this.dom[t]))throw new Error(`AccessibleMenu: The "${t}" element cannot be set through _setDOMElementType.`);n!==this.dom.menu&&e(HTMLElement,{base:n});const l=Array.from(n.querySelectorAll(this.selectors[t])).filter((e=>e.parentElement===n));this._dom[t]=s?l:[...this._dom[t],...l]}}_resetDOMElementType(e){if(void 0===this.dom[e])throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`);if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}_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(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}_createChildElements(){this.dom.menuItems.forEach((e=>{let t;if(this.dom.submenuItems.includes(e)){const n=e.querySelector(this.selectors.submenuToggles),s=e.querySelector(this.selectors.submenus),l=new this._MenuType({menuElement:s,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,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),i=new this._MenuToggleType({menuToggleElement:n,parentElement:e,controlledMenu:l,parentMenu:this});this._elements.submenuToggles.push(i),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,parentMenu:this,isSubmenuItem:!0,childMenu:l,toggle:i})}else{const n=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,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(e,t,n){u(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach(((t,n)=>{t.dom.link.addEventListener("pointerdown",(()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(n)}),{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",(n=>{if("pen"!==n.pointerType&&"touch"!==n.pointerType)if("on"===this.hoverType)this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&e.elements.toggle.preview();else if("dynamic"===this.hoverType){const n=this.elements.submenuToggles.some((e=>e.isOpen));this.currentChild=t,this.isTopLevel&&"none"===this.focusState||(this.currentEvent="mouse",this.focusCurrentChild()),!e.isSubmenuItem||this.isTopLevel&&!n||(this.currentEvent="mouse",e.elements.toggle.preview())}})),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",(t=>{"pen"!==t.pointerType&&"touch"!==t.pointerType&&("on"===this.hoverType?this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close()}),this.hoverDelay):(this.currentEvent="mouse",e.elements.toggle.close()):"dynamic"===this.hoverType&&(this.isTopLevel||(this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()}),this.hoverDelay):(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=r(e);"Space"!==t&&"Enter"!==t||u(e)}))}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=r(e);"Space"!==t&&"Enter"!==t||(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",-1!==this.currentChild&&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",-1!==this.currentChild&&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 h extends o{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l=!1,childMenu:i=null,toggle:o=null,initialize:r=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l,childMenu:i,toggle:o}),r&&this.initialize()}}class c extends i{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l=null,initialize:i=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l}),i&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class a extends m{_MenuType=a;_MenuItemType=h;_MenuToggleType=c;_currentChild=-1;_optionalSupport=!1;constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:l="",submenuToggleSelector:i="a",submenuSelector:o="ul",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,optionalKeySupport:g=!1,initialize:M=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:l,submenuToggleSelector:i,submenuSelector:o,controllerElement:r,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p}),this._optionalSupport=g,M&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(e){console.error(e)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(e){t("boolean",{optionalKeySupport:e}),this._optionalSupport=e}_validate(){let e=super._validate();return t("boolean",{optionalKeySupport:this._optionalSupport})||(e=!1),e}_handleClick(){super._handleClick(),document.addEventListener("pointerup",(e=>{"none"!==this.focusState&&(this.currentEvent="mouse",this.dom.menu.contains(e.target)||!this.dom.menu===e.target||(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))}))}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",(e=>{this.currentEvent="keyboard";const t=r(e);if("self"===this.focusState){const n=["Space","Enter"],s=["Escape"],l=["Escape"];if(this.optionalKeySupport){["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(t)&&u(e)}else(this.currentMenuItem.isSubmenuItem&&n.includes(t)||this.elements.controller&&s.includes(t)||this.elements.parentMenu&&l.includes(t))&&u(e)}}))}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=r(e);if("self"===this.focusState)if("Space"===t||"Enter"===t)this.currentMenuItem.isSubmenuItem?(u(e),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click();else if("Escape"===t){this.elements.submenuToggles.some((e=>e.isOpen))?(u(e),this.closeChildren()):this.elements.parentMenu?(u(e),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())}else this.optionalKeySupport&&("ArrowDown"===t||"ArrowRight"===t?(u(e),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):"ArrowUp"===t||"ArrowLeft"===t?(u(e),this.focusPreviousChild()):"Home"===t?(u(e),this.focusFirstChild()):"End"===t&&(u(e),this.focusLastChild()))}))}}class d extends h{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l=!1,childMenu:i=null,toggle:o=null,initialize:r=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l,childMenu:i,toggle:o,initialize:!1}),r&&this.initialize()}}class p extends c{_dom={toggle:null,parent:null,container:null};constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l=null,initialize:i=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l,initialize:!1}),this._dom.toggle=t,this._dom.parent=n,this._dom.container=s.isTopLevel?s.dom.container:s.dom.menu,i&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),""!==n&&("string"==typeof n?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class g extends a{_MenuType=g;_MenuItemType=d;_MenuToggleType=p;constructor(e){let{menuElement:t,menuItemSelector:n=".nav-item,li",menuLinkSelector:s=".nav-link,.dropdown-item",submenuItemSelector:l=".dropdown",submenuToggleSelector:i=".dropdown-toggle",submenuSelector:o=".dropdown-menu",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="collapse",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,optionalKeySupport:g=!1,initialize:M=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:l,submenuToggleSelector:i,submenuSelector:o,controllerElement:r,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p,optionalKeySupport:g,initialize:!1}),M&&this.initialize()}}class M extends o{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l=!1,childMenu:i=null,toggle:o=null,initialize:r=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l,childMenu:i,toggle:o}),r&&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 b extends i{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l=null,initialize:i=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l}),i&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class f extends m{_MenuType=f;_MenuItemType=M;_MenuToggleType=b;constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:l="",submenuToggleSelector:i="a",submenuSelector:o="ul",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,initialize:g=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:l,submenuToggleSelector:i,submenuSelector:o,controllerElement:r,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p}),g&&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(e){console.error(e)}}_handleClick(){super._handleClick(),document.addEventListener("pointerup",(e=>{"none"!==this.focusState&&(this.currentEvent="mouse",this.dom.menu.contains(e.target)||!this.dom.menu===e.target||(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))}))}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",(e=>{this.currentEvent="keyboard";const t=r(e);if("Tab"===t&&("none"!==this.elements.rootMenu.focusState?(this.elements.rootMenu.blur(),this.elements.rootMenu.closeChildren()):this.elements.rootMenu.focus()),"Character"===t)u(e);else if(this.isTopLevel){if("self"===this.focusState){const n=["Space","Enter","ArrowDown","ArrowUp"],s=["Escape"];(["ArrowRight","ArrowLeft","Home","End"].includes(t)||this.currentMenuItem.isSubmenuItem&&n.includes(t)||this.elements.controller&&s.includes(t))&&u(e)}}else{const n=["Space","Enter"];(["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"].includes(t)||this.currentMenuItem.isSubmenuItem&&n.includes(t))&&u(e)}}))}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=r(e),{altKey:n,crtlKey:s,metaKey:l}=e;if("Character"!==t||(n||s||l))if(this.isTopLevel){if("self"===this.focusState)if("Space"===t||"Enter"===t)this.currentMenuItem.isSubmenuItem?(u(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()}))):this.currentMenuItem.dom.link.click();else if("ArrowRight"===t){u(e);const t=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusNextChild(),t&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if("ArrowLeft"===t){u(e);const t=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusPreviousChild(),t&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if("ArrowDown"===t)this.currentMenuItem.isSubmenuItem&&(u(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})));else if("ArrowUp"===t)this.currentMenuItem.isSubmenuItem&&(u(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusLastChild()})));else if("Home"===t)u(e),this.focusFirstChild();else if("End"===t)u(e),this.focusLastChild();else if("Escape"===t){this.elements.submenuToggles.some((e=>e.isOpen))?(u(e),this.closeChildren()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(u(e),this.elements.controller.close(),this.focusController())}}else"Space"===t||"Enter"===t?this.currentMenuItem.isSubmenuItem?(u(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()}))):this.currentMenuItem.dom.link.click():"Escape"===t?(u(e),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusCurrentChild()):"ArrowRight"===t?this.currentMenuItem.isSubmenuItem?(u(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()}))):(u(e),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusNextChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&this.elements.rootMenu.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===t?this.elements.parentMenu.currentMenuItem.isSubmenuItem&&(u(e),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()))):"ArrowDown"===t?(u(e),this.focusNextChild()):"ArrowUp"===t?(u(e),this.focusPreviousChild()):"Home"===t?(u(e),this.focusFirstChild()):"End"===t&&(u(e),this.focusLastChild());else u(e),this.elements.rootMenu.currentEvent="character",this.focusNextChildWithCharacter(e.key)}))}focusNextChild(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}focusPreviousChild(){0===this.currentChild?this.focusLastChild():this.focusChild(this.currentChild-1)}focusNextChildWithCharacter(e){const t=e.toLowerCase();let n=this.currentChild+1,s=!1;for(;!s&&n<this.elements.menuItems.length;){let e="";e=this.elements.menuItems[n].dom.item.innerText?this.elements.menuItems[n].dom.item.innerText:this.elements.menuItems[n].dom.item.textContent,e=e.replace(/[\s]/g,"").toLowerCase().charAt(0),e===t&&(s=!0,this.focusChild(n)),n++}}}class v extends M{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l=!1,childMenu:i=null,toggle:o=null,initialize:r=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l,childMenu:i,toggle:o,initialize:!1}),r&&this.initialize()}}class E extends b{_dom={toggle:null,parent:null,container:null};constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l=null,initialize:i=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l,initialize:!1}),this._dom.toggle=t,this._dom.parent=n,this._dom.container=s.isTopLevel?s.dom.container:s.dom.menu,i&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),""!==n&&("string"==typeof n?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class C extends f{_MenuType=C;_MenuItemType=v;_MenuToggleType=E;constructor(e){let{menuElement:t,menuItemSelector:n=".nav-item,li",menuLinkSelector:s=".nav-link,.dropdown-item",submenuItemSelector:l=".dropdown",submenuToggleSelector:i=".dropdown-toggle",submenuSelector:o=".dropdown-menu",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="collapse",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,initialize:g=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:l,submenuToggleSelector:i,submenuSelector:o,controllerElement:r,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p,initialize:!1}),g&&this.initialize()}}class y extends o{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l=!1,childMenu:i=null,toggle:o=null,initialize:r=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l,childMenu:i,toggle:o}),r&&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 I extends i{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l=null,initialize:i=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l}),i&&this.initialize()}}class _ extends m{_MenuType=_;_MenuItemType=y;_MenuToggleType=I;constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:l="",submenuToggleSelector:i="a",submenuSelector:o="ul",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,initialize:g=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:l,submenuToggleSelector:i,submenuSelector:o,controllerElement:r,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p}),g&&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(e){console.error(e)}}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",(e=>{this.currentEvent="keyboard";const t=r(e);if("Tab"===t&&("none"!==this.elements.rootMenu.focusState?this.elements.rootMenu.blur():this.elements.rootMenu.focus()),"self"===this.focusState){const n=["Enter","ArrowRight"],s=["Escape"];(["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"].includes(t)||this.currentMenuItem.isSubmenuItem&&n.includes(t)||this.elements.controller&&s.includes(t))&&u(e)}}))}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=r(e),{altKey:n,crtlKey:s,metaKey:l}=e;if("Character"!==t||(n||s||l)){if("self"===this.focusState)if("Enter"===t||"Space"===t)u(e),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("Escape"===t)this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController());else if("ArrowDown"===t)u(e),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.focusNextChild():this.focusParentsNextChild();else if("ArrowUp"===t){u(e);const t=this.elements.menuItems[this.currentChild-1];t&&t.isSubmenuItem&&t.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentChild=this.currentChild-1,this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.focusChildsLastNode()):this.isTopLevel||0!==this.currentChild?this.focusPreviousChild():(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild())}else"ArrowRight"===t?this.currentMenuItem.isSubmenuItem&&(u(e),this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):this.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===t?(u(e),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())):"Home"===t?(u(e),this.blurCurrentChild(),this.elements.rootMenu.focusFirstChild()):"End"===t?(u(e),this.blurCurrentChild(),this.elements.rootMenu.focusLastNode()):"Asterisk"===t&&(u(e),this.openChildren())}else u(e),this.elements.rootMenu.currentEvent="character",this.focusNextNodeWithCharacter(e.key)}))}focusLastNode(){const e=this.elements.menuItems.length-1,t=this.elements.menuItems[e];t.isSubmenuItem&&t.elements.toggle.isOpen?(this.currentChild=e,t.elements.childMenu.currentEvent=this.currentEvent,t.elements.childMenu.focusLastNode()):this.focusLastChild()}openChildren(){this.elements.submenuToggles.forEach((e=>e.preview()))}focusNextNodeWithCharacter(e){const t=e.toLowerCase(),n=function e(t){let n=[];return t.elements.menuItems.forEach((t=>{n.push(t),t.isSubmenuItem&&t.elements.toggle.isOpen&&(n=[...n,...e(t.elements.toggle.elements.controlledMenu)])})),n}(this.elements.rootMenu),s=n.indexOf(this.currentMenuItem)+1,l=[...n.slice(s),...n.slice(0,s)];let i=0,o=!1;for(;!o&&i<l.length;){let e="";if(e=l[i].dom.item.innerText?l[i].dom.item.innerText:l[i].dom.item.textContent,e=e.replace(/[\s]/g,"").toLowerCase().charAt(0),e===t){o=!0;const e=l[i].elements.parentMenu,t=e.elements.menuItems.indexOf(l[i]);this.elements.rootMenu.blurChildren(),e.focusChild(t)}i++}}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 T extends y{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l=!1,childMenu:i=null,toggle:o=null,initialize:r=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l,childMenu:i,toggle:o,initialize:!1}),r&&this.initialize()}}class S extends I{_dom={toggle:null,parent:null,container:null};constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l=null,initialize:i=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l,initialize:!1}),this._dom.toggle=t,this._dom.parent=n,this._dom.container=s.isTopLevel?s.dom.container:s.dom.menu,i&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),""!==n&&("string"==typeof n?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class w extends _{_MenuType=w;_MenuItemType=T;_MenuToggleType=S;constructor(e){let{menuElement:t,menuItemSelector:n=".nav-item,li",menuLinkSelector:s=".nav-link,.dropdown-item",submenuItemSelector:l=".dropdown",submenuToggleSelector:i=".dropdown-toggle",submenuSelector:o=".dropdown-menu",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="collapse",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,initialize:g=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:l,submenuToggleSelector:i,submenuSelector:o,controllerElement:r,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p,initialize:!1}),g&&this.initialize()}}return{Bootstrap5DisclosureMenu:g,Bootstrap5Menubar:C,Bootstrap5Treeview:w}}();
//# sourceMappingURL=accessible-menu-bs5.min.js.map

@@ -158,6 +158,24 @@ function isValidInstance(contructor, elements) {

function _defineProperty$5(obj, key, value) { key = _toPropertyKey$5(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$5(arg) { var key = _toPrimitive$5(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$5(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenuToggle {
_dom = {
toggle: null,
parent: null
};
_elements = {
controlledMenu: null,
parentMenu: null
};
_open = false;
_expandEvent = new CustomEvent("accessibleMenuExpand", {
bubbles: true,
detail: {
toggle: this
}
});
_collapseEvent = new CustomEvent("accessibleMenuCollapse", {
bubbles: true,
detail: {
toggle: this
}
});
constructor(_ref) {

@@ -170,23 +188,2 @@ let {

} = _ref;
_defineProperty$5(this, "_dom", {
toggle: null,
parent: null
});
_defineProperty$5(this, "_elements", {
controlledMenu: null,
parentMenu: null
});
_defineProperty$5(this, "_open", false);
_defineProperty$5(this, "_expandEvent", new CustomEvent("accessibleMenuExpand", {
bubbles: true,
detail: {
toggle: this
}
}));
_defineProperty$5(this, "_collapseEvent", new CustomEvent("accessibleMenuCollapse", {
bubbles: true,
detail: {
toggle: this
}
}));
this._dom.toggle = menuToggleElement;

@@ -336,6 +333,13 @@ this._dom.parent = parentElement;

function _defineProperty$4(obj, key, value) { key = _toPropertyKey$4(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$4(arg) { var key = _toPrimitive$4(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$4(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenuItem {
_dom = {
item: null,
link: null
};
_elements = {
parentMenu: null,
childMenu: null,
toggle: null
};
_submenu = false;
constructor(_ref) {

@@ -350,12 +354,2 @@ let {

} = _ref;
_defineProperty$4(this, "_dom", {
item: null,
link: null
});
_defineProperty$4(this, "_elements", {
parentMenu: null,
childMenu: null,
toggle: null
});
_defineProperty$4(this, "_submenu", false);
this._dom.item = menuItemElement;

@@ -417,6 +411,37 @@ this._dom.link = menuLinkElement;

function _defineProperty$3(obj, key, value) { key = _toPropertyKey$3(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$3(arg) { var key = _toPrimitive$3(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$3(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenu {
_MenuType = BaseMenu;
_MenuItemType = BaseMenuItem;
_MenuToggleType = BaseMenuToggle;
_dom = {
menu: null,
menuItems: [],
submenuItems: [],
submenuToggles: [],
submenus: [],
controller: null,
container: null
};
_selectors = {
menuItems: "",
menuLinks: "",
submenuItems: "",
submenuToggles: "",
submenus: ""
};
_elements = {
menuItems: [],
submenuToggles: [],
controller: null,
parentMenu: null,
rootMenu: null
};
_openClass = "show";
_closeClass = "hide";
_root = true;
_currentChild = 0;
_focusState = "none";
_currentEvent = "none";
_hoverType = "off";
_hoverDelay = 250;
constructor(_ref) {

@@ -439,36 +464,2 @@ let {

} = _ref;
_defineProperty$3(this, "_MenuType", BaseMenu);
_defineProperty$3(this, "_MenuItemType", BaseMenuItem);
_defineProperty$3(this, "_MenuToggleType", BaseMenuToggle);
_defineProperty$3(this, "_dom", {
menu: null,
menuItems: [],
submenuItems: [],
submenuToggles: [],
submenus: [],
controller: null,
container: null
});
_defineProperty$3(this, "_selectors", {
menuItems: "",
menuLinks: "",
submenuItems: "",
submenuToggles: "",
submenus: ""
});
_defineProperty$3(this, "_elements", {
menuItems: [],
submenuToggles: [],
controller: null,
parentMenu: null,
rootMenu: null
});
_defineProperty$3(this, "_openClass", "show");
_defineProperty$3(this, "_closeClass", "hide");
_defineProperty$3(this, "_root", true);
_defineProperty$3(this, "_currentChild", 0);
_defineProperty$3(this, "_focusState", "none");
_defineProperty$3(this, "_currentEvent", "none");
_defineProperty$3(this, "_hoverType", "off");
_defineProperty$3(this, "_hoverDelay", 250);
this._dom.menu = menuElement;

@@ -926,4 +917,6 @@ this._dom.controller = controllerElement;

preventEvent(event);
this.elements.controller.open();
this.focusFirstChild();
this.elements.controller.toggle();
if (this.elements.controller.isOpen) {
this.focusFirstChild();
}
}

@@ -1071,6 +1064,8 @@ });

function _defineProperty$2(obj, key, value) { key = _toPropertyKey$2(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$2(arg) { var key = _toPrimitive$2(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$2(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class DisclosureMenu extends BaseMenu {
_MenuType = DisclosureMenu;
_MenuItemType = DisclosureMenuItem;
_MenuToggleType = DisclosureMenuToggle;
_currentChild = -1;
_optionalSupport = false;
constructor(_ref) {

@@ -1111,7 +1106,2 @@ let {

});
_defineProperty$2(this, "_MenuType", DisclosureMenu);
_defineProperty$2(this, "_MenuItemType", DisclosureMenuItem);
_defineProperty$2(this, "_MenuToggleType", DisclosureMenuToggle);
_defineProperty$2(this, "_currentChild", -1);
_defineProperty$2(this, "_optionalSupport", false);
this._optionalSupport = optionalKeySupport;

@@ -1273,6 +1263,8 @@ if (initialize) {

function _defineProperty$1(obj, key, value) { key = _toPropertyKey$1(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$1(arg) { var key = _toPrimitive$1(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$1(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Bootstrap5DisclosureMenuToggle extends DisclosureMenuToggle {
_dom = {
toggle: null,
parent: null,
container: null
};
constructor(_ref) {

@@ -1293,7 +1285,2 @@ let {

});
_defineProperty$1(this, "_dom", {
toggle: null,
parent: null,
container: null
});
this._dom.toggle = menuToggleElement;

@@ -1359,6 +1346,6 @@ this._dom.parent = parentElement;

function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Bootstrap5DisclosureMenu extends DisclosureMenu {
_MenuType = Bootstrap5DisclosureMenu;
_MenuItemType = Bootstrap5DisclosureMenuItem;
_MenuToggleType = Bootstrap5DisclosureMenuToggle;
constructor(_ref) {

@@ -1401,5 +1388,2 @@ let {

});
_defineProperty(this, "_MenuType", Bootstrap5DisclosureMenu);
_defineProperty(this, "_MenuItemType", Bootstrap5DisclosureMenuItem);
_defineProperty(this, "_MenuToggleType", Bootstrap5DisclosureMenuToggle);
if (initialize) {

@@ -1406,0 +1390,0 @@ this.initialize();

@@ -1,2 +0,2 @@

function e(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ${typeof t} given.`)}for(const n in t)if(!(t[n]instanceof e)){const s=typeof t[n];throw new TypeError(`AccessibleMenu: ${n} must be an instance of ${e.name}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function t(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Values given to isValidType() must be inside of an object. ${typeof t} given.`)}for(const n in t){const s=typeof t[n];if(s!==e)throw new TypeError(`AccessibleMenu: ${n} must be a ${e}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function n(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ${typeof e} given.`)}for(const t in e)try{if(null===e[t])throw new Error;document.querySelector(e[t])}catch(n){throw new TypeError(`AccessibleMenu: ${t} must be a valid CSS selector. "${e[t]}" given.`)}return!0}catch(e){return console.error(e),!1}}function s(e){try{if("object"!=typeof e||Array.isArray(e)){throw new TypeError(`AccessibleMenu: Values given to isValidClassList() must be inside of an object. ${typeof e} given.`)}for(const t in e){const s=typeof e[t];if("string"!==s){if(!Array.isArray(e[t]))throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. ${s} given.`);e[t].forEach((e=>{if("string"!=typeof e)throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. An array containing non-strings given.`)}))}else{const s={};s[t]=e[t],n(s)}}return!0}catch(e){return console.error(e),!1}}function o(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ${typeof e} given.`)}const t=["off","on","dynamic"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}function i(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class r{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o=null}=e;i(this,"_dom",{toggle:null,parent:null}),i(this,"_elements",{controlledMenu:null,parentMenu:null}),i(this,"_open",!1),i(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}})),i(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}})),this._dom.toggle=t,this._dom.parent=n,this._elements.controlledMenu=s,this._elements.parentMenu=o}initialize(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(n,s){if(t("string",{tagName:n})&&e(HTMLElement,s)){const e=n.toLowerCase();let t=!0;for(const n in s)s[n].tagName.toLowerCase()!==e&&(t=!1);return t}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){const e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&(t=t.toLowerCase().replace(/\s+/g,"-"),t.startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n=`${t}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){t("boolean",{value:e}),this._open=e}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.add(n):this.elements.controlledMenu.dom.menu.classList.add(...n)),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.remove(t):this.elements.controlledMenu.dom.menu.classList.remove(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.add(t):this.elements.controlledMenu.dom.menu.classList.add(...t)),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.remove(n):this.elements.controlledMenu.dom.menu.classList.remove(...n)),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.currentChild=0,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()))}}function l(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class u{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o=!1,childMenu:i=null,toggle:r=null}=e;l(this,"_dom",{item:null,link:null}),l(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),l(this,"_submenu",!1),this._dom.item=t,this._dom.link=n,this._elements.parentMenu=s,this._elements.childMenu=i,this._elements.toggle=r,this._submenu=o}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 m(e){try{const t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((e=>!0===n[e]))||""}catch(e){return""}}function h(e){e.preventDefault(),e.stopPropagation()}function c(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class a{constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:o="",submenuToggleSelector:i="a",submenuSelector:l="ul",controllerElement:m=null,containerElement:h=null,openClass:d="show",closeClass:p="hide",isTopLevel:g=!0,parentMenu:f=null,hoverType:b="off",hoverDelay:v=250}=e;c(this,"_MenuType",a),c(this,"_MenuItemType",u),c(this,"_MenuToggleType",r),c(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null}),c(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""}),c(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null}),c(this,"_openClass","show"),c(this,"_closeClass","hide"),c(this,"_root",!0),c(this,"_currentChild",0),c(this,"_focusState","none"),c(this,"_currentEvent","none"),c(this,"_hoverType","off"),c(this,"_hoverDelay",250),this._dom.menu=t,this._dom.controller=m,this._dom.container=h,this._selectors.menuItems=n,this._selectors.menuLinks=s,this._selectors.submenuItems=o,this._selectors.submenuToggles=i,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=f,this._elements.rootMenu=g?this:null,this._openClass=d||"",this._closeClass=p||"",this._root=g,this._hoverType=b,this._hoverDelay=v}initialize(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&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 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 shouldFocus(){let e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}set openClass(e){s({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){s({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set currentChild(e){function n(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu){let t=0,n=!1;for(;!n&&t<e.elements.parentMenu.elements.menuItems.length;){const s=e.elements.parentMenu.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}}t("number",{value:e}),e<-1?(this._currentChild=-1,n(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,n(this)):this.focusChild!==e&&(this._currentChild=e,n(this))}set focusState(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidState() must be inside of an object. ${typeof e} given.`);const t=["none","self","child"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&("self"===e||"none"===e)&&this.elements.submenuToggles.forEach((e=>{e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==e&&"child"!==e||(this.elements.parentMenu.focusState="child")}set currentEvent(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidEvent() must be inside of an object. ${typeof e} given.`);const t=["none","mouse","keyboard","character"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({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){t("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}_validate(){let i=!0;return null!==this._dom.container||null!==this._dom.controller?e(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(i=!1):e(HTMLElement,{menuElement:this._dom.menu})||(i=!1),""!==this._selectors.submenuItems?n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(i=!1):n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(i=!1),""===this._openClass||s({openClass:this._openClass})||(i=!1),""===this._closeClass||s({closeClass:this._closeClass})||(i=!1),t("boolean",{isTopLevel:this._root})||(i=!1),null===this._elements.parentMenu||e(a,{parentMenu:this._elements.parentMenu})||(i=!1),o({hoverType:this._hoverType})||(i=!1),t("number",{hoverDelay:this._hoverDelay})||(i=!1),i}_setDOMElementType(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[t])throw new Error(`AccessibleMenu: "${t}" is not a valid element type within the menu.`);{if(!Array.isArray(this.dom[t]))throw new Error(`AccessibleMenu: The "${t}" element cannot be set through _setDOMElementType.`);n!==this.dom.menu&&e(HTMLElement,{base:n});const o=Array.from(n.querySelectorAll(this.selectors[t])).filter((e=>e.parentElement===n));this._dom[t]=s?o:[...this._dom[t],...o]}}_resetDOMElementType(e){if(void 0===this.dom[e])throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`);if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}_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(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}_createChildElements(){this.dom.menuItems.forEach((e=>{let t;if(this.dom.submenuItems.includes(e)){const n=e.querySelector(this.selectors.submenuToggles),s=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:s,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,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),i=new this._MenuToggleType({menuToggleElement:n,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(i),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:i})}else{const n=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,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(e,t,n){h(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach(((t,n)=>{t.dom.link.addEventListener("pointerdown",(()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(n)}),{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",(n=>{if("pen"!==n.pointerType&&"touch"!==n.pointerType)if("on"===this.hoverType)this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&e.elements.toggle.preview();else if("dynamic"===this.hoverType){const n=this.elements.submenuToggles.some((e=>e.isOpen));this.currentChild=t,this.isTopLevel&&"none"===this.focusState||(this.currentEvent="mouse",this.focusCurrentChild()),!e.isSubmenuItem||this.isTopLevel&&!n||(this.currentEvent="mouse",e.elements.toggle.preview())}})),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",(t=>{"pen"!==t.pointerType&&"touch"!==t.pointerType&&("on"===this.hoverType?this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close()}),this.hoverDelay):(this.currentEvent="mouse",e.elements.toggle.close()):"dynamic"===this.hoverType&&(this.isTopLevel||(this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()}),this.hoverDelay):(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=m(e);"Space"!==t&&"Enter"!==t||h(e)}))}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=m(e);"Space"!==t&&"Enter"!==t||(h(e),this.elements.controller.open(),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",-1!==this.currentChild&&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",-1!==this.currentChild&&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 d extends u{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o=!1,childMenu:i=null,toggle:r=null,initialize:l=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o,childMenu:i,toggle:r}),l&&this.initialize()}}class p extends r{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o=null,initialize:i=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o}),i&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}function g(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class f extends a{constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:o="",submenuToggleSelector:i="a",submenuSelector:r="ul",controllerElement:l=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:b="off",hoverDelay:v=250,optionalKeySupport:y=!1,initialize:_=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:o,submenuToggleSelector:i,submenuSelector:r,controllerElement:l,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:b,hoverDelay:v}),g(this,"_MenuType",f),g(this,"_MenuItemType",d),g(this,"_MenuToggleType",p),g(this,"_currentChild",-1),g(this,"_optionalSupport",!1),this._optionalSupport=y,_&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(e){console.error(e)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(e){t("boolean",{optionalKeySupport:e}),this._optionalSupport=e}_validate(){let e=super._validate();return t("boolean",{optionalKeySupport:this._optionalSupport})||(e=!1),e}_handleClick(){super._handleClick(),document.addEventListener("pointerup",(e=>{"none"!==this.focusState&&(this.currentEvent="mouse",this.dom.menu.contains(e.target)||!this.dom.menu===e.target||(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))}))}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",(e=>{this.currentEvent="keyboard";const t=m(e);if("self"===this.focusState){const n=["Space","Enter"],s=["Escape"],o=["Escape"];if(this.optionalKeySupport){["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(t)&&h(e)}else(this.currentMenuItem.isSubmenuItem&&n.includes(t)||this.elements.controller&&s.includes(t)||this.elements.parentMenu&&o.includes(t))&&h(e)}}))}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=m(e);if("self"===this.focusState)if("Space"===t||"Enter"===t)this.currentMenuItem.isSubmenuItem?(h(e),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click();else if("Escape"===t){this.elements.submenuToggles.some((e=>e.isOpen))?(h(e),this.closeChildren()):this.elements.parentMenu?(h(e),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())}else this.optionalKeySupport&&("ArrowDown"===t||"ArrowRight"===t?(h(e),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):"ArrowUp"===t||"ArrowLeft"===t?(h(e),this.focusPreviousChild()):"Home"===t?(h(e),this.focusFirstChild()):"End"===t&&(h(e),this.focusLastChild()))}))}}class b extends d{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o=!1,childMenu:i=null,toggle:r=null,initialize:l=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o,childMenu:i,toggle:r,initialize:!1}),l&&this.initialize()}}function v(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class y extends p{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o=null,initialize:i=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o,initialize:!1}),v(this,"_dom",{toggle:null,parent:null,container:null}),this._dom.toggle=t,this._dom.parent=n,this._dom.container=s.isTopLevel?s.dom.container:s.dom.menu,i&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),""!==n&&("string"==typeof n?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}function _(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class E extends f{constructor(e){let{menuElement:t,menuItemSelector:n=".nav-item,li",menuLinkSelector:s=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:i=".dropdown-toggle",submenuSelector:r=".dropdown-menu",controllerElement:l=null,containerElement:u=null,openClass:m="show",closeClass:h="collapse",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,optionalKeySupport:g=!1,initialize:f=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:o,submenuToggleSelector:i,submenuSelector:r,controllerElement:l,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p,optionalKeySupport:g,initialize:!1}),_(this,"_MenuType",E),_(this,"_MenuItemType",b),_(this,"_MenuToggleType",y),f&&this.initialize()}}export{E as default};
function e(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ${typeof t} given.`)}for(const n in t)if(!(t[n]instanceof e)){const s=typeof t[n];throw new TypeError(`AccessibleMenu: ${n} must be an instance of ${e.name}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function t(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Values given to isValidType() must be inside of an object. ${typeof t} given.`)}for(const n in t){const s=typeof t[n];if(s!==e)throw new TypeError(`AccessibleMenu: ${n} must be a ${e}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function n(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ${typeof e} given.`)}for(const t in e)try{if(null===e[t])throw new Error;document.querySelector(e[t])}catch(n){throw new TypeError(`AccessibleMenu: ${t} must be a valid CSS selector. "${e[t]}" given.`)}return!0}catch(e){return console.error(e),!1}}function s(e){try{if("object"!=typeof e||Array.isArray(e)){throw new TypeError(`AccessibleMenu: Values given to isValidClassList() must be inside of an object. ${typeof e} given.`)}for(const t in e){const s=typeof e[t];if("string"!==s){if(!Array.isArray(e[t]))throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. ${s} given.`);e[t].forEach((e=>{if("string"!=typeof e)throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. An array containing non-strings given.`)}))}else{const s={};s[t]=e[t],n(s)}}return!0}catch(e){return console.error(e),!1}}function o(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ${typeof e} given.`)}const t=["off","on","dynamic"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}class l{_dom={toggle:null,parent:null};_elements={controlledMenu:null,parentMenu:null};_open=!1;_expandEvent=new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}});_collapseEvent=new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}});constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o=null}=e;this._dom.toggle=t,this._dom.parent=n,this._elements.controlledMenu=s,this._elements.parentMenu=o}initialize(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(n,s){if(t("string",{tagName:n})&&e(HTMLElement,s)){const e=n.toLowerCase();let t=!0;for(const n in s)s[n].tagName.toLowerCase()!==e&&(t=!1);return t}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){const e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&(t=t.toLowerCase().replace(/\s+/g,"-"),t.startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n=`${t}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){t("boolean",{value:e}),this._open=e}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.add(n):this.elements.controlledMenu.dom.menu.classList.add(...n)),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.remove(t):this.elements.controlledMenu.dom.menu.classList.remove(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.add(t):this.elements.controlledMenu.dom.menu.classList.add(...t)),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.remove(n):this.elements.controlledMenu.dom.menu.classList.remove(...n)),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.currentChild=0,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 i{_dom={item:null,link:null};_elements={parentMenu:null,childMenu:null,toggle:null};_submenu=!1;constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o=!1,childMenu:l=null,toggle:i=null}=e;this._dom.item=t,this._dom.link=n,this._elements.parentMenu=s,this._elements.childMenu=l,this._elements.toggle=i,this._submenu=o}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 r(e){try{const t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((e=>!0===n[e]))||""}catch(e){return""}}function u(e){e.preventDefault(),e.stopPropagation()}class m{_MenuType=m;_MenuItemType=i;_MenuToggleType=l;_dom={menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null};_selectors={menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""};_elements={menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null};_openClass="show";_closeClass="hide";_root=!0;_currentChild=0;_focusState="none";_currentEvent="none";_hoverType="off";_hoverDelay=250;constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:o="",submenuToggleSelector:l="a",submenuSelector:i="ul",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250}=e;this._dom.menu=t,this._dom.controller=r,this._dom.container=u,this._selectors.menuItems=n,this._selectors.menuLinks=s,this._selectors.submenuItems=o,this._selectors.submenuToggles=l,this._selectors.submenus=i,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=a,this._elements.rootMenu=c?this:null,this._openClass=m||"",this._closeClass=h||"",this._root=c,this._hoverType=d,this._hoverDelay=p}initialize(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&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 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 shouldFocus(){let e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}set openClass(e){s({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){s({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set currentChild(e){function n(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu){let t=0,n=!1;for(;!n&&t<e.elements.parentMenu.elements.menuItems.length;){const s=e.elements.parentMenu.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}}t("number",{value:e}),e<-1?(this._currentChild=-1,n(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,n(this)):this.focusChild!==e&&(this._currentChild=e,n(this))}set focusState(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidState() must be inside of an object. ${typeof e} given.`);const t=["none","self","child"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&("self"===e||"none"===e)&&this.elements.submenuToggles.forEach((e=>{e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==e&&"child"!==e||(this.elements.parentMenu.focusState="child")}set currentEvent(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidEvent() must be inside of an object. ${typeof e} given.`);const t=["none","mouse","keyboard","character"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({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){t("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}_validate(){let l=!0;return null!==this._dom.container||null!==this._dom.controller?e(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(l=!1):e(HTMLElement,{menuElement:this._dom.menu})||(l=!1),""!==this._selectors.submenuItems?n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(l=!1):n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(l=!1),""===this._openClass||s({openClass:this._openClass})||(l=!1),""===this._closeClass||s({closeClass:this._closeClass})||(l=!1),t("boolean",{isTopLevel:this._root})||(l=!1),null===this._elements.parentMenu||e(m,{parentMenu:this._elements.parentMenu})||(l=!1),o({hoverType:this._hoverType})||(l=!1),t("number",{hoverDelay:this._hoverDelay})||(l=!1),l}_setDOMElementType(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[t])throw new Error(`AccessibleMenu: "${t}" is not a valid element type within the menu.`);{if(!Array.isArray(this.dom[t]))throw new Error(`AccessibleMenu: The "${t}" element cannot be set through _setDOMElementType.`);n!==this.dom.menu&&e(HTMLElement,{base:n});const o=Array.from(n.querySelectorAll(this.selectors[t])).filter((e=>e.parentElement===n));this._dom[t]=s?o:[...this._dom[t],...o]}}_resetDOMElementType(e){if(void 0===this.dom[e])throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`);if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}_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(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}_createChildElements(){this.dom.menuItems.forEach((e=>{let t;if(this.dom.submenuItems.includes(e)){const n=e.querySelector(this.selectors.submenuToggles),s=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:s,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,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),l=new this._MenuToggleType({menuToggleElement:n,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:l})}else{const n=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,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(e,t,n){u(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach(((t,n)=>{t.dom.link.addEventListener("pointerdown",(()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(n)}),{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",(n=>{if("pen"!==n.pointerType&&"touch"!==n.pointerType)if("on"===this.hoverType)this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&e.elements.toggle.preview();else if("dynamic"===this.hoverType){const n=this.elements.submenuToggles.some((e=>e.isOpen));this.currentChild=t,this.isTopLevel&&"none"===this.focusState||(this.currentEvent="mouse",this.focusCurrentChild()),!e.isSubmenuItem||this.isTopLevel&&!n||(this.currentEvent="mouse",e.elements.toggle.preview())}})),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",(t=>{"pen"!==t.pointerType&&"touch"!==t.pointerType&&("on"===this.hoverType?this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close()}),this.hoverDelay):(this.currentEvent="mouse",e.elements.toggle.close()):"dynamic"===this.hoverType&&(this.isTopLevel||(this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()}),this.hoverDelay):(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=r(e);"Space"!==t&&"Enter"!==t||u(e)}))}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=r(e);"Space"!==t&&"Enter"!==t||(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",-1!==this.currentChild&&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",-1!==this.currentChild&&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 h extends i{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o=!1,childMenu:l=null,toggle:i=null,initialize:r=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o,childMenu:l,toggle:i}),r&&this.initialize()}}class c extends l{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o=null,initialize:l=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o}),l&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class a extends m{_MenuType=a;_MenuItemType=h;_MenuToggleType=c;_currentChild=-1;_optionalSupport=!1;constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:o="",submenuToggleSelector:l="a",submenuSelector:i="ul",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,optionalKeySupport:g=!1,initialize:f=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:i,controllerElement:r,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p}),this._optionalSupport=g,f&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(e){console.error(e)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(e){t("boolean",{optionalKeySupport:e}),this._optionalSupport=e}_validate(){let e=super._validate();return t("boolean",{optionalKeySupport:this._optionalSupport})||(e=!1),e}_handleClick(){super._handleClick(),document.addEventListener("pointerup",(e=>{"none"!==this.focusState&&(this.currentEvent="mouse",this.dom.menu.contains(e.target)||!this.dom.menu===e.target||(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))}))}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",(e=>{this.currentEvent="keyboard";const t=r(e);if("self"===this.focusState){const n=["Space","Enter"],s=["Escape"],o=["Escape"];if(this.optionalKeySupport){["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(t)&&u(e)}else(this.currentMenuItem.isSubmenuItem&&n.includes(t)||this.elements.controller&&s.includes(t)||this.elements.parentMenu&&o.includes(t))&&u(e)}}))}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=r(e);if("self"===this.focusState)if("Space"===t||"Enter"===t)this.currentMenuItem.isSubmenuItem?(u(e),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click();else if("Escape"===t){this.elements.submenuToggles.some((e=>e.isOpen))?(u(e),this.closeChildren()):this.elements.parentMenu?(u(e),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())}else this.optionalKeySupport&&("ArrowDown"===t||"ArrowRight"===t?(u(e),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):"ArrowUp"===t||"ArrowLeft"===t?(u(e),this.focusPreviousChild()):"Home"===t?(u(e),this.focusFirstChild()):"End"===t&&(u(e),this.focusLastChild()))}))}}class d extends h{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o=!1,childMenu:l=null,toggle:i=null,initialize:r=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o,childMenu:l,toggle:i,initialize:!1}),r&&this.initialize()}}class p extends c{_dom={toggle:null,parent:null,container:null};constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o=null,initialize:l=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o,initialize:!1}),this._dom.toggle=t,this._dom.parent=n,this._dom.container=s.isTopLevel?s.dom.container:s.dom.menu,l&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),""!==n&&("string"==typeof n?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class g extends a{_MenuType=g;_MenuItemType=d;_MenuToggleType=p;constructor(e){let{menuElement:t,menuItemSelector:n=".nav-item,li",menuLinkSelector:s=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:i=".dropdown-menu",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="collapse",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,optionalKeySupport:g=!1,initialize:f=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:i,controllerElement:r,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p,optionalKeySupport:g,initialize:!1}),f&&this.initialize()}}export{g as default};
//# sourceMappingURL=disclosure-menu-bs5.esm.min.js.map

@@ -161,6 +161,24 @@ var Bootstrap5DisclosureMenu = (function () {

function _defineProperty$5(obj, key, value) { key = _toPropertyKey$5(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$5(arg) { var key = _toPrimitive$5(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$5(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenuToggle {
_dom = {
toggle: null,
parent: null
};
_elements = {
controlledMenu: null,
parentMenu: null
};
_open = false;
_expandEvent = new CustomEvent("accessibleMenuExpand", {
bubbles: true,
detail: {
toggle: this
}
});
_collapseEvent = new CustomEvent("accessibleMenuCollapse", {
bubbles: true,
detail: {
toggle: this
}
});
constructor(_ref) {

@@ -173,23 +191,2 @@ let {

} = _ref;
_defineProperty$5(this, "_dom", {
toggle: null,
parent: null
});
_defineProperty$5(this, "_elements", {
controlledMenu: null,
parentMenu: null
});
_defineProperty$5(this, "_open", false);
_defineProperty$5(this, "_expandEvent", new CustomEvent("accessibleMenuExpand", {
bubbles: true,
detail: {
toggle: this
}
}));
_defineProperty$5(this, "_collapseEvent", new CustomEvent("accessibleMenuCollapse", {
bubbles: true,
detail: {
toggle: this
}
}));
this._dom.toggle = menuToggleElement;

@@ -339,6 +336,13 @@ this._dom.parent = parentElement;

function _defineProperty$4(obj, key, value) { key = _toPropertyKey$4(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$4(arg) { var key = _toPrimitive$4(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$4(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenuItem {
_dom = {
item: null,
link: null
};
_elements = {
parentMenu: null,
childMenu: null,
toggle: null
};
_submenu = false;
constructor(_ref) {

@@ -353,12 +357,2 @@ let {

} = _ref;
_defineProperty$4(this, "_dom", {
item: null,
link: null
});
_defineProperty$4(this, "_elements", {
parentMenu: null,
childMenu: null,
toggle: null
});
_defineProperty$4(this, "_submenu", false);
this._dom.item = menuItemElement;

@@ -420,6 +414,37 @@ this._dom.link = menuLinkElement;

function _defineProperty$3(obj, key, value) { key = _toPropertyKey$3(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$3(arg) { var key = _toPrimitive$3(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$3(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenu {
_MenuType = BaseMenu;
_MenuItemType = BaseMenuItem;
_MenuToggleType = BaseMenuToggle;
_dom = {
menu: null,
menuItems: [],
submenuItems: [],
submenuToggles: [],
submenus: [],
controller: null,
container: null
};
_selectors = {
menuItems: "",
menuLinks: "",
submenuItems: "",
submenuToggles: "",
submenus: ""
};
_elements = {
menuItems: [],
submenuToggles: [],
controller: null,
parentMenu: null,
rootMenu: null
};
_openClass = "show";
_closeClass = "hide";
_root = true;
_currentChild = 0;
_focusState = "none";
_currentEvent = "none";
_hoverType = "off";
_hoverDelay = 250;
constructor(_ref) {

@@ -442,36 +467,2 @@ let {

} = _ref;
_defineProperty$3(this, "_MenuType", BaseMenu);
_defineProperty$3(this, "_MenuItemType", BaseMenuItem);
_defineProperty$3(this, "_MenuToggleType", BaseMenuToggle);
_defineProperty$3(this, "_dom", {
menu: null,
menuItems: [],
submenuItems: [],
submenuToggles: [],
submenus: [],
controller: null,
container: null
});
_defineProperty$3(this, "_selectors", {
menuItems: "",
menuLinks: "",
submenuItems: "",
submenuToggles: "",
submenus: ""
});
_defineProperty$3(this, "_elements", {
menuItems: [],
submenuToggles: [],
controller: null,
parentMenu: null,
rootMenu: null
});
_defineProperty$3(this, "_openClass", "show");
_defineProperty$3(this, "_closeClass", "hide");
_defineProperty$3(this, "_root", true);
_defineProperty$3(this, "_currentChild", 0);
_defineProperty$3(this, "_focusState", "none");
_defineProperty$3(this, "_currentEvent", "none");
_defineProperty$3(this, "_hoverType", "off");
_defineProperty$3(this, "_hoverDelay", 250);
this._dom.menu = menuElement;

@@ -929,4 +920,6 @@ this._dom.controller = controllerElement;

preventEvent(event);
this.elements.controller.open();
this.focusFirstChild();
this.elements.controller.toggle();
if (this.elements.controller.isOpen) {
this.focusFirstChild();
}
}

@@ -1074,6 +1067,8 @@ });

function _defineProperty$2(obj, key, value) { key = _toPropertyKey$2(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$2(arg) { var key = _toPrimitive$2(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$2(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class DisclosureMenu extends BaseMenu {
_MenuType = DisclosureMenu;
_MenuItemType = DisclosureMenuItem;
_MenuToggleType = DisclosureMenuToggle;
_currentChild = -1;
_optionalSupport = false;
constructor(_ref) {

@@ -1114,7 +1109,2 @@ let {

});
_defineProperty$2(this, "_MenuType", DisclosureMenu);
_defineProperty$2(this, "_MenuItemType", DisclosureMenuItem);
_defineProperty$2(this, "_MenuToggleType", DisclosureMenuToggle);
_defineProperty$2(this, "_currentChild", -1);
_defineProperty$2(this, "_optionalSupport", false);
this._optionalSupport = optionalKeySupport;

@@ -1276,6 +1266,8 @@ if (initialize) {

function _defineProperty$1(obj, key, value) { key = _toPropertyKey$1(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$1(arg) { var key = _toPrimitive$1(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$1(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Bootstrap5DisclosureMenuToggle extends DisclosureMenuToggle {
_dom = {
toggle: null,
parent: null,
container: null
};
constructor(_ref) {

@@ -1296,7 +1288,2 @@ let {

});
_defineProperty$1(this, "_dom", {
toggle: null,
parent: null,
container: null
});
this._dom.toggle = menuToggleElement;

@@ -1362,6 +1349,6 @@ this._dom.parent = parentElement;

function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Bootstrap5DisclosureMenu extends DisclosureMenu {
_MenuType = Bootstrap5DisclosureMenu;
_MenuItemType = Bootstrap5DisclosureMenuItem;
_MenuToggleType = Bootstrap5DisclosureMenuToggle;
constructor(_ref) {

@@ -1404,5 +1391,2 @@ let {

});
_defineProperty(this, "_MenuType", Bootstrap5DisclosureMenu);
_defineProperty(this, "_MenuItemType", Bootstrap5DisclosureMenuItem);
_defineProperty(this, "_MenuToggleType", Bootstrap5DisclosureMenuToggle);
if (initialize) {

@@ -1409,0 +1393,0 @@ this.initialize();

@@ -1,2 +0,2 @@

var Bootstrap5DisclosureMenu=function(){"use strict";function e(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ${typeof t} given.`)}for(const n in t)if(!(t[n]instanceof e)){const s=typeof t[n];throw new TypeError(`AccessibleMenu: ${n} must be an instance of ${e.name}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function t(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Values given to isValidType() must be inside of an object. ${typeof t} given.`)}for(const n in t){const s=typeof t[n];if(s!==e)throw new TypeError(`AccessibleMenu: ${n} must be a ${e}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function n(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ${typeof e} given.`)}for(const t in e)try{if(null===e[t])throw new Error;document.querySelector(e[t])}catch(n){throw new TypeError(`AccessibleMenu: ${t} must be a valid CSS selector. "${e[t]}" given.`)}return!0}catch(e){return console.error(e),!1}}function s(e){try{if("object"!=typeof e||Array.isArray(e)){throw new TypeError(`AccessibleMenu: Values given to isValidClassList() must be inside of an object. ${typeof e} given.`)}for(const t in e){const s=typeof e[t];if("string"!==s){if(!Array.isArray(e[t]))throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. ${s} given.`);e[t].forEach((e=>{if("string"!=typeof e)throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. An array containing non-strings given.`)}))}else{const s={};s[t]=e[t],n(s)}}return!0}catch(e){return console.error(e),!1}}function o(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ${typeof e} given.`)}const t=["off","on","dynamic"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}function i(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class r{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o=null}=e;i(this,"_dom",{toggle:null,parent:null}),i(this,"_elements",{controlledMenu:null,parentMenu:null}),i(this,"_open",!1),i(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}})),i(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}})),this._dom.toggle=t,this._dom.parent=n,this._elements.controlledMenu=s,this._elements.parentMenu=o}initialize(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(n,s){if(t("string",{tagName:n})&&e(HTMLElement,s)){const e=n.toLowerCase();let t=!0;for(const n in s)s[n].tagName.toLowerCase()!==e&&(t=!1);return t}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){const e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&(t=t.toLowerCase().replace(/\s+/g,"-"),t.startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n=`${t}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){t("boolean",{value:e}),this._open=e}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.add(n):this.elements.controlledMenu.dom.menu.classList.add(...n)),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.remove(t):this.elements.controlledMenu.dom.menu.classList.remove(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.add(t):this.elements.controlledMenu.dom.menu.classList.add(...t)),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.remove(n):this.elements.controlledMenu.dom.menu.classList.remove(...n)),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.currentChild=0,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()))}}function l(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class u{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o=!1,childMenu:i=null,toggle:r=null}=e;l(this,"_dom",{item:null,link:null}),l(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),l(this,"_submenu",!1),this._dom.item=t,this._dom.link=n,this._elements.parentMenu=s,this._elements.childMenu=i,this._elements.toggle=r,this._submenu=o}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 m(e){try{const t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((e=>!0===n[e]))||""}catch(e){return""}}function h(e){e.preventDefault(),e.stopPropagation()}function c(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class a{constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:o="",submenuToggleSelector:i="a",submenuSelector:l="ul",controllerElement:m=null,containerElement:h=null,openClass:d="show",closeClass:p="hide",isTopLevel:g=!0,parentMenu:f=null,hoverType:b="off",hoverDelay:v=250}=e;c(this,"_MenuType",a),c(this,"_MenuItemType",u),c(this,"_MenuToggleType",r),c(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null}),c(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""}),c(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null}),c(this,"_openClass","show"),c(this,"_closeClass","hide"),c(this,"_root",!0),c(this,"_currentChild",0),c(this,"_focusState","none"),c(this,"_currentEvent","none"),c(this,"_hoverType","off"),c(this,"_hoverDelay",250),this._dom.menu=t,this._dom.controller=m,this._dom.container=h,this._selectors.menuItems=n,this._selectors.menuLinks=s,this._selectors.submenuItems=o,this._selectors.submenuToggles=i,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=f,this._elements.rootMenu=g?this:null,this._openClass=d||"",this._closeClass=p||"",this._root=g,this._hoverType=b,this._hoverDelay=v}initialize(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&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 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 shouldFocus(){let e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}set openClass(e){s({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){s({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set currentChild(e){function n(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu){let t=0,n=!1;for(;!n&&t<e.elements.parentMenu.elements.menuItems.length;){const s=e.elements.parentMenu.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}}t("number",{value:e}),e<-1?(this._currentChild=-1,n(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,n(this)):this.focusChild!==e&&(this._currentChild=e,n(this))}set focusState(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidState() must be inside of an object. ${typeof e} given.`);const t=["none","self","child"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&("self"===e||"none"===e)&&this.elements.submenuToggles.forEach((e=>{e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==e&&"child"!==e||(this.elements.parentMenu.focusState="child")}set currentEvent(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidEvent() must be inside of an object. ${typeof e} given.`);const t=["none","mouse","keyboard","character"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({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){t("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}_validate(){let i=!0;return null!==this._dom.container||null!==this._dom.controller?e(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(i=!1):e(HTMLElement,{menuElement:this._dom.menu})||(i=!1),""!==this._selectors.submenuItems?n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(i=!1):n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(i=!1),""===this._openClass||s({openClass:this._openClass})||(i=!1),""===this._closeClass||s({closeClass:this._closeClass})||(i=!1),t("boolean",{isTopLevel:this._root})||(i=!1),null===this._elements.parentMenu||e(a,{parentMenu:this._elements.parentMenu})||(i=!1),o({hoverType:this._hoverType})||(i=!1),t("number",{hoverDelay:this._hoverDelay})||(i=!1),i}_setDOMElementType(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[t])throw new Error(`AccessibleMenu: "${t}" is not a valid element type within the menu.`);{if(!Array.isArray(this.dom[t]))throw new Error(`AccessibleMenu: The "${t}" element cannot be set through _setDOMElementType.`);n!==this.dom.menu&&e(HTMLElement,{base:n});const o=Array.from(n.querySelectorAll(this.selectors[t])).filter((e=>e.parentElement===n));this._dom[t]=s?o:[...this._dom[t],...o]}}_resetDOMElementType(e){if(void 0===this.dom[e])throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`);if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}_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(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}_createChildElements(){this.dom.menuItems.forEach((e=>{let t;if(this.dom.submenuItems.includes(e)){const n=e.querySelector(this.selectors.submenuToggles),s=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:s,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,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),i=new this._MenuToggleType({menuToggleElement:n,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(i),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:i})}else{const n=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,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(e,t,n){h(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach(((t,n)=>{t.dom.link.addEventListener("pointerdown",(()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(n)}),{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",(n=>{if("pen"!==n.pointerType&&"touch"!==n.pointerType)if("on"===this.hoverType)this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&e.elements.toggle.preview();else if("dynamic"===this.hoverType){const n=this.elements.submenuToggles.some((e=>e.isOpen));this.currentChild=t,this.isTopLevel&&"none"===this.focusState||(this.currentEvent="mouse",this.focusCurrentChild()),!e.isSubmenuItem||this.isTopLevel&&!n||(this.currentEvent="mouse",e.elements.toggle.preview())}})),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",(t=>{"pen"!==t.pointerType&&"touch"!==t.pointerType&&("on"===this.hoverType?this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close()}),this.hoverDelay):(this.currentEvent="mouse",e.elements.toggle.close()):"dynamic"===this.hoverType&&(this.isTopLevel||(this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()}),this.hoverDelay):(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=m(e);"Space"!==t&&"Enter"!==t||h(e)}))}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=m(e);"Space"!==t&&"Enter"!==t||(h(e),this.elements.controller.open(),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",-1!==this.currentChild&&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",-1!==this.currentChild&&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 d extends u{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o=!1,childMenu:i=null,toggle:r=null,initialize:l=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o,childMenu:i,toggle:r}),l&&this.initialize()}}class p extends r{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o=null,initialize:i=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o}),i&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}function g(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class f extends a{constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:o="",submenuToggleSelector:i="a",submenuSelector:r="ul",controllerElement:l=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:b="off",hoverDelay:v=250,optionalKeySupport:y=!1,initialize:_=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:o,submenuToggleSelector:i,submenuSelector:r,controllerElement:l,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:b,hoverDelay:v}),g(this,"_MenuType",f),g(this,"_MenuItemType",d),g(this,"_MenuToggleType",p),g(this,"_currentChild",-1),g(this,"_optionalSupport",!1),this._optionalSupport=y,_&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(e){console.error(e)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(e){t("boolean",{optionalKeySupport:e}),this._optionalSupport=e}_validate(){let e=super._validate();return t("boolean",{optionalKeySupport:this._optionalSupport})||(e=!1),e}_handleClick(){super._handleClick(),document.addEventListener("pointerup",(e=>{"none"!==this.focusState&&(this.currentEvent="mouse",this.dom.menu.contains(e.target)||!this.dom.menu===e.target||(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))}))}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",(e=>{this.currentEvent="keyboard";const t=m(e);if("self"===this.focusState){const n=["Space","Enter"],s=["Escape"],o=["Escape"];if(this.optionalKeySupport){["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(t)&&h(e)}else(this.currentMenuItem.isSubmenuItem&&n.includes(t)||this.elements.controller&&s.includes(t)||this.elements.parentMenu&&o.includes(t))&&h(e)}}))}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=m(e);if("self"===this.focusState)if("Space"===t||"Enter"===t)this.currentMenuItem.isSubmenuItem?(h(e),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click();else if("Escape"===t){this.elements.submenuToggles.some((e=>e.isOpen))?(h(e),this.closeChildren()):this.elements.parentMenu?(h(e),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())}else this.optionalKeySupport&&("ArrowDown"===t||"ArrowRight"===t?(h(e),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):"ArrowUp"===t||"ArrowLeft"===t?(h(e),this.focusPreviousChild()):"Home"===t?(h(e),this.focusFirstChild()):"End"===t&&(h(e),this.focusLastChild()))}))}}class b extends d{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o=!1,childMenu:i=null,toggle:r=null,initialize:l=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o,childMenu:i,toggle:r,initialize:!1}),l&&this.initialize()}}function v(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class y extends p{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o=null,initialize:i=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o,initialize:!1}),v(this,"_dom",{toggle:null,parent:null,container:null}),this._dom.toggle=t,this._dom.parent=n,this._dom.container=s.isTopLevel?s.dom.container:s.dom.menu,i&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),""!==n&&("string"==typeof n?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}function _(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class E extends f{constructor(e){let{menuElement:t,menuItemSelector:n=".nav-item,li",menuLinkSelector:s=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:i=".dropdown-toggle",submenuSelector:r=".dropdown-menu",controllerElement:l=null,containerElement:u=null,openClass:m="show",closeClass:h="collapse",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,optionalKeySupport:g=!1,initialize:f=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:o,submenuToggleSelector:i,submenuSelector:r,controllerElement:l,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p,optionalKeySupport:g,initialize:!1}),_(this,"_MenuType",E),_(this,"_MenuItemType",b),_(this,"_MenuToggleType",y),f&&this.initialize()}}return E}();
var Bootstrap5DisclosureMenu=function(){"use strict";function e(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ${typeof t} given.`)}for(const n in t)if(!(t[n]instanceof e)){const s=typeof t[n];throw new TypeError(`AccessibleMenu: ${n} must be an instance of ${e.name}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function t(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Values given to isValidType() must be inside of an object. ${typeof t} given.`)}for(const n in t){const s=typeof t[n];if(s!==e)throw new TypeError(`AccessibleMenu: ${n} must be a ${e}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function n(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ${typeof e} given.`)}for(const t in e)try{if(null===e[t])throw new Error;document.querySelector(e[t])}catch(n){throw new TypeError(`AccessibleMenu: ${t} must be a valid CSS selector. "${e[t]}" given.`)}return!0}catch(e){return console.error(e),!1}}function s(e){try{if("object"!=typeof e||Array.isArray(e)){throw new TypeError(`AccessibleMenu: Values given to isValidClassList() must be inside of an object. ${typeof e} given.`)}for(const t in e){const s=typeof e[t];if("string"!==s){if(!Array.isArray(e[t]))throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. ${s} given.`);e[t].forEach((e=>{if("string"!=typeof e)throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. An array containing non-strings given.`)}))}else{const s={};s[t]=e[t],n(s)}}return!0}catch(e){return console.error(e),!1}}function o(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ${typeof e} given.`)}const t=["off","on","dynamic"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}class l{_dom={toggle:null,parent:null};_elements={controlledMenu:null,parentMenu:null};_open=!1;_expandEvent=new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}});_collapseEvent=new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}});constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o=null}=e;this._dom.toggle=t,this._dom.parent=n,this._elements.controlledMenu=s,this._elements.parentMenu=o}initialize(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(n,s){if(t("string",{tagName:n})&&e(HTMLElement,s)){const e=n.toLowerCase();let t=!0;for(const n in s)s[n].tagName.toLowerCase()!==e&&(t=!1);return t}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){const e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&(t=t.toLowerCase().replace(/\s+/g,"-"),t.startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n=`${t}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){t("boolean",{value:e}),this._open=e}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.add(n):this.elements.controlledMenu.dom.menu.classList.add(...n)),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.remove(t):this.elements.controlledMenu.dom.menu.classList.remove(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.add(t):this.elements.controlledMenu.dom.menu.classList.add(...t)),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.remove(n):this.elements.controlledMenu.dom.menu.classList.remove(...n)),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.currentChild=0,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 i{_dom={item:null,link:null};_elements={parentMenu:null,childMenu:null,toggle:null};_submenu=!1;constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o=!1,childMenu:l=null,toggle:i=null}=e;this._dom.item=t,this._dom.link=n,this._elements.parentMenu=s,this._elements.childMenu=l,this._elements.toggle=i,this._submenu=o}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 r(e){try{const t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((e=>!0===n[e]))||""}catch(e){return""}}function u(e){e.preventDefault(),e.stopPropagation()}class m{_MenuType=m;_MenuItemType=i;_MenuToggleType=l;_dom={menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null};_selectors={menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""};_elements={menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null};_openClass="show";_closeClass="hide";_root=!0;_currentChild=0;_focusState="none";_currentEvent="none";_hoverType="off";_hoverDelay=250;constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:o="",submenuToggleSelector:l="a",submenuSelector:i="ul",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250}=e;this._dom.menu=t,this._dom.controller=r,this._dom.container=u,this._selectors.menuItems=n,this._selectors.menuLinks=s,this._selectors.submenuItems=o,this._selectors.submenuToggles=l,this._selectors.submenus=i,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=a,this._elements.rootMenu=c?this:null,this._openClass=m||"",this._closeClass=h||"",this._root=c,this._hoverType=d,this._hoverDelay=p}initialize(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&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 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 shouldFocus(){let e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}set openClass(e){s({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){s({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set currentChild(e){function n(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu){let t=0,n=!1;for(;!n&&t<e.elements.parentMenu.elements.menuItems.length;){const s=e.elements.parentMenu.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}}t("number",{value:e}),e<-1?(this._currentChild=-1,n(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,n(this)):this.focusChild!==e&&(this._currentChild=e,n(this))}set focusState(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidState() must be inside of an object. ${typeof e} given.`);const t=["none","self","child"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&("self"===e||"none"===e)&&this.elements.submenuToggles.forEach((e=>{e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==e&&"child"!==e||(this.elements.parentMenu.focusState="child")}set currentEvent(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidEvent() must be inside of an object. ${typeof e} given.`);const t=["none","mouse","keyboard","character"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({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){t("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}_validate(){let l=!0;return null!==this._dom.container||null!==this._dom.controller?e(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(l=!1):e(HTMLElement,{menuElement:this._dom.menu})||(l=!1),""!==this._selectors.submenuItems?n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(l=!1):n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(l=!1),""===this._openClass||s({openClass:this._openClass})||(l=!1),""===this._closeClass||s({closeClass:this._closeClass})||(l=!1),t("boolean",{isTopLevel:this._root})||(l=!1),null===this._elements.parentMenu||e(m,{parentMenu:this._elements.parentMenu})||(l=!1),o({hoverType:this._hoverType})||(l=!1),t("number",{hoverDelay:this._hoverDelay})||(l=!1),l}_setDOMElementType(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[t])throw new Error(`AccessibleMenu: "${t}" is not a valid element type within the menu.`);{if(!Array.isArray(this.dom[t]))throw new Error(`AccessibleMenu: The "${t}" element cannot be set through _setDOMElementType.`);n!==this.dom.menu&&e(HTMLElement,{base:n});const o=Array.from(n.querySelectorAll(this.selectors[t])).filter((e=>e.parentElement===n));this._dom[t]=s?o:[...this._dom[t],...o]}}_resetDOMElementType(e){if(void 0===this.dom[e])throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`);if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}_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(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}_createChildElements(){this.dom.menuItems.forEach((e=>{let t;if(this.dom.submenuItems.includes(e)){const n=e.querySelector(this.selectors.submenuToggles),s=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:s,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,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),l=new this._MenuToggleType({menuToggleElement:n,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:l})}else{const n=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,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(e,t,n){u(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach(((t,n)=>{t.dom.link.addEventListener("pointerdown",(()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(n)}),{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",(n=>{if("pen"!==n.pointerType&&"touch"!==n.pointerType)if("on"===this.hoverType)this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&e.elements.toggle.preview();else if("dynamic"===this.hoverType){const n=this.elements.submenuToggles.some((e=>e.isOpen));this.currentChild=t,this.isTopLevel&&"none"===this.focusState||(this.currentEvent="mouse",this.focusCurrentChild()),!e.isSubmenuItem||this.isTopLevel&&!n||(this.currentEvent="mouse",e.elements.toggle.preview())}})),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",(t=>{"pen"!==t.pointerType&&"touch"!==t.pointerType&&("on"===this.hoverType?this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close()}),this.hoverDelay):(this.currentEvent="mouse",e.elements.toggle.close()):"dynamic"===this.hoverType&&(this.isTopLevel||(this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()}),this.hoverDelay):(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=r(e);"Space"!==t&&"Enter"!==t||u(e)}))}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=r(e);"Space"!==t&&"Enter"!==t||(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",-1!==this.currentChild&&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",-1!==this.currentChild&&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 h extends i{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o=!1,childMenu:l=null,toggle:i=null,initialize:r=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o,childMenu:l,toggle:i}),r&&this.initialize()}}class c extends l{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o=null,initialize:l=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o}),l&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class a extends m{_MenuType=a;_MenuItemType=h;_MenuToggleType=c;_currentChild=-1;_optionalSupport=!1;constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:o="",submenuToggleSelector:l="a",submenuSelector:i="ul",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,optionalKeySupport:g=!1,initialize:f=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:i,controllerElement:r,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p}),this._optionalSupport=g,f&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(e){console.error(e)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(e){t("boolean",{optionalKeySupport:e}),this._optionalSupport=e}_validate(){let e=super._validate();return t("boolean",{optionalKeySupport:this._optionalSupport})||(e=!1),e}_handleClick(){super._handleClick(),document.addEventListener("pointerup",(e=>{"none"!==this.focusState&&(this.currentEvent="mouse",this.dom.menu.contains(e.target)||!this.dom.menu===e.target||(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))}))}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",(e=>{this.currentEvent="keyboard";const t=r(e);if("self"===this.focusState){const n=["Space","Enter"],s=["Escape"],o=["Escape"];if(this.optionalKeySupport){["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(t)&&u(e)}else(this.currentMenuItem.isSubmenuItem&&n.includes(t)||this.elements.controller&&s.includes(t)||this.elements.parentMenu&&o.includes(t))&&u(e)}}))}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=r(e);if("self"===this.focusState)if("Space"===t||"Enter"===t)this.currentMenuItem.isSubmenuItem?(u(e),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click();else if("Escape"===t){this.elements.submenuToggles.some((e=>e.isOpen))?(u(e),this.closeChildren()):this.elements.parentMenu?(u(e),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())}else this.optionalKeySupport&&("ArrowDown"===t||"ArrowRight"===t?(u(e),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):"ArrowUp"===t||"ArrowLeft"===t?(u(e),this.focusPreviousChild()):"Home"===t?(u(e),this.focusFirstChild()):"End"===t&&(u(e),this.focusLastChild()))}))}}class d extends h{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o=!1,childMenu:l=null,toggle:i=null,initialize:r=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o,childMenu:l,toggle:i,initialize:!1}),r&&this.initialize()}}class p extends c{_dom={toggle:null,parent:null,container:null};constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o=null,initialize:l=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o,initialize:!1}),this._dom.toggle=t,this._dom.parent=n,this._dom.container=s.isTopLevel?s.dom.container:s.dom.menu,l&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),""!==n&&("string"==typeof n?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class g extends a{_MenuType=g;_MenuItemType=d;_MenuToggleType=p;constructor(e){let{menuElement:t,menuItemSelector:n=".nav-item,li",menuLinkSelector:s=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:i=".dropdown-menu",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="collapse",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,optionalKeySupport:g=!1,initialize:f=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:i,controllerElement:r,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p,optionalKeySupport:g,initialize:!1}),f&&this.initialize()}}return g}();
//# sourceMappingURL=disclosure-menu-bs5.min.js.map

@@ -158,6 +158,24 @@ function isValidInstance(contructor, elements) {

function _defineProperty$5(obj, key, value) { key = _toPropertyKey$5(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$5(arg) { var key = _toPrimitive$5(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$5(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenuToggle {
_dom = {
toggle: null,
parent: null
};
_elements = {
controlledMenu: null,
parentMenu: null
};
_open = false;
_expandEvent = new CustomEvent("accessibleMenuExpand", {
bubbles: true,
detail: {
toggle: this
}
});
_collapseEvent = new CustomEvent("accessibleMenuCollapse", {
bubbles: true,
detail: {
toggle: this
}
});
constructor(_ref) {

@@ -170,23 +188,2 @@ let {

} = _ref;
_defineProperty$5(this, "_dom", {
toggle: null,
parent: null
});
_defineProperty$5(this, "_elements", {
controlledMenu: null,
parentMenu: null
});
_defineProperty$5(this, "_open", false);
_defineProperty$5(this, "_expandEvent", new CustomEvent("accessibleMenuExpand", {
bubbles: true,
detail: {
toggle: this
}
}));
_defineProperty$5(this, "_collapseEvent", new CustomEvent("accessibleMenuCollapse", {
bubbles: true,
detail: {
toggle: this
}
}));
this._dom.toggle = menuToggleElement;

@@ -336,6 +333,13 @@ this._dom.parent = parentElement;

function _defineProperty$4(obj, key, value) { key = _toPropertyKey$4(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$4(arg) { var key = _toPrimitive$4(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$4(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenuItem {
_dom = {
item: null,
link: null
};
_elements = {
parentMenu: null,
childMenu: null,
toggle: null
};
_submenu = false;
constructor(_ref) {

@@ -350,12 +354,2 @@ let {

} = _ref;
_defineProperty$4(this, "_dom", {
item: null,
link: null
});
_defineProperty$4(this, "_elements", {
parentMenu: null,
childMenu: null,
toggle: null
});
_defineProperty$4(this, "_submenu", false);
this._dom.item = menuItemElement;

@@ -417,6 +411,37 @@ this._dom.link = menuLinkElement;

function _defineProperty$3(obj, key, value) { key = _toPropertyKey$3(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$3(arg) { var key = _toPrimitive$3(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$3(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenu {
_MenuType = BaseMenu;
_MenuItemType = BaseMenuItem;
_MenuToggleType = BaseMenuToggle;
_dom = {
menu: null,
menuItems: [],
submenuItems: [],
submenuToggles: [],
submenus: [],
controller: null,
container: null
};
_selectors = {
menuItems: "",
menuLinks: "",
submenuItems: "",
submenuToggles: "",
submenus: ""
};
_elements = {
menuItems: [],
submenuToggles: [],
controller: null,
parentMenu: null,
rootMenu: null
};
_openClass = "show";
_closeClass = "hide";
_root = true;
_currentChild = 0;
_focusState = "none";
_currentEvent = "none";
_hoverType = "off";
_hoverDelay = 250;
constructor(_ref) {

@@ -439,36 +464,2 @@ let {

} = _ref;
_defineProperty$3(this, "_MenuType", BaseMenu);
_defineProperty$3(this, "_MenuItemType", BaseMenuItem);
_defineProperty$3(this, "_MenuToggleType", BaseMenuToggle);
_defineProperty$3(this, "_dom", {
menu: null,
menuItems: [],
submenuItems: [],
submenuToggles: [],
submenus: [],
controller: null,
container: null
});
_defineProperty$3(this, "_selectors", {
menuItems: "",
menuLinks: "",
submenuItems: "",
submenuToggles: "",
submenus: ""
});
_defineProperty$3(this, "_elements", {
menuItems: [],
submenuToggles: [],
controller: null,
parentMenu: null,
rootMenu: null
});
_defineProperty$3(this, "_openClass", "show");
_defineProperty$3(this, "_closeClass", "hide");
_defineProperty$3(this, "_root", true);
_defineProperty$3(this, "_currentChild", 0);
_defineProperty$3(this, "_focusState", "none");
_defineProperty$3(this, "_currentEvent", "none");
_defineProperty$3(this, "_hoverType", "off");
_defineProperty$3(this, "_hoverDelay", 250);
this._dom.menu = menuElement;

@@ -926,4 +917,6 @@ this._dom.controller = controllerElement;

preventEvent(event);
this.elements.controller.open();
this.focusFirstChild();
this.elements.controller.toggle();
if (this.elements.controller.isOpen) {
this.focusFirstChild();
}
}

@@ -1089,6 +1082,6 @@ });

function _defineProperty$2(obj, key, value) { key = _toPropertyKey$2(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$2(arg) { var key = _toPrimitive$2(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$2(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Menubar extends BaseMenu {
_MenuType = Menubar;
_MenuItemType = MenubarItem;
_MenuToggleType = MenubarToggle;
constructor(_ref) {

@@ -1128,5 +1121,2 @@ let {

});
_defineProperty$2(this, "_MenuType", Menubar);
_defineProperty$2(this, "_MenuItemType", MenubarItem);
_defineProperty$2(this, "_MenuToggleType", MenubarToggle);
if (initialize) {

@@ -1139,3 +1129,7 @@ this.initialize();

super.initialize();
this.dom.menu.setAttribute("role", "menubar");
if (this.isTopLevel) {
this.dom.menu.setAttribute("role", "menubar");
} else {
this.dom.menu.setAttribute("role", "menu");
}
this._handleFocus();

@@ -1418,6 +1412,8 @@ this._handleClick();

function _defineProperty$1(obj, key, value) { key = _toPropertyKey$1(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$1(arg) { var key = _toPrimitive$1(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$1(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Bootstrap5MenubarToggle extends MenubarToggle {
_dom = {
toggle: null,
parent: null,
container: null
};
constructor(_ref) {

@@ -1438,7 +1434,2 @@ let {

});
_defineProperty$1(this, "_dom", {
toggle: null,
parent: null,
container: null
});
this._dom.toggle = menuToggleElement;

@@ -1504,6 +1495,6 @@ this._dom.parent = parentElement;

function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Bootstrap5Menubar extends Menubar {
_MenuType = Bootstrap5Menubar;
_MenuItemType = Bootstrap5MenubarItem;
_MenuToggleType = Bootstrap5MenubarToggle;
constructor(_ref) {

@@ -1544,5 +1535,2 @@ let {

});
_defineProperty(this, "_MenuType", Bootstrap5Menubar);
_defineProperty(this, "_MenuItemType", Bootstrap5MenubarItem);
_defineProperty(this, "_MenuToggleType", Bootstrap5MenubarToggle);
if (initialize) {

@@ -1549,0 +1537,0 @@ this.initialize();

@@ -1,2 +0,2 @@

function e(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ${typeof t} given.`)}for(const n in t)if(!(t[n]instanceof e)){const s=typeof t[n];throw new TypeError(`AccessibleMenu: ${n} must be an instance of ${e.name}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function t(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Values given to isValidType() must be inside of an object. ${typeof t} given.`)}for(const n in t){const s=typeof t[n];if(s!==e)throw new TypeError(`AccessibleMenu: ${n} must be a ${e}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function n(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ${typeof e} given.`)}for(const t in e)try{if(null===e[t])throw new Error;document.querySelector(e[t])}catch(n){throw new TypeError(`AccessibleMenu: ${t} must be a valid CSS selector. "${e[t]}" given.`)}return!0}catch(e){return console.error(e),!1}}function s(e){try{if("object"!=typeof e||Array.isArray(e)){throw new TypeError(`AccessibleMenu: Values given to isValidClassList() must be inside of an object. ${typeof e} given.`)}for(const t in e){const s=typeof e[t];if("string"!==s){if(!Array.isArray(e[t]))throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. ${s} given.`);e[t].forEach((e=>{if("string"!=typeof e)throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. An array containing non-strings given.`)}))}else{const s={};s[t]=e[t],n(s)}}return!0}catch(e){return console.error(e),!1}}function i(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ${typeof e} given.`)}const t=["off","on","dynamic"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}function r(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class o{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i=null}=e;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=t,this._dom.parent=n,this._elements.controlledMenu=s,this._elements.parentMenu=i}initialize(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(n,s){if(t("string",{tagName:n})&&e(HTMLElement,s)){const e=n.toLowerCase();let t=!0;for(const n in s)s[n].tagName.toLowerCase()!==e&&(t=!1);return t}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){const e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&(t=t.toLowerCase().replace(/\s+/g,"-"),t.startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n=`${t}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){t("boolean",{value:e}),this._open=e}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.add(n):this.elements.controlledMenu.dom.menu.classList.add(...n)),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.remove(t):this.elements.controlledMenu.dom.menu.classList.remove(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.add(t):this.elements.controlledMenu.dom.menu.classList.add(...t)),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.remove(n):this.elements.controlledMenu.dom.menu.classList.remove(...n)),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.currentChild=0,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()))}}function l(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class u{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:o=null}=e;l(this,"_dom",{item:null,link:null}),l(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),l(this,"_submenu",!1),this._dom.item=t,this._dom.link=n,this._elements.parentMenu=s,this._elements.childMenu=r,this._elements.toggle=o,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 m(e){try{const t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((e=>!0===n[e]))||""}catch(e){return""}}function h(e){e.preventDefault(),e.stopPropagation()}function c(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class a{constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:l="ul",controllerElement:m=null,containerElement:h=null,openClass:d="show",closeClass:p="hide",isTopLevel:g=!0,parentMenu:f=null,hoverType:b="off",hoverDelay:v=250}=e;c(this,"_MenuType",a),c(this,"_MenuItemType",u),c(this,"_MenuToggleType",o),c(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null}),c(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""}),c(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null}),c(this,"_openClass","show"),c(this,"_closeClass","hide"),c(this,"_root",!0),c(this,"_currentChild",0),c(this,"_focusState","none"),c(this,"_currentEvent","none"),c(this,"_hoverType","off"),c(this,"_hoverDelay",250),this._dom.menu=t,this._dom.controller=m,this._dom.container=h,this._selectors.menuItems=n,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=f,this._elements.rootMenu=g?this:null,this._openClass=d||"",this._closeClass=p||"",this._root=g,this._hoverType=b,this._hoverDelay=v}initialize(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&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 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 shouldFocus(){let e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}set openClass(e){s({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){s({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set currentChild(e){function n(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu){let t=0,n=!1;for(;!n&&t<e.elements.parentMenu.elements.menuItems.length;){const s=e.elements.parentMenu.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}}t("number",{value:e}),e<-1?(this._currentChild=-1,n(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,n(this)):this.focusChild!==e&&(this._currentChild=e,n(this))}set focusState(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidState() must be inside of an object. ${typeof e} given.`);const t=["none","self","child"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&("self"===e||"none"===e)&&this.elements.submenuToggles.forEach((e=>{e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==e&&"child"!==e||(this.elements.parentMenu.focusState="child")}set currentEvent(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidEvent() must be inside of an object. ${typeof e} given.`);const t=["none","mouse","keyboard","character"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({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){i({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){t("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}_validate(){let r=!0;return null!==this._dom.container||null!==this._dom.controller?e(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(r=!1):e(HTMLElement,{menuElement:this._dom.menu})||(r=!1),""!==this._selectors.submenuItems?n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(r=!1):n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(r=!1),""===this._openClass||s({openClass:this._openClass})||(r=!1),""===this._closeClass||s({closeClass:this._closeClass})||(r=!1),t("boolean",{isTopLevel:this._root})||(r=!1),null===this._elements.parentMenu||e(a,{parentMenu:this._elements.parentMenu})||(r=!1),i({hoverType:this._hoverType})||(r=!1),t("number",{hoverDelay:this._hoverDelay})||(r=!1),r}_setDOMElementType(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[t])throw new Error(`AccessibleMenu: "${t}" is not a valid element type within the menu.`);{if(!Array.isArray(this.dom[t]))throw new Error(`AccessibleMenu: The "${t}" element cannot be set through _setDOMElementType.`);n!==this.dom.menu&&e(HTMLElement,{base:n});const i=Array.from(n.querySelectorAll(this.selectors[t])).filter((e=>e.parentElement===n));this._dom[t]=s?i:[...this._dom[t],...i]}}_resetDOMElementType(e){if(void 0===this.dom[e])throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`);if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}_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(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}_createChildElements(){this.dom.menuItems.forEach((e=>{let t;if(this.dom.submenuItems.includes(e)){const n=e.querySelector(this.selectors.submenuToggles),s=e.querySelector(this.selectors.submenus),i=new this._MenuType({menuElement:s,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,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),r=new this._MenuToggleType({menuToggleElement:n,parentElement:e,controlledMenu:i,parentMenu:this});this._elements.submenuToggles.push(r),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,parentMenu:this,isSubmenuItem:!0,childMenu:i,toggle:r})}else{const n=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,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(e,t,n){h(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach(((t,n)=>{t.dom.link.addEventListener("pointerdown",(()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(n)}),{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",(n=>{if("pen"!==n.pointerType&&"touch"!==n.pointerType)if("on"===this.hoverType)this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&e.elements.toggle.preview();else if("dynamic"===this.hoverType){const n=this.elements.submenuToggles.some((e=>e.isOpen));this.currentChild=t,this.isTopLevel&&"none"===this.focusState||(this.currentEvent="mouse",this.focusCurrentChild()),!e.isSubmenuItem||this.isTopLevel&&!n||(this.currentEvent="mouse",e.elements.toggle.preview())}})),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",(t=>{"pen"!==t.pointerType&&"touch"!==t.pointerType&&("on"===this.hoverType?this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close()}),this.hoverDelay):(this.currentEvent="mouse",e.elements.toggle.close()):"dynamic"===this.hoverType&&(this.isTopLevel||(this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()}),this.hoverDelay):(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=m(e);"Space"!==t&&"Enter"!==t||h(e)}))}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=m(e);"Space"!==t&&"Enter"!==t||(h(e),this.elements.controller.open(),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",-1!==this.currentChild&&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",-1!==this.currentChild&&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 d extends u{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:o=null,initialize:l=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i,childMenu:r,toggle:o}),l&&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 p extends o{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i=null,initialize:r=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i}),r&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}function g(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class f extends a{constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:o="ul",controllerElement:l=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:b="off",hoverDelay:v=250,initialize:M=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:o,controllerElement:l,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:b,hoverDelay:v}),g(this,"_MenuType",f),g(this,"_MenuItemType",d),g(this,"_MenuToggleType",p),M&&this.initialize()}initialize(){try{super.initialize(),this.dom.menu.setAttribute("role","menubar"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup(),this.isTopLevel&&(this.elements.menuItems[0].dom.link.tabIndex=0)}catch(e){console.error(e)}}_handleClick(){super._handleClick(),document.addEventListener("pointerup",(e=>{"none"!==this.focusState&&(this.currentEvent="mouse",this.dom.menu.contains(e.target)||!this.dom.menu===e.target||(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))}))}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",(e=>{this.currentEvent="keyboard";const t=m(e);if("Tab"===t&&("none"!==this.elements.rootMenu.focusState?(this.elements.rootMenu.blur(),this.elements.rootMenu.closeChildren()):this.elements.rootMenu.focus()),"Character"===t)h(e);else if(this.isTopLevel){if("self"===this.focusState){const n=["Space","Enter","ArrowDown","ArrowUp"],s=["Escape"];(["ArrowRight","ArrowLeft","Home","End"].includes(t)||this.currentMenuItem.isSubmenuItem&&n.includes(t)||this.elements.controller&&s.includes(t))&&h(e)}}else{const n=["Space","Enter"];(["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"].includes(t)||this.currentMenuItem.isSubmenuItem&&n.includes(t))&&h(e)}}))}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=m(e),{altKey:n,crtlKey:s,metaKey:i}=e;if("Character"!==t||(n||s||i))if(this.isTopLevel){if("self"===this.focusState)if("Space"===t||"Enter"===t)this.currentMenuItem.isSubmenuItem?(h(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()}))):this.currentMenuItem.dom.link.click();else if("ArrowRight"===t){h(e);const t=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusNextChild(),t&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if("ArrowLeft"===t){h(e);const t=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusPreviousChild(),t&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if("ArrowDown"===t)this.currentMenuItem.isSubmenuItem&&(h(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})));else if("ArrowUp"===t)this.currentMenuItem.isSubmenuItem&&(h(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusLastChild()})));else if("Home"===t)h(e),this.focusFirstChild();else if("End"===t)h(e),this.focusLastChild();else if("Escape"===t){this.elements.submenuToggles.some((e=>e.isOpen))?(h(e),this.closeChildren()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(h(e),this.elements.controller.close(),this.focusController())}}else"Space"===t||"Enter"===t?this.currentMenuItem.isSubmenuItem?(h(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()}))):this.currentMenuItem.dom.link.click():"Escape"===t?(h(e),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusCurrentChild()):"ArrowRight"===t?this.currentMenuItem.isSubmenuItem?(h(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()}))):(h(e),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusNextChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&this.elements.rootMenu.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===t?this.elements.parentMenu.currentMenuItem.isSubmenuItem&&(h(e),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()))):"ArrowDown"===t?(h(e),this.focusNextChild()):"ArrowUp"===t?(h(e),this.focusPreviousChild()):"Home"===t?(h(e),this.focusFirstChild()):"End"===t&&(h(e),this.focusLastChild());else h(e),this.elements.rootMenu.currentEvent="character",this.focusNextChildWithCharacter(e.key)}))}focusNextChild(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}focusPreviousChild(){0===this.currentChild?this.focusLastChild():this.focusChild(this.currentChild-1)}focusNextChildWithCharacter(e){const t=e.toLowerCase();let n=this.currentChild+1,s=!1;for(;!s&&n<this.elements.menuItems.length;){let e="";e=this.elements.menuItems[n].dom.item.innerText?this.elements.menuItems[n].dom.item.innerText:this.elements.menuItems[n].dom.item.textContent,e=e.replace(/[\s]/g,"").toLowerCase().charAt(0),e===t&&(s=!0,this.focusChild(n)),n++}}}class b extends d{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:o=null,initialize:l=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i,childMenu:r,toggle:o,initialize:!1}),l&&this.initialize()}}function v(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class M extends p{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i=null,initialize:r=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i,initialize:!1}),v(this,"_dom",{toggle:null,parent:null,container:null}),this._dom.toggle=t,this._dom.parent=n,this._dom.container=s.isTopLevel?s.dom.container:s.dom.menu,r&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),""!==n&&("string"==typeof n?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}function y(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class E extends f{constructor(e){let{menuElement:t,menuItemSelector:n=".nav-item,li",menuLinkSelector:s=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:o=".dropdown-menu",controllerElement:l=null,containerElement:u=null,openClass:m="show",closeClass:h="collapse",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,initialize:g=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:o,controllerElement:l,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p,initialize:!1}),y(this,"_MenuType",E),y(this,"_MenuItemType",b),y(this,"_MenuToggleType",M),g&&this.initialize()}}export{E as default};
function e(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ${typeof t} given.`)}for(const n in t)if(!(t[n]instanceof e)){const s=typeof t[n];throw new TypeError(`AccessibleMenu: ${n} must be an instance of ${e.name}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function t(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Values given to isValidType() must be inside of an object. ${typeof t} given.`)}for(const n in t){const s=typeof t[n];if(s!==e)throw new TypeError(`AccessibleMenu: ${n} must be a ${e}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function n(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ${typeof e} given.`)}for(const t in e)try{if(null===e[t])throw new Error;document.querySelector(e[t])}catch(n){throw new TypeError(`AccessibleMenu: ${t} must be a valid CSS selector. "${e[t]}" given.`)}return!0}catch(e){return console.error(e),!1}}function s(e){try{if("object"!=typeof e||Array.isArray(e)){throw new TypeError(`AccessibleMenu: Values given to isValidClassList() must be inside of an object. ${typeof e} given.`)}for(const t in e){const s=typeof e[t];if("string"!==s){if(!Array.isArray(e[t]))throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. ${s} given.`);e[t].forEach((e=>{if("string"!=typeof e)throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. An array containing non-strings given.`)}))}else{const s={};s[t]=e[t],n(s)}}return!0}catch(e){return console.error(e),!1}}function o(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ${typeof e} given.`)}const t=["off","on","dynamic"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}class l{_dom={toggle:null,parent:null};_elements={controlledMenu:null,parentMenu:null};_open=!1;_expandEvent=new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}});_collapseEvent=new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}});constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o=null}=e;this._dom.toggle=t,this._dom.parent=n,this._elements.controlledMenu=s,this._elements.parentMenu=o}initialize(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(n,s){if(t("string",{tagName:n})&&e(HTMLElement,s)){const e=n.toLowerCase();let t=!0;for(const n in s)s[n].tagName.toLowerCase()!==e&&(t=!1);return t}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){const e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&(t=t.toLowerCase().replace(/\s+/g,"-"),t.startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n=`${t}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){t("boolean",{value:e}),this._open=e}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.add(n):this.elements.controlledMenu.dom.menu.classList.add(...n)),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.remove(t):this.elements.controlledMenu.dom.menu.classList.remove(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.add(t):this.elements.controlledMenu.dom.menu.classList.add(...t)),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.remove(n):this.elements.controlledMenu.dom.menu.classList.remove(...n)),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.currentChild=0,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 i{_dom={item:null,link:null};_elements={parentMenu:null,childMenu:null,toggle:null};_submenu=!1;constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o=!1,childMenu:l=null,toggle:i=null}=e;this._dom.item=t,this._dom.link=n,this._elements.parentMenu=s,this._elements.childMenu=l,this._elements.toggle=i,this._submenu=o}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 r(e){try{const t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((e=>!0===n[e]))||""}catch(e){return""}}function u(e){e.preventDefault(),e.stopPropagation()}class m{_MenuType=m;_MenuItemType=i;_MenuToggleType=l;_dom={menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null};_selectors={menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""};_elements={menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null};_openClass="show";_closeClass="hide";_root=!0;_currentChild=0;_focusState="none";_currentEvent="none";_hoverType="off";_hoverDelay=250;constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:o="",submenuToggleSelector:l="a",submenuSelector:i="ul",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250}=e;this._dom.menu=t,this._dom.controller=r,this._dom.container=u,this._selectors.menuItems=n,this._selectors.menuLinks=s,this._selectors.submenuItems=o,this._selectors.submenuToggles=l,this._selectors.submenus=i,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=a,this._elements.rootMenu=c?this:null,this._openClass=m||"",this._closeClass=h||"",this._root=c,this._hoverType=d,this._hoverDelay=p}initialize(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&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 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 shouldFocus(){let e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}set openClass(e){s({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){s({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set currentChild(e){function n(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu){let t=0,n=!1;for(;!n&&t<e.elements.parentMenu.elements.menuItems.length;){const s=e.elements.parentMenu.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}}t("number",{value:e}),e<-1?(this._currentChild=-1,n(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,n(this)):this.focusChild!==e&&(this._currentChild=e,n(this))}set focusState(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidState() must be inside of an object. ${typeof e} given.`);const t=["none","self","child"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&("self"===e||"none"===e)&&this.elements.submenuToggles.forEach((e=>{e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==e&&"child"!==e||(this.elements.parentMenu.focusState="child")}set currentEvent(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidEvent() must be inside of an object. ${typeof e} given.`);const t=["none","mouse","keyboard","character"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({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){t("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}_validate(){let l=!0;return null!==this._dom.container||null!==this._dom.controller?e(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(l=!1):e(HTMLElement,{menuElement:this._dom.menu})||(l=!1),""!==this._selectors.submenuItems?n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(l=!1):n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(l=!1),""===this._openClass||s({openClass:this._openClass})||(l=!1),""===this._closeClass||s({closeClass:this._closeClass})||(l=!1),t("boolean",{isTopLevel:this._root})||(l=!1),null===this._elements.parentMenu||e(m,{parentMenu:this._elements.parentMenu})||(l=!1),o({hoverType:this._hoverType})||(l=!1),t("number",{hoverDelay:this._hoverDelay})||(l=!1),l}_setDOMElementType(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[t])throw new Error(`AccessibleMenu: "${t}" is not a valid element type within the menu.`);{if(!Array.isArray(this.dom[t]))throw new Error(`AccessibleMenu: The "${t}" element cannot be set through _setDOMElementType.`);n!==this.dom.menu&&e(HTMLElement,{base:n});const o=Array.from(n.querySelectorAll(this.selectors[t])).filter((e=>e.parentElement===n));this._dom[t]=s?o:[...this._dom[t],...o]}}_resetDOMElementType(e){if(void 0===this.dom[e])throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`);if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}_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(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}_createChildElements(){this.dom.menuItems.forEach((e=>{let t;if(this.dom.submenuItems.includes(e)){const n=e.querySelector(this.selectors.submenuToggles),s=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:s,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,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),l=new this._MenuToggleType({menuToggleElement:n,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:l})}else{const n=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,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(e,t,n){u(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach(((t,n)=>{t.dom.link.addEventListener("pointerdown",(()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(n)}),{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",(n=>{if("pen"!==n.pointerType&&"touch"!==n.pointerType)if("on"===this.hoverType)this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&e.elements.toggle.preview();else if("dynamic"===this.hoverType){const n=this.elements.submenuToggles.some((e=>e.isOpen));this.currentChild=t,this.isTopLevel&&"none"===this.focusState||(this.currentEvent="mouse",this.focusCurrentChild()),!e.isSubmenuItem||this.isTopLevel&&!n||(this.currentEvent="mouse",e.elements.toggle.preview())}})),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",(t=>{"pen"!==t.pointerType&&"touch"!==t.pointerType&&("on"===this.hoverType?this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close()}),this.hoverDelay):(this.currentEvent="mouse",e.elements.toggle.close()):"dynamic"===this.hoverType&&(this.isTopLevel||(this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()}),this.hoverDelay):(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=r(e);"Space"!==t&&"Enter"!==t||u(e)}))}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=r(e);"Space"!==t&&"Enter"!==t||(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",-1!==this.currentChild&&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",-1!==this.currentChild&&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 h extends i{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o=!1,childMenu:l=null,toggle:i=null,initialize:r=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o,childMenu:l,toggle:i}),r&&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 c extends l{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o=null,initialize:l=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o}),l&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class a extends m{_MenuType=a;_MenuItemType=h;_MenuToggleType=c;constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:o="",submenuToggleSelector:l="a",submenuSelector:i="ul",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,initialize:g=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:i,controllerElement:r,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p}),g&&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(e){console.error(e)}}_handleClick(){super._handleClick(),document.addEventListener("pointerup",(e=>{"none"!==this.focusState&&(this.currentEvent="mouse",this.dom.menu.contains(e.target)||!this.dom.menu===e.target||(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))}))}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",(e=>{this.currentEvent="keyboard";const t=r(e);if("Tab"===t&&("none"!==this.elements.rootMenu.focusState?(this.elements.rootMenu.blur(),this.elements.rootMenu.closeChildren()):this.elements.rootMenu.focus()),"Character"===t)u(e);else if(this.isTopLevel){if("self"===this.focusState){const n=["Space","Enter","ArrowDown","ArrowUp"],s=["Escape"];(["ArrowRight","ArrowLeft","Home","End"].includes(t)||this.currentMenuItem.isSubmenuItem&&n.includes(t)||this.elements.controller&&s.includes(t))&&u(e)}}else{const n=["Space","Enter"];(["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"].includes(t)||this.currentMenuItem.isSubmenuItem&&n.includes(t))&&u(e)}}))}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=r(e),{altKey:n,crtlKey:s,metaKey:o}=e;if("Character"!==t||(n||s||o))if(this.isTopLevel){if("self"===this.focusState)if("Space"===t||"Enter"===t)this.currentMenuItem.isSubmenuItem?(u(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()}))):this.currentMenuItem.dom.link.click();else if("ArrowRight"===t){u(e);const t=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusNextChild(),t&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if("ArrowLeft"===t){u(e);const t=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusPreviousChild(),t&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if("ArrowDown"===t)this.currentMenuItem.isSubmenuItem&&(u(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})));else if("ArrowUp"===t)this.currentMenuItem.isSubmenuItem&&(u(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusLastChild()})));else if("Home"===t)u(e),this.focusFirstChild();else if("End"===t)u(e),this.focusLastChild();else if("Escape"===t){this.elements.submenuToggles.some((e=>e.isOpen))?(u(e),this.closeChildren()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(u(e),this.elements.controller.close(),this.focusController())}}else"Space"===t||"Enter"===t?this.currentMenuItem.isSubmenuItem?(u(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()}))):this.currentMenuItem.dom.link.click():"Escape"===t?(u(e),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusCurrentChild()):"ArrowRight"===t?this.currentMenuItem.isSubmenuItem?(u(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()}))):(u(e),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusNextChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&this.elements.rootMenu.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===t?this.elements.parentMenu.currentMenuItem.isSubmenuItem&&(u(e),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()))):"ArrowDown"===t?(u(e),this.focusNextChild()):"ArrowUp"===t?(u(e),this.focusPreviousChild()):"Home"===t?(u(e),this.focusFirstChild()):"End"===t&&(u(e),this.focusLastChild());else u(e),this.elements.rootMenu.currentEvent="character",this.focusNextChildWithCharacter(e.key)}))}focusNextChild(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}focusPreviousChild(){0===this.currentChild?this.focusLastChild():this.focusChild(this.currentChild-1)}focusNextChildWithCharacter(e){const t=e.toLowerCase();let n=this.currentChild+1,s=!1;for(;!s&&n<this.elements.menuItems.length;){let e="";e=this.elements.menuItems[n].dom.item.innerText?this.elements.menuItems[n].dom.item.innerText:this.elements.menuItems[n].dom.item.textContent,e=e.replace(/[\s]/g,"").toLowerCase().charAt(0),e===t&&(s=!0,this.focusChild(n)),n++}}}class d extends h{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o=!1,childMenu:l=null,toggle:i=null,initialize:r=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o,childMenu:l,toggle:i,initialize:!1}),r&&this.initialize()}}class p extends c{_dom={toggle:null,parent:null,container:null};constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o=null,initialize:l=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o,initialize:!1}),this._dom.toggle=t,this._dom.parent=n,this._dom.container=s.isTopLevel?s.dom.container:s.dom.menu,l&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),""!==n&&("string"==typeof n?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class g extends a{_MenuType=g;_MenuItemType=d;_MenuToggleType=p;constructor(e){let{menuElement:t,menuItemSelector:n=".nav-item,li",menuLinkSelector:s=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:i=".dropdown-menu",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="collapse",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,initialize:g=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:i,controllerElement:r,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p,initialize:!1}),g&&this.initialize()}}export{g as default};
//# sourceMappingURL=menubar-bs5.esm.min.js.map

@@ -161,6 +161,24 @@ var Bootstrap5Menubar = (function () {

function _defineProperty$5(obj, key, value) { key = _toPropertyKey$5(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$5(arg) { var key = _toPrimitive$5(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$5(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenuToggle {
_dom = {
toggle: null,
parent: null
};
_elements = {
controlledMenu: null,
parentMenu: null
};
_open = false;
_expandEvent = new CustomEvent("accessibleMenuExpand", {
bubbles: true,
detail: {
toggle: this
}
});
_collapseEvent = new CustomEvent("accessibleMenuCollapse", {
bubbles: true,
detail: {
toggle: this
}
});
constructor(_ref) {

@@ -173,23 +191,2 @@ let {

} = _ref;
_defineProperty$5(this, "_dom", {
toggle: null,
parent: null
});
_defineProperty$5(this, "_elements", {
controlledMenu: null,
parentMenu: null
});
_defineProperty$5(this, "_open", false);
_defineProperty$5(this, "_expandEvent", new CustomEvent("accessibleMenuExpand", {
bubbles: true,
detail: {
toggle: this
}
}));
_defineProperty$5(this, "_collapseEvent", new CustomEvent("accessibleMenuCollapse", {
bubbles: true,
detail: {
toggle: this
}
}));
this._dom.toggle = menuToggleElement;

@@ -339,6 +336,13 @@ this._dom.parent = parentElement;

function _defineProperty$4(obj, key, value) { key = _toPropertyKey$4(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$4(arg) { var key = _toPrimitive$4(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$4(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenuItem {
_dom = {
item: null,
link: null
};
_elements = {
parentMenu: null,
childMenu: null,
toggle: null
};
_submenu = false;
constructor(_ref) {

@@ -353,12 +357,2 @@ let {

} = _ref;
_defineProperty$4(this, "_dom", {
item: null,
link: null
});
_defineProperty$4(this, "_elements", {
parentMenu: null,
childMenu: null,
toggle: null
});
_defineProperty$4(this, "_submenu", false);
this._dom.item = menuItemElement;

@@ -420,6 +414,37 @@ this._dom.link = menuLinkElement;

function _defineProperty$3(obj, key, value) { key = _toPropertyKey$3(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$3(arg) { var key = _toPrimitive$3(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$3(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenu {
_MenuType = BaseMenu;
_MenuItemType = BaseMenuItem;
_MenuToggleType = BaseMenuToggle;
_dom = {
menu: null,
menuItems: [],
submenuItems: [],
submenuToggles: [],
submenus: [],
controller: null,
container: null
};
_selectors = {
menuItems: "",
menuLinks: "",
submenuItems: "",
submenuToggles: "",
submenus: ""
};
_elements = {
menuItems: [],
submenuToggles: [],
controller: null,
parentMenu: null,
rootMenu: null
};
_openClass = "show";
_closeClass = "hide";
_root = true;
_currentChild = 0;
_focusState = "none";
_currentEvent = "none";
_hoverType = "off";
_hoverDelay = 250;
constructor(_ref) {

@@ -442,36 +467,2 @@ let {

} = _ref;
_defineProperty$3(this, "_MenuType", BaseMenu);
_defineProperty$3(this, "_MenuItemType", BaseMenuItem);
_defineProperty$3(this, "_MenuToggleType", BaseMenuToggle);
_defineProperty$3(this, "_dom", {
menu: null,
menuItems: [],
submenuItems: [],
submenuToggles: [],
submenus: [],
controller: null,
container: null
});
_defineProperty$3(this, "_selectors", {
menuItems: "",
menuLinks: "",
submenuItems: "",
submenuToggles: "",
submenus: ""
});
_defineProperty$3(this, "_elements", {
menuItems: [],
submenuToggles: [],
controller: null,
parentMenu: null,
rootMenu: null
});
_defineProperty$3(this, "_openClass", "show");
_defineProperty$3(this, "_closeClass", "hide");
_defineProperty$3(this, "_root", true);
_defineProperty$3(this, "_currentChild", 0);
_defineProperty$3(this, "_focusState", "none");
_defineProperty$3(this, "_currentEvent", "none");
_defineProperty$3(this, "_hoverType", "off");
_defineProperty$3(this, "_hoverDelay", 250);
this._dom.menu = menuElement;

@@ -929,4 +920,6 @@ this._dom.controller = controllerElement;

preventEvent(event);
this.elements.controller.open();
this.focusFirstChild();
this.elements.controller.toggle();
if (this.elements.controller.isOpen) {
this.focusFirstChild();
}
}

@@ -1092,6 +1085,6 @@ });

function _defineProperty$2(obj, key, value) { key = _toPropertyKey$2(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$2(arg) { var key = _toPrimitive$2(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$2(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Menubar extends BaseMenu {
_MenuType = Menubar;
_MenuItemType = MenubarItem;
_MenuToggleType = MenubarToggle;
constructor(_ref) {

@@ -1131,5 +1124,2 @@ let {

});
_defineProperty$2(this, "_MenuType", Menubar);
_defineProperty$2(this, "_MenuItemType", MenubarItem);
_defineProperty$2(this, "_MenuToggleType", MenubarToggle);
if (initialize) {

@@ -1142,3 +1132,7 @@ this.initialize();

super.initialize();
this.dom.menu.setAttribute("role", "menubar");
if (this.isTopLevel) {
this.dom.menu.setAttribute("role", "menubar");
} else {
this.dom.menu.setAttribute("role", "menu");
}
this._handleFocus();

@@ -1421,6 +1415,8 @@ this._handleClick();

function _defineProperty$1(obj, key, value) { key = _toPropertyKey$1(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$1(arg) { var key = _toPrimitive$1(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$1(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Bootstrap5MenubarToggle extends MenubarToggle {
_dom = {
toggle: null,
parent: null,
container: null
};
constructor(_ref) {

@@ -1441,7 +1437,2 @@ let {

});
_defineProperty$1(this, "_dom", {
toggle: null,
parent: null,
container: null
});
this._dom.toggle = menuToggleElement;

@@ -1507,6 +1498,6 @@ this._dom.parent = parentElement;

function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Bootstrap5Menubar extends Menubar {
_MenuType = Bootstrap5Menubar;
_MenuItemType = Bootstrap5MenubarItem;
_MenuToggleType = Bootstrap5MenubarToggle;
constructor(_ref) {

@@ -1547,5 +1538,2 @@ let {

});
_defineProperty(this, "_MenuType", Bootstrap5Menubar);
_defineProperty(this, "_MenuItemType", Bootstrap5MenubarItem);
_defineProperty(this, "_MenuToggleType", Bootstrap5MenubarToggle);
if (initialize) {

@@ -1552,0 +1540,0 @@ this.initialize();

@@ -1,2 +0,2 @@

var Bootstrap5Menubar=function(){"use strict";function e(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ${typeof t} given.`)}for(const n in t)if(!(t[n]instanceof e)){const s=typeof t[n];throw new TypeError(`AccessibleMenu: ${n} must be an instance of ${e.name}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function t(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Values given to isValidType() must be inside of an object. ${typeof t} given.`)}for(const n in t){const s=typeof t[n];if(s!==e)throw new TypeError(`AccessibleMenu: ${n} must be a ${e}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function n(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ${typeof e} given.`)}for(const t in e)try{if(null===e[t])throw new Error;document.querySelector(e[t])}catch(n){throw new TypeError(`AccessibleMenu: ${t} must be a valid CSS selector. "${e[t]}" given.`)}return!0}catch(e){return console.error(e),!1}}function s(e){try{if("object"!=typeof e||Array.isArray(e)){throw new TypeError(`AccessibleMenu: Values given to isValidClassList() must be inside of an object. ${typeof e} given.`)}for(const t in e){const s=typeof e[t];if("string"!==s){if(!Array.isArray(e[t]))throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. ${s} given.`);e[t].forEach((e=>{if("string"!=typeof e)throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. An array containing non-strings given.`)}))}else{const s={};s[t]=e[t],n(s)}}return!0}catch(e){return console.error(e),!1}}function i(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ${typeof e} given.`)}const t=["off","on","dynamic"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}function r(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class o{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i=null}=e;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=t,this._dom.parent=n,this._elements.controlledMenu=s,this._elements.parentMenu=i}initialize(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(n,s){if(t("string",{tagName:n})&&e(HTMLElement,s)){const e=n.toLowerCase();let t=!0;for(const n in s)s[n].tagName.toLowerCase()!==e&&(t=!1);return t}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){const e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&(t=t.toLowerCase().replace(/\s+/g,"-"),t.startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n=`${t}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){t("boolean",{value:e}),this._open=e}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.add(n):this.elements.controlledMenu.dom.menu.classList.add(...n)),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.remove(t):this.elements.controlledMenu.dom.menu.classList.remove(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.add(t):this.elements.controlledMenu.dom.menu.classList.add(...t)),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.remove(n):this.elements.controlledMenu.dom.menu.classList.remove(...n)),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.currentChild=0,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()))}}function l(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class u{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:o=null}=e;l(this,"_dom",{item:null,link:null}),l(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),l(this,"_submenu",!1),this._dom.item=t,this._dom.link=n,this._elements.parentMenu=s,this._elements.childMenu=r,this._elements.toggle=o,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 m(e){try{const t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((e=>!0===n[e]))||""}catch(e){return""}}function h(e){e.preventDefault(),e.stopPropagation()}function c(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class a{constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:l="ul",controllerElement:m=null,containerElement:h=null,openClass:d="show",closeClass:p="hide",isTopLevel:g=!0,parentMenu:f=null,hoverType:b="off",hoverDelay:v=250}=e;c(this,"_MenuType",a),c(this,"_MenuItemType",u),c(this,"_MenuToggleType",o),c(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null}),c(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""}),c(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null}),c(this,"_openClass","show"),c(this,"_closeClass","hide"),c(this,"_root",!0),c(this,"_currentChild",0),c(this,"_focusState","none"),c(this,"_currentEvent","none"),c(this,"_hoverType","off"),c(this,"_hoverDelay",250),this._dom.menu=t,this._dom.controller=m,this._dom.container=h,this._selectors.menuItems=n,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=f,this._elements.rootMenu=g?this:null,this._openClass=d||"",this._closeClass=p||"",this._root=g,this._hoverType=b,this._hoverDelay=v}initialize(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&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 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 shouldFocus(){let e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}set openClass(e){s({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){s({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set currentChild(e){function n(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu){let t=0,n=!1;for(;!n&&t<e.elements.parentMenu.elements.menuItems.length;){const s=e.elements.parentMenu.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}}t("number",{value:e}),e<-1?(this._currentChild=-1,n(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,n(this)):this.focusChild!==e&&(this._currentChild=e,n(this))}set focusState(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidState() must be inside of an object. ${typeof e} given.`);const t=["none","self","child"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&("self"===e||"none"===e)&&this.elements.submenuToggles.forEach((e=>{e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==e&&"child"!==e||(this.elements.parentMenu.focusState="child")}set currentEvent(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidEvent() must be inside of an object. ${typeof e} given.`);const t=["none","mouse","keyboard","character"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({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){i({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){t("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}_validate(){let r=!0;return null!==this._dom.container||null!==this._dom.controller?e(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(r=!1):e(HTMLElement,{menuElement:this._dom.menu})||(r=!1),""!==this._selectors.submenuItems?n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(r=!1):n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(r=!1),""===this._openClass||s({openClass:this._openClass})||(r=!1),""===this._closeClass||s({closeClass:this._closeClass})||(r=!1),t("boolean",{isTopLevel:this._root})||(r=!1),null===this._elements.parentMenu||e(a,{parentMenu:this._elements.parentMenu})||(r=!1),i({hoverType:this._hoverType})||(r=!1),t("number",{hoverDelay:this._hoverDelay})||(r=!1),r}_setDOMElementType(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[t])throw new Error(`AccessibleMenu: "${t}" is not a valid element type within the menu.`);{if(!Array.isArray(this.dom[t]))throw new Error(`AccessibleMenu: The "${t}" element cannot be set through _setDOMElementType.`);n!==this.dom.menu&&e(HTMLElement,{base:n});const i=Array.from(n.querySelectorAll(this.selectors[t])).filter((e=>e.parentElement===n));this._dom[t]=s?i:[...this._dom[t],...i]}}_resetDOMElementType(e){if(void 0===this.dom[e])throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`);if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}_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(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}_createChildElements(){this.dom.menuItems.forEach((e=>{let t;if(this.dom.submenuItems.includes(e)){const n=e.querySelector(this.selectors.submenuToggles),s=e.querySelector(this.selectors.submenus),i=new this._MenuType({menuElement:s,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,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),r=new this._MenuToggleType({menuToggleElement:n,parentElement:e,controlledMenu:i,parentMenu:this});this._elements.submenuToggles.push(r),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,parentMenu:this,isSubmenuItem:!0,childMenu:i,toggle:r})}else{const n=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,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(e,t,n){h(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach(((t,n)=>{t.dom.link.addEventListener("pointerdown",(()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(n)}),{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",(n=>{if("pen"!==n.pointerType&&"touch"!==n.pointerType)if("on"===this.hoverType)this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&e.elements.toggle.preview();else if("dynamic"===this.hoverType){const n=this.elements.submenuToggles.some((e=>e.isOpen));this.currentChild=t,this.isTopLevel&&"none"===this.focusState||(this.currentEvent="mouse",this.focusCurrentChild()),!e.isSubmenuItem||this.isTopLevel&&!n||(this.currentEvent="mouse",e.elements.toggle.preview())}})),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",(t=>{"pen"!==t.pointerType&&"touch"!==t.pointerType&&("on"===this.hoverType?this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close()}),this.hoverDelay):(this.currentEvent="mouse",e.elements.toggle.close()):"dynamic"===this.hoverType&&(this.isTopLevel||(this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()}),this.hoverDelay):(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=m(e);"Space"!==t&&"Enter"!==t||h(e)}))}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=m(e);"Space"!==t&&"Enter"!==t||(h(e),this.elements.controller.open(),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",-1!==this.currentChild&&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",-1!==this.currentChild&&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 d extends u{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:o=null,initialize:l=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i,childMenu:r,toggle:o}),l&&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 p extends o{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i=null,initialize:r=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i}),r&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}function g(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class f extends a{constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:o="ul",controllerElement:l=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:b="off",hoverDelay:v=250,initialize:M=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:o,controllerElement:l,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:b,hoverDelay:v}),g(this,"_MenuType",f),g(this,"_MenuItemType",d),g(this,"_MenuToggleType",p),M&&this.initialize()}initialize(){try{super.initialize(),this.dom.menu.setAttribute("role","menubar"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup(),this.isTopLevel&&(this.elements.menuItems[0].dom.link.tabIndex=0)}catch(e){console.error(e)}}_handleClick(){super._handleClick(),document.addEventListener("pointerup",(e=>{"none"!==this.focusState&&(this.currentEvent="mouse",this.dom.menu.contains(e.target)||!this.dom.menu===e.target||(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))}))}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",(e=>{this.currentEvent="keyboard";const t=m(e);if("Tab"===t&&("none"!==this.elements.rootMenu.focusState?(this.elements.rootMenu.blur(),this.elements.rootMenu.closeChildren()):this.elements.rootMenu.focus()),"Character"===t)h(e);else if(this.isTopLevel){if("self"===this.focusState){const n=["Space","Enter","ArrowDown","ArrowUp"],s=["Escape"];(["ArrowRight","ArrowLeft","Home","End"].includes(t)||this.currentMenuItem.isSubmenuItem&&n.includes(t)||this.elements.controller&&s.includes(t))&&h(e)}}else{const n=["Space","Enter"];(["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"].includes(t)||this.currentMenuItem.isSubmenuItem&&n.includes(t))&&h(e)}}))}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=m(e),{altKey:n,crtlKey:s,metaKey:i}=e;if("Character"!==t||(n||s||i))if(this.isTopLevel){if("self"===this.focusState)if("Space"===t||"Enter"===t)this.currentMenuItem.isSubmenuItem?(h(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()}))):this.currentMenuItem.dom.link.click();else if("ArrowRight"===t){h(e);const t=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusNextChild(),t&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if("ArrowLeft"===t){h(e);const t=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusPreviousChild(),t&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if("ArrowDown"===t)this.currentMenuItem.isSubmenuItem&&(h(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})));else if("ArrowUp"===t)this.currentMenuItem.isSubmenuItem&&(h(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusLastChild()})));else if("Home"===t)h(e),this.focusFirstChild();else if("End"===t)h(e),this.focusLastChild();else if("Escape"===t){this.elements.submenuToggles.some((e=>e.isOpen))?(h(e),this.closeChildren()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(h(e),this.elements.controller.close(),this.focusController())}}else"Space"===t||"Enter"===t?this.currentMenuItem.isSubmenuItem?(h(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()}))):this.currentMenuItem.dom.link.click():"Escape"===t?(h(e),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusCurrentChild()):"ArrowRight"===t?this.currentMenuItem.isSubmenuItem?(h(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()}))):(h(e),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusNextChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&this.elements.rootMenu.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===t?this.elements.parentMenu.currentMenuItem.isSubmenuItem&&(h(e),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()))):"ArrowDown"===t?(h(e),this.focusNextChild()):"ArrowUp"===t?(h(e),this.focusPreviousChild()):"Home"===t?(h(e),this.focusFirstChild()):"End"===t&&(h(e),this.focusLastChild());else h(e),this.elements.rootMenu.currentEvent="character",this.focusNextChildWithCharacter(e.key)}))}focusNextChild(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}focusPreviousChild(){0===this.currentChild?this.focusLastChild():this.focusChild(this.currentChild-1)}focusNextChildWithCharacter(e){const t=e.toLowerCase();let n=this.currentChild+1,s=!1;for(;!s&&n<this.elements.menuItems.length;){let e="";e=this.elements.menuItems[n].dom.item.innerText?this.elements.menuItems[n].dom.item.innerText:this.elements.menuItems[n].dom.item.textContent,e=e.replace(/[\s]/g,"").toLowerCase().charAt(0),e===t&&(s=!0,this.focusChild(n)),n++}}}class b extends d{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:o=null,initialize:l=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:i,childMenu:r,toggle:o,initialize:!1}),l&&this.initialize()}}function v(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class M extends p{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i=null,initialize:r=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:i,initialize:!1}),v(this,"_dom",{toggle:null,parent:null,container:null}),this._dom.toggle=t,this._dom.parent=n,this._dom.container=s.isTopLevel?s.dom.container:s.dom.menu,r&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),""!==n&&("string"==typeof n?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}function y(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class E extends f{constructor(e){let{menuElement:t,menuItemSelector:n=".nav-item,li",menuLinkSelector:s=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:o=".dropdown-menu",controllerElement:l=null,containerElement:u=null,openClass:m="show",closeClass:h="collapse",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,initialize:g=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:o,controllerElement:l,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p,initialize:!1}),y(this,"_MenuType",E),y(this,"_MenuItemType",b),y(this,"_MenuToggleType",M),g&&this.initialize()}}return E}();
var Bootstrap5Menubar=function(){"use strict";function e(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ${typeof t} given.`)}for(const n in t)if(!(t[n]instanceof e)){const s=typeof t[n];throw new TypeError(`AccessibleMenu: ${n} must be an instance of ${e.name}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function t(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Values given to isValidType() must be inside of an object. ${typeof t} given.`)}for(const n in t){const s=typeof t[n];if(s!==e)throw new TypeError(`AccessibleMenu: ${n} must be a ${e}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function n(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ${typeof e} given.`)}for(const t in e)try{if(null===e[t])throw new Error;document.querySelector(e[t])}catch(n){throw new TypeError(`AccessibleMenu: ${t} must be a valid CSS selector. "${e[t]}" given.`)}return!0}catch(e){return console.error(e),!1}}function s(e){try{if("object"!=typeof e||Array.isArray(e)){throw new TypeError(`AccessibleMenu: Values given to isValidClassList() must be inside of an object. ${typeof e} given.`)}for(const t in e){const s=typeof e[t];if("string"!==s){if(!Array.isArray(e[t]))throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. ${s} given.`);e[t].forEach((e=>{if("string"!=typeof e)throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. An array containing non-strings given.`)}))}else{const s={};s[t]=e[t],n(s)}}return!0}catch(e){return console.error(e),!1}}function o(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ${typeof e} given.`)}const t=["off","on","dynamic"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}class l{_dom={toggle:null,parent:null};_elements={controlledMenu:null,parentMenu:null};_open=!1;_expandEvent=new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}});_collapseEvent=new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}});constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o=null}=e;this._dom.toggle=t,this._dom.parent=n,this._elements.controlledMenu=s,this._elements.parentMenu=o}initialize(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(n,s){if(t("string",{tagName:n})&&e(HTMLElement,s)){const e=n.toLowerCase();let t=!0;for(const n in s)s[n].tagName.toLowerCase()!==e&&(t=!1);return t}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){const e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&(t=t.toLowerCase().replace(/\s+/g,"-"),t.startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n=`${t}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){t("boolean",{value:e}),this._open=e}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.add(n):this.elements.controlledMenu.dom.menu.classList.add(...n)),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.remove(t):this.elements.controlledMenu.dom.menu.classList.remove(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.add(t):this.elements.controlledMenu.dom.menu.classList.add(...t)),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.remove(n):this.elements.controlledMenu.dom.menu.classList.remove(...n)),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.currentChild=0,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 i{_dom={item:null,link:null};_elements={parentMenu:null,childMenu:null,toggle:null};_submenu=!1;constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o=!1,childMenu:l=null,toggle:i=null}=e;this._dom.item=t,this._dom.link=n,this._elements.parentMenu=s,this._elements.childMenu=l,this._elements.toggle=i,this._submenu=o}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 r(e){try{const t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((e=>!0===n[e]))||""}catch(e){return""}}function u(e){e.preventDefault(),e.stopPropagation()}class m{_MenuType=m;_MenuItemType=i;_MenuToggleType=l;_dom={menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null};_selectors={menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""};_elements={menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null};_openClass="show";_closeClass="hide";_root=!0;_currentChild=0;_focusState="none";_currentEvent="none";_hoverType="off";_hoverDelay=250;constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:o="",submenuToggleSelector:l="a",submenuSelector:i="ul",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250}=e;this._dom.menu=t,this._dom.controller=r,this._dom.container=u,this._selectors.menuItems=n,this._selectors.menuLinks=s,this._selectors.submenuItems=o,this._selectors.submenuToggles=l,this._selectors.submenus=i,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=a,this._elements.rootMenu=c?this:null,this._openClass=m||"",this._closeClass=h||"",this._root=c,this._hoverType=d,this._hoverDelay=p}initialize(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&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 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 shouldFocus(){let e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}set openClass(e){s({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){s({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set currentChild(e){function n(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu){let t=0,n=!1;for(;!n&&t<e.elements.parentMenu.elements.menuItems.length;){const s=e.elements.parentMenu.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}}t("number",{value:e}),e<-1?(this._currentChild=-1,n(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,n(this)):this.focusChild!==e&&(this._currentChild=e,n(this))}set focusState(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidState() must be inside of an object. ${typeof e} given.`);const t=["none","self","child"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&("self"===e||"none"===e)&&this.elements.submenuToggles.forEach((e=>{e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==e&&"child"!==e||(this.elements.parentMenu.focusState="child")}set currentEvent(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidEvent() must be inside of an object. ${typeof e} given.`);const t=["none","mouse","keyboard","character"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({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){t("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}_validate(){let l=!0;return null!==this._dom.container||null!==this._dom.controller?e(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(l=!1):e(HTMLElement,{menuElement:this._dom.menu})||(l=!1),""!==this._selectors.submenuItems?n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(l=!1):n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(l=!1),""===this._openClass||s({openClass:this._openClass})||(l=!1),""===this._closeClass||s({closeClass:this._closeClass})||(l=!1),t("boolean",{isTopLevel:this._root})||(l=!1),null===this._elements.parentMenu||e(m,{parentMenu:this._elements.parentMenu})||(l=!1),o({hoverType:this._hoverType})||(l=!1),t("number",{hoverDelay:this._hoverDelay})||(l=!1),l}_setDOMElementType(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[t])throw new Error(`AccessibleMenu: "${t}" is not a valid element type within the menu.`);{if(!Array.isArray(this.dom[t]))throw new Error(`AccessibleMenu: The "${t}" element cannot be set through _setDOMElementType.`);n!==this.dom.menu&&e(HTMLElement,{base:n});const o=Array.from(n.querySelectorAll(this.selectors[t])).filter((e=>e.parentElement===n));this._dom[t]=s?o:[...this._dom[t],...o]}}_resetDOMElementType(e){if(void 0===this.dom[e])throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`);if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}_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(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}_createChildElements(){this.dom.menuItems.forEach((e=>{let t;if(this.dom.submenuItems.includes(e)){const n=e.querySelector(this.selectors.submenuToggles),s=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:s,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,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),l=new this._MenuToggleType({menuToggleElement:n,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:l})}else{const n=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,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(e,t,n){u(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach(((t,n)=>{t.dom.link.addEventListener("pointerdown",(()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(n)}),{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",(n=>{if("pen"!==n.pointerType&&"touch"!==n.pointerType)if("on"===this.hoverType)this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&e.elements.toggle.preview();else if("dynamic"===this.hoverType){const n=this.elements.submenuToggles.some((e=>e.isOpen));this.currentChild=t,this.isTopLevel&&"none"===this.focusState||(this.currentEvent="mouse",this.focusCurrentChild()),!e.isSubmenuItem||this.isTopLevel&&!n||(this.currentEvent="mouse",e.elements.toggle.preview())}})),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",(t=>{"pen"!==t.pointerType&&"touch"!==t.pointerType&&("on"===this.hoverType?this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close()}),this.hoverDelay):(this.currentEvent="mouse",e.elements.toggle.close()):"dynamic"===this.hoverType&&(this.isTopLevel||(this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()}),this.hoverDelay):(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=r(e);"Space"!==t&&"Enter"!==t||u(e)}))}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=r(e);"Space"!==t&&"Enter"!==t||(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",-1!==this.currentChild&&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",-1!==this.currentChild&&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 h extends i{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o=!1,childMenu:l=null,toggle:i=null,initialize:r=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o,childMenu:l,toggle:i}),r&&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 c extends l{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o=null,initialize:l=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o}),l&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class a extends m{_MenuType=a;_MenuItemType=h;_MenuToggleType=c;constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:o="",submenuToggleSelector:l="a",submenuSelector:i="ul",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,initialize:g=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:i,controllerElement:r,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p}),g&&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(e){console.error(e)}}_handleClick(){super._handleClick(),document.addEventListener("pointerup",(e=>{"none"!==this.focusState&&(this.currentEvent="mouse",this.dom.menu.contains(e.target)||!this.dom.menu===e.target||(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))}))}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",(e=>{this.currentEvent="keyboard";const t=r(e);if("Tab"===t&&("none"!==this.elements.rootMenu.focusState?(this.elements.rootMenu.blur(),this.elements.rootMenu.closeChildren()):this.elements.rootMenu.focus()),"Character"===t)u(e);else if(this.isTopLevel){if("self"===this.focusState){const n=["Space","Enter","ArrowDown","ArrowUp"],s=["Escape"];(["ArrowRight","ArrowLeft","Home","End"].includes(t)||this.currentMenuItem.isSubmenuItem&&n.includes(t)||this.elements.controller&&s.includes(t))&&u(e)}}else{const n=["Space","Enter"];(["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"].includes(t)||this.currentMenuItem.isSubmenuItem&&n.includes(t))&&u(e)}}))}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=r(e),{altKey:n,crtlKey:s,metaKey:o}=e;if("Character"!==t||(n||s||o))if(this.isTopLevel){if("self"===this.focusState)if("Space"===t||"Enter"===t)this.currentMenuItem.isSubmenuItem?(u(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()}))):this.currentMenuItem.dom.link.click();else if("ArrowRight"===t){u(e);const t=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusNextChild(),t&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if("ArrowLeft"===t){u(e);const t=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusPreviousChild(),t&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if("ArrowDown"===t)this.currentMenuItem.isSubmenuItem&&(u(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})));else if("ArrowUp"===t)this.currentMenuItem.isSubmenuItem&&(u(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusLastChild()})));else if("Home"===t)u(e),this.focusFirstChild();else if("End"===t)u(e),this.focusLastChild();else if("Escape"===t){this.elements.submenuToggles.some((e=>e.isOpen))?(u(e),this.closeChildren()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(u(e),this.elements.controller.close(),this.focusController())}}else"Space"===t||"Enter"===t?this.currentMenuItem.isSubmenuItem?(u(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()}))):this.currentMenuItem.dom.link.click():"Escape"===t?(u(e),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusCurrentChild()):"ArrowRight"===t?this.currentMenuItem.isSubmenuItem?(u(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame((()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()}))):(u(e),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusNextChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&this.elements.rootMenu.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===t?this.elements.parentMenu.currentMenuItem.isSubmenuItem&&(u(e),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()))):"ArrowDown"===t?(u(e),this.focusNextChild()):"ArrowUp"===t?(u(e),this.focusPreviousChild()):"Home"===t?(u(e),this.focusFirstChild()):"End"===t&&(u(e),this.focusLastChild());else u(e),this.elements.rootMenu.currentEvent="character",this.focusNextChildWithCharacter(e.key)}))}focusNextChild(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}focusPreviousChild(){0===this.currentChild?this.focusLastChild():this.focusChild(this.currentChild-1)}focusNextChildWithCharacter(e){const t=e.toLowerCase();let n=this.currentChild+1,s=!1;for(;!s&&n<this.elements.menuItems.length;){let e="";e=this.elements.menuItems[n].dom.item.innerText?this.elements.menuItems[n].dom.item.innerText:this.elements.menuItems[n].dom.item.textContent,e=e.replace(/[\s]/g,"").toLowerCase().charAt(0),e===t&&(s=!0,this.focusChild(n)),n++}}}class d extends h{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o=!1,childMenu:l=null,toggle:i=null,initialize:r=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:o,childMenu:l,toggle:i,initialize:!1}),r&&this.initialize()}}class p extends c{_dom={toggle:null,parent:null,container:null};constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o=null,initialize:l=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:o,initialize:!1}),this._dom.toggle=t,this._dom.parent=n,this._dom.container=s.isTopLevel?s.dom.container:s.dom.menu,l&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),""!==n&&("string"==typeof n?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class g extends a{_MenuType=g;_MenuItemType=d;_MenuToggleType=p;constructor(e){let{menuElement:t,menuItemSelector:n=".nav-item,li",menuLinkSelector:s=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:i=".dropdown-menu",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="collapse",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,initialize:g=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:i,controllerElement:r,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p,initialize:!1}),g&&this.initialize()}}return g}();
//# sourceMappingURL=menubar-bs5.min.js.map

@@ -158,6 +158,24 @@ function isValidInstance(contructor, elements) {

function _defineProperty$5(obj, key, value) { key = _toPropertyKey$5(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$5(arg) { var key = _toPrimitive$5(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$5(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenuToggle {
_dom = {
toggle: null,
parent: null
};
_elements = {
controlledMenu: null,
parentMenu: null
};
_open = false;
_expandEvent = new CustomEvent("accessibleMenuExpand", {
bubbles: true,
detail: {
toggle: this
}
});
_collapseEvent = new CustomEvent("accessibleMenuCollapse", {
bubbles: true,
detail: {
toggle: this
}
});
constructor(_ref) {

@@ -170,23 +188,2 @@ let {

} = _ref;
_defineProperty$5(this, "_dom", {
toggle: null,
parent: null
});
_defineProperty$5(this, "_elements", {
controlledMenu: null,
parentMenu: null
});
_defineProperty$5(this, "_open", false);
_defineProperty$5(this, "_expandEvent", new CustomEvent("accessibleMenuExpand", {
bubbles: true,
detail: {
toggle: this
}
}));
_defineProperty$5(this, "_collapseEvent", new CustomEvent("accessibleMenuCollapse", {
bubbles: true,
detail: {
toggle: this
}
}));
this._dom.toggle = menuToggleElement;

@@ -336,6 +333,13 @@ this._dom.parent = parentElement;

function _defineProperty$4(obj, key, value) { key = _toPropertyKey$4(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$4(arg) { var key = _toPrimitive$4(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$4(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenuItem {
_dom = {
item: null,
link: null
};
_elements = {
parentMenu: null,
childMenu: null,
toggle: null
};
_submenu = false;
constructor(_ref) {

@@ -350,12 +354,2 @@ let {

} = _ref;
_defineProperty$4(this, "_dom", {
item: null,
link: null
});
_defineProperty$4(this, "_elements", {
parentMenu: null,
childMenu: null,
toggle: null
});
_defineProperty$4(this, "_submenu", false);
this._dom.item = menuItemElement;

@@ -417,6 +411,37 @@ this._dom.link = menuLinkElement;

function _defineProperty$3(obj, key, value) { key = _toPropertyKey$3(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$3(arg) { var key = _toPrimitive$3(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$3(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenu {
_MenuType = BaseMenu;
_MenuItemType = BaseMenuItem;
_MenuToggleType = BaseMenuToggle;
_dom = {
menu: null,
menuItems: [],
submenuItems: [],
submenuToggles: [],
submenus: [],
controller: null,
container: null
};
_selectors = {
menuItems: "",
menuLinks: "",
submenuItems: "",
submenuToggles: "",
submenus: ""
};
_elements = {
menuItems: [],
submenuToggles: [],
controller: null,
parentMenu: null,
rootMenu: null
};
_openClass = "show";
_closeClass = "hide";
_root = true;
_currentChild = 0;
_focusState = "none";
_currentEvent = "none";
_hoverType = "off";
_hoverDelay = 250;
constructor(_ref) {

@@ -439,36 +464,2 @@ let {

} = _ref;
_defineProperty$3(this, "_MenuType", BaseMenu);
_defineProperty$3(this, "_MenuItemType", BaseMenuItem);
_defineProperty$3(this, "_MenuToggleType", BaseMenuToggle);
_defineProperty$3(this, "_dom", {
menu: null,
menuItems: [],
submenuItems: [],
submenuToggles: [],
submenus: [],
controller: null,
container: null
});
_defineProperty$3(this, "_selectors", {
menuItems: "",
menuLinks: "",
submenuItems: "",
submenuToggles: "",
submenus: ""
});
_defineProperty$3(this, "_elements", {
menuItems: [],
submenuToggles: [],
controller: null,
parentMenu: null,
rootMenu: null
});
_defineProperty$3(this, "_openClass", "show");
_defineProperty$3(this, "_closeClass", "hide");
_defineProperty$3(this, "_root", true);
_defineProperty$3(this, "_currentChild", 0);
_defineProperty$3(this, "_focusState", "none");
_defineProperty$3(this, "_currentEvent", "none");
_defineProperty$3(this, "_hoverType", "off");
_defineProperty$3(this, "_hoverDelay", 250);
this._dom.menu = menuElement;

@@ -926,4 +917,6 @@ this._dom.controller = controllerElement;

preventEvent(event);
this.elements.controller.open();
this.focusFirstChild();
this.elements.controller.toggle();
if (this.elements.controller.isOpen) {
this.focusFirstChild();
}
}

@@ -1071,6 +1064,6 @@ });

function _defineProperty$2(obj, key, value) { key = _toPropertyKey$2(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$2(arg) { var key = _toPrimitive$2(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$2(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Treeview extends BaseMenu {
_MenuType = Treeview;
_MenuItemType = TreeviewItem;
_MenuToggleType = TreeviewToggle;
constructor(_ref) {

@@ -1110,5 +1103,2 @@ let {

});
_defineProperty$2(this, "_MenuType", Treeview);
_defineProperty$2(this, "_MenuItemType", TreeviewItem);
_defineProperty$2(this, "_MenuToggleType", TreeviewToggle);
if (initialize) {

@@ -1352,6 +1342,8 @@ this.initialize();

function _defineProperty$1(obj, key, value) { key = _toPropertyKey$1(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$1(arg) { var key = _toPrimitive$1(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$1(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Bootstrap5TreeviewToggle extends TreeviewToggle {
_dom = {
toggle: null,
parent: null,
container: null
};
constructor(_ref) {

@@ -1372,7 +1364,2 @@ let {

});
_defineProperty$1(this, "_dom", {
toggle: null,
parent: null,
container: null
});
this._dom.toggle = menuToggleElement;

@@ -1438,6 +1425,6 @@ this._dom.parent = parentElement;

function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Bootstrap5Treeview extends Treeview {
_MenuType = Bootstrap5Treeview;
_MenuItemType = Bootstrap5TreeviewItem;
_MenuToggleType = Bootstrap5TreeviewToggle;
constructor(_ref) {

@@ -1478,5 +1465,2 @@ let {

});
_defineProperty(this, "_MenuType", Bootstrap5Treeview);
_defineProperty(this, "_MenuItemType", Bootstrap5TreeviewItem);
_defineProperty(this, "_MenuToggleType", Bootstrap5TreeviewToggle);
if (initialize) {

@@ -1483,0 +1467,0 @@ this.initialize();

@@ -1,2 +0,2 @@

function e(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ${typeof t} given.`)}for(const n in t)if(!(t[n]instanceof e)){const s=typeof t[n];throw new TypeError(`AccessibleMenu: ${n} must be an instance of ${e.name}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function t(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Values given to isValidType() must be inside of an object. ${typeof t} given.`)}for(const n in t){const s=typeof t[n];if(s!==e)throw new TypeError(`AccessibleMenu: ${n} must be a ${e}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function n(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ${typeof e} given.`)}for(const t in e)try{if(null===e[t])throw new Error;document.querySelector(e[t])}catch(n){throw new TypeError(`AccessibleMenu: ${t} must be a valid CSS selector. "${e[t]}" given.`)}return!0}catch(e){return console.error(e),!1}}function s(e){try{if("object"!=typeof e||Array.isArray(e)){throw new TypeError(`AccessibleMenu: Values given to isValidClassList() must be inside of an object. ${typeof e} given.`)}for(const t in e){const s=typeof e[t];if("string"!==s){if(!Array.isArray(e[t]))throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. ${s} given.`);e[t].forEach((e=>{if("string"!=typeof e)throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. An array containing non-strings given.`)}))}else{const s={};s[t]=e[t],n(s)}}return!0}catch(e){return console.error(e),!1}}function r(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ${typeof e} given.`)}const t=["off","on","dynamic"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}function i(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class l{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:r=null}=e;i(this,"_dom",{toggle:null,parent:null}),i(this,"_elements",{controlledMenu:null,parentMenu:null}),i(this,"_open",!1),i(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}})),i(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}})),this._dom.toggle=t,this._dom.parent=n,this._elements.controlledMenu=s,this._elements.parentMenu=r}initialize(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(n,s){if(t("string",{tagName:n})&&e(HTMLElement,s)){const e=n.toLowerCase();let t=!0;for(const n in s)s[n].tagName.toLowerCase()!==e&&(t=!1);return t}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){const e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&(t=t.toLowerCase().replace(/\s+/g,"-"),t.startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n=`${t}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){t("boolean",{value:e}),this._open=e}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.add(n):this.elements.controlledMenu.dom.menu.classList.add(...n)),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.remove(t):this.elements.controlledMenu.dom.menu.classList.remove(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.add(t):this.elements.controlledMenu.dom.menu.classList.add(...t)),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.remove(n):this.elements.controlledMenu.dom.menu.classList.remove(...n)),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.currentChild=0,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()))}}function o(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class u{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:r=!1,childMenu:i=null,toggle:l=null}=e;o(this,"_dom",{item:null,link:null}),o(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),o(this,"_submenu",!1),this._dom.item=t,this._dom.link=n,this._elements.parentMenu=s,this._elements.childMenu=i,this._elements.toggle=l,this._submenu=r}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 m(e){try{const t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((e=>!0===n[e]))||""}catch(e){return""}}function h(e){e.preventDefault(),e.stopPropagation()}function c(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class a{constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:r="",submenuToggleSelector:i="a",submenuSelector:o="ul",controllerElement:m=null,containerElement:h=null,openClass:d="show",closeClass:p="hide",isTopLevel:g=!0,parentMenu:f=null,hoverType:b="off",hoverDelay:v=250}=e;c(this,"_MenuType",a),c(this,"_MenuItemType",u),c(this,"_MenuToggleType",l),c(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null}),c(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""}),c(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null}),c(this,"_openClass","show"),c(this,"_closeClass","hide"),c(this,"_root",!0),c(this,"_currentChild",0),c(this,"_focusState","none"),c(this,"_currentEvent","none"),c(this,"_hoverType","off"),c(this,"_hoverDelay",250),this._dom.menu=t,this._dom.controller=m,this._dom.container=h,this._selectors.menuItems=n,this._selectors.menuLinks=s,this._selectors.submenuItems=r,this._selectors.submenuToggles=i,this._selectors.submenus=o,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=f,this._elements.rootMenu=g?this:null,this._openClass=d||"",this._closeClass=p||"",this._root=g,this._hoverType=b,this._hoverDelay=v}initialize(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&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 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 shouldFocus(){let e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}set openClass(e){s({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){s({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set currentChild(e){function n(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu){let t=0,n=!1;for(;!n&&t<e.elements.parentMenu.elements.menuItems.length;){const s=e.elements.parentMenu.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}}t("number",{value:e}),e<-1?(this._currentChild=-1,n(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,n(this)):this.focusChild!==e&&(this._currentChild=e,n(this))}set focusState(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidState() must be inside of an object. ${typeof e} given.`);const t=["none","self","child"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&("self"===e||"none"===e)&&this.elements.submenuToggles.forEach((e=>{e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==e&&"child"!==e||(this.elements.parentMenu.focusState="child")}set currentEvent(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidEvent() must be inside of an object. ${typeof e} given.`);const t=["none","mouse","keyboard","character"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({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){r({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){t("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}_validate(){let i=!0;return null!==this._dom.container||null!==this._dom.controller?e(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(i=!1):e(HTMLElement,{menuElement:this._dom.menu})||(i=!1),""!==this._selectors.submenuItems?n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(i=!1):n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(i=!1),""===this._openClass||s({openClass:this._openClass})||(i=!1),""===this._closeClass||s({closeClass:this._closeClass})||(i=!1),t("boolean",{isTopLevel:this._root})||(i=!1),null===this._elements.parentMenu||e(a,{parentMenu:this._elements.parentMenu})||(i=!1),r({hoverType:this._hoverType})||(i=!1),t("number",{hoverDelay:this._hoverDelay})||(i=!1),i}_setDOMElementType(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[t])throw new Error(`AccessibleMenu: "${t}" is not a valid element type within the menu.`);{if(!Array.isArray(this.dom[t]))throw new Error(`AccessibleMenu: The "${t}" element cannot be set through _setDOMElementType.`);n!==this.dom.menu&&e(HTMLElement,{base:n});const r=Array.from(n.querySelectorAll(this.selectors[t])).filter((e=>e.parentElement===n));this._dom[t]=s?r:[...this._dom[t],...r]}}_resetDOMElementType(e){if(void 0===this.dom[e])throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`);if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}_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(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}_createChildElements(){this.dom.menuItems.forEach((e=>{let t;if(this.dom.submenuItems.includes(e)){const n=e.querySelector(this.selectors.submenuToggles),s=e.querySelector(this.selectors.submenus),r=new this._MenuType({menuElement:s,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,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),i=new this._MenuToggleType({menuToggleElement:n,parentElement:e,controlledMenu:r,parentMenu:this});this._elements.submenuToggles.push(i),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,parentMenu:this,isSubmenuItem:!0,childMenu:r,toggle:i})}else{const n=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,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(e,t,n){h(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach(((t,n)=>{t.dom.link.addEventListener("pointerdown",(()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(n)}),{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",(n=>{if("pen"!==n.pointerType&&"touch"!==n.pointerType)if("on"===this.hoverType)this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&e.elements.toggle.preview();else if("dynamic"===this.hoverType){const n=this.elements.submenuToggles.some((e=>e.isOpen));this.currentChild=t,this.isTopLevel&&"none"===this.focusState||(this.currentEvent="mouse",this.focusCurrentChild()),!e.isSubmenuItem||this.isTopLevel&&!n||(this.currentEvent="mouse",e.elements.toggle.preview())}})),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",(t=>{"pen"!==t.pointerType&&"touch"!==t.pointerType&&("on"===this.hoverType?this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close()}),this.hoverDelay):(this.currentEvent="mouse",e.elements.toggle.close()):"dynamic"===this.hoverType&&(this.isTopLevel||(this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()}),this.hoverDelay):(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=m(e);"Space"!==t&&"Enter"!==t||h(e)}))}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=m(e);"Space"!==t&&"Enter"!==t||(h(e),this.elements.controller.open(),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",-1!==this.currentChild&&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",-1!==this.currentChild&&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 d extends u{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:r=!1,childMenu:i=null,toggle:l=null,initialize:o=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:r,childMenu:i,toggle:l}),o&&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 p extends l{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:r=null,initialize:i=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:r}),i&&this.initialize()}}function g(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class f extends a{constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:r="",submenuToggleSelector:i="a",submenuSelector:l="ul",controllerElement:o=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:b="off",hoverDelay:v=250,initialize:M=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:r,submenuToggleSelector:i,submenuSelector:l,controllerElement:o,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:b,hoverDelay:v}),g(this,"_MenuType",f),g(this,"_MenuItemType",d),g(this,"_MenuToggleType",p),M&&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(e){console.error(e)}}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",(e=>{this.currentEvent="keyboard";const t=m(e);if("Tab"===t&&("none"!==this.elements.rootMenu.focusState?this.elements.rootMenu.blur():this.elements.rootMenu.focus()),"self"===this.focusState){const n=["Enter","ArrowRight"],s=["Escape"];(["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"].includes(t)||this.currentMenuItem.isSubmenuItem&&n.includes(t)||this.elements.controller&&s.includes(t))&&h(e)}}))}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=m(e),{altKey:n,crtlKey:s,metaKey:r}=e;if("Character"!==t||(n||s||r)){if("self"===this.focusState)if("Enter"===t||"Space"===t)h(e),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("Escape"===t)this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController());else if("ArrowDown"===t)h(e),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.focusNextChild():this.focusParentsNextChild();else if("ArrowUp"===t){h(e);const t=this.elements.menuItems[this.currentChild-1];t&&t.isSubmenuItem&&t.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentChild=this.currentChild-1,this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.focusChildsLastNode()):this.isTopLevel||0!==this.currentChild?this.focusPreviousChild():(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild())}else"ArrowRight"===t?this.currentMenuItem.isSubmenuItem&&(h(e),this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):this.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===t?(h(e),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())):"Home"===t?(h(e),this.blurCurrentChild(),this.elements.rootMenu.focusFirstChild()):"End"===t?(h(e),this.blurCurrentChild(),this.elements.rootMenu.focusLastNode()):"Asterisk"===t&&(h(e),this.openChildren())}else h(e),this.elements.rootMenu.currentEvent="character",this.focusNextNodeWithCharacter(e.key)}))}focusLastNode(){const e=this.elements.menuItems.length-1,t=this.elements.menuItems[e];t.isSubmenuItem&&t.elements.toggle.isOpen?(this.currentChild=e,t.elements.childMenu.currentEvent=this.currentEvent,t.elements.childMenu.focusLastNode()):this.focusLastChild()}openChildren(){this.elements.submenuToggles.forEach((e=>e.preview()))}focusNextNodeWithCharacter(e){const t=e.toLowerCase(),n=function e(t){let n=[];return t.elements.menuItems.forEach((t=>{n.push(t),t.isSubmenuItem&&t.elements.toggle.isOpen&&(n=[...n,...e(t.elements.toggle.elements.controlledMenu)])})),n}(this.elements.rootMenu),s=n.indexOf(this.currentMenuItem)+1,r=[...n.slice(s),...n.slice(0,s)];let i=0,l=!1;for(;!l&&i<r.length;){let e="";if(e=r[i].dom.item.innerText?r[i].dom.item.innerText:r[i].dom.item.textContent,e=e.replace(/[\s]/g,"").toLowerCase().charAt(0),e===t){l=!0;const e=r[i].elements.parentMenu,t=e.elements.menuItems.indexOf(r[i]);this.elements.rootMenu.blurChildren(),e.focusChild(t)}i++}}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 b extends d{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:r=!1,childMenu:i=null,toggle:l=null,initialize:o=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:r,childMenu:i,toggle:l,initialize:!1}),o&&this.initialize()}}function v(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class M extends p{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:r=null,initialize:i=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:r,initialize:!1}),v(this,"_dom",{toggle:null,parent:null,container:null}),this._dom.toggle=t,this._dom.parent=n,this._dom.container=s.isTopLevel?s.dom.container:s.dom.menu,i&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),""!==n&&("string"==typeof n?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}function y(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class E extends f{constructor(e){let{menuElement:t,menuItemSelector:n=".nav-item,li",menuLinkSelector:s=".nav-link,.dropdown-item",submenuItemSelector:r=".dropdown",submenuToggleSelector:i=".dropdown-toggle",submenuSelector:l=".dropdown-menu",controllerElement:o=null,containerElement:u=null,openClass:m="show",closeClass:h="collapse",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,initialize:g=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:r,submenuToggleSelector:i,submenuSelector:l,controllerElement:o,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p,initialize:!1}),y(this,"_MenuType",E),y(this,"_MenuItemType",b),y(this,"_MenuToggleType",M),g&&this.initialize()}}export{E as default};
function e(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ${typeof t} given.`)}for(const n in t)if(!(t[n]instanceof e)){const s=typeof t[n];throw new TypeError(`AccessibleMenu: ${n} must be an instance of ${e.name}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function t(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Values given to isValidType() must be inside of an object. ${typeof t} given.`)}for(const n in t){const s=typeof t[n];if(s!==e)throw new TypeError(`AccessibleMenu: ${n} must be a ${e}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function n(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ${typeof e} given.`)}for(const t in e)try{if(null===e[t])throw new Error;document.querySelector(e[t])}catch(n){throw new TypeError(`AccessibleMenu: ${t} must be a valid CSS selector. "${e[t]}" given.`)}return!0}catch(e){return console.error(e),!1}}function s(e){try{if("object"!=typeof e||Array.isArray(e)){throw new TypeError(`AccessibleMenu: Values given to isValidClassList() must be inside of an object. ${typeof e} given.`)}for(const t in e){const s=typeof e[t];if("string"!==s){if(!Array.isArray(e[t]))throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. ${s} given.`);e[t].forEach((e=>{if("string"!=typeof e)throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. An array containing non-strings given.`)}))}else{const s={};s[t]=e[t],n(s)}}return!0}catch(e){return console.error(e),!1}}function l(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ${typeof e} given.`)}const t=["off","on","dynamic"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}class o{_dom={toggle:null,parent:null};_elements={controlledMenu:null,parentMenu:null};_open=!1;_expandEvent=new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}});_collapseEvent=new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}});constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l=null}=e;this._dom.toggle=t,this._dom.parent=n,this._elements.controlledMenu=s,this._elements.parentMenu=l}initialize(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(n,s){if(t("string",{tagName:n})&&e(HTMLElement,s)){const e=n.toLowerCase();let t=!0;for(const n in s)s[n].tagName.toLowerCase()!==e&&(t=!1);return t}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){const e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&(t=t.toLowerCase().replace(/\s+/g,"-"),t.startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n=`${t}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){t("boolean",{value:e}),this._open=e}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.add(n):this.elements.controlledMenu.dom.menu.classList.add(...n)),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.remove(t):this.elements.controlledMenu.dom.menu.classList.remove(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.add(t):this.elements.controlledMenu.dom.menu.classList.add(...t)),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.remove(n):this.elements.controlledMenu.dom.menu.classList.remove(...n)),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.currentChild=0,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 i{_dom={item:null,link:null};_elements={parentMenu:null,childMenu:null,toggle:null};_submenu=!1;constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l=!1,childMenu:o=null,toggle:i=null}=e;this._dom.item=t,this._dom.link=n,this._elements.parentMenu=s,this._elements.childMenu=o,this._elements.toggle=i,this._submenu=l}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 r(e){try{const t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((e=>!0===n[e]))||""}catch(e){return""}}function u(e){e.preventDefault(),e.stopPropagation()}class m{_MenuType=m;_MenuItemType=i;_MenuToggleType=o;_dom={menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null};_selectors={menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""};_elements={menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null};_openClass="show";_closeClass="hide";_root=!0;_currentChild=0;_focusState="none";_currentEvent="none";_hoverType="off";_hoverDelay=250;constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:l="",submenuToggleSelector:o="a",submenuSelector:i="ul",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250}=e;this._dom.menu=t,this._dom.controller=r,this._dom.container=u,this._selectors.menuItems=n,this._selectors.menuLinks=s,this._selectors.submenuItems=l,this._selectors.submenuToggles=o,this._selectors.submenus=i,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=a,this._elements.rootMenu=c?this:null,this._openClass=m||"",this._closeClass=h||"",this._root=c,this._hoverType=d,this._hoverDelay=p}initialize(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&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 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 shouldFocus(){let e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}set openClass(e){s({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){s({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set currentChild(e){function n(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu){let t=0,n=!1;for(;!n&&t<e.elements.parentMenu.elements.menuItems.length;){const s=e.elements.parentMenu.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}}t("number",{value:e}),e<-1?(this._currentChild=-1,n(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,n(this)):this.focusChild!==e&&(this._currentChild=e,n(this))}set focusState(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidState() must be inside of an object. ${typeof e} given.`);const t=["none","self","child"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&("self"===e||"none"===e)&&this.elements.submenuToggles.forEach((e=>{e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==e&&"child"!==e||(this.elements.parentMenu.focusState="child")}set currentEvent(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidEvent() must be inside of an object. ${typeof e} given.`);const t=["none","mouse","keyboard","character"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({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){l({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){t("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}_validate(){let o=!0;return null!==this._dom.container||null!==this._dom.controller?e(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(o=!1):e(HTMLElement,{menuElement:this._dom.menu})||(o=!1),""!==this._selectors.submenuItems?n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(o=!1):n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(o=!1),""===this._openClass||s({openClass:this._openClass})||(o=!1),""===this._closeClass||s({closeClass:this._closeClass})||(o=!1),t("boolean",{isTopLevel:this._root})||(o=!1),null===this._elements.parentMenu||e(m,{parentMenu:this._elements.parentMenu})||(o=!1),l({hoverType:this._hoverType})||(o=!1),t("number",{hoverDelay:this._hoverDelay})||(o=!1),o}_setDOMElementType(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[t])throw new Error(`AccessibleMenu: "${t}" is not a valid element type within the menu.`);{if(!Array.isArray(this.dom[t]))throw new Error(`AccessibleMenu: The "${t}" element cannot be set through _setDOMElementType.`);n!==this.dom.menu&&e(HTMLElement,{base:n});const l=Array.from(n.querySelectorAll(this.selectors[t])).filter((e=>e.parentElement===n));this._dom[t]=s?l:[...this._dom[t],...l]}}_resetDOMElementType(e){if(void 0===this.dom[e])throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`);if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}_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(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}_createChildElements(){this.dom.menuItems.forEach((e=>{let t;if(this.dom.submenuItems.includes(e)){const n=e.querySelector(this.selectors.submenuToggles),s=e.querySelector(this.selectors.submenus),l=new this._MenuType({menuElement:s,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,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),o=new this._MenuToggleType({menuToggleElement:n,parentElement:e,controlledMenu:l,parentMenu:this});this._elements.submenuToggles.push(o),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,parentMenu:this,isSubmenuItem:!0,childMenu:l,toggle:o})}else{const n=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,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(e,t,n){u(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach(((t,n)=>{t.dom.link.addEventListener("pointerdown",(()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(n)}),{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",(n=>{if("pen"!==n.pointerType&&"touch"!==n.pointerType)if("on"===this.hoverType)this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&e.elements.toggle.preview();else if("dynamic"===this.hoverType){const n=this.elements.submenuToggles.some((e=>e.isOpen));this.currentChild=t,this.isTopLevel&&"none"===this.focusState||(this.currentEvent="mouse",this.focusCurrentChild()),!e.isSubmenuItem||this.isTopLevel&&!n||(this.currentEvent="mouse",e.elements.toggle.preview())}})),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",(t=>{"pen"!==t.pointerType&&"touch"!==t.pointerType&&("on"===this.hoverType?this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close()}),this.hoverDelay):(this.currentEvent="mouse",e.elements.toggle.close()):"dynamic"===this.hoverType&&(this.isTopLevel||(this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()}),this.hoverDelay):(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=r(e);"Space"!==t&&"Enter"!==t||u(e)}))}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=r(e);"Space"!==t&&"Enter"!==t||(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",-1!==this.currentChild&&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",-1!==this.currentChild&&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 h extends i{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l=!1,childMenu:o=null,toggle:i=null,initialize:r=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l,childMenu:o,toggle:i}),r&&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 c extends o{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l=null,initialize:o=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l}),o&&this.initialize()}}class a extends m{_MenuType=a;_MenuItemType=h;_MenuToggleType=c;constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:l="",submenuToggleSelector:o="a",submenuSelector:i="ul",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,initialize:g=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:l,submenuToggleSelector:o,submenuSelector:i,controllerElement:r,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p}),g&&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(e){console.error(e)}}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",(e=>{this.currentEvent="keyboard";const t=r(e);if("Tab"===t&&("none"!==this.elements.rootMenu.focusState?this.elements.rootMenu.blur():this.elements.rootMenu.focus()),"self"===this.focusState){const n=["Enter","ArrowRight"],s=["Escape"];(["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"].includes(t)||this.currentMenuItem.isSubmenuItem&&n.includes(t)||this.elements.controller&&s.includes(t))&&u(e)}}))}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=r(e),{altKey:n,crtlKey:s,metaKey:l}=e;if("Character"!==t||(n||s||l)){if("self"===this.focusState)if("Enter"===t||"Space"===t)u(e),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("Escape"===t)this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController());else if("ArrowDown"===t)u(e),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.focusNextChild():this.focusParentsNextChild();else if("ArrowUp"===t){u(e);const t=this.elements.menuItems[this.currentChild-1];t&&t.isSubmenuItem&&t.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentChild=this.currentChild-1,this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.focusChildsLastNode()):this.isTopLevel||0!==this.currentChild?this.focusPreviousChild():(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild())}else"ArrowRight"===t?this.currentMenuItem.isSubmenuItem&&(u(e),this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):this.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===t?(u(e),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())):"Home"===t?(u(e),this.blurCurrentChild(),this.elements.rootMenu.focusFirstChild()):"End"===t?(u(e),this.blurCurrentChild(),this.elements.rootMenu.focusLastNode()):"Asterisk"===t&&(u(e),this.openChildren())}else u(e),this.elements.rootMenu.currentEvent="character",this.focusNextNodeWithCharacter(e.key)}))}focusLastNode(){const e=this.elements.menuItems.length-1,t=this.elements.menuItems[e];t.isSubmenuItem&&t.elements.toggle.isOpen?(this.currentChild=e,t.elements.childMenu.currentEvent=this.currentEvent,t.elements.childMenu.focusLastNode()):this.focusLastChild()}openChildren(){this.elements.submenuToggles.forEach((e=>e.preview()))}focusNextNodeWithCharacter(e){const t=e.toLowerCase(),n=function e(t){let n=[];return t.elements.menuItems.forEach((t=>{n.push(t),t.isSubmenuItem&&t.elements.toggle.isOpen&&(n=[...n,...e(t.elements.toggle.elements.controlledMenu)])})),n}(this.elements.rootMenu),s=n.indexOf(this.currentMenuItem)+1,l=[...n.slice(s),...n.slice(0,s)];let o=0,i=!1;for(;!i&&o<l.length;){let e="";if(e=l[o].dom.item.innerText?l[o].dom.item.innerText:l[o].dom.item.textContent,e=e.replace(/[\s]/g,"").toLowerCase().charAt(0),e===t){i=!0;const e=l[o].elements.parentMenu,t=e.elements.menuItems.indexOf(l[o]);this.elements.rootMenu.blurChildren(),e.focusChild(t)}o++}}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 d extends h{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l=!1,childMenu:o=null,toggle:i=null,initialize:r=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l,childMenu:o,toggle:i,initialize:!1}),r&&this.initialize()}}class p extends c{_dom={toggle:null,parent:null,container:null};constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l=null,initialize:o=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l,initialize:!1}),this._dom.toggle=t,this._dom.parent=n,this._dom.container=s.isTopLevel?s.dom.container:s.dom.menu,o&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),""!==n&&("string"==typeof n?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class g extends a{_MenuType=g;_MenuItemType=d;_MenuToggleType=p;constructor(e){let{menuElement:t,menuItemSelector:n=".nav-item,li",menuLinkSelector:s=".nav-link,.dropdown-item",submenuItemSelector:l=".dropdown",submenuToggleSelector:o=".dropdown-toggle",submenuSelector:i=".dropdown-menu",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="collapse",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,initialize:g=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:l,submenuToggleSelector:o,submenuSelector:i,controllerElement:r,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p,initialize:!1}),g&&this.initialize()}}export{g as default};
//# sourceMappingURL=treeview-bs5.esm.min.js.map

@@ -161,6 +161,24 @@ var Bootstrap5Treeview = (function () {

function _defineProperty$5(obj, key, value) { key = _toPropertyKey$5(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$5(arg) { var key = _toPrimitive$5(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$5(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenuToggle {
_dom = {
toggle: null,
parent: null
};
_elements = {
controlledMenu: null,
parentMenu: null
};
_open = false;
_expandEvent = new CustomEvent("accessibleMenuExpand", {
bubbles: true,
detail: {
toggle: this
}
});
_collapseEvent = new CustomEvent("accessibleMenuCollapse", {
bubbles: true,
detail: {
toggle: this
}
});
constructor(_ref) {

@@ -173,23 +191,2 @@ let {

} = _ref;
_defineProperty$5(this, "_dom", {
toggle: null,
parent: null
});
_defineProperty$5(this, "_elements", {
controlledMenu: null,
parentMenu: null
});
_defineProperty$5(this, "_open", false);
_defineProperty$5(this, "_expandEvent", new CustomEvent("accessibleMenuExpand", {
bubbles: true,
detail: {
toggle: this
}
}));
_defineProperty$5(this, "_collapseEvent", new CustomEvent("accessibleMenuCollapse", {
bubbles: true,
detail: {
toggle: this
}
}));
this._dom.toggle = menuToggleElement;

@@ -339,6 +336,13 @@ this._dom.parent = parentElement;

function _defineProperty$4(obj, key, value) { key = _toPropertyKey$4(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$4(arg) { var key = _toPrimitive$4(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$4(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenuItem {
_dom = {
item: null,
link: null
};
_elements = {
parentMenu: null,
childMenu: null,
toggle: null
};
_submenu = false;
constructor(_ref) {

@@ -353,12 +357,2 @@ let {

} = _ref;
_defineProperty$4(this, "_dom", {
item: null,
link: null
});
_defineProperty$4(this, "_elements", {
parentMenu: null,
childMenu: null,
toggle: null
});
_defineProperty$4(this, "_submenu", false);
this._dom.item = menuItemElement;

@@ -420,6 +414,37 @@ this._dom.link = menuLinkElement;

function _defineProperty$3(obj, key, value) { key = _toPropertyKey$3(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$3(arg) { var key = _toPrimitive$3(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$3(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenu {
_MenuType = BaseMenu;
_MenuItemType = BaseMenuItem;
_MenuToggleType = BaseMenuToggle;
_dom = {
menu: null,
menuItems: [],
submenuItems: [],
submenuToggles: [],
submenus: [],
controller: null,
container: null
};
_selectors = {
menuItems: "",
menuLinks: "",
submenuItems: "",
submenuToggles: "",
submenus: ""
};
_elements = {
menuItems: [],
submenuToggles: [],
controller: null,
parentMenu: null,
rootMenu: null
};
_openClass = "show";
_closeClass = "hide";
_root = true;
_currentChild = 0;
_focusState = "none";
_currentEvent = "none";
_hoverType = "off";
_hoverDelay = 250;
constructor(_ref) {

@@ -442,36 +467,2 @@ let {

} = _ref;
_defineProperty$3(this, "_MenuType", BaseMenu);
_defineProperty$3(this, "_MenuItemType", BaseMenuItem);
_defineProperty$3(this, "_MenuToggleType", BaseMenuToggle);
_defineProperty$3(this, "_dom", {
menu: null,
menuItems: [],
submenuItems: [],
submenuToggles: [],
submenus: [],
controller: null,
container: null
});
_defineProperty$3(this, "_selectors", {
menuItems: "",
menuLinks: "",
submenuItems: "",
submenuToggles: "",
submenus: ""
});
_defineProperty$3(this, "_elements", {
menuItems: [],
submenuToggles: [],
controller: null,
parentMenu: null,
rootMenu: null
});
_defineProperty$3(this, "_openClass", "show");
_defineProperty$3(this, "_closeClass", "hide");
_defineProperty$3(this, "_root", true);
_defineProperty$3(this, "_currentChild", 0);
_defineProperty$3(this, "_focusState", "none");
_defineProperty$3(this, "_currentEvent", "none");
_defineProperty$3(this, "_hoverType", "off");
_defineProperty$3(this, "_hoverDelay", 250);
this._dom.menu = menuElement;

@@ -929,4 +920,6 @@ this._dom.controller = controllerElement;

preventEvent(event);
this.elements.controller.open();
this.focusFirstChild();
this.elements.controller.toggle();
if (this.elements.controller.isOpen) {
this.focusFirstChild();
}
}

@@ -1074,6 +1067,6 @@ });

function _defineProperty$2(obj, key, value) { key = _toPropertyKey$2(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$2(arg) { var key = _toPrimitive$2(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$2(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Treeview extends BaseMenu {
_MenuType = Treeview;
_MenuItemType = TreeviewItem;
_MenuToggleType = TreeviewToggle;
constructor(_ref) {

@@ -1113,5 +1106,2 @@ let {

});
_defineProperty$2(this, "_MenuType", Treeview);
_defineProperty$2(this, "_MenuItemType", TreeviewItem);
_defineProperty$2(this, "_MenuToggleType", TreeviewToggle);
if (initialize) {

@@ -1355,6 +1345,8 @@ this.initialize();

function _defineProperty$1(obj, key, value) { key = _toPropertyKey$1(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey$1(arg) { var key = _toPrimitive$1(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive$1(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Bootstrap5TreeviewToggle extends TreeviewToggle {
_dom = {
toggle: null,
parent: null,
container: null
};
constructor(_ref) {

@@ -1375,7 +1367,2 @@ let {

});
_defineProperty$1(this, "_dom", {
toggle: null,
parent: null,
container: null
});
this._dom.toggle = menuToggleElement;

@@ -1441,6 +1428,6 @@ this._dom.parent = parentElement;

function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Bootstrap5Treeview extends Treeview {
_MenuType = Bootstrap5Treeview;
_MenuItemType = Bootstrap5TreeviewItem;
_MenuToggleType = Bootstrap5TreeviewToggle;
constructor(_ref) {

@@ -1481,5 +1468,2 @@ let {

});
_defineProperty(this, "_MenuType", Bootstrap5Treeview);
_defineProperty(this, "_MenuItemType", Bootstrap5TreeviewItem);
_defineProperty(this, "_MenuToggleType", Bootstrap5TreeviewToggle);
if (initialize) {

@@ -1486,0 +1470,0 @@ this.initialize();

@@ -1,2 +0,2 @@

var Bootstrap5Treeview=function(){"use strict";function e(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ${typeof t} given.`)}for(const n in t)if(!(t[n]instanceof e)){const s=typeof t[n];throw new TypeError(`AccessibleMenu: ${n} must be an instance of ${e.name}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function t(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Values given to isValidType() must be inside of an object. ${typeof t} given.`)}for(const n in t){const s=typeof t[n];if(s!==e)throw new TypeError(`AccessibleMenu: ${n} must be a ${e}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function n(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ${typeof e} given.`)}for(const t in e)try{if(null===e[t])throw new Error;document.querySelector(e[t])}catch(n){throw new TypeError(`AccessibleMenu: ${t} must be a valid CSS selector. "${e[t]}" given.`)}return!0}catch(e){return console.error(e),!1}}function s(e){try{if("object"!=typeof e||Array.isArray(e)){throw new TypeError(`AccessibleMenu: Values given to isValidClassList() must be inside of an object. ${typeof e} given.`)}for(const t in e){const s=typeof e[t];if("string"!==s){if(!Array.isArray(e[t]))throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. ${s} given.`);e[t].forEach((e=>{if("string"!=typeof e)throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. An array containing non-strings given.`)}))}else{const s={};s[t]=e[t],n(s)}}return!0}catch(e){return console.error(e),!1}}function r(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ${typeof e} given.`)}const t=["off","on","dynamic"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}function i(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class o{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:r=null}=e;i(this,"_dom",{toggle:null,parent:null}),i(this,"_elements",{controlledMenu:null,parentMenu:null}),i(this,"_open",!1),i(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}})),i(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}})),this._dom.toggle=t,this._dom.parent=n,this._elements.controlledMenu=s,this._elements.parentMenu=r}initialize(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(n,s){if(t("string",{tagName:n})&&e(HTMLElement,s)){const e=n.toLowerCase();let t=!0;for(const n in s)s[n].tagName.toLowerCase()!==e&&(t=!1);return t}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){const e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&(t=t.toLowerCase().replace(/\s+/g,"-"),t.startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n=`${t}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){t("boolean",{value:e}),this._open=e}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.add(n):this.elements.controlledMenu.dom.menu.classList.add(...n)),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.remove(t):this.elements.controlledMenu.dom.menu.classList.remove(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.add(t):this.elements.controlledMenu.dom.menu.classList.add(...t)),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.remove(n):this.elements.controlledMenu.dom.menu.classList.remove(...n)),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.currentChild=0,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()))}}function l(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class u{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:r=!1,childMenu:i=null,toggle:o=null}=e;l(this,"_dom",{item:null,link:null}),l(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),l(this,"_submenu",!1),this._dom.item=t,this._dom.link=n,this._elements.parentMenu=s,this._elements.childMenu=i,this._elements.toggle=o,this._submenu=r}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 m(e){try{const t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((e=>!0===n[e]))||""}catch(e){return""}}function h(e){e.preventDefault(),e.stopPropagation()}function c(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class a{constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:r="",submenuToggleSelector:i="a",submenuSelector:l="ul",controllerElement:m=null,containerElement:h=null,openClass:d="show",closeClass:p="hide",isTopLevel:g=!0,parentMenu:f=null,hoverType:b="off",hoverDelay:v=250}=e;c(this,"_MenuType",a),c(this,"_MenuItemType",u),c(this,"_MenuToggleType",o),c(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null}),c(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""}),c(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null}),c(this,"_openClass","show"),c(this,"_closeClass","hide"),c(this,"_root",!0),c(this,"_currentChild",0),c(this,"_focusState","none"),c(this,"_currentEvent","none"),c(this,"_hoverType","off"),c(this,"_hoverDelay",250),this._dom.menu=t,this._dom.controller=m,this._dom.container=h,this._selectors.menuItems=n,this._selectors.menuLinks=s,this._selectors.submenuItems=r,this._selectors.submenuToggles=i,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=f,this._elements.rootMenu=g?this:null,this._openClass=d||"",this._closeClass=p||"",this._root=g,this._hoverType=b,this._hoverDelay=v}initialize(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&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 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 shouldFocus(){let e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}set openClass(e){s({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){s({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set currentChild(e){function n(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu){let t=0,n=!1;for(;!n&&t<e.elements.parentMenu.elements.menuItems.length;){const s=e.elements.parentMenu.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}}t("number",{value:e}),e<-1?(this._currentChild=-1,n(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,n(this)):this.focusChild!==e&&(this._currentChild=e,n(this))}set focusState(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidState() must be inside of an object. ${typeof e} given.`);const t=["none","self","child"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&("self"===e||"none"===e)&&this.elements.submenuToggles.forEach((e=>{e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==e&&"child"!==e||(this.elements.parentMenu.focusState="child")}set currentEvent(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidEvent() must be inside of an object. ${typeof e} given.`);const t=["none","mouse","keyboard","character"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({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){r({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){t("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}_validate(){let i=!0;return null!==this._dom.container||null!==this._dom.controller?e(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(i=!1):e(HTMLElement,{menuElement:this._dom.menu})||(i=!1),""!==this._selectors.submenuItems?n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(i=!1):n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(i=!1),""===this._openClass||s({openClass:this._openClass})||(i=!1),""===this._closeClass||s({closeClass:this._closeClass})||(i=!1),t("boolean",{isTopLevel:this._root})||(i=!1),null===this._elements.parentMenu||e(a,{parentMenu:this._elements.parentMenu})||(i=!1),r({hoverType:this._hoverType})||(i=!1),t("number",{hoverDelay:this._hoverDelay})||(i=!1),i}_setDOMElementType(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[t])throw new Error(`AccessibleMenu: "${t}" is not a valid element type within the menu.`);{if(!Array.isArray(this.dom[t]))throw new Error(`AccessibleMenu: The "${t}" element cannot be set through _setDOMElementType.`);n!==this.dom.menu&&e(HTMLElement,{base:n});const r=Array.from(n.querySelectorAll(this.selectors[t])).filter((e=>e.parentElement===n));this._dom[t]=s?r:[...this._dom[t],...r]}}_resetDOMElementType(e){if(void 0===this.dom[e])throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`);if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}_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(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}_createChildElements(){this.dom.menuItems.forEach((e=>{let t;if(this.dom.submenuItems.includes(e)){const n=e.querySelector(this.selectors.submenuToggles),s=e.querySelector(this.selectors.submenus),r=new this._MenuType({menuElement:s,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,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),i=new this._MenuToggleType({menuToggleElement:n,parentElement:e,controlledMenu:r,parentMenu:this});this._elements.submenuToggles.push(i),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,parentMenu:this,isSubmenuItem:!0,childMenu:r,toggle:i})}else{const n=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,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(e,t,n){h(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach(((t,n)=>{t.dom.link.addEventListener("pointerdown",(()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(n)}),{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",(n=>{if("pen"!==n.pointerType&&"touch"!==n.pointerType)if("on"===this.hoverType)this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&e.elements.toggle.preview();else if("dynamic"===this.hoverType){const n=this.elements.submenuToggles.some((e=>e.isOpen));this.currentChild=t,this.isTopLevel&&"none"===this.focusState||(this.currentEvent="mouse",this.focusCurrentChild()),!e.isSubmenuItem||this.isTopLevel&&!n||(this.currentEvent="mouse",e.elements.toggle.preview())}})),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",(t=>{"pen"!==t.pointerType&&"touch"!==t.pointerType&&("on"===this.hoverType?this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close()}),this.hoverDelay):(this.currentEvent="mouse",e.elements.toggle.close()):"dynamic"===this.hoverType&&(this.isTopLevel||(this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()}),this.hoverDelay):(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=m(e);"Space"!==t&&"Enter"!==t||h(e)}))}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=m(e);"Space"!==t&&"Enter"!==t||(h(e),this.elements.controller.open(),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",-1!==this.currentChild&&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",-1!==this.currentChild&&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 d extends u{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:r=!1,childMenu:i=null,toggle:o=null,initialize:l=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:r,childMenu:i,toggle:o}),l&&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 p extends o{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:r=null,initialize:i=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:r}),i&&this.initialize()}}function g(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class f extends a{constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:r="",submenuToggleSelector:i="a",submenuSelector:o="ul",controllerElement:l=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:b="off",hoverDelay:v=250,initialize:M=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:r,submenuToggleSelector:i,submenuSelector:o,controllerElement:l,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:b,hoverDelay:v}),g(this,"_MenuType",f),g(this,"_MenuItemType",d),g(this,"_MenuToggleType",p),M&&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(e){console.error(e)}}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",(e=>{this.currentEvent="keyboard";const t=m(e);if("Tab"===t&&("none"!==this.elements.rootMenu.focusState?this.elements.rootMenu.blur():this.elements.rootMenu.focus()),"self"===this.focusState){const n=["Enter","ArrowRight"],s=["Escape"];(["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"].includes(t)||this.currentMenuItem.isSubmenuItem&&n.includes(t)||this.elements.controller&&s.includes(t))&&h(e)}}))}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=m(e),{altKey:n,crtlKey:s,metaKey:r}=e;if("Character"!==t||(n||s||r)){if("self"===this.focusState)if("Enter"===t||"Space"===t)h(e),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("Escape"===t)this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController());else if("ArrowDown"===t)h(e),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.focusNextChild():this.focusParentsNextChild();else if("ArrowUp"===t){h(e);const t=this.elements.menuItems[this.currentChild-1];t&&t.isSubmenuItem&&t.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentChild=this.currentChild-1,this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.focusChildsLastNode()):this.isTopLevel||0!==this.currentChild?this.focusPreviousChild():(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild())}else"ArrowRight"===t?this.currentMenuItem.isSubmenuItem&&(h(e),this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):this.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===t?(h(e),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())):"Home"===t?(h(e),this.blurCurrentChild(),this.elements.rootMenu.focusFirstChild()):"End"===t?(h(e),this.blurCurrentChild(),this.elements.rootMenu.focusLastNode()):"Asterisk"===t&&(h(e),this.openChildren())}else h(e),this.elements.rootMenu.currentEvent="character",this.focusNextNodeWithCharacter(e.key)}))}focusLastNode(){const e=this.elements.menuItems.length-1,t=this.elements.menuItems[e];t.isSubmenuItem&&t.elements.toggle.isOpen?(this.currentChild=e,t.elements.childMenu.currentEvent=this.currentEvent,t.elements.childMenu.focusLastNode()):this.focusLastChild()}openChildren(){this.elements.submenuToggles.forEach((e=>e.preview()))}focusNextNodeWithCharacter(e){const t=e.toLowerCase(),n=function e(t){let n=[];return t.elements.menuItems.forEach((t=>{n.push(t),t.isSubmenuItem&&t.elements.toggle.isOpen&&(n=[...n,...e(t.elements.toggle.elements.controlledMenu)])})),n}(this.elements.rootMenu),s=n.indexOf(this.currentMenuItem)+1,r=[...n.slice(s),...n.slice(0,s)];let i=0,o=!1;for(;!o&&i<r.length;){let e="";if(e=r[i].dom.item.innerText?r[i].dom.item.innerText:r[i].dom.item.textContent,e=e.replace(/[\s]/g,"").toLowerCase().charAt(0),e===t){o=!0;const e=r[i].elements.parentMenu,t=e.elements.menuItems.indexOf(r[i]);this.elements.rootMenu.blurChildren(),e.focusChild(t)}i++}}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 b extends d{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:r=!1,childMenu:i=null,toggle:o=null,initialize:l=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:r,childMenu:i,toggle:o,initialize:!1}),l&&this.initialize()}}function v(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class M extends p{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:r=null,initialize:i=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:r,initialize:!1}),v(this,"_dom",{toggle:null,parent:null,container:null}),this._dom.toggle=t,this._dom.parent=n,this._dom.container=s.isTopLevel?s.dom.container:s.dom.menu,i&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),""!==n&&("string"==typeof n?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}function y(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class E extends f{constructor(e){let{menuElement:t,menuItemSelector:n=".nav-item,li",menuLinkSelector:s=".nav-link,.dropdown-item",submenuItemSelector:r=".dropdown",submenuToggleSelector:i=".dropdown-toggle",submenuSelector:o=".dropdown-menu",controllerElement:l=null,containerElement:u=null,openClass:m="show",closeClass:h="collapse",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,initialize:g=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:r,submenuToggleSelector:i,submenuSelector:o,controllerElement:l,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p,initialize:!1}),y(this,"_MenuType",E),y(this,"_MenuItemType",b),y(this,"_MenuToggleType",M),g&&this.initialize()}}return E}();
var Bootstrap5Treeview=function(){"use strict";function e(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ${typeof t} given.`)}for(const n in t)if(!(t[n]instanceof e)){const s=typeof t[n];throw new TypeError(`AccessibleMenu: ${n} must be an instance of ${e.name}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function t(e,t){try{if("object"!=typeof t){throw new TypeError(`AccessibleMenu: Values given to isValidType() must be inside of an object. ${typeof t} given.`)}for(const n in t){const s=typeof t[n];if(s!==e)throw new TypeError(`AccessibleMenu: ${n} must be a ${e}. ${s} given.`)}return!0}catch(e){return console.error(e),!1}}function n(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ${typeof e} given.`)}for(const t in e)try{if(null===e[t])throw new Error;document.querySelector(e[t])}catch(n){throw new TypeError(`AccessibleMenu: ${t} must be a valid CSS selector. "${e[t]}" given.`)}return!0}catch(e){return console.error(e),!1}}function s(e){try{if("object"!=typeof e||Array.isArray(e)){throw new TypeError(`AccessibleMenu: Values given to isValidClassList() must be inside of an object. ${typeof e} given.`)}for(const t in e){const s=typeof e[t];if("string"!==s){if(!Array.isArray(e[t]))throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. ${s} given.`);e[t].forEach((e=>{if("string"!=typeof e)throw new TypeError(`AccessibleMenu: ${t} must be a string or an array of strings. An array containing non-strings given.`)}))}else{const s={};s[t]=e[t],n(s)}}return!0}catch(e){return console.error(e),!1}}function l(e){try{if("object"!=typeof e){throw new TypeError(`AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ${typeof e} given.`)}const t=["off","on","dynamic"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}class o{_dom={toggle:null,parent:null};_elements={controlledMenu:null,parentMenu:null};_open=!1;_expandEvent=new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}});_collapseEvent=new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}});constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l=null}=e;this._dom.toggle=t,this._dom.parent=n,this._elements.controlledMenu=s,this._elements.parentMenu=l}initialize(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(n,s){if(t("string",{tagName:n})&&e(HTMLElement,s)){const e=n.toLowerCase();let t=!0;for(const n in s)s[n].tagName.toLowerCase()!==e&&(t=!1);return t}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){const e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&(t=t.toLowerCase().replace(/\s+/g,"-"),t.startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n=`${t}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){t("boolean",{value:e}),this._open=e}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.add(n):this.elements.controlledMenu.dom.menu.classList.add(...n)),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.remove(t):this.elements.controlledMenu.dom.menu.classList.remove(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.elements.controlledMenu.dom.menu.classList.add(t):this.elements.controlledMenu.dom.menu.classList.add(...t)),""!==n&&("string"==typeof n?this.elements.controlledMenu.dom.menu.classList.remove(n):this.elements.controlledMenu.dom.menu.classList.remove(...n)),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.currentChild=0,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 i{_dom={item:null,link:null};_elements={parentMenu:null,childMenu:null,toggle:null};_submenu=!1;constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l=!1,childMenu:o=null,toggle:i=null}=e;this._dom.item=t,this._dom.link=n,this._elements.parentMenu=s,this._elements.childMenu=o,this._elements.toggle=i,this._submenu=l}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 r(e){try{const t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((e=>!0===n[e]))||""}catch(e){return""}}function u(e){e.preventDefault(),e.stopPropagation()}class m{_MenuType=m;_MenuItemType=i;_MenuToggleType=o;_dom={menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null};_selectors={menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""};_elements={menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null};_openClass="show";_closeClass="hide";_root=!0;_currentChild=0;_focusState="none";_currentEvent="none";_hoverType="off";_hoverDelay=250;constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:l="",submenuToggleSelector:o="a",submenuSelector:i="ul",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250}=e;this._dom.menu=t,this._dom.controller=r,this._dom.container=u,this._selectors.menuItems=n,this._selectors.menuLinks=s,this._selectors.submenuItems=l,this._selectors.submenuToggles=o,this._selectors.submenus=i,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=a,this._elements.rootMenu=c?this:null,this._openClass=m||"",this._closeClass=h||"",this._root=c,this._hoverType=d,this._hoverDelay=p}initialize(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&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 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 shouldFocus(){let e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}set openClass(e){s({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){s({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set currentChild(e){function n(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu){let t=0,n=!1;for(;!n&&t<e.elements.parentMenu.elements.menuItems.length;){const s=e.elements.parentMenu.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}}t("number",{value:e}),e<-1?(this._currentChild=-1,n(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,n(this)):this.focusChild!==e&&(this._currentChild=e,n(this))}set focusState(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidState() must be inside of an object. ${typeof e} given.`);const t=["none","self","child"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&("self"===e||"none"===e)&&this.elements.submenuToggles.forEach((e=>{e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==e&&"child"!==e||(this.elements.parentMenu.focusState="child")}set currentEvent(e){!function(e){try{if("object"!=typeof e)throw new TypeError(`AccessibleMenu: Values given to isValidEvent() must be inside of an object. ${typeof e} given.`);const t=["none","mouse","keyboard","character"];for(const n in e)if(!t.includes(e[n]))throw new TypeError(`AccessibleMenu: ${n} must be one of the following values: ${t.join(", ")}. "${e[n]}" given.`);return!0}catch(e){return console.error(e),!1}}({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){l({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){t("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}_validate(){let o=!0;return null!==this._dom.container||null!==this._dom.controller?e(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(o=!1):e(HTMLElement,{menuElement:this._dom.menu})||(o=!1),""!==this._selectors.submenuItems?n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(o=!1):n({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(o=!1),""===this._openClass||s({openClass:this._openClass})||(o=!1),""===this._closeClass||s({closeClass:this._closeClass})||(o=!1),t("boolean",{isTopLevel:this._root})||(o=!1),null===this._elements.parentMenu||e(m,{parentMenu:this._elements.parentMenu})||(o=!1),l({hoverType:this._hoverType})||(o=!1),t("number",{hoverDelay:this._hoverDelay})||(o=!1),o}_setDOMElementType(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[t])throw new Error(`AccessibleMenu: "${t}" is not a valid element type within the menu.`);{if(!Array.isArray(this.dom[t]))throw new Error(`AccessibleMenu: The "${t}" element cannot be set through _setDOMElementType.`);n!==this.dom.menu&&e(HTMLElement,{base:n});const l=Array.from(n.querySelectorAll(this.selectors[t])).filter((e=>e.parentElement===n));this._dom[t]=s?l:[...this._dom[t],...l]}}_resetDOMElementType(e){if(void 0===this.dom[e])throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`);if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}_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(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}_createChildElements(){this.dom.menuItems.forEach((e=>{let t;if(this.dom.submenuItems.includes(e)){const n=e.querySelector(this.selectors.submenuToggles),s=e.querySelector(this.selectors.submenus),l=new this._MenuType({menuElement:s,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,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),o=new this._MenuToggleType({menuToggleElement:n,parentElement:e,controlledMenu:l,parentMenu:this});this._elements.submenuToggles.push(o),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,parentMenu:this,isSubmenuItem:!0,childMenu:l,toggle:o})}else{const n=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:n,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(e,t,n){u(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach(((t,n)=>{t.dom.link.addEventListener("pointerdown",(()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(n)}),{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",(n=>{if("pen"!==n.pointerType&&"touch"!==n.pointerType)if("on"===this.hoverType)this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&e.elements.toggle.preview();else if("dynamic"===this.hoverType){const n=this.elements.submenuToggles.some((e=>e.isOpen));this.currentChild=t,this.isTopLevel&&"none"===this.focusState||(this.currentEvent="mouse",this.focusCurrentChild()),!e.isSubmenuItem||this.isTopLevel&&!n||(this.currentEvent="mouse",e.elements.toggle.preview())}})),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",(t=>{"pen"!==t.pointerType&&"touch"!==t.pointerType&&("on"===this.hoverType?this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close()}),this.hoverDelay):(this.currentEvent="mouse",e.elements.toggle.close()):"dynamic"===this.hoverType&&(this.isTopLevel||(this.hoverDelay>0?setTimeout((()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()}),this.hoverDelay):(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=r(e);"Space"!==t&&"Enter"!==t||u(e)}))}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=r(e);"Space"!==t&&"Enter"!==t||(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",-1!==this.currentChild&&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",-1!==this.currentChild&&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 h extends i{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l=!1,childMenu:o=null,toggle:i=null,initialize:r=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l,childMenu:o,toggle:i}),r&&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 c extends o{constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l=null,initialize:o=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l}),o&&this.initialize()}}class a extends m{_MenuType=a;_MenuItemType=h;_MenuToggleType=c;constructor(e){let{menuElement:t,menuItemSelector:n="li",menuLinkSelector:s="a",submenuItemSelector:l="",submenuToggleSelector:o="a",submenuSelector:i="ul",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="hide",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,initialize:g=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:l,submenuToggleSelector:o,submenuSelector:i,controllerElement:r,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p}),g&&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(e){console.error(e)}}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",(e=>{this.currentEvent="keyboard";const t=r(e);if("Tab"===t&&("none"!==this.elements.rootMenu.focusState?this.elements.rootMenu.blur():this.elements.rootMenu.focus()),"self"===this.focusState){const n=["Enter","ArrowRight"],s=["Escape"];(["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"].includes(t)||this.currentMenuItem.isSubmenuItem&&n.includes(t)||this.elements.controller&&s.includes(t))&&u(e)}}))}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",(e=>{this.currentEvent="keyboard";const t=r(e),{altKey:n,crtlKey:s,metaKey:l}=e;if("Character"!==t||(n||s||l)){if("self"===this.focusState)if("Enter"===t||"Space"===t)u(e),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("Escape"===t)this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController());else if("ArrowDown"===t)u(e),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.focusNextChild():this.focusParentsNextChild();else if("ArrowUp"===t){u(e);const t=this.elements.menuItems[this.currentChild-1];t&&t.isSubmenuItem&&t.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentChild=this.currentChild-1,this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.focusChildsLastNode()):this.isTopLevel||0!==this.currentChild?this.focusPreviousChild():(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild())}else"ArrowRight"===t?this.currentMenuItem.isSubmenuItem&&(u(e),this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):this.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===t?(u(e),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())):"Home"===t?(u(e),this.blurCurrentChild(),this.elements.rootMenu.focusFirstChild()):"End"===t?(u(e),this.blurCurrentChild(),this.elements.rootMenu.focusLastNode()):"Asterisk"===t&&(u(e),this.openChildren())}else u(e),this.elements.rootMenu.currentEvent="character",this.focusNextNodeWithCharacter(e.key)}))}focusLastNode(){const e=this.elements.menuItems.length-1,t=this.elements.menuItems[e];t.isSubmenuItem&&t.elements.toggle.isOpen?(this.currentChild=e,t.elements.childMenu.currentEvent=this.currentEvent,t.elements.childMenu.focusLastNode()):this.focusLastChild()}openChildren(){this.elements.submenuToggles.forEach((e=>e.preview()))}focusNextNodeWithCharacter(e){const t=e.toLowerCase(),n=function e(t){let n=[];return t.elements.menuItems.forEach((t=>{n.push(t),t.isSubmenuItem&&t.elements.toggle.isOpen&&(n=[...n,...e(t.elements.toggle.elements.controlledMenu)])})),n}(this.elements.rootMenu),s=n.indexOf(this.currentMenuItem)+1,l=[...n.slice(s),...n.slice(0,s)];let o=0,i=!1;for(;!i&&o<l.length;){let e="";if(e=l[o].dom.item.innerText?l[o].dom.item.innerText:l[o].dom.item.textContent,e=e.replace(/[\s]/g,"").toLowerCase().charAt(0),e===t){i=!0;const e=l[o].elements.parentMenu,t=e.elements.menuItems.indexOf(l[o]);this.elements.rootMenu.blurChildren(),e.focusChild(t)}o++}}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 d extends h{constructor(e){let{menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l=!1,childMenu:o=null,toggle:i=null,initialize:r=!0}=e;super({menuItemElement:t,menuLinkElement:n,parentMenu:s,isSubmenuItem:l,childMenu:o,toggle:i,initialize:!1}),r&&this.initialize()}}class p extends c{_dom={toggle:null,parent:null,container:null};constructor(e){let{menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l=null,initialize:o=!0}=e;super({menuToggleElement:t,parentElement:n,controlledMenu:s,parentMenu:l,initialize:!1}),this._dom.toggle=t,this._dom.parent=n,this._dom.container=s.isTopLevel?s.dom.container:s.dom.menu,o&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),""!==t&&("string"==typeof t?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),""!==n&&("string"==typeof n?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class g extends a{_MenuType=g;_MenuItemType=d;_MenuToggleType=p;constructor(e){let{menuElement:t,menuItemSelector:n=".nav-item,li",menuLinkSelector:s=".nav-link,.dropdown-item",submenuItemSelector:l=".dropdown",submenuToggleSelector:o=".dropdown-toggle",submenuSelector:i=".dropdown-menu",controllerElement:r=null,containerElement:u=null,openClass:m="show",closeClass:h="collapse",isTopLevel:c=!0,parentMenu:a=null,hoverType:d="off",hoverDelay:p=250,initialize:g=!0}=e;super({menuElement:t,menuItemSelector:n,menuLinkSelector:s,submenuItemSelector:l,submenuToggleSelector:o,submenuSelector:i,controllerElement:r,containerElement:u,openClass:m,closeClass:h,isTopLevel:c,parentMenu:a,hoverType:d,hoverDelay:p,initialize:!1}),g&&this.initialize()}}return g}();
//# sourceMappingURL=treeview-bs5.min.js.map
{
"name": "accessible-menu-bootstrap-5",
"version": "1.0.2",
"version": "1.0.3",
"description": "A JavaScript library to help you generate WAI-ARIA accessible menus with in the DOM using Bootstrap 5.",

@@ -20,3 +20,3 @@ "main": "index.js",

"prebuild": "npm run build:docs",
"build": "rollup --config .rollup.config.js",
"build": "rollup --config rollup.config.mjs",
"build:docs": "jsdoc -c jsdoc.config.js",

@@ -49,36 +49,36 @@ "test": "jest"

"dependencies": {
"accessible-menu": "^3.0.4"
"accessible-menu": "^3.0.8"
},
"devDependencies": {
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/eslint-parser": "^7.14.7",
"@babel/preset-env": "^7.12.1",
"@commitlint/cli": "^17.0.0",
"@commitlint/config-conventional": "^17.0.0",
"@rollup/plugin-babel": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.0",
"commitizen": "^4.2.2",
"@babel/cli": "^7.22.5",
"@babel/core": "^7.22.5",
"@babel/eslint-parser": "^7.22.5",
"@babel/preset-env": "^7.22.5",
"@commitlint/cli": "^17.6.6",
"@commitlint/config-conventional": "^17.6.6",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-node-resolve": "^15.1.0",
"@rollup/plugin-terser": "^0.4.3",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^7.12.1",
"eslint-config-prettier": "^8.1.0",
"eslint-config-standard": "^16.0.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsdoc": "^40.0.0",
"eslint": "^8.43.0",
"eslint-config-prettier": "^8.8.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsdoc": "^46.4.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"husky": "^8.0.1",
"jest": "^29.0.0",
"jest-environment-jsdom": "^29.0.0",
"jest-extended": "^3.0.0",
"jsdoc": "^4.0.0",
"eslint-plugin-promise": "^6.1.1",
"husky": "^8.0.3",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jest-extended": "^4.0.0",
"jsdoc": "^4.0.2",
"jsdoc-typeof-plugin": "^1.0.0",
"lint-staged": "^13.0.1",
"prettier": "^2.1.2",
"rollup": "^2.33.1",
"lint-staged": "^13.2.3",
"prettier": "^2.8.8",
"rollup": "^2.79.1",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-terser": "^7.0.2",
"standard-version": "^9.0.0",
"terser": "^5.6.1"
"standard-version": "^9.5.0",
"terser": "^5.18.2"
}
}

@@ -48,3 +48,3 @@ # accessible-menu-bootstrap-5

```html
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.2/dist/accessible-menu-bs5.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.3/dist/accessible-menu-bs5.min.js"></script>
```

@@ -79,3 +79,3 @@

```html
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.2/dist/accessible-menu-bs5.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.3/dist/accessible-menu-bs5.min.js"></script>
```

@@ -108,3 +108,3 @@

```html
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.2/dist/disclosure-menu-bs5.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.3/dist/disclosure-menu-bs5.min.js"></script>
```

@@ -129,3 +129,3 @@

```html
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.2/dist/menubar-bs5.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.3/dist/menubar-bs5.min.js"></script>
```

@@ -150,3 +150,3 @@

```html
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.2/dist/treeview-bs5.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.3/dist/treeview-bs5.min.js"></script>
```

@@ -153,0 +153,0 @@

@@ -17,5 +17,6 @@ import DisclosureMenu from "accessible-menu/src/disclosureMenu.js";

* @type {typeof Bootstrap5DisclosureMenu}
*
* @protected
*/
_MenuType = Bootstrap5DisclosureMenu;
_MenuType = Bootstrap5DisclosureMenu; // eslint-disable-line no-use-before-define

@@ -26,2 +27,3 @@ /**

* @type {typeof Bootstrap5DisclosureMenuItem}
*
* @protected

@@ -35,2 +37,3 @@ */

* @type {typeof Bootstrap5DisclosureMenuToggle}
*
* @protected

@@ -37,0 +40,0 @@ */

@@ -1,2 +0,3 @@

/* eslint-disable jsdoc/no-undefined-types */
// eslint-disable-next-line no-unused-vars
/* global Bootstrap5DisclosureMenu Bootstrap5DisclosureMenuToggle */

@@ -3,0 +4,0 @@ import DisclosureMenuItem from "accessible-menu/src/disclosureMenuItem.js";

@@ -1,2 +0,3 @@

/* eslint-disable jsdoc/no-undefined-types */
// eslint-disable-next-line no-unused-vars
/* global Bootstrap5DisclosureMenu */

@@ -13,2 +14,3 @@ import DisclosureMenuToggle from "accessible-menu/src/disclosureMenuToggle.js";

* @type {Object<HTMLElement>}
*
* @property {HTMLElement} toggle - The menu toggle.

@@ -15,0 +17,0 @@ * @property {HTMLElement} parent - The menu containing this toggle.

@@ -15,5 +15,6 @@ import Menubar from "accessible-menu/src/menubar.js";

* @type {typeof Bootstrap5Menubar}
*
* @public
*/
_MenuType = Bootstrap5Menubar;
_MenuType = Bootstrap5Menubar; // eslint-disable-line no-use-before-define

@@ -24,2 +25,3 @@ /**

* @type {typeof Bootstrap5MenubarItem}
*
* @public

@@ -33,2 +35,3 @@ */

* @type {typeof Bootstrap5MenubarToggle}
*
* @public

@@ -35,0 +38,0 @@ */

@@ -1,2 +0,3 @@

/* eslint-disable jsdoc/no-undefined-types */
// eslint-disable-next-line no-unused-vars
/* global Bootstrap5Menubar Bootstrap5MenubarToggle */

@@ -3,0 +4,0 @@ import MenubarItem from "accessible-menu/src/menubarItem.js";

@@ -1,2 +0,3 @@

/* eslint-disable jsdoc/no-undefined-types */
// eslint-disable-next-line no-unused-vars
/* global Bootstrap5Menubar */

@@ -13,2 +14,3 @@ import MenubarToggle from "accessible-menu/src/menubarToggle.js";

* @type {Object<HTMLElement>}
*
* @property {HTMLElement} toggle - The menu toggle.

@@ -15,0 +17,0 @@ * @property {HTMLElement} parent - The menu containing this toggle.

@@ -15,5 +15,6 @@ import Treeview from "accessible-menu/src/treeview.js";

* @type {typeof Bootstrap5Treeview}
*
* @public
*/
_MenuType = Bootstrap5Treeview;
_MenuType = Bootstrap5Treeview; // eslint-disable-line no-use-before-define

@@ -24,2 +25,3 @@ /**

* @type {typeof Bootstrap5TreeviewItem}
*
* @public

@@ -33,2 +35,3 @@ */

* @type {typeof Bootstrap5TreeviewToggle}
*
* @public

@@ -35,0 +38,0 @@ */

@@ -1,2 +0,3 @@

/* eslint-disable jsdoc/no-undefined-types */
// eslint-disable-next-line no-unused-vars
/* global Bootstrap5Treeview Bootstrap5TreeviewToggle */

@@ -3,0 +4,0 @@ import TreeviewItem from "accessible-menu/src/treeviewItem.js";

@@ -1,2 +0,3 @@

/* eslint-disable jsdoc/no-undefined-types */
// eslint-disable-next-line no-unused-vars
/* global Bootstrap5Treeview */

@@ -13,2 +14,3 @@ import TreeviewToggle from "accessible-menu/src/treeviewToggle.js";

* @type {Object<HTMLElement>}
*
* @property {HTMLElement} toggle - The menu toggle.

@@ -15,0 +17,0 @@ * @property {HTMLElement} parent - The menu containing this toggle.

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc