import{a as l,j as a}from"./@tanstack-D1KSn3AD.js";import{R as c}from"./refresh-Cx_kzUlu.js";import{P as m}from"./PageHeader-hJZEYC_E.js";import{S as p,P as u}from"./Pagination-cwZwDAZA.js";import{k as d,l as h,j as f,n as x,F as g,m as j,r as P,T as y,z as r,h as b,D as N,S as i}from"./index-M2LMbZSu.js";import{o as v}from"./url-BxOqGmlk.js";import{S as w}from"./terminal-C3Pq8EZ0.js";import{g as S,E as T,C as _}from"./CopyButton-D9wonjFm.js";import{L as E,f as C}from"./@react-router-t1nY6c48.js";import"./@radix-Mqgm9uyP.js";import"./chevron-right-double-BdbmNpRk.js";import"./@reactflow-DOgoC88E.js";import"./check-circle-B_YRDK8p.js";import"./copy-Vxjjuv3p.js";function F({params:e}){return["pipeline_namespaces",e]}async function R({params:e}){const s=d(h.pipelines.namespaces+"?"+v(e)),t=await f(s,{method:"GET",headers:{"Content-Type":"application/json"}});if(t.status===404&&x(),!t.ok)throw new g({message:"Error while fetching pipeline namespaces",status:t.status,statusText:t.statusText});return t.json()}function k(e,s){return l({queryKey:F(e),queryFn:()=>R(e),...s})}function A(){return[{id:"name",header:"Pipeline",accessorFn:e=>{var s;return{name:e.name,status:(s=e.body)==null?void 0:s.latest_run_status}},cell:({getValue:e})=>{const{name:s,status:t}=e();return a.jsxs("div",{className:"group/copybutton flex items-center gap-2",children:[a.jsx(j,{className:`h-5 w-5 ${S(t)}`}),a.jsxs(E,{to:P.pipelines.namespace(encodeURIComponent(s)),className:"flex items-center gap-1",children:[a.jsx("h2",{className:"text-text-md font-semibold",children:s}),a.jsx(T,{status:t}),a.jsx(_,{copyText:s})]})]})}},{id:"latest-run",header:"Latest Run",accessorFn:e=>{var s,t;return{status:(s=e.body)==null?void 0:s.latest_run_status,runId:(t=e.body)==null?void 0:t.latest_run_id}},cell:({getValue:e})=>{const{runId:s,status:t}=e();return a.jsx("div",{children:a.jsxs(y,{emphasis:"subtle",rounded:!1,className:"inline-flex items-center gap-0.5",color:"green",children:[a.jsx(w,{className:`h-3 w-3 ${L(t)}`}),s==null?void 0:s.split("-")[0]]})})}}]}function L(e){if(!e)return"fill-theme-text-brand";switch(e){case"running":return"fill-orange-700";case"cached":return"fill-theme-text-secondary";case"completed":return"fill-success-800";case"failed":return"fill-error-800";case"initializing":return"fill-theme-text-brand"}}const n=1,q=r.object({page:r.coerce.number().min(n).optional().default(n).catch(n),name:r.string().optional(),operator:r.enum(["and","or"]).optional()});function z(){const[e]=C(),{page:s,name:t,operator:o}=q.parse({page:e.get("page")||void 0,name:e.get("name")||void 0,operator:e.get("operator")||void 0});return{page:s,name:t,logical_operator:o}}function X(){const e=z(),{data:s,refetch:t}=k({params:{...e,sort_by:"desc:updated"}},{throwOnError:!0});return a.jsxs("div",{children:[a.jsx(m,{children:a.jsx("h1",{className:"text-display-xs font-semibold",children:"Pipelines"})}),a.jsx("section",{className:"p-5",children:a.jsxs("div",{className:"flex flex-col gap-5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(p,{searchParams:e}),a.jsx("div",{className:"flex justify-between",children:a.jsxs(b,{intent:"primary",emphasis:"subtle",size:"md",onClick:()=>t(),children:[a.jsx(c,{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:s?a.jsx(N,{columns:A(),data:s.items}):a.jsx(i,{className:"h-[500px] w-full"})}),s?s.total_pages>1&&a.jsx(u,{searchParams:e,paginate:s}):a.jsx(i,{className:"h-[36px] w-[300px]"})]})]})})]})}export{X as default};
