"use strict";(self.webpackChunkforgejo=self.webpackChunkforgejo||[]).push([["node_modules_mermaid_dist_chunks_mermaid_core_pieDiagram-4H26LBE5_mjs"],{"./node_modules/mermaid/dist/chunks/mermaid.core/pieDiagram-4H26LBE5.mjs":(function(fe,U,o){o.d(U,{diagram:function(){return re}});var G=o("./node_modules/mermaid/dist/chunks/mermaid.core/chunk-WU5MYG2G.mjs"),b=o("./node_modules/mermaid/dist/chunks/mermaid.core/chunk-4BX2VUAB.mjs"),A=o("./node_modules/mermaid/dist/chunks/mermaid.core/chunk-5ZQYHXKU.mjs"),n=o("./node_modules/mermaid/dist/chunks/mermaid.core/chunk-CSCIHK7Q.mjs"),i=o("./node_modules/mermaid/dist/chunks/mermaid.core/chunk-AGHRB4JF.mjs"),F=o("./node_modules/@mermaid-js/parser/dist/mermaid-parser.core.mjs"),h=o("./node_modules/d3/src/index.js"),T=n.UI.pie,v={sections:new Map,showData:!1,config:T},_=v.sections,D=v.showData,H=structuredClone(T),z=(0,i.K2)(()=>structuredClone(H),"getConfig"),N=(0,i.K2)(()=>{_=new Map,D=v.showData,(0,n.IU)()},"clear"),X=(0,i.K2)(({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),i.Rm.debug(`added new section: ${e}, with value: ${a}`))},"addSection"),J=(0,i.K2)(()=>_,"getSections"),Q=(0,i.K2)(e=>{D=e},"setShowData"),V=(0,i.K2)(()=>D,"getShowData"),w={getConfig:z,clear:N,setDiagramTitle:n.ke,getDiagramTitle:n.ab,setAccTitle:n.SV,getAccTitle:n.iN,setAccDescription:n.EI,getAccDescription:n.m7,addSection:X,getSections:J,setShowData:Q,getShowData:V},Y=(0,i.K2)((e,a)=>{(0,b.S)(e,a),a.setShowData(e.showData),e.sections.map(a.addSection)},"populateDb"),Z={parse:(0,i.K2)(async e=>{const a=await(0,F.qg)("pie",e);i.Rm.debug(a),Y(a,w)},"parse")},q=(0,i.K2)(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"),ee=q,te=(0,i.K2)(e=>{const a=[...e.values()].reduce((s,l)=>s+l,0),M=[...e.entries()].map(([s,l])=>({label:s,value:l})).filter(s=>s.value/a*100>=1);return(0,h.rLf)().value(s=>s.value).sort(null)(M)},"createPieArcs"),ae=(0,i.K2)((e,a,M,$)=>{i.Rm.debug(`rendering pie chart
`+e);const s=$.db,l=(0,n.D7)(),y=(0,A.$t)(s.getConfig(),l.pie),R=40,c=18,p=4,d=450,u=d,C=(0,G.D)(a),m=C.append("g");m.attr("transform","translate("+u/2+","+d/2+")");const{themeVariables:r}=l;let[B]=(0,A.I5)(r.pieOuterStrokeWidth);B??(B=2);const K=y.textPosition,g=Math.min(u,d)/2-R,se=(0,h.JLW)().innerRadius(0).outerRadius(g),ne=(0,h.JLW)().innerRadius(g*K).outerRadius(g*K);m.append("circle").attr("cx",0).attr("cy",0).attr("r",g+B/2).attr("class","pieOuterCircle");const f=s.getSections(),oe=te(f),ce=[r.pie1,r.pie2,r.pie3,r.pie4,r.pie5,r.pie6,r.pie7,r.pie8,r.pie9,r.pie10,r.pie11,r.pie12];let E=0;f.forEach(t=>{E+=t});const O=oe.filter(t=>(t.data.value/E*100).toFixed(0)!=="0"),x=(0,h.UMr)(ce).domain([...f.keys()]);m.selectAll("mySlices").data(O).enter().append("path").attr("d",se).attr("fill",t=>x(t.data.label)).attr("class","pieCircle"),m.selectAll("mySlices").data(O).enter().append("text").text(t=>(t.data.value/E*100).toFixed(0)+"%").attr("transform",t=>"translate("+ne.centroid(t)+")").style("text-anchor","middle").attr("class","slice");const le=m.append("text").text(s.getDiagramTitle()).attr("x",0).attr("y",-(d-50)/2).attr("class","pieTitleText"),P=[...f.entries()].map(([t,k])=>({label:t,value:k})),S=m.selectAll(".legend").data(P).enter().append("g").attr("class","legend").attr("transform",(t,k)=>{const j=c+p,_e=j*P.length/2,pe=12*c,ge=k*j-_e;return"translate("+pe+","+ge+")"});S.append("rect").attr("width",c).attr("height",c).style("fill",t=>x(t.label)).style("stroke",t=>x(t.label)),S.append("text").attr("x",c+p).attr("y",c-p).text(t=>s.getShowData()?`${t.label} [${t.value}]`:t.label);const de=Math.max(...S.selectAll("text").nodes().map(t=>t?.getBoundingClientRect().width??0)),me=u+R+c+p+de,W=le.node()?.getBoundingClientRect().width??0,ue=u/2-W/2,he=u/2+W/2,L=Math.min(0,ue),I=Math.max(me,he)-L;C.attr("viewBox",`${L} 0 ${I} ${d}`),(0,n.a$)(C,d,I,y.useMaxWidth)},"draw"),ie={draw:ae},re={parser:Z,db:w,renderer:ie,styles:ee}})}]);
