21 lines
231 KiB
JavaScript
21 lines
231 KiB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PodFileBrowser-CVjj8HxI.js","assets/vendor-codemirror-B1SGo4xl.js","assets/index-Bp-M7P_8.js","assets/vendor-icons-BWk-DH7F.js","assets/index-6V28XIIj.css","assets/use-toast-DNZLibQY.js","assets/index-BkulU9RM.js","assets/k8s-yaml-utils-4KZB_Bq_.js","assets/select-DbhcBWnH.js","assets/index-5FEebgvX.js","assets/vendor-xterm-20M9KZE1.js","assets/vendor-xterm-DXOU9pbP.css","assets/badge-B00SZHvE.js"])))=>i.map(i=>d[i]);
|
||
import{j as e,r as p}from"./vendor-codemirror-B1SGo4xl.js";import{B as b,f as ot,o as ft,i as es,ae as Cs,g as Es}from"./index-Bp-M7P_8.js";import{C as W,a as G,b as me,c as xe}from"./card-BHSBTtub.js";import{B as ne}from"./badge-B00SZHvE.js";import{k as X}from"./index-BkulU9RM.js";import{u as Te}from"./use-toast-DNZLibQY.js";import{p as ws,h as $t,Y as mt,P as Ds,a as Ps}from"./PodFileBrowser-CVjj8HxI.js";import{I as v}from"./input-Bnlm--la.js";import{S as Ce,e as As,f as at,a as Ts,s as xt}from"./k8s-yaml-utils-4KZB_Bq_.js";import{E as Hs,n as Ms}from"./EventTable-D9T7PrIy.js";import{Q as ts,f as ss,F as St,r as ns,H as os,o as Bs,L as be,N as Ae,E as Rs,A as as,b as rs,n as Is,k as $e,P as Q,aq as Os,s as Ct,b8 as Ls,aK as cs,b9 as ht,T as he,$ as rt,g as zs,ba as _s,a4 as ls,j as ds,am as $s,aU as is,bb as Ws,z as ps,R as We,D as Xe,b2 as Gs,h as Et,aW as Vs,aV as Fs,G as qs,M as Ys,p as kt,y as gt,d as Wt,J as ut,X as ms,l as xs,a as Us,m as Js,aD as Gt,bc as Ks,ar as Xs}from"./vendor-icons-BWk-DH7F.js";import{T as Le,a as ze,b as Ee,c as re,d as _e,e as ce}from"./table-u8V9iTZf.js";import{L as M}from"./label-NkONM5Mp.js";import{T as Qe}from"./textarea-BvOVhaCD.js";import{S as Ze,a as et,b as tt,c as st,d as ge}from"./select-DbhcBWnH.js";import{S as wt}from"./switch-CEwFnSNV.js";import{R as hs}from"./ResourceVisualEditor-B64kRCHd.js";import"./vendor-xterm-20M9KZE1.js";import"./index-5FEebgvX.js";function us(t){const s=t.conditions||t.pod_conditions||[],a=n=>s.find(l=>(l.type||l.Type)===n),o=n=>n?.lastTransitionTime||n?.LastTransitionTime||n?.last_transition_time;return{scheduled:o(a("PodScheduled")||{}),initialized:o(a("Initialized")||{}),containersReady:o(a("ContainersReady")||{}),ready:o(a("Ready")||{}),startTime:t.start_time||t.startTime}}function Be({label:t,value:s}){return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:25:5",children:[e.jsx("p",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:26:7",className:"text-xs text-[var(--dg-text-muted)] mb-1",children:t}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:27:7",className:"text-sm text-[var(--dg-text-primary)]",children:s})]})}function bs({pod:t}){const s=us(t),a=[{label:"已调度",ts:s.scheduled,color:Ce.blue},{label:"已初始化",ts:s.initialized,color:Ce.orange},{label:"容器已就绪",ts:s.containersReady,color:Ce.green},{label:"容器组已就绪",ts:s.ready,color:Ce.green}];return e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:42:5",className:"flex items-center gap-2 overflow-x-auto",children:a.map((o,n)=>{const l=a[n-1],c=As(l?.ts,o.ts);return e.jsxs(p.Fragment,{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:47:11",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:48:13",className:"flex flex-col items-center min-w-[80px]",children:[e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:49:15",className:"h-2 w-2 rounded-full",style:{background:o.ts?o.color:"#334155"}}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:50:15",className:"text-[10px] mt-1 font-medium",style:{color:o.ts?o.color:"#475569"},children:o.label}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:51:15",className:"text-[9px] text-[var(--dg-text-muted)]",children:o.ts?at(o.ts):"-"})]}),n<a.length-1&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:54:15",className:"flex flex-col items-center mx-0.5 min-w-[30px]",children:[e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:55:17",className:"h-0.5 w-8 bg-[var(--dg-border)]"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:56:17",className:"text-[9px] text-[var(--dg-text-muted)] mt-0.5",children:c!=null?Ts(c):""})]})]},o.label)})})}function Qs({clusterCode:t,pods:s,onShowPodLogs:a,onShowPodTerminal:o,onShowPodYaml:n,onShowPodFileBrowser:l,expandedPod:c,setExpandedPod:m}){return s.length===0?e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:17:12",className:"text-center text-[var(--dg-text-muted)] py-12",children:"暂无容器组"}):e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:20:5",className:"space-y-2",children:s.map(u=>{const d=us(u),k=c===u.name,w=u.node_name||u.node;return e.jsx(W,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:26:11",className:"dg-card",children:e.jsxs(G,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:27:13",className:"p-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:29:15",className:"flex items-center gap-3",children:[e.jsx(b,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:30:17",variant:"ghost",size:"icon",className:"h-6 w-6 text-[var(--dg-text-muted)]",onClick:()=>m(k?null:u.name),children:k?e.jsx(ts,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:31:31",className:"h-4 w-4"}):e.jsx(ss,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:31:69",className:"h-4 w-4"})}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:33:17",className:"font-mono text-sm text-[var(--dg-text-primary)]",children:u.name}),e.jsx(ne,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:34:17",style:{background:`${xt(u.status)}22`,color:xt(u.status),border:`1px solid ${xt(u.status)}44`},children:u.status||"Unknown"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:37:17",className:"text-xs text-[var(--dg-text-muted)]",children:e.jsx("button",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:38:19",className:"text-[var(--dg-blue)] hover:underline mr-2",onClick:()=>window.open(`/kubernetes/${t}/nodes/${w}`,"_blank"),children:w||"-"})}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:42:17",className:"text-xs font-mono text-[var(--dg-text-muted)]",children:u.ip||u.pod_ip||"-"}),e.jsxs("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:43:17",className:"text-xs text-[var(--dg-text-muted)]",children:["重启 ",u.restart_count||0," 次"]}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:44:17",className:"text-xs text-[var(--dg-text-muted)]",children:at(d.startTime||u.created_at)}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:45:17",className:"flex-1"}),e.jsxs(b,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:46:17",variant:"ghost",size:"sm",className:"h-7 text-xs text-[var(--dg-blue)]",onClick:()=>a(u),children:[e.jsx(St,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:47:19",className:"h-3.5 w-3.5 mr-1"}),"日志"]}),e.jsxs(b,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:49:17",variant:"ghost",size:"sm",className:"h-7 text-xs text-emerald-400",onClick:()=>o(u),children:[e.jsx(ns,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:50:19",className:"h-3.5 w-3.5 mr-1"}),"终端"]}),e.jsxs(b,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:52:17",variant:"ghost",size:"sm",className:"h-7 text-xs text-amber-400",onClick:()=>l(u),children:[e.jsx(os,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:53:19",className:"h-3.5 w-3.5 mr-1"}),"文件"]}),e.jsxs(b,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:55:17",variant:"ghost",size:"sm",className:"h-7 text-xs text-slate-400 hover:text-blue-400",onClick:()=>n(u),children:[e.jsx(Bs,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:56:19",className:"h-3.5 w-3.5 mr-1"}),"YAML"]})]}),k&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:61:17",className:"mt-3 pt-3 border-t border-[var(--dg-border)]",children:[e.jsx(bs,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:62:19",pod:u}),u.containers&&u.containers.length>0&&e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:65:21",className:"mt-3 grid grid-cols-1 md:grid-cols-2 gap-2",children:u.containers.map((E,y)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:67:25",className:"p-2 rounded bg-[var(--dg-bg-tertiary)] text-xs",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:68:27",className:"flex items-center justify-between",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:69:29",className:"font-medium text-[var(--dg-text-primary)]",children:E.name}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:70:29",className:E.ready?"text-emerald-400":"text-[var(--dg-text-muted)]",children:E.ready?"Ready":"Pending"})]}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:72:27",className:"text-[var(--dg-text-muted)] mt-1",children:E.image}),E.resources&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:74:29",className:"mt-1 flex gap-3",children:[e.jsxs("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:75:31",children:["CPU: ",E.resources?.requests?.cpu||"0","/",E.resources?.limits?.cpu||"-"," m"]}),e.jsxs("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:76:31",children:["内存: ",E.resources?.requests?.memory||"0","/",E.resources?.limits?.memory||"-"]})]})]},y))})]})]})},u.name)})})}function Zs({services:t,ingresses:s,loading:a}){return a==="services"?e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:11:12",className:"flex items-center justify-center py-12",children:e.jsx(be,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:11:68",className:"h-6 w-6 animate-spin text-[var(--dg-text-muted)]"})}):e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:14:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:16:7",children:[e.jsxs("h3",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:17:9",className:"text-sm font-semibold text-[var(--dg-text-primary)] mb-3 flex items-center gap-2",children:[e.jsx(Ae,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:18:11",className:"h-4 w-4 text-[var(--dg-blue)]"}),"关联 Service"]}),t.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:21:11",className:"text-sm text-[var(--dg-text-muted)] py-4",children:"暂无匹配的 Service(Deployment 选择器未关联任何 Service)"}):e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:23:11",className:"overflow-x-auto",children:e.jsxs(Le,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:24:13",children:[e.jsx(ze,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:25:15",children:e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:26:17",className:"border-[var(--dg-border)]",children:[e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:27:19",className:"text-[var(--dg-text-muted)]",children:"名称"}),e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:28:19",className:"text-[var(--dg-text-muted)]",children:"类型"}),e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:29:19",className:"text-[var(--dg-text-muted)]",children:"ClusterIP"}),e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:30:19",className:"text-[var(--dg-text-muted)]",children:"端口"}),e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:31:19",className:"text-[var(--dg-text-muted)]",children:"Selector"})]})}),e.jsx(_e,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:34:15",children:t.map(o=>e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:36:19",className:"border-[var(--dg-border)]",children:[e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:37:21",className:"font-medium text-[var(--dg-text-primary)]",children:o.name}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:38:21",children:e.jsx(ne,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:38:32",variant:"outline",className:"text-xs",children:o.type})}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:39:21",className:"font-mono text-sm text-[var(--dg-text-muted)]",children:o.clusterIP}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:40:21",className:"text-sm text-[var(--dg-text-muted)]",children:o.ports.join(", ")}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:41:21",className:"text-xs text-[var(--dg-text-muted)]",children:Object.entries(o.selector).map(([n,l])=>e.jsxs("code",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:43:25",className:"mr-1 bg-[var(--dg-bg-tertiary)] px-1 rounded",children:[n,"=",l]},n))})]},o.name))})]})})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:55:7",children:[e.jsxs("h3",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:56:9",className:"text-sm font-semibold text-[var(--dg-text-primary)] mb-3 flex items-center gap-2",children:[e.jsx(Rs,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:57:11",className:"h-4 w-4 text-[var(--dg-purple)]"}),"关联 Ingress"]}),s.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:60:11",className:"text-sm text-[var(--dg-text-muted)] py-4",children:"暂无匹配的 Ingress"}):e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:62:11",className:"overflow-x-auto",children:e.jsxs(Le,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:63:13",children:[e.jsx(ze,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:64:15",children:e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:65:17",className:"border-[var(--dg-border)]",children:[e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:66:19",className:"text-[var(--dg-text-muted)]",children:"名称"}),e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:67:19",className:"text-[var(--dg-text-muted)]",children:"Class"}),e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:68:19",className:"text-[var(--dg-text-muted)]",children:"Host"}),e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:69:19",className:"text-[var(--dg-text-muted)]",children:"路径"})]})}),e.jsx(_e,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:72:15",children:s.map(o=>e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:74:19",className:"border-[var(--dg-border)]",children:[e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:75:21",className:"font-medium text-[var(--dg-text-primary)]",children:o.name}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:76:21",className:"text-sm text-[var(--dg-text-muted)]",children:o.className}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:77:21",className:"text-sm text-[var(--dg-text-muted)]",children:o.hosts.join(", ")}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:78:21",className:"text-xs text-[var(--dg-text-muted)]",children:o.rules.flatMap(n=>(n.http?.paths||n.paths||[]).map(l=>l.path||"/")).join(", ")})]},o.name))})]})})]})]})}function en({events:t,loading:s}){return e.jsx(Hs,{"code-path":"src/components/kubernetes/deployment-view/EventsTab.tsx:7:5",events:t,loading:s,emptyText:"暂无事件"})}function tn({hpas:t,cronHpas:s,loading:a,replicas:o}){return a==="scale"?e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:12:12",className:"flex items-center justify-center py-12",children:e.jsx(be,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:12:68",className:"h-6 w-6 animate-spin text-[var(--dg-text-muted)]"})}):e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:16:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:18:7",className:"flex items-center gap-2 px-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:19:9",className:"text-sm text-[var(--dg-text-muted)]",children:"当前副本:"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:20:9",className:"text-sm font-bold text-[var(--dg-text-primary)]",children:o}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:21:9",className:"text-xs text-[var(--dg-text-muted)]",children:"(可通过 Tab 栏右侧 +/- 手动调整)"})]}),e.jsxs(W,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:25:7",className:"dg-card",children:[e.jsx(me,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:26:9",className:"pb-2",children:e.jsxs(xe,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:26:38",className:"text-sm flex items-center gap-2",children:[e.jsx(as,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:26:93",className:"h-4 w-4 text-[var(--dg-orange)]"}),"HPA — 水平自动伸缩"]})}),e.jsx(G,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:27:9",children:t.length===0?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:29:13",className:"text-sm text-[var(--dg-text-muted)] py-4",children:["未关联 HPA — ",e.jsx(b,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:30:25",variant:"link",className:"h-auto p-0 text-[var(--dg-blue)] text-sm",children:"创建 HPA"})]}):e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:33:13",className:"overflow-x-auto",children:e.jsxs(Le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:34:15",children:[e.jsx(ze,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:35:17",children:e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:36:19",className:"border-[var(--dg-border)]",children:[e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:37:21",className:"text-[var(--dg-text-muted)]",children:"名称"}),e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:38:21",className:"text-[var(--dg-text-muted)]",children:"最小/最大"}),e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:39:21",className:"text-[var(--dg-text-muted)]",children:"指标"}),e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:40:21",className:"text-[var(--dg-text-muted)]",children:"当前负载"}),e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:41:21",className:"text-[var(--dg-text-muted)]",children:"状态"})]})}),e.jsx(_e,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:44:17",children:t.map((n,l)=>{const c=n.spec?.minReplicas??n.minReplicas??1,m=n.spec?.maxReplicas??n.maxReplicas??10,u=n.spec?.metrics||n.metrics||[],d=n.status?.currentReplicas??n.currentReplicas??0,E=(n.status?.conditions||n.conditions||[]).find(y=>y.type==="AbleToScale")?.status==="True";return e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:54:23",className:"border-[var(--dg-border)]",children:[e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:55:25",className:"font-medium text-[var(--dg-text-primary)]",children:n.name||n.metadata?.name}),e.jsxs(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:56:25",className:"text-sm text-[var(--dg-text-secondary)] font-mono",children:[c," → ",m]}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:57:25",className:"text-xs text-[var(--dg-text-muted)]",children:u.map((y,S)=>{const C=y.resource||y.object?.metric?.name||"",D=y.resource?.target?.averageUtilization||y.resource?.target?.averageValue||y.resource?.target?.type||"-";return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:61:36",children:[C?.name||C,": ",D,y.resource?.target?.averageUtilization?"%":""]},S)})}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:64:25",className:"text-sm font-mono text-[var(--dg-text-secondary)]",children:d}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:65:25",children:e.jsx(ne,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:66:27",className:E?"bg-[var(--dg-green)]/20 text-[var(--dg-green)]":"bg-[var(--dg-red)]/20 text-[var(--dg-red)]",children:E?"正常":"异常"})})]},n.name||l)})})]})})})]}),e.jsxs(W,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:81:7",className:"dg-card",children:[e.jsx(me,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:82:9",className:"pb-2",children:e.jsxs(xe,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:82:38",className:"text-sm flex items-center gap-2",children:[e.jsx(rs,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:82:93",className:"h-4 w-4 text-[var(--dg-blue)]"}),"CronHPA — 定时伸缩"]})}),e.jsx(G,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:83:9",children:s.length===0?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:85:13",className:"text-sm text-[var(--dg-text-muted)] py-4",children:["未关联 CronHPA — ",e.jsx(b,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:86:29",variant:"link",className:"h-auto p-0 text-[var(--dg-blue)] text-sm",children:"创建 CronHPA"})]}):e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:89:13",className:"overflow-x-auto",children:e.jsxs(Le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:90:15",children:[e.jsx(ze,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:91:17",children:e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:92:19",className:"border-[var(--dg-border)]",children:[e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:93:21",className:"text-[var(--dg-text-muted)]",children:"名称"}),e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:94:21",className:"text-[var(--dg-text-muted)]",children:"目标副本"}),e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:95:21",className:"text-[var(--dg-text-muted)]",children:"调度规则"}),e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:96:21",className:"text-[var(--dg-text-muted)]",children:"时区"}),e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:97:21",className:"text-[var(--dg-text-muted)]",children:"状态"})]})}),e.jsx(_e,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:100:17",children:s.map((n,l)=>{const c=n.spec?.jobs||n.jobs||[],m=n.spec?.timezone||"UTC";return e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:105:23",className:"border-[var(--dg-border)]",children:[e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:106:25",className:"font-medium text-[var(--dg-text-primary)]",children:n.name||n.metadata?.name}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:107:25",className:"text-sm text-[var(--dg-text-secondary)]",children:c.map(u=>u.targetSize||u.targetReplicas||"?").join(", ")}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:110:25",className:"text-xs font-mono text-[var(--dg-text-muted)]",children:c.map(u=>u.schedule||"?").join(", ")}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:111:25",className:"text-xs text-[var(--dg-text-muted)]",children:m}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:112:25",children:e.jsx(ne,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:113:27",className:"bg-[var(--dg-green)]/20 text-[var(--dg-green)]",children:"已启用"})})]},n.name||l)})})]})})})]})]})}function sn({revisions:t,rollbackLoading:s,onRollback:a}){return t.length===0?e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:12:12",className:"text-center text-[var(--dg-text-muted)] py-12",children:"暂无历史版本"}):e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:15:5",className:"overflow-x-auto",children:e.jsxs(Le,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:16:7",children:[e.jsx(ze,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:17:9",children:e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:18:11",className:"border-[var(--dg-border)]",children:[e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:19:13",className:"text-[var(--dg-text-muted)] w-24",children:"Revision"}),e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:20:13",className:"text-[var(--dg-text-muted)]",children:"镜像"}),e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:21:13",className:"text-[var(--dg-text-muted)] w-24",children:"状态"}),e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:22:13",className:"text-[var(--dg-text-muted)] w-40",children:"更新时间"}),e.jsx(re,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:23:13",className:"text-[var(--dg-text-muted)] w-24",children:"操作"})]})}),e.jsx(_e,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:26:9",children:t.map((o,n)=>{const l=o.revision??o.revision_number??o.number??n+1,c=n===0;return e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:31:15",className:"border-[var(--dg-border)]",children:[e.jsxs(ce,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:32:17",className:"font-mono text-[var(--dg-text-primary)]",children:["#",l]}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:33:17",className:"text-xs font-mono text-[var(--dg-text-muted)] max-w-[300px] truncate",children:o.image||o.images?.[0]||"-"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:34:17",children:c?e.jsx(ne,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:36:23",className:"bg-[var(--dg-green)]/20 text-[var(--dg-green)] border-[var(--dg-green)]/30",children:"当前"}):e.jsx(ne,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:37:23",variant:"outline",className:"text-[var(--dg-text-muted)]",children:"历史"})}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:39:17",className:"text-xs text-[var(--dg-text-muted)]",children:at(o.created_at||o.time)}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:40:17",children:e.jsxs(b,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:41:19",variant:"ghost",size:"sm",className:"h-7 text-amber-400",disabled:c||s!==null,onClick:()=>a(o),children:[s===l?e.jsx(be,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:42:53",className:"h-3 w-3 animate-spin mr-1"}):e.jsx(Is,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:42:105",className:"h-3 w-3 mr-1"}),"回滚"]})})]},l)})})]})})}function nn(t){const{clusterCode:s,namespace:a,deployment:o,pods:n,revisions:l,onRefresh:c}=t,{toast:m}=Te(),u=ot(),[d,k]=p.useState("pods"),[w,E]=p.useState(null),[y,S]=p.useState(null),[C,D]=p.useState(o?.replicas||0),[z,I]=p.useState(!1),[Y,U]=p.useState([]),[Z,_]=p.useState([]),[V,F]=p.useState([]),[J,ee]=p.useState(""),[g,O]=p.useState([]),[q,K]=p.useState([]),le=o?.ready_replicas??o?.readyReplicas??0,ue=o?.replicas??0,ke=le===ue&&ue>0;p.useEffect(()=>{d==="services"&&(ee("services"),Promise.all([X.getNamespaceServices(s,a).catch(()=>[]),X.getNamespaceIngresses(s,a).catch(()=>[])]).then(([r,h])=>{const j=R=>Array.isArray(R)?R:R?.list||R?.items||R?.data||[],N=j(r),P=j(h),H=o?.spec?.selector?.matchLabels||o?.spec?.template?.metadata?.labels||{},de=N.filter(R=>{const oe=R.spec?.selector||R.selector||{};return Object.keys(oe).length===0?!1:Object.entries(oe).every(([Ne,fe])=>H[Ne]===fe)}).map(R=>({name:R.name||R.metadata?.name,type:R.spec?.type||R.type||"ClusterIP",clusterIP:R.spec?.clusterIP||R.cluster_ip||"<none>",ports:(R.spec?.ports||R.ports||[]).map(oe=>`${oe.port}${oe.targetPort?":"+oe.targetPort:""}/${oe.protocol||"TCP"}`),selector:R.spec?.selector||R.selector||{},age:R.age||""})),we=new Set(de.map(R=>R.name)),pe=P.filter(R=>(R.spec?.rules||R.rules||[]).some(Ne=>(Ne.http?.paths||Ne.paths||[]).some(fe=>{const A=fe.backend?.service?.name||fe.backendService||"";return we.has(A)}))).map(R=>({name:R.name||R.metadata?.name,className:R.spec?.ingressClassName||R.ingressClass||"-",hosts:(R.spec?.rules||R.rules||[]).map(oe=>oe.host).filter(Boolean),rules:R.spec?.rules||R.rules||[],age:R.age||""}));U(de),_(pe)}).catch(()=>{}).finally(()=>ee("")))},[d,s,a,o]),p.useEffect(()=>{d==="events"&&(ee("events"),X.getEvents(s,a,void 0).then(r=>{const h=Array.isArray(r)?r:r?.list||r?.items||r?.data||[],j=o?.name||"",N=h.filter(P=>{const H=String(P.object||"");if(!j||!H)return!1;if(H.endsWith(`/${j}`))return!0;const de=H.split("/").pop()||"";return de===j||de.startsWith(`${j}-`)}).map(P=>Ms(P));F(N)}).catch(()=>{}).finally(()=>ee("")))},[d,s,a,o?.name]),p.useEffect(()=>{d==="scale"&&(ee("scale"),Promise.all([X.getHPAs(s,a).catch(()=>[]),Promise.resolve([])]).then(([r])=>{const j=(P=>Array.isArray(P)?P:P?.list||P?.items||P?.data||[])(r),N=o?.name||"";O(j.filter(P=>(P.scaleTargetRef?.name||P.targetRef?.name||"")===N)),K([])}).catch(()=>{}).finally(()=>ee("")))},[d,s,a,o?.name]);const B=async r=>{const h=r.revision??r.revision_number??r.number;if(await u({title:"回滚版本",description:`确认回滚到修订版本 #${h}?`,confirmText:"回滚",variant:"destructive"})){S(h);try{await X.rollbackDeployment(s,a,o.name,Number(h)),m({title:"回滚已下发",description:`正在回滚到 #${h}`}),c()}catch(N){m({title:"回滚失败",description:N?.message||String(N),variant:"destructive"})}finally{S(null)}}},i=async()=>{I(!0);try{await X.scaleDeployment(s,a,o.name,C),m({title:"伸缩已提交",description:`副本数 → ${C}`}),c()}catch(r){m({title:"伸缩失败",description:r?.message||String(r),variant:"destructive"})}finally{I(!1)}},x=[{key:"pods",label:"容器组",icon:$e,count:n.length},{key:"services",label:"访问方式",icon:Ae,count:Y.length},{key:"events",label:"事件",icon:as,count:V.length},{key:"scale",label:"容器伸缩",icon:Q},{key:"history",label:"历史版本",icon:Os,count:l.length}];return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentView.tsx:177:5",className:"space-y-4",children:[e.jsx(W,{"code-path":"src/components/kubernetes/DeploymentView.tsx:179:7",className:"dg-card",children:e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentView.tsx:180:9",className:"p-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentView.tsx:181:11",className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3 text-sm",children:[e.jsx(Be,{"code-path":"src/components/kubernetes/DeploymentView.tsx:182:13",label:"状态",value:e.jsx(ne,{"code-path":"src/components/kubernetes/DeploymentView.tsx:183:15",style:{background:`${ke?Ce.green:Ce.orange}22`,color:ke?Ce.green:Ce.orange,border:`1px solid ${ke?Ce.green:Ce.orange}44`},children:ke?"Running":"Updating"})}),e.jsx(Be,{"code-path":"src/components/kubernetes/DeploymentView.tsx:187:13",label:"副本",value:e.jsxs("span",{"code-path":"src/components/kubernetes/DeploymentView.tsx:187:41",className:"font-mono",children:[le,"/",ue]})}),e.jsx(Be,{"code-path":"src/components/kubernetes/DeploymentView.tsx:188:13",label:"策略",value:o?.strategy||"RollingUpdate"}),n[0]&&e.jsxs(e.Fragment,{children:[e.jsx(Be,{"code-path":"src/components/kubernetes/DeploymentView.tsx:191:17",label:"所在节点",value:e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentView.tsx:192:19",className:"text-[var(--dg-blue)] hover:underline",onClick:()=>window.open(`/kubernetes/${s}/nodes/${n[0].node_name||n[0].node}`,"_blank"),children:n[0].node_name||n[0].node||"-"})}),e.jsx(Be,{"code-path":"src/components/kubernetes/DeploymentView.tsx:196:17",label:"容器组 IP",value:e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentView.tsx:196:49",className:"font-mono",children:n[0].ip||n[0].pod_ip||"-"})})]}),e.jsx(Be,{"code-path":"src/components/kubernetes/DeploymentView.tsx:199:13",label:"创建时间",value:at(o?.created_at||o?.creationTimestamp)})]}),n[0]&&e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentView.tsx:202:13",className:"mt-3 pt-3 border-t border-[var(--dg-border)]",children:e.jsx(bs,{"code-path":"src/components/kubernetes/DeploymentView.tsx:203:15",pod:n[0]})})]})}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentView.tsx:210:7",className:"flex items-center gap-0.5 border-b border-[var(--dg-border)] overflow-x-auto",children:[x.map(r=>e.jsxs("button",{"code-path":"src/components/kubernetes/DeploymentView.tsx:212:11",className:`flex items-center gap-1.5 px-4 py-2.5 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${d===r.key?"border-[var(--dg-blue)] text-[var(--dg-blue)]":"border-transparent text-[var(--dg-text-muted)] hover:text-[var(--dg-text-secondary)]"}`,onClick:()=>k(r.key),children:[e.jsx(r.icon,{"code-path":"src/components/kubernetes/DeploymentView.tsx:221:13",className:"h-4 w-4"}),r.label,r.key==="pods"&&e.jsx(ne,{"code-path":"src/components/kubernetes/DeploymentView.tsx:223:34",className:"ml-1 text-[10px] px-1.5 py-0 bg-[var(--dg-bg-tertiary)] text-[var(--dg-text-muted)]",children:r.count})]},r.key)),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentView.tsx:226:9",className:"ml-auto flex items-center gap-1 pr-2 shrink-0",children:[e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentView.tsx:227:11",variant:"ghost",size:"icon",className:"h-7 w-7 text-[var(--dg-text-muted)] hover:text-[var(--dg-text-primary)]",disabled:z||C<=0,onClick:()=>D(r=>Math.max(0,r-1)),children:e.jsx(Ct,{"code-path":"src/components/kubernetes/DeploymentView.tsx:230:13",className:"h-4 w-4"})}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentView.tsx:232:11",type:"number",min:0,value:C,onChange:r=>D(Math.max(0,Number(r.target.value))),className:"w-16 h-7 text-center text-sm font-bold bg-slate-800 border-slate-700 text-slate-200"}),e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentView.tsx:237:11",variant:"ghost",size:"icon",className:"h-7 w-7 text-[var(--dg-text-muted)] hover:text-[var(--dg-text-primary)]",disabled:z,onClick:()=>D(r=>r+1),children:e.jsx(Q,{"code-path":"src/components/kubernetes/DeploymentView.tsx:240:13",className:"h-4 w-4"})}),C!==ue&&e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentView.tsx:243:13",size:"sm",className:"h-7 text-xs bg-[var(--dg-blue)] hover:bg-[var(--dg-blue-hover)]",disabled:z,onClick:i,children:z?e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentView.tsx:245:31",className:"h-3 w-3 animate-spin"}):"应用"})]})]}),d==="pods"&&e.jsx(Qs,{"code-path":"src/components/kubernetes/DeploymentView.tsx:252:26",...t,expandedPod:w,setExpandedPod:E}),d==="services"&&e.jsx(Zs,{"code-path":"src/components/kubernetes/DeploymentView.tsx:253:30",services:Y,ingresses:Z,loading:J,namespace:a}),d==="events"&&e.jsx(en,{"code-path":"src/components/kubernetes/DeploymentView.tsx:254:28",events:V,loading:J}),d==="scale"&&e.jsx(tn,{"code-path":"src/components/kubernetes/DeploymentView.tsx:256:9",hpas:g,cronHpas:q,loading:J,replicas:ue}),d==="history"&&e.jsx(sn,{"code-path":"src/components/kubernetes/DeploymentView.tsx:263:29",revisions:l,rollbackLoading:y,onRollback:B})]})}async function ct(t,s,a,o){const n=await ws(o);await X.updateResourceYaml(t,s,"deployments",a,n)}function Ue(t){return!t||typeof t!="object"?[]:Object.entries(t).map(([s,a])=>({key:s,value:String(a)}))}function Re(t){const s={};for(const{key:a,value:o}of t){const n=a.trim();n&&(s[n]=o)}return s}function on({clusterCode:t,namespace:s,deploymentName:a,manifest:o,onSaved:n,onCancel:l}){const{toast:c}=Te(),[m,u]=p.useState(!1),[d,k]=p.useState(!o),[w,E]=p.useState(o||{}),[y,S]=p.useState(1),[C,D]=p.useState([]),[z,I]=p.useState([]),[Y,U]=p.useState([]),[Z,_]=p.useState([]);p.useEffect(()=>{const r=o;if(!r){k(!1);return}E(r),S(r?.spec?.replicas??1),D(Ue(r?.metadata?.labels)),I(Ue(r?.metadata?.annotations)),U(Ue(r?.spec?.selector?.matchLabels)),_(Ue(r?.spec?.template?.metadata?.labels)),k(!1)},[o]);const V=(r,h)=>{D(j=>j.map((N,P)=>P===r?{...N,...h}:N))},F=()=>D(r=>[...r,{key:"",value:""}]),J=r=>D(h=>h.filter((j,N)=>N!==r)),ee=(r,h)=>{I(j=>j.map((N,P)=>P===r?{...N,...h}:N))},g=()=>I(r=>[...r,{key:"",value:""}]),O=r=>I(h=>h.filter((j,N)=>N!==r)),q=(r,h)=>{U(j=>j.map((N,P)=>P===r?{...N,...h}:N))},K=()=>U(r=>[...r,{key:"",value:""}]),le=r=>U(h=>h.filter((j,N)=>N!==r)),ue=(r,h)=>{_(j=>j.map((N,P)=>P===r?{...N,...h}:N))},ke=()=>_(r=>[...r,{key:"",value:""}]),B=r=>_(h=>h.filter((j,N)=>N!==r)),i=()=>{const r=Re(Y);_(h=>{const j={...Re(h),...r};return Object.entries(j).map(([N,P])=>({key:N,value:P}))}),c({title:"已同步",description:"Selector 标签已合并到 Pod 模板标签"})},x=async()=>{u(!0);try{const r=JSON.parse(JSON.stringify(w));r.spec=r.spec||{},r.spec.replicas=y;const h=Re(C);r.metadata=r.metadata||{},r.metadata.labels=Object.keys(h).length>0?h:void 0;const j=Re(z);r.metadata.annotations=Object.keys(j).length>0?j:void 0;const N=Re(Y);Object.keys(N).length>0&&(r.spec.selector=r.spec.selector||{},r.spec.selector.matchLabels=N);const P=Re(Z);r.spec.template=r.spec.template||{},r.spec.template.metadata=r.spec.template.metadata||{},Object.keys(P).length>0?r.spec.template.metadata.labels=P:delete r.spec.template.metadata.labels,await ct(t,s,a,r),c({title:"基本信息已保存",description:`${a} 更新已提交`}),n(r)}catch(r){c({title:"保存失败",description:r?.message||String(r),variant:"destructive"})}finally{u(!1)}};return d?e.jsx(W,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:130:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:131:9",className:"p-12 text-center",children:[e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:132:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:133:11",className:"text-slate-500 mt-3 text-sm",children:"加载中..."})]})}):o?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:150:5",className:"space-y-4",children:[e.jsxs(W,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:152:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(me,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:153:9",className:"pb-3",children:e.jsxs(xe,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:154:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(Ls,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:155:13",className:"h-4 w-4 text-blue-400"}),"副本数 (Replicas)"]})}),e.jsx(G,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:159:9",className:"pt-0",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:160:11",className:"flex items-center gap-3",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:161:13",type:"number",min:0,value:y,onChange:r=>S(Math.max(0,Number(r.target.value)||0)),className:"w-32 bg-slate-800 border-slate-700 text-slate-200"}),e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:168:13",className:"text-xs text-slate-500",children:"期望运行的 Pod 实例数量"})]})})]}),e.jsxs(W,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:174:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(me,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:175:9",className:"pb-3",children:e.jsxs(xe,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:176:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(cs,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:177:13",className:"h-4 w-4 text-slate-500"}),"基本标识(只读)"]})}),e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:181:9",className:"pt-0 grid grid-cols-2 gap-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:182:11",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:183:13",className:"text-slate-400 text-xs",children:"名称 (name)"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:184:13",value:a,readOnly:!0,className:"mt-1 bg-slate-950 border-slate-800 text-slate-500 font-mono text-sm cursor-not-allowed"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:187:11",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:188:13",className:"text-slate-400 text-xs",children:"命名空间 (namespace)"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:189:13",value:s,readOnly:!0,className:"mt-1 bg-slate-950 border-slate-800 text-slate-500 font-mono text-sm cursor-not-allowed"})]})]})]}),e.jsxs(W,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:196:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(me,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:197:9",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:198:11",className:"flex items-center justify-between",children:[e.jsxs(xe,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:199:13",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(ht,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:200:15",className:"h-4 w-4 text-emerald-400"}),"标签 (Labels)",e.jsx(ne,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:202:15",variant:"outline",className:"border-slate-700 text-slate-500 text-[10px]",children:C.length})]}),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:204:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:F,children:[e.jsx(Q,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:205:15",className:"h-3 w-3 mr-1"}),"新增"]})]})}),e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:209:9",className:"pt-0 space-y-1.5",children:[C.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:210:35",className:"text-[11px] text-slate-600",children:"无标签"}),C.map((r,h)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:212:13",className:"grid grid-cols-[1fr_1.4fr_auto] gap-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:213:15",value:r.key,placeholder:"app",onChange:j=>V(h,{key:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:216:15",value:r.value,placeholder:"nginx",onChange:j=>V(h,{value:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:219:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400 hover:text-red-300",onClick:()=>J(h),children:e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:220:48",className:"h-3.5 w-3.5"})})]},h))]})]}),e.jsxs(W,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:227:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(me,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:228:9",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:229:11",className:"flex items-center justify-between",children:[e.jsxs(xe,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:230:13",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(ht,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:231:15",className:"h-4 w-4 text-amber-400"}),"选择器 (Selector)",e.jsx(ne,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:233:15",variant:"outline",className:"border-amber-700/50 text-amber-500 text-[10px]",children:"⚠️ 需与模板标签一致"})]}),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:235:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:K,children:[e.jsx(Q,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:236:15",className:"h-3 w-3 mr-1"}),"新增"]})]})}),e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:240:9",className:"pt-0 space-y-1.5",children:[e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:241:11",className:"text-[11px] text-amber-500/70 mb-1",children:"Selector 决定哪些 Pod 归属此 Deployment。修改时必须确保与 Pod Template Labels 匹配,否则 Deployment 将无法管理 Pod。"}),Y.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:242:43",className:"text-[11px] text-slate-600",children:"无选择器"}),Y.map((r,h)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:244:13",className:"grid grid-cols-[1fr_1.4fr_auto] gap-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:245:15",value:r.key,placeholder:"app",onChange:j=>q(h,{key:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:248:15",value:r.value,placeholder:"nginx",onChange:j=>q(h,{value:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:251:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400 hover:text-red-300",onClick:()=>le(h),children:e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:252:51",className:"h-3.5 w-3.5"})})]},h))]})]}),e.jsxs(W,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:259:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(me,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:260:9",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:261:11",className:"flex items-center justify-between",children:[e.jsxs(xe,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:262:13",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(ht,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:263:15",className:"h-4 w-4 text-cyan-400"}),"Pod 模板标签 (template.metadata.labels)"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:266:13",className:"flex gap-1",children:[e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:267:15",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:i,children:"从 Selector 同步"}),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:270:15",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:ke,children:[e.jsx(Q,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:271:17",className:"h-3 w-3 mr-1"}),"新增"]})]})]})}),e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:276:9",className:"pt-0 space-y-1.5",children:[e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:277:11",className:"text-[11px] text-slate-600 mb-1",children:"Pod 模板标签必须包含 Selector 全部键值,否则 Deployment 无法管理 Pod"}),Z.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:278:43",className:"text-[11px] text-slate-600",children:"无模板标签"}),Z.map((r,h)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:280:13",className:"grid grid-cols-[1fr_1.4fr_auto] gap-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:281:15",value:r.key,placeholder:"app",onChange:j=>ue(h,{key:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:284:15",value:r.value,placeholder:"nginx",onChange:j=>ue(h,{value:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:287:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400 hover:text-red-300",onClick:()=>B(h),children:e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:288:56",className:"h-3.5 w-3.5"})})]},h))]})]}),e.jsxs(W,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:295:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(me,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:296:9",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:297:11",className:"flex items-center justify-between",children:[e.jsxs(xe,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:298:13",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(St,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:299:15",className:"h-4 w-4 text-purple-400"}),"注解 (Annotations)",e.jsx(ne,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:301:15",variant:"outline",className:"border-slate-700 text-slate-500 text-[10px]",children:z.length})]}),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:303:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:g,children:[e.jsx(Q,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:304:15",className:"h-3 w-3 mr-1"}),"新增"]})]})}),e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:308:9",className:"pt-0 space-y-1.5",children:[z.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:309:40",className:"text-[11px] text-slate-600",children:"无注解"}),z.map((r,h)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:311:13",className:"grid grid-cols-[1fr_1.4fr_auto] gap-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:312:15",value:r.key,placeholder:"deployment.kubernetes.io/revision",onChange:j=>ee(h,{key:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:315:15",value:r.value,placeholder:"1",onChange:j=>ee(h,{value:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:318:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400 hover:text-red-300",onClick:()=>O(h),children:e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:319:53",className:"h-3.5 w-3.5"})})]},h))]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:326:7",className:"sticky bottom-0 bg-slate-950/80 backdrop-blur border-t border-slate-800 p-3 flex items-center justify-between",children:[e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:327:9",className:"text-[11px] text-slate-500",children:["保存将通过 ",e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:328:17",className:"text-slate-400",children:"PUT application/yaml"})," 提交(自动剥离 status/managedFields 等只读字段)"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:330:9",className:"flex gap-2",children:[e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:331:11",variant:"outline",className:"border-slate-700 text-slate-400",onClick:l,children:"取消"}),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:332:11",className:"bg-blue-600 hover:bg-blue-700",disabled:m,onClick:x,children:[m?e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:333:23",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(rt,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:333:75",className:"h-4 w-4 mr-1"}),"保存"]})]})]})]}):e.jsx(W,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:141:7",className:"bg-slate-900 border-slate-800",children:e.jsx(G,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:142:9",className:"p-8 text-center text-slate-500",children:"未获取到 manifest 数据,请使用 YAML 编辑模式直接修改。"})})}function Vt(t){const s=n=>{if(!n)return null;let l="none";return n.httpGet?l="httpGet":n.tcpSocket?l="tcpSocket":n.exec&&(l="exec"),{type:l,httpPath:n.httpGet?.path||"",httpPort:n.httpGet?.port??"",httpHost:n.httpGet?.host||"",tcpPort:n.tcpSocket?.port??"",execCommand:Array.isArray(n.exec?.command)?n.exec.command.join(`
|
||
`):n.exec?.command||"",initialDelaySeconds:n.initialDelaySeconds,periodSeconds:n.periodSeconds,timeoutSeconds:n.timeoutSeconds,successThreshold:n.successThreshold,failureThreshold:n.failureThreshold}},a=n=>{if(!n)return{type:"none"};let l="none";return n.exec?l="exec":n.httpGet?l="httpGet":n.tcpSocket&&(l="tcpSocket"),{type:l,execCommand:Array.isArray(n.exec?.command)?n.exec.command.join(`
|
||
`):"",httpPath:n.httpGet?.path||"",httpPort:n.httpGet?.port??"",tcpPort:n.tcpSocket?.port??""}},o=t.securityContext;return{name:t.name||"",image:t.image||"",imagePullPolicy:t.imagePullPolicy||"",command:Array.isArray(t.command)?t.command:[],args:Array.isArray(t.args)?t.args:[],workingDir:t.workingDir||"",env:(Array.isArray(t.env)?t.env:[]).map(n=>({name:n.name||"",value:n.value??""})),ports:(Array.isArray(t.ports)?t.ports:[]).map(n=>({name:n.name||"",containerPort:n.containerPort??"",protocol:n.protocol||"TCP"})),resources:{requests:t.resources?.requests||{},limits:t.resources?.limits||{}},livenessProbe:s(t.livenessProbe),readinessProbe:s(t.readinessProbe),startupProbe:s(t.startupProbe),lifecycle:t.lifecycle?{postStart:t.lifecycle.postStart?a(t.lifecycle.postStart):void 0,preStop:t.lifecycle.preStop?a(t.lifecycle.preStop):void 0}:null,securityContext:o?{runAsUser:o.runAsUser,runAsGroup:o.runAsGroup,runAsNonRoot:o.runAsNonRoot,privileged:o.privileged,readOnlyRootFilesystem:o.readOnlyRootFilesystem,allowPrivilegeEscalation:o.allowPrivilegeEscalation,capabilitiesAdd:o.capabilities?.add||[],capabilitiesDrop:o.capabilities?.drop||[]}:null,volumeMounts:(Array.isArray(t.volumeMounts)?t.volumeMounts:[]).map(n=>({name:n.name||"",mountPath:n.mountPath||"",subPath:n.subPath||"",readOnly:n.readOnly||!1}))}}function Ft(t=""){return{name:t,image:"",imagePullPolicy:"IfNotPresent",command:[],args:[],workingDir:"",env:[],ports:[],resources:{},livenessProbe:null,readinessProbe:null,startupProbe:null,lifecycle:null,securityContext:null,volumeMounts:[]}}function bt(t){if(!t||t.type==="none"||!t.type)return;const s={};if(t.type==="httpGet")s.httpGet={},t.httpPath&&(s.httpGet.path=t.httpPath),t.httpPort!==""&&t.httpPort!=null&&(s.httpGet.port=typeof t.httpPort=="number"?t.httpPort:Number(t.httpPort)),t.httpHost&&(s.httpGet.host=t.httpHost);else if(t.type==="tcpSocket")s.tcpSocket={},t.tcpPort!==""&&t.tcpPort!=null&&(s.tcpSocket.port=typeof t.tcpPort=="number"?t.tcpPort:Number(t.tcpPort));else if(t.type==="exec"){const a=(t.execCommand||"").split(`
|
||
`).map(o=>o.trim()).filter(Boolean);a.length&&(s.exec={command:a})}return t.initialDelaySeconds!=null&&(s.initialDelaySeconds=t.initialDelaySeconds),t.periodSeconds!=null&&(s.periodSeconds=t.periodSeconds),t.timeoutSeconds!=null&&(s.timeoutSeconds=t.timeoutSeconds),t.successThreshold!=null&&(s.successThreshold=t.successThreshold),t.failureThreshold!=null&&(s.failureThreshold=t.failureThreshold),Object.keys(s).length>0?s:void 0}function qt(t){if(!(!t||t.type==="none"||!t.type)){if(t.type==="exec"){const s=(t.execCommand||"").split(`
|
||
`).map(a=>a.trim()).filter(Boolean);return s.length?{exec:{command:s}}:void 0}if(t.type==="httpGet"){const s={httpGet:{}};return t.httpPath&&(s.httpGet.path=t.httpPath),t.httpPort!==""&&t.httpPort!=null&&(s.httpGet.port=Number(t.httpPort)),s}if(t.type==="tcpSocket"){const s={tcpSocket:{}};return t.tcpPort!==""&&t.tcpPort!=null&&(s.tcpSocket.port=Number(t.tcpPort)),s}}}function Yt(t){const s={name:t.name};t.image&&(s.image=t.image),t.imagePullPolicy&&(s.imagePullPolicy=t.imagePullPolicy),t.workingDir&&(s.workingDir=t.workingDir),t.command.length>0&&(s.command=t.command),t.args.length>0&&(s.args=t.args),t.env.length>0&&(s.env=t.env.filter(d=>d.name.trim()).map(d=>{const k={name:d.name};return d.value!=null&&(k.value=d.value),k})),t.ports.length>0&&(s.ports=t.ports.filter(d=>d.containerPort!=="").map(d=>{const k={containerPort:typeof d.containerPort=="number"?d.containerPort:Number(d.containerPort)};return d.name&&(k.name=d.name),d.protocol&&(k.protocol=d.protocol),k}));const a=t.resources.requests,o=t.resources.limits,n=a&&Object.values(a).some(d=>d&&d.trim()),l=o&&Object.values(o).some(d=>d&&d.trim());(n||l)&&(s.resources={},n&&(s.resources.requests={},a.cpu?.trim()&&(s.resources.requests.cpu=a.cpu),a.memory?.trim()&&(s.resources.requests.memory=a.memory)),l&&(s.resources.limits={},o.cpu?.trim()&&(s.resources.limits.cpu=o.cpu),o.memory?.trim()&&(s.resources.limits.memory=o.memory)));const c=bt(t.livenessProbe);c&&(s.livenessProbe=c);const m=bt(t.readinessProbe);m&&(s.readinessProbe=m);const u=bt(t.startupProbe);if(u&&(s.startupProbe=u),t.lifecycle){const d={},k=qt(t.lifecycle.postStart);k&&(d.postStart=k);const w=qt(t.lifecycle.preStop);w&&(d.preStop=w),Object.keys(d).length>0&&(s.lifecycle=d)}if(t.securityContext){const d=t.securityContext,k={};d.runAsUser!==""&&d.runAsUser!=null&&(k.runAsUser=Number(d.runAsUser)),d.runAsGroup!==""&&d.runAsGroup!=null&&(k.runAsGroup=Number(d.runAsGroup)),d.runAsNonRoot!=null&&(k.runAsNonRoot=d.runAsNonRoot),d.privileged!=null&&(k.privileged=d.privileged),d.readOnlyRootFilesystem!=null&&(k.readOnlyRootFilesystem=d.readOnlyRootFilesystem),d.allowPrivilegeEscalation!=null&&(k.allowPrivilegeEscalation=d.allowPrivilegeEscalation);const w=(d.capabilitiesAdd||[]).filter(Boolean),E=(d.capabilitiesDrop||[]).filter(Boolean);(w.length||E.length)&&(k.capabilities={},w.length&&(k.capabilities.add=w),E.length&&(k.capabilities.drop=E)),Object.keys(k).length>0&&(s.securityContext=k)}return t.volumeMounts.length>0&&(s.volumeMounts=t.volumeMounts.filter(d=>d.name.trim()&&d.mountPath.trim()).map(d=>{const k={name:d.name,mountPath:d.mountPath};return d.subPath&&(k.subPath=d.subPath),d.readOnly&&(k.readOnly=!0),k})),s}function Ut(t){return t.join(`
|
||
`)}function Jt(t){return t.split(`
|
||
`).map(s=>s.trim()).filter(Boolean)}function an({container:t,onUpdate:s}){const a=t,o="flex items-center gap-1.5 text-xs font-semibold text-slate-300 mb-2";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:36:7",className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:37:9",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:38:11",className:"text-slate-400 text-xs",children:"容器名称"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:39:11",value:a.name,onChange:n=>s({name:n.target.value}),placeholder:"my-app",className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:43:9",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:44:11",className:"text-slate-400 text-xs",children:"容器镜像"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:45:11",value:a.image,onChange:n=>s({image:n.target.value}),placeholder:"nginx:1.25",className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:49:9",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:50:11",className:"text-slate-400 text-xs",children:"镜像拉取策略"}),e.jsxs(Ze,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:51:11",value:a.imagePullPolicy||"__none",onValueChange:n=>s({imagePullPolicy:n==="__none"?"":n}),children:[e.jsx(et,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:52:13",className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 text-xs h-8",children:e.jsx(tt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:53:15"})}),e.jsxs(st,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:55:13",className:"bg-slate-900 border-slate-700",children:[e.jsx(ge,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:56:15",value:"__none",className:"text-slate-400",children:"不设置(默认 IfNotPresent)"}),e.jsx(ge,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:57:15",value:"Always",className:"text-slate-200",children:"Always"}),e.jsx(ge,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:58:15",value:"IfNotPresent",className:"text-slate-200",children:"IfNotPresent"}),e.jsx(ge,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:59:15",value:"Never",className:"text-slate-200",children:"Never"})]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:63:9",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:64:11",className:"text-slate-400 text-xs",children:"工作目录 (workingDir)"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:65:11",value:a.workingDir||"",onChange:n=>s({workingDir:n.target.value}),placeholder:"/app",className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:72:7",className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:73:9",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:74:11",className:"text-slate-400 text-xs",children:"启动命令 (command) — 每行一个"}),e.jsx(Qe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:75:11",value:Ut(a.command),placeholder:`/bin/sh
|
||
-c`,onChange:n=>s({command:Jt(n.target.value)}),className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs min-h-[60px]"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:79:9",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:80:11",className:"text-slate-400 text-xs",children:"启动参数 (args) — 每行一个"}),e.jsx(Qe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:81:11",value:Ut(a.args),placeholder:`--config=/etc/app.yaml
|
||
--debug`,onChange:n=>s({args:Jt(n.target.value)}),className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs min-h-[60px]"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:88:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:89:9",className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:90:11",className:o,children:[e.jsx(ns,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:90:39",className:"h-3.5 w-3.5 text-cyan-400"})," 环境变量"]}),e.jsxs(b,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:91:11",size:"sm",variant:"outline",className:"h-6 border-slate-700 text-slate-300 text-[11px]",onClick:()=>s({env:[...a.env,{name:"",value:""}]}),children:[e.jsx(Q,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:93:13",className:"h-3 w-3 mr-1"}),"新增"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:96:9",className:"space-y-1.5",children:[a.env.map((n,l)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:98:13",className:"grid grid-cols-[1fr_1.4fr_auto] gap-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:99:15",value:n.name,placeholder:"KEY",onChange:c=>{const m=[...a.env];m[l]={...n,name:c.target.value},s({env:m})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:102:15",value:n.value||"",placeholder:"value",onChange:c=>{const m=[...a.env];m[l]={...n,value:c.target.value},s({env:m})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:105:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400",onClick:()=>s({env:a.env.filter((c,m)=>m!==l)}),children:e.jsx(he,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:107:17",className:"h-3.5 w-3.5"})})]},l)),a.env.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:111:34",className:"text-[11px] text-slate-600",children:"无环境变量"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:116:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:117:9",className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:118:11",className:o,children:[e.jsx(Ae,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:118:39",className:"h-3.5 w-3.5 text-indigo-400"})," 端口"]}),e.jsxs(b,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:119:11",size:"sm",variant:"outline",className:"h-6 border-slate-700 text-slate-300 text-[11px]",onClick:()=>s({ports:[...a.ports,{name:"",containerPort:"",protocol:"TCP"}]}),children:[e.jsx(Q,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:121:13",className:"h-3 w-3 mr-1"}),"新增"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:124:9",className:"space-y-1.5",children:[a.ports.map((n,l)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:126:13",className:"grid grid-cols-[1fr_1fr_100px_auto] gap-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:127:15",value:n.name||"",placeholder:"http",onChange:c=>{const m=[...a.ports];m[l]={...n,name:c.target.value},s({ports:m})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:130:15",type:"number",value:n.containerPort,placeholder:"8080",onChange:c=>{const m=[...a.ports];m[l]={...n,containerPort:c.target.value},s({ports:m})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsxs(Ze,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:133:15",value:n.protocol||"TCP",onValueChange:c=>{const m=[...a.ports];m[l]={...n,protocol:c},s({ports:m})},children:[e.jsx(et,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:134:17",className:"bg-slate-800 border-slate-700 text-slate-200 text-xs h-8",children:e.jsx(tt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:135:19"})}),e.jsxs(st,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:137:17",className:"bg-slate-900 border-slate-700",children:[e.jsx(ge,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:138:19",value:"TCP",className:"text-slate-200",children:"TCP"}),e.jsx(ge,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:139:19",value:"UDP",className:"text-slate-200",children:"UDP"}),e.jsx(ge,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:140:19",value:"SCTP",className:"text-slate-200",children:"SCTP"})]})]}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:143:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400",onClick:()=>s({ports:a.ports.filter((c,m)=>m!==l)}),children:e.jsx(he,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:145:17",className:"h-3.5 w-3.5"})})]},l)),a.ports.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:149:36",className:"text-[11px] text-slate-600",children:"无端口暴露"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:154:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:155:9",className:o,children:[e.jsx(zs,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:155:37",className:"h-3.5 w-3.5 text-amber-400"})," 资源 (requests / limits)"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:156:9",className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:157:11",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:158:13",className:"text-[11px] text-slate-500",children:"CPU 请求"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:159:13",value:a.resources.requests?.cpu||"",placeholder:"100m",onChange:n=>s({resources:{...a.resources,requests:{...a.resources.requests,cpu:n.target.value}}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:163:11",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:164:13",className:"text-[11px] text-slate-500",children:"CPU 上限"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:165:13",value:a.resources.limits?.cpu||"",placeholder:"500m",onChange:n=>s({resources:{...a.resources,limits:{...a.resources.limits,cpu:n.target.value}}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:169:11",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:170:13",className:"text-[11px] text-slate-500",children:"内存请求"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:171:13",value:a.resources.requests?.memory||"",placeholder:"128Mi",onChange:n=>s({resources:{...a.resources,requests:{...a.resources.requests,memory:n.target.value}}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:175:11",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:176:13",className:"text-[11px] text-slate-500",children:"内存上限"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:177:13",value:a.resources.limits?.memory||"",placeholder:"512Mi",onChange:n=>s({resources:{...a.resources,limits:{...a.resources.limits,memory:n.target.value}}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:185:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:186:9",className:o,children:[e.jsx(_s,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:186:37",className:"h-3.5 w-3.5 text-rose-400"})," 健康检查 (Probes)"]}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:187:9",className:"space-y-2",children:["livenessProbe","readinessProbe","startupProbe"].map(n=>e.jsx(rn,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:189:13",label:{livenessProbe:"存活探针 (liveness)",readinessProbe:"就绪探针 (readiness)",startupProbe:"启动探针 (startup)"}[n],probe:a[n],onChange:l=>s({[n]:l})},n))})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:199:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:200:9",className:o,children:[e.jsx(ls,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:200:37",className:"h-3.5 w-3.5 text-yellow-400"})," 生命周期回调 (Lifecycle)"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:201:9",className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(Kt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:202:11",label:"启动后 (postStart)",handler:a.lifecycle?.postStart,onChange:n=>s({lifecycle:{...a.lifecycle,postStart:n}})}),e.jsx(Kt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:204:11",label:"终止前 (preStop)",handler:a.lifecycle?.preStop,onChange:n=>s({lifecycle:{...a.lifecycle,preStop:n}})})]}),!a.lifecycle&&e.jsxs(b,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:208:11",size:"sm",variant:"outline",className:"h-6 border-slate-700 text-slate-300 text-[11px] mt-1",onClick:()=>s({lifecycle:{postStart:{type:"none"},preStop:{type:"none"}}}),children:[e.jsx(Q,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:210:13",className:"h-3 w-3 mr-1"}),"启用生命周期回调"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:216:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:217:9",className:o,children:[e.jsx(ds,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:217:37",className:"h-3.5 w-3.5 text-emerald-400"})," 安全上下文 (SecurityContext)"]}),a.securityContext?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:219:11",className:"space-y-2 border border-slate-800 rounded-md p-3 bg-slate-950/30",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:220:13",className:"grid grid-cols-2 md:grid-cols-3 gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:221:15",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:222:17",className:"text-[11px] text-slate-500",children:"runAsUser"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:223:17",type:"number",value:a.securityContext.runAsUser??"",placeholder:"1000",onChange:n=>s({securityContext:{...a.securityContext,runAsUser:n.target.value===""?void 0:Number(n.target.value)}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:227:15",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:228:17",className:"text-[11px] text-slate-500",children:"runAsGroup"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:229:17",type:"number",value:a.securityContext.runAsGroup??"",placeholder:"1000",onChange:n=>s({securityContext:{...a.securityContext,runAsGroup:n.target.value===""?void 0:Number(n.target.value)}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:233:15",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:234:17",className:"text-[11px] text-slate-500",children:"Capabilities Add (逗号分隔)"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:235:17",value:(a.securityContext.capabilitiesAdd||[]).join(","),placeholder:"NET_ADMIN",onChange:n=>s({securityContext:{...a.securityContext,capabilitiesAdd:n.target.value.split(",").map(l=>l.trim()).filter(Boolean)}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:239:15",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:240:17",className:"text-[11px] text-slate-500",children:"Capabilities Drop (逗号分隔)"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:241:17",value:(a.securityContext.capabilitiesDrop||[]).join(","),placeholder:"ALL",onChange:n=>s({securityContext:{...a.securityContext,capabilitiesDrop:n.target.value.split(",").map(l=>l.trim()).filter(Boolean)}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:246:13",className:"flex items-center gap-4 flex-wrap",children:[e.jsx(Je,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:247:15",label:"runAsNonRoot",value:!!a.securityContext.runAsNonRoot,onChange:n=>s({securityContext:{...a.securityContext,runAsNonRoot:n}})}),e.jsx(Je,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:249:15",label:"privileged",value:!!a.securityContext.privileged,onChange:n=>s({securityContext:{...a.securityContext,privileged:n}})}),e.jsx(Je,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:251:15",label:"readOnlyRootFilesystem",value:!!a.securityContext.readOnlyRootFilesystem,onChange:n=>s({securityContext:{...a.securityContext,readOnlyRootFilesystem:n}})}),e.jsx(Je,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:253:15",label:"allowPrivilegeEscalation",value:a.securityContext.allowPrivilegeEscalation??!1,onChange:n=>s({securityContext:{...a.securityContext,allowPrivilegeEscalation:n}})})]}),e.jsxs(b,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:256:13",size:"sm",variant:"ghost",className:"h-6 text-red-400 text-[11px]",onClick:()=>s({securityContext:null}),children:[e.jsx(he,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:258:15",className:"h-3 w-3 mr-1"}),"移除安全上下文"]})]}):e.jsxs(b,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:262:11",size:"sm",variant:"outline",className:"h-6 border-slate-700 text-slate-300 text-[11px]",onClick:()=>s({securityContext:{runAsNonRoot:!1,privileged:!1}}),children:[e.jsx(Q,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:264:13",className:"h-3 w-3 mr-1"}),"启用安全上下文"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:270:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:271:9",className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:272:11",className:o,children:[e.jsx($s,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:272:39",className:"h-3.5 w-3.5 text-teal-400"})," 卷挂载 (VolumeMounts)"]}),e.jsxs(b,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:273:11",size:"sm",variant:"outline",className:"h-6 border-slate-700 text-slate-300 text-[11px]",onClick:()=>s({volumeMounts:[...a.volumeMounts,{name:"",mountPath:"",subPath:"",readOnly:!1}]}),children:[e.jsx(Q,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:275:13",className:"h-3 w-3 mr-1"}),"新增"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:278:9",className:"space-y-1.5",children:[a.volumeMounts.map((n,l)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:280:13",className:"grid grid-cols-[1fr_1fr_1fr_60px_auto] gap-2 items-center",children:[e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:281:15",value:n.name,placeholder:"volume 名称",onChange:c=>{const m=[...a.volumeMounts];m[l]={...n,name:c.target.value},s({volumeMounts:m})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:284:15",value:n.mountPath,placeholder:"/data",onChange:c=>{const m=[...a.volumeMounts];m[l]={...n,mountPath:c.target.value},s({volumeMounts:m})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:287:15",value:n.subPath||"",placeholder:"subPath (可选)",onChange:c=>{const m=[...a.volumeMounts];m[l]={...n,subPath:c.target.value},s({volumeMounts:m})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsxs("label",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:290:15",className:"flex items-center gap-1 text-[10px] text-slate-500 cursor-pointer",children:[e.jsx(wt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:291:17",checked:!!n.readOnly,onCheckedChange:c=>{const m=[...a.volumeMounts];m[l]={...n,readOnly:c},s({volumeMounts:m})}}),"RO"]}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:295:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400",onClick:()=>s({volumeMounts:a.volumeMounts.filter((c,m)=>m!==l)}),children:e.jsx(he,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:297:17",className:"h-3.5 w-3.5"})})]},l)),a.volumeMounts.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:301:43",className:"text-[11px] text-slate-600",children:"无卷挂载"})]})]})]})}function rn({label:t,probe:s,onChange:a}){const o=!!s,n=s||{type:"httpGet"},l=c=>a({...n,...c});return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:315:5",className:"border border-slate-800 rounded-md p-2.5 bg-slate-950/30",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:316:7",className:"flex items-center justify-between mb-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:317:9",className:"text-xs text-slate-300 font-medium",children:t}),e.jsx(wt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:318:9",checked:o,onCheckedChange:c=>a(c?{type:"httpGet",httpPath:"/",httpPort:8080,initialDelaySeconds:10,periodSeconds:10}:null)})]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:323:11",className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:324:13",className:"text-[10px] text-slate-500 w-8",children:"类型"}),e.jsxs(Ze,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:325:13",value:n.type||"httpGet",onValueChange:c=>l({type:c}),children:[e.jsx(et,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:326:15",className:"bg-slate-800 border-slate-700 text-slate-200 text-xs h-7 flex-1",children:e.jsx(tt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:327:17"})}),e.jsxs(st,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:329:15",className:"bg-slate-900 border-slate-700",children:[e.jsx(ge,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:330:17",value:"httpGet",className:"text-slate-200",children:"HTTP GET"}),e.jsx(ge,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:331:17",value:"tcpSocket",className:"text-slate-200",children:"TCP Socket"}),e.jsx(ge,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:332:17",value:"exec",className:"text-slate-200",children:"Exec 命令"})]})]})]}),n.type==="httpGet"&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:337:13",className:"grid grid-cols-3 gap-2 mb-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:338:15",value:n.httpPath||"",placeholder:"/healthz",onChange:c=>l({httpPath:c.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:341:15",type:"number",value:n.httpPort??"",placeholder:"8080",onChange:c=>l({httpPort:c.target.value===""?void 0:Number(c.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:344:15",value:n.httpHost||"",placeholder:"host (可选)",onChange:c=>l({httpHost:c.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]}),n.type==="tcpSocket"&&e.jsx("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:350:13",className:"mb-2",children:e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:351:15",type:"number",value:n.tcpPort??"",placeholder:"端口",onChange:c=>l({tcpPort:c.target.value===""?void 0:Number(c.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})}),n.type==="exec"&&e.jsx("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:357:13",className:"mb-2",children:e.jsx(Qe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:358:15",value:n.execCommand||"",placeholder:"每行一个命令片段,如:\\ncat\\n/tmp/healthy",onChange:c=>l({execCommand:c.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs min-h-[50px]"})}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:363:11",className:"grid grid-cols-5 gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:364:13",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:365:15",className:"text-[10px] text-slate-500",children:"延迟(s)"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:366:15",type:"number",value:n.initialDelaySeconds??"",placeholder:"10",onChange:c=>l({initialDelaySeconds:c.target.value===""?void 0:Number(c.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:370:13",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:371:15",className:"text-[10px] text-slate-500",children:"间隔(s)"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:372:15",type:"number",value:n.periodSeconds??"",placeholder:"10",onChange:c=>l({periodSeconds:c.target.value===""?void 0:Number(c.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:376:13",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:377:15",className:"text-[10px] text-slate-500",children:"超时(s)"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:378:15",type:"number",value:n.timeoutSeconds??"",placeholder:"1",onChange:c=>l({timeoutSeconds:c.target.value===""?void 0:Number(c.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:382:13",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:383:15",className:"text-[10px] text-slate-500",children:"成功"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:384:15",type:"number",value:n.successThreshold??"",placeholder:"1",onChange:c=>l({successThreshold:c.target.value===""?void 0:Number(c.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:388:13",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:389:15",className:"text-[10px] text-slate-500",children:"失败"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:390:15",type:"number",value:n.failureThreshold??"",placeholder:"3",onChange:c=>l({failureThreshold:c.target.value===""?void 0:Number(c.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]})]})]})]})}function Kt({label:t,handler:s,onChange:a}){const o=s||{type:"none"},n=!o.type||o.type==="none"?"__none":o.type;return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:406:5",className:"border border-slate-800 rounded-md p-2.5 bg-slate-950/30",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:407:7",className:"text-xs text-slate-300 font-medium block mb-2",children:t}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:408:7",className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:409:9",className:"text-[10px] text-slate-500 w-8",children:"类型"}),e.jsxs(Ze,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:410:9",value:n,onValueChange:l=>a({...o,type:l==="__none"?"none":l}),children:[e.jsx(et,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:411:11",className:"bg-slate-800 border-slate-700 text-slate-200 text-xs h-7 flex-1",children:e.jsx(tt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:412:13"})}),e.jsxs(st,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:414:11",className:"bg-slate-900 border-slate-700",children:[e.jsx(ge,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:415:13",value:"__none",className:"text-slate-400",children:"不设置"}),e.jsx(ge,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:416:13",value:"exec",className:"text-slate-200",children:"Exec 命令"}),e.jsx(ge,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:417:13",value:"httpGet",className:"text-slate-200",children:"HTTP GET"}),e.jsx(ge,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:418:13",value:"tcpSocket",className:"text-slate-200",children:"TCP Socket"})]})]})]}),o.type==="exec"&&e.jsx(Qe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:423:9",value:o.execCommand||"",placeholder:"每行一个命令片段",onChange:l=>a({...o,execCommand:l.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs min-h-[50px]"}),o.type==="httpGet"&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:428:9",className:"grid grid-cols-2 gap-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:429:11",value:o.httpPath||"",placeholder:"/shutdown",onChange:l=>a({...o,httpPath:l.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:432:11",type:"number",value:o.httpPort??"",placeholder:"8080",onChange:l=>a({...o,httpPort:l.target.value===""?void 0:Number(l.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]}),o.type==="tcpSocket"&&e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:438:9",type:"number",value:o.tcpPort??"",placeholder:"端口",onChange:l=>a({...o,tcpPort:l.target.value===""?void 0:Number(l.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]})}function Je({label:t,value:s,onChange:a}){return e.jsxs("label",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:448:5",className:"flex items-center gap-1.5 cursor-pointer",children:[e.jsx(wt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:449:7",checked:s,onCheckedChange:a}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:450:7",className:"text-[11px] text-slate-400 font-mono",children:t})]})}function Xt({title:t,description:s,icon:a,containers:o,accentColor:n,onAdd:l,onRemove:c,onUpdate:m,onDuplicate:u}){const d=ot(),[k,w]=p.useState(new Set([0])),E=C=>{w(D=>{const z=new Set(D);return z.has(C)?z.delete(C):z.add(C),z})},y=n==="blue"?"border-blue-500/30":"border-purple-500/30",S=n==="blue"?"bg-blue-500/5":"bg-purple-500/5";return e.jsxs(W,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:37:5",className:"bg-slate-900 border-slate-800",children:[e.jsxs(me,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:38:7",className:"pb-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:39:9",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:40:11",className:"flex items-center gap-2",children:[a,e.jsx(xe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:42:13",className:"text-sm text-slate-200",children:t}),e.jsx(ne,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:43:13",variant:"outline",className:"border-slate-700 text-slate-400 text-[10px]",children:o.length})]}),e.jsxs(b,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:45:11",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:l,children:[e.jsx(Q,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:46:13",className:"h-3 w-3 mr-1"}),"新增容器"]})]}),e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:49:9",className:"text-[11px] text-slate-600",children:s})]}),e.jsxs(G,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:51:7",className:"pt-0 space-y-3",children:[o.length===0&&e.jsx("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:53:11",className:"text-center py-6 text-slate-600 text-xs",children:"暂无容器,点击「新增容器」添加"}),o.map((C,D)=>{const z=k.has(D)||o.length===1;return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:58:13",className:`rounded-lg border ${y} overflow-hidden`,children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:60:15",className:`flex items-center justify-between px-3 py-2 ${S} cursor-pointer`,onClick:()=>E(D),children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:61:17",className:"flex items-center gap-2",children:[z?e.jsx(ts,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:62:29",className:"h-4 w-4 text-slate-500"}):e.jsx(ss,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:62:82",className:"h-4 w-4 text-slate-500"}),e.jsx($e,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:63:19",className:`h-4 w-4 ${n==="blue"?"text-blue-400":"text-purple-400"}`}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:64:19",className:"text-sm font-mono text-slate-200 font-semibold",children:C.name||"(未命名)"}),C.image&&e.jsx("code",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:65:31",className:"text-[10px] text-slate-500 font-mono truncate max-w-[300px]",children:C.image})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:67:17",className:"flex items-center gap-1",onClick:I=>I.stopPropagation(),children:[u&&e.jsx(b,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:69:21",variant:"ghost",size:"icon",className:"h-7 w-7 text-slate-500 hover:text-slate-300",title:"复制",onClick:()=>u(D),children:e.jsx(is,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:71:23",className:"h-3.5 w-3.5"})}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:74:19",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-400 hover:text-red-300",title:"删除",onClick:async()=>{await d({title:"删除容器",description:`确认删除容器「${C.name}」?`,confirmText:"删除",variant:"destructive"})&&c(D)},children:e.jsx(he,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:84:21",className:"h-3.5 w-3.5"})})]})]}),z&&e.jsx("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:90:17",className:"p-3 space-y-4 bg-slate-950/30",children:e.jsx(an,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:91:19",container:C,onUpdate:I=>m(D,I)})})]},D)})]})]})}function cn({clusterCode:t,namespace:s,deploymentName:a,manifest:o,onSaved:n,onCancel:l}){const{toast:c}=Te(),[m,u]=p.useState(!1),[d,k]=p.useState(!o),[w,E]=p.useState(o||{}),[y,S]=p.useState([]),[C,D]=p.useState([]),[z,I]=p.useState([]);p.useEffect(()=>{if(!o){k(!1);return}E(o);const g=o?.spec?.template?.spec||{};S((Array.isArray(g.containers)?g.containers:[]).map(Vt)),D((Array.isArray(g.initContainers)?g.initContainers:[]).map(Vt)),I((Array.isArray(g.imagePullSecrets)?g.imagePullSecrets:[]).map(O=>O.name||"")),k(!1)},[o]);const Y=(g,O)=>{S(q=>q.map((K,le)=>le===g?{...K,...O}:K))},U=()=>{S(g=>[...g,Ft(`container-${g.length+1}`)])},Z=g=>{S(O=>O.filter((q,K)=>K!==g))},_=g=>{S(O=>{const q=JSON.parse(JSON.stringify(O[g]));q.name=`${q.name}-copy`;const K=[...O];return K.splice(g+1,0,q),K})},V=(g,O)=>{D(q=>q.map((K,le)=>le===g?{...K,...O}:K))},F=()=>{D(g=>[...g,Ft(`init-${g.length+1}`)])},J=g=>{D(O=>O.filter((q,K)=>K!==g))},ee=async()=>{for(const g of[...C,...y]){if(!g.name.trim()){c({title:"保存失败",description:"容器名称不能为空",variant:"destructive"});return}if(!g.image.trim()){c({title:"保存失败",description:`容器 ${g.name} 的镜像不能为空`,variant:"destructive"});return}}u(!0);try{const g=JSON.parse(JSON.stringify(w));g.spec=g.spec||{},g.spec.template=g.spec.template||{},g.spec.template.spec=g.spec.template.spec||{},g.spec.template.spec.containers=y.map(Yt),g.spec.template.spec.initContainers=C.length>0?C.map(Yt):void 0,g.spec.template.spec.imagePullSecrets=z.filter(O=>O.trim()).length>0?z.filter(O=>O.trim()).map(O=>({name:O})):void 0,await ct(t,s,a,g),c({title:"容器配置已保存",description:`${a} 更新已提交`}),n(g)}catch(g){c({title:"保存失败",description:g?.message||String(g),variant:"destructive"})}finally{u(!1)}};return d?e.jsx(W,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:112:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:113:9",className:"p-12 text-center",children:[e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:114:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:115:11",className:"text-slate-500 mt-3 text-sm",children:"加载中..."})]})}):o?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:131:5",className:"space-y-4",children:[e.jsxs(W,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:133:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(me,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:134:9",className:"pb-3",children:e.jsxs(xe,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:135:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(Ws,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:136:13",className:"h-4 w-4 text-amber-400"}),"镜像拉取凭证 (imagePullSecrets)",e.jsx(ne,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:138:13",variant:"outline",className:"border-slate-700 text-slate-500 text-[10px]",children:"Pod 级别"})]})}),e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:141:9",className:"pt-0 space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:142:11",className:"flex items-center gap-2 flex-wrap",children:[z.map((g,O)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:144:15",className:"flex items-center gap-1 bg-slate-800 rounded px-2 py-1",children:[e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:145:17",className:"text-xs text-slate-300 font-mono",children:g}),e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:146:17",onClick:()=>I(q=>q.filter((K,le)=>le!==O)),className:"text-red-400 hover:text-red-300 ml-1",children:e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:147:68",className:"h-3 w-3"})})]},O)),z.length===0&&e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:150:47",className:"text-[11px] text-slate-600",children:"无"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:152:11",className:"flex gap-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:153:13",placeholder:"输入 Secret 名称后回车",className:"bg-slate-800 border-slate-700 text-slate-200 text-xs h-8",onKeyDown:g=>{if(g.key==="Enter"){const O=g.target.value.trim();O&&(I(q=>[...q,O]),g.target.value="")}}}),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:160:13",size:"sm",variant:"outline",className:"h-8 border-slate-700 text-slate-300 text-xs",onClick:()=>I(g=>[...g,""]),children:[e.jsx(Q,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:162:15",className:"h-3 w-3 mr-1"}),"新增"]})]})]})]}),e.jsx(Xt,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:169:7",title:"初始化容器",description:"在主容器启动前按顺序执行的容器,用于初始化环境",icon:e.jsx(ps,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:172:15",className:"h-4 w-4 text-purple-400"}),containers:C,accentColor:"purple",onAdd:F,onRemove:J,onUpdate:V}),e.jsx(Xt,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:181:7",title:"工作容器",description:"Deployment 运行的主容器,定义应用进程及其运行时配置",icon:e.jsx($e,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:184:15",className:"h-4 w-4 text-blue-400"}),containers:y,accentColor:"blue",onAdd:U,onRemove:Z,onUpdate:Y,onDuplicate:_}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:194:7",className:"sticky bottom-0 bg-slate-950/80 backdrop-blur border-t border-slate-800 p-3 flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:195:9",className:"text-[11px] text-slate-500",children:["共 ",e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:196:13",className:"text-slate-300 font-semibold",children:C.length})," 个初始化容器 +",e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:197:11",className:"text-slate-300 font-semibold ml-1",children:y.length})," 个工作容器"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:199:9",className:"flex gap-2",children:[e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:200:11",variant:"outline",className:"border-slate-700 text-slate-400",onClick:l,children:"取消"}),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:201:11",className:"bg-blue-600 hover:bg-blue-700",disabled:m,onClick:ee,children:[m?e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:202:23",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(rt,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:202:75",className:"h-4 w-4 mr-1"}),"保存"]})]})]})]}):e.jsx(W,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:122:7",className:"bg-slate-900 border-slate-800",children:e.jsx(G,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:123:9",className:"p-8 text-center text-slate-500",children:"未获取到 manifest 数据,请使用 YAML 编辑模式直接修改。"})})}function yt(t){const s=Array.isArray(t)?t:t?.list||t?.data||[];return Array.isArray(s)?s.map(a=>String(a?.name||"")).filter(Boolean).sort():[]}function vt({label:t,value:s,options:a,loading:o,onChange:n,onRefresh:l,onCreate:c}){const m=s&&!a.includes(s);return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:36:5",className:"flex items-center gap-2 flex-wrap flex-1 min-w-0",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:37:7",className:"text-[10px] text-slate-500 w-20 shrink-0",children:t}),e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:38:7",value:s||"",onChange:u=>n(u.target.value),disabled:o,className:"h-7 flex-1 min-w-[160px] max-w-xs bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-2 font-mono",children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:44:9",value:"",disabled:!0,children:a.length===0?"暂无资源":"请选择"}),m&&e.jsxs("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:45:20",value:s,children:[s,"(未在集群中找到)"]}),a.map(u=>e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:46:29",value:u,children:u},u))]}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:48:7",type:"button",size:"sm",variant:"outline",className:"h-7 px-2 border-slate-700 text-slate-400 text-xs",onClick:l,disabled:o,children:o?e.jsx(be,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:49:20",className:"h-3 w-3 animate-spin"}):e.jsx(We,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:49:67",className:"h-3 w-3"})}),e.jsxs(b,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:51:7",type:"button",size:"sm",variant:"outline",className:"h-7 px-2 border-slate-700 text-blue-400 text-xs",onClick:c,children:[e.jsx(Q,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:52:9",className:"h-3 w-3 mr-0.5"}),"新建"]}),a.length===0&&!m&&e.jsxs("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:55:9",className:"text-[10px] text-amber-400/90",children:["命名空间内暂无",t,",请先新建"]})]})}function ln({vol:t,resources:s,resourcesLoading:a,onChange:o,onRefreshResources:n,onCreateResource:l}){return t.type==="persistentVolumeClaim"?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:75:7",className:"space-y-2",children:[e.jsx(vt,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:76:9",label:"PVC 关联",value:t.pvcName||"",options:s.pvcs,loading:a,onChange:c=>o({pvcName:c}),onRefresh:n,onCreate:()=>l("pvcs")}),e.jsxs("label",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:85:9",className:"flex items-center gap-1.5 text-xs text-slate-400 cursor-pointer whitespace-nowrap pl-[88px]",children:[e.jsx("input",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:86:11",type:"checkbox",checked:!!t.pvcReadOnly,onChange:c=>o({pvcReadOnly:c.target.checked}),className:"accent-blue-500"}),"卷只读"]})]}):t.type==="emptyDir"?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:94:7",className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:95:9",className:"text-[10px] text-slate-500 w-20 shrink-0",children:"介质"}),e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:96:9",value:t.medium||"",onChange:c=>o({medium:c.target.value}),className:"h-7 w-28 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5",children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:98:11",value:"",children:"默认磁盘"}),e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:99:11",value:"Memory",children:"Memory"})]}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:101:9",value:t.sizeLimit||"",onChange:c=>o({sizeLimit:c.target.value}),placeholder:"sizeLimit 如 512Mi",className:"h-7 flex-1 min-w-[120px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}):t.type==="hostPath"?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:108:7",className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:109:9",className:"text-[10px] text-slate-500 w-20 shrink-0",children:"主机路径"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:110:9",value:t.path||"",onChange:c=>o({path:c.target.value}),placeholder:"/data/app",className:"h-7 flex-1 min-w-[160px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:112:9",value:t.pathType||"Directory",onChange:c=>o({pathType:c.target.value}),className:"h-7 w-28 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5",children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:114:11",value:"Directory",children:"Directory"}),e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:115:11",value:"File",children:"File"}),e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:116:11",value:"",children:"默认"})]})]}):t.type==="nfs"?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:123:7",className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:124:9",className:"text-[10px] text-slate-500 w-20 shrink-0",children:"NFS"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:125:9",value:t.nfsServer||"",onChange:c=>o({nfsServer:c.target.value}),placeholder:"Server IP",className:"h-7 w-36 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:127:9",value:t.nfsPath||"",onChange:c=>o({nfsPath:c.target.value}),placeholder:"/export/path",className:"h-7 flex-1 min-w-[120px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}):t.type==="configMap"?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:134:7",className:"space-y-2",children:[e.jsx(vt,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:135:9",label:"ConfigMap",value:t.configMapName||"",options:s.configMaps,loading:a,onChange:c=>o({configMapName:c}),onRefresh:n,onCreate:()=>l("configmaps")}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:144:9",className:"flex items-center gap-2 pl-[88px]",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:145:11",className:"text-[10px] text-slate-500 shrink-0",children:"键映射"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:146:11",value:t.cmItems||"",onChange:c=>o({cmItems:c.target.value}),placeholder:"key:path(可选,挂载子项)",className:"h-7 flex-1 max-w-md bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]})]}):t.type==="secret"?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:154:7",className:"space-y-2",children:[e.jsx(vt,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:155:9",label:"Secret",value:t.secretName||"",options:s.secrets,loading:a,onChange:c=>o({secretName:c}),onRefresh:n,onCreate:()=>l("secrets")}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:164:9",className:"flex items-center gap-2 pl-[88px]",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:165:11",className:"text-[10px] text-slate-500 shrink-0",children:"键映射"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:166:11",value:t.secItems||"",onChange:c=>o({secItems:c.target.value}),placeholder:"key:path(可选,挂载子项)",className:"h-7 flex-1 max-w-md bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]})]}):t.type==="custom"?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:173:12",className:"text-[11px] text-amber-400/80",children:"未识别卷类型,保存时将保留原始 YAML 结构"}):null}function nt(t=""){return{containerName:t,mountPath:"",subPath:"",readOnly:!1}}function dn(t=""){return{volume:{name:"",type:"emptyDir"},mounts:[nt(t)]}}const pn=["kube-api-access-","default-token-","kube-"];function jt(t){if(!t||typeof t!="object")return!1;const s=String(t.name||"");return pn.some(a=>s.startsWith(a))?!0:!!(t.projected||t.downwardAPI||t.csi||t.ephemeral)}function Qt(t){const s=t?.trim();if(!s)return;if(s.startsWith("["))try{const o=JSON.parse(s);if(Array.isArray(o))return o.filter(n=>n?.key&&n?.path)}catch{}const a=s.split(",").map(o=>o.trim()).filter(Boolean).map(o=>{const n=o.indexOf(":");return n<=0?null:{key:o.slice(0,n).trim(),path:o.slice(n+1).trim()}}).filter(Boolean);return a.length?a:void 0}function mn(t){if(!t||typeof t!="object")return{name:"",type:"emptyDir"};const s=t.name||"";return t.persistentVolumeClaim?{name:s,type:"persistentVolumeClaim",pvcName:t.persistentVolumeClaim.claimName||"",pvcReadOnly:!!t.persistentVolumeClaim.readOnly}:t.nfs?{name:s,type:"nfs",nfsServer:t.nfs.server||"",nfsPath:t.nfs.path||"",nfsReadOnly:!!t.nfs.readOnly}:t.configMap?{name:s,type:"configMap",configMapName:t.configMap.name||"",cmItems:t.configMap.items?JSON.stringify(t.configMap.items):""}:t.secret?{name:s,type:"secret",secretName:t.secret.secretName||"",secItems:t.secret.items?JSON.stringify(t.secret.items):""}:t.hostPath?{name:s,type:"hostPath",path:t.hostPath.path||"",pathType:t.hostPath.type||""}:t.emptyDir!=null?{name:s,type:"emptyDir",medium:t.emptyDir.medium||"",sizeLimit:t.emptyDir.sizeLimit||""}:jt(t)?{name:s,type:"custom",_raw:t}:{name:s,type:"custom",_raw:t}}function ys(t){if(t.type==="custom"&&t._raw)return JSON.parse(JSON.stringify(t._raw));const s=t.name?.trim();if(!s)return null;const a={name:s};switch(t.type){case"emptyDir":{const o={};t.medium?.trim()&&(o.medium=t.medium.trim()),t.sizeLimit?.trim()&&(o.sizeLimit=t.sizeLimit.trim()),a.emptyDir=o;break}case"hostPath":{const o={path:t.path?.trim()||"/"};t.pathType?.trim()&&(o.type=t.pathType.trim()),a.hostPath=o;break}case"configMap":{const o=t.configMapName?.trim();if(!o)return null;const n={name:o},l=Qt(t.cmItems);l&&(n.items=l),a.configMap=n;break}case"secret":{const o=t.secretName?.trim();if(!o)return null;const n={secretName:o},l=Qt(t.secItems);l&&(n.items=l),a.secret=n;break}case"persistentVolumeClaim":{const o=t.pvcName?.trim();if(!o)return null;const n={claimName:o};t.pvcReadOnly&&(n.readOnly=!0),a.persistentVolumeClaim=n;break}case"nfs":{const o=t.nfsServer?.trim(),n=t.nfsPath?.trim();if(!o||!n)return null;const l={server:o,path:n};t.nfsReadOnly&&(l.readOnly=!0),a.nfs=l;break}default:return null}return a}function xn(t,s){return{containerName:t,volumeName:s.name||"",mountPath:s.mountPath||"",subPath:s.subPath||"",readOnly:!!s.readOnly}}function hn(t){if(!t.volumeName?.trim()||!t.mountPath?.trim())return null;const s={name:t.volumeName.trim(),mountPath:t.mountPath.trim()};return t.subPath?.trim()&&(s.subPath=t.subPath.trim()),t.readOnly&&(s.readOnly=!0),s}const un=["/var/run/secrets/kubernetes.io/serviceaccount"];function vs(t,s){if(!t)return!1;if(s.has(t.name))return!0;const a=t.mountPath||"";return un.some(o=>a.startsWith(o))}function bn(t){const s=t?.spec?.template?.spec||{},a=Array.isArray(s.volumes)?s.volumes:[],o=a.filter(jt),n=a.filter(d=>!jt(d)),l=[...Array.isArray(s.containers)?s.containers:[],...Array.isArray(s.initContainers)?s.initContainers:[]],c=l.map(d=>d.name||"(unnamed)"),m=new Set(o.map(d=>d.name)),u=[];for(const d of l){const k=d.name||"(unnamed)",w=Array.isArray(d.volumeMounts)?d.volumeMounts:[];for(const E of w)vs(E,m)||u.push(xn(k,E))}return{volumes:n.map(mn),mounts:u,containers:c,passthroughVolumes:o}}function yn(t){const{volumes:s,mounts:a,containers:o,passthroughVolumes:n}=bn(t),l=o.find(m=>m!=="(unnamed)")||o[0]||"";return{entries:s.map(m=>{const u=a.filter(d=>d.volumeName===m.name);return{volume:m,mounts:u.length>0?u.map(d=>({containerName:d.containerName,mountPath:d.mountPath,subPath:d.subPath,readOnly:d.readOnly})):[nt(l)]}}),containers:o,passthroughVolumes:n}}function vn(t){const s=t.map(o=>o.volume),a=[];for(const o of t){const n=o.volume.name.trim();if(n)for(const l of o.mounts)l.mountPath.trim()&&a.push({containerName:l.containerName,volumeName:n,mountPath:l.mountPath.trim(),subPath:l.subPath.trim(),readOnly:l.readOnly})}return{volumes:s,mounts:a}}function kn(t,s,a,o){const n=JSON.parse(JSON.stringify(t));n.spec=n.spec||{},n.spec.template=n.spec.template||{},n.spec.template.spec=n.spec.template.spec||{};const l=n.spec.template.spec,c=s.map(ys).filter(Boolean),m=[...o,...c];m.length>0?l.volumes=m:delete l.volumes;const u=new Set(o.map(k=>k.name)),d=k=>{const w=k.name||"(unnamed)",y=(Array.isArray(k.volumeMounts)?k.volumeMounts:[]).filter(D=>vs(D,u)),S=a.filter(D=>D.containerName===w).map(hn).filter(Boolean),C=[...y,...S];C.length>0?k.volumeMounts=C:delete k.volumeMounts};return(l.containers||[]).forEach(d),(l.initContainers||[]).forEach(d),n}const Nt=[{key:"persistentVolumeClaim",label:"存储卷声明",icon:Xe,color:"text-emerald-400"},{key:"emptyDir",label:"临时目录(EmptyDir)",icon:Gs,color:"text-slate-400"},{key:"hostPath",label:"HostPath",icon:os,color:"text-amber-400"},{key:"nfs",label:"NFS",icon:Et,color:"text-purple-400"},{key:"configMap",label:"配置字典",icon:Vs,color:"text-blue-400"},{key:"secret",label:"密文",icon:cs,color:"text-rose-400"}],gn=new Set(Nt.map(t=>t.key));function jn({clusterCode:t,namespace:s,deploymentName:a,manifest:o,onSaved:n,onCancel:l}){const{toast:c}=Te(),[m,u]=p.useState(!1),[d,k]=p.useState(!o),[w,E]=p.useState(o||{}),[y,S]=p.useState([]),[C,D]=p.useState([]),[z,I]=p.useState([]),[Y,U]=p.useState({configMaps:[],secrets:[],pvcs:[]}),[Z,_]=p.useState(!1),[V,F]=p.useState(null),J=p.useCallback(async()=>{if(!(!t||!s)){_(!0);try{const[B,i,x]=await Promise.all([X.getNamespaceConfigMaps(t,s).catch(()=>[]),X.getNamespaceSecrets(t,s).catch(()=>[]),X.getPVCs(t,s).catch(()=>[])]);U({configMaps:yt(B),secrets:yt(i),pvcs:yt(x)})}finally{_(!1)}}},[t,s]);p.useEffect(()=>{J()},[J]),p.useEffect(()=>{if(!o){k(!1);return}E(o);const B=yn(o);S(B.entries),D(B.containers),I(B.passthroughVolumes),k(!1)},[o]);const ee=C.find(B=>B!=="(unnamed)")||C[0]||"",g=(B,i)=>S(x=>x.map((r,h)=>h===B?{...r,volume:{...r.volume,...i}}:r)),O=(B,i,x)=>S(r=>r.map((h,j)=>j!==B?h:{...h,mounts:h.mounts.map((N,P)=>P===i?{...N,...x}:N)})),q=B=>S(i=>i.map((x,r)=>r!==B?x:{...x,mounts:[...x.mounts,nt(ee)]})),K=(B,i)=>S(x=>x.map((r,h)=>{if(h!==B)return r;const j=r.mounts.filter((N,P)=>P!==i);return{...r,mounts:j.length>0?j:[nt(ee)]}})),le=()=>S(B=>[...B,dn(ee)]),ue=B=>S(i=>i.filter((x,r)=>r!==B)),ke=async()=>{for(const B of y){if(!B.volume.name.trim()){c({title:"请填写数据卷名称",variant:"destructive"});return}if(!ys(B.volume)){const x=B.volume.type==="configMap"?"请选择 ConfigMap":B.volume.type==="secret"?"请选择 Secret":B.volume.type==="persistentVolumeClaim"?"请选择 PVC":"的类型必填项";c({title:"数据卷配置不完整",description:`请为「${B.volume.name}」${x}`,variant:"destructive"});return}if(B.mounts.filter(x=>x.mountPath.trim()).length===0){c({title:"请填写挂载路径",description:`数据卷「${B.volume.name}」需至少挂载到一个容器`,variant:"destructive"});return}}u(!0);try{const{volumes:B,mounts:i}=vn(y),x=kn(w,B,i,z);await ct(t,s,a,x),c({title:"存储配置已保存",description:`${a} 更新已提交`}),n(x)}catch(B){c({title:"保存失败",description:B?.message||String(B),variant:"destructive"})}finally{u(!1)}};return d?e.jsx(W,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:164:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:165:9",className:"p-12 text-center",children:[e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:166:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:167:11",className:"text-slate-500 mt-3 text-sm",children:"加载中..."})]})}):o?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:182:5",className:"space-y-4",children:[V&&e.jsx(hs,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:184:9",clusterCode:t,namespace:s,resource:V,name:"",isCreate:!0,onClose:()=>F(null),onSaved:()=>{J(),F(null)}}),e.jsxs(W,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:194:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(me,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:195:9",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:196:11",className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:197:13",children:[e.jsxs(xe,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:198:15",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(Xe,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:199:17",className:"h-4 w-4 text-emerald-400"}),"数据卷",e.jsx(ne,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:201:17",variant:"outline",className:"border-slate-700 text-slate-400",children:y.length})]}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:203:15",className:"text-[11px] text-slate-500 mt-1",children:"定义数据卷,并将其挂载到工作负载的容器中"})]}),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:205:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs shrink-0",onClick:le,children:[e.jsx(Q,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:206:15",className:"h-3 w-3 mr-1"}),"添加数据卷"]})]})}),e.jsx(G,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:210:9",className:"pt-0 space-y-4",children:y.length===0?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:212:13",className:"text-center py-10 text-slate-500 text-sm border border-dashed border-slate-800 rounded-lg",children:[e.jsx(Xe,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:213:15",className:"h-8 w-8 mx-auto mb-2 text-slate-700"}),"未配置数据卷,点击「添加数据卷」开始"]}):y.map((B,i)=>{const x=B.volume,r=Nt.find(N=>N.key===x.type),h=r?.icon||Fs,j=gn.has(x.type)?x.type:"emptyDir";return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:222:15",className:"bg-slate-950/60 border border-slate-800 rounded-lg",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:224:17",className:"p-3 space-y-2.5 border-b border-slate-800/80",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:225:19",className:"flex items-center gap-2 flex-wrap",children:[e.jsx(h,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:226:21",className:`h-4 w-4 ${r?.color||"text-slate-400"}`}),e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:227:21",className:"text-xs text-slate-400 shrink-0",children:"数据卷名称"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:228:21",value:x.name,onChange:N=>{const P=N.target.value,H={name:P};x.type==="configMap"&&!x.configMapName&&(H.configMapName=P),x.type==="secret"&&!x.secretName&&(H.secretName=P),x.type==="persistentVolumeClaim"&&!x.pvcName&&(H.pvcName=P),g(i,H)},placeholder:"如 app-logs / fluent-bit-config",className:"h-8 w-44 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"}),e.jsx("select",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:242:21",value:j,onChange:N=>{const P=N.target.value,H={type:P};P==="configMap"&&Y.configMaps.length===1&&(H.configMapName=Y.configMaps[0]),P==="secret"&&Y.secrets.length===1&&(H.secretName=Y.secrets[0]),P==="persistentVolumeClaim"&&Y.pvcs.length===1&&(H.pvcName=Y.pvcs[0]),g(i,H)},className:"h-8 min-w-[168px] bg-slate-800 border border-slate-700 rounded-md text-xs text-slate-300 px-2",children:Nt.map(N=>e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:255:25",value:N.key,children:N.label},N.key))}),e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:258:21",size:"icon",variant:"ghost",className:"h-8 w-8 text-red-400 ml-auto",onClick:()=>ue(i),children:e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:259:23",className:"h-4 w-4"})})]}),e.jsx(ln,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:262:19",vol:x,resources:Y,resourcesLoading:Z,onChange:N=>{const P=y[i]?.volume,H={};P&&!P.name.trim()&&(N.configMapName&&(H.name=N.configMapName),N.secretName&&(H.name=N.secretName),N.pvcName&&(H.name=N.pvcName)),g(i,{...N,...H})},onRefreshResources:J,onCreateResource:F})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:282:17",className:"px-3 py-2.5 bg-slate-900/40 space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:283:19",className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:284:21",className:"text-[11px] text-slate-500 flex items-center gap-1.5",children:[e.jsx($e,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:285:23",className:"h-3.5 w-3.5 text-blue-400"}),"将上述数据卷挂载到容器"]}),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:288:21",size:"sm",variant:"ghost",className:"h-6 px-2 text-[11px] text-slate-400 hover:text-slate-200",onClick:()=>q(i),children:[e.jsx(Q,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:289:23",className:"h-3 w-3 mr-0.5"}),"添加挂载"]})]}),B.mounts.map((N,P)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:293:21",className:"space-y-2 rounded-md border border-slate-800/60 bg-slate-950/40 p-2.5",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:294:23",className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:295:25",value:N.containerName,onChange:H=>O(i,P,{containerName:H.target.value}),className:"h-8 min-w-[140px] max-w-[280px] bg-slate-800 border border-slate-700 rounded-md text-sm text-slate-200 px-2 font-medium truncate",children:[C.length===0&&e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:300:55",value:"",children:"(无容器)"}),C.map(H=>e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:301:51",value:H,children:H},H))]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:303:25",className:"flex items-center gap-1 bg-slate-800 rounded-lg p-0.5 border border-slate-700",children:[e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:304:27",type:"button",onClick:()=>O(i,P,{readOnly:!0}),className:`px-2.5 py-1 rounded text-xs font-medium transition-all ${N.readOnly?"bg-amber-500/20 text-amber-300":"text-slate-500 hover:text-slate-300"}`,children:"只读"}),e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:308:27",type:"button",onClick:()=>O(i,P,{readOnly:!1}),className:`px-2.5 py-1 rounded text-xs font-medium transition-all ${N.readOnly?"text-slate-500 hover:text-slate-300":"bg-blue-500/20 text-blue-300"}`,children:"读写"})]}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:313:25",value:N.mountPath,onChange:H=>O(i,P,{mountPath:H.target.value}),placeholder:"挂载路径 /bitcloud/app/.../logs",className:"h-8 flex-1 min-w-[200px] bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"}),B.mounts.length>1&&e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:320:27",size:"icon",variant:"ghost",className:"h-8 w-8 text-red-400/70 shrink-0",onClick:()=>K(i,P),children:e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:321:29",className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:325:23",className:"flex items-center gap-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:326:25",className:"text-[11px] text-slate-500 shrink-0",children:"子路径 subPath"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:327:25",value:N.subPath,onChange:H=>O(i,P,{subPath:H.target.value}),placeholder:"如 config.yaml(挂载单文件时填写)",className:"h-7 flex-1 max-w-md bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]})]},P))]})]},i)})})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:343:7",className:"flex justify-end gap-2 pt-2",children:[e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:344:9",variant:"outline",className:"border-slate-700 text-slate-400",onClick:l,children:"取消"}),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:345:9",className:"bg-blue-600 hover:bg-blue-700",disabled:m,onClick:ke,children:[m?e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:346:21",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(rt,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:346:73",className:"h-4 w-4 mr-1"}),"保存"]})]})]}):e.jsx(W,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:175:7",className:"bg-slate-900 border-slate-800",children:e.jsx(G,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:176:9",className:"p-8 text-center text-slate-500",children:"未获取到 manifest 数据,请使用 YAML 编辑模式。"})})}const Nn=[{key:"nodeName",label:"节点名称"},{key:"nodeSelector",label:"标签选择器"},{key:"nodeAffinity",label:"节点亲和性"}];function fn({scheduleMode:t,onScheduleModeChange:s,nodeName:a,onNodeNameChange:o,availableNodes:n,nodesLoading:l,labelSelectorKv:c,onAddLabelSelector:m,onRemoveLabelSelector:u,onUpdateLabelSelector:d,nodeLabels:k}){return e.jsxs(W,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:54:5",className:"bg-slate-900 border-slate-800",children:[e.jsxs(me,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:55:7",className:"pb-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:56:9",className:"flex items-center justify-between",children:[e.jsxs(xe,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:57:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(Et,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:58:13",className:"h-4 w-4 text-emerald-400"}),"调度 (Scheduling)"]}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:60:11",className:"flex items-center gap-1 bg-slate-800 rounded-lg p-0.5 border border-slate-700",children:Nn.map(w=>e.jsx("button",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:62:15",onClick:()=>s(w.key),className:`px-2.5 py-1 rounded text-[10px] font-medium transition-all ${t===w.key?"bg-emerald-500/20 text-emerald-300 shadow-sm":"text-slate-400 hover:text-slate-300"}`,children:w.label},w.key))})]}),e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:76:9",className:"text-xs text-slate-500 mt-1",children:[t==="nodeName"&&"Pod 将直接调度到指定节点",t==="nodeSelector"&&"Pod 将调度到匹配标签的节点",t==="nodeAffinity"&&"通过亲和性规则控制 Pod 调度到指定节点"]})]}),e.jsxs(G,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:82:7",className:"pt-0",children:[t==="nodeName"&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:84:11",className:"space-y-2",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:85:13",className:"text-slate-400 text-xs",children:"请选择节点"}),l?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:87:15",className:"flex items-center gap-1 text-slate-500 text-xs",children:[e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:88:17",className:"h-3 w-3 animate-spin"}),"加载节点列表..."]}):e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:91:15",value:a,onChange:w=>o(w.target.value),className:"h-8 w-full bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-2",children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:96:17",value:"",children:"(不指定)"}),n.map(w=>e.jsxs("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:98:19",value:w.name,children:[w.name," ",w.ip?`(${w.ip})`:""]},w.name))]}),a&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:105:15",className:"text-[10px] text-slate-500",children:["已选择: ",e.jsx("code",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:106:22",className:"bg-slate-800 px-1 py-0.5 rounded text-emerald-400",children:a})]})]}),t==="nodeSelector"&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:113:11",className:"space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:114:13",className:"flex items-center justify-between",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:115:15",className:"text-slate-400 text-xs",children:"请选择标签"}),e.jsxs(b,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:116:15",size:"sm",variant:"ghost",className:"h-6 text-xs text-slate-400",onClick:m,children:[e.jsx(Q,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:117:17",className:"h-3 w-3 mr-1"}),"添加"]})]}),c.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:121:15",className:"text-xs text-slate-600 italic",children:"未配置标签选择器"}):c.map((w,E)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:124:17",className:"flex items-center gap-2",children:[e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:125:19",value:w.key,onChange:y=>d(E,{key:y.target.value,value:""}),className:"flex-1 h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5",children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:130:21",value:"",children:"选择标签"}),Object.entries(k).map(([y,S])=>e.jsxs("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:132:23",value:y,children:[y," (",S.length,")"]},y))]}),e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:135:19",value:w.value,onChange:y=>d(E,{value:y.target.value}),className:"flex-1 h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5",disabled:!w.key,children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:141:21",value:"",children:"选择值"}),(k[w.key]||[]).map(y=>e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:143:23",value:y,children:y},y))]}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:146:19",size:"icon",variant:"ghost",className:"h-6 w-6 text-red-400",onClick:()=>u(E),children:e.jsx(he,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:152:21",className:"h-3 w-3"})})]},E))]}),t==="nodeAffinity"&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:161:11",className:"space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:162:13",className:"flex items-center justify-between",children:[e.jsxs(M,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:163:15",className:"text-slate-400 text-xs",children:["请选择标签 ",e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:164:23",className:"text-slate-600",children:"(生成 requiredDuringScheduling 规则)"})]}),e.jsxs(b,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:166:15",size:"sm",variant:"ghost",className:"h-6 text-xs text-slate-400",onClick:m,children:[e.jsx(Q,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:167:17",className:"h-3 w-3 mr-1"}),"添加"]})]}),c.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:171:15",className:"text-xs text-slate-600 italic",children:"未配置亲和性规则"}):c.map((w,E)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:174:17",className:"flex items-center gap-2",children:[e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:175:19",value:w.key,onChange:y=>d(E,{key:y.target.value,value:""}),className:"flex-1 h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5",children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:180:21",value:"",children:"选择标签"}),Object.entries(k).map(([y,S])=>e.jsxs("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:182:23",value:y,children:[y," (",S.length,")"]},y))]}),e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:185:19",value:w.value,onChange:y=>d(E,{value:y.target.value}),className:"flex-1 h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5",disabled:!w.key,children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:191:21",value:"",children:"选择值"}),(k[w.key]||[]).map(y=>e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:193:23",value:y,children:y},y))]}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:196:19",size:"icon",variant:"ghost",className:"h-6 w-6 text-red-400",onClick:()=>u(E),children:e.jsx(he,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:202:21",className:"h-3 w-3"})})]},E))]})]})]})}function Sn({dnsNameservers:t,onDnsNameserversChange:s,dnsSearches:a,onDnsSearchesChange:o,dnsOptions:n,onDnsOptionsChange:l,hostAliases:c,onHostAliasesChange:m}){const u=()=>l([...n,{name:"",value:""}]),d=(S,C)=>l(n.map((D,z)=>z===S?{...D,...C}:D)),k=S=>l(n.filter((C,D)=>D!==S)),w=()=>m([...c,{ip:"",hostnames:""}]),E=(S,C)=>m(c.map((D,z)=>z===S?{...D,...C}:D)),y=S=>m(c.filter((C,D)=>D!==S));return e.jsxs(e.Fragment,{children:[e.jsxs(W,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:53:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(me,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:54:9",className:"pb-3",children:e.jsxs(xe,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:55:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(qs,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:56:13",className:"h-4 w-4 text-indigo-400"}),"DNS 配置 (dnsConfig)"]})}),e.jsxs(G,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:59:9",className:"pt-0 space-y-3",children:[e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:60:11",className:"text-[11px] text-slate-500",children:["提示:dnsConfig 通常与 ",e.jsx("code",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:61:30",className:"text-slate-400",children:"dnsPolicy: None"})," 搭配使用。每行一个值。"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:63:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:64:13",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:65:15",className:"text-slate-500 text-xs",children:"nameservers(每行一个 IP)"}),e.jsx("textarea",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:66:15",value:t,onChange:S=>s(S.target.value),placeholder:`8.8.8.8
|
||
114.114.114.114`,rows:3,className:"w-full mt-1 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 font-mono p-2 resize-y"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:74:13",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:75:15",className:"text-slate-500 text-xs",children:"searches(搜索域,每行一个)"}),e.jsx("textarea",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:76:15",value:a,onChange:S=>o(S.target.value),placeholder:`svc.cluster.local
|
||
cluster.local`,rows:3,className:"w-full mt-1 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 font-mono p-2 resize-y"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:85:11",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:86:13",className:"flex items-center justify-between mb-1",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:87:15",className:"text-slate-400 text-xs",children:"options(DNS 选项)"}),e.jsxs(b,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:88:15",size:"sm",variant:"ghost",className:"h-6 text-xs text-slate-400",onClick:u,children:[e.jsx(Q,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:89:17",className:"h-3 w-3 mr-1"}),"添加"]})]}),n.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:93:15",className:"text-xs text-slate-600 italic",children:"未配置"}):n.map((S,C)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:96:17",className:"flex items-center gap-2 mb-1.5",children:[e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:97:19",value:S.name,onChange:D=>d(C,{name:D.target.value}),placeholder:"ndots",className:"flex-1 h-7 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:103:19",className:"text-slate-600",children:":"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:104:19",value:S.value,onChange:D=>d(C,{value:D.target.value}),placeholder:"5(可留空)",className:"flex-1 h-7 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:110:19",size:"icon",variant:"ghost",className:"h-6 w-6 text-red-400",onClick:()=>k(C),children:e.jsx(he,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:111:21",className:"h-3 w-3"})})]},C))]})]})]}),e.jsxs(W,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:120:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(me,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:121:9",className:"pb-3",children:e.jsxs(xe,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:122:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(Ys,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:123:13",className:"h-4 w-4 text-amber-400"}),"主机别名 (hostAliases)"]})}),e.jsxs(G,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:126:9",className:"pt-0 space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:127:11",className:"flex items-center justify-between mb-1",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:128:13",className:"text-slate-400 text-xs",children:"IP → 主机名映射(注入 Pod 的 /etc/hosts)"}),e.jsxs(b,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:129:13",size:"sm",variant:"ghost",className:"h-6 text-xs text-slate-400",onClick:w,children:[e.jsx(Q,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:130:15",className:"h-3 w-3 mr-1"}),"添加"]})]}),c.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:134:13",className:"text-xs text-slate-600 italic",children:"未配置"}):c.map((S,C)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:137:15",className:"flex items-center gap-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:138:17",value:S.ip,onChange:D=>E(C,{ip:D.target.value}),placeholder:"10.10.10.72",className:"w-40 h-7 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:144:17",className:"text-slate-600",children:"→"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:145:17",value:S.hostnames,onChange:D=>E(C,{hostnames:D.target.value}),placeholder:"gitlab.local, registry.local",className:"flex-1 h-7 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:151:17",size:"icon",variant:"ghost",className:"h-6 w-6 text-red-400",onClick:()=>y(C),children:e.jsx(he,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:152:19",className:"h-3 w-3"})})]},C))]})]})]})}function Cn({clusterCode:t,namespace:s,deploymentName:a,manifest:o,onSaved:n,onCancel:l}){const{toast:c}=Te(),[m,u]=p.useState(!1),[d,k]=p.useState(!o),[w,E]=p.useState(o||{}),[y,S]=p.useState("RollingUpdate"),[C,D]=p.useState("25%"),[z,I]=p.useState("25%"),[Y,U]=p.useState("10"),[Z,_]=p.useState("600"),[V,F]=p.useState("nodeSelector"),[J,ee]=p.useState(""),[g,O]=p.useState([]),[q,K]=p.useState(!1),[le,ue]=p.useState([]),[ke,B]=p.useState({}),[i,x]=p.useState([]),[r,h]=p.useState("ClusterFirst"),[j,N]=p.useState("Always"),[P,H]=p.useState("default-scheduler"),[de,we]=p.useState("30"),[pe,R]=p.useState(""),[oe,Ne]=p.useState(""),[fe,A]=p.useState(""),[ye,De]=p.useState(""),[je,He]=p.useState(!1),[lt,Ge]=p.useState(!1),[dt,Ve]=p.useState(!1),[Pe,Dt]=p.useState(!1),[Pt,At]=p.useState(!1),[Tt,Ht]=p.useState([]),[Mt,Bt]=p.useState(""),[Rt,It]=p.useState(""),[Ot,Lt]=p.useState([]);p.useEffect(()=>{const f=o;if(!f){k(!1);return}E(f);const T=f?.spec||{},$=T?.template?.spec||{},te=T.strategy||{};S(te.type||"RollingUpdate");const ae=te.rollingUpdate||{};D(String(ae.maxSurge??"25%")),I(String(ae.maxUnavailable??"25%")),U(T.revisionHistoryLimit!=null?String(T.revisionHistoryLimit):"10"),_(T.progressDeadlineSeconds!=null?String(T.progressDeadlineSeconds):"600");const ve=$.nodeSelector||{},Ie=Object.entries(ve).map(([ie,zt])=>({key:ie,value:String(zt)}));ue(Ie),ee($.nodeName||""),$.nodeName?F("nodeName"):$.affinity?.nodeAffinity?F("nodeAffinity"):Ie.length>0&&F("nodeSelector"),t&&(K(!0),X.getClusterNodes(t).then(ie=>{const _t=(Array.isArray(ie)?ie:ie?.items||ie?.list||[]).map(qe=>{const Me=qe.metadata||{},Ye=qe.status||{},fs=(Array.isArray(Ye.addresses)?Ye.addresses:[]).find(Ss=>Ss.type==="InternalIP")?.address||"";return{name:Me.name||"",ip:fs,labels:Me.labels||{}}});O(_t);const Oe={};for(const qe of _t)for(const[Me,Ye]of Object.entries(qe.labels)){const pt=String(Ye);Oe[Me]||(Oe[Me]=[]),Oe[Me].includes(pt)||Oe[Me].push(pt)}B(Oe)}).catch(()=>{}).finally(()=>K(!1)));const Fe=Array.isArray($.tolerations)?$.tolerations:[];x(Fe.map(ie=>({key:ie.key||"",operator:ie.operator||"Equal",value:ie.value||"",effect:ie.effect||"",tolerationSeconds:ie.tolerationSeconds!=null?String(ie.tolerationSeconds):""}))),h($.dnsPolicy||"ClusterFirst"),N($.restartPolicy||"Always"),H($.schedulerName||"default-scheduler"),we($.terminationGracePeriodSeconds!=null?String($.terminationGracePeriodSeconds):"30"),R($.serviceAccountName||"");const Se=$.securityContext||{};Ne(Se.fsGroup!=null?String(Se.fsGroup):""),A(Se.runAsUser!=null?String(Se.runAsUser):""),De(Se.runAsGroup!=null?String(Se.runAsGroup):""),He(!!Se.runAsNonRoot),Ge(!!$.hostNetwork),Ve(!!$.hostIPC),Dt(!!$.hostPID),At(!!$.shareProcessNamespace);const L=Array.isArray($.hostAliases)?$.hostAliases:[];Ht(L.map(ie=>({ip:ie.ip||"",hostnames:Array.isArray(ie.hostnames)?ie.hostnames.join(", "):""})));const se=$.dnsConfig||{};Bt(Array.isArray(se.nameservers)?se.nameservers.join(`
|
||
`):""),It(Array.isArray(se.searches)?se.searches.join(`
|
||
`):"");const it=Array.isArray(se.options)?se.options:[];Lt(it.map(ie=>({name:ie.name||"",value:ie.value||""}))),k(!1)},[o]);const ks=()=>ue(f=>[...f,{key:"",value:""}]),gs=f=>ue(T=>T.filter(($,te)=>te!==f)),js=(f,T)=>ue($=>$.map((te,ae)=>ae===f?{...te,...T}:te)),Ns=async()=>{u(!0);try{const f=JSON.parse(JSON.stringify(w));f.spec=f.spec||{},f.spec.template=f.spec.template||{},f.spec.template.spec=f.spec.template.spec||{};const T=f.spec.template.spec;if(f.spec.strategy={type:y},y==="RollingUpdate"&&(f.spec.strategy.rollingUpdate={maxSurge:C,maxUnavailable:z}),Y&&(f.spec.revisionHistoryLimit=Number(Y)),Z&&(f.spec.progressDeadlineSeconds=Number(Z)),V==="nodeName"&&J.trim())T.nodeName=J.trim(),delete T.nodeSelector,T.affinity&&delete T.affinity.nodeAffinity;else if(V==="nodeSelector"){const L={};for(const{key:se,value:it}of le){const ie=se.trim();ie&&(L[ie]=it)}Object.keys(L).length>0?T.nodeSelector=L:delete T.nodeSelector,T.nodeName&&delete T.nodeName,T.affinity&&delete T.affinity.nodeAffinity}else if(V==="nodeAffinity"){const L=le.filter(se=>se.key.trim()).map(se=>({key:se.key.trim(),operator:"In",values:[se.value]}));L.length>0?(T.affinity=T.affinity||{},T.affinity.nodeAffinity={requiredDuringSchedulingIgnoredDuringExecution:{nodeSelectorTerms:[{matchExpressions:L}]}}):T.affinity&&delete T.affinity.nodeAffinity,delete T.nodeSelector,T.nodeName&&delete T.nodeName}const $=i.filter(L=>L.key||L.operator==="Exists").map(L=>{const se={};return L.key&&(se.key=L.key),L.operator&&(se.operator=L.operator),L.value&&L.operator!=="Exists"&&(se.value=L.value),L.effect&&(se.effect=L.effect),L.tolerationSeconds&&L.effect==="NoExecute"&&(se.tolerationSeconds=Number(L.tolerationSeconds)),se});$.length>0?T.tolerations=$:delete T.tolerations,r&&(T.dnsPolicy=r),j&&(T.restartPolicy=j),P&&(T.schedulerName=P),de&&(T.terminationGracePeriodSeconds=Number(de)),pe&&(T.serviceAccountName=pe);const te={};oe&&(te.fsGroup=Number(oe)),fe&&(te.runAsUser=Number(fe)),ye&&(te.runAsGroup=Number(ye)),je&&(te.runAsNonRoot=!0),Object.keys(te).length>0?T.securityContext=te:delete T.securityContext,lt?T.hostNetwork=!0:delete T.hostNetwork,dt?T.hostIPC=!0:delete T.hostIPC,Pe?T.hostPID=!0:delete T.hostPID,Pt?T.shareProcessNamespace=!0:delete T.shareProcessNamespace;const ae=Tt.filter(L=>L.ip.trim()).map(L=>({ip:L.ip.trim(),hostnames:L.hostnames.split(/[,\s]+/).map(se=>se.trim()).filter(Boolean)})).filter(L=>L.hostnames.length>0);ae.length>0?T.hostAliases=ae:delete T.hostAliases;const ve={},Ie=Mt.split(`
|
||
`).map(L=>L.trim()).filter(Boolean);Ie.length>0&&(ve.nameservers=Ie);const Fe=Rt.split(`
|
||
`).map(L=>L.trim()).filter(Boolean);Fe.length>0&&(ve.searches=Fe);const Se=Ot.filter(L=>L.name.trim()).map(L=>{const se={name:L.name.trim()};return L.value.trim()&&(se.value=L.value.trim()),se});Se.length>0&&(ve.options=Se),Object.keys(ve).length>0?T.dnsConfig=ve:delete T.dnsConfig,await ct(t,s,a,f),c({title:"高级设置已保存",description:`${a} 更新已提交`}),n(f)}catch(f){c({title:"保存失败",description:f?.message||String(f),variant:"destructive"})}finally{u(!1)}};return d?e.jsx(W,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:322:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:323:9",className:"p-12 text-center",children:[e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:324:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:325:11",className:"text-slate-500 mt-3 text-sm",children:"加载中..."})]})}):o?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:342:5",className:"space-y-4",children:[e.jsxs(W,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:344:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(me,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:345:9",className:"pb-3",children:e.jsxs(xe,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:346:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(We,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:347:13",className:"h-4 w-4 text-blue-400"}),"更新策略 (Strategy)"]})}),e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:350:9",className:"pt-0 space-y-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:351:11",className:"flex items-center gap-4",children:[e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:352:13",className:"flex items-center gap-1.5 text-xs text-slate-300 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:353:15",type:"radio",checked:y==="RollingUpdate",onChange:()=>S("RollingUpdate"),className:"accent-blue-500"}),"RollingUpdate(滚动更新)"]}),e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:357:13",className:"flex items-center gap-1.5 text-xs text-slate-300 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:358:15",type:"radio",checked:y==="Recreate",onChange:()=>S("Recreate"),className:"accent-blue-500"}),"Recreate(重建)"]})]}),y==="RollingUpdate"&&e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:364:13",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:365:15",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:366:17",className:"text-slate-500 text-xs",children:"maxSurge(整数或百分比,超出期望副本数)"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:367:17",value:C,onChange:f=>D(f.target.value),placeholder:"25%",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:370:15",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:371:17",className:"text-slate-500 text-xs",children:"maxUnavailable(整数或百分比,不可用上限)"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:372:17",value:z,onChange:f=>I(f.target.value),placeholder:"25%",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]})]})]})]}),e.jsxs(W,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:381:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(me,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:382:9",className:"pb-3",children:e.jsxs(xe,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:383:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(rs,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:384:13",className:"h-4 w-4 text-amber-400"}),"历史版本 & 进度"]})}),e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:387:9",className:"pt-0 grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:388:11",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:389:13",className:"text-slate-500 text-xs",children:"revisionHistoryLimit(保留 RS 历史)"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:390:13",type:"number",value:Y,onChange:f=>U(f.target.value),className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:393:11",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:394:13",className:"text-slate-500 text-xs",children:"progressDeadlineSeconds(升级超时秒数)"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:395:13",type:"number",value:Z,onChange:f=>_(f.target.value),className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]})]})]}),e.jsxs(W,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:402:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(me,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:403:9",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:404:11",className:"flex items-center justify-between",children:[e.jsx(xe,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:405:13",className:"text-sm text-slate-200",children:"容忍 (Tolerations)"}),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:406:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:()=>x(f=>[...f,{key:"",operator:"Equal",value:"",effect:"NoSchedule",tolerationSeconds:""}]),children:[e.jsx(Q,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:408:15",className:"h-3 w-3 mr-1"}),"添加"]})]})}),e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:412:9",className:"pt-0 space-y-2",children:[i.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:413:40",className:"text-xs text-slate-600",children:"未配置容忍"}),i.map((f,T)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:415:13",className:"grid grid-cols-[1fr_80px_1fr_100px_80px_auto] gap-2 items-center",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:416:15",value:f.key,placeholder:"key",onChange:$=>x(te=>te.map((ae,ve)=>ve===T?{...ae,key:$.target.value}:ae)),className:"h-7 bg-slate-800 border-slate-700 text-xs font-mono"}),e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:418:15",value:f.operator,onChange:$=>x(te=>te.map((ae,ve)=>ve===T?{...ae,operator:$.target.value}:ae)),className:"h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1",children:[e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:420:17",value:"Equal",children:"Equal"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:421:17",value:"Exists",children:"Exists"})]}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:423:15",value:f.value,placeholder:"value",disabled:f.operator==="Exists",onChange:$=>x(te=>te.map((ae,ve)=>ve===T?{...ae,value:$.target.value}:ae)),className:"h-7 bg-slate-800 border-slate-700 text-xs font-mono"}),e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:426:15",value:f.effect,onChange:$=>x(te=>te.map((ae,ve)=>ve===T?{...ae,effect:$.target.value}:ae)),className:"h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1",children:[e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:428:17",value:"",children:"任意"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:429:17",value:"NoSchedule",children:"NoSchedule"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:430:17",value:"PreferNoSchedule",children:"PreferNoSchedule"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:431:17",value:"NoExecute",children:"NoExecute"})]}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:433:15",value:f.tolerationSeconds,placeholder:"秒",disabled:f.effect!=="NoExecute",onChange:$=>x(te=>te.map((ae,ve)=>ve===T?{...ae,tolerationSeconds:$.target.value}:ae)),className:"h-7 bg-slate-800 border-slate-700 text-xs font-mono"}),e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:436:15",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-400",onClick:()=>x($=>$.filter((te,ae)=>ae!==T)),children:e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:437:17",className:"h-3 w-3"})})]},T))]})]}),e.jsx(fn,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:444:7",scheduleMode:V,onScheduleModeChange:F,nodeName:J,onNodeNameChange:ee,availableNodes:g,nodesLoading:q,labelSelectorKv:le,onAddLabelSelector:ks,onRemoveLabelSelector:gs,onUpdateLabelSelector:js,nodeLabels:ke}),e.jsxs(W,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:459:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(me,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:460:9",className:"pb-3",children:e.jsxs(xe,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:461:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(kt,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:462:13",className:"h-4 w-4 text-slate-400"}),"Pod 级别"]})}),e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:465:9",className:"pt-0 grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:466:11",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:467:13",className:"text-slate-500 text-xs",children:"dnsPolicy"}),e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:468:13",value:r,onChange:f=>h(f.target.value),className:"h-8 mt-1 w-full bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-2",children:[e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:470:15",value:"ClusterFirst",children:"ClusterFirst"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:471:15",value:"ClusterFirstWithHostNet",children:"ClusterFirstWithHostNet"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:472:15",value:"Default",children:"Default"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:473:15",value:"None",children:"None"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:476:11",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:477:13",className:"text-slate-500 text-xs",children:"restartPolicy"}),e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:478:13",value:j,onChange:f=>N(f.target.value),className:"h-8 mt-1 w-full bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-2",children:[e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:480:15",value:"Always",children:"Always"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:481:15",value:"OnFailure",children:"OnFailure"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:482:15",value:"Never",children:"Never"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:485:11",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:486:13",className:"text-slate-500 text-xs",children:"schedulerName"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:487:13",value:P,onChange:f=>H(f.target.value),className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:490:11",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:491:13",className:"text-slate-500 text-xs",children:"terminationGracePeriodSeconds"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:492:13",type:"number",value:de,onChange:f=>we(f.target.value),className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:495:11",className:"col-span-2",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:496:13",className:"text-slate-500 text-xs",children:"serviceAccountName"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:497:13",value:pe,onChange:f=>R(f.target.value),placeholder:"default",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]})]})]}),e.jsxs(W,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:504:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(me,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:505:9",className:"pb-3",children:e.jsxs(xe,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:506:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(ds,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:507:13",className:"h-4 w-4 text-rose-400"}),"Pod 安全上下文 (securityContext)"]})}),e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:510:9",className:"pt-0 grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:511:11",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:512:13",className:"text-slate-500 text-xs",children:"fsGroup"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:513:13",type:"number",value:oe,onChange:f=>Ne(f.target.value),placeholder:"1000",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:516:11",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:517:13",className:"text-slate-500 text-xs",children:"runAsUser"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:518:13",type:"number",value:fe,onChange:f=>A(f.target.value),placeholder:"1000",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:521:11",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:522:13",className:"text-slate-500 text-xs",children:"runAsGroup"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:523:13",type:"number",value:ye,onChange:f=>De(f.target.value),placeholder:"1000",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:526:11",className:"flex items-end pb-1",children:e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:527:13",className:"flex items-center gap-2 text-xs text-slate-400 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:528:15",type:"checkbox",checked:je,onChange:f=>He(f.target.checked),className:"accent-blue-500"}),"runAsNonRoot"]})})]})]}),e.jsxs(W,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:537:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(me,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:538:9",className:"pb-3",children:e.jsxs(xe,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:539:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(Ae,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:540:13",className:"h-4 w-4 text-cyan-400"}),"主机设置 (Host Namespace)"]})}),e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:543:9",className:"pt-0 grid grid-cols-2 gap-3",children:[e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:544:11",className:"flex items-center gap-2 text-xs text-slate-300 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:545:13",type:"checkbox",checked:lt,onChange:f=>Ge(f.target.checked),className:"accent-blue-500"}),"hostNetwork(共享主机网络命名空间)"]}),e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:549:11",className:"flex items-center gap-2 text-xs text-slate-300 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:550:13",type:"checkbox",checked:dt,onChange:f=>Ve(f.target.checked),className:"accent-blue-500"}),"hostIPC(共享主机 IPC 命名空间)"]}),e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:554:11",className:"flex items-center gap-2 text-xs text-slate-300 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:555:13",type:"checkbox",checked:Pe,onChange:f=>Dt(f.target.checked),className:"accent-blue-500"}),"hostPID(共享主机 PID 命名空间)"]}),e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:559:11",className:"flex items-center gap-2 text-xs text-slate-300 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:560:13",type:"checkbox",checked:Pt,onChange:f=>At(f.target.checked),className:"accent-blue-500"}),"shareProcessNamespace(共享进程命名空间)"]})]})]}),e.jsx(Sn,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:567:7",dnsNameservers:Mt,onDnsNameserversChange:Bt,dnsSearches:Rt,onDnsSearchesChange:It,dnsOptions:Ot,onDnsOptionsChange:Lt,hostAliases:Tt,onHostAliasesChange:Ht}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:579:7",className:"flex justify-end gap-2 pt-2",children:[e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:580:9",variant:"outline",className:"border-slate-700 text-slate-400",onClick:l,children:"取消"}),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:581:9",className:"bg-blue-600 hover:bg-blue-700",disabled:m,onClick:Ns,children:[m?e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:582:21",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(rt,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:582:73",className:"h-4 w-4 mr-1"}),"保存"]})]})]}):e.jsx(W,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:333:7",className:"bg-slate-900 border-slate-800",children:e.jsx(G,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:334:9",className:"p-8 text-center text-slate-500",children:"未获取到 manifest 数据,请使用 YAML 编辑模式直接修改。"})})}const En=[{label:"HTTP",protocol:"TCP",port:8080,targetPort:8080,name:"http"},{label:"WebSocket",protocol:"TCP",port:8001,targetPort:8002,name:"ws"},{label:"gRPC",protocol:"TCP",port:8002,targetPort:8002,name:"grpc"}],Zt=t=>Array.isArray(t)?t:t?.list||t?.items||t?.data||[];function wn({clusterCode:t,namespace:s,deploymentName:a,manifest:o,onSaved:n,onCancel:l}){const{toast:c}=Te(),m=ot(),[u,d]=p.useState(!0),[k,w]=p.useState([]),[E,y]=p.useState([]),[S,C]=p.useState({}),[D,z]=p.useState(null),[I,Y]=p.useState(null),[U,Z]=p.useState({name:"",type:"ClusterIP",ports:[{name:"http",port:"8080",targetPort:"8080",protocol:"TCP",nodePort:""}]}),[_,V]=p.useState({name:"",className:"nginx",host:"",path:"/",pathType:"Prefix",svcPort:"80"}),F=i=>{Z(x=>({...x,ports:[...x.ports,i?{name:i.name,port:String(i.port),targetPort:String(i.targetPort),protocol:i.protocol,nodePort:""}:{name:"",port:"",targetPort:"",protocol:"TCP",nodePort:""}]}))},J=(i,x,r)=>{Z(h=>({...h,ports:h.ports.map((j,N)=>N===i?{...j,[x]:r}:j)}))},ee=i=>{U.ports.length<=1||Z(x=>({...x,ports:x.ports.filter((r,h)=>h!==i)}))},g=p.useCallback(async()=>{d(!0);try{const i=o?.spec?.selector?.matchLabels||o?.selector||{};C(i);const[x,r]=await Promise.all([X.getNamespaceServices(t,s).catch(()=>[]),X.getNamespaceIngresses(t,s).catch(()=>[])]),h=Zt(x),j=Zt(r),N=h.map(H=>{const de=H.spec||{},we=Array.isArray(de.ports)?de.ports.map(pe=>({port:pe.port,targetPort:pe.targetPort,protocol:pe.protocol||"TCP",nodePort:pe.nodePort,name:pe.name})):Array.isArray(H.portList)?H.portList.map(pe=>({port:pe.port,targetPort:pe.targetPort,protocol:pe.protocol||"TCP",nodePort:pe.nodePort,name:pe.name})):[];return{name:H.name||H.metadata?.name||"",type:de.type||H.type||"ClusterIP",clusterIP:de.clusterIP||H.cluster_ip||"<none>",externalIP:Array.isArray(de.externalIPs)?de.externalIPs.join(","):"",ports:we,selector:de.selector||H.selector||{},age:H.age||H.created_at||"",raw:H}}),P=j.map(H=>{const de=H.spec||{},pe=(Array.isArray(de.rules)?de.rules:Array.isArray(H.rules)?H.rules:[]).map(R=>({host:R.host||"",paths:(R.http?.paths||R.paths||[]).map(oe=>({path:oe.path||"/",backend:{service:oe.backend?.service?.name||oe.backendService||"",port:oe.backend?.service?.port?.number||oe.backend?.service?.port?.name||oe.backendPort||""}}))}));return{name:H.name||H.metadata?.name||"",className:de.ingressClassName||H.ingressClass||"<none>",hosts:pe.map(R=>R.host).filter(Boolean),rules:pe,raw:H}});w(N),y(P)}catch(i){console.error("M9 load error:",i)}finally{d(!1)}},[t,s,o]);p.useEffect(()=>{g()},[g]);const O=i=>Object.keys(i).length===0?!1:Object.entries(i).every(([x,r])=>S[x]===r),q=k.filter(i=>O(i.selector)),K=new Set(q.map(i=>i.name)),le=E.filter(i=>i.rules.some(x=>x.paths.some(r=>K.has(r.backend.service)))),ue=async()=>{const i=U.name.trim()||`${a}-svc`,x=U.ports.map(h=>{const j={name:h.name||"http",port:Number(h.port)||80,targetPort:/^\d+$/.test(String(h.targetPort))?Number(h.targetPort):h.targetPort,protocol:h.protocol||"TCP"};return U.type==="NodePort"&&h.nodePort&&(j.nodePort=Number(h.nodePort)),j}),r={apiVersion:"v1",kind:"Service",metadata:{name:i,namespace:s,labels:{app:a}},spec:{type:U.type,selector:S,ports:x}};try{const h=await $t(r);await X.applyYAML(t,h),c({title:"Service 已创建",description:i}),Y(null),g()}catch(h){c({title:"创建失败",description:h?.message||String(h),variant:"destructive"})}},ke=async()=>{const i=_.name.trim()||`${a}-ingress`,x=q[0]?.name||`${a}-svc`,r=Number(_.svcPort)||80,h={apiVersion:"networking.k8s.io/v1",kind:"Ingress",metadata:{name:i,namespace:s,labels:{app:a}},spec:{ingressClassName:_.className||void 0,rules:[{host:_.host||void 0,http:{paths:[{path:_.path||"/",pathType:_.pathType||"Prefix",backend:{service:{name:x,port:{number:r}}}}]}}]}};_.className||delete h.spec.ingressClassName;try{const j=await $t(h);await X.applyYAML(t,j),c({title:"Ingress 已创建",description:i}),Y(null),g()}catch(j){c({title:"创建失败",description:j?.message||String(j),variant:"destructive"})}},B=async(i,x)=>{if(await m({title:"删除资源",description:`确认删除 ${i==="service"?"Service":"Ingress"} 「${x}」?此操作不可撤销。`,confirmText:"删除",variant:"destructive"}))try{const h=i==="service"?"services":"ingresses";await X.deleteResourceYaml(t,s,h,x),c({title:"已删除",description:`${i==="service"?"Service":"Ingress"} ${x} 已删除`}),g()}catch(h){c({title:"删除失败",description:h?.message||String(h),variant:"destructive"})}};return u?e.jsx(W,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:291:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:292:9",className:"p-12 text-center",children:[e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:293:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:294:11",className:"text-slate-500 mt-3 text-sm",children:"加载中..."})]})}):e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:301:5",className:"space-y-4",children:[e.jsx(W,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:303:7",className:"bg-slate-900/50 border-slate-800",children:e.jsx(G,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:304:9",className:"p-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:305:11",className:"flex items-center gap-2 text-xs text-slate-400",children:[e.jsx(Ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:306:13",className:"h-3.5 w-3.5 text-blue-400"}),e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:307:13",children:"选择器:"}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:308:13",className:"flex flex-wrap gap-1",children:[Object.entries(S).map(([i,x])=>e.jsxs("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:310:17",className:"bg-slate-800 px-1.5 py-0.5 rounded text-slate-300 text-[11px]",children:[i,"=",x]},i)),Object.keys(S).length===0&&e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:313:17",className:"text-slate-600 italic",children:"(无 selector)"})]}),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:316:13",size:"sm",variant:"ghost",className:"h-6 ml-auto text-xs text-slate-400",onClick:g,children:[e.jsx(We,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:317:15",className:"h-3 w-3 mr-1"}),"刷新"]})]})})}),e.jsxs(W,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:324:7",className:"bg-slate-900 border-slate-800",children:[e.jsxs(me,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:325:9",className:"pb-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:326:11",className:"flex items-center justify-between",children:[e.jsxs(xe,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:327:13",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(Ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:328:15",className:"h-4 w-4 text-blue-400"}),"Services",e.jsxs(ne,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:330:15",variant:"outline",className:"border-slate-700 text-slate-400",children:[q.length," 个关联"]})]}),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:332:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:()=>{Z({name:`${a}-svc`,type:"ClusterIP",ports:[{name:"http",port:"8080",targetPort:"8080",protocol:"TCP",nodePort:""}]}),Y("service")},children:[e.jsx(Q,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:337:15",className:"h-3 w-3 mr-1"}),"创建 Service"]})]}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:340:11",className:"text-xs text-slate-500 mt-1",children:"仅显示 selector 匹配此 Deployment 的关联 Service"})]}),e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:342:9",className:"pt-0",children:[q.length===0&&I!=="service"?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:344:13",className:"text-center py-6 text-slate-500 text-sm border border-dashed border-slate-800 rounded-lg",children:[e.jsx(Ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:345:15",className:"h-8 w-8 mx-auto mb-2 text-slate-700"}),"当前命名空间暂无关联 Service"]}):e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:349:13",className:"space-y-2",children:q.map(i=>{const x=O(i.selector);return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:353:19",className:`rounded-lg border p-3 ${x?"border-blue-700/50 bg-blue-950/20":"border-slate-800 bg-slate-950/30"}`,children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:354:21",className:"flex items-center gap-2 flex-wrap",children:[x?e.jsx(gt,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:355:34",className:"h-4 w-4 text-blue-400"}):e.jsx(Ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:355:86",className:"h-4 w-4 text-slate-500"}),e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:356:23",className:"text-sm font-semibold text-slate-200",children:i.name}),e.jsx(ne,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:357:23",variant:"outline",className:"border-slate-700 text-slate-400 text-[10px]",children:i.type}),x&&e.jsx(ne,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:358:35",className:"bg-blue-500/20 text-blue-300 border-blue-500/30 text-[10px]",children:"关联"}),e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:359:23",className:"text-[11px] text-slate-500 ml-auto",children:i.clusterIP}),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:360:23",size:"sm",variant:"ghost",className:"h-6 text-xs text-emerald-400",onClick:()=>z({resource:"services",name:i.name}),children:[e.jsx(Wt,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:362:25",className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:364:23",size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-red-400 hover:text-red-300",title:"删除 Service",onClick:()=>B("service",i.name),children:e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:366:25",className:"h-3 w-3"})})]}),e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:370:21",className:"mt-2 flex flex-wrap gap-1.5 text-[11px]",children:i.ports.map((r,h)=>e.jsxs("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:372:25",className:"bg-slate-800/60 px-1.5 py-0.5 rounded text-slate-300",children:[r.name&&e.jsxs("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:373:38",className:"text-slate-500",children:[r.name,": "]}),r.port,"→",r.targetPort,r.nodePort?`/NodePort:${r.nodePort}`:"","/",r.protocol]},h))}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:379:21",className:"mt-1 flex flex-wrap gap-1 text-[10px]",children:[e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:380:23",className:"text-slate-600",children:"selector:"}),Object.entries(i.selector).map(([r,h])=>e.jsxs("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:382:25",className:"text-slate-500",children:[r,"=",h]},r))]})]},i.name)})}),I==="service"&&e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:393:13",className:"mt-3 border border-blue-800/50 rounded-lg p-3 bg-blue-950/20 space-y-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:394:15",className:"text-xs font-semibold text-blue-300 flex items-center gap-1.5",children:[e.jsx(Q,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:395:17",className:"h-3 w-3"}),"创建新 Service"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:399:15",className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:400:17",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:401:19",className:"text-slate-500 text-[11px]",children:"名称"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:402:19",value:U.name,onChange:i=>Z(x=>({...x,name:i.target.value})),placeholder:`${a}-svc`,className:"h-7 mt-0.5 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:406:17",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:407:19",className:"text-slate-500 text-[11px]",children:"类型"}),e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:408:19",value:U.type,onChange:i=>Z(x=>({...x,type:i.target.value})),className:"h-7 mt-0.5 w-full bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-2",children:[e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:410:21",value:"ClusterIP",children:"ClusterIP"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:411:21",value:"NodePort",children:"NodePort"})]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:417:15",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:418:17",className:"text-slate-500 text-[11px] mb-1 block",children:"快速添加常用端口"}),e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:419:17",className:"flex gap-1.5",children:En.map(i=>e.jsxs("button",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:421:21",onClick:()=>F(i),className:`flex items-center gap-1 px-2 py-1 rounded text-[10px] font-medium
|
||
bg-slate-800 border border-slate-700 text-slate-300 hover:border-blue-500/50 hover:text-blue-300 transition-colors`,children:[e.jsx(ls,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:424:23",className:"h-2.5 w-2.5"}),i.label,e.jsxs("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:426:23",className:"text-slate-500 text-[9px]",children:[i.protocol," ",i.port,":",i.targetPort]})]},i.name))})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:433:15",className:"space-y-2",children:[e.jsxs(M,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:434:17",className:"text-slate-500 text-[11px]",children:["端口配置 ",e.jsxs("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:435:24",className:"text-slate-600",children:["(",U.ports.length," 个端口)"]})]}),U.ports.map((i,x)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:438:19",className:"flex items-center gap-1.5 p-2 rounded bg-slate-800/50 border border-slate-700/50",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:440:21",value:i.name,onChange:r=>J(x,"name",r.target.value),placeholder:"http",className:"h-7 w-[72px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:444:21",value:i.protocol,onChange:r=>J(x,"protocol",r.target.value),className:"h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5 w-16",children:[e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:446:23",value:"TCP",children:"TCP"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:447:23",value:"UDP",children:"UDP"})]}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:450:21",value:i.port,onChange:r=>J(x,"port",r.target.value),type:"number",placeholder:"port",className:"h-7 w-[72px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:453:21",className:"text-slate-600 text-[10px]",children:"→"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:454:21",value:i.targetPort,onChange:r=>J(x,"targetPort",r.target.value),type:"number",placeholder:"targetPort",className:"h-7 w-[72px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),U.type==="NodePort"&&e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:459:23",value:i.nodePort,onChange:r=>J(x,"nodePort",r.target.value),type:"number",placeholder:"30000-32767",className:"h-7 w-[80px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:464:21",size:"icon",variant:"ghost",className:"h-6 w-6 text-slate-500 hover:text-red-400",onClick:()=>ee(x),disabled:U.ports.length<=1,children:e.jsx(Ct,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:466:23",className:"h-3 w-3"})})]},x)),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:471:17",size:"sm",variant:"outline",className:"h-7 w-full border-dashed border-slate-700 text-slate-400 text-xs",onClick:()=>F(),children:[e.jsx(Q,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:473:19",className:"h-3 w-3 mr-1"}),"添加自定义端口"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:478:15",className:"text-[10px] text-slate-500 border-t border-slate-700/50 pt-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:479:17",className:"text-slate-600",children:"selector (自动检测): "}),Object.keys(S).length>0?Object.entries(S).map(([i,x])=>e.jsxs("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:482:21",className:"bg-slate-800 px-1 py-0.5 rounded text-slate-400 ml-1",children:[i,"=",x]},i)):e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:485:19",className:"text-slate-600 italic",children:"未检测到"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:489:15",className:"flex justify-end gap-2 pt-1",children:[e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:490:17",size:"sm",variant:"ghost",className:"h-7 text-xs text-slate-400",onClick:()=>Y(null),children:"取消"}),e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:491:17",size:"sm",className:"h-7 bg-blue-600 hover:bg-blue-700 text-xs",onClick:ue,children:"创建"})]})]})]})]}),e.jsxs(W,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:499:7",className:"bg-slate-900 border-slate-800",children:[e.jsxs(me,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:500:9",className:"pb-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:501:11",className:"flex items-center justify-between",children:[e.jsxs(xe,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:502:13",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(ut,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:503:15",className:"h-4 w-4 text-purple-400"}),"Ingresses (应用路由)",e.jsxs(ne,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:505:15",variant:"outline",className:"border-slate-700 text-slate-400",children:[le.length,"/",E.length]})]}),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:507:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:()=>{V(i=>({...i,name:`${a}-ingress`,svcPort:String(q[0]?.ports[0]?.port||80)})),Y("ingress")},children:[e.jsx(Q,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:512:15",className:"h-3 w-3 mr-1"}),"创建 Ingress"]})]}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:515:11",className:"text-xs text-slate-500 mt-1",children:"backend 指向关联 Service 的 Ingress 自动高亮"})]}),e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:517:9",className:"pt-0",children:[E.length===0?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:519:13",className:"text-center py-6 text-slate-500 text-sm border border-dashed border-slate-800 rounded-lg",children:[e.jsx(ut,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:520:15",className:"h-8 w-8 mx-auto mb-2 text-slate-700"}),"当前命名空间暂无 Ingress"]}):e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:524:13",className:"space-y-2",children:E.map(i=>{const x=le.includes(i);return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:528:19",className:`rounded-lg border p-3 ${x?"border-purple-700/50 bg-purple-950/20":"border-slate-800 bg-slate-950/30"}`,children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:529:21",className:"flex items-center gap-2 flex-wrap",children:[x?e.jsx(gt,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:530:34",className:"h-4 w-4 text-purple-400"}):e.jsx(ut,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:530:88",className:"h-4 w-4 text-slate-500"}),e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:531:23",className:"text-sm font-semibold text-slate-200",children:i.name}),e.jsx(ne,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:532:23",variant:"outline",className:"border-slate-700 text-slate-400 text-[10px]",children:i.className}),x&&e.jsx(ne,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:533:35",className:"bg-purple-500/20 text-purple-300 border-purple-500/30 text-[10px]",children:"关联"}),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:534:23",size:"sm",variant:"ghost",className:"h-6 text-xs text-emerald-400 ml-auto",onClick:()=>z({resource:"ingresses",name:i.name}),children:[e.jsx(Wt,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:536:25",className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:538:23",size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-red-400 hover:text-red-300",title:"删除 Ingress",onClick:()=>B("ingress",i.name),children:e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:540:25",className:"h-3 w-3"})})]}),e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:544:21",className:"mt-2 space-y-1 text-[11px]",children:i.rules.map((r,h)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:546:25",className:"flex items-start gap-1.5",children:[e.jsx(Et,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:547:27",className:"h-3 w-3 text-slate-500 mt-0.5"}),e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:548:27",className:"text-slate-300",children:r.host||"*"}),r.paths.map((j,N)=>e.jsxs("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:550:29",className:"bg-slate-800/60 px-1.5 py-0.5 rounded text-slate-400",children:[j.path," → ",j.backend?.service,":",j.backend?.port]},N))]},h))})]},i.name)})}),I==="ingress"&&e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:565:13",className:"mt-3 border border-purple-800/50 rounded-lg p-3 bg-purple-950/20 space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:566:15",className:"text-xs font-semibold text-purple-300 flex items-center gap-1.5",children:[e.jsx(Q,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:567:17",className:"h-3 w-3"}),"创建新 Ingress"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:569:15",className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:570:17",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:571:19",className:"text-slate-500 text-[11px]",children:"名称"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:572:19",value:_.name,onChange:i=>V(x=>({...x,name:i.target.value})),placeholder:`${a}-ingress`,className:"h-7 mt-0.5 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:576:17",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:577:19",className:"text-slate-500 text-[11px]",children:"ingressClassName"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:578:19",value:_.className,onChange:i=>V(x=>({...x,className:i.target.value})),placeholder:"nginx",className:"h-7 mt-0.5 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:582:17",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:583:19",className:"text-slate-500 text-[11px]",children:"host (域名)"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:584:19",value:_.host,onChange:i=>V(x=>({...x,host:i.target.value})),placeholder:"app.example.com",className:"h-7 mt-0.5 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:588:17",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:589:19",className:"text-slate-500 text-[11px]",children:"path"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:590:19",value:_.path,onChange:i=>V(x=>({...x,path:i.target.value})),placeholder:"/",className:"h-7 mt-0.5 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:594:17",children:[e.jsx(M,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:595:19",className:"text-slate-500 text-[11px]",children:"Service 端口"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:596:19",type:"number",value:_.svcPort,onChange:i=>V(x=>({...x,svcPort:i.target.value})),className:"h-7 mt-0.5 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:600:15",className:"flex justify-end gap-2 pt-1",children:[e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:601:17",size:"sm",variant:"ghost",className:"h-7 text-xs text-slate-400",onClick:()=>Y(null),children:"取消"}),e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:602:17",size:"sm",className:"h-7 bg-purple-600 hover:bg-purple-700 text-xs",onClick:ke,children:"创建"})]})]})]})]}),D&&e.jsx(hs,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:610:9",clusterCode:t,namespace:s,resource:D.resource,name:D.name,onClose:()=>z(null),onSaved:()=>{z(null),g()}}),e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:620:7",className:"flex justify-end gap-2 pt-2",children:e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:621:9",size:"sm",variant:"outline",className:"h-7 text-xs border-slate-700 text-slate-400",onClick:l,children:"返回查看"})})]})}function Dn({clusterCode:t,namespace:s,deploymentName:a,manifest:o,onSaved:n,onCancel:l}){const[c,m]=p.useState("basic"),[u,d]=p.useState(o);p.useEffect(()=>{o&&d(o)},[o]);const k=y=>{y&&d(y),n()},w=[{key:"basic",label:"基本信息",icon:kt},{key:"containers",label:"容器信息",icon:$e},{key:"storage",label:"存储挂载",icon:Xe},{key:"advanced",label:"高级设置",icon:kt},{key:"service",label:"服务/应用路由",icon:Ae}],E={clusterCode:t,namespace:s,deploymentName:a,manifest:u,onSaved:k,onCancel:l};return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:51:5",className:"space-y-4",children:[e.jsx("div",{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:52:7",className:"flex items-center gap-1 border-b border-slate-800 pb-px overflow-x-auto",children:w.map(y=>{const S=c===y.key,C=y.icon;return e.jsxs("button",{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:57:13",onClick:()=>m(y.key),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium border-b-2 transition-colors whitespace-nowrap ${S?"border-blue-500 text-blue-400":"border-transparent text-slate-400 hover:text-slate-200"}`,children:[e.jsx(C,{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:64:15",className:"h-3.5 w-3.5"}),y.label]},y.key)})}),c==="basic"&&e.jsx(on,{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:71:33",...E}),c==="containers"&&e.jsx(cn,{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:72:38",...E}),c==="storage"&&e.jsx(jn,{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:73:35",...E}),c==="advanced"&&e.jsx(Cn,{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:74:36",...E}),c==="service"&&e.jsx(wn,{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:75:35",...E})]})}function Pn({clusterCode:t,namespace:s,deploymentName:a}){const{toast:o}=Te(),n=ft(u=>u.token)||localStorage.getItem("token")||"",l=`${window.location.origin}/api/v1/clusters/${t}/namespaces/${s}/deployments/${a}/update-image`,c=`curl -X POST '${l}' \\
|
||
-H 'Authorization: Bearer ${n?n.substring(0,16)+"...":"YOUR_TOKEN"}' \\
|
||
-H 'Content-Type: application/json' \\
|
||
-d '{"image": "harbor.example.com/app:v1.0", "container": "your-container-name"}'`,m=u=>{navigator.clipboard.writeText(u).then(()=>o({title:"已复制"})).catch(()=>{})};return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:28:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:29:7",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:30:9",className:"text-slate-400 text-sm",children:"Webhook URL"}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:31:9",className:"flex items-center gap-2 mt-1",children:[e.jsx("code",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:32:11",className:"flex-1 text-xs text-slate-300 bg-slate-800 rounded px-3 py-2 break-all font-mono",children:l}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:33:11",variant:"outline",size:"sm",className:"border-slate-700 text-slate-400 shrink-0",onClick:()=>m(l),children:"复制"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:36:7",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:37:9",className:"text-slate-400 text-sm",children:"curl 示例"}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:38:9",className:"relative mt-1",children:[e.jsx("pre",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:39:11",className:"text-xs text-slate-300 bg-slate-800 rounded p-3 overflow-x-auto font-mono whitespace-pre-wrap",children:c}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:40:11",variant:"outline",size:"sm",className:"absolute top-2 right-2 border-slate-700 text-slate-400",onClick:()=>m(c),children:"复制"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:43:7",className:"text-xs text-slate-500 space-y-1",children:[e.jsx("p",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:44:9",children:"• 使用 Bearer Token 认证(JWT 登录令牌)"}),e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:45:9",children:["• ",e.jsx("code",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:45:14",className:"text-slate-400",children:"image"})," 必填,指定新镜像地址"]}),e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:46:9",children:["• ",e.jsx("code",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:46:14",className:"text-slate-400",children:"container"})," 可选,不填则更新第一个容器"]})]})]})}function Ke({title:t,children:s,onClose:a}){return e.jsx("div",{"code-path":"src/components/kubernetes/deployment-workload/ModalShell.tsx:14:5",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:a,children:e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ModalShell.tsx:15:7",className:"bg-slate-900 border border-slate-700 rounded-xl p-6 w-[460px] max-w-[90vw] shadow-2xl",onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ModalShell.tsx:16:9",className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{"code-path":"src/components/kubernetes/deployment-workload/ModalShell.tsx:17:11",className:"text-base font-bold text-slate-100",children:t}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-workload/ModalShell.tsx:18:11",variant:"ghost",size:"icon",className:"h-7 w-7 text-slate-400",onClick:a,children:e.jsx(ms,{"code-path":"src/components/kubernetes/deployment-workload/ModalShell.tsx:18:100",className:"h-4 w-4"})})]}),s]})})}function An({clusterCode:t,namespace:s,podName:a,containers:o,onClose:n}){const{toast:l}=Te(),[c,m]=p.useState(""),[u,d]=p.useState(200),[k,w]=p.useState(o[0]||""),[E,y]=p.useState(!1),[S,C]=p.useState(!1),D=async()=>{y(!0);try{const I=await X.getPodLogs(t,s,a,u,k||void 0);m(I?.data?.logs||I?.logs||I||"无日志")}catch{m("获取日志失败")}finally{y(!1)}};p.useEffect(()=>{D()},[k,u]);const z=async()=>{C(!0);const I=ft.getState().token||"",Y="",U=k?`&container=${encodeURIComponent(k)}`:"",Z=`${Y}/api/v1/kubernetes/${t}/namespace/${s}/pods/${a}/logs?tail=${u}&stream=true${U}`;try{const V=(await fetch(Z,{headers:{Authorization:`Bearer ${I}`}})).body?.getReader();if(!V)return;const F=new TextDecoder;let J="";for(;;){const{done:ee,value:g}=await V.read();if(ee)break;J+=F.decode(g,{stream:!0}),m(J)}}catch{l({title:"流式日志连接中断",variant:"destructive"})}finally{C(!1)}};return e.jsx("div",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:64:5",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:n,children:e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:65:7",className:"bg-slate-900 border border-slate-700 rounded-xl w-[90vw] max-w-4xl max-h-[80vh] flex flex-col",onClick:I=>I.stopPropagation(),children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:66:9",className:"flex items-center justify-between p-3 border-b border-slate-700",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:67:11",className:"flex items-center gap-2",children:[e.jsx(St,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:68:13",className:"h-4 w-4 text-blue-400"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:69:13",className:"text-sm font-semibold text-slate-200",children:a}),k&&e.jsx(ne,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:70:27",variant:"outline",className:"border-slate-700 text-slate-400 text-[10px]",children:k})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:72:11",className:"flex items-center gap-2",children:[o.length>0&&e.jsx("select",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:74:15",value:k,onChange:I=>w(I.target.value),className:"bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-2 py-1",children:o.map(I=>e.jsx("option",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:76:38",value:I,children:I},I))}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:79:13",className:"text-[11px] text-slate-500",children:"最近"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:80:13",type:"number",value:u,onChange:I=>d(Number(I.target.value)||200),className:"w-16 h-7 bg-slate-800 border-slate-700 text-slate-200 text-xs"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:82:13",className:"text-[11px] text-slate-500",children:"行"}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:83:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:D,disabled:E,children:E?e.jsx(be,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:84:26",className:"h-3 w-3 animate-spin"}):e.jsx(We,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:84:73",className:"h-3 w-3"})}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:86:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-emerald-400 text-xs",onClick:z,disabled:S,children:S?"流中...":"实时流"}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:89:13",variant:"ghost",size:"icon",className:"h-7 w-7 text-slate-400",onClick:n,children:e.jsx(ms,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:89:102",className:"h-4 w-4"})})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:92:9",className:"flex-1 overflow-auto p-3",children:e.jsx("pre",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:93:11",className:"bg-slate-950 rounded p-3 text-xs text-slate-300 font-mono whitespace-pre-wrap max-h-[60vh] overflow-auto",children:c||"无日志内容"})})]})})}function Tn({modal:t,deployment:s,namespace:a,deploymentName:o,newImage:n,setNewImage:l,scaleValue:c,setScaleValue:m,actionLoading:u,onClose:d,onUpdateImage:k,onScaleTo:w,onDelete:E}){return e.jsxs(e.Fragment,{children:[t?.kind==="image"&&e.jsx(Ke,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:45:9",title:"调整镜像版本",onClose:d,children:e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:46:11",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:47:13",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:48:15",className:"text-slate-400 text-sm",children:"当前镜像"}),e.jsx("p",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:49:15",className:"text-xs text-slate-500 font-mono mt-1 bg-slate-800 rounded px-3 py-2",children:s.image||"-"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:51:13",children:[e.jsx(M,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:52:15",className:"text-slate-400 text-sm",children:"新镜像地址"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:53:15",value:n,onChange:y=>l(y.target.value),placeholder:"harbor.example.com/app:v2.0",className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:57:13",className:"flex justify-end gap-2 pt-2",children:[e.jsx(b,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:58:15",variant:"outline",className:"border-slate-700 text-slate-400",onClick:d,children:"取消"}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:59:15",className:"bg-blue-600 hover:bg-blue-700",disabled:u==="image"||!n.trim(),onClick:k,children:u==="image"?e.jsx(be,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:60:46",className:"h-4 w-4 animate-spin"}):"更新镜像"})]})]})}),t?.kind==="scale"&&e.jsx(Ke,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:69:9",title:"伸缩 (Scale)",onClose:d,children:e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:70:11",className:"space-y-3",children:[e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:71:13",className:"text-xs text-slate-500",children:["当前副本: ",s.replicas||0]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:72:13",className:"flex items-center justify-center gap-3 py-3",children:[e.jsx(b,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:73:15",variant:"outline",size:"icon",className:"border-slate-700 text-slate-300",disabled:u==="scale"||c<=0,onClick:()=>m(y=>Math.max(0,y-1)),children:e.jsx(Ct,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:76:17",className:"h-4 w-4"})}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:78:15",type:"number",min:0,value:c,onChange:y=>m(Math.max(0,Number(y.target.value))),className:"w-24 text-center text-lg font-bold bg-slate-800 border-slate-700 text-slate-200"}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:81:15",variant:"outline",size:"icon",className:"border-slate-700 text-slate-300",disabled:u==="scale",onClick:()=>m(y=>y+1),children:e.jsx(Q,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:84:17",className:"h-4 w-4"})})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:87:13",className:"flex justify-end gap-2 pt-2",children:[e.jsx(b,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:88:15",variant:"outline",className:"border-slate-700 text-slate-400",onClick:d,children:"取消"}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:89:15",className:"bg-blue-600 hover:bg-blue-700",disabled:u==="scale",onClick:w,children:u==="scale"?e.jsx(be,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:90:46",className:"h-4 w-4 animate-spin"}):"确认"})]})]})}),t?.kind==="delete"&&e.jsx(Ke,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:99:9",title:"删除 Deployment",onClose:d,children:e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:100:11",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:101:13",className:"flex items-center gap-2 text-red-400",children:[e.jsx(xs,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:102:15",className:"h-5 w-5"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:103:15",className:"font-semibold",children:"此操作不可撤销"})]}),e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:105:13",className:"text-sm text-slate-400",children:["确认删除 Deployment ",e.jsxs("code",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:106:31",className:"text-slate-200 font-mono",children:[a,"/",o]}),"? 其管理的所有 Pod 将被一并回收。"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:109:13",className:"flex justify-end gap-2 pt-2",children:[e.jsx(b,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:110:15",variant:"outline",className:"border-slate-700 text-slate-400",onClick:d,children:"取消"}),e.jsxs(b,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:111:15",variant:"destructive",disabled:u==="delete",onClick:E,children:[u==="delete"?e.jsx(be,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:112:47",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(he,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:112:99",className:"h-4 w-4 mr-1"}),"确认删除"]})]})]})})]})}function Hn({clusterCode:t,namespace:s,deploymentName:a,mode:o,onBack:n,onModeChange:l}){const c=es(),{toast:m}=Te(),u=ot(),[d,k]=p.useState(null),[w,E]=p.useState(null),[y,S]=p.useState([]),[C,D]=p.useState([]),[z,I]=p.useState([]),[Y,U]=p.useState(!0),[Z,_]=p.useState(""),[V,F]=p.useState(null),[J,ee]=p.useState(""),[g,O]=p.useState(0),[q,K]=p.useState(null),[le,ue]=p.useState(null),ke=d?.cluster_id||d?.clusterId||t,B=A=>Array.isArray(A)?A:A?.list||A?.items||A?.data||[],i=p.useCallback(async()=>{U(!0);try{const[A,ye,De,je]=await Promise.all([X.getDeployment(t,s,a).catch(()=>null),X.getNamespacePods(t,s).catch(()=>[]),X.getReplicaSets(t,s).catch(()=>[]),X.getDeploymentRevisions(t,s,a).catch(()=>[])]),He=A||(Array.isArray(A)?A[0]:null);k(He),O(He?.replicas||0),ee(He?.image||"");const Ge=B(ye).filter(Pe=>Pe.namespace===s&&(Pe.name||"").startsWith(a));S(Ge);const Ve=B(De).filter(Pe=>Pe.namespace===s&&(Pe.owner_deployment===a||(Pe.name||"").startsWith(a)));D(Ve),I(B(je))}catch(A){console.error("加载详情失败:",A)}finally{U(!1)}},[t,s,a]),x=p.useCallback(async()=>{try{const A=await X.getResourceYaml(t,s,"deployments",a),{parseEditableManifest:ye}=await Cs(async()=>{const{parseEditableManifest:je}=await import("./PodFileBrowser-CVjj8HxI.js").then(He=>He.k);return{parseEditableManifest:je}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])),{manifest:De}=await ye(A);E(De||d)}catch(A){console.warn("加载 manifest 失败(编辑功能降级):",A),E(d)}},[t,s,a,d]);p.useEffect(()=>{i()},[i]),p.useEffect(()=>{o==="edit"&&!w&&x()},[o,w,x]);const r=async()=>{_("scale");try{await X.scaleDeployment(t,s,a,g),m({title:"伸缩成功",description:`副本数已设置为 ${g}`}),F(null),i()}catch(A){m({title:"操作失败",description:A?.message||String(A),variant:"destructive"})}finally{_("")}},h=async()=>{if(await u({title:"滚动重启",description:`确认滚动重启 Deployment "${a}"?`,confirmText:"重启"})){_("restart");try{await X.restartDeployment(t,s,a),m({title:"重启指令已下发",description:"Deployment 正在滚动重启"}),setTimeout(i,1500)}catch(ye){m({title:"重启失败",description:ye?.message||String(ye),variant:"destructive"})}finally{_("")}}},j=async()=>{const A=!!d?.paused,ye=A?"恢复":"暂停";if(await u({title:`${ye}滚动更新`,description:`确认${ye} Deployment "${a}" 的滚动更新?`,confirmText:ye})){_(A?"resume":"pause");try{A?await X.resumeDeployment(t,s,a):await X.pauseDeployment(t,s,a),m({title:`${ye}成功`,description:`Deployment 滚动更新已${ye}`}),setTimeout(i,1e3)}catch(je){m({title:`${ye}失败`,description:je?.message||String(je),variant:"destructive"})}finally{_("")}}},N=()=>{F({kind:"cicd"})},P=async()=>{if(J.trim()){_("image");try{await X.updateDeploymentImage(t,s,a,J),m({title:"镜像更新成功",description:`正在滚动更新为 ${J}`}),F(null),i()}catch(A){m({title:"更新失败",description:A?.message||String(A),variant:"destructive"})}finally{_("")}}},H=async()=>{_("delete");try{const A=ft.getState().token||"",De=`/api/v1/kubernetes/${t}/namespace/${s}/deployments/${a}`,je=await fetch(De,{method:"DELETE",headers:{Authorization:`Bearer ${A}`}});if(!je.ok)throw new Error(`HTTP ${je.status}`);m({title:"删除成功",description:`${a} 已删除`}),F(null),setTimeout(()=>c(`/kubernetes/${t}/namespace/${s}/deployments`),800)}catch(A){m({title:"删除失败",description:A?.message||String(A),variant:"destructive"})}finally{_("")}},de=A=>F({kind:"podLogs",pod:A.name}),we=A=>F({kind:"podYaml",pod:A.name}),pe=A=>{K(A.name)},R=A=>{ue(A.name)};if(Y)return e.jsx(W,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:229:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:230:9",className:"p-12 text-center",children:[e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:231:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:232:11",className:"text-slate-500 mt-3",children:"加载中..."})]})});if(!d)return e.jsx(W,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:240:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:241:9",className:"p-12 text-center",children:[e.jsx(Us,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:242:11",className:"h-8 w-8 mx-auto text-red-400"}),e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:243:11",className:"text-slate-400 mt-3",children:["未找到 Deployment: ",a]}),e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:244:11",variant:"outline",className:"mt-4",onClick:n,children:"返回"})]})});const oe=d.ready_replicas||d.readyReplicas||0,Ne=d.replicas||0,fe=oe===Ne&&Ne>0;return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:256:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:258:7",className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:259:9",className:"flex items-center gap-3 min-w-0",children:[e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:260:11",variant:"ghost",size:"sm",className:"text-slate-400",onClick:n,children:[e.jsx(Js,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:261:13",className:"h-4 w-4 mr-1"}),"返回"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:263:11",className:"min-w-0",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:264:13",className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h1",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:265:15",className:"text-xl font-bold text-slate-100 truncate",children:a}),e.jsx(ne,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:266:15",variant:"outline",className:"border-slate-700 text-slate-400",children:s}),e.jsx(ne,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:267:15",variant:"outline",className:"border-slate-700 text-slate-400",children:"Deployment"}),e.jsxs(ne,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:268:15",className:fe?"bg-emerald-500/20 text-emerald-400 border-emerald-500/30":"bg-amber-500/20 text-amber-400 border-amber-500/30",children:[fe?e.jsx(gt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:273:30",className:"h-3 w-3 mr-1"}):e.jsx(xs,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:273:73",className:"h-3 w-3 mr-1"}),oe,"/",Ne]}),d?.paused&&e.jsxs(ne,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:277:17",className:"bg-orange-500/20 text-orange-400 border-orange-500/30",children:[e.jsx(Gt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:278:19",className:"h-3 w-3 mr-1"}),"已暂停更新"]})]}),e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:282:13",className:"text-xs text-slate-500 mt-0.5 truncate",children:["镜像: ",e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:283:19",className:"text-slate-400",children:d.image||"-"})]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:288:9",className:"flex items-center gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:290:11",className:"inline-flex rounded-md border border-slate-700 overflow-hidden",children:[e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:291:13",className:`px-3 py-1.5 text-xs font-medium transition-colors ${o==="view"?"bg-slate-700 text-slate-100":"bg-transparent text-slate-400 hover:text-slate-200"}`,onClick:()=>l("view"),children:"查看"}),e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:297:13",className:`px-3 py-1.5 text-xs font-medium transition-colors ${o==="edit"?"bg-blue-600 text-white":"bg-transparent text-slate-400 hover:text-slate-200"}`,onClick:()=>l("edit"),children:"编辑"}),e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:303:13",className:`px-3 py-1.5 text-xs font-medium transition-colors ${o==="yaml"?"bg-emerald-600 text-white":"bg-transparent text-slate-400 hover:text-slate-200"}`,onClick:()=>l("yaml"),children:"YAML"})]}),e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:311:11",variant:"outline",size:"sm",className:"border-slate-700 text-slate-400",onClick:i,title:"刷新",children:e.jsx(We,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:312:13",className:"h-4 w-4"})}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:316:11",className:"flex items-center gap-1.5",children:[e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:317:13",variant:"outline",size:"sm",className:"border-slate-700 text-slate-300",onClick:()=>F({kind:"image"}),children:[e.jsx(Ks,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:318:15",className:"h-3.5 w-3.5 mr-1"}),"调整镜像"]}),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:320:13",variant:"outline",size:"sm",className:"border-slate-700 text-slate-300",onClick:h,children:[e.jsx(is,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:321:15",className:"h-3.5 w-3.5 mr-1"}),"重启"]}),e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:323:13",variant:"outline",size:"sm",className:"border-slate-700 text-slate-300",disabled:!!Z,onClick:j,children:d?.paused?e.jsxs(e.Fragment,{children:[e.jsx(ps,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:330:21",className:"h-3.5 w-3.5 mr-1 text-green-400"}),"恢复"]}):e.jsxs(e.Fragment,{children:[e.jsx(Gt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:331:21",className:"h-3.5 w-3.5 mr-1 text-orange-400"}),"暂停"]})}),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:334:13",variant:"outline",size:"sm",className:"border-slate-700 text-slate-300",onClick:N,children:[e.jsx(Xs,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:335:15",className:"h-3.5 w-3.5 mr-1 text-purple-400"}),"CI/CD"]}),e.jsxs(b,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:337:13",variant:"outline",size:"sm",className:"border-slate-700 text-red-400 hover:bg-red-500/10",onClick:()=>F({kind:"delete"}),children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:338:15",className:"h-3.5 w-3.5 mr-1"}),"删除"]})]})]})]}),o==="view"?e.jsx(nn,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:346:9",clusterCode:t,namespace:s,deployment:d,pods:y,replicaSets:C,revisions:z,onRefresh:i,onShowPodLogs:de,onShowPodTerminal:pe,onShowPodYaml:we,onShowPodFileBrowser:R}):o==="yaml"?e.jsx(mt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:361:9",clusterCode:t,namespace:s,resource:"deployments",name:a,inline:!0,onSaved:i,onClose:()=>l("view")}):e.jsx(Dn,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:372:9",clusterCode:t,namespace:s,deploymentName:a,manifest:w,onSaved:()=>{x(),i()},onCancel:()=>l("view")}),V?.kind==="yaml"&&e.jsx(mt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:384:9",clusterCode:t,namespace:s,resource:"deployments",name:a,onClose:()=>F(null),onSaved:i}),e.jsx(Tn,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:394:7",modal:V,deployment:d,namespace:s,deploymentName:a,newImage:J,setNewImage:ee,scaleValue:g,setScaleValue:O,actionLoading:Z,onClose:()=>F(null),onUpdateImage:P,onScaleTo:r,onDelete:H}),V?.kind==="cicd"&&e.jsx(Ke,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:412:9",title:"CI/CD Webhook",onClose:()=>F(null),children:e.jsx(Pn,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:413:11",clusterCode:t,namespace:s,deploymentName:a})}),V?.kind==="podYaml"&&e.jsx(mt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:419:9",clusterCode:t,namespace:s,resource:"pods",name:V.pod,readOnly:!0,onClose:()=>F(null)}),V?.kind==="podLogs"&&e.jsx(An,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:431:9",clusterCode:t,namespace:s,podName:V.pod,containers:(y.find(A=>A.name===V.pod)?.containers||[]).map(A=>A.name).filter(Boolean),onClose:()=>F(null)}),e.jsx(Ds,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:441:7",open:!!q,onOpenChange:A=>{A||K(null)},clusterId:ke,namespace:s,podName:q||"",containers:(y.find(A=>A.name===q)?.containers||[]).map(A=>A.name).filter(Boolean)}),e.jsx(Ps,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:450:7",open:!!le,onOpenChange:A=>{A||ue(null)},clusterCode:t,namespace:s,podName:le||"",containers:(y.find(A=>A.name===le)?.containers||[]).map(A=>A.name).filter(Boolean)})]})}function Qn(){const t=Es(),s=es(),a=t.clusterCode||"",o=t.namespace||"",n=t.name||"",l=t.mode==="edit"||t.mode==="yaml"?t.mode:"view",c=m=>{m!==l&&s(`/kubernetes/${a}/namespace/${o}/workload/${m}/Deployment/${n}`,{replace:!0})};return e.jsx(Hn,{"code-path":"src/components/kubernetes/DeploymentDetailPage.tsx:38:5",clusterCode:a,namespace:o,deploymentName:n,mode:l,onBack:()=>s(-1),onModeChange:c})}export{Qn as default};
|