All Downloads are FREE. Search and download functionalities are using the official Maven repository.

static.chunk-QM2DDFCD.js Maven / Gradle / Ivy

There is a newer version: 5.10.9
Show newest version
import{a as C,b as A}from"./chunk-7FNOC45H.js";var Yu=class{writeInfo(t){console.log(t)}writeError(t){console.error(t)}writeWarning(t){console.warn(t)}},Xu=class{openConfirmDialog(t,e){return confirm(e)}openInformationDialog(t,e){alert(e)}openWarningDialog(t,e){alert(e)}openErrorDialog(t,e){alert(e)}openPasswordDialog(t,e,i){let r=prompt(e);return r?r===i:!1}},m=class X{constructor(e,i,r,s=255){this.red=e,this.green=i,this.blue=r,this.alpha=s}static TRANSPARENT=new X(0,0,0,0);static BLACK=new X(0,0,0);static BLUE=new X(0,0,255);static CYAN=new X(0,255,255);static DARK_GRAY=new X(150,150,150);static GRAY=new X(200,200,200);static GREEN=new X(0,255,0);static LIGHT_BLUE=new X(153,186,243);static ORANGE=new X(255,128,0);static PINK=new X(255,0,255);static PURPLE=new X(128,0,255);static RED=new X(255,0,0);static WHITE=new X(255,255,255);static YELLOW=new X(255,255,0);static BUTTON=new X(239,240,241);static BUTTON_DARKER=new X(164,168,172);static BUTTON_DARKEST=X.BLACK;static BUTTON_LIGHTEST=X.WHITE;withAlpha(e){return new X(this.red,this.green,this.blue,e)}mixWith(e,i){let r=Math.floor(this.red*i+e.red*(1-i)),s=Math.floor(this.green*i+e.green*(1-i)),o=Math.floor(this.blue*i+e.blue*(1-i));return new X(r,s,o)}brighter(){let{red:e,green:i,blue:r}=this,s=Math.floor(1/(1-.7));return e===0&&i===0&&r===0?new X(s,s,s):(e>0&&e0&&i0&&r(document.removeEventListener("click",We,!0),t.preventDefault(),t.stopPropagation(),!1);function ye(t){return(t.buttons&1)===1||t.buttons===void 0&&t.which==1}var gi=5;function Ku(t,e,i,r){return Math.sqrt((i-t)*(i-t)+(r-e)*(r-e))}function mi(t,e){return t&&e&&t.id===e.id}var ju=class{constructor(t,e,i){this.display=t,this.canvas=e,this.hitCanvas=i,e.addEventListener("click",r=>this.onCanvasClick(r),!1),e.addEventListener("mousedown",r=>this.onCanvasMouseDown(r),!1),e.addEventListener("mouseup",r=>this.onCanvasMouseUp(r),!1),e.addEventListener("mouseout",r=>this.onCanvasMouseOut(r),!1),e.addEventListener("mousemove",r=>this.onCanvasMouseMove(r),!1)}grabbing=!1;grabTarget;grabPoint;documentMouseMoveListener=t=>this.onDocumentMouseMove(t);documentMouseUpListener=t=>this.onDocumentMouseUp(t);prevEnteredRegion;toPoint(t){let e=this.canvas.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}}onCanvasClick(t){this.display.clearSelection();let e=this.toPoint(t);if(this.display.editMode)this.selectSingleWidget(e.x,e.y);else{let i=this.hitCanvas.getActiveRegion(e.x,e.y);i&&i.click&&i.click({clientX:t.clientX,clientY:t.clientY,point:e})}}onCanvasMouseDown(t){if(!this.display.editMode&&(document.removeEventListener("click",We,!0),ye(t))){let e=this.toPoint(t),i=this.hitCanvas.getActiveRegion(e.x,e.y);return i&&i.mouseDown&&i.mouseDown({clientX:t.clientX,clientY:t.clientY,point:e}),i&&i.grab&&(this.grabPoint=C({},e),this.grabTarget=i),t.preventDefault(),t.stopPropagation(),!1}}onCanvasMouseUp(t){if(this.display.editMode)return;let e=this.toPoint(t),i=this.hitCanvas.getActiveRegion(e.x,e.y);i&&i.mouseUp&&i.mouseUp()}onCanvasMouseOut(t){this.prevEnteredRegion&&this.prevEnteredRegion.mouseOut&&this.prevEnteredRegion.mouseOut(),this.prevEnteredRegion=void 0,t.preventDefault(),t.stopPropagation()}onCanvasMouseMove(t){let e=this.toPoint(t),i=this.hitCanvas.getActiveRegion(e.x,e.y);this.prevEnteredRegion&&this.prevEnteredRegion.mouseOut&&(mi(this.prevEnteredRegion,i)||this.prevEnteredRegion.mouseOut()),i&&i.mouseEnter&&(mi(this.prevEnteredRegion,i)||i.mouseEnter()),this.prevEnteredRegion=i;let r=i&&i.cursor?i.cursor:"auto";if(r!=this.canvas.style.cursor&&(this.canvas.style.cursor=r),!this.grabbing&&i&&i.tooltip?this.display.setTooltip(i.tooltip()):this.display.setTooltip(void 0),this.grabPoint&&!this.grabbing&&ye(t)){let s=Ku(this.grabPoint.x,this.grabPoint.y,e.x,e.y);Math.abs(s)>gi&&(this.initiateGrab(),gi>0&&this.grabPoint&&(this.grabPoint=e))}this.grabbing&&this.grabTarget&&ye(t)&&this.grabTarget.grab({clientX:t.clientX,clientY:t.clientY,point:e,dx:e.x-this.grabPoint.x,dy:e.y-this.grabPoint.y})}initiateGrab(){document.addEventListener("click",We,!0),document.addEventListener("mouseup",this.documentMouseUpListener),document.addEventListener("mousemove",this.documentMouseMoveListener),this.grabbing=!0}onDocumentMouseUp(t){if(this.grabbing){document.removeEventListener("mouseup",this.documentMouseUpListener),document.removeEventListener("mousemove",this.documentMouseMoveListener);let e=this.grabTarget;this.grabbing=!1,this.grabPoint=void 0,this.grabTarget=void 0,e?.grabEnd&&e.grabEnd()}}onDocumentMouseMove(t){this.onCanvasMouseMove(t)}selectSingleWidget(t,e){let i=this.display.instance;if(i)for(let r of i.widgets.slice().reverse()){let s=r.holderX,o=r.holderY,a=r.holderX+r.holderWidth,h=r.holderY+r.holderHeight;if(sPt(r,e,i))}function $(t){return t*Math.PI/180}function xt(t,e,i){let r=Math.floor(t*Math.cos(e)),s=Math.floor(-t*Math.sin(e));return{x:i.x+i.width/2+r,y:i.y+i.height/2+s}}function _d(t,e){let i=e.x-t.x,r=e.y-t.y,s=Math.sqrt(Math.pow(i,2)+Math.pow(r,2)),o=Math.acos(i/s);return r>0&&(o=2*Math.PI-o),new kt(Math.floor(s),o)}var kt=class{constructor(t,e){this.r=t,this.theta=e}toPoint(){let t=Math.floor(this.r*Math.cos(this.theta)),e=Math.floor(-this.r*Math.sin(this.theta));return{x:t,y:e}}};function oe(t,e){return t.map(i=>({x:i.x*e,y:i.y*e}))}function ve(t,e,i,r,s,o,a){t.beginPath(),!o&&!a?t.rect(e,i,r,s):(r<2*o&&(o=r/2),s<2*a&&(a=s/2),t.moveTo(e+o,i),t.lineTo(e+r-o,i),t.quadraticCurveTo(e+r,i,e+r,i+a),t.lineTo(e+r,i+s-a),t.quadraticCurveTo(e+r,i+s,e+r-o,i+s),t.lineTo(e+o,i+s),t.quadraticCurveTo(e,i+s,e,i+s-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+o,i))}function ae(t,e,i){return t===null?"":typeof t=="string"?t:typeof t=="number"?i===-1?wi(e,t,void 0,3):wi(e,t,i,i):t instanceof Date?t.toISOString().replace("T"," ").replace("Z",""):String(t)}function wi(t,e,i,r){if(e==null||e==null)return"";switch(t){case 0:case 1:let s={minimumFractionDigits:i,maximumFractionDigits:r,useGrouping:!1,roundingMode:"halfEven"};return Intl.NumberFormat("en-US",s).format(e);case 2:return e.toExponential(r).replace("e+","E").toUpperCase();case 3:return"0x"+e.toString(16).toUpperCase();default:return console.warn(`Unexpected format type ${t}`),String(e)}}var ep=class Ld{constructor(e,i){this.canvas=e,this.ctx=e.getContext("2d"),this.hitCanvas=i||new Qu,this.hitCtx=this.hitCanvas.ctx}ctx;hitCanvas;hitCtx;createChild(e,i){let r=this.hitCanvas.createChild(e,i),s=document.createElement("canvas");return s.width=e,s.height=i,new Ld(s,r)}translate(e,i){this.ctx.translate(e,i),this.hitCtx.translate(e,i)}copy(e,i,r){this.ctx.drawImage(e.canvas,i,r),e.hitCanvas.transferToParent(i,r,e.canvas.width,e.canvas.height)}copyFitted(e,i,r,s,o){let{width:a,height:h}=e.canvas,l=a/h,d=s,n=d/l;n>o&&(n=o,d=n*l),this.copyScaled(e,i,r,d,n)}copyScaled(e,i,r,s,o){this.ctx.drawImage(e.canvas,i,r,s,o),e.hitCanvas.transferToParent(i,r,s,o)}clearHitCanvas(){this.hitCanvas.clear()}fillCanvas(e){this.ctx.fillStyle=e.toString(),this.ctx.fillRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height)}clearCanvas(){this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height)}scaleCanvas(e,i){this.ctx.canvas.style.width=e+"px",this.ctx.canvas.style.height=i+"px"}resize(e,i){(this.ctx.canvas.width!=e||this.ctx.canvas.height!=i)&&(this.ctx.canvas.width=e,this.ctx.canvas.height=i,this.hitCanvas.ctx.canvas.width=e,this.hitCanvas.ctx.canvas.height=i)}fillRect(e){"color"in e?this.ctx.fillStyle=e.color.toString():this.ctx.fillStyle=e.gradient,e.opacity!==void 0&&(this.ctx.globalAlpha=e.opacity),e.rx||e.ry?(ve(this.ctx,e.x,e.y,e.width,e.height,e.rx||0,e.ry||0),this.ctx.fill()):this.ctx.fillRect(e.x,e.y,e.width,e.height),e.opacity!==void 0&&(this.ctx.globalAlpha=1)}fillText(e){this.ctx.textBaseline=e.baseline,this.ctx.textAlign=e.align,this.ctx.font=e.font.getFontString(),this.ctx.fillStyle=e.color.toString(),this.ctx.fillText(e.text,e.x,e.y)}fillEllipse(e){this.ctx.beginPath();let i=e.startAngle||0,r=e.endAngle===void 0?2*Math.PI:e.endAngle;this.ctx.ellipse(e.cx,e.cy,e.rx,e.ry,0,i,r,e.anticlockwise),"color"in e?this.ctx.fillStyle=e.color.toString():this.ctx.fillStyle=e.gradient,e.opacity!==void 0&&(this.ctx.globalAlpha=e.opacity),this.ctx.fill(),e.opacity!==void 0&&(this.ctx.globalAlpha=1)}strokeEllipse(e){e.dash&&this.ctx.setLineDash(e.dash),this.ctx.lineWidth=e.lineWidth||1,this.ctx.beginPath();let i=e.startAngle||0,r=e.endAngle===void 0?2*Math.PI:e.endAngle;this.ctx.ellipse(e.cx,e.cy,e.rx,e.ry,0,i,r,e.anticlockwise),"color"in e?this.ctx.strokeStyle=e.color.toString():this.ctx.strokeStyle=e.gradient,this.ctx.stroke(),e.dash&&this.ctx.setLineDash([])}measureText(e,i){this.ctx.font=i.getFontString();let r=this.ctx.measureText(e).width,s=i.height;return{width:r,height:s}}createLinearGradient(e,i,r,s){return this.ctx.createLinearGradient(e,i,r,s)}strokeRect(e){e.dash&&this.ctx.setLineDash(e.dash);let i=e.lineWidth||1;if(this.ctx.lineWidth=i,this.ctx.strokeStyle=e.color.toString(),e.crispen&&i){let r=U(e,i/2,i/2);e.rx||e.ry?(ve(this.ctx,r.x,r.y,r.width,r.height,e.rx||0,e.ry||0),this.ctx.stroke()):this.ctx.strokeRect(r.x,r.y,r.width,r.height)}else e.rx||e.ry?(ve(this.ctx,e.x,e.y,e.width,e.height,e.rx||0,e.ry||0),this.ctx.stroke()):this.ctx.strokeRect(e.x,e.y,e.width,e.height);e.dash&&this.ctx.setLineDash([])}strokePath(e){e.dash&&this.ctx.setLineDash(e.dash),this.ctx.beginPath();for(let i of e.path.segments)i.line?this.ctx.lineTo(i.x,i.y):this.ctx.moveTo(i.x,i.y);this.ctx.lineWidth=e.lineWidth||1,this.ctx.strokeStyle=e.color.toString(),e.opacity!==void 0&&(this.ctx.globalAlpha=e.opacity),this.ctx.stroke(),e.opacity!==void 0&&(this.ctx.globalAlpha=1),e.dash&&this.ctx.setLineDash([])}fillPath(e){this.ctx.beginPath();for(let i of e.path.segments)i.line?this.ctx.lineTo(i.x,i.y):this.ctx.moveTo(i.x,i.y);"color"in e?this.ctx.fillStyle=e.color.toString():this.ctx.fillStyle=e.gradient,e.opacity!==void 0&&(this.ctx.globalAlpha=e.opacity),this.ctx.fill("evenodd"),e.opacity!==void 0&&(this.ctx.globalAlpha=1)}addHitRegion(e){return this.hitCanvas.beginHitRegion(e),new ip(this.hitCanvas.ctx)}},S=class Be{segments=[];constructor(e,i){this.segments.push({x:e,y:i,line:!1})}static fromPoints(e){let i=e.findIndex(s=>s.y!==null);if(i===-1){let s=new Be(0,0);return s.segments.length=0,s}let r=new Be(e[i].x,e[i].y);for(let s=i+1;s0&&e[s-1].y===null?r.moveTo(o,a):r.lineTo(o,a))}return r}getBoundingBox(){let e={x:this.segments[0].x,y:this.segments[0].y},i={x:this.segments[0].x,y:this.segments[0].y};for(let r=0;ri.x&&(i.x=s.x),s.yi.y&&(i.y=s.y)}return{x:e.x,y:e.y,width:i.x-e.x,height:i.y-e.y}}lineTo(e,i){return this.segments.push({x:e,y:i,line:!0}),this}moveTo(e,i){return this.segments.push({x:e,y:i,line:!1}),this}closePath(){let e=this.segments[0];return this.segments.push({x:e.x,y:e.y,line:!0}),this}translate(e,i){for(let r of this.segments)r.x+=e,r.y+=i;return this}},ip=class{constructor(t){this.ctx=t}addRect(t,e,i,r){return this.ctx.fillRect(t,e,i,r),this}addEllipse(t,e,i,r,s,o,a,h){this.ctx.beginPath(),this.ctx.ellipse(t,e,i,r,s,o,a,h),this.ctx.fill()}addPath(t){this.ctx.beginPath();for(let e of t.segments)e.line?this.ctx.lineTo(e.x,e.y):this.ctx.moveTo(e.x,e.y);this.ctx.fill()}},Pd=class{constructor(t,e=[]){this.widget=t;for(let i of e)this.properties.set(i.name,i)}properties=new Map;generators=[];clear(){this.properties.clear()}add(t){this.properties.set(t.name,t)}addGenerator(t){this.generators.push(t)}all(){return[...this.properties.values()]}loadProperty(t,e){if(t.hasNode(e.name)){if(e instanceof kd)e.value=t.getActions(e.name);else if(e instanceof Wd)e.value=t.getAutoScaleWidgets(e.name);else if(e instanceof y)e.value=t.getBoolean(e.name);else if(e instanceof Fe)e.value=t.getColorMap(e.name);else if(e instanceof R)e.value=t.getColor(e.name);else if(e instanceof H)e.value=t.getFloat(e.name);else if(e instanceof O)e.value=t.getFont(e.name);else if(e instanceof b)e.value=t.getInt(e.name);else if(e instanceof $e)e.value=t.getMacros(e.name);else if(e instanceof ne)e.value=t.getPoints(e.name);else if(!(e instanceof Jt))if(e instanceof Rd)e.value=t.getRules(e.name);else if(e instanceof Ed)e.value=t.getScaleOptions(e.name);else if(e instanceof Md)e.value=t.getScripts(e.name);else if(e instanceof _)e.rawValue=t.getString(e.name);else if(e instanceof de)e.value=t.getStringList(e.name);else if(e instanceof Oe)e.value=t.getStringMap(e.name);else if(e instanceof Ie)e.value=t.getStringTable(e.name);else throw new Error(`Property ${e.name} has an unexpected type`)}}loadXMLValues(t){this.properties.forEach(e=>{this.loadProperty(t,e)}),this.resolveStringProperties();for(let e of this.generators)for(let i of e())this.properties.set(i.name,i),this.loadProperty(t,i);this.resolveStringProperties()}resolveStringProperties(){for(let t=0;t<2;t++)this.properties.forEach(e=>{if(e instanceof _){let i=e;i.rawValue!==void 0&&this.widget?e.value=this.widget.expandMacro(i.rawValue):e.value=i.rawValue}})}getProperty(t){return this.properties.get(t)}getValue(t,e=!1){let i=this.properties.get(t);if(i&&i.value!==void 0)return i.value;if(!e)throw new Error(`Missing property ${t}`)}setValue(t,e){let i=this.properties.get(t);if(!i)throw new Error(`Cannot set value of unknown property ${t}`);i.value=e}},Z=class{constructor(t,e){this.name=t,this.defaultValue=e,this.value=e}_value;listeners;get value(){return this._value}set value(t){if(this.value!==t){let e=this._value;if(this._value=t,this.listeners)for(let i of this.listeners)i(t,e)}}addListener(t){this.listeners=this.listeners||[],this.listeners.push(t)}removeListener(t){let e=this.listeners||[],i=e.indexOf(t);i!==-1&&e.splice(i,1)}printScriptValue(t){return String(t)}},_=class extends Z{rawValue;printScriptValue(t){return`"${t.replace('"','\\"')}"`}},Jt=class extends Z{constructor(t,e){super(t),this.pvPropertyName=e}},b=class extends Z{},H=class extends Z{},y=class extends Z{},R=class extends Z{printScriptValue(t){let{red:e,green:i,blue:r}=C({},t);return`ColorFontUtil.getColorFromRGB(${e}, ${i}, ${r})`}},O=class extends Z{printScriptValue(t){let{name:e,height:i,style:r}=C({},t);return`ColorFontUtil.getFont("${e}", ${i}, ${r})`}},Fe=class extends Z{printScriptValue(t){return`${t.code}`}},ne=class extends Z{},kd=class extends Z{},$e=class extends Z{},Md=class extends Z{},de=class extends Z{},Oe=class extends Z{},Ie=class extends Z{},Rd=class extends Z{},Ed=class extends Z{},Wd=class extends Z{},Bd=class{actions=[];hookFirstActionToClick=!1;hookAllActionsToClick=!1;add(t){this.actions.push(t)}isClickable(){return this.actions.length&&(this.hookFirstActionToClick||this.hookAllActionsToClick)}getAction(t){if(!(t>=this.actions.length))return this.actions[t]}toString(){return this.actions.length===1?String(this.actions[0]):`${this.actions.length} actions`}},yi="description",ct=class{properties;constructor(){this.properties=new Pd(null,[new _(yi,"")])}parseNode(t){this.properties.loadXMLValues(t)}get description(){return this.properties.getValue(yi)}},vi="command",bi="command_directory",Ti="wait_time",rp=class extends ct{constructor(){super(),this.properties.add(new _(vi,"")),this.properties.add(new _(bi,"$(user.home)")),this.properties.add(new b(Ti,10))}execute(t){throw new Error("Unsupported action EXECUTE_CMD")}get command(){return this.properties.getValue(vi)}get commandDirectory(){return this.properties.getValue(bi)}get waitTime(){return this.properties.getValue(Ti)}toString(){return`Execute Command ${this.command}`}},sp=["Arial","Arial Black","Courier New","Helvetica","Tahoma","Verdana"],it=class Nt{constructor(e,i,r,s){this.name=e,this.style=r,s?this.height=i:this.height=Math.round(i*16/15)}static ARIAL_9=new Nt("Arial",9,0,!1);static ARIAL_10=new Nt("Arial",10,0,!1);static ARIAL_11=new Nt("Arial",11,0,!1);static ARIAL_12_BOLD=new Nt("Arial",12,1,!1);height;scale(e){return new Nt(this.name,e*this.height,this.style,!0)}getFontString(){return this.style===1?`bold ${this.height}px ${this.name}`:this.style===2?`italic ${this.height}px ${this.name}`:this.style===3?`italic bold ${this.height}px ${this.name}`:(this.style!==0&&console.warn(`Unsupported font style ${this.style}`),`normal ${this.height}px ${this.name}`)}get bold(){return this.style===1||this.style===3}get italic(){return this.style===2||this.style===3}isWebSafe(){return sp.indexOf(this.name)!==-1}},op=class{BLACK=m.BLACK;BLUE=m.BLUE;CYAN=m.CYAN;DARK_GRAY=m.DARK_GRAY;GRAY=m.GRAY;GREEN=m.GREEN;LIGHT_BLUE=m.LIGHT_BLUE;ORANGE=m.ORANGE;PINK=m.PINK;PURPLE=m.PURPLE;RED=m.RED;WHITE=m.WHITE;YELLOW=m.YELLOW;getColorFromRGB(t,e,i){return new m(t,e,i)}getFont(t,e,i){return new it(t,e,i,!1)}},ap=class{constructor(t){this.display=t}writeInfo(t){this.display.getConsoleHandler().writeInfo(t)}writeError(t){this.display.getConsoleHandler().writeError(t)}writeWarning(t){this.display.getConsoleHandler().writeWarning(t)}},hp=class{createDoubleArray(t){return Array(t).fill(0)}createIntArray(t){return Array(t).fill(0)}toJavaDoubleArray(t){return[...t]}toJavaIntArray(t){return[...t]}},lp=class{constructor(t,e){this.spreadsheet=t,this.scriptEngine=e}addModifiedListener(t){}addSelectionChangedListener(t){this.spreadsheet.addSelectionChangedListener(()=>{this.scriptEngine.schedule(()=>{let e=t.selectionChanged;e(this.spreadsheet.getSelection())})})}appendRow(){return this.spreadsheet.appendRow()}deleteColumn(t){this.spreadsheet.deleteColumn(t)}deleteRow(t){this.spreadsheet.deleteRow(t)}getCellText(t,e){return this.spreadsheet.getCellText(t,e)}getColumnCount(){return this.spreadsheet.getColumnCount()}getContent(){return this.spreadsheet.getContent()}getRowCount(){return this.spreadsheet.getRowCount()}getSelection(){return this.spreadsheet.getSelection()}insertColumn(t){this.spreadsheet.insertColumn(t)}insertRow(t){this.spreadsheet.insertRow(t)}isEmpty(){return this.spreadsheet.isEmpty()}refresh(){this.spreadsheet.refresh()}setCellBackground(t,e,i){this.spreadsheet.setCellBackground(t,e,i)}setCellForeground(t,e,i){this.spreadsheet.setCellForeground(t,e,i)}setCellText(t,e,i){this.spreadsheet.setCellText(t,e,i)}setColumnCellEditorData(t,e){this.spreadsheet.setColumnCellEditorData(t,e)}setColumnsCount(t){this.spreadsheet.setColumnsCount(t)}setContent(t){this.spreadsheet.setContent(t)}setRowBackground(t,e){this.spreadsheet.setRowBackground(t,e)}setRowForeground(t,e){this.spreadsheet.setRowForeground(t,e)}revealRow(t){}},He=class{constructor(t,e,i){this.code=t,this.interpolate=e,this.autoscale=i,t===0||(t===1?(this.values=[0,1],this.colors=[[0,0,0],[255,255,255]]):t===2?(this.values=[0,.111,.365,.619,.873,1],this.colors=[[0,0,143],[0,0,255],[0,255,255],[255,255,0],[255,0,0],[128,0,0]]):t===3?(this.values=[0,.126,.251,.375,.5,.625,.749,.874,1],this.colors=[[0,0,0],[255,0,255],[0,0,255],[0,255,255],[0,255,0],[255,255,0],[255,128,0],[255,0,0],[255,255,255]]):t===4?(this.values=[0,.365,.746,1],this.colors=[[11,0,0],[255,0,0],[255,255,0],[255,255,255]]):t===5?(this.values=[0,1],this.colors=[[0,255,255],[255,0,255]]):t===6&&(this.values=[0,.5,1],this.colors=[[0,0,0],[255,0,0],[255,255,255]]))}values=[];colors=[];entries=[];dirty=!0;addMapping(t,e,i,r){this.values.push(t),this.colors.push([e,i,r]),this.dirty=!0}compile(){this.entries.length=0;for(let t=0;tt[0]e[0]?1:0)}lookup(t){this.dirty&&(this.compile(),this.dirty=!1);let e=this.binarySearch(t);if(e>=0)return this.entries[e][1];if(e=-e-1,e===0)return this.entries[e][1];if(e===this.entries.length)return this.entries[e-1][1];if(this.interpolate){let[i,r]=this.entries[e-1],[s,o]=this.entries[e],a=(t-i)/(s-i),h=Math.floor((o[0]-r[0])*a+r[0]),l=Math.floor((o[1]-r[1])*a+r[1]),d=Math.floor((o[2]-r[2])*a+r[2]);return[h,l,d]}else return this.entries[e-1][1]}getMinMax(){let t=Math.min.apply(Math,this.values),e=Math.max.apply(Math,this.values);return[t,e]}binarySearch(t){let e=0,i=this.entries.length-1;for(;e<=i;){let r=i+e>>1;if(t>this.entries[r][0])e=r+1;else if(t{t.valueChanged(this)})}removeListener(t){this._pv.removeListener(t)}},ze=class{constructor(t){this.widget=t}executeAction(t){this.widget.executeActionByIndex(t)}getPVByName(t){let e=this.widget.display.getPV(t);return e?new Ge(e):null}getPV(t="pv_name"){let e=this.getPropertyValue(t);return e?this.getPVByName(e):null}getHookedActions(){let t=this.widget.getHookedActions().map(e=>new np(e,this.widget));return new dp(t)}getVar(t){return this.widget.vars.get(t)??null}setVar(t,e){this.widget.vars.set(t,e)}getPropertyValue(t){let e=this.widget.properties.getProperty(t);return e?e.value:null}setPropertyValue(t,e){let i=this.widget.properties.getProperty(t);if(!i)throw new Error(`Cannot set value of unknown property ${t}`);if(i instanceof _)e=e!==void 0?String(e):e,this.widget.properties.setValue(t,e);else if(i instanceof Fe){let r=0;switch(e){case"GrayScale":r=1;break;case"JET":r=2;break;case"ColorSpectrum":r=3;break;case"Hot":r=4;break;case"Cool":r=5;break;case"Shaded":r=6;break}let s=new He(r,!0,!0);this.widget.properties.setValue(t,s)}else this.widget.properties.setValue(t,e);this.widget.requestRepaint()}getName(){return this.getPropertyValue("name")}setX(t){this.setPropertyValue("x",t)}setY(t){this.setPropertyValue("y",t)}setWidth(t){this.setPropertyValue("width",t)}setHeight(t){this.setPropertyValue("height",t)}setEnabled(t){this.setPropertyValue("enabled",t)}setVisible(t){this.setPropertyValue("visible",t)}getValue(){return this.widget.value??null}setValue(t){this.widget.value=t}setValueInUIThread(t){this.setValue(t)}},up=class extends ze{table;spreadSheetTable;constructor(t,e){super(t),this.table=t,this.spreadSheetTable=new lp(this.table.spreadsheet,e)}getTable(){return this.spreadSheetTable}},pp=class extends ze{xyGraph;constructor(t){super(t),this.xyGraph=t}clearGraph(){this.xyGraph.clearGraph()}getXBuffer(t){return this.xyGraph.getTrace(t).snapshot().map(e=>e.x)}getYBuffer(t){return this.xyGraph.getTrace(t).snapshot().map(e=>e.y)}};function Id(t,e){switch(t.widgetType){case"Table":return new up(t,e);case"XY Graph":return new pp(t);default:return new ze(t)}}var cp=class{constructor(t,e){this.display=t,this.scriptEngine=e}isActive(){return!0}getWidget(t){let e=this.display.findWidgetByName(t);if(e)return Id(e,this.scriptEngine)}},gp=class{constructor(t){this.display=t}readTextFile(t){let e=this.display.resolvePath(t);var i=new XMLHttpRequest;if(i.open("GET",e,!1),i.send(null),i.status===200)return i.responseText;throw Error(`Cannot open ${e}`)}},mp=class{constructor(t){this.display=t}fullScreen(){document.documentElement.requestFullscreen()}openConfirmDialog(t){return this.display.getDialogHandler().openConfirmDialog("Confirm Dialog",t)}openInformationDialog(t){this.display.getDialogHandler().openInformationDialog("Information",t)}openWarningDialog(t){this.display.getDialogHandler().openWarningDialog("Warning",t)}openErrorDialog(t){this.display.getDialogHandler().openErrorDialog("Error",t)}openPasswordDialog(t,e){return this.display.getDialogHandler().openPasswordDialog("Password Input Dialog",t,e)}},fp=class{constructor(t){this.display=t}openInformation(t,e,i){this.display.getDialogHandler().openInformationDialog(e,i)}openConfirm(t,e,i){return this.display.getDialogHandler().openConfirmDialog(e,i)}openError(t,e,i){this.display.getDialogHandler().openErrorDialog(e,i)}},Hd=class{constructor(t,e){this.name=t,this.pvEngine=e}_writable=!1;_units;_labels;_lowerDisplayLimit;_lowerAlarmLimit;_lowerWarningLimit;_upperWarningLimit;_upperAlarmLimit;_upperDisplayLimit;_time;_value;_severity="NONE";_indexValue;_precision=-1;_disconnected=!1;provider;get navigable(){return this.provider?.isNavigable()||!1}get units(){return this._units}set units(t){this._units=t,this.pvEngine.requestRepaint()}get labels(){return this._labels}set labels(t){this._labels=t,this.pvEngine.requestRepaint()}get lowerDisplayLimit(){return this._lowerDisplayLimit}set lowerDisplayLimit(t){this._lowerDisplayLimit=t,this.pvEngine.requestRepaint()}get lowerAlarmLimit(){return this._lowerAlarmLimit}set lowerAlarmLimit(t){this._lowerAlarmLimit=t,this.pvEngine.requestRepaint()}get lowerWarningLimit(){return this._lowerWarningLimit}set lowerWarningLimit(t){this._lowerWarningLimit=t,this.pvEngine.requestRepaint()}get upperWarningLimit(){return this._upperWarningLimit}set upperWarningLimit(t){this._upperWarningLimit=t,this.pvEngine.requestRepaint()}get upperAlarmLimit(){return this._upperAlarmLimit}set upperAlarmLimit(t){this._upperAlarmLimit=t,this.pvEngine.requestRepaint()}get upperDisplayLimit(){return this._upperDisplayLimit}set upperDisplayLimit(t){this._upperDisplayLimit=t,this.pvEngine.requestRepaint()}get precision(){return this._precision}set precision(t){this._precision=t,this.pvEngine.requestRepaint()}get writable(){return this._writable}set writable(t){this._writable=t,this.pvEngine.requestRepaint()}get disconnected(){return this._disconnected}set disconnected(t){this._disconnected=t,this.pvEngine.requestRepaint()}get time(){return this._time}get value(){return this._value}get indexValue(){return this._indexValue}get severity(){return this._severity}get alarmName(){let t=this.toNumber();return t==null?"NONE":t<=(this.lowerAlarmLimit??NaN)?"LOLO":t>=(this.upperAlarmLimit??NaN)?"HIHI":t<=(this.lowerWarningLimit??NaN)?"LOW":t>=(this.upperWarningLimit??NaN)?"HIGH":"NONE"}toNumber(){if(this.value===null)return null;if(typeof this.value=="number")return this.value;if(typeof this.value=="boolean")return this.value?1:0;if(typeof this.indexValue!==void 0)return this.indexValue}setSample(t){this._time=t.time,this._value=t.value,this._indexValue=t.valueIndex,this._severity=t.severity,this._units=t.units,this.pvEngine.requestRepaint()}addListener(t){this.pvEngine.addListener(this.name,t)}removeListener(t){this.pvEngine.addListener(this.name,t)}toString(){if(this.value!==void 0)return String(this.value)}},xp=(t=>(t.NONE="NONE",t.MINOR="MINOR",t.MAJOR="MAJOR",t.INVALID="INVALID",t.UNDEFINED="UNDEFINED",t))(xp||{}),wp=["yyyy","MM","dd","HH","mm","ss","nnnnnnnnn"],yp=class{constructor(t){this.display=t,this.pvEngine=t.pvEngine}pvEngine;checkPVValue(t){if(t.getValue()===null)throw new Error(`PV ${t.getName()} has no value.`)}createPV(t,e){let i=this.pvEngine.createPV(t);return new Ge(i)}writePV(t,e,i){this.pvEngine.createPV(t),this.pvEngine.setValue(new Date,t,e)}getDouble(t){this.checkPVValue(t);let e=t._pv.toNumber();return parseFloat(e??t.getValue())}getLong(t){this.checkPVValue(t);let e=t._pv.toNumber();return typeof e=="number"&&(e=Math.floor(e)),parseInt(e??t.getValue(),10)}getString(t){return this.checkPVValue(t),ae(t._pv.value,0,-1)}getStringArray(t){this.checkPVValue(t);let e=t.getValue();return Array.isArray(e)?e.map(i=>String(i)):[String(e)]}getTimeInMilliseconds(t){return this.checkPVValue(t),t._pv.time?.getTime()??0}getTimeString(t,e="yyyy-MM-dd HH:mm:ss.nnnnnnnnn"){this.checkPVValue(t);let i=t._pv.time;if(i){let r=e;for(let s of wp)r=r.replace(s,this.formatDate(i,s));return r}return null}getSeverity(t){switch(this.checkPVValue(t),t._pv.severity){case"NONE":return 0;case"MAJOR":return 1;case"MINOR":return 2;default:return-1}}getSeverityString(t){return this.checkPVValue(t),String(t._pv.severity)}getStatus(t){return this.checkPVValue(t),t._pv.alarmName}getUnits(t){return this.checkPVValue(t),t._pv.units||null}formatDate(t,e){let{utc:i}=this.display;if(e==="yyyy")return String(i?t.getUTCFullYear():t.getFullYear());if(e==="MM"){let r=(i?t.getUTCMonth():t.getMonth())+1;return r<10?"0"+r:""+r}else if(e==="dd"){let r=i?t.getUTCDate():t.getDate();return r<10?"0"+r:""+r}else if(e==="HH"){let r=i?t.getUTCHours():t.getHours();return r<10?"0"+r:""+r}else if(e==="mm"){let r=i?t.getUTCMinutes():t.getMinutes();return r<10?"0"+r:""+r}else if(e==="ss"){let r=i?t.getUTCSeconds():t.getSeconds();return r<10?"0"+r:""+r}else if(e==="nnnnnnnnn"){let r=i?t.getUTCMilliseconds():t.getMilliseconds();return r<10?"00"+r:r<100?"0"+r:""+r}else throw new Error(`Unexpected format '${e}'`)}},vp=class{constructor(t){this.display=t}openOPI(t,e,i,r){if(i===0){let s={path:e,replace:i===0};this.display.fireEvent("opendisplay",s)}else throw new Error(`Unsupported target ${i}`)}closeCurrentOPI(){this.display.fireEvent("closedisplay",{})}};function bp(t){let e=t.widget,i=t.widget.display,r=function(l){this.run=l.run},s=function(l){this.runnable=l};s.prototype.start=function(){t.schedule(()=>this.runnable.run())},s.sleep=function(l){let d=Date.now(),n=0;for(;Date.now(){t.schedule(()=>{let n=l.valueChanged;n(d)})}},h={ITableModifiedListener:function(l){this.modified=d=>{let n=l.modified;n(d)}},ITableSelectionChangedListener:function(l){this.selectionChanged=d=>{let n=l.selectionChanged;n(d)}}};return{display:new cp(e.display,t),widget:Id(e,t),java:{lang:{Runnable:r,Thread:s},util:{Timer:o}},org:{csstudio:{swt:{widgets:{natives:{SpreadSheetTable:h}}}},yamcs:{studio:{data:{IPVListener:a}}}},ColorFontUtil:new op,ConsoleUtil:new ap(i),DataUtil:new hp,FileUtil:new gp(i),GUIUtil:new mp(i),MessageDialog:new fp(i),PVUtil:new yp(i),ScriptUtil:new vp(i),SpreadSheetTable:h,Java:{type:function(l){switch(l){case"java.lang.Runnable":return r;case"java.lang.Thread":return s;case"java.util.Timer":return o;case"org.csstudio.swt.widgets.natives.SpreadSheetTable":return h;case"org.yamcs.studio.data.IPVListener":return a;default:throw new Error("Unexpected class name: "+l)}},to:function(l,d){return l}}}}var _t,rt,re;function Tp(){_t=document.createElement("iframe"),_t.id="script-e",_t.style.display="none",document.body.appendChild(_t),rt=_t.contentWindow,re=rt.eval,!re&&rt.execScript&&(rt.execScript.call(rt,"null"),re=rt.eval)}var he=class{constructor(t,e,i=[]){this.widget=t,this.scriptText=e,_t||Tp(),this.scriptText=e.replace(/importClass\([^\)]*\)\s*\;?/gi,"").replace(/importPackage\([^\)]*\)\s*\;?/gi,"").trim(),this.context=C(C({pvs:i.map(r=>new Ge(r)),triggerPV:null},t.display.pvEngine.scriptLibraries),bp(this))}context;run(t){window.setTimeout(()=>{if(this.context.triggerPV=null,t)for(let e of this.context.pvs)e._pv===t&&(this.context.triggerPV=e);this.runWithContext(()=>{re.call(rt,this.scriptText)})})}schedule(t,e){window.setTimeout(()=>this.runWithContext(t),e)}runWithContext(t){let e=[];for(let i in _t.contentWindow)e.push(i);try{for(let r in this.context)this.context.hasOwnProperty(r)&&(rt[r]=this.context[r]);t();let i={};for(let r in rt)e.indexOf(r)===-1&&(i[r]=rt[r]);this.context=i}finally{for(let i in rt)e.indexOf(i)===-1&&delete rt[i]}}},Si="path",Vi="embedded",Ci="scriptText",Sp=class extends ct{constructor(){super(),this.properties.add(new _(Si,"")),this.properties.add(new y(Vi,!1)),this.properties.add(new _(Ci,""))}execute(t){this.embedded?new he(t,this.scriptText).run():fetch(t.display.resolvePath(this.path),{credentials:"same-origin"}).then(e=>{e.ok&&e.text().then(i=>{new he(t.display.instance,i).run()})})}get path(){return this.properties.getValue(Si)}get embedded(){return this.properties.getValue(Vi)}get scriptText(){return this.properties.getValue(Ci)}toString(){return"Execute JavaScript"}},Ai="macros",_i="mode",Li="path",Vp=class extends ct{constructor(){super(),this.properties.add(new _(Li,"")),this.properties.add(new $e(Ai)),this.properties.add(new b(_i,0))}execute(t){let e=C({},this.macros.macros),i={path:this.path,replace:this.mode===0,args:e};t.display.fireEvent("opendisplay",i)}get macros(){return this.properties.getValue(Ai)}get path(){return this.properties.getValue(Li)}get mode(){return this.properties.getValue(_i)}toString(){return`Open ${this.path}`}},Pi="path",Cp=class extends ct{constructor(){super(),this.properties.add(new _(Pi,""))}execute(t){throw new Error("Unsupported action OPEN_FILE")}get path(){return this.properties.getValue(Pi)}toString(){return`Open ${this.path}`}},ki="hyperlink",Ap=class extends ct{constructor(){super(),this.properties.add(new _(ki,"http://"))}execute(t){this.hyperlink&&(window.location.href=this.hyperlink)}get hyperlink(){return this.properties.getValue(ki)}toString(){return`Open Webpage ${this.hyperlink}`}},Mi="path",_p=class extends ct{constructor(){super(),this.properties.add(new _(Mi,""))}execute(t){this.path&&new Audio(t.display.resolvePath(this.path)).play()}get path(){return this.properties.getValue(Mi)}toString(){return`Play WAV File ${this.path}`}},Ri="command",Ei="args",Wi="confirm_message",Lp=class extends ct{constructor(){super(),this.properties.add(new _(Ri,"")),this.properties.add(new Oe(Ei,{})),this.properties.add(new _(Wi,""))}execute(t){if(this.confirmMessage&&!t.display.getDialogHandler().openConfirmDialog("Confirm Dialog",this.confirmMessage))return;let e=t.expandMacro(this.command),i={};for(let s in this.args)i[s]=t.expandMacro(this.args[s]);let r={command:e,args:i};t.display.fireEvent("runcommand",r)}get command(){return this.properties.getValue(Ri)}get args(){return this.properties.getValue(Ei)}get confirmMessage(){return this.properties.getValue(Wi)}toString(){return`Run ${this.command}`}},Bi="procedure",Ii="args",Hi="confirm_message",Pp=class extends ct{constructor(){super(),this.properties.add(new _(Bi,"")),this.properties.add(new Oe(Ii,{})),this.properties.add(new _(Hi,""))}execute(t){if(this.confirmMessage&&!t.display.getDialogHandler().openConfirmDialog("Confirm Dialog",this.confirmMessage))return;let e={procedure:this.procedure,args:this.args};t.display.fireEvent("runprocedure",e)}get procedure(){return this.properties.getValue(Bi)}get args(){return this.properties.getValue(Ii)}get confirmMessage(){return this.properties.getValue(Hi)}toString(){return`Run ${this.procedure}`}},Di="pv_name",Ni="value",Fi="timeout",$i="confirm_message",kp=class extends ct{constructor(){super(),this.properties.add(new _(Di,"$(pv_name)")),this.properties.add(new _(Ni,"")),this.properties.add(new b(Fi,10)),this.properties.add(new _($i,""))}execute(t){if(!(this.confirmMessage&&!t.display.getDialogHandler().openConfirmDialog("Confirm Dialog",this.confirmMessage))&&this.pvName){let e=t.expandMacro(this.pvName);t.display.pvEngine.createPV(e),t.display.pvEngine.setValue(new Date,e,this.value)}}get pvName(){return this.properties.getValue(Di)}get value(){return this.properties.getValue(Ni)}get timeout(){return this.properties.getValue(Fi)}get confirmMessage(){return this.properties.getValue($i)}toString(){return`Write ${this.value} to ${this.pvName}`}},Mp=class{includeParentMacros=!0;macros={};clear(){this.macros={}}set(t,e){this.macros[t]=e}get(t){if(t in this.macros)return this.macros[t]}},Dd=class{rules=[]},Rp=class{constructor(t,e,i){this.autoScaleWidgets=t,this.minWidth=e,this.minHeight=i}},Ep=class{constructor(t,e,i){this.widthScalable=t,this.heightScalable=e,this.keepWidthHeightRatio=i}},Wp=class{scripts=[]},Nd=class Zt{constructor(e){this.node=e}get name(){return this.node.nodeName}static parseFromXML(e){let i=new DOMParser().parseFromString(e,"text/xml");return new Zt(i.documentElement)}getNode(e){let i=this.findChild(e);return new Zt(i)}getNodes(e){let i=[];for(let r=0;r{i.ok&&i.text().then(r=>{let s=this.display.pvEngine.createScript(this,e,r);this.pvs.push(...s.pvs)})});for(let e of this.rules.rules)this.properties.getProperty(e.propertyName)?this.display.pvEngine.createRule(this,e):console.warn(`Cannot create rule for unsupported property ${e.propertyName}`);this.actions.isClickable()&&(this.holderRegion={id:`${this.wuid}-holder`},this.tooltip&&(this.holderRegion.tooltip=()=>this.tooltip),this.actions.isClickable()&&(this.holderRegion.click=()=>{for(let e of this.getHookedActions())this.executeAction(e)},this.holderRegion.cursor="pointer")),this.init()}getHookedActions(){let{actions:t}=this,e=[];for(let i=0;i{document.fonts.add(r),this.requestRepaint()}).catch(r=>{console.warn(`Failed to load font '${t.getFontString()}'.`,r)})}get pv(){if(this.pvName)return this.display.getPV(this.pvName)}isMinorSeverity(){return this.pv?.severity==="MINOR"}isMajorSeverity(){return this.pv?.severity==="MAJOR"}get alarm(){return this.pv?.severity==="MINOR"||this.pv?.severity==="MAJOR"||this.pv?.severity==="INVALID"}get alarmSensitiveBackgroundColor(){if(this.backgroundAlarmSensitive){if(this.isMajorSeverity())return m.RED;if(this.isMinorSeverity())return m.ORANGE;if(this.pv?.severity==="INVALID")return m.PINK}return this.backgroundColor}get alarmSensitiveForegroundColor(){if(this.foregroundAlarmSensitive){if(this.isMajorSeverity())return m.RED;if(this.isMinorSeverity())return m.ORANGE}return this.foregroundColor}get scale(){let t=this.display.scale,e=this.parent;for(;e;)t*=e.relativeScale,e=e.parent;return t}get value(){return this._value}set value(t){this._value=t,this.requestRepaint()}addPropertyListener(t,e){this.properties.getProperty(t).addListener(e)}removePropertyListener(t,e){this.properties.getProperty(t).removeListener(e)}toDataURL(t="image/png",e){let i=this.display.measureAbsoluteArea(this);return this.display.copyCanvas(i).toDataURL(t,e)}get wuid(){return this.properties.getValue(hr)}get name(){return this.properties.getValue(Ji)}get holderX(){return this.scale*this.properties.getValue(Ce)}get holderY(){return this.scale*this.properties.getValue(Ae)}get holderWidth(){return this.scale*this.properties.getValue(Ve)}get holderHeight(){return this.scale*this.properties.getValue(be)}get borderAlarmSensitive(){return this.properties.getValue(Ui)}get backgroundAlarmSensitive(){return this.properties.getValue(zi)}get foregroundAlarmSensitive(){return this.properties.getValue(Zi)}get pvName(){return this.properties.getValue(Te,!0)}get pvValue(){return this.properties.getValue(Qi,!0)}get borderColor(){return this.properties.getValue(qi)}get borderStyle(){return this.properties.getValue(Xi)}get borderWidth(){return this.scale*this.properties.getValue(Yi)}get backgroundColor(){return this.properties.getValue(Gi)}get enabled(){return this.properties.getValue(Ki)}get foregroundColor(){return this.properties.getValue(ji)}get tooltip(){let t=this.properties.getProperty(rr);if(t.rawValue)return this.expandMacro(t.rawValue)}get transparent(){return this.properties.getValue(sr)}get visible(){return this.properties.getValue(or)}get actions(){return this.properties.getValue(Oi)}get scripts(){return this.properties.getValue(ir)}get rules(){return this.properties.getValue(tr)}get scaleOptions(){return this.properties.getValue(er)}get widgetType(){return this.properties.getValue(ar,!0)}get text(){return this.display.editMode?(this.properties.getProperty(Se).rawValue||"").split(" ").join("\xA0"):this.properties.getValue(Se).split(" ").join("\xA0")}init(){}hide(){}destroy(){}},lr="macros",ue=class De extends G{_widgets=[];_connections=[];relativeScale=1;constructor(e,i){super(e,i),this.properties.add(new $e(lr))}expandContainerMacros(e){for(let i in this.macros.macros)e=e.replace(`$(${i})`,this.macros.macros[i]),e=e.replace(`\${${i}}`,this.macros.macros[i]);return this.parent&&this.macros.includeParentMacros&&(e=this.parent.expandContainerMacros(e)),e}findWidget(e){for(let i of this.widgets){if(i.wuid===e)return i;if(i instanceof De){let r=i.findWidget(e);if(r)return r}}}findWidgetByName(e){for(let i of this.widgets){if(i.name===e)return i;if(i instanceof De){let r=i.findWidgetByName(e);if(r)return r}}for(let i of this.connections)if(i.name===e)return i}hide(){for(let e of this.widgets)e.hide()}destroy(){for(let e of this.widgets)e.destroy()}get widgets(){return this._widgets}get connections(){return this._connections}get macros(){return this.properties.getValue(lr)}},nr="arrow_length",dr="arrows",ur="fill_arrow",pr="name",cr="line_color",gr="line_style",mr="line_width",fr="src_wuid",xr="src_term",wr="tgt_wuid",yr="tgt_term",vr="router",br="points",Bp="wuid",wt="LEFT",yt="UP",vt="DOWN",bt="RIGHT",Ip=class extends G{sourceWidget;targetWidget;constructor(t){super(t),this.properties.clear(),this.properties.add(new b(nr)),this.properties.add(new b(dr)),this.properties.add(new y(ur)),this.properties.add(new _(pr)),this.properties.add(new R(cr)),this.properties.add(new b(gr)),this.properties.add(new b(mr)),this.properties.add(new _(fr)),this.properties.add(new _(xr)),this.properties.add(new _(wr)),this.properties.add(new _(yr)),this.properties.add(new b(vr)),this.properties.add(new ne(br)),this.properties.add(new _(Bp))}parseNode(t){this.properties.loadXMLValues(t),this.sourceWidget=this.display.findWidget(this.sourceWuid),this.sourceWidget||console.warn(`Can't find source widget ${this.sourceWuid}`),this.targetWidget=this.display.findWidget(this.targetWuid),this.targetWidget||console.warn(`Can't find target widget ${this.targetWuid}`)}draw(t){!this.sourceWidget||!this.targetWidget||(this.points.length?this.drawPath(t):this.router===0?this.drawManhattanConnection(t):this.router===1&&this.drawDirectConnection(t))}drawPath(t){let e=this.getPosition(this.sourceWidget,this.sourceTerm),i=this.getPosition(this.targetWidget,this.targetTerm),r=[e,...this.points,i],s=S.fromPoints(r).translate(.5*this.scale,.5*this.scale);t.strokePath({path:s,lineWidth:this.lineWidth,color:this.lineColor,dash:this.getDashArray()}),this.drawStartArrow(t,r[1],r[0]),this.drawStopArrow(t,r[r.length-2],r[r.length-1])}drawManhattanConnection(t){let e=this.getManhattanAnchor(this.sourceWidget,this.sourceTerm),i=this.getManhattanAnchor(this.targetWidget,this.targetTerm),r=this.route(e,i),s=S.fromPoints(r);this.lineWidth&&t.strokePath({lineWidth:this.lineWidth,color:this.lineColor,path:s,dash:this.getDashArray()}),this.drawStartArrow(t,r[r.length-2],r[r.length-1]),this.drawStopArrow(t,r[1],r[0])}getDashArray(){let{scale:t}=this;if(this.lineWidth){if(this.lineStyle===0)return[];if(this.lineStyle===1)return[6*t,2*t];if(this.lineStyle===2)return[2*t,2*t];if(this.lineStyle===3)return[6*t,2*t,2*t,2*t];if(this.lineStyle===4)return[6*t,2*t,2*t,2*t,2*t,2*t];console.warn(`Unsupported connection line style ${this.lineStyle}`)}}drawDirectConnection(t){let e=this.getPosition(this.sourceWidget,this.sourceTerm),i=this.getPosition(this.targetWidget,this.targetTerm);this.lineWidth&&t.strokePath({path:new S(e.x,e.y).lineTo(i.x,i.y),lineWidth:this.lineWidth,color:this.lineColor,dash:this.getDashArray()}),this.drawStartArrow(t,i,e),this.drawStopArrow(t,e,i)}getManhattanAnchor(t,e){let i;switch(e){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":i=yt;break;case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":i=vt;break;case"LEFT":i=wt;break;case"RIGHT":i=bt;break;default:}let r=t.bounds,s=this.getPosition(t,e),o=s.x-r.x,a=r.x+r.width-s.x,h=s.y-r.y,l=r.y+r.height-s.y;return Math.min(o,a)0&&r*r0&&e.direction===vt||r<0&&e.direction===yt?s={x:e.x,y:t.y}:t.direction===e.direction?(a=Math.min(t.x,e.x)-n,s={x:a,y:t.y}):s={x:t.x-i/2,y:t.y},r>0?o=yt:o=vt):t.direction===bt?i<0&&r*r0?s={x:t.x+n,y:t.y}:r>0&&e.direction===vt||r<0&&e.direction===yt?s={x:e.x,y:t.y}:t.direction===e.direction?(a=Math.max(t.x,e.x)+n,s={x:a,y:t.y}):s={x:t.x-i/2,y:t.y},r>0?o=yt:o=vt):t.direction===vt?i*i0?s={x:t.x,y:t.y+n}:i>0&&e.direction===bt||i<0&&e.direction===wt?s={x:t.x,y:e.y}:t.direction===e.direction?(a=Math.max(t.y,e.y)+n,s={x:t.x,y:a}):s={x:t.x,y:t.y-r/2},i>0?o=wt:o=bt):t.direction===yt&&(i*i0&&e.direction===vt?(s=e,o=e.direction):(r<0?s={x:t.x,y:t.y-n}:i>0&&e.direction===bt||i<0&&e.direction===wt?s={x:t.x,y:e.y}:t.direction===e.direction?(a=Math.min(t.y,e.y)-n,s={x:t.x,y:a}):s={x:t.x,y:t.y-r/2},i>0?o=wt:o=bt));let p=A(C({},s),{direction:o});return h=h.concat(this.route(p,e)),h.push(t),h}drawStartArrow(t,e,i){let r=t.ctx;if(this.arrows===1||this.arrows===3){let s=this.calculateArrowPoints(e,i);if(s[2]=i,this.fillArrow){r.fillStyle=this.lineColor.toString(),r.beginPath();for(let o=0;oi.visible))e.drawHolder(t),e.draw(t),e.drawDecoration(t);for(let e of this.connections)e.draw(t);for(let e of this.widgets.filter(i=>i.visible))e.drawOverlay(t)}measureContentBounds(t){let e=0,i=0,r=0,s=0;for(let o of this.widgets.filter(a=>a.visible)){let a=t?o.bounds:o.unscaledBounds;e=Math.min(e,a.x),i=Math.min(i,a.y),r=Math.max(r,a.x+a.width),s=Math.max(s,a.y+a.height)}return{x:e,y:i,width:r-e,height:s-i}}get autoScaleWidgets(){return this.properties.getValue(Tr)}},Dp=0,Sr="group_name",Vr="opi_file",Cr="resize_behaviour",$d=class extends ue{linkedDisplay;resolvedOpiFile;constructor(t,e){super(t,e),this.properties.add(new _(Sr)),this.properties.add(new _(Vr)),this.properties.add(new b(Cr,0))}parseNode(t){super.parseNode(t);let e=Dp++;this.macros.set("LCID",`LCID_${e}`)}init(){this.opiFile&&(this.resolvedOpiFile=this.display.resolvePath(this.opiFile),fetch(this.resolvedOpiFile,{credentials:"same-origin"}).then(t=>{t.ok&&t.text().then(e=>{this.linkedDisplay=new Fd(this.display,this);let i=Nd.parseFromXML(e);this.linkedDisplay.parseNode(i),this.requestRepaint()})}))}draw(t){this.transparent||t.fillRect(A(C({},this.area),{color:this.backgroundColor}));let e=this.getLinkedWidget();if(this.linkedDisplay&&e)if(t.fillRect(A(C({},this.area),{color:this.linkedDisplay.backgroundColor})),this.resizeBehavior===0){let i=this.linkedDisplay.measureContentBounds(!1),{width:r,height:s}=i,o=this.display.scale;r*=o,s*=o;let a=r/s,h=this.width,l=h/a,d=h/r;l>this.height&&(l=this.height,h=l*a,d=l/r),this.linkedDisplay.relativeScale=d;let n=t.createChild(Math.ceil(h),Math.ceil(l));n.translate(i.x,i.y),this.linkedDisplay.draw(n),t.copy(n,this.x,this.y)}else if(this.resizeBehavior===1)console.warn("Unsupported resize behavior of LinkingContainer",this.resizeBehavior);else if(this.resizeBehavior===2){let i=this.linkedDisplay.measureContentBounds(!0),r=t.createChild(i.width,i.height);r.translate(i.x,i.y),this.linkedDisplay.draw(r),t.copy(r,this.x,this.y)}else this.resizeBehavior===3&&console.warn("Unsupported resize behavior of LinkingContainer",this.resizeBehavior)}getLinkedWidget(){return this.linkedDisplay&&this.groupName!==""?this.linkedDisplay.findWidgetByName(this.groupName):this.linkedDisplay}get widgets(){return this.linkedDisplay?this.linkedDisplay.widgets:[]}get connections(){return this.linkedDisplay?this.linkedDisplay.connections:[]}findWidget(t){if(this.linkedDisplay)return this.linkedDisplay.findWidget(t)}get opiFile(){return this.properties.getValue(Vr)}get groupName(){return this.properties.getValue(Sr)}get resizeBehavior(){return this.properties.getValue(Cr)}},Np=class{constructor(t){this.display=t}resolve(t,e){if(t.startsWith("/"))return`${this.display.absPrefix}${t.slice(1)}`;if(t.startsWith("http://")||t.startsWith("https://"))return t;if(e){let i=e.parent;for(;i;){if(i instanceof $d){let r=i.resolvedOpiFile,s=r.lastIndexOf("/")+1;return`${r.substring(0,s)}${t}`}i=i.parent}}return`${this.display.relPrefix}${t}`}},Fp=class{constructor(t,e){this.pvName=t,this.formula=e}pvValues=new Map;updateDataSource(t,e){this.pvValues.set(t,e)}clearState(){this.pvValues.clear()}getPVNames(){let t=this.formula.expression,e=[];return this.getExpressionParameters(t,e),e}getExpressionParameters(t,e){switch(t.type){case"ParameterLiteral":e.indexOf(t.value)===-1&&e.push(t.value);break;case"ConditionalExpression":this.getExpressionParameters(t.consequent,e),t.alternate&&this.getExpressionParameters(t.alternate,e);break;case"BinaryExpression":this.getExpressionParameters(t.left,e),this.getExpressionParameters(t.right,e);break;case"LogicalExpression":this.getExpressionParameters(t.left,e),this.getExpressionParameters(t.right,e);break;case"UnaryExpression":this.getExpressionParameters(t.argument,e);break;case"CallExpression":for(let i of t.arguments)this.getExpressionParameters(i,e);break}}execute(){let t=this.formula.expression;return this.executeExpression(t)}executeExpression(t){switch(t.type){case"BooleanLiteral":return t.value;case"ParameterLiteral":let e=this.pvValues.get(t.value);return e?e.value:void 0;case"ConstantLiteral":return t.value;case"NumericLiteral":return t.value;case"StringLiteral":return t.value;case"ConditionalExpression":return this.executeConditionalExpression(t);case"BinaryExpression":return this.executeBinaryExpression(t);case"LogicalExpression":return this.executeLogicalExpression(t);case"UnaryExpression":return this.executeUnaryExpression(t);case"CallExpression":return this.executeCallExpression(t);default:throw new Error("Unexpected expression type")}}executeBinaryExpression(t){let e=this.executeExpression(t.left),i=this.executeExpression(t.right);switch(t.operator){case"+":return e+i;case"-":return e-i;case"*":return e*i;case"/":return e/i;case"^":return Math.pow(e,i);case"%":return e%i;case"==":return e===i;case"!=":return e!==i;case"<=":return e<=i;case"<":return e=":return e>=i;case">":return e>i;default:throw new Error(`Unexpected binary operator ${t.operator}`)}}executeLogicalExpression(t){let e=this.executeExpression(t.left),i=this.executeExpression(t.right);switch(t.operator){case"&&":return e&&i;case"||":return e||i;default:throw new Error(`Unexpected logical operator ${t.operator}`)}}executeConditionalExpression(t){let e=this.executeExpression(t.test),i=this.executeExpression(t.consequent);if(t.alternate===void 0)return e?i:null;{let r=this.executeExpression(t.alternate);return e?i:r}}executeUnaryExpression(t){let e=this.executeExpression(t.argument);switch(t.operator){case"-":return-e;case"+":return e;default:throw new Error(`Unexpected unary operator ${t.operator}`)}}executeCallExpression(t){let e=t.callee.name,i=[];for(let r of t.arguments)i.push(this.executeExpression(r));switch(e){case"abs":return Math.abs(i[0]);case"acos":return Math.acos(i[0]);case"asin":return Math.asin(i[0]);case"atan":return Math.atan(i[0]);case"cbrt":return Math.cbrt(i[0]);case"ceil":return Math.ceil(i[0]);case"cos":return Math.cos(i[0]);case"cosh":return Math.cosh(i[0]);case"exp":return Math.exp(i[0]);case"floor":return Math.floor(i[0]);case"log":return Math.log(i[0]);case"log10":return Math.log10(i[0]);case"round":return Math.round(i[0]);case"signum":return Math.sign(i[0]);case"sin":return Math.sin(i[0]);case"sinh":return Math.sinh(i[0]);case"sqrt":return Math.sqrt(i[0]);case"tan":return Math.tan(i[0]);case"tanh":return Math.tanh(i[0]);case"toDegrees":return i[0]*180/Math.PI;case"toRadians":return i[0]/180*Math.PI;case"parameterAcquisitionStatus":return this.callParameterAcquisitionStatus(i[0]);default:throw new Error(`Unsupported function '${e}'`)}}callParameterAcquisitionStatus(t){let e=this.pvValues.get(t);if(e)return e.acquisitionStatus}};function $p(t,e){function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i}function Mt(t,e,i,r){var s=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(s,Mt.prototype),s.expected=e,s.found=i,s.location=r,s.name="SyntaxError",s}$p(Mt,Error);function _e(t,e,i){return i=i||" ",t.length>e?t:(e-=t.length,i+=i.repeat(e),t+i.slice(0,e))}Mt.prototype.format=function(t){var e="Error: "+this.message;if(this.location){var i=null,r;for(r=0;r `+a+`
`+l+` |
`+o.line+" | "+d+`
`+l+" | "+_e("",s.column-1," ")+_e("",p,"^")}else e+=`
 at `+a}return e};Mt.buildMessage=function(t,e){var i={literal:function(d){return'"'+s(d.text)+'"'},class:function(d){var n=d.parts.map(function(p){return Array.isArray(p)?o(p[0])+"-"+o(p[1]):o(p)});return"["+(d.inverted?"^":"")+n.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(d){return d.description}};function r(d){return d.charCodeAt(0).toString(16).toUpperCase()}function s(d){return d.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(n){return"\\x0"+r(n)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(n){return"\\x"+r(n)})}function o(d){return d.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(n){return"\\x0"+r(n)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(n){return"\\x"+r(n)})}function a(d){return i[d.type](d)}function h(d){var n=d.map(a),p,g;if(n.sort(),n.length>0){for(p=1,g=1;p=",D="==",N="!=",K="&&",J="||",ht=/^[\t ]/,tt=/^[A-Z_a-z]/,lt=/^[a-zA-Z0-9_]/,st=/^[0-9]/,Rt=/^[1-9]/,Gt=/^[^\n\r\f"]/,et=/^[^\n\r\f']/,nt=/^[+\-]/,gt=/^[%*\/\^]/,mt=/^[<>]/,Et=j("=",!1),St=dt(["	"," "],!1,!1),Vt=j("false",!0),ft=j("true",!0),ut=j("PI",!0),ot=j("E",!0),pt=Ct("identifier"),zt=dt([["A","Z"],"_",["a","z"]],!1,!1),Ut=dt([["a","z"],["A","Z"],["0","9"],"_"],!1,!1),qt=Ct("boolean"),Yt=Ct("constant"),qd=Ct("number"),Ue=j(".",!1),Yd=j("0",!1),Xd=dt([["0","9"]],!1,!1),Kd=dt([["1","9"]],!1,!1),jd=Ct("string"),qe=j('"',!1),Ye=dt([`
`,"\r","\f",'"'],!0,!1),Zd=Ct("parameter"),Xe=j("'",!1),Ke=dt([`
`,"\r","\f","'"],!0,!1),je=j("(",!1),Ze=j(")",!1),pe=dt(["+","-"],!1,!1),Je=j(",",!1),Qe=dt(["%","*","/","^"],!1,!1),ti=j("<=",!1),ei=j(">=",!1),ii=dt(["<",">"],!1,!1),ri=j("==",!1),si=j("!=",!1),oi=j("&&",!1),ai=j("||",!1),Jd=function(u){return u},Qd=function(u){return{type:"Formula",expression:u}},tu=function(u){return u},eu=function(u,f){return{type:"Symbol",name:u+f.join("")}},iu=function(){return{type:"BooleanLiteral",value:!0}},ru=function(){return{type:"BooleanLiteral",value:!1}},su=function(){return{type:"ConstantLiteral",value:Math.PI}},ou=function(){return{type:"ConstantLiteral",value:Math.E}},au=function(){return{type:"NumericLiteral",value:parseFloat(ce())}},hu=function(){return{type:"NumericLiteral",value:parseFloat(ce())}},lu=function(){return{type:"NumericLiteral",value:parseFloat(ce())}},nu=function(u){return{type:"StringLiteral",value:u.join("")}},du=function(u){return{type:"ParameterLiteral",value:u.join("")}},uu=function(u){return u},pu=function(u,f){return{type:"UnaryExpression",operator:u,argument:f}},cu=function(u,f){return{type:"CallExpression",callee:u,arguments:f}},gu=function(u){return qu(Gu(u,0))},mu=function(u,f){return zu(u,f,3)},fu=function(u,f){return ee(u,f)},xu=function(u,f){return ee(u,f)},wu=function(u,f){return ee(u,f)},yu=function(u,f){return ee(u,f)},vu=function(u,f){return Uu(u,f)},c=e.peg$currPos|0,q=c,Wt=[{line:1,column:1}],at=c,te=e.peg$maxFailExpected||[],E=e.peg$silentFails|0,Xt;if(e.startRule){if(!(e.startRule in s))throw new Error(`Can't start parsing from rule "`+e.startRule+'".');o=s[e.startRule]}function ce(){return t.substring(q,c)}function im(){return q}function rm(){return{source:r,start:q,end:c}}function sm(){return Kt(q,c)}function om(u,f){throw f=f!==void 0?f:Kt(q,c),li([Ct(u)],t.substring(q,c),f)}function am(u,f){throw f=f!==void 0?f:Kt(q,c),Tu(u,f)}function j(u,f){return{type:"literal",text:u,ignoreCase:f}}function dt(u,f,L){return{type:"class",parts:u,inverted:f,ignoreCase:L}}function hm(){return{type:"any"}}function bu(){return{type:"end"}}function Ct(u){return{type:"other",description:u}}function hi(u){var f=Wt[u],L;if(f)return f;if(u>=Wt.length)L=Wt.length-1;else for(L=u;!Wt[--L];);for(f=Wt[L],f={line:f.line,column:f.column};Lat&&(at=c,te=[]),te.push(u))}function Tu(u,f){return new Mt(u,null,null,f)}function li(u,f,L){return new Mt(Mt.buildMessage(u,f),u,f,L)}function ni(){var u,f,L,x,P;return u=c,t.charCodeAt(c)===61?(f=a,c++):(f=i,E===0&&I(Et)),f!==i?(L=z(),x=Su(),x!==i?(P=z(),q=u,u=Jd(x)):(c=u,u=i)):(c=u,u=i),u}function Su(){var u,f;return u=c,f=jt(),f!==i&&(q=u,f=Qd(f)),u=f,u}function z(){var u,f;for(u=[],f=di();f!==i;)u.push(f),f=di();return u}function di(){var u;return u=t.charAt(c),ht.test(u)?c++:(u=i,E===0&&I(St)),u}function Vu(){var u;return u=t.substr(c,5),u.toLowerCase()===h?c+=5:(u=i,E===0&&I(Vt)),u}function Cu(){var u;return u=t.substr(c,4),u.toLowerCase()===l?c+=4:(u=i,E===0&&I(ft)),u}function Au(){var u;return u=t.substr(c,2),u.toLowerCase()===d?c+=2:(u=i,E===0&&I(ut)),u}function _u(){var u;return u=t.charAt(c),u.toLowerCase()===n?c++:(u=i,E===0&&I(ot)),u}function Lu(){var u,f;return u=c,f=Pu(),f!==i&&(q=u,f=tu(f)),u=f,u}function Pu(){var u,f,L,x;if(E++,u=c,f=ku(),f!==i){for(L=[],x=ui();x!==i;)L.push(x),x=ui();q=u,u=eu(f,L)}else c=u,u=i;return E--,u===i&&(f=i,E===0&&I(pt)),u}function ku(){var u;return u=t.charAt(c),tt.test(u)?c++:(u=i,E===0&&I(zt)),u}function ui(){var u;return u=t.charAt(c),lt.test(u)?c++:(u=i,E===0&&I(Ut)),u}function Mu(){var u;return u=Ru(),u===i&&(u=Eu(),u===i&&(u=Wu(),u===i&&(u=Iu(),u===i&&(u=Hu())))),u}function Ru(){var u,f;return E++,u=c,f=Cu(),f!==i&&(q=u,f=iu()),u=f,u===i&&(u=c,f=Vu(),f!==i&&(q=u,f=ru()),u=f),E--,u===i&&(f=i,E===0&&I(qt)),u}function Eu(){var u,f;return E++,u=c,f=Au(),f!==i&&(q=u,f=su()),u=f,u===i&&(u=c,f=_u(),f!==i&&(q=u,f=ou()),u=f),E--,u===i&&(f=i,E===0&&I(Yt)),u}function Wu(){var u,f,L,x,P;if(E++,u=c,f=pi(),f!==i)if(t.charCodeAt(c)===46?(L=p,c++):(L=i,E===0&&I(Ue)),L!==i){for(x=[],P=Bt();P!==i;)x.push(P),P=Bt();q=u,u=au()}else c=u,u=i;else c=u,u=i;if(u===i){if(u=c,t.charCodeAt(c)===46?(f=p,c++):(f=i,E===0&&I(Ue)),f!==i){if(L=[],x=Bt(),x!==i)for(;x!==i;)L.push(x),x=Bt();else L=i;L!==i?(q=u,u=hu()):(c=u,u=i)}else c=u,u=i;u===i&&(u=c,f=pi(),f!==i&&(q=u,f=lu()),u=f)}return E--,u===i&&(f=i,E===0&&I(qd)),u}function pi(){var u,f,L,x;if(t.charCodeAt(c)===48?(u=g,c++):(u=i,E===0&&I(Yd)),u===i)if(u=c,f=Bu(),f!==i){for(L=[],x=Bt();x!==i;)L.push(x),x=Bt();f=[f,L],u=f}else c=u,u=i;return u}function Bt(){var u;return u=t.charAt(c),st.test(u)?c++:(u=i,E===0&&I(Xd)),u}function Bu(){var u;return u=t.charAt(c),Rt.test(u)?c++:(u=i,E===0&&I(Kd)),u}function Iu(){var u,f,L,x;if(E++,u=c,t.charCodeAt(c)===34?(f=v,c++):(f=i,E===0&&I(qe)),f!==i){for(L=[],x=t.charAt(c),Gt.test(x)?c++:(x=i,E===0&&I(Ye));x!==i;)L.push(x),x=t.charAt(c),Gt.test(x)?c++:(x=i,E===0&&I(Ye));t.charCodeAt(c)===34?(x=v,c++):(x=i,E===0&&I(qe)),x!==i?(q=u,u=nu(L)):(c=u,u=i)}else c=u,u=i;return E--,u===i&&(f=i,E===0&&I(jd)),u}function Hu(){var u,f,L,x;if(E++,u=c,t.charCodeAt(c)===39?(f=w,c++):(f=i,E===0&&I(Xe)),f!==i){for(L=[],x=t.charAt(c),et.test(x)?c++:(x=i,E===0&&I(Ke));x!==i;)L.push(x),x=t.charAt(c),et.test(x)?c++:(x=i,E===0&&I(Ke));t.charCodeAt(c)===39?(x=w,c++):(x=i,E===0&&I(Xe)),x!==i?(q=u,u=du(L)):(c=u,u=i)}else c=u,u=i;return E--,u===i&&(f=i,E===0&&I(Zd)),u}function Du(){var u,f,L,x,P,V;return u=Mu(),u===i&&(u=c,t.charCodeAt(c)===40?(f=T,c++):(f=i,E===0&&I(je)),f!==i?(L=z(),x=jt(),x!==i?(P=z(),t.charCodeAt(c)===41?(V=B,c++):(V=i,E===0&&I(Ze)),V!==i?(q=u,u=uu(x)):(c=u,u=i)):(c=u,u=i)):(c=u,u=i)),u}function ci(){var u,f,L,x,P;return u=Du(),u===i&&(u=c,f=Nu(),f!==i?(L=z(),x=ci(),x!==i?(P=z(),q=u,u=pu(f,x)):(c=u,u=i)):(c=u,u=i)),u}function Nu(){var u;return u=t.charAt(c),nt.test(u)?c++:(u=i,E===0&&I(pe)),u}function ge(){var u,f,L,x;return u=c,f=Lu(),f!==i?(L=z(),x=Fu(),x!==i?(q=u,u=cu(f,x)):(c=u,u=i)):(c=u,u=i),u===i&&(u=ci()),u}function Fu(){var u,f,L,x,P,V;return u=c,t.charCodeAt(c)===40?(f=T,c++):(f=i,E===0&&I(je)),f!==i?(L=z(),x=c,P=$u(),P!==i?(V=z(),P=[P,V],x=P):(c=x,x=i),x===i&&(x=null),t.charCodeAt(c)===41?(P=B,c++):(P=i,E===0&&I(Ze)),P!==i?(q=u,u=gu(x)):(c=u,u=i)):(c=u,u=i),u}function $u(){var u,f,L,x,P,V,Y,F;if(u=c,f=jt(),f!==i){for(L=[],x=c,P=z(),t.charCodeAt(c)===44?(V=M,c++):(V=i,E===0&&I(Je)),V!==i?(Y=z(),F=jt(),F!==i?(P=[P,V,Y,F],x=P):(c=x,x=i)):(c=x,x=i);x!==i;)L.push(x),x=c,P=z(),t.charCodeAt(c)===44?(V=M,c++):(V=i,E===0&&I(Je)),V!==i?(Y=z(),F=jt(),F!==i?(P=[P,V,Y,F],x=P):(c=x,x=i)):(c=x,x=i);q=u,u=mu(f,L)}else c=u,u=i;return u}function me(){var u,f,L,x,P,V,Y,F;if(u=c,f=ge(),f!==i){for(L=[],x=c,P=z(),V=t.charAt(c),gt.test(V)?c++:(V=i,E===0&&I(Qe)),V!==i?(Y=z(),F=ge(),F!==i?(P=[P,V,Y,F],x=P):(c=x,x=i)):(c=x,x=i);x!==i;)L.push(x),x=c,P=z(),V=t.charAt(c),gt.test(V)?c++:(V=i,E===0&&I(Qe)),V!==i?(Y=z(),F=ge(),F!==i?(P=[P,V,Y,F],x=P):(c=x,x=i)):(c=x,x=i);q=u,u=fu(f,L)}else c=u,u=i;return u}function fe(){var u,f,L,x,P,V,Y,F;if(u=c,f=me(),f!==i){for(L=[],x=c,P=z(),V=t.charAt(c),nt.test(V)?c++:(V=i,E===0&&I(pe)),V!==i?(Y=z(),F=me(),F!==i?(P=[P,V,Y,F],x=P):(c=x,x=i)):(c=x,x=i);x!==i;)L.push(x),x=c,P=z(),V=t.charAt(c),nt.test(V)?c++:(V=i,E===0&&I(pe)),V!==i?(Y=z(),F=me(),F!==i?(P=[P,V,Y,F],x=P):(c=x,x=i)):(c=x,x=i);q=u,u=xu(f,L)}else c=u,u=i;return u}function xe(){var u,f,L,x,P,V,Y,F;if(u=c,f=fe(),f!==i){for(L=[],x=c,P=z(),t.substr(c,2)===k?(V=k,c+=2):(V=i,E===0&&I(ti)),V===i&&(t.substr(c,2)===W?(V=W,c+=2):(V=i,E===0&&I(ei)),V===i&&(V=t.charAt(c),mt.test(V)?c++:(V=i,E===0&&I(ii)))),V!==i?(Y=z(),F=fe(),F!==i?(P=[P,V,Y,F],x=P):(c=x,x=i)):(c=x,x=i);x!==i;)L.push(x),x=c,P=z(),t.substr(c,2)===k?(V=k,c+=2):(V=i,E===0&&I(ti)),V===i&&(t.substr(c,2)===W?(V=W,c+=2):(V=i,E===0&&I(ei)),V===i&&(V=t.charAt(c),mt.test(V)?c++:(V=i,E===0&&I(ii)))),V!==i?(Y=z(),F=fe(),F!==i?(P=[P,V,Y,F],x=P):(c=x,x=i)):(c=x,x=i);q=u,u=wu(f,L)}else c=u,u=i;return u}function we(){var u,f,L,x,P,V,Y,F;if(u=c,f=xe(),f!==i){for(L=[],x=c,P=z(),t.substr(c,2)===D?(V=D,c+=2):(V=i,E===0&&I(ri)),V===i&&(t.substr(c,2)===N?(V=N,c+=2):(V=i,E===0&&I(si))),V!==i?(Y=z(),F=xe(),F!==i?(P=[P,V,Y,F],x=P):(c=x,x=i)):(c=x,x=i);x!==i;)L.push(x),x=c,P=z(),t.substr(c,2)===D?(V=D,c+=2):(V=i,E===0&&I(ri)),V===i&&(t.substr(c,2)===N?(V=N,c+=2):(V=i,E===0&&I(si))),V!==i?(Y=z(),F=xe(),F!==i?(P=[P,V,Y,F],x=P):(c=x,x=i)):(c=x,x=i);q=u,u=yu(f,L)}else c=u,u=i;return u}function jt(){var u,f,L,x,P,V,Y,F;if(u=c,f=we(),f!==i){for(L=[],x=c,P=z(),t.substr(c,2)===K?(V=K,c+=2):(V=i,E===0&&I(oi)),V===i&&(t.substr(c,2)===J?(V=J,c+=2):(V=i,E===0&&I(ai))),V!==i?(Y=z(),F=we(),F!==i?(P=[P,V,Y,F],x=P):(c=x,x=i)):(c=x,x=i);x!==i;)L.push(x),x=c,P=z(),t.substr(c,2)===K?(V=K,c+=2):(V=i,E===0&&I(oi)),V===i&&(t.substr(c,2)===J?(V=J,c+=2):(V=i,E===0&&I(ai))),V!==i?(Y=z(),F=we(),F!==i?(P=[P,V,Y,F],x=P):(c=x,x=i)):(c=x,x=i);q=u,u=vu(f,L)}else c=u,u=i;return u}function Ou(u,f){return u.map(function(L){return L[f]})}function Gu(u,f){return u?u[f]:null}function zu(u,f,L){return[u].concat(Ou(f,L))}function ee(u,f){return f.reduce(function(L,x){return{type:"BinaryExpression",operator:x[1],left:L,right:x[3]}},u)}function Uu(u,f){return f.reduce(function(L,x){return{type:"LogicalExpression",operator:x[1],left:L,right:x[3]}},u)}function qu(u){return u!==null?u:[]}if(Xt=o(),e.peg$library)return{peg$result:Xt,peg$currPos:c,peg$FAILED:i,peg$maxFailExpected:te,peg$maxFailPos:at};if(Xt!==i&&c===t.length)return Xt;throw Xt!==i&&c{this.compiledFormula.updateDataSource(i,{value:t.pvEngine.getValue(i),acquisitionStatus:"good"}),this.trigger()})}this.trigger()}compiledFormula;trigger(){let t=this.compiledFormula.execute();this.pv.pvEngine.setValue(new Date,this.pv.name,t)}};function Od(t){return!isNaN(t)&&(Number.isInteger(parseFloat(t))||t%1!==0)}function Ar(t){return Od(t)?parseFloat(t):(console.warn(`Not a valid float: ${t}`),t)}function _r(t){return t!=null?String(t):t}var qp=class extends Hd{constructor(t,e,i,r){super(t,e),this.type=i,this.initializer=r,this.writable=!0}setSample(t){if(this.type==="VDouble")t.value=Ar(t.value);else if(this.type==="VDoubleArray")for(let e=0;e)?(\((.*)\))?/;function It(t){if(!t.startsWith("loc://"))return t;let e=t.match(Gd);return e?e[1]:t}var Yp=class{constructor(t){this.display=t}rules=[];scripts=[];pvs=new Map;providers=[];scriptLibraries={};listeners=new Map;init(){for(let t of this.listeners.entries()){let e=this.pvs.get(t[0]);if(e&&e.value!==null&&e.value!==void 0)for(let i of t[1])i()}}clearState(){this.disconnectAll(),this.rules=[],this.scripts=[],this.listeners.clear()}getPVNames(){return[...this.pvs.keys()]}hasPV(t){let e=It(t);return this.pvs.has(e)}getPV(t){let e=It(t);return this.pvs.get(e)}disconnectAll(){for(let t of this.providers){let e=[];for(let i of this.pvs.values())t.canProvide(i.name)&&e.push(i);e.length&&t.stopProviding(e)}this.pvs.clear()}createPV(t){if(t.startsWith("loc://"))return this.createLocalPV(t);let e=this.pvs.get(t);if(e)return e;e=new Hd(t,this),this.pvs.set(t,e);let i=this.findProvider(t);return i?(e.provider=i,i.startProviding([e]),e):(console.warn(`No provider for PV ${t}`),e.disconnected=!0,e)}createHistoricalDataProvider(t,e){let i=this.findProvider(t);if(i?.createHistoricalDataProvider)return i.createHistoricalDataProvider(t,e)}findProvider(t){for(let e of this.providers)if(e.canProvide(t))return e;return null}requestRepaint(){this.display.requestRepaint()}createLocalPV(t){let e=t.match(Gd),i,r;if(e){if(t=e[1],e[3])switch(e[3]){case"VDouble":case"VDoubleArray":case"VString":case"VStringArray":i=e[3];break;default:console.warn(`Unknown local PV type information: ${e[3]}`)}if(e[5]!==void 0){let a=e[5];a.startsWith('"')&&a.endsWith('"')?r=a.substring(1,a.length-1):a.indexOf(",")!==-1?r=a.split(",").map(h=>{let l=h.trim();return l.startsWith('"')&&l.endsWith('"')?l.substring(1,l.length-1):Number(l)}):r=Number(a)}}let s=this.pvs.get(t),o=!1;if(s){let a=s;a.type&&i&&a.type!==i&&console.warn(`PV ${t} is defined with different types: ${a.type} !== ${i}`),a.initializer!==void 0&&r!==void 0&&!this.initializerEquals(a.initializer,r)?console.warn(`PV ${t} is defined with different initializers: ${a.initializer} !== ${r}`):a.initializer===void 0&&r!==void 0&&(o=!0)}return s?i&&!s.type&&(s.type=i):(s=new qp(t,this,i,r),this.pvs.set(t,s),o=!0),o&&r!==void 0&&this.setValue(new Date,t,r),s}initializerEquals(t,e){if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let i=0;i{if(e.checkConnect)for(let d=0;dr.scriptEngine.run();for(let o of e.inputs)if(o.trigger){let a=t.expandMacro(o.pvName);this.addListener(a,s,!1)}}addProvider(t){this.providers.push(t)}addScriptLibrary(t,e){this.scriptLibraries[t]=e}addListener(t,e,i=!0){let r=It(t),s=this.listeners.get(r);if(s?s.push(e):this.listeners.set(r,[e]),i){let o=this.pvs.get(r);o&&o.value!==null&&o.value!==void 0&&e()}}removeListener(t,e){let i=It(t),r=this.listeners.get(i);if(r){let s=r.indexOf(e);s!==-1&&r.splice(s,1)}}},Xp=class{constructor(t,e,i,r){this.widget=t,this.script=e,this.text=i,this.pvs=r,this.scriptEngine=new he(t,i,r)}scriptEngine},Kp=class{constructor(t,e,i){this.widget=t,this.rule=e;let r="",s=t.properties.getProperty(e.propertyName);if(!s)throw new Error(`Cannot create rule for unsupported property ${e.propertyName}`);if(e.expressions.length){let o=!1,a=!1,h=!1,l=!1;for(let p of e.expressions)p.expression.match(/pv[0-9]+/)&&(o=!0),e.outputExpression&&p.outputValue.toString().match(/pv[0-9]+/)&&(o=!0),p.expression.indexOf("pvInt")!==-1&&(a=!0),e.outputExpression&&p.outputValue.toString().indexOf("pvInt")!==-1&&(a=!0),p.expression.indexOf("pvStr")!==-1&&(h=!0),e.outputExpression&&p.outputValue.toString().indexOf("pvStr")!==-1&&(h=!0),p.expression.indexOf("pvSev")!==-1&&(l=!0),e.outputExpression&&p.outputValue.toString().indexOf("pvSev")!==-1&&(l=!0);for(let p=0;p0&&(r+="else "),r+=`if (${g}) widget.setPropertyValue("${e.propertyName}", `,e.outputExpression)r+=`${v});
`;else{let w=this.printScriptValue(s,v);r+=`${w});
`}}let d=s.value,n=this.printScriptValue(s,d);r+=`else widget.setPropertyValue("${e.propertyName}", `,r+=`${n});
`}this.scriptEngine=new he(t,r,i)}scriptEngine;printScriptValue(t,e){return e==null?"null":t.printScriptValue(e)}},Ot=class{constructor(t,e,i){this.pv=t,this.interval=e,i!==void 0&&t.pvEngine.setValue(new Date,t.name,i),this.interval>0&&(this.timer=window.setInterval(()=>{this.generateSample(new Date)},e))}timer;emit(t,e){let i="NONE";this.pv.lowerAlarmLimit!==void 0&&ethis.pv.upperAlarmLimit?i="MAJOR":(this.pv.lowerWarningLimit!==void 0&&ethis.pv.upperWarningLimit)&&(i="MINOR"),this.pv.pvEngine.setValue(t,this.pv.name,e,i)}stop(){window.clearInterval(this.timer)}},Lt=class extends Ot{constructor(t,e){super(t,-1,e)}generateSample(){}},jp=class extends Ot{constructor(t,e){super(t,1e3),this.formatter=e}generateSample(t){let e=this.formatter.formatDate(t,{year:!0,month:!0,day:!0})+" "+this.formatter.formatTime(t,{hours:!0,minutes:!0,seconds:!0,milliseconds:!0});this.emit(t,e)}},Lr=class extends Ot{constructor(t,e,i,r){super(t,r),this.min=e,this.max=i;let s=this.max-this.min;t.units="x",t.lowerDisplayLimit=e,t.lowerAlarmLimit=e+s*.1,t.lowerWarningLimit=e+s*.2,t.upperWarningLimit=e+s*.8,t.upperAlarmLimit=e+s*.9,t.upperDisplayLimit=i}generateSample(t){let e=Math.random()*(this.max-this.min)+this.min;this.emit(t,e)}},Pr=class extends Ot{constructor(t,e,i,r){super(t,r),this.avg=e,this.stddev=i,t.units="x",t.lowerDisplayLimit=e-4*i,t.lowerAlarmLimit=e-2*i,t.lowerWarningLimit=e-i,t.upperWarningLimit=e+i,t.upperAlarmLimit=e+2*i,t.upperDisplayLimit=e+4*i}generateSample(t){let e,i,r;do e=2*Math.random()-1,i=2*Math.random()-1,r=e*e+i*i;while(r>=1||r===0);let s=Math.sqrt(-2*Math.log(r)/r),o=e*s;this.emit(t,this.avg+o*this.stddev)}},Le=class extends Ot{constructor(t,e,i,r,s){super(t,s),this.min=e,this.max=i,this.samplesPerCycle=r;let o=this.max-this.min;t.units="x",t.lowerDisplayLimit=e,t.lowerAlarmLimit=e+o*.1,t.lowerWarningLimit=e+o*.2,t.upperWarningLimit=e+o*.8,t.upperAlarmLimit=e+o*.9,t.upperDisplayLimit=i}currentValue=0;generateSample(t){let e=this.max-this.min,i=Math.sin(this.currentValue*2*Math.PI/this.samplesPerCycle)*e/2+this.min+e/2;this.currentValue++,this.emit(t,i)}},Pe=class extends Ot{constructor(t,e,i,r,s){super(t,s),this.min=e,this.max=i,this.inc=r,r>=0?this.currentValue=e-r:this.currentValue=i-r;let o=this.max-this.min;t.units="x",t.lowerDisplayLimit=e,t.lowerAlarmLimit=e+o*.1,t.lowerWarningLimit=e+o*.2,t.upperWarningLimit=e+o*.8,t.upperAlarmLimit=e+o*.9,t.upperDisplayLimit=i}currentValue=0;generateSample(t){this.currentValue=this.currentValue+this.inc,this.currentValue>this.max&&(this.currentValue=this.min),this.currentValue{this.imageLoaded=!0,this.requestRepaint()},this.imageElement.src=this.resolvePath(this.image)),this.areaRegion={id:`${this.wuid}-area`,mouseDown:()=>{this.enabled&&!this.toggleButton&&(this.pushed=!0,this.requestRepaint())},mouseOut:()=>{this.enabled&&(this.pushed=!1),this.requestRepaint()},mouseUp:()=>{this.enabled&&!this.toggleButton&&(this.pushed=!1,this.requestRepaint())},click:()=>{this.enabled&&(this.executeActionByIndex(this.pushed?this.releaseActionIndex:this.pushActionIndex),this.toggleButton&&(this.pushed=!this.pushed))},tooltip:()=>this.tooltip,cursor:"pointer"}}draw(t){let e=t.ctx,{scale:i}=this;t.fillRect(A(C({},this.area),{color:this.backgroundColor})),t.addHitRegion(this.areaRegion).addRect(this.x,this.y,this.width,this.height);let r=1*i,s=this.holderY+r/2,o=this.holderX+r/2,a=this.holderY+this.holderHeight-r+r/2,h=this.holderX+this.holderWidth-r+r/2;t.strokePath({lineWidth:r,color:this.pushed?m.BUTTON_LIGHTEST:m.BLACK,path:new S(h,a).lineTo(h,s).moveTo(h,a).lineTo(o,a)}),t.strokePath({lineWidth:r,color:this.pushed?this.backgroundColor:m.BUTTON_DARKER,path:new S(h-r,a-r).lineTo(h-r,s+r).moveTo(h-r,a-r).lineTo(o+r,a-r)}),t.strokePath({lineWidth:r,color:this.pushed?m.BLACK:m.BUTTON_LIGHTEST,path:new S(o,s).lineTo(h-r,s).moveTo(o,s).lineTo(o,a-r)}),t.strokePath({lineWidth:r,color:this.pushed?m.BUTTON_DARKER:this.backgroundColor,path:new S(o+r,s+r).lineTo(h-r-r,s+r).moveTo(o+r,s+r).lineTo(o+r,a-r-r)});let l=this.text.split(`
`);e.fillStyle=this.foregroundColor.toString(),e.font=this.font.getFontString();let d,n;if(this.imageElement&&this.imageLoaded){let p=e.measureText(l[0]).width,g=this.font.height,v=this.imageElement.naturalHeight*i,w=this.imageElement.naturalWidth*i,T=(this.height-v)/g,B=(this.width-w)/p,M=5*i;if(B>T){e.textBaseline="middle",e.textAlign="left",d=this.x+(this.width-p)/2+M,n=this.y+this.height/2;let k=this.x+(this.width-p)/2-w,W=this.y+(this.height-v)/2;e.drawImage(this.imageElement,k,W,w,v)}else{e.textAlign="center",e.textBaseline="top";let k=g+v;d=this.x+this.width/2,n=this.y+(this.height-k)/2+v;let W=this.x+(this.width-w)/2,D=this.y+(this.height-k)/2;e.drawImage(this.imageElement,W,D,w,v)}this.pushed&&(d+=1*i,n+=1*i),this.enabled?(e.fillStyle=this.foregroundColor.toString(),e.fillText(l[0],d,n)):(e.fillStyle=m.BUTTON_LIGHTEST.toString(),e.fillText(l[0],d+1*i,n+1*i),e.fillStyle=m.BUTTON_DARKER.toString(),e.fillText(l[0],d,n))}else{e.textAlign="start",e.textBaseline="top";let p=0;for(let v of l){let w=e.measureText(v).width;p=Math.max(p,w)}d=this.x+(this.width-p)/2;let g=l.length*this.font.height+(l.length-1)*this.font.height*.2;n=this.y+(this.height-g)/2;for(let v of l){let w=d,T=n;this.pushed&&(w+=1*i,T+=1*i),this.enabled?(e.fillStyle=this.foregroundColor.toString(),e.fillText(v,w,T)):(e.fillStyle=m.BUTTON_LIGHTEST.toString(),e.fillText(v,w+1*i,T+1*i),e.fillStyle=m.BUTTON_DARKER.toString(),e.fillText(v,w,T)),n+=this.font.height*1.2}}}getHookedActions(){let{actions:t}=this;if(t.hookAllActionsToClick)return t.actions;if(this.pushed){let e=this.releaseActionIndex;return[t.getAction(e)]}else{let e=this.pushActionIndex;return[t.getAction(e)]}}get font(){return this.properties.getValue(kr).scale(this.scale)}get image(){return this.properties.getValue(Wr)}get toggleButton(){return this.properties.getValue(Er)}get pushActionIndex(){return this.properties.getValue(Mr)}get releaseActionIndex(){return this.properties.getValue(Rr)}get backgroundColor(){let t=this.properties.getProperty("background_color");return t&&t.value!==m.TRANSPARENT?t.value:m.BUTTON}},Br="bit",Ir="data_type",Hr="effect_3d",Dr="font",Nr="off_color",Fr="off_label",$r="off_state",Or="on_color",Gr="on_label",zr="on_state",Ur="push_action_index",qr="released_action_index",Yr="show_led",Xr="show_boolean_label",Kr="square_button",jr="toggle_button",rc=class extends G{hovered=!1;manualToggleState=!1;areaRegion;constructor(t,e){super(t,e),this.properties.add(new b(Br)),this.properties.add(new b(Ir)),this.properties.add(new y(Kr)),this.properties.add(new y(Yr)),this.properties.add(new y(Hr)),this.properties.add(new R(Or)),this.properties.add(new _(Gr)),this.properties.add(new _(zr)),this.properties.add(new R(Nr)),this.properties.add(new _(Fr)),this.properties.add(new _($r)),this.properties.add(new O(Dr)),this.properties.add(new y(jr)),this.properties.add(new b(Ur)),this.properties.add(new b(qr)),this.properties.add(new y(Xr))}init(){this.areaRegion={id:`${this.wuid}-area`,mouseDown:()=>{this.toggleButton?this.booleanValue?this.toggleOff():this.toggleOn():this.toggleOn(),this.requestRepaint()},mouseEnter:()=>{this.hovered=!0,this.requestRepaint()},mouseUp:()=>{this.booleanValue&&!this.toggleButton&&(this.toggleOff(),this.requestRepaint())},mouseOut:()=>{this.booleanValue&&!this.toggleButton&&this.toggleOff(),this.hovered=!1,this.requestRepaint()},tooltip:()=>this.tooltip,cursor:"pointer"}}toggleOn(){if(this.manualToggleState=!0,this.pv&&this.pv.writable)if(this.dataType===0)if(this.bit<0)this.display.pvEngine.setValue(new Date,this.pv.name,1);else{let t=this.pv.value|1<>this.bit&1)>0:this.dataType===1?this.pv.toString()===this.onState:!1:this.manualToggleState}draw(t){let e=this.booleanValue;this.squareButton?this.drawSquare(t,e):this.drawEllipse(t,e),this.width>this.height?this.drawHorizontal(t,e):this.drawVertical(t,e),this.showBooleanLabel&&t.fillText({x:this.x+this.width/2,y:this.y+this.height/2,font:this.font,color:this.foregroundColor,align:"center",baseline:"middle",text:e?this.onLabel:this.offLabel})}drawSquare(t,e){t.fillRect({x:this.x,y:this.y,width:this.width,height:this.height,color:m.DARK_GRAY}),t.addHitRegion(this.areaRegion).addRect(this.x,this.y,this.width,this.height);let i=2*this.scale,r=e?m.DARK_GRAY:m.WHITE,s=e?m.WHITE:m.DARK_GRAY;this.effect3d&&(t.fillPath({color:r,path:new S(this.x,this.y).lineTo(this.x,this.y+this.height).lineTo(this.x+i,this.y+this.height-i).lineTo(this.x+i,this.y+i).lineTo(this.x+this.width-i,this.y+i).lineTo(this.x+this.width,this.y).closePath()}),t.fillPath({color:s,path:new S(this.x,this.y+this.height).lineTo(this.x+this.width,this.y+this.height).lineTo(this.x+this.width,this.y).lineTo(this.x+this.width-i,this.y+i).lineTo(this.x+this.width-i,this.y+this.height-i).lineTo(this.x+i,this.y+this.height-i).closePath()}));let o=this.backgroundColor;this.hovered&&(o=this.backgroundColor.mixWith(m.WHITE,.5)),t.fillRect({x:this.x+i,y:this.y+i,width:this.width-i-i,height:this.height-i-i,color:o})}drawEllipse(t,e){let{scale:i}=this;if(this.effect3d){let h=this.width/2,l=this.height/2,d=Math.sqrt(h*h+l*l),n=this.x+h+(l-h-d)/2-1*i,p=this.y+l-(l-h+d)/2-1*i,g=this.x+h+(l-h+d)/2+5*i,v=this.y+l-(l-h-d)/2+5*i,w=t.createLinearGradient(n,p,g,v);e?(w.addColorStop(0,m.DARK_GRAY.toString()),w.addColorStop(1,m.WHITE.toString())):(w.addColorStop(0,m.WHITE.toString()),w.addColorStop(1,m.DARK_GRAY.toString())),t.ctx.fillStyle=w}else e?t.ctx.fillStyle=m.WHITE.toString():t.ctx.fillStyle=m.DARK_GRAY.toString();let r=this.x+this.width/2,s=this.y+this.height/2,o=this.width/2,a=this.height/2;t.ctx.beginPath(),t.ctx.ellipse(r,s,o,a,0,0,2*Math.PI),t.ctx.fill(),t.addHitRegion(this.areaRegion).addEllipse(r,s,o,a,0,0,2*Math.PI),this.hovered?t.ctx.fillStyle=this.backgroundColor.mixWith(m.WHITE,.5).toString():t.ctx.fillStyle=this.backgroundColor.toString(),t.ctx.beginPath(),t.ctx.ellipse(r,s,o-i*2,a-i*2,0,0,2*Math.PI),t.ctx.fill()}drawHorizontal(t,e){let{scale:i}=this;if(this.showLed){let r;this.squareButton?(r=Math.floor(.3*(this.width+this.height)/2),r>Math.min(this.width,this.height)&&(r=Math.min(this.width,this.height)-2*i)):(r=Math.floor(.25*(this.width+this.height)/2),r>Math.min(this.width,this.height)&&(r=Math.min(this.width,this.height)-8*i));let s={x:Math.floor(this.x+this.width*.79999-r/2),y:Math.floor(this.y+this.height/2-r/2),width:r,height:r},o=s.x+s.width/2,a=s.y+s.height/2,h=s.width/2,l=s.height/2,d=e?this.onColor:this.offColor;if(t.fillEllipse({cx:o,cy:a,rx:h,ry:l,color:d}),this.effect3d){let n=t.createLinearGradient(s.x,s.y,s.x+s.width,s.y+s.height);n.addColorStop(0,"white"),n.addColorStop(1,d.withAlpha(0).toString()),t.ctx.beginPath(),t.ctx.ellipse(o,a,h,l,0,0,2*Math.PI),t.ctx.fillStyle=n,t.ctx.fill()}}}drawVertical(t,e){let{scale:i}=this;if(this.showLed){let r;this.squareButton?(r=Math.floor(.3*(this.width+this.height)/2),r>Math.min(this.width,this.height)&&(r=Math.min(this.width,this.height)-2*i)):(r=Math.floor(.25*(this.width+this.height)/2),r>Math.min(this.width,this.height)&&(r=Math.min(this.width,this.height)-8*i));let s={x:Math.floor(this.x+this.width/2-r/2),y:Math.floor(this.y+(1-.79999)*this.height-r/2),width:r,height:r},o=e?this.onColor:this.offColor,a=s.x+s.width/2,h=s.y+s.height/2,l=s.width/2,d=s.height/2;if(t.fillEllipse({cx:a,cy:h,rx:l,ry:d,color:o}),this.effect3d){let n=t.createLinearGradient(s.x,s.y,s.x+s.width,s.y+s.height);n.addColorStop(0,m.WHITE.toString()),n.addColorStop(1,o.withAlpha(0).toString()),t.ctx.beginPath(),t.ctx.ellipse(a,h,l,d,0,0,2*Math.PI),t.ctx.fillStyle=n,t.ctx.fill()}}}get bit(){return this.properties.getValue(Br)}get dataType(){return this.properties.getValue(Ir)}get toggleButton(){return this.properties.getValue(jr)}get pushActionIndex(){return this.properties.getValue(Ur)}get releaseActionIndex(){return this.properties.getValue(qr)}get squareButton(){return this.properties.getValue(Kr)}get showLed(){return this.properties.getValue(Yr)}get showBooleanLabel(){return this.properties.getValue(Xr)}get effect3d(){return this.properties.getValue(Hr)}get onColor(){return this.properties.getValue(Or)}get onLabel(){return this.properties.getValue(Gr)}get onState(){return this.properties.getValue(zr)}get offColor(){return this.properties.getValue(Nr)}get offLabel(){return this.properties.getValue(Fr)}get offState(){return this.properties.getValue($r)}get font(){return this.properties.getValue(Dr).scale(this.scale)}},Zr="bit",Jr="data_type",Qr="effect_3d",ts="off_color",es="off_label",is="off_state",rs="on_color",ss="on_label",os="on_state",as="push_action_index",hs="released_action_index",ls="toggle_button",sc=class extends G{manualToggleState=!1;shaftRegion;constructor(t,e){super(t,e),this.properties.add(new b(Zr)),this.properties.add(new b(Jr)),this.properties.add(new y(Qr)),this.properties.add(new R(rs)),this.properties.add(new _(ss)),this.properties.add(new _(os)),this.properties.add(new R(ts)),this.properties.add(new _(es)),this.properties.add(new _(is)),this.properties.add(new b(as)),this.properties.add(new b(hs)),this.properties.add(new y(ls))}init(){this.shaftRegion={id:`${this.wuid}-shaft`,mouseDown:()=>{this.toggleButton?this.booleanValue?this.toggleOff():this.toggleOn():this.toggleOn(),this.requestRepaint()},mouseUp:()=>{this.booleanValue&&!this.toggleButton&&(this.toggleOff(),this.requestRepaint())},mouseOut:()=>{this.booleanValue&&!this.toggleButton&&(this.toggleOff(),this.requestRepaint())},tooltip:()=>this.tooltip,cursor:"pointer"}}toggleOn(){if(this.manualToggleState=!0,this.pv&&this.pv.writable)if(this.dataType===0)if(this.bit<0)this.display.pvEngine.setValue(new Date,this.pv.name,1);else{let t=this.pv.value|1<>this.bit&1)>0:this.dataType===1?this.pv.toString()===this.onState:!1:this.manualToggleState}draw(t){let e=this.booleanValue;this.width>this.height?this.drawHorizontal(t,e):this.drawVertical(t,e)}drawHorizontal(t,e){let i=this.width,r=this.height;r>i/2?r=Math.floor(this.width/2):i=Math.floor(2*this.height);let s={x:Math.floor(63/218*i),y:0,width:r/2,height:r/2};this.drawPedestal(t,s,e);let o=Math.floor(35/218*i),a=Math.floor(45/105*r),h=Math.floor(43/218*i),l=Math.floor(35/105*r),d=Math.floor(1/7*s.width);if(e){let n={x:2*s.x+s.width-o,y:s.height/2-a/2,width:o,height:a},p={x:s.x+s.width/2-h/2+d,y:s.y+s.height/2-l/2,width:h,height:l};this.drawHorizontalBar(t,p,n,!0)}else{let n={x:0,y:s.height/2-a/2,width:o,height:a},p={x:s.x+s.width/2-h/2-d,y:s.y+s.height/2-l/2,width:h,height:l};this.drawHorizontalBar(t,p,n,!1)}}drawVertical(t,e){let i=this.width,r=this.height;i>r/2?i=Math.floor(this.height/2):r=Math.floor(2*this.width);let s={x:0,y:Math.floor(63/218*r),width:i/2,height:i/2};this.drawPedestal(t,s,e);let o=Math.floor(45/105*i),a=Math.floor(35/218*r),h=Math.floor(35/105*i),l=Math.floor(43/218*r);if(e){let d={x:s.width/2-o/2,y:0,width:o,height:a},n={x:s.x+s.width/2-h/2,y:s.y+s.height/2-l/2,width:h,height:l};n.y-=Math.floor(1/7*s.height),this.drawVerticalBar(t,n,d,!0)}else{let d=s.y+s.height/2+l/2+2*this.scale,n={x:s.width/2-o/2,y:s.y+s.height/2-l/2+d-a,width:o,height:a},p={x:s.x+s.width/2-h/2,y:s.y+s.height/2-l/2,width:h,height:l};p.y+=Math.floor(1/7*s.height),this.drawVerticalBar(t,p,n,!1)}}drawPedestal(t,e,i){let r=this.x+e.x+e.width/2,s=this.y+e.y+e.height/2,o=e.width/2,a=e.height/2;if(t.ctx.fillStyle=this.effect3d?m.WHITE.toString():m.GRAY.toString(),t.ctx.beginPath(),t.ctx.ellipse(r,s,o,a,0,0,2*Math.PI),t.ctx.fill(),this.effect3d){let h=t.createLinearGradient(this.x+e.x,this.y+e.y,this.x+e.x+e.width,this.y+e.y+e.height);i?(h.addColorStop(0,`rgba(255,255,255,${10/255})`),h.addColorStop(1,`rgba(0,0,0,${100/255})`)):(h.addColorStop(0,"rgba(0,0,0,0)"),h.addColorStop(1,`rgba(0,0,0,${150/255})`)),t.ctx.fillStyle=h,t.ctx.fill()}}drawHorizontalBar(t,e,i,r){let s=(r?0:10)/255,o=(r?150:220)/255,a=t.createLinearGradient(this.x+i.x,this.y+i.y,this.x+i.x,this.y+i.y+i.height);a.addColorStop(0,`rgba(0,0,0,${s})`),a.addColorStop(1,`rgba(0,0,0,${o})`);let h=t.addHitRegion(this.shaftRegion),l=this.x+e.x+e.width/2,d=this.y+e.y+e.height/2,n=e.width/2,p=e.height/2;t.ctx.beginPath(),t.ctx.ellipse(l,d,n,p,0,0,2*Math.PI),h.addEllipse(l,d,n,p,0,0,2*Math.PI),t.ctx.fillStyle=r?this.onColor.toString():this.offColor.toString(),t.ctx.fill(),this.effect3d&&(t.ctx.fillStyle=a,t.ctx.fill());let g=[Math.round(this.x+i.x+i.width/2),Math.round(this.y+i.y),Math.round(this.x+i.x+i.width/2),Math.round(this.y+i.y+i.height),Math.round(this.x+e.x+e.width/2),Math.round(this.y+e.y+e.height),Math.round(this.x+e.x+e.width/2),Math.round(this.y+e.y)];if(t.ctx.beginPath(),t.ctx.moveTo(g[0],g[1]),t.ctx.lineTo(g[2],g[3]),t.ctx.lineTo(g[4],g[5]),t.ctx.lineTo(g[6],g[7]),t.ctx.closePath(),h.addPath(new S(g[0],g[1]).lineTo(g[2],g[3]).lineTo(g[4],g[5]).lineTo(g[6],g[7]).closePath()),t.ctx.fillStyle=r?this.onColor.toString():this.offColor.toString(),t.ctx.fill(),this.effect3d&&(t.ctx.fillStyle=a,t.ctx.fill()),l=this.x+i.x+i.width/2,d=this.y+i.y+i.height/2,n=i.width/2,p=i.height/2,t.ctx.beginPath(),t.ctx.ellipse(l,d,n,p,0,0,2*Math.PI),h.addEllipse(l,d,n,p,0,0,2*Math.PI),t.ctx.fillStyle=r?this.onColor.toString():this.offColor.toString(),t.ctx.fill(),this.effect3d){let{scale:v}=this,w=Math.sqrt(n*n+p*p),T=p-n,B=this.x+i.x+n+(T-w)/2-1*v,M=this.x+i.y+p-(T+w)/2-1*v,k=this.x+i.x+n+(T+w)/2+5*v,W=this.x+i.y+p-(T-w)/2+5*v,D=t.createLinearGradient(B,M,k,W);D.addColorStop(0,`rgba(0,0,0,${s})`),D.addColorStop(1,`rgba(0,0,0,${o})`),t.ctx.fillStyle=D,t.ctx.fill()}}drawVerticalBar(t,e,i,r){let s=t.createLinearGradient(this.x+i.x,this.y+i.y,this.x+i.x+i.width,this.y+i.y);s.addColorStop(0,`rgba(0,0,0,${10/255})`),s.addColorStop(1,`rgba(0,0,0,${r?210/255:160/255})`);let o=t.addHitRegion(this.shaftRegion),a=this.x+e.x+e.width/2,h=this.y+e.y+e.height/2;t.ctx.beginPath(),t.ctx.ellipse(a,h,e.width/2,e.height/2,0,0,2*Math.PI),o.addEllipse(a,h,e.width/2,e.height/2,0,0,2*Math.PI),t.ctx.fillStyle=r?this.onColor.toString():this.offColor.toString(),t.ctx.fill(),this.effect3d&&(t.ctx.fillStyle=s,t.ctx.fill());let l=[Math.round(this.x+i.x),Math.round(this.y+i.y+i.height/2),Math.round(this.x+i.x+i.width),Math.round(this.y+i.y+i.height/2),Math.round(this.x+e.x+e.width),Math.round(this.y+e.y+e.height/2),Math.round(this.x+e.x),Math.round(this.y+e.y+e.height/2)];t.ctx.beginPath(),t.ctx.moveTo(l[0],l[1]),t.ctx.lineTo(l[2],l[3]),t.ctx.lineTo(l[4],l[5]),t.ctx.lineTo(l[6],l[7]),t.ctx.closePath(),o.addPath(new S(l[0],l[1]).lineTo(l[2],l[3]).lineTo(l[4],l[5]).lineTo(l[6],l[7]).closePath()),t.ctx.fillStyle=r?this.onColor.toString():this.offColor.toString(),t.ctx.fill(),this.effect3d&&(t.ctx.fillStyle=s,t.ctx.fill()),a=this.x+i.x+i.width/2,h=this.y+i.y+i.height/2;let d=i.width/2,n=i.height/2;if(t.ctx.beginPath(),t.ctx.ellipse(a,h,d,n,0,0,2*Math.PI),o.addEllipse(a,h,d,n,0,0,2*Math.PI),t.ctx.fillStyle=r?this.onColor.toString():this.offColor.toString(),t.ctx.fill(),this.effect3d){let p=t.createLinearGradient(this.x+i.x,this.y+i.y,this.x+i.width,this.y+i.height);p.addColorStop(0,`rgba(0,0,0,${(r?5:10)/255})`),p.addColorStop(1,`rgba(0,0,0,${(r?180:160)/255})`),t.ctx.fillStyle=p,t.ctx.fill()}}get bit(){return this.properties.getValue(Zr)}get dataType(){return this.properties.getValue(Jr)}get toggleButton(){return this.properties.getValue(ls)}get pushActionIndex(){return this.properties.getValue(as)}get releaseActionIndex(){return this.properties.getValue(hs)}get effect3d(){return this.properties.getValue(Qr)}get onColor(){return this.properties.getValue(rs)}get onLabel(){return this.properties.getValue(ss)}get onState(){return this.properties.getValue(os)}get offColor(){return this.properties.getValue(ts)}get offLabel(){return this.properties.getValue(es)}get offState(){return this.properties.getValue(is)}},ns="bit",ds="enabled",us="font",ps="label",cs="selected_color",oc=16,ac=new m(130,130,130),hc=new m(94,151,230),lc=4,nc=class extends G{hovered=!1;manualToggleState=!1;areaRegion;constructor(t,e){super(t,e),this.properties.add(new b(ns)),this.properties.add(new y(ds)),this.properties.add(new O(us)),this.properties.add(new _(ps)),this.properties.add(new R(cs,new m(64,64,64)))}init(){this.areaRegion={id:`${this.wuid}-area`,mouseDown:()=>{this.enabled&&(this.booleanValue?this.toggleOff():this.toggleOn(),this.requestRepaint())},mouseEnter:()=>{this.hovered=!0,this.requestRepaint()},mouseOut:()=>{this.hovered=!1,this.requestRepaint()},tooltip:()=>this.tooltip,cursor:"pointer"}}toggleOn(){if(this.manualToggleState=!0,this.pv&&this.pv.writable)if(this.bit<0)this.display.pvEngine.setValue(new Date,this.pv.name,1);else{let t=this.pv.value|1<>this.bit&1)>0:this.manualToggleState}draw(t){t.addHitRegion(this.areaRegion).addRect(this.x,this.y,this.width,this.height);let e=this.booleanValue,{boxSize:i,gap:r,scale:s}=this,o=this.backgroundColor;this.hovered&&(o=o.mixWith(hc,.7));let a={x:this.x,y:this.y+this.height/2-i/2,width:i,height:i},h=t.createLinearGradient(a.x,a.y+1*s,a.x,a.y+a.height);h.addColorStop(0,m.WHITE.toString()),h.addColorStop(1,o.toString()),t.fillRect(A(C({},a),{rx:2*s,ry:2*s,gradient:h})),t.strokeRect({x:a.x+.5*s,y:a.y+.5*s,width:a.width-1*s,height:a.height-1*s,rx:2*s,ry:2*s,color:ac}),e&&t.strokePath({lineWidth:3*s,color:this.selectedColor,path:new S(a.x+3*s,a.y+Math.floor(i*.45)).lineTo(a.x+Math.floor(i*.45),a.y+i*3/4-1*s).lineTo(a.x+i-2*s,a.y+3*s)}),this.enabled?t.fillText({x:a.x+a.width+r,y:a.y+a.height/2,align:"left",baseline:"middle",color:this.foregroundColor,font:this.font,text:this.label}):(t.fillText({x:a.x+a.width+r+1*s,y:a.y+a.height/2+1*s,align:"left",baseline:"middle",color:m.BUTTON_LIGHTEST,font:this.font,text:this.label}),t.fillText({x:a.x+a.width+r,y:a.y+a.height/2,align:"left",baseline:"middle",color:m.BUTTON_DARKER,font:this.font,text:this.label}))}get boxSize(){return this.scale*oc}get gap(){return this.scale*lc}get bit(){return this.properties.getValue(ns)}get enabled(){return this.properties.getValue(ds)}get selectedColor(){return this.properties.getValue(cs)}get font(){return this.properties.getValue(us).scale(this.scale)}get label(){return this.properties.getValue(ps)}},gs="enabled",ms="font",fs="horizontal",xs="items",ws="items_from_pv",ys="selected_color",dc=class extends G{pushedItem;itemRegions=[];constructor(t,e){super(t,e),this.properties.add(new y(gs)),this.properties.add(new O(ms)),this.properties.add(new y(fs)),this.properties.add(new de(xs,[])),this.properties.add(new y(ws)),this.properties.add(new R(ys))}init(){for(let t=0;t{this.pushedItem=t,this.requestRepaint()},mouseOut:()=>{this.pushedItem=void 0,this.requestRepaint()},mouseUp:()=>{this.pushedItem=void 0,this.requestRepaint()},click:()=>{this.writeValue(this.items[t]),this.requestRepaint()},tooltip:()=>this.tooltip})}draw(t){this.horizontal?this.drawHorizontal(t):this.drawVertical(t)}drawHorizontal(t){let e=this.area.width/this.items.length,i=this.area.x;for(let r=0;rthis.tooltip},this.selectEl=document.createElement("select"),this.selectEl.style.display="block",this.selectEl.style.position="absolute",this.selectEl.style.boxSizing="border-box",this.selectEl.style.opacity="0",this.selectEl.addEventListener("change",()=>{this.writeValue(this.selectEl?.value??""),this.requestRepaint()}),this.display.rootPanel.appendChild(this.selectEl)}draw(t){let e=this.display.measureAbsoluteArea(this);this.selectEl.style.display="block",this.selectEl.style.left=`${e.x}px`,this.selectEl.style.top=`${e.y}px`,this.selectEl.style.width=`${e.width}px`,this.selectEl.style.height=`${e.height}px`,this.updateSelectOptions(),e=U(this.bounds,2*this.scale),t.fillRect(A(C({},e),{color:this.backgroundColor})),t.strokeRect(A(C({},e),{color:pc,crispen:!0})),t.addHitRegion(this.areaRegion).addRect(e.x,e.y,e.width,e.height);let i=this.pv?.value??this.value;if(i){let a=this.itemsFromPV?this.pv?.labels??[]:this.items;for(let h of a){let l=h===i;if(!l)try{l=parseFloat(h)===i}catch{}l&&t.fillText({x:5*this.scale+e.x,y:e.y+e.height/2,align:"left",baseline:"middle",color:this.foregroundColor,font:this.font,text:i})}}let{selectorWidth:r}=this,s=Math.min(e.height,r/2),o={x:e.x+e.width-r-5*this.scale+r/2,y:e.y+(e.height-s)/2+s};t.fillPath({color:this.foregroundColor,path:new S(o.x,o.y).lineTo(o.x-s,o.y-s).lineTo(o.x+s,o.y-s).closePath()})}writeValue(t){this.pv?this.pv.writable&&this.display.pvEngine.setValue(new Date,this.pv.name,t):this.value=t}hide(){this.selectEl&&(this.selectEl.style.display="none")}updateSelectOptions(){let t=this.itemsFromPV?this.pv?.labels??[]:this.items,e=!1;if(this.renderedItems===void 0)e=!0;else if(t.length!==this.renderedItems.length)e=!0;else for(let i=0;i{this.onImageLoaded=!0,this.requestRepaint()},this.offImageElement=new Image,this.offImageElement.onload=()=>{this.offImageLoaded=!0,this.requestRepaint()},this.onImage&&(this.onImageElement.src=this.resolvePath(this.onImage)),this.offImage&&(this.offImageElement.src=this.resolvePath(this.offImage)),this.areaRegion={id:`${this.wuid}-area`,mouseDown:()=>{this.toggleButton?this.booleanValue?this.toggleOff():this.toggleOn():this.toggleOn(),this.requestRepaint()},mouseUp:()=>{this.booleanValue&&!this.toggleButton&&(this.toggleOff(),this.requestRepaint())},mouseOut:()=>{this.booleanValue&&!this.toggleButton&&(this.toggleOff(),this.requestRepaint())},tooltip:()=>this.tooltip,cursor:"pointer"}}toggleOn(){if(this.manualToggleState=!0,this.pv&&this.pv.writable)if(this.dataType===0)if(this.bit<0)this.display.pvEngine.setValue(new Date,this.pv.name,1);else{let t=this.pv.value|1<>this.bit&1)>0:this.dataType===1?this.pv.toString()===this.onState:!1:this.manualToggleState}draw(t){let e=this.bounds;this.borderAlarmSensitive&&(e=U(e,2*this.scale,2*this.scale));let i=this.booleanValue;i?this.onImageLoaded&&t.ctx.drawImage(this.onImageElement,e.x,e.y,e.width,e.height):this.offImageLoaded&&t.ctx.drawImage(this.offImageElement,e.x,e.y,e.width,e.height),t.addHitRegion(this.areaRegion).addRect(e.x,e.y,e.width,e.height),this.showBooleanLabel&&t.fillText({x:this.x+this.width/2,y:this.y+this.height/2,font:this.font,color:this.foregroundColor,align:"center",baseline:"middle",text:i?this.onLabel:this.offLabel})}get bit(){return this.properties.getValue(Vs)}get dataType(){return this.properties.getValue(Cs)}get toggleButton(){return this.properties.getValue(Hs)}get pushActionIndex(){return this.properties.getValue(Ws)}get releaseActionIndex(){return this.properties.getValue(Bs)}get showBooleanLabel(){return this.properties.getValue(Is)}get effect3d(){return this.properties.getValue(As)}get onImage(){return this.properties.getValue(Ms)}get onLabel(){return this.properties.getValue(Rs)}get onState(){return this.properties.getValue(Es)}get offImage(){return this.properties.getValue(Ls)}get offLabel(){return this.properties.getValue(Ps)}get offState(){return this.properties.getValue(ks)}get font(){return this.properties.getValue(_s).scale(this.scale)}},Ds="font",Ns="label",mc=class extends G{areaRegion;selectEl;constructor(t,e){super(t,e),this.properties.add(new O(Ds)),this.properties.add(new _(Ns))}init(){this.areaRegion={id:`${this.wuid}-area`,tooltip:()=>this.tooltip,cursor:"pointer"},this.selectEl=document.createElement("select"),this.selectEl.style.display="block",this.selectEl.style.position="absolute",this.selectEl.style.boxSizing="border-box",this.selectEl.style.opacity="0",this.selectEl.addEventListener("change",i=>{let r=this.selectEl?.value;if(r){this.selectEl.selectedIndex=0;let s=Number(r.substring(7));this.executeActionByIndex(s)}});let t=document.createElement("option");t.disabled=!0,t.value="",t.defaultSelected=!0,t.text=" -- select an option -- ",this.selectEl.add(t);let e=this.actions.actions;for(let i=0;i{this.writeValue(this.items[t]),this.requestRepaint()},mouseEnter:()=>{this.hoveredItem=t,this.requestRepaint()},mouseOut:()=>{this.hoveredItem=void 0,this.requestRepaint()},tooltip:()=>this.tooltip})}draw(t){this.horizontal?this.drawHorizontal(t):this.drawVertical(t)}drawHorizontal(t){let e=this.area.width/this.items.length,i=this.area.x;for(let r=0;r{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=U(this.bounds,2*e);t.fillRect(A(C({},i),{color:eo}));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,a=this.minimum,h=o-a,l=h-s,d=i.width-r-r,n=Math.floor(Math.max(6*e,d*s/h));this.dragRange=d-n;let p=this.getCoercedValue(),g=Math.floor((d-n)*(p-a)/l),v=d-g-n,w={x:i.x+r+g,y:i.y,width:n,height:i.height};t.fillRect(A(C({},w),{color:Ht})),this.drawRaisedButtonBorder(t,w),t.addHitRegion(this.thumbRegion).addRect(w.x,w.y,w.width,w.height);let T={x:i.x+r,y:i.y,width:g,height:i.height};t.addHitRegion(this.pageDecreaseRegion).addRect(T.x,T.y,T.width,T.height),this.pageDecreasePressed&&t.fillRect(A(C({},T),{color:m.BLACK}));let B={x:i.x+r+g+n,y:i.y,width:v,height:i.height};t.addHitRegion(this.pageIncreaseRegion).addRect(B.x,B.y,B.width,B.height),this.pageIncreasePressed&&t.fillRect(A(C({},B),{color:m.BLACK}))}drawVertical(t){let{scale:e}=this,i=U(this.bounds,e);t.fillRect(A(C({},i),{color:eo}));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,a=this.minimum,h=o-a,l=h-s,d=i.height-r-r,n=Math.floor(Math.max(6*e,d*s/h));this.dragRange=d-n;let p=this.getCoercedValue(),g=Math.floor((d-n)*(p-a)/l),v=d-g-n,w={x:i.x,y:i.y+r+g,width:i.width,height:n};t.fillRect(A(C({},w),{color:Ht})),this.drawRaisedButtonBorder(t,w),t.addHitRegion(this.thumbRegion).addRect(w.x,w.y,w.width,w.height);let T={x:i.x,y:i.y+r,width:i.width,height:g};t.addHitRegion(this.pageDecreaseRegion).addRect(T.x,T.y,T.width,T.height),this.pageDecreasePressed&&t.fillRect(A(C({},T),{color:m.BLACK}));let B={x:i.x,y:i.y+r+g+n,width:i.width,height:v};t.addHitRegion(this.pageIncreaseRegion).addRect(B.x,B.y,B.width,B.height),this.pageIncreasePressed&&t.fillRect(A(C({},B),{color:m.BLACK}))}drawLeftButton(t,e){t.fillRect(A(C({},e),{color:Ht})),this.decreasePressed?this.drawPressedButtonBorder(t,e):this.drawRaisedButtonBorder(t,e),t.addHitRegion(this.decreaseRegion).addRect(e.x,e.y,e.width,e.height);let i=U(e,3*this.scale),r=Math.min(i.height/2,i.width);i.x+=(i.width-r)/2,r=Math.max(r,1);let s={x:i.x,y:i.y+i.height/2};t.fillPath({color:m.BLACK,path:new S(s.x,s.y).lineTo(s.x+r,s.y-r).lineTo(s.x+r,s.y+r).closePath()})}drawRightButton(t,e){t.fillRect(A(C({},e),{color:Ht})),this.increasePressed?this.drawPressedButtonBorder(t,e):this.drawRaisedButtonBorder(t,e),t.addHitRegion(this.increaseRegion).addRect(e.x,e.y,e.width,e.height);let i=U(e,3*this.scale),r=Math.min(i.height/2,i.width);i.x+=(i.width-r)/2,r=Math.max(r,1);let s={x:i.x+r,y:i.y+i.height/2};t.fillPath({color:m.BLACK,path:new S(s.x,s.y).lineTo(s.x-r,s.y-r).lineTo(s.x-r,s.y+r).closePath()})}drawUpButton(t,e){t.fillRect(A(C({},e),{color:Ht})),this.decreasePressed?this.drawPressedButtonBorder(t,e):this.drawRaisedButtonBorder(t,e),t.addHitRegion(this.decreaseRegion).addRect(e.x,e.y,e.width,e.height);let i=U(e,3*this.scale),r=Math.min(i.height,i.width/2);i.y+=(i.height-r)/2,r=Math.max(r,1);let s={x:i.x+i.width/2,y:i.y};t.fillPath({color:m.BLACK,path:new S(s.x,s.y).lineTo(s.x-r,s.y+r).lineTo(s.x+r,s.y+r).closePath()})}drawDownButton(t,e){t.fillRect(A(C({},e),{color:Ht})),this.increasePressed?this.drawPressedButtonBorder(t,e):this.drawRaisedButtonBorder(t,e),t.addHitRegion(this.increaseRegion).addRect(e.x,e.y,e.width,e.height);let i=U(e,3*this.scale),r=Math.min(i.height,i.width/2);i.y+=(i.height-r)/2,r=Math.max(r,1);let s={x:i.x+i.width/2,y:i.y+r};t.fillPath({color:m.BLACK,path:new S(s.x,s.y).lineTo(s.x-r,s.y-r).lineTo(s.x+r,s.y-r).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 a=1*this.scale,h=e.y+a/2,l=e.x+a/2,d=e.y+e.height-a+a/2,n=e.x+e.width-a+a/2;t.strokePath({color:i,path:new S(n,d).lineTo(n,h).moveTo(n,d).lineTo(l,d)}),t.strokePath({color:r,path:new S(n-a,d-a).lineTo(n-a,h+a).moveTo(n-a,d-a).lineTo(l+a,d-a)}),t.strokePath({color:s,path:new S(l,h).lineTo(n-a,h).moveTo(l,h).lineTo(l,d-a)}),t.strokePath({color:o,path:new S(l+a,h+a).lineTo(n-a-a,h+a).moveTo(l+a,h+a).lineTo(l+a,d-a-a)})}stepIncreaseRepeatedly(){window.clearTimeout(this.actionTimeout),this.stepIncrease(),this.requestRepaint(),this.actionTimeout=window.setTimeout(()=>this.stepIncreaseRepeatedly(),ie)}stepDecreaseRepeatedly(){window.clearTimeout(this.actionTimeout),this.stepDecrease(),this.requestRepaint(),this.actionTimeout=window.setTimeout(()=>this.stepDecreaseRepeatedly(),ie)}stepIncrease(){let t=this.pv?.value??(this.maximum-this.minimum)/2;this.setCoercedValue(t+this.stepIncrement)}stepDecrease(){let t=this.pv?.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(),ie)}pageDecreaseRepeatedly(){window.clearTimeout(this.actionTimeout),this.pageDecrease(),this.requestRepaint(),this.actionTimeout=window.setTimeout(()=>this.pageDecreaseRepeatedly(),ie)}pageIncrease(){let t=this.pv?.value??(this.maximum-this.minimum)/2;this.setCoercedValue(t+this.pageIncrement)}pageDecrease(){let t=this.pv?.value??(this.maximum-this.minimum)/2;this.setCoercedValue(t-this.pageIncrement)}setCoercedValue(t){this.pv&&this.pv.writable&&(t=tthis.maximum?this.maximum:t,this.display.pvEngine.setValue(new Date,this.pv.name,t))}getCoercedValue(){let t=this.pv?.value??(this.maximum-this.minimum)/2;return tthis.maximum?this.maximum:t}destroy(){window.clearTimeout(this.actionTimeout)}get enabled(){return this.properties.getValue(qs)}get horizontal(){return this.properties.getValue(js)}get showValueTip(){return this.properties.getValue(to)}get font(){return this.properties.getValue(Ys).scale(this.scale)}get minimum(){return this.properties.getValue(Ks)}get maximum(){return this.properties.getValue(Xs)}get stepIncrement(){return this.properties.getValue(Zs)}get pageIncrement(){return this.properties.getValue(Js)}get barLength(){return this.properties.getValue(Qs)}},io="confirm_message",ro="font",so="format_type",oo="horizontal_alignment",ao="multiline_input",ho="password_input",lo="precision",no="precision_from_pv",uo="show_units",Vc="text",po="vertical_alignment",Cc=class extends G{areaRegion;inputEl;editing=!1;constructor(t,e){super(t,e),this.properties.add(new _(io)),this.properties.add(new O(ro)),this.properties.add(new b(so)),this.properties.add(new b(oo)),this.properties.add(new y(ao)),this.properties.add(new y(ho,!1)),this.properties.add(new b(lo)),this.properties.add(new y(no)),this.properties.add(new y(uo,!0)),this.properties.add(new b(po,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.pv?.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||"";!this.confirmMessage||confirm(this.confirmMessage)?(this.value=e,this.pv&&this.display.pvEngine.setValue(new Date,this.pv.name,e),this.inputEl.style.display="none",this.editing=!1,this.requestRepaint()):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)}cancelInput(){this.inputEl.style.display="none",this.editing=!1,this.requestRepaint()}draw(t){if(this.editing)return;t.addHitRegion(this.areaRegion).addRect(this.x,this.y,this.width,this.height);let e=t.ctx;this.backgroundAlarmSensitive&&this.alarm?t.fillRect(A(C({},this.area),{color:this.alarmSensitiveBackgroundColor})):this.transparent||t.fillRect(A(C({},this.area),{color:this.backgroundColor}));let i=document.createElement("canvas");i.width=this.area.width,i.height=this.area.height;let r=i.getContext("2d");r.fillStyle=this.alarmSensitiveForegroundColor.toString(),r.font=this.font.getFontString();let s=this.x;this.horizAlignment===0?r.textAlign="start":this.horizAlignment===1?(s+=this.width/2,r.textAlign="center"):this.horizAlignment===2&&(s+=this.width,r.textAlign="end");let o=this.y;this.vertAlignment===0?r.textBaseline="top":this.vertAlignment===1?(o=o+this.height/2,r.textBaseline="middle"):this.vertAlignment===2&&(o=o+this.height,r.textBaseline="bottom");let a=this.text;if(this.pv&&this.pv.value!==void 0){let h=this.precisionFromPV?this.pv.precision:this.precision;h===-1&&(h=this.pv.precision??-1),a=ae(this.pv.value,this.formatType,h),this.showUnits&&this.pv?.units&&(a+=" "+this.pv.units)}r.fillText(a,s-this.area.x,o-this.area.y),e.drawImage(i,this.area.x,this.area.y)}hide(){this.editing=!1,this.inputEl&&(this.inputEl.style.display="none")}destroy(){this.inputEl&&(this.display.rootPanel.removeChild(this.inputEl),this.inputEl=void 0)}get value(){return this.text}set value(t){this.properties.setValue(Vc,t),this.requestRepaint()}get confirmMessage(){return this.properties.getValue(io)}get font(){return this.properties.getValue(ro).scale(this.scale)}get formatType(){return this.properties.getValue(so)}get horizAlignment(){return this.properties.getValue(oo)}get multilineInput(){return this.properties.getValue(ao)}get passwordInput(){return this.properties.getValue(ho)}get precision(){return this.properties.getValue(lo)}get precisionFromPV(){return this.properties.getValue(no)}get showUnits(){return this.properties.getValue(uo)}get vertAlignment(){return this.properties.getValue(po)}},co="alpha",go="fill",mo="line_width",fo="line_style",xo="start_angle",wo="total_angle",Ac=class extends G{constructor(t,e){super(t,e),this.properties.add(new b(co,255)),this.properties.add(new b(mo)),this.properties.add(new b(xo)),this.properties.add(new b(wo)),this.properties.add(new y(go)),this.properties.add(new b(fo))}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=-$(this.startAngle),a=-$(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,a,!0),t.ctx.closePath(),t.ctx.fill()),this.lineWidth&&this.totalAngle!==0){let h,{scale:l}=this;this.lineStyle===0?h=[]:this.lineStyle===1?h=[6*l,2*l]:this.lineStyle===2?h=[2*l,2*l]:console.warn(`Unsupported arc line style ${this.lineStyle}`),t.strokeEllipse({cx:e,cy:i,rx:r,ry:s,startAngle:o,endAngle:a,lineWidth:this.lineWidth,anticlockwise:!0,color:this.alarmSensitiveForegroundColor,dash:h})}}get alpha(){return this.properties.getValue(co)}get lineWidth(){return this.scale*this.properties.getValue(mo)}get lineStyle(){return this.properties.getValue(fo)}get startAngle(){return this.properties.getValue(xo)}get totalAngle(){return this.properties.getValue(wo)}get fill(){return this.properties.getValue(go)}},yo="alpha",vo="bg_gradient_color",bo="fg_gradient_color",To="fill_level",So="gradient",Vo="horizontal_fill",Co="line_color",Ao="line_width",_o="line_style",_c=class extends G{constructor(t,e){super(t,e),this.properties.add(new b(yo,255)),this.properties.add(new R(vo)),this.properties.add(new R(bo)),this.properties.add(new y(So)),this.properties.add(new b(Ao)),this.properties.add(new H(To)),this.properties.add(new y(Vo)),this.properties.add(new R(Co)),this.properties.add(new b(_o))}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 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.backgroundGradientStartColor.toString()),l.addColorStop(1,o.toString()),t.fillEllipse({cx:e,cy:i,rx:r,ry:s,gradient:l})}else t.fillEllipse({cx:e,cy:i,rx:r,ry:s,color:o})}this.lineWidth&&(this.lineStyle===0?t.strokeEllipse({cx:e,cy:i,rx:r,ry:s,color:this.lineColor,lineWidth:this.lineWidth}):this.lineStyle===1?t.strokeEllipse({cx:e,cy:i,rx:r,ry:s,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=U(this,this.lineWidth);if(t.ctx.save(),this.horizontalFill){let h=e.width*(this.fillLevel/100);t.ctx.beginPath(),t.ctx.rect(e.x,e.y,h,e.height)}else{let h=e.height*(this.fillLevel/100),l=e.y+e.height-h;t.ctx.beginPath(),t.ctx.rect(e.x,l,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,a=this.alarmSensitiveForegroundColor;if(this.gradient){let h=this.horizontalFill?this.x:this.x+this.width,l=this.horizontalFill?this.y+this.height:this.y,d=t.createLinearGradient(this.x,this.y,h,l);d.addColorStop(0,this.foregroundGradientStartColor.toString()),d.addColorStop(1,a.toString()),t.fillEllipse({cx:i,cy:r,rx:s,ry:o,gradient:d})}else t.fillEllipse({cx:i,cy:r,rx:s,ry:o,color:a});t.ctx.restore()}get alpha(){return this.properties.getValue(yo)}get lineWidth(){return this.scale*this.properties.getValue(Ao)}get fillLevel(){return this.properties.getValue(To)}get horizontalFill(){return this.properties.getValue(Vo)}get lineColor(){return this.properties.getValue(Co)}get lineStyle(){return this.properties.getValue(_o)}get gradient(){return this.properties.getValue(So)}get backgroundGradientStartColor(){return this.properties.getValue(vo)}get foregroundGradientStartColor(){return this.properties.getValue(bo)}},Lo="image_file",Po="no_animation",ko="transparency",Lc=class extends G{currentImageFile;imageElement;imageSnapshot;imageLoading=!1;imageLoaded=!1;constructor(t,e){super(t,e),this.properties.add(new _(Lo)),this.properties.add(new _(Po)),this.properties.add(new y(ko,!0))}init(){this.imageElement=new Image(this.width,this.height),this.imageElement.onload=()=>{this.snapshotImage(this.imageElement),this.imageLoading=!1,this.imageLoaded=!0,this.requestRepaint()},this.triggerImageLoad()}draw(t){this.imageFile&&this.currentImageFile!==this.imageFile&&this.triggerImageLoad(),this.transparency||(t.ctx.fillStyle=this.backgroundColor.toString(),t.ctx.fillRect(this.x,this.y,this.width,this.height)),this.imageLoading&&this.imageSnapshot?t.ctx.drawImage(this.imageSnapshot,this.x,this.y,this.width,this.height):this.imageLoaded&&(this.noAnimation?t.ctx.drawImage(this.imageSnapshot,this.x,this.y,this.width,this.height):t.ctx.drawImage(this.imageElement,this.x,this.y,this.width,this.height))}triggerImageLoad(){this.imageLoading=!0,this.imageLoaded=!1,this.imageElement&&this.imageFile&&(this.currentImageFile=this.imageFile,this.imageElement.src=this.resolvePath(this.imageFile))}snapshotImage(t){let e=document.createElement("canvas"),i=e.getContext("2d");e.width=t.naturalWidth,e.height=t.naturalHeight,i.drawImage(t,0,0),this.imageSnapshot=e}get transparency(){return this.properties.getValue(ko)}get imageFile(){return this.properties.getValue(Lo)}get noAnimation(){return this.properties.getValue(Po)}},Mo="font",Ro="horizontal_alignment",Eo="vertical_alignment",Wo="wrap_words",Pc=class extends G{constructor(t,e){super(t,e),this.properties.add(new O(Mo)),this.properties.add(new b(Ro)),this.properties.add(new b(Eo)),this.properties.add(new y(Wo))}draw(t){let e=t.ctx;this.transparent||t.fillRect({x:this.x,y:this.y,width:this.width,height:this.height,color:this.backgroundColor});let i=this.wrapText(t,this.text,this.width);e.fillStyle=this.foregroundColor.toString(),e.font=this.font.getFontString(),e.textAlign="start",e.textBaseline="top";let r=0;for(let h of i){let l=e.measureText(h).width;r=Math.max(r,l)}let s=this.x;this.horizAlignment===1?s=this.x+(this.width-r)/2:this.horizAlignment===2&&(s=this.x+(this.width-r));let o=i.length*this.font.height+(i.length-1)*this.font.height*.2,a=this.y;this.vertAlignment===1?a+=(this.height-o)/2:this.vertAlignment===2&&(a+=this.height-o);for(let h of i)e.fillText(h,s,a),a+=this.font.height*1.2}wrapText(t,e,i){let r=[];for(let s of e.split(`
`))r=r.concat(this.wrapLine(t,s,i));return r}wrapLine(t,e,i){if(!e)return[""];let r=[],s,o,a,h=0;for(;e.length;){for(o=e.length;t.measureText(e.substr(0,o),this.font).width>i;o--);if(s=e.substr(0,o),o!==e.length)for(a=0;s.indexOf(" ",a)!==-1;a=s.indexOf(" ",a)+1);r.push(s.substr(0,a||s.length)),h=Math.max(h,t.measureText(r[r.length-1],this.font).width),e=e.substr(r[r.length-1].length,e.length)}return r}get font(){return this.properties.getValue(Mo).scale(this.scale)}get horizAlignment(){return this.properties.getValue(Ro)}get vertAlignment(){return this.properties.getValue(Eo)}get wrapWords(){return this.properties.getValue(Wo)}},Bo="alpha",Io="fill_level",Ho="horizontal_fill",Do="line_color",No="line_style",Fo="line_width",Dt="points",kc=class extends G{constructor(t,e){super(t,e),this.properties.add(new b(Bo,255)),this.properties.add(new b(Fo)),this.properties.add(new H(Io)),this.properties.add(new y(Ho)),this.properties.add(new R(Do)),this.properties.add(new b(No)),this.properties.add(new ne(Dt,[]))}init(){this.addPropertyListener("x",(t,e)=>{let i=this.properties.getValue(Dt),r=se(i,t-e,0);this.properties.setValue(Dt,r),this.requestRepaint()}),this.addPropertyListener("y",(t,e)=>{let i=this.properties.getValue(Dt),r=se(i,0,t-e);this.properties.setValue(Dt,r),this.requestRepaint()})}draw(t){let{scale:e}=this;t.ctx.globalAlpha=this.alpha/255;let i=S.fromPoints(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+=s),t.ctx.save();let o=this.x-this.lineWidth/2,a=i-this.lineWidth/2,h=r+this.lineWidth,l=s+this.lineWidth;t.ctx.beginPath(),t.ctx.rect(o,a,h,l),t.ctx.clip();let d=this.alarmSensitiveForegroundColor;t.fillPath({path:e,color:d}),t.ctx.restore()}get alpha(){return this.properties.getValue(Bo)}get lineWidth(){return this.scale*this.properties.getValue(Fo)}get fillLevel(){return this.properties.getValue(Io)}get horizontalFill(){return this.properties.getValue(Ho)}get lineColor(){return this.properties.getValue(Do)}get lineStyle(){return this.properties.getValue(No)}get points(){return oe(this.properties.getValue(Dt),this.scale)}},$o="alpha",Oo="arrows",Go="arrow_length",zo="fill_arrow",Uo="fill_level",qo="horizontal_fill",Yo="line_width",Xo="points",Mc=class extends G{constructor(t,e){super(t,e),this.properties.add(new b($o,255)),this.properties.add(new b(Yo)),this.properties.add(new H(Uo)),this.properties.add(new y(qo)),this.properties.add(new ne(Xo,[])),this.properties.add(new b(Go)),this.properties.add(new y(zo)),this.properties.add(new b(Oo))}draw(t){let e=t.ctx;e.globalAlpha=this.alpha/255,this.transparent&&(e.globalAlpha=0),this.drawShape(e,this.backgroundColor),this.fillLevel&&this.drawFill(e),e.globalAlpha=1}drawFill(t){let e=this.y,i=this.width,r=this.height;this.horizontalFill?i*=this.fillLevel/100:(r*=this.fillLevel/100,e+=r),t.save();let s=this.x-this.lineWidth/2,o=e-this.lineWidth/2,a=i+this.lineWidth,h=r+this.lineWidth;t.beginPath(),t.rect(s,o,a,h),t.clip(),this.drawShape(t,this.foregroundColor),t.restore()}drawShape(t,e){t.strokeStyle=e.toString(),t.lineWidth=this.lineWidth,t.beginPath();for(let i=0;i=2){let i=this.points[0],r=this.points[this.points.length-1];if(this.arrows===2||this.arrows===3){let s=this.calculateArrowPoints(this.points[this.points.length-2],r);if(s[2]=r,this.fillArrow){t.fillStyle=e.toString(),t.beginPath();for(let o=0;o>i&1)>0;break}}return e?this.onColor:this.offColor}draw(t){if(this.numBits<1)return;let e=this.bounds;this.borderAlarmSensitive&&(e=U(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;oe.width||this.squareLed?s=e.width:s=i;for(let o=0;o0&&(o-=this.ledBorder/2,a-=this.ledBorder/2),t.fillEllipse({cx:r,cy:s,rx:o,ry:a,color:this.getLedColor(i)}),t.strokeEllipse({cx:r,cy:s,rx:o,ry:a,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,a=e.height/2;t.fillEllipse({cx:r,cy:s,rx:o,ry:a,color:m.WHITE});let h=t.createLinearGradient(e.x,e.y,e.x+e.width,e.y+e.height);h.addColorStop(0,this.ledBorderColor.toString()),h.addColorStop(1,this.ledBorderColor.withAlpha(0).toString()),t.fillEllipse({cx:r,cy:s,rx:o,ry:a,gradient:h});let l=e.width-2*this.ledBorder,d=e.height-2*this.ledBorder;o=l/2,a=d/2,t.fillEllipse({cx:r,cy:s,rx:o,ry:a,color:this.getLedColor(i)}),h=t.createLinearGradient(e.x,e.y,e.x+e.width,e.y+e.height),h.addColorStop(0,m.WHITE.toString()),h.addColorStop(1,this.ledBorderColor.withAlpha(0).toString()),t.fillEllipse({cx:r,cy:s,rx:o,ry:a,gradient:h})}drawSquare2d(t,e,i){let r=Ft(e.x,e.y,e.width,e.height,this.ledBorder);t.fillRect(A(C({},r),{color:this.getLedColor(i)})),t.strokeRect(A(C({},r),{color:this.ledBorderColor,lineWidth:this.ledBorder}))}drawSquare3d(t,e,i){t.fillRect(A(C({},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 S(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 S(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 S(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 S(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,a=e.width-2*this.ledBorder,h=e.height-2*this.ledBorder,l=this.getLedColor(i);t.fillRect({x:s,y:o,width:a,height:h,color:l}),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,l.withAlpha(0).toString()),t.fillRect({x:s,y:o,width:a,height:h,gradient:r})}get bitReverse(){return this.properties.getValue(ma)}get horizontal(){return this.properties.getValue(xa)}get numBits(){return this.properties.getValue(ba)}get startBit(){return this.properties.getValue(Va)}get ledPacked(){return this.properties.getValue(va)}get ledBorder(){return this.scale*this.properties.getValue(wa)}get ledBorderColor(){return this.properties.getValue(ya)}get offColor(){return this.properties.getValue(Ta)}get onColor(){return this.properties.getValue(Sa)}get effect3d(){return this.properties.getValue(fa)}get squareLed(){return this.properties.getValue(Ca)}},Qt=class{prefix="";suffix="";comma=0;minInt=1;minFrac=0;maxFrac=0;constructor(t){for(let h=0;hthis.minInt&&(this.minInt=a.length),a=r.replace(/[^0]/g,""),this.minFrac=a.length}format(t){let e=this.formatBack(t).toLowerCase();if(isNaN(e)||e.length==0)return t;if(e.indexOf("e")!=-1){let g=Number(e);if(g===1/0||g===-1/0||(e=g+"",e.indexOf("e")!==-1))return e}let i=!1;e.charAt(0)==="-"?(i=!0,e=e.substring(1)):e.charAt(0)==="+"&&(e=e.substring(1));let r=e.indexOf("."),s="",o="";r!=-1?(s=e.substring(0,r),o=e.substring(r+1)):s=e,o=o.replace(/[.]/,"");let a=this.suffix&&this.suffix.charAt(0)==="%",h=this.minInt,l=this.minFrac,d=this.maxFrac;if(a&&(h-=2,l+=2,d+=2),o.length>d){let g=+("0."+o);g=d==0?Math.round(g):g.toFixed(d),o=g.toString(10).substr(2);let v=g>=1?1:0,w,T=s.length-1;for(;v;)if(T==-1){s="1"+s;break}else w=Number(s.charAt(T)),w===9?(w="0",v=1):(w=++w+"",v=0),s=s.substring(0,T)+w+s.substring(T+1,s.length),T--}for(let g=o.length;gl&&o.charAt(o.length-1)=="0";)o=o.substring(0,o.length-1);for(let g=s.length;gh&&s.charAt(0)=="0";)s=s.substring(1);a&&(s+=o.substring(0,2),o=o.substring(2));let n=0;for(let g=s.length;g>0;g--)n!=0&&n%this.comma==0&&(s=s.substring(0,g)+","+s.substring(g),n=0),n++;let p;return o.length>0?p=this.prefix+s+"."+o+this.suffix:p=this.prefix+s+this.suffix,i&&(p="-"+p),p}formatBack(t){if(t+="",!t)return"";if(!isNaN(t))return this.getNumericString(t);let e=t,i=!1;t.charAt(0)==="-"&&(e=e.substr(1),i=!0);let r=e.indexOf(this.prefix),s=this.suffix==""?e.length:e.indexOf(this.suffix,this.prefix.length+1);return r==0&&s>0&&(e=e.substr(0,s),e=e.substr(this.prefix.length),e=e.replace(/,/g,""),i&&(e="-"+e),!isNaN(e))?this.getNumericString(e):t}getNumericString(t){let e=Number(t)+"";if(t.indexOf(".")>-1&&e.indexOf(".")<0){for(var i=t.indexOf(".")+1;i0?this.lengthInDegrees=360-(this.endAngle-this.startAngle):this.lengthInDegrees=this.startAngle-this.endAngle,this.drawRamp(t,i)}drawRamp(t,e){let i=e.x+e.width/2,r=e.y+e.height/2,s=e.width/2,o=e.height/2,a,h=360-this.endAngle;if(this.endAngle-this.startAngle>0?a=this.startAngle-90:a=this.startAngle+90,this.showLoLo){let v=a,w=360-this.getValuePosition(this.lolo,!0);t.strokeEllipse({cx:i,cy:r,rx:s-this.rampWidth/2,ry:o-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:$(v),endAngle:$(w),color:this.loloColor})}if(this.showLo){let v;this.showLoLo?v=this.lolo:v=this.minimum;let w=360-this.getValuePosition(v,!0),T=360-this.getValuePosition(this.lo,!0);if(this.effect3d&&this.gradient&&this.showLoLo){let B=$(this.getValuePosition(v,!0)-Q),M=xt(e.width/2,B,e),k=$(this.getValuePosition(this.lo,!0)+Q),W=xt(e.width/2,k,e),D=t.createLinearGradient(M.x,M.y,W.x,W.y);D.addColorStop(0,this.loloColor.toString()),D.addColorStop(1,this.loColor.toString()),t.strokeEllipse({cx:i,cy:r,rx:s-this.rampWidth/2,ry:o-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:$(w-Q/2),endAngle:$(T+Q/2),gradient:D})}else t.strokeEllipse({cx:i,cy:r,rx:s-this.rampWidth/2,ry:o-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:$(w),endAngle:$(T),color:this.loColor})}let l=this.minimum;this.showLo?l=this.lo:this.showLoLo&&(l=this.lolo);let d=this.maximum;this.showHi?d=this.hi:this.showHiHi&&(d=this.hihi);let n=(l+d)/2,p=360-this.getValuePosition(l,!0),g=360-this.getValuePosition(n,!0);if(this.effect3d&&this.gradient&&(this.showLoLo||this.showLo)){let v=$(this.getValuePosition(l,!0)-Q),w=xt(e.width/2,v,e),T=$(this.getValuePosition(n,!0)+Q),B=xt(e.width/2,T,e),M=t.createLinearGradient(w.x,w.y,B.x,B.y);M.addColorStop(0,(this.showLo?this.loColor:this.loloColor).toString()),M.addColorStop(1,m.GREEN.toString()),t.strokeEllipse({cx:i,cy:r,rx:s-this.rampWidth/2,ry:o-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:$(p-Q/2),endAngle:$(g+Q/2),gradient:M})}else t.strokeEllipse({cx:i,cy:r,rx:s-this.rampWidth/2,ry:o-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:$(p),endAngle:$(g),color:m.GREEN});if(p=360-this.getValuePosition(n,!0),g=360-this.getValuePosition(d,!0),this.effect3d&&this.gradient&&(this.showHi||this.showHiHi)){let v=$(this.getValuePosition(n,!0)-Q),w=xt(e.width/2,v,e),T=$(this.getValuePosition(d,!0)+Q),B=xt(e.width/2,T,e),M=t.createLinearGradient(w.x,w.y,B.x,B.y);M.addColorStop(0,m.GREEN.toString()),M.addColorStop(1,(this.showHi?this.hiColor:this.hihiColor).toString());let k=g!==h?Q/2:0;t.strokeEllipse({cx:i,cy:r,rx:s-this.rampWidth/2,ry:o-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:$(p-Q/2),endAngle:$(g+k),gradient:M})}else t.strokeEllipse({cx:i,cy:r,rx:s-this.rampWidth/2,ry:o-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:$(p),endAngle:$(g),color:m.GREEN});if(this.showHi){let v;this.showHiHi?v=this.hihi:v=this.maximum;let w=360-this.getValuePosition(this.hi,!0),T=360-this.getValuePosition(v,!0);if(this.effect3d&&this.gradient&&this.showHiHi){let B=$(this.getValuePosition(this.hi,!0)-Q),M=xt(e.width/2,B,e),k=$(this.getValuePosition(v,!0)+Q),W=xt(e.width/2,k,e),D=t.createLinearGradient(M.x,M.y,W.x,W.y);D.addColorStop(0,this.hiColor.toString()),D.addColorStop(1,this.hihiColor.toString());let N=T!==h?Q/2:0;t.strokeEllipse({cx:i,cy:r,rx:s-this.rampWidth/2,ry:o-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:$(w-Q/2),endAngle:$(T+N),gradient:D})}else t.strokeEllipse({cx:i,cy:r,rx:s-this.rampWidth/2,ry:o-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:$(w),endAngle:$(T),color:this.hiColor})}if(this.showHiHi){p=360-this.getValuePosition(this.hihi,!0),g=h;let v=this.gradient?Q/2:0;t.strokeEllipse({cx:i,cy:r,rx:s-this.rampWidth/2,ry:o-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:$(p-v),endAngle:$(g),color:this.hihiColor})}}getRadius(){return this.radius}getValuePosition(t,e=!1){e&&(t=this.getValueInRange(t));let i;return this.logScale?i=this.startAngle-(Math.log10(t)-Math.log10(this.range.min))/(Math.log10(this.range.max)-Math.log10(this.range.min))*this.lengthInDegrees:i=this.startAngle-(t-this.range.min)/(this.range.max-this.range.min)*this.lengthInDegrees,i<0&&(i+=360),i}getValueInRange(t){return this.range.min<=t&&t<=this.range.max?t:t>this.range.max?this.range.max:this.range.min}getRenderedRange(){let t={min:this.minimum,max:this.maximum};return this.logScale&&(this.minimum<=0&&(t.min=.1),t.max<=this.minimum&&(t.max=t.min+100)),t}},Aa=new m(100,100,100),Hc=16,Dc=8,Nc=5,Fc=-1,_a="color_hi",La="color_hihi",Pa="color_lo",ka="color_lolo",Ma="effect_3d",Ra="font",Ea="value_label_format",Wa="level_hi",Ba="level_hihi",Ia="level_lo",Ha="level_lolo",Da="limits_from_pv",Na="log_scale",Fa="minimum",$a="maximum",Oa="needle_color",Ga="ramp_gradient",za="show_ramp",ke=225,$c=315,Oc=class extends G{constructor(t,e){super(t,e),this.properties.add(new R(_a)),this.properties.add(new R(La)),this.properties.add(new R(Pa)),this.properties.add(new R(ka)),this.properties.add(new y(Ma)),this.properties.add(new O(Ra)),this.properties.add(new H(Wa)),this.properties.add(new H(Ba)),this.properties.add(new H(Ia)),this.properties.add(new H(Ha)),this.properties.add(new y(Na)),this.properties.add(new y(Da)),this.properties.add(new H($a)),this.properties.add(new H(Fa)),this.properties.add(new R(Oa)),this.properties.add(new y(Ga)),this.properties.add(new y(za,!0)),this.properties.add(new _(Ea))}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.drawLabel(t,i,r),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,Aa.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,a=1/2,h=8.5/10,l=$(0),d=$(35),n={x:Math.floor(this.x+e/2-s*h*Math.cos(l)),y:Math.floor(this.y+i/2-s*o),width:Math.floor(2*s*h*Math.cos(l)),height:Math.floor(s*o+s*a)},p=t.createLinearGradient(n.x,n.y,n.x,n.y+n.height);p.addColorStop(0,m.WHITE.withAlpha(90/255).toString()),p.addColorStop(1,m.WHITE.withAlpha(0).toString()),t.fillEllipse({cx:n.x+n.width/2,cy:n.y+n.height/2,rx:n.width/2,ry:n.height/2,gradient:p}),n={x:Math.floor(this.x+e/2-s*h*Math.sin(d)),y:Math.floor(Math.ceil(this.y+i/2+s*a)),width:Math.floor(2*s*h*Math.sin(d)),height:Math.floor(Math.ceil(s*o-s*a))},p=t.createLinearGradient(n.x,n.y,n.x,n.y+n.height),p.addColorStop(0,m.WHITE.withAlpha(0).toString()),p.addColorStop(1,m.WHITE.withAlpha(40/255).toString()),t.fillEllipse({cx:n.x+n.width/2,cy:n.y+n.height/2,rx:n.width/2,ry:n.height/2,gradient:p})}}drawRamp(t,e,i,r){let s=U({x:this.x,y:this.y,width:e,height:i},e/4,i/4),o=C({},s);o.width=Math.min(s.width,s.height),o.height=s.width;let a=new Ud(10*this.scale,225,315);a.lolo=r.lolo,a.loloColor=this.colorLoLo,a.lo=r.lo,a.loColor=this.colorLo,a.hi=r.hi,a.hiColor=this.colorHi,a.hihi=r.hihi,a.hihiColor=this.colorHiHi,a.minimum=r.min,a.maximum=r.max,a.effect3d=this.effect3d,a.gradient=this.rampGradient,a.logScale=this.logScale,a.draw(t,s,o)}drawLabel(t,e,i){let r=it.ARIAL_12_BOLD.scale(this.scale);if(this.pv?.value!==void 0){let s=this.formatLabelValue(this.pv.value),o=t.measureText(s,r);t.fillText({x:this.x+e/2-o.width/2,y:this.y+i*7/8-o.height/2,color:this.foregroundColor,align:"left",baseline:"top",font:r,text:s})}}drawNeedle(t,e,i,r){let s=this.x+e/2,o=this.y+i/2,a;if(this.pv?.value!==void 0){let T=this.getValueInRange(this.pv.value,r);a=360-this.getValuePosition(T,r),r.max>r.min?T>r.max?a+=10:Tr.min?a-=10:Te.max?e.max:e.min}getValuePosition(t,e){let i=360-($c-ke),r;return this.logScale?r=ke-(Math.log10(t)-Math.log10(e.min))/(Math.log10(e.max)-Math.log10(e.min))*i:r=ke-(t-e.min)/(e.max-e.min)*i,r<0&&(r+=360),r}formatLabelValue(t){return this.valueLabelFormat?new Qt(this.valueLabelFormat).format(t):String(Number(t.toFixed(3)))}get needleDiameter(){return this.scale*Hc}get majorTickLength(){return this.scale*Dc}get minorTickLength(){return this.scale*Nc}get gapBetweenNeedleScale(){return this.scale*Fc}get colorLo(){return this.properties.getValue(Pa)}get colorLoLo(){return this.properties.getValue(ka)}get colorHi(){return this.properties.getValue(_a)}get colorHiHi(){return this.properties.getValue(La)}get effect3d(){return this.properties.getValue(Ma)}get font(){return this.properties.getValue(Ra).scale(this.scale)}get levelLo(){return this.properties.getValue(Ia)}get levelLoLo(){return this.properties.getValue(Ha)}get levelHi(){return this.properties.getValue(Wa)}get levelHiHi(){return this.properties.getValue(Ba)}get limitsFromPv(){return this.properties.getValue(Da)}get logScale(){return this.properties.getValue(Na)}get minimum(){return this.properties.getValue(Fa)}get maximum(){return this.properties.getValue($a)}get needleColor(){return this.properties.getValue(Oa)}get rampGradient(){return this.properties.getValue(Ga)}get showRamp(){return this.properties.getValue(za)}get valueLabelFormat(){return this.properties.getValue(Ea)}},Ua="bit",qa="data_type",Ya="off_image",Xa="off_label",Ka="font",ja="on_image",Za="on_label",Ja="show_boolean_label",Gc=class extends G{onImageElement;onImageLoaded=!1;offImageElement;offImageLoaded=!1;constructor(t,e){super(t,e),this.properties.add(new b(Ua)),this.properties.add(new b(qa)),this.properties.add(new _(Ya)),this.properties.add(new _(Xa)),this.properties.add(new _(ja)),this.properties.add(new _(Za)),this.properties.add(new O(Ka)),this.properties.add(new y(Ja))}init(){this.onImageElement=new Image,this.onImageElement.onload=()=>{this.onImageLoaded=!0,this.requestRepaint()},this.offImageElement=new Image,this.offImageElement.onload=()=>{this.offImageLoaded=!0,this.requestRepaint()},this.onImage&&(this.onImageElement.src=this.resolvePath(this.onImage)),this.offImage&&(this.offImageElement.src=this.resolvePath(this.offImage))}get booleanValue(){return this.bit<0?!!this.pv?.toNumber():this.pv?.value!==void 0?(this.pv?.value>>this.bit&1)>0:!1}get image(){return this.booleanValue?this.onImage:this.offImage}get label(){return this.booleanValue?this.onLabel:this.offLabel}draw(t){this.transparent||t.fillRect({x:this.x,y:this.y,width:this.width,height:this.height,color:this.backgroundColor}),this.booleanValue?this.onImageLoaded&&t.ctx.drawImage(this.onImageElement,this.x,this.y,this.width,this.height):this.offImageLoaded&&t.ctx.drawImage(this.offImageElement,this.x,this.y,this.width,this.height),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 bit(){return this.properties.getValue(Ua)}get dataType(){return this.properties.getValue(qa)}get showBooleanLabel(){return this.properties.getValue(Ja)}get font(){return this.properties.getValue(Ka).scale(this.scale)}get offLabel(){return this.properties.getValue(Xa)}get offImage(){return this.properties.getValue(Ya)}get onLabel(){return this.properties.getValue(Za)}get onImage(){return this.properties.getValue(ja)}},zc=["January","February","March","April","May","June","July","August","September","October","November","December"],Tt=class{constructor(t,e,i,r,s,o,a,h,l,d){this.formatter=t,this.scale=e,this.scaleFont=i,this.minimum=r,this.maximum=s,this.logScale=o,this.majorTickStepHint=a,this.foregroundColor=h,this.showMinorTicks=l,this.showScale=d}labels=[];labelValues=[];labelPositions=[];labelVisibilities=[];gridStepInPixel=0;horizontal=!1;x=0;y=0;scaleFormat="";timeFormat=0;length=0;margin=0;get scaleLength(){return this.length-2*this.margin}getX(){return this.x}getY(){return this.y}getGridPositions(){let t=[...this.labelPositions];return this.horizontal||(t=t.map(e=>this.length-e)),t.pop(),t.shift(),t}setDimensions(t,e,i,r){this.x=t,this.y=e,this.length=i,this.horizontal=r}getValuePosition(t){let{start:e,stop:i}=this.getMinMax(),r=0,s=this.length-2*this.margin;if(this.logScale)t<=0?r=this.margin:r=(Math.log10(t)-Math.log10(e))/(Math.log10(i)-Math.log10(e))*s+this.margin;else{let o=Math.max(Math.abs(e),Math.abs(i));i/=o,e/=o;let a=i-e;r=(t/o-e)/a*s+this.margin}return this.horizontal?r+this.x:this.length-r+this.y}getMinMax(){let t=this.minimum,e=this.maximum;return this.logScale&&(t<=0&&(t=.1),e<=t&&(e=t+100)),{start:t,stop:e}}getPositionValue(t){let e=this.getMinMax(),{start:i,stop:r}=e,s=this.horizontal?t-this.x:this.length+this.y-t,o=this.length-2*this.margin,a;if(this.logScale)a=Math.pow(10,(s-this.margin)*(Math.log10(r)-Math.log10(i))/o+Math.log10(i));else{let h=Math.max(Math.abs(i),Math.abs(r));r/=h,i/=h;let l=r-i;a=((s-this.margin)/o*l+i)*h}return a}calculateMargin(t,e){if(this.showScale){let i=t.measureText(this.format(this.minimum),this.scaleFont),r=t.measureText(this.format(this.maximum),this.scaleFont);return Math.ceil(e?Math.max(i.width,r.width)/2:Math.max(i.height,r.height)/2)}else return 0}measureHorizontalHeight(t){let e=t.measureText("dummy",this.scaleFont);return this.showScale?e.height+this.spaceBetweenMarkAndLabel+this.majorTickLength:0}drawHorizontal(t,e,i,r){let{scale:s}=this;this.length=r,this.horizontal=!0,this.margin=this.calculateMargin(t,this.horizontal);let o=r-2*this.margin;o>0&&this.updateLabels(t,o);let a=0;for(let l=0;la&&(a=d.height)}let h=this.showScale?a+this.spaceBetweenMarkAndLabel+this.majorTickLength:0;if(i=i-h,this.x=e,this.y=i,this.logScale)for(let l=0;l0&&this.updateLabels(t,h);let l=0;for(let n=0;nl&&(l=p.width)}let d=this.showScale?l+this.spaceBetweenMarkAndLabel+this.majorTickLength:0;if(s||(e=e-d),this.x=e,this.y=i,this.logScale)for(let n=0;n=this.minorTickMarkStepHint?(o=5,a=Math.floor(s/5)):s/4>=this.minorTickMarkStepHint?(o=4,a=Math.floor(s/4)):(o=2,a=Math.floor(s/2));let{labelPositions:h,minorTickLength:l,scale:d}=this;if(e>0)if(e===1&&h[1]-h[0]a+3*d;){n=n-a;let p=Math.round(i+n)-d*.5;t.strokePath({path:new S(p,r).lineTo(p,r+l),color:this.foregroundColor,lineWidth:d*1,opacity:100/255})}}else if(e===h.length-1&&h[e]-h[e-1]a+3*d;){n=n+a;let p=Math.round(i+n)-d*.5;t.strokePath({path:new S(p,r).lineTo(p,r+l),color:this.foregroundColor,lineWidth:d*1,opacity:100/255})}}else for(let n=0;n=this.minorTickMarkStepHint?(o=5,a=Math.floor(s/5)):s/4>=this.minorTickMarkStepHint?(o=4,a=Math.floor(s/4)):(o=2,a=Math.floor(s/2));let{labelPositions:h,minorTickLength:l,majorTickLength:d,scale:n}=this;if(e>0)if(e===1&&h[1]-h[0]a+3*n;){p-=a;let g=Math.round(r-p)-n*.5;t.strokePath({path:new S(i+d-l,g).lineTo(i+d,g),color:this.foregroundColor,lineWidth:n*1,opacity:100/255})}}else if(e===h.length-1&&h[e]-h[e-1]a+3*n;){p+=a;let g=Math.round(r-p)-n*.5;t.strokePath({path:new S(i+d-l,g).lineTo(i+d,g),color:this.foregroundColor,lineWidth:n*1,opacity:100/255})}}else for(let p=0;p=i)if(i===e)i++;else{r=!0;let d=e;e=i,i=d}let s=Math.abs(i-e),o=this.majorTickStepHint;o>t&&(o=t);let a=s/t*o,h=0;if(a<1){if(a!=0)for(;a<1;)a*=10,h--}else for(;a>=10;)a/=10,h++;let l;return a>7.5?l=10*Math.pow(10,h):a>3.5?l=5*Math.pow(10,h):a>1.5?l=2*Math.pow(10,h):l=Math.pow(10,h),r&&(l=-l),l}updateLabelsForLogScale(t,e,i){t<=0&&(t=.1),e<=t&&(e=t+100);let r=el?this.addMinMaxTickInfo(t,i,!0):!r&&t=a:d<=a;d+=r?-1:1)if(Math.abs(a-o)>20){let n=Math.pow(10,d);if(n>e)break;this.addTickInfo(n,e,s,i)}else{for(let n=l;(r?n>=Math.pow(10,d-1):n<=Math.pow(10,d))&&!(r?ne);n=r?n-h:n+h)this.addTickInfo(n,e,s,i);h=r?h/Math.pow(10,1):h*Math.pow(10,1),l=r?Math.pow(10,d-1):h+Math.pow(10,d)}(r?ethis.labelValues[this.labelValues.length-1])&&this.addMinMaxTickInfo(e,i,!1)}addMinMaxTickInfo(t,e,i){i?(this.labelValues.push(t),this.labels.push(this.format(t)),this.labelPositions.push(this.margin)):(this.labelValues.push(t),this.labels.push(this.format(t)),this.labelPositions.push(this.margin+e))}addTickInfo(t,e,i,r){this.labels.push(this.format(t));let s=Math.floor((Math.log10(t)-i)/(Math.log10(e)-i)*r)+this.margin;this.labelPositions.push(s),this.labelValues.push(t)}updateLabelsForLinearScale(t,e,i,r){let s=eo==s&&(this.labelValues.push(t),this.labels.push(this.format(t)),this.labelPositions.push(this.margin));let a=1,h=Math.max(Math.abs(t),Math.abs(e));e/=h,t/=h,r/=h,o/=h;let l=e-t;for(let d=o;e>=t?de;d=o+a++*r){let n=d*h;this.labels.push(this.format(n)),this.labelValues.push(n);let p=Math.floor((d-t)/l*i)+this.margin;this.labelPositions.push(p)}e*=h,this.labelValues.push(e),this.labels.push(this.format(e)),this.labelPositions.push(this.margin+i)}updateVisibility(t){if(this.labelVisibilities=[],!this.labelPositions.length)return;for(let r=0;rl+this.tickLabelGap;let p=t.measureText(this.labels[this.labels.length-1],this.scaleFont);h=this.labelPositions[this.labelPositions.length-1]-i,l=Math.floor(this.horizontal?o.width/2+p.width/2:o.height),n=h>l+this.tickLabelGap}return d&&n}isMajorTick(t){if(!this.logScale)return!0;let e=Math.log10(t);return e===Math.round(e)}format(t){if(this.timeFormat===0)return this.scaleFormat?new Qt(this.scaleFormat).format(t):String(Number(t.toFixed(2)));let e=new Date(t),i=this.formatter;switch(this.timeFormat){case 1:return i.formatDate(e,{year:!0,month:!0,day:!0})+`
`+i.formatTime(e,{hours:!0,minutes:!0,seconds:!0,milliseconds:!1});case 2:return i.formatDate(e,{year:!0,month:!0,day:!0})+`
`+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=zc[r?e.getUTCMonth():e.getMonth()],o=r?e.getUTCDate():e.getDate();return`${s} ${o}`;case 8:let a=Math.abs(this.maximum-this.minimum);return a<=5e3?i.formatTime(e,{hours:!1,minutes:!1,seconds:!0,milliseconds:!0}):a<=18e5?i.formatTime(e,{hours:!0,minutes:!0,seconds:!0,milliseconds:!1}):a<=864e5?i.formatTime(e,{hours:!0,minutes:!0,seconds:!1,milliseconds:!1}):a<=6048e5?i.formatDate(e,{year:!1,month:!0,day:!0})+`
`+i.formatTime(e,{hours:!0,minutes:!0,seconds:!1,milliseconds:!1}):a<=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}},Qa="color_map",th="crop_bottom",eh="crop_left",ih="crop_right",rh="crop_top",sh="data_height",oh="data_width",ah="font",hh="graph_area_height",lh="graph_area_width",nh="maximum",dh="minimum",uh="show_ramp",ph="x_axis_axis_color",ch="x_axis_axis_title",gh="x_axis_major_tick_step_hint",mh="x_axis_maximum",fh="x_axis_minimum",xh="x_axis_scale_font",wh="x_axis_show_minor_ticks",yh="x_axis_title_font",vh="x_axis_visible",bh="y_axis_axis_color",Th="y_axis_axis_title",Sh="y_axis_major_tick_step_hint",Vh="y_axis_maximum",Ch="y_axis_minimum",Ah="y_axis_scale_font",_h="y_axis_show_minor_ticks",Lh="y_axis_title_font",Ph="y_axis_visible",Uc=class extends G{constructor(t,e){super(t,e),this.properties.add(new Fe(Qa)),this.properties.add(new b(th)),this.properties.add(new b(eh)),this.properties.add(new b(ih)),this.properties.add(new b(rh)),this.properties.add(new b(sh)),this.properties.add(new b(oh)),this.properties.add(new b(hh)),this.properties.add(new b(lh)),this.properties.add(new O(ah)),this.properties.add(new H(nh)),this.properties.add(new H(dh)),this.properties.add(new y(uh)),this.properties.add(new R(ph)),this.properties.add(new _(ch)),this.properties.add(new b(gh)),this.properties.add(new H(mh)),this.properties.add(new H(fh)),this.properties.add(new O(xh)),this.properties.add(new y(wh)),this.properties.add(new O(yh)),this.properties.add(new y(vh)),this.properties.add(new R(bh)),this.properties.add(new _(Th)),this.properties.add(new b(Sh)),this.properties.add(new H(Vh)),this.properties.add(new H(Ch)),this.properties.add(new O(Ah)),this.properties.add(new y(_h)),this.properties.add(new O(Lh)),this.properties.add(new y(Ph))}draw(t){let{scale:e}=this,i=this.area;this.borderAlarmSensitive&&(i=U(i,2*e));let r=this.alarmSensitiveBackgroundColor;t.fillRect(A(C({},i),{color:r}));let{graphAreaWidth:s,graphAreaHeight:o}=this,a=0;this.xAxisVisible&&(a=t.measureText(this.xAxisAxisTitle,this.xAxisTitleFont).height);let h=0;this.yAxisVisible&&(h=t.measureText(this.yAxisAxisTitle,this.yAxisTitleFont).height);let l=new Tt(this.display.formatter,e,this.xAxisScaleFont,this.xAxisMinimum,this.xAxisMaximum,!1,this.xAxisMajorTickStepHint,this.xAxisAxisColor,this.xAxisShowMinorTicks,this.xAxisVisible),d=l.calculateMargin(t,!0),n=new Tt(this.display.formatter,e,this.yAxisScaleFont,this.yAxisMinimum,this.yAxisMaximum,!1,this.yAxisMajorTickStepHint,this.yAxisAxisColor,this.yAxisShowMinorTicks,this.yAxisVisible),p=n.calculateMargin(t,!1),g=l.measureHorizontalHeight(t),v=o+2*p,w=n.drawVertical(t,i.x+h,i.y,v,!0),T=s+2*d,B=i.x+h+w-d,M=i.y+v+g-p;l.drawHorizontal(t,B,M,T);let k=e*1,W=Math.round(i.x+h+w)-k/2,D=Math.round(i.y+p)-k/2;t.strokePath({path:new S(W,D).lineTo(W,D+o),color:this.yAxisAxisColor,opacity:100/255,lineWidth:k});let N=W,K=D+o+k;t.strokePath({path:new S(N,K).lineTo(N+s,K),color:this.xAxisAxisColor,opacity:100/255,lineWidth:k});let{dataWidth:J,dataHeight:ht,colorMap:tt}=this,{minimum:lt,maximum:st}=this,[Rt,Gt]=tt.getMinMax();if(this.value&&this.value.length){let et=document.createElement("canvas"),{cropLeft:nt,cropRight:gt,cropTop:mt,cropBottom:Et}=this;et.width=J-nt-gt,et.height=ht-mt-Et;let St=et.getContext("2d");for(let ut=nt;ut2)for(let e=0;e{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.pv?.toNumber()??this.value):this.pv?.value!==void 0?(this.pv?.value>>this.bit&1)>0:this.value!==void 0?(this.value>>this.bit&1)>0:!1:this.dataType===1?(this.pv?.toString()??this.value)===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.pv?.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.pv?.value??this.value))return t.label;return this.stateLabelFallback}draw(t){let e=U(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 a=t.createLinearGradient(e.x,e.y,e.x+e.width,e.y+e.height);a.addColorStop(0,this.bulbBorderColor.toString()),a.addColorStop(1,this.bulbBorderColor.withAlpha(0).toString()),t.fillEllipse({cx:i,cy:r,rx:s,ry:o,gradient:a});let h=e.width-2*this.bulbBorder,l=e.height-2*this.bulbBorder;s=h/2,o=l/2,t.fillEllipse({cx:i,cy:r,rx:s,ry:o,color:this.bulbColor}),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.bulbBorderColor.withAlpha(0).toString()),t.fillEllipse({cx:i,cy:r,rx:s,ry:o,gradient:a}),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=Ft(e.x,e.y,e.width,e.height,this.bulbBorder);t.fillRect(A(C({},i),{color:this.bulbColor})),t.strokeRect(A(C({},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(A(C({},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 S(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 S(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 S(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 S(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,a=e.height-2*this.bulbBorder;t.fillRect({x:r,y:s,width:o,height:a,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:a,gradient:i})}get bit(){return this.properties.getValue(kh)}get dataType(){return this.properties.getValue(Mh)}get squareLed(){return this.properties.getValue(Wh)}get showBooleanLabel(){return this.properties.getValue(qh)}get font(){return this.properties.getValue(Dh).scale(this.scale)}get effect3d(){return this.properties.getValue(Rh)}get stateCount(){return this.properties.getValue(Eh)}get bulbBorder(){return this.scale*this.properties.getValue(Oh)}get bulbBorderColor(){return this.properties.getValue(Gh)}get offLabel(){return this.properties.getValue(Ih)}get offColor(){return this.properties.getValue(Bh)}get offState(){return this.properties.getValue(Hh)}get onLabel(){return this.properties.getValue(Fh)}get onColor(){return this.properties.getValue(Nh)}get onState(){return this.properties.getValue($h)}get stateLabelFallback(){return this.properties.getValue(Uh)}get stateColorFallback(){return this.properties.getValue(zh)}},Yc=16,Xc=12,Kc=-5,jc=45,le=$(jc),Yh=(1-Math.sin(le)/2)/(2*Math.cos(le)),Xh="color_hi",Kh="color_hihi",jh="color_lo",Zh="color_lolo",Jh="font",Qh="level_hi",tl="level_hihi",el="level_lo",il="level_lolo",rl="log_scale",sl="minimum",ol="maximum",al="needle_color",hl="ramp_gradient",ll="scale_font",nl="show_hi",dl="show_hihi",ul="show_lo",pl="show_lolo",cl="show_ramp",gl="value_label_format",Zc=class extends G{areaRegion;constructor(t,e){super(t,e),this.properties.add(new R(Xh)),this.properties.add(new R(Kh)),this.properties.add(new R(jh)),this.properties.add(new R(Zh)),this.properties.add(new O(Jh)),this.properties.add(new b(Qh)),this.properties.add(new b(tl)),this.properties.add(new b(el)),this.properties.add(new b(il)),this.properties.add(new y(rl)),this.properties.add(new b(ol)),this.properties.add(new b(sl)),this.properties.add(new R(al)),this.properties.add(new y(hl)),this.properties.add(new O(ll)),this.properties.add(new y(nl)),this.properties.add(new y(dl)),this.properties.add(new y(ul)),this.properties.add(new y(pl)),this.properties.add(new y(cl,!0)),this.properties.add(new _(gl))}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.showRamp&&this.drawRamp(t),this.pv&&this.pv.navigable&&!this.pv.disconnected&&t.addHitRegion(this.areaRegion).addRect(this.x,this.y,this.width,this.height)}drawRamp(t){let e=String(this.minimum),i=t.measureText(e,this.scaleFont),r=String(this.maximum),s=t.measureText(r,this.scaleFont),o=Math.max(i.width,s.width)/2,a=this.height,h=this.width;a>Yh*(h-2*o)&&(a=Math.floor(Yh*(h-2*o)));let l=a/(1-Math.sin(le)/2),d=Math.floor(this.x-l*(1-Math.cos(le))+o),n=this.y,p={x:d,y:n,width:Math.floor(2*l),height:Math.floor(2*l)},{rampWidth:g}=this,v=U(p,p.width/4-g,p.height/4-g);v.width=Math.min(v.width,v.height),v.height=v.width;let w=new Ud(g,135,45);w.lolo=this.levelLoLo,w.loloColor=this.colorLoLo,w.showLoLo=!0,w.lo=this.levelLo,w.loColor=this.colorLo,w.showLo=!0,w.hi=this.levelHi,w.hiColor=this.colorHi,w.showHi=!0,w.hihi=this.levelHiHi,w.hihiColor=this.colorHiHi,w.showHiHi=!0,w.minimum=this.minimum,w.maximum=this.maximum,w.gradient=this.rampGradient,w.logScale=this.logScale,w.draw(t,p,v),this.drawNeedle(t,p,w);let T=it.ARIAL_12_BOLD.scale(this.scale);if(this.pv&&this.pv.value!==void 0){let B=this.format(this.pv.value),M=t.measureText(B,T);t.fillText({x:p.x+p.width/2-M.width/2,y:p.y+p.height/2-p.height/4-(w.getRadius()-p.height/4)/2-M.height/2,align:"left",baseline:"top",font:T,text:B,color:this.foregroundColor})}}drawNeedle(t,e,i){let r=e.x+e.width/2,s=e.y+e.height/2,o;if(this.pv&&this.pv.value!==void 0){let v=i.getValueInRange(this.pv.value);o=360-i.getValuePosition(v),this.maximum>this.minimum?v>this.maximum?o+=8:vthis.minimum?o-=8:v2*w-n-2*h&&(g=2*w-n);let T=s.getValuePosition(this.getFillValue()),B=this.alarmSensitiveFillColor;if(this.effect3d){t.fillRect({x:l,y:d,width:n,height:p,rx:g/2,ry:g/2,color:m.WHITE});let k=t.createLinearGradient(l,d,l+w+2*a,d);k.addColorStop(0,this.colorFillbackground.toString()),k.addColorStop(1,m.WHITE.withAlpha(0).toString()),t.fillRect({x:l,y:d,width:w,height:p,rx:g/2,ry:g/2,gradient:k}),k=t.createLinearGradient(l+n-w-2*a,d,l+n,d),k.addColorStop(0,m.WHITE.withAlpha(0).toString()),k.addColorStop(1,this.colorFillbackground.toString()),t.fillRect({x:l+n-w,y:d,width:w,height:p,rx:g/2,ry:g/2,gradient:k});let W=T,D=d+p-T;k=t.createLinearGradient(l,W,l+w+2*a,W),k.addColorStop(0,B.toString()),k.addColorStop(1,m.WHITE.withAlpha(0).toString()),t.fillRect({x:l,y:W,width:w,height:D,rx:g/2,ry:g/2,gradient:k}),k=t.createLinearGradient(l+n-w-2*a,W,l+n,W),k.addColorStop(0,m.WHITE.withAlpha(0).toString()),k.addColorStop(1,B.toString()),t.fillRect({x:l+n-w,y:W,width:w,height:D,rx:g/2,ry:g/2,gradient:k})}else t.fillRect({x:l,y:d,width:n,height:p,rx:g/2,ry:g/2,color:this.colorFillbackground}),t.fillRect({x:l,y:T,width:n,height:d+p-T,rx:g/2,ry:g/2,color:B});let M=U({x:l,y:d,width:n,height:p},h/2);t.strokeRect(A(C({},M),{rx:g/2,ry:g/2,color:this.effect3d?Qc:o,lineWidth:h}))}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 m.RED;if(this.isMinorSeverity())return m.ORANGE}return this.fillColor}getFillValue(){let t=this.pv?.value??this.min;return t=Math.max(this.min,t),t=Math.min(this.max,t),t}get colorLo(){return this.properties.getValue(Zl)}get colorLoLo(){return this.properties.getValue(Jl)}get colorHi(){return this.properties.getValue(Kl)}get colorHiHi(){return this.properties.getValue(jl)}get colorFillbackground(){return this.properties.getValue(Ql)}get fillColorAlarmSensitive(){return this.properties.getValue(en)}get fillColor(){return this.properties.getValue(tn)}get effect3d(){return this.properties.getValue(rn)}get levelLo(){return this.properties.getValue(an)}get levelLoLo(){return this.properties.getValue(hn)}get levelHi(){return this.properties.getValue(sn)}get levelHiHi(){return this.properties.getValue(on)}get limitsFromPv(){return this.properties.getValue(ln)}get logScale(){return this.properties.getValue(nn)}get minimum(){return this.properties.getValue(pn)}get majorTickStepHint(){return this.scale*this.properties.getValue(un)}get maximum(){return this.properties.getValue(dn)}get scaleFont(){return this.properties.getValue(cn).scale(this.scale)}get scaleFormat(){return this.properties.getValue(gn)}get showLo(){return this.properties.getValue(xn)}get showLoLo(){return this.properties.getValue(wn)}get showHi(){return this.properties.getValue(mn)}get showHiHi(){return this.properties.getValue(fn)}get showMarkers(){return this.properties.getValue(yn)}get showMinorTicks(){return this.properties.getValue(vn)}get showScale(){return this.properties.getValue(bn)}get transparentBackground(){return this.properties.getValue(Tn)}},Sn="font",Vn="format_type",Cn="horizontal_alignment",An="precision",_n="precision_from_pv",Ln="show_units",Pn="vertical_alignment",eg=class extends G{areaRegion;constructor(t,e){super(t,e),this.properties.add(new O(Sn)),this.properties.add(new b(Vn)),this.properties.add(new b(Cn)),this.properties.add(new b(An)),this.properties.add(new y(_n)),this.properties.add(new y(Ln,!0)),this.properties.add(new b(Pn))}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){let e=t.ctx;this.backgroundAlarmSensitive&&this.alarm?t.fillRect(A(C({},this.area),{color:this.alarmSensitiveBackgroundColor})):this.transparent||t.fillRect(A(C({},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),e.fillStyle=this.alarmSensitiveForegroundColor.toString(),e.font=this.font.getFontString();let{scale:i}=this,r=this.area;this.borderAlarmSensitive&&(r=U(r,2*i,2*i));let s=r.x;this.horizAlignment===0?e.textAlign="start":this.horizAlignment===1?(s+=r.width/2,e.textAlign="center"):this.horizAlignment===2&&(s+=r.width,e.textAlign="end");let o=r.y;this.vertAlignment===0?e.textBaseline="top":this.vertAlignment===1?(o=o+r.height/2,e.textBaseline="middle"):this.vertAlignment===2&&(o=o+r.height,e.textBaseline="bottom");let a=this.text;if(this.pv?.value!==void 0){let h=this.precisionFromPV?this.pv.precision:this.precision;h===-1&&(h=this.pv.precision??-1),a=ae(this.pv.value,this.formatType,h)}else this.value!==void 0&&(a=ae(this.value,this.formatType,this.precision));this.showUnits&&this.pv?.units&&(a+=" "+this.pv.units),e.fillText(a,s,o)}get font(){return this.properties.getValue(Sn).scale(this.scale)}get formatType(){return this.properties.getValue(Vn)}get horizAlignment(){return this.properties.getValue(Cn)}get precision(){return this.properties.getValue(An)}get precisionFromPV(){return this.properties.getValue(_n)}get showUnits(){return this.properties.getValue(Ln)}get vertAlignment(){return this.properties.getValue(Pn)}},kn="color_hi",Mn="color_hihi",Rn="color_lo",En="color_lolo",Wn="color_fillbackground",Bn="fill_color",In="fillcolor_alarm_sensitive",Hn="font",Dn="effect_3d",Nn="level_hi",Fn="level_hihi",$n="level_lo",On="level_lolo",Gn="limits_from_pv",zn="log_scale",Un="maximum",qn="major_tick_step_hint",Yn="minimum",Xn="scale_font",Kn="scale_format",jn="show_bulb",Zn="show_hi",Jn="show_hihi",Qn="show_lo",td="show_lolo",ed="show_markers",id="show_minor_ticks",rd="show_scale",sd="transparent_background",od="unit",ad="value_label_format",hd=new m(160,160,160),ig=class extends G{constructor(t,e){super(t,e),this.properties.add(new R(kn)),this.properties.add(new R(Mn)),this.properties.add(new R(Rn)),this.properties.add(new R(En)),this.properties.add(new R(Wn)),this.properties.add(new R(Bn)),this.properties.add(new y(In,!1)),this.properties.add(new y(Dn)),this.properties.add(new H(Nn)),this.properties.add(new H(Fn)),this.properties.add(new H($n)),this.properties.add(new H(On)),this.properties.add(new y(Gn)),this.properties.add(new O(Hn)),this.properties.add(new y(zn)),this.properties.add(new H(Un)),this.properties.add(new H(qn)),this.properties.add(new H(Yn)),this.properties.add(new O(Xn)),this.properties.add(new _(Kn)),this.properties.add(new y(jn)),this.properties.add(new y(Zn)),this.properties.add(new y(Jn)),this.properties.add(new y(Qn)),this.properties.add(new y(td)),this.properties.add(new y(ed)),this.properties.add(new y(id)),this.properties.add(new y(rd)),this.properties.add(new y(sd)),this.properties.add(new b(od)),this.properties.add(new _(ad))}draw(t){let{scale:e,min:i,max:r}=this,s=this.area;this.borderAlarmSensitive&&(s=U(this.area,2*this.scale));let o=this.alarmSensitiveBackgroundColor,a=this.alarmSensitiveForegroundColor,h=this.alarmSensitiveFillColor;this.transparentBackground||t.fillRect(A(C({},s),{color:o}));let l=s.height;if(this.showBulb){let M=Math.min(s.width/2,this.bulbMaxDiameter);l=s.heighto?n>a?p-=10*r:no?p+=10*r:nnd&&(o=nd),o=Math.pow(10,o)}else{let a=Math.max(Math.abs(i),Math.abs(r));i/=a,r/=a;let h=t/a*e,l=1-e;s=(h+i*l)*a,o=(h+r*l)*a}this.effectiveMinimum=s,this.effectiveMaximum=o,this.widget.requestRepaint()}get autoScale(){return this.getValue("auto_scale")}get autoScaleTreshold(){return this.getValue("auto_scale_treshold")}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")}},At=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})}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;t0}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))}},og=class{constructor(t,e){this.widget=e,this.id=t}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 At(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=A(C({},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 At(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 At(i.getXAxes(),i.getYAxes());this.rangeZoomXAxes(e),r.saveState(),i.toolbar.addCommand(r)}break;case"vertical-zoom":if(e){let r=new At(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 At(e.getXAxes(),e.getYAxes());for(let s of e.getAxes()){let o=s.isHorizontal()?t.point.x:t.point.y,a=s.linearScale.getPositionValue(o);s.applyZoom(a,.1)}i.saveState(),e.toolbar.addCommand(i);break;case"zoom-out":let r=new At(e.getXAxes(),e.getYAxes());for(let s of e.getAxes()){let o=s.isHorizontal()?t.point.x:t.point.y,a=s.linearScale.getPositionValue(o);s.applyZoom(a,-.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 a=o.linearScale,h=a.getMinMax(),l=a.getValuePosition(h.start)+r,d=a.getValuePosition(h.stop)+r;o.effectiveMinimum=a.getPositionValue(l),o.effectiveMaximum=a.getPositionValue(d)}let s=e.dy-t.dy;if(s!==0)for(let o of i.getYAxes()){let a=o.linearScale,h=a.getMinMax(),l=a.getValuePosition(h.start)+s,d=a.getValuePosition(h.stop)+s;o.effectiveMinimum=a.getPositionValue(l),o.effectiveMaximum=a.getPositionValue(d)}}}},ag=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(e=>e!==void 0).sort((e,i)=>e.x-i.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)}}},hg=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 ag(t)}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{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:a}=s.display;this.historicalDataProvider=void 0,o&&this.yPV&&(this.historicalDataProvider=a.createHistoricalDataProvider(this.yPV,s)||void 0),this.traceData=new hg(t,e,i,r,o,this.historicalDataProvider),this.xPV&&(this.xPVInstance=a.createPV(this.xPV),this.xPVInstance.addListener(this.xPVListener)),this.yPV&&(this.yPVInstance=a.createPV(this.yPV),this.yPVInstance.addListener(this.yPVListener)),s.addPropertyListener(`trace_${this.i}_x_pv`,()=>{let h=a.createPV(this.xPV);h!==this.xPVInstance&&(this.xPVInstance?.removeListener(this.xPVListener),this.xPVInstance=h,this.xPVInstance.addListener(this.xPVListener))}),s.addPropertyListener(`trace_${this.i}_y_pv`,()=>{let h=a.createPV(this.yPV);h!==this.yPVInstance&&(this.yPVInstance?.removeListener(this.yPVListener),this.yPVInstance=h,this.yPVInstance.addListener(this.yPVListener))})}snapshot(){return this.traceData?.snapshot()||[]}drawTrace(t,e){let{lineWidth:i}=this;if(this.traceType===0)t.strokePath({path:S.fromPoints(e),color:this.traceColor,lineWidth:i});else if(this.traceType===1)t.strokePath({path:S.fromPoints(e),color:this.traceColor,lineWidth:i,dash:[6*this.scale,2*this.scale]});else if(this.traceType!==2){if(this.traceType===3){let r=this.widget.getAxis(this.yAxisIndex).linearScale.getValuePosition(0);for(let s of e)s.y!==null&&t.strokePath({path:new S(s.x,s.y).lineTo(s.x,r),lineWidth:i,color:this.traceColor,opacity:100/255})}else if(this.traceType===4||this.traceType===5){let r=this.widget.getAxis(this.yAxisIndex).linearScale.getValuePosition(0);for(let s=1;s{this.imageElement.onload=()=>o()}),this.disabledLoadPromise=new Promise((o,a)=>{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}}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}},pg=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 At(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)}buttons=[];showLegend;autoScale;rubberbandZoom;horizontalZoom;verticalZoom;zoomIn;zoomOut;panning;mouseArrow;undo;redo;camera;imagesLoaded=!1;currentTool="default";commandBuffer=new sg;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 ug(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 S(o,i).lineTo(o,i+r),color:dg,lineWidth:s})}drawButton(t,e,i,r){let{buttonSize:s,scale:o}=this;t.fillRect({x:e,y:i,width:s,height:s,color:ng}),this.xyGraph.enabled&&!r.disabled&&t.addHitRegion(r.region).addRect(e,i,s,s);let a=1*o,h=Math.round(i+a/2)-.5,l=Math.round(e+a/2)-.5,d=Math.round(i+s-a+a/2)-.5,n=Math.round(e+s-a+a/2)-.5;if(t.strokePath({color:r.pushed?m.WHITE:m.BLACK,path:new S(n,d).lineTo(n,h).moveTo(n,d).lineTo(l,d),lineWidth:a}),t.strokePath({color:r.pushed?m.BLACK:m.WHITE,path:new S(l,h).lineTo(n-a,h).moveTo(l,h).lineTo(l,d-a),lineWidth:a}),this.imagesLoaded){let p=r.disabled?r.disabledImageElement:r.imageElement,g=p.naturalHeight*o,v=p.naturalWidth*o,w=Math.round(e+(s-v)/2),T=Math.round(i+(s-g)/2);t.ctx.drawImage(p,w,T,v,g)}}get scale(){return this.xyGraph.scale}get buttonSize(){return 25*this.scale}},Me="axis_count",dd="plot_area_background_color",ud="show_legend",pd="show_plot_area_border",cd="show_toolbar",gd="title",md="title_font",Re="trace_count",fd="transparent",cg=class extends G{toolbar;plotAreaRegion;axes=[];traces=[];autoScaleAllowed=!0;constructor(t,e){super(t,e),this.properties.add(new b(Me)),this.properties.add(new R(dd)),this.properties.add(new y(ud)),this.properties.add(new y(pd)),this.properties.add(new y(cd)),this.properties.add(new _(gd)),this.properties.add(new O(md)),this.properties.add(new b(Re)),this.properties.add(new y(fd)),this.properties.addGenerator(()=>{let i=[];this.axes=[];let r=this.properties.getValue(Me);for(let o=0;o1&&i.push(new y(`axis_${o}_left_bottom_side`),new y(`axis_${o}_y_axis`));this.traces=[];let s=this.properties.getValue(Re);for(let o=0;ot.init())}draw(t){let{scale:e}=this,i=this.area;if(this.borderAlarmSensitive&&(i=U(this.area,2*e)),!this.transparent){let o=this.alarmSensitiveBackgroundColor;t.fillRect(A(C({},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 l={start:o.minimum,stop:o.maximum},d=this.calculateAutoscaledRange(o,l);d&&(o.effectiveMinimum=d.start,o.effectiveMaximum=d.stop)}let a=o.effectiveMinimum,h=o.effectiveMaximum;o.linearScale=new Tt(this.display.formatter,e,o.scaleFont,a,h,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,tp(r,s))}drawToolbar(t,e){this.toolbar||(this.toolbar=new pg(this));let i=3*this.scale,r=U(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=C({},e),o=0,a=0;for(let n of this.getXAxes())if(n.visible){let p=0;n.axisTitle&&(p=r+t.measureText(n.axisTitle,n.titleFont).height),o+=p,a+=p+n.linearScale.measureHorizontalHeight(t)}let h=0,l=0;for(let n of this.getYAxes().reverse()){let p=n.linearScale;if(n.visible){let g=p.calculateMargin(t,!1),v=s.height-a+(a>0?g:0),w=0;n.axisTitle&&(w=t.measureText(n.axisTitle,n.titleFont).height,t.ctx.save(),t.ctx.translate(s.x+r+w/2,e.y+v/2),t.ctx.rotate(-Math.PI/2),t.fillText({x:0,y:0,align:"center",baseline:"middle",font:n.titleFont,color:n.axisColor,text:n.axisTitle}),t.ctx.restore(),w+=r);let T=w+p.drawVertical(t,s.x+w,e.y,v,!0,!1);s.x+=T,s.width-=T,h+=T;let B=p.margin;l=l===0?B:Math.min(l,B);let M=i*1,k=Math.round(s.x)-M/2,W=Math.round(e.y+g)-M/2;t.strokePath({path:new S(k,W).lineTo(k,W+v-2*g),color:n.axisColor,opacity:100/255,lineWidth:M})}else{let g=s.height-a;p.setDimensions(0,e.y,g,!1)}}let d=0;for(let n of this.getXAxes().reverse()){let p=n.linearScale;if(n.visible){let g=p.calculateMargin(t,!0),v=h-g,w=0;if(n.axisTitle){w=t.measureText(n.axisTitle,n.titleFont).height;let D=e.x+h+(e.width-h)/2;t.fillText({x:D,y:s.y+s.height-w/2,align:"center",baseline:"middle",font:n.titleFont,color:n.axisColor,text:n.axisTitle}),w+=r}let T=w+p.drawHorizontal(t,e.x+v,s.y+s.height-w,e.width-v);s.height-=T;let B=p.margin;d=d===0?B:Math.min(d,B);let M=i*1,k=Math.round(e.x+v+g)-M/2,W=Math.round(s.y+s.height)-M/2;t.strokePath({path:new S(k,W).lineTo(k+s.width-g,W),color:n.axisColor,opacity:100/255,lineWidth:M})}else{let g=e.x+h,v=e.width-h;p.setDimensions(g,0,v,!0)}}return s.y+=l,s.width-=d,a>0?s.height-=l:s.height-=2*l,s}drawPlotArea(t,e){let{scale:i}=this,r=1*i;if(this.transparent||t.fillRect(A(C({},e),{color:this.plotAreaBackgroundColor})),this.showPlotAreaBorder){let{x:s,y:o,width:a,height:h}=U(e,r/2);t.strokePath({path:new S(s,o).lineTo(s+a,o).lineTo(s+a,o+h),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 a of o.getGridPositions()){let h=Math.round(o.getX()+a)-r/2;t.strokePath({path:new S(h,e.y).lineTo(h,e.y+e.height),color:s.gridColor,lineWidth:r,dash:s.dashGridLine?[6*i,2*i]:void 0})}else for(let a of o.getGridPositions()){let h=Math.round(o.getY()+a)-r/2;t.strokePath({path:new S(e.x,h).lineTo(e.x+e.width,h),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,a=this.getAxis(s.yAxisIndex).linearScale,h=[];for(let l of s.snapshot()){let d=o.getValuePosition(l.x),n=l.y!==null?a.getValuePosition(l.y):null;h.push({x:d,y:n})}if(h.length){s.drawTrace(t,h);for(let l of h)l.y!==null&&s.drawPoint(t,l)}}t.ctx.restore()}drawZoomSelection(t,e,i){let{scale:r}=this;switch(this.toolbar?.currentTool){case"rubberband-zoom":t.strokeRect(A(C({},i),{color:m.BLACK,lineWidth:1*r}));break;case"horizontal-zoom":let s=i;s.y=e.y,s.height=e.height,t.strokeRect(A(C({},xi(s)),{color:m.BLACK,lineWidth:1*r}));break;case"vertical-zoom":let o=i;o.x=e.x,o.width=e.width,t.strokeRect(A(C({},xi(o)),{color:m.BLACK,lineWidth:1*r}));break}}drawLegend(t,e){let{scale:i}=this,r=25*i,s=2*i,o=5*i,a=it.ARIAL_10.scale(i);for(let h of this.getYAxes()){let l=this.traces.filter(M=>M.visible&&M.yAxisIndex===h.index),d=[],n=[],p=0,g=0;for(let M of l){let k=r+s+o;M.name&&(k+=t.measureText(M.name,a).width),p+kMath.floor((r-o)/2)?Math.floor(r-o):N.pointSize;switch(N.traceType){case 3:let J=T+r/2;t.strokePath({path:new S(J,W+K).lineTo(J,W+r),lineWidth:N.lineWidth,color:N.traceColor,opacity:100/255}),N.drawPoint(t,{x:J,y:W+K});break;case 4:case 5:let ht=[{x:T,y:W+r/2},{x:T+r/2,y:W+K},{x:T+r,y:W+r/2},{x:T+r,y:W+r},{x:T,y:W+r}];t.fillPath({path:S.fromPoints(ht),color:N.traceColor,opacity:100/255}),N.traceType===5&&t.strokePath({path:S.fromPoints(ht.slice(0,3)),color:N.traceColor,lineWidth:1*i}),N.drawPoint(t,{x:T+r/2,y:W+K});break;default:N.drawTrace(t,[{x:T,y:D},{x:T+r,y:D}]),N.drawPoint(t,{x:T+r/2,y:D})}T+=r+s,N.name&&(t.fillText({x:T,y:D,align:"left",baseline:"middle",color:N.traceColor,font:a,text:N.name}),T+=t.measureText(N.name,a).width),T+=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 a of o.snapshot()){let h=t.isHorizontal()?a.x:a.y;h!==null&&((i===void 0||i>h)&&(!s||h>0)&&(i=h),(r===void 0||r0)&&(r=h))}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(Me)}get plotAreaBackgroundColor(){return this.properties.getValue(dd)}get showLegend(){return this.properties.getValue(ud)}get showPlotAreaBorder(){return this.properties.getValue(pd)}get showToolbar(){return this.properties.getValue(cd)}get title(){return this.properties.getValue(gd)}get titleFont(){return this.properties.getValue(md).scale(this.scale)}get traceCount(){return this.properties.getValue(Re)}get transparent(){return this.properties.getValue(fd)}destroy(){for(let t of this.traces)t.destroy()}},gg=class extends ue{parseNode(t){super.parseNode(t);for(let e of t.getNodes("widget")){let i=e.getString("widget_type"),r=this.display.createWidget(i,this);r&&(r.parseNode(e),this.widgets.push(r))}}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.createChild(this.width,this.height);for(let i of this.widgets.filter(r=>r.visible))i.drawHolder(e),i.draw(e),i.drawDecoration(e);for(let i of this.widgets.filter(r=>r.visible))i.drawOverlay(e);t.copy(e,this.x,this.y)}},xd="minimum_tab_height",Ne="active_tab",wd="horizontal_tabs",Ee="tab_count",mg=class{constructor(t,e){this.widget=t,this.i=e,this.headerRegion={id:`${t.wuid}-header-${e}`,click:()=>{t.activeTab!==e&&(t.properties.setValue(Ne,e),t.requestRepaint())},cursor:"pointer"}}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)}},yd=class extends ue{tabs=[];constructor(t,e){super(t,e),this.properties.add(new b(xd)),this.properties.add(new b(Ne)),this.properties.add(new y(wd)),this.properties.add(new b(Ee)),this.properties.addGenerator(()=>{this.tabs=[];let i=this.properties.getValue(Ee),r=[];for(let s=0;sr&&(r=a)}return r+this.margin}measureLabelWidth(t){let{scale:e}=this,i=1*e,r=this.minimumTabWidth;for(let s=0;sr&&(r=a)}return r+this.margin}drawHorizontalTabs(t){let{margin:e,gap:i,scale:r}=this,s=this.measureLabelHeight(t),o=1*r,a=this.x;for(let h=0;hi.text||""));return t}setContent(t){this.cells.length=0;for(let e=0;e({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(t=>t.text??null)]]}getCellText(t,e){let i=this.cells[t];return i?i[e]?.text??null:null}setColumnsCount(t){if(tthis.columnCount){let e=t-this.columnCount;for(let i of this.cells)for(let r=0;r{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{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 Np(this),this.consoleHandler=new Yu,this.dialogHandler=new Xu,window.setTimeout(()=>this.step()),new ju(this,e,this.g.hitCanvas)}rootPanel;g;ctx;pvEngine;pathResolver;fontResolver;consoleHandler;dialogHandler;formatter;repaintRequested=!1;_editMode=!1;_showGrid=!1;_showOutline=!1;_showRuler=!1;_selection=[];_scale=1;_transparent=!1;refreshCycle=100;imagesPrefix="";absPrefix="";relPrefix="";instance;eventListeners={closedisplay:[],opendisplay:[],openpv:[],runcommand:[],runprocedure:[],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}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.repaintRequested&&(this.g.clearHitCanvas(),this.drawScreen(),this.repaintRequested=!1),window.setTimeout(()=>this.step(),this.refreshCycle)}drawScreen(){if(this.instance?(this.rootPanel.style.height=this.instance.holderHeight+"px",this.rootPanel.style.width=this.instance.holderWidth+"px"):(this.rootPanel.style.height="0px",this.rootPanel.style.width="0px"),this.g.resize(this.rootPanel.clientWidth,this.rootPanel.clientHeight),this.transparent&&this.g.clearCanvas(),this.editMode){let t=document.createElement("canvas"),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="#d6d6d6",e.fillRect(0,0,8,8),e.fillRect(8,8,8,8),this.ctx.fillStyle=this.ctx.createPattern(t,"repeat"),this.ctx.fillRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.instance&&this.g.fillRect(A(C({},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.ctx.canvas.width,this.ctx.canvas.height),this.showGrid&&this.instance){let t=document.createElement("canvas"),e=t.getContext("2d");t.width=25,t.height=25,e.fillStyle=this.instance.foregroundColor.toString(),e.fillRect(0,0,2,1),this.ctx.fillStyle=this.ctx.createPattern(t,"repeat"),this.ctx.fillRect(25,25,this.ctx.canvas.width-50,this.ctx.canvas.height-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 t=0;for(;t<=this.ctx.canvas.width;)t+=100,this.ctx.beginPath(),this.ctx.moveTo(t-75+.5,this.ctx.canvas.height),this.ctx.lineTo(t-75+.5,this.ctx.canvas.height-4),this.ctx.moveTo(t-50+.5,this.ctx.canvas.height),this.ctx.lineTo(t-50+.5,this.ctx.canvas.height-6),this.ctx.moveTo(t-25+.5,this.ctx.canvas.height),this.ctx.lineTo(t-25+.5,this.ctx.canvas.height-4),this.ctx.moveTo(t+.5,this.ctx.canvas.height),this.ctx.lineTo(t+.5,this.ctx.canvas.height-8),this.ctx.stroke(),this.ctx.fillText(String(t),t,this.ctx.canvas.height-8);this.ctx.textAlign="right",this.ctx.textBaseline="middle";let e=0;for(;e<=this.ctx.canvas.height;)e+=100,this.ctx.beginPath(),this.ctx.moveTo(this.ctx.canvas.width,e-75+.5),this.ctx.lineTo(this.ctx.canvas.width-4,e-75+.5),this.ctx.moveTo(this.ctx.canvas.width,e-50+.5),this.ctx.lineTo(this.ctx.canvas.width-6,e-50+.5),this.ctx.moveTo(this.ctx.canvas.width,e-25+.5),this.ctx.lineTo(this.ctx.canvas.width-4,e-25+.5),this.ctx.moveTo(this.ctx.canvas.width,e+.5),this.ctx.lineTo(this.ctx.canvas.width-8,e+.5),this.ctx.stroke(),this.ctx.fillText(String(e),this.ctx.canvas.width-8,e)}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 t of this.selection){let e=this.findWidget(t);e&&e.drawSelection(this.ctx)}}requestRepaint(){this.repaintRequested=!0}setTooltip(t){this.rootPanel.title=t?.trim()??""}createWidget(t,e){switch(t){case yg:return new zd(this,e);case vg:return new Ac(this,e);case bg:return new rc(this,e);case Tg:return new sc(this,e);case Sg:return new Wc(this,e);case Vg:return new nc(this,e);case Cg:return new dc(this,e);case Ag:case _g:return new cc(this,e);case Lg:return new _c(this,e);case Pg:return new Oc(this,e);case kg:return new gg(this,e);case Mg:return new Lc(this,e);case Rg:return new gc(this,e);case Eg:return new Gc(this,e);case Wg:return new Uc(this,e);case Bg:return new Pc(this,e);case Ig:return new qc(this,e);case Hg:return new $d(this,e);case Dg:return new mc(this,e);case Ng:return new Zc(this,e);case Fg:return new fc(this,e);case $g:return new kc(this,e);case Og:return new Mc(this,e);case Gg:return new Jc(this,e);case zg:return new Tc(this,e);case Ug:return new Rc(this,e);case qg:return new Ec(this,e);case Yg:return new Sc(this,e);case Xg:return new yd(this,e);case Kg:return new xg(this,e);case jg:return new tg(this,e);case Zg:return new Cc(this,e);case Jg:return new eg(this,e);case Qg:return new ig(this,e);case tm:return new wg(this,e);case em:return new cg(this,e);default:console.warn(`Unsupported widget type: ${t}`)}}destroy(){this.instance?.destroy(),this.instance=void 0,this.pvEngine.clearState(),this.requestRepaint()}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(a=>{this.setSourceString(a,e),r()}).catch(a=>s(a))}).catch(o=>s(o))})}setSourceString(t,e){this.reset(),this.instance=new Fd(this,void 0,e);let i=Nd.parseFromXML(t);this.instance.parseNode(i),this.pvEngine.init(),this.requestRepaint()}getRefreshCycle(){return this.refreshCycle}setRefreshCycle(t){this.refreshCycle=t}reset(){this.instance&&(this.clearSelection(),this.pvEngine.clearState(),this.instance.destroy(),this.instance=void 0)}measureAbsoluteArea(t){let e=t.bounds,i=t.parent;for(;i;){if(e.x+=i.x,e.y+=i.y,i instanceof yd){let{x:r,y:s}=i.measureTabOffset(this.g);e.x+=r,e.y+=s}i=i.parent}return 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(i=>i(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 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 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){t||(t={x:0,y:0,width:this.g.canvas.width,height:this.g.canvas.height});let e=document.createElement("canvas");return e.width=t.width,e.height=t.height,e.getContext("2d").drawImage(this.g.canvas,t.x,t.y,t.width,t.height,0,0,t.width,t.height),e}toDataURL(t="image/png",e){return this.g.ctx.canvas.toDataURL(t,e)}};export{xp as a,Np as b,Gp as c,lm as d};




© 2015 - 2025 Weber Informatics LLC | Privacy Policy