UNPKG

@eventcatalogtest/studio

Version:

A drag and drop UI for distributed systems that keeps your diagrams where they belong – in your repo

43 lines 6.03 kB
"use strict";exports.id=107,exports.ids=[107],exports.modules={70107:(a,b,c)=>{c.d(b,{diagram:()=>G});var d=c(87124),e=c(65299),f=c(58210),g=c(32892),h=c(66689),i={showLegend:!0,ticks:5,max:null,min:0,graticule:"circle"},j={axes:[],curves:[],options:i},k=structuredClone(j),l=g.UI.radar,m=(0,g.K2)(()=>(0,e.$t)({...l,...(0,g.zj)().radar}),"getConfig"),n=(0,g.K2)(()=>k.axes,"getAxes"),o=(0,g.K2)(()=>k.curves,"getCurves"),p=(0,g.K2)(()=>k.options,"getOptions"),q=(0,g.K2)(a=>{k.axes=a.map(a=>({name:a.name,label:a.label??a.name}))},"setAxes"),r=(0,g.K2)(a=>{k.curves=a.map(a=>({name:a.name,label:a.label??a.name,entries:s(a.entries)}))},"setCurves"),s=(0,g.K2)(a=>{if(void 0==a[0].axis)return a.map(a=>a.value);let b=n();if(0===b.length)throw Error("Axes must be populated before curves for reference entries");return b.map(b=>{let c=a.find(a=>a.axis?.$refText===b.name);if(void 0===c)throw Error("Missing entry for axis "+b.label);return c.value})},"computeCurveEntries"),t={getAxes:n,getCurves:o,getOptions:p,setAxes:q,setCurves:r,setOptions:(0,g.K2)(a=>{let b=a.reduce((a,b)=>(a[b.name]=b,a),{});k.options={showLegend:b.showLegend?.value??i.showLegend,ticks:b.ticks?.value??i.ticks,max:b.max?.value??i.max,min:b.min?.value??i.min,graticule:b.graticule?.value??i.graticule}},"setOptions"),getConfig:m,clear:(0,g.K2)(()=>{(0,g.IU)(),k=structuredClone(j)},"clear"),setAccTitle:g.SV,getAccTitle:g.iN,setDiagramTitle:g.ke,getDiagramTitle:g.ab,getAccDescription:g.m7,setAccDescription:g.EI},u=(0,g.K2)(a=>{(0,d.S)(a,t);let{axes:b,curves:c,options:e}=a;t.setAxes(b),t.setCurves(c),t.setOptions(e)},"populate"),v={parse:(0,g.K2)(async a=>{let b=await (0,h.qg)("radar",a);g.Rm.debug(b),u(b)},"parse")},w=(0,g.K2)((a,b,c,d)=>{let e=d.db,g=e.getAxes(),h=e.getCurves(),i=e.getOptions(),j=e.getConfig(),k=e.getDiagramTitle(),l=x((0,f.D)(b),j),m=i.max??Math.max(...h.map(a=>Math.max(...a.entries))),n=i.min,o=Math.min(j.width,j.height)/2;y(l,g,o,i.ticks,i.graticule),z(l,g,o,j),A(l,g,h,n,m,i.graticule,j),D(l,h,i.showLegend,j),l.append("text").attr("class","radarTitle").text(k).attr("x",0).attr("y",-j.height/2-j.marginTop)},"draw"),x=(0,g.K2)((a,b)=>{let c=b.width+b.marginLeft+b.marginRight,d=b.height+b.marginTop+b.marginBottom,e={x:b.marginLeft+b.width/2,y:b.marginTop+b.height/2};return a.attr("viewbox",`0 0 ${c} ${d}`).attr("width",c).attr("height",d),a.append("g").attr("transform",`translate(${e.x}, ${e.y})`)},"drawFrame"),y=(0,g.K2)((a,b,c,d,e)=>{if("circle"===e)for(let b=0;b<d;b++){let e=c*(b+1)/d;a.append("circle").attr("r",e).attr("class","radarGraticule")}else if("polygon"===e){let e=b.length;for(let f=0;f<d;f++){let g=c*(f+1)/d,h=b.map((a,b)=>{let c=2*b*Math.PI/e-Math.PI/2,d=g*Math.cos(c),f=g*Math.sin(c);return`${d},${f}`}).join(" ");a.append("polygon").attr("points",h).attr("class","radarGraticule")}}},"drawGraticule"),z=(0,g.K2)((a,b,c,d)=>{let e=b.length;for(let f=0;f<e;f++){let g=b[f].label,h=2*f*Math.PI/e-Math.PI/2;a.append("line").attr("x1",0).attr("y1",0).attr("x2",c*d.axisScaleFactor*Math.cos(h)).attr("y2",c*d.axisScaleFactor*Math.sin(h)).attr("class","radarAxisLine"),a.append("text").text(g).attr("x",c*d.axisLabelFactor*Math.cos(h)).attr("y",c*d.axisLabelFactor*Math.sin(h)).attr("class","radarAxisLabel")}},"drawAxes");function A(a,b,c,d,e,f,g){let h=b.length,i=Math.min(g.width,g.height)/2;c.forEach((b,c)=>{if(b.entries.length!==h)return;let j=b.entries.map((a,b)=>{let c=2*Math.PI*b/h-Math.PI/2,f=B(a,d,e,i);return{x:f*Math.cos(c),y:f*Math.sin(c)}});"circle"===f?a.append("path").attr("d",C(j,g.curveTension)).attr("class",`radarCurve-${c}`):"polygon"===f&&a.append("polygon").attr("points",j.map(a=>`${a.x},${a.y}`).join(" ")).attr("class",`radarCurve-${c}`)})}function B(a,b,c,d){return d*(Math.min(Math.max(a,b),c)-b)/(c-b)}function C(a,b){let c=a.length,d=`M${a[0].x},${a[0].y}`;for(let e=0;e<c;e++){let f=a[(e-1+c)%c],g=a[e],h=a[(e+1)%c],i=a[(e+2)%c],j={x:g.x+(h.x-f.x)*b,y:g.y+(h.y-f.y)*b},k={x:h.x-(i.x-g.x)*b,y:h.y-(i.y-g.y)*b};d+=` C${j.x},${j.y} ${k.x},${k.y} ${h.x},${h.y}`}return`${d} Z`}function D(a,b,c,d){if(!c)return;let e=(d.width/2+d.marginRight)*3/4,f=-(3*(d.height/2+d.marginTop))/4;b.forEach((b,c)=>{let d=a.append("g").attr("transform",`translate(${e}, ${f+20*c})`);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(b.label)})}(0,g.K2)(A,"drawCurves"),(0,g.K2)(B,"relativeRadius"),(0,g.K2)(C,"closedRoundCurve"),(0,g.K2)(D,"drawLegend");var E=(0,g.K2)((a,b)=>{let c="";for(let d=0;d<a.THEME_COLOR_LIMIT;d++){let e=a[`cScale${d}`];c+=` .radarCurve-${d} { color: ${e}; fill: ${e}; fill-opacity: ${b.curveOpacity}; stroke: ${e}; stroke-width: ${b.curveStrokeWidth}; } .radarLegendBox-${d} { fill: ${e}; fill-opacity: ${b.curveOpacity}; stroke: ${e}; } `}return c},"genIndexStyles"),F=(0,g.K2)(a=>{let b=(0,g.P$)(),c=(0,g.zj)(),d=(0,e.$t)(b,c.themeVariables),f=(0,e.$t)(d.radar,a);return{themeVariables:d,radarOptions:f}},"buildRadarStyleOptions"),G={parser:v,db:t,renderer:{draw:w},styles:(0,g.K2)(({radar:a}={})=>{let{themeVariables:b,radarOptions:c}=F(a);return` .radarTitle { font-size: ${b.fontSize}; color: ${b.titleColor}; dominant-baseline: hanging; text-anchor: middle; } .radarAxisLine { stroke: ${c.axisColor}; stroke-width: ${c.axisStrokeWidth}; } .radarAxisLabel { dominant-baseline: middle; text-anchor: middle; font-size: ${c.axisLabelFontSize}px; color: ${c.axisColor}; } .radarGraticule { fill: ${c.graticuleColor}; fill-opacity: ${c.graticuleOpacity}; stroke: ${c.graticuleColor}; stroke-width: ${c.graticuleStrokeWidth}; } .radarLegendText { text-anchor: start; font-size: ${c.legendFontSize}px; dominant-baseline: hanging; } ${E(b,c)} `},"styles")}},87124:(a,b,c)=>{function d(a,b){a.accDescr&&b.setAccDescription?.(a.accDescr),a.accTitle&&b.setAccTitle?.(a.accTitle),a.title&&b.setDiagramTitle?.(a.title)}c.d(b,{S:()=>d}),(0,c(32892).K2)(d,"populateCommonDb")}};