var q=Object.defineProperty;var C=(e,a)=>q(e,"name",{value:a,configurable:!0});import{Q as S,T as F,aG as H,_ as p,g as K,s as Q,a as Z,b as J,t as X,q as Y,l as G,c as ee,F as te,K as ae,a4 as re,e as ne,z as ie,H as se}from"./mermaid.core-Eyq-ET19.js";import{p as oe}from"./chunk-4BX2VUAB-q5lIvvr0.js";import{p as le}from"./treemap-KMMF4GRG-DW2a9A9h.js";import{d as L}from"./arc-Bj6bkS5k.js";import{o as ce}from"./ordinal-BCXkz34N.js";import"./main-CUGOPQDL.js";import"./main-D2Md95jo.js";import"./react-vendor-BGrcQn-n.js";import"./ui-vendor-B7JxFfFk.js";import"./_baseUniq-Dyc3X_MP.js";import"./_basePickBy-BNTvgNGW.js";import"./clone-Byt2uRCA.js";import"./init-GRbUuopv.js";function ue(e,a){return a<e?-1:a>e?1:a>=e?0:NaN}C(ue,"descending");function pe(e){return e}C(pe,"identity");function de(){var e=pe,a=ue,f=null,x=S(0),s=S(F),l=S(0);function o(t){var n,c=(t=H(t)).length,d,y,h=0,u=new Array(c),i=new Array(c),v=+x.apply(this,arguments),w=Math.min(F,Math.max(-F,s.apply(this,arguments)-v)),m,$=Math.min(Math.abs(w)/c,l.apply(this,arguments)),T=$*(w<0?-1:1),g;for(n=0;n<c;++n)(g=i[u[n]=n]=+e(t[n],n,t))>0&&(h+=g);for(a!=null?u.sort(function(A,D){return a(i[A],i[D])}):f!=null&&u.sort(function(A,D){return f(t[A],t[D])}),n=0,y=h?(w-c*T)/h:0;n<c;++n,v=m)d=u[n],g=i[d],m=v+(g>0?g*y:0)+T,i[d]={data:t[d],index:n,value:g,startAngle:v,endAngle:m,padAngle:$};return i}return C(o,"pie"),o.value=function(t){return arguments.length?(e=typeof t=="function"?t:S(+t),o):e},o.sortValues=function(t){return arguments.length?(a=t,f=null,o):a},o.sort=function(t){return arguments.length?(f=t,a=null,o):f},o.startAngle=function(t){return arguments.length?(x=typeof t=="function"?t:S(+t),o):x},o.endAngle=function(t){return arguments.length?(s=typeof t=="function"?t:S(+t),o):s},o.padAngle=function(t){return arguments.length?(l=typeof t=="function"?t:S(+t),o):l},o}C(de,"d3pie");var ge=se.pie,N={sections:new Map,showData:!1},b=N.sections,W=N.showData,fe=structuredClone(ge),me=p(()=>structuredClone(fe),"getConfig"),he=p(()=>{b=new Map,W=N.showData,ie()},"clear"),ve=p(({label:e,value:a})=>{if(a<0)throw new Error(`"${e}" has invalid value: ${a}. Negative values are not allowed in pie charts. All slice values must be >= 0.`);b.has(e)||(b.set(e,a),G.debug(`added new section: ${e}, with value: ${a}`))},"addSection"),Se=p(()=>b,"getSections"),xe=p(e=>{W=e},"setShowData"),ye=p(()=>W,"getShowData"),_={getConfig:me,clear:he,setDiagramTitle:Y,getDiagramTitle:X,setAccTitle:J,getAccTitle:Z,setAccDescription:Q,getAccDescription:K,addSection:ve,getSections:Se,setShowData:xe,getShowData:ye},we=p((e,a)=>{oe(e,a),a.setShowData(e.showData),e.sections.map(a.addSection)},"populateDb"),Ae={parse:p(async e=>{const a=await le("pie",e);G.debug(a),we(a,_)},"parse")},De=p(e=>`
  .pieCircle{
    stroke: ${e.pieStrokeColor};
    stroke-width : ${e.pieStrokeWidth};
    opacity : ${e.pieOpacity};
  }
  .pieOuterCircle{
    stroke: ${e.pieOuterStrokeColor};
    stroke-width: ${e.pieOuterStrokeWidth};
    fill: none;
  }
  .pieTitleText {
    text-anchor: middle;
    font-size: ${e.pieTitleTextSize};
    fill: ${e.pieTitleTextColor};
    font-family: ${e.fontFamily};
  }
  .slice {
    font-family: ${e.fontFamily};
    fill: ${e.pieSectionTextColor};
    font-size:${e.pieSectionTextSize};
    // fill: white;
  }
  .legend text {
    fill: ${e.pieLegendTextColor};
    font-family: ${e.fontFamily};
    font-size: ${e.pieLegendTextSize};
  }
`,"getStyles"),Ce=De,$e=p(e=>{const a=[...e.values()].reduce((s,l)=>s+l,0),f=[...e.entries()].map(([s,l])=>({label:s,value:l})).filter(s=>s.value/a*100>=1).sort((s,l)=>l.value-s.value);return de().value(s=>s.value)(f)},"createPieArcs"),Te=p((e,a,f,x)=>{G.debug(`rendering pie chart
`+e);const s=x.db,l=ee(),o=te(s.getConfig(),l.pie),t=40,n=18,c=4,d=450,y=d,h=ae(a),u=h.append("g");u.attr("transform","translate("+y/2+","+d/2+")");const{themeVariables:i}=l;let[v]=re(i.pieOuterStrokeWidth);v??=2;const w=o.textPosition,m=Math.min(y,d)/2-t,$=L().innerRadius(0).outerRadius(m),T=L().innerRadius(m*w).outerRadius(m*w);u.append("circle").attr("cx",0).attr("cy",0).attr("r",m+v/2).attr("class","pieOuterCircle");const g=s.getSections(),A=$e(g),D=[i.pie1,i.pie2,i.pie3,i.pie4,i.pie5,i.pie6,i.pie7,i.pie8,i.pie9,i.pie10,i.pie11,i.pie12];let E=0;g.forEach(r=>{E+=r});const O=A.filter(r=>(r.data.value/E*100).toFixed(0)!=="0"),k=ce(D);u.selectAll("mySlices").data(O).enter().append("path").attr("d",$).attr("fill",r=>k(r.data.label)).attr("class","pieCircle"),u.selectAll("mySlices").data(O).enter().append("text").text(r=>(r.data.value/E*100).toFixed(0)+"%").attr("transform",r=>"translate("+T.centroid(r)+")").style("text-anchor","middle").attr("class","slice"),u.append("text").text(s.getDiagramTitle()).attr("x",0).attr("y",-400/2).attr("class","pieTitleText");const P=[...g.entries()].map(([r,z])=>({label:r,value:z})),M=u.selectAll(".legend").data(P).enter().append("g").attr("class","legend").attr("transform",(r,z)=>{const I=n+c,V=I*P.length/2,U=12*n,j=z*I-V;return"translate("+U+","+j+")"});M.append("rect").attr("width",n).attr("height",n).style("fill",r=>k(r.label)).style("stroke",r=>k(r.label)),M.append("text").attr("x",n+c).attr("y",n-c).text(r=>s.getShowData()?`${r.label} [${r.value}]`:r.label);const B=Math.max(...M.selectAll("text").nodes().map(r=>r?.getBoundingClientRect().width??0)),R=y+t+n+c+B;h.attr("viewBox",`0 0 ${R} ${d}`),ne(h,d,R,o.useMaxWidth)},"draw"),be={draw:Te},Be={parser:Ae,db:_,renderer:be,styles:Ce};export{Be as diagram};
//# sourceMappingURL=pieDiagram-ADFJNKIX-DKa1wk17.js.map
