import{j as s}from"./@radix-D8tIKeo-.js";import{V as u,a3 as j,X as f,r as c,Y as S,Z as v,_ as b,$ as N,a0 as R,a1 as m,aH as k,T,aK as w,aJ as P,B as C,e as h,a4 as y}from"./index-B44sgOyQ.js";import{A}from"./action-cell-BgyPfYXo.js";import{S as _}from"./schedule-tag-FF3JaJ1t.js";import{L as l,f as E}from"./@react-router-D1ODL_Ub.js";import{a as F,u as p,b as D}from"./ButtonGroup-1QXCEfkt.js";import{S as I}from"./refresh-DNxZUtB4.js";import{S as z}from"./SearchField-BOlpKJtF.js";import{u as x}from"./all-pipeline-runs-query-g0Sk3bVP.js";import{P as B}from"./Pagination-Bpjzny1d.js";import{z as n}from"./@zod-2qqdh1cM.js";function Y(){return[{id:"select",meta:{width:"1%"},header:({table:e})=>s.jsx(u,{id:"check-all",checked:e.getIsAllRowsSelected(),onCheckedChange:t=>e.toggleAllRowsSelected(t==="indeterminate"?!0:t)}),cell:({row:e})=>s.jsx(u,{id:`check-${e.id}`,checked:e.getIsSelected(),onCheckedChange:e.getToggleSelectedHandler()})},{id:"run",header:"Run",accessorFn:e=>({name:e.name,id:e.id,status:e.body?.status}),cell:({getValue:e})=>{const{name:t,status:a,id:r}=e();return s.jsxs("div",{className:"group/copybutton flex min-w-[10rem] items-center gap-2",children:[s.jsx(j,{className:`h-5 w-5 shrink-0 ${f(a)}`}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(l,{to:c.projects.runs.detail(r),className:"grid grid-cols-1 items-center gap-1",children:s.jsx("h2",{className:"truncate text-text-md font-semibold",children:t})}),s.jsx(S,{children:s.jsxs(v,{children:[s.jsx(b,{className:"hover:text-theme-text-brand hover:underline",children:s.jsx(N,{status:a})}),s.jsx(R,{className:"z-20 capitalize",children:a})]})}),s.jsx(m,{copyText:t})]}),s.jsxs(l,{to:c.projects.runs.detail(r),className:"flex items-center gap-1",children:[s.jsx("p",{className:"text-text-xs text-theme-text-secondary",children:r.split("-")[0]}),s.jsx(m,{copyText:r})]})]})]})}},{id:"Snapshot",header:"Snapshot",accessorFn:e=>e.resources?.source_snapshot?.id,cell:({row:e})=>{const t=e.original.resources?.source_snapshot,a=t?.name;return!t||!a?null:s.jsx(k,{snapshotId:t.id,snapshotName:a})}},{id:"stack",header:"Stack",accessorFn:e=>({name:e.resources?.stack?.name,id:e.resources?.stack?.id}),cell:({getValue:e})=>{const{name:t,id:a}=e();return!t||!a?null:s.jsx(l,{to:c.stacks.overview,children:s.jsx(T,{rounded:!1,className:"inline-block whitespace-nowrap",color:"turquoise",emphasis:"subtle",children:t})})}},{id:"trigger",header:"Trigger",accessorFn:e=>e.resources?.schedule?.name,cell:({row:e})=>e.original.resources?.schedule?s.jsx(_,{}):null},{id:"created",header:"Created at",accessorFn:e=>e.body?.created,cell:({getValue:e})=>s.jsx("p",{className:"text-text-sm text-theme-text-secondary",children:s.jsx(w,{dateString:e()})})},{id:"author",header:"Author",accessorFn:e=>({author:e.resources?.user}),cell:({getValue:e})=>{const{author:t}=e();return s.jsx(P,{avatarUrl:t.body?.avatar_url??void 0,username:t.name,isServiceAccount:!!t.body?.is_service_account})}},{id:"admin_actions",header:"",meta:{width:"5%"},cell:({row:e})=>s.jsx(A,{children:s.jsx(F,{id:e.original.id})})}]}function Z({params:e}){const{refetch:t}=x({params:e},{throwOnError:!0}),{selectedRowCount:a}=p();return s.jsxs("div",{className:"flex items-center justify-between",children:[a?s.jsx(D,{}):s.jsx(z,{searchParams:e}),s.jsxs(C,{intent:"primary",emphasis:"subtle",size:"md",onClick:()=>t(),children:[s.jsx(I,{className:"h-5 w-5 fill-theme-text-brand"}),"Refresh"]})]})}function M({params:e,columns:t}){const{rowSelection:a,setRowSelection:r}=p(),o=x({params:e},{throwOnError:!0});if(o.isPending)return s.jsxs("div",{className:"flex flex-col items-center gap-5",children:[s.jsx(h,{className:"h-[500px] w-full"}),s.jsx(h,{className:"h-[36px] w-[300px]"})]});if(o.isError)return s.jsx("p",{children:"Error fetching pipeline runs"});const i=o.data;return s.jsxs("div",{className:"flex flex-col items-center gap-5",children:[s.jsx("div",{className:"w-full",children:s.jsx(y,{rowSelection:a,onRowSelectionChange:r,getRowId:g=>g.id,columns:t,data:i.items})}),i.total_pages>1&&s.jsx(B,{searchParams:e,paginate:i})]})}const d=1,L=n.object({page:n.coerce.number().min(d).optional().default(d).catch(d),name:n.string().optional(),operator:n.enum(["and","or"]).optional()});function W(){const[e]=E(),{page:t,name:a,operator:r}=L.parse({page:e.get("page")||void 0,name:e.get("name")||void 0});return{page:t,name:a,logical_operator:r}}export{M as P,Z as R,Y as g,W as u};
