import{u as p,r as n,j as t,g as r}from"./index-B48HCCvn.js";import{C as w}from"./chevron-down-DBS9-_Q3.js";import{C as v}from"./check-CadkXmJ-.js";function g({value:l,onChange:d,options:o,placeholder:m="Select...",disabled:f=!1,className:x}){const{t:i}=p(),[s,a]=n.useState(!1),c=n.useRef(null),u=o.find(e=>e.value===l);n.useEffect(()=>{if(!s)return;const e=h=>{c.current&&!c.current.contains(h.target)&&a(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[s]);const b=n.useCallback(e=>{e.key==="Escape"&&a(!1)},[]);return t.jsxs("div",{ref:c,className:r("relative",x),onKeyDown:b,children:[t.jsxs("button",{type:"button",disabled:f,onClick:()=>a(e=>!e),className:r("flex items-center justify-between w-full h-9 px-3 border rounded-lg text-sm transition-colors","bg-white border-neutral-200 hover:border-neutral-300","focus:outline-none focus:border-neutral-400","disabled:opacity-50 disabled:cursor-not-allowed",s&&"border-neutral-400",!u&&"text-neutral-400"),children:[t.jsx("span",{className:"truncate",children:u?u.label:i(m)}),t.jsx(w,{size:14,className:r("ml-2 shrink-0 text-neutral-400 transition-transform duration-150",s&&"rotate-180")})]}),s&&t.jsx("div",{className:"absolute z-50 mt-1 w-full min-w-[160px] bg-white border border-neutral-200 rounded-lg shadow-lg shadow-neutral-200/50 py-1 max-h-[200px] overflow-y-auto",children:o.length===0?t.jsx("div",{className:"px-3 py-2 text-sm text-neutral-400",children:i("No options")}):o.map(e=>t.jsxs("button",{type:"button",disabled:e.disabled,onClick:()=>{d(e.value),a(!1)},className:r("flex items-center w-full px-3 py-1.5 text-sm text-left transition-colors","hover:bg-neutral-50",e.value===l?"text-neutral-900 font-medium":"text-neutral-600",e.disabled&&"opacity-40 cursor-not-allowed"),children:[t.jsx(v,{size:14,className:r("mr-2 shrink-0",e.value===l?"opacity-100":"opacity-0")}),t.jsx("span",{className:"truncate",children:e.label})]},e.value))})]})}export{g as S};
