import{b3 as x,b1 as f,b0 as C,a5 as B,a1 as T,a2 as y,b as s,s as u,aD as k,a$ as V,E as S,a3 as D,t as N,S as _}from"./mermaid.core-CgzKIwyi.js";import{p as $}from"./chunk-4BX2VUAB-D7aZ98Fd.js";import{I as A}from"./chunk-QZHKN3VN-DwhgjqdW.js";import{p as I}from"./wardley-L42UT6IY-DnTZ6aB4.js";import"./offscreen-2SGNljWq.js";import"./_commonjsHelpers-CjYu-_XP.js";var l=new A(()=>({cnt:1,stack:[{id:0,level:-1,name:"/",children:[]}]})),X=s(()=>{l.reset(),N()},"clear"),z=s(()=>l.records.stack[0],"getRoot"),E=s(()=>l.records.cnt,"getCount"),H=_.treeView,L=s(()=>u(H,D().treeView),"getConfig"),R=s((e,t)=>{for(;e<=l.records.stack[l.records.stack.length-1].level;)l.records.stack.pop();const a={id:l.records.cnt++,level:e,name:t,children:[]};l.records.stack[l.records.stack.length-1].children.push(a),l.records.stack.push(a)},"addNode"),W={clear:X,addNode:R,getRoot:z,getCount:E,getConfig:L,getAccTitle:y,getAccDescription:T,getDiagramTitle:B,setAccDescription:C,setAccTitle:f,setDiagramTitle:x},m=W,M=s(e=>{$(e,m),e.nodes.map(t=>m.addNode(t.indent?parseInt(t.indent):0,t.name))},"populate"),F={parse:s(async e=>{const t=await I("treeView",e);k.debug(t),M(t)},"parse")},Y=s((e,t,a,n,o)=>{const c=n.append("text").text(a.name).attr("dominant-baseline","middle").attr("class","treeView-node-label"),{height:g,width:r}=c.node().getBBox(),d=g+o.paddingY*2,i=r+o.paddingX*2;c.attr("x",e+o.paddingX),c.attr("y",t+d/2),a.BBox={x:e,y:t,width:i,height:d}},"positionLabel"),w=s((e,t,a,n,o,c)=>e.append("line").attr("x1",t).attr("y1",a).attr("x2",n).attr("y2",o).attr("stroke-width",c).attr("class","treeView-node-line"),"positionLine"),j=s((e,t,a)=>{let n=0,o=0;const c=s((r,d,i,h)=>{const v=h*(i.rowIndent+i.paddingX);Y(v,n,d,r,i);const{height:p,width:b}=d.BBox;w(r,v-i.rowIndent,n+p/2,v,n+p/2,i.lineThickness),o=Math.max(o,v+b),n+=p},"drawNode"),g=s((r,d=0)=>{c(e,r,a,d),r.children.forEach(p=>{g(p,d+1)});const{x:i,y:h,height:v}=r.BBox;if(r.children.length){const{y:p,height:b}=r.children[r.children.length-1].BBox;w(e,i+a.paddingX,h+v,i+a.paddingX,p+b/2+a.lineThickness/2,a.lineThickness)}},"processNode");return g(t),{totalHeight:n,totalWidth:o}},"drawTree"),q=s((e,t,a,n)=>{k.debug(`Rendering treeView diagram
`+e);const o=n.db,c=o.getRoot(),g=o.getConfig(),r=V(t),d=r.append("g");d.attr("class","tree-view");const{totalHeight:i,totalWidth:h}=j(d,c,g);r.attr("viewBox",`-${g.lineThickness/2} 0 ${h} ${i}`),S(r,i,h,g.useMaxWidth)},"draw"),G={draw:q},J=G,K={labelFontSize:"16px",labelColor:"black",lineColor:"black"},O=s(({treeView:e})=>{const{labelFontSize:t,labelColor:a,lineColor:n}=u(K,e);return`
    .treeView-node-label {
        font-size: ${t};
        fill: ${a};
    }
    .treeView-node-line {
        stroke: ${n};
    }
    `},"styles"),P=O,re={db:m,renderer:J,parser:F,styles:P};export{re as diagram};
