accessible-menu-bootstrap-5
Advanced tools
Comparing version 2.0.0-beta.0 to 2.0.0-beta.1
@@ -1,3 +0,3 @@ | ||
var AccessibleMenuBootstrap5=function(){"use strict";var ne=Object.defineProperty;var ie=(C,p,_)=>p in C?ne(C,p,{enumerable:!0,configurable:!0,writable:!0,value:_}):C[p]=_;var h=(C,p,_)=>(ie(C,typeof p!="symbol"?p+"":p,_),_);function C(o,s){try{if(typeof s!="object"){const e=typeof s;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${e}" given.`)}for(const e in s)if(!(s[e]instanceof o)){const t=typeof s[e];throw new TypeError(`${e} must be an instance of ${o.name}. "${t}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function p(o,s){try{if(typeof s!="object"){const e=typeof s;throw new TypeError(`Values given to isValidType() must be inside of an object. "${e}" given.`)}for(const e in s){const t=typeof s[e];if(t!==o)throw new TypeError(`${e} must be a ${o}. "${t}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function _(o){try{if(typeof o!="object"){const s=typeof o;throw new TypeError(`Values given to isCSSSelector() must be inside of an object. "${s}" given.`)}for(const s in o)try{if(o[s]===null)throw new Error;document.querySelector(o[s])}catch{throw new TypeError(`${s} must be a valid CSS selector. "${o[s]}" given.`)}return{status:!0,error:null}}catch(s){return{status:!1,error:s}}}function S(o){try{if(typeof o!="object"||Array.isArray(o)){const s=typeof o;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${s}" given.`)}for(const s in o){const e=typeof o[s];if(e!=="string")if(Array.isArray(o[s]))o[s].forEach(t=>{if(typeof t!="string")throw new TypeError(`${s} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${s} must be a string or an array of strings. "${e}" given.`);else{const t={};t[s]=o[s],_(t)}}return{status:!0,error:null}}catch(s){return{status:!1,error:s}}}function B(o){try{if(typeof o!="object"){const e=typeof o;throw new TypeError(`Values given to isValidState() must be inside of an object. "${e}" given.`)}const s=["none","self","child"];for(const e in o)if(!s.includes(o[e]))throw new TypeError(`${e} must be one of the following values: ${s.join(", ")}. "${o[e]}" given.`);return{status:!0,error:null}}catch(s){return{status:!1,error:s}}}function W(o){try{if(typeof o!="object"){const e=typeof o;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${e}" given.`)}const s=["none","mouse","keyboard","character"];for(const e in o)if(!s.includes(o[e]))throw new TypeError(`${e} must be one of the following values: ${s.join(", ")}. "${o[e]}" given.`);return{status:!0,error:null}}catch(s){return{status:!1,error:s}}}function F(o){try{if(typeof o!="object"){const e=typeof o;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${e}" given.`)}const s=["off","on","dynamic"];for(const e in o)if(!s.includes(o[e]))throw new TypeError(`${e} must be one of the following values: ${s.join(", ")}. "${o[e]}" given.`);return{status:!0,error:null}}catch(s){return{status:!1,error:s}}}function Z(o,s){if(p("string",{tagName:o}).status&&C(HTMLElement,s).status){const e=o.toLowerCase();let t=!0;for(const n in s)s[n].tagName.toLowerCase()!==e&&(t=!1);return t}else return!1}class w{constructor({menuToggleElement:s,parentElement:e,controlledMenu:t,parentMenu:n=null}){h(this,"_dom",{toggle:null,parent:null});h(this,"_elements",{controlledMenu:null,parentMenu:null});h(this,"_open",!1);h(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));h(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=s,this._dom.parent=e,this._elements.controlledMenu=t,this._elements.parentMenu=n}initialize(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),Z("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const s=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let e=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),t=s;!e.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(e=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),e.replace(/\s/g,"").length>0&&(e=e.toLowerCase().replace(/\s+/g,"-"),e.startsWith("-")&&(e=e.substring(1)),e.endsWith("-")&&(e=e.slice(0,-1)),t=`${e}-${t}`),this.dom.toggle.id=this.dom.toggle.id||`${t}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${t}-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(s){p("boolean",{value:s}),this._open=s}_expand(s=!0){const{closeClass:e,openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),t!==""&&(typeof t=="string"?this.elements.controlledMenu.dom.menu.classList.add(t):this.elements.controlledMenu.dom.menu.classList.add(...t)),e!==""&&(typeof e=="string"?this.elements.controlledMenu.dom.menu.classList.remove(e):this.elements.controlledMenu.dom.menu.classList.remove(...e)),s&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(s=!0){const{closeClass:e,openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),e!==""&&(typeof e=="string"?this.elements.controlledMenu.dom.menu.classList.add(e):this.elements.controlledMenu.dom.menu.classList.add(...e)),t!==""&&(typeof t=="string"?this.elements.controlledMenu.dom.menu.classList.remove(t):this.elements.controlledMenu.dom.menu.classList.remove(...t)),s&&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(s=>{s!==this&&s.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(s=>s.close())}}class v{constructor({menuItemElement:s,menuLinkElement:e,parentMenu:t,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null}){h(this,"_dom",{item:null,link:null});h(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});h(this,"_submenu",!1);this._dom.item=s,this._dom.link=e,this._elements.parentMenu=t,this._elements.childMenu=i,this._elements.toggle=r,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function E(o){try{const s=o.key||o.keyCode,e={Enter:s==="Enter"||s===13,Space:s===" "||s==="Spacebar"||s===32,Escape:s==="Escape"||s==="Esc"||s===27,ArrowUp:s==="ArrowUp"||s==="Up"||s===38,ArrowRight:s==="ArrowRight"||s==="Right"||s===39,ArrowDown:s==="ArrowDown"||s==="Down"||s===40,ArrowLeft:s==="ArrowLeft"||s==="Left"||s===37,Home:s==="Home"||s===36,End:s==="End"||s===35,Character:isNaN(s)&&!!s.match(/^[a-zA-Z]{1}$/),Tab:s==="Tab"||s===9,Asterisk:s==="*"||s===56};return Object.keys(e).find(t=>e[t]===!0)||""}catch{return""}}function l(o){o.preventDefault(),o.stopPropagation()}class I{constructor({menuElement:s,menuItemSelector:e="li",menuLinkSelector:t="a",submenuItemSelector:n="",submenuToggleSelector:i="a",submenuSelector:r="ul",controllerElement:u=null,containerElement:c=null,openClass:m="show",closeClass:d="hide",isTopLevel:a=!0,parentMenu:f=null,hoverType:g="off",hoverDelay:M=250}){h(this,"_MenuType",I);h(this,"_MenuItemType",v);h(this,"_MenuToggleType",w);h(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});h(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});h(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});h(this,"_openClass","show");h(this,"_closeClass","hide");h(this,"_root",!0);h(this,"_currentChild",0);h(this,"_focusState","none");h(this,"_currentEvent","none");h(this,"_hoverType","off");h(this,"_hoverDelay",250);h(this,"_errors",[]);this._dom.menu=s,this._dom.controller=u,this._dom.container=c,this._selectors.menuItems=e,this._selectors.menuLinks=t,this._selectors.submenuItems=n,this._selectors.submenuToggles=i,this._selectors.submenus=r,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=f,this._elements.rootMenu=a?this:null,this._openClass=m||"",this._closeClass=d||"",this._root=a,this._hoverType=g,this._hoverDelay=M}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
var AccessibleMenuBootstrap5=function(){"use strict";var ue=Object.defineProperty;var he=(a,d,v)=>d in a?ue(a,d,{enumerable:!0,configurable:!0,writable:!0,value:v}):a[d]=v;var u=(a,d,v)=>(he(a,typeof d!="symbol"?d+"":d,v),v);function a(o,t){typeof o=="string"?t.classList.add(o):t.classList.add(...o)}function d(o,t){typeof o=="string"?t.classList.remove(o):t.classList.remove(...o)}function v(o,t){try{if(typeof t!="object"){const e=typeof t;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${e}" given.`)}for(const e in t)if(!(t[e]instanceof o)){const s=typeof t[e];throw new TypeError(`${e} must be an instance of ${o.name}. "${s}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function I(o,t){try{if(typeof t!="object"){const e=typeof t;throw new TypeError(`Values given to isValidType() must be inside of an object. "${e}" given.`)}for(const e in t){const s=typeof t[e];if(s!==o)throw new TypeError(`${e} must be a ${o}. "${s}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function x(o){try{if(typeof o!="object"){const t=typeof o;throw new TypeError(`Values given to isCSSSelector() must be inside of an object. "${t}" given.`)}for(const t in o)try{if(o[t]===null)throw new Error;document.querySelector(o[t])}catch{throw new TypeError(`${t} must be a valid CSS selector. "${o[t]}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function A(o){try{if(typeof o!="object"||Array.isArray(o)){const t=typeof o;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${t}" given.`)}for(const t in o){const e=typeof o[t];if(e!=="string")if(Array.isArray(o[t]))o[t].forEach(s=>{if(typeof s!="string")throw new TypeError(`${t} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${t} must be a string or an array of strings. "${e}" given.`);else{const s={};s[t]=o[t],x(s)}}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function Q(o){try{if(typeof o!="object"){const e=typeof o;throw new TypeError(`Values given to isValidState() must be inside of an object. "${e}" given.`)}const t=["none","self","child"];for(const e in o)if(!t.includes(o[e]))throw new TypeError(`${e} must be one of the following values: ${t.join(", ")}. "${o[e]}" given.`);return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function X(o){try{if(typeof o!="object"){const e=typeof o;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${e}" given.`)}const t=["none","mouse","keyboard","character"];for(const e in o)if(!t.includes(o[e]))throw new TypeError(`${e} must be one of the following values: ${t.join(", ")}. "${o[e]}" given.`);return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function V(o){try{if(typeof o!="object"){const e=typeof o;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${e}" given.`)}const t=["off","on","dynamic"];for(const e in o)if(!t.includes(o[e]))throw new TypeError(`${e} must be one of the following values: ${t.join(", ")}. "${o[e]}" given.`);return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function Y(o,t){if(I("string",{tagName:o}).status&&v(HTMLElement,t).status){const e=o.toLowerCase();let s=!0;for(const n in t)t[n].tagName.toLowerCase()!==e&&(s=!1);return s}else return!1}class L{constructor({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n=null}){u(this,"_dom",{toggle:null,parent:null});u(this,"_elements",{controlledMenu:null,parentMenu:null});u(this,"_open",!1);u(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));u(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=t,this._dom.parent=e,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){var t;if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),Y("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 s=((t=this.dom.toggle.innerText)==null?void 0:t.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=e;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${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(t){I("boolean",{value:t}),this._open=t}_expand(t=!0){const{closeClass:e,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{e!==""&&d(e,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&a(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{d(n,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&a(s,this.elements.controlledMenu.dom.menu),e!==""&&d(e,this.elements.controlledMenu.dom.menu)),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:e,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(a(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&d(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{e!==""&&a(e,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{d(n,this.elements.controlledMenu.dom.menu)})})})):(e!==""&&a(e,this.elements.controlledMenu.dom.menu),s!==""&&d(s,this.elements.controlledMenu.dom.menu)),t&&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(t=>{t!==this&&t.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(t=>t.close())}}class D{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null}){u(this,"_dom",{item:null,link:null});u(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});u(this,"_submenu",!1);this._dom.item=t,this._dom.link=e,this._elements.parentMenu=s,this._elements.childMenu=i,this._elements.toggle=r,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function w(o){try{const t=o.key||o.keyCode,e={Enter:t==="Enter"||t===13,Space:t===" "||t==="Spacebar"||t===32,Escape:t==="Escape"||t==="Esc"||t===27,ArrowUp:t==="ArrowUp"||t==="Up"||t===38,ArrowRight:t==="ArrowRight"||t==="Right"||t===39,ArrowDown:t==="ArrowDown"||t==="Down"||t===40,ArrowLeft:t==="ArrowLeft"||t==="Left"||t===37,Home:t==="Home"||t===36,End:t==="End"||t===35,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:t==="Tab"||t===9,Asterisk:t==="*"||t===56};return Object.keys(e).find(s=>e[s]===!0)||""}catch{return""}}function l(o){o.preventDefault(),o.stopPropagation()}class S{constructor({menuElement:t,menuItemSelector:e="li",menuLinkSelector:s="a",submenuItemSelector:n="",submenuToggleSelector:i="a",submenuSelector:r="ul",controllerElement:h=null,containerElement:m=null,openClass:c="show",closeClass:f="hide",transitionClass:p="transitioning",isTopLevel:g=!0,parentMenu:M=null,hoverType:b="off",hoverDelay:y=250,enterDelay:_=-1,leaveDelay:C=-1}){u(this,"_MenuType",S);u(this,"_MenuItemType",D);u(this,"_MenuToggleType",L);u(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});u(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});u(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});u(this,"_openClass","show");u(this,"_closeClass","hide");u(this,"_transitionClass","transitioning");u(this,"_root",!0);u(this,"_currentChild",0);u(this,"_focusState","none");u(this,"_currentEvent","none");u(this,"_hoverType","off");u(this,"_hoverDelay",250);u(this,"_enterDelay",-1);u(this,"_leaveDelay",-1);u(this,"_hoverTimeout",null);u(this,"_errors",[]);this._dom.menu=t,this._dom.controller=h,this._dom.container=m,this._selectors.menuItems=e,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=i,this._selectors.submenus=r,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=M,this._elements.rootMenu=g?this:null,this._openClass=c||"",this._closeClass=f||"",this._transitionClass=p||"",this._root=g,this._hoverType=b,this._hoverDelay=y,this._enterDelay=_,this._leaveDelay=C}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
- ${this.errors.join(` | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const s=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=s}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 s=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(s=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(s=!0),s}get errors(){return this._errors}set openClass(s){S({openClass:s}),this._openClass!==s&&(this._openClass=s)}set closeClass(s){S({closeClass:s}),this._closeClass!==s&&(this._closeClass=s)}set currentChild(s){p("number",{value:s});function e(t){if(["mouse","character"].includes(t.currentEvent)&&t.elements.parentMenu){let i=0,r=!1;for(;!r&&i<t.elements.parentMenu.elements.menuItems.length;){const u=t.elements.parentMenu.elements.menuItems[i];u.isSubmenuItem&&u.elements.toggle.elements.controlledMenu===t&&(r=!0,t.elements.parentMenu.currentEvent=t.currentEvent,t.elements.parentMenu.currentChild=i),i++}}}s<-1?(this._currentChild=-1,e(this)):s>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,e(this)):this.focusChild!==s&&(this._currentChild=s,e(this))}set focusState(s){B({value:s}),this._focusState!==s&&(this._focusState=s),this.elements.submenuToggles.length>0&&(s==="self"||s==="none")&&this.elements.submenuToggles.forEach(e=>{e.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(s==="self"||s==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(s){W({value:s}),this._currentEvent!==s&&(this._currentEvent=s,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(e=>{e.elements.controlledMenu.currentEvent=s}))}set hoverType(s){F({value:s}),this._hoverType!==s&&(this._hoverType=s)}set hoverDelay(s){p("number",{value:s}),this._hoverDelay!==s&&(this._hoverDelay=s)}_validate(){let s=!0,e;this._dom.container!==null||this._dom.controller!==null?e=C(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):e=C(HTMLElement,{menuElement:this._dom.menu}),e.status||(this._errors.push(e.error.message),s=!1);let t;if(this._selectors.submenuItems!==""?t=_({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):t=_({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),t.status||(this._errors.push(t.error.message),s=!1),this._openClass!==""){const u=S({openClass:this._openClass});u.status||(this._errors.push(u.error.message),s=!1)}if(this._closeClass!==""){const u=S({closeClass:this._closeClass});u.status||(this._errors.push(u.error.message),s=!1)}const n=p("boolean",{isTopLevel:this._root});if(n.status||(this._errors.push(n.error.message),s=!1),this._elements.parentMenu!==null){const u=C(I,{parentMenu:this._elements.parentMenu});u.status||(this._errors.push(u.error.message),s=!1)}const i=F({hoverType:this._hoverType});i.status||(this._errors.push(i.error.message),s=!1);const r=p("number",{hoverDelay:this._hoverDelay});return r.status||(this._errors.push(r.error.message),s=!1),s}_setDOMElementType(s,e=this.dom.menu,t=!0){if(typeof this.selectors[s]=="string"){if(!Array.isArray(this.dom[s]))throw new Error(`AccessibleMenu: The "${s}" element cannot be set through _setDOMElementType.`);e!==this.dom.menu&&C(HTMLElement,{base:e});const i=Array.from(e.querySelectorAll(this.selectors[s])).filter(r=>r.parentElement===e);t?this._dom[s]=i:this._dom[s]=[...this._dom[s],...i]}else throw new Error(`AccessibleMenu: "${s}" is not a valid element type within the menu.`)}_resetDOMElementType(s){if(typeof this.dom[s]<"u"){if(!Array.isArray(this.dom[s]))throw new Error(`AccessibleMenu: The "${s}" element cannot be reset through _resetDOMElementType.`);this._dom[s]=[]}else throw new Error(`AccessibleMenu: "${s}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(s=>{this._setDOMElementType("submenuToggles",s,!1),this._setDOMElementType("submenus",s,!1)}))}_findRootMenu(s){if(s.isTopLevel)this._elements.rootMenu=s;else if(s.elements.parentMenu!==null)this._findRootMenu(s.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(s=>{let e;if(this.dom.submenuItems.includes(s)){const t=s.querySelector(this.selectors.submenuToggles),n=s.querySelector(this.selectors.submenus),i=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),r=new this._MenuToggleType({menuToggleElement:t,parentElement:s,controlledMenu:i,parentMenu:this});this._elements.submenuToggles.push(r),e=new this._MenuItemType({menuItemElement:s,menuLinkElement:t,parentMenu:this,isSubmenuItem:!0,childMenu:i,toggle:r})}else{const t=s.querySelector(this.selectors.menuLinks);e=new this._MenuItemType({menuItemElement:s,menuLinkElement:t,parentMenu:this})}this._elements.menuItems.push(e)})}_handleFocus(){this.elements.menuItems.forEach((s,e)=>{s.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=e})})}_handleClick(){function s(e,t,n){l(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t)},{passive:!0}),e.isSubmenuItem&&e.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",s(this,e.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",e=>{this.currentEvent="mouse",s(this,this.elements.controller,e)})}_handleHover(){this.elements.menuItems.forEach((s,e)=>{s.dom.link.addEventListener("pointerenter",t=>{if(!(t.pointerType==="pen"||t.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.currentChild=e,s.isSubmenuItem&&s.elements.toggle.preview();else if(this.hoverType==="dynamic"){const n=this.elements.submenuToggles.some(i=>i.isOpen);this.currentChild=e,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),s.isSubmenuItem&&(!this.isTopLevel||n)&&(this.currentEvent="mouse",s.elements.toggle.preview())}}}),s.isSubmenuItem&&s.dom.item.addEventListener("pointerleave",t=>{t.pointerType==="pen"||t.pointerType==="touch"||(this.hoverType==="on"?this.hoverDelay>0?setTimeout(()=>{this.currentEvent="mouse",s.elements.toggle.close()},this.hoverDelay):(this.currentEvent="mouse",s.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.hoverDelay>0?setTimeout(()=>{this.currentEvent="mouse",s.elements.toggle.close(),this.focusCurrentChild()},this.hoverDelay):(this.currentEvent="mouse",s.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",s=>{this.currentEvent="keyboard";const e=E(s);(e==="Space"||e==="Enter")&&l(s)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",s=>{this.currentEvent="keyboard";const e=E(s);(e==="Space"||e==="Enter")&&(l(s),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",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(s){this.blurCurrentChild(),this.currentChild=s,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(s=>s.close())}blurChildren(){this.elements.menuItems.forEach(s=>{s.blur(),s.isSubmenuItem&&s.elements.childMenu.blurChildren()})}}class N extends v{constructor({menuItemElement:s,menuLinkElement:e,parentMenu:t,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:u=!0}){super({menuItemElement:s,menuLinkElement:e,parentMenu:t,isSubmenuItem:n,childMenu:i,toggle:r}),u&&this.initialize()}}class H extends w{constructor({menuToggleElement:s,parentElement:e,controlledMenu:t,parentMenu:n=null,initialize:i=!0}){super({menuToggleElement:s,parentElement:e,controlledMenu:t,parentMenu:n}),i&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class L extends I{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:n="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:u="ul",controllerElement:c=null,containerElement:m=null,openClass:d="show",closeClass:a="hide",isTopLevel:f=!0,parentMenu:g=null,hoverType:M="off",hoverDelay:b=250,optionalKeySupport:y=!1,initialize:T=!0}){super({menuElement:e,menuItemSelector:t,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:u,controllerElement:c,containerElement:m,openClass:d,closeClass:a,isTopLevel:f,parentMenu:g,hoverType:M,hoverDelay:b});h(this,"_MenuType",L);h(this,"_MenuItemType",N);h(this,"_MenuToggleType",H);h(this,"_currentChild",-1);h(this,"_optionalSupport",!1);this._optionalSupport=y,T&&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){p("boolean",{optionalKeySupport:e}),this._optionalSupport=e}_validate(){let e=super._validate();const t=p("boolean",{optionalKeySupport:this._optionalSupport});return t.status||(this._errors.push(t.error.message),e=!1),e}_handleClick(){super._handleClick(),document.addEventListener("pointerup",e=>{this.focusState!=="none"&&(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=E(e);if(this.focusState==="self"){const n=["Space","Enter"],i=["Escape"],r=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(t)&&l(e):(this.currentMenuItem.isSubmenuItem&&n.includes(t)||this.elements.controller&&i.includes(t)||this.elements.parentMenu&&r.includes(t))&&l(e)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=E(e);this.focusState==="self"&&(t==="Space"||t==="Enter"?this.currentMenuItem.isSubmenuItem?(l(e),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():t==="Escape"?this.elements.submenuToggles.some(i=>i.isOpen)?(l(e),this.closeChildren()):this.elements.parentMenu?(l(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()):this.optionalKeySupport&&(t==="ArrowDown"||t==="ArrowRight"?(l(e),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):t==="ArrowUp"||t==="ArrowLeft"?(l(e),this.focusPreviousChild()):t==="Home"?(l(e),this.focusFirstChild()):t==="End"&&(l(e),this.focusLastChild())))})}}class G extends N{constructor({menuItemElement:s,menuLinkElement:e,parentMenu:t,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:u=!0}){super({menuItemElement:s,menuLinkElement:e,parentMenu:t,isSubmenuItem:n,childMenu:i,toggle:r,initialize:!1}),u&&this.initialize()}}class J extends H{constructor({menuToggleElement:e,parentElement:t,controlledMenu:n,parentMenu:i=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:n,parentMenu:i,initialize:!1});h(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=e,this._dom.parent=t,this._dom.container=n.isTopLevel?n.dom.container:n.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(e=!0){const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),t!==""&&(typeof t=="string"?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),t!==""&&(typeof t=="string"?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),n!==""&&(typeof n=="string"?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class k extends L{constructor({menuElement:e,menuItemSelector:t=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:u=".dropdown-menu",controllerElement:c=null,containerElement:m=null,openClass:d="show",closeClass:a="collapse",isTopLevel:f=!0,parentMenu:g=null,hoverType:M="off",hoverDelay:b=250,optionalKeySupport:y=!1,initialize:T=!0}){super({menuElement:e,menuItemSelector:t,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:u,controllerElement:c,containerElement:m,openClass:d,closeClass:a,isTopLevel:f,parentMenu:g,hoverType:M,hoverDelay:b,optionalKeySupport:y,initialize:!1});h(this,"_MenuType",k);h(this,"_MenuItemType",G);h(this,"_MenuToggleType",J);T&&this.initialize()}}class j extends v{constructor({menuItemElement:s,menuLinkElement:e,parentMenu:t,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:u=!0}){super({menuItemElement:s,menuLinkElement:e,parentMenu:t,isSubmenuItem:n,childMenu:i,toggle:r}),u&&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 V extends w{constructor({menuToggleElement:s,parentElement:e,controlledMenu:t,parentMenu:n=null,initialize:i=!0}){super({menuToggleElement:s,parentElement:e,controlledMenu:t,parentMenu:n}),i&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class A extends I{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:n="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:u="ul",controllerElement:c=null,containerElement:m=null,openClass:d="show",closeClass:a="hide",isTopLevel:f=!0,parentMenu:g=null,hoverType:M="off",hoverDelay:b=250,initialize:y=!0}){super({menuElement:e,menuItemSelector:t,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:u,controllerElement:c,containerElement:m,openClass:d,closeClass:a,isTopLevel:f,parentMenu:g,hoverType:M,hoverDelay:b});h(this,"_MenuType",A);h(this,"_MenuItemType",j);h(this,"_MenuToggleType",V);y&&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=>{this.focusState!=="none"&&(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=E(e);if(t==="Tab"&&(this.elements.rootMenu.focusState!=="none"?(this.elements.rootMenu.blur(),this.elements.rootMenu.closeChildren()):this.elements.rootMenu.focus()),t==="Character")l(e);else if(this.isTopLevel){if(this.focusState==="self"){const n=["ArrowRight","ArrowLeft","Home","End"],i=["Space","Enter","ArrowDown","ArrowUp"],r=["Escape"];(n.includes(t)||this.currentMenuItem.isSubmenuItem&&i.includes(t)||this.elements.controller&&r.includes(t))&&l(e)}}else{const n=["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"],i=["Space","Enter"];(n.includes(t)||this.currentMenuItem.isSubmenuItem&&i.includes(t))&&l(e)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=E(e),{altKey:n,crtlKey:i,metaKey:r}=e;if(t==="Character"&&!(n||i||r))l(e),this.elements.rootMenu.currentEvent="character",this.focusNextChildWithCharacter(e.key);else if(this.isTopLevel){if(this.focusState==="self")if(t==="Space"||t==="Enter")this.currentMenuItem.isSubmenuItem?(l(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(t==="ArrowRight"){l(e);const c=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusNextChild(),c&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if(t==="ArrowLeft"){l(e);const c=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusPreviousChild(),c&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else t==="ArrowDown"?this.currentMenuItem.isSubmenuItem&&(l(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):t==="ArrowUp"?this.currentMenuItem.isSubmenuItem&&(l(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusLastChild()})):t==="Home"?(l(e),this.focusFirstChild()):t==="End"?(l(e),this.focusLastChild()):t==="Escape"&&(this.elements.submenuToggles.some(m=>m.isOpen)?(l(e),this.closeChildren()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(l(e),this.elements.controller.close(),this.focusController()))}else t==="Space"||t==="Enter"?this.currentMenuItem.isSubmenuItem?(l(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click():t==="Escape"?(l(e),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusCurrentChild()):t==="ArrowRight"?this.currentMenuItem.isSubmenuItem?(l(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):(l(e),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusNextChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&this.elements.rootMenu.currentMenuItem.elements.toggle.preview()):t==="ArrowLeft"?this.elements.parentMenu.currentMenuItem.isSubmenuItem&&(l(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()))):t==="ArrowDown"?(l(e),this.focusNextChild()):t==="ArrowUp"?(l(e),this.focusPreviousChild()):t==="Home"?(l(e),this.focusFirstChild()):t==="End"&&(l(e),this.focusLastChild())})}focusNextChild(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}focusPreviousChild(){this.currentChild===0?this.focusLastChild():this.focusChild(this.currentChild-1)}focusNextChildWithCharacter(e){const t=e.toLowerCase();let n=this.currentChild+1,i=!1;for(;!i&&n<this.elements.menuItems.length;){let r="";this.elements.menuItems[n].dom.item.innerText?r=this.elements.menuItems[n].dom.item.innerText:r=this.elements.menuItems[n].dom.item.textContent,r=r.replace(/[\s]/g,"").toLowerCase().charAt(0),r===t&&(i=!0,this.focusChild(n)),n++}}}class Q extends j{constructor({menuItemElement:s,menuLinkElement:e,parentMenu:t,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:u=!0}){super({menuItemElement:s,menuLinkElement:e,parentMenu:t,isSubmenuItem:n,childMenu:i,toggle:r,initialize:!1}),u&&this.initialize()}}class X extends V{constructor({menuToggleElement:e,parentElement:t,controlledMenu:n,parentMenu:i=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:n,parentMenu:i,initialize:!1});h(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=e,this._dom.parent=t,this._dom.container=n.isTopLevel?n.dom.container:n.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(e=!0){const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),t!==""&&(typeof t=="string"?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),t!==""&&(typeof t=="string"?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),n!==""&&(typeof n=="string"?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class x extends A{constructor({menuElement:e,menuItemSelector:t=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:u=".dropdown-menu",controllerElement:c=null,containerElement:m=null,openClass:d="show",closeClass:a="collapse",isTopLevel:f=!0,parentMenu:g=null,hoverType:M="off",hoverDelay:b=250,initialize:y=!0}){super({menuElement:e,menuItemSelector:t,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:u,controllerElement:c,containerElement:m,openClass:d,closeClass:a,isTopLevel:f,parentMenu:g,hoverType:M,hoverDelay:b,initialize:!1});h(this,"_MenuType",x);h(this,"_MenuItemType",Q);h(this,"_MenuToggleType",X);y&&this.initialize()}}class R extends v{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:n,isSubmenuItem:i=!1,childMenu:r=null,toggle:u=null,initialize:c=!0,submenuSibling:m=null}){super({menuItemElement:e,menuLinkElement:t,parentMenu:n,isSubmenuItem:i,childMenu:r,toggle:u});h(this,"_elements",{parentMenu:null,childMenu:null,toggle:null,sibling:null});this._elements.parentMenu=n,this._elements.childMenu=r,this._elements.toggle=u,this._elements.sibling=m,c&&this.initialize()}}class P extends w{constructor({menuToggleElement:s,parentElement:e,controlledMenu:t,parentMenu:n=null,initialize:i=!0}){super({menuToggleElement:s,parentElement:e,controlledMenu:t,parentMenu:n}),i&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class z extends I{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:n="a",submenuItemSelector:i="",submenuToggleSelector:r="button",submenuSelector:u="ul",submenuSubtoggleSelector:c="a",controllerElement:m=null,containerElement:d=null,openClass:a="show",closeClass:f="hide",isTopLevel:g=!0,parentMenu:M=null,hoverType:b="off",hoverDelay:y=250,optionalKeySupport:T=!1,initialize:$=!0}){super({menuElement:e,menuItemSelector:t,menuLinkSelector:n,submenuItemSelector:i,submenuSelector:u,submenuToggleSelector:r,controllerElement:m,containerElement:d,openClass:a,closeClass:f,isTopLevel:g,parentMenu:M,hoverType:b,hoverDelay:y});h(this,"_MenuType",z);h(this,"_MenuItemType",R);h(this,"_MenuToggleType",P);h(this,"_currentChild",-1);h(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:"",submenuSubtoggles:""});h(this,"_optionalSupport",!1);this._optionalSupport=T,this._selectors.menuItems=t,this._selectors.submenuItems=i,this._selectors.submenuToggles=r,this._selectors.submenus=u,this._selectors.submenuSubtoggles=c,this._selectors.menuLinks=[...new Set([n,r])].join(","),$&&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){p("boolean",{optionalKeySupport:e}),this._optionalSupport=e}_createChildElements(){this.dom.menuItems.forEach(e=>{let t,n;const i=e.querySelector(this.selectors.menuLinks);if(this.dom.submenuItems.includes(e)){const r=e.querySelector(this.selectors.submenuToggles),u=e.querySelector(this.selectors.submenus),c=new this._MenuType({menuElement:u,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuSubtoggles,submenuSelector:this.selectors.submenus,submenuSubtoggleSelector:this.selectors.submenuSubtoggles,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),m=new this._MenuToggleType({menuToggleElement:r,parentElement:e,controlledMenu:c,parentMenu:this});this._elements.submenuToggles.push(m),r!==i?(n=new this._MenuItemType({menuItemElement:e,menuLinkElement:r,parentMenu:this,isSubmenuItem:!0,childMenu:c,toggle:m}),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:i,parentMenu:this,submenuSibling:n})):t=new this._MenuItemType({menuItemElement:e,menuLinkElement:i,parentMenu:this,isSubmenuItem:!0,childMenu:c,toggle:m})}else t=new this._MenuItemType({menuItemElement:e,menuLinkElement:i,parentMenu:this});this._elements.menuItems.push(t),typeof n<"u"&&this._elements.menuItems.push(n)})}_validate(){let e=super._validate();const t=_({submenuSubtoggleSelector:this._selectors.submenuSubtoggles});t.status||(this._errors.push(t.error.message),e=!1);const n=p("boolean",{optionalKeySupport:this._optionalSupport});return n.status||(this._errors.push(n.error.message),e=!1),e}_handleClick(){super._handleClick(),document.addEventListener("pointerup",e=>{this.focusState!=="none"&&(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()))})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",n=>{if(!(n.pointerType==="pen"||n.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem?e.elements.toggle.preview():e.elements.sibling!==null&&e.elements.sibling.elements.toggle.preview();else if(this.hoverType==="dynamic"){const i=this.elements.submenuToggles.some(r=>r.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),(!this.isTopLevel||i)&&(this.currentEvent="mouse",e.isSubmenuItem?e.elements.toggle.preview():e.elements.sibling!==null&&e.elements.sibling.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",n=>{n.pointerType==="pen"||n.pointerType==="touch"||(this.hoverType==="on"?this.hoverDelay>0?setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.hoverDelay):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(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(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=E(e);if(this.focusState==="self"){const n=["Space","Enter"],i=["Escape"],r=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(t)&&l(e):(this.currentMenuItem.isSubmenuItem&&n.includes(t)||this.elements.controller&&i.includes(t)||this.elements.parentMenu&&r.includes(t))&&l(e)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=E(e);this.focusState==="self"&&(t==="Space"||t==="Enter"?this.currentMenuItem.isSubmenuItem?(l(e),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():t==="Escape"?this.elements.submenuToggles.some(i=>i.isOpen)?(l(e),this.closeChildren()):this.elements.parentMenu?(l(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()):this.optionalKeySupport&&(t==="ArrowDown"||t==="ArrowRight"?(l(e),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):t==="ArrowUp"||t==="ArrowLeft"?(l(e),this.focusPreviousChild()):t==="Home"?(l(e),this.focusFirstChild()):t==="End"&&(l(e),this.focusLastChild())))})}}class Y extends R{constructor({menuItemElement:s,menuLinkElement:e,parentMenu:t,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:u=!0,submenuSibling:c=null}){super({menuItemElement:s,menuLinkElement:e,parentMenu:t,isSubmenuItem:n,childMenu:i,toggle:r,initialize:!1,submenuSibling:c}),u&&this.initialize()}}class ee extends P{constructor({menuToggleElement:e,parentElement:t,controlledMenu:n,parentMenu:i=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:n,parentMenu:i,initialize:!1});h(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=e,this._dom.parent=t,this._dom.container=n.isTopLevel?n.dom.container:n.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(e=!0){const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),t!==""&&(typeof t=="string"?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),t!==""&&(typeof t=="string"?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),n!==""&&(typeof n=="string"?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class O extends z{constructor({menuElement:e,menuItemSelector:t=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:u=".dropdown-menu",submenuSubtoggleSelector:c=".dropdown-toggle",controllerElement:m=null,containerElement:d=null,openClass:a="show",closeClass:f="collapse",isTopLevel:g=!0,parentMenu:M=null,hoverType:b="off",hoverDelay:y=250,optionalKeySupport:T=!1,initialize:$=!0}){super({menuElement:e,menuItemSelector:t,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:u,submenuSubtoggleSelector:c,controllerElement:m,containerElement:d,openClass:a,closeClass:f,isTopLevel:g,parentMenu:M,hoverType:b,hoverDelay:y,optionalKeySupport:T,initialize:!1});h(this,"_MenuType",O);h(this,"_MenuItemType",Y);h(this,"_MenuToggleType",ee);$&&this.initialize()}}class q extends v{constructor({menuItemElement:s,menuLinkElement:e,parentMenu:t,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:u=!0}){super({menuItemElement:s,menuLinkElement:e,parentMenu:t,isSubmenuItem:n,childMenu:i,toggle:r}),u&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","treeitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.dom.link.tabIndex=0}blur(){super.blur(),this.dom.link.tabIndex=-1}}class U extends w{constructor({menuToggleElement:s,parentElement:e,controlledMenu:t,parentMenu:n=null,initialize:i=!0}){super({menuToggleElement:s,parentElement:e,controlledMenu:t,parentMenu:n}),i&&this.initialize()}}class D extends I{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:n="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:u="ul",controllerElement:c=null,containerElement:m=null,openClass:d="show",closeClass:a="hide",isTopLevel:f=!0,parentMenu:g=null,hoverType:M="off",hoverDelay:b=250,initialize:y=!0}){super({menuElement:e,menuItemSelector:t,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:u,controllerElement:c,containerElement:m,openClass:d,closeClass:a,isTopLevel:f,parentMenu:g,hoverType:M,hoverDelay:b});h(this,"_MenuType",D);h(this,"_MenuItemType",q);h(this,"_MenuToggleType",U);y&&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=E(e);if(t==="Tab"&&(this.elements.rootMenu.focusState!=="none"?this.elements.rootMenu.blur():this.elements.rootMenu.focus()),this.focusState==="self"){const n=["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"],i=["Enter","ArrowRight"],r=["Escape"];(n.includes(t)||this.currentMenuItem.isSubmenuItem&&i.includes(t)||this.elements.controller&&r.includes(t))&&l(e)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=E(e),{altKey:n,crtlKey:i,metaKey:r}=e;if(t==="Character"&&!(n||i||r))l(e),this.elements.rootMenu.currentEvent="character",this.focusNextNodeWithCharacter(e.key);else if(this.focusState==="self")if(t==="Enter"||t==="Space")l(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(t==="Escape")this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController());else if(t==="ArrowDown")l(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.focusParentsNextChild():this.focusNextChild();else if(t==="ArrowUp"){l(e);const c=this.elements.menuItems[this.currentChild-1];c&&c.isSubmenuItem&&c.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentChild=this.currentChild-1,this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.focusChildsLastNode()):!this.isTopLevel&&this.currentChild===0?(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild()):this.focusPreviousChild()}else t==="ArrowRight"?this.currentMenuItem.isSubmenuItem&&(l(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()):t==="ArrowLeft"?(l(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())):t==="Home"?(l(e),this.blurCurrentChild(),this.elements.rootMenu.focusFirstChild()):t==="End"?(l(e),this.blurCurrentChild(),this.elements.rootMenu.focusLastNode()):t==="Asterisk"&&(l(e),this.openChildren())})}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){function t(d){let a=[];return d.elements.menuItems.forEach(f=>{a.push(f),f.isSubmenuItem&&f.elements.toggle.isOpen&&(a=[...a,...t(f.elements.toggle.elements.controlledMenu)])}),a}const n=e.toLowerCase(),i=t(this.elements.rootMenu),r=i.indexOf(this.currentMenuItem)+1,u=[...i.slice(r),...i.slice(0,r)];let c=0,m=!1;for(;!m&&c<u.length;){let d="";if(u[c].dom.item.innerText?d=u[c].dom.item.innerText:d=u[c].dom.item.textContent,d=d.replace(/[\s]/g,"").toLowerCase().charAt(0),d===n){m=!0;const a=u[c].elements.parentMenu,f=a.elements.menuItems.indexOf(u[c]);this.elements.rootMenu.blurChildren(),a.focusChild(f)}c++}}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 te extends q{constructor({menuItemElement:s,menuLinkElement:e,parentMenu:t,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:u=!0}){super({menuItemElement:s,menuLinkElement:e,parentMenu:t,isSubmenuItem:n,childMenu:i,toggle:r,initialize:!1}),u&&this.initialize()}}class se extends U{constructor({menuToggleElement:e,parentElement:t,controlledMenu:n,parentMenu:i=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:n,parentMenu:i,initialize:!1});h(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=e,this._dom.parent=t,this._dom.container=n.isTopLevel?n.dom.container:n.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(e=!0){const{openClass:t}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),t!==""&&(typeof t=="string"?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),t!==""&&(typeof t=="string"?this.dom.container.classList.add(t):this.dom.container.classList.add(...t)),n!==""&&(typeof n=="string"?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class K extends D{constructor({menuElement:e,menuItemSelector:t=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:u=".dropdown-menu",controllerElement:c=null,containerElement:m=null,openClass:d="show",closeClass:a="collapse",isTopLevel:f=!0,parentMenu:g=null,hoverType:M="off",hoverDelay:b=250,initialize:y=!0}){super({menuElement:e,menuItemSelector:t,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:u,controllerElement:c,containerElement:m,openClass:d,closeClass:a,isTopLevel:f,parentMenu:g,hoverType:M,hoverDelay:b,initialize:!1});h(this,"_MenuType",K);h(this,"_MenuItemType",te);h(this,"_MenuToggleType",se);y&&this.initialize()}}return{Bootstrap5DisclosureMenu:k,Bootstrap5Menubar:x,Bootstrap5TopLinkDisclosureMenu:O,Bootstrap5Treeview:K}}(); | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const t=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=t}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let t=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(t=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(t=!0),t}get errors(){return this._errors}set openClass(t){A({openClass:t}),this._openClass!==t&&(this._openClass=t)}set closeClass(t){A({closeClass:t}),this._closeClass!==t&&(this._closeClass=t)}set transitionClass(t){A({transitionClass:t}),this._transitionClass!==t&&(this._transitionClass=t)}set currentChild(t){I("number",{value:t});function e(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let i=0,r=!1;for(;!r&&i<s.elements.parentMenu.elements.menuItems.length;){const h=s.elements.parentMenu.elements.menuItems[i];h.isSubmenuItem&&h.elements.toggle.elements.controlledMenu===s&&(r=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=i),i++}}}t<-1?(this._currentChild=-1,e(this)):t>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,e(this)):this.focusChild!==t&&(this._currentChild=t,e(this))}set focusState(t){Q({value:t}),this._focusState!==t&&(this._focusState=t),this.elements.submenuToggles.length>0&&(t==="self"||t==="none")&&this.elements.submenuToggles.forEach(e=>{e.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(t==="self"||t==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(t){X({value:t}),this._currentEvent!==t&&(this._currentEvent=t,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(e=>{e.elements.controlledMenu.currentEvent=t}))}set hoverType(t){V({value:t}),this._hoverType!==t&&(this._hoverType=t)}set hoverDelay(t){I("number",{value:t}),this._hoverDelay!==t&&(this._hoverDelay=t)}set enterDelay(t){I("number",{value:t}),this._enterDelay!==t&&(this._enterDelay=t)}set leaveDelay(t){I("number",{value:t}),this._leaveDelay!==t&&(this._leaveDelay=t)}_validate(){let t=!0,e;this._dom.container!==null||this._dom.controller!==null?e=v(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):e=v(HTMLElement,{menuElement:this._dom.menu}),e.status||(this._errors.push(e.error.message),t=!1);let s;if(this._selectors.submenuItems!==""?s=x({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=x({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),t=!1),this._openClass!==""){const c=A({openClass:this._openClass});c.status||(this._errors.push(c.error.message),t=!1)}if(this._closeClass!==""){const c=A({closeClass:this._closeClass});c.status||(this._errors.push(c.error.message),t=!1)}if(this._transitionClass!==""){const c=A({transitionClass:this._transitionClass});c.status||(this._errors.push(c.error.message),t=!1)}const n=I("boolean",{isTopLevel:this._root});if(n.status||(this._errors.push(n.error.message),t=!1),this._elements.parentMenu!==null){const c=v(S,{parentMenu:this._elements.parentMenu});c.status||(this._errors.push(c.error.message),t=!1)}const i=V({hoverType:this._hoverType});i.status||(this._errors.push(i.error.message),t=!1);const r=I("number",{hoverDelay:this._hoverDelay});r.status||(this._errors.push(r.error.message),t=!1);const h=I("number",{enterDelay:this._enterDelay});h.status||(this._errors.push(h.error.message),t=!1);const m=I("number",{leaveDelay:this._leaveDelay});return m.status||(this._errors.push(m.error.message),t=!1),t}_setDOMElementType(t,e=this.dom.menu,s=!0){if(typeof this.selectors[t]=="string"){if(!Array.isArray(this.dom[t]))throw new Error(`AccessibleMenu: The "${t}" element cannot be set through _setDOMElementType.`);e!==this.dom.menu&&v(HTMLElement,{base:e});const i=Array.from(e.querySelectorAll(this.selectors[t])).filter(r=>r.parentElement===e);s?this._dom[t]=i:this._dom[t]=[...this._dom[t],...i]}else throw new Error(`AccessibleMenu: "${t}" is not a valid element type within the menu.`)}_resetDOMElementType(t){if(typeof this.dom[t]<"u"){if(!Array.isArray(this.dom[t]))throw new Error(`AccessibleMenu: The "${t}" element cannot be reset through _resetDOMElementType.`);this._dom[t]=[]}else throw new Error(`AccessibleMenu: "${t}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(t=>{this._setDOMElementType("submenuToggles",t,!1),this._setDOMElementType("submenus",t,!1)}))}_findRootMenu(t){if(t.isTopLevel)this._elements.rootMenu=t;else if(t.elements.parentMenu!==null)this._findRootMenu(t.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(t=>{let e;if(this.dom.submenuItems.includes(t)){const s=t.querySelector(this.selectors.submenuToggles),n=t.querySelector(this.selectors.submenus),i=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),r=new this._MenuToggleType({menuToggleElement:s,parentElement:t,controlledMenu:i,parentMenu:this});this._elements.submenuToggles.push(r),e=new this._MenuItemType({menuItemElement:t,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:i,toggle:r})}else{const s=t.querySelector(this.selectors.menuLinks);e=new this._MenuItemType({menuItemElement:t,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(e)})}_handleFocus(){this.elements.menuItems.forEach((t,e)=>{t.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=e})})}_handleClick(){function t(e,s,n){l(n),s.toggle(),s.isOpen&&(e.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((e,s)=>{e.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),e.isSubmenuItem&&e.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",t(this,e.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",e=>{this.currentEvent="mouse",t(this,this.elements.controller,e)})}_handleHover(){this.elements.menuItems.forEach((t,e)=>{t.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.currentChild=e,t.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{t.elements.toggle.preview()},this.enterDelay):t.elements.toggle.preview());else if(this.hoverType==="dynamic"){const n=this.elements.submenuToggles.some(i=>i.isOpen);this.currentChild=e,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),t.isSubmenuItem&&(!this.isTopLevel||n)&&(this.currentEvent="mouse",this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{t.elements.toggle.preview()},this.enterDelay):t.elements.toggle.preview())}}}),t.isSubmenuItem&&t.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",t.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",t.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",t.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",t.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",t=>{this.currentEvent="keyboard";const e=w(t);(e==="Space"||e==="Enter")&&l(t)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",t=>{this.currentEvent="keyboard";const e=w(t);(e==="Space"||e==="Enter")&&(l(t),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",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(t){this.blurCurrentChild(),this.currentChild=t,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(t=>t.close())}blurChildren(){this.elements.menuItems.forEach(t=>{t.blur(),t.isSubmenuItem&&t.elements.childMenu.blurChildren()})}}class R extends D{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r}),h&&this.initialize()}}class P extends L{constructor({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n=null,initialize:i=!0}){super({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n}),i&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class z extends S{constructor({menuElement:e,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:h="ul",controllerElement:m=null,containerElement:c=null,openClass:f="show",closeClass:p="hide",transitionClass:g="transitioning",isTopLevel:M=!0,parentMenu:b=null,hoverType:y="off",hoverDelay:_=250,enterDelay:C=-1,leaveDelay:E=-1,optionalKeySupport:T=!1,initialize:k=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,controllerElement:m,containerElement:c,openClass:f,closeClass:p,transitionClass:g,isTopLevel:M,parentMenu:b,hoverType:y,hoverDelay:_,enterDelay:C,leaveDelay:E});u(this,"_MenuType",z);u(this,"_MenuItemType",R);u(this,"_MenuToggleType",P);u(this,"_currentChild",-1);u(this,"_optionalSupport",!1);this._optionalSupport=T,k&&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){I("boolean",{optionalKeySupport:e}),this._optionalSupport=e}_validate(){let e=super._validate();const s=I("boolean",{optionalKeySupport:this._optionalSupport});return s.status||(this._errors.push(s.error.message),e=!1),e}_handleClick(){super._handleClick(),document.addEventListener("pointerup",e=>{this.focusState!=="none"&&(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 s=w(e);if(this.focusState==="self"){const n=["Space","Enter"],i=["Escape"],r=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&l(e):(this.currentMenuItem.isSubmenuItem&&n.includes(s)||this.elements.controller&&i.includes(s)||this.elements.parentMenu&&r.includes(s))&&l(e)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",e=>{this.currentEvent="keyboard";const s=w(e);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(l(e),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(i=>i.isOpen)?(l(e),this.closeChildren()):this.elements.parentMenu?(l(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()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(l(e),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(l(e),this.focusPreviousChild()):s==="Home"?(l(e),this.focusFirstChild()):s==="End"&&(l(e),this.focusLastChild())))})}}class ee extends R{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r,initialize:!1}),h&&this.initialize()}}class te extends P{constructor({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i,initialize:!1});u(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=e,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.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(e=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{d(n,this.dom.container)})})):s!==""&&a(s,this.dom.container),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:s,openClass:n,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),i!==""?(a(i,this.dom.container),requestAnimationFrame(()=>{n!==""&&d(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&a(s,this.dom.container),requestAnimationFrame(()=>{d(i,this.dom.container)})})})):(s!==""&&a(s,this.dom.container),n!==""&&d(n,this.dom.container)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class O extends z{constructor({menuElement:e,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:h=".dropdown-menu",controllerElement:m=null,containerElement:c=null,openClass:f="show",closeClass:p="collapse",transitionClass:g="transitioning",isTopLevel:M=!0,parentMenu:b=null,hoverType:y="off",hoverDelay:_=250,enterDelay:C=-1,leaveDelay:E=-1,optionalKeySupport:T=!1,initialize:k=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,controllerElement:m,containerElement:c,openClass:f,closeClass:p,transitionClass:g,isTopLevel:M,parentMenu:b,hoverType:y,hoverDelay:_,enterDelay:C,leaveDelay:E,optionalKeySupport:T,initialize:!1});u(this,"_MenuType",O);u(this,"_MenuItemType",ee);u(this,"_MenuToggleType",te);k&&this.initialize()}}class U extends D{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r}),h&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","menuitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=0)}blur(){super.blur(),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=-1)}}class B extends L{constructor({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n=null,initialize:i=!0}){super({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n}),i&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class F extends S{constructor({menuElement:e,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:h="ul",controllerElement:m=null,containerElement:c=null,openClass:f="show",closeClass:p="hide",transitionClass:g="transitioning",isTopLevel:M=!0,parentMenu:b=null,hoverType:y="off",hoverDelay:_=250,enterDelay:C=-1,leaveDelay:E=-1,initialize:T=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,controllerElement:m,containerElement:c,openClass:f,closeClass:p,transitionClass:g,isTopLevel:M,parentMenu:b,hoverType:y,hoverDelay:_,enterDelay:C,leaveDelay:E});u(this,"_MenuType",F);u(this,"_MenuItemType",U);u(this,"_MenuToggleType",B);T&&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=>{this.focusState!=="none"&&(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 s=w(e);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?(this.elements.rootMenu.blur(),this.elements.rootMenu.closeChildren()):this.elements.rootMenu.focus()),s==="Character")l(e);else if(this.isTopLevel){if(this.focusState==="self"){const n=["ArrowRight","ArrowLeft","Home","End"],i=["Space","Enter","ArrowDown","ArrowUp"],r=["Escape"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&i.includes(s)||this.elements.controller&&r.includes(s))&&l(e)}}else{const n=["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"],i=["Space","Enter"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&i.includes(s))&&l(e)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",e=>{this.currentEvent="keyboard";const s=w(e),{altKey:n,crtlKey:i,metaKey:r}=e;if(s==="Character"&&!(n||i||r))l(e),this.elements.rootMenu.currentEvent="character",this.focusNextChildWithCharacter(e.key);else if(this.isTopLevel){if(this.focusState==="self")if(s==="Space"||s==="Enter")this.currentMenuItem.isSubmenuItem?(l(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(s==="ArrowRight"){l(e);const m=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusNextChild(),m&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if(s==="ArrowLeft"){l(e);const m=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusPreviousChild(),m&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else s==="ArrowDown"?this.currentMenuItem.isSubmenuItem&&(l(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):s==="ArrowUp"?this.currentMenuItem.isSubmenuItem&&(l(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusLastChild()})):s==="Home"?(l(e),this.focusFirstChild()):s==="End"?(l(e),this.focusLastChild()):s==="Escape"&&(this.elements.submenuToggles.some(c=>c.isOpen)?(l(e),this.closeChildren()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(l(e),this.elements.controller.close(),this.focusController()))}else s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(l(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click():s==="Escape"?(l(e),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusCurrentChild()):s==="ArrowRight"?this.currentMenuItem.isSubmenuItem?(l(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):(l(e),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusNextChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&this.elements.rootMenu.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?this.elements.parentMenu.currentMenuItem.isSubmenuItem&&(l(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()))):s==="ArrowDown"?(l(e),this.focusNextChild()):s==="ArrowUp"?(l(e),this.focusPreviousChild()):s==="Home"?(l(e),this.focusFirstChild()):s==="End"&&(l(e),this.focusLastChild())})}focusNextChild(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}focusPreviousChild(){this.currentChild===0?this.focusLastChild():this.focusChild(this.currentChild-1)}focusNextChildWithCharacter(e){const s=e.toLowerCase();let n=this.currentChild+1,i=!1;for(;!i&&n<this.elements.menuItems.length;){let r="";this.elements.menuItems[n].dom.item.innerText?r=this.elements.menuItems[n].dom.item.innerText:r=this.elements.menuItems[n].dom.item.textContent,r=r.replace(/[\s]/g,"").toLowerCase().charAt(0),r===s&&(i=!0,this.focusChild(n)),n++}}}class se extends U{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r,initialize:!1}),h&&this.initialize()}}class ne extends B{constructor({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i,initialize:!1});u(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=e,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.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(e=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{d(n,this.dom.container)})})):s!==""&&a(s,this.dom.container),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:s,openClass:n,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),i!==""?(a(i,this.dom.container),requestAnimationFrame(()=>{n!==""&&d(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&a(s,this.dom.container),requestAnimationFrame(()=>{d(i,this.dom.container)})})})):(s!==""&&a(s,this.dom.container),n!==""&&d(n,this.dom.container)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class K extends F{constructor({menuElement:e,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:h=".dropdown-menu",controllerElement:m=null,containerElement:c=null,openClass:f="show",closeClass:p="collapse",transitionClass:g="transitioning",isTopLevel:M=!0,parentMenu:b=null,hoverType:y="off",hoverDelay:_=250,enterDelay:C=-1,leaveDelay:E=-1,initialize:T=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,controllerElement:m,containerElement:c,openClass:f,closeClass:p,transitionClass:g,isTopLevel:M,parentMenu:b,hoverType:y,hoverDelay:_,enterDelay:C,leaveDelay:E,initialize:!1});u(this,"_MenuType",K);u(this,"_MenuItemType",se);u(this,"_MenuToggleType",ne);T&&this.initialize()}}class W extends D{constructor({menuItemElement:e,menuLinkElement:s,parentMenu:n,isSubmenuItem:i=!1,childMenu:r=null,toggle:h=null,initialize:m=!0,submenuSibling:c=null}){super({menuItemElement:e,menuLinkElement:s,parentMenu:n,isSubmenuItem:i,childMenu:r,toggle:h});u(this,"_elements",{parentMenu:null,childMenu:null,toggle:null,sibling:null});this._elements.parentMenu=n,this._elements.childMenu=r,this._elements.toggle=h,this._elements.sibling=c,m&&this.initialize()}}class Z extends L{constructor({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n=null,initialize:i=!0}){super({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n}),i&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class q extends S{constructor({menuElement:e,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:i="",submenuToggleSelector:r="button",submenuSelector:h="ul",submenuSubtoggleSelector:m="a",controllerElement:c=null,containerElement:f=null,openClass:p="show",closeClass:g="hide",transitionClass:M="transitioning",isTopLevel:b=!0,parentMenu:y=null,hoverType:_="off",hoverDelay:C=250,enterDelay:E=-1,leaveDelay:T=-1,optionalKeySupport:k=!1,initialize:j=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuSelector:h,submenuToggleSelector:r,controllerElement:c,containerElement:f,openClass:p,closeClass:g,transitionClass:M,isTopLevel:b,parentMenu:y,hoverType:_,hoverDelay:C,enterDelay:E,leaveDelay:T});u(this,"_MenuType",q);u(this,"_MenuItemType",W);u(this,"_MenuToggleType",Z);u(this,"_currentChild",-1);u(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:"",submenuSubtoggles:""});u(this,"_optionalSupport",!1);this._optionalSupport=k,this._selectors.menuItems=s,this._selectors.submenuItems=i,this._selectors.submenuToggles=r,this._selectors.submenus=h,this._selectors.submenuSubtoggles=m,this._selectors.menuLinks=[...new Set([n,r])].join(","),j&&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){I("boolean",{optionalKeySupport:e}),this._optionalSupport=e}_createChildElements(){this.dom.menuItems.forEach(e=>{let s,n;const i=e.querySelector(this.selectors.menuLinks);if(this.dom.submenuItems.includes(e)){const r=e.querySelector(this.selectors.submenuToggles),h=e.querySelector(this.selectors.submenus),m=new this._MenuType({menuElement:h,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuSubtoggles,submenuSelector:this.selectors.submenus,submenuSubtoggleSelector:this.selectors.submenuSubtoggles,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),c=new this._MenuToggleType({menuToggleElement:r,parentElement:e,controlledMenu:m,parentMenu:this});this._elements.submenuToggles.push(c),r!==i?(n=new this._MenuItemType({menuItemElement:e,menuLinkElement:r,parentMenu:this,isSubmenuItem:!0,childMenu:m,toggle:c}),s=new this._MenuItemType({menuItemElement:e,menuLinkElement:i,parentMenu:this,submenuSibling:n})):s=new this._MenuItemType({menuItemElement:e,menuLinkElement:i,parentMenu:this,isSubmenuItem:!0,childMenu:m,toggle:c})}else s=new this._MenuItemType({menuItemElement:e,menuLinkElement:i,parentMenu:this});this._elements.menuItems.push(s),typeof n<"u"&&this._elements.menuItems.push(n)})}_validate(){let e=super._validate();const s=x({submenuSubtoggleSelector:this._selectors.submenuSubtoggles});s.status||(this._errors.push(s.error.message),e=!1);const n=I("boolean",{optionalKeySupport:this._optionalSupport});return n.status||(this._errors.push(n.error.message),e=!1),e}_handleClick(){super._handleClick(),document.addEventListener("pointerup",e=>{this.focusState!=="none"&&(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()))})}_handleHover(){this.elements.menuItems.forEach((e,s)=>{e.dom.link.addEventListener("pointerenter",n=>{if(!(n.pointerType==="pen"||n.pointerType==="touch")){if(this.hoverType==="on"){this.currentEvent="mouse",this.currentChild=s;let i=e.isSubmenuItem?e.elements.toggle:null;if(e.elements.sibling!==null&&(i=e.elements.sibling.elements.toggle),i===null)return;this.enterDelay>0?(clearTimeout(this._hoverTimeout),this._hoverTimeout=setTimeout(()=>{i.preview()},this.enterDelay)):i.preview()}else if(this.hoverType==="dynamic"){const i=this.elements.submenuToggles.some(r=>r.isOpen);if(this.currentChild=s,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),!this.isTopLevel||i){this.currentEvent="mouse";let r=e.isSubmenuItem?e.elements.toggle:null;if(e.elements.sibling!==null&&(r=e.elements.sibling.elements.toggle),r===null)return;this.enterDelay>0?(clearTimeout(this._hoverTimeout),this._hoverTimeout=setTimeout(()=>{r.preview()},this.enterDelay)):r.preview()}}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",n=>{n.pointerType==="pen"||n.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",e=>{this.currentEvent="keyboard";const s=w(e);if(this.focusState==="self"){const n=["Space","Enter"],i=["Escape"],r=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&l(e):(this.currentMenuItem.isSubmenuItem&&n.includes(s)||this.elements.controller&&i.includes(s)||this.elements.parentMenu&&r.includes(s))&&l(e)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",e=>{this.currentEvent="keyboard";const s=w(e);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(l(e),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(i=>i.isOpen)?(l(e),this.closeChildren()):this.elements.parentMenu?(l(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()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(l(e),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(l(e),this.focusPreviousChild()):s==="Home"?(l(e),this.focusFirstChild()):s==="End"&&(l(e),this.focusLastChild())))})}}class ie extends W{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0,submenuSibling:m=null}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r,initialize:!1,submenuSibling:m}),h&&this.initialize()}}class re extends Z{constructor({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i,initialize:!1});u(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=e,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.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(e=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{d(n,this.dom.container)})})):s!==""&&a(s,this.dom.container),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:s,openClass:n,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),i!==""?(a(i,this.dom.container),requestAnimationFrame(()=>{n!==""&&d(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&a(s,this.dom.container),requestAnimationFrame(()=>{d(i,this.dom.container)})})})):(s!==""&&a(s,this.dom.container),n!==""&&d(n,this.dom.container)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class $ extends q{constructor({menuElement:e,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:h=".dropdown-menu",submenuSubtoggleSelector:m=".dropdown-toggle",controllerElement:c=null,containerElement:f=null,openClass:p="show",closeClass:g="collapse",transitionClass:M="transitioning",isTopLevel:b=!0,parentMenu:y=null,hoverType:_="off",hoverDelay:C=250,enterDelay:E=-1,leaveDelay:T=-1,optionalKeySupport:k=!1,initialize:j=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,submenuSubtoggleSelector:m,controllerElement:c,containerElement:f,openClass:p,closeClass:g,transitionClass:M,isTopLevel:b,parentMenu:y,hoverType:_,hoverDelay:C,enterDelay:E,leaveDelay:T,optionalKeySupport:k,initialize:!1});u(this,"_MenuType",$);u(this,"_MenuItemType",ie);u(this,"_MenuToggleType",re);j&&this.initialize()}}class G extends D{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r}),h&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","treeitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.dom.link.tabIndex=0}blur(){super.blur(),this.dom.link.tabIndex=-1}}class J extends L{constructor({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n=null,initialize:i=!0}){super({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n}),i&&this.initialize()}}class H extends S{constructor({menuElement:e,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:h="ul",controllerElement:m=null,containerElement:c=null,openClass:f="show",closeClass:p="hide",transitionClass:g="transitioning",isTopLevel:M=!0,parentMenu:b=null,hoverType:y="off",hoverDelay:_=250,enterDelay:C=-1,leaveDelay:E=-1,initialize:T=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,controllerElement:m,containerElement:c,openClass:f,closeClass:p,transitionClass:g,isTopLevel:M,parentMenu:b,hoverType:y,hoverDelay:_,enterDelay:C,leaveDelay:E});u(this,"_MenuType",H);u(this,"_MenuItemType",G);u(this,"_MenuToggleType",J);T&&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 s=w(e);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?this.elements.rootMenu.blur():this.elements.rootMenu.focus()),this.focusState==="self"){const n=["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"],i=["Enter","ArrowRight"],r=["Escape"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&i.includes(s)||this.elements.controller&&r.includes(s))&&l(e)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",e=>{this.currentEvent="keyboard";const s=w(e),{altKey:n,crtlKey:i,metaKey:r}=e;if(s==="Character"&&!(n||i||r))l(e),this.elements.rootMenu.currentEvent="character",this.focusNextNodeWithCharacter(e.key);else if(this.focusState==="self")if(s==="Enter"||s==="Space")l(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(s==="Escape")this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController());else if(s==="ArrowDown")l(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.focusParentsNextChild():this.focusNextChild();else if(s==="ArrowUp"){l(e);const m=this.elements.menuItems[this.currentChild-1];m&&m.isSubmenuItem&&m.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentChild=this.currentChild-1,this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.focusChildsLastNode()):!this.isTopLevel&&this.currentChild===0?(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild()):this.focusPreviousChild()}else s==="ArrowRight"?this.currentMenuItem.isSubmenuItem&&(l(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()):s==="ArrowLeft"?(l(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())):s==="Home"?(l(e),this.blurCurrentChild(),this.elements.rootMenu.focusFirstChild()):s==="End"?(l(e),this.blurCurrentChild(),this.elements.rootMenu.focusLastNode()):s==="Asterisk"&&(l(e),this.openChildren())})}focusLastNode(){const e=this.elements.menuItems.length-1,s=this.elements.menuItems[e];s.isSubmenuItem&&s.elements.toggle.isOpen?(this.currentChild=e,s.elements.childMenu.currentEvent=this.currentEvent,s.elements.childMenu.focusLastNode()):this.focusLastChild()}openChildren(){this.elements.submenuToggles.forEach(e=>e.preview())}focusNextNodeWithCharacter(e){function s(f){let p=[];return f.elements.menuItems.forEach(g=>{p.push(g),g.isSubmenuItem&&g.elements.toggle.isOpen&&(p=[...p,...s(g.elements.toggle.elements.controlledMenu)])}),p}const n=e.toLowerCase(),i=s(this.elements.rootMenu),r=i.indexOf(this.currentMenuItem)+1,h=[...i.slice(r),...i.slice(0,r)];let m=0,c=!1;for(;!c&&m<h.length;){let f="";if(h[m].dom.item.innerText?f=h[m].dom.item.innerText:f=h[m].dom.item.textContent,f=f.replace(/[\s]/g,"").toLowerCase().charAt(0),f===n){c=!0;const p=h[m].elements.parentMenu,g=p.elements.menuItems.indexOf(h[m]);this.elements.rootMenu.blurChildren(),p.focusChild(g)}m++}}focusParentsNextChild(){this.elements.parentMenu&&(this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.currentChild===this.elements.parentMenu.elements.menuItems.length-1?(this.elements.parentMenu.blurCurrentChild(),this.elements.parentMenu.focusParentsNextChild()):(this.blurChildren(),this.elements.parentMenu.focusNextChild()))}focusChildsLastNode(){this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusLastChild(),this.currentMenuItem.elements.childMenu.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.childMenu.currentMenuItem.elements.toggle.isOpen&&(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.childMenu.focusChildsLastNode())}}class oe extends G{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r,initialize:!1}),h&&this.initialize()}}class le extends J{constructor({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i,initialize:!1});u(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=e,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.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(e=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{d(n,this.dom.container)})})):s!==""&&a(s,this.dom.container),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:s,openClass:n,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),i!==""?(a(i,this.dom.container),requestAnimationFrame(()=>{n!==""&&d(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&a(s,this.dom.container),requestAnimationFrame(()=>{d(i,this.dom.container)})})})):(s!==""&&a(s,this.dom.container),n!==""&&d(n,this.dom.container)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class N extends H{constructor({menuElement:e,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:h=".dropdown-menu",controllerElement:m=null,containerElement:c=null,openClass:f="show",closeClass:p="collapse",transitionClass:g="transitioning",isTopLevel:M=!0,parentMenu:b=null,hoverType:y="off",hoverDelay:_=250,enterDelay:C=-1,leaveDelay:E=-1,initialize:T=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,controllerElement:m,containerElement:c,openClass:f,closeClass:p,transitionClass:g,isTopLevel:M,parentMenu:b,hoverType:y,hoverDelay:_,enterDelay:C,leaveDelay:E,initialize:!1});u(this,"_MenuType",N);u(this,"_MenuItemType",oe);u(this,"_MenuToggleType",le);T&&this.initialize()}}return{Bootstrap5DisclosureMenu:O,Bootstrap5Menubar:K,Bootstrap5TopLinkDisclosureMenu:$,Bootstrap5Treeview:N}}(); |
@@ -1,3 +0,3 @@ | ||
var Bootstrap5DisclosureMenu=function(){"use strict";var V=Object.defineProperty;var F=(a,h,m)=>h in a?V(a,h,{enumerable:!0,configurable:!0,writable:!0,value:m}):a[h]=m;var r=(a,h,m)=>(F(a,typeof h!="symbol"?h+"":h,m),m);function a(n,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof n)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${n.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function h(n,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==n)throw new TypeError(`${t} must be a ${n}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function m(n){try{if(typeof n!="object"){const e=typeof n;throw new TypeError(`Values given to isCSSSelector() must be inside of an object. "${e}" given.`)}for(const e in n)try{if(n[e]===null)throw new Error;document.querySelector(n[e])}catch{throw new TypeError(`${e} must be a valid CSS selector. "${n[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function E(n){try{if(typeof n!="object"||Array.isArray(n)){const e=typeof n;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in n){const t=typeof n[e];if(t!=="string")if(Array.isArray(n[e]))n[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=n[e],m(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function O(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function x(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function L(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function z(n,e){if(h("string",{tagName:n}).status&&a(HTMLElement,e).status){const t=n.toLowerCase();let s=!0;for(const o in e)e[o].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class I{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:o=null}){r(this,"_dom",{toggle:null,parent:null});r(this,"_elements",{controlledMenu:null,parentMenu:null});r(this,"_open",!1);r(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));r(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=o}initialize(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),z("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,""),s=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)),s=`${t}-${s}`),this.dom.toggle.id=this.dom.toggle.id||`${s}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${s}-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){h("boolean",{value:e}),this._open=e}_expand(e=!0){const{closeClass:t,openClass:s}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),s!==""&&(typeof s=="string"?this.elements.controlledMenu.dom.menu.classList.add(s):this.elements.controlledMenu.dom.menu.classList.add(...s)),t!==""&&(typeof t=="string"?this.elements.controlledMenu.dom.menu.classList.remove(t):this.elements.controlledMenu.dom.menu.classList.remove(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),t!==""&&(typeof t=="string"?this.elements.controlledMenu.dom.menu.classList.add(t):this.elements.controlledMenu.dom.menu.classList.add(...t)),s!==""&&(typeof s=="string"?this.elements.controlledMenu.dom.menu.classList.remove(s):this.elements.controlledMenu.dom.menu.classList.remove(...s)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class A{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:o=!1,childMenu:i=null,toggle:l=null}){r(this,"_dom",{item:null,link:null});r(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});r(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=i,this._elements.toggle=l,this._submenu=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 C(n){try{const e=n.key||n.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function c(n){n.preventDefault(),n.stopPropagation()}class M{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:o="",submenuToggleSelector:i="a",submenuSelector:l="ul",controllerElement:u=null,containerElement:f=null,openClass:p="show",closeClass:g="hide",isTopLevel:d=!0,parentMenu:_=null,hoverType:y="off",hoverDelay:b=250}){r(this,"_MenuType",M);r(this,"_MenuItemType",A);r(this,"_MenuToggleType",I);r(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});r(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});r(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});r(this,"_openClass","show");r(this,"_closeClass","hide");r(this,"_root",!0);r(this,"_currentChild",0);r(this,"_focusState","none");r(this,"_currentEvent","none");r(this,"_hoverType","off");r(this,"_hoverDelay",250);r(this,"_errors",[]);this._dom.menu=e,this._dom.controller=u,this._dom.container=f,this._selectors.menuItems=t,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=_,this._elements.rootMenu=d?this:null,this._openClass=p||"",this._closeClass=g||"",this._root=d,this._hoverType=y,this._hoverDelay=b}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
var Bootstrap5DisclosureMenu=function(){"use strict";var P=Object.defineProperty;var U=(u,h,f)=>h in u?P(u,h,{enumerable:!0,configurable:!0,writable:!0,value:f}):u[h]=f;var r=(u,h,f)=>(U(u,typeof h!="symbol"?h+"":h,f),f);function u(n,e){typeof n=="string"?e.classList.add(n):e.classList.add(...n)}function h(n,e){typeof n=="string"?e.classList.remove(n):e.classList.remove(...n)}function f(n,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof n)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${n.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function d(n,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==n)throw new TypeError(`${t} must be a ${n}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function k(n){try{if(typeof n!="object"){const e=typeof n;throw new TypeError(`Values given to isCSSSelector() must be inside of an object. "${e}" given.`)}for(const e in n)try{if(n[e]===null)throw new Error;document.querySelector(n[e])}catch{throw new TypeError(`${e} must be a valid CSS selector. "${n[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function g(n){try{if(typeof n!="object"||Array.isArray(n)){const e=typeof n;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in n){const t=typeof n[e];if(t!=="string")if(Array.isArray(n[e]))n[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=n[e],k(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function K(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function V(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function O(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function q(n,e){if(d("string",{tagName:n}).status&&f(HTMLElement,e).status){const t=n.toLowerCase();let s=!0;for(const i in e)e[i].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class F{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i=null}){r(this,"_dom",{toggle:null,parent:null});r(this,"_elements",{controlledMenu:null,parentMenu:null});r(this,"_open",!1);r(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));r(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=i}initialize(){var e;if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),q("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",i=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),i=`${s}-${i}`),this.dom.toggle.id=this.dom.toggle.id||`${i}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${i}-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){d("boolean",{value:e}),this._open=e}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),i!==""?(u(i,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&h(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&u(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{h(i,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&u(s,this.elements.controlledMenu.dom.menu),t!==""&&h(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),i!==""?(u(i,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&h(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&u(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{h(i,this.elements.controlledMenu.dom.menu)})})})):(t!==""&&u(t,this.elements.controlledMenu.dom.menu),s!==""&&h(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class x{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:o=null,toggle:l=null}){r(this,"_dom",{item:null,link:null});r(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});r(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=o,this._elements.toggle=l,this._submenu=i}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function w(n){try{const e=n.key||n.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function m(n){n.preventDefault(),n.stopPropagation()}class S{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:i="",submenuToggleSelector:o="a",submenuSelector:l="ul",controllerElement:c=null,containerElement:p=null,openClass:a="show",closeClass:y="hide",transitionClass:b="transitioning",isTopLevel:_=!0,parentMenu:C=null,hoverType:E="off",hoverDelay:M=250,enterDelay:T=-1,leaveDelay:v=-1}){r(this,"_MenuType",S);r(this,"_MenuItemType",x);r(this,"_MenuToggleType",F);r(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});r(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});r(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});r(this,"_openClass","show");r(this,"_closeClass","hide");r(this,"_transitionClass","transitioning");r(this,"_root",!0);r(this,"_currentChild",0);r(this,"_focusState","none");r(this,"_currentEvent","none");r(this,"_hoverType","off");r(this,"_hoverDelay",250);r(this,"_enterDelay",-1);r(this,"_leaveDelay",-1);r(this,"_hoverTimeout",null);r(this,"_errors",[]);this._dom.menu=e,this._dom.controller=c,this._dom.container=p,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=i,this._selectors.submenuToggles=o,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=C,this._elements.rootMenu=_?this:null,this._openClass=a||"",this._closeClass=y||"",this._transitionClass=b||"",this._root=_,this._hoverType=E,this._hoverDelay=M,this._enterDelay=T,this._leaveDelay=v}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
- ${this.errors.join(` | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get 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(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){E({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){E({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set currentChild(e){h("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let i=0,l=!1;for(;!l&&i<s.elements.parentMenu.elements.menuItems.length;){const u=s.elements.parentMenu.elements.menuItems[i];u.isSubmenuItem&&u.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=i),i++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){O({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){x({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){L({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){h("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=a(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=a(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=m({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=m({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const u=E({openClass:this._openClass});u.status||(this._errors.push(u.error.message),e=!1)}if(this._closeClass!==""){const u=E({closeClass:this._closeClass});u.status||(this._errors.push(u.error.message),e=!1)}const o=h("boolean",{isTopLevel:this._root});if(o.status||(this._errors.push(o.error.message),e=!1),this._elements.parentMenu!==null){const u=a(M,{parentMenu:this._elements.parentMenu});u.status||(this._errors.push(u.error.message),e=!1)}const i=L({hoverType:this._hoverType});i.status||(this._errors.push(i.error.message),e=!1);const l=h("number",{hoverDelay:this._hoverDelay});return l.status||(this._errors.push(l.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&a(HTMLElement,{base:t});const i=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=i:this._dom[e]=[...this._dom[e],...i]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),o=e.querySelector(this.selectors.submenus),i=new this._MenuType({menuElement:o,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:i,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:i,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,o){c(o),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",o=>{this.currentEvent="mouse",e(this,t.elements.toggle,o)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&e.elements.toggle.preview();else if(this.hoverType==="dynamic"){const o=this.elements.submenuToggles.some(i=>i.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||o)&&(this.currentEvent="mouse",e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.hoverDelay>0?setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.hoverDelay):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(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=C(e);(t==="Space"||t==="Enter")&&c(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=C(e);(t==="Space"||t==="Enter")&&(c(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",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class D extends A{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:o=!1,childMenu:i=null,toggle:l=null,initialize:u=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:o,childMenu:i,toggle:l}),u&&this.initialize()}}class $ extends I{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:o=null,initialize:i=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:o}),i&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class T extends M{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:o="a",submenuItemSelector:i="",submenuToggleSelector:l="a",submenuSelector:u="ul",controllerElement:f=null,containerElement:p=null,openClass:g="show",closeClass:d="hide",isTopLevel:_=!0,parentMenu:y=null,hoverType:b="off",hoverDelay:w=250,optionalKeySupport:S=!1,initialize:k=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:o,submenuItemSelector:i,submenuToggleSelector:l,submenuSelector:u,controllerElement:f,containerElement:p,openClass:g,closeClass:d,isTopLevel:_,parentMenu:y,hoverType:b,hoverDelay:w});r(this,"_MenuType",T);r(this,"_MenuItemType",D);r(this,"_MenuToggleType",$);r(this,"_currentChild",-1);r(this,"_optionalSupport",!1);this._optionalSupport=S,k&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(t){h("boolean",{optionalKeySupport:t}),this._optionalSupport=t}_validate(){let t=super._validate();const s=h("boolean",{optionalKeySupport:this._optionalSupport});return s.status||(this._errors.push(s.error.message),t=!1),t}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=C(t);if(this.focusState==="self"){const o=["Space","Enter"],i=["Escape"],l=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&c(t):(this.currentMenuItem.isSubmenuItem&&o.includes(s)||this.elements.controller&&i.includes(s)||this.elements.parentMenu&&l.includes(s))&&c(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=C(t);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(c(t),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(i=>i.isOpen)?(c(t),this.closeChildren()):this.elements.parentMenu?(c(t),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.closeChildren(),this.elements.parentMenu.focusCurrentChild()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(c(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(c(t),this.focusPreviousChild()):s==="Home"?(c(t),this.focusFirstChild()):s==="End"&&(c(t),this.focusLastChild())))})}}class j extends D{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:o=!1,childMenu:i=null,toggle:l=null,initialize:u=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:o,childMenu:i,toggle:l,initialize:!1}),u&&this.initialize()}}class K extends ${constructor({menuToggleElement:t,parentElement:s,controlledMenu:o,parentMenu:i=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:o,parentMenu:i,initialize:!1});r(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=o.isTopLevel?o.dom.container:o.dom.menu,l&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(t=!0){const{openClass:s}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),s!==""&&(typeof s=="string"?this.dom.container.classList.add(s):this.dom.container.classList.add(...s)),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),s!==""&&(typeof s=="string"?this.dom.container.classList.add(s):this.dom.container.classList.add(...s)),o!==""&&(typeof o=="string"?this.dom.container.classList.remove(o):this.dom.container.classList.remove(...o)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class v extends T{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:o=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:u=".dropdown-menu",controllerElement:f=null,containerElement:p=null,openClass:g="show",closeClass:d="collapse",isTopLevel:_=!0,parentMenu:y=null,hoverType:b="off",hoverDelay:w=250,optionalKeySupport:S=!1,initialize:k=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:o,submenuItemSelector:i,submenuToggleSelector:l,submenuSelector:u,controllerElement:f,containerElement:p,openClass:g,closeClass:d,isTopLevel:_,parentMenu:y,hoverType:b,hoverDelay:w,optionalKeySupport:S,initialize:!1});r(this,"_MenuType",v);r(this,"_MenuItemType",j);r(this,"_MenuToggleType",K);k&&this.initialize()}}return v}(); | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){g({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set currentChild(e){d("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let o=0,l=!1;for(;!l&&o<s.elements.parentMenu.elements.menuItems.length;){const c=s.elements.parentMenu.elements.menuItems[o];c.isSubmenuItem&&c.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=o),o++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){K({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){V({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){O({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){d("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){d("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){d("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=f(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=f(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=k({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=k({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const a=g({openClass:this._openClass});a.status||(this._errors.push(a.error.message),e=!1)}if(this._closeClass!==""){const a=g({closeClass:this._closeClass});a.status||(this._errors.push(a.error.message),e=!1)}if(this._transitionClass!==""){const a=g({transitionClass:this._transitionClass});a.status||(this._errors.push(a.error.message),e=!1)}const i=d("boolean",{isTopLevel:this._root});if(i.status||(this._errors.push(i.error.message),e=!1),this._elements.parentMenu!==null){const a=f(S,{parentMenu:this._elements.parentMenu});a.status||(this._errors.push(a.error.message),e=!1)}const o=O({hoverType:this._hoverType});o.status||(this._errors.push(o.error.message),e=!1);const l=d("number",{hoverDelay:this._hoverDelay});l.status||(this._errors.push(l.error.message),e=!1);const c=d("number",{enterDelay:this._enterDelay});c.status||(this._errors.push(c.error.message),e=!1);const p=d("number",{leaveDelay:this._leaveDelay});return p.status||(this._errors.push(p.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&f(HTMLElement,{base:t});const o=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=o:this._dom[e]=[...this._dom[e],...o]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),i=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:i,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,i){m(i),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",i=>{this.currentEvent="mouse",e(this,t.elements.toggle,i)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview());else if(this.hoverType==="dynamic"){const i=this.elements.submenuToggles.some(o=>o.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||i)&&(this.currentEvent="mouse",this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&m(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&(m(e),this.elements.controller.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",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class z extends x{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:o=null,toggle:l=null,initialize:c=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i,childMenu:o,toggle:l}),c&&this.initialize()}}class j extends F{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i=null,initialize:o=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i}),o&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class D extends S{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:i="a",submenuItemSelector:o="",submenuToggleSelector:l="a",submenuSelector:c="ul",controllerElement:p=null,containerElement:a=null,openClass:y="show",closeClass:b="hide",transitionClass:_="transitioning",isTopLevel:C=!0,parentMenu:E=null,hoverType:M="off",hoverDelay:T=250,enterDelay:v=-1,leaveDelay:I=-1,optionalKeySupport:L=!1,initialize:$=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:i,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:c,controllerElement:p,containerElement:a,openClass:y,closeClass:b,transitionClass:_,isTopLevel:C,parentMenu:E,hoverType:M,hoverDelay:T,enterDelay:v,leaveDelay:I});r(this,"_MenuType",D);r(this,"_MenuItemType",z);r(this,"_MenuToggleType",j);r(this,"_currentChild",-1);r(this,"_optionalSupport",!1);this._optionalSupport=L,$&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(t){d("boolean",{optionalKeySupport:t}),this._optionalSupport=t}_validate(){let t=super._validate();const s=d("boolean",{optionalKeySupport:this._optionalSupport});return s.status||(this._errors.push(s.error.message),t=!1),t}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=w(t);if(this.focusState==="self"){const i=["Space","Enter"],o=["Escape"],l=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&m(t):(this.currentMenuItem.isSubmenuItem&&i.includes(s)||this.elements.controller&&o.includes(s)||this.elements.parentMenu&&l.includes(s))&&m(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=w(t);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(m(t),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(o=>o.isOpen)?(m(t),this.closeChildren()):this.elements.parentMenu?(m(t),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.closeChildren(),this.elements.parentMenu.focusCurrentChild()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(m(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(m(t),this.focusPreviousChild()):s==="Home"?(m(t),this.focusFirstChild()):s==="End"&&(m(t),this.focusLastChild())))})}}class H extends z{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:o=null,toggle:l=null,initialize:c=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i,childMenu:o,toggle:l,initialize:!1}),c&&this.initialize()}}class R extends j{constructor({menuToggleElement:t,parentElement:s,controlledMenu:i,parentMenu:o=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:i,parentMenu:o,initialize:!1});r(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=i.isTopLevel?i.dom.container:i.dom.menu,l&&this.initialize()}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(t=!0){const{openClass:s,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),i!==""?(u(i,this.dom.container),requestAnimationFrame(()=>{u(s,this.dom.container),requestAnimationFrame(()=>{h(i,this.dom.container)})})):s!==""&&u(s,this.dom.container),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:i,transitionClass:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),o!==""?(u(o,this.dom.container),requestAnimationFrame(()=>{i!==""&&h(i,this.dom.container),requestAnimationFrame(()=>{s!==""&&u(s,this.dom.container),requestAnimationFrame(()=>{h(o,this.dom.container)})})})):(s!==""&&u(s,this.dom.container),i!==""&&h(i,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class A extends D{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:i=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:c=".dropdown-menu",controllerElement:p=null,containerElement:a=null,openClass:y="show",closeClass:b="collapse",transitionClass:_="transitioning",isTopLevel:C=!0,parentMenu:E=null,hoverType:M="off",hoverDelay:T=250,enterDelay:v=-1,leaveDelay:I=-1,optionalKeySupport:L=!1,initialize:$=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:i,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:c,controllerElement:p,containerElement:a,openClass:y,closeClass:b,transitionClass:_,isTopLevel:C,parentMenu:E,hoverType:M,hoverDelay:T,enterDelay:v,leaveDelay:I,optionalKeySupport:L,initialize:!1});r(this,"_MenuType",A);r(this,"_MenuItemType",H);r(this,"_MenuToggleType",R);$&&this.initialize()}}return A}(); |
@@ -1,3 +0,3 @@ | ||
var Bootstrap5Menubar=function(){"use strict";var j=Object.defineProperty;var V=(m,c,d)=>c in m?j(m,c,{enumerable:!0,configurable:!0,writable:!0,value:d}):m[c]=d;var l=(m,c,d)=>(V(m,typeof c!="symbol"?c+"":c,d),d);function m(n,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof n)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${n.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function c(n,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==n)throw new TypeError(`${t} must be a ${n}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function d(n){try{if(typeof n!="object"){const e=typeof n;throw new TypeError(`Values given to isCSSSelector() must be inside of an object. "${e}" given.`)}for(const e in n)try{if(n[e]===null)throw new Error;document.querySelector(n[e])}catch{throw new TypeError(`${e} must be a valid CSS selector. "${n[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function _(n){try{if(typeof n!="object"||Array.isArray(n)){const e=typeof n;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in n){const t=typeof n[e];if(t!=="string")if(Array.isArray(n[e]))n[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=n[e],d(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function $(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function x(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function S(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function O(n,e){if(c("string",{tagName:n}).status&&m(HTMLElement,e).status){const t=n.toLowerCase();let s=!0;for(const i in e)e[i].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class k{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i=null}){l(this,"_dom",{toggle:null,parent:null});l(this,"_elements",{controlledMenu:null,parentMenu:null});l(this,"_open",!1);l(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));l(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=i}initialize(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),O("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,""),s=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)),s=`${t}-${s}`),this.dom.toggle.id=this.dom.toggle.id||`${s}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${s}-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){c("boolean",{value:e}),this._open=e}_expand(e=!0){const{closeClass:t,openClass:s}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),s!==""&&(typeof s=="string"?this.elements.controlledMenu.dom.menu.classList.add(s):this.elements.controlledMenu.dom.menu.classList.add(...s)),t!==""&&(typeof t=="string"?this.elements.controlledMenu.dom.menu.classList.remove(t):this.elements.controlledMenu.dom.menu.classList.remove(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),t!==""&&(typeof t=="string"?this.elements.controlledMenu.dom.menu.classList.add(t):this.elements.controlledMenu.dom.menu.classList.add(...t)),s!==""&&(typeof s=="string"?this.elements.controlledMenu.dom.menu.classList.remove(s):this.elements.controlledMenu.dom.menu.classList.remove(...s)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class L{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:o=null}){l(this,"_dom",{item:null,link:null});l(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});l(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,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 C(n){try{const e=n.key||n.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function u(n){n.preventDefault(),n.stopPropagation()}class E{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:o="ul",controllerElement:h=null,containerElement:a=null,openClass:f="show",closeClass:g="hide",isTopLevel:p=!0,parentMenu:b=null,hoverType:M="off",hoverDelay:y=250}){l(this,"_MenuType",E);l(this,"_MenuItemType",L);l(this,"_MenuToggleType",k);l(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});l(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});l(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});l(this,"_openClass","show");l(this,"_closeClass","hide");l(this,"_root",!0);l(this,"_currentChild",0);l(this,"_focusState","none");l(this,"_currentEvent","none");l(this,"_hoverType","off");l(this,"_hoverDelay",250);l(this,"_errors",[]);this._dom.menu=e,this._dom.controller=h,this._dom.container=a,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=i,this._selectors.submenuToggles=r,this._selectors.submenus=o,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=b,this._elements.rootMenu=p?this:null,this._openClass=f||"",this._closeClass=g||"",this._root=p,this._hoverType=M,this._hoverDelay=y}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
var Bootstrap5Menubar=function(){"use strict";var R=Object.defineProperty;var P=(m,c,f)=>c in m?R(m,c,{enumerable:!0,configurable:!0,writable:!0,value:f}):m[c]=f;var o=(m,c,f)=>(P(m,typeof c!="symbol"?c+"":c,f),f);function m(i,e){typeof i=="string"?e.classList.add(i):e.classList.add(...i)}function c(i,e){typeof i=="string"?e.classList.remove(i):e.classList.remove(...i)}function f(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function p(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function S(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isCSSSelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid CSS selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function g(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],S(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function q(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function j(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function $(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function V(i,e){if(p("string",{tagName:i}).status&&f(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class x{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){o(this,"_dom",{toggle:null,parent:null});o(this,"_elements",{controlledMenu:null,parentMenu:null});o(this,"_open",!1);o(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));o(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){var e;if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),V("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${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){p("boolean",{value:e}),this._open=e}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(m(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&c(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&m(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{c(n,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&m(s,this.elements.controlledMenu.dom.menu),t!==""&&c(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(m(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&c(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&m(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{c(n,this.elements.controlledMenu.dom.menu)})})})):(t!==""&&m(t,this.elements.controlledMenu.dom.menu),s!==""&&c(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class F{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null}){o(this,"_dom",{item:null,link:null});o(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});o(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=r,this._elements.toggle=l,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function w(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function u(i){i.preventDefault(),i.stopPropagation()}class I{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="",submenuToggleSelector:r="a",submenuSelector:l="ul",controllerElement:a=null,containerElement:d=null,openClass:h="show",closeClass:_="hide",transitionClass:b="transitioning",isTopLevel:y=!0,parentMenu:M=null,hoverType:C="off",hoverDelay:E=250,enterDelay:T=-1,leaveDelay:v=-1}){o(this,"_MenuType",I);o(this,"_MenuItemType",F);o(this,"_MenuToggleType",x);o(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});o(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});o(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});o(this,"_openClass","show");o(this,"_closeClass","hide");o(this,"_transitionClass","transitioning");o(this,"_root",!0);o(this,"_currentChild",0);o(this,"_focusState","none");o(this,"_currentEvent","none");o(this,"_hoverType","off");o(this,"_hoverDelay",250);o(this,"_enterDelay",-1);o(this,"_leaveDelay",-1);o(this,"_hoverTimeout",null);o(this,"_errors",[]);this._dom.menu=e,this._dom.controller=a,this._dom.container=d,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=r,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=M,this._elements.rootMenu=y?this:null,this._openClass=h||"",this._closeClass=_||"",this._transitionClass=b||"",this._root=y,this._hoverType=C,this._hoverDelay=E,this._enterDelay=T,this._leaveDelay=v}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
- ${this.errors.join(` | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get 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(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){_({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){_({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set currentChild(e){c("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let r=0,o=!1;for(;!o&&r<s.elements.parentMenu.elements.menuItems.length;){const h=s.elements.parentMenu.elements.menuItems[r];h.isSubmenuItem&&h.elements.toggle.elements.controlledMenu===s&&(o=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=r),r++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){$({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){x({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){S({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){c("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=m(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=m(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=d({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=d({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const h=_({openClass:this._openClass});h.status||(this._errors.push(h.error.message),e=!1)}if(this._closeClass!==""){const h=_({closeClass:this._closeClass});h.status||(this._errors.push(h.error.message),e=!1)}const i=c("boolean",{isTopLevel:this._root});if(i.status||(this._errors.push(i.error.message),e=!1),this._elements.parentMenu!==null){const h=m(E,{parentMenu:this._elements.parentMenu});h.status||(this._errors.push(h.error.message),e=!1)}const r=S({hoverType:this._hoverType});r.status||(this._errors.push(r.error.message),e=!1);const o=c("number",{hoverDelay:this._hoverDelay});return o.status||(this._errors.push(o.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&m(HTMLElement,{base:t});const r=Array.from(t.querySelectorAll(this.selectors[e])).filter(o=>o.parentElement===t);s?this._dom[e]=r:this._dom[e]=[...this._dom[e],...r]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),i=e.querySelector(this.selectors.submenus),r=new this._MenuType({menuElement:i,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),o=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:r,parentMenu:this});this._elements.submenuToggles.push(o),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:r,toggle:o})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,i){u(i),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",i=>{this.currentEvent="mouse",e(this,t.elements.toggle,i)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&e.elements.toggle.preview();else if(this.hoverType==="dynamic"){const i=this.elements.submenuToggles.some(r=>r.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||i)&&(this.currentEvent="mouse",e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.hoverDelay>0?setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.hoverDelay):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(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=C(e);(t==="Space"||t==="Enter")&&u(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=C(e);(t==="Space"||t==="Enter")&&(u(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",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class A extends L{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:o=null,initialize:h=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i,childMenu:r,toggle:o}),h&&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 D extends k{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i}),r&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class T extends E{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:i="a",submenuItemSelector:r="",submenuToggleSelector:o="a",submenuSelector:h="ul",controllerElement:a=null,containerElement:f=null,openClass:g="show",closeClass:p="hide",isTopLevel:b=!0,parentMenu:M=null,hoverType:y="off",hoverDelay:I=250,initialize:v=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:i,submenuItemSelector:r,submenuToggleSelector:o,submenuSelector:h,controllerElement:a,containerElement:f,openClass:g,closeClass:p,isTopLevel:b,parentMenu:M,hoverType:y,hoverDelay:I});l(this,"_MenuType",T);l(this,"_MenuItemType",A);l(this,"_MenuToggleType",D);v&&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(t){console.error(t)}}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=C(t);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?(this.elements.rootMenu.blur(),this.elements.rootMenu.closeChildren()):this.elements.rootMenu.focus()),s==="Character")u(t);else if(this.isTopLevel){if(this.focusState==="self"){const i=["ArrowRight","ArrowLeft","Home","End"],r=["Space","Enter","ArrowDown","ArrowUp"],o=["Escape"];(i.includes(s)||this.currentMenuItem.isSubmenuItem&&r.includes(s)||this.elements.controller&&o.includes(s))&&u(t)}}else{const i=["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"],r=["Space","Enter"];(i.includes(s)||this.currentMenuItem.isSubmenuItem&&r.includes(s))&&u(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=C(t),{altKey:i,crtlKey:r,metaKey:o}=t;if(s==="Character"&&!(i||r||o))u(t),this.elements.rootMenu.currentEvent="character",this.focusNextChildWithCharacter(t.key);else if(this.isTopLevel){if(this.focusState==="self")if(s==="Space"||s==="Enter")this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click();else if(s==="ArrowRight"){u(t);const a=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusNextChild(),a&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if(s==="ArrowLeft"){u(t);const a=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusPreviousChild(),a&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else s==="ArrowDown"?this.currentMenuItem.isSubmenuItem&&(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):s==="ArrowUp"?this.currentMenuItem.isSubmenuItem&&(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusLastChild()})):s==="Home"?(u(t),this.focusFirstChild()):s==="End"?(u(t),this.focusLastChild()):s==="Escape"&&(this.elements.submenuToggles.some(f=>f.isOpen)?(u(t),this.closeChildren()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(u(t),this.elements.controller.close(),this.focusController()))}else s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click():s==="Escape"?(u(t),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusCurrentChild()):s==="ArrowRight"?this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):(u(t),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusNextChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&this.elements.rootMenu.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?this.elements.parentMenu.currentMenuItem.isSubmenuItem&&(u(t),this.elements.parentMenu.currentMenuItem.elements.toggle.close(),this.elements.parentMenu.focusCurrentChild(),this.elements.parentMenu===this.elements.rootMenu&&(this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusPreviousChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&(this.elements.rootMenu.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.elements.rootMenu.currentMenuItem.elements.toggle.preview()))):s==="ArrowDown"?(u(t),this.focusNextChild()):s==="ArrowUp"?(u(t),this.focusPreviousChild()):s==="Home"?(u(t),this.focusFirstChild()):s==="End"&&(u(t),this.focusLastChild())})}focusNextChild(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}focusPreviousChild(){this.currentChild===0?this.focusLastChild():this.focusChild(this.currentChild-1)}focusNextChildWithCharacter(t){const s=t.toLowerCase();let i=this.currentChild+1,r=!1;for(;!r&&i<this.elements.menuItems.length;){let o="";this.elements.menuItems[i].dom.item.innerText?o=this.elements.menuItems[i].dom.item.innerText:o=this.elements.menuItems[i].dom.item.textContent,o=o.replace(/[\s]/g,"").toLowerCase().charAt(0),o===s&&(r=!0,this.focusChild(i)),i++}}}class z extends A{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:o=null,initialize:h=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i,childMenu:r,toggle:o,initialize:!1}),h&&this.initialize()}}class F extends D{constructor({menuToggleElement:t,parentElement:s,controlledMenu:i,parentMenu:r=null,initialize:o=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:i,parentMenu:r,initialize:!1});l(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=i.isTopLevel?i.dom.container:i.dom.menu,o&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(t=!0){const{openClass:s}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),s!==""&&(typeof s=="string"?this.dom.container.classList.add(s):this.dom.container.classList.add(...s)),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),s!==""&&(typeof s=="string"?this.dom.container.classList.add(s):this.dom.container.classList.add(...s)),i!==""&&(typeof i=="string"?this.dom.container.classList.remove(i):this.dom.container.classList.remove(...i)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class w extends T{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:i=".nav-link,.dropdown-item",submenuItemSelector:r=".dropdown",submenuToggleSelector:o=".dropdown-toggle",submenuSelector:h=".dropdown-menu",controllerElement:a=null,containerElement:f=null,openClass:g="show",closeClass:p="collapse",isTopLevel:b=!0,parentMenu:M=null,hoverType:y="off",hoverDelay:I=250,initialize:v=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:i,submenuItemSelector:r,submenuToggleSelector:o,submenuSelector:h,controllerElement:a,containerElement:f,openClass:g,closeClass:p,isTopLevel:b,parentMenu:M,hoverType:y,hoverDelay:I,initialize:!1});l(this,"_MenuType",w);l(this,"_MenuItemType",z);l(this,"_MenuToggleType",F);v&&this.initialize()}}return w}(); | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){g({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set currentChild(e){p("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let r=0,l=!1;for(;!l&&r<s.elements.parentMenu.elements.menuItems.length;){const a=s.elements.parentMenu.elements.menuItems[r];a.isSubmenuItem&&a.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=r),r++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){q({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){j({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){$({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){p("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){p("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){p("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=f(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=f(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const h=g({openClass:this._openClass});h.status||(this._errors.push(h.error.message),e=!1)}if(this._closeClass!==""){const h=g({closeClass:this._closeClass});h.status||(this._errors.push(h.error.message),e=!1)}if(this._transitionClass!==""){const h=g({transitionClass:this._transitionClass});h.status||(this._errors.push(h.error.message),e=!1)}const n=p("boolean",{isTopLevel:this._root});if(n.status||(this._errors.push(n.error.message),e=!1),this._elements.parentMenu!==null){const h=f(I,{parentMenu:this._elements.parentMenu});h.status||(this._errors.push(h.error.message),e=!1)}const r=$({hoverType:this._hoverType});r.status||(this._errors.push(r.error.message),e=!1);const l=p("number",{hoverDelay:this._hoverDelay});l.status||(this._errors.push(l.error.message),e=!1);const a=p("number",{enterDelay:this._enterDelay});a.status||(this._errors.push(a.error.message),e=!1);const d=p("number",{leaveDelay:this._leaveDelay});return d.status||(this._errors.push(d.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&f(HTMLElement,{base:t});const r=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=r:this._dom[e]=[...this._dom[e],...r]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),r=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:r,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:r,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,n){u(n),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview());else if(this.hoverType==="dynamic"){const n=this.elements.submenuToggles.some(r=>r.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||n)&&(this.currentEvent="mouse",this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&u(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&(u(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",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class O extends F{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:a=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l}),a&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","menuitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=0)}blur(){super.blur(),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=-1)}}class z extends x{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),r&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class k extends I{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:r="",submenuToggleSelector:l="a",submenuSelector:a="ul",controllerElement:d=null,containerElement:h=null,openClass:_="show",closeClass:b="hide",transitionClass:y="transitioning",isTopLevel:M=!0,parentMenu:C=null,hoverType:E="off",hoverDelay:T=250,enterDelay:v=-1,leaveDelay:L=-1,initialize:D=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:a,controllerElement:d,containerElement:h,openClass:_,closeClass:b,transitionClass:y,isTopLevel:M,parentMenu:C,hoverType:E,hoverDelay:T,enterDelay:v,leaveDelay:L});o(this,"_MenuType",k);o(this,"_MenuItemType",O);o(this,"_MenuToggleType",z);D&&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(t){console.error(t)}}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=w(t);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?(this.elements.rootMenu.blur(),this.elements.rootMenu.closeChildren()):this.elements.rootMenu.focus()),s==="Character")u(t);else if(this.isTopLevel){if(this.focusState==="self"){const n=["ArrowRight","ArrowLeft","Home","End"],r=["Space","Enter","ArrowDown","ArrowUp"],l=["Escape"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&r.includes(s)||this.elements.controller&&l.includes(s))&&u(t)}}else{const n=["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"],r=["Space","Enter"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&r.includes(s))&&u(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=w(t),{altKey:n,crtlKey:r,metaKey:l}=t;if(s==="Character"&&!(n||r||l))u(t),this.elements.rootMenu.currentEvent="character",this.focusNextChildWithCharacter(t.key);else if(this.isTopLevel){if(this.focusState==="self")if(s==="Space"||s==="Enter")this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click();else if(s==="ArrowRight"){u(t);const d=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusNextChild(),d&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if(s==="ArrowLeft"){u(t);const d=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusPreviousChild(),d&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else s==="ArrowDown"?this.currentMenuItem.isSubmenuItem&&(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):s==="ArrowUp"?this.currentMenuItem.isSubmenuItem&&(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusLastChild()})):s==="Home"?(u(t),this.focusFirstChild()):s==="End"?(u(t),this.focusLastChild()):s==="Escape"&&(this.elements.submenuToggles.some(h=>h.isOpen)?(u(t),this.closeChildren()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(u(t),this.elements.controller.close(),this.focusController()))}else s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click():s==="Escape"?(u(t),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusCurrentChild()):s==="ArrowRight"?this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):(u(t),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusNextChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&this.elements.rootMenu.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?this.elements.parentMenu.currentMenuItem.isSubmenuItem&&(u(t),this.elements.parentMenu.currentMenuItem.elements.toggle.close(),this.elements.parentMenu.focusCurrentChild(),this.elements.parentMenu===this.elements.rootMenu&&(this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusPreviousChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&(this.elements.rootMenu.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.elements.rootMenu.currentMenuItem.elements.toggle.preview()))):s==="ArrowDown"?(u(t),this.focusNextChild()):s==="ArrowUp"?(u(t),this.focusPreviousChild()):s==="Home"?(u(t),this.focusFirstChild()):s==="End"&&(u(t),this.focusLastChild())})}focusNextChild(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}focusPreviousChild(){this.currentChild===0?this.focusLastChild():this.focusChild(this.currentChild-1)}focusNextChildWithCharacter(t){const s=t.toLowerCase();let n=this.currentChild+1,r=!1;for(;!r&&n<this.elements.menuItems.length;){let l="";this.elements.menuItems[n].dom.item.innerText?l=this.elements.menuItems[n].dom.item.innerText:l=this.elements.menuItems[n].dom.item.textContent,l=l.replace(/[\s]/g,"").toLowerCase().charAt(0),l===s&&(r=!0,this.focusChild(n)),n++}}}class H extends O{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:a=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l,initialize:!1}),a&&this.initialize()}}class K extends z{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r,initialize:!1});o(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,l&&this.initialize()}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(t=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(m(n,this.dom.container),requestAnimationFrame(()=>{m(s,this.dom.container),requestAnimationFrame(()=>{c(n,this.dom.container)})})):s!==""&&m(s,this.dom.container),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:r}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),r!==""?(m(r,this.dom.container),requestAnimationFrame(()=>{n!==""&&c(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&m(s,this.dom.container),requestAnimationFrame(()=>{c(r,this.dom.container)})})})):(s!==""&&m(s,this.dom.container),n!==""&&c(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class A extends k{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:r=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:a=".dropdown-menu",controllerElement:d=null,containerElement:h=null,openClass:_="show",closeClass:b="collapse",transitionClass:y="transitioning",isTopLevel:M=!0,parentMenu:C=null,hoverType:E="off",hoverDelay:T=250,enterDelay:v=-1,leaveDelay:L=-1,initialize:D=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:a,controllerElement:d,containerElement:h,openClass:_,closeClass:b,transitionClass:y,isTopLevel:M,parentMenu:C,hoverType:E,hoverDelay:T,enterDelay:v,leaveDelay:L,initialize:!1});o(this,"_MenuType",A);o(this,"_MenuItemType",H);o(this,"_MenuToggleType",K);D&&this.initialize()}}return A}(); |
@@ -1,3 +0,3 @@ | ||
var Bootstrap5TopLinkDisclosureMenu=function(){"use strict";var F=Object.defineProperty;var H=(a,h,p)=>h in a?F(a,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):a[h]=p;var l=(a,h,p)=>(H(a,typeof h!="symbol"?h+"":h,p),p);function a(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function h(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function p(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isCSSSelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid CSS selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function E(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],p(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function j(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function x(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function I(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function z(i,e){if(h("string",{tagName:i}).status&&a(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class A{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){l(this,"_dom",{toggle:null,parent:null});l(this,"_elements",{controlledMenu:null,parentMenu:null});l(this,"_open",!1);l(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));l(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),z("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,""),s=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)),s=`${t}-${s}`),this.dom.toggle.id=this.dom.toggle.id||`${s}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${s}-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){h("boolean",{value:e}),this._open=e}_expand(e=!0){const{closeClass:t,openClass:s}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),s!==""&&(typeof s=="string"?this.elements.controlledMenu.dom.menu.classList.add(s):this.elements.controlledMenu.dom.menu.classList.add(...s)),t!==""&&(typeof t=="string"?this.elements.controlledMenu.dom.menu.classList.remove(t):this.elements.controlledMenu.dom.menu.classList.remove(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),t!==""&&(typeof t=="string"?this.elements.controlledMenu.dom.menu.classList.add(t):this.elements.controlledMenu.dom.menu.classList.add(...t)),s!==""&&(typeof s=="string"?this.elements.controlledMenu.dom.menu.classList.remove(s):this.elements.controlledMenu.dom.menu.classList.remove(...s)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class D{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:r=null}){l(this,"_dom",{item:null,link:null});l(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});l(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=o,this._elements.toggle=r,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function M(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function c(i){i.preventDefault(),i.stopPropagation()}class C{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="",submenuToggleSelector:o="a",submenuSelector:r="ul",controllerElement:u=null,containerElement:m=null,openClass:d="show",closeClass:g="hide",isTopLevel:f=!0,parentMenu:y=null,hoverType:_="off",hoverDelay:b=250}){l(this,"_MenuType",C);l(this,"_MenuItemType",D);l(this,"_MenuToggleType",A);l(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});l(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});l(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});l(this,"_openClass","show");l(this,"_closeClass","hide");l(this,"_root",!0);l(this,"_currentChild",0);l(this,"_focusState","none");l(this,"_currentEvent","none");l(this,"_hoverType","off");l(this,"_hoverDelay",250);l(this,"_errors",[]);this._dom.menu=e,this._dom.controller=u,this._dom.container=m,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=o,this._selectors.submenus=r,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=y,this._elements.rootMenu=f?this:null,this._openClass=d||"",this._closeClass=g||"",this._root=f,this._hoverType=_,this._hoverDelay=b}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
var Bootstrap5TopLinkDisclosureMenu=function(){"use strict";var U=Object.defineProperty;var B=(m,a,p)=>a in m?U(m,a,{enumerable:!0,configurable:!0,writable:!0,value:p}):m[a]=p;var l=(m,a,p)=>(B(m,typeof a!="symbol"?a+"":a,p),p);function m(i,e){typeof i=="string"?e.classList.add(i):e.classList.add(...i)}function a(i,e){typeof i=="string"?e.classList.remove(i):e.classList.remove(...i)}function p(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function f(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function w(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isCSSSelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid CSS selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function g(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],w(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function K(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function V(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function F(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function H(i,e){if(f("string",{tagName:i}).status&&p(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class j{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){l(this,"_dom",{toggle:null,parent:null});l(this,"_elements",{controlledMenu:null,parentMenu:null});l(this,"_open",!1);l(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));l(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){var e;if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),H("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${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){f("boolean",{value:e}),this._open=e}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(m(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&a(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&m(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{a(n,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&m(s,this.elements.controlledMenu.dom.menu),t!==""&&a(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(m(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&a(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&m(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{a(n,this.elements.controlledMenu.dom.menu)})})})):(t!==""&&m(t,this.elements.controlledMenu.dom.menu),s!==""&&a(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class x{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:r=null}){l(this,"_dom",{item:null,link:null});l(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});l(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=o,this._elements.toggle=r,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function S(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function d(i){i.preventDefault(),i.stopPropagation()}class k{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="",submenuToggleSelector:o="a",submenuSelector:r="ul",controllerElement:h=null,containerElement:c=null,openClass:u="show",closeClass:y="hide",transitionClass:b="transitioning",isTopLevel:_=!0,parentMenu:C=null,hoverType:T="off",hoverDelay:E=250,enterDelay:M=-1,leaveDelay:v=-1}){l(this,"_MenuType",k);l(this,"_MenuItemType",x);l(this,"_MenuToggleType",j);l(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});l(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});l(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});l(this,"_openClass","show");l(this,"_closeClass","hide");l(this,"_transitionClass","transitioning");l(this,"_root",!0);l(this,"_currentChild",0);l(this,"_focusState","none");l(this,"_currentEvent","none");l(this,"_hoverType","off");l(this,"_hoverDelay",250);l(this,"_enterDelay",-1);l(this,"_leaveDelay",-1);l(this,"_hoverTimeout",null);l(this,"_errors",[]);this._dom.menu=e,this._dom.controller=h,this._dom.container=c,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=o,this._selectors.submenus=r,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=C,this._elements.rootMenu=_?this:null,this._openClass=u||"",this._closeClass=y||"",this._transitionClass=b||"",this._root=_,this._hoverType=T,this._hoverDelay=E,this._enterDelay=M,this._leaveDelay=v}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
- ${this.errors.join(` | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get 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(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){E({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){E({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set currentChild(e){h("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let o=0,r=!1;for(;!r&&o<s.elements.parentMenu.elements.menuItems.length;){const u=s.elements.parentMenu.elements.menuItems[o];u.isSubmenuItem&&u.elements.toggle.elements.controlledMenu===s&&(r=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=o),o++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){j({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){x({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){h("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=a(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=a(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=p({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=p({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const u=E({openClass:this._openClass});u.status||(this._errors.push(u.error.message),e=!1)}if(this._closeClass!==""){const u=E({closeClass:this._closeClass});u.status||(this._errors.push(u.error.message),e=!1)}const n=h("boolean",{isTopLevel:this._root});if(n.status||(this._errors.push(n.error.message),e=!1),this._elements.parentMenu!==null){const u=a(C,{parentMenu:this._elements.parentMenu});u.status||(this._errors.push(u.error.message),e=!1)}const o=I({hoverType:this._hoverType});o.status||(this._errors.push(o.error.message),e=!1);const r=h("number",{hoverDelay:this._hoverDelay});return r.status||(this._errors.push(r.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&a(HTMLElement,{base:t});const o=Array.from(t.querySelectorAll(this.selectors[e])).filter(r=>r.parentElement===t);s?this._dom[e]=o:this._dom[e]=[...this._dom[e],...o]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),r=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(r),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:r})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,n){c(n),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&e.elements.toggle.preview();else if(this.hoverType==="dynamic"){const n=this.elements.submenuToggles.some(o=>o.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||n)&&(this.currentEvent="mouse",e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.hoverDelay>0?setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.hoverDelay):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(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);(t==="Space"||t==="Enter")&&c(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=M(e);(t==="Space"||t==="Enter")&&(c(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",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class $ extends D{constructor({menuItemElement:t,menuLinkElement:s,parentMenu:n,isSubmenuItem:o=!1,childMenu:r=null,toggle:u=null,initialize:m=!0,submenuSibling:d=null}){super({menuItemElement:t,menuLinkElement:s,parentMenu:n,isSubmenuItem:o,childMenu:r,toggle:u});l(this,"_elements",{parentMenu:null,childMenu:null,toggle:null,sibling:null});this._elements.parentMenu=n,this._elements.childMenu=r,this._elements.toggle=u,this._elements.sibling=d,m&&this.initialize()}}class O extends A{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:o=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),o&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class T extends C{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:o="",submenuToggleSelector:r="button",submenuSelector:u="ul",submenuSubtoggleSelector:m="a",controllerElement:d=null,containerElement:g=null,openClass:f="show",closeClass:y="hide",isTopLevel:_=!0,parentMenu:b=null,hoverType:w="off",hoverDelay:S=250,optionalKeySupport:k=!1,initialize:L=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuSelector:u,submenuToggleSelector:r,controllerElement:d,containerElement:g,openClass:f,closeClass:y,isTopLevel:_,parentMenu:b,hoverType:w,hoverDelay:S});l(this,"_MenuType",T);l(this,"_MenuItemType",$);l(this,"_MenuToggleType",O);l(this,"_currentChild",-1);l(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:"",submenuSubtoggles:""});l(this,"_optionalSupport",!1);this._optionalSupport=k,this._selectors.menuItems=s,this._selectors.submenuItems=o,this._selectors.submenuToggles=r,this._selectors.submenus=u,this._selectors.submenuSubtoggles=m,this._selectors.menuLinks=[...new Set([n,r])].join(","),L&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(t){h("boolean",{optionalKeySupport:t}),this._optionalSupport=t}_createChildElements(){this.dom.menuItems.forEach(t=>{let s,n;const o=t.querySelector(this.selectors.menuLinks);if(this.dom.submenuItems.includes(t)){const r=t.querySelector(this.selectors.submenuToggles),u=t.querySelector(this.selectors.submenus),m=new this._MenuType({menuElement:u,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuSubtoggles,submenuSelector:this.selectors.submenus,submenuSubtoggleSelector:this.selectors.submenuSubtoggles,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),d=new this._MenuToggleType({menuToggleElement:r,parentElement:t,controlledMenu:m,parentMenu:this});this._elements.submenuToggles.push(d),r!==o?(n=new this._MenuItemType({menuItemElement:t,menuLinkElement:r,parentMenu:this,isSubmenuItem:!0,childMenu:m,toggle:d}),s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this,submenuSibling:n})):s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this,isSubmenuItem:!0,childMenu:m,toggle:d})}else s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this});this._elements.menuItems.push(s),typeof n<"u"&&this._elements.menuItems.push(n)})}_validate(){let t=super._validate();const s=p({submenuSubtoggleSelector:this._selectors.submenuSubtoggles});s.status||(this._errors.push(s.error.message),t=!1);const n=h("boolean",{optionalKeySupport:this._optionalSupport});return n.status||(this._errors.push(n.error.message),t=!1),t}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleHover(){this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerenter",n=>{if(!(n.pointerType==="pen"||n.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.currentChild=s,t.isSubmenuItem?t.elements.toggle.preview():t.elements.sibling!==null&&t.elements.sibling.elements.toggle.preview();else if(this.hoverType==="dynamic"){const o=this.elements.submenuToggles.some(r=>r.isOpen);this.currentChild=s,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),(!this.isTopLevel||o)&&(this.currentEvent="mouse",t.isSubmenuItem?t.elements.toggle.preview():t.elements.sibling!==null&&t.elements.sibling.elements.toggle.preview())}}}),t.isSubmenuItem&&t.dom.item.addEventListener("pointerleave",n=>{n.pointerType==="pen"||n.pointerType==="touch"||(this.hoverType==="on"?this.hoverDelay>0?setTimeout(()=>{this.currentEvent="mouse",t.elements.toggle.close()},this.hoverDelay):(this.currentEvent="mouse",t.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.hoverDelay>0?setTimeout(()=>{this.currentEvent="mouse",t.elements.toggle.close(),this.focusCurrentChild()},this.hoverDelay):(this.currentEvent="mouse",t.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=M(t);if(this.focusState==="self"){const n=["Space","Enter"],o=["Escape"],r=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&c(t):(this.currentMenuItem.isSubmenuItem&&n.includes(s)||this.elements.controller&&o.includes(s)||this.elements.parentMenu&&r.includes(s))&&c(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=M(t);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(c(t),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(o=>o.isOpen)?(c(t),this.closeChildren()):this.elements.parentMenu?(c(t),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.closeChildren(),this.elements.parentMenu.focusCurrentChild()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(c(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(c(t),this.focusPreviousChild()):s==="Home"?(c(t),this.focusFirstChild()):s==="End"&&(c(t),this.focusLastChild())))})}}class K extends ${constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:r=null,initialize:u=!0,submenuSibling:m=null}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:o,toggle:r,initialize:!1,submenuSibling:m}),u&&this.initialize()}}class V extends O{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o=null,initialize:r=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o,initialize:!1});l(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,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(t=!0){const{openClass:s}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),s!==""&&(typeof s=="string"?this.dom.container.classList.add(s):this.dom.container.classList.add(...s)),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),s!==""&&(typeof s=="string"?this.dom.container.classList.add(s):this.dom.container.classList.add(...s)),n!==""&&(typeof n=="string"?this.dom.container.classList.remove(n):this.dom.container.classList.remove(...n)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class v extends T{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:u=".dropdown-menu",submenuSubtoggleSelector:m=".dropdown-toggle",controllerElement:d=null,containerElement:g=null,openClass:f="show",closeClass:y="collapse",isTopLevel:_=!0,parentMenu:b=null,hoverType:w="off",hoverDelay:S=250,optionalKeySupport:k=!1,initialize:L=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuToggleSelector:r,submenuSelector:u,submenuSubtoggleSelector:m,controllerElement:d,containerElement:g,openClass:f,closeClass:y,isTopLevel:_,parentMenu:b,hoverType:w,hoverDelay:S,optionalKeySupport:k,initialize:!1});l(this,"_MenuType",v);l(this,"_MenuItemType",K);l(this,"_MenuToggleType",V);L&&this.initialize()}}return v}(); | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){g({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set currentChild(e){f("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let o=0,r=!1;for(;!r&&o<s.elements.parentMenu.elements.menuItems.length;){const h=s.elements.parentMenu.elements.menuItems[o];h.isSubmenuItem&&h.elements.toggle.elements.controlledMenu===s&&(r=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=o),o++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){K({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){V({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){F({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){f("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){f("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){f("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=p(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=p(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=w({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=w({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const u=g({openClass:this._openClass});u.status||(this._errors.push(u.error.message),e=!1)}if(this._closeClass!==""){const u=g({closeClass:this._closeClass});u.status||(this._errors.push(u.error.message),e=!1)}if(this._transitionClass!==""){const u=g({transitionClass:this._transitionClass});u.status||(this._errors.push(u.error.message),e=!1)}const n=f("boolean",{isTopLevel:this._root});if(n.status||(this._errors.push(n.error.message),e=!1),this._elements.parentMenu!==null){const u=p(k,{parentMenu:this._elements.parentMenu});u.status||(this._errors.push(u.error.message),e=!1)}const o=F({hoverType:this._hoverType});o.status||(this._errors.push(o.error.message),e=!1);const r=f("number",{hoverDelay:this._hoverDelay});r.status||(this._errors.push(r.error.message),e=!1);const h=f("number",{enterDelay:this._enterDelay});h.status||(this._errors.push(h.error.message),e=!1);const c=f("number",{leaveDelay:this._leaveDelay});return c.status||(this._errors.push(c.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&p(HTMLElement,{base:t});const o=Array.from(t.querySelectorAll(this.selectors[e])).filter(r=>r.parentElement===t);s?this._dom[e]=o:this._dom[e]=[...this._dom[e],...o]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),r=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(r),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:r})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,n){d(n),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview());else if(this.hoverType==="dynamic"){const n=this.elements.submenuToggles.some(o=>o.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||n)&&(this.currentEvent="mouse",this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=S(e);(t==="Space"||t==="Enter")&&d(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=S(e);(t==="Space"||t==="Enter")&&(d(e),this.elements.controller.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",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class z extends x{constructor({menuItemElement:t,menuLinkElement:s,parentMenu:n,isSubmenuItem:o=!1,childMenu:r=null,toggle:h=null,initialize:c=!0,submenuSibling:u=null}){super({menuItemElement:t,menuLinkElement:s,parentMenu:n,isSubmenuItem:o,childMenu:r,toggle:h});l(this,"_elements",{parentMenu:null,childMenu:null,toggle:null,sibling:null});this._elements.parentMenu=n,this._elements.childMenu=r,this._elements.toggle=h,this._elements.sibling=u,c&&this.initialize()}}class q extends j{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:o=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),o&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class D extends k{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:o="",submenuToggleSelector:r="button",submenuSelector:h="ul",submenuSubtoggleSelector:c="a",controllerElement:u=null,containerElement:y=null,openClass:b="show",closeClass:_="hide",transitionClass:C="transitioning",isTopLevel:T=!0,parentMenu:E=null,hoverType:M="off",hoverDelay:v=250,enterDelay:I=-1,leaveDelay:A=-1,optionalKeySupport:$=!1,initialize:O=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuSelector:h,submenuToggleSelector:r,controllerElement:u,containerElement:y,openClass:b,closeClass:_,transitionClass:C,isTopLevel:T,parentMenu:E,hoverType:M,hoverDelay:v,enterDelay:I,leaveDelay:A});l(this,"_MenuType",D);l(this,"_MenuItemType",z);l(this,"_MenuToggleType",q);l(this,"_currentChild",-1);l(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:"",submenuSubtoggles:""});l(this,"_optionalSupport",!1);this._optionalSupport=$,this._selectors.menuItems=s,this._selectors.submenuItems=o,this._selectors.submenuToggles=r,this._selectors.submenus=h,this._selectors.submenuSubtoggles=c,this._selectors.menuLinks=[...new Set([n,r])].join(","),O&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(t){f("boolean",{optionalKeySupport:t}),this._optionalSupport=t}_createChildElements(){this.dom.menuItems.forEach(t=>{let s,n;const o=t.querySelector(this.selectors.menuLinks);if(this.dom.submenuItems.includes(t)){const r=t.querySelector(this.selectors.submenuToggles),h=t.querySelector(this.selectors.submenus),c=new this._MenuType({menuElement:h,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuSubtoggles,submenuSelector:this.selectors.submenus,submenuSubtoggleSelector:this.selectors.submenuSubtoggles,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),u=new this._MenuToggleType({menuToggleElement:r,parentElement:t,controlledMenu:c,parentMenu:this});this._elements.submenuToggles.push(u),r!==o?(n=new this._MenuItemType({menuItemElement:t,menuLinkElement:r,parentMenu:this,isSubmenuItem:!0,childMenu:c,toggle:u}),s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this,submenuSibling:n})):s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this,isSubmenuItem:!0,childMenu:c,toggle:u})}else s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this});this._elements.menuItems.push(s),typeof n<"u"&&this._elements.menuItems.push(n)})}_validate(){let t=super._validate();const s=w({submenuSubtoggleSelector:this._selectors.submenuSubtoggles});s.status||(this._errors.push(s.error.message),t=!1);const n=f("boolean",{optionalKeySupport:this._optionalSupport});return n.status||(this._errors.push(n.error.message),t=!1),t}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleHover(){this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerenter",n=>{if(!(n.pointerType==="pen"||n.pointerType==="touch")){if(this.hoverType==="on"){this.currentEvent="mouse",this.currentChild=s;let o=t.isSubmenuItem?t.elements.toggle:null;if(t.elements.sibling!==null&&(o=t.elements.sibling.elements.toggle),o===null)return;this.enterDelay>0?(clearTimeout(this._hoverTimeout),this._hoverTimeout=setTimeout(()=>{o.preview()},this.enterDelay)):o.preview()}else if(this.hoverType==="dynamic"){const o=this.elements.submenuToggles.some(r=>r.isOpen);if(this.currentChild=s,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),!this.isTopLevel||o){this.currentEvent="mouse";let r=t.isSubmenuItem?t.elements.toggle:null;if(t.elements.sibling!==null&&(r=t.elements.sibling.elements.toggle),r===null)return;this.enterDelay>0?(clearTimeout(this._hoverTimeout),this._hoverTimeout=setTimeout(()=>{r.preview()},this.enterDelay)):r.preview()}}}}),t.isSubmenuItem&&t.dom.item.addEventListener("pointerleave",n=>{n.pointerType==="pen"||n.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",t.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",t.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",t.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",t.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=S(t);if(this.focusState==="self"){const n=["Space","Enter"],o=["Escape"],r=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&d(t):(this.currentMenuItem.isSubmenuItem&&n.includes(s)||this.elements.controller&&o.includes(s)||this.elements.parentMenu&&r.includes(s))&&d(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=S(t);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(d(t),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(o=>o.isOpen)?(d(t),this.closeChildren()):this.elements.parentMenu?(d(t),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.closeChildren(),this.elements.parentMenu.focusCurrentChild()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(d(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(d(t),this.focusPreviousChild()):s==="Home"?(d(t),this.focusFirstChild()):s==="End"&&(d(t),this.focusLastChild())))})}}class R extends z{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:r=null,initialize:h=!0,submenuSibling:c=null}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:o,toggle:r,initialize:!1,submenuSibling:c}),h&&this.initialize()}}class P extends q{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o=null,initialize:r=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o,initialize:!1});l(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,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(t=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(m(n,this.dom.container),requestAnimationFrame(()=>{m(s,this.dom.container),requestAnimationFrame(()=>{a(n,this.dom.container)})})):s!==""&&m(s,this.dom.container),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),o!==""?(m(o,this.dom.container),requestAnimationFrame(()=>{n!==""&&a(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&m(s,this.dom.container),requestAnimationFrame(()=>{a(o,this.dom.container)})})})):(s!==""&&m(s,this.dom.container),n!==""&&a(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class L extends D{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:h=".dropdown-menu",submenuSubtoggleSelector:c=".dropdown-toggle",controllerElement:u=null,containerElement:y=null,openClass:b="show",closeClass:_="collapse",transitionClass:C="transitioning",isTopLevel:T=!0,parentMenu:E=null,hoverType:M="off",hoverDelay:v=250,enterDelay:I=-1,leaveDelay:A=-1,optionalKeySupport:$=!1,initialize:O=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuToggleSelector:r,submenuSelector:h,submenuSubtoggleSelector:c,controllerElement:u,containerElement:y,openClass:b,closeClass:_,transitionClass:C,isTopLevel:T,parentMenu:E,hoverType:M,hoverDelay:v,enterDelay:I,leaveDelay:A,optionalKeySupport:$,initialize:!1});l(this,"_MenuType",L);l(this,"_MenuItemType",R);l(this,"_MenuToggleType",P);O&&this.initialize()}}return L}(); |
@@ -1,3 +0,3 @@ | ||
var Bootstrap5Treeview=function(){"use strict";var N=Object.defineProperty;var V=(p,m,g)=>m in p?N(p,m,{enumerable:!0,configurable:!0,writable:!0,value:g}):p[m]=g;var l=(p,m,g)=>(V(p,typeof m!="symbol"?m+"":m,g),g);function p(n,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof n)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${n.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function m(n,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==n)throw new TypeError(`${t} must be a ${n}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function g(n){try{if(typeof n!="object"){const e=typeof n;throw new TypeError(`Values given to isCSSSelector() must be inside of an object. "${e}" given.`)}for(const e in n)try{if(n[e]===null)throw new Error;document.querySelector(n[e])}catch{throw new TypeError(`${e} must be a valid CSS selector. "${n[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function M(n){try{if(typeof n!="object"||Array.isArray(n)){const e=typeof n;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in n){const t=typeof n[e];if(t!=="string")if(Array.isArray(n[e]))n[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=n[e],g(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function $(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function D(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function L(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function O(n,e){if(m("string",{tagName:n}).status&&p(HTMLElement,e).status){const t=n.toLowerCase();let s=!0;for(const i in e)e[i].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class S{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i=null}){l(this,"_dom",{toggle:null,parent:null});l(this,"_elements",{controlledMenu:null,parentMenu:null});l(this,"_open",!1);l(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));l(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=i}initialize(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),O("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,""),s=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)),s=`${t}-${s}`),this.dom.toggle.id=this.dom.toggle.id||`${s}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${s}-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){m("boolean",{value:e}),this._open=e}_expand(e=!0){const{closeClass:t,openClass:s}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),s!==""&&(typeof s=="string"?this.elements.controlledMenu.dom.menu.classList.add(s):this.elements.controlledMenu.dom.menu.classList.add(...s)),t!==""&&(typeof t=="string"?this.elements.controlledMenu.dom.menu.classList.remove(t):this.elements.controlledMenu.dom.menu.classList.remove(...t)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),t!==""&&(typeof t=="string"?this.elements.controlledMenu.dom.menu.classList.add(t):this.elements.controlledMenu.dom.menu.classList.add(...t)),s!==""&&(typeof s=="string"?this.elements.controlledMenu.dom.menu.classList.remove(s):this.elements.controlledMenu.dom.menu.classList.remove(...s)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class k{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:o=null}){l(this,"_dom",{item:null,link:null});l(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});l(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,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 C(n){try{const e=n.key||n.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function c(n){n.preventDefault(),n.stopPropagation()}class E{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:o="ul",controllerElement:u=null,containerElement:h=null,openClass:b="show",closeClass:d="hide",isTopLevel:a=!0,parentMenu:f=null,hoverType:y="off",hoverDelay:_=250}){l(this,"_MenuType",E);l(this,"_MenuItemType",k);l(this,"_MenuToggleType",S);l(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});l(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});l(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});l(this,"_openClass","show");l(this,"_closeClass","hide");l(this,"_root",!0);l(this,"_currentChild",0);l(this,"_focusState","none");l(this,"_currentEvent","none");l(this,"_hoverType","off");l(this,"_hoverDelay",250);l(this,"_errors",[]);this._dom.menu=e,this._dom.controller=u,this._dom.container=h,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=i,this._selectors.submenuToggles=r,this._selectors.submenus=o,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=f,this._elements.rootMenu=a?this:null,this._openClass=b||"",this._closeClass=d||"",this._root=a,this._hoverType=y,this._hoverDelay=_}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
var Bootstrap5Treeview=function(){"use strict";var H=Object.defineProperty;var P=(c,a,_)=>a in c?H(c,a,{enumerable:!0,configurable:!0,writable:!0,value:_}):c[a]=_;var o=(c,a,_)=>(P(c,typeof a!="symbol"?a+"":a,_),_);function c(i,e){typeof i=="string"?e.classList.add(i):e.classList.add(...i)}function a(i,e){typeof i=="string"?e.classList.remove(i):e.classList.remove(...i)}function _(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function y(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function S(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isCSSSelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid CSS selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function C(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],S(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function j(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function V(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function x(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function q(i,e){if(y("string",{tagName:i}).status&&_(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class ${constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){o(this,"_dom",{toggle:null,parent:null});o(this,"_elements",{controlledMenu:null,parentMenu:null});o(this,"_open",!1);o(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));o(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){var e;if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),q("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${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){y("boolean",{value:e}),this._open=e}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(c(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&a(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&c(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{a(n,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&c(s,this.elements.controlledMenu.dom.menu),t!==""&&a(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(c(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&a(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&c(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{a(n,this.elements.controlledMenu.dom.menu)})})})):(t!==""&&c(t,this.elements.controlledMenu.dom.menu),s!==""&&a(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class O{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null}){o(this,"_dom",{item:null,link:null});o(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});o(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=r,this._elements.toggle=l,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function w(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function d(i){i.preventDefault(),i.stopPropagation()}class I{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="",submenuToggleSelector:r="a",submenuSelector:l="ul",controllerElement:u=null,containerElement:h=null,openClass:m="show",closeClass:f="hide",transitionClass:p="transitioning",isTopLevel:g=!0,parentMenu:b=null,hoverType:M="off",hoverDelay:E=250,enterDelay:T=-1,leaveDelay:v=-1}){o(this,"_MenuType",I);o(this,"_MenuItemType",O);o(this,"_MenuToggleType",$);o(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});o(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});o(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});o(this,"_openClass","show");o(this,"_closeClass","hide");o(this,"_transitionClass","transitioning");o(this,"_root",!0);o(this,"_currentChild",0);o(this,"_focusState","none");o(this,"_currentEvent","none");o(this,"_hoverType","off");o(this,"_hoverDelay",250);o(this,"_enterDelay",-1);o(this,"_leaveDelay",-1);o(this,"_hoverTimeout",null);o(this,"_errors",[]);this._dom.menu=e,this._dom.controller=u,this._dom.container=h,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=r,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=b,this._elements.rootMenu=g?this:null,this._openClass=m||"",this._closeClass=f||"",this._transitionClass=p||"",this._root=g,this._hoverType=M,this._hoverDelay=E,this._enterDelay=T,this._leaveDelay=v}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
- ${this.errors.join(` | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get 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(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){M({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){M({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set currentChild(e){m("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let r=0,o=!1;for(;!o&&r<s.elements.parentMenu.elements.menuItems.length;){const u=s.elements.parentMenu.elements.menuItems[r];u.isSubmenuItem&&u.elements.toggle.elements.controlledMenu===s&&(o=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=r),r++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){$({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){D({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){L({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){m("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=p(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=p(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=g({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=g({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const u=M({openClass:this._openClass});u.status||(this._errors.push(u.error.message),e=!1)}if(this._closeClass!==""){const u=M({closeClass:this._closeClass});u.status||(this._errors.push(u.error.message),e=!1)}const i=m("boolean",{isTopLevel:this._root});if(i.status||(this._errors.push(i.error.message),e=!1),this._elements.parentMenu!==null){const u=p(E,{parentMenu:this._elements.parentMenu});u.status||(this._errors.push(u.error.message),e=!1)}const r=L({hoverType:this._hoverType});r.status||(this._errors.push(r.error.message),e=!1);const o=m("number",{hoverDelay:this._hoverDelay});return o.status||(this._errors.push(o.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&p(HTMLElement,{base:t});const r=Array.from(t.querySelectorAll(this.selectors[e])).filter(o=>o.parentElement===t);s?this._dom[e]=r:this._dom[e]=[...this._dom[e],...r]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),i=e.querySelector(this.selectors.submenus),r=new this._MenuType({menuElement:i,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),o=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:r,parentMenu:this});this._elements.submenuToggles.push(o),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:r,toggle:o})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,i){c(i),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",i=>{this.currentEvent="mouse",e(this,t.elements.toggle,i)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&e.elements.toggle.preview();else if(this.hoverType==="dynamic"){const i=this.elements.submenuToggles.some(r=>r.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||i)&&(this.currentEvent="mouse",e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.hoverDelay>0?setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.hoverDelay):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(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=C(e);(t==="Space"||t==="Enter")&&c(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=C(e);(t==="Space"||t==="Enter")&&(c(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",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class A extends k{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:o=null,initialize:u=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i,childMenu:r,toggle:o}),u&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","treeitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.dom.link.tabIndex=0}blur(){super.blur(),this.dom.link.tabIndex=-1}}class x extends S{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i}),r&&this.initialize()}}class T extends E{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:i="a",submenuItemSelector:r="",submenuToggleSelector:o="a",submenuSelector:u="ul",controllerElement:h=null,containerElement:b=null,openClass:d="show",closeClass:a="hide",isTopLevel:f=!0,parentMenu:y=null,hoverType:_="off",hoverDelay:w=250,initialize:I=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:i,submenuItemSelector:r,submenuToggleSelector:o,submenuSelector:u,controllerElement:h,containerElement:b,openClass:d,closeClass:a,isTopLevel:f,parentMenu:y,hoverType:_,hoverDelay:w});l(this,"_MenuType",T);l(this,"_MenuItemType",A);l(this,"_MenuToggleType",x);I&&this.initialize()}initialize(){try{super.initialize(),this.isTopLevel?(this.dom.menu.setAttribute("role","tree"),this.elements.menuItems[0].dom.link.tabIndex=0):this.dom.menu.setAttribute("role","group"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=C(t);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?this.elements.rootMenu.blur():this.elements.rootMenu.focus()),this.focusState==="self"){const i=["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"],r=["Enter","ArrowRight"],o=["Escape"];(i.includes(s)||this.currentMenuItem.isSubmenuItem&&r.includes(s)||this.elements.controller&&o.includes(s))&&c(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=C(t),{altKey:i,crtlKey:r,metaKey:o}=t;if(s==="Character"&&!(i||r||o))c(t),this.elements.rootMenu.currentEvent="character",this.focusNextNodeWithCharacter(t.key);else if(this.focusState==="self")if(s==="Enter"||s==="Space")c(t),this.currentMenuItem.isSubmenuItem?this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview():this.currentMenuItem.dom.link.click();else if(s==="Escape")this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController());else if(s==="ArrowDown")c(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):!this.isTopLevel&&this.currentChild===this.elements.menuItems.length-1?this.focusParentsNextChild():this.focusNextChild();else if(s==="ArrowUp"){c(t);const h=this.elements.menuItems[this.currentChild-1];h&&h.isSubmenuItem&&h.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentChild=this.currentChild-1,this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.focusChildsLastNode()):!this.isTopLevel&&this.currentChild===0?(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild()):this.focusPreviousChild()}else s==="ArrowRight"?this.currentMenuItem.isSubmenuItem&&(c(t),this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):this.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?(c(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.toggle.close()):this.isTopLevel||(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild())):s==="Home"?(c(t),this.blurCurrentChild(),this.elements.rootMenu.focusFirstChild()):s==="End"?(c(t),this.blurCurrentChild(),this.elements.rootMenu.focusLastNode()):s==="Asterisk"&&(c(t),this.openChildren())})}focusLastNode(){const t=this.elements.menuItems.length-1,s=this.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.isOpen?(this.currentChild=t,s.elements.childMenu.currentEvent=this.currentEvent,s.elements.childMenu.focusLastNode()):this.focusLastChild()}openChildren(){this.elements.submenuToggles.forEach(t=>t.preview())}focusNextNodeWithCharacter(t){function s(d){let a=[];return d.elements.menuItems.forEach(f=>{a.push(f),f.isSubmenuItem&&f.elements.toggle.isOpen&&(a=[...a,...s(f.elements.toggle.elements.controlledMenu)])}),a}const i=t.toLowerCase(),r=s(this.elements.rootMenu),o=r.indexOf(this.currentMenuItem)+1,u=[...r.slice(o),...r.slice(0,o)];let h=0,b=!1;for(;!b&&h<u.length;){let d="";if(u[h].dom.item.innerText?d=u[h].dom.item.innerText:d=u[h].dom.item.textContent,d=d.replace(/[\s]/g,"").toLowerCase().charAt(0),d===i){b=!0;const a=u[h].elements.parentMenu,f=a.elements.menuItems.indexOf(u[h]);this.elements.rootMenu.blurChildren(),a.focusChild(f)}h++}}focusParentsNextChild(){this.elements.parentMenu&&(this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.currentChild===this.elements.parentMenu.elements.menuItems.length-1?(this.elements.parentMenu.blurCurrentChild(),this.elements.parentMenu.focusParentsNextChild()):(this.blurChildren(),this.elements.parentMenu.focusNextChild()))}focusChildsLastNode(){this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusLastChild(),this.currentMenuItem.elements.childMenu.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.childMenu.currentMenuItem.elements.toggle.isOpen&&(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.childMenu.focusChildsLastNode())}}class z extends A{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:r=null,toggle:o=null,initialize:u=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i,childMenu:r,toggle:o,initialize:!1}),u&&this.initialize()}}class j extends x{constructor({menuToggleElement:t,parentElement:s,controlledMenu:i,parentMenu:r=null,initialize:o=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:i,parentMenu:r,initialize:!1});l(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=i.isTopLevel?i.dom.container:i.dom.menu,o&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(t=!0){const{openClass:s}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),s!==""&&(typeof s=="string"?this.dom.container.classList.add(s):this.dom.container.classList.add(...s)),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),s!==""&&(typeof s=="string"?this.dom.container.classList.add(s):this.dom.container.classList.add(...s)),i!==""&&(typeof i=="string"?this.dom.container.classList.remove(i):this.dom.container.classList.remove(...i)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class v extends T{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:i=".nav-link,.dropdown-item",submenuItemSelector:r=".dropdown",submenuToggleSelector:o=".dropdown-toggle",submenuSelector:u=".dropdown-menu",controllerElement:h=null,containerElement:b=null,openClass:d="show",closeClass:a="collapse",isTopLevel:f=!0,parentMenu:y=null,hoverType:_="off",hoverDelay:w=250,initialize:I=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:i,submenuItemSelector:r,submenuToggleSelector:o,submenuSelector:u,controllerElement:h,containerElement:b,openClass:d,closeClass:a,isTopLevel:f,parentMenu:y,hoverType:_,hoverDelay:w,initialize:!1});l(this,"_MenuType",v);l(this,"_MenuItemType",z);l(this,"_MenuToggleType",j);I&&this.initialize()}}return v}(); | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){C({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){C({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){C({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set currentChild(e){y("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let r=0,l=!1;for(;!l&&r<s.elements.parentMenu.elements.menuItems.length;){const u=s.elements.parentMenu.elements.menuItems[r];u.isSubmenuItem&&u.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=r),r++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){j({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){V({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){x({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){y("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){y("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){y("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=_(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=_(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const m=C({openClass:this._openClass});m.status||(this._errors.push(m.error.message),e=!1)}if(this._closeClass!==""){const m=C({closeClass:this._closeClass});m.status||(this._errors.push(m.error.message),e=!1)}if(this._transitionClass!==""){const m=C({transitionClass:this._transitionClass});m.status||(this._errors.push(m.error.message),e=!1)}const n=y("boolean",{isTopLevel:this._root});if(n.status||(this._errors.push(n.error.message),e=!1),this._elements.parentMenu!==null){const m=_(I,{parentMenu:this._elements.parentMenu});m.status||(this._errors.push(m.error.message),e=!1)}const r=x({hoverType:this._hoverType});r.status||(this._errors.push(r.error.message),e=!1);const l=y("number",{hoverDelay:this._hoverDelay});l.status||(this._errors.push(l.error.message),e=!1);const u=y("number",{enterDelay:this._enterDelay});u.status||(this._errors.push(u.error.message),e=!1);const h=y("number",{leaveDelay:this._leaveDelay});return h.status||(this._errors.push(h.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&_(HTMLElement,{base:t});const r=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=r:this._dom[e]=[...this._dom[e],...r]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),r=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:r,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:r,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,n){d(n),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview());else if(this.hoverType==="dynamic"){const n=this.elements.submenuToggles.some(r=>r.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||n)&&(this.currentEvent="mouse",this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&d(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&(d(e),this.elements.controller.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",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class F extends O{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:u=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l}),u&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","treeitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.dom.link.tabIndex=0}blur(){super.blur(),this.dom.link.tabIndex=-1}}class z extends ${constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),r&&this.initialize()}}class k extends I{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:r="",submenuToggleSelector:l="a",submenuSelector:u="ul",controllerElement:h=null,containerElement:m=null,openClass:f="show",closeClass:p="hide",transitionClass:g="transitioning",isTopLevel:b=!0,parentMenu:M=null,hoverType:E="off",hoverDelay:T=250,enterDelay:v=-1,leaveDelay:A=-1,initialize:D=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:u,controllerElement:h,containerElement:m,openClass:f,closeClass:p,transitionClass:g,isTopLevel:b,parentMenu:M,hoverType:E,hoverDelay:T,enterDelay:v,leaveDelay:A});o(this,"_MenuType",k);o(this,"_MenuItemType",F);o(this,"_MenuToggleType",z);D&&this.initialize()}initialize(){try{super.initialize(),this.isTopLevel?(this.dom.menu.setAttribute("role","tree"),this.elements.menuItems[0].dom.link.tabIndex=0):this.dom.menu.setAttribute("role","group"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=w(t);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?this.elements.rootMenu.blur():this.elements.rootMenu.focus()),this.focusState==="self"){const n=["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"],r=["Enter","ArrowRight"],l=["Escape"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&r.includes(s)||this.elements.controller&&l.includes(s))&&d(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=w(t),{altKey:n,crtlKey:r,metaKey:l}=t;if(s==="Character"&&!(n||r||l))d(t),this.elements.rootMenu.currentEvent="character",this.focusNextNodeWithCharacter(t.key);else if(this.focusState==="self")if(s==="Enter"||s==="Space")d(t),this.currentMenuItem.isSubmenuItem?this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview():this.currentMenuItem.dom.link.click();else if(s==="Escape")this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController());else if(s==="ArrowDown")d(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):!this.isTopLevel&&this.currentChild===this.elements.menuItems.length-1?this.focusParentsNextChild():this.focusNextChild();else if(s==="ArrowUp"){d(t);const h=this.elements.menuItems[this.currentChild-1];h&&h.isSubmenuItem&&h.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentChild=this.currentChild-1,this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.focusChildsLastNode()):!this.isTopLevel&&this.currentChild===0?(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild()):this.focusPreviousChild()}else s==="ArrowRight"?this.currentMenuItem.isSubmenuItem&&(d(t),this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):this.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?(d(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.toggle.close()):this.isTopLevel||(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild())):s==="Home"?(d(t),this.blurCurrentChild(),this.elements.rootMenu.focusFirstChild()):s==="End"?(d(t),this.blurCurrentChild(),this.elements.rootMenu.focusLastNode()):s==="Asterisk"&&(d(t),this.openChildren())})}focusLastNode(){const t=this.elements.menuItems.length-1,s=this.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.isOpen?(this.currentChild=t,s.elements.childMenu.currentEvent=this.currentEvent,s.elements.childMenu.focusLastNode()):this.focusLastChild()}openChildren(){this.elements.submenuToggles.forEach(t=>t.preview())}focusNextNodeWithCharacter(t){function s(f){let p=[];return f.elements.menuItems.forEach(g=>{p.push(g),g.isSubmenuItem&&g.elements.toggle.isOpen&&(p=[...p,...s(g.elements.toggle.elements.controlledMenu)])}),p}const n=t.toLowerCase(),r=s(this.elements.rootMenu),l=r.indexOf(this.currentMenuItem)+1,u=[...r.slice(l),...r.slice(0,l)];let h=0,m=!1;for(;!m&&h<u.length;){let f="";if(u[h].dom.item.innerText?f=u[h].dom.item.innerText:f=u[h].dom.item.textContent,f=f.replace(/[\s]/g,"").toLowerCase().charAt(0),f===n){m=!0;const p=u[h].elements.parentMenu,g=p.elements.menuItems.indexOf(u[h]);this.elements.rootMenu.blurChildren(),p.focusChild(g)}h++}}focusParentsNextChild(){this.elements.parentMenu&&(this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.currentChild===this.elements.parentMenu.elements.menuItems.length-1?(this.elements.parentMenu.blurCurrentChild(),this.elements.parentMenu.focusParentsNextChild()):(this.blurChildren(),this.elements.parentMenu.focusNextChild()))}focusChildsLastNode(){this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusLastChild(),this.currentMenuItem.elements.childMenu.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.childMenu.currentMenuItem.elements.toggle.isOpen&&(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.childMenu.focusChildsLastNode())}}class N extends F{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:u=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l,initialize:!1}),u&&this.initialize()}}class K extends z{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r,initialize:!1});o(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,l&&this.initialize()}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(t=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(c(n,this.dom.container),requestAnimationFrame(()=>{c(s,this.dom.container),requestAnimationFrame(()=>{a(n,this.dom.container)})})):s!==""&&c(s,this.dom.container),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:r}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),r!==""?(c(r,this.dom.container),requestAnimationFrame(()=>{n!==""&&a(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&c(s,this.dom.container),requestAnimationFrame(()=>{a(r,this.dom.container)})})})):(s!==""&&c(s,this.dom.container),n!==""&&a(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class L extends k{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:r=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:u=".dropdown-menu",controllerElement:h=null,containerElement:m=null,openClass:f="show",closeClass:p="collapse",transitionClass:g="transitioning",isTopLevel:b=!0,parentMenu:M=null,hoverType:E="off",hoverDelay:T=250,enterDelay:v=-1,leaveDelay:A=-1,initialize:D=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:u,controllerElement:h,containerElement:m,openClass:f,closeClass:p,transitionClass:g,isTopLevel:b,parentMenu:M,hoverType:E,hoverDelay:T,enterDelay:v,leaveDelay:A,initialize:!1});o(this,"_MenuType",L);o(this,"_MenuItemType",N);o(this,"_MenuToggleType",K);D&&this.initialize()}}return L}(); |
{ | ||
"name": "accessible-menu-bootstrap-5", | ||
"version": "2.0.0-beta.0", | ||
"version": "2.0.0-beta.1", | ||
"description": "A JavaScript library to help you generate WAI-ARIA accessible menus with in the DOM using Bootstrap 5.", | ||
@@ -56,3 +56,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"accessible-menu": "^4.0.0-beta.0" | ||
"accessible-menu": "^4.0.0-beta.1" | ||
}, | ||
@@ -65,3 +65,3 @@ "devDependencies": { | ||
"@commitlint/config-conventional": "^17.0.0", | ||
"@vitest/ui": "^0.28.5", | ||
"@vitest/ui": "^0.32.2", | ||
"commitizen": "^4.2.2", | ||
@@ -72,3 +72,3 @@ "cz-conventional-changelog": "^3.3.0", | ||
"eslint-config-standard": "^16.0.1", | ||
"eslint-plugin-jsdoc": "^40.0.0", | ||
"eslint-plugin-jsdoc": "^43.0.0", | ||
"husky": "^8.0.1", | ||
@@ -84,4 +84,4 @@ "jsdoc": "^4.0.0", | ||
"vite-plugin-browser-sync": "^1.0.2", | ||
"vitest": "^0.28.5" | ||
"vitest": "^0.32.2" | ||
} | ||
} |
@@ -49,3 +49,3 @@ # accessible-menu-bootstrap-5 | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@2.0.0-beta.0/dist/accessible-menu-bs5.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@2.0.0-beta.1/dist/accessible-menu-bs5.min.js"></script> | ||
``` | ||
@@ -80,3 +80,3 @@ | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@2.0.0-beta.0/dist/accessible-menu-bs5.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@2.0.0-beta.1/dist/accessible-menu-bs5.min.js"></script> | ||
``` | ||
@@ -109,3 +109,3 @@ | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@2.0.0-beta.0/dist/disclosure-menu-bs5.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@2.0.0-beta.1/dist/disclosure-menu-bs5.min.js"></script> | ||
``` | ||
@@ -130,3 +130,3 @@ | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@2.0.0-beta.0/dist/menubar-bs5.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@2.0.0-beta.1/dist/menubar-bs5.min.js"></script> | ||
``` | ||
@@ -171,3 +171,3 @@ | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@2.0.0-beta.0/dist/treeview-bs5.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@2.0.0-beta.1/dist/treeview-bs5.min.js"></script> | ||
``` | ||
@@ -174,0 +174,0 @@ |
@@ -54,2 +54,3 @@ import DisclosureMenu from "accessible-menu/src/disclosureMenu.js"; | ||
* @param {(string|string[]|null)} [options.closeClass = collapse] - The class to apply when a menu is "closed". | ||
* @param {?(string|string[])} [options.transitionClass = transitioning] - The class to apply when a menu is transitioning between "open" and "closed" states. | ||
* @param {boolean} [options.isTopLevel = false] - A flag to mark the root menu. | ||
@@ -59,2 +60,4 @@ * @param {(Bootstrap5DisclosureMenu|null)} [options.parentMenu = null] - The parent menu to this menu. | ||
* @param {number} [options.hoverDelay = 250] - The delay for closing menus if the menu is hoverable (in miliseconds). | ||
* @param {number} [options.enterDelay = -1] - The delay for opening a menu if the menu is focusable (in miliseconds). | ||
* @param {number} [options.leaveDelay = -1] - The delay for closing a menu if the menu is focusable (in miliseconds). | ||
* @param {boolean} [options.optionalKeySupport = false] - A flag to add optional keyboard support (Arrow keys, Home, and End) to the menu. | ||
@@ -74,2 +77,3 @@ * @param {boolean} [options.initialize = true] - A flag to initialize the menu immediately upon creation. | ||
closeClass = "collapse", | ||
transitionClass = "transitioning", | ||
isTopLevel = true, | ||
@@ -79,2 +83,4 @@ parentMenu = null, | ||
hoverDelay = 250, | ||
enterDelay = -1, | ||
leaveDelay = -1, | ||
optionalKeySupport = false, | ||
@@ -94,2 +100,3 @@ initialize = true, | ||
closeClass, | ||
transitionClass, | ||
isTopLevel, | ||
@@ -99,2 +106,4 @@ parentMenu, | ||
hoverDelay, | ||
enterDelay, | ||
leaveDelay, | ||
optionalKeySupport, | ||
@@ -101,0 +110,0 @@ initialize: false, |
/* eslint-disable jsdoc/no-undefined-types */ | ||
import DisclosureMenuToggle from "accessible-menu/src/disclosureMenuToggle.js"; | ||
import { addClass, removeClass } from "accessible-menu/src/domHelpers.js"; | ||
@@ -87,13 +88,21 @@ /* | ||
_expand(emit = true) { | ||
const { openClass } = this.elements.controlledMenu; | ||
const { openClass, transitionClass } = this.elements.controlledMenu; | ||
this.dom.toggle.setAttribute("aria-expanded", "true"); | ||
// Add the open class | ||
if (openClass !== "") { | ||
if (typeof openClass === "string") { | ||
this.dom.container.classList.add(openClass); | ||
} else { | ||
this.dom.container.classList.add(...openClass); | ||
} | ||
// If we're dealing with transition classes, then we need to utilize | ||
// requestAnimationFrame to add the transition class, add the open class, | ||
// and then remove the transition class. | ||
if (transitionClass !== "") { | ||
addClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
addClass(openClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
}); | ||
}); | ||
} else if (openClass !== "") { | ||
addClass(openClass, this.dom.container); | ||
} | ||
@@ -114,21 +123,37 @@ | ||
_collapse(emit = true) { | ||
const { closeClass, openClass } = this.elements.controlledMenu; | ||
const { closeClass, openClass, transitionClass } = | ||
this.elements.controlledMenu; | ||
this.dom.toggle.setAttribute("aria-expanded", "false"); | ||
// Add the close class | ||
if (closeClass !== "") { | ||
if (typeof closeClass === "string") { | ||
this.dom.container.classList.add(closeClass); | ||
} else { | ||
this.dom.container.classList.add(...closeClass); | ||
// If we're dealing with transition classes, then we need to utilize | ||
// requestAnimationFrame to add the transition class, remove the open class, | ||
// add the close class, and finally remove the transition class. | ||
if (transitionClass !== "") { | ||
addClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
if (openClass !== "") { | ||
removeClass(openClass, this.dom.container); | ||
} | ||
requestAnimationFrame(() => { | ||
if (closeClass !== "") { | ||
addClass(closeClass, this.dom.container); | ||
} | ||
requestAnimationFrame(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
}); | ||
}); | ||
}); | ||
} else { | ||
// Add the close class | ||
if (closeClass !== "") { | ||
addClass(closeClass, this.dom.container); | ||
} | ||
} | ||
// Remove the open class. | ||
if (openClass !== "") { | ||
if (typeof openClass === "string") { | ||
this.dom.container.classList.remove(openClass); | ||
} else { | ||
this.dom.container.classList.remove(...openClass); | ||
// Remove the open class. | ||
if (openClass !== "") { | ||
removeClass(openClass, this.dom.container); | ||
} | ||
@@ -135,0 +160,0 @@ } |
@@ -52,2 +52,3 @@ import Menubar from "accessible-menu/src/menubar.js"; | ||
* @param {(string|string[]|null)} [options.closeClass = collapse] - The class to apply when a menu is "closed". | ||
* @param {?(string|string[])} [options.transitionClass = transitioning] - The class to apply when a menu is transitioning between "open" and "closed" states. | ||
* @param {boolean} [options.isTopLevel = false] - A flag to mark the root menu. | ||
@@ -57,2 +58,4 @@ * @param {(Bootstrap5Menubar|null)} [options.parentMenu = null] - The parent menu to this menu. | ||
* @param {number} [options.hoverDelay = 250] - The delay for closing menus if the menu is hoverable (in miliseconds). | ||
* @param {number} [options.enterDelay = -1] - The delay for opening a menu if the menu is focusable (in miliseconds). | ||
* @param {number} [options.leaveDelay = -1] - The delay for closing a menu if the menu is focusable (in miliseconds). | ||
* @param {boolean} [options.initialize = true] - A flag to initialize the menu immediately upon creation. | ||
@@ -71,2 +74,3 @@ */ | ||
closeClass = "collapse", | ||
transitionClass = "transitioning", | ||
isTopLevel = true, | ||
@@ -76,2 +80,4 @@ parentMenu = null, | ||
hoverDelay = 250, | ||
enterDelay = -1, | ||
leaveDelay = -1, | ||
initialize = true, | ||
@@ -90,2 +96,3 @@ }) { | ||
closeClass, | ||
transitionClass, | ||
isTopLevel, | ||
@@ -95,2 +102,4 @@ parentMenu, | ||
hoverDelay, | ||
enterDelay, | ||
leaveDelay, | ||
initialize: false, | ||
@@ -97,0 +106,0 @@ }); |
/* eslint-disable jsdoc/no-undefined-types */ | ||
import MenubarToggle from "accessible-menu/src/menubarToggle.js"; | ||
import { addClass, removeClass } from "accessible-menu/src/domHelpers.js"; | ||
@@ -87,13 +88,21 @@ /* | ||
_expand(emit = true) { | ||
const { openClass } = this.elements.controlledMenu; | ||
const { openClass, transitionClass } = this.elements.controlledMenu; | ||
this.dom.toggle.setAttribute("aria-expanded", "true"); | ||
// Add the open class | ||
if (openClass !== "") { | ||
if (typeof openClass === "string") { | ||
this.dom.container.classList.add(openClass); | ||
} else { | ||
this.dom.container.classList.add(...openClass); | ||
} | ||
// If we're dealing with transition classes, then we need to utilize | ||
// requestAnimationFrame to add the transition class, add the open class, | ||
// and then remove the transition class. | ||
if (transitionClass !== "") { | ||
addClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
addClass(openClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
}); | ||
}); | ||
} else if (openClass !== "") { | ||
addClass(openClass, this.dom.container); | ||
} | ||
@@ -114,21 +123,37 @@ | ||
_collapse(emit = true) { | ||
const { closeClass, openClass } = this.elements.controlledMenu; | ||
const { closeClass, openClass, transitionClass } = | ||
this.elements.controlledMenu; | ||
this.dom.toggle.setAttribute("aria-expanded", "false"); | ||
// Add the close class | ||
if (closeClass !== "") { | ||
if (typeof closeClass === "string") { | ||
this.dom.container.classList.add(closeClass); | ||
} else { | ||
this.dom.container.classList.add(...closeClass); | ||
// If we're dealing with transition classes, then we need to utilize | ||
// requestAnimationFrame to add the transition class, remove the open class, | ||
// add the close class, and finally remove the transition class. | ||
if (transitionClass !== "") { | ||
addClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
if (openClass !== "") { | ||
removeClass(openClass, this.dom.container); | ||
} | ||
requestAnimationFrame(() => { | ||
if (closeClass !== "") { | ||
addClass(closeClass, this.dom.container); | ||
} | ||
requestAnimationFrame(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
}); | ||
}); | ||
}); | ||
} else { | ||
// Add the close class | ||
if (closeClass !== "") { | ||
addClass(closeClass, this.dom.container); | ||
} | ||
} | ||
// Remove the open class. | ||
if (openClass !== "") { | ||
if (typeof openClass === "string") { | ||
this.dom.container.classList.remove(openClass); | ||
} else { | ||
this.dom.container.classList.remove(...openClass); | ||
// Remove the open class. | ||
if (openClass !== "") { | ||
removeClass(openClass, this.dom.container); | ||
} | ||
@@ -135,0 +160,0 @@ } |
@@ -55,2 +55,3 @@ import TopLinkDisclosureMenu from "accessible-menu/src/topLinkDisclosureMenu.js"; | ||
* @param {(string|string[]|null)} [options.closeClass = collapse] - The class to apply when a menu is "closed". | ||
* @param {?(string|string[])} [options.transitionClass = transitioning] - The class to apply when a menu is transitioning between "open" and "closed" states. | ||
* @param {boolean} [options.isTopLevel = false] - A flag to mark the root menu. | ||
@@ -60,2 +61,4 @@ * @param {(Bootstrap5TopLinkDisclosureMenu|null)} [options.parentMenu = null] - The parent menu to this menu. | ||
* @param {number} [options.hoverDelay = 250] - The delay for closing menus if the menu is hoverable (in miliseconds). | ||
* @param {number} [options.enterDelay = -1] - The delay for opening a menu if the menu is focusable (in miliseconds). | ||
* @param {number} [options.leaveDelay = -1] - The delay for closing a menu if the menu is focusable (in miliseconds). | ||
* @param {boolean} [options.optionalKeySupport = false] - A flag to add optional keyboard support (Arrow keys, Home, and End) to the menu. | ||
@@ -76,2 +79,3 @@ * @param {boolean} [options.initialize = true] - A flag to initialize the menu immediately upon creation. | ||
closeClass = "collapse", | ||
transitionClass = "transitioning", | ||
isTopLevel = true, | ||
@@ -81,2 +85,4 @@ parentMenu = null, | ||
hoverDelay = 250, | ||
enterDelay = -1, | ||
leaveDelay = -1, | ||
optionalKeySupport = false, | ||
@@ -97,2 +103,3 @@ initialize = true, | ||
closeClass, | ||
transitionClass, | ||
isTopLevel, | ||
@@ -102,2 +109,4 @@ parentMenu, | ||
hoverDelay, | ||
enterDelay, | ||
leaveDelay, | ||
optionalKeySupport, | ||
@@ -104,0 +113,0 @@ initialize: false, |
/* eslint-disable jsdoc/no-undefined-types */ | ||
import TopLinkDisclosureMenuToggle from "accessible-menu/src/topLinkDisclosureMenuToggle.js"; | ||
import { addClass, removeClass } from "accessible-menu/src/domHelpers.js"; | ||
@@ -87,13 +88,21 @@ /* | ||
_expand(emit = true) { | ||
const { openClass } = this.elements.controlledMenu; | ||
const { openClass, transitionClass } = this.elements.controlledMenu; | ||
this.dom.toggle.setAttribute("aria-expanded", "true"); | ||
// Add the open class | ||
if (openClass !== "") { | ||
if (typeof openClass === "string") { | ||
this.dom.container.classList.add(openClass); | ||
} else { | ||
this.dom.container.classList.add(...openClass); | ||
} | ||
// If we're dealing with transition classes, then we need to utilize | ||
// requestAnimationFrame to add the transition class, add the open class, | ||
// and then remove the transition class. | ||
if (transitionClass !== "") { | ||
addClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
addClass(openClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
}); | ||
}); | ||
} else if (openClass !== "") { | ||
addClass(openClass, this.dom.container); | ||
} | ||
@@ -114,21 +123,37 @@ | ||
_collapse(emit = true) { | ||
const { closeClass, openClass } = this.elements.controlledMenu; | ||
const { closeClass, openClass, transitionClass } = | ||
this.elements.controlledMenu; | ||
this.dom.toggle.setAttribute("aria-expanded", "false"); | ||
// Add the close class | ||
if (closeClass !== "") { | ||
if (typeof closeClass === "string") { | ||
this.dom.container.classList.add(closeClass); | ||
} else { | ||
this.dom.container.classList.add(...closeClass); | ||
// If we're dealing with transition classes, then we need to utilize | ||
// requestAnimationFrame to add the transition class, remove the open class, | ||
// add the close class, and finally remove the transition class. | ||
if (transitionClass !== "") { | ||
addClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
if (openClass !== "") { | ||
removeClass(openClass, this.dom.container); | ||
} | ||
requestAnimationFrame(() => { | ||
if (closeClass !== "") { | ||
addClass(closeClass, this.dom.container); | ||
} | ||
requestAnimationFrame(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
}); | ||
}); | ||
}); | ||
} else { | ||
// Add the close class | ||
if (closeClass !== "") { | ||
addClass(closeClass, this.dom.container); | ||
} | ||
} | ||
// Remove the open class. | ||
if (openClass !== "") { | ||
if (typeof openClass === "string") { | ||
this.dom.container.classList.remove(openClass); | ||
} else { | ||
this.dom.container.classList.remove(...openClass); | ||
// Remove the open class. | ||
if (openClass !== "") { | ||
removeClass(openClass, this.dom.container); | ||
} | ||
@@ -135,0 +160,0 @@ } |
@@ -52,2 +52,3 @@ import Treeview from "accessible-menu/src/treeview.js"; | ||
* @param {(string|string[]|null)} [options.closeClass = collapse] - The class to apply when a menu is "closed". | ||
* @param {?(string|string[])} [options.transitionClass = transitioning] - The class to apply when a menu is transitioning between "open" and "closed" states. | ||
* @param {boolean} [options.isTopLevel = false] - A flag to mark the root menu. | ||
@@ -57,2 +58,4 @@ * @param {(Bootstrap5Treeview|null)} [options.parentMenu = null] - The parent menu to this menu. | ||
* @param {number} [options.hoverDelay = 250] - The delay for closing menus if the menu is hoverable (in miliseconds). | ||
* @param {number} [options.enterDelay = -1] - The delay for opening a menu if the menu is focusable (in miliseconds). | ||
* @param {number} [options.leaveDelay = -1] - The delay for closing a menu if the menu is focusable (in miliseconds). | ||
* @param {boolean} [options.initialize = true] - A flag to initialize the menu immediately upon creation. | ||
@@ -71,2 +74,3 @@ */ | ||
closeClass = "collapse", | ||
transitionClass = "transitioning", | ||
isTopLevel = true, | ||
@@ -76,2 +80,4 @@ parentMenu = null, | ||
hoverDelay = 250, | ||
enterDelay = -1, | ||
leaveDelay = -1, | ||
initialize = true, | ||
@@ -90,2 +96,3 @@ }) { | ||
closeClass, | ||
transitionClass, | ||
isTopLevel, | ||
@@ -95,2 +102,4 @@ parentMenu, | ||
hoverDelay, | ||
enterDelay, | ||
leaveDelay, | ||
initialize: false, | ||
@@ -97,0 +106,0 @@ }); |
/* eslint-disable jsdoc/no-undefined-types */ | ||
import TreeviewToggle from "accessible-menu/src/treeviewToggle.js"; | ||
import { addClass, removeClass } from "accessible-menu/src/domHelpers.js"; | ||
@@ -87,13 +88,21 @@ /** | ||
_expand(emit = true) { | ||
const { openClass } = this.elements.controlledMenu; | ||
const { openClass, transitionClass } = this.elements.controlledMenu; | ||
this.dom.toggle.setAttribute("aria-expanded", "true"); | ||
// Add the open class | ||
if (openClass !== "") { | ||
if (typeof openClass === "string") { | ||
this.dom.container.classList.add(openClass); | ||
} else { | ||
this.dom.container.classList.add(...openClass); | ||
} | ||
// If we're dealing with transition classes, then we need to utilize | ||
// requestAnimationFrame to add the transition class, add the open class, | ||
// and then remove the transition class. | ||
if (transitionClass !== "") { | ||
addClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
addClass(openClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
}); | ||
}); | ||
} else if (openClass !== "") { | ||
addClass(openClass, this.dom.container); | ||
} | ||
@@ -114,21 +123,37 @@ | ||
_collapse(emit = true) { | ||
const { closeClass, openClass } = this.elements.controlledMenu; | ||
const { closeClass, openClass, transitionClass } = | ||
this.elements.controlledMenu; | ||
this.dom.toggle.setAttribute("aria-expanded", "false"); | ||
// Add the close class | ||
if (closeClass !== "") { | ||
if (typeof closeClass === "string") { | ||
this.dom.container.classList.add(closeClass); | ||
} else { | ||
this.dom.container.classList.add(...closeClass); | ||
// If we're dealing with transition classes, then we need to utilize | ||
// requestAnimationFrame to add the transition class, remove the open class, | ||
// add the close class, and finally remove the transition class. | ||
if (transitionClass !== "") { | ||
addClass(transitionClass, this.dom.container); | ||
requestAnimationFrame(() => { | ||
if (openClass !== "") { | ||
removeClass(openClass, this.dom.container); | ||
} | ||
requestAnimationFrame(() => { | ||
if (closeClass !== "") { | ||
addClass(closeClass, this.dom.container); | ||
} | ||
requestAnimationFrame(() => { | ||
removeClass(transitionClass, this.dom.container); | ||
}); | ||
}); | ||
}); | ||
} else { | ||
// Add the close class | ||
if (closeClass !== "") { | ||
addClass(closeClass, this.dom.container); | ||
} | ||
} | ||
// Remove the open class. | ||
if (openClass !== "") { | ||
if (typeof openClass === "string") { | ||
this.dom.container.classList.remove(openClass); | ||
} else { | ||
this.dom.container.classList.remove(...openClass); | ||
// Remove the open class. | ||
if (openClass !== "") { | ||
removeClass(openClass, this.dom.container); | ||
} | ||
@@ -135,0 +160,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
737293
14757
0