import{r as x,j as t}from"./@radix-3bj3otF9.js";import{c as h}from"./helper-BXlR2ZLp.js";import{P as f}from"./Pagination-DePVp3ki.js";import{ab as j,r as g,a0 as y,ac as v,a9 as P,aa as S,ad as u,e as m,a3 as b,B as D,z as o}from"./index-1REJ-mbf.js";import{b as d}from"./@tanstack-CByuvRcg.js";import{D as N,B as w}from"./deployment-status-tag-CXWJMCxB.js";import{L as C,f as R,a as B}from"./@react-router-Ct_TgVUW.js";import{S as E}from"./refresh-BaK7e0kN.js";import{S as F}from"./SearchField-CjwYvxg3.js";import"./chevron-right-double-BuLe9bCa.js";import"./@reactflow-CwWcBchH.js";import"./trash-B0fyghWi.js";import"./DeleteAlertDialog-BUIIlTob.js";import"./zod-36FJuF1H.js";import"./index.esm-DnoyTjte.js";import"./index-FwZ5fdjO.js";const{ContextProvider:T,useContext:l}=h();function _(){return x.useMemo(()=>[{id:"name",header:"Deployment",accessorFn:s=>s.name,cell:({row:s})=>{const e=s.original.name,a=s.original.id;return t.jsxs("div",{className:"group/copybutton flex items-center gap-2",children:[t.jsx(j,{className:"h-5 w-5 fill-primary-400"}),t.jsx("div",{children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(C,{to:g.projects.deployments.detail.overview(a),className:"flex items-center gap-1",children:t.jsx("span",{className:"text-text-md font-semibold text-theme-text-primary",children:e??"Unnamed"})}),t.jsx(y,{copyText:e??""})]})})]})}},{id:"status",header:"Status",accessorFn:s=>{var e;return(e=s.body)==null?void 0:e.status},cell:({row:s})=>{var a;const e=(a=s.original.body)==null?void 0:a.status;return e?t.jsx(N,{status:e}):t.jsx("div",{children:"No status"})}},{id:"snapshot",header:"Snapshot",accessorFn:s=>{var e,a;return(a=(e=s.resources)==null?void 0:e.snapshot)==null?void 0:a.name},cell:({row:s})=>{var n;const e=(n=s.original.resources)==null?void 0:n.snapshot,a=e==null?void 0:e.name,r=e==null?void 0:e.id;return!a||!r?null:t.jsx(v,{snapshotId:r,snapshotName:a})}},{id:"author",header:"Author",accessorFn:s=>{var e,a;return(a=(e=s.resources)==null?void 0:e.user)==null?void 0:a.name},cell:({row:s})=>{var a,r,n;const e=(a=s.original.resources)==null?void 0:a.user;return e?t.jsx(P,{username:e.name,isServiceAccount:!!((r=e.body)!=null&&r.is_service_account),avatarUrl:((n=e.body)==null?void 0:n.avatar_url)??void 0}):null}},{id:"created",header:"Created at",accessorFn:s=>{var e;return{date:(e=s.body)==null?void 0:e.created}},cell:({getValue:s})=>{const{date:e}=s();return t.jsx(S,{dateString:e})}}],[])}function k({params:s}){const{rowSelection:e,setRowSelection:a}=l(),r=_(),n=d({...u.list(s),throwOnError:!0});if(n.isPending)return t.jsxs("div",{className:"flex flex-col items-center gap-5",children:[t.jsx("div",{className:"w-full",children:t.jsx(m,{className:"h-[500px] w-full"})}),t.jsx(m,{className:"h-[36px] w-[300px]"})]});if(n.isError)return t.jsx("p",{children:"Error fetching deployments"});const i=n.data;return t.jsxs("div",{className:"flex flex-col items-center gap-5",children:[t.jsx("div",{className:"w-full",children:t.jsx(b,{columns:r,data:i.items,rowSelection:e,onRowSelectionChange:a,getRowId:p=>p.id})}),i.total_pages>1&&t.jsx(f,{searchParams:s,paginate:i})]})}function A(){const{selectedRowCount:s}=l();async function e(){}return t.jsx(w,{itemName:"Pipeline Snapshot",selectedItemCount:s,onDeleteSelected:e})}function I({params:s}){const{refetch:e}=d({...u.list(s),throwOnError:!0}),{selectedRowCount:a}=l();return t.jsxs("div",{className:"flex items-center justify-between",children:[a?t.jsx(A,{}):t.jsx(F,{searchParams:s}),t.jsxs(D,{intent:"primary",emphasis:"subtle",size:"md",onClick:()=>e(),children:[t.jsx(E,{className:"h-5 w-5 fill-theme-text-brand"}),"Refresh"]})]})}const c=1,L=o.object({page:o.coerce.number().min(c).optional().default(c).catch(c),name:o.string().optional(),operator:o.enum(["and","or"]).optional()});function G(){const[s]=R(),{page:e,name:a,operator:r}=L.parse({page:s.get("page")||void 0,name:s.get("name")||void 0});return{page:e,name:a,logical_operator:r}}function Q(){const{pipelineId:s}=B(),a={...G(),pipeline:s,sort_by:"desc:updated"};return t.jsxs(t.Fragment,{children:[t.jsx(I,{params:a}),t.jsx(k,{params:a})]})}function se(){return t.jsx("div",{className:"space-y-5",children:t.jsx(T,{children:t.jsx(Q,{})})})}export{se as default};
