import{t as e}from"./x-CNIkD3YH.js";import{A as t,D as n,E as r,S as i,T as a,Vn as o,Y as s,an as c,b as l,en as u,f as d,j as f,k as p,l as m,p as h,qn as g,s as _,sn as v,u as y,w as b,x,zn as S}from"./index-BaTxSAlR.js";var C=g(o(),1),w=g(S(),1),T=Object.defineProperty,E=(e,t)=>T(e,`name`,{value:t,configurable:!0}),D=`Dialog`,[O,ee]=p(D),[k,A]=O(D),j=E(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=C.useRef(null),c=C.useRef(null),{nodes:u,registry:d}=b(),[f,p]=y({prop:r,defaultProp:i??!1,onChange:a,caller:D}),[m,h]=C.useState(0),[g,_]=C.useState(0);return(0,w.jsx)(k,{scope:t,triggerRef:s,contentRef:c,contentId:l(),titleId:l(),descriptionId:l(),titlePresent:m>0,descriptionPresent:g>0,setTitleCount:h,setDescriptionCount:_,open:f,onOpenChange:p,onOpenToggle:C.useCallback(()=>p(e=>!e),[p]),modal:o,branchNodes:u,branchRegistry:d,children:n})},`Dialog`),M=`DialogPortal`,[N,P]=O(M,{forceMount:void 0}),F=E(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=A(M,t);return(0,w.jsx)(N,{scope:t,forceMount:n,children:C.Children.map(r,e=>(0,w.jsx)(d,{present:n||a.open,children:(0,w.jsx)(h,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),I=`DialogOverlay`,L=C.forwardRef(E(function(e,t){let n=P(I,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=A(I,e.__scopeDialog);return a.modal?(0,w.jsx)(d,{present:r||a.open,children:(0,w.jsx)(z,{...i,ref:t})}):null},`DialogOverlay`)),R=c(`DialogOverlay.RemoveScroll`),z=C.forwardRef(E(function(e,t){let{__scopeDialog:r,...i}=e,a=A(I,r),o=v(t,n());return(0,w.jsx)(_,{as:R,allowPinchZoom:!0,shards:C.useMemo(()=>[a.contentRef,...a.branchNodes.map(e=>({current:e}))],[a.contentRef,a.branchNodes]),children:(0,w.jsx)(s.div,{"data-state":X(a.open),...i,ref:o,style:{pointerEvents:`auto`,...i.style}})})},`DialogOverlayImpl`)),B=`DialogContent`,V=C.forwardRef(E(function(e,t){let n=P(B,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=A(B,e.__scopeDialog);return(0,w.jsx)(d,{present:r||a.open,children:a.modal?(0,w.jsx)(H,{...i,ref:t}):(0,w.jsx)(U,{...i,ref:t})})},`DialogContent`)),H=C.forwardRef(E(function(e,n){let r=A(B,e.__scopeDialog),i=C.useRef(null),a=v(n,r.contentRef,i);return C.useEffect(()=>{let e=i.current;if(e)return m(e)},[]),(0,w.jsx)(W,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,onCloseAutoFocus:t(e.onCloseAutoFocus,e=>{var t;e.preventDefault(),(t=r.triggerRef.current)==null||t.focus()}),onPointerDownOutside:t(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:t(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),U=C.forwardRef(E(function(e,t){let n=A(B,e.__scopeDialog),r=C.useRef(!1),i=C.useRef(!1);return(0,w.jsx)(W,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{var a;if((a=e.onCloseAutoFocus)==null||a.call(e,t),!t.defaultPrevented){var o;r.current||(o=n.triggerRef.current)==null||o.focus(),t.preventDefault()}r.current=!1,i.current=!1},onInteractOutside:t=>{var a,o;(a=e.onInteractOutside)==null||a.call(e,t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let s=t.target;(o=n.triggerRef.current)!=null&&o.contains(s)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),W=C.forwardRef(E(function(e,t){let{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:c,"aria-describedby":l,children:u,...d}=e,f=A(B,n);return a(),(0,w.jsx)(i,{registry:f.branchRegistry,children:(0,w.jsx)(x,{asChild:!0,loop:!0,trapped:o,branches:f.branchNodes,onMountAutoFocus:s,onUnmountAutoFocus:c,children:(0,w.jsx)(r,{role:`dialog`,id:f.contentId,"aria-labelledby":f.titlePresent?f.titleId:void 0,"aria-describedby":f.descriptionPresent?Y(l,f.descriptionId):l,"data-state":X(f.open),...d,ref:t,deferPointerDownOutside:!0,onDismiss:()=>f.onOpenChange(!1),children:u})})})},`DialogContentImpl`)),G=C.forwardRef(E(function(e,t){let{__scopeDialog:n,...r}=e,i=A(`DialogTitle`,n),{setTitleCount:a}=i;return f(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,w.jsx)(s.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),K=C.forwardRef(E(function(e,t){let{__scopeDialog:n,...r}=e,i=A(`DialogDescription`,n),{setDescriptionCount:a}=i;return f(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,w.jsx)(s.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),q=`DialogClose`,J=C.forwardRef(E(function(e,n){let{__scopeDialog:r,...i}=e,a=A(q,r);return(0,w.jsx)(s.button,{type:`button`,...i,ref:n,onClick:t(e.onClick,()=>a.onOpenChange(!1))})},`DialogClose`));function Y(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}E(Y,`concatAriaDescribedby`);function X(e){return e?`open`:`closed`}E(X,`getState`);function Z({...e}){return(0,w.jsx)(j,{"data-slot":`dialog`,...e})}function Q({...e}){return(0,w.jsx)(F,{"data-slot":`dialog-portal`,...e})}function $({...e}){return(0,w.jsx)(J,{"data-slot":`dialog-close`,...e})}function te({className:e,...t}){return(0,w.jsx)(L,{"data-slot":`dialog-overlay`,className:u(`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed left-0 right-0 top-0 bottom-0 z-50 bg-black/50`,e),...t})}function ne({className:t,children:n,showCloseButton:r=!0,...i}){return(0,w.jsxs)(Q,{"data-slot":`dialog-portal`,children:[(0,w.jsx)(te,{}),(0,w.jsxs)(V,{"data-slot":`dialog-content`,className:u(`bg-background grid-cols-1 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg`,t),...i,children:[n,r&&(0,w.jsxs)(J,{"data-slot":`dialog-close`,className:`ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,w.jsx)(e,{}),(0,w.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function re({className:e,...t}){return(0,w.jsx)(`div`,{"data-slot":`dialog-header`,className:u(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function ie({className:e,...t}){return(0,w.jsx)(`div`,{"data-slot":`dialog-footer`,className:u(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}function ae({className:e,...t}){return(0,w.jsx)(G,{"data-slot":`dialog-title`,className:u(`text-lg leading-none font-semibold`,e),...t})}function oe({className:e,...t}){return(0,w.jsx)(K,{"data-slot":`dialog-description`,className:u(`text-muted-foreground text-sm`,e),...t})}export{ie as a,j as c,K as d,L as f,oe as i,J as l,G as m,$ as n,re as o,F as p,ne as r,ae as s,Z as t,V as u};