import{i as e,u as t}from"./src-DU38EUZK-DV_JaBXd.js";import{D as n,J as r,Q as i,S as a,Y as o,c as s,d as c,h as l,w as u,x as d}from"./chunk-ICPOFSXX-Bzl23lJq-DIqk8fiF.js";import{p as f}from"./dist-CuNsB3ua-DS1N7huq.js";import{L as p,d as m}from"./chunk-5PVQY5BW-ZS1bFUpH-DRVOTwoJ.js";import{t as h}from"./chunk-426QAEUC-CqnkfUrs-TDEr_sXx.js";import{t as g}from"./chunk-4BX2VUAB-C65ncpNL-Jlf3rRAU.js";import{t as _}from"./mermaid-parser.core-BOjEsmRy-CxF0g9Iw.js";import{t as v}from"./path-D51p9iUn-CuGVSWlg.js";import{t as y}from"./array-CCeX_eWS-chaTJ1-P.js";import{t as b}from"./ordinal-BbVX1NG1-CMT42kcg.js";import{t as x}from"./arc-B5GoS-AY-Dt3EY4yI.js";function S(e,t){return t<e?-1:t>e?1:t>=e?0:NaN}function C(e){return e}function w(){var e=C,t=S,n=null,r=v(0),i=v(f),a=v(0);function o(o){var s,c=(o=y(o)).length,l,u,d=0,p=Array(c),m=Array(c),h=+r.apply(this,arguments),g=Math.min(f,Math.max(-f,i.apply(this,arguments)-h)),_,v=Math.min(Math.abs(g)/c,a.apply(this,arguments)),b=v*(g<0?-1:1),x;for(s=0;s<c;++s)(x=m[p[s]=s]=+e(o[s],s,o))>0&&(d+=x);for(t==null?n!=null&&p.sort(function(e,t){return n(o[e],o[t])}):p.sort(function(e,n){return t(m[e],m[n])}),s=0,u=d?(g-c*b)/d:0;s<c;++s,h=_)l=p[s],x=m[l],_=h+(x>0?x*u:0)+b,m[l]={data:o[l],index:s,value:x,startAngle:h,endAngle:_,padAngle:v};return m}return o.value=function(t){return arguments.length?(e=typeof t==`function`?t:v(+t),o):e},o.sortValues=function(e){return arguments.length?(t=e,n=null,o):t},o.sort=function(e){return arguments.length?(n=e,t=null,o):n},o.startAngle=function(e){return arguments.length?(r=typeof e==`function`?e:v(+e),o):r},o.endAngle=function(e){return arguments.length?(i=typeof e==`function`?e:v(+e),o):i},o.padAngle=function(e){return arguments.length?(a=typeof e==`function`?e:v(+e),o):a},o}var T=l.pie,E={sections:new Map,showData:!1,config:T},D=E.sections,O=E.showData,k=structuredClone(T),A={getConfig:e(()=>structuredClone(k),`getConfig`),clear:e(()=>{D=new Map,O=E.showData,s()},`clear`),setDiagramTitle:i,getDiagramTitle:n,setAccTitle:o,getAccTitle:a,setAccDescription:r,getAccDescription:d,addSection:e(({label:e,value:n})=>{if(n<0)throw Error(`"${e}" has invalid value: ${n}. Negative values are not allowed in pie charts. All slice values must be >= 0.`);D.has(e)||(D.set(e,n),t.debug(`added new section: ${e}, with value: ${n}`))},`addSection`),getSections:e(()=>D,`getSections`),setShowData:e(e=>{O=e},`setShowData`),getShowData:e(()=>O,`getShowData`)},j=e((e,t)=>{g(e,t),t.setShowData(e.showData),e.sections.map(t.addSection)},`populateDb`),M={parse:e(async e=>{let n=await _(`pie`,e);t.debug(n),j(n,A)},`parse`)},N=e(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`),P=e(e=>{let t=[...e.values()].reduce((e,t)=>e+t,0),n=[...e.entries()].map(([e,t])=>({label:e,value:t})).filter(e=>e.value/t*100>=1);return w().value(e=>e.value).sort(null)(n)},`createPieArcs`),F={parser:M,db:A,renderer:{draw:e((e,n,r,i)=>{t.debug(`rendering pie chart
`+e);let a=i.db,o=u(),s=m(a.getConfig(),o.pie),l=h(n),d=l.append(`g`);d.attr(`transform`,`translate(225,225)`);let{themeVariables:f}=o,[g]=p(f.pieOuterStrokeWidth);g??=2;let _=s.textPosition,v=x().innerRadius(0).outerRadius(185),y=x().innerRadius(185*_).outerRadius(185*_);d.append(`circle`).attr(`cx`,0).attr(`cy`,0).attr(`r`,185+g/2).attr(`class`,`pieOuterCircle`);let S=a.getSections(),C=P(S),w=[f.pie1,f.pie2,f.pie3,f.pie4,f.pie5,f.pie6,f.pie7,f.pie8,f.pie9,f.pie10,f.pie11,f.pie12],T=0;S.forEach(e=>{T+=e});let E=C.filter(e=>(e.data.value/T*100).toFixed(0)!==`0`),D=b(w).domain([...S.keys()]);d.selectAll(`mySlices`).data(E).enter().append(`path`).attr(`d`,v).attr(`fill`,e=>D(e.data.label)).attr(`class`,`pieCircle`),d.selectAll(`mySlices`).data(E).enter().append(`text`).text(e=>(e.data.value/T*100).toFixed(0)+`%`).attr(`transform`,e=>`translate(`+y.centroid(e)+`)`).style(`text-anchor`,`middle`).attr(`class`,`slice`);let O=d.append(`text`).text(a.getDiagramTitle()).attr(`x`,0).attr(`y`,-400/2).attr(`class`,`pieTitleText`),k=[...S.entries()].map(([e,t])=>({label:e,value:t})),A=d.selectAll(`.legend`).data(k).enter().append(`g`).attr(`class`,`legend`).attr(`transform`,(e,t)=>{let n=22*k.length/2;return`translate(216,`+(t*22-n)+`)`});A.append(`rect`).attr(`width`,18).attr(`height`,18).style(`fill`,e=>D(e.label)).style(`stroke`,e=>D(e.label)),A.append(`text`).attr(`x`,22).attr(`y`,14).text(e=>a.getShowData()?`${e.label} [${e.value}]`:e.label);let j=512+Math.max(...A.selectAll(`text`).nodes().map(e=>e?.getBoundingClientRect().width??0)),M=O.node()?.getBoundingClientRect().width??0,N=450/2-M/2,F=450/2+M/2,I=Math.min(0,N),L=Math.max(j,F)-I;l.attr(`viewBox`,`${I} 0 ${L} 450`),c(l,450,L,s.useMaxWidth)},`draw`)},styles:N};export{F as diagram};
//# sourceMappingURL=pieDiagram-DEJITSTG-B8xqo_v1-DQyNR2b-.js.map