import{g as p,p as M,aj as L,aA as S,b3 as O,aG as K,ao as B,an as F,bv as U,c5 as w,ap as N,bi as j,c6 as H,at as q,c7 as E,aq as z,bM as A,al as G,E as k,c as Q,a4 as V,d as P,aQ as W,as as $,av as J,b5 as X,bT as Y,c8 as b,c9 as Z,bA as _,ca as ee}from"./index-GaWRVcb2.js";const te=M({id:String,submenu:Boolean,disableInitialFocus:Boolean,...J(X({closeDelay:250,closeOnContentClick:!0,locationStrategy:"connected",location:void 0,openDelay:300,scrim:!1,scrollStrategy:"reposition",transition:{component:Y}}),["absolute"])},"VMenu"),ne=p()({name:"VMenu",props:te(),emits:{"update:modelValue":t=>!0},setup(t,h){let{slots:c}=h;const s=L(t,"modelValue"),{scopeId:C}=S(),{isRtl:f}=O(),v=K(),m=B(()=>t.id||`v-menu-${v}`),o=F(),n=U(w,null),d=N(new Set);_(w,{register(){d.value.add(v)},unregister(){d.value.delete(v)},closeParents(e){setTimeout(()=>{var a;!d.value.size&&!t.persistent&&(e==null||(a=o.value)!=null&&a.contentEl&&!ee(e,o.value.contentEl))&&(s.value=!1,n==null||n.closeParents())},40)}}),j(()=>{n==null||n.unregister(),document.removeEventListener("focusin",g)}),H(()=>s.value=!1);async function g(e){var u,i,r;const a=e.relatedTarget,l=e.target;await q(),s.value&&a!==l&&((u=o.value)!=null&&u.contentEl)&&((i=o.value)!=null&&i.globalTop)&&![document,o.value.contentEl].includes(l)&&!o.value.contentEl.contains(l)&&((r=E(o.value.contentEl)[0])==null||r.focus())}z(s,e=>{e?(n==null||n.register(),A&&!t.disableInitialFocus&&document.addEventListener("focusin",g,{once:!0})):(n==null||n.unregister(),A&&document.removeEventListener("focusin",g))},{immediate:!0});function D(e){n==null||n.closeParents(e)}function I(e){var a,l,u,i,r;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(),Z(E((a=o.value)==null?void 0:a.contentEl,!1),e.shiftKey?"prev":"next",x=>x.tabIndex>=0)||(s.value=!1,(u=(l=o.value)==null?void 0:l.activatorEl)==null||u.focus())}else t.submenu&&e.key===(f.value?"ArrowRight":"ArrowLeft")&&(s.value=!1,(r=(i=o.value)==null?void 0:i.activatorEl)==null||r.focus())}function y(e){var l;if(t.disabled)return;const a=(l=o.value)==null?void 0:l.contentEl;a&&s.value?e.key==="ArrowDown"?(e.preventDefault(),e.stopImmediatePropagation(),b(a,"next")):e.key==="ArrowUp"?(e.preventDefault(),e.stopImmediatePropagation(),b(a,"prev")):t.submenu&&(e.key===(f.value?"ArrowRight":"ArrowLeft")?s.value=!1:e.key===(f.value?"ArrowLeft":"ArrowRight")&&(e.preventDefault(),b(a,"first"))):(t.submenu?e.key===(f.value?"ArrowLeft":"ArrowRight"):["ArrowDown","ArrowUp"].includes(e.key))&&(s.value=!0,e.preventDefault(),setTimeout(()=>setTimeout(()=>y(e))))}const R=G(()=>k({"aria-haspopup":"menu","aria-expanded":String(s.value),"aria-controls":m.value,onKeydown:y},t.activatorProps));return Q(()=>{const e=V.filterProps(t);return P(V,k({ref:o,id:m.value,class:["v-menu",t.class],style:t.style},e,{modelValue:s.value,"onUpdate:modelValue":a=>s.value=a,absolute:!0,activatorProps:R.value,location:t.location??(t.submenu?"end":"bottom"),"onClick:outside":D,onKeydown:I},C),{activator:c.activator,default:function(){for(var a=arguments.length,l=new Array(a),u=0;u<a;u++)l[u]=arguments[u];return P(W,{root:"VMenu"},{default:()=>{var i;return[(i=c.default)==null?void 0:i.call(c,...l)]}})}})}),$({id:m,ΨopenChildren:d},o)}});export{ne as V};
