import t from"@babel/runtime/helpers/slicedToArray";import e from"@babel/runtime/helpers/objectWithoutProperties";import{useContext as o,useState as i,useRef as r,useEffect as l}from"react";import{makeStyles as n,Tooltip as a}from"@material-ui/core";import c from"@material-ui/icons/Straighten";import s from"../ChartWrapperContext.js";import{jsxs as u,jsx as f}from"react/jsx-runtime";var p=["left","width","top","bottom","right","labelOffset","offset","height","coll","onCustomizeScaleClick"],h=n((function(t){return{axis:function(t){return{position:"absolute",cursor:"pointer",width:t.width,left:t.left,bottom:t.bottom,height:t.height}},tooltip:{display:"flex",alignItems:"center",justifyContent:"space-between",minWidth:125,backgroundColor:t.palette.background.b9,color:t.palette.text.primary,fontSize:"12px",lineHeight:"16px",letterSpacing:"0.4px",borderRadius:"4px",padding:"4px",zIndex:1e4},tooltipIcon:{fontSize:16,color:t.palette.primary.text6}}})),m=function(n){var m,d,x=n.left,g=n.width,b=n.top,y=n.bottom,v=n.right,C=n.labelOffset,w=n.offset,B=n.height,E=n.coll,S=n.onCustomizeScaleClick,z=e(n,p),O=o(s).chart,W=i({}),k=t(W,2),j=k[0],I=k[1],M=r(),A=(null==O?void 0:O.inverted)?"yAxis"===E:"xAxis"===E,N=14+C,P=14+C,R=((null==z||null===(m=z.userOptions)||void 0===m?void 0:m.title)||{}).text,H=A?x-5:x-P,D=A?y-P:y-5,F=h({top:b,right:v,width:A?g+P:P,height:A?P:B+P,left:A?H:H+w,bottom:A?D-w:D}),G=null===(d=M.current)||void 0===d?void 0:d.getBoundingClientRect(),L=u("div",{className:F.tooltip,children:[f(c,{className:F.tooltipIcon})," Customize Scale"]}),T=function(){O[E].find((function(t){return t.userOptions.title.text===R})).update({lineColor:"#03BCD4",lineWidth:2,labels:{style:{color:"#ffffff"}},title:{style:{color:"#ffffff"}}})},X=function(){O[E].find((function(t){return t.userOptions.title.text===R})).update({lineColor:"#3B3B3B",lineWidth:1,labels:{style:{color:"#9E9E9E"}},title:{style:{color:"#9E9E9E"}}})};return l((function(){var t=O.axisGroup;t&&(t.element.style.cursor="pointer")}),[O]),f(a,{title:L,placement:A?"top":"right",onMouseMove:function(t){var e=t.pageX,o=t.pageY;I({x:e,y:o})},PopperProps:{anchorEl:{clientHeight:0,clientWidth:0,getBoundingClientRect:function(){return{top:A?G.y:j.y,left:A?j.x:G.x-N,right:A?j.x:G.x+N,bottom:A?G.y:j.y,width:0,height:0}}}},children:f("div",{className:F.axis,ref:M,onClick:function(){return S(z)},onMouseOver:T,onMouseLeave:X,onFocus:T,onBlur:X})})};export{m as default};
