import{r as e}from"./rolldown-runtime-hePW80VL.js";import{o as t}from"./vendor-forms-yQg41KHz.js";import{t as n}from"./vendor-react-CAGJwf-T.js";import{t as r}from"./x-OubpdBTF.js";import{t as i}from"./utils-Dk_44zMo.js";var a=e(t(),1),o=n(),s={sm:`w-full sm:max-w-sm`,md:`w-full sm:max-w-md`,lg:`w-full sm:max-w-lg`,xl:`w-full sm:max-w-2xl`},c=`a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])`;function l({isOpen:e,onClose:t,title:n,description:l,size:u=`md`,children:d,footer:f,closeOnOverlay:p=!0}){let m=(0,a.useRef)(null),h=(0,a.useRef)(null),g=(0,a.useRef)(null),_=(0,a.useId)(),v=(0,a.useRef)(t);(0,a.useEffect)(()=>{v.current=t},[t]);let y=(0,a.useCallback)(e=>{if(e.key===`Escape`){v.current();return}if(e.key===`Tab`&&h.current){let t=h.current.querySelectorAll(c);if(t.length===0)return;let n=t[0],r=t[t.length-1];e.shiftKey?document.activeElement===n&&(e.preventDefault(),r.focus()):document.activeElement===r&&(e.preventDefault(),n.focus())}},[]);return(0,a.useEffect)(()=>(e&&(g.current=document.activeElement,document.addEventListener(`keydown`,y),requestAnimationFrame(()=>{if(h.current){let e=h.current.querySelector(c);e?e.focus():h.current.focus()}})),()=>{document.removeEventListener(`keydown`,y)}),[e,y]),(0,a.useEffect)(()=>(e&&(document.body.style.overflow=`hidden`),()=>{e||(document.body.style.overflow=``,g.current&&typeof g.current.focus==`function`&&g.current.focus())}),[e]),e?(0,o.jsxs)(`div`,{className:`fixed inset-0 z-50`,children:[(0,o.jsx)(`div`,{ref:m,className:`absolute inset-0 bg-black/40 backdrop-blur-[2px] animate-in fade-in duration-200`,onClick:p?t:void 0,"aria-hidden":`true`}),(0,o.jsxs)(`div`,{ref:h,className:i(`absolute top-0 right-0 h-full flex flex-col`,`bg-[var(--color-surface)] border-l border-[var(--color-border)]`,`shadow-[var(--shadow-lg)]`,`animate-in slide-in-from-right duration-200`,s[u]),role:`dialog`,"aria-modal":`true`,"aria-labelledby":n?_:void 0,tabIndex:-1,children:[(n||l)&&(0,o.jsxs)(`div`,{className:`flex items-start justify-between gap-4 p-5 border-b border-[var(--color-border)]`,children:[(0,o.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[n&&(0,o.jsx)(`h2`,{id:_,className:`text-[15px] font-semibold text-[var(--color-text-primary)] tracking-tight`,children:n}),l&&(0,o.jsx)(`p`,{className:`mt-1 text-[12px] text-[var(--color-text-muted)]`,children:l})]}),(0,o.jsx)(`button`,{onClick:t,className:`flex-shrink-0 p-1.5 rounded-lg text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)] hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors`,"aria-label":`Close`,children:(0,o.jsx)(r,{className:`w-4 h-4`})})]}),(0,o.jsx)(`div`,{className:`flex-1 overflow-y-auto p-5`,children:d}),f&&(0,o.jsx)(`div`,{className:`flex items-center justify-between gap-3 px-5 py-3 border-t border-[var(--color-border)] bg-slate-50/50 dark:bg-slate-800/30`,children:f})]})]}):null}export{l as t};