import{j as s,r as p}from"./@radix-CFOkMR_E.js";import{C as u,R as d}from"./CopyButton-B3sWVJ4Z.js";import{k as h,l as f,j as x,n as g,F as j,m as P,r as l,T as y,z as r,o as b,P as N,h as v,D as w,S as o}from"./index-KsTz2dHG.js";import{S,P as E}from"./SearchField-CXoBknpt.js";import{q as T,a as C}from"./@tanstack-k96lU_C-.js";import{o as _}from"./url-rGEp5Umh.js";import{S as F}from"./terminal-By9cErXc.js";import{g as R,E as L}from"./ExecutionStatus-9zM7eaLh.js";import{L as c,c as k}from"./@react-router-CO-OsFwI.js";import"./copy-BXNk6BjL.js";import"./@reactflow-DIYUhKYX.js";import"./dots-horizontal-BObFzD5l.js";import"./chevron-right-double-CZBOf6JM.js";import"./check-circle-i56092KI.js";async function q({params:e}){const t=h(f.pipelines.all+"?"+_(e)),a=await x(t,{method:"GET",headers:{"Content-Type":"application/json"}});if(a.status===404&&g(),!a.ok)throw new j({message:"Error while fetching pipelines",status:a.status,statusText:a.statusText});return a.json()}const m={all:["pipelines"],pipelineList:e=>T({queryKey:[...m.all,e],queryFn:async()=>q({params:e})})};function z(){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(P,{className:`h-5 w-5 ${R(a)}`}),s.jsxs(c,{to:l.pipelines.namespace(encodeURIComponent(t)),className:"flex items-center gap-1",children:[s.jsx("h2",{className:"text-text-md font-semibold",children:t}),s.jsx(L,{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(c,{to:l.runs.detail(t),children:s.jsxs(y,{emphasis:"subtle",rounded:!1,className:"inline-flex items-center gap-0.5",color:B(a),children:[s.jsx(F,{className:`h-3 w-3 ${A(a)}`}),t==null?void 0:t.split("-")[0]]})})}}]}function A(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 B(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,D=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]=k(),{page:t,name:a,operator:n}=D.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}=b(),t=I(),{data:a,refetch:n}=C({...m.pipelineList({...t,sort_by:"desc:latest_run"}),throwOnError:!0});return p.useEffect(()=>{e({segment:"pipelines",data:null})},[]),s.jsxs("div",{children:[s.jsx(N,{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(S,{searchParams:t}),s.jsx("div",{className:"flex justify-between",children:s.jsxs(v,{intent:"primary",emphasis:"subtle",size:"md",onClick:()=>n(),children:[s.jsx(d,{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(w,{columns:z(),data:a.items}):s.jsx(o,{className:"h-[500px] w-full"})}),a?a.total_pages>1&&s.jsx(E,{searchParams:t,paginate:a}):s.jsx(o,{className:"h-[36px] w-[300px]"})]})]})})]})}export{ee as default};
