"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[570],{40570:(e,t,r)=>{r.r(t),r.d(t,{default:()=>d});var a=r(7349),n=r(32142),l=r(86444),s=r(96540),c=r(85867),u=r(51536),i=r(52425),o=r(71194),h=r(2445);function d({echartOptions:e,emitCrossFilters:t,groupby:r,height:d,labelMap:f,onContextMenu:p,refs:g,setDataMask:v,selectedValues:m,width:b,formData:w,coltypeMapping:y}){const k=(0,s.useCallback)(((e,t)=>{if(null!=e&&e.children)return;const{treePath:a}=(0,i.Rq)(t),n=a.join(","),l=Object.values(m);let s;s=l.includes(n)?l.filter((e=>e!==n)):[n];const c=s.map((e=>f[e]));return{dataMask:{extraFormData:{filters:0===s.length?[]:r.map(((e,t)=>{const r=c.map((e=>e[t]));return null==r?{col:e,op:"IS NULL"}:{col:e,op:"IN",val:r}}))},filterState:{value:c.length?c:null,selectedValues:s.length?s:null}},isCurrentValueSelected:l.includes(n)}}),[r,f,m]),E=(0,s.useCallback)(((e,a)=>{var n;if(!t||0===r.length)return;const l=null==(n=k(e,a))?void 0:n.dataMask;l&&v(l)}),[t,k,v]),I={click:e=>{const{data:t,treePathInfo:r}=e;E(t,r)},contextmenu:async e=>{if(p){e.event.stop();const{data:t,treePathInfo:s}=e,{treePath:c}=(0,i.Rq)(s);if(c.length>0){const i=e.event.event,h=[],d=[];c.forEach(((e,t)=>{const s="null"===e?u.mu:e;h.push({col:r[t],op:"==",val:s,formattedVal:e}),d.push({col:r[t],op:"==",val:s,formattedVal:(0,o.Wy)(s,{timeFormatter:(0,a.mo)(w.dateFormat),numberFormatter:(0,n.gV)(w.numberFormat),coltype:null==y?void 0:y[(0,l.A)(r[t])]})})})),p(i.clientX,i.clientY,{drillToDetail:h,crossFilter:r.length>0?k(t,s):void 0,drillBy:{filters:d,groupbyFieldName:"groupby"}})}}}};return(0,h.Y)(c.A,{refs:g,height:d,width:b,echartOptions:e,eventHandlers:I,selectedValues:m})}},85867:(e,t,r)=>{r.d(t,{A:()=>T});var a=r(96540),n=r(96453),l=r(3087),s=r(92351),c=r(42900),u=r(51719),i=r(74508),o=r(61030),h=r(45567),d=r(49714),f=r(11734),p=r(80491),g=r(25652),v=r(73900),m=r(32003),b=r(22329),w=r(31441),y=r(12458),k=r(39539),E=r(5553),I=r(45967),C=r(40830),F=r(45620),O=r(39838),V=r(42998),M=r(69380),R=r(25384),j=r(29022),x=r(28540),A=r(35278),D=r(2445);const H=n.I4.div`
  height: ${({height:e})=>e};
  width: ${({width:e})=>e};
`;function P({width:e,height:t,echartOptions:r,eventHandlers:n,zrEventHandlers:l,selectedValues:c={},refs:u},i){const o=(0,a.useRef)(null);u&&(u.divRef=o);const h=(0,a.useRef)(),d=(0,a.useMemo)((()=>Object.keys(c)||[]),[c]),f=(0,a.useRef)([]);(0,a.useImperativeHandle)(i,(()=>({getEchartInstance:()=>h.current}))),(0,a.useEffect)((()=>{o.current&&(h.current||(h.current=(0,s.Ts)(o.current)),Object.entries(n||{}).forEach((([e,t])=>{var r,a;null==(r=h.current)||r.off(e),null==(a=h.current)||a.on(e,t)})),Object.entries(l||{}).forEach((([e,t])=>{var r,a;null==(r=h.current)||r.getZr().off(e),null==(a=h.current)||a.getZr().on(e,t)})),h.current.setOption(r,!0))}),[r,n,l]),(0,a.useEffect)((()=>{h.current&&(h.current.dispatchAction({type:"downplay",dataIndex:f.current.filter((e=>!d.includes(e)))}),d.length&&h.current.dispatchAction({type:"highlight",dataIndex:d}),f.current=d)}),[d]);const p=(0,a.useCallback)((({width:e,height:t})=>{h.current&&h.current.resize({width:e,height:t})}),[]);return(0,a.useEffect)((()=>(p({width:e,height:t}),()=>{var e;return null==(e=h.current)?void 0:e.dispose()})),[]),(0,a.useLayoutEffect)((()=>{p({width:e,height:t})}),[e,t,p]),(0,D.Y)(H,{ref:o,height:t,width:e})}(0,l.Y)([k.a,c.a,u.a,i.a,o.a,h.a,d.a,f.a,p.a,g.a,v.a,m.a,b.a,w.a,y.a,E.a,I.a,C.a,F.a,O.a,V.a,M.a,R.a,j.a,x.a,A._]);const T=(0,a.forwardRef)(P)}}]);