"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[8551],{88551:(e,t,r)=>{r.r(t),r.d(t,{default:()=>y});var l=r(78580),n=r.n(l),a=r(67294),o=r(16355),s=r(5364),u=r(51115),c=r(67190),i=r(10581),d=r(63475),f=r(6915),h=r(51995),g=r(356),p=r(49239),m=r(11965);const{RadioButtonControl:v}=g.Z,b=h.iK.div`
  text-align: center;
`;function C(e){let{formData:t,setControlValue:r}=e;const{extraControlsOptions:l,extraControlsHandler:n,extraValue:o}=function(e){let{formData:t,setControlValue:r}=e;const{stack:l,area:n}=t,[o,s]=(0,a.useState)(null!=l?l:void 0);return(0,a.useEffect)((()=>{s(l)}),[l]),{extraControlsOptions:(0,a.useMemo)((()=>n?p.Df:[]),[n]),extraControlsHandler:(0,a.useCallback)((e=>{n&&r&&(r("stack",e),s(e))}),[n,r]),extraValue:o}}({formData:t,setControlValue:r});return t.showExtraControls?(0,m.tZ)(b,null,(0,m.tZ)(v,{options:l,onChange:n,value:o})):null}function y(e){let{formData:t,height:r,width:l,echartOptions:h,groupby:g,labelMap:p,selectedValues:v,setDataMask:b,setControlValue:y,legendData:x=[],onContextMenu:k,onLegendStateChanged:w,xValueFormatter:E,xAxis:V,refs:Z,emitCrossFilters:D,coltypeMapping:F}=e;const{stack:O}=t,R=(0,a.useRef)(null);Z.echartRef=R;const S=(0,a.useRef)(),M=(0,a.useRef)(null),[H,I]=(0,a.useState)(0);(0,a.useEffect)((()=>{var e;const t=(null==(e=M.current)?void 0:e.offsetHeight)||0;I(t)}),[t.showExtraControls]);const T=(0,a.useCallback)((e=>{const t=Object.values(v);let r;r=n()(t).call(t,e)?t.filter((t=>t!==e)):[e];const l=r.map((e=>p[e]));return{dataMask:{extraFormData:{filters:0===r.length?[]:g.map(((e,t)=>{const r=l.map((e=>e[t]));return null==r?{col:e,op:"IS NULL"}:{col:e,op:"IN",val:r}}))},filterState:{label:l.length?l:void 0,value:l.length?l:null,selectedValues:r.length?r:null}},isCurrentValueSelected:n()(t).call(t,e)}}),[g,p,v]),j=(0,a.useCallback)((e=>{D&&b(T(e).dataMask)}),[D,b,T]),N={click:e=>{S.current&&clearTimeout(S.current),S.current=setTimeout((()=>{const{seriesName:t}=e;j(t)}),300)},legendselectchanged:e=>{null==w||w(e.selected)},legendselectall:e=>{null==w||w(e.selected)},legendinverseselect:e=>{null==w||w(e.selected)},contextmenu:async e=>{if(k){var r;e.event.stop();const{data:l,seriesName:n}=e,a=[],d=[],h=e.event.event,g=[...e.name?[e.name]:[],...null!=(r=p[n])?r:[]];l&&V.type===o.we.time&&a.push({col:V.label===s.W3?t.granularitySqla:V.label,grain:t.timeGrainSqla,op:"==",val:l[0],formattedVal:E(l[0])}),[...V.type===o.we.category&&l?[V.label]:[],...t.groupby].forEach(((e,t)=>a.push({col:e,op:"==",val:g[t],formattedVal:String(g[t])}))),t.groupby.forEach(((e,r)=>{const l=p[n][r];d.push({col:e,op:"==",val:l,formattedVal:(0,f.mj)(g[r],{timeFormatter:(0,u.bt)(t.dateFormat),numberFormatter:(0,c.JB)(t.numberFormat),coltype:null==F?void 0:F[(0,i.Z)(e)]})})})),k(h.clientX,h.clientY,{drillToDetail:a,crossFilter:T(n),drillBy:{filters:d,groupbyFieldName:"groupby"}})}}},L={dblclick:e=>{var t;S.current&&clearTimeout(S.current);const r=[e.offsetX,e.offsetY],l=null==(t=R.current)?void 0:t.getEchartInstance();if(null!=l&&l.containPixel("grid",r)){var n;if(!O&&"ec-polygon"===(null==(n=e.target)?void 0:n.type))return;const t=l.getModel(),r=((e,t)=>{let r=e,l=null;for(;r;){const e=r.__ecComponentInfo;if(null!=e){l=t.getComponent(e.mainType,e.index);break}r=r.parent}return l})(e.target,t);if(r){const{name:e}=r,t=x.reduce(((t,r)=>({...t,[r]:r===e})),{});null==w||w(t)}}}};return(0,m.tZ)(a.Fragment,null,(0,m.tZ)("div",{ref:M},(0,m.tZ)(C,{formData:t,setControlValue:y})),(0,m.tZ)(d.Z,{ref:R,refs:Z,height:r-H,width:l,echartOptions:h,eventHandlers:N,zrEventHandlers:L,selectedValues:v}))}},63475:(e,t,r)=>{r.d(t,{Z:()=>d});var l=r(78580),n=r.n(l),a=r(67294),o=r(51995),s=r(31431),u=r(11965);const c=o.iK.div`
  height: ${e=>{let{height:t}=e;return t}};
  width: ${e=>{let{width:t}=e;return t}};
`;function i(e,t){let{width:r,height:l,echartOptions:o,eventHandlers:i,zrEventHandlers:d,selectedValues:f={},refs:h}=e;const g=(0,a.useRef)(null);h&&(h.divRef=g);const p=(0,a.useRef)(),m=(0,a.useMemo)((()=>Object.keys(f)||[]),[f]),v=(0,a.useRef)([]);(0,a.useImperativeHandle)(t,(()=>({getEchartInstance:()=>p.current}))),(0,a.useEffect)((()=>{g.current&&(p.current||(p.current=(0,s.S1)(g.current)),Object.entries(i||{}).forEach((e=>{var t,r;let[l,n]=e;null==(t=p.current)||t.off(l),null==(r=p.current)||r.on(l,n)})),Object.entries(d||{}).forEach((e=>{var t,r;let[l,n]=e;null==(t=p.current)||t.getZr().off(l),null==(r=p.current)||r.getZr().on(l,n)})),p.current.setOption(o,!0))}),[o,i,d]),(0,a.useEffect)((()=>{p.current&&(p.current.dispatchAction({type:"downplay",dataIndex:v.current.filter((e=>!n()(m).call(m,e)))}),m.length&&p.current.dispatchAction({type:"highlight",dataIndex:m}),v.current=m)}),[m]);const b=(0,a.useCallback)((e=>{let{width:t,height:r}=e;p.current&&p.current.resize({width:t,height:r})}),[]);return(0,a.useEffect)((()=>(b({width:r,height:l}),()=>{var e;return null==(e=p.current)?void 0:e.dispose()})),[]),(0,a.useLayoutEffect)((()=>{b({width:r,height:l})}),[r,l,b]),(0,u.tZ)(c,{ref:g,height:l,width:r})}const d=(0,a.forwardRef)(i)}}]);
//# sourceMappingURL=51e770d8fa3c205ca23c.chunk.js.map