const e=require("./custom-Bl_fVJZ0.cjs"),t=require("./src-BMjps4Ui.cjs"),n=require("./chunk-ABZYJK2D-CbIYYZa_.cjs"),r=require("./ordinal-CUPR-p0T.cjs"),i=require("./path-Kklx0M1v.cjs"),a=require("./math-G8rF7UWn.cjs"),o=require("./arc-C78br9Yj.cjs"),s=require("./array-DZSRzHA_.cjs"),c=require("./chunk-S3R3BYOJ-B2ozcJNg.cjs"),l=require("./mermaid-parser.core-C9EbhVVg.cjs"),u=require("./chunk-4BX2VUAB-HXFjpyQg.cjs");function d(e,t){return t<e?-1:t>e?1:t>=e?0:NaN}function f(e){return e}function p(){var e=f,t=d,n=null,r=i.n(0),o=i.n(a.p),c=i.n(0);function l(i){var l,u=(i=s.t(i)).length,d,f,p=0,m=Array(u),h=Array(u),g=+r.apply(this,arguments),_=Math.min(a.p,Math.max(-a.p,o.apply(this,arguments)-g)),v,y=Math.min(Math.abs(_)/u,c.apply(this,arguments)),b=y*(_<0?-1:1),x;for(l=0;l<u;++l)(x=h[m[l]=l]=+e(i[l],l,i))>0&&(p+=x);for(t==null?n!=null&&m.sort(function(e,t){return n(i[e],i[t])}):m.sort(function(e,n){return t(h[e],h[n])}),l=0,f=p?(_-u*b)/p:0;l<u;++l,g=v)d=m[l],x=h[d],v=g+(x>0?x*f:0)+b,h[d]={data:i[d],index:l,value:x,startAngle:g,endAngle:v,padAngle:y};return h}return l.value=function(t){return arguments.length?(e=typeof t==`function`?t:i.n(+t),l):e},l.sortValues=function(e){return arguments.length?(t=e,n=null,l):t},l.sort=function(e){return arguments.length?(n=e,t=null,l):n},l.startAngle=function(e){return arguments.length?(r=typeof e==`function`?e:i.n(+e),l):r},l.endAngle=function(e){return arguments.length?(o=typeof e==`function`?e:i.n(+e),l):o},l.padAngle=function(e){return arguments.length?(c=typeof e==`function`?e:i.n(+e),l):c},l}var m=n.d.pie,h={sections:new Map,showData:!1,config:m},g=h.sections,_=h.showData,v=structuredClone(m),y={getConfig:t.h(()=>structuredClone(v),`getConfig`),clear:t.h(()=>{g=new Map,_=h.showData,n.a()},`clear`),setDiagramTitle:n.U,getDiagramTitle:n.C,setAccTitle:n.B,getAccTitle:n.v,setAccDescription:n.z,getAccDescription:n._,addSection:t.h(({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.`);g.has(e)||(g.set(e,n),t.g.debug(`added new section: ${e}, with value: ${n}`))},`addSection`),getSections:t.h(()=>g,`getSections`),setShowData:t.h(e=>{_=e},`setShowData`),getShowData:t.h(()=>_,`getShowData`)},b=t.h((e,t)=>{u.t(e,t),t.setShowData(e.showData),e.sections.map(t.addSection)},`populateDb`),x={parse:t.h(async e=>{let n=await l.t(`pie`,e);t.g.debug(n),b(n,y)},`parse`)},S=t.h(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`),C=t.h(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).sort((e,t)=>t.value-e.value);return p().value(e=>e.value)(n)},`createPieArcs`),w={parser:x,db:y,renderer:{draw:t.h((i,a,s,l)=>{t.g.debug(`rendering pie chart
`+i);let u=l.db,d=n.b(),f=c.r(u.getConfig(),d.pie),p=e.f(a),m=p.append(`g`);m.attr(`transform`,`translate(225,225)`);let{themeVariables:h}=d,[g]=c.f(h.pieOuterStrokeWidth);g??=2;let _=f.textPosition,v=o.t().innerRadius(0).outerRadius(185),y=o.t().innerRadius(185*_).outerRadius(185*_);m.append(`circle`).attr(`cx`,0).attr(`cy`,0).attr(`r`,185+g/2).attr(`class`,`pieOuterCircle`);let b=u.getSections(),x=C(b),S=[h.pie1,h.pie2,h.pie3,h.pie4,h.pie5,h.pie6,h.pie7,h.pie8,h.pie9,h.pie10,h.pie11,h.pie12],w=0;b.forEach(e=>{w+=e});let T=x.filter(e=>(e.data.value/w*100).toFixed(0)!==`0`),E=r.t(S);m.selectAll(`mySlices`).data(T).enter().append(`path`).attr(`d`,v).attr(`fill`,e=>E(e.data.label)).attr(`class`,`pieCircle`),m.selectAll(`mySlices`).data(T).enter().append(`text`).text(e=>(e.data.value/w*100).toFixed(0)+`%`).attr(`transform`,e=>`translate(`+y.centroid(e)+`)`).style(`text-anchor`,`middle`).attr(`class`,`slice`),m.append(`text`).text(u.getDiagramTitle()).attr(`x`,0).attr(`y`,-400/2).attr(`class`,`pieTitleText`);let D=[...b.entries()].map(([e,t])=>({label:e,value:t})),O=m.selectAll(`.legend`).data(D).enter().append(`g`).attr(`class`,`legend`).attr(`transform`,(e,t)=>{let n=22*D.length/2;return`translate(216,`+(t*22-n)+`)`});O.append(`rect`).attr(`width`,18).attr(`height`,18).style(`fill`,e=>E(e.label)).style(`stroke`,e=>E(e.label)),O.append(`text`).attr(`x`,22).attr(`y`,14).text(e=>u.getShowData()?`${e.label} [${e.value}]`:e.label);let k=512+Math.max(...O.selectAll(`text`).nodes().map(e=>e?.getBoundingClientRect().width??0));p.attr(`viewBox`,`0 0 ${k} 450`),n.c(p,450,k,f.useMaxWidth)},`draw`)},styles:S};exports.diagram=w;