import{jsxs as i,Fragment as w,jsx as t}from"react/jsx-runtime";import y from"../icons/ico-caret-down.js";import m 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 _ from"../primitives/text.js";import{cn as l}from"../../lib/cn.js";import{useState as c,useRef as k,useEffect as d,useCallback as E}from"react";const N=({isOpen:r=!1,title:p,onToggle:o,children:u,showCloseButton:f=!0})=>{const[b,a]=c(r),[g,s]=c(r),n=k(null);d(()=>{let e;return r?(a(!0),e=setTimeout(()=>s(!0),10)):s(!1),()=>clearTimeout(e)},[r]),d(()=>{const e=v=>{n.current&&!n.current.contains(v.target)&&o(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[o]);const h=()=>{r||a(!1)},x=E(()=>{o(!1)},[o]);return i(w,{children:[t("div",{className:l("absolute bottom-0 left-0 right-0 h-full bg-[color-mix(in_srgb,var(--color-text-primary)_20%,transparent)] dark:bg-[rgba(0,0,0,0.7)] backdrop-blur-[3px]",r?"block":"hidden")}),b&&i("div",{ref:n,className:l("absolute bottom-0 left-0 right-0 bg-surface-primary dark:bg-surface-secondary rounded-t-3xl shadow-[0px_-12px_56px_0px_rgba(119,118,122,0.15)] z-10 transition-transform duration-300",g?"translate-y-0":"translate-y-full"),onTransitionEnd:h,children:[i("div",{className:"flex flex-row items-center gap-2.5 justify-between px-6 py-4",children:[t(_,{fontWeight:"medium",children:p}),f&&t(m,{size:"sm",variant:"neutral",onPress:x,children:t(m.LeadingIcon,{children:t(y,{})})})]}),t("div",{className:"px-6 pb-6",children:u})]})]})};export{N as Drawer};
//# sourceMappingURL=drawer.js.map
