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