"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[8551],{788551:(e,t,n)=>{n.r(t),n.d(t,{default:()=>C});var r=n(667294),l=n(355786),a=n(616355),o=n(5364),s=n(751115),u=n(767190),c=n(310581),i=n(263475),d=n(806915),f=n(751995),h=n(593362),g=n(849239),p=n(135944);const{RadioButtonControl:m}=h.default,v=f.iK.div`
  text-align: center;
`;function N({formData:e,setControlValue:t}){const{extraControlsOptions:n,extraControlsHandler:l,extraValue:a}=function({formData:e,setControlValue:t}){const{stack:n,area:l}=e,[a,o]=(0,r.useState)(null!=n?n:void 0);return(0,r.useEffect)((()=>{o(n)}),[n]),{extraControlsOptions:(0,r.useMemo)((()=>l?g.Df:[]),[l]),extraControlsHandler:(0,r.useCallback)((e=>{l&&t&&(t("stack",e),o(e))}),[l,t]),extraValue:a}}({formData:e,setControlValue:t});return e.showExtraControls?(0,p.tZ)(v,{children:(0,p.tZ)(m,{options:n,onChange:l,value:a})}):null}const b=300;function C({formData:e,height:t,width:n,echartOptions:f,groupby:h,labelMap:g,selectedValues:m,setDataMask:v,setControlValue:C,legendData:y=[],onContextMenu:x,onLegendStateChanged:k,onFocusedSeries:w,xValueFormatter:E,xAxis:V,refs:Z,emitCrossFilters:D,coltypeMapping:S}){const{stack:F}=e,O=(0,r.useRef)(null);Z.echartRef=O;const R=(0,r.useRef)(),H=(0,r.useRef)(null),[M,T]=(0,r.useState)(0);(0,r.useEffect)((()=>{var e;const t=(null==(e=H.current)?void 0:e.offsetHeight)||0;T(t)}),[e.showExtraControls]);const I=(0,l.Z)(h).length>0,j=(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]),B=(0,r.useCallback)((e=>{D&&v(j(e).dataMask)}),[D,v,j]),L={click:e=>{I&&(R.current&&clearTimeout(R.current),R.current=setTimeout((()=>{const{seriesName:t}=e;B(t)}),b))},mouseout:()=>{w(null)},mouseover:e=>{w(e.seriesName)},legendselectchanged:e=>{null==k||k(e.selected)},legendselectall:e=>{null==k||k(e.selected)},legendinverseselect:e=>{null==k||k(e.selected)},contextmenu:async t=>{if(x){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,l.Z)(e.groupby);r&&V.type===a.we.Time&&f.push({col:V.label===o.W3?e.granularitySqla:V.label,grain:e.timeGrainSqla,op:"==",val:r[0],formattedVal:E(r[0])}),[...V.type===a.we.Category&&r?[V.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.mj)(m[n],{timeFormatter:(0,s.bt)(e.dateFormat),numberFormatter:(0,u.JB)(e.numberFormat),coltype:null==S?void 0:S[(0,c.Z)(t)]})})})),x(p.clientX,p.clientY,{drillToDetail:f,drillBy:{filters:h,groupbyFieldName:"groupby"},crossFilter:I?j(i):void 0})}}},z={dblclick:e=>{var t;R.current&&clearTimeout(R.current);const n=[e.offsetX,e.offsetY],r=null==(t=O.current)?void 0:t.getEchartInstance();if(null!=r&&r.containPixel("grid",n)){var l;if(!F&&"ec-polygon"===(null==(l=e.target)?void 0:l.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=y.reduce(((t,n)=>({...t,[n]:n===e})),{});null==k||k(t)}}}};return(0,p.BX)(p.HY,{children:[(0,p.tZ)("div",{ref:H,children:(0,p.tZ)(N,{formData:e,setControlValue:C})}),(0,p.tZ)(i.Z,{ref:O,refs:Z,height:t-M,width:n,echartOptions:f,eventHandlers:L,zrEventHandlers:z,selectedValues:m})]})}},263475:(e,t,n)=>{n.d(t,{Z:()=>I});var r=n(667294),l=n(751995),a=n(768023),o=n(281615),s=n(967021),u=n(358062),c=n(781836),i=n(873463),d=n(216026),f=n(259048),h=n(15746),g=n(126947),p=n(302907),m=n(516049),v=n(541969),N=n(938198),b=n(548785),C=n(557494),y=n(570012),x=n(730322),k=n(655958),w=n(603174),E=n(731281),V=n(210680),Z=n(347106),D=n(693450),S=n(499326),F=n(617813),O=n(129167),R=n(787164),H=n(135944);const M=l.iK.div`
  height: ${({height:e})=>e};
  width: ${({width:e})=>e};
`;function T({width:e,height:t,echartOptions:n,eventHandlers:l,zrEventHandlers:a,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.S1)(i.current)),Object.entries(l||{}).forEach((([e,t])=>{var n,r;null==(n=d.current)||n.off(e),null==(r=d.current)||r.on(e,t)})),Object.entries(a||{}).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,l,a]),(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,H.tZ)(M,{ref:i,height:t,width:e})}(0,a.D)([y.N,s.N,u.N,c.N,i.N,d.N,f.N,h.N,g.N,p.N,m.N,v.N,N.N,b.N,C.N,x.N,k.N,w.N,E.N,V.N,Z.N,D.N,S.N,F.N,O.N,R.T]);const I=(0,r.forwardRef)(T)}}]);
//# sourceMappingURL=1fd95927686b512365e4.chunk.js.map