import{Q as y,T as M,aG as j,_ as d,g as q,s as H,a as K,b as Q,t as Y,q as Z,l as _,c as J,F as X,K as ee,a4 as te,e as ae,z as re,H as ne}from"./mermaid.core-CVhassan.js";import{p as ie}from"./chunk-4BX2VUAB-CujZm1R1.js";import{p as se}from"./treemap-KMMF4GRG-8-j8RoA6.js";import{d as L}from"./arc-_ALcW-nh.js";import{o as oe}from"./ordinal-DseSlIYb.js";import"./preload-helper-DqNgO5-4.js";import"./misc-DRDyxdMg.js";import"./jsx-runtime-C4_65a1U.js";import"./index-B9zr-vzA.js";import"./chunk-JZWAC4HX-5kJHQiQ9.js";import"./_baseUniq-DdZcSuTs.js";import"./_basePickBy-CQpyTSb0.js";import"./clone-z8f4YUjj.js";import"./init-DUB596OH.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:"8a6db0ac5fe78363b0c97fe458a96ce773bf357c"};var a=new e.Error().stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="3fa61b98-0ca3-4713-b9c2-9898d40ae85f",e._sentryDebugIdIdentifier="sentry-dbid-3fa61b98-0ca3-4713-b9c2-9898d40ae85f")}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,g=null,S=y(0),s=y(M),l=y(0);function o(t){var n,c=(t=j(t)).length,p,w,h=0,u=new Array(c),i=new Array(c),v=+S.apply(this,arguments),x=Math.min(M,Math.max(-M,s.apply(this,arguments)-v)),m,b=Math.min(Math.abs(x)/c,l.apply(this,arguments)),C=b*(x<0?-1:1),f;for(n=0;n<c;++n)(f=i[u[n]=n]=+e(t[n],n,t))>0&&(h+=f);for(a!=null?u.sort(function(A,D){return a(i[A],i[D])}):g!=null&&u.sort(function(A,D){return g(t[A],t[D])}),n=0,w=h?(x-c*C)/h:0;n<c;++n,v=m)p=u[n],f=i[p],m=v+(f>0?f*w:0)+C,i[p]={data:t[p],index:n,value:f,startAngle:v,endAngle:m,padAngle:b};return i}return o.value=function(t){return arguments.length?(e=typeof t=="function"?t:y(+t),o):e},o.sortValues=function(t){return arguments.length?(a=t,g=null,o):a},o.sort=function(t){return arguments.length?(g=t,a=null,o):g},o.startAngle=function(t){return arguments.length?(S=typeof t=="function"?t:y(+t),o):S},o.endAngle=function(t){return arguments.length?(s=typeof t=="function"?t:y(+t),o):s},o.padAngle=function(t){return arguments.length?(l=typeof t=="function"?t:y(+t),o):l},o}var de=ne.pie,z={sections:new Map,showData:!1},T=z.sections,F=z.showData,pe=structuredClone(de),fe=d(()=>structuredClone(pe),"getConfig"),ge=d(()=>{T=new Map,F=z.showData,re()},"clear"),me=d(({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.`);T.has(e)||(T.set(e,a),_.debug(`added new section: ${e}, with value: ${a}`))},"addSection"),he=d(()=>T,"getSections"),ve=d(e=>{F=e},"setShowData"),ye=d(()=>F,"getShowData"),O={getConfig:fe,clear:ge,setDiagramTitle:Z,getDiagramTitle:Y,setAccTitle:Q,getAccTitle:K,setAccDescription:H,getAccDescription:q,addSection:me,getSections:he,setShowData:ve,getShowData:ye},Se=d((e,a)=>{ie(e,a),a.setShowData(e.showData),e.sections.map(a.addSection)},"populateDb"),we={parse:d(async e=>{const a=await se("pie",e);_.debug(a),Se(a,O)},"parse")},xe=d(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=d(e=>{const a=[...e.values()].reduce((s,l)=>s+l,0),g=[...e.entries()].map(([s,l])=>({label:s,value:l})).filter(s=>s.value/a*100>=1).sort((s,l)=>l.value-s.value);return ue().value(s=>s.value)(g)},"createPieArcs"),be=d((e,a,g,S)=>{_.debug(`rendering pie chart
`+e);const s=S.db,l=J(),o=X(s.getConfig(),l.pie),t=40,n=18,c=4,p=450,w=p,h=ee(a),u=h.append("g");u.attr("transform","translate("+w/2+","+p/2+")");const{themeVariables:i}=l;let[v]=te(i.pieOuterStrokeWidth);v??=2;const x=o.textPosition,m=Math.min(w,p)/2-t,b=L().innerRadius(0).outerRadius(m),C=L().innerRadius(m*x).outerRadius(m*x);u.append("circle").attr("cx",0).attr("cy",0).attr("r",m+v/2).attr("class","pieOuterCircle");const f=s.getSections(),A=De(f),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 $=0;f.forEach(r=>{$+=r});const G=A.filter(r=>(r.data.value/$*100).toFixed(0)!=="0"),E=oe(D);u.selectAll("mySlices").data(G).enter().append("path").attr("d",b).attr("fill",r=>E(r.data.label)).attr("class","pieCircle"),u.selectAll("mySlices").data(G).enter().append("text").text(r=>(r.data.value/$*100).toFixed(0)+"%").attr("transform",r=>"translate("+C.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 N=[...f.entries()].map(([r,I])=>({label:r,value:I})),k=u.selectAll(".legend").data(N).enter().append("g").attr("class","legend").attr("transform",(r,I)=>{const W=n+c,B=W*N.length/2,V=12*n,U=I*W-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=>s.getShowData()?`${r.label} [${r.value}]`:r.label);const P=Math.max(...k.selectAll("text").nodes().map(r=>r?.getBoundingClientRect().width??0)),R=w+t+n+c+P;h.attr("viewBox",`0 0 ${R} ${p}`),ae(h,p,R,o.useMaxWidth)},"draw"),Ce={draw:be},Oe={parser:we,db:O,renderer:Ce,styles:Ae};export{Oe as diagram};
//# sourceMappingURL=pieDiagram-ADFJNKIX-P-85xAi1.js.map
