import{j as a,a as f}from"./@tanstack-CEbkxrhX.js";import{m as j,z as o,k as y,l as g,j as b,n as P,F as N,r as i,p as v,T as u,h as S,D as R,S as p,o as T}from"./index-BhYPVFKa.js";import{P as k}from"./PageHeader-D-u0obgg.js";import{b as E,L as c,g as h}from"./@react-router-DYovave8.js";import{g as F,E as C,C as x,R as _}from"./CopyButton-eUfW9370.js";import{o as w}from"./url-ZKNs861m.js";import{S as D,P as A}from"./Pagination-ZYqHJ5gE.js";import{S as B}from"./terminal-B2ovgWuz.js";import{D as I}from"./DisplayDate-BdguISQF.js";import{I as q}from"./InlineAvatar-BiKh3XC5.js";import{r as z}from"./@radix-C9DBgJhe.js";import"./@reactflow-CegZ5GV3.js";import"./check-circle-BVvhm5dy.js";import"./copy-BRhQz3j-.js";import"./chevron-right-double-CJ50E9Gr.js";function L({namespace:e}){return a.jsx(k,{children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(j,{className:"h-5 w-5 fill-neutral-400"}),a.jsx("h1",{className:"text-display-xs font-semibold",children:decodeURIComponent(e)})]})})}const l=1,U=o.object({page:o.coerce.number().min(l).optional().default(l).catch(l),name:o.string().optional(),operator:o.enum(["and","or"]).optional()});function G(){const[e]=E(),{page:s,name:t,operator:r}=U.parse({page:e.get("page")||void 0,name:e.get("name")||void 0});return{page:s,name:t,logical_operator:r}}function H({params:e}){return["runs",e]}async function K({params:e}){const s=y(g.runs.all+"?"+w(e)),t=await b(s,{method:"GET",headers:{"Content-Type":"application/json"}});if(t.status===404&&P(),!t.ok)throw new N({message:"Error while fetching pipeline runs",status:t.status,statusText:t.statusText});return t.json()}function Q(e,s){return f({queryKey:H(e),queryFn:()=>K(e),...s})}function O(){return[{id:"run",header:"Run",accessorFn:e=>{var s;return{name:e.name,id:e.id,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(B,{className:`h-5 w-5 ${F(t)}`}),a.jsxs("div",{children:[a.jsxs(c,{to:i.runs.detail(r),className:"flex items-center gap-1",children:[a.jsx("h2",{className:"text-text-md font-semibold",children:s}),a.jsx(C,{status:t}),a.jsx(x,{copyText:s})]}),a.jsxs(c,{to:i.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(x,{copyText:r})]})]})]})}},{id:"version",header:"Version",accessorFn:e=>{var s,t,r;return(r=(t=(s=e.body)==null?void 0:s.pipeline)==null?void 0:t.body)==null?void 0:r.version},cell:({getValue:e})=>{const s=e();return a.jsx(v,{color:"purple",className:"inline-flex",size:"sm",children:s})}},{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(c,{to:i.stacks.overview,children:a.jsx(u,{rounded:!1,className:"inline-block",color:"turquoise",emphasis:"subtle",children:s})})}},{id:"repository",header:"Repository",accessorFn:e=>{var s,t,r,n,m,d;return{name:(r=(t=(s=e.body)==null?void 0:s.code_reference)==null?void 0:t.body)==null?void 0:r.code_repository.name,id:(d=(m=(n=e.body)==null?void 0:n.code_reference)==null?void 0:m.body)==null?void 0:d.code_repository.id}},cell:({getValue:e})=>{const{name:s,id:t}=e();return!s||!t?null:a.jsx("div",{children:a.jsx(u,{rounded:!1,className:"inline-block",color:"grey",emphasis:"subtle",children:s})})}},{id:"created",header:"Created at",accessorFn:e=>{var s;return(s=e.body)==null?void 0:s.created},cell:({getValue:e})=>a.jsx("p",{className:"text-text-sm text-theme-text-secondary",children:a.jsx(I,{dateString:e()})})},{id:"author",header:"Author",accessorFn:e=>{var s;return{author:(s=e.body)==null?void 0:s.user}},cell:({getValue:e})=>{const{author:s}=e();return a.jsx(q,{username:s.name})}}]}function V(){const{namespace:e}=h(),s=G(),t=O(),{data:r,refetch:n}=Q({params:{pipeline_name:decodeURIComponent(e),...s,sort_by:"desc:updated"}},{throwOnError:!0});return a.jsxs("div",{className:"flex flex-col gap-5 p-5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(D,{searchParams:s}),a.jsxs(S,{intent:"primary",emphasis:"subtle",size:"md",onClick:()=>n(),children:[a.jsx(_,{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(R,{columns:t,data:r.items}):a.jsx(p,{className:"h-[500px] w-full"})}),r?r.total_pages>1&&a.jsx(A,{searchParams:s,paginate:r}):a.jsx(p,{className:"h-[36px] w-[300px]"})]})]})}function ce(){const{namespace:e}=h(),{setCurrentBreadcrumbData:s}=T();return z.useEffect(()=>{e&&s({segment:"pipeline_detail",data:{name:e}})},[e]),a.jsxs("div",{children:[a.jsx(L,{namespace:e}),a.jsx(V,{})]})}export{ce as default};
