import{r as c,j as e,S as h,X as v}from"./index-D4ZMoJFe.js";function w({value:a,onChange:d,options:l,onSelect:i,placeholder:x,disabled:n=!1,emptyMessage:p="Aucun résultat",renderOption:o,onClear:u,className:f=""}){const[m,r]=c.useState(!1),s=c.useRef(null);return e.jsxs("div",{className:`relative ${f}`,children:[e.jsx(h,{size:14,className:"pointer-events-none absolute left-3 top-1/2 z-10 -translate-y-1/2 text-textMuted"}),e.jsx("input",{value:a,onChange:t=>{d(t.target.value),r(!0)},onFocus:()=>{s.current&&window.clearTimeout(s.current),r(!0)},onBlur:()=>{s.current=window.setTimeout(()=>{r(!1)},120)},placeholder:x,disabled:n,className:"input-dark pl-9 pr-9"}),a&&u?e.jsx("button",{type:"button",className:"absolute right-2 top-1/2 z-10 -translate-y-1/2 rounded-md p-1 text-textMuted transition hover:bg-surface2 hover:text-text",onMouseDown:t=>t.preventDefault(),onClick:()=>{u(),r(!1)},"aria-label":"Effacer",children:e.jsx(v,{size:14})}):null,m&&!n?e.jsx("div",{className:"absolute z-30 mt-2 max-h-72 w-full overflow-y-auto rounded-xl border border-border bg-surface p-2 shadow-panel",children:l.length?e.jsx("div",{className:"space-y-1",children:l.map(t=>e.jsx("button",{type:"button",className:"w-full rounded-lg border border-transparent p-3 text-left transition hover:border-accent/20 hover:bg-accent/5",onMouseDown:b=>b.preventDefault(),onClick:()=>{i(t),r(!1)},children:o?o(t):t.label},t.id))}):e.jsx("p",{className:"px-3 py-2 text-sm text-textMuted",children:p})}):null]})}export{w as A};
