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