import{a as z,q as w,o as A,c as me,w as Z,x as P,ay as Ce,ch as Be,u as Oe,as as xe,B as ne,au as S,bg as V,bi as ue,be as Ne,s as p,p as ve,L as G,N as fe,O as J,r as x,bL as Ae,i as ze,D as he,aj as K,v as ce,b as be,aI as Te,bo as g,aA as D,E as ke,a0 as Le,a1 as He,F as ge,bs as Ie,M as de,aa as De,bb as je,aH as We,ci as Re,aY as Fe,ak as qe,b0 as Ve,m as Ge,e as X,j as pe,y as ee,h as Ue,t as Ke,C as Qe,Q as Me}from"./entry.539d3b49.js";import{E as Ee}from"./el-popper.6e1fd591.js";import{T as Ye,u as Ze,t as te}from"./index.e7365e3c.js";import{f as Je}from"./vnode.48eda29e.js";const Q=function(e,o,...n){let t;o.includes("mouse")||o.includes("click")?t="MouseEvents":o.includes("key")?t="KeyboardEvent":t="HTMLEvents";const u=document.createEvent(t);return u.initEvent(o,...n),e.dispatchEvent(u),e},Xe=z({name:"ElCollapseTransition"}),et=z({...Xe,setup(e){const o=w("collapse-transition"),n={beforeEnter(t){t.dataset||(t.dataset={}),t.dataset.oldPaddingTop=t.style.paddingTop,t.dataset.oldPaddingBottom=t.style.paddingBottom,t.style.maxHeight=0,t.style.paddingTop=0,t.style.paddingBottom=0},enter(t){t.dataset.oldOverflow=t.style.overflow,t.scrollHeight!==0?(t.style.maxHeight=`${t.scrollHeight}px`,t.style.paddingTop=t.dataset.oldPaddingTop,t.style.paddingBottom=t.dataset.oldPaddingBottom):(t.style.maxHeight=0,t.style.paddingTop=t.dataset.oldPaddingTop,t.style.paddingBottom=t.dataset.oldPaddingBottom),t.style.overflow="hidden"},afterEnter(t){t.style.maxHeight="",t.style.overflow=t.dataset.oldOverflow},beforeLeave(t){t.dataset||(t.dataset={}),t.dataset.oldPaddingTop=t.style.paddingTop,t.dataset.oldPaddingBottom=t.style.paddingBottom,t.dataset.oldOverflow=t.style.overflow,t.style.maxHeight=`${t.scrollHeight}px`,t.style.overflow="hidden"},leave(t){t.scrollHeight!==0&&(t.style.maxHeight=0,t.style.paddingTop=0,t.style.paddingBottom=0)},afterLeave(t){t.style.maxHeight="",t.style.overflow=t.dataset.oldOverflow,t.style.paddingTop=t.dataset.oldPaddingTop,t.style.paddingBottom=t.dataset.oldPaddingBottom}};return(t,u)=>(A(),me(xe,Ce({name:Oe(o).b()},Be(n)),{default:Z(()=>[P(t.$slots,"default")]),_:3},16,["name"]))}});var Y=ne(et,[["__file","/home/runner/work/element-plus/element-plus/packages/components/collapse-transition/src/collapse-transition.vue"]]);Y.install=e=>{e.component(Y.name,Y)};const tt=Y;let nt=class{constructor(o,n){this.parent=o,this.domNode=n,this.subIndex=0,this.subIndex=0,this.init()}init(){this.subMenuItems=this.domNode.querySelectorAll("li"),this.addListeners()}gotoSubIndex(o){o===this.subMenuItems.length?o=0:o<0&&(o=this.subMenuItems.length-1),this.subMenuItems[o].focus(),this.subIndex=o}addListeners(){const o=this.parent.domNode;Array.prototype.forEach.call(this.subMenuItems,n=>{n.addEventListener("keydown",t=>{let u=!1;switch(t.code){case S.down:{this.gotoSubIndex(this.subIndex+1),u=!0;break}case S.up:{this.gotoSubIndex(this.subIndex-1),u=!0;break}case S.tab:{Q(o,"mouseleave");break}case S.enter:case S.space:{u=!0,t.currentTarget.click();break}}return u&&(t.preventDefault(),t.stopPropagation()),!1})})}},ot=class{constructor(o,n){this.domNode=o,this.submenu=null,this.submenu=null,this.init(n)}init(o){this.domNode.setAttribute("tabindex","0");const n=this.domNode.querySelector(`.${o}-menu`);n&&(this.submenu=new nt(this,n)),this.addListeners()}addListeners(){this.domNode.addEventListener("keydown",o=>{let n=!1;switch(o.code){case S.down:{Q(o.currentTarget,"mouseenter"),this.submenu&&this.submenu.gotoSubIndex(0),n=!0;break}case S.up:{Q(o.currentTarget,"mouseenter"),this.submenu&&this.submenu.gotoSubIndex(this.submenu.subMenuItems.length-1),n=!0;break}case S.tab:{Q(o.currentTarget,"mouseleave");break}case S.enter:case S.space:{n=!0,o.currentTarget.click();break}}n&&o.preventDefault()})}},at=class{constructor(o,n){this.domNode=o,this.init(n)}init(o){const n=this.domNode.childNodes;Array.from(n).forEach(t=>{t.nodeType===1&&new ot(t,o)})}};const st=z({name:"ElMenuCollapseTransition",setup(){const e=w("menu");return{listeners:{onBeforeEnter:n=>n.style.opacity="0.2",onEnter(n,t){V(n,`${e.namespace.value}-opacity-transition`),n.style.opacity="1",t()},onAfterEnter(n){ue(n,`${e.namespace.value}-opacity-transition`),n.style.opacity=""},onBeforeLeave(n){n.dataset||(n.dataset={}),Ne(n,e.m("collapse"))?(ue(n,e.m("collapse")),n.dataset.oldOverflow=n.style.overflow,n.dataset.scrollWidth=n.clientWidth.toString(),V(n,e.m("collapse"))):(V(n,e.m("collapse")),n.dataset.oldOverflow=n.style.overflow,n.dataset.scrollWidth=n.clientWidth.toString(),ue(n,e.m("collapse"))),n.style.width=`${n.scrollWidth}px`,n.style.overflow="hidden"},onLeave(n){V(n,"horizontal-collapse-transition"),n.style.width=`${n.dataset.scrollWidth}px`}}}}});function lt(e,o,n,t,u,C){return A(),me(xe,Ce({mode:"out-in"},e.listeners),{default:Z(()=>[P(e.$slots,"default")]),_:3},16)}var ut=ne(st,[["render",lt],["__file","/home/runner/work/element-plus/element-plus/packages/components/menu/src/menu-collapse-transition.vue"]]);function Se(e,o){const n=p(()=>{let u=e.parent;const C=[o.value];for(;u.type.name!=="ElMenu";)u.props.index&&C.unshift(u.props.index),u=u.parent;return C});return{parentMenu:p(()=>{let u=e.parent;for(;u&&!["ElMenu","ElSubMenu"].includes(u.type.name);)u=u.parent;return u}),indexPath:n}}function rt(e){return p(()=>{const n=e.backgroundColor;return n?new Ye(n).shade(20).toString():""})}const we=(e,o)=>{const n=w("menu");return p(()=>n.cssVarBlock({"text-color":e.textColor||"","hover-text-color":e.textColor||"","bg-color":e.backgroundColor||"","hover-bg-color":rt(e).value||"","active-color":e.activeTextColor||"",level:`${o}`}))},it=ve({index:{type:String,required:!0},showTimeout:{type:Number,default:300},hideTimeout:{type:Number,default:300},popperClass:String,disabled:Boolean,popperAppendToBody:{type:Boolean,default:void 0},teleported:{type:Boolean,default:void 0},popperOffset:{type:Number,default:6},expandCloseIcon:{type:G},expandOpenIcon:{type:G},collapseCloseIcon:{type:G},collapseOpenIcon:{type:G}}),U="ElSubMenu";var ye=z({name:U,props:it,setup(e,{slots:o,expose:n}){Ze({from:"popper-append-to-body",replacement:"teleported",scope:U,version:"2.3.0",ref:"https://element-plus.org/en-US/component/menu.html#submenu-attributes"},p(()=>e.popperAppendToBody!==void 0));const t=fe(),{indexPath:u,parentMenu:C}=Se(t,p(()=>e.index)),d=w("menu"),h=w("sub-menu"),l=J("rootMenu");l||te(U,"can not inject root menu");const m=J(`subMenu:${C.value.uid}`);m||te(U,"can not inject sub menu");const v=x({}),M=x({});let I;const $=x(!1),oe=x(),q=x(null),B=p(()=>a.value==="horizontal"&&O.value?"bottom-start":"right-start"),L=p(()=>a.value==="horizontal"&&O.value||a.value==="vertical"&&!l.props.collapse?e.expandCloseIcon&&e.expandOpenIcon?T.value?e.expandOpenIcon:e.expandCloseIcon:Ae:e.collapseCloseIcon&&e.collapseOpenIcon?T.value?e.collapseOpenIcon:e.collapseCloseIcon:ze),O=p(()=>m.level===0),j=p(()=>{var i;const c=(i=e.teleported)!=null?i:e.popperAppendToBody;return c===void 0?O.value:c}),ae=p(()=>l.props.collapse?`${d.namespace.value}-zoom-in-left`:`${d.namespace.value}-zoom-in-top`),se=p(()=>a.value==="horizontal"&&O.value?["bottom-start","bottom-end","top-start","top-end","right-start","left-start"]:["right-start","left-start","bottom-start","bottom-end","top-start","top-end"]),T=p(()=>l.openedMenus.includes(e.index)),N=p(()=>{let i=!1;return Object.values(v.value).forEach(c=>{c.active&&(i=!0)}),Object.values(M.value).forEach(c=>{c.active&&(i=!0)}),i}),W=p(()=>l.props.backgroundColor||""),R=p(()=>l.props.activeTextColor||""),H=p(()=>l.props.textColor||""),a=p(()=>l.props.mode),s=he({index:e.index,indexPath:u,active:N}),r=p(()=>a.value!=="horizontal"?{color:H.value}:{borderBottomColor:N.value?l.props.activeTextColor?R.value:"":"transparent",color:N.value?R.value:H.value}),y=()=>{var i,c,f;return(f=(c=(i=q.value)==null?void 0:i.popperRef)==null?void 0:c.popperInstanceRef)==null?void 0:f.destroy()},b=i=>{i||y()},k=()=>{l.props.menuTrigger==="hover"&&l.props.mode==="horizontal"||l.props.collapse&&l.props.mode==="vertical"||e.disabled||l.handleSubMenuClick({index:e.index,indexPath:u.value,active:N.value})},E=(i,c=e.showTimeout)=>{var f;i.type!=="focus"&&(l.props.menuTrigger==="click"&&l.props.mode==="horizontal"||!l.props.collapse&&l.props.mode==="vertical"||e.disabled||(m.mouseInChild.value=!0,I==null||I(),{stop:I}=Ie(()=>{l.openMenu(e.index,u.value)},c),j.value&&((f=C.value.vnode.el)==null||f.dispatchEvent(new MouseEvent("mouseenter")))))},_=(i=!1)=>{var c,f;l.props.menuTrigger==="click"&&l.props.mode==="horizontal"||!l.props.collapse&&l.props.mode==="vertical"||(I==null||I(),m.mouseInChild.value=!1,{stop:I}=Ie(()=>!$.value&&l.closeMenu(e.index,u.value),e.hideTimeout),j.value&&i&&((c=t.parent)==null?void 0:c.type.name)==="ElSubMenu"&&((f=m.handleMouseleave)==null||f.call(m,!0)))};K(()=>l.props.collapse,i=>b(!!i));{const i=f=>{M.value[f.index]=f},c=f=>{delete M.value[f.index]};ce(`subMenu:${t.uid}`,{addSubMenu:i,removeSubMenu:c,handleMouseleave:_,mouseInChild:$,level:m.level+1})}return n({opened:T}),be(()=>{l.addSubMenu(s),m.addSubMenu(s)}),Te(()=>{m.removeSubMenu(s),l.removeSubMenu(s)}),()=>{var i;const c=[(i=o.title)==null?void 0:i.call(o),g(ke,{class:h.e("icon-arrow"),style:{transform:T.value?e.expandCloseIcon&&e.expandOpenIcon||e.collapseCloseIcon&&e.collapseOpenIcon&&l.props.collapse?"none":"rotateZ(180deg)":"none"}},{default:()=>D(L.value)?g(t.appContext.components[L.value]):g(L.value)})],f=we(l.props,m.level+1),Pe=l.isMenuPopup?g(Ee,{ref:q,visible:T.value,effect:"light",pure:!0,offset:e.popperOffset,showArrow:!1,persistent:!0,popperClass:e.popperClass,placement:B.value,teleported:j.value,fallbackPlacements:se.value,transition:ae.value,gpuAcceleration:!1},{content:()=>{var F;return g("div",{class:[d.m(a.value),d.m("popup-container"),e.popperClass],onMouseenter:le=>E(le,100),onMouseleave:()=>_(!0),onFocus:le=>E(le,100)},[g("ul",{class:[d.b(),d.m("popup"),d.m(`popup-${B.value}`)],style:f.value},[(F=o.default)==null?void 0:F.call(o)])])},default:()=>g("div",{class:h.e("title"),style:[r.value,{backgroundColor:W.value}],onClick:k},c)}):g(ge,{},[g("div",{class:h.e("title"),style:[r.value,{backgroundColor:W.value}],ref:oe,onClick:k},c),g(tt,{},{default:()=>{var F;return Le(g("ul",{role:"menu",class:[d.b(),d.m("inline")],style:f.value},[(F=o.default)==null?void 0:F.call(o)]),[[He,T.value]])}})]);return g("li",{class:[h.b(),h.is("active",N.value),h.is("opened",T.value),h.is("disabled",e.disabled)],role:"menuitem",ariaHaspopup:!0,ariaExpanded:T.value,onMouseenter:E,onMouseleave:()=>_(!0),onFocus:E},[Pe])}}});const ct=ve({mode:{type:String,values:["horizontal","vertical"],default:"vertical"},defaultActive:{type:String,default:""},defaultOpeneds:{type:de(Array),default:()=>De([])},uniqueOpened:Boolean,router:Boolean,menuTrigger:{type:String,values:["hover","click"],default:"hover"},collapse:Boolean,backgroundColor:String,textColor:String,activeTextColor:String,collapseTransition:{type:Boolean,default:!0},ellipsis:{type:Boolean,default:!0},popperEffect:{type:String,values:["dark","light"],default:"dark"}}),re=e=>Array.isArray(e)&&e.every(o=>D(o)),dt={close:(e,o)=>D(e)&&re(o),open:(e,o)=>D(e)&&re(o),select:(e,o,n,t)=>D(e)&&re(o)&&Fe(n)&&(t===void 0||t instanceof Promise)};var pt=z({name:"ElMenu",props:ct,emits:dt,setup(e,{emit:o,slots:n,expose:t}){const u=fe(),C=u.appContext.config.globalProperties.$router,d=x(),h=w("menu"),l=w("sub-menu"),m=x(-1),v=x(e.defaultOpeneds&&!e.collapse?e.defaultOpeneds.slice(0):[]),M=x(e.defaultActive),I=x({}),$=x({}),oe=p(()=>e.mode==="horizontal"||e.mode==="vertical"&&e.collapse),q=()=>{const a=M.value&&I.value[M.value];if(!a||e.mode==="horizontal"||e.collapse)return;a.indexPath.forEach(r=>{const y=$.value[r];y&&B(r,y.indexPath)})},B=(a,s)=>{v.value.includes(a)||(e.uniqueOpened&&(v.value=v.value.filter(r=>s.includes(r))),v.value.push(a),o("open",a,s))},L=a=>{const s=v.value.indexOf(a);s!==-1&&v.value.splice(s,1)},O=(a,s)=>{L(a),o("close",a,s)},j=({index:a,indexPath:s})=>{v.value.includes(a)?O(a,s):B(a,s)},ae=a=>{(e.mode==="horizontal"||e.collapse)&&(v.value=[]);const{index:s,indexPath:r}=a;if(!(s===void 0||r===void 0))if(e.router&&C){const y=a.route||s,b=C.push(y).then(k=>(k||(M.value=s),k));o("select",s,r,{index:s,indexPath:r,route:y},b)}else M.value=s,o("select",s,r,{index:s,indexPath:r})},se=a=>{const s=I.value,r=s[a]||M.value&&s[M.value]||s[e.defaultActive];r?M.value=r.index:M.value=a},T=()=>{var a,s;if(!d.value)return-1;const r=Array.from((s=(a=d.value)==null?void 0:a.childNodes)!=null?s:[]).filter(c=>c.nodeName!=="#text"||c.nodeValue),y=64,b=Number.parseInt(getComputedStyle(d.value).paddingLeft,10),k=Number.parseInt(getComputedStyle(d.value).paddingRight,10),E=d.value.clientWidth-b-k;let _=0,i=0;return r.forEach((c,f)=>{_+=c.offsetWidth||0,_<=E-y&&(i=f+1)}),i===r.length?-1:i},N=(a,s=33.34)=>{let r;return()=>{r&&clearTimeout(r),r=setTimeout(()=>{a()},s)}};let W=!0;const R=()=>{const a=()=>{m.value=-1,qe(()=>{m.value=T()})};W?a():N(a)(),W=!1};K(()=>e.defaultActive,a=>{I.value[a]||(M.value=""),se(a)}),K(()=>e.collapse,a=>{a&&(v.value=[])}),K(I.value,q);let H;je(()=>{e.mode==="horizontal"&&e.ellipsis?H=We(d,R).stop:H==null||H()});{const a=b=>{$.value[b.index]=b},s=b=>{delete $.value[b.index]};ce("rootMenu",he({props:e,openedMenus:v,items:I,subMenus:$,activeIndex:M,isMenuPopup:oe,addMenuItem:b=>{I.value[b.index]=b},removeMenuItem:b=>{delete I.value[b.index]},addSubMenu:a,removeSubMenu:s,openMenu:B,closeMenu:O,handleMenuItemClick:ae,handleSubMenuClick:j})),ce(`subMenu:${u.uid}`,{addSubMenu:a,removeSubMenu:s,mouseInChild:x(!1),level:0})}return be(()=>{e.mode==="horizontal"&&new at(u.vnode.el,h.namespace.value)}),t({open:s=>{const{indexPath:r}=$.value[s];r.forEach(y=>B(y,r))},close:L,handleResize:R}),()=>{var a,s;let r=(s=(a=n.default)==null?void 0:a.call(n))!=null?s:[];const y=[];if(e.mode==="horizontal"&&d.value){const E=Je(r),_=m.value===-1?E:E.slice(0,m.value),i=m.value===-1?[]:E.slice(m.value);i!=null&&i.length&&e.ellipsis&&(r=_,y.push(g(ye,{index:"sub-menu-more",class:l.e("hide-arrow")},{title:()=>g(ke,{class:l.e("icon-more")},{default:()=>g(Re)}),default:()=>i})))}const b=we(e,0),k=g("ul",{key:String(e.collapse),role:"menubar",ref:d,style:b.value,class:{[h.b()]:!0,[h.m(e.mode)]:!0,[h.m("collapse")]:e.collapse}},[...r,...y]);return e.collapseTransition&&e.mode==="vertical"?g(ut,()=>k):k}}});const mt=ve({index:{type:de([String,null]),default:null},route:{type:de([String,Object])},disabled:Boolean}),vt={click:e=>D(e.index)&&Array.isArray(e.indexPath)},ie="ElMenuItem",ft=z({name:ie,components:{ElTooltip:Ee},props:mt,emits:vt,setup(e,{emit:o}){const n=fe(),t=J("rootMenu"),u=w("menu"),C=w("menu-item");t||te(ie,"can not inject root menu");const{parentMenu:d,indexPath:h}=Se(n,Ve(e,"index")),l=J(`subMenu:${d.value.uid}`);l||te(ie,"can not inject sub menu");const m=p(()=>e.index===t.activeIndex),v=he({index:e.index,indexPath:h,active:m}),M=()=>{e.disabled||(t.handleMenuItemClick({index:e.index,indexPath:h.value,route:e.route}),o("click",v))};return be(()=>{l.addSubMenu(v),t.addMenuItem(v)}),Te(()=>{l.removeSubMenu(v),t.removeMenuItem(v)}),{parentMenu:d,rootMenu:t,active:m,nsMenu:u,nsMenuItem:C,handleClick:M}}});function ht(e,o,n,t,u,C){const d=Ge("el-tooltip");return A(),X("li",{class:ee([e.nsMenuItem.b(),e.nsMenuItem.is("active",e.active),e.nsMenuItem.is("disabled",e.disabled)]),role:"menuitem",tabindex:"-1",onClick:o[0]||(o[0]=(...h)=>e.handleClick&&e.handleClick(...h))},[e.parentMenu.type.name==="ElMenu"&&e.rootMenu.props.collapse&&e.$slots.title?(A(),me(d,{key:0,effect:e.rootMenu.props.popperEffect,placement:"right","fallback-placements":["left"],persistent:""},{content:Z(()=>[P(e.$slots,"title")]),default:Z(()=>[pe("div",{class:ee(e.nsMenu.be("tooltip","trigger"))},[P(e.$slots,"default")],2)]),_:3},8,["effect"])):(A(),X(ge,{key:1},[P(e.$slots,"default"),P(e.$slots,"title")],64))],2)}var $e=ne(ft,[["render",ht],["__file","/home/runner/work/element-plus/element-plus/packages/components/menu/src/menu-item.vue"]]);const bt={title:String},gt="ElMenuItemGroup",Mt=z({name:gt,props:bt,setup(){return{ns:w("menu-item-group")}}});function yt(e,o,n,t,u,C){return A(),X("li",{class:ee(e.ns.b())},[pe("div",{class:ee(e.ns.e("title"))},[e.$slots.title?P(e.$slots,"title",{key:1}):(A(),X(ge,{key:0},[Ue(Ke(e.title),1)],64))],2),pe("ul",null,[P(e.$slots,"default")])],2)}var _e=ne(Mt,[["render",yt],["__file","/home/runner/work/element-plus/element-plus/packages/components/menu/src/menu-item-group.vue"]]);const wt=Qe(pt,{MenuItem:$e,MenuItemGroup:_e,SubMenu:ye}),$t=Me($e);Me(_e);Me(ye);export{$t as E,wt as a};