import{B as L,C as x,a1 as D,ay as B,r as A,q as k,cC as F,ae as m,G as S,aJ as T,b_ as C,cN as I,ap as g,cO as E,bm as h,aB as f,b as y,aH as O}from"./index-CD7iYaFT.js";const R=x({fullscreen:Boolean,retainFocus:{type:Boolean,default:!0},scrollable:Boolean,...C({origin:"center center",scrollStrategy:"block",transition:{component:I},zIndex:2400})},"VDialog"),K=L()({name:"VDialog",props:R(),emits:{"update:modelValue":e=>!0,afterEnter:()=>!0,afterLeave:()=>!0},setup(e,b){let{emit:d,slots:v}=b;const r=D(e,"modelValue"),{scopeId:V}=B(),n=A();async function u(t){const a=t.relatedTarget,o=t.target;await g(),r.value&&a!==o&&n.value?.contentEl&&n.value?.globalTop&&![document,n.value.contentEl].includes(o)&&!n.value.contentEl.contains(o)&&E(n.value.contentEl)[0]?.focus()}function i(t){if(t.key!=="Tab"||!n.value?.contentEl)return;const a=E(n.value.contentEl);if(!a.length)return;const o=a[0],l=a[a.length-1],c=document.activeElement;t.shiftKey&&c===o?(t.preventDefault(),l.focus()):!t.shiftKey&&c===l&&(t.preventDefault(),o.focus())}k(()=>{document.removeEventListener("focusin",u),document.removeEventListener("keydown",i)}),F&&m(()=>r.value&&e.retainFocus,t=>{t?(document.addEventListener("focusin",u,{once:!0}),document.addEventListener("keydown",i)):(document.removeEventListener("focusin",u),document.removeEventListener("keydown",i))},{immediate:!0});function P(){d("afterEnter"),(e.scrim||e.retainFocus)&&n.value?.contentEl&&!n.value.contentEl.contains(document.activeElement)&&n.value.contentEl.focus({preventScroll:!0})}function w(){d("afterLeave")}return m(r,async t=>{t||(await g(),n.value.activatorEl?.focus({preventScroll:!0}))}),S(()=>{const t=h.filterProps(e),a=f({"aria-haspopup":"dialog"},e.activatorProps),o=f({tabindex:-1},e.contentProps);return y(h,f({ref:n,class:["v-dialog",{"v-dialog--fullscreen":e.fullscreen,"v-dialog--scrollable":e.scrollable},e.class],style:e.style},t,{modelValue:r.value,"onUpdate:modelValue":l=>r.value=l,"aria-modal":"true",activatorProps:a,contentProps:o,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:w},V),{activator:v.activator,default:function(){for(var l=arguments.length,c=new Array(l),s=0;s<l;s++)c[s]=arguments[s];return y(O,{root:"VDialog"},{default:()=>[v.default?.(...c)]})}})}),T({},n)}});export{K as V};
