import{a as H}from"./chunk-AQ7QNAOH.js";import{a as O}from"./chunk-CDENLQJG.js";import{a as G}from"./chunk-GCLFR7RJ.js";import{a as z}from"./chunk-HDKR6WI7.js";import"./chunk-GBAVNUHL.js";import"./chunk-BPMBFFCK.js";import"./chunk-OMKCQORZ.js";import"./chunk-NPTHKJ2T.js";import"./chunk-PNOROMQC.js";import"./chunk-YLPW272G.js";import"./chunk-EE6VSO4L.js";import"./chunk-KIKOYZ3Y.js";import"./chunk-AYJOBZGG.js";import"./chunk-72QLSRFG.js";import"./chunk-RZZP2ERR.js";import"./chunk-SR3GFKQL.js";import"./chunk-6FD75OKF.js";import"./chunk-QY6Y4V6I.js";import"./chunk-O4AR42YJ.js";import"./chunk-F4FWBINX.js";import{b as W,d as X}from"./chunk-OML3RYBD.js";import{o as y}from"./chunk-3FYGGAQT.js";import"./chunk-VLJCJ4DM.js";import{G as N,N as A,S as E,T as L,U as D,V as _,W as M,X as S,Y as R,j as k,t as I}from"./chunk-2LQZINQI.js";import{b as C}from"./chunk-BG5BKATX.js";import{a as f}from"./chunk-YUSHYV7C.js";import"./chunk-3ZIVKGVJ.js";import"./chunk-OOJM4CTU.js";var q=/[─━│┃└┗├┣]/,U=/[└┗├┣]/,re=/[─━]/,Y=/^[\s│┃]+$/,P=/^\s*(title[\t ]|accTitle[\t ]*:|accDescr[\t ]*[:{])/,F=/^\s*%%/,ne="    ";function j(r){return r.some(t=>q.test(t))}f(j,"isBoxDrawingFormat");function J(r){for(let t of r){let e=U.exec(t);if(e?.index&&e.index>0)return e.index}return 4}f(J,"inferSegmentWidth");function K(r,t){return r.replace(/\bline\s+(\d+)\b/gi,(e,n)=>{let s=parseInt(n,10),i=t.get(s);return i?`line ${i}`:e})}f(K,"remapErrorLines");function Q(r){let t=r.split(`
`),e=new Map,n=-1;for(let[p,c]of t.entries())if(c.trim()==="treeView-beta"){n=p;break}if(n===-1)return{text:r,lineMap:e};let s=[];for(let p=n+1;p<t.length;p++){let c=t[p];c.trim()===""||F.test(c)||P.test(c)||Y.test(c)||s.push(c.replace(/\t/g,"    "))}if(!j(s))return{text:r,lineMap:e};let i=J(s),o=[],a=0;for(let p=0;p<=n;p++)o.push(t[p]),a++,e.set(a,p+1);for(let p=n+1;p<t.length;p++){let c=t[p],d=c.trim(),h=p+1;if(d===""){o.push(c),a++,e.set(a,h);continue}if(F.test(c)){o.push(c),a++,e.set(a,h);continue}if(P.test(c)){o.push(c),a++,e.set(a,h);continue}if(Y.test(c))continue;let l=c.replace(/\t/g,"    "),m=U.exec(l);if(m?.index!==void 0){let g=m.index,w=Math.round(g/i)+1,u=g+1;for(;u<l.length&&re.test(l[u]);)u++;for(;u<l.length&&l[u]===" ";)u++;let v=l.slice(u).trimEnd();if(!v)throw new Error(`Line ${h}: Empty node \u2014 expected a filename or directory name after the box-drawing prefix`);let te=ne.repeat(w);o.push(te+v),a++,e.set(a,h)}else{if(/^[\s─━│┃└┗├┣]+$/.test(l))continue;if(q.test(l))o.push(c),a++,e.set(a,h);else{if(/^\s+/.test(l))throw new Error(`Line ${h}: Unexpected indentation without box-drawing characters. In box-drawing format, use \u251C\u2500\u2500 or \u2514\u2500\u2500 prefixes for indented nodes.`);o.push(c),a++,e.set(a,h)}}}return{text:o.join(`
`),lineMap:e}}f(Q,"preprocessBoxDrawing");var x=new z(()=>({cnt:1,stack:[{id:0,level:-1,name:"/",nodeType:"directory",children:[]}]})),ie=f(()=>{x.reset(),E()},"clear"),oe=f(()=>x.records.stack[0],"getRoot"),se=f(()=>x.records.cnt,"getCount"),ae=k.treeView,ce=f(()=>y(ae,I().treeView),"getConfig"),le=f((r,t,e,n,s,i)=>{for(;r<=x.records.stack[x.records.stack.length-1].level;)x.records.stack.pop();let o={id:x.records.cnt++,level:r,name:t,nodeType:e,icon:s,cssClass:n,description:i,children:[]};x.records.stack[x.records.stack.length-1].children.push(o),x.records.stack.push(o)},"addNode"),de={clear:ie,addNode:le,getRoot:oe,getCount:se,getConfig:ce,getAccTitle:D,getAccDescription:M,getDiagramTitle:R,setAccDescription:_,setAccTitle:L,setDiagramTitle:S},B=de,he=f(r=>{O(r,B);for(let t of r.nodes){let e=typeof t.indent=="number"?t.indent:0,n=t.name,s=n.endsWith("/");s&&(n=n.slice(0,-1));let i=s?"directory":"file",o=t.classAnnotation||void 0,a=t.iconAnnotation,p=a!==void 0?a||"none":void 0,c=t.descAnnotation||void 0,d=c?N(c,I()):void 0;B.addNode(e,n,i,o,p,d)}},"populate"),pe={parse:f(async r=>{let{text:t,lineMap:e}=Q(r);try{let n=await G("treeView",t);C.debug(n),he(n)}catch(n){throw e.size>0&&n instanceof Error&&(n.message=K(n.message,e)),n}},"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(r,t){let e=t?.filenameIcons?.[r];if(e)return e;let n=r.lastIndexOf(".");if(n>0){let s=r.substring(n).toLowerCase(),i=t?.extensionIcons;return i?.[s]??i?.[s.slice(1)]}}f(ee,"detectIcon");function T(r,t){return r.includes(":")?r:r in b.icons||!t?`${b.prefix}:${r}`:`${t}:${r}`}f(T,"qualifyIcon");function $(r,t){if(r.icon!=="none"){if(r.icon)return T(r.icon,t.defaultIconPack);if(t.showIcons){if(r.nodeType==="file"){let e=ee(r.name,t);if(e==="none")return;if(e)return T(e,t.defaultIconPack)}return`${b.prefix}:${r.nodeType==="directory"?"folder":"file"}`}}}f($,"getNodeIcon");W([{name:b.prefix,icons:b}]);var V=14,fe=4,ge=16,ue=f(async(r,t)=>{let e=[],n=f(i=>{let o=$(i,t);o&&e.push({icon:o,node:i}),i.children.forEach(n)},"collect");n(r);let s=await Promise.all(e.map(async({icon:i,node:o})=>({id:o.id,svg:await X(i,{height:V,width:V})})));return new Map(s.map(({id:i,svg:o})=>[i,o]))},"resolveNodeIcons"),me=f((r,t,e,n,s,i)=>{let o=n.append("g"),a="treeView-node-label";e.nodeType==="directory"&&(a+=" treeView-node-dir"),e.cssClass&&(a+=` ${e.cssClass}`);let p=V+fe,c=$(e,s),d=c!==void 0;c&&o.append("g").attr("class","treeView-node-icon").attr("transform",`translate(${r+s.paddingX}, ${t+s.paddingY})`).html(i.get(e.id)??"");let h=o.append("text").text(e.name).attr("dominant-baseline","middle").attr("class",a),{height:l,width:m}=h.node().getBBox(),g=l+s.paddingY*2,w=r+s.paddingX+(d?p:0);h.attr("x",w),h.attr("y",t+g/2);let u=w+m,v=m+s.paddingX*2+(d?p:0);return e.BBox={x:r,y:t,width:v,height:g},e.cssClass?.split(/\s+/).includes("highlight")&&o.insert("rect",":first-child").attr("x",r).attr("y",t+1).attr("width",0).attr("height",g-2).attr("rx",3).attr("class","treeView-highlight-bg"),{node:e,nodeGroup:o,labelRightEdge:u,centerY:t+g/2}},"positionLabel"),Z=f((r,t,e,n,s,i)=>r.append("line").attr("x1",t).attr("y1",e).attr("x2",n).attr("y2",s).attr("stroke-width",i).attr("class","treeView-node-line"),"positionLine"),we=f((r,t,e,n)=>{let s=0,i=0,o=[],a=f((d,h,l,m)=>{let g=m*(l.rowIndent+l.paddingX),w=me(g,s,h,d,l,n);o.push(w);let{height:u,width:v}=h.BBox;Z(d,g-l.rowIndent,s+u/2,g,s+u/2,l.lineThickness),i=Math.max(i,g+v),s+=u},"drawNode"),p=f((d,h=0)=>{a(r,d,e,h),d.children.forEach(w=>{p(w,h+1)});let{x:l,y:m,height:g}=d.BBox;if(d.children.length){let{y:w,height:u}=d.children[d.children.length-1].BBox;Z(r,l+e.paddingX,m+g,l+e.paddingX,w+u/2+e.lineThickness/2,e.lineThickness)}},"processNode");p(t);let c=o.filter(d=>d.node.description);if(c.length>0){let h=Math.max(...o.map(l=>l.labelRightEdge))+ge;for(let l of c){let g=l.nodeGroup.append("text").text(l.node.description).attr("dominant-baseline","middle").attr("class","treeView-node-description").attr("x",h).attr("y",l.centerY).node().getBBox();i=Math.max(i,h+g.width+e.paddingX)}}for(let d of o)if(d.node.cssClass?.split(/\s+/).includes("highlight")){let h=d.nodeGroup.select(".treeView-highlight-bg");if(!h.empty()){let l=i-d.node.BBox.x+8;h.attr("width",l),i=Math.max(i,d.node.BBox.x+l+2)}}return{totalHeight:s,totalWidth:i}},"drawTree"),xe=f(async(r,t,e,n)=>{C.debug(`Rendering treeView diagram
`+r);let s=n.db,i=s.getRoot(),o=s.getConfig(),a=H(t),p=a.append("g");p.attr("class","tree-view");let c=await ue(i,o),{totalHeight:d,totalWidth:h}=we(p,i,o,c);a.attr("viewBox",`-${o.lineThickness/2} 0 ${h} ${d}`),A(a,d,h,o.useMaxWidth)},"draw"),ve={draw:xe},be=ve,Ce={labelFontSize:"16px",labelColor:"black",lineColor:"black",iconColor:"#546e7a",descriptionColor:"#6a9955",highlightBg:"rgba(255, 193, 7, 0.15)",highlightStroke:"#ffc107"},Ie=f(({treeView:r})=>{let{labelFontSize:t,labelColor:e,lineColor:n,iconColor:s,descriptionColor:i,highlightBg:o,highlightStroke:a}=y(Ce,r);return`
    .treeView-node-label {
        font-size: ${t};
        fill: ${e};
        white-space: pre;
    }
    .treeView-node-dir {
        font-weight: bold;
    }
    .treeView-node-line {
        stroke: ${n};
    }
    .treeView-node-icon {
        color: ${s};
    }
    .treeView-node-description {
        font-size: ${t};
        fill: ${i};
        font-style: italic;
        white-space: pre;
    }
    .treeView-highlight-bg {
        fill: ${o};
        stroke: ${a};
        stroke-width: 1;
    }
    `},"styles"),ye=Ie,De={db:B,renderer:be,parser:pe,styles:ye};export{De as diagram};
