import{ad as I,ae as M,al as L,am as S,an as O,ao as K,r as B,ap as U,aq as z,ar as F,as as H,at as N,au as E,M as j,z as q,D as b,af as G,av as W,aw as $,ax as J,ay as Q,az as X,aA as A,aB as k,i as V,aC as Y,aD as g,aE as Z,aF as P,aG as _,aH as ee}from"./index-CChjpdNU.js";const te=M({id:String,submenu:Boolean,...$(J({closeDelay:250,closeOnContentClick:!0,locationStrategy:"connected",location:void 0,openDelay:300,scrim:!1,scrollStrategy:"reposition",transition:{component:Q}}),["absolute"])},"VMenu"),ne=I()({name:"VMenu",props:te(),emits:{"update:modelValue":a=>!0},setup(a,D){let{slots:c}=D;const s=L(a,"modelValue"),{scopeId:h}=S(),{isRtl:f}=O(),d=X(),m=K(()=>a.id||`v-menu-${d}`),o=B(),n=F(A,null),v=U(new Set);_(A,{register(){v.value.add(d)},unregister(){v.value.delete(d)},closeParents(e){setTimeout(()=>{var t;!v.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)}}),z(()=>{n==null||n.unregister(),document.removeEventListener("focusin",y)}),H(()=>s.value=!1);async function y(e){var u,r,i;const t=e.relatedTarget,l=e.target;await N(),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())}j(s,e=>{e?(n==null||n.register(),P&&document.addEventListener("focusin",y,{once:!0})):(n==null||n.unregister(),P&&document.removeEventListener("focusin",y))},{immediate:!0});function C(e){n==null||n.closeParents(e)}function x(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(),Z(E((t=o.value)==null?void 0:t.contentEl,!1),e.shiftKey?"prev":"next",T=>T.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 w(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(()=>w(e))))}const R=q(()=>b({"aria-haspopup":"menu","aria-expanded":String(s.value),"aria-controls":m.value,onKeydown:w},a.activatorProps));return G(()=>{const e=k.filterProps(a);return V(k,b({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:R.value,location:a.location??(a.submenu?"end":"bottom"),"onClick:outside":C,onKeydown:x},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 V(Y,{root:"VMenu"},{default:()=>{var r;return[(r=c.default)==null?void 0:r.call(c,...l)]}})}})}),W({id:m,ΨopenChildren:v},o)}});export{ne as V};