import{At as e,Ct as t,Et as n,K as r,Kt as i,Nt as a,Ot as o,Ut as s,Wt as c,an as l,in as u,j as d,jt as f,kt as p}from"./index-Cmfh6eB3.js";import{t as m}from"./chunk-4BX2VUAB-D9rcpK81.js";import{t as h}from"./mermaid-parser.core-xyaQdDp-.js";import{t as g}from"./chunk-QZHKN3VN-CRwqZYGV.js";var _=new g(()=>({cnt:1,stack:[{id:0,level:-1,name:`/`,children:[]}]})),v=u(()=>{_.reset(),t()},`clear`),y=u(()=>_.records.stack[0],`getRoot`),b=u(()=>_.records.cnt,`getCount`),x=o.treeView,S={clear:v,addNode:u((e,t)=>{for(;e<=_.records.stack[_.records.stack.length-1].level;)_.records.stack.pop();let n={id:_.records.cnt++,level:e,name:t,children:[]};_.records.stack[_.records.stack.length-1].children.push(n),_.records.stack.push(n)},`addNode`),getRoot:y,getCount:b,getConfig:u(()=>d(x,f().treeView),`getConfig`),getAccTitle:e,getAccDescription:p,getDiagramTitle:a,setAccDescription:s,setAccTitle:c,setDiagramTitle:i},C=u(e=>{m(e,S),e.nodes.map(e=>S.addNode(e.indent?parseInt(e.indent):0,e.name))},`populate`),w={parse:u(async e=>{let t=await h(`treeView`,e);l.debug(t),C(t)},`parse`)},T=u((e,t,n,r,i)=>{let a=r.append(`text`).text(n.name).attr(`dominant-baseline`,`middle`).attr(`class`,`treeView-node-label`),{height:o,width:s}=a.node().getBBox(),c=o+i.paddingY*2,l=s+i.paddingX*2;a.attr(`x`,e+i.paddingX),a.attr(`y`,t+c/2),n.BBox={x:e,y:t,width:l,height:c}},`positionLabel`),E=u((e,t,n,r,i,a)=>e.append(`line`).attr(`x1`,t).attr(`y1`,n).attr(`x2`,r).attr(`y2`,i).attr(`stroke-width`,a).attr(`class`,`treeView-node-line`),`positionLine`),D=u((e,t,n)=>{let r=0,i=0,a=u((e,t,n,a)=>{let o=a*(n.rowIndent+n.paddingX);T(o,r,t,e,n);let{height:s,width:c}=t.BBox;E(e,o-n.rowIndent,r+s/2,o,r+s/2,n.lineThickness),i=Math.max(i,o+c),r+=s},`drawNode`),o=u((t,r=0)=>{a(e,t,n,r),t.children.forEach(e=>{o(e,r+1)});let{x:i,y:s,height:c}=t.BBox;if(t.children.length){let{y:r,height:a}=t.children[t.children.length-1].BBox;E(e,i+n.paddingX,s+c,i+n.paddingX,r+a/2+n.lineThickness/2,n.lineThickness)}},`processNode`);return o(t),{totalHeight:r,totalWidth:i}},`drawTree`),O={draw:u((e,t,i,a)=>{l.debug(`Rendering treeView diagram
`+e);let o=a.db,s=o.getRoot(),c=o.getConfig(),u=r(t),d=u.append(`g`);d.attr(`class`,`tree-view`);let{totalHeight:f,totalWidth:p}=D(d,s,c);u.attr(`viewBox`,`-${c.lineThickness/2} 0 ${p} ${f}`),n(u,f,p,c.useMaxWidth)},`draw`)},k={labelFontSize:`16px`,labelColor:`black`,lineColor:`black`},A={db:S,renderer:O,parser:w,styles:u(({treeView:e})=>{let{labelFontSize:t,labelColor:n,lineColor:r}=d(k,e);return`
    .treeView-node-label {
        font-size: ${t};
        fill: ${n};
    }
    .treeView-node-line {
        stroke: ${r};
    }
    `},`styles`)};export{A as diagram};