| 123456789101112131415161718192021222324 |
- import{aa as w,dJ as de,dm as Q,bY as K,g1 as he,cb as ue,eV as U,go as P,g0 as Y,g4 as pe,dg as fe,g6 as ge,dr as me,df as ye,g3 as Se,cK as ve,ep as xe,bZ as be}from"./builder-DygomDiV.js";import{s as we}from"./chunk-2J33WTMH-DTqwDsyF.js";import{p as Ce}from"./chunk-4BX2VUAB-rSZvuPbd.js";import{p as Te}from"./wardley-L42UT6IY-DF83sseq.js";import{f as I}from"./defaultLocale-CrowFXzY.js";import{o as J}from"./ordinal-Cboi1Yqb.js";import"./init-Gi6I4Gst.js";function Le(e){var a=0,n=e.children,l=n&&n.length;if(!l)a=1;else for(;--l>=0;)a+=n[l].value;e.value=a}function $e(){return this.eachAfter(Le)}function Ae(e,a){let n=-1;for(const l of this)e.call(a,l,++n,this);return this}function Fe(e,a){for(var n=this,l=[n],r,o,d=-1;n=l.pop();)if(e.call(a,n,++d,this),r=n.children)for(o=r.length-1;o>=0;--o)l.push(r[o]);return this}function Ne(e,a){for(var n=this,l=[n],r=[],o,d,h,g=-1;n=l.pop();)if(r.push(n),o=n.children)for(d=0,h=o.length;d<h;++d)l.push(o[d]);for(;n=r.pop();)e.call(a,n,++g,this);return this}function Me(e,a){let n=-1;for(const l of this)if(e.call(a,l,++n,this))return l}function Ve(e){return this.eachAfter(function(a){for(var n=+e(a.data)||0,l=a.children,r=l&&l.length;--r>=0;)n+=l[r].value;a.value=n})}function ke(e){return this.eachBefore(function(a){a.children&&a.children.sort(e)})}function _e(e){for(var a=this,n=ze(a,e),l=[a];a!==n;)a=a.parent,l.push(a);for(var r=l.length;e!==n;)l.splice(r,0,e),e=e.parent;return l}function ze(e,a){if(e===a)return e;var n=e.ancestors(),l=a.ancestors(),r=null;for(e=n.pop(),a=l.pop();e===a;)r=e,e=n.pop(),a=l.pop();return r}function De(){for(var e=this,a=[e];e=e.parent;)a.push(e);return a}function Pe(){return Array.from(this)}function Be(){var e=[];return this.eachBefore(function(a){a.children||e.push(a)}),e}function Re(){var e=this,a=[];return e.each(function(n){n!==e&&a.push({source:n.parent,target:n})}),a}function*Ee(){var e=this,a,n=[e],l,r,o;do for(a=n.reverse(),n=[];e=a.pop();)if(yield e,l=e.children)for(r=0,o=l.length;r<o;++r)n.push(l[r]);while(n.length)}function ee(e,a){e instanceof Map?(e=[void 0,e],a===void 0&&(a=Ie)):a===void 0&&(a=He);for(var n=new j(e),l,r=[n],o,d,h,g;l=r.pop();)if((d=a(l.data))&&(g=(d=Array.from(d)).length))for(l.children=d,h=g-1;h>=0;--h)r.push(o=d[h]=new j(d[h])),o.parent=l,o.depth=l.depth+1;return n.eachBefore(Ge)}function We(){return ee(this).eachBefore(Oe)}function He(e){return e.children}function Ie(e){return Array.isArray(e)?e[1]:null}function Oe(e){e.data.value!==void 0&&(e.value=e.data.value),e.data=e.data.data}function Ge(e){var a=0;do e.height=a;while((e=e.parent)&&e.height<++a)}function j(e){this.data=e,this.depth=this.height=0,this.parent=null}j.prototype=ee.prototype={constructor:j,count:$e,each:Ae,eachAfter:Ne,eachBefore:Fe,find:Me,sum:Ve,sort:ke,path:_e,ancestors:De,descendants:Pe,leaves:Be,links:Re,copy:We,[Symbol.iterator]:Ee};function qe(e){if(typeof e!="function")throw new Error;return e}function O(){return 0}function G(e){return function(){return e}}function Xe(e){e.x0=Math.round(e.x0),e.y0=Math.round(e.y0),e.x1=Math.round(e.x1),e.y1=Math.round(e.y1)}function Ye(e,a,n,l,r){for(var o=e.children,d,h=-1,g=o.length,c=e.value&&(l-a)/e.value;++h<g;)d=o[h],d.y0=n,d.y1=r,d.x0=a,d.x1=a+=d.value*c}function je(e,a,n,l,r){for(var o=e.children,d,h=-1,g=o.length,c=e.value&&(r-n)/e.value;++h<g;)d=o[h],d.x0=a,d.x1=l,d.y0=n,d.y1=n+=d.value*c}var Ze=(1+Math.sqrt(5))/2;function Je(e,a,n,l,r,o){for(var d=[],h=a.children,g,c,u=0,b=0,s=h.length,x,S,v=a.value,p,m,M,N,z,R,V;u<s;){x=r-n,S=o-l;do p=h[b++].value;while(!p&&b<s);for(m=M=p,R=Math.max(S/x,x/S)/(v*e),V=p*p*R,z=Math.max(M/V,V/m);b<s;++b){if(p+=c=h[b].value,c<m&&(m=c),c>M&&(M=c),V=p*p*R,N=Math.max(M/V,V/m),N>z){p-=c;break}z=N}d.push(g={value:p,dice:x<S,children:h.slice(u,b)}),g.dice?Ye(g,n,l,r,v?l+=S*p/v:o):je(g,n,l,v?n+=x*p/v:r,o),v-=p,u=b}return d}const Ke=(function e(a){function n(l,r,o,d,h){Je(a,l,r,o,d,h)}return n.ratio=function(l){return e((l=+l)>1?l:1)},n})(Ze);function Ue(){var e=Ke,a=!1,n=1,l=1,r=[0],o=O,d=O,h=O,g=O,c=O;function u(s){return s.x0=s.y0=0,s.x1=n,s.y1=l,s.eachBefore(b),r=[0],a&&s.eachBefore(Xe),s}function b(s){var x=r[s.depth],S=s.x0+x,v=s.y0+x,p=s.x1-x,m=s.y1-x;p<S&&(S=p=(S+p)/2),m<v&&(v=m=(v+m)/2),s.x0=S,s.y0=v,s.x1=p,s.y1=m,s.children&&(x=r[s.depth+1]=o(s)/2,S+=c(s)-x,v+=d(s)-x,p-=h(s)-x,m-=g(s)-x,p<S&&(S=p=(S+p)/2),m<v&&(v=m=(v+m)/2),e(s,S,v,p,m))}return u.round=function(s){return arguments.length?(a=!!s,u):a},u.size=function(s){return arguments.length?(n=+s[0],l=+s[1],u):[n,l]},u.tile=function(s){return arguments.length?(e=qe(s),u):e},u.padding=function(s){return arguments.length?u.paddingInner(s).paddingOuter(s):u.paddingInner()},u.paddingInner=function(s){return arguments.length?(o=typeof s=="function"?s:G(+s),u):o},u.paddingOuter=function(s){return arguments.length?u.paddingTop(s).paddingRight(s).paddingBottom(s).paddingLeft(s):u.paddingTop()},u.paddingTop=function(s){return arguments.length?(d=typeof s=="function"?s:G(+s),u):d},u.paddingRight=function(s){return arguments.length?(h=typeof s=="function"?s:G(+s),u):h},u.paddingBottom=function(s){return arguments.length?(g=typeof s=="function"?s:G(+s),u):g},u.paddingLeft=function(s){return arguments.length?(c=typeof s=="function"?s:G(+s),u):c},u}var ae=class{constructor(){this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.setAccTitle=pe,this.getAccTitle=fe,this.setDiagramTitle=ge,this.getDiagramTitle=me,this.getAccDescription=ye,this.setAccDescription=Se}static{w(this,"TreeMapDB")}getNodes(){return this.nodes}getConfig(){const e=ve,a=Q();return K({...e.treemap,...a.treemap??{}})}addNode(e,a){this.nodes.push(e),this.levels.set(e,a),a===0&&(this.outerNodes.push(e),this.root??=e)}getRoot(){return{name:"",children:this.outerNodes}}addClass(e,a){const n=this.classes.get(e)??{id:e,styles:[],textStyles:[]},l=a.replace(/\\,/g,"§§§").replace(/,/g,";").replace(/§§§/g,",").split(";");l&&l.forEach(r=>{xe(r)&&(n?.textStyles?n.textStyles.push(r):n.textStyles=[r]),n?.styles?n.styles.push(r):n.styles=[r]}),this.classes.set(e,n)}getClasses(){return this.classes}getStylesForClass(e){return this.classes.get(e)?.styles??[]}clear(){be(),this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.root=void 0}};function ne(e){if(!e.length)return[];const a=[],n=[];return e.forEach(l=>{const r={name:l.name,children:l.type==="Leaf"?void 0:[]};for(r.classSelector=l?.classSelector,l?.cssCompiledStyles&&(r.cssCompiledStyles=l.cssCompiledStyles),l.type==="Leaf"&&l.value!==void 0&&(r.value=l.value);n.length>0&&n[n.length-1].level>=l.level;)n.pop();if(n.length===0)a.push(r);else{const o=n[n.length-1].node;o.children?o.children.push(r):o.children=[r]}l.type!=="Leaf"&&n.push({node:r,level:l.level})}),a}w(ne,"buildHierarchy");var Qe=w((e,a)=>{Ce(e,a);const n=[];for(const o of e.TreemapRows??[])o.$type==="ClassDefStatement"&&a.addClass(o.className??"",o.styleText??"");for(const o of e.TreemapRows??[]){const d=o.item;if(!d)continue;const h=o.indent?parseInt(o.indent):0,g=et(d),c=d.classSelector?a.getStylesForClass(d.classSelector):[],u=c.length>0?c:void 0,b={level:h,name:g,type:d.$type,value:d.value,classSelector:d.classSelector,cssCompiledStyles:u};n.push(b)}const l=ne(n),r=w((o,d)=>{for(const h of o)a.addNode(h,d),h.children&&h.children.length>0&&r(h.children,d+1)},"addNodesRecursively");r(l,0)},"populate"),et=w(e=>e.name?String(e.name):"","getItemName"),le={parser:{yy:void 0},parse:w(async e=>{try{const n=await Te("treemap",e);U.debug("Treemap AST:",n);const l=le.parser?.yy;if(!(l instanceof ae))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.");Qe(n,l)}catch(a){throw U.error("Error parsing treemap:",a),a}},"parse")},tt=10,B=10,q=25,at=w((e,a,n,l)=>{const r=l.db,o=r.getConfig(),d=o.padding??tt,h=r.getDiagramTitle(),g=r.getRoot(),{themeVariables:c}=Q();if(!g)return;const u=h?30:0,b=he(a),s=o.nodeWidth?o.nodeWidth*B:960,x=o.nodeHeight?o.nodeHeight*B:500,S=s,v=x+u;b.attr("viewBox",`0 0 ${S} ${v}`),ue(b,v,S,o.useMaxWidth);let p;try{const t=o.valueFormat||",";if(t==="$0,0")p=w(i=>"$"+I(",")(i),"valueFormat");else if(t.startsWith("$")&&t.includes(",")){const i=/\.\d+/.exec(t),f=i?i[0]:"";p=w(C=>"$"+I(","+f)(C),"valueFormat")}else if(t.startsWith("$")){const i=t.substring(1);p=w(f=>"$"+I(i||"")(f),"valueFormat")}else p=I(t)}catch(t){U.error("Error creating format function:",t),p=I(",")}const m=J().range(["transparent",c.cScale0,c.cScale1,c.cScale2,c.cScale3,c.cScale4,c.cScale5,c.cScale6,c.cScale7,c.cScale8,c.cScale9,c.cScale10,c.cScale11]),M=J().range(["transparent",c.cScalePeer0,c.cScalePeer1,c.cScalePeer2,c.cScalePeer3,c.cScalePeer4,c.cScalePeer5,c.cScalePeer6,c.cScalePeer7,c.cScalePeer8,c.cScalePeer9,c.cScalePeer10,c.cScalePeer11]),N=J().range([c.cScaleLabel0,c.cScaleLabel1,c.cScaleLabel2,c.cScaleLabel3,c.cScaleLabel4,c.cScaleLabel5,c.cScaleLabel6,c.cScaleLabel7,c.cScaleLabel8,c.cScaleLabel9,c.cScaleLabel10,c.cScaleLabel11]);h&&b.append("text").attr("x",S/2).attr("y",u/2).attr("class","treemapTitle").attr("text-anchor","middle").attr("dominant-baseline","middle").text(h);const z=b.append("g").attr("transform",`translate(0, ${u})`).attr("class","treemapContainer"),R=ee(g).sum(t=>t.value??0).sort((t,i)=>(i.value??0)-(t.value??0)),te=Ue().size([s,x]).paddingTop(t=>t.children&&t.children.length>0?q+B:0).paddingInner(d).paddingLeft(t=>t.children&&t.children.length>0?B:0).paddingRight(t=>t.children&&t.children.length>0?B:0).paddingBottom(t=>t.children&&t.children.length>0?B:0).round(!0)(R),re=te.descendants().filter(t=>t.children&&t.children.length>0),E=z.selectAll(".treemapSection").data(re).enter().append("g").attr("class","treemapSection").attr("transform",t=>`translate(${t.x0},${t.y0})`);E.append("rect").attr("width",t=>t.x1-t.x0).attr("height",q).attr("class","treemapSectionHeader").attr("fill","none").attr("fill-opacity",.6).attr("stroke-width",.6).attr("style",t=>t.depth===0?"display: none;":""),E.append("clipPath").attr("id",(t,i)=>`clip-section-${a}-${i}`).append("rect").attr("width",t=>Math.max(0,t.x1-t.x0-12)).attr("height",q),E.append("rect").attr("width",t=>t.x1-t.x0).attr("height",t=>t.y1-t.y0).attr("class",(t,i)=>`treemapSection section${i}`).attr("fill",t=>m(t.data.name)).attr("fill-opacity",.6).attr("stroke",t=>M(t.data.name)).attr("stroke-width",2).attr("stroke-opacity",.4).attr("style",t=>{if(t.depth===0)return"display: none;";const i=P({cssCompiledStyles:t.data.cssCompiledStyles});return i.nodeStyles+";"+i.borderStyles.join(";")}),E.append("text").attr("class","treemapSectionLabel").attr("x",6).attr("y",q/2).attr("dominant-baseline","middle").text(t=>t.depth===0?"":t.data.name).attr("font-weight","bold").attr("style",t=>{if(t.depth===0)return"display: none;";const i="dominant-baseline: middle; font-size: 12px; fill:"+N(t.data.name)+"; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;",f=P({cssCompiledStyles:t.data.cssCompiledStyles});return i+f.labelStyles.replace("color:","fill:")}).each(function(t){if(t.depth===0)return;const i=Y(this),f=t.data.name;i.text(f);const C=t.x1-t.x0,L=6;let $;o.showValues!==!1&&t.value?$=C-10-30-10-L:$=C-L-6;const A=Math.max(15,$),y=i.node();if(y.getComputedTextLength()>A){let T=f;for(;T.length>0;){if(T=f.substring(0,T.length-1),T.length===0){i.text("..."),y.getComputedTextLength()>A&&i.text("");break}if(i.text(T+"..."),y.getComputedTextLength()<=A)break}}}),o.showValues!==!1&&E.append("text").attr("class","treemapSectionValue").attr("x",t=>t.x1-t.x0-10).attr("y",q/2).attr("text-anchor","end").attr("dominant-baseline","middle").text(t=>t.value?p(t.value):"").attr("font-style","italic").attr("style",t=>{if(t.depth===0)return"display: none;";const i="text-anchor: end; dominant-baseline: middle; font-size: 10px; fill:"+N(t.data.name)+"; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;",f=P({cssCompiledStyles:t.data.cssCompiledStyles});return i+f.labelStyles.replace("color:","fill:")});const se=te.leaves(),X=z.selectAll(".treemapLeafGroup").data(se).enter().append("g").attr("class",(t,i)=>`treemapNode treemapLeafGroup leaf${i}${t.data.classSelector?` ${t.data.classSelector}`:""}x`).attr("transform",t=>`translate(${t.x0},${t.y0})`);X.append("rect").attr("width",t=>t.x1-t.x0).attr("height",t=>t.y1-t.y0).attr("class","treemapLeaf").attr("fill",t=>t.parent?m(t.parent.data.name):m(t.data.name)).attr("style",t=>P({cssCompiledStyles:t.data.cssCompiledStyles}).nodeStyles).attr("fill-opacity",.3).attr("stroke",t=>t.parent?m(t.parent.data.name):m(t.data.name)).attr("stroke-width",3),X.append("clipPath").attr("id",(t,i)=>`clip-${a}-${i}`).append("rect").attr("width",t=>Math.max(0,t.x1-t.x0-4)).attr("height",t=>Math.max(0,t.y1-t.y0-4)),X.append("text").attr("class","treemapLabel").attr("x",t=>(t.x1-t.x0)/2).attr("y",t=>(t.y1-t.y0)/2).attr("style",t=>{const i="text-anchor: middle; dominant-baseline: middle; font-size: 38px;fill:"+N(t.data.name)+";",f=P({cssCompiledStyles:t.data.cssCompiledStyles});return i+f.labelStyles.replace("color:","fill:")}).attr("clip-path",(t,i)=>`url(#clip-${a}-${i})`).text(t=>t.data.name).each(function(t){const i=Y(this),f=t.x1-t.x0,C=t.y1-t.y0,L=i.node(),$=4,D=f-2*$,A=C-2*$;if(D<10||A<10){i.style("display","none");return}let y=parseInt(i.style("font-size"),10);const k=8,F=28,T=.6,_=6,W=2;for(;L.getComputedTextLength()>D&&y>k;)y--,i.style("font-size",`${y}px`);let H=Math.max(_,Math.min(F,Math.round(y*T))),Z=y+W+H;for(;Z>A&&y>k&&(y--,H=Math.max(_,Math.min(F,Math.round(y*T))),!(H<_&&y===k));)i.style("font-size",`${y}px`),Z=y+W+H;i.style("font-size",`${y}px`),(L.getComputedTextLength()>D||y<k||A<y)&&i.style("display","none")}),o.showValues!==!1&&X.append("text").attr("class","treemapValue").attr("x",i=>(i.x1-i.x0)/2).attr("y",function(i){return(i.y1-i.y0)/2}).attr("style",i=>{const f="text-anchor: middle; dominant-baseline: hanging; font-size: 28px;fill:"+N(i.data.name)+";",C=P({cssCompiledStyles:i.data.cssCompiledStyles});return f+C.labelStyles.replace("color:","fill:")}).attr("clip-path",(i,f)=>`url(#clip-${a}-${f})`).text(i=>i.value?p(i.value):"").each(function(i){const f=Y(this),C=this.parentNode;if(!C){f.style("display","none");return}const L=Y(C).select(".treemapLabel");if(L.empty()||L.style("display")==="none"){f.style("display","none");return}const $=parseFloat(L.style("font-size")),D=28,A=.6,y=6,k=2,F=Math.max(y,Math.min(D,Math.round($*A)));f.style("font-size",`${F}px`);const _=(i.y1-i.y0)/2+$/2+k;f.attr("y",_);const W=i.x1-i.x0,oe=i.y1-i.y0-4,ce=W-8;f.node().getComputedTextLength()>ce||_+F>oe||F<y?f.style("display","none"):f.style("display",null)});const ie=o.diagramPadding??8;we(b,ie,"flowchart",o?.useMaxWidth||!1)},"draw"),nt=w(function(e,a){return a.db.getClasses()},"getClasses"),lt={draw:at,getClasses:nt},rt={sectionStrokeColor:"black",sectionStrokeWidth:"1",sectionFillColor:"#efefef",leafStrokeColor:"black",leafStrokeWidth:"1",leafFillColor:"#efefef",labelFontSize:"12px",valueFontSize:"10px",titleFontSize:"14px"},st=w(({treemap:e}={})=>{const a=de(),n=Q(),l=K(a,n.themeVariables),r=K(rt,e),o=r.titleColor??l.titleColor,d=r.labelColor??l.textColor,h=r.valueColor??l.textColor;return`
- .treemapNode.section {
- stroke: ${r.sectionStrokeColor};
- stroke-width: ${r.sectionStrokeWidth};
- fill: ${r.sectionFillColor};
- }
- .treemapNode.leaf {
- stroke: ${r.leafStrokeColor};
- stroke-width: ${r.leafStrokeWidth};
- fill: ${r.leafFillColor};
- }
- .treemapLabel {
- fill: ${d};
- font-size: ${r.labelFontSize};
- }
- .treemapValue {
- fill: ${h};
- font-size: ${r.valueFontSize};
- }
- .treemapTitle {
- fill: ${o};
- font-size: ${r.titleFontSize};
- }
- `},"getStyles"),it=st,mt={parser:le,get db(){return new ae},renderer:lt,styles:it};export{mt as diagram};
|