import{j as e}from"./vendor-query-B2UbickB.js";import{u as h}from"./agents-CQsJU21y.js";import{u as f,d as b}from"./index-BZu5zewH.js";import{i as j}from"./useEventHooks-CPxcH6zx.js";import{u as v}from"./useFilterParams-x-Dg0Vgz.js";import{D as N}from"./DataTable-D9yuBv0w.js";import{S as y}from"./StickyPagination-BWhFSr2d.js";import{F as P,b as S}from"./FilterBar-Ck4K4rzu.js";import{P as k}from"./PageHeader-CR6TpJG_.js";import{L as w}from"./ListToolbar-4lObXT3_.js";import{o as _}from"./vendor-icons-CrrAvF2g.js";import{c as A}from"./vendor-react-CXumBFUA.js";import"./EmptyState-BcsfPq9T.js";const $=[{value:"active",label:"Active"},{value:"inactive",label:"Inactive"},{value:"paused",label:"Paused"},{value:"error",label:"Error"}],z=[{key:"name",label:"Agent",render:t=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${t.status==="active"?"bg-emerald-400":t.status==="paused"?"bg-amber-400":t.status==="error"?"bg-red-400":"bg-zinc-500"}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"text-xs font-medium text-text-primary block",children:t.id}),t.description&&e.jsx("p",{className:"text-[10px] text-text-tertiary truncate",children:t.description})]})]})},{key:"knowledge_domain",label:"Knowledge",render:t=>t.knowledge_domain?e.jsx("span",{className:"text-[10px] font-mono text-text-secondary whitespace-nowrap",children:t.knowledge_domain}):e.jsx("span",{className:"text-text-quaternary",children:"—"}),className:"w-28"},{key:"schedules",label:"Schedules",render:t=>{var o,r;const s=(o=t.behaviors)==null?void 0:o.schedules,a=s!=null&&s.length?s.map(i=>i.cron):(r=t.behaviors)!=null&&r.cron?[t.behaviors.cron]:[];return a.length?e.jsxs("span",{className:"text-[10px] font-mono text-text-secondary whitespace-nowrap",children:[a[0],a.length>1?` +${a.length-1}`:""]}):e.jsx("span",{className:"text-text-quaternary",children:"—"})},className:"w-28"},{key:"subscriptions",label:"Subscriptions",render:t=>{var r;const s=t.subscription_count??0,a=t.sub_topics??[];if(!s)return e.jsx("span",{className:"text-text-quaternary",children:"—"});const o=((r=a[0])==null?void 0:r.replace(/^lt\.events\./,""))??"";return e.jsxs("span",{className:"text-[10px] font-mono text-text-secondary whitespace-nowrap",children:[o,s>1?` +${s-1}`:""]})},className:"w-36"},{key:"last_run_at",label:"Last Run",render:t=>t.last_run_at?e.jsx("span",{className:"whitespace-nowrap",children:e.jsx(b,{date:t.last_run_at})}):e.jsx("span",{className:"text-text-quaternary",children:"—"}),className:"w-32"}];function M(){var u;const t=A(),{data:s}=f(),a=!!((u=s==null?void 0:s.ai)!=null&&u.enabled),o=a?"Agent":"Automation",r=a?"Agents":"Automations";j();const{filters:i,setFilter:p,pagination:n}=v({filters:{status:""}}),{data:l,isLoading:d,refetch:x,isFetching:g}=h({status:i.status||void 0,limit:n.pageSize,offset:n.offset}),m=(l==null?void 0:l.total)??0;return e.jsxs("div",{children:[e.jsx(k,{title:r,docsHash:"#docs:agents.md",actions:e.jsxs("button",{onClick:()=>t("/agents/new"),className:"flex items-center gap-2 px-4 py-2 text-sm rounded-md bg-accent text-text-inverse hover:bg-accent-hover transition-colors",children:[e.jsx(_,{className:"w-4 h-4"})," Create ",o]})}),e.jsx(P,{actions:e.jsx(w,{onRefresh:()=>x(),isFetching:g,apiPath:`/agents?limit=${n.pageSize}&offset=${n.offset}${i.status?`&status=${i.status}`:""}`}),children:e.jsx(S,{label:"Status",value:i.status,onChange:c=>p("status",c),options:$})}),e.jsx(N,{columns:z,data:(l==null?void 0:l.agents)??[],keyFn:c=>c.id,onRowClick:c=>t(`/agents/${c.id}`),isLoading:d,emptyMessage:`No ${r.toLowerCase()} found`}),e.jsx(y,{page:n.page,totalPages:n.totalPages(m),onPageChange:n.setPage,total:m,pageSize:n.pageSize,onPageSizeChange:n.setPageSize})]})}export{M as AgentsPage};
//# sourceMappingURL=AgentsPage-DzpWsTFO.js.map
