import{a as m,j as e}from"./vendor-query-B2UbickB.js";import{h as j}from"./bots-t1FPESbm.js";import{a as d,X as y,af as u,l as N,a0 as p}from"./vendor-icons-CrrAvF2g.js";function k({selected:s,onChange:n,placeholder:f}){const{data:l}=j({limit:100}),c=((l==null?void 0:l.bots)??[]).filter(t=>t.status==="active"),[o,r]=m.useState(!1),i=m.useRef(null);m.useEffect(()=>{const t=a=>{i.current&&!i.current.contains(a.target)&&r(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]);const x=c.find(t=>t.external_id===s),h=f??"Invoking user (default)";return e.jsxs("div",{ref:i,className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>r(!o),className:"flex items-center gap-1.5 w-full px-1 py-1.5 bg-transparent border-b border-surface-border/60 text-left cursor-pointer hover:border-accent/50 transition-colors focus:outline-none focus:border-accent/50",children:[s&&x?e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-lg bg-accent/[0.08] text-text-secondary text-[11px]",children:[e.jsx(d,{className:"w-2.5 h-2.5 shrink-0 text-accent/75"}),x.display_name||x.external_id,e.jsx("span",{role:"button",onClick:t=>{t.stopPropagation(),n("")},className:"ml-0.5 hover:text-status-error transition-colors",children:e.jsx(y,{className:"w-2.5 h-2.5"})})]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-text-tertiary",children:[e.jsx(u,{className:"w-3 h-3 shrink-0"}),h]}),e.jsx(N,{className:`w-3.5 h-3.5 ml-auto shrink-0 text-text-tertiary transition-transform ${o?"rotate-180":""}`})]}),o&&e.jsxs("div",{className:"absolute z-20 mt-1 w-full bg-surface-raised border border-surface-border rounded-md shadow-lg max-h-48 overflow-y-auto",children:[e.jsxs("button",{type:"button",onClick:()=>{n(""),r(!1)},className:`flex items-center gap-2 w-full px-3 py-1.5 text-left text-xs transition-colors ${s?"text-text-primary hover:bg-surface-sunken":"bg-accent/[0.06] text-accent"}`,children:[e.jsx(u,{className:"w-3 h-3 shrink-0 text-text-tertiary"}),e.jsx("span",{className:"flex-1",children:"Invoking user"}),!s&&e.jsx(p,{className:"w-3 h-3 shrink-0"})]}),c.length===0?e.jsx("p",{className:"px-3 py-2 text-xs text-text-tertiary",children:"No bot accounts"}):c.map(t=>{const a=s===t.external_id;return e.jsxs("button",{type:"button",onClick:()=>{n(t.external_id),r(!1)},className:`flex items-center gap-2 w-full px-3 py-1.5 text-left text-xs transition-colors ${a?"bg-accent/[0.06] text-accent":"text-text-primary hover:bg-surface-sunken"}`,children:[e.jsx(d,{className:"w-3 h-3 shrink-0 text-accent/60"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{children:t.display_name||t.external_id}),t.display_name&&t.display_name!==t.external_id&&e.jsx("span",{className:"ml-1 text-text-tertiary font-mono",children:t.external_id})]}),a&&e.jsx(p,{className:"w-3 h-3 shrink-0"})]},t.id)})]})]})}export{k as B};
//# sourceMappingURL=BotPicker-Ddu4V0uf.js.map
