import{q as E,f as y,g,l as D,V as h}from"./7nzMR1a0.js";import{f as C}from"./D_qxKlPu.js";import{au as x,cv as R,cD as I,cn as M,aO as O,bt as T,bv as S,cP as L,cw as K,a3 as w,bi as b,aD as U,as as q,O as F,c3 as B,bO as H,bZ as N,bI as j,bq as z,ar as v,bJ as J,q as Z,aP as $}from"#entry";const G=j({id:String,submenu:Boolean,...z(D({captureFocus:!0,closeDelay:250,closeOnContentClick:!0,locationStrategy:"connected",location:void 0,openDelay:300,scrim:!1,scrollStrategy:"reposition",transition:{component:h}}),["absolute"])},"VMenu"),Y=x()({name:"VMenu",props:G(),emits:{"update:modelValue":t=>!0},setup(t,p){let{slots:d}=p;const a=R(t,"modelValue"),{scopeId:P}=E(),{isRtl:s}=I(),f=M(),l=B(()=>t.id||`v-menu-${f}`),o=H(),r=O(y,null),u=N(new Set);J(y,{register(){u.value.add(f)},unregister(){u.value.delete(f)},closeParents(e){setTimeout(()=>{!u.value.size&&!t.persistent&&(e==null||o.value?.contentEl&&!$(e,o.value.contentEl))&&(a.value=!1,r?.closeParents())},40)}}),T(()=>r?.unregister()),S(()=>a.value=!1),L(a,e=>{e?r?.register():r?.unregister()},{immediate:!0});function V(e){r?.closeParents(e)}function A(e){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(),!U(q(o.value?.contentEl,!1),e.shiftKey?"prev":"next",i=>i.tabIndex>=0)&&!t.retainFocus&&(a.value=!1,o.value?.activatorEl?.focus())}else t.submenu&&e.key===(s.value?"ArrowRight":"ArrowLeft")&&(a.value=!1,o.value?.activatorEl?.focus())}function m(e){if(t.disabled)return;const n=o.value?.contentEl;n&&a.value?e.key==="ArrowDown"?(e.preventDefault(),e.stopImmediatePropagation(),v(n,"next")):e.key==="ArrowUp"?(e.preventDefault(),e.stopImmediatePropagation(),v(n,"prev")):t.submenu&&(e.key===(s.value?"ArrowRight":"ArrowLeft")?a.value=!1:e.key===(s.value?"ArrowLeft":"ArrowRight")&&(e.preventDefault(),v(n,"first"))):(t.submenu?e.key===(s.value?"ArrowLeft":"ArrowRight"):["ArrowDown","ArrowUp"].includes(e.key))&&(a.value=!0,e.preventDefault(),setTimeout(()=>setTimeout(()=>m(e))))}const k=F(()=>b({"aria-haspopup":"menu","aria-expanded":String(a.value),"aria-controls":l.value,"aria-owns":l.value,onKeydown:m},t.activatorProps));return K(()=>{const e=g.filterProps(t);return w(g,b({ref:o,id:l.value,class:["v-menu",t.class],style:t.style},e,{modelValue:a.value,"onUpdate:modelValue":n=>a.value=n,absolute:!0,activatorProps:k.value,location:t.location??(t.submenu?"end":"bottom"),"onClick:outside":V,onKeydown:A},P),{activator:d.activator,default:function(){for(var n=arguments.length,i=new Array(n),c=0;c<n;c++)i[c]=arguments[c];return w(Z,{root:"VMenu"},{default:()=>[d.default?.(...i)]})}})}),C({id:l,ΨopenChildren:u},o)}});export{Y as V};
