import{r,k as w,c as k,j as e,R as C,C as j,E,F as S,B as F,a as L,Z as v}from"./main-BzPVmAp-.js";import{d as z}from"./index-B-RBPprY.js";import{C as R}from"./index-7u0Bo8e4.js";import{T as A}from"./Table-kIlrKW-9.js";import"./index-CDeD9lyT.js";import"./index-CUuSmggi.js";import"./addEventListener-CzbSevz3.js";import"./index-Fy_dqHL_.js";import"./index-CSq209pq.js";import"./index-sAnz6zLe.js";import"./index-BQm1iTRH.js";import"./UpOutlined-B_NQN-zy.js";import"./index-SGIbgpRk.js";import"./Dropdown-Clv_Pvnt.js";import"./index-CUrh6kIn.js";import"./index-Djhsc5K4.js";import"./study-page-D4nenWxt.js";import"./usePagination-CGdUxo17.js";import"./index-BZ6Sq__j.js";import"./RedoOutlined-d_QTXv-s.js";import"./index-Cl0Hi3Gl.js";import"./callSuper-CKCGYiRV.js";const ee=()=>{const[c,o]=r.useState(!1),{project:u,projectObj:m}=w(),[d,g]=r.useState(),[n,p]=r.useState();r.useRef(null),k();const x=r.useRef(null),[f,s]=r.useState(null),l=()=>{if(x.current){const t=x.current.getBoundingClientRect().top;s(t)}};r.useEffect(()=>(l(),window.addEventListener("resize",l),()=>{window.removeEventListener("resize",l)}),[]);const i=async()=>{var a,h,y;o(!0);let t=await L.post("/list-analysis-tree",{is_report:!0,project:u});g(t.data),t.data.length>0&&(a=t.data[0])!=null&&a.children&&((h=t.data[0])==null?void 0:h.children.length)>0&&p((y=t.data[0])==null?void 0:y.children[0]),o(!1)};return r.useEffect(()=>{i()},[u]),e.jsx("div",{style:{maxWidth:"1500px",margin:"0 auto"},children:e.jsxs(C,{style:{marginTop:"1rem"},children:[e.jsx(j,{lg:6,sm:6,xs:24,ref:x,style:{position:"sticky",top:`${f}px`,alignSelf:"flex-start",height:`calc(100vh - ${f}px - 1rem )`},children:e.jsx(R,{loading:c,title:m==null?void 0:m.project_name,size:"small",style:{height:"100%"},styles:{body:{height:"90%",overflowY:"auto"}},extra:e.jsx(S,{gap:"small",children:e.jsx(F,{size:"small",color:"cyan",variant:"solid",onClick:i,children:"刷新"})}),children:Array.isArray(d)&&d.length!=0?e.jsx(e.Fragment,{children:e.jsx(T,{onSelect:t=>{var a,h;((a=t.node)==null?void 0:a.type)=="analysis"?p(t.node):((h=t.node)==null?void 0:h.type)=="components"&&console.log(t.node)},defaultSelectKey:n==null?void 0:n.key,treeData:d})}):e.jsx(e.Fragment,{children:e.jsx(E,{})})})}),e.jsx(j,{lg:18,sm:18,xs:24,style:{paddingLeft:"1rem"},children:n?e.jsx(e.Fragment,{children:e.jsx(z,{cancalReportCallback:()=>{i()},analysis_id:n==null?void 0:n.key})}):e.jsx(e.Fragment,{children:e.jsx(R,{size:"small",children:e.jsx(E,{})})})})]})})},T=({treeData:c,defaultSelectKey:o,onSelect:u})=>{const[m,d]=r.useState(o),[g,n]=r.useState([]),p=(s,l,i=[])=>{for(const t of l){if(t.key===s)return i;if(t.children){const a=p(s,t.children,[...i,t.key]);if(a.length)return a}}return[]};r.useEffect(()=>{if(o){const s=p(o,c);n(s),d(o)}},[o,c]);const x=(s,l)=>{if(s.length>0){u(l),d(s[0]);const i=p(s[0],c);n(i)}},f=s=>{n(s)};return e.jsx(e.Fragment,{children:e.jsx(A,{selectedKeys:[m],showLine:!0,expandedKeys:g,onExpand:f,autoExpandParent:!0,switcherIcon:e.jsx(v,{}),onSelect:x,treeData:c})})};export{ee as default};
