import{j as e}from"./query-PJ0ZdjbV.js";import{a as r}from"./vendor-CWhr2lg4.js";import{c4 as y,c5 as E,B as L,ap as p,c6 as P,c7 as k,ar as S,c8 as T,c9 as D,ca as O,cb as V,cc as A,C as B}from"./index-BSPIaiZU.js";import{C as I}from"./date-range-picker-BB0TgAn8.js";function q(a,o=500){const[n,t]=r.useState(a);return r.useEffect(()=>{const c=setTimeout(()=>t(a),o);return()=>clearTimeout(c)},[a,o]),n}function U({value:a,onValueChange:o,options:n,onSearch:t,selectedLabel:c,isLoading:f=!1,placeholder:j="Select...",searchPlaceholder:C="Search...",emptyText:b="No results found.",disabled:g=!1,className:v}){const[u,d]=r.useState(!1),[l,w]=r.useState(""),x=q(l,250);r.useEffect(()=>{t==null||t(x)},[x]);const i=n.find(s=>s.value===a),N=t?n:n.filter(s=>{var h;const m=l.trim().toLowerCase();return m?s.label.toLowerCase().includes(m)||(((h=s.hint)==null?void 0:h.toLowerCase().includes(m))??!1):!0});return e.jsxs(y,{open:u,onOpenChange:d,children:[e.jsx(E,{asChild:!0,children:e.jsxs(L,{variant:"outline",role:"combobox","aria-expanded":u,disabled:g,className:p("w-full justify-between font-normal h-9",!a&&"text-muted-foreground",v),children:[e.jsx("span",{className:"truncate",children:(i==null?void 0:i.label)??c??j}),e.jsx(I,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(P,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",onWheel:s=>s.stopPropagation(),onTouchMove:s=>s.stopPropagation(),children:e.jsxs(k,{shouldFilter:!1,children:[e.jsxs("div",{className:"flex items-center border-b px-3",children:[e.jsx(S,{className:"mr-2 h-3.5 w-3.5 shrink-0 opacity-50"}),e.jsx(T,{placeholder:C,value:l,onValueChange:w,className:"border-0 focus:ring-0"})]}),e.jsxs(D,{children:[e.jsx(O,{children:f?"Loading...":b}),e.jsx(V,{children:N.map(s=>e.jsxs(A,{value:s.value,onSelect:()=>{o(s.value),d(!1)},className:"flex items-center gap-2",children:[e.jsx(B,{className:p("h-3.5 w-3.5 shrink-0",a===s.value?"opacity-100":"opacity-0")}),e.jsxs("span",{className:"flex-1 min-w-0 truncate text-[13px] text-slate-900",children:[s.label,s.hint&&e.jsx("span",{className:"ml-2 text-[11px] text-slate-400",children:s.hint})]})]},s.value))})]})]})})]})}export{U as A,q as u};
