import{aJ as s}from"./@ui-core-DKdciH1Z.js";import{_ as u,aY as j,a0 as f,aS as S,r as c,a1 as v,a2 as b,a3 as N,a4 as R,a5 as k,a6 as m,ah as T,T as w,al as P,ak as y,B as C,a7 as A,e as h,a8 as _}from"./index-D7KLAbvI.js";import{A as E}from"./action-cell-CsLz-mf4.js";import{S as F}from"./schedule-tag-Cpi_jTxz.js";import{L as l,f as D}from"./@react-router-DaIuhn3X.js";import{a as I,u as x,b as z}from"./ButtonGroup-BirxIr-W.js";import{S as B}from"./SearchField-DEer4oQ6.js";import{u as p}from"./all-pipeline-runs-query-CQbINLBU.js";import{P as L}from"./Pagination-Bl0X6mOG.js";import{z as o}from"./@zod-DKyD3xVW.js";function V(){return[{id:"select",meta:{width:"1%"},header:({table:e})=>s.jsx(u,{id:"check-all",checked:e.getIsAllRowsSelected(),onCheckedChange:a=>e.toggleAllRowsSelected(a==="indeterminate"?!0:a)}),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,index:e.body?.index}),cell:({getValue:e})=>{const{name:a,status:t,id:r,index:n}=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(t)}`}),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:s.jsx(S,{name:a,index:n})})}),s.jsx(v,{children:s.jsxs(b,{children:[s.jsx(N,{className:"hover:text-theme-text-brand hover:underline",children:s.jsx(R,{status:t})}),s.jsx(k,{className:"z-20 capitalize",children:t})]})}),s.jsx(m,{copyText:a})]}),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 a=e.original.resources?.source_snapshot,t=a?.name;return!a||!t?null:s.jsx(T,{snapshotId:a.id,snapshotName:t})}},{id:"stack",header:"Stack",accessorFn:e=>({name:e.resources?.stack?.name,id:e.resources?.stack?.id}),cell:({getValue:e})=>{const{name:a,id:t}=e();return!a||!t?null:s.jsx(l,{to:c.stacks.overview,children:s.jsx(w,{rounded:!1,className:"inline-block whitespace-nowrap",color:"turquoise",emphasis:"subtle",children:a})})}},{id:"trigger",header:"Trigger",accessorFn:e=>e.resources?.schedule?.name,cell:({row:e})=>e.original.resources?.schedule?s.jsx(F,{}):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(P,{dateString:e()})})},{id:"author",header:"Author",accessorFn:e=>({author:e.resources?.user}),cell:({getValue:e})=>{const{author:a}=e();return s.jsx(y,{avatarUrl:a.body?.avatar_url??void 0,username:a.name,isServiceAccount:!!a.body?.is_service_account})}},{id:"admin_actions",header:"",meta:{width:"5%"},cell:({row:e})=>s.jsx(E,{children:s.jsx(I,{id:e.original.id})})}]}function W({params:e}){const{refetch:a}=p({params:e},{throwOnError:!0}),{selectedRowCount:t}=x();return s.jsxs("div",{className:"flex items-center justify-between",children:[t?s.jsx(z,{}):s.jsx(B,{searchParams:e}),s.jsxs(C,{intent:"primary",emphasis:"subtle",size:"md",onClick:()=>a(),children:[s.jsx(A,{className:"h-5 w-5 fill-theme-text-brand"}),"Refresh"]})]})}function X({params:e,columns:a}){const{rowSelection:t,setRowSelection:r}=x(),n=p({params:e},{throwOnError:!0});if(n.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(n.isError)return s.jsx("p",{children:"Error fetching pipeline runs"});const i=n.data;return s.jsxs("div",{className:"flex flex-col items-center gap-5",children:[s.jsx("div",{className:"w-full",children:s.jsx(_,{rowSelection:t,onRowSelectionChange:r,getRowId:g=>g.id,columns:a,data:i.items})}),i.total_pages>1&&s.jsx(L,{searchParams:e,paginate:i})]})}const d=1,G=o.object({page:o.coerce.number().min(d).optional().default(d).catch(d),name:o.string().optional(),operator:o.enum(["and","or"]).optional()});function Z(){const[e]=D(),{page:a,name:t,operator:r}=G.parse({page:e.get("page")||void 0,name:e.get("name")||void 0});return{page:a,name:t,logical_operator:r}}export{X as P,W as R,V as g,Z as u};
