@carto/meridian-ds 0.1.1-alpha.1 → 0.1.1-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Alert-DyuvFDkP.cjs +4 -0
- package/dist/Alert-_PI5QbXW.js +127 -0
- package/dist/TablePaginationActions-B7ycFqaM.cjs +9 -0
- package/dist/{Alert-BawVDNyY.js → TablePaginationActions-OJyfVTms.js} +730 -311
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.js +31 -31
- package/dist/theme/index.cjs +1 -1
- package/dist/theme/index.js +25 -23
- package/dist/types/components/atoms/Button.d.ts +2 -5
- package/dist/types/components/atoms/Button.d.ts.map +1 -1
- package/dist/types/components/atoms/PasswordField.d.ts +1 -2
- package/dist/types/components/atoms/PasswordField.d.ts.map +1 -1
- package/dist/types/components/atoms/SelectField.d.ts +5 -4
- package/dist/types/components/atoms/SelectField.d.ts.map +1 -1
- package/dist/types/components/atoms/Typography.d.ts +1 -6
- package/dist/types/components/atoms/Typography.d.ts.map +1 -1
- package/dist/types/components/molecules/Alert.d.ts +1 -7
- package/dist/types/components/molecules/Alert.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete.d.ts +5 -6
- package/dist/types/components/molecules/Autocomplete.d.ts.map +1 -1
- package/dist/types/components/molecules/MultipleSelectField/MultipleSelectField.d.ts +1 -10
- package/dist/types/components/molecules/MultipleSelectField/MultipleSelectField.d.ts.map +1 -1
- package/dist/types/theme/carto-theme.d.ts +3 -3
- package/dist/types/theme/sections/components/buttons.d.ts.map +1 -1
- package/dist/types/theme/sections/components/data-display.d.ts.map +1 -1
- package/dist/types/theme/sections/typography.d.ts +3 -3
- package/dist/types/widgets/CategoryWidgetUI/CategoryWidgetUI.styled.d.ts +8 -13
- package/dist/types/widgets/CategoryWidgetUI/CategoryWidgetUI.styled.d.ts.map +1 -1
- package/dist/types/widgets/SkeletonWidgets.d.ts +4 -4
- package/dist/types/widgets/TableWidgetUI/TableWidgetUI.d.ts +4 -1
- package/dist/types/widgets/TableWidgetUI/TableWidgetUI.d.ts.map +1 -1
- package/dist/types/widgets/TimeSeriesWidgetUI/TimeSeriesWidgetUI.d.ts.map +1 -1
- package/dist/types/widgets/TimeSeriesWidgetUI/components/TimeSeriesChart.d.ts +2 -1
- package/dist/types/widgets/TimeSeriesWidgetUI/components/TimeSeriesChart.d.ts.map +1 -1
- package/dist/types/widgets/legend/LegendWidgetUI.styles.d.ts +1 -1
- package/dist/widgets/index.cjs +10 -10
- package/dist/widgets/index.js +1260 -1255
- package/package.json +1 -1
- package/dist/Alert-CrvY-jFA.cjs +0 -4
- package/dist/theme-constants-DL1946wP.js +0 -544
- package/dist/theme-constants-PqPZ2w1q.cjs +0 -9
package/dist/widgets/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),u=require("react"),o=require("@mui/material"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),u=require("react"),o=require("@mui/material"),X=require("react-intl"),j=require("../TablePaginationActions-B7ycFqaM.cjs"),yn=require("echarts-for-react"),Ne=require("../search-icon-CyudR_26.cjs"),fe=require("@mui/icons-material"),Te=require("../paletteUtils-DLQVT9qo.cjs"),Bt=require("@mui/material/styles"),vn=require("@mui/icons-material/KeyboardArrowDown"),jn=require("@mui/icons-material/Close"),wn=require("@mui/icons-material/LayersOutlined"),bn=require("@mui/icons-material/VisibilityOutlined"),Sn=require("@mui/icons-material/VisibilityOffOutlined"),In=require("@mui/icons-material/ExpandMore"),kn=require("@mui/icons-material/ExpandLess"),Tn=require("../Alert-DyuvFDkP.cjs");function Pt(){let e=!1;return window.PointerEvent&&"maxTouchPoints"in navigator?navigator.maxTouchPoints>0&&(e=!0):(window.matchMedia&&window.matchMedia("(any-pointer:coarse)").matches||window.TouchEvent||"ontouchstart"in window)&&(e=!0),e}function te(e){return!e||typeof e!="object"?e:`${e.prefix??""}${e.value}${e.suffix??""}`}const Mn=[],Cn={},st=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=te(n(Number(l))),h=a,d=`<div style="margin-left: 8px; display: inline">
|
|
2
2
|
${c}${g}${String((h==null?void 0:h.unit)||"")}
|
|
3
|
-
</div>`;return`<div style="margin-top: 4px">${String(p)}${d}</div>`}).join(" "),i}function En({height:e,labels:n=Cn,yAxisData:r,selectedBars:i=
|
|
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:${
|
|
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=Mn,series:s,colors:l,tooltip:a=!0,tooltipFormatter:p=An,xAxisFormatter:c=st,yAxisFormatter:g=st,onSelectedBarsChange:h,animation:d=!0,filterable:v=!0,stacked:f=!0,...y}){const m=o.useTheme(),x=u.useMemo(()=>(s??[]).map(I=>n[I]??I),[s,n]),S=u.useMemo(()=>Array.isArray(r[0])?r:[r],[r]),b=u.useMemo(()=>typeof l=="string"?[l]:Array.isArray(l)&&l.length?l:S.length<=1||x.length===1?[m.palette.secondary.main]:S.length===2||x.length===2?[m.palette.secondary.light,m.palette.secondary.dark]:Object.values(m.palette.qualitative.bold||{}),[l,m,S,x]);return{...y,tooltip:a,tooltipFormatter:p,xAxisFormatter:c,yAxisFormatter:g,onSelectedBarsChange:h,animation:d,filterable:v,stacked:f,labels:n,height:e??parseInt(m.spacing(22)),selectedBars:Bn(i),yAxisData:S,colors:b,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 xe=j.getDefaultExportFromCjs(Pn);class ye extends yn{componentDidUpdate(n){const{shouldSetOption:r}=this.props;if(typeof r=="function"&&!r(n,this.props))return;if(!xe(n.theme,this.props.theme)||!xe(n.opts,this.props.opts)){this.dispose(),this.renderNewEcharts();return}const i=this.getEchartsInstance();xe(n.onEvents,this.props.onEvents)||(this.offEvents(i,n.onEvents),this.bindEvents(i,this.props.onEvents));const s=["option","notMerge","lazyUpdate","showLoading","loadingOption"];xe(lt(this.props,s),lt(n,s))||this.updateEChartsOption(),(!xe(n.style,this.props.style)||!xe(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 lt(e,n){const r={};return n.forEach(i=>{r[i]=e[i]}),r}const _e=240,Lt=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)"}})),Dt=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"flex-end",justifyContent:"space-between",backgroundImage:`linear-gradient(${e.palette.grey[50]} 0.5px, transparent 0.5px, transparent calc(100% - 0.5px), ${e.palette.grey[50]} calc(100% - 0.5px)), linear-gradient(90deg, ${e.palette.grey[50]} 0.5px, transparent 0.5px, transparent calc(100% - 0.5px), ${e.palette.grey[50]} calc(100% - 0.5px))`,backgroundSize:"8.33% 20%",border:`0.5px solid ${e.palette.grey[50]}`})),je=o.styled(o.Skeleton)(({theme:e})=>({flex:1,maxWidth:e.spacing(12),"& + &":{marginLeft:e.spacing(1)}})),ne=o.styled(o.Skeleton)(({theme:e})=>({flex:1,maxWidth:e.spacing(8),"& + &":{marginLeft:"1px"}})),Ln=o.styled(o.Skeleton)(({theme:e})=>({backgroundColor:e.palette.common.white})),at=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(Lt,{style:{height:e||_e},children:[t.jsx(je,{variant:"rectangular",height:"20%"}),t.jsx(je,{variant:"rectangular",height:"40%"}),t.jsx(je,{variant:"rectangular",height:"60%"}),t.jsx(je,{variant:"rectangular",height:"20%"}),t.jsx(je,{variant:"rectangular",height:"80%"})]})]})}function ce(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=Pt(),$n=o.styled(o.Grid)(({theme:e})=>({marginBottom:e.spacing(2),flexDirection:"row",justifyContent:"space-between",alignItems:"center","& .MuiTypography-caption":{color:e.palette.text.secondary}})),On=o.styled(o.Link)(({theme:e})=>({...e.typography.caption,cursor:"pointer"}));function Rn(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:y,animation:m,isLoading:x}=En(e),S=i.length>1,b=o.useTheme(),I=X.useIntl(),k=j.useImperativeIntl(I),{showSkeleton:w}=ce(!!x),C=u.useMemo(()=>({show:a,trigger:"axis",padding:[parseInt(b.spacing(.5)),parseInt(b.spacing(1))],borderWidth:0,textStyle:{...b.typography.caption,fontSize:11,color:b.palette.common.white},backgroundColor:b.palette.black[90],position:function(M,$,G,R,H){const U={top:0};return H.contentSize[0]<H.viewSize[0]-M[0]?U.left=M[0]:U.right=H.viewSize[0]-M[0],U},formatter:M=>p(M,d)}),[b,a,p,d]),A=u.useMemo(()=>r.map(M=>te(h(c[M]??String(M)))),[r,c,h]),D=u.useMemo(()=>({type:"category",axisLine:{show:!1},axisTick:{show:!1},axisLabel:{...b.typography.overlineDelicate,padding:[parseInt(b.spacing(.5)),0,0,0]},data:A}),[b,A]),B=u.useMemo(()=>{let M=[];return v?M=n.reduce(($,G)=>(G.forEach((R,H)=>$[H]=($[H]??0)+(R??Number.MIN_SAFE_INTEGER)),$),[]):M=n.flat().map($=>$??Number.MIN_SAFE_INTEGER),Math.max(...M)},[n,v]),P=u.useMemo(()=>({type:"value",axisLabel:{margin:0,verticalAlign:"bottom",padding:[0,0,parseInt(b.spacing(1.25)),0],show:!0,showMaxLabel:!0,showMinLabel:!1,inside:!0,color:M=>M>=B?b.palette.black[60]:"transparent",...b.typography.overlineDelicate,formatter:M=>te(d(M))},axisLine:{show:!1},axisTick:{show:!1},splitLine:{show:!0,onZero:!1,lineStyle:{color:b.palette.black[4]}}}),[b,B,d]),L=u.useMemo(()=>n.map((M,$)=>({type:"bar",name:i[$]??"",animation:m,barMaxWidth:100,data:M.map((G,R)=>{const H=s.some(([F,z=0])=>F===R&&z===$),U=!!s.length&&!H;return{value:G,...U&&{itemStyle:{color:b.palette.black[25]},disabled:!0}}}),...v&&{stack:"total"},...!Nn&&{emphasis:{focus:"series",itemStyle:{color:o.darken(g[$]??"#000",.25)}}}})),[m,g,i,n,s,v,b]),N=u.useMemo(()=>({grid:{left:A.length>=4?ct(String(A[0]),A.length):0,top:parseInt(b.spacing(2)),right:A.length>=4?ct(String(A[A.length-1]),A.length):0,bottom:0,containLabel:!0},axisPointer:{lineStyle:{color:b.palette.black[40]}},color:g,tooltip:C,xAxis:D,yAxis:P,series:L}),[A,b,g,C,D,P,L]),V=()=>{l&&l([],[])},_=M=>{M.key==="Enter"&&V()},T=u.useCallback(M=>{if(l){const $=[...s],{dataIndex:G,componentIndex:R}=M,H=$.findIndex(([F,z=0])=>G===F&&R===z);H===-1?$.push([G,R]):$.splice(H,1);const U=$.map(([F,z=0])=>({xAxis:r[F],serie:i[z],yAxis:n[z][F]}));l(S?$:$.map(F=>F[0]),U)}},[n,l,s,r,i,S]),O=u.useMemo(()=>y?{click:T}:{},[y,T]);return w?t.jsx(Dn,{height:f}):t.jsxs("div",{children:[l&&t.jsxs($n,{container:!0,children:[t.jsx(j.Typography,{variant:"caption",children:s.length>0?k.formatMessage({id:"c4r.widgets.bar.selectedItems"},{items:s.length}):k.formatMessage({id:"c4r.widgets.bar.all"})}),s&&s.length>0&&t.jsx(On,{onClick:()=>V(),onKeyDown:_,underline:"hover",tabIndex:0,children:k.formatMessage({id:"c4r.widgets.bar.clear"})})]}),!!N&&t.jsx(ye,{option:N,lazyUpdate:!0,notMerge:!0,onEvents:O,style:{height:f}})]})}function ct(e="",n=0){return n<=15&&e.length<=8?0:e.length*8.5/6}const ue="__rest__",me="Others";var pe=(e=>(e.RANKING="ranking",e.FIXED="fixed",e))(pe||{});const Nt=o.styled(o.Grid)(({theme:e})=>({maxHeight:e.spacing(40),overflow:"auto",padding:0})),$t=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!==ue&&n&&{cursor:"pointer",flexWrap:"nowrap","&:hover .progressbar div":{backgroundColor:e.palette.secondary.dark}},...r===ue&&{cursor:"default",".progressbar div":{backgroundColor:e.palette.text.disabled}}})),dt=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(j.Typography)(({theme:e})=>({fontWeight:e.typography.fontWeightBold,marginRight:e.spacing(2)})),Ce=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})),ut=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,Ot=()=>t.jsxs(t.Fragment,{children:[t.jsx(o.Skeleton,{width:48,height:8}),t.jsx(Nt,{container:!0,mt:3,children:[...Array(6)].map((e,n)=>t.jsxs($t,{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 Rt(e){const n=u.useRef();return u.useEffect(()=>{n.current=e}),n.current}function Ke({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,y)=>f.value===n[y].value))return;let a=n.map((f,y)=>e[y]&&e[y].name===f.name?{...f,value:e[y].value}:f),p=0;const c=a.map((f,y)=>n[y].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,y)=>{const m=Math.floor(f.value+d[y]),x=y>0&&Math.floor(f.value+d[y-1]);return{...f,value:m===x?n[y].value:m}}),i(a),p++,s.current=requestAnimationFrame(v)):i(n)};s.current=requestAnimationFrame(v)}const Vn=[],Un={},qn=e=>e,Ve=()=>{};function Kn({data:e,formatter:n=qn,labels:r=Un,maxItems:i=5,order:s=pe.RANKING,selectedCategories:l=Vn,onSelectedCategoriesChange:a=Ve,animation:p=!0,filterable:c=!0,searchable:g=!0,isLoading:h}){const[d,v]=u.useState([]),[f,y]=u.useState(1),[m,x]=u.useState(!1),[S,b]=u.useState(""),[I,k]=u.useState([]),[w,C]=u.useState([]),[A,D]=u.useState([]),B=u.useRef(null),P=u.useRef(),L=Rt(A),N=u.useRef([]),{showSkeleton:V}=ce(!!h),_=X.useIntl(),T=j.useImperativeIntl(_);function O(E){return d.reduce((Y,K)=>(E.includes(K.name)&&Y.push(K.name),Y),[])}function M(E){if(E!==ue){let Y;l.includes(E)?Y=l.filter(K=>K!==E):Y=[...l,E],a&&a(Y)}}const $=()=>a([]),G=E=>{E.key==="Enter"&&$()},R=()=>{a([]),k([])},H=E=>{E.key==="Enter"&&R()},U=()=>{k(O(l))},F=E=>{E.key==="Enter"&&U()},z=()=>{const E=O(w);a([...E]),k([...E]),C([]),x(!1),b("")},Q=E=>{E.key==="Enter"&&z()},de=()=>{b(""),x(!1)},re=E=>{if(E!==ue){let Y;w.includes(E)?Y=w.filter(K=>K!==E):Y=[...w,E],C(Y)}},W=E=>{E.currentTarget.scrollIntoView()},q=E=>{b(E.currentTarget.value)},Z=()=>{x(!0),C([...l])},J=u.useCallback(E=>{if(m)return S?E.filter(Y=>{var ee;if(!Y.name)return!1;const K=String(Y.name);return!!(K.toLowerCase().includes(S.toLowerCase())||(ee=r[K])!=null&&ee.toLowerCase().includes(S.toLowerCase()))}):E;if(I.length)return I.reduce((K,ee)=>{const ge=E.find(se=>se.name===ee);return K.push({name:ee,value:ge?ge.value:null}),K},[]);{const Y=E.slice(0,i);if(Y.length<E.length){const K=E.slice(i).reduce((ee,ge)=>(ge.value!==null&&ee.value!==null&&(ee.value+=ge.value),ee),{name:ue,value:0});return[...Y,K]}else return Y}},[I,r,i,S,m]),ie=u.useCallback(()=>{const E=I.length;return E?e.length-E:e.length-i},[e,i,I]),Me=u.useCallback(E=>E===ue?`Others ${g?"":`(${ie()})`}`:r[String(E)]??String(E),[ie,r,g]),ve=u.useCallback(E=>E>=f?E!=null?"100%":0:`${(E||0)*100/f}%`,[f]);u.useEffect(()=>{l.length===0&&k([])},[l]),u.useEffect(()=>{if(e){if(s===pe.RANKING){const E=[...e].sort((K,ee)=>(ee.value??0)-(K.value??0)),Y=J(E);Y.length>0?y(Y[0].value??0):y(1),v(Y)}else if(s===pe.FIXED){y(Math.max(...e.map(Y=>Y.value??0)));const E=J(e);v(E)}}},[I,J,e,r,i,s,S,m]),u.useEffect(()=>{L&&(N.current=L)},[L]),u.useEffect(()=>{if(p)return Yn({start:(N.current||[]).map(E=>({...E,value:E.value??0})),end:d.map(E=>({...E,value:E.value??0})),duration:500,drawFrame:E=>D(E),requestRef:B}),()=>{B.current&&cancelAnimationFrame(B.current)};D(d)},[p,d]),u.useEffect(()=>{m&&P.current&&P.current.focus()},[m,P]);function fn({data:E,onCategoryClick:Y}){const K=n(E.value??0),[ee,ge]=u.useState(!1),se=u.useRef(null),ze=()=>{var rt,it;const Ye=(((rt=se==null?void 0:se.current)==null?void 0:rt.scrollWidth)??0)>(((it=se==null?void 0:se.current)==null?void 0:it.clientWidth)??0);ge(Ye)};u.useEffect(()=>(ze(),window.addEventListener("resize",ze),()=>{window.removeEventListener("resize",ze)}),[]);const xn=Ye=>{Ye.key==="Enter"&&Y()},mn=!m&&l.length>0&&!l.includes(E.name);return t.jsxs($t,{container:!0,direction:"row",spacing:1,onClick:c?Y:Ve,onKeyDown:c?xn:Ve,selectable:c,unselected:mn,name:E.name===ue?ue:"",tabIndex:c?0:-1,children:[c&&m&&t.jsx(o.Grid,{item:!0,mr:1,children:t.jsx(o.Checkbox,{checked:w.includes(E.name),tabIndex:-1})}),t.jsxs(Wn,{container:!0,item:!0,xs:!0,isSelectable:m,children:[t.jsxs(o.Grid,{container:!0,item:!0,direction:"row",justifyContent:"space-between",wrap:"nowrap",children:[t.jsx(o.Tooltip,{title:Me(E.name),disableHoverListener:!ee,children:t.jsx(_n,{variant:"body2",noWrap:!0,ref:se,children:Me(E.name)})}),typeof K=="object"&&K!==null?t.jsxs("span",{children:[K.prefix,K.value,K.suffix]}):t.jsx("span",{children:K})]}),t.jsx(Fn,{className:"progressbar",item:!0,children:t.jsx("div",{style:{width:ve(E.value??0)}})})]})]})}return(e==null?void 0:e.length)===0||V?t.jsx(Ot,{}):t.jsxs(Gn,{children:[c&&d.length>0&&t.jsxs(dt,{container:!0,children:[t.jsx(j.Typography,{variant:"caption",children:l.length>0?T.formatMessage({id:"c4r.widgets.category.selectedItems"},{items:l.length}):T.formatMessage({id:"c4r.widgets.category.all"})}),m?t.jsx(Ce,{onClick:z,onKeyDown:Q,underline:"hover",tabIndex:0,"data-testid":"primaryApplyButton",children:T.formatMessage({id:"c4r.widgets.category.apply"})}):I.length>0?t.jsx(Ce,{onClick:R,onKeyDown:H,underline:"hover",tabIndex:0,children:T.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(Ce,{onClick:U,onKeyDown:F,underline:"hover",tabIndex:0,children:T.formatMessage({id:"c4r.widgets.category.lock"})}),t.jsx(o.Divider,{orientation:"vertical",flexItem:!0}),t.jsx(Ce,{onClick:$,onKeyDown:G,underline:"hover",tabIndex:0,children:T.formatMessage({id:"c4r.widgets.category.clear"})})]})]}),e.length>i&&m&&t.jsxs(dt,{container:!0,children:[t.jsx(o.TextField,{size:"small",sx:{mt:-.5},placeholder:T.formatMessage({id:"c4r.widgets.category.search"}),onChange:q,onFocus:W,InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx(Ne.SearchIcon,{})})},inputProps:{tabIndex:0,ref:P}}),t.jsx(ut,{size:"small",onClick:de,children:T.formatMessage({id:"c4r.widgets.category.cancel"})})]}),t.jsx(Nt,{container:!0,item:!0,children:A.length?A.map((E,Y)=>t.jsx(fn,{data:E,onCategoryClick:()=>m?re(E.name):M(E.name)},Y)):t.jsxs(o.Box,{children:[t.jsx(j.Typography,{variant:"body2",children:T.formatMessage({id:"c4r.widgets.category.noResults"})}),t.jsx(j.Typography,{component:"p",variant:"caption",mb:2,children:T.formatMessage({id:"c4r.widgets.category.noResultsMessage"},{searchValue:S})})]})}),m&&t.jsx(ut,{size:"small",onClick:z,children:T.formatMessage({id:"c4r.widgets.category.apply"})}),e.length>i&&g?m?t.jsx(o.Box,{mt:1.5,children:t.jsx(o.Button,{size:"small",color:"primary",onClick:de,"data-testid":"primaryCancelButton",children:T.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(Ne.SearchIcon,{}),onClick:Z,children:T.formatMessage({id:"c4r.widgets.category.searchInfo"},{elements:ie()})})}):null]})}const Ft=()=>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"})),Ae="-",Jn=e=>e;function Qn({data:e=Ae,formatter:n=Jn,animation:r=!0,isLoading:i=!1}){const[s,l]=u.useState(Ae),a=u.useRef(null),p=Rt(s),c=u.useRef(p),{showSkeleton:g}=ce(!!i);u.useEffect(()=>(typeof e=="number"&&r?Ke({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?Ke({start:Number(c.current.value),end:Number(e.value),duration:1e3,drawFrame:f=>l({value:f,prefix:e.prefix,suffix:e.suffix}),requestRef:a}):l(e??Ae),()=>{a.current&&cancelAnimationFrame(a.current)}),[r,e,l]);const h=n(s),d=typeof h=="object"&&h!==null,v=h===Ae;return g?t.jsx(Ft,{}):d?t.jsxs(j.Typography,{variant:"h5",component:"div",weight:"medium",children:[t.jsx(Zn,{children:h.prefix}),h.value,t.jsx(Xn,{children:h.suffix})]}):t.jsx(j.Typography,{variant:"h5",component:"div",weight:"medium",color:v?"text.disabled":"default",whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",children:h})}const pt={};let we=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]);we=f??null}}function d(v){if(s&&we!==null){const[f]=s.convertFromPixel({seriesIndex:0},[v.offsetX,v.offsetY]);p(we===f?[]:[we,f].sort((y,m)=>y-m))}}if(s&&n){const v=Ue(c,"mousedown",h),f=Ue(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,y)=>((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(y),v),[]);i(e.length===d.length?[]:d)}p([]),we=null}if(s&&n)return Ue(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 Ue(e,n,r){if(e!=null&&e.handler)return pt[n]=r,e.on(n,r),()=>{pt[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(Dt,{style:{height:e??_e},children:[t.jsx(ne,{variant:"rectangular",height:"20%"}),t.jsx(ne,{variant:"rectangular",height:"40%"}),t.jsx(ne,{variant:"rectangular",height:"60%"}),t.jsx(ne,{variant:"rectangular",height:"20%"}),t.jsx(ne,{variant:"rectangular",height:"80%"}),t.jsx(ne,{variant:"rectangular",height:"50%"}),t.jsx(ne,{variant:"rectangular",height:"20%"}),t.jsx(ne,{variant:"rectangular",height:"40%"}),t.jsx(ne,{variant:"rectangular",height:"60%"}),t.jsx(ne,{variant:"rectangular",height:"20%"}),t.jsx(ne,{variant:"rectangular",height:"80%"}),t.jsx(ne,{variant:"rectangular",height:"50%"})]})]})}const no=Pt(),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=te(n(l)),g=te(n(a)),h=te(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:y}){const m=X.useIntl(),x=o.useTheme(),S=j.useImperativeIntl(m),{showSkeleton:b}=ce(!!y),I=!!v&&!!c,[k,w]=u.useState(),C=M=>w(M),A=u.useMemo(()=>po(e,n,r,i),[e,n,r,i]),{onEvents:D,markAreaOptions:B}=eo({data:A,filterable:I,selectedBars:p,onSelectedBarsChange:c,echartsInstance:k}),P=u.useMemo(()=>({show:g,trigger:"item",padding:[j.SPACING*.5,j.SPACING],borderWidth:0,textStyle:{...x.typography.caption,fontSize:11,color:x.palette.common.white},backgroundColor:x.palette.black[90],confine:!0,position:"top",formatter(M){return h(M,s,l)}}),[x,g,h,s,l]),L=u.useMemo(()=>({min:r,max:i,interval:(i-r)/A.length,axisLine:{show:!1},splitLine:{show:!0,lineStyle:{color:x.palette.black[4]}},axisTick:{show:!1},axisLabel:{showMinLabel:!0,showMaxLabel:!0,...x.typography.overlineDelicate,hideOverlap:!0,padding:[j.SPACING*.5,j.SPACING*.5,0,j.SPACING*.5],formatter:M=>{const $=te(s(M));return M===r?co($):M===i?uo($):$},color:x.palette.black[60]}}),[r,i,A.length,x,s]),N=u.useMemo(()=>{const M={margin:0,verticalAlign:"bottom",padding:[0,0,j.SPACING*1.25,0],inside:!0,color:R=>{const H=Math.max(...e.map(F=>F??Number.MIN_SAFE_INTEGER))||1;let U="transparent";return R>=H&&(U=x.palette.black[60]),U},...x.typography.overlineDelicate,formatter:R=>te(l(R))},$={verticalAlign:"middle",padding:[0,0,0,j.SPACING*.5],color:x.palette.black[60]},G=a==="dense"?M:$;return{type:"value",axisLine:{show:!1},splitLine:{show:!0,lineStyle:{color:x.palette.black[4]}},axisTick:{show:!1},axisLabel:{show:!0,showMaxLabel:!0,showMinLabel:!1,...G,...x.typography.overlineDelicate,formatter:R=>te(l(R))}}},[x.palette.black,x.typography.overlineDelicate,e,l,a]),V=u.useMemo(()=>{const M=r===i&&A.filter(R=>R[2]!==0).length===1,G=(M?[A[0],A[A.length-1]]:A).map((R,H)=>{const F=p.length&&!p.includes(H)?x.palette.black[25]:x.palette.secondary.main;return{value:R,itemStyle:{color:F}}});return{type:"custom",cursor:"pointer",markArea:B,renderItem:function(R,H){const U=R.dataIndex===A.length-1,F=R.dataIndex===0,z=G[R.dataIndex].itemStyle.color,Q=H.value(0),de=H.value(1),re=H.value(2),[W,q]=H.coord([Q,re]),[Z,J]=H.size([de-Q,re]);return{type:"rect",shape:{x:M?W/10:W+(F?0:1),y:q,width:M?W-W/10:Z-(U?0:1),height:J},style:{fill:z},...!no&&{emphasis:{style:{fill:o.darken(z,.25)}}}}},encode:{x:[0,1],y:2,tooltip:[0,1,2]},data:G,animation:d}},[r,i,A,B,x.palette.black,x.palette.secondary.main,p,d]),_=u.useMemo(()=>({grid:{left:j.SPACING*.1,right:j.SPACING*.1,top:j.SPACING*2,bottom:j.SPACING*.5,containLabel:!0},tooltip:P,xAxis:L,yAxis:N,series:[V]}),[P,L,N,V]),T=p.reduce((M,$)=>M+=e[$]??0,0),O=M=>{M.key==="Enter"&&c([])};return b?t.jsx(to,{height:f}):t.jsxs("div",{children:[I&&t.jsxs(oo,{container:!0,children:[t.jsx(j.Typography,{variant:"caption",weight:"strong",children:p.length>0?S.formatMessage({id:"c4r.widgets.histogram.selectedItems"},{items:te(l(T))}):S.formatMessage({id:"c4r.widgets.histogram.all"})}),p.length>0&&t.jsx(ro,{onClick:()=>c([]),onKeyDown:O,underline:"hover",tabIndex:0,children:S.formatMessage({id:"c4r.widgets.histogram.clear"})})]}),t.jsx(ye,{option:_,onEvents:D,lazyUpdate:!0,onChartReady:C,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===pe.RANKING?e.slice().sort((c,g)=>(g.value??0)-(c.value??0)):e,[e,n]),a=u.useMemo(()=>{const c=[];let g=0;for(const h of l)c.length<r?c.push({...h}):g+=h.value??0;return g>0&&c.push({name:me,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 y=s.palette.qualitative.bold[h];y&&(d=y)}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(y=>n.includes(y.name)):g=e;const h=yo(g),d=g.find(y=>y===h);if(!d)return null;let v=0;for(const y of e)v+=y.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(j.Typography,{variant:"h5",children:p}),t.jsxs(fo,{children:[t.jsx(xo,{bgcolor:c,component:"span"}),t.jsx(j.Typography,{component:"span",variant:"body2",noWrap:!0,children:a})]})]}):null}function yo(e){const n=e.filter(r=>r.name!==me);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 gt=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 Wt({height:e}){const n=parseInt(String(e),10)||_e,r=n-gt,i=r-gt;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 To=o.styled(o.Box)(({theme:e})=>({position:"relative",padding:e.spacing(1.25,1,0,1),width:"100%"})),Mo=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 _t({series:e,selectedCategories:n,onCategoryClick:r}){var I,k;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=X.useIntl(),y=j.useImperativeIntl(f);function m(){p(a+1)}function x(){p(Math.max(a-1))}function S(w,C){w.key==="Enter"&&(r==null||r(C))}const b=u.useCallback(()=>{var C,A,D;const w=!!d.current&&d.current.scrollWidth>d.current.clientWidth;l(w),g(w&&d.current?(((C=h.current)==null?void 0:C.clientWidth)??0)-(((A=v.current)==null?void 0:A.clientWidth)??70):(((D=h.current)==null?void 0:D.clientWidth)??0)-12||500)},[h,d,v]);return u.useEffect(()=>{b()},[d,(I=d.current)==null?void 0:I.scrollWidth,(k=d.current)==null?void 0:k.clientWidth,b,a]),u.useEffect(()=>{if(typeof ResizeObserver>"u")return;let w;return h.current&&(w=new ResizeObserver(()=>{b()}),w.observe(h.current)),()=>{w==null||w.disconnect()}},[h,b]),t.jsxs(To,{ref:h,children:[t.jsx(Mo,{ref:d,style:{maxWidth:`${c}px`},children:e.map((w,C)=>{if(C<a)return null;const A=n.length===0||n.includes(w.name);return t.jsxs(Co,{tabIndex:0,onClick:r?()=>r(w.name):void 0,onKeyDown:r?D=>S(D,w.name):void 0,style:{pointerEvents:!r||w.name==="Others"?"none":void 0},children:[t.jsx(Bo,{color:A?w.color:i.palette.text.disabled}),t.jsx(j.Typography,{variant:"overline",color:A?void 0:"text.disabled",children:w.name})]},C)})}),(s||a>0)&&t.jsxs(Eo,{ref:v,children:[t.jsx(Ao,{}),t.jsx(o.Tooltip,{title:y.formatMessage({id:"c4r.widgets.chartLegend.next"}),children:t.jsx(o.IconButton,{size:"small",disabled:a===0,onClick:x,children:t.jsx(fe.ChevronLeft,{})})}),t.jsx(o.Tooltip,{title:y.formatMessage({id:"c4r.widgets.chartLegend.prev"}),children:t.jsx(o.IconButton,{size:"small",disabled:!s,onClick:m,children:t.jsx(fe.ChevronRight,{})})})]})]})}const Ze="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(ye)(()=>({position:"absolute",top:0,right:0,left:0,bottom:0})),ht=[],No={},$o=e=>e;function Oo({name:e,data:n,formatter:r=$o,tooltipFormatter:i=Ro,percentFormatter:s,height:l=Ze,width:a=Ze,labels:p=No,colors:c=ht,animation:g=!0,filterable:h=!0,selectedCategories:d=ht,onSelectedCategoriesChange:v,isLoading:f,maxItems:y=11,order:m=pe.RANKING}){const x=o.useTheme(),S=go(n,m,y,c),{showSkeleton:b}=ce(!!f),I=X.useIntl(),k=j.useImperativeIntl(I),w=u.useMemo(()=>s||(_=>`${I.formatNumber(_,{maximumFractionDigits:2,minimumFractionDigits:2})}%`),[I,s]),C=u.useMemo(()=>{let _;return i&&(_=T=>i(T,r,w)),{padding:[j.SPACING*.5,j.SPACING],backgroundColor:x.palette.black[90],borderColor:"transparent",textStyle:{color:x.palette.common.white},confine:!0,formatter:_}},[x.palette.black,x.palette.common.white,i,r,w]),A=u.useMemo(()=>[{type:"pie",name:e,animation:g,data:S.map(_=>{const T={..._},O=(d==null?void 0:d.length)&&!d.includes(T.name);return p!=null&&p[T.name]&&(T.name=p[T.name]),O?{...T,disabled:!0,itemStyle:{color:x.palette.black[25]}}:{...T,itemStyle:{color:T.color}}}),radius:["74%","90%"],selectedOffset:0,bottom:j.SPACING*1.5,label:{show:!1},emphasis:{focus:"series",scaleSize:5},itemStyle:{borderColor:x.palette.background.paper,borderWidth:1}}],[e,g,S,p,d,x]),D=u.useMemo(()=>({grid:{left:0,top:0,right:0,bottom:0},tooltip:C,legend:{show:!1},series:A}),[C,A]),B=u.useCallback(_=>{if(v){const T=[...d],{name:O}=S[_.dataIndex];if(O===me)return;const M=T.indexOf(O);M===-1?T.push(O):T.splice(M,1),v(T)}},[S,v,d]),P=u.useCallback(_=>{if(v){const T=[...d],O=T.indexOf(_);O===-1?T.push(_):T.splice(O,1),v(T)}},[v,d]),L={...h&&{click:B}},N=()=>{v==null||v([])},V=_=>{_.key==="Enter"&&N()};return b?t.jsx(Wt,{height:l}):t.jsxs(t.Fragment,{children:[h&&t.jsxs(Po,{container:!0,children:[t.jsx(j.Typography,{variant:"caption",color:"textSecondary",children:d.length?k.formatMessage({id:"c4r.widgets.pie.selectedItems"},{items:d.length}):k.formatMessage({id:"c4r.widgets.pie.allSelected"})}),d.length>0&&t.jsx(o.Link,{variant:"caption",onClick:N,onKeyDown:V,tabIndex:0,children:k.formatMessage({id:"c4r.widgets.pie.clear"})})]}),t.jsxs(Lo,{height:l,width:a,children:[t.jsx(mo,{data:S,selectedCategories:d,formatter:w}),t.jsx(Do,{option:D,onEvents:L,lazyUpdate:!0,style:{height:l,width:a}})]}),S.length>0&&t.jsx(_t,{series:S,selectedCategories:d,onCategoryClick:v&&P})]})}function Ro(e,n,r){var c;const i=Array.isArray(e)?e[0]:e;if(!i)return null;const s=te(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:${Ze};font-size:11px;font-weight:500;line-height:1.454;text-transform:uppercase;margin:0 0 4px 0;">${i.name}</p>
|
|
6
6
|
<p style="display:flex;align-items:center;font-size: 11px;font-weight:500;line-height:1.454;margin:0;"><span style="${p}"></span> <span style="margin:0 4px;font-weight:400;">${s}</span> (${l})</p></div>
|
|
7
|
-
`.trim()}const 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;'>${
|
|
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(at,{variant:"circular",width:12,height:12}),t.jsx(at,{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"})),ft=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=X.useIntl(),d=j.useImperativeIntl(h),{showSkeleton:v}=ce(!!l),f=u.useMemo(()=>{if(!i||i.length!==2)return;if(i[0]===i[1])return[{value:i[0]}];const w=[{value:Math.max(i[0],n)},{value:Math.min(i[1],r)}];if(!(w[0].value>w[1].value))return w},[i,r,n]),y=u.useMemo(()=>s?o.debounce(s,250):null,[s]),m=w=>{g([...w]),p([...w]),y&&y([...w])};function x(w,C){const A=w.target.value===""?"":Number(w.target.value);C===0&&g([A,c[1]]),C===1&&g([c[0],A])}const S=n!==c[0]||r!==c[1];u.useEffect(()=>{e&&(g([...e]),p([...e]))},[e]);function b(w){let C=c[w];C===""&&(C=a[w]),C>r&&(C=r),C<n&&(C=n);const A=w===0?[C,c[1]]:[c[0],C];m(A.sort((D,B)=>D-B))}const I=()=>{m([n,r])};function k(w){w.key==="Enter"&&I()}return v?t.jsx(_o,{}):t.jsxs(Go,{children:[t.jsx(Ho,{children:S&&t.jsx(j.Typography,{variant:"caption",color:"primary",children:t.jsx(zo,{onClick:I,onKeyDown:k,tabIndex:0,component:"button",underline:"hover",children:d.formatMessage({id:"c4r.widgets.range.clear"})})})}),t.jsxs(o.Box,{children:[t.jsx(Yo,{getAriaLabel:w=>w===0?d.formatMessage({id:"c4r.widgets.range.minValue"}):d.formatMessage({id:"c4r.widgets.range.maxValue"}),value:a,min:n,max:r,onChange:(w,C)=>m(C)}),i&&i.length===2&&t.jsx(Vo,{getAriaLabel:w=>w===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(ft,{value:c[0],size:"small",onChange:w=>x(w,0),onBlur:()=>b(0),inputProps:{min:n,max:r,type:"number","aria-label":d.formatMessage({id:"c4r.widgets.range.minValue"})}}),t.jsx(ft,{value:c[1],size:"small",onChange:w=>x(w,1),onBlur:()=>b(1),inputProps:{min:n,max:r,type:"number","aria-label":d.formatMessage({id:"c4r.widgets.range.maxValue"})}})]})]})}const qo=o.styled(Dt)(({theme:e})=>({flexDirection:"column",alignItems:"center",justifyContent:"center",marginLeft:e.spacing(4),containerType:"inline-size",[`@container (max-width: ${j.BREAKPOINTS.XS}px)`]:{" > div":{maxWidth:"75%"}}})),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??_e,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:[j.SPACING*.5,j.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:[j.SPACING*.5,0,0,0],formatter:s=>te(n(s))}},yAxis:{axisLabel:{...i.typography.overlineDelicate,formatter:s=>te(r(s))}}}}function Qo({name:e,data:n,animation:r}){return[{type:"scatter",name:e,data:n,animation:r}]}const er=u.memo(ye,(e,n)=>Xo(e.option,n.option)),xt=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}=ce(!!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:xt}):t.jsx(er,{ref:c,option:g,lazyUpdate:!0,style:{height:xt}})}function or(e){const n=Array.isArray(e)?e[0]:e,r=(n==null?void 0:n.value)||[];return`[${r[0]}, ${r[1]})`}function Ee({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(Ee,{rows:1,width:8}),t.jsx(Ee,{width:56})]})}),t.jsx(o.TableBody,{children:[...Array(Math.min(10,i??10))].map((s,l)=>t.jsxs(o.TableRow,{children:[t.jsx(Ee,{rows:1,width:8}),t.jsx(Ee,{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,whiteSpace:"nowrap"})),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],be=()=>{};function gr({columns:e,rows:n,sorting:r=!1,sortBy:i,sortDirection:s="asc",onSetSortBy:l=be,onSetSortDirection:a=be,pagination:p=!1,totalCount:c,page:g,onSetPage:h=be,rowsPerPage:d=ur,rowsPerPageOptions:v=pr,onSetRowsPerPage:f=be,onRowClick:y=be,onRowMouseEnter:m,onRowMouseLeave:x,height:S,dense:b=!1,isLoading:I,lastPageTooltip:k}){var _;const w=u.useRef(null),C=X.useIntl(),A=j.useImperativeIntl(C),{showSkeleton:D}=ce(!!I);function B({from:T,to:O,count:M}){return A.formatMessage({id:"c4r.widgets.table.of"},{from:T,to:O,count:M})}function P(T){a(i===T&&s==="asc"?"desc":"asc"),l(T)}function L(T,O){h(O)}function N(T){f(parseInt(T.target.value,10)),h(0)}const V={height:void 0};if(S){const T=Math.max(((_=w==null?void 0:w.current)==null?void 0:_.clientHeight)??0,p?j.SPACING*6:0);V.height=`calc(${S} - ${T}px)`}return D?t.jsx(sr,{rowsPerPage:d,style:V,dense:b,pagination:p}):t.jsxs(t.Fragment,{children:[t.jsx(o.TableContainer,{style:V,children:t.jsxs(o.Table,{stickyHeader:!0,size:b?"small":"medium",children:[t.jsx(hr,{columns:e,sorting:r,sortBy:i,sortDirection:s,onSort:P}),t.jsx(fr,{columns:e,rows:n,onRowMouseEnter:m,onRowMouseLeave:x,onRowClick:y})]})}),p&&t.jsx(dr,{ref:w,rowsPerPageOptions:v,labelRowsPerPage:A.formatMessage({id:"c4r.widgets.table.rowsPerPage"}),labelDisplayedRows:B,component:"div",count:c,rowsPerPage:d,page:g,onPageChange:L,onRowsPerPageChange:N,ActionsComponent:()=>t.jsx(j.TablePaginationActions,{count:c,rowsPerPage:d,page:g,onPageChange:L,lastPageTooltip:k})})]})}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({columns:e,rows:n,onRowMouseEnter:r,onRowMouseLeave:i,onRowClick:s}){return t.jsx(o.TableBody,{children:n.map((l,a)=>{const p=String(l.cartodb_id||l.id||a);return t.jsx(ar,{hover:!!s,onMouseEnter:()=>r==null?void 0:r(l),onMouseLeave:()=>i==null?void 0:i(l),onClick:()=>s&&s(l),children:e.map(({field:c,headerName:g,align:h,component:d,formatter:v})=>{var y;let f=(y=Object.entries(l).find(([m])=>m.toUpperCase()===c.toUpperCase()))==null?void 0:y[1];return v?f=v(f):typeof f=="bigint"?f=f.toString():Array.isArray(f)?f=`[${f.map(m=>typeof m=="string"?`"${m}"`:String(m)).join(", ")}]`:typeof f=="object"&&f!==null&&(f=JSON.stringify(f)),(g??c)&&t.jsx(cr,{scope:"row",align:h??"left",children:d?d(f):f},`${p}_${c}`)})},p)})})}function Gt(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;'>${zt({date:p,stepMultiplier:i,stepSize:n})}</p>
|
|
9
9
|
${l.reduce((g,h)=>{if(h.value!==void 0&&h.value!==null){const d=`<div style='display: flex; flex-direction: row; align-items: center; justify-content: spread; height: 20px; gap: 8px;'>
|
|
10
10
|
<div style='display: flex; flex-direction: row; align-items: center; margin: 4px 0;'>
|
|
11
11
|
<div style='width: 8px; height: 8px; margin-right: 4px; border-radius: 50%; border: 2px solid ${String(h.color)}'></div>
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
</p>
|
|
16
16
|
<p style='line-height: 1; justify-self: flex-end;'>${r(h.data[1])}</p>
|
|
17
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=`
|
|
18
|
+
</div>`}var Ge=(e=>(e.LINE="line",e.BAR="bar",e))(Ge||{});function mt(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 Ht(e){return typeof e=="object"&&typeof(e==null?void 0:e.getTime)=="function"?e:new Date(e)}function Re(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 xr(e){let n,r=0;for(const{name:i}of e)i!==n&&(n=i,r++);return r}function mr(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 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 et={year:he,month:he,week:he,day:he,hour:wr,minute:yt,second:yt},yr={year:Ar,month:Cr,week:Mr,day:Tr,hour:kr,minute:Ir,second:Sr};function vr({date:e,stepSize:n}){const r=et[n];if(!r)throw new Error("formatTime: invalid stepSize");return r(e)}function Fe({start:e,end:n,stepSize:r}){if(e>n)return Fe({start:n,end:e,stepSize:r});const i=et[r];if(!i)throw new Error("formatTimeRange: missing formatter or invalid stepSize");const s=i(e),l=i(n);return`${s} - ${l}`}function zt({date:e,stepSize:n,stepMultiplier:r}){if(!et[n])throw new Error("formatBucketRange: missing formatter or invalid stepSize");const{start:s,end:l}=br({date:e,stepSize:n,stepMultiplier:r});if(r===1){if(n==="day")return vr({date:s,stepSize:n});if(n==="second")return`${he(s)} ${Xe(s)} - ${Xe(l)}`}return Fe({start:s,end:l,stepSize:n})}const tt=e=>1e3*e,nt=e=>tt(60*e),jr=e=>nt(60*e);function he(e){return e.toLocaleDateString()}function wr(e){return he(e)+" "+e.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0})}function Xe(e){return e.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!0,second:"2-digit"})}function yt(e){return he(e)+" "+Xe(e)}function br({date:e,stepSize:n,stepMultiplier:r=1}){const i=yr[n];if(!i)throw new Error("getBucketInterval: invalid bucket size");return i({date:e,stepMultiplier:r})}function Sr({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()+tt(n-1)+999);return{start:r,end:i}}function Ir({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()+nt(n-1)+tt(59));return{start:r,end:i}}function kr({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()+jr(n-1)+nt(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 Mr({date:e,stepMultiplier:n=1}){const r=new Date(mr(e)),i=new Date(r.getFullYear(),r.getMonth(),r.getDate()+6+7*(n-1));return{start:r,end:i}}function Cr({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 Ar({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 oe=()=>{},Yt=u.createContext({isPlaying:!1,setIsPlaying:oe,isPaused:!1,setIsPaused:oe,timeWindow:[],setTimeWindow:oe,onTimeWindowUpdate:oe,togglePlay:oe,stop:oe,intl:{}});function He(){return u.useContext(Yt)}function Vt({children:e,isPlaying:n,isPaused:r,onPlay:i=oe,onPause:s=oe,onStop:l=oe,timeWindow:a,onTimeWindowUpdate:p=oe,intl:c}){const[g,h]=u.useState(n),[d,v]=u.useState(r),[f,y]=u.useState([]),m=j.useImperativeIntl(c);u.useEffect(()=>{const I=f.sort((k,w)=>k<w?-1:1).map(Ht);p==null||p(I)},[f,p]);const x=u.useCallback(()=>{g&&(s&&s(),v(!0)),g||(i&&i(),v(!1)),h(I=>!I)},[g,s,i]),S=u.useCallback(()=>{h(!1),v(!1),y([])},[]),b=u.useCallback(()=>{S(),setTimeout(l)},[l,S]);return u.useEffect(()=>{n!==g&&h(n)},[n]),u.useEffect(()=>{r!==d&&v(r)},[r]),u.useEffect(()=>{if(!a)return;const I=a.map(mt),k=f.map(mt);(I[0]!==k[0]||I[1]!==k[1])&&y(I)},a),t.jsx(Yt.Provider,{value:{isPlaying:!!g,setIsPlaying:h,isPaused:!!d,setIsPaused:v,timeWindow:f,setTimeWindow:y,onTimeWindowUpdate:p,togglePlay:x,stop:b,intl:m},children:e})}const vt={};let Be=null;const Se={seriesId:"0"};function Ut({echartsInstance:e,data:n,canSelectLines:r,filterable:i}){const s=o.useTheme(),{isPlaying:l,isPaused:a,setIsPaused:p,timeWindow:c,setTimeWindow:g,stop:h}=He(),[d,v]=u.useState(!1),[f,y]=u.useState(!1),[m,x]=u.useState(!1),[S,b]=u.useState(0),I=u.useMemo(()=>e==null?void 0:e.getZr(),[e]),k=u.useCallback(D=>I==null?void 0:I.setCursorStyle(D),[I]),w=u.useCallback(D=>{if(e){const[B]=e.convertFromPixel(Se,[D.offsetX,D.offsetY]),P=Re(B,n);g(P!==void 0?[n[P].name]:[])}},[n,e,g]);u.useEffect(()=>{function D(B){i&&(r&&B.target||(c.length||(w(B),!a&&!l&&p(!0)),c.length===2&&(g([]),h())))}return Pe(I,"click",D)},[I,a,l,p,g,h,c.length,w,r,i]),u.useEffect(()=>{function D(B){var P;if(i){if(((P=B.target)==null?void 0:P.type)==="ec-line"){v(!0),k("grabbing");return}if(c.length===2){const[L]=e.convertFromPixel(Se,[B.offsetX,B.offsetY]);if(L>=c[0]&&L<=c[1]){x(!0);const N=L-c[0];b(N);return}}if(e){y(!0);const[L]=e.convertFromPixel(Se,[B.offsetX,B.offsetY]);Be=L;return}}}return Pe(I,"mousedown",D)},[I,e,c,k,i]),u.useEffect(()=>{function D(B){var P;if(((P=B==null?void 0:B.target)==null?void 0:P.type)==="polygon"&&k("move"),d&&e&&(w(B),k("grabbing")),f&&e){const[L]=e.convertFromPixel(Se,[B.offsetX,B.offsetY]);g(Be===L?[]:[Be,L])}}return Pe(I,"mousemove",D)},[I,e,f,d,g,k,w]),u.useEffect(()=>{function D(B){if(d&&(v(!1),k("default")),f&&(y(!1),Be=null,c.length===1&&g([])),m&&e){const[P]=e.convertFromPixel(Se,[B.offsetX,B.offsetY]),L=P-c[0];if(S){const N=L-S;g([c[0]+N,c[1]+N])}x(!1)}}return Pe(I,"mouseup",D)},[I,e,m,f,d,S,g,c,k]),u.useEffect(()=>{!i&&c.length&&g([])},[i,g,c.length]);const C=u.useMemo(()=>{var L;if(c.length!==1)return;const D=c[0],B=Re(D,n);if(B===void 0)return;const P=(L=n[B])==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]),A=u.useMemo(()=>c.length===2&&{data:[[{coord:[c[0]]},{coord:[c[1]]}]],itemStyle:{color:s.palette.primary.main,opacity:.2}},[s,c]);return{timelineOptions:C,timeWindowOptions:A}}function Pe(e,n,r){if(e!=null&&e.handler)return vt[n]=r,e.on(n,r),()=>{vt[n]&&(e!=null&&e.handler)&&e.off(n,r)}}const qt=j.SPACING*22,Kt="100%",Er=5,Br=3,Pr=j.SPACING*20;function Lr({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:y}){const m=o.useTheme(),[x,S]=u.useState(),b=T=>S(T),[I,k]=u.useState(),w=u.useMemo(()=>a.reduce((T,{data:O})=>O.reduce((M,$)=>$[1]>M?$[1]:M,T),Number.MIN_VALUE),[a]),C=u.useMemo(()=>({show:i,trigger:"axis",appendToBody:!0,padding:[j.SPACING*.5,j.SPACING],textStyle:{...m.typography.caption,fontSize:11,color:m.palette.common.white},borderWidth:0,backgroundColor:m.palette.black[90],position:(T,O,M,$,G)=>{const R={top:0};return G.contentSize[0]<G.viewSize[0]-T[0]?R.left=T[0]+j.SPACING*1.5:R.right=G.viewSize[0]-T[0]+j.SPACING*1.5,R},...s?{formatter:s}:{}}),[m,i,s]),A=u.useMemo(()=>{const T={margin:0,verticalAlign:"bottom",padding:[0,0,j.SPACING*1.25,0],inside:!0,color:$=>{let G="transparent";return $>=w&&(G=m.palette.black[60]),G}},O={margin:0,verticalAlign:"middle",padding:[0,j.SPACING*.75,0,0],color:m.palette.black[60]},M=y==="dense"?T:O;return{axisPointer:{lineStyle:{color:m.palette.black[40]}},xAxis:{type:"time",axisLine:{show:!0,lineStyle:{color:m.palette.grey[900],opacity:.2}},axisLabel:{fontWeight:m.typography.fontWeightRegular,fontSize:m.typography.caption.fontSize,fontFamily:m.typography.caption.fontFamily,lineHeight:m.typography.caption.lineHeight*8,letterSpacing:m.typography.caption.letterSpacing,formatter:{year:"{yearStyle|{yyyy}}"},rich:{yearStyle:{fontWeight:m.typography.fontWeightMedium,fontSize:m.typography.caption.fontSize,fontFamily:m.typography.caption.fontFamily,letterSpacing:m.typography.caption.letterSpacing,lineHeight:m.typography.caption.lineHeight*8}}},axisTick:{show:!1},splitNumber:r??(I!==void 0?Math.min(Br,Math.ceil(I/Pr)):Er)},yAxis:{type:"value",axisLabel:{show:!0,showMaxLabel:!0,showMinLabel:!1,...M,...n?{formatter:$=>n($)}:{},fontWeight:m.typography.fontWeightRegular,fontSize:m.typography.overlineDelicate.fontSize,fontFamily:m.typography.overlineDelicate.fontFamily,lineHeight:m.typography.overlineDelicate.lineHeight*8,letterSpacing:m.typography.overlineDelicate.letterSpacing},axisLine:{show:!1},axisTick:{show:!1},splitLine:{show:!0,onZero:!1,lineStyle:{color:m.palette.black[4]}},max:w}}},[m,w,n,I,r,y]),{timelineOptions:D,timeWindowOptions:B}=Ut({echartsInstance:x,data:l,canSelectLines:!!f,filterable:d}),P=u.useMemo(()=>a.map(({data:T,color:O,name:M},$)=>{const G=v&&v.length>0,R=G&&v.includes(M),H=!G||R?O:m.palette.action.disabledBackground;return{id:String($),name:M,markLine:$===0?D:void 0,markArea:$===0?B:void 0,animation:h,data:T,type:e,smooth:!0,color:H,z:G&&R?10:0,lineStyle:{width:2},showSymbol:!1,emphasis:{scale:2,lineStyle:{width:2,color:H}}}}),[a,D,B,h,e,v,m]),L=u.useMemo(()=>({grid:{left:j.SPACING*(y==="dense"?2:3.5),top:j.SPACING*4,right:j.SPACING*2,bottom:j.SPACING*3},color:[m.palette.secondary.main],tooltip:C,...A,series:P}),[A,P,y,m.palette.secondary.main,C]),V={click:u.useCallback(T=>{if(p&&f&&T.componentType==="series"){const O=p[T.seriesIndex];f(O)}},[p,f])};u.useEffect(()=>{var M;if(typeof ResizeObserver>"u"||!x)return;const T=(M=x==null?void 0:x.getDom())==null?void 0:M.parentElement;if(!T)return;const O=new ResizeObserver(()=>{k(T.clientWidth),x.resize()});return O.observe(T),()=>{O.disconnect()}},[x]);const _=g?Kt:c??qt;return u.useLayoutEffect(()=>{var O;const T=(O=x==null?void 0:x.getDom())==null?void 0:O.parentElement;T&&k(T.clientWidth),x==null||x.resize()},[_,g,x]),t.jsx(ye,{option:L,onEvents:V,onChartReady:b,style:{height:_}})}const Dr={[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},Nr=[.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}=He();_r(()=>(p||c)&&d(),[e]);const y=()=>{const{animationFrameId:k,timeoutId:w}=a.current;k&&window.cancelAnimationFrame(k),w&&clearTimeout(w)},m=u.useCallback(()=>{y(),d()},[d]),x=()=>{y(),v()};u.useEffect(()=>{if(p&&g.length===2&&e.length){const w=Dr[n]*1e3;return Gr({data:e,timeWindow:g,msTimeWindowStep:w*s,drawFrame:C=>{h(C)},onEnd:()=>{setTimeout(m,250)},animationRef:a}),()=>y()}},[e,p,n,h,m,s]),u.useEffect(()=>{if(p&&g.length===1&&e.length)return zr({speed:s,timelinePosition:g[0],data:e,drawFrame:k=>{h([k])},onEnd:()=>{setTimeout(m,250)},animationRef:a}),()=>y();p&&g.length===0&&h([e[0].name])},[e,p,s,g.length,m]);const S=k=>{k!=null&&k.currentTarget&&i(k.currentTarget)},b=()=>{i(null)},I=k=>{l(k),b()};return t.jsxs(t.Fragment,{children:[t.jsx(o.IconButton,{size:"small",color:"default",onClick:S,"data-testid":"clock",children:t.jsx(Or,{})}),t.jsxs(o.Menu,{anchorEl:r,keepMounted:!0,open:!!r,onClose:b,children:[t.jsx(o.MenuItem,{disabled:!0,children:t.jsx(j.Typography,{variant:"caption",color:"textSecondary",children:f.formatMessage({id:"c4r.widgets.timeSeries.speed"})})}),Nr.map(k=>t.jsxs(o.MenuItem,{selected:k===s,onClick:()=>I(k),children:[k,"x"]},k))]}),t.jsx(o.Box,{mt:2,children:t.jsx(o.IconButton,{size:"small",color:"primary",disabled:!(c||p),onClick:m,"data-testid":"stop",children:t.jsx(Fr,{})})}),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(Wr,{}):t.jsx(Rr,{})})})]})}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 Rr(){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 Fr(){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 Wr(){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 _r(e,n=[]){const r=u.useRef(!1);u.useEffect(()=>{r.current?e():r.current=!0},n)}function Gr({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 Hr=2;function zr({speed:e,timelinePosition:n,data:r,drawFrame:i,onEnd:s,animationRef:l}){let a=Re(n,r)??0,p=r[a].name;const c=xr(r),g=Math.max(Math.round(Math.sqrt(c)/2),Hr)*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 Yr=o.styled(o.Box)(()=>({containerType:"inline-size",display:"flex",flexDirection:"column"})),Vr=o.styled(o.Box)(()=>({display:"flex",flexDirection:"column"})),Zt=o.styled(o.Box)(()=>({display:"flex",flexDirection:"row"})),Ur=o.styled(Zt)(()=>({alignItems:"center",justifyContent:"space-between"})),qr=o.styled(o.Box)(({theme:e})=>({flexShrink:0,marginLeft:0,paddingLeft:e.spacing(1),[`@container (max-width: ${j.BREAKPOINTS.XS}px)`]:{paddingLeft:0},paddingBottom:e.spacing(1.5),alignSelf:"flex-end"})),Kr=o.styled(o.Box)(({theme:e})=>({alignSelf:"normal",minWidth:0,paddingLeft:e.spacing(5),paddingBottom:e.spacing(1.5),[`@container (max-width: ${j.BREAKPOINTS.XS}px)`]:{paddingLeft:e.spacing(1)}}));function Xt({fitHeight:e,header:n,controls:r,chart:i,legend:s}){const l=s&&t.jsx(o.Box,{flex:0,mt:2,children:s});return t.jsxs(Yr,{style:{flex:e?"1":void 0},children:[t.jsx(Ur,{flex:0,children:n}),r?t.jsxs(Vr,{flex:1,children:[t.jsxs(Zt,{flex:1,children:[t.jsx(qr,{flex:0,children:r}),t.jsx(Kr,{flex:1,children:i})]}),l]}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{pb:1.5,flex:1,children:i}),l]})]})}const Zr=o.styled(o.Box)(()=>({display:"flex",flexDirection:"column",justifyContent:"flex-end"})),Xr=o.styled(o.Box)(()=>({position:"relative",height:"100%",alignSelf:"normal",display:"flex",flexDirection:"column",justifyContent:"flex-end"})),Jr=o.styled(o.Box)(({theme:e})=>({padding:e.spacing(2.25,0,.5,2)})),Qr=o.styled(Lt)(({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]}}})),ei=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",justifyContent:"space-between",padding:e.spacing(1.25,.5,.75,.5)})),ti=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(2),margin:0,padding:e.spacing(1.5,1,.25,1)})),jt=o.styled(o.Box)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(1)})),ni=({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(Zr,{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?Kt:n??qt,p=t.jsxs(Xr,{style:{height:a},children:[t.jsx(Jr,{flex:0,children:t.jsx(o.Skeleton,{width:24,height:8})}),t.jsx(Qr,{flex:1,children:t.jsx(Ne.GraphLineIcon,{preserveAspectRatio:"none"})}),t.jsxs(ei,{flex:0,children:[t.jsx(o.Skeleton,{width:32,height:8}),t.jsx(o.Skeleton,{width:32,height:8})]})]}),c=i&&t.jsxs(ti,{children:[t.jsxs(jt,{children:[t.jsx(o.Skeleton,{width:8,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]}),t.jsxs(jt,{children:[t.jsx(o.Skeleton,{width:8,height:8}),t.jsx(o.Skeleton,{width:48,height:8})]})]});return t.jsx(Xt,{fitHeight:!!e,header:s,controls:l,chart:p,legend:i&&c})},Jt=e=>e,Qt=[];function oi({data:e=Qt,categories:n,stepSize:r,stepMultiplier:i=1,chartType:s=Ge.LINE,timeAxisSplitNumber:l,tooltip:a=!0,tooltipFormatter:p=Gt,formatter:c=Jt,height:g,fitHeight:h,showControls:d=!0,animation:v=!0,filterable:f=!0,onTimelineUpdate:y,timeWindow:m,timelinePosition:x,onTimeWindowUpdate:S,selectedCategories:b,onSelectedCategoriesChange:I,isPlaying:k=!1,onPlay:w,isPaused:C=!1,onPause:A,onStop:D,isLoading:B=!1,palette:P=Object.values(Te.commonPalette.qualitative.bold),showLegend:L,yAxisType:N="dense"}){const V=u.useRef([]),_=X.useIntl(),{showSkeleton:T}=ce(!!B),O=u.useCallback(M=>{var $,G;if(M.length===2){(($=V.current)==null?void 0:$.length)===1&&(y==null||y(void 0));const R=M.sort((H,U)=>H<U?-1:1).map(Ht);S==null||S(R)}if(M.length===1){((G=V.current)==null?void 0:G.length)===2&&(S==null||S([]));const R=Re(Number(M[0]),e);y==null||y(R)}V.current=M},[S,y,e]);return T?t.jsx(ni,{fitHeight:h,height:g,showControls:d,showLegend:L}):t.jsx(Vt,{isPlaying:k,onPlay:w,isPaused:C,onPause:A,onStop:D,timeWindow:m,onTimeWindowUpdate:O,intl:_,children:t.jsx(ri,{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:b,timelinePosition:x,onSelectedCategoriesChange:I,yAxisType:N})})}function ri({data:e=Qt,categories:n,stepSize:r,stepMultiplier:i=1,chartType:s=Ge.LINE,timeAxisSplitNumber:l,tooltip:a=!0,tooltipFormatter:p=Gt,formatter:c=Jt,height:g,fitHeight:h=!1,showControls:d=!0,animation:v=!0,filterable:f=!0,palette:y=Object.values(Te.commonPalette.qualitative.bold),selectedCategories:m=[],onSelectedCategoriesChange:x,showLegend:S,timelinePosition:b,yAxisType:I="dense"}){const k=o.useTheme(),w=k.palette.secondary.main,{isPlaying:C,isPaused:A,timeWindow:D,stop:B,setTimeWindow:P,intl:L}=He();u.useEffect(()=>{if(b!==void 0){if(b<0||b>=e.length)return;const F=e[b].name;P([F])}},[b,e]),u.useEffect(()=>{if(!e.length)return;const F=e[0].name,z=e[e.length-1].name;(D[0]<F||D[1]>z||D[1]<F||D[1]>z)&&P([])},[e]);const N=u.useMemo(()=>{const F={},z=n?n.map(Q=>({name:Q,data:[],color:Te.getColorByCategory(Q,{palette:y,fallbackColor:w,colorMapping:F})})):[{name:"",data:[],color:k.palette.secondary.main}];for(const{name:Q,value:de,category:re,categoryIndex:W}of e){const q=W??(n&&re?n.indexOf(re):0);q===-1||n&&q>=n.length||!Number.isFinite(q)||z[q].data.push([Q,de])}return z},[n,e,y,w,k.palette.secondary.main]),V=u.useMemo(()=>{if(!e.length)return"";if(D.length===2){const[F,z]=D.map(Q=>new Date(Q));return Fe({start:F,end:z,stepSize:r})}if(!C&&!A){const F=new Date(e[0].name),z=new Date(e[e.length-1].name);return Fe({start:F,end:z,stepSize:r})}if(D.length===1){const F=new Date(D[0]);return zt({date:F,stepSize:r,stepMultiplier:i})}},[e,D,C,A,r,i]),_=u.useMemo(()=>C||A||D.length>0||(m==null?void 0:m.length)>0,[A,C,m==null?void 0:m.length,D.length]),T=()=>{B(),P([]),x==null||x([])},O=F=>{F.key==="Enter"&&T()},M=u.useCallback(F=>{if(x){const z=[...m],Q=z.indexOf(F);Q===-1?z.push(F):z.splice(Q,1),x(z)}},[x,m]),$=!!(S??N.length>1),G=t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{children:t.jsx(j.Typography,{color:"textSecondary",variant:"caption",children:V??"-"})}),f&&_&&t.jsx(o.Link,{variant:"caption",style:{cursor:"pointer"},onClick:T,onKeyDown:O,tabIndex:0,underline:"hover",children:L.formatMessage({id:"c4r.widgets.timeSeries.clear"})})]}),R=f&&d&&t.jsx($r,{data:e,stepSize:r}),H=t.jsx(Lr,{chartType:s,timeAxisSplitNumber:l,data:e,series:N,categories:n,tooltip:a,formatter:c,tooltipFormatter:F=>p(F,r,c,i,$),height:g,fitHeight:h,animation:v,filterable:f,selectedCategories:m,onCategoryClick:x&&M,yAxisType:I}),U=$&&t.jsx(_t,{series:N,selectedCategories:m,onCategoryClick:x&&M});return t.jsx(Xt,{fitHeight:h,header:G,controls:R,chart:H,legend:U})}const ii=o.styled("div")(({theme:e})=>({padding:e.spacing(2,0),...e.typography.body2})),si=o.styled(o.Box)(({theme:e})=>({overflow:"auto",maxHeight:e.spacing(40),paddingRight:e.spacing(1),margin:e.spacing(.5,0)})),li=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",flexWrap:"wrap",gap:e.spacing(1.5),padding:e.spacing(2,0)})),en=o.styled(o.Box)(({theme:e,alignItems:n="center"})=>({display:"flex",alignItems:n,gap:e.spacing(.75)})),tn=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})),ai=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(2)})),ci=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`}})),wt=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"}})),di=o.styled(o.Tooltip)(({theme:e})=>({".MuiTooltip-tooltip":{color:e.palette.common.white,maxWidth:260,marginBottom:0,overflow:"hidden"}})),ui=o.styled(o.TextField)(({theme:e})=>({marginTop:e.spacing(-.5)}));o.styled(o.Box)(()=>({display:"flex",flexWrap:"nowrap",justifyContent:"space-between"}));const pi=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)"}}})),gi=o.styled(o.Box)(({theme:e})=>({display:"flex",alignItems:"center",flexWrap:"nowrap",overflow:"hidden",gap:e.spacing(1)})),hi=o.styled(o.Box)(({theme:e})=>({padding:e.spacing(.5,0),flexGrow:"1",maxWidth:"100%",minWidth:0})),fi=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 xi(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,y)=>{var m;return{color:h?Bt.lighten(n[y],.8):n[y],value:((m=f[c])==null?void 0:m.value)??0}});return{label:d,key:g,data:v}});return s===pe.RANKING&&a.sort((p,c)=>{const g=Math.max(...p.data.map(d=>d.value));return Math.max(...c.data.map(d=>d.value))-g}),a}const mi=500;function yi(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):Ke({start:p,end:e,duration:i??mi,drawFrame:g=>c(g),requestRef:a}),()=>{a.current&&cancelAnimationFrame(a.current)}),[e,r,i]),p}const vi={};function nn({enabled:e=!0,value:n=0,options:r=vi,formatter:i}){const l=yi(n||0,{...{animateOnMount:!0,disabled:e===!1||n===null||n===void 0},...r});return t.jsx("span",{children:i?i(l):l})}const Je=e=>e,ji=()=>{},wi=[];function bi({item:e,index:n=0,names:r=wi,formatter:i=Je}){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===me?s.palette.text.disabled:h;return t.jsxs("div",{children:[t.jsx(o.Typography,{color:"inherit",variant:"caption",noWrap:!0,children:e.label}),t.jsx(o.Box,{pt:1,pb:.5,children:t.jsxs(en,{alignItems:"baseline",children:[t.jsx(tn,{color:e.key===me?s.palette.background.default:a.color}),t.jsx(o.Typography,{color:"inherit",variant:"caption",children:p}),t.jsx(o.Box,{style:{flexGrow:1}}),t.jsx(fi,{backgroundColor:d,children:t.jsxs(o.Typography,{color:"inherit",variant:"caption",children:[g,i(Math.abs(c))]})})]})})]})}function Si({item:e,animation:n=!0,animationOptions:r,maxValue:i,showCheckbox:s,checkboxChecked:l,formatter:a=Je,tooltipFormatter:p=Je,onClick:c=ji,names:g,tooltip:h}){function d(f){return`${Math.min(100,(f||0)/i*100)}%`}const v=f=>t.jsx(bi,{item:e,names:g,formatter:p,index:f});return t.jsxs(gi,{onClick:()=>c(e.key),children:[s?t.jsx(o.Checkbox,{checked:l}):null,t.jsxs(hi,{children:[t.jsx(o.Typography,{variant:"body2",noWrap:!0,children:e.label}),e.data.map((f,y)=>t.jsx(di,{title:v(y),placement:"top-start",arrow:!1,disableHoverListener:!h,children:t.jsxs(ai,{children:[t.jsx(ci,{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:y===0?"body2":"caption",color:y===0?"textPrimary":"textSecondary",children:t.jsx(nn,{value:f.value,enabled:n,options:r,formatter:a})})]})},`${e.key}_${y}`))]})]})}const bt=e=>e,Ii=()=>{},Ie=[];function St(){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 ki({names:e=Ie,data:n=Ie,labels:r=Ie,colors:i=Ie,maxItems:s=5,order:l=pe.FIXED,animation:a=!0,animationOptions:p,searchable:c=!0,filterable:g=!0,selectedCategories:h=Ie,onSelectedCategoriesChange:d=Ii,formatter:v=bt,tooltipFormatter:f=bt,tooltip:y=!0,isLoading:m=!1}){const x=o.useTheme(),[S,b]=u.useState(!1),[I,k]=u.useState(!1),[w,C]=u.useState(h),[A,D]=u.useState(""),B=X.useIntl(),P=j.useImperativeIntl(B),L=u.useMemo(()=>{const W=i.length?i:[x.palette.secondary.main,x.palette.primary.main,x.palette.info.main];return xi(n,W,r,h,l)},[n,i,r,x,h,l]),N=u.useMemo(()=>Math.max(...n.map(W=>W.map(q=>q.value??0)).flat()),[n]),V=u.useMemo(()=>{if(s>=L.length)return L;const W=L.slice(0,s),q=L.slice(s),Z=[];for(const ie of q)ie.data.forEach((Me,ve)=>{Z[ve]=Z[ve]??0,Z[ve]+=Me.value});const J={key:me,label:c?"Others":`Others (${L.length-s})`,data:Z.map(ie=>({value:ie,color:x.palette.divider}))};return[...W,J]},[L,c,s,x.palette.divider]),_=u.useMemo(()=>L.filter(W=>h.includes(W.key)),[L,h]),T=u.useMemo(()=>A?L.filter(W=>{const q=(W.key||"").toLowerCase(),Z=(W.label||"").toLowerCase(),J=q==null?void 0:q.includes(A.toLowerCase()),ie=Z==null?void 0:Z.includes(A.toLowerCase());return J||ie}):L,[L,A]),O=L.length-V.length+1,M=c&&!S&&s<L.length;if(L.length===0||m)return t.jsx(Ot,{});const $=S?T:I?_:V;function G(){k(!0),d([...w]),z()}function R(){k(!1)}function H(){d([])}function U(){k(!0)}function F(){b(!0),C([...h])}function z(){b(!1),C([])}function Q(W){const q=h.includes(W),Z=new Set(h);q?Z.delete(W):Z.add(W);let J=Array.from(Z);J.length===L.length&&(J=[]),d(J)}function de(W){const q=w.includes(W),Z=new Set(w);q?Z.delete(W):Z.add(W);let J=Array.from(Z);J.length===L.length&&(J=[]),C(J)}const re=g?S?de:Q:void 0;return t.jsxs(ii,{children:[g?t.jsxs(wt,{center:!0,children:[t.jsx(j.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(j.Typography,{variant:"caption",children:S?t.jsx(o.Link,{onClick:G,children:P.formatMessage({id:"c4r.widgets.category.apply"})}):I?t.jsx(o.Link,{onClick:R,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:U,children:P.formatMessage({id:"c4r.widgets.category.lock"})}),t.jsx(o.Divider,{orientation:"vertical",flexItem:!0}),t.jsx(o.Link,{onClick:H,children:P.formatMessage({id:"c4r.widgets.category.clear"})})]}):null})]}):null,S?t.jsx(wt,{children:t.jsx(ui,{size:"small",placeholder:P.formatMessage({id:"c4r.widgets.category.search"}),onChange:W=>D(W.currentTarget.value),onFocus:W=>W.currentTarget.scrollIntoView(),InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx(St,{})})}})}):null,t.jsxs(si,{children:[$.length===0?t.jsxs(t.Fragment,{children:[t.jsx(j.Typography,{variant:"body2",children:P.formatMessage({id:"c4r.widgets.category.noResults"})}),t.jsx(j.Typography,{variant:"caption",children:P.formatMessage({id:"c4r.widgets.category.noResultsMessage"},{searchValue:A})})]}):null,$.map(W=>t.jsx(pi,{children:t.jsx(Si,{item:W,animation:a,animationOptions:p,maxValue:N,showCheckbox:g&&S,checkboxChecked:w.includes(W.key),formatter:v,tooltipFormatter:f,tooltip:y,onClick:re,names:e})},W.key))]}),M?t.jsx(o.Button,{size:"small",color:"primary",startIcon:t.jsx(St,{}),onClick:F,children:P.formatMessage({id:"c4r.widgets.category.searchInfo"},{elements:O})}):null,S?t.jsx(o.Button,{size:"small",color:"primary",onClick:z,children:P.formatMessage({id:"c4r.widgets.category.cancel"})}):null,t.jsx(li,{children:e.map((W,q)=>t.jsxs(en,{children:[t.jsx(tn,{color:(i==null?void 0:i[q])??x.palette.background.default}),t.jsx(j.Typography,{variant:"overline",children:W})]},e[q]))})]})}const Ti=Bt.styled(j.Typography)(({theme:e})=>({display:"inline-block",marginTop:e.spacing(.5)}));function Mi({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 Ci=o.styled("div")(({theme:e})=>({margin:0,...e.typography.h5,fontWeight:Number(e.typography.fontWeightMedium),color:e.palette.text.primary,display:"flex"})),Ai=o.styled(j.Typography)(({theme:e})=>({marginRight:e.spacing(.5)})),Ei=o.styled(j.Typography)(({theme:e})=>({marginLeft:e.spacing(.5)}));function Bi({row:e,animated:n,animationOptions:r,formatter:i}){const s=o.useTheme(),{prefix:l,value:a,suffix:p,shouldBeHighlighted:c}=e;return t.jsxs(Ci,{children:[l?t.jsx(o.Box,{color:s.palette.text.secondary,children:t.jsx(Ai,{color:"inherit",component:"span",variant:"subtitle2",children:l})}):null,t.jsx(o.Box,{fontWeight:c?"bold":"",children:t.jsx(nn,{value:a,enabled:n,options:r,formatter:i})}),p?t.jsx(o.Box,{color:s.palette.text.secondary,children:t.jsx(Ei,{color:"inherit",component:"span",variant:"subtitle2",children:p})}):null]})}const Pi=e=>e,It=[],Li=o.styled("div")(({theme:e})=>({"&:nth-of-type(n+2)":{marginTop:e.spacing(2)}}));function Di({data:e=It,colors:n=It,animated:r=!0,animationOptions:i,formatter:s=Pi,isLoading:l=!1}){const a=Ni(e,n);return l?t.jsx(Ft,{}):t.jsx("div",{children:a.map((p,c)=>t.jsxs(Li,{children:[t.jsx(Bi,{row:p,animated:r,animationOptions:i,formatter:s}),t.jsx(Mi,{row:p})]},c))})}function Ni(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;
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
`,l=Array.isArray(e)?e[0]:e;if(!l)return null;const a=l.data,p=n(a.value),c=r?l.seriesName:p,g=n(l.percent);return`
|
|
30
30
|
<p style="${i}">${a.name}</p>
|
|
31
31
|
<p style="${s}">${String(l.marker)} ${c} (${g} %)</p>
|
|
32
|
-
`.trim()}const
|
|
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;
|
|
32
|
+
`.trim()}const Ri=e=>e,Fi=()=>{},Le=[],Wi="260px";function _i({names:e=Le,data:n=Le,labels:r=Le,colors:i=Le,height:s=Wi,animation:l=!0,formatter:a=Ri,tooltipFormatter:p=Oi,selectedCategories:c=[],onCategorySelected:g=Fi,isLoading:h=!1}){const d=o.useTheme(),v=u.useRef(),f=u.useMemo(()=>n.map((S,b)=>$i(S,i[b],r[b],d,c)),[n,i,r,d,c]),y=u.useMemo(()=>{const S=f.length>1;let b;p&&(b=B=>p(B,a,S));const I={trigger:"item",show:!0,backgroundColor:d.palette.black[90],textStyle:{color:d.palette.common.white},confine:!0,borderWidth:0,formatter:b},w={data:S?f.map((B,P)=>e[P]):(f[0]??[]).map(B=>B.name),selectedMode:!1,type:"scroll",left:j.SPACING,bottom:j.SPACING*-.5,itemGap:j.SPACING*3,icon:"circle",itemWidth:j.SPACING,itemHeight:j.SPACING,textStyle:{...d.typography.overline,color:d.palette.text.primary,fontWeight:400,lineHeight:1,verticalAlign:"bottom",padding:[0,0,0,j.SPACING*.5]},inactiveColor:d.palette.text.disabled,pageIcons:{horizontal:["path://M15.41 7.41 14 6 8 12 14 18 15.41 16.59 10.83 12z","path://M9 16.59 13.3265857 12 9 7.41 10.3319838 6 16 12 10.3319838 18z"]},pageIconSize:j.SPACING*1.5,pageIconColor:d.palette.text.secondary,pageIconInactiveColor:d.palette.text.disabled,pageTextStyle:{fontFamily:d.typography.overline.fontFamily,fontSize:j.SPACING*1.5,lineHeight:j.SPACING*1.75,fontWeight:400,color:d.palette.text.primary}},C={formatter:({name:B,percent:P})=>`{per|${a(P)}%}
|
|
33
|
+
{b|${B}}`,position:"center",rich:{b:{fontFamily:d.typography.overline.fontFamily,fontSize:j.SPACING*1.75,lineHeight:j.SPACING*1.75,fontWeight:400,color:d.palette.text.primary},per:{...d.typography.overline,fontSize:j.SPACING*3,lineHeight:j.SPACING*4.5,fontWeight:600,color:d.palette.text.primary}}},A=f.map((B,P)=>{var L;return{type:"pie",name:e[P],itemStyle:{color:(L=B[0])==null?void 0:L.color},animation:l,data:B.map(N=>({...N,itemStyle:{color:N.color}})),radius:P===0?["75%","90%"]:["56%","72%"],selectedOffset:0,hoverOffset:5,bottom:j.SPACING*2.5,avoidLabelOverlap:!0,label:{show:!1,...C},emphasis:{label:{show:!0,formatter:C.formatter,rich:C.rich}}}});return{grid:{left:0,top:0,right:0,bottom:0},tooltip:I,legend:w,series:A}},[d,e,l,f,a,p]),m={mouseover:(S,b)=>{f.length===1&&(S.seriesIndex!==0||S.dataIndex!==0)&&b.dispatchAction({type:"downplay",seriesIndex:0,dataIndex:0})},mouseout:(S,b)=>{f.length===1&&b.dispatchAction({type:"highlight",seriesIndex:0,dataIndex:0})},click:S=>{const I=f[S.seriesIndex][S.dataIndex].key,k=c.includes(I),w=new Set(c);k?w.delete(I):w.add(I);const C=f[0].length;let A=Array.from(w);A.length===C&&(A=[]),g(A)}};u.useEffect(()=>{v.current&&v.current.dispatchAction({type:f.length===1?"highlight":"downplay",seriesIndex:0,dataIndex:0})},[f]);function x(S){v.current=S}return f.length?h?t.jsx(Wt,{height:s}):t.jsx(ye,{onChartReady:x,notMerge:!0,option:y,onEvents:m,style:{maxHeight:s,width:"100%"}}):null}const Gi=()=>{};function on({icon:e,hoverTooltip:n,clickTooltip:r,enabled:i,onEnabledChange:s=Gi,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 Hi=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})),zi=o.styled(o.MenuItem,{shouldForwardProp:e=>e!=="disabled"})(({disabled:e,theme:n})=>({...e&&{pointerEvents:"none",color:n.palette.text.disabled}})),Yi=o.styled(o.MenuItem)(()=>({"&.Mui-disabled":{opacity:1}})),Vi=()=>{};function rn({selectionModes:e,editModes:n,selectedMode:r,onSelectMode:i=Vi,enabled:s,tooltipPlacement:l="bottom",tooltipText:a="",menuHeaderText:p="",editDisabled:c}){const g=o.useTheme(),[h,d]=u.useState(null),v=!!h,f=I=>d(I.currentTarget),y=()=>d(null),m=I=>{i&&i(I),y()},x=!!e.length&&!!n.length,S=I=>n.some(k=>k.id===I.id);function b(I){return t.jsx(zi,{selected:s&&r===I.id,onClick:()=>m(I.id),disabled:c&&S(I),children:t.jsxs(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[I.icon,t.jsx(o.Box,{ml:2,children:t.jsx(j.Typography,{variant:"body2",color:"inherit",children:o.capitalize(I.label)})})]})},I.id)}return t.jsxs(t.Fragment,{children:[t.jsx(o.Tooltip,{title:a,placement:l,children:t.jsx(Hi,{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(vn,{})})}),t.jsxs(o.Menu,{id:"feature-selection-menu",style:{zIndex:g.zIndex.tooltip+1},anchorEl:h,open:v,onClose:y,MenuListProps:{"aria-labelledby":"feature-selection-menu-button"},children:[p&&t.jsx(Yi,{disabled:!0,children:t.jsx(j.Typography,{variant:"caption",color:"textSecondary",children:p})}),!!e.length&&e.map(b),x&&t.jsx(o.Divider,{sx:{margin:({spacing:I})=>I(1,0)}}),!!n.length&&n.map(b)]})]})}const Ui=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"}})),qi=()=>{};function sn({features:e,onSelectGeometry:n=qi,onDeleteGeometry:r,chipTooltip:i,disabledChipTooltip:s,size:l="medium",tooltipPlacement:a="bottom",chipLabel:p}){const c=X.useIntl(),g=j.useImperativeIntl(c);function h(y){return y==="MultiPoint"?g.formatMessage({id:"c4r.widgets.featureSelection.point"}):y==="MultiLineString"?g.formatMessage({id:"c4r.widgets.featureSelection.lineString"}):y==="MultiPolygon"||y==="Polygon"||y==="GeometryCollection"?g.formatMessage({id:"c4r.widgets.featureSelection.polygon"}):y}function d(y,m){var S;const x=h(y.geometry.type);return p||((S=y.properties)==null?void 0:S.name)||`${x} ${m+1}`}const[v,f]=u.useState(!1);return t.jsx(o.Box,{sx:{overflowX:"auto"},children:t.jsx(Ui,{sx:{gap:l==="small"?.5:1},children:e.map((y,m)=>{var k,w;const x=(k=y.properties)==null?void 0:k.disabled,S=(w=y.properties)==null?void 0:w.invalid;let b=i;x&&(b=s||i),S&&(b=g.formatMessage({id:"c4r.widgets.featureSelection.invalid"})),v&&(b=g.formatMessage({id:"c4r.widgets.featureSelection.remove"}));let I="secondary";return x&&(I="default"),S&&(I="error"),t.jsx(o.ListItem,{disablePadding:!0,children:t.jsx(o.Tooltip,{disableHoverListener:x?!s:!i,title:b,placement:a,children:t.jsx(o.Chip,{size:l,label:d(y,m),color:I,onClick:()=>n(y),onDelete:r?()=>r(y):void 0,icon:S?t.jsx(fe.ErrorOutline,{color:"error"}):void 0,deleteIcon:t.jsx(fe.Cancel,{onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1)})})})},m)})})})}const Ki=o.styled(o.Paper)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",maxHeight:e.spacing(5),padding:e.spacing(.5)})),Zi=[];function Xi({selectionModes:e,editModes:n=Zi,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=X.useIntl(),f=j.useImperativeIntl(v),y=u.useMemo(()=>e.map(k=>({...k,label:f.formatMessage({id:`c4r.widgets.featureSelection.${kt(k.id)}`})})),[e,f]),m=u.useMemo(()=>n.map(k=>({...k,label:f.formatMessage({id:`c4r.widgets.featureSelection.${kt(k.id)}`})})),[n,f]),x=u.useMemo(()=>{const w=[...y.map(C=>({...C,isEdit:!1})),...m.map(C=>({...C,isEdit:!0}))].find(C=>C.id===r);if(!w)throw new Error(`Selected mode "${r}" not supported`);return w},[m,y,r]),S=o.capitalize((x==null?void 0:x.label)||""),b=x!=null&&x.isEdit?S:f.formatMessage({id:"c4r.widgets.featureSelection.selectTool"},{label:S}),I=x!=null&&x.isEdit?f.formatMessage({id:"c4r.widgets.featureSelection.clickToEdit"}):f.formatMessage({id:"c4r.widgets.featureSelection.clickToCreate"});return t.jsxs(Ki,{children:[t.jsx(on,{icon:x==null?void 0:x.icon,hoverTooltip:b,clickTooltip:I,enabled:s,onEnabledChange:l,tooltipPlacement:g}),t.jsx(rn,{selectionModes:y,editModes:m,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(sn,{features:[a],onSelectGeometry:p,onDeleteGeometry:c,disabledChipTooltip:f.formatMessage({id:"c4r.widgets.featureSelection.applyMask"}),chipTooltip:f.formatMessage({id:"c4r.widgets.featureSelection.clearMask"}),tooltipPlacement:g,size:h,chipLabel:d})]})}function kt(e){return e.charAt(0).toLowerCase()+e.slice(1)}const ln=240,Ji=o.styled(o.Paper,{shouldForwardProp:e=>e!=="collapsed"})(({theme:e,collapsed:n})=>({width:n?"min-content":ln,background:e.palette.background.paper,maxHeight:"calc(100% - 120px)",display:"flex",flexDirection:"column"})),Qi=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}`})),es=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})),ts=o.styled("div")(({theme:e})=>({display:"flex",gap:e.spacing(2),alignItems:"center",padding:e.spacing(1),minWidth:`calc(${ln}px - ${e.spacing(4)})`})),ns=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}})),os=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)})),an=o.styled("ul")(({theme:e})=>({margin:0,padding:0,paddingBottom:e.spacing(1),display:"flex",flexDirection:"column"})),rs=o.styled("li")(()=>({display:"flex",alignItems:"center"})),is=o.styled("div")(({theme:e})=>({marginRight:e.spacing(1.5),width:j.ICON_SIZE_MEDIUM,height:j.ICON_SIZE_MEDIUM,"& img":{margin:"auto",display:"block"}})),Tt=o.styled(o.Box,{shouldForwardProp:e=>e!=="width"})(({width:e,theme:n})=>({width:e,overflow:"auto",maxHeight:`calc(100% - ${n.spacing(1.5)})`})),ss=o.styled("section")(({theme:e})=>({"&:not(:first-of-type)":{borderTop:`1px solid ${e.palette.divider}`}})),ls=o.styled("div")(()=>({flexGrow:1,flexShrink:1,minWidth:0}));function as({menuRef:e,open:n,toggleOpen:r,opacity:i,onChange:s}){const l=X.useIntl(),a=j.useImperativeIntl(l);function p(c){const g=parseInt(c.target.value||"0"),h=Math.min(Math.max(g,0),100);s(h/100)}return t.jsxs(t.Fragment,{children:[t.jsx(o.Tooltip,{title:a.formatMessage({id:"c4r.widgets.legend.opacity"}),children:t.jsx(o.IconButton,{size:"small",color:n?"primary":"default",onClick:()=>r(!n),children:t.jsx(Ne.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(ts,{children:[t.jsx(o.Slider,{value:i*100,onChange:(c,g)=>s(g/100),min:0,max:100,step:1}),t.jsx(ns,{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 ot({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(j.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 ae=(e=>(e.CATEGORY="category",e.ICON="icon",e.CONTINUOUS_RAMP="continuous_ramp",e.BINS="bins",e.PROPORTION="proportion",e))(ae||{});const qe=20;function cn({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>qe,c=X.useIntl(),g=j.useImperativeIntl(c);return t.jsxs(t.Fragment,{children:[t.jsx(an,{"data-testid":"categories-legend",children:n.slice(0,qe).map((h,d)=>t.jsx(ps,{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(j.Typography,{variant:"caption",color:"textSecondary",component:"div",py:2,children:g.formatMessage({id:"c4r.widgets.legend.maxCategories"},{n:qe})})]})}const cs=({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}}),ds=({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})`}}),us=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?ds({icon:e,color:r,maskedIcon:n}):cs({color:r,isStrokeColor:i,theme:s})}));function ps({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(us,{className:"marker",mr:1.5,component:"span",icon:i,maskedIcon:s,isStrokeColor:n,color:r}),t.jsx(ot,{title:e,visible:!0,typographyProps:{variant:"overline",my:.75}})]})}const De=6,We={0:12,1:9,2:6,3:3},gs=o.styled(o.Box,{shouldForwardProp:e=>e!=="index"})(({index:e=0,theme:n})=>{const r=n.spacing(We[e]),i=n.spacing(We[e]);return{border:`solid 1px ${n.palette.divider}`,backgroundColor:n.palette.background.default,borderRadius:"50%",position:"absolute",right:0,bottom:0,width:r,height:i}}),hs=o.styled(o.Box)(({theme:{spacing:e}})=>({display:"flex",justifyContent:"flex-end",flexShrink:0,position:"relative",width:e(We[0]),height:e(We[0])})),fs=o.styled(o.Box)(({theme:{spacing:e}})=>({display:"flex",gap:e(1),alignItems:"stretch",justifyContent:"stretch",padding:e(2,0)})),xs=o.styled(o.Box)(()=>({display:"flex",flexDirection:"column",justifyContent:"space-around",gap:1,flexGrow:1,flexShrink:1}));function dn({legend:e}){const n=X.useIntl(),r=j.useImperativeIntl(n),i=e.showMinMax??!0,{min:s,max:l,error:a}=ms(e),[p,c]=a?[0,0]:ys(s,l);return t.jsxs(fs,{"data-testid":"proportion-legend",children:[t.jsx(hs,{children:[...Array(4)].map((g,h)=>t.jsx(gs,{index:h,component:"span"},h))}),t.jsx(xs,{children:a?t.jsx(o.Box,{maxWidth:240,children:t.jsx(j.Typography,{variant:"overline",children:"You need to specify valid numbers for the labels property"})}):t.jsxs(t.Fragment,{children:[t.jsxs(j.Typography,{variant:"overline",color:"textSecondary",children:[i&&r.formatMessage({id:"c4r.widgets.legend.max"})+": ",n.formatNumber(l,{maximumSignificantDigits:De})]}),t.jsx(j.Typography,{variant:"overline",color:"textSecondary",children:n.formatNumber(c,{maximumSignificantDigits:De})}),t.jsx(j.Typography,{variant:"overline",color:"textSecondary",children:n.formatNumber(p,{maximumSignificantDigits:De})}),t.jsxs(j.Typography,{variant:"overline",color:"textSecondary",children:[i&&r.formatMessage({id:"c4r.widgets.legend.min"})+": ",n.formatNumber(s,{maximumSignificantDigits:De})]})]})})]})}function un({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 ms(e){let n=!1;const[r,i]=un(e);return(Number.isNaN(r)||Number.isNaN(i))&&(n=!0),{min:r,max:i,error:n}}function ys(e,n){const r=(n-e)/3;return[e+r,n-r]}function pn({legend:e}){const{labels:n=[],icons:r=[]}=e;return t.jsx(an,{"data-testid":"icon-legend",children:n.map((i,s)=>t.jsxs(rs,{children:[t.jsx(is,{children:t.jsx("img",{src:r[s],alt:i,width:"auto",height:j.ICON_SIZE_MEDIUM})}),t.jsx(ot,{visible:!0,title:i,typographyProps:{variant:"overline",my:.75}})]},i))})}function vs(e){return typeof e[0]=="object"&&"label"in e[0]}function Qe({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=vs(r),p=a?r.map(({value:y})=>y):r,c=a?r.map(({label:y})=>y):r,[g,h]=un({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(j.Typography,{variant:"overline",children:"You need to specify valid numbers for the labels property"})}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{display:"flex",pb:1,children:e?t.jsx(js,{"data-testid":"step-continuous",palette:l}):t.jsx(bs,{palette:l,labels:c,max:v,min:f})}),t.jsxs(o.Box,{display:"flex",justifyContent:"space-between",children:[t.jsx(j.Typography,{variant:"overlineDelicate",color:"textSecondary",children:f}),t.jsx(j.Typography,{variant:"overlineDelicate",color:"textSecondary",children:v})]})]})})}const js=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()})`})),ws=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 bs({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(ws,{"data-testid":"step-discontinuous",color:n[a]})},a)})})}const Ss={[ae.CATEGORY]:cn,[ae.PROPORTION]:dn,[ae.ICON]:pn,[ae.BINS]:e=>t.jsx(Qe,{...e,isContinuous:!1}),[ae.CONTINUOUS_RAMP]:e=>t.jsx(Qe,{...e,isContinuous:!0})};function Is({legend:e}){const n=X.useIntl(),r=j.useImperativeIntl(n);return e.select||!e.type?null:t.jsxs(j.Typography,{variant:"body2",color:"textSecondary",component:"p",children:[e.type," ",r.formatMessage({id:"c4r.widgets.legend.notSupported"}),"."]})}function ks(e){return e.type===ae.PROPORTION?"c4r.widgets.legend.subtitles.proportion":e.type===ae.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=X.useIntl(),l=j.useImperativeIntl(s),a=n.type,c=Ss[a]??r[a]??Is,g=((h=n.select)==null?void 0:h.options)??[];return t.jsxs(o.Box,{component:"li","data-testid":"legend-layer-variable",px:2,children:[n.attr?t.jsxs(o.Box,{pb:1,children:[t.jsx(j.Typography,{gutterBottom:!0,variant:"overlineDelicate",color:"textSecondary",component:"p",children:l.formatMessage({id:ks(n)})}),t.jsx(j.Typography,{variant:"caption",component:"p",children:n.attr})]}):null,n.select?t.jsxs(o.Box,{pb:1,children:[t.jsx(j.Typography,{variant:"caption",weight:"medium",component:"p",children:n.select.label}),t.jsx(o.Select,{"data-testid":"legend-layer-variable-select",name:"legend-select",value:n.select.value,renderValue:d=>{var 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 Ms={};function gn(e){return e?Array.isArray(e)?e.every(n=>gn(n)):!e.select&&!e.type:!0}function Mt({customLegendTypes:e=Ms,layer:n,onChangeCollapsed:r,onChangeOpacity:i,onChangeVisibility:s,onChangeSelection:l,maxZoom:a=21,minZoom:p=0,currentZoom:c=0}){const g=X.useIntl(),h=j.useImperativeIntl(g),d=u.useRef(null),[v,f]=u.useState(!1),y=n.id,m=n.title,x=n.visible??!0,S=n.switchable??!0,b=n.collapsed??!1,I=(n.collapsible??!0)&&!gn(n.legend),k=n.opacity??1,w=n.showOpacityControl??!0,C=x&&!b,A=C?t.jsx(kn,{}):t.jsx(In,{}),D=(n==null?void 0:n.minZoom)!==void 0||(n==null?void 0:n.maxZoom)!==void 0,B=n.minZoom??p,P=n.maxZoom??a,L=D&&(B>p||P<a),N=c<B||c>P,V=Cs({intl:h,minZoom:p,maxZoom:a,layerMinZoom:B,layerMaxZoom:P}),_=n.helperText??(L?V:""),T=u.useMemo(()=>n.legend?Array.isArray(n.legend)?n.legend:[n.legend]:[],[n.legend]);return n.legend?t.jsxs(ss,{"data-testid":"legend-layer","aria-label":m,children:[t.jsxs(es,{ref:d,children:[I&&t.jsx(o.IconButton,{size:"small","aria-label":h.formatMessage({id:b?"c4r.widgets.legend.expand":"c4r.widgets.legend.collapse"}),disabled:!x,onClick:()=>r({id:y,collapsed:!b}),children:A}),t.jsxs(ls,{children:[t.jsx(ot,{visible:x,title:m??""}),L&&t.jsx(o.Tooltip,{title:h.formatMessage({id:"c4r.widgets.legend.zoomLevelTooltip"}),children:t.jsxs(j.Typography,{color:x?"textPrimary":"textSecondary",variant:"caption",component:"p",children:[h.formatMessage({id:"c4r.widgets.legend.zoomLevel"})," ",n.minZoom," - ",n.maxZoom]})})]}),w&&x&&!b&&t.jsx(as,{menuRef:d,open:v,toggleOpen:f,opacity:k,onChange:O=>i({id:y,opacity:O})}),S&&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:y,collapsed:x?b:!1,visible:!x}),children:x?t.jsx(bn,{}):t.jsx(Sn,{})})})]}),t.jsxs(o.Collapse,{unmountOnExit:!0,timeout:100,in:C,children:[t.jsx(os,{"data-testid":"legend-layer-variable-list",opacity:N?.5:1,children:T.map((O,M)=>t.jsx(Ts,{legend:O,layer:n,customLegendTypes:e,onChangeSelection:$=>l({id:y,index:M,selection:$})},`${O.type}-${M}`))}),_&&t.jsx(j.Typography,{variant:"caption",color:"textSecondary",component:"div",p:2,children:t.jsx("div",{dangerouslySetInnerHTML:{__html:_}})})]})]}):null}function Cs({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 As={},ke=()=>{},Es=[];function Bs({customLegendTypes:e=As,layers:n=Es,collapsed:r=!1,onChangeCollapsed:i=ke,onChangeVisibility:s=ke,onChangeOpacity:l=ke,onChangeLegendRowCollapsed:a=ke,onChangeSelection:p=ke,title:c="Layers",maxZoom:g=20,minZoom:h=0,currentZoom:d,isMobile:v,sx:f}){const y=X.useIntl(),m=j.useImperativeIntl(y),x=t.jsxs(Qi,{collapsed:r,children:[t.jsx(j.Typography,{variant:"caption",flexGrow:1,children:c}),t.jsx(o.Tooltip,{title:m.formatMessage({id:"c4r.widgets.legend.close"}),children:t.jsx(o.IconButton,{size:"small",onClick:()=>i(!0),children:t.jsx(jn,{})})})]}),S=t.jsx(o.Tooltip,{title:m.formatMessage({id:"c4r.widgets.legend.open"}),children:t.jsx(o.IconButton,{"aria-label":c,onClick:()=>i(!1),children:t.jsx(wn,{})})});return t.jsx(Ji,{sx:f,elevation:3,collapsed:r||!!v,children:v?t.jsxs(t.Fragment,{children:[S,t.jsxs(o.Drawer,{anchor:"bottom",open:!r,onClose:()=>i(!0),children:[x,t.jsx(Tt,{children:n.map(b=>t.jsx(Mt,{layer:b,onChangeCollapsed:a,onChangeOpacity:l,onChangeVisibility:s,onChangeSelection:p,maxZoom:g,minZoom:h,currentZoom:d,customLegendTypes:e},b.id))})]})]}):t.jsxs(t.Fragment,{children:[r?S:x,t.jsx(Tt,{width:r?0:void 0,children:t.jsx(o.Collapse,{unmountOnExit:!0,in:!r,timeout:500,children:n.map(b=>t.jsx(Mt,{layer:b,onChangeCollapsed:a,onChangeOpacity:l,onChangeVisibility:s,onChangeSelection:p,maxZoom:g,minZoom:h,currentZoom:d,customLegendTypes:e},b.id))})})]})})}function Ct({color:e=void 0,children:n}){return n?t.jsx(o.Box,{mt:.5,children:t.jsx(j.Typography,{component:"div",variant:"caption",color:e??"inherit",style:{fontWeight:"normal"},children:n})}):t.jsx(o.Box,{mt:-1})}function Ps({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(Tn.Alert,{title:e,severity:r,...i,children:t.jsx(Ct,{children:n})}):t.jsxs(o.Box,{...i,children:[e&&t.jsx(j.Typography,{variant:"body2",children:e}),t.jsx(Ct,{color:"textSecondary",children:n})]})}const Ls=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)})),Ds=o.styled(o.LinearProgress)(({theme:e})=>({position:"absolute",top:0,left:0,width:"100%",height:e.spacing(.25)})),Ns=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"}})),hn=({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",width:e.spacing(3),height:e.spacing(3),color:e.palette.text.secondary}),Os=o.styled(fe.ExpandLess)(({theme:e})=>hn({theme:e})),Rs=o.styled(fe.ExpandMore)(({theme:e})=>hn({theme:e})),Fs=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"}})),Ws=o.styled(o.Grid)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1),marginRight:e.spacing(-.5),marginLeft:e.spacing(1)})),At=o.styled(o.IconButton)(({theme:e})=>({color:e.palette.text.secondary})),_s=o.styled(o.Menu)(({theme:e})=>({".MuiPaper-root":{marginTop:e.spacing(5),maxHeight:e.spacing(21),minWidth:e.spacing(16)}})),Et=[],Gs=t.jsx(fe.MoreVert,{});function Hs({title:e,actions:n=Et,options:r=Et,optionsIcon:i=Gs,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 y=u.createRef(),[m,x]=u.useState(!0),S=c!==void 0&&g!==void 0,b=p!==!1?S?c:m:!0,I=S?g:x,[k,w]=u.useState(null),C=!!k,A=()=>{p&&I(!b)},D=N=>w(N.currentTarget),B=()=>w(null);function P(N){N&&N(),B()}const L=N=>t.jsx(At,{"aria-label":N.label,onClick:N.action,size:"small",children:N.icon},N.id);return a?s:t.jsxs(Ls,{margin:f,component:"section","aria-label":e,children:[v?t.jsx(Ds,{}):null,t.jsxs(Ns,{container:!0,expanded:c,children:[t.jsx($s,{expandable:p,startIcon:p&&t.jsx(o.Icon,{children:b?t.jsx(Os,{}):t.jsx(Rs,{})}),onClick:A,tabIndex:p?0:-1,children:t.jsx(o.Tooltip,{title:e,children:t.jsx(Fs,{expanded:c,align:"left",variant:"subtitle1",children:e})})}),t.jsxs(Ws,{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(At,{"aria-label":"options","aria-controls":"options-menu","aria-haspopup":"true",onClick:D,size:"small",children:i}),t.jsx(_s,{id:"options-menu",elevation:8,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:k,keepMounted:!0,open:C,onClose:B,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:y,in:b,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=Rn;exports.CategoryWidgetUI=Kn;exports.ComparativeCategoryWidgetUI=ki;exports.ComparativeFormulaWidgetUI=Di;exports.ComparativePieWidgetUI=_i;exports.FeatureSelectionUIDropdown=rn;exports.FeatureSelectionUIGeometryChips=sn;exports.FeatureSelectionUIToggleButton=on;exports.FeatureSelectionWidgetUI=Xi;exports.FormulaWidgetUI=Qn;exports.GroupDateTypes=le;exports.HistogramWidgetUI=ao;exports.LEGEND_TYPES=ae;exports.LegendCategories=cn;exports.LegendIcon=pn;exports.LegendProportion=dn;exports.LegendRamp=Qe;exports.LegendWidgetUI=Bs;exports.NoDataAlert=Ps;exports.PieWidgetUI=Oo;exports.RangeWidgetUI=Uo;exports.ScatterPlotWidgetUI=nr;exports.TIME_SERIES_CHART_TYPES=Ge;exports.TableWidgetUI=gr;exports.TimeSeriesProvider=Vt;exports.TimeSeriesWidgetUI=oi;exports.WrapperWidgetUI=Hs;exports.useTimeSeriesContext=He;exports.useTimeSeriesInteractivity=Ut;
|