import{n as g,a as b,d as j,u as k,e as N,j as s,c as y,B as w,L as S,I as v}from"./index-O0BQoyzo.js";import{r as C}from"./react-Cb2sDjhD.js";import{D as L}from"./data-table-S7rIjwdO.js";import{E as T}from"./empty-state-C-qjOHyu.js";import{S as I}from"./status-badge-BSkpyN4D.js";import{u as A}from"./useQuery-PdiC7-sY.js";import{u as D}from"./use-event-stream-DgGpGKop.js";import{L as M}from"./loader-circle-9VUMGitw.js";import{R as E}from"./refresh-ccw-D2CWiyU_.js";import"./table-CPn1MRcy.js";import"./arrow-up-63xELY5Q.js";import"./arrow-down-BXvC8Al2.js";/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const R=g("ListTree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]),m={all:["subtasks"],list:e=>["subtasks","list",e]};function q(e){return A({queryKey:m.list(e),queryFn:()=>j.listSubtasks(e)})}function F(){const e=b();return()=>e.invalidateQueries({queryKey:m.all})}const $={connected:"text-success",connecting:"text-text-dim",reconnecting:"text-warning",closed:"text-text-muted"};function X(){const{t:e}=k(["tasks","common"]),[a,n]=N(),r=F(),i=a.get("agent")??"",{data:d,isLoading:u,isFetching:c,refetch:x}=q(i?{agent:i}:{}),p=d?.subtasks??[],o=D({job:()=>r()});function h(t){const l=new URLSearchParams(a);t?l.set("agent",t):l.delete("agent"),n(l,{replace:!0})}const f=C.useMemo(()=>[{id:"id",header:e("subtasks.col.id"),cell:t=>s.jsxs("span",{className:"tabular-nums text-text-dim",children:["#",t.id]}),headClassName:"w-16"},{id:"agent",header:e("subtasks.col.agent"),cell:t=>s.jsx("span",{className:"font-medium",children:t.agent}),headClassName:"w-32"},{id:"prompt",header:e("subtasks.col.prompt"),cell:t=>s.jsx("span",{className:"line-clamp-2 text-text-dim",children:t.prompt}),asCardTitle:!0},{id:"status",header:e("subtasks.col.status"),cell:t=>s.jsx(I,{status:t.status,children:e(`subtasks.status.${t.status}`,{defaultValue:t.status})}),headClassName:"w-32"},{id:"parent",header:e("subtasks.col.parent"),cell:t=>s.jsxs("span",{className:"text-text-dim",children:[s.jsx("span",{className:"font-medium text-text",children:t.parentAgent}),s.jsx("span",{className:"text-text-muted",children:" / "}),s.jsx("span",{title:t.parentSessionId,children:t.parentSessionId.slice(0,8)})]}),headClassName:"w-40"},{id:"platform",header:e("subtasks.col.platform"),cell:t=>s.jsx("span",{className:"text-text-dim",children:t.platform}),headClassName:"w-28",hideOnMobile:!0},{id:"createdAt",header:e("subtasks.col.createdAt"),cell:t=>s.jsx("span",{className:"text-text-dim",children:B(t.createdAt)}),headClassName:"w-40",hideOnMobile:!0}],[e]);return s.jsxs("div",{className:"mx-auto flex max-w-7xl flex-col gap-4",children:[s.jsxs("header",{className:"flex flex-col gap-1",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("h1",{className:"text-xl font-semibold",children:e("subtasks.title")}),s.jsx("span",{className:y("text-xs font-medium tabular-nums",$[o]),children:e(`jobs.live.${o}`)}),s.jsxs(w,{variant:"ghost",size:"sm",className:"ml-auto",onClick:()=>x(),disabled:c,"aria-label":e("actions.refresh",{ns:"common"}),children:[c?s.jsx(M,{className:"h-4 w-4 animate-spin"}):s.jsx(E,{className:"h-4 w-4"}),s.jsx("span",{className:"hidden sm:inline",children:e("actions.refresh",{ns:"common"})})]})]}),s.jsx("p",{className:"text-sm text-text-dim",children:e("subtasks.subtitle")})]}),s.jsx("div",{className:"flex flex-wrap items-end gap-2",children:s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(S,{htmlFor:"agent-filter",className:"text-xs text-text-dim",children:e("subtasks.filter.agent")}),s.jsx(v,{id:"agent-filter",value:i,onChange:t=>h(t.target.value),placeholder:e("subtasks.filter.agentAny"),className:"w-48"})]})}),s.jsx(L,{columns:f,rows:p,getRowId:t=>`${t.parentSessionId}:${t.id}`,loading:u,emptyState:s.jsx(T,{icon:s.jsx(R,{}),title:e("subtasks.empty.title"),description:e("subtasks.empty.description")})})]})}function B(e){try{const a=new Date(e);if(Number.isNaN(a.getTime()))return e;const n=new Date;return a.toDateString()===n.toDateString()?a.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):a.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return e}}export{X as default};
//# sourceMappingURL=subtasks-Bel-I1Sk.js.map
