import{Q as y,T as z,aG as j,_ as p,g as q,s as H,a as K,b as Q,t as Y,q as Z,l as F,c as J,F as X,K as ee,a4 as te,e as ae,z as re,H as ne}from"./mermaid.core-CQtGV0ai.js";import{p as ie}from"./chunk-4BX2VUAB-fcMy1X-p.js";import{p as oe}from"./treemap-KMMF4GRG-BqnMeY6Y.js";import{d as P}from"./arc-B9Vs-U0C.js";import{o as se}from"./ordinal-Cjm0Ee1q.js";import"./preload-helper-DECEsjER.js";import"./misc-BOyXKFuR.js";import"./jsx-runtime-C_974cfT.js";import"./index-BDZD4X5K.js";import"./chunk-UIGDSWPH-fNK8sKgt.js";import"./_baseUniq-DRi1ndAK.js";import"./_basePickBy-d8-8M4h-.js";import"./clone-BjnxyxVD.js";import"./init-DOWc6eJH.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"3ea6c863933c57219be78eb06addfb47859d8df2"}}catch{}})();function le(e,a){return a<e?-1:a>e?1:a>=e?0:NaN}function ce(e){return e}function ue(){var e=ce,a=le,f=null,S=y(0),o=y(z),l=y(0);function s(t){var n,c=(t=j(t)).length,d,w,h=0,u=new Array(c),i=new Array(c),v=+S.apply(this,arguments),x=Math.min(z,Math.max(-z,o.apply(this,arguments)-v)),m,C=Math.min(Math.abs(x)/c,l.apply(this,arguments)),T=C*(x<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,w=h?(x-c*T)/h:0;n<c;++n,v=m)d=u[n],g=i[d],m=v+(g>0?g*w:0)+T,i[d]={data:t[d],index:n,value:g,startAngle:v,endAngle:m,padAngle:C};return i}return s.value=function(t){return arguments.length?(e=typeof t=="function"?t:y(+t),s):e},s.sortValues=function(t){return arguments.length?(a=t,f=null,s):a},s.sort=function(t){return arguments.length?(f=t,a=null,s):f},s.startAngle=function(t){return arguments.length?(S=typeof t=="function"?t:y(+t),s):S},s.endAngle=function(t){return arguments.length?(o=typeof t=="function"?t:y(+t),s):o},s.padAngle=function(t){return arguments.length?(l=typeof t=="function"?t:y(+t),s):l},s}var pe=ne.pie,G={sections:new Map,showData:!1},$=G.sections,N=G.showData,de=structuredClone(pe),ge=p(()=>structuredClone(de),"getConfig"),fe=p(()=>{$=new Map,N=G.showData,re()},"clear"),me=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.`);$.has(e)||($.set(e,a),F.debug(`added new section: ${e}, with value: ${a}`))},"addSection"),he=p(()=>$,"getSections"),ve=p(e=>{N=e},"setShowData"),ye=p(()=>N,"getShowData"),_={getConfig:ge,clear:fe,setDiagramTitle:Z,getDiagramTitle:Y,setAccTitle:Q,getAccTitle:K,setAccDescription:H,getAccDescription:q,addSection:me,getSections:he,setShowData:ve,getShowData:ye},Se=p((e,a)=>{ie(e,a),a.setShowData(e.showData),e.sections.map(a.addSection)},"populateDb"),we={parse:p(async e=>{const a=await oe("pie",e);F.debug(a),Se(a,_)},"parse")},xe=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"),Ae=xe,De=p(e=>{const a=[...e.values()].reduce((o,l)=>o+l,0),f=[...e.entries()].map(([o,l])=>({label:o,value:l})).filter(o=>o.value/a*100>=1).sort((o,l)=>l.value-o.value);return ue().value(o=>o.value)(f)},"createPieArcs"),Ce=p((e,a,f,S)=>{F.debug(`rendering pie chart
`+e);const o=S.db,l=J(),s=X(o.getConfig(),l.pie),t=40,n=18,c=4,d=450,w=d,h=ee(a),u=h.append("g");u.attr("transform","translate("+w/2+","+d/2+")");const{themeVariables:i}=l;let[v]=te(i.pieOuterStrokeWidth);v??=2;const x=s.textPosition,m=Math.min(w,d)/2-t,C=P().innerRadius(0).outerRadius(m),T=P().innerRadius(m*x).outerRadius(m*x);u.append("circle").attr("cx",0).attr("cy",0).attr("r",m+v/2).attr("class","pieOuterCircle");const g=o.getSections(),A=De(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 b=0;g.forEach(r=>{b+=r});const R=A.filter(r=>(r.data.value/b*100).toFixed(0)!=="0"),E=se(D);u.selectAll("mySlices").data(R).enter().append("path").attr("d",C).attr("fill",r=>E(r.data.label)).attr("class","pieCircle"),u.selectAll("mySlices").data(R).enter().append("text").text(r=>(r.data.value/b*100).toFixed(0)+"%").attr("transform",r=>"translate("+T.centroid(r)+")").style("text-anchor","middle").attr("class","slice"),u.append("text").text(o.getDiagramTitle()).attr("x",0).attr("y",-400/2).attr("class","pieTitleText");const W=[...g.entries()].map(([r,M])=>({label:r,value:M})),k=u.selectAll(".legend").data(W).enter().append("g").attr("class","legend").attr("transform",(r,M)=>{const O=n+c,B=O*W.length/2,V=12*n,U=M*O-B;return"translate("+V+","+U+")"});k.append("rect").attr("width",n).attr("height",n).style("fill",r=>E(r.label)).style("stroke",r=>E(r.label)),k.append("text").attr("x",n+c).attr("y",n-c).text(r=>o.getShowData()?`${r.label} [${r.value}]`:r.label);const I=Math.max(...k.selectAll("text").nodes().map(r=>r?.getBoundingClientRect().width??0)),L=w+t+n+c+I;h.attr("viewBox",`0 0 ${L} ${d}`),ae(h,d,L,s.useMaxWidth)},"draw"),Te={draw:Ce},_e={parser:we,db:_,renderer:Te,styles:Ae};export{_e as diagram};
//# sourceMappingURL=pieDiagram-ADFJNKIX-DM311w1H.js.map
