import{u as M,j as e,y as T,ay as B,r as i,w as R,az as P,L as D,K as d,z as I,B as r}from"./index-DWaKf7-t.js";import{M as N}from"./index-DpT0T8kB.js";import{F as O,f as $}from"./index-DeigmNJB.js";import{r as J,w as V}from"./index-Bdd9AuZi.js";import{T as q}from"./index-FZ8AkgCd.js";import{T as _}from"./index-DXS1j8KM.js";import"./index-Tb4IBdIf.js";import"./Table-DdQ_sLHU.js";import"./addEventListener-Bv6KfeSZ.js";import"./index-bFL3q_Rm.js";import"./index-B9lQzejH.js";const ae=()=>{const{analysisId:p}=M();if(!p)return e.jsx("div",{children:"404"});const g=T(),w=B(),{location:m}=w.state||{},h=i.useRef(null),[n,E]=i.useState(null),{messageApi:x}=R(),[F,C]=i.useState(""),[a,y]=i.useState(null),{eventSourceRef:l,status:G,reconnect:H}=P(),[k,S]=i.useState("pipeline_script"),[b,z]=i.useState({}),[L,j]=i.useState(!1);i.useEffect(()=>{var t;if(l){const s=o=>{const f=JSON.parse(o.data);p==f.analysis_id&&(f.event=="analysis_complete"||f.event=="analysis_failed")&&c()};return(t=l.current)==null||t.addEventListener("message",s),()=>{var o;console.log("removeEventListener"),(o=l.current)==null||o.removeEventListener("message",s)}}},[l.current]);const A=async t=>(await J(t)).data,u=async()=>{a&&(await V(a,h.current.getValue()),x.success("保存成功"))},c=async()=>{const s=(await $(p)).data;E(s),y(s.pipeline_script),z({pipeline_script:s.pipeline_script,script_config_file:s.script_config_file})};i.useEffect(()=>{a&&v(a)},[a]);const v=async(t,s=!1)=>{t&&A(t).then(o=>{C(o),s&&x.success(`脚本加载成功: ${t}`)})};i.useEffect(()=>{const t=s=>{(s.ctrlKey||s.metaKey)&&s.key==="s"&&(s.preventDefault(),typeof u=="function"&&u())};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[]);const{openModal:K}=D();return i.useEffect(()=>{c()},[]),e.jsxs("div",{children:[e.jsx(q,{size:"small",activeKey:k,onChange:t=>{S(t),y(b[t]),j(t==="params_path")},tabBarExtraContent:e.jsxs(I,{gap:"small",align:"center",children:[e.jsx(_,{color:"cyan",children:n==null?void 0:n.analysis_status}),e.jsx(_,{color:"cyan",children:n==null?void 0:n.analysis_name}),e.jsx(r,{size:"small",color:"cyan",variant:"solid",onClick:()=>{window.open(`http://10.110.1.11:8888/jupyter/notebooks/${n.jupyter_notebook_path}`,"_blank")},children:"jupyter"}),e.jsx(d,{title:e.jsx(e.Fragment,{children:a}),children:e.jsx(r,{size:"small",color:"cyan",variant:"solid",onClick:u,children:"保存"})}),e.jsx(d,{title:e.jsx(e.Fragment,{children:a}),children:e.jsx(r,{size:"small",color:"cyan",variant:"solid",onClick:()=>{v(a,!0)},children:"刷新脚本"})}),e.jsx(r,{size:"small",color:"cyan",variant:"solid",onClick:c,children:"刷新"}),m&&e.jsx(r,{size:"small",color:"cyan",variant:"solid",onClick:()=>{g(m)},children:"返回"})]}),items:[{key:"pipeline_script",label:e.jsx(d,{title:e.jsx(e.Fragment,{children:e.jsx("ul",{children:e.jsx("li",{children:n==null?void 0:n.pipeline_script})})}),children:"脚本"})},{key:"script_config_file",label:e.jsx(d,{title:e.jsx(e.Fragment,{children:e.jsx("ul",{children:e.jsx("li",{children:n==null?void 0:n.script_config_file})})}),children:"脚本配置"})}]}),e.jsx(N,{format:L,value:F,editorRef:h,defaultLanguage:"python",height:"50vh"}),e.jsx(O,{callback:c,analysis:n,operatePipeline:{openModal:K}})]})};export{ae as default};
