import{u as y,c as L,d as D,a as v}from"./VMenu-DTm7W1Hp.js";import{f as w}from"./forwardRefs-BSESyuUp.js";import{v as A,x as B,T as F,g as S,az as T,ar as I,L as g,a5 as R,bz as z,B as d,a as E}from"./index-CTxlYqj4.js";import{h as O}from"./VAvatar-x_79C0tA.js";import{u as W}from"./tag-Dx3OexMp.js";const C=B({fullscreen:Boolean,retainFocus:{type:Boolean,default:!0},scrollable:Boolean,...L({origin:"center center",scrollStrategy:"block",transition:{component:D},zIndex:2400})},"VDialog"),j=A()({name:"VDialog",props:C(),emits:{"update:modelValue":e=>!0,afterEnter:()=>!0,afterLeave:()=>!0},setup(e,h){let{emit:m,slots:s}=h;const u=F(e,"modelValue"),{scopeId:V}=y(),t=S();function f(a){var r,c;const o=a.relatedTarget,l=a.target;if(o!==l&&((r=t.value)!=null&&r.contentEl)&&((c=t.value)!=null&&c.globalTop)&&![document,t.value.contentEl].includes(l)&&!t.value.contentEl.contains(l)){const n=z(t.value.contentEl);if(!n.length)return;const i=n[0],x=n[n.length-1];o===i?x.focus():i.focus()}}T(()=>{document.removeEventListener("focusin",f)}),I&&g(()=>u.value&&e.retainFocus,a=>{a?document.addEventListener("focusin",f):document.removeEventListener("focusin",f)},{immediate:!0});function P(){var a;m("afterEnter"),(e.scrim||e.retainFocus)&&((a=t.value)!=null&&a.contentEl)&&!t.value.contentEl.contains(document.activeElement)&&t.value.contentEl.focus({preventScroll:!0})}function b(){m("afterLeave")}return g(u,async a=>{var o;a||(await R(),(o=t.value.activatorEl)==null||o.focus({preventScroll:!0}))}),W(()=>{const a=v.filterProps(e),o=d({"aria-haspopup":"dialog"},e.activatorProps),l=d({tabindex:-1},e.contentProps);return E(v,d({ref:t,class:["v-dialog",{"v-dialog--fullscreen":e.fullscreen,"v-dialog--scrollable":e.scrollable},e.class],style:e.style},a,{modelValue:u.value,"onUpdate:modelValue":r=>u.value=r,"aria-modal":"true",activatorProps:o,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:P,onAfterLeave:b},V),{activator:s.activator,default:function(){for(var r=arguments.length,c=new Array(r),n=0;n<r;n++)c[n]=arguments[n];return E(O,{root:"VDialog"},{default:()=>{var i;return[(i=s.default)==null?void 0:i.call(s,...c)]}})}})}),w({},t)}});export{j as V};
