accessible-menu-bootstrap-5
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -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",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",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",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 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:$}}(); | ||
//# sourceMappingURL=accessible-menu-bs5.min.js.map |
@@ -1355,3 +1355,3 @@ function isValidInstance(contructor, elements) { | ||
menuElement, | ||
menuItemSelector = ".nav-item", | ||
menuItemSelector = ".nav-item,li", | ||
menuLinkSelector = ".nav-link,.dropdown-item", | ||
@@ -1358,0 +1358,0 @@ submenuItemSelector = ".dropdown", |
@@ -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",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}}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}; | ||
//# sourceMappingURL=disclosure-menu-bs5.esm.min.js.map |
@@ -1358,3 +1358,3 @@ var Bootstrap5DisclosureMenu = (function () { | ||
menuElement, | ||
menuItemSelector = ".nav-item", | ||
menuItemSelector = ".nav-item,li", | ||
menuLinkSelector = ".nav-link,.dropdown-item", | ||
@@ -1361,0 +1361,0 @@ submenuItemSelector = ".dropdown", |
@@ -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",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}}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}(); | ||
//# sourceMappingURL=disclosure-menu-bs5.min.js.map |
@@ -1499,3 +1499,3 @@ function isValidInstance(contructor, elements) { | ||
menuElement, | ||
menuItemSelector = ".nav-item", | ||
menuItemSelector = ".nav-item,li", | ||
menuLinkSelector = ".nav-link,.dropdown-item", | ||
@@ -1502,0 +1502,0 @@ submenuItemSelector = ".dropdown", |
@@ -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",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 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}; | ||
//# sourceMappingURL=menubar-bs5.esm.min.js.map |
@@ -1502,3 +1502,3 @@ var Bootstrap5Menubar = (function () { | ||
menuElement, | ||
menuItemSelector = ".nav-item", | ||
menuItemSelector = ".nav-item,li", | ||
menuLinkSelector = ".nav-link,.dropdown-item", | ||
@@ -1505,0 +1505,0 @@ submenuItemSelector = ".dropdown", |
@@ -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",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 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}(); | ||
//# sourceMappingURL=menubar-bs5.min.js.map |
@@ -1434,3 +1434,3 @@ function isValidInstance(contructor, elements) { | ||
menuElement, | ||
menuItemSelector = ".nav-item", | ||
menuItemSelector = ".nav-item,li", | ||
menuLinkSelector = ".nav-link,.dropdown-item", | ||
@@ -1437,0 +1437,0 @@ submenuItemSelector = ".dropdown", |
@@ -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",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 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}; | ||
//# sourceMappingURL=treeview-bs5.esm.min.js.map |
@@ -1437,3 +1437,3 @@ var Bootstrap5Treeview = (function () { | ||
menuElement, | ||
menuItemSelector = ".nav-item", | ||
menuItemSelector = ".nav-item,li", | ||
menuLinkSelector = ".nav-link,.dropdown-item", | ||
@@ -1440,0 +1440,0 @@ submenuItemSelector = ".dropdown", |
@@ -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",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 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}(); | ||
//# sourceMappingURL=treeview-bs5.min.js.map |
{ | ||
"name": "accessible-menu-bootstrap-5", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A JavaScript library to help you generate WAI-ARIA accessible menus with in the DOM using Bootstrap 5.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -48,3 +48,3 @@ # accessible-menu-bootstrap-5 | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.1/dist/accessible-menu-bs5.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.2/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.1/dist/accessible-menu-bs5.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.2/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.1/dist/disclosure-menu-bs5.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.2/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.1/dist/menubar-bs5.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.2/dist/menubar-bs5.min.js"></script> | ||
``` | ||
@@ -150,3 +150,3 @@ | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.1/dist/treeview-bs5.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.2/dist/treeview-bs5.min.js"></script> | ||
``` | ||
@@ -153,0 +153,0 @@ |
@@ -40,23 +40,23 @@ import DisclosureMenu from "accessible-menu/src/disclosureMenu.js"; | ||
* | ||
* @param {object} options - The options for generating the menu. | ||
* @param {HTMLElement} options.menuElement - The menu element in the DOM. | ||
* @param {string} [options.menuItemSelector = li] - The CSS selector string for menu items. | ||
* @param {string} [options.menuLinkSelector = a] - The CSS selector string for menu links. | ||
* @param {string} [options.submenuItemSelector] - The CSS selector string for menu items containing submenus. | ||
* @param {string} [options.submenuToggleSelector = a] - The CSS selector string for submenu toggle buttons/links. | ||
* @param {string} [options.submenuSelector = ul] - The CSS selector string for submenus. | ||
* @param {(HTMLElement|null)} [options.controllerElement = null] - The element controlling the menu in the DOM. | ||
* @param {(HTMLElement|null)} [options.containerElement = null] - The element containing the menu in the DOM. | ||
* @param {(string|string[]|null)} [options.openClass = show] - The class to apply when a menu is "open". | ||
* @param {(string|string[]|null)} [options.closeClass = collapse] - The class to apply when a menu is "closed". | ||
* @param {boolean} [options.isTopLevel = false] - A flag to mark the root menu. | ||
* @param {(Bootstrap5DisclosureMenu|null)} [options.parentMenu = null] - The parent menu to this menu. | ||
* @param {string} [options.hoverType = off] - The type of hoverability a menu has. | ||
* @param {number} [options.hoverDelay = 250] - The delay for closing menus if the menu is hoverable (in miliseconds). | ||
* @param {boolean} [options.optionalKeySupport = false] - A flag to add optional keyboard support (Arrow keys, Home, and End) to the menu. | ||
* @param {boolean} [options.initialize = true] - A flag to initialize the menu immediately upon creation. | ||
* @param {object} options - The options for generating the menu. | ||
* @param {HTMLElement} options.menuElement - The menu element in the DOM. | ||
* @param {string} [options.menuItemSelector = .nav-item,li] - The CSS selector string for menu items. | ||
* @param {string} [options.menuLinkSelector = .nav-link,.dropdown-item] - The CSS selector string for menu links. | ||
* @param {string} [options.submenuItemSelector = .dropdown] - The CSS selector string for menu items containing submenus. | ||
* @param {string} [options.submenuToggleSelector = .dropdown-toggle] - The CSS selector string for submenu toggle buttons/links. | ||
* @param {string} [options.submenuSelector = .dropdown-menu] - The CSS selector string for submenus. | ||
* @param {(HTMLElement|null)} [options.controllerElement = null] - The element controlling the menu in the DOM. | ||
* @param {(HTMLElement|null)} [options.containerElement = null] - The element containing the menu in the DOM. | ||
* @param {(string|string[]|null)} [options.openClass = show] - The class to apply when a menu is "open". | ||
* @param {(string|string[]|null)} [options.closeClass = collapse] - The class to apply when a menu is "closed". | ||
* @param {boolean} [options.isTopLevel = false] - A flag to mark the root menu. | ||
* @param {(Bootstrap5DisclosureMenu|null)} [options.parentMenu = null] - The parent menu to this menu. | ||
* @param {string} [options.hoverType = off] - The type of hoverability a menu has. | ||
* @param {number} [options.hoverDelay = 250] - The delay for closing menus if the menu is hoverable (in miliseconds). | ||
* @param {boolean} [options.optionalKeySupport = false] - A flag to add optional keyboard support (Arrow keys, Home, and End) to the menu. | ||
* @param {boolean} [options.initialize = true] - A flag to initialize the menu immediately upon creation. | ||
*/ | ||
constructor({ | ||
menuElement, | ||
menuItemSelector = ".nav-item", | ||
menuItemSelector = ".nav-item,li", | ||
menuLinkSelector = ".nav-link,.dropdown-item", | ||
@@ -63,0 +63,0 @@ submenuItemSelector = ".dropdown", |
@@ -38,22 +38,22 @@ import Menubar from "accessible-menu/src/menubar.js"; | ||
* | ||
* @param {object} options - The options for generating the menu. | ||
* @param {HTMLElement} options.menuElement - The menu element in the DOM. | ||
* @param {string} [options.menuItemSelector = li] - The CSS selector string for menu items. | ||
* @param {string} [options.menuLinkSelector = a] - The CSS selector string for menu links. | ||
* @param {string} [options.submenuItemSelector] - The CSS selector string for menu items containing submenus. | ||
* @param {string} [options.submenuToggleSelector = a] - The CSS selector string for submenu toggle buttons/links. | ||
* @param {string} [options.submenuSelector = ul] - The CSS selector string for submenus. | ||
* @param {(HTMLElement|null)} [options.controllerElement = null] - The element controlling the menu in the DOM. | ||
* @param {(HTMLElement|null)} [options.containerElement = null] - The element containing the menu in the DOM. | ||
* @param {(string|string[]|null)} [options.openClass = show] - The class to apply when a menu is "open". | ||
* @param {(string|string[]|null)} [options.closeClass = collapse] - The class to apply when a menu is "closed". | ||
* @param {boolean} [options.isTopLevel = false] - A flag to mark the root menu. | ||
* @param {(Bootstrap5Menubar|null)} [options.parentMenu = null] - The parent menu to this menu. | ||
* @param {string} [options.hoverType = off] - The type of hoverability a menu has. | ||
* @param {number} [options.hoverDelay = 250] - The delay for closing menus if the menu is hoverable (in miliseconds). | ||
* @param {boolean} [options.initialize = true] - A flag to initialize the menu immediately upon creation. | ||
* @param {object} options - The options for generating the menu. | ||
* @param {HTMLElement} options.menuElement - The menu element in the DOM. | ||
* @param {string} [options.menuItemSelector = .nav-item,li] - The CSS selector string for menu items. | ||
* @param {string} [options.menuLinkSelector = .nav-link,.dropdown-item] - The CSS selector string for menu links. | ||
* @param {string} [options.submenuItemSelector = .dropdown] - The CSS selector string for menu items containing submenus. | ||
* @param {string} [options.submenuToggleSelector = .dropdown-toggle] - The CSS selector string for submenu toggle buttons/links. | ||
* @param {string} [options.submenuSelector = .dropdown-menu] - The CSS selector string for submenus. | ||
* @param {(HTMLElement|null)} [options.controllerElement = null] - The element controlling the menu in the DOM. | ||
* @param {(HTMLElement|null)} [options.containerElement = null] - The element containing the menu in the DOM. | ||
* @param {(string|string[]|null)} [options.openClass = show] - The class to apply when a menu is "open". | ||
* @param {(string|string[]|null)} [options.closeClass = collapse] - The class to apply when a menu is "closed". | ||
* @param {boolean} [options.isTopLevel = false] - A flag to mark the root menu. | ||
* @param {(Bootstrap5Menubar|null)} [options.parentMenu = null] - The parent menu to this menu. | ||
* @param {string} [options.hoverType = off] - The type of hoverability a menu has. | ||
* @param {number} [options.hoverDelay = 250] - The delay for closing menus if the menu is hoverable (in miliseconds). | ||
* @param {boolean} [options.initialize = true] - A flag to initialize the menu immediately upon creation. | ||
*/ | ||
constructor({ | ||
menuElement, | ||
menuItemSelector = ".nav-item", | ||
menuItemSelector = ".nav-item,li", | ||
menuLinkSelector = ".nav-link,.dropdown-item", | ||
@@ -60,0 +60,0 @@ submenuItemSelector = ".dropdown", |
@@ -37,23 +37,26 @@ import Treeview from "accessible-menu/src/treeview.js"; | ||
* Constructs the menu. | ||
/** | ||
* Constructs the menu. | ||
* | ||
* @param {object} options - The options for generating the menu. | ||
* @param {HTMLElement} options.menuElement - The menu element in the DOM. | ||
* @param {string} [options.menuItemSelector = li] - The CSS selector string for menu items. | ||
* @param {string} [options.menuLinkSelector = a] - The CSS selector string for menu links. | ||
* @param {string} [options.submenuItemSelector] - The CSS selector string for menu items containing submenus. | ||
* @param {string} [options.submenuToggleSelector = a] - The CSS selector string for submenu toggle buttons/links. | ||
* @param {string} [options.submenuSelector = ul] - The CSS selector string for submenus. | ||
* @param {(HTMLElement|null)} [options.controllerElement = null] - The element controlling the menu in the DOM. | ||
* @param {(HTMLElement|null)} [options.containerElement = null] - The element containing the menu in the DOM. | ||
* @param {(string|string[]|null)} [options.openClass = show] - The class to apply when a menu is "open". | ||
* @param {(string|string[]|null)} [options.closeClass = collapse] - The class to apply when a menu is "closed". | ||
* @param {boolean} [options.isTopLevel = false] - A flag to mark the root menu. | ||
* @param {(Bootstrap5Treeview|null)} [options.parentMenu = null] - The parent menu to this menu. | ||
* @param {string} [options.hoverType = off] - The type of hoverability a menu has. | ||
* @param {number} [options.hoverDelay = 250] - The delay for closing menus if the menu is hoverable (in miliseconds). | ||
* @param {boolean} [options.initialize = true] - A flag to initialize the menu immediately upon creation. | ||
* @param {object} options - The options for generating the menu. | ||
* @param {HTMLElement} options.menuElement - The menu element in the DOM. | ||
* @param {string} [options.menuItemSelector = .nav-item,li] - The CSS selector string for menu items. | ||
* @param {string} [options.menuLinkSelector = .nav-link,.dropdown-item] - The CSS selector string for menu links. | ||
* @param {string} [options.submenuItemSelector = .dropdown] - The CSS selector string for menu items containing submenus. | ||
* @param {string} [options.submenuToggleSelector = .dropdown-toggle] - The CSS selector string for submenu toggle buttons/links. | ||
* @param {string} [options.submenuSelector = .dropdown-menu] - The CSS selector string for submenus. | ||
* @param {(HTMLElement|null)} [options.controllerElement = null] - The element controlling the menu in the DOM. | ||
* @param {(HTMLElement|null)} [options.containerElement = null] - The element containing the menu in the DOM. | ||
* @param {(string|string[]|null)} [options.openClass = show] - The class to apply when a menu is "open". | ||
* @param {(string|string[]|null)} [options.closeClass = collapse] - The class to apply when a menu is "closed". | ||
* @param {boolean} [options.isTopLevel = false] - A flag to mark the root menu. | ||
* @param {(Bootstrap5Treeview|null)} [options.parentMenu = null] - The parent menu to this menu. | ||
* @param {string} [options.hoverType = off] - The type of hoverability a menu has. | ||
* @param {number} [options.hoverDelay = 250] - The delay for closing menus if the menu is hoverable (in miliseconds). | ||
* @param {boolean} [options.initialize = true] - A flag to initialize the menu immediately upon creation. | ||
*/ | ||
constructor({ | ||
menuElement, | ||
menuItemSelector = ".nav-item", | ||
menuItemSelector = ".nav-item,li", | ||
menuLinkSelector = ".nav-link,.dropdown-item", | ||
@@ -60,0 +63,0 @@ submenuItemSelector = ".dropdown", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2806255
12886