import{j as e,L as p,r as i,s as m}from"./vendor-tanstack-BVzzyDEt.js";import{E as g,m as C,n as f,o as y,p as N,q as x,I as u,D as k,r as W,s as S,t as P,u as v,v as d,w as o,W as E,x as D,y as b,A as I,C as T,F as _,G as L,H as A,J as M,K as O,M as R,N as z,O as w,P as $}from"./index-BJkJ93Lr.js";import{W as F}from"./header-qLx9chqd.js";import{S as B}from"./index-HTfhyme4.js";import"./vendor-react-Bce9NwRC.js";import"./vendor-radix-CTAic6HB.js";import"./vendor-recharts-Mwm2qLZp.js";import"./vendor-forms-BN3tpxM2.js";import"./vendor-date-2jFo9aCm.js";const K=()=>e.jsxs(g,{children:[e.jsx(C,{id:"Cpu"}),e.jsx(f,{children:"Add a work pool to get started"}),e.jsx(y,{children:"Work pools allow you to prioritize and manage deployments and control the infrastructure they run on."}),e.jsxs(N,{children:[e.jsx(p,{to:"/work-pools/create",children:e.jsxs(x,{children:["Add Work Pool ",e.jsx(u,{id:"Plus",className:"size-4 ml-2"})]})}),e.jsx(k,{id:"work-pools-guide"})]})]}),H=({workPool:s,onDelete:n})=>{const a=r=>{navigator.clipboard.writeText(r),o.success("ID copied")};return e.jsxs(W,{children:[e.jsx(S,{asChild:!0,children:e.jsxs(x,{variant:"outline",className:"size-8 p-0",children:[e.jsx("span",{className:"sr-only",children:"Open menu"}),e.jsx(u,{id:"MoreVertical",className:"size-4"})]})}),e.jsxs(P,{align:"end",children:[e.jsx(v,{children:"Actions"}),e.jsx(d,{onClick:()=>a(s.id),children:"Copy ID"}),e.jsx(p,{to:"/work-pools/work-pool/$workPoolName/edit",params:{workPoolName:s.name},children:e.jsx(d,{children:"Edit"})}),e.jsx(d,{onClick:n,children:"Delete"})]})]})},Q=({workPoolName:s})=>e.jsx(E,{workPoolName:s}),U=({workPool:s})=>{const[n,a]=i.useState(s.status==="PAUSED"),{pauseWorkPool:r,isPending:c}=D(),{resumeWorkPool:l,isPending:t}=b(),j=i.useMemo(()=>c||t,[c,t]),h=()=>{n?l(s.name,{onSuccess:()=>{a(!1),o.success(`${s.name} resumed`)},onError:()=>{o.error(`Failed to resume ${s.name}`)}}):r(s.name,{onSuccess:()=>{a(!0),o.success(`${s.name} paused`)},onError:()=>{o.error(`Failed to pause ${s.name}`)}})};return e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:n?"Paused":"Active"}),e.jsx(I,{checked:!n,onCheckedChange:h,disabled:j,"aria-label":n?"Resume work pool":"Pause work pool"})]})},q={process:"Process",ecs:"ECS","azure-container-instance":"Azure Container Instance",docker:"Docker","cloud-run":"Cloud Run","cloud-run-v2":"Cloud Run v2","vertex-ai":"Vertex AI",kubernetes:"Kubernetes"},J={process:"Cpu",ecs:"Cpu","azure-container-instance":"Cpu",docker:"Cpu","cloud-run":"Cpu","cloud-run-v2":"Cpu","vertex-ai":"Cpu",kubernetes:"Cpu"},V=s=>q[s]??s,Y=s=>J[s]??"Cpu",G=({type:s})=>e.jsxs(T,{children:[e.jsx(u,{id:Y(s)}),V(s)]}),X=({workPool:s})=>{const{deleteWorkPool:n}=_(),a=()=>{n(s.name,{onSuccess:()=>{o.success(`${s.name} deleted`)},onError:r=>{o.error(`Failed to delete work pool: ${r instanceof Error?r.message:"Unknown error"}`)}})};return e.jsxs(L,{className:"gap-2",children:[e.jsxs(A,{className:"flex flex-row items-center justify-between",children:[e.jsxs(M,{className:"flex items-center gap-2",children:[e.jsx(Q,{workPoolName:s.name}),s.status&&e.jsx(B,{status:s.status})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{workPool:s}),e.jsx(H,{workPool:s,onDelete:a})]})]}),e.jsxs(O,{className:"flex flex-col gap-1",children:[e.jsx("div",{className:"flex items-center gap-1",children:e.jsx(G,{type:s.type})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Concurrency:"," ",e.jsx("span",{className:"text-foreground",children:s.concurrency_limit?s.concurrency_limit:"Unlimited"})]})]})]})};function ie(){const[s,n]=i.useState(""),{data:a=0}=m(R()),{data:r=[]}=m(z({limit:200,offset:0})),c=i.useMemo(()=>r.filter(t=>[t.name,t.description,t.type,JSON.stringify(t.base_job_template),t.id,t.default_queue_id,t.status].join(" ").toLowerCase().includes(s.toLowerCase())),[r,s]),l=t=>{n(t.target.value)};return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(F,{}),a<1?e.jsx(K,{}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:[a," ",w(a,"work pool")]}),e.jsx("div",{className:"flex gap-2",children:e.jsx($,{placeholder:"Search work pools...",value:s,onChange:l})})]}),e.jsx("div",{className:"flex flex-col gap-4",children:c.map(t=>e.jsx(X,{workPool:t},t.id))})]})]})}export{ie as component};
//# sourceMappingURL=index-Rg7xaFlb.js.map
