"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[2197],{72197:(e,t,r)=>{r.r(t),r.d(t,{default:()=>h,extractTreePathInfo:()=>o});var n=r(67294),l=r(51115),a=r(67190),c=r(10581),s=r(63475),u=r(6915),i=r(11965);const o=e=>(null!=e?e:[]).map((e=>(null==e?void 0:e.name)||"")).filter((e=>""!==e));function h(e){const{height:t,width:r,echartOptions:h,setDataMask:d,labelMap:f,selectedValues:p,formData:g,onContextMenu:m,refs:v,emitCrossFilters:b,coltypeMapping:w}=e,{columns:k}=g,y=(0,n.useCallback)((e=>{const t=o(e),r=t.join(","),n=Object.values(p);let l;l=n.includes(r)?n.filter((e=>e!==r)):[r];const a=l.map((e=>f[e]));return{dataMask:{extraFormData:{filters:0!==l.length&&k?k.slice(0,t.length).map(((e,t)=>{const r=a.map((e=>e[t]));return null==r?{col:e,op:"IS NULL"}:{col:e,op:"IN",val:r}})):[]},filterState:{value:a.length?a:null,selectedValues:l.length?l:null}},isCurrentValueSelected:n.includes(r)}}),[k,f,p]),I=(0,n.useCallback)((e=>{b&&d(y(e).dataMask)}),[b,d,y]),E={click:e=>{const{treePathInfo:t}=e;I(t)},contextmenu:async e=>{if(m){e.event.stop();const{data:t,treePathInfo:r}=e,{records:n}=t,s=o(e.treePathInfo),i=e.event.event,h=[],d=[];if(null!=k&&k.length){s.forEach(((e,t)=>h.push({col:k[t],op:"==",val:n[t],formattedVal:e})));const e=s[s.length-1];d.push({col:k[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==w?void 0:w[(0,c.Z)(k[s.length-1])]})})}m(i.clientX,i.clientY,{drillToDetail:h,crossFilter:y(r),drillBy:{filters:d,groupbyFieldName:"columns"}})}}};return(0,i.tZ)(s.Z,{refs:v,height:t,width:r,echartOptions:h,eventHandlers:E,selectedValues:p})}},63475:(e,t,r)=>{r.d(t,{Z:()=>i});var n=r(67294),l=r(51995),a=r(31431),c=r(11965);const s=l.iK.div`
  height: ${({height:e})=>e};
  width: ${({width:e})=>e};
`;function u({width:e,height:t,echartOptions:r,eventHandlers:l,zrEventHandlers:u,selectedValues:i={},refs:o},h){const d=(0,n.useRef)(null);o&&(o.divRef=d);const f=(0,n.useRef)(),p=(0,n.useMemo)((()=>Object.keys(i)||[]),[i]),g=(0,n.useRef)([]);(0,n.useImperativeHandle)(h,(()=>({getEchartInstance:()=>f.current}))),(0,n.useEffect)((()=>{d.current&&(f.current||(f.current=(0,a.S1)(d.current)),Object.entries(l||{}).forEach((([e,t])=>{var r,n;null==(r=f.current)||r.off(e),null==(n=f.current)||n.on(e,t)})),Object.entries(u||{}).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,l,u]),(0,n.useEffect)((()=>{f.current&&(f.current.dispatchAction({type:"downplay",dataIndex:g.current.filter((e=>!p.includes(e)))}),p.length&&f.current.dispatchAction({type:"highlight",dataIndex:p}),g.current=p)}),[p]);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,c.tZ)(s,{ref:d,height:t,width:e})}const i=(0,n.forwardRef)(u)}}]);
//# sourceMappingURL=c7efb08bf60a001167c3.chunk.js.map