import{j as e}from"./query-PJ0ZdjbV.js";import{a as m}from"./vendor-CWhr2lg4.js";import{c4 as u,c5 as C,B as g,ap as l,c6 as N,c7 as v,ar as w,c8 as b,c9 as S,ca as y,cb as _,cc as k,C as U}from"./index-BSPIaiZU.js";import{u as $}from"./accounts.api-DU956vCW.js";import{C as E}from"./date-range-picker-BB0TgAn8.js";function z({value:r,onValueChange:d,placeholder:p="Select user",disabled:x=!1,className:h}){const[n,o]=m.useState(!1),[i,f]=m.useState(""),{data:t,isLoading:j}=$({page_size:200,search:i||void 0}),c=(t==null?void 0:t.results)??[],a=c.find(s=>s.id===r);return e.jsxs(u,{open:n,onOpenChange:o,children:[e.jsx(C,{asChild:!0,children:e.jsxs(g,{variant:"outline",role:"combobox","aria-expanded":n,disabled:x,className:l("w-full justify-between font-normal h-9",!r&&"text-muted-foreground",h),children:[a?`${a.first_name} ${a.last_name}`.trim()||a.email:p,e.jsx(E,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(N,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(v,{shouldFilter:!1,children:[e.jsxs("div",{className:"flex items-center border-b px-3",children:[e.jsx(w,{className:"mr-2 h-3.5 w-3.5 shrink-0 opacity-50"}),e.jsx(b,{placeholder:"Search by name or email...",value:i,onValueChange:f,className:"border-0 focus:ring-0"})]}),e.jsxs(S,{children:[e.jsx(y,{children:j?"Loading...":"No users found."}),e.jsx(_,{children:c.map(s=>e.jsxs(k,{value:s.id,onSelect:()=>{d(s.id),o(!1)},className:"flex items-center gap-2",children:[e.jsx(U,{className:l("h-3.5 w-3.5 shrink-0",r===s.id?"opacity-100":"opacity-0")}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-[13px] font-medium text-slate-900",children:`${s.first_name} ${s.last_name}`.trim()||s.email}),(s.first_name||s.last_name)&&e.jsx("span",{className:"ml-2 text-[11px] text-slate-400",children:s.email})]})]},s.id))})]})]})})]})}export{z as U};
