import{d as E,r as y,j as g,k as h,l as C}from"./DCT0cttX.js";import{f as D}from"./D_qxKlPu.js";import{g as R,k as x,aP as M,c3 as I,j as T,b7 as S,cj as L,af as K,a as O,b as w,l as p,cP as U,bU as j,i as F,aH as H,a4 as B,aC as N,p as z,o as Q,cr as d,aR as $,d as q,cQ as G}from"#entry";const J=z({id:String,submenu:Boolean,...Q(h({captureFocus:!0,closeDelay:250,closeOnContentClick:!0,locationStrategy:"connected",location:void 0,openDelay:300,scrim:!1,scrollStrategy:"reposition",transition:{component:C}}),["absolute"])},"VMenu"),Z=R()({name:"VMenu",props:J(),emits:{"update:modelValue":t=>!0},setup(t,b){let{slots:v}=b;const a=x(t,"modelValue"),{scopeId:k}=E(),{isRtl:s}=M(),f=I(),l=H(()=>t.id||`v-menu-${f}`),o=B(),r=T(y,null),u=N(new Set);$(y,{register(){u.value.add(f)},unregister(){u.value.delete(f)},closeParents(e){setTimeout(()=>{!u.value.size&&!t.persistent&&(e==null||o.value?.contentEl&&!G(e,o.value.contentEl))&&(a.value=!1,r?.closeParents())},40)}}),S(()=>r?.unregister()),L(()=>a.value=!1),K(a,e=>{e?r?.register():r?.unregister()},{immediate:!0});function P(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(j(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(),d(n,"next")):e.key==="ArrowUp"?(e.preventDefault(),e.stopImmediatePropagation(),d(n,"prev")):t.submenu&&(e.key===(s.value?"ArrowRight":"ArrowLeft")?a.value=!1:e.key===(s.value?"ArrowLeft":"ArrowRight")&&(e.preventDefault(),d(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 V=F(()=>p({"aria-haspopup":"menu","aria-expanded":String(a.value),"aria-controls":l.value,"aria-owns":l.value,onKeydown:m},t.activatorProps));return O(()=>{const e=g.filterProps(t);return w(g,p({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:V.value,location:t.location??(t.submenu?"end":"bottom"),"onClick:outside":P,onKeydown:A},k),{activator:v.activator,default:function(){for(var n=arguments.length,i=new Array(n),c=0;c<n;c++)i[c]=arguments[c];return w(q,{root:"VMenu"},{default:()=>[v.default?.(...i)]})}})}),D({id:l,ΨopenChildren:u},o)}});export{Z as V};
