import{g as I,p as M,a6 as L,a_ as S,ak as O,aJ as K,t as U,r as B,aU as N,bW as w,s as j,bi as F,bX as H,ad as W,bY as E,a8 as X,bC as k,f as $,X as A,j as z,aC as V,k as P,a3 as J,aM as Y,a9 as Z,b4 as q,bI as G,bZ as g,b_ as Q,aT as _,b$ as ee}from"./index-DHJ8t5vF.js";const te=M({id:String,submenu:Boolean,...Z(q({closeDelay:250,closeOnContentClick:!0,locationStrategy:"connected",location:void 0,openDelay:300,scrim:!1,scrollStrategy:"reposition",transition:{component:G}}),["absolute"])},"VMenu"),ne=I()({name:"VMenu",props:te(),emits:{"update:modelValue":a=>!0},setup(a,C){let{slots:c}=C;const s=L(a,"modelValue"),{scopeId:h}=S(),{isRtl:f}=O(),v=K(),m=U(()=>a.id||`v-menu-${v}`),o=B(),n=N(w,null),d=j(new Set);_(w,{register(){d.value.add(v)},unregister(){d.value.delete(v)},closeParents(e){setTimeout(()=>{var t;!d.value.size&&!a.persistent&&(e==null||(t=o.value)!=null&&t.contentEl&&!ee(e,o.value.contentEl))&&(s.value=!1,n==null||n.closeParents())},40)}}),F(()=>{n==null||n.unregister(),document.removeEventListener("focusin",b)}),H(()=>s.value=!1);async function b(e){var u,r,i;const t=e.relatedTarget,l=e.target;await W(),s.value&&t!==l&&((u=o.value)!=null&&u.contentEl)&&((r=o.value)!=null&&r.globalTop)&&![document,o.value.contentEl].includes(l)&&!o.value.contentEl.contains(l)&&((i=E(o.value.contentEl)[0])==null||i.focus())}X(s,e=>{e?(n==null||n.register(),k&&document.addEventListener("focusin",b,{once:!0})):(n==null||n.unregister(),k&&document.removeEventListener("focusin",b))},{immediate:!0});function D(e){n==null||n.closeParents(e)}function R(e){var t,l,u,r,i;if(!a.disabled)if(e.key==="Tab"||e.key==="Enter"&&!a.closeOnContentClick){if(e.key==="Enter"&&(e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLInputElement&&e.target.closest("form")))return;e.key==="Enter"&&e.preventDefault(),Q(E((t=o.value)==null?void 0:t.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 a.submenu&&e.key===(f.value?"ArrowRight":"ArrowLeft")&&(s.value=!1,(i=(r=o.value)==null?void 0:r.activatorEl)==null||i.focus())}function y(e){var l;if(a.disabled)return;const t=(l=o.value)==null?void 0:l.contentEl;t&&s.value?e.key==="ArrowDown"?(e.preventDefault(),e.stopImmediatePropagation(),g(t,"next")):e.key==="ArrowUp"?(e.preventDefault(),e.stopImmediatePropagation(),g(t,"prev")):a.submenu&&(e.key===(f.value?"ArrowRight":"ArrowLeft")?s.value=!1:e.key===(f.value?"ArrowLeft":"ArrowRight")&&(e.preventDefault(),g(t,"first"))):(a.submenu?e.key===(f.value?"ArrowLeft":"ArrowRight"):["ArrowDown","ArrowUp"].includes(e.key))&&(s.value=!0,e.preventDefault(),setTimeout(()=>setTimeout(()=>y(e))))}const T=$(()=>A({"aria-haspopup":"menu","aria-expanded":String(s.value),"aria-controls":m.value,onKeydown:y},a.activatorProps));return z(()=>{const e=V.filterProps(a);return P(V,A({ref:o,id:m.value,class:["v-menu",a.class],style:a.style},e,{modelValue:s.value,"onUpdate:modelValue":t=>s.value=t,absolute:!0,activatorProps:T.value,location:a.location??(a.submenu?"end":"bottom"),"onClick:outside":D,onKeydown:R},h),{activator:c.activator,default:function(){for(var t=arguments.length,l=new Array(t),u=0;u<t;u++)l[u]=arguments[u];return P(J,{root:"VMenu"},{default:()=>{var r;return[(r=c.default)==null?void 0:r.call(c,...l)]}})}})}),Y({id:m,ΨopenChildren:d},o)}});export{ne as V};
