"use strict";(self.webpackChunkfirebird=self.webpackChunkfirebird||[]).push([[8845],{8845:(Y,d,f)=>{f.r(d),f.d(d,{TGaxisPainter:()=>u});var m=f(467),l=f(6998),v=f(5680),P=f(9041),E=f(4468),M=f(9025),O=f(6714),T=f(6370),y=f(5983),X=f(3693);class u extends E.TB{convertTo(e){const i=this.getObject(),a=this.axisToSvg("x",i.fX1),s=this.axisToSvg("y",i.fY1),t=this.axisToSvg("x",i.fX2),_=this.axisToSvg("y",i.fY2);if("ndc"===e){const n=this.getPadPainter().getPadWidth(),r=this.getPadPainter().getPadHeight();i.fX1=a/n,i.fX2=t/n,i.fY1=(r-s)/r,i.fY2=(r-_)/r,this.use_ndc=!0}else if("frame"===e){const n=this.getFramePainter().getFrameRect();i.fX1=(a-n.x)/n.width,i.fX2=(t-n.x)/n.width,i.fY1=(s-n.y)/n.height,i.fY2=(_-n.y)/n.height,this.bind_frame=!0}}moveDrag(e,i){this.gaxis_x+=e,this.gaxis_y+=i,(0,P.bk)(this.getG(),this.gaxis_x,this.gaxis_y)}moveEnd(e){if(e)return;const i=this.getObject();let a,s;if(this.bind_frame){const t=this.getFramePainter().getFrameRect();a=(this.gaxis_x-t.x)/t.width,s=(this.gaxis_y-t.y)/t.height}else a=this.svgToAxis("x",this.gaxis_x,this.use_ndc),s=this.svgToAxis("y",this.gaxis_y,this.use_ndc);this.vertical?(i.fX1=i.fX2=a,this.reverse?(i.fY2=s+(i.fY2-i.fY1),i.fY1=s):(i.fY1=s+(i.fY1-i.fY2),i.fY2=s)):(this.reverse?(i.fX1=a+(i.fX1-i.fX2),i.fX2=a):(i.fX2=a+(i.fX2-i.fX1),i.fX1=a),i.fY1=i.fY2=s),this.submitAxisExec(`SetX1(${i.fX1});;SetX2(${i.fX2});;SetY1(${i.fY1});;SetY2(${i.fY2})`,!0)}redraw(){const e=this.getObject(),i=e.fWmin,a=e.fWmax;let s,t,_,n;if(this.bind_frame){const h=this.getFramePainter().getFrameRect();s=Math.round(h.x+e.fX1*h.width),_=Math.round(h.x+e.fX2*h.width),t=Math.round(h.y+e.fY1*h.height),n=Math.round(h.y+e.fY2*h.height)}else s=this.axisToSvg("x",e.fX1,this.use_ndc),t=this.axisToSvg("y",e.fY1,this.use_ndc),_=this.axisToSvg("x",e.fX2,this.use_ndc),n=this.axisToSvg("y",e.fY2,this.use_ndc);const r=_-s,c=t-n,g=Math.abs(r)<Math.abs(c);let o=g?c:r,x=!1;return o<0&&(x=!0,o=-o,g?n=t:s=_),this.configureAxis(g?"yaxis":"xaxis",i,a,i,a,g,[0,o],{time_scale:e.fChopt.indexOf("t")>=0,log:e.fChopt.indexOf("G")>=0?1:0,reverse:x,swap_side:x,axis_func:this.axis_func}),this.createG(),this.gaxis_x=s,this.gaxis_y=n,this.drawAxis(this.getG(),Math.abs(r),Math.abs(c),(0,P.bk)(this.gaxis_x,this.gaxis_y)||"").then(()=>((0,O.X2)(this),(0,T.wh)(this,T.Og),this))}fillContextMenuItems(e){e.addTAxisMenu(E.rb,this,this.getObject(),"")}checkFuncion(){var e=this;return(0,m.A)(function*(){const i=e.getObject();if(!i.fFunctionName)return void(e.axis_func=null);const a=e.getPadPainter()?.findInPrimitives(i.fFunctionName,l.clTF1);let s=Promise.resolve(a);if(!a){const t=(0,y.gZ)(),_=t?.findItem({name:i.fFunctionName,check_keys:!0});_&&(s=t.getObject({item:_}).then(n=>n?.obj?._typename===l.clTF1?n.obj:null))}return s.then(t=>{e.axis_func=t,t&&(0,X.Dx)(t)})})()}createFuncHandle(e,i,a,s){const t=function(r){return t.toGraph(r)};t._func=e,t._domain=[a,s],t._scale=i?(0,v.ZE)().base(i):(0,v.m4)(),t._scale.domain(t._domain).range([0,100]),t.eval=function(r){try{r=t._func.evalPar(r)}catch{r=0}return Number.isFinite(r)?r:0};const _=t.eval(a),n=t.eval(s);return _<n==a<s?(t._vmin=_,t._vk=1/(n-_)):_===n?(t._vmin=0,t._vk=1):(t._vmin=n,t._vk=1/(_-n)),t._range=[0,100],t.range=function(r){return r?(t._range=r,t):t._range},t.domain=function(){return t._domain},t.toGraph=function(r){const c=(t.eval(r)-t._vmin)*t._vk;return t._range[0]*(1-c)+t._range[1]*c},t.ticks=function(r){return t._scale.ticks(r)},t}static draw(e,i,a){return(0,m.A)(function*(){const s=new u(e,i,!1);return(0,M.ensureTCanvas)(s,!1).then(()=>(a&&s.convertTo(a),s.checkFuncion())).then(()=>s.redraw())})()}}}}]);