@verifiedinc-public/shared-ui-elements 3.6.0 → 3.8.1
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.
@@ -0,0 +1,19 @@
|
|
1
|
+
import { ComponentProps, ReactElement } from 'react';
|
2
|
+
import { SxProps } from '@mui/material';
|
3
|
+
import { ReferenceLine, XAxis, YAxis } from 'recharts';
|
4
|
+
interface Series {
|
5
|
+
key: string;
|
6
|
+
dataKey: string;
|
7
|
+
color?: string;
|
8
|
+
}
|
9
|
+
interface SimpleBarChartProps {
|
10
|
+
data: Array<Record<string, number | string>>;
|
11
|
+
series: Series[];
|
12
|
+
xAxisDataKey: string;
|
13
|
+
xAxisProps?: ComponentProps<typeof XAxis>;
|
14
|
+
yAxisProps?: ComponentProps<typeof YAxis>;
|
15
|
+
referenceLines?: Array<ComponentProps<typeof ReferenceLine>>;
|
16
|
+
sx?: SxProps;
|
17
|
+
}
|
18
|
+
export declare function SimpleBarChart({ data, series, xAxisDataKey, xAxisProps, yAxisProps, referenceLines, sx, }: SimpleBarChartProps): ReactElement;
|
19
|
+
export {};
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";import{j as l}from"../../shared/jsx-runtime-jmtevAuS.mjs";import*as A from"react";import{useCallback as Y,useMemo as H,createElement as Ne}from"react";import{Box as J,Stack as z,Typography as R,useTheme as le,Paper as _e}from"@mui/material";import{ResponsiveContainer as ce,LineChart as Te,CartesianGrid as ue,XAxis as pe,YAxis as de,Label as Ee,Tooltip as me,Legend as Ce,Line as Ge,AreaChart as Ae,Area as Le}from"recharts";import{b as fe,c as he}from"../../shared/date-Cq0LS2Mr.mjs";import K,{Decimal as Q}from"decimal.js";import{AnimatePresence as De}from"framer-motion";import{u as Me}from"../../shared/useCopyToClipboard-BALOSYVW.mjs";import"qrcode";import{u as ee}from"../../shared/usePrevious-DyvR1iCQ.mjs";import{a as Re,C as ye}from"../../shared/motions-CpxgbzKX.mjs";import{i as Fe,_ as P,s as We,a as d,c as be,d as Ie,e as Ve,f as qe,h as ze,j as Ke,k as Pe,l as Be,m as Ue,n as Ze,o as Xe,p as Ye,u as He}from"../../shared/index-CDq4CkLc.mjs";import{u as Je}from"../../shared/useCounter-BV32zXDQ.mjs";const Qe=["ownerState"],en=["variants"],nn=["name","slot","skipVariantsResolver","skipSx","overridesResolver"];function tn(e){return Object.keys(e).length===0}function on(e){return typeof e=="string"&&e.charCodeAt(0)>96}function ne(e){return e!=="ownerState"&&e!=="theme"&&e!=="sx"&&e!=="as"}const rn=be(),an=e=>e&&e.charAt(0).toLowerCase()+e.slice(1);function B({defaultTheme:e,theme:n,themeId:t}){return tn(n)?e:n[t]||n}function sn(e){return e?(n,t)=>t[e]:null}function U(e,n){let{ownerState:t}=n,o=P(n,Qe);const r=typeof e=="function"?e(d({ownerState:t},o)):e;if(Array.isArray(r))return r.flatMap(a=>U(a,d({ownerState:t},o)));if(r&&typeof r=="object"&&Array.isArray(r.variants)){const{variants:a=[]}=r;let i=P(r,en);return a.forEach(c=>{let s=!0;typeof c.props=="function"?s=c.props(d({ownerState:t},o,t)):Object.keys(c.props).forEach(u=>{t?.[u]!==c.props[u]&&o[u]!==c.props[u]&&(s=!1)}),s&&(Array.isArray(i)||(i=[i]),i.push(typeof c.style=="function"?c.style(d({ownerState:t},o,t)):c.style))}),i}return r}function ln(e={}){const{themeId:n,defaultTheme:t=rn,rootShouldForwardProp:o=ne,slotShouldForwardProp:r=ne}=e,a=i=>Ie(d({},i,{theme:B(d({},i,{defaultTheme:t,themeId:n}))}));return a.__mui_systemSx=!0,(i,c={})=>{Fe(i,p=>p.filter(w=>!(w!=null&&w.__mui_systemSx)));const{name:s,slot:u,skipVariantsResolver:m,skipSx:f,overridesResolver:y=sn(an(u))}=c,h=P(c,nn),x=m!==void 0?m:u&&u!=="Root"&&u!=="root"||!1,b=f||!1;let S,j=ne;u==="Root"||u==="root"?j=o:u?j=r:on(i)&&(j=void 0);const N=We(i,d({shouldForwardProp:j,label:S},h)),W=p=>typeof p=="function"&&p.__emotion_real!==p||Ve(p)?w=>U(p,d({},w,{theme:B({theme:w.theme,defaultTheme:t,themeId:n})})):p,E=(p,...w)=>{let D=W(p);const _=w?w.map(W):[];s&&y&&_.push(g=>{const v=B(d({},g,{defaultTheme:t,themeId:n}));if(!v.components||!v.components[s]||!v.components[s].styleOverrides)return null;const k=v.components[s].styleOverrides,C={};return Object.entries(k).forEach(([Z,q])=>{C[Z]=U(q,d({},g,{theme:v}))}),y(g,C)}),s&&!x&&_.push(g=>{var v;const k=B(d({},g,{defaultTheme:t,themeId:n})),C=k==null||(v=k.components)==null||(v=v[s])==null?void 0:v.variants;return U({variants:C},d({},g,{theme:k}))}),b||_.push(a);const I=_.length-w.length;if(Array.isArray(p)&&I>0){const g=new Array(I).fill("");D=[...p,...g],D.raw=[...p.raw,...g]}const V=N(D,..._);return i.muiName&&(V.muiName=i.muiName),V};return N.withConfig&&(E.withConfig=N.withConfig),E}}const cn=ln(),un=(e,n)=>e.filter(t=>n.includes(t)),L=(e,n,t)=>{const o=e.keys[0];Array.isArray(n)?n.forEach((r,a)=>{t((i,c)=>{a<=e.keys.length-1&&(a===0?Object.assign(i,c):i[e.up(e.keys[a])]=c)},r)}):n&&typeof n=="object"?(Object.keys(n).length>e.keys.length?e.keys:un(e.keys,Object.keys(n))).forEach(r=>{if(e.keys.indexOf(r)!==-1){const a=n[r];a!==void 0&&t((i,c)=>{o===r?Object.assign(i,c):i[e.up(r)]=c},a)}}):(typeof n=="number"||typeof n=="string")&&t((r,a)=>{Object.assign(r,a)},n)};function $(e){return e?`Level${e}`:""}function F(e){return e.unstable_level>0&&e.container}function ge(e){return function(n){return`var(--Grid-${n}Spacing${$(e.unstable_level)})`}}function te(e){return function(n){return e.unstable_level===0?`var(--Grid-${n}Spacing)`:`var(--Grid-${n}Spacing${$(e.unstable_level-1)})`}}function oe(e){return e.unstable_level===0?"var(--Grid-columns)":`var(--Grid-columns${$(e.unstable_level-1)})`}const pn=({theme:e,ownerState:n})=>{const t=ge(n),o={};return L(e.breakpoints,n.gridSize,(r,a)=>{let i={};a===!0&&(i={flexBasis:0,flexGrow:1,maxWidth:"100%"}),a==="auto"&&(i={flexBasis:"auto",flexGrow:0,flexShrink:0,maxWidth:"none",width:"auto"}),typeof a=="number"&&(i={flexGrow:0,flexBasis:"auto",width:`calc(100% * ${a} / ${oe(n)}${F(n)?` + ${t("column")}`:""})`}),r(o,i)}),o},dn=({theme:e,ownerState:n})=>{const t={};return L(e.breakpoints,n.gridOffset,(o,r)=>{let a={};r==="auto"&&(a={marginLeft:"auto"}),typeof r=="number"&&(a={marginLeft:r===0?"0px":`calc(100% * ${r} / ${oe(n)})`}),o(t,a)}),t},mn=({theme:e,ownerState:n})=>{if(!n.container)return{};const t=F(n)?{[`--Grid-columns${$(n.unstable_level)}`]:oe(n)}:{"--Grid-columns":12};return L(e.breakpoints,n.columns,(o,r)=>{o(t,{[`--Grid-columns${$(n.unstable_level)}`]:r})}),t},fn=({theme:e,ownerState:n})=>{if(!n.container)return{};const t=te(n),o=F(n)?{[`--Grid-rowSpacing${$(n.unstable_level)}`]:t("row")}:{};return L(e.breakpoints,n.rowSpacing,(r,a)=>{var i;r(o,{[`--Grid-rowSpacing${$(n.unstable_level)}`]:typeof a=="string"?a:(i=e.spacing)==null?void 0:i.call(e,a)})}),o},hn=({theme:e,ownerState:n})=>{if(!n.container)return{};const t=te(n),o=F(n)?{[`--Grid-columnSpacing${$(n.unstable_level)}`]:t("column")}:{};return L(e.breakpoints,n.columnSpacing,(r,a)=>{var i;r(o,{[`--Grid-columnSpacing${$(n.unstable_level)}`]:typeof a=="string"?a:(i=e.spacing)==null?void 0:i.call(e,a)})}),o},yn=({theme:e,ownerState:n})=>{if(!n.container)return{};const t={};return L(e.breakpoints,n.direction,(o,r)=>{o(t,{flexDirection:r})}),t},bn=({ownerState:e})=>{const n=ge(e),t=te(e);return d({minWidth:0,boxSizing:"border-box"},e.container&&d({display:"flex",flexWrap:"wrap"},e.wrap&&e.wrap!=="wrap"&&{flexWrap:e.wrap},{margin:`calc(${n("row")} / -2) calc(${n("column")} / -2)`},e.disableEqualOverflow&&{margin:`calc(${n("row")} * -1) 0px 0px calc(${n("column")} * -1)`}),(!e.container||F(e))&&d({padding:`calc(${t("row")} / 2) calc(${t("column")} / 2)`},(e.disableEqualOverflow||e.parentDisableEqualOverflow)&&{padding:`${t("row")} 0px 0px ${t("column")}`}))},gn=e=>{const n=[];return Object.entries(e).forEach(([t,o])=>{o!==!1&&o!==void 0&&n.push(`grid-${t}-${String(o)}`)}),n},vn=(e,n="xs")=>{function t(o){return o===void 0?!1:typeof o=="string"&&!Number.isNaN(Number(o))||typeof o=="number"&&o>0}if(t(e))return[`spacing-${n}-${String(e)}`];if(typeof e=="object"&&!Array.isArray(e)){const o=[];return Object.entries(e).forEach(([r,a])=>{t(a)&&o.push(`spacing-${r}-${String(a)}`)}),o}return[]},xn=e=>e===void 0?[]:typeof e=="object"?Object.entries(e).map(([n,t])=>`direction-${n}-${t}`):[`direction-xs-${String(e)}`],wn=["className","children","columns","container","component","direction","wrap","spacing","rowSpacing","columnSpacing","disableEqualOverflow","unstable_level"],On=be(),Sn=cn("div",{name:"MuiGrid",slot:"Root",overridesResolver:(e,n)=>n.root});function jn(e){return Be({props:e,name:"MuiGrid",defaultTheme:On})}function kn(e={}){const{createStyledComponent:n=Sn,useThemeProps:t=jn,componentName:o="MuiGrid"}=e,r=A.createContext(void 0),a=(s,u)=>{const{container:m,direction:f,spacing:y,wrap:h,gridSize:x}=s,b={root:["root",m&&"container",h!=="wrap"&&`wrap-xs-${String(h)}`,...xn(f),...gn(x),...m?vn(y,u.breakpoints.keys[0]):[]]};return Ue(b,S=>Ze(o,S),{})},i=n(mn,hn,fn,pn,yn,bn,dn),c=A.forwardRef(function(s,u){var m,f,y,h,x,b,S,j;const N=qe(),W=t(s),E=ze(W),p=A.useContext(r),{className:w,children:D,columns:_=12,container:I=!1,component:V="div",direction:g="row",wrap:v="wrap",spacing:k=0,rowSpacing:C=k,columnSpacing:Z=k,disableEqualOverflow:q,unstable_level:T=0}=E,we=P(E,wn);let M=q;T&&q!==void 0&&(M=s.disableEqualOverflow);const re={},ae={},ie={};Object.entries(we).forEach(([O,G])=>{N.breakpoints.values[O]!==void 0?re[O]=G:N.breakpoints.values[O.replace("Offset","")]!==void 0?ae[O.replace("Offset","")]=G:ie[O]=G});const Oe=(m=s.columns)!=null?m:T?void 0:_,Se=(f=s.spacing)!=null?f:T?void 0:k,je=(y=(h=s.rowSpacing)!=null?h:s.spacing)!=null?y:T?void 0:C,ke=(x=(b=s.columnSpacing)!=null?b:s.spacing)!=null?x:T?void 0:Z,se=d({},E,{level:T,columns:Oe,container:I,direction:g,wrap:v,spacing:Se,rowSpacing:je,columnSpacing:ke,gridSize:re,gridOffset:ae,disableEqualOverflow:(S=(j=M)!=null?j:p)!=null?S:!1,parentDisableEqualOverflow:p}),$e=a(se,N);let X=l.jsx(i,d({ref:u,as:V,ownerState:se,className:Ke($e.root,w)},ie,{children:A.Children.map(D,O=>{if(A.isValidElement(O)&&Pe(O,["Grid"])){var G;return A.cloneElement(O,{unstable_level:(G=O.props.unstable_level)!=null?G:T+1})}return O})}));return M!==void 0&&M!==(p??!1)&&(X=l.jsx(r.Provider,{value:M,children:X})),X});return c.muiName="Grid",c}const ve=kn({createStyledComponent:Xe("div",{name:"MuiGrid2",slot:"Root",overridesResolver:(e,n)=>n.root}),componentName:"MuiGrid2",useThemeProps:e=>Ye({props:e,name:"MuiGrid2"})});function $n({entry:e,payload:n}){const t=Y(f=>{var y,h,x;return(x=(h=(y=f.payload)==null?void 0:y.data)==null?void 0:h.reduce)==null?void 0:x.call(h,(b,S)=>b+S.value,0)},[]),o=Y(f=>{const y=new Q(t(f)||0),h=n?.reduce((S,j)=>S+t(j),0)||0,x=new Q(h),b=Number(y.div(x).times(100).toFixed(2,Q.ROUND_DOWN));return isNaN(b)||!isFinite(b)?0:b},[t,n]),r=H(()=>t(e),[e,t]),a=ee(r),i=H(()=>Number(o(e)),[e,o]),c=ee(i),s=Y(f=>Math.floor(f).toLocaleString(),[]),u=Me({type:"text/plain"}),m=He();return l.jsxs(Re,{component:"li",direction:"row",spacing:1,sx:{color:e.color},layout:"position",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:[l.jsx(J,{sx:{width:"3px",height:"100%",backgroundColor:e.color,borderRadius:3}}),l.jsxs(z,{children:[l.jsxs(R,{component:"p",variant:"caption",children:[l.jsx(z,{component:"span",display:"inline-flex",mr:.5,children:l.jsx(ye,{from:a??0,to:r,map:s,children:"0"})}),l.jsxs(z,{component:"span",direction:"row",display:"inline-flex",children:["(",l.jsx(ye,{from:c??0,to:i,map:s,children:"0"}),"%)"]})]}),l.jsx(R,{variant:"body1",children:e.value}),e.payload.uuid&&l.jsxs(R,{variant:"body2",sx:{cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:()=>{u.copy(e.payload.uuid).catch(()=>{}),m.enqueueSnackbar("UUID copied to clipboard","success")},children:[e.payload.uuid.slice(0,5),"..."]})]})]})}function xe(e){const{payload:n}=e;return l.jsx(ve,{container:!0,direction:"row",component:"ul",gap:2,sx:{mt:2,justifyContent:"flex-start",alignItem:"center",flexWrap:"wrap"},children:l.jsx(De,{children:n?.map(t=>l.jsx(ve,{children:l.jsx($n,{entry:t,payload:n})},`item-${t.value}`))})})}function Nn(e){const n=le();return l.jsx(J,{sx:{width:"100%",height:"100%",...e.sx},children:l.jsx(ce,{children:l.jsxs(Te,{width:500,height:300,margin:{top:5,right:60,left:20,bottom:5},children:[l.jsx(ue,{vertical:!1}),l.jsx(pe,{dataKey:"date",type:"number",domain:["dataMin","dataMax"],tickFormatter:t=>fe(t,{timeZone:e.filter.timezone,hour12:!1,hour:"numeric"}),allowDuplicatedCategory:!1,tickLine:!1,fontSize:12,tickMargin:12}),l.jsx(de,{textAnchor:"end",dataKey:"value",tickLine:!1,tickFormatter:t=>Number(t).toLocaleString(),allowDecimals:!1,domain:[1,"dataMax"],children:e.label&&l.jsx(Ee,{value:e.label,angle:-90,position:"insideLeft",style:{textAnchor:"middle"}})}),l.jsx(me,{cursor:{stroke:n.palette.neutral.main,strokeWidth:1},formatter:t=>Number(t).toLocaleString(),labelFormatter:t=>he(t,{timeZone:e.filter.timezone,hour12:!1})}),l.jsx(Ce,{content:l.jsx(xe,{})}),e.data.map(t=>Ne(Ge,{uuid:t.uuid,key:t.uuid,name:t.name,dataKey:"value",data:t.chartData,type:"monotone",stroke:t.color,strokeWidth:2}))]})})})}const _n=(e,n)=>{const t=new Map;return e.forEach(o=>{o.chartData.forEach(r=>{const a=new Date(r.date).getTime().toString();if(!t.has(a)){const i={date:a,total:0,diff:0,totalKey:"",originalTotal:0};n.forEach(({key:c})=>{i[c]=0,i[`${c}_absolute`]=0}),t.set(a,i)}n.forEach(({key:i})=>{const c=t.get(a),s=r[i],u=typeof s=="string"?s.trim()===""?0:parseInt(s,10):typeof s=="number"?s:0;c[`${i}_absolute`]=u,c[i]=0})})}),Array.from(t.values()).map(o=>{var r;const a=(r=n.find(s=>s.isTotal))==null?void 0:r.key,i=n.filter(s=>!s.isTotal).map(s=>s.key);if(!a||i.length===0)return o;const c=o[`${a}_absolute`];return o.originalTotal=c,o.total=c,o[a]=100,i.forEach(s=>{const u=o[`${s}_absolute`],m=c>0?new K(u.toString()).div(c).mul(100).toFixed(2,K.ROUND_DOWN):"0.00";o[s]=parseFloat(m)}),{...o,totalKey:a}}).sort((o,r)=>parseInt(o.date)-parseInt(r.date))};function Tn(e){const n=le(),t=H(()=>e.data?_n(e.data,e.keyValues):[],[e.data,e.keyValues]);return l.jsx(J,{sx:{width:"100%",height:"100%",...e.sx},children:l.jsx(ce,{width:"100%",height:"100%",children:l.jsxs(Ae,{data:t,width:500,height:300,margin:{top:5,right:60,left:20,bottom:5},children:[l.jsx(ue,{strokeDasharray:"3 3"}),l.jsx(pe,{dataKey:"date",type:"number",domain:["dataMin","dataMax"],tickFormatter:o=>fe(o,{timeZone:e.filter.timezone,hour12:!1,hour:"numeric"}),allowDuplicatedCategory:!1,tickLine:!1,fontSize:12,tickMargin:12}),l.jsx(de,{textAnchor:"end",tickLine:!1,tickFormatter:o=>`${o.toFixed(2)}%`}),l.jsx(me,{cursor:{stroke:n.palette.neutral.main,strokeWidth:1},labelFormatter:o=>he(o,{timeZone:e.filter.timezone,hour12:!1}),formatter:(o,r,a)=>{const i=a.payload.totalKey,c=a.dataKey,s=c===i,u=a.payload[`${c}_absolute`],m=a.payload.originalTotal,f=s?null:m===0?"0.00":new K(u.toString()).div(m).mul(100).toFixed(2,K.ROUND_DOWN);return[f?`${u.toLocaleString()} (${f}%)`:`${u.toLocaleString()} (TOTAL)`,r]}}),e.keyValues.sort((o,r)=>o.isTotal?-1:r.isTotal?1:0).map(o=>l.jsx(Le,{type:"monotone",dataKey:o.key,name:o.name,stroke:o.color,fill:o.color,strokeWidth:2,fillOpacity:.6},o.key))]})})})}function En(e){const n=ee(e.value),{ref:t}=Je({from:n??0,to:e.value,duration:1,map:e.map});return l.jsx(_e,{sx:{p:3,flex:1,...e.sx},children:l.jsxs(z,{spacing:1,alignItems:"center",children:[l.jsx(R,{ref:t,variant:"h4",fontWeight:"bold",children:e.initialValue}),l.jsx(R,{color:"text.secondary",children:e.label})]})})}export{En as BigNumber,Nn as SeriesChart,xe as SeriesChartLegend,Tn as SeriesPercentageChart};
|
1
|
+
"use strict";import{j as s}from"../../shared/jsx-runtime-jmtevAuS.mjs";import*as G from"react";import{useCallback as H,useMemo as J,createElement as _e}from"react";import{Box as P,Stack as z,Typography as R,useTheme as Q,Paper as Te}from"@mui/material";import{ResponsiveContainer as ee,LineChart as Ee,CartesianGrid as ne,XAxis as te,YAxis as oe,Label as Ae,Tooltip as re,Legend as Ce,Line as Ge,AreaChart as Le,Area as De,ComposedChart as Me,ReferenceLine as fe,Bar as Re}from"recharts";import{b as he,c as ye}from"../../shared/date-Cq0LS2Mr.mjs";import q,{Decimal as ae}from"decimal.js";import{AnimatePresence as Fe}from"framer-motion";import{u as We}from"../../shared/useCopyToClipboard-BALOSYVW.mjs";import"qrcode";import{u as ie}from"../../shared/usePrevious-DyvR1iCQ.mjs";import{a as Ie,C as be}from"../../shared/motions-CpxgbzKX.mjs";import{i as Ke,_ as B,s as Ve,a as f,c as ge,d as Pe,e as ze,f as qe,h as Be,j as Ue,k as Ze,l as Xe,m as Ye,n as He,o as Je,p as Qe,u as en}from"../../shared/index-CDq4CkLc.mjs";import{u as nn}from"../../shared/useCounter-BV32zXDQ.mjs";const tn=["ownerState"],on=["variants"],rn=["name","slot","skipVariantsResolver","skipSx","overridesResolver"];function an(e){return Object.keys(e).length===0}function sn(e){return typeof e=="string"&&e.charCodeAt(0)>96}function se(e){return e!=="ownerState"&&e!=="theme"&&e!=="sx"&&e!=="as"}const ln=ge(),cn=e=>e&&e.charAt(0).toLowerCase()+e.slice(1);function U({defaultTheme:e,theme:n,themeId:t}){return an(n)?e:n[t]||n}function un(e){return e?(n,t)=>t[e]:null}function Z(e,n){let{ownerState:t}=n,o=B(n,tn);const a=typeof e=="function"?e(f({ownerState:t},o)):e;if(Array.isArray(a))return a.flatMap(r=>Z(r,f({ownerState:t},o)));if(a&&typeof a=="object"&&Array.isArray(a.variants)){const{variants:r=[]}=a;let i=B(a,on);return r.forEach(c=>{let l=!0;typeof c.props=="function"?l=c.props(f({ownerState:t},o,t)):Object.keys(c.props).forEach(u=>{t?.[u]!==c.props[u]&&o[u]!==c.props[u]&&(l=!1)}),l&&(Array.isArray(i)||(i=[i]),i.push(typeof c.style=="function"?c.style(f({ownerState:t},o,t)):c.style))}),i}return a}function pn(e={}){const{themeId:n,defaultTheme:t=ln,rootShouldForwardProp:o=se,slotShouldForwardProp:a=se}=e,r=i=>Pe(f({},i,{theme:U(f({},i,{defaultTheme:t,themeId:n}))}));return r.__mui_systemSx=!0,(i,c={})=>{Ke(i,m=>m.filter(w=>!(w!=null&&w.__mui_systemSx)));const{name:l,slot:u,skipVariantsResolver:p,skipSx:d,overridesResolver:y=un(cn(u))}=c,h=B(c,rn),x=p!==void 0?p:u&&u!=="Root"&&u!=="root"||!1,b=d||!1;let j,k=se;u==="Root"||u==="root"?k=o:u?k=a:sn(i)&&(k=void 0);const N=Ve(i,f({shouldForwardProp:k,label:j},h)),W=m=>typeof m=="function"&&m.__emotion_real!==m||ze(m)?w=>Z(m,f({},w,{theme:U({theme:w.theme,defaultTheme:t,themeId:n})})):m,E=(m,...w)=>{let D=W(m);const _=w?w.map(W):[];l&&y&&_.push(g=>{const v=U(f({},g,{defaultTheme:t,themeId:n}));if(!v.components||!v.components[l]||!v.components[l].styleOverrides)return null;const S=v.components[l].styleOverrides,A={};return Object.entries(S).forEach(([X,V])=>{A[X]=Z(V,f({},g,{theme:v}))}),y(g,A)}),l&&!x&&_.push(g=>{var v;const S=U(f({},g,{defaultTheme:t,themeId:n})),A=S==null||(v=S.components)==null||(v=v[l])==null?void 0:v.variants;return Z({variants:A},f({},g,{theme:S}))}),b||_.push(r);const I=_.length-w.length;if(Array.isArray(m)&&I>0){const g=new Array(I).fill("");D=[...m,...g],D.raw=[...m.raw,...g]}const K=N(D,..._);return i.muiName&&(K.muiName=i.muiName),K};return N.withConfig&&(E.withConfig=N.withConfig),E}}const dn=pn(),mn=(e,n)=>e.filter(t=>n.includes(t)),L=(e,n,t)=>{const o=e.keys[0];Array.isArray(n)?n.forEach((a,r)=>{t((i,c)=>{r<=e.keys.length-1&&(r===0?Object.assign(i,c):i[e.up(e.keys[r])]=c)},a)}):n&&typeof n=="object"?(Object.keys(n).length>e.keys.length?e.keys:mn(e.keys,Object.keys(n))).forEach(a=>{if(e.keys.indexOf(a)!==-1){const r=n[a];r!==void 0&&t((i,c)=>{o===a?Object.assign(i,c):i[e.up(a)]=c},r)}}):(typeof n=="number"||typeof n=="string")&&t((a,r)=>{Object.assign(a,r)},n)};function $(e){return e?`Level${e}`:""}function F(e){return e.unstable_level>0&&e.container}function ve(e){return function(n){return`var(--Grid-${n}Spacing${$(e.unstable_level)})`}}function le(e){return function(n){return e.unstable_level===0?`var(--Grid-${n}Spacing)`:`var(--Grid-${n}Spacing${$(e.unstable_level-1)})`}}function ce(e){return e.unstable_level===0?"var(--Grid-columns)":`var(--Grid-columns${$(e.unstable_level-1)})`}const fn=({theme:e,ownerState:n})=>{const t=ve(n),o={};return L(e.breakpoints,n.gridSize,(a,r)=>{let i={};r===!0&&(i={flexBasis:0,flexGrow:1,maxWidth:"100%"}),r==="auto"&&(i={flexBasis:"auto",flexGrow:0,flexShrink:0,maxWidth:"none",width:"auto"}),typeof r=="number"&&(i={flexGrow:0,flexBasis:"auto",width:`calc(100% * ${r} / ${ce(n)}${F(n)?` + ${t("column")}`:""})`}),a(o,i)}),o},hn=({theme:e,ownerState:n})=>{const t={};return L(e.breakpoints,n.gridOffset,(o,a)=>{let r={};a==="auto"&&(r={marginLeft:"auto"}),typeof a=="number"&&(r={marginLeft:a===0?"0px":`calc(100% * ${a} / ${ce(n)})`}),o(t,r)}),t},yn=({theme:e,ownerState:n})=>{if(!n.container)return{};const t=F(n)?{[`--Grid-columns${$(n.unstable_level)}`]:ce(n)}:{"--Grid-columns":12};return L(e.breakpoints,n.columns,(o,a)=>{o(t,{[`--Grid-columns${$(n.unstable_level)}`]:a})}),t},bn=({theme:e,ownerState:n})=>{if(!n.container)return{};const t=le(n),o=F(n)?{[`--Grid-rowSpacing${$(n.unstable_level)}`]:t("row")}:{};return L(e.breakpoints,n.rowSpacing,(a,r)=>{var i;a(o,{[`--Grid-rowSpacing${$(n.unstable_level)}`]:typeof r=="string"?r:(i=e.spacing)==null?void 0:i.call(e,r)})}),o},gn=({theme:e,ownerState:n})=>{if(!n.container)return{};const t=le(n),o=F(n)?{[`--Grid-columnSpacing${$(n.unstable_level)}`]:t("column")}:{};return L(e.breakpoints,n.columnSpacing,(a,r)=>{var i;a(o,{[`--Grid-columnSpacing${$(n.unstable_level)}`]:typeof r=="string"?r:(i=e.spacing)==null?void 0:i.call(e,r)})}),o},vn=({theme:e,ownerState:n})=>{if(!n.container)return{};const t={};return L(e.breakpoints,n.direction,(o,a)=>{o(t,{flexDirection:a})}),t},xn=({ownerState:e})=>{const n=ve(e),t=le(e);return f({minWidth:0,boxSizing:"border-box"},e.container&&f({display:"flex",flexWrap:"wrap"},e.wrap&&e.wrap!=="wrap"&&{flexWrap:e.wrap},{margin:`calc(${n("row")} / -2) calc(${n("column")} / -2)`},e.disableEqualOverflow&&{margin:`calc(${n("row")} * -1) 0px 0px calc(${n("column")} * -1)`}),(!e.container||F(e))&&f({padding:`calc(${t("row")} / 2) calc(${t("column")} / 2)`},(e.disableEqualOverflow||e.parentDisableEqualOverflow)&&{padding:`${t("row")} 0px 0px ${t("column")}`}))},wn=e=>{const n=[];return Object.entries(e).forEach(([t,o])=>{o!==!1&&o!==void 0&&n.push(`grid-${t}-${String(o)}`)}),n},On=(e,n="xs")=>{function t(o){return o===void 0?!1:typeof o=="string"&&!Number.isNaN(Number(o))||typeof o=="number"&&o>0}if(t(e))return[`spacing-${n}-${String(e)}`];if(typeof e=="object"&&!Array.isArray(e)){const o=[];return Object.entries(e).forEach(([a,r])=>{t(r)&&o.push(`spacing-${a}-${String(r)}`)}),o}return[]},jn=e=>e===void 0?[]:typeof e=="object"?Object.entries(e).map(([n,t])=>`direction-${n}-${t}`):[`direction-xs-${String(e)}`],kn=["className","children","columns","container","component","direction","wrap","spacing","rowSpacing","columnSpacing","disableEqualOverflow","unstable_level"],Sn=ge(),$n=dn("div",{name:"MuiGrid",slot:"Root",overridesResolver:(e,n)=>n.root});function Nn(e){return Xe({props:e,name:"MuiGrid",defaultTheme:Sn})}function _n(e={}){const{createStyledComponent:n=$n,useThemeProps:t=Nn,componentName:o="MuiGrid"}=e,a=G.createContext(void 0),r=(l,u)=>{const{container:p,direction:d,spacing:y,wrap:h,gridSize:x}=l,b={root:["root",p&&"container",h!=="wrap"&&`wrap-xs-${String(h)}`,...jn(d),...wn(x),...p?On(y,u.breakpoints.keys[0]):[]]};return Ye(b,j=>He(o,j),{})},i=n(yn,gn,bn,fn,vn,xn,hn),c=G.forwardRef(function(l,u){var p,d,y,h,x,b,j,k;const N=qe(),W=t(l),E=Be(W),m=G.useContext(a),{className:w,children:D,columns:_=12,container:I=!1,component:K="div",direction:g="row",wrap:v="wrap",spacing:S=0,rowSpacing:A=S,columnSpacing:X=S,disableEqualOverflow:V,unstable_level:T=0}=E,Oe=B(E,kn);let M=V;T&&V!==void 0&&(M=l.disableEqualOverflow);const ue={},pe={},de={};Object.entries(Oe).forEach(([O,C])=>{N.breakpoints.values[O]!==void 0?ue[O]=C:N.breakpoints.values[O.replace("Offset","")]!==void 0?pe[O.replace("Offset","")]=C:de[O]=C});const je=(p=l.columns)!=null?p:T?void 0:_,ke=(d=l.spacing)!=null?d:T?void 0:S,Se=(y=(h=l.rowSpacing)!=null?h:l.spacing)!=null?y:T?void 0:A,$e=(x=(b=l.columnSpacing)!=null?b:l.spacing)!=null?x:T?void 0:X,me=f({},E,{level:T,columns:je,container:I,direction:g,wrap:v,spacing:ke,rowSpacing:Se,columnSpacing:$e,gridSize:ue,gridOffset:pe,disableEqualOverflow:(j=(k=M)!=null?k:m)!=null?j:!1,parentDisableEqualOverflow:m}),Ne=r(me,N);let Y=s.jsx(i,f({ref:u,as:K,ownerState:me,className:Ue(Ne.root,w)},de,{children:G.Children.map(D,O=>{if(G.isValidElement(O)&&Ze(O,["Grid"])){var C;return G.cloneElement(O,{unstable_level:(C=O.props.unstable_level)!=null?C:T+1})}return O})}));return M!==void 0&&M!==(m??!1)&&(Y=s.jsx(a.Provider,{value:M,children:Y})),Y});return c.muiName="Grid",c}const xe=_n({createStyledComponent:Je("div",{name:"MuiGrid2",slot:"Root",overridesResolver:(e,n)=>n.root}),componentName:"MuiGrid2",useThemeProps:e=>Qe({props:e,name:"MuiGrid2"})});function Tn({entry:e,payload:n}){const t=H(d=>{var y,h,x;return(x=(h=(y=d.payload)==null?void 0:y.data)==null?void 0:h.reduce)==null?void 0:x.call(h,(b,j)=>b+j.value,0)},[]),o=H(d=>{const y=new ae(t(d)||0),h=n?.reduce((j,k)=>j+t(k),0)||0,x=new ae(h),b=Number(y.div(x).times(100).toFixed(2,ae.ROUND_DOWN));return isNaN(b)||!isFinite(b)?0:b},[t,n]),a=J(()=>t(e),[e,t]),r=ie(a),i=J(()=>Number(o(e)),[e,o]),c=ie(i),l=H(d=>Math.floor(d).toLocaleString(),[]),u=We({type:"text/plain"}),p=en();return s.jsxs(Ie,{component:"li",direction:"row",spacing:1,sx:{color:e.color},layout:"position",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:[s.jsx(P,{sx:{width:"3px",height:"100%",backgroundColor:e.color,borderRadius:3}}),s.jsxs(z,{children:[s.jsxs(R,{component:"p",variant:"caption",children:[s.jsx(z,{component:"span",display:"inline-flex",mr:.5,children:s.jsx(be,{from:r??0,to:a,map:l,children:"0"})}),s.jsxs(z,{component:"span",direction:"row",display:"inline-flex",children:["(",s.jsx(be,{from:c??0,to:i,map:l,children:"0"}),"%)"]})]}),s.jsx(R,{variant:"body1",children:e.value}),e.payload.uuid&&s.jsxs(R,{variant:"body2",sx:{cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:()=>{u.copy(e.payload.uuid).catch(()=>{}),p.enqueueSnackbar("UUID copied to clipboard","success")},children:[e.payload.uuid.slice(0,5),"..."]})]})]})}function we(e){const{payload:n}=e;return s.jsx(xe,{container:!0,direction:"row",component:"ul",gap:2,sx:{mt:2,justifyContent:"flex-start",alignItem:"center",flexWrap:"wrap"},children:s.jsx(Fe,{children:n?.map(t=>s.jsx(xe,{children:s.jsx(Tn,{entry:t,payload:n})},`item-${t.value}`))})})}function En(e){const n=Q();return s.jsx(P,{sx:{width:"100%",height:"100%",...e.sx},children:s.jsx(ee,{children:s.jsxs(Ee,{width:500,height:300,margin:{top:5,right:60,left:20,bottom:5},children:[s.jsx(ne,{vertical:!1}),s.jsx(te,{dataKey:"date",type:"number",domain:["dataMin","dataMax"],tickFormatter:t=>he(t,{timeZone:e.filter.timezone,hour12:!1,hour:"numeric"}),allowDuplicatedCategory:!1,tickLine:!1,fontSize:12,tickMargin:12}),s.jsx(oe,{textAnchor:"end",dataKey:"value",tickLine:!1,tickFormatter:t=>Number(t).toLocaleString(),allowDecimals:!1,domain:[1,"dataMax"],children:e.label&&s.jsx(Ae,{value:e.label,angle:-90,position:"insideLeft",style:{textAnchor:"middle"}})}),s.jsx(re,{cursor:{stroke:n.palette.neutral.main,strokeWidth:1},formatter:t=>Number(t).toLocaleString(),labelFormatter:t=>ye(t,{timeZone:e.filter.timezone,hour12:!1})}),s.jsx(Ce,{content:s.jsx(we,{})}),e.data.map(t=>_e(Ge,{uuid:t.uuid,key:t.uuid,name:t.name,dataKey:"value",data:t.chartData,type:"monotone",stroke:t.color,strokeWidth:2}))]})})})}const An=(e,n)=>{const t=new Map;return e.forEach(o=>{o.chartData.forEach(a=>{const r=new Date(a.date).getTime().toString();if(!t.has(r)){const i={date:r,total:0,diff:0,totalKey:"",originalTotal:0};n.forEach(({key:c})=>{i[c]=0,i[`${c}_absolute`]=0}),t.set(r,i)}n.forEach(({key:i})=>{const c=t.get(r),l=a[i],u=typeof l=="string"?l.trim()===""?0:parseInt(l,10):typeof l=="number"?l:0;c[`${i}_absolute`]=u,c[i]=0})})}),Array.from(t.values()).map(o=>{var a;const r=(a=n.find(l=>l.isTotal))==null?void 0:a.key,i=n.filter(l=>!l.isTotal).map(l=>l.key);if(!r||i.length===0)return o;const c=o[`${r}_absolute`];return o.originalTotal=c,o.total=c,o[r]=100,i.forEach(l=>{const u=o[`${l}_absolute`],p=c>0?new q(u.toString()).div(c).mul(100).toFixed(2,q.ROUND_DOWN):"0.00";o[l]=parseFloat(p)}),{...o,totalKey:r}}).sort((o,a)=>parseInt(o.date)-parseInt(a.date))};function Cn(e){const n=Q(),t=J(()=>e.data?An(e.data,e.keyValues):[],[e.data,e.keyValues]);return s.jsx(P,{sx:{width:"100%",height:"100%",...e.sx},children:s.jsx(ee,{width:"100%",height:"100%",children:s.jsxs(Le,{data:t,width:500,height:300,margin:{top:5,right:60,left:20,bottom:5},children:[s.jsx(ne,{strokeDasharray:"3 3"}),s.jsx(te,{dataKey:"date",type:"number",domain:["dataMin","dataMax"],tickFormatter:o=>he(o,{timeZone:e.filter.timezone,hour12:!1,hour:"numeric"}),allowDuplicatedCategory:!1,tickLine:!1,fontSize:12,tickMargin:12}),s.jsx(oe,{textAnchor:"end",tickLine:!1,tickFormatter:o=>`${o.toFixed(2)}%`}),s.jsx(re,{cursor:{stroke:n.palette.neutral.main,strokeWidth:1},labelFormatter:o=>ye(o,{timeZone:e.filter.timezone,hour12:!1}),formatter:(o,a,r)=>{const i=r.payload.totalKey,c=r.dataKey,l=c===i,u=r.payload[`${c}_absolute`],p=r.payload.originalTotal,d=l?null:p===0?"0.00":new q(u.toString()).div(p).mul(100).toFixed(2,q.ROUND_DOWN);return[d?`${u.toLocaleString()} (${d}%)`:`${u.toLocaleString()} (TOTAL)`,a]}}),e.keyValues.sort((o,a)=>o.isTotal?-1:a.isTotal?1:0).map(o=>s.jsx(De,{type:"monotone",dataKey:o.key,name:o.name,stroke:o.color,fill:o.color,strokeWidth:2,fillOpacity:.6},o.key))]})})})}function Gn(e){const n=ie(e.value),{ref:t}=nn({from:n??0,to:e.value,duration:1,map:e.map});return s.jsx(Te,{sx:{p:3,flex:1,...e.sx},children:s.jsxs(z,{spacing:1,alignItems:"center",children:[s.jsx(R,{ref:t,variant:"h4",fontWeight:"bold",children:e.initialValue}),s.jsx(R,{color:"text.secondary",children:e.label})]})})}function Ln({data:e,series:n,xAxisDataKey:t,xAxisProps:o,yAxisProps:a,referenceLines:r,sx:i}){const c=Q(),l=p=>!p.isFront,u=p=>!!p.isFront;return s.jsx(P,{sx:{width:"100%",height:"100%",...i},children:s.jsx(ee,{children:s.jsxs(Me,{data:e,margin:{top:5,right:30,left:20,bottom:5},children:[s.jsx(ne,{strokeDasharray:"3 3",vertical:!1}),s.jsx(te,{dataKey:t,tickLine:!1,fontSize:12,tickMargin:12,...o}),s.jsx(oe,{textAnchor:"end",tickLine:!1,...a}),s.jsx(re,{cursor:{stroke:c.palette.neutral.main,strokeWidth:1}}),r?.filter(l).map((p,d)=>s.jsx(fe,{...p},d)),n.map(p=>s.jsx(Re,{name:p.key,dataKey:p.dataKey,fill:p.color,stackId:"stack",isAnimationActive:!1},p.key)),r?.filter(u).map((p,d)=>s.jsx(fe,{...p},d))]})})})}export{Gn as BigNumber,En as SeriesChart,we as SeriesChartLegend,Cn as SeriesPercentageChart,Ln as SimpleBarChart};
|