import{j as a}from"./@radix-C7hRs6Kx.js";import{S as p}from"./refresh-CM5T3QeU.js";import{S as x,P as h}from"./SearchField-D-h6jXyg.js";import{u as j}from"./all-pipeline-runs-query-BGASHYtF.js";import{L as f,r as o,T as g,E as b,G as v,H as y,J as d,K as m,z as i,h as N,M as S,S as u}from"./index-D2iSHVZq.js";import{a as P,b as R,u as T,c as k}from"./RunSelector-BLuBYNJt.js";import{D as F}from"./DisplayDate-CYVBBSgr.js";import{g as w,E as C}from"./ExecutionStatus-XrvT2r65.js";import{I as E}from"./InlineAvatar-Cfz4WSLK.js";import{L as l,d as D}from"./@react-router-CNP6g_RL.js";const A=[{id:"check",header:"",meta:{width:"1%"},accessorFn:e=>({id:e.id}),cell:({getValue:e})=>{const{id:s}=e();return a.jsx(P,{id:s})}},{id:"name",header:"Run",accessorFn:e=>{var s;return{id:e.id,name:e.name,status:(s=e.body)==null?void 0:s.status}},cell:({getValue:e})=>{const{name:s,status:t,id:r}=e();return a.jsxs("div",{className:"group/copybutton flex items-center gap-2",children:[a.jsx(f,{className:`h-5 w-5 ${w(t)}`}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(l,{to:o.runs.detail(r),className:"flex items-center gap-1",children:a.jsx("span",{className:"text-text-md font-semibold text-theme-text-primary",children:s})}),a.jsx(g,{children:a.jsxs(b,{children:[a.jsx(v,{className:"hover:text-theme-text-brand hover:underline",children:a.jsx(C,{status:t})}),a.jsx(y,{className:"z-20 capitalize",children:t})]})}),a.jsx(d,{copyText:s})]}),a.jsxs(l,{to:o.runs.detail(r),className:"flex items-center gap-1",children:[a.jsx("p",{className:"text-text-xs text-theme-text-secondary",children:r.split("-")[0]}),a.jsx(d,{copyText:r})]})]})]})}},{id:"pipeline",header:"Pipeline",accessorFn:e=>{var s,t;return(t=(s=e.body)==null?void 0:s.pipeline)==null?void 0:t.name},cell:({getValue:e})=>{const s=e();return s?a.jsx(l,{to:o.pipelines.namespace(s),children:a.jsx(m,{color:"purple",className:"inline-flex items-center gap-0.5 truncate",rounded:!1,emphasis:"subtle",children:s})}):null}},{id:"stack",header:"Stack",accessorFn:e=>{var s,t,r,n;return{name:(t=(s=e.body)==null?void 0:s.stack)==null?void 0:t.name,id:(n=(r=e.body)==null?void 0:r.stack)==null?void 0:n.id}},cell:({getValue:e})=>{const{name:s,id:t}=e();return!s||!t?null:a.jsx(m,{rounded:!1,className:"inline-block",color:"turquoise",emphasis:"subtle",children:s})}},{id:"created-at",header:"Created at",accessorFn:e=>{var s;return{date:(s=e.body)==null?void 0:s.created}},cell:({getValue:e})=>{const{date:s}=e();return a.jsx(F,{dateString:s})}},{id:"author",header:"Author",accessorFn:e=>{var s,t;return{name:(t=(s=e.body)==null?void 0:s.user)==null?void 0:t.name}},cell:({getValue:e})=>{const{name:s}=e();return s?a.jsx(E,{username:s}):null}},{id:"admin_actions",header:"",meta:{width:"5%"},cell:({row:e})=>a.jsx(R,{id:e.original.id})}],c=1,_=i.object({page:i.coerce.number().min(c).optional().default(c).catch(c),name:i.string().optional(),operator:i.enum(["and","or"]).optional(),status:i.enum(["pending","running","completed"]).optional()});function z(){const[e]=D(),{page:s,name:t,operator:r,status:n}=_.parse({page:e.get("page")||void 0,name:e.get("name")||void 0,operator:e.get("operator")||void 0,status:e.get("status")||void 0});return{page:s,name:t,logical_operator:r,status:n}}function U({fixedQueryParams:e={}}){const{selectedRuns:s}=T(),t=z(),{data:r,refetch:n}=j({params:{...t,sort_by:"desc:updated",...e}});return a.jsxs("div",{className:"mt-5 flex flex-col gap-5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[s.length?a.jsx(k,{}):a.jsx(x,{searchParams:t}),a.jsx("div",{className:"flex justify-between",children:a.jsxs(N,{intent:"primary",emphasis:"subtle",size:"md",onClick:()=>n(),children:[a.jsx(p,{className:"h-5 w-5 fill-theme-text-brand"}),"Refresh"]})})]}),a.jsxs("div",{className:"flex flex-col items-center gap-5",children:[a.jsx("div",{className:"w-full",children:r?a.jsx(S,{columns:A,data:r.items}):a.jsx(u,{className:"h-[500px] w-full"})}),r?r.total_pages>1&&a.jsx(h,{searchParams:t,paginate:r}):a.jsx(u,{className:"h-[36px] w-[300px]"})]})]})}export{U as R};
