import*as e from"lit";import*as t from"lit/decorators.js";import*as s from"lit/directives/class-map.js";import*as i from"lit/directives/if-defined.js";var r,n,o={4085(e,t,s){s.d(t,{R:()=>f,W:()=>v});var i=s(2900),r=s(9609),n=s(4781),o=s(608),a=s(93),c=s(4084),d=s(2927),l=s(8899),m=s(4955),h=s(5410),u=s(3051),p=function(e,t,s,i){var r,n=arguments.length,o=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,s,o):r(t,s))||o);return n>3&&o&&Object.defineProperty(t,s,o),o};const f="more-menu-item-";var v;!function(e){let t=class extends((0,o.T)((0,n.I)(d.LitElement))){constructor(){super(...arguments),this.justified=!1,this.direction="horizontal",this.items=[],this.itemsHash={},this.itemsIdxHash={}}getNormalizedItemId(e){return e.replace(f,"")}static get styles(){return[c.A,u.A]}get slotItem(){return this.menuSlotElement}linkMenuItems(){return e=this,t=void 0,i=function*(){const{items:e}=this;e.forEach((e,t)=>{const s=(0,a.O)("menu");e.setAttribute("id",s),e.setAttribute("aria-controls",s),e.selected=this.selected===t}),this.itemsHash=this.items.reduce((e,t)=>(e[t.id]=t,e),{}),this.itemsIdxHash=this.items.reduce((e,t,s)=>(e[t.id]=s,e),{})},new((s=void 0)||(s=Promise))(function(r,n){function o(e){try{c(i.next(e))}catch(e){n(e)}}function a(e){try{c(i.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s(function(e){e(t)})).then(o,a)}c((i=i.apply(e,t||[])).next())});var e,t,s,i}setupMenuItems(){if(this.menuSlotElement){const e=this.menuSlotElement.assignedElements({flatten:!0});this.getChildrenFromTree({children:e},this.items)}}getChildrenFromTree(e,t){e.children.forEach(e=>{e instanceof h.D.ELEMENT&&t.push(e),this.getChildrenFromTree({children:Array.from(e.children)},t)})}updateSelectedItem(e){const t=this.slotted.findIndex(e=>e.hasAttribute("selected"));t!==e&&(this.items&&[t,e].forEach(e=>{const t=this.items[e];null==t||t.toggleAttribute("selected")}),this.dispatchEvent(new CustomEvent("selected-menu-item",{detail:{value:e},composed:!0,bubbles:!0})),this.changeSelectedItemIdx(e))}changeSelectedItemIdx(e){this.selected=e}handleItemClick(e){const{id:t}=e.detail,s=this.itemsHash[this.getNormalizedItemId(t)];if(s&&!s.disabled){const e=this.itemsIdxHash[s.id];-1!==e&&this.updateSelectedItem(e)}}handleItemKeydown(e){const{key:t,id:s}=e.detail;switch(t){case i.Uz.End:this.changeSelectedItemIdx(this.items.length-1);break;case i.Uz.Home:this.changeSelectedItemIdx(0);break;case i.Uz.ArrowLeft:case i.Uz.ArrowUp:0===this.selected?this.changeSelectedItemIdx(this.items.length-1):this.changeSelectedItemIdx(this.selected-1);break;case i.Uz.ArrowRight:case i.Uz.ArrowDown:this.selected===this.items.length-1?this.changeSelectedItemIdx(0):this.changeSelectedItemIdx(this.selected+1);break;case i.Uz.Enter:case i.Uz.Space:const e=this.slotted.findIndex(e=>e.id===s&&!e.disabled);-1!==e&&this.updateSelectedItem(e)}}connectedCallback(){super.connectedCallback(),this.addEventListener("menu-item-click",this.handleItemClick),this.addEventListener("menu-item-keydown",this.handleItemKeydown)}disconnectedCallback(){super.connectedCallback(),this.removeEventListener("menu-item-click",this.handleItemClick),this.removeEventListener("menu-item-keydown",this.handleItemKeydown)}onSlotChange(){this.setupMenuItems(),this.linkMenuItems()}get menuClassMap(){return{[`md-menu--${this.direction}`]:this.direction,justified:this.justified}}render(){return d.html`
        <nav class="md-menu ${(0,m.classMap)(this.menuClassMap)}">
          <ul class="md-menu-list">
            <slot @slotchange=${this.onSlotChange}></slot>
          </ul>
        </nav>
      `}};p([(0,l.property)({type:Boolean})],t.prototype,"justified",void 0),p([(0,l.property)({type:String})],t.prototype,"direction",void 0),p([(0,l.query)("slot")],t.prototype,"menuSlotElement",void 0),p([(0,l.query)("md-menu-overlay")],t.prototype,"menuSubElement",void 0),t=p([(0,r.w)("md-menu")],t),e.ELEMENT=t}(v||(v={}))},2927(t,s,i){var r,n;t.exports=(r={LitElement:()=>e.LitElement,css:()=>e.css,html:()=>e.html},n={},i.d(n,r),n)},8899(e,s,i){var r,n;e.exports=(r={property:()=>t.property,query:()=>t.query},n={},i.d(n,r),n)},4955(e,t,i){var r,n;e.exports=(r={classMap:()=>s.classMap},n={},i.d(n,r),n)},3517(e,t,s){var r,n;e.exports=(r={ifDefined:()=>i.ifDefined},n={},s.d(n,r),n)}},a={};function c(e){var t=a[e];if(void 0!==t)return t.exports;var s=a[e]={exports:{}};return o[e](s,s.exports,c),s.exports}c.m=o,r=[],c.O=(e,t,s,i)=>{if(!t){var n=1/0;for(l=0;l<r.length;l++){for(var[t,s,i]=r[l],o=!0,a=0;a<t.length;a++)(!1&i||n>=i)&&Object.keys(c.O).every(e=>c.O[e](t[a]))?t.splice(a--,1):(o=!1,i<n&&(n=i));if(o){r.splice(l--,1);var d=s();void 0!==d&&(e=d)}}return e}i=i||0;for(var l=r.length;l>0&&r[l-1][2]>i;l--)r[l]=r[l-1];r[l]=[t,s,i]},c.d=(e,t)=>{for(var s in t)c.o(t,s)&&!c.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);export{c as __webpack_require__};n={502:0,1037:0,1745:0,4928:0,5369:0,6060:0,8111:0,8442:0},c.C=e=>{var t,s,{__webpack_esm_ids__:i,__webpack_esm_modules__:r,__webpack_esm_runtime__:o}=e,a=0;for(t in r)c.o(r,t)&&(c.m[t]=r[t]);for(o&&o(c);a<i.length;a++)s=i[a],c.o(n,s)&&n[s]&&n[s][0](),n[i[a]]=0;c.O()},c.O.j=e=>0===n[e];import*as d from"../9609.js";c.C(d);import*as l from"../4084.js";c.C(l);import*as m from"../519.js";c.C(m);import*as h from"../9983.js";c.C(h);import*as u from"../7162.js";c.C(u);import*as p from"../93.js";c.C(p);import*as f from"../5846.js";c.C(f);import*as v from"../3051.js";c.C(v);import*as I from"../5410.js";c.C(I);var g=c.O(void 0,[9609,4084,519,9983,7162,93,5846,3051,5410],()=>c(4085));const y=(g=c.O(g)).R,E=g.W;export{y as MORE_MENU_ITEM_COPY_ID_PREFIX,E as Menu};