@yamcs/opi 1.4.0 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/opi.js
CHANGED
|
@@ -19,5 +19,5 @@ function tx(p){let t=document.createElement("canvas").getContext("2d");t.fillSty
|
|
|
19
19
|
`+i.formatTime(e,{hours:!0,minutes:!0,seconds:!0,milliseconds:!0});case 3:return i.formatTime(e,{hours:!0,minutes:!0,seconds:!0,milliseconds:!1});case 4:return i.formatTime(e,{hours:!0,minutes:!0,seconds:!0,milliseconds:!0});case 5:return i.formatTime(e,{hours:!0,minutes:!0,seconds:!1,milliseconds:!1});case 6:return i.formatDate(e,{year:!0,month:!0,day:!0});case 7:let r=this.formatter.utc,s=jx[r?e.getUTCMonth():e.getMonth()],o=r?e.getUTCDate():e.getDate();return`${s} ${o}`;case 8:let n=Math.abs(this.maximum-this.minimum);return n<=5e3?i.formatTime(e,{hours:!1,minutes:!1,seconds:!0,milliseconds:!0}):n<=18e5?i.formatTime(e,{hours:!0,minutes:!0,seconds:!0,milliseconds:!1}):n<=864e5?i.formatTime(e,{hours:!0,minutes:!0,seconds:!1,milliseconds:!1}):n<=6048e5?i.formatDate(e,{year:!1,month:!0,day:!0})+`
|
|
20
20
|
`+i.formatTime(e,{hours:!0,minutes:!0,seconds:!1,milliseconds:!1}):n<=2592e6?i.formatDate(e,{year:!1,month:!0,day:!0}):i.formatDate(e,{year:!0,month:!0,day:!0})}return""}get spaceBetweenMarkAndLabel(){return this.scale*2}get majorTickLength(){return this.scale*6}get minorTickLength(){return this.scale*3}get minorTickMarkStepHint(){return this.scale*4}get tickLabelGap(){return this.horizontal?this.scale*10:this.scale*2}};var Zx=100/255,Jx=20,Qx=11,ty=6,ey=5,iy=150,cl="color_hi",pl="color_hihi",dl="color_lo",ul="color_lolo",gl="color_fillbackground",ml="effect_3d",fl="fill_color",wl="font",xl="horizontal",yl="level_hi",Pl="level_hihi",bl="level_lo",vl="level_lolo",Rl="limits_from_pv",_l="log_scale",Tl="major_tick_step_hint",Sl="maximum",Ll="minimum",Cl="page_increment",Al="scale_font",Ol="scale_format",El="show_hi",Ml="show_hihi",Vl="show_lo",Il="show_lolo",Bl="show_markers",Hl="show_minor_ticks",Dl="show_scale",Wl="step_increment",kl="thumb_color",Nl="transparent_background",Fl="value_label_format",wr=class extends M{trackRegion;thumbRegion;grabStartValue;trackScale;pageTimeout;pageUp=!1;pagePressedValue=0;hoveringThumb=!1;draggingThumb=!1;constructor(t,e){super(t,e),this.properties.add(new S(cl,new m(255,128,0))),this.properties.add(new S(pl,new m(255,0,0))),this.properties.add(new S(dl,new m(255,128,0))),this.properties.add(new S(ul,new m(255,0,0))),this.properties.add(new S(gl,new m(200,200,200))),this.properties.add(new f(ml,!0)),this.properties.add(new S(fl,m.BLUE)),this.properties.add(new H(wl)),this.properties.add(new f(xl,!1)),this.properties.add(new C(yl)),this.properties.add(new C(Pl)),this.properties.add(new C(bl)),this.properties.add(new C(vl)),this.properties.add(new f(Rl,!0)),this.properties.add(new f(_l)),this.properties.add(new P(Tl,50)),this.properties.add(new C(Sl,100)),this.properties.add(new C(Ll,0)),this.properties.add(new C(Cl,10)),this.properties.add(new H(Al)),this.properties.add(new T(Ol)),this.properties.add(new f(El,!0)),this.properties.add(new f(Ml,!0)),this.properties.add(new f(Vl,!0)),this.properties.add(new f(Il,!0)),this.properties.add(new f(Bl,!0)),this.properties.add(new f(Hl,!0)),this.properties.add(new f(Dl,!0)),this.properties.add(new C(Wl,1)),this.properties.add(new S(kl,new m(172,172,172))),this.properties.add(new f(Nl)),this.properties.add(new T(Fl))}init(){this.trackRegion={id:`${this.wuid}-track`,mouseDown:t=>{if(!this.enabled||!this.trackScale)return;let e=this.getAncestorOffset(),i=this.horizontal?t.point.x-e.x:t.point.y-e.y;this.pagePressedValue=this.trackScale.getPositionValue(i),this.pageUp=this.pagePressedValue>this.getCoercedValue(),this.pageRepeatedly()},mouseUp:()=>this.stopPaging(),mouseOut:()=>this.stopPaging(),tooltip:()=>this.tooltip},this.thumbRegion={id:`${this.wuid}-thumb`,mouseEnter:()=>{this.hoveringThumb=!0,this.requestRepaint()},mouseOut:()=>{this.hoveringThumb=!1,this.requestRepaint()},mouseDown:()=>{this.enabled&&(this.grabStartValue=this.getCoercedValue(),this.draggingThumb=!0,this.requestRepaint())},mouseUp:()=>{this.draggingThumb=!1,this.requestRepaint()},grabEnd:()=>{this.draggingThumb=!1,this.requestRepaint()},grab:t=>{if(!this.enabled||this.grabStartValue===void 0||!this.trackScale)return;let e=this.trackScale.scaleLength;if(e<=0)return;let i=this.horizontal?t.dx:-t.dy,{min:r,max:s}=this,o;if(this.logScale){let a=e/(Math.log10(s)-Math.log10(r));o=this.grabStartValue*Math.pow(10,i/a)}else{let a=(s-r)*i/e;o=this.grabStartValue+a}let{stepIncrement:n}=this;if(n>0){let a=o-this.grabStartValue,h=n*Math.round(a/n);o=this.grabStartValue+h}this.setCoercedValue(o),this.requestRepaint()},cursor:"pointer",tooltip:()=>this.tooltip}}draw(t){let e=this.area;this.transparentBackground||t.fillRect({...e,color:this.backgroundColor}),this.horizontal?this.drawHorizontal(t,e):this.drawVertical(t,e),this.enabled||t.fillRect({...e,color:m.GRAY,opacity:Zx})}drawVertical(t,e){let i=new ot(this.display.formatter,this.scale,this.scaleFont,this.min,this.max,this.logScale,this.majorTickStepHint,this.foregroundColor,this.showMinorTicks,this.showScale);i.scaleFormat=this.scaleFormat;let r=e.x+e.width/2,s=this.thumbLength/2+this.gapBtwThumbScale;i.drawVertical(t,r+s,e.y,e.height,!0,!0),this.showMarkers&&this.drawVerticalMarkers(t,i,r-s);let o={x:r-this.trackBreadth/2,y:e.y+i.margin,width:this.trackBreadth,height:e.height-2*i.margin};this.trackScale=i,this.drawVerticalTrack(t,i,o)}drawVerticalMarkers(t,e,i){let{lolo:r,lo:s,hi:o,hihi:n}=this,a=U.ARIAL_9.scale(this.scale),h=0;this.showLoLo&&r!==void 0&&(h=Math.max(h,t.measureText("LOLO",a).width)),this.showLo&&s!==void 0&&(h=Math.max(h,t.measureText("LO",a).width)),this.showHi&&o!==void 0&&(h=Math.max(h,t.measureText("HI",a).width)),this.showHiHi&&n!==void 0&&(h=Math.max(h,t.measureText("HIHI",a).width));let l=this.markerTickLength+this.markerGap+h,c=i-l,d=(g,w,x)=>{let _=c+h+this.markerGap,L=Math.round(e.getValuePosition(g));t.strokePath({path:new R(_,L).lineTo(_+this.markerTickLength,L),color:w,lineWidth:this.markerTickLineWidth}),t.fillText({x:c,y:L,text:x,align:"left",baseline:"middle",color:w,font:a})};this.showLoLo&&r!==void 0&&d(r,this.colorLoLo,"LOLO"),this.showLo&&s!==void 0&&d(s,this.colorLo,"LO"),this.showHi&&o!==void 0&&d(o,this.colorHi,"HI"),this.showHiHi&&n!==void 0&&d(n,this.colorHiHi,"HIHI")}drawVerticalTrack(t,e,i){let{outlineWidth:r}=this;if(t.fillRect({...i,color:this.colorFillbackground}),this.effect3d){let h=t.createLinearGradient(i.x,0,i.x+i.width,0);h.addColorStop(0,m.WHITE.toString()),h.addColorStop(1,this.colorFillbackground.withAlpha(0).toString()),t.fillRect({...i,gradient:h});let l=D(i,r/2);t.strokeRect({...l,color:m.GRAY,lineWidth:r})}let s=e.getValuePosition(this.getCoercedValue()),o=D({...i,y:s,height:i.y+i.height-s},r);if(t.fillRect({...o,color:this.fillColor}),this.effect3d){let h=t.createLinearGradient(o.x,0,o.x+o.width,0);h.addColorStop(0,m.WHITE.toString()),h.addColorStop(1,this.fillColor.withAlpha(0).toString()),t.fillRect({...o,gradient:h})}t.addHitRegion(this.trackRegion).addRect(i.x,i.y,i.width,i.height);let a={x:i.x+i.width/2,y:s};this.drawThumb(t,a,!0),this.drawValueLabel(t,{x:a.x-this.thumbLength/2-this.markerGap,y:a.y},"right","middle")}drawHorizontal(t,e){let i=new ot(this.display.formatter,this.scale,this.scaleFont,this.min,this.max,this.logScale,this.majorTickStepHint,this.foregroundColor,this.showMinorTicks,this.showScale);i.scaleFormat=this.scaleFormat;let r=e.y+e.height/2,s=this.thumbLength/2+this.gapBtwThumbScale,o=i.measureHorizontalHeight(t);i.drawHorizontal(t,e.x,r+s+o,e.width),this.showMarkers&&this.drawHorizontalMarkers(t,i,r-s);let n={x:e.x+i.margin,y:r-this.trackBreadth/2,width:e.width-2*i.margin,height:this.trackBreadth};this.trackScale=i,this.drawHorizontalTrack(t,i,n)}drawHorizontalMarkers(t,e,i){let{lolo:r,lo:s,hi:o,hihi:n}=this,a=U.ARIAL_9.scale(this.scale),h=0;this.showLoLo&&r!==void 0&&(h=Math.max(h,t.measureText("LOLO",a).height)),this.showLo&&s!==void 0&&(h=Math.max(h,t.measureText("LO",a).height)),this.showHi&&o!==void 0&&(h=Math.max(h,t.measureText("HI",a).height)),this.showHiHi&&n!==void 0&&(h=Math.max(h,t.measureText("HIHI",a).height));let l=i-(this.markerTickLength+this.markerGap+h),c=(d,g,w)=>{let x=Math.round(e.getValuePosition(d)),_=l+h+this.markerGap;t.strokePath({path:new R(x,_).lineTo(x,_+this.markerTickLength),color:g,lineWidth:this.markerTickLineWidth}),t.fillText({x,y:l,text:w,align:"center",baseline:"top",color:g,font:a})};this.showLoLo&&r!==void 0&&c(r,this.colorLoLo,"LOLO"),this.showLo&&s!==void 0&&c(s,this.colorLo,"LO"),this.showHi&&o!==void 0&&c(o,this.colorHi,"HI"),this.showHiHi&&n!==void 0&&c(n,this.colorHiHi,"HIHI")}drawHorizontalTrack(t,e,i){let{outlineWidth:r}=this;if(t.fillRect({...i,color:this.colorFillbackground}),this.effect3d){let h=t.createLinearGradient(0,i.y,0,i.y+i.height);h.addColorStop(0,m.WHITE.toString()),h.addColorStop(1,this.colorFillbackground.withAlpha(0).toString()),t.fillRect({...i,gradient:h});let l=D(i,r/2);t.strokeRect({...l,color:m.GRAY,lineWidth:r})}let s=e.getValuePosition(this.getCoercedValue()),o=D({...i,width:s-i.x},r);if(t.fillRect({...o,color:this.fillColor}),this.effect3d){let h=t.createLinearGradient(0,o.y,0,o.y+o.height);h.addColorStop(0,m.WHITE.toString()),h.addColorStop(1,this.fillColor.withAlpha(0).toString()),t.fillRect({...o,gradient:h})}t.addHitRegion(this.trackRegion).addRect(i.x,i.y,i.width,i.height);let a={x:s,y:i.y+i.height/2};this.drawThumb(t,a,!1),this.drawValueLabel(t,{x:a.x,y:a.y-this.thumbLength/2-this.markerGap},"center","bottom")}drawThumb(t,e,i){let r=this.thumbLength,s=this.thumbBreadth,o;if(i){let h=e.x-r/2,l=e.y-s/2;o=[{x:h,y:l},{x:h,y:l+s},{x:h+r*4/5,y:l+s},{x:h+r,y:l+s/2},{x:h+r*4/5,y:l}]}else{let h=e.x-s/2,l=e.y-r/2;o=[{x:h,y:l},{x:h+s,y:l},{x:h+s,y:l+r*4/5},{x:h+s/2,y:l+r},{x:h,y:l+r*4/5}]}let n=R.fromPoints(o).closePath();if(this.effect3d){let h=o[0],l=o[3],c=t.createLinearGradient(h.x,h.y,l.x,l.y);c.addColorStop(0,m.WHITE.toString()),c.addColorStop(1,this.thumbColor.toString()),t.fillPath({path:n,gradient:c})}else t.fillPath({path:n,color:this.thumbColor});t.strokePath({path:n,color:m.GRAY,lineWidth:1*this.scale}),t.addHitRegion(this.thumbRegion).addPath(n)}drawValueLabel(t,e,i,r){this.value!==void 0&&(!this.hoveringThumb&&!this.draggingThumb||t.fillText({x:e.x,y:e.y,text:this.formatLabelValue(this.value),align:i,baseline:r,color:this.foregroundColor,font:this.font}))}pageRepeatedly(){window.clearTimeout(this.pageTimeout);let t=this.getCoercedValue();(this.pageUp?t>=this.pagePressedValue:t<=this.pagePressedValue)||(this.setCoercedValue(t+(this.pageUp?this.pageIncrement:-this.pageIncrement)),this.requestRepaint(),this.pageTimeout=window.setTimeout(()=>this.pageRepeatedly(),iy))}stopPaging(){window.clearTimeout(this.pageTimeout)}getAncestorOffset(){let t=0,e=0,i=this.parent;for(;i;)t+=i.x,e+=i.y,i=i.parent;return{x:t,y:e}}setCoercedValue(t){let{min:e,max:i}=this;t=Math.min(i,Math.max(e,t)),this.pv&&this.pv.writable?this.display.pvEngine.setValue(new Date,this.pv.name,t):this.pv||(this.value=t)}getCoercedValue(){let{min:t,max:e}=this,i=this.value??(t+e)/2;return Math.min(e,Math.max(t,i))}formatLabelValue(t){if(this.valueLabelFormat)return new it(this.valueLabelFormat).format(t);{let e=Kt(this.min,this.max);return new it(e).format(t)}}destroy(){window.clearTimeout(this.pageTimeout)}get min(){return this.limitsFromPv?this.pv?.lowerDisplayLimit??this.minimum:this.minimum}get max(){return this.limitsFromPv?this.pv?.upperDisplayLimit??this.maximum:this.maximum}get lolo(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.lowerAlarmLimit:this.levelLoLo}get lo(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.lowerWarningLimit:this.levelLo}get hi(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.upperWarningLimit:this.levelHi}get hihi(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.upperAlarmLimit:this.levelHiHi}get markerTickLength(){return this.scale*10}get markerTickLineWidth(){return this.scale*2}get markerGap(){return this.scale*3}get outlineWidth(){return this.scale*1}get trackBreadth(){return this.scale*ty}get thumbLength(){return this.scale*Jx}get thumbBreadth(){return this.scale*Qx}get gapBtwThumbScale(){return this.scale*ey}get colorHi(){return this.properties.getValue(cl)}get colorHiHi(){return this.properties.getValue(pl)}get colorLo(){return this.properties.getValue(dl)}get colorLoLo(){return this.properties.getValue(ul)}get colorFillbackground(){return this.properties.getValue(gl)}get effect3d(){return this.properties.getValue(ml)}get fillColor(){return this.properties.getValue(fl)}get font(){return this.properties.getValue(wl).scale(this.scale)}get horizontal(){return this.properties.getValue(xl)}get levelHi(){return this.properties.getValue(yl)}get levelHiHi(){return this.properties.getValue(Pl)}get levelLo(){return this.properties.getValue(bl)}get levelLoLo(){return this.properties.getValue(vl)}get limitsFromPv(){return this.properties.getValue(Rl)}get logScale(){return this.properties.getValue(_l)}get majorTickStepHint(){return this.scale*this.properties.getValue(Tl)}get maximum(){return this.properties.getValue(Sl)}get minimum(){return this.properties.getValue(Ll)}get pageIncrement(){return this.properties.getValue(Cl)}get scaleFont(){return this.properties.getValue(Al).scale(this.scale)}get scaleFormat(){return this.properties.getValue(Ol)}get showHi(){return this.properties.getValue(El)}get showHiHi(){return this.properties.getValue(Ml)}get showLo(){return this.properties.getValue(Vl)}get showLoLo(){return this.properties.getValue(Il)}get showMarkers(){return this.properties.getValue(Bl)}get showMinorTicks(){return this.properties.getValue(Hl)}get showScale(){return this.properties.getValue(Dl)}get stepIncrement(){return this.properties.getValue(Wl)}get thumbColor(){return this.properties.getValue(kl)}get transparentBackground(){return this.properties.getValue(Nl)}get valueLabelFormat(){return this.properties.getValue(Fl)}};var Gl="enabled",$l="font",Ul="maximum",Yl="minimum",zl="horizontal",Xl="step_increment",ql="page_increment",Kl="bar_length",jl="show_value_tip",Zl=new m(243,243,243),Oe=new m(232,232,231),xr=150,yr=class extends M{decreaseRegion;decreasePressed=!1;increaseRegion;increasePressed=!1;pageDecreaseRegion;pageDecreasePressed=!1;pageIncreaseRegion;pageIncreasePressed=!1;thumbRegion;grabStartValue;dragRange;actionTimeout;constructor(t,e){super(t,e),this.properties.add(new f(Gl)),this.properties.add(new f(zl)),this.properties.add(new f(jl)),this.properties.add(new H($l)),this.properties.add(new C(Ul)),this.properties.add(new C(Yl)),this.properties.add(new C(Xl)),this.properties.add(new C(ql)),this.properties.add(new C(Kl))}init(){this.decreaseRegion={id:`${this.wuid}-decrease`,mouseDown:()=>{this.decreasePressed=!0,this.stepDecreaseRepeatedly()},mouseUp:()=>{window.clearTimeout(this.actionTimeout),this.decreasePressed=!1,this.requestRepaint()},mouseOut:()=>{window.clearTimeout(this.actionTimeout),this.decreasePressed=!1,this.requestRepaint()},tooltip:()=>this.tooltip},this.increaseRegion={id:`${this.wuid}-increase`,mouseDown:()=>{this.increasePressed=!0,this.stepIncreaseRepeatedly()},mouseUp:()=>{window.clearTimeout(this.actionTimeout),this.increasePressed=!1,this.requestRepaint()},mouseOut:()=>{window.clearTimeout(this.actionTimeout),this.increasePressed=!1,this.requestRepaint()},tooltip:()=>this.tooltip},this.thumbRegion={id:`${this.wuid}-thumb`,mouseDown:()=>{this.grabStartValue=this.getCoercedValue()},grab:t=>{let e=this.horizontal?t.dx:t.dy,i=(this.maximum-this.minimum)*e/this.dragRange;this.setCoercedValue(this.grabStartValue+i),this.requestRepaint()},tooltip:()=>this.tooltip},this.pageDecreaseRegion={id:`${this.wuid}-page-decrease`,mouseDown:()=>{this.pageDecreasePressed=!0,this.pageDecreaseRepeatedly()},mouseUp:()=>{window.clearTimeout(this.actionTimeout),this.pageDecreasePressed=!1,this.requestRepaint()},mouseOut:()=>{window.clearTimeout(this.actionTimeout),this.pageDecreasePressed=!1,this.requestRepaint()},tooltip:()=>this.tooltip},this.pageIncreaseRegion={id:`${this.wuid}-page-increase`,mouseDown:()=>{this.pageIncreasePressed=!0,this.pageIncreaseRepeatedly()},mouseUp:()=>{window.clearTimeout(this.actionTimeout),this.pageIncreasePressed=!1,this.requestRepaint()},mouseOut:()=>{window.clearTimeout(this.actionTimeout),this.pageIncreasePressed=!1,this.requestRepaint()},tooltip:()=>this.tooltip}}draw(t){this.horizontal?this.drawHorizontal(t):this.drawVertical(t)}drawHorizontal(t){let{scale:e}=this,i=D(this.bounds,2*e);t.fillRect({...i,color:Zl});let r=Math.min(i.height,i.width/2);this.drawLeftButton(t,{x:i.x,y:i.y,width:r,height:i.height}),this.drawRightButton(t,{x:i.x+i.width-r,y:i.y,width:r,height:i.height});let s=this.barLength,o=this.maximum+s,n=this.minimum,a=o-n,h=a-s,l=i.width-r-r,c=Math.floor(Math.max(6*e,l*s/a));this.dragRange=l-c;let d=this.getCoercedValue(),g=Math.floor((l-c)*(d-n)/h),w=l-g-c,x={x:i.x+r+g,y:i.y,width:c,height:i.height};t.fillRect({...x,color:Oe}),this.drawRaisedButtonBorder(t,x),t.addHitRegion(this.thumbRegion).addRect(x.x,x.y,x.width,x.height);let L={x:i.x+r,y:i.y,width:g,height:i.height};t.addHitRegion(this.pageDecreaseRegion).addRect(L.x,L.y,L.width,L.height),this.pageDecreasePressed&&t.fillRect({...L,color:m.BLACK});let E={x:i.x+r+g+c,y:i.y,width:w,height:i.height};t.addHitRegion(this.pageIncreaseRegion).addRect(E.x,E.y,E.width,E.height),this.pageIncreasePressed&&t.fillRect({...E,color:m.BLACK})}drawVertical(t){let{scale:e}=this,i=D(this.bounds,e);t.fillRect({...i,color:Zl});let r=Math.min(i.width,i.height/2);this.drawUpButton(t,{x:i.x,y:i.y,width:i.width,height:r}),this.drawDownButton(t,{x:i.x,y:i.y+i.height-r,width:i.width,height:r});let s=this.barLength,o=this.maximum+s,n=this.minimum,a=o-n,h=a-s,l=i.height-r-r,c=Math.floor(Math.max(6*e,l*s/a));this.dragRange=l-c;let d=this.getCoercedValue(),g=Math.floor((l-c)*(d-n)/h),w=l-g-c,x={x:i.x,y:i.y+r+g,width:i.width,height:c};t.fillRect({...x,color:Oe}),this.drawRaisedButtonBorder(t,x),t.addHitRegion(this.thumbRegion).addRect(x.x,x.y,x.width,x.height);let L={x:i.x,y:i.y+r,width:i.width,height:g};t.addHitRegion(this.pageDecreaseRegion).addRect(L.x,L.y,L.width,L.height),this.pageDecreasePressed&&t.fillRect({...L,color:m.BLACK});let E={x:i.x,y:i.y+r+g+c,width:i.width,height:w};t.addHitRegion(this.pageIncreaseRegion).addRect(E.x,E.y,E.width,E.height),this.pageIncreasePressed&&t.fillRect({...E,color:m.BLACK})}drawLeftButton(t,e){t.fillRect({...e,color:Oe}),this.decreasePressed?this.drawPressedButtonBorder(t,e):this.drawRaisedButtonBorder(t,e),t.addHitRegion(this.decreaseRegion).addRect(e.x,e.y,e.width,e.height);let r=D(e,3*this.scale),s=Math.min(r.height/2,r.width);r.x+=(r.width-s)/2,s=Math.max(s,1);let o={x:r.x,y:r.y+r.height/2};t.fillPath({color:m.BLACK,path:new R(o.x,o.y).lineTo(o.x+s,o.y-s).lineTo(o.x+s,o.y+s).closePath()})}drawRightButton(t,e){t.fillRect({...e,color:Oe}),this.increasePressed?this.drawPressedButtonBorder(t,e):this.drawRaisedButtonBorder(t,e),t.addHitRegion(this.increaseRegion).addRect(e.x,e.y,e.width,e.height);let r=D(e,3*this.scale),s=Math.min(r.height/2,r.width);r.x+=(r.width-s)/2,s=Math.max(s,1);let o={x:r.x+s,y:r.y+r.height/2};t.fillPath({color:m.BLACK,path:new R(o.x,o.y).lineTo(o.x-s,o.y-s).lineTo(o.x-s,o.y+s).closePath()})}drawUpButton(t,e){t.fillRect({...e,color:Oe}),this.decreasePressed?this.drawPressedButtonBorder(t,e):this.drawRaisedButtonBorder(t,e),t.addHitRegion(this.decreaseRegion).addRect(e.x,e.y,e.width,e.height);let r=D(e,3*this.scale),s=Math.min(r.height,r.width/2);r.y+=(r.height-s)/2,s=Math.max(s,1);let o={x:r.x+r.width/2,y:r.y};t.fillPath({color:m.BLACK,path:new R(o.x,o.y).lineTo(o.x-s,o.y+s).lineTo(o.x+s,o.y+s).closePath()})}drawDownButton(t,e){t.fillRect({...e,color:Oe}),this.increasePressed?this.drawPressedButtonBorder(t,e):this.drawRaisedButtonBorder(t,e),t.addHitRegion(this.increaseRegion).addRect(e.x,e.y,e.width,e.height);let r=D(e,3*this.scale),s=Math.min(r.height,r.width/2);r.y+=(r.height-s)/2,s=Math.max(s,1);let o={x:r.x+r.width/2,y:r.y+s};t.fillPath({color:m.BLACK,path:new R(o.x,o.y).lineTo(o.x-s,o.y-s).lineTo(o.x+s,o.y-s).closePath()})}drawRaisedButtonBorder(t,e){this.drawButtonBorder(t,e,m.BUTTON_DARKEST,m.BUTTON_DARKER,m.BUTTON,m.BUTTON_LIGHTEST)}drawPressedButtonBorder(t,e){this.drawButtonBorder(t,e,m.BUTTON_LIGHTEST,m.BUTTON_LIGHTEST,m.BUTTON_DARKEST,m.BUTTON_DARKER)}drawButtonBorder(t,e,i,r,s,o){let n=1*this.scale,a=e.y+n/2,h=e.x+n/2,l=e.y+e.height-n+n/2,c=e.x+e.width-n+n/2;t.strokePath({color:i,path:new R(c,l).lineTo(c,a).moveTo(c,l).lineTo(h,l)}),t.strokePath({color:r,path:new R(c-n,l-n).lineTo(c-n,a+n).moveTo(c-n,l-n).lineTo(h+n,l-n)}),t.strokePath({color:s,path:new R(h,a).lineTo(c-n,a).moveTo(h,a).lineTo(h,l-n)}),t.strokePath({color:o,path:new R(h+n,a+n).lineTo(c-n-n,a+n).moveTo(h+n,a+n).lineTo(h+n,l-n-n)})}stepIncreaseRepeatedly(){window.clearTimeout(this.actionTimeout),this.stepIncrease(),this.requestRepaint(),this.actionTimeout=window.setTimeout(()=>this.stepIncreaseRepeatedly(),xr)}stepDecreaseRepeatedly(){window.clearTimeout(this.actionTimeout),this.stepDecrease(),this.requestRepaint(),this.actionTimeout=window.setTimeout(()=>this.stepDecreaseRepeatedly(),xr)}stepIncrease(){let t=this.value??(this.maximum-this.minimum)/2;this.setCoercedValue(t+this.stepIncrement)}stepDecrease(){let t=this.value??(this.maximum-this.minimum)/2;this.setCoercedValue(t-this.stepIncrement)}pageIncreaseRepeatedly(){window.clearTimeout(this.actionTimeout),this.pageIncrease(),this.requestRepaint(),this.actionTimeout=window.setTimeout(()=>this.pageIncreaseRepeatedly(),xr)}pageDecreaseRepeatedly(){window.clearTimeout(this.actionTimeout),this.pageDecrease(),this.requestRepaint(),this.actionTimeout=window.setTimeout(()=>this.pageDecreaseRepeatedly(),xr)}pageIncrease(){let t=this.value??(this.maximum-this.minimum)/2;this.setCoercedValue(t+this.pageIncrement)}pageDecrease(){let t=this.value??(this.maximum-this.minimum)/2;this.setCoercedValue(t-this.pageIncrement)}setCoercedValue(t){this.pv&&this.pv.writable&&(t=t<this.minimum?this.minimum:t>this.maximum?this.maximum:t,this.display.pvEngine.setValue(new Date,this.pv.name,t))}getCoercedValue(){let t=this.value??(this.maximum-this.minimum)/2;return t<this.minimum?this.minimum:t>this.maximum?this.maximum:t}destroy(){window.clearTimeout(this.actionTimeout)}get enabled(){return this.properties.getValue(Gl)}get horizontal(){return this.properties.getValue(zl)}get showValueTip(){return this.properties.getValue(jl)}get font(){return this.properties.getValue($l).scale(this.scale)}get minimum(){return this.properties.getValue(Yl)}get maximum(){return this.properties.getValue(Ul)}get stepIncrement(){return this.properties.getValue(Xl)}get pageIncrement(){return this.properties.getValue(ql)}get barLength(){return this.properties.getValue(Kl)}};var Jl="minimum",Ql="maximum",tc="step_increment",ec="page_increment",ic="limits_from_pv",rc="format",sc="precision",oc="precision_from_pv",nc="buttons_on_left",ac="horizontal_buttons_layout",hc="show_text",lc="font",cc="horizontal_alignment",pc="vertical_alignment",ry=100/255,sy=20,oy=250,ny=40,Pr=class extends M{upRegion;upPressed=!1;downRegion;downPressed=!1;areaRegion;repeatTimeout;editing=!1;inputEl;scratchCanvas;scratchCtx;constructor(t,e){super(t,e),this.properties.add(new C(Jl,-Number.MAX_VALUE)),this.properties.add(new C(Ql,Number.MAX_VALUE)),this.properties.add(new C(tc,1)),this.properties.add(new C(ec,10)),this.properties.add(new f(ic,!0)),this.properties.add(new P(rc,0)),this.properties.add(new P(sc,3)),this.properties.add(new f(oc,!1)),this.properties.add(new f(nc,!1)),this.properties.add(new f(ac,!1)),this.properties.add(new f(hc,!0)),this.properties.add(new H(lc)),this.properties.add(new P(cc,1)),this.properties.add(new P(pc,1))}init(){this.upRegion={id:`${this.wuid}-up`,mouseDown:()=>{this.upPressed=!0,this.stepRepeatedly(1,!0)},mouseUp:()=>this.stopRepeating("up"),mouseOut:()=>this.stopRepeating("up"),tooltip:()=>this.tooltip},this.downRegion={id:`${this.wuid}-down`,mouseDown:()=>{this.downPressed=!0,this.stepRepeatedly(-1,!0)},mouseUp:()=>this.stopRepeating("down"),mouseOut:()=>this.stopRepeating("down"),tooltip:()=>this.tooltip},this.areaRegion={id:`${this.wuid}-area`,click:()=>this.startEditing(),tooltip:()=>this.tooltip,cursor:"text"},this.inputEl=document.createElement("input"),this.inputEl.style.display="none",this.inputEl.autocomplete="off",this.inputEl.addEventListener("keyup",t=>{t.key==="Enter"?this.commitEditing():t.key==="Escape"&&this.cancelEditing()}),this.inputEl.addEventListener("blur",()=>this.cancelEditing()),this.display.rootPanel.appendChild(this.inputEl),this.scratchCanvas=document.createElement("canvas"),this.scratchCtx=this.scratchCanvas.getContext("2d")}stopRepeating(t){window.clearTimeout(this.repeatTimeout),t==="up"?this.upPressed=!1:this.downPressed=!1,this.requestRepaint()}stepRepeatedly(t,e){window.clearTimeout(this.repeatTimeout),this.step(t),this.requestRepaint(),this.repeatTimeout=window.setTimeout(()=>this.stepRepeatedly(t,!1),e?oy:ny)}step(t){let e=this.currentNumericValue(),i=this.clamp(e+t*this.stepIncrement);i!==e&&(this.pv&&this.pv.writable?this.display.pvEngine.setValue(new Date,this.pv.name,i):this.pv||(this.value=i))}currentNumericValue(){let t=Number(this.value);return isNaN(t)?0:t}clamp(t){let{minimum:e,maximum:i}=this;return t<e?e:t>i?i:t}startEditing(){if(this.pv&&!this.pv.writable)return;let{labelBounds:t}=this.computeLayout();if(!t)return;this.editing=!0;let e=this.display.measureAbsoluteArea(this),i={x:e.x+(t.x-this.area.x),y:e.y+(t.y-this.area.y),width:t.width,height:t.height};this.inputEl.value=this.formatSpinnerValue(this.currentNumericValue()),this.inputEl.style.display="block",this.inputEl.style.position="absolute",this.inputEl.style.boxSizing="border-box",this.inputEl.style.left=`${i.x}px`,this.inputEl.style.top=`${i.y}px`,this.inputEl.style.width=`${i.width}px`,this.inputEl.style.height=`${i.height}px`,this.inputEl.focus(),this.inputEl.select(),this.requestRepaint()}commitEditing(){let t=this.inputEl.value;this.cancelEditing();let e=Number(t);if(isNaN(e))return;let i=this.clamp(e);this.pv&&this.pv.writable?this.display.pvEngine.setValue(new Date,this.pv.name,i):this.pv||(this.value=i)}cancelEditing(){this.inputEl.style.display="none",this.editing=!1,this.requestRepaint()}draw(t){this.backgroundAlarmSensitive&&this.alarm?t.fillRect({...this.area,color:this.alarmSensitiveBackgroundColor}):this.transparent||t.fillRect({...this.area,color:this.backgroundColor});let{labelBounds:e,upBounds:i,downBounds:r}=this.computeLayout();e&&!this.editing&&(t.addHitRegion(this.areaRegion).addRect(e.x,e.y,e.width,e.height),this.drawLabel(t,e)),this.drawUpButton(t,i),this.drawDownButton(t,r),this.enabled||t.fillRect({...this.area,color:m.GRAY,opacity:ry})}computeLayout(){let t=sy*this.scale,e=1*this.scale,i=this.area,r,s,o;if(this.showText)if(this.buttonsOnLeft)if(this.horizontalButtonsLayout)r={x:i.x+e+2*t,y:i.y,width:i.width-2*t-e,height:i.height},s={x:i.x,y:i.y,width:t,height:i.height},o={x:i.x+t,y:i.y,width:t,height:i.height};else{r={x:i.x+e+t,y:i.y,width:i.width-t-e,height:i.height};let n=Math.floor(i.height/2);s={x:i.x,y:i.y,width:t,height:n},o={x:i.x,y:i.y+n,width:t,height:n}}else if(this.horizontalButtonsLayout)r={x:i.x,y:i.y,width:i.width-2*t,height:i.height},s={x:i.x+i.width-2*t,y:i.y,width:t,height:i.height},o={x:i.x+i.width-t,y:i.y,width:t,height:i.height};else{r={x:i.x,y:i.y,width:i.width-t,height:i.height};let n=Math.floor(i.height/2);s={x:i.x+i.width-t,y:i.y,width:t,height:n},o={x:i.x+i.width-t,y:i.y+n,width:t,height:n}}else if(this.horizontalButtonsLayout){let n=Math.floor(i.width/2);s={x:i.x,y:i.y,width:n,height:i.height},o={x:i.x+n,y:i.y,width:n,height:i.height}}else{let n=Math.floor(i.height/2);s={x:i.x,y:i.y,width:i.width,height:n},o={x:i.x,y:i.y+n,width:i.width,height:n}}return{labelBounds:r,upBounds:s,downBounds:o}}drawLabel(t,e){let{pixelRatio:i}=t,r=me(t.ctx,e.x,e.y),s=Math.max(1,Math.ceil(e.width+r.subPixelX)),o=Math.max(1,Math.ceil(e.height+r.subPixelY));this.scratchCanvas.width=Math.ceil(s*i),this.scratchCanvas.height=Math.ceil(o*i);let n=this.scratchCtx;n.clearRect(0,0,this.scratchCanvas.width,this.scratchCanvas.height),n.setTransform(i,0,0,i,0,0),n.translate(r.subPixelX,r.subPixelY),n.fillStyle=this.alarmSensitiveForegroundColor.toString(),n.font=this.font.getFontString();let a=e.x;this.horizAlignment===0?n.textAlign="start":this.horizAlignment===1?(a+=e.width/2,n.textAlign="center"):(a+=e.width,n.textAlign="end");let h=e.y;this.vertAlignment===0?n.textBaseline="top":this.vertAlignment===1?(h+=e.height/2,n.textBaseline="middle"):(h+=e.height,n.textBaseline="bottom");let l=this.formatSpinnerValue(this.currentNumericValue());n.fillText(l,a-e.x,h-e.y),t.ctx.drawImage(this.scratchCanvas,r.x,r.y,s,o)}formatSpinnerValue(t){let e=this.precisionFromPV&&this.pv&&this.pv.precision>=0?this.pv.precision:this.precision;switch(this.format){case 1:return t.toExponential(e).toUpperCase().replace("E+","E");case 2:return"0x"+Math.trunc(t).toString(16);default:{let i={minimumFractionDigits:0,maximumFractionDigits:e,useGrouping:!1,roundingMode:"halfEven"};return new Intl.NumberFormat("en-US",i).format(t)}}}drawUpButton(t,e){t.fillRect({...e,color:m.BUTTON}),this.drawSpinnerButtonBorder(t,e,this.upPressed),t.addHitRegion(this.upRegion).addRect(e.x,e.y,e.width,e.height);let r=D(e,3*this.scale),s=Math.min(r.height,r.width/2);r.y+=(r.height-s)/2,s=Math.max(s,1);let o={x:r.x+r.width/2,y:r.y};t.fillPath({color:m.BLACK,path:new R(o.x,o.y).lineTo(o.x-s,o.y+s).lineTo(o.x+s,o.y+s).closePath()})}drawDownButton(t,e){t.fillRect({...e,color:m.BUTTON}),this.drawSpinnerButtonBorder(t,e,this.downPressed),t.addHitRegion(this.downRegion).addRect(e.x,e.y,e.width,e.height);let r=D(e,3*this.scale),s=Math.min(r.height,r.width/2);r.y+=(r.height-s)/2,s=Math.max(s,1);let o={x:r.x+r.width/2,y:r.y+s};t.fillPath({color:m.BLACK,path:new R(o.x,o.y).lineTo(o.x-s,o.y-s).lineTo(o.x+s,o.y-s).closePath()})}drawSpinnerButtonBorder(t,e,i){let r=1*this.scale,s=e.y+r/2,o=e.x+r/2,n=e.y+e.height-r/2,a=e.x+e.width-r/2,h=i?m.BUTTON_DARKEST:m.BUTTON_LIGHTEST,l=i?m.BUTTON_LIGHTEST:m.BUTTON_DARKEST;t.strokePath({color:h,lineWidth:r,path:new R(o,n).lineTo(o,s).lineTo(a,s)}),t.strokePath({color:l,lineWidth:r,path:new R(a,s).lineTo(a,n).lineTo(o,n)})}destroy(){window.clearTimeout(this.repeatTimeout),this.inputEl&&(this.display.rootPanel.removeChild(this.inputEl),this.inputEl=void 0),this.scratchCanvas=void 0,this.scratchCtx=void 0}get minimum(){return this.limitsFromPV&&this.pv?.lowerDisplayLimit!==void 0?this.pv.lowerDisplayLimit:this.properties.getValue(Jl)}get maximum(){return this.limitsFromPV&&this.pv?.upperDisplayLimit!==void 0?this.pv.upperDisplayLimit:this.properties.getValue(Ql)}get stepIncrement(){return this.properties.getValue(tc)}get pageIncrement(){return this.properties.getValue(ec)}get limitsFromPV(){return this.properties.getValue(ic)}get format(){return this.properties.getValue(rc)}get precision(){return this.properties.getValue(sc)}get precisionFromPV(){return this.properties.getValue(oc)}get buttonsOnLeft(){return this.properties.getValue(nc)}get horizontalButtonsLayout(){return this.properties.getValue(ac)}get showText(){return this.properties.getValue(hc)}get font(){return this.properties.getValue(lc).scale(this.scale)}get horizAlignment(){return this.properties.getValue(cc)}get vertAlignment(){return this.properties.getValue(pc)}};var dc="auto_size",uc="confirm_message",Is="font",gc="format_type",mc="horizontal_alignment",fc="limits_from_pv",wc="maximum",xc="minimum",yc="multiline_input",Pc="password_input",bc="precision",vc="precision_from_pv",Rc="read_only",_c="rotation_angle",Tc="show_h_scroll",Sc="show_lohi",Lc="show_native_border",Cc="show_units",Ac="show_v_scroll",Oc="style",Ec="vertical_alignment",Mc="wrap_words",ay=0,Bs=1,br=class extends M{areaRegion;inputEl;editing=!1;scratchCanvas;scratchCtx;constructor(t,e){super(t,e),this.properties.add(new f(dc)),this.properties.add(new T(uc)),this.properties.add(new H(Is)),this.properties.add(new P(gc)),this.properties.add(new P(mc)),this.properties.add(new f(fc,!1)),this.properties.add(new C(wc,Number.MAX_VALUE)),this.properties.add(new C(xc,-Number.MAX_VALUE)),this.properties.add(new f(yc)),this.properties.add(new f(Pc,!1)),this.properties.add(new P(bc)),this.properties.add(new f(vc)),this.properties.add(new f(Rc,!1)),this.properties.add(new C(_c)),this.properties.add(new f(Tc,!1)),this.properties.add(new f(Sc,!0)),this.properties.add(new f(Lc,!0)),this.properties.add(new f(Cc,!0)),this.properties.add(new f(Ac,!1)),this.properties.add(new P(Oc,ay)),this.properties.add(new P(Ec,1)),this.properties.add(new f(Mc,!1))}init(){this.text&&(this.value=this.text),this.areaRegion={id:`${this.wuid}-area`,click:()=>{if(this.pv&&!this.pv.writable)return;this.editing=!0;let t=this.display.measureAbsoluteArea(this);if(t.x-=2*this.scale,t.y-=2*this.scale,t.width+=2*this.scale,t.height+=2*this.scale,this.inputEl.value=this.value??"",this.inputEl.style.display="block",this.inputEl.style.position="absolute",this.inputEl.style.boxSizing="border-box",this.inputEl.style.left=`${t.x}px`,this.inputEl.style.top=`${t.y}px`,this.inputEl.style.width=`${t.width}px`,this.inputEl.style.height=`${t.height}px`,this.inputEl.autocomplete="off",this.multilineInput){let e=this.inputEl;e.style.resize="none"}else{let e=this.inputEl;this.passwordInput&&(e.type="password")}this.inputEl.focus(),this.inputEl.select()},tooltip:()=>this.tooltip,cursor:"text"},this.inputEl=document.createElement(this.multilineInput?"textarea":"input"),this.inputEl.style.display="none",this.inputEl.addEventListener("keyup",t=>{if(t.key==="Enter"){if(!this.multilineInput||t.ctrlKey){let e=this.inputEl?.value||"";if(typeof this.pv?.value=="number"){let i=Number(e);isNaN(i)||(e=this.clampToLimits(i))}!this.confirmMessage||confirm(this.confirmMessage)?(this.value=e,this.pv&&this.display.pvEngine.setValue(new Date,this.pv.name,e),this.finishEditing()):this.cancelInput()}}else t.key==="Escape"&&this.cancelInput()}),this.inputEl.addEventListener("blur",t=>{this.pv?this.cancelInput():(this.value=this.inputEl?.value||"",this.cancelInput())}),this.display.rootPanel.appendChild(this.inputEl),this.scratchCanvas=document.createElement("canvas"),this.scratchCtx=this.scratchCanvas.getContext("2d")}clampToLimits(t){let{minimum:e,maximum:i}=this;if(e<i){if(t<e)return e;if(t>i)return i}return t}finishEditing(){this.style!==Bs&&(this.inputEl.style.display="none"),this.editing=!1,this.requestRepaint()}cancelInput(){this.style===Bs&&(this.inputEl.value=this.computeDisplayText()),this.finishEditing()}computeDisplayText(){let t=this.text;if(this.value!==void 0){let e=this.precisionFromPV?this.pv?.precision??-1:this.precision;t=ge(this.value,this.formatType,e,this.pv?.typeHint),this.showUnits&&this.pv?.units&&(t+=" "+this.pv.units),this.showLohi&&(this.pv?.alarmName==="LOLO"||this.pv?.alarmName==="LOW"?t+=" \u2193":(this.pv?.alarmName==="HIHI"||this.pv?.alarmName==="HIGH")&&(t+=" \u2191"))}return t}drawHolder(t){if(this.autoSize){let e=this.properties.getValue(Is).scale(1);this.customSize=t.measureText(this.computeDisplayText(),e,!0)}super.drawHolder(t)}draw(t){if(this.style===Bs){this.drawNative();return}if(this.editing)return;t.addHitRegion(this.areaRegion).addRect(this.x,this.y,this.width,this.height);let i=t.ctx;this.backgroundAlarmSensitive&&this.alarm?t.fillRect({...this.area,color:this.alarmSensitiveBackgroundColor}):this.transparent||t.fillRect({...this.area,color:this.backgroundColor});let{pixelRatio:r}=t,s=me(i,this.area.x,this.area.y),o=Math.ceil(this.area.width+s.subPixelX),n=Math.ceil(this.area.height+s.subPixelY);this.scratchCanvas.width=Math.ceil(o*r),this.scratchCanvas.height=Math.ceil(n*r);let a=this.scratchCtx;a.setTransform(r,0,0,r,0,0),a.translate(s.subPixelX,s.subPixelY),a.fillStyle=this.alarmSensitiveForegroundColor.toString(),a.font=this.font.getFontString();let h=this.computeDisplayText(),l=h.replace(/(\r\n|\r|\n)$/,"").split(/\r\n|\r|\n/);if(l.length>1){let c=t.measureText("Mg",this.font).height,d=l.length*c,g=0;for(let _ of l)g=Math.max(g,a.measureText(_).width);let w=0;this.horizAlignment===1?w=(this.width-g)/2:this.horizAlignment===2&&(w=this.width-g);let x=0;this.vertAlignment===1?x=(this.height-d)/2:this.vertAlignment===2&&(x=this.height-d),a.textAlign="start",a.textBaseline="top";for(let _=0;_<l.length;_++)a.fillText(l[_],w,x+_*c)}else if(this.rotationAngle){let c=t.measureText(h,this.font,!0),d=wi({width:this.area.width,height:this.area.height},c,this.rotationAngle,this.horizAlignment,this.vertAlignment);a.translate(d.x,d.y),a.rotate(this.rotationAngle*Math.PI/180),a.textAlign="left",a.textBaseline="top",a.fillText(h,0,0)}else{let c=this.x;this.horizAlignment===0?a.textAlign="start":this.horizAlignment===1?(c+=this.width/2,a.textAlign="center"):this.horizAlignment===2&&(c+=this.width,a.textAlign="end");let d=this.y;this.vertAlignment===0?a.textBaseline="top":this.vertAlignment===1?(d=d+this.height/2,a.textBaseline="middle"):this.vertAlignment===2&&(d=d+this.height,a.textBaseline="bottom"),a.fillText(h,c-this.area.x,d-this.area.y)}i.drawImage(this.scratchCanvas,s.x,s.y,o,n)}drawNative(){let t=this.inputEl,e=this.display.measureAbsoluteArea(this);t.style.display="block",t.style.position="absolute",t.style.boxSizing="border-box",t.style.left=`${e.x}px`,t.style.top=`${e.y}px`,t.style.width=`${e.width}px`,t.style.height=`${e.height}px`,t.autocomplete="off",t.style.font=this.font.getFontString(),t.style.color=this.alarmSensitiveForegroundColor.toString(),this.backgroundAlarmSensitive&&this.alarm?t.style.backgroundColor=this.alarmSensitiveBackgroundColor.toString():t.style.backgroundColor=this.backgroundColor.toString(),t.style.border=this.showNativeBorder?"":"none";let i=["left","center","right"][this.horizAlignment]??"left";if(t.style.textAlign=i,t.readOnly=this.readOnly||!this.enabled,this.multilineInput){let r=t;r.style.resize="none",this.wrapWords?(r.wrap="soft",r.style.whiteSpace="pre-wrap",r.style.overflowWrap="break-word"):(r.wrap="off",r.style.whiteSpace="pre",r.style.overflowWrap="normal"),r.style.overflowX=this.showHScroll?"scroll":"hidden",r.style.overflowY=this.showVScroll?"scroll":"hidden"}else{let r=t;r.type=this.passwordInput?"password":"text"}if(document.activeElement!==t){let r=this.computeDisplayText();t.value!==r&&(t.value=r)}}hide(){this.editing=!1,this.inputEl&&(this.inputEl.style.display="none")}destroy(){this.inputEl&&(this.display.rootPanel.removeChild(this.inputEl),this.inputEl=void 0),this.scratchCanvas=void 0,this.scratchCtx=void 0}get autoSize(){return this.properties.getValue(dc)}get confirmMessage(){return this.properties.getValue(uc)}get font(){return this.properties.getValue(Is).scale(this.scale)}get formatType(){return this.properties.getValue(gc)}get horizAlignment(){return this.properties.getValue(mc)}get limitsFromPV(){return this.properties.getValue(fc)}get maximum(){return this.limitsFromPV&&this.pv?.upperDisplayLimit!==void 0?this.pv.upperDisplayLimit:this.properties.getValue(wc)}get minimum(){return this.limitsFromPV&&this.pv?.lowerDisplayLimit!==void 0?this.pv.lowerDisplayLimit:this.properties.getValue(xc)}get multilineInput(){return this.properties.getValue(yc)}get passwordInput(){return this.properties.getValue(Pc)}get precision(){return this.properties.getValue(bc)}get precisionFromPV(){return this.properties.getValue(vc)}get readOnly(){return this.properties.getValue(Rc)}get rotationAngle(){return this.properties.getValue(_c)}get showHScroll(){return this.properties.getValue(Tc)}get showLohi(){return this.properties.getValue(Sc)}get showNativeBorder(){return this.properties.getValue(Lc)}get showUnits(){return this.properties.getValue(Cc)}get showVScroll(){return this.properties.getValue(Ac)}get style(){return this.properties.getValue(Oc)}get vertAlignment(){return this.properties.getValue(Ec)}get wrapWords(){return this.properties.getValue(Mc)}};var Vc="minimum",Ic="maximum",Bc="integerDigits",Hc="decimalDigits",Dc="internalFrameColor",Wc="focusedFrameColor",kc="internalFrameSize",Nc="limits_from_pv",Fc="show_buttons",Gc="font",hy=100/255,ly=20,$c=15,cy=250,py=40;function vr(p,t){let e=Math.pow(10,t);return Math.round(p*e)/e}var Rr=class extends M{repeatTimeout;integerPressed=[];decimalPressed=[];constructor(t,e){super(t,e),this.properties.add(new C(Vc,0)),this.properties.add(new C(Ic,100)),this.properties.add(new P(Bc,3)),this.properties.add(new P(Hc,2)),this.properties.add(new S(Dc,m.BLACK)),this.properties.add(new S(Wc,m.BLUE)),this.properties.add(new P(kc,1)),this.properties.add(new f(Nc,!1)),this.properties.add(new f(Fc,!0)),this.properties.add(new H(Gc))}ensurePressedArrays(){let{integerDigits:t,decimalDigits:e}=this;this.integerPressed.length!==t&&(this.integerPressed=new Array(t).fill(void 0)),this.decimalPressed.length!==e&&(this.decimalPressed=new Array(e).fill(void 0))}draw(t){this.ensurePressedArrays(),this.backgroundAlarmSensitive&&this.alarm?t.fillRect({...this.area,color:this.alarmSensitiveBackgroundColor}):this.transparent||t.fillRect({...this.area,color:this.backgroundColor});let e=this.computeLayout(),{integerCharsByPlace:i,decimalCharsByIndex:r,showMinus:s}=this.computeDigits(),{integerDigits:o,decimalDigits:n}=this;this.drawPlainCell(t,e.sign,s?"-":"");for(let a=0;a<e.integer.length;a++){let h=o-a-1;this.drawDigitCell(t,e.integer[a],i[h],!1,h)}this.drawPlainCell(t,e.dot,n>0?".":"");for(let a=0;a<e.decimal.length;a++)this.drawDigitCell(t,e.decimal[a],r[a],!0,a);this.enabled||t.fillRect({...this.area,color:m.GRAY,opacity:hy})}computeLayout(){let{integerDigits:t,decimalDigits:e,showButtons:i}=this,r=this.area,s=2+t+e,o=r.width/s,n=i?ly*this.scale:0,a=x=>({x:r.x+x*o,y:r.y,width:o,height:r.height}),h=x=>{let _=a(x);return i?{cell:_,up:{x:_.x,y:_.y,width:o,height:n},down:{x:_.x,y:_.y+_.height-n,width:o,height:n}}:{cell:_}},l=0,c=a(l++),d=[];for(let x=0;x<t;x++)d.push(h(l++));let g=a(l++),w=[];for(let x=0;x<e;x++)w.push(h(l++));return{sign:c,integer:d,dot:g,decimal:w}}computeDigits(){let{integerDigits:t,decimalDigits:e}=this,i=this.currentNumericValue(),{wheelMax:r}=this.computeWheelLimits(),s=i<0;if(Math.abs(i)>r)return{integerCharsByPlace:new Array(t).fill("X"),decimalCharsByIndex:new Array(e).fill("X"),showMinus:s};let o=Math.abs(i).toFixed(e),[n,a]=o.split("."),h=[];for(let c=0;c<t;c++){let d=n.length-1-c;h.push(d>=0?n[d]:"0")}let l=[];for(let c=0;c<e;c++)l.push(a?a[c]:"0");return{integerCharsByPlace:h,decimalCharsByIndex:l,showMinus:s}}computeWheelLimits(){let{integerDigits:t,decimalDigits:e}=this,i=t>0?"9".repeat(t):"0";e>0&&(i+="."+"9".repeat(e));let r=Number(i);return{wheelMin:-r,wheelMax:r}}currentNumericValue(){let t=Number(this.value);return isNaN(t)?0:t}drawPlainCell(t,e,i){this.drawCellBorder(t,e),this.drawCellText(t,e,i)}drawDigitCell(t,e,i,r,s){if(this.drawCellBorder(t,e.cell),this.drawCellText(t,this.computeLabelBounds(e),i),!e.up||!e.down)return;let o=r?this.decimalPressed:this.integerPressed,n={id:`${this.wuid}-${r?"dec":"int"}-${s}-up`,mouseDown:()=>{this.enabled&&(o[s]=1,this.clickRepeatedly(r,s,1,!0))},mouseUp:()=>this.stopRepeating(o,s),mouseOut:()=>this.stopRepeating(o,s),tooltip:()=>this.tooltip},a={id:`${this.wuid}-${r?"dec":"int"}-${s}-down`,mouseDown:()=>{this.enabled&&(o[s]=-1,this.clickRepeatedly(r,s,-1,!0))},mouseUp:()=>this.stopRepeating(o,s),mouseOut:()=>this.stopRepeating(o,s),tooltip:()=>this.tooltip};this.drawUpButton(t,e.up,n,o[s]===1),this.drawDownButton(t,e.down,a,o[s]===-1)}computeLabelBounds(t){return!t.up||!t.down?t.cell:{x:t.cell.x,y:t.up.y+t.up.height,width:t.cell.width,height:t.cell.height-t.up.height-t.down.height}}drawCellBorder(t,e){this.internalFrameSize<=0||t.strokeRect({...e,color:this.internalFrameColor,lineWidth:this.internalFrameSize*this.scale})}drawCellText(t,e,i){i&&t.fillText({x:e.x+e.width/2,y:e.y+e.height/2,text:i,align:"center",baseline:"middle",color:this.alarmSensitiveForegroundColor,font:this.font})}drawUpButton(t,e,i,r){t.fillRect({...e,color:m.BUTTON}),this.drawButtonBorder(t,e,r),t.addHitRegion(i).addRect(e.x,e.y,e.width,e.height);let o=D(e,3*this.scale),n=Math.min(o.height,o.width/2);o.y+=(o.height-n)/2,n=Math.max(n,1);let a={x:o.x+o.width/2,y:o.y};t.fillPath({color:m.BLACK,path:new R(a.x,a.y).lineTo(a.x-n,a.y+n).lineTo(a.x+n,a.y+n).closePath()})}drawDownButton(t,e,i,r){t.fillRect({...e,color:m.BUTTON}),this.drawButtonBorder(t,e,r),t.addHitRegion(i).addRect(e.x,e.y,e.width,e.height);let o=D(e,3*this.scale),n=Math.min(o.height,o.width/2);o.y+=(o.height-n)/2,n=Math.max(n,1);let a={x:o.x+o.width/2,y:o.y+n};t.fillPath({color:m.BLACK,path:new R(a.x,a.y).lineTo(a.x-n,a.y-n).lineTo(a.x+n,a.y-n).closePath()})}drawButtonBorder(t,e,i){let r=1*this.scale,s=e.y+r/2,o=e.x+r/2,n=e.y+e.height-r/2,a=e.x+e.width-r/2,h=i?m.BUTTON_DARKEST:m.BUTTON_LIGHTEST,l=i?m.BUTTON_LIGHTEST:m.BUTTON_DARKEST;t.strokePath({color:h,lineWidth:r,path:new R(o,n).lineTo(o,s).lineTo(a,s)}),t.strokePath({color:l,lineWidth:r,path:new R(a,s).lineTo(a,n).lineTo(o,n)})}stopRepeating(t,e){window.clearTimeout(this.repeatTimeout),t[e]=void 0,this.requestRepaint()}clickRepeatedly(t,e,i,r){window.clearTimeout(this.repeatTimeout),this.click(t,e,i),this.requestRepaint(),this.repeatTimeout=window.setTimeout(()=>this.clickRepeatedly(t,e,i,!1),r?cy:py)}click(t,e,i){if(!this.enabled)return;let r=i*(t?Math.pow(10,-(e+1)):Math.pow(10,e)),s=this.currentNumericValue(),o=i>0?this.increment(s,r):this.decrement(s,r);this.pv&&this.pv.writable?this.display.pvEngine.setValue(new Date,this.pv.name,o):this.pv||(this.value=o)}increment(t,e){let{decimalDigits:i,minimum:r,maximum:s}=this,{wheelMin:o,wheelMax:n}=this.computeWheelLimits(),a=vr(t+e,i);return a!==0&&Math.sign(a)!==Math.sign(t)&&(a=vr(-t+e,i)),t>s||t>n?t:t<r?r:t<o?o:a>n?n:a>s?s:a}decrement(t,e){let{decimalDigits:i,minimum:r,maximum:s}=this,{wheelMin:o,wheelMax:n}=this.computeWheelLimits(),a=vr(t+e,i);return a!==0&&Math.sign(a)!==Math.sign(t)&&(a=vr(-t+e,i)),t<r||t<o?t:t>s?s:t>n?n:a<r?r:a<o?o:a}destroy(){window.clearTimeout(this.repeatTimeout)}get minimum(){return this.limitsFromPV&&this.pv?.lowerDisplayLimit!==void 0?this.pv.lowerDisplayLimit:this.properties.getValue(Vc)}get maximum(){return this.limitsFromPV&&this.pv?.upperDisplayLimit!==void 0?this.pv.upperDisplayLimit:this.properties.getValue(Ic)}get integerDigits(){return Math.min(this.properties.getValue(Bc),$c)}get decimalDigits(){let t=this.properties.getValue(Hc);return Math.min(t,Math.max(0,$c-this.integerDigits))}get internalFrameColor(){return this.properties.getValue(Dc)}get focusedFrameColor(){return this.properties.getValue(Wc)}get internalFrameSize(){return this.properties.getValue(kc)}get limitsFromPV(){return this.properties.getValue(Nc)}get showButtons(){return this.properties.getValue(Fc)}get font(){return this.properties.getValue(Gc).scale(this.scale)}};var Uc="alpha",Yc="fill",zc="line_width",Xc="line_style",qc="start_angle",Kc="total_angle",dy="scale_options",_r=class extends M{constructor(t,e){super(t,e),this.properties.add(new P(Uc,255)),this.properties.add(new P(zc)),this.properties.add(new P(qc)),this.properties.add(new P(Kc)),this.properties.add(new f(Yc)),this.properties.add(new P(Xc)),this.properties.add(new Q(dy,new Z(!0,!0,!0)))}draw(t){t.ctx.globalAlpha=this.alpha/255,this.drawShape(t),t.ctx.globalAlpha=1}drawShape(t){let e=this.x+this.width/2,i=this.y+this.height/2,r=this.width/2,s=this.height/2,o=-G(this.startAngle),n=-G(this.totalAngle+this.startAngle);if(this.fill&&(t.ctx.fillStyle=this.alarmSensitiveBackgroundColor.toString(),t.ctx.beginPath(),t.ctx.moveTo(e,i),t.ctx.ellipse(e,i,r,s,0,o,n,!0),t.ctx.closePath(),t.ctx.fill()),this.lineWidth&&this.totalAngle!==0){let a,{scale:h}=this;this.lineStyle===0?a=[]:this.lineStyle===1?a=[6*h,2*h]:this.lineStyle===2?a=[2*h,2*h]:console.warn(`Unsupported arc line style ${this.lineStyle}`),t.strokeEllipse({cx:e,cy:i,rx:r-this.lineWidth/2,ry:s-this.lineWidth/2,startAngle:o,endAngle:n,lineWidth:this.lineWidth,anticlockwise:!0,color:this.alarmSensitiveForegroundColor,dash:a})}}get alpha(){return this.properties.getValue(Uc)}get lineWidth(){return this.scale*this.properties.getValue(zc)}get lineStyle(){return this.properties.getValue(Xc)}get startAngle(){return this.properties.getValue(qc)}get totalAngle(){return this.properties.getValue(Kc)}get fill(){return this.properties.getValue(Yc)}};var jc="alpha",Zc="bg_gradient_color",Jc="fg_gradient_color",Qc="fill_level",tp="gradient",ep="horizontal_fill",ip="line_color",rp="line_width",sp="line_style",uy="scale_options",Tr=class extends M{constructor(t,e){super(t,e),this.properties.add(new P(jc,255)),this.properties.add(new S(Zc)),this.properties.add(new S(Jc)),this.properties.add(new f(tp)),this.properties.add(new P(rp)),this.properties.add(new C(Qc)),this.properties.add(new f(ep)),this.properties.add(new S(ip)),this.properties.add(new P(sp)),this.properties.add(new Q(uy,new Z(!0,!0,!0)))}draw(t){t.ctx.globalAlpha=this.alpha/255,this.drawBackground(t),this.fillLevel&&this.drawFill(t),t.ctx.globalAlpha=1}drawBackground(t){let e=this.x+this.width/2,i=this.y+this.height/2,r=this.width/2,s=this.height/2;if(!this.transparent){let o=this.alarmSensitiveBackgroundColor;if(this.gradient){let n=this.horizontalFill?this.x:this.x+this.width,a=this.horizontalFill?this.y+this.height:this.y,h=t.createLinearGradient(this.x,this.y,n,a);h.addColorStop(0,this.backgroundGradientStartColor.toString()),h.addColorStop(1,o.toString()),t.fillEllipse({cx:e,cy:i,rx:r,ry:s,gradient:h})}else t.fillEllipse({cx:e,cy:i,rx:r,ry:s,color:o})}if(this.lineWidth){let o=r-this.lineWidth/2,n=s-this.lineWidth/2;this.lineStyle===0?t.strokeEllipse({cx:e,cy:i,rx:o,ry:n,color:this.lineColor,lineWidth:this.lineWidth}):this.lineStyle===1?t.strokeEllipse({cx:e,cy:i,rx:o,ry:n,color:this.lineColor,lineWidth:this.lineWidth,dash:[6*this.scale,2*this.scale]}):console.warn(`Unsupported ellipse line style ${this.lineStyle}`)}}drawFill(t){let e=D(this,this.lineWidth);if(t.ctx.save(),this.horizontalFill){let a=e.width*(this.fillLevel/100);t.ctx.beginPath(),t.ctx.rect(e.x,e.y,a,e.height)}else{let a=e.height*(this.fillLevel/100),h=e.y+e.height-a;t.ctx.beginPath(),t.ctx.rect(e.x,h,e.width,e.height)}t.ctx.clip();let i=this.x+this.width/2,r=this.y+this.height/2,s=(this.width-this.lineWidth)/2,o=(this.height-this.lineWidth)/2,n=this.alarmSensitiveForegroundColor;if(this.gradient){let a=this.horizontalFill?this.x:this.x+this.width,h=this.horizontalFill?this.y+this.height:this.y,l=t.createLinearGradient(this.x,this.y,a,h);l.addColorStop(0,this.foregroundGradientStartColor.toString()),l.addColorStop(1,n.toString()),t.fillEllipse({cx:i,cy:r,rx:s,ry:o,gradient:l})}else t.fillEllipse({cx:i,cy:r,rx:s,ry:o,color:n});t.ctx.restore()}get alpha(){return this.properties.getValue(jc)}get lineWidth(){return this.scale*this.properties.getValue(rp)}get fillLevel(){return this.properties.getValue(Qc)}get horizontalFill(){return this.properties.getValue(ep)}get lineColor(){return this.properties.getValue(ip)}get lineStyle(){return this.properties.getValue(sp)}get gradient(){return this.properties.getValue(tp)}get backgroundGradientStartColor(){return this.properties.getValue(Zc)}get foregroundGradientStartColor(){return this.properties.getValue(Jc)}};var op="auto_size",np="crop_bottom",ap="crop_left",hp="crop_right",lp="crop_top",cp="degree",pp="flip_horizontal",dp="flip_vertical",gy="height",up="image_file",gp="no_animation",Hs="permutation_matrix",mp="stretch_to_fit",fp="transparency",my="width",fy=[[1,0],[0,1]],wp=[0,90,180,270],wy=[[-1,0],[0,1]],xy=[[1,0],[0,-1]];function xp(p){return p[0][0]===1&&p[0][1]===0&&p[1][0]===0&&p[1][1]===1}function yp(p){return Math.round(p*1e4)/1e4}function yy(p){let t=p*Math.PI/180,e=yp(Math.cos(t)),i=yp(Math.sin(t));return[[e,-i],[i,e]]}function Py(p,t){return[[p[0][0]*t[0][0]+p[0][1]*t[1][0],p[0][0]*t[0][1]+p[0][1]*t[1][1]],[p[1][0]*t[0][0]+p[1][1]*t[1][0],p[1][0]*t[0][1]+p[1][1]*t[1][1]]]}function by(p){return p.map(t=>t.map(e=>Math.round(e)))}function vy(p,t,e){let[[i,r],[s,o]]=e,a=[[0,0],[p-1,0],[p-1,t-1],[0,t-1]].map(([x,_])=>[i*x+r*_,s*x+o*_]),h=a.map(x=>x[0]),l=a.map(x=>x[1]),c=Math.min(...h),d=Math.min(...l),g=Math.max(...h),w=Math.max(...l);return{width:Math.round(g-c),height:Math.round(w-d),a:i,b:s,c:r,d:o,e:-c,f:-d}}var Sr=class extends M{currentImageFile;imageElement;imageSnapshot;imageLoading=!1;imageLoaded=!1;constructor(t,e){super(t,e),this.properties.add(new f(op,!0)),this.properties.add(new P(np,0)),this.properties.add(new P(ap,0)),this.properties.add(new P(hp,0)),this.properties.add(new P(lp,0)),this.properties.add(new T(up)),this.properties.add(new T(gp)),this.properties.add(new Ge(Hs,fy)),this.properties.add(new P(cp,0)),this.properties.add(new f(pp,!1)),this.properties.add(new f(dp,!1)),this.properties.add(new f(mp,!1)),this.properties.add(new f(fp,!0))}init(){this.imageElement=new Image(this.width,this.height),this.imageElement.onload=()=>{this.snapshotImage(this.imageElement),this.imageLoading=!1,this.imageLoaded=!0,this.applyAutoSize(),this.requestRepaint()},this.triggerImageLoad(),this.addPropertyListener(cp,(t,e)=>{let i=wp[t]-wp[e];this.applyPermutationDelta(yy(i))}),this.addPropertyListener(pp,()=>{this.applyPermutationDelta(wy)}),this.addPropertyListener(dp,()=>{this.applyPermutationDelta(xy)})}applyPermutationDelta(t){let e=by(Py(t,this.permutationMatrix));this.properties.setValue(Hs,e),this.imageElement&&this.imageLoaded&&(this.snapshotImage(this.imageElement),this.applyAutoSize()),this.requestRepaint()}autoScale(t,e){M.prototype.autoScale.call(this,t,e),this.applyAutoSize()}applyAutoSize(){if(this.autoSize&&!this.stretchToFit&&this.imageSnapshot){let t=this.getCropRegion(this.imageSnapshot);this.properties.setValue(my,t.width),this.properties.setValue(gy,t.height)}}getCropRegion(t){let e=t.width,i=t.height,r=this.cropTop>i?0:this.cropTop,s=this.cropLeft>e?0:this.cropLeft,o=i-r-this.cropBottom<0?0:this.cropBottom,n=e-s-this.cropRight<0?0:this.cropRight;return{x:s,y:r,width:e-s-n,height:i-r-o}}draw(t){if(this.imageFile&&this.currentImageFile!==this.imageFile&&this.triggerImageLoad(),this.imageLoading&&this.imageSnapshot)this.drawSource(t,this.imageSnapshot,this.imageSnapshot);else if(this.imageLoaded)if(this.noAnimation)this.drawSource(t,this.imageSnapshot,this.imageSnapshot);else{let e=xp(this.permutationMatrix)?this.imageElement:this.renderOriented(this.imageElement,this.imageElement.naturalWidth,this.imageElement.naturalHeight);this.drawSource(t,e,this.imageSnapshot)}else this.transparency||(t.ctx.fillStyle=this.backgroundColor.toString(),t.ctx.fillRect(this.x,this.y,this.width,this.height))}drawSource(t,e,i){let r=this.stretchToFit?this.getStretchedSourceRect(i):this.getUnstretchedSourceRect(i);r&&(this.transparency||(t.ctx.fillStyle=this.backgroundColor.toString(),t.ctx.fillRect(this.x,this.y,r.destWidth,r.destHeight)),t.ctx.drawImage(e,r.sx,r.sy,r.sw,r.sh,this.x,this.y,r.destWidth,r.destHeight))}getUnstretchedSourceRect(t){let e=this.getCropRegion(t);if(!(e.width<=0||e.height<=0))return{sx:e.x,sy:e.y,sw:e.width,sh:e.height,destWidth:e.width,destHeight:e.height}}getStretchedSourceRect(t){let e=this.width+this.cropLeft+this.cropRight,i=this.height+this.cropTop+this.cropBottom;if(e<=0||i<=0)return;let r=t.width/e,s=t.height/i;return{sx:this.cropLeft*r,sy:this.cropTop*s,sw:this.width*r,sh:this.height*s,destWidth:this.width,destHeight:this.height}}triggerImageLoad(){if(this.imageLoading=!0,this.imageLoaded=!1,this.imageElement&&this.imageFile){this.currentImageFile=this.imageFile;let t=this.imageElement;this.display.getImageLoader().load(this.resolvePath(this.imageFile)).then(e=>{t.src=e})}}snapshotImage(t){this.imageSnapshot=this.renderOriented(t,t.naturalWidth,t.naturalHeight)}renderOriented(t,e,i){let r=document.createElement("canvas"),s=r.getContext("2d"),o=this.permutationMatrix;if(xp(o))r.width=e,r.height=i,s.drawImage(t,0,0);else{let n=vy(e,i,o);r.width=n.width,r.height=n.height,s.setTransform(n.a,n.b,n.c,n.d,n.e,n.f),s.drawImage(t,0,0)}return r}get transparency(){return this.properties.getValue(fp)}get imageFile(){return this.properties.getValue(up)}get noAnimation(){return this.properties.getValue(gp)}get autoSize(){return this.properties.getValue(op)}get stretchToFit(){return this.properties.getValue(mp)}get cropTop(){return this.properties.getValue(lp)}get cropBottom(){return this.properties.getValue(np)}get cropLeft(){return this.properties.getValue(ap)}get cropRight(){return this.properties.getValue(hp)}get permutationMatrix(){return this.properties.getValue(Hs)}};function Pp(p,t,e,i,r,s,o){let n=1*e,a=t.y+n/2,h=t.x+n/2,l=t.y+t.height-n+n/2,c=t.x+t.width-n+n/2;p.strokePath({color:i,path:new R(c,l).lineTo(c,a).moveTo(c,l).lineTo(h,l)}),p.strokePath({color:r,path:new R(c-n,l-n).lineTo(c-n,a+n).moveTo(c-n,l-n).lineTo(h+n,l-n)}),p.strokePath({color:s,path:new R(h,a).lineTo(c-n,a).moveTo(h,a).lineTo(h,l-n)}),p.strokePath({color:o,path:new R(h+n,a+n).lineTo(c-n-n,a+n).moveTo(h+n,a+n).lineTo(h+n,l-n-n)})}function Ee(p,t,e){Pp(p,t,e,m.BUTTON_DARKEST,m.BUTTON_DARKER,m.BUTTON,m.BUTTON_LIGHTEST)}function Lr(p,t,e){Pp(p,t,e,m.BUTTON_LIGHTEST,m.BUTTON_LIGHTEST,m.BUTTON_DARKEST,m.BUTTON_DARKER)}function Cr(p,t,e,i,r=m.BLACK){let s=3*e,o={x:t.x+s,y:t.y+s,width:t.width-2*s,height:t.height-2*s},n=i==="left"||i==="right",a=n?Math.min(o.width,o.height/2):Math.min(o.height,o.width/2);n?o.x+=(o.width-a)/2:o.y+=(o.height-a)/2,a=Math.max(a,1);let h;switch(i){case"up":h={x:o.x+o.width/2,y:o.y};break;case"down":h={x:o.x+o.width/2,y:o.y+a};break;case"left":h={x:o.x,y:o.y+o.height/2};break;case"right":h={x:o.x+a,y:o.y+o.height/2};break}let l;switch(i){case"up":l=new R(h.x,h.y).lineTo(h.x-a,h.y+a).lineTo(h.x+a,h.y+a).closePath();break;case"down":l=new R(h.x,h.y).lineTo(h.x-a,h.y-a).lineTo(h.x+a,h.y-a).closePath();break;case"left":l=new R(h.x,h.y).lineTo(h.x+a,h.y-a).lineTo(h.x+a,h.y+a).closePath();break;case"right":l=new R(h.x,h.y).lineTo(h.x-a,h.y-a).lineTo(h.x-a,h.y+a).closePath();break}p.fillPath({color:r,path:l})}var bp="auto_size",Ds="font",vp="horizontal_alignment",Rp="show_scrollbar",_p="vertical_alignment",Tp="wrap_words",Ry=16,_y=new m(243,243,243),Sp=new m(232,232,231),Lp=150,Ar=class extends M{scrollOffset=0;maxScroll=0;dragRange;grabStartOffset;actionTimeout;upPressed=!1;downPressed=!1;thumbRegion;upRegion;downRegion;trackAboveRegion;trackBelowRegion;constructor(t,e){super(t,e),this.properties.add(new f(bp)),this.properties.add(new H(Ds)),this.properties.add(new P(vp)),this.properties.add(new f(Rp)),this.properties.add(new P(_p)),this.properties.add(new f(Tp))}init(){this.thumbRegion={id:`${this.wuid}-scrollbar-thumb`,mouseDown:()=>{this.grabStartOffset=this.scrollOffset},grab:t=>{let e=this.maxScroll*t.dy/(this.dragRange||1);this.setScrollOffset((this.grabStartOffset??0)+e)},tooltip:()=>this.tooltip},this.upRegion={id:`${this.wuid}-scrollbar-up`,mouseDown:()=>{this.upPressed=!0,this.stepScrollRepeatedly(-1)},mouseUp:()=>this.endScrollAction(()=>this.upPressed=!1),mouseOut:()=>this.endScrollAction(()=>this.upPressed=!1),tooltip:()=>this.tooltip},this.downRegion={id:`${this.wuid}-scrollbar-down`,mouseDown:()=>{this.downPressed=!0,this.stepScrollRepeatedly(1)},mouseUp:()=>this.endScrollAction(()=>this.downPressed=!1),mouseOut:()=>this.endScrollAction(()=>this.downPressed=!1),tooltip:()=>this.tooltip},this.trackAboveRegion={id:`${this.wuid}-scrollbar-track-above`,mouseDown:()=>this.pageScrollRepeatedly(-1),mouseUp:()=>this.endScrollAction(),mouseOut:()=>this.endScrollAction(),tooltip:()=>this.tooltip},this.trackBelowRegion={id:`${this.wuid}-scrollbar-track-below`,mouseDown:()=>this.pageScrollRepeatedly(1),mouseUp:()=>this.endScrollAction(),mouseOut:()=>this.endScrollAction(),tooltip:()=>this.tooltip}}destroy(){window.clearTimeout(this.actionTimeout)}setScrollOffset(t){this.scrollOffset=Math.min(Math.max(t,0),this.maxScroll),this.requestRepaint()}stepScrollRepeatedly(t){window.clearTimeout(this.actionTimeout),this.setScrollOffset(this.scrollOffset+t*this.font.height*1.2),this.actionTimeout=window.setTimeout(()=>this.stepScrollRepeatedly(t),Lp)}pageScrollRepeatedly(t){window.clearTimeout(this.actionTimeout),this.setScrollOffset(this.scrollOffset+t*this.height),this.actionTimeout=window.setTimeout(()=>this.pageScrollRepeatedly(t),Lp)}endScrollAction(t){window.clearTimeout(this.actionTimeout),t?.(),this.requestRepaint()}drawHolder(t){if(this.autoSize){let e=this.properties.getValue(Ds).scale(1);this.customSize=t.measureText(this.text,e,!0)}super.drawHolder(t)}draw(t){this.transparent||t.fillRect({x:this.x,y:this.y,width:this.width,height:this.height,color:this.backgroundColor}),this.wrapWords?this.drawWrapped(t):this.drawText(t)}drawText(t){let e=t.ctx,i={...this.area},r=t.measureText(this.text,this.font,!0);e.font=this.font.getFontString(),e.textBaseline="alphabetic";let o=e.measureText(this.text).fontBoundingBoxAscent,n={x:i.x,y:i.y,width:r.width,height:r.height};this.horizAlignment===0||(this.horizAlignment===1?n.x+=(i.width-r.width)/2:this.horizAlignment===2&&(n.x+=i.width-r.width)),this.vertAlignment===0||i.height<=r.height||(this.vertAlignment===1?n.y+=i.height/2-r.height/2:this.vertAlignment===2&&(n.y+=i.height-r.height)),e.textAlign="start",e.textBaseline="top",n.y+=n.height/2-o/2,e.save(),e.beginPath();let a=this.area;e.rect(a.x,a.y,a.width,a.height),e.clip(),e.fillStyle=this.foregroundColor.toString(),e.fillText(this.text,n.x,n.y),e.restore()}drawWrapped(t){let e=t.ctx,i=t.measureText("Mg",this.font).height,r=this.wrapText(t,this.text,this.width),s=r.length*i,o=this.width,n=!1,a=Ry*this.scale;this.showScrollbar&&s>this.height&&(n=!0,o=Math.max(0,this.width-a),r=this.wrapText(t,this.text,o),s=r.length*i),this.maxScroll=Math.max(0,s-this.height),this.scrollOffset=Math.min(Math.max(this.scrollOffset,0),this.maxScroll),e.fillStyle=this.foregroundColor.toString(),e.font=this.font.getFontString(),e.textAlign="start",e.textBaseline="top";let h=this.y;this.height>s&&(this.vertAlignment===1?h+=(this.height-s)/2:this.vertAlignment===2&&(h+=this.height-s)),h-=this.scrollOffset,e.save(),e.beginPath(),e.rect(this.x,this.y,o,this.height),e.clip();for(let l of r){let c=this.x;if(this.horizAlignment===1){let d=e.measureText(l).width;c=this.x+(o-d)/2}else if(this.horizAlignment===2){let d=e.measureText(l).width;c=this.x+(o-d)}e.fillText(l,c,h),h+=i}e.restore(),n&&this.drawScrollbar(t,{x:this.x+o,y:this.y,width:a,height:this.height})}drawScrollbar(t,e){let{scale:i}=this;t.fillRect({...e,color:_y});let r=Math.min(e.width,e.height/2);this.drawScrollButton(t,"up",{x:e.x,y:e.y,width:e.width,height:r}),this.drawScrollButton(t,"down",{x:e.x,y:e.y+e.height-r,width:e.width,height:r});let s=e.height-2*r,o=Math.min(1,this.height/(this.height+this.maxScroll)),n=Math.max(6*i,s*o);this.dragRange=s-n;let a=this.maxScroll>0?this.scrollOffset/this.maxScroll:0,h=e.y+r+this.dragRange*a,l={x:e.x,y:h,width:e.width,height:n};t.fillRect({...l,color:Sp}),Ee(t,l,i),t.addHitRegion(this.thumbRegion).addRect(l.x,l.y,l.width,l.height);let c=e.y+r,d=e.y+e.height-r;t.addHitRegion(this.trackAboveRegion).addRect(e.x,c,e.width,h-c),t.addHitRegion(this.trackBelowRegion).addRect(e.x,h+n,e.width,d-(h+n))}drawScrollButton(t,e,i){let{scale:r}=this,s=e==="up"?this.upPressed:this.downPressed;t.fillRect({...i,color:Sp}),s?Lr(t,i,r):Ee(t,i,r);let o=e==="up"?this.upRegion:this.downRegion;t.addHitRegion(o).addRect(i.x,i.y,i.width,i.height),Cr(t,i,r,e)}wrapText(t,e,i){let r=[];for(let s of e.replace(/\n$/,"").split(`
|
|
21
21
|
`))r=r.concat(this.wrapLine(t,s,i));return r}wrapLine(t,e,i){if(!e)return[""];let r=[];for(;e.length;){let s;for(s=e.length;t.measureText(e.substr(0,s),this.font).width>i;s--);let o;if(s===e.length)o=e;else if(e[s]===" ")o=e.substr(0,s+1);else{let n=e.substr(0,s),a=0;for(;n.indexOf(" ",a)!==-1;a=n.indexOf(" ",a)+1);if(a)o=n.substr(0,a);else{let h=e.indexOf(" ");o=h===-1?e:e.substr(0,h)}}r.push(o),e=e.substr(o.length)}return r}get autoSize(){return this.properties.getValue(bp)}get font(){return this.properties.getValue(Ds).scale(this.scale)}get horizAlignment(){return this.properties.getValue(vp)}get showScrollbar(){return this.properties.getValue(Rp)}get vertAlignment(){return this.properties.getValue(_p)}get wrapWords(){return this.properties.getValue(Tp)}};var Cp="alpha",Ap="fill_level",Op="horizontal_fill",Ep="line_color",Mp="line_style",Vp="line_width",Jt="points",Ws="rotation_angle",Or=class extends M{zeroDegreePoints=[];originPoints;constructor(t,e){super(t,e),this.properties.add(new P(Cp,255)),this.properties.add(new P(Vp)),this.properties.add(new C(Ap)),this.properties.add(new f(Op)),this.properties.add(new S(Ep)),this.properties.add(new P(Mp)),this.properties.add(new Dt(Jt,[])),this.properties.add(new C(Ws))}init(){this.addPropertyListener("x",(t,e)=>{let i=t-e,r=this.properties.getValue(Jt);this.properties.setValue(Jt,_t(r,i,0)),this.zeroDegreePoints=_t(this.zeroDegreePoints,i,0),this.requestRepaint()}),this.addPropertyListener("y",(t,e)=>{let i=t-e,r=this.properties.getValue(Jt);this.properties.setValue(Jt,_t(r,0,i)),this.zeroDegreePoints=_t(this.zeroDegreePoints,0,i),this.requestRepaint()}),this.updateZeroDegreePoints(),this.addPropertyListener(Ws,()=>this.requestRepaint())}updateZeroDegreePoints(){let t=this.properties.getValue(Jt),e=this.rotationAngle;this.zeroDegreePoints=e?ue(t,-e):t}autoScale(t,e){this.originPoints||(this.originPoints=this.properties.getValue(Jt)),M.prototype.autoScale.call(this,t,e);let i=Math.min(...this.originPoints.map(h=>h.x)),r=Math.min(...this.originPoints.map(h=>h.y)),s=Math.round(i*t),o=Math.round(r*e),n=vi(t,e,this.scaleOptions),a=this.originPoints.map(h=>({x:Math.trunc((h.x-i)*n.widthRatio)+s,y:Math.trunc((h.y-r)*n.heightRatio)+o}));this.properties.setValue(Jt,a),this.updateZeroDegreePoints()}draw(t){let{scale:e}=this;t.ctx.globalAlpha=this.alpha/255;let i=R.fromPoints(fi(this.points)).closePath();if(!this.transparent){let r=this.alarmSensitiveBackgroundColor;t.fillPath({path:i,color:r})}this.lineWidth&&(this.lineStyle===0?t.strokePath({path:i,lineWidth:this.lineWidth,color:this.lineColor}):this.lineStyle===2?t.strokePath({path:i,lineWidth:this.lineWidth,color:this.lineColor,dash:[6*e,2*e]}):console.warn(`Unsupported polygon line style ${this.lineStyle}`)),this.fillLevel&&this.drawFill(t,i),t.ctx.globalAlpha=1}drawFill(t,e){let i=this.y,r=this.width,s=this.height;this.horizontalFill?r*=this.fillLevel/100:(s*=this.fillLevel/100,i+=this.height-s),t.ctx.save();let o=this.x-this.lineWidth/2,n=i-this.lineWidth/2,a=r+this.lineWidth,h=s+this.lineWidth;t.ctx.beginPath(),t.ctx.rect(o,n,a,h),t.ctx.clip();let l=this.alarmSensitiveForegroundColor;t.fillPath({path:e,color:l}),t.ctx.restore()}get alpha(){return this.properties.getValue(Cp)}get lineWidth(){return this.scale*this.properties.getValue(Vp)}get fillLevel(){return this.properties.getValue(Ap)}get horizontalFill(){return this.properties.getValue(Op)}get lineColor(){return this.properties.getValue(Ep)}get lineStyle(){return this.properties.getValue(Mp)}get points(){let t=this.rotationAngle,e=t?ue(this.zeroDegreePoints,t):this.zeroDegreePoints;return re(e,this.scale)}get rotationAngle(){return this.properties.getValue(Ws)}};var Ip="alpha",Bp="arrows",Hp="arrow_length",Dp="fill_arrow",Wp="fill_level",kp="horizontal_fill",Np="line_width",Er="points",ks="rotation_angle",Mr=class extends M{zeroDegreePoints=[];originPoints;constructor(t,e){super(t,e),this.properties.add(new P(Ip,255)),this.properties.add(new P(Np)),this.properties.add(new C(Wp)),this.properties.add(new f(kp)),this.properties.add(new Dt(Er,[])),this.properties.add(new P(Hp)),this.properties.add(new f(Dp)),this.properties.add(new P(Bp)),this.properties.add(new C(ks))}init(){this.updateZeroDegreePoints(),this.addPropertyListener(ks,()=>this.requestRepaint())}updateZeroDegreePoints(){let t=this.properties.getValue(Er),e=this.rotationAngle;this.zeroDegreePoints=e?ue(t,-e):t}autoScale(t,e){M.prototype.autoScale.call(this,t,e),this.originPoints||(this.originPoints=this.properties.getValue(Er));let i=Math.min(...this.originPoints.map(h=>h.x)),r=Math.min(...this.originPoints.map(h=>h.y)),s=Math.round(i*t),o=Math.round(r*e),n=vi(t,e,this.scaleOptions),a=this.originPoints.map(h=>({x:Math.trunc((h.x-i)*n.widthRatio)+s,y:Math.trunc((h.y-r)*n.heightRatio)+o}));this.properties.setValue(Er,a),this.updateZeroDegreePoints()}draw(t){let e=t.ctx;e.globalAlpha=this.alpha/255,this.transparent&&(e.globalAlpha=0),this.drawShape(e,this.alarmSensitiveBackgroundColor),this.fillLevel&&this.drawFill(e),e.globalAlpha=1}drawFill(t){let e=this.getFillBounds(),i=e.y,r=e.width,s=e.height;this.horizontalFill?r*=this.fillLevel/100:(s*=this.fillLevel/100,i+=e.height-s),t.save(),t.beginPath(),t.rect(e.x,i,r,s),t.clip(),this.drawShape(t,this.alarmSensitiveForegroundColor),t.restore()}getFillBounds(){let t=this.points,e=t[0].x,i=t[0].x,r=t[0].y,s=t[0].y,o=a=>{e=Math.min(e,a.x),i=Math.max(i,a.x),r=Math.min(r,a.y),s=Math.max(s,a.y)};for(let a of t)o(a);if(this.arrows!==0&&t.length>=2){let a=t[0],h=t[t.length-1];if(this.arrows===2||this.arrows===3)for(let l of this.calculateArrowPoints(t[t.length-2],h))o(l);if(this.arrows===1||this.arrows===3)for(let l of this.calculateArrowPoints(t[1],a))o(l)}let n=this.lineWidth/2;return{x:e-n,y:r-n,width:i-e+this.lineWidth,height:s-r+this.lineWidth}}drawShape(t,e){let i=[...this.points];if(i.length>=2){let r=i[0],s=i[i.length-1];if(this.arrows===2||this.arrows===3){let o=this.calculateArrowPoints(i[i.length-2],s);this.fillArrow&&(i[i.length-1]=o[2]),o[2]=s,this.drawArrowhead(t,e,o,s)}if(this.arrows===1||this.arrows===3){let o=this.calculateArrowPoints(i[1],r);this.fillArrow&&(i[0]=o[2]),o[2]=r,this.drawArrowhead(t,e,o,r)}}t.strokeStyle=e.toString(),t.lineWidth=this.lineWidth,t.beginPath();for(let r=0;r<i.length;r++)r===0?t.moveTo(i[r].x,i[r].y):t.lineTo(i[r].x,i[r].y);t.stroke()}drawArrowhead(t,e,i,r){if(this.fillArrow){t.fillStyle=e.toString(),t.beginPath();for(let s=0;s<i.length;s++)s===0?t.moveTo(i[s].x,i[s].y):t.lineTo(i[s].x,i[s].y);t.fill()}else t.strokeStyle=e.toString(),t.lineWidth=this.lineWidth,t.beginPath(),t.moveTo(r.x,r.y),t.lineTo(i[0].x,i[0].y),t.moveTo(r.x,r.y),t.lineTo(i[1].x,i[1].y),t.stroke()}calculateArrowPoints(t,e){let i=mi(e,t),r=Math.PI/10,s=new vt(this.arrowLength,i.theta-r),o=new vt(this.arrowLength,i.theta+r),n=new vt(Math.floor(this.arrowLength*Math.cos(r)),i.theta),a=Bt(s.toPoint(),e.x,e.y),h=Bt(o.toPoint(),e.x,e.y),l=Bt(n.toPoint(),e.x,e.y);return[a,h,l]}get alpha(){return this.properties.getValue(Ip)}get lineWidth(){return this.scale*this.properties.getValue(Np)}get fillLevel(){return this.properties.getValue(Wp)}get horizontalFill(){return this.properties.getValue(kp)}get points(){let t=this.rotationAngle,e=t?ue(this.zeroDegreePoints,t):this.zeroDegreePoints,i=re(e,this.scale);return fi(i)}get rotationAngle(){return this.properties.getValue(ks)}get arrows(){return this.properties.getValue(Bp)}get fillArrow(){return this.properties.getValue(Dp)}get arrowLength(){return this.scale*this.properties.getValue(Hp)}};var Fp="alpha",Gp="bg_gradient_color",$p="fg_gradient_color",Up="fill_level",Yp="gradient",zp="horizontal_fill",Xp="line_color",qp="line_width",Kp="line_style",Vr=class extends M{constructor(t,e){super(t,e),this.fillRoundRectangleBackgroundBorder=!1,this.properties.add(new P(Fp,255)),this.properties.add(new S(Gp)),this.properties.add(new S($p)),this.properties.add(new f(Yp)),this.properties.add(new P(qp)),this.properties.add(new C(Up)),this.properties.add(new f(zp)),this.properties.add(new S(Xp)),this.properties.add(new P(Kp))}draw(t){t.ctx.globalAlpha=this.alpha/255,this.drawBackground(t),this.fillLevel&&this.drawFill(t),t.ctx.globalAlpha=1}drawBackground(t){if(!this.transparent){let e=this.alarmSensitiveBackgroundColor;if(this.gradient){let i=this.horizontalFill?this.x:this.x+this.width,r=this.horizontalFill?this.y+this.height:this.y,s=t.createLinearGradient(this.x,this.y,i,r);s.addColorStop(0,this.backgroundGradientStartColor.toString()),s.addColorStop(1,e.toString()),t.fillRect({...this.area,gradient:s})}else t.fillRect({...this.area,color:e})}this.lineWidth&&(this.lineStyle===0?t.strokeRect({...this.area,color:this.lineColor,lineWidth:this.lineWidth,crispen:!0}):this.lineStyle===1?t.strokeRect({...this.area,color:this.lineColor,lineWidth:this.lineWidth,crispen:!0,dash:[6*this.scale,2*this.scale]}):console.warn(`Unsupported rectangle line style ${this.lineStyle}`))}drawFill(t){let e=D(this,this.lineWidth);if(t.ctx.save(),this.horizontalFill){let r=e.width*(this.fillLevel/100);t.ctx.beginPath(),t.ctx.rect(e.x,e.y,r,e.height)}else{let r=e.height*(this.fillLevel/100),s=e.y+e.height-r;t.ctx.beginPath(),t.ctx.rect(e.x,s,e.width,e.height)}t.ctx.clip();let i=this.alarmSensitiveForegroundColor;if(this.gradient){let r=this.horizontalFill?e.x:e.x+e.width,s=this.horizontalFill?e.y+e.height:e.y,o=t.createLinearGradient(e.x,e.y,r,s);o.addColorStop(0,this.foregroundGradientStartColor.toString()),o.addColorStop(1,i.toString()),t.fillRect({...e,gradient:o})}else t.fillRect({...e,color:i});t.ctx.restore()}get alpha(){return this.properties.getValue(Fp)}get lineWidth(){return this.scale*this.properties.getValue(qp)}get fillLevel(){return this.properties.getValue(Up)}get horizontalFill(){return this.properties.getValue(zp)}get lineColor(){return this.properties.getValue(Xp)}get lineStyle(){return this.properties.getValue(Kp)}get gradient(){return this.properties.getValue(Yp)}get backgroundGradientStartColor(){return this.properties.getValue(Gp)}get foregroundGradientStartColor(){return this.properties.getValue($p)}};var jp="alpha",Zp="bg_gradient_color",Jp="corner_width",Qp="corner_height",td="fg_gradient_color",ed="fill_level",id="gradient",rd="horizontal_fill",sd="line_color",od="line_width",nd="line_style",Ir=class extends M{constructor(t,e){super(t,e),this.fillRoundRectangleBackgroundBorder=!1,this.properties.add(new P(jp,255)),this.properties.add(new S(Zp)),this.properties.add(new S(td)),this.properties.add(new f(id)),this.properties.add(new P(od)),this.properties.add(new C(ed)),this.properties.add(new f(rd)),this.properties.add(new S(sd)),this.properties.add(new P(Jp)),this.properties.add(new P(Qp)),this.properties.add(new P(nd))}draw(t){t.ctx.globalAlpha=this.alpha/255,this.drawBackground(t),this.fillLevel&&this.drawFill(t),t.ctx.globalAlpha=1}drawBackground(t){if(!this.transparent){let e=this.alarmSensitiveBackgroundColor;if(this.gradient){let i=this.horizontalFill?this.x:this.x+this.width,r=this.horizontalFill?this.y+this.height:this.y,s=t.createLinearGradient(this.x,this.y,i,r);s.addColorStop(0,this.backgroundGradientStartColor.toString()),s.addColorStop(1,e.toString()),t.fillRect({...this.area,rx:this.cornerWidth/2,ry:this.cornerHeight/2,gradient:s})}else t.fillRect({...this.area,rx:this.cornerWidth/2,ry:this.cornerHeight/2,color:e})}this.lineWidth&&(this.lineStyle===0?t.strokeRect({...this.area,rx:this.cornerWidth/2,ry:this.cornerHeight/2,color:this.lineColor,lineWidth:this.lineWidth,crispen:!0}):this.lineStyle===1?t.strokeRect({...this.area,rx:this.cornerWidth/2,ry:this.cornerHeight/2,color:this.lineColor,lineWidth:this.lineWidth,crispen:!0,dash:[6*this.scale,2*this.scale]}):console.warn(`Unsupported RoundedRectangle line style ${this.lineStyle}`))}drawFill(t){let e=this.cornerWidth/2,i=this.cornerHeight/2,r=D(this,this.lineWidth);if(t.ctx.save(),this.horizontalFill){let o=r.width*(this.fillLevel/100);t.ctx.beginPath(),t.ctx.rect(r.x,r.y,o,r.height)}else{let o=r.height*(this.fillLevel/100),n=r.y+r.height-o;t.ctx.beginPath(),t.ctx.rect(r.x,n,r.width,r.height)}t.ctx.clip();let s=this.alarmSensitiveForegroundColor;if(this.gradient){let o=this.horizontalFill?r.x:r.x+r.width,n=this.horizontalFill?r.y+r.height:r.y,a=t.createLinearGradient(r.x,r.y,o,n);a.addColorStop(0,this.foregroundGradientStartColor.toString()),a.addColorStop(1,s.toString()),t.fillRect({...r,rx:e,ry:i,gradient:a})}else t.fillRect({...r,rx:e,ry:i,color:s});t.ctx.restore()}get alpha(){return this.properties.getValue(jp)}get lineWidth(){return this.scale*this.properties.getValue(od)}get fillLevel(){return this.properties.getValue(ed)}get horizontalFill(){return this.properties.getValue(rd)}get lineColor(){return this.properties.getValue(sd)}get lineStyle(){return this.properties.getValue(nd)}get gradient(){return this.properties.getValue(id)}get cornerWidth(){return this.scale*this.properties.getValue(Jp)}get cornerHeight(){return this.scale*this.properties.getValue(Qp)}get backgroundGradientStartColor(){return this.properties.getValue(Zp)}get foregroundGradientStartColor(){return this.properties.getValue(td)}};var ad="bitReverse",hd="effect_3d",ld="horizontal",cd="led_border",pd="led_border_color",dd="led_packed",ud="numBits",gd="off_color",md="on_color",fd="startBit",wd="square_led",Br=class extends M{constructor(t,e){super(t,e),this.properties.add(new f(ad)),this.properties.add(new f(hd)),this.properties.add(new f(ld)),this.properties.add(new P(ud)),this.properties.add(new S(gd)),this.properties.add(new S(md)),this.properties.add(new P(fd)),this.properties.add(new f(wd)),this.properties.add(new P(cd,3)),this.properties.add(new S(pd,m.DARK_GRAY)),this.properties.add(new f(dd,!1))}getLedColor(t){let e=!1;if(this.value!==void 0)for(let i=this.startBit;i<this.startBit+this.numBits;i++){let r=0;if(this.bitReverse?r=i-this.startBit:r=this.numBits-1-(i-this.startBit),r===t){e=(this.value>>i&1)>0;break}}return e?this.onColor:this.offColor}draw(t){if(this.numBits<1)return;let e=this.bounds;this.borderAlarmSensitive&&(e=D(e,2*this.scale)),this.horizontal?this.drawHorizontal(t,e):this.drawVertical(t,e)}drawHorizontal(t,e){let i,r;this.ledPacked?(i=Math.floor((e.width-this.ledBorder)/this.numBits+this.ledBorder),r=i-this.ledBorder):(i=Math.floor(e.width/this.numBits),r=i);let s=0;i>e.height||this.squareLed?s=e.height:s=i;for(let o=0;o<this.numBits;o++)if(this.squareLed){let n={x:e.x+o*r,y:e.y,width:i,height:s};this.effect3d?this.drawSquare3d(t,n,o):this.drawSquare2d(t,n,o)}else{let n=Math.min(i,s),a={x:e.x+o*r,y:e.y,width:n,height:n};this.effect3d?this.drawCircle3d(t,a,o):this.drawCircle2d(t,a,o)}}drawVertical(t,e){let i,r;this.ledPacked?(i=Math.floor((e.height-this.ledBorder)/this.numBits+this.ledBorder),r=i-this.ledBorder):(i=Math.floor(e.height/this.numBits),r=i);let s=0;i>e.width||this.squareLed?s=e.width:s=i;for(let o=0;o<this.numBits;o++)if(this.squareLed){let n={x:e.x,y:e.y+o*r,width:s,height:i};this.effect3d?this.drawSquare3d(t,n,o):this.drawSquare2d(t,n,o)}else{let n=Math.min(s,i),a={x:e.x,y:e.y+o*r,width:n,height:n};this.effect3d?this.drawCircle3d(t,a,o):this.drawCircle2d(t,a,o)}}drawCircle2d(t,e,i){let r=e.x+e.width/2,s=e.y+e.height/2,o=e.width/2,n=e.height/2;this.ledBorder>0&&(o-=this.ledBorder/2,n-=this.ledBorder/2),t.fillEllipse({cx:r,cy:s,rx:o,ry:n,color:this.getLedColor(i)}),t.strokeEllipse({cx:r,cy:s,rx:o,ry:n,color:this.ledBorderColor,lineWidth:this.ledBorder})}drawCircle3d(t,e,i){let r=e.x+e.width/2,s=e.y+e.height/2,o=e.width/2,n=e.height/2;t.fillEllipse({cx:r,cy:s,rx:o,ry:n,color:m.WHITE});let a=t.createLinearGradient(e.x,e.y,e.x+e.width,e.y+e.height);a.addColorStop(0,this.ledBorderColor.toString()),a.addColorStop(1,this.ledBorderColor.withAlpha(0).toString()),t.fillEllipse({cx:r,cy:s,rx:o,ry:n,gradient:a});let h=e.width-2*this.ledBorder,l=e.height-2*this.ledBorder;o=h/2,n=l/2,t.fillEllipse({cx:r,cy:s,rx:o,ry:n,color:this.getLedColor(i)}),a=t.createLinearGradient(e.x,e.y,e.x+e.width,e.y+e.height),a.addColorStop(0,m.WHITE.toString()),a.addColorStop(1,this.ledBorderColor.withAlpha(0).toString()),t.fillEllipse({cx:r,cy:s,rx:o,ry:n,gradient:a})}drawSquare2d(t,e,i){let r=It(e.x,e.y,e.width,e.height,this.ledBorder);t.fillRect({...r,color:this.getLedColor(i)}),t.strokeRect({...r,color:this.ledBorderColor,lineWidth:this.ledBorder})}drawSquare3d(t,e,i){t.fillRect({...e,color:this.ledBorderColor});let r=t.createLinearGradient(e.x,e.y,e.x+e.width,e.y);r.addColorStop(0,"rgba(0,0,0,0.078)"),r.addColorStop(1,"rgba(0,0,0,0.39)"),t.fillPath({gradient:r,path:new R(e.x,e.y).lineTo(e.x+this.ledBorder,e.y+this.ledBorder).lineTo(e.x+this.ledBorder,e.y+e.height-this.ledBorder).lineTo(e.x,e.y+e.height)}),r=t.createLinearGradient(e.x,e.y,e.x,e.y+e.height),r.addColorStop(0,"rgba(0,0,0,0.078)"),r.addColorStop(1,"rgba(0,0,0,0.39)"),t.fillPath({gradient:r,path:new R(e.x,e.y).lineTo(e.x+this.ledBorder,e.y+this.ledBorder).lineTo(e.x+e.width-this.ledBorder,e.y+this.ledBorder).lineTo(e.x+e.width,e.y)}),r=t.createLinearGradient(e.x,e.y,e.x+e.width,e.y),r.addColorStop(0,"rgba(255,255,255,0.078)"),r.addColorStop(1,"rgba(255,255,255,0.39)"),t.fillPath({gradient:r,path:new R(e.x+e.width,e.y).lineTo(e.x+e.width-this.ledBorder,e.y+this.ledBorder).lineTo(e.x+e.width-this.ledBorder,e.y+e.height-this.ledBorder).lineTo(e.x+e.width,e.y+e.height)}),r=t.createLinearGradient(e.x,e.y,e.x,e.y+e.height),r.addColorStop(0,"rgba(255,255,255,0.078)"),r.addColorStop(1,"rgba(255,255,255,0.39)"),t.fillPath({gradient:r,path:new R(e.x,e.y+e.height).lineTo(e.x+this.ledBorder,e.y+e.height-this.ledBorder).lineTo(e.x+e.width-this.ledBorder,e.y+e.height-this.ledBorder).lineTo(e.x+e.width,e.y+e.height)});let s=e.x+this.ledBorder,o=e.y+this.ledBorder,n=e.width-2*this.ledBorder,a=e.height-2*this.ledBorder,h=this.getLedColor(i);t.fillRect({x:s,y:o,width:n,height:a,color:h}),r=t.createLinearGradient(e.x,e.y,e.x+e.width,e.y+e.height),r.addColorStop(0,"rgba(255,255,255,0.784)"),r.addColorStop(1,h.withAlpha(0).toString()),t.fillRect({x:s,y:o,width:n,height:a,gradient:r})}get bitReverse(){return this.properties.getValue(ad)}get horizontal(){return this.properties.getValue(ld)}get numBits(){return this.properties.getValue(ud)}get startBit(){return this.properties.getValue(fd)}get ledPacked(){return this.properties.getValue(dd)}get ledBorder(){return this.scale*this.properties.getValue(cd)}get ledBorderColor(){return this.properties.getValue(pd)}get offColor(){return this.properties.getValue(gd)}get onColor(){return this.properties.getValue(md)}get effect3d(){return this.properties.getValue(hd)}get squareLed(){return this.properties.getValue(wd)}};var xd=new m(100,100,100),Ty=16,Sy=8,Ly=5,Cy=-1,yd="color_hi",Pd="color_hihi",bd="color_lo",vd="color_lolo",Rd="effect_3d",_d="font",Td="value_label_format",Sd="level_hi",Ld="level_hihi",Cd="level_lo",Ad="level_lolo",Od="limits_from_pv",Ed="log_scale",Md="major_tick_step_hint",Vd="minimum",Id="maximum",Bd="needle_color",Hd="ramp_gradient",Dd="scale_font",Wd="scale_format",kd="show_minor_ticks",Nd="show_markers",Fd="show_scale",Ay="scale_options",Hr=225,Gd=315;var Dr=class extends M{constructor(t,e){super(t,e),this.properties.add(new S(yd)),this.properties.add(new S(Pd)),this.properties.add(new S(bd)),this.properties.add(new S(vd)),this.properties.add(new f(Rd)),this.properties.add(new H(_d)),this.properties.add(new C(Sd)),this.properties.add(new C(Ld)),this.properties.add(new C(Cd)),this.properties.add(new C(Ad)),this.properties.add(new f(Ed)),this.properties.add(new f(Od,!0)),this.properties.add(new P(Md,50)),this.properties.add(new C(Id)),this.properties.add(new C(Vd)),this.properties.add(new S(Bd)),this.properties.add(new f(Hd)),this.properties.add(new H(Dd)),this.properties.add(new T(Wd)),this.properties.add(new f(kd,!0)),this.properties.add(new f(Nd,!0)),this.properties.add(new f(Fd,!0)),this.properties.add(new T(Td)),this.properties.add(new Q(Ay,new Z(!0,!0,!0)))}draw(t){let e;this.limitsFromPv&&this.pv&&!this.pv.disconnected?e={min:this.pv.lowerDisplayLimit??this.minimum,lolo:this.pv.lowerAlarmLimit,lo:this.pv.lowerWarningLimit,hi:this.pv.upperWarningLimit,hihi:this.pv.upperAlarmLimit,max:this.pv.upperDisplayLimit??this.maximum}:e={min:this.minimum,lolo:this.levelLoLo,lo:this.levelLo,hi:this.levelHi,hihi:this.levelHiHi,max:this.maximum},this.logScale&&(e.min=Math.max(.1,e.min),e.max<=e.min&&(e.max=e.min+100));let i=Math.min(this.width,this.height),r=i;this.drawBackground(t,i,r),this.showRamp&&this.drawRamp(t,i,r,e),this.showScale&&this.drawScale(t,i,r,e),this.drawLabel(t,i,r,e),this.drawNeedle(t,i,r,e),this.drawNeedleCenter(t,i,r)}drawBackground(t,e,i){if(t.fillEllipse({cx:this.x+e/2,cy:this.y+i/2,rx:e/2,ry:i/2,color:m.GRAY}),this.effect3d){let s=t.createLinearGradient(this.x,this.y,this.x+this.width,this.y+this.height);s.addColorStop(0,xd.toString()),s.addColorStop(1,m.WHITE.toString()),t.fillEllipse({cx:this.x+e/2,cy:this.y+i/2,rx:e/2,ry:i/2,gradient:s})}let r=(this.effect3d?2:1)*this.scale;if(t.fillEllipse({cx:this.x+e/2,cy:this.y+i/2,rx:e/2-r,ry:i/2-r,color:this.backgroundColor}),this.effect3d){let s=e/2,o=9.5/10,n=1/2,a=8.5/10,h=G(0),l=G(35),c={x:Math.floor(this.x+e/2-s*a*Math.cos(h)),y:Math.floor(this.y+i/2-s*o),width:Math.floor(2*s*a*Math.cos(h)),height:Math.floor(s*o+s*n)},d=t.createLinearGradient(c.x,c.y,c.x,c.y+c.height);d.addColorStop(0,m.WHITE.withAlpha(90/255).toString()),d.addColorStop(1,m.WHITE.withAlpha(0).toString()),t.fillEllipse({cx:c.x+c.width/2,cy:c.y+c.height/2,rx:c.width/2,ry:c.height/2,gradient:d}),c={x:Math.floor(this.x+e/2-s*a*Math.sin(l)),y:Math.floor(Math.ceil(this.y+i/2+s*n)),width:Math.floor(2*s*a*Math.sin(l)),height:Math.floor(Math.ceil(s*o-s*n))},d=t.createLinearGradient(c.x,c.y,c.x,c.y+c.height),d.addColorStop(0,m.WHITE.withAlpha(0).toString()),d.addColorStop(1,m.WHITE.withAlpha(40/255).toString()),t.fillEllipse({cx:c.x+c.width/2,cy:c.y+c.height/2,rx:c.width/2,ry:c.height/2,gradient:d})}}drawRamp(t,e,i,r){let s=D({x:this.x,y:this.y,width:e,height:i},e/4,i/4),o={...s};o.width=Math.min(s.width,s.height),o.height=s.width;let n=new jt(10*this.scale,225,315);n.lolo=r.lolo,n.loloColor=this.colorLoLo,n.lo=r.lo,n.loColor=this.colorLo,n.hi=r.hi,n.hiColor=this.colorHi,n.hihi=r.hihi,n.hihiColor=this.colorHiHi,n.minimum=r.min,n.maximum=r.max,n.effect3d=this.effect3d,n.gradient=this.rampGradient,n.logScale=this.logScale,n.draw(t,s,o)}drawScale(t,e,i,r){let s=new Zt(Hr,Gd,"inward");s.minimum=r.min,s.maximum=r.max,s.logScale=this.logScale,s.showMinorTicks=this.showMinorTicks,s.majorTickStepHint=this.majorTickStepHint*this.scale,s.majorTickLength=this.majorTickLength,s.minorTickLength=this.minorTickLength,s.majorLineWidth=2*this.scale,s.minorLineWidth=1*this.scale,s.format=this.scaleFormat,s.font=this.scaleFont,s.foregroundColor=this.foregroundColor,s.draw(t,{x:this.x,y:this.y,width:e,height:i})}drawLabel(t,e,i,r){let s=U.ARIAL_12_BOLD.scale(this.scale);if(this.value!==void 0){let o=this.formatLabelValue(this.value,r),n=t.measureText(o,s);t.fillText({x:this.x+e/2-n.width/2,y:this.y+i*7/8-n.height/2,color:this.foregroundColor,align:"left",baseline:"top",font:s,text:o})}}drawNeedle(t,e,i,r){let s=this.x+e/2,o=this.y+i/2,n;if(this.value!==void 0){let _=this.getValueInRange(this.value,r);n=360-this.getValuePosition(_,r),r.max>r.min?_>r.max?n+=10:_<r.min&&(n-=10):_>r.min?n-=10:_<r.max&&(n+=10)}else n=360-this.getValuePosition((r.min+r.max)/2,r);let a=G(n),{scale:h}=this,{needleDiameter:l,majorTickLength:c,gapBetweenNeedleScale:d}=this,g=Rt(s,o-l/2+3*h,s,o,a),w=Rt(s+e/2-c-d,o,s,o,a),x=Rt(s,o+l/2-3*h,s,o,a);t.fillPath({color:this.needleColor,path:new R(g.x,g.y).lineTo(w.x,w.y).lineTo(x.x,x.y).closePath()})}drawNeedleCenter(t,e,i){let{needleDiameter:r}=this,s=this.x+e/2,o=this.y+i/2,n=r/2,a=r/2;if(this.effect3d){let h=t.createLinearGradient(s-n,o-a,s+n,o+a);h.addColorStop(0,m.WHITE.toString()),h.addColorStop(1,xd.toString()),t.fillEllipse({cx:s,cy:o,rx:n,ry:a,gradient:h})}else t.fillEllipse({cx:s,cy:o,rx:n,ry:a,color:m.GRAY})}getValueInRange(t,e){return e.min<=t&&t<=e.max?t:t>e.max?e.max:e.min}getValuePosition(t,e){let i=360-(Gd-Hr),r;return this.logScale?r=Hr-(Math.log10(t)-Math.log10(e.min))/(Math.log10(e.max)-Math.log10(e.min))*i:r=Hr-(t-e.min)/(e.max-e.min)*i,r<0&&(r+=360),r}formatLabelValue(t,e){if(this.valueLabelFormat)return new it(this.valueLabelFormat).format(t);{let i=Kt(e.min,e.max);return new it(i).format(t)}}get needleDiameter(){return this.scale*Ty}get majorTickLength(){return this.scale*Sy}get minorTickLength(){return this.scale*Ly}get gapBetweenNeedleScale(){return this.scale*Cy}get colorLo(){return this.properties.getValue(bd)}get colorLoLo(){return this.properties.getValue(vd)}get colorHi(){return this.properties.getValue(yd)}get colorHiHi(){return this.properties.getValue(Pd)}get effect3d(){return this.properties.getValue(Rd)}get font(){return this.properties.getValue(_d).scale(this.scale)}get levelLo(){return this.properties.getValue(Cd)}get levelLoLo(){return this.properties.getValue(Ad)}get levelHi(){return this.properties.getValue(Sd)}get levelHiHi(){return this.properties.getValue(Ld)}get limitsFromPv(){return this.properties.getValue(Od)}get logScale(){return this.properties.getValue(Ed)}get majorTickStepHint(){return this.properties.getValue(Md)}get minimum(){return this.properties.getValue(Vd)}get maximum(){return this.properties.getValue(Id)}get needleColor(){return this.properties.getValue(Bd)}get rampGradient(){return this.properties.getValue(Hd)}get scaleFont(){return this.properties.getValue(Dd).scale(this.scale)}get scaleFormat(){return this.properties.getValue(Wd)}get showMinorTicks(){return this.properties.getValue(kd)}get showRamp(){return this.properties.getValue(Nd)}get showScale(){return this.properties.getValue(Fd)}get valueLabelFormat(){return this.properties.getValue(Td)}};var $d="auto_size",Ud="bit",Yd="data_type",Oy="height",zd="off_image",Xd="off_label",qd="font",Kd="on_image",jd="on_label",Zd="show_boolean_label",Jd="stretch_to_fit",Ey="width",Wr=class extends M{onImageElement;onImageLoaded=!1;offImageElement;offImageLoaded=!1;constructor(t,e){super(t,e),this.properties.add(new f($d,!0)),this.properties.add(new P(Ud)),this.properties.add(new P(Yd)),this.properties.add(new T(zd)),this.properties.add(new T(Xd)),this.properties.add(new T(Kd)),this.properties.add(new T(jd)),this.properties.add(new H(qd)),this.properties.add(new f(Zd)),this.properties.add(new f(Jd,!1))}init(){if(this.onImageElement=new Image,this.onImageElement.onload=()=>{this.onImageLoaded=!0,this.applyAutoSize(),this.requestRepaint()},this.offImageElement=new Image,this.offImageElement.onload=()=>{this.offImageLoaded=!0,this.applyAutoSize(),this.requestRepaint()},this.onImage){let t=this.onImageElement;this.display.getImageLoader().load(this.resolvePath(this.onImage)).then(e=>{t.src=e})}if(this.offImage){let t=this.offImageElement;this.display.getImageLoader().load(this.resolvePath(this.offImage)).then(e=>{t.src=e})}}get booleanValue(){return this.bit<0?!!this.value:this.value!==void 0?(this.value>>this.bit&1)>0:!1}get image(){return this.booleanValue?this.onImage:this.offImage}get label(){return this.booleanValue?this.onLabel:this.offLabel}applyAutoSize(){if(!this.autoSize||this.stretchToFit)return;let t=this.booleanValue?this.onImageElement:this.offImageElement,e=this.booleanValue?this.onImageLoaded:this.offImageLoaded;t&&e&&(this.properties.setValue(Ey,t.naturalWidth),this.properties.setValue(Oy,t.naturalHeight))}autoScale(t,e){M.prototype.autoScale.call(this,t,e),this.applyAutoSize()}draw(t){let e=this.booleanValue?this.onImageElement:this.offImageElement,i=this.booleanValue?this.onImageLoaded:this.offImageLoaded,r=this.stretchToFit?this.width:e?.naturalWidth,s=this.stretchToFit?this.height:e?.naturalHeight;this.transparent||t.fillRect({x:this.x,y:this.y,width:i?r:this.width,height:i?s:this.height,color:this.backgroundColor}),e&&i&&t.ctx.drawImage(e,this.x,this.y,r,s),this.showBooleanLabel&&t.fillText({x:this.x+this.width/2,y:this.y+this.height/2,font:this.font,baseline:"middle",align:"center",color:this.foregroundColor,text:this.label})}get autoSize(){return this.properties.getValue($d)}get stretchToFit(){return this.properties.getValue(Jd)}get bit(){return this.properties.getValue(Ud)}get dataType(){return this.properties.getValue(Yd)}get showBooleanLabel(){return this.properties.getValue(Zd)}get font(){return this.properties.getValue(qd).scale(this.scale)}get offLabel(){return this.properties.getValue(Xd)}get offImage(){return this.properties.getValue(zd)}get onLabel(){return this.properties.getValue(jd)}get onImage(){return this.properties.getValue(Kd)}};var kr=class{constructor(t,e){this.widget=e;this.id=t}widget;id;selection;grabStart;mouseDown(t){this.grabStart=t}grab(t){this.grabStart&&(this.selection={...this.grabStart.point,width:t.dx,height:t.dy},this.widget.requestRepaint())}grabEnd(){let{selection:t}=this;t&&t.width&&t.height&&this.widget.applyRubberBandZoom(t),this.selection=void 0,this.grabStart=void 0,this.widget.requestRepaint()}dblclick(){this.widget.resetZoom(),this.widget.requestRepaint()}};var Qd="color_depth",My=0,Vy=1,Iy=2,By=3,Hy=4,Dy=5,tu="color_map",eu="crop_bottom",iu="crop_left",ru="crop_right",su="crop_top",ou="data_height",nu="data_width",au="font",hu="graph_area_height",lu="graph_area_width",Wy=25,cu="horizon_profile_x_pv_name",pu="horizon_profile_y_pv_name",du="vertical_profile_x_pv_name",uu="vertical_profile_y_pv_name",gu="maximum",mu="minimum",fu="rgb_mode",wu="show_ramp",xu="x_axis_axis_color",yu="x_axis_axis_title",Pu="x_axis_major_tick_step_hint",bu="x_axis_maximum",vu="x_axis_minimum",Ru="x_axis_scale_font",_u="x_axis_show_minor_ticks",Tu="x_axis_title_font",Su="x_axis_visible",Lu="y_axis_axis_color",Cu="y_axis_axis_title",Au="y_axis_major_tick_step_hint",Ou="y_axis_maximum",Eu="y_axis_minimum",Mu="y_axis_scale_font",Vu="y_axis_show_minor_ticks",Iu="y_axis_title_font",Bu="y_axis_visible",ky="scale_options",Nr=class extends M{region;xScale;yScale;graphAreaX=0;graphAreaY=0;renderedGraphAreaWidth=0;renderedGraphAreaHeight=0;_effectiveCropLeft;_effectiveCropRight;_effectiveCropTop;_effectiveCropBottom;_effectiveXAxisMinimum;_effectiveXAxisMaximum;_effectiveYAxisMinimum;_effectiveYAxisMaximum;originalState;constructor(t,e){super(t,e),this.properties.add(new P(Qd,My)),this.properties.add(new se(tu)),this.properties.add(new P(eu)),this.properties.add(new P(iu)),this.properties.add(new P(ru)),this.properties.add(new P(su)),this.properties.add(new P(ou)),this.properties.add(new P(nu)),this.properties.add(new P(hu)),this.properties.add(new P(lu)),this.properties.add(new T(cu)),this.properties.add(new T(pu)),this.properties.add(new T(du)),this.properties.add(new T(uu)),this.properties.add(new H(au)),this.properties.add(new C(gu)),this.properties.add(new C(mu)),this.properties.add(new f(fu,!1)),this.properties.add(new f(wu)),this.properties.add(new S(xu)),this.properties.add(new T(yu)),this.properties.add(new P(Pu)),this.properties.add(new C(bu)),this.properties.add(new C(vu)),this.properties.add(new H(Ru)),this.properties.add(new f(_u)),this.properties.add(new H(Tu)),this.properties.add(new f(Su)),this.properties.add(new S(Lu)),this.properties.add(new T(Cu)),this.properties.add(new P(Au)),this.properties.add(new C(Ou)),this.properties.add(new C(Eu)),this.properties.add(new H(Mu)),this.properties.add(new f(Vu)),this.properties.add(new H(Iu)),this.properties.add(new f(Bu)),this.properties.add(new Q(ky,new Z(!0,!0,!0)))}init(){this.region=new kr(`${this.wuid}-graph`,this)}draw(t){let{scale:e}=this,i=this.area;this.borderAlarmSensitive&&(i=D(i,2*e));let r=this.alarmSensitiveBackgroundColor;t.fillRect({...i,color:r});let{minimum:s,maximum:o}=this,n=0;this.xAxisVisible&&(n=t.measureText(this.xAxisAxisTitle,this.xAxisTitleFont).height);let a=0;this.yAxisVisible&&(a=t.measureText(this.yAxisAxisTitle,this.yAxisTitleFont).height);let h=this.xScale=new ot(this.display.formatter,e,this.xAxisScaleFont,this.effectiveXAxisMinimum,this.effectiveXAxisMaximum,!1,this.xAxisMajorTickStepHint,this.xAxisAxisColor,this.xAxisShowMinorTicks,this.xAxisVisible),l=h.calculateMargin(t,!0),c=this.yScale=new ot(this.display.formatter,e,this.yAxisScaleFont,this.effectiveYAxisMinimum,this.effectiveYAxisMaximum,!1,this.yAxisMajorTickStepHint,this.yAxisAxisColor,this.yAxisShowMinorTicks,this.yAxisVisible),d=c.calculateMargin(t,!1),g=h.measureHorizontalHeight(t),w=i.height-n-g-d,x=w+2*d,_=c.drawVertical(t,i.x+a,i.y,x,!0),L=this.showRamp&&!this.rgbMode,A,E=0,I=0,k=0;L&&(A=new ot(this.display.formatter,e,this.font,s,o,!1,50*e,this.alarmSensitiveForegroundColor,!1,!0),E=i.y+d,I=w,k=A.drawVertical(t,i.x+i.width,E,I,!1,!0));let F=e*Wy,Y=L?F+k+this.gap:0,K=i.width-a-_-Y,mt=K+2*l,ht=i.x+a+_-l,Lt=i.y+x+g-d;h.drawHorizontal(t,ht,Lt,mt);let pt=e*1,xt=Math.round(i.x+a+_)-pt/2,yt=Math.round(i.y+d)-pt/2;t.strokePath({path:new R(xt,yt).lineTo(xt,yt+w),color:this.yAxisAxisColor,opacity:100/255,lineWidth:pt});let kt=xt,Qt=yt+w+pt;t.strokePath({path:new R(kt,Qt).lineTo(kt+K,Qt),color:this.xAxisAxisColor,opacity:100/255,lineWidth:pt});let{dataWidth:Nt,dataHeight:Me,colorMap:te}=this,[ce,oi]=te.getMinMax(),Ve=this.graphAreaX=Math.round(i.x+a+_),Ie=this.graphAreaY=Math.round(i.y+c.margin);this.renderedGraphAreaWidth=K,this.renderedGraphAreaHeight=w,this.region&&t.addHitRegion(this.region).addRect(Ve,Ie,K,w);let ni=this.rgbMode;if(this.value&&this.value.length&&(!ni||this.value.length>=3*Nt*Me)){let lt=document.createElement("canvas"),{effectiveCropLeft:Ct,effectiveCropRight:Ft,effectiveCropTop:ut,effectiveCropBottom:ee}=this;lt.width=Nt-Ct-Ft,lt.height=Me-ut-ee;let At=lt.getContext("2d");for(let nt=Ct;nt<Nt-Ft;nt++)for(let ct=ut;ct<Me-ee;ct++){if(ni){let at=(ct*Nt+nt)*3,Ot=this.applyColorDepth(this.value[at],s,o),wt=this.applyColorDepth(this.value[at+1],s,o),j=this.applyColorDepth(this.value[at+2],s,o);At.fillStyle=`rgb(${Ot},${wt},${j})`}else{let at=this.value[ct*Nt+nt];if(te.autoscale){let Et=(at-s)/(o-s);at=ce+Et*(oi-ce)}let[Ot,wt,j]=te.lookup(at);At.fillStyle=`rgb(${Ot},${wt},${j})`}At.fillRect(nt-Ct,ct-ut,1,1)}t.ctx.drawImage(lt,Ve,Ie,K,w);let dt=lt.width,ft=lt.height;if(this.horizonProfileXPvName||this.horizonProfileYPvName){let nt=new Array(dt);for(let j=0;j<dt;j++){let Et=0;for(let Pt=0;Pt<ft;Pt++)Et+=this.pixelValueAt(ut+Pt,Ct+j);nt[j]=Et/ft}let{effectiveXAxisMinimum:ct,effectiveXAxisMaximum:at}=this,Ot=dt>1?(at-ct)/(dt-1):0,wt=new Array(dt);for(let j=0;j<dt;j++)wt[j]=ct+j*Ot;this.pushProfilePV(this.horizonProfileXPvName,wt),this.pushProfilePV(this.horizonProfileYPvName,nt)}if(this.verticalProfileXPvName||this.verticalProfileYPvName){let nt=new Array(ft);for(let j=0;j<ft;j++){let Et=0;for(let Pt=0;Pt<dt;Pt++)Et+=this.pixelValueAt(ut+j,Ct+Pt);nt[j]=Et/dt}let{effectiveYAxisMinimum:ct,effectiveYAxisMaximum:at}=this,Ot=ft>1?(at-ct)/(ft-1):0,wt=new Array(ft);for(let j=0;j<ft;j++)wt[j]=at-j*Ot;this.pushProfilePV(this.verticalProfileXPvName,wt),this.pushProfilePV(this.verticalProfileYPvName,nt)}}if(L&&A){let lt=i.x+i.width-k-F,Ct=F,Ft=I-2*A.margin,ut=document.createElement("canvas");ut.width=Ct,ut.height=Ft;let ee=ut.getContext("2d");for(let At=0;At<Ft;At++){let dt=o-At/Ft*(o-s);if(te.autoscale){let at=(dt-s)/(o-s);dt=ce+at*(oi-ce)}let[ft,nt,ct]=te.lookup(dt);ee.fillStyle=`rgb(${ft},${nt},${ct})`,ee.fillRect(0,At,Ct,1)}t.ctx.drawImage(ut,lt,E+A.margin)}if(this.xAxisVisible){let lt=i.x+_+K/2;this.yAxisVisible&&(lt+=a),t.fillText({x:lt,y:i.y+i.height,align:"center",baseline:"bottom",font:this.xAxisTitleFont,color:this.xAxisAxisColor,text:this.xAxisAxisTitle})}this.yAxisVisible&&(t.ctx.save(),t.ctx.translate(i.x+a/2,i.y+x/2),t.ctx.rotate(-Math.PI/2),t.fillText({x:0,y:0,align:"center",baseline:"middle",font:this.yAxisTitleFont,color:this.yAxisAxisColor,text:this.yAxisAxisTitle}),t.ctx.restore());let ai=this.region?.selection;if(ai){let lt={x:Ve,y:Ie,width:K,height:w};t.strokeRect({...gi(lt,ai),color:m.BLACK,lineWidth:e,dash:[2*e,2*e]})}}applyRubberBandZoom(t){if(!this.xScale||!this.yScale||!this.renderedGraphAreaWidth||!this.renderedGraphAreaHeight)return;this.originalState||(this.originalState={cropLeft:this.effectiveCropLeft,cropRight:this.effectiveCropRight,cropTop:this.effectiveCropTop,cropBottom:this.effectiveCropBottom,xAxisMinimum:this.effectiveXAxisMinimum,xAxisMaximum:this.effectiveXAxisMaximum,yAxisMinimum:this.effectiveYAxisMinimum,yAxisMaximum:this.effectiveYAxisMaximum});let{dataWidth:e,dataHeight:i,graphAreaX:r,graphAreaY:s}=this,{renderedGraphAreaWidth:o,renderedGraphAreaHeight:n}=this,a=this.effectiveCropLeft,h=this.effectiveCropRight,l=this.effectiveCropTop,c=this.effectiveCropBottom,d=e-a-h,g=i-l-c,w=Math.min(t.x,t.x+t.width),x=Math.max(t.x,t.x+t.width),_=Math.min(t.y,t.y+t.height),L=Math.max(t.y,t.y+t.height),A=(kt,Qt)=>({x:Math.round(d*(kt-r)/o),y:Math.round(g*(Qt-s)/n)}),E=A(w,_),I=A(x,L),k=a+E.x,F=l+E.y,Y=h+d-I.x,K=c+g-I.y;if(k+Y>=e||F+K>=i)return;this.effectiveCropLeft=k,this.effectiveCropTop=F,this.effectiveCropRight=Y,this.effectiveCropBottom=K;let mt=this.xScale.getMinMax(),ht=this.xScale.getPositionValue(t.x),Lt=this.xScale.getPositionValue(t.x+t.width);ht>Lt&&([ht,Lt]=[Lt,ht]),this.effectiveXAxisMinimum=Math.max(mt.start,ht),this.effectiveXAxisMaximum=Math.min(mt.stop,Lt);let pt=this.yScale.getMinMax(),xt=this.yScale.getPositionValue(t.y),yt=this.yScale.getPositionValue(t.y+t.height);xt>yt&&([xt,yt]=[yt,xt]),this.effectiveYAxisMinimum=Math.max(pt.start,xt),this.effectiveYAxisMaximum=Math.min(pt.stop,yt)}resetZoom(){let{originalState:t}=this;t&&(this.effectiveCropLeft=t.cropLeft,this.effectiveCropRight=t.cropRight,this.effectiveCropTop=t.cropTop,this.effectiveCropBottom=t.cropBottom,this.effectiveXAxisMinimum=t.xAxisMinimum,this.effectiveXAxisMaximum=t.xAxisMaximum,this.effectiveYAxisMinimum=t.yAxisMinimum,this.effectiveYAxisMaximum=t.yAxisMaximum)}pushProfilePV(t,e){t&&(this.display.pvEngine.createPV(t),this.display.pvEngine.setValue(new Date,t,e))}applyColorDepth(t,e,i){let r=Math.trunc(t);switch(this.colorDepth){case Vy:return r>>8;case Iy:return r>>16;case By:return r>>22;case Dy:return r&255;case Hy:return Math.trunc((t-e)/(i-e)*255);default:return r}}pixelValueAt(t,e){if(this.rgbMode){let i=(t*this.dataWidth+e)*3;return(this.value[i]+this.value[i+1]+this.value[i+2])/3}return this.value[t*this.dataWidth+e]}get effectiveCropLeft(){return this._effectiveCropLeft??this.cropLeft}set effectiveCropLeft(t){this._effectiveCropLeft=t}get effectiveCropRight(){return this._effectiveCropRight??this.cropRight}set effectiveCropRight(t){this._effectiveCropRight=t}get effectiveCropTop(){return this._effectiveCropTop??this.cropTop}set effectiveCropTop(t){this._effectiveCropTop=t}get effectiveCropBottom(){return this._effectiveCropBottom??this.cropBottom}set effectiveCropBottom(t){this._effectiveCropBottom=t}get effectiveXAxisMinimum(){return this._effectiveXAxisMinimum??this.xAxisMinimum}set effectiveXAxisMinimum(t){this._effectiveXAxisMinimum=t}get effectiveXAxisMaximum(){return this._effectiveXAxisMaximum??this.xAxisMaximum}set effectiveXAxisMaximum(t){this._effectiveXAxisMaximum=t}get effectiveYAxisMinimum(){return this._effectiveYAxisMinimum??this.yAxisMinimum}set effectiveYAxisMinimum(t){this._effectiveYAxisMinimum=t}get effectiveYAxisMaximum(){return this._effectiveYAxisMaximum??this.yAxisMaximum}set effectiveYAxisMaximum(t){this._effectiveYAxisMaximum=t}get gap(){return this.scale*3}get colorDepth(){return this.properties.getValue(Qd)}get colorMap(){return this.properties.getValue(tu)}get cropBottom(){return this.properties.getValue(eu)}get cropLeft(){return this.properties.getValue(iu)}get cropRight(){return this.properties.getValue(ru)}get cropTop(){return this.properties.getValue(su)}get dataHeight(){return this.properties.getValue(ou)}get dataWidth(){return this.properties.getValue(nu)}get font(){return this.properties.getValue(au).scale(this.scale)}get graphAreaHeight(){return this.scale*this.properties.getValue(hu)}get graphAreaWidth(){return this.scale*this.properties.getValue(lu)}get horizonProfileXPvName(){return this.properties.getValue(cu)}get horizonProfileYPvName(){return this.properties.getValue(pu)}get verticalProfileXPvName(){return this.properties.getValue(du)}get verticalProfileYPvName(){return this.properties.getValue(uu)}get maximum(){return this.properties.getValue(gu)}get minimum(){return this.properties.getValue(mu)}get rgbMode(){return this.properties.getValue(fu)}get showRamp(){return this.properties.getValue(wu)}get xAxisAxisColor(){return this.properties.getValue(xu)}get xAxisAxisTitle(){return this.properties.getValue(yu)}get xAxisMajorTickStepHint(){return this.scale*this.properties.getValue(Pu)}get xAxisMaximum(){return this.properties.getValue(bu)}get xAxisMinimum(){return this.properties.getValue(vu)}get xAxisScaleFont(){return this.properties.getValue(Ru).scale(this.scale)}get xAxisShowMinorTicks(){return this.properties.getValue(_u)}get xAxisTitleFont(){return this.properties.getValue(Tu).scale(this.scale)}get xAxisVisible(){return this.properties.getValue(Su)}get yAxisAxisColor(){return this.properties.getValue(Lu)}get yAxisAxisTitle(){return this.properties.getValue(Cu)}get yAxisMajorTickStepHint(){return this.scale*this.properties.getValue(Au)}get yAxisMaximum(){return this.properties.getValue(Ou)}get yAxisMinimum(){return this.properties.getValue(Eu)}get yAxisScaleFont(){return this.properties.getValue(Mu).scale(this.scale)}get yAxisShowMinorTicks(){return this.properties.getValue(Vu)}get yAxisTitleFont(){return this.properties.getValue(Iu).scale(this.scale)}get yAxisVisible(){return this.properties.getValue(Bu)}};var Hu="bit",Du="data_type",Wu="effect_3d",ku="state_count",Nu="square_led",Fu="off_color",Gu="off_label",$u="off_state",Uu="font",Yu="on_color",zu="on_label",Xu="on_state",qu="bulb_border",Ku="bulb_border_color",ju="state_color_fallback",Zu="state_label_fallback",Ju="show_boolean_label",Ny="scale_options",Fr=class extends M{areaRegion;states=[];constructor(t,e){super(t,e),this.properties.add(new P(Hu)),this.properties.add(new P(Du)),this.properties.add(new f(Wu)),this.properties.add(new f(Nu)),this.properties.add(new P(ku,2)),this.properties.add(new S(Fu)),this.properties.add(new T(Gu)),this.properties.add(new T($u)),this.properties.add(new S(Yu)),this.properties.add(new T(zu)),this.properties.add(new T(Xu)),this.properties.add(new H(Uu)),this.properties.add(new f(Ju)),this.properties.add(new S(ju)),this.properties.add(new T(Zu)),this.properties.add(new P(qu,3)),this.properties.add(new S(Ku,m.DARK_GRAY)),this.properties.add(new Q(Ny,new Z(!0,!0,!0)))}async parseNode(t){if(await super.parseNode(t),this.stateCount>2)for(let e=0;e<this.stateCount;e++){let i=new S(`state_color_${e}`);i.value=t.getColor(`state_color_${e}`),this.properties.add(i);let r=new T(`state_label_${e}`);r.value=t.getString(`state_label_${e}`),this.properties.add(r);let s=new C(`state_value_${e}`);s.value=t.getFloat(`state_value_${e}`),this.properties.add(s),this.states.push({label:this.properties.getValue(r.name),color:this.properties.getValue(i.name),value:this.properties.getValue(s.name)})}}init(){this.areaRegion={id:`${this.wuid}-area`,click:()=>{let t={pvName:this.pvName};this.display.fireEvent("openpv",t)},cursor:"pointer",tooltip:()=>this.tooltip}}get booleanValue(){return this.dataType===0?this.bit<0?!!this.value:this.value!==void 0?(this.value>>this.bit&1)>0:!1:this.dataType===1?(this.value!==void 0?String(this.value):void 0)===this.onState:!1}get bulbColor(){if(this.stateCount<=2)return this.booleanValue?this.onColor:this.offColor;for(let t of this.states)if(t.value===this.value)return t.color;return this.stateColorFallback}get label(){if(this.stateCount===2)return this.booleanValue?this.onLabel:this.offLabel;for(let t of this.states)if(t.value===this.value)return t.label;return this.stateLabelFallback}draw(t){let e=D(this.bounds,3*this.scale);if(this.squareLed?this.effect3d?this.drawSquare3d(t,e):this.drawSquare2d(t,e):this.effect3d?this.drawCircle3d(t,e):this.drawCircle2d(t,e),this.showBooleanLabel){let i=this.bulbColor;i.red*299+i.green*587+i.blue*114>105e3?i=m.BLACK:i=m.WHITE,t.fillText({x:e.x+e.width/2,y:e.y+e.height/2,font:this.font,baseline:"middle",align:"center",color:i,text:this.label})}}drawCircle2d(t,e){let i=e.x+e.width/2,r=e.y+e.height/2,s=e.width/2,o=e.height/2;this.bulbBorder>0&&(s-=this.bulbBorder/2,o-=this.bulbBorder/2),t.fillEllipse({cx:i,cy:r,rx:s,ry:o,color:this.bulbColor}),t.strokeEllipse({cx:i,cy:r,rx:s,ry:o,color:this.bulbBorderColor,lineWidth:this.bulbBorder}),this.pv&&this.pv.navigable&&!this.pv.disconnected&&t.addHitRegion(this.areaRegion).addEllipse(i,r,s,o,0,0,2*Math.PI)}drawCircle3d(t,e){let i=e.x+e.width/2,r=e.y+e.height/2,s=e.width/2,o=e.height/2;t.fillEllipse({cx:i,cy:r,rx:s,ry:o,color:m.WHITE});let n=t.createLinearGradient(e.x,e.y,e.x+e.width,e.y+e.height);n.addColorStop(0,this.bulbBorderColor.toString()),n.addColorStop(1,this.bulbBorderColor.withAlpha(0).toString()),t.fillEllipse({cx:i,cy:r,rx:s,ry:o,gradient:n});let a=e.width-2*this.bulbBorder,h=e.height-2*this.bulbBorder;s=a/2,o=h/2,t.fillEllipse({cx:i,cy:r,rx:s,ry:o,color:this.bulbColor}),n=t.createLinearGradient(e.x,e.y,e.x+e.width,e.y+e.height),n.addColorStop(0,m.WHITE.toString()),n.addColorStop(1,this.bulbBorderColor.withAlpha(0).toString()),t.fillEllipse({cx:i,cy:r,rx:s,ry:o,gradient:n}),this.pv&&this.pv.navigable&&!this.pv.disconnected&&t.addHitRegion(this.areaRegion).addEllipse(i,r,s,o,0,0,2*Math.PI)}drawSquare2d(t,e){let i=It(e.x,e.y,e.width,e.height,this.bulbBorder);t.fillRect({...i,color:this.bulbColor}),t.strokeRect({...i,color:this.bulbBorderColor,lineWidth:this.bulbBorder}),this.pv&&this.pv.navigable&&!this.pv.disconnected&&t.addHitRegion(this.areaRegion).addRect(e.x,e.y,e.width,e.height)}drawSquare3d(t,e){t.fillRect({...e,color:this.bulbBorderColor}),this.pv&&this.pv.navigable&&!this.pv.disconnected&&t.addHitRegion(this.areaRegion).addRect(e.x,e.y,e.width,e.height);let i=t.createLinearGradient(e.x,e.y,e.x+e.width,e.y);i.addColorStop(0,"rgba(0,0,0,0.078)"),i.addColorStop(1,"rgba(0,0,0,0.39)"),t.fillPath({gradient:i,path:new R(e.x,e.y).lineTo(e.x+this.bulbBorder,e.y+this.bulbBorder).lineTo(e.x+this.bulbBorder,e.y+e.height-this.bulbBorder).lineTo(e.x,e.y+e.height)}),i=t.createLinearGradient(e.x,e.y,e.x,e.y+e.height),i.addColorStop(0,"rgba(0,0,0,0.078)"),i.addColorStop(1,"rgba(0,0,0,0.39)"),t.fillPath({gradient:i,path:new R(e.x,e.y).lineTo(e.x+this.bulbBorder,e.y+this.bulbBorder).lineTo(e.x+e.width-this.bulbBorder,e.y+this.bulbBorder).lineTo(e.x+e.width,e.y)}),i=t.createLinearGradient(e.x,e.y,e.x+e.width,e.y),i.addColorStop(0,"rgba(255,255,255,0.078)"),i.addColorStop(1,"rgba(255,255,255,0.39)"),t.fillPath({gradient:i,path:new R(e.x+e.width,e.y).lineTo(e.x+e.width-this.bulbBorder,e.y+this.bulbBorder).lineTo(e.x+e.width-this.bulbBorder,e.y+e.height-this.bulbBorder).lineTo(e.x+e.width,e.y+e.height)}),i=t.createLinearGradient(e.x,e.y,e.x,e.y+e.height),i.addColorStop(0,"rgba(255,255,255,0.078)"),i.addColorStop(1,"rgba(255,255,255,0.39)"),t.fillPath({gradient:i,path:new R(e.x,e.y+e.height).lineTo(e.x+this.bulbBorder,e.y+e.height-this.bulbBorder).lineTo(e.x+e.width-this.bulbBorder,e.y+e.height-this.bulbBorder).lineTo(e.x+e.width,e.y+e.height)});let r=e.x+this.bulbBorder,s=e.y+this.bulbBorder,o=e.width-2*this.bulbBorder,n=e.height-2*this.bulbBorder;t.fillRect({x:r,y:s,width:o,height:n,color:this.bulbColor}),i=t.createLinearGradient(e.x,e.y,e.x+e.width,e.y+e.height),i.addColorStop(0,"rgba(255,255,255,0.784)"),i.addColorStop(1,this.bulbColor.withAlpha(0).toString()),t.fillRect({x:r,y:s,width:o,height:n,gradient:i})}get bit(){return this.properties.getValue(Hu)}get dataType(){return this.properties.getValue(Du)}get squareLed(){return this.properties.getValue(Nu)}get showBooleanLabel(){return this.properties.getValue(Ju)}get font(){return this.properties.getValue(Uu).scale(this.scale)}get effect3d(){return this.properties.getValue(Wu)}get stateCount(){return this.properties.getValue(ku)}get bulbBorder(){return this.scale*this.properties.getValue(qu)}get bulbBorderColor(){return this.properties.getValue(Ku)}get offLabel(){return this.properties.getValue(Gu)}get offColor(){return this.properties.getValue(Fu)}get offState(){return this.properties.getValue($u)}get onLabel(){return this.properties.getValue(zu)}get onColor(){return this.properties.getValue(Yu)}get onState(){return this.properties.getValue(Xu)}get stateLabelFallback(){return this.properties.getValue(Zu)}get stateColorFallback(){return this.properties.getValue(ju)}};var Fy=16,Gy=12,$y=-5,Ns=45,Gr=G(Ns),Qu=(1-Math.sin(Gr)/2)/(2*Math.cos(Gr)),Uy=8,Yy=5,zy=180-Ns,Xy=Ns,tg="color_hi",eg="color_hihi",ig="color_lo",rg="color_lolo",sg="font",og="level_hi",ng="level_hihi",ag="level_lo",hg="level_lolo",lg="limits_from_pv",cg="log_scale",pg="major_tick_step_hint",dg="minimum",ug="maximum",gg="needle_color",mg="ramp_gradient",fg="scale_font",wg="scale_format",xg="show_hi",yg="show_hihi",Pg="show_lo",bg="show_lolo",vg="show_minor_ticks",Rg="show_markers",_g="show_scale",Tg="show_value_label",Sg="value_label_format",qy="scale_options",$r=class extends M{areaRegion;constructor(t,e){super(t,e),this.properties.add(new S(tg)),this.properties.add(new S(eg)),this.properties.add(new S(ig)),this.properties.add(new S(rg)),this.properties.add(new H(sg)),this.properties.add(new P(og)),this.properties.add(new P(ng)),this.properties.add(new P(ag)),this.properties.add(new P(hg)),this.properties.add(new f(cg)),this.properties.add(new f(lg,!0)),this.properties.add(new P(pg,50)),this.properties.add(new P(ug)),this.properties.add(new P(dg)),this.properties.add(new S(gg)),this.properties.add(new f(mg)),this.properties.add(new H(fg)),this.properties.add(new T(wg)),this.properties.add(new f(xg)),this.properties.add(new f(yg)),this.properties.add(new f(Pg)),this.properties.add(new f(bg)),this.properties.add(new f(vg,!0)),this.properties.add(new f(Rg,!0)),this.properties.add(new f(_g,!0)),this.properties.add(new f(Tg,!0)),this.properties.add(new T(Sg)),this.properties.add(new Q(qy,new Z(!0,!0,!0)))}init(){this.areaRegion={id:`${this.wuid}-area`,click:()=>{let t={pvName:this.pvName};this.display.fireEvent("openpv",t)},tooltip:()=>this.tooltip,cursor:"pointer"}}draw(t){t.fillRect({x:this.x,y:this.y,width:this.width,height:this.height,color:this.backgroundColor}),this.drawRamp(t,this.computeLimits()),this.pv&&this.pv.navigable&&!this.pv.disconnected&&t.addHitRegion(this.areaRegion).addRect(this.x,this.y,this.width,this.height)}computeLimits(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?{min:this.pv.lowerDisplayLimit??this.minimum,lolo:this.pv.lowerAlarmLimit,lo:this.pv.lowerWarningLimit,hi:this.pv.upperWarningLimit,hihi:this.pv.upperAlarmLimit,max:this.pv.upperDisplayLimit??this.maximum}:{min:this.minimum,lolo:this.levelLoLo,lo:this.levelLo,hi:this.levelHi,hihi:this.levelHiHi,max:this.maximum}}drawRamp(t,e){let i=new Zt(zy,Xy,"outward");i.minimum=e.min,i.maximum=e.max,i.logScale=this.logScale,i.showMinorTicks=this.showMinorTicks,i.visible=this.showScale,i.majorTickStepHint=this.majorTickStepHint*this.scale,i.majorTickLength=this.majorTickLength,i.minorTickLength=this.minorTickLength,i.majorLineWidth=2*this.scale,i.minorLineWidth=1*this.scale,i.format=this.scaleFormat,i.font=this.scaleFont,i.foregroundColor=this.foregroundColor;let r=i.formatText(e.min),s=t.measureText(r,this.scaleFont),o=i.formatText(e.max),n=t.measureText(o,this.scaleFont),a=Math.max(s.width,n.width)/2,h=this.height,l=this.width;h>Qu*(l-2*a)&&(h=Math.floor(Qu*(l-2*a)));let c=h/(1-Math.sin(Gr)/2),d=Math.floor(this.x-c*(1-Math.cos(Gr))+a),g=this.y,w={x:d,y:g,width:Math.floor(2*c),height:Math.floor(2*c)},{rampWidth:x}=this,_=D(w,w.width/4-x,w.height/4-x);_.width=Math.min(_.width,_.height),_.height=_.width;let L=new jt(x,135,45);L.lolo=e.lolo,L.loloColor=this.colorLoLo,L.showLoLo=!0,L.lo=e.lo,L.loColor=this.colorLo,L.showLo=!0,L.hi=e.hi,L.hiColor=this.colorHi,L.showHi=!0,L.hihi=e.hihi,L.hihiColor=this.colorHiHi,L.showHiHi=!0,L.minimum=e.min,L.maximum=e.max,L.gradient=this.rampGradient,L.logScale=this.logScale,L.draw(t,w,_,this.showRamp),i.draw(t,w),this.drawNeedle(t,w,L,i.getRadius(),e);let A=U.ARIAL_12_BOLD.scale(this.scale);if(this.showValueLabel&&this.value!==void 0){let E=this.format(this.value,e),I=t.measureText(E,A);t.fillText({x:w.x+w.width/2-I.width/2,y:w.y+w.height/2-w.height/4-(i.getRadius()-w.height/4)/2-I.height/2,align:"left",baseline:"top",font:A,text:E,color:this.foregroundColor})}}drawNeedle(t,e,i,r,s){let o=e.x+e.width/2,n=e.y+e.height/2,a;if(this.value!==void 0){let _=i.getValueInRange(this.value);a=360-i.getValuePosition(_),s.max>s.min?_>s.max?a+=8:_<s.min&&(a-=8):_>s.min?a-=8:_<s.max&&(a+=8)}else a=360-i.getValuePosition(s.min+s.max/2);let h=G(a),{needleWidth:l,gapBetweenNeedleScale:c,scale:d}=this,g=Rt(o+e.width/4,n-l/2+3*d,o,n,h),w=Rt(o+r-c,n,o,n,h),x=Rt(o+e.width/4,n+l/2-3*d,o,n,h);t.fillPath({color:this.needleColor,path:new R(g.x,g.y).lineTo(w.x,w.y).lineTo(x.x,x.y).closePath()})}get needleWidth(){return this.scale*Fy}get gapBetweenNeedleScale(){return this.scale*$y}get rampWidth(){return this.scale*Gy}format(t,e){if(this.valueLabelFormat)return new it(this.valueLabelFormat).format(t);{let i=Kt(e.min,e.max);return new it(i).format(t)}}get colorLo(){return this.properties.getValue(ig)}get colorLoLo(){return this.properties.getValue(rg)}get colorHi(){return this.properties.getValue(tg)}get colorHiHi(){return this.properties.getValue(eg)}get font(){return this.properties.getValue(sg).scale(this.scale)}get levelLo(){return this.properties.getValue(ag)}get levelLoLo(){return this.properties.getValue(hg)}get levelHi(){return this.properties.getValue(og)}get levelHiHi(){return this.properties.getValue(ng)}get limitsFromPv(){return this.properties.getValue(lg)}get logScale(){return this.properties.getValue(cg)}get majorTickStepHint(){return this.properties.getValue(pg)}get majorTickLength(){return this.scale*Uy}get minorTickLength(){return this.scale*Yy}get minimum(){return this.properties.getValue(dg)}get maximum(){return this.properties.getValue(ug)}get needleColor(){return this.properties.getValue(gg)}get rampGradient(){return this.properties.getValue(mg)}get scaleFont(){return this.properties.getValue(fg).scale(this.scale)}get scaleFormat(){return this.properties.getValue(wg)}get showLo(){return this.properties.getValue(Pg)}get showLoLo(){return this.properties.getValue(bg)}get showHi(){return this.properties.getValue(xg)}get showHiHi(){return this.properties.getValue(yg)}get showMinorTicks(){return this.properties.getValue(vg)}get showRamp(){return this.properties.getValue(Rg)}get showScale(){return this.properties.getValue(_g)}get showValueLabel(){return this.properties.getValue(Tg)}get valueLabelFormat(){return this.properties.getValue(Sg)}};var Lg="color_hi",Cg="color_hihi",Ag="color_lo",Og="color_lolo",Eg="color_fillbackground",Mg="effect_3d",Vg="fill_color",Ig="fillcolor_alarm_sensitive",Bg="font",Hg="horizontal",Dg="indicator_mode",Wg="level_hi",kg="level_hihi",Ng="level_lo",Fg="level_lolo",Gg="limits_from_pv",$g="log_scale",Ug="maximum",Yg="major_tick_step_hint",zg="minimum",Xg="origin",qg="origin_ignored",Kg="scale_font",jg="scale_format",Zg="show_hi",Jg="show_hihi",Qg="show_label",tm="show_lo",em="show_lolo",im="show_markers",rm="show_minor_ticks",sm="show_scale",om="transparent_background",nm="value_label_format",Ur=class extends M{tooltipRegion;constructor(t,e){super(t,e),this.properties.add(new S(Lg)),this.properties.add(new S(Cg)),this.properties.add(new S(Ag)),this.properties.add(new S(Og)),this.properties.add(new S(Eg)),this.properties.add(new f(Mg)),this.properties.add(new S(Vg)),this.properties.add(new f(Ig,!1)),this.properties.add(new H(Bg)),this.properties.add(new f(Hg)),this.properties.add(new f(Dg)),this.properties.add(new C(Wg)),this.properties.add(new C(kg)),this.properties.add(new C(Ng)),this.properties.add(new C(Fg)),this.properties.add(new f(Gg,!0)),this.properties.add(new f($g)),this.properties.add(new C(Ug)),this.properties.add(new C(Yg)),this.properties.add(new C(zg)),this.properties.add(new C(Xg,0)),this.properties.add(new f(qg,!0)),this.properties.add(new H(Kg)),this.properties.add(new T(jg)),this.properties.add(new f(Zg)),this.properties.add(new f(Jg)),this.properties.add(new f(Qg)),this.properties.add(new f(tm)),this.properties.add(new f(em)),this.properties.add(new f(im)),this.properties.add(new f(rm)),this.properties.add(new f(sm)),this.properties.add(new f(om)),this.properties.add(new T(nm))}init(){this.tooltipRegion={id:`${this.wuid}-tooltip`,tooltip:()=>this.tooltip}}draw(t){let e=this.area;this.borderAlarmSensitive&&(e=D(this.area,2*this.scale));let i=this.alarmSensitiveBackgroundColor;this.transparentBackground||t.fillRect({...e,color:i}),this.tooltip&&t.addHitRegion(this.tooltipRegion).addRect(this.x,this.y,this.width,this.height),this.horizontal?this.drawHorizontal(t,e):this.drawVertical(t,e)}drawVertical(t,e){let i=this.alarmSensitiveForegroundColor,r=new ot(this.display.formatter,this.scale,this.scaleFont,this.min,this.max,this.logScale,this.majorTickStepHint,i,this.showMinorTicks,this.showScale);r.scaleFormat=this.scaleFormat;let s=r.drawVertical(t,e.x,e.y,e.height,!0),o=0;this.showMarkers&&(o=this.drawVerticalMarkers(t,r,e)),this.drawVerticalBar(t,r,{x:e.x+s,y:e.y+r.margin,width:e.width-s-o,height:e.height-2*r.margin})}drawVerticalMarkers(t,e,i){let{lolo:r,lo:s,hi:o,hihi:n}=this,a=U.ARIAL_9.scale(this.scale),h=0;if(this.showLoLo&&r!==void 0){let c=t.measureText("LOLO",a);h=Math.max(h,c.width)}if(this.showLo&&s!==void 0){let c=t.measureText("LO",a);h=Math.max(h,c.width)}if(this.showHi&&o!==void 0){let c=t.measureText("HI",a);h=Math.max(h,c.width)}if(this.showHiHi&&n!==void 0){let c=t.measureText("HIHI",a);h=Math.max(h,c.width)}let l=i.x+i.width;if(this.showLoLo&&r!==void 0){let c=l-h-this.markerGap,d=Math.round(e.getValuePosition(r));t.strokePath({path:new R(c,d).lineTo(c-this.markerTickLength,d),color:this.colorLoLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:c+this.markerGap,y:d,text:"LOLO",align:"left",baseline:"middle",color:this.colorLoLo,font:a})}if(this.showLo&&s!==void 0){let c=l-h-this.markerGap,d=Math.round(e.getValuePosition(s));t.strokePath({path:new R(c,d).lineTo(c-this.markerTickLength,d),color:this.colorLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:c+this.markerGap,y:d,text:"LO",align:"left",baseline:"middle",color:this.colorLo,font:a})}if(this.showHi&&o!==void 0){let c=l-h-this.markerGap,d=Math.round(e.getValuePosition(o));t.strokePath({path:new R(c,d).lineTo(c-this.markerTickLength,d),color:this.colorHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:c+this.markerGap,y:d,text:"HI",align:"left",baseline:"middle",color:this.colorHi,font:a})}if(this.showHiHi&&n!==void 0){let c=l-h-this.markerGap,d=Math.round(e.getValuePosition(n));t.strokePath({path:new R(c,d).lineTo(c-this.markerTickLength,d),color:this.colorHiHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:c+this.markerGap,y:d,text:"HIHI",align:"left",baseline:"middle",color:this.colorHiHi,font:a})}return this.markerTickLength+this.markerGap+h}drawVerticalBar(t,e,i){let{outlineWidth:r}=this;if(t.fillRect({...i,color:this.colorFillbackground}),this.effect3d){let n=t.createLinearGradient(i.x,0,i.x+i.width,0);n.addColorStop(0,m.WHITE.toString()),n.addColorStop(1,this.colorFillbackground.withAlpha(0).toString()),t.fillRect({...i,gradient:n});let a=D(i,r/2);t.strokeRect({...a,color:m.GRAY,lineWidth:r})}let s=this.alarmSensitiveFillColor;if(this.indicatorMode){let n=Math.round(e.getValuePosition(this.getFillValue())),a=i.width,h=this.thumbBreadth,l=_t([{x:0,y:h/2},{x:a/2,y:0},{x:a-1,y:h/2},{x:a/2,y:h}],i.x,n-h/2),c=R.fromPoints(l);if(this.effect3d){let{x:d,y:g}=l[0],{x:w,y:x}=l[2],_=t.createLinearGradient(d,g,w,x);_.addColorStop(0,m.WHITE.toString()),_.addColorStop(1,s.toString()),t.fillPath({path:c,gradient:_}),t.strokePath({path:c,color:m.GRAY,lineWidth:r})}else t.fillPath({path:c,color:s})}else{let n=this.originIgnored?this.min:this.origin,a=this.getFillValue();if(a<n){let d=n;n=a,a=d}let h=Math.round(e.getValuePosition(n)),l=Math.round(e.getValuePosition(a)),c=D({...i,y:h,height:l-h},r);if(t.fillRect({...c,color:s}),this.effect3d){let d=t.createLinearGradient(c.x,0,c.x+c.width,0);d.addColorStop(0,m.WHITE.toString()),d.addColorStop(1,s.withAlpha(0).toString()),t.fillRect({...c,gradient:d})}}let o=this.value;this.showLabel&&o!==void 0&&t.fillText({x:i.x+i.width/2,y:i.y+i.height/2,align:"center",baseline:"middle",color:this.alarmSensitiveForegroundColor,font:this.font,text:this.format(o)})}drawHorizontal(t,e){let i=this.alarmSensitiveForegroundColor,r=new ot(this.display.formatter,this.scale,this.scaleFont,this.min,this.max,this.logScale,this.majorTickStepHint,i,this.showMinorTicks,this.showScale);r.scaleFormat=this.scaleFormat;let s=r.drawHorizontal(t,e.x,e.y+e.height,e.width),o=0;this.showMarkers&&(o=this.drawHorizontalMarkers(t,r,e)),this.drawHorizontalBar(t,r,{x:e.x+r.margin,y:e.y+o,width:e.width-2*r.margin,height:e.height-s-o})}drawHorizontalMarkers(t,e,i){let{lolo:r,lo:s,hi:o,hihi:n}=this,a=U.ARIAL_9.scale(this.scale),h=0;if(this.showLoLo&&r!==void 0){let c=t.measureText("LOLO",a);h=Math.max(h,c.height)}if(this.showLo&&s!==void 0){let c=t.measureText("LO",a);h=Math.max(h,c.height)}if(this.showHi&&o!==void 0){let c=t.measureText("HI",a);h=Math.max(h,c.height)}if(this.showHiHi&&n!==void 0){let c=t.measureText("HIHI",a);h=Math.max(h,c.height)}let l=i.y;if(this.showLoLo&&r!==void 0){let c=Math.round(e.getValuePosition(r)),d=l+h+this.markerGap;t.strokePath({path:new R(c,d).lineTo(c,d+this.markerTickLength),color:this.colorLoLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:c,y:l,text:"LOLO",align:"center",baseline:"top",color:this.colorLoLo,font:a})}if(this.showLo&&s!==void 0){let c=Math.round(e.getValuePosition(s)),d=l+h+this.markerGap;t.strokePath({path:new R(c,d).lineTo(c,d+this.markerTickLength),color:this.colorLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:c,y:l,text:"LO",align:"center",baseline:"top",color:this.colorLo,font:a})}if(this.showHi&&o!==void 0){let c=Math.round(e.getValuePosition(o)),d=l+h+this.markerGap;t.strokePath({path:new R(c,d).lineTo(c,d+this.markerTickLength),color:this.colorHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:c,y:l,text:"HI",align:"center",baseline:"top",color:this.colorHi,font:a})}if(this.showHiHi&&n!==void 0){let c=Math.round(e.getValuePosition(n)),d=l+h+this.markerGap;t.strokePath({path:new R(c,d).lineTo(c,d+this.markerTickLength),color:this.colorHiHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:c,y:l,text:"HIHI",align:"center",baseline:"top",color:this.colorHiHi,font:a})}return this.markerTickLength+this.markerGap+h}drawHorizontalBar(t,e,i){let{outlineWidth:r}=this;if(t.fillRect({...i,color:this.colorFillbackground}),this.effect3d){let n=t.createLinearGradient(0,i.y,0,i.y+i.height);n.addColorStop(0,m.WHITE.toString()),n.addColorStop(1,this.colorFillbackground.withAlpha(0).toString()),t.fillRect({...i,gradient:n});let a=D(i,r/2);t.strokeRect({...a,color:m.GRAY,lineWidth:r})}let s=this.alarmSensitiveFillColor;if(this.indicatorMode){let n=Math.round(e.getValuePosition(this.getFillValue())),a=i.height,h=this.thumbBreadth,l=_t([{x:h/2,y:0},{x:h,y:a/2},{x:h/2,y:a-1},{x:0,y:a/2}],n-h/2,i.y),c=R.fromPoints(l);if(this.effect3d){let{x:d,y:g}=l[0],{x:w,y:x}=l[2],_=t.createLinearGradient(d,g,w,x);_.addColorStop(0,m.WHITE.toString()),_.addColorStop(1,s.toString()),t.fillPath({path:c,gradient:_}),t.strokePath({path:c,color:m.GRAY,lineWidth:r})}else t.fillPath({path:c,color:s})}else{let n=this.originIgnored?this.min:this.origin,a=this.getFillValue();if(a<n){let d=n;n=a,a=d}let h=Math.round(e.getValuePosition(n)),l=Math.round(e.getValuePosition(a)),c=D({...i,x:h,width:l-h},r);if(t.fillRect({...c,color:s}),this.effect3d){let d=t.createLinearGradient(0,c.y,0,c.y+c.height);d.addColorStop(0,m.WHITE.toString()),d.addColorStop(1,s.withAlpha(0).toString()),t.fillRect({...c,gradient:d})}}let o=this.value;this.showLabel&&o!==void 0&&t.fillText({x:i.x+i.width/2,y:i.y+i.height/2,align:"center",baseline:"middle",color:this.alarmSensitiveForegroundColor,font:this.font,text:this.format(o)})}get min(){return this.limitsFromPv?this.pv?.lowerDisplayLimit??this.minimum:this.minimum}get max(){return this.limitsFromPv?this.pv?.upperDisplayLimit??this.maximum:this.maximum}get lolo(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.lowerAlarmLimit:this.levelLoLo}get lo(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.lowerWarningLimit:this.levelLo}get hi(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.upperWarningLimit:this.levelHi}get hihi(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.upperAlarmLimit:this.levelHiHi}get markerTickLength(){return this.scale*10}get markerTickLineWidth(){return this.scale*2}get markerGap(){return this.scale*3}get thumbBreadth(){return this.scale*13}get outlineWidth(){return this.scale*1}get alarmSensitiveFillColor(){if(this.fillColorAlarmSensitive){if(this.isMajorSeverity())return this.display.majorColor;if(this.isMinorSeverity())return this.display.minorColor}return this.fillColor}getFillValue(){let t=this.value??this.min;return t=Math.max(this.min,t),t=Math.min(this.max,t),t}format(t){return this.valueLabelFormat?new it(this.valueLabelFormat).format(t):String(Number(t.toFixed(2)))}get colorLo(){return this.properties.getValue(Ag)}get colorLoLo(){return this.properties.getValue(Og)}get colorHi(){return this.properties.getValue(Lg)}get colorHiHi(){return this.properties.getValue(Cg)}get colorFillbackground(){return this.properties.getValue(Eg)}get effect3d(){return this.properties.getValue(Mg)}get fillColorAlarmSensitive(){return this.properties.getValue(Ig)}get fillColor(){return this.properties.getValue(Vg)}get font(){return this.properties.getValue(Bg).scale(this.scale)}get horizontal(){return this.properties.getValue(Hg)}get indicatorMode(){return this.properties.getValue(Dg)}get levelLo(){return this.properties.getValue(Ng)}get levelLoLo(){return this.properties.getValue(Fg)}get levelHi(){return this.properties.getValue(Wg)}get levelHiHi(){return this.properties.getValue(kg)}get limitsFromPv(){return this.properties.getValue(Gg)}get logScale(){return this.properties.getValue($g)}get minimum(){return this.properties.getValue(zg)}get majorTickStepHint(){return this.scale*this.properties.getValue(Yg)}get maximum(){return this.properties.getValue(Ug)}get origin(){return this.properties.getValue(Xg)}get originIgnored(){return this.properties.getValue(qg)}get scaleFont(){return this.properties.getValue(Kg).scale(this.scale)}get scaleFormat(){return this.properties.getValue(jg)}get showHi(){return this.properties.getValue(Zg)}get showHiHi(){return this.properties.getValue(Jg)}get showLabel(){return this.properties.getValue(Qg)}get showLo(){return this.properties.getValue(tm)}get showLoLo(){return this.properties.getValue(em)}get showMarkers(){return this.properties.getValue(im)}get showMinorTicks(){return this.properties.getValue(rm)}get showScale(){return this.properties.getValue(sm)}get transparentBackground(){return this.properties.getValue(om)}get valueLabelFormat(){return this.properties.getValue(nm)}};var am="color_hi",hm="color_hihi",lm="color_lo",cm="color_lolo",pm="color_fillbackground",dm="fill_color",um="fillcolor_alarm_sensitive",gm="effect_3d",mm="level_hi",fm="level_hihi",wm="level_lo",xm="level_lolo",ym="limits_from_pv",Pm="log_scale",bm="maximum",vm="major_tick_step_hint",Rm="minimum",_m="scale_font",Tm="scale_format",Sm="show_hi",Lm="show_hihi",Cm="show_lo",Am="show_lolo",Om="show_markers",Em="show_minor_ticks",Mm="show_scale",Vm="transparent_background",Ky=new m(160,160,160),Yr=class extends M{tooltipRegion;constructor(t,e){super(t,e),this.properties.add(new S(am)),this.properties.add(new S(hm)),this.properties.add(new S(lm)),this.properties.add(new S(cm)),this.properties.add(new S(pm)),this.properties.add(new f(gm)),this.properties.add(new S(dm)),this.properties.add(new f(um,!1)),this.properties.add(new C(mm)),this.properties.add(new C(fm)),this.properties.add(new C(wm)),this.properties.add(new C(xm)),this.properties.add(new f(ym,!0)),this.properties.add(new f(Pm)),this.properties.add(new C(bm)),this.properties.add(new C(vm)),this.properties.add(new C(Rm)),this.properties.add(new H(_m)),this.properties.add(new T(Tm)),this.properties.add(new f(Sm)),this.properties.add(new f(Lm)),this.properties.add(new f(Cm)),this.properties.add(new f(Am)),this.properties.add(new f(Om)),this.properties.add(new f(Em)),this.properties.add(new f(Mm)),this.properties.add(new f(Vm))}init(){this.tooltipRegion={id:`${this.wuid}-tooltip`,tooltip:()=>this.tooltip}}draw(t){let{scale:e,min:i,max:r}=this,s=this.area;this.borderAlarmSensitive&&(s=D(s,2*e));let o=this.alarmSensitiveBackgroundColor;this.transparentBackground||t.fillRect({...s,color:o}),this.tooltip&&t.addHitRegion(this.tooltipRegion).addRect(this.x,this.y,this.width,this.height);let n=this.alarmSensitiveForegroundColor,a=new ot(this.display.formatter,e,this.scaleFont,i,r,this.logScale,this.majorTickStepHint,n,this.showMinorTicks,this.showScale);a.scaleFormat=this.scaleFormat;let h=a.drawVertical(t,s.x,s.y,s.height,!0),l=0;this.showMarkers&&(l=this.drawMarkers(t,s,a)),this.drawTank(t,s,h,l,a)}drawMarkers(t,e,i){let{lolo:r,lo:s,hi:o,hihi:n}=this,a=U.ARIAL_9.scale(this.scale),h=0;if(this.showLoLo&&r!==void 0){let c=t.measureText("LOLO",a);h=Math.max(h,c.width)}if(this.showLo&&s!==void 0){let c=t.measureText("LO",a);h=Math.max(h,c.width)}if(this.showHi&&o!==void 0){let c=t.measureText("HI",a);h=Math.max(h,c.width)}if(this.showHiHi&&n!==void 0){let c=t.measureText("HIHI",a);h=Math.max(h,c.width)}let l=e.x+e.width-h-this.markerGap-this.markerTickLength;if(this.showLoLo&&r!==void 0){let c=Math.round(i.getValuePosition(r));t.strokePath({path:new R(l,c).lineTo(l+this.markerTickLength,c),color:this.colorLoLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:l+this.markerTickLength+this.markerGap,y:c,text:"LOLO",align:"left",baseline:"middle",color:this.colorLoLo,font:a})}if(this.showLo&&s!==void 0){let c=Math.round(i.getValuePosition(s));t.strokePath({path:new R(l,c).lineTo(l+this.markerTickLength,c),color:this.colorLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:l+this.markerTickLength+this.markerGap,y:c,text:"LO",align:"left",baseline:"middle",color:this.colorLo,font:a})}if(this.showHi&&o!==void 0){let c=Math.round(i.getValuePosition(o));t.strokePath({path:new R(l,c).lineTo(l+this.markerTickLength,c),color:this.colorHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:l+this.markerTickLength+this.markerGap,y:c,text:"HI",align:"left",baseline:"middle",color:this.colorHi,font:a})}if(this.showHiHi&&n!==void 0){let c=Math.round(i.getValuePosition(n));t.strokePath({path:new R(l,c).lineTo(l+this.markerTickLength,c),color:this.colorHiHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:l+this.markerTickLength+this.markerGap,y:c,text:"HIHI",align:"left",baseline:"middle",color:this.colorHiHi,font:a})}return this.markerTickLength+this.markerGap+h}drawTank(t,e,i,r,s){let o=this.alarmSensitiveForegroundColor,{scale:n,outlineWidth:a}=this,h=e.x+i,l=e.y+s.margin,c=e.width-i-r,d=e.height-2*s.margin,g=this.defaultCorner,w=11/20;c<2*g&&(w=12/20);let x=Math.floor(c*w);g>2*x-c-2*a&&(g=2*x-c);let _=s.getValuePosition(this.getFillValue()),L=this.alarmSensitiveFillColor;if(this.effect3d){t.fillRect({x:h,y:l,width:c,height:d,rx:g/2,ry:g/2,color:m.WHITE});let E=t.createLinearGradient(h,l,h+x+2*n,l);E.addColorStop(0,this.colorFillbackground.toString()),E.addColorStop(1,m.WHITE.withAlpha(0).toString()),t.fillRect({x:h,y:l,width:x,height:d,rx:g/2,ry:g/2,gradient:E}),E=t.createLinearGradient(h+c-x-2*n,l,h+c,l),E.addColorStop(0,m.WHITE.withAlpha(0).toString()),E.addColorStop(1,this.colorFillbackground.toString()),t.fillRect({x:h+c-x,y:l,width:x,height:d,rx:g/2,ry:g/2,gradient:E});let I=_,k=l+d-_;E=t.createLinearGradient(h,I,h+x+2*n,I),E.addColorStop(0,L.toString()),E.addColorStop(1,m.WHITE.withAlpha(0).toString()),t.fillRect({x:h,y:I,width:x,height:k,rx:g/2,ry:g/2,gradient:E}),E=t.createLinearGradient(h+c-x-2*n,I,h+c,I),E.addColorStop(0,m.WHITE.withAlpha(0).toString()),E.addColorStop(1,L.toString()),t.fillRect({x:h+c-x,y:I,width:x,height:k,rx:g/2,ry:g/2,gradient:E})}else t.fillRect({x:h,y:l,width:c,height:d,rx:g/2,ry:g/2,color:this.colorFillbackground}),t.fillRect({x:h,y:_,width:c,height:l+d-_,rx:g/2,ry:g/2,color:L});let A=D({x:h,y:l,width:c,height:d},a/2);t.strokeRect({...A,rx:g/2,ry:g/2,color:this.effect3d?Ky:o,lineWidth:a})}get min(){return this.limitsFromPv?this.pv?.lowerDisplayLimit??this.minimum:this.minimum}get max(){return this.limitsFromPv?this.pv?.upperDisplayLimit??this.maximum:this.maximum}get lolo(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.lowerAlarmLimit:this.levelLoLo}get lo(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.lowerWarningLimit:this.levelLo}get hi(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.upperWarningLimit:this.levelHi}get hihi(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.upperAlarmLimit:this.levelHiHi}get defaultCorner(){return this.scale*15}get markerTickLength(){return this.scale*10}get markerTickLineWidth(){return this.scale*2}get markerGap(){return this.scale*3}get outlineWidth(){return this.scale*1}get alarmSensitiveFillColor(){if(this.fillColorAlarmSensitive){if(this.isMajorSeverity())return this.display.majorColor;if(this.isMinorSeverity())return this.display.minorColor}return this.fillColor}getFillValue(){let t=this.value??this.min;return t=Math.max(this.min,t),t=Math.min(this.max,t),t}get colorLo(){return this.properties.getValue(lm)}get colorLoLo(){return this.properties.getValue(cm)}get colorHi(){return this.properties.getValue(am)}get colorHiHi(){return this.properties.getValue(hm)}get colorFillbackground(){return this.properties.getValue(pm)}get fillColorAlarmSensitive(){return this.properties.getValue(um)}get fillColor(){return this.properties.getValue(dm)}get effect3d(){return this.properties.getValue(gm)}get levelLo(){return this.properties.getValue(wm)}get levelLoLo(){return this.properties.getValue(xm)}get levelHi(){return this.properties.getValue(mm)}get levelHiHi(){return this.properties.getValue(fm)}get limitsFromPv(){return this.properties.getValue(ym)}get logScale(){return this.properties.getValue(Pm)}get minimum(){return this.properties.getValue(Rm)}get majorTickStepHint(){return this.scale*this.properties.getValue(vm)}get maximum(){return this.properties.getValue(bm)}get scaleFont(){return this.properties.getValue(_m).scale(this.scale)}get scaleFormat(){return this.properties.getValue(Tm)}get showLo(){return this.properties.getValue(Cm)}get showLoLo(){return this.properties.getValue(Am)}get showHi(){return this.properties.getValue(Sm)}get showHiHi(){return this.properties.getValue(Lm)}get showMarkers(){return this.properties.getValue(Om)}get showMinorTicks(){return this.properties.getValue(Em)}get showScale(){return this.properties.getValue(Mm)}get transparentBackground(){return this.properties.getValue(Vm)}};var Im="auto_size",Fs="font",Bm="format_type",Hm="horizontal_alignment",Dm="precision",Wm="precision_from_pv",km="rotation_angle",Nm="show_lohi",Fm="show_units",Gm="vertical_alignment",$m="wrap_words",zr=class extends M{areaRegion;tooltipRegion;constructor(t,e){super(t,e),this.properties.add(new f(Im)),this.properties.add(new H(Fs)),this.properties.add(new P(Bm)),this.properties.add(new P(Hm)),this.properties.add(new P(Dm)),this.properties.add(new f(Wm)),this.properties.add(new C(km)),this.properties.add(new f(Nm,!0)),this.properties.add(new f(Fm,!0)),this.properties.add(new P(Gm)),this.properties.add(new f($m))}init(){this.areaRegion={id:`${this.wuid}-area`,click:()=>{let t={pvName:this.pvName};this.display.fireEvent("openpv",t)},tooltip:()=>this.tooltip,cursor:"pointer"},this.tooltipRegion={id:`${this.wuid}-tooltip`,tooltip:()=>this.tooltip}}drawHolder(t){if(this.autoSize){let e=this.properties.getValue(Fs).scale(1);this.customSize=t.measureText(this.computeDisplayText(),e,!0)}super.drawHolder(t)}computeDisplayText(){let t=this.text;if(this.value!==void 0){let e=this.precisionFromPV?this.pv?.precision??-1:this.precision;t=ge(this.value,this.formatType,e,this.pv?.typeHint)}return this.showUnits&&this.pv?.units&&(t+=" "+this.pv.units),this.showLohi&&(this.pv?.alarmName==="LOLO"||this.pv?.alarmName==="LOW"?t+=" \u2193":(this.pv?.alarmName==="HIHI"||this.pv?.alarmName==="HIGH")&&(t+=" \u2191")),t}draw(t){let e=t.ctx;this.backgroundAlarmSensitive&&this.alarm?t.fillRect({...this.area,color:this.alarmSensitiveBackgroundColor}):this.transparent||t.fillRect({...this.area,color:this.backgroundColor}),this.pv&&this.pv.navigable&&!this.pv.disconnected?t.addHitRegion(this.areaRegion).addRect(this.x,this.y,this.width,this.height):this.tooltip&&t.addHitRegion(this.tooltipRegion).addRect(this.x,this.y,this.width,this.height);let{scale:i}=this,r=this.area;this.borderAlarmSensitive&&(r=D(r,2*i,2*i));let s=this.computeDisplayText();this.wrapWords?this.drawWrapped(t,s,r):this.drawSingleLine(t,s,r)}drawSingleLine(t,e,i){let r=t.ctx,s=t.measureText(e,this.font,!0);if(r.font=this.font.getFontString(),this.rotationAngle){this.drawRotated(t,e,i,s);return}r.textBaseline="alphabetic";let n=r.measureText(e).fontBoundingBoxAscent,a={x:i.x,y:i.y,width:s.width,height:s.height};this.horizAlignment===0||(this.horizAlignment===1?a.x+=(i.width-s.width)/2:this.horizAlignment===2&&(a.x+=i.width-s.width)),this.vertAlignment===0||i.height<=s.height||(this.vertAlignment===1?a.y+=i.height/2-s.height/2:this.vertAlignment===2&&(a.y+=i.height-s.height)),r.textAlign="start",r.textBaseline="top",a.y+=a.height/2-n/2,r.save(),r.beginPath();let h=this.area;r.rect(h.x,h.y,h.width,h.height),r.clip(),r.fillStyle=this.alarmSensitiveForegroundColor.toString(),r.fillText(e,a.x,a.y),r.restore()}drawRotated(t,e,i,r){let s=t.ctx,o=wi(i,r,this.rotationAngle,this.horizAlignment,this.vertAlignment);s.save(),s.beginPath();let n=this.area;s.rect(n.x,n.y,n.width,n.height),s.clip(),s.translate(i.x+o.x,i.y+o.y),s.rotate(this.rotationAngle*Math.PI/180),s.textAlign="left",s.textBaseline="top",s.fillStyle=this.alarmSensitiveForegroundColor.toString(),s.fillText(e,0,0),s.restore()}drawWrapped(t,e,i){let r=t.ctx,s=this.wrapText(t,e,i.width);r.fillStyle=this.alarmSensitiveForegroundColor.toString(),r.font=this.font.getFontString(),r.textAlign="start",r.textBaseline="top";let o=t.measureText("Mg",this.font).height,n=s.length*o,a=i.y;i.height>n&&(this.vertAlignment===1?a+=(i.height-n)/2:this.vertAlignment===2&&(a+=i.height-n)),r.save(),r.beginPath();let h=this.area;r.rect(h.x,h.y,h.width,h.height),r.clip();for(let l of s){let c=i.x;if(this.horizAlignment===1){let d=r.measureText(l).width;c=i.x+(i.width-d)/2}else if(this.horizAlignment===2){let d=r.measureText(l).width;c=i.x+(i.width-d)}r.fillText(l,c,a),a+=o}r.restore()}wrapText(t,e,i){let r=[];for(let s of e.replace(/\n$/,"").split(`
|
|
22
|
-
`))r=r.concat(this.wrapLine(t,s,i));return r}wrapLine(t,e,i){if(!e)return[""];let r=[];for(;e.length;){let s;for(s=e.length;t.measureText(e.substr(0,s),this.font).width>i;s--);let o;if(s===e.length)o=e;else if(e[s]===" ")o=e.substr(0,s+1);else{let n=e.substr(0,s),a=0;for(;n.indexOf(" ",a)!==-1;a=n.indexOf(" ",a)+1);if(a)o=n.substr(0,a);else{let h=e.indexOf(" ");o=h===-1?e:e.substr(0,h)}}r.push(o),e=e.substr(o.length)}return r}get autoSize(){return this.properties.getValue(Im)}get font(){return this.properties.getValue(Fs).scale(this.scale)}get formatType(){return this.properties.getValue(Bm)}get horizAlignment(){return this.properties.getValue(Hm)}get precision(){return this.properties.getValue(Dm)}get precisionFromPV(){return this.properties.getValue(Wm)}get rotationAngle(){return this.properties.getValue(km)}get showLohi(){return this.properties.getValue(Nm)}get showUnits(){return this.properties.getValue(Fm)}get vertAlignment(){return this.properties.getValue(Gm)}get wrapWords(){return this.properties.getValue($m)}};var Um="color_hi",Ym="color_hihi",zm="color_lo",Xm="color_lolo",qm="color_fillbackground",Km="fill_color",jm="fillcolor_alarm_sensitive",Zm="font",Jm="effect_3d",Qm="level_hi",tf="level_hihi",ef="level_lo",rf="level_lolo",sf="limits_from_pv",of="log_scale",nf="maximum",af="major_tick_step_hint",hf="minimum",lf="scale_font",cf="scale_format",pf="show_bulb",df="show_hi",uf="show_hihi",gf="show_lo",mf="show_lolo",ff="show_markers",wf="show_minor_ticks",xf="show_scale",yf="transparent_background",Pf="unit",bf="value_label_format",vf=new m(160,160,160),Xr=class extends M{tooltipRegion;constructor(t,e){super(t,e),this.properties.add(new S(Um)),this.properties.add(new S(Ym)),this.properties.add(new S(zm)),this.properties.add(new S(Xm)),this.properties.add(new S(qm)),this.properties.add(new S(Km)),this.properties.add(new f(jm,!1)),this.properties.add(new f(Jm)),this.properties.add(new C(Qm)),this.properties.add(new C(tf)),this.properties.add(new C(ef)),this.properties.add(new C(rf)),this.properties.add(new f(sf,!0)),this.properties.add(new H(Zm)),this.properties.add(new f(of)),this.properties.add(new C(nf)),this.properties.add(new C(af)),this.properties.add(new C(hf)),this.properties.add(new H(lf)),this.properties.add(new T(cf)),this.properties.add(new f(pf)),this.properties.add(new f(df)),this.properties.add(new f(uf)),this.properties.add(new f(gf)),this.properties.add(new f(mf)),this.properties.add(new f(ff)),this.properties.add(new f(wf)),this.properties.add(new f(xf)),this.properties.add(new f(yf)),this.properties.add(new P(Pf)),this.properties.add(new T(bf))}init(){this.tooltipRegion={id:`${this.wuid}-tooltip`,tooltip:()=>this.tooltip}}draw(t){let{scale:e,min:i,max:r}=this,s=this.area;this.borderAlarmSensitive&&(s=D(this.area,2*this.scale));let o=this.alarmSensitiveBackgroundColor,n=this.alarmSensitiveForegroundColor,a=this.alarmSensitiveFillColor;this.transparentBackground||t.fillRect({...s,color:o}),this.tooltip&&t.addHitRegion(this.tooltipRegion).addRect(this.x,this.y,this.width,this.height);let h=s.height;if(this.showBulb){let A=Math.min(s.width/2,this.bulbMaxDiameter);h=s.height<A?0:s.height-A}let l={...s,height:h},c=new ot(this.display.formatter,e,this.scaleFont,i,r,this.logScale,this.majorTickStepHint,n,this.showMinorTicks,this.showScale);c.scaleFormat=this.scaleFormat;let d=0,g="";if(this.unit===0?g="\xB0C":this.unit===1?g="\xB0F":this.unit===2&&(g="K"),g){let A=U.ARIAL_9.scale(e),E=t.measureText(g,A),I=2*e;d=E.height+2*I,t.fillText({x:s.x+s.width/2-this.pipeWidth/2-I,y:s.y+I,baseline:"top",align:"right",color:n,font:A,text:g})}let w=l.x+l.width/2-this.pipeWidth/2-1*e,x={...l,y:l.y+d,height:l.height-d+c.calculateMargin(t,!1)},_=c.drawVertical(t,w,x.y,x.height,!1),L=Math.floor(this.pipeWidth/2);if(l={...l,y:c.getValuePosition(r)-L,height:c.scaleLength+2*L},this.drawPipe(t,l,c),this.showMarkers&&this.drawMarkers(t,s,c),this.showBulb){let A=Math.min(s.width/2,this.bulbMaxDiameter),E=1*e,I=s.x+s.width/2,k=s.y+h+A/2,F=A/2,Y=A/2;if(t.fillEllipse({cx:I,cy:k,rx:F,ry:Y,color:a}),this.effect3d){let ht=t.createLinearGradient(I-F,k-Y,I+F,k+Y);ht.addColorStop(0,m.WHITE.toString()),ht.addColorStop(1,a.withAlpha(0).toString()),t.fillEllipse({cx:I,cy:k,rx:F,ry:Y,gradient:ht})}t.strokeEllipse({cx:I,cy:k,rx:F-E/2,ry:Y-E/2,color:this.effect3d?vf:n,lineWidth:E});let K={x:Math.round(l.x+l.width/2-this.pipeWidth/2)+this.outlineWidth,y:Math.floor(c.getValuePosition(i)),width:this.pipeWidth-2*this.outlineWidth,height:e*3};if(this.effect3d){let ht=Math.round(l.x+l.width/2-this.pipeWidth/2),Lt=ht+this.pipeWidth,pt=t.createLinearGradient(ht,K.y,Lt,K.y);pt.addColorStop(0,m.WHITE.toString()),pt.addColorStop(1,a.toString()),t.fillRect({...K,gradient:pt})}else t.fillRect({...K,color:a});let mt=this.value;mt!==void 0&&t.fillText({x:I,y:k,align:"center",baseline:"middle",color:a.contrast(),font:this.font,text:this.format(mt)})}}drawPipe(t,e,i){let{scale:r,outlineWidth:s,min:o,max:n}=this,a=this.alarmSensitiveForegroundColor,h=this.alarmSensitiveFillColor,l={x:Math.round(e.x+e.width/2-this.pipeWidth/2),y:e.y,width:this.pipeWidth,height:e.height},c=this.getFillValue(),d=i.getValuePosition(c);n>o?c>n?d-=10*r:c<o&&(d+=10*r):c>o?d+=10*r:c<n&&(d-=10*r);let g=this.pipeWidth/2,{x:w,y:x,width:_,height:L}=l;if(this.effect3d){let E=t.createLinearGradient(w,x,w+_,x);E.addColorStop(0,m.WHITE.toString()),E.addColorStop(1,this.colorFillbackground.toString()),t.fillRect({...l,rx:g/2,ry:g/2,gradient:E}),E=t.createLinearGradient(w,x,w+_,x),E.addColorStop(0,m.WHITE.toString()),E.addColorStop(1,h.toString()),t.fillRect({x:w,y:d,width:_,height:x+L-d,rx:g/2,ry:g/2,gradient:E})}else t.fillRect({...l,rx:g/2,ry:g/2,color:this.colorFillbackground}),t.fillRect({x:w,y:d,width:_,height:x+L-d,rx:g/2,ry:g/2,color:h});let A=D(l,s/2);t.strokeRect({...A,rx:g/2,ry:g/2,color:this.effect3d?vf:a,lineWidth:s})}drawMarkers(t,e,i){let{lolo:r,lo:s,hi:o,hihi:n}=this,a=U.ARIAL_9.scale(this.scale),h=e.x+e.width/2+this.pipeWidth/2;if(this.showLoLo&&r!==void 0){let l=Math.round(i.getValuePosition(r));t.strokePath({path:new R(h,l).lineTo(h+this.markerTickLength,l),color:this.colorLoLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:h+this.markerTickLength+this.markerGap,y:l,text:"LOLO",align:"left",baseline:"middle",color:this.colorLoLo,font:a})}if(this.showLo&&s!==void 0){let l=Math.round(i.getValuePosition(s));t.strokePath({path:new R(h,l).lineTo(h+this.markerTickLength,l),color:this.colorLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:h+this.markerTickLength+this.markerGap,y:l,text:"LO",align:"left",baseline:"middle",color:this.colorLo,font:a})}if(this.showHi&&o!==void 0){let l=Math.round(i.getValuePosition(o));t.strokePath({path:new R(h,l).lineTo(h+this.markerTickLength,l),color:this.colorHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:h+this.markerTickLength+this.markerGap,y:l,text:"HI",align:"left",baseline:"middle",color:this.colorHi,font:a})}if(this.showHiHi&&n!==void 0){let l=Math.round(i.getValuePosition(n));t.strokePath({path:new R(h,l).lineTo(h+this.markerTickLength,l),color:this.colorHiHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:h+this.markerTickLength+this.markerGap,y:l,text:"HIHI",align:"left",baseline:"middle",color:this.colorHiHi,font:a})}}get min(){return this.limitsFromPv?this.pv?.lowerDisplayLimit??this.minimum:this.minimum}get max(){return this.limitsFromPv?this.pv?.upperDisplayLimit??this.maximum:this.maximum}get lolo(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.lowerAlarmLimit:this.levelLoLo}get lo(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.lowerWarningLimit:this.levelLo}get hi(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.upperWarningLimit:this.levelHi}get hihi(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.upperAlarmLimit:this.levelHiHi}get pipeWidth(){return this.scale*15}get bulbMaxDiameter(){return this.scale*40}get outlineWidth(){return this.scale*1}get markerTickLength(){return this.scale*10}get markerTickLineWidth(){return this.scale*2}get markerGap(){return this.scale*3}get alarmSensitiveFillColor(){if(this.fillColorAlarmSensitive){if(this.isMajorSeverity())return this.display.majorColor;if(this.isMinorSeverity())return this.display.minorColor}return this.fillColor}getFillValue(){let t=this.value??this.min;return t=Math.max(this.min,t),t=Math.min(this.max,t),t}format(t){return this.valueLabelFormat?new it(this.valueLabelFormat).format(t):String(Number(t.toFixed(3)))}get colorLo(){return this.properties.getValue(zm)}get colorLoLo(){return this.properties.getValue(Xm)}get colorHi(){return this.properties.getValue(Um)}get colorHiHi(){return this.properties.getValue(Ym)}get colorFillbackground(){return this.properties.getValue(qm)}get fillColorAlarmSensitive(){return this.properties.getValue(jm)}get fillColor(){return this.properties.getValue(Km)}get font(){return this.properties.getValue(Zm).scale(this.scale)}get effect3d(){return this.properties.getValue(Jm)}get levelLo(){return this.properties.getValue(ef)}get levelLoLo(){return this.properties.getValue(rf)}get levelHi(){return this.properties.getValue(Qm)}get levelHiHi(){return this.properties.getValue(tf)}get limitsFromPv(){return this.properties.getValue(sf)}get logScale(){return this.properties.getValue(of)}get minimum(){return this.properties.getValue(hf)}get majorTickStepHint(){return this.scale*this.properties.getValue(af)}get maximum(){return this.properties.getValue(nf)}get scaleFont(){return this.properties.getValue(lf).scale(this.scale)}get scaleFormat(){return this.properties.getValue(cf)}get showBulb(){return this.properties.getValue(pf)}get showMarkers(){return this.properties.getValue(ff)}get showMinorTicks(){return this.properties.getValue(wf)}get showLo(){return this.properties.getValue(gf)}get showLoLo(){return this.properties.getValue(mf)}get showHi(){return this.properties.getValue(df)}get showHiHi(){return this.properties.getValue(uf)}get showScale(){return this.properties.getValue(xf)}get transparentBackground(){return this.properties.getValue(yf)}get unit(){return this.properties.getValue(Pf)}get valueLabelFormat(){return this.properties.getValue(bf)}};var Rf=-323.3062,_f=308.2547,qr=class{constructor(t,e){this.widget=t;this.index=e}widget;index;linearScale;_effectiveMinimum;_effectiveMaximum;get scale(){return this.widget.scale}getValue(t){return this.widget.properties.getValue(`axis_${this.index}_${t}`)}isDateEnabled(){return this.timeFormat!==0}isHorizontal(){return this.index===0||this.index!==1&&!this.yAxis}isVertical(){return!this.isHorizontal()}isPrimary(){return this.index<=1}get effectiveMinimum(){return this._effectiveMinimum??this.minimum}set effectiveMinimum(t){this._effectiveMinimum=t}get effectiveMaximum(){return this._effectiveMaximum??this.maximum}set effectiveMaximum(t){this._effectiveMaximum=t}performAutoScale(){let t={start:this.minimum,stop:this.maximum},e=this.widget.calculateAutoscaledRange(this,t);e&&(this.effectiveMinimum=e.start,this.effectiveMaximum=e.stop,this.widget.requestRepaint())}applyZoom(t,e){let i=this.effectiveMinimum,r=this.effectiveMaximum,s,o;if(this.logScale){r=Math.log10(r),i=Math.log10(i);let n=Math.log10(t)*e,a=1-e;s=n+i*a,o=n+r*a,s<Rf&&(s=Rf),s=Math.pow(10,s),o>_f&&(o=_f),o=Math.pow(10,o)}else{let n=Math.max(Math.abs(i),Math.abs(r));i/=n,r/=n;let a=t/n*e,h=1-e;s=(a+i*h)*n,o=(a+r*h)*n}this.effectiveMinimum=s,this.effectiveMaximum=o,this.widget.requestRepaint()}get autoScale(){return this.getValue("auto_scale")}get autoScaleThreshold(){return this.getValue("auto_scale_threshold")}get axisColor(){return this.getValue("axis_color")}get axisTitle(){return this.getValue("axis_title")}get dashGridLine(){return this.getValue("dash_grid_line")}get gridColor(){return this.getValue("grid_color")}get leftBottomSide(){return this.getValue("left_bottom_side")}get logScale(){return this.getValue("log_scale")}get maximum(){return this.getValue("maximum")}get minimum(){return this.getValue("minimum")}get scaleFont(){return this.getValue("scale_font").scale(this.scale)}get scaleFormat(){return this.getValue("scale_format")}get showGrid(){return this.getValue("show_grid")}get timeFormat(){return this.getValue("time_format")}get titleFont(){return this.getValue("title_font").scale(this.scale)}get visible(){return this.getValue("visible")}get yAxis(){return this.getValue("y_axis")}};var St=class{constructor(t,e){this.xAxis=t;this.yAxis=e;for(let i of t)this.beforeXRanges.push({min:i.effectiveMinimum,max:i.effectiveMaximum});for(let i of e)this.beforeYRanges.push({min:i.effectiveMinimum,max:i.effectiveMaximum})}xAxis;yAxis;beforeXRanges=[];beforeYRanges=[];afterXRanges=[];afterYRanges=[];saveState(){for(let t of this.xAxis)this.afterXRanges.push({min:t.effectiveMinimum,max:t.effectiveMaximum});for(let t of this.yAxis)this.afterYRanges.push({min:t.effectiveMinimum,max:t.effectiveMaximum})}undo(){for(let t=0;t<this.xAxis.length;t++){let e=this.xAxis[t],i=this.beforeXRanges[t];e.effectiveMinimum=i.min,e.effectiveMaximum=i.max}for(let t=0;t<this.yAxis.length;t++){let e=this.yAxis[t],i=this.beforeYRanges[t];e.effectiveMinimum=i.min,e.effectiveMaximum=i.max}}redo(){for(let t=0;t<this.xAxis.length;t++){let e=this.xAxis[t],i=this.afterXRanges[t];e.effectiveMinimum=i.min,e.effectiveMaximum=i.max}for(let t=0;t<this.yAxis.length;t++){let e=this.yAxis[t],i=this.afterYRanges[t];e.effectiveMinimum=i.min,e.effectiveMaximum=i.max}}},Kr=class{undoStack=[];redoStack=[];canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}add(t){this.undoStack.push(t),this.redoStack.length=0}undo(){let t=this.undoStack.pop();t&&(t.undo(),this.redoStack.push(t))}redo(){let t=this.redoStack.pop();t&&(t.redo(),this.undoStack.push(t))}};var jr=class{constructor(t,e){this.widget=e;this.id=t}widget;id;cursor;selection;grabStart;prevGrabEvent;grabZoomCommand;tooltip(){return this.widget.tooltip}mouseDown(t){let{widget:e}=this;switch(e.toolbar?.currentTool){case"rubberband-zoom":case"horizontal-zoom":case"vertical-zoom":this.grabStart=t;break;case"panning":this.grabZoomCommand=new St(e.getXAxes(),e.getYAxes());break}}grab(t){switch(this.widget.toolbar?.currentTool){case"rubberband-zoom":case"horizontal-zoom":case"vertical-zoom":this.grabStart&&(this.selection={...this.grabStart.point,width:t.dx,height:t.dy},this.widget.requestRepaint());break;case"panning":this.pan(t),this.prevGrabEvent=t,this.widget.requestRepaint();break}}grabEnd(){let{grabZoomCommand:t,selection:e,widget:i}=this;switch(i.toolbar?.currentTool){case"rubberband-zoom":if(e){let r=new St(i.getXAxes(),i.getYAxes());this.rangeZoomXAxes(e),this.rangeZoomYAxes(e),r.saveState(),i.toolbar.addCommand(r)}break;case"horizontal-zoom":if(e){let r=new St(i.getXAxes(),i.getYAxes());this.rangeZoomXAxes(e),r.saveState(),i.toolbar.addCommand(r)}break;case"vertical-zoom":if(e){let r=new St(i.getXAxes(),i.getYAxes());this.rangeZoomYAxes(e),r.saveState(),i.toolbar.addCommand(r)}break;case"panning":t&&(t.saveState(),i.toolbar.addCommand(t));break}this.selection=void 0,this.prevGrabEvent=void 0,this.grabZoomCommand=void 0,this.widget.requestRepaint()}click(t){let{widget:e}=this;switch(e.toolbar?.currentTool){case"zoom-in":let i=new St(e.getXAxes(),e.getYAxes());for(let s of e.getAxes()){let o=s.isHorizontal()?t.point.x:t.point.y,n=s.linearScale.getPositionValue(o);s.applyZoom(n,.1)}i.saveState(),e.toolbar.addCommand(i);break;case"zoom-out":let r=new St(e.getXAxes(),e.getYAxes());for(let s of e.getAxes()){let o=s.isHorizontal()?t.point.x:t.point.y,n=s.linearScale.getPositionValue(o);s.applyZoom(n,-.1)}r.saveState(),e.toolbar.addCommand(r);break}}rangeZoomXAxes(t){for(let e of this.widget.getXAxes()){let i=e.linearScale.getPositionValue(t.x),r=e.linearScale.getPositionValue(t.x+t.width);if(i>r){let o=i;i=r,r=o}let s=e.linearScale.getMinMax();i=Math.max(s.start,i),r=Math.min(s.stop,r),e.effectiveMinimum=i,e.effectiveMaximum=r}}rangeZoomYAxes(t){for(let e of this.widget.getYAxes()){let i=e.linearScale.getPositionValue(t.y),r=e.linearScale.getPositionValue(t.y+t.height);if(i>r){let o=i;i=r,r=o}let s=e.linearScale.getMinMax();i=Math.max(s.start,i),r=Math.min(s.stop,r),e.effectiveMinimum=i,e.effectiveMaximum=r}}pan(t){let{prevGrabEvent:e,widget:i}=this;if(e){let r=e.dx-t.dx;if(r!==0)for(let o of i.getXAxes()){let n=o.linearScale,a=n.getMinMax(),h=n.getValuePosition(a.start)+r,l=n.getValuePosition(a.stop)+r;o.effectiveMinimum=n.getPositionValue(h),o.effectiveMaximum=n.getPositionValue(l)}let s=e.dy-t.dy;if(s!==0)for(let o of i.getYAxes()){let n=o.linearScale,a=n.getMinMax(),h=n.getValuePosition(a.start)+s,l=n.getValuePosition(a.stop)+s;o.effectiveMinimum=n.getPositionValue(h),o.effectiveMaximum=n.getPositionValue(l)}}}};var Gs=class{pointer=0;samples=[];constructor(t){this.samples=Array(t).fill(void 0)}push(t,e){this.samples[this.pointer]={x:t,y:e},this.pointer=(this.pointer+1)%this.samples.length}clear(){this.samples.fill(void 0),this.pointer=0}isFull(){let t=(this.pointer+1)%this.samples.length;return this.samples[t]!==void 0}isEmpty(){return this.tail()===void 0}tail(){return this.pointer===0?this.samples[this.samples.length-1]:this.samples[this.pointer-1]}snapshot(t=!1){if(t)return this.samples.filter(i=>i!==void 0).sort((i,r)=>i.x-r.x);{let e=this.samples.slice(this.pointer).filter(r=>r!==void 0),i=this.samples.slice(0,this.pointer).filter(r=>r!==void 0);return e.concat(i)}}},Zr=class{constructor(t,e,i,r,s,o){this.bufferSize=t;this.plotMode=e;this.updateMode=i;this.concatenateData=r;this.chronological=s;this.historicalDataProvider=o;this.traceData=new Gs(t)}bufferSize;plotMode;updateMode;concatenateData;chronological;historicalDataProvider;traceData;x=0;xPending=!1;y=0;yTimestamp=0;yPending=!1;xArray=[];xArrayPending=!1;yArray=[];yArrayPending=!1;clear(){this.traceData.clear(),this.x=0,this.xPending=!1,this.y=0,this.yPending=!1,this.yTimestamp=0,this.xArray=[],this.xArrayPending=!1,this.yArray=[],this.yArrayPending=!1}snapshot(){return this.historicalDataProvider?this.historicalDataProvider.getSamples():this.traceData.snapshot()}updateX(t){this.x=t,this.xPending=!0,this.maybeAddPoint()}updateY(t,e){this.y=t,this.yTimestamp=e,this.yPending=!0,this.maybeAddPoint()}updateXArray(t){this.xArray=t,this.xArrayPending=!0,this.maybeAddArray()}updateYArray(t){this.yArray=t,this.yArrayPending=!0,this.maybeAddArray()}maybeAddPoint(){if(this.plotMode===1&&this.traceData.isFull())return;let{xPending:t,yPending:e,chronological:i,updateMode:r}=this;r===0?(i&&e||!i&&(t||e))&&this.addPoint():r===1?(i&&e||!i&&t&&e)&&this.addPoint():r===2?(i&&e||!i&&t)&&this.addPoint():r===3&&this.yPending&&this.addPoint()}maybeAddArray(){if(this.plotMode===1&&this.traceData.isFull())return;let{xArrayPending:t,yArrayPending:e,chronological:i,updateMode:r}=this;r===0?(i&&e||!i&&(t||e))&&this.addArray():r===1?(i&&e||!i&&t&&e)&&this.addArray():r===2?(i&&e||!i&&t)&&this.addArray():r===3&&this.yArrayPending&&this.addArray()}addPoint(){this.concatenateData||this.traceData.clear();let t=this.x;if(this.chronological)if(this.updateMode===5)t=new Date().getTime();else if(this.yTimestamp!==void 0)t=this.yTimestamp;else{let e=this.traceData.tail();t=e?e.x+1:0}this.traceData.push(t,this.y),this.xPending=!1,this.yPending=!1}addArray(){this.concatenateData||this.traceData.clear();let{xArray:t,yArray:e}=this;if(this.chronological)if(t=Array(e.length),this.traceData.isEmpty())for(let s=0;s<e.length;s++)t[s]=s;else{let s=this.traceData.tail();for(let o=1;o<e.length;o++)t[o-1]=s.x+o}let i=Math.min(t.length,e.length),r=Math.min(i,this.bufferSize);for(let s=0;s<r;s++)this.traceData.push(t[s],e[s]);this.xArrayPending=!1,this.yArrayPending=!1}};var Jr=class{constructor(t,e){this.widget=t;this.i=e}widget;i;traceData;historicalDataProvider;xPVInstance;yPVInstance;xPVListener=()=>{let t=this.xPVInstance;if(t)if(Array.isArray(t.value))this.traceData?.updateXArray(t.value);else{let e=t.toNumber();e!=null&&this.traceData?.updateX(e)}};yPVListener=()=>{let t=this.yPVInstance;if(t)if(Array.isArray(t.value))this.traceData?.updateYArray(t.value);else{let e=this.widget.getAxis(this.xAxisIndex),i=t.toNumber();if(i!=null)if(e.isDateEnabled()){let r=(t.time||new Date).getTime();this.traceData?.updateY(i,r)}else this.traceData?.updateY(i)}};init(){let{bufferSize:t,plotMode:e,updateMode:i,concatenateData:r,widget:s}=this,o=!this.xPV,{pvEngine:n}=s.display;this.historicalDataProvider=void 0,o&&this.yPV&&(this.historicalDataProvider=n.createHistoricalDataProvider(this.yPV,s)||void 0),this.traceData=new Zr(t,e,i,r,o,this.historicalDataProvider),this.xPV&&(this.xPVInstance=n.createPV(this.xPV),this.xPVInstance.addListener(this.xPVListener)),this.yPV&&(this.yPVInstance=n.createPV(this.yPV),this.yPVInstance.addListener(this.yPVListener)),s.addPropertyListener(`trace_${this.i}_x_pv`,()=>{let a=n.createPV(this.xPV);a!==this.xPVInstance&&(this.xPVInstance?.removeListener(this.xPVListener),this.xPVInstance=a,this.xPVInstance.addListener(this.xPVListener))}),s.addPropertyListener(`trace_${this.i}_y_pv`,()=>{let a=n.createPV(this.yPV);a!==this.yPVInstance&&(this.yPVInstance?.removeListener(this.yPVListener),this.yPVInstance=a,this.yPVInstance.addListener(this.yPVListener))})}snapshot(){return this.traceData?.snapshot()||[]}drawTrace(t,e){let{lineWidth:i}=this;if(this.traceType===0)t.strokePath({path:R.fromPoints(e),color:this.traceColor,lineWidth:i});else if(this.traceType===1)t.strokePath({path:R.fromPoints(e),color:this.traceColor,lineWidth:i,dash:[6*this.scale,2*this.scale]});else if(this.traceType!==2){if(this.traceType===3){let s=this.widget.getAxis(this.yAxisIndex).linearScale.getValuePosition(0);for(let o of e)o.y!==null&&t.strokePath({path:new R(o.x,o.y).lineTo(o.x,s),lineWidth:i,color:this.traceColor,opacity:100/255})}else if(this.traceType===4||this.traceType===5){let s=this.widget.getAxis(this.yAxisIndex).linearScale.getValuePosition(0);for(let o=1;o<e.length;o++){let n=e[o-1],a=e[o];n.y!==null&&a.y!==null&&t.fillPath({path:new R(n.x,n.y).lineTo(n.x,s).lineTo(a.x,s).lineTo(a.x,a.y),color:this.traceColor,opacity:100/255})}this.traceType===5&&t.strokePath({path:R.fromPoints(e),color:this.traceColor,lineWidth:i})}else if(this.traceType===6)for(let r=1;r<e.length;r++){let s=e[r-1],o=e[r];s.y!==null&&o.y!==null&&t.strokePath({path:new R(s.x,s.y).lineTo(s.x,o.y).lineTo(o.x,o.y),color:this.traceColor,lineWidth:i})}else if(this.traceType===7)for(let r=1;r<e.length;r++){let s=e[r-1],o=e[r];s.y!==null&&o.y!==null&&t.strokePath({path:new R(s.x,s.y).lineTo(o.x,s.y).lineTo(o.x,o.y),color:this.traceColor,lineWidth:i})}else if(this.traceType===8){let{scale:r}=this;t.strokePath({path:R.fromPoints(e),color:this.traceColor,lineWidth:i,dash:[6*r,2*r,2*r,2*r]})}else if(this.traceType===9){let{scale:r}=this;t.strokePath({path:R.fromPoints(e),color:this.traceColor,lineWidth:i,dash:[6*r,2*r,2*r,2*r,2*r,2*r]})}else if(this.traceType===10){let{scale:r}=this;t.strokePath({path:R.fromPoints(e),color:this.traceColor,lineWidth:i,dash:[2*r,2*r]})}}}drawPoint(t,e){t.ctx.fillStyle=this.traceColor.toString(),t.ctx.strokeStyle=this.traceColor.toString(),t.ctx.lineWidth=1*this.scale;let i=this.pointSize/2,r=e.x,s=e.y;switch(this.pointStyle){case 1:t.ctx.beginPath(),t.ctx.ellipse(r,s,i,i,0,0,2*Math.PI),t.ctx.fill();break;case 2:t.ctx.beginPath(),t.ctx.ellipse(r,s,i,i,0,0,2*Math.PI),t.ctx.stroke();break;case 3:t.ctx.beginPath(),t.ctx.ellipse(r,s,i,i,0,0,2*Math.PI),t.ctx.fill();break;case 4:t.ctx.lineWidth=1*this.scale,t.ctx.beginPath(),t.ctx.moveTo(r-i,s+i),t.ctx.lineTo(r,s-i),t.ctx.lineTo(r+i,s+i),t.ctx.closePath(),t.ctx.stroke();break;case 5:t.ctx.lineWidth=1*this.scale,t.ctx.beginPath(),t.ctx.moveTo(r-i,s+i),t.ctx.lineTo(r,s-i),t.ctx.lineTo(r+i,s+i),t.ctx.closePath(),t.ctx.fill();break;case 6:t.ctx.strokeRect(r-i,s-i,2*i,2*i);break;case 7:t.ctx.fillRect(r-i,s-i,2*i,2*i);break;case 8:t.ctx.beginPath(),t.ctx.moveTo(r-i,s),t.ctx.lineTo(r,s-i),t.ctx.lineTo(r+i,s),t.ctx.lineTo(r,s+i),t.ctx.closePath(),t.ctx.stroke();break;case 9:t.ctx.beginPath(),t.ctx.moveTo(r-i,s),t.ctx.lineTo(r,s-i),t.ctx.lineTo(r+i,s),t.ctx.lineTo(r,s+i),t.ctx.closePath(),t.ctx.stroke();break;case 10:t.ctx.beginPath(),t.ctx.moveTo(r-i,s-i),t.ctx.lineTo(r+i,s+i),t.ctx.moveTo(r+i,s-i),t.ctx.lineTo(r-i,s+i),t.ctx.stroke();break;case 11:t.ctx.beginPath(),t.ctx.moveTo(r-i,s),t.ctx.lineTo(r+i,s),t.ctx.moveTo(r,s-i),t.ctx.lineTo(r,s+i),t.ctx.stroke();break;case 12:t.ctx.beginPath(),t.ctx.moveTo(r,s-i),t.ctx.lineTo(r,s+i),t.ctx.stroke()}}clearData(){this.traceData?.clear()}get scale(){return this.widget.scale}getValue(t){return this.widget.properties.getValue(`trace_${this.i}_${t}`)}get antiAlias(){return this.getValue("anti_alias")}get bufferSize(){return this.getValue("buffer_size")}get concatenateData(){return this.getValue("concatenate_data")}get lineWidth(){return this.scale*this.getValue("line_width")}get name(){return this.getValue("name")}get plotMode(){return this.getValue("plot_mode")}get pointSize(){return this.scale*this.getValue("point_size")}get pointStyle(){return this.getValue("point_style")}get traceColor(){return this.getValue("trace_color")}get traceType(){return this.getValue("trace_type")}get updateDelay(){return this.getValue("update_delay")}get updateMode(){return this.getValue("update_mode")}get visible(){return this.getValue("visible")}get xAxisIndex(){return this.getValue("x_axis_index")}get xPV(){return this.getValue("x_pv")}get yAxisIndex(){return this.getValue("y_axis_index")}get yPV(){return this.getValue("y_pv")}destroy(){this.historicalDataProvider?.disconnect()}};var jy=new m(236,236,236),Zy=new m(130,130,130),$s=class{constructor(t,e,i,r,s){this.imageFile=e;this.disabledImageFile=i;this.action=s;this.loadPromise=new Promise((o,n)=>{this.imageElement.onload=()=>o()}),this.disabledLoadPromise=new Promise((o,n)=>{this.disabledImageElement.onload=()=>o()}),this.region={id:`${t.xyGraph.wuid}-${e}`,mouseDown:()=>{this.toggleButton||(this.pushed=!0,t.xyGraph.requestRepaint())},mouseOut:()=>{this.toggleButton||(this.pushed=!1),t.xyGraph.requestRepaint()},mouseUp:()=>{this.toggleButton||(this.pushed=!1,t.xyGraph.requestRepaint())},click:()=>{this.toggleButton&&(this.pushed=!this.pushed,this.toolButton&&t.toggleTool(this)),this.action(),t.updateState()},tooltip:()=>r}}imageFile;disabledImageFile;action;imageElement=new Image;disabledImageElement=new Image;loadPromise;disabledLoadPromise;toggleButton=!1;toolButton=!1;pushed=!1;disabled=!1;region;loadImage(t){this.imageElement.src=t+this.imageFile,this.disabledImageElement.src=t+this.disabledImageFile}},Qr=class{constructor(t){this.xyGraph=t;this.showLegend=this.createToggleButton("ShowLegend.png","Show Legend",()=>{t.properties.setValue("show_legend",this.showLegend.pushed)}),this.showLegend.pushed=t.showLegend,t.addPropertyListener("show_legend",i=>{this.showLegend.pushed=i}),this.autoScale=this.createButton("AutoScale.png","AutoScale.png","Perform Auto Scale",()=>{let i=new St(t.getXAxes(),t.getYAxes());t.performAutoScale(),i.saveState(),this.addCommand(i)}),this.rubberbandZoom=this.createToolButton("RubberbandZoom.png","Rubberband Zoom",()=>{this.rubberbandZoom.pushed?(this.currentTool="rubberband-zoom",t.setCursor("crosshair"),t.autoScaleAllowed=!1):(this.currentTool="default",t.setCursor(void 0),t.autoScaleAllowed=!0)}),this.horizontalZoom=this.createToolButton("HorizontalZoom.png","Horizontal Zoom",()=>{this.horizontalZoom.pushed?(this.currentTool="horizontal-zoom",t.setCursor("col-resize"),t.autoScaleAllowed=!1):(this.currentTool="default",t.setCursor(void 0),t.autoScaleAllowed=!0)}),this.verticalZoom=this.createToolButton("VerticalZoom.png","Vertical Zoom",()=>{this.verticalZoom.pushed?(this.currentTool="vertical-zoom",t.setCursor("row-resize"),t.autoScaleAllowed=!1):(this.currentTool="default",t.setCursor(void 0),t.autoScaleAllowed=!0)}),this.zoomIn=this.createToolButton("ZoomIn.png","Zoom In",()=>{this.zoomIn.pushed?(this.currentTool="zoom-in",t.setCursor("zoom-in"),t.autoScaleAllowed=!1):(this.currentTool="default",t.setCursor(void 0),t.autoScaleAllowed=!0)}),this.zoomOut=this.createToolButton("ZoomOut.png","Zoom Out",()=>{this.zoomOut.pushed?(this.currentTool="zoom-out",t.setCursor("zoom-out"),t.autoScaleAllowed=!1):(this.currentTool="default",t.setCursor(void 0),t.autoScaleAllowed=!0)}),this.panning=this.createToolButton("Panning.png","Panning",()=>{this.panning.pushed?(this.currentTool="panning",t.setCursor("grab"),t.autoScaleAllowed=!1):(this.currentTool="default",t.setCursor(void 0),t.autoScaleAllowed=!0)}),this.mouseArrow=this.createToolButton("MouseArrow.png","None",()=>{this.currentTool="default",t.setCursor(void 0),t.autoScaleAllowed=!0}),this.undo=this.createButton("Undo.png","Undo_Gray.png","Undo",()=>{this.commandBuffer.undo()}),this.undo.disabled=!0,this.redo=this.createButton("Redo.png","Redo_Gray.png","Redo",()=>{this.commandBuffer.redo()}),this.redo.disabled=!0,this.camera=this.createButton("camera.png","camera.png","Save Snapshot to PNG File",()=>{let i=document.createElement("a");try{i.href=t.toDataURL(),i.download=`${t.name}_export.png`,document.body.appendChild(i),i.click()}finally{document.body.removeChild(i)}}),this.toggleTool(this.mouseArrow);let e=this.buttons.map(i=>i.loadPromise).concat(this.buttons.map(i=>i.disabledLoadPromise));Promise.all(e).finally(()=>{this.imagesLoaded=!0,t.requestRepaint()});for(let i of this.buttons)i.loadImage(t.display.imagesPrefix)}xyGraph;buttons=[];showLegend;autoScale;rubberbandZoom;horizontalZoom;verticalZoom;zoomIn;zoomOut;panning;mouseArrow;undo;redo;camera;imagesLoaded=!1;currentTool="default";commandBuffer=new Kr;updateState(){this.undo.disabled=!this.commandBuffer.canUndo(),this.redo.disabled=!this.commandBuffer.canRedo(),this.xyGraph.requestRepaint()}addCommand(t){this.commandBuffer.add(t),this.updateState()}toggleTool(t){let e=t.pushed;for(let i of this.buttons)i.toolButton&&(i.pushed=!1);e?t.pushed=!0:this.mouseArrow.pushed=!0,this.xyGraph.requestRepaint()}createToolButton(t,e,i){let r=this.createToggleButton(t,e,i);return r.toolButton=!0,r}createToggleButton(t,e,i){let r=this.createButton(t,t,e,i);return r.toggleButton=!0,r}createButton(t,e,i,r){let s=new $s(this,t,e,i,r);return this.buttons.push(s),s}draw(t,e){let{buttonSize:i}=this,r={x:e.x,y:e.y};return this.drawButton(t,r.x,r.y,this.showLegend),r.x+=i,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.autoScale),r.x+=i,this.maybeWrap(r,e,i/2),this.drawSeparator(t,r.x,r.y),r.x+=i/2,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.rubberbandZoom),r.x+=i,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.horizontalZoom),r.x+=i,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.verticalZoom),r.x+=i,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.zoomIn),r.x+=i,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.zoomOut),r.x+=i,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.panning),r.x+=i,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.mouseArrow),r.x+=i,this.maybeWrap(r,e,i/2),this.drawSeparator(t,r.x,r.y),r.x+=i/2,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.undo),r.x+=i,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.redo),r.x+=i,this.maybeWrap(r,e,i/2),this.drawSeparator(t,r.x,r.y),r.x+=i/2,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.camera),r.x+=i,r.y+i-e.y}maybeWrap(t,e,i){i=i??this.buttonSize,t.x+i>e.x+e.width&&(t.x=e.x,t.y+=this.buttonSize)}drawSeparator(t,e,i){let{buttonSize:r}=this,s=1*this.scale,o=Math.round(e+r/4)-s/2;t.strokePath({path:new R(o,i).lineTo(o,i+r),color:Zy,lineWidth:s})}drawButton(t,e,i,r){let{buttonSize:s,scale:o}=this;t.fillRect({x:e,y:i,width:s,height:s,color:jy}),this.xyGraph.enabled&&!r.disabled&&t.addHitRegion(r.region).addRect(e,i,s,s);let n=1*o,a=Math.round(i+n/2)-.5,h=Math.round(e+n/2)-.5,l=Math.round(i+s-n+n/2)-.5,c=Math.round(e+s-n+n/2)-.5;if(t.strokePath({color:r.pushed?m.WHITE:m.BLACK,path:new R(c,l).lineTo(c,a).moveTo(c,l).lineTo(h,l),lineWidth:n}),t.strokePath({color:r.pushed?m.BLACK:m.WHITE,path:new R(h,a).lineTo(c-n,a).moveTo(h,a).lineTo(h,l-n),lineWidth:n}),this.imagesLoaded){let d=r.disabled?r.disabledImageElement:r.imageElement,g=d.naturalHeight*o,w=d.naturalWidth*o,x=Math.round(e+(s-w)/2),_=Math.round(i+(s-g)/2);t.ctx.drawImage(d,x,_,w,g)}}get scale(){return this.xyGraph.scale}get buttonSize(){return 25*this.scale}};var Us="axis_count",Tf="plot_area_background_color",Sf="show_legend",Lf="show_plot_area_border",Cf="show_toolbar",Af="title",Of="title_font",Ys="trace_count",Ef="transparent",ts=class extends M{toolbar;plotAreaRegion;axes=[];traces=[];autoScaleAllowed=!0;constructor(t,e){super(t,e),this.properties.add(new P(Us)),this.properties.add(new S(Tf)),this.properties.add(new f(Sf)),this.properties.add(new f(Lf)),this.properties.add(new f(Cf)),this.properties.add(new T(Af)),this.properties.add(new H(Of)),this.properties.add(new P(Ys)),this.properties.add(new f(Ef)),this.properties.addGenerator(()=>{let i=[];this.axes=[];let r=this.properties.getValue(Us);for(let o=0;o<r;o++)this.axes.push(new qr(this,o)),i.push(new f(`axis_${o}_auto_scale`),new C(`axis_${o}_auto_scale_threshold`),new S(`axis_${o}_axis_color`),new T(`axis_${o}_axis_title`),new f(`axis_${o}_dash_grid_line`),new S(`axis_${o}_grid_color`),new f(`axis_${o}_log_scale`),new C(`axis_${o}_maximum`),new C(`axis_${o}_minimum`),new H(`axis_${o}_scale_font`),new T(`axis_${o}_scale_format`),new f(`axis_${o}_show_grid`),new P(`axis_${o}_time_format`),new H(`axis_${o}_title_font`),new f(`axis_${o}_visible`)),o>1&&i.push(new f(`axis_${o}_left_bottom_side`),new f(`axis_${o}_y_axis`));this.traces=[];let s=this.properties.getValue(Ys);for(let o=0;o<s;o++)this.traces.push(new Jr(this,o)),i.push(new f(`trace_${o}_anti_alias`),new P(`trace_${o}_buffer_size`),new f(`trace_${o}_concatenate_data`),new P(`trace_${o}_line_width`),new T(`trace_${o}_name`),new P(`trace_${o}_plot_mode`),new P(`trace_${o}_point_size`),new P(`trace_${o}_point_style`),new S(`trace_${o}_trace_color`),new P(`trace_${o}_trace_type`),new P(`trace_${o}_update_delay`),new P(`trace_${o}_update_mode`),new f(`trace_${o}_visible`),new P(`trace_${o}_x_axis_index`),new T(`trace_${o}_x_pv`),new Ht(`trace_${o}_x_pv_value`,`trace_${o}_x_pv`),new P(`trace_${o}_y_axis_index`),new T(`trace_${o}_y_pv`),new Ht(`trace_${o}_y_pv_value`,`trace_${o}_y_pv`));return i})}init(){this.plotAreaRegion=new jr(`${this.wuid}-plotarea`,this),this.traces.forEach(t=>t.init())}draw(t){let{scale:e}=this,i=this.area;if(this.borderAlarmSensitive&&(i=D(this.area,2*e)),!this.transparent){let o=this.alarmSensitiveBackgroundColor;t.fillRect({...i,color:o})}this.showToolbar&&this.drawToolbar(t,i),this.title&&this.drawTitle(t,i);for(let o of this.axes){if(o.autoScale&&this.autoScaleAllowed){let h={start:o.minimum,stop:o.maximum},l=this.calculateAutoscaledRange(o,h);l&&(o.effectiveMinimum=l.start,o.effectiveMaximum=l.stop)}let n=o.effectiveMinimum,a=o.effectiveMaximum;o.linearScale=new ot(this.display.formatter,e,o.scaleFont,n,a,o.logScale,50*e,o.axisColor,!0,o.visible),o.linearScale.scaleFormat=o.scaleFormat,o.linearScale.timeFormat=o.timeFormat}this.showLegend&&this.drawLegend(t,i),t.addHitRegion(this.plotAreaRegion).addRect(i.x,i.y,i.width,i.height);let r=this.drawAxes(t,i);this.drawPlotArea(t,r);let s=this.plotAreaRegion?.selection;s&&this.drawZoomSelection(t,r,gi(r,s))}drawToolbar(t,e){this.toolbar||(this.toolbar=new Qr(this));let i=3*this.scale,r=D(e,i),s=this.toolbar.draw(t,r);e.y+=i+s+i,e.height-=i+s+i}drawTitle(t,e){let i=t.measureText(this.title,this.titleFont).height;t.fillText({x:e.x+e.width/2,y:e.y+i/2,align:"center",baseline:"middle",color:this.alarmSensitiveForegroundColor,font:this.titleFont,text:this.title});let r=2*this.scale;e.y+=i+r,e.height-=i+r}drawAxes(t,e){let{scale:i}=this,r=5*i,s={...e},o=0,n=0;for(let c of this.getXAxes())if(c.visible){let d=0;c.axisTitle&&(d=r+t.measureText(c.axisTitle,c.titleFont).height),o+=d,n+=d+c.linearScale.measureHorizontalHeight(t)}let a=0,h=0;for(let c of this.getYAxes().reverse()){let d=c.linearScale;if(c.visible){let g=d.calculateMargin(t,!1),w=s.height-n+(n>0?g:0),x=0;c.axisTitle&&(x=t.measureText(c.axisTitle,c.titleFont).height,t.ctx.save(),t.ctx.translate(s.x+r+x/2,e.y+w/2),t.ctx.rotate(-Math.PI/2),t.fillText({x:0,y:0,align:"center",baseline:"middle",font:c.titleFont,color:c.axisColor,text:c.axisTitle}),t.ctx.restore(),x+=r);let _=x+d.drawVertical(t,s.x+x,e.y,w,!0,!1);s.x+=_,s.width-=_,a+=_;let L=d.margin;h=h===0?L:Math.min(h,L);let A=i*1,E=Math.round(s.x)-A/2,I=Math.round(e.y+g)-A/2;t.strokePath({path:new R(E,I).lineTo(E,I+w-2*g),color:c.axisColor,opacity:100/255,lineWidth:A})}else{let g=s.height-n;d.setDimensions(0,e.y,g,!1)}}let l=0;for(let c of this.getXAxes().reverse()){let d=c.linearScale;if(c.visible){let g=d.calculateMargin(t,!0),w=a-g,x=0;if(c.axisTitle){x=t.measureText(c.axisTitle,c.titleFont).height;let k=e.x+a+(e.width-a)/2;t.fillText({x:k,y:s.y+s.height-x/2,align:"center",baseline:"middle",font:c.titleFont,color:c.axisColor,text:c.axisTitle}),x+=r}let _=x+d.drawHorizontal(t,e.x+w,s.y+s.height-x,e.width-w);s.height-=_;let L=d.margin;l=l===0?L:Math.min(l,L);let A=i*1,E=Math.round(e.x+w+g)-A/2,I=Math.round(s.y+s.height)-A/2;t.strokePath({path:new R(E,I).lineTo(E+s.width-g,I),color:c.axisColor,opacity:100/255,lineWidth:A})}else{let g=e.x+a,w=e.width-a;d.setDimensions(g,0,w,!0)}}return s.y+=h,s.width-=l,n>0?s.height-=h:s.height-=2*h,s}drawPlotArea(t,e){let{scale:i}=this,r=1*i;if(this.transparent||t.fillRect({...e,color:this.plotAreaBackgroundColor}),this.showPlotAreaBorder){let{x:s,y:o,width:n,height:a}=D(e,r/2);t.strokePath({path:new R(s,o).lineTo(s+n,o).lineTo(s+n,o+a),color:m.BLACK,lineWidth:r})}for(let s of this.axes.filter(o=>o.visible&&o.showGrid)){let o=s.linearScale;if(s.isHorizontal())for(let n of o.getGridPositions()){let a=Math.round(o.getX()+n)-r/2;t.strokePath({path:new R(a,e.y).lineTo(a,e.y+e.height),color:s.gridColor,lineWidth:r,dash:s.dashGridLine?[6*i,2*i]:void 0})}else for(let n of o.getGridPositions()){let a=Math.round(o.getY()+n)-r/2;t.strokePath({path:new R(e.x,a).lineTo(e.x+e.width,a),color:s.gridColor,lineWidth:r,dash:s.dashGridLine?[6*i,2*i]:void 0})}}t.ctx.save(),t.ctx.beginPath(),t.ctx.rect(e.x,e.y,e.width,e.height),t.ctx.clip();for(let s of this.traces.filter(o=>o.visible)){let o=this.getAxis(s.xAxisIndex).linearScale,n=this.getAxis(s.yAxisIndex).linearScale,a=[];for(let h of s.snapshot()){let l=o.getValuePosition(h.x),c=h.y!==null?n.getValuePosition(h.y):null;a.push({x:l,y:c})}if(a.length){s.drawTrace(t,a);for(let h of a)h.y!==null&&s.drawPoint(t,h)}}t.ctx.restore()}drawZoomSelection(t,e,i){let{scale:r}=this;switch(this.toolbar?.currentTool){case"rubberband-zoom":t.strokeRect({...i,color:m.BLACK,lineWidth:1*r});break;case"horizontal-zoom":let s=i;s.y=e.y,s.height=e.height,t.strokeRect({...ys(s),color:m.BLACK,lineWidth:1*r});break;case"vertical-zoom":let o=i;o.x=e.x,o.width=e.width,t.strokeRect({...ys(o),color:m.BLACK,lineWidth:1*r});break}}drawLegend(t,e){let{scale:i}=this,r=25*i,s=2*i,o=5*i,n=U.ARIAL_10.scale(i);for(let a of this.getYAxes()){let h=this.traces.filter(A=>A.visible&&A.yAxisIndex===a.index),l=[],c=[],d=0,g=0;for(let A of h){let E=r+s+o;A.name&&(E+=t.measureText(A.name,n).width),d+E<e.width?(c.push(A),d+=E):(l.push(c),E=Math.max(E,d),c=[A],d=E)}if(c.length&&(l.push(c),g=Math.max(g,d)),!l.length)continue;let w=r*l.length,x={x:Math.round(e.x+(e.width-g)/2),y:Math.round(e.y+e.height-w),width:g,height:w};e.height-=x.height,this.transparent||t.fillRect({...x,color:this.plotAreaBackgroundColor}),t.strokeRect({...D(x,1*i/2),color:a.axisColor});let _=x.x,L=x.y;for(let A=0;A<l.length;A++){let E=l[A],I=L+A*r,k=I+r/2;for(let F of E){let Y=F.pointSize>Math.floor((r-o)/2)?Math.floor(r-o):F.pointSize;switch(F.traceType){case 3:let K=_+r/2;t.strokePath({path:new R(K,I+Y).lineTo(K,I+r),lineWidth:F.lineWidth,color:F.traceColor,opacity:100/255}),F.drawPoint(t,{x:K,y:I+Y});break;case 4:case 5:let mt=[{x:_,y:I+r/2},{x:_+r/2,y:I+Y},{x:_+r,y:I+r/2},{x:_+r,y:I+r},{x:_,y:I+r}];t.fillPath({path:R.fromPoints(mt),color:F.traceColor,opacity:100/255}),F.traceType===5&&t.strokePath({path:R.fromPoints(mt.slice(0,3)),color:F.traceColor,lineWidth:1*i}),F.drawPoint(t,{x:_+r/2,y:I+Y});break;default:F.drawTrace(t,[{x:_,y:k},{x:_+r,y:k}]),F.drawPoint(t,{x:_+r/2,y:k})}_+=r+s,F.name&&(t.fillText({x:_,y:k,align:"left",baseline:"middle",color:F.traceColor,font:n,text:F.name}),_+=t.measureText(F.name,n).width),_+=o}}}}setCursor(t){this.plotAreaRegion.cursor=t}calculateAutoscaledRange(t,e){let i,r,s=t.logScale;for(let o of this.traces)if(o.visible&&!(this.axes[o.xAxisIndex]!==t&&this.axes[o.yAxisIndex]!==t))for(let n of o.snapshot()){let a=t.isHorizontal()?n.x:n.y;a!==null&&((i===void 0||i>a)&&(!s||a>0)&&(i=a),(r===void 0||r<a)&&(!s||a>0)&&(r=a))}if(i!==void 0&&r!==void 0)return i===r?{start:Math.min(i,e.start),stop:Math.max(r,e.stop)}:{start:i,stop:r}}performAutoScale(){for(let t of this.axes)t.visible&&t.performAutoScale()}clearGraph(){for(let t of this.traces)t.clearData();this.requestRepaint()}getAxes(){return[...this.axes]}getXAxes(){return this.axes.filter(t=>t.isHorizontal())}getYAxes(){return this.axes.filter(t=>t.isVertical())}getAxis(t){return this.axes[t]}getTrace(t){return this.traces[t]}get axisCount(){return this.properties.getValue(Us)}get plotAreaBackgroundColor(){return this.properties.getValue(Tf)}get showLegend(){return this.properties.getValue(Sf)}get showPlotAreaBorder(){return this.properties.getValue(Lf)}get showToolbar(){return this.properties.getValue(Cf)}get title(){return this.properties.getValue(Af)}get titleFont(){return this.properties.getValue(Of).scale(this.scale)}get traceCount(){return this.properties.getValue(Ys)}get transparent(){return this.properties.getValue(Ef)}destroy(){for(let t of this.traces)t.destroy()}};var Mf="array_length",Vf="spinner_width",If="horizontal",Bf="show_spinner",Hf="show_scrollbar",Df="vec",Wf="data_type",Jy="scale_options",kf=1,Nf=25,Qy=16,Ff=16,tP=new m(64,64,64),eP=250,iP=40,rP=150,sP=new m(243,243,243),es=class extends rt{templateNode;templateWidgetType="";elementWidth=0;elementHeight=0;originalEnabled=new WeakMap;scrollIndex=0;fullValue=[];redistributing=!1;spinnerUpRegion;spinnerUpPressed=!1;spinnerDownRegion;spinnerDownPressed=!1;spinnerRepeatTimeout;spinnerLabelRegion;spinnerLabelBounds;editingIndex=!1;indexInputEl;scrollDecreaseRegion;scrollDecreasePressed=!1;scrollIncreaseRegion;scrollIncreasePressed=!1;scrollPageDecreaseRegion;scrollPageIncreaseRegion;scrollThumbRegion;scrollGrabStartIndex=0;scrollDragRange=0;scrollRepeatTimeout;constructor(t,e){super(t,e),this.properties.add(new P(Mf,10)),this.properties.add(new P(Vf,40)),this.properties.add(new f(If,!1)),this.properties.add(new f(Bf,!0)),this.properties.add(new f(Hf,!0)),this.properties.add(new P(Df,1)),this.properties.add(new P(Wf,0))}async parseNode(t){await super.parseNode(t);let e=t.getNodes("widget");if(e.length){this.templateNode=e[0],this.templateWidgetType=this.templateNode.getString("widget_type"),this.elementWidth=this.templateNode.getInt("width",0),this.elementHeight=this.templateNode.getInt("height",0);for(let i=0;i<this.vec;i++){let r=this.templateNode.cloneWithOverrides({pvName:this.slotPvName(i),wuidSuffix:`-slot${i}`}),s=r.getString("widget_type"),o=this.display.createWidget(s,this);o&&(await o.parseNode(r),this.forEachDescendant(o,n=>this.originalEnabled.set(n,n.enabled)),o.properties.setValue(Jy,new Z(!1,!1,!1)),this.widgets.push(o),this.hookSlotWriteBack(i))}this.layoutSlots(),this.pvName&&this.display.pvEngine.trackListener(this,this.pvName,()=>this.value=this.pv.value)}}init(){this.spinnerUpRegion={id:`${this.wuid}-array-spinner-up`,mouseDown:()=>{this.spinnerUpPressed=!0,this.stepSpinnerRepeatedly(1,!0)},mouseUp:()=>this.stopSpinnerRepeating("up"),mouseOut:()=>this.stopSpinnerRepeating("up")},this.spinnerDownRegion={id:`${this.wuid}-array-spinner-down`,mouseDown:()=>{this.spinnerDownPressed=!0,this.stepSpinnerRepeatedly(-1,!0)},mouseUp:()=>this.stopSpinnerRepeating("down"),mouseOut:()=>this.stopSpinnerRepeating("down")},this.scrollDecreaseRegion={id:`${this.wuid}-array-scroll-decrease`,mouseDown:()=>{this.scrollDecreasePressed=!0,this.stepScrollbarRepeatedly(-1)},mouseUp:()=>this.stopScrollbarRepeating("decrease"),mouseOut:()=>this.stopScrollbarRepeating("decrease")},this.scrollIncreaseRegion={id:`${this.wuid}-array-scroll-increase`,mouseDown:()=>{this.scrollIncreasePressed=!0,this.stepScrollbarRepeatedly(1)},mouseUp:()=>this.stopScrollbarRepeating("increase"),mouseOut:()=>this.stopScrollbarRepeating("increase")},this.scrollPageDecreaseRegion={id:`${this.wuid}-array-scroll-page-decrease`,mouseDown:()=>this.setScrollbarIndex(this.scrollIndex-this.vec)},this.scrollPageIncreaseRegion={id:`${this.wuid}-array-scroll-page-increase`,mouseDown:()=>this.setScrollbarIndex(this.scrollIndex+this.vec)},this.scrollThumbRegion={id:`${this.wuid}-array-scroll-thumb`,mouseDown:()=>{this.scrollGrabStartIndex=this.scrollIndex},grab:t=>{if(this.scrollDragRange<=0)return;let e=this.horizontal?t.dx:t.dy,r=Math.max(0,this.effectiveArrayLength-this.vec)*e/this.scrollDragRange;this.setScrollbarIndex(this.scrollGrabStartIndex+r)}},this.spinnerLabelRegion={id:`${this.wuid}-array-spinner-label`,click:()=>this.startEditingIndex(),cursor:"text"},this.indexInputEl=document.createElement("input"),this.indexInputEl.style.display="none",this.indexInputEl.autocomplete="off",this.indexInputEl.addEventListener("keyup",t=>{t.key==="Enter"?this.commitEditingIndex():t.key==="Escape"&&this.cancelEditingIndex()}),this.indexInputEl.addEventListener("blur",()=>this.cancelEditingIndex()),this.display.rootPanel.appendChild(this.indexInputEl)}destroy(){window.clearTimeout(this.spinnerRepeatTimeout),window.clearTimeout(this.scrollRepeatTimeout),this.indexInputEl&&(this.display.rootPanel.removeChild(this.indexInputEl),this.indexInputEl=void 0),super.destroy()}forEachDescendant(t,e){if(e(t),t instanceof rt)for(let i of t.widgets)this.forEachDescendant(i,e)}startEditingIndex(){if(!this.spinnerLabelBounds||!this.indexInputEl)return;this.editingIndex=!0;let t=this.display.measureAbsoluteArea(this),e=this.spinnerLabelBounds;this.indexInputEl.value=String(this.scrollIndex),this.indexInputEl.style.display="block",this.indexInputEl.style.position="absolute",this.indexInputEl.style.boxSizing="border-box",this.indexInputEl.style.left=`${t.x+e.x}px`,this.indexInputEl.style.top=`${t.y+e.y}px`,this.indexInputEl.style.width=`${e.width}px`,this.indexInputEl.style.height=`${e.height}px`,this.indexInputEl.style.textAlign="center",this.indexInputEl.focus(),this.indexInputEl.select(),this.requestRepaint()}commitEditingIndex(){let t=this.indexInputEl.value;this.cancelEditingIndex();let e=Number(t);isNaN(e)||this.setSpinnerIndex(e)}cancelEditingIndex(){this.indexInputEl.style.display="none",this.editingIndex=!1,this.requestRepaint()}slotPvName(t){return`loc://__array_${this.wuid}_slot${t}`}hookSlotWriteBack(t){let e=this.display.pvEngine.getPV(this.slotPvName(t));e&&this.display.pvEngine.trackListener(this,e.name,()=>{if(this.redistributing)return;let i=this.scrollIndex+t;i>=this.effectiveArrayLength||(this.fullValue[i]=this.coerceElement(e.value),this.pvName&&this.display.pvEngine.setValue(new Date,this.pvName,this.fullValue))})}coerceElement(t){if(this.dataType===kf)return String(t);let e=Number(t);return isNaN(e)?t:e}defaultElementValue(){return this.dataType===kf||this.templateWidgetType==="Text Update"?"":0}get value(){return super.value}set value(t){super.value=t,this.fullValue=Array.isArray(t)?t.slice():t!==void 0?[t]:[],this.scrollIndex=this.clampScrollbarIndex(this.scrollIndex),this.redistribute()}get effectiveArrayLength(){return this.pvName?this.fullValue.length:this.arrayLength}redistribute(){this.redistributing=!0;try{let t=this.effectiveArrayLength;for(let e=0;e<this.widgets.length;e++){let i=this.scrollIndex+e,r=i<t,s=r?this.fullValue[i]:this.defaultElementValue(),o=this.display.pvEngine.getPV(this.slotPvName(e));o&&(o.writable=r),this.display.pvEngine.setValue(new Date,this.slotPvName(e),s),this.forEachDescendant(this.widgets[e],n=>{n.properties.setValue("enabled",r?this.originalEnabled.get(n)??!0:!1)})}}finally{this.redistributing=!1}this.requestRepaint()}clampSpinnerIndex(t){let e=Math.max(0,this.effectiveArrayLength-1);return Math.min(Math.max(0,Math.round(t)),e)}clampScrollbarIndex(t){let e=Math.max(0,this.effectiveArrayLength-this.vec);return Math.min(Math.max(0,Math.round(t)),e)}setSpinnerIndex(t){let e=this.clampSpinnerIndex(t);e!==this.scrollIndex&&(this.scrollIndex=e,this.redistribute())}setScrollbarIndex(t){let e=this.clampScrollbarIndex(t);e!==this.scrollIndex&&(this.scrollIndex=e,this.redistribute())}setScrollIndex(t){this.setSpinnerIndex(t)}getScrollIndex(){return this.scrollIndex}stopSpinnerRepeating(t){window.clearTimeout(this.spinnerRepeatTimeout),t==="up"?this.spinnerUpPressed=!1:this.spinnerDownPressed=!1,this.requestRepaint()}stepSpinnerRepeatedly(t,e){window.clearTimeout(this.spinnerRepeatTimeout),this.setSpinnerIndex(this.scrollIndex+t),this.spinnerRepeatTimeout=window.setTimeout(()=>this.stepSpinnerRepeatedly(t,!1),e?eP:iP)}stopScrollbarRepeating(t){window.clearTimeout(this.scrollRepeatTimeout),t==="decrease"?this.scrollDecreasePressed=!1:this.scrollIncreasePressed=!1,this.requestRepaint()}stepScrollbarRepeatedly(t){window.clearTimeout(this.scrollRepeatTimeout),this.setScrollbarIndex(this.scrollIndex+t),this.scrollRepeatTimeout=window.setTimeout(()=>this.stepScrollbarRepeatedly(t),rP)}computeRegions(t,e,i,r,s){let o,n,a=0,h=0,l=t,c=e;return i>0&&(o={x:0,y:0,width:i,height:Math.min(s,e)},a+=i,l-=i),r>0&&(this.horizontal?(n={x:a,y:e-r,width:l,height:r},c-=r):(n={x:t-r,y:0,width:r,height:e},l-=r)),{spinnerBounds:o,scrollbarBounds:n,paneBounds:{x:a,y:h,width:l,height:c}}}autoScale(t,e){M.prototype.autoScale.call(this,t,e),this.layoutSlots()}layoutSlots(){if(!this.widgets.length)return;let t=this.properties.getValue("width"),e=this.properties.getValue("height"),{paneBounds:i}=this.computeRegions(t,e,this.showSpinner?this.spinnerWidth:0,this.showScrollbar?Ff:0,Nf);for(let r=0;r<this.widgets.length;r++){let s=this.widgets[r],o=this.horizontal?i.x+r*this.elementWidth:i.x,n=this.horizontal?i.y:i.y+r*this.elementHeight;s.properties.setValue("x",o),s.properties.setValue("y",n)}}beforeDrawBorder(t){this.transparent||t.fillRect({x:this.holderX,y:this.holderY,width:this.holderWidth,height:this.holderHeight,color:this.backgroundColor})}draw(t){let e=t.createChildAt(this.x,this.y,this.width,this.height);for(let s of this.widgets.filter(o=>o.visible))s.drawHolder(e),s.draw(e),s.drawDecoration(e);let{scale:i}=this,r=this.computeRegions(this.width,this.height,this.showSpinner?this.spinnerWidth*i:0,this.showScrollbar?Ff*i:0,Nf*i);r.spinnerBounds&&this.drawSpinner(e,r.spinnerBounds),r.scrollbarBounds&&this.drawScrollbar(e,r.scrollbarBounds),this.drawGrayOverlay(e,r.paneBounds);for(let s of this.widgets.filter(o=>o.visible))s.drawOverlay(e);t.copyChild(e)}drawGrayOverlay(t,e){let i=Math.max(0,this.scrollIndex+this.vec-this.effectiveArrayLength);if(i<=0||!this.elementWidth||!this.elementHeight)return;let{scale:r}=this,s=this.vec-i,o=this.horizontal?{x:e.x+s*this.elementWidth*r,y:e.y,width:i*this.elementWidth*r,height:e.height}:{x:e.x,y:e.y+s*this.elementHeight*r,width:e.width,height:i*this.elementHeight*r};o.width<=0||o.height<=0||t.fillRect({...o,color:tP,opacity:40/255})}drawSpinner(t,e){let i=Math.min(e.width,Qy*this.scale),r={x:e.x,y:e.y,width:i,height:e.height},s={x:e.x+i,y:e.y,width:Math.max(0,e.width-i),height:e.height},o=Math.floor(r.height/2),n={x:r.x,y:r.y,width:r.width,height:o},a={x:r.x,y:r.y+o,width:r.width,height:r.height-o};this.drawArrowButton(t,n,this.spinnerUpPressed,"up"),t.addHitRegion(this.spinnerUpRegion).addRect(n.x,n.y,n.width,n.height),this.drawArrowButton(t,a,this.spinnerDownPressed,"down"),t.addHitRegion(this.spinnerDownRegion).addRect(a.x,a.y,a.width,a.height),this.drawSpinnerLabel(t,s)}drawSpinnerLabel(t,e){if(this.spinnerLabelBounds=e,e.width<=0)return;t.fillRect({...e,color:m.WHITE}),t.strokeRect({...e,color:m.BUTTON_DARKER}),this.editingIndex||t.fillText({x:e.x+e.width/2,y:e.y+e.height/2,baseline:"middle",align:"center",font:U.ARIAL_11.scale(this.scale),color:m.BLACK,text:String(this.scrollIndex)}),t.addHitRegion(this.spinnerLabelRegion).addRect(e.x,e.y,e.width,e.height)}drawScrollbar(t,e){t.fillRect({...e,color:sP});let i=this.effectiveArrayLength,r=Math.max(1,Math.min(this.vec,Math.max(i,1))),s=Math.max(i,r,1),o=Math.max(1,s-r);if(this.horizontal){let n=Math.min(e.height,e.width/2),a={x:e.x,y:e.y,width:n,height:e.height},h={x:e.x+e.width-n,y:e.y,width:n,height:e.height};this.drawArrowButton(t,a,this.scrollDecreasePressed,"left"),this.drawArrowButton(t,h,this.scrollIncreasePressed,"right"),t.addHitRegion(this.scrollDecreaseRegion).addRect(a.x,a.y,a.width,a.height),t.addHitRegion(this.scrollIncreaseRegion).addRect(h.x,h.y,h.width,h.height);let d=e.x+n,g=Math.max(0,e.width-2*n),w=Math.min(g,Math.max(6*this.scale,Math.floor(g*r/s)));this.scrollDragRange=g-w;let x=Math.floor((g-w)*Math.min(this.scrollIndex,o)/o),_={x:d+x,y:e.y,width:w,height:e.height};this.drawThumb(t,_),this.registerPageRegion(t,this.scrollPageDecreaseRegion,d,e.y,x,e.height),this.registerPageRegion(t,this.scrollPageIncreaseRegion,d+x+w,e.y,g-x-w,e.height)}else{let n=Math.min(e.width,e.height/2),a={x:e.x,y:e.y,width:e.width,height:n},h={x:e.x,y:e.y+e.height-n,width:e.width,height:n};this.drawArrowButton(t,a,this.scrollDecreasePressed,"up"),this.drawArrowButton(t,h,this.scrollIncreasePressed,"down"),t.addHitRegion(this.scrollDecreaseRegion).addRect(a.x,a.y,a.width,a.height),t.addHitRegion(this.scrollIncreaseRegion).addRect(h.x,h.y,h.width,h.height);let d=e.y+n,g=Math.max(0,e.height-2*n),w=Math.min(g,Math.max(6*this.scale,Math.floor(g*r/s)));this.scrollDragRange=g-w;let x=Math.floor((g-w)*Math.min(this.scrollIndex,o)/o),_={x:e.x,y:d+x,width:e.width,height:w};this.drawThumb(t,_),this.registerPageRegion(t,this.scrollPageDecreaseRegion,e.x,d,e.width,x),this.registerPageRegion(t,this.scrollPageIncreaseRegion,e.x,d+x+w,e.width,g-x-w)}}registerPageRegion(t,e,i,r,s,o){if(s<=0||o<=0)return;t.addHitRegion(e).addRect(i,r,s,o)}drawThumb(t,e){t.fillRect({...e,color:m.BUTTON}),this.drawBevelBorder(t,e,!1),t.addHitRegion(this.scrollThumbRegion).addRect(e.x,e.y,e.width,e.height)}drawBevelBorder(t,e,i){let r=1*this.scale,s=e.y+r/2,o=e.x+r/2,n=e.y+e.height-r+r/2,a=e.x+e.width-r+r/2,[h,l,c,d]=i?[m.BUTTON_LIGHTEST,m.BUTTON_LIGHTEST,m.BUTTON_DARKEST,m.BUTTON_DARKER]:[m.BUTTON_DARKEST,m.BUTTON_DARKER,m.BUTTON,m.BUTTON_LIGHTEST];t.strokePath({color:h,path:new R(a,n).lineTo(a,s).moveTo(a,n).lineTo(o,n)}),t.strokePath({color:l,path:new R(a-r,n-r).lineTo(a-r,s+r).moveTo(a-r,n-r).lineTo(o+r,n-r)}),t.strokePath({color:c,path:new R(o,s).lineTo(a-r,s).moveTo(o,s).lineTo(o,n-r)}),t.strokePath({color:d,path:new R(o+r,s+r).lineTo(a-r-r,s+r).moveTo(o+r,s+r).lineTo(o+r,n-r-r)})}drawArrowButton(t,e,i,r){t.fillRect({...e,color:i?m.BUTTON_DARKER:m.BUTTON}),this.drawBevelBorder(t,e,i);let s=Math.max(1,Math.min(3*this.scale,e.width/2-1,e.height/2-1)),o=Math.max(1,Math.min(2*this.scale,s)),n=e.x+e.width/2,a=e.y+e.height/2,h;r==="up"?h=new R(n,a-o).lineTo(n-s,a+o).lineTo(n+s,a+o).closePath():r==="down"?h=new R(n,a+o).lineTo(n-s,a-o).lineTo(n+s,a-o).closePath():r==="left"?h=new R(n-o,a).lineTo(n+o,a-s).lineTo(n+o,a+s).closePath():h=new R(n+o,a).lineTo(n-o,a-s).lineTo(n-o,a+s).closePath(),t.fillPath({color:m.BLACK,path:h})}get arrayLength(){return this.properties.getValue(Mf)}get spinnerWidth(){return this.properties.getValue(Vf)}get horizontal(){return this.properties.getValue(If)}get showSpinner(){return this.properties.getValue(Bf)}get showScrollbar(){return this.properties.getValue(Hf)}get vec(){return this.properties.getValue(Df)}get dataType(){return this.properties.getValue(Wf)}};var zs="fc",Gf="show_scrollbar",$f="background_color",Uf="foreground_color",oP=16,nP=20,Yf=150,aP=new m(243,243,243),zf=new m(232,232,231),is=class extends rt{scrollX=0;scrollY=0;maxScrollX=0;maxScrollY=0;contentWidth=0;contentHeight=0;dragRangeX;dragRangeY;grabStartX;grabStartY;actionTimeout;xDecPressed=!1;xIncPressed=!1;yDecPressed=!1;yIncPressed=!1;thumbXRegion;thumbYRegion;xDecRegion;xIncRegion;yDecRegion;yIncRegion;trackXBeforeRegion;trackXAfterRegion;trackYBeforeRegion;trackYAfterRegion;constructor(t,e){super(t,e),this.properties.add(new f(zs,!1)),this.properties.add(new f(Gf,!0))}async parseNode(t){await super.parseNode(t);for(let i of t.getNodes("widget")){let r=i.getString("widget_type"),s=this.display.createWidget(r,this);s&&(await s.parseNode(i),this.widgets.push(s))}Ji(this.widgets);let e=()=>{if(this.forwardColors)for(let i of this.widgets)i.properties.setValue($f,this.backgroundColor),i.properties.setValue(Uf,this.foregroundColor),i.requestRepaint()};this.addPropertyListener(zs,e),this.addPropertyListener($f,e),this.addPropertyListener(Uf,e)}init(){this.thumbXRegion=this.makeThumbRegion("x"),this.thumbYRegion=this.makeThumbRegion("y"),this.xDecRegion=this.makeStepRegion("x",-1),this.xIncRegion=this.makeStepRegion("x",1),this.yDecRegion=this.makeStepRegion("y",-1),this.yIncRegion=this.makeStepRegion("y",1),this.trackXBeforeRegion=this.makePageRegion("x",-1),this.trackXAfterRegion=this.makePageRegion("x",1),this.trackYBeforeRegion=this.makePageRegion("y",-1),this.trackYAfterRegion=this.makePageRegion("y",1)}destroy(){window.clearTimeout(this.actionTimeout),super.destroy()}makeThumbRegion(t){return{id:`${this.wuid}-scrollbar-${t}-thumb`,mouseDown:()=>{t==="x"?this.grabStartX=this.scrollX:this.grabStartY=this.scrollY},grab:e=>{let i=t==="x"?this.maxScrollX:this.maxScrollY,r=(t==="x"?this.dragRangeX:this.dragRangeY)||1,s=t==="x"?e.dx:e.dy,o=(t==="x"?this.grabStartX:this.grabStartY)??0;this.setScrollOffset(t,o+i*s/r)},tooltip:()=>this.tooltip}}makeStepRegion(t,e){let i=r=>{t==="x"?e<0?this.xDecPressed=r:this.xIncPressed=r:e<0?this.yDecPressed=r:this.yIncPressed=r};return{id:`${this.wuid}-scrollbar-${t}-${e<0?"dec":"inc"}`,mouseDown:()=>{i(!0),this.stepScrollRepeatedly(t,e)},mouseUp:()=>this.endScrollAction(()=>i(!1)),mouseOut:()=>this.endScrollAction(()=>i(!1)),tooltip:()=>this.tooltip}}makePageRegion(t,e){return{id:`${this.wuid}-scrollbar-${t}-page-${e<0?"before":"after"}`,mouseDown:()=>this.pageScrollRepeatedly(t,e),mouseUp:()=>this.endScrollAction(),mouseOut:()=>this.endScrollAction(),tooltip:()=>this.tooltip}}setScrollOffset(t,e){let i=t==="x"?this.maxScrollX:this.maxScrollY,r=Math.min(Math.max(e,0),i);t==="x"?this.scrollX=r:this.scrollY=r,this.requestRepaint()}stepScrollRepeatedly(t,e){window.clearTimeout(this.actionTimeout);let i=t==="x"?this.scrollX:this.scrollY;this.setScrollOffset(t,i+e*nP*this.scale),this.actionTimeout=window.setTimeout(()=>this.stepScrollRepeatedly(t,e),Yf)}pageScrollRepeatedly(t,e){window.clearTimeout(this.actionTimeout);let i=t==="x"?this.scrollX:this.scrollY,r=t==="x"?this.contentWidth:this.contentHeight;this.setScrollOffset(t,i+e*r),this.actionTimeout=window.setTimeout(()=>this.pageScrollRepeatedly(t,e),Yf)}endScrollAction(t){window.clearTimeout(this.actionTimeout),t?.(),this.requestRepaint()}get forwardColors(){return this.properties.getValue(zs)}get showScrollbar(){return this.properties.getValue(Gf)}beforeDrawBorder(t){this.transparent||t.fillRect({x:this.holderX,y:this.holderY,width:this.holderWidth,height:this.holderHeight,color:this.backgroundColor})}measureContentExtent(){let t=this.width,e=this.height;for(let i of this.widgets.filter(r=>r.visible)){let r=i.bounds;t=Math.max(t,r.x+r.width),e=Math.max(e,r.y+r.height)}return{width:t,height:e}}resolveScrollbars(t,e,i){if(!this.showScrollbar)return{showH:!1,showV:!1};let r=t>this.width,s=e>this.height;return r&&!s&&e>this.height-i?s=!0:s&&!r&&t>this.width-i&&(r=!0),{showH:r,showV:s}}draw(t){let e=oP*this.scale,i=this.measureContentExtent(),{showH:r,showV:s}=this.resolveScrollbars(i.width,i.height,e);this.contentWidth=this.width-(s?e:0),this.contentHeight=this.height-(r?e:0),this.maxScrollX=Math.max(0,i.width-this.contentWidth),this.maxScrollY=Math.max(0,i.height-this.contentHeight),this.scrollX=Math.min(Math.max(this.scrollX,0),this.maxScrollX),this.scrollY=Math.min(Math.max(this.scrollY,0),this.maxScrollY);let o=t.createChildAt(this.x,this.y,this.width,this.height);o.translate(-this.scrollX,-this.scrollY),o.ctx.save(),o.ctx.beginPath(),o.ctx.rect(this.scrollX,this.scrollY,this.contentWidth,this.contentHeight),o.ctx.clip();for(let n of this.widgets.filter(a=>a.visible))n.drawHolder(o),n.draw(o),n.drawDecoration(o);for(let n of this.widgets.filter(a=>a.visible))n.drawOverlay(o);o.ctx.restore(),o.translate(this.scrollX,this.scrollY),r&&this.drawScrollbar(o,"x",{x:0,y:this.contentHeight,width:this.contentWidth,height:e}),s&&this.drawScrollbar(o,"y",{x:this.contentWidth,y:0,width:e,height:this.contentHeight}),t.copyChild(o)}drawScrollbar(t,e,i){let{scale:r}=this;t.fillRect({...i,color:aP});let s=e==="x",o=s?Math.min(i.height,i.width/2):Math.min(i.width,i.height/2),n=s?{x:i.x,y:i.y,width:o,height:i.height}:{x:i.x,y:i.y,width:i.width,height:o},a=s?{x:i.x+i.width-o,y:i.y,width:o,height:i.height}:{x:i.x,y:i.y+i.height-o,width:i.width,height:o};this.drawScrollButton(t,e,-1,n),this.drawScrollButton(t,e,1,a);let h=s?i.x+o:i.y+o,l=(s?i.width:i.height)-2*o,c=s?this.contentWidth:this.contentHeight,d=s?this.maxScrollX:this.maxScrollY,g=Math.min(1,c/(c+d)),w=Math.max(6*r,l*g);s?this.dragRangeX=l-w:this.dragRangeY=l-w;let x=s?this.scrollX:this.scrollY,_=d>0?x/d:0,L=h+(l-w)*_,A=s?{x:L,y:i.y,width:w,height:i.height}:{x:i.x,y:L,width:i.width,height:w};t.fillRect({...A,color:zf}),Ee(t,A,r);let E=s?this.thumbXRegion:this.thumbYRegion;t.addHitRegion(E).addRect(A.x,A.y,A.width,A.height);let I=h+l,k=s?this.trackXBeforeRegion:this.trackYBeforeRegion,F=s?this.trackXAfterRegion:this.trackYAfterRegion;s?(t.addHitRegion(k).addRect(h,i.y,L-h,i.height),t.addHitRegion(F).addRect(L+w,i.y,I-(L+w),i.height)):(t.addHitRegion(k).addRect(i.x,h,i.width,L-h),t.addHitRegion(F).addRect(i.x,L+w,i.width,I-(L+w)))}drawScrollButton(t,e,i,r){let{scale:s}=this,o=e==="x"?i<0?this.xDecPressed:this.xIncPressed:i<0?this.yDecPressed:this.yIncPressed;t.fillRect({...r,color:zf}),o?Lr(t,r,s):Ee(t,r,s);let n=e==="x"?i<0?this.xDecRegion:this.xIncRegion:i<0?this.yDecRegion:this.yIncRegion;t.addHitRegion(n).addRect(r.x,r.y,r.width,r.height);let a=e==="x"?i<0?"left":"right":i<0?"up":"down";Cr(t,r,s,a)}};var Xf="horizontal",qf="panel1_auto_scale_children",Kf="panel2_auto_scale_children",Xs="sash_position",jf="sash_style",Zf="sash_width",qs="x",Ks="y",rs="width",ss="height",hP=0,lP=1,cP=2,pP=3,dP=4,uP=5,gP=12,os=class extends rt{sashRegion;grabStartPosition;grabClientSize;panelOriginSizes=new Map;childOriginBounds=new Map;constructor(t,e){super(t,e),this.properties.add(new f(Xf,!0)),this.properties.add(new f(qf,!1)),this.properties.add(new f(Kf,!1)),this.properties.add(new C(Xs,.5)),this.properties.add(new P(jf,cP)),this.properties.add(new P(Zf,3))}async parseNode(t){await super.parseNode(t);for(let e of t.getNodes("widget")){let i=e.getString("widget_type"),r=this.display.createWidget(i,this);r&&(await r.parseNode(e),this.widgets.push(r))}}init(){this.sashRegion={id:`${this.wuid}-sash`,mouseDown:()=>{this.grabStartPosition=this.sashPosition,this.grabClientSize=this.horizontal?this.width:this.height},grab:t=>{if(this.grabStartPosition===void 0||!this.grabClientSize)return;let e=this.horizontal?t.dx:t.dy,i=this.sashWidth*this.scale,r=this.minPaneSize,s=r+i/2,o=this.grabClientSize-r-i/2,n=this.grabStartPosition*this.grabClientSize+e;n=Math.min(o,Math.max(s,n)),this.properties.setValue(Xs,n/this.grabClientSize),this.requestRepaint()}}}beforeDrawBorder(t){this.transparent||t.fillRect({x:this.holderX,y:this.holderY,width:this.holderWidth,height:this.holderHeight,color:this.backgroundColor})}draw(t){let e=t.createChildAt(this.x,this.y,this.width,this.height),[i,r]=this.widgets;if(i&&r){let{boundsA:s,boundsB:o,sashBounds:n}=this.measureLayout();this.applyPanelBounds(i,s,this.panel1AutoScaleChildren),this.applyPanelBounds(r,o,this.panel2AutoScaleChildren);for(let a of[i,r])a.drawHolder(e),a.draw(e),a.drawDecoration(e);for(let a of[i,r])a.drawOverlay(e);this.drawSash(e,n,s,o)}t.copyChild(e)}measureLayout(){let{horizontal:t}=this,e=t?this.width:this.height,i=t?this.height:this.width,r=this.sashWidth*this.scale,s=Math.floor(r/2),o=this.minPaneSize,n=e-r-o,a=Math.floor(this.sashPosition*e-s);a=Math.min(n,Math.max(o,a));let h=e-a-r,l,c,d;return t?(l={x:0,y:0,width:a,height:i},c={x:a+r,y:0,width:h,height:i},d={x:a,y:0,width:r,height:i}):(l={x:0,y:0,width:i,height:a},c={x:0,y:a+r,width:i,height:h},d={x:0,y:a,width:i,height:r}),{boundsA:l,boundsB:c,sashBounds:d}}applyPanelBounds(t,e,i){let{scale:r}=this,s={x:e.x/r,y:e.y/r,width:e.width/r,height:e.height/r};i&&t instanceof rt&&this.scalePanelChildren(t,s),t.properties.setValue(qs,s.x),t.properties.setValue(Ks,s.y),t.properties.setValue(rs,s.width),t.properties.setValue(ss,s.height)}scalePanelChildren(t,e){let i=this.panelOriginSizes.get(t);i||(i={x:0,y:0,width:t.properties.getValue(rs),height:t.properties.getValue(ss)},this.panelOriginSizes.set(t,i));let r=i.width?e.width/i.width:1,s=i.height?e.height/i.height:1;for(let o of t.widgets){let n=this.childOriginBounds.get(o);n||(n={x:o.properties.getValue(qs),y:o.properties.getValue(Ks),width:o.properties.getValue(rs),height:o.properties.getValue(ss)},this.childOriginBounds.set(o,n)),o.properties.setValue(qs,Math.round(n.x*r)),o.properties.setValue(Ks,Math.round(n.y*s));let{widthScalable:a,heightScalable:h}=o.scaleOptions;if(a||h){let{width:l,height:c}=bi(n,r,s,o.scaleOptions);o.properties.setValue(rs,l),o.properties.setValue(ss,c)}}}autoScale(t,e){M.prototype.autoScale.call(this,t,e)}drawSash(t,e,i,r){let{sashStyle:s}=this;if(s!==hP)if(s===lP){let o=6*this.scale;for(let n of[i,r])t.strokeRect({x:n.x+1,y:n.y+1,width:n.width-2,height:n.height-2,rx:o,ry:o,color:m.BUTTON_DARKER})}else if(s===dP){let o=this.horizontal?e.width:e.height,n=e.x+e.width/2,a=e.y+e.height/2,h=this.horizontal?new R(n,e.y).lineTo(n,e.y+e.height):new R(e.x,a).lineTo(e.x+e.width,a);t.strokePath({path:h,color:this.foregroundColor,lineWidth:o})}else if(s===uP)this.drawSashEdge(t,e,"near",m.BUTTON_DARKER),this.drawSashEdge(t,e,"far",m.BUTTON_DARKER);else{let o=s===pP;t.fillRect({...e,color:m.BUTTON}),this.drawSashEdge(t,e,"near",o?m.BUTTON_DARKER:m.BUTTON_LIGHTEST),this.drawSashEdge(t,e,"far",o?m.BUTTON_LIGHTEST:m.BUTTON_DARKER)}this.sashRegion&&(this.sashRegion.cursor=this.horizontal?"col-resize":"row-resize",t.addHitRegion(this.sashRegion).addRect(e.x,e.y,e.width,e.height))}drawSashEdge(t,e,i,r){let s=1*this.scale,o;if(this.horizontal){let n=i==="near"?e.x:e.x+e.width-s;o=new R(n,e.y).lineTo(n,e.y+e.height)}else{let n=i==="near"?e.y:e.y+e.height-s;o=new R(e.x,n).lineTo(e.x+e.width,n)}t.strokePath({path:o,color:r,lineWidth:s})}get horizontal(){return this.properties.getValue(Xf)}get minPaneSize(){return gP*this.scale}get panel1AutoScaleChildren(){return this.properties.getValue(qf)}get panel2AutoScaleChildren(){return this.properties.getValue(Kf)}get sashPosition(){return this.properties.getValue(Xs)}get sashStyle(){return this.properties.getValue(jf)}get sashWidth(){return this.properties.getValue(Zf)}};var Jf="minimum_tab_height",Zs="active_tab",Qf="horizontal_tabs",js="tab_count",Js=class{constructor(t,e){this.widget=t;this.i=e;this.headerRegion={id:`${t.wuid}-header-${e}`,click:()=>{t.activeTab!==e&&(t.properties.setValue(Zs,e),t.requestRepaint())},cursor:"pointer"}}widget;i;headerRegion;get scale(){return this.widget.scale}getValue(t){return this.widget.properties.getValue(`tab_${this.i}_${t}`)}get title(){return this.getValue("title")}get backgroundColor(){return this.getValue("background_color")}get foregroundColor(){return this.getValue("foreground_color")}get enabled(){return this.getValue("enabled")}get font(){return this.getValue("font").scale(this.scale)}},si=class extends rt{tabs=[];constructor(t,e){super(t,e),this.properties.add(new P(Jf)),this.properties.add(new P(Zs)),this.properties.add(new f(Qf)),this.properties.add(new P(js)),this.properties.addGenerator(()=>{this.tabs=[];let i=this.properties.getValue(js),r=[];for(let s=0;s<i;s++)this.tabs.push(new Js(this,s)),r.push(new T(`tab_${s}_title`),new S(`tab_${s}_background_color`),new S(`tab_${s}_foreground_color`),new f(`tab_${s}_enabled`),new H(`tab_${s}_font`));return r})}async parseNode(t){await super.parseNode(t);for(let e of t.getNodes("widget")){let i=e.getString("widget_type"),r=this.display.createWidget(i,this);r&&(await r.parseNode(e),this.widgets.push(r))}}draw(t){this.horizontalTabs?this.drawHorizontalTabs(t):this.drawVerticalTabs(t)}measureTabOffset(t){return this.horizontalTabs?{x:0,y:this.measureLabelHeight(t)}:{x:this.measureLabelWidth(t),y:0}}measureLabelHeight(t){let{scale:e}=this,i=1*e,r=this.minimumTabHeight;for(let s=0;s<this.tabs.length;s++){let o=this.tabs[s],a=t.measureText(o.title,o.font).height+i;a>r&&(r=a)}return r+this.margin}measureLabelWidth(t){let{scale:e}=this,i=1*e,r=this.minimumTabWidth;for(let s=0;s<this.tabs.length;s++){let o=this.tabs[s],a=t.measureText(o.title,o.font).width+i;a>r&&(r=a)}return r+this.margin}drawHorizontalTabs(t){let{margin:e,gap:i,scale:r}=this,s=this.measureLabelHeight(t),o=1*r,n=this.x;for(let a=0;a<this.tabs.length;a++){let h=this.tabs[a],l=t.measureText(h.title,h.font),c,d,g,w,x;this.activeTab===a?(c=n,d=this.y,g=l.width+o+e+i,w=s,x=h.backgroundColor):(c=n+i,d=this.y+2*r,g=l.width+o+e-i,w=s-2*r,x=this.darken(h.backgroundColor)),t.fillRect({x:c,y:d,width:g,height:w,color:x}),t.addHitRegion(h.headerRegion).addRect(c,d,g,w);let L=t.createLinearGradient(c,d,c,d+w);if(L.addColorStop(0,m.WHITE.toString()),L.addColorStop(1,m.WHITE.withAlpha(0).toString()),t.fillRect({x:c,y:d,width:g,height:w,gradient:L}),t.fillText({x:c+g/2,y:d+w/2,baseline:"middle",align:"center",font:h.font,color:h.foregroundColor,text:h.title}),n+=l.width+o+e-1*r,this.activeTab===a){let A=this.x,E=this.y+s,I=this.width,k=this.height-s;t.fillRect({x:A,y:E,width:I,height:k,color:h.backgroundColor});let F=this.widgets[a],Y=t.createChildAt(A,E,I,k);F.drawHolder(Y),F.draw(Y),F.drawDecoration(Y),F.drawOverlay(Y),t.copyChild(Y)}else this.widgets[a].hide()}}drawVerticalTabs(t){let{margin:e,gap:i,scale:r}=this,s=this.measureLabelWidth(t),o=1*r,n=this.y;for(let a=0;a<this.tabs.length;a++){let h=this.tabs[a],l=t.measureText(h.title,h.font),c=Math.max(l.height+o+o,this.minimumTabHeight),d,g,w,x,_;this.activeTab===a?(d=this.x,g=n,w=s,x=c+e+i,_=h.backgroundColor):(d=this.x+2*r,g=n+i,w=s-2*r,x=c+e-i,_=this.darken(h.backgroundColor)),t.fillRect({x:d,y:g,width:w,height:x,color:_}),t.addHitRegion(h.headerRegion).addRect(d,g,w,x);let A=t.createLinearGradient(d,g,d+w,g);if(A.addColorStop(0,m.WHITE.toString()),A.addColorStop(1,m.WHITE.withAlpha(0).toString()),t.fillRect({x:d,y:g,width:w,height:x,gradient:A}),t.fillText({x:d+w/2,y:g+x/2,baseline:"middle",align:"center",font:h.font,color:h.foregroundColor,text:h.title}),n+=c+e-1*r,this.activeTab===a){let E=this.x+s-1*r,I=this.y,k=this.width-s,F=this.height-1*r;t.fillRect({x:E,y:I,width:k,height:F,color:h.backgroundColor});let Y=this.widgets[a],K=t.createChildAt(E,I,k,F);Y.drawHolder(K),Y.draw(K),Y.drawDecoration(K),Y.drawOverlay(K),t.copyChild(K)}else this.widgets[a].destroy()}}darken(t){let e=Math.max(0,t.red-30),i=Math.max(0,t.green-30),r=Math.max(0,t.blue-30);return new m(e,i,r)}get margin(){return this.scale*10}get gap(){return this.scale*2}get minimumTabWidth(){return this.scale*20}get minimumTabHeight(){return this.scale*this.properties.getValue(Jf)}get activeTab(){return this.properties.getValue(Zs)}get tabCount(){return this.properties.getValue(js)}get horizontalTabs(){return this.properties.getValue(Qf)}};var ns=class{constructor(t){this.table=t}table;columnCount=0;cells=[];selectedRowIndex;dirty=!1;modifiedListeners=[];selectionChangedListeners=[];isEmpty(){return!this.cells.length}refresh(){this.dirty=!0}getCells(){return this.cells}getContent(){let t=[];for(let e of this.cells)t.push(e.map(i=>i.text||""));return t}setContent(t){this.cells.length=0;for(let e=0;e<t.length;e++)e===0&&(this.columnCount=t[e].length),this.cells.push(t[e].map(i=>({text:i})));this.dirty=!0}getColumnCount(){return this.columnCount}getRowCount(){return this.cells.length}setSelectedRowIndex(t){this.selectedRowIndex=t,this.selectionChangedListeners.forEach(e=>e()),this.dirty=!0}getSelection(){return this.selectedRowIndex===void 0?[]:[[...this.cells[this.selectedRowIndex].map(e=>e.text??null)]]}getCellText(t,e){let i=this.cells[t];return i?i[e]?.text??null:null}setColumnsCount(t){if(t<this.columnCount)for(let e of this.cells)e.length=t;if(t>this.columnCount){let e=t-this.columnCount;for(let i of this.cells)for(let r=0;r<e;r++)i.push({text:""})}this.columnCount=t,this.dirty=!0}addModifiedListener(t){this.modifiedListeners.push(t)}addSelectionChangedListener(t){this.selectionChangedListeners.push(t)}appendRow(){let t=[];for(let e=0;e<this.columnCount;e++)t[e]={text:""};return this.cells.push(t),this.dirty=!0,this.cells.length-1}deleteRow(t){this.cells.splice(t,1),this.dirty=!0}deleteColumn(t){for(let e of this.cells)e.splice(t,1);this.columnCount--,this.dirty=!0}insertRow(t){let e=[];for(let i=0;i<this.columnCount;i++)e.push({text:""});this.cells.splice(t,0,e),this.dirty=!0}insertColumn(t){for(let e of this.cells)e.splice(t,0,{text:""});this.columnCount++,this.dirty=!0}getCell(t,e){this.cells[t]=this.cells[t]??[];let i=this.cells[t][e]??{};return this.cells[t][e]=i,i}setCellText(t,e,i){let r=this.getCell(t,e);r.text=i,this.dirty=!0}setRowBackground(t,e){let i=this.cells[t];for(let r of i)r.backgroundColor=e;this.dirty=!0}setRowForeground(t,e){let i=this.cells[t];for(let r of i)r.foregroundColor=e;this.dirty=!0}setCellBackground(t,e,i){let r=this.getCell(t,e);r.backgroundColor=i,this.dirty=!0}setCellForeground(t,e,i){let r=this.getCell(t,e);r.foregroundColor=i,this.dirty=!0}setColumnCellEditorData(t,e){}};var tw="columns_count",ew="column_headers",iw="column_header_visible",rw="default_content",sw="font",as=class extends M{tableWrapper;table;spreadsheet;constructor(t,e){super(t,e),this.properties.add(new P(tw)),this.properties.add(new we(ew)),this.properties.add(new f(iw)),this.properties.add(new we(rw)),this.properties.add(new H(sw)),this.spreadsheet=new ns(this)}init(){this.tableWrapper=document.createElement("div"),this.tableWrapper.style.display="none",this.tableWrapper.style.overflow="auto",this.table=document.createElement("table"),this.table.style.tableLayout="fixed",this.table.style.borderSpacing="0",this.table.style.borderCollapse="collapse",this.tableWrapper.appendChild(this.table),this.display.rootPanel.appendChild(this.tableWrapper),this.table.addEventListener("click",t=>{let e=t.target;if(e.tagName==="TD"){let i=e.parentElement;i.rowIndex>0&&this.spreadsheet.setSelectedRowIndex(i.rowIndex-1)}else this.spreadsheet.setSelectedRowIndex(void 0);this.requestRepaint()}),this.spreadsheet.setContent(this.defaultContent)}draw(t){if(this.tableWrapper){let{x:e,y:i,width:r,height:s}=this.display.measureAbsoluteArea(this);this.tableWrapper.style.backgroundColor="white",this.tableWrapper.style.position="absolute",this.tableWrapper.style.display="block",this.tableWrapper.style.left=`${e}px`,this.tableWrapper.style.top=`${i}px`,this.tableWrapper.style.width=`${r}px`,this.tableWrapper.style.height=`${s}px`,this.tableWrapper.style.border="1px solid rgba(0, 0, 0, 0.1)",this.table.style.font=this.font.getFontString(),this.spreadsheet.dirty&&(this.generateTableContent(),this.spreadsheet.dirty=!1)}}generateTableContent(){let t=this.table.rows.length;for(let i=t-1;i>=0;i--)this.table.deleteRow(i);if(this.columnHeaderVisible){let i=this.table.insertRow();for(let r=0;r<this.columnsCount;r++){let s=this.columnHeaders[r],o=i.insertCell();o.style.color="#aaa",o.style.textAlign="left",s?.length>=2&&s[1]!==""&&(o.style.width=Number(s[1])*this.scale+"px"),o.style.overflow="hidden",o.style.padding=`${4*this.scale}px`,o.style.borderBottom="1px solid rgba(0, 0, 0, 0.1)",r!==0&&(o.style.borderLeft="1px solid rgba(0, 0, 0, 0.1)");let n="";s?.length>=1&&(n=s[0]);let a=document.createTextNode(n);o.appendChild(a)}i.insertCell()}let e=this.spreadsheet.getCells();for(let i=0;i<e.length;i++){let r=e[i],s=i===this.spreadsheet.selectedRowIndex,o=this.table.insertRow();for(let n=0;n<this.columnsCount;n++){let a=o.insertCell();if(a.style.textAlign="left",a.style.overflow="hidden",a.style.wordWrap="break-word",a.style.textOverflow="ellipsis",a.style.padding=`${4*this.scale}px`,n!==0&&(a.style.borderLeft="1px solid rgba(0, 0, 0, 0.1)"),r[n]!==void 0){let h=s?m.BLUE:r[n].backgroundColor;h&&(a.style.backgroundColor=h.toString());let l=s?m.WHITE:r[n].foregroundColor;l&&(a.style.color=l.toString());let c=document.createTextNode(r[n].text||"");a.appendChild(c)}}o.insertCell()}}hide(){this.tableWrapper&&(this.tableWrapper.style.display="none")}destroy(){this.tableWrapper&&(this.display.rootPanel.removeChild(this.tableWrapper),this.tableWrapper=void 0,this.table=void 0)}get columnsCount(){return this.properties.getValue(tw)}get columnHeaders(){return this.properties.getValue(ew)}get columnHeaderVisible(){return this.properties.getValue(iw)}get defaultContent(){return this.properties.getValue(rw)}get font(){return this.properties.getValue(sw).scale(this.scale)}};var ow="url",hs=class extends M{iframe;prevUrl;constructor(t,e){super(t,e),this.properties.add(new T(ow))}init(){this.iframe=document.createElement("iframe"),this.iframe.src="",this.iframe.style.display="none",this.iframe.style.border="0",this.display.rootPanel.appendChild(this.iframe)}draw(t){if(this.iframe){let{x:e,y:i,width:r,height:s}=this.display.measureAbsoluteArea(this);this.iframe.style.position="absolute",this.iframe.style.display="block",this.iframe.style.left=`${e}px`,this.iframe.style.top=`${i}px`,this.iframe.style.width=`${r}px`,this.iframe.style.height=`${s}px`,this.url&&this.prevUrl!==this.url&&(this.iframe.src=this.url,this.prevUrl=this.url)}}hide(){this.iframe&&(this.iframe.style.display="none")}destroy(){this.iframe&&(this.display.rootPanel.removeChild(this.iframe),this.iframe=void 0)}get url(){return this.properties.getValue(ow)}};var mP="Action Button",fP="Arc",wP="Array",xP="Boolean Button",yP="Boolean Switch",PP="Byte Monitor",bP="Check Box",vP="Choice Button",RP="Combo",_P="Combo Box",TP="Ellipse",SP="Gauge",LP="Grid Layout",CP="Grouping Container",AP="Image",OP="Image Boolean Button",EP="Image Boolean Indicator",MP="Intensity Graph",VP="Knob",IP="Label",BP="LED",HP="Linking Container",DP="Menu Button",WP="Meter",kP="Button",NP="Polygon",FP="Polyline",GP="Progress Bar",$P="Radio Box",UP="Rectangle",YP="Rounded Rectangle",zP="Sash Container",XP="Scaled Slider",qP="Scrollbar",KP="Spinner",jP="Tabbed Container",ZP="Table",JP="Tank",QP="Text Input",tb="Text Update",eb="Thermometer",ib="Thumb Wheel",rb="Web Browser",sb="XY Graph";function Qs(){return window.devicePixelRatio||1}var nw=(i=>(i.ENABLED="ENABLED",i.DISABLED="DISABLED",i.DEFAULT="DEFAULT",i))(nw||{}),to=class{constructor(t){this.targetElement=t;this.rootPanel=document.createElement("div"),this.rootPanel.className="display-root",this.rootPanel.style.overflow="hidden",this.rootPanel.style.position="relative",this.rootPanel.style.fontSize="0",this.rootPanel.style.margin="auto",t.appendChild(this.rootPanel),t.style.position="relative",t.style.display="flex";let e=document.createElement("canvas");this.rootPanel.appendChild(e),this.g=new yi(e),this.ctx=this.g.ctx,this.formatter=new di(!1),this.pvEngine=new ir(this),this.pvEngine.addProvider(new sr),this.pvEngine.addProvider(new or(this.formatter)),this.pvEngine.addProvider(new tr),this.displayRegion={id:"display-root",click:()=>{for(let i of this.rootPanel.getElementsByTagName("input"))i.blur();for(let i of this.rootPanel.getElementsByTagName("textarea"))i.blur();for(let i of this.rootPanel.getElementsByTagName("select"))i.blur()}},this.pathResolver=new Je(this),this.scriptLoader=new Qi(this),this.consoleHandler=new We,this.dialogHandler=new ke,this.imageLoader=new Fe,this.stepTimer=window.setTimeout(()=>this.step()),this.eventHandler=new pi(this,e,this.g.hitCanvas),this.resizeObserver=new ResizeObserver(()=>this.requestRepaint()),this.resizeObserver.observe(t)}targetElement;rootPanel;g;ctx;pvEngine;pathResolver;fontResolver;scriptLoader;imageLoader;consoleHandler;dialogHandler;formatter;repaintRequested=!1;_editMode=!1;_showGrid=!1;_showOutline=!1;_showRuler=!1;_selection=[];_scale=1;_pixelRatio=Qs();pixelRatioOverridden=!1;_transparent=!1;_disconnectedColor=new m(160,32,240);_invalidColor=new m(255,0,255);_majorColor=new m(255,0,0);_minorColor=new m(255,128,0);refreshCycle=100;originDesignSize;wasAutoScaleActive=!1;_autoScaleOverride="DEFAULT";resizeObserver;eventHandler;stepTimer;imagesPrefix="";absPrefix="";relPrefix="";instance;eventListeners={closedisplay:[],displayloaded:[],opendisplay:[],openpv:[],runcommand:[],runprocedure:[],runstack:[],selection:[],scale:[]};displayRegion;addProvider(t){this.pvEngine.addProvider(t)}addScriptLibrary(t,e){this.pvEngine.addScriptLibrary(t,e)}setPathResolver(t){this.pathResolver=t}getPathResolver(){return this.pathResolver}setScriptLoader(t){this.scriptLoader=t}getScriptLoader(){return this.scriptLoader}loadContent(t){return this.scriptLoader.load(t)}setImageLoader(t){this.imageLoader=t}getImageLoader(){return this.imageLoader}setConsoleHandler(t){this.consoleHandler=t}getConsoleHandler(){return this.consoleHandler}setDialogHandler(t){this.dialogHandler=t}getDialogHandler(){return this.dialogHandler}setFontResolver(t){this.fontResolver=t}getFontResolver(){return this.fontResolver}step(){!this.pixelRatioOverridden&&this._pixelRatio!==Qs()&&(this._pixelRatio=Qs(),this.requestRepaint()),this.repaintRequested&&(this.g.clearHitCanvas(),this.drawScreen(),this.repaintRequested=!1),this.stepTimer=window.setTimeout(()=>this.step(),this.refreshCycle)}drawScreen(){let t=this.rootPanel.style;if(t.position="relative",t.inset="",t.width="",t.height="",this.instance){let i=this.measureContainerSize();i&&this.isAutoScaleActive()?(t.position="absolute",t.inset="0",this.applyAutoScale(i)):(this.revertAutoScale(),t.width=this.instance.holderWidth+"px",t.height=this.instance.holderHeight+"px")}else t.width="0px",t.height="0px";if(this.g.pixelRatio=this._pixelRatio,this.g.resize(this.rootPanel.clientWidth,this.rootPanel.clientHeight),this.transparent&&this.g.clearCanvas(),this.editMode){let i=document.createElement("canvas"),r=i.getContext("2d");i.width=16,i.height=16,r.fillStyle="#d6d6d6",r.fillRect(0,0,8,8),r.fillRect(8,8,8,8),this.ctx.fillStyle=this.ctx.createPattern(i,"repeat"),this.ctx.fillRect(0,0,this.g.cssWidth,this.g.cssHeight),this.instance&&this.g.fillRect({...this.instance.bounds,color:this.instance.backgroundColor})}else this.transparent||this.g.fillCanvas(this.instance?.backgroundColor||m.WHITE);if(this.g.addHitRegion(this.displayRegion).addRect(0,0,this.g.cssWidth,this.g.cssHeight),this.showGrid&&this.instance){let i=document.createElement("canvas"),r=i.getContext("2d");i.width=25,i.height=25,r.fillStyle=this.instance.foregroundColor.toString(),r.fillRect(0,0,2,1),this.ctx.fillStyle=this.ctx.createPattern(i,"repeat"),this.ctx.fillRect(25,25,this.g.cssWidth-50,this.g.cssHeight-50)}if(this.showRuler){this.ctx.lineWidth=1,this.ctx.strokeStyle="grey",this.ctx.textBaseline="bottom",this.ctx.textAlign="center",this.ctx.fillStyle="grey",this.ctx.font="12px Arial";let i=0;for(;i<=this.g.cssWidth;)i+=100,this.ctx.beginPath(),this.ctx.moveTo(i-75+.5,this.g.cssHeight),this.ctx.lineTo(i-75+.5,this.g.cssHeight-4),this.ctx.moveTo(i-50+.5,this.g.cssHeight),this.ctx.lineTo(i-50+.5,this.g.cssHeight-6),this.ctx.moveTo(i-25+.5,this.g.cssHeight),this.ctx.lineTo(i-25+.5,this.g.cssHeight-4),this.ctx.moveTo(i+.5,this.g.cssHeight),this.ctx.lineTo(i+.5,this.g.cssHeight-8),this.ctx.stroke(),this.ctx.fillText(String(i),i,this.g.cssHeight-8);this.ctx.textAlign="right",this.ctx.textBaseline="middle";let r=0;for(;r<=this.g.cssHeight;)r+=100,this.ctx.beginPath(),this.ctx.moveTo(this.g.cssWidth,r-75+.5),this.ctx.lineTo(this.g.cssWidth-4,r-75+.5),this.ctx.moveTo(this.g.cssWidth,r-50+.5),this.ctx.lineTo(this.g.cssWidth-6,r-50+.5),this.ctx.moveTo(this.g.cssWidth,r-25+.5),this.ctx.lineTo(this.g.cssWidth-4,r-25+.5),this.ctx.moveTo(this.g.cssWidth,r+.5),this.ctx.lineTo(this.g.cssWidth-8,r+.5),this.ctx.stroke(),this.ctx.fillText(String(r),this.g.cssWidth-8,r)}this.showOutline&&this.instance&&(this.ctx.lineWidth=1,this.ctx.setLineDash([10,5]),this.ctx.strokeStyle="black",this.ctx.strokeRect(-.5,-.5,this.instance.holderWidth+1,this.instance.holderHeight+1),this.ctx.setLineDash([])),this.instance&&this.instance.draw(this.g);for(let i of this.selection){let r=this.findWidget(i);r&&r.drawSelection(this.ctx)}}requestRepaint(){this.repaintRequested=!0}setTooltip(t){this.rootPanel.title=t?.trim()??""}createWidget(t,e){switch(t){case mP:return new Ae(this,e);case fP:return new _r(this,e);case wP:return new es(this,e);case xP:return new nr(this,e);case yP:return new ar(this,e);case PP:return new Br(this,e);case bP:return new hr(this,e);case vP:return new lr(this,e);case RP:case _P:return new cr(this,e);case TP:return new Tr(this,e);case SP:return new Dr(this,e);case LP:return new Ze(this,e);case CP:return new is(this,e);case AP:return new Sr(this,e);case OP:return new pr(this,e);case EP:return new Wr(this,e);case MP:return new Nr(this,e);case VP:return new ur(this,e);case IP:return new Ar(this,e);case BP:return new Fr(this,e);case HP:return new Te(this,e);case DP:return new gr(this,e);case WP:return new $r(this,e);case kP:return new mr(this,e);case NP:return new Or(this,e);case FP:return new Mr(this,e);case GP:return new Ur(this,e);case $P:return new fr(this,e);case UP:return new Vr(this,e);case YP:return new Ir(this,e);case zP:return new os(this,e);case XP:return new wr(this,e);case qP:return new yr(this,e);case KP:return new Pr(this,e);case jP:return new si(this,e);case ZP:return new as(this,e);case JP:return new Yr(this,e);case QP:return new br(this,e);case tb:return new zr(this,e);case eb:return new Xr(this,e);case ib:return new Rr(this,e);case rb:return new hs(this,e);case sb:return new ts(this,e);default:console.warn(`Unsupported widget type: ${t}`)}}destroy(){this.instance?.destroy(),this.instance=void 0,this.pvEngine.clearState(),window.clearTimeout(this.stepTimer),this.resizeObserver.disconnect(),this.eventHandler.destroy(),this.rootPanel.remove(),this.targetElement.style.position="",this.targetElement.style.display=""}resolvePath(t,e){return this.pathResolver.resolve(t,e)}setSource(t,e){this.reset();let i=t.lastIndexOf("/")+1;return this.relPrefix=t.substring(0,i),new Promise((r,s)=>{fetch(t,{credentials:"same-origin"}).then(o=>{o.ok&&o.text().then(n=>{this.setSourceString(n,e),r()}).catch(n=>s(n))}).catch(o=>s(o))})}setSourceString(t,e){this.reset(),this.instance=new _e(this,void 0,e);let i=Re.parseFromXML(t);this.instance.parseNode(i).then(()=>{this.originDesignSize=this.instance.designSize,this.pvEngine.init(),this.requestRepaint();let r={backgroundColor:this.instance.backgroundColor.toString()};this.fireEvent("displayloaded",r)})}getRefreshCycle(){return this.refreshCycle}setRefreshCycle(t){this.refreshCycle=t}reset(){this.instance&&(this.clearSelection(),this.pvEngine.clearState(),this.instance.destroy(),this.instance=void 0),this.originDesignSize=void 0,this.wasAutoScaleActive=!1}measureAbsoluteOffset(t){let e=0,i=0,r=t.parent;for(;r;){if(e+=r.x,i+=r.y,r instanceof si){let s=r.measureTabOffset(this.g);e+=s.x,i+=s.y}r=r.parent}return{x:e,y:i}}measureAbsoluteArea(t){let e=t.bounds,i=this.measureAbsoluteOffset(t);return e.x+=i.x,e.y+=i.y,e.x+=t.x-t.holderX,e.y+=t.y-t.holderY,e.width+=t.width-t.holderWidth,e.height+=t.height-t.holderHeight,e.x+=this.scale*1,e.y+=this.scale*1,e}addEventListener(t,e){if(!(t in this.eventListeners))throw new Error(`Unknown event '${t}'`);this.eventListeners[t].push(e)}removeEventListener(t,e){if(!(t in this.eventListeners))throw new Error(`Unknown event '${t}'`);this.eventListeners[t]=this.eventListeners[t].filter(i=>i!==e)}fireEvent(t,e){this.eventListeners[t].forEach(r=>r(e))}get showGrid(){return this._showGrid}set showGrid(t){this._showGrid=t,this.requestRepaint()}get showOutline(){return this._showOutline}set showOutline(t){this._showOutline=t,this.requestRepaint()}get showRuler(){return this._showRuler}set showRuler(t){this._showRuler=t,this.requestRepaint()}get selection(){return this._selection}set selection(t){this._selection=t,this.requestRepaint();let e={selected:this._selection.slice()};this.fireEvent("selection",e)}get editMode(){return this._editMode}set editMode(t){this._editMode=t,this.requestRepaint()}get scale(){return this._scale}set scale(t){this._scale=t,this.requestRepaint();let e={scale:t};this.fireEvent("scale",e)}get autoScaleOverride(){return this._autoScaleOverride}set autoScaleOverride(t){this._autoScaleOverride=t,this.requestRepaint()}isAutoScaleActive(){if(!this.instance)return!1;switch(this._autoScaleOverride){case"ENABLED":return!0;case"DISABLED":return!1;case"DEFAULT":return this.instance.autoScaleWidgets.autoScaleWidgets}}measureContainerSize(){let t=this.targetElement.clientWidth,e=this.targetElement.clientHeight;return t&&e?{width:t,height:e}:void 0}applyAutoScale(t){if(!this.instance||!this.originDesignSize)return;this.wasAutoScaleActive=!0;let{width:e,height:i}=this.originDesignSize;if(!e||!i)return;let r=t.width/e,s=t.height/i,{minWidth:o,minHeight:n}=this.instance.autoScaleWidgets,a=o<0?e:o,h=n<0?i:n;e*r<a&&(r=a/e),i*s<h&&(s=h/i),this.instance.autoScale(r,s)}revertAutoScale(){this.instance&&this.wasAutoScaleActive&&this.instance.autoScale(1,1),this.wasAutoScaleActive=!1}get pixelRatio(){return this._pixelRatio}set pixelRatio(t){this._pixelRatio=t,this.pixelRatioOverridden=!0,this.requestRepaint()}get transparent(){return this._transparent}set transparent(t){this._transparent=t,this.requestRepaint()}get utc(){return this.formatter.utc}set utc(t){this.formatter.utc=t,this.requestRepaint()}get disconnectedColor(){return this._disconnectedColor}set disconnectedColor(t){this._disconnectedColor=t,this.requestRepaint()}get invalidColor(){return this._invalidColor}set invalidColor(t){this._invalidColor=t,this.requestRepaint()}get majorColor(){return this._majorColor}set majorColor(t){this._majorColor=t,this.requestRepaint()}get minorColor(){return this._minorColor}set minorColor(t){this._minorColor=t,this.requestRepaint()}get widgets(){return this.instance?this.instance.widgets:[]}clearSelection(){this.selection.length&&(this.selection=[])}findWidget(t){if(this.instance)return this.instance.findWidget(t)}findWidgetByName(t){if(this.instance)return this.instance.findWidgetByName(t)}getPVNames(){return this.pvEngine.getPVNames()}getPV(t){return this.pvEngine.getPV(t)}setValues(t){this.pvEngine.setExternalValues(t)}copyCanvas(t){let e=this.g.pixelRatio,i=t?{x:t.x*e,y:t.y*e,width:t.width*e,height:t.height*e}:{x:0,y:0,width:this.g.canvas.width,height:this.g.canvas.height},r=document.createElement("canvas");return r.width=i.width,r.height=i.height,r.getContext("2d").drawImage(this.g.canvas,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r}toDataURL(t="image/png",e){return this.g.ctx.canvas.toDataURL(t,e)}};var eo=class{pending=new Map;load(t){return new Promise(e=>{let i=this.pending.get(t);i?i.push(e):(this.pending.set(t,[e]),window.parent.postMessage({type:"loadImage",url:t},"*"))})}receiveData(t,e){let i=this.pending.get(t)??[];this.pending.delete(t);let r=e??t;for(let s of i)s(r)}};var io=class{pending=new Map;async load(t){return new Promise(e=>{this.pending.set(t,e),window.parent.postMessage({type:"loadScript",path:t},"*")})}receiveContent(t,e){let i=this.pending.get(t);i&&(this.pending.delete(t),i(e))}};var ls=new Map;var cs=class{constructor(t,e){this.pvName=t;this.widget=e;let i=ls.get(t)??[],r=i.length>0;i.push(this),ls.set(t,i),r||window.parent.postMessage({type:"historySubscribe",pvName:t},"*")}pvName;widget;samples=[];getSamples(){return this.samples}updateSamples(t){this.samples=t,this.widget.requestRepaint()}disconnect(){let t=ls.get(this.pvName)??[],e=t.indexOf(this);e!==-1&&t.splice(e,1),t.length===0&&(ls.delete(this.pvName),window.parent.postMessage({type:"historyUnsubscribe",pvName:this.pvName},"*"))}};var ro=class{canProvide(t){return!0}startProviding(t){window.parent.postMessage({type:"subscribe",pvNames:t.map(e=>e.name)},"*")}stopProviding(t){window.parent.postMessage({type:"unsubscribe",pvNames:t.map(e=>e.name)},"*")}isNavigable(){return!0}writeValue(t,e){window.parent.postMessage({type:"write",pvName:t,value:e},"*")}createHistoricalDataProvider(t,e){return new cs(t,e)}shutdown(){}};export{ye as AlarmSeverity,nw as AutoScaleOverride,m as Color,Qe as CompiledFormula,We as DefaultConsoleHandler,ke as DefaultDialogHandler,Fe as DefaultImageLoader,Je as DefaultPathResolver,to as Display,U as Font,ei as FormulaCompiler,ae as PV,eo as PostMessageImageLoader,ro as PostMessagePVProvider,io as PostMessageScriptLoader,M as Widget,tx as colorFromCssColor};
|
|
22
|
+
`))r=r.concat(this.wrapLine(t,s,i));return r}wrapLine(t,e,i){if(!e)return[""];let r=[];for(;e.length;){let s;for(s=e.length;t.measureText(e.substr(0,s),this.font).width>i;s--);let o;if(s===e.length)o=e;else if(e[s]===" ")o=e.substr(0,s+1);else{let n=e.substr(0,s),a=0;for(;n.indexOf(" ",a)!==-1;a=n.indexOf(" ",a)+1);if(a)o=n.substr(0,a);else{let h=e.indexOf(" ");o=h===-1?e:e.substr(0,h)}}r.push(o),e=e.substr(o.length)}return r}get autoSize(){return this.properties.getValue(Im)}get font(){return this.properties.getValue(Fs).scale(this.scale)}get formatType(){return this.properties.getValue(Bm)}get horizAlignment(){return this.properties.getValue(Hm)}get precision(){return this.properties.getValue(Dm)}get precisionFromPV(){return this.properties.getValue(Wm)}get rotationAngle(){return this.properties.getValue(km)}get showLohi(){return this.properties.getValue(Nm)}get showUnits(){return this.properties.getValue(Fm)}get vertAlignment(){return this.properties.getValue(Gm)}get wrapWords(){return this.properties.getValue($m)}};var Um="color_hi",Ym="color_hihi",zm="color_lo",Xm="color_lolo",qm="color_fillbackground",Km="fill_color",jm="fillcolor_alarm_sensitive",Zm="font",Jm="effect_3d",Qm="level_hi",tf="level_hihi",ef="level_lo",rf="level_lolo",sf="limits_from_pv",of="log_scale",nf="maximum",af="major_tick_step_hint",hf="minimum",lf="scale_font",cf="scale_format",pf="show_bulb",df="show_hi",uf="show_hihi",gf="show_lo",mf="show_lolo",ff="show_markers",wf="show_minor_ticks",xf="show_scale",yf="transparent_background",Pf="unit",bf="value_label_format",vf=new m(160,160,160),Xr=class extends M{tooltipRegion;constructor(t,e){super(t,e),this.properties.add(new S(Um)),this.properties.add(new S(Ym)),this.properties.add(new S(zm)),this.properties.add(new S(Xm)),this.properties.add(new S(qm)),this.properties.add(new S(Km)),this.properties.add(new f(jm,!1)),this.properties.add(new f(Jm)),this.properties.add(new C(Qm)),this.properties.add(new C(tf)),this.properties.add(new C(ef)),this.properties.add(new C(rf)),this.properties.add(new f(sf,!0)),this.properties.add(new H(Zm)),this.properties.add(new f(of)),this.properties.add(new C(nf)),this.properties.add(new C(af)),this.properties.add(new C(hf)),this.properties.add(new H(lf)),this.properties.add(new T(cf)),this.properties.add(new f(pf)),this.properties.add(new f(df)),this.properties.add(new f(uf)),this.properties.add(new f(gf)),this.properties.add(new f(mf)),this.properties.add(new f(ff)),this.properties.add(new f(wf)),this.properties.add(new f(xf)),this.properties.add(new f(yf)),this.properties.add(new P(Pf)),this.properties.add(new T(bf))}init(){this.tooltipRegion={id:`${this.wuid}-tooltip`,tooltip:()=>this.tooltip}}draw(t){let{scale:e,min:i,max:r}=this,s=this.area;this.borderAlarmSensitive&&(s=D(this.area,2*this.scale));let o=this.alarmSensitiveBackgroundColor,n=this.alarmSensitiveForegroundColor,a=this.alarmSensitiveFillColor;this.transparentBackground||t.fillRect({...s,color:o}),this.tooltip&&t.addHitRegion(this.tooltipRegion).addRect(this.x,this.y,this.width,this.height);let h=s.height;if(this.showBulb){let A=Math.min(s.width/2,this.bulbMaxDiameter);h=s.height<A?0:s.height-A}let l={...s,height:h},c=new ot(this.display.formatter,e,this.scaleFont,i,r,this.logScale,this.majorTickStepHint,n,this.showMinorTicks,this.showScale);c.scaleFormat=this.scaleFormat;let d=0,g="";if(this.unit===0?g="\xB0C":this.unit===1?g="\xB0F":this.unit===2&&(g="K"),g){let A=U.ARIAL_9.scale(e),E=t.measureText(g,A),I=2*e;d=E.height+2*I,t.fillText({x:s.x+s.width/2-this.pipeWidth/2-I,y:s.y+I,baseline:"top",align:"right",color:n,font:A,text:g})}let w=l.x+l.width/2-this.pipeWidth/2-1*e,x={...l,y:l.y+d,height:l.height-d+c.calculateMargin(t,!1)},_=c.drawVertical(t,w,x.y,x.height,!1),L=Math.floor(this.pipeWidth/2);if(l={...l,y:c.getValuePosition(r)-L,height:c.scaleLength+2*L},this.drawPipe(t,l,c),this.showMarkers&&this.drawMarkers(t,s,c),this.showBulb){let A=Math.min(s.width/2,this.bulbMaxDiameter),E=1*e,I=s.x+s.width/2,k=s.y+h+A/2,F=A/2,Y=A/2;if(t.fillEllipse({cx:I,cy:k,rx:F,ry:Y,color:a}),this.effect3d){let ht=t.createLinearGradient(I-F,k-Y,I+F,k+Y);ht.addColorStop(0,m.WHITE.toString()),ht.addColorStop(1,a.withAlpha(0).toString()),t.fillEllipse({cx:I,cy:k,rx:F,ry:Y,gradient:ht})}t.strokeEllipse({cx:I,cy:k,rx:F-E/2,ry:Y-E/2,color:this.effect3d?vf:n,lineWidth:E});let K={x:Math.round(l.x+l.width/2-this.pipeWidth/2)+this.outlineWidth,y:Math.floor(c.getValuePosition(i)),width:this.pipeWidth-2*this.outlineWidth,height:e*3};if(this.effect3d){let ht=Math.round(l.x+l.width/2-this.pipeWidth/2),Lt=ht+this.pipeWidth,pt=t.createLinearGradient(ht,K.y,Lt,K.y);pt.addColorStop(0,m.WHITE.toString()),pt.addColorStop(1,a.toString()),t.fillRect({...K,gradient:pt})}else t.fillRect({...K,color:a});let mt=this.value;mt!==void 0&&t.fillText({x:I,y:k,align:"center",baseline:"middle",color:a.contrast(),font:this.font,text:this.format(mt)})}}drawPipe(t,e,i){let{scale:r,outlineWidth:s,min:o,max:n}=this,a=this.alarmSensitiveForegroundColor,h=this.alarmSensitiveFillColor,l={x:Math.round(e.x+e.width/2-this.pipeWidth/2),y:e.y,width:this.pipeWidth,height:e.height},c=this.getFillValue(),d=i.getValuePosition(c);n>o?c>n?d-=10*r:c<o&&(d+=10*r):c>o?d+=10*r:c<n&&(d-=10*r);let g=this.pipeWidth/2,{x:w,y:x,width:_,height:L}=l;if(this.effect3d){let E=t.createLinearGradient(w,x,w+_,x);E.addColorStop(0,m.WHITE.toString()),E.addColorStop(1,this.colorFillbackground.toString()),t.fillRect({...l,rx:g/2,ry:g/2,gradient:E}),E=t.createLinearGradient(w,x,w+_,x),E.addColorStop(0,m.WHITE.toString()),E.addColorStop(1,h.toString()),t.fillRect({x:w,y:d,width:_,height:x+L-d,rx:g/2,ry:g/2,gradient:E})}else t.fillRect({...l,rx:g/2,ry:g/2,color:this.colorFillbackground}),t.fillRect({x:w,y:d,width:_,height:x+L-d,rx:g/2,ry:g/2,color:h});let A=D(l,s/2);t.strokeRect({...A,rx:g/2,ry:g/2,color:this.effect3d?vf:a,lineWidth:s})}drawMarkers(t,e,i){let{lolo:r,lo:s,hi:o,hihi:n}=this,a=U.ARIAL_9.scale(this.scale),h=e.x+e.width/2+this.pipeWidth/2;if(this.showLoLo&&r!==void 0){let l=Math.round(i.getValuePosition(r));t.strokePath({path:new R(h,l).lineTo(h+this.markerTickLength,l),color:this.colorLoLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:h+this.markerTickLength+this.markerGap,y:l,text:"LOLO",align:"left",baseline:"middle",color:this.colorLoLo,font:a})}if(this.showLo&&s!==void 0){let l=Math.round(i.getValuePosition(s));t.strokePath({path:new R(h,l).lineTo(h+this.markerTickLength,l),color:this.colorLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:h+this.markerTickLength+this.markerGap,y:l,text:"LO",align:"left",baseline:"middle",color:this.colorLo,font:a})}if(this.showHi&&o!==void 0){let l=Math.round(i.getValuePosition(o));t.strokePath({path:new R(h,l).lineTo(h+this.markerTickLength,l),color:this.colorHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:h+this.markerTickLength+this.markerGap,y:l,text:"HI",align:"left",baseline:"middle",color:this.colorHi,font:a})}if(this.showHiHi&&n!==void 0){let l=Math.round(i.getValuePosition(n));t.strokePath({path:new R(h,l).lineTo(h+this.markerTickLength,l),color:this.colorHiHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:h+this.markerTickLength+this.markerGap,y:l,text:"HIHI",align:"left",baseline:"middle",color:this.colorHiHi,font:a})}}get min(){return this.limitsFromPv?this.pv?.lowerDisplayLimit??this.minimum:this.minimum}get max(){return this.limitsFromPv?this.pv?.upperDisplayLimit??this.maximum:this.maximum}get lolo(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.lowerAlarmLimit:this.levelLoLo}get lo(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.lowerWarningLimit:this.levelLo}get hi(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.upperWarningLimit:this.levelHi}get hihi(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.upperAlarmLimit:this.levelHiHi}get pipeWidth(){return this.scale*15}get bulbMaxDiameter(){return this.scale*40}get outlineWidth(){return this.scale*1}get markerTickLength(){return this.scale*10}get markerTickLineWidth(){return this.scale*2}get markerGap(){return this.scale*3}get alarmSensitiveFillColor(){if(this.fillColorAlarmSensitive){if(this.isMajorSeverity())return this.display.majorColor;if(this.isMinorSeverity())return this.display.minorColor}return this.fillColor}getFillValue(){let t=this.value??this.min;return t=Math.max(this.min,t),t=Math.min(this.max,t),t}format(t){return this.valueLabelFormat?new it(this.valueLabelFormat).format(t):String(Number(t.toFixed(3)))}get colorLo(){return this.properties.getValue(zm)}get colorLoLo(){return this.properties.getValue(Xm)}get colorHi(){return this.properties.getValue(Um)}get colorHiHi(){return this.properties.getValue(Ym)}get colorFillbackground(){return this.properties.getValue(qm)}get fillColorAlarmSensitive(){return this.properties.getValue(jm)}get fillColor(){return this.properties.getValue(Km)}get font(){return this.properties.getValue(Zm).scale(this.scale)}get effect3d(){return this.properties.getValue(Jm)}get levelLo(){return this.properties.getValue(ef)}get levelLoLo(){return this.properties.getValue(rf)}get levelHi(){return this.properties.getValue(Qm)}get levelHiHi(){return this.properties.getValue(tf)}get limitsFromPv(){return this.properties.getValue(sf)}get logScale(){return this.properties.getValue(of)}get minimum(){return this.properties.getValue(hf)}get majorTickStepHint(){return this.scale*this.properties.getValue(af)}get maximum(){return this.properties.getValue(nf)}get scaleFont(){return this.properties.getValue(lf).scale(this.scale)}get scaleFormat(){return this.properties.getValue(cf)}get showBulb(){return this.properties.getValue(pf)}get showMarkers(){return this.properties.getValue(ff)}get showMinorTicks(){return this.properties.getValue(wf)}get showLo(){return this.properties.getValue(gf)}get showLoLo(){return this.properties.getValue(mf)}get showHi(){return this.properties.getValue(df)}get showHiHi(){return this.properties.getValue(uf)}get showScale(){return this.properties.getValue(xf)}get transparentBackground(){return this.properties.getValue(yf)}get unit(){return this.properties.getValue(Pf)}get valueLabelFormat(){return this.properties.getValue(bf)}};var Rf=-323.3062,_f=308.2547,qr=class{constructor(t,e){this.widget=t;this.index=e}widget;index;linearScale;_effectiveMinimum;_effectiveMaximum;get scale(){return this.widget.scale}getValue(t){return this.widget.properties.getValue(`axis_${this.index}_${t}`)}isDateEnabled(){return this.timeFormat!==0}isHorizontal(){return this.index===0||this.index!==1&&!this.yAxis}isVertical(){return!this.isHorizontal()}isPrimary(){return this.index<=1}get effectiveMinimum(){return this._effectiveMinimum??this.minimum}set effectiveMinimum(t){this._effectiveMinimum=t}get effectiveMaximum(){return this._effectiveMaximum??this.maximum}set effectiveMaximum(t){this._effectiveMaximum=t}performAutoScale(){let t={start:this.minimum,stop:this.maximum},e=this.widget.calculateAutoscaledRange(this,t);e&&(this.effectiveMinimum=e.start,this.effectiveMaximum=e.stop,this.widget.requestRepaint())}applyZoom(t,e){let i=this.effectiveMinimum,r=this.effectiveMaximum,s,o;if(this.logScale){r=Math.log10(r),i=Math.log10(i);let n=Math.log10(t)*e,a=1-e;s=n+i*a,o=n+r*a,s<Rf&&(s=Rf),s=Math.pow(10,s),o>_f&&(o=_f),o=Math.pow(10,o)}else{let n=Math.max(Math.abs(i),Math.abs(r));i/=n,r/=n;let a=t/n*e,h=1-e;s=(a+i*h)*n,o=(a+r*h)*n}this.effectiveMinimum=s,this.effectiveMaximum=o,this.widget.requestRepaint()}get autoScale(){return this.getValue("auto_scale")}get autoScaleThreshold(){return this.getValue("auto_scale_threshold")}get axisColor(){return this.getValue("axis_color")}get axisTitle(){return this.getValue("axis_title")}get dashGridLine(){return this.getValue("dash_grid_line")}get gridColor(){return this.getValue("grid_color")}get leftBottomSide(){return this.getValue("left_bottom_side")}get logScale(){return this.getValue("log_scale")}get maximum(){return this.getValue("maximum")}get minimum(){return this.getValue("minimum")}get scaleFont(){return this.getValue("scale_font").scale(this.scale)}get scaleFormat(){return this.getValue("scale_format")}get showGrid(){return this.getValue("show_grid")}get timeFormat(){return this.getValue("time_format")}get titleFont(){return this.getValue("title_font").scale(this.scale)}get visible(){return this.getValue("visible")}get yAxis(){return this.getValue("y_axis")}};var St=class{constructor(t,e){this.xAxis=t;this.yAxis=e;for(let i of t)this.beforeXRanges.push({min:i.effectiveMinimum,max:i.effectiveMaximum});for(let i of e)this.beforeYRanges.push({min:i.effectiveMinimum,max:i.effectiveMaximum})}xAxis;yAxis;beforeXRanges=[];beforeYRanges=[];afterXRanges=[];afterYRanges=[];saveState(){for(let t of this.xAxis)this.afterXRanges.push({min:t.effectiveMinimum,max:t.effectiveMaximum});for(let t of this.yAxis)this.afterYRanges.push({min:t.effectiveMinimum,max:t.effectiveMaximum})}undo(){for(let t=0;t<this.xAxis.length;t++){let e=this.xAxis[t],i=this.beforeXRanges[t];e.effectiveMinimum=i.min,e.effectiveMaximum=i.max}for(let t=0;t<this.yAxis.length;t++){let e=this.yAxis[t],i=this.beforeYRanges[t];e.effectiveMinimum=i.min,e.effectiveMaximum=i.max}}redo(){for(let t=0;t<this.xAxis.length;t++){let e=this.xAxis[t],i=this.afterXRanges[t];e.effectiveMinimum=i.min,e.effectiveMaximum=i.max}for(let t=0;t<this.yAxis.length;t++){let e=this.yAxis[t],i=this.afterYRanges[t];e.effectiveMinimum=i.min,e.effectiveMaximum=i.max}}},Kr=class{undoStack=[];redoStack=[];canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}add(t){this.undoStack.push(t),this.redoStack.length=0}undo(){let t=this.undoStack.pop();t&&(t.undo(),this.redoStack.push(t))}redo(){let t=this.redoStack.pop();t&&(t.redo(),this.undoStack.push(t))}};var jr=class{constructor(t,e){this.widget=e;this.id=t}widget;id;cursor;selection;grabStart;prevGrabEvent;grabZoomCommand;tooltip(){return this.widget.tooltip}mouseDown(t){let{widget:e}=this;switch(e.toolbar?.currentTool){case"rubberband-zoom":case"horizontal-zoom":case"vertical-zoom":this.grabStart=t;break;case"panning":this.grabZoomCommand=new St(e.getXAxes(),e.getYAxes());break}}grab(t){switch(this.widget.toolbar?.currentTool){case"rubberband-zoom":case"horizontal-zoom":case"vertical-zoom":this.grabStart&&(this.selection={...this.grabStart.point,width:t.dx,height:t.dy},this.widget.requestRepaint());break;case"panning":this.pan(t),this.prevGrabEvent=t,this.widget.requestRepaint();break}}grabEnd(){let{grabZoomCommand:t,selection:e,widget:i}=this;switch(i.toolbar?.currentTool){case"rubberband-zoom":if(e){let r=new St(i.getXAxes(),i.getYAxes());this.rangeZoomXAxes(e),this.rangeZoomYAxes(e),r.saveState(),i.toolbar.addCommand(r)}break;case"horizontal-zoom":if(e){let r=new St(i.getXAxes(),i.getYAxes());this.rangeZoomXAxes(e),r.saveState(),i.toolbar.addCommand(r)}break;case"vertical-zoom":if(e){let r=new St(i.getXAxes(),i.getYAxes());this.rangeZoomYAxes(e),r.saveState(),i.toolbar.addCommand(r)}break;case"panning":t&&(t.saveState(),i.toolbar.addCommand(t));break}this.selection=void 0,this.prevGrabEvent=void 0,this.grabZoomCommand=void 0,this.widget.requestRepaint()}click(t){let{widget:e}=this;switch(e.toolbar?.currentTool){case"zoom-in":let i=new St(e.getXAxes(),e.getYAxes());for(let s of e.getAxes()){let o=s.isHorizontal()?t.point.x:t.point.y,n=s.linearScale.getPositionValue(o);s.applyZoom(n,.1)}i.saveState(),e.toolbar.addCommand(i);break;case"zoom-out":let r=new St(e.getXAxes(),e.getYAxes());for(let s of e.getAxes()){let o=s.isHorizontal()?t.point.x:t.point.y,n=s.linearScale.getPositionValue(o);s.applyZoom(n,-.1)}r.saveState(),e.toolbar.addCommand(r);break}}rangeZoomXAxes(t){for(let e of this.widget.getXAxes()){let i=e.linearScale.getPositionValue(t.x),r=e.linearScale.getPositionValue(t.x+t.width);if(i>r){let o=i;i=r,r=o}let s=e.linearScale.getMinMax();i=Math.max(s.start,i),r=Math.min(s.stop,r),e.effectiveMinimum=i,e.effectiveMaximum=r}}rangeZoomYAxes(t){for(let e of this.widget.getYAxes()){let i=e.linearScale.getPositionValue(t.y),r=e.linearScale.getPositionValue(t.y+t.height);if(i>r){let o=i;i=r,r=o}let s=e.linearScale.getMinMax();i=Math.max(s.start,i),r=Math.min(s.stop,r),e.effectiveMinimum=i,e.effectiveMaximum=r}}pan(t){let{prevGrabEvent:e,widget:i}=this;if(e){let r=e.dx-t.dx;if(r!==0)for(let o of i.getXAxes()){let n=o.linearScale,a=n.getMinMax(),h=n.getValuePosition(a.start)+r,l=n.getValuePosition(a.stop)+r;o.effectiveMinimum=n.getPositionValue(h),o.effectiveMaximum=n.getPositionValue(l)}let s=e.dy-t.dy;if(s!==0)for(let o of i.getYAxes()){let n=o.linearScale,a=n.getMinMax(),h=n.getValuePosition(a.start)+s,l=n.getValuePosition(a.stop)+s;o.effectiveMinimum=n.getPositionValue(h),o.effectiveMaximum=n.getPositionValue(l)}}}};var Gs=class{pointer=0;samples=[];constructor(t){this.samples=Array(t).fill(void 0)}push(t,e){this.samples[this.pointer]={x:t,y:e},this.pointer=(this.pointer+1)%this.samples.length}clear(){this.samples.fill(void 0),this.pointer=0}isFull(){let t=(this.pointer+1)%this.samples.length;return this.samples[t]!==void 0}isEmpty(){return this.tail()===void 0}tail(){return this.pointer===0?this.samples[this.samples.length-1]:this.samples[this.pointer-1]}snapshot(t=!1){if(t)return this.samples.filter(i=>i!==void 0).sort((i,r)=>i.x-r.x);{let e=this.samples.slice(this.pointer).filter(r=>r!==void 0),i=this.samples.slice(0,this.pointer).filter(r=>r!==void 0);return e.concat(i)}}},Zr=class{constructor(t,e,i,r,s,o){this.bufferSize=t;this.plotMode=e;this.updateMode=i;this.concatenateData=r;this.chronological=s;this.historicalDataProvider=o;this.traceData=new Gs(t)}bufferSize;plotMode;updateMode;concatenateData;chronological;historicalDataProvider;traceData;x=0;xPending=!1;y=0;yTimestamp=0;yPending=!1;xArray=[];xArrayPending=!1;yArray=[];yArrayPending=!1;clear(){this.traceData.clear(),this.x=0,this.xPending=!1,this.y=0,this.yPending=!1,this.yTimestamp=0,this.xArray=[],this.xArrayPending=!1,this.yArray=[],this.yArrayPending=!1}snapshot(){return this.historicalDataProvider?this.historicalDataProvider.getSamples():this.traceData.snapshot()}updateX(t){this.x=t,this.xPending=!0,this.maybeAddPoint()}updateY(t,e){this.y=t,this.yTimestamp=e,this.yPending=!0,this.maybeAddPoint()}updateXArray(t){this.xArray=t,this.xArrayPending=!0,this.maybeAddArray()}updateYArray(t){this.yArray=t,this.yArrayPending=!0,this.maybeAddArray()}maybeAddPoint(){if(this.plotMode===1&&this.traceData.isFull())return;let{xPending:t,yPending:e,chronological:i,updateMode:r}=this;r===0?(i&&e||!i&&(t||e))&&this.addPoint():r===1?(i&&e||!i&&t&&e)&&this.addPoint():r===2?(i&&e||!i&&t)&&this.addPoint():r===3&&this.yPending&&this.addPoint()}maybeAddArray(){if(this.plotMode===1&&this.traceData.isFull())return;let{xArrayPending:t,yArrayPending:e,chronological:i,updateMode:r}=this;r===0?(i&&e||!i&&(t||e))&&this.addArray():r===1?(i&&e||!i&&t&&e)&&this.addArray():r===2?(i&&e||!i&&t)&&this.addArray():r===3&&this.yArrayPending&&this.addArray()}addPoint(){this.concatenateData||this.traceData.clear();let t=this.x;if(this.chronological)if(this.updateMode===5)t=new Date().getTime();else if(this.yTimestamp!==void 0)t=this.yTimestamp;else{let e=this.traceData.tail();t=e?e.x+1:0}this.traceData.push(t,this.y),this.xPending=!1,this.yPending=!1}addArray(){this.concatenateData||this.traceData.clear();let{xArray:t,yArray:e}=this;if(this.chronological)if(t=Array(e.length),this.traceData.isEmpty())for(let s=0;s<e.length;s++)t[s]=s;else{let s=this.traceData.tail();for(let o=1;o<e.length;o++)t[o-1]=s.x+o}let i=Math.min(t.length,e.length),r=Math.min(i,this.bufferSize);for(let s=0;s<r;s++)this.traceData.push(t[s],e[s]);this.xArrayPending=!1,this.yArrayPending=!1}};var Jr=class{constructor(t,e){this.widget=t;this.i=e}widget;i;traceData;historicalDataProvider;xPVInstance;yPVInstance;xPVListener=()=>{let t=this.xPVInstance;if(t)if(Array.isArray(t.value))this.traceData?.updateXArray(t.value);else{let e=t.toNumber();e!=null&&this.traceData?.updateX(e)}};yPVListener=()=>{let t=this.yPVInstance;if(t)if(Array.isArray(t.value))this.traceData?.updateYArray(t.value);else{let e=this.widget.getAxis(this.xAxisIndex),i=t.toNumber();if(i!=null)if(e.isDateEnabled()){let r=(t.time||new Date).getTime();this.traceData?.updateY(i,r)}else this.traceData?.updateY(i)}};init(){let{bufferSize:t,plotMode:e,updateMode:i,concatenateData:r,widget:s}=this,o=!this.xPV,{pvEngine:n}=s.display;this.historicalDataProvider=void 0,o&&this.yPV&&(this.historicalDataProvider=n.createHistoricalDataProvider(this.yPV,s)||void 0),this.traceData=new Zr(t,e,i,r,o,this.historicalDataProvider),this.xPV&&(this.xPVInstance=n.createPV(this.xPV),this.xPVInstance.addListener(this.xPVListener)),this.yPV&&(this.yPVInstance=n.createPV(this.yPV),this.yPVInstance.addListener(this.yPVListener)),s.addPropertyListener(`trace_${this.i}_x_pv`,()=>{let a=n.createPV(this.xPV);a!==this.xPVInstance&&(this.xPVInstance?.removeListener(this.xPVListener),this.xPVInstance=a,this.xPVInstance.addListener(this.xPVListener))}),s.addPropertyListener(`trace_${this.i}_y_pv`,()=>{let a=n.createPV(this.yPV);a!==this.yPVInstance&&(this.yPVInstance?.removeListener(this.yPVListener),this.yPVInstance=a,this.yPVInstance.addListener(this.yPVListener))})}snapshot(){return this.traceData?.snapshot()||[]}drawTrace(t,e){let{lineWidth:i}=this;if(this.traceType===0)t.strokePath({path:R.fromPoints(e),color:this.traceColor,lineWidth:i});else if(this.traceType===1)t.strokePath({path:R.fromPoints(e),color:this.traceColor,lineWidth:i,dash:[6*this.scale,2*this.scale]});else if(this.traceType!==2){if(this.traceType===3){let s=this.widget.getAxis(this.yAxisIndex).linearScale.getValuePosition(0);for(let o of e)o.y!==null&&t.strokePath({path:new R(o.x,o.y).lineTo(o.x,s),lineWidth:i,color:this.traceColor,opacity:100/255})}else if(this.traceType===4||this.traceType===5){let s=this.widget.getAxis(this.yAxisIndex).linearScale.getValuePosition(0);for(let o=1;o<e.length;o++){let n=e[o-1],a=e[o];n.y!==null&&a.y!==null&&t.fillPath({path:new R(n.x,n.y).lineTo(n.x,s).lineTo(a.x,s).lineTo(a.x,a.y),color:this.traceColor,opacity:100/255})}this.traceType===5&&t.strokePath({path:R.fromPoints(e),color:this.traceColor,lineWidth:i})}else if(this.traceType===6)for(let r=1;r<e.length;r++){let s=e[r-1],o=e[r];s.y!==null&&o.y!==null&&t.strokePath({path:new R(s.x,s.y).lineTo(s.x,o.y).lineTo(o.x,o.y),color:this.traceColor,lineWidth:i})}else if(this.traceType===7)for(let r=1;r<e.length;r++){let s=e[r-1],o=e[r];s.y!==null&&o.y!==null&&t.strokePath({path:new R(s.x,s.y).lineTo(o.x,s.y).lineTo(o.x,o.y),color:this.traceColor,lineWidth:i})}else if(this.traceType===8){let{scale:r}=this;t.strokePath({path:R.fromPoints(e),color:this.traceColor,lineWidth:i,dash:[6*r,2*r,2*r,2*r]})}else if(this.traceType===9){let{scale:r}=this;t.strokePath({path:R.fromPoints(e),color:this.traceColor,lineWidth:i,dash:[6*r,2*r,2*r,2*r,2*r,2*r]})}else if(this.traceType===10){let{scale:r}=this;t.strokePath({path:R.fromPoints(e),color:this.traceColor,lineWidth:i,dash:[2*r,2*r]})}}}drawPoint(t,e){t.ctx.fillStyle=this.traceColor.toString(),t.ctx.strokeStyle=this.traceColor.toString(),t.ctx.lineWidth=1*this.scale;let i=this.pointSize/2,r=e.x,s=e.y;switch(this.pointStyle){case 1:t.ctx.beginPath(),t.ctx.ellipse(r,s,i,i,0,0,2*Math.PI),t.ctx.fill();break;case 2:t.ctx.beginPath(),t.ctx.ellipse(r,s,i,i,0,0,2*Math.PI),t.ctx.stroke();break;case 3:t.ctx.beginPath(),t.ctx.ellipse(r,s,i,i,0,0,2*Math.PI),t.ctx.fill();break;case 4:t.ctx.lineWidth=1*this.scale,t.ctx.beginPath(),t.ctx.moveTo(r-i,s+i),t.ctx.lineTo(r,s-i),t.ctx.lineTo(r+i,s+i),t.ctx.closePath(),t.ctx.stroke();break;case 5:t.ctx.lineWidth=1*this.scale,t.ctx.beginPath(),t.ctx.moveTo(r-i,s+i),t.ctx.lineTo(r,s-i),t.ctx.lineTo(r+i,s+i),t.ctx.closePath(),t.ctx.fill();break;case 6:t.ctx.strokeRect(r-i,s-i,2*i,2*i);break;case 7:t.ctx.fillRect(r-i,s-i,2*i,2*i);break;case 8:t.ctx.beginPath(),t.ctx.moveTo(r-i,s),t.ctx.lineTo(r,s-i),t.ctx.lineTo(r+i,s),t.ctx.lineTo(r,s+i),t.ctx.closePath(),t.ctx.stroke();break;case 9:t.ctx.beginPath(),t.ctx.moveTo(r-i,s),t.ctx.lineTo(r,s-i),t.ctx.lineTo(r+i,s),t.ctx.lineTo(r,s+i),t.ctx.closePath(),t.ctx.stroke();break;case 10:t.ctx.beginPath(),t.ctx.moveTo(r-i,s-i),t.ctx.lineTo(r+i,s+i),t.ctx.moveTo(r+i,s-i),t.ctx.lineTo(r-i,s+i),t.ctx.stroke();break;case 11:t.ctx.beginPath(),t.ctx.moveTo(r-i,s),t.ctx.lineTo(r+i,s),t.ctx.moveTo(r,s-i),t.ctx.lineTo(r,s+i),t.ctx.stroke();break;case 12:t.ctx.beginPath(),t.ctx.moveTo(r,s-i),t.ctx.lineTo(r,s+i),t.ctx.stroke()}}clearData(){this.traceData?.clear()}get scale(){return this.widget.scale}getValue(t){return this.widget.properties.getValue(`trace_${this.i}_${t}`)}get antiAlias(){return this.getValue("anti_alias")}get bufferSize(){return this.getValue("buffer_size")}get concatenateData(){return this.getValue("concatenate_data")}get lineWidth(){return this.scale*this.getValue("line_width")}get name(){return this.getValue("name")}get plotMode(){return this.getValue("plot_mode")}get pointSize(){return this.scale*this.getValue("point_size")}get pointStyle(){return this.getValue("point_style")}get traceColor(){return this.getValue("trace_color")}get traceType(){return this.getValue("trace_type")}get updateDelay(){return this.getValue("update_delay")}get updateMode(){return this.getValue("update_mode")}get visible(){return this.getValue("visible")}get xAxisIndex(){return this.getValue("x_axis_index")}get xPV(){return this.getValue("x_pv")}get yAxisIndex(){return this.getValue("y_axis_index")}get yPV(){return this.getValue("y_pv")}destroy(){this.historicalDataProvider?.disconnect()}};var jy=new m(236,236,236),Zy=new m(130,130,130),$s=class{constructor(t,e,i,r,s){this.imageFile=e;this.disabledImageFile=i;this.action=s;this.loadPromise=new Promise((o,n)=>{this.imageElement.onload=()=>o()}),this.disabledLoadPromise=new Promise((o,n)=>{this.disabledImageElement.onload=()=>o()}),this.region={id:`${t.xyGraph.wuid}-${e}`,mouseDown:()=>{this.toggleButton||(this.pushed=!0,t.xyGraph.requestRepaint())},mouseOut:()=>{this.toggleButton||(this.pushed=!1),t.xyGraph.requestRepaint()},mouseUp:()=>{this.toggleButton||(this.pushed=!1,t.xyGraph.requestRepaint())},click:()=>{this.toggleButton&&(this.pushed=!this.pushed,this.toolButton&&t.toggleTool(this)),this.action(),t.updateState()},tooltip:()=>r}}imageFile;disabledImageFile;action;imageElement=new Image;disabledImageElement=new Image;loadPromise;disabledLoadPromise;toggleButton=!1;toolButton=!1;pushed=!1;disabled=!1;region;loadImage(t){this.imageElement.src=t+this.imageFile,this.disabledImageElement.src=t+this.disabledImageFile}},Qr=class{constructor(t){this.xyGraph=t;this.showLegend=this.createToggleButton("ShowLegend.png","Show Legend",()=>{t.properties.setValue("show_legend",this.showLegend.pushed)}),this.showLegend.pushed=t.showLegend,t.addPropertyListener("show_legend",i=>{this.showLegend.pushed=i}),this.autoScale=this.createButton("AutoScale.png","AutoScale.png","Perform Auto Scale",()=>{let i=new St(t.getXAxes(),t.getYAxes());t.performAutoScale(),i.saveState(),this.addCommand(i)}),this.rubberbandZoom=this.createToolButton("RubberbandZoom.png","Rubberband Zoom",()=>{this.rubberbandZoom.pushed?(this.currentTool="rubberband-zoom",t.setCursor("crosshair"),t.autoScaleAllowed=!1):(this.currentTool="default",t.setCursor(void 0),t.autoScaleAllowed=!0)}),this.horizontalZoom=this.createToolButton("HorizontalZoom.png","Horizontal Zoom",()=>{this.horizontalZoom.pushed?(this.currentTool="horizontal-zoom",t.setCursor("col-resize"),t.autoScaleAllowed=!1):(this.currentTool="default",t.setCursor(void 0),t.autoScaleAllowed=!0)}),this.verticalZoom=this.createToolButton("VerticalZoom.png","Vertical Zoom",()=>{this.verticalZoom.pushed?(this.currentTool="vertical-zoom",t.setCursor("row-resize"),t.autoScaleAllowed=!1):(this.currentTool="default",t.setCursor(void 0),t.autoScaleAllowed=!0)}),this.zoomIn=this.createToolButton("ZoomIn.png","Zoom In",()=>{this.zoomIn.pushed?(this.currentTool="zoom-in",t.setCursor("zoom-in"),t.autoScaleAllowed=!1):(this.currentTool="default",t.setCursor(void 0),t.autoScaleAllowed=!0)}),this.zoomOut=this.createToolButton("ZoomOut.png","Zoom Out",()=>{this.zoomOut.pushed?(this.currentTool="zoom-out",t.setCursor("zoom-out"),t.autoScaleAllowed=!1):(this.currentTool="default",t.setCursor(void 0),t.autoScaleAllowed=!0)}),this.panning=this.createToolButton("Panning.png","Panning",()=>{this.panning.pushed?(this.currentTool="panning",t.setCursor("grab"),t.autoScaleAllowed=!1):(this.currentTool="default",t.setCursor(void 0),t.autoScaleAllowed=!0)}),this.mouseArrow=this.createToolButton("MouseArrow.png","None",()=>{this.currentTool="default",t.setCursor(void 0),t.autoScaleAllowed=!0}),this.undo=this.createButton("Undo.png","Undo_Gray.png","Undo",()=>{this.commandBuffer.undo()}),this.undo.disabled=!0,this.redo=this.createButton("Redo.png","Redo_Gray.png","Redo",()=>{this.commandBuffer.redo()}),this.redo.disabled=!0,this.camera=this.createButton("camera.png","camera.png","Save Snapshot to PNG File",()=>{let i=document.createElement("a");try{i.href=t.toDataURL(),i.download=`${t.name}_export.png`,document.body.appendChild(i),i.click()}finally{document.body.removeChild(i)}}),this.toggleTool(this.mouseArrow);let e=this.buttons.map(i=>i.loadPromise).concat(this.buttons.map(i=>i.disabledLoadPromise));Promise.all(e).finally(()=>{this.imagesLoaded=!0,t.requestRepaint()});for(let i of this.buttons)i.loadImage(t.display.imagesPrefix)}xyGraph;buttons=[];showLegend;autoScale;rubberbandZoom;horizontalZoom;verticalZoom;zoomIn;zoomOut;panning;mouseArrow;undo;redo;camera;imagesLoaded=!1;currentTool="default";commandBuffer=new Kr;updateState(){this.undo.disabled=!this.commandBuffer.canUndo(),this.redo.disabled=!this.commandBuffer.canRedo(),this.xyGraph.requestRepaint()}addCommand(t){this.commandBuffer.add(t),this.updateState()}toggleTool(t){let e=t.pushed;for(let i of this.buttons)i.toolButton&&(i.pushed=!1);e?t.pushed=!0:this.mouseArrow.pushed=!0,this.xyGraph.requestRepaint()}createToolButton(t,e,i){let r=this.createToggleButton(t,e,i);return r.toolButton=!0,r}createToggleButton(t,e,i){let r=this.createButton(t,t,e,i);return r.toggleButton=!0,r}createButton(t,e,i,r){let s=new $s(this,t,e,i,r);return this.buttons.push(s),s}draw(t,e){let{buttonSize:i}=this,r={x:e.x,y:e.y};return this.drawButton(t,r.x,r.y,this.showLegend),r.x+=i,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.autoScale),r.x+=i,this.maybeWrap(r,e,i/2),this.drawSeparator(t,r.x,r.y),r.x+=i/2,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.rubberbandZoom),r.x+=i,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.horizontalZoom),r.x+=i,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.verticalZoom),r.x+=i,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.zoomIn),r.x+=i,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.zoomOut),r.x+=i,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.panning),r.x+=i,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.mouseArrow),r.x+=i,this.maybeWrap(r,e,i/2),this.drawSeparator(t,r.x,r.y),r.x+=i/2,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.undo),r.x+=i,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.redo),r.x+=i,this.maybeWrap(r,e,i/2),this.drawSeparator(t,r.x,r.y),r.x+=i/2,this.maybeWrap(r,e),this.drawButton(t,r.x,r.y,this.camera),r.x+=i,r.y+i-e.y}maybeWrap(t,e,i){i=i??this.buttonSize,t.x+i>e.x+e.width&&(t.x=e.x,t.y+=this.buttonSize)}drawSeparator(t,e,i){let{buttonSize:r}=this,s=1*this.scale,o=Math.round(e+r/4)-s/2;t.strokePath({path:new R(o,i).lineTo(o,i+r),color:Zy,lineWidth:s})}drawButton(t,e,i,r){let{buttonSize:s,scale:o}=this;t.fillRect({x:e,y:i,width:s,height:s,color:jy}),this.xyGraph.enabled&&!r.disabled&&t.addHitRegion(r.region).addRect(e,i,s,s);let n=1*o,a=Math.round(i+n/2)-.5,h=Math.round(e+n/2)-.5,l=Math.round(i+s-n+n/2)-.5,c=Math.round(e+s-n+n/2)-.5;if(t.strokePath({color:r.pushed?m.WHITE:m.BLACK,path:new R(c,l).lineTo(c,a).moveTo(c,l).lineTo(h,l),lineWidth:n}),t.strokePath({color:r.pushed?m.BLACK:m.WHITE,path:new R(h,a).lineTo(c-n,a).moveTo(h,a).lineTo(h,l-n),lineWidth:n}),this.imagesLoaded){let d=r.disabled?r.disabledImageElement:r.imageElement,g=d.naturalHeight*o,w=d.naturalWidth*o,x=Math.round(e+(s-w)/2),_=Math.round(i+(s-g)/2);t.ctx.drawImage(d,x,_,w,g)}}get scale(){return this.xyGraph.scale}get buttonSize(){return 25*this.scale}};var Us="axis_count",Tf="plot_area_background_color",Sf="show_legend",Lf="show_plot_area_border",Cf="show_toolbar",Af="title",Of="title_font",Ys="trace_count",Ef="transparent",ts=class extends M{toolbar;plotAreaRegion;axes=[];traces=[];autoScaleAllowed=!0;constructor(t,e){super(t,e),this.properties.add(new P(Us)),this.properties.add(new S(Tf)),this.properties.add(new f(Sf)),this.properties.add(new f(Lf)),this.properties.add(new f(Cf)),this.properties.add(new T(Af)),this.properties.add(new H(Of)),this.properties.add(new P(Ys)),this.properties.add(new f(Ef)),this.properties.addGenerator(()=>{let i=[];this.axes=[];let r=this.properties.getValue(Us);for(let o=0;o<r;o++)this.axes.push(new qr(this,o)),i.push(new f(`axis_${o}_auto_scale`),new C(`axis_${o}_auto_scale_threshold`),new S(`axis_${o}_axis_color`),new T(`axis_${o}_axis_title`),new f(`axis_${o}_dash_grid_line`),new S(`axis_${o}_grid_color`),new f(`axis_${o}_log_scale`),new C(`axis_${o}_maximum`),new C(`axis_${o}_minimum`),new H(`axis_${o}_scale_font`),new T(`axis_${o}_scale_format`),new f(`axis_${o}_show_grid`),new P(`axis_${o}_time_format`),new H(`axis_${o}_title_font`),new f(`axis_${o}_visible`)),o>1&&i.push(new f(`axis_${o}_left_bottom_side`),new f(`axis_${o}_y_axis`));this.traces=[];let s=this.properties.getValue(Ys);for(let o=0;o<s;o++)this.traces.push(new Jr(this,o)),i.push(new f(`trace_${o}_anti_alias`),new P(`trace_${o}_buffer_size`),new f(`trace_${o}_concatenate_data`),new P(`trace_${o}_line_width`),new T(`trace_${o}_name`),new P(`trace_${o}_plot_mode`),new P(`trace_${o}_point_size`),new P(`trace_${o}_point_style`),new S(`trace_${o}_trace_color`),new P(`trace_${o}_trace_type`),new P(`trace_${o}_update_delay`),new P(`trace_${o}_update_mode`),new f(`trace_${o}_visible`),new P(`trace_${o}_x_axis_index`),new T(`trace_${o}_x_pv`),new Ht(`trace_${o}_x_pv_value`,`trace_${o}_x_pv`),new P(`trace_${o}_y_axis_index`),new T(`trace_${o}_y_pv`),new Ht(`trace_${o}_y_pv_value`,`trace_${o}_y_pv`));return i})}init(){this.plotAreaRegion=new jr(`${this.wuid}-plotarea`,this),this.traces.forEach(t=>t.init())}draw(t){let{scale:e}=this,i=this.area;if(this.borderAlarmSensitive&&(i=D(this.area,2*e)),!this.transparent){let o=this.alarmSensitiveBackgroundColor;t.fillRect({...i,color:o})}this.showToolbar&&this.drawToolbar(t,i),this.title&&this.drawTitle(t,i);for(let o of this.axes){if(o.autoScale&&this.autoScaleAllowed){let h={start:o.minimum,stop:o.maximum},l=this.calculateAutoscaledRange(o,h);l&&(o.effectiveMinimum=l.start,o.effectiveMaximum=l.stop)}let n=o.effectiveMinimum,a=o.effectiveMaximum;o.linearScale=new ot(this.display.formatter,e,o.scaleFont,n,a,o.logScale,50*e,o.axisColor,!0,o.visible),o.linearScale.scaleFormat=o.scaleFormat,o.linearScale.timeFormat=o.timeFormat}this.showLegend&&this.drawLegend(t,i),t.addHitRegion(this.plotAreaRegion).addRect(i.x,i.y,i.width,i.height);let r=this.drawAxes(t,i);this.drawPlotArea(t,r);let s=this.plotAreaRegion?.selection;s&&this.drawZoomSelection(t,r,gi(r,s))}drawToolbar(t,e){this.toolbar||(this.toolbar=new Qr(this));let i=3*this.scale,r=D(e,i),s=this.toolbar.draw(t,r);e.y+=i+s+i,e.height-=i+s+i}drawTitle(t,e){let i=t.measureText(this.title,this.titleFont).height;t.fillText({x:e.x+e.width/2,y:e.y+i/2,align:"center",baseline:"middle",color:this.alarmSensitiveForegroundColor,font:this.titleFont,text:this.title});let r=2*this.scale;e.y+=i+r,e.height-=i+r}drawAxes(t,e){let{scale:i}=this,r=5*i,s={...e},o=0,n=0;for(let c of this.getXAxes())if(c.visible){let d=0;c.axisTitle&&(d=r+t.measureText(c.axisTitle,c.titleFont).height),o+=d,n+=d+c.linearScale.measureHorizontalHeight(t)}let a=0,h=0;for(let c of this.getYAxes().reverse()){let d=c.linearScale;if(c.visible){let g=d.calculateMargin(t,!1),w=s.height-n+(n>0?g:0),x=0;c.axisTitle&&(x=t.measureText(c.axisTitle,c.titleFont).height,t.ctx.save(),t.ctx.translate(s.x+r+x/2,e.y+w/2),t.ctx.rotate(-Math.PI/2),t.fillText({x:0,y:0,align:"center",baseline:"middle",font:c.titleFont,color:c.axisColor,text:c.axisTitle}),t.ctx.restore(),x+=r);let _=x+d.drawVertical(t,s.x+x,e.y,w,!0,!1);s.x+=_,s.width-=_,a+=_;let L=d.margin;h=h===0?L:Math.min(h,L);let A=i*1,E=Math.round(s.x)-A/2,I=Math.round(e.y+g)-A/2;t.strokePath({path:new R(E,I).lineTo(E,I+w-2*g),color:c.axisColor,opacity:100/255,lineWidth:A})}else{let g=s.height-n;d.setDimensions(0,e.y,g,!1)}}let l=0;for(let c of this.getXAxes().reverse()){let d=c.linearScale;if(c.visible){let g=d.calculateMargin(t,!0),w=a-g,x=0;if(c.axisTitle){x=t.measureText(c.axisTitle,c.titleFont).height;let k=e.x+a+(e.width-a)/2;t.fillText({x:k,y:s.y+s.height-x/2,align:"center",baseline:"middle",font:c.titleFont,color:c.axisColor,text:c.axisTitle}),x+=r}let _=x+d.drawHorizontal(t,e.x+w,s.y+s.height-x,e.width-w);s.height-=_;let L=d.margin;l=l===0?L:Math.min(l,L);let A=i*1,E=Math.round(e.x+w+g)-A/2,I=Math.round(s.y+s.height)-A/2;t.strokePath({path:new R(E,I).lineTo(E+s.width-g,I),color:c.axisColor,opacity:100/255,lineWidth:A})}else{let g=e.x+a,w=e.width-a;d.setDimensions(g,0,w,!0)}}return s.y+=h,s.width-=l,n>0?s.height-=h:s.height-=2*h,s}drawPlotArea(t,e){let{scale:i}=this,r=1*i;if(this.transparent||t.fillRect({...e,color:this.plotAreaBackgroundColor}),this.showPlotAreaBorder){let{x:s,y:o,width:n,height:a}=D(e,r/2);t.strokePath({path:new R(s,o).lineTo(s+n,o).lineTo(s+n,o+a),color:m.BLACK,lineWidth:r})}for(let s of this.axes.filter(o=>o.visible&&o.showGrid)){let o=s.linearScale;if(s.isHorizontal())for(let n of o.getGridPositions()){let a=Math.round(o.getX()+n)-r/2;t.strokePath({path:new R(a,e.y).lineTo(a,e.y+e.height),color:s.gridColor,lineWidth:r,dash:s.dashGridLine?[6*i,2*i]:void 0})}else for(let n of o.getGridPositions()){let a=Math.round(o.getY()+n)-r/2;t.strokePath({path:new R(e.x,a).lineTo(e.x+e.width,a),color:s.gridColor,lineWidth:r,dash:s.dashGridLine?[6*i,2*i]:void 0})}}t.ctx.save(),t.ctx.beginPath(),t.ctx.rect(e.x,e.y,e.width,e.height),t.ctx.clip();for(let s of this.traces.filter(o=>o.visible)){let o=this.getAxis(s.xAxisIndex).linearScale,n=this.getAxis(s.yAxisIndex).linearScale,a=[];for(let h of s.snapshot()){let l=o.getValuePosition(h.x),c=h.y!==null?n.getValuePosition(h.y):null;a.push({x:l,y:c})}if(a.length){s.drawTrace(t,a);for(let h of a)h.y!==null&&s.drawPoint(t,h)}}t.ctx.restore()}drawZoomSelection(t,e,i){let{scale:r}=this;switch(this.toolbar?.currentTool){case"rubberband-zoom":t.strokeRect({...i,color:m.BLACK,lineWidth:1*r});break;case"horizontal-zoom":let s=i;s.y=e.y,s.height=e.height,t.strokeRect({...ys(s),color:m.BLACK,lineWidth:1*r});break;case"vertical-zoom":let o=i;o.x=e.x,o.width=e.width,t.strokeRect({...ys(o),color:m.BLACK,lineWidth:1*r});break}}drawLegend(t,e){let{scale:i}=this,r=25*i,s=2*i,o=5*i,n=U.ARIAL_10.scale(i);for(let a of this.getYAxes()){let h=this.traces.filter(A=>A.visible&&A.yAxisIndex===a.index),l=[],c=[],d=0,g=0;for(let A of h){let E=r+s+o;A.name&&(E+=t.measureText(A.name,n).width),d+E<e.width?(c.push(A),d+=E):(l.push(c),E=Math.max(E,d),c=[A],d=E)}if(c.length&&(l.push(c),g=Math.max(g,d)),!l.length)continue;let w=r*l.length,x={x:Math.round(e.x+(e.width-g)/2),y:Math.round(e.y+e.height-w),width:g,height:w};e.height-=x.height,this.transparent||t.fillRect({...x,color:this.plotAreaBackgroundColor}),t.strokeRect({...D(x,1*i/2),color:a.axisColor});let _=x.x,L=x.y;for(let A=0;A<l.length;A++){let E=l[A],I=L+A*r,k=I+r/2;for(let F of E){let Y=F.pointSize>Math.floor((r-o)/2)?Math.floor(r-o):F.pointSize;switch(F.traceType){case 3:let K=_+r/2;t.strokePath({path:new R(K,I+Y).lineTo(K,I+r),lineWidth:F.lineWidth,color:F.traceColor,opacity:100/255}),F.drawPoint(t,{x:K,y:I+Y});break;case 4:case 5:let mt=[{x:_,y:I+r/2},{x:_+r/2,y:I+Y},{x:_+r,y:I+r/2},{x:_+r,y:I+r},{x:_,y:I+r}];t.fillPath({path:R.fromPoints(mt),color:F.traceColor,opacity:100/255}),F.traceType===5&&t.strokePath({path:R.fromPoints(mt.slice(0,3)),color:F.traceColor,lineWidth:1*i}),F.drawPoint(t,{x:_+r/2,y:I+Y});break;default:F.drawTrace(t,[{x:_,y:k},{x:_+r,y:k}]),F.drawPoint(t,{x:_+r/2,y:k})}_+=r+s,F.name&&(t.fillText({x:_,y:k,align:"left",baseline:"middle",color:F.traceColor,font:n,text:F.name}),_+=t.measureText(F.name,n).width),_+=o}}}}setCursor(t){this.plotAreaRegion.cursor=t}calculateAutoscaledRange(t,e){let i,r,s=t.logScale;for(let o of this.traces)if(o.visible&&!(this.axes[o.xAxisIndex]!==t&&this.axes[o.yAxisIndex]!==t))for(let n of o.snapshot()){let a=t.isHorizontal()?n.x:n.y;a!==null&&((i===void 0||i>a)&&(!s||a>0)&&(i=a),(r===void 0||r<a)&&(!s||a>0)&&(r=a))}if(i!==void 0&&r!==void 0)return i===r?{start:Math.min(i,e.start),stop:Math.max(r,e.stop)}:{start:i,stop:r}}performAutoScale(){for(let t of this.axes)t.visible&&t.performAutoScale()}clearGraph(){for(let t of this.traces)t.clearData();this.requestRepaint()}getAxes(){return[...this.axes]}getXAxes(){return this.axes.filter(t=>t.isHorizontal())}getYAxes(){return this.axes.filter(t=>t.isVertical())}getAxis(t){return this.axes[t]}getTrace(t){return this.traces[t]}get axisCount(){return this.properties.getValue(Us)}get plotAreaBackgroundColor(){return this.properties.getValue(Tf)}get showLegend(){return this.properties.getValue(Sf)}get showPlotAreaBorder(){return this.properties.getValue(Lf)}get showToolbar(){return this.properties.getValue(Cf)}get title(){return this.properties.getValue(Af)}get titleFont(){return this.properties.getValue(Of).scale(this.scale)}get traceCount(){return this.properties.getValue(Ys)}get transparent(){return this.properties.getValue(Ef)}destroy(){for(let t of this.traces)t.destroy()}};var Mf="array_length",Vf="spinner_width",If="horizontal",Bf="show_spinner",Hf="show_scrollbar",Df="vec",Wf="data_type",Jy="scale_options",kf=1,Nf=25,Qy=16,Ff=16,tP=new m(64,64,64),eP=250,iP=40,rP=150,sP=new m(243,243,243),es=class extends rt{templateNode;templateWidgetType="";elementWidth=0;elementHeight=0;originalEnabled=new WeakMap;scrollIndex=0;fullValue=[];redistributing=!1;spinnerUpRegion;spinnerUpPressed=!1;spinnerDownRegion;spinnerDownPressed=!1;spinnerRepeatTimeout;spinnerLabelRegion;spinnerLabelBounds;editingIndex=!1;indexInputEl;scrollDecreaseRegion;scrollDecreasePressed=!1;scrollIncreaseRegion;scrollIncreasePressed=!1;scrollPageDecreaseRegion;scrollPageIncreaseRegion;scrollThumbRegion;scrollGrabStartIndex=0;scrollDragRange=0;scrollRepeatTimeout;constructor(t,e){super(t,e),this.properties.add(new P(Mf,10)),this.properties.add(new P(Vf,40)),this.properties.add(new f(If,!1)),this.properties.add(new f(Bf,!0)),this.properties.add(new f(Hf,!0)),this.properties.add(new P(Df,1)),this.properties.add(new P(Wf,0))}async parseNode(t){await super.parseNode(t);let e=t.getNodes("widget");if(e.length){this.templateNode=e[0],this.templateWidgetType=this.templateNode.getString("widget_type"),this.elementWidth=this.templateNode.getInt("width",0),this.elementHeight=this.templateNode.getInt("height",0);for(let i=0;i<this.vec;i++){let r=this.templateNode.cloneWithOverrides({pvName:this.slotPvName(i),wuidSuffix:`-slot${i}`}),s=r.getString("widget_type"),o=this.display.createWidget(s,this);o&&(await o.parseNode(r),this.forEachDescendant(o,n=>this.originalEnabled.set(n,n.enabled)),o.properties.setValue(Jy,new Z(!1,!1,!1)),this.widgets.push(o),this.hookSlotWriteBack(i))}this.layoutSlots(),this.pvName&&this.display.pvEngine.trackListener(this,this.pvName,()=>this.value=this.pv.value)}}init(){this.spinnerUpRegion={id:`${this.wuid}-array-spinner-up`,mouseDown:()=>{this.spinnerUpPressed=!0,this.stepSpinnerRepeatedly(1,!0)},mouseUp:()=>this.stopSpinnerRepeating("up"),mouseOut:()=>this.stopSpinnerRepeating("up")},this.spinnerDownRegion={id:`${this.wuid}-array-spinner-down`,mouseDown:()=>{this.spinnerDownPressed=!0,this.stepSpinnerRepeatedly(-1,!0)},mouseUp:()=>this.stopSpinnerRepeating("down"),mouseOut:()=>this.stopSpinnerRepeating("down")},this.scrollDecreaseRegion={id:`${this.wuid}-array-scroll-decrease`,mouseDown:()=>{this.scrollDecreasePressed=!0,this.stepScrollbarRepeatedly(-1)},mouseUp:()=>this.stopScrollbarRepeating("decrease"),mouseOut:()=>this.stopScrollbarRepeating("decrease")},this.scrollIncreaseRegion={id:`${this.wuid}-array-scroll-increase`,mouseDown:()=>{this.scrollIncreasePressed=!0,this.stepScrollbarRepeatedly(1)},mouseUp:()=>this.stopScrollbarRepeating("increase"),mouseOut:()=>this.stopScrollbarRepeating("increase")},this.scrollPageDecreaseRegion={id:`${this.wuid}-array-scroll-page-decrease`,mouseDown:()=>this.setScrollbarIndex(this.scrollIndex-this.vec)},this.scrollPageIncreaseRegion={id:`${this.wuid}-array-scroll-page-increase`,mouseDown:()=>this.setScrollbarIndex(this.scrollIndex+this.vec)},this.scrollThumbRegion={id:`${this.wuid}-array-scroll-thumb`,mouseDown:()=>{this.scrollGrabStartIndex=this.scrollIndex},grab:t=>{if(this.scrollDragRange<=0)return;let e=this.horizontal?t.dx:t.dy,r=Math.max(0,this.effectiveArrayLength-this.vec)*e/this.scrollDragRange;this.setScrollbarIndex(this.scrollGrabStartIndex+r)}},this.spinnerLabelRegion={id:`${this.wuid}-array-spinner-label`,click:()=>this.startEditingIndex(),cursor:"text"},this.indexInputEl=document.createElement("input"),this.indexInputEl.style.display="none",this.indexInputEl.autocomplete="off",this.indexInputEl.addEventListener("keyup",t=>{t.key==="Enter"?this.commitEditingIndex():t.key==="Escape"&&this.cancelEditingIndex()}),this.indexInputEl.addEventListener("blur",()=>this.cancelEditingIndex()),this.display.rootPanel.appendChild(this.indexInputEl)}destroy(){window.clearTimeout(this.spinnerRepeatTimeout),window.clearTimeout(this.scrollRepeatTimeout),this.indexInputEl&&(this.display.rootPanel.removeChild(this.indexInputEl),this.indexInputEl=void 0),super.destroy()}forEachDescendant(t,e){if(e(t),t instanceof rt)for(let i of t.widgets)this.forEachDescendant(i,e)}startEditingIndex(){if(!this.spinnerLabelBounds||!this.indexInputEl)return;this.editingIndex=!0;let t=this.display.measureAbsoluteArea(this),e=this.spinnerLabelBounds;this.indexInputEl.value=String(this.scrollIndex),this.indexInputEl.style.display="block",this.indexInputEl.style.position="absolute",this.indexInputEl.style.boxSizing="border-box",this.indexInputEl.style.left=`${t.x+e.x}px`,this.indexInputEl.style.top=`${t.y+e.y}px`,this.indexInputEl.style.width=`${e.width}px`,this.indexInputEl.style.height=`${e.height}px`,this.indexInputEl.style.textAlign="center",this.indexInputEl.focus(),this.indexInputEl.select(),this.requestRepaint()}commitEditingIndex(){let t=this.indexInputEl.value;this.cancelEditingIndex();let e=Number(t);isNaN(e)||this.setSpinnerIndex(e)}cancelEditingIndex(){this.indexInputEl.style.display="none",this.editingIndex=!1,this.requestRepaint()}slotPvName(t){return`loc://__array_${this.wuid}_slot${t}`}hookSlotWriteBack(t){let e=this.display.pvEngine.getPV(this.slotPvName(t));e&&this.display.pvEngine.trackListener(this,e.name,()=>{if(this.redistributing)return;let i=this.scrollIndex+t;i>=this.effectiveArrayLength||(this.fullValue[i]=this.coerceElement(e.value),this.pvName&&this.display.pvEngine.setValue(new Date,this.pvName,this.fullValue))})}coerceElement(t){if(this.dataType===kf)return String(t);let e=Number(t);return isNaN(e)?t:e}defaultElementValue(){return this.dataType===kf||this.templateWidgetType==="Text Update"?"":0}get value(){return super.value}set value(t){super.value=t,this.fullValue=Array.isArray(t)?t.slice():t!==void 0?[t]:[],this.scrollIndex=this.clampScrollbarIndex(this.scrollIndex),this.redistribute()}get effectiveArrayLength(){return this.pvName?this.fullValue.length:this.arrayLength}redistribute(){this.redistributing=!0;try{let t=this.effectiveArrayLength;for(let e=0;e<this.widgets.length;e++){let i=this.scrollIndex+e,r=i<t,s=r?this.fullValue[i]:this.defaultElementValue(),o=this.display.pvEngine.getPV(this.slotPvName(e));o&&(o.writable=r),this.display.pvEngine.setValue(new Date,this.slotPvName(e),s),this.forEachDescendant(this.widgets[e],n=>{n.properties.setValue("enabled",r?this.originalEnabled.get(n)??!0:!1)})}}finally{this.redistributing=!1}this.requestRepaint()}clampSpinnerIndex(t){let e=Math.max(0,this.effectiveArrayLength-1);return Math.min(Math.max(0,Math.round(t)),e)}clampScrollbarIndex(t){let e=Math.max(0,this.effectiveArrayLength-this.vec);return Math.min(Math.max(0,Math.round(t)),e)}setSpinnerIndex(t){let e=this.clampSpinnerIndex(t);e!==this.scrollIndex&&(this.scrollIndex=e,this.redistribute())}setScrollbarIndex(t){let e=this.clampScrollbarIndex(t);e!==this.scrollIndex&&(this.scrollIndex=e,this.redistribute())}setScrollIndex(t){this.setSpinnerIndex(t)}getScrollIndex(){return this.scrollIndex}stopSpinnerRepeating(t){window.clearTimeout(this.spinnerRepeatTimeout),t==="up"?this.spinnerUpPressed=!1:this.spinnerDownPressed=!1,this.requestRepaint()}stepSpinnerRepeatedly(t,e){window.clearTimeout(this.spinnerRepeatTimeout),this.setSpinnerIndex(this.scrollIndex+t),this.spinnerRepeatTimeout=window.setTimeout(()=>this.stepSpinnerRepeatedly(t,!1),e?eP:iP)}stopScrollbarRepeating(t){window.clearTimeout(this.scrollRepeatTimeout),t==="decrease"?this.scrollDecreasePressed=!1:this.scrollIncreasePressed=!1,this.requestRepaint()}stepScrollbarRepeatedly(t){window.clearTimeout(this.scrollRepeatTimeout),this.setScrollbarIndex(this.scrollIndex+t),this.scrollRepeatTimeout=window.setTimeout(()=>this.stepScrollbarRepeatedly(t),rP)}computeRegions(t,e,i,r,s){let o,n,a=0,h=0,l=t,c=e;return i>0&&(o={x:0,y:0,width:i,height:Math.min(s,e)},a+=i,l-=i),r>0&&(this.horizontal?(n={x:a,y:e-r,width:l,height:r},c-=r):(n={x:t-r,y:0,width:r,height:e},l-=r)),{spinnerBounds:o,scrollbarBounds:n,paneBounds:{x:a,y:h,width:l,height:c}}}autoScale(t,e){M.prototype.autoScale.call(this,t,e),this.layoutSlots()}layoutSlots(){if(!this.widgets.length)return;let t=this.properties.getValue("width"),e=this.properties.getValue("height"),{paneBounds:i}=this.computeRegions(t,e,this.showSpinner?this.spinnerWidth:0,this.showScrollbar?Ff:0,Nf);for(let r=0;r<this.widgets.length;r++){let s=this.widgets[r],o=this.horizontal?i.x+r*this.elementWidth:i.x,n=this.horizontal?i.y:i.y+r*this.elementHeight;s.properties.setValue("x",o),s.properties.setValue("y",n)}}beforeDrawBorder(t){this.transparent||t.fillRect({x:this.holderX,y:this.holderY,width:this.holderWidth,height:this.holderHeight,color:this.backgroundColor})}draw(t){let e=t.createChildAt(this.x,this.y,this.width,this.height);for(let s of this.widgets.filter(o=>o.visible))s.drawHolder(e),s.draw(e),s.drawDecoration(e);let{scale:i}=this,r=this.computeRegions(this.width,this.height,this.showSpinner?this.spinnerWidth*i:0,this.showScrollbar?Ff*i:0,Nf*i);r.spinnerBounds&&this.drawSpinner(e,r.spinnerBounds),r.scrollbarBounds&&this.drawScrollbar(e,r.scrollbarBounds),this.drawGrayOverlay(e,r.paneBounds);for(let s of this.widgets.filter(o=>o.visible))s.drawOverlay(e);t.copyChild(e)}drawGrayOverlay(t,e){let i=Math.max(0,this.scrollIndex+this.vec-this.effectiveArrayLength);if(i<=0||!this.elementWidth||!this.elementHeight)return;let{scale:r}=this,s=this.vec-i,o=this.horizontal?{x:e.x+s*this.elementWidth*r,y:e.y,width:i*this.elementWidth*r,height:e.height}:{x:e.x,y:e.y+s*this.elementHeight*r,width:e.width,height:i*this.elementHeight*r};o.width<=0||o.height<=0||t.fillRect({...o,color:tP,opacity:40/255})}drawSpinner(t,e){let i=Math.min(e.width,Qy*this.scale),r={x:e.x,y:e.y,width:i,height:e.height},s={x:e.x+i,y:e.y,width:Math.max(0,e.width-i),height:e.height},o=Math.floor(r.height/2),n={x:r.x,y:r.y,width:r.width,height:o},a={x:r.x,y:r.y+o,width:r.width,height:r.height-o};this.drawArrowButton(t,n,this.spinnerUpPressed,"up"),t.addHitRegion(this.spinnerUpRegion).addRect(n.x,n.y,n.width,n.height),this.drawArrowButton(t,a,this.spinnerDownPressed,"down"),t.addHitRegion(this.spinnerDownRegion).addRect(a.x,a.y,a.width,a.height),this.drawSpinnerLabel(t,s)}drawSpinnerLabel(t,e){if(this.spinnerLabelBounds=e,e.width<=0)return;t.fillRect({...e,color:m.WHITE}),t.strokeRect({...e,color:m.BUTTON_DARKER}),this.editingIndex||t.fillText({x:e.x+e.width/2,y:e.y+e.height/2,baseline:"middle",align:"center",font:U.ARIAL_11.scale(this.scale),color:m.BLACK,text:String(this.scrollIndex)}),t.addHitRegion(this.spinnerLabelRegion).addRect(e.x,e.y,e.width,e.height)}drawScrollbar(t,e){t.fillRect({...e,color:sP});let i=this.effectiveArrayLength,r=Math.max(1,Math.min(this.vec,Math.max(i,1))),s=Math.max(i,r,1),o=Math.max(1,s-r);if(this.horizontal){let n=Math.min(e.height,e.width/2),a={x:e.x,y:e.y,width:n,height:e.height},h={x:e.x+e.width-n,y:e.y,width:n,height:e.height};this.drawArrowButton(t,a,this.scrollDecreasePressed,"left"),this.drawArrowButton(t,h,this.scrollIncreasePressed,"right"),t.addHitRegion(this.scrollDecreaseRegion).addRect(a.x,a.y,a.width,a.height),t.addHitRegion(this.scrollIncreaseRegion).addRect(h.x,h.y,h.width,h.height);let d=e.x+n,g=Math.max(0,e.width-2*n),w=Math.min(g,Math.max(6*this.scale,Math.floor(g*r/s)));this.scrollDragRange=g-w;let x=Math.floor((g-w)*Math.min(this.scrollIndex,o)/o),_={x:d+x,y:e.y,width:w,height:e.height};this.drawThumb(t,_),this.registerPageRegion(t,this.scrollPageDecreaseRegion,d,e.y,x,e.height),this.registerPageRegion(t,this.scrollPageIncreaseRegion,d+x+w,e.y,g-x-w,e.height)}else{let n=Math.min(e.width,e.height/2),a={x:e.x,y:e.y,width:e.width,height:n},h={x:e.x,y:e.y+e.height-n,width:e.width,height:n};this.drawArrowButton(t,a,this.scrollDecreasePressed,"up"),this.drawArrowButton(t,h,this.scrollIncreasePressed,"down"),t.addHitRegion(this.scrollDecreaseRegion).addRect(a.x,a.y,a.width,a.height),t.addHitRegion(this.scrollIncreaseRegion).addRect(h.x,h.y,h.width,h.height);let d=e.y+n,g=Math.max(0,e.height-2*n),w=Math.min(g,Math.max(6*this.scale,Math.floor(g*r/s)));this.scrollDragRange=g-w;let x=Math.floor((g-w)*Math.min(this.scrollIndex,o)/o),_={x:e.x,y:d+x,width:e.width,height:w};this.drawThumb(t,_),this.registerPageRegion(t,this.scrollPageDecreaseRegion,e.x,d,e.width,x),this.registerPageRegion(t,this.scrollPageIncreaseRegion,e.x,d+x+w,e.width,g-x-w)}}registerPageRegion(t,e,i,r,s,o){if(s<=0||o<=0)return;t.addHitRegion(e).addRect(i,r,s,o)}drawThumb(t,e){t.fillRect({...e,color:m.BUTTON}),this.drawBevelBorder(t,e,!1),t.addHitRegion(this.scrollThumbRegion).addRect(e.x,e.y,e.width,e.height)}drawBevelBorder(t,e,i){let r=1*this.scale,s=e.y+r/2,o=e.x+r/2,n=e.y+e.height-r+r/2,a=e.x+e.width-r+r/2,[h,l,c,d]=i?[m.BUTTON_LIGHTEST,m.BUTTON_LIGHTEST,m.BUTTON_DARKEST,m.BUTTON_DARKER]:[m.BUTTON_DARKEST,m.BUTTON_DARKER,m.BUTTON,m.BUTTON_LIGHTEST];t.strokePath({color:h,path:new R(a,n).lineTo(a,s).moveTo(a,n).lineTo(o,n)}),t.strokePath({color:l,path:new R(a-r,n-r).lineTo(a-r,s+r).moveTo(a-r,n-r).lineTo(o+r,n-r)}),t.strokePath({color:c,path:new R(o,s).lineTo(a-r,s).moveTo(o,s).lineTo(o,n-r)}),t.strokePath({color:d,path:new R(o+r,s+r).lineTo(a-r-r,s+r).moveTo(o+r,s+r).lineTo(o+r,n-r-r)})}drawArrowButton(t,e,i,r){t.fillRect({...e,color:i?m.BUTTON_DARKER:m.BUTTON}),this.drawBevelBorder(t,e,i);let s=Math.max(1,Math.min(3*this.scale,e.width/2-1,e.height/2-1)),o=Math.max(1,Math.min(2*this.scale,s)),n=e.x+e.width/2,a=e.y+e.height/2,h;r==="up"?h=new R(n,a-o).lineTo(n-s,a+o).lineTo(n+s,a+o).closePath():r==="down"?h=new R(n,a+o).lineTo(n-s,a-o).lineTo(n+s,a-o).closePath():r==="left"?h=new R(n-o,a).lineTo(n+o,a-s).lineTo(n+o,a+s).closePath():h=new R(n+o,a).lineTo(n-o,a-s).lineTo(n-o,a+s).closePath(),t.fillPath({color:m.BLACK,path:h})}get arrayLength(){return this.properties.getValue(Mf)}get spinnerWidth(){return this.properties.getValue(Vf)}get horizontal(){return this.properties.getValue(If)}get showSpinner(){return this.properties.getValue(Bf)}get showScrollbar(){return this.properties.getValue(Hf)}get vec(){return this.properties.getValue(Df)}get dataType(){return this.properties.getValue(Wf)}};var zs="fc",Gf="show_scrollbar",$f="background_color",Uf="foreground_color",oP=16,nP=20,Yf=150,aP=new m(243,243,243),zf=new m(232,232,231),is=class extends rt{scrollX=0;scrollY=0;maxScrollX=0;maxScrollY=0;contentWidth=0;contentHeight=0;dragRangeX;dragRangeY;grabStartX;grabStartY;actionTimeout;xDecPressed=!1;xIncPressed=!1;yDecPressed=!1;yIncPressed=!1;thumbXRegion;thumbYRegion;xDecRegion;xIncRegion;yDecRegion;yIncRegion;trackXBeforeRegion;trackXAfterRegion;trackYBeforeRegion;trackYAfterRegion;constructor(t,e){super(t,e),this.properties.add(new f(zs,!1)),this.properties.add(new f(Gf,!0))}async parseNode(t){await super.parseNode(t);for(let i of t.getNodes("widget")){let r=i.getString("widget_type"),s=this.display.createWidget(r,this);s&&(await s.parseNode(i),this.widgets.push(s))}Ji(this.widgets);let e=()=>{if(this.forwardColors)for(let i of this.widgets)i.properties.setValue($f,this.backgroundColor),i.properties.setValue(Uf,this.foregroundColor),i.requestRepaint()};this.addPropertyListener(zs,e),this.addPropertyListener($f,e),this.addPropertyListener(Uf,e)}init(){this.thumbXRegion=this.makeThumbRegion("x"),this.thumbYRegion=this.makeThumbRegion("y"),this.xDecRegion=this.makeStepRegion("x",-1),this.xIncRegion=this.makeStepRegion("x",1),this.yDecRegion=this.makeStepRegion("y",-1),this.yIncRegion=this.makeStepRegion("y",1),this.trackXBeforeRegion=this.makePageRegion("x",-1),this.trackXAfterRegion=this.makePageRegion("x",1),this.trackYBeforeRegion=this.makePageRegion("y",-1),this.trackYAfterRegion=this.makePageRegion("y",1)}destroy(){window.clearTimeout(this.actionTimeout),super.destroy()}makeThumbRegion(t){return{id:`${this.wuid}-scrollbar-${t}-thumb`,mouseDown:()=>{t==="x"?this.grabStartX=this.scrollX:this.grabStartY=this.scrollY},grab:e=>{let i=t==="x"?this.maxScrollX:this.maxScrollY,r=(t==="x"?this.dragRangeX:this.dragRangeY)||1,s=t==="x"?e.dx:e.dy,o=(t==="x"?this.grabStartX:this.grabStartY)??0;this.setScrollOffset(t,o+i*s/r)},tooltip:()=>this.tooltip}}makeStepRegion(t,e){let i=r=>{t==="x"?e<0?this.xDecPressed=r:this.xIncPressed=r:e<0?this.yDecPressed=r:this.yIncPressed=r};return{id:`${this.wuid}-scrollbar-${t}-${e<0?"dec":"inc"}`,mouseDown:()=>{i(!0),this.stepScrollRepeatedly(t,e)},mouseUp:()=>this.endScrollAction(()=>i(!1)),mouseOut:()=>this.endScrollAction(()=>i(!1)),tooltip:()=>this.tooltip}}makePageRegion(t,e){return{id:`${this.wuid}-scrollbar-${t}-page-${e<0?"before":"after"}`,mouseDown:()=>this.pageScrollRepeatedly(t,e),mouseUp:()=>this.endScrollAction(),mouseOut:()=>this.endScrollAction(),tooltip:()=>this.tooltip}}setScrollOffset(t,e){let i=t==="x"?this.maxScrollX:this.maxScrollY,r=Math.min(Math.max(e,0),i);t==="x"?this.scrollX=r:this.scrollY=r,this.requestRepaint()}stepScrollRepeatedly(t,e){window.clearTimeout(this.actionTimeout);let i=t==="x"?this.scrollX:this.scrollY;this.setScrollOffset(t,i+e*nP*this.scale),this.actionTimeout=window.setTimeout(()=>this.stepScrollRepeatedly(t,e),Yf)}pageScrollRepeatedly(t,e){window.clearTimeout(this.actionTimeout);let i=t==="x"?this.scrollX:this.scrollY,r=t==="x"?this.contentWidth:this.contentHeight;this.setScrollOffset(t,i+e*r),this.actionTimeout=window.setTimeout(()=>this.pageScrollRepeatedly(t,e),Yf)}endScrollAction(t){window.clearTimeout(this.actionTimeout),t?.(),this.requestRepaint()}get forwardColors(){return this.properties.getValue(zs)}get showScrollbar(){return this.properties.getValue(Gf)}beforeDrawBorder(t){this.transparent||t.fillRect({x:this.holderX,y:this.holderY,width:this.holderWidth,height:this.holderHeight,color:this.backgroundColor})}measureContentExtent(){let t=this.width,e=this.height;for(let i of this.widgets.filter(r=>r.visible)){let r=i.bounds;t=Math.max(t,r.x+r.width),e=Math.max(e,r.y+r.height)}return{width:t,height:e}}resolveScrollbars(t,e,i){if(!this.showScrollbar)return{showH:!1,showV:!1};let r=t>this.width,s=e>this.height;return r&&!s&&e>this.height-i?s=!0:s&&!r&&t>this.width-i&&(r=!0),{showH:r,showV:s}}draw(t){let e=oP*this.scale,i=this.measureContentExtent(),{showH:r,showV:s}=this.resolveScrollbars(i.width,i.height,e);this.contentWidth=this.width-(s?e:0),this.contentHeight=this.height-(r?e:0),this.maxScrollX=Math.max(0,i.width-this.contentWidth),this.maxScrollY=Math.max(0,i.height-this.contentHeight),this.scrollX=Math.min(Math.max(this.scrollX,0),this.maxScrollX),this.scrollY=Math.min(Math.max(this.scrollY,0),this.maxScrollY);let o=t.createChildAt(this.x,this.y,this.width,this.height);o.translate(-this.scrollX,-this.scrollY),o.ctx.save(),o.ctx.beginPath(),o.ctx.rect(this.scrollX,this.scrollY,this.contentWidth,this.contentHeight),o.ctx.clip();for(let n of this.widgets.filter(a=>a.visible))n.drawHolder(o),n.draw(o),n.drawDecoration(o);for(let n of this.widgets.filter(a=>a.visible))n.drawOverlay(o);o.ctx.restore(),o.translate(this.scrollX,this.scrollY),r&&this.drawScrollbar(o,"x",{x:0,y:this.contentHeight,width:this.contentWidth,height:e}),s&&this.drawScrollbar(o,"y",{x:this.contentWidth,y:0,width:e,height:this.contentHeight}),t.copyChild(o)}drawScrollbar(t,e,i){let{scale:r}=this;t.fillRect({...i,color:aP});let s=e==="x",o=s?Math.min(i.height,i.width/2):Math.min(i.width,i.height/2),n=s?{x:i.x,y:i.y,width:o,height:i.height}:{x:i.x,y:i.y,width:i.width,height:o},a=s?{x:i.x+i.width-o,y:i.y,width:o,height:i.height}:{x:i.x,y:i.y+i.height-o,width:i.width,height:o};this.drawScrollButton(t,e,-1,n),this.drawScrollButton(t,e,1,a);let h=s?i.x+o:i.y+o,l=(s?i.width:i.height)-2*o,c=s?this.contentWidth:this.contentHeight,d=s?this.maxScrollX:this.maxScrollY,g=Math.min(1,c/(c+d)),w=Math.max(6*r,l*g);s?this.dragRangeX=l-w:this.dragRangeY=l-w;let x=s?this.scrollX:this.scrollY,_=d>0?x/d:0,L=h+(l-w)*_,A=s?{x:L,y:i.y,width:w,height:i.height}:{x:i.x,y:L,width:i.width,height:w};t.fillRect({...A,color:zf}),Ee(t,A,r);let E=s?this.thumbXRegion:this.thumbYRegion;t.addHitRegion(E).addRect(A.x,A.y,A.width,A.height);let I=h+l,k=s?this.trackXBeforeRegion:this.trackYBeforeRegion,F=s?this.trackXAfterRegion:this.trackYAfterRegion;s?(t.addHitRegion(k).addRect(h,i.y,L-h,i.height),t.addHitRegion(F).addRect(L+w,i.y,I-(L+w),i.height)):(t.addHitRegion(k).addRect(i.x,h,i.width,L-h),t.addHitRegion(F).addRect(i.x,L+w,i.width,I-(L+w)))}drawScrollButton(t,e,i,r){let{scale:s}=this,o=e==="x"?i<0?this.xDecPressed:this.xIncPressed:i<0?this.yDecPressed:this.yIncPressed;t.fillRect({...r,color:zf}),o?Lr(t,r,s):Ee(t,r,s);let n=e==="x"?i<0?this.xDecRegion:this.xIncRegion:i<0?this.yDecRegion:this.yIncRegion;t.addHitRegion(n).addRect(r.x,r.y,r.width,r.height);let a=e==="x"?i<0?"left":"right":i<0?"up":"down";Cr(t,r,s,a)}};var Xf="horizontal",qf="panel1_auto_scale_children",Kf="panel2_auto_scale_children",Xs="sash_position",jf="sash_style",Zf="sash_width",qs="x",Ks="y",rs="width",ss="height",hP=0,lP=1,cP=2,pP=3,dP=4,uP=5,gP=12,os=class extends rt{sashRegion;grabStartPosition;grabClientSize;panelOriginSizes=new Map;childOriginBounds=new Map;constructor(t,e){super(t,e),this.properties.add(new f(Xf,!0)),this.properties.add(new f(qf,!1)),this.properties.add(new f(Kf,!1)),this.properties.add(new C(Xs,.5)),this.properties.add(new P(jf,cP)),this.properties.add(new P(Zf,3))}async parseNode(t){await super.parseNode(t);for(let e of t.getNodes("widget")){let i=e.getString("widget_type"),r=this.display.createWidget(i,this);r&&(await r.parseNode(e),this.widgets.push(r))}}init(){this.sashRegion={id:`${this.wuid}-sash`,mouseDown:()=>{this.grabStartPosition=this.sashPosition,this.grabClientSize=this.horizontal?this.width:this.height},grab:t=>{if(this.grabStartPosition===void 0||!this.grabClientSize)return;let e=this.horizontal?t.dx:t.dy,i=this.sashWidth*this.scale,r=this.minPaneSize,s=r+i/2,o=this.grabClientSize-r-i/2,n=this.grabStartPosition*this.grabClientSize+e;n=Math.min(o,Math.max(s,n)),this.properties.setValue(Xs,n/this.grabClientSize),this.requestRepaint()}}}beforeDrawBorder(t){this.transparent||t.fillRect({x:this.holderX,y:this.holderY,width:this.holderWidth,height:this.holderHeight,color:this.backgroundColor})}draw(t){let e=t.createChildAt(this.x,this.y,this.width,this.height),[i,r]=this.widgets;if(i&&r){let{boundsA:s,boundsB:o,sashBounds:n}=this.measureLayout();this.applyPanelBounds(i,s,this.panel1AutoScaleChildren),this.applyPanelBounds(r,o,this.panel2AutoScaleChildren);for(let a of[i,r])a.drawHolder(e),a.draw(e),a.drawDecoration(e);for(let a of[i,r])a.drawOverlay(e);this.drawSash(e,n,s,o)}t.copyChild(e)}measureLayout(){let{horizontal:t}=this,e=t?this.width:this.height,i=t?this.height:this.width,r=this.sashWidth*this.scale,s=Math.floor(r/2),o=this.minPaneSize,n=e-r-o,a=Math.floor(this.sashPosition*e-s);a=Math.min(n,Math.max(o,a));let h=e-a-r,l,c,d;return t?(l={x:0,y:0,width:a,height:i},c={x:a+r,y:0,width:h,height:i},d={x:a,y:0,width:r,height:i}):(l={x:0,y:0,width:i,height:a},c={x:0,y:a+r,width:i,height:h},d={x:0,y:a,width:i,height:r}),{boundsA:l,boundsB:c,sashBounds:d}}applyPanelBounds(t,e,i){let{scale:r}=this,s={x:e.x/r,y:e.y/r,width:e.width/r,height:e.height/r};i&&t instanceof rt&&this.scalePanelChildren(t,s),t.properties.setValue(qs,s.x),t.properties.setValue(Ks,s.y),t.properties.setValue(rs,s.width),t.properties.setValue(ss,s.height)}scalePanelChildren(t,e){let i=this.panelOriginSizes.get(t);i||(i={x:0,y:0,width:t.properties.getValue(rs),height:t.properties.getValue(ss)},this.panelOriginSizes.set(t,i));let r=i.width?e.width/i.width:1,s=i.height?e.height/i.height:1;for(let o of t.widgets){let n=this.childOriginBounds.get(o);n||(n={x:o.properties.getValue(qs),y:o.properties.getValue(Ks),width:o.properties.getValue(rs),height:o.properties.getValue(ss)},this.childOriginBounds.set(o,n)),o.properties.setValue(qs,Math.round(n.x*r)),o.properties.setValue(Ks,Math.round(n.y*s));let{widthScalable:a,heightScalable:h}=o.scaleOptions;if(a||h){let{width:l,height:c}=bi(n,r,s,o.scaleOptions);o.properties.setValue(rs,l),o.properties.setValue(ss,c)}}}autoScale(t,e){M.prototype.autoScale.call(this,t,e)}drawSash(t,e,i,r){let{sashStyle:s}=this;if(s!==hP)if(s===lP){let o=6*this.scale;for(let n of[i,r])t.strokeRect({x:n.x+1,y:n.y+1,width:n.width-2,height:n.height-2,rx:o,ry:o,color:m.BUTTON_DARKER})}else if(s===dP){let o=this.horizontal?e.width:e.height,n=e.x+e.width/2,a=e.y+e.height/2,h=this.horizontal?new R(n,e.y).lineTo(n,e.y+e.height):new R(e.x,a).lineTo(e.x+e.width,a);t.strokePath({path:h,color:this.foregroundColor,lineWidth:o})}else if(s===uP)this.drawSashEdge(t,e,"near",m.BUTTON_DARKER),this.drawSashEdge(t,e,"far",m.BUTTON_DARKER);else{let o=s===pP;t.fillRect({...e,color:m.BUTTON}),this.drawSashEdge(t,e,"near",o?m.BUTTON_DARKER:m.BUTTON_LIGHTEST),this.drawSashEdge(t,e,"far",o?m.BUTTON_LIGHTEST:m.BUTTON_DARKER)}this.sashRegion&&(this.sashRegion.cursor=this.horizontal?"col-resize":"row-resize",t.addHitRegion(this.sashRegion).addRect(e.x,e.y,e.width,e.height))}drawSashEdge(t,e,i,r){let s=1*this.scale,o;if(this.horizontal){let n=i==="near"?e.x:e.x+e.width-s;o=new R(n,e.y).lineTo(n,e.y+e.height)}else{let n=i==="near"?e.y:e.y+e.height-s;o=new R(e.x,n).lineTo(e.x+e.width,n)}t.strokePath({path:o,color:r,lineWidth:s})}get horizontal(){return this.properties.getValue(Xf)}get minPaneSize(){return gP*this.scale}get panel1AutoScaleChildren(){return this.properties.getValue(qf)}get panel2AutoScaleChildren(){return this.properties.getValue(Kf)}get sashPosition(){return this.properties.getValue(Xs)}get sashStyle(){return this.properties.getValue(jf)}get sashWidth(){return this.properties.getValue(Zf)}};var Jf="minimum_tab_height",Zs="active_tab",Qf="horizontal_tabs",js="tab_count",Js=class{constructor(t,e){this.widget=t;this.i=e;this.headerRegion={id:`${t.wuid}-header-${e}`,click:()=>{t.activeTab!==e&&(t.properties.setValue(Zs,e),t.requestRepaint())},cursor:"pointer"}}widget;i;headerRegion;get scale(){return this.widget.scale}getValue(t){return this.widget.properties.getValue(`tab_${this.i}_${t}`)}get title(){return this.getValue("title")}get backgroundColor(){return this.getValue("background_color")}get foregroundColor(){return this.getValue("foreground_color")}get enabled(){return this.getValue("enabled")}get font(){return this.getValue("font").scale(this.scale)}},si=class extends rt{tabs=[];constructor(t,e){super(t,e),this.properties.add(new P(Jf)),this.properties.add(new P(Zs)),this.properties.add(new f(Qf)),this.properties.add(new P(js)),this.properties.addGenerator(()=>{this.tabs=[];let i=this.properties.getValue(js),r=[];for(let s=0;s<i;s++)this.tabs.push(new Js(this,s)),r.push(new T(`tab_${s}_title`),new S(`tab_${s}_background_color`),new S(`tab_${s}_foreground_color`),new f(`tab_${s}_enabled`),new H(`tab_${s}_font`));return r})}async parseNode(t){await super.parseNode(t);for(let e of t.getNodes("widget")){let i=e.getString("widget_type"),r=this.display.createWidget(i,this);r&&(await r.parseNode(e),this.widgets.push(r))}}draw(t){this.horizontalTabs?this.drawHorizontalTabs(t):this.drawVerticalTabs(t)}measureTabOffset(t){return this.horizontalTabs?{x:0,y:this.measureLabelHeight(t)}:{x:this.measureLabelWidth(t),y:0}}measureLabelHeight(t){let{scale:e}=this,i=1*e,r=this.minimumTabHeight;for(let s=0;s<this.tabs.length;s++){let o=this.tabs[s],a=t.measureText(o.title,o.font).height+i;a>r&&(r=a)}return r+this.margin}measureLabelWidth(t){let{scale:e}=this,i=1*e,r=this.minimumTabWidth;for(let s=0;s<this.tabs.length;s++){let o=this.tabs[s],a=t.measureText(o.title,o.font).width+i;a>r&&(r=a)}return r+this.margin}drawHorizontalTabs(t){let{margin:e,gap:i,scale:r}=this,s=this.measureLabelHeight(t),o=1*r,n=this.x;for(let a=0;a<this.tabs.length;a++){let h=this.tabs[a],l=t.measureText(h.title,h.font),c,d,g,w,x;this.activeTab===a?(c=n,d=this.y,g=l.width+o+e+i,w=s,x=h.backgroundColor):(c=n+i,d=this.y+2*r,g=l.width+o+e-i,w=s-2*r,x=this.darken(h.backgroundColor)),t.fillRect({x:c,y:d,width:g,height:w,color:x}),t.addHitRegion(h.headerRegion).addRect(c,d,g,w);let L=t.createLinearGradient(c,d,c,d+w);if(L.addColorStop(0,m.WHITE.toString()),L.addColorStop(1,m.WHITE.withAlpha(0).toString()),t.fillRect({x:c,y:d,width:g,height:w,gradient:L}),t.fillText({x:c+g/2,y:d+w/2,baseline:"middle",align:"center",font:h.font,color:h.foregroundColor,text:h.title}),n+=l.width+o+e-1*r,this.activeTab===a){let A=this.x,E=this.y+s,I=this.width,k=this.height-s;t.fillRect({x:A,y:E,width:I,height:k,color:h.backgroundColor});let F=this.widgets[a],Y=t.createChildAt(A,E,I,k);F.drawHolder(Y),F.draw(Y),F.drawDecoration(Y),F.drawOverlay(Y),t.copyChild(Y)}else this.widgets[a].hide()}}drawVerticalTabs(t){let{margin:e,gap:i,scale:r}=this,s=this.measureLabelWidth(t),o=1*r,n=this.y;for(let a=0;a<this.tabs.length;a++){let h=this.tabs[a],l=t.measureText(h.title,h.font),c=Math.max(l.height+o+o,this.minimumTabHeight),d,g,w,x,_;this.activeTab===a?(d=this.x,g=n,w=s,x=c+e+i,_=h.backgroundColor):(d=this.x+2*r,g=n+i,w=s-2*r,x=c+e-i,_=this.darken(h.backgroundColor)),t.fillRect({x:d,y:g,width:w,height:x,color:_}),t.addHitRegion(h.headerRegion).addRect(d,g,w,x);let A=t.createLinearGradient(d,g,d+w,g);if(A.addColorStop(0,m.WHITE.toString()),A.addColorStop(1,m.WHITE.withAlpha(0).toString()),t.fillRect({x:d,y:g,width:w,height:x,gradient:A}),t.fillText({x:d+w/2,y:g+x/2,baseline:"middle",align:"center",font:h.font,color:h.foregroundColor,text:h.title}),n+=c+e-1*r,this.activeTab===a){let E=this.x+s-1*r,I=this.y,k=this.width-s,F=this.height-1*r;t.fillRect({x:E,y:I,width:k,height:F,color:h.backgroundColor});let Y=this.widgets[a],K=t.createChildAt(E,I,k,F);Y.drawHolder(K),Y.draw(K),Y.drawDecoration(K),Y.drawOverlay(K),t.copyChild(K)}else this.widgets[a].destroy()}}darken(t){let e=Math.max(0,t.red-30),i=Math.max(0,t.green-30),r=Math.max(0,t.blue-30);return new m(e,i,r)}get margin(){return this.scale*10}get gap(){return this.scale*2}get minimumTabWidth(){return this.scale*20}get minimumTabHeight(){return this.scale*this.properties.getValue(Jf)}get activeTab(){return this.properties.getValue(Zs)}get tabCount(){return this.properties.getValue(js)}get horizontalTabs(){return this.properties.getValue(Qf)}};var ns=class{constructor(t){this.table=t}table;columnCount=0;cells=[];selectedRowIndex;dirty=!1;modifiedListeners=[];selectionChangedListeners=[];isEmpty(){return!this.cells.length}refresh(){this.dirty=!0}getCells(){return this.cells}getContent(){let t=[];for(let e of this.cells)t.push(e.map(i=>i.text||""));return t}setContent(t){this.cells.length=0;for(let e=0;e<t.length;e++)e===0&&(this.columnCount=t[e].length),this.cells.push(t[e].map(i=>({text:i})));this.dirty=!0}getColumnCount(){return this.columnCount}getRowCount(){return this.cells.length}setSelectedRowIndex(t){this.selectedRowIndex=t,this.selectionChangedListeners.forEach(e=>e()),this.dirty=!0}getSelection(){return this.selectedRowIndex===void 0?[]:[[...this.cells[this.selectedRowIndex].map(e=>e.text??null)]]}getCellText(t,e){let i=this.cells[t];return i?i[e]?.text??null:null}setColumnsCount(t){if(t<this.columnCount)for(let e of this.cells)e.length=t;if(t>this.columnCount){let e=t-this.columnCount;for(let i of this.cells)for(let r=0;r<e;r++)i.push({text:""})}this.columnCount=t,this.dirty=!0}addModifiedListener(t){this.modifiedListeners.push(t)}addSelectionChangedListener(t){this.selectionChangedListeners.push(t)}appendRow(){let t=[];for(let e=0;e<this.columnCount;e++)t[e]={text:""};return this.cells.push(t),this.dirty=!0,this.cells.length-1}deleteRow(t){this.cells.splice(t,1),this.dirty=!0}deleteColumn(t){for(let e of this.cells)e.splice(t,1);this.columnCount--,this.dirty=!0}insertRow(t){let e=[];for(let i=0;i<this.columnCount;i++)e.push({text:""});this.cells.splice(t,0,e),this.dirty=!0}insertColumn(t){for(let e of this.cells)e.splice(t,0,{text:""});this.columnCount++,this.dirty=!0}getCell(t,e){this.cells[t]=this.cells[t]??[];let i=this.cells[t][e]??{};return this.cells[t][e]=i,i}setCellText(t,e,i){let r=this.getCell(t,e);r.text=i,this.dirty=!0}setRowBackground(t,e){let i=this.cells[t];for(let r of i)r.backgroundColor=e;this.dirty=!0}setRowForeground(t,e){let i=this.cells[t];for(let r of i)r.foregroundColor=e;this.dirty=!0}setCellBackground(t,e,i){let r=this.getCell(t,e);r.backgroundColor=i,this.dirty=!0}setCellForeground(t,e,i){let r=this.getCell(t,e);r.foregroundColor=i,this.dirty=!0}setColumnCellEditorData(t,e){}};var tw="columns_count",ew="column_headers",iw="column_header_visible",rw="default_content",sw="font",as=class extends M{tableWrapper;table;spreadsheet;constructor(t,e){super(t,e),this.properties.add(new P(tw)),this.properties.add(new we(ew)),this.properties.add(new f(iw)),this.properties.add(new we(rw)),this.properties.add(new H(sw)),this.spreadsheet=new ns(this)}init(){this.tableWrapper=document.createElement("div"),this.tableWrapper.style.display="none",this.tableWrapper.style.overflow="auto",this.table=document.createElement("table"),this.table.style.tableLayout="fixed",this.table.style.borderSpacing="0",this.table.style.borderCollapse="collapse",this.tableWrapper.appendChild(this.table),this.display.rootPanel.appendChild(this.tableWrapper),this.table.addEventListener("click",t=>{let e=t.target;if(e.tagName==="TD"){let i=e.parentElement;i.rowIndex>0&&this.spreadsheet.setSelectedRowIndex(i.rowIndex-1)}else this.spreadsheet.setSelectedRowIndex(void 0);this.requestRepaint()}),this.spreadsheet.setContent(this.defaultContent)}draw(t){if(this.tableWrapper){let{x:e,y:i,width:r,height:s}=this.display.measureAbsoluteArea(this);this.tableWrapper.style.backgroundColor="white",this.tableWrapper.style.position="absolute",this.tableWrapper.style.display="block",this.tableWrapper.style.left=`${e}px`,this.tableWrapper.style.top=`${i}px`,this.tableWrapper.style.width=`${r}px`,this.tableWrapper.style.height=`${s}px`,this.tableWrapper.style.border="1px solid rgba(0, 0, 0, 0.1)",this.table.style.font=this.font.getFontString(),this.spreadsheet.dirty&&(this.generateTableContent(),this.spreadsheet.dirty=!1)}}generateTableContent(){let t=this.table.rows.length;for(let i=t-1;i>=0;i--)this.table.deleteRow(i);if(this.columnHeaderVisible){let i=this.table.insertRow();for(let r=0;r<this.columnsCount;r++){let s=this.columnHeaders[r],o=i.insertCell();o.style.color="#aaa",o.style.textAlign="left",s?.length>=2&&s[1]!==""&&(o.style.width=Number(s[1])*this.scale+"px"),o.style.overflow="hidden",o.style.padding=`${4*this.scale}px`,o.style.borderBottom="1px solid rgba(0, 0, 0, 0.1)",r!==0&&(o.style.borderLeft="1px solid rgba(0, 0, 0, 0.1)");let n="";s?.length>=1&&(n=s[0]);let a=document.createTextNode(n);o.appendChild(a)}i.insertCell()}let e=this.spreadsheet.getCells();for(let i=0;i<e.length;i++){let r=e[i],s=i===this.spreadsheet.selectedRowIndex,o=this.table.insertRow();for(let n=0;n<this.columnsCount;n++){let a=o.insertCell();if(a.style.textAlign="left",a.style.overflow="hidden",a.style.wordWrap="break-word",a.style.textOverflow="ellipsis",a.style.padding=`${4*this.scale}px`,n!==0&&(a.style.borderLeft="1px solid rgba(0, 0, 0, 0.1)"),r[n]!==void 0){let h=s?m.BLUE:r[n].backgroundColor;h&&(a.style.backgroundColor=h.toString());let l=s?m.WHITE:r[n].foregroundColor;l&&(a.style.color=l.toString());let c=document.createTextNode(r[n].text||"");a.appendChild(c)}}o.insertCell()}}hide(){this.tableWrapper&&(this.tableWrapper.style.display="none")}destroy(){this.tableWrapper&&(this.display.rootPanel.removeChild(this.tableWrapper),this.tableWrapper=void 0,this.table=void 0)}get columnsCount(){return this.properties.getValue(tw)}get columnHeaders(){return this.properties.getValue(ew)}get columnHeaderVisible(){return this.properties.getValue(iw)}get defaultContent(){return this.properties.getValue(rw)}get font(){return this.properties.getValue(sw).scale(this.scale)}};var ow="url",hs=class extends M{iframe;prevUrl;constructor(t,e){super(t,e),this.properties.add(new T(ow))}init(){this.iframe=document.createElement("iframe"),this.iframe.src="",this.iframe.style.display="none",this.iframe.style.border="0",this.display.rootPanel.appendChild(this.iframe)}draw(t){if(this.iframe){let{x:e,y:i,width:r,height:s}=this.display.measureAbsoluteArea(this);this.iframe.style.position="absolute",this.iframe.style.display="block",this.iframe.style.left=`${e}px`,this.iframe.style.top=`${i}px`,this.iframe.style.width=`${r}px`,this.iframe.style.height=`${s}px`,this.url&&this.prevUrl!==this.url&&(this.iframe.src=this.url,this.prevUrl=this.url)}}hide(){this.iframe&&(this.iframe.style.display="none")}destroy(){this.iframe&&(this.display.rootPanel.removeChild(this.iframe),this.iframe=void 0)}get url(){return this.properties.getValue(ow)}};var mP="Action Button",fP="Arc",wP="Array",xP="Boolean Button",yP="Boolean Switch",PP="Byte Monitor",bP="Check Box",vP="Choice Button",RP="Combo",_P="Combo Box",TP="Ellipse",SP="Gauge",LP="Grid Layout",CP="Grouping Container",AP="Image",OP="Image Boolean Button",EP="Image Boolean Indicator",MP="Intensity Graph",VP="Knob",IP="Label",BP="LED",HP="Linking Container",DP="Menu Button",WP="Meter",kP="Button",NP="Polygon",FP="Polyline",GP="Progress Bar",$P="Radio Box",UP="Rectangle",YP="Rounded Rectangle",zP="Sash Container",XP="Scaled Slider",qP="Scrollbar",KP="Spinner",jP="Tabbed Container",ZP="Table",JP="Tank",QP="Text Input",tb="Text Update",eb="Thermometer",ib="Thumb Wheel",rb="Web Browser",sb="XY Graph";function Qs(){return window.devicePixelRatio||1}var nw=(i=>(i.ENABLED="ENABLED",i.DISABLED="DISABLED",i.DEFAULT="DEFAULT",i))(nw||{}),to=class{constructor(t){this.targetElement=t;this.rootPanel=document.createElement("div"),this.rootPanel.className="display-root",this.rootPanel.style.overflow="hidden",this.rootPanel.style.position="relative",this.rootPanel.style.fontSize="0",this.rootPanel.style.flexShrink="0",this.rootPanel.style.margin="auto",t.appendChild(this.rootPanel),t.style.position="relative",t.style.display="flex";let e=document.createElement("canvas");this.rootPanel.appendChild(e),this.g=new yi(e),this.ctx=this.g.ctx,this.formatter=new di(!1),this.pvEngine=new ir(this),this.pvEngine.addProvider(new sr),this.pvEngine.addProvider(new or(this.formatter)),this.pvEngine.addProvider(new tr),this.displayRegion={id:"display-root",click:()=>{for(let i of this.rootPanel.getElementsByTagName("input"))i.blur();for(let i of this.rootPanel.getElementsByTagName("textarea"))i.blur();for(let i of this.rootPanel.getElementsByTagName("select"))i.blur()}},this.pathResolver=new Je(this),this.scriptLoader=new Qi(this),this.consoleHandler=new We,this.dialogHandler=new ke,this.imageLoader=new Fe,this.stepTimer=window.setTimeout(()=>this.step()),this.eventHandler=new pi(this,e,this.g.hitCanvas),this.resizeObserver=new ResizeObserver(()=>this.requestRepaint()),this.resizeObserver.observe(t)}targetElement;rootPanel;g;ctx;pvEngine;pathResolver;fontResolver;scriptLoader;imageLoader;consoleHandler;dialogHandler;formatter;repaintRequested=!1;_editMode=!1;_showGrid=!1;_showOutline=!1;_showRuler=!1;_selection=[];_scale=1;_pixelRatio=Qs();pixelRatioOverridden=!1;_transparent=!1;_disconnectedColor=new m(160,32,240);_invalidColor=new m(255,0,255);_majorColor=new m(255,0,0);_minorColor=new m(255,128,0);refreshCycle=100;originDesignSize;wasAutoScaleActive=!1;_autoScaleOverride="DEFAULT";resizeObserver;eventHandler;stepTimer;imagesPrefix="";absPrefix="";relPrefix="";instance;eventListeners={closedisplay:[],displayloaded:[],opendisplay:[],openpv:[],runcommand:[],runprocedure:[],runstack:[],selection:[],scale:[]};displayRegion;addProvider(t){this.pvEngine.addProvider(t)}addScriptLibrary(t,e){this.pvEngine.addScriptLibrary(t,e)}setPathResolver(t){this.pathResolver=t}getPathResolver(){return this.pathResolver}setScriptLoader(t){this.scriptLoader=t}getScriptLoader(){return this.scriptLoader}loadContent(t){return this.scriptLoader.load(t)}setImageLoader(t){this.imageLoader=t}getImageLoader(){return this.imageLoader}setConsoleHandler(t){this.consoleHandler=t}getConsoleHandler(){return this.consoleHandler}setDialogHandler(t){this.dialogHandler=t}getDialogHandler(){return this.dialogHandler}setFontResolver(t){this.fontResolver=t}getFontResolver(){return this.fontResolver}step(){!this.pixelRatioOverridden&&this._pixelRatio!==Qs()&&(this._pixelRatio=Qs(),this.requestRepaint()),this.repaintRequested&&(this.g.clearHitCanvas(),this.drawScreen(),this.repaintRequested=!1),this.stepTimer=window.setTimeout(()=>this.step(),this.refreshCycle)}drawScreen(){let t=this.rootPanel.style;if(t.position="relative",t.inset="",t.width="",t.height="",this.instance){let i=this.measureContainerSize();i&&this.isAutoScaleActive()?(t.position="absolute",t.inset="0",this.applyAutoScale(i)):(this.revertAutoScale(),t.width=this.instance.holderWidth+"px",t.height=this.instance.holderHeight+"px")}else t.width="0px",t.height="0px";if(this.g.pixelRatio=this._pixelRatio,this.g.resize(this.rootPanel.clientWidth,this.rootPanel.clientHeight),this.transparent&&this.g.clearCanvas(),this.editMode){let i=document.createElement("canvas"),r=i.getContext("2d");i.width=16,i.height=16,r.fillStyle="#d6d6d6",r.fillRect(0,0,8,8),r.fillRect(8,8,8,8),this.ctx.fillStyle=this.ctx.createPattern(i,"repeat"),this.ctx.fillRect(0,0,this.g.cssWidth,this.g.cssHeight),this.instance&&this.g.fillRect({...this.instance.bounds,color:this.instance.backgroundColor})}else this.transparent||this.g.fillCanvas(this.instance?.backgroundColor||m.WHITE);if(this.g.addHitRegion(this.displayRegion).addRect(0,0,this.g.cssWidth,this.g.cssHeight),this.showGrid&&this.instance){let i=document.createElement("canvas"),r=i.getContext("2d");i.width=25,i.height=25,r.fillStyle=this.instance.foregroundColor.toString(),r.fillRect(0,0,2,1),this.ctx.fillStyle=this.ctx.createPattern(i,"repeat"),this.ctx.fillRect(25,25,this.g.cssWidth-50,this.g.cssHeight-50)}if(this.showRuler){this.ctx.lineWidth=1,this.ctx.strokeStyle="grey",this.ctx.textBaseline="bottom",this.ctx.textAlign="center",this.ctx.fillStyle="grey",this.ctx.font="12px Arial";let i=0;for(;i<=this.g.cssWidth;)i+=100,this.ctx.beginPath(),this.ctx.moveTo(i-75+.5,this.g.cssHeight),this.ctx.lineTo(i-75+.5,this.g.cssHeight-4),this.ctx.moveTo(i-50+.5,this.g.cssHeight),this.ctx.lineTo(i-50+.5,this.g.cssHeight-6),this.ctx.moveTo(i-25+.5,this.g.cssHeight),this.ctx.lineTo(i-25+.5,this.g.cssHeight-4),this.ctx.moveTo(i+.5,this.g.cssHeight),this.ctx.lineTo(i+.5,this.g.cssHeight-8),this.ctx.stroke(),this.ctx.fillText(String(i),i,this.g.cssHeight-8);this.ctx.textAlign="right",this.ctx.textBaseline="middle";let r=0;for(;r<=this.g.cssHeight;)r+=100,this.ctx.beginPath(),this.ctx.moveTo(this.g.cssWidth,r-75+.5),this.ctx.lineTo(this.g.cssWidth-4,r-75+.5),this.ctx.moveTo(this.g.cssWidth,r-50+.5),this.ctx.lineTo(this.g.cssWidth-6,r-50+.5),this.ctx.moveTo(this.g.cssWidth,r-25+.5),this.ctx.lineTo(this.g.cssWidth-4,r-25+.5),this.ctx.moveTo(this.g.cssWidth,r+.5),this.ctx.lineTo(this.g.cssWidth-8,r+.5),this.ctx.stroke(),this.ctx.fillText(String(r),this.g.cssWidth-8,r)}this.showOutline&&this.instance&&(this.ctx.lineWidth=1,this.ctx.setLineDash([10,5]),this.ctx.strokeStyle="black",this.ctx.strokeRect(-.5,-.5,this.instance.holderWidth+1,this.instance.holderHeight+1),this.ctx.setLineDash([])),this.instance&&this.instance.draw(this.g);for(let i of this.selection){let r=this.findWidget(i);r&&r.drawSelection(this.ctx)}}requestRepaint(){this.repaintRequested=!0}setTooltip(t){this.rootPanel.title=t?.trim()??""}createWidget(t,e){switch(t){case mP:return new Ae(this,e);case fP:return new _r(this,e);case wP:return new es(this,e);case xP:return new nr(this,e);case yP:return new ar(this,e);case PP:return new Br(this,e);case bP:return new hr(this,e);case vP:return new lr(this,e);case RP:case _P:return new cr(this,e);case TP:return new Tr(this,e);case SP:return new Dr(this,e);case LP:return new Ze(this,e);case CP:return new is(this,e);case AP:return new Sr(this,e);case OP:return new pr(this,e);case EP:return new Wr(this,e);case MP:return new Nr(this,e);case VP:return new ur(this,e);case IP:return new Ar(this,e);case BP:return new Fr(this,e);case HP:return new Te(this,e);case DP:return new gr(this,e);case WP:return new $r(this,e);case kP:return new mr(this,e);case NP:return new Or(this,e);case FP:return new Mr(this,e);case GP:return new Ur(this,e);case $P:return new fr(this,e);case UP:return new Vr(this,e);case YP:return new Ir(this,e);case zP:return new os(this,e);case XP:return new wr(this,e);case qP:return new yr(this,e);case KP:return new Pr(this,e);case jP:return new si(this,e);case ZP:return new as(this,e);case JP:return new Yr(this,e);case QP:return new br(this,e);case tb:return new zr(this,e);case eb:return new Xr(this,e);case ib:return new Rr(this,e);case rb:return new hs(this,e);case sb:return new ts(this,e);default:console.warn(`Unsupported widget type: ${t}`)}}destroy(){this.instance?.destroy(),this.instance=void 0,this.pvEngine.clearState(),window.clearTimeout(this.stepTimer),this.resizeObserver.disconnect(),this.eventHandler.destroy(),this.rootPanel.remove(),this.targetElement.style.position="",this.targetElement.style.display=""}resolvePath(t,e){return this.pathResolver.resolve(t,e)}setSource(t,e){this.reset();let i=t.lastIndexOf("/")+1;return this.relPrefix=t.substring(0,i),new Promise((r,s)=>{fetch(t,{credentials:"same-origin"}).then(o=>{o.ok&&o.text().then(n=>{this.setSourceString(n,e),r()}).catch(n=>s(n))}).catch(o=>s(o))})}setSourceString(t,e){this.reset(),this.instance=new _e(this,void 0,e);let i=Re.parseFromXML(t);this.instance.parseNode(i).then(()=>{this.originDesignSize=this.instance.designSize,this.pvEngine.init(),this.requestRepaint();let r={backgroundColor:this.instance.backgroundColor.toString()};this.fireEvent("displayloaded",r)})}getRefreshCycle(){return this.refreshCycle}setRefreshCycle(t){this.refreshCycle=t}reset(){this.instance&&(this.clearSelection(),this.pvEngine.clearState(),this.instance.destroy(),this.instance=void 0),this.originDesignSize=void 0,this.wasAutoScaleActive=!1}measureAbsoluteOffset(t){let e=0,i=0,r=t.parent;for(;r;){if(e+=r.x,i+=r.y,r instanceof si){let s=r.measureTabOffset(this.g);e+=s.x,i+=s.y}r=r.parent}return{x:e,y:i}}measureAbsoluteArea(t){let e=t.bounds,i=this.measureAbsoluteOffset(t);return e.x+=i.x,e.y+=i.y,e.x+=t.x-t.holderX,e.y+=t.y-t.holderY,e.width+=t.width-t.holderWidth,e.height+=t.height-t.holderHeight,e.x+=this.scale*1,e.y+=this.scale*1,e}addEventListener(t,e){if(!(t in this.eventListeners))throw new Error(`Unknown event '${t}'`);this.eventListeners[t].push(e)}removeEventListener(t,e){if(!(t in this.eventListeners))throw new Error(`Unknown event '${t}'`);this.eventListeners[t]=this.eventListeners[t].filter(i=>i!==e)}fireEvent(t,e){this.eventListeners[t].forEach(r=>r(e))}get showGrid(){return this._showGrid}set showGrid(t){this._showGrid=t,this.requestRepaint()}get showOutline(){return this._showOutline}set showOutline(t){this._showOutline=t,this.requestRepaint()}get showRuler(){return this._showRuler}set showRuler(t){this._showRuler=t,this.requestRepaint()}get selection(){return this._selection}set selection(t){this._selection=t,this.requestRepaint();let e={selected:this._selection.slice()};this.fireEvent("selection",e)}get editMode(){return this._editMode}set editMode(t){this._editMode=t,this.requestRepaint()}get scale(){return this._scale}set scale(t){this._scale=t,this.requestRepaint();let e={scale:t};this.fireEvent("scale",e)}get autoScaleOverride(){return this._autoScaleOverride}set autoScaleOverride(t){this._autoScaleOverride=t,this.requestRepaint()}isAutoScaleActive(){if(!this.instance)return!1;switch(this._autoScaleOverride){case"ENABLED":return!0;case"DISABLED":return!1;case"DEFAULT":return this.instance.autoScaleWidgets.autoScaleWidgets}}measureContainerSize(){let t=this.targetElement.clientWidth,e=this.targetElement.clientHeight;return t&&e?{width:t,height:e}:void 0}applyAutoScale(t){if(!this.instance||!this.originDesignSize)return;this.wasAutoScaleActive=!0;let{width:e,height:i}=this.originDesignSize;if(!e||!i)return;let r=t.width/e,s=t.height/i,{minWidth:o,minHeight:n}=this.instance.autoScaleWidgets,a=o<0?e:o,h=n<0?i:n;e*r<a&&(r=a/e),i*s<h&&(s=h/i),this.instance.autoScale(r,s)}revertAutoScale(){this.instance&&this.wasAutoScaleActive&&this.instance.autoScale(1,1),this.wasAutoScaleActive=!1}get pixelRatio(){return this._pixelRatio}set pixelRatio(t){this._pixelRatio=t,this.pixelRatioOverridden=!0,this.requestRepaint()}get transparent(){return this._transparent}set transparent(t){this._transparent=t,this.requestRepaint()}get utc(){return this.formatter.utc}set utc(t){this.formatter.utc=t,this.requestRepaint()}get disconnectedColor(){return this._disconnectedColor}set disconnectedColor(t){this._disconnectedColor=t,this.requestRepaint()}get invalidColor(){return this._invalidColor}set invalidColor(t){this._invalidColor=t,this.requestRepaint()}get majorColor(){return this._majorColor}set majorColor(t){this._majorColor=t,this.requestRepaint()}get minorColor(){return this._minorColor}set minorColor(t){this._minorColor=t,this.requestRepaint()}get widgets(){return this.instance?this.instance.widgets:[]}clearSelection(){this.selection.length&&(this.selection=[])}findWidget(t){if(this.instance)return this.instance.findWidget(t)}findWidgetByName(t){if(this.instance)return this.instance.findWidgetByName(t)}getPVNames(){return this.pvEngine.getPVNames()}getPV(t){return this.pvEngine.getPV(t)}setValues(t){this.pvEngine.setExternalValues(t)}copyCanvas(t){let e=this.g.pixelRatio,i=t?{x:t.x*e,y:t.y*e,width:t.width*e,height:t.height*e}:{x:0,y:0,width:this.g.canvas.width,height:this.g.canvas.height},r=document.createElement("canvas");return r.width=i.width,r.height=i.height,r.getContext("2d").drawImage(this.g.canvas,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r}toDataURL(t="image/png",e){return this.g.ctx.canvas.toDataURL(t,e)}};var eo=class{pending=new Map;load(t){return new Promise(e=>{let i=this.pending.get(t);i?i.push(e):(this.pending.set(t,[e]),window.parent.postMessage({type:"loadImage",url:t},"*"))})}receiveData(t,e){let i=this.pending.get(t)??[];this.pending.delete(t);let r=e??t;for(let s of i)s(r)}};var io=class{cache=new Map;ttl=5e3;pending=new Map;async load(t){this.removeOldEntries();let e=this.cache.get(t);if(e)return e.text;let i=this.pending.get(t);return i?new Promise(r=>i.push(r)):new Promise(r=>{this.pending.set(t,[r]),window.parent.postMessage({type:"loadScript",path:t},"*")})}receiveContent(t,e){e!==null&&this.cache.set(t,{timestamp:Date.now(),text:e});let i=this.pending.get(t);if(i){this.pending.delete(t);for(let r of i)r(e)}}removeOldEntries(){let t=Date.now();this.cache.forEach((e,i)=>{e.timestamp+this.ttl<=t&&this.cache.delete(i)})}};var ls=new Map;var cs=class{constructor(t,e){this.pvName=t;this.widget=e;let i=ls.get(t)??[],r=i.length>0;i.push(this),ls.set(t,i),r||window.parent.postMessage({type:"historySubscribe",pvName:t},"*")}pvName;widget;samples=[];getSamples(){return this.samples}updateSamples(t){this.samples=t,this.widget.requestRepaint()}disconnect(){let t=ls.get(this.pvName)??[],e=t.indexOf(this);e!==-1&&t.splice(e,1),t.length===0&&(ls.delete(this.pvName),window.parent.postMessage({type:"historyUnsubscribe",pvName:this.pvName},"*"))}};var ro=class{canProvide(t){return!0}startProviding(t){window.parent.postMessage({type:"subscribe",pvNames:t.map(e=>e.name)},"*")}stopProviding(t){window.parent.postMessage({type:"unsubscribe",pvNames:t.map(e=>e.name)},"*")}isNavigable(){return!0}writeValue(t,e){window.parent.postMessage({type:"write",pvName:t,value:e},"*")}createHistoricalDataProvider(t,e){return new cs(t,e)}shutdown(){}};export{ye as AlarmSeverity,nw as AutoScaleOverride,m as Color,Qe as CompiledFormula,We as DefaultConsoleHandler,ke as DefaultDialogHandler,Fe as DefaultImageLoader,Je as DefaultPathResolver,to as Display,U as Font,ei as FormulaCompiler,ae as PV,eo as PostMessageImageLoader,ro as PostMessagePVProvider,io as PostMessageScriptLoader,M as Widget,tx as colorFromCssColor};
|
|
23
23
|
//# sourceMappingURL=opi.js.map
|