import{J as x,m as f,s as C,K as B,k as T,l as y,_ as s,a0 as b,p as k,a3 as V,q as S,Z as _,a1 as N,S as D}from"./index-CVAj7PxY.js";import{p as $}from"./chunk-4BX2VUAB-WPq3Ddjs.js";import{I as A}from"./chunk-QZHKN3VN-PahkgR2H.js";import{p as I}from"./wardley-RL74JXVD-D54PzR9e.js";import"./min-CsOe_qnr.js";import"./_baseUniq-C2C4b5Zg.js";var d=new A(()=>({cnt:1,stack:[{id:0,level:-1,name:"/",children:[]}]})),X=s(()=>{d.reset(),D()},"clear"),z=s(()=>d.records.stack[0],"getRoot"),H=s(()=>d.records.cnt,"getCount"),L=N.treeView,R=s(()=>b(L,_().treeView),"getConfig"),W=s((e,t)=>{for(;e<=d.records.stack[d.records.stack.length-1].level;)d.records.stack.pop();const a={id:d.records.cnt++,level:e,name:t,children:[]};d.records.stack[d.records.stack.length-1].children.push(a),d.records.stack.push(a)},"addNode"),E={clear:X,addNode:W,getRoot:z,getCount:H,getConfig:R,getAccTitle:y,getAccDescription:T,getDiagramTitle:B,setAccDescription:C,setAccTitle:f,setDiagramTitle:x},w=E,M=s(e=>{$(e,w),e.nodes.map(t=>w.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:p,width:r}=c.node().getBBox(),l=p+o.paddingY*2,i=r+o.paddingX*2;c.attr("x",e+o.paddingX),c.attr("y",t+l/2),a.BBox={x:e,y:t,width:i,height:l}},"positionLabel"),u=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"),q=s((e,t,a)=>{let n=0,o=0;const c=s((r,l,i,h)=>{const v=h*(i.rowIndent+i.paddingX);Y(v,n,l,r,i);const{height:g,width:m}=l.BBox;u(r,v-i.rowIndent,n+g/2,v,n+g/2,i.lineThickness),o=Math.max(o,v+m),n+=g},"drawNode"),p=s((r,l=0)=>{c(e,r,a,l),r.children.forEach(g=>{p(g,l+1)});const{x:i,y:h,height:v}=r.BBox;if(r.children.length){const{y:g,height:m}=r.children[r.children.length-1].BBox;u(e,i+a.paddingX,h+v,i+a.paddingX,g+m/2+a.lineThickness/2,a.lineThickness)}},"processNode");return p(t),{totalHeight:n,totalWidth:o}},"drawTree"),J=s((e,t,a,n)=>{k.debug(`Rendering treeView diagram
`+e);const o=n.db,c=o.getRoot(),p=o.getConfig(),r=V(t),l=r.append("g");l.attr("class","tree-view");const{totalHeight:i,totalWidth:h}=q(l,c,p);r.attr("viewBox",`-${p.lineThickness/2} 0 ${h} ${i}`),S(r,i,h,p.useMaxWidth)},"draw"),K={draw:J},Z=K,j={labelFontSize:"16px",labelColor:"black",lineColor:"black"},G=s(({treeView:e})=>{const{labelFontSize:t,labelColor:a,lineColor:n}=b(j,e);return`
    .treeView-node-label {
        font-size: ${t};
        fill: ${a};
    }
    .treeView-node-line {
        stroke: ${n};
    }
    `},"styles"),O=G,re={db:w,renderer:Z,parser:F,styles:O};export{re as diagram};
