25 lines
11 KiB
JavaScript
Raw Permalink Normal View History

2026-05-31 13:21:13 +02:00
import{a as de}from"./chunk-JQRUD6KW.mjs";import{a as me}from"./chunk-2T2R6R2M.mjs";import"./chunk-UP6H54XL.mjs";import"./chunk-UXSXWOXI.mjs";import"./chunk-C62D2QBJ.mjs";import"./chunk-CEXFNPSA.mjs";import"./chunk-RERM46MO.mjs";import"./chunk-J5EP6P6S.mjs";import"./chunk-RLI5ZMPA.mjs";import"./chunk-2UTLFMKG.mjs";import"./chunk-RKZBBQEN.mjs";import{a as fe}from"./chunk-LRIF4GLE.mjs";import{a as pe}from"./chunk-ZXARS5L4.mjs";import{c as ce,d as v}from"./chunk-T2UQINTJ.mjs";import{o as W}from"./chunk-QA3QBVWF.mjs";import"./chunk-KNLZD3CH.mjs";import{O as Z,S as ee,T as te,U as ae,V as re,W as se,X as le,Y as oe,h as K,j as Q,t as L}from"./chunk-67TQ5CYL.mjs";import{b as k,h as E,j as $,k as ne,l as ie,m as I}from"./chunk-7W6UQGC5.mjs";import"./chunk-KGYTTC2M.mjs";import"./chunk-4R4BOZG6.mjs";import{a as p}from"./chunk-AQ6EADP3.mjs";var F=class{constructor(){this.nodes=[];this.levels=new Map;this.outerNodes=[];this.classes=new Map;this.setAccTitle=te;this.getAccTitle=ae;this.setDiagramTitle=le;this.getDiagramTitle=oe;this.getAccDescription=se;this.setAccDescription=re}static{p(this,"TreeMapDB")}getNodes(){return this.nodes}getConfig(){let r=Q,i=L();return W({...r.treemap,...i.treemap??{}})}addNode(r,i){this.nodes.push(r),this.levels.set(r,i),i===0&&(this.outerNodes.push(r),this.root??=r)}getRoot(){return{name:"",children:this.outerNodes}}addClass(r,i){let l=this.classes.get(r)??{id:r,styles:[],textStyles:[]},o=i.replace(/\\,/g,"\xA7\xA7\xA7").replace(/,/g,";").replace(/§§§/g,",").split(";");o&&o.forEach(s=>{ce(s)&&(l?.textStyles?l.textStyles.push(s):l.textStyles=[s]),l?.styles?l.styles.push(s):l.styles=[s]}),this.classes.set(r,l)}getClasses(){return this.classes}getStylesForClass(r){return this.classes.get(r)?.styles??[]}clear(){ee(),this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.root=void 0}};function ge(m){if(!m.length)return[];let r=[],i=[];return m.forEach(l=>{let o={name:l.name,children:l.type==="Leaf"?void 0:[]};for(o.classSelector=l?.classSelector,l?.cssCompiledStyles&&(o.cssCompiledStyles=l.cssCompiledStyles),l.type==="Leaf"&&l.value!==void 0&&(o.value=l.value);i.length>0&&i[i.length-1].level>=l.level;)i.pop();if(i.length===0)r.push(o);else{let s=i[i.length-1].node;s.children?s.children.push(o):s.children=[o]}l.type!=="Leaf"&&i.push({node:o,level:l.level})}),r}p(ge,"buildHierarchy");var ve=p((m,r)=>{de(m,r);let i=[];for(let s of m.TreemapRows??[])s.$type==="ClassDefStatement"&&r.addClass(s.className??"",s.styleText??"");for(let s of m.TreemapRows??[]){let d=s.item;if(!d)continue;let f=s.indent?parseInt(s.indent):0,R=we(d),a=d.classSelector?r.getStylesForClass(d.classSelector):[],A=a.length>0?a:void 0,T={level:f,name:R,type:d.$type,value:d.value,classSelector:d.classSelector,cssCompiledStyles:A};i.push(T)}let l=ge(i),o=p((s,d)=>{for(let f of s)r.addNode(f,d),f.children&&f.children.length>0&&o(f.children,d+1)},"addNodesRecursively");o(l,0)},"populate"),we=p(m=>m.name?String(m.name):"","getItemName"),O={parser:{yy:void 0},parse:p(async m=>{try{let i=await me("treemap",m);k.debug("Treemap AST:",i);let l=O.parser?.yy;if(!(l instanceof F))throw new Error("parser.parser?.yy was not a TreemapDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");ve(i,l)}catch(r){throw k.error("Error parsing treemap:",r),r}},"parse")};var Ne=10,P=10,B=25,Le=p((m,r,i,l)=>{let o=l.db,s=o.getConfig(),d=s.padding??Ne,f=o.getDiagramTitle(),R=o.getRoot(),{themeVariables:a}=L();if(!R)return;let A=f?30:0,T=fe(r),X=s.nodeWidth?s.nodeWidth*P:960,Y=s.nodeHeight?s.nodeHeight*P:500,G=X,q=Y+A;T.attr("viewBox",`0 0 ${G} ${q}`),Z(T,q,G,s.useMaxWidth);let C;try{let e=s.valueFormat||",";if(e==="$0,0")C=p(t=>"$"+$(",")(t),"valueFormat");else if(e.startsWith("$")&&e.includes(",")){let t=/\.\d+/.exec(e),n=t?t[0]:"";C=p(g=>"$"+$(","+n)(g),"valueFormat")}else if(e.startsWith("$")){let t=e.substring(1);C=p(n=>"$"+$(t||"")(n),"valueFormat")}else C=$(e)}catch(e){k.error("Error creating format function:",e),C=$(",")}let V=I().range(["transparent",a.cScale0,a.cScale1,a.cS
.treemapNode.section {
stroke: ${o.sectionStrokeColor};
stroke-width: ${o.sectionStrokeWidth};
fill: ${o.sectionFillColor};
}
.treemapNode.leaf {
stroke: ${o.leafStrokeColor};
stroke-width: ${o.leafStrokeWidth};
fill: ${o.leafFillColor};
}
.treemapLabel {
fill: ${d};
font-size: ${o.labelFontSize};
}
.treemapValue {
fill: ${f};
font-size: ${o.valueFontSize};
}
.treemapTitle {
fill: ${s};
font-size: ${o.titleFontSize};
}
`},"getStyles"),he=Pe;var ft={parser:O,get db(){return new F},renderer:ue,styles:he};export{ft as diagram};