import{j as s}from"./@radix-DAoBbclx.js";import{P as g}from"./Pagination-hLnXxv_M.js";import{aG as x,e as m,a4 as j,B as y,bd as v,r as u,a1 as p,b9 as S,aH as D,aJ as b,aK as N}from"./index-DnCFURX3.js";import{b as h}from"./@tanstack-2852wz5w.js";import{S as C}from"./refresh-DhdtzFSJ.js";import{c as P}from"./helper-CKgq8caL.js";import{S as w}from"./SearchField-CVlpmsG6.js";import{B as F}from"./button-group-basic-B-kwcZSw.js";import{f as R,L as d}from"./@react-router-BTai9D5g.js";import{z as o}from"./@zod-3snSrKBm.js";import{D as T}from"./deployment-status-tag-DXByBKnK.js";import{P as k}from"./pipeline-link-n7S1rP3v.js";const{ContextProvider:q,useContext:c}=P();function M({params:t,columns:e}){const{rowSelection:r,setRowSelection:a}=c(),n=h({...x.list(t),throwOnError:!0});if(n.isPending)return s.jsxs("div",{className:"flex flex-col items-center gap-5",children:[s.jsx("div",{className:"w-full",children:s.jsx(m,{className:"h-[500px] w-full"})}),s.jsx(m,{className:"h-[36px] w-[300px]"})]});if(n.isError)return s.jsx("p",{children:"Error fetching deployments"});const i=n.data;return s.jsxs("div",{className:"flex flex-col items-center gap-5",children:[s.jsx("div",{className:"w-full",children:s.jsx(j,{columns:e,data:i.items,rowSelection:r,onRowSelectionChange:a,getRowId:f=>f.id})}),i.total_pages>1&&s.jsx(g,{searchParams:t,paginate:i})]})}function B(){const{selectedRowCount:t}=c();async function e(){}return s.jsx(F,{itemName:"Pipeline Snapshot",selectedItemCount:t,onDeleteSelected:e})}function V({params:t}){const{refetch:e}=h({...x.list(t),throwOnError:!0}),{selectedRowCount:r}=c();return s.jsxs("div",{className:"flex items-center justify-between",children:[r?s.jsx(B,{}):s.jsx(w,{searchParams:t}),s.jsxs(y,{intent:"primary",emphasis:"subtle",size:"md",onClick:()=>e(),children:[s.jsx(C,{className:"h-5 w-5 fill-theme-text-brand"}),"Refresh"]})]})}const l=1,E=o.object({page:o.coerce.number().min(l).optional().default(l).catch(l),name:o.string().optional(),operator:o.enum(["and","or"]).optional()});function W(){const[t]=R(),{page:e,name:r,operator:a}=E.parse({page:t.get("page")||void 0,name:t.get("name")||void 0});return{page:e,name:r,logical_operator:a}}function X(){return{id:"name",header:"Deployment",accessorFn:t=>t.name,cell:({row:t})=>{const e=t.original.name,r=t.original.id;return s.jsxs("div",{className:"group/copybutton flex min-w-[10rem] items-center gap-2",children:[s.jsx(v,{className:"h-5 w-5 shrink-0 fill-primary-400"}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(d,{to:u.projects.deployments.detail.overview(r),className:"grid grid-cols-1 items-center gap-1",children:s.jsx("span",{className:"truncate text-text-md font-semibold text-theme-text-primary",children:e??"Unnamed"})}),s.jsx(p,{copyText:e??""})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(d,{to:u.projects.deployments.detail.overview(r),className:"flex items-center gap-1",children:s.jsx("p",{className:"text-text-xs text-theme-text-secondary",children:S(r)})}),s.jsx(p,{copyText:r})]})]})]})}}}function Y(){return{id:"status",header:"Status",accessorFn:t=>{var e;return(e=t.body)==null?void 0:e.status},cell:({row:t})=>{var r;const e=(r=t.original.body)==null?void 0:r.status;return e?s.jsx(T,{size:"sm",status:e}):s.jsx("div",{children:"No status"})}}}function Z(){return{id:"pipeline",header:"Pipeline",accessorFn:t=>{var e,r;return(r=(e=t.resources)==null?void 0:e.pipeline)==null?void 0:r.name},cell:({row:t})=>{var r;const e=(r=t.original.resources)==null?void 0:r.pipeline;return e?s.jsx(k,{pipelineId:e.id,pipelineName:e.name}):null}}}function $(){return{id:"snapshot",header:"Snapshot",accessorFn:t=>{var e,r;return(r=(e=t.resources)==null?void 0:e.snapshot)==null?void 0:r.name},cell:({row:t})=>{var n;const e=(n=t.original.resources)==null?void 0:n.snapshot,r=e==null?void 0:e.name,a=e==null?void 0:e.id;return!r||!a?null:s.jsx(D,{size:"sm",snapshotId:a,snapshotName:r})}}}function ee(){return{id:"author",header:"Author",accessorFn:t=>{var e,r;return(r=(e=t.resources)==null?void 0:e.user)==null?void 0:r.name},cell:({row:t})=>{var r,a,n;const e=(r=t.original.resources)==null?void 0:r.user;return e?s.jsx(b,{username:e.name,isServiceAccount:!!((a=e.body)!=null&&a.is_service_account),avatarUrl:((n=e.body)==null?void 0:n.avatar_url)??void 0}):null}}}function te(){return{id:"created",header:"Created at",accessorFn:t=>{var e;return{date:(e=t.body)==null?void 0:e.created}},cell:({getValue:t})=>{const{date:e}=t();return s.jsx(N,{dateString:e})}}}export{V as D,M as P,Y as a,$ as b,X as c,ee as d,te as e,q as f,Z as g,W as u};
