import{m as b,k as y,a as D,f}from"./VMenu-b634019c.js";import{i as h,j as S,F as w}from"./forwardRefs-7be90dc2.js";import{p as x,g as F,h as B,r as I,aX as R,w as v,q as T,c as k,n as m,l as g,aY as L}from"./index-b687f95a.js";const O=x({fullscreen:Boolean,retainFocus:{type:Boolean,default:!0},scrollable:Boolean,...b({origin:"center center",scrollStrategy:"block",transition:{component:y},zIndex:2400})},"VDialog"),j=F()({name:"VDialog",props:O(),emits:{"click:outside":e=>!0,"update:modelValue":e=>!0,afterLeave:()=>!0},setup(e,p){let{slots:c}=p;const n=B(e,"modelValue"),{scopeId:V}=D(),t=I();function i(l){var r,s;const a=l.relatedTarget,o=l.target;if(a!==o&&((r=t.value)!=null&&r.contentEl)&&((s=t.value)!=null&&s.globalTop)&&![document,t.value.contentEl].includes(o)&&!t.value.contentEl.contains(o)){const u=L(t.value.contentEl);if(!u.length)return;const d=u[0],P=u[u.length-1];a===d?P.focus():d.focus()}}R&&v(()=>n.value&&e.retainFocus,l=>{l?document.addEventListener("focusin",i):document.removeEventListener("focusin",i)},{immediate:!0}),v(n,async l=>{var a,o;await T(),l?(a=t.value.contentEl)==null||a.focus({preventScroll:!0}):(o=t.value.activatorEl)==null||o.focus({preventScroll:!0})});const E=k(()=>m({"aria-haspopup":"dialog","aria-expanded":String(n.value)},e.activatorProps));return h(()=>{const l=f.filterProps(e);return g(f,m({ref:t,class:["v-dialog",{"v-dialog--fullscreen":e.fullscreen,"v-dialog--scrollable":e.scrollable},e.class],style:e.style},l,{modelValue:n.value,"onUpdate:modelValue":a=>n.value=a,"aria-modal":"true",activatorProps:E.value,role:"dialog"},V),{activator:c.activator,default:function(){for(var a=arguments.length,o=new Array(a),r=0;r<a;r++)o[r]=arguments[r];return g(S,{root:"VDialog"},{default:()=>{var s;return[(s=c.default)==null?void 0:s.call(c,...o)]}})}})}),w({},t)}});export{j as V};
