import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{d as t,t as n}from"./jsx-runtime-UY3v_sjn.js";import{a as r,i,n as a,r as o,t as s}from"./dist-D79fvq5v.js";import{a as c,r as l}from"./dist-CpbhN_cU.js";import{t as u}from"./dist-CMaNrZHo.js";import{a as d,c as f,i as p,n as m,o as h,r as g,s as _,t as v}from"./es2015-CEhw2WdQ.js";import{t as y}from"./createLucideIcon-BeHZXpLp.js";var b=y(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),x=e(t(),1),S=n(),C=Object.defineProperty,w=(e,t)=>C(e,`name`,{value:t,configurable:!0}),T=`Dialog`,[E,D]=i(T),[O,k]=E(T),A=w(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,c=x.useRef(null),l=x.useRef(null),[u,d]=s({prop:r,defaultProp:i??!1,onChange:a,caller:T}),[f,p]=x.useState(0),[m,g]=x.useState(0);return(0,S.jsx)(O,{scope:t,triggerRef:c,contentRef:l,contentId:h(),titleId:h(),descriptionId:h(),titlePresent:f>0,descriptionPresent:m>0,setTitleCount:p,setDescriptionCount:g,open:u,onOpenChange:d,onOpenToggle:x.useCallback(()=>d(e=>!e),[d]),modal:o,children:n})},`Dialog`),j=`DialogTrigger`,M=x.forwardRef(w(function(e,t){let{__scopeDialog:n,...i}=e,a=k(j,n),o=c(t,a.triggerRef);return(0,S.jsx)(u.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":Q(a.open),...i,ref:o,onClick:r(e.onClick,a.onOpenToggle)})},`DialogTrigger`)),N=`DialogPortal`,[P,F]=E(N,{forceMount:void 0}),I=w(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,o=k(N,t);return(0,S.jsx)(P,{scope:t,forceMount:n,children:x.Children.map(r,e=>(0,S.jsx)(a,{present:n||o.open,children:(0,S.jsx)(d,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),L=`DialogOverlay`,R=x.forwardRef(w(function(e,t){let n=F(L,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=k(L,e.__scopeDialog);return o.modal?(0,S.jsx)(a,{present:r||o.open,children:(0,S.jsx)(B,{...i,ref:t})}):null},`DialogOverlay`)),z=l(`DialogOverlay.RemoveScroll`),B=x.forwardRef(w(function(e,t){let{__scopeDialog:n,...r}=e,i=k(L,n),a=c(t,f());return(0,S.jsx)(m,{as:z,allowPinchZoom:!0,shards:[i.contentRef],children:(0,S.jsx)(u.div,{"data-state":Q(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),V=`DialogContent`,H=x.forwardRef(w(function(e,t){let n=F(V,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=k(V,e.__scopeDialog);return(0,S.jsx)(a,{present:r||o.open,children:o.modal?(0,S.jsx)(U,{...i,ref:t}):(0,S.jsx)(W,{...i,ref:t})})},`DialogContent`)),U=x.forwardRef(w(function(e,t){let n=k(V,e.__scopeDialog),i=x.useRef(null),a=c(t,n.contentRef,i);return x.useEffect(()=>{let e=i.current;if(e)return v(e)},[]),(0,S.jsx)(G,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:r(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:r(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:r(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),W=x.forwardRef(w(function(e,t){let n=k(V,e.__scopeDialog),r=x.useRef(!1),i=x.useRef(!1);return(0,S.jsx)(G,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),G=x.forwardRef(w(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=k(V,n);return g(),(0,S.jsx)(S.Fragment,{children:(0,S.jsx)(p,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,S.jsx)(_,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":Q(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),K=`DialogTitle`,q=x.forwardRef(w(function(e,t){let{__scopeDialog:n,...r}=e,i=k(K,n),{setTitleCount:a}=i;return o(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,S.jsx)(u.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),J=`DialogDescription`,Y=x.forwardRef(w(function(e,t){let{__scopeDialog:n,...r}=e,i=k(J,n),{setDescriptionCount:a}=i;return o(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,S.jsx)(u.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),X=`DialogClose`,Z=x.forwardRef(w(function(e,t){let{__scopeDialog:n,...i}=e,a=k(X,n);return(0,S.jsx)(u.button,{type:`button`,...i,ref:t,onClick:r(e.onClick,()=>a.onOpenChange(!1))})},`DialogClose`));function Q(e){return e?`open`:`closed`}w(Q,`getState`);export{R as a,M as c,Y as i,D as l,Z as n,I as o,H as r,q as s,A as t,b as u};