@carto/meridian-ds 0.1.0 → 0.1.1-alpha.0

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.
@@ -1,33 +1,33 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../jsx-runtime-Cek9Ww4S.cjs"),p=require("react"),s=require("@mui/material"),J=require("react-intl"),B=require("../Alert-l8e3Fw5e.cjs"),Bn=require("echarts-for-react"),A=require("../createSvgIcon-BhsoeSAN.cjs"),$e=require("../search-icon-DHF2JDWR.cjs"),fe=require("@mui/icons-material"),je=require("../paletteUtils-DELR0VRh.cjs");function Wt(){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 ne(e){return!e||typeof e!="object"?e:`${e.prefix??""}${e.value}${e.suffix??""}`}const Pn=[],Ln={},gt=e=>e;function Dn(e,n){if(!e||Array.isArray(e)&&e.length===0)return null;const o=Array.isArray(e)?e:[e];let r="";return r+=String(o[0].axisValueLabel),r+=o.map(({seriesName:i,value:a,data:l,marker:x})=>{const c=i?i+": ":"",d=ne(n(Number(a))),m=l,u=`<div style="margin-left: 8px; display: inline">
2
- ${c}${d}${String((m==null?void 0:m.unit)||"")}
3
- </div>`;return`<div style="margin-top: 4px">${String(x)}${u}</div>`}).join(" "),r}function $n({height:e,labels:n=Ln,yAxisData:o,selectedBars:r=Pn,series:i,colors:a,tooltip:l=!0,tooltipFormatter:x=Dn,xAxisFormatter:c=gt,yAxisFormatter:d=gt,onSelectedBarsChange:m,animation:u=!0,filterable:y=!0,stacked:g=!0,...h}){const j=s.useTheme(),f=p.useMemo(()=>(i??[]).map(w=>n[w]??w),[i,n]),v=p.useMemo(()=>Array.isArray(o[0])?o:[o],[o]),R=p.useMemo(()=>typeof a=="string"?[a]:Array.isArray(a)&&a.length?a:v.length<=1||f.length===1?[j.palette.secondary.main]:v.length===2||f.length===2?[j.palette.secondary.light,j.palette.secondary.dark]:Object.values(j.palette.qualitative.bold||{}),[a,j,v,f]);return{...h,tooltip:l,tooltipFormatter:x,xAxisFormatter:c,yAxisFormatter:d,onSelectedBarsChange:m,animation:u,filterable:y,stacked:g,labels:n,height:e??parseInt(j.spacing(22)),selectedBars:On(r),yAxisData:v,colors:R,series:f}}function On(e){return(e??[]).length?e.map(n=>Array.isArray(n)&&n.length===2?n:Array.isArray(n)?[...Array(2)].map((r,i)=>n[i]??0):[n,0]):[]}var Nn=function e(n,o){if(n===o)return!0;if(n&&o&&typeof n=="object"&&typeof o=="object"){if(n.constructor!==o.constructor)return!1;var r,i,a;if(Array.isArray(n)){if(r=n.length,r!=o.length)return!1;for(i=r;i--!==0;)if(!e(n[i],o[i]))return!1;return!0}if(n.constructor===RegExp)return n.source===o.source&&n.flags===o.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===o.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===o.toString();if(a=Object.keys(n),r=a.length,r!==Object.keys(o).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(o,a[i]))return!1;for(i=r;i--!==0;){var l=a[i];if(!e(n[l],o[l]))return!1}return!0}return n!==n&&o!==o};const he=A.getDefaultExportFromCjs(Nn);class Ee extends Bn{componentDidUpdate(n){const{shouldSetOption:o}=this.props;if(typeof o=="function"&&!o(n,this.props))return;if(!he(n.theme,this.props.theme)||!he(n.opts,this.props.opts)){this.dispose(),this.renderNewEcharts();return}const r=this.getEchartsInstance();he(n.onEvents,this.props.onEvents)||(this.offEvents(r,n.onEvents),this.bindEvents(r,this.props.onEvents));const i=["option","notMerge","lazyUpdate","showLoading","loadingOption"];he(ft(this.props,i),ft(n,i))||this.updateEChartsOption(),(!he(n.style,this.props.style)||!he(n.className,this.props.className))&&this.resize()}updateEChartsOption(){const n=this.props.option,o=this.props.loadingOption||null,{lazyUpdate:r,showLoading:i}=this.props,a=this.getEchartsInstance();return a.setOption(n,{replaceMerge:["series"],lazyUpdate:r}),i?a.showLoading(o):a.hideLoading(),a}offEvents(n,o){if(o)for(const r in o)typeof r=="string"&&n.off(r)}}function ft(e,n){const o={};return n.forEach(r=>{o[r]=e[r]}),o}const ze=240,_t=s.styled(s.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)"}})),Gt=s.styled(s.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]}`})),ve=s.styled(s.Skeleton)(({theme:e})=>({flex:1,maxWidth:e.spacing(12),"& + &":{marginLeft:e.spacing(1)}})),se=s.styled(s.Skeleton)(({theme:e})=>({flex:1,maxWidth:e.spacing(8),"& + &":{marginLeft:"1px"}})),Fn=s.styled(s.Skeleton)(({theme:e})=>({backgroundColor:e.palette.common.white})),ht=s.styled(s.Skeleton)(({theme:e})=>({backgroundColor:e.palette.grey[100]}));function Wn({height:e}){return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(s.Box,{mb:2,children:t.jsxRuntimeExports.jsx(s.Skeleton,{width:48,height:8})}),t.jsxRuntimeExports.jsxs(_t,{style:{height:e||ze},children:[t.jsxRuntimeExports.jsx(ve,{variant:"rectangular",height:"20%"}),t.jsxRuntimeExports.jsx(ve,{variant:"rectangular",height:"40%"}),t.jsxRuntimeExports.jsx(ve,{variant:"rectangular",height:"60%"}),t.jsxRuntimeExports.jsx(ve,{variant:"rectangular",height:"20%"}),t.jsxRuntimeExports.jsx(ve,{variant:"rectangular",height:"80%"})]})]})}function ue(e){const[n,o]=p.useState(!1),[r,i]=p.useState(!1);return p.useEffect(()=>{e&&!r&&(o(!0),i(!0)),e||o(!1)},[e,r]),{showSkeleton:n}}const _n=Wt(),Gn=s.styled(s.Grid)(({theme:e})=>({marginBottom:e.spacing(2),flexDirection:"row",justifyContent:"space-between",alignItems:"center","& .MuiTypography-caption":{color:e.palette.text.secondary}})),zn=s.styled(s.Link)(({theme:e})=>({...e.typography.caption,cursor:"pointer"}));function Hn(e){const{yAxisData:n,xAxisData:o,series:r,selectedBars:i,onSelectedBarsChange:a,tooltip:l,tooltipFormatter:x,labels:c,colors:d,xAxisFormatter:m,yAxisFormatter:u,stacked:y,height:g,filterable:h,animation:j,isLoading:f}=$n(e),v=r.length>1,R=s.useTheme(),w=J.useIntl(),b=B.useImperativeIntl(w),{showSkeleton:E}=ue(!!f),k=p.useMemo(()=>({show:l,trigger:"axis",padding:[parseInt(R.spacing(.5)),parseInt(R.spacing(1))],borderWidth:0,textStyle:{...R.typography.caption,fontSize:11,color:R.palette.common.white},backgroundColor:R.palette.black[90],position:function(I,O,H,F,Y){const q={top:0};return Y.contentSize[0]<Y.viewSize[0]-I[0]?q.left=I[0]:q.right=Y.viewSize[0]-I[0],q},formatter:I=>x(I,u)}),[R,l,x,u]),M=p.useMemo(()=>o.map(I=>ne(m(c[I]??String(I)))),[o,c,m]),D=p.useMemo(()=>({type:"category",axisLine:{show:!1},axisTick:{show:!1},axisLabel:{...R.typography.overlineDelicate,padding:[parseInt(R.spacing(.5)),0,0,0]},data:M}),[R,M]),C=p.useMemo(()=>{let I=[];return y?I=n.reduce((O,H)=>(H.forEach((F,Y)=>O[Y]=(O[Y]??0)+(F??Number.MIN_SAFE_INTEGER)),O),[]):I=n.flat().map(O=>O??Number.MIN_SAFE_INTEGER),Math.max(...I)},[n,y]),P=p.useMemo(()=>({type:"value",axisLabel:{margin:0,verticalAlign:"bottom",padding:[0,0,parseInt(R.spacing(1.25)),0],show:!0,showMaxLabel:!0,showMinLabel:!1,inside:!0,color:I=>I>=C?R.palette.black[60]:"transparent",...R.typography.overlineDelicate,formatter:I=>ne(u(I))},axisLine:{show:!1},axisTick:{show:!1},splitLine:{show:!0,onZero:!1,lineStyle:{color:R.palette.black[4]}}}),[R,C,u]),L=p.useMemo(()=>n.map((I,O)=>({type:"bar",name:r[O]??"",animation:j,barMaxWidth:100,data:I.map((H,F)=>{const Y=i.some(([W,V=0])=>W===F&&V===O),q=!!i.length&&!Y;return{value:H,...q&&{itemStyle:{color:R.palette.black[25]},disabled:!0}}}),...y&&{stack:"total"},...!_n&&{emphasis:{focus:"series",itemStyle:{color:s.darken(d[O]??"#000",.25)}}}})),[j,d,r,n,i,y,R]),$=p.useMemo(()=>({grid:{left:M.length>=4?jt(String(M[0]),M.length):0,top:parseInt(R.spacing(2)),right:M.length>=4?jt(String(M[M.length-1]),M.length):0,bottom:0,containLabel:!0},axisPointer:{lineStyle:{color:R.palette.black[40]}},color:d,tooltip:k,xAxis:D,yAxis:P,series:L}),[M,R,d,k,D,P,L]),z=()=>{a&&a([],[])},G=I=>{I.key==="Enter"&&z()},S=p.useCallback(I=>{if(a){const O=[...i],{dataIndex:H,componentIndex:F}=I,Y=O.findIndex(([W,V=0])=>H===W&&F===V);Y===-1?O.push([H,F]):O.splice(Y,1);const q=O.map(([W,V=0])=>({xAxis:o[W],serie:r[V],yAxis:n[V][W]}));a(v?O:O.map(W=>W[0]),q)}},[n,a,i,o,r,v]),N=p.useMemo(()=>h?{click:S}:{},[h,S]);return E?t.jsxRuntimeExports.jsx(Wn,{height:g}):t.jsxRuntimeExports.jsxs("div",{children:[a&&t.jsxRuntimeExports.jsxs(Gn,{container:!0,children:[t.jsxRuntimeExports.jsx(B.Typography,{variant:"caption",children:i.length>0?b.formatMessage({id:"c4r.widgets.bar.selectedItems"},{items:i.length}):b.formatMessage({id:"c4r.widgets.bar.all"})}),i&&i.length>0&&t.jsxRuntimeExports.jsx(zn,{onClick:()=>z(),onKeyDown:G,underline:"hover",tabIndex:0,children:b.formatMessage({id:"c4r.widgets.bar.clear"})})]}),!!$&&t.jsxRuntimeExports.jsx(Ee,{option:$,lazyUpdate:!0,notMerge:!0,onEvents:N,style:{height:g}})]})}function jt(e="",n=0){return n<=15&&e.length<=8?0:e.length*8.5/6}const xe="__rest__",ye="Others";var de=(e=>(e.RANKING="ranking",e.FIXED="fixed",e))(de||{});const zt=s.styled(s.Grid)(({theme:e})=>({maxHeight:e.spacing(40),overflow:"auto",padding:0})),Ht=s.styled(s.Grid,{shouldForwardProp:e=>e!=="selectable"&&e!=="name"&&e!=="unselected"})(({theme:e,selectable:n,name:o,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}},...o!==xe&&n&&{cursor:"pointer",flexWrap:"nowrap","&:hover .progressbar div":{backgroundColor:e.palette.secondary.dark}},...o===xe&&{cursor:"default",".progressbar div":{backgroundColor:e.palette.text.disabled}}})),yt=s.styled(s.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}})),Yn=s.styled(s.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`}})),Vn=s.styled(s.Grid,{shouldForwardProp:e=>e!=="isSelectable"})(({theme:e,isSelectable:n})=>({...n&&{width:`calc(100% - ${e.spacing(4)})`}})),Un=s.styled(B.Typography)(({theme:e})=>({fontWeight:e.typography.fontWeightBold,marginRight:e.spacing(2)})),Te=s.styled(s.Link)(({theme:e})=>({...e.typography.caption,cursor:"pointer","& + hr":{margin:e.spacing(0,1)}})),qn=s.styled(s.Box)(({theme:e})=>({...e.typography.body2})),Et=s.styled(s.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)}})),Kn=s.styled(s.Skeleton)(({theme:e})=>({marginTop:e.spacing(1.25),marginBottom:e.spacing(1.75)})),Zn=e=>e%2===1,Yt=()=>t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(s.Skeleton,{width:48,height:8}),t.jsxRuntimeExports.jsx(zt,{container:!0,mt:3,children:[...Array(6)].map((e,n)=>t.jsxRuntimeExports.jsxs(Ht,{container:!0,spacing:1,children:[t.jsxRuntimeExports.jsxs(s.Grid,{container:!0,item:!0,direction:"row",justifyContent:"space-between",children:[t.jsxRuntimeExports.jsx(s.Skeleton,{width:Zn(n)?72:48,height:8}),t.jsxRuntimeExports.jsx(s.Skeleton,{width:48,height:8})]}),t.jsxRuntimeExports.jsx(Kn,{height:4,width:"100%"})]},n))})]});function Vt(e){const n=p.useRef();return p.useEffect(()=>{n.current=e}),n.current}function Xe({start:e,end:n,duration:o,drawFrame:r,requestRef:i}){if(e===n&&!(e===0&&n===0))return;const l=n-e;let x=e;const c=l/(o/1e3*60),d=()=>{x+=c,r(Math.floor(x)),c>0&&x<n||c<0&&x>n?i.current=requestAnimationFrame(d):r(n)};i.current=requestAnimationFrame(d)}function Xn({start:e,end:n,duration:o,drawFrame:r,requestRef:i}){if(e.length===n.length&&e.every((g,h)=>g.value===n[h].value))return;let l=n.map((g,h)=>e[h]&&e[h].name===g.name?{...g,value:e[h].value}:g),x=0;const c=l.map((g,h)=>n[h].value-g.value);if(c.every(g=>g===0)){r(n);return}const m=o/1e3*60,u=c.map(g=>g/m),y=()=>{x<m?(l=l.map((g,h)=>{const j=Math.floor(g.value+u[h]),f=h>0&&Math.floor(g.value+u[h-1]);return{...g,value:j===f?n[h].value:j}}),r(l),x++,i.current=requestAnimationFrame(y)):r(n)};i.current=requestAnimationFrame(y)}const Jn=[],Qn={},es=e=>e,qe=()=>{};function ts({data:e,formatter:n=es,labels:o=Qn,maxItems:r=5,order:i=de.RANKING,selectedCategories:a=Jn,onSelectedCategoriesChange:l=qe,animation:x=!0,filterable:c=!0,searchable:d=!0,isLoading:m}){const[u,y]=p.useState([]),[g,h]=p.useState(1),[j,f]=p.useState(!1),[v,R]=p.useState(""),[w,b]=p.useState([]),[E,k]=p.useState([]),[M,D]=p.useState([]),C=p.useRef(null),P=p.useRef(),L=Vt(M),$=p.useRef([]),{showSkeleton:z}=ue(!!m),G=J.useIntl(),S=B.useImperativeIntl(G);function N(T){return u.reduce((U,Z)=>(T.includes(Z.name)&&U.push(Z.name),U),[])}function I(T){if(T!==xe){let U;a.includes(T)?U=a.filter(Z=>Z!==T):U=[...a,T],l&&l(U)}}const O=()=>l([]),H=T=>{T.key==="Enter"&&O()},F=()=>{l([]),b([])},Y=T=>{T.key==="Enter"&&F()},q=()=>{b(N(a))},W=T=>{T.key==="Enter"&&q()},V=()=>{const T=N(E);l([...T]),b([...T]),k([]),f(!1),R("")},ee=T=>{T.key==="Enter"&&V()},pe=()=>{R(""),f(!1)},re=T=>{if(T!==xe){let U;E.includes(T)?U=E.filter(Z=>Z!==T):U=[...E,T],k(U)}},_=T=>{T.currentTarget.scrollIntoView()},K=T=>{R(T.currentTarget.value)},X=()=>{f(!0),k([...a])},Q=p.useCallback(T=>{if(j)return v?T.filter(U=>{var te;if(!U.name)return!1;const Z=String(U.name);return!!(Z.toLowerCase().includes(v.toLowerCase())||(te=o[Z])!=null&&te.toLowerCase().includes(v.toLowerCase()))}):T;if(w.length)return w.reduce((Z,te)=>{const me=T.find(ae=>ae.name===te);return Z.push({name:te,value:me?me.value:null}),Z},[]);{const U=T.slice(0,r);if(U.length<T.length){const Z=T.slice(r).reduce((te,me)=>(me.value!==null&&te.value!==null&&(te.value+=me.value),te),{name:xe,value:0});return[...U,Z]}else return U}},[w,o,r,v,j]),ie=p.useCallback(()=>{const T=w.length;return T?e.length-T:e.length-r},[e,r,w]),Me=p.useCallback(T=>T===xe?`Others ${d?"":`(${ie()})`}`:o[String(T)]??String(T),[ie,o,d]),Re=p.useCallback(T=>T>=g?T!=null?"100%":0:`${(T||0)*100/g}%`,[g]);p.useEffect(()=>{a.length===0&&b([])},[a]),p.useEffect(()=>{if(e){if(i===de.RANKING){const T=[...e].sort((Z,te)=>(te.value??0)-(Z.value??0)),U=Q(T);U.length>0?h(U[0].value??0):h(1),y(U)}else if(i===de.FIXED){h(Math.max(...e.map(U=>U.value??0)));const T=Q(e);y(T)}}},[w,Q,e,o,r,i,v,j]),p.useEffect(()=>{L&&($.current=L)},[L]),p.useEffect(()=>{if(x)return Xn({start:($.current||[]).map(T=>({...T,value:T.value??0})),end:u.map(T=>({...T,value:T.value??0})),duration:500,drawFrame:T=>D(T),requestRef:C}),()=>{C.current&&cancelAnimationFrame(C.current)};D(u)},[x,u]),p.useEffect(()=>{j&&P.current&&P.current.focus()},[j,P]);function Tn({data:T,onCategoryClick:U}){const Z=n(T.value??0),[te,me]=p.useState(!1),ae=p.useRef(null),Ve=()=>{var dt,mt;const Ue=(((dt=ae==null?void 0:ae.current)==null?void 0:dt.scrollWidth)??0)>(((mt=ae==null?void 0:ae.current)==null?void 0:mt.clientWidth)??0);me(Ue)};p.useEffect(()=>(Ve(),window.addEventListener("resize",Ve),()=>{window.removeEventListener("resize",Ve)}),[]);const Cn=Ue=>{Ue.key==="Enter"&&U()},An=!j&&a.length>0&&!a.includes(T.name);return t.jsxRuntimeExports.jsxs(Ht,{container:!0,direction:"row",spacing:1,onClick:c?U:qe,onKeyDown:c?Cn:qe,selectable:c,unselected:An,name:T.name===xe?xe:"",tabIndex:c?0:-1,children:[c&&j&&t.jsxRuntimeExports.jsx(s.Grid,{item:!0,mr:1,children:t.jsxRuntimeExports.jsx(s.Checkbox,{checked:E.includes(T.name),tabIndex:-1})}),t.jsxRuntimeExports.jsxs(Vn,{container:!0,item:!0,xs:!0,isSelectable:j,children:[t.jsxRuntimeExports.jsxs(s.Grid,{container:!0,item:!0,direction:"row",justifyContent:"space-between",wrap:"nowrap",children:[t.jsxRuntimeExports.jsx(s.Tooltip,{title:Me(T.name),disableHoverListener:!te,children:t.jsxRuntimeExports.jsx(Un,{variant:"body2",noWrap:!0,ref:ae,children:Me(T.name)})}),typeof Z=="object"&&Z!==null?t.jsxRuntimeExports.jsxs("span",{children:[Z.prefix,Z.value,Z.suffix]}):t.jsxRuntimeExports.jsx("span",{children:Z})]}),t.jsxRuntimeExports.jsx(Yn,{className:"progressbar",item:!0,children:t.jsxRuntimeExports.jsx("div",{style:{width:Re(T.value??0)}})})]})]})}return(e==null?void 0:e.length)===0||z?t.jsxRuntimeExports.jsx(Yt,{}):t.jsxRuntimeExports.jsxs(qn,{children:[c&&u.length>0&&t.jsxRuntimeExports.jsxs(yt,{container:!0,children:[t.jsxRuntimeExports.jsx(B.Typography,{variant:"caption",children:a.length>0?S.formatMessage({id:"c4r.widgets.category.selectedItems"},{items:a.length}):S.formatMessage({id:"c4r.widgets.category.all"})}),j?t.jsxRuntimeExports.jsx(Te,{onClick:V,onKeyDown:ee,underline:"hover",tabIndex:0,"data-testid":"primaryApplyButton",children:S.formatMessage({id:"c4r.widgets.category.apply"})}):w.length>0?t.jsxRuntimeExports.jsx(Te,{onClick:F,onKeyDown:Y,underline:"hover",tabIndex:0,children:S.formatMessage({id:"c4r.widgets.category.unlock"})}):a.length>0&&t.jsxRuntimeExports.jsxs(s.Grid,{container:!0,direction:"row",justifyContent:"flex-end",item:!0,xs:!0,children:[t.jsxRuntimeExports.jsx(Te,{onClick:q,onKeyDown:W,underline:"hover",tabIndex:0,children:S.formatMessage({id:"c4r.widgets.category.lock"})}),t.jsxRuntimeExports.jsx(s.Divider,{orientation:"vertical",flexItem:!0}),t.jsxRuntimeExports.jsx(Te,{onClick:O,onKeyDown:H,underline:"hover",tabIndex:0,children:S.formatMessage({id:"c4r.widgets.category.clear"})})]})]}),e.length>r&&j&&t.jsxRuntimeExports.jsxs(yt,{container:!0,children:[t.jsxRuntimeExports.jsx(s.TextField,{size:"small",sx:{mt:-.5},placeholder:S.formatMessage({id:"c4r.widgets.category.search"}),onChange:K,onFocus:_,InputProps:{startAdornment:t.jsxRuntimeExports.jsx(s.InputAdornment,{position:"start",children:t.jsxRuntimeExports.jsx($e.SearchIcon,{})})},inputProps:{tabIndex:0,ref:P}}),t.jsxRuntimeExports.jsx(Et,{size:"small",onClick:pe,children:S.formatMessage({id:"c4r.widgets.category.cancel"})})]}),t.jsxRuntimeExports.jsx(zt,{container:!0,item:!0,children:M.length?M.map((T,U)=>t.jsxRuntimeExports.jsx(Tn,{data:T,onCategoryClick:()=>j?re(T.name):I(T.name)},U)):t.jsxRuntimeExports.jsxs(s.Box,{children:[t.jsxRuntimeExports.jsx(B.Typography,{variant:"body2",children:S.formatMessage({id:"c4r.widgets.category.noResults"})}),t.jsxRuntimeExports.jsx(B.Typography,{component:"p",variant:"caption",mb:2,children:S.formatMessage({id:"c4r.widgets.category.noResultsMessage"},{searchValue:v})})]})}),j&&t.jsxRuntimeExports.jsx(Et,{size:"small",onClick:V,children:S.formatMessage({id:"c4r.widgets.category.apply"})}),e.length>r&&d?j?t.jsxRuntimeExports.jsx(s.Box,{mt:1.5,children:t.jsxRuntimeExports.jsx(s.Button,{size:"small",color:"primary",onClick:pe,"data-testid":"primaryCancelButton",children:S.formatMessage({id:"c4r.widgets.category.cancel"})})}):t.jsxRuntimeExports.jsx(s.Box,{mt:1.5,children:t.jsxRuntimeExports.jsx(s.Button,{size:"small",color:"primary",startIcon:t.jsxRuntimeExports.jsx($e.SearchIcon,{}),onClick:X,children:S.formatMessage({id:"c4r.widgets.category.searchInfo"},{elements:ie()})})}):null]})}const Ut=()=>t.jsxRuntimeExports.jsx(s.Box,{pt:.5,children:t.jsxRuntimeExports.jsx(s.Skeleton,{height:24,width:120})}),ns=s.styled("span")(()=>({marginRight:"2px"})),ss=s.styled("span")(()=>({marginLeft:"2px"})),Ce="-",os=e=>e;function rs({data:e=Ce,formatter:n=os,animation:o=!0,isLoading:r=!1}){const[i,a]=p.useState(Ce),l=p.useRef(null),x=Vt(i),c=p.useRef(x),{showSkeleton:d}=ue(!!r);p.useEffect(()=>(typeof e=="number"&&o?Xe({start:c.current||0,end:e,duration:500,drawFrame:g=>a(g),requestRef:l}):typeof e=="object"&&o&&e&&c.current&&e.value!==null&&e.value!==void 0?Xe({start:Number(c.current.value),end:Number(e.value),duration:1e3,drawFrame:g=>a({value:g,prefix:e.prefix,suffix:e.suffix}),requestRef:l}):a(e??Ce),()=>{l.current&&cancelAnimationFrame(l.current)}),[o,e,a]);const m=n(i),u=typeof m=="object"&&m!==null,y=m===Ce;return d?t.jsxRuntimeExports.jsx(Ut,{}):u?t.jsxRuntimeExports.jsxs(B.Typography,{variant:"h5",component:"div",weight:"medium",children:[t.jsxRuntimeExports.jsx(ns,{children:m.prefix}),m.value,t.jsxRuntimeExports.jsx(ss,{children:m.suffix})]}):t.jsxRuntimeExports.jsx(B.Typography,{variant:"h5",component:"div",weight:"medium",color:y?"text.disabled":"default",whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",children:m})}const Rt={};let we=null;function is({data:e,filterable:n,selectedBars:o,onSelectedBarsChange:r,echartsInstance:i}){const a=s.useTheme(),[l,x]=p.useState([]),c=p.useMemo(()=>i==null?void 0:i.getZr(),[i]);p.useEffect(()=>{function m(y){if(i){const[g]=i.convertFromPixel({seriesIndex:0},[y.offsetX,y.offsetY]);we=g??null}}function u(y){if(i&&we!==null){const[g]=i.convertFromPixel({seriesIndex:0},[y.offsetX,y.offsetY]);x(we===g?[]:[we,g].sort((h,j)=>h-j))}}if(i&&n){const y=Ke(c,"mousedown",m),g=Ke(c,"mousemove",u);return()=>{y==null||y(),g==null||g()}}},[c,i,n]),p.useEffect(()=>{function m(){if(l.length===2&&r){const u=e.reduce((y,g,h)=>((l[0]>=g[0]&&l[0]<=g[1]||l[1]>=g[0]&&l[1]<=g[1]||l[0]<=g[0]&&l[1]>=g[1])&&y.push(h),y),[]);r(e.length===u.length?[]:u)}x([]),we=null}if(i&&n)return Ke(c,"mouseup",m)},[c,i,l,e,r,n]);const d=p.useCallback(m=>{if(r){const u=new Set(o);u.has(m.dataIndex)?u.delete(m.dataIndex):u.add(m.dataIndex),r(u.size===e.length?[]:Array.from(u))}},[r,o,e.length]);return{markAreaOptions:l.length===2&&{data:[[{coord:[l[0]]},{coord:[l[1]]}]],itemStyle:{color:a.palette.primary.main,opacity:.2}},onEvents:n?{click:d}:{}}}function Ke(e,n,o){if(e!=null&&e.handler)return Rt[n]=o,e.on(n,o),()=>{Rt[n]&&(e!=null&&e.handler)&&e.off(n,o)}}function as({height:e}){return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(s.Box,{mb:2,children:t.jsxRuntimeExports.jsx(s.Skeleton,{width:48,height:8})}),t.jsxRuntimeExports.jsxs(Gt,{style:{height:e??ze},children:[t.jsxRuntimeExports.jsx(se,{variant:"rectangular",height:"20%"}),t.jsxRuntimeExports.jsx(se,{variant:"rectangular",height:"40%"}),t.jsxRuntimeExports.jsx(se,{variant:"rectangular",height:"60%"}),t.jsxRuntimeExports.jsx(se,{variant:"rectangular",height:"20%"}),t.jsxRuntimeExports.jsx(se,{variant:"rectangular",height:"80%"}),t.jsxRuntimeExports.jsx(se,{variant:"rectangular",height:"50%"}),t.jsxRuntimeExports.jsx(se,{variant:"rectangular",height:"20%"}),t.jsxRuntimeExports.jsx(se,{variant:"rectangular",height:"40%"}),t.jsxRuntimeExports.jsx(se,{variant:"rectangular",height:"60%"}),t.jsxRuntimeExports.jsx(se,{variant:"rectangular",height:"20%"}),t.jsxRuntimeExports.jsx(se,{variant:"rectangular",height:"80%"}),t.jsxRuntimeExports.jsx(se,{variant:"rectangular",height:"50%"})]})]})}const ls=Wt(),cs=s.styled(s.Grid)(({theme:e})=>({marginBottom:e.spacing(2),flexDirection:"row",justifyContent:"space-between",alignItems:"center","& .MuiTypography-caption":{color:e.palette.text.secondary}})),us=s.styled(s.Link)(({theme:e})=>({...e.typography.caption,cursor:"pointer"})),ps=[],xs=()=>{},Oe=e=>e;function ds(e,n=Oe,o=Oe){if(!e)return null;if(Array.isArray(e)&&e.length===0)return;const r=Array.isArray(e)?e[0].marker:e.marker,i=Array.isArray(e)?e[0].data:e.data;if((i==null?void 0:i.value)===void 0)return;const[a,l,x]=i.value,c=ne(n(a)),d=ne(n(l)),m=ne(o(x)),u=`${c} <span style="vertical-align: 1px;">—</span> ${d}`,y=`<div style="margin-left: 8px; display: inline">${m}</div>`;return`${u} <div style="margin-top: 4px">${String(r)}${y}</div>`}function ms({data:e,ticks:n,min:o,max:r,xAxisFormatter:i=Oe,yAxisFormatter:a=Oe,yAxisType:l="dense",selectedBars:x=ps,onSelectedBarsChange:c=xs,tooltip:d=!0,tooltipFormatter:m=ds,animation:u=!0,filterable:y=!0,height:g=200,isLoading:h}){const j=J.useIntl(),f=s.useTheme(),v=B.useImperativeIntl(j),{showSkeleton:R}=ue(!!h),w=!!y&&!!c,[b,E]=p.useState(),k=I=>E(I),M=p.useMemo(()=>hs(e,n,o,r),[e,n,o,r]),{onEvents:D,markAreaOptions:C}=is({data:M,filterable:w,selectedBars:x,onSelectedBarsChange:c,echartsInstance:b}),P=p.useMemo(()=>({show:d,trigger:"item",padding:[A.SPACING*.5,A.SPACING],borderWidth:0,textStyle:{...f.typography.caption,fontSize:11,color:f.palette.common.white},backgroundColor:f.palette.black[90],confine:!0,position:"top",formatter(I){return m(I,i,a)}}),[f,d,m,i,a]),L=p.useMemo(()=>({min:o,max:r,interval:(r-o)/M.length,axisLine:{show:!1},splitLine:{show:!0,lineStyle:{color:f.palette.black[4]}},axisTick:{show:!1},axisLabel:{showMinLabel:!0,showMaxLabel:!0,...f.typography.overlineDelicate,hideOverlap:!0,padding:[A.SPACING*.5,A.SPACING*.5,0,A.SPACING*.5],formatter:I=>{const O=ne(i(I));return I===o?gs(O):I===r?fs(O):O},color:f.palette.black[60]}}),[o,r,M.length,f,i]),$=p.useMemo(()=>{const I={margin:0,verticalAlign:"bottom",padding:[0,0,A.SPACING*1.25,0],inside:!0,color:F=>{const Y=Math.max(...e.map(W=>W??Number.MIN_SAFE_INTEGER))||1;let q="transparent";return F>=Y&&(q=f.palette.black[60]),q},...f.typography.overlineDelicate,formatter:F=>ne(a(F))},O={verticalAlign:"middle",padding:[0,0,0,A.SPACING*.5],color:f.palette.black[60]},H=l==="dense"?I:O;return{type:"value",axisLine:{show:!1},splitLine:{show:!0,lineStyle:{color:f.palette.black[4]}},axisTick:{show:!1},axisLabel:{show:!0,showMaxLabel:!0,showMinLabel:!1,...H,...f.typography.overlineDelicate,formatter:F=>ne(a(F))}}},[f.palette.black,f.typography.overlineDelicate,e,a,l]),z=p.useMemo(()=>{const I=o===r&&M.filter(F=>F[2]!==0).length===1,H=(I?[M[0],M[M.length-1]]:M).map((F,Y)=>{const W=x.length&&!x.includes(Y)?f.palette.black[25]:f.palette.secondary.main;return{value:F,itemStyle:{color:W}}});return{type:"custom",cursor:"pointer",markArea:C,renderItem:function(F,Y){const q=F.dataIndex===M.length-1,W=F.dataIndex===0,V=H[F.dataIndex].itemStyle.color,ee=Y.value(0),pe=Y.value(1),re=Y.value(2),[_,K]=Y.coord([ee,re]),[X,Q]=Y.size([pe-ee,re]);return{type:"rect",shape:{x:I?_/10:_+(W?0:1),y:K,width:I?_-_/10:X-(q?0:1),height:Q},style:{fill:V},...!ls&&{emphasis:{style:{fill:s.darken(V,.25)}}}}},encode:{x:[0,1],y:2,tooltip:[0,1,2]},data:H,animation:u}},[o,r,M,C,f.palette.black,f.palette.secondary.main,x,u]),G=p.useMemo(()=>({grid:{left:A.SPACING*.1,right:A.SPACING*.1,top:A.SPACING*2,bottom:A.SPACING*.5,containLabel:!0},tooltip:P,xAxis:L,yAxis:$,series:[z]}),[P,L,$,z]),S=x.reduce((I,O)=>I+=e[O]??0,0),N=I=>{I.key==="Enter"&&c([])};return R?t.jsxRuntimeExports.jsx(as,{height:g}):t.jsxRuntimeExports.jsxs("div",{children:[w&&t.jsxRuntimeExports.jsxs(cs,{container:!0,children:[t.jsxRuntimeExports.jsx(B.Typography,{variant:"caption",weight:"strong",children:x.length>0?v.formatMessage({id:"c4r.widgets.histogram.selectedItems"},{items:ne(a(S))}):v.formatMessage({id:"c4r.widgets.histogram.all"})}),x.length>0&&t.jsxRuntimeExports.jsx(us,{onClick:()=>c([]),onKeyDown:N,underline:"hover",tabIndex:0,children:v.formatMessage({id:"c4r.widgets.histogram.clear"})})]}),t.jsxRuntimeExports.jsx(Ee,{option:G,onEvents:D,lazyUpdate:!0,onChartReady:k,style:{maxHeight:g}})]})}function gs(e){return`${Array(String(e).length).fill(" ").join("")}${e}`}function fs(e){const n=Array(String(e).length).fill(" ").join("");return`${e}${n}`}function hs(e,n,o,r){return e.map((i,a)=>[a===0?o:n[a-1],a===e.length-1?r:n[a],i])}function js(e,n,o,r){const i=s.useTheme(),a=p.useMemo(()=>n===de.RANKING?e.slice().sort((c,d)=>(d.value??0)-(c.value??0)):e,[e,n]),l=p.useMemo(()=>{const c=[];let d=0;for(const m of a)c.length<o?c.push({...m}):d+=m.value??0;return d>0&&c.push({name:ye,value:d,emphasis:{scale:!1}}),c},[o,a]);return p.useMemo(()=>{const c=i.palette.common.white;return l.map((d,m)=>{let u=c;if(r.length){const g=r[m%r.length];g&&(u=g)}else{const h=i.palette.qualitative.bold[m];h&&(u=h)}const y=d;return y.color=u,y})},[l,r,i])}const ys=s.styled(s.Box)(({theme:e})=>({zIndex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",paddingBottom:e.spacing(1)})),Es=s.styled(s.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1),maxWidth:"140px",textTransform:"uppercase"})),Rs=s.styled(s.Box)(({theme:e})=>({display:"inline-block",borderRadius:e.spacing(.5),width:e.spacing(1),minWidth:e.spacing(1),height:e.spacing(1)}));function vs({data:e,selectedCategories:n,formatter:o}){const[r,i]=p.useState(),a=p.useMemo(()=>{if(!e||e.length===0)return null;let d;n.length>0?d=e.filter(h=>n.includes(h.name)):d=e;const m=ws(d),u=d.find(h=>h===m);if(!u)return null;let y=0;for(const h of e)y+=h.value??0;const g=bs(u.value??0,y,o);return{...u,percentage:g}},[e,n,o]);p.useEffect(()=>{a&&i(a)},[a,i]);const{name:l,percentage:x,color:c}=r??{};return r?t.jsxRuntimeExports.jsxs(ys,{children:[t.jsxRuntimeExports.jsx(B.Typography,{variant:"h5",children:x}),t.jsxRuntimeExports.jsxs(Es,{children:[t.jsxRuntimeExports.jsx(Rs,{bgcolor:c,component:"span"}),t.jsxRuntimeExports.jsx(B.Typography,{component:"span",variant:"body2",noWrap:!0,children:l})]})]}):null}function ws(e){const n=e.filter(o=>o.name!==ye);return n.length===0?e[0]:n.reduce((o,r)=>(r.value??0)>(o.value??0)?r:o)}function bs(e,n,o){let r=0;return n!==0&&(r=e/n*100),o?o(r):`${r}%`}const vt=32,Ss=s.styled(s.Box)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",marginTop:e.spacing(.5)})),Is=s.styled("div")(()=>({display:"flex",alignItems:"center",justifyContent:"center",position:"relative"})),ks=s.styled(Fn)(()=>({position:"absolute",zIndex:1})),Ms=s.styled("div")(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",gap:e.spacing(1),position:"absolute",zIndex:2})),Ts=s.styled(s.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(2),height:e.spacing(5)})),Cs=s.styled("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5)}));function qt({height:e}){const n=parseInt(String(e),10)||ze,o=n-vt,r=o-vt;return t.jsxRuntimeExports.jsxs(s.Box,{mt:.5,children:[t.jsxRuntimeExports.jsx(s.Skeleton,{height:8,width:64}),t.jsxRuntimeExports.jsx(Ss,{height:n,children:t.jsxRuntimeExports.jsxs(Is,{children:[t.jsxRuntimeExports.jsx(s.Skeleton,{variant:"circular",width:o,height:o}),t.jsxRuntimeExports.jsx(ks,{variant:"circular",width:r,height:r}),t.jsxRuntimeExports.jsxs(Ms,{children:[t.jsxRuntimeExports.jsx(s.Skeleton,{height:24,width:72}),t.jsxRuntimeExports.jsx(s.Skeleton,{height:8,width:48})]})]})}),t.jsxRuntimeExports.jsx(Ts,{children:[...Array(2)].map((i,a)=>t.jsxRuntimeExports.jsxs(Cs,{children:[t.jsxRuntimeExports.jsx(s.Skeleton,{variant:"circular",width:8,height:8}),t.jsxRuntimeExports.jsx(s.Skeleton,{width:48,height:8})]},a))})]})}const As=s.styled(s.Box)(({theme:e})=>({position:"relative",padding:e.spacing(1.25,1,0,1),width:"100%"})),Bs=s.styled(s.Box)(({theme:e})=>({position:"relative",display:"flex",flexDirection:"row",overflowX:"hidden",gap:e.spacing(2),padding:e.spacing(.5),margin:e.spacing(-.5)})),Ps=s.styled(s.Box)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(1),alignItems:"center",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"})),Ls=s.styled(s.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%)`})),Ds=s.styled(s.Box)(({theme:e})=>({position:"absolute",padding:e.spacing(.25,1),top:e.spacing(0),right:0,background:e.palette.background.paper})),$s=s.styled(s.Box,{shouldForwardProp:e=>e!=="color"})(({theme:e,color:n})=>{const o=e.spacing(1);return{backgroundColor:n,borderRadius:"50%",width:o,height:o}});function Kt({series:e,selectedCategories:n,onCategoryClick:o}){var w,b;const r=s.useTheme(),[i,a]=p.useState(!1),[l,x]=p.useState(0),[c,d]=p.useState(void 0),m=p.useRef(null),u=p.useRef(null),y=p.useRef(null),g=J.useIntl(),h=B.useImperativeIntl(g);function j(){x(l+1)}function f(){x(Math.max(l-1))}function v(E,k){E.key==="Enter"&&(o==null||o(k))}const R=p.useCallback(()=>{var k,M,D;const E=!!u.current&&u.current.scrollWidth>u.current.clientWidth;a(E),d(E&&u.current?(((k=m.current)==null?void 0:k.clientWidth)??0)-(((M=y.current)==null?void 0:M.clientWidth)??70):(((D=m.current)==null?void 0:D.clientWidth)??0)-12||500)},[m,u,y]);return p.useEffect(()=>{R()},[u,(w=u.current)==null?void 0:w.scrollWidth,(b=u.current)==null?void 0:b.clientWidth,R,l]),p.useEffect(()=>{if(typeof ResizeObserver>"u")return;let E;return m.current&&(E=new ResizeObserver(()=>{R()}),E.observe(m.current)),()=>{E==null||E.disconnect()}},[m,R]),t.jsxRuntimeExports.jsxs(As,{ref:m,children:[t.jsxRuntimeExports.jsx(Bs,{ref:u,style:{maxWidth:`${c}px`},children:e.map((E,k)=>{if(k<l)return null;const M=n.length===0||n.includes(E.name);return t.jsxRuntimeExports.jsxs(Ps,{tabIndex:0,onClick:o?()=>o(E.name):void 0,onKeyDown:o?D=>v(D,E.name):void 0,style:{pointerEvents:!o||E.name==="Others"?"none":void 0},children:[t.jsxRuntimeExports.jsx($s,{color:M?E.color:r.palette.text.disabled}),t.jsxRuntimeExports.jsx(B.Typography,{variant:"overline",color:M?void 0:"text.disabled",children:E.name})]},k)})}),(i||l>0)&&t.jsxRuntimeExports.jsxs(Ds,{ref:y,children:[t.jsxRuntimeExports.jsx(Ls,{}),t.jsxRuntimeExports.jsx(s.Tooltip,{title:h.formatMessage({id:"c4r.widgets.chartLegend.next"}),children:t.jsxRuntimeExports.jsx(s.IconButton,{size:"small",disabled:l===0,onClick:f,children:t.jsxRuntimeExports.jsx(fe.ChevronLeft,{})})}),t.jsxRuntimeExports.jsx(s.Tooltip,{title:h.formatMessage({id:"c4r.widgets.chartLegend.prev"}),children:t.jsxRuntimeExports.jsx(s.IconButton,{size:"small",disabled:!i,onClick:j,children:t.jsxRuntimeExports.jsx(fe.ChevronRight,{})})})]})]})}const Je="232px",Os=s.styled(s.Grid)(({theme:e})=>({flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:e.spacing(.5)})),Ns=s.styled(s.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%"})),Fs=s.styled(Ee)(()=>({position:"absolute",top:0,right:0,left:0,bottom:0})),wt=[],Ws={},_s=e=>e;function Gs({name:e,data:n,formatter:o=_s,tooltipFormatter:r=zs,percentFormatter:i,height:a=Je,width:l=Je,labels:x=Ws,colors:c=wt,animation:d=!0,filterable:m=!0,selectedCategories:u=wt,onSelectedCategoriesChange:y,isLoading:g,maxItems:h=11,order:j=de.RANKING}){const f=s.useTheme(),v=js(n,j,h,c),{showSkeleton:R}=ue(!!g),w=J.useIntl(),b=B.useImperativeIntl(w),E=p.useMemo(()=>i||(G=>`${w.formatNumber(G,{maximumFractionDigits:2,minimumFractionDigits:2})}%`),[w,i]),k=p.useMemo(()=>{let G;return r&&(G=S=>r(S,o,E)),{padding:[A.SPACING*.5,A.SPACING],backgroundColor:f.palette.black[90],borderColor:"transparent",textStyle:{color:f.palette.common.white},confine:!0,formatter:G}},[f.palette.black,f.palette.common.white,r,o,E]),M=p.useMemo(()=>[{type:"pie",name:e,animation:d,data:v.map(G=>{const S={...G},N=(u==null?void 0:u.length)&&!u.includes(S.name);return x!=null&&x[S.name]&&(S.name=x[S.name]),N?{...S,disabled:!0,itemStyle:{color:f.palette.black[25]}}:{...S,itemStyle:{color:S.color}}}),radius:["74%","90%"],selectedOffset:0,bottom:A.SPACING*1.5,label:{show:!1},emphasis:{focus:"series",scaleSize:5},itemStyle:{borderColor:f.palette.background.paper,borderWidth:1}}],[e,d,v,x,u,f]),D=p.useMemo(()=>({grid:{left:0,top:0,right:0,bottom:0},tooltip:k,legend:{show:!1},series:M}),[k,M]),C=p.useCallback(G=>{if(y){const S=[...u],{name:N}=v[G.dataIndex];if(N===ye)return;const I=S.indexOf(N);I===-1?S.push(N):S.splice(I,1),y(S)}},[v,y,u]),P=p.useCallback(G=>{if(y){const S=[...u],N=S.indexOf(G);N===-1?S.push(G):S.splice(N,1),y(S)}},[y,u]),L={...m&&{click:C}},$=()=>{y==null||y([])},z=G=>{G.key==="Enter"&&$()};return R?t.jsxRuntimeExports.jsx(qt,{height:a}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[m&&t.jsxRuntimeExports.jsxs(Os,{container:!0,children:[t.jsxRuntimeExports.jsx(B.Typography,{variant:"caption",color:"textSecondary",children:u.length?b.formatMessage({id:"c4r.widgets.pie.selectedItems"},{items:u.length}):b.formatMessage({id:"c4r.widgets.pie.allSelected"})}),u.length>0&&t.jsxRuntimeExports.jsx(s.Link,{variant:"caption",onClick:$,onKeyDown:z,tabIndex:0,children:b.formatMessage({id:"c4r.widgets.pie.clear"})})]}),t.jsxRuntimeExports.jsxs(Ns,{height:a,width:l,children:[t.jsxRuntimeExports.jsx(vs,{data:v,selectedCategories:u,formatter:E}),t.jsxRuntimeExports.jsx(Fs,{option:D,onEvents:L,lazyUpdate:!0,style:{height:a,width:l}})]}),v.length>0&&t.jsxRuntimeExports.jsx(Kt,{series:v,selectedCategories:u,onCategoryClick:y&&P})]})}function zs(e,n,o){var c;const r=Array.isArray(e)?e[0]:e;if(!r)return null;const i=ne(n(r.value)),a=o(r.percent)||`${r.percent}%`,x=`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:${Je};font-size:11px;font-weight:500;line-height:1.454;text-transform:uppercase;margin:0 0 4px 0;">${r.name}</p>
6
- <p style="display:flex;align-items:center;font-size: 11px;font-weight:500;line-height:1.454;margin:0;"><span style="${x}"></span> <span style="margin:0 4px;font-weight:400;">${i}</span> (${a})</p></div>
7
- `.trim()}const Hs=s.styled(s.Grid)(({theme:e})=>({position:"relative",alignItems:"center",height:e.spacing(4)})),Ys=s.styled(s.Grid)(({theme:e})=>({position:"absolute",zIndex:1,padding:e.spacing(0,3)}));function Vs(){return t.jsxRuntimeExports.jsxs(s.Grid,{container:!0,children:[t.jsxRuntimeExports.jsxs(Hs,{container:!0,item:!0,children:[t.jsxRuntimeExports.jsxs(Ys,{container:!0,item:!0,justifyContent:"space-between",children:[t.jsxRuntimeExports.jsx(ht,{variant:"circular",width:12,height:12}),t.jsxRuntimeExports.jsx(ht,{variant:"circular",width:12,height:12})]}),t.jsxRuntimeExports.jsx(s.Skeleton,{height:2,width:"100%"})]}),t.jsxRuntimeExports.jsxs(s.Grid,{container:!0,item:!0,justifyContent:"space-between",children:[t.jsxRuntimeExports.jsx(s.Skeleton,{width:56,height:32}),t.jsxRuntimeExports.jsx(s.Skeleton,{width:56,height:32})]})]})}const Us=s.styled(s.Box)(()=>({position:"relative"})),qs=s.styled(s.Box)(({theme:{spacing:e}})=>({display:"flex",flexDirection:"row-reverse",height:e(1.5)})),Ks=s.styled(s.Link)(()=>({cursor:"pointer"})),bt=s.styled(s.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}}})),Zs=s.styled(s.Slider)(({theme:{palette:e}})=>({"& .MuiSlider-rail":{color:e.text.hint}})),Xs=s.styled(s.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 Js({data:e,min:n,max:o,limits:r,onSelectedRangeChange:i,isLoading:a}){const[l,x]=p.useState([n,o]),[c,d]=p.useState([n,o]),m=J.useIntl(),u=B.useImperativeIntl(m),{showSkeleton:y}=ue(!!a),g=p.useMemo(()=>{if(!r||r.length!==2)return;if(r[0]===r[1])return[{value:r[0]}];const E=[{value:Math.max(r[0],n)},{value:Math.min(r[1],o)}];if(!(E[0].value>E[1].value))return E},[r,o,n]),h=p.useMemo(()=>i?s.debounce(i,250):null,[i]),j=E=>{d([...E]),x([...E]),h&&h([...E])};function f(E,k){const M=E.target.value===""?"":Number(E.target.value);k===0&&d([M,c[1]]),k===1&&d([c[0],M])}const v=n!==c[0]||o!==c[1];p.useEffect(()=>{e&&(d([...e]),x([...e]))},[e]);function R(E){let k=c[E];k===""&&(k=l[E]),k>o&&(k=o),k<n&&(k=n);const M=E===0?[k,c[1]]:[c[0],k];j(M.sort((D,C)=>D-C))}const w=()=>{j([n,o])};function b(E){E.key==="Enter"&&w()}return y?t.jsxRuntimeExports.jsx(Vs,{}):t.jsxRuntimeExports.jsxs(Us,{children:[t.jsxRuntimeExports.jsx(qs,{children:v&&t.jsxRuntimeExports.jsx(B.Typography,{variant:"caption",color:"primary",children:t.jsxRuntimeExports.jsx(Ks,{onClick:w,onKeyDown:b,tabIndex:0,component:"button",underline:"hover",children:u.formatMessage({id:"c4r.widgets.range.clear"})})})}),t.jsxRuntimeExports.jsxs(s.Box,{children:[t.jsxRuntimeExports.jsx(Zs,{getAriaLabel:E=>E===0?u.formatMessage({id:"c4r.widgets.range.minValue"}):u.formatMessage({id:"c4r.widgets.range.maxValue"}),value:l,min:n,max:o,onChange:(E,k)=>j(k)}),r&&r.length===2&&t.jsxRuntimeExports.jsx(Xs,{getAriaLabel:E=>E===0?u.formatMessage({id:"c4r.widgets.range.minLimit"}):u.formatMessage({id:"c4r.widgets.range.maxLimit"}),value:r,min:n,max:o,marks:g})]}),t.jsxRuntimeExports.jsxs(s.Box,{display:"flex",justifyContent:"space-between",mb:1,children:[t.jsxRuntimeExports.jsx(bt,{value:c[0],size:"small",onChange:E=>f(E,0),onBlur:()=>R(0),inputProps:{min:n,max:o,type:"number","aria-label":u.formatMessage({id:"c4r.widgets.range.minValue"})}}),t.jsxRuntimeExports.jsx(bt,{value:c[1],size:"small",onChange:E=>f(E,1),onBlur:()=>R(1),inputProps:{min:n,max:o,type:"number","aria-label":u.formatMessage({id:"c4r.widgets.range.maxValue"})}})]})]})}const Qs=s.styled(Gt)(({theme:e})=>({flexDirection:"column",alignItems:"center",justifyContent:"center",marginLeft:e.spacing(4),containerType:"inline-size",[`@container (max-width: ${A.BREAKPOINTS.XS}px)`]:{" > div":{maxWidth:"75%"}}})),eo=s.styled(s.Box)(()=>({position:"relative",display:"flex",justifyContent:"space-between",width:"80%",maxWidth:"50%"}));function to({height:e}){function n(){return Math.floor(Math.random()*5)}return t.jsxRuntimeExports.jsxs(s.Box,{height:e??ze,children:[t.jsxRuntimeExports.jsx(s.Box,{mb:4,children:t.jsxRuntimeExports.jsx(s.Skeleton,{width:48,height:8})}),t.jsxRuntimeExports.jsx(Qs,{height:"80%",children:[...Array(3)].map((o,r)=>t.jsxRuntimeExports.jsx(eo,{ml:r*3,children:[...Array(4)].map((i,a)=>t.jsxRuntimeExports.jsx(s.Box,{mt:n(),ml:n(),children:t.jsxRuntimeExports.jsx(s.Skeleton,{variant:"circular",width:12,height:12})},a))},r))})]})}function no(e,n){var c;const o=Array.isArray(e.tooltip)?e.tooltip[0]:e.tooltip,r=Array.isArray(n.tooltip)?n.tooltip[0]:n.tooltip,i=o==null?void 0:o.formatter,a=r==null?void 0:r.formatter,l=(c=e.series[0])==null?void 0:c.data,x=n.series[0].data;return i!==a?!1:l&&x&&l.length===x.length?!x.some(({value:d},m)=>{var u;return d!==((u=l[m])==null?void 0:u.value)}):!1}function so({tooltipFormatter:e,xAxisFormatter:n=Ne,yAxisFormatter:o=Ne},r){return{grid:{top:10,left:5,bottom:10,right:15,containLabel:!0},tooltip:{padding:[A.SPACING*.5,A.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:[A.SPACING*.5,0,0,0],formatter:i=>ne(n(i))}},yAxis:{axisLabel:{...r.typography.overlineDelicate,formatter:i=>ne(o(i))}}}}function oo({name:e,data:n,animation:o}){return[{type:"scatter",name:e,data:n,animation:o}]}const ro=p.memo(Ee,(e,n)=>no(e.option,n.option)),St=225,io=[],Ne=e=>e;function ao({name:e=null,data:n=io,animation:o=!0,xAxisFormatter:r=Ne,yAxisFormatter:i=Ne,tooltipFormatter:a=lo,isLoading:l}){const x=s.useTheme(),c=p.useRef(),[d,m]=p.useState({series:[]}),{showSkeleton:u}=ue(!!l);return p.useEffect(()=>{const y=so({xAxisFormatter:r,yAxisFormatter:i,tooltipFormatter:a},x),g=oo({name:e,data:n||[],animation:o});m({...y,series:g})},[n,e,o,x,r,i,a]),u?t.jsxRuntimeExports.jsx(to,{height:St}):t.jsxRuntimeExports.jsx(ro,{ref:c,option:d,lazyUpdate:!0,style:{height:St}})}function lo(e){const n=Array.isArray(e)?e[0]:e,o=(n==null?void 0:n.value)||[];return`[${o[0]}, ${o[1]})`}function Ae({width:e,rows:n=4,index:o=0}){function r(i){const a=[72,48,96,32,64],l=i%a.length;return a[l]}return[...Array(n)].map((i,a)=>t.jsxRuntimeExports.jsx(s.TableCell,{children:t.jsxRuntimeExports.jsx(s.Skeleton,{width:e??r(o),height:8})},a))}const co=s.styled(s.Box)(({theme:e})=>({display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:e.spacing(2),margin:0,padding:e.spacing(2,1)})),uo=s.styled(s.TableContainer)(()=>({overflow:"hidden"}));function po({style:e,dense:n,pagination:o,rowsPerPage:r}){return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(uo,{style:e,children:t.jsxRuntimeExports.jsxs(s.Table,{"aria-label":"skeleton table",size:n?"small":"medium",children:[t.jsxRuntimeExports.jsx(s.TableHead,{children:t.jsxRuntimeExports.jsxs(s.TableRow,{children:[t.jsxRuntimeExports.jsx(Ae,{rows:1,width:8}),t.jsxRuntimeExports.jsx(Ae,{width:56})]})}),t.jsxRuntimeExports.jsx(s.TableBody,{children:[...Array(Math.min(10,r??10))].map((i,a)=>t.jsxRuntimeExports.jsxs(s.TableRow,{children:[t.jsxRuntimeExports.jsx(Ae,{rows:1,width:8}),t.jsxRuntimeExports.jsx(Ae,{index:a})]},a))})]})}),o&&t.jsxRuntimeExports.jsxs(co,{children:[t.jsxRuntimeExports.jsx(s.Skeleton,{width:56,height:8}),t.jsxRuntimeExports.jsx(s.Box,{mr:1,children:t.jsxRuntimeExports.jsx(s.Skeleton,{width:52,height:16})}),t.jsxRuntimeExports.jsx(s.Skeleton,{width:60,height:8}),t.jsxRuntimeExports.jsx(s.Skeleton,{width:16,height:16}),t.jsxRuntimeExports.jsx(s.Skeleton,{width:16,height:16})]})]})}const xo=s.styled(s.TableSortLabel)(({theme:e})=>({...e.typography.caption,color:e.palette.text.secondary})),mo=s.styled(s.TableRow)(({theme:e})=>({maxHeight:e.spacing(6.5),transition:"background-color 0.25s ease","&.MuiTableRow-hover:hover":{cursor:"pointer",backgroundColor:e.palette.background.default}})),go=s.styled(s.TableCell)(()=>({overflow:"hidden","& p":{maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}})),fo=s.styled(s.TablePagination)(({theme:e})=>({height:e.spacing(6),overflowX:"auto",overflowY:"hidden"})),ho=10,jo=[5,10,25],be=()=>{};function yo({columns:e,rows:n,sorting:o=!1,sortBy:r,sortDirection:i="asc",onSetSortBy:a=be,onSetSortDirection:l=be,pagination:x=!1,totalCount:c,page:d,onSetPage:m=be,rowsPerPage:u=ho,rowsPerPageOptions:y=jo,onSetRowsPerPage:g=be,onRowClick:h=be,height:j,dense:f=!1,isLoading:v,lastPageTooltip:R}){var $;const w=p.useRef(null),b=J.useIntl(),E=B.useImperativeIntl(b),{showSkeleton:k}=ue(!!v);function M({from:z,to:G,count:S}){return E.formatMessage({id:"c4r.widgets.table.of"},{from:z,to:G,count:S})}function D(z){l(r===z&&i==="asc"?"desc":"asc"),a(z)}function C(z,G){m(G)}function P(z){g(parseInt(z.target.value,10)),m(0)}const L={height:void 0};if(j){const z=Math.max((($=w==null?void 0:w.current)==null?void 0:$.clientHeight)??0,x?A.SPACING*6:0);L.height=`calc(${j} - ${z}px)`}return k?t.jsxRuntimeExports.jsx(po,{rowsPerPage:u,style:L,dense:f,pagination:x}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(s.TableContainer,{style:L,children:t.jsxRuntimeExports.jsxs(s.Table,{stickyHeader:!0,size:f?"small":"medium",children:[t.jsxRuntimeExports.jsx(Eo,{columns:e,sorting:o,sortBy:r,sortDirection:i,onSort:D}),t.jsxRuntimeExports.jsx(vo,{columns:e,rows:n,onRowClick:h})]})}),x&&t.jsxRuntimeExports.jsx(fo,{ref:w,rowsPerPageOptions:y,labelRowsPerPage:E.formatMessage({id:"c4r.widgets.table.rowsPerPage"}),labelDisplayedRows:M,component:"div",count:c,rowsPerPage:u,page:d,onPageChange:C,onRowsPerPageChange:P,ActionsComponent:()=>t.jsxRuntimeExports.jsx(B.TablePaginationActions,{count:c,rowsPerPage:u,page:d,onPageChange:C,lastPageTooltip:R})})]})}function Eo({columns:e,sorting:n,sortBy:o,sortDirection:r,onSort:i}){return t.jsxRuntimeExports.jsx(s.TableHead,{children:t.jsxRuntimeExports.jsx(s.TableRow,{children:e.map(({field:a,headerName:l,align:x})=>t.jsxRuntimeExports.jsx(s.TableCell,{align:x??"left",children:n?t.jsxRuntimeExports.jsx(xo,{active:o===a,direction:o===a?r:"asc",onClick:()=>i(a),children:l??a}):l??a},a))})})}function Ro(e,n){var r;const o=(r=Object.entries(e).find(([i])=>i.toUpperCase()===n.toUpperCase()))==null?void 0:r[1];return typeof o=="bigint"?o.toString():Array.isArray(o)?`[${o.map(a=>typeof a=="string"?`"${a}"`:String(a)).join(", ")}]`:typeof o=="object"&&o!==null?JSON.stringify(o):o}function vo({columns:e,rows:n,onRowClick:o}){return t.jsxRuntimeExports.jsx(s.TableBody,{children:n.map((r,i)=>{const a=String(r.cartodb_id||r.id||i);return t.jsxRuntimeExports.jsx(mo,{hover:!!o,onClick:()=>o&&o(r),children:e.map(({field:l,headerName:x,align:c,component:d})=>{const m=Ro(r,l);return(x??l)&&t.jsxRuntimeExports.jsx(go,{scope:"row",align:c??"left",children:d?d(m):m},`${a}_${l}`)})},a)})})}function Zt(e,n,o,r,i){const a=Array.isArray(e)?e:[e],[l]=a[0].data,x=new Date(l);return`<div style='minWidth: 160px;'>
8
- <p style='font-weight: 600; line-height: 1; margin: 4px 0;'>${Jt({date:x,stepMultiplier:r,stepSize:n})}</p>
9
- ${a.reduce((d,m)=>{if(m.value!==void 0&&m.value!==null){const u=`<div style='display: flex; flex-direction: row; align-items: center; justify-content: spread; height: 20px; gap: 8px;'>
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),u=require("react"),o=require("@mui/material"),J=require("react-intl"),B=require("../Alert-FPd1YXw5.cjs"),vn=require("echarts-for-react"),$=require("../theme-constants-Da63svSG.cjs"),Re=require("../search-icon-CyudR_26.cjs"),xe=require("@mui/icons-material"),Te=require("../paletteUtils-DLQVT9qo.cjs"),Lt=require("@mui/material/styles"),jn=require("@mui/icons-material/KeyboardArrowDown"),wn=require("@mui/icons-material/Close"),bn=require("@mui/icons-material/LayersOutlined"),Sn=require("@mui/icons-material/VisibilityOutlined"),In=require("@mui/icons-material/VisibilityOffOutlined"),kn=require("@mui/icons-material/ExpandMore"),Mn=require("@mui/icons-material/ExpandLess");function Dt(){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 ne(e){return!e||typeof e!="object"?e:`${e.prefix??""}${e.value}${e.suffix??""}`}const Tn=[],Cn={},at=e=>e;function An(e,n){if(!e||Array.isArray(e)&&e.length===0)return null;const r=Array.isArray(e)?e:[e];let i="";return i+=String(r[0].axisValueLabel),i+=r.map(({seriesName:s,value:l,data:a,marker:p})=>{const c=s?s+": ":"",g=ne(n(Number(l))),h=a,d=`<div style="margin-left: 8px; display: inline">
2
+ ${c}${g}${String((h==null?void 0:h.unit)||"")}
3
+ </div>`;return`<div style="margin-top: 4px">${String(p)}${d}</div>`}).join(" "),i}function En({height:e,labels:n=Cn,yAxisData:r,selectedBars:i=Tn,series:s,colors:l,tooltip:a=!0,tooltipFormatter:p=An,xAxisFormatter:c=at,yAxisFormatter:g=at,onSelectedBarsChange:h,animation:d=!0,filterable:v=!0,stacked:f=!0,...m}){const y=o.useTheme(),x=u.useMemo(()=>(s??[]).map(S=>n[S]??S),[s,n]),b=u.useMemo(()=>Array.isArray(r[0])?r:[r],[r]),w=u.useMemo(()=>typeof l=="string"?[l]:Array.isArray(l)&&l.length?l:b.length<=1||x.length===1?[y.palette.secondary.main]:b.length===2||x.length===2?[y.palette.secondary.light,y.palette.secondary.dark]:Object.values(y.palette.qualitative.bold||{}),[l,y,b,x]);return{...m,tooltip:a,tooltipFormatter:p,xAxisFormatter:c,yAxisFormatter:g,onSelectedBarsChange:h,animation:d,filterable:v,stacked:f,labels:n,height:e??parseInt(y.spacing(22)),selectedBars:Bn(i),yAxisData:b,colors:w,series:x}}function Bn(e){return(e??[]).length?e.map(n=>Array.isArray(n)&&n.length===2?n:Array.isArray(n)?[...Array(2)].map((i,s)=>n[s]??0):[n,0]):[]}var Pn=function e(n,r){if(n===r)return!0;if(n&&r&&typeof n=="object"&&typeof r=="object"){if(n.constructor!==r.constructor)return!1;var i,s,l;if(Array.isArray(n)){if(i=n.length,i!=r.length)return!1;for(s=i;s--!==0;)if(!e(n[s],r[s]))return!1;return!0}if(n.constructor===RegExp)return n.source===r.source&&n.flags===r.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===r.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===r.toString();if(l=Object.keys(n),i=l.length,i!==Object.keys(r).length)return!1;for(s=i;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,l[s]))return!1;for(s=i;s--!==0;){var a=l[s];if(!e(n[a],r[a]))return!1}return!0}return n!==n&&r!==r};const me=$.getDefaultExportFromCjs(Pn);class ve extends vn{componentDidUpdate(n){const{shouldSetOption:r}=this.props;if(typeof r=="function"&&!r(n,this.props))return;if(!me(n.theme,this.props.theme)||!me(n.opts,this.props.opts)){this.dispose(),this.renderNewEcharts();return}const i=this.getEchartsInstance();me(n.onEvents,this.props.onEvents)||(this.offEvents(i,n.onEvents),this.bindEvents(i,this.props.onEvents));const s=["option","notMerge","lazyUpdate","showLoading","loadingOption"];me(ct(this.props,s),ct(n,s))||this.updateEChartsOption(),(!me(n.style,this.props.style)||!me(n.className,this.props.className))&&this.resize()}updateEChartsOption(){const n=this.props.option,r=this.props.loadingOption||null,{lazyUpdate:i,showLoading:s}=this.props,l=this.getEchartsInstance();return l.setOption(n,{replaceMerge:["series"],lazyUpdate:i}),s?l.showLoading(r):l.hideLoading(),l}offEvents(n,r){if(r)for(const i in r)typeof i=="string"&&n.off(i)}}function ct(e,n){const r={};return n.forEach(i=>{r[i]=e[i]}),r}const He=240,Nt=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)"}})),Rt=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]}`})),we=o.styled(o.Skeleton)(({theme:e})=>({flex:1,maxWidth:e.spacing(12),"& + &":{marginLeft:e.spacing(1)}})),oe=o.styled(o.Skeleton)(({theme:e})=>({flex:1,maxWidth:e.spacing(8),"& + &":{marginLeft:"1px"}})),Ln=o.styled(o.Skeleton)(({theme:e})=>({backgroundColor:e.palette.common.white})),dt=o.styled(o.Skeleton)(({theme:e})=>({backgroundColor:e.palette.grey[100]}));function Dn({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(Nt,{style:{height:e||He},children:[t.jsx(we,{variant:"rectangular",height:"20%"}),t.jsx(we,{variant:"rectangular",height:"40%"}),t.jsx(we,{variant:"rectangular",height:"60%"}),t.jsx(we,{variant:"rectangular",height:"20%"}),t.jsx(we,{variant:"rectangular",height:"80%"})]})]})}function de(e){const[n,r]=u.useState(!1),[i,s]=u.useState(!1);return u.useEffect(()=>{e&&!i&&(r(!0),s(!0)),e||r(!1)},[e,i]),{showSkeleton:n}}const Nn=Dt(),Rn=o.styled(o.Grid)(({theme:e})=>({marginBottom:e.spacing(2),flexDirection:"row",justifyContent:"space-between",alignItems:"center","& .MuiTypography-caption":{color:e.palette.text.secondary}})),$n=o.styled(o.Link)(({theme:e})=>({...e.typography.caption,cursor:"pointer"}));function On(e){const{yAxisData:n,xAxisData:r,series:i,selectedBars:s,onSelectedBarsChange:l,tooltip:a,tooltipFormatter:p,labels:c,colors:g,xAxisFormatter:h,yAxisFormatter:d,stacked:v,height:f,filterable:m,animation:y,isLoading:x}=En(e),b=i.length>1,w=o.useTheme(),S=J.useIntl(),I=B.useImperativeIntl(S),{showSkeleton:j}=de(!!x),T=u.useMemo(()=>({show:a,trigger:"axis",padding:[parseInt(w.spacing(.5)),parseInt(w.spacing(1))],borderWidth:0,textStyle:{...w.typography.caption,fontSize:11,color:w.palette.common.white},backgroundColor:w.palette.black[90],position:function(M,R,z,F,Y){const q={top:0};return Y.contentSize[0]<Y.viewSize[0]-M[0]?q.left=M[0]:q.right=Y.viewSize[0]-M[0],q},formatter:M=>p(M,d)}),[w,a,p,d]),C=u.useMemo(()=>r.map(M=>ne(h(c[M]??String(M)))),[r,c,h]),D=u.useMemo(()=>({type:"category",axisLine:{show:!1},axisTick:{show:!1},axisLabel:{...w.typography.overlineDelicate,padding:[parseInt(w.spacing(.5)),0,0,0]},data:C}),[w,C]),E=u.useMemo(()=>{let M=[];return v?M=n.reduce((R,z)=>(z.forEach((F,Y)=>R[Y]=(R[Y]??0)+(F??Number.MIN_SAFE_INTEGER)),R),[]):M=n.flat().map(R=>R??Number.MIN_SAFE_INTEGER),Math.max(...M)},[n,v]),P=u.useMemo(()=>({type:"value",axisLabel:{margin:0,verticalAlign:"bottom",padding:[0,0,parseInt(w.spacing(1.25)),0],show:!0,showMaxLabel:!0,showMinLabel:!1,inside:!0,color:M=>M>=E?w.palette.black[60]:"transparent",...w.typography.overlineDelicate,formatter:M=>ne(d(M))},axisLine:{show:!1},axisTick:{show:!1},splitLine:{show:!0,onZero:!1,lineStyle:{color:w.palette.black[4]}}}),[w,E,d]),L=u.useMemo(()=>n.map((M,R)=>({type:"bar",name:i[R]??"",animation:y,barMaxWidth:100,data:M.map((z,F)=>{const Y=s.some(([W,V=0])=>W===F&&V===R),q=!!s.length&&!Y;return{value:z,...q&&{itemStyle:{color:w.palette.black[25]},disabled:!0}}}),...v&&{stack:"total"},...!Nn&&{emphasis:{focus:"series",itemStyle:{color:o.darken(g[R]??"#000",.25)}}}})),[y,g,i,n,s,v,w]),N=u.useMemo(()=>({grid:{left:C.length>=4?ut(String(C[0]),C.length):0,top:parseInt(w.spacing(2)),right:C.length>=4?ut(String(C[C.length-1]),C.length):0,bottom:0,containLabel:!0},axisPointer:{lineStyle:{color:w.palette.black[40]}},color:g,tooltip:T,xAxis:D,yAxis:P,series:L}),[C,w,g,T,D,P,L]),H=()=>{l&&l([],[])},G=M=>{M.key==="Enter"&&H()},k=u.useCallback(M=>{if(l){const R=[...s],{dataIndex:z,componentIndex:F}=M,Y=R.findIndex(([W,V=0])=>z===W&&F===V);Y===-1?R.push([z,F]):R.splice(Y,1);const q=R.map(([W,V=0])=>({xAxis:r[W],serie:i[V],yAxis:n[V][W]}));l(b?R:R.map(W=>W[0]),q)}},[n,l,s,r,i,b]),O=u.useMemo(()=>m?{click:k}:{},[m,k]);return j?t.jsx(Dn,{height:f}):t.jsxs("div",{children:[l&&t.jsxs(Rn,{container:!0,children:[t.jsx(B.Typography,{variant:"caption",children:s.length>0?I.formatMessage({id:"c4r.widgets.bar.selectedItems"},{items:s.length}):I.formatMessage({id:"c4r.widgets.bar.all"})}),s&&s.length>0&&t.jsx($n,{onClick:()=>H(),onKeyDown:G,underline:"hover",tabIndex:0,children:I.formatMessage({id:"c4r.widgets.bar.clear"})})]}),!!N&&t.jsx(ve,{option:N,lazyUpdate:!0,notMerge:!0,onEvents:O,style:{height:f}})]})}function ut(e="",n=0){return n<=15&&e.length<=8?0:e.length*8.5/6}const pe="__rest__",ye="Others";var ge=(e=>(e.RANKING="ranking",e.FIXED="fixed",e))(ge||{});const $t=o.styled(o.Grid)(({theme:e})=>({maxHeight:e.spacing(40),overflow:"auto",padding:0})),Ot=o.styled(o.Grid,{shouldForwardProp:e=>e!=="selectable"&&e!=="name"&&e!=="unselected"})(({theme:e,selectable:n,name:r,unselected:i})=>({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`},...i&&{color:e.palette.text.disabled,".progressbar div":{backgroundColor:e.palette.text.disabled}},...r!==pe&&n&&{cursor:"pointer",flexWrap:"nowrap","&:hover .progressbar div":{backgroundColor:e.palette.secondary.dark}},...r===pe&&{cursor:"default",".progressbar div":{backgroundColor:e.palette.text.disabled}}})),pt=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}})),Fn=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`}})),Wn=o.styled(o.Grid,{shouldForwardProp:e=>e!=="isSelectable"})(({theme:e,isSelectable:n})=>({...n&&{width:`calc(100% - ${e.spacing(4)})`}})),_n=o.styled(B.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)}})),Gn=o.styled(o.Box)(({theme:e})=>({...e.typography.body2})),gt=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)}})),Hn=o.styled(o.Skeleton)(({theme:e})=>({marginTop:e.spacing(1.25),marginBottom:e.spacing(1.75)})),zn=e=>e%2===1,Ft=()=>t.jsxs(t.Fragment,{children:[t.jsx(o.Skeleton,{width:48,height:8}),t.jsx($t,{container:!0,mt:3,children:[...Array(6)].map((e,n)=>t.jsxs(Ot,{container:!0,spacing:1,children:[t.jsxs(o.Grid,{container:!0,item:!0,direction:"row",justifyContent:"space-between",children:[t.jsx(o.Skeleton,{width:zn(n)?72:48,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]}),t.jsx(Hn,{height:4,width:"100%"})]},n))})]});function Wt(e){const n=u.useRef();return u.useEffect(()=>{n.current=e}),n.current}function Xe({start:e,end:n,duration:r,drawFrame:i,requestRef:s}){if(e===n&&!(e===0&&n===0))return;const a=n-e;let p=e;const c=a/(r/1e3*60),g=()=>{p+=c,i(Math.floor(p)),c>0&&p<n||c<0&&p>n?s.current=requestAnimationFrame(g):i(n)};s.current=requestAnimationFrame(g)}function Yn({start:e,end:n,duration:r,drawFrame:i,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)){i(n);return}const h=r/1e3*60,d=c.map(f=>f/h),v=()=>{p<h?(a=a.map((f,m)=>{const y=Math.floor(f.value+d[m]),x=m>0&&Math.floor(f.value+d[m-1]);return{...f,value:y===x?n[m].value:y}}),i(a),p++,s.current=requestAnimationFrame(v)):i(n)};s.current=requestAnimationFrame(v)}const Vn=[],Un={},qn=e=>e,qe=()=>{};function Kn({data:e,formatter:n=qn,labels:r=Un,maxItems:i=5,order:s=ge.RANKING,selectedCategories:l=Vn,onSelectedCategoriesChange:a=qe,animation:p=!0,filterable:c=!0,searchable:g=!0,isLoading:h}){const[d,v]=u.useState([]),[f,m]=u.useState(1),[y,x]=u.useState(!1),[b,w]=u.useState(""),[S,I]=u.useState([]),[j,T]=u.useState([]),[C,D]=u.useState([]),E=u.useRef(null),P=u.useRef(),L=Wt(C),N=u.useRef([]),{showSkeleton:H}=de(!!h),G=J.useIntl(),k=B.useImperativeIntl(G);function O(A){return d.reduce((U,Z)=>(A.includes(Z.name)&&U.push(Z.name),U),[])}function M(A){if(A!==pe){let U;l.includes(A)?U=l.filter(Z=>Z!==A):U=[...l,A],a&&a(U)}}const R=()=>a([]),z=A=>{A.key==="Enter"&&R()},F=()=>{a([]),I([])},Y=A=>{A.key==="Enter"&&F()},q=()=>{I(O(l))},W=A=>{A.key==="Enter"&&q()},V=()=>{const A=O(j);a([...A]),I([...A]),T([]),x(!1),w("")},ee=A=>{A.key==="Enter"&&V()},ue=()=>{w(""),x(!1)},ie=A=>{if(A!==pe){let U;j.includes(A)?U=j.filter(Z=>Z!==A):U=[...j,A],T(U)}},_=A=>{A.currentTarget.scrollIntoView()},K=A=>{w(A.currentTarget.value)},X=()=>{x(!0),T([...l])},Q=u.useCallback(A=>{if(y)return b?A.filter(U=>{var te;if(!U.name)return!1;const Z=String(U.name);return!!(Z.toLowerCase().includes(b.toLowerCase())||(te=r[Z])!=null&&te.toLowerCase().includes(b.toLowerCase()))}):A;if(S.length)return S.reduce((Z,te)=>{const he=A.find(le=>le.name===te);return Z.push({name:te,value:he?he.value:null}),Z},[]);{const U=A.slice(0,i);if(U.length<A.length){const Z=A.slice(i).reduce((te,he)=>(he.value!==null&&te.value!==null&&(te.value+=he.value),te),{name:pe,value:0});return[...U,Z]}else return U}},[S,r,i,b,y]),se=u.useCallback(()=>{const A=S.length;return A?e.length-A:e.length-i},[e,i,S]),Ce=u.useCallback(A=>A===pe?`Others ${g?"":`(${se()})`}`:r[String(A)]??String(A),[se,r,g]),je=u.useCallback(A=>A>=f?A!=null?"100%":0:`${(A||0)*100/f}%`,[f]);u.useEffect(()=>{l.length===0&&I([])},[l]),u.useEffect(()=>{if(e){if(s===ge.RANKING){const A=[...e].sort((Z,te)=>(te.value??0)-(Z.value??0)),U=Q(A);U.length>0?m(U[0].value??0):m(1),v(U)}else if(s===ge.FIXED){m(Math.max(...e.map(U=>U.value??0)));const A=Q(e);v(A)}}},[S,Q,e,r,i,s,b,y]),u.useEffect(()=>{L&&(N.current=L)},[L]),u.useEffect(()=>{if(p)return Yn({start:(N.current||[]).map(A=>({...A,value:A.value??0})),end:d.map(A=>({...A,value:A.value??0})),duration:500,drawFrame:A=>D(A),requestRef:E}),()=>{E.current&&cancelAnimationFrame(E.current)};D(d)},[p,d]),u.useEffect(()=>{y&&P.current&&P.current.focus()},[y,P]);function xn({data:A,onCategoryClick:U}){const Z=n(A.value??0),[te,he]=u.useState(!1),le=u.useRef(null),Ve=()=>{var st,lt;const Ue=(((st=le==null?void 0:le.current)==null?void 0:st.scrollWidth)??0)>(((lt=le==null?void 0:le.current)==null?void 0:lt.clientWidth)??0);he(Ue)};u.useEffect(()=>(Ve(),window.addEventListener("resize",Ve),()=>{window.removeEventListener("resize",Ve)}),[]);const mn=Ue=>{Ue.key==="Enter"&&U()},yn=!y&&l.length>0&&!l.includes(A.name);return t.jsxs(Ot,{container:!0,direction:"row",spacing:1,onClick:c?U:qe,onKeyDown:c?mn:qe,selectable:c,unselected:yn,name:A.name===pe?pe:"",tabIndex:c?0:-1,children:[c&&y&&t.jsx(o.Grid,{item:!0,mr:1,children:t.jsx(o.Checkbox,{checked:j.includes(A.name),tabIndex:-1})}),t.jsxs(Wn,{container:!0,item:!0,xs:!0,isSelectable:y,children:[t.jsxs(o.Grid,{container:!0,item:!0,direction:"row",justifyContent:"space-between",wrap:"nowrap",children:[t.jsx(o.Tooltip,{title:Ce(A.name),disableHoverListener:!te,children:t.jsx(_n,{variant:"body2",noWrap:!0,ref:le,children:Ce(A.name)})}),typeof Z=="object"&&Z!==null?t.jsxs("span",{children:[Z.prefix,Z.value,Z.suffix]}):t.jsx("span",{children:Z})]}),t.jsx(Fn,{className:"progressbar",item:!0,children:t.jsx("div",{style:{width:je(A.value??0)}})})]})]})}return(e==null?void 0:e.length)===0||H?t.jsx(Ft,{}):t.jsxs(Gn,{children:[c&&d.length>0&&t.jsxs(pt,{container:!0,children:[t.jsx(B.Typography,{variant:"caption",children:l.length>0?k.formatMessage({id:"c4r.widgets.category.selectedItems"},{items:l.length}):k.formatMessage({id:"c4r.widgets.category.all"})}),y?t.jsx(Ae,{onClick:V,onKeyDown:ee,underline:"hover",tabIndex:0,"data-testid":"primaryApplyButton",children:k.formatMessage({id:"c4r.widgets.category.apply"})}):S.length>0?t.jsx(Ae,{onClick:F,onKeyDown:Y,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:q,onKeyDown:W,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:z,underline:"hover",tabIndex:0,children:k.formatMessage({id:"c4r.widgets.category.clear"})})]})]}),e.length>i&&y&&t.jsxs(pt,{container:!0,children:[t.jsx(o.TextField,{size:"small",sx:{mt:-.5},placeholder:k.formatMessage({id:"c4r.widgets.category.search"}),onChange:K,onFocus:_,InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx(Re.SearchIcon,{})})},inputProps:{tabIndex:0,ref:P}}),t.jsx(gt,{size:"small",onClick:ue,children:k.formatMessage({id:"c4r.widgets.category.cancel"})})]}),t.jsx($t,{container:!0,item:!0,children:C.length?C.map((A,U)=>t.jsx(xn,{data:A,onCategoryClick:()=>y?ie(A.name):M(A.name)},U)):t.jsxs(o.Box,{children:[t.jsx(B.Typography,{variant:"body2",children:k.formatMessage({id:"c4r.widgets.category.noResults"})}),t.jsx(B.Typography,{component:"p",variant:"caption",mb:2,children:k.formatMessage({id:"c4r.widgets.category.noResultsMessage"},{searchValue:b})})]})}),y&&t.jsx(gt,{size:"small",onClick:V,children:k.formatMessage({id:"c4r.widgets.category.apply"})}),e.length>i&&g?y?t.jsx(o.Box,{mt:1.5,children:t.jsx(o.Button,{size:"small",color:"primary",onClick:ue,"data-testid":"primaryCancelButton",children:k.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(Re.SearchIcon,{}),onClick:X,children:k.formatMessage({id:"c4r.widgets.category.searchInfo"},{elements:se()})})}):null]})}const _t=()=>t.jsx(o.Box,{pt:.5,children:t.jsx(o.Skeleton,{height:24,width:120})}),Zn=o.styled("span")(()=>({marginRight:"2px"})),Xn=o.styled("span")(()=>({marginLeft:"2px"})),Ee="-",Jn=e=>e;function Qn({data:e=Ee,formatter:n=Jn,animation:r=!0,isLoading:i=!1}){const[s,l]=u.useState(Ee),a=u.useRef(null),p=Wt(s),c=u.useRef(p),{showSkeleton:g}=de(!!i);u.useEffect(()=>(typeof e=="number"&&r?Xe({start:c.current||0,end:e,duration:500,drawFrame:f=>l(f),requestRef:a}):typeof e=="object"&&r&&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)}),[r,e,l]);const h=n(s),d=typeof h=="object"&&h!==null,v=h===Ee;return g?t.jsx(_t,{}):d?t.jsxs(B.Typography,{variant:"h5",component:"div",weight:"medium",children:[t.jsx(Zn,{children:h.prefix}),h.value,t.jsx(Xn,{children:h.suffix})]}):t.jsx(B.Typography,{variant:"h5",component:"div",weight:"medium",color:v?"text.disabled":"default",whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",children:h})}const ht={};let be=null;function eo({data:e,filterable:n,selectedBars:r,onSelectedBarsChange:i,echartsInstance:s}){const l=o.useTheme(),[a,p]=u.useState([]),c=u.useMemo(()=>s==null?void 0:s.getZr(),[s]);u.useEffect(()=>{function h(v){if(s){const[f]=s.convertFromPixel({seriesIndex:0},[v.offsetX,v.offsetY]);be=f??null}}function d(v){if(s&&be!==null){const[f]=s.convertFromPixel({seriesIndex:0},[v.offsetX,v.offsetY]);p(be===f?[]:[be,f].sort((m,y)=>m-y))}}if(s&&n){const v=Ke(c,"mousedown",h),f=Ke(c,"mousemove",d);return()=>{v==null||v(),f==null||f()}}},[c,s,n]),u.useEffect(()=>{function h(){if(a.length===2&&i){const d=e.reduce((v,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])&&v.push(m),v),[]);i(e.length===d.length?[]:d)}p([]),be=null}if(s&&n)return Ke(c,"mouseup",h)},[c,s,a,e,i,n]);const g=u.useCallback(h=>{if(i){const d=new Set(r);d.has(h.dataIndex)?d.delete(h.dataIndex):d.add(h.dataIndex),i(d.size===e.length?[]:Array.from(d))}},[i,r,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 Ke(e,n,r){if(e!=null&&e.handler)return ht[n]=r,e.on(n,r),()=>{ht[n]&&(e!=null&&e.handler)&&e.off(n,r)}}function to({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(Rt,{style:{height:e??He},children:[t.jsx(oe,{variant:"rectangular",height:"20%"}),t.jsx(oe,{variant:"rectangular",height:"40%"}),t.jsx(oe,{variant:"rectangular",height:"60%"}),t.jsx(oe,{variant:"rectangular",height:"20%"}),t.jsx(oe,{variant:"rectangular",height:"80%"}),t.jsx(oe,{variant:"rectangular",height:"50%"}),t.jsx(oe,{variant:"rectangular",height:"20%"}),t.jsx(oe,{variant:"rectangular",height:"40%"}),t.jsx(oe,{variant:"rectangular",height:"60%"}),t.jsx(oe,{variant:"rectangular",height:"20%"}),t.jsx(oe,{variant:"rectangular",height:"80%"}),t.jsx(oe,{variant:"rectangular",height:"50%"})]})]})}const no=Dt(),oo=o.styled(o.Grid)(({theme:e})=>({marginBottom:e.spacing(2),flexDirection:"row",justifyContent:"space-between",alignItems:"center","& .MuiTypography-caption":{color:e.palette.text.secondary}})),ro=o.styled(o.Link)(({theme:e})=>({...e.typography.caption,cursor:"pointer"})),io=[],so=()=>{},$e=e=>e;function lo(e,n=$e,r=$e){if(!e)return null;if(Array.isArray(e)&&e.length===0)return;const i=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=ne(n(l)),g=ne(n(a)),h=ne(r(p)),d=`${c} <span style="vertical-align: 1px;">—</span> ${g}`,v=`<div style="margin-left: 8px; display: inline">${h}</div>`;return`${d} <div style="margin-top: 4px">${String(i)}${v}</div>`}function ao({data:e,ticks:n,min:r,max:i,xAxisFormatter:s=$e,yAxisFormatter:l=$e,yAxisType:a="dense",selectedBars:p=io,onSelectedBarsChange:c=so,tooltip:g=!0,tooltipFormatter:h=lo,animation:d=!0,filterable:v=!0,height:f=200,isLoading:m}){const y=J.useIntl(),x=o.useTheme(),b=B.useImperativeIntl(y),{showSkeleton:w}=de(!!m),S=!!v&&!!c,[I,j]=u.useState(),T=M=>j(M),C=u.useMemo(()=>po(e,n,r,i),[e,n,r,i]),{onEvents:D,markAreaOptions:E}=eo({data:C,filterable:S,selectedBars:p,onSelectedBarsChange:c,echartsInstance:I}),P=u.useMemo(()=>({show:g,trigger:"item",padding:[$.SPACING*.5,$.SPACING],borderWidth:0,textStyle:{...x.typography.caption,fontSize:11,color:x.palette.common.white},backgroundColor:x.palette.black[90],confine:!0,position:"top",formatter(M){return h(M,s,l)}}),[x,g,h,s,l]),L=u.useMemo(()=>({min:r,max:i,interval:(i-r)/C.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:[$.SPACING*.5,$.SPACING*.5,0,$.SPACING*.5],formatter:M=>{const R=ne(s(M));return M===r?co(R):M===i?uo(R):R},color:x.palette.black[60]}}),[r,i,C.length,x,s]),N=u.useMemo(()=>{const M={margin:0,verticalAlign:"bottom",padding:[0,0,$.SPACING*1.25,0],inside:!0,color:F=>{const Y=Math.max(...e.map(W=>W??Number.MIN_SAFE_INTEGER))||1;let q="transparent";return F>=Y&&(q=x.palette.black[60]),q},...x.typography.overlineDelicate,formatter:F=>ne(l(F))},R={verticalAlign:"middle",padding:[0,0,0,$.SPACING*.5],color:x.palette.black[60]},z=a==="dense"?M:R;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,...z,...x.typography.overlineDelicate,formatter:F=>ne(l(F))}}},[x.palette.black,x.typography.overlineDelicate,e,l,a]),H=u.useMemo(()=>{const M=r===i&&C.filter(F=>F[2]!==0).length===1,z=(M?[C[0],C[C.length-1]]:C).map((F,Y)=>{const W=p.length&&!p.includes(Y)?x.palette.black[25]:x.palette.secondary.main;return{value:F,itemStyle:{color:W}}});return{type:"custom",cursor:"pointer",markArea:E,renderItem:function(F,Y){const q=F.dataIndex===C.length-1,W=F.dataIndex===0,V=z[F.dataIndex].itemStyle.color,ee=Y.value(0),ue=Y.value(1),ie=Y.value(2),[_,K]=Y.coord([ee,ie]),[X,Q]=Y.size([ue-ee,ie]);return{type:"rect",shape:{x:M?_/10:_+(W?0:1),y:K,width:M?_-_/10:X-(q?0:1),height:Q},style:{fill:V},...!no&&{emphasis:{style:{fill:o.darken(V,.25)}}}}},encode:{x:[0,1],y:2,tooltip:[0,1,2]},data:z,animation:d}},[r,i,C,E,x.palette.black,x.palette.secondary.main,p,d]),G=u.useMemo(()=>({grid:{left:$.SPACING*.1,right:$.SPACING*.1,top:$.SPACING*2,bottom:$.SPACING*.5,containLabel:!0},tooltip:P,xAxis:L,yAxis:N,series:[H]}),[P,L,N,H]),k=p.reduce((M,R)=>M+=e[R]??0,0),O=M=>{M.key==="Enter"&&c([])};return w?t.jsx(to,{height:f}):t.jsxs("div",{children:[S&&t.jsxs(oo,{container:!0,children:[t.jsx(B.Typography,{variant:"caption",weight:"strong",children:p.length>0?b.formatMessage({id:"c4r.widgets.histogram.selectedItems"},{items:ne(l(k))}):b.formatMessage({id:"c4r.widgets.histogram.all"})}),p.length>0&&t.jsx(ro,{onClick:()=>c([]),onKeyDown:O,underline:"hover",tabIndex:0,children:b.formatMessage({id:"c4r.widgets.histogram.clear"})})]}),t.jsx(ve,{option:G,onEvents:D,lazyUpdate:!0,onChartReady:T,style:{maxHeight:f}})]})}function co(e){return`${Array(String(e).length).fill(" ").join("")}${e}`}function uo(e){const n=Array(String(e).length).fill(" ").join("");return`${e}${n}`}function po(e,n,r,i){return e.map((s,l)=>[l===0?r:n[l-1],l===e.length-1?i:n[l],s])}function go(e,n,r,i){const s=o.useTheme(),l=u.useMemo(()=>n===ge.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<r?c.push({...h}):g+=h.value??0;return g>0&&c.push({name:ye,value:g,emphasis:{scale:!1}}),c},[r,l]);return u.useMemo(()=>{const c=s.palette.common.white;return a.map((g,h)=>{let d=c;if(i.length){const f=i[h%i.length];f&&(d=f)}else{const m=s.palette.qualitative.bold[h];m&&(d=m)}const v=g;return v.color=d,v})},[a,i,s])}const ho=o.styled(o.Box)(({theme:e})=>({zIndex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",paddingBottom:e.spacing(1)})),fo=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1),maxWidth:"140px",textTransform:"uppercase"})),xo=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 mo({data:e,selectedCategories:n,formatter:r}){const[i,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=yo(g),d=g.find(m=>m===h);if(!d)return null;let v=0;for(const m of e)v+=m.value??0;const f=vo(d.value??0,v,r);return{...d,percentage:f}},[e,n,r]);u.useEffect(()=>{l&&s(l)},[l,s]);const{name:a,percentage:p,color:c}=i??{};return i?t.jsxs(ho,{children:[t.jsx(B.Typography,{variant:"h5",children:p}),t.jsxs(fo,{children:[t.jsx(xo,{bgcolor:c,component:"span"}),t.jsx(B.Typography,{component:"span",variant:"body2",noWrap:!0,children:a})]})]}):null}function yo(e){const n=e.filter(r=>r.name!==ye);return n.length===0?e[0]:n.reduce((r,i)=>(i.value??0)>(r.value??0)?i:r)}function vo(e,n,r){let i=0;return n!==0&&(i=e/n*100),r?r(i):`${i}%`}const ft=32,jo=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",marginTop:e.spacing(.5)})),wo=o.styled("div")(()=>({display:"flex",alignItems:"center",justifyContent:"center",position:"relative"})),bo=o.styled(Ln)(()=>({position:"absolute",zIndex:1})),So=o.styled("div")(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",gap:e.spacing(1),position:"absolute",zIndex:2})),Io=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(2),height:e.spacing(5)})),ko=o.styled("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5)}));function Gt({height:e}){const n=parseInt(String(e),10)||He,r=n-ft,i=r-ft;return t.jsxs(o.Box,{mt:.5,children:[t.jsx(o.Skeleton,{height:8,width:64}),t.jsx(jo,{height:n,children:t.jsxs(wo,{children:[t.jsx(o.Skeleton,{variant:"circular",width:r,height:r}),t.jsx(bo,{variant:"circular",width:i,height:i}),t.jsxs(So,{children:[t.jsx(o.Skeleton,{height:24,width:72}),t.jsx(o.Skeleton,{height:8,width:48})]})]})}),t.jsx(Io,{children:[...Array(2)].map((s,l)=>t.jsxs(ko,{children:[t.jsx(o.Skeleton,{variant:"circular",width:8,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]},l))})]})}const Mo=o.styled(o.Box)(({theme:e})=>({position:"relative",padding:e.spacing(1.25,1,0,1),width:"100%"})),To=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)})),Co=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(1),alignItems:"center",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"})),Ao=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%)`})),Eo=o.styled(o.Box)(({theme:e})=>({position:"absolute",padding:e.spacing(.25,1),top:e.spacing(0),right:0,background:e.palette.background.paper})),Bo=o.styled(o.Box,{shouldForwardProp:e=>e!=="color"})(({theme:e,color:n})=>{const r=e.spacing(1);return{backgroundColor:n,borderRadius:"50%",width:r,height:r}});function Ht({series:e,selectedCategories:n,onCategoryClick:r}){var S,I;const i=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),v=u.useRef(null),f=J.useIntl(),m=B.useImperativeIntl(f);function y(){p(a+1)}function x(){p(Math.max(a-1))}function b(j,T){j.key==="Enter"&&(r==null||r(T))}const w=u.useCallback(()=>{var T,C,D;const j=!!d.current&&d.current.scrollWidth>d.current.clientWidth;l(j),g(j&&d.current?(((T=h.current)==null?void 0:T.clientWidth)??0)-(((C=v.current)==null?void 0:C.clientWidth)??70):(((D=h.current)==null?void 0:D.clientWidth)??0)-12||500)},[h,d,v]);return u.useEffect(()=>{w()},[d,(S=d.current)==null?void 0:S.scrollWidth,(I=d.current)==null?void 0:I.clientWidth,w,a]),u.useEffect(()=>{if(typeof ResizeObserver>"u")return;let j;return h.current&&(j=new ResizeObserver(()=>{w()}),j.observe(h.current)),()=>{j==null||j.disconnect()}},[h,w]),t.jsxs(Mo,{ref:h,children:[t.jsx(To,{ref:d,style:{maxWidth:`${c}px`},children:e.map((j,T)=>{if(T<a)return null;const C=n.length===0||n.includes(j.name);return t.jsxs(Co,{tabIndex:0,onClick:r?()=>r(j.name):void 0,onKeyDown:r?D=>b(D,j.name):void 0,style:{pointerEvents:!r||j.name==="Others"?"none":void 0},children:[t.jsx(Bo,{color:C?j.color:i.palette.text.disabled}),t.jsx(B.Typography,{variant:"overline",color:C?void 0:"text.disabled",children:j.name})]},T)})}),(s||a>0)&&t.jsxs(Eo,{ref:v,children:[t.jsx(Ao,{}),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(xe.ChevronLeft,{})})}),t.jsx(o.Tooltip,{title:m.formatMessage({id:"c4r.widgets.chartLegend.prev"}),children:t.jsx(o.IconButton,{size:"small",disabled:!s,onClick:y,children:t.jsx(xe.ChevronRight,{})})})]})]})}const Je="232px",Po=o.styled(o.Grid)(({theme:e})=>({flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:e.spacing(.5)})),Lo=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%"})),Do=o.styled(ve)(()=>({position:"absolute",top:0,right:0,left:0,bottom:0})),xt=[],No={},Ro=e=>e;function $o({name:e,data:n,formatter:r=Ro,tooltipFormatter:i=Oo,percentFormatter:s,height:l=Je,width:a=Je,labels:p=No,colors:c=xt,animation:g=!0,filterable:h=!0,selectedCategories:d=xt,onSelectedCategoriesChange:v,isLoading:f,maxItems:m=11,order:y=ge.RANKING}){const x=o.useTheme(),b=go(n,y,m,c),{showSkeleton:w}=de(!!f),S=J.useIntl(),I=B.useImperativeIntl(S),j=u.useMemo(()=>s||(G=>`${S.formatNumber(G,{maximumFractionDigits:2,minimumFractionDigits:2})}%`),[S,s]),T=u.useMemo(()=>{let G;return i&&(G=k=>i(k,r,j)),{padding:[$.SPACING*.5,$.SPACING],backgroundColor:x.palette.black[90],borderColor:"transparent",textStyle:{color:x.palette.common.white},confine:!0,formatter:G}},[x.palette.black,x.palette.common.white,i,r,j]),C=u.useMemo(()=>[{type:"pie",name:e,animation:g,data:b.map(G=>{const k={...G},O=(d==null?void 0:d.length)&&!d.includes(k.name);return p!=null&&p[k.name]&&(k.name=p[k.name]),O?{...k,disabled:!0,itemStyle:{color:x.palette.black[25]}}:{...k,itemStyle:{color:k.color}}}),radius:["74%","90%"],selectedOffset:0,bottom:$.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:T,legend:{show:!1},series:C}),[T,C]),E=u.useCallback(G=>{if(v){const k=[...d],{name:O}=b[G.dataIndex];if(O===ye)return;const M=k.indexOf(O);M===-1?k.push(O):k.splice(M,1),v(k)}},[b,v,d]),P=u.useCallback(G=>{if(v){const k=[...d],O=k.indexOf(G);O===-1?k.push(G):k.splice(O,1),v(k)}},[v,d]),L={...h&&{click:E}},N=()=>{v==null||v([])},H=G=>{G.key==="Enter"&&N()};return w?t.jsx(Gt,{height:l}):t.jsxs(t.Fragment,{children:[h&&t.jsxs(Po,{container:!0,children:[t.jsx(B.Typography,{variant:"caption",color:"textSecondary",children:d.length?I.formatMessage({id:"c4r.widgets.pie.selectedItems"},{items:d.length}):I.formatMessage({id:"c4r.widgets.pie.allSelected"})}),d.length>0&&t.jsx(o.Link,{variant:"caption",onClick:N,onKeyDown:H,tabIndex:0,children:I.formatMessage({id:"c4r.widgets.pie.clear"})})]}),t.jsxs(Lo,{height:l,width:a,children:[t.jsx(mo,{data:b,selectedCategories:d,formatter:j}),t.jsx(Do,{option:D,onEvents:L,lazyUpdate:!0,style:{height:l,width:a}})]}),b.length>0&&t.jsx(Ht,{series:b,selectedCategories:d,onCategoryClick:v&&P})]})}function Oo(e,n,r){var c;const i=Array.isArray(e)?e[0]:e;if(!i)return null;const s=ne(n(i.value)),l=r(i.percent)||`${i.percent}%`,p=`display:inline-block;border-radius:4px;width:8px;height:8px;background-color:${((c=i.data)==null?void 0:c.color)||i.textStyle.color}`;return`
5
+ <div style="white-space:normal;"><p style="max-width:${Je};font-size:11px;font-weight:500;line-height:1.454;text-transform:uppercase;margin:0 0 4px 0;">${i.name}</p>
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 Fo=o.styled(o.Grid)(({theme:e})=>({position:"relative",alignItems:"center",height:e.spacing(4)})),Wo=o.styled(o.Grid)(({theme:e})=>({position:"absolute",zIndex:1,padding:e.spacing(0,3)}));function _o(){return t.jsxs(o.Grid,{container:!0,children:[t.jsxs(Fo,{container:!0,item:!0,children:[t.jsxs(Wo,{container:!0,item:!0,justifyContent:"space-between",children:[t.jsx(dt,{variant:"circular",width:12,height:12}),t.jsx(dt,{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 Go=o.styled(o.Box)(()=>({position:"relative"})),Ho=o.styled(o.Box)(({theme:{spacing:e}})=>({display:"flex",flexDirection:"row-reverse",height:e(1.5)})),zo=o.styled(o.Link)(()=>({cursor:"pointer"})),mt=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}}})),Yo=o.styled(o.Slider)(({theme:{palette:e}})=>({"& .MuiSlider-rail":{color:e.text.hint}})),Vo=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 Uo({data:e,min:n,max:r,limits:i,onSelectedRangeChange:s,isLoading:l}){const[a,p]=u.useState([n,r]),[c,g]=u.useState([n,r]),h=J.useIntl(),d=B.useImperativeIntl(h),{showSkeleton:v}=de(!!l),f=u.useMemo(()=>{if(!i||i.length!==2)return;if(i[0]===i[1])return[{value:i[0]}];const j=[{value:Math.max(i[0],n)},{value:Math.min(i[1],r)}];if(!(j[0].value>j[1].value))return j},[i,r,n]),m=u.useMemo(()=>s?o.debounce(s,250):null,[s]),y=j=>{g([...j]),p([...j]),m&&m([...j])};function x(j,T){const C=j.target.value===""?"":Number(j.target.value);T===0&&g([C,c[1]]),T===1&&g([c[0],C])}const b=n!==c[0]||r!==c[1];u.useEffect(()=>{e&&(g([...e]),p([...e]))},[e]);function w(j){let T=c[j];T===""&&(T=a[j]),T>r&&(T=r),T<n&&(T=n);const C=j===0?[T,c[1]]:[c[0],T];y(C.sort((D,E)=>D-E))}const S=()=>{y([n,r])};function I(j){j.key==="Enter"&&S()}return v?t.jsx(_o,{}):t.jsxs(Go,{children:[t.jsx(Ho,{children:b&&t.jsx(B.Typography,{variant:"caption",color:"primary",children:t.jsx(zo,{onClick:S,onKeyDown:I,tabIndex:0,component:"button",underline:"hover",children:d.formatMessage({id:"c4r.widgets.range.clear"})})})}),t.jsxs(o.Box,{children:[t.jsx(Yo,{getAriaLabel:j=>j===0?d.formatMessage({id:"c4r.widgets.range.minValue"}):d.formatMessage({id:"c4r.widgets.range.maxValue"}),value:a,min:n,max:r,onChange:(j,T)=>y(T)}),i&&i.length===2&&t.jsx(Vo,{getAriaLabel:j=>j===0?d.formatMessage({id:"c4r.widgets.range.minLimit"}):d.formatMessage({id:"c4r.widgets.range.maxLimit"}),value:i,min:n,max:r,marks:f})]}),t.jsxs(o.Box,{display:"flex",justifyContent:"space-between",mb:1,children:[t.jsx(mt,{value:c[0],size:"small",onChange:j=>x(j,0),onBlur:()=>w(0),inputProps:{min:n,max:r,type:"number","aria-label":d.formatMessage({id:"c4r.widgets.range.minValue"})}}),t.jsx(mt,{value:c[1],size:"small",onChange:j=>x(j,1),onBlur:()=>w(1),inputProps:{min:n,max:r,type:"number","aria-label":d.formatMessage({id:"c4r.widgets.range.maxValue"})}})]})]})}const qo=o.styled(Rt)(({theme:e})=>({flexDirection:"column",alignItems:"center",justifyContent:"center",marginLeft:e.spacing(4),containerType:"inline-size",[`@container (max-width: ${$.BREAKPOINTS.XS}px)`]:{" > div":{maxWidth:"75%"}}})),Ko=o.styled(o.Box)(()=>({position:"relative",display:"flex",justifyContent:"space-between",width:"80%",maxWidth:"50%"}));function Zo({height:e}){function n(){return Math.floor(Math.random()*5)}return t.jsxs(o.Box,{height:e??He,children:[t.jsx(o.Box,{mb:4,children:t.jsx(o.Skeleton,{width:48,height:8})}),t.jsx(qo,{height:"80%",children:[...Array(3)].map((r,i)=>t.jsx(Ko,{ml:i*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))},i))})]})}function Xo(e,n){var c;const r=Array.isArray(e.tooltip)?e.tooltip[0]:e.tooltip,i=Array.isArray(n.tooltip)?n.tooltip[0]:n.tooltip,s=r==null?void 0:r.formatter,l=i==null?void 0:i.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 Jo({tooltipFormatter:e,xAxisFormatter:n=Oe,yAxisFormatter:r=Oe},i){return{grid:{top:10,left:5,bottom:10,right:15,containLabel:!0},tooltip:{padding:[$.SPACING*.5,$.SPACING],textStyle:{...i.typography.caption,fontSize:11,color:i.palette.common.white},backgroundColor:i.palette.black[90],...e?{formatter:e}:{}},color:[i.palette.secondary.main],xAxis:{axisLabel:{...i.typography.overlineDelicate,padding:[$.SPACING*.5,0,0,0],formatter:s=>ne(n(s))}},yAxis:{axisLabel:{...i.typography.overlineDelicate,formatter:s=>ne(r(s))}}}}function Qo({name:e,data:n,animation:r}){return[{type:"scatter",name:e,data:n,animation:r}]}const er=u.memo(ve,(e,n)=>Xo(e.option,n.option)),yt=225,tr=[],Oe=e=>e;function nr({name:e=null,data:n=tr,animation:r=!0,xAxisFormatter:i=Oe,yAxisFormatter:s=Oe,tooltipFormatter:l=or,isLoading:a}){const p=o.useTheme(),c=u.useRef(),[g,h]=u.useState({series:[]}),{showSkeleton:d}=de(!!a);return u.useEffect(()=>{const v=Jo({xAxisFormatter:i,yAxisFormatter:s,tooltipFormatter:l},p),f=Qo({name:e,data:n||[],animation:r});h({...v,series:f})},[n,e,r,p,i,s,l]),d?t.jsx(Zo,{height:yt}):t.jsx(er,{ref:c,option:g,lazyUpdate:!0,style:{height:yt}})}function or(e){const n=Array.isArray(e)?e[0]:e,r=(n==null?void 0:n.value)||[];return`[${r[0]}, ${r[1]})`}function Be({width:e,rows:n=4,index:r=0}){function i(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??i(r),height:8})},l))}const rr=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)})),ir=o.styled(o.TableContainer)(()=>({overflow:"hidden"}));function sr({style:e,dense:n,pagination:r,rowsPerPage:i}){return t.jsxs(t.Fragment,{children:[t.jsx(ir,{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,i??10))].map((s,l)=>t.jsxs(o.TableRow,{children:[t.jsx(Be,{rows:1,width:8}),t.jsx(Be,{index:l})]},l))})]})}),r&&t.jsxs(rr,{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 lr=o.styled(o.TableSortLabel)(({theme:e})=>({...e.typography.caption,color:e.palette.text.secondary})),ar=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}})),cr=o.styled(o.TableCell)(()=>({overflow:"hidden","& p":{maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}})),dr=o.styled(o.TablePagination)(({theme:e})=>({height:e.spacing(6),overflowX:"auto",overflowY:"hidden"})),ur=10,pr=[5,10,25],Se=()=>{};function gr({columns:e,rows:n,sorting:r=!1,sortBy:i,sortDirection:s="asc",onSetSortBy:l=Se,onSetSortDirection:a=Se,pagination:p=!1,totalCount:c,page:g,onSetPage:h=Se,rowsPerPage:d=ur,rowsPerPageOptions:v=pr,onSetRowsPerPage:f=Se,onRowClick:m=Se,height:y,dense:x=!1,isLoading:b,lastPageTooltip:w}){var N;const S=u.useRef(null),I=J.useIntl(),j=B.useImperativeIntl(I),{showSkeleton:T}=de(!!b);function C({from:H,to:G,count:k}){return j.formatMessage({id:"c4r.widgets.table.of"},{from:H,to:G,count:k})}function D(H){a(i===H&&s==="asc"?"desc":"asc"),l(H)}function E(H,G){h(G)}function P(H){f(parseInt(H.target.value,10)),h(0)}const L={height:void 0};if(y){const H=Math.max(((N=S==null?void 0:S.current)==null?void 0:N.clientHeight)??0,p?$.SPACING*6:0);L.height=`calc(${y} - ${H}px)`}return T?t.jsx(sr,{rowsPerPage:d,style:L,dense:x,pagination:p}):t.jsxs(t.Fragment,{children:[t.jsx(o.TableContainer,{style:L,children:t.jsxs(o.Table,{stickyHeader:!0,size:x?"small":"medium",children:[t.jsx(hr,{columns:e,sorting:r,sortBy:i,sortDirection:s,onSort:D}),t.jsx(xr,{columns:e,rows:n,onRowClick:m})]})}),p&&t.jsx(dr,{ref:S,rowsPerPageOptions:v,labelRowsPerPage:j.formatMessage({id:"c4r.widgets.table.rowsPerPage"}),labelDisplayedRows:C,component:"div",count:c,rowsPerPage:d,page:g,onPageChange:E,onRowsPerPageChange:P,ActionsComponent:()=>t.jsx(B.TablePaginationActions,{count:c,rowsPerPage:d,page:g,onPageChange:E,lastPageTooltip:w})})]})}function hr({columns:e,sorting:n,sortBy:r,sortDirection:i,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(lr,{active:r===l,direction:r===l?i:"asc",onClick:()=>s(l),children:a??l}):a??l},l))})})}function fr(e,n){var i;const r=(i=Object.entries(e).find(([s])=>s.toUpperCase()===n.toUpperCase()))==null?void 0:i[1];return typeof r=="bigint"?r.toString():Array.isArray(r)?`[${r.map(l=>typeof l=="string"?`"${l}"`:String(l)).join(", ")}]`:typeof r=="object"&&r!==null?JSON.stringify(r):r}function xr({columns:e,rows:n,onRowClick:r}){return t.jsx(o.TableBody,{children:n.map((i,s)=>{const l=String(i.cartodb_id||i.id||s);return t.jsx(ar,{hover:!!r,onClick:()=>r&&r(i),children:e.map(({field:a,headerName:p,align:c,component:g})=>{const h=fr(i,a);return(p??a)&&t.jsx(cr,{scope:"row",align:c??"left",children:g?g(h):h},`${l}_${a}`)})},l)})})}function zt(e,n,r,i,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;'>${Vt({date:p,stepMultiplier:i,stepSize:n})}</p>
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
- <div style='width: 8px; height: 8px; margin-right: 4px; border-radius: 50%; border: 2px solid ${String(m.color)}'></div>
11
+ <div style='width: 8px; height: 8px; margin-right: 4px; border-radius: 50%; border: 2px solid ${String(h.color)}'></div>
12
12
  </div>
13
13
  <p style='line-height: 1; flex: 1; margin-left: 0.5em; min-width: 20px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; align-self: left;'>
14
- ${i&&m.seriesName?`${m.seriesName}</p>`:""}
14
+ ${s&&h.seriesName?`${h.seriesName}</p>`:""}
15
15
  </p>
16
- <p style='line-height: 1; justify-self: flex-end;'>${o(m.data[1])}</p>
17
- </div>`;d.push(u)}return d},[]).join("")}
18
- </div>`}var He=(e=>(e.LINE="line",e.BAR="bar",e))(He||{});function It(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 Xt(e){return typeof e=="object"&&typeof(e==null?void 0:e.getTime)=="function"?e:new Date(e)}function Fe(e,n){var o,r;for(let i=0;i<n.length;i++){const a=n[i].name,l=i<n.length?(o=n[i+1])==null?void 0:o.name:a,x=i>0?(r=n[i-1])==null?void 0:r.name:a,c=Math.abs(a-l),d=Math.abs(a-x),m=a-d*.5,u=a+c*.5;if(isFinite(m)&&isFinite(u)){if(e>=m&&e<=u)return i}else if(isFinite(m)){if(e>=m)return i}else if(isFinite(u)&&e<=u)return i}}function wo(e){let n,o=0;for(const{name:r}of e)r!==n&&(n=r,o++);return o}function bo(e){const n=new Date(e),o=n.getDay(),r=n.getDate()-o+(o?1:-6);return n.setDate(r),n.setHours(0,0,0,0),n.getTime()}var le=(e=>(e.YEARS="year",e.MONTHS="month",e.WEEKS="week",e.DAYS="day",e.HOURS="hour",e.MINUTES="minute",e.SECONDS="second",e))(le||{});const nt={year:ge,month:ge,week:ge,day:ge,hour:Mo,minute:kt,second:kt},So={year:$o,month:Do,week:Lo,day:Po,hour:Bo,minute:Ao,second:Co};function Io({date:e,stepSize:n}){const o=nt[n];if(!o)throw new Error("formatTime: invalid stepSize");return o(e)}function We({start:e,end:n,stepSize:o}){if(e>n)return We({start:n,end:e,stepSize:o});const r=nt[o];if(!r)throw new Error("formatTimeRange: missing formatter or invalid stepSize");const i=r(e),a=r(n);return`${i} - ${a}`}function Jt({date:e,stepSize:n,stepMultiplier:o}){if(!nt[n])throw new Error("formatBucketRange: missing formatter or invalid stepSize");const{start:i,end:a}=To({date:e,stepSize:n,stepMultiplier:o});if(o===1){if(n==="day")return Io({date:i,stepSize:n});if(n==="second")return`${ge(i)} ${Qe(i)} - ${Qe(a)}`}return We({start:i,end:a,stepSize:n})}const st=e=>1e3*e,ot=e=>st(60*e),ko=e=>ot(60*e);function ge(e){return e.toLocaleDateString()}function Mo(e){return ge(e)+" "+e.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0})}function Qe(e){return e.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!0,second:"2-digit"})}function kt(e){return ge(e)+" "+Qe(e)}function To({date:e,stepSize:n,stepMultiplier:o=1}){const r=So[n];if(!r)throw new Error("getBucketInterval: invalid bucket size");return r({date:e,stepMultiplier:o})}function Co({date:e,stepMultiplier:n=1}){const o=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),0),r=new Date(o.getTime()+st(n-1)+999);return{start:o,end:r}}function Ao({date:e,stepMultiplier:n=1}){const o=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),0,0),r=new Date(o.getTime()+ot(n-1)+st(59));return{start:o,end:r}}function Bo({date:e,stepMultiplier:n=1}){const o=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),0,0,0),r=new Date(o.getTime()+ko(n-1)+ot(59));return{start:o,end:r}}function Po({date:e,stepMultiplier:n=1}){const o=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:o,end:r}}function Lo({date:e,stepMultiplier:n=1}){const o=new Date(bo(e)),r=new Date(o.getFullYear(),o.getMonth(),o.getDate()+6+7*(n-1));return{start:o,end:r}}function Do({date:e,stepMultiplier:n=1}){const o=new Date(e.getFullYear(),e.getMonth(),1),r=new Date(e.getFullYear(),e.getMonth()+n,0);return{start:o,end:r}}function $o({date:e,stepMultiplier:n=1}){const o=new Date(e.getFullYear(),0,1),r=new Date(e.getFullYear()+(n-1),11,31);return{start:o,end:r}}const oe=()=>{},Qt=p.createContext({isPlaying:!1,setIsPlaying:oe,isPaused:!1,setIsPaused:oe,timeWindow:[],setTimeWindow:oe,onTimeWindowUpdate:oe,togglePlay:oe,stop:oe,intl:{}});function Ye(){return p.useContext(Qt)}function en({children:e,isPlaying:n,isPaused:o,onPlay:r=oe,onPause:i=oe,onStop:a=oe,timeWindow:l,onTimeWindowUpdate:x=oe,intl:c}){const[d,m]=p.useState(n),[u,y]=p.useState(o),[g,h]=p.useState([]),j=B.useImperativeIntl(c);p.useEffect(()=>{const w=g.sort((b,E)=>b<E?-1:1).map(Xt);x==null||x(w)},[g,x]);const f=p.useCallback(()=>{d&&(i&&i(),y(!0)),d||(r&&r(),y(!1)),m(w=>!w)},[d,i,r]),v=p.useCallback(()=>{m(!1),y(!1),h([])},[]),R=p.useCallback(()=>{v(),setTimeout(a)},[a,v]);return p.useEffect(()=>{n!==d&&m(n)},[n]),p.useEffect(()=>{o!==u&&y(o)},[o]),p.useEffect(()=>{if(!l)return;const w=l.map(It),b=g.map(It);(w[0]!==b[0]||w[1]!==b[1])&&h(w)},l),t.jsxRuntimeExports.jsx(Qt.Provider,{value:{isPlaying:!!d,setIsPlaying:m,isPaused:!!u,setIsPaused:y,timeWindow:g,setTimeWindow:h,onTimeWindowUpdate:x,togglePlay:f,stop:R,intl:j},children:e})}const Mt={};let Be=null;const Se={seriesId:"0"};function tn({echartsInstance:e,data:n,canSelectLines:o,filterable:r}){const i=s.useTheme(),{isPlaying:a,isPaused:l,setIsPaused:x,timeWindow:c,setTimeWindow:d,stop:m}=Ye(),[u,y]=p.useState(!1),[g,h]=p.useState(!1),[j,f]=p.useState(!1),[v,R]=p.useState(0),w=p.useMemo(()=>e==null?void 0:e.getZr(),[e]),b=p.useCallback(D=>w==null?void 0:w.setCursorStyle(D),[w]),E=p.useCallback(D=>{if(e){const[C]=e.convertFromPixel(Se,[D.offsetX,D.offsetY]),P=Fe(C,n);d(P!==void 0?[n[P].name]:[])}},[n,e,d]);p.useEffect(()=>{function D(C){r&&(o&&C.target||(c.length||(E(C),!l&&!a&&x(!0)),c.length===2&&(d([]),m())))}return Pe(w,"click",D)},[w,l,a,x,d,m,c.length,E,o,r]),p.useEffect(()=>{function D(C){var P;if(r){if(((P=C.target)==null?void 0:P.type)==="ec-line"){y(!0),b("grabbing");return}if(c.length===2){const[L]=e.convertFromPixel(Se,[C.offsetX,C.offsetY]);if(L>=c[0]&&L<=c[1]){f(!0);const $=L-c[0];R($);return}}if(e){h(!0);const[L]=e.convertFromPixel(Se,[C.offsetX,C.offsetY]);Be=L;return}}}return Pe(w,"mousedown",D)},[w,e,c,b,r]),p.useEffect(()=>{function D(C){var P;if(((P=C==null?void 0:C.target)==null?void 0:P.type)==="polygon"&&b("move"),u&&e&&(E(C),b("grabbing")),g&&e){const[L]=e.convertFromPixel(Se,[C.offsetX,C.offsetY]);d(Be===L?[]:[Be,L])}}return Pe(w,"mousemove",D)},[w,e,g,u,d,b,E]),p.useEffect(()=>{function D(C){if(u&&(y(!1),b("default")),g&&(h(!1),Be=null,c.length===1&&d([])),j&&e){const[P]=e.convertFromPixel(Se,[C.offsetX,C.offsetY]),L=P-c[0];if(v){const $=L-v;d([c[0]+$,c[1]+$])}f(!1)}}return Pe(w,"mouseup",D)},[w,e,j,g,u,v,d,c,b]),p.useEffect(()=>{!r&&c.length&&d([])},[r,d,c.length]);const k=p.useMemo(()=>{var L;if(c.length!==1)return;const D=c[0],C=Fe(D,n);if(C===void 0)return;const P=(L=n[C])==null?void 0:L.name;return P!==void 0&&{symbol:["none","none"],animationDuration:100,animationDurationUpdate:150,animationEasingUpdate:"linear",data:l||a?[{label:{show:!1},emphasis:{label:{show:!1}},xAxis:P,lineStyle:{type:"solid",color:i.palette.primary.main,width:1.5,shadowColor:i.palette.primary.light,shadowBlur:3}}]:[]}},[n,l,a,i,c]),M=p.useMemo(()=>c.length===2&&{data:[[{coord:[c[0]]},{coord:[c[1]]}]],itemStyle:{color:i.palette.primary.main,opacity:.2}},[i,c]);return{timelineOptions:k,timeWindowOptions:M}}function Pe(e,n,o){if(e!=null&&e.handler)return Mt[n]=o,e.on(n,o),()=>{Mt[n]&&(e!=null&&e.handler)&&e.off(n,o)}}const nn=A.SPACING*22,sn="100%",Oo=5,No=3,Fo=A.SPACING*20;function Wo({chartType:e,formatter:n,timeAxisSplitNumber:o,tooltip:r,tooltipFormatter:i,data:a,series:l,categories:x,height:c,fitHeight:d,animation:m,filterable:u,selectedCategories:y,onCategoryClick:g,yAxisType:h}){const j=s.useTheme(),[f,v]=p.useState(),R=S=>v(S),[w,b]=p.useState(),E=p.useMemo(()=>l.reduce((S,{data:N})=>N.reduce((I,O)=>O[1]>I?O[1]:I,S),Number.MIN_VALUE),[l]),k=p.useMemo(()=>({show:r,trigger:"axis",appendToBody:!0,padding:[A.SPACING*.5,A.SPACING],textStyle:{...j.typography.caption,fontSize:11,color:j.palette.common.white},borderWidth:0,backgroundColor:j.palette.black[90],position:(S,N,I,O,H)=>{const F={top:0};return H.contentSize[0]<H.viewSize[0]-S[0]?F.left=S[0]+A.SPACING*1.5:F.right=H.viewSize[0]-S[0]+A.SPACING*1.5,F},...i?{formatter:i}:{}}),[j,r,i]),M=p.useMemo(()=>{const S={margin:0,verticalAlign:"bottom",padding:[0,0,A.SPACING*1.25,0],inside:!0,color:O=>{let H="transparent";return O>=E&&(H=j.palette.black[60]),H}},N={margin:0,verticalAlign:"middle",padding:[0,A.SPACING*.75,0,0],color:j.palette.black[60]},I=h==="dense"?S:N;return{axisPointer:{lineStyle:{color:j.palette.black[40]}},xAxis:{type:"time",axisLine:{show:!0,lineStyle:{color:j.palette.grey[900],opacity:.2}},axisLabel:{fontWeight:j.typography.fontWeightRegular,fontSize:j.typography.caption.fontSize,fontFamily:j.typography.caption.fontFamily,lineHeight:j.typography.caption.lineHeight*8,letterSpacing:j.typography.caption.letterSpacing,formatter:{year:"{yearStyle|{yyyy}}"},rich:{yearStyle:{fontWeight:j.typography.fontWeightMedium,fontSize:j.typography.caption.fontSize,fontFamily:j.typography.caption.fontFamily,letterSpacing:j.typography.caption.letterSpacing,lineHeight:j.typography.caption.lineHeight*8}}},axisTick:{show:!1},splitNumber:o??(w!==void 0?Math.min(No,Math.ceil(w/Fo)):Oo)},yAxis:{type:"value",axisLabel:{show:!0,showMaxLabel:!0,showMinLabel:!1,...I,...n?{formatter:O=>n(O)}:{},fontWeight:j.typography.fontWeightRegular,fontSize:j.typography.overlineDelicate.fontSize,fontFamily:j.typography.overlineDelicate.fontFamily,lineHeight:j.typography.overlineDelicate.lineHeight*8,letterSpacing:j.typography.overlineDelicate.letterSpacing},axisLine:{show:!1},axisTick:{show:!1},splitLine:{show:!0,onZero:!1,lineStyle:{color:j.palette.black[4]}},max:E}}},[j,E,n,w,o,h]),{timelineOptions:D,timeWindowOptions:C}=tn({echartsInstance:f,data:a,canSelectLines:!!g,filterable:u}),P=p.useMemo(()=>l.map(({data:S,color:N,name:I},O)=>{const H=y&&y.length>0,F=H&&y.includes(I),Y=!H||F?N:j.palette.action.disabledBackground;return{id:String(O),name:I,markLine:O===0?D:void 0,markArea:O===0?C:void 0,animation:m,data:S,type:e,smooth:!0,color:Y,z:H&&F?10:0,lineStyle:{width:2},showSymbol:!1,emphasis:{scale:2,lineStyle:{width:2,color:Y}}}}),[l,D,C,m,e,y,j]),L=p.useMemo(()=>({grid:{left:A.SPACING*(h==="dense"?2:3.5),top:A.SPACING*4,right:A.SPACING*2,bottom:A.SPACING*3},color:[j.palette.secondary.main],tooltip:k,...M,series:P}),[M,P,h,j.palette.secondary.main,k]),z={click:p.useCallback(S=>{if(x&&g&&S.componentType==="series"){const N=x[S.seriesIndex];g(N)}},[x,g])};p.useEffect(()=>{var I;if(typeof ResizeObserver>"u"||!f)return;const S=(I=f==null?void 0:f.getDom())==null?void 0:I.parentElement;if(!S)return;const N=new ResizeObserver(()=>{b(S.clientWidth),f.resize()});return N.observe(S),()=>{N.disconnect()}},[f]);const G=d?sn:c??nn;return p.useLayoutEffect(()=>{var N;const S=(N=f==null?void 0:f.getDom())==null?void 0:N.parentElement;S&&b(S.clientWidth),f==null||f.resize()},[G,d,f]),t.jsxRuntimeExports.jsx(Ee,{option:L,onEvents:z,onChartReady:R,style:{height:G}})}const _o={[le.YEARS]:60*60*24*7,[le.MONTHS]:60*60*24,[le.WEEKS]:60*60*24,[le.DAYS]:60*60*12,[le.HOURS]:60*60,[le.MINUTES]:60*15,[le.SECONDS]:1},Go=[.5,1,2,3];function zo({data:e,stepSize:n}){const[o,r]=p.useState(null),[i,a]=p.useState(1),l=p.useRef({animationFrameId:null,timeoutId:null}),{isPlaying:x,isPaused:c,timeWindow:d,setTimeWindow:m,stop:u,togglePlay:y,intl:g}=Ye();qo(()=>(x||c)&&u(),[e]);const h=()=>{const{animationFrameId:b,timeoutId:E}=l.current;b&&window.cancelAnimationFrame(b),E&&clearTimeout(E)},j=p.useCallback(()=>{h(),u()},[u]),f=()=>{h(),y()};p.useEffect(()=>{if(x&&d.length===2&&e.length){const E=_o[n]*1e3;return Ko({data:e,timeWindow:d,msTimeWindowStep:E*i,drawFrame:k=>{m(k)},onEnd:()=>{setTimeout(j,250)},animationRef:l}),()=>h()}},[e,x,n,m,j,i]),p.useEffect(()=>{if(x&&d.length===1&&e.length)return Xo({speed:i,timelinePosition:d[0],data:e,drawFrame:b=>{m([b])},onEnd:()=>{setTimeout(j,250)},animationRef:l}),()=>h();x&&d.length===0&&m([e[0].name])},[e,x,i,d.length,j]);const v=b=>{b!=null&&b.currentTarget&&r(b.currentTarget)},R=()=>{r(null)},w=b=>{a(b),R()};return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(s.IconButton,{size:"small",color:"default",onClick:v,"data-testid":"clock",children:t.jsxRuntimeExports.jsx(Ho,{})}),t.jsxRuntimeExports.jsxs(s.Menu,{anchorEl:o,keepMounted:!0,open:!!o,onClose:R,children:[t.jsxRuntimeExports.jsx(s.MenuItem,{disabled:!0,children:t.jsxRuntimeExports.jsx(B.Typography,{variant:"caption",color:"textSecondary",children:g.formatMessage({id:"c4r.widgets.timeSeries.speed"})})}),Go.map(b=>t.jsxRuntimeExports.jsxs(s.MenuItem,{selected:b===i,onClick:()=>w(b),children:[b,"x"]},b))]}),t.jsxRuntimeExports.jsx(s.Box,{mt:2,children:t.jsxRuntimeExports.jsx(s.IconButton,{size:"small",color:"primary",disabled:!(c||x),onClick:j,"data-testid":"stop",children:t.jsxRuntimeExports.jsx(Vo,{})})}),t.jsxRuntimeExports.jsx(s.Box,{mt:.75,children:t.jsxRuntimeExports.jsx(s.IconButton,{"data-testid":"play-pause",size:"small",color:"primary",onClick:f,children:x?t.jsxRuntimeExports.jsx(Uo,{}):t.jsxRuntimeExports.jsx(Yo,{})})})]})}function Ho(){return t.jsxRuntimeExports.jsx(s.SvgIcon,{viewBox:"0 0 20 20",children:t.jsxRuntimeExports.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 Yo(){return t.jsxRuntimeExports.jsx(s.SvgIcon,{"data-testid":"play-icon",children:t.jsxRuntimeExports.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 Vo(){return t.jsxRuntimeExports.jsx(s.SvgIcon,{children:t.jsxRuntimeExports.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 Uo(){return t.jsxRuntimeExports.jsx(s.SvgIcon,{"data-testid":"pause-icon",children:t.jsxRuntimeExports.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 qo(e,n=[]){const o=p.useRef(!1);p.useEffect(()=>{o.current?e():o.current=!0},n)}function Ko({msTimeWindowStep:e,timeWindow:n,data:o,drawFrame:r,onEnd:i,animationRef:a}){let l=n;const x=()=>{a.current.animationFrameId=window.requestAnimationFrame(c)},c=()=>{l=[l[0]+e,l[1]+e],l[1]>o[o.length-1].name?i():(r(l),x())};x()}const Zo=2;function Xo({speed:e,timelinePosition:n,data:o,drawFrame:r,onEnd:i,animationRef:a}){let l=Fe(n,o)??0,x=o[l].name;const c=wo(o),d=Math.max(Math.round(Math.sqrt(c)/2),Zo)*e,m=()=>{a.current.timeoutId=setTimeout(()=>{a.current.animationFrameId=window.requestAnimationFrame(u)},1e3/d)},u=()=>{for(;l<o.length;l++){const y=o[l].name;if(y!==x){x=y;break}}l===o.length?i():(r(x),m())};m()}const Jo=s.styled(s.Box)(()=>({containerType:"inline-size",display:"flex",flexDirection:"column"})),Qo=s.styled(s.Box)(()=>({display:"flex",flexDirection:"column"})),on=s.styled(s.Box)(()=>({display:"flex",flexDirection:"row"})),er=s.styled(on)(()=>({alignItems:"center",justifyContent:"space-between"})),tr=s.styled(s.Box)(({theme:e})=>({flexShrink:0,marginLeft:0,paddingLeft:e.spacing(1),[`@container (max-width: ${A.BREAKPOINTS.XS}px)`]:{paddingLeft:0},paddingBottom:e.spacing(1.5),alignSelf:"flex-end"})),nr=s.styled(s.Box)(({theme:e})=>({alignSelf:"normal",minWidth:0,paddingLeft:e.spacing(5),paddingBottom:e.spacing(1.5),[`@container (max-width: ${A.BREAKPOINTS.XS}px)`]:{paddingLeft:e.spacing(1)}}));function rn({fitHeight:e,header:n,controls:o,chart:r,legend:i}){const a=i&&t.jsxRuntimeExports.jsx(s.Box,{flex:0,mt:2,children:i});return t.jsxRuntimeExports.jsxs(Jo,{style:{flex:e?"1":void 0},children:[t.jsxRuntimeExports.jsx(er,{flex:0,children:n}),o?t.jsxRuntimeExports.jsxs(Qo,{flex:1,children:[t.jsxRuntimeExports.jsxs(on,{flex:1,children:[t.jsxRuntimeExports.jsx(tr,{flex:0,children:o}),t.jsxRuntimeExports.jsx(nr,{flex:1,children:r})]}),a]}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(s.Box,{pb:1.5,flex:1,children:r}),a]})]})}const sr=s.styled(s.Box)(()=>({display:"flex",flexDirection:"column",justifyContent:"flex-end"})),or=s.styled(s.Box)(()=>({position:"relative",height:"100%",alignSelf:"normal",display:"flex",flexDirection:"column",justifyContent:"flex-end"})),rr=s.styled(s.Box)(({theme:e})=>({padding:e.spacing(2.25,0,.5,2)})),ir=s.styled(_t)(({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]}}})),ar=s.styled(s.Box)(({theme:e})=>({display:"flex",flexDirection:"row",justifyContent:"space-between",padding:e.spacing(1.25,.5,.75,.5)})),lr=s.styled(s.Box)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(2),margin:0,padding:e.spacing(1.5,1,.25,1)})),Tt=s.styled(s.Box)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(1)})),cr=({fitHeight:e,height:n,showControls:o,showLegend:r})=>{const i=t.jsxRuntimeExports.jsx(s.Box,{pt:1.25,pb:.75,children:t.jsxRuntimeExports.jsx(s.Skeleton,{width:48,height:8})}),a=o&&t.jsxRuntimeExports.jsxs(sr,{children:[t.jsxRuntimeExports.jsx(s.Box,{p:.5,children:t.jsxRuntimeExports.jsx(s.Skeleton,{width:16,height:16})}),t.jsxRuntimeExports.jsx(s.Box,{mt:2,p:.5,children:t.jsxRuntimeExports.jsx(s.Skeleton,{width:16,height:16})}),t.jsxRuntimeExports.jsx(s.Box,{mt:1,p:.5,children:t.jsxRuntimeExports.jsx(s.Skeleton,{width:16,height:16})})]}),l=e?sn:n??nn,x=t.jsxRuntimeExports.jsxs(or,{style:{height:l},children:[t.jsxRuntimeExports.jsx(rr,{flex:0,children:t.jsxRuntimeExports.jsx(s.Skeleton,{width:24,height:8})}),t.jsxRuntimeExports.jsx(ir,{flex:1,children:t.jsxRuntimeExports.jsx($e.GraphLineIcon,{preserveAspectRatio:"none"})}),t.jsxRuntimeExports.jsxs(ar,{flex:0,children:[t.jsxRuntimeExports.jsx(s.Skeleton,{width:32,height:8}),t.jsxRuntimeExports.jsx(s.Skeleton,{width:32,height:8})]})]}),c=r&&t.jsxRuntimeExports.jsxs(lr,{children:[t.jsxRuntimeExports.jsxs(Tt,{children:[t.jsxRuntimeExports.jsx(s.Skeleton,{width:8,height:8}),t.jsxRuntimeExports.jsx(s.Skeleton,{width:48,height:8})]}),t.jsxRuntimeExports.jsxs(Tt,{children:[t.jsxRuntimeExports.jsx(s.Skeleton,{width:8,height:8}),t.jsxRuntimeExports.jsx(s.Skeleton,{width:48,height:8})]})]});return t.jsxRuntimeExports.jsx(rn,{fitHeight:!!e,header:i,controls:a,chart:x,legend:r&&c})},an=e=>e,_e=[];function ur({data:e=_e,categories:n=_e,stepSize:o,stepMultiplier:r=1,chartType:i=He.LINE,timeAxisSplitNumber:a,tooltip:l=!0,tooltipFormatter:x=Zt,formatter:c=an,height:d,fitHeight:m=!1,showControls:u=!0,animation:y=!0,filterable:g=!0,onTimelineUpdate:h,timeWindow:j,timelinePosition:f,onTimeWindowUpdate:v,selectedCategories:R,onSelectedCategoriesChange:w,isPlaying:b=!1,onPlay:E,isPaused:k=!1,onPause:M,onStop:D,isLoading:C=!1,palette:P=Object.values(je.commonPalette.qualitative.bold),showLegend:L=!0,yAxisType:$="dense"}){const z=p.useRef([]),G=J.useIntl(),{showSkeleton:S}=ue(!!C),N=p.useCallback(I=>{var O,H;if(I.length===2){((O=z.current)==null?void 0:O.length)===1&&(h==null||h(void 0));const F=I.sort((Y,q)=>Y<q?-1:1).map(Xt);v==null||v(F)}if(I.length===1){((H=z.current)==null?void 0:H.length)===2&&(v==null||v([]));const F=Fe(Number(I[0]),e);h==null||h(F)}z.current=I},[v,h,e]);return S?t.jsxRuntimeExports.jsx(cr,{fitHeight:m,height:d,showControls:u,showLegend:L}):t.jsxRuntimeExports.jsx(en,{isPlaying:b,onPlay:E,isPaused:k,onPause:M,onStop:D,timeWindow:j,onTimeWindowUpdate:N,intl:G,children:t.jsxRuntimeExports.jsx(pr,{data:e,categories:n,stepSize:o,stepMultiplier:r,chartType:i,timeAxisSplitNumber:a,tooltip:l,tooltipFormatter:x,formatter:c,height:d,fitHeight:m,showControls:u,animation:y,filterable:g,palette:P,showLegend:L,selectedCategories:R,timelinePosition:f,onSelectedCategoriesChange:w,yAxisType:$})})}function pr({data:e=_e,categories:n=_e,stepSize:o,stepMultiplier:r=1,chartType:i=He.LINE,timeAxisSplitNumber:a,tooltip:l=!0,tooltipFormatter:x=Zt,formatter:c=an,height:d,fitHeight:m=!1,showControls:u=!0,animation:y=!0,filterable:g=!0,palette:h=Object.values(je.commonPalette.qualitative.bold),selectedCategories:j=[],onSelectedCategoriesChange:f,showLegend:v=!0,timelinePosition:R,yAxisType:w="dense"}){const b=s.useTheme(),E=b.palette.secondary.main,{isPlaying:k,isPaused:M,timeWindow:D,stop:C,setTimeWindow:P,intl:L}=Ye();p.useEffect(()=>{if(R!==void 0){if(R<0||R>=e.length)return;const W=e[R].name;P([W])}},[R,e]),p.useEffect(()=>{if(!e.length)return;const W=e[0].name,V=e[e.length-1].name;(D[0]<W||D[1]>V||D[1]<W||D[1]>V)&&P([])},[e]);const $=p.useMemo(()=>{const W={},V=n?n.map(ee=>({name:ee,data:[],color:je.getColorByCategory(ee,{palette:h,fallbackColor:E,colorMapping:W})})):[{name:"",data:[],color:b.palette.secondary.main}];for(const{name:ee,value:pe,category:re,categoryIndex:_}of e){const K=_??(n&&re?n.indexOf(re):0);K===-1||n&&K>=n.length||!Number.isFinite(K)||V[K].data.push([ee,pe])}return V},[n,e,h,E,b.palette.secondary.main]),z=p.useMemo(()=>{if(!e.length)return"";if(D.length===2){const[W,V]=D.map(ee=>new Date(ee));return We({start:W,end:V,stepSize:o})}if(!k&&!M){const W=new Date(e[0].name),V=new Date(e[e.length-1].name);return We({start:W,end:V,stepSize:o})}if(D.length===1){const W=new Date(D[0]);return Jt({date:W,stepSize:o,stepMultiplier:r})}},[e,D,k,M,o,r]),G=p.useMemo(()=>k||M||D.length>0||(j==null?void 0:j.length)>0,[M,k,j==null?void 0:j.length,D.length]),S=()=>{C(),P([]),f==null||f([])},N=W=>{W.key==="Enter"&&S()},I=p.useCallback(W=>{if(f){const V=[...j],ee=V.indexOf(W);ee===-1?V.push(W):V.splice(ee,1),f(V)}},[f,j]),O=!!(v??$.length>1),H=t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(s.Box,{children:t.jsxRuntimeExports.jsx(B.Typography,{color:"textSecondary",variant:"caption",children:z??"-"})}),g&&G&&t.jsxRuntimeExports.jsx(s.Link,{variant:"caption",style:{cursor:"pointer"},onClick:S,onKeyDown:N,tabIndex:0,underline:"hover",children:L.formatMessage({id:"c4r.widgets.timeSeries.clear"})})]}),F=g&&u&&t.jsxRuntimeExports.jsx(zo,{data:e,stepSize:o}),Y=t.jsxRuntimeExports.jsx(Wo,{chartType:i,timeAxisSplitNumber:a,data:e,series:$,categories:n,tooltip:l,formatter:c,tooltipFormatter:W=>x(W,o,c,r,O),height:d,fitHeight:m,animation:y,filterable:g,selectedCategories:j,onCategoryClick:f&&I,yAxisType:w}),q=O&&t.jsxRuntimeExports.jsx(Kt,{series:$,selectedCategories:j,onCategoryClick:f&&I});return t.jsxRuntimeExports.jsx(rn,{fitHeight:m,header:H,controls:F,chart:Y,legend:q})}const xr=s.styled("div")(({theme:e})=>({padding:e.spacing(2,0),...e.typography.body2})),dr=s.styled(s.Box)(({theme:e})=>({overflow:"auto",maxHeight:e.spacing(40),paddingRight:e.spacing(1),margin:e.spacing(.5,0)})),mr=s.styled(s.Box)(({theme:e})=>({display:"flex",alignItems:"center",flexWrap:"wrap",gap:e.spacing(1.5),padding:e.spacing(2,0)})),ln=s.styled(s.Box)(({theme:e,alignItems:n="center"})=>({display:"flex",alignItems:n,gap:e.spacing(.75)})),cn=s.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})),gr=s.styled(s.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(2)})),fr=s.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`}})),Ct=s.styled(s.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"}})),hr=s.styled(s.Tooltip)(({theme:e})=>({".MuiTooltip-tooltip":{color:e.palette.common.white,maxWidth:260,marginBottom:0,overflow:"hidden"}})),jr=s.styled(s.TextField)(({theme:e})=>({marginTop:e.spacing(-.5)}));s.styled(s.Box)(()=>({display:"flex",flexWrap:"nowrap",justifyContent:"space-between"}));const yr=s.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)"}}})),Er=s.styled(s.Box)(({theme:e})=>({display:"flex",alignItems:"center",flexWrap:"nowrap",overflow:"hidden",gap:e.spacing(1)})),Rr=s.styled(s.Box)(({theme:e})=>({padding:e.spacing(.5,0),flexGrow:"1",maxWidth:"100%",minWidth:0})),vr=s.styled(s.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 wr(e,n,o,r,i){const l=(e[0]??[]).map((x,c)=>{const d=String(x.name),m=r.length>0&&!r.includes(d),u=o[c]??d,y=e.map((g,h)=>{var j;return{color:m?je.lighten(n[h],.8):n[h],value:((j=g[c])==null?void 0:j.value)??0}});return{label:u,key:d,data:y}});return i===de.RANKING&&l.sort((x,c)=>{const d=Math.max(...x.data.map(u=>u.value));return Math.max(...c.data.map(u=>u.value))-d}),l}const br=500;function Sr(e,n={}){const{disabled:o,duration:r,animateOnMount:i,initialValue:a=0}=n,l=p.useRef(null),[x,c]=p.useState(()=>i?a:e);return p.useEffect(()=>(o?c(e):Xe({start:x,end:e,duration:r??br,drawFrame:d=>c(d),requestRef:l}),()=>{l.current&&cancelAnimationFrame(l.current)}),[e,o,r]),x}const Ir={};function un({enabled:e=!0,value:n=0,options:o=Ir,formatter:r}){const a=Sr(n||0,{...{animateOnMount:!0,disabled:e===!1||n===null||n===void 0},...o});return t.jsxRuntimeExports.jsx("span",{children:r?r(a):a})}const et=e=>e,kr=()=>{},Mr=[];function Tr({item:e,index:n=0,names:o=Mr,formatter:r=et}){const i=s.useTheme(),a=e.data[0],l=e.data[n],x=o[n],c=(l.value-a.value)/(a.value||1)*100,d=Math.sign(c)===-1?"-":"+",m=Math.sign(c)===-1?i.palette.error.main:i.palette.success.main,u=e.key===ye?i.palette.text.disabled:m;return t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(s.Typography,{color:"inherit",variant:"caption",noWrap:!0,children:e.label}),t.jsxRuntimeExports.jsx(s.Box,{pt:1,pb:.5,children:t.jsxRuntimeExports.jsxs(ln,{alignItems:"baseline",children:[t.jsxRuntimeExports.jsx(cn,{color:e.key===ye?i.palette.background.default:l.color}),t.jsxRuntimeExports.jsx(s.Typography,{color:"inherit",variant:"caption",children:x}),t.jsxRuntimeExports.jsx(s.Box,{style:{flexGrow:1}}),t.jsxRuntimeExports.jsx(vr,{backgroundColor:u,children:t.jsxRuntimeExports.jsxs(s.Typography,{color:"inherit",variant:"caption",children:[d,r(Math.abs(c))]})})]})})]})}function Cr({item:e,animation:n=!0,animationOptions:o,maxValue:r,showCheckbox:i,checkboxChecked:a,formatter:l=et,tooltipFormatter:x=et,onClick:c=kr,names:d,tooltip:m}){function u(g){return`${Math.min(100,(g||0)/r*100)}%`}const y=g=>t.jsxRuntimeExports.jsx(Tr,{item:e,names:d,formatter:x,index:g});return t.jsxRuntimeExports.jsxs(Er,{onClick:()=>c(e.key),children:[i?t.jsxRuntimeExports.jsx(s.Checkbox,{checked:a}):null,t.jsxRuntimeExports.jsxs(Rr,{children:[t.jsxRuntimeExports.jsx(s.Typography,{variant:"body2",noWrap:!0,children:e.label}),e.data.map((g,h)=>t.jsxRuntimeExports.jsx(hr,{title:y(h),placement:"top-start",arrow:!1,disableHoverListener:!m,children:t.jsxRuntimeExports.jsxs(gr,{children:[t.jsxRuntimeExports.jsx(fr,{className:"progressbar",children:t.jsxRuntimeExports.jsx("div",{style:{"--hover-color":s.darken(g.color,.2),"--color":g.color,width:u(g.value)}})}),t.jsxRuntimeExports.jsx(s.Typography,{variant:h===0?"body2":"caption",color:h===0?"textPrimary":"textSecondary",children:t.jsxRuntimeExports.jsx(un,{value:g.value,enabled:n,options:o,formatter:l})})]})},`${e.key}_${h}`))]})]})}const At=e=>e,Ar=()=>{},Ie=[];function Bt(){return t.jsxRuntimeExports.jsx(s.SvgIcon,{children:t.jsxRuntimeExports.jsx("path",{d:"M11,4 C14.8659932,4 18,7.13400675 18,11 C18,12.7003211 17.3937669,14.2590489 16.3856562,15.4718279 L19.4748737,18.5606602 L18.0606602,19.9748737 L14.8998887,16.8138615 C13.7854137,17.5629194 12.4437497,18 11,18 C7.13400675,18 4,14.8659932 4,11 C4,7.13400675 7.13400675,4 11,4 Z M11,6 C8.23857625,6 6,8.23857625 6,11 C6,13.7614237 8.23857625,16 11,16 C13.7614237,16 16,13.7614237 16,11 C16,8.23857625 13.7614237,6 11,6 Z",id:"Color",fill:"inherit"})})}function Br({names:e=Ie,data:n=Ie,labels:o=Ie,colors:r=Ie,maxItems:i=5,order:a=de.FIXED,animation:l=!0,animationOptions:x,searchable:c=!0,filterable:d=!0,selectedCategories:m=Ie,onSelectedCategoriesChange:u=Ar,formatter:y=At,tooltipFormatter:g=At,tooltip:h=!0,isLoading:j=!1}){const f=s.useTheme(),[v,R]=p.useState(!1),[w,b]=p.useState(!1),[E,k]=p.useState(m),[M,D]=p.useState(""),C=J.useIntl(),P=B.useImperativeIntl(C),L=p.useMemo(()=>{const _=r.length?r:[f.palette.secondary.main,f.palette.primary.main,f.palette.info.main];return wr(n,_,o,m,a)},[n,r,o,f,m,a]),$=p.useMemo(()=>Math.max(...n.map(_=>_.map(K=>K.value??0)).flat()),[n]),z=p.useMemo(()=>{if(i>=L.length)return L;const _=L.slice(0,i),K=L.slice(i),X=[];for(const ie of K)ie.data.forEach((Me,Re)=>{X[Re]=X[Re]??0,X[Re]+=Me.value});const Q={key:ye,label:c?"Others":`Others (${L.length-i})`,data:X.map(ie=>({value:ie,color:f.palette.divider}))};return[..._,Q]},[L,c,i,f.palette.divider]),G=p.useMemo(()=>L.filter(_=>m.includes(_.key)),[L,m]),S=p.useMemo(()=>M?L.filter(_=>{const K=(_.key||"").toLowerCase(),X=(_.label||"").toLowerCase(),Q=K==null?void 0:K.includes(M.toLowerCase()),ie=X==null?void 0:X.includes(M.toLowerCase());return Q||ie}):L,[L,M]),N=L.length-z.length+1,I=c&&!v&&i<L.length;if(L.length===0||j)return t.jsxRuntimeExports.jsx(Yt,{});const O=v?S:w?G:z;function H(){b(!0),u([...E]),V()}function F(){b(!1)}function Y(){u([])}function q(){b(!0)}function W(){R(!0),k([...m])}function V(){R(!1),k([])}function ee(_){const K=m.includes(_),X=new Set(m);K?X.delete(_):X.add(_);let Q=Array.from(X);Q.length===L.length&&(Q=[]),u(Q)}function pe(_){const K=E.includes(_),X=new Set(E);K?X.delete(_):X.add(_);let Q=Array.from(X);Q.length===L.length&&(Q=[]),k(Q)}const re=d?v?pe:ee:void 0;return t.jsxRuntimeExports.jsxs(xr,{children:[d?t.jsxRuntimeExports.jsxs(Ct,{center:!0,children:[t.jsxRuntimeExports.jsx(B.Typography,{variant:"caption",children:m.length>0?P.formatMessage({id:"c4r.widgets.category.selectedItems"},{items:m.length}):P.formatMessage({id:"c4r.widgets.category.all"})}),t.jsxRuntimeExports.jsx(B.Typography,{variant:"caption",children:v?t.jsxRuntimeExports.jsx(s.Link,{onClick:H,children:P.formatMessage({id:"c4r.widgets.category.apply"})}):w?t.jsxRuntimeExports.jsx(s.Link,{onClick:F,children:P.formatMessage({id:"c4r.widgets.category.unlock"})}):m.length?t.jsxRuntimeExports.jsxs(s.Box,{style:{display:"flex",justifyContent:"flex-end",gap:f.spacing(1)},children:[t.jsxRuntimeExports.jsx(s.Link,{onClick:q,children:P.formatMessage({id:"c4r.widgets.category.lock"})}),t.jsxRuntimeExports.jsx(s.Divider,{orientation:"vertical",flexItem:!0}),t.jsxRuntimeExports.jsx(s.Link,{onClick:Y,children:P.formatMessage({id:"c4r.widgets.category.clear"})})]}):null})]}):null,v?t.jsxRuntimeExports.jsx(Ct,{children:t.jsxRuntimeExports.jsx(jr,{size:"small",placeholder:P.formatMessage({id:"c4r.widgets.category.search"}),onChange:_=>D(_.currentTarget.value),onFocus:_=>_.currentTarget.scrollIntoView(),InputProps:{startAdornment:t.jsxRuntimeExports.jsx(s.InputAdornment,{position:"start",children:t.jsxRuntimeExports.jsx(Bt,{})})}})}):null,t.jsxRuntimeExports.jsxs(dr,{children:[O.length===0?t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(B.Typography,{variant:"body2",children:P.formatMessage({id:"c4r.widgets.category.noResults"})}),t.jsxRuntimeExports.jsx(B.Typography,{variant:"caption",children:P.formatMessage({id:"c4r.widgets.category.noResultsMessage"},{searchValue:M})})]}):null,O.map(_=>t.jsxRuntimeExports.jsx(yr,{children:t.jsxRuntimeExports.jsx(Cr,{item:_,animation:l,animationOptions:x,maxValue:$,showCheckbox:d&&v,checkboxChecked:E.includes(_.key),formatter:y,tooltipFormatter:g,tooltip:h,onClick:re,names:e})},_.key))]}),I?t.jsxRuntimeExports.jsx(s.Button,{size:"small",color:"primary",startIcon:t.jsxRuntimeExports.jsx(Bt,{}),onClick:W,children:P.formatMessage({id:"c4r.widgets.category.searchInfo"},{elements:N})}):null,v?t.jsxRuntimeExports.jsx(s.Button,{size:"small",color:"primary",onClick:V,children:P.formatMessage({id:"c4r.widgets.category.cancel"})}):null,t.jsxRuntimeExports.jsx(mr,{children:e.map((_,K)=>t.jsxRuntimeExports.jsxs(ln,{children:[t.jsxRuntimeExports.jsx(cn,{color:(r==null?void 0:r[K])??f.palette.background.default}),t.jsxRuntimeExports.jsx(B.Typography,{variant:"overline",children:_})]},e[K]))})]})}const Pr=A.styled(B.Typography)(({theme:e})=>({display:"inline-block",marginTop:e.spacing(.5)}));function Lr({row:e}){const n=s.useTheme();return e.label?t.jsxRuntimeExports.jsx(s.Box,{color:e.color??n.palette.text.secondary,children:t.jsxRuntimeExports.jsx(Pr,{color:"inherit",variant:"caption",children:e.label})}):null}const Dr=s.styled("div")(({theme:e})=>({margin:0,...e.typography.h5,fontWeight:Number(e.typography.fontWeightMedium),color:e.palette.text.primary,display:"flex"})),$r=s.styled(B.Typography)(({theme:e})=>({marginRight:e.spacing(.5)})),Or=s.styled(B.Typography)(({theme:e})=>({marginLeft:e.spacing(.5)}));function Nr({row:e,animated:n,animationOptions:o,formatter:r}){const i=s.useTheme(),{prefix:a,value:l,suffix:x,shouldBeHighlighted:c}=e;return t.jsxRuntimeExports.jsxs(Dr,{children:[a?t.jsxRuntimeExports.jsx(s.Box,{color:i.palette.text.secondary,children:t.jsxRuntimeExports.jsx($r,{color:"inherit",component:"span",variant:"subtitle2",children:a})}):null,t.jsxRuntimeExports.jsx(s.Box,{fontWeight:c?"bold":"",children:t.jsxRuntimeExports.jsx(un,{value:l,enabled:n,options:o,formatter:r})}),x?t.jsxRuntimeExports.jsx(s.Box,{color:i.palette.text.secondary,children:t.jsxRuntimeExports.jsx(Or,{color:"inherit",component:"span",variant:"subtitle2",children:x})}):null]})}const Fr=e=>e,Pt=[],Wr=s.styled("div")(({theme:e})=>({"&:nth-of-type(n+2)":{marginTop:e.spacing(2)}}));function _r({data:e=Pt,colors:n=Pt,animated:o=!0,animationOptions:r,formatter:i=Fr,isLoading:a=!1}){const l=Gr(e,n);return a?t.jsxRuntimeExports.jsx(Ut,{}):t.jsxRuntimeExports.jsx("div",{children:l.map((x,c)=>t.jsxRuntimeExports.jsxs(Wr,{children:[t.jsxRuntimeExports.jsx(Nr,{row:x,animated:o,animationOptions:r,formatter:i}),t.jsxRuntimeExports.jsx(Lr,{row:x})]},c))})}function Gr(e,n){const o=e.map((i,a)=>({...i,color:n[a],shouldBeHighlighted:!1})).filter(i=>i.value!==void 0);return o&&o.length>1&&(o[0].shouldBeHighlighted=!0),o}function zr(e,n=[],o=[],r,i=[]){return e.map((a,l)=>{const x=i.length>0&&!i.includes(a.name),d=(n!=null&&n.length?n:r.palette.qualitative.bold)[l];return{...a,key:a.name,color:x?s.lighten(d,.8):d,name:o[l]??a.name}})}function Hr(e,n,o){const r=`
16
+ <p style='line-height: 1; justify-self: flex-end;'>${r(h.data[1])}</p>
17
+ </div>`;g.push(d)}return g},[]).join("")}
18
+ </div>`}var ze=(e=>(e.LINE="line",e.BAR="bar",e))(ze||{});function vt(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 Yt(e){return typeof e=="object"&&typeof(e==null?void 0:e.getTime)=="function"?e:new Date(e)}function Fe(e,n){var r,i;for(let s=0;s<n.length;s++){const l=n[s].name,a=s<n.length?(r=n[s+1])==null?void 0:r.name:l,p=s>0?(i=n[s-1])==null?void 0:i.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 mr(e){let n,r=0;for(const{name:i}of e)i!==n&&(n=i,r++);return r}function yr(e){const n=new Date(e),r=n.getDay(),i=n.getDate()-r+(r?1:-6);return n.setDate(i),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 nt={year:fe,month:fe,week:fe,day:fe,hour:br,minute:jt,second:jt},vr={year:Er,month:Ar,week:Cr,day:Tr,hour:Mr,minute:kr,second:Ir};function jr({date:e,stepSize:n}){const r=nt[n];if(!r)throw new Error("formatTime: invalid stepSize");return r(e)}function We({start:e,end:n,stepSize:r}){if(e>n)return We({start:n,end:e,stepSize:r});const i=nt[r];if(!i)throw new Error("formatTimeRange: missing formatter or invalid stepSize");const s=i(e),l=i(n);return`${s} - ${l}`}function Vt({date:e,stepSize:n,stepMultiplier:r}){if(!nt[n])throw new Error("formatBucketRange: missing formatter or invalid stepSize");const{start:s,end:l}=Sr({date:e,stepSize:n,stepMultiplier:r});if(r===1){if(n==="day")return jr({date:s,stepSize:n});if(n==="second")return`${fe(s)} ${Qe(s)} - ${Qe(l)}`}return We({start:s,end:l,stepSize:n})}const ot=e=>1e3*e,rt=e=>ot(60*e),wr=e=>rt(60*e);function fe(e){return e.toLocaleDateString()}function br(e){return fe(e)+" "+e.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0})}function Qe(e){return e.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!0,second:"2-digit"})}function jt(e){return fe(e)+" "+Qe(e)}function Sr({date:e,stepSize:n,stepMultiplier:r=1}){const i=vr[n];if(!i)throw new Error("getBucketInterval: invalid bucket size");return i({date:e,stepMultiplier:r})}function Ir({date:e,stepMultiplier:n=1}){const r=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),0),i=new Date(r.getTime()+ot(n-1)+999);return{start:r,end:i}}function kr({date:e,stepMultiplier:n=1}){const r=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),0,0),i=new Date(r.getTime()+rt(n-1)+ot(59));return{start:r,end:i}}function Mr({date:e,stepMultiplier:n=1}){const r=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),0,0,0),i=new Date(r.getTime()+wr(n-1)+rt(59));return{start:r,end:i}}function Tr({date:e,stepMultiplier:n=1}){const r=new Date(e.getFullYear(),e.getMonth(),e.getDate(),0,0,0,0),i=new Date(e.getFullYear(),e.getMonth(),e.getDate()+n-1);return{start:r,end:i}}function Cr({date:e,stepMultiplier:n=1}){const r=new Date(yr(e)),i=new Date(r.getFullYear(),r.getMonth(),r.getDate()+6+7*(n-1));return{start:r,end:i}}function Ar({date:e,stepMultiplier:n=1}){const r=new Date(e.getFullYear(),e.getMonth(),1),i=new Date(e.getFullYear(),e.getMonth()+n,0);return{start:r,end:i}}function Er({date:e,stepMultiplier:n=1}){const r=new Date(e.getFullYear(),0,1),i=new Date(e.getFullYear()+(n-1),11,31);return{start:r,end:i}}const re=()=>{},Ut=u.createContext({isPlaying:!1,setIsPlaying:re,isPaused:!1,setIsPaused:re,timeWindow:[],setTimeWindow:re,onTimeWindowUpdate:re,togglePlay:re,stop:re,intl:{}});function Ye(){return u.useContext(Ut)}function qt({children:e,isPlaying:n,isPaused:r,onPlay:i=re,onPause:s=re,onStop:l=re,timeWindow:a,onTimeWindowUpdate:p=re,intl:c}){const[g,h]=u.useState(n),[d,v]=u.useState(r),[f,m]=u.useState([]),y=B.useImperativeIntl(c);u.useEffect(()=>{const S=f.sort((I,j)=>I<j?-1:1).map(Yt);p==null||p(S)},[f,p]);const x=u.useCallback(()=>{g&&(s&&s(),v(!0)),g||(i&&i(),v(!1)),h(S=>!S)},[g,s,i]),b=u.useCallback(()=>{h(!1),v(!1),m([])},[]),w=u.useCallback(()=>{b(),setTimeout(l)},[l,b]);return u.useEffect(()=>{n!==g&&h(n)},[n]),u.useEffect(()=>{r!==d&&v(r)},[r]),u.useEffect(()=>{if(!a)return;const S=a.map(vt),I=f.map(vt);(S[0]!==I[0]||S[1]!==I[1])&&m(S)},a),t.jsx(Ut.Provider,{value:{isPlaying:!!g,setIsPlaying:h,isPaused:!!d,setIsPaused:v,timeWindow:f,setTimeWindow:m,onTimeWindowUpdate:p,togglePlay:x,stop:w,intl:y},children:e})}const wt={};let Pe=null;const Ie={seriesId:"0"};function Kt({echartsInstance:e,data:n,canSelectLines:r,filterable:i}){const s=o.useTheme(),{isPlaying:l,isPaused:a,setIsPaused:p,timeWindow:c,setTimeWindow:g,stop:h}=Ye(),[d,v]=u.useState(!1),[f,m]=u.useState(!1),[y,x]=u.useState(!1),[b,w]=u.useState(0),S=u.useMemo(()=>e==null?void 0:e.getZr(),[e]),I=u.useCallback(D=>S==null?void 0:S.setCursorStyle(D),[S]),j=u.useCallback(D=>{if(e){const[E]=e.convertFromPixel(Ie,[D.offsetX,D.offsetY]),P=Fe(E,n);g(P!==void 0?[n[P].name]:[])}},[n,e,g]);u.useEffect(()=>{function D(E){i&&(r&&E.target||(c.length||(j(E),!a&&!l&&p(!0)),c.length===2&&(g([]),h())))}return Le(S,"click",D)},[S,a,l,p,g,h,c.length,j,r,i]),u.useEffect(()=>{function D(E){var P;if(i){if(((P=E.target)==null?void 0:P.type)==="ec-line"){v(!0),I("grabbing");return}if(c.length===2){const[L]=e.convertFromPixel(Ie,[E.offsetX,E.offsetY]);if(L>=c[0]&&L<=c[1]){x(!0);const N=L-c[0];w(N);return}}if(e){m(!0);const[L]=e.convertFromPixel(Ie,[E.offsetX,E.offsetY]);Pe=L;return}}}return Le(S,"mousedown",D)},[S,e,c,I,i]),u.useEffect(()=>{function D(E){var P;if(((P=E==null?void 0:E.target)==null?void 0:P.type)==="polygon"&&I("move"),d&&e&&(j(E),I("grabbing")),f&&e){const[L]=e.convertFromPixel(Ie,[E.offsetX,E.offsetY]);g(Pe===L?[]:[Pe,L])}}return Le(S,"mousemove",D)},[S,e,f,d,g,I,j]),u.useEffect(()=>{function D(E){if(d&&(v(!1),I("default")),f&&(m(!1),Pe=null,c.length===1&&g([])),y&&e){const[P]=e.convertFromPixel(Ie,[E.offsetX,E.offsetY]),L=P-c[0];if(b){const N=L-b;g([c[0]+N,c[1]+N])}x(!1)}}return Le(S,"mouseup",D)},[S,e,y,f,d,b,g,c,I]),u.useEffect(()=>{!i&&c.length&&g([])},[i,g,c.length]);const T=u.useMemo(()=>{var L;if(c.length!==1)return;const D=c[0],E=Fe(D,n);if(E===void 0)return;const P=(L=n[E])==null?void 0:L.name;return P!==void 0&&{symbol:["none","none"],animationDuration:100,animationDurationUpdate:150,animationEasingUpdate:"linear",data:a||l?[{label:{show:!1},emphasis:{label:{show:!1}},xAxis:P,lineStyle:{type:"solid",color:s.palette.primary.main,width:1.5,shadowColor:s.palette.primary.light,shadowBlur:3}}]:[]}},[n,a,l,s,c]),C=u.useMemo(()=>c.length===2&&{data:[[{coord:[c[0]]},{coord:[c[1]]}]],itemStyle:{color:s.palette.primary.main,opacity:.2}},[s,c]);return{timelineOptions:T,timeWindowOptions:C}}function Le(e,n,r){if(e!=null&&e.handler)return wt[n]=r,e.on(n,r),()=>{wt[n]&&(e!=null&&e.handler)&&e.off(n,r)}}const Zt=$.SPACING*22,Xt="100%",Br=5,Pr=3,Lr=$.SPACING*20;function Dr({chartType:e,formatter:n,timeAxisSplitNumber:r,tooltip:i,tooltipFormatter:s,data:l,series:a,categories:p,height:c,fitHeight:g,animation:h,filterable:d,selectedCategories:v,onCategoryClick:f,yAxisType:m}){const y=o.useTheme(),[x,b]=u.useState(),w=k=>b(k),[S,I]=u.useState(),j=u.useMemo(()=>a.reduce((k,{data:O})=>O.reduce((M,R)=>R[1]>M?R[1]:M,k),Number.MIN_VALUE),[a]),T=u.useMemo(()=>({show:i,trigger:"axis",appendToBody:!0,padding:[$.SPACING*.5,$.SPACING],textStyle:{...y.typography.caption,fontSize:11,color:y.palette.common.white},borderWidth:0,backgroundColor:y.palette.black[90],position:(k,O,M,R,z)=>{const F={top:0};return z.contentSize[0]<z.viewSize[0]-k[0]?F.left=k[0]+$.SPACING*1.5:F.right=z.viewSize[0]-k[0]+$.SPACING*1.5,F},...s?{formatter:s}:{}}),[y,i,s]),C=u.useMemo(()=>{const k={margin:0,verticalAlign:"bottom",padding:[0,0,$.SPACING*1.25,0],inside:!0,color:R=>{let z="transparent";return R>=j&&(z=y.palette.black[60]),z}},O={margin:0,verticalAlign:"middle",padding:[0,$.SPACING*.75,0,0],color:y.palette.black[60]},M=m==="dense"?k:O;return{axisPointer:{lineStyle:{color:y.palette.black[40]}},xAxis:{type:"time",axisLine:{show:!0,lineStyle:{color:y.palette.grey[900],opacity:.2}},axisLabel:{fontWeight:y.typography.fontWeightRegular,fontSize:y.typography.caption.fontSize,fontFamily:y.typography.caption.fontFamily,lineHeight:y.typography.caption.lineHeight*8,letterSpacing:y.typography.caption.letterSpacing,formatter:{year:"{yearStyle|{yyyy}}"},rich:{yearStyle:{fontWeight:y.typography.fontWeightMedium,fontSize:y.typography.caption.fontSize,fontFamily:y.typography.caption.fontFamily,letterSpacing:y.typography.caption.letterSpacing,lineHeight:y.typography.caption.lineHeight*8}}},axisTick:{show:!1},splitNumber:r??(S!==void 0?Math.min(Pr,Math.ceil(S/Lr)):Br)},yAxis:{type:"value",axisLabel:{show:!0,showMaxLabel:!0,showMinLabel:!1,...M,...n?{formatter:R=>n(R)}:{},fontWeight:y.typography.fontWeightRegular,fontSize:y.typography.overlineDelicate.fontSize,fontFamily:y.typography.overlineDelicate.fontFamily,lineHeight:y.typography.overlineDelicate.lineHeight*8,letterSpacing:y.typography.overlineDelicate.letterSpacing},axisLine:{show:!1},axisTick:{show:!1},splitLine:{show:!0,onZero:!1,lineStyle:{color:y.palette.black[4]}},max:j}}},[y,j,n,S,r,m]),{timelineOptions:D,timeWindowOptions:E}=Kt({echartsInstance:x,data:l,canSelectLines:!!f,filterable:d}),P=u.useMemo(()=>a.map(({data:k,color:O,name:M},R)=>{const z=v&&v.length>0,F=z&&v.includes(M),Y=!z||F?O:y.palette.action.disabledBackground;return{id:String(R),name:M,markLine:R===0?D:void 0,markArea:R===0?E:void 0,animation:h,data:k,type:e,smooth:!0,color:Y,z:z&&F?10:0,lineStyle:{width:2},showSymbol:!1,emphasis:{scale:2,lineStyle:{width:2,color:Y}}}}),[a,D,E,h,e,v,y]),L=u.useMemo(()=>({grid:{left:$.SPACING*(m==="dense"?2:3.5),top:$.SPACING*4,right:$.SPACING*2,bottom:$.SPACING*3},color:[y.palette.secondary.main],tooltip:T,...C,series:P}),[C,P,m,y.palette.secondary.main,T]),H={click:u.useCallback(k=>{if(p&&f&&k.componentType==="series"){const O=p[k.seriesIndex];f(O)}},[p,f])};u.useEffect(()=>{var M;if(typeof ResizeObserver>"u"||!x)return;const k=(M=x==null?void 0:x.getDom())==null?void 0:M.parentElement;if(!k)return;const O=new ResizeObserver(()=>{I(k.clientWidth),x.resize()});return O.observe(k),()=>{O.disconnect()}},[x]);const G=g?Xt:c??Zt;return u.useLayoutEffect(()=>{var O;const k=(O=x==null?void 0:x.getDom())==null?void 0:O.parentElement;k&&I(k.clientWidth),x==null||x.resize()},[G,g,x]),t.jsx(ve,{option:L,onEvents:H,onChartReady:w,style:{height:G}})}const Nr={[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},Rr=[.5,1,2,3];function $r({data:e,stepSize:n}){const[r,i]=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:v,intl:f}=Ye();Gr(()=>(p||c)&&d(),[e]);const m=()=>{const{animationFrameId:I,timeoutId:j}=a.current;I&&window.cancelAnimationFrame(I),j&&clearTimeout(j)},y=u.useCallback(()=>{m(),d()},[d]),x=()=>{m(),v()};u.useEffect(()=>{if(p&&g.length===2&&e.length){const j=Nr[n]*1e3;return Hr({data:e,timeWindow:g,msTimeWindowStep:j*s,drawFrame:T=>{h(T)},onEnd:()=>{setTimeout(y,250)},animationRef:a}),()=>m()}},[e,p,n,h,y,s]),u.useEffect(()=>{if(p&&g.length===1&&e.length)return Yr({speed:s,timelinePosition:g[0],data:e,drawFrame:I=>{h([I])},onEnd:()=>{setTimeout(y,250)},animationRef:a}),()=>m();p&&g.length===0&&h([e[0].name])},[e,p,s,g.length,y]);const b=I=>{I!=null&&I.currentTarget&&i(I.currentTarget)},w=()=>{i(null)},S=I=>{l(I),w()};return t.jsxs(t.Fragment,{children:[t.jsx(o.IconButton,{size:"small",color:"default",onClick:b,"data-testid":"clock",children:t.jsx(Or,{})}),t.jsxs(o.Menu,{anchorEl:r,keepMounted:!0,open:!!r,onClose:w,children:[t.jsx(o.MenuItem,{disabled:!0,children:t.jsx(B.Typography,{variant:"caption",color:"textSecondary",children:f.formatMessage({id:"c4r.widgets.timeSeries.speed"})})}),Rr.map(I=>t.jsxs(o.MenuItem,{selected:I===s,onClick:()=>S(I),children:[I,"x"]},I))]}),t.jsx(o.Box,{mt:2,children:t.jsx(o.IconButton,{size:"small",color:"primary",disabled:!(c||p),onClick:y,"data-testid":"stop",children:t.jsx(Wr,{})})}),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(_r,{}):t.jsx(Fr,{})})})]})}function Or(){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 Fr(){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 Wr(){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 _r(){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 Gr(e,n=[]){const r=u.useRef(!1);u.useEffect(()=>{r.current?e():r.current=!0},n)}function Hr({msTimeWindowStep:e,timeWindow:n,data:r,drawFrame:i,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]>r[r.length-1].name?s():(i(a),p())};p()}const zr=2;function Yr({speed:e,timelinePosition:n,data:r,drawFrame:i,onEnd:s,animationRef:l}){let a=Fe(n,r)??0,p=r[a].name;const c=mr(r),g=Math.max(Math.round(Math.sqrt(c)/2),zr)*e,h=()=>{l.current.timeoutId=setTimeout(()=>{l.current.animationFrameId=window.requestAnimationFrame(d)},1e3/g)},d=()=>{for(;a<r.length;a++){const v=r[a].name;if(v!==p){p=v;break}}a===r.length?s():(i(p),h())};h()}const Vr=o.styled(o.Box)(()=>({containerType:"inline-size",display:"flex",flexDirection:"column"})),Ur=o.styled(o.Box)(()=>({display:"flex",flexDirection:"column"})),Jt=o.styled(o.Box)(()=>({display:"flex",flexDirection:"row"})),qr=o.styled(Jt)(()=>({alignItems:"center",justifyContent:"space-between"})),Kr=o.styled(o.Box)(({theme:e})=>({flexShrink:0,marginLeft:0,paddingLeft:e.spacing(1),[`@container (max-width: ${$.BREAKPOINTS.XS}px)`]:{paddingLeft:0},paddingBottom:e.spacing(1.5),alignSelf:"flex-end"})),Zr=o.styled(o.Box)(({theme:e})=>({alignSelf:"normal",minWidth:0,paddingLeft:e.spacing(5),paddingBottom:e.spacing(1.5),[`@container (max-width: ${$.BREAKPOINTS.XS}px)`]:{paddingLeft:e.spacing(1)}}));function Qt({fitHeight:e,header:n,controls:r,chart:i,legend:s}){const l=s&&t.jsx(o.Box,{flex:0,mt:2,children:s});return t.jsxs(Vr,{style:{flex:e?"1":void 0},children:[t.jsx(qr,{flex:0,children:n}),r?t.jsxs(Ur,{flex:1,children:[t.jsxs(Jt,{flex:1,children:[t.jsx(Kr,{flex:0,children:r}),t.jsx(Zr,{flex:1,children:i})]}),l]}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{pb:1.5,flex:1,children:i}),l]})]})}const Xr=o.styled(o.Box)(()=>({display:"flex",flexDirection:"column",justifyContent:"flex-end"})),Jr=o.styled(o.Box)(()=>({position:"relative",height:"100%",alignSelf:"normal",display:"flex",flexDirection:"column",justifyContent:"flex-end"})),Qr=o.styled(o.Box)(({theme:e})=>({padding:e.spacing(2.25,0,.5,2)})),ei=o.styled(Nt)(({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]}}})),ti=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",justifyContent:"space-between",padding:e.spacing(1.25,.5,.75,.5)})),ni=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(2),margin:0,padding:e.spacing(1.5,1,.25,1)})),bt=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(1)})),oi=({fitHeight:e,height:n,showControls:r,showLegend:i})=>{const s=t.jsx(o.Box,{pt:1.25,pb:.75,children:t.jsx(o.Skeleton,{width:48,height:8})}),l=r&&t.jsxs(Xr,{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?Xt:n??Zt,p=t.jsxs(Jr,{style:{height:a},children:[t.jsx(Qr,{flex:0,children:t.jsx(o.Skeleton,{width:24,height:8})}),t.jsx(ei,{flex:1,children:t.jsx(Re.GraphLineIcon,{preserveAspectRatio:"none"})}),t.jsxs(ti,{flex:0,children:[t.jsx(o.Skeleton,{width:32,height:8}),t.jsx(o.Skeleton,{width:32,height:8})]})]}),c=i&&t.jsxs(ni,{children:[t.jsxs(bt,{children:[t.jsx(o.Skeleton,{width:8,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]}),t.jsxs(bt,{children:[t.jsx(o.Skeleton,{width:8,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]})]});return t.jsx(Qt,{fitHeight:!!e,header:s,controls:l,chart:p,legend:i&&c})},en=e=>e,_e=[];function ri({data:e=_e,categories:n=_e,stepSize:r,stepMultiplier:i=1,chartType:s=ze.LINE,timeAxisSplitNumber:l,tooltip:a=!0,tooltipFormatter:p=zt,formatter:c=en,height:g,fitHeight:h=!1,showControls:d=!0,animation:v=!0,filterable:f=!0,onTimelineUpdate:m,timeWindow:y,timelinePosition:x,onTimeWindowUpdate:b,selectedCategories:w,onSelectedCategoriesChange:S,isPlaying:I=!1,onPlay:j,isPaused:T=!1,onPause:C,onStop:D,isLoading:E=!1,palette:P=Object.values(Te.commonPalette.qualitative.bold),showLegend:L=!0,yAxisType:N="dense"}){const H=u.useRef([]),G=J.useIntl(),{showSkeleton:k}=de(!!E),O=u.useCallback(M=>{var R,z;if(M.length===2){((R=H.current)==null?void 0:R.length)===1&&(m==null||m(void 0));const F=M.sort((Y,q)=>Y<q?-1:1).map(Yt);b==null||b(F)}if(M.length===1){((z=H.current)==null?void 0:z.length)===2&&(b==null||b([]));const F=Fe(Number(M[0]),e);m==null||m(F)}H.current=M},[b,m,e]);return k?t.jsx(oi,{fitHeight:h,height:g,showControls:d,showLegend:L}):t.jsx(qt,{isPlaying:I,onPlay:j,isPaused:T,onPause:C,onStop:D,timeWindow:y,onTimeWindowUpdate:O,intl:G,children:t.jsx(ii,{data:e,categories:n,stepSize:r,stepMultiplier:i,chartType:s,timeAxisSplitNumber:l,tooltip:a,tooltipFormatter:p,formatter:c,height:g,fitHeight:h,showControls:d,animation:v,filterable:f,palette:P,showLegend:L,selectedCategories:w,timelinePosition:x,onSelectedCategoriesChange:S,yAxisType:N})})}function ii({data:e=_e,categories:n=_e,stepSize:r,stepMultiplier:i=1,chartType:s=ze.LINE,timeAxisSplitNumber:l,tooltip:a=!0,tooltipFormatter:p=zt,formatter:c=en,height:g,fitHeight:h=!1,showControls:d=!0,animation:v=!0,filterable:f=!0,palette:m=Object.values(Te.commonPalette.qualitative.bold),selectedCategories:y=[],onSelectedCategoriesChange:x,showLegend:b=!0,timelinePosition:w,yAxisType:S="dense"}){const I=o.useTheme(),j=I.palette.secondary.main,{isPlaying:T,isPaused:C,timeWindow:D,stop:E,setTimeWindow:P,intl:L}=Ye();u.useEffect(()=>{if(w!==void 0){if(w<0||w>=e.length)return;const W=e[w].name;P([W])}},[w,e]),u.useEffect(()=>{if(!e.length)return;const W=e[0].name,V=e[e.length-1].name;(D[0]<W||D[1]>V||D[1]<W||D[1]>V)&&P([])},[e]);const N=u.useMemo(()=>{const W={},V=n?n.map(ee=>({name:ee,data:[],color:Te.getColorByCategory(ee,{palette:m,fallbackColor:j,colorMapping:W})})):[{name:"",data:[],color:I.palette.secondary.main}];for(const{name:ee,value:ue,category:ie,categoryIndex:_}of e){const K=_??(n&&ie?n.indexOf(ie):0);K===-1||n&&K>=n.length||!Number.isFinite(K)||V[K].data.push([ee,ue])}return V},[n,e,m,j,I.palette.secondary.main]),H=u.useMemo(()=>{if(!e.length)return"";if(D.length===2){const[W,V]=D.map(ee=>new Date(ee));return We({start:W,end:V,stepSize:r})}if(!T&&!C){const W=new Date(e[0].name),V=new Date(e[e.length-1].name);return We({start:W,end:V,stepSize:r})}if(D.length===1){const W=new Date(D[0]);return Vt({date:W,stepSize:r,stepMultiplier:i})}},[e,D,T,C,r,i]),G=u.useMemo(()=>T||C||D.length>0||(y==null?void 0:y.length)>0,[C,T,y==null?void 0:y.length,D.length]),k=()=>{E(),P([]),x==null||x([])},O=W=>{W.key==="Enter"&&k()},M=u.useCallback(W=>{if(x){const V=[...y],ee=V.indexOf(W);ee===-1?V.push(W):V.splice(ee,1),x(V)}},[x,y]),R=!!(b??N.length>1),z=t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{children:t.jsx(B.Typography,{color:"textSecondary",variant:"caption",children:H??"-"})}),f&&G&&t.jsx(o.Link,{variant:"caption",style:{cursor:"pointer"},onClick:k,onKeyDown:O,tabIndex:0,underline:"hover",children:L.formatMessage({id:"c4r.widgets.timeSeries.clear"})})]}),F=f&&d&&t.jsx($r,{data:e,stepSize:r}),Y=t.jsx(Dr,{chartType:s,timeAxisSplitNumber:l,data:e,series:N,categories:n,tooltip:a,formatter:c,tooltipFormatter:W=>p(W,r,c,i,R),height:g,fitHeight:h,animation:v,filterable:f,selectedCategories:y,onCategoryClick:x&&M,yAxisType:S}),q=R&&t.jsx(Ht,{series:N,selectedCategories:y,onCategoryClick:x&&M});return t.jsx(Qt,{fitHeight:h,header:z,controls:F,chart:Y,legend:q})}const si=o.styled("div")(({theme:e})=>({padding:e.spacing(2,0),...e.typography.body2})),li=o.styled(o.Box)(({theme:e})=>({overflow:"auto",maxHeight:e.spacing(40),paddingRight:e.spacing(1),margin:e.spacing(.5,0)})),ai=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",flexWrap:"wrap",gap:e.spacing(1.5),padding:e.spacing(2,0)})),tn=o.styled(o.Box)(({theme:e,alignItems:n="center"})=>({display:"flex",alignItems:n,gap:e.spacing(.75)})),nn=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})),ci=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(2)})),di=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`}})),St=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"}})),ui=o.styled(o.Tooltip)(({theme:e})=>({".MuiTooltip-tooltip":{color:e.palette.common.white,maxWidth:260,marginBottom:0,overflow:"hidden"}})),pi=o.styled(o.TextField)(({theme:e})=>({marginTop:e.spacing(-.5)}));o.styled(o.Box)(()=>({display:"flex",flexWrap:"nowrap",justifyContent:"space-between"}));const gi=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)"}}})),hi=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",flexWrap:"nowrap",overflow:"hidden",gap:e.spacing(1)})),fi=o.styled(o.Box)(({theme:e})=>({padding:e.spacing(.5,0),flexGrow:"1",maxWidth:"100%",minWidth:0})),xi=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 mi(e,n,r,i,s){const a=(e[0]??[]).map((p,c)=>{const g=String(p.name),h=i.length>0&&!i.includes(g),d=r[c]??g,v=e.map((f,m)=>{var y;return{color:h?Lt.lighten(n[m],.8):n[m],value:((y=f[c])==null?void 0:y.value)??0}});return{label:d,key:g,data:v}});return s===ge.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 yi=500;function vi(e,n={}){const{disabled:r,duration:i,animateOnMount:s,initialValue:l=0}=n,a=u.useRef(null),[p,c]=u.useState(()=>s?l:e);return u.useEffect(()=>(r?c(e):Xe({start:p,end:e,duration:i??yi,drawFrame:g=>c(g),requestRef:a}),()=>{a.current&&cancelAnimationFrame(a.current)}),[e,r,i]),p}const ji={};function on({enabled:e=!0,value:n=0,options:r=ji,formatter:i}){const l=vi(n||0,{...{animateOnMount:!0,disabled:e===!1||n===null||n===void 0},...r});return t.jsx("span",{children:i?i(l):l})}const et=e=>e,wi=()=>{},bi=[];function Si({item:e,index:n=0,names:r=bi,formatter:i=et}){const s=o.useTheme(),l=e.data[0],a=e.data[n],p=r[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===ye?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(tn,{alignItems:"baseline",children:[t.jsx(nn,{color:e.key===ye?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(xi,{backgroundColor:d,children:t.jsxs(o.Typography,{color:"inherit",variant:"caption",children:[g,i(Math.abs(c))]})})]})})]})}function Ii({item:e,animation:n=!0,animationOptions:r,maxValue:i,showCheckbox:s,checkboxChecked:l,formatter:a=et,tooltipFormatter:p=et,onClick:c=wi,names:g,tooltip:h}){function d(f){return`${Math.min(100,(f||0)/i*100)}%`}const v=f=>t.jsx(Si,{item:e,names:g,formatter:p,index:f});return t.jsxs(hi,{onClick:()=>c(e.key),children:[s?t.jsx(o.Checkbox,{checked:l}):null,t.jsxs(fi,{children:[t.jsx(o.Typography,{variant:"body2",noWrap:!0,children:e.label}),e.data.map((f,m)=>t.jsx(ui,{title:v(m),placement:"top-start",arrow:!1,disableHoverListener:!h,children:t.jsxs(ci,{children:[t.jsx(di,{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(on,{value:f.value,enabled:n,options:r,formatter:a})})]})},`${e.key}_${m}`))]})]})}const It=e=>e,ki=()=>{},ke=[];function kt(){return t.jsx(o.SvgIcon,{children:t.jsx("path",{d:"M11,4 C14.8659932,4 18,7.13400675 18,11 C18,12.7003211 17.3937669,14.2590489 16.3856562,15.4718279 L19.4748737,18.5606602 L18.0606602,19.9748737 L14.8998887,16.8138615 C13.7854137,17.5629194 12.4437497,18 11,18 C7.13400675,18 4,14.8659932 4,11 C4,7.13400675 7.13400675,4 11,4 Z M11,6 C8.23857625,6 6,8.23857625 6,11 C6,13.7614237 8.23857625,16 11,16 C13.7614237,16 16,13.7614237 16,11 C16,8.23857625 13.7614237,6 11,6 Z",id:"Color",fill:"inherit"})})}function Mi({names:e=ke,data:n=ke,labels:r=ke,colors:i=ke,maxItems:s=5,order:l=ge.FIXED,animation:a=!0,animationOptions:p,searchable:c=!0,filterable:g=!0,selectedCategories:h=ke,onSelectedCategoriesChange:d=ki,formatter:v=It,tooltipFormatter:f=It,tooltip:m=!0,isLoading:y=!1}){const x=o.useTheme(),[b,w]=u.useState(!1),[S,I]=u.useState(!1),[j,T]=u.useState(h),[C,D]=u.useState(""),E=J.useIntl(),P=B.useImperativeIntl(E),L=u.useMemo(()=>{const _=i.length?i:[x.palette.secondary.main,x.palette.primary.main,x.palette.info.main];return mi(n,_,r,h,l)},[n,i,r,x,h,l]),N=u.useMemo(()=>Math.max(...n.map(_=>_.map(K=>K.value??0)).flat()),[n]),H=u.useMemo(()=>{if(s>=L.length)return L;const _=L.slice(0,s),K=L.slice(s),X=[];for(const se of K)se.data.forEach((Ce,je)=>{X[je]=X[je]??0,X[je]+=Ce.value});const Q={key:ye,label:c?"Others":`Others (${L.length-s})`,data:X.map(se=>({value:se,color:x.palette.divider}))};return[..._,Q]},[L,c,s,x.palette.divider]),G=u.useMemo(()=>L.filter(_=>h.includes(_.key)),[L,h]),k=u.useMemo(()=>C?L.filter(_=>{const K=(_.key||"").toLowerCase(),X=(_.label||"").toLowerCase(),Q=K==null?void 0:K.includes(C.toLowerCase()),se=X==null?void 0:X.includes(C.toLowerCase());return Q||se}):L,[L,C]),O=L.length-H.length+1,M=c&&!b&&s<L.length;if(L.length===0||y)return t.jsx(Ft,{});const R=b?k:S?G:H;function z(){I(!0),d([...j]),V()}function F(){I(!1)}function Y(){d([])}function q(){I(!0)}function W(){w(!0),T([...h])}function V(){w(!1),T([])}function ee(_){const K=h.includes(_),X=new Set(h);K?X.delete(_):X.add(_);let Q=Array.from(X);Q.length===L.length&&(Q=[]),d(Q)}function ue(_){const K=j.includes(_),X=new Set(j);K?X.delete(_):X.add(_);let Q=Array.from(X);Q.length===L.length&&(Q=[]),T(Q)}const ie=g?b?ue:ee:void 0;return t.jsxs(si,{children:[g?t.jsxs(St,{center:!0,children:[t.jsx(B.Typography,{variant:"caption",children:h.length>0?P.formatMessage({id:"c4r.widgets.category.selectedItems"},{items:h.length}):P.formatMessage({id:"c4r.widgets.category.all"})}),t.jsx(B.Typography,{variant:"caption",children:b?t.jsx(o.Link,{onClick:z,children:P.formatMessage({id:"c4r.widgets.category.apply"})}):S?t.jsx(o.Link,{onClick:F,children:P.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:P.formatMessage({id:"c4r.widgets.category.lock"})}),t.jsx(o.Divider,{orientation:"vertical",flexItem:!0}),t.jsx(o.Link,{onClick:Y,children:P.formatMessage({id:"c4r.widgets.category.clear"})})]}):null})]}):null,b?t.jsx(St,{children:t.jsx(pi,{size:"small",placeholder:P.formatMessage({id:"c4r.widgets.category.search"}),onChange:_=>D(_.currentTarget.value),onFocus:_=>_.currentTarget.scrollIntoView(),InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx(kt,{})})}})}):null,t.jsxs(li,{children:[R.length===0?t.jsxs(t.Fragment,{children:[t.jsx(B.Typography,{variant:"body2",children:P.formatMessage({id:"c4r.widgets.category.noResults"})}),t.jsx(B.Typography,{variant:"caption",children:P.formatMessage({id:"c4r.widgets.category.noResultsMessage"},{searchValue:C})})]}):null,R.map(_=>t.jsx(gi,{children:t.jsx(Ii,{item:_,animation:a,animationOptions:p,maxValue:N,showCheckbox:g&&b,checkboxChecked:j.includes(_.key),formatter:v,tooltipFormatter:f,tooltip:m,onClick:ie,names:e})},_.key))]}),M?t.jsx(o.Button,{size:"small",color:"primary",startIcon:t.jsx(kt,{}),onClick:W,children:P.formatMessage({id:"c4r.widgets.category.searchInfo"},{elements:O})}):null,b?t.jsx(o.Button,{size:"small",color:"primary",onClick:V,children:P.formatMessage({id:"c4r.widgets.category.cancel"})}):null,t.jsx(ai,{children:e.map((_,K)=>t.jsxs(tn,{children:[t.jsx(nn,{color:(i==null?void 0:i[K])??x.palette.background.default}),t.jsx(B.Typography,{variant:"overline",children:_})]},e[K]))})]})}const Ti=Lt.styled(B.Typography)(({theme:e})=>({display:"inline-block",marginTop:e.spacing(.5)}));function Ci({row:e}){const n=o.useTheme();return e.label?t.jsx(o.Box,{color:e.color??n.palette.text.secondary,children:t.jsx(Ti,{color:"inherit",variant:"caption",children:e.label})}):null}const Ai=o.styled("div")(({theme:e})=>({margin:0,...e.typography.h5,fontWeight:Number(e.typography.fontWeightMedium),color:e.palette.text.primary,display:"flex"})),Ei=o.styled(B.Typography)(({theme:e})=>({marginRight:e.spacing(.5)})),Bi=o.styled(B.Typography)(({theme:e})=>({marginLeft:e.spacing(.5)}));function Pi({row:e,animated:n,animationOptions:r,formatter:i}){const s=o.useTheme(),{prefix:l,value:a,suffix:p,shouldBeHighlighted:c}=e;return t.jsxs(Ai,{children:[l?t.jsx(o.Box,{color:s.palette.text.secondary,children:t.jsx(Ei,{color:"inherit",component:"span",variant:"subtitle2",children:l})}):null,t.jsx(o.Box,{fontWeight:c?"bold":"",children:t.jsx(on,{value:a,enabled:n,options:r,formatter:i})}),p?t.jsx(o.Box,{color:s.palette.text.secondary,children:t.jsx(Bi,{color:"inherit",component:"span",variant:"subtitle2",children:p})}):null]})}const Li=e=>e,Mt=[],Di=o.styled("div")(({theme:e})=>({"&:nth-of-type(n+2)":{marginTop:e.spacing(2)}}));function Ni({data:e=Mt,colors:n=Mt,animated:r=!0,animationOptions:i,formatter:s=Li,isLoading:l=!1}){const a=Ri(e,n);return l?t.jsx(_t,{}):t.jsx("div",{children:a.map((p,c)=>t.jsxs(Di,{children:[t.jsx(Pi,{row:p,animated:r,animationOptions:i,formatter:s}),t.jsx(Ci,{row:p})]},c))})}function Ri(e,n){const r=e.map((s,l)=>({...s,color:n[l],shouldBeHighlighted:!1})).filter(s=>s.value!==void 0);return r&&r.length>1&&(r[0].shouldBeHighlighted=!0),r}function $i(e,n=[],r=[],i,s=[]){return e.map((l,a)=>{const p=s.length>0&&!s.includes(l.name),g=(n!=null&&n.length?n:i.palette.qualitative.bold)[a];return{...l,key:l.name,color:p?o.lighten(g,.8):g,name:r[a]??l.name}})}function Oi(e,n,r){const i=`
20
20
  font-size: 12px;
21
21
  line-height: 1.33;
22
22
  font-weight: 600;
23
23
  margin: 4px 0 4px 0;
24
- `,i=`
24
+ `,s=`
25
25
  font-size: 12px;
26
26
  line-height: 1.33;
27
27
  font-weight: normal;
28
28
  margin: 0 0 4px 0;
29
- `,a=Array.isArray(e)?e[0]:e;if(!a)return null;const l=a.data,x=n(l.value),c=o?a.seriesName:x,d=n(a.percent);return`
30
- <p style="${r}">${l.name}</p>
31
- <p style="${i}">${String(a.marker)} ${c} (${d} %)</p>
32
- `.trim()}const Yr=e=>e,Vr=()=>{},Le=[],Ur="260px";function qr({names:e=Le,data:n=Le,labels:o=Le,colors:r=Le,height:i=Ur,animation:a=!0,formatter:l=Yr,tooltipFormatter:x=Hr,selectedCategories:c=[],onCategorySelected:d=Vr,isLoading:m=!1}){const u=s.useTheme(),y=p.useRef(),g=p.useMemo(()=>n.map((v,R)=>zr(v,r[R],o[R],u,c)),[n,r,o,u,c]),h=p.useMemo(()=>{const v=g.length>1;let R;x&&(R=C=>x(C,l,v));const w={trigger:"item",show:!0,backgroundColor:u.palette.black[90],textStyle:{color:u.palette.common.white},confine:!0,borderWidth:0,formatter:R},E={data:v?g.map((C,P)=>e[P]):(g[0]??[]).map(C=>C.name),selectedMode:!1,type:"scroll",left:A.SPACING,bottom:A.SPACING*-.5,itemGap:A.SPACING*3,icon:"circle",itemWidth:A.SPACING,itemHeight:A.SPACING,textStyle:{...u.typography.overline,color:u.palette.text.primary,fontWeight:400,lineHeight:1,verticalAlign:"bottom",padding:[0,0,0,A.SPACING*.5]},inactiveColor:u.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:A.SPACING*1.5,pageIconColor:u.palette.text.secondary,pageIconInactiveColor:u.palette.text.disabled,pageTextStyle:{fontFamily:u.typography.overline.fontFamily,fontSize:A.SPACING*1.5,lineHeight:A.SPACING*1.75,fontWeight:400,color:u.palette.text.primary}},k={formatter:({name:C,percent:P})=>`{per|${l(P)}%}
33
- {b|${C}}`,position:"center",rich:{b:{fontFamily:u.typography.overline.fontFamily,fontSize:A.SPACING*1.75,lineHeight:A.SPACING*1.75,fontWeight:400,color:u.palette.text.primary},per:{...u.typography.overline,fontSize:A.SPACING*3,lineHeight:A.SPACING*4.5,fontWeight:600,color:u.palette.text.primary}}},M=g.map((C,P)=>{var L;return{type:"pie",name:e[P],itemStyle:{color:(L=C[0])==null?void 0:L.color},animation:a,data:C.map($=>({...$,itemStyle:{color:$.color}})),radius:P===0?["75%","90%"]:["56%","72%"],selectedOffset:0,hoverOffset:5,bottom:A.SPACING*2.5,avoidLabelOverlap:!0,label:{show:!1,...k},emphasis:{label:{show:!0,formatter:k.formatter,rich:k.rich}}}});return{grid:{left:0,top:0,right:0,bottom:0},tooltip:w,legend:E,series:M}},[u,e,a,g,l,x]),j={mouseover:(v,R)=>{g.length===1&&(v.seriesIndex!==0||v.dataIndex!==0)&&R.dispatchAction({type:"downplay",seriesIndex:0,dataIndex:0})},mouseout:(v,R)=>{g.length===1&&R.dispatchAction({type:"highlight",seriesIndex:0,dataIndex:0})},click:v=>{const w=g[v.seriesIndex][v.dataIndex].key,b=c.includes(w),E=new Set(c);b?E.delete(w):E.add(w);const k=g[0].length;let M=Array.from(E);M.length===k&&(M=[]),d(M)}};p.useEffect(()=>{y.current&&y.current.dispatchAction({type:g.length===1?"highlight":"downplay",seriesIndex:0,dataIndex:0})},[g]);function f(v){y.current=v}return g.length?m?t.jsxRuntimeExports.jsx(qt,{height:i}):t.jsxRuntimeExports.jsx(Ee,{onChartReady:f,notMerge:!0,option:h,onEvents:j,style:{maxHeight:i,width:"100%"}}):null}const Kr=()=>{};function pn({icon:e,hoverTooltip:n,clickTooltip:o,enabled:r,onEnabledChange:i=Kr,tooltipPlacement:a="bottom"}){const[l,x]=p.useState(!1),[c,d]=p.useState(r);p.useEffect(()=>{d(r)},[r]),p.useEffect(()=>{if(r){const u=y=>{y.key==="Escape"&&i&&i(!1)};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u)}}},[r,i]);const m=c?o:n;return t.jsxRuntimeExports.jsx(s.ClickAwayListener,{onClickAway:()=>d(!1),children:t.jsxRuntimeExports.jsx(s.Tooltip,{title:m,placement:a,open:l,onOpen:()=>x(!0),onClose:()=>{c||x(!1)},children:t.jsxRuntimeExports.jsx(s.ToggleButton,{value:"selectedMode",selected:r,onClick:()=>i&&i(!r),children:e})})})}var rt={},Zr=A.interopRequireDefaultExports;Object.defineProperty(rt,"__esModule",{value:!0});var xn=rt.default=void 0,Xr=Zr(A.requireCreateSvgIcon()),Jr=t.jsxRuntimeExports;xn=rt.default=(0,Xr.default)((0,Jr.jsx)("path",{d:"M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z"}),"KeyboardArrowDown");const Qr=s.styled(s.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})),ei=s.styled(s.MenuItem,{shouldForwardProp:e=>e!=="disabled"})(({disabled:e,theme:n})=>({...e&&{pointerEvents:"none",color:n.palette.text.disabled}})),ti=s.styled(s.MenuItem)(()=>({"&.Mui-disabled":{opacity:1}})),ni=()=>{};function dn({selectionModes:e,editModes:n,selectedMode:o,onSelectMode:r=ni,enabled:i,tooltipPlacement:a="bottom",tooltipText:l="",menuHeaderText:x="",editDisabled:c}){const d=s.useTheme(),[m,u]=p.useState(null),y=!!m,g=w=>u(w.currentTarget),h=()=>u(null),j=w=>{r&&r(w),h()},f=!!e.length&&!!n.length,v=w=>n.some(b=>b.id===w.id);function R(w){return t.jsxRuntimeExports.jsx(ei,{selected:i&&o===w.id,onClick:()=>j(w.id),disabled:c&&v(w),children:t.jsxRuntimeExports.jsxs(s.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[w.icon,t.jsxRuntimeExports.jsx(s.Box,{ml:2,children:t.jsxRuntimeExports.jsx(B.Typography,{variant:"body2",color:"inherit",children:s.capitalize(w.label)})})]})},w.id)}return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(s.Tooltip,{title:l,placement:a,children:t.jsxRuntimeExports.jsx(Qr,{id:"feature-selection-menu-button","aria-controls":"feature-selection-menu","aria-haspopup":"true","aria-expanded":y?"true":void 0,onClick:g,isOpen:y,children:t.jsxRuntimeExports.jsx(xn,{})})}),t.jsxRuntimeExports.jsxs(s.Menu,{id:"feature-selection-menu",style:{zIndex:d.zIndex.tooltip+1},anchorEl:m,open:y,onClose:h,MenuListProps:{"aria-labelledby":"feature-selection-menu-button"},children:[x&&t.jsxRuntimeExports.jsx(ti,{disabled:!0,children:t.jsxRuntimeExports.jsx(B.Typography,{variant:"caption",color:"textSecondary",children:x})}),!!e.length&&e.map(R),f&&t.jsxRuntimeExports.jsx(s.Divider,{sx:{margin:({spacing:w})=>w(1,0)}}),!!n.length&&n.map(R)]})]})}const si=s.styled(s.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"}})),oi=()=>{};function mn({features:e,onSelectGeometry:n=oi,onDeleteGeometry:o,chipTooltip:r,disabledChipTooltip:i,size:a="medium",tooltipPlacement:l="bottom",chipLabel:x}){const c=J.useIntl(),d=B.useImperativeIntl(c);function m(h){return h==="MultiPoint"?d.formatMessage({id:"c4r.widgets.featureSelection.point"}):h==="MultiLineString"?d.formatMessage({id:"c4r.widgets.featureSelection.lineString"}):h==="MultiPolygon"||h==="Polygon"||h==="GeometryCollection"?d.formatMessage({id:"c4r.widgets.featureSelection.polygon"}):h}function u(h,j){var v;const f=m(h.geometry.type);return x||((v=h.properties)==null?void 0:v.name)||`${f} ${j+1}`}const[y,g]=p.useState(!1);return t.jsxRuntimeExports.jsx(s.Box,{sx:{overflowX:"auto"},children:t.jsxRuntimeExports.jsx(si,{sx:{gap:a==="small"?.5:1},children:e.map((h,j)=>{var b,E;const f=(b=h.properties)==null?void 0:b.disabled,v=(E=h.properties)==null?void 0:E.invalid;let R=r;f&&(R=i||r),v&&(R=d.formatMessage({id:"c4r.widgets.featureSelection.invalid"})),y&&(R=d.formatMessage({id:"c4r.widgets.featureSelection.remove"}));let w="secondary";return f&&(w="default"),v&&(w="error"),t.jsxRuntimeExports.jsx(s.ListItem,{disablePadding:!0,children:t.jsxRuntimeExports.jsx(s.Tooltip,{disableHoverListener:f?!i:!r,title:R,placement:l,children:t.jsxRuntimeExports.jsx(s.Chip,{size:a,label:u(h,j),color:w,onClick:()=>n(h),onDelete:o?()=>o(h):void 0,icon:v?t.jsxRuntimeExports.jsx(fe.ErrorOutline,{color:"error"}):void 0,deleteIcon:t.jsxRuntimeExports.jsx(fe.Cancel,{onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1)})})})},j)})})})}const ri=s.styled(s.Paper)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",maxHeight:e.spacing(5),padding:e.spacing(.5)})),ii=[];function ai({selectionModes:e,editModes:n=ii,selectedMode:o,onSelectMode:r,enabled:i=!1,onEnabledChange:a,geometry:l,onSelectGeometry:x,onDeleteGeometry:c,tooltipPlacement:d="bottom",size:m="medium",chipLabel:u}){const y=J.useIntl(),g=B.useImperativeIntl(y),h=p.useMemo(()=>e.map(b=>({...b,label:g.formatMessage({id:`c4r.widgets.featureSelection.${Lt(b.id)}`})})),[e,g]),j=p.useMemo(()=>n.map(b=>({...b,label:g.formatMessage({id:`c4r.widgets.featureSelection.${Lt(b.id)}`})})),[n,g]),f=p.useMemo(()=>{const E=[...h.map(k=>({...k,isEdit:!1})),...j.map(k=>({...k,isEdit:!0}))].find(k=>k.id===o);if(!E)throw new Error(`Selected mode "${o}" not supported`);return E},[j,h,o]),v=s.capitalize((f==null?void 0:f.label)||""),R=f!=null&&f.isEdit?v:g.formatMessage({id:"c4r.widgets.featureSelection.selectTool"},{label:v}),w=f!=null&&f.isEdit?g.formatMessage({id:"c4r.widgets.featureSelection.clickToEdit"}):g.formatMessage({id:"c4r.widgets.featureSelection.clickToCreate"});return t.jsxRuntimeExports.jsxs(ri,{children:[t.jsxRuntimeExports.jsx(pn,{icon:f==null?void 0:f.icon,hoverTooltip:R,clickTooltip:w,enabled:i,onEnabledChange:a,tooltipPlacement:d}),t.jsxRuntimeExports.jsx(dn,{selectionModes:h,editModes:j,selectedMode:o,onSelectMode:r,enabled:i,tooltipPlacement:d,tooltipText:g.formatMessage({id:"c4r.widgets.featureSelection.selectMode"}),menuHeaderText:g.formatMessage({id:"c4r.widgets.featureSelection.chooseSelectionMode"}),editDisabled:!l}),!!l&&t.jsxRuntimeExports.jsx(mn,{features:[l],onSelectGeometry:x,onDeleteGeometry:c,disabledChipTooltip:g.formatMessage({id:"c4r.widgets.featureSelection.applyMask"}),chipTooltip:g.formatMessage({id:"c4r.widgets.featureSelection.clearMask"}),tooltipPlacement:d,size:m,chipLabel:u})]})}function Lt(e){return e.charAt(0).toLowerCase()+e.slice(1)}var it={},li=A.interopRequireDefaultExports;Object.defineProperty(it,"__esModule",{value:!0});var gn=it.default=void 0,ci=li(A.requireCreateSvgIcon()),ui=t.jsxRuntimeExports;gn=it.default=(0,ci.default)((0,ui.jsx)("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close");var at={},pi=A.interopRequireDefaultExports;Object.defineProperty(at,"__esModule",{value:!0});var fn=at.default=void 0,xi=pi(A.requireCreateSvgIcon()),di=t.jsxRuntimeExports;fn=at.default=(0,xi.default)((0,di.jsx)("path",{d:"m11.99 18.54-7.37-5.73L3 14.07l9 7 9-7-1.63-1.27zM12 16l7.36-5.73L21 9l-9-7-9 7 1.63 1.27zm0-11.47L17.74 9 12 13.47 6.26 9z"}),"LayersOutlined");var lt={},mi=A.interopRequireDefaultExports;Object.defineProperty(lt,"__esModule",{value:!0});var hn=lt.default=void 0,gi=mi(A.requireCreateSvgIcon()),fi=t.jsxRuntimeExports;hn=lt.default=(0,gi.default)((0,fi.jsx)("path",{d:"M12 6c3.79 0 7.17 2.13 8.82 5.5C19.17 14.87 15.79 17 12 17s-7.17-2.13-8.82-5.5C4.83 8.13 8.21 6 12 6m0-2C7 4 2.73 7.11 1 11.5 2.73 15.89 7 19 12 19s9.27-3.11 11-7.5C21.27 7.11 17 4 12 4m0 5c1.38 0 2.5 1.12 2.5 2.5S13.38 14 12 14s-2.5-1.12-2.5-2.5S10.62 9 12 9m0-2c-2.48 0-4.5 2.02-4.5 4.5S9.52 16 12 16s4.5-2.02 4.5-4.5S14.48 7 12 7"}),"VisibilityOutlined");var ct={},hi=A.interopRequireDefaultExports;Object.defineProperty(ct,"__esModule",{value:!0});var jn=ct.default=void 0,ji=hi(A.requireCreateSvgIcon()),yi=t.jsxRuntimeExports;jn=ct.default=(0,ji.default)((0,yi.jsx)("path",{d:"M12 6c3.79 0 7.17 2.13 8.82 5.5-.59 1.22-1.42 2.27-2.41 3.12l1.41 1.41c1.39-1.23 2.49-2.77 3.18-4.53C21.27 7.11 17 4 12 4c-1.27 0-2.49.2-3.64.57l1.65 1.65C10.66 6.09 11.32 6 12 6m-1.07 1.14L13 9.21c.57.25 1.03.71 1.28 1.28l2.07 2.07c.08-.34.14-.7.14-1.07C16.5 9.01 14.48 7 12 7c-.37 0-.72.05-1.07.14M2.01 3.87l2.68 2.68C3.06 7.83 1.77 9.53 1 11.5 2.73 15.89 7 19 12 19c1.52 0 2.98-.29 4.32-.82l3.42 3.42 1.41-1.41L3.42 2.45zm7.5 7.5 2.61 2.61c-.04.01-.08.02-.12.02-1.38 0-2.5-1.12-2.5-2.5 0-.05.01-.08.01-.13m-3.4-3.4 1.75 1.75c-.23.55-.36 1.15-.36 1.78 0 2.48 2.02 4.5 4.5 4.5.63 0 1.23-.13 1.77-.36l.98.98c-.88.24-1.8.38-2.75.38-3.79 0-7.17-2.13-8.82-5.5.7-1.43 1.72-2.61 2.93-3.53"}),"VisibilityOffOutlined");var ut={},Ei=A.interopRequireDefaultExports;Object.defineProperty(ut,"__esModule",{value:!0});var yn=ut.default=void 0,Ri=Ei(A.requireCreateSvgIcon()),vi=t.jsxRuntimeExports;yn=ut.default=(0,Ri.default)((0,vi.jsx)("path",{d:"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"}),"ExpandMore");var pt={},wi=A.interopRequireDefaultExports;Object.defineProperty(pt,"__esModule",{value:!0});var En=pt.default=void 0,bi=wi(A.requireCreateSvgIcon()),Si=t.jsxRuntimeExports;En=pt.default=(0,bi.default)((0,Si.jsx)("path",{d:"m12 8-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"}),"ExpandLess");const Rn=240,Ii=s.styled(s.Paper,{shouldForwardProp:e=>e!=="collapsed"})(({theme:e,collapsed:n})=>({width:n?"min-content":Rn,background:e.palette.background.paper,maxHeight:"calc(100% - 120px)",display:"flex",flexDirection:"column"})),ki=s.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}`})),Mi=s.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})),Ti=s.styled("div")(({theme:e})=>({display:"flex",gap:e.spacing(2),alignItems:"center",padding:e.spacing(1),minWidth:`calc(${Rn}px - ${e.spacing(4)})`})),Ci=s.styled(s.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}})),Ai=s.styled("ul",{shouldForwardProp:e=>e!=="opacity"})(({theme:e,opacity:n})=>({opacity:n,margin:0,padding:0,display:"flex",flexDirection:"column",gap:e.spacing(1)})),vn=s.styled("ul")(({theme:e})=>({margin:0,padding:0,paddingBottom:e.spacing(1),display:"flex",flexDirection:"column"})),Bi=s.styled("li")(()=>({display:"flex",alignItems:"center"})),Pi=s.styled("div")(({theme:e})=>({marginRight:e.spacing(1.5),width:A.ICON_SIZE_MEDIUM,height:A.ICON_SIZE_MEDIUM,"& img":{margin:"auto",display:"block"}})),Dt=s.styled(s.Box,{shouldForwardProp:e=>e!=="width"})(({width:e,theme:n})=>({width:e,overflow:"auto",maxHeight:`calc(100% - ${n.spacing(1.5)})`})),Li=s.styled("section")(({theme:e})=>({"&:not(:first-of-type)":{borderTop:`1px solid ${e.palette.divider}`}})),Di=s.styled("div")(()=>({flexGrow:1,flexShrink:1,minWidth:0}));function $i({menuRef:e,open:n,toggleOpen:o,opacity:r,onChange:i}){const a=J.useIntl(),l=B.useImperativeIntl(a);function x(c){const d=parseInt(c.target.value||"0"),m=Math.min(Math.max(d,0),100);i(m/100)}return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(s.Tooltip,{title:l.formatMessage({id:"c4r.widgets.legend.opacity"}),children:t.jsxRuntimeExports.jsx(s.IconButton,{size:"small",color:n?"primary":"default",onClick:()=>o(!n),children:t.jsxRuntimeExports.jsx($e.OpacityIcon,{})})}),t.jsxRuntimeExports.jsx(s.Popover,{open:n,onClose:()=>o(!1),anchorEl:e.current,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{root:{sx:{transform:"translate(-12px, 36px)"}}},children:t.jsxRuntimeExports.jsxs(Ti,{children:[t.jsxRuntimeExports.jsx(s.Slider,{value:r*100,onChange:(c,d)=>i(d/100),min:0,max:100,step:1}),t.jsxRuntimeExports.jsx(Ci,{size:"small",type:"number",value:Math.round(r*100),onChange:x,inputProps:{step:1,min:0,max:100,style:{appearance:"textfield"},"data-testid":"opacity-slider"},InputProps:{endAdornment:t.jsxRuntimeExports.jsxs(s.InputAdornment,{position:"end",sx:{margin:0},children:[" ","%"]})}})]})})]})}function xt({title:e,visible:n,typographyProps:o}){const r=p.useRef(null),[i,a]=p.useState(!1);p.useLayoutEffect(()=>{if(n&&r.current){const{offsetWidth:x,scrollWidth:c}=r.current;a(x<c)}},[e,n]);const l=t.jsxRuntimeExports.jsx(B.Typography,{ref:r,color:n?"textPrimary":"textSecondary",variant:"button",weight:"medium",component:"p",noWrap:!0,my:.25,...o,children:e});return i?t.jsxRuntimeExports.jsx(s.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 Ze=20;function wn({legend:e}){const{labels:n=[],colors:o=[],isStrokeColor:r=!1,customMarkers:i,maskedMarkers:a=!0}=e,l=je.getPalette(o,n.length),x=n.length>Ze,c=J.useIntl(),d=B.useImperativeIntl(c);return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(vn,{"data-testid":"categories-legend",children:n.slice(0,Ze).map((m,u)=>t.jsxRuntimeExports.jsx(Wi,{label:String(m),color:l[u%l.length],icon:i&&Array.isArray(i)?i[u]:i,maskedIcon:a,isStrokeColor:r},`${m}${u}`))}),x&&t.jsxRuntimeExports.jsx(B.Typography,{variant:"caption",color:"textSecondary",component:"div",py:2,children:d.formatMessage({id:"c4r.widgets.legend.maxCategories"},{n:Ze})})]})}const Oi=({isMax:e,color:n,isStrokeColor:o,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"},...o?{borderColor:n}:{backgroundColor:n}}),Ni=({icon:e,color:n,maskedIcon:o})=>({maskRepeat:"no-repeat",maskSize:"cover",backgroundRepeat:"no-repeat",backgroundSize:"cover",...o?{backgroundColor:n,maskImage:`url(${e})`,WebkitMaskImage:`url(${e})`}:{backgroundColor:"rgba(0,0,0,0)",backgroundImage:`url(${e})`}}),Fi=s.styled(s.Box,{shouldForwardProp:e=>e!=="icon"&&e!=="maskedIcon"&&e!=="color"&&e!=="isStrokeColor"})(({icon:e,maskedIcon:n,color:o,isStrokeColor:r,theme:i})=>({whiteSpace:"nowrap",display:"block",width:i.spacing(1.5),height:i.spacing(1.5),flexShrink:"0",borderRadius:"50%",position:"relative",border:"2px solid transparent",...e?Ni({icon:e,color:o,maskedIcon:n}):Oi({color:o,isStrokeColor:r,theme:i})}));function Wi({label:e,isStrokeColor:n,color:o="#000",icon:r,maskedIcon:i}){return t.jsxRuntimeExports.jsxs(s.Box,{component:"li",sx:{display:"flex",alignItems:"center"},children:[t.jsxRuntimeExports.jsx(Fi,{className:"marker",mr:1.5,component:"span",icon:r,maskedIcon:i,isStrokeColor:n,color:o}),t.jsxRuntimeExports.jsx(xt,{title:e,visible:!0,typographyProps:{variant:"overline",my:.75}})]})}const De=6,Ge={0:12,1:9,2:6,3:3},_i=s.styled(s.Box,{shouldForwardProp:e=>e!=="index"})(({index:e=0,theme:n})=>{const o=n.spacing(Ge[e]),r=n.spacing(Ge[e]);return{border:`solid 1px ${n.palette.divider}`,backgroundColor:n.palette.background.default,borderRadius:"50%",position:"absolute",right:0,bottom:0,width:o,height:r}}),Gi=s.styled(s.Box)(({theme:{spacing:e}})=>({display:"flex",justifyContent:"flex-end",flexShrink:0,position:"relative",width:e(Ge[0]),height:e(Ge[0])})),zi=s.styled(s.Box)(({theme:{spacing:e}})=>({display:"flex",gap:e(1),alignItems:"stretch",justifyContent:"stretch",padding:e(2,0)})),Hi=s.styled(s.Box)(()=>({display:"flex",flexDirection:"column",justifyContent:"space-around",gap:1,flexGrow:1,flexShrink:1}));function bn({legend:e}){const n=J.useIntl(),o=B.useImperativeIntl(n),r=e.showMinMax??!0,{min:i,max:a,error:l}=Yi(e),[x,c]=l?[0,0]:Vi(i,a);return t.jsxRuntimeExports.jsxs(zi,{"data-testid":"proportion-legend",children:[t.jsxRuntimeExports.jsx(Gi,{children:[...Array(4)].map((d,m)=>t.jsxRuntimeExports.jsx(_i,{index:m,component:"span"},m))}),t.jsxRuntimeExports.jsx(Hi,{children:l?t.jsxRuntimeExports.jsx(s.Box,{maxWidth:240,children:t.jsxRuntimeExports.jsx(B.Typography,{variant:"overline",children:"You need to specify valid numbers for the labels property"})}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsxs(B.Typography,{variant:"overline",color:"textSecondary",children:[r&&o.formatMessage({id:"c4r.widgets.legend.max"})+": ",n.formatNumber(a,{maximumSignificantDigits:De})]}),t.jsxRuntimeExports.jsx(B.Typography,{variant:"overline",color:"textSecondary",children:n.formatNumber(c,{maximumSignificantDigits:De})}),t.jsxRuntimeExports.jsx(B.Typography,{variant:"overline",color:"textSecondary",children:n.formatNumber(x,{maximumSignificantDigits:De})}),t.jsxRuntimeExports.jsxs(B.Typography,{variant:"overline",color:"textSecondary",children:[r&&o.formatMessage({id:"c4r.widgets.legend.min"})+": ",n.formatNumber(i,{maximumSignificantDigits:De})]})]})})]})}function Sn({labels:e}){let n=e==null?void 0:e[e.length-1],o=e==null?void 0:e[0];return Number.isFinite(o)||(o=parseInt(String(o),10)),Number.isFinite(n)||(n=parseInt(String(n),10)),[o,n]}function Yi(e){let n=!1;const[o,r]=Sn(e);return(Number.isNaN(o)||Number.isNaN(r))&&(n=!0),{min:o,max:r,error:n}}function Vi(e,n){const o=(n-e)/3;return[e+o,n-o]}function In({legend:e}){const{labels:n=[],icons:o=[]}=e;return t.jsxRuntimeExports.jsx(vn,{"data-testid":"icon-legend",children:n.map((r,i)=>t.jsxRuntimeExports.jsxs(Bi,{children:[t.jsxRuntimeExports.jsx(Pi,{children:t.jsxRuntimeExports.jsx("img",{src:o[i],alt:r,width:"auto",height:A.ICON_SIZE_MEDIUM})}),t.jsxRuntimeExports.jsx(xt,{visible:!0,title:r,typographyProps:{variant:"overline",my:.75}})]},r))})}function Ui(e){return typeof e[0]=="object"&&"label"in e[0]}function tt({isContinuous:e=!1,legend:n}){const{labels:o=[],colors:r=[],showMinMax:i=!0}=n,a=je.getPalette(r,!o.length||e?2:o.length+1),l=Ui(o),x=l?o.map(({value:h})=>h):o,c=l?o.map(({label:h})=>h):o,[d,m]=Sn({labels:x}),u=Number.isNaN(d)||Number.isNaN(m);let y=c[c.length-1],g=c[0];return!e&&i&&(g="< "+g,y="≥ "+y),t.jsxRuntimeExports.jsx(s.Box,{py:2,"data-testid":"ramp-legend",children:u?t.jsxRuntimeExports.jsx(s.Box,{maxWidth:240,children:t.jsxRuntimeExports.jsx(B.Typography,{variant:"overline",children:"You need to specify valid numbers for the labels property"})}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(s.Box,{display:"flex",pb:1,children:e?t.jsxRuntimeExports.jsx(qi,{"data-testid":"step-continuous",palette:a}):t.jsxRuntimeExports.jsx(Zi,{palette:a,labels:c,max:y,min:g})}),t.jsxRuntimeExports.jsxs(s.Box,{display:"flex",justifyContent:"space-between",children:[t.jsxRuntimeExports.jsx(B.Typography,{variant:"overlineDelicate",color:"textSecondary",children:g}),t.jsxRuntimeExports.jsx(B.Typography,{variant:"overlineDelicate",color:"textSecondary",children:y})]})]})})}const qi=s.styled(s.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()})`})),Ki=s.styled(s.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 Zi({labels:e=[],palette:n=[],max:o,min:r}){const i=e.length?[r,...e]:[r,o];return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:i.map((a,l)=>{const x=l===0?r:l===i.length-1?o:`${a} - ${i[l+1]}`;return t.jsxRuntimeExports.jsx(s.Tooltip,{title:x,children:t.jsxRuntimeExports.jsx(Ki,{"data-testid":"step-discontinuous",color:n[l]})},l)})})}const Xi={[ce.CATEGORY]:wn,[ce.PROPORTION]:bn,[ce.ICON]:In,[ce.BINS]:e=>t.jsxRuntimeExports.jsx(tt,{...e,isContinuous:!1}),[ce.CONTINUOUS_RAMP]:e=>t.jsxRuntimeExports.jsx(tt,{...e,isContinuous:!0})};function Ji({legend:e}){const n=J.useIntl(),o=B.useImperativeIntl(n);return e.select||!e.type?null:t.jsxRuntimeExports.jsxs(B.Typography,{variant:"body2",color:"textSecondary",component:"p",children:[e.type," ",o.formatMessage({id:"c4r.widgets.legend.notSupported"}),"."]})}function Qi(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 ea({layer:e,legend:n,customLegendTypes:o,onChangeSelection:r}){var m;const i=J.useIntl(),a=B.useImperativeIntl(i),l=n.type,c=Xi[l]??o[l]??Ji,d=((m=n.select)==null?void 0:m.options)??[];return t.jsxRuntimeExports.jsxs(s.Box,{component:"li","data-testid":"legend-layer-variable",px:2,children:[n.attr?t.jsxRuntimeExports.jsxs(s.Box,{pb:1,children:[t.jsxRuntimeExports.jsx(B.Typography,{gutterBottom:!0,variant:"overlineDelicate",color:"textSecondary",component:"p",children:a.formatMessage({id:Qi(n)})}),t.jsxRuntimeExports.jsx(B.Typography,{variant:"caption",component:"p",children:n.attr})]}):null,n.select?t.jsxRuntimeExports.jsxs(s.Box,{pb:1,children:[t.jsxRuntimeExports.jsx(B.Typography,{variant:"caption",weight:"medium",component:"p",children:n.select.label}),t.jsxRuntimeExports.jsx(s.Select,{"data-testid":"legend-layer-variable-select",name:"legend-select",value:n.select.value,renderValue:u=>{var y;return((y=d.find(g=>g.value===u))==null?void 0:y.label)??u},onChange:u=>r(u.target.value),MenuProps:{transformOrigin:{vertical:"bottom",horizontal:"left"},anchorOrigin:{vertical:"top",horizontal:"left"},PaperProps:{style:{maxHeight:240}}},children:d.map(u=>t.jsxRuntimeExports.jsx(s.MenuItem,{value:u.value,children:t.jsxRuntimeExports.jsx(s.ListItemText,{primary:u.label})},u.value))})]}):null,t.jsxRuntimeExports.jsx(c,{layer:e,legend:n})]})}const ta={};function kn(e){return e?Array.isArray(e)?e.every(n=>kn(n)):!e.select&&!e.type:!0}function $t({customLegendTypes:e=ta,layer:n,onChangeCollapsed:o,onChangeOpacity:r,onChangeVisibility:i,onChangeSelection:a,maxZoom:l=21,minZoom:x=0,currentZoom:c=0}){const d=J.useIntl(),m=B.useImperativeIntl(d),u=p.useRef(null),[y,g]=p.useState(!1),h=n.id,j=n.title,f=n.visible??!0,v=n.switchable??!0,R=n.collapsed??!1,w=(n.collapsible??!0)&&!kn(n.legend),b=n.opacity??1,E=n.showOpacityControl??!0,k=f&&!R,M=k?t.jsxRuntimeExports.jsx(En,{}):t.jsxRuntimeExports.jsx(yn,{}),D=(n==null?void 0:n.minZoom)!==void 0||(n==null?void 0:n.maxZoom)!==void 0,C=n.minZoom??x,P=n.maxZoom??l,L=D&&(C>x||P<l),$=c<C||c>P,z=na({intl:m,minZoom:x,maxZoom:l,layerMinZoom:C,layerMaxZoom:P}),G=n.helperText??(L?z:""),S=p.useMemo(()=>n.legend?Array.isArray(n.legend)?n.legend:[n.legend]:[],[n.legend]);return n.legend?t.jsxRuntimeExports.jsxs(Li,{"data-testid":"legend-layer","aria-label":j,children:[t.jsxRuntimeExports.jsxs(Mi,{ref:u,children:[w&&t.jsxRuntimeExports.jsx(s.IconButton,{size:"small","aria-label":m.formatMessage({id:R?"c4r.widgets.legend.expand":"c4r.widgets.legend.collapse"}),disabled:!f,onClick:()=>o({id:h,collapsed:!R}),children:M}),t.jsxRuntimeExports.jsxs(Di,{children:[t.jsxRuntimeExports.jsx(xt,{visible:f,title:j??""}),L&&t.jsxRuntimeExports.jsx(s.Tooltip,{title:m.formatMessage({id:"c4r.widgets.legend.zoomLevelTooltip"}),children:t.jsxRuntimeExports.jsxs(B.Typography,{color:f?"textPrimary":"textSecondary",variant:"caption",component:"p",children:[m.formatMessage({id:"c4r.widgets.legend.zoomLevel"})," ",n.minZoom," - ",n.maxZoom]})})]}),E&&f&&!R&&t.jsxRuntimeExports.jsx($i,{menuRef:u,open:y,toggleOpen:g,opacity:b,onChange:N=>r({id:h,opacity:N})}),v&&t.jsxRuntimeExports.jsx(s.Tooltip,{title:m.formatMessage({id:f?"c4r.widgets.legend.hideLayer":"c4r.widgets.legend.showLayer"}),children:t.jsxRuntimeExports.jsx(s.IconButton,{size:"small",onClick:()=>i({id:h,collapsed:f?R:!1,visible:!f}),children:f?t.jsxRuntimeExports.jsx(hn,{}):t.jsxRuntimeExports.jsx(jn,{})})})]}),t.jsxRuntimeExports.jsxs(s.Collapse,{unmountOnExit:!0,timeout:100,in:k,children:[t.jsxRuntimeExports.jsx(Ai,{"data-testid":"legend-layer-variable-list",opacity:$?.5:1,children:S.map((N,I)=>t.jsxRuntimeExports.jsx(ea,{legend:N,layer:n,customLegendTypes:e,onChangeSelection:O=>a({id:h,index:I,selection:O})},`${N.type}-${I}`))}),G&&t.jsxRuntimeExports.jsx(B.Typography,{variant:"caption",color:"textSecondary",component:"div",p:2,children:t.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:G}})})]})]}):null}function na({intl:e,minZoom:n,maxZoom:o,layerMinZoom:r,layerMaxZoom:i}){const a=e.formatMessage({id:"c4r.widgets.legend.and"}),l=e.formatMessage({id:"c4r.widgets.legend.lowerThan"}),x=e.formatMessage({id:"c4r.widgets.legend.greaterThan"}),c=e.formatMessage({id:"c4r.widgets.legend.zoomNote"}),d=i<o?`${l} ${i}`:"",m=r>n?`${x} ${r}`:"",u=[d,m].filter(Boolean).join(` ${a} `);return u?`${c} ${u}`:""}const sa={},ke=()=>{},oa=[];function ra({customLegendTypes:e=sa,layers:n=oa,collapsed:o=!1,onChangeCollapsed:r=ke,onChangeVisibility:i=ke,onChangeOpacity:a=ke,onChangeLegendRowCollapsed:l=ke,onChangeSelection:x=ke,title:c="Layers",maxZoom:d=20,minZoom:m=0,currentZoom:u,isMobile:y,sx:g}){const h=J.useIntl(),j=B.useImperativeIntl(h),f=t.jsxRuntimeExports.jsxs(ki,{collapsed:o,children:[t.jsxRuntimeExports.jsx(B.Typography,{variant:"caption",flexGrow:1,children:c}),t.jsxRuntimeExports.jsx(s.Tooltip,{title:j.formatMessage({id:"c4r.widgets.legend.close"}),children:t.jsxRuntimeExports.jsx(s.IconButton,{size:"small",onClick:()=>r(!0),children:t.jsxRuntimeExports.jsx(gn,{})})})]}),v=t.jsxRuntimeExports.jsx(s.Tooltip,{title:j.formatMessage({id:"c4r.widgets.legend.open"}),children:t.jsxRuntimeExports.jsx(s.IconButton,{"aria-label":c,onClick:()=>r(!1),children:t.jsxRuntimeExports.jsx(fn,{})})});return t.jsxRuntimeExports.jsx(Ii,{sx:g,elevation:3,collapsed:o||!!y,children:y?t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[v,t.jsxRuntimeExports.jsxs(s.Drawer,{anchor:"bottom",open:!o,onClose:()=>r(!0),children:[f,t.jsxRuntimeExports.jsx(Dt,{children:n.map(R=>t.jsxRuntimeExports.jsx($t,{layer:R,onChangeCollapsed:l,onChangeOpacity:a,onChangeVisibility:i,onChangeSelection:x,maxZoom:d,minZoom:m,currentZoom:u,customLegendTypes:e},R.id))})]})]}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[o?v:f,t.jsxRuntimeExports.jsx(Dt,{width:o?0:void 0,children:t.jsxRuntimeExports.jsx(s.Collapse,{unmountOnExit:!0,in:!o,timeout:500,children:n.map(R=>t.jsxRuntimeExports.jsx($t,{layer:R,onChangeCollapsed:l,onChangeOpacity:a,onChangeVisibility:i,onChangeSelection:x,maxZoom:d,minZoom:m,currentZoom:u,customLegendTypes:e},R.id))})})]})})}function Ot({color:e=void 0,children:n}){return n?t.jsxRuntimeExports.jsx(s.Box,{mt:.5,children:t.jsxRuntimeExports.jsx(B.Typography,{component:"div",variant:"caption",color:e??"inherit",style:{fontWeight:"normal"},children:n})}):t.jsxRuntimeExports.jsx(s.Box,{mt:-1})}function ia({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:o=void 0,...r}){return o?t.jsxRuntimeExports.jsx(B.Alert,{title:e,severity:o,...r,children:t.jsxRuntimeExports.jsx(Ot,{children:n})}):t.jsxRuntimeExports.jsxs(s.Box,{...r,children:[e&&t.jsxRuntimeExports.jsx(B.Typography,{variant:"body2",children:e}),t.jsxRuntimeExports.jsx(Ot,{color:"textSecondary",children:n})]})}const aa=s.styled(s.Box,{shouldForwardProp:e=>e!=="margin"})(({theme:e,margin:n})=>({margin:0,position:"relative",maxWidth:"100%",padding:n??e.spacing(2,2.5)})),la=s.styled(s.LinearProgress)(({theme:e})=>({position:"absolute",top:0,left:0,width:"100%",height:e.spacing(.25)})),ca=s.styled(s.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})),ua=s.styled(s.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"}})),Mn=({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",width:e.spacing(3),height:e.spacing(3),color:e.palette.text.secondary}),pa=s.styled(fe.ExpandLess)(({theme:e})=>Mn({theme:e})),xa=s.styled(fe.ExpandMore)(({theme:e})=>Mn({theme:e})),da=s.styled(s.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"}})),ma=s.styled(s.Grid)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1),marginRight:e.spacing(-.5),marginLeft:e.spacing(1)})),Nt=s.styled(s.IconButton)(({theme:e})=>({color:e.palette.text.secondary})),ga=s.styled(s.Menu)(({theme:e})=>({".MuiPaper-root":{marginTop:e.spacing(5),maxHeight:e.spacing(21),minWidth:e.spacing(16)}})),Ft=[],fa=t.jsxRuntimeExports.jsx(fe.MoreVert,{});function ha({title:e,actions:n=Ft,options:o=Ft,optionsIcon:r=fa,children:i,contentProps:a,disabled:l=!1,expandable:x=!0,expanded:c=!0,onExpandedChange:d,footer:m,headerItems:u,isLoading:y=!1,margin:g}){const h=p.createRef(),[j,f]=p.useState(!0),v=c!==void 0&&d!==void 0,R=x!==!1?v?c:j:!0,w=v?d:f,[b,E]=p.useState(null),k=!!b,M=()=>{x&&w(!R)},D=$=>E($.currentTarget),C=()=>E(null);function P($){$&&$(),C()}const L=$=>t.jsxRuntimeExports.jsx(Nt,{"aria-label":$.label,onClick:$.action,size:"small",children:$.icon},$.id);return l?i:t.jsxRuntimeExports.jsxs(aa,{margin:g,component:"section","aria-label":e,children:[y?t.jsxRuntimeExports.jsx(la,{}):null,t.jsxRuntimeExports.jsxs(ca,{container:!0,expanded:c,children:[t.jsxRuntimeExports.jsx(ua,{expandable:x,startIcon:x&&t.jsxRuntimeExports.jsx(s.Icon,{children:R?t.jsxRuntimeExports.jsx(pa,{}):t.jsxRuntimeExports.jsx(xa,{})}),onClick:M,tabIndex:x?0:-1,children:t.jsxRuntimeExports.jsx(s.Tooltip,{title:e,children:t.jsxRuntimeExports.jsx(da,{expanded:c,align:"left",variant:"subtitle1",children:e})})}),t.jsxRuntimeExports.jsxs(ma,{item:!0,children:[u,n.length>0&&n.map($=>$.tooltip?t.jsxRuntimeExports.jsx(s.Tooltip,{title:$.tooltip.text,placement:$.tooltip.placement??"top",children:L($)},$.id):L($)),o.length>0&&t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(Nt,{"aria-label":"options","aria-controls":"options-menu","aria-haspopup":"true",onClick:D,size:"small",children:r}),t.jsxRuntimeExports.jsx(ga,{id:"options-menu",elevation:8,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:b,keepMounted:!0,open:k,onClose:C,children:o.map($=>t.jsxRuntimeExports.jsx(s.MenuItem,{selected:$.selected,onClick:()=>P($.action),children:$.name},$.id))})]})]})]}),t.jsxRuntimeExports.jsx(s.Collapse,{ref:h,in:R,timeout:"auto",unmountOnExit:!0,children:t.jsxRuntimeExports.jsxs(s.Box,{...a,children:[t.jsxRuntimeExports.jsx(s.Box,{pt:1,children:i}),m??t.jsxRuntimeExports.jsx(s.Box,{children:m})]})})]})}exports.BarWidgetUI=Hn;exports.CategoryWidgetUI=ts;exports.ComparativeCategoryWidgetUI=Br;exports.ComparativeFormulaWidgetUI=_r;exports.ComparativePieWidgetUI=qr;exports.FeatureSelectionUIDropdown=dn;exports.FeatureSelectionUIGeometryChips=mn;exports.FeatureSelectionUIToggleButton=pn;exports.FeatureSelectionWidgetUI=ai;exports.FormulaWidgetUI=rs;exports.GroupDateTypes=le;exports.HistogramWidgetUI=ms;exports.LEGEND_TYPES=ce;exports.LegendCategories=wn;exports.LegendIcon=In;exports.LegendProportion=bn;exports.LegendRamp=tt;exports.LegendWidgetUI=ra;exports.NoDataAlert=ia;exports.PieWidgetUI=Gs;exports.RangeWidgetUI=Js;exports.ScatterPlotWidgetUI=ao;exports.TIME_SERIES_CHART_TYPES=He;exports.TableWidgetUI=yo;exports.TimeSeriesProvider=en;exports.TimeSeriesWidgetUI=ur;exports.WrapperWidgetUI=ha;exports.useTimeSeriesContext=Ye;exports.useTimeSeriesInteractivity=tn;
29
+ `,l=Array.isArray(e)?e[0]:e;if(!l)return null;const a=l.data,p=n(a.value),c=r?l.seriesName:p,g=n(l.percent);return`
30
+ <p style="${i}">${a.name}</p>
31
+ <p style="${s}">${String(l.marker)} ${c} (${g} %)</p>
32
+ `.trim()}const Fi=e=>e,Wi=()=>{},De=[],_i="260px";function Gi({names:e=De,data:n=De,labels:r=De,colors:i=De,height:s=_i,animation:l=!0,formatter:a=Fi,tooltipFormatter:p=Oi,selectedCategories:c=[],onCategorySelected:g=Wi,isLoading:h=!1}){const d=o.useTheme(),v=u.useRef(),f=u.useMemo(()=>n.map((b,w)=>$i(b,i[w],r[w],d,c)),[n,i,r,d,c]),m=u.useMemo(()=>{const b=f.length>1;let w;p&&(w=E=>p(E,a,b));const S={trigger:"item",show:!0,backgroundColor:d.palette.black[90],textStyle:{color:d.palette.common.white},confine:!0,borderWidth:0,formatter:w},j={data:b?f.map((E,P)=>e[P]):(f[0]??[]).map(E=>E.name),selectedMode:!1,type:"scroll",left:$.SPACING,bottom:$.SPACING*-.5,itemGap:$.SPACING*3,icon:"circle",itemWidth:$.SPACING,itemHeight:$.SPACING,textStyle:{...d.typography.overline,color:d.palette.text.primary,fontWeight:400,lineHeight:1,verticalAlign:"bottom",padding:[0,0,0,$.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:$.SPACING*1.5,pageIconColor:d.palette.text.secondary,pageIconInactiveColor:d.palette.text.disabled,pageTextStyle:{fontFamily:d.typography.overline.fontFamily,fontSize:$.SPACING*1.5,lineHeight:$.SPACING*1.75,fontWeight:400,color:d.palette.text.primary}},T={formatter:({name:E,percent:P})=>`{per|${a(P)}%}
33
+ {b|${E}}`,position:"center",rich:{b:{fontFamily:d.typography.overline.fontFamily,fontSize:$.SPACING*1.75,lineHeight:$.SPACING*1.75,fontWeight:400,color:d.palette.text.primary},per:{...d.typography.overline,fontSize:$.SPACING*3,lineHeight:$.SPACING*4.5,fontWeight:600,color:d.palette.text.primary}}},C=f.map((E,P)=>{var L;return{type:"pie",name:e[P],itemStyle:{color:(L=E[0])==null?void 0:L.color},animation:l,data:E.map(N=>({...N,itemStyle:{color:N.color}})),radius:P===0?["75%","90%"]:["56%","72%"],selectedOffset:0,hoverOffset:5,bottom:$.SPACING*2.5,avoidLabelOverlap:!0,label:{show:!1,...T},emphasis:{label:{show:!0,formatter:T.formatter,rich:T.rich}}}});return{grid:{left:0,top:0,right:0,bottom:0},tooltip:S,legend:j,series:C}},[d,e,l,f,a,p]),y={mouseover:(b,w)=>{f.length===1&&(b.seriesIndex!==0||b.dataIndex!==0)&&w.dispatchAction({type:"downplay",seriesIndex:0,dataIndex:0})},mouseout:(b,w)=>{f.length===1&&w.dispatchAction({type:"highlight",seriesIndex:0,dataIndex:0})},click:b=>{const S=f[b.seriesIndex][b.dataIndex].key,I=c.includes(S),j=new Set(c);I?j.delete(S):j.add(S);const T=f[0].length;let C=Array.from(j);C.length===T&&(C=[]),g(C)}};u.useEffect(()=>{v.current&&v.current.dispatchAction({type:f.length===1?"highlight":"downplay",seriesIndex:0,dataIndex:0})},[f]);function x(b){v.current=b}return f.length?h?t.jsx(Gt,{height:s}):t.jsx(ve,{onChartReady:x,notMerge:!0,option:m,onEvents:y,style:{maxHeight:s,width:"100%"}}):null}const Hi=()=>{};function rn({icon:e,hoverTooltip:n,clickTooltip:r,enabled:i,onEnabledChange:s=Hi,tooltipPlacement:l="bottom"}){const[a,p]=u.useState(!1),[c,g]=u.useState(i);u.useEffect(()=>{g(i)},[i]),u.useEffect(()=>{if(i){const d=v=>{v.key==="Escape"&&s&&s(!1)};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}}},[i,s]);const h=c?r: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:i,onClick:()=>s&&s(!i),children:e})})})}const zi=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})),Yi=o.styled(o.MenuItem,{shouldForwardProp:e=>e!=="disabled"})(({disabled:e,theme:n})=>({...e&&{pointerEvents:"none",color:n.palette.text.disabled}})),Vi=o.styled(o.MenuItem)(()=>({"&.Mui-disabled":{opacity:1}})),Ui=()=>{};function sn({selectionModes:e,editModes:n,selectedMode:r,onSelectMode:i=Ui,enabled:s,tooltipPlacement:l="bottom",tooltipText:a="",menuHeaderText:p="",editDisabled:c}){const g=o.useTheme(),[h,d]=u.useState(null),v=!!h,f=S=>d(S.currentTarget),m=()=>d(null),y=S=>{i&&i(S),m()},x=!!e.length&&!!n.length,b=S=>n.some(I=>I.id===S.id);function w(S){return t.jsx(Yi,{selected:s&&r===S.id,onClick:()=>y(S.id),disabled:c&&b(S),children:t.jsxs(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[S.icon,t.jsx(o.Box,{ml:2,children:t.jsx(B.Typography,{variant:"body2",color:"inherit",children:o.capitalize(S.label)})})]})},S.id)}return t.jsxs(t.Fragment,{children:[t.jsx(o.Tooltip,{title:a,placement:l,children:t.jsx(zi,{id:"feature-selection-menu-button","aria-controls":"feature-selection-menu","aria-haspopup":"true","aria-expanded":v?"true":void 0,onClick:f,isOpen:v,children:t.jsx(jn,{})})}),t.jsxs(o.Menu,{id:"feature-selection-menu",style:{zIndex:g.zIndex.tooltip+1},anchorEl:h,open:v,onClose:m,MenuListProps:{"aria-labelledby":"feature-selection-menu-button"},children:[p&&t.jsx(Vi,{disabled:!0,children:t.jsx(B.Typography,{variant:"caption",color:"textSecondary",children:p})}),!!e.length&&e.map(w),x&&t.jsx(o.Divider,{sx:{margin:({spacing:S})=>S(1,0)}}),!!n.length&&n.map(w)]})]})}const qi=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"}})),Ki=()=>{};function ln({features:e,onSelectGeometry:n=Ki,onDeleteGeometry:r,chipTooltip:i,disabledChipTooltip:s,size:l="medium",tooltipPlacement:a="bottom",chipLabel:p}){const c=J.useIntl(),g=B.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,y){var b;const x=h(m.geometry.type);return p||((b=m.properties)==null?void 0:b.name)||`${x} ${y+1}`}const[v,f]=u.useState(!1);return t.jsx(o.Box,{sx:{overflowX:"auto"},children:t.jsx(qi,{sx:{gap:l==="small"?.5:1},children:e.map((m,y)=>{var I,j;const x=(I=m.properties)==null?void 0:I.disabled,b=(j=m.properties)==null?void 0:j.invalid;let w=i;x&&(w=s||i),b&&(w=g.formatMessage({id:"c4r.widgets.featureSelection.invalid"})),v&&(w=g.formatMessage({id:"c4r.widgets.featureSelection.remove"}));let S="secondary";return x&&(S="default"),b&&(S="error"),t.jsx(o.ListItem,{disablePadding:!0,children:t.jsx(o.Tooltip,{disableHoverListener:x?!s:!i,title:w,placement:a,children:t.jsx(o.Chip,{size:l,label:d(m,y),color:S,onClick:()=>n(m),onDelete:r?()=>r(m):void 0,icon:b?t.jsx(xe.ErrorOutline,{color:"error"}):void 0,deleteIcon:t.jsx(xe.Cancel,{onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1)})})})},y)})})})}const Zi=o.styled(o.Paper)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",maxHeight:e.spacing(5),padding:e.spacing(.5)})),Xi=[];function Ji({selectionModes:e,editModes:n=Xi,selectedMode:r,onSelectMode:i,enabled:s=!1,onEnabledChange:l,geometry:a,onSelectGeometry:p,onDeleteGeometry:c,tooltipPlacement:g="bottom",size:h="medium",chipLabel:d}){const v=J.useIntl(),f=B.useImperativeIntl(v),m=u.useMemo(()=>e.map(I=>({...I,label:f.formatMessage({id:`c4r.widgets.featureSelection.${Tt(I.id)}`})})),[e,f]),y=u.useMemo(()=>n.map(I=>({...I,label:f.formatMessage({id:`c4r.widgets.featureSelection.${Tt(I.id)}`})})),[n,f]),x=u.useMemo(()=>{const j=[...m.map(T=>({...T,isEdit:!1})),...y.map(T=>({...T,isEdit:!0}))].find(T=>T.id===r);if(!j)throw new Error(`Selected mode "${r}" not supported`);return j},[y,m,r]),b=o.capitalize((x==null?void 0:x.label)||""),w=x!=null&&x.isEdit?b:f.formatMessage({id:"c4r.widgets.featureSelection.selectTool"},{label:b}),S=x!=null&&x.isEdit?f.formatMessage({id:"c4r.widgets.featureSelection.clickToEdit"}):f.formatMessage({id:"c4r.widgets.featureSelection.clickToCreate"});return t.jsxs(Zi,{children:[t.jsx(rn,{icon:x==null?void 0:x.icon,hoverTooltip:w,clickTooltip:S,enabled:s,onEnabledChange:l,tooltipPlacement:g}),t.jsx(sn,{selectionModes:m,editModes:y,selectedMode:r,onSelectMode:i,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(ln,{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 Tt(e){return e.charAt(0).toLowerCase()+e.slice(1)}const an=240,Qi=o.styled(o.Paper,{shouldForwardProp:e=>e!=="collapsed"})(({theme:e,collapsed:n})=>({width:n?"min-content":an,background:e.palette.background.paper,maxHeight:"calc(100% - 120px)",display:"flex",flexDirection:"column"})),es=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}`})),ts=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})),ns=o.styled("div")(({theme:e})=>({display:"flex",gap:e.spacing(2),alignItems:"center",padding:e.spacing(1),minWidth:`calc(${an}px - ${e.spacing(4)})`})),os=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}})),rs=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)})),cn=o.styled("ul")(({theme:e})=>({margin:0,padding:0,paddingBottom:e.spacing(1),display:"flex",flexDirection:"column"})),is=o.styled("li")(()=>({display:"flex",alignItems:"center"})),ss=o.styled("div")(({theme:e})=>({marginRight:e.spacing(1.5),width:$.ICON_SIZE_MEDIUM,height:$.ICON_SIZE_MEDIUM,"& img":{margin:"auto",display:"block"}})),Ct=o.styled(o.Box,{shouldForwardProp:e=>e!=="width"})(({width:e,theme:n})=>({width:e,overflow:"auto",maxHeight:`calc(100% - ${n.spacing(1.5)})`})),ls=o.styled("section")(({theme:e})=>({"&:not(:first-of-type)":{borderTop:`1px solid ${e.palette.divider}`}})),as=o.styled("div")(()=>({flexGrow:1,flexShrink:1,minWidth:0}));function cs({menuRef:e,open:n,toggleOpen:r,opacity:i,onChange:s}){const l=J.useIntl(),a=B.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:()=>r(!n),children:t.jsx(Re.OpacityIcon,{})})}),t.jsx(o.Popover,{open:n,onClose:()=>r(!1),anchorEl:e.current,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{root:{sx:{transform:"translate(-12px, 36px)"}}},children:t.jsxs(ns,{children:[t.jsx(o.Slider,{value:i*100,onChange:(c,g)=>s(g/100),min:0,max:100,step:1}),t.jsx(os,{size:"small",type:"number",value:Math.round(i*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 it({title:e,visible:n,typographyProps:r}){const i=u.useRef(null),[s,l]=u.useState(!1);u.useLayoutEffect(()=>{if(n&&i.current){const{offsetWidth:p,scrollWidth:c}=i.current;l(p<c)}},[e,n]);const a=t.jsx(B.Typography,{ref:i,color:n?"textPrimary":"textSecondary",variant:"button",weight:"medium",component:"p",noWrap:!0,my:.25,...r,children:e});return s?t.jsx(o.Tooltip,{title:e,children:a}):a}var ce=(e=>(e.CATEGORY="category",e.ICON="icon",e.CONTINUOUS_RAMP="continuous_ramp",e.BINS="bins",e.PROPORTION="proportion",e))(ce||{});const Ze=20;function dn({legend:e}){const{labels:n=[],colors:r=[],isStrokeColor:i=!1,customMarkers:s,maskedMarkers:l=!0}=e,a=Te.getPalette(r,n.length),p=n.length>Ze,c=J.useIntl(),g=B.useImperativeIntl(c);return t.jsxs(t.Fragment,{children:[t.jsx(cn,{"data-testid":"categories-legend",children:n.slice(0,Ze).map((h,d)=>t.jsx(gs,{label:String(h),color:a[d%a.length],icon:s&&Array.isArray(s)?s[d]:s,maskedIcon:l,isStrokeColor:i},`${h}${d}`))}),p&&t.jsx(B.Typography,{variant:"caption",color:"textSecondary",component:"div",py:2,children:g.formatMessage({id:"c4r.widgets.legend.maxCategories"},{n:Ze})})]})}const ds=({isMax:e,color:n,isStrokeColor:r,theme:i})=>({border:"2px solid transparent","&::after":{position:"absolute",display:e?"block":"none",content:'""',width:i.spacing(2),height:i.spacing(2),border:`2px solid ${i.palette.grey[900]}`,transform:"translate(-30%, -30%)",borderRadius:"50%",boxSizing:"content-box"},...r?{borderColor:n}:{backgroundColor:n}}),us=({icon:e,color:n,maskedIcon:r})=>({maskRepeat:"no-repeat",maskSize:"cover",backgroundRepeat:"no-repeat",backgroundSize:"cover",...r?{backgroundColor:n,maskImage:`url(${e})`,WebkitMaskImage:`url(${e})`}:{backgroundColor:"rgba(0,0,0,0)",backgroundImage:`url(${e})`}}),ps=o.styled(o.Box,{shouldForwardProp:e=>e!=="icon"&&e!=="maskedIcon"&&e!=="color"&&e!=="isStrokeColor"})(({icon:e,maskedIcon:n,color:r,isStrokeColor:i,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?us({icon:e,color:r,maskedIcon:n}):ds({color:r,isStrokeColor:i,theme:s})}));function gs({label:e,isStrokeColor:n,color:r="#000",icon:i,maskedIcon:s}){return t.jsxs(o.Box,{component:"li",sx:{display:"flex",alignItems:"center"},children:[t.jsx(ps,{className:"marker",mr:1.5,component:"span",icon:i,maskedIcon:s,isStrokeColor:n,color:r}),t.jsx(it,{title:e,visible:!0,typographyProps:{variant:"overline",my:.75}})]})}const Ne=6,Ge={0:12,1:9,2:6,3:3},hs=o.styled(o.Box,{shouldForwardProp:e=>e!=="index"})(({index:e=0,theme:n})=>{const r=n.spacing(Ge[e]),i=n.spacing(Ge[e]);return{border:`solid 1px ${n.palette.divider}`,backgroundColor:n.palette.background.default,borderRadius:"50%",position:"absolute",right:0,bottom:0,width:r,height:i}}),fs=o.styled(o.Box)(({theme:{spacing:e}})=>({display:"flex",justifyContent:"flex-end",flexShrink:0,position:"relative",width:e(Ge[0]),height:e(Ge[0])})),xs=o.styled(o.Box)(({theme:{spacing:e}})=>({display:"flex",gap:e(1),alignItems:"stretch",justifyContent:"stretch",padding:e(2,0)})),ms=o.styled(o.Box)(()=>({display:"flex",flexDirection:"column",justifyContent:"space-around",gap:1,flexGrow:1,flexShrink:1}));function un({legend:e}){const n=J.useIntl(),r=B.useImperativeIntl(n),i=e.showMinMax??!0,{min:s,max:l,error:a}=ys(e),[p,c]=a?[0,0]:vs(s,l);return t.jsxs(xs,{"data-testid":"proportion-legend",children:[t.jsx(fs,{children:[...Array(4)].map((g,h)=>t.jsx(hs,{index:h,component:"span"},h))}),t.jsx(ms,{children:a?t.jsx(o.Box,{maxWidth:240,children:t.jsx(B.Typography,{variant:"overline",children:"You need to specify valid numbers for the labels property"})}):t.jsxs(t.Fragment,{children:[t.jsxs(B.Typography,{variant:"overline",color:"textSecondary",children:[i&&r.formatMessage({id:"c4r.widgets.legend.max"})+": ",n.formatNumber(l,{maximumSignificantDigits:Ne})]}),t.jsx(B.Typography,{variant:"overline",color:"textSecondary",children:n.formatNumber(c,{maximumSignificantDigits:Ne})}),t.jsx(B.Typography,{variant:"overline",color:"textSecondary",children:n.formatNumber(p,{maximumSignificantDigits:Ne})}),t.jsxs(B.Typography,{variant:"overline",color:"textSecondary",children:[i&&r.formatMessage({id:"c4r.widgets.legend.min"})+": ",n.formatNumber(s,{maximumSignificantDigits:Ne})]})]})})]})}function pn({labels:e}){let n=e==null?void 0:e[e.length-1],r=e==null?void 0:e[0];return Number.isFinite(r)||(r=parseInt(String(r),10)),Number.isFinite(n)||(n=parseInt(String(n),10)),[r,n]}function ys(e){let n=!1;const[r,i]=pn(e);return(Number.isNaN(r)||Number.isNaN(i))&&(n=!0),{min:r,max:i,error:n}}function vs(e,n){const r=(n-e)/3;return[e+r,n-r]}function gn({legend:e}){const{labels:n=[],icons:r=[]}=e;return t.jsx(cn,{"data-testid":"icon-legend",children:n.map((i,s)=>t.jsxs(is,{children:[t.jsx(ss,{children:t.jsx("img",{src:r[s],alt:i,width:"auto",height:$.ICON_SIZE_MEDIUM})}),t.jsx(it,{visible:!0,title:i,typographyProps:{variant:"overline",my:.75}})]},i))})}function js(e){return typeof e[0]=="object"&&"label"in e[0]}function tt({isContinuous:e=!1,legend:n}){const{labels:r=[],colors:i=[],showMinMax:s=!0}=n,l=Te.getPalette(i,!r.length||e?2:r.length+1),a=js(r),p=a?r.map(({value:m})=>m):r,c=a?r.map(({label:m})=>m):r,[g,h]=pn({labels:p}),d=Number.isNaN(g)||Number.isNaN(h);let v=c[c.length-1],f=c[0];return!e&&s&&(f="< "+f,v="≥ "+v),t.jsx(o.Box,{py:2,"data-testid":"ramp-legend",children:d?t.jsx(o.Box,{maxWidth:240,children:t.jsx(B.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(ws,{"data-testid":"step-continuous",palette:l}):t.jsx(Ss,{palette:l,labels:c,max:v,min:f})}),t.jsxs(o.Box,{display:"flex",justifyContent:"space-between",children:[t.jsx(B.Typography,{variant:"overlineDelicate",color:"textSecondary",children:f}),t.jsx(B.Typography,{variant:"overlineDelicate",color:"textSecondary",children:v})]})]})})}const ws=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()})`})),bs=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 Ss({labels:e=[],palette:n=[],max:r,min:i}){const s=e.length?[i,...e]:[i,r];return t.jsx(t.Fragment,{children:s.map((l,a)=>{const p=a===0?i:a===s.length-1?r:`${l} - ${s[a+1]}`;return t.jsx(o.Tooltip,{title:p,children:t.jsx(bs,{"data-testid":"step-discontinuous",color:n[a]})},a)})})}const Is={[ce.CATEGORY]:dn,[ce.PROPORTION]:un,[ce.ICON]:gn,[ce.BINS]:e=>t.jsx(tt,{...e,isContinuous:!1}),[ce.CONTINUOUS_RAMP]:e=>t.jsx(tt,{...e,isContinuous:!0})};function ks({legend:e}){const n=J.useIntl(),r=B.useImperativeIntl(n);return e.select||!e.type?null:t.jsxs(B.Typography,{variant:"body2",color:"textSecondary",component:"p",children:[e.type," ",r.formatMessage({id:"c4r.widgets.legend.notSupported"}),"."]})}function Ms(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 Ts({layer:e,legend:n,customLegendTypes:r,onChangeSelection:i}){var h;const s=J.useIntl(),l=B.useImperativeIntl(s),a=n.type,c=Is[a]??r[a]??ks,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(B.Typography,{gutterBottom:!0,variant:"overlineDelicate",color:"textSecondary",component:"p",children:l.formatMessage({id:Ms(n)})}),t.jsx(B.Typography,{variant:"caption",component:"p",children:n.attr})]}):null,n.select?t.jsxs(o.Box,{pb:1,children:[t.jsx(B.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 v;return((v=g.find(f=>f.value===d))==null?void 0:v.label)??d},onChange:d=>i(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 Cs={};function hn(e){return e?Array.isArray(e)?e.every(n=>hn(n)):!e.select&&!e.type:!0}function At({customLegendTypes:e=Cs,layer:n,onChangeCollapsed:r,onChangeOpacity:i,onChangeVisibility:s,onChangeSelection:l,maxZoom:a=21,minZoom:p=0,currentZoom:c=0}){const g=J.useIntl(),h=B.useImperativeIntl(g),d=u.useRef(null),[v,f]=u.useState(!1),m=n.id,y=n.title,x=n.visible??!0,b=n.switchable??!0,w=n.collapsed??!1,S=(n.collapsible??!0)&&!hn(n.legend),I=n.opacity??1,j=n.showOpacityControl??!0,T=x&&!w,C=T?t.jsx(Mn,{}):t.jsx(kn,{}),D=(n==null?void 0:n.minZoom)!==void 0||(n==null?void 0:n.maxZoom)!==void 0,E=n.minZoom??p,P=n.maxZoom??a,L=D&&(E>p||P<a),N=c<E||c>P,H=As({intl:h,minZoom:p,maxZoom:a,layerMinZoom:E,layerMaxZoom:P}),G=n.helperText??(L?H:""),k=u.useMemo(()=>n.legend?Array.isArray(n.legend)?n.legend:[n.legend]:[],[n.legend]);return n.legend?t.jsxs(ls,{"data-testid":"legend-layer","aria-label":y,children:[t.jsxs(ts,{ref:d,children:[S&&t.jsx(o.IconButton,{size:"small","aria-label":h.formatMessage({id:w?"c4r.widgets.legend.expand":"c4r.widgets.legend.collapse"}),disabled:!x,onClick:()=>r({id:m,collapsed:!w}),children:C}),t.jsxs(as,{children:[t.jsx(it,{visible:x,title:y??""}),L&&t.jsx(o.Tooltip,{title:h.formatMessage({id:"c4r.widgets.legend.zoomLevelTooltip"}),children:t.jsxs(B.Typography,{color:x?"textPrimary":"textSecondary",variant:"caption",component:"p",children:[h.formatMessage({id:"c4r.widgets.legend.zoomLevel"})," ",n.minZoom," - ",n.maxZoom]})})]}),j&&x&&!w&&t.jsx(cs,{menuRef:d,open:v,toggleOpen:f,opacity:I,onChange:O=>i({id:m,opacity:O})}),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?w:!1,visible:!x}),children:x?t.jsx(Sn,{}):t.jsx(In,{})})})]}),t.jsxs(o.Collapse,{unmountOnExit:!0,timeout:100,in:T,children:[t.jsx(rs,{"data-testid":"legend-layer-variable-list",opacity:N?.5:1,children:k.map((O,M)=>t.jsx(Ts,{legend:O,layer:n,customLegendTypes:e,onChangeSelection:R=>l({id:m,index:M,selection:R})},`${O.type}-${M}`))}),G&&t.jsx(B.Typography,{variant:"caption",color:"textSecondary",component:"div",p:2,children:t.jsx("div",{dangerouslySetInnerHTML:{__html:G}})})]})]}):null}function As({intl:e,minZoom:n,maxZoom:r,layerMinZoom:i,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<r?`${a} ${s}`:"",h=i>n?`${p} ${i}`:"",d=[g,h].filter(Boolean).join(` ${l} `);return d?`${c} ${d}`:""}const Es={},Me=()=>{},Bs=[];function Ps({customLegendTypes:e=Es,layers:n=Bs,collapsed:r=!1,onChangeCollapsed:i=Me,onChangeVisibility:s=Me,onChangeOpacity:l=Me,onChangeLegendRowCollapsed:a=Me,onChangeSelection:p=Me,title:c="Layers",maxZoom:g=20,minZoom:h=0,currentZoom:d,isMobile:v,sx:f}){const m=J.useIntl(),y=B.useImperativeIntl(m),x=t.jsxs(es,{collapsed:r,children:[t.jsx(B.Typography,{variant:"caption",flexGrow:1,children:c}),t.jsx(o.Tooltip,{title:y.formatMessage({id:"c4r.widgets.legend.close"}),children:t.jsx(o.IconButton,{size:"small",onClick:()=>i(!0),children:t.jsx(wn,{})})})]}),b=t.jsx(o.Tooltip,{title:y.formatMessage({id:"c4r.widgets.legend.open"}),children:t.jsx(o.IconButton,{"aria-label":c,onClick:()=>i(!1),children:t.jsx(bn,{})})});return t.jsx(Qi,{sx:f,elevation:3,collapsed:r||!!v,children:v?t.jsxs(t.Fragment,{children:[b,t.jsxs(o.Drawer,{anchor:"bottom",open:!r,onClose:()=>i(!0),children:[x,t.jsx(Ct,{children:n.map(w=>t.jsx(At,{layer:w,onChangeCollapsed:a,onChangeOpacity:l,onChangeVisibility:s,onChangeSelection:p,maxZoom:g,minZoom:h,currentZoom:d,customLegendTypes:e},w.id))})]})]}):t.jsxs(t.Fragment,{children:[r?b:x,t.jsx(Ct,{width:r?0:void 0,children:t.jsx(o.Collapse,{unmountOnExit:!0,in:!r,timeout:500,children:n.map(w=>t.jsx(At,{layer:w,onChangeCollapsed:a,onChangeOpacity:l,onChangeVisibility:s,onChangeSelection:p,maxZoom:g,minZoom:h,currentZoom:d,customLegendTypes:e},w.id))})})]})})}function Et({color:e=void 0,children:n}){return n?t.jsx(o.Box,{mt:.5,children:t.jsx(B.Typography,{component:"div",variant:"caption",color:e??"inherit",style:{fontWeight:"normal"},children:n})}):t.jsx(o.Box,{mt:-1})}function Ls({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:r=void 0,...i}){return r?t.jsx(B.Alert,{title:e,severity:r,...i,children:t.jsx(Et,{children:n})}):t.jsxs(o.Box,{...i,children:[e&&t.jsx(B.Typography,{variant:"body2",children:e}),t.jsx(Et,{color:"textSecondary",children:n})]})}const Ds=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)})),Ns=o.styled(o.LinearProgress)(({theme:e})=>({position:"absolute",top:0,left:0,width:"100%",height:e.spacing(.25)})),Rs=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})),$s=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"}})),fn=({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",width:e.spacing(3),height:e.spacing(3),color:e.palette.text.secondary}),Os=o.styled(xe.ExpandLess)(({theme:e})=>fn({theme:e})),Fs=o.styled(xe.ExpandMore)(({theme:e})=>fn({theme:e})),Ws=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"}})),_s=o.styled(o.Grid)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1),marginRight:e.spacing(-.5),marginLeft:e.spacing(1)})),Bt=o.styled(o.IconButton)(({theme:e})=>({color:e.palette.text.secondary})),Gs=o.styled(o.Menu)(({theme:e})=>({".MuiPaper-root":{marginTop:e.spacing(5),maxHeight:e.spacing(21),minWidth:e.spacing(16)}})),Pt=[],Hs=t.jsx(xe.MoreVert,{});function zs({title:e,actions:n=Pt,options:r=Pt,optionsIcon:i=Hs,children:s,contentProps:l,disabled:a=!1,expandable:p=!0,expanded:c=!0,onExpandedChange:g,footer:h,headerItems:d,isLoading:v=!1,margin:f}){const m=u.createRef(),[y,x]=u.useState(!0),b=c!==void 0&&g!==void 0,w=p!==!1?b?c:y:!0,S=b?g:x,[I,j]=u.useState(null),T=!!I,C=()=>{p&&S(!w)},D=N=>j(N.currentTarget),E=()=>j(null);function P(N){N&&N(),E()}const L=N=>t.jsx(Bt,{"aria-label":N.label,onClick:N.action,size:"small",children:N.icon},N.id);return a?s:t.jsxs(Ds,{margin:f,component:"section","aria-label":e,children:[v?t.jsx(Ns,{}):null,t.jsxs(Rs,{container:!0,expanded:c,children:[t.jsx($s,{expandable:p,startIcon:p&&t.jsx(o.Icon,{children:w?t.jsx(Os,{}):t.jsx(Fs,{})}),onClick:C,tabIndex:p?0:-1,children:t.jsx(o.Tooltip,{title:e,children:t.jsx(Ws,{expanded:c,align:"left",variant:"subtitle1",children:e})})}),t.jsxs(_s,{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:L(N)},N.id):L(N)),r.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Bt,{"aria-label":"options","aria-controls":"options-menu","aria-haspopup":"true",onClick:D,size:"small",children:i}),t.jsx(Gs,{id:"options-menu",elevation:8,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:I,keepMounted:!0,open:T,onClose:E,children:r.map(N=>t.jsx(o.MenuItem,{selected:N.selected,onClick:()=>P(N.action),children:N.name},N.id))})]})]})]}),t.jsx(o.Collapse,{ref:m,in:w,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=On;exports.CategoryWidgetUI=Kn;exports.ComparativeCategoryWidgetUI=Mi;exports.ComparativeFormulaWidgetUI=Ni;exports.ComparativePieWidgetUI=Gi;exports.FeatureSelectionUIDropdown=sn;exports.FeatureSelectionUIGeometryChips=ln;exports.FeatureSelectionUIToggleButton=rn;exports.FeatureSelectionWidgetUI=Ji;exports.FormulaWidgetUI=Qn;exports.GroupDateTypes=ae;exports.HistogramWidgetUI=ao;exports.LEGEND_TYPES=ce;exports.LegendCategories=dn;exports.LegendIcon=gn;exports.LegendProportion=un;exports.LegendRamp=tt;exports.LegendWidgetUI=Ps;exports.NoDataAlert=Ls;exports.PieWidgetUI=$o;exports.RangeWidgetUI=Uo;exports.ScatterPlotWidgetUI=nr;exports.TIME_SERIES_CHART_TYPES=ze;exports.TableWidgetUI=gr;exports.TimeSeriesProvider=qt;exports.TimeSeriesWidgetUI=ri;exports.WrapperWidgetUI=zs;exports.useTimeSeriesContext=Ye;exports.useTimeSeriesInteractivity=Kt;