import{functionType as e}from"../../../_util/type.mjs";import t from"../../../_util/classNames.mjs";import n from"../../../_util/vue-types/index.mjs";import r from"../../../_util/KeyCode.mjs";import i from"../../../_util/hooks/useState.mjs";import a from"../../../menu/src/MenuItem.mjs";import{useProvideOverride as o}from"../../../menu/src/OverrideContext.mjs";import s from"../../../menu/index.mjs";import c from"../../../vc-dropdown/index.mjs";import l from"./AddButton.mjs";import{computed as u,createVNode as d,defineComponent as f,onMounted as p,watch as m}from"vue";import{EllipsisOutlined as h}from"@antsoo-lib/icons";var g={prefixCls:{type:String},id:{type:String},tabs:{type:Object},rtl:{type:Boolean},tabBarGutter:{type:Number},activeKey:{type:[String,Number]},mobile:{type:Boolean},moreIcon:n.any,moreTransitionName:{type:String},editable:{type:Object},locale:{type:Object,default:void 0},removeAriaLabel:String,onTabClick:{type:Function},popupClassName:String,getPopupContainer:e()},_=f({compatConfig:{MODE:3},name:`OperationNode`,inheritAttrs:!1,props:g,emits:[`tabClick`],slots:Object,setup(e,{attrs:n,slots:f}){let[g,_]=i(!1),[v,y]=i(null),b=t=>{let n=e.tabs.filter(e=>!e.disabled),r=n.findIndex(e=>e.key===v.value)||0,i=n.length;for(let e=0;e<i;e+=1){r=(r+t+i)%i;let e=n[r];if(!e.disabled){y(e.key);return}}},x=t=>{let{which:n}=t;if(!g.value){[r.DOWN,r.SPACE,r.ENTER].includes(n)&&(_(!0),t.preventDefault());return}switch(n){case r.UP:b(-1),t.preventDefault();break;case r.DOWN:b(1),t.preventDefault();break;case r.ESC:_(!1);break;case r.SPACE:case r.ENTER:v.value!==null&&e.onTabClick(v.value,t);break}},S=u(()=>`${e.id}-more-popup`),C=u(()=>v.value===null?null:`${S.value}-${v.value}`),w=(t,n)=>{t.preventDefault(),t.stopPropagation(),e.editable.onEdit(`remove`,{key:n,event:t})};return p(()=>{m(v,()=>{let e=document.getElementById(C.value);e&&e.scrollIntoView&&e.scrollIntoView(!1)},{flush:`post`,immediate:!0})}),m(g,()=>{g.value||y(null)}),o({}),()=>{let{prefixCls:r,id:i,tabs:o,locale:u,mobile:p,moreIcon:m=f.moreIcon?.()||d(h,null,null),moreTransitionName:y,editable:b,tabBarGutter:T,rtl:E,onTabClick:D,popupClassName:O}=e;if(!o.length)return null;let k=`${r}-dropdown`,A=u?.dropdownAriaLabel,j={[E?`marginRight`:`marginLeft`]:T};o.length||(j.visibility=`hidden`,j.order=1);let M=t({[`${k}-rtl`]:E,[`${O}`]:!0}),N=p?null:d(c,{prefixCls:k,trigger:[`hover`],visible:g.value,transitionName:y,onVisibleChange:_,overlayClassName:M,mouseEnterDelay:.1,mouseLeaveDelay:.1,getPopupContainer:e.getPopupContainer},{overlay:()=>d(s,{onClick:({key:e,domEvent:t})=>{D(e,t),_(!1)},id:S.value,tabindex:-1,role:`listbox`,"aria-activedescendant":C.value,selectedKeys:[v.value],"aria-label":A===void 0?`expanded dropdown`:A},{default:()=>[o.map(t=>{let n=b&&t.closable!==!1&&!t.disabled;return d(a,{key:t.key,id:`${S.value}-${t.key}`,role:`option`,"aria-controls":i&&`${i}-panel-${t.key}`,disabled:t.disabled},{default:()=>[d(`span`,null,[typeof t.tab==`function`?t.tab():t.tab]),n&&d(`button`,{type:`button`,"aria-label":e.removeAriaLabel||`remove`,tabindex:0,class:`${k}-menu-item-remove`,onClick:e=>{e.stopPropagation(),w(e,t.key)}},[t.closeIcon?.()||b.removeIcon?.()||`×`])]})})]}),default:()=>d(`button`,{type:`button`,class:`${r}-nav-more`,style:j,tabindex:-1,"aria-hidden":`true`,"aria-haspopup":`listbox`,"aria-controls":S.value,id:`${i}-more`,"aria-expanded":g.value,onKeydown:x},[m])});return d(`div`,{class:t(`${r}-nav-operations`,n.class),style:n.style},[N,d(l,{prefixCls:r,locale:u,editable:b},null)])}}});export{_ as default,g as operationNodeProps};