import{t as e}from"./mermaid-parser.core-DJSfJeVd.js";import{g as t,h as n}from"./src-Cj8Bsjcj.js";import{H as r,K as i,U as a,a as o,b as s,c,f as l,v as u,w as d,y as f}from"./chunk-CSCIHK7Q-CH4Qb1Yg.js";import{i as p}from"./chunk-5ZQYHXKU-DuukB2a2.js";import{t as m}from"./chunk-WU5MYG2G-CRcendUM.js";import{t as h}from"./chunk-4BX2VUAB-CC3fcb1N.js";import{t as g}from"./chunk-QZHKN3VN-YU1TuFC3.js";var _=new g(()=>({cnt:1,stack:[{id:0,level:-1,name:`/`,children:[]}]})),v=n(()=>{_.reset(),o()},`clear`),y=n(()=>_.records.stack[0],`getRoot`),b=n(()=>_.records.cnt,`getCount`),x=l.treeView,S={clear:v,addNode:n((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:n(()=>p(x,s().treeView),`getConfig`),getAccTitle:f,getAccDescription:u,getDiagramTitle:d,setAccDescription:r,setAccTitle:a,setDiagramTitle:i},C=n(e=>{h(e,S),e.nodes.map(e=>S.addNode(e.indent?parseInt(e.indent):0,e.name))},`populate`),w={parse:n(async n=>{let r=await e(`treeView`,n);t.debug(r),C(r)},`parse`)},T=n((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=n((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=n((e,t,r)=>{let i=0,a=0,o=n((e,t,n,r)=>{let o=r*(n.rowIndent+n.paddingX);T(o,i,t,e,n);let{height:s,width:c}=t.BBox;E(e,o-n.rowIndent,i+s/2,o,i+s/2,n.lineThickness),a=Math.max(a,o+c),i+=s},`drawNode`),s=n((t,n=0)=>{o(e,t,r,n),t.children.forEach(e=>{s(e,n+1)});let{x:i,y:a,height:c}=t.BBox;if(t.children.length){let{y:n,height:o}=t.children[t.children.length-1].BBox;E(e,i+r.paddingX,a+c,i+r.paddingX,n+o/2+r.lineThickness/2,r.lineThickness)}},`processNode`);return s(t),{totalHeight:i,totalWidth:a}},`drawTree`),O={draw:n((e,n,r,i)=>{t.debug(`Rendering treeView diagram
`+e);let a=i.db,o=a.getRoot(),s=a.getConfig(),l=m(n),u=l.append(`g`);u.attr(`class`,`tree-view`);let{totalHeight:d,totalWidth:f}=D(u,o,s);l.attr(`viewBox`,`-${s.lineThickness/2} 0 ${f} ${d}`),c(l,d,f,s.useMaxWidth)},`draw`)},k={labelFontSize:`16px`,labelColor:`black`,lineColor:`black`},A={db:S,renderer:O,parser:w,styles:n(({treeView:e})=>{let{labelFontSize:t,labelColor:n,lineColor:r}=p(k,e);return`
    .treeView-node-label {
        font-size: ${t};
        fill: ${n};
    }
    .treeView-node-line {
        stroke: ${r};
    }
    `},`styles`)};export{A as diagram};