import{b as R,w as k,r as D,j as e}from"./main.js";import{u as H}from"./history-store-D5olzx0I.js";import{M as S}from"./MonacoEditor-CkW-kZUy.js";import{d as U,B as f}from"./button-D4VgS8ri.js";import{C as m,a as p,b as g,c as y}from"./card-D6OLc_JP.js";import{B}from"./badge-C9rqaanl.js";import{S as o}from"./skeleton-huerLprc.js";import{A as j}from"./arrow-left-j3vPbhKI.js";import"./config-C5ccHKCm.js";import"./config-CPAyKrGO.js";function q(){const{t:s}=U(),N=R(),[i]=k(),c=i.get("dataId")||"",l=i.get("group")||"",d=i.get("nid")||"",x=i.get("namespace")||"",{currentHistory:r,detailLoading:v,fetchHistoryDetail:I,clearCurrentHistory:b}=H();D.useEffect(()=>(d&&c&&l&&I(d,c,l),()=>{b()}),[d,c,l]);const h=()=>{N(`/historyRollback?dataId=${encodeURIComponent(c)}&group=${encodeURIComponent(l)}&namespace=${encodeURIComponent(x)}`)},C=n=>{switch(n?.trim()){case"I":return s("history.opInsert");case"U":return s("history.opUpdate");case"D":return s("history.opDelete");default:return n}},T=()=>r?r.publishType==="gray"?s("history.gray"):s("history.formal"):"-",w=()=>{if(!r||r.publishType!=="gray")return null;try{const t=JSON.parse(r.extInfo||"{}").gray_rule;return typeof t=="string"?JSON.parse(t).expr||t:t?.expr?t.expr:null}catch{return null}},a=(n,t)=>e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:n}),e.jsx("span",{className:"text-sm font-medium",children:t||"-"})]});if(v)return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(o,{className:"h-9 w-9"}),e.jsx(o,{className:"h-8 w-48"})]}),e.jsx(m,{children:e.jsx(p,{className:"p-6",children:e.jsx("div",{className:"grid grid-cols-3 gap-6",children:Array.from({length:9}).map((n,t)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{className:"h-4 w-20"}),e.jsx(o,{className:"h-5 w-32"})]},t))})})}),e.jsx(o,{className:"h-[350px] w-full"})]});if(!r)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-[400px] gap-4",children:[e.jsx("p",{className:"text-muted-foreground",children:s("common.noData")}),e.jsxs(f,{variant:"outline",onClick:h,children:[e.jsx(j,{className:"h-4 w-4 mr-2"}),s("common.back")]})]});const u=w();return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(f,{variant:"outline",size:"icon",onClick:h,children:e.jsx(j,{className:"h-4 w-4"})}),e.jsx("h1",{className:"text-2xl font-semibold",children:s("history.detailTitle")})]}),e.jsxs(m,{children:[e.jsx(g,{children:e.jsx(y,{children:s("history.detailTitle")})}),e.jsxs(p,{className:"p-6 pt-0",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[a(s("common.selectNamespace"),x||"public"),a(s("config.dataId"),r.dataId),a(s("config.group"),r.groupName),a(s("config.appName"),r.appName),a(s("history.publishType"),e.jsx(B,{variant:r.publishType==="gray"?"secondary":"default",children:T()})),a(s("history.operator"),r.srcUser),a(s("history.sourceIp"),r.srcIp),a(s("history.opType"),C(r.opType)),a(s("config.md5"),r.md5)]}),u&&e.jsx("div",{className:"mt-4",children:a(s("history.grayRule"),u)})]})]}),e.jsxs(m,{children:[e.jsx(g,{children:e.jsx(y,{children:s("config.content")})}),e.jsx(p,{className:"p-6 pt-0",children:e.jsx(S,{value:r.content||"",language:r.type||"text",readOnly:!0,height:"350px"})})]})]})}export{q as default};
