@apia/charts 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +45 -14
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -37,15 +37,10 @@ type TApiaChartColumn = {
|
|
|
37
37
|
*/
|
|
38
38
|
name: string;
|
|
39
39
|
};
|
|
40
|
-
type
|
|
41
|
-
chartType: 'pie2D';
|
|
42
|
-
};
|
|
43
|
-
type TNoPie = {
|
|
44
|
-
chartType: 'barH2D' | 'barV2D' | 'linear' | 'waterfall';
|
|
40
|
+
type TApiaChartDefinition = {
|
|
41
|
+
chartType: 'barH2D' | 'barV2D' | 'linear' | 'waterfall' | 'pie2D';
|
|
45
42
|
axisXTitle: string;
|
|
46
43
|
axisYTitle: string;
|
|
47
|
-
};
|
|
48
|
-
type TApiaChartDefinitionBase = {
|
|
49
44
|
/**
|
|
50
45
|
* The colors of the waterfall chart are defined by the bars with positive
|
|
51
46
|
* values and the bars with negative values. So in order to mantain cohesion
|
|
@@ -169,10 +164,6 @@ type TApiaChartDefinitionBase = {
|
|
|
169
164
|
maxWidth: number;
|
|
170
165
|
};
|
|
171
166
|
};
|
|
172
|
-
type TApiaPieChartDefinition = TPie & TApiaChartDefinitionBase;
|
|
173
|
-
type TApiaNoPieChartDefinition = TNoPie & TApiaChartDefinitionBase;
|
|
174
|
-
type TApiaChartDefinition = TApiaPieChartDefinition | TApiaNoPieChartDefinition;
|
|
175
|
-
declare function isPieChart(chart: TApiaChartDefinition): chart is TApiaPieChartDefinition;
|
|
176
167
|
type TChartMargin = {
|
|
177
168
|
top: number;
|
|
178
169
|
bottom: number;
|
|
@@ -201,7 +192,47 @@ declare const ChartRenderer: React$1.FC<{
|
|
|
201
192
|
id: _apia_util.TId;
|
|
202
193
|
}>;
|
|
203
194
|
|
|
204
|
-
|
|
195
|
+
type TWidgetZone = {
|
|
196
|
+
minimum: number;
|
|
197
|
+
maximum: number;
|
|
198
|
+
transparency: number;
|
|
199
|
+
color: string;
|
|
200
|
+
};
|
|
201
|
+
type TWidgetData = {
|
|
202
|
+
border: boolean;
|
|
203
|
+
backgroundColor: string;
|
|
204
|
+
currentValue: number;
|
|
205
|
+
forceProp?: Record<string, unknown>;
|
|
206
|
+
height: number;
|
|
207
|
+
maxValue: number;
|
|
208
|
+
minValue: number;
|
|
209
|
+
noValueColor: string;
|
|
210
|
+
pointerColor: string;
|
|
211
|
+
ringAnchor: number;
|
|
212
|
+
scaleFontSize: string | number;
|
|
213
|
+
valueColor: string;
|
|
214
|
+
valueDecimals: number;
|
|
215
|
+
valueFontSize: string | number;
|
|
216
|
+
valueType: string | number;
|
|
217
|
+
viewBtnDshAssociated: boolean;
|
|
218
|
+
viewBtnHistory: boolean;
|
|
219
|
+
viewBtnInfo: boolean;
|
|
220
|
+
viewBtnComments: boolean;
|
|
221
|
+
viewBtnUpdate: boolean;
|
|
222
|
+
viewBtnOpenCbe: boolean;
|
|
223
|
+
viewBtnOpenQry: boolean;
|
|
224
|
+
viewBtnOpenOtherQry: boolean;
|
|
225
|
+
viewBtnOpenOtherQbe: boolean;
|
|
226
|
+
viewWidName: boolean;
|
|
227
|
+
widKpiType: string | number;
|
|
228
|
+
width: number;
|
|
229
|
+
zones: {
|
|
230
|
+
Zone: TWidgetZone | TWidgetZone[];
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
declare const WidgetContainer: ({ data }: {
|
|
235
|
+
data: TWidgetData;
|
|
236
|
+
}) => theme_ui_jsx_runtime.JSX.Element;
|
|
205
237
|
|
|
206
|
-
export { ChartRenderer, TApiaChartDefinition,
|
|
207
|
-
//# sourceMappingURL=index.d.ts.map
|
|
238
|
+
export { ChartRenderer, TApiaChartColumn, TApiaChartDefinition, TWidgetData, WidgetContainer };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{jsx as l,jsxs as P,Fragment as q}from"react/jsx-runtime";import de,{createContext as dt,useContext as te,useState as H,useMemo as B,useLayoutEffect as me,useEffect as Ee,useRef as mt}from"react";import{Box as D,Select as ut}from"theme-ui";import{ThemeProviderContext as pt,spacing as je,makeStyledComponent as gt,getVariant as ft}from"@apia/theme";import{uniqueId as ue}from"lodash";import{makeImperativeComponent as _e,arrayOrArray as p,useImperativeComponentEvents as re,getValueByPath as yt,usePanAndZoom as ae,usePrevious as vt,getIndex as xt}from"@apia/util";import{scaleBand as oe,scaleLog as Ce,scaleLinear as pe,scaleOrdinal as Oe}from"@visx/scale";import{Grid as Ne}from"@visx/visx";import{Group as Q}from"@visx/group";import{BarGroupHorizontal as bt,BarGroup as wt,LinePath as $t,Line as kt}from"@visx/shape";import{AxisLeft as ge,AxisBottom as fe}from"@visx/axis";import{usePanelParametersSelector as Le}from"@apia/dashboard";import W from"tinycolor2";import{localPoint as U}from"@visx/event";import{SimpleButton as St,useTooltip as le}from"@apia/components";import{icons as Ct}from"@apia/icons";import Ve from"@visx/shape/lib/shapes/Pie";import{min as ye,max as Re,extent as Ot}from"d3-array";import*as Nt from"@visx/curve";import{Fragment as Pt}from"theme-ui/jsx-runtime";import{GridRows as At}from"@visx/grid";import{useGauge as Tt}from"use-gauge";function ve(e={left:100,right:50,top:50,bottom:70}){return typeof e=="number"?{left:e,right:e,top:e,bottom:e}:e}const ne=dt({}),Mt=({groupId:e,title:t,color:r,className:o,isHighlighted:a,isAnyHighlighted:s,avoidEvent:i})=>{const{chartId:d}=te(ne);return l(St,{variant:"icon-outline",className:`${o??""} ${a?"highlight":""}`,iconColor:r||"black",icon:r==="transparent"?void 0:Ct.SquareFilled,sx:{opacity:s&&!a?"0.15":"1"},onMouseEnter:()=>{i||ot(d,"highlight",e)},onMouseLeave:()=>{i||ot(d,"highlight","")},children:t})},[ee,,ie]=_e()({initialState:{highlightedBarGroup:""},methods:{highlight(e,t){e({highlightedBarGroup:t})}},Component:({references:e,containerClassName:t,highlightedBarGroup:r,avoidEvent:o})=>l(D,{className:t,children:e.map(a=>l(Mt,{isHighlighted:a.title===r,isAnyHighlighted:r!=="",groupId:a.title,color:a.color,title:a.title,avoidEvent:o??!1},a.title))})}),Et=({bar:e,barGroup:t,chart:r,parsedData:o,isSingle:a,effectiveMargin:s,setsWithColor:i})=>{var d;const g=p(r.dataSets.data)[e.index],f=p(g?.sets)[t.index],y=(d=i.find(u=>u.columnName===g.name&&u.key===f.key))==null?void 0:d.color,[v,b]=H(!1),[k,S]=H(!1),{open:V}=le({children:P(q,{children:[l("div",{style:{color:y},children:l("strong",{children:o[t.index].columnName})}),r.showValues&&l("div",{children:e.value}),l("div",{children:e.key})]})});re({highlight(u){u.split(" - ").length===1?(b(u===e.key),S(u!==e.key&&u!=="")):u.split(" - ").length===2&&(b(u.split(" - ")[0]===e.key&&u.split(" - ")[1]===f.key),S(u.split(" - ")[0]!==e.key&&u.split(" - ")[0]!==""))}});const{chartId:x}=te(ne);return P("g",{children:[P("text",{x:e.x+5,y:e.y-5,width:e.width,height:e.height,textAnchor:"start",style:{display:v?"block":"none",opacity:v?1:0,transition:"opacity 500ms"},children:[e.value," - ",o[t.index].columnName]}),l(D,{as:"rect",className:"chart__barRect",sx:B(()=>({fill:k?`#${W(y).desaturate(70).toHex()}`:y,"&:hover":{fill:`#${W(y).saturate(25).toHex()}`},transition:"fill 500ms, opacity 500ms",x:e.x,y:e.y,width:e.width-s.left,opacity:k&&!v?.15:1,height:e.height>0?e.height:0}),[e.height,e.width,e.x,e.y,y,s.left,k,v]),onMouseEnter:u=>{var N,L,A;a||ee.highlight(x,e.key),(N=u.target.classList)==null||N.add("over"),(L=U(u))==null||L.x,(A=U(u))==null||A.y,V({attachToElement:()=>u.target,attachToElementAnchorPoint:"center"})},onMouseLeave:u=>{var N;a||ee.highlight(x,""),(N=u.target.classList)==null||N.remove("over")},children:l("animate",{attributeName:"width",from:0,to:e.width,dur:"0.5s",calcMode:"paced",keySplines:"0.5 0 0.5 1;",keyTimes:"0; 1"})})]})};function ce(e,t,r=!1){const o=e.length;let a=0,s="";if(r)e[t]?s=e[t]:s=W(e[t%o]).toHex();else if(e[t])s=e[t];else{let i=t;for(;i>=o;)i=t/o,a++;s=W(e[t%o]).desaturate(a*5).toHex()}return s}var jt=Object.defineProperty,Ie=Object.getOwnPropertySymbols,_t=Object.prototype.hasOwnProperty,Lt=Object.prototype.propertyIsEnumerable,Be=(e,t,r)=>t in e?jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,De=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&Be(e,r,t[r]);if(Ie)for(var r of Ie(t))Lt.call(t,r)&&Be(e,r,t[r]);return e};function xe(e){var t,r,o;const a=te(pt);a.layout||console.error("The layout property is missing in the current theme");const s=(r=(t=a.layout)==null?void 0:t.charts)!=null?r:{},i=s.common,d={schema:yt(a.colors,(o=s[e||"blue"])==null?void 0:o.schema)};return De(De({},i),d)}var Vt=Object.defineProperty,Rt=Object.defineProperties,It=Object.getOwnPropertyDescriptors,We=Object.getOwnPropertySymbols,Bt=Object.prototype.hasOwnProperty,Dt=Object.prototype.propertyIsEnumerable,He=(e,t,r)=>t in e?Vt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,be=(e,t)=>{for(var r in t||(t={}))Bt.call(t,r)&&He(e,r,t[r]);if(We)for(var r of We(t))Dt.call(t,r)&&He(e,r,t[r]);return e},we=(e,t)=>Rt(e,It(t));function Wt({width:e,height:t,maxWidth:r}){if(e<=r)return{width:e,height:t};const o=e/t,a=r,s=Math.floor(a/o);return{width:a,height:s}}const Ge=e=>e.columnName,Ht=({margin:e={top:20,left:50,bottom:150,right:20},chart:t,className:r,chartId:o,outerClassName:a,allowZoom:s})=>{var i;const d=ve(e);let g=t.ratio.width+(-d.left-d.right)/2,f=t.ratio.height+(-d.top-d.bottom)/2;if(g>t.ratio.maxWidth){const c=Wt({height:f,width:g,maxWidth:t.ratio.maxWidth});g=c.width,f=c.height}const y=p((i=t.dataSets)==null?void 0:i.data).filter(c=>!!c.sets).map(c=>we(be({},c),{sets:c.sets})),v=p(y[0].sets).map(c=>c.key),b=y.map(c=>c.name),k=v.map(c=>y.reduce((n,$)=>we(be({},n),{[$.name]:p($.sets).filter(j=>j.key===c)[0].value}),{columnName:c})),S=oe({range:[typeof d=="number"?d:d.top,f],domain:k.map(Ge),padding:.2}),V=oe({domain:b,range:[0,S.bandwidth()]}),x=Ce({range:[typeof d=="number"?d:d.left,g],domain:[1,Math.max(...k.map(c=>Math.max(...b.map(n=>Number(c[n])))))],base:10}),u=pe({range:[typeof d=="number"?d:d.left,g],domain:[0,Math.max(...k.map(c=>Math.max(...b.map(n=>Number(c[n])))))]}),N=Oe({domain:b,range:y.map(c=>c.color)}),L=Le(c=>c).PRMT_CHART_SCALE==="0",A=B(()=>L?x:u,[L,u,x]),Y=B(()=>`VerticalBars${ue()}`,[]);me(()=>{document.querySelectorAll(`#${Y} .__${o??a}`).forEach(c=>{const n=c.getBoundingClientRect().width;c.style.transformOrigin=c.getAttribute("x")+"px 14px",c.style.transform=`rotate(15deg) translateX(${n/2}px)`})});const R=xe(t.colorSchema),{boxRef:K,elementRef:w}=ae(void 0,!s),T=p(t.dataSets.data).map((c,n)=>{const $=p(t.dataSets.data).length===1,j=c.color!==""&&c.color!==void 0?c.color:p(R.schema).length>0?ce(p(R.schema),n,$):"",E=[];return p(c.sets).forEach(h=>{h.color!==""&&h.color!==void 0?E.push(we(be({},h),{columnName:c.name})):E.push(we(be({},h),{color:j,columnName:c.name}))}),E}),m=T.map(c=>{var n;return{color:(n=c[0].color)!=null?n:"",title:c[0].columnName}});return p(t.dataSets.data).map(c=>{const n=[];return p(c.sets).forEach($=>{$.color!==""&&$.color!==void 0&&n.push({color:$.color,title:c.name+" - "+$.key})}),n}).flat().forEach(c=>m.push(c)),P(q,{children:[l(D,{ref:K,id:Y,className:`${a??""} ${o} ${t.title}`,sx:de.useMemo(()=>({[`.__${o??a}`]:{transform:"rotate(45deg)",transformOrigin:"attr(x) 18px"},overflow:"auto",position:"relative",height:`${t.ratio.height}px`,width:`${t.ratio.width}px`}),[t.ratio.height,t.ratio.width,o,a]),children:P("svg",{ref:w,className:`_${o} ${r||""} chart__svg`,height:t.ratio.height,width:t.ratio.width,style:{position:"absolute"},children:[t.showGrid&&l(Ne.Grid,{xScale:A,yScale:S,left:0,width:g,height:f,numTicksRows:10,numTicksColumns:10,top:(typeof d=="number"?d:d.top)-20}),l(Q,{top:(typeof d=="number"?d:d.top)-20,left:d.left,children:l(bt,{data:k,keys:b,width:g,y0:Ge,y0Scale:S,y1Scale:V,xScale:A,color:N,children:c=>c.map(n=>l(Q,{top:n.y0,children:n.bars.map($=>{const j=`${n.index}-${$.index}-${$.key}`;return l(Et,{isSingle:n.bars.length===1,bar:$,barGroup:n,chart:t,parsedData:k,effectiveMargin:d,setsWithColor:T.flat()},j)})},`bar-group-${n.index}-${n.y0}`))})}),l(ge,{scale:S,left:d.left,label:t.chartType!=="pie2D"&&t.showAxisYTitle?t.axisYTitle:"",tickLabelProps:()=>({display:"none"})}),l(fe,{top:f,scale:A,label:t.chartType!=="pie2D"&&t.showAxisXTitle?t.axisXTitle:"",tickLabelProps:{className:"tickLabel"},labelOffset:50})]})}),m.length>1&&l(ie,{id:o,containerClassName:"legendContainer",references:m})]})},Gt=({arc:e,arcPath:t,chart:r,actualColor:o})=>{const[a,s]=H(!1),[i,d]=H(!1),{open:g}=le({children:P(q,{children:[l("div",{style:{color:`#${W(o).toHex()}`},children:l("strong",{children:e.data.key})}),r.showValues&&l("div",{children:`${e.value} ${e.data.percentage?"- "+e.data.percentage:""}${e.data.percentage?"%":""}`})]})});re({highlight(v){s(v===e.data.key),d(v!==e.data.key&&v!=="")}});const{chartId:f}=te(ne),y=e.data;return l("path",{style:B(()=>({"&:hover":{fill:`#${W(o).saturate(25).toHex()}`},transition:"fill 500ms, opacity 500ms"}),[o]),fill:i?`#${W(o).desaturate(70).toHex()}`:o,opacity:i&&!a?.15:1,d:t??"",onMouseEnter:v=>{var b,k,S;ee.highlight(f,e.data.key),(b=v.target.classList)==null||b.add("over"),(k=U(v))==null||k.x,(S=U(v))==null||S.y,g({attachToElement:()=>v.target,attachToElementAnchorPoint:"center"})},onMouseLeave:v=>{var b;ee.highlight(f,""),(b=v.target.classList)==null||b.remove("over")}},`arc-${y.key}-${y.value}`)};function Ye({chartId:e,pieces:t,className:r,current:o,setCurrent:a}){return P(ut,{sx:{width:"auto"},name:`chartSelector_${e}`,className:`chartSelector_${e} ${r??""}`,value:o??"0",onChange:s=>{s.preventDefault(),a(s.target.value)},children:[t.map((s,i)=>({label:s,value:`${i}`})).map(s=>l("option",{value:s.value,children:s.label},s.value))," "]})}const Yt=({arc:e,x:t,y:r,dy:o})=>{const[a,s]=H(!1);return re({highlight(i){s(i===e.data.key)}}),l("text",{textAnchor:"middle",style:{opacity:a?1:0,display:a?"block":"none",transition:"opacity 500ms"},x:t,y:r,dy:o,children:e.value})};var Xt=Object.defineProperty,zt=Object.defineProperties,Ft=Object.getOwnPropertyDescriptors,Xe=Object.getOwnPropertySymbols,qt=Object.prototype.hasOwnProperty,Zt=Object.prototype.propertyIsEnumerable,ze=(e,t,r)=>t in e?Xt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Kt=(e,t)=>{for(var r in t||(t={}))qt.call(t,r)&&ze(e,r,t[r]);if(Xe)for(var r of Xe(t))Zt.call(t,r)&&ze(e,r,t[r]);return e},Jt=(e,t)=>zt(e,Ft(t));function Qt({width:e,height:t,maxWidth:r}){if(e<=r)return{width:e,height:t};const o=e/t,a=r,s=Math.floor(a/o);return{width:a,height:s}}const Ut=({chart:e,className:t,chartId:r,allowZoom:o})=>{var a;const[s,i]=H({});let d=e.ratio.width>e.ratio.height?e.ratio.width:e.ratio.height,g=e.ratio.width>e.ratio.height?e.ratio.width:e.ratio.height;if(d>e.ratio.maxWidth){const w=Qt({height:g,width:d,maxWidth:e.ratio.maxWidth});d=w.width,g=w.height}const f=p((a=e.dataSets)==null?void 0:a.data).filter(w=>!!w.sets).map(w=>Jt(Kt({},w),{coordinate:w.sets})),[y,v]=H("0");Ee(()=>{i(f[y??0])},[y]);const b=B(()=>g/2.5,[g]),k=B(()=>d/2.5,[d]),S=b,V=k,x=w=>Number(w.value)===0&&f.length===1&&p(f.map(T=>T.coordinate)[0]).length===1?100:Number(w.value),u=Math.min(g,d)/2.5,N=f.map(w=>w.name),L=xe(e.colorSchema).schema,A=p(p(e.dataSets.data)[0].sets).map(w=>w.key).map((w,T)=>({title:w,color:ce(p(L),T)})),{boxRef:Y,elementRef:R}=ae(void 0,!o),K=mt([]);return P(q,{children:[f.length>1&&l(D,{className:"chart__combo__wrapper",children:l(Ye,{chartId:r,pieces:N,className:"chartSelectorCombo",current:y,setCurrent:v})}),l(D,{ref:Y,className:`${t||""} ${r}`,sx:{textAlign:"center",pb:je(5)},children:l("svg",{ref:R,height:u*2,width:u*2,className:`_${r} chart__svg`,children:P(Q,{top:S??0,left:V??0,children:[l(Ve,{data:p(s.coordinate),pieValue:x,pieSort:null,outerRadius:u,children:w=>{const T=p(w.arcs).map(c=>w.path(c)),m=w.arcs.map(c=>{var n,$;const j=c.data,E=w.path(c);return l(Gt,{arc:c,arcPath:E,chart:e,actualColor:($=(n=A.find(h=>h.title===j.key))==null?void 0:n.color)!=null?$:""},`${j.key}_${j.value}`)});return K.current=T,m}}),l(Ve,{data:p(s.coordinate),pieValue:x,pieSort:null,outerRadius:u,children:w=>w.arcs.map(T=>{const m=T.data,c=(T.startAngle-Math.PI+T.endAngle)/2,n=Math.cos(c)*(u*.75),$=Math.sin(c)*(u*.75);return l("g",{children:l(Yt,{arc:T,chart:e,dy:"0.33em",x:n,y:$})},`arc-${m.key}-${m.value}`)})})]})})},s.name),A.length>1&&l(ie,{id:r,containerClassName:"legendContainer",references:A})]})},er=({bar:e,barGroup:t,chart:r,parsedData:o,isSingle:a,setsWithColor:s})=>{var i;const d=p(r.dataSets.data)[e.index],g=p(d?.sets)[t.index],f=(i=s.find(x=>x.columnName===d.name&&x.key===g.key))==null?void 0:i.color,[y,v]=H(!1),[b,k]=H(!1),{open:S}=le({children:P(q,{children:[l("div",{style:{color:f},children:l("strong",{children:o[t.index].columnName})}),r.showValues&&l("div",{children:e.value}),l("div",{children:e.key})]})});re({highlight(x){x.split(" - ").length===1?(v(x===e.key),k(x!==e.key&&x!=="")):x.split(" - ").length===2&&(v(x.split(" - ")[0]===e.key&&x.split(" - ")[1]===g.key),k(x.split(" - ")[0]!==e.key&&x.split(" - ")[0]!==""))}});const{chartId:V}=te(ne);return P("g",{children:[l("text",{x:e.x+e.width/2,y:e.y-5,width:e.width,height:e.height,textAnchor:"middle",style:{display:y?"block":"none",opacity:y?1:0,transition:"opacity 500ms"},children:e.value}),P(D,{as:"rect",className:"chart__barRect",sx:B(()=>({fill:b?`#${W(f).desaturate(70).toHex()}`:f,"&:hover":{fill:`#${W(f).saturate(25).toHex()}`},transition:"fill 500ms, opacity 500ms",x:e.x,y:e.y,width:e.width,opacity:b&&!y?.15:1,height:e.height>0?e.height:0}),[e.height,e.width,e.x,e.y,f,b,y]),onMouseEnter:x=>{var u,N,L;a||ee.highlight(V,e.key),(u=x.target.classList)==null||u.add("over"),(N=U(x))==null||N.x,(L=U(x))==null||L.y,S({attachToElement:()=>x.target,attachToElementAnchorPoint:"center"})},onMouseLeave:x=>{var u;a||ee.highlight(V,""),(u=x.target.classList)==null||u.remove("over")},children:[l("animate",{attributeName:"height",from:0,to:e.height,dur:"0.5s",calcMode:"paced",keySplines:"0.5 0 0.5 1;",keyTimes:"0; 1"}),l("animate",{attributeName:"y",from:e.y+e.height,to:e.y,dur:"0.5s",calcMode:"paced",keySplines:"0.5 0 0.5 1;",keyTimes:"0; 1"})]})]})};var tr=Object.defineProperty,rr=Object.defineProperties,ar=Object.getOwnPropertyDescriptors,Fe=Object.getOwnPropertySymbols,or=Object.prototype.hasOwnProperty,lr=Object.prototype.propertyIsEnumerable,qe=(e,t,r)=>t in e?tr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$e=(e,t)=>{for(var r in t||(t={}))or.call(t,r)&&qe(e,r,t[r]);if(Fe)for(var r of Fe(t))lr.call(t,r)&&qe(e,r,t[r]);return e},ke=(e,t)=>rr(e,ar(t));function nr({width:e,height:t,maxWidth:r}){if(e<=r)return{width:e,height:t};const o=e/t,a=r,s=Math.floor(a/o);return{width:a,height:s}}const Ze=e=>e.columnName,ir=({margin:e={top:20,left:100,bottom:150,right:20},chart:t,className:r,chartId:o,allowZoom:a})=>{var s;const i=ve(e);t.showAxisYTitle||(i.left=50);let d=t.ratio.width+(-i.left-i.right)/2,g=t.ratio.height+(-i.top-i.bottom)/2;if(d>t.ratio.maxWidth){const m=nr({height:g,width:d,maxWidth:t.ratio.maxWidth});d=m.width,g=m.height}const f=xe(t.colorSchema),y=p((s=t.dataSets)==null?void 0:s.data).filter(m=>!!m.sets).map(m=>ke($e({},m),{sets:m.sets})),v=p(y[0].sets).map(m=>m.key),b=y.map(m=>m.name),k=v.map(m=>y.reduce((c,n)=>ke($e({},c),{[n.name]:p(n.sets).filter($=>$.key===m)[0].value}),{columnName:m})),S=oe({range:[typeof i=="number"?i:i.left,d],domain:k.map(Ze),padding:.2}),V=oe({domain:b,range:[0,S.bandwidth()]}),x=Ce({range:[g,typeof i=="number"?i:i.top],domain:[1,Math.max(...k.map(m=>Math.max(...b.map(c=>Number(m[c])))))],base:10}),u=pe({range:[g,typeof i=="number"?i:i.top],domain:[0,Math.max(...k.map(m=>Math.max(...b.map(c=>Number(m[c])))))]}),N=Oe({domain:b,range:y.map(m=>m.color)}),L=Le(m=>m).PRMT_CHART_SCALE==="0",A=B(()=>L?x:u,[L,u,x]),Y=B(()=>`VerticalBars${ue()}`,[]);me(()=>{document.querySelectorAll(`#${Y} .tickLabel`).forEach(m=>{const c=m.getBoundingClientRect().width;m.style.transformOrigin=m.getAttribute("x")+"px 14px",m.style.transform=`rotate(25deg) translateX(${c/2}px)`})});const{boxRef:R,elementRef:K}=ae(void 0,!a),w=p(t.dataSets.data).map((m,c)=>{const n=p(t.dataSets.data).length===1,$=m.color!==""&&m.color!==void 0?m.color:p(f.schema).length>0?ce(p(f.schema),c,n):"",j=[];return p(m.sets).forEach(E=>{E.color!==""&&E.color!==void 0?j.push(ke($e({},E),{columnName:m.name})):j.push(ke($e({},E),{color:$,columnName:m.name}))}),j}),T=p(t.dataSets.data).map((m,c)=>{const n=p(t.dataSets.data).length===1;return{color:m.color!==""&&m.color!==void 0?m.color:p(f.schema).length>0?ce(p(f.schema),c,n):"",title:m.name}});return p(t.dataSets.data).map(m=>{const c=[];return p(m.sets).forEach(n=>{n.color!==""&&n.color!==void 0&&c.push({color:n.color,title:m.name+" - "+n.key})}),c}).flat().forEach(m=>T.push(m)),P(q,{children:[l(D,{ref:R,id:Y,className:`${r??""} ${t.title}`,sx:{overflow:"hidden"},children:P("svg",{ref:K,className:`_${o} chart__svg`,height:t.ratio.height,width:t.ratio.width,children:[t.showGrid&&l(Ne.Grid,{xScale:S,yScale:A,left:0,width:d,height:g,numTicksRows:10,numTicksColumns:10,top:(typeof i=="number"?i:i.top)-20}),l(Q,{top:(typeof i=="number"?i:i.top)-20,children:l(wt,{data:k,keys:b,height:g,x0:Ze,x0Scale:S,x1Scale:V,yScale:A,color:N,children:m=>m.map(c=>l(Q,{left:c.x0,children:c.bars.map(n=>{const $=`${c.index}-${n.index}-${n.key}`;return l(er,{isSingle:c.bars.length===1,bar:n,barGroup:c,chart:t,parsedData:k,setsWithColor:w.flat()},$)})},`bar-group-${c.index}-${c.x0}`))})}),l(ge,{scale:A,left:i.left,label:t.chartType!=="pie2D"&&t.showAxisYTitle?t.axisYTitle:""}),l(fe,{top:g,scale:S,label:t.chartType!=="pie2D"&&t.showAxisXTitle?t.axisXTitle:"",tickLabelProps:{className:"tickLabel"},labelOffset:50})]})}),T.length>1&&l(ie,{id:o,containerClassName:"legendContainer",references:T})]})},cr=({currentCircle:e,innerKey:t,cx:r,cy:o,color:a,setCurrentCircle:s})=>P(Pt,{children:[e.includes(t)&&l("circle",{r:6,cx:r,cy:o,stroke:`#${W(a).saturate(25).toHex()}`,fill:`#${W(a).saturate(25).toHex()}`}),l("circle",{r:3,cx:r,cy:o,stroke:`#${W(a).darken(15).toHex()}`,fill:`#${W(a).darken(15).toHex()}`}),l("circle",{r:10,cx:r,cy:o,stroke:"transparent",fill:"transparent",onMouseEnter:()=>{s([t])},onMouseLeave:()=>{s([])},style:{cursor:"pointer"}})]},t);var sr=Object.defineProperty,hr=Object.defineProperties,dr=Object.getOwnPropertyDescriptors,Ke=Object.getOwnPropertySymbols,mr=Object.prototype.hasOwnProperty,ur=Object.prototype.propertyIsEnumerable,Je=Math.pow,Qe=(e,t,r)=>t in e?sr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Pe=(e,t)=>{for(var r in t||(t={}))mr.call(t,r)&&Qe(e,r,t[r]);if(Ke)for(var r of Ke(t))ur.call(t,r)&&Qe(e,r,t[r]);return e},Ae=(e,t)=>hr(e,dr(t));function pr({width:e,height:t,maxWidth:r}){if(e<=r)return{width:e,height:t};const o=e/t,a=r,s=Math.floor(a/o);return{width:a,height:s}}function se(e){return e.key}function Z(e){return Number(e.value)}function gr(e){var t,r,o,a,s,i,d;const g=p((t=e.dataSets)==null?void 0:t.data),f=g.map(y=>y.sets).reduce((y,v)=>p(y).concat(v),[]);return{columns:g,xScale:Oe({domain:p(g[0].sets).map(se)}),yScale:pe({domain:[((r=ye(f,Z))!=null?r:0<0)&&(o=ye(f,Z))!=null?o:0,(a=Re(f,Z))!=null?a:1]}),yScaleLog:Ce({domain:[((s=ye(f,Z))!=null?s:1>0)&&(i=ye(f,Z))!=null?i:1,(d=Re(f,Z))!=null?d:10]})}}const fr=({chart:e,margin:t={top:20,left:100,bottom:150,right:70},chartId:r,allowZoom:o})=>{const a=ve(t);e.showAxisYTitle||(a.left=50);let s=e.ratio.width,i=e.ratio.height-(a.top+a.bottom)/2;if(s>e.ratio.maxWidth){const h=pr({height:i,width:s,maxWidth:e.ratio.maxWidth});s=h.width,i=h.height}const{columns:d,xScale:g,yScale:f,yScaleLog:y}=gr(e),v=xe(e.colorSchema),b=p(d[0].sets),k=d.map(h=>h.sets),S=s/b.length;g.range(b.map((h,C)=>C===0?a.left:C*S+a.left)),f.range([i-(a.top+a.bottom)/2,typeof a=="number"?a:a.top]),y.range([i,typeof a=="number"?a:a.top]);const[V,x]=H([]),u=B(()=>f,[f]),N=B(()=>`VerticalBars${ue()}`,[]);me(()=>{document.querySelectorAll(`#${N} .tickLabel`).forEach(h=>{const C=h.getBoundingClientRect().width;h.style.transformOrigin=h.getAttribute("x")+"px 14px",h.style.transform=`rotate(25deg) translateX(${C/2}px)`})});function L(h,C,_){return C.map((M,G)=>{const O=Math.floor(G/_),I=h[O];return Ae(Pe({},M),{columnName:I})})}const[A,Y]=H([]);Ee(()=>{const h=k.flat().map(M=>({xValue:M.key,yValue:M.value,x:g(se(M)),y:u(Z(M))})),C=d.map(M=>M.name),_=L(C,h,b.length);Y(_)},[]);const[R,K]=H([]),w=vt(R),T=p(e.dataSets.data).map((h,C)=>{const _=p(e.dataSets.data).length===1,M=h.color!==""&&h.color!==void 0?h.color:p(v.schema).length>0?ce(p(v.schema),C,_):"",G=[];return p(h.sets).forEach(O=>{O.color!==""&&O.color!==void 0?G.push(Ae(Pe({},O),{columnName:h.name})):G.push(Ae(Pe({},O),{color:M,columnName:h.name}))}),{returnColumnsArray:G,columnColor:M}}),m=T.map(h=>{var C;return{color:(C=h.columnColor)!=null?C:"",title:h.returnColumnsArray[0].columnName}});p(e.dataSets.data).map(h=>{const C=[];return p(h.sets).forEach(_=>{_.color!==""&&_.color!==void 0&&C.push({color:_.color,title:h.name+" - "+_.key})}),C}).flat().forEach(h=>m.push(h));const{open:c}=le({children:R.sort((h,C)=>Number(C.yValue)-Number(h.yValue)).map((h,C)=>{const _=m.some(M=>M.title===h.columnName+" - "+h.xValue);return P(D,{children:[l("div",{style:{color:m[m.findIndex(M=>M.title===(_?h.columnName+" - "+h.xValue:h.columnName))].color},children:l("strong",{children:h.columnName})}),e.showValues&&l("div",{children:h.yValue}),l("div",{children:h.xValue}),R[C+1]&&l("hr",{})]},`${h.columnName}_${h.xValue}_${h.yValue}`)})}),[n,$]=H("");re({highlight(h){h.split(" - ").length===1?$(h):h.split(" - ").length===2&&$(h.split(" - ")[0])}});const{boxRef:j,elementRef:E}=ae(void 0,!o);return P(q,{children:[l(D,{id:N,ref:j,children:P("svg",{ref:E,width:s,height:i,id:"LinesChart",className:`_${r} chart__svg`,onMouseMove:h=>{var C;const _=(C=E.current)==null?void 0:C.getBoundingClientRect();let M=h.clientX,G=h.clientY-(a.top+a.bottom)/2;_&&(M=h.clientX-_.left,G=h.clientY-_.top);const O=A.filter(I=>Math.sqrt(Je(I.x-M,2)+Je(I.y-G,2))<20);if(w.current&&O.length>0){const I=d.map(X=>{let z="";return O.forEach(F=>{X.name===F.columnName&&(z=F.columnName)}),z}).filter(X=>X!==""),J=b.findIndex(X=>X.key===O[0].xValue);if(I&&J!==void 0){const X=I.map(z=>`${z}${J}`);x([...X])}K(O),c({attachToElement:()=>h.target,attachToElementAnchorPoint:"center"})}else O.length===0&&x([])},children:[e.showGrid&&l(Ne.Grid,{top:(typeof a=="number"?a:a.top)-20,left:0,xScale:g,yScale:u,width:s,height:i,stroke:v.grid.stroke,strokeOpacity:v.grid.opacity}),d.map((h,C)=>{var _;const M=p(h.sets),G=(_=T.find(O=>O.returnColumnsArray[0].columnName===h.name))==null?void 0:_.columnColor;return P(Q,{top:(typeof a=="number"?a:a.top)-20,style:{opacity:n!==""&&n!==h.name?.15:1,transition:"opacity 500ms"},children:[l($t,{curve:Nt.curveMonotoneX,data:M,x:O=>{var I;return(I=g(se(O)))!=null?I:0},y:O=>{var I;return(I=u(Z(O)))!=null?I:0},stroke:G??"black",strokeWidth:2,strokeOpacity:1,shapeRendering:"geometricPrecision"}),M.map((O,I)=>{var J;const X=h.name+I.toString(),z=(J=T.map(F=>F.returnColumnsArray).flat().find(F=>F.columnName===h.name&&F.key===O.key))==null?void 0:J.color;return P("g",{children:[l("text",{x:g(se(O))+10,y:u(Z(O))-5,textAnchor:"middle",style:{display:n===h.name?"block":"none",opacity:n===h.name?1:0,transition:"opacity 500ms"},children:O.value}),l(cr,{color:z??"black",coordinate:O,currentCircle:V,cx:g(se(O)),cy:u(Z(O)),setCurrentCircle:x,innerKey:X,column:h})]},X)})]},`lines-${h.name+C.toString()}`)}),l(ge,{scale:u,left:a.left,label:e.chartType!=="pie2D"&&e.showAxisYTitle?e.axisYTitle:""}),l(fe,{top:i-(a.top+a.bottom)/2,scale:g,label:e.chartType!=="pie2D"&&e.showAxisXTitle?e.axisXTitle:"",tickLabelProps:{className:"tickLabel"},labelOffset:50})]})}),m.length>1&&l(ie,{id:r,containerClassName:"legendContainer",references:m})]})},yr=({width:e,height:t,x:r,y:o,fill:a,x1:s,lineY:i,x2:d,stroke:g,strokeDashArray:f,textX:y,textY:v,textContent:b,isLast:k,step:S,columnName:V,chart:x})=>{const{open:u}=le({children:P(q,{children:[l("div",{style:{color:S.color},children:l("strong",{children:V})}),x.showValues&&l("div",{children:S.y}),l("div",{children:S.x})]})});return P(q,{children:[l(D,{as:"rect",sx:B(()=>({width:`${e}px`,height:`${t}px`,x:`${r}px`,y:`${o}px`,fill:`${a}`,"&:hover":{fill:`#${W(a).saturate(25).toHex()}`},transition:"fill 500ms"}),[a,t,e,r,o]),onMouseEnter:N=>{u({attachToElement:()=>N.target,attachToElementAnchorPoint:"center"})},onMouseLeave:()=>{}}),!k&&l(kt,{x1:s,x2:d,y1:i,y2:i,stroke:g,strokeDasharray:f}),l("text",{textAnchor:"middle",x:y,y:v,children:b})]})};var vr=Object.defineProperty,xr=Object.defineProperties,br=Object.getOwnPropertyDescriptors,Se=Object.getOwnPropertySymbols,Ue=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable,tt=(e,t,r)=>t in e?vr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,wr=(e,t)=>{for(var r in t||(t={}))Ue.call(t,r)&&tt(e,r,t[r]);if(Se)for(var r of Se(t))et.call(t,r)&&tt(e,r,t[r]);return e},$r=(e,t)=>xr(e,br(t)),kr=(e,t)=>{var r={};for(var o in e)Ue.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&Se)for(var o of Se(e))t.indexOf(o)<0&&et.call(e,o)&&(r[o]=e[o]);return r};const Sr=({data:e,xAccessor:t,yAccessor:r,showFinal:o,colors:a})=>{let s=0;const i=e.map(d=>{const g=t(d),f=r(d),y=s;return s+=Number(f),{x:g,y:f,start:y,end:s,color:Number(f)>0?a.positive:a.negative}});return o&&i.push({x:"Total",y:s,start:0,end:s,color:a.total}),i};function Cr({width:e,height:t,maxWidth:r}){if(e<=r)return{width:e,height:t};const o=e/t,a=r,s=Math.floor(a/o);return{width:a,height:s}}const Or=e=>{var t=e,{margin:r={top:20,left:100,bottom:150,right:70},chart:o}=t,a=o,{waterfallColors:s={positive:"#49b86f",negative:"#c92e5b",total:"#434857",stepConnector:"#888d94"}}=a,i=kr(a,["waterfallColors"]),{className:d,chartId:g,allowZoom:f}=t,y;const v=ve(r);i.showAxisYTitle||(v.left=50);let b=i.ratio.width+(-v.left-v.right)/2,k=i.ratio.height+(-v.top-v.bottom)/2;if(b>i.ratio.maxWidth){const n=Cr({height:k,width:b,maxWidth:i.ratio.maxWidth});b=n.width,k=n.height}const S=n=>n.key,V=n=>n.value,x=p((y=i.dataSets)==null?void 0:y.data).filter(n=>!!n.sets).map(n=>$r(wr({},n),{coordinate:n.sets})),[u,N]=H("0"),L=x.map(n=>n.name),A=B(()=>{var n;return Sr({data:p(i.dataSets.data)[u].sets,xAccessor:S,yAccessor:V,showFinal:(n=i.showTotal)!=null?n:!0,colors:s})},[i.dataSets.data,i.showTotal,u,s]),Y=.2,R=oe({domain:A.map(n=>n.x),padding:Y,range:[0,b]}),K=B(()=>{const n=A.flatMap(E=>[E.start,E.end]),[$,j]=Ot(n);return $!=null&&j!=null?[$-5,j+5]:void 0},[A]),w=pe({domain:K,nice:!0,range:[k,0]}),T=B(()=>`VerticalBars${ue()}`,[]);me(()=>{document.querySelectorAll(`#${T} .tickLabel`).forEach(n=>{const $=n.getBoundingClientRect().width;n.style.transformOrigin=n.getAttribute("x")+"px 14px",n.style.transform=`rotate(25deg) translateX(${$/2}px)`})});const{boxRef:m,elementRef:c}=ae(void 0,!f);return P(q,{children:[x.length>1&&l(D,{className:"chart__combo__wrapper",children:l(Ye,{chartId:g,pieces:L,className:"chartSelectorCombo",current:u,setCurrent:N})}),l(D,{id:T,className:d,ref:m,children:l("svg",{height:i.ratio.height,width:i.ratio.width,ref:c,children:P(Q,{left:v.left,top:v.top,children:[l(At,{scale:w,width:b,strokeDasharray:"5"}),A.map((n,$)=>{var j;const E=R(n.x),h=w(Math.max(n.start,n.end));if(E==null||h==null)return null;const C=Math.abs(w(n.start)-w(n.end)),_=$===A.length-1,M=2,G=E+R.bandwidth()+M,O=E+R.bandwidth()/(1-Y)-M,I=n.end<n.start?h+C:h,J=10,X=w(n.end)+(n.y<0?J:-J);let z=0;return A.filter((F,Te)=>{var Me;return((Me=i.showTotal)==null||Me)&&!A[Te+1]?!1:Te<=$}).forEach(F=>{z+=Number(F.y)}),l(yr,{chart:i,columnName:L[u],fill:n.color,height:C,isLast:_,lineY:I,step:n,stroke:s.stepConnector,strokeDashArray:2,textContent:(j=i.showTotal)==null||j?n.y:z,textX:E+R.bandwidth()/2,textY:X+5,width:R.bandwidth(),x:E,y:h,x1:G,x2:O},$)}),l(ge,{label:"",scale:w,hideAxisLine:!0,hideTicks:!0,tickLabelProps:()=>({textAnchor:"end",verticalAnchor:"middle"})}),l(fe,{scale:R,top:k,tickLabelProps:()=>({textAnchor:"middle",verticalAnchor:"middle",className:"tickLabel"})})]})})}),l(ie,{id:g,avoidEvent:!0,references:[{title:p(i.dataSets.data)[u].name,color:"transparent"}]})]})};var Nr=Object.defineProperty,Pr=Object.defineProperties,Ar=Object.getOwnPropertyDescriptors,rt=Object.getOwnPropertySymbols,Tr=Object.prototype.hasOwnProperty,Mr=Object.prototype.propertyIsEnumerable,at=(e,t,r)=>t in e?Nr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Er=(e,t)=>{for(var r in t||(t={}))Tr.call(t,r)&&at(e,r,t[r]);if(rt)for(var r of rt(t))Mr.call(t,r)&&at(e,r,t[r]);return e},jr=(e,t)=>Pr(e,Ar(t));const he="hsl(196, 37%, 13%)";function _r(...e){return de.useCallback(function(t){e.forEach(r=>{r&&(r.current=t)})},[e])}const[,ot,Lr]=_e()({Component:gt("ChartRenderer","layout.charts",{red:{schema:"schemas.red"},orange:{schema:"schemas.orange"},green:{schema:"schemas.green"},blue:{schema:"schemas.blue"},violet:{schema:"schemas.violet"},turquoise:{schema:"schemas.turquoise"},yellow:{schema:"schemas.yellow"},grey:{schema:"schemas.grey"},ocean:{schema:"schemas.ocean"},sunset:{schema:"schemas.sunset"},common:{axis:{stroke:he,title:he},schema:he,background:"hsl(200deg 20% 98%)",grid:{stroke:he,opacity:"0.1"},toolTip:{backgroundColor:"rgb(232, 241, 255)",border:"1px solid #07c",color:he,padding:".3rem .5rem",borderRadius:"3px",fontSize:"18px",boxShadow:"0 1px 2px rgba(33,33,33,0.2)",lineHeight:"1em"}},".legendContainer":{display:"flex",flexDirection:"row",gap:je(3),flexWrap:"wrap"},".chart__combo__wrapper":{position:"absolute"}},de.forwardRef(({currentChart:e,chartId:t,allowZoom:r},o)=>{const a=de.useRef(null),s=_r(o,a),i=B(()=>({chartId:t}),[t]),d=xt([Ut,Ht,ir,fr,Or],[e.chartType==="pie2D",e.chartType==="barH2D",e.chartType==="barV2D",e.chartType==="linear",e.chartType==="waterfall"],0);return l(ne.Provider,{value:i,children:l(D,jr(Er({ref:s,className:"chart__chartRenderer"},ft("layout.charts")),{children:l(d,{chart:e,chartId:t,parentRef:a,allowZoom:r})}))})}),!0)});var Vr=Object.defineProperty,Rr=Object.defineProperties,Ir=Object.getOwnPropertyDescriptors,lt=Object.getOwnPropertySymbols,Br=Object.prototype.hasOwnProperty,Dr=Object.prototype.propertyIsEnumerable,nt=(e,t,r)=>t in e?Vr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,it=(e,t)=>{for(var r in t||(t={}))Br.call(t,r)&&nt(e,r,t[r]);if(lt)for(var r of lt(t))Dr.call(t,r)&&nt(e,r,t[r]);return e},ct=(e,t)=>Rr(e,Ir(t));const st=0,ht=360,Wr=({addBorder:e=!1,colorRanges:t,maxValue:r,minValue:o,currentValue:a,height:s,valueRanges:i,width:d,currentValueColor:g,currentValueFontSize:f})=>{const y=a,v=Math.min(s,d),b=r??i[i.length-1],k=o??i[0],S=Tt({domain:[k,b],startAngle:st,endAngle:ht,numTicks:0,diameter:v});function V(x){var u;const N=i.findIndex(L=>x<L);return N===-1?t[0]:(u=t[N-1])!=null?u:t[N]}return l(D,{children:P("svg",ct(it({},S.getSVGProps()),{viewBox:"-325 -325 600 600",children:[l("g",{id:"arcs",children:l("path",ct(it({},S.getArcProps({offset:20,startAngle:st,endAngle:ht})),{stroke:e?"black":"transparent",fill:V(y),strokeLinecap:"round",strokeWidth:5}))}),l("g",{children:l("text",{textAnchor:"middle",style:{fontSize:`${f??100}px`},alignmentBaseline:"central",fill:g,children:y})})]}))})},Hr=()=>{const e={addBorder:!0,backgColor:"white",currentValue:1010,height:400,width:400,maxValue:1050,minValue:1e3,noValueColor:"",pointerColor:"blue",ringAnchor:5,scaleFontSize:20,valueColor:"darkblue",valueDecimals:1,valueFontSize:50,valueType:"",widKpiType:0,zones:[{color:"blue",maximum:1020,minimum:1e3,transparency:20},{color:"purple",maximum:1040,minimum:1020,transparency:50},{color:"red",maximum:1050,minimum:1040,transparency:0}]},t=Array.from(new Set(p(e.zones).map(o=>[o.minimum,o.maximum]).flat().sort((o,a)=>o-a))),r=p(e.zones).map(o=>W(o.color).setAlpha(1-o.transparency/100).toPercentageRgbString()).flat();return l(D,{children:l(Wr,{addBorder:e.addBorder,backgroundColor:e.backgColor,colorRanges:r,currentValue:e.currentValue,decimals:e.valueDecimals,currentValueColor:e.valueColor,currentValueFontSize:e.valueFontSize,height:e.height,maxValue:e.maxValue,minValue:e.minValue,pointerColor:e.pointerColor,scaleValuesSize:e.scaleFontSize,valueRanges:t,width:e.width})})};export{Lr as ChartRenderer,Hr as WidgetContainer};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{jsx as n,jsxs as V,Fragment as Q}from"react/jsx-runtime";import ne,{createContext as rr,useContext as ge,useCallback as Se,useState as G,useMemo as H,useLayoutEffect as Ae,useRef as U,useEffect as Me,createElement as at}from"react";import{Box as D,Select as ar}from"theme-ui";import{ThemeProviderContext as nr,spacing as nt,makeStyledComponent as or,getVariant as lr}from"@apia/theme";import{uniqueId as Ce}from"lodash";import{makeImperativeComponent as ot,arrayOrArray as M,useImperativeComponentEvents as fe,getValueByPath as ir,usePanAndZoom as ye,animate as Ne,addBoundary as je,usePrevious as cr,getIndex as lt,noNaN as _}from"@apia/util";import{scaleBand as ve,scaleLog as He,scaleLinear as Ve,scaleOrdinal as Xe}from"@visx/scale";import{Grid as Ye}from"@visx/visx";import{Group as he}from"@visx/group";import{BarGroupHorizontal as sr,BarGroup as hr,LinePath as dr,Line as ur}from"@visx/shape";import{AxisLeft as Te,AxisBottom as Ee}from"@visx/axis";import{usePanelParametersSelector as it,usePanelIdentity as pr}from"@apia/dashboard";import X from"tinycolor2";import{localPoint as de}from"@visx/event";import{SimpleButton as mr,useTooltip as be}from"@apia/components";import{icons as gr}from"@apia/icons";import ct from"@visx/shape/lib/shapes/Pie";import{min as Re,max as st,extent as fr}from"d3-array";import*as yr from"@visx/curve";import{Fragment as vr}from"theme-ui/jsx-runtime";import{GridRows as br}from"@visx/grid";import{useGauge as oe}from"use-gauge";function Le(t={left:100,right:50,top:50,bottom:70}){return typeof t=="number"?{left:t,right:t,top:t,bottom:t}:t}const xe=rr({}),xr=({groupId:t,title:e,color:r,className:l,isHighlighted:a,isAnyHighlighted:i,avoidEvent:o})=>{const{chartId:s}=ge(xe),m=Se(()=>{o||Tt(s,"highlight",t)},[o,s,t]),p=Se(()=>{o||Tt(s,"highlight","")},[o,s]);return n(mr,{variant:"icon-outline",className:`${l??""} ${a?"highlight":""}`,iconColor:r||"black",icon:r==="transparent"?void 0:gr.SquareFilled,sx:{opacity:i&&!a?"0.15":"1"},onMouseEnter:m,onMouseLeave:p,children:e})},[ue,,$e]=ot()({initialState:{highlightedBarGroup:""},methods:{highlight(t,e){t({highlightedBarGroup:e})}},Component:({references:t,containerClassName:e,highlightedBarGroup:r,avoidEvent:l})=>n(D,{className:e,children:t.map(a=>n(xr,{isHighlighted:a.title===r,isAnyHighlighted:r!=="",groupId:a.title,color:a.color,title:a.title,avoidEvent:l??!1},a.title))})}),$r=({bar:t,barGroup:e,chart:r,parsedData:l,isSingle:a,effectiveMargin:i,setsWithColor:o})=>{var s;const m=M(r.dataSets.data)[t.index],p=M(m?.sets)[e.index],c=(s=o.find(g=>g.columnName===m.name&&g.key===p.key))==null?void 0:s.color,[y,f]=G(!1),[S,O]=G(!1),{open:A}=be({children:V(Q,{children:[n("div",{style:{color:c},children:n("strong",{children:l[e.index].columnName})}),r.showValues&&n("div",{children:t.value}),n("div",{children:t.key})]})});fe({highlight(g){g.split(" - ").length===1?(f(g===t.key),O(g!==t.key&&g!=="")):g.split(" - ").length===2&&(f(g.split(" - ")[0]===t.key&&g.split(" - ")[1]===p.key),O(g.split(" - ")[0]!==t.key&&g.split(" - ")[0]!==""))}});const{chartId:b}=ge(xe);return V("g",{children:[V("text",{x:t.x+5,y:t.y-5,width:t.width,height:t.height,textAnchor:"start",style:{display:y?"block":"none",opacity:y?1:0,transition:"opacity 500ms"},children:[t.value," - ",l[e.index].columnName]}),n(D,{as:"rect",className:"chart__barRect",sx:H(()=>({fill:S?`#${X(c).desaturate(70).toHex()}`:c,"&:hover":{fill:`#${X(c).saturate(25).toHex()}`},transition:"fill 500ms, opacity 500ms",x:t.x,y:t.y,width:t.width-i.left,opacity:S&&!y?.15:1,height:t.height>0?t.height:0}),[t.height,t.width,t.x,t.y,c,i.left,S,y]),onMouseEnter:g=>{var C,P,N;a||ue.highlight(b,t.key),(C=g.target.classList)==null||C.add("over"),(P=de(g))==null||P.x,(N=de(g))==null||N.y,A({attachToElement:()=>g.target,attachToElementAnchorPoint:"center"})},onMouseLeave:g=>{var C;a||ue.highlight(b,""),(C=g.target.classList)==null||C.remove("over")},children:n("animate",{attributeName:"width",from:0,to:t.width,dur:"0.5s",calcMode:"paced",keySplines:"0.5 0 0.5 1;",keyTimes:"0; 1"})})]})};function we(t,e,r=!1){const l=t.length;let a=0,i="";if(r)t[e]?i=t[e]:i=X(t[e%l]).toHex();else if(t[e])i=t[e];else{let o=e;for(;o>=l;)o=e/l,a++;i=X(t[e%l]).desaturate(a*5).toHex()}return i}var wr=Object.defineProperty,ht=Object.getOwnPropertySymbols,kr=Object.prototype.hasOwnProperty,Or=Object.prototype.propertyIsEnumerable,dt=(t,e,r)=>e in t?wr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ut=(t,e)=>{for(var r in e||(e={}))kr.call(e,r)&&dt(t,r,e[r]);if(ht)for(var r of ht(e))Or.call(e,r)&&dt(t,r,e[r]);return t};function _e(t){var e,r,l;const a=ge(nr);a.layout||console.error("The layout property is missing in the current theme");const i=(r=(e=a.layout)==null?void 0:e.charts)!=null?r:{},o=i.common,s={schema:ir(a.colors,(l=i[t||"blue"])==null?void 0:l.schema)};return ut(ut({},o),s)}var Pr=Object.defineProperty,Sr=Object.defineProperties,Ar=Object.getOwnPropertyDescriptors,pt=Object.getOwnPropertySymbols,Mr=Object.prototype.hasOwnProperty,Cr=Object.prototype.propertyIsEnumerable,mt=(t,e,r)=>e in t?Pr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ie=(t,e)=>{for(var r in e||(e={}))Mr.call(e,r)&&mt(t,r,e[r]);if(pt)for(var r of pt(e))Cr.call(e,r)&&mt(t,r,e[r]);return t},Be=(t,e)=>Sr(t,Ar(e));function Nr({width:t,height:e,maxWidth:r}){if(t<=r)return{width:t,height:e};const l=t/e,a=r,i=Math.floor(a/l);return{width:a,height:i}}const gt=t=>t.columnName,jr=({margin:t={top:20,left:50,bottom:150,right:20},chart:e,className:r,chartId:l,outerClassName:a,allowZoom:i})=>{var o;const s=Le(t);let m=e.ratio.width+(-s.left-s.right)/2,p=e.ratio.height+(-s.top-s.bottom)/2;if(m>e.ratio.maxWidth){const d=Nr({height:p,width:m,maxWidth:e.ratio.maxWidth});m=d.width,p=d.height}const c=M((o=e.dataSets)==null?void 0:o.data).filter(d=>!!d.sets).map(d=>Be(Ie({},d),{sets:d.sets})),y=M(c[0].sets).map(d=>d.key),f=c.map(d=>d.name),S=y.map(d=>c.reduce((h,j)=>Be(Ie({},h),{[j.name]:M(j.sets).filter(L=>L.key===d)[0].value}),{columnName:d})),O=ve({range:[typeof s=="number"?s:s.top,p],domain:S.map(gt),padding:.2}),A=ve({domain:f,range:[0,O.bandwidth()]}),b=He({range:[typeof s=="number"?s:s.left,m],domain:[1,Math.max(...S.map(d=>Math.max(...f.map(h=>Number(d[h])))))],base:10}),g=Ve({range:[typeof s=="number"?s:s.left,m],domain:[0,Math.max(...S.map(d=>Math.max(...f.map(h=>Number(d[h])))))]}),C=Xe({domain:f,range:c.map(d=>d.color)}),P=it(d=>d).PRMT_CHART_SCALE==="0",N=H(()=>P?b:g,[P,g,b]),T=H(()=>`VerticalBars${Ce()}`,[]);Ae(()=>{document.querySelectorAll(`#${T} .__${l??a}`).forEach(d=>{const h=d.getBoundingClientRect().width;d.style.transformOrigin=d.getAttribute("x")+"px 14px",d.style.transform=`rotate(15deg) translateX(${h/2}px)`})});const $=_e(e.colorSchema),{boxRef:k,elementRef:v}=ye(void 0,!i),w=M(e.dataSets.data).map((d,h)=>{const j=M(e.dataSets.data).length===1,L=d.color!==""&&d.color!==void 0?d.color:M($.schema).length>0?we(M($.schema),h,j):"",I=[];return M(d.sets).forEach(x=>{x.color!==""&&x.color!==void 0?I.push(Be(Ie({},x),{columnName:d.name})):I.push(Be(Ie({},x),{color:L,columnName:d.name}))}),I}),u=w.map(d=>{var h;return{color:(h=d[0].color)!=null?h:"",title:d[0].columnName}});return M(e.dataSets.data).map(d=>{const h=[];return M(d.sets).forEach(j=>{j.color!==""&&j.color!==void 0&&h.push({color:j.color,title:d.name+" - "+j.key})}),h}).flat().forEach(d=>u.push(d)),V(Q,{children:[n(D,{ref:k,id:T,className:`${a??""} ${l} ${e.title}`,sx:ne.useMemo(()=>({[`.__${l??a}`]:{transform:"rotate(45deg)",transformOrigin:"attr(x) 18px"},overflow:"auto",position:"relative",height:`${e.ratio.height}px`,width:`${e.ratio.width}px`}),[e.ratio.height,e.ratio.width,l,a]),children:V("svg",{ref:v,className:`_${l} ${r||""} chart__svg`,height:e.ratio.height,width:e.ratio.width,style:{position:"absolute"},children:[e.showGrid&&n(Ye.Grid,{xScale:N,yScale:O,left:0,width:m,height:p,numTicksRows:10,numTicksColumns:10,top:(typeof s=="number"?s:s.top)-20}),n(he,{top:(typeof s=="number"?s:s.top)-20,left:s.left,children:n(sr,{data:S,keys:f,width:m,y0:gt,y0Scale:O,y1Scale:A,xScale:N,color:C,children:d=>d.map(h=>n(he,{top:h.y0,children:h.bars.map(j=>{const L=`${h.index}-${j.index}-${j.key}`;return n($r,{isSingle:h.bars.length===1,bar:j,barGroup:h,chart:e,parsedData:S,effectiveMargin:s,setsWithColor:w.flat()},L)})},`bar-group-${h.index}-${h.y0}`))})}),n(Te,{scale:O,left:s.left,label:e.chartType!=="pie2D"&&e.showAxisYTitle?e.axisYTitle:"",tickLabelProps:()=>({display:"none"})}),n(Ee,{top:p,scale:N,label:e.chartType!=="pie2D"&&e.showAxisXTitle?e.axisXTitle:"",tickLabelProps:{className:"tickLabel"},labelOffset:50})]})}),u.length>1&&n($e,{id:l,containerClassName:"legendContainer",references:u})]})},Vr=({arc:t,arcPath:e,chart:r,actualColor:l})=>{const[a,i]=G(!1),[o,s]=G(!1),{open:m}=be({children:V(Q,{children:[n("div",{style:{color:`#${X(l).toHex()}`},children:n("strong",{children:t.data.key})}),r.showValues&&n("div",{children:`${t.value} ${t.data.percentage?"- "+t.data.percentage:""}${t.data.percentage?"%":""}`})]})});fe({highlight(y){i(y===t.data.key),s(y!==t.data.key&&y!=="")}});const{chartId:p}=ge(xe),c=t.data;return n("path",{id:`arc-${c.key}-${c.value}`,style:H(()=>({"&:hover":{fill:`#${X(l).saturate(25).toHex()}`},transition:"fill 500ms, opacity 500ms"}),[l]),fill:o?`#${X(l).desaturate(70).toHex()}`:l,opacity:o&&!a?.15:1,d:e??"",onMouseEnter:y=>{var f,S,O;ue.highlight(p,t.data.key),(f=y.target.classList)==null||f.add("over"),(S=de(y))==null||S.x,(O=de(y))==null||O.y,m({attachToElement:()=>y.target,attachToElementAnchorPoint:"center"})},onMouseLeave:y=>{var f;ue.highlight(p,""),(f=y.target.classList)==null||f.remove("over")}},`arc-${c.key}-${c.value}`)},Tr=({arc:t,x:e,y:r,dy:l})=>{const[a,i]=G(!1);return fe({highlight(o){i(o===t.data.key)}}),n("text",{textAnchor:"middle",style:{opacity:a?1:0,display:a?"block":"none",transition:"opacity 500ms"},x:e,y:r,dy:l,children:t.value})};var Er=Object.defineProperty,Rr=Object.defineProperties,Lr=Object.getOwnPropertyDescriptors,ft=Object.getOwnPropertySymbols,_r=Object.prototype.hasOwnProperty,Ir=Object.prototype.propertyIsEnumerable,yt=(t,e,r)=>e in t?Er(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,vt=(t,e)=>{for(var r in e||(e={}))_r.call(e,r)&&yt(t,r,e[r]);if(ft)for(var r of ft(e))Ir.call(e,r)&&yt(t,r,e[r]);return t},bt=(t,e)=>Rr(t,Lr(e));const Br=({incomingColumn:t,piezas:e,setDataset:r})=>{const l=U(void 0),a=U(void 0),i=U(!1);if(l.current&&e){const o=i.current&&a.current?M(a.current.coordinate):M(l.current.coordinate),s=M(t.sets);if(o.some((m,p)=>{const c=s[p];return m.value!==c.value})){i.current=!0;const m=[];for(let p=0;p<Math.max(o.length,s.length);p++){const c=o[p],y=s[p];if(c&&y){const f=Math.abs(parseInt(c.value)-parseInt(y.value)).toString(),S={key:y.key,color:y.color,value:f};m.push(S)}}return Ne(500,p=>{const c={color:e.color,name:t.name,sets:m.map((y,f)=>({key:y.key,color:y.color,percentage:y.percentage,value:je(Number(s[f].value)>Number(o[f].value)?Number(y.value)*p+Number(o[f].value):Number(o[f].value)-Number(y.value)*p,Math.min(Number(o[f].value),Number(s[f].value)),Math.max(Number(o[f].value),Number(s[f].value))).toString()}))};a.current={color:c.color,coordinate:c.sets,name:c.name},r([c])},()=>{const p=bt(vt({},t),{coordinate:t.sets});l.current=p,i.current=!1})}}else if(!l.current){const o=bt(vt({},t),{coordinate:t.sets});l.current=o,i.current=!1}};var Wr=Object.defineProperty,Dr=Object.defineProperties,zr=Object.getOwnPropertyDescriptors,xt=Object.getOwnPropertySymbols,Gr=Object.prototype.hasOwnProperty,Hr=Object.prototype.propertyIsEnumerable,$t=(t,e,r)=>e in t?Wr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xr=(t,e)=>{for(var r in e||(e={}))Gr.call(e,r)&&$t(t,r,e[r]);if(xt)for(var r of xt(e))Hr.call(e,r)&&$t(t,r,e[r]);return t},Yr=(t,e)=>Dr(t,zr(e));function Fr({width:t,height:e,maxWidth:r}){if(t<=r)return{width:t,height:e};const l=t/e,a=r,i=Math.floor(a/l);return{width:a,height:i}}const qr=({chart:t,className:e,chartId:r,allowZoom:l})=>{var a,i;const[o,s]=G(M((a=t.dataSets)==null?void 0:a.data)),m=H(()=>o.filter($=>!!$.sets).map($=>Yr(Xr({},$),{coordinate:$.sets}))[0],[o]);Br({incomingColumn:M((i=t.dataSets)==null?void 0:i.data)[0],piezas:m,setDataset:s});let p=t.ratio.width>t.ratio.height?t.ratio.width:t.ratio.height,c=t.ratio.width>t.ratio.height?t.ratio.width:t.ratio.height;if(p>t.ratio.maxWidth){const $=Fr({height:c,width:p,maxWidth:t.ratio.maxWidth});p=$.width,c=$.height}const y=H(()=>c/2.5,[c]),f=H(()=>p/2.5,[p]),S=y,O=f,A=$=>Number($.value)===0&&M(m.coordinate).length===1?100:Number($.value),b=Math.min(c,p)/2.5,g=_e(t.colorSchema).schema,C=M(o[0].sets).map($=>$.key).map(($,k)=>({title:$,color:we(M(g),k)})),{boxRef:P,elementRef:N}=ye(void 0,!l),T=U([]);return m?V(Q,{children:[n(D,{ref:P,className:`${e||""} ${r}`,sx:{textAlign:"center",pb:nt(5)},children:n("svg",{ref:N,height:b*2,width:b*2,className:`_${r} chart__svg`,children:V(he,{top:S??0,left:O??0,children:[n(ct,{data:M(m.coordinate),pieValue:A,pieSort:null,outerRadius:b,children:$=>{const k=M($.arcs).map(w=>$.path(w)),v=$.arcs.map(w=>{var u,d;const h=w.data,j=$.path(w);return n(Vr,{arc:w,arcPath:j,chart:t,actualColor:(d=(u=C.find(L=>L.title===h.key))==null?void 0:u.color)!=null?d:""},`${h.key}_${h.value}`)});return T.current=k,v}}),n(ct,{data:M(m.coordinate),pieValue:A,pieSort:null,outerRadius:b,children:$=>$.arcs.map(k=>{const v=k.data,w=(k.startAngle-Math.PI+k.endAngle)/2,u=Math.cos(w)*(b*.75),d=Math.sin(w)*(b*.75);return n("g",{children:n(Tr,{arc:k,chart:t,dy:"0.33em",x:u,y:d})},`arc-${v.key}-${v.value}`)})})]})})},m.name),C.length>1&&n($e,{id:r,containerClassName:"legendContainer",references:C})]}):null},Kr=({bar:t,barGroup:e,chart:r,parsedData:l,isSingle:a,setsWithColor:i})=>{var o;const s=M(r.dataSets.data)[t.index],m=M(s?.sets)[e.index],p=(o=i.find(b=>b.columnName===s.name&&b.key===m.key))==null?void 0:o.color,[c,y]=G(!1),[f,S]=G(!1),{open:O}=be({children:V(Q,{children:[n("div",{style:{color:p},children:n("strong",{children:l[e.index].columnName})}),r.showValues&&n("div",{children:t.value}),n("div",{children:t.key})]})});fe({highlight(b){b.split(" - ").length===1?(y(b===t.key),S(b!==t.key&&b!=="")):b.split(" - ").length===2&&(y(b.split(" - ")[0]===t.key&&b.split(" - ")[1]===m.key),S(b.split(" - ")[0]!==t.key&&b.split(" - ")[0]!==""))}});const{chartId:A}=ge(xe);return V("g",{children:[n("text",{x:t.x+t.width/2,y:t.y-5,width:t.width,height:t.height,textAnchor:"middle",style:{display:c?"block":"none",opacity:c?1:0,transition:"opacity 500ms"},children:t.value}),V(D,{as:"rect",className:"chart__barRect",sx:H(()=>({fill:f?`#${X(p).desaturate(70).toHex()}`:p,"&:hover":{fill:`#${X(p).saturate(25).toHex()}`},transition:"fill 500ms, opacity 500ms",x:t.x,y:t.y,width:t.width,opacity:f&&!c?.15:1,height:t.height>0?t.height:0}),[t.height,t.width,t.x,t.y,p,f,c]),onMouseEnter:b=>{var g,C,P;a||ue.highlight(A,t.key),(g=b.target.classList)==null||g.add("over"),(C=de(b))==null||C.x,(P=de(b))==null||P.y,O({attachToElement:()=>b.target,attachToElementAnchorPoint:"center"})},onMouseLeave:b=>{var g;a||ue.highlight(A,""),(g=b.target.classList)==null||g.remove("over")},children:[n("animate",{attributeName:"height",from:0,to:t.height,dur:"0.5s",calcMode:"paced",keySplines:"0.5 0 0.5 1;",keyTimes:"0; 1"}),n("animate",{attributeName:"y",from:t.y+t.height,to:t.y,dur:"0.5s",calcMode:"paced",keySplines:"0.5 0 0.5 1;",keyTimes:"0; 1"})]})]})};var Zr=Object.defineProperty,Jr=Object.defineProperties,Qr=Object.getOwnPropertyDescriptors,wt=Object.getOwnPropertySymbols,Ur=Object.prototype.hasOwnProperty,ea=Object.prototype.propertyIsEnumerable,kt=(t,e,r)=>e in t?Zr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,We=(t,e)=>{for(var r in e||(e={}))Ur.call(e,r)&&kt(t,r,e[r]);if(wt)for(var r of wt(e))ea.call(e,r)&&kt(t,r,e[r]);return t},De=(t,e)=>Jr(t,Qr(e));function ta({width:t,height:e,maxWidth:r}){if(t<=r)return{width:t,height:e};const l=t/e,a=r,i=Math.floor(a/l);return{width:a,height:i}}const Ot=t=>t.columnName,ra=({margin:t={top:20,left:100,bottom:150,right:20},chart:e,className:r,chartId:l,allowZoom:a})=>{var i;const o=Le(t);e.showAxisYTitle||(o.left=50);let s=e.ratio.width+(-o.left-o.right)/2,m=e.ratio.height+(-o.top-o.bottom)/2;if(s>e.ratio.maxWidth){const u=ta({height:m,width:s,maxWidth:e.ratio.maxWidth});s=u.width,m=u.height}const p=_e(e.colorSchema),c=M((i=e.dataSets)==null?void 0:i.data).filter(u=>!!u.sets).map(u=>De(We({},u),{sets:u.sets})),y=M(c[0].sets).map(u=>u.key),f=c.map(u=>u.name),S=y.map(u=>c.reduce((d,h)=>De(We({},d),{[h.name]:M(h.sets).filter(j=>j.key===u)[0].value}),{columnName:u})),O=ve({range:[typeof o=="number"?o:o.left,s],domain:S.map(Ot),padding:.2}),A=ve({domain:f,range:[0,O.bandwidth()]}),b=He({range:[m,typeof o=="number"?o:o.top],domain:[1,Math.max(...S.map(u=>Math.max(...f.map(d=>Number(u[d])))))],base:10}),g=Ve({range:[m,typeof o=="number"?o:o.top],domain:[0,Math.max(...S.map(u=>Math.max(...f.map(d=>Number(u[d])))))]}),C=Xe({domain:f,range:c.map(u=>u.color)}),P=it(u=>u).PRMT_CHART_SCALE==="0",N=H(()=>P?b:g,[P,g,b]),T=H(()=>`VerticalBars${Ce()}`,[]);Ae(()=>{document.querySelectorAll(`#${T} .tickLabel`).forEach(u=>{const d=u.getBoundingClientRect().width;u.style.transformOrigin=u.getAttribute("x")+"px 14px",u.style.transform=`rotate(25deg) translateX(${d/2}px)`})});const{boxRef:$,elementRef:k}=ye(void 0,!a),v=M(e.dataSets.data).map((u,d)=>{const h=M(e.dataSets.data).length===1,j=u.color!==""&&u.color!==void 0?u.color:M(p.schema).length>0?we(M(p.schema),d,h):"",L=[];return M(u.sets).forEach(I=>{I.color!==""&&I.color!==void 0?L.push(De(We({},I),{columnName:u.name})):L.push(De(We({},I),{color:j,columnName:u.name}))}),L}),w=M(e.dataSets.data).map((u,d)=>{const h=M(e.dataSets.data).length===1;return{color:u.color!==""&&u.color!==void 0?u.color:M(p.schema).length>0?we(M(p.schema),d,h):"",title:u.name}});return M(e.dataSets.data).map(u=>{const d=[];return M(u.sets).forEach(h=>{h.color!==""&&h.color!==void 0&&d.push({color:h.color,title:u.name+" - "+h.key})}),d}).flat().forEach(u=>w.push(u)),V(Q,{children:[n(D,{ref:$,id:T,className:`${r??""} ${e.title}`,sx:{overflow:"hidden"},children:V("svg",{ref:k,className:`_${l} chart__svg`,height:e.ratio.height,width:e.ratio.width,children:[e.showGrid&&n(Ye.Grid,{xScale:O,yScale:N,left:0,width:s,height:m,numTicksRows:10,numTicksColumns:10,top:(typeof o=="number"?o:o.top)-20}),n(he,{top:(typeof o=="number"?o:o.top)-20,children:n(hr,{data:S,keys:f,height:m,x0:Ot,x0Scale:O,x1Scale:A,yScale:N,color:C,children:u=>u.map(d=>n(he,{left:d.x0,children:d.bars.map(h=>{const j=`${d.index}-${h.index}-${h.key}`;return n(Kr,{isSingle:d.bars.length===1,bar:h,barGroup:d,chart:e,parsedData:S,setsWithColor:v.flat()},j)})},`bar-group-${d.index}-${d.x0}`))})}),n(Te,{scale:N,left:o.left,label:e.chartType!=="pie2D"&&e.showAxisYTitle?e.axisYTitle:""}),n(Ee,{top:m,scale:O,label:e.chartType!=="pie2D"&&e.showAxisXTitle?e.axisXTitle:"",tickLabelProps:{className:"tickLabel"},labelOffset:50})]})}),w.length>1&&n($e,{id:l,containerClassName:"legendContainer",references:w})]})},aa=({currentCircle:t,innerKey:e,cx:r,cy:l,color:a,setCurrentCircle:i})=>V(vr,{children:[t.includes(e)&&n("circle",{r:6,cx:r,cy:l,stroke:`#${X(a).saturate(25).toHex()}`,fill:`#${X(a).saturate(25).toHex()}`}),n("circle",{r:3,cx:r,cy:l,stroke:`#${X(a).darken(15).toHex()}`,fill:`#${X(a).darken(15).toHex()}`}),n("circle",{r:10,cx:r,cy:l,stroke:"transparent",fill:"transparent",onMouseEnter:()=>{i([e])},onMouseLeave:()=>{i([])},style:{cursor:"pointer"}})]},e);var na=Object.defineProperty,oa=Object.defineProperties,la=Object.getOwnPropertyDescriptors,Pt=Object.getOwnPropertySymbols,ia=Object.prototype.hasOwnProperty,ca=Object.prototype.propertyIsEnumerable,St=Math.pow,At=(t,e,r)=>e in t?na(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Fe=(t,e)=>{for(var r in e||(e={}))ia.call(e,r)&&At(t,r,e[r]);if(Pt)for(var r of Pt(e))ca.call(e,r)&&At(t,r,e[r]);return t},qe=(t,e)=>oa(t,la(e));function sa({width:t,height:e,maxWidth:r}){if(t<=r)return{width:t,height:e};const l=t/e,a=r,i=Math.floor(a/l);return{width:a,height:i}}function ke(t){return t.key}function ee(t){return Number(t.value)}function ha(t){var e,r,l,a,i,o,s;const m=M((e=t.dataSets)==null?void 0:e.data),p=m.map(c=>c.sets).reduce((c,y)=>M(c).concat(y),[]);return{columns:m,xScale:Xe({domain:M(m[0].sets).map(ke)}),yScale:Ve({domain:[((r=Re(p,ee))!=null?r:0<0)&&(l=Re(p,ee))!=null?l:0,(a=st(p,ee))!=null?a:1]}),yScaleLog:He({domain:[((i=Re(p,ee))!=null?i:1>0)&&(o=Re(p,ee))!=null?o:1,(s=st(p,ee))!=null?s:10]})}}const da=({chart:t,margin:e={top:20,left:100,bottom:150,right:70},chartId:r,allowZoom:l})=>{const a=Le(e);t.showAxisYTitle||(a.left=50);let i=t.ratio.width,o=t.ratio.height-(a.top+a.bottom)/2;if(i>t.ratio.maxWidth){const x=sa({height:o,width:i,maxWidth:t.ratio.maxWidth});i=x.width,o=x.height}const{columns:s,xScale:m,yScale:p,yScaleLog:c}=ha(t),y=_e(t.colorSchema),f=M(s[0].sets),S=s.map(x=>x.sets),O=i/f.length;m.range(f.map((x,E)=>E===0?a.left:E*O+a.left)),p.range([o-(a.top+a.bottom)/2,typeof a=="number"?a:a.top]),c.range([o,typeof a=="number"?a:a.top]);const[A,b]=G([]),g=H(()=>p,[p]),C=H(()=>`VerticalBars${Ce()}`,[]);Ae(()=>{document.querySelectorAll(`#${C} .tickLabel`).forEach(x=>{const E=x.getBoundingClientRect().width;x.style.transformOrigin=x.getAttribute("x")+"px 14px",x.style.transform=`rotate(25deg) translateX(${E/2}px)`})});function P(x,E,W){return E.map((B,Y)=>{const R=Math.floor(Y/W),z=x[R];return qe(Fe({},B),{columnName:z})})}const[N,T]=G([]);Me(()=>{const x=S.flat().map(B=>({xValue:B.key,yValue:B.value,x:m(ke(B)),y:g(ee(B))})),E=s.map(B=>B.name),W=P(E,x,f.length);T(W)},[]);const[$,k]=G([]),v=cr($),w=M(t.dataSets.data).map((x,E)=>{const W=M(t.dataSets.data).length===1,B=x.color!==""&&x.color!==void 0?x.color:M(y.schema).length>0?we(M(y.schema),E,W):"",Y=[];return M(x.sets).forEach(R=>{R.color!==""&&R.color!==void 0?Y.push(qe(Fe({},R),{columnName:x.name})):Y.push(qe(Fe({},R),{color:B,columnName:x.name}))}),{returnColumnsArray:Y,columnColor:B}}),u=w.map(x=>{var E;return{color:(E=x.columnColor)!=null?E:"",title:x.returnColumnsArray[0].columnName}});M(t.dataSets.data).map(x=>{const E=[];return M(x.sets).forEach(W=>{W.color!==""&&W.color!==void 0&&E.push({color:W.color,title:x.name+" - "+W.key})}),E}).flat().forEach(x=>u.push(x));const{open:d}=be({children:$.sort((x,E)=>Number(E.yValue)-Number(x.yValue)).map((x,E)=>{const W=u.some(B=>B.title===x.columnName+" - "+x.xValue);return V(D,{children:[n("div",{style:{color:u[u.findIndex(B=>B.title===(W?x.columnName+" - "+x.xValue:x.columnName))].color},children:n("strong",{children:x.columnName})}),t.showValues&&n("div",{children:x.yValue}),n("div",{children:x.xValue}),$[E+1]&&n("hr",{})]},`${x.columnName}_${x.xValue}_${x.yValue}`)})}),[h,j]=G("");fe({highlight(x){x.split(" - ").length===1?j(x):x.split(" - ").length===2&&j(x.split(" - ")[0])}});const{boxRef:L,elementRef:I}=ye(void 0,!l);return V(Q,{children:[n(D,{id:C,ref:L,children:V("svg",{ref:I,width:i,height:o,id:"LinesChart",className:`_${r} chart__svg`,onMouseMove:x=>{var E;const W=(E=I.current)==null?void 0:E.getBoundingClientRect();let B=x.clientX,Y=x.clientY-(a.top+a.bottom)/2;W&&(B=x.clientX-W.left,Y=x.clientY-W.top);const R=N.filter(z=>Math.sqrt(St(z.x-B,2)+St(z.y-Y,2))<20);if(v.current&&R.length>0){const z=s.map(F=>{let Z="";return R.forEach(J=>{F.name===J.columnName&&(Z=J.columnName)}),Z}).filter(F=>F!==""),ae=f.findIndex(F=>F.key===R[0].xValue);if(z&&ae!==void 0){const F=z.map(Z=>`${Z}${ae}`);b([...F])}k(R),d({attachToElement:()=>x.target,attachToElementAnchorPoint:"center"})}else R.length===0&&b([])},children:[t.showGrid&&n(Ye.Grid,{top:(typeof a=="number"?a:a.top)-20,left:0,xScale:m,yScale:g,width:i,height:o,stroke:y.grid.stroke,strokeOpacity:y.grid.opacity}),s.map((x,E)=>{var W;const B=M(x.sets),Y=(W=w.find(R=>R.returnColumnsArray[0].columnName===x.name))==null?void 0:W.columnColor;return V(he,{top:(typeof a=="number"?a:a.top)-20,style:{opacity:h!==""&&h!==x.name?.15:1,transition:"opacity 500ms"},children:[n(dr,{curve:yr.curveMonotoneX,data:B,x:R=>{var z;return(z=m(ke(R)))!=null?z:0},y:R=>{var z;return(z=g(ee(R)))!=null?z:0},stroke:Y??"black",strokeWidth:2,strokeOpacity:1,shapeRendering:"geometricPrecision"}),B.map((R,z)=>{var ae;const F=x.name+z.toString(),Z=(ae=w.map(J=>J.returnColumnsArray).flat().find(J=>J.columnName===x.name&&J.key===R.key))==null?void 0:ae.color;return V("g",{children:[n("text",{x:m(ke(R))+10,y:g(ee(R))-5,textAnchor:"middle",style:{display:h===x.name?"block":"none",opacity:h===x.name?1:0,transition:"opacity 500ms"},children:R.value}),n(aa,{color:Z??"black",coordinate:R,currentCircle:A,cx:m(ke(R)),cy:g(ee(R)),setCurrentCircle:b,innerKey:F,column:x})]},F)})]},`lines-${x.name+E.toString()}`)}),n(Te,{scale:g,left:a.left,label:t.chartType!=="pie2D"&&t.showAxisYTitle?t.axisYTitle:""}),n(Ee,{top:o-(a.top+a.bottom)/2,scale:m,label:t.chartType!=="pie2D"&&t.showAxisXTitle?t.axisXTitle:"",tickLabelProps:{className:"tickLabel"},labelOffset:50})]})}),u.length>1&&n($e,{id:r,containerClassName:"legendContainer",references:u})]})};function ua({chartId:t,pieces:e,className:r,current:l,setCurrent:a}){return V(ar,{sx:{width:"auto"},name:`chartSelector_${t}`,className:`chartSelector_${t} ${r??""}`,value:l??"0",onChange:i=>{i.preventDefault(),a(i.target.value)},children:[e.map((i,o)=>({label:i,value:`${o}`})).map(i=>n("option",{value:i.value,children:i.label},i.value))," "]})}const pa=({width:t,height:e,x:r,y:l,fill:a,x1:i,lineY:o,x2:s,stroke:m,strokeDashArray:p,textX:c,textY:y,textContent:f,isLast:S,step:O,columnName:A,chart:b})=>{const{open:g}=be({children:V(Q,{children:[n("div",{style:{color:O.color},children:n("strong",{children:A})}),b.showValues&&n("div",{children:O.y}),n("div",{children:O.x})]})});return V(Q,{children:[n(D,{as:"rect",sx:H(()=>({width:`${t}px`,height:`${e}px`,x:`${r}px`,y:`${l}px`,fill:`${a}`,"&:hover":{fill:`#${X(a).saturate(25).toHex()}`},transition:"fill 500ms"}),[a,e,t,r,l]),onMouseEnter:C=>{g({attachToElement:()=>C.target,attachToElementAnchorPoint:"center"})},onMouseLeave:()=>{}}),!S&&n(ur,{x1:i,x2:s,y1:o,y2:o,stroke:m,strokeDasharray:p}),n("text",{textAnchor:"middle",x:c,y,children:f})]})};var ma=Object.defineProperty,ga=Object.defineProperties,fa=Object.getOwnPropertyDescriptors,ze=Object.getOwnPropertySymbols,Mt=Object.prototype.hasOwnProperty,Ct=Object.prototype.propertyIsEnumerable,Nt=(t,e,r)=>e in t?ma(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ya=(t,e)=>{for(var r in e||(e={}))Mt.call(e,r)&&Nt(t,r,e[r]);if(ze)for(var r of ze(e))Ct.call(e,r)&&Nt(t,r,e[r]);return t},va=(t,e)=>ga(t,fa(e)),ba=(t,e)=>{var r={};for(var l in t)Mt.call(t,l)&&e.indexOf(l)<0&&(r[l]=t[l]);if(t!=null&&ze)for(var l of ze(t))e.indexOf(l)<0&&Ct.call(t,l)&&(r[l]=t[l]);return r};const xa=({data:t,xAccessor:e,yAccessor:r,showFinal:l,colors:a})=>{let i=0;const o=t.map(s=>{const m=e(s),p=r(s),c=i;return i+=Number(p),{x:m,y:p,start:c,end:i,color:Number(p)>0?a.positive:a.negative}});return l&&o.push({x:"Total",y:i,start:0,end:i,color:a.total}),o};function $a({width:t,height:e,maxWidth:r}){if(t<=r)return{width:t,height:e};const l=t/e,a=r,i=Math.floor(a/l);return{width:a,height:i}}const wa=t=>{var e=t,{margin:r={top:20,left:100,bottom:150,right:70},chart:l}=e,a=l,{waterfallColors:i={positive:"#49b86f",negative:"#c92e5b",total:"#434857",stepConnector:"#888d94"}}=a,o=ba(a,["waterfallColors"]),{className:s,chartId:m,allowZoom:p}=e,c;const y=Le(r);o.showAxisYTitle||(y.left=50);let f=o.ratio.width+(-y.left-y.right)/2,S=o.ratio.height+(-y.top-y.bottom)/2;if(f>o.ratio.maxWidth){const h=$a({height:S,width:f,maxWidth:o.ratio.maxWidth});f=h.width,S=h.height}const O=h=>h.key,A=h=>h.value,b=M((c=o.dataSets)==null?void 0:c.data).filter(h=>!!h.sets).map(h=>va(ya({},h),{coordinate:h.sets})),[g,C]=G("0"),P=b.map(h=>h.name),N=H(()=>{var h;return xa({data:M(o.dataSets.data)[g].sets,xAccessor:O,yAccessor:A,showFinal:(h=o.showTotal)!=null?h:!0,colors:i})},[o.dataSets.data,o.showTotal,g,i]),T=.2,$=ve({domain:N.map(h=>h.x),padding:T,range:[0,f]}),k=H(()=>{const h=N.flatMap(I=>[I.start,I.end]),[j,L]=fr(h);return j!=null&&L!=null?[j-5,L+5]:void 0},[N]),v=Ve({domain:k,nice:!0,range:[S,0]}),w=H(()=>`VerticalBars${Ce()}`,[]);Ae(()=>{document.querySelectorAll(`#${w} .tickLabel`).forEach(h=>{const j=h.getBoundingClientRect().width;h.style.transformOrigin=h.getAttribute("x")+"px 14px",h.style.transform=`rotate(25deg) translateX(${j/2}px)`})});const{boxRef:u,elementRef:d}=ye(void 0,!p);return V(Q,{children:[b.length>1&&n(D,{className:"chart__combo__wrapper",children:n(ua,{chartId:m,pieces:P,className:"chartSelectorCombo",current:g,setCurrent:C})}),n(D,{id:w,className:s,ref:u,children:n("svg",{height:o.ratio.height,width:o.ratio.width,ref:d,children:V(he,{left:y.left,top:y.top,children:[n(br,{scale:v,width:f,strokeDasharray:"5"}),N.map((h,j)=>{var L;const I=$(h.x),x=v(Math.max(h.start,h.end));if(I==null||x==null)return null;const E=Math.abs(v(h.start)-v(h.end)),W=j===N.length-1,B=2,Y=I+$.bandwidth()+B,R=I+$.bandwidth()/(1-T)-B,z=h.end<h.start?x+E:x,ae=10,F=v(h.end)+(h.y<0?ae:-ae);let Z=0;return N.filter((J,tt)=>{var rt;return((rt=o.showTotal)==null||rt)&&!N[tt+1]?!1:tt<=j}).forEach(J=>{Z+=Number(J.y)}),n(pa,{chart:o,columnName:P[g],fill:h.color,height:E,isLast:W,lineY:z,step:h,stroke:i.stepConnector,strokeDashArray:2,textContent:(L=o.showTotal)==null||L?h.y:Z,textX:I+$.bandwidth()/2,textY:F+5,width:$.bandwidth(),x:I,y:x,x1:Y,x2:R},j)}),n(Te,{label:"",scale:v,hideAxisLine:!0,hideTicks:!0,tickLabelProps:()=>({textAnchor:"end",verticalAnchor:"middle"})}),n(Ee,{scale:$,top:S,tickLabelProps:()=>({textAnchor:"middle",verticalAnchor:"middle",className:"tickLabel"})})]})})}),n($e,{id:m,avoidEvent:!0,references:[{title:M(o.dataSets.data)[g].name,color:"transparent"}]})]})};var ka=Object.defineProperty,Oa=Object.defineProperties,Pa=Object.getOwnPropertyDescriptors,jt=Object.getOwnPropertySymbols,Sa=Object.prototype.hasOwnProperty,Aa=Object.prototype.propertyIsEnumerable,Vt=(t,e,r)=>e in t?ka(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ma=(t,e)=>{for(var r in e||(e={}))Sa.call(e,r)&&Vt(t,r,e[r]);if(jt)for(var r of jt(e))Aa.call(e,r)&&Vt(t,r,e[r]);return t},Ca=(t,e)=>Oa(t,Pa(e));const Oe="hsl(196, 37%, 13%)";function Na(...t){return ne.useCallback(function(e){t.forEach(r=>{r&&(r.current=e)})},[t])}const[,Tt,ja]=ot()({Component:or("ChartRenderer","layout.charts",{red:{schema:"schemas.red"},orange:{schema:"schemas.orange"},green:{schema:"schemas.green"},blue:{schema:"schemas.blue"},violet:{schema:"schemas.violet"},turquoise:{schema:"schemas.turquoise"},yellow:{schema:"schemas.yellow"},grey:{schema:"schemas.grey"},ocean:{schema:"schemas.ocean"},sunset:{schema:"schemas.sunset"},common:{axis:{stroke:Oe,title:Oe},schema:Oe,background:"hsl(200deg 20% 98%)",grid:{stroke:Oe,opacity:"0.1"},toolTip:{backgroundColor:"rgb(232, 241, 255)",border:"1px solid #07c",color:Oe,padding:".3rem .5rem",borderRadius:"3px",fontSize:"18px",boxShadow:"0 1px 2px rgba(33,33,33,0.2)",lineHeight:"1em"}},".legendContainer":{display:"flex",flexDirection:"row",gap:nt(3),flexWrap:"wrap"},".chart__combo__wrapper":{position:"absolute"}},ne.forwardRef(({currentChart:t,chartId:e,allowZoom:r},l)=>{const a=ne.useRef(null),i=Na(l,a),o=H(()=>({chartId:e}),[e]),s=lt([qr,jr,ra,da,wa],[t.chartType==="pie2D",t.chartType==="barH2D",t.chartType==="barV2D",t.chartType==="linear",t.chartType==="waterfall"],0);return n(xe.Provider,{value:o,children:n(D,Ca(Ma({ref:i,className:"chart__chartRenderer"},lr("layout.charts")),{children:n(s,{chart:t,chartId:e,parentRef:a,allowZoom:r})}))})}),!0)});var Va=Object.defineProperty,Ta=Object.defineProperties,Ea=Object.getOwnPropertyDescriptors,Et=Object.getOwnPropertySymbols,Ra=Object.prototype.hasOwnProperty,La=Object.prototype.propertyIsEnumerable,Rt=(t,e,r)=>e in t?Va(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,le=(t,e)=>{for(var r in e||(e={}))Ra.call(e,r)&&Rt(t,r,e[r]);if(Et)for(var r of Et(e))La.call(e,r)&&Rt(t,r,e[r]);return t},pe=(t,e)=>Ta(t,Ea(e));const Pe=90,Ge=270,_a=({currentValue:t,currentValueFontSize:e,height:r,maxValue:l,minValue:a,pointerColor:i,scaleValuesSize:o,valueRanges:s,width:m})=>{var p,c;const y=t,f=Math.min(r,m),S=(p=_(l))!=null?p:s[s.length-1],O=(c=_(a))!=null?c:s[0],A=20,b=oe({domain:[O,S],startAngle:Pe,endAngle:Ge,numTicks:10+1,diameter:f});oe({domain:[s[0],s[s.length-1]],startAngle:Pe,endAngle:Ge,numTicks:s[s.length-1]-s[0]+1,diameter:f});const g=b.getNeedleProps({value:0,baseRadius:12,tipRadius:2}),C=(Ge-Pe)*y/(S-O);return n(D,{children:V("svg",pe(le({},b.getSVGProps()),{height:Math.max(m,r),width:Math.max(m,r),viewBox:`-${f/2+A} -${f/2+A} ${f+A*2} ${f/2+A*2}`,children:[n("g",{id:"arcs",children:n("path",pe(le({},b.getArcProps({offset:A-5,startAngle:90,endAngle:270})),{stroke:"gray",opacity:"0.2",fill:"none",strokeLinecap:"round",strokeWidth:5}))}),V("g",{id:"ticks",children:[b.ticks.map(P=>{const N=($=>{const k=Ge-Pe,v=S-O,w=O+($-Pe)/k*v;return Math.round(w)})(P),T=N%10===0;return V(ne.Fragment,{children:[n("line",le({stroke:"gray",strokeWidth:T?4:2},b.getTickProps({angle:P,length:T?12:3}))),T&&n("text",pe(le({fill:"black"},b.getLabelProps({angle:P,offset:20})),{style:{fontSize:`${o??30}px`},children:N}))]},`tick-group-${P}`)}),!1]}),V("g",{id:"needle",children:[n("circle",pe(le({fill:i},g.base),{r:20})),n("circle",le({fill:i},g.base)),n("circle",pe(le({fill:i,opacity:"0.5"},g.tip),{style:{transform:`rotate(${C}deg)`,transition:"transform 500ms"}})),n("polyline",{style:{transform:`rotate(${C}deg)`,transition:"transform 500ms"},fill:i,opacity:"0.5",points:g.points}),n("circle",pe(le({fill:"white"},g.base),{r:4}))]}),n("g",{children:n("text",{textAnchor:"middle",style:{fontSize:`${e??30}px`},y:-f/4+20,children:y})})]}))})};var Ia=Object.defineProperty,Ba=Object.defineProperties,Wa=Object.getOwnPropertyDescriptors,Lt=Object.getOwnPropertySymbols,Da=Object.prototype.hasOwnProperty,za=Object.prototype.propertyIsEnumerable,_t=(t,e,r)=>e in t?Ia(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,te=(t,e)=>{for(var r in e||(e={}))Da.call(e,r)&&_t(t,r,e[r]);if(Lt)for(var r of Lt(e))za.call(e,r)&&_t(t,r,e[r]);return t},ie=(t,e)=>Ba(t,Wa(e));const ce=30,me=330,Ga=({backgroundColor:t,colorRanges:e,currentValue:r,currentValueColor:l,currentValueFontSize:a,height:i,maxValue:o,minValue:s,pointerColor:m,scaleValuesSize:p,valueRanges:c,width:y})=>{var f,S;const O=r,A=Math.min(i,y),b=(f=_(o))!=null?f:c[c.length-1],g=(S=_(s))!=null?S:c[0],C=20,P=oe({domain:[g,b],startAngle:ce,endAngle:me,numTicks:c[c.length-1]/10+1,diameter:A}),N=P.getNeedleProps({value:0,baseRadius:12,tipRadius:2});function T(k){const v=c.findIndex(w=>k<=w);return v===-1?e[0]:e[v]}const $=(me-ce)*O/(b-g);return n(D,{children:V("svg",ie(te({},P.getSVGProps()),{height:Math.max(y,i),width:Math.max(y,i),viewBox:`-${A/2+C} -${A/2+C} ${A+C*2} ${A+C*2}`,children:[V("g",{id:"arcs",children:[n("path",ie(te({},P.getArcProps({offset:C-5,startAngle:0,endAngle:360})),{stroke:"gray",fill:t??"none",strokeLinecap:"round",strokeWidth:5})),c.map((k,v)=>{const w=u=>{const d=me-ce,h=b-g,j=ce+(u-g)/h*d;return Math.round(j)};return V("g",{children:[n("path",ie(te({},P.getArcProps({offset:-50,startAngle:v===0?ce:w(k),endAngle:v===0?w(c[1]):v===c.length-1?me:w(c[v+1])})),{stroke:T(k),opacity:"0.8",fill:"none",strokeLinecap:"round",strokeWidth:2})),at("path",ie(te({},P.getArcProps({offset:-55,startAngle:v===0?ce:w(k),endAngle:v===0?w(c[1]):v===c.length-1?me:w(c[v+1])})),{key:`${k}_${v}`,stroke:T(k),opacity:"0.8",fill:"none",strokeLinecap:"round",strokeWidth:2}))]},`${k}_${v}`)})]}),n("g",{id:"ticks",children:P.ticks.map(k=>{const v=(u=>{const d=me-ce,h=b-g,j=g+(u-ce)/d*h;return Math.round(j)})(k),w=v%10===0;return V(ne.Fragment,{children:[n("line",te({stroke:"gray",strokeWidth:w?4:2},P.getTickProps({angle:k,length:w?12:3}))),w&&n("text",ie(te({fill:"black"},P.getLabelProps({angle:k,offset:20})),{style:{fontSize:`${p??30}px`},children:v}))]},`tick-group-${k}`)})}),V("g",{id:"needle",children:[n("circle",ie(te({fill:m},N.base),{r:20})),n("circle",te({fill:m},N.base)),n("circle",ie(te({fill:m,opacity:"0.5"},N.tip),{style:{transform:`rotate(${$}deg)`,transition:"transform 500ms"}})),n("polyline",{style:{transform:`rotate(${$}deg)`,transition:"transform 500ms"},fill:m,opacity:"0.5",points:N.points}),n("circle",ie(te({fill:"white"},N.base),{r:4}))]}),n("g",{children:n("text",{textAnchor:"middle",y:A/2,fill:l,style:{fontSize:`${a??30}px`},children:O})})]}))})};var Ha=Object.defineProperty,Xa=Object.defineProperties,Ya=Object.getOwnPropertyDescriptors,It=Object.getOwnPropertySymbols,Fa=Object.prototype.hasOwnProperty,qa=Object.prototype.propertyIsEnumerable,Bt=(t,e,r)=>e in t?Ha(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ke=(t,e)=>{for(var r in e||(e={}))Fa.call(e,r)&&Bt(t,r,e[r]);if(It)for(var r of It(e))qa.call(e,r)&&Bt(t,r,e[r]);return t},Ze=(t,e)=>Xa(t,Ya(e));const Je=0,Qe=360,Ka=({addBorder:t=!1,colorRanges:e,maxValue:r,minValue:l,currentValue:a,height:i,valueRanges:o,width:s,currentValueColor:m,currentValueFontSize:p})=>{var c,y;const[f,S]=G(a),O=Math.min(i,s),A=(c=_(r))!=null?c:o[o.length-1],b=(y=_(l))!=null?y:o[0],g=oe({domain:[b,A],startAngle:Je,endAngle:Qe,numTicks:0,diameter:O});function C($){var k;const v=o.findIndex(w=>$<w);return v===-1?e[0]:(k=e[v-1])!=null?k:e[v]}const P=U(!1),N=Se($=>{if(!$||P.current)return;P.current=!0;const k=$,v=$.querySelector("#TLight_arcs");if(!(k&&v))return;const w=v.getBoundingClientRect(),u=k.getBoundingClientRect(),d=w.width,h=w.height,j=w.x-u.x,L=w.y-u.y,I=`${j-O/2} ${L-O/2} ${d} ${h}`;k.setAttribute("viewBox",I),k.style.visibility="visible"},[O]),T=U(0);return Me(()=>{const $=a-T.current;return Ne(500,k=>{const v=je($*k+T.current,b,A);S(Math.round(v))},()=>{T.current=a})},[a]),n(D,{children:V("svg",Ze(Ke({},g.getSVGProps()),{style:{visibility:"hidden"},height:Math.max(s,i),width:Math.max(s,i),id:"TLight_svg",ref:N,viewBox:`-${O/2} -${O/2} ${O} ${O}`,children:[V("g",{id:"TLight_arcs",children:[n("path",Ze(Ke({},g.getArcProps({startAngle:Je,endAngle:Qe})),{fill:C(f),id:"TLight_path",style:{transition:"fill 0.3s"}})),t&&n("path",Ze(Ke({},g.getArcProps({offset:-2.5,startAngle:Je,endAngle:Qe})),{stroke:"black",fill:"transparent",strokeLinecap:"round",strokeWidth:5,id:"TLight_path"}))]}),n("g",{children:n("text",{textAnchor:"middle",style:{fontSize:`${p??100}pt`},alignmentBaseline:"central",fill:m,children:f})})]}))})};var Za=Object.defineProperty,Ja=Object.defineProperties,Qa=Object.getOwnPropertyDescriptors,Wt=Object.getOwnPropertySymbols,Ua=Object.prototype.hasOwnProperty,en=Object.prototype.propertyIsEnumerable,Dt=(t,e,r)=>e in t?Za(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,q=(t,e)=>{for(var r in e||(e={}))Ua.call(e,r)&&Dt(t,r,e[r]);if(Wt)for(var r of Wt(e))en.call(e,r)&&Dt(t,r,e[r]);return t},K=(t,e)=>Ja(t,Qa(e));const re=45,se=315,tn=({backgroundColor:t,colorRanges:e,currentValue:r,currentValueColor:l,currentValueFontSize:a,height:i,maxValue:o,minValue:s,pointerColor:m,scaleValuesSize:p,valueRanges:c,width:y})=>{var f,S;const O=r,A=Math.min(i,y),b=(f=_(o))!=null?f:c[c.length-1],g=(S=_(s))!=null?S:c[0],C=20,P=oe({domain:[g,b],startAngle:re,endAngle:se,numTicks:10+1,diameter:A}),N=oe({domain:[c[0],c[c.length-1]],startAngle:re,endAngle:se,numTicks:c[c.length-1]-c[0]+1,diameter:A}),T=P.getNeedleProps({value:0,baseRadius:12,tipRadius:2}),$=(se-re)*O/(b-g);function k(v){const w=c.findIndex(u=>v<=u);return w===-1?e[0]:e[w]}return n(D,{children:V("svg",K(q({},P.getSVGProps()),{height:Math.max(y,i),width:Math.max(y,i),viewBox:`-${A/2+C} -${A/2+C} ${A+C*2} ${A+C*2}`,children:[V("g",{id:"arcs",children:[n("path",K(q({},P.getArcProps({offset:C-5,startAngle:0,endAngle:360})),{stroke:"black",opacity:"1",fill:t!==""&&t!==void 0?X(t).setAlpha(.5).toPercentageRgbString():"none",strokeLinecap:"round",strokeWidth:5,vectorEffect:"non-scaling-stroke"})),c.map((v,w)=>{if(!c[w+1])return null;const u=d=>{const h=se-re,j=b-g,L=re+(d-g)/j*h;return Math.round(L)};return V("g",{children:[n("path",K(q({},P.getArcProps({offset:C-5,startAngle:w===0?re:u(v),endAngle:w===0?u(c[1]):w===c.length-1?se:u(c[w+1])})),{stroke:"black",opacity:"0.8",fill:"none",strokeLinecap:"square",strokeWidth:5,vectorEffect:"non-scaling-stroke"})),n("path",K(q({},P.getArcProps({offset:-20,startAngle:w===0?re:u(v),endAngle:w===0?u(c[1]):w===c.length-1?se:u(c[w+1])})),{stroke:k(v),opacity:"0.1",fill:"none",strokeLinecap:"butt",strokeWidth:75,vectorEffect:"non-scaling-stroke"})),at("path",K(q({},P.getArcProps({offset:-55,startAngle:w===0?re:u(v),endAngle:w===0?u(c[1]):w===c.length-1?se:u(c[w+1])})),{key:`${v}_${w}`,stroke:k(v)||"#999",opacity:"0.8",fill:"none",strokeLinecap:"butt",strokeWidth:10,vectorEffect:"non-scaling-stroke"}))]},`${v}_${w}`)})]}),V("g",{id:"ticks",children:[P.ticks.map((v,w)=>{const u=(h=>{const j=se-re,L=b-g,I=g+(h-re)/j*L;return Math.round(I)})(v),d=u%10===0;return V(ne.Fragment,{children:[n("line",K(q({stroke:"gray",strokeWidth:d?4:2},P.getTickProps({angle:v,length:d?12:3})),{vectorEffect:"non-scaling-stroke"})),d&&n("text",K(q({fill:"black"},P.getLabelProps({angle:v,offset:20})),{style:{fontSize:`${p??30}px`},children:u}))]},`tick-group-${v}_ ${w}`)}),N.ticks.map((v,w)=>n(ne.Fragment,{children:n("line",K(q({stroke:"gray",strokeWidth:2},P.getTickProps({angle:v,length:3})),{vectorEffect:"non-scaling-stroke"}))},`tick-group-${v}_ ${w}_2`))]}),V("g",{id:"needle",children:[n("circle",K(q({fill:m},T.base),{r:20})),n("circle",q({fill:m},T.base)),n("circle",K(q({fill:m,opacity:"0.5"},T.tip),{style:{transform:`rotate(${$}deg)`,transition:"transform 500ms"}})),n("polyline",{style:{transform:`rotate(${$}deg)`,transition:"transform 500ms"},fill:m,opacity:"0.5",points:T.points}),n("circle",K(q({fill:"white"},T.base),{r:4}))]}),n("g",{children:n("text",{textAnchor:"middle",alignmentBaseline:"text-before-edge",y:A/5,style:{fontSize:`${a??30}px`},fill:l,children:O})})]}))})};var rn=Object.defineProperty,an=Object.defineProperties,nn=Object.getOwnPropertyDescriptors,zt=Object.getOwnPropertySymbols,on=Object.prototype.hasOwnProperty,ln=Object.prototype.propertyIsEnumerable,Gt=(t,e,r)=>e in t?rn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ht=(t,e)=>{for(var r in e||(e={}))on.call(e,r)&&Gt(t,r,e[r]);if(zt)for(var r of zt(e))ln.call(e,r)&&Gt(t,r,e[r]);return t},Xt=(t,e)=>an(t,nn(e));const Yt=0,Ft=360,cn=({addBorder:t=!1,colorRanges:e,currentValue:r,height:l,valueRanges:a,width:i,maxValue:o,minValue:s,currentValueFontSize:m,panelId:p})=>{var c,y;const[f,S]=G(r),O=Math.min(l,i),A=20,b=(c=_(o))!=null?c:a[a.length-1],g=(y=_(s))!=null?y:a[0],C=oe({domain:[g,b],startAngle:Yt,endAngle:Ft,numTicks:0,diameter:O});function P(T){var $;const k=a.findIndex(v=>T<=v);return k===-1?e[0]:($=e[k-1])!=null?$:e[k]}const N=U(0);return Me(()=>{const T=r-N.current;return Ne(500,$=>{const k=je(T*$+N.current,g,b);S(Math.round(k))},()=>{N.current=r})},[r]),V(D,{sx:{position:"relative"},children:[n("svg",Xt(Ht({},C.getSVGProps()),{height:Math.max(i,l),width:Math.max(i,l),viewBox:`-${O/2+A} -${O/2+A} ${O+A*2} ${O+A*2}`,children:n("g",{id:"arcs",children:t&&n("path",Xt(Ht({},C.getArcProps({offset:A-5,startAngle:Yt,endAngle:Ft})),{stroke:"gray",opacity:"0.2",fill:"none",strokeLinecap:"round",strokeWidth:2}))})})),n("svg",{height:Math.max(i,l),width:Math.max(i,l),style:{position:"absolute",left:0},children:n("text",{x:Math.max(i,l)/2,y:Math.max(i,l)/2,textAnchor:"middle",style:{fontSize:`${m??30}px`,transition:"fill 0.5s"},alignmentBaseline:"central",fill:P(f),id:`text_${p}`,children:f})})]})};var sn=Object.defineProperty,hn=Object.defineProperties,dn=Object.getOwnPropertyDescriptors,qt=Object.getOwnPropertySymbols,un=Object.prototype.hasOwnProperty,pn=Object.prototype.propertyIsEnumerable,Kt=(t,e,r)=>e in t?sn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ue=(t,e)=>{for(var r in e||(e={}))un.call(e,r)&&Kt(t,r,e[r]);if(qt)for(var r of qt(e))pn.call(e,r)&&Kt(t,r,e[r]);return t},et=(t,e)=>hn(t,dn(e));const Zt=0,Jt=360,mn=({colorRanges:t,maxValue:e,minValue:r,currentValue:l,height:a,valueRanges:i,ringEmptyColor:o,ringWidth:s,width:m,currentValueColor:p,currentValueFontSize:c})=>{var y,f,S,O,A,b;const[g,C]=G(l),P=Math.min(a,m),N=20,T=(y=_(e))!=null?y:i[i.length-1],$=(f=_(r))!=null?f:i[0],k=oe({domain:[$,T],startAngle:Zt,endAngle:Jt,numTicks:0,diameter:P}),v=U(0);Me(()=>{const d=l-v.current;return Ne(500,h=>{const j=je(d*h+v.current,$,T);C(Math.round(j))},()=>{v.current=l})},[l]);function w(d){var h;const j=i.findIndex(L=>d<=L);return j===-1?t[0]:(h=t[j-1])!=null?h:t[j]}const u=d=>{const h=T-$,j=(d-$)/h*360;return Math.round(j)};return n(D,{children:V("svg",et(Ue({},k.getSVGProps()),{height:Math.max(m,a),width:Math.max(m,a),viewBox:`-${P/2+N} -${P/2+N} ${P+N*2} ${P+N*2}`,children:[V("g",{id:"arcs",children:[n("path",et(Ue({},k.getArcProps({offset:N-((S=_(s))!=null?S:0)*100,startAngle:Zt,endAngle:Jt})),{stroke:o??"transparent",fill:"none",strokeLinecap:"round",strokeWidth:((O=_(s))!=null?O:0)*100})),n("path",et(Ue({},k.getArcProps({offset:N-((A=_(s))!=null?A:0)*100,startAngle:180,endAngle:u(g)===360?179+u(g):180+u(g)})),{stroke:w(g),opacity:"0.8",fill:"none",strokeLinecap:"square",strokeWidth:((b=_(s))!=null?b:0)*100,style:{transition:"stroke 0.5s"}}))]}),n("g",{children:n("text",{textAnchor:"middle",style:{fontSize:`${c??30}px`},alignmentBaseline:"central",color:p,children:g})})]}))})},gn=(t,e,r)=>{let l="";return t.forEach((a,i)=>{a>=r&&t[i-1]<=r&&(l=e[i-1])}),l};function fn(t,e,r){const l=t.findIndex(a=>r<=a);return l===-1?e[0]:e[l]}function yn(t,e,r){var l;const a=t.findIndex(i=>r<i);return a===-1?e[0]:(l=e[a-1])!=null?l:e[a]}const vn=(t,e,r)=>{const l=t-(e??0),a=100-(r-(e??0))/l*100;return Math.round(a)},bn=(t,e,r)=>{const l=t-(e??0),a=(100-(r-(e??0))/l*100)*69/100;return Math.round(a)},xn=({maxValue:t,minValue:e,currentValue:r,panelId:l})=>{const a=e,i=t,[o,s]=G(0),m=U({}),p=U({}),c=Se(g=>{if(!g)return;const C=g.closest("svg"),P=C?.querySelector(`#path_${l}`);if(!C)throw new Error("No svg");if(!P)throw new Error("No path");const N=C.getBoundingClientRect(),T=P.getBoundingClientRect(),$=T.y-N.y;m.current=N,p.current=T,s($)},[l]),y=_(p.current.x-m.current.x),f=_(p.current.y-m.current.y),S=_(p.current.width),O=_(p.current.height),A=`${y} ${f} ${S} ${O}`,b={y:_(bn(i,a,r)*O/100+o),x:y,width:S,height:O,style:{visibility:"visible",transition:"y 0.5s, fill 0.5s"}};return{rectRef:c,svgViewBox:A,rectProps:b,pathX:y,pathY:f,pathRect:p,svgRect:m}};var $n=Object.defineProperty,Qt=Object.getOwnPropertySymbols,wn=Object.prototype.hasOwnProperty,kn=Object.prototype.propertyIsEnumerable,Ut=(t,e,r)=>e in t?$n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,On=(t,e)=>{for(var r in e||(e={}))wn.call(e,r)&&Ut(t,r,e[r]);if(Qt)for(var r of Qt(e))kn.call(e,r)&&Ut(t,r,e[r]);return t};const Pn=({colorRanges:t,maxValue:e,minValue:r,currentValue:l,height:a,valueRanges:i,width:o,panelId:s,currentValueFontSize:m})=>{var p,c,y;const f=l,S=(p=_(r))!=null?p:i[0],O=(c=_(e))!=null?c:i[i.length-1],A="m 179.6875,717.73633 c -0.45013,0 -0.8125,0.36237 -0.8125,0.8125 l 0,8.46289 a 2.3125,2.3125 0 0 0 -1.5,2.16211 2.3125,2.3125 0 0 0 2.3125,2.3125 2.3125,2.3125 0 0 0 2.3125,-2.3125 2.3125,2.3125 0 0 0 -1.5,-2.16211 l 0,-8.46289 c 0,-0.45013 -0.36237,-0.8125 -0.8125,-0.8125 z",{rectProps:b,rectRef:g,svgViewBox:C,pathX:P,pathY:N}=xn({currentValue:f,maxValue:O,minValue:S,panelId:s}),T={height:_(Math.max(o,a)-Math.max(o,a)*.31),width:_(Math.max(o,a)),x:P,y:N},$=i.map((k,v)=>({height:T.height*(vn(O,S,k)/100),color:i[v+1]?gn(i,t,k):"black",value:k}));return V(D,{sx:{position:"relative"},children:[V("svg",{height:Math.max(o,a),width:Math.max(o,a),id:`svg_${s}`,viewBox:C,style:{position:"relative",top:"10px"},children:[n("clipPath",{id:"clipPath",children:n("path",{d:A})}),n("mask",{id:"myMask",children:n("path",{d:A,id:"maskPath",fill:"white"})}),n("path",{d:A,id:`path_${s}`,fill:"white"}),n("rect",On({fill:yn(i,t,f),id:`rect_${s}`,mask:"url(#myMask)",ref:g},b)),n("path",{d:A,id:"path",fill:"none",stroke:"white",strokeWidth:10,clipPath:"url(#clipPath)",vectorEffect:"non-scaling-stroke"}),n("path",{clipPath:"url(#clipPath)",d:A,id:"path",fill:"none",stroke:"black",strokeWidth:5,vectorEffect:"non-scaling-stroke"})]}),V("svg",{height:Math.max(o,a)+10,width:Math.max(o,a),style:{position:"absolute",left:0,top:0},children:[T.x&&n("g",{children:n("text",{x:Math.max(o,a)/2,y:Math.max(o,a)-Math.max(o,a)/6+10,style:{fontSize:`${(y=_(m))!=null?y:50}px`},textAnchor:"middle",alignmentBaseline:"central",vectorEffect:"non-scaling-stroke",children:f})}),$.map((k,v)=>V("g",{children:[n("rect",{x:v===0?Math.max(o,a)/2+30:Math.max(o,a)/2+20,y:k.height+10,width:"15px",height:"3px",vectorEffect:"non-scaling-stroke",fill:fn(i,t,k.value)}),n("text",{x:v===0?Math.max(o,a)-Math.max(o,a)/3+10:Math.max(o,a)-Math.max(o,a)/3,y:$[v+1]?k.height+16:k.height+1.5,textAnchor:"middle",alignmentBaseline:$[v+1]?"auto":"text-before-edge",children:k.value})]},v))]})]})};var Sn=Object.defineProperty,er=Object.getOwnPropertySymbols,An=Object.prototype.hasOwnProperty,Mn=Object.prototype.propertyIsEnumerable,tr=(t,e,r)=>e in t?Sn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Cn=(t,e)=>{for(var r in e||(e={}))An.call(e,r)&&tr(t,r,e[r]);if(er)for(var r of er(e))Mn.call(e,r)&&tr(t,r,e[r]);return t};const Nn=({data:t})=>{const e=Cn({},t),r=Array.from(new Set(M(e.zones.Zone).map(o=>[Number(o.minimum),Number(o.maximum)]).flat().sort((o,s)=>o-s))),l=M(e.zones.Zone).map(o=>X(o.color).setAlpha(1-(255-o.transparency)/255).toPercentageRgbString()).flat(),a=lt([Ga,tn,cn,Ka,Pn,_a,mn],[e.widKpiType==="1",e.widKpiType==="2",e.widKpiType==="3",e.widKpiType==="4",e.widKpiType==="5",e.widKpiType==="6",e.widKpiType==="7"],0),i=pr();return n(D,{children:n(a,{addBorder:e.border,backgroundColor:e.backgroundColor,colorRanges:l,currentValue:Number(e.currentValue),decimals:e.valueDecimals,currentValueColor:e.valueColor,currentValueFontSize:e.valueFontSize,forceProp:e.forceProp,height:e.height,panelId:i.panelId,maxValue:e.maxValue,minValue:e.minValue,pointerColor:e.pointerColor,ringEmptyColor:e.noValueColor,ringWidth:e.ringAnchor,scaleValuesSize:e.scaleFontSize,valueRanges:r,width:e.width})})};export{ja as ChartRenderer,Nn as WidgetContainer};
|