import{g as x,p as M,a3 as R,aG as p,b8 as I,aN as S,ay as T,$ as L,bH as K,cf as w,a0 as O,aS as U,cg as F,a6 as H,a5 as N,E as b,c as j,au as k,d as A,ac as B,ad as $,ae as z,bb as G,cb as q,ch as m,ci as J,cj as Q,bM as W,ck as X}from"./index-BBhBboPS.js";const Y=M({id:String,submenu:Boolean,...z(G({captureFocus:!0,closeDelay:250,closeOnContentClick:!0,locationStrategy:"connected",location:void 0,openDelay:300,scrim:!1,scrollStrategy:"reposition",transition:{component:q}}),["absolute"])},"VMenu"),ee=x()({name:"VMenu",props:Y(),emits:{"update:modelValue":t=>!0},setup(t,E){let{slots:i}=E;const o=R(t,"modelValue"),{scopeId:V}=p(),{isRtl:c}=I(),v=S(),f=T(()=>t.id||`v-menu-${v}`),s=L(),a=K(w,null),d=O(new Set);W(w,{register(){d.value.add(v)},unregister(){d.value.delete(v)},closeParents(e){setTimeout(()=>{var n;!d.value.size&&!t.persistent&&(e==null||(n=s.value)!=null&&n.contentEl&&!X(e,s.value.contentEl))&&(o.value=!1,a==null||a.closeParents())},40)}}),U(()=>a==null?void 0:a.unregister()),F(()=>o.value=!1),H(o,e=>{e?a==null||a.register():a==null||a.unregister()},{immediate:!0});function P(e){a==null||a.closeParents(e)}function h(e){var n,l,r,u,g;if(!t.disabled)if(e.key==="Tab"||e.key==="Enter"&&!t.closeOnContentClick){if(e.key==="Enter"&&(e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLInputElement&&e.target.closest("form")))return;e.key==="Enter"&&e.preventDefault(),!J(Q((n=s.value)==null?void 0:n.contentEl,!1),e.shiftKey?"prev":"next",D=>D.tabIndex>=0)&&!t.retainFocus&&(o.value=!1,(r=(l=s.value)==null?void 0:l.activatorEl)==null||r.focus())}else t.submenu&&e.key===(c.value?"ArrowRight":"ArrowLeft")&&(o.value=!1,(g=(u=s.value)==null?void 0:u.activatorEl)==null||g.focus())}function y(e){var l;if(t.disabled)return;const n=(l=s.value)==null?void 0:l.contentEl;n&&o.value?e.key==="ArrowDown"?(e.preventDefault(),e.stopImmediatePropagation(),m(n,"next")):e.key==="ArrowUp"?(e.preventDefault(),e.stopImmediatePropagation(),m(n,"prev")):t.submenu&&(e.key===(c.value?"ArrowRight":"ArrowLeft")?o.value=!1:e.key===(c.value?"ArrowLeft":"ArrowRight")&&(e.preventDefault(),m(n,"first"))):(t.submenu?e.key===(c.value?"ArrowLeft":"ArrowRight"):["ArrowDown","ArrowUp"].includes(e.key))&&(o.value=!0,e.preventDefault(),setTimeout(()=>setTimeout(()=>y(e))))}const C=N(()=>b({"aria-haspopup":"menu","aria-expanded":String(o.value),"aria-controls":f.value,"aria-owns":f.value,onKeydown:y},t.activatorProps));return j(()=>{const e=k.filterProps(t);return A(k,b({ref:s,id:f.value,class:["v-menu",t.class],style:t.style},e,{modelValue:o.value,"onUpdate:modelValue":n=>o.value=n,absolute:!0,activatorProps:C.value,location:t.location??(t.submenu?"end":"bottom"),"onClick:outside":P,onKeydown:h},V),{activator:i.activator,default:function(){for(var n=arguments.length,l=new Array(n),r=0;r<n;r++)l[r]=arguments[r];return A(B,{root:"VMenu"},{default:()=>{var u;return[(u=i.default)==null?void 0:u.call(i,...l)]}})}})}),$({id:f,ΨopenChildren:d},s)}});export{ee as V};
