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