import{a as X}from"./chunk-IVXEP2GX.js";import{a as Y}from"./chunk-5VULEZUR.js";import"./chunk-I7AX7T7O.js";import"./chunk-XK4G7G7T.js";import"./chunk-VEXGBG23.js";import"./chunk-3UY5EKAG.js";import"./chunk-VWRMTJIG.js";import"./chunk-UKDM673Y.js";import{a as H}from"./chunk-E44FJ4V5.js";import{k as J,l as K}from"./chunk-EC3EU6U5.js";import"./chunk-T62BAALO.js";import{L as E,P as U,Q as I,R as N,S as Q,T as V,U as j,V as q,W as G,p as B}from"./chunk-JB23YLA3.js";import{F as $,I as L,b as m,m as P}from"./chunk-TUEROSNP.js";import"./chunk-PLDLE5YP.js";import"./chunk-YFOJOJKZ.js";import"./chunk-EIBZ4D3G.js";import"./chunk-N4TPONBE.js";import"./chunk-WCWYUUX6.js";import{g as W,h as r}from"./chunk-7DHJDT2N.js";var Z=B.pie,y={sections:new Map,showData:!1,config:Z},u=y.sections,T=y.showData,pe=structuredClone(Z),ne=r(()=>structuredClone(pe),"getConfig"),de=r(()=>{u=new Map,T=y.showData,U()},"clear"),ce=r(({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.`);u.has(e)||(u.set(e,a),m.debug(`added new section: ${e}, with value: ${a}`))},"addSection"),me=r(()=>u,"getSections"),ue=r(e=>{T=e},"setShowData"),ge=r(()=>T,"getShowData"),_={getConfig:ne,clear:de,setDiagramTitle:j,getDiagramTitle:q,setAccTitle:I,getAccTitle:N,setAccDescription:Q,getAccDescription:V,addSection:ce,getSections:me,setShowData:ue,getShowData:ge},fe=r((e,a)=>{X(e,a),a.setShowData(e.showData),e.sections.map(a.addSection)},"populateDb"),he={parse:r(e=>W(null,null,function*(){let a=yield Y("pie",e);m.debug(a),fe(a,_)}),"parse")},xe=r(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"),Se=xe,we=r(e=>{let a=[...e.values()].reduce((l,o)=>l+o,0),b=[...e.entries()].map(([l,o])=>({label:l,value:o})).filter(l=>l.value/a*100>=1).sort((l,o)=>o.value-l.value);return L().value(l=>l.value)(b)},"createPieArcs"),ve=r((e,a,b,l)=>{m.debug(`rendering pie chart
`+e);let o=l.db,D=G(),C=K(o.getConfig(),D.pie),k=40,s=18,d=4,p=450,g=p,f=H(a),n=f.append("g");n.attr("transform","translate("+g/2+","+p/2+")");let{themeVariables:i}=D,[A]=J(i.pieOuterStrokeWidth);A??=2;let O=C.textPosition,c=Math.min(g,p)/2-k,ee=$().innerRadius(0).outerRadius(c),te=$().innerRadius(c*O).outerRadius(c*O);n.append("circle").attr("cx",0).attr("cy",0).attr("r",c+A/2).attr("class","pieOuterCircle");let h=o.getSections(),ae=we(h),ie=[i.pie1,i.pie2,i.pie3,i.pie4,i.pie5,i.pie6,i.pie7,i.pie8,i.pie9,i.pie10,i.pie11,i.pie12],x=0;h.forEach(t=>{x+=t});let z=ae.filter(t=>(t.data.value/x*100).toFixed(0)!=="0"),S=P(ie);n.selectAll("mySlices").data(z).enter().append("path").attr("d",ee).attr("fill",t=>S(t.data.label)).attr("class","pieCircle"),n.selectAll("mySlices").data(z).enter().append("text").text(t=>(t.data.value/x*100).toFixed(0)+"%").attr("transform",t=>"translate("+te.centroid(t)+")").style("text-anchor","middle").attr("class","slice"),n.append("text").text(o.getDiagramTitle()).attr("x",0).attr("y",-(p-50)/2).attr("class","pieTitleText");let F=[...h.entries()].map(([t,v])=>({label:t,value:v})),w=n.selectAll(".legend").data(F).enter().append("g").attr("class","legend").attr("transform",(t,v)=>{let M=s+d,le=M*F.length/2,oe=12*s,se=v*M-le;return"translate("+oe+","+se+")"});w.append("rect").attr("width",s).attr("height",s).style("fill",t=>S(t.label)).style("stroke",t=>S(t.label)),w.append("text").attr("x",s+d).attr("y",s-d).text(t=>o.getShowData()?`${t.label} [${t.value}]`:t.label);let re=Math.max(...w.selectAll("text").nodes().map(t=>t?.getBoundingClientRect().width??0)),R=g+k+s+d+re;f.attr("viewBox",`0 0 ${R} ${p}`),E(f,p,R,C.useMaxWidth)},"draw"),$e={draw:ve},Ne={parser:he,db:_,renderer:$e,styles:Se};export{Ne as diagram};
