import{j as e,r as C}from"./vendor-react-wBh_31cN.js";import{R as c,cD as h}from"./index-dNe6i2rS.js";import{B as k}from"./badge-UCnweWGd.js";import{C as S,c as E}from"./card-BeQtvmcJ.js";import{I as K}from"./icon-button-BZeFL7T7.js";import{M as n}from"./metadata-field-Uf1PM1Ss.js";import{S as N}from"./separator-CxqNNMXg.js";import{V as o}from"./value-7N0Keti9.js";import{a as L}from"./time-utils-CQYZ5msB.js";import{ac as B,ad as I}from"./vendor-icons-BUUmD6ht.js";const w=({color:i="black",size:l="12px",className:r,...s})=>e.jsx("span",{className:r,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:l,height:l,backgroundColor:i,borderRadius:"50%",userSelect:"none"},...s}),R=({lastTransitionTime:i,lastUpdateTime:l,message:r,reason:s,type:a,ready:u,age:x})=>{const d=l??i;return e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(w,{color:U({type:a,reason:s,message:r,ready:u}),size:"8px"}),e.jsx("span",{className:"text-sm font-semibold",children:a}),s&&e.jsx(c,{gray:!0,children:s})]}),r&&e.jsx(c,{className:"break-words",children:r}),(d||x)&&e.jsxs(c,{sm:!0,gray:!0,children:[d&&L(d),d&&x&&" · ",x]})]})},U=({type:i,reason:l,message:r,ready:s})=>s||i==="Available"&&l!=="MinimumReplicasUnavailable"?"var(--quartz-primary)":l!=null&&l.includes("Unavailable")||l!=null&&l.includes("NotReady")||r!=null&&r.includes("unready")||r!=null&&r.includes("Unavailable")?"var(--quartz-label-red)":i==="Progressing"||l!=null&&l.includes("Progressing")||l!=null&&l.includes("ReplicaSetUpdated")?"var(--quartz-label-yellow)":"var(--quartz-gray)",D=function({items:i,Component:l}){return e.jsxs("div",{className:"ml-0.5 flex flex-col gap-2 border-l-2 border-border pl-3",children:[i.length===0&&"-",i.map((r,s)=>e.jsx(l,{...r},s))]})},F=({message:i,reason:l,type:r,age:s,from:a})=>e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(w,{color:T({type:r,reason:l}),size:"8px"}),e.jsx("span",{className:"text-sm font-semibold",children:r}),e.jsx(c,{gray:!0,children:l})]}),e.jsx(c,{className:"break-words",children:i}),e.jsxs(c,{sm:!0,gray:!0,children:[s,a&&` · ${a}`]})]}),T=({type:i,reason:l})=>i==="Warning"||l!=null&&l.toLocaleLowerCase().includes("failed")||l!=null&&l.toLocaleLowerCase().includes("unhealthy")?"var(--quartz-label-red)":i==="Normal"?"var(--quartz-primary)":"var(--quartz-gray)",V=({events:i})=>e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(c,{sm:!0,gray:!0,children:"Events"}),e.jsx(D,{items:i,Component:F})]}),$=i=>{const l=i.toLowerCase();return l.includes("running")||l.includes("succeeded")||l.includes("completed")?"success":l.includes("pending")||l.includes("progressing")||l.includes("unknown")?"notice":l.includes("failed")||l.includes("crashloop")||l.includes("error")?"fail":"outline"},A=({name:i,namespace:l,events:r,expandable:s,desiredReplicas:a,lastCondition:u,ready:x,readyReplicas:d,status:j,activePods:p,succeededPods:f,failedPods:b,children:g})=>{const[m,y]=C.useState(!s),v=h(d)&&h(a),z=l||v||p!==void 0||f!==void 0||b!==void 0||h(r==null?void 0:r.items)||g,q=s&&z&&e.jsx(K,{size:"icon-sm",variant:"ghost",onClick:()=>y(M=>!M),"aria-label":m?"Collapse details":"Expand details","aria-expanded":m,children:m?e.jsx(B,{className:"size-4"}):e.jsx(I,{className:"size-4"})}),t=s&&!m;return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[q,e.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-start gap-x-5 gap-y-2",children:[e.jsx(n,{label:"name",children:e.jsx(o,{className:"break-all",children:i??"-"})}),j&&e.jsx(n,{label:"status",children:e.jsx(k,{variant:$(j),children:j})}),!t&&l&&e.jsx(n,{label:"namespace",children:e.jsx(o,{className:"break-all",children:l})}),!t&&v&&e.jsxs(e.Fragment,{children:[e.jsx(N,{orientation:"vertical",className:"h-9"}),e.jsx(n,{label:"pod readiness",children:e.jsx(o,{children:`${d}/${a}`})})]}),!t&&p!==void 0&&e.jsx(n,{label:"active pods",children:e.jsx(o,{children:p})}),!t&&f!==void 0&&e.jsx(n,{label:"succeeded pods",children:e.jsx(o,{children:f})}),!t&&b!==void 0&&e.jsx(n,{label:"failed pods",children:e.jsx(o,{children:b})})]})]}),!t&&u&&e.jsx(n,{label:"condition",children:e.jsx(R,{...u,ready:x})}),!t&&h(r==null?void 0:r.items)&&e.jsxs(e.Fragment,{children:[e.jsx(N,{}),e.jsx(V,{events:r.items})]}),!t&&g]})},O=C.memo(({title:i,withBorder:l=!1,...r})=>{const s=i&&e.jsx("h2",{className:"text-base font-semibold leading-none",children:i});return e.jsx(S,{variant:l?"default":"muted",children:e.jsxs(E,{className:"flex flex-col gap-3 p-4",children:[s,e.jsx(A,{...r})]})})}),ee=({pods:i})=>e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(c,{sm:!0,gray:!0,children:"Pods"}),e.jsx("div",{className:"flex flex-col gap-3",children:i.map(l=>e.jsx(O,{expandable:i.length>1,withBorder:!0,...l},l.name))})]});export{O as K,ee as a};
