import{r as i,x as B,j as s,ak as C,z as R,P as D,y as p,aJ as _,ap as H,F as V,aQ as q,ar as z,as as J}from"./index-DLIdDvtv.js";import{h as K,R as Q,u as U,F as Y}from"./Combination-B0NUnCBf.js";var x="Dialog",[P,le]=V(x),[Z,u]=P(x),N=e=>{const{__scopeDialog:o,children:r,open:a,defaultOpen:n,onOpenChange:t,modal:c=!0}=e,l=i.useRef(null),d=i.useRef(null),[g,m]=B({prop:a,defaultProp:n??!1,onChange:t,caller:x});return s.jsx(Z,{scope:o,triggerRef:l,contentRef:d,contentId:C(),titleId:C(),descriptionId:C(),open:g,onOpenChange:m,onOpenToggle:i.useCallback(()=>m($=>!$),[m]),modal:c,children:r})};N.displayName=x;var O="DialogTrigger",I=i.forwardRef((e,o)=>{const{__scopeDialog:r,...a}=e,n=u(O,r),t=R(o,n.triggerRef);return s.jsx(D.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":y(n.open),...a,ref:t,onClick:p(e.onClick,n.onOpenToggle)})});I.displayName=O;var h="DialogPortal",[X,A]=P(h,{forceMount:void 0}),T=e=>{const{__scopeDialog:o,forceMount:r,children:a,container:n}=e,t=u(h,o);return s.jsx(X,{scope:o,forceMount:r,children:i.Children.map(a,c=>s.jsx(_,{present:r||t.open,children:s.jsx(H,{asChild:!0,container:n,children:c})}))})};T.displayName=h;var v="DialogOverlay",j=i.forwardRef((e,o)=>{const r=A(v,e.__scopeDialog),{forceMount:a=r.forceMount,...n}=e,t=u(v,e.__scopeDialog);return t.modal?s.jsx(_,{present:a||t.open,children:s.jsx(te,{...n,ref:o})}):null});j.displayName=v;var ee=J("DialogOverlay.RemoveScroll"),te=i.forwardRef((e,o)=>{const{__scopeDialog:r,...a}=e,n=u(v,r);return s.jsx(Q,{as:ee,allowPinchZoom:!0,shards:[n.contentRef],children:s.jsx(D.div,{"data-state":y(n.open),...a,ref:o,style:{pointerEvents:"auto",...a.style}})})}),f="DialogContent",b=i.forwardRef((e,o)=>{const r=A(f,e.__scopeDialog),{forceMount:a=r.forceMount,...n}=e,t=u(f,e.__scopeDialog);return s.jsx(_,{present:a||t.open,children:t.modal?s.jsx(oe,{...n,ref:o}):s.jsx(ne,{...n,ref:o})})});b.displayName=f;var oe=i.forwardRef((e,o)=>{const r=u(f,e.__scopeDialog),a=i.useRef(null),n=R(o,r.contentRef,a);return i.useEffect(()=>{const t=a.current;if(t)return K(t)},[]),s.jsx(M,{...e,ref:n,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:p(e.onCloseAutoFocus,t=>{var c;t.preventDefault(),(c=r.triggerRef.current)==null||c.focus()}),onPointerDownOutside:p(e.onPointerDownOutside,t=>{const c=t.detail.originalEvent,l=c.button===0&&c.ctrlKey===!0;(c.button===2||l)&&t.preventDefault()}),onFocusOutside:p(e.onFocusOutside,t=>t.preventDefault())})}),ne=i.forwardRef((e,o)=>{const r=u(f,e.__scopeDialog),a=i.useRef(!1),n=i.useRef(!1);return s.jsx(M,{...e,ref:o,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{var c,l;(c=e.onCloseAutoFocus)==null||c.call(e,t),t.defaultPrevented||(a.current||(l=r.triggerRef.current)==null||l.focus(),t.preventDefault()),a.current=!1,n.current=!1},onInteractOutside:t=>{var d,g;(d=e.onInteractOutside)==null||d.call(e,t),t.defaultPrevented||(a.current=!0,t.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const c=t.target;((g=r.triggerRef.current)==null?void 0:g.contains(c))&&t.preventDefault(),t.detail.originalEvent.type==="focusin"&&n.current&&t.preventDefault()}})}),M=i.forwardRef((e,o)=>{const{__scopeDialog:r,trapFocus:a,onOpenAutoFocus:n,onCloseAutoFocus:t,...c}=e,l=u(f,r),d=i.useRef(null),g=R(o,d);return U(),s.jsxs(s.Fragment,{children:[s.jsx(Y,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:n,onUnmountAutoFocus:t,children:s.jsx(z,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":y(l.open),...c,ref:g,onDismiss:()=>l.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(re,{titleId:l.titleId}),s.jsx(se,{contentRef:d,descriptionId:l.descriptionId})]})]})}),E="DialogTitle",F=i.forwardRef((e,o)=>{const{__scopeDialog:r,...a}=e,n=u(E,r);return s.jsx(D.h2,{id:n.titleId,...a,ref:o})});F.displayName=E;var w="DialogDescription",S=i.forwardRef((e,o)=>{const{__scopeDialog:r,...a}=e,n=u(w,r);return s.jsx(D.p,{id:n.descriptionId,...a,ref:o})});S.displayName=w;var W="DialogClose",k=i.forwardRef((e,o)=>{const{__scopeDialog:r,...a}=e,n=u(W,r);return s.jsx(D.button,{type:"button",...a,ref:o,onClick:p(e.onClick,()=>n.onOpenChange(!1))})});k.displayName=W;function y(e){return e?"open":"closed"}var G="DialogTitleWarning",[ue,L]=q(G,{contentName:f,titleName:E,docsSlug:"dialog"}),re=({titleId:e})=>{const o=L(G),r=`\`${o.contentName}\` requires a \`${o.titleName}\` for the component to be accessible for screen reader users.

If you want to hide the \`${o.titleName}\`, you can wrap it with our VisuallyHidden component.

For more information, see https://radix-ui.com/primitives/docs/components/${o.docsSlug}`;return i.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},ae="DialogDescriptionWarning",se=({contentRef:e,descriptionId:o})=>{const a=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${L(ae).contentName}}.`;return i.useEffect(()=>{var t;const n=(t=e.current)==null?void 0:t.getAttribute("aria-describedby");o&&n&&(document.getElementById(o)||console.warn(a))},[a,e,o]),null},de=N,fe=I,ge=T,pe=j,De=b,ve=F,xe=S,me=k;export{De as C,xe as D,pe as O,ge as P,de as R,ve as T,ue as W,me as a,fe as b,le as c};