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