import{x as b,y as x,a0 as y,ax as L,i as A,l as D,cz as w,ad as v,C as B,aI as F,b_ as I,cK as S,cL as R,bl as m,aA as u,b as g,ao as T,aG as C}from"./index-LFx1jIjH.js";const O=x({fullscreen:Boolean,retainFocus:{type:Boolean,default:!0},scrollable:Boolean,...I({origin:"center center",scrollStrategy:"block",transition:{component:S},zIndex:2400})},"VDialog"),z=b()({name:"VDialog",props:O(),emits:{"update:modelValue":e=>!0,afterEnter:()=>!0,afterLeave:()=>!0},setup(e,E){let{emit:f,slots:d}=E;const c=y(e,"modelValue"),{scopeId:h}=L(),t=A();function i(n){const s=n.relatedTarget,l=n.target;if(s!==l&&t.value?.contentEl&&t.value?.globalTop&&![document,t.value.contentEl].includes(l)&&!t.value.contentEl.contains(l)){const a=R(t.value.contentEl);if(!a.length)return;const r=a[0],o=a[a.length-1];s===r?o.focus():r.focus()}}D(()=>{document.removeEventListener("focusin",i)}),w&&v(()=>c.value&&e.retainFocus,n=>{n?document.addEventListener("focusin",i):document.removeEventListener("focusin",i)},{immediate:!0});function V(){f("afterEnter"),(e.scrim||e.retainFocus)&&t.value?.contentEl&&!t.value.contentEl.contains(document.activeElement)&&t.value.contentEl.focus({preventScroll:!0})}function P(){f("afterLeave")}return v(c,async n=>{n||(await T(),t.value.activatorEl?.focus({preventScroll:!0}))}),B(()=>{const n=m.filterProps(e),s=u({"aria-haspopup":"dialog"},e.activatorProps),l=u({tabindex:-1},e.contentProps);return g(m,u({ref:t,class:["v-dialog",{"v-dialog--fullscreen":e.fullscreen,"v-dialog--scrollable":e.scrollable},e.class],style:e.style},n,{modelValue:c.value,"onUpdate:modelValue":a=>c.value=a,"aria-modal":"true",activatorProps:s,contentProps:l,height:e.fullscreen?void 0:e.height,width:e.fullscreen?void 0:e.width,maxHeight:e.fullscreen?void 0:e.maxHeight,maxWidth:e.fullscreen?void 0:e.maxWidth,role:"dialog",onAfterEnter:V,onAfterLeave:P},h),{activator:d.activator,default:function(){for(var a=arguments.length,r=new Array(a),o=0;o<a;o++)r[o]=arguments[o];return g(C,{root:"VDialog"},{default:()=>[d.default?.(...r)]})}})}),F({},t)}});export{z as V};
