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