"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[1459],{61459:(e,t,n)=>{n.r(t),n.d(t,{default:()=>y});var r=n(96540),a=n(62952),l=n(58863),o=n(96627),s=n(7349),u=n(32142),c=n(86444),i=n(85867),d=n(71194),f=n(96453),h=n(9203),g=n(51536),p=n(2445);const{RadioButtonControl:m}=h.A,v=f.I4.div`
  text-align: center;
`;function C({formData:e,setControlValue:t}){const{extraControlsOptions:n,extraControlsHandler:a,extraValue:l}=function({formData:e,setControlValue:t}){const{stack:n,area:a}=e,[l,o]=(0,r.useState)(null!=n?n:void 0);return(0,r.useEffect)((()=>{o(n)}),[n]),{extraControlsOptions:(0,r.useMemo)((()=>a?g.RC:[]),[a]),extraControlsHandler:(0,r.useCallback)((e=>{a&&t&&(t("stack",e),o(e))}),[a,t]),extraValue:l}}({formData:e,setControlValue:t});return e.showExtraControls?(0,p.Y)(v,{children:(0,p.Y)(m,{options:n,onChange:a,value:l})}):null}const b=300;function y({formData:e,height:t,width:n,echartOptions:f,groupby:h,labelMap:g,selectedValues:m,setDataMask:v,setControlValue:y,legendData:x=[],onContextMenu:k,onLegendStateChanged:w,onFocusedSeries:V,xValueFormatter:E,xAxis:F,refs:R,emitCrossFilters:D,coltypeMapping:I}){const{stack:O}=e,S=(0,r.useRef)(null);R.echartRef=S;const T=(0,r.useRef)(),A=(0,r.useRef)(null),[M,Y]=(0,r.useState)(0);(0,r.useEffect)((()=>{var e;const t=(null==(e=A.current)?void 0:e.offsetHeight)||0;Y(t)}),[e.showExtraControls]);const H=(0,a.A)(h).length>0,N=(0,r.useCallback)((e=>{const t=Object.values(m);let n;n=t.includes(e)?t.filter((t=>t!==e)):[e];const r=n.map((e=>g[e]));return{dataMask:{extraFormData:{filters:0===n.length?[]:h.map(((e,t)=>{const n=r.map((e=>e[t]));return null==n?{col:e,op:"IS NULL"}:{col:e,op:"IN",val:n}}))},filterState:{label:r.length?r:void 0,value:r.length?r:null,selectedValues:n.length?n:null}},isCurrentValueSelected:t.includes(e)}}),[h,g,m]),j=(0,r.useCallback)((e=>{D&&v(N(e).dataMask)}),[D,v,N]),L={click:e=>{H&&(T.current&&clearTimeout(T.current),T.current=setTimeout((()=>{const{seriesName:t}=e;j(t)}),b))},mouseout:()=>{V(null)},mouseover:e=>{V(e.seriesName)},legendselectchanged:e=>{null==w||w(e.selected)},legendselectall:e=>{null==w||w(e.selected)},legendinverseselect:e=>{null==w||w(e.selected)},contextmenu:async t=>{if(k){var n;t.event.stop();const{data:r,seriesName:i}=t,f=[],h=[],p=t.event.event,m=[...t.name?[t.name]:[],...null!=(n=g[i])?n:[]],v=(0,a.A)(e.groupby);r&&F.type===l.Gw.Time&&f.push({col:F.label===o.Tf?e.granularitySqla:F.label,grain:e.timeGrainSqla,op:"==",val:r[0],formattedVal:E(r[0])}),[...F.type===l.Gw.Category&&r?[F.label]:[],...v].forEach(((e,t)=>f.push({col:e,op:"==",val:m[t],formattedVal:String(m[t])}))),v.forEach(((t,n)=>{const r=g[i][n];h.push({col:t,op:"==",val:r,formattedVal:(0,d.Wy)(m[n],{timeFormatter:(0,s.mo)(e.dateFormat),numberFormatter:(0,u.gV)(e.numberFormat),coltype:null==I?void 0:I[(0,c.A)(t)]})})})),k(p.clientX,p.clientY,{drillToDetail:f,drillBy:{filters:h,groupbyFieldName:"groupby"},crossFilter:H?N(i):void 0})}}},z={dblclick:e=>{var t;T.current&&clearTimeout(T.current);const n=[e.offsetX,e.offsetY],r=null==(t=S.current)?void 0:t.getEchartInstance();if(null!=r&&r.containPixel("grid",n)){var a;if(!O&&"ec-polygon"===(null==(a=e.target)?void 0:a.type))return;const t=r.getModel(),n=((e,t)=>{let n=e,r=null;for(;n;){const e=n.__ecComponentInfo;if(null!=e){r=t.getComponent(e.mainType,e.index);break}n=n.parent}return r})(e.target,t);if(n){const{name:e}=n,t=x.reduce(((t,n)=>({...t,[n]:n===e})),{});null==w||w(t)}}}};return(0,p.FD)(p.FK,{children:[(0,p.Y)("div",{ref:A,children:(0,p.Y)(C,{formData:e,setControlValue:y})}),(0,p.Y)(i.A,{ref:S,refs:R,height:t-M,width:n,echartOptions:f,eventHandlers:L,zrEventHandlers:z,selectedValues:m})]})}},85867:(e,t,n)=>{n.d(t,{A:()=>H});var r=n(96540),a=n(96453),l=n(3087),o=n(92351),s=n(42900),u=n(51719),c=n(74508),i=n(61030),d=n(45567),f=n(49714),h=n(11734),g=n(80491),p=n(25652),m=n(73900),v=n(32003),C=n(22329),b=n(31441),y=n(12458),x=n(39539),k=n(5553),w=n(45967),V=n(40830),E=n(45620),F=n(39838),R=n(42998),D=n(69380),I=n(25384),O=n(29022),S=n(28540),T=n(35278),A=n(2445);const M=a.I4.div`
  height: ${({height:e})=>e};
  width: ${({width:e})=>e};
`;function Y({width:e,height:t,echartOptions:n,eventHandlers:a,zrEventHandlers:l,selectedValues:s={},refs:u},c){const i=(0,r.useRef)(null);u&&(u.divRef=i);const d=(0,r.useRef)(),f=(0,r.useMemo)((()=>Object.keys(s)||[]),[s]),h=(0,r.useRef)([]);(0,r.useImperativeHandle)(c,(()=>({getEchartInstance:()=>d.current}))),(0,r.useEffect)((()=>{i.current&&(d.current||(d.current=(0,o.Ts)(i.current)),Object.entries(a||{}).forEach((([e,t])=>{var n,r;null==(n=d.current)||n.off(e),null==(r=d.current)||r.on(e,t)})),Object.entries(l||{}).forEach((([e,t])=>{var n,r;null==(n=d.current)||n.getZr().off(e),null==(r=d.current)||r.getZr().on(e,t)})),d.current.setOption(n,!0))}),[n,a,l]),(0,r.useEffect)((()=>{d.current&&(d.current.dispatchAction({type:"downplay",dataIndex:h.current.filter((e=>!f.includes(e)))}),f.length&&d.current.dispatchAction({type:"highlight",dataIndex:f}),h.current=f)}),[f]);const g=(0,r.useCallback)((({width:e,height:t})=>{d.current&&d.current.resize({width:e,height:t})}),[]);return(0,r.useEffect)((()=>(g({width:e,height:t}),()=>{var e;return null==(e=d.current)?void 0:e.dispose()})),[]),(0,r.useLayoutEffect)((()=>{g({width:e,height:t})}),[e,t,g]),(0,A.Y)(M,{ref:i,height:t,width:e})}(0,l.Y)([x.a,s.a,u.a,c.a,i.a,d.a,f.a,h.a,g.a,p.a,m.a,v.a,C.a,b.a,y.a,k.a,w.a,V.a,E.a,F.a,R.a,D.a,I.a,O.a,S.a,T._]);const H=(0,r.forwardRef)(Y)}}]);