import{c as S}from"./chunk-AEOMTBSW-DS2XDHi2.js";import{p as I}from"./treemap-KZPCXAKY-RU5UWGQG-Bieyf2w6.js";import{Y as E,X as F,Z as z,K as D,V as P,j as R,m as o,aO as V,$ as W,L as v,n as B,o as w,p as j,aT as G,U as Z}from"./mermaid.esm.min-DGQNoR5D.js";import"./chunk-H3VCZNTA-CxC2d02b.js";import"./app-t8Vldhgr.js";var h={showLegend:!0,ticks:5,max:null,min:0,graticule:"circle"},b={axes:[],curves:[],options:h},x=structuredClone(b),K=B.radar,U=o(()=>v({...K,...w().radar}),"getConfig"),M=o(()=>x.axes,"getAxes"),X=o(()=>x.curves,"getCurves"),Y=o(()=>x.options,"getOptions"),_=o(a=>{x.axes=a.map(t=>({name:t.name,label:t.label??t.name}))},"setAxes"),H=o(a=>{x.curves=a.map(t=>({name:t.name,label:t.label??t.name,entries:q(t.entries)}))},"setCurves"),q=o(a=>{if(a[0].axis==null)return a.map(e=>e.value);let t=M();if(t.length===0)throw new Error("Axes must be populated before curves for reference entries");return t.map(e=>{let r=a.find(i=>i.axis?.$refText===e.name);if(r===void 0)throw new Error("Missing entry for axis "+e.label);return r.value})},"computeCurveEntries"),J=o(a=>{let t=a.reduce((e,r)=>(e[r.name]=r,e),{});x.options={showLegend:t.showLegend?.value??h.showLegend,ticks:t.ticks?.value??h.ticks,max:t.max?.value??h.max,min:t.min?.value??h.min,graticule:t.graticule?.value??h.graticule}},"setOptions"),N=o(()=>{W(),x=structuredClone(b)},"clear"),f={getAxes:M,getCurves:X,getOptions:Y,setAxes:_,setCurves:H,setOptions:J,getConfig:U,clear:N,setAccTitle:R,getAccTitle:P,setDiagramTitle:D,getDiagramTitle:z,getAccDescription:F,setAccDescription:E},Q=o(a=>{S(a,f);let{axes:t,curves:e,options:r}=a;f.setAxes(t),f.setCurves(e),f.setOptions(r)},"populate"),tt={parse:o(async a=>{let t=await I("radar",a);j.debug(t),Q(t)},"parse")},et=o((a,t,e,r)=>{let i=r.db,n=i.getAxes(),l=i.getCurves(),s=i.getOptions(),c=i.getConfig(),d=i.getDiagramTitle(),g=V(t),p=at(g,c),u=s.max??Math.max(...l.map(y=>Math.max(...y.entries))),m=s.min,$=Math.min(c.width,c.height)/2;rt(p,n,$,s.ticks,s.graticule),it(p,n,$,c),C(p,n,l,m,u,s.graticule,c),k(p,l,s.showLegend,c),p.append("text").attr("class","radarTitle").text(d).attr("x",0).attr("y",-c.height/2-c.marginTop)},"draw"),at=o((a,t)=>{let e=t.width+t.marginLeft+t.marginRight,r=t.height+t.marginTop+t.marginBottom,i={x:t.marginLeft+t.width/2,y:t.marginTop+t.height/2};return Z(a,r,e,t.useMaxWidth??!0),a.attr("viewBox",`0 0 ${e} ${r}`),a.append("g").attr("transform",`translate(${i.x}, ${i.y})`)},"drawFrame"),rt=o((a,t,e,r,i)=>{if(i==="circle")for(let n=0;n{let p=2*g*Math.PI/n-Math.PI/2,u=s*Math.cos(p),m=s*Math.sin(p);return`${u},${m}`}).join(" ");a.append("polygon").attr("points",c).attr("class","radarGraticule")}}},"drawGraticule"),it=o((a,t,e,r)=>{let i=t.length;for(let n=0;n{if(d.entries.length!==s)return;let p=d.entries.map((u,m)=>{let $=2*Math.PI*m/s-Math.PI/2,y=L(u,r,i,c),A=y*Math.cos($),O=y*Math.sin($);return{x:A,y:O}});n==="circle"?a.append("path").attr("d",T(p,l.curveTension)).attr("class",`radarCurve-${g}`):n==="polygon"&&a.append("polygon").attr("points",p.map(u=>`${u.x},${u.y}`).join(" ")).attr("class",`radarCurve-${g}`)})}o(C,"drawCurves");function L(a,t,e,r){let i=Math.min(Math.max(a,t),e);return r*(i-t)/(e-t)}o(L,"relativeRadius");function T(a,t){let e=a.length,r=`M${a[0].x},${a[0].y}`;for(let i=0;i{let d=a.append("g").attr("transform",`translate(${i}, ${n+c*l})`);d.append("rect").attr("width",12).attr("height",12).attr("class",`radarLegendBox-${c}`),d.append("text").attr("x",16).attr("y",0).attr("class","radarLegendText").text(s.label)})}o(k,"drawLegend");var st={draw:et},nt=o((a,t)=>{let e="";for(let r=0;r{let t=G(),e=w(),r=v(t,e.themeVariables),i=v(r.radar,a);return{themeVariables:r,radarOptions:i}},"buildRadarStyleOptions"),ot=o(({radar:a}={})=>{let{themeVariables:t,radarOptions:e}=lt(a);return` .radarTitle { font-size: ${t.fontSize}; color: ${t.titleColor}; dominant-baseline: hanging; text-anchor: middle; } .radarAxisLine { stroke: ${e.axisColor}; stroke-width: ${e.axisStrokeWidth}; } .radarAxisLabel { dominant-baseline: middle; text-anchor: middle; font-size: ${e.axisLabelFontSize}px; color: ${e.axisColor}; } .radarGraticule { fill: ${e.graticuleColor}; fill-opacity: ${e.graticuleOpacity}; stroke: ${e.graticuleColor}; stroke-width: ${e.graticuleStrokeWidth}; } .radarLegendText { text-anchor: start; font-size: ${e.legendFontSize}px; dominant-baseline: hanging; } ${nt(t,e)} `},"styles"),xt={parser:tt,db:f,renderer:st,styles:ot};export{xt as diagram};