"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),d=require("react"),r=require("../index-C-J_tHdS.js"),S=require("@spark-ui/hooks/use-merge-refs"),q=require("@spark-ui/hooks/use-scroll-overflow"),g=require("../index-DnaHaH_0.js"),E=require("@spark-ui/icons/Close"),O=require("../Icon-Bf0XrmiR.js"),w=require("../IconButton-Bf-EDzpI.js"),B=require("../DialogContent.styles-BrhKaHc_.js"),T=d.createContext(null),I=({children:e,withFade:o=!1})=>{const[t,a]=d.useState(!1);return s.jsx(T.Provider,{value:{isFullScreen:t,setIsFullScreen:a,withFade:o},children:e})},p=()=>{const e=d.useContext(T);if(!e)throw Error("useDialog must be used within a Dialog provider");return e},k=({children:e,withFade:o=!1,...t})=>{const a=t.open,l=d.useRef(null);function n(){a&&document.activeElement&&(l.current=document.activeElement),a||setTimeout(()=>{l.current instanceof HTMLElement&&l.current.focus()},0)}return d.useEffect(n,[a]),s.jsx(I,{withFade:o,children:s.jsx(r.Root,{...t,children:e})})};k.displayName="Dialog.Root";const m=({children:e,className:o,inset:t=!1,ref:a,...l})=>{const n=d.useRef(null),u=S.useMergeRefs(a,n),{withFade:i}=p(),{overflow:c}=q.useScrollOverflow(n);return s.jsx("div",{"data-spark-component":"dialog-body",ref:u,className:g.cx("focus-visible:u-outline relative grow overflow-y-auto outline-hidden","transition-all duration-300",{"px-xl py-lg":!t},o),style:{...i&&{maskImage:"linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 44px, rgba(0, 0, 0, 1) calc(100% - 44px), rgba(0, 0, 0, 0))",maskSize:`100% calc(100% + ${c.top?"0px":"44px"} + ${c.bottom?"0px":"44px"})`,maskPosition:`0 ${c.top?"0px":"-44px"}`}},...l,children:e})};m.displayName="Dialog.Body";const x=e=>s.jsx(r.Close,{...e});x.displayName="Dialog.Close";const F=({"aria-label":e,className:o,size:t="md",intent:a="neutral",design:l="ghost",children:n=s.jsx(E.Close,{}),ref:u,...i})=>s.jsx(x,{"data-spark-component":"dialog-close-button","data-part":"close",ref:u,className:g.cx(["absolute","top-md","right-xl"],o),asChild:!0,...i,children:s.jsx(w.IconButton,{intent:a,size:t,design:l,"aria-label":e,children:s.jsx(O.Icon,{children:n})})}),R=Object.assign(F,{id:"CloseButton"});F.displayName="Dialog.CloseButton";const y=({children:e,className:o,isNarrow:t=!1,size:a="md",onInteractOutside:l,ref:n,...u})=>{const{setIsFullScreen:i}=p();return d.useEffect(()=>(a==="fullscreen"&&i(!0),()=>i(!1)),[i,a]),s.jsx(r.Content,{"data-spark-component":"dialog-content",ref:n,className:B.dialogContentStyles({className:o,isNarrow:t,size:a}),onInteractOutside:c=>{c.target.closest(".z-toast, .z-popover")&&c.preventDefault(),l?.(c)},...u,children:e})};y.displayName="Dialog.Content";const f=e=>s.jsx(r.Description,{"data-spark-component":"dialog-description",...e});f.displayName="Dialog.Description";const D=({children:e,className:o,ref:t,...a})=>s.jsx("footer",{"data-spark-component":"dialog-footer",ref:t,className:g.cx(o,["px-xl","py-lg"]),...a,children:e});D.displayName="Dialog.Footer";const N=({children:e,className:o,ref:t,...a})=>s.jsx("header",{"data-spark-component":"dialog-header",ref:t,className:g.cx(o,["px-xl","py-lg"]),...a,children:e});N.displayName="Dialog.Header";const v=({className:e,ref:o,...t})=>{const{isFullScreen:a}=p();return s.jsx(r.Overlay,{"data-spark-component":"dialog-overlay",ref:o,className:g.cx(a?"hidden":"fixed",["top-0","left-0","w-screen","h-screen","z-overlay"],["bg-overlay/dim-1"],["data-[state=open]:animate-fade-in"],["data-[state=closed]:animate-fade-out"],e),...t})};v.displayName="Dialog.Overlay";const j=({children:e,...o})=>s.jsx(r.Portal,{...o,children:e});j.displayName="Dialog.Portal";const h=({className:e,ref:o,...t})=>s.jsx(r.Title,{"data-spark-component":"dialog-title",ref:o,className:g.cx("text-headline-1 text-on-surface","group-has-data-[part=close]:pr-3xl",e),...t});h.displayName="Dialog.Title";const C=e=>s.jsx(r.Trigger,{"data-spark-component":"dialog-trigger",...e});C.displayName="Dialog.Trigger";const b=Object.assign(k,{Trigger:C,Portal:j,Overlay:v,Content:y,Header:N,Body:m,Footer:D,Close:x,CloseButton:R,Title:h,Description:f});b.displayName="Dialog";b.Trigger.displayName="Dialog.Trigger";C.displayName="Dialog.Trigger";j.displayName="Dialog.Portal";v.displayName="Dialog.Overlay";y.displayName="Dialog.Content";N.displayName="Dialog.Header";m.displayName="Dialog.Body";D.displayName="Dialog.Footer";R.displayName="Dialog.CloseButton";h.displayName="Dialog.Title";f.displayName="Dialog.Description";exports.Dialog=b;
//# sourceMappingURL=index.js.map
