import{a as H}from"./chunk-T4KNOXOM.js";import{a as O}from"./chunk-CDENLQJG.js";import{a as G}from"./chunk-23OFDAHQ.js";import{a as X}from"./chunk-HDKR6WI7.js";import"./chunk-64RAZIDH.js";import"./chunk-BKUW36BS.js";import"./chunk-4R6AKNXZ.js";import"./chunk-7BXJKEEM.js";import"./chunk-KKCTMRNV.js";import"./chunk-3JAGLS23.js";import"./chunk-PVZRSI6V.js";import"./chunk-JDVLQXMK.js";import"./chunk-WQ47ED54.js";import"./chunk-AP7GPLJ7.js";import"./chunk-W7QF4GTN.js";import"./chunk-42NANJO2.js";import"./chunk-GYOZBIN2.js";import"./chunk-RLKBNOCG.js";import"./chunk-CR6SF2HR.js";import"./chunk-7AJGXJKH.js";import{b as z,d as W}from"./chunk-ZKLJWGVP.js";import{o as y}from"./chunk-55QKDJ5H.js";import"./chunk-2K35RNHN.js";import{H as A,O as N,T as D,U as E,V as S,W as L,X as _,Y as M,Z as R,k as T,u as C}from"./chunk-E5GXGYZM.js";import{b as I}from"./chunk-ZZZJFKF2.js";import{a as p}from"./chunk-YUSHYV7C.js";import"./chunk-C6Q5SG76.js";var Z=/[─━│┃└┗├┣]/,q=/[└┗├┣]/,re=/[─━]/,Y=/^[\s│┃]+$/,P=/^\s*(title[\t ]|accTitle[\t ]*:|accDescr[\t ]*[:{])/,F=/^\s*%%/,ie="    ";function U(n){return n.some(e=>Z.test(e))}p(U,"isBoxDrawingFormat");function J(n){for(let e of n){let t=q.exec(e);if(t?.index&&t.index>0)return t.index}return 4}p(J,"inferSegmentWidth");function K(n,e){return n.replace(/\bline\s+(\d+)\b/gi,(t,r)=>{let i=parseInt(r,10),a=e.get(i);return a?`line ${a}`:t})}p(K,"remapErrorLines");function Q(n){let e=n.split(`
`),t=new Map,r=-1;for(let[s,o]of e.entries())if(o.trim()==="treeView-beta"){r=s;break}if(r===-1)return{text:n,lineMap:t};let i=[];for(let s=r+1;s<e.length;s++){let o=e[s];o.trim()===""||F.test(o)||P.test(o)||Y.test(o)||i.push(o.replace(/\t/g,"    "))}if(!U(i))return{text:n,lineMap:t};let a=J(i),c=[],l=0;for(let s=0;s<=r;s++)c.push(e[s]),l++,t.set(l,s+1);for(let s=r+1;s<e.length;s++){let o=e[s],h=o.trim(),f=s+1;if(h===""){c.push(o),l++,t.set(l,f);continue}if(F.test(o)){c.push(o),l++,t.set(l,f);continue}if(P.test(o)){c.push(o),l++,t.set(l,f);continue}if(Y.test(o))continue;let d=o.replace(/\t/g,"    "),m=q.exec(d);if(m?.index!==void 0){let g=m.index,w=Math.round(g/a)+1,u=g+1;for(;u<d.length&&re.test(d[u]);)u++;for(;u<d.length&&d[u]===" ";)u++;let v=d.slice(u).trimEnd();if(!v)throw new Error(`Line ${f}: Empty node \u2014 expected a filename or directory name after the box-drawing prefix`);let ne=ie.repeat(w);c.push(ne+v),l++,t.set(l,f)}else{if(/^[\s─━│┃└┗├┣]+$/.test(d))continue;if(Z.test(d))c.push(o),l++,t.set(l,f);else{if(/^\s+/.test(d))throw new Error(`Line ${f}: Unexpected indentation without box-drawing characters. In box-drawing format, use \u251C\u2500\u2500 or \u2514\u2500\u2500 prefixes for indented nodes.`);c.push(o),l++,t.set(l,f)}}}return{text:c.join(`
`),lineMap:t}}p(Q,"preprocessBoxDrawing");var x=new X(()=>({cnt:1,stack:[{id:0,level:-1,name:"/",nodeType:"directory",children:[]}]})),oe=p(()=>{x.reset(),D()},"clear"),se=p(()=>x.records.stack[0],"getRoot"),ae=p(()=>x.records.cnt,"getCount"),ce=T.treeView,le=p(()=>y(ce,C().treeView),"getConfig"),de=p((n,e,t,r,i,a)=>{for(;n<=x.records.stack[x.records.stack.length-1].level;)x.records.stack.pop();let c={id:x.records.cnt++,level:n,name:e,nodeType:t,icon:i,cssClass:r,description:a,children:[]};x.records.stack[x.records.stack.length-1].children.push(c),x.records.stack.push(c)},"addNode"),he={clear:oe,addNode:de,getRoot:se,getCount:ae,getConfig:le,getAccTitle:S,getAccDescription:_,getDiagramTitle:R,setAccDescription:L,setAccTitle:E,setDiagramTitle:M},B=he,pe=p(n=>{O(n,B);for(let e of n.nodes){let t=typeof e.indent=="number"?e.indent:0,r=e.name,i=r.endsWith("/");i&&(r=r.slice(0,-1));let a=i?"directory":"file",c=e.classAnnotation||void 0,l=e.iconAnnotation,s=l!==void 0?l||"none":void 0,o=e.descAnnotation||void 0,h=o?A(o,C()):void 0;B.addNode(t,r,a,c,s,h)}},"populate"),fe={parse:p(async n=>{let{text:e,lineMap:t}=Q(n);try{let r=await G("treeView",e);I.debug(r),pe(r)}catch(r){throw t.size>0&&r instanceof Error&&(r.message=K(r.message,t)),r}},"parse")},b={prefix:"mermaid-treeview",height:24,width:24,icons:{folder:{body:'<path fill="currentColor" d="M10.59 4.59A2 2 0 0 0 9.17 4H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.17z"/>'},file:{body:'<path fill="currentColor" fill-rule="evenodd" d="M6 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8.83a2 2 0 0 0-.59-1.42l-4.82-4.82A2 2 0 0 0 13.17 2H6Zm7.5 1.9l4.6 4.6h-3.6a1 1 0 0 1-1-1V3.9Z" clip-rule="evenodd"/>'}}};function ee(n,e){let t=e?.filenameIcons?.[n];if(t)return t;let r=n.lastIndexOf(".");if(r>0){let i=n.substring(r).toLowerCase(),a=e?.extensionIcons;return a?.[i]??a?.[i.slice(1)]}}p(ee,"detectIcon");function V(n,e){return n.includes(":")?n:n in b.icons||!e?`${b.prefix}:${n}`:`${e}:${n}`}p(V,"qualifyIcon");function k(n,e){if(n.icon!=="none"){if(n.icon)return V(n.icon,e.defaultIconPack);if(e.showIcons){if(n.nodeType==="file"){let t=ee(n.name,e);if(t==="none")return;if(t)return V(t,e.defaultIconPack)}return`${b.prefix}:${n.nodeType==="directory"?"folder":"file"}`}}}p(k,"getNodeIcon");z([{name:b.prefix,icons:b}]);var $=14,ge=4,ue=16,te=p((n,e)=>`tv-icon-${n}-${e.replace(/[^\w-]/g,"-")}`,"iconSymbolId"),me=p(async(n,e,t,r)=>{let i=new Set,a=p(s=>{let o=k(s,t);o&&i.add(o),s.children.forEach(a)},"collect");if(a(e),i.size===0)return;let c=await Promise.all([...i].map(async s=>({icon:s,svg:await W(s,{height:$,width:$})}))),l=n.append("defs");for(let{icon:s,svg:o}of c)l.append("g").attr("id",te(r,s)).html(o)},"injectIconDefs"),we=p((n,e,t,r,i,a)=>{let c=r.append("g"),l="treeView-node-label";t.nodeType==="directory"&&(l+=" treeView-node-dir"),t.cssClass&&(l+=` ${t.cssClass}`);let s=$+ge,o=k(t,i),h=o!==void 0;o&&c.append("use").attr("xlink:href",`#${te(a,o)}`).attr("x",n+i.paddingX).attr("y",e+i.paddingY).attr("class","treeView-node-icon");let f=c.append("text").text(t.name).attr("dominant-baseline","middle").attr("class",l),{height:d,width:m}=f.node().getBBox(),g=d+i.paddingY*2,w=n+i.paddingX+(h?s:0);f.attr("x",w),f.attr("y",e+g/2);let u=w+m,v=m+i.paddingX*2+(h?s:0);return t.BBox={x:n,y:e,width:v,height:g},t.cssClass?.split(/\s+/).includes("highlight")&&c.insert("rect",":first-child").attr("x",n).attr("y",e+1).attr("width",0).attr("height",g-2).attr("rx",3).attr("class","treeView-highlight-bg"),{node:t,nodeGroup:c,labelRightEdge:u,centerY:e+g/2}},"positionLabel"),j=p((n,e,t,r,i,a)=>n.append("line").attr("x1",e).attr("y1",t).attr("x2",r).attr("y2",i).attr("stroke-width",a).attr("class","treeView-node-line"),"positionLine"),xe=p((n,e,t,r)=>{let i=0,a=0,c=[],l=p((h,f,d,m)=>{let g=m*(d.rowIndent+d.paddingX),w=we(g,i,f,h,d,r);c.push(w);let{height:u,width:v}=f.BBox;j(h,g-d.rowIndent,i+u/2,g,i+u/2,d.lineThickness),a=Math.max(a,g+v),i+=u},"drawNode"),s=p((h,f=0)=>{l(n,h,t,f),h.children.forEach(w=>{s(w,f+1)});let{x:d,y:m,height:g}=h.BBox;if(h.children.length){let{y:w,height:u}=h.children[h.children.length-1].BBox;j(n,d+t.paddingX,m+g,d+t.paddingX,w+u/2+t.lineThickness/2,t.lineThickness)}},"processNode");s(e);let o=c.filter(h=>h.node.description);if(o.length>0){let f=Math.max(...c.map(d=>d.labelRightEdge))+ue;for(let d of o){let g=d.nodeGroup.append("text").text(d.node.description).attr("dominant-baseline","middle").attr("class","treeView-node-description").attr("x",f).attr("y",d.centerY).node().getBBox();a=Math.max(a,f+g.width+t.paddingX)}}for(let h of c)if(h.node.cssClass?.split(/\s+/).includes("highlight")){let f=h.nodeGroup.select(".treeView-highlight-bg");if(!f.empty()){let d=a-h.node.BBox.x+8;f.attr("width",d),a=Math.max(a,h.node.BBox.x+d+2)}}return{totalHeight:i,totalWidth:a}},"drawTree"),ve=p(async(n,e,t,r)=>{I.debug(`Rendering treeView diagram
`+n);let i=r.db,a=i.getRoot(),c=i.getConfig(),l=H(e);await me(l,a,c,e);let s=l.append("g");s.attr("class","tree-view");let{totalHeight:o,totalWidth:h}=xe(s,a,c,e);l.attr("viewBox",`-${c.lineThickness/2} 0 ${h} ${o}`),N(l,o,h,c.useMaxWidth)},"draw"),be={draw:ve},Ie=be,Ce={labelFontSize:"16px",labelColor:"black",lineColor:"black",iconColor:"#546e7a",descriptionColor:"#6a9955",highlightBg:"rgba(255, 193, 7, 0.15)",highlightStroke:"#ffc107"},ye=p(({treeView:n})=>{let{labelFontSize:e,labelColor:t,lineColor:r,iconColor:i,descriptionColor:a,highlightBg:c,highlightStroke:l}=y(Ce,n);return`
    .treeView-node-label {
        font-size: ${e};
        fill: ${t};
        white-space: pre;
    }
    .treeView-node-dir {
        font-weight: bold;
    }
    .treeView-node-line {
        stroke: ${r};
    }
    .treeView-node-icon {
        color: ${i};
    }
    .treeView-node-description {
        font-size: ${e};
        fill: ${a};
        font-style: italic;
        white-space: pre;
    }
    .treeView-highlight-bg {
        fill: ${c};
        stroke: ${l};
        stroke-width: 1;
    }
    `},"styles"),Be=ye,Le={db:B,renderer:Ie,parser:fe,styles:Be};export{Le as diagram};
