import{jsxs as i,Fragment as w,jsx as t}from"react/jsx-runtime";import"@styled/tokens";import y from"../icons/ico-caret-down.js";import p from"../primitives/button.js";import"../primitives/checkbox.js";import"../primitives/dropdown-selector.js";import"../primitives/popover.js";import"../primitives/radio.js";import"../primitives/segmented-control.js";import"../primitives/switch.js";import T from"../primitives/text.js";import{Box as s,HStack as v}from"@styled/jsx";import{useState as l,useRef as E,useEffect as c,useCallback as j}from"react";const B=({isOpen:r=!1,title:u,onToggle:e,children:d,showCloseButton:f=!0})=>{const[b,a]=l(r),[x,m]=l(r),n=E(null);c(()=>{let o;return r?(a(!0),o=setTimeout(()=>m(!0),10)):m(!1),()=>clearTimeout(o)},[r]),c(()=>{const o=k=>{n.current&&!n.current.contains(k.target)&&e(!1)};return document.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o)}},[e]);const g=()=>{r||a(!1)},h=j(()=>{e(!1)},[e]);return i(w,{children:[t(s,{position:"absolute",display:r?"block":"none",h:"full",bottom:0,left:0,right:0,bg:"text.primary/20",_dark:{bg:"rgba(0, 0, 0, .7)"},backdropFilter:"blur(3px)"}),b&&i(s,{ref:n,position:"absolute",transform:x?"translateY(0)":"translateY(100%)",transition:"transform 0.3s",bottom:0,left:0,right:0,bg:"surface.primary",_dark:{bg:"surface.secondary"},roundedTop:"3xl",boxShadow:"0px -12px 56px 0px rgba(119, 118, 122, 0.15)",onTransitionEnd:g,zIndex:10,children:[i(v,{justifyContent:"space-between",px:6,py:4,children:[t(T,{fontWeight:"medium",children:u}),f&&t(p,{size:"sm",variant:"neutral",onPress:h,children:t(p.LeadingIcon,{children:t(y,{})})})]}),t(s,{px:6,pb:6,children:d})]})]})};export{B as Drawer};
//# sourceMappingURL=drawer.js.map
