"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[8551],{88551:(e,t,n)=>{n.r(t),n.d(t,{default:()=>C});var r=n(67294),l=n(16355),a=n(5364),o=n(51115),s=n(67190),u=n(10581),c=n(63475),i=n(6915),d=n(51995),f=n(93362),h=n(49239),g=n(11965);const{RadioButtonControl:p}=f.default,m=d.iK.div`
  text-align: center;
`;function v({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?h.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,g.tZ)(m,null,(0,g.tZ)(p,{options:n,onChange:l,value:a})):null}const b=300;function C({formData:e,height:t,width:n,echartOptions:d,groupby:f,labelMap:h,selectedValues:p,setDataMask:m,setControlValue:C,legendData:y=[],onContextMenu:x,onLegendStateChanged:k,onFocusedSeries:w,xValueFormatter:E,xAxis:V,refs:Z,emitCrossFilters:F,coltypeMapping:S}){const{stack:D}=e,O=(0,r.useRef)(null);Z.echartRef=O;const R=(0,r.useRef)(),M=(0,r.useRef)(null),[H,I]=(0,r.useState)(0);(0,r.useEffect)((()=>{var e;const t=(null==(e=M.current)?void 0:e.offsetHeight)||0;I(t)}),[e.showExtraControls]);const T=(0,r.useCallback)((e=>{const t=Object.values(p);let n;n=t.includes(e)?t.filter((t=>t!==e)):[e];const r=n.map((e=>h[e]));return{dataMask:{extraFormData:{filters:0===n.length?[]:f.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)}}),[f,h,p]),N=(0,r.useCallback)((e=>{F&&m(T(e).dataMask)}),[F,m,T]),j={click:e=>{R.current&&clearTimeout(R.current),R.current=setTimeout((()=>{const{seriesName:t}=e;N(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:c}=t,d=[],f=[],g=t.event.event,p=[...t.name?[t.name]:[],...null!=(n=h[c])?n:[]];r&&V.type===l.we.Time&&d.push({col:V.label===a.W3?e.granularitySqla:V.label,grain:e.timeGrainSqla,op:"==",val:r[0],formattedVal:E(r[0])}),[...V.type===l.we.Category&&r?[V.label]:[],...e.groupby].forEach(((e,t)=>d.push({col:e,op:"==",val:p[t],formattedVal:String(p[t])}))),e.groupby.forEach(((t,n)=>{const r=h[c][n];f.push({col:t,op:"==",val:r,formattedVal:(0,i.mj)(p[n],{timeFormatter:(0,o.bt)(e.dateFormat),numberFormatter:(0,s.JB)(e.numberFormat),coltype:null==S?void 0:S[(0,u.Z)(t)]})})})),x(g.clientX,g.clientY,{drillToDetail:d,crossFilter:T(c),drillBy:{filters:f,groupbyFieldName:"groupby"}})}}},L={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(!D&&"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,g.tZ)(r.Fragment,null,(0,g.tZ)("div",{ref:M},(0,g.tZ)(v,{formData:e,setControlValue:C})),(0,g.tZ)(c.Z,{ref:O,refs:Z,height:t-H,width:n,echartOptions:d,eventHandlers:j,zrEventHandlers:L,selectedValues:p}))}},63475:(e,t,n)=>{n.d(t,{Z:()=>c});var r=n(67294),l=n(51995),a=n(31431),o=n(11965);const s=l.iK.div`
  height: ${({height:e})=>e};
  width: ${({width:e})=>e};
`;function u({width:e,height:t,echartOptions:n,eventHandlers:l,zrEventHandlers:u,selectedValues:c={},refs:i},d){const f=(0,r.useRef)(null);i&&(i.divRef=f);const h=(0,r.useRef)(),g=(0,r.useMemo)((()=>Object.keys(c)||[]),[c]),p=(0,r.useRef)([]);(0,r.useImperativeHandle)(d,(()=>({getEchartInstance:()=>h.current}))),(0,r.useEffect)((()=>{f.current&&(h.current||(h.current=(0,a.S1)(f.current)),Object.entries(l||{}).forEach((([e,t])=>{var n,r;null==(n=h.current)||n.off(e),null==(r=h.current)||r.on(e,t)})),Object.entries(u||{}).forEach((([e,t])=>{var n,r;null==(n=h.current)||n.getZr().off(e),null==(r=h.current)||r.getZr().on(e,t)})),h.current.setOption(n,!0))}),[n,l,u]),(0,r.useEffect)((()=>{h.current&&(h.current.dispatchAction({type:"downplay",dataIndex:p.current.filter((e=>!g.includes(e)))}),g.length&&h.current.dispatchAction({type:"highlight",dataIndex:g}),p.current=g)}),[g]);const m=(0,r.useCallback)((({width:e,height:t})=>{h.current&&h.current.resize({width:e,height:t})}),[]);return(0,r.useEffect)((()=>(m({width:e,height:t}),()=>{var e;return null==(e=h.current)?void 0:e.dispose()})),[]),(0,r.useLayoutEffect)((()=>{m({width:e,height:t})}),[e,t,m]),(0,o.tZ)(s,{ref:f,height:t,width:e})}const c=(0,r.forwardRef)(u)}}]);
//# sourceMappingURL=60b8655f562e4fee878a.chunk.js.map