"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[2197],{572197:(e,t,n)=>{n.r(t),n.d(t,{default:()=>h,extractTreePathInfo:()=>o});var r=n(667294),l=n(751115),a=n(767190),c=n(310581),s=n(263475),u=n(806915),i=n(135944);const o=e=>(null!=e?e:[]).map((e=>(null==e?void 0:e.name)||"")).filter((e=>""!==e));function h(e){const{height:t,width:n,echartOptions:h,setDataMask:d,labelMap:f,selectedValues:p,formData:g,onContextMenu:N,refs:m,emitCrossFilters:v,coltypeMapping:b}=e,{columns:w}=g,k=(0,r.useCallback)((e=>{const t=o(e),n=t.join(","),r=Object.values(p);let l;l=r.includes(n)?r.filter((e=>e!==n)):[n];const a=l.map((e=>f[e]));return{dataMask:{extraFormData:{filters:0!==l.length&&w?w.slice(0,t.length).map(((e,t)=>{const n=a.map((e=>e[t]));return null==n?{col:e,op:"IS NULL"}:{col:e,op:"IN",val:n}})):[]},filterState:{value:a.length?a:null,selectedValues:l.length?l:null}},isCurrentValueSelected:r.includes(n)}}),[w,f,p]),y=(0,r.useCallback)((e=>{v&&null!=w&&w.length&&d(k(e).dataMask)}),[v,d,k]),I={click:e=>{const{treePathInfo:t}=e;y(t)},contextmenu:async e=>{if(N){e.event.stop();const{data:t,treePathInfo:n}=e,{records:r}=t,s=o(e.treePathInfo),i=e.event.event,h=[],d=[];if(null!=w&&w.length){s.forEach(((e,t)=>h.push({col:w[t],op:"==",val:r[t],formattedVal:e})));const e=s[s.length-1];d.push({col:w[s.length-1],op:"==",val:e,formattedVal:(0,u.mj)(e,{timeFormatter:(0,l.bt)(g.dateFormat),numberFormatter:(0,a.JB)(g.numberFormat),coltype:null==b?void 0:b[(0,c.Z)(w[s.length-1])]})})}N(i.clientX,i.clientY,{drillToDetail:h,crossFilter:null!=w&&w.length?k(n):void 0,drillBy:{filters:d,groupbyFieldName:"columns"}})}}};return(0,i.tZ)(s.Z,{refs:m,height:t,width:n,echartOptions:h,eventHandlers:I,selectedValues:p})}},263475:(e,t,n)=>{n.d(t,{Z:()=>H});var r=n(667294),l=n(751995),a=n(768023),c=n(281615),s=n(967021),u=n(358062),i=n(781836),o=n(873463),h=n(216026),d=n(259048),f=n(15746),p=n(126947),g=n(302907),N=n(516049),m=n(541969),v=n(938198),b=n(548785),w=n(557494),k=n(570012),y=n(730322),I=n(655958),E=n(603174),C=n(731281),F=n(210680),O=n(347106),M=n(693450),V=n(499326),Z=n(617813),j=n(129167),x=n(787164),D=n(135944);const R=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},i){const o=(0,r.useRef)(null);u&&(u.divRef=o);const h=(0,r.useRef)(),d=(0,r.useMemo)((()=>Object.keys(s)||[]),[s]),f=(0,r.useRef)([]);(0,r.useImperativeHandle)(i,(()=>({getEchartInstance:()=>h.current}))),(0,r.useEffect)((()=>{o.current&&(h.current||(h.current=(0,c.S1)(o.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(a||{}).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,a]),(0,r.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,r.useCallback)((({width:e,height:t})=>{h.current&&h.current.resize({width:e,height:t})}),[]);return(0,r.useEffect)((()=>(p({width:e,height:t}),()=>{var e;return null==(e=h.current)?void 0:e.dispose()})),[]),(0,r.useLayoutEffect)((()=>{p({width:e,height:t})}),[e,t,p]),(0,D.tZ)(R,{ref:o,height:t,width:e})}(0,a.D)([k.N,s.N,u.N,i.N,o.N,h.N,d.N,f.N,p.N,g.N,N.N,m.N,v.N,b.N,w.N,y.N,I.N,E.N,C.N,F.N,O.N,M.N,V.N,Z.N,j.N,x.T]);const H=(0,r.forwardRef)(T)}}]);
//# sourceMappingURL=d7754049ff95956c0d7c.chunk.js.map