@carto/meridian-ds 1.3.3 → 1.3.5
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/CHANGELOG.md +10 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.js +1344 -1334
- package/dist/types/components/molecules/Avatar.d.ts +1 -0
- package/dist/types/components/molecules/Avatar.d.ts.map +1 -1
- package/dist/types/components/organisms/Dialog/DialogContent.d.ts +2 -2
- package/dist/types/components/organisms/Dialog/DialogContent.d.ts.map +1 -1
- package/dist/types/widgets/CategoryWidgetUI/CategoryWidgetUI.d.ts.map +1 -1
- package/dist/widgets/index.cjs +10 -10
- package/dist/widgets/index.js +460 -458
- package/package.json +13 -13
package/dist/widgets/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),u=require("react"),o=require("@mui/material"),Z=require("react-intl"),j=require("../TablePaginationActions-Bv-6vZ7z.cjs"),jn=require("echarts-for-react"),wn=require("react-window"),Te=require("../SwatchSquare-C-QxZLYN.cjs"),ee=require("@mui/icons-material"),bn=require("../Alert-C0xmyi3Z.cjs"),Me=require("../paletteUtils-DLQVT9qo.cjs");function Bt(){let e=!1;return window.PointerEvent&&"maxTouchPoints"in navigator?navigator.maxTouchPoints>0&&(e=!0):(window.matchMedia&&window.matchMedia("(any-pointer:coarse)").matches||window.TouchEvent||"ontouchstart"in window)&&(e=!0),e}function te(e){return!e||typeof e!="object"?e:`${e.prefix??""}${e.value}${e.suffix??""}`}const Sn=[],
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),u=require("react"),o=require("@mui/material"),Z=require("react-intl"),j=require("../TablePaginationActions-Bv-6vZ7z.cjs"),jn=require("echarts-for-react"),wn=require("react-window"),Te=require("../SwatchSquare-C-QxZLYN.cjs"),ee=require("@mui/icons-material"),bn=require("../Alert-C0xmyi3Z.cjs"),Me=require("../paletteUtils-DLQVT9qo.cjs");function Bt(){let e=!1;return window.PointerEvent&&"maxTouchPoints"in navigator?navigator.maxTouchPoints>0&&(e=!0):(window.matchMedia&&window.matchMedia("(any-pointer:coarse)").matches||window.TouchEvent||"ontouchstart"in window)&&(e=!0),e}function te(e){return!e||typeof e!="object"?e:`${e.prefix??""}${e.value}${e.suffix??""}`}const Sn=[],In={},lt=e=>e;function kn(e,n){if(!e||Array.isArray(e)&&e.length===0)return null;const i=Array.isArray(e)?e:[e];let r="";return r+=String(i[0].axisValueLabel),r+=i.map(({seriesName:s,value:l,data:a,marker:p})=>{const c=s?s+": ":"",g=te(n(Number(l))),h=a,d=`<div style="margin-left: 8px; display: inline">
|
|
2
2
|
${c}${g}${String((h==null?void 0:h.unit)||"")}
|
|
3
|
-
</div>`;return`<div style="margin-top: 4px">${String(p)}${d}</div>`}).join(" "),r}function Tn({height:e,labels:n=
|
|
4
|
-
width ${e.transitions.easing.sharp} ${e.transitions.duration.complex}ms`}})),On=o.styled(o.Grid,{shouldForwardProp:e=>e!=="isSelectable"})(({theme:e,isSelectable:n})=>({...n&&{width:`calc(100% - ${e.spacing(4)})`}})),$n=o.styled(j.Typography)(({theme:e})=>({fontWeight:e.typography.fontWeightBold,marginRight:e.spacing(2)})),Ae=o.styled(o.Link)(({theme:e})=>({...e.typography.caption,cursor:"pointer","& + hr":{margin:e.spacing(0,1)}})),Rn=o.styled(o.Box)(({theme:e})=>({...e.typography.body2})),pt=o.styled(o.Button)(({theme:e})=>({position:"absolute",left:"-999px",top:"-1px",width:"1px",height:"1px",display:"inline-flex","&:focus-visible":{position:"static",width:"auto",height:"auto",marginTop:e.spacing(2)}})),Fn=o.styled(o.Skeleton)(({theme:e})=>({marginTop:e.spacing(1.25),marginBottom:e.spacing(1.75)})),Wn=e=>e%2===1,Ot=()=>t.jsxs(t.Fragment,{children:[t.jsx(o.Skeleton,{width:48,height:8}),t.jsx(Dt,{container:!0,mt:3,children:[...Array(6)].map((e,n)=>t.jsxs(Nt,{container:!0,spacing:1,children:[t.jsxs(o.Grid,{container:!0,item:!0,direction:"row",justifyContent:"space-between",children:[t.jsx(o.Skeleton,{width:Wn(n)?72:48,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]}),t.jsx(Fn,{height:4,width:"100%"})]},n))})]});function $t(e){const n=u.useRef();return u.useEffect(()=>{n.current=e}),n.current}function Ke({start:e,end:n,duration:i,drawFrame:r,requestRef:s}){if(e===n&&!(e===0&&n===0))return;const a=n-e;let p=e;const c=a/(i/1e3*60),g=()=>{p+=c,r(Math.floor(p)),c>0&&p<n||c<0&&p>n?s.current=requestAnimationFrame(g):r(n)};s.current=requestAnimationFrame(g)}function _n({start:e,end:n,duration:i,drawFrame:r,requestRef:s}){if(e.length===n.length&&e.every((f,m)=>f.value===n[m].value))return;let a=n.map((f,m)=>e[m]&&e[m].name===f.name?{...f,value:e[m].value}:f),p=0;const c=a.map((f,m)=>n[m].value-f.value);if(c.every(f=>f===0)){r(n);return}const h=i/1e3*60,d=c.map(f=>f/h),y=()=>{p<h?(a=a.map((f,m)=>{const v=Math.floor(f.value+d[m]),x=m>0&&Math.floor(f.value+d[m-1]);return{...f,value:v===x?n[m].value:v}}),r(a),p++,s.current=requestAnimationFrame(y)):r(n)};s.current=requestAnimationFrame(y)}const Gn=[],zn={},Hn=e=>e,Ve=()=>{},Yn=e=>e.reduce((n,i)=>n+(i.value??0),0);function Vn({data:e,formatter:n=Hn,labels:i=zn,maxItems:r=5,order:s=pe.RANKING,selectedCategories:l=Gn,onSelectedCategoriesChange:a=Ve,onMaxItemsOverflow:p=Yn,animation:c=!0,filterable:g=!0,searchable:h=!0,isLoading:d}){const y=o.useTheme(),[f,m]=u.useState([]),[v,x]=u.useState(1),[b,S]=u.useState(!1),[k,T]=u.useState(""),[w,C]=u.useState([]),[M,D]=u.useState([]),[E,L]=u.useState([]),P=u.useRef(null),N=u.useRef(),V=$t(E),_=u.useRef([]),{showSkeleton:A}=de(!!d),$=Z.useIntl(),I=j.useImperativeIntl($);function O(B){return f.reduce((Y,U)=>(B.includes(U.name)&&Y.push(U.name),Y),[])}function G(B){if(B!==ue){let Y;l.includes(B)?Y=l.filter(U=>U!==B):Y=[...l,B],a&&a(Y)}}const R=()=>a([]),z=B=>{B.key==="Enter"&&R()},q=()=>{a([]),C([])},F=B=>{B.key==="Enter"&&q()},H=()=>{C(O(l))},J=B=>{B.key==="Enter"&&H()},ie=()=>{const B=O(M);a([...B]),C([...B]),D([]),S(!1),T("")},re=B=>{B.key==="Enter"&&ie()},W=()=>{T(""),S(!1)},K=B=>{if(B!==ue){let Y;M.includes(B)?Y=M.filter(U=>U!==B):Y=[...M,B],D(Y)}},X=B=>{B.currentTarget.scrollIntoView()},Q=B=>{T(B.currentTarget.value)},ge=()=>{S(!0),D([...l])},ve=u.useCallback(B=>{if(b)return k?B.filter(Y=>{var se;if(!Y.name)return!1;const U=String(Y.name);return!!(U.toLowerCase().includes(k.toLowerCase())||(se=i[U])!=null&&se.toLowerCase().includes(k.toLowerCase()))}):B;if(w.length)return w.reduce((U,se)=>{const Ce=B.find(le=>le.name===se);return U.push({name:se,value:Ce?Ce.value:null}),U},[]);{const Y=B.slice(0,r);if(Y.length<B.length){const U={name:ue,value:p(B.slice(r))};return[...Y,U]}else return Y}},[w,i,r,k,b,p]),he=u.useCallback(()=>{const B=w.length;return B?e.length-B:e.length-r},[e,r,w]),it=u.useCallback(B=>B===ue?`Others ${h?"":`(${he()})`}`:i[String(B)]??String(B),[he,i,h]),hn=u.useCallback(B=>B>=v?B!=null?"100%":0:`${(B||0)*100/v}%`,[v]);u.useEffect(()=>{l.length===0&&C([])},[l]),u.useEffect(()=>{if(e){if(s===pe.RANKING){const B=[...e].sort((U,se)=>(se.value??0)-(U.value??0)),Y=ve(B);Y.length>0?x(Y[0].value??0):x(1),m(Y)}else if(s===pe.FIXED){x(Math.max(...e.map(Y=>Y.value??0)));const B=ve(e);m(B)}}},[w,ve,e,i,r,s,k,b]),u.useEffect(()=>{V&&(_.current=V)},[V]),u.useEffect(()=>{if(c)return _n({start:(_.current||[]).map(B=>({...B,value:B.value??0})),end:f.map(B=>({...B,value:B.value??0})),duration:500,drawFrame:B=>L(B),requestRef:P}),()=>{P.current&&cancelAnimationFrame(P.current)};L(f)},[c,f]),u.useEffect(()=>{b&&N.current&&N.current.focus()},[b,N]);function fn({data:B,onCategoryClick:Y}){const U=n(B.value??0),[se,Ce]=u.useState(!1),le=u.useRef(null),He=()=>{var rt,st;const Ye=(((rt=le==null?void 0:le.current)==null?void 0:rt.scrollWidth)??0)>(((st=le==null?void 0:le.current)==null?void 0:st.clientWidth)??0);Ce(Ye)};u.useEffect(()=>(He(),window.addEventListener("resize",He),()=>{window.removeEventListener("resize",He)}),[]);const yn=Ye=>{Ye.key==="Enter"&&Y()},vn=!b&&l.length>0&&!l.includes(B.name);return t.jsxs(Nt,{container:!0,direction:"row",spacing:1,onClick:g?Y:Ve,onKeyDown:g?yn:Ve,selectable:g,unselected:vn,name:B.name===ue?ue:"",tabIndex:g?0:-1,children:[g&&b&&t.jsx(o.Grid,{item:!0,mr:1,children:t.jsx(o.Checkbox,{checked:M.includes(B.name),tabIndex:-1})}),t.jsxs(On,{container:!0,item:!0,xs:!0,isSelectable:b,children:[t.jsxs(o.Grid,{container:!0,item:!0,direction:"row",justifyContent:"space-between",wrap:"nowrap",children:[t.jsx(o.Tooltip,{title:it(B.name),disableHoverListener:!se,children:t.jsx($n,{variant:"body2",noWrap:!0,ref:le,children:it(B.name)})}),typeof U=="object"&&U!==null?t.jsxs("span",{children:[U.prefix,U.value,U.suffix]}):t.jsx("span",{children:U})]}),t.jsx(Nn,{className:"progressbar",item:!0,children:t.jsx("div",{style:{width:hn(B.value??0)}})})]})]})}if((e==null?void 0:e.length)===0||A)return t.jsx(Ot,{});const xn=({index:B,style:Y})=>{const U=E[B];return U?t.jsx("div",{style:Y,children:t.jsx(fn,{data:U,onCategoryClick:()=>b?K(U.name):G(U.name)})}):null},mn=()=>b?320:w.length>0?w.length*38:(r+1)*38;return t.jsxs(Rn,{children:[g&&f.length>0&&t.jsxs(ut,{container:!0,children:[t.jsx(j.Typography,{variant:"caption",children:l.length>0?I.formatMessage({id:"c4r.widgets.category.selectedItems"},{items:l.length}):I.formatMessage({id:"c4r.widgets.category.all"})}),b?t.jsx(Ae,{onClick:ie,onKeyDown:re,underline:"hover",tabIndex:0,"data-testid":"primaryApplyButton",children:I.formatMessage({id:"c4r.widgets.category.apply"})}):w.length>0?t.jsx(Ae,{onClick:q,onKeyDown:F,underline:"hover",tabIndex:0,children:I.formatMessage({id:"c4r.widgets.category.unlock"})}):l.length>0&&t.jsxs(o.Grid,{container:!0,direction:"row",justifyContent:"flex-end",item:!0,xs:!0,children:[t.jsx(Ae,{onClick:H,onKeyDown:J,underline:"hover",tabIndex:0,children:I.formatMessage({id:"c4r.widgets.category.lock"})}),t.jsx(o.Divider,{orientation:"vertical",flexItem:!0}),t.jsx(Ae,{onClick:R,onKeyDown:z,underline:"hover",tabIndex:0,children:I.formatMessage({id:"c4r.widgets.category.clear"})})]})]}),e.length>r&&b&&t.jsxs(ut,{container:!0,children:[t.jsx(o.TextField,{size:"small",sx:{mt:-.5},placeholder:I.formatMessage({id:"c4r.widgets.category.search"}),onChange:Q,onFocus:X,InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx(Te.Search,{})})},inputProps:{tabIndex:0,ref:N}}),t.jsx(pt,{size:"small",onClick:W,children:I.formatMessage({id:"c4r.widgets.category.cancel"})})]}),t.jsx(Dt,{container:!0,item:!0,children:E.length?t.jsx(wn.FixedSizeList,{height:mn(),width:"100%",itemCount:E.length,itemSize:y.spacingValue*4.5,children:xn}):t.jsxs(o.Box,{children:[t.jsx(j.Typography,{variant:"body2",children:I.formatMessage({id:"c4r.widgets.category.noResults"})}),t.jsx(j.Typography,{component:"p",variant:"caption",mb:2,children:I.formatMessage({id:"c4r.widgets.category.noResultsMessage"},{searchValue:k})})]})}),b&&t.jsx(pt,{size:"small",onClick:ie,children:I.formatMessage({id:"c4r.widgets.category.apply"})}),e.length>r&&h?b?t.jsx(o.Box,{mt:1.5,children:t.jsx(o.Button,{size:"small",color:"primary",onClick:W,"data-testid":"primaryCancelButton",children:I.formatMessage({id:"c4r.widgets.category.cancel"})})}):t.jsx(o.Box,{mt:1.5,children:t.jsx(o.Button,{size:"small",color:"primary",startIcon:t.jsx(Te.Search,{}),onClick:ge,children:I.formatMessage({id:"c4r.widgets.category.searchInfo"},{elements:he()})})}):null]})}const Rt=()=>t.jsx(o.Box,{pt:.5,children:t.jsx(o.Skeleton,{height:24,width:120})}),Un=o.styled("span")(()=>({marginRight:"2px"})),qn=o.styled("span")(()=>({marginLeft:"2px"})),Ee="-",Kn=e=>e;function Xn({data:e=Ee,formatter:n=Kn,animation:i=!0,isLoading:r=!1}){const[s,l]=u.useState(Ee),a=u.useRef(null),p=$t(s),c=u.useRef(p),{showSkeleton:g}=de(!!r);u.useEffect(()=>(typeof e=="number"&&i?Ke({start:c.current||0,end:e,duration:500,drawFrame:f=>l(f),requestRef:a}):typeof e=="object"&&i&&e&&c.current&&e.value!==null&&e.value!==void 0?Ke({start:Number(c.current.value),end:Number(e.value),duration:1e3,drawFrame:f=>l({value:f,prefix:e.prefix,suffix:e.suffix}),requestRef:a}):l(e??Ee),()=>{a.current&&cancelAnimationFrame(a.current)}),[i,e,l]);const h=n(s),d=typeof h=="object"&&h!==null,y=h===Ee;return g?t.jsx(Rt,{}):d?t.jsxs(j.Typography,{variant:"h5",component:"div",weight:"medium",children:[t.jsx(Un,{children:h.prefix}),h.value,t.jsx(qn,{children:h.suffix})]}):t.jsx(j.Typography,{variant:"h5",component:"div",weight:"medium",color:y?"text.disabled":"default",whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",children:h})}const gt={};let we=null;function Zn({data:e,filterable:n,selectedBars:i,onSelectedBarsChange:r,echartsInstance:s}){const l=o.useTheme(),[a,p]=u.useState([]),c=u.useMemo(()=>s==null?void 0:s.getZr(),[s]);u.useEffect(()=>{function h(y){if(s){const[f]=s.convertFromPixel({seriesIndex:0},[y.offsetX,y.offsetY]);we=f??null}}function d(y){if(s&&we!==null){const[f]=s.convertFromPixel({seriesIndex:0},[y.offsetX,y.offsetY]);p(we===f?[]:[we,f].sort((m,v)=>m-v))}}if(s&&n){const y=Ue(c,"mousedown",h),f=Ue(c,"mousemove",d);return()=>{y==null||y(),f==null||f()}}},[c,s,n]),u.useEffect(()=>{function h(){if(a.length===2&&r){const d=e.reduce((y,f,m)=>((a[0]>=f[0]&&a[0]<=f[1]||a[1]>=f[0]&&a[1]<=f[1]||a[0]<=f[0]&&a[1]>=f[1])&&y.push(m),y),[]);r(e.length===d.length?[]:d)}p([]),we=null}if(s&&n)return Ue(c,"mouseup",h)},[c,s,a,e,r,n]);const g=u.useCallback(h=>{if(r){const d=new Set(i);d.has(h.dataIndex)?d.delete(h.dataIndex):d.add(h.dataIndex),r(d.size===e.length?[]:Array.from(d))}},[r,i,e.length]);return{markAreaOptions:a.length===2&&{data:[[{coord:[a[0]]},{coord:[a[1]]}]],itemStyle:{color:l.palette.primary.main,opacity:.2}},onEvents:n?{click:g}:{}}}function Ue(e,n,i){if(e!=null&&e.handler)return gt[n]=i,e.on(n,i),()=>{gt[n]&&(e!=null&&e.handler)&&e.off(n,i)}}function Jn({height:e}){return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{mb:2,children:t.jsx(o.Skeleton,{width:48,height:8})}),t.jsxs(Lt,{style:{height:e??_e},children:[t.jsx(ne,{variant:"rectangular",height:"20%"}),t.jsx(ne,{variant:"rectangular",height:"40%"}),t.jsx(ne,{variant:"rectangular",height:"60%"}),t.jsx(ne,{variant:"rectangular",height:"20%"}),t.jsx(ne,{variant:"rectangular",height:"80%"}),t.jsx(ne,{variant:"rectangular",height:"50%"}),t.jsx(ne,{variant:"rectangular",height:"20%"}),t.jsx(ne,{variant:"rectangular",height:"40%"}),t.jsx(ne,{variant:"rectangular",height:"60%"}),t.jsx(ne,{variant:"rectangular",height:"20%"}),t.jsx(ne,{variant:"rectangular",height:"80%"}),t.jsx(ne,{variant:"rectangular",height:"50%"})]})]})}const Qn=Bt(),eo=o.styled(o.Grid)(({theme:e})=>({marginBottom:e.spacing(2),flexDirection:"row",justifyContent:"space-between",alignItems:"center","& .MuiTypography-caption":{color:e.palette.text.secondary}})),to=o.styled(o.Link)(({theme:e})=>({...e.typography.caption,cursor:"pointer"})),no=[],oo=()=>{},Oe=e=>e;function io(e,n=Oe,i=Oe){if(!e)return null;if(Array.isArray(e)&&e.length===0)return;const r=Array.isArray(e)?e[0].marker:e.marker,s=Array.isArray(e)?e[0].data:e.data;if((s==null?void 0:s.value)===void 0)return;const[l,a,p]=s.value,c=te(n(l)),g=te(n(a)),h=te(i(p)),d=`${c} <span style="vertical-align: 1px;">—</span> ${g}`,y=`<div style="margin-left: 8px; display: inline">${h}</div>`;return`${d} <div style="margin-top: 4px">${String(r)}${y}</div>`}function ro({data:e,ticks:n,min:i,max:r,xAxisFormatter:s=Oe,yAxisFormatter:l=Oe,yAxisType:a="dense",selectedBars:p=no,onSelectedBarsChange:c=oo,tooltip:g=!0,tooltipFormatter:h=io,animation:d=!0,filterable:y=!0,height:f=200,isLoading:m}){const v=Z.useIntl(),x=o.useTheme(),b=j.useImperativeIntl(v),{showSkeleton:S}=de(!!m),k=!!y&&!!c,[T,w]=u.useState(),C=I=>w(I),M=u.useMemo(()=>ao(e,n,i,r),[e,n,i,r]),{onEvents:D,markAreaOptions:E}=Zn({data:M,filterable:k,selectedBars:p,onSelectedBarsChange:c,echartsInstance:T}),L=u.useMemo(()=>({show:g,trigger:"item",padding:[j.SPACING*.5,j.SPACING],borderWidth:0,textStyle:{...x.typography.caption,fontSize:11,color:x.palette.common.white},backgroundColor:x.palette.black[90],confine:!0,position:"top",formatter(I){return h(I,s,l)}}),[x,g,h,s,l]),P=u.useMemo(()=>({min:i,max:r,interval:(r-i)/M.length,axisLine:{show:!1},splitLine:{show:!0,lineStyle:{color:x.palette.black[4]}},axisTick:{show:!1},axisLabel:{showMinLabel:!0,showMaxLabel:!0,...x.typography.overlineDelicate,hideOverlap:!0,padding:[j.SPACING*.5,j.SPACING*.5,0,j.SPACING*.5],formatter:I=>{const O=te(s(I));return I===i?so(O):I===r?lo(O):O},color:x.palette.black[60]}}),[i,r,M.length,x,s]),N=u.useMemo(()=>{const I={margin:0,verticalAlign:"bottom",padding:[0,0,j.SPACING*1.25,0],inside:!0,color:R=>{const z=Math.max(...e.map(F=>F??Number.MIN_SAFE_INTEGER))||1;let q="transparent";return R>=z&&(q=x.palette.black[60]),q},...x.typography.overlineDelicate,formatter:R=>te(l(R))},O={verticalAlign:"middle",padding:[0,0,0,j.SPACING*.5],color:x.palette.black[60]},G=a==="dense"?I:O;return{type:"value",axisLine:{show:!1},splitLine:{show:!0,lineStyle:{color:x.palette.black[4]}},axisTick:{show:!1},axisLabel:{show:!0,showMaxLabel:!0,showMinLabel:!1,...G,...x.typography.overlineDelicate,formatter:R=>te(l(R))}}},[x.palette.black,x.typography.overlineDelicate,e,l,a]),V=u.useMemo(()=>{const I=i===r&&M.filter(R=>R[2]!==0).length===1,G=(I?[M[0],M[M.length-1]]:M).map((R,z)=>{const F=p.length&&!p.includes(z)?x.palette.black[25]:x.palette.secondary.main;return{value:R,itemStyle:{color:F}}});return{type:"custom",cursor:"pointer",markArea:E,renderItem:function(R,z){const q=R.dataIndex===M.length-1,F=R.dataIndex===0,H=G[R.dataIndex].itemStyle.color,J=z.value(0),ie=z.value(1),re=z.value(2),[W,K]=z.coord([J,re]),[X,Q]=z.size([ie-J,re]);return{type:"rect",shape:{x:I?W/10:W+(F?0:1),y:K,width:I?W-W/10:X-(q?0:1),height:Q},style:{fill:H},...!Qn&&{emphasis:{style:{fill:o.darken(H,.25)}}}}},encode:{x:[0,1],y:2,tooltip:[0,1,2]},data:G,animation:d}},[i,r,M,E,x.palette.black,x.palette.secondary.main,p,d]),_=u.useMemo(()=>({grid:{left:j.SPACING*.1,right:j.SPACING*.1,top:j.SPACING*2,bottom:j.SPACING*.5,containLabel:!0},tooltip:L,xAxis:P,yAxis:N,series:[V]}),[L,P,N,V]),A=p.reduce((I,O)=>I+=e[O]??0,0),$=I=>{I.key==="Enter"&&c([])};return S?t.jsx(Jn,{height:f}):t.jsxs("div",{children:[k&&t.jsxs(eo,{container:!0,children:[t.jsx(j.Typography,{variant:"caption",weight:"strong",children:p.length>0?b.formatMessage({id:"c4r.widgets.histogram.selectedItems"},{items:te(l(A))}):b.formatMessage({id:"c4r.widgets.histogram.all"})}),p.length>0&&t.jsx(to,{onClick:()=>c([]),onKeyDown:$,underline:"hover",tabIndex:0,children:b.formatMessage({id:"c4r.widgets.histogram.clear"})})]}),t.jsx(ye,{option:_,onEvents:D,lazyUpdate:!0,onChartReady:C,style:{maxHeight:f}})]})}function so(e){return`${Array(String(e).length).fill(" ").join("")}${e}`}function lo(e){const n=Array(String(e).length).fill(" ").join("");return`${e}${n}`}function ao(e,n,i,r){return e.map((s,l)=>[l===0?i:n[l-1],l===e.length-1?r:n[l],s])}function co(e,n,i,r){const s=o.useTheme(),l=u.useMemo(()=>n===pe.RANKING?e.slice().sort((c,g)=>(g.value??0)-(c.value??0)):e,[e,n]),a=u.useMemo(()=>{const c=[];let g=0;for(const h of l)c.length<i?c.push({...h}):g+=h.value??0;return g>0&&c.push({name:me,value:g,emphasis:{scale:!1}}),c},[i,l]);return u.useMemo(()=>{const c=s.palette.common.white;return a.map((g,h)=>{let d=c;if(r.length){const f=r[h%r.length];f&&(d=f)}else{const m=s.palette.qualitative.bold[h];m&&(d=m)}const y=g;return y.color=d,y})},[a,r,s])}const uo=o.styled(o.Box)(({theme:e})=>({zIndex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",paddingBottom:e.spacing(1)})),po=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1),maxWidth:"140px",textTransform:"uppercase"})),go=o.styled(o.Box)(({theme:e})=>({display:"inline-block",borderRadius:e.spacing(.5),width:e.spacing(1),minWidth:e.spacing(1),height:e.spacing(1)}));function ho({data:e,selectedCategories:n,formatter:i}){const[r,s]=u.useState(),l=u.useMemo(()=>{if(!e||e.length===0)return null;let g;n.length>0?g=e.filter(m=>n.includes(m.name)):g=e;const h=fo(g),d=g.find(m=>m===h);if(!d)return null;let y=0;for(const m of e)y+=m.value??0;const f=xo(d.value??0,y,i);return{...d,percentage:f}},[e,n,i]);u.useEffect(()=>{l&&s(l)},[l,s]);const{name:a,percentage:p,color:c}=r??{};return r?t.jsxs(uo,{children:[t.jsx(j.Typography,{variant:"h5",children:p}),t.jsxs(po,{children:[t.jsx(go,{bgcolor:c,component:"span"}),t.jsx(j.Typography,{component:"span",variant:"body2",noWrap:!0,children:a})]})]}):null}function fo(e){const n=e.filter(i=>i.name!==me);return n.length===0?e[0]:n.reduce((i,r)=>(r.value??0)>(i.value??0)?r:i)}function xo(e,n,i){let r=0;return n!==0&&(r=e/n*100),i?i(r):`${r}%`}const ht=32,mo=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",marginTop:e.spacing(.5)})),yo=o.styled("div")(()=>({display:"flex",alignItems:"center",justifyContent:"center",position:"relative"})),vo=o.styled(An)(()=>({position:"absolute",zIndex:1})),jo=o.styled("div")(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",gap:e.spacing(1),position:"absolute",zIndex:2})),wo=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(2),height:e.spacing(5)})),bo=o.styled("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5)}));function Ft({height:e}){const n=parseInt(String(e),10)||_e,i=n-ht,r=i-ht;return t.jsxs(o.Box,{mt:.5,children:[t.jsx(o.Skeleton,{height:8,width:64}),t.jsx(mo,{height:n,children:t.jsxs(yo,{children:[t.jsx(o.Skeleton,{variant:"circular",width:i,height:i}),t.jsx(vo,{variant:"circular",width:r,height:r}),t.jsxs(jo,{children:[t.jsx(o.Skeleton,{height:24,width:72}),t.jsx(o.Skeleton,{height:8,width:48})]})]})}),t.jsx(wo,{children:[...Array(2)].map((s,l)=>t.jsxs(bo,{children:[t.jsx(o.Skeleton,{variant:"circular",width:8,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]},l))})]})}const So=o.styled(o.Box)(({theme:e})=>({position:"relative",padding:e.spacing(1.25,1,0,1),width:"100%"})),ko=o.styled(o.Box)(({theme:e})=>({position:"relative",display:"flex",flexDirection:"row",overflowX:"hidden",gap:e.spacing(2),padding:e.spacing(.5),margin:e.spacing(-.5)})),Io=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(1),alignItems:"center",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"})),To=o.styled(o.Box)(({theme:e})=>({display:"inline-block",position:"absolute",left:e.spacing(-2),top:e.spacing(1),bottom:e.spacing(1),zIndex:1,width:e.spacing(2.5),background:`linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, ${e.palette.background.paper} 100%)`})),Mo=o.styled(o.Box)(({theme:e})=>({position:"absolute",padding:e.spacing(.25,1),top:e.spacing(0),right:0,background:e.palette.background.paper})),Co=o.styled(o.Box,{shouldForwardProp:e=>e!=="color"})(({theme:e,color:n})=>{const i=e.spacing(1);return{backgroundColor:n,borderRadius:"50%",width:i,height:i}});function Wt({series:e,selectedCategories:n,onCategoryClick:i}){var k,T;const r=o.useTheme(),[s,l]=u.useState(!1),[a,p]=u.useState(0),[c,g]=u.useState(void 0),h=u.useRef(null),d=u.useRef(null),y=u.useRef(null),f=Z.useIntl(),m=j.useImperativeIntl(f);function v(){p(a+1)}function x(){p(Math.max(a-1))}function b(w,C){w.key==="Enter"&&(i==null||i(C))}const S=u.useCallback(()=>{var C,M,D;const w=!!d.current&&d.current.scrollWidth>d.current.clientWidth;l(w),g(w&&d.current?(((C=h.current)==null?void 0:C.clientWidth)??0)-(((M=y.current)==null?void 0:M.clientWidth)??70):(((D=h.current)==null?void 0:D.clientWidth)??0)-12||500)},[h,d,y]);return u.useEffect(()=>{S()},[d,(k=d.current)==null?void 0:k.scrollWidth,(T=d.current)==null?void 0:T.clientWidth,S,a]),u.useEffect(()=>{if(typeof ResizeObserver>"u")return;let w;return h.current&&(w=new ResizeObserver(()=>{S()}),w.observe(h.current)),()=>{w==null||w.disconnect()}},[h,S]),t.jsxs(So,{ref:h,children:[t.jsx(ko,{ref:d,style:{maxWidth:`${c}px`},children:e.map((w,C)=>{if(C<a)return null;const M=n.length===0||n.includes(w.name);return t.jsxs(Io,{tabIndex:0,onClick:i?()=>i(w.name):void 0,onKeyDown:i?D=>b(D,w.name):void 0,style:{pointerEvents:!i||w.name==="Others"?"none":void 0},children:[t.jsx(Co,{color:M?w.color:r.palette.text.disabled}),t.jsx(j.Typography,{variant:"overline",color:M?void 0:"text.disabled",children:w.name})]},C)})}),(s||a>0)&&t.jsxs(Mo,{ref:y,children:[t.jsx(To,{}),t.jsx(o.Tooltip,{title:m.formatMessage({id:"c4r.widgets.chartLegend.next"}),children:t.jsx(o.IconButton,{size:"small",disabled:a===0,onClick:x,children:t.jsx(ee.ChevronLeft,{})})}),t.jsx(o.Tooltip,{title:m.formatMessage({id:"c4r.widgets.chartLegend.prev"}),children:t.jsx(o.IconButton,{size:"small",disabled:!s,onClick:v,children:t.jsx(ee.ChevronRight,{})})})]})]})}const Xe="232px",Ao=o.styled(o.Grid)(({theme:e})=>({flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:e.spacing(.5)})),Eo=o.styled(o.Box,{shouldForwardProp:e=>e!=="height"&&e!=="width"})(({height:e,width:n})=>({position:"relative",margin:"0 auto",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:n||"100%",height:e||"100%"})),Bo=o.styled(ye)(()=>({position:"absolute",top:0,right:0,left:0,bottom:0})),ft=[],Po={},Lo=e=>e;function Do({name:e,data:n,formatter:i=Lo,tooltipFormatter:r=No,percentFormatter:s,height:l=Xe,width:a=Xe,labels:p=Po,colors:c=ft,animation:g=!0,filterable:h=!0,selectedCategories:d=ft,onSelectedCategoriesChange:y,isLoading:f,maxItems:m=11,order:v=pe.RANKING}){const x=o.useTheme(),b=co(n,v,m,c),{showSkeleton:S}=de(!!f),k=Z.useIntl(),T=j.useImperativeIntl(k),w=u.useMemo(()=>s||(_=>`${k.formatNumber(_,{maximumFractionDigits:2,minimumFractionDigits:2})}%`),[k,s]),C=u.useMemo(()=>{let _;return r&&(_=A=>r(A,i,w)),{padding:[j.SPACING*.5,j.SPACING],backgroundColor:x.palette.black[90],borderColor:"transparent",textStyle:{color:x.palette.common.white},confine:!0,formatter:_}},[x.palette.black,x.palette.common.white,r,i,w]),M=u.useMemo(()=>[{type:"pie",name:e,animation:g,data:b.map(_=>{const A={..._},$=(d==null?void 0:d.length)&&!d.includes(A.name);return p!=null&&p[A.name]&&(A.name=p[A.name]),$?{...A,disabled:!0,itemStyle:{color:x.palette.black[25]}}:{...A,itemStyle:{color:A.color}}}),radius:["74%","90%"],selectedOffset:0,bottom:j.SPACING*1.5,label:{show:!1},emphasis:{focus:"series",scaleSize:5},itemStyle:{borderColor:x.palette.background.paper,borderWidth:1}}],[e,g,b,p,d,x]),D=u.useMemo(()=>({grid:{left:0,top:0,right:0,bottom:0},tooltip:C,legend:{show:!1},series:M}),[C,M]),E=u.useCallback(_=>{if(y){const A=[...d],{name:$}=b[_.dataIndex];if($===me)return;const I=A.indexOf($);I===-1?A.push($):A.splice(I,1),y(A)}},[b,y,d]),L=u.useCallback(_=>{if(y){const A=[...d],$=A.indexOf(_);$===-1?A.push(_):A.splice($,1),y(A)}},[y,d]),P={...h&&{click:E}},N=()=>{y==null||y([])},V=_=>{_.key==="Enter"&&N()};return S?t.jsx(Ft,{height:l}):t.jsxs(t.Fragment,{children:[h&&t.jsxs(Ao,{container:!0,children:[t.jsx(j.Typography,{variant:"caption",color:"textSecondary",children:d.length?T.formatMessage({id:"c4r.widgets.pie.selectedItems"},{items:d.length}):T.formatMessage({id:"c4r.widgets.pie.allSelected"})}),d.length>0&&t.jsx(o.Link,{variant:"caption",onClick:N,onKeyDown:V,tabIndex:0,children:T.formatMessage({id:"c4r.widgets.pie.clear"})})]}),t.jsxs(Eo,{height:l,width:a,children:[t.jsx(ho,{data:b,selectedCategories:d,formatter:w}),t.jsx(Bo,{option:D,onEvents:P,lazyUpdate:!0,style:{height:l,width:a}})]}),b.length>0&&t.jsx(Wt,{series:b,selectedCategories:d,onCategoryClick:y&&L})]})}function No(e,n,i){var c;const r=Array.isArray(e)?e[0]:e;if(!r)return null;const s=te(n(r.value)),l=i(r.percent)||`${r.percent}%`,p=`display:inline-block;border-radius:4px;width:8px;height:8px;background-color:${((c=r.data)==null?void 0:c.color)||r.textStyle.color}`;return`
|
|
5
|
-
<div style="white-space:normal;"><p style="max-width:${
|
|
3
|
+
</div>`;return`<div style="margin-top: 4px">${String(p)}${d}</div>`}).join(" "),r}function Tn({height:e,labels:n=In,yAxisData:i,selectedBars:r=Sn,series:s,colors:l,tooltip:a=!0,tooltipFormatter:p=kn,xAxisFormatter:c=lt,yAxisFormatter:g=lt,onSelectedBarsChange:h,animation:d=!0,filterable:y=!0,stacked:f=!0,...m}){const v=o.useTheme(),x=u.useMemo(()=>(s??[]).map(I=>n[I]??I),[s,n]),b=u.useMemo(()=>Array.isArray(i[0])?i:[i],[i]),S=u.useMemo(()=>typeof l=="string"?[l]:Array.isArray(l)&&l.length?l:b.length<=1||x.length===1?[v.palette.secondary.main]:b.length===2||x.length===2?[v.palette.secondary.light,v.palette.secondary.dark]:Object.values(v.palette.qualitative.bold||{}),[l,v,b,x]);return{...m,tooltip:a,tooltipFormatter:p,xAxisFormatter:c,yAxisFormatter:g,onSelectedBarsChange:h,animation:d,filterable:y,stacked:f,labels:n,height:e??parseInt(v.spacing(22)),selectedBars:Mn(r),yAxisData:b,colors:S,series:x}}function Mn(e){return(e??[]).length?e.map(n=>Array.isArray(n)&&n.length===2?n:Array.isArray(n)?[...Array(2)].map((r,s)=>n[s]??0):[n,0]):[]}var Cn=function e(n,i){if(n===i)return!0;if(n&&i&&typeof n=="object"&&typeof i=="object"){if(n.constructor!==i.constructor)return!1;var r,s,l;if(Array.isArray(n)){if(r=n.length,r!=i.length)return!1;for(s=r;s--!==0;)if(!e(n[s],i[s]))return!1;return!0}if(n.constructor===RegExp)return n.source===i.source&&n.flags===i.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===i.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===i.toString();if(l=Object.keys(n),r=l.length,r!==Object.keys(i).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(i,l[s]))return!1;for(s=r;s--!==0;){var a=l[s];if(!e(n[a],i[a]))return!1}return!0}return n!==n&&i!==i};const xe=j.getDefaultExportFromCjs(Cn);class ye extends jn{componentDidUpdate(n){const{shouldSetOption:i}=this.props;if(typeof i=="function"&&!i(n,this.props))return;if(!xe(n.theme,this.props.theme)||!xe(n.opts,this.props.opts)){this.dispose(),this.renderNewEcharts();return}const r=this.getEchartsInstance();xe(n.onEvents,this.props.onEvents)||(this.offEvents(r,n.onEvents),this.bindEvents(r,this.props.onEvents));const s=["option","notMerge","lazyUpdate","showLoading","loadingOption"];xe(at(this.props,s),at(n,s))||this.updateEChartsOption(),(!xe(n.style,this.props.style)||!xe(n.className,this.props.className))&&this.resize()}updateEChartsOption(){const n=this.props.option,i=this.props.loadingOption||null,{lazyUpdate:r,showLoading:s}=this.props,l=this.getEchartsInstance();return l.setOption(n,{replaceMerge:["series"],lazyUpdate:r}),s?l.showLoading(i):l.hideLoading(),l}offEvents(n,i){if(i)for(const r in i)typeof r=="string"&&n.off(r)}}function at(e,n){const i={};return n.forEach(r=>{i[r]=e[r]}),i}const _e=240,Pt=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"flex-end",justifyContent:"space-between",position:"relative",padding:e.spacing(0,2),"&::before":{content:'""',position:"absolute",top:0,right:0,left:0,bottom:0,backgroundSize:e.spacing(4,4),backgroundImage:`linear-gradient(to bottom, ${e.palette.grey[50]} 1px, transparent 1px)`,transform:"scaleY(-1)"}})),Lt=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"flex-end",justifyContent:"space-between",backgroundImage:`linear-gradient(${e.palette.grey[50]} 0.5px, transparent 0.5px, transparent calc(100% - 0.5px), ${e.palette.grey[50]} calc(100% - 0.5px)), linear-gradient(90deg, ${e.palette.grey[50]} 0.5px, transparent 0.5px, transparent calc(100% - 0.5px), ${e.palette.grey[50]} calc(100% - 0.5px))`,backgroundSize:"8.33% 20%",border:`0.5px solid ${e.palette.grey[50]}`})),je=o.styled(o.Skeleton)(({theme:e})=>({flex:1,maxWidth:e.spacing(12),"& + &":{marginLeft:e.spacing(1)}})),ne=o.styled(o.Skeleton)(({theme:e})=>({flex:1,maxWidth:e.spacing(8),"& + &":{marginLeft:"1px"}})),An=o.styled(o.Skeleton)(({theme:e})=>({backgroundColor:e.palette.common.white})),ct=o.styled(o.Skeleton)(({theme:e})=>({backgroundColor:e.palette.grey[100]}));function En({height:e}){return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{mb:2,children:t.jsx(o.Skeleton,{width:48,height:8})}),t.jsxs(Pt,{style:{height:e||_e},children:[t.jsx(je,{variant:"rectangular",height:"20%"}),t.jsx(je,{variant:"rectangular",height:"40%"}),t.jsx(je,{variant:"rectangular",height:"60%"}),t.jsx(je,{variant:"rectangular",height:"20%"}),t.jsx(je,{variant:"rectangular",height:"80%"})]})]})}function de(e){const[n,i]=u.useState(!1),[r,s]=u.useState(!1);return u.useEffect(()=>{e&&!r&&(i(!0),s(!0)),e||i(!1)},[e,r]),{showSkeleton:n}}const Bn=Bt(),Pn=o.styled(o.Grid)(({theme:e})=>({marginBottom:e.spacing(2),flexDirection:"row",justifyContent:"space-between",alignItems:"center","& .MuiTypography-caption":{color:e.palette.text.secondary}})),Ln=o.styled(o.Link)(({theme:e})=>({...e.typography.caption,cursor:"pointer"}));function Dn(e){const{yAxisData:n,xAxisData:i,series:r,selectedBars:s,onSelectedBarsChange:l,tooltip:a,tooltipFormatter:p,labels:c,colors:g,xAxisFormatter:h,yAxisFormatter:d,stacked:y,height:f,filterable:m,animation:v,isLoading:x}=Tn(e),b=r.length>1,S=o.useTheme(),I=Z.useIntl(),T=j.useImperativeIntl(I),{showSkeleton:w}=de(!!x),C=u.useMemo(()=>({show:a,trigger:"axis",padding:[parseInt(S.spacing(.5)),parseInt(S.spacing(1))],borderWidth:0,textStyle:{...S.typography.caption,fontSize:11,color:S.palette.common.white},backgroundColor:S.palette.black[90],position:function(k,O,G,R,H){const q={top:0};return H.contentSize[0]<H.viewSize[0]-k[0]?q.left=k[0]:q.right=H.viewSize[0]-k[0],q},formatter:k=>p(k,d)}),[S,a,p,d]),M=u.useMemo(()=>i.map(k=>te(h(c[k]??String(k)))),[i,c,h]),D=u.useMemo(()=>({type:"category",axisLine:{show:!1},axisTick:{show:!1},axisLabel:{...S.typography.overlineDelicate,padding:[parseInt(S.spacing(.5)),0,0,0]},data:M}),[S,M]),E=u.useMemo(()=>{let k=[];return y?k=n.reduce((O,G)=>(G.forEach((R,H)=>O[H]=(O[H]??0)+(R??Number.MIN_SAFE_INTEGER)),O),[]):k=n.flat().map(O=>O??Number.MIN_SAFE_INTEGER),Math.max(...k)},[n,y]),L=u.useMemo(()=>({type:"value",axisLabel:{margin:0,verticalAlign:"bottom",padding:[0,0,parseInt(S.spacing(1.25)),0],show:!0,showMaxLabel:!0,showMinLabel:!1,inside:!0,color:k=>k>=E?S.palette.black[60]:"transparent",...S.typography.overlineDelicate,formatter:k=>te(d(k))},axisLine:{show:!1},axisTick:{show:!1},splitLine:{show:!0,onZero:!1,lineStyle:{color:S.palette.black[4]}}}),[S,E,d]),P=u.useMemo(()=>n.map((k,O)=>({type:"bar",name:r[O]??"",animation:v,barMaxWidth:100,data:k.map((G,R)=>{const H=s.some(([F,z=0])=>F===R&&z===O),q=!!s.length&&!H;return{value:G,...q&&{itemStyle:{color:S.palette.black[25]},disabled:!0}}}),...y&&{stack:"total"},...!Bn&&{emphasis:{focus:"series",itemStyle:{color:o.darken(g[O]??"#000",.25)}}}})),[v,g,r,n,s,y,S]),N=u.useMemo(()=>({grid:{left:M.length>=4?dt(String(M[0]),M.length):0,top:parseInt(S.spacing(2)),right:M.length>=4?dt(String(M[M.length-1]),M.length):0,bottom:0,containLabel:!0},axisPointer:{lineStyle:{color:S.palette.black[40]}},color:g,tooltip:C,xAxis:D,yAxis:L,series:P}),[M,S,g,C,D,L,P]),V=()=>{l&&l([],[])},_=k=>{k.key==="Enter"&&V()},B=u.useCallback(k=>{if(l){const O=[...s],{dataIndex:G,componentIndex:R}=k,H=O.findIndex(([F,z=0])=>G===F&&R===z);H===-1?O.push([G,R]):O.splice(H,1);const q=O.map(([F,z=0])=>({xAxis:i[F],serie:r[z],yAxis:n[z][F]}));l(b?O:O.map(F=>F[0]),q)}},[n,l,s,i,r,b]),$=u.useMemo(()=>m?{click:B}:{},[m,B]);return w?t.jsx(En,{height:f}):t.jsxs("div",{children:[l&&t.jsxs(Pn,{container:!0,children:[t.jsx(j.Typography,{variant:"caption",children:s.length>0?T.formatMessage({id:"c4r.widgets.bar.selectedItems"},{items:s.length}):T.formatMessage({id:"c4r.widgets.bar.all"})}),s&&s.length>0&&t.jsx(Ln,{onClick:()=>V(),onKeyDown:_,underline:"hover",tabIndex:0,children:T.formatMessage({id:"c4r.widgets.bar.clear"})})]}),!!N&&t.jsx(ye,{option:N,lazyUpdate:!0,notMerge:!0,onEvents:$,style:{height:f}})]})}function dt(e="",n=0){return n<=15&&e.length<=8?0:e.length*8.5/6}const ue="__rest__",me="Others";var pe=(e=>(e.RANKING="ranking",e.FIXED="fixed",e))(pe||{});const Dt=o.styled(o.Grid)(({theme:e})=>({maxHeight:e.spacing(40),overflow:"auto",padding:0})),Nt=o.styled(o.Grid,{shouldForwardProp:e=>e!=="selectable"&&e!=="name"&&e!=="unselected"})(({theme:e,selectable:n,name:i,unselected:r})=>({flexDirection:"row",maxWidth:"100%",padding:e.spacing(.5,.25),margin:0,"> .MuiGrid-item":{paddingTop:0,paddingLeft:0},"&:focus-visible":{outline:"none !important",boxShadow:`inset 0 0 0 2px ${e.palette.primary.main} !important`},...r&&{color:e.palette.text.disabled,".progressbar div":{backgroundColor:e.palette.text.disabled}},...i!==ue&&n&&{cursor:"pointer",flexWrap:"nowrap","&:hover .progressbar div":{backgroundColor:e.palette.secondary.dark}},...i===ue&&{cursor:"default",".progressbar div":{backgroundColor:e.palette.text.disabled}}})),ut=o.styled(o.Grid)(({theme:{spacing:e,palette:n}})=>({flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:e(1.5),paddingRight:e(1),"& .MuiTypography-caption":{color:n.text.secondary}})),Nn=o.styled(o.Grid)(({theme:e})=>({height:e.spacing(.5),width:"100%",margin:e.spacing(.5,0,.25,0),borderRadius:e.spacing(.5),backgroundColor:e.palette.action.disabledBackground,"& div":{width:0,height:"100%",borderRadius:e.spacing(.5),backgroundColor:e.palette.secondary.main,transition:`background-color ${e.transitions.easing.sharp} ${e.transitions.duration.shortest}ms,
|
|
4
|
+
width ${e.transitions.easing.sharp} ${e.transitions.duration.complex}ms`}})),On=o.styled(o.Grid,{shouldForwardProp:e=>e!=="isSelectable"})(({theme:e,isSelectable:n})=>({...n&&{width:`calc(100% - ${e.spacing(4)})`}})),$n=o.styled(j.Typography)(({theme:e})=>({fontWeight:e.typography.fontWeightBold,marginRight:e.spacing(2)})),Ae=o.styled(o.Link)(({theme:e})=>({...e.typography.caption,cursor:"pointer","& + hr":{margin:e.spacing(0,1)}})),Rn=o.styled(o.Box)(({theme:e})=>({...e.typography.body2})),pt=o.styled(o.Button)(({theme:e})=>({position:"absolute",left:"-999px",top:"-1px",width:"1px",height:"1px",display:"inline-flex","&:focus-visible":{position:"static",width:"auto",height:"auto",marginTop:e.spacing(2)}})),Fn=o.styled(o.Skeleton)(({theme:e})=>({marginTop:e.spacing(1.25),marginBottom:e.spacing(1.75)})),Wn=e=>e%2===1,Ot=()=>t.jsxs(t.Fragment,{children:[t.jsx(o.Skeleton,{width:48,height:8}),t.jsx(Dt,{container:!0,mt:3,children:[...Array(6)].map((e,n)=>t.jsxs(Nt,{container:!0,spacing:1,children:[t.jsxs(o.Grid,{container:!0,item:!0,direction:"row",justifyContent:"space-between",children:[t.jsx(o.Skeleton,{width:Wn(n)?72:48,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]}),t.jsx(Fn,{height:4,width:"100%"})]},n))})]});function $t(e){const n=u.useRef();return u.useEffect(()=>{n.current=e}),n.current}function Xe({start:e,end:n,duration:i,drawFrame:r,requestRef:s}){if(e===n&&!(e===0&&n===0))return;const a=n-e;let p=e;const c=a/(i/1e3*60),g=()=>{p+=c,r(Math.floor(p)),c>0&&p<n||c<0&&p>n?s.current=requestAnimationFrame(g):r(n)};s.current=requestAnimationFrame(g)}function _n({start:e,end:n,duration:i,drawFrame:r,requestRef:s}){if(e.length===n.length&&e.every((f,m)=>f.value===n[m].value))return;let a=n.map((f,m)=>e[m]&&e[m].name===f.name?{...f,value:e[m].value}:f),p=0;const c=a.map((f,m)=>n[m].value-f.value);if(c.every(f=>f===0)){r(n);return}const h=i/1e3*60,d=c.map(f=>f/h),y=()=>{p<h?(a=a.map((f,m)=>{const v=Math.floor(f.value+d[m]),x=m>0&&Math.floor(f.value+d[m-1]);return{...f,value:v===x?n[m].value:v}}),r(a),p++,s.current=requestAnimationFrame(y)):r(n)};s.current=requestAnimationFrame(y)}const Gn=[],Hn={},zn=e=>e,Ve=()=>{},Yn=e=>e.reduce((n,i)=>n+(i.value??0),0);function Vn({data:e,formatter:n=zn,labels:i=Hn,maxItems:r=5,order:s=pe.RANKING,selectedCategories:l=Gn,onSelectedCategoriesChange:a=Ve,onMaxItemsOverflow:p=Yn,animation:c=!0,filterable:g=!0,searchable:h=!0,isLoading:d}){const y=o.useTheme(),[f,m]=u.useState([]),[v,x]=u.useState(1),[b,S]=u.useState(!1),[I,T]=u.useState(""),[w,C]=u.useState([]),[M,D]=u.useState([]),[E,L]=u.useState([]),P=u.useRef(null),N=u.useRef(),V=$t(E),_=u.useRef([]),{showSkeleton:B}=de(!!d),$=Z.useIntl(),k=j.useImperativeIntl($);function O(A){return f.reduce((Y,U)=>(A.includes(U.name)&&Y.push(U.name),Y),[])}function G(A){if(A!==ue){let Y;l.includes(A)?Y=l.filter(U=>U!==A):Y=[...l,A],a&&a(Y)}}const R=()=>a([]),H=A=>{A.key==="Enter"&&R()},q=()=>{a([]),C([])},F=A=>{A.key==="Enter"&&q()},z=()=>{C(O(l))},J=A=>{A.key==="Enter"&&z()},ie=()=>{const A=O(M);a([...A]),C([...A]),D([]),S(!1),T("")},re=A=>{A.key==="Enter"&&ie()},W=()=>{T(""),S(!1)},X=A=>{if(A!==ue){let Y;M.includes(A)?Y=M.filter(U=>U!==A):Y=[...M,A],D(Y)}},K=A=>{A.currentTarget.scrollIntoView()},Q=A=>{T(A.currentTarget.value)},ge=()=>{S(!0),D([...l])},ve=u.useCallback(A=>{if(b)return I?A.filter(Y=>{var se;if(!Y.name)return!1;const U=String(Y.name);return!!(U.toLowerCase().includes(I.toLowerCase())||(se=i[U])!=null&&se.toLowerCase().includes(I.toLowerCase()))}):A;if(w.length)return w.reduce((U,se)=>{const Ce=A.find(le=>le.name===se);return U.push({name:se,value:Ce?Ce.value:null}),U},[]);{const Y=A.slice(0,r);if(Y.length<A.length){const U={name:ue,value:p(A.slice(r))};return[...Y,U]}else return Y}},[w,i,r,I,b,p]),he=u.useCallback(()=>{const A=w.length;return A?e.length-A:e.length-r},[e,r,w]),it=u.useCallback(A=>A===ue?`Others ${h?"":`(${he()})`}`:i[String(A)]??String(A),[he,i,h]),hn=u.useCallback(A=>A>=v?A!=null?"100%":0:`${(A||0)*100/v}%`,[v]);u.useEffect(()=>{l.length===0&&C([])},[l]),u.useEffect(()=>{if(e){if(s===pe.RANKING){const A=[...e].sort((U,se)=>(se.value??0)-(U.value??0)),Y=ve(A);Y.length>0?x(Y[0].value??0):x(1),m(Y)}else if(s===pe.FIXED){x(Math.max(...e.map(Y=>Y.value??0)));const A=ve(e);m(A)}}},[w,ve,e,i,r,s,I,b]),u.useEffect(()=>{V&&(_.current=V)},[V]),u.useEffect(()=>{if(c)return _n({start:(_.current||[]).map(A=>({...A,value:A.value??0})),end:f.map(A=>({...A,value:A.value??0})),duration:500,drawFrame:A=>L(A),requestRef:P}),()=>{P.current&&cancelAnimationFrame(P.current)};L(f)},[c,f]),u.useEffect(()=>{b&&N.current&&N.current.focus()},[b,N]);function fn({data:A,onCategoryClick:Y}){const U=n(A.value??0),[se,Ce]=u.useState(!1),le=u.useRef(null),ze=()=>{var rt,st;const Ye=(((rt=le==null?void 0:le.current)==null?void 0:rt.scrollWidth)??0)>(((st=le==null?void 0:le.current)==null?void 0:st.clientWidth)??0);Ce(Ye)};u.useEffect(()=>(ze(),window.addEventListener("resize",ze),()=>{window.removeEventListener("resize",ze)}),[]);const yn=Ye=>{Ye.key==="Enter"&&Y()},vn=!b&&l.length>0&&!l.includes(A.name);return t.jsxs(Nt,{container:!0,direction:"row",spacing:1,onClick:g?Y:Ve,onKeyDown:g?yn:Ve,selectable:g,unselected:vn,name:A.name===ue?ue:"",tabIndex:g?0:-1,children:[g&&b&&t.jsx(o.Grid,{item:!0,mr:1,children:t.jsx(o.Checkbox,{checked:M.includes(A.name),tabIndex:-1})}),t.jsxs(On,{container:!0,item:!0,xs:!0,isSelectable:b,children:[t.jsxs(o.Grid,{container:!0,item:!0,direction:"row",justifyContent:"space-between",wrap:"nowrap",children:[t.jsx(o.Tooltip,{title:it(A.name),disableHoverListener:!se,children:t.jsx($n,{variant:"body2",noWrap:!0,ref:le,children:it(A.name)})}),typeof U=="object"&&U!==null?t.jsxs("span",{children:[U.prefix,U.value,U.suffix]}):t.jsx("span",{children:U})]}),t.jsx(Nn,{className:"progressbar",item:!0,children:t.jsx("div",{style:{width:hn(A.value??0)}})})]})]})}if((e==null?void 0:e.length)===0||B)return t.jsx(Ot,{});const xn=({index:A,style:Y})=>{const U=E[A];return U?t.jsx("div",{style:Y,children:t.jsx(fn,{data:U,onCategoryClick:()=>b?X(U.name):G(U.name)})}):null},mn=()=>b?320:E.length<=r?E.length*38:w.length>0?w.length*38:(r+1)*38;return t.jsxs(Rn,{children:[g&&f.length>0&&t.jsxs(ut,{container:!0,children:[t.jsx(j.Typography,{variant:"caption",children:l.length>0?k.formatMessage({id:"c4r.widgets.category.selectedItems"},{items:l.length}):k.formatMessage({id:"c4r.widgets.category.all"})}),b?t.jsx(Ae,{onClick:ie,onKeyDown:re,underline:"hover",tabIndex:0,"data-testid":"primaryApplyButton",children:k.formatMessage({id:"c4r.widgets.category.apply"})}):w.length>0?t.jsx(Ae,{onClick:q,onKeyDown:F,underline:"hover",tabIndex:0,children:k.formatMessage({id:"c4r.widgets.category.unlock"})}):l.length>0&&t.jsxs(o.Grid,{container:!0,direction:"row",justifyContent:"flex-end",item:!0,xs:!0,children:[t.jsx(Ae,{onClick:z,onKeyDown:J,underline:"hover",tabIndex:0,children:k.formatMessage({id:"c4r.widgets.category.lock"})}),t.jsx(o.Divider,{orientation:"vertical",flexItem:!0}),t.jsx(Ae,{onClick:R,onKeyDown:H,underline:"hover",tabIndex:0,children:k.formatMessage({id:"c4r.widgets.category.clear"})})]})]}),e.length>r&&b&&t.jsxs(ut,{container:!0,children:[t.jsx(o.TextField,{size:"small",sx:{mt:-.5},placeholder:k.formatMessage({id:"c4r.widgets.category.search"}),onChange:Q,onFocus:K,InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx(Te.Search,{})})},inputProps:{tabIndex:0,ref:N}}),t.jsx(pt,{size:"small",onClick:W,children:k.formatMessage({id:"c4r.widgets.category.cancel"})})]}),t.jsx(Dt,{container:!0,item:!0,children:E.length?t.jsx(wn.FixedSizeList,{outerElementType:A=>t.jsx("div",{...A,"data-testid":"category-widget-list"}),height:mn(),width:"100%",itemCount:E.length,itemSize:y.spacingValue*4.5,children:xn}):t.jsxs(o.Box,{children:[t.jsx(j.Typography,{variant:"body2",children:k.formatMessage({id:"c4r.widgets.category.noResults"})}),t.jsx(j.Typography,{component:"p",variant:"caption",mb:2,children:k.formatMessage({id:"c4r.widgets.category.noResultsMessage"},{searchValue:I})})]})}),b&&t.jsx(pt,{size:"small",onClick:ie,children:k.formatMessage({id:"c4r.widgets.category.apply"})}),e.length>r&&h?b?t.jsx(o.Box,{mt:1.5,children:t.jsx(o.Button,{size:"small",color:"primary",onClick:W,"data-testid":"primaryCancelButton",children:k.formatMessage({id:"c4r.widgets.category.cancel"})})}):t.jsx(o.Box,{mt:1.5,children:t.jsx(o.Button,{"data-testid":"show-all-categories-button",size:"small",color:"primary",startIcon:t.jsx(Te.Search,{}),onClick:ge,children:k.formatMessage({id:"c4r.widgets.category.searchInfo"},{elements:he()})})}):null]})}const Rt=()=>t.jsx(o.Box,{pt:.5,children:t.jsx(o.Skeleton,{height:24,width:120})}),Un=o.styled("span")(()=>({marginRight:"2px"})),qn=o.styled("span")(()=>({marginLeft:"2px"})),Ee="-",Xn=e=>e;function Kn({data:e=Ee,formatter:n=Xn,animation:i=!0,isLoading:r=!1}){const[s,l]=u.useState(Ee),a=u.useRef(null),p=$t(s),c=u.useRef(p),{showSkeleton:g}=de(!!r);u.useEffect(()=>(typeof e=="number"&&i?Xe({start:c.current||0,end:e,duration:500,drawFrame:f=>l(f),requestRef:a}):typeof e=="object"&&i&&e&&c.current&&e.value!==null&&e.value!==void 0?Xe({start:Number(c.current.value),end:Number(e.value),duration:1e3,drawFrame:f=>l({value:f,prefix:e.prefix,suffix:e.suffix}),requestRef:a}):l(e??Ee),()=>{a.current&&cancelAnimationFrame(a.current)}),[i,e,l]);const h=n(s),d=typeof h=="object"&&h!==null,y=h===Ee;return g?t.jsx(Rt,{}):d?t.jsxs(j.Typography,{variant:"h5",component:"div",weight:"medium",children:[t.jsx(Un,{children:h.prefix}),h.value,t.jsx(qn,{children:h.suffix})]}):t.jsx(j.Typography,{variant:"h5",component:"div",weight:"medium",color:y?"text.disabled":"default",whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",children:h})}const gt={};let we=null;function Zn({data:e,filterable:n,selectedBars:i,onSelectedBarsChange:r,echartsInstance:s}){const l=o.useTheme(),[a,p]=u.useState([]),c=u.useMemo(()=>s==null?void 0:s.getZr(),[s]);u.useEffect(()=>{function h(y){if(s){const[f]=s.convertFromPixel({seriesIndex:0},[y.offsetX,y.offsetY]);we=f??null}}function d(y){if(s&&we!==null){const[f]=s.convertFromPixel({seriesIndex:0},[y.offsetX,y.offsetY]);p(we===f?[]:[we,f].sort((m,v)=>m-v))}}if(s&&n){const y=Ue(c,"mousedown",h),f=Ue(c,"mousemove",d);return()=>{y==null||y(),f==null||f()}}},[c,s,n]),u.useEffect(()=>{function h(){if(a.length===2&&r){const d=e.reduce((y,f,m)=>((a[0]>=f[0]&&a[0]<=f[1]||a[1]>=f[0]&&a[1]<=f[1]||a[0]<=f[0]&&a[1]>=f[1])&&y.push(m),y),[]);r(e.length===d.length?[]:d)}p([]),we=null}if(s&&n)return Ue(c,"mouseup",h)},[c,s,a,e,r,n]);const g=u.useCallback(h=>{if(r){const d=new Set(i);d.has(h.dataIndex)?d.delete(h.dataIndex):d.add(h.dataIndex),r(d.size===e.length?[]:Array.from(d))}},[r,i,e.length]);return{markAreaOptions:a.length===2&&{data:[[{coord:[a[0]]},{coord:[a[1]]}]],itemStyle:{color:l.palette.primary.main,opacity:.2}},onEvents:n?{click:g}:{}}}function Ue(e,n,i){if(e!=null&&e.handler)return gt[n]=i,e.on(n,i),()=>{gt[n]&&(e!=null&&e.handler)&&e.off(n,i)}}function Jn({height:e}){return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{mb:2,children:t.jsx(o.Skeleton,{width:48,height:8})}),t.jsxs(Lt,{style:{height:e??_e},children:[t.jsx(ne,{variant:"rectangular",height:"20%"}),t.jsx(ne,{variant:"rectangular",height:"40%"}),t.jsx(ne,{variant:"rectangular",height:"60%"}),t.jsx(ne,{variant:"rectangular",height:"20%"}),t.jsx(ne,{variant:"rectangular",height:"80%"}),t.jsx(ne,{variant:"rectangular",height:"50%"}),t.jsx(ne,{variant:"rectangular",height:"20%"}),t.jsx(ne,{variant:"rectangular",height:"40%"}),t.jsx(ne,{variant:"rectangular",height:"60%"}),t.jsx(ne,{variant:"rectangular",height:"20%"}),t.jsx(ne,{variant:"rectangular",height:"80%"}),t.jsx(ne,{variant:"rectangular",height:"50%"})]})]})}const Qn=Bt(),eo=o.styled(o.Grid)(({theme:e})=>({marginBottom:e.spacing(2),flexDirection:"row",justifyContent:"space-between",alignItems:"center","& .MuiTypography-caption":{color:e.palette.text.secondary}})),to=o.styled(o.Link)(({theme:e})=>({...e.typography.caption,cursor:"pointer"})),no=[],oo=()=>{},Oe=e=>e;function io(e,n=Oe,i=Oe){if(!e)return null;if(Array.isArray(e)&&e.length===0)return;const r=Array.isArray(e)?e[0].marker:e.marker,s=Array.isArray(e)?e[0].data:e.data;if((s==null?void 0:s.value)===void 0)return;const[l,a,p]=s.value,c=te(n(l)),g=te(n(a)),h=te(i(p)),d=`${c} <span style="vertical-align: 1px;">—</span> ${g}`,y=`<div style="margin-left: 8px; display: inline">${h}</div>`;return`${d} <div style="margin-top: 4px">${String(r)}${y}</div>`}function ro({data:e,ticks:n,min:i,max:r,xAxisFormatter:s=Oe,yAxisFormatter:l=Oe,yAxisType:a="dense",selectedBars:p=no,onSelectedBarsChange:c=oo,tooltip:g=!0,tooltipFormatter:h=io,animation:d=!0,filterable:y=!0,height:f=200,isLoading:m}){const v=Z.useIntl(),x=o.useTheme(),b=j.useImperativeIntl(v),{showSkeleton:S}=de(!!m),I=!!y&&!!c,[T,w]=u.useState(),C=k=>w(k),M=u.useMemo(()=>ao(e,n,i,r),[e,n,i,r]),{onEvents:D,markAreaOptions:E}=Zn({data:M,filterable:I,selectedBars:p,onSelectedBarsChange:c,echartsInstance:T}),L=u.useMemo(()=>({show:g,trigger:"item",padding:[j.SPACING*.5,j.SPACING],borderWidth:0,textStyle:{...x.typography.caption,fontSize:11,color:x.palette.common.white},backgroundColor:x.palette.black[90],confine:!0,position:"top",formatter(k){return h(k,s,l)}}),[x,g,h,s,l]),P=u.useMemo(()=>({min:i,max:r,interval:(r-i)/M.length,axisLine:{show:!1},splitLine:{show:!0,lineStyle:{color:x.palette.black[4]}},axisTick:{show:!1},axisLabel:{showMinLabel:!0,showMaxLabel:!0,...x.typography.overlineDelicate,hideOverlap:!0,padding:[j.SPACING*.5,j.SPACING*.5,0,j.SPACING*.5],formatter:k=>{const O=te(s(k));return k===i?so(O):k===r?lo(O):O},color:x.palette.black[60]}}),[i,r,M.length,x,s]),N=u.useMemo(()=>{const k={margin:0,verticalAlign:"bottom",padding:[0,0,j.SPACING*1.25,0],inside:!0,color:R=>{const H=Math.max(...e.map(F=>F??Number.MIN_SAFE_INTEGER))||1;let q="transparent";return R>=H&&(q=x.palette.black[60]),q},...x.typography.overlineDelicate,formatter:R=>te(l(R))},O={verticalAlign:"middle",padding:[0,0,0,j.SPACING*.5],color:x.palette.black[60]},G=a==="dense"?k:O;return{type:"value",axisLine:{show:!1},splitLine:{show:!0,lineStyle:{color:x.palette.black[4]}},axisTick:{show:!1},axisLabel:{show:!0,showMaxLabel:!0,showMinLabel:!1,...G,...x.typography.overlineDelicate,formatter:R=>te(l(R))}}},[x.palette.black,x.typography.overlineDelicate,e,l,a]),V=u.useMemo(()=>{const k=i===r&&M.filter(R=>R[2]!==0).length===1,G=(k?[M[0],M[M.length-1]]:M).map((R,H)=>{const F=p.length&&!p.includes(H)?x.palette.black[25]:x.palette.secondary.main;return{value:R,itemStyle:{color:F}}});return{type:"custom",cursor:"pointer",markArea:E,renderItem:function(R,H){const q=R.dataIndex===M.length-1,F=R.dataIndex===0,z=G[R.dataIndex].itemStyle.color,J=H.value(0),ie=H.value(1),re=H.value(2),[W,X]=H.coord([J,re]),[K,Q]=H.size([ie-J,re]);return{type:"rect",shape:{x:k?W/10:W+(F?0:1),y:X,width:k?W-W/10:K-(q?0:1),height:Q},style:{fill:z},...!Qn&&{emphasis:{style:{fill:o.darken(z,.25)}}}}},encode:{x:[0,1],y:2,tooltip:[0,1,2]},data:G,animation:d}},[i,r,M,E,x.palette.black,x.palette.secondary.main,p,d]),_=u.useMemo(()=>({grid:{left:j.SPACING*.1,right:j.SPACING*.1,top:j.SPACING*2,bottom:j.SPACING*.5,containLabel:!0},tooltip:L,xAxis:P,yAxis:N,series:[V]}),[L,P,N,V]),B=p.reduce((k,O)=>k+=e[O]??0,0),$=k=>{k.key==="Enter"&&c([])};return S?t.jsx(Jn,{height:f}):t.jsxs("div",{children:[I&&t.jsxs(eo,{container:!0,children:[t.jsx(j.Typography,{variant:"caption",weight:"strong",children:p.length>0?b.formatMessage({id:"c4r.widgets.histogram.selectedItems"},{items:te(l(B))}):b.formatMessage({id:"c4r.widgets.histogram.all"})}),p.length>0&&t.jsx(to,{onClick:()=>c([]),onKeyDown:$,underline:"hover",tabIndex:0,children:b.formatMessage({id:"c4r.widgets.histogram.clear"})})]}),t.jsx(ye,{option:_,onEvents:D,lazyUpdate:!0,onChartReady:C,style:{maxHeight:f}})]})}function so(e){return`${Array(String(e).length).fill(" ").join("")}${e}`}function lo(e){const n=Array(String(e).length).fill(" ").join("");return`${e}${n}`}function ao(e,n,i,r){return e.map((s,l)=>[l===0?i:n[l-1],l===e.length-1?r:n[l],s])}function co(e,n,i,r){const s=o.useTheme(),l=u.useMemo(()=>n===pe.RANKING?e.slice().sort((c,g)=>(g.value??0)-(c.value??0)):e,[e,n]),a=u.useMemo(()=>{const c=[];let g=0;for(const h of l)c.length<i?c.push({...h}):g+=h.value??0;return g>0&&c.push({name:me,value:g,emphasis:{scale:!1}}),c},[i,l]);return u.useMemo(()=>{const c=s.palette.common.white;return a.map((g,h)=>{let d=c;if(r.length){const f=r[h%r.length];f&&(d=f)}else{const m=s.palette.qualitative.bold[h];m&&(d=m)}const y=g;return y.color=d,y})},[a,r,s])}const uo=o.styled(o.Box)(({theme:e})=>({zIndex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",paddingBottom:e.spacing(1)})),po=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1),maxWidth:"140px",textTransform:"uppercase"})),go=o.styled(o.Box)(({theme:e})=>({display:"inline-block",borderRadius:e.spacing(.5),width:e.spacing(1),minWidth:e.spacing(1),height:e.spacing(1)}));function ho({data:e,selectedCategories:n,formatter:i}){const[r,s]=u.useState(),l=u.useMemo(()=>{if(!e||e.length===0)return null;let g;n.length>0?g=e.filter(m=>n.includes(m.name)):g=e;const h=fo(g),d=g.find(m=>m===h);if(!d)return null;let y=0;for(const m of e)y+=m.value??0;const f=xo(d.value??0,y,i);return{...d,percentage:f}},[e,n,i]);u.useEffect(()=>{l&&s(l)},[l,s]);const{name:a,percentage:p,color:c}=r??{};return r?t.jsxs(uo,{children:[t.jsx(j.Typography,{variant:"h5",children:p}),t.jsxs(po,{children:[t.jsx(go,{bgcolor:c,component:"span"}),t.jsx(j.Typography,{component:"span",variant:"body2",noWrap:!0,children:a})]})]}):null}function fo(e){const n=e.filter(i=>i.name!==me);return n.length===0?e[0]:n.reduce((i,r)=>(r.value??0)>(i.value??0)?r:i)}function xo(e,n,i){let r=0;return n!==0&&(r=e/n*100),i?i(r):`${r}%`}const ht=32,mo=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",marginTop:e.spacing(.5)})),yo=o.styled("div")(()=>({display:"flex",alignItems:"center",justifyContent:"center",position:"relative"})),vo=o.styled(An)(()=>({position:"absolute",zIndex:1})),jo=o.styled("div")(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",gap:e.spacing(1),position:"absolute",zIndex:2})),wo=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(2),height:e.spacing(5)})),bo=o.styled("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5)}));function Ft({height:e}){const n=parseInt(String(e),10)||_e,i=n-ht,r=i-ht;return t.jsxs(o.Box,{mt:.5,children:[t.jsx(o.Skeleton,{height:8,width:64}),t.jsx(mo,{height:n,children:t.jsxs(yo,{children:[t.jsx(o.Skeleton,{variant:"circular",width:i,height:i}),t.jsx(vo,{variant:"circular",width:r,height:r}),t.jsxs(jo,{children:[t.jsx(o.Skeleton,{height:24,width:72}),t.jsx(o.Skeleton,{height:8,width:48})]})]})}),t.jsx(wo,{children:[...Array(2)].map((s,l)=>t.jsxs(bo,{children:[t.jsx(o.Skeleton,{variant:"circular",width:8,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]},l))})]})}const So=o.styled(o.Box)(({theme:e})=>({position:"relative",padding:e.spacing(1.25,1,0,1),width:"100%"})),Io=o.styled(o.Box)(({theme:e})=>({position:"relative",display:"flex",flexDirection:"row",overflowX:"hidden",gap:e.spacing(2),padding:e.spacing(.5),margin:e.spacing(-.5)})),ko=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(1),alignItems:"center",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"})),To=o.styled(o.Box)(({theme:e})=>({display:"inline-block",position:"absolute",left:e.spacing(-2),top:e.spacing(1),bottom:e.spacing(1),zIndex:1,width:e.spacing(2.5),background:`linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, ${e.palette.background.paper} 100%)`})),Mo=o.styled(o.Box)(({theme:e})=>({position:"absolute",padding:e.spacing(.25,1),top:e.spacing(0),right:0,background:e.palette.background.paper})),Co=o.styled(o.Box,{shouldForwardProp:e=>e!=="color"})(({theme:e,color:n})=>{const i=e.spacing(1);return{backgroundColor:n,borderRadius:"50%",width:i,height:i}});function Wt({series:e,selectedCategories:n,onCategoryClick:i}){var I,T;const r=o.useTheme(),[s,l]=u.useState(!1),[a,p]=u.useState(0),[c,g]=u.useState(void 0),h=u.useRef(null),d=u.useRef(null),y=u.useRef(null),f=Z.useIntl(),m=j.useImperativeIntl(f);function v(){p(a+1)}function x(){p(Math.max(a-1))}function b(w,C){w.key==="Enter"&&(i==null||i(C))}const S=u.useCallback(()=>{var C,M,D;const w=!!d.current&&d.current.scrollWidth>d.current.clientWidth;l(w),g(w&&d.current?(((C=h.current)==null?void 0:C.clientWidth)??0)-(((M=y.current)==null?void 0:M.clientWidth)??70):(((D=h.current)==null?void 0:D.clientWidth)??0)-12||500)},[h,d,y]);return u.useEffect(()=>{S()},[d,(I=d.current)==null?void 0:I.scrollWidth,(T=d.current)==null?void 0:T.clientWidth,S,a]),u.useEffect(()=>{if(typeof ResizeObserver>"u")return;let w;return h.current&&(w=new ResizeObserver(()=>{S()}),w.observe(h.current)),()=>{w==null||w.disconnect()}},[h,S]),t.jsxs(So,{ref:h,children:[t.jsx(Io,{ref:d,style:{maxWidth:`${c}px`},children:e.map((w,C)=>{if(C<a)return null;const M=n.length===0||n.includes(w.name);return t.jsxs(ko,{tabIndex:0,onClick:i?()=>i(w.name):void 0,onKeyDown:i?D=>b(D,w.name):void 0,style:{pointerEvents:!i||w.name==="Others"?"none":void 0},children:[t.jsx(Co,{color:M?w.color:r.palette.text.disabled}),t.jsx(j.Typography,{variant:"overline",color:M?void 0:"text.disabled",children:w.name})]},C)})}),(s||a>0)&&t.jsxs(Mo,{ref:y,children:[t.jsx(To,{}),t.jsx(o.Tooltip,{title:m.formatMessage({id:"c4r.widgets.chartLegend.next"}),children:t.jsx(o.IconButton,{size:"small",disabled:a===0,onClick:x,children:t.jsx(ee.ChevronLeft,{})})}),t.jsx(o.Tooltip,{title:m.formatMessage({id:"c4r.widgets.chartLegend.prev"}),children:t.jsx(o.IconButton,{size:"small",disabled:!s,onClick:v,children:t.jsx(ee.ChevronRight,{})})})]})]})}const Ke="232px",Ao=o.styled(o.Grid)(({theme:e})=>({flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:e.spacing(.5)})),Eo=o.styled(o.Box,{shouldForwardProp:e=>e!=="height"&&e!=="width"})(({height:e,width:n})=>({position:"relative",margin:"0 auto",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:n||"100%",height:e||"100%"})),Bo=o.styled(ye)(()=>({position:"absolute",top:0,right:0,left:0,bottom:0})),ft=[],Po={},Lo=e=>e;function Do({name:e,data:n,formatter:i=Lo,tooltipFormatter:r=No,percentFormatter:s,height:l=Ke,width:a=Ke,labels:p=Po,colors:c=ft,animation:g=!0,filterable:h=!0,selectedCategories:d=ft,onSelectedCategoriesChange:y,isLoading:f,maxItems:m=11,order:v=pe.RANKING}){const x=o.useTheme(),b=co(n,v,m,c),{showSkeleton:S}=de(!!f),I=Z.useIntl(),T=j.useImperativeIntl(I),w=u.useMemo(()=>s||(_=>`${I.formatNumber(_,{maximumFractionDigits:2,minimumFractionDigits:2})}%`),[I,s]),C=u.useMemo(()=>{let _;return r&&(_=B=>r(B,i,w)),{padding:[j.SPACING*.5,j.SPACING],backgroundColor:x.palette.black[90],borderColor:"transparent",textStyle:{color:x.palette.common.white},confine:!0,formatter:_}},[x.palette.black,x.palette.common.white,r,i,w]),M=u.useMemo(()=>[{type:"pie",name:e,animation:g,data:b.map(_=>{const B={..._},$=(d==null?void 0:d.length)&&!d.includes(B.name);return p!=null&&p[B.name]&&(B.name=p[B.name]),$?{...B,disabled:!0,itemStyle:{color:x.palette.black[25]}}:{...B,itemStyle:{color:B.color}}}),radius:["74%","90%"],selectedOffset:0,bottom:j.SPACING*1.5,label:{show:!1},emphasis:{focus:"series",scaleSize:5},itemStyle:{borderColor:x.palette.background.paper,borderWidth:1}}],[e,g,b,p,d,x]),D=u.useMemo(()=>({grid:{left:0,top:0,right:0,bottom:0},tooltip:C,legend:{show:!1},series:M}),[C,M]),E=u.useCallback(_=>{if(y){const B=[...d],{name:$}=b[_.dataIndex];if($===me)return;const k=B.indexOf($);k===-1?B.push($):B.splice(k,1),y(B)}},[b,y,d]),L=u.useCallback(_=>{if(y){const B=[...d],$=B.indexOf(_);$===-1?B.push(_):B.splice($,1),y(B)}},[y,d]),P={...h&&{click:E}},N=()=>{y==null||y([])},V=_=>{_.key==="Enter"&&N()};return S?t.jsx(Ft,{height:l}):t.jsxs(t.Fragment,{children:[h&&t.jsxs(Ao,{container:!0,children:[t.jsx(j.Typography,{variant:"caption",color:"textSecondary",children:d.length?T.formatMessage({id:"c4r.widgets.pie.selectedItems"},{items:d.length}):T.formatMessage({id:"c4r.widgets.pie.allSelected"})}),d.length>0&&t.jsx(o.Link,{variant:"caption",onClick:N,onKeyDown:V,tabIndex:0,children:T.formatMessage({id:"c4r.widgets.pie.clear"})})]}),t.jsxs(Eo,{height:l,width:a,children:[t.jsx(ho,{data:b,selectedCategories:d,formatter:w}),t.jsx(Bo,{option:D,onEvents:P,lazyUpdate:!0,style:{height:l,width:a}})]}),b.length>0&&t.jsx(Wt,{series:b,selectedCategories:d,onCategoryClick:y&&L})]})}function No(e,n,i){var c;const r=Array.isArray(e)?e[0]:e;if(!r)return null;const s=te(n(r.value)),l=i(r.percent)||`${r.percent}%`,p=`display:inline-block;border-radius:4px;width:8px;height:8px;background-color:${((c=r.data)==null?void 0:c.color)||r.textStyle.color}`;return`
|
|
5
|
+
<div style="white-space:normal;"><p style="max-width:${Ke};font-size:11px;font-weight:500;line-height:1.454;text-transform:uppercase;margin:0 0 4px 0;">${r.name}</p>
|
|
6
6
|
<p style="display:flex;align-items:center;font-size: 11px;font-weight:500;line-height:1.454;margin:0;"><span style="${p}"></span> <span style="margin:0 4px;font-weight:400;">${s}</span> (${l})</p></div>
|
|
7
|
-
`.trim()}const Oo=o.styled(o.Grid)(({theme:e})=>({position:"relative",alignItems:"center",height:e.spacing(4)})),$o=o.styled(o.Grid)(({theme:e})=>({position:"absolute",zIndex:1,padding:e.spacing(0,3)}));function Ro(){return t.jsxs(o.Grid,{container:!0,children:[t.jsxs(Oo,{container:!0,item:!0,children:[t.jsxs($o,{container:!0,item:!0,justifyContent:"space-between",children:[t.jsx(ct,{variant:"circular",width:12,height:12}),t.jsx(ct,{variant:"circular",width:12,height:12})]}),t.jsx(o.Skeleton,{height:2,width:"100%"})]}),t.jsxs(o.Grid,{container:!0,item:!0,justifyContent:"space-between",children:[t.jsx(o.Skeleton,{width:56,height:32}),t.jsx(o.Skeleton,{width:56,height:32})]})]})}const Fo=o.styled(o.Box)(()=>({position:"relative"})),Wo=o.styled(o.Box)(({theme:{spacing:e}})=>({display:"flex",flexDirection:"row-reverse",height:e(1.5)})),_o=o.styled(o.Link)(()=>({cursor:"pointer"})),xt=o.styled(o.TextField)(({theme:{spacing:e}})=>({maxWidth:e(9),margin:0,"& fieldset":{borderWidth:1},"& input":{"&[type=number]":{appearance:"textfield"},"&::-webkit-outer-spin-button":{appearance:"none",margin:0},"&::-webkit-inner-spin-button":{appearance:"none",margin:0}}})),Go=o.styled(o.Slider)(({theme:{palette:e}})=>({"& .MuiSlider-rail":{color:e.text.hint}})),zo=o.styled(o.Slider)(({theme:{palette:e,spacing:n}})=>({pointerEvents:"none",position:"absolute",zIndex:1,left:0,right:0,"& .MuiSlider-rail":{display:"none"},"& .MuiSlider-thumb":{display:"none"},"& .MuiSlider-track":{color:e.primary.main,opacity:.38},"& .MuiSlider-mark, & .MuiSlider-markActive":{backgroundColor:e.primary.main,opacity:.38,height:n(1),width:n(.25),top:"50%",transform:"translateY(-50%)"}}));function Ho({data:e,min:n,max:i,limits:r,onSelectedRangeChange:s,isLoading:l}){const[a,p]=u.useState([n,i]),[c,g]=u.useState([n,i]),h=Z.useIntl(),d=j.useImperativeIntl(h),{showSkeleton:y}=de(!!l),f=u.useMemo(()=>{if(!r||r.length!==2)return;if(r[0]===r[1])return[{value:r[0]}];const w=[{value:Math.max(r[0],n)},{value:Math.min(r[1],i)}];if(!(w[0].value>w[1].value))return w},[r,i,n]),m=u.useMemo(()=>s?o.debounce(s,250):null,[s]),v=w=>{g([...w]),p([...w]),m&&m([...w])};function x(w,C){const M=w.target.value===""?"":Number(w.target.value);C===0&&g([M,c[1]]),C===1&&g([c[0],M])}const b=n!==c[0]||i!==c[1];u.useEffect(()=>{e&&(g([...e]),p([...e]))},[e]);function S(w){let C=c[w];C===""&&(C=a[w]),C>i&&(C=i),C<n&&(C=n);const M=w===0?[C,c[1]]:[c[0],C];v(M.sort((D,E)=>D-E))}const k=()=>{v([n,i])};function T(w){w.key==="Enter"&&k()}return y?t.jsx(Ro,{}):t.jsxs(Fo,{children:[t.jsx(Wo,{children:b&&t.jsx(j.Typography,{variant:"caption",color:"primary",children:t.jsx(_o,{onClick:k,onKeyDown:T,tabIndex:0,component:"button",underline:"hover",children:d.formatMessage({id:"c4r.widgets.range.clear"})})})}),t.jsxs(o.Box,{children:[t.jsx(Go,{getAriaLabel:w=>w===0?d.formatMessage({id:"c4r.widgets.range.minValue"}):d.formatMessage({id:"c4r.widgets.range.maxValue"}),value:a,min:n,max:i,onChange:(w,C)=>v(C)}),r&&r.length===2&&t.jsx(zo,{getAriaLabel:w=>w===0?d.formatMessage({id:"c4r.widgets.range.minLimit"}):d.formatMessage({id:"c4r.widgets.range.maxLimit"}),value:r,min:n,max:i,marks:f})]}),t.jsxs(o.Box,{display:"flex",justifyContent:"space-between",mb:1,children:[t.jsx(xt,{value:c[0],size:"small",onChange:w=>x(w,0),onBlur:()=>S(0),inputProps:{min:n,max:i,type:"number","aria-label":d.formatMessage({id:"c4r.widgets.range.minValue"})}}),t.jsx(xt,{value:c[1],size:"small",onChange:w=>x(w,1),onBlur:()=>S(1),inputProps:{min:n,max:i,type:"number","aria-label":d.formatMessage({id:"c4r.widgets.range.maxValue"})}})]})]})}const Yo=o.styled(Lt)(({theme:e})=>({flexDirection:"column",alignItems:"center",justifyContent:"center",marginLeft:e.spacing(4),containerType:"inline-size",[`@container (max-width: ${j.BREAKPOINTS.XS}px)`]:{" > div":{maxWidth:"75%"}}})),Vo=o.styled(o.Box)(()=>({position:"relative",display:"flex",justifyContent:"space-between",width:"80%",maxWidth:"50%"}));function Uo({height:e}){function n(){return Math.floor(Math.random()*5)}return t.jsxs(o.Box,{height:e??_e,children:[t.jsx(o.Box,{mb:4,children:t.jsx(o.Skeleton,{width:48,height:8})}),t.jsx(Yo,{height:"80%",children:[...Array(3)].map((i,r)=>t.jsx(Vo,{ml:r*3,children:[...Array(4)].map((s,l)=>t.jsx(o.Box,{mt:n(),ml:n(),children:t.jsx(o.Skeleton,{variant:"circular",width:12,height:12})},l))},r))})]})}function qo(e,n){var c;const i=Array.isArray(e.tooltip)?e.tooltip[0]:e.tooltip,r=Array.isArray(n.tooltip)?n.tooltip[0]:n.tooltip,s=i==null?void 0:i.formatter,l=r==null?void 0:r.formatter,a=(c=e.series[0])==null?void 0:c.data,p=n.series[0].data;return s!==l?!1:a&&p&&a.length===p.length?!p.some(({value:g},h)=>{var d;return g!==((d=a[h])==null?void 0:d.value)}):!1}function Ko({tooltipFormatter:e,xAxisFormatter:n=$e,yAxisFormatter:i=$e},r){return{grid:{top:10,left:5,bottom:10,right:15,containLabel:!0},tooltip:{padding:[j.SPACING*.5,j.SPACING],textStyle:{...r.typography.caption,fontSize:11,color:r.palette.common.white},backgroundColor:r.palette.black[90],...e?{formatter:e}:{}},color:[r.palette.secondary.main],xAxis:{axisLabel:{...r.typography.overlineDelicate,padding:[j.SPACING*.5,0,0,0],formatter:s=>te(n(s))}},yAxis:{axisLabel:{...r.typography.overlineDelicate,formatter:s=>te(i(s))}}}}function Xo({name:e,data:n,animation:i}){return[{type:"scatter",name:e,data:n,animation:i}]}const Zo=u.memo(ye,(e,n)=>qo(e.option,n.option)),mt=225,Jo=[],$e=e=>e;function Qo({name:e=null,data:n=Jo,animation:i=!0,xAxisFormatter:r=$e,yAxisFormatter:s=$e,tooltipFormatter:l=ei,isLoading:a}){const p=o.useTheme(),c=u.useRef(),[g,h]=u.useState({series:[]}),{showSkeleton:d}=de(!!a);return u.useEffect(()=>{const y=Ko({xAxisFormatter:r,yAxisFormatter:s,tooltipFormatter:l},p),f=Xo({name:e,data:n||[],animation:i});h({...y,series:f})},[n,e,i,p,r,s,l]),d?t.jsx(Uo,{height:mt}):t.jsx(Zo,{ref:c,option:g,lazyUpdate:!0,style:{height:mt}})}function ei(e){const n=Array.isArray(e)?e[0]:e,i=(n==null?void 0:n.value)||[];return`[${i[0]}, ${i[1]})`}function Be({width:e,rows:n=4,index:i=0}){function r(s){const l=[72,48,96,32,64],a=s%l.length;return l[a]}return[...Array(n)].map((s,l)=>t.jsx(o.TableCell,{children:t.jsx(o.Skeleton,{width:e??r(i),height:8})},l))}const ti=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:e.spacing(2),margin:0,padding:e.spacing(2,1)})),ni=o.styled(o.TableContainer)(()=>({overflow:"hidden"}));function oi({style:e,dense:n,pagination:i,rowsPerPage:r}){return t.jsxs(t.Fragment,{children:[t.jsx(ni,{style:e,children:t.jsxs(o.Table,{"aria-label":"skeleton table",size:n?"small":"medium",children:[t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{children:[t.jsx(Be,{rows:1,width:8}),t.jsx(Be,{width:56})]})}),t.jsx(o.TableBody,{children:[...Array(Math.min(10,r??10))].map((s,l)=>t.jsxs(o.TableRow,{children:[t.jsx(Be,{rows:1,width:8}),t.jsx(Be,{index:l})]},l))})]})}),i&&t.jsxs(ti,{children:[t.jsx(o.Skeleton,{width:56,height:8}),t.jsx(o.Box,{mr:1,children:t.jsx(o.Skeleton,{width:52,height:16})}),t.jsx(o.Skeleton,{width:60,height:8}),t.jsx(o.Skeleton,{width:16,height:16}),t.jsx(o.Skeleton,{width:16,height:16})]})]})}const ii=o.styled(o.TableSortLabel)(({theme:e})=>({...e.typography.caption,color:e.palette.text.secondary,whiteSpace:"nowrap"})),ri=o.styled(o.TableRow)(({theme:e})=>({maxHeight:e.spacing(6.5),transition:"background-color 0.25s ease","&.MuiTableRow-hover:hover":{cursor:"pointer",backgroundColor:e.palette.background.default}})),si=o.styled(o.TableCell)(()=>({overflow:"hidden","& p":{maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}})),li=o.styled(o.TablePagination)(({theme:e})=>({height:e.spacing(6),overflowX:"auto",overflowY:"hidden"})),ai=10,ci=[5,10,25],be=()=>{};function di({columns:e,rows:n,sorting:i=!1,sortBy:r,sortDirection:s="asc",onSetSortBy:l=be,onSetSortDirection:a=be,pagination:p=!1,totalCount:c,page:g,onSetPage:h=be,rowsPerPage:d=ai,rowsPerPageOptions:y=ci,onSetRowsPerPage:f=be,onRowClick:m=be,onRowMouseEnter:v,onRowMouseLeave:x,height:b,dense:S=!1,isLoading:k,lastPageTooltip:T}){var _;const w=u.useRef(null),C=Z.useIntl(),M=j.useImperativeIntl(C),{showSkeleton:D}=de(!!k);function E({from:A,to:$,count:I}){return M.formatMessage({id:"c4r.widgets.table.of"},{from:A,to:$,count:I})}function L(A){a(r===A&&s==="asc"?"desc":"asc"),l(A)}function P(A,$){h($)}function N(A){f(parseInt(A.target.value,10)),h(0)}const V={height:void 0};if(b){const A=Math.max(((_=w==null?void 0:w.current)==null?void 0:_.clientHeight)??0,p?j.SPACING*6:0);V.height=`calc(${b} - ${A}px)`}return D?t.jsx(oi,{rowsPerPage:d,style:V,dense:S,pagination:p}):t.jsxs(t.Fragment,{children:[t.jsx(o.TableContainer,{style:V,children:t.jsxs(o.Table,{stickyHeader:!0,size:S?"small":"medium",children:[t.jsx(ui,{columns:e,sorting:i,sortBy:r,sortDirection:s,onSort:L}),t.jsx(pi,{columns:e,rows:n,onRowMouseEnter:v,onRowMouseLeave:x,onRowClick:m})]})}),p&&t.jsx(li,{ref:w,rowsPerPageOptions:y,labelRowsPerPage:M.formatMessage({id:"c4r.widgets.table.rowsPerPage"}),labelDisplayedRows:E,component:"div",count:c,rowsPerPage:d,page:g,onPageChange:P,onRowsPerPageChange:N,ActionsComponent:()=>t.jsx(j.TablePaginationActions,{count:c,rowsPerPage:d,page:g,onPageChange:P,lastPageTooltip:T})})]})}function ui({columns:e,sorting:n,sortBy:i,sortDirection:r,onSort:s}){return t.jsx(o.TableHead,{children:t.jsx(o.TableRow,{children:e.map(({field:l,headerName:a,align:p})=>t.jsx(o.TableCell,{align:p??"left",children:n?t.jsx(ii,{active:i===l,direction:i===l?r:"asc",onClick:()=>s(l),children:a??l}):a??l},l))})})}function pi({columns:e,rows:n,onRowMouseEnter:i,onRowMouseLeave:r,onRowClick:s}){return t.jsx(o.TableBody,{children:n.map((l,a)=>{const p=String(l.cartodb_id||l.id||a);return t.jsx(ri,{hover:!!s,onMouseEnter:()=>i==null?void 0:i(l),onMouseLeave:()=>r==null?void 0:r(l),onClick:()=>s&&s(l),children:e.map(({field:c,headerName:g,align:h,component:d,formatter:y})=>{var m;let f=(m=Object.entries(l).find(([v])=>v.toUpperCase()===c.toUpperCase()))==null?void 0:m[1];return y?f=y(f):typeof f=="bigint"?f=f.toString():Array.isArray(f)?f=`[${f.map(v=>typeof v=="string"?`"${v}"`:String(v)).join(", ")}]`:typeof f=="object"&&f!==null&&(f=JSON.stringify(f)),(g??c)&&t.jsx(si,{scope:"row",align:h??"left",children:d?d(f):f},`${p}_${c}`)})},p)})})}function _t(e,n,i,r,s){const l=Array.isArray(e)?e:[e],[a]=l[0].data,p=new Date(a);return`<div style='minWidth: 160px;'>
|
|
8
|
-
<p style='font-weight: 600; line-height: 1; margin: 4px 0;'>${
|
|
7
|
+
`.trim()}const Oo=o.styled(o.Grid)(({theme:e})=>({position:"relative",alignItems:"center",height:e.spacing(4)})),$o=o.styled(o.Grid)(({theme:e})=>({position:"absolute",zIndex:1,padding:e.spacing(0,3)}));function Ro(){return t.jsxs(o.Grid,{container:!0,children:[t.jsxs(Oo,{container:!0,item:!0,children:[t.jsxs($o,{container:!0,item:!0,justifyContent:"space-between",children:[t.jsx(ct,{variant:"circular",width:12,height:12}),t.jsx(ct,{variant:"circular",width:12,height:12})]}),t.jsx(o.Skeleton,{height:2,width:"100%"})]}),t.jsxs(o.Grid,{container:!0,item:!0,justifyContent:"space-between",children:[t.jsx(o.Skeleton,{width:56,height:32}),t.jsx(o.Skeleton,{width:56,height:32})]})]})}const Fo=o.styled(o.Box)(()=>({position:"relative"})),Wo=o.styled(o.Box)(({theme:{spacing:e}})=>({display:"flex",flexDirection:"row-reverse",height:e(1.5)})),_o=o.styled(o.Link)(()=>({cursor:"pointer"})),xt=o.styled(o.TextField)(({theme:{spacing:e}})=>({maxWidth:e(9),margin:0,"& fieldset":{borderWidth:1},"& input":{"&[type=number]":{appearance:"textfield"},"&::-webkit-outer-spin-button":{appearance:"none",margin:0},"&::-webkit-inner-spin-button":{appearance:"none",margin:0}}})),Go=o.styled(o.Slider)(({theme:{palette:e}})=>({"& .MuiSlider-rail":{color:e.text.hint}})),Ho=o.styled(o.Slider)(({theme:{palette:e,spacing:n}})=>({pointerEvents:"none",position:"absolute",zIndex:1,left:0,right:0,"& .MuiSlider-rail":{display:"none"},"& .MuiSlider-thumb":{display:"none"},"& .MuiSlider-track":{color:e.primary.main,opacity:.38},"& .MuiSlider-mark, & .MuiSlider-markActive":{backgroundColor:e.primary.main,opacity:.38,height:n(1),width:n(.25),top:"50%",transform:"translateY(-50%)"}}));function zo({data:e,min:n,max:i,limits:r,onSelectedRangeChange:s,isLoading:l}){const[a,p]=u.useState([n,i]),[c,g]=u.useState([n,i]),h=Z.useIntl(),d=j.useImperativeIntl(h),{showSkeleton:y}=de(!!l),f=u.useMemo(()=>{if(!r||r.length!==2)return;if(r[0]===r[1])return[{value:r[0]}];const w=[{value:Math.max(r[0],n)},{value:Math.min(r[1],i)}];if(!(w[0].value>w[1].value))return w},[r,i,n]),m=u.useMemo(()=>s?o.debounce(s,250):null,[s]),v=w=>{g([...w]),p([...w]),m&&m([...w])};function x(w,C){const M=w.target.value===""?"":Number(w.target.value);C===0&&g([M,c[1]]),C===1&&g([c[0],M])}const b=n!==c[0]||i!==c[1];u.useEffect(()=>{e&&(g([...e]),p([...e]))},[e]);function S(w){let C=c[w];C===""&&(C=a[w]),C>i&&(C=i),C<n&&(C=n);const M=w===0?[C,c[1]]:[c[0],C];v(M.sort((D,E)=>D-E))}const I=()=>{v([n,i])};function T(w){w.key==="Enter"&&I()}return y?t.jsx(Ro,{}):t.jsxs(Fo,{children:[t.jsx(Wo,{children:b&&t.jsx(j.Typography,{variant:"caption",color:"primary",children:t.jsx(_o,{onClick:I,onKeyDown:T,tabIndex:0,component:"button",underline:"hover",children:d.formatMessage({id:"c4r.widgets.range.clear"})})})}),t.jsxs(o.Box,{children:[t.jsx(Go,{getAriaLabel:w=>w===0?d.formatMessage({id:"c4r.widgets.range.minValue"}):d.formatMessage({id:"c4r.widgets.range.maxValue"}),value:a,min:n,max:i,onChange:(w,C)=>v(C)}),r&&r.length===2&&t.jsx(Ho,{getAriaLabel:w=>w===0?d.formatMessage({id:"c4r.widgets.range.minLimit"}):d.formatMessage({id:"c4r.widgets.range.maxLimit"}),value:r,min:n,max:i,marks:f})]}),t.jsxs(o.Box,{display:"flex",justifyContent:"space-between",mb:1,children:[t.jsx(xt,{value:c[0],size:"small",onChange:w=>x(w,0),onBlur:()=>S(0),inputProps:{min:n,max:i,type:"number","aria-label":d.formatMessage({id:"c4r.widgets.range.minValue"})}}),t.jsx(xt,{value:c[1],size:"small",onChange:w=>x(w,1),onBlur:()=>S(1),inputProps:{min:n,max:i,type:"number","aria-label":d.formatMessage({id:"c4r.widgets.range.maxValue"})}})]})]})}const Yo=o.styled(Lt)(({theme:e})=>({flexDirection:"column",alignItems:"center",justifyContent:"center",marginLeft:e.spacing(4),containerType:"inline-size",[`@container (max-width: ${j.BREAKPOINTS.XS}px)`]:{" > div":{maxWidth:"75%"}}})),Vo=o.styled(o.Box)(()=>({position:"relative",display:"flex",justifyContent:"space-between",width:"80%",maxWidth:"50%"}));function Uo({height:e}){function n(){return Math.floor(Math.random()*5)}return t.jsxs(o.Box,{height:e??_e,children:[t.jsx(o.Box,{mb:4,children:t.jsx(o.Skeleton,{width:48,height:8})}),t.jsx(Yo,{height:"80%",children:[...Array(3)].map((i,r)=>t.jsx(Vo,{ml:r*3,children:[...Array(4)].map((s,l)=>t.jsx(o.Box,{mt:n(),ml:n(),children:t.jsx(o.Skeleton,{variant:"circular",width:12,height:12})},l))},r))})]})}function qo(e,n){var c;const i=Array.isArray(e.tooltip)?e.tooltip[0]:e.tooltip,r=Array.isArray(n.tooltip)?n.tooltip[0]:n.tooltip,s=i==null?void 0:i.formatter,l=r==null?void 0:r.formatter,a=(c=e.series[0])==null?void 0:c.data,p=n.series[0].data;return s!==l?!1:a&&p&&a.length===p.length?!p.some(({value:g},h)=>{var d;return g!==((d=a[h])==null?void 0:d.value)}):!1}function Xo({tooltipFormatter:e,xAxisFormatter:n=$e,yAxisFormatter:i=$e},r){return{grid:{top:10,left:5,bottom:10,right:15,containLabel:!0},tooltip:{padding:[j.SPACING*.5,j.SPACING],textStyle:{...r.typography.caption,fontSize:11,color:r.palette.common.white},backgroundColor:r.palette.black[90],...e?{formatter:e}:{}},color:[r.palette.secondary.main],xAxis:{axisLabel:{...r.typography.overlineDelicate,padding:[j.SPACING*.5,0,0,0],formatter:s=>te(n(s))}},yAxis:{axisLabel:{...r.typography.overlineDelicate,formatter:s=>te(i(s))}}}}function Ko({name:e,data:n,animation:i}){return[{type:"scatter",name:e,data:n,animation:i}]}const Zo=u.memo(ye,(e,n)=>qo(e.option,n.option)),mt=225,Jo=[],$e=e=>e;function Qo({name:e=null,data:n=Jo,animation:i=!0,xAxisFormatter:r=$e,yAxisFormatter:s=$e,tooltipFormatter:l=ei,isLoading:a}){const p=o.useTheme(),c=u.useRef(),[g,h]=u.useState({series:[]}),{showSkeleton:d}=de(!!a);return u.useEffect(()=>{const y=Xo({xAxisFormatter:r,yAxisFormatter:s,tooltipFormatter:l},p),f=Ko({name:e,data:n||[],animation:i});h({...y,series:f})},[n,e,i,p,r,s,l]),d?t.jsx(Uo,{height:mt}):t.jsx(Zo,{ref:c,option:g,lazyUpdate:!0,style:{height:mt}})}function ei(e){const n=Array.isArray(e)?e[0]:e,i=(n==null?void 0:n.value)||[];return`[${i[0]}, ${i[1]})`}function Be({width:e,rows:n=4,index:i=0}){function r(s){const l=[72,48,96,32,64],a=s%l.length;return l[a]}return[...Array(n)].map((s,l)=>t.jsx(o.TableCell,{children:t.jsx(o.Skeleton,{width:e??r(i),height:8})},l))}const ti=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:e.spacing(2),margin:0,padding:e.spacing(2,1)})),ni=o.styled(o.TableContainer)(()=>({overflow:"hidden"}));function oi({style:e,dense:n,pagination:i,rowsPerPage:r}){return t.jsxs(t.Fragment,{children:[t.jsx(ni,{style:e,children:t.jsxs(o.Table,{"aria-label":"skeleton table",size:n?"small":"medium",children:[t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{children:[t.jsx(Be,{rows:1,width:8}),t.jsx(Be,{width:56})]})}),t.jsx(o.TableBody,{children:[...Array(Math.min(10,r??10))].map((s,l)=>t.jsxs(o.TableRow,{children:[t.jsx(Be,{rows:1,width:8}),t.jsx(Be,{index:l})]},l))})]})}),i&&t.jsxs(ti,{children:[t.jsx(o.Skeleton,{width:56,height:8}),t.jsx(o.Box,{mr:1,children:t.jsx(o.Skeleton,{width:52,height:16})}),t.jsx(o.Skeleton,{width:60,height:8}),t.jsx(o.Skeleton,{width:16,height:16}),t.jsx(o.Skeleton,{width:16,height:16})]})]})}const ii=o.styled(o.TableSortLabel)(({theme:e})=>({...e.typography.caption,color:e.palette.text.secondary,whiteSpace:"nowrap"})),ri=o.styled(o.TableRow)(({theme:e})=>({maxHeight:e.spacing(6.5),transition:"background-color 0.25s ease","&.MuiTableRow-hover:hover":{cursor:"pointer",backgroundColor:e.palette.background.default}})),si=o.styled(o.TableCell)(()=>({overflow:"hidden","& p":{maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}})),li=o.styled(o.TablePagination)(({theme:e})=>({height:e.spacing(6),overflowX:"auto",overflowY:"hidden"})),ai=10,ci=[5,10,25],be=()=>{};function di({columns:e,rows:n,sorting:i=!1,sortBy:r,sortDirection:s="asc",onSetSortBy:l=be,onSetSortDirection:a=be,pagination:p=!1,totalCount:c,page:g,onSetPage:h=be,rowsPerPage:d=ai,rowsPerPageOptions:y=ci,onSetRowsPerPage:f=be,onRowClick:m=be,onRowMouseEnter:v,onRowMouseLeave:x,height:b,dense:S=!1,isLoading:I,lastPageTooltip:T}){var _;const w=u.useRef(null),C=Z.useIntl(),M=j.useImperativeIntl(C),{showSkeleton:D}=de(!!I);function E({from:B,to:$,count:k}){return M.formatMessage({id:"c4r.widgets.table.of"},{from:B,to:$,count:k})}function L(B){a(r===B&&s==="asc"?"desc":"asc"),l(B)}function P(B,$){h($)}function N(B){f(parseInt(B.target.value,10)),h(0)}const V={height:void 0};if(b){const B=Math.max(((_=w==null?void 0:w.current)==null?void 0:_.clientHeight)??0,p?j.SPACING*6:0);V.height=`calc(${b} - ${B}px)`}return D?t.jsx(oi,{rowsPerPage:d,style:V,dense:S,pagination:p}):t.jsxs(t.Fragment,{children:[t.jsx(o.TableContainer,{style:V,children:t.jsxs(o.Table,{stickyHeader:!0,size:S?"small":"medium",children:[t.jsx(ui,{columns:e,sorting:i,sortBy:r,sortDirection:s,onSort:L}),t.jsx(pi,{columns:e,rows:n,onRowMouseEnter:v,onRowMouseLeave:x,onRowClick:m})]})}),p&&t.jsx(li,{ref:w,rowsPerPageOptions:y,labelRowsPerPage:M.formatMessage({id:"c4r.widgets.table.rowsPerPage"}),labelDisplayedRows:E,component:"div",count:c,rowsPerPage:d,page:g,onPageChange:P,onRowsPerPageChange:N,ActionsComponent:()=>t.jsx(j.TablePaginationActions,{count:c,rowsPerPage:d,page:g,onPageChange:P,lastPageTooltip:T})})]})}function ui({columns:e,sorting:n,sortBy:i,sortDirection:r,onSort:s}){return t.jsx(o.TableHead,{children:t.jsx(o.TableRow,{children:e.map(({field:l,headerName:a,align:p})=>t.jsx(o.TableCell,{align:p??"left",children:n?t.jsx(ii,{active:i===l,direction:i===l?r:"asc",onClick:()=>s(l),children:a??l}):a??l},l))})})}function pi({columns:e,rows:n,onRowMouseEnter:i,onRowMouseLeave:r,onRowClick:s}){return t.jsx(o.TableBody,{children:n.map((l,a)=>{const p=String(l.cartodb_id||l.id||a);return t.jsx(ri,{hover:!!s,onMouseEnter:()=>i==null?void 0:i(l),onMouseLeave:()=>r==null?void 0:r(l),onClick:()=>s&&s(l),children:e.map(({field:c,headerName:g,align:h,component:d,formatter:y})=>{var m;let f=(m=Object.entries(l).find(([v])=>v.toUpperCase()===c.toUpperCase()))==null?void 0:m[1];return y?f=y(f):typeof f=="bigint"?f=f.toString():Array.isArray(f)?f=`[${f.map(v=>typeof v=="string"?`"${v}"`:String(v)).join(", ")}]`:typeof f=="object"&&f!==null&&(f=JSON.stringify(f)),(g??c)&&t.jsx(si,{scope:"row",align:h??"left",children:d?d(f):f},`${p}_${c}`)})},p)})})}function _t(e,n,i,r,s){const l=Array.isArray(e)?e:[e],[a]=l[0].data,p=new Date(a);return`<div style='minWidth: 160px;'>
|
|
8
|
+
<p style='font-weight: 600; line-height: 1; margin: 4px 0;'>${Ht({date:p,stepMultiplier:r,stepSize:n})}</p>
|
|
9
9
|
${l.reduce((g,h)=>{if(h.value!==void 0&&h.value!==null){const d=`<div style='display: flex; flex-direction: row; align-items: center; justify-content: spread; height: 20px; gap: 8px;'>
|
|
10
10
|
<div style='display: flex; flex-direction: row; align-items: center; margin: 4px 0;'>
|
|
11
11
|
<div style='width: 8px; height: 8px; margin-right: 4px; border-radius: 50%; border: 2px solid ${String(h.color)}'></div>
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
</p>
|
|
16
16
|
<p style='line-height: 1; justify-self: flex-end;'>${i(h.data[1])}</p>
|
|
17
17
|
</div>`;g.push(d)}return g},[]).join("")}
|
|
18
|
-
</div>`}var Ge=(e=>(e.LINE="line",e.BAR="bar",e))(Ge||{});function yt(e){if(typeof e=="object"&&typeof(e==null?void 0:e.getTime)=="function")return e.getTime();const n=new Date(e).getTime();if(isFinite(n))return n}function Gt(e){return typeof e=="object"&&typeof(e==null?void 0:e.getTime)=="function"?e:new Date(e)}function Re(e,n){var i,r;for(let s=0;s<n.length;s++){const l=n[s].name,a=s<n.length?(i=n[s+1])==null?void 0:i.name:l,p=s>0?(r=n[s-1])==null?void 0:r.name:l,c=Math.abs(l-a),g=Math.abs(l-p),h=l-g*.5,d=l+c*.5;if(isFinite(h)&&isFinite(d)){if(e>=h&&e<=d)return s}else if(isFinite(h)){if(e>=h)return s}else if(isFinite(d)&&e<=d)return s}}function gi(e){let n,i=0;for(const{name:r}of e)r!==n&&(n=r,i++);return i}function hi(e){const n=new Date(e),i=n.getDay(),r=n.getDate()-i+(i?1:-6);return n.setDate(r),n.setHours(0,0,0,0),n.getTime()}var ae=(e=>(e.YEARS="year",e.MONTHS="month",e.WEEKS="week",e.DAYS="day",e.HOURS="hour",e.MINUTES="minute",e.SECONDS="second",e))(ae||{});const et={year:fe,month:fe,week:fe,day:fe,hour:yi,minute:vt,second:vt},fi={year:Ti,month:Ii,week:ki,day:Si,hour:bi,minute:wi,second:ji};function xi({date:e,stepSize:n}){const i=et[n];if(!i)throw new Error("formatTime: invalid stepSize");return i(e)}function Fe({start:e,end:n,stepSize:i}){if(e>n)return Fe({start:n,end:e,stepSize:i});const r=et[i];if(!r)throw new Error("formatTimeRange: missing formatter or invalid stepSize");const s=r(e),l=r(n);return`${s} - ${l}`}function zt({date:e,stepSize:n,stepMultiplier:i}){if(!et[n])throw new Error("formatBucketRange: missing formatter or invalid stepSize");const{start:s,end:l}=vi({date:e,stepSize:n,stepMultiplier:i});if(i===1){if(n==="day")return xi({date:s,stepSize:n});if(n==="second")return`${fe(s)} ${Ze(s)} - ${Ze(l)}`}return Fe({start:s,end:l,stepSize:n})}const tt=e=>1e3*e,nt=e=>tt(60*e),mi=e=>nt(60*e);function fe(e){return e.toLocaleDateString()}function yi(e){return fe(e)+" "+e.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0})}function Ze(e){return e.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!0,second:"2-digit"})}function vt(e){return fe(e)+" "+Ze(e)}function vi({date:e,stepSize:n,stepMultiplier:i=1}){const r=fi[n];if(!r)throw new Error("getBucketInterval: invalid bucket size");return r({date:e,stepMultiplier:i})}function ji({date:e,stepMultiplier:n=1}){const i=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),0),r=new Date(i.getTime()+tt(n-1)+999);return{start:i,end:r}}function wi({date:e,stepMultiplier:n=1}){const i=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),0,0),r=new Date(i.getTime()+nt(n-1)+tt(59));return{start:i,end:r}}function bi({date:e,stepMultiplier:n=1}){const i=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),0,0,0),r=new Date(i.getTime()+mi(n-1)+nt(59));return{start:i,end:r}}function Si({date:e,stepMultiplier:n=1}){const i=new Date(e.getFullYear(),e.getMonth(),e.getDate(),0,0,0,0),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()+n-1);return{start:i,end:r}}function ki({date:e,stepMultiplier:n=1}){const i=new Date(hi(e)),r=new Date(i.getFullYear(),i.getMonth(),i.getDate()+6+7*(n-1));return{start:i,end:r}}function Ii({date:e,stepMultiplier:n=1}){const i=new Date(e.getFullYear(),e.getMonth(),1),r=new Date(e.getFullYear(),e.getMonth()+n,0);return{start:i,end:r}}function Ti({date:e,stepMultiplier:n=1}){const i=new Date(e.getFullYear(),0,1),r=new Date(e.getFullYear()+(n-1),11,31);return{start:i,end:r}}const oe=()=>{},Ht=u.createContext({isPlaying:!1,setIsPlaying:oe,isPaused:!1,setIsPaused:oe,timeWindow:[],setTimeWindow:oe,onTimeWindowUpdate:oe,togglePlay:oe,stop:oe,intl:{}});function ze(){return u.useContext(Ht)}function Yt({children:e,isPlaying:n,isPaused:i,onPlay:r=oe,onPause:s=oe,onStop:l=oe,timeWindow:a,onTimeWindowUpdate:p=oe,intl:c}){const[g,h]=u.useState(n),[d,y]=u.useState(i),[f,m]=u.useState([]),v=j.useImperativeIntl(c);u.useEffect(()=>{const k=f.sort((T,w)=>T<w?-1:1).map(Gt);p==null||p(k)},[f,p]);const x=u.useCallback(()=>{g&&(s&&s(),y(!0)),g||(r&&r(),y(!1)),h(k=>!k)},[g,s,r]),b=u.useCallback(()=>{h(!1),y(!1),m([])},[]),S=u.useCallback(()=>{b(),setTimeout(l)},[l,b]);return u.useEffect(()=>{n!==g&&h(n)},[n]),u.useEffect(()=>{i!==d&&y(i)},[i]),u.useEffect(()=>{if(!a)return;const k=a.map(yt),T=f.map(yt);(k[0]!==T[0]||k[1]!==T[1])&&m(k)},a),t.jsx(Ht.Provider,{value:{isPlaying:!!g,setIsPlaying:h,isPaused:!!d,setIsPaused:y,timeWindow:f,setTimeWindow:m,onTimeWindowUpdate:p,togglePlay:x,stop:S,intl:v},children:e})}const jt={};let Pe=null;const Se={seriesId:"0"};function Vt({echartsInstance:e,data:n,canSelectLines:i,filterable:r}){const s=o.useTheme(),{isPlaying:l,isPaused:a,setIsPaused:p,timeWindow:c,setTimeWindow:g,stop:h}=ze(),[d,y]=u.useState(!1),[f,m]=u.useState(!1),[v,x]=u.useState(!1),[b,S]=u.useState(0),k=u.useMemo(()=>e==null?void 0:e.getZr(),[e]),T=u.useCallback(D=>k==null?void 0:k.setCursorStyle(D),[k]),w=u.useCallback(D=>{if(e){const[E]=e.convertFromPixel(Se,[D.offsetX,D.offsetY]),L=Re(E,n);g(L!==void 0?[n[L].name]:[])}},[n,e,g]);u.useEffect(()=>{function D(E){r&&(i&&E.target||(c.length||(w(E),!a&&!l&&p(!0)),c.length===2&&(g([]),h())))}return Le(k,"click",D)},[k,a,l,p,g,h,c.length,w,i,r]),u.useEffect(()=>{function D(E){var L;if(r){if(((L=E.target)==null?void 0:L.type)==="ec-line"){y(!0),T("grabbing");return}if(c.length===2){const[P]=e.convertFromPixel(Se,[E.offsetX,E.offsetY]);if(P>=c[0]&&P<=c[1]){x(!0);const N=P-c[0];S(N);return}}if(e){m(!0);const[P]=e.convertFromPixel(Se,[E.offsetX,E.offsetY]);Pe=P;return}}}return Le(k,"mousedown",D)},[k,e,c,T,r]),u.useEffect(()=>{function D(E){var L;if(((L=E==null?void 0:E.target)==null?void 0:L.type)==="polygon"&&T("move"),d&&e&&(w(E),T("grabbing")),f&&e){const[P]=e.convertFromPixel(Se,[E.offsetX,E.offsetY]);g(Pe===P?[]:[Pe,P])}}return Le(k,"mousemove",D)},[k,e,f,d,g,T,w]),u.useEffect(()=>{function D(E){if(d&&(y(!1),T("default")),f&&(m(!1),Pe=null,c.length===1&&g([])),v&&e){const[L]=e.convertFromPixel(Se,[E.offsetX,E.offsetY]),P=L-c[0];if(b){const N=P-b;g([c[0]+N,c[1]+N])}x(!1)}}return Le(k,"mouseup",D)},[k,e,v,f,d,b,g,c,T]),u.useEffect(()=>{!r&&c.length&&g([])},[r,g,c.length]);const C=u.useMemo(()=>{var P;if(c.length!==1)return;const D=c[0],E=Re(D,n);if(E===void 0)return;const L=(P=n[E])==null?void 0:P.name;return L!==void 0&&{symbol:["none","none"],animationDuration:100,animationDurationUpdate:150,animationEasingUpdate:"linear",data:a||l?[{label:{show:!1},emphasis:{label:{show:!1}},xAxis:L,lineStyle:{type:"solid",color:s.palette.primary.main,width:1.5,shadowColor:s.palette.primary.light,shadowBlur:3}}]:[]}},[n,a,l,s,c]),M=u.useMemo(()=>c.length===2&&{data:[[{coord:[c[0]]},{coord:[c[1]]}]],itemStyle:{color:s.palette.primary.main,opacity:.2}},[s,c]);return{timelineOptions:C,timeWindowOptions:M}}function Le(e,n,i){if(e!=null&&e.handler)return jt[n]=i,e.on(n,i),()=>{jt[n]&&(e!=null&&e.handler)&&e.off(n,i)}}const Ut=j.SPACING*22,qt="100%",Mi=5,Ci=3,Ai=j.SPACING*20;function Ei({chartType:e,formatter:n,timeAxisSplitNumber:i,tooltip:r,tooltipFormatter:s,data:l,series:a,categories:p,height:c,fitHeight:g,animation:h,filterable:d,selectedCategories:y,onCategoryClick:f,yAxisType:m}){const v=o.useTheme(),[x,b]=u.useState(),S=A=>b(A),[k,T]=u.useState(),w=u.useMemo(()=>a.reduce((A,{data:$})=>$.reduce((I,O)=>O[1]>I?O[1]:I,A),Number.MIN_VALUE),[a]),C=u.useMemo(()=>({show:r,trigger:"axis",appendToBody:!0,padding:[j.SPACING*.5,j.SPACING],textStyle:{...v.typography.caption,fontSize:11,color:v.palette.common.white},borderWidth:0,backgroundColor:v.palette.black[90],position:(A,$,I,O,G)=>{const R={top:0};return G.contentSize[0]<G.viewSize[0]-A[0]?R.left=A[0]+j.SPACING*1.5:R.right=G.viewSize[0]-A[0]+j.SPACING*1.5,R},...s?{formatter:s}:{}}),[v,r,s]),M=u.useMemo(()=>{const A={margin:0,verticalAlign:"bottom",padding:[0,0,j.SPACING*1.25,0],inside:!0,color:O=>{let G="transparent";return O>=w&&(G=v.palette.black[60]),G}},$={margin:0,verticalAlign:"middle",padding:[0,j.SPACING*.75,0,0],color:v.palette.black[60]},I=m==="dense"?A:$;return{axisPointer:{lineStyle:{color:v.palette.black[40]}},xAxis:{type:"time",axisLine:{show:!0,lineStyle:{color:v.palette.grey[900],opacity:.2}},axisLabel:{fontWeight:v.typography.fontWeightRegular,fontSize:v.typography.caption.fontSize,fontFamily:v.typography.caption.fontFamily,lineHeight:v.typography.caption.lineHeight*8,letterSpacing:v.typography.caption.letterSpacing,formatter:{year:"{yearStyle|{yyyy}}"},rich:{yearStyle:{fontWeight:v.typography.fontWeightMedium,fontSize:v.typography.caption.fontSize,fontFamily:v.typography.caption.fontFamily,letterSpacing:v.typography.caption.letterSpacing,lineHeight:v.typography.caption.lineHeight*8}}},axisTick:{show:!1},splitNumber:i??(k!==void 0?Math.min(Ci,Math.ceil(k/Ai)):Mi)},yAxis:{type:"value",axisLabel:{show:!0,showMaxLabel:!0,showMinLabel:!1,...I,...n?{formatter:O=>n(O)}:{},fontWeight:v.typography.fontWeightRegular,fontSize:v.typography.overlineDelicate.fontSize,fontFamily:v.typography.overlineDelicate.fontFamily,lineHeight:v.typography.overlineDelicate.lineHeight*8,letterSpacing:v.typography.overlineDelicate.letterSpacing},axisLine:{show:!1},axisTick:{show:!1},splitLine:{show:!0,onZero:!1,lineStyle:{color:v.palette.black[4]}},max:w}}},[v,w,n,k,i,m]),{timelineOptions:D,timeWindowOptions:E}=Vt({echartsInstance:x,data:l,canSelectLines:!!f,filterable:d}),L=u.useMemo(()=>a.map(({data:A,color:$,name:I},O)=>{const G=y&&y.length>0,R=G&&y.includes(I),z=!G||R?$:v.palette.action.disabledBackground;return{id:String(O),name:I,markLine:O===0?D:void 0,markArea:O===0?E:void 0,animation:h,data:A,type:e,smooth:!0,color:z,z:G&&R?10:0,lineStyle:{width:2},showSymbol:!1,emphasis:{scale:2,lineStyle:{width:2,color:z}}}}),[a,D,E,h,e,y,v]),P=u.useMemo(()=>({grid:{left:j.SPACING*(m==="dense"?2:3.5),top:j.SPACING*4,right:j.SPACING*2,bottom:j.SPACING*3},color:[v.palette.secondary.main],tooltip:C,...M,series:L}),[M,L,m,v.palette.secondary.main,C]),V={click:u.useCallback(A=>{if(p&&f&&A.componentType==="series"){const $=p[A.seriesIndex];f($)}},[p,f])};u.useEffect(()=>{var I;if(typeof ResizeObserver>"u"||!x)return;const A=(I=x==null?void 0:x.getDom())==null?void 0:I.parentElement;if(!A)return;const $=new ResizeObserver(()=>{T(A.clientWidth),x.resize()});return $.observe(A),()=>{$.disconnect()}},[x]);const _=g?qt:c??Ut;return u.useLayoutEffect(()=>{var $;const A=($=x==null?void 0:x.getDom())==null?void 0:$.parentElement;A&&T(A.clientWidth),x==null||x.resize()},[_,g,x]),t.jsx(ye,{option:P,onEvents:V,onChartReady:S,style:{height:_}})}const Bi={[ae.YEARS]:60*60*24*7,[ae.MONTHS]:60*60*24,[ae.WEEKS]:60*60*24,[ae.DAYS]:60*60*12,[ae.HOURS]:60*60,[ae.MINUTES]:60*15,[ae.SECONDS]:1},Pi=[.5,1,2,3];function Li({data:e,stepSize:n}){const[i,r]=u.useState(null),[s,l]=u.useState(1),a=u.useRef({animationFrameId:null,timeoutId:null}),{isPlaying:p,isPaused:c,timeWindow:g,setTimeWindow:h,stop:d,togglePlay:y,intl:f}=ze();Ri(()=>(p||c)&&d(),[e]);const m=()=>{const{animationFrameId:T,timeoutId:w}=a.current;T&&window.cancelAnimationFrame(T),w&&clearTimeout(w)},v=u.useCallback(()=>{m(),d()},[d]),x=()=>{m(),y()};u.useEffect(()=>{if(p&&g.length===2&&e.length){const w=Bi[n]*1e3;return Fi({data:e,timeWindow:g,msTimeWindowStep:w*s,drawFrame:C=>{h(C)},onEnd:()=>{setTimeout(v,250)},animationRef:a}),()=>m()}},[e,p,n,h,v,s]),u.useEffect(()=>{if(p&&g.length===1&&e.length)return _i({speed:s,timelinePosition:g[0],data:e,drawFrame:T=>{h([T])},onEnd:()=>{setTimeout(v,250)},animationRef:a}),()=>m();p&&g.length===0&&h([e[0].name])},[e,p,s,g.length,v]);const b=T=>{T!=null&&T.currentTarget&&r(T.currentTarget)},S=()=>{r(null)},k=T=>{l(T),S()};return t.jsxs(t.Fragment,{children:[t.jsx(o.IconButton,{size:"small",color:"default",onClick:b,"data-testid":"clock",children:t.jsx(Di,{})}),t.jsxs(o.Menu,{anchorEl:i,keepMounted:!0,open:!!i,onClose:S,children:[t.jsx(o.MenuItem,{disabled:!0,children:t.jsx(j.Typography,{variant:"caption",color:"textSecondary",children:f.formatMessage({id:"c4r.widgets.timeSeries.speed"})})}),Pi.map(T=>t.jsxs(o.MenuItem,{selected:T===s,onClick:()=>k(T),children:[T,"x"]},T))]}),t.jsx(o.Box,{mt:2,children:t.jsx(o.IconButton,{size:"small",color:"primary",disabled:!(c||p),onClick:v,"data-testid":"stop",children:t.jsx(Oi,{})})}),t.jsx(o.Box,{mt:.75,children:t.jsx(o.IconButton,{"data-testid":"play-pause",size:"small",color:"primary",onClick:x,children:p?t.jsx($i,{}):t.jsx(Ni,{})})})]})}function Di(){return t.jsx(o.SvgIcon,{viewBox:"0 0 20 20",children:t.jsx("path",{d:"M12.5 1.254h-5v1.667h5V1.254zM9.167 12.088h1.666v-5H9.167v5zm6.691-5.517 1.184-1.183a9.207 9.207 0 0 0-1.175-1.175l-1.184 1.183A7.468 7.468 0 0 0 10 3.746a7.5 7.5 0 0 0-7.5 7.5c0 4.141 3.35 7.5 7.5 7.5s7.5-3.358 7.5-7.5a7.504 7.504 0 0 0-1.642-4.675zM10 17.088a5.83 5.83 0 0 1-5.833-5.834A5.83 5.83 0 0 1 10 5.421a5.83 5.83 0 0 1 5.833 5.833A5.83 5.83 0 0 1 10 17.087z",id:"-↳Color",fill:"inherit"})})}function Ni(){return t.jsx(o.SvgIcon,{"data-testid":"play-icon",children:t.jsx("path",{d:"M10 16.5l6-4.5-6-4.5v9zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z",id:"-↳Color",fill:"inherit"})})}function Oi(){return t.jsx(o.SvgIcon,{children:t.jsx("path",{d:"M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2zm0 2c-4.41 0-8 3.59-8 8s3.59 8 8 8 8-3.59 8-8-3.59-8-8-8zm4 4v8H8V8h8zm-2 2h-4v4h4v-4z",id:"-↳Color",fill:"inherit"})})}function $i(){return t.jsx(o.SvgIcon,{"data-testid":"pause-icon",children:t.jsx("path",{d:"M9,16 L11,16 L11,8 L9,8 L9,16 Z M12,2 C6.48,2 2,6.48 2,12 C2,17.52 6.48,22 12,22 C17.52,22 22,17.52 22,12 C22,6.48 17.52,2 12,2 Z M12,20 C7.59,20 4,16.41 4,12 C4,7.59 7.59,4 12,4 C16.41,4 20,7.59 20,12 C20,16.41 16.41,20 12,20 Z M13,16 L15,16 L15,8 L13,8 L13,16 Z",id:"-↳Color",fill:"inherit"})})}function Ri(e,n=[]){const i=u.useRef(!1);u.useEffect(()=>{i.current?e():i.current=!0},n)}function Fi({msTimeWindowStep:e,timeWindow:n,data:i,drawFrame:r,onEnd:s,animationRef:l}){let a=n;const p=()=>{l.current.animationFrameId=window.requestAnimationFrame(c)},c=()=>{a=[a[0]+e,a[1]+e],a[1]>i[i.length-1].name?s():(r(a),p())};p()}const Wi=2;function _i({speed:e,timelinePosition:n,data:i,drawFrame:r,onEnd:s,animationRef:l}){let a=Re(n,i)??0,p=i[a].name;const c=gi(i),g=Math.max(Math.round(Math.sqrt(c)/2),Wi)*e,h=()=>{l.current.timeoutId=setTimeout(()=>{l.current.animationFrameId=window.requestAnimationFrame(d)},1e3/g)},d=()=>{for(;a<i.length;a++){const y=i[a].name;if(y!==p){p=y;break}}a===i.length?s():(r(p),h())};h()}const Gi=o.styled(o.Box)(()=>({containerType:"inline-size",display:"flex",flexDirection:"column"})),zi=o.styled(o.Box)(()=>({display:"flex",flexDirection:"column"})),Kt=o.styled(o.Box)(()=>({display:"flex",flexDirection:"row"})),Hi=o.styled(Kt)(()=>({alignItems:"center",justifyContent:"space-between"})),Yi=o.styled(o.Box)(({theme:e})=>({flexShrink:0,marginLeft:0,paddingLeft:e.spacing(1),[`@container (max-width: ${j.BREAKPOINTS.XS}px)`]:{paddingLeft:0},paddingBottom:e.spacing(1.5),alignSelf:"flex-end"})),Vi=o.styled(o.Box)(({theme:e})=>({alignSelf:"normal",minWidth:0,paddingLeft:e.spacing(5),paddingBottom:e.spacing(1.5),[`@container (max-width: ${j.BREAKPOINTS.XS}px)`]:{paddingLeft:e.spacing(1)}}));function Xt({fitHeight:e,header:n,controls:i,chart:r,legend:s}){const l=s&&t.jsx(o.Box,{flex:0,mt:2,children:s});return t.jsxs(Gi,{style:{flex:e?"1":void 0},children:[t.jsx(Hi,{flex:0,children:n}),i?t.jsxs(zi,{flex:1,children:[t.jsxs(Kt,{flex:1,children:[t.jsx(Yi,{flex:0,children:i}),t.jsx(Vi,{flex:1,children:r})]}),l]}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{pb:1.5,flex:1,children:r}),l]})]})}const Ui=e=>t.jsx(o.SvgIcon,{width:"720",height:"124",viewBox:"0 0 720 124",...e,children:t.jsx("path",{d:"M0.74707 123C11.8168 119.656 26.7934 118.37 53.4909 102.164C73.1959 90.2031 92.5604 81.3284 108.188 76.6983C122.841 72.357 136.188 74.3832 144.653 75.1549C150.496 75.6876 195.443 82.8718 207.164 83.6435C218.885 84.4152 241.676 87.502 274.234 80.5567C306.791 73.6115 305.869 75.4585 330.233 67.438C388.837 48.1456 433.461 2.6348 458.511 1.07229C495.627 -1.24279 512.557 52.7758 539.255 58.1776C565.952 63.5795 583.534 64.3512 601.766 55.0909C619.999 45.8305 625.859 40.4287 646.045 38.1136C666.231 35.7985 683.812 41.972 718.975 70.5247",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})}),qi=o.styled(o.Box)(()=>({display:"flex",flexDirection:"column",justifyContent:"flex-end"})),Ki=o.styled(o.Box)(()=>({position:"relative",height:"100%",alignSelf:"normal",display:"flex",flexDirection:"column",justifyContent:"flex-end"})),Xi=o.styled(o.Box)(({theme:e})=>({padding:e.spacing(2.25,0,.5,2)})),Zi=o.styled(Pt)(({theme:e})=>({flexDirection:"column",flex:1,height:"100%",overflow:"hidden",svg:{height:"100%",width:"100%",fontSize:"initial",fill:"none",path:{stroke:e.palette.black[8]}}})),Ji=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",justifyContent:"space-between",padding:e.spacing(1.25,.5,.75,.5)})),Qi=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(2),margin:0,padding:e.spacing(1.5,1,.25,1)})),wt=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(1)})),er=({fitHeight:e,height:n,showControls:i,showLegend:r})=>{const s=t.jsx(o.Box,{pt:1.25,pb:.75,children:t.jsx(o.Skeleton,{width:48,height:8})}),l=i&&t.jsxs(qi,{children:[t.jsx(o.Box,{p:.5,children:t.jsx(o.Skeleton,{width:16,height:16})}),t.jsx(o.Box,{mt:2,p:.5,children:t.jsx(o.Skeleton,{width:16,height:16})}),t.jsx(o.Box,{mt:1,p:.5,children:t.jsx(o.Skeleton,{width:16,height:16})})]}),a=e?qt:n??Ut,p=t.jsxs(Ki,{style:{height:a},children:[t.jsx(Xi,{flex:0,children:t.jsx(o.Skeleton,{width:24,height:8})}),t.jsx(Zi,{flex:1,children:t.jsx(Ui,{preserveAspectRatio:"none"})}),t.jsxs(Ji,{flex:0,children:[t.jsx(o.Skeleton,{width:32,height:8}),t.jsx(o.Skeleton,{width:32,height:8})]})]}),c=r&&t.jsxs(Qi,{children:[t.jsxs(wt,{children:[t.jsx(o.Skeleton,{width:8,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]}),t.jsxs(wt,{children:[t.jsx(o.Skeleton,{width:8,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]})]});return t.jsx(Xt,{fitHeight:!!e,header:s,controls:l,chart:p,legend:r&&c})},Zt=e=>e,Jt=[];function tr({data:e=Jt,categories:n,stepSize:i,stepMultiplier:r=1,chartType:s=Ge.LINE,timeAxisSplitNumber:l,tooltip:a=!0,tooltipFormatter:p=_t,formatter:c=Zt,height:g,fitHeight:h,showControls:d=!0,animation:y=!0,filterable:f=!0,onTimelineUpdate:m,timeWindow:v,timelinePosition:x,onTimeWindowUpdate:b,selectedCategories:S,onSelectedCategoriesChange:k,isPlaying:T=!1,onPlay:w,isPaused:C=!1,onPause:M,onStop:D,isLoading:E=!1,palette:L=Object.values(Me.commonPalette.qualitative.bold),showLegend:P,yAxisType:N="dense"}){const V=u.useRef([]),_=Z.useIntl(),{showSkeleton:A}=de(!!E),$=u.useCallback(I=>{var O,G;if(I.length===2){((O=V.current)==null?void 0:O.length)===1&&(m==null||m(void 0));const R=I.sort((z,q)=>z<q?-1:1).map(Gt);b==null||b(R)}if(I.length===1){((G=V.current)==null?void 0:G.length)===2&&(b==null||b([]));const R=Re(Number(I[0]),e);m==null||m(R)}V.current=I},[b,m,e]);return A?t.jsx(er,{fitHeight:h,height:g,showControls:d,showLegend:P}):t.jsx(Yt,{isPlaying:T,onPlay:w,isPaused:C,onPause:M,onStop:D,timeWindow:v,onTimeWindowUpdate:$,intl:_,children:t.jsx(nr,{data:e,categories:n,stepSize:i,stepMultiplier:r,chartType:s,timeAxisSplitNumber:l,tooltip:a,tooltipFormatter:p,formatter:c,height:g,fitHeight:h,showControls:d,animation:y,filterable:f,palette:L,showLegend:P,selectedCategories:S,timelinePosition:x,onSelectedCategoriesChange:k,yAxisType:N})})}function nr({data:e=Jt,categories:n,stepSize:i,stepMultiplier:r=1,chartType:s=Ge.LINE,timeAxisSplitNumber:l,tooltip:a=!0,tooltipFormatter:p=_t,formatter:c=Zt,height:g,fitHeight:h=!1,showControls:d=!0,animation:y=!0,filterable:f=!0,palette:m=Object.values(Me.commonPalette.qualitative.bold),selectedCategories:v=[],onSelectedCategoriesChange:x,showLegend:b,timelinePosition:S,yAxisType:k="dense"}){const T=o.useTheme(),w=T.palette.secondary.main,{isPlaying:C,isPaused:M,timeWindow:D,stop:E,setTimeWindow:L,intl:P}=ze();u.useEffect(()=>{if(S!==void 0){if(S<0||S>=e.length)return;const F=e[S].name;L([F])}},[S,e]),u.useEffect(()=>{if(!e.length)return;const F=e[0].name,H=e[e.length-1].name;(D[0]<F||D[1]>H||D[1]<F||D[1]>H)&&L([])},[e]);const N=u.useMemo(()=>{const F={},H=n?n.map(J=>({name:J,data:[],color:Me.getColorByCategory(J,{palette:m,fallbackColor:w,colorMapping:F})})):[{name:"",data:[],color:T.palette.secondary.main}];for(const{name:J,value:ie,category:re,categoryIndex:W}of e){const K=W??(n&&re?n.indexOf(re):0);K===-1||n&&K>=n.length||!Number.isFinite(K)||H[K].data.push([J,ie])}return H},[n,e,m,w,T.palette.secondary.main]),V=u.useMemo(()=>{if(!e.length)return"";if(D.length===2){const[F,H]=D.map(J=>new Date(J));return Fe({start:F,end:H,stepSize:i})}if(!C&&!M){const F=new Date(e[0].name),H=new Date(e[e.length-1].name);return Fe({start:F,end:H,stepSize:i})}if(D.length===1){const F=new Date(D[0]);return zt({date:F,stepSize:i,stepMultiplier:r})}},[e,D,C,M,i,r]),_=u.useMemo(()=>C||M||D.length>0||(v==null?void 0:v.length)>0,[M,C,v==null?void 0:v.length,D.length]),A=()=>{E(),L([]),x==null||x([])},$=F=>{F.key==="Enter"&&A()},I=u.useCallback(F=>{if(x){const H=[...v],J=H.indexOf(F);J===-1?H.push(F):H.splice(J,1),x(H)}},[x,v]),O=!!(b??N.length>1),G=t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{children:t.jsx(j.Typography,{color:"textSecondary",variant:"caption",children:V??"-"})}),f&&_&&t.jsx(o.Link,{variant:"caption",style:{cursor:"pointer"},onClick:A,onKeyDown:$,tabIndex:0,underline:"hover",children:P.formatMessage({id:"c4r.widgets.timeSeries.clear"})})]}),R=f&&d&&t.jsx(Li,{data:e,stepSize:i}),z=t.jsx(Ei,{chartType:s,timeAxisSplitNumber:l,data:e,series:N,categories:n,tooltip:a,formatter:c,tooltipFormatter:F=>p(F,i,c,r,O),height:g,fitHeight:h,animation:y,filterable:f,selectedCategories:v,onCategoryClick:x&&I,yAxisType:k}),q=O&&t.jsx(Wt,{series:N,selectedCategories:v,onCategoryClick:x&&I});return t.jsx(Xt,{fitHeight:h,header:G,controls:R,chart:z,legend:q})}const or=o.styled("div")(({theme:e})=>({padding:e.spacing(2,0),...e.typography.body2})),ir=o.styled(o.Box)(({theme:e})=>({overflow:"auto",maxHeight:e.spacing(40),paddingRight:e.spacing(1),margin:e.spacing(.5,0)})),rr=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",flexWrap:"wrap",gap:e.spacing(1.5),padding:e.spacing(2,0)})),Qt=o.styled(o.Box)(({theme:e,alignItems:n="center"})=>({display:"flex",alignItems:n,gap:e.spacing(.75)})),en=o.styled("div",{shouldForwardProp:e=>e!=="color"})(({theme:e,color:n})=>({flexShrink:0,width:e.spacing(1),height:e.spacing(1),borderRadius:e.spacing(1),backgroundColor:n})),sr=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(2)})),lr=o.styled("div")(({theme:e})=>({height:e.spacing(.5),width:"100%",borderRadius:e.spacing(.5),backgroundColor:e.palette.action.disabledBackground,"& div":{width:0,height:"100%",borderRadius:e.spacing(.5),transition:`background-color ${e.transitions.easing.sharp} ${e.transitions.duration.shortest}ms,
|
|
19
|
-
width ${e.transitions.easing.sharp} ${e.transitions.duration.complex}ms`}})),bt=o.styled(o.Box,{shouldForwardProp:e=>e!=="center"})(({theme:e,center:n=!1})=>({marginBottom:e.spacing(2),paddingRight:e.spacing(1),...n&&{display:"flex",justifyContent:"space-between",alignItems:"center"},"& .MuiTypography-caption":{color:e.palette.text.secondary},"& .MuiButton-label":{...e.typography.caption},"& a":{cursor:"pointer"}})),ar=o.styled(o.Tooltip)(({theme:e})=>({".MuiTooltip-tooltip":{color:e.palette.common.white,maxWidth:260,marginBottom:0,overflow:"hidden"}})),cr=o.styled(o.TextField)(({theme:e})=>({marginTop:e.spacing(-.5)}));o.styled(o.Box)(()=>({display:"flex",flexWrap:"nowrap",justifyContent:"space-between"}));const dr=o.styled("div",{shouldForwardProp:e=>e!=="filterable"})(({filterable:e})=>({"& .progressbar div":{backgroundColor:"var(--color)"},...e&&{cursor:"pointer","& .MuiBox-root:hover .progressbar div":{backgroundColor:"var(--hover-color)"}}})),ur=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",flexWrap:"nowrap",overflow:"hidden",gap:e.spacing(1)})),pr=o.styled(o.Box)(({theme:e})=>({padding:e.spacing(.5,0),flexGrow:"1",maxWidth:"100%",minWidth:0})),gr=o.styled(o.Box,{shouldForwardProp:e=>e!=="backgroundColor"})(({theme:e,backgroundColor:n})=>({marginLeft:e.spacing(1),padding:e.spacing(0,1),backgroundColor:n,color:"white",borderRadius:e.spacing(2)}));function hr(e,n,i,r,s){const a=(e[0]??[]).map((p,c)=>{const g=String(p.name),h=r.length>0&&!r.includes(g),d=i[c]??g,y=e.map((f,m)=>{var v;return{color:h?o.lighten(n[m],.8):n[m],value:((v=f[c])==null?void 0:v.value)??0}});return{label:d,key:g,data:y}});return s===pe.RANKING&&a.sort((p,c)=>{const g=Math.max(...p.data.map(d=>d.value));return Math.max(...c.data.map(d=>d.value))-g}),a}const fr=500;function xr(e,n={}){const{disabled:i,duration:r,animateOnMount:s,initialValue:l=0}=n,a=u.useRef(null),[p,c]=u.useState(()=>s?l:e);return u.useEffect(()=>(i?c(e):
|
|
18
|
+
</div>`}var Ge=(e=>(e.LINE="line",e.BAR="bar",e))(Ge||{});function yt(e){if(typeof e=="object"&&typeof(e==null?void 0:e.getTime)=="function")return e.getTime();const n=new Date(e).getTime();if(isFinite(n))return n}function Gt(e){return typeof e=="object"&&typeof(e==null?void 0:e.getTime)=="function"?e:new Date(e)}function Re(e,n){var i,r;for(let s=0;s<n.length;s++){const l=n[s].name,a=s<n.length?(i=n[s+1])==null?void 0:i.name:l,p=s>0?(r=n[s-1])==null?void 0:r.name:l,c=Math.abs(l-a),g=Math.abs(l-p),h=l-g*.5,d=l+c*.5;if(isFinite(h)&&isFinite(d)){if(e>=h&&e<=d)return s}else if(isFinite(h)){if(e>=h)return s}else if(isFinite(d)&&e<=d)return s}}function gi(e){let n,i=0;for(const{name:r}of e)r!==n&&(n=r,i++);return i}function hi(e){const n=new Date(e),i=n.getDay(),r=n.getDate()-i+(i?1:-6);return n.setDate(r),n.setHours(0,0,0,0),n.getTime()}var ae=(e=>(e.YEARS="year",e.MONTHS="month",e.WEEKS="week",e.DAYS="day",e.HOURS="hour",e.MINUTES="minute",e.SECONDS="second",e))(ae||{});const et={year:fe,month:fe,week:fe,day:fe,hour:yi,minute:vt,second:vt},fi={year:Ti,month:ki,week:Ii,day:Si,hour:bi,minute:wi,second:ji};function xi({date:e,stepSize:n}){const i=et[n];if(!i)throw new Error("formatTime: invalid stepSize");return i(e)}function Fe({start:e,end:n,stepSize:i}){if(e>n)return Fe({start:n,end:e,stepSize:i});const r=et[i];if(!r)throw new Error("formatTimeRange: missing formatter or invalid stepSize");const s=r(e),l=r(n);return`${s} - ${l}`}function Ht({date:e,stepSize:n,stepMultiplier:i}){if(!et[n])throw new Error("formatBucketRange: missing formatter or invalid stepSize");const{start:s,end:l}=vi({date:e,stepSize:n,stepMultiplier:i});if(i===1){if(n==="day")return xi({date:s,stepSize:n});if(n==="second")return`${fe(s)} ${Ze(s)} - ${Ze(l)}`}return Fe({start:s,end:l,stepSize:n})}const tt=e=>1e3*e,nt=e=>tt(60*e),mi=e=>nt(60*e);function fe(e){return e.toLocaleDateString()}function yi(e){return fe(e)+" "+e.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0})}function Ze(e){return e.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!0,second:"2-digit"})}function vt(e){return fe(e)+" "+Ze(e)}function vi({date:e,stepSize:n,stepMultiplier:i=1}){const r=fi[n];if(!r)throw new Error("getBucketInterval: invalid bucket size");return r({date:e,stepMultiplier:i})}function ji({date:e,stepMultiplier:n=1}){const i=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),0),r=new Date(i.getTime()+tt(n-1)+999);return{start:i,end:r}}function wi({date:e,stepMultiplier:n=1}){const i=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),0,0),r=new Date(i.getTime()+nt(n-1)+tt(59));return{start:i,end:r}}function bi({date:e,stepMultiplier:n=1}){const i=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),0,0,0),r=new Date(i.getTime()+mi(n-1)+nt(59));return{start:i,end:r}}function Si({date:e,stepMultiplier:n=1}){const i=new Date(e.getFullYear(),e.getMonth(),e.getDate(),0,0,0,0),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()+n-1);return{start:i,end:r}}function Ii({date:e,stepMultiplier:n=1}){const i=new Date(hi(e)),r=new Date(i.getFullYear(),i.getMonth(),i.getDate()+6+7*(n-1));return{start:i,end:r}}function ki({date:e,stepMultiplier:n=1}){const i=new Date(e.getFullYear(),e.getMonth(),1),r=new Date(e.getFullYear(),e.getMonth()+n,0);return{start:i,end:r}}function Ti({date:e,stepMultiplier:n=1}){const i=new Date(e.getFullYear(),0,1),r=new Date(e.getFullYear()+(n-1),11,31);return{start:i,end:r}}const oe=()=>{},zt=u.createContext({isPlaying:!1,setIsPlaying:oe,isPaused:!1,setIsPaused:oe,timeWindow:[],setTimeWindow:oe,onTimeWindowUpdate:oe,togglePlay:oe,stop:oe,intl:{}});function He(){return u.useContext(zt)}function Yt({children:e,isPlaying:n,isPaused:i,onPlay:r=oe,onPause:s=oe,onStop:l=oe,timeWindow:a,onTimeWindowUpdate:p=oe,intl:c}){const[g,h]=u.useState(n),[d,y]=u.useState(i),[f,m]=u.useState([]),v=j.useImperativeIntl(c);u.useEffect(()=>{const I=f.sort((T,w)=>T<w?-1:1).map(Gt);p==null||p(I)},[f,p]);const x=u.useCallback(()=>{g&&(s&&s(),y(!0)),g||(r&&r(),y(!1)),h(I=>!I)},[g,s,r]),b=u.useCallback(()=>{h(!1),y(!1),m([])},[]),S=u.useCallback(()=>{b(),setTimeout(l)},[l,b]);return u.useEffect(()=>{n!==g&&h(n)},[n]),u.useEffect(()=>{i!==d&&y(i)},[i]),u.useEffect(()=>{if(!a)return;const I=a.map(yt),T=f.map(yt);(I[0]!==T[0]||I[1]!==T[1])&&m(I)},a),t.jsx(zt.Provider,{value:{isPlaying:!!g,setIsPlaying:h,isPaused:!!d,setIsPaused:y,timeWindow:f,setTimeWindow:m,onTimeWindowUpdate:p,togglePlay:x,stop:S,intl:v},children:e})}const jt={};let Pe=null;const Se={seriesId:"0"};function Vt({echartsInstance:e,data:n,canSelectLines:i,filterable:r}){const s=o.useTheme(),{isPlaying:l,isPaused:a,setIsPaused:p,timeWindow:c,setTimeWindow:g,stop:h}=He(),[d,y]=u.useState(!1),[f,m]=u.useState(!1),[v,x]=u.useState(!1),[b,S]=u.useState(0),I=u.useMemo(()=>e==null?void 0:e.getZr(),[e]),T=u.useCallback(D=>I==null?void 0:I.setCursorStyle(D),[I]),w=u.useCallback(D=>{if(e){const[E]=e.convertFromPixel(Se,[D.offsetX,D.offsetY]),L=Re(E,n);g(L!==void 0?[n[L].name]:[])}},[n,e,g]);u.useEffect(()=>{function D(E){r&&(i&&E.target||(c.length||(w(E),!a&&!l&&p(!0)),c.length===2&&(g([]),h())))}return Le(I,"click",D)},[I,a,l,p,g,h,c.length,w,i,r]),u.useEffect(()=>{function D(E){var L;if(r){if(((L=E.target)==null?void 0:L.type)==="ec-line"){y(!0),T("grabbing");return}if(c.length===2){const[P]=e.convertFromPixel(Se,[E.offsetX,E.offsetY]);if(P>=c[0]&&P<=c[1]){x(!0);const N=P-c[0];S(N);return}}if(e){m(!0);const[P]=e.convertFromPixel(Se,[E.offsetX,E.offsetY]);Pe=P;return}}}return Le(I,"mousedown",D)},[I,e,c,T,r]),u.useEffect(()=>{function D(E){var L;if(((L=E==null?void 0:E.target)==null?void 0:L.type)==="polygon"&&T("move"),d&&e&&(w(E),T("grabbing")),f&&e){const[P]=e.convertFromPixel(Se,[E.offsetX,E.offsetY]);g(Pe===P?[]:[Pe,P])}}return Le(I,"mousemove",D)},[I,e,f,d,g,T,w]),u.useEffect(()=>{function D(E){if(d&&(y(!1),T("default")),f&&(m(!1),Pe=null,c.length===1&&g([])),v&&e){const[L]=e.convertFromPixel(Se,[E.offsetX,E.offsetY]),P=L-c[0];if(b){const N=P-b;g([c[0]+N,c[1]+N])}x(!1)}}return Le(I,"mouseup",D)},[I,e,v,f,d,b,g,c,T]),u.useEffect(()=>{!r&&c.length&&g([])},[r,g,c.length]);const C=u.useMemo(()=>{var P;if(c.length!==1)return;const D=c[0],E=Re(D,n);if(E===void 0)return;const L=(P=n[E])==null?void 0:P.name;return L!==void 0&&{symbol:["none","none"],animationDuration:100,animationDurationUpdate:150,animationEasingUpdate:"linear",data:a||l?[{label:{show:!1},emphasis:{label:{show:!1}},xAxis:L,lineStyle:{type:"solid",color:s.palette.primary.main,width:1.5,shadowColor:s.palette.primary.light,shadowBlur:3}}]:[]}},[n,a,l,s,c]),M=u.useMemo(()=>c.length===2&&{data:[[{coord:[c[0]]},{coord:[c[1]]}]],itemStyle:{color:s.palette.primary.main,opacity:.2}},[s,c]);return{timelineOptions:C,timeWindowOptions:M}}function Le(e,n,i){if(e!=null&&e.handler)return jt[n]=i,e.on(n,i),()=>{jt[n]&&(e!=null&&e.handler)&&e.off(n,i)}}const Ut=j.SPACING*22,qt="100%",Mi=5,Ci=3,Ai=j.SPACING*20;function Ei({chartType:e,formatter:n,timeAxisSplitNumber:i,tooltip:r,tooltipFormatter:s,data:l,series:a,categories:p,height:c,fitHeight:g,animation:h,filterable:d,selectedCategories:y,onCategoryClick:f,yAxisType:m}){const v=o.useTheme(),[x,b]=u.useState(),S=B=>b(B),[I,T]=u.useState(),w=u.useMemo(()=>a.reduce((B,{data:$})=>$.reduce((k,O)=>O[1]>k?O[1]:k,B),Number.MIN_VALUE),[a]),C=u.useMemo(()=>({show:r,trigger:"axis",appendToBody:!0,padding:[j.SPACING*.5,j.SPACING],textStyle:{...v.typography.caption,fontSize:11,color:v.palette.common.white},borderWidth:0,backgroundColor:v.palette.black[90],position:(B,$,k,O,G)=>{const R={top:0};return G.contentSize[0]<G.viewSize[0]-B[0]?R.left=B[0]+j.SPACING*1.5:R.right=G.viewSize[0]-B[0]+j.SPACING*1.5,R},...s?{formatter:s}:{}}),[v,r,s]),M=u.useMemo(()=>{const B={margin:0,verticalAlign:"bottom",padding:[0,0,j.SPACING*1.25,0],inside:!0,color:O=>{let G="transparent";return O>=w&&(G=v.palette.black[60]),G}},$={margin:0,verticalAlign:"middle",padding:[0,j.SPACING*.75,0,0],color:v.palette.black[60]},k=m==="dense"?B:$;return{axisPointer:{lineStyle:{color:v.palette.black[40]}},xAxis:{type:"time",axisLine:{show:!0,lineStyle:{color:v.palette.grey[900],opacity:.2}},axisLabel:{fontWeight:v.typography.fontWeightRegular,fontSize:v.typography.caption.fontSize,fontFamily:v.typography.caption.fontFamily,lineHeight:v.typography.caption.lineHeight*8,letterSpacing:v.typography.caption.letterSpacing,formatter:{year:"{yearStyle|{yyyy}}"},rich:{yearStyle:{fontWeight:v.typography.fontWeightMedium,fontSize:v.typography.caption.fontSize,fontFamily:v.typography.caption.fontFamily,letterSpacing:v.typography.caption.letterSpacing,lineHeight:v.typography.caption.lineHeight*8}}},axisTick:{show:!1},splitNumber:i??(I!==void 0?Math.min(Ci,Math.ceil(I/Ai)):Mi)},yAxis:{type:"value",axisLabel:{show:!0,showMaxLabel:!0,showMinLabel:!1,...k,...n?{formatter:O=>n(O)}:{},fontWeight:v.typography.fontWeightRegular,fontSize:v.typography.overlineDelicate.fontSize,fontFamily:v.typography.overlineDelicate.fontFamily,lineHeight:v.typography.overlineDelicate.lineHeight*8,letterSpacing:v.typography.overlineDelicate.letterSpacing},axisLine:{show:!1},axisTick:{show:!1},splitLine:{show:!0,onZero:!1,lineStyle:{color:v.palette.black[4]}},max:w}}},[v,w,n,I,i,m]),{timelineOptions:D,timeWindowOptions:E}=Vt({echartsInstance:x,data:l,canSelectLines:!!f,filterable:d}),L=u.useMemo(()=>a.map(({data:B,color:$,name:k},O)=>{const G=y&&y.length>0,R=G&&y.includes(k),H=!G||R?$:v.palette.action.disabledBackground;return{id:String(O),name:k,markLine:O===0?D:void 0,markArea:O===0?E:void 0,animation:h,data:B,type:e,smooth:!0,color:H,z:G&&R?10:0,lineStyle:{width:2},showSymbol:!1,emphasis:{scale:2,lineStyle:{width:2,color:H}}}}),[a,D,E,h,e,y,v]),P=u.useMemo(()=>({grid:{left:j.SPACING*(m==="dense"?2:3.5),top:j.SPACING*4,right:j.SPACING*2,bottom:j.SPACING*3},color:[v.palette.secondary.main],tooltip:C,...M,series:L}),[M,L,m,v.palette.secondary.main,C]),V={click:u.useCallback(B=>{if(p&&f&&B.componentType==="series"){const $=p[B.seriesIndex];f($)}},[p,f])};u.useEffect(()=>{var k;if(typeof ResizeObserver>"u"||!x)return;const B=(k=x==null?void 0:x.getDom())==null?void 0:k.parentElement;if(!B)return;const $=new ResizeObserver(()=>{T(B.clientWidth),x.resize()});return $.observe(B),()=>{$.disconnect()}},[x]);const _=g?qt:c??Ut;return u.useLayoutEffect(()=>{var $;const B=($=x==null?void 0:x.getDom())==null?void 0:$.parentElement;B&&T(B.clientWidth),x==null||x.resize()},[_,g,x]),t.jsx(ye,{option:P,onEvents:V,onChartReady:S,style:{height:_}})}const Bi={[ae.YEARS]:60*60*24*7,[ae.MONTHS]:60*60*24,[ae.WEEKS]:60*60*24,[ae.DAYS]:60*60*12,[ae.HOURS]:60*60,[ae.MINUTES]:60*15,[ae.SECONDS]:1},Pi=[.5,1,2,3];function Li({data:e,stepSize:n}){const[i,r]=u.useState(null),[s,l]=u.useState(1),a=u.useRef({animationFrameId:null,timeoutId:null}),{isPlaying:p,isPaused:c,timeWindow:g,setTimeWindow:h,stop:d,togglePlay:y,intl:f}=He();Ri(()=>(p||c)&&d(),[e]);const m=()=>{const{animationFrameId:T,timeoutId:w}=a.current;T&&window.cancelAnimationFrame(T),w&&clearTimeout(w)},v=u.useCallback(()=>{m(),d()},[d]),x=()=>{m(),y()};u.useEffect(()=>{if(p&&g.length===2&&e.length){const w=Bi[n]*1e3;return Fi({data:e,timeWindow:g,msTimeWindowStep:w*s,drawFrame:C=>{h(C)},onEnd:()=>{setTimeout(v,250)},animationRef:a}),()=>m()}},[e,p,n,h,v,s]),u.useEffect(()=>{if(p&&g.length===1&&e.length)return _i({speed:s,timelinePosition:g[0],data:e,drawFrame:T=>{h([T])},onEnd:()=>{setTimeout(v,250)},animationRef:a}),()=>m();p&&g.length===0&&h([e[0].name])},[e,p,s,g.length,v]);const b=T=>{T!=null&&T.currentTarget&&r(T.currentTarget)},S=()=>{r(null)},I=T=>{l(T),S()};return t.jsxs(t.Fragment,{children:[t.jsx(o.IconButton,{size:"small",color:"default",onClick:b,"data-testid":"clock",children:t.jsx(Di,{})}),t.jsxs(o.Menu,{anchorEl:i,keepMounted:!0,open:!!i,onClose:S,children:[t.jsx(o.MenuItem,{disabled:!0,children:t.jsx(j.Typography,{variant:"caption",color:"textSecondary",children:f.formatMessage({id:"c4r.widgets.timeSeries.speed"})})}),Pi.map(T=>t.jsxs(o.MenuItem,{selected:T===s,onClick:()=>I(T),children:[T,"x"]},T))]}),t.jsx(o.Box,{mt:2,children:t.jsx(o.IconButton,{size:"small",color:"primary",disabled:!(c||p),onClick:v,"data-testid":"stop",children:t.jsx(Oi,{})})}),t.jsx(o.Box,{mt:.75,children:t.jsx(o.IconButton,{"data-testid":"play-pause",size:"small",color:"primary",onClick:x,children:p?t.jsx($i,{}):t.jsx(Ni,{})})})]})}function Di(){return t.jsx(o.SvgIcon,{viewBox:"0 0 20 20",children:t.jsx("path",{d:"M12.5 1.254h-5v1.667h5V1.254zM9.167 12.088h1.666v-5H9.167v5zm6.691-5.517 1.184-1.183a9.207 9.207 0 0 0-1.175-1.175l-1.184 1.183A7.468 7.468 0 0 0 10 3.746a7.5 7.5 0 0 0-7.5 7.5c0 4.141 3.35 7.5 7.5 7.5s7.5-3.358 7.5-7.5a7.504 7.504 0 0 0-1.642-4.675zM10 17.088a5.83 5.83 0 0 1-5.833-5.834A5.83 5.83 0 0 1 10 5.421a5.83 5.83 0 0 1 5.833 5.833A5.83 5.83 0 0 1 10 17.087z",id:"-↳Color",fill:"inherit"})})}function Ni(){return t.jsx(o.SvgIcon,{"data-testid":"play-icon",children:t.jsx("path",{d:"M10 16.5l6-4.5-6-4.5v9zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z",id:"-↳Color",fill:"inherit"})})}function Oi(){return t.jsx(o.SvgIcon,{children:t.jsx("path",{d:"M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2zm0 2c-4.41 0-8 3.59-8 8s3.59 8 8 8 8-3.59 8-8-3.59-8-8-8zm4 4v8H8V8h8zm-2 2h-4v4h4v-4z",id:"-↳Color",fill:"inherit"})})}function $i(){return t.jsx(o.SvgIcon,{"data-testid":"pause-icon",children:t.jsx("path",{d:"M9,16 L11,16 L11,8 L9,8 L9,16 Z M12,2 C6.48,2 2,6.48 2,12 C2,17.52 6.48,22 12,22 C17.52,22 22,17.52 22,12 C22,6.48 17.52,2 12,2 Z M12,20 C7.59,20 4,16.41 4,12 C4,7.59 7.59,4 12,4 C16.41,4 20,7.59 20,12 C20,16.41 16.41,20 12,20 Z M13,16 L15,16 L15,8 L13,8 L13,16 Z",id:"-↳Color",fill:"inherit"})})}function Ri(e,n=[]){const i=u.useRef(!1);u.useEffect(()=>{i.current?e():i.current=!0},n)}function Fi({msTimeWindowStep:e,timeWindow:n,data:i,drawFrame:r,onEnd:s,animationRef:l}){let a=n;const p=()=>{l.current.animationFrameId=window.requestAnimationFrame(c)},c=()=>{a=[a[0]+e,a[1]+e],a[1]>i[i.length-1].name?s():(r(a),p())};p()}const Wi=2;function _i({speed:e,timelinePosition:n,data:i,drawFrame:r,onEnd:s,animationRef:l}){let a=Re(n,i)??0,p=i[a].name;const c=gi(i),g=Math.max(Math.round(Math.sqrt(c)/2),Wi)*e,h=()=>{l.current.timeoutId=setTimeout(()=>{l.current.animationFrameId=window.requestAnimationFrame(d)},1e3/g)},d=()=>{for(;a<i.length;a++){const y=i[a].name;if(y!==p){p=y;break}}a===i.length?s():(r(p),h())};h()}const Gi=o.styled(o.Box)(()=>({containerType:"inline-size",display:"flex",flexDirection:"column"})),Hi=o.styled(o.Box)(()=>({display:"flex",flexDirection:"column"})),Xt=o.styled(o.Box)(()=>({display:"flex",flexDirection:"row"})),zi=o.styled(Xt)(()=>({alignItems:"center",justifyContent:"space-between"})),Yi=o.styled(o.Box)(({theme:e})=>({flexShrink:0,marginLeft:0,paddingLeft:e.spacing(1),[`@container (max-width: ${j.BREAKPOINTS.XS}px)`]:{paddingLeft:0},paddingBottom:e.spacing(1.5),alignSelf:"flex-end"})),Vi=o.styled(o.Box)(({theme:e})=>({alignSelf:"normal",minWidth:0,paddingLeft:e.spacing(5),paddingBottom:e.spacing(1.5),[`@container (max-width: ${j.BREAKPOINTS.XS}px)`]:{paddingLeft:e.spacing(1)}}));function Kt({fitHeight:e,header:n,controls:i,chart:r,legend:s}){const l=s&&t.jsx(o.Box,{flex:0,mt:2,children:s});return t.jsxs(Gi,{style:{flex:e?"1":void 0},children:[t.jsx(zi,{flex:0,children:n}),i?t.jsxs(Hi,{flex:1,children:[t.jsxs(Xt,{flex:1,children:[t.jsx(Yi,{flex:0,children:i}),t.jsx(Vi,{flex:1,children:r})]}),l]}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{pb:1.5,flex:1,children:r}),l]})]})}const Ui=e=>t.jsx(o.SvgIcon,{width:"720",height:"124",viewBox:"0 0 720 124",...e,children:t.jsx("path",{d:"M0.74707 123C11.8168 119.656 26.7934 118.37 53.4909 102.164C73.1959 90.2031 92.5604 81.3284 108.188 76.6983C122.841 72.357 136.188 74.3832 144.653 75.1549C150.496 75.6876 195.443 82.8718 207.164 83.6435C218.885 84.4152 241.676 87.502 274.234 80.5567C306.791 73.6115 305.869 75.4585 330.233 67.438C388.837 48.1456 433.461 2.6348 458.511 1.07229C495.627 -1.24279 512.557 52.7758 539.255 58.1776C565.952 63.5795 583.534 64.3512 601.766 55.0909C619.999 45.8305 625.859 40.4287 646.045 38.1136C666.231 35.7985 683.812 41.972 718.975 70.5247",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})}),qi=o.styled(o.Box)(()=>({display:"flex",flexDirection:"column",justifyContent:"flex-end"})),Xi=o.styled(o.Box)(()=>({position:"relative",height:"100%",alignSelf:"normal",display:"flex",flexDirection:"column",justifyContent:"flex-end"})),Ki=o.styled(o.Box)(({theme:e})=>({padding:e.spacing(2.25,0,.5,2)})),Zi=o.styled(Pt)(({theme:e})=>({flexDirection:"column",flex:1,height:"100%",overflow:"hidden",svg:{height:"100%",width:"100%",fontSize:"initial",fill:"none",path:{stroke:e.palette.black[8]}}})),Ji=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",justifyContent:"space-between",padding:e.spacing(1.25,.5,.75,.5)})),Qi=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(2),margin:0,padding:e.spacing(1.5,1,.25,1)})),wt=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(1)})),er=({fitHeight:e,height:n,showControls:i,showLegend:r})=>{const s=t.jsx(o.Box,{pt:1.25,pb:.75,children:t.jsx(o.Skeleton,{width:48,height:8})}),l=i&&t.jsxs(qi,{children:[t.jsx(o.Box,{p:.5,children:t.jsx(o.Skeleton,{width:16,height:16})}),t.jsx(o.Box,{mt:2,p:.5,children:t.jsx(o.Skeleton,{width:16,height:16})}),t.jsx(o.Box,{mt:1,p:.5,children:t.jsx(o.Skeleton,{width:16,height:16})})]}),a=e?qt:n??Ut,p=t.jsxs(Xi,{style:{height:a},children:[t.jsx(Ki,{flex:0,children:t.jsx(o.Skeleton,{width:24,height:8})}),t.jsx(Zi,{flex:1,children:t.jsx(Ui,{preserveAspectRatio:"none"})}),t.jsxs(Ji,{flex:0,children:[t.jsx(o.Skeleton,{width:32,height:8}),t.jsx(o.Skeleton,{width:32,height:8})]})]}),c=r&&t.jsxs(Qi,{children:[t.jsxs(wt,{children:[t.jsx(o.Skeleton,{width:8,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]}),t.jsxs(wt,{children:[t.jsx(o.Skeleton,{width:8,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]})]});return t.jsx(Kt,{fitHeight:!!e,header:s,controls:l,chart:p,legend:r&&c})},Zt=e=>e,Jt=[];function tr({data:e=Jt,categories:n,stepSize:i,stepMultiplier:r=1,chartType:s=Ge.LINE,timeAxisSplitNumber:l,tooltip:a=!0,tooltipFormatter:p=_t,formatter:c=Zt,height:g,fitHeight:h,showControls:d=!0,animation:y=!0,filterable:f=!0,onTimelineUpdate:m,timeWindow:v,timelinePosition:x,onTimeWindowUpdate:b,selectedCategories:S,onSelectedCategoriesChange:I,isPlaying:T=!1,onPlay:w,isPaused:C=!1,onPause:M,onStop:D,isLoading:E=!1,palette:L=Object.values(Me.commonPalette.qualitative.bold),showLegend:P,yAxisType:N="dense"}){const V=u.useRef([]),_=Z.useIntl(),{showSkeleton:B}=de(!!E),$=u.useCallback(k=>{var O,G;if(k.length===2){((O=V.current)==null?void 0:O.length)===1&&(m==null||m(void 0));const R=k.sort((H,q)=>H<q?-1:1).map(Gt);b==null||b(R)}if(k.length===1){((G=V.current)==null?void 0:G.length)===2&&(b==null||b([]));const R=Re(Number(k[0]),e);m==null||m(R)}V.current=k},[b,m,e]);return B?t.jsx(er,{fitHeight:h,height:g,showControls:d,showLegend:P}):t.jsx(Yt,{isPlaying:T,onPlay:w,isPaused:C,onPause:M,onStop:D,timeWindow:v,onTimeWindowUpdate:$,intl:_,children:t.jsx(nr,{data:e,categories:n,stepSize:i,stepMultiplier:r,chartType:s,timeAxisSplitNumber:l,tooltip:a,tooltipFormatter:p,formatter:c,height:g,fitHeight:h,showControls:d,animation:y,filterable:f,palette:L,showLegend:P,selectedCategories:S,timelinePosition:x,onSelectedCategoriesChange:I,yAxisType:N})})}function nr({data:e=Jt,categories:n,stepSize:i,stepMultiplier:r=1,chartType:s=Ge.LINE,timeAxisSplitNumber:l,tooltip:a=!0,tooltipFormatter:p=_t,formatter:c=Zt,height:g,fitHeight:h=!1,showControls:d=!0,animation:y=!0,filterable:f=!0,palette:m=Object.values(Me.commonPalette.qualitative.bold),selectedCategories:v=[],onSelectedCategoriesChange:x,showLegend:b,timelinePosition:S,yAxisType:I="dense"}){const T=o.useTheme(),w=T.palette.secondary.main,{isPlaying:C,isPaused:M,timeWindow:D,stop:E,setTimeWindow:L,intl:P}=He();u.useEffect(()=>{if(S!==void 0){if(S<0||S>=e.length)return;const F=e[S].name;L([F])}},[S,e]),u.useEffect(()=>{if(!e.length)return;const F=e[0].name,z=e[e.length-1].name;(D[0]<F||D[1]>z||D[1]<F||D[1]>z)&&L([])},[e]);const N=u.useMemo(()=>{const F={},z=n?n.map(J=>({name:J,data:[],color:Me.getColorByCategory(J,{palette:m,fallbackColor:w,colorMapping:F})})):[{name:"",data:[],color:T.palette.secondary.main}];for(const{name:J,value:ie,category:re,categoryIndex:W}of e){const X=W??(n&&re?n.indexOf(re):0);X===-1||n&&X>=n.length||!Number.isFinite(X)||z[X].data.push([J,ie])}return z},[n,e,m,w,T.palette.secondary.main]),V=u.useMemo(()=>{if(!e.length)return"";if(D.length===2){const[F,z]=D.map(J=>new Date(J));return Fe({start:F,end:z,stepSize:i})}if(!C&&!M){const F=new Date(e[0].name),z=new Date(e[e.length-1].name);return Fe({start:F,end:z,stepSize:i})}if(D.length===1){const F=new Date(D[0]);return Ht({date:F,stepSize:i,stepMultiplier:r})}},[e,D,C,M,i,r]),_=u.useMemo(()=>C||M||D.length>0||(v==null?void 0:v.length)>0,[M,C,v==null?void 0:v.length,D.length]),B=()=>{E(),L([]),x==null||x([])},$=F=>{F.key==="Enter"&&B()},k=u.useCallback(F=>{if(x){const z=[...v],J=z.indexOf(F);J===-1?z.push(F):z.splice(J,1),x(z)}},[x,v]),O=!!(b??N.length>1),G=t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{children:t.jsx(j.Typography,{color:"textSecondary",variant:"caption",children:V??"-"})}),f&&_&&t.jsx(o.Link,{variant:"caption",style:{cursor:"pointer"},onClick:B,onKeyDown:$,tabIndex:0,underline:"hover",children:P.formatMessage({id:"c4r.widgets.timeSeries.clear"})})]}),R=f&&d&&t.jsx(Li,{data:e,stepSize:i}),H=t.jsx(Ei,{chartType:s,timeAxisSplitNumber:l,data:e,series:N,categories:n,tooltip:a,formatter:c,tooltipFormatter:F=>p(F,i,c,r,O),height:g,fitHeight:h,animation:y,filterable:f,selectedCategories:v,onCategoryClick:x&&k,yAxisType:I}),q=O&&t.jsx(Wt,{series:N,selectedCategories:v,onCategoryClick:x&&k});return t.jsx(Kt,{fitHeight:h,header:G,controls:R,chart:H,legend:q})}const or=o.styled("div")(({theme:e})=>({padding:e.spacing(2,0),...e.typography.body2})),ir=o.styled(o.Box)(({theme:e})=>({overflow:"auto",maxHeight:e.spacing(40),paddingRight:e.spacing(1),margin:e.spacing(.5,0)})),rr=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",flexWrap:"wrap",gap:e.spacing(1.5),padding:e.spacing(2,0)})),Qt=o.styled(o.Box)(({theme:e,alignItems:n="center"})=>({display:"flex",alignItems:n,gap:e.spacing(.75)})),en=o.styled("div",{shouldForwardProp:e=>e!=="color"})(({theme:e,color:n})=>({flexShrink:0,width:e.spacing(1),height:e.spacing(1),borderRadius:e.spacing(1),backgroundColor:n})),sr=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(2)})),lr=o.styled("div")(({theme:e})=>({height:e.spacing(.5),width:"100%",borderRadius:e.spacing(.5),backgroundColor:e.palette.action.disabledBackground,"& div":{width:0,height:"100%",borderRadius:e.spacing(.5),transition:`background-color ${e.transitions.easing.sharp} ${e.transitions.duration.shortest}ms,
|
|
19
|
+
width ${e.transitions.easing.sharp} ${e.transitions.duration.complex}ms`}})),bt=o.styled(o.Box,{shouldForwardProp:e=>e!=="center"})(({theme:e,center:n=!1})=>({marginBottom:e.spacing(2),paddingRight:e.spacing(1),...n&&{display:"flex",justifyContent:"space-between",alignItems:"center"},"& .MuiTypography-caption":{color:e.palette.text.secondary},"& .MuiButton-label":{...e.typography.caption},"& a":{cursor:"pointer"}})),ar=o.styled(o.Tooltip)(({theme:e})=>({".MuiTooltip-tooltip":{color:e.palette.common.white,maxWidth:260,marginBottom:0,overflow:"hidden"}})),cr=o.styled(o.TextField)(({theme:e})=>({marginTop:e.spacing(-.5)}));o.styled(o.Box)(()=>({display:"flex",flexWrap:"nowrap",justifyContent:"space-between"}));const dr=o.styled("div",{shouldForwardProp:e=>e!=="filterable"})(({filterable:e})=>({"& .progressbar div":{backgroundColor:"var(--color)"},...e&&{cursor:"pointer","& .MuiBox-root:hover .progressbar div":{backgroundColor:"var(--hover-color)"}}})),ur=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",flexWrap:"nowrap",overflow:"hidden",gap:e.spacing(1)})),pr=o.styled(o.Box)(({theme:e})=>({padding:e.spacing(.5,0),flexGrow:"1",maxWidth:"100%",minWidth:0})),gr=o.styled(o.Box,{shouldForwardProp:e=>e!=="backgroundColor"})(({theme:e,backgroundColor:n})=>({marginLeft:e.spacing(1),padding:e.spacing(0,1),backgroundColor:n,color:"white",borderRadius:e.spacing(2)}));function hr(e,n,i,r,s){const a=(e[0]??[]).map((p,c)=>{const g=String(p.name),h=r.length>0&&!r.includes(g),d=i[c]??g,y=e.map((f,m)=>{var v;return{color:h?o.lighten(n[m],.8):n[m],value:((v=f[c])==null?void 0:v.value)??0}});return{label:d,key:g,data:y}});return s===pe.RANKING&&a.sort((p,c)=>{const g=Math.max(...p.data.map(d=>d.value));return Math.max(...c.data.map(d=>d.value))-g}),a}const fr=500;function xr(e,n={}){const{disabled:i,duration:r,animateOnMount:s,initialValue:l=0}=n,a=u.useRef(null),[p,c]=u.useState(()=>s?l:e);return u.useEffect(()=>(i?c(e):Xe({start:p,end:e,duration:r??fr,drawFrame:g=>c(g),requestRef:a}),()=>{a.current&&cancelAnimationFrame(a.current)}),[e,i,r]),p}const mr={};function tn({enabled:e=!0,value:n=0,options:i=mr,formatter:r}){const l=xr(n||0,{...{animateOnMount:!0,disabled:e===!1||n===null||n===void 0},...i});return t.jsx("span",{children:r?r(l):l})}const Je=e=>e,yr=()=>{},vr=[];function jr({item:e,index:n=0,names:i=vr,formatter:r=Je}){const s=o.useTheme(),l=e.data[0],a=e.data[n],p=i[n],c=(a.value-l.value)/(l.value||1)*100,g=Math.sign(c)===-1?"-":"+",h=Math.sign(c)===-1?s.palette.error.main:s.palette.success.main,d=e.key===me?s.palette.text.disabled:h;return t.jsxs("div",{children:[t.jsx(o.Typography,{color:"inherit",variant:"caption",noWrap:!0,children:e.label}),t.jsx(o.Box,{pt:1,pb:.5,children:t.jsxs(Qt,{alignItems:"baseline",children:[t.jsx(en,{color:e.key===me?s.palette.background.default:a.color}),t.jsx(o.Typography,{color:"inherit",variant:"caption",children:p}),t.jsx(o.Box,{style:{flexGrow:1}}),t.jsx(gr,{backgroundColor:d,children:t.jsxs(o.Typography,{color:"inherit",variant:"caption",children:[g,r(Math.abs(c))]})})]})})]})}function wr({item:e,animation:n=!0,animationOptions:i,maxValue:r,showCheckbox:s,checkboxChecked:l,formatter:a=Je,tooltipFormatter:p=Je,onClick:c=yr,names:g,tooltip:h}){function d(f){return`${Math.min(100,(f||0)/r*100)}%`}const y=f=>t.jsx(jr,{item:e,names:g,formatter:p,index:f});return t.jsxs(ur,{onClick:()=>c(e.key),children:[s?t.jsx(o.Checkbox,{checked:l}):null,t.jsxs(pr,{children:[t.jsx(o.Typography,{variant:"body2",noWrap:!0,children:e.label}),e.data.map((f,m)=>t.jsx(ar,{title:y(m),placement:"top-start",arrow:!1,disableHoverListener:!h,children:t.jsxs(sr,{children:[t.jsx(lr,{className:"progressbar",children:t.jsx("div",{style:{"--hover-color":o.darken(f.color,.2),"--color":f.color,width:d(f.value)}})}),t.jsx(o.Typography,{variant:m===0?"body2":"caption",color:m===0?"textPrimary":"textSecondary",children:t.jsx(tn,{value:f.value,enabled:n,options:i,formatter:a})})]})},`${e.key}_${m}`))]})]})}const St=e=>e,br=()=>{},Ie=[];function Sr({names:e=Ie,data:n=Ie,labels:i=Ie,colors:r=Ie,maxItems:s=5,order:l=pe.FIXED,animation:a=!0,animationOptions:p,searchable:c=!0,filterable:g=!0,selectedCategories:h=Ie,onSelectedCategoriesChange:d=br,formatter:y=St,tooltipFormatter:f=St,tooltip:m=!0,isLoading:v=!1}){const x=o.useTheme(),[b,S]=u.useState(!1),[I,T]=u.useState(!1),[w,C]=u.useState(h),[M,D]=u.useState(""),E=Z.useIntl(),L=j.useImperativeIntl(E),P=u.useMemo(()=>{const W=r.length?r:[x.palette.secondary.main,x.palette.primary.main,x.palette.info.main];return hr(n,W,i,h,l)},[n,r,i,x,h,l]),N=u.useMemo(()=>Math.max(...n.map(W=>W.map(X=>X.value??0)).flat()),[n]),V=u.useMemo(()=>{if(s>=P.length)return P;const W=P.slice(0,s),X=P.slice(s),K=[];for(const ge of X)ge.data.forEach((ve,he)=>{K[he]=K[he]??0,K[he]+=ve.value});const Q={key:me,label:c?"Others":`Others (${P.length-s})`,data:K.map(ge=>({value:ge,color:x.palette.divider}))};return[...W,Q]},[P,c,s,x.palette.divider]),_=u.useMemo(()=>P.filter(W=>h.includes(W.key)),[P,h]),B=u.useMemo(()=>M?P.filter(W=>{const X=(W.key||"").toLowerCase(),K=(W.label||"").toLowerCase(),Q=X==null?void 0:X.includes(M.toLowerCase()),ge=K==null?void 0:K.includes(M.toLowerCase());return Q||ge}):P,[P,M]),$=P.length-V.length+1,k=c&&!b&&s<P.length;if(P.length===0||v)return t.jsx(Ot,{});const O=b?B:I?_:V;function G(){T(!0),d([...w]),z()}function R(){T(!1)}function H(){d([])}function q(){T(!0)}function F(){S(!0),C([...h])}function z(){S(!1),C([])}function J(W){const X=h.includes(W),K=new Set(h);X?K.delete(W):K.add(W);let Q=Array.from(K);Q.length===P.length&&(Q=[]),d(Q)}function ie(W){const X=w.includes(W),K=new Set(w);X?K.delete(W):K.add(W);let Q=Array.from(K);Q.length===P.length&&(Q=[]),C(Q)}const re=g?b?ie:J:void 0;return t.jsxs(or,{children:[g?t.jsxs(bt,{center:!0,children:[t.jsx(j.Typography,{variant:"caption",children:h.length>0?L.formatMessage({id:"c4r.widgets.category.selectedItems"},{items:h.length}):L.formatMessage({id:"c4r.widgets.category.all"})}),t.jsx(j.Typography,{variant:"caption",children:b?t.jsx(o.Link,{onClick:G,children:L.formatMessage({id:"c4r.widgets.category.apply"})}):I?t.jsx(o.Link,{onClick:R,children:L.formatMessage({id:"c4r.widgets.category.unlock"})}):h.length?t.jsxs(o.Box,{style:{display:"flex",justifyContent:"flex-end",gap:x.spacing(1)},children:[t.jsx(o.Link,{onClick:q,children:L.formatMessage({id:"c4r.widgets.category.lock"})}),t.jsx(o.Divider,{orientation:"vertical",flexItem:!0}),t.jsx(o.Link,{onClick:H,children:L.formatMessage({id:"c4r.widgets.category.clear"})})]}):null})]}):null,b?t.jsx(bt,{children:t.jsx(cr,{size:"small",placeholder:L.formatMessage({id:"c4r.widgets.category.search"}),onChange:W=>D(W.currentTarget.value),onFocus:W=>W.currentTarget.scrollIntoView(),InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx(Te.Search,{})})}})}):null,t.jsxs(ir,{children:[O.length===0?t.jsxs(t.Fragment,{children:[t.jsx(j.Typography,{variant:"body2",children:L.formatMessage({id:"c4r.widgets.category.noResults"})}),t.jsx(j.Typography,{variant:"caption",children:L.formatMessage({id:"c4r.widgets.category.noResultsMessage"},{searchValue:M})})]}):null,O.map(W=>t.jsx(dr,{children:t.jsx(wr,{item:W,animation:a,animationOptions:p,maxValue:N,showCheckbox:g&&b,checkboxChecked:w.includes(W.key),formatter:y,tooltipFormatter:f,tooltip:m,onClick:re,names:e})},W.key))]}),k?t.jsx(o.Button,{size:"small",color:"primary",startIcon:t.jsx(Te.Search,{}),onClick:F,children:L.formatMessage({id:"c4r.widgets.category.searchInfo"},{elements:$})}):null,b?t.jsx(o.Button,{size:"small",color:"primary",onClick:z,children:L.formatMessage({id:"c4r.widgets.category.cancel"})}):null,t.jsx(rr,{children:e.map((W,X)=>t.jsxs(Qt,{children:[t.jsx(en,{color:(r==null?void 0:r[X])??x.palette.background.default}),t.jsx(j.Typography,{variant:"overline",children:W})]},e[X]))})]})}const Ir=o.styled(j.Typography)(({theme:e})=>({display:"inline-block",marginTop:e.spacing(.5)}));function kr({row:e}){const n=o.useTheme();return e.label?t.jsx(o.Box,{color:e.color??n.palette.text.secondary,children:t.jsx(Ir,{color:"inherit",variant:"caption",children:e.label})}):null}const Tr=o.styled("div")(({theme:e})=>({margin:0,...e.typography.h5,fontWeight:Number(e.typography.fontWeightMedium),color:e.palette.text.primary,display:"flex"})),Mr=o.styled(j.Typography)(({theme:e})=>({marginRight:e.spacing(.5)})),Cr=o.styled(j.Typography)(({theme:e})=>({marginLeft:e.spacing(.5)}));function Ar({row:e,animated:n,animationOptions:i,formatter:r}){const s=o.useTheme(),{prefix:l,value:a,suffix:p,shouldBeHighlighted:c}=e;return t.jsxs(Tr,{children:[l?t.jsx(o.Box,{color:s.palette.text.secondary,children:t.jsx(Mr,{color:"inherit",component:"span",variant:"subtitle2",children:l})}):null,t.jsx(o.Box,{fontWeight:c?"bold":"",children:t.jsx(tn,{value:a,enabled:n,options:i,formatter:r})}),p?t.jsx(o.Box,{color:s.palette.text.secondary,children:t.jsx(Cr,{color:"inherit",component:"span",variant:"subtitle2",children:p})}):null]})}const Er=e=>e,It=[],Br=o.styled("div")(({theme:e})=>({"&:nth-of-type(n+2)":{marginTop:e.spacing(2)}}));function Pr({data:e=It,colors:n=It,animated:i=!0,animationOptions:r,formatter:s=Er,isLoading:l=!1}){const a=Lr(e,n);return l?t.jsx(Rt,{}):t.jsx("div",{children:a.map((p,c)=>t.jsxs(Br,{children:[t.jsx(Ar,{row:p,animated:i,animationOptions:r,formatter:s}),t.jsx(kr,{row:p})]},c))})}function Lr(e,n){const i=e.map((s,l)=>({...s,color:n[l],shouldBeHighlighted:!1})).filter(s=>s.value!==void 0);return i&&i.length>1&&(i[0].shouldBeHighlighted=!0),i}function Dr(e,n=[],i=[],r,s=[]){return e.map((l,a)=>{const p=s.length>0&&!s.includes(l.name),g=(n!=null&&n.length?n:r.palette.qualitative.bold)[a];return{...l,key:l.name,color:p?o.lighten(g,.8):g,name:i[a]??l.name}})}function Nr(e,n,i){const r=`
|
|
20
20
|
font-size: 12px;
|
|
21
21
|
line-height: 1.33;
|
|
22
22
|
font-weight: 600;
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
`,l=Array.isArray(e)?e[0]:e;if(!l)return null;const a=l.data,p=n(a.value),c=i?l.seriesName:p,g=n(l.percent);return`
|
|
30
30
|
<p style="${r}">${a.name}</p>
|
|
31
31
|
<p style="${s}">${String(l.marker)} ${c} (${g} %)</p>
|
|
32
|
-
`.trim()}const Or=e=>e,$r=()=>{},De=[],Rr="260px";function Fr({names:e=De,data:n=De,labels:i=De,colors:r=De,height:s=Rr,animation:l=!0,formatter:a=Or,tooltipFormatter:p=Nr,selectedCategories:c=[],onCategorySelected:g=$r,isLoading:h=!1}){const d=o.useTheme(),y=u.useRef(),f=u.useMemo(()=>n.map((b,S)=>Dr(b,r[S],i[S],d,c)),[n,r,i,d,c]),m=u.useMemo(()=>{const b=f.length>1;let S;p&&(S=E=>p(E,a,b));const
|
|
33
|
-
{b|${E}}`,position:"center",rich:{b:{fontFamily:d.typography.overline.fontFamily,fontSize:j.SPACING*1.75,lineHeight:j.SPACING*1.75,fontWeight:400,color:d.palette.text.primary},per:{...d.typography.overline,fontSize:j.SPACING*3,lineHeight:j.SPACING*4.5,fontWeight:600,color:d.palette.text.primary}}},M=f.map((E,L)=>{var P;return{type:"pie",name:e[L],itemStyle:{color:(P=E[0])==null?void 0:P.color},animation:l,data:E.map(N=>({...N,itemStyle:{color:N.color}})),radius:L===0?["75%","90%"]:["56%","72%"],selectedOffset:0,hoverOffset:5,bottom:j.SPACING*2.5,avoidLabelOverlap:!0,label:{show:!1,...C},emphasis:{label:{show:!0,formatter:C.formatter,rich:C.rich}}}});return{grid:{left:0,top:0,right:0,bottom:0},tooltip:k,legend:w,series:M}},[d,e,l,f,a,p]),v={mouseover:(b,S)=>{f.length===1&&(b.seriesIndex!==0||b.dataIndex!==0)&&S.dispatchAction({type:"downplay",seriesIndex:0,dataIndex:0})},mouseout:(b,S)=>{f.length===1&&S.dispatchAction({type:"highlight",seriesIndex:0,dataIndex:0})},click:b=>{const k=f[b.seriesIndex][b.dataIndex].key,T=c.includes(k),w=new Set(c);T?w.delete(k):w.add(k);const C=f[0].length;let M=Array.from(w);M.length===C&&(M=[]),g(M)}};u.useEffect(()=>{y.current&&y.current.dispatchAction({type:f.length===1?"highlight":"downplay",seriesIndex:0,dataIndex:0})},[f]);function x(b){y.current=b}return f.length?h?t.jsx(Ft,{height:s}):t.jsx(ye,{onChartReady:x,notMerge:!0,option:m,onEvents:v,style:{maxHeight:s,width:"100%"}}):null}const Wr=()=>{};function nn({icon:e,hoverTooltip:n,clickTooltip:i,enabled:r,onEnabledChange:s=Wr,tooltipPlacement:l="bottom"}){const[a,p]=u.useState(!1),[c,g]=u.useState(r);u.useEffect(()=>{g(r)},[r]),u.useEffect(()=>{if(r){const d=y=>{y.key==="Escape"&&s&&s(!1)};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}}},[r,s]);const h=c?i:n;return t.jsx(o.ClickAwayListener,{onClickAway:()=>g(!1),children:t.jsx(o.Tooltip,{title:h,placement:l,open:a,onOpen:()=>p(!0),onClose:()=>{c||p(!1)},children:t.jsx(o.ToggleButton,{value:"selectedMode",selected:r,onClick:()=>s&&s(!r),children:e})})})}const _r=o.styled(o.IconButton,{shouldForwardProp:e=>e!=="isOpen"})(({isOpen:e,theme:n})=>({color:n.palette.text.secondary,width:n.spacing(3),transform:`rotate(${e?"180":"0"}deg)`,backgroundColor:e?n.palette.action.hover:void 0})),Gr=o.styled(o.MenuItem,{shouldForwardProp:e=>e!=="disabled"})(({disabled:e,theme:n})=>({...e&&{pointerEvents:"none",color:n.palette.text.disabled}})),zr=o.styled(o.MenuItem)(()=>({"&.Mui-disabled":{opacity:1}})),Hr=()=>{};function on({selectionModes:e,editModes:n,selectedMode:i,onSelectMode:r=Hr,enabled:s,tooltipPlacement:l="bottom",tooltipText:a="",menuHeaderText:p="",editDisabled:c}){const g=o.useTheme(),[h,d]=u.useState(null),y=!!h,f=k=>d(k.currentTarget),m=()=>d(null),v=k=>{r&&r(k),m()},x=!!e.length&&!!n.length,b=k=>n.some(T=>T.id===k.id);function S(k){return t.jsx(Gr,{selected:s&&i===k.id,onClick:()=>v(k.id),disabled:c&&b(k),children:t.jsxs(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[k.icon,t.jsx(o.Box,{ml:2,children:t.jsx(j.Typography,{variant:"body2",color:"inherit",children:o.capitalize(k.label)})})]})},k.id)}return t.jsxs(t.Fragment,{children:[t.jsx(o.Tooltip,{title:a,placement:l,children:t.jsx(_r,{id:"feature-selection-menu-button","aria-controls":"feature-selection-menu","aria-haspopup":"true","aria-expanded":y?"true":void 0,onClick:f,isOpen:y,children:t.jsx(ee.KeyboardArrowDown,{})})}),t.jsxs(o.Menu,{id:"feature-selection-menu",style:{zIndex:g.zIndex.tooltip+1},anchorEl:h,open:y,onClose:m,MenuListProps:{"aria-labelledby":"feature-selection-menu-button"},children:[p&&t.jsx(zr,{disabled:!0,children:t.jsx(j.Typography,{variant:"caption",color:"textSecondary",children:p})}),!!e.length&&e.map(S),x&&t.jsx(o.Divider,{sx:{margin:({spacing:k})=>k(1,0)}}),!!n.length&&n.map(S)]})]})}const Yr=o.styled(o.List)(({theme:e})=>({display:"flex",alignItems:"center",marginLeft:e.spacing(1.5),padding:e.spacing(.5),overflowX:"auto",maxWidth:"100%",scrollbarWidth:"none",msOverflowStyle:"none","&::-webkit-scrollbar":{display:"none"}})),Vr=()=>{};function rn({features:e,onSelectGeometry:n=Vr,onDeleteGeometry:i,chipTooltip:r,disabledChipTooltip:s,size:l="medium",tooltipPlacement:a="bottom",chipLabel:p}){const c=Z.useIntl(),g=j.useImperativeIntl(c);function h(m){return m==="MultiPoint"?g.formatMessage({id:"c4r.widgets.featureSelection.point"}):m==="MultiLineString"?g.formatMessage({id:"c4r.widgets.featureSelection.lineString"}):m==="MultiPolygon"||m==="Polygon"||m==="GeometryCollection"?g.formatMessage({id:"c4r.widgets.featureSelection.polygon"}):m}function d(m,v){var b;const x=h(m.geometry.type);return p||((b=m.properties)==null?void 0:b.name)||`${x} ${v+1}`}const[y,f]=u.useState(!1);return t.jsx(o.Box,{sx:{overflowX:"auto"},children:t.jsx(Yr,{sx:{gap:l==="small"?.5:1},children:e.map((m,v)=>{var T,w;const x=(T=m.properties)==null?void 0:T.disabled,b=(w=m.properties)==null?void 0:w.invalid;let S=r;x&&(S=s||r),b&&(S=g.formatMessage({id:"c4r.widgets.featureSelection.invalid"})),y&&(S=g.formatMessage({id:"c4r.widgets.featureSelection.remove"}));let k="secondary";return x&&(k="default"),b&&(k="error"),t.jsx(o.ListItem,{disablePadding:!0,children:t.jsx(o.Tooltip,{disableHoverListener:x?!s:!r,title:S,placement:a,children:t.jsx(o.Chip,{size:l,label:d(m,v),color:k,onClick:()=>n(m),onDelete:i?()=>i(m):void 0,icon:b?t.jsx(ee.ErrorOutline,{color:"error"}):void 0,deleteIcon:t.jsx(ee.Cancel,{onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1)})})})},v)})})})}const Ur=o.styled(o.Paper)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",maxHeight:e.spacing(5),padding:e.spacing(.5)})),qr=[];function Kr({selectionModes:e,editModes:n=qr,selectedMode:i,onSelectMode:r,enabled:s=!1,onEnabledChange:l,geometry:a,onSelectGeometry:p,onDeleteGeometry:c,tooltipPlacement:g="bottom",size:h="medium",chipLabel:d}){const y=Z.useIntl(),f=j.useImperativeIntl(y),m=u.useMemo(()=>e.map(T=>({...T,label:f.formatMessage({id:`c4r.widgets.featureSelection.${It(T.id)}`})})),[e,f]),v=u.useMemo(()=>n.map(T=>({...T,label:f.formatMessage({id:`c4r.widgets.featureSelection.${It(T.id)}`})})),[n,f]),x=u.useMemo(()=>{const w=[...m.map(C=>({...C,isEdit:!1})),...v.map(C=>({...C,isEdit:!0}))].find(C=>C.id===i);if(!w)throw new Error(`Selected mode "${i}" not supported`);return w},[v,m,i]),b=o.capitalize((x==null?void 0:x.label)||""),S=x!=null&&x.isEdit?b:f.formatMessage({id:"c4r.widgets.featureSelection.selectTool"},{label:b}),k=x!=null&&x.isEdit?f.formatMessage({id:"c4r.widgets.featureSelection.clickToEdit"}):f.formatMessage({id:"c4r.widgets.featureSelection.clickToCreate"});return t.jsxs(Ur,{children:[t.jsx(nn,{icon:x==null?void 0:x.icon,hoverTooltip:S,clickTooltip:k,enabled:s,onEnabledChange:l,tooltipPlacement:g}),t.jsx(on,{selectionModes:m,editModes:v,selectedMode:i,onSelectMode:r,enabled:s,tooltipPlacement:g,tooltipText:f.formatMessage({id:"c4r.widgets.featureSelection.selectMode"}),menuHeaderText:f.formatMessage({id:"c4r.widgets.featureSelection.chooseSelectionMode"}),editDisabled:!a}),!!a&&t.jsx(rn,{features:[a],onSelectGeometry:p,onDeleteGeometry:c,disabledChipTooltip:f.formatMessage({id:"c4r.widgets.featureSelection.applyMask"}),chipTooltip:f.formatMessage({id:"c4r.widgets.featureSelection.clearMask"}),tooltipPlacement:g,size:h,chipLabel:d})]})}function It(e){return e.charAt(0).toLowerCase()+e.slice(1)}const sn=240,Xr=o.styled(o.Paper,{shouldForwardProp:e=>e!=="collapsed"})(({theme:e,collapsed:n})=>({width:n?"min-content":sn,background:e.palette.background.paper,maxHeight:"calc(100% - 120px)",display:"flex",flexDirection:"column"})),Zr=o.styled("header",{shouldForwardProp:e=>e!=="collapsed"})(({theme:e,collapsed:n})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:e.spacing(1),paddingLeft:e.spacing(2),borderBottom:n?void 0:`1px solid ${e.palette.divider}`})),Jr=o.styled("header")(({theme:e})=>({padding:e.spacing(1.5),paddingRight:e.spacing(2),gap:e.spacing(.5),display:"flex",justifyContent:"space-between",position:"sticky",zIndex:2,top:0,background:e.palette.background.paper})),Qr=o.styled("div")(({theme:e})=>({display:"flex",gap:e.spacing(2),alignItems:"center",padding:e.spacing(1),minWidth:`calc(${sn}px - ${e.spacing(4)})`})),es=o.styled(o.TextField)(({theme:e})=>({display:"flex",width:e.spacing(7.5),flexShrink:0,"input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button":{WebkitAppearance:"none",margin:0}})),ts=o.styled("ul",{shouldForwardProp:e=>e!=="opacity"})(({theme:e,opacity:n})=>({opacity:n,margin:0,padding:0,display:"flex",flexDirection:"column",gap:e.spacing(1)})),ln=o.styled("ul")(({theme:e})=>({margin:0,padding:0,paddingBottom:e.spacing(1),display:"flex",flexDirection:"column"})),ns=o.styled("li")(()=>({display:"flex",alignItems:"center"})),os=o.styled("div")(({theme:e})=>({marginRight:e.spacing(1.5),width:j.ICON_SIZE_MEDIUM,height:j.ICON_SIZE_MEDIUM,"& img":{margin:"auto",display:"block"}})),Tt=o.styled(o.Box,{shouldForwardProp:e=>e!=="width"})(({width:e,theme:n})=>({width:e,overflow:"auto",maxHeight:`calc(100% - ${n.spacing(1.5)})`})),is=o.styled("section")(({theme:e})=>({"&:not(:first-of-type)":{borderTop:`1px solid ${e.palette.divider}`}})),rs=o.styled("div")(()=>({flexGrow:1,flexShrink:1,minWidth:0}));function ss({menuRef:e,open:n,toggleOpen:i,opacity:r,onChange:s}){const l=Z.useIntl(),a=j.useImperativeIntl(l);function p(c){const g=parseInt(c.target.value||"0"),h=Math.min(Math.max(g,0),100);s(h/100)}return t.jsxs(t.Fragment,{children:[t.jsx(o.Tooltip,{title:a.formatMessage({id:"c4r.widgets.legend.opacity"}),children:t.jsx(o.IconButton,{size:"small",color:n?"primary":"default",onClick:()=>i(!n),children:t.jsx(Te.SwatchSquare,{})})}),t.jsx(o.Popover,{open:n,onClose:()=>i(!1),anchorEl:e.current,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{root:{sx:{transform:"translate(-12px, 36px)"}}},children:t.jsxs(Qr,{children:[t.jsx(o.Slider,{value:r*100,onChange:(c,g)=>s(g/100),min:0,max:100,step:1}),t.jsx(es,{size:"small",type:"number",value:Math.round(r*100),onChange:p,inputProps:{step:1,min:0,max:100,style:{appearance:"textfield"},"data-testid":"opacity-slider"},InputProps:{endAdornment:t.jsxs(o.InputAdornment,{position:"end",sx:{margin:0},children:[" ","%"]})}})]})})]})}function ot({title:e,visible:n}){const i=u.useRef(null),[r,s]=u.useState(!1);u.useLayoutEffect(()=>{if(n&&i.current){const{offsetWidth:a,scrollWidth:p}=i.current;s(a<p)}},[e,n]);const l=t.jsx(j.Typography,{ref:i,color:n?"textPrimary":"textSecondary",variant:"caption",weight:"regular",component:"p",noWrap:!0,my:.25,textTransform:"none",children:e});return r?t.jsx(o.Tooltip,{title:e,children:l}):l}var ce=(e=>(e.CATEGORY="category",e.ICON="icon",e.CONTINUOUS_RAMP="continuous_ramp",e.BINS="bins",e.PROPORTION="proportion",e))(ce||{});const qe=20;function an({legend:e}){const{labels:n=[],colors:i=[],isStrokeColor:r=!1,customMarkers:s,maskedMarkers:l=!0}=e,a=Me.getPalette(i,n.length),p=n.length>qe,c=Z.useIntl(),g=j.useImperativeIntl(c);return t.jsxs(t.Fragment,{children:[t.jsx(ln,{"data-testid":"categories-legend",children:n.slice(0,qe).map((h,d)=>t.jsx(ds,{label:String(h),color:a[d%a.length],icon:s&&Array.isArray(s)?s[d]:s,maskedIcon:l,isStrokeColor:r},`${h}${d}`))}),p&&t.jsx(j.Typography,{variant:"caption",color:"textSecondary",component:"div",py:2,children:g.formatMessage({id:"c4r.widgets.legend.maxCategories"},{n:qe})})]})}const ls=({isMax:e,color:n,isStrokeColor:i,theme:r})=>({border:"2px solid transparent","&::after":{position:"absolute",display:e?"block":"none",content:'""',width:r.spacing(2),height:r.spacing(2),border:`2px solid ${r.palette.grey[900]}`,transform:"translate(-30%, -30%)",borderRadius:"50%",boxSizing:"content-box"},...i?{borderColor:n}:{backgroundColor:n}}),as=({icon:e,color:n,maskedIcon:i})=>({maskRepeat:"no-repeat",maskSize:"cover",backgroundRepeat:"no-repeat",backgroundSize:"cover",...i?{backgroundColor:n,maskImage:`url(${e})`,WebkitMaskImage:`url(${e})`}:{backgroundColor:"rgba(0,0,0,0)",backgroundImage:`url(${e})`}}),cs=o.styled(o.Box,{shouldForwardProp:e=>e!=="icon"&&e!=="maskedIcon"&&e!=="color"&&e!=="isStrokeColor"})(({icon:e,maskedIcon:n,color:i,isStrokeColor:r,theme:s})=>({whiteSpace:"nowrap",display:"block",width:s.spacing(1.5),height:s.spacing(1.5),flexShrink:"0",borderRadius:"50%",position:"relative",border:"2px solid transparent",...e?as({icon:e,color:i,maskedIcon:n}):ls({color:i,isStrokeColor:r,theme:s})}));function ds({label:e,isStrokeColor:n,color:i="#000",icon:r,maskedIcon:s}){return t.jsxs(o.Box,{component:"li",sx:{display:"flex",alignItems:"center"},children:[t.jsx(cs,{className:"marker",mr:1.5,component:"span",icon:r,maskedIcon:s,isStrokeColor:n,color:i}),t.jsx(ot,{title:e,visible:!0})]})}const Ne=6,We={0:12,1:9,2:6,3:3},us=o.styled(o.Box,{shouldForwardProp:e=>e!=="index"})(({index:e=0,theme:n})=>{const i=n.spacing(We[e]),r=n.spacing(We[e]);return{border:`solid 1px ${n.palette.divider}`,backgroundColor:n.palette.background.default,borderRadius:"50%",position:"absolute",right:0,bottom:0,width:i,height:r}}),ps=o.styled(o.Box)(({theme:{spacing:e}})=>({display:"flex",justifyContent:"flex-end",flexShrink:0,position:"relative",width:e(We[0]),height:e(We[0])})),gs=o.styled(o.Box)(({theme:{spacing:e}})=>({display:"flex",gap:e(1),alignItems:"stretch",justifyContent:"stretch",padding:e(2,0)})),hs=o.styled(o.Box)(()=>({display:"flex",flexDirection:"column",justifyContent:"space-around",gap:1,flexGrow:1,flexShrink:1}));function cn({legend:e}){const n=Z.useIntl(),i=j.useImperativeIntl(n),r=e.showMinMax??!0,{min:s,max:l,error:a}=fs(e),[p,c]=a?[0,0]:xs(s,l);return t.jsxs(gs,{"data-testid":"proportion-legend",children:[t.jsx(ps,{children:[...Array(4)].map((g,h)=>t.jsx(us,{index:h,component:"span"},h))}),t.jsx(hs,{children:a?t.jsx(o.Box,{maxWidth:240,children:t.jsx(j.Typography,{variant:"overline",children:"You need to specify valid numbers for the labels property"})}):t.jsxs(t.Fragment,{children:[t.jsxs(j.Typography,{variant:"overline",color:"textSecondary",children:[r&&i.formatMessage({id:"c4r.widgets.legend.max"})+": ",n.formatNumber(l,{maximumSignificantDigits:Ne})]}),t.jsx(j.Typography,{variant:"overline",color:"textSecondary",children:n.formatNumber(c,{maximumSignificantDigits:Ne})}),t.jsx(j.Typography,{variant:"overline",color:"textSecondary",children:n.formatNumber(p,{maximumSignificantDigits:Ne})}),t.jsxs(j.Typography,{variant:"overline",color:"textSecondary",children:[r&&i.formatMessage({id:"c4r.widgets.legend.min"})+": ",n.formatNumber(s,{maximumSignificantDigits:Ne})]})]})})]})}function dn({labels:e}){let n=e==null?void 0:e[e.length-1],i=e==null?void 0:e[0];return Number.isFinite(i)||(i=parseInt(String(i),10)),Number.isFinite(n)||(n=parseInt(String(n),10)),[i,n]}function fs(e){let n=!1;const[i,r]=dn(e);return(Number.isNaN(i)||Number.isNaN(r))&&(n=!0),{min:i,max:r,error:n}}function xs(e,n){const i=(n-e)/3;return[e+i,n-i]}function un({legend:e}){const{labels:n=[],icons:i=[]}=e;return t.jsx(ln,{"data-testid":"icon-legend",children:n.map((r,s)=>t.jsxs(ns,{children:[t.jsx(os,{children:t.jsx("img",{src:i[s],alt:r,width:"auto",height:j.ICON_SIZE_MEDIUM})}),t.jsx(ot,{visible:!0,title:r})]},r))})}function ms(e){return typeof e[0]=="object"&&"label"in e[0]}function Qe({isContinuous:e=!1,legend:n}){const{labels:i=[],colors:r=[],showMinMax:s=!0}=n,l=Me.getPalette(r,!i.length||e?2:i.length+1),a=ms(i),p=a?i.map(({value:m})=>m):i,c=a?i.map(({label:m})=>m):i,[g,h]=dn({labels:p}),d=Number.isNaN(g)||Number.isNaN(h);let y=c[c.length-1],f=c[0];return!e&&s&&(f="< "+f,y="≥ "+y),t.jsx(o.Box,{py:2,"data-testid":"ramp-legend",children:d?t.jsx(o.Box,{maxWidth:240,children:t.jsx(j.Typography,{variant:"overline",children:"You need to specify valid numbers for the labels property"})}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{display:"flex",pb:1,children:e?t.jsx(ys,{"data-testid":"step-continuous",palette:l}):t.jsx(js,{palette:l,labels:c,max:y,min:f})}),t.jsxs(o.Box,{display:"flex",justifyContent:"space-between",children:[t.jsx(j.Typography,{variant:"overlineDelicate",color:"textSecondary",children:f}),t.jsx(j.Typography,{variant:"overlineDelicate",color:"textSecondary",children:y})]})]})})}const ys=o.styled(o.Box,{shouldForwardProp:e=>e!=="palette"})(({palette:e,theme:n})=>({display:"block",flexGrow:1,height:n.spacing(1),borderRadius:n.spacing(.5),background:`linear-gradient(to right, ${e.join()})`})),vs=o.styled(o.Box,{shouldForwardProp:e=>e!=="color"})(({color:e,theme:n})=>({display:"block",flexGrow:1,height:n.spacing(1),backgroundColor:e,"&:first-of-type":{borderRadius:n.spacing(.5,0,0,.5)},"&:last-of-type":{borderRadius:n.spacing(0,.5,.5,0)}}));function js({labels:e=[],palette:n=[],max:i,min:r}){const s=e.length?[r,...e]:[r,i];return t.jsx(t.Fragment,{children:s.map((l,a)=>{const p=a===0?r:a===s.length-1?i:`${l} - ${s[a+1]}`;return t.jsx(o.Tooltip,{title:p,children:t.jsx(vs,{"data-testid":"step-discontinuous",color:n[a]})},a)})})}const ws={[ce.CATEGORY]:an,[ce.PROPORTION]:cn,[ce.ICON]:un,[ce.BINS]:e=>t.jsx(Qe,{...e,isContinuous:!1}),[ce.CONTINUOUS_RAMP]:e=>t.jsx(Qe,{...e,isContinuous:!0})};function bs({legend:e}){const n=Z.useIntl(),i=j.useImperativeIntl(n);return e.select||!e.type?null:t.jsxs(j.Typography,{variant:"body2",color:"textSecondary",component:"p",children:[e.type," ",i.formatMessage({id:"c4r.widgets.legend.notSupported"}),"."]})}function Ss(e){return e.type===ce.PROPORTION?"c4r.widgets.legend.subtitles.proportion":e.type===ce.ICON||e.customMarkers?"c4r.widgets.legend.subtitles.icon":e.isStrokeColor?"c4r.widgets.legend.subtitles.strokeColor":"c4r.widgets.legend.subtitles.color"}function ks({layer:e,legend:n,customLegendTypes:i,onChangeSelection:r}){var h;const s=Z.useIntl(),l=j.useImperativeIntl(s),a=n.type,c=ws[a]??i[a]??bs,g=((h=n.select)==null?void 0:h.options)??[];return t.jsxs(o.Box,{component:"li","data-testid":"legend-layer-variable",px:2,children:[n.attr?t.jsxs(o.Box,{pb:1,children:[t.jsx(j.Typography,{gutterBottom:!0,variant:"overlineDelicate",color:"textSecondary",component:"p",children:l.formatMessage({id:Ss(n)})}),t.jsx(j.Typography,{variant:"caption",component:"p",children:n.attr})]}):null,n.select?t.jsxs(o.Box,{pb:1,children:[t.jsx(j.Typography,{variant:"caption",weight:"medium",component:"p",children:n.select.label}),t.jsx(o.Select,{"data-testid":"legend-layer-variable-select",name:"legend-select",value:n.select.value,renderValue:d=>{var y;return((y=g.find(f=>f.value===d))==null?void 0:y.label)??d},onChange:d=>r(d.target.value),MenuProps:{transformOrigin:{vertical:"bottom",horizontal:"left"},anchorOrigin:{vertical:"top",horizontal:"left"},PaperProps:{style:{maxHeight:240}}},children:g.map(d=>t.jsx(o.MenuItem,{value:d.value,children:t.jsx(o.ListItemText,{primary:d.label})},d.value))})]}):null,t.jsx(c,{layer:e,legend:n})]})}const Is={};function pn(e){return e?Array.isArray(e)?e.every(n=>pn(n)):!e.select&&!e.type:!0}function Mt({customLegendTypes:e=Is,layer:n,onChangeCollapsed:i,onChangeOpacity:r,onChangeVisibility:s,onChangeSelection:l,maxZoom:a=21,minZoom:p=0,currentZoom:c=0}){const g=Z.useIntl(),h=j.useImperativeIntl(g),d=u.useRef(null),[y,f]=u.useState(!1),m=n.id,v=n.title,x=n.visible??!0,b=n.switchable??!0,S=n.collapsed??!1,k=(n.collapsible??!0)&&!pn(n.legend),T=n.opacity??1,w=n.showOpacityControl??!0,C=x&&!S,M=C?t.jsx(ee.ExpandLess,{}):t.jsx(ee.ExpandMore,{}),D=(n==null?void 0:n.minZoom)!==void 0||(n==null?void 0:n.maxZoom)!==void 0,E=n.minZoom??p,L=n.maxZoom??a,P=D&&(E>p||L<a),N=c<E||c>L,V=Ts({intl:h,minZoom:p,maxZoom:a,layerMinZoom:E,layerMaxZoom:L}),_=n.helperText??(P?V:""),A=u.useMemo(()=>n.legend?Array.isArray(n.legend)?n.legend:[n.legend]:[],[n.legend]);return n.legend?t.jsxs(is,{"data-testid":"legend-layer","aria-label":v,children:[t.jsxs(Jr,{ref:d,children:[k&&t.jsx(o.IconButton,{size:"small","aria-label":h.formatMessage({id:S?"c4r.widgets.legend.expand":"c4r.widgets.legend.collapse"}),disabled:!x,onClick:()=>i({id:m,collapsed:!S}),children:M}),t.jsxs(rs,{children:[t.jsx(ot,{visible:x,title:v??""}),P&&t.jsx(o.Tooltip,{title:h.formatMessage({id:"c4r.widgets.legend.zoomLevelTooltip"}),children:t.jsxs(j.Typography,{color:x?"textPrimary":"textSecondary",variant:"caption",component:"p",children:[h.formatMessage({id:"c4r.widgets.legend.zoomLevel"})," ",n.minZoom," - ",n.maxZoom]})})]}),w&&x&&!S&&t.jsx(ss,{menuRef:d,open:y,toggleOpen:f,opacity:T,onChange:$=>r({id:m,opacity:$})}),b&&t.jsx(o.Tooltip,{title:h.formatMessage({id:x?"c4r.widgets.legend.hideLayer":"c4r.widgets.legend.showLayer"}),children:t.jsx(o.IconButton,{size:"small",onClick:()=>s({id:m,collapsed:x?S:!1,visible:!x}),children:x?t.jsx(ee.VisibilityOutlined,{}):t.jsx(ee.VisibilityOffOutlined,{})})})]}),t.jsxs(o.Collapse,{unmountOnExit:!0,timeout:100,in:C,children:[t.jsx(ts,{"data-testid":"legend-layer-variable-list",opacity:N?.5:1,children:A.map(($,I)=>t.jsx(ks,{legend:$,layer:n,customLegendTypes:e,onChangeSelection:O=>l({id:m,index:I,selection:O})},`${$.type}-${I}`))}),_&&t.jsx(j.Typography,{variant:"caption",color:"textSecondary",component:"div",p:2,children:t.jsx("div",{dangerouslySetInnerHTML:{__html:_}})})]})]}):null}function Ts({intl:e,minZoom:n,maxZoom:i,layerMinZoom:r,layerMaxZoom:s}){const l=e.formatMessage({id:"c4r.widgets.legend.and"}),a=e.formatMessage({id:"c4r.widgets.legend.lowerThan"}),p=e.formatMessage({id:"c4r.widgets.legend.greaterThan"}),c=e.formatMessage({id:"c4r.widgets.legend.zoomNote"}),g=s<i?`${a} ${s}`:"",h=r>n?`${p} ${r}`:"",d=[g,h].filter(Boolean).join(` ${l} `);return d?`${c} ${d}`:""}const Ms={},Ie=()=>{},Cs=[];function As({customLegendTypes:e=Ms,layers:n=Cs,collapsed:i=!1,onChangeCollapsed:r=Ie,onChangeVisibility:s=Ie,onChangeOpacity:l=Ie,onChangeLegendRowCollapsed:a=Ie,onChangeSelection:p=Ie,title:c="Layers",maxZoom:g=20,minZoom:h=0,currentZoom:d,isMobile:y,sx:f}){const m=Z.useIntl(),v=j.useImperativeIntl(m),x=t.jsxs(Zr,{collapsed:i,children:[t.jsx(j.Typography,{variant:"caption",flexGrow:1,children:c}),t.jsx(o.Tooltip,{title:v.formatMessage({id:"c4r.widgets.legend.close"}),children:t.jsx(o.IconButton,{size:"small",onClick:()=>r(!0),children:t.jsx(ee.Close,{})})})]}),b=t.jsx(o.Tooltip,{title:v.formatMessage({id:"c4r.widgets.legend.open"}),children:t.jsx(o.IconButton,{"aria-label":c,onClick:()=>r(!1),children:t.jsx(ee.LayersOutlined,{})})});return t.jsx(Xr,{sx:f,elevation:3,collapsed:i||!!y,children:y?t.jsxs(t.Fragment,{children:[b,t.jsxs(o.Drawer,{anchor:"bottom",open:!i,onClose:()=>r(!0),children:[x,t.jsx(Tt,{children:n.map(S=>t.jsx(Mt,{layer:S,onChangeCollapsed:a,onChangeOpacity:l,onChangeVisibility:s,onChangeSelection:p,maxZoom:g,minZoom:h,currentZoom:d,customLegendTypes:e},S.id))})]})]}):t.jsxs(t.Fragment,{children:[i?b:x,t.jsx(Tt,{width:i?0:void 0,children:t.jsx(o.Collapse,{unmountOnExit:!0,in:!i,timeout:500,children:n.map(S=>t.jsx(Mt,{layer:S,onChangeCollapsed:a,onChangeOpacity:l,onChangeVisibility:s,onChangeSelection:p,maxZoom:g,minZoom:h,currentZoom:d,customLegendTypes:e},S.id))})})]})})}function Ct({color:e=void 0,children:n}){return n?t.jsx(o.Box,{mt:.5,children:t.jsx(j.Typography,{component:"div",variant:"caption",color:e??"inherit",style:{fontWeight:"normal"},children:n})}):t.jsx(o.Box,{mt:-1})}function Es({title:e="No data available",body:n="There are no results for the combination of filters applied to your data. Try tweaking your filters, or zoom and pan the map to adjust the Map View.",severity:i=void 0,...r}){return i?t.jsx(bn.Alert,{title:e,severity:i,...r,children:t.jsx(Ct,{children:n})}):t.jsxs(o.Box,{...r,children:[e&&t.jsx(j.Typography,{variant:"body2",children:e}),t.jsx(Ct,{color:"textSecondary",children:n})]})}const Bs=o.styled(o.Box,{shouldForwardProp:e=>e!=="margin"})(({theme:e,margin:n})=>({margin:0,position:"relative",maxWidth:"100%",padding:n??e.spacing(2,2.5)})),Ps=o.styled(o.LinearProgress)(({theme:e})=>({position:"absolute",top:0,left:0,width:"100%",height:e.spacing(.25)})),Ls=o.styled(o.Grid,{shouldForwardProp:e=>e!=="expanded"})(({theme:e,expanded:n=!0})=>({display:"flex",flexDirection:"row",alignItems:"flex-start",justifyContent:"space-between",width:"100%",...n?{minHeight:e.spacing(3)}:{height:e.spacing(3)},padding:0})),Ds=o.styled(o.Button,{shouldForwardProp:e=>e!=="expandable"})(({theme:e,expandable:n=!0})=>({flex:1,padding:0,alignItems:"flex-start",justifyContent:"flex-start",height:"auto",minHeight:"auto",marginBottom:e.spacing(1),cursor:n?"pointer":"default","& .MuiButton-startIcon":{marginTop:"3px",marginRight:e.spacing(1)},"&:hover":{background:"none"}})),gn=({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",width:e.spacing(3),height:e.spacing(3),color:e.palette.text.secondary}),Ns=o.styled(ee.ExpandLess)(({theme:e})=>gn({theme:e})),Os=o.styled(ee.ExpandMore)(({theme:e})=>gn({theme:e})),$s=o.styled(o.Typography,{shouldForwardProp:e=>e!=="expanded"})(({expanded:e=!0})=>({wordBreak:"break-word",overflow:"hidden",...e&&{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},...!e&&{whiteSpace:"nowrap",textOverflow:"ellipsis"}})),Rs=o.styled(o.Grid)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1),marginRight:e.spacing(-.5),marginLeft:e.spacing(1)})),At=o.styled(o.IconButton)(({theme:e})=>({color:e.palette.text.secondary})),Fs=o.styled(o.Menu)(({theme:e})=>({".MuiPaper-root":{marginTop:e.spacing(5),maxHeight:e.spacing(21),minWidth:e.spacing(16)}})),Et=[],Ws=t.jsx(ee.MoreVert,{});function _s({title:e,actions:n=Et,options:i=Et,optionsIcon:r=Ws,children:s,contentProps:l,disabled:a=!1,expandable:p=!0,expanded:c=!0,onExpandedChange:g,footer:h,headerItems:d,isLoading:y=!1,margin:f}){const m=u.createRef(),[v,x]=u.useState(!0),b=c!==void 0&&g!==void 0,S=p!==!1?b?c:v:!0,k=b?g:x,[T,w]=u.useState(null),C=!!T,M=()=>{p&&k(!S)},D=N=>w(N.currentTarget),E=()=>w(null);function L(N){N&&N(),E()}const P=N=>t.jsx(At,{"aria-label":N.label,onClick:N.action,size:"small",children:N.icon},N.id);return a?s?t.jsx(t.Fragment,{children:s}):null:t.jsxs(Bs,{margin:f,component:"section","aria-label":e,children:[y?t.jsx(Ps,{}):null,t.jsxs(Ls,{container:!0,expanded:c,children:[t.jsx(Ds,{expandable:p,startIcon:p&&t.jsx(o.Icon,{children:S?t.jsx(Ns,{}):t.jsx(Os,{})}),onClick:M,tabIndex:p?0:-1,children:t.jsx(o.Tooltip,{title:e,children:t.jsx($s,{expanded:c,align:"left",variant:"subtitle1",children:e})})}),t.jsxs(Rs,{item:!0,children:[d,n.length>0&&n.map(N=>N.tooltip?t.jsx(o.Tooltip,{title:N.tooltip.text,placement:N.tooltip.placement??"top",children:P(N)},N.id):P(N)),i.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(At,{"aria-label":"options","aria-controls":"options-menu","aria-haspopup":"true",onClick:D,size:"small",children:r}),t.jsx(Fs,{id:"options-menu",elevation:8,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:T,keepMounted:!0,open:C,onClose:E,children:i.map(N=>t.jsx(o.MenuItem,{selected:N.selected,onClick:()=>L(N.action),children:N.name},N.id))})]})]})]}),t.jsx(o.Collapse,{ref:m,in:S,timeout:"auto",unmountOnExit:!0,children:t.jsxs(o.Box,{...l,children:[t.jsx(o.Box,{pt:1,children:s}),h??t.jsx(o.Box,{children:h})]})})]})}exports.BarWidgetUI=Dn;exports.CategoryWidgetUI=Vn;exports.ComparativeCategoryWidgetUI=Sr;exports.ComparativeFormulaWidgetUI=Pr;exports.ComparativePieWidgetUI=Fr;exports.FeatureSelectionUIDropdown=on;exports.FeatureSelectionUIGeometryChips=rn;exports.FeatureSelectionUIToggleButton=nn;exports.FeatureSelectionWidgetUI=Kr;exports.FormulaWidgetUI=Xn;exports.GroupDateTypes=ae;exports.HistogramWidgetUI=ro;exports.LEGEND_TYPES=ce;exports.LegendCategories=an;exports.LegendIcon=un;exports.LegendProportion=cn;exports.LegendRamp=Qe;exports.LegendWidgetUI=As;exports.NoDataAlert=Es;exports.PieWidgetUI=Do;exports.RangeWidgetUI=Ho;exports.ScatterPlotWidgetUI=Qo;exports.TIME_SERIES_CHART_TYPES=Ge;exports.TableWidgetUI=di;exports.TimeSeriesProvider=Yt;exports.TimeSeriesWidgetUI=tr;exports.WrapperWidgetUI=_s;exports.useTimeSeriesContext=ze;exports.useTimeSeriesInteractivity=Vt;
|
|
32
|
+
`.trim()}const Or=e=>e,$r=()=>{},De=[],Rr="260px";function Fr({names:e=De,data:n=De,labels:i=De,colors:r=De,height:s=Rr,animation:l=!0,formatter:a=Or,tooltipFormatter:p=Nr,selectedCategories:c=[],onCategorySelected:g=$r,isLoading:h=!1}){const d=o.useTheme(),y=u.useRef(),f=u.useMemo(()=>n.map((b,S)=>Dr(b,r[S],i[S],d,c)),[n,r,i,d,c]),m=u.useMemo(()=>{const b=f.length>1;let S;p&&(S=E=>p(E,a,b));const I={trigger:"item",show:!0,backgroundColor:d.palette.black[90],textStyle:{color:d.palette.common.white},confine:!0,borderWidth:0,formatter:S},w={data:b?f.map((E,L)=>e[L]):(f[0]??[]).map(E=>E.name),selectedMode:!1,type:"scroll",left:j.SPACING,bottom:j.SPACING*-.5,itemGap:j.SPACING*3,icon:"circle",itemWidth:j.SPACING,itemHeight:j.SPACING,textStyle:{...d.typography.overline,color:d.palette.text.primary,fontWeight:400,lineHeight:1,verticalAlign:"bottom",padding:[0,0,0,j.SPACING*.5]},inactiveColor:d.palette.text.disabled,pageIcons:{horizontal:["path://M15.41 7.41 14 6 8 12 14 18 15.41 16.59 10.83 12z","path://M9 16.59 13.3265857 12 9 7.41 10.3319838 6 16 12 10.3319838 18z"]},pageIconSize:j.SPACING*1.5,pageIconColor:d.palette.text.secondary,pageIconInactiveColor:d.palette.text.disabled,pageTextStyle:{fontFamily:d.typography.overline.fontFamily,fontSize:j.SPACING*1.5,lineHeight:j.SPACING*1.75,fontWeight:400,color:d.palette.text.primary}},C={formatter:({name:E,percent:L})=>`{per|${a(L)}%}
|
|
33
|
+
{b|${E}}`,position:"center",rich:{b:{fontFamily:d.typography.overline.fontFamily,fontSize:j.SPACING*1.75,lineHeight:j.SPACING*1.75,fontWeight:400,color:d.palette.text.primary},per:{...d.typography.overline,fontSize:j.SPACING*3,lineHeight:j.SPACING*4.5,fontWeight:600,color:d.palette.text.primary}}},M=f.map((E,L)=>{var P;return{type:"pie",name:e[L],itemStyle:{color:(P=E[0])==null?void 0:P.color},animation:l,data:E.map(N=>({...N,itemStyle:{color:N.color}})),radius:L===0?["75%","90%"]:["56%","72%"],selectedOffset:0,hoverOffset:5,bottom:j.SPACING*2.5,avoidLabelOverlap:!0,label:{show:!1,...C},emphasis:{label:{show:!0,formatter:C.formatter,rich:C.rich}}}});return{grid:{left:0,top:0,right:0,bottom:0},tooltip:I,legend:w,series:M}},[d,e,l,f,a,p]),v={mouseover:(b,S)=>{f.length===1&&(b.seriesIndex!==0||b.dataIndex!==0)&&S.dispatchAction({type:"downplay",seriesIndex:0,dataIndex:0})},mouseout:(b,S)=>{f.length===1&&S.dispatchAction({type:"highlight",seriesIndex:0,dataIndex:0})},click:b=>{const I=f[b.seriesIndex][b.dataIndex].key,T=c.includes(I),w=new Set(c);T?w.delete(I):w.add(I);const C=f[0].length;let M=Array.from(w);M.length===C&&(M=[]),g(M)}};u.useEffect(()=>{y.current&&y.current.dispatchAction({type:f.length===1?"highlight":"downplay",seriesIndex:0,dataIndex:0})},[f]);function x(b){y.current=b}return f.length?h?t.jsx(Ft,{height:s}):t.jsx(ye,{onChartReady:x,notMerge:!0,option:m,onEvents:v,style:{maxHeight:s,width:"100%"}}):null}const Wr=()=>{};function nn({icon:e,hoverTooltip:n,clickTooltip:i,enabled:r,onEnabledChange:s=Wr,tooltipPlacement:l="bottom"}){const[a,p]=u.useState(!1),[c,g]=u.useState(r);u.useEffect(()=>{g(r)},[r]),u.useEffect(()=>{if(r){const d=y=>{y.key==="Escape"&&s&&s(!1)};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}}},[r,s]);const h=c?i:n;return t.jsx(o.ClickAwayListener,{onClickAway:()=>g(!1),children:t.jsx(o.Tooltip,{title:h,placement:l,open:a,onOpen:()=>p(!0),onClose:()=>{c||p(!1)},children:t.jsx(o.ToggleButton,{value:"selectedMode",selected:r,onClick:()=>s&&s(!r),children:e})})})}const _r=o.styled(o.IconButton,{shouldForwardProp:e=>e!=="isOpen"})(({isOpen:e,theme:n})=>({color:n.palette.text.secondary,width:n.spacing(3),transform:`rotate(${e?"180":"0"}deg)`,backgroundColor:e?n.palette.action.hover:void 0})),Gr=o.styled(o.MenuItem,{shouldForwardProp:e=>e!=="disabled"})(({disabled:e,theme:n})=>({...e&&{pointerEvents:"none",color:n.palette.text.disabled}})),Hr=o.styled(o.MenuItem)(()=>({"&.Mui-disabled":{opacity:1}})),zr=()=>{};function on({selectionModes:e,editModes:n,selectedMode:i,onSelectMode:r=zr,enabled:s,tooltipPlacement:l="bottom",tooltipText:a="",menuHeaderText:p="",editDisabled:c}){const g=o.useTheme(),[h,d]=u.useState(null),y=!!h,f=I=>d(I.currentTarget),m=()=>d(null),v=I=>{r&&r(I),m()},x=!!e.length&&!!n.length,b=I=>n.some(T=>T.id===I.id);function S(I){return t.jsx(Gr,{selected:s&&i===I.id,onClick:()=>v(I.id),disabled:c&&b(I),children:t.jsxs(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[I.icon,t.jsx(o.Box,{ml:2,children:t.jsx(j.Typography,{variant:"body2",color:"inherit",children:o.capitalize(I.label)})})]})},I.id)}return t.jsxs(t.Fragment,{children:[t.jsx(o.Tooltip,{title:a,placement:l,children:t.jsx(_r,{id:"feature-selection-menu-button","aria-controls":"feature-selection-menu","aria-haspopup":"true","aria-expanded":y?"true":void 0,onClick:f,isOpen:y,children:t.jsx(ee.KeyboardArrowDown,{})})}),t.jsxs(o.Menu,{id:"feature-selection-menu",style:{zIndex:g.zIndex.tooltip+1},anchorEl:h,open:y,onClose:m,MenuListProps:{"aria-labelledby":"feature-selection-menu-button"},children:[p&&t.jsx(Hr,{disabled:!0,children:t.jsx(j.Typography,{variant:"caption",color:"textSecondary",children:p})}),!!e.length&&e.map(S),x&&t.jsx(o.Divider,{sx:{margin:({spacing:I})=>I(1,0)}}),!!n.length&&n.map(S)]})]})}const Yr=o.styled(o.List)(({theme:e})=>({display:"flex",alignItems:"center",marginLeft:e.spacing(1.5),padding:e.spacing(.5),overflowX:"auto",maxWidth:"100%",scrollbarWidth:"none",msOverflowStyle:"none","&::-webkit-scrollbar":{display:"none"}})),Vr=()=>{};function rn({features:e,onSelectGeometry:n=Vr,onDeleteGeometry:i,chipTooltip:r,disabledChipTooltip:s,size:l="medium",tooltipPlacement:a="bottom",chipLabel:p}){const c=Z.useIntl(),g=j.useImperativeIntl(c);function h(m){return m==="MultiPoint"?g.formatMessage({id:"c4r.widgets.featureSelection.point"}):m==="MultiLineString"?g.formatMessage({id:"c4r.widgets.featureSelection.lineString"}):m==="MultiPolygon"||m==="Polygon"||m==="GeometryCollection"?g.formatMessage({id:"c4r.widgets.featureSelection.polygon"}):m}function d(m,v){var b;const x=h(m.geometry.type);return p||((b=m.properties)==null?void 0:b.name)||`${x} ${v+1}`}const[y,f]=u.useState(!1);return t.jsx(o.Box,{sx:{overflowX:"auto"},children:t.jsx(Yr,{sx:{gap:l==="small"?.5:1},children:e.map((m,v)=>{var T,w;const x=(T=m.properties)==null?void 0:T.disabled,b=(w=m.properties)==null?void 0:w.invalid;let S=r;x&&(S=s||r),b&&(S=g.formatMessage({id:"c4r.widgets.featureSelection.invalid"})),y&&(S=g.formatMessage({id:"c4r.widgets.featureSelection.remove"}));let I="secondary";return x&&(I="default"),b&&(I="error"),t.jsx(o.ListItem,{disablePadding:!0,children:t.jsx(o.Tooltip,{disableHoverListener:x?!s:!r,title:S,placement:a,children:t.jsx(o.Chip,{size:l,label:d(m,v),color:I,onClick:()=>n(m),onDelete:i?()=>i(m):void 0,icon:b?t.jsx(ee.ErrorOutline,{color:"error"}):void 0,deleteIcon:t.jsx(ee.Cancel,{onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1)})})})},v)})})})}const Ur=o.styled(o.Paper)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",maxHeight:e.spacing(5),padding:e.spacing(.5)})),qr=[];function Xr({selectionModes:e,editModes:n=qr,selectedMode:i,onSelectMode:r,enabled:s=!1,onEnabledChange:l,geometry:a,onSelectGeometry:p,onDeleteGeometry:c,tooltipPlacement:g="bottom",size:h="medium",chipLabel:d}){const y=Z.useIntl(),f=j.useImperativeIntl(y),m=u.useMemo(()=>e.map(T=>({...T,label:f.formatMessage({id:`c4r.widgets.featureSelection.${kt(T.id)}`})})),[e,f]),v=u.useMemo(()=>n.map(T=>({...T,label:f.formatMessage({id:`c4r.widgets.featureSelection.${kt(T.id)}`})})),[n,f]),x=u.useMemo(()=>{const w=[...m.map(C=>({...C,isEdit:!1})),...v.map(C=>({...C,isEdit:!0}))].find(C=>C.id===i);if(!w)throw new Error(`Selected mode "${i}" not supported`);return w},[v,m,i]),b=o.capitalize((x==null?void 0:x.label)||""),S=x!=null&&x.isEdit?b:f.formatMessage({id:"c4r.widgets.featureSelection.selectTool"},{label:b}),I=x!=null&&x.isEdit?f.formatMessage({id:"c4r.widgets.featureSelection.clickToEdit"}):f.formatMessage({id:"c4r.widgets.featureSelection.clickToCreate"});return t.jsxs(Ur,{children:[t.jsx(nn,{icon:x==null?void 0:x.icon,hoverTooltip:S,clickTooltip:I,enabled:s,onEnabledChange:l,tooltipPlacement:g}),t.jsx(on,{selectionModes:m,editModes:v,selectedMode:i,onSelectMode:r,enabled:s,tooltipPlacement:g,tooltipText:f.formatMessage({id:"c4r.widgets.featureSelection.selectMode"}),menuHeaderText:f.formatMessage({id:"c4r.widgets.featureSelection.chooseSelectionMode"}),editDisabled:!a}),!!a&&t.jsx(rn,{features:[a],onSelectGeometry:p,onDeleteGeometry:c,disabledChipTooltip:f.formatMessage({id:"c4r.widgets.featureSelection.applyMask"}),chipTooltip:f.formatMessage({id:"c4r.widgets.featureSelection.clearMask"}),tooltipPlacement:g,size:h,chipLabel:d})]})}function kt(e){return e.charAt(0).toLowerCase()+e.slice(1)}const sn=240,Kr=o.styled(o.Paper,{shouldForwardProp:e=>e!=="collapsed"})(({theme:e,collapsed:n})=>({width:n?"min-content":sn,background:e.palette.background.paper,maxHeight:"calc(100% - 120px)",display:"flex",flexDirection:"column"})),Zr=o.styled("header",{shouldForwardProp:e=>e!=="collapsed"})(({theme:e,collapsed:n})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:e.spacing(1),paddingLeft:e.spacing(2),borderBottom:n?void 0:`1px solid ${e.palette.divider}`})),Jr=o.styled("header")(({theme:e})=>({padding:e.spacing(1.5),paddingRight:e.spacing(2),gap:e.spacing(.5),display:"flex",justifyContent:"space-between",position:"sticky",zIndex:2,top:0,background:e.palette.background.paper})),Qr=o.styled("div")(({theme:e})=>({display:"flex",gap:e.spacing(2),alignItems:"center",padding:e.spacing(1),minWidth:`calc(${sn}px - ${e.spacing(4)})`})),es=o.styled(o.TextField)(({theme:e})=>({display:"flex",width:e.spacing(7.5),flexShrink:0,"input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button":{WebkitAppearance:"none",margin:0}})),ts=o.styled("ul",{shouldForwardProp:e=>e!=="opacity"})(({theme:e,opacity:n})=>({opacity:n,margin:0,padding:0,display:"flex",flexDirection:"column",gap:e.spacing(1)})),ln=o.styled("ul")(({theme:e})=>({margin:0,padding:0,paddingBottom:e.spacing(1),display:"flex",flexDirection:"column"})),ns=o.styled("li")(()=>({display:"flex",alignItems:"center"})),os=o.styled("div")(({theme:e})=>({marginRight:e.spacing(1.5),width:j.ICON_SIZE_MEDIUM,height:j.ICON_SIZE_MEDIUM,"& img":{margin:"auto",display:"block"}})),Tt=o.styled(o.Box,{shouldForwardProp:e=>e!=="width"})(({width:e,theme:n})=>({width:e,overflow:"auto",maxHeight:`calc(100% - ${n.spacing(1.5)})`})),is=o.styled("section")(({theme:e})=>({"&:not(:first-of-type)":{borderTop:`1px solid ${e.palette.divider}`}})),rs=o.styled("div")(()=>({flexGrow:1,flexShrink:1,minWidth:0}));function ss({menuRef:e,open:n,toggleOpen:i,opacity:r,onChange:s}){const l=Z.useIntl(),a=j.useImperativeIntl(l);function p(c){const g=parseInt(c.target.value||"0"),h=Math.min(Math.max(g,0),100);s(h/100)}return t.jsxs(t.Fragment,{children:[t.jsx(o.Tooltip,{title:a.formatMessage({id:"c4r.widgets.legend.opacity"}),children:t.jsx(o.IconButton,{size:"small",color:n?"primary":"default",onClick:()=>i(!n),children:t.jsx(Te.SwatchSquare,{})})}),t.jsx(o.Popover,{open:n,onClose:()=>i(!1),anchorEl:e.current,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{root:{sx:{transform:"translate(-12px, 36px)"}}},children:t.jsxs(Qr,{children:[t.jsx(o.Slider,{value:r*100,onChange:(c,g)=>s(g/100),min:0,max:100,step:1}),t.jsx(es,{size:"small",type:"number",value:Math.round(r*100),onChange:p,inputProps:{step:1,min:0,max:100,style:{appearance:"textfield"},"data-testid":"opacity-slider"},InputProps:{endAdornment:t.jsxs(o.InputAdornment,{position:"end",sx:{margin:0},children:[" ","%"]})}})]})})]})}function ot({title:e,visible:n}){const i=u.useRef(null),[r,s]=u.useState(!1);u.useLayoutEffect(()=>{if(n&&i.current){const{offsetWidth:a,scrollWidth:p}=i.current;s(a<p)}},[e,n]);const l=t.jsx(j.Typography,{ref:i,color:n?"textPrimary":"textSecondary",variant:"caption",weight:"regular",component:"p",noWrap:!0,my:.25,textTransform:"none",children:e});return r?t.jsx(o.Tooltip,{title:e,children:l}):l}var ce=(e=>(e.CATEGORY="category",e.ICON="icon",e.CONTINUOUS_RAMP="continuous_ramp",e.BINS="bins",e.PROPORTION="proportion",e))(ce||{});const qe=20;function an({legend:e}){const{labels:n=[],colors:i=[],isStrokeColor:r=!1,customMarkers:s,maskedMarkers:l=!0}=e,a=Me.getPalette(i,n.length),p=n.length>qe,c=Z.useIntl(),g=j.useImperativeIntl(c);return t.jsxs(t.Fragment,{children:[t.jsx(ln,{"data-testid":"categories-legend",children:n.slice(0,qe).map((h,d)=>t.jsx(ds,{label:String(h),color:a[d%a.length],icon:s&&Array.isArray(s)?s[d]:s,maskedIcon:l,isStrokeColor:r},`${h}${d}`))}),p&&t.jsx(j.Typography,{variant:"caption",color:"textSecondary",component:"div",py:2,children:g.formatMessage({id:"c4r.widgets.legend.maxCategories"},{n:qe})})]})}const ls=({isMax:e,color:n,isStrokeColor:i,theme:r})=>({border:"2px solid transparent","&::after":{position:"absolute",display:e?"block":"none",content:'""',width:r.spacing(2),height:r.spacing(2),border:`2px solid ${r.palette.grey[900]}`,transform:"translate(-30%, -30%)",borderRadius:"50%",boxSizing:"content-box"},...i?{borderColor:n}:{backgroundColor:n}}),as=({icon:e,color:n,maskedIcon:i})=>({maskRepeat:"no-repeat",maskSize:"cover",backgroundRepeat:"no-repeat",backgroundSize:"cover",...i?{backgroundColor:n,maskImage:`url(${e})`,WebkitMaskImage:`url(${e})`}:{backgroundColor:"rgba(0,0,0,0)",backgroundImage:`url(${e})`}}),cs=o.styled(o.Box,{shouldForwardProp:e=>e!=="icon"&&e!=="maskedIcon"&&e!=="color"&&e!=="isStrokeColor"})(({icon:e,maskedIcon:n,color:i,isStrokeColor:r,theme:s})=>({whiteSpace:"nowrap",display:"block",width:s.spacing(1.5),height:s.spacing(1.5),flexShrink:"0",borderRadius:"50%",position:"relative",border:"2px solid transparent",...e?as({icon:e,color:i,maskedIcon:n}):ls({color:i,isStrokeColor:r,theme:s})}));function ds({label:e,isStrokeColor:n,color:i="#000",icon:r,maskedIcon:s}){return t.jsxs(o.Box,{component:"li",sx:{display:"flex",alignItems:"center"},children:[t.jsx(cs,{className:"marker",mr:1.5,component:"span",icon:r,maskedIcon:s,isStrokeColor:n,color:i}),t.jsx(ot,{title:e,visible:!0})]})}const Ne=6,We={0:12,1:9,2:6,3:3},us=o.styled(o.Box,{shouldForwardProp:e=>e!=="index"})(({index:e=0,theme:n})=>{const i=n.spacing(We[e]),r=n.spacing(We[e]);return{border:`solid 1px ${n.palette.divider}`,backgroundColor:n.palette.background.default,borderRadius:"50%",position:"absolute",right:0,bottom:0,width:i,height:r}}),ps=o.styled(o.Box)(({theme:{spacing:e}})=>({display:"flex",justifyContent:"flex-end",flexShrink:0,position:"relative",width:e(We[0]),height:e(We[0])})),gs=o.styled(o.Box)(({theme:{spacing:e}})=>({display:"flex",gap:e(1),alignItems:"stretch",justifyContent:"stretch",padding:e(2,0)})),hs=o.styled(o.Box)(()=>({display:"flex",flexDirection:"column",justifyContent:"space-around",gap:1,flexGrow:1,flexShrink:1}));function cn({legend:e}){const n=Z.useIntl(),i=j.useImperativeIntl(n),r=e.showMinMax??!0,{min:s,max:l,error:a}=fs(e),[p,c]=a?[0,0]:xs(s,l);return t.jsxs(gs,{"data-testid":"proportion-legend",children:[t.jsx(ps,{children:[...Array(4)].map((g,h)=>t.jsx(us,{index:h,component:"span"},h))}),t.jsx(hs,{children:a?t.jsx(o.Box,{maxWidth:240,children:t.jsx(j.Typography,{variant:"overline",children:"You need to specify valid numbers for the labels property"})}):t.jsxs(t.Fragment,{children:[t.jsxs(j.Typography,{variant:"overline",color:"textSecondary",children:[r&&i.formatMessage({id:"c4r.widgets.legend.max"})+": ",n.formatNumber(l,{maximumSignificantDigits:Ne})]}),t.jsx(j.Typography,{variant:"overline",color:"textSecondary",children:n.formatNumber(c,{maximumSignificantDigits:Ne})}),t.jsx(j.Typography,{variant:"overline",color:"textSecondary",children:n.formatNumber(p,{maximumSignificantDigits:Ne})}),t.jsxs(j.Typography,{variant:"overline",color:"textSecondary",children:[r&&i.formatMessage({id:"c4r.widgets.legend.min"})+": ",n.formatNumber(s,{maximumSignificantDigits:Ne})]})]})})]})}function dn({labels:e}){let n=e==null?void 0:e[e.length-1],i=e==null?void 0:e[0];return Number.isFinite(i)||(i=parseInt(String(i),10)),Number.isFinite(n)||(n=parseInt(String(n),10)),[i,n]}function fs(e){let n=!1;const[i,r]=dn(e);return(Number.isNaN(i)||Number.isNaN(r))&&(n=!0),{min:i,max:r,error:n}}function xs(e,n){const i=(n-e)/3;return[e+i,n-i]}function un({legend:e}){const{labels:n=[],icons:i=[]}=e;return t.jsx(ln,{"data-testid":"icon-legend",children:n.map((r,s)=>t.jsxs(ns,{children:[t.jsx(os,{children:t.jsx("img",{src:i[s],alt:r,width:"auto",height:j.ICON_SIZE_MEDIUM})}),t.jsx(ot,{visible:!0,title:r})]},r))})}function ms(e){return typeof e[0]=="object"&&"label"in e[0]}function Qe({isContinuous:e=!1,legend:n}){const{labels:i=[],colors:r=[],showMinMax:s=!0}=n,l=Me.getPalette(r,!i.length||e?2:i.length+1),a=ms(i),p=a?i.map(({value:m})=>m):i,c=a?i.map(({label:m})=>m):i,[g,h]=dn({labels:p}),d=Number.isNaN(g)||Number.isNaN(h);let y=c[c.length-1],f=c[0];return!e&&s&&(f="< "+f,y="≥ "+y),t.jsx(o.Box,{py:2,"data-testid":"ramp-legend",children:d?t.jsx(o.Box,{maxWidth:240,children:t.jsx(j.Typography,{variant:"overline",children:"You need to specify valid numbers for the labels property"})}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{display:"flex",pb:1,children:e?t.jsx(ys,{"data-testid":"step-continuous",palette:l}):t.jsx(js,{palette:l,labels:c,max:y,min:f})}),t.jsxs(o.Box,{display:"flex",justifyContent:"space-between",children:[t.jsx(j.Typography,{variant:"overlineDelicate",color:"textSecondary",children:f}),t.jsx(j.Typography,{variant:"overlineDelicate",color:"textSecondary",children:y})]})]})})}const ys=o.styled(o.Box,{shouldForwardProp:e=>e!=="palette"})(({palette:e,theme:n})=>({display:"block",flexGrow:1,height:n.spacing(1),borderRadius:n.spacing(.5),background:`linear-gradient(to right, ${e.join()})`})),vs=o.styled(o.Box,{shouldForwardProp:e=>e!=="color"})(({color:e,theme:n})=>({display:"block",flexGrow:1,height:n.spacing(1),backgroundColor:e,"&:first-of-type":{borderRadius:n.spacing(.5,0,0,.5)},"&:last-of-type":{borderRadius:n.spacing(0,.5,.5,0)}}));function js({labels:e=[],palette:n=[],max:i,min:r}){const s=e.length?[r,...e]:[r,i];return t.jsx(t.Fragment,{children:s.map((l,a)=>{const p=a===0?r:a===s.length-1?i:`${l} - ${s[a+1]}`;return t.jsx(o.Tooltip,{title:p,children:t.jsx(vs,{"data-testid":"step-discontinuous",color:n[a]})},a)})})}const ws={[ce.CATEGORY]:an,[ce.PROPORTION]:cn,[ce.ICON]:un,[ce.BINS]:e=>t.jsx(Qe,{...e,isContinuous:!1}),[ce.CONTINUOUS_RAMP]:e=>t.jsx(Qe,{...e,isContinuous:!0})};function bs({legend:e}){const n=Z.useIntl(),i=j.useImperativeIntl(n);return e.select||!e.type?null:t.jsxs(j.Typography,{variant:"body2",color:"textSecondary",component:"p",children:[e.type," ",i.formatMessage({id:"c4r.widgets.legend.notSupported"}),"."]})}function Ss(e){return e.type===ce.PROPORTION?"c4r.widgets.legend.subtitles.proportion":e.type===ce.ICON||e.customMarkers?"c4r.widgets.legend.subtitles.icon":e.isStrokeColor?"c4r.widgets.legend.subtitles.strokeColor":"c4r.widgets.legend.subtitles.color"}function Is({layer:e,legend:n,customLegendTypes:i,onChangeSelection:r}){var h;const s=Z.useIntl(),l=j.useImperativeIntl(s),a=n.type,c=ws[a]??i[a]??bs,g=((h=n.select)==null?void 0:h.options)??[];return t.jsxs(o.Box,{component:"li","data-testid":"legend-layer-variable",px:2,children:[n.attr?t.jsxs(o.Box,{pb:1,children:[t.jsx(j.Typography,{gutterBottom:!0,variant:"overlineDelicate",color:"textSecondary",component:"p",children:l.formatMessage({id:Ss(n)})}),t.jsx(j.Typography,{variant:"caption",component:"p",children:n.attr})]}):null,n.select?t.jsxs(o.Box,{pb:1,children:[t.jsx(j.Typography,{variant:"caption",weight:"medium",component:"p",children:n.select.label}),t.jsx(o.Select,{"data-testid":"legend-layer-variable-select",name:"legend-select",value:n.select.value,renderValue:d=>{var y;return((y=g.find(f=>f.value===d))==null?void 0:y.label)??d},onChange:d=>r(d.target.value),MenuProps:{transformOrigin:{vertical:"bottom",horizontal:"left"},anchorOrigin:{vertical:"top",horizontal:"left"},PaperProps:{style:{maxHeight:240}}},children:g.map(d=>t.jsx(o.MenuItem,{value:d.value,children:t.jsx(o.ListItemText,{primary:d.label})},d.value))})]}):null,t.jsx(c,{layer:e,legend:n})]})}const ks={};function pn(e){return e?Array.isArray(e)?e.every(n=>pn(n)):!e.select&&!e.type:!0}function Mt({customLegendTypes:e=ks,layer:n,onChangeCollapsed:i,onChangeOpacity:r,onChangeVisibility:s,onChangeSelection:l,maxZoom:a=21,minZoom:p=0,currentZoom:c=0}){const g=Z.useIntl(),h=j.useImperativeIntl(g),d=u.useRef(null),[y,f]=u.useState(!1),m=n.id,v=n.title,x=n.visible??!0,b=n.switchable??!0,S=n.collapsed??!1,I=(n.collapsible??!0)&&!pn(n.legend),T=n.opacity??1,w=n.showOpacityControl??!0,C=x&&!S,M=C?t.jsx(ee.ExpandLess,{}):t.jsx(ee.ExpandMore,{}),D=(n==null?void 0:n.minZoom)!==void 0||(n==null?void 0:n.maxZoom)!==void 0,E=n.minZoom??p,L=n.maxZoom??a,P=D&&(E>p||L<a),N=c<E||c>L,V=Ts({intl:h,minZoom:p,maxZoom:a,layerMinZoom:E,layerMaxZoom:L}),_=n.helperText??(P?V:""),B=u.useMemo(()=>n.legend?Array.isArray(n.legend)?n.legend:[n.legend]:[],[n.legend]);return n.legend?t.jsxs(is,{"data-testid":"legend-layer","aria-label":v,children:[t.jsxs(Jr,{ref:d,children:[I&&t.jsx(o.IconButton,{size:"small","aria-label":h.formatMessage({id:S?"c4r.widgets.legend.expand":"c4r.widgets.legend.collapse"}),disabled:!x,onClick:()=>i({id:m,collapsed:!S}),children:M}),t.jsxs(rs,{children:[t.jsx(ot,{visible:x,title:v??""}),P&&t.jsx(o.Tooltip,{title:h.formatMessage({id:"c4r.widgets.legend.zoomLevelTooltip"}),children:t.jsxs(j.Typography,{color:x?"textPrimary":"textSecondary",variant:"caption",component:"p",children:[h.formatMessage({id:"c4r.widgets.legend.zoomLevel"})," ",n.minZoom," - ",n.maxZoom]})})]}),w&&x&&!S&&t.jsx(ss,{menuRef:d,open:y,toggleOpen:f,opacity:T,onChange:$=>r({id:m,opacity:$})}),b&&t.jsx(o.Tooltip,{title:h.formatMessage({id:x?"c4r.widgets.legend.hideLayer":"c4r.widgets.legend.showLayer"}),children:t.jsx(o.IconButton,{size:"small",onClick:()=>s({id:m,collapsed:x?S:!1,visible:!x}),children:x?t.jsx(ee.VisibilityOutlined,{}):t.jsx(ee.VisibilityOffOutlined,{})})})]}),t.jsxs(o.Collapse,{unmountOnExit:!0,timeout:100,in:C,children:[t.jsx(ts,{"data-testid":"legend-layer-variable-list",opacity:N?.5:1,children:B.map(($,k)=>t.jsx(Is,{legend:$,layer:n,customLegendTypes:e,onChangeSelection:O=>l({id:m,index:k,selection:O})},`${$.type}-${k}`))}),_&&t.jsx(j.Typography,{variant:"caption",color:"textSecondary",component:"div",p:2,children:t.jsx("div",{dangerouslySetInnerHTML:{__html:_}})})]})]}):null}function Ts({intl:e,minZoom:n,maxZoom:i,layerMinZoom:r,layerMaxZoom:s}){const l=e.formatMessage({id:"c4r.widgets.legend.and"}),a=e.formatMessage({id:"c4r.widgets.legend.lowerThan"}),p=e.formatMessage({id:"c4r.widgets.legend.greaterThan"}),c=e.formatMessage({id:"c4r.widgets.legend.zoomNote"}),g=s<i?`${a} ${s}`:"",h=r>n?`${p} ${r}`:"",d=[g,h].filter(Boolean).join(` ${l} `);return d?`${c} ${d}`:""}const Ms={},ke=()=>{},Cs=[];function As({customLegendTypes:e=Ms,layers:n=Cs,collapsed:i=!1,onChangeCollapsed:r=ke,onChangeVisibility:s=ke,onChangeOpacity:l=ke,onChangeLegendRowCollapsed:a=ke,onChangeSelection:p=ke,title:c="Layers",maxZoom:g=20,minZoom:h=0,currentZoom:d,isMobile:y,sx:f}){const m=Z.useIntl(),v=j.useImperativeIntl(m),x=t.jsxs(Zr,{collapsed:i,children:[t.jsx(j.Typography,{variant:"caption",flexGrow:1,children:c}),t.jsx(o.Tooltip,{title:v.formatMessage({id:"c4r.widgets.legend.close"}),children:t.jsx(o.IconButton,{size:"small",onClick:()=>r(!0),children:t.jsx(ee.Close,{})})})]}),b=t.jsx(o.Tooltip,{title:v.formatMessage({id:"c4r.widgets.legend.open"}),children:t.jsx(o.IconButton,{"aria-label":c,onClick:()=>r(!1),children:t.jsx(ee.LayersOutlined,{})})});return t.jsx(Kr,{sx:f,elevation:3,collapsed:i||!!y,children:y?t.jsxs(t.Fragment,{children:[b,t.jsxs(o.Drawer,{anchor:"bottom",open:!i,onClose:()=>r(!0),children:[x,t.jsx(Tt,{children:n.map(S=>t.jsx(Mt,{layer:S,onChangeCollapsed:a,onChangeOpacity:l,onChangeVisibility:s,onChangeSelection:p,maxZoom:g,minZoom:h,currentZoom:d,customLegendTypes:e},S.id))})]})]}):t.jsxs(t.Fragment,{children:[i?b:x,t.jsx(Tt,{width:i?0:void 0,children:t.jsx(o.Collapse,{unmountOnExit:!0,in:!i,timeout:500,children:n.map(S=>t.jsx(Mt,{layer:S,onChangeCollapsed:a,onChangeOpacity:l,onChangeVisibility:s,onChangeSelection:p,maxZoom:g,minZoom:h,currentZoom:d,customLegendTypes:e},S.id))})})]})})}function Ct({color:e=void 0,children:n}){return n?t.jsx(o.Box,{mt:.5,children:t.jsx(j.Typography,{component:"div",variant:"caption",color:e??"inherit",style:{fontWeight:"normal"},children:n})}):t.jsx(o.Box,{mt:-1})}function Es({title:e="No data available",body:n="There are no results for the combination of filters applied to your data. Try tweaking your filters, or zoom and pan the map to adjust the Map View.",severity:i=void 0,...r}){return i?t.jsx(bn.Alert,{title:e,severity:i,...r,children:t.jsx(Ct,{children:n})}):t.jsxs(o.Box,{...r,children:[e&&t.jsx(j.Typography,{variant:"body2",children:e}),t.jsx(Ct,{color:"textSecondary",children:n})]})}const Bs=o.styled(o.Box,{shouldForwardProp:e=>e!=="margin"})(({theme:e,margin:n})=>({margin:0,position:"relative",maxWidth:"100%",padding:n??e.spacing(2,2.5)})),Ps=o.styled(o.LinearProgress)(({theme:e})=>({position:"absolute",top:0,left:0,width:"100%",height:e.spacing(.25)})),Ls=o.styled(o.Grid,{shouldForwardProp:e=>e!=="expanded"})(({theme:e,expanded:n=!0})=>({display:"flex",flexDirection:"row",alignItems:"flex-start",justifyContent:"space-between",width:"100%",...n?{minHeight:e.spacing(3)}:{height:e.spacing(3)},padding:0})),Ds=o.styled(o.Button,{shouldForwardProp:e=>e!=="expandable"})(({theme:e,expandable:n=!0})=>({flex:1,padding:0,alignItems:"flex-start",justifyContent:"flex-start",height:"auto",minHeight:"auto",marginBottom:e.spacing(1),cursor:n?"pointer":"default","& .MuiButton-startIcon":{marginTop:"3px",marginRight:e.spacing(1)},"&:hover":{background:"none"}})),gn=({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",width:e.spacing(3),height:e.spacing(3),color:e.palette.text.secondary}),Ns=o.styled(ee.ExpandLess)(({theme:e})=>gn({theme:e})),Os=o.styled(ee.ExpandMore)(({theme:e})=>gn({theme:e})),$s=o.styled(o.Typography,{shouldForwardProp:e=>e!=="expanded"})(({expanded:e=!0})=>({wordBreak:"break-word",overflow:"hidden",...e&&{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},...!e&&{whiteSpace:"nowrap",textOverflow:"ellipsis"}})),Rs=o.styled(o.Grid)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1),marginRight:e.spacing(-.5),marginLeft:e.spacing(1)})),At=o.styled(o.IconButton)(({theme:e})=>({color:e.palette.text.secondary})),Fs=o.styled(o.Menu)(({theme:e})=>({".MuiPaper-root":{marginTop:e.spacing(5),maxHeight:e.spacing(21),minWidth:e.spacing(16)}})),Et=[],Ws=t.jsx(ee.MoreVert,{});function _s({title:e,actions:n=Et,options:i=Et,optionsIcon:r=Ws,children:s,contentProps:l,disabled:a=!1,expandable:p=!0,expanded:c=!0,onExpandedChange:g,footer:h,headerItems:d,isLoading:y=!1,margin:f}){const m=u.createRef(),[v,x]=u.useState(!0),b=c!==void 0&&g!==void 0,S=p!==!1?b?c:v:!0,I=b?g:x,[T,w]=u.useState(null),C=!!T,M=()=>{p&&I(!S)},D=N=>w(N.currentTarget),E=()=>w(null);function L(N){N&&N(),E()}const P=N=>t.jsx(At,{"aria-label":N.label,onClick:N.action,size:"small",children:N.icon},N.id);return a?s?t.jsx(t.Fragment,{children:s}):null:t.jsxs(Bs,{margin:f,component:"section","aria-label":e,children:[y?t.jsx(Ps,{}):null,t.jsxs(Ls,{container:!0,expanded:c,children:[t.jsx(Ds,{expandable:p,startIcon:p&&t.jsx(o.Icon,{children:S?t.jsx(Ns,{}):t.jsx(Os,{})}),onClick:M,tabIndex:p?0:-1,children:t.jsx(o.Tooltip,{title:e,children:t.jsx($s,{expanded:c,align:"left",variant:"subtitle1",children:e})})}),t.jsxs(Rs,{item:!0,children:[d,n.length>0&&n.map(N=>N.tooltip?t.jsx(o.Tooltip,{title:N.tooltip.text,placement:N.tooltip.placement??"top",children:P(N)},N.id):P(N)),i.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(At,{"aria-label":"options","aria-controls":"options-menu","aria-haspopup":"true",onClick:D,size:"small",children:r}),t.jsx(Fs,{id:"options-menu",elevation:8,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:T,keepMounted:!0,open:C,onClose:E,children:i.map(N=>t.jsx(o.MenuItem,{selected:N.selected,onClick:()=>L(N.action),children:N.name},N.id))})]})]})]}),t.jsx(o.Collapse,{ref:m,in:S,timeout:"auto",unmountOnExit:!0,children:t.jsxs(o.Box,{...l,children:[t.jsx(o.Box,{pt:1,children:s}),h??t.jsx(o.Box,{children:h})]})})]})}exports.BarWidgetUI=Dn;exports.CategoryWidgetUI=Vn;exports.ComparativeCategoryWidgetUI=Sr;exports.ComparativeFormulaWidgetUI=Pr;exports.ComparativePieWidgetUI=Fr;exports.FeatureSelectionUIDropdown=on;exports.FeatureSelectionUIGeometryChips=rn;exports.FeatureSelectionUIToggleButton=nn;exports.FeatureSelectionWidgetUI=Xr;exports.FormulaWidgetUI=Kn;exports.GroupDateTypes=ae;exports.HistogramWidgetUI=ro;exports.LEGEND_TYPES=ce;exports.LegendCategories=an;exports.LegendIcon=un;exports.LegendProportion=cn;exports.LegendRamp=Qe;exports.LegendWidgetUI=As;exports.NoDataAlert=Es;exports.PieWidgetUI=Do;exports.RangeWidgetUI=zo;exports.ScatterPlotWidgetUI=Qo;exports.TIME_SERIES_CHART_TYPES=Ge;exports.TableWidgetUI=di;exports.TimeSeriesProvider=Yt;exports.TimeSeriesWidgetUI=tr;exports.WrapperWidgetUI=_s;exports.useTimeSeriesContext=He;exports.useTimeSeriesInteractivity=Vt;
|