"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[7521],{67521:(e,t,r)=>{r.r(t),r.d(t,{default:()=>u}),r(67294);var n=r(51115),a=r(67190),l=r(10581),i=r(63475),c=r(6915),s=r(11965);function u({height:e,width:t,echartOptions:r,formData:u,onContextMenu:o,setDataMask:d,filterState:h,emitCrossFilters:f,refs:v,coltypeMapping:p}){const m=e=>{if(null==e||!e.name||null==e||!e.col)return;const{name:t,col:r}=e,n=Object.values((null==h?void 0:h.selectedValues)||{});let a;return a=n.includes(t)?n.filter((e=>e!==t)):[t],{dataMask:{extraFormData:{filters:a.length?[{col:r,op:"IN",val:a}]:[]},filterState:{value:a.length?a:null,selectedValues:a.length?a:null}},isCurrentValueSelected:n.includes(t)}},g={click:e=>{var t;if(!f||!d)return;e.event.stop();const n=r.series[0].data.find((t=>t.id===e.data.id)),a=null==(t=m(n))?void 0:t.dataMask;a&&d(a)},contextmenu:e=>{if(o){e.event.stop();const t=e.event.event,i=r.series[0].data,s="node"===e.dataType?(t=>{const r=t.find((t=>t.id===e.data.id));if(null!=r&&r.name)return[{col:r.col,op:"==",val:r.name,formattedVal:r.name}]})(i):(t=>{var r,n;const a=null==(r=t.find((t=>t.id===e.data.source)))?void 0:r.name,l=null==(n=t.find((t=>t.id===e.data.target)))?void 0:n.name;if(a&&l)return[{col:u.source,op:"==",val:a,formattedVal:a},{col:u.target,op:"==",val:l,formattedVal:l}]})(i),d=i.find((t=>t.id===e.data.id));o(t.clientX,t.clientY,{drillToDetail:s,crossFilter:m(d),drillBy:d&&{filters:[{col:d.col,op:"==",val:d.name,formattedVal:(0,c.mj)(d.name,{timeFormatter:(0,n.bt)(u.dateFormat),numberFormatter:(0,a.JB)(u.numberFormat),coltype:null==p?void 0:p[(0,l.Z)(d.col)]})}],groupbyFieldName:d.col===u.source?"source":"target"}})}}};return(0,s.tZ)(i.Z,{refs:v,height:e,width:t,echartOptions:r,eventHandlers:g})}},63475:(e,t,r)=>{r.d(t,{Z:()=>u});var n=r(67294),a=r(51995),l=r(31431),i=r(11965);const c=a.iK.div`
  height: ${({height:e})=>e};
  width: ${({width:e})=>e};
`;function s({width:e,height:t,echartOptions:r,eventHandlers:a,zrEventHandlers:s,selectedValues:u={},refs:o},d){const h=(0,n.useRef)(null);o&&(o.divRef=h);const f=(0,n.useRef)(),v=(0,n.useMemo)((()=>Object.keys(u)||[]),[u]),p=(0,n.useRef)([]);(0,n.useImperativeHandle)(d,(()=>({getEchartInstance:()=>f.current}))),(0,n.useEffect)((()=>{h.current&&(f.current||(f.current=(0,l.S1)(h.current)),Object.entries(a||{}).forEach((([e,t])=>{var r,n;null==(r=f.current)||r.off(e),null==(n=f.current)||n.on(e,t)})),Object.entries(s||{}).forEach((([e,t])=>{var r,n;null==(r=f.current)||r.getZr().off(e),null==(n=f.current)||n.getZr().on(e,t)})),f.current.setOption(r,!0))}),[r,a,s]),(0,n.useEffect)((()=>{f.current&&(f.current.dispatchAction({type:"downplay",dataIndex:p.current.filter((e=>!v.includes(e)))}),v.length&&f.current.dispatchAction({type:"highlight",dataIndex:v}),p.current=v)}),[v]);const m=(0,n.useCallback)((({width:e,height:t})=>{f.current&&f.current.resize({width:e,height:t})}),[]);return(0,n.useEffect)((()=>(m({width:e,height:t}),()=>{var e;return null==(e=f.current)?void 0:e.dispose()})),[]),(0,n.useLayoutEffect)((()=>{m({width:e,height:t})}),[e,t,m]),(0,i.tZ)(c,{ref:h,height:t,width:e})}const u=(0,n.forwardRef)(s)}}]);
//# sourceMappingURL=4c07cc771b7a0456279c.chunk.js.map