@yamcs/opi 1.2.1 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +4 -6
  2. package/dist/images/Add_Annotation.png +0 -0
  3. package/dist/images/AutoScale.png +0 -0
  4. package/dist/images/Configure.png +0 -0
  5. package/dist/images/Del_Annotation.png +0 -0
  6. package/dist/images/HorizontalZoom.png +0 -0
  7. package/dist/images/MouseArrow.png +0 -0
  8. package/dist/images/Panning.png +0 -0
  9. package/dist/images/Redo.png +0 -0
  10. package/dist/images/Redo_Gray.png +0 -0
  11. package/dist/images/RubberbandZoom.png +0 -0
  12. package/dist/images/ShowLegend.png +0 -0
  13. package/dist/images/Undo.png +0 -0
  14. package/dist/images/Undo_Gray.png +0 -0
  15. package/dist/images/VerticalZoom.png +0 -0
  16. package/dist/images/ZoomIn.png +0 -0
  17. package/dist/images/ZoomOut.png +0 -0
  18. package/dist/images/camera.png +0 -0
  19. package/dist/opi.js +1 -1
  20. package/dist/opi.js.map +1 -1
  21. package/dist/opi.umd.js +1 -1
  22. package/dist/opi.umd.js.map +1 -1
  23. package/dist/types/AutoScaleWidgets.d.ts +6 -0
  24. package/dist/types/Color.d.ts +5 -0
  25. package/dist/types/ColorMap.d.ts +23 -0
  26. package/dist/types/DecimalFormat.d.ts +36 -0
  27. package/dist/types/Display.d.ts +23 -6
  28. package/dist/types/EventHandler.d.ts +10 -0
  29. package/dist/types/Graphics.d.ts +4 -1
  30. package/dist/types/HitCanvas.d.ts +1 -11
  31. package/dist/types/HitRegionSpecification.d.ts +15 -0
  32. package/dist/types/ImageResolver.d.ts +9 -0
  33. package/dist/types/Range.d.ts +4 -0
  34. package/dist/types/ScaleOptions.d.ts +6 -0
  35. package/dist/types/Widget.d.ts +15 -1
  36. package/dist/types/XMLNode.d.ts +2 -0
  37. package/dist/types/index.d.ts +3 -2
  38. package/dist/types/positioning.d.ts +1 -0
  39. package/dist/types/properties.d.ts +18 -0
  40. package/dist/types/pv/LocalPV.d.ts +2 -2
  41. package/dist/types/pv/PV.d.ts +1 -0
  42. package/dist/types/pv/PVEngine.d.ts +2 -0
  43. package/dist/types/scripting/ColorFontUtil.d.ts +13 -13
  44. package/dist/types/scripting/DataUtil.d.ts +6 -0
  45. package/dist/types/scripting/DisplayWrapper.d.ts +1 -2
  46. package/dist/types/scripting/GUIUtil.d.ts +8 -0
  47. package/dist/types/scripting/WidgetWrapper.d.ts +12 -0
  48. package/dist/types/scripting/XYGraphWrapper.d.ts +9 -0
  49. package/dist/types/scripting/utils.d.ts +3 -0
  50. package/dist/types/scripts.d.ts +2 -1
  51. package/dist/types/widgets/graphics/ImageWidget.d.ts +1 -0
  52. package/dist/types/widgets/monitors/IntensityGraph.d.ts +43 -0
  53. package/dist/types/widgets/monitors/LinearScale.d.ts +20 -1
  54. package/dist/types/widgets/monitors/Meter.d.ts +1 -0
  55. package/dist/types/widgets/monitors/ProgressBar.d.ts +3 -1
  56. package/dist/types/widgets/monitors/Tank.d.ts +2 -1
  57. package/dist/types/widgets/monitors/Thermometer.d.ts +3 -1
  58. package/dist/types/widgets/monitors/xygraph/Axis.d.ts +41 -0
  59. package/dist/types/widgets/monitors/xygraph/CommandBuffer.d.ts +26 -0
  60. package/dist/types/widgets/monitors/xygraph/PlotAreaRegion.d.ts +22 -0
  61. package/dist/types/widgets/monitors/xygraph/Trace.d.ts +38 -0
  62. package/dist/types/widgets/monitors/xygraph/TraceBuffer.d.ts +32 -0
  63. package/dist/types/widgets/monitors/xygraph/XYGraph.d.ts +44 -0
  64. package/dist/types/widgets/monitors/xygraph/XYGraphToolbar.d.ts +54 -0
  65. package/dist/types/widgets/others/LinkingContainer.d.ts +2 -0
  66. package/package.json +6 -8
package/dist/opi.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).opi={})}(this,(function(t){"use strict";class e{constructor(t,e,i,s=255){this.red=t,this.green=e,this.blue=i,this.alpha=s}withAlpha(t){return new e(this.red,this.green,this.blue,t)}mixWith(t,i){const s=Math.floor(this.red*i+t.red*(1-i)),r=Math.floor(this.green*i+t.green*(1-i)),o=Math.floor(this.blue*i+t.blue*(1-i));return new e(s,r,o)}brighter(){let t=this.red,i=this.green,s=this.blue;const r=Math.floor(1/(1-.7));return 0===t&&0===i&&0===s?new e(r,r,r):(t>0&&t<r&&(t=r),i>0&&i<r&&(i=r),s>0&&s<r&&(s=r),new e(Math.min(Math.floor(this.red/.7),255),Math.min(Math.floor(this.green/.7),255),Math.min(Math.floor(this.blue/.7),255)))}darker(){return new e(Math.max(Math.floor(.7*this.red),0),Math.max(Math.floor(.7*this.green),0),Math.max(Math.floor(.7*this.blue),0))}contrast(){return new e(this.red,255-this.green,255-this.blue)}toString(){return`rgba(${this.red},${this.green},${this.blue},${this.alpha})`}}e.TRANSPARENT=new e(0,0,0,0),e.BLACK=new e(0,0,0),e.BLUE=new e(0,0,255),e.CYAN=new e(0,255,255),e.DARK_GRAY=new e(150,150,150),e.GRAY=new e(200,200,200),e.GREEN=new e(0,255,0),e.LIGHT_BLUE=new e(153,186,243),e.ORANGE=new e(255,128,0),e.PINK=new e(255,0,255),e.PURPLE=new e(128,0,255),e.RED=new e(255,0,0),e.WHITE=new e(255,255,255),e.YELLOW=new e(255,255,0),e.BUTTON=new e(239,240,241),e.BUTTON_DARKER=new e(164,168,172),e.BUTTON_DARKEST=e.BLACK,e.BUTTON_LIGHTEST=e.WHITE;const i=t=>(document.removeEventListener("click",i,!0),t.preventDefault(),t.stopPropagation(),!1);function s(t){return 1==(1&t.buttons)||void 0===t.buttons&&1==t.which}function r(t,e){return t&&e&&t.id===e.id}class o{constructor(t,e,i){this.display=t,this.canvas=e,this.hitCanvas=i,this.grabbing=!1,this.documentMouseMoveListener=t=>this.onDocumentMouseMove(t),this.documentMouseUpListener=t=>this.onDocumentMouseUp(t),e.addEventListener("click",(t=>this.onCanvasClick(t)),!1),e.addEventListener("mousedown",(t=>this.onCanvasMouseDown(t)),!1),e.addEventListener("mouseup",(t=>this.onCanvasMouseUp(t)),!1),e.addEventListener("mouseout",(t=>this.onCanvasMouseOut(t)),!1),e.addEventListener("mousemove",(t=>this.onCanvasMouseMove(t)),!1)}toPoint(t){const e=this.canvas.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}}onCanvasClick(t){this.display.clearSelection();const e=this.toPoint(t);if(this.display.editMode)this.selectSingleWidget(e.x,e.y);else{const t=this.hitCanvas.getActiveRegion(e.x,e.y);t&&t.click&&t.click()}}onCanvasMouseDown(t){if(!this.display.editMode&&(document.removeEventListener("click",i,!0),s(t))){const e=this.toPoint(t),i=this.hitCanvas.getActiveRegion(e.x,e.y);return i&&i.mouseDown&&i.mouseDown(),i&&i.grab&&(this.grabPoint=Object.assign({},e),this.grabTarget=i),t.preventDefault(),t.stopPropagation(),!1}}onCanvasMouseUp(t){if(this.display.editMode)return;const e=this.toPoint(t),i=this.hitCanvas.getActiveRegion(e.x,e.y);i&&i.mouseUp&&i.mouseUp()}onCanvasMouseOut(t){}onCanvasMouseMove(t){const e=this.toPoint(t),i=this.hitCanvas.getActiveRegion(e.x,e.y);this.prevEnteredRegion&&this.prevEnteredRegion.mouseOut&&(r(this.prevEnteredRegion,i)||this.prevEnteredRegion.mouseOut()),i&&i.mouseEnter&&(r(this.prevEnteredRegion,i)||i.mouseEnter()),this.prevEnteredRegion=i;const o=i&&i.cursor?i.cursor:"auto";if(o!=this.canvas.style.cursor&&(this.canvas.style.cursor=o),this.grabPoint&&!this.grabbing&&s(t)){const t=(a=this.grabPoint.x,n=this.grabPoint.y,l=e.x,h=e.y,Math.sqrt((l-a)*(l-a)+(h-n)*(h-n)));Math.abs(t)>5&&(this.initiateGrab(),this.grabPoint&&(this.grabPoint=e))}var a,n,l,h;this.grabbing&&this.grabTarget&&s(t)&&this.grabTarget.grab(e.x-this.grabPoint.x,e.y-this.grabPoint.y)}initiateGrab(){document.addEventListener("click",i,!0),document.addEventListener("mouseup",this.documentMouseUpListener),document.addEventListener("mousemove",this.documentMouseMoveListener),this.grabbing=!0}onDocumentMouseUp(t){this.grabbing&&(document.removeEventListener("mouseup",this.documentMouseUpListener),document.removeEventListener("mousemove",this.documentMouseMoveListener),this.grabbing=!1,this.grabPoint=void 0,this.grabTarget=void 0)}onDocumentMouseMove(t){this.onCanvasMouseMove(t)}selectSingleWidget(t,e){const i=this.display.instance;if(i)for(const s of i.widgets.slice().reverse()){const i=s.holderX,r=s.holderY,o=s.holderX+s.holderWidth,a=s.holderY+s.holderHeight;if(i<t&&t<o&&r<e&&e<a)return this.display.selection=[s.wuid],!1}}}const a="rgb(255,255,255)";class n{constructor(t,e,i){this.parent=t,this.regions={};const s=document.createElement("canvas");s.width=null!=e?e:s.width,s.height=null!=i?i:s.height,this.ctx=s.getContext("2d"),this.root=(null==t?void 0:t.root)||t}clear(){this.regions={},this.ctx.fillStyle=a,this.ctx.fillRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height)}beginHitRegion(t){const e=(this.root||this).generateUniqueColor();return(this.root||this).regions[e]=t,this.ctx.beginPath(),this.ctx.fillStyle=e,e}getActiveRegion(t,e){const i=this.ctx.getImageData(t,e,1,1).data,s=`rgb(${i[0]},${i[1]},${i[2]})`;return this.regions[s]||void 0}createChild(t,e){return new n(this,t,e)}transferToParent(t,e,i,s){if(!this.parent)throw new Error("No parent to transfer to");this.parent.ctx.drawImage(this.ctx.canvas,t,e,i,s)}generateUniqueColor(){for(;;){const t=`rgb(${Math.round(255*Math.random())},${Math.round(255*Math.random())},${Math.round(255*Math.random())})`;if(!this.regions[t]&&t!=a)return t}}}function l(t,e,i,s,r){return d({x:t,y:e,width:i,height:s},r/2)}function h(t,e,i,s,r){const o=Math.sin(r),a=Math.cos(r),n=t-i,l=e-s;return{x:n*a-l*o+i,y:n*o+l*a+s}}function d(t,e,i){return void 0===i&&(i=e),{x:t.x+i,y:t.y+e,width:t.width-(i+i),height:t.height-(e+e)}}function c(t,e,i){return{x:t.x+e,y:t.y+i}}function p(t,e,i){return t.map((t=>c(t,e,i)))}function u(t){return t*Math.PI/180}function g(t,e,i){const s=Math.floor(t*Math.cos(e)),r=Math.floor(-t*Math.sin(e));return{x:i.x+i.width/2+s,y:i.y+i.height/2+r}}function f(t,e){const i=e.x-t.x,s=e.y-t.y,r=Math.sqrt(Math.pow(i,2)+Math.pow(s,2));let o=Math.acos(i/r);return s>0&&(o=2*Math.PI-o),new m(Math.floor(r),o)}class m{constructor(t,e){this.r=t,this.theta=e}toPoint(){return{x:Math.floor(this.r*Math.cos(this.theta)),y:Math.floor(-this.r*Math.sin(this.theta))}}}function y(t,e){return t.map((t=>({x:t.x*e,y:t.y*e})))}function x(t,e,i,s,r,o,a){t.beginPath(),o||a?(s<2*o&&(o=s/2),r<2*a&&(a=r/2),t.moveTo(e+o,i),t.lineTo(e+s-o,i),t.quadraticCurveTo(e+s,i,e+s,i+a),t.lineTo(e+s,i+r-a),t.quadraticCurveTo(e+s,i+r,e+s-o,i+r),t.lineTo(e+o,i+r),t.quadraticCurveTo(e,i+r,e,i+r-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+o,i)):t.rect(e,i,s,r)}class v{constructor(t,e){this.canvas=t,this.ctx=t.getContext("2d"),this.hitCanvas=e||new n,this.hitCtx=this.hitCanvas.ctx}createChild(t,e){const i=this.hitCanvas.createChild(t,e),s=document.createElement("canvas");return s.width=t,s.height=e,new v(s,i)}translate(t,e){this.ctx.translate(t,e),this.hitCtx.translate(t,e)}copy(t,e,i){this.ctx.drawImage(t.canvas,e,i),t.hitCanvas.transferToParent(e,i,t.canvas.width,t.canvas.height)}copyFitted(t,e,i,s,r){const{width:o,height:a}=t.canvas,n=o/a;let l=s,h=l/n;h>r&&(h=r,l=h*n),this.copyScaled(t,e,i,l,h)}copyScaled(t,e,i,s,r){this.ctx.drawImage(t.canvas,e,i,s,r),t.hitCanvas.transferToParent(e,i,s,r)}clearHitCanvas(){this.hitCanvas.clear()}fillCanvas(t){this.ctx.fillStyle=t.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(t,e){this.ctx.canvas.style.width=t+"px",this.ctx.canvas.style.height=e+"px"}resize(t,e){this.ctx.canvas.width==t&&this.ctx.canvas.height==e||(this.ctx.canvas.width=t,this.ctx.canvas.height=e,this.hitCanvas.ctx.canvas.width=t,this.hitCanvas.ctx.canvas.height=e)}fillRect(t){this.ctx.fillStyle="color"in t?t.color.toString():t.gradient,void 0!==t.opacity&&(this.ctx.globalAlpha=t.opacity),t.rx||t.ry?(x(this.ctx,t.x,t.y,t.width,t.height,t.rx||0,t.ry||0),this.ctx.fill()):this.ctx.fillRect(t.x,t.y,t.width,t.height),void 0!==t.opacity&&(this.ctx.globalAlpha=1)}fillText(t){this.ctx.textBaseline=t.baseline,this.ctx.textAlign=t.align,this.ctx.font=t.font.getFontString(),this.ctx.fillStyle=t.color.toString(),this.ctx.fillText(t.text,t.x,t.y)}fillEllipse(t){this.ctx.beginPath();const e=t.startAngle||0,i=void 0===t.endAngle?2*Math.PI:t.endAngle;this.ctx.ellipse(t.cx,t.cy,t.rx,t.ry,0,e,i,t.anticlockwise),this.ctx.fillStyle="color"in t?t.color.toString():t.gradient,void 0!==t.opacity&&(this.ctx.globalAlpha=t.opacity),this.ctx.fill(),void 0!==t.opacity&&(this.ctx.globalAlpha=1)}strokeEllipse(t){t.dash&&this.ctx.setLineDash(t.dash),this.ctx.lineWidth=t.lineWidth||1,this.ctx.beginPath();const e=t.startAngle||0,i=void 0===t.endAngle?2*Math.PI:t.endAngle;this.ctx.ellipse(t.cx,t.cy,t.rx,t.ry,0,e,i,t.anticlockwise),this.ctx.strokeStyle="color"in t?t.color.toString():t.gradient,this.ctx.stroke(),t.dash&&this.ctx.setLineDash([])}measureText(t,e){this.ctx.font=e.getFontString();return{width:this.ctx.measureText(t).width,height:e.height}}createLinearGradient(t,e,i,s){return this.ctx.createLinearGradient(t,e,i,s)}strokeRect(t){t.dash&&this.ctx.setLineDash(t.dash);const e=t.lineWidth||1;if(this.ctx.lineWidth=e,this.ctx.strokeStyle=t.color.toString(),t.crispen&&e){const i=d(t,e/2,e/2);t.rx||t.ry?(x(this.ctx,i.x,i.y,i.width,i.height,t.rx||0,t.ry||0),this.ctx.stroke()):this.ctx.strokeRect(i.x,i.y,i.width,i.height)}else t.rx||t.ry?(x(this.ctx,t.x,t.y,t.width,t.height,t.rx||0,t.ry||0),this.ctx.stroke()):this.ctx.strokeRect(t.x,t.y,t.width,t.height);t.dash&&this.ctx.setLineDash([])}strokePath(t){t.dash&&this.ctx.setLineDash(t.dash),this.ctx.beginPath();for(const e of t.path.segments)e.line?this.ctx.lineTo(e.x,e.y):this.ctx.moveTo(e.x,e.y);this.ctx.lineWidth=t.lineWidth||1,this.ctx.strokeStyle=t.color.toString(),void 0!==t.opacity&&(this.ctx.globalAlpha=t.opacity),this.ctx.stroke(),void 0!==t.opacity&&(this.ctx.globalAlpha=1),t.dash&&this.ctx.setLineDash([])}fillPath(t){this.ctx.beginPath();for(const e of t.path.segments)e.line?this.ctx.lineTo(e.x,e.y):this.ctx.moveTo(e.x,e.y);this.ctx.fillStyle="color"in t?t.color.toString():t.gradient,this.ctx.fill("evenodd")}addHitRegion(t){return this.hitCanvas.beginHitRegion(t),new b(this.hitCanvas.ctx)}}class w{constructor(t,e){this.segments=[],this.segments.push({x:t,y:e,line:!1})}static fromPoints(t){const e=new w(t[0].x,t[0].y);for(let i=1;i<t.length;i++)e.lineTo(t[i].x,t[i].y);return e}getBoundingBox(){const t={x:this.segments[0].x,y:this.segments[0].y},e={x:this.segments[0].x,y:this.segments[0].y};for(let i=0;i<this.segments.length;i++){const s=this.segments[i];s.x<t.x&&(t.x=s.x),s.x>e.x&&(e.x=s.x),s.y<t.y&&(t.y=s.y),s.y>e.y&&(e.y=s.y)}return{x:t.x,y:t.y,width:e.x-t.x,height:e.y-t.y}}lineTo(t,e){return this.segments.push({x:t,y:e,line:!0}),this}moveTo(t,e){return this.segments.push({x:t,y:e,line:!1}),this}closePath(){const t=this.segments[0];return this.segments.push({x:t.x,y:t.y,line:!0}),this}translate(t,e){for(const i of this.segments)i.x+=t,i.y+=e;return this}}class b{constructor(t){this.ctx=t}addRect(t,e,i,s){return this.ctx.fillRect(t,e,i,s),this}addEllipse(t,e,i,s,r,o,a,n){this.ctx.beginPath(),this.ctx.ellipse(t,e,i,s,r,o,a,n),this.ctx.fill()}addPath(t){this.ctx.beginPath();for(const e of t.segments)e.line?this.ctx.lineTo(e.x,e.y):this.ctx.moveTo(e.x,e.y);this.ctx.fill()}}class _{constructor(t,e){this.pvName=t,this.formula=e,this.pvValues=new Map}updateDataSource(t,e){this.pvValues.set(t,e)}clearState(){this.pvValues.clear()}getPVNames(){const t=this.formula.expression,e=[];return this.getExpressionParameters(t,e),e}getExpressionParameters(t,e){switch(t.type){case"ParameterLiteral":-1===e.indexOf(t.value)&&e.push(t.value);break;case"ConditionalExpression":this.getExpressionParameters(t.consequent,e),t.alternate&&this.getExpressionParameters(t.alternate,e);break;case"BinaryExpression":case"LogicalExpression":this.getExpressionParameters(t.left,e),this.getExpressionParameters(t.right,e);break;case"UnaryExpression":this.getExpressionParameters(t.argument,e);break;case"CallExpression":for(const i of t.arguments)this.getExpressionParameters(i,e)}}execute(){const t=this.formula.expression;return this.executeExpression(t)}executeExpression(t){switch(t.type){case"BooleanLiteral":return t.value;case"ParameterLiteral":const e=this.pvValues.get(t.value);return e?e.value:void 0;case"ConstantLiteral":case"NumericLiteral":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){const 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<i;case">=":return e>=i;case">":return e>i;default:throw new Error(`Unexpected binary operator ${t.operator}`)}}executeLogicalExpression(t){const 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){const e=this.executeExpression(t.test),i=this.executeExpression(t.consequent);if(void 0===t.alternate)return e?i:null;{const s=this.executeExpression(t.alternate);return e?i:s}}executeUnaryExpression(t){const 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){const e=t.callee.name,i=[];for(const e of t.arguments)i.push(this.executeExpression(e));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 180*i[0]/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){const e=this.pvValues.get(t);if(e)return e.acquisitionStatus}}function S(t,e,i,s){var r=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(r,S.prototype),r.expected=e,r.found=i,r.location=s,r.name="SyntaxError",r}function T(t,e,i){return i=i||" ",t.length>e?t:(e-=t.length,t+(i+=i.repeat(e)).slice(0,e))}function C(t,e){var i,s,r,o,a={},n=(e=void 0!==e?e:{}).grammarSource,l={Start:Et},h=Et,d=".",c='"',p="'",u="-",g="+",f=",",m="<=",y=">=",x="==",v="!=",w="&&",b="||",_=/^[a-zA-Z]/,T=/^[a-zA-Z0-9_]/,C=/^[0-9]/,L=/^[1-9]/,A=/^[^\n\r\f"]/,k=/^[^\n\r\f']/,P=Ct("=",!1),R=Ct(" ",!1),E=Ct("\t",!1),M=Ct("false",!0),V=Ct("true",!0),O=Ct("PI",!0),N=Ct("E",!0),D=At("identifier"),I=Lt([["a","z"],["A","Z"]],!1,!1),W=Ct("_",!1),H=Lt([["a","z"],["A","Z"],["0","9"],"_"],!1,!1),B=At("boolean"),F=At("constant"),G=At("number"),Y=Ct(".",!1),z=Ct("0",!1),U=Lt([["0","9"]],!1,!1),$=Lt([["1","9"]],!1,!1),j=At("string"),X=Ct('"',!1),q=Lt(["\n","\r","\f",'"'],!0,!1),Z=At("parameter"),K=Ct("'",!1),J=Lt(["\n","\r","\f","'"],!0,!1),Q=Ct("(",!1),tt=Ct(")",!1),et=Ct("-",!1),it=Ct("+",!1),st=Ct(",",!1),rt=Ct("*",!1),ot=Ct("/",!1),at=Ct("^",!1),nt=Ct("%",!1),lt=Ct("<=",!1),ht=Ct(">=",!1),dt=Ct("<",!1),ct=Ct(">",!1),pt=Ct("==",!1),ut=Ct("!=",!1),gt=Ct("&&",!1),ft=Ct("||",!1),mt=function(){return{type:"NumericLiteral",value:parseFloat(t.substring(wt,vt))}},yt=function(t,e){return function(t,e,i){return[t].concat(function(t,e){return t.map((function(t){return t[e]}))}(e,i))}(t,e,3)},xt=function(t,e){return function(t,e){return e.reduce((function(t,e){return{type:"BinaryExpression",operator:e[1],left:t,right:e[3]}}),t)}(t,e)},vt=0,wt=0,bt=[{line:1,column:1}],_t=0,St=[],Tt=0;if("startRule"in e){if(!(e.startRule in l))throw new Error("Can't start parsing from rule \""+e.startRule+'".');h=l[e.startRule]}function Ct(t,e){return{type:"literal",text:t,ignoreCase:e}}function Lt(t,e,i){return{type:"class",parts:t,inverted:e,ignoreCase:i}}function At(t){return{type:"other",description:t}}function kt(e){var i,s=bt[e];if(s)return s;for(i=e-1;!bt[i];)i--;for(s={line:(s=bt[i]).line,column:s.column};i<e;)10===t.charCodeAt(i)?(s.line++,s.column=1):s.column++,i++;return bt[e]=s,s}function Pt(t,e){var i=kt(t),s=kt(e);return{source:n,start:{offset:t,line:i.line,column:i.column},end:{offset:e,line:s.line,column:s.column}}}function Rt(t){vt<_t||(vt>_t&&(_t=vt,St=[]),St.push(t))}function Et(){var e,i,s;return e=vt,61===t.charCodeAt(vt)?(i="=",vt++):(i=a,0===Tt&&Rt(P)),i!==a?(Mt(),(s=function(){var t,e;t=vt,(e=Ut())!==a&&(wt=t,e={type:"Formula",expression:e});return t=e}())!==a?(Mt(),wt=e,e=s):(vt=e,e=a)):(vt=e,e=a),e}function Mt(){var t,e;for(t=[],e=Vt();e!==a;)t.push(e),e=Vt();return t}function Vt(){var e;return 32===t.charCodeAt(vt)?(e=" ",vt++):(e=a,0===Tt&&Rt(R)),e===a&&(9===t.charCodeAt(vt)?(e="\t",vt++):(e=a,0===Tt&&Rt(E))),e}function Ot(){var e,i;return e=vt,(i=function(){var e,i,s,r;if(Tt++,e=vt,(i=function(){var e;_.test(t.charAt(vt))?(e=t.charAt(vt),vt++):(e=a,0===Tt&&Rt(I));e===a&&(95===t.charCodeAt(vt)?(e="_",vt++):(e=a,0===Tt&&Rt(W)));return e}())!==a){for(s=[],r=Nt();r!==a;)s.push(r),r=Nt();wt=e,e={type:"Symbol",name:i+s.join("")}}else vt=e,e=a;Tt--,e===a&&(i=a,0===Tt&&Rt(D));return e}())!==a&&(wt=e,i=i),e=i}function Nt(){var e;return T.test(t.charAt(vt))?(e=t.charAt(vt),vt++):(e=a,0===Tt&&Rt(H)),e}function Dt(){var e;return(e=function(){var e,i;Tt++,e=vt,(i=function(){var e;return"true"===t.substr(vt,4).toLowerCase()?(e=t.substr(vt,4),vt+=4):(e=a,0===Tt&&Rt(V)),e}())!==a&&(wt=e,i={type:"BooleanLiteral",value:!0});(e=i)===a&&(e=vt,(i=function(){var e;return"false"===t.substr(vt,5).toLowerCase()?(e=t.substr(vt,5),vt+=5):(e=a,0===Tt&&Rt(M)),e}())!==a&&(wt=e,i={type:"BooleanLiteral",value:!1}),e=i);Tt--,e===a&&(i=a,0===Tt&&Rt(B));return e}())===a&&(e=function(){var e,i;Tt++,e=vt,(i=function(){var e;return"pi"===t.substr(vt,2).toLowerCase()?(e=t.substr(vt,2),vt+=2):(e=a,0===Tt&&Rt(O)),e}())!==a&&(wt=e,i={type:"ConstantLiteral",value:Math.PI});(e=i)===a&&(e=vt,(i=function(){var e;return"e"===t.substr(vt,1).toLowerCase()?(e=t.charAt(vt),vt++):(e=a,0===Tt&&Rt(N)),e}())!==a&&(wt=e,i={type:"ConstantLiteral",value:Math.E}),e=i);Tt--,e===a&&(i=a,0===Tt&&Rt(F));return e}())===a&&(e=function(){var e,i,s,r,o;if(Tt++,e=vt,(i=It())!==a)if(46===t.charCodeAt(vt)?(s=d,vt++):(s=a,0===Tt&&Rt(Y)),s!==a){for(r=[],o=Wt();o!==a;)r.push(o),o=Wt();wt=e,e=mt()}else vt=e,e=a;else vt=e,e=a;if(e===a){if(e=vt,46===t.charCodeAt(vt)?(i=d,vt++):(i=a,0===Tt&&Rt(Y)),i!==a){if(s=[],(r=Wt())!==a)for(;r!==a;)s.push(r),r=Wt();else s=a;s!==a?(wt=e,e=mt()):(vt=e,e=a)}else vt=e,e=a;e===a&&(e=vt,(i=It())!==a&&(wt=e,i=mt()),e=i)}Tt--,e===a&&(i=a,0===Tt&&Rt(G));return e}())===a&&(e=function(){var e,i,s,r;Tt++,e=vt,34===t.charCodeAt(vt)?(i=c,vt++):(i=a,0===Tt&&Rt(X));if(i!==a){for(s=[],A.test(t.charAt(vt))?(r=t.charAt(vt),vt++):(r=a,0===Tt&&Rt(q));r!==a;)s.push(r),A.test(t.charAt(vt))?(r=t.charAt(vt),vt++):(r=a,0===Tt&&Rt(q));34===t.charCodeAt(vt)?(r=c,vt++):(r=a,0===Tt&&Rt(X)),r!==a?(wt=e,e={type:"StringLiteral",value:s.join("")}):(vt=e,e=a)}else vt=e,e=a;Tt--,e===a&&(i=a,0===Tt&&Rt(j));return e}())===a&&(e=function(){var e,i,s,r;Tt++,e=vt,39===t.charCodeAt(vt)?(i=p,vt++):(i=a,0===Tt&&Rt(K));if(i!==a){for(s=[],k.test(t.charAt(vt))?(r=t.charAt(vt),vt++):(r=a,0===Tt&&Rt(J));r!==a;)s.push(r),k.test(t.charAt(vt))?(r=t.charAt(vt),vt++):(r=a,0===Tt&&Rt(J));39===t.charCodeAt(vt)?(r=p,vt++):(r=a,0===Tt&&Rt(K)),r!==a?(wt=e,e={type:"ParameterLiteral",value:s.join("")}):(vt=e,e=a)}else vt=e,e=a;Tt--,e===a&&(i=a,0===Tt&&Rt(Z));return e}()),e}function It(){var e,i,s,r;if(48===t.charCodeAt(vt)?(e="0",vt++):(e=a,0===Tt&&Rt(z)),e===a)if(e=vt,(i=function(){var e;L.test(t.charAt(vt))?(e=t.charAt(vt),vt++):(e=a,0===Tt&&Rt($));return e}())!==a){for(s=[],r=Wt();r!==a;)s.push(r),r=Wt();e=i=[i,s]}else vt=e,e=a;return e}function Wt(){var e;return C.test(t.charAt(vt))?(e=t.charAt(vt),vt++):(e=a,0===Tt&&Rt(U)),e}function Ht(){var e,i,s;return(e=function(){var e,i,s,r;return(e=Dt())===a&&(e=vt,40===t.charCodeAt(vt)?(i="(",vt++):(i=a,0===Tt&&Rt(Q)),i!==a?(Mt(),(s=Ut())!==a?(Mt(),41===t.charCodeAt(vt)?(r=")",vt++):(r=a,0===Tt&&Rt(tt)),r!==a?(wt=e,e=s):(vt=e,e=a)):(vt=e,e=a)):(vt=e,e=a)),e}())===a&&(e=vt,(i=function(){var e;45===t.charCodeAt(vt)?(e=u,vt++):(e=a,0===Tt&&Rt(et));e===a&&(43===t.charCodeAt(vt)?(e=g,vt++):(e=a,0===Tt&&Rt(it)));return e}())!==a?(Mt(),(s=Ht())!==a?(Mt(),wt=e,e={type:"UnaryExpression",operator:i,argument:s}):(vt=e,e=a)):(vt=e,e=a)),e}function Bt(){var e,i,s;return e=vt,(i=Ot())!==a?(Mt(),(s=function(){var e,i,s,r;e=vt,40===t.charCodeAt(vt)?(i="(",vt++):(i=a,0===Tt&&Rt(Q));i!==a?(Mt(),s=vt,(r=function(){var e,i,s,r,o,n,l,h;if(e=vt,(i=Ut())!==a){for(s=[],r=vt,o=Mt(),44===t.charCodeAt(vt)?(n=f,vt++):(n=a,0===Tt&&Rt(st)),n!==a?(l=Mt(),(h=Ut())!==a?r=o=[o,n,l,h]:(vt=r,r=a)):(vt=r,r=a);r!==a;)s.push(r),r=vt,o=Mt(),44===t.charCodeAt(vt)?(n=f,vt++):(n=a,0===Tt&&Rt(st)),n!==a?(l=Mt(),(h=Ut())!==a?r=o=[o,n,l,h]:(vt=r,r=a)):(vt=r,r=a);wt=e,e=yt(i,s)}else vt=e,e=a;return e}())!==a?s=r=[r,Mt()]:(vt=s,s=a),s===a&&(s=null),41===t.charCodeAt(vt)?(r=")",vt++):(r=a,0===Tt&&Rt(tt)),r!==a?(wt=e,l=0,e=null!==(o=(n=s)?n[l]:null)?o:[]):(vt=e,e=a)):(vt=e,e=a);var o,n,l;return e}())!==a?(wt=e,e={type:"CallExpression",callee:i,arguments:s}):(vt=e,e=a)):(vt=e,e=a),e===a&&(e=Ht()),e}function Ft(){var e,i,s,r,o,n,l,h;if(e=vt,(i=Bt())!==a){for(s=[],r=vt,o=Mt(),42===t.charCodeAt(vt)?(n="*",vt++):(n=a,0===Tt&&Rt(rt)),n===a&&(47===t.charCodeAt(vt)?(n="/",vt++):(n=a,0===Tt&&Rt(ot)),n===a&&(94===t.charCodeAt(vt)?(n="^",vt++):(n=a,0===Tt&&Rt(at)),n===a&&(37===t.charCodeAt(vt)?(n="%",vt++):(n=a,0===Tt&&Rt(nt))))),n!==a?(l=Mt(),(h=Bt())!==a?r=o=[o,n,l,h]:(vt=r,r=a)):(vt=r,r=a);r!==a;)s.push(r),r=vt,o=Mt(),42===t.charCodeAt(vt)?(n="*",vt++):(n=a,0===Tt&&Rt(rt)),n===a&&(47===t.charCodeAt(vt)?(n="/",vt++):(n=a,0===Tt&&Rt(ot)),n===a&&(94===t.charCodeAt(vt)?(n="^",vt++):(n=a,0===Tt&&Rt(at)),n===a&&(37===t.charCodeAt(vt)?(n="%",vt++):(n=a,0===Tt&&Rt(nt))))),n!==a?(l=Mt(),(h=Bt())!==a?r=o=[o,n,l,h]:(vt=r,r=a)):(vt=r,r=a);wt=e,e=xt(i,s)}else vt=e,e=a;return e}function Gt(){var e,i,s,r,o,n,l,h;if(e=vt,(i=Ft())!==a){for(s=[],r=vt,o=Mt(),43===t.charCodeAt(vt)?(n=g,vt++):(n=a,0===Tt&&Rt(it)),n===a&&(45===t.charCodeAt(vt)?(n=u,vt++):(n=a,0===Tt&&Rt(et))),n!==a?(l=Mt(),(h=Ft())!==a?r=o=[o,n,l,h]:(vt=r,r=a)):(vt=r,r=a);r!==a;)s.push(r),r=vt,o=Mt(),43===t.charCodeAt(vt)?(n=g,vt++):(n=a,0===Tt&&Rt(it)),n===a&&(45===t.charCodeAt(vt)?(n=u,vt++):(n=a,0===Tt&&Rt(et))),n!==a?(l=Mt(),(h=Ft())!==a?r=o=[o,n,l,h]:(vt=r,r=a)):(vt=r,r=a);wt=e,e=xt(i,s)}else vt=e,e=a;return e}function Yt(){var e,i,s,r,o,n,l,h;if(e=vt,(i=Gt())!==a){for(s=[],r=vt,o=Mt(),t.substr(vt,2)===m?(n=m,vt+=2):(n=a,0===Tt&&Rt(lt)),n===a&&(t.substr(vt,2)===y?(n=y,vt+=2):(n=a,0===Tt&&Rt(ht)),n===a&&(60===t.charCodeAt(vt)?(n="<",vt++):(n=a,0===Tt&&Rt(dt)),n===a&&(62===t.charCodeAt(vt)?(n=">",vt++):(n=a,0===Tt&&Rt(ct))))),n!==a?(l=Mt(),(h=Gt())!==a?r=o=[o,n,l,h]:(vt=r,r=a)):(vt=r,r=a);r!==a;)s.push(r),r=vt,o=Mt(),t.substr(vt,2)===m?(n=m,vt+=2):(n=a,0===Tt&&Rt(lt)),n===a&&(t.substr(vt,2)===y?(n=y,vt+=2):(n=a,0===Tt&&Rt(ht)),n===a&&(60===t.charCodeAt(vt)?(n="<",vt++):(n=a,0===Tt&&Rt(dt)),n===a&&(62===t.charCodeAt(vt)?(n=">",vt++):(n=a,0===Tt&&Rt(ct))))),n!==a?(l=Mt(),(h=Gt())!==a?r=o=[o,n,l,h]:(vt=r,r=a)):(vt=r,r=a);wt=e,e=xt(i,s)}else vt=e,e=a;return e}function zt(){var e,i,s,r,o,n,l,h;if(e=vt,(i=Yt())!==a){for(s=[],r=vt,o=Mt(),t.substr(vt,2)===x?(n=x,vt+=2):(n=a,0===Tt&&Rt(pt)),n===a&&(t.substr(vt,2)===v?(n=v,vt+=2):(n=a,0===Tt&&Rt(ut))),n!==a?(l=Mt(),(h=Yt())!==a?r=o=[o,n,l,h]:(vt=r,r=a)):(vt=r,r=a);r!==a;)s.push(r),r=vt,o=Mt(),t.substr(vt,2)===x?(n=x,vt+=2):(n=a,0===Tt&&Rt(pt)),n===a&&(t.substr(vt,2)===v?(n=v,vt+=2):(n=a,0===Tt&&Rt(ut))),n!==a?(l=Mt(),(h=Yt())!==a?r=o=[o,n,l,h]:(vt=r,r=a)):(vt=r,r=a);wt=e,e=xt(i,s)}else vt=e,e=a;return e}function Ut(){var e,i,s,r,o,n,l,h;if(e=vt,(i=zt())!==a){for(s=[],r=vt,o=Mt(),t.substr(vt,2)===w?(n=w,vt+=2):(n=a,0===Tt&&Rt(gt)),n===a&&(t.substr(vt,2)===b?(n=b,vt+=2):(n=a,0===Tt&&Rt(ft))),n!==a?(l=Mt(),(h=zt())!==a?r=o=[o,n,l,h]:(vt=r,r=a)):(vt=r,r=a);r!==a;)s.push(r),r=vt,o=Mt(),t.substr(vt,2)===w?(n=w,vt+=2):(n=a,0===Tt&&Rt(gt)),n===a&&(t.substr(vt,2)===b?(n=b,vt+=2):(n=a,0===Tt&&Rt(ft))),n!==a?(l=Mt(),(h=zt())!==a?r=o=[o,n,l,h]:(vt=r,r=a)):(vt=r,r=a);wt=e,e=function(t,e){return e.reduce((function(t,e){return{type:"LogicalExpression",operator:e[1],left:t,right:e[3]}}),t)}(i,s)}else vt=e,e=a;return e}if((i=h())!==a&&vt===t.length)return i;throw i!==a&&vt<t.length&&Rt({type:"end"}),s=St,r=_t<t.length?t.charAt(_t):null,o=_t<t.length?Pt(_t,_t+1):Pt(_t,_t),new S(S.buildMessage(s,r),s,r,o)}!function(t,e){function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i}(S,Error),S.prototype.format=function(t){var e="Error: "+this.message;if(this.location){var i,s=null;for(i=0;i<t.length;i++)if(t[i].source===this.location.source){s=t[i].text.split(/\r\n|\n|\r/g);break}var r=this.location.start,o=this.location.source+":"+r.line+":"+r.column;if(s){var a=this.location.end,n=T("",r.line.toString().length),l=s[r.line-1],h=r.line===a.line?a.column:l.length+1;e+="\n --\x3e "+o+"\n"+n+" |\n"+r.line+" | "+l+"\n"+n+" | "+T("",r.column-1)+T("",h-r.column,"^")}else e+="\n at "+o}return e},S.buildMessage=function(t,e){var i={literal:function(t){return'"'+r(t.text)+'"'},class:function(t){var e=t.parts.map((function(t){return Array.isArray(t)?o(t[0])+"-"+o(t[1]):o(t)}));return"["+(t.inverted?"^":"")+e+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(t){return t.description}};function s(t){return t.charCodeAt(0).toString(16).toUpperCase()}function r(t){return t.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(t){return"\\x0"+s(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+s(t)}))}function o(t){return t.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(t){return"\\x0"+s(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+s(t)}))}function a(t){return i[t.type](t)}return"Expected "+function(t){var e,i,s=t.map(a);if(s.sort(),s.length>0){for(e=1,i=1;e<s.length;e++)s[e-1]!==s[e]&&(s[i]=s[e],i++);s.length=i}switch(s.length){case 1:return s[0];case 2:return s[0]+" or "+s[1];default:return s.slice(0,-1).join(", ")+", or "+s[s.length-1]}}(t)+" but "+function(t){return t?'"'+r(t)+'"':"end of input"}(e)+" found."};class L{compile(t){const e=C(t,{});return new _(t,e)}execute(t){return this.compile(t).execute()}}class A{constructor(){this.pvs=new Map}canProvide(t){return t.startsWith("=")}startProviding(t){for(const e of t)this.pvs.set(e.name,new k(e))}stopProviding(t){for(const e of t)this.pvs.delete(e.name)}isNavigable(){return!1}shutdown(){}}class k{constructor(t){this.pv=t;const e=new L;this.compiledFormula=e.compile(t.name);for(const e of this.compiledFormula.getPVNames()){const i=t.pvEngine.createPV(e);this.compiledFormula.updateDataSource(i.name,{value:i.value,acquisitionStatus:"good"}),t.pvEngine.addListener(e,(()=>{this.compiledFormula.updateDataSource(e,{value:t.pvEngine.getValue(e),acquisitionStatus:"good"}),this.trigger()}))}this.trigger()}trigger(){const t=this.compiledFormula.execute();this.pv.pvEngine.setValue(new Date,this.pv.name,t)}}var P={exports:{}};!function(t){!function(){function e(t,e){document.addEventListener?t.addEventListener("scroll",e,!1):t.attachEvent("scroll",e)}function i(t){this.a=document.createElement("div"),this.a.setAttribute("aria-hidden","true"),this.a.appendChild(document.createTextNode(t)),this.b=document.createElement("span"),this.c=document.createElement("span"),this.h=document.createElement("span"),this.f=document.createElement("span"),this.g=-1,this.b.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.c.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.f.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.h.style.cssText="display:inline-block;width:200%;height:200%;font-size:16px;max-width:none;",this.b.appendChild(this.h),this.c.appendChild(this.f),this.a.appendChild(this.b),this.a.appendChild(this.c)}function s(t,e){t.a.style.cssText="max-width:none;min-width:20px;min-height:20px;display:inline-block;overflow:hidden;position:absolute;width:auto;margin:0;padding:0;top:-999px;white-space:nowrap;font-synthesis:none;font:"+e+";"}function r(t){var e=t.a.offsetWidth,i=e+100;return t.f.style.width=i+"px",t.c.scrollLeft=i,t.b.scrollLeft=t.b.scrollWidth+100,t.g!==e&&(t.g=e,!0)}function o(t,i){function s(){var t=o;r(t)&&t.a.parentNode&&i(t.g)}var o=t;e(t.b,s),e(t.c,s),r(t)}function a(t,e){var i=e||{};this.family=t,this.style=i.style||"normal",this.weight=i.weight||"normal",this.stretch=i.stretch||"normal"}var n=null,l=null,h=null,d=null;function c(){return null===d&&(d=!!document.fonts),d}function p(){if(null===h){var t=document.createElement("div");try{t.style.font="condensed 100px sans-serif"}catch(t){}h=""!==t.style.font}return h}function u(t,e){return[t.style,t.weight,p()?t.stretch:"","100px",e].join(" ")}a.prototype.load=function(t,e){var r=this,a=t||"BESbswy",h=0,d=e||3e3,p=(new Date).getTime();return new Promise((function(t,e){if(c()&&!function(){if(null===l)if(c()&&/Apple/.test(window.navigator.vendor)){var t=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))(?:\.([0-9]+))/.exec(window.navigator.userAgent);l=!!t&&603>parseInt(t[1],10)}else l=!1;return l}()){var g=new Promise((function(t,e){!function i(){(new Date).getTime()-p>=d?e(Error(d+"ms timeout exceeded")):document.fonts.load(u(r,'"'+r.family+'"'),a).then((function(e){1<=e.length?t():setTimeout(i,25)}),e)}()})),f=new Promise((function(t,e){h=setTimeout((function(){e(Error(d+"ms timeout exceeded"))}),d)}));Promise.race([f,g]).then((function(){clearTimeout(h),t(r)}),e)}else!function(t){document.body?t():document.addEventListener?document.addEventListener("DOMContentLoaded",(function e(){document.removeEventListener("DOMContentLoaded",e),t()})):document.attachEvent("onreadystatechange",(function e(){"interactive"!=document.readyState&&"complete"!=document.readyState||(document.detachEvent("onreadystatechange",e),t())}))}((function(){function l(){var e;(e=-1!=m&&-1!=y||-1!=m&&-1!=x||-1!=y&&-1!=x)&&((e=m!=y&&m!=x&&y!=x)||(null===n&&(e=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent),n=!!e&&(536>parseInt(e[1],10)||536===parseInt(e[1],10)&&11>=parseInt(e[2],10))),e=n&&(m==v&&y==v&&x==v||m==w&&y==w&&x==w||m==b&&y==b&&x==b)),e=!e),e&&(_.parentNode&&_.parentNode.removeChild(_),clearTimeout(h),t(r))}var c=new i(a),g=new i(a),f=new i(a),m=-1,y=-1,x=-1,v=-1,w=-1,b=-1,_=document.createElement("div");_.dir="ltr",s(c,u(r,"sans-serif")),s(g,u(r,"serif")),s(f,u(r,"monospace")),_.appendChild(c.a),_.appendChild(g.a),_.appendChild(f.a),document.body.appendChild(_),v=c.a.offsetWidth,w=g.a.offsetWidth,b=f.a.offsetWidth,function t(){if((new Date).getTime()-p>=d)_.parentNode&&_.parentNode.removeChild(_),e(Error(d+"ms timeout exceeded"));else{var i=document.hidden;!0!==i&&void 0!==i||(m=c.a.offsetWidth,y=g.a.offsetWidth,x=f.a.offsetWidth,l()),h=setTimeout(t,50)}}(),o(c,(function(t){m=t,l()})),s(c,u(r,'"'+r.family+'",sans-serif')),o(g,(function(t){y=t,l()})),s(g,u(r,'"'+r.family+'",serif')),o(f,(function(t){x=t,l()})),s(f,u(r,'"'+r.family+'",monospace'))}))}))},t.exports=a}()}(P);var R=P.exports;const E=["Arial","Arial Black","Courier New","Helvetica","Tahoma","Verdana"];class M{constructor(t,e,i,s){this.name=t,this.style=i,this.height=s?e:Math.round(16*e/15)}scale(t){return new M(this.name,t*this.height,this.style,!0)}getFontString(){return 1===this.style?`bold ${this.height}px ${this.name}`:2===this.style?`italic ${this.height}px ${this.name}`:(0!==this.style&&console.warn(`Unsupported font style ${this.style}`),`normal ${this.height}px ${this.name}`)}preload(){if(-1!==E.indexOf(this.name))return Promise.resolve();let t={weight:"normal",style:"normal"};return 1===this.style?t.weight="bold":2===this.style&&(t.style="italic"),new R(this.name,t).load()}}M.ARIAL_9=new M("Arial",9,0,!1),M.ARIAL_10=new M("Arial",10,0,!1),M.ARIAL_11=new M("Arial",11,0,!1),M.ARIAL_12_BOLD=new M("Arial",12,1,!1);class V{getColorFromRGB(t,i,s){return new e(t,i,s)}getFont(t,e,i){return new M(t,e,i,!1)}}V.BLACK=e.BLACK,V.BLUE=e.BLUE,V.CYAN=e.CYAN,V.DARK_GRAY=e.DARK_GRAY,V.GRAY=e.GRAY,V.GREEN=e.GREEN,V.LIGHT_BLUE=e.LIGHT_BLUE,V.ORANGE=e.ORANGE,V.PINK=e.PINK,V.PURPLE=e.PURPLE,V.RED=e.RED,V.WHITE=e.WHITE,V.YELLOW=e.YELLOW;class O{writeInfo(t){console.log(t)}writeError(t){console.error(t)}writeWarning(t){console.warn(t)}}class N{constructor(t,e=[]){this.widget=t,this.properties=new Map;for(const t of e)this.properties.set(t.name,t)}clear(){this.properties.clear()}add(t){this.properties.set(t.name,t)}all(){return this.properties.values()}loadXMLValues(t){this.properties.forEach((e=>{if(t.hasNode(e.name))if(e instanceof z)e.value=t.getActions(e.name);else if(e instanceof B)e.value=t.getBoolean(e.name);else if(e instanceof F)e.value=t.getColor(e.name);else if(e instanceof H)e.value=t.getFloat(e.name);else if(e instanceof G)e.value=t.getFont(e.name);else if(e instanceof W)e.value=t.getInt(e.name);else if(e instanceof U)e.value=t.getMacros(e.name);else if(e instanceof Y)e.value=t.getPoints(e.name);else if(e instanceof X)e.value=t.getRules(e.name);else if(e instanceof $)e.value=t.getScripts(e.name);else if(e instanceof q)e.value=t.getScaleOptions(e.name);else if(e instanceof Z)e.value=t.getAutoScaleWidgets(e.name);else if(e instanceof I)e.rawValue=t.getString(e.name);else{if(!(e instanceof j))throw new Error(`Property ${e.name} has an unexpected type`);e.value=t.getStringList(e.name)}})),this.properties.forEach((t=>{if(t instanceof I){const e=t;void 0!==e.rawValue?t.value=this.widget.expandMacro(e.rawValue):t.value=e.rawValue}}))}getProperty(t){return this.properties.get(t)}getValue(t,e=!1){const i=this.properties.get(t);if(i&&void 0!==i.value)return i.value;if(!e)throw new Error(`Missing property ${t}`)}setValue(t,e){const i=this.properties.get(t);if(!i)throw new Error(`Cannot set value of unknown property ${t}`);i.value=e}}class D{constructor(t,e){this.name=t,this.defaultValue=e,this.value=e}get value(){return this._value}set value(t){if(this.value!==t){const e=this._value;if(this._value=t,this.listeners)for(const i of this.listeners)i(t,e)}}addListener(t){this.listeners=this.listeners||[],this.listeners.push(t)}printScriptValue(t){return String(t)}}class I extends D{printScriptValue(t){return`"${t.replace('"','\\"')}"`}}class W extends D{}class H extends D{}class B extends D{}class F extends D{printScriptValue(t){const{red:e,green:i,blue:s}=Object.assign({},t);return`ColorFontUtil.getColorFromRGB(${e}, ${i}, ${s})`}}class G extends D{printScriptValue(t){const{name:e,height:i,style:s}=Object.assign({},t);return`ColorFontUtil.getFont("${e}", ${i}, ${s})`}}class Y extends D{}class z extends D{}class U extends D{}class $ extends D{}class j extends D{}class X extends D{}class q extends D{}class Z extends D{}class K{constructor(t){this.widget=t}getPropertyValue(t){const e=this.widget.properties.getProperty(t);return e?e.value:null}setPropertyValue(t,e){const i=this.widget.properties.getProperty(t);if(!i)throw new Error(`Cannot set value of unknown property ${t}`);i instanceof I?(e=void 0!==e?String(e):e,this.widget.properties.setValue(t,e)):this.widget.properties.setValue(t,e),this.widget.requestRepaint()}}class J{constructor(t){this.display=t}getWidget(t){const e=this.display.findWidgetByName(t);if(e)return new K(e)}}class Q{openInformation(t,e,i){alert(i)}openConfirm(t,e,i){return confirm(i)}openError(t,e,i){alert(i)}}const tt=["yyyy","MM","dd","HH","mm","ss","nnnnnnnnn"];class et{constructor(t){this.pvEngine=t}getDouble(t){return parseFloat(t.getValue())}getLong(t){return parseInt(t.getValue(),10)}getString(t){return String(t.getValue())}getTimeString(t,e="yyyy-MM-dd HH:mm:ss.nnnnnnnnn"){const i=t._pv.time;if(i){let t=e;for(const e of tt)t=t.replace(e,this.formatDate(i,e));return t}return null}formatDate(t,e){if("yyyy"===e)return String(t.getUTCFullYear());if("MM"===e){const e=t.getUTCMonth()+1;return e<10?"0"+e:""+e}if("dd"===e){const e=t.getUTCDate();return e<10?"0"+e:""+e}if("HH"===e){const e=t.getUTCHours();return e<10?"0"+e:""+e}if("mm"===e){const e=t.getUTCMinutes();return e<10?"0"+e:""+e}if("ss"===e){const e=t.getUTCSeconds();return e<10?"0"+e:""+e}if("nnnnnnnnn"===e){const e=t.getUTCMilliseconds();return e<10?"00"+e:e<100?"0"+e:""+e}throw new Error(`Unexpected format '${e}'`)}}class it{constructor(t){this._pv=t}getName(){return this._pv.name}getValue(){return this._pv.value}setValue(t){this._pv.pvEngine.setValue(new Date,this._pv.name,t)}}class st{constructor(t){this.display=t}openOPI(t,e,i,s){if(0!==i)throw new Error(`Unsupported target ${i}`);{const t={path:e,replace:0===i};this.display.fireEvent("opendisplay",t)}}closeCurrentOPI(){this.display.fireEvent("closedisplay",{})}}const rt=document.createElement("iframe");rt.style.display="none",document.body.appendChild(rt);const ot=rt.contentWindow;let at=ot.eval;!at&&ot.execScript&&(ot.execScript.call(ot,"null"),at=ot.eval);class nt{constructor(t,e,i=[]){this.scriptText=e,this.scriptText=e.replace(/importClass\([^\)]*\)\s*\;?/gi,"").replace(/importPackage\([^\)]*\)\s*\;?/gi,"").trim(),this.context=Object.assign({display:new J(t.display),pvs:i.map((t=>new it(t))),widget:new K(t),ConsoleUtil:new O,ColorFontUtil:new V,MessageDialog:new Q,PVUtil:new et(t.display.pvEngine),ScriptUtil:new st(t.display)},t.display.pvEngine.scriptLibraries)}run(){const t=[];for(const e in rt.contentWindow)t.push(e);try{for(const t in this.context)this.context.hasOwnProperty(t)&&(ot[t]=this.context[t]);at.call(ot,this.scriptText);const e={};for(const i in ot)-1===t.indexOf(i)&&(e[i]=ot[i]);this.context=e}finally{for(const e in ot)-1===t.indexOf(e)&&delete ot[e]}}}class lt{constructor(e,i){this.name=e,this.pvEngine=i,this._writable=!1,this._severity=t.AlarmSeverity.NONE,this._precision=3,this._disconnected=!1,this.navigable=!1}get units(){return this._units}set units(t){this._units=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}toNumber(){return null===this.value?null:"number"==typeof this.value?this.value:"boolean"==typeof this.value?this.value?1:0:void 0!==typeof this.indexValue?this.indexValue:void 0}formatValue(t,e){return null===this.value?"":"string"==typeof this.value?this.value:"number"==typeof this.value?this.formatNumber(t,this.value,e):String(this.value)}formatNumber(t,e,i){if(null==e||null==e)return"";switch(t){case 0:case 1:return-1===i?String(e):e.toFixed(i);case 2:return e.toExponential().replace("e+","E").toUpperCase();case 3:return"0x"+e.toString(16).toUpperCase();default:return console.warn(`Unexpected format type ${t}`),String(e)}}setSample(t){this._time=t.time,this._value=t.value,this._indexValue=t.valueIndex,this._severity=t.severity,this.pvEngine.requestRepaint()}addListener(t){this.pvEngine.addListener(this.name,t)}toString(){if(void 0!==this.value)return String(this.value)}}var ht;t.AlarmSeverity=void 0,(ht=t.AlarmSeverity||(t.AlarmSeverity={}))[ht.NONE=0]="NONE",ht[ht.MINOR=1]="MINOR",ht[ht.MAJOR=2]="MAJOR",ht[ht.INVALID=3]="INVALID",ht[ht.UNDEFINED=4]="UNDEFINED";class dt extends lt{constructor(t,e,i){super(t,e),this.initializer=i,this.writable=!0}}const ct=/(loc\:\/\/[^\(]+)(\((.*)\))?/;function pt(t){if(!t.startsWith("loc://"))return t;const e=t.match(ct);return e?e[1]:t}class ut{constructor(t){this.display=t,this.rules=[],this.scripts=[],this.pvs=new Map,this.providers=[],this.scriptLibraries={},this.listeners=new Map}clearState(){this.disconnectAll(),this.rules=[],this.scripts=[],this.listeners.clear()}getPVNames(){return[...this.pvs.keys()]}hasPV(t){const e=pt(t);return this.pvs.has(e)}getPV(t){const e=pt(t);return this.pvs.get(e)}disconnectAll(){for(const t of this.providers){const e=[];for(const 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 lt(t,this),this.pvs.set(t,e);for(const i of this.providers)if(i.canProvide(t))return e.navigable=i.isNavigable(),i.startProviding([e]),e;return console.warn(`No provider for PV ${t}`),e.disconnected=!0,e}requestRepaint(){this.display.requestRepaint()}createLocalPV(t){const e=t.match(ct);let i;e&&(t=e[1],void 0!==e[3]&&(i=e[3]));let s=this.pvs.get(t);return s&&s.initializer!==i&&console.warn(`PV ${t} is defined with different initializers.`),s||(s=new dt(t,this,i),this.pvs.set(t,s),void 0!==i&&this.setValue(new Date,t,i)),s}getValue(t){const e=pt(t),i=this.pvs.get(e);if(i)return i.value}setValue(e,i,s,r=t.AlarmSeverity.NONE){const o=pt(i),a=this.pvs.get(o);if(!a)throw new Error(`Cannot set value of unknown PV ${i}`);a.setSample({time:e,value:s,severity:r});for(const t of this.listeners.get(i)||[])t()}setValues(t){const e=[];for(const i of t.keys()){const s=this.pvs.get(i);if(s){s.setSample(t.get(i));for(const t of this.listeners.get(i)||[])e.push(t)}else console.warn(`Received an update for unknown pv ${i}`)}for(const t of e)t()}createScript(t,e,i){const s=[];for(const i of e.inputs){const e=t.expandMacro(i.pvName);s.push(this.createPV(e))}const r=new gt(t,e,i,s);this.scripts.push(r);const o=()=>r.scriptEngine.run();for(const i of e.inputs)if(i.trigger){const e=t.expandMacro(i.pvName);this.addListener(e,o)}}createRule(t,e){const i=[];for(const s of e.inputs){const e=t.expandMacro(s.pvName);i.push(this.createPV(e))}const s=new ft(t,e,i);this.rules.push(s);const r=()=>s.scriptEngine.run();for(const i of e.inputs)if(i.trigger){const e=t.expandMacro(i.pvName);this.addListener(e,r)}}addProvider(t){this.providers.push(t)}addScriptLibrary(t,e){this.scriptLibraries[t]=e}addListener(t,e){const i=this.listeners.get(t);i?i.push(e):this.listeners.set(t,[e])}}class gt{constructor(t,e,i,s){this.widget=t,this.script=e,this.text=i,this.scriptEngine=new nt(t,i,s)}}class ft{constructor(t,e,i){this.widget=t,this.rule=e;let s="";const r=t.properties.getProperty(e.propertyName);if(!r)throw new Error(`Cannot create rule for unsupported property ${e.propertyName}`);if(e.expressions.length){let t=!1,o=!1,a=!1,n=!1;for(const i of e.expressions)i.expression.match(/pv[0-9]+/)&&(t=!0),e.outputExpression&&i.outputValue.toString().match(/pv[0-9]+/)&&(t=!0),-1!==i.expression.indexOf("pvInt")&&(o=!0),e.outputExpression&&-1!==i.outputValue.toString().indexOf("pvInt")&&(o=!0),-1!==i.expression.indexOf("pvStr")&&(a=!0),e.outputExpression&&-1!==i.outputValue.toString().indexOf("pvStr")&&(a=!0),-1!==i.expression.indexOf("pvSev")&&(n=!0),e.outputExpression&&-1!==i.outputValue.toString().indexOf("pvSev")&&(n=!0);for(let e=0;e<i.length;e++)t&&(s+=`var pv${e} = PVUtil.getDouble(pvs[${e}]);\n`),o&&(s+=`var pvInt${e} = PVUtil.getLong(pvs[${e}]);\n`),a&&(s+=`var pvStr${e} = PVUtil.getString(pvs[${e}]);\n`),n&&(s+=`var pvSev${e} = PVUtil.getSeverity(pvs[${e}]);\n`);for(let t=0;t<e.expressions.length;t++){const i=e.expressions[t].expression,o=e.expressions[t].outputValue;if(t>0&&(s+="else "),s+=`if (${i}) widget.setPropertyValue("${e.propertyName}", `,e.outputExpression)s+=`${o});\n`;else{s+=`${this.printScriptValue(r,o)});\n`}}const l=r.value,h=this.printScriptValue(r,l);s+=`else widget.setPropertyValue("${e.propertyName}", `,s+=`${h});\n`}this.scriptEngine=new nt(t,s,i)}printScriptValue(t,e){return null==e?"null":t.printScriptValue(e)}}class mt{constructor(t,e,i){this.pv=t,this.interval=e,void 0!==i&&t.pvEngine.setValue(new Date,t.name,i),this.interval>0&&(this.timer=window.setInterval((()=>{this.generateSample(new Date)}),e))}emit(e,i){let s=t.AlarmSeverity.NONE;void 0!==this.pv.lowerAlarmLimit&&i<this.pv.lowerAlarmLimit||void 0!==this.pv.upperAlarmLimit&&i>this.pv.upperAlarmLimit?s=t.AlarmSeverity.MAJOR:(void 0!==this.pv.lowerWarningLimit&&i<this.pv.lowerWarningLimit||void 0!==this.pv.upperWarningLimit&&i>this.pv.upperWarningLimit)&&(s=t.AlarmSeverity.MINOR),this.pv.pvEngine.setValue(e,this.pv.name,i,s)}stop(){window.clearInterval(this.timer)}}class yt extends mt{constructor(t,e){super(t,-1,e)}generateSample(){}}class xt extends mt{constructor(t,e,i,s){super(t,s),this.min=e,this.max=i;const r=this.max-this.min;t.units="x",t.lowerDisplayLimit=e,t.lowerAlarmLimit=e+.1*r,t.lowerWarningLimit=e+.2*r,t.upperWarningLimit=e+.8*r,t.upperAlarmLimit=e+.9*r,t.upperDisplayLimit=i}generateSample(t){const e=Math.random()*(this.max-this.min)+this.min;this.emit(t,e)}}class vt extends mt{constructor(t,e,i,s){super(t,s),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,s;do{e=2*Math.random()-1,i=2*Math.random()-1,s=e*e+i*i}while(s>=1||0===s);const r=e*Math.sqrt(-2*Math.log(s)/s);this.emit(t,this.avg+r*this.stddev)}}class wt extends mt{constructor(t,e,i,s,r){super(t,r),this.min=e,this.max=i,this.samplesPerCycle=s,this.currentValue=0;const o=this.max-this.min;t.units="x",t.lowerDisplayLimit=e,t.lowerAlarmLimit=e+.1*o,t.lowerWarningLimit=e+.2*o,t.upperWarningLimit=e+.8*o,t.upperAlarmLimit=e+.9*o,t.upperDisplayLimit=i}generateSample(t){const e=this.max-this.min,i=Math.sin(2*this.currentValue*Math.PI/this.samplesPerCycle)*e/2+this.min+e/2;this.currentValue++,this.emit(t,i)}}class bt extends mt{constructor(t,e,i,s,r){super(t,r),this.min=e,this.max=i,this.inc=s,this.currentValue=0,this.currentValue=s>=0?e-s:i-s;const o=this.max-this.min;t.units="x",t.lowerDisplayLimit=e,t.lowerAlarmLimit=e+.1*o,t.lowerWarningLimit=e+.2*o,t.upperWarningLimit=e+.8*o,t.upperAlarmLimit=e+.9*o,t.upperDisplayLimit=i}generateSample(t){this.currentValue=this.currentValue+this.inc,this.currentValue>this.max&&(this.currentValue=this.min),this.currentValue<this.min&&(this.currentValue=this.max),this.emit(t,this.currentValue)}}const _t=/sim\:\/\/([a-zA-Z]+)(\((.*)\))?/;class St{constructor(){this.pvs=new Map}canProvide(t){return t.startsWith("sim://")}startProviding(t){for(const e of t){const t=new Tt(e);this.pvs.set(e.name,t)}}stopProviding(t){for(const e of t){const t=this.pvs.get(e.name);t&&(t.fn.stop(),this.pvs.delete(e.name))}}isNavigable(){return!1}shutdown(){for(const t of this.pvs.values())t.fn.stop()}}class Tt{constructor(t){this.pv=t;const e=t.name.match(_t);if(e){const t=e[3]?e[3].split(","):[];for(let e=0;e<t.length;e++)t[e]=t[e].trim();this.fn=this.createGenerator(e[1],t)}else console.warn(`Unexpected pattern for PV ${t.name}`),this.fn=new yt(t,void 0)}createGenerator(t,e){switch(t){case"const":const i=this.saferEval(e[0]);return new yt(this.pv,i);case"gaussianNoise":return this.createGaussianNoise(e);case"noise":return this.createNoise(e);case"ramp":return this.createRamp(e);case"sine":return this.createSine(e);default:return console.warn(`Unexpected function ${t} for PV ${this.pv.name}`),new yt(this.pv,void 0)}}saferEval(t){return Function('"use strict";return ('+t+")")()}createNoise(t){if(0===t.length)return new xt(this.pv,-5,5,1e3);{const e=parseFloat(t[0]),i=parseFloat(t[1]),s=1e3*parseFloat(t[2]);return new xt(this.pv,e,i,s)}}createGaussianNoise(t){if(0===t.length)return new vt(this.pv,0,1,100);{const e=parseFloat(t[0]),i=parseFloat(t[1]),s=1e3*parseFloat(t[2]);return new vt(this.pv,e,i,s)}}createRamp(t){let e;if(0===t.length)e=new bt(this.pv,-5,5,1,1e3);else if(3===t.length){const i=parseFloat(t[0]),s=parseFloat(t[1]),r=1e3*parseFloat(t[2]);e=new bt(this.pv,i,s,1,r)}else{if(4!==t.length)return console.warn(`Unexpected ramp arguments for PV ${this.pv.name}`),new yt(this.pv,void 0);{const i=parseFloat(t[0]),s=parseFloat(t[1]),r=parseFloat(t[2]),o=1e3*parseFloat(t[3]);e=new bt(this.pv,i,s,r,o)}}return e}createSine(t){let e;if(0===t.length)e=new wt(this.pv,-5,5,10,1e3);else if(3===t.length){const i=parseFloat(t[0]),s=parseFloat(t[1]),r=1e3*parseFloat(t[2]);e=new wt(this.pv,i,s,10,r)}else{if(4!==t.length)return console.warn(`Unexpected sine arguments for PV ${this.pv.name}`),new yt(this.pv,void 0);{const i=parseFloat(t[0]),s=parseFloat(t[1]),r=parseFloat(t[2]),o=1e3*parseFloat(t[3]);e=new wt(this.pv,i,s,r,o)}}return e}}class Ct{constructor(){this.actions=[],this.hookFirstActionToClick=!1,this.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]}getClickActions(){const t=[];if(this.hookFirstActionToClick)t.push(0);else if(this.hookAllActionsToClick)for(let e=0;e<this.actions.length;e++)t.push(e);return t}toString(){return 1===this.actions.length?String(this.actions[0])||this.actions[0].type:`${this.actions.length} actions`}}class Lt{constructor(t){this.path=t,this.type="OPEN_DISPLAY"}toString(){return`Open ${this.path}`}}class At{constructor(){this.type="OPEN_FILE"}toString(){return`Open ${this.path}`}}class kt{constructor(t){this.embedded=t,this.type="EXECUTE_JAVASCRIPT"}toString(){return"Execute JavaScript"}}class Pt{constructor(){this.type="EXECUTE_CMD"}toString(){return`Execute Command ${this.command}`}}class Rt{constructor(t,e){this.pvName=t,this.value=e,this.type="WRITE_PV"}toString(){return`Write ${this.value} to ${this.pvName}`}}class Et{constructor(){this.type="PLAY_SOUND"}toString(){return`Play WAV File ${this.path}`}}class Mt{constructor(){this.type="OPEN_WEBPAGE"}toString(){return`Open Webpage ${this.hyperlink}`}}class Vt{constructor(){this.rules=[]}}const Ot="actions",Nt="background_color",Dt="backcolor_alarm_sensitive",It="border_alarm_sensitive",Wt="border_color",Ht="border_width",Bt="border_style",Ft="foreground_color",Gt="forecolor_alarm_sensitive",Yt="height",zt="name",Ut="pv_name",$t="rules",jt="scale_options",Xt="scripts",qt="text",Zt="transparent",Kt="visible",Jt="width",Qt="wuid";class te{constructor(t,i){this.display=t,this.parent=i,this.x=0,this.y=0,this.width=0,this.height=0,this.fillRoundRectangleBackgroundBorder=!0,this.properties=new N(this,[new z(Ot,new Ct),new B(Dt,!1),new F(Nt,e.TRANSPARENT),new B(It,!1),new F(Wt),new W(Bt),new W(Ht),new B(Gt,!1),new F(Ft),new W(Yt),new I(zt),new I(Ut),new X($t,new Vt),new $(Xt),new I(qt,""),new B(Zt,!1),new B(Kt),new I("widget_type"),new W(Jt),new I(Qt),new W("x"),new W("y"),new q(jt)])}parseNode(t){this.properties.loadXMLValues(t);for(const t of this.properties.all())if(t instanceof G){const e=t.value;e.preload().then((()=>this.requestRepaint())).catch((()=>console.warn(`Failed to load font '${e.getFontString()}'.`)))}this.pvName&&this.display.pvEngine.createPV(this.pvName);for(const t of this.scripts.scripts)t.embedded?this.display.pvEngine.createScript(this,t,t.text):fetch(`${this.display.baseUrl}${t.path}`,{credentials:"same-origin"}).then((e=>{e.ok&&e.text().then((e=>{this.display.pvEngine.createScript(this,t,e)}))}));for(const t of this.rules.rules)this.properties.getProperty(t.propertyName)?this.display.pvEngine.createRule(this,t):console.warn(`Cannot create rule for unsupported property ${t.propertyName}`);this.init()}drawHolder(e){var i,s;const{scale:r}=this;let o=[0,0,0,0];const a=this.borderAlarmSensitive&&((null===(i=this.pv)||void 0===i?void 0:i.severity)===t.AlarmSeverity.MINOR||(null===(s=this.pv)||void 0===s?void 0:s.severity)===t.AlarmSeverity.MAJOR);if(!a)switch(this.borderStyle){case 0:break;case 1:o=[this.borderWidth,this.borderWidth,this.borderWidth,this.borderWidth];break;case 2:case 3:o=[1*r,1*r,1*r,1*r];break;case 4:case 5:case 6:o=[2*r,2*r,2*r,2*r];break;case 7:o=[2*r,2*r,1*r,1*r];break;case 8:case 9:case 10:case 11:o=[this.borderWidth,this.borderWidth,this.borderWidth,this.borderWidth];break;case 12:o=[17*r,1*r,1*r,1*r];break;case 13:o=[16*r,16*r,16*r,16*r];break;case 14:const t=2*this.borderWidth;o=[t,t,t,t]}if(this.x=this.holderX+o[1],this.y=this.holderY+o[0],this.width=this.holderWidth-o[1]-o[3],this.height=this.holderHeight-o[0]-o[2],a||this.drawBorderStyle(e),this.actions.isClickable()){e.addHitRegion({id:`${this.wuid}-holder`,click:()=>{for(const t of this.actions.getClickActions())this.executeAction(t)},cursor:"pointer"}).addRect(this.holderX,this.holderY,this.holderWidth,this.holderHeight)}}drawBorderStyle(t){const{scale:i}=this;if(0===this.borderStyle);else if(1===this.borderStyle)t.strokeRect({x:this.holderX,y:this.holderY,width:this.holderWidth,height:this.holderHeight,color:this.borderColor,lineWidth:this.borderWidth,crispen:!0});else if(2===this.borderStyle){const s=1*i,r=this.holderY+s/2,o=this.holderX+s/2,a=this.holderY+this.holderHeight-s+s/2,n=this.holderX+this.holderWidth-s+s/2;t.strokePath({color:e.BLACK,path:new w(n,a).lineTo(n,r).moveTo(n,a).lineTo(o,a)}),t.strokePath({color:e.WHITE,path:new w(o,r).lineTo(n-s,r).moveTo(o,r).lineTo(o,a-s)})}else if(3===this.borderStyle){const s=1*i,r=this.holderY+s/2,o=this.holderX+s/2,a=this.holderY+this.holderHeight-s+s/2,n=this.holderX+this.holderWidth-s+s/2;t.strokePath({color:e.WHITE,path:new w(n,a).lineTo(n,r).moveTo(n,a).lineTo(o,a)}),t.strokePath({color:e.BLACK,path:new w(o,r).lineTo(n-s,r).moveTo(o,r).lineTo(o,a-s)})}else if(4===this.borderStyle)this.drawShadowBorder(t,e.BUTTON_LIGHTEST,e.BUTTON_DARKER,e.BUTTON_DARKER,e.BUTTON_LIGHTEST);else if(5===this.borderStyle)this.drawShadowBorder(t,e.BUTTON_DARKER,e.BUTTON_LIGHTEST,e.BUTTON_LIGHTEST,e.BUTTON_DARKER);else if(6===this.borderStyle)this.drawShadowBorder(t,e.BUTTON_DARKEST,e.BUTTON_DARKER,e.BUTTON,e.BUTTON_LIGHTEST);else if(7===this.borderStyle)this.drawShadowBorder(t,e.BUTTON_LIGHTEST,e.BUTTON_LIGHTEST,e.BUTTON_DARKEST,e.BUTTON_DARKER);else if(8===this.borderStyle)this.drawDashedBorder(t,[2*i,2*i]);else if(9===this.borderStyle)this.drawDashedBorder(t,[6*i,2*i]);else if(10===this.borderStyle)this.drawDashedBorder(t,[6*i,2*i,2*i,2*i]);else if(11===this.borderStyle)this.drawDashedBorder(t,[6*i,2*i,2*i,2*i,2*i,2*i]);else if(12===this.borderStyle)t.fillRect({x:this.holderX,y:this.holderY+1*i,width:this.holderWidth,height:16*i,color:this.borderColor}),t.fillText({x:this.holderX+1*i+3*i,y:this.holderY+1*i+8*i,baseline:"middle",align:"left",font:M.ARIAL_11.scale(i),color:e.BLACK,text:this.name}),t.strokeRect({x:this.holderX,y:this.holderY,width:this.holderWidth,height:this.holderHeight,color:e.BLACK,crispen:!0});else if(13===this.borderStyle){this.transparent||t.fillRect({x:this.holderX,y:this.holderY,width:this.holderWidth,height:this.holderHeight,color:this.backgroundColor}),t.fillText({x:this.holderX+16*i,y:this.holderY+8*i,baseline:"middle",align:"left",font:M.ARIAL_11.scale(i),color:this.borderColor,text:this.name});const e=t.measureText(this.name,M.ARIAL_11.scale(i)),s=1;let r=l(this.holderX+8*i,this.holderY+8*i,this.holderWidth-16*i-s,this.holderHeight-16*i-s,s);t.strokePath({color:this.backgroundColor.darker(),path:new w(r.x,r.y).lineTo(r.x+8*i,r.y).moveTo(r.x+8*i+e.width,r.y).lineTo(r.x+r.width,r.y).lineTo(r.x+r.width,r.y+r.height).lineTo(r.x,r.y+r.height).lineTo(r.x,r.y)}),r=l(this.holderX+8*i+s,this.holderY+8*i+s,this.holderWidth-16*i-s,this.holderHeight-16*i-s,s),t.strokePath({color:this.backgroundColor.brighter(),path:new w(r.x,r.y).lineTo(r.x+8*i-s,r.y).moveTo(r.x+8*i-s+e.width,r.y).lineTo(r.x+r.width,r.y).lineTo(r.x+r.width,r.y+r.height).lineTo(r.x,r.y+r.height).lineTo(r.x,r.y)})}else if(14===this.borderStyle){const e=l(this.holderX,this.holderY,this.holderWidth,this.holderHeight,this.borderWidth);this.fillRoundRectangleBackgroundBorder&&t.fillRect(Object.assign(Object.assign({},e),{rx:4*i,ry:4*i,color:this.backgroundColor})),this.borderWidth&&t.strokeRect(Object.assign(Object.assign({},e),{rx:4*i,ry:4*i,color:this.borderColor,lineWidth:this.borderWidth}))}else 15===this.borderStyle||console.warn(`Unsupported border style: ${this.borderStyle}`)}drawDecoration(i){var s,r,o;if(this.display.editMode)return;const{scale:a}=this;if(!this.pvName||this.pv&&!this.pv.disconnected)this.pv&&void 0===this.pv.value&&i.strokeRect(Object.assign(Object.assign({},this.bounds),{dash:[2*a,2*a],lineWidth:2*a,color:e.PINK,crispen:!0}));else{const t=1*a;i.fillRect({x:this.holderX-t/2,y:this.holderY-t/2,width:this.holderWidth+t,height:this.holderHeight+t,color:e.PURPLE,opacity:.4}),i.strokeRect({x:this.holderX-t/2,y:this.holderY-t/2,width:this.holderWidth+t,height:this.holderHeight+t,color:e.PURPLE})}if(this.borderAlarmSensitive){let n;8===this.borderStyle?n=[2*a,2*a]:9===this.borderStyle?n=[6*a,2*a]:10===this.borderStyle?n=[6*a,2*a,2*a,2*a]:11===this.borderStyle&&(n=[6*a,2*a,2*a,2*a,2*a,2*a]),(null===(s=this.pv)||void 0===s?void 0:s.severity)===t.AlarmSeverity.MAJOR?i.strokeRect(Object.assign(Object.assign({},this.bounds),{lineWidth:2*a,color:e.RED,crispen:!0,dash:n})):(null===(r=this.pv)||void 0===r?void 0:r.severity)===t.AlarmSeverity.MINOR?i.strokeRect(Object.assign(Object.assign({},this.bounds),{lineWidth:2*a,color:e.ORANGE,crispen:!0,dash:n})):(null===(o=this.pv)||void 0===o?void 0:o.severity)===t.AlarmSeverity.INVALID&&i.strokeRect(Object.assign(Object.assign({},this.bounds),{lineWidth:2*a,color:e.PINK,crispen:!0}))}}drawOverlay(t){}drawSelection(t){t.lineWidth=1,t.strokeStyle="black",t.strokeRect(this.holderX-.5,this.holderY-.5,this.holderWidth+1,this.holderHeight+1),t.fillStyle="black";let e=2;t.fillRect(this.holderX-e,this.holderY-e,e+e,e+e),t.fillRect(this.holderX+this.holderWidth/2-e,this.holderY-e,e+e,e+e),t.fillRect(this.holderX+this.holderWidth-e,this.holderY-e,e+e,e+e),t.fillRect(this.holderX-e,this.holderY+this.holderHeight/2-e,e+e,e+e),t.fillRect(this.holderX+this.holderWidth-e,this.holderY+this.holderHeight/2-e,e+e,e+e),t.fillRect(this.holderX-e,this.holderY+this.holderHeight-e,e+e,e+e),t.fillRect(this.holderX+this.holderWidth/2-e,this.holderY+this.holderHeight-e,e+e,e+e),t.fillRect(this.holderX+this.holderWidth-e,this.holderY+this.holderHeight-e,e+e,e+e),t.strokeStyle="white",e=3,t.strokeRect(this.holderX-e+.5,this.holderY-e+.5,e+e-1,e+e-1),t.strokeRect(this.holderX+this.holderWidth/2-e+.5,this.holderY-e+.5,e+e-1,e+e-1),t.strokeRect(this.holderX+this.holderWidth-e+.5,this.holderY-e+.5,e+e-1,e+e-1),t.strokeRect(this.holderX-e+.5,this.holderY+this.holderHeight/2-e+.5,e+e-1,e+e-1),t.strokeRect(this.holderX+this.holderWidth-e+.5,this.holderY+this.holderHeight/2-e+.5,e+e-1,e+e-1),t.strokeRect(this.holderX-e+.5,this.holderY+this.holderHeight-e+.5,e+e-1,e+e-1),t.strokeRect(this.holderX+this.holderWidth/2-e+.5,this.holderY+this.holderHeight-e+.5,e+e-1,e+e-1),t.strokeRect(this.holderX+this.holderWidth-e+.5,this.holderY+this.holderHeight-e+.5,e+e-1,e+e-1)}requestRepaint(){this.display.requestRepaint()}closeMenu(){}get bounds(){return{x:this.holderX,y:this.holderY,width:this.holderWidth,height:this.holderHeight}}get unscaledBounds(){return{x:this.properties.getValue("x"),y:this.properties.getValue("y"),width:this.properties.getValue(Jt),height:this.properties.getValue(Yt)}}get area(){return{x:this.x,y:this.y,width:this.width,height:this.height}}drawShadowBorder(t,e,i,s,r){const o=1*this.scale,a=this.holderY+o/2,n=this.holderX+o/2,l=this.holderY+this.holderHeight-o+o/2,h=this.holderX+this.holderWidth-o+o/2;t.strokePath({color:e,path:new w(h,l).lineTo(h,a).moveTo(h,l).lineTo(n,l)}),t.strokePath({color:i,path:new w(h-o,l-o).lineTo(h-o,a+o).moveTo(h-o,l-o).lineTo(n+o,l-o)}),t.strokePath({color:s,path:new w(n,a).lineTo(h-o,a).moveTo(n,a).lineTo(n,l-o)}),t.strokePath({color:r,path:new w(n+o,a+o).lineTo(h-o-o,a+o).moveTo(n+o,a+o).lineTo(n+o,l-o-o)})}drawDashedBorder(t,e){const i=l(this.holderX,this.holderY,this.holderWidth,this.holderHeight,this.borderWidth);t.strokePath({color:this.borderColor,lineWidth:this.borderWidth,dash:e,path:new w(i.x,i.y).lineTo(i.x+i.width,i.y).lineTo(i.x+i.width,i.y+i.height).lineTo(i.x,i.y+i.height).closePath()})}executeAction(t){const e=this.actions.getAction(t);if(e)switch(e.type){case"OPEN_DISPLAY":const t={path:e.path,replace:0===e.mode};this.display.fireEvent("opendisplay",t);break;case"EXECUTE_JAVASCRIPT":if(e.embedded){new nt(this.display.instance,e.text).run()}else fetch(`${this.display.baseUrl}${e.path}`,{credentials:"same-origin"}).then((t=>{t.ok&&t.text().then((t=>{new nt(this.display.instance,t).run()}))}));break;case"WRITE_PV":if(e.pvName){const t=this.expandMacro(e.pvName);this.display.pvEngine.setValue(new Date,t,e.value)}break;case"PLAY_SOUND":if(e.path){new Audio(`${this.display.baseUrl}${e.path}`).play()}break;case"OPEN_WEBPAGE":e.hyperlink&&(window.location.href=e.hyperlink);break;default:throw new Error(`Unsupported command ${e.type}`)}}expandMacro(t){if(-1===t.indexOf("$"))return t;for(const e of this.properties.all())t=(t=t.replace(`$(${e.name})`,e.value||"")).replace(`\${${e.name}}`,e.value||"");return this.parent?this.parent.expandContainerMacros(t):t}get pv(){if(this.pvName)return this.display.getPV(this.pvName)}isMinorSeverity(){var e;return(null===(e=this.pv)||void 0===e?void 0:e.severity)===t.AlarmSeverity.MINOR}isMajorSeverity(){var e;return(null===(e=this.pv)||void 0===e?void 0:e.severity)===t.AlarmSeverity.MAJOR}get alarm(){var e,i;return(null===(e=this.pv)||void 0===e?void 0:e.severity)===t.AlarmSeverity.MINOR||(null===(i=this.pv)||void 0===i?void 0:i.severity)===t.AlarmSeverity.MAJOR}get alarmSensitiveBackgroundColor(){if(this.backgroundAlarmSensitive){if(this.isMajorSeverity())return e.RED;if(this.isMinorSeverity())return e.ORANGE}return this.backgroundColor}get alarmSensitiveForegroundColor(){if(this.foregroundAlarmSensitive){if(this.isMajorSeverity())return e.RED;if(this.isMinorSeverity())return e.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 wuid(){return this.properties.getValue(Qt)}get name(){return this.properties.getValue(zt)}get holderX(){return this.scale*this.properties.getValue("x")}get holderY(){return this.scale*this.properties.getValue("y")}get holderWidth(){return this.scale*this.properties.getValue(Jt)}get holderHeight(){return this.scale*this.properties.getValue(Yt)}get borderAlarmSensitive(){return this.properties.getValue(It)}get backgroundAlarmSensitive(){return this.properties.getValue(Dt)}get foregroundAlarmSensitive(){return this.properties.getValue(Gt)}get pvName(){return this.properties.getValue(Ut,!0)}get borderColor(){return this.properties.getValue(Wt)}get borderStyle(){return this.properties.getValue(Bt)}get borderWidth(){return this.scale*this.properties.getValue(Ht)}get backgroundColor(){return this.properties.getValue(Nt)}get foregroundColor(){return this.properties.getValue(Ft)}get transparent(){return this.properties.getValue(Zt)}get visible(){return this.properties.getValue(Kt)}get actions(){return this.properties.getValue(Ot)}get scripts(){return this.properties.getValue(Xt)}get rules(){return this.properties.getValue($t)}get scaleOptions(){return this.properties.getValue(jt)}get text(){if(this.display.editMode){return(this.properties.getProperty(qt).rawValue||"").split(" ").join(" ")}return this.properties.getValue(qt).split(" ").join(" ")}init(){}hide(){}destroy(){}}const ee="font",ie="push_action_index",se="release_action_index",re="toggle_button",oe="image";class ae extends te{constructor(t,e){super(t,e),this.pushed=!1,this.imageLoaded=!1,this.properties.add(new G(ee)),this.properties.add(new B(re)),this.properties.add(new W(ie)),this.properties.add(new W(se)),this.properties.add(new I(oe))}init(){this.image&&(this.imageElement=new Image,this.imageElement.onload=()=>{this.imageLoaded=!0,this.requestRepaint()},this.imageElement.src=`${this.display.baseUrl}${this.image}`),this.areaRegion={id:`${this.wuid}-area`,mouseDown:()=>{this.toggleButton||(this.pushed=!0,this.requestRepaint())},mouseOut:()=>{this.pushed=!1,this.requestRepaint()},mouseUp:()=>{this.toggleButton||(this.pushed=!1,this.requestRepaint())},click:()=>{this.executeAction(this.pushed?this.releaseActionIndex:this.pushActionIndex),this.toggleButton&&(this.pushed=!this.pushed)},cursor:"pointer"}}draw(t){const i=t.ctx,{scale:s}=this;t.fillRect(Object.assign(Object.assign({},this.area),{color:this.backgroundColor}));t.addHitRegion(this.areaRegion).addRect(this.x,this.y,this.width,this.height);const r=1*s,o=this.holderY+r/2,a=this.holderX+r/2,n=this.holderY+this.holderHeight-r+r/2,l=this.holderX+this.holderWidth-r+r/2;t.strokePath({lineWidth:r,color:this.pushed?e.BUTTON_LIGHTEST:e.BLACK,path:new w(l,n).lineTo(l,o).moveTo(l,n).lineTo(a,n)}),t.strokePath({lineWidth:r,color:this.pushed?this.backgroundColor:e.BUTTON_DARKER,path:new w(l-r,n-r).lineTo(l-r,o+r).moveTo(l-r,n-r).lineTo(a+r,n-r)}),t.strokePath({lineWidth:r,color:this.pushed?e.BLACK:e.BUTTON_LIGHTEST,path:new w(a,o).lineTo(l-r,o).moveTo(a,o).lineTo(a,n-r)}),t.strokePath({lineWidth:r,color:this.pushed?e.BUTTON_DARKER:this.backgroundColor,path:new w(a+r,o+r).lineTo(l-r-r,o+r).moveTo(a+r,o+r).lineTo(a+r,n-r-r)});const h=this.text.split("\n");let d,c;if(i.fillStyle=this.foregroundColor.toString(),i.font=this.font.getFontString(),this.imageElement&&this.imageLoaded){const t=i.measureText(h[0]).width,e=this.font.height,r=this.imageElement.naturalHeight*s,o=this.imageElement.naturalWidth*s,a=(this.height-r)/e,n=5*s;if((this.width-o)/t>a){i.textBaseline="middle",i.textAlign="left",d=this.x+(this.width-t)/2+n,c=this.y+this.height/2;const e=this.x+(this.width-t)/2-o,s=this.y+(this.height-r)/2;i.drawImage(this.imageElement,e,s,o,r)}else{i.textAlign="center",i.textBaseline="top";const t=e+r;d=this.x+this.width/2,c=this.y+(this.height-t)/2+r;const s=this.x+(this.width-o)/2,a=this.y+(this.height-t)/2;i.drawImage(this.imageElement,s,a,o,r)}}else i.textBaseline="middle",i.textAlign="center",d=this.x+this.width/2,c=this.y+this.height/2;this.pushed&&(d+=1*s,c+=1*s),i.fillText(h[0],d,c)}get font(){return this.properties.getValue(ee).scale(this.scale)}get image(){return this.properties.getValue(oe)}get toggleButton(){return this.properties.getValue(re)}get pushActionIndex(){return this.properties.getValue(ie)}get releaseActionIndex(){return this.properties.getValue(se)}get backgroundColor(){const t=this.properties.getProperty("background_color");return t&&t.value!==e.TRANSPARENT?t.value:e.BUTTON}}const ne="data_type",le="effect_3d",he="font",de="off_color",ce="off_label",pe="off_state",ue="on_color",ge="on_label",fe="on_state",me="push_action_index",ye="released_action_index",xe="show_led",ve="show_boolean_label",we="square_button",be="toggle_button";class _e extends te{constructor(t,e){super(t,e),this.hovered=!1,this.manualToggleState=!1,this.properties.add(new W("bit")),this.properties.add(new W(ne)),this.properties.add(new B(we)),this.properties.add(new B(xe)),this.properties.add(new B(le)),this.properties.add(new F(ue)),this.properties.add(new I(ge)),this.properties.add(new I(fe)),this.properties.add(new F(de)),this.properties.add(new I(ce)),this.properties.add(new I(pe)),this.properties.add(new G(he)),this.properties.add(new B(be)),this.properties.add(new W(me)),this.properties.add(new W(ye)),this.properties.add(new B(ve))}init(){this.areaRegion={id:`${this.wuid}-area`,mouseDown:()=>{this.toggleButton&&this.booleanValue?this.toggleOff():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()},cursor:"pointer"}}toggleOn(){if(this.manualToggleState=!0,this.pv&&this.pv.writable)if(0===this.dataType)if(this.bit<0)this.display.pvEngine.setValue(new Date,this.pv.name,1);else{const t=this.pv.value|1<<this.bit;this.display.pvEngine.setValue(new Date,this.pv.name,t)}else this.display.pvEngine.setValue(new Date,this.pv.name,this.onState);this.executeAction(this.pushActionIndex)}toggleOff(){if(this.manualToggleState=!1,this.pv&&this.pv.writable)if(0===this.dataType)if(this.bit<0)this.display.pvEngine.setValue(new Date,this.pv.name,0);else{const t=this.pv.value&~(1<<this.bit);this.display.pvEngine.setValue(new Date,this.pv.name,t)}else this.display.pvEngine.setValue(new Date,this.pv.name,this.offState);void 0!==this.releaseActionIndex&&this.executeAction(this.releaseActionIndex)}get booleanValue(){var t,e;return this.pv&&void 0!==this.pv.value?0===this.dataType?this.bit<0?Boolean(null===(t=this.pv)||void 0===t?void 0:t.toNumber()):((null===(e=this.pv)||void 0===e?void 0:e.value)>>this.bit&1)>0:1===this.dataType&&this.pv.toString()===this.onState:this.manualToggleState}draw(t){const 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,i){t.fillRect({x:this.x,y:this.y,width:this.width,height:this.height,color:e.DARK_GRAY});t.addHitRegion(this.areaRegion).addRect(this.x,this.y,this.width,this.height);const s=2*this.scale,r=i?e.DARK_GRAY:e.WHITE,o=i?e.WHITE:e.DARK_GRAY;this.effect3d&&(t.fillPath({color:r,path:new w(this.x,this.y).lineTo(this.x,this.y+this.height).lineTo(this.x+s,this.y+this.height-s).lineTo(this.x+s,this.y+s).lineTo(this.x+this.width-s,this.y+s).lineTo(this.x+this.width,this.y).closePath()}),t.fillPath({color:o,path:new w(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-s,this.y+s).lineTo(this.x+this.width-s,this.y+this.height-s).lineTo(this.x+s,this.y+this.height-s).closePath()}));let a=this.backgroundColor;this.hovered&&(a=this.backgroundColor.mixWith(e.WHITE,.5)),t.fillRect({x:this.x+s,y:this.y+s,width:this.width-s-s,height:this.height-s-s,color:a})}drawEllipse(t,i){const{scale:s}=this;if(this.effect3d){const r=this.width/2,o=this.height/2,a=Math.sqrt(r*r+o*o),n=this.x+r+(o-r-a)/2-1*s,l=this.y+o-(o-r+a)/2-1*s,h=this.x+r+(o-r+a)/2+5*s,d=this.y+o-(o-r-a)/2+5*s,c=t.createLinearGradient(n,l,h,d);i?(c.addColorStop(0,e.DARK_GRAY.toString()),c.addColorStop(1,e.WHITE.toString())):(c.addColorStop(0,e.WHITE.toString()),c.addColorStop(1,e.DARK_GRAY.toString())),t.ctx.fillStyle=c}else t.ctx.fillStyle=i?e.WHITE.toString():e.DARK_GRAY.toString();const r=this.x+this.width/2,o=this.y+this.height/2,a=this.width/2,n=this.height/2;t.ctx.beginPath(),t.ctx.ellipse(r,o,a,n,0,0,2*Math.PI),t.ctx.fill();t.addHitRegion(this.areaRegion).addEllipse(r,o,a,n,0,0,2*Math.PI),this.hovered?t.ctx.fillStyle=this.backgroundColor.mixWith(e.WHITE,.5).toString():t.ctx.fillStyle=this.backgroundColor.toString(),t.ctx.beginPath(),t.ctx.ellipse(r,o,a-2*s,n-2*s,0,0,2*Math.PI),t.ctx.fill()}drawHorizontal(t,e){const{scale:i}=this;if(this.showLed){let s;this.squareButton?(s=Math.floor(.3*(this.width+this.height)/2),s>Math.min(this.width,this.height)&&(s=Math.min(this.width,this.height)-2*i)):(s=Math.floor(.25*(this.width+this.height)/2),s>Math.min(this.width,this.height)&&(s=Math.min(this.width,this.height)-8*i));const r={x:Math.floor(this.x+.79999*this.width-s/2),y:Math.floor(this.y+this.height/2-s/2),width:s,height:s},o=r.x+r.width/2,a=r.y+r.height/2,n=r.width/2,l=r.height/2,h=e?this.onColor:this.offColor;if(t.fillEllipse({cx:o,cy:a,rx:n,ry:l,color:h}),this.effect3d){const e=t.createLinearGradient(r.x,r.y,r.x+r.width,r.y+r.height);e.addColorStop(0,"white"),e.addColorStop(1,h.withAlpha(0).toString()),t.ctx.beginPath(),t.ctx.ellipse(o,a,n,l,0,0,2*Math.PI),t.ctx.fillStyle=e,t.ctx.fill()}}}drawVertical(t,i){const{scale:s}=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*s)):(r=Math.floor(.25*(this.width+this.height)/2),r>Math.min(this.width,this.height)&&(r=Math.min(this.width,this.height)-8*s));const o={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},a=i?this.onColor:this.offColor,n=o.x+o.width/2,l=o.y+o.height/2,h=o.width/2,d=o.height/2;if(t.fillEllipse({cx:n,cy:l,rx:h,ry:d,color:a}),this.effect3d){const i=t.createLinearGradient(o.x,o.y,o.x+o.width,o.y+o.height);i.addColorStop(0,e.WHITE.toString()),i.addColorStop(1,a.withAlpha(0).toString()),t.ctx.beginPath(),t.ctx.ellipse(n,l,h,d,0,0,2*Math.PI),t.ctx.fillStyle=i,t.ctx.fill()}}}get bit(){return this.properties.getValue("bit")}get dataType(){return this.properties.getValue(ne)}get toggleButton(){return this.properties.getValue(be)}get pushActionIndex(){return this.properties.getValue(me)}get releaseActionIndex(){return this.properties.getValue(ye)}get squareButton(){return this.properties.getValue(we)}get showLed(){return this.properties.getValue(xe)}get showBooleanLabel(){return this.properties.getValue(ve)}get effect3d(){return this.properties.getValue(le)}get onColor(){return this.properties.getValue(ue)}get onLabel(){return this.properties.getValue(ge)}get onState(){return this.properties.getValue(fe)}get offColor(){return this.properties.getValue(de)}get offLabel(){return this.properties.getValue(ce)}get offState(){return this.properties.getValue(pe)}get font(){return this.properties.getValue(he).scale(this.scale)}}const Se="data_type",Te="effect_3d",Ce="off_color",Le="off_label",Ae="off_state",ke="on_color",Pe="on_label",Re="on_state",Ee="push_action_index",Me="released_action_index",Ve="toggle_button";class Oe extends te{constructor(t,e){super(t,e),this.manualToggleState=!1,this.properties.add(new W("bit")),this.properties.add(new W(Se)),this.properties.add(new B(Te)),this.properties.add(new F(ke)),this.properties.add(new I(Pe)),this.properties.add(new I(Re)),this.properties.add(new F(Ce)),this.properties.add(new I(Le)),this.properties.add(new I(Ae)),this.properties.add(new W(Ee)),this.properties.add(new W(Me)),this.properties.add(new B(Ve))}init(){this.shaftRegion={id:`${this.wuid}-shaft`,mouseDown:()=>{this.toggleButton&&this.booleanValue?this.toggleOff():this.toggleOn(),this.requestRepaint()},mouseUp:()=>{this.booleanValue&&!this.toggleButton&&(this.toggleOff(),this.requestRepaint())},mouseOut:()=>{this.booleanValue&&!this.toggleButton&&(this.toggleOff(),this.requestRepaint())},cursor:"pointer"}}toggleOn(){if(this.manualToggleState=!0,this.pv&&this.pv.writable)if(0===this.dataType)if(this.bit<0)this.display.pvEngine.setValue(new Date,this.pv.name,1);else{const t=this.pv.value|1<<this.bit;this.display.pvEngine.setValue(new Date,this.pv.name,t)}else this.display.pvEngine.setValue(new Date,this.pv.name,this.onState);this.executeAction(this.pushActionIndex)}toggleOff(){if(this.manualToggleState=!1,this.pv&&this.pv.writable)if(0===this.dataType)if(this.bit<0)this.display.pvEngine.setValue(new Date,this.pv.name,0);else{const t=this.pv.value&~(1<<this.bit);this.display.pvEngine.setValue(new Date,this.pv.name,t)}else this.display.pvEngine.setValue(new Date,this.pv.name,this.offState);void 0!==this.releaseActionIndex&&this.executeAction(this.releaseActionIndex)}get booleanValue(){var t,e;return this.pv&&void 0!==this.pv.value?0===this.dataType?this.bit<0?Boolean(null===(t=this.pv)||void 0===t?void 0:t.toNumber()):((null===(e=this.pv)||void 0===e?void 0:e.value)>>this.bit&1)>0:1===this.dataType&&this.pv.toString()===this.onState:this.manualToggleState}draw(t){const e=this.booleanValue;this.width>this.height?this.drawHorizontal(t,e):this.drawVertical(t,e)}drawHorizontal(t,e){let i=this.width,s=this.height;s>i/2?s=Math.floor(this.width/2):i=Math.floor(2*this.height);const r={x:Math.floor(63/218*i),y:0,width:s/2,height:s/2};this.drawPedestal(t,r,e);const o=Math.floor(35/218*i),a=Math.floor(45/105*s),n=Math.floor(43/218*i),l=Math.floor(35/105*s),h=Math.floor(1/7*r.width);if(e){const e={x:2*r.x+r.width-o,y:r.height/2-a/2,width:o,height:a},i={x:r.x+r.width/2-n/2+h,y:r.y+r.height/2-l/2,width:n,height:l};this.drawHorizontalBar(t,i,e,!0)}else{const e={x:0,y:r.height/2-a/2,width:o,height:a},i={x:r.x+r.width/2-n/2-h,y:r.y+r.height/2-l/2,width:n,height:l};this.drawHorizontalBar(t,i,e,!1)}}drawVertical(t,e){let i=this.width,s=this.height;i>s/2?i=Math.floor(this.height/2):s=Math.floor(2*this.width);const r={x:0,y:Math.floor(63/218*s),width:i/2,height:i/2};this.drawPedestal(t,r,e);const o=Math.floor(45/105*i),a=Math.floor(35/218*s),n=Math.floor(35/105*i),l=Math.floor(43/218*s);if(e){const e={x:r.width/2-o/2,y:0,width:o,height:a},i={x:r.x+r.width/2-n/2,y:r.y+r.height/2-l/2,width:n,height:l};i.y-=Math.floor(1/7*r.height),this.drawVerticalBar(t,i,e,!0)}else{const e=r.y+r.height/2+l/2+2*this.scale,i={x:r.width/2-o/2,y:r.y+r.height/2-l/2+e-a,width:o,height:a},s={x:r.x+r.width/2-n/2,y:r.y+r.height/2-l/2,width:n,height:l};s.y+=Math.floor(1/7*r.height),this.drawVerticalBar(t,s,i,!1)}}drawPedestal(t,i,s){let r=this.x+i.x+i.width/2,o=this.y+i.y+i.height/2,a=i.width/2,n=i.height/2;if(t.ctx.fillStyle=this.effect3d?e.WHITE.toString():e.GRAY.toString(),t.ctx.beginPath(),t.ctx.ellipse(r,o,a,n,0,0,2*Math.PI),t.ctx.fill(),this.effect3d){const e=t.createLinearGradient(this.x+i.x,this.y+i.y,this.x+i.x+i.width,this.y+i.y+i.height);s?(e.addColorStop(0,`rgba(255,255,255,${10/255})`),e.addColorStop(1,`rgba(0,0,0,${100/255})`)):(e.addColorStop(0,"rgba(0,0,0,0)"),e.addColorStop(1,`rgba(0,0,0,${150/255})`)),t.ctx.fillStyle=e,t.ctx.fill()}}drawHorizontalBar(t,e,i,s){let r=(s?0:10)/255,o=(s?150:220)/255;const 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,${r})`),a.addColorStop(1,`rgba(0,0,0,${o})`);const n=t.addHitRegion(this.shaftRegion);let l=this.x+e.x+e.width/2,h=this.y+e.y+e.height/2,d=e.width/2,c=e.height/2;t.ctx.beginPath(),t.ctx.ellipse(l,h,d,c,0,0,2*Math.PI),n.addEllipse(l,h,d,c,0,0,2*Math.PI),t.ctx.fillStyle=s?this.onColor.toString():this.offColor.toString(),t.ctx.fill(),this.effect3d&&(t.ctx.fillStyle=a,t.ctx.fill());const p=[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(p[0],p[1]),t.ctx.lineTo(p[2],p[3]),t.ctx.lineTo(p[4],p[5]),t.ctx.lineTo(p[6],p[7]),t.ctx.closePath(),n.addPath(new w(p[0],p[1]).lineTo(p[2],p[3]).lineTo(p[4],p[5]).lineTo(p[6],p[7]).closePath()),t.ctx.fillStyle=s?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,h=this.y+i.y+i.height/2,d=i.width/2,c=i.height/2,t.ctx.beginPath(),t.ctx.ellipse(l,h,d,c,0,0,2*Math.PI),n.addEllipse(l,h,d,c,0,0,2*Math.PI),t.ctx.fillStyle=s?this.onColor.toString():this.offColor.toString(),t.ctx.fill(),this.effect3d){const{scale:e}=this,s=Math.sqrt(d*d+c*c),a=c-d,n=this.x+i.x+d+(a-s)/2-1*e,l=this.x+i.y+c-(a+s)/2-1*e,h=this.x+i.x+d+(a+s)/2+5*e,p=this.x+i.y+c-(a-s)/2+5*e,u=t.createLinearGradient(n,l,h,p);u.addColorStop(0,`rgba(0,0,0,${r})`),u.addColorStop(1,`rgba(0,0,0,${o})`),t.ctx.fillStyle=u,t.ctx.fill()}}drawVerticalBar(t,e,i,s){const r=t.createLinearGradient(this.x+i.x,this.y+i.y,this.x+i.x+i.width,this.y+i.y);r.addColorStop(0,`rgba(0,0,0,${10/255})`),r.addColorStop(1,`rgba(0,0,0,${s?210/255:160/255})`);const o=t.addHitRegion(this.shaftRegion);let a=this.x+e.x+e.width/2,n=this.y+e.y+e.height/2;t.ctx.beginPath(),t.ctx.ellipse(a,n,e.width/2,e.height/2,0,0,2*Math.PI),o.addEllipse(a,n,e.width/2,e.height/2,0,0,2*Math.PI),t.ctx.fillStyle=s?this.onColor.toString():this.offColor.toString(),t.ctx.fill(),this.effect3d&&(t.ctx.fillStyle=r,t.ctx.fill());const 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 w(l[0],l[1]).lineTo(l[2],l[3]).lineTo(l[4],l[5]).lineTo(l[6],l[7]).closePath()),t.ctx.fillStyle=s?this.onColor.toString():this.offColor.toString(),t.ctx.fill(),this.effect3d&&(t.ctx.fillStyle=r,t.ctx.fill()),a=this.x+i.x+i.width/2,n=this.y+i.y+i.height/2;const h=i.width/2,d=i.height/2;if(t.ctx.beginPath(),t.ctx.ellipse(a,n,h,d,0,0,2*Math.PI),o.addEllipse(a,n,h,d,0,0,2*Math.PI),t.ctx.fillStyle=s?this.onColor.toString():this.offColor.toString(),t.ctx.fill(),this.effect3d){const e=t.createLinearGradient(this.x+i.x,this.y+i.y,this.x+i.width,this.y+i.height);e.addColorStop(0,`rgba(0,0,0,${(s?5:10)/255})`),e.addColorStop(1,`rgba(0,0,0,${(s?180:160)/255})`),t.ctx.fillStyle=e,t.ctx.fill()}}get bit(){return this.properties.getValue("bit")}get dataType(){return this.properties.getValue(Se)}get toggleButton(){return this.properties.getValue(Ve)}get pushActionIndex(){return this.properties.getValue(Ee)}get releaseActionIndex(){return this.properties.getValue(Me)}get effect3d(){return this.properties.getValue(Te)}get onColor(){return this.properties.getValue(ke)}get onLabel(){return this.properties.getValue(Pe)}get onState(){return this.properties.getValue(Re)}get offColor(){return this.properties.getValue(Ce)}get offLabel(){return this.properties.getValue(Le)}get offState(){return this.properties.getValue(Ae)}}const Ne="enabled",De="font",Ie="label",We="selected_color",He=new e(130,130,130),Be=new e(94,151,230);class Fe extends te{constructor(t,e){super(t,e),this.hovered=!1,this.manualToggleState=!1,this.properties.add(new W("bit")),this.properties.add(new B(Ne)),this.properties.add(new G(De)),this.properties.add(new I(Ie)),this.properties.add(new F(We))}init(){this.areaRegion={id:`${this.wuid}-area`,mouseDown:()=>{this.booleanValue?this.toggleOff():this.toggleOn(),this.requestRepaint()},mouseEnter:()=>{this.hovered=!0,this.requestRepaint()},mouseOut:()=>{this.hovered=!1,this.requestRepaint()},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{const t=this.pv.value|1<<this.bit;this.display.pvEngine.setValue(new Date,this.pv.name,t)}}toggleOff(){if(this.manualToggleState=!1,this.pv&&this.pv.writable)if(this.bit<0)this.display.pvEngine.setValue(new Date,this.pv.name,0);else{const t=this.pv.value&~(1<<this.bit);this.display.pvEngine.setValue(new Date,this.pv.name,t)}}get booleanValue(){var t,e;return this.pv&&void 0!==this.pv.value?this.bit<0?Boolean(null===(t=this.pv)||void 0===t?void 0:t.toNumber()):((null===(e=this.pv)||void 0===e?void 0:e.value)>>this.bit&1)>0:this.manualToggleState}draw(t){t.addHitRegion(this.areaRegion).addRect(this.x,this.y,this.width,this.height);const i=this.booleanValue,{boxSize:s,gap:r,scale:o}=this;let a=this.backgroundColor;this.hovered&&(a=a.mixWith(Be,.7));const n={x:this.x,y:this.y+this.height/2-s/2,width:s,height:s},l=t.createLinearGradient(n.x,n.y+1*o,n.x,n.y+n.height);l.addColorStop(0,e.WHITE.toString()),l.addColorStop(1,a.toString()),t.fillRect(Object.assign(Object.assign({},n),{rx:2*o,ry:2*o,gradient:l})),t.strokeRect({x:n.x+.5*o,y:n.y+.5*o,width:n.width-1*o,height:n.height-1*o,rx:2*o,ry:2*o,color:He}),i&&t.strokePath({lineWidth:3*o,color:this.selectedColor,path:new w(n.x+3*o,n.y+Math.floor(.45*s)).lineTo(n.x+Math.floor(.45*s),n.y+3*s/4-1*o).lineTo(n.x+s-2*o,n.y+3*o)}),this.enabled?t.fillText({x:n.x+n.width+r,y:n.y+n.height/2,align:"left",baseline:"middle",color:this.foregroundColor,font:this.font,text:this.label}):(t.fillText({x:n.x+n.width+r+1*o,y:n.y+n.height/2+1*o,align:"left",baseline:"middle",color:e.BUTTON_LIGHTEST,font:this.font,text:this.label}),t.fillText({x:n.x+n.width+r,y:n.y+n.height/2,align:"left",baseline:"middle",color:e.BUTTON_DARKER,font:this.font,text:this.label}))}get boxSize(){return 16*this.scale}get gap(){return 4*this.scale}get bit(){return this.properties.getValue("bit")}get enabled(){return this.properties.getValue(Ne)}get selectedColor(){return this.properties.getValue(We)}get font(){return this.properties.getValue(De).scale(this.scale)}get label(){return this.properties.getValue(Ie)}}const Ge="enabled",Ye="font",ze="horizontal",Ue="items",$e="items_from_pv",je="selected_color";class Xe extends te{constructor(t,e){super(t,e),this.itemRegions=[],this.properties.add(new B(Ge)),this.properties.add(new G(Ye)),this.properties.add(new B(ze)),this.properties.add(new j(Ue,[])),this.properties.add(new B($e)),this.properties.add(new F(je))}init(){for(let t=0;t<this.items.length;t++)this.itemRegions.push({id:`${this.wuid}-item-${t}`,cursor:"pointer",mouseDown:()=>{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()}})}draw(t){this.horizontal?this.drawHorizontal(t):this.drawVertical(t)}drawHorizontal(t){const e=this.area.width/this.items.length;let i=this.area.x;for(let s=0;s<this.items.length;s++){const r={x:i,y:this.area.y,width:e,height:this.area.height};i+=e,this.drawButton(t,r,s)}}drawVertical(t){const e=this.area.height/this.items.length;let i=this.area.y;for(let s=0;s<this.items.length;s++){const r={x:Math.round(this.area.x),y:Math.round(i),width:Math.round(this.area.width),height:Math.round(e)};i+=e,this.drawButton(t,r,s)}}drawButton(t,i,s){var r;const o=(null===(r=this.pv)||void 0===r?void 0:r.value)===this.items[s],a=o||s===this.pushedItem;t.fillRect(Object.assign(Object.assign({},i),{color:o?this.selectedColor:this.backgroundColor}));t.addHitRegion(this.itemRegions[s]).addRect(i.x,i.y,i.width,i.height);const n=1*this.scale,l=i.y+n/2,h=i.x+n/2,d=i.y+i.height-n+n/2,c=i.x+i.width-n+n/2;t.strokePath({lineWidth:n,color:a?e.BUTTON_LIGHTEST:e.BLACK,path:new w(c,d).lineTo(c,l).moveTo(c,d).lineTo(h,d)}),t.strokePath({lineWidth:n,color:a?this.backgroundColor:e.BUTTON_DARKER,path:new w(c-n,d-n).lineTo(c-n,l+n).moveTo(c-n,d-n).lineTo(h+n,d-n)}),t.strokePath({lineWidth:n,color:a?e.BLACK:e.BUTTON_LIGHTEST,path:new w(h,l).lineTo(c-n,l).moveTo(h,l).lineTo(h,d-n)}),t.strokePath({lineWidth:n,color:a?e.BUTTON_DARKER:this.backgroundColor,path:new w(h+n,l+n).lineTo(c-n-n,l+n).moveTo(h+n,l+n).lineTo(h+n,d-n-n)}),t.fillText({x:i.x+i.width/2,y:i.y+i.height/2,text:this.items[s],align:"center",baseline:"middle",color:this.foregroundColor,font:this.font})}writeValue(t){this.pv&&this.pv.writable&&this.display.pvEngine.setValue(new Date,this.pv.name,t)}get enabled(){return this.properties.getValue(Ge)}get font(){return this.properties.getValue(Ye).scale(this.scale)}get horizontal(){return this.properties.getValue(ze)}get items(){return this.properties.getValue(Ue)}get itemsFromPV(){return this.properties.getValue($e)}get selectedColor(){return this.properties.getValue(je)}}const qe="enabled",Ze="font",Ke="items",Je="items_from_pv",Qe=new e(240,240,240);class ti extends te{constructor(t,e){super(t,e),this.listVisible=!1,this.itemRegions=[],this.properties.add(new B(qe)),this.properties.add(new G(Ze)),this.properties.add(new j(Ke,[])),this.properties.add(new B(Je))}init(){this.areaRegion={id:`${this.wuid}-area`,click:()=>{const t=this.listVisible;this.display.closeMenu(),this.items.length&&!t&&(this.listVisible=!0,this.hoveredItem=0,this.requestRepaint())}};for(let t=0;t<this.items.length;t++)this.itemRegions.push({id:`${this.wuid}-item-${t}`,click:()=>{this.writeValue(this.items[t]),this.listVisible=!1,this.hoveredItem=void 0,this.requestRepaint()},mouseEnter:()=>{this.hoveredItem=t,this.requestRepaint()},mouseOut:()=>{this.hoveredItem=void 0,this.requestRepaint()}})}draw(t){var e,i;let s=d(this.bounds,2*this.scale);t.fillRect(Object.assign(Object.assign({},s),{color:this.backgroundColor})),t.strokeRect(Object.assign(Object.assign({},s),{color:Qe,crispen:!0}));t.addHitRegion(this.areaRegion).addRect(s.x,s.y,s.width,s.height),(null===(e=this.pv)||void 0===e?void 0:e.value)&&-1!==this.items.indexOf(this.pv.value)&&t.fillText({x:5*this.scale+s.x,y:s.y+s.height/2,align:"left",baseline:"middle",color:this.foregroundColor,font:this.font,text:null===(i=this.pv)||void 0===i?void 0:i.value});const{selectorWidth:r}=this,o=Math.min(s.height,r/2),a={x:s.x+s.width-r-5*this.scale+r/2,y:s.y+(s.height-o)/2+o};t.fillPath({color:this.foregroundColor,path:new w(a.x,a.y).lineTo(a.x-o,a.y-o).lineTo(a.x+o,a.y-o).closePath()})}closeMenu(){this.listVisible=!1,this.requestRepaint()}drawOverlay(t){if(!this.listVisible||!this.items.length)return;let i=0,s=0;for(const e of this.items){const r=t.measureText(e,this.font);i=Math.max(i,r.width),s=Math.max(s,r.height)}const{scale:r}=this,o=5*r,a=o+s+o,n={x:this.bounds.x+5*r,y:this.bounds.y+this.bounds.height-5*r,width:o+i+o,height:a*this.items.length+2*r+2*r};t.fillRect(Object.assign(Object.assign({},n),{color:this.backgroundColor}));for(let i=0;i<this.items.length;i++){const s={x:n.x,y:n.y+2*r+i*a,width:n.width,height:a};t.addHitRegion(this.itemRegions[i]).addRect(s.x,s.y,s.width,s.height),i===this.hoveredItem&&t.fillRect(Object.assign(Object.assign({},s),{color:e.LIGHT_BLUE}))}t.strokeRect(Object.assign(Object.assign({},n),{color:Qe,lineWidth:1*r,crispen:!0}));for(let e=0;e<this.items.length;e++)t.fillText({x:n.x+o,y:n.y+2*r+e*a+a/2,font:this.font,color:this.foregroundColor,align:"left",baseline:"middle",text:this.items[e]})}writeValue(t){this.pv&&this.pv.writable&&this.display.pvEngine.setValue(new Date,this.pv.name,t)}get selectorWidth(){return 8*this.scale}get enabled(){return this.properties.getValue(qe)}get font(){return this.properties.getValue(Ze).scale(this.scale)}get items(){return this.properties.getValue(Ke)}get itemsFromPV(){return this.properties.getValue(Je)}}const ei="data_type",ii="effect_3d",si="font",ri="off_image",oi="off_label",ai="off_state",ni="on_image",li="on_label",hi="on_state",di="push_action_index",ci="released_action_index",pi="show_boolean_label",ui="toggle_button";class gi extends te{constructor(t,e){super(t,e),this.onImageLoaded=!1,this.offImageLoaded=!1,this.manualToggleState=!1,this.properties.add(new W("bit")),this.properties.add(new W(ei)),this.properties.add(new B(ii)),this.properties.add(new I(ni)),this.properties.add(new I(li)),this.properties.add(new I(hi)),this.properties.add(new I(ri)),this.properties.add(new I(oi)),this.properties.add(new I(ai)),this.properties.add(new G(si)),this.properties.add(new B(ui)),this.properties.add(new W(di)),this.properties.add(new W(ci)),this.properties.add(new B(pi))}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.display.baseUrl}${this.onImage}`),this.offImage&&(this.offImageElement.src=`${this.display.baseUrl}${this.offImage}`),this.areaRegion={id:`${this.wuid}-area`,mouseDown:()=>{this.toggleButton&&this.booleanValue?this.toggleOff():this.toggleOn(),this.requestRepaint()},mouseUp:()=>{this.booleanValue&&!this.toggleButton&&(this.toggleOff(),this.requestRepaint())},mouseOut:()=>{this.booleanValue&&!this.toggleButton&&(this.toggleOff(),this.requestRepaint())},cursor:"pointer"}}toggleOn(){if(this.manualToggleState=!0,this.pv&&this.pv.writable)if(0===this.dataType)if(this.bit<0)this.display.pvEngine.setValue(new Date,this.pv.name,1);else{const t=this.pv.value|1<<this.bit;this.display.pvEngine.setValue(new Date,this.pv.name,t)}else this.display.pvEngine.setValue(new Date,this.pv.name,this.onState);this.executeAction(this.pushActionIndex)}toggleOff(){if(this.manualToggleState=!1,this.pv&&this.pv.writable)if(0===this.dataType)if(this.bit<0)this.display.pvEngine.setValue(new Date,this.pv.name,0);else{const t=this.pv.value&~(1<<this.bit);this.display.pvEngine.setValue(new Date,this.pv.name,t)}else this.display.pvEngine.setValue(new Date,this.pv.name,this.offState);void 0!==this.releaseActionIndex&&this.executeAction(this.releaseActionIndex)}get booleanValue(){var t,e;return this.pv&&void 0!==this.pv.value?0===this.dataType?this.bit<0?Boolean(null===(t=this.pv)||void 0===t?void 0:t.toNumber()):((null===(e=this.pv)||void 0===e?void 0:e.value)>>this.bit&1)>0:1===this.dataType&&this.pv.toString()===this.onState:this.manualToggleState}draw(t){let e=this.bounds;this.borderAlarmSensitive&&(e=d(e,2*this.scale,2*this.scale));const 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("bit")}get dataType(){return this.properties.getValue(ei)}get toggleButton(){return this.properties.getValue(ui)}get pushActionIndex(){return this.properties.getValue(di)}get releaseActionIndex(){return this.properties.getValue(ci)}get showBooleanLabel(){return this.properties.getValue(pi)}get effect3d(){return this.properties.getValue(ii)}get onImage(){return this.properties.getValue(ni)}get onLabel(){return this.properties.getValue(li)}get onState(){return this.properties.getValue(hi)}get offImage(){return this.properties.getValue(ri)}get offLabel(){return this.properties.getValue(oi)}get offState(){return this.properties.getValue(ai)}get font(){return this.properties.getValue(si).scale(this.scale)}}class fi extends ae{}const mi="enabled",yi="font",xi="horizontal",vi="items",wi="items_from_pv",bi="selected_color",_i=new e(120,120,120),Si=new e(94,151,230);class Ti extends te{constructor(t,e){super(t,e),this.itemRegions=[],this.properties.add(new B(mi)),this.properties.add(new G(yi)),this.properties.add(new B(xi)),this.properties.add(new j(vi,[])),this.properties.add(new B(wi)),this.properties.add(new F(bi))}init(){for(let t=0;t<this.items.length;t++)this.itemRegions.push({id:`${this.wuid}-item-${t}`,cursor:"pointer",click:()=>{this.writeValue(this.items[t]),this.requestRepaint()},mouseEnter:()=>{this.hoveredItem=t,this.requestRepaint()},mouseOut:()=>{this.hoveredItem=void 0,this.requestRepaint()}})}draw(t){this.horizontal?this.drawHorizontal(t):this.drawVertical(t)}drawHorizontal(t){const e=this.area.width/this.items.length;let i=this.area.x;for(let s=0;s<this.items.length;s++){const r={x:i,y:this.area.y,width:e,height:this.area.height};i+=e,this.drawRadio(t,r,s)}}drawVertical(t){const e=this.area.height/this.items.length;let i=this.area.y;for(let s=0;s<this.items.length;s++){const r={x:this.area.x,y:i,width:this.area.width,height:e};i+=e,this.drawRadio(t,r,s)}}drawRadio(t,i,s){var r;const{radioRadius:o,dotRadius:a,gap:n}=this;let l=this.backgroundColor;s===this.hoveredItem&&(l=l.mixWith(Si,.7));const h=t.createLinearGradient(i.x,i.y,i.x+i.width,i.y+i.height);h.addColorStop(0,e.WHITE.toString()),h.addColorStop(1,l.toString()),t.fillEllipse({cx:i.x+o,cy:i.y+i.height/2,rx:o,ry:o,gradient:h});const d=1*this.scale;t.strokeEllipse({cx:i.x+o,cy:i.y+i.height/2,rx:o,ry:o,color:_i,lineWidth:d}),(null===(r=this.pv)||void 0===r?void 0:r.value)===this.items[s]&&t.fillEllipse({cx:i.x+o,cy:i.y+i.height/2,rx:a+d/2,ry:a+d/2,color:this.selectedColor});t.addHitRegion(this.itemRegions[s]).addRect(i.x,i.y,i.width,i.height),t.fillText({x:i.x+o+o+n,y:i.y+i.height/2,text:this.items[s],align:"left",baseline:"middle",color:this.foregroundColor,font:this.font})}writeValue(t){this.pv&&this.pv.writable&&this.display.pvEngine.setValue(new Date,this.pv.name,t)}get radioRadius(){return 7*this.scale}get dotRadius(){return 2*this.scale}get gap(){return 4*this.scale}get enabled(){return this.properties.getValue(mi)}get font(){return this.properties.getValue(yi).scale(this.scale)}get horizontal(){return this.properties.getValue(xi)}get items(){return this.properties.getValue(vi)}get itemsFromPV(){return this.properties.getValue(wi)}get selectedColor(){return this.properties.getValue(bi)}}const Ci="enabled",Li="font",Ai="maximum",ki="minimum",Pi="horizontal",Ri="step_increment",Ei="page_increment",Mi="bar_length",Vi="show_value_tip",Oi=new e(243,243,243),Ni=new e(232,232,231),Di=150;class Ii extends te{constructor(t,e){super(t,e),this.decreasePressed=!1,this.increasePressed=!1,this.pageDecreasePressed=!1,this.pageIncreasePressed=!1,this.properties.add(new B(Ci)),this.properties.add(new B(Pi)),this.properties.add(new B(Vi)),this.properties.add(new G(Li)),this.properties.add(new H(Ai)),this.properties.add(new H(ki)),this.properties.add(new H(Ri)),this.properties.add(new H(Ei)),this.properties.add(new H(Mi))}init(){this.decreaseRegion={id:`${this.wuid}-decrease`,mouseDown:()=>{this.decreasePressed=!0,this.stepDecreaseRepeatedly()},mouseUp:()=>{window.clearTimeout(this.actionTimeout),this.decreasePressed=!1,this.requestRepaint()},mouseOut:()=>{window.clearTimeout(this.actionTimeout),this.decreasePressed=!1,this.requestRepaint()}},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()}},this.thumbRegion={id:`${this.wuid}-thumb`,mouseDown:()=>{this.grabStartValue=this.getCoercedValue()},grab:(t,e)=>{const i=this.horizontal?t:e,s=(this.maximum-this.minimum)*i/this.dragRange;this.setCoercedValue(this.grabStartValue+s),this.requestRepaint()}},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()}},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()}}}draw(t){this.horizontal?this.drawHorizontal(t):this.drawVertical(t)}drawHorizontal(t){const{scale:i}=this,s=d(this.bounds,2*i);t.fillRect(Object.assign(Object.assign({},s),{color:Oi}));const r=Math.min(s.height,s.width/2);this.drawLeftButton(t,{x:s.x,y:s.y,width:r,height:s.height}),this.drawRightButton(t,{x:s.x+s.width-r,y:s.y,width:r,height:s.height});const o=this.barLength,a=this.maximum+o,n=this.minimum,l=a-n,h=l-o,c=s.width-r-r,p=Math.floor(Math.max(6*i,c*o/l));this.dragRange=c-p;const u=this.getCoercedValue(),g=Math.floor((c-p)*(u-n)/h),f=c-g-p,m={x:s.x+r+g,y:s.y,width:p,height:s.height};t.fillRect(Object.assign(Object.assign({},m),{color:Ni})),this.drawRaisedButtonBorder(t,m);t.addHitRegion(this.thumbRegion).addRect(m.x,m.y,m.width,m.height);const y={x:s.x+r,y:s.y,width:g,height:s.height};t.addHitRegion(this.pageDecreaseRegion).addRect(y.x,y.y,y.width,y.height),this.pageDecreasePressed&&t.fillRect(Object.assign(Object.assign({},y),{color:e.BLACK}));const x={x:s.x+r+g+p,y:s.y,width:f,height:s.height};t.addHitRegion(this.pageIncreaseRegion).addRect(x.x,x.y,x.width,x.height),this.pageIncreasePressed&&t.fillRect(Object.assign(Object.assign({},x),{color:e.BLACK}))}drawVertical(t){const{scale:i}=this,s=d(this.bounds,i);t.fillRect(Object.assign(Object.assign({},s),{color:Oi}));const r=Math.min(s.width,s.height/2);this.drawUpButton(t,{x:s.x,y:s.y,width:s.width,height:r}),this.drawDownButton(t,{x:s.x,y:s.y+s.height-r,width:s.width,height:r});const o=this.barLength,a=this.maximum+o,n=this.minimum,l=a-n,h=l-o,c=s.height-r-r,p=Math.floor(Math.max(6*i,c*o/l));this.dragRange=c-p;const u=this.getCoercedValue(),g=Math.floor((c-p)*(u-n)/h),f=c-g-p,m={x:s.x,y:s.y+r+g,width:s.width,height:p};t.fillRect(Object.assign(Object.assign({},m),{color:Ni})),this.drawRaisedButtonBorder(t,m);t.addHitRegion(this.thumbRegion).addRect(m.x,m.y,m.width,m.height);const y={x:s.x,y:s.y+r,width:s.width,height:g};t.addHitRegion(this.pageDecreaseRegion).addRect(y.x,y.y,y.width,y.height),this.pageDecreasePressed&&t.fillRect(Object.assign(Object.assign({},y),{color:e.BLACK}));const x={x:s.x,y:s.y+r+g+p,width:s.width,height:f};t.addHitRegion(this.pageIncreaseRegion).addRect(x.x,x.y,x.width,x.height),this.pageIncreasePressed&&t.fillRect(Object.assign(Object.assign({},x),{color:e.BLACK}))}drawLeftButton(t,i){t.fillRect(Object.assign(Object.assign({},i),{color:Ni})),this.decreasePressed?this.drawPressedButtonBorder(t,i):this.drawRaisedButtonBorder(t,i);t.addHitRegion(this.decreaseRegion).addRect(i.x,i.y,i.width,i.height);const s=d(i,3*this.scale);let r=Math.min(s.height/2,s.width);s.x+=(s.width-r)/2,r=Math.max(r,1);const o={x:s.x,y:s.y+s.height/2};t.fillPath({color:e.BLACK,path:new w(o.x,o.y).lineTo(o.x+r,o.y-r).lineTo(o.x+r,o.y+r).closePath()})}drawRightButton(t,i){t.fillRect(Object.assign(Object.assign({},i),{color:Ni})),this.increasePressed?this.drawPressedButtonBorder(t,i):this.drawRaisedButtonBorder(t,i);t.addHitRegion(this.increaseRegion).addRect(i.x,i.y,i.width,i.height);const s=d(i,3*this.scale);let r=Math.min(s.height/2,s.width);s.x+=(s.width-r)/2,r=Math.max(r,1);const o={x:s.x+r,y:s.y+s.height/2};t.fillPath({color:e.BLACK,path:new w(o.x,o.y).lineTo(o.x-r,o.y-r).lineTo(o.x-r,o.y+r).closePath()})}drawUpButton(t,i){t.fillRect(Object.assign(Object.assign({},i),{color:Ni})),this.decreasePressed?this.drawPressedButtonBorder(t,i):this.drawRaisedButtonBorder(t,i);t.addHitRegion(this.decreaseRegion).addRect(i.x,i.y,i.width,i.height);const s=d(i,3*this.scale);let r=Math.min(s.height,s.width/2);s.y+=(s.height-r)/2,r=Math.max(r,1);const o={x:s.x+s.width/2,y:s.y};t.fillPath({color:e.BLACK,path:new w(o.x,o.y).lineTo(o.x-r,o.y+r).lineTo(o.x+r,o.y+r).closePath()})}drawDownButton(t,i){t.fillRect(Object.assign(Object.assign({},i),{color:Ni})),this.increasePressed?this.drawPressedButtonBorder(t,i):this.drawRaisedButtonBorder(t,i);t.addHitRegion(this.increaseRegion).addRect(i.x,i.y,i.width,i.height);const s=d(i,3*this.scale);let r=Math.min(s.height,s.width/2);s.y+=(s.height-r)/2,r=Math.max(r,1);const o={x:s.x+s.width/2,y:s.y+r};t.fillPath({color:e.BLACK,path:new w(o.x,o.y).lineTo(o.x-r,o.y-r).lineTo(o.x+r,o.y-r).closePath()})}drawRaisedButtonBorder(t,i){this.drawButtonBorder(t,i,e.BUTTON_DARKEST,e.BUTTON_DARKER,e.BUTTON,e.BUTTON_LIGHTEST)}drawPressedButtonBorder(t,i){this.drawButtonBorder(t,i,e.BUTTON_LIGHTEST,e.BUTTON_LIGHTEST,e.BUTTON_DARKEST,e.BUTTON_DARKER)}drawButtonBorder(t,e,i,s,r,o){const a=1*this.scale,n=e.y+a/2,l=e.x+a/2,h=e.y+e.height-a+a/2,d=e.x+e.width-a+a/2;t.strokePath({color:i,path:new w(d,h).lineTo(d,n).moveTo(d,h).lineTo(l,h)}),t.strokePath({color:s,path:new w(d-a,h-a).lineTo(d-a,n+a).moveTo(d-a,h-a).lineTo(l+a,h-a)}),t.strokePath({color:r,path:new w(l,n).lineTo(d-a,n).moveTo(l,n).lineTo(l,h-a)}),t.strokePath({color:o,path:new w(l+a,n+a).lineTo(d-a-a,n+a).moveTo(l+a,n+a).lineTo(l+a,h-a-a)})}stepIncreaseRepeatedly(){window.clearTimeout(this.actionTimeout),this.stepIncrease(),this.requestRepaint(),this.actionTimeout=window.setTimeout((()=>this.stepIncreaseRepeatedly()),Di)}stepDecreaseRepeatedly(){window.clearTimeout(this.actionTimeout),this.stepDecrease(),this.requestRepaint(),this.actionTimeout=window.setTimeout((()=>this.stepDecreaseRepeatedly()),Di)}stepIncrease(){var t,e;const i=null!==(e=null===(t=this.pv)||void 0===t?void 0:t.value)&&void 0!==e?e:(this.maximum-this.minimum)/2;this.setCoercedValue(i+this.stepIncrement)}stepDecrease(){var t,e;const i=null!==(e=null===(t=this.pv)||void 0===t?void 0:t.value)&&void 0!==e?e:(this.maximum-this.minimum)/2;this.setCoercedValue(i-this.stepIncrement)}pageIncreaseRepeatedly(){window.clearTimeout(this.actionTimeout),this.pageIncrease(),this.requestRepaint(),this.actionTimeout=window.setTimeout((()=>this.pageIncreaseRepeatedly()),Di)}pageDecreaseRepeatedly(){window.clearTimeout(this.actionTimeout),this.pageDecrease(),this.requestRepaint(),this.actionTimeout=window.setTimeout((()=>this.pageDecreaseRepeatedly()),Di)}pageIncrease(){var t,e;const i=null!==(e=null===(t=this.pv)||void 0===t?void 0:t.value)&&void 0!==e?e:(this.maximum-this.minimum)/2;this.setCoercedValue(i+this.pageIncrement)}pageDecrease(){var t,e;const i=null!==(e=null===(t=this.pv)||void 0===t?void 0:t.value)&&void 0!==e?e:(this.maximum-this.minimum)/2;this.setCoercedValue(i-this.pageIncrement)}setCoercedValue(t){this.pv&&this.pv.writable&&(t=t<this.minimum?this.minimum:t>this.maximum?this.maximum:t,this.display.pvEngine.setValue(new Date,this.pv.name,t))}getCoercedValue(){var t,e;const i=null!==(e=null===(t=this.pv)||void 0===t?void 0:t.value)&&void 0!==e?e:(this.maximum-this.minimum)/2;return i<this.minimum?this.minimum:i>this.maximum?this.maximum:i}destroy(){window.clearTimeout(this.actionTimeout)}get enabled(){return this.properties.getValue(Ci)}get horizontal(){return this.properties.getValue(Pi)}get showValueTip(){return this.properties.getValue(Vi)}get font(){return this.properties.getValue(Li).scale(this.scale)}get minimum(){return this.properties.getValue(ki)}get maximum(){return this.properties.getValue(Ai)}get stepIncrement(){return this.properties.getValue(Ri)}get pageIncrement(){return this.properties.getValue(Ei)}get barLength(){return this.properties.getValue(Mi)}}const Wi="font",Hi="format_type",Bi="horizontal_alignment",Fi="precision",Gi="precision_from_pv",Yi="vertical_alignment";class zi extends te{constructor(t,e){super(t,e),this.properties.add(new G(Wi)),this.properties.add(new W(Hi)),this.properties.add(new W(Bi)),this.properties.add(new W(Fi)),this.properties.add(new B(Gi)),this.properties.add(new W(Yi,1))}draw(t){const e=t.ctx;this.transparent?this.backgroundAlarmSensitive&&this.alarm&&t.fillRect(Object.assign(Object.assign({},this.area),{color:this.alarmSensitiveBackgroundColor})):t.fillRect(Object.assign(Object.assign({},this.area),{color:this.backgroundColor}));const i=document.createElement("canvas");i.width=this.area.width,i.height=this.area.height;const s=i.getContext("2d");s.fillStyle=this.alarmSensitiveForegroundColor.toString(),s.font=this.font.getFontString();let r=this.x;0===this.horizAlignment?s.textAlign="start":1===this.horizAlignment?(r+=this.width/2,s.textAlign="center"):2===this.horizAlignment&&(r+=this.width,s.textAlign="end");let o=this.y;0===this.vertAlignment?s.textBaseline="top":1===this.vertAlignment?(o+=this.height/2,s.textBaseline="middle"):2===this.vertAlignment&&(o+=this.height,s.textBaseline="bottom");let a=this.text;if(this.pv&&void 0!==this.pv.value){const t=this.precisionFromPV?this.pv.precision:this.precision;a=this.pv.formatValue(this.formatType,t)}s.fillText(a,r-this.area.x,o-this.area.y),e.drawImage(i,this.area.x,this.area.y)}get font(){return this.properties.getValue(Wi).scale(this.scale)}get formatType(){return this.properties.getValue(Hi)}get horizAlignment(){return this.properties.getValue(Bi)}get precision(){return this.properties.getValue(Fi)}get precisionFromPV(){return this.properties.getValue(Gi)}get vertAlignment(){return this.properties.getValue(Yi)}}const Ui="alpha",$i="fill",ji="line_width",Xi="line_style",qi="start_angle",Zi="total_angle";class Ki extends te{constructor(t,e){super(t,e),this.properties.add(new W(Ui,255)),this.properties.add(new W(ji)),this.properties.add(new W(qi)),this.properties.add(new W(Zi)),this.properties.add(new B($i)),this.properties.add(new W(Xi))}draw(t){t.ctx.globalAlpha=this.alpha/255,this.drawShape(t),t.ctx.globalAlpha=1}drawShape(t){const e=this.x+this.width/2,i=this.y+this.height/2,s=this.width/2,r=this.height/2,o=-u(this.startAngle),a=-u(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,s,r,0,o,a,!0),t.ctx.closePath(),t.ctx.fill()),this.lineWidth&&0!==this.totalAngle){let n;const{scale:l}=this;0===this.lineStyle?n=[]:1===this.lineStyle?n=[6*l,2*l]:2===this.lineStyle?n=[2*l,2*l]:console.warn(`Unsupported arc line style ${this.lineStyle}`),t.strokeEllipse({cx:e,cy:i,rx:s,ry:r,startAngle:o,endAngle:a,lineWidth:this.lineWidth,anticlockwise:!0,color:this.alarmSensitiveForegroundColor,dash:n})}}get alpha(){return this.properties.getValue(Ui)}get lineWidth(){return this.scale*this.properties.getValue(ji)}get lineStyle(){return this.properties.getValue(Xi)}get startAngle(){return this.properties.getValue(qi)}get totalAngle(){return this.properties.getValue(Zi)}get fill(){return this.properties.getValue($i)}}const Ji="alpha",Qi="bg_gradient_color",ts="fg_gradient_color",es="fill_level",is="gradient",ss="horizontal_fill",rs="line_color",os="line_width",as="line_style";class ns extends te{constructor(t,e){super(t,e),this.properties.add(new W(Ji,255)),this.properties.add(new F(Qi)),this.properties.add(new F(ts)),this.properties.add(new B(is)),this.properties.add(new W(os)),this.properties.add(new H(es)),this.properties.add(new B(ss)),this.properties.add(new F(rs)),this.properties.add(new W(as))}draw(t){t.ctx.globalAlpha=this.alpha/255,this.drawBackground(t),this.fillLevel&&this.drawFill(t),t.ctx.globalAlpha=1}drawBackground(t){const e=this.x+this.width/2,i=this.y+this.height/2,s=this.width/2,r=this.height/2;if(!this.transparent){const o=this.alarmSensitiveBackgroundColor;if(this.gradient){const a=this.horizontalFill?this.x:this.x+this.width,n=this.horizontalFill?this.y+this.height:this.y,l=t.createLinearGradient(this.x,this.y,a,n);l.addColorStop(0,this.backgroundGradientStartColor.toString()),l.addColorStop(1,o.toString()),t.fillEllipse({cx:e,cy:i,rx:s,ry:r,gradient:l})}else t.fillEllipse({cx:e,cy:i,rx:s,ry:r,color:o})}this.lineWidth&&(0===this.lineStyle?t.strokeEllipse({cx:e,cy:i,rx:s,ry:r,color:this.lineColor,lineWidth:this.lineWidth}):1===this.lineStyle?t.strokeEllipse({cx:e,cy:i,rx:s,ry:r,color:this.lineColor,lineWidth:this.lineWidth,dash:[6,2]}):console.warn(`Unsupported ellipse line style ${this.lineStyle}`))}drawFill(t){const e=d(this,this.lineWidth);if(t.ctx.save(),this.horizontalFill){const i=e.width*(this.fillLevel/100);t.ctx.beginPath(),t.ctx.rect(e.x,e.y,i,e.height)}else{const i=e.height*(this.fillLevel/100),s=e.y+e.height-i;t.ctx.beginPath(),t.ctx.rect(e.x,s,e.width,e.height)}t.ctx.clip();const i=this.x+this.width/2,s=this.y+this.height/2,r=(this.width-this.lineWidth)/2,o=(this.height-this.lineWidth)/2,a=this.alarmSensitiveForegroundColor;if(this.gradient){const e=this.horizontalFill?this.x:this.x+this.width,n=this.horizontalFill?this.y+this.height:this.y,l=t.createLinearGradient(this.x,this.y,e,n);l.addColorStop(0,this.foregroundGradientStartColor.toString()),l.addColorStop(1,a.toString()),t.fillEllipse({cx:i,cy:s,rx:r,ry:o,gradient:l})}else t.fillEllipse({cx:i,cy:s,rx:r,ry:o,color:a});t.ctx.restore()}get alpha(){return this.properties.getValue(Ji)}get lineWidth(){return this.scale*this.properties.getValue(os)}get fillLevel(){return this.properties.getValue(es)}get horizontalFill(){return this.properties.getValue(ss)}get lineColor(){return this.properties.getValue(rs)}get lineStyle(){return this.properties.getValue(as)}get gradient(){return this.properties.getValue(is)}get backgroundGradientStartColor(){return this.properties.getValue(Qi)}get foregroundGradientStartColor(){return this.properties.getValue(ts)}}const ls="image_file",hs="no_animation",ds="transparency";class cs extends te{constructor(t,e){super(t,e),this.imageLoaded=!1,this.properties.add(new I(ls)),this.properties.add(new I(hs)),this.properties.add(new B(ds,!0))}init(){this.imageElement=new Image(this.width,this.height),this.imageElement.onload=()=>{this.snapshotImage(this.imageElement),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.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.imageLoaded=!1,this.imageElement&&this.imageFile&&(this.currentImageFile=this.imageFile,this.imageElement.src=`${this.display.baseUrl}${this.imageFile}`)}snapshotImage(t){const 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(ds)}get imageFile(){return this.properties.getValue(ls)}get noAnimation(){return this.properties.getValue(hs)}}const ps="font",us="horizontal_alignment",gs="vertical_alignment",fs="wrap_words";class ms extends te{constructor(t,e){super(t,e),this.properties.add(new G(ps)),this.properties.add(new W(us)),this.properties.add(new W(gs)),this.properties.add(new B(fs))}draw(t){const e=t.ctx;this.transparent||t.fillRect({x:this.x,y:this.y,width:this.width,height:this.height,color:this.backgroundColor});const 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 s=0;for(const t of i){const i=e.measureText(t).width;s=Math.max(s,i)}let r=this.x;1===this.horizAlignment?r=this.x+(this.width-s)/2:2===this.horizAlignment&&(r=this.x+(this.width-s));const o=i.length*this.font.height+(i.length-1)*this.font.height*.2;let a=this.y;1===this.vertAlignment?a+=(this.height-o)/2:2===this.vertAlignment&&(a+=this.height-o);for(const t of i)e.fillText(t,r,a),a+=1.2*this.font.height}wrapText(t,e,i){let s=[];for(const r of e.split("\n"))s=s.concat(this.wrapLine(t,r,i));return s}wrapLine(t,e,i){const s=[];let r,o,a,n=0;for(;e.length;){for(o=e.length;t.measureText(e.substr(0,o),this.font).width>i;o--);if(r=e.substr(0,o),o!==e.length)for(a=0;-1!==r.indexOf(" ",a);a=r.indexOf(" ",a)+1);s.push(r.substr(0,a||r.length)),n=Math.max(n,t.measureText(s[s.length-1],this.font).width),e=e.substr(s[s.length-1].length,e.length)}return s}get font(){return this.properties.getValue(ps).scale(this.scale)}get horizAlignment(){return this.properties.getValue(us)}get vertAlignment(){return this.properties.getValue(gs)}get wrapWords(){return this.properties.getValue(fs)}}const ys="alpha",xs="fill_level",vs="horizontal_fill",ws="line_color",bs="line_style",_s="line_width",Ss="points";class Ts extends te{constructor(t,e){super(t,e),this.properties.add(new W(ys,255)),this.properties.add(new W(_s)),this.properties.add(new H(xs)),this.properties.add(new B(vs)),this.properties.add(new F(ws)),this.properties.add(new W(bs)),this.properties.add(new Y(Ss,[]))}init(){const t=this.properties.getProperty("x");t&&t.addListener(((t,e)=>{const i=p(this.points,t-e,0);this.properties.setValue(Ss,i),this.requestRepaint()}));const e=this.properties.getProperty("y");e&&e.addListener(((t,e)=>{const i=p(this.points,0,t-e);this.properties.setValue(Ss,i),this.requestRepaint()}))}draw(t){t.ctx.globalAlpha=this.alpha/255;const e=w.fromPoints(this.points).closePath();if(!this.transparent){const i=this.alarmSensitiveBackgroundColor;t.fillPath({path:e,color:i})}this.lineWidth&&(0===this.lineStyle?t.strokePath({path:e,lineWidth:this.lineWidth,color:this.lineColor}):2===this.lineStyle?t.strokePath({path:e,lineWidth:this.lineWidth,color:this.lineColor,dash:[6,2]}):console.warn(`Unsupported polygon line style ${this.lineStyle}`)),this.fillLevel&&this.drawFill(t,e),t.ctx.globalAlpha=1}drawFill(t,e){let i=this.y,s=this.width,r=this.height;this.horizontalFill?s*=this.fillLevel/100:(r*=this.fillLevel/100,i+=r),t.ctx.save();let o=this.x-this.lineWidth/2,a=i-this.lineWidth/2,n=s+this.lineWidth,l=r+this.lineWidth;t.ctx.beginPath(),t.ctx.rect(o,a,n,l),t.ctx.clip();const h=this.alarmSensitiveForegroundColor;t.fillPath({path:e,color:h}),t.ctx.restore()}get alpha(){return this.properties.getValue(ys)}get lineWidth(){return this.scale*this.properties.getValue(_s)}get fillLevel(){return this.properties.getValue(xs)}get horizontalFill(){return this.properties.getValue(vs)}get lineColor(){return this.properties.getValue(ws)}get lineStyle(){return this.properties.getValue(bs)}get points(){return y(this.properties.getValue(Ss),this.scale)}}const Cs="alpha",Ls="arrows",As="arrow_length",ks="fill_arrow",Ps="fill_level",Rs="horizontal_fill",Es="line_width",Ms="points";class Vs extends te{constructor(t,e){super(t,e),this.properties.add(new W(Cs,255)),this.properties.add(new W(Es)),this.properties.add(new H(Ps)),this.properties.add(new B(Rs)),this.properties.add(new Y(Ms,[])),this.properties.add(new W(As)),this.properties.add(new B(ks)),this.properties.add(new W(Ls))}draw(t){const 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,s=this.height;this.horizontalFill?i*=this.fillLevel/100:(s*=this.fillLevel/100,e+=s),t.save();let r=this.x-this.lineWidth/2,o=e-this.lineWidth/2,a=i+this.lineWidth,n=s+this.lineWidth;t.beginPath(),t.rect(r,o,a,n),t.clip(),this.drawShape(t,this.foregroundColor),t.restore()}drawShape(t,e){t.strokeStyle=e.toString(),t.lineWidth=this.lineWidth,t.beginPath();for(let e=0;e<this.points.length;e++)0===e?t.moveTo(this.points[e].x,this.points[e].y):t.lineTo(this.points[e].x,this.points[e].y);if(t.stroke(),this.points.length>=2){const i=this.points[0],s=this.points[this.points.length-1];if(2===this.arrows||3===this.arrows){const i=this.calculateArrowPoints(this.points[this.points.length-2],s);if(i[2]=s,this.fillArrow){t.fillStyle=e.toString(),t.beginPath();for(let e=0;e<i.length;e++)0===e?t.moveTo(i[e].x,i[e].y):t.lineTo(i[e].x,i[e].y);t.fill()}else t.strokeStyle=e.toString(),t.lineWidth=this.lineWidth,t.beginPath(),t.moveTo(s.x,s.y),t.lineTo(i[0].x,i[0].y),t.moveTo(s.x,s.y),t.lineTo(i[1].x,i[1].y),t.stroke()}if(1===this.arrows||3===this.arrows){const s=this.calculateArrowPoints(this.points[1],i);if(s[2]=i,this.fillArrow){t.fillStyle=e.toString(),t.beginPath();for(let e=0;e<s.length;e++)0===e?t.moveTo(s[e].x,s[e].y):t.lineTo(s[e].x,s[e].y);t.fill()}else t.strokeStyle=e.toString(),t.lineWidth=this.lineWidth,t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(s[0].x,s[0].y),t.moveTo(i.x,i.y),t.lineTo(s[1].x,s[1].y),t.stroke()}}}calculateArrowPoints(t,e){const i=f(e,t),s=Math.PI/10,r=new m(this.arrowLength,i.theta-s),o=new m(this.arrowLength,i.theta+s),a=new m(Math.floor(this.arrowLength*Math.cos(s)),i.theta);return[c(r.toPoint(),e.x,e.y),c(o.toPoint(),e.x,e.y),c(a.toPoint(),e.x,e.y)]}get alpha(){return this.properties.getValue(Cs)}get lineWidth(){return this.scale*this.properties.getValue(Es)}get fillLevel(){return this.properties.getValue(Ps)}get horizontalFill(){return this.properties.getValue(Rs)}get points(){return y(this.properties.getValue(Ms),this.scale)}get arrows(){return this.properties.getValue(Ls)}get fillArrow(){return this.properties.getValue(ks)}get arrowLength(){return this.properties.getValue(As)}}const Os="alpha",Ns="bg_gradient_color",Ds="fg_gradient_color",Is="fill_level",Ws="gradient",Hs="horizontal_fill",Bs="line_color",Fs="line_width",Gs="line_style";class Ys extends te{constructor(t,e){super(t,e),this.fillRoundRectangleBackgroundBorder=!1,this.properties.add(new W(Os,255)),this.properties.add(new F(Ns)),this.properties.add(new F(Ds)),this.properties.add(new B(Ws)),this.properties.add(new W(Fs)),this.properties.add(new H(Is)),this.properties.add(new B(Hs)),this.properties.add(new F(Bs)),this.properties.add(new W(Gs))}draw(t){t.ctx.globalAlpha=this.alpha/255,this.drawBackground(t),this.fillLevel&&this.drawFill(t),t.ctx.globalAlpha=1}drawBackground(t){if(!this.transparent){const e=this.alarmSensitiveBackgroundColor;if(this.gradient){const i=this.horizontalFill?this.x:this.x+this.width,s=this.horizontalFill?this.y+this.height:this.y,r=t.createLinearGradient(this.x,this.y,i,s);r.addColorStop(0,this.backgroundGradientStartColor.toString()),r.addColorStop(1,e.toString()),t.fillRect(Object.assign(Object.assign({},this.area),{gradient:r}))}else t.fillRect(Object.assign(Object.assign({},this.area),{color:e}))}this.lineWidth&&(0===this.lineStyle?t.strokeRect(Object.assign(Object.assign({},this.area),{color:this.lineColor,lineWidth:this.lineWidth,crispen:!0})):1===this.lineStyle?t.strokeRect(Object.assign(Object.assign({},this.area),{color:this.lineColor,lineWidth:this.lineWidth,crispen:!0,dash:[6,2]})):console.warn(`Unsupported rectangle line style ${this.lineStyle}`))}drawFill(t){const e=d(this,this.lineWidth);if(t.ctx.save(),this.horizontalFill){const i=e.width*(this.fillLevel/100);t.ctx.beginPath(),t.ctx.rect(e.x,e.y,i,e.height)}else{const i=e.height*(this.fillLevel/100),s=e.y+e.height-i;t.ctx.beginPath(),t.ctx.rect(e.x,s,e.width,e.height)}t.ctx.clip();const i=this.alarmSensitiveForegroundColor;if(this.gradient){const s=this.horizontalFill?e.x:e.x+e.width,r=this.horizontalFill?e.y+e.height:e.y,o=t.createLinearGradient(e.x,e.y,s,r);o.addColorStop(0,this.foregroundGradientStartColor.toString()),o.addColorStop(1,i.toString()),t.fillRect(Object.assign(Object.assign({},e),{gradient:o}))}else t.fillRect(Object.assign(Object.assign({},e),{color:i}));t.ctx.restore()}get alpha(){return this.properties.getValue(Os)}get lineWidth(){return this.scale*this.properties.getValue(Fs)}get fillLevel(){return this.properties.getValue(Is)}get horizontalFill(){return this.properties.getValue(Hs)}get lineColor(){return this.properties.getValue(Bs)}get lineStyle(){return this.properties.getValue(Gs)}get gradient(){return this.properties.getValue(Ws)}get backgroundGradientStartColor(){return this.properties.getValue(Ns)}get foregroundGradientStartColor(){return this.properties.getValue(Ds)}}const zs="alpha",Us="bg_gradient_color",$s="corner_width",js="corner_height",Xs="fg_gradient_color",qs="fill_level",Zs="gradient",Ks="horizontal_fill",Js="line_color",Qs="line_width",tr="line_style";class er extends te{constructor(t,e){super(t,e),this.fillRoundRectangleBackgroundBorder=!1,this.properties.add(new W(zs,255)),this.properties.add(new F(Us)),this.properties.add(new F(Xs)),this.properties.add(new B(Zs)),this.properties.add(new W(Qs)),this.properties.add(new H(qs)),this.properties.add(new B(Ks)),this.properties.add(new F(Js)),this.properties.add(new W($s)),this.properties.add(new W(js)),this.properties.add(new W(tr))}draw(t){t.ctx.globalAlpha=this.alpha/255,this.drawBackground(t),this.fillLevel&&this.drawFill(t),t.ctx.globalAlpha=1}drawBackground(t){if(!this.transparent){const e=this.alarmSensitiveBackgroundColor;if(this.gradient){const i=this.horizontalFill?this.x:this.x+this.width,s=this.horizontalFill?this.y+this.height:this.y,r=t.createLinearGradient(this.x,this.y,i,s);r.addColorStop(0,this.backgroundGradientStartColor.toString()),r.addColorStop(1,e.toString()),t.fillRect(Object.assign(Object.assign({},this.area),{rx:this.cornerWidth/2,ry:this.cornerHeight/2,gradient:r}))}else t.fillRect(Object.assign(Object.assign({},this.area),{rx:this.cornerWidth/2,ry:this.cornerHeight/2,color:e}))}this.lineWidth&&(0===this.lineStyle?t.strokeRect(Object.assign(Object.assign({},this.area),{rx:this.cornerWidth/2,ry:this.cornerHeight/2,color:this.lineColor,lineWidth:this.lineWidth,crispen:!0})):1===this.lineStyle?t.strokeRect(Object.assign(Object.assign({},this.area),{rx:this.cornerWidth/2,ry:this.cornerHeight/2,color:this.lineColor,lineWidth:this.lineWidth,crispen:!0,dash:[6,2]})):console.warn(`Unsupported RoundedRectangle line style ${this.lineStyle}`))}drawFill(t){const e=this.cornerWidth/2,i=this.cornerHeight/2,s=d(this,this.lineWidth);if(t.ctx.save(),this.horizontalFill){const e=s.width*(this.fillLevel/100);t.ctx.beginPath(),t.ctx.rect(s.x,s.y,e,s.height)}else{const e=s.height*(this.fillLevel/100),i=s.y+s.height-e;t.ctx.beginPath(),t.ctx.rect(s.x,i,s.width,s.height)}t.ctx.clip();const r=this.alarmSensitiveForegroundColor;if(this.gradient){const o=this.horizontalFill?s.x:s.x+s.width,a=this.horizontalFill?s.y+s.height:s.y,n=t.createLinearGradient(s.x,s.y,o,a);n.addColorStop(0,this.foregroundGradientStartColor.toString()),n.addColorStop(1,r.toString()),t.fillRect(Object.assign(Object.assign({},s),{rx:e,ry:i,gradient:n}))}else t.fillRect(Object.assign(Object.assign({},s),{rx:e,ry:i,color:r}));t.ctx.restore()}get alpha(){return this.properties.getValue(zs)}get lineWidth(){return this.scale*this.properties.getValue(Qs)}get fillLevel(){return this.properties.getValue(qs)}get horizontalFill(){return this.properties.getValue(Ks)}get lineColor(){return this.properties.getValue(Js)}get lineStyle(){return this.properties.getValue(tr)}get gradient(){return this.properties.getValue(Zs)}get cornerWidth(){return this.scale*this.properties.getValue($s)}get cornerHeight(){return this.scale*this.properties.getValue(js)}get backgroundGradientStartColor(){return this.properties.getValue(Us)}get foregroundGradientStartColor(){return this.properties.getValue(Xs)}}const ir="bitReverse",sr="effect_3d",rr="horizontal",or="led_border",ar="led_border_color",nr="led_packed",lr="numBits",hr="off_color",dr="on_color",cr="startBit",pr="square_led";class ur extends te{constructor(t,i){super(t,i),this.properties.add(new B(ir)),this.properties.add(new B(sr)),this.properties.add(new B(rr)),this.properties.add(new W(lr)),this.properties.add(new F(hr)),this.properties.add(new F(dr)),this.properties.add(new W(cr)),this.properties.add(new B(pr)),this.properties.add(new W(or,3)),this.properties.add(new F(ar,e.DARK_GRAY)),this.properties.add(new B(nr,!1))}getLedColor(t){var e,i;let s=!1;if(void 0!==(null===(e=this.pv)||void 0===e?void 0:e.value))for(let e=this.startBit;e<this.startBit+this.numBits;e++){let r=0;if(r=this.bitReverse?e-this.startBit:this.numBits-1-(e-this.startBit),r===t){s=((null===(i=this.pv)||void 0===i?void 0:i.value)>>e&1)>0;break}}return s?this.onColor:this.offColor}draw(t){if(this.numBits<1)return;let e=this.bounds;this.borderAlarmSensitive&&(e=d(e,2*this.scale)),this.horizontal?this.drawHorizontal(t,e):this.drawVertical(t,e)}drawHorizontal(t,e){let i,s;this.ledPacked?(i=Math.floor((e.width-this.ledBorder)/this.numBits+this.ledBorder),s=i-this.ledBorder):(i=Math.floor(e.width/this.numBits),s=i);let r=0;r=i>e.height||this.squareLed?e.height:i;for(let o=0;o<this.numBits;o++)if(this.squareLed){const a={x:e.x+o*s,y:e.y,width:i,height:r};this.effect3d?this.drawSquare3d(t,a,o):this.drawSquare2d(t,a,o)}else{const a=Math.min(i,r),n={x:e.x+o*s,y:e.y,width:a,height:a};this.effect3d?this.drawCircle3d(t,n,o):this.drawCircle2d(t,n,o)}}drawVertical(t,e){let i,s;this.ledPacked?(i=Math.floor((e.height-this.ledBorder)/this.numBits+this.ledBorder),s=i-this.ledBorder):(i=Math.floor(e.height/this.numBits),s=i);let r=0;r=i>e.width||this.squareLed?e.width:i;for(let o=0;o<this.numBits;o++)if(this.squareLed){const a={x:e.x,y:e.y+o*s,width:r,height:i};this.effect3d?this.drawSquare3d(t,a,o):this.drawSquare2d(t,a,o)}else{const a=Math.min(r,i),n={x:e.x,y:e.y+o*s,width:a,height:a};this.effect3d?this.drawCircle3d(t,n,o):this.drawCircle2d(t,n,o)}}drawCircle2d(t,e,i){const s=e.x+e.width/2,r=e.y+e.height/2;let o=e.width/2,a=e.height/2;this.ledBorder>0&&(o-=this.ledBorder/2,a-=this.ledBorder/2),t.fillEllipse({cx:s,cy:r,rx:o,ry:a,color:this.getLedColor(i)}),t.strokeEllipse({cx:s,cy:r,rx:o,ry:a,color:this.ledBorderColor,lineWidth:this.ledBorder})}drawCircle3d(t,i,s){const r=i.x+i.width/2,o=i.y+i.height/2;let a=i.width/2,n=i.height/2;t.fillEllipse({cx:r,cy:o,rx:a,ry:n,color:e.WHITE});let l=t.createLinearGradient(i.x,i.y,i.x+i.width,i.y+i.height);l.addColorStop(0,this.ledBorderColor.toString()),l.addColorStop(1,this.ledBorderColor.withAlpha(0).toString()),t.fillEllipse({cx:r,cy:o,rx:a,ry:n,gradient:l});a=(i.width-2*this.ledBorder)/2,n=(i.height-2*this.ledBorder)/2,t.fillEllipse({cx:r,cy:o,rx:a,ry:n,color:this.getLedColor(s)}),l=t.createLinearGradient(i.x,i.y,i.x+i.width,i.y+i.height),l.addColorStop(0,e.WHITE.toString()),l.addColorStop(1,this.ledBorderColor.withAlpha(0).toString()),t.fillEllipse({cx:r,cy:o,rx:a,ry:n,gradient:l})}drawSquare2d(t,e,i){const s=l(e.x,e.y,e.width,e.height,this.ledBorder);t.fillRect(Object.assign(Object.assign({},s),{color:this.getLedColor(i)})),t.strokeRect(Object.assign(Object.assign({},s),{color:this.ledBorderColor,lineWidth:this.ledBorder}))}drawSquare3d(t,e,i){t.fillRect(Object.assign(Object.assign({},e),{color:this.ledBorderColor}));let s=t.createLinearGradient(e.x,e.y,e.x+e.width,e.y);s.addColorStop(0,"rgba(0,0,0,0.078)"),s.addColorStop(1,"rgba(0,0,0,0.39)"),t.fillPath({gradient:s,path:new w(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)}),s=t.createLinearGradient(e.x,e.y,e.x,e.y+e.height),s.addColorStop(0,"rgba(0,0,0,0.078)"),s.addColorStop(1,"rgba(0,0,0,0.39)"),t.fillPath({gradient:s,path:new w(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)}),s=t.createLinearGradient(e.x,e.y,e.x+e.width,e.y),s.addColorStop(0,"rgba(255,255,255,0.078)"),s.addColorStop(1,"rgba(255,255,255,0.39)"),t.fillPath({gradient:s,path:new w(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)}),s=t.createLinearGradient(e.x,e.y,e.x,e.y+e.height),s.addColorStop(0,"rgba(255,255,255,0.078)"),s.addColorStop(1,"rgba(255,255,255,0.39)"),t.fillPath({gradient:s,path:new w(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)});const r=e.x+this.ledBorder,o=e.y+this.ledBorder,a=e.width-2*this.ledBorder,n=e.height-2*this.ledBorder,l=this.getLedColor(i);t.fillRect({x:r,y:o,width:a,height:n,color:l}),s=t.createLinearGradient(e.x,e.y,e.x+e.width,e.y+e.height),s.addColorStop(0,"rgba(255,255,255,0.784)"),s.addColorStop(1,l.withAlpha(0).toString()),t.fillRect({x:r,y:o,width:a,height:n,gradient:s})}get bitReverse(){return this.properties.getValue(ir)}get horizontal(){return this.properties.getValue(rr)}get numBits(){return this.properties.getValue(lr)}get startBit(){return this.properties.getValue(cr)}get ledPacked(){return this.properties.getValue(nr)}get ledBorder(){return this.scale*this.properties.getValue(or)}get ledBorderColor(){return this.properties.getValue(ar)}get offColor(){return this.properties.getValue(hr)}get onColor(){return this.properties.getValue(dr)}get effect3d(){return this.properties.getValue(sr)}get squareLed(){return this.properties.getValue(pr)}}class gr{constructor(t,i,s){this.rampWidth=t,this.startAngle=i,this.endAngle=s,this.lolo=10,this.loloColor=e.RED,this.showLoLo=!0,this.lo=25,this.loColor=e.ORANGE,this.showLo=!0,this.hi=75,this.hiColor=e.ORANGE,this.showHi=!0,this.hihi=90,this.hihiColor=e.RED,this.showHiHi=!0,this.minimum=0,this.maximum=100,this.gradient=!0,this.logScale=!1,this.effect3d=!0,this.labelsOutside=!0,this.range={min:this.minimum,max:this.maximum},this.lengthInDegrees=0,this.radius=0}draw(t,e,i){if(this.labelsOutside){const t=9;this.radius=e.width/2-t}else this.radius=e.width/2-1;this.range=this.getRenderedRange(),this.endAngle-this.startAngle>0?this.lengthInDegrees=360-(this.endAngle-this.startAngle):this.lengthInDegrees=this.startAngle-this.endAngle,this.drawRamp(t,i)}drawRamp(t,i){const s=i.x+i.width/2,r=i.y+i.height/2,o=i.width/2,a=i.height/2;let n,l=360-this.endAngle;if(n=this.endAngle-this.startAngle>0?this.startAngle-90:this.startAngle+90,this.showLoLo){let e=n,i=360-this.getValuePosition(this.lolo,!0);t.strokeEllipse({cx:s,cy:r,rx:o-this.rampWidth/2,ry:a-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:u(e),endAngle:u(i),color:this.loloColor})}if(this.showLo){let e;e=this.showLoLo?this.lolo:this.minimum;const n=360-this.getValuePosition(e,!0),l=360-this.getValuePosition(this.lo,!0);if(this.effect3d&&this.gradient&&this.showLoLo){const h=u(this.getValuePosition(e,!0)-2),d=g(i.width/2,h,i),c=u(this.getValuePosition(this.lo,!0)+2),p=g(i.width/2,c,i),f=t.createLinearGradient(d.x,d.y,p.x,p.y);f.addColorStop(0,this.loloColor.toString()),f.addColorStop(1,this.loColor.toString()),t.strokeEllipse({cx:s,cy:r,rx:o-this.rampWidth/2,ry:a-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:u(n-1),endAngle:u(l+1),gradient:f})}else t.strokeEllipse({cx:s,cy:r,rx:o-this.rampWidth/2,ry:a-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:u(n),endAngle:u(l),color:this.loColor})}let h=this.minimum;this.showLo?h=this.lo:this.showLoLo&&(h=this.lolo);let d=this.maximum;this.showHi?d=this.hi:this.showHiHi&&(d=this.hihi);const c=(h+d)/2;let p=360-this.getValuePosition(h,!0),f=360-this.getValuePosition(c,!0);if(this.effect3d&&this.gradient&&(this.showLoLo||this.showLo)){const n=u(this.getValuePosition(h,!0)-2),l=g(i.width/2,n,i),d=u(this.getValuePosition(c,!0)+2),m=g(i.width/2,d,i),y=t.createLinearGradient(l.x,l.y,m.x,m.y);y.addColorStop(0,(this.showLo?this.loColor:this.loloColor).toString()),y.addColorStop(1,e.GREEN.toString()),t.strokeEllipse({cx:s,cy:r,rx:o-this.rampWidth/2,ry:a-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:u(p-1),endAngle:u(f+1),gradient:y})}else t.strokeEllipse({cx:s,cy:r,rx:o-this.rampWidth/2,ry:a-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:u(p),endAngle:u(f),color:e.GREEN});if(p=360-this.getValuePosition(c,!0),f=360-this.getValuePosition(d,!0),this.effect3d&&this.gradient&&(this.showHi||this.showHiHi)){const n=u(this.getValuePosition(c,!0)-2),h=g(i.width/2,n,i),m=u(this.getValuePosition(d,!0)+2),y=g(i.width/2,m,i),x=t.createLinearGradient(h.x,h.y,y.x,y.y);x.addColorStop(0,e.GREEN.toString()),x.addColorStop(1,(this.showHi?this.hiColor:this.hihiColor).toString());const v=f!==l?1:0;t.strokeEllipse({cx:s,cy:r,rx:o-this.rampWidth/2,ry:a-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:u(p-1),endAngle:u(f+v),gradient:x})}else t.strokeEllipse({cx:s,cy:r,rx:o-this.rampWidth/2,ry:a-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:u(p),endAngle:u(f),color:e.GREEN});if(this.showHi){let e;e=this.showHiHi?this.hihi:this.maximum;const n=360-this.getValuePosition(this.hi,!0),h=360-this.getValuePosition(e,!0);if(this.effect3d&&this.gradient&&this.showHiHi){const d=u(this.getValuePosition(this.hi,!0)-2),c=g(i.width/2,d,i),p=u(this.getValuePosition(e,!0)+2),f=g(i.width/2,p,i),m=t.createLinearGradient(c.x,c.y,f.x,f.y);m.addColorStop(0,this.hiColor.toString()),m.addColorStop(1,this.hihiColor.toString());const y=h!==l?1:0;t.strokeEllipse({cx:s,cy:r,rx:o-this.rampWidth/2,ry:a-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:u(n-1),endAngle:u(h+y),gradient:m})}else t.strokeEllipse({cx:s,cy:r,rx:o-this.rampWidth/2,ry:a-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:u(n),endAngle:u(h),color:this.hiColor})}if(this.showHiHi){p=360-this.getValuePosition(this.hihi,!0),f=l;const e=this.gradient?1:0;t.strokeEllipse({cx:s,cy:r,rx:o-this.rampWidth/2,ry:a-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:u(p-e),endAngle:u(f),color:this.hihiColor})}}getRadius(){return this.radius}getValuePosition(t,e=!1){let i;return e&&(t=this.getValueInRange(t)),i=this.logScale?this.startAngle-(Math.log10(t)-Math.log10(this.range.min))/(Math.log10(this.range.max)-Math.log10(this.range.min))*this.lengthInDegrees: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(){const 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}}const fr=new e(100,100,100),mr="color_hi",yr="color_hihi",xr="color_lo",vr="color_lolo",wr="effect_3d",br="font",_r="value_label_format",Sr="level_hi",Tr="level_hihi",Cr="level_lo",Lr="level_lolo",Ar="limits_from_pv",kr="log_scale",Pr="minimum",Rr="maximum",Er="needle_color",Mr="ramp_gradient",Vr="show_ramp";class Or extends te{constructor(t,e){super(t,e),this.properties.add(new F(mr)),this.properties.add(new F(yr)),this.properties.add(new F(xr)),this.properties.add(new F(vr)),this.properties.add(new B(wr)),this.properties.add(new G(br)),this.properties.add(new H(Sr)),this.properties.add(new H(Tr)),this.properties.add(new H(Cr)),this.properties.add(new H(Lr)),this.properties.add(new B(kr)),this.properties.add(new B(Ar)),this.properties.add(new H(Rr)),this.properties.add(new H(Pr)),this.properties.add(new F(Er)),this.properties.add(new B(Mr)),this.properties.add(new B(Vr,!0)),this.properties.add(new I(_r))}draw(t){var e,i;let s;s=this.limitsFromPv&&this.pv&&!this.pv.disconnected?{min:null!==(e=this.pv.lowerDisplayLimit)&&void 0!==e?e:this.minimum,lolo:this.pv.lowerAlarmLimit,lo:this.pv.lowerWarningLimit,hi:this.pv.upperWarningLimit,hihi:this.pv.upperAlarmLimit,max:null!==(i=this.pv.upperDisplayLimit)&&void 0!==i?i:this.maximum}:{min:this.minimum,lolo:this.levelLoLo,lo:this.levelLo,hi:this.levelHi,hihi:this.levelHiHi,max:this.maximum},this.logScale&&(s.min=Math.max(.1,s.min),s.max<=s.min&&(s.max=s.min+100));const r=Math.min(this.width,this.height),o=r;this.drawBackground(t,r,o),this.showRamp&&this.drawRamp(t,r,o,s),this.drawLabel(t,r,o),this.drawNeedle(t,r,o,s),this.drawNeedleCenter(t,r,o)}drawBackground(t,i,s){if(t.fillEllipse({cx:this.x+i/2,cy:this.y+s/2,rx:i/2,ry:s/2,color:e.GRAY}),this.effect3d){const r=t.createLinearGradient(this.x,this.y,this.x+this.width,this.y+this.height);r.addColorStop(0,fr.toString()),r.addColorStop(1,e.WHITE.toString()),t.fillEllipse({cx:this.x+i/2,cy:this.y+s/2,rx:i/2,ry:s/2,gradient:r})}const r=(this.effect3d?2:1)*this.scale;if(t.fillEllipse({cx:this.x+i/2,cy:this.y+s/2,rx:i/2-r,ry:s/2-r,color:this.backgroundColor}),this.effect3d){const r=i/2,o=.95,a=.5,n=.85,l=u(0),h=u(35);let d={x:Math.floor(this.x+i/2-r*n*Math.cos(l)),y:Math.floor(this.y+s/2-r*o),width:Math.floor(2*r*n*Math.cos(l)),height:Math.floor(r*o+r*a)},c=t.createLinearGradient(d.x,d.y,d.x,d.y+d.height);c.addColorStop(0,e.WHITE.withAlpha(90/255).toString()),c.addColorStop(1,e.WHITE.withAlpha(0).toString()),t.fillEllipse({cx:d.x+d.width/2,cy:d.y+d.height/2,rx:d.width/2,ry:d.height/2,gradient:c}),d={x:Math.floor(this.x+i/2-r*n*Math.sin(h)),y:Math.floor(Math.ceil(this.y+s/2+r*a)),width:Math.floor(2*r*n*Math.sin(h)),height:Math.floor(Math.ceil(r*o-r*a))},c=t.createLinearGradient(d.x,d.y,d.x,d.y+d.height),c.addColorStop(0,e.WHITE.withAlpha(0).toString()),c.addColorStop(1,e.WHITE.withAlpha(40/255).toString()),t.fillEllipse({cx:d.x+d.width/2,cy:d.y+d.height/2,rx:d.width/2,ry:d.height/2,gradient:c})}}drawRamp(t,e,i,s){const r=d({x:this.x,y:this.y,width:e,height:i},e/4,i/4),o=Object.assign({},r);o.width=Math.min(r.width,r.height),o.height=r.width;const a=new gr(10*this.scale,225,315);a.lolo=s.lolo,a.loloColor=this.colorLoLo,a.lo=s.lo,a.loColor=this.colorLo,a.hi=s.hi,a.hiColor=this.colorHi,a.hihi=s.hihi,a.hihiColor=this.colorHiHi,a.minimum=s.min,a.maximum=s.max,a.effect3d=this.effect3d,a.gradient=this.rampGradient,a.logScale=this.logScale,a.draw(t,r,o)}drawLabel(t,e,i){var s;const r=M.ARIAL_12_BOLD.scale(this.scale);if(void 0!==(null===(s=this.pv)||void 0===s?void 0:s.value)){const s=this.formatLabelValue(this.pv.value),o=t.measureText(s,r);t.fillText({x:this.x+e/2-o.width/2,y:this.y+7*i/8-o.height/2,color:this.foregroundColor,align:"left",baseline:"top",font:r,text:s})}}drawNeedle(t,e,i,s){var r;const o=this.x+e/2,a=this.y+i/2;let n;if(void 0!==(null===(r=this.pv)||void 0===r?void 0:r.value)){const t=this.getValueInRange(this.pv.value,s);n=360-this.getValuePosition(t,s),s.max>s.min?t>s.max?n+=10:t<s.min&&(n-=10):t>s.min?n-=10:t<s.max&&(n+=10)}else n=360-this.getValuePosition((s.min+s.max)/2,s);const l=u(n),{scale:d}=this,{needleDiameter:c,majorTickLength:p,gapBetweenNeedleScale:g}=this,f=h(o,a-c/2+3*d,o,a,l),m=h(o+e/2-p-g,a,o,a,l),y=h(o,a+c/2-3*d,o,a,l);t.fillPath({color:this.needleColor,path:new w(f.x,f.y).lineTo(m.x,m.y).lineTo(y.x,y.y).closePath()})}drawNeedleCenter(t,i,s){const{needleDiameter:r}=this,o=this.x+i/2,a=this.y+s/2,n=r/2,l=r/2;if(this.effect3d){const i=t.createLinearGradient(o-n,a-l,o+n,a+l);i.addColorStop(0,e.WHITE.toString()),i.addColorStop(1,fr.toString()),t.fillEllipse({cx:o,cy:a,rx:n,ry:l,gradient:i})}else t.fillEllipse({cx:o,cy:a,rx:n,ry:l,color:e.GRAY})}getValueInRange(t,e){return e.min<=t&&t<=e.max?t:t>e.max?e.max:e.min}getValuePosition(t,e){let i;return i=this.logScale?225-(Math.log10(t)-Math.log10(e.min))/(Math.log10(e.max)-Math.log10(e.min))*270:225-(t-e.min)/(e.max-e.min)*270,i<0&&(i+=360),i}formatLabelValue(t){return this.valueLabelFormat?(console.log(`Custom format ${this.valueLabelFormat} not supported.`),String(t)):String(Number(t.toFixed(3)))}get needleDiameter(){return 16*this.scale}get majorTickLength(){return 8*this.scale}get minorTickLength(){return 5*this.scale}get gapBetweenNeedleScale(){return-1*this.scale}get colorLo(){return this.properties.getValue(xr)}get colorLoLo(){return this.properties.getValue(vr)}get colorHi(){return this.properties.getValue(mr)}get colorHiHi(){return this.properties.getValue(yr)}get effect3d(){return this.properties.getValue(wr)}get font(){return this.properties.getValue(br).scale(this.scale)}get levelLo(){return this.properties.getValue(Cr)}get levelLoLo(){return this.properties.getValue(Lr)}get levelHi(){return this.properties.getValue(Sr)}get levelHiHi(){return this.properties.getValue(Tr)}get limitsFromPv(){return this.properties.getValue(Ar)}get logScale(){return this.properties.getValue(kr)}get minimum(){return this.properties.getValue(Pr)}get maximum(){return this.properties.getValue(Rr)}get needleColor(){return this.properties.getValue(Er)}get rampGradient(){return this.properties.getValue(Mr)}get showRamp(){return this.properties.getValue(Vr)}get valueLabelFormat(){return this.properties.getValue(_r)}}const Nr="data_type",Dr="off_image",Ir="off_label",Wr="font",Hr="on_image",Br="on_label",Fr="show_boolean_label";class Gr extends te{constructor(t,e){super(t,e),this.onImageLoaded=!1,this.offImageLoaded=!1,this.properties.add(new W("bit")),this.properties.add(new W(Nr)),this.properties.add(new I(Dr)),this.properties.add(new I(Ir)),this.properties.add(new I(Hr)),this.properties.add(new I(Br)),this.properties.add(new G(Wr)),this.properties.add(new B(Fr))}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.display.baseUrl}${this.onImage}`),this.offImage&&(this.offImageElement.src=`${this.display.baseUrl}${this.offImage}`)}get booleanValue(){var t,e,i;return this.bit<0?Boolean(null===(t=this.pv)||void 0===t?void 0:t.toNumber()):void 0!==(null===(e=this.pv)||void 0===e?void 0:e.value)&&((null===(i=this.pv)||void 0===i?void 0:i.value)>>this.bit&1)>0}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("bit")}get dataType(){return this.properties.getValue(Nr)}get showBooleanLabel(){return this.properties.getValue(Fr)}get font(){return this.properties.getValue(Wr).scale(this.scale)}get offLabel(){return this.properties.getValue(Ir)}get offImage(){return this.properties.getValue(Dr)}get onLabel(){return this.properties.getValue(Br)}get onImage(){return this.properties.getValue(Hr)}}const Yr="data_type",zr="effect_3d",Ur="state_count",$r="square_led",jr="off_color",Xr="off_label",qr="font",Zr="on_color",Kr="on_label",Jr="bulb_border",Qr="bulb_border_color",to="state_color_fallback",eo="state_label_fallback",io="show_boolean_label";class so extends te{constructor(t,i){super(t,i),this.states=[],this.properties.add(new W("bit")),this.properties.add(new W(Yr)),this.properties.add(new B(zr)),this.properties.add(new B($r)),this.properties.add(new W(Ur,2)),this.properties.add(new F(jr)),this.properties.add(new I(Xr)),this.properties.add(new F(Zr)),this.properties.add(new I(Kr)),this.properties.add(new G(qr)),this.properties.add(new B(io)),this.properties.add(new F(to)),this.properties.add(new I(eo)),this.properties.add(new W(Jr,3)),this.properties.add(new F(Qr,e.DARK_GRAY))}parseNode(t){if(super.parseNode(t),this.stateCount>2)for(let e=0;e<this.stateCount;e++){const i=new F(`state_color_${e}`);i.value=t.getColor(`state_color_${e}`),this.properties.add(i);const s=new I(`state_label_${e}`);s.value=t.getString(`state_label_${e}`),this.properties.add(s);const r=new H(`state_value_${e}`);r.value=t.getFloat(`state_value_${e}`),this.properties.add(r),this.states.push({label:this.properties.getValue(s.name),color:this.properties.getValue(i.name),value:this.properties.getValue(r.name)})}}init(){this.areaRegion={id:`${this.wuid}-area`,click:()=>{const t={pvName:this.pvName};this.display.fireEvent("openpv",t)},cursor:"pointer"}}get booleanValue(){var t,e,i;return 0===this.dataType?this.bit<0?Boolean(null===(t=this.pv)||void 0===t?void 0:t.toNumber()):void 0!==(null===(e=this.pv)||void 0===e?void 0:e.value)&&((null===(i=this.pv)||void 0===i?void 0:i.value)>>this.bit&1)>0:(this.dataType,!1)}get bulbColor(){var t;if(this.stateCount<=2)return this.booleanValue?this.onColor:this.offColor;for(const e of this.states)if(e.value===(null===(t=this.pv)||void 0===t?void 0:t.value))return e.color;return this.stateColorFallback}get label(){var t;if(2===this.stateCount)return this.booleanValue?this.onLabel:this.offLabel;for(const e of this.states)if(e.value===(null===(t=this.pv)||void 0===t?void 0:t.value))return e.label;return this.stateLabelFallback}draw(t){const e=d(this.bounds,3*this.scale);this.squareLed?this.effect3d?this.drawSquare3d(t,e):this.drawSquare2d(t,e):this.effect3d?this.drawCircle3d(t,e):this.drawCircle2d(t,e),this.showBooleanLabel&&t.fillText({x:e.x+e.width/2,y:e.y+e.height/2,font:this.font,baseline:"middle",align:"center",color:this.foregroundColor,text:this.label})}drawCircle2d(t,e){const i=e.x+e.width/2,s=e.y+e.height/2;let r=e.width/2,o=e.height/2;if(this.bulbBorder>0&&(r-=this.bulbBorder/2,o-=this.bulbBorder/2),t.fillEllipse({cx:i,cy:s,rx:r,ry:o,color:this.bulbColor}),t.strokeEllipse({cx:i,cy:s,rx:r,ry:o,color:this.bulbBorderColor,lineWidth:this.bulbBorder}),this.pv&&this.pv.navigable&&!this.pv.disconnected){t.addHitRegion(this.areaRegion).addEllipse(i,s,r,o,0,0,2*Math.PI)}}drawCircle3d(t,i){const s=i.x+i.width/2,r=i.y+i.height/2;let o=i.width/2,a=i.height/2;t.fillEllipse({cx:s,cy:r,rx:o,ry:a,color:e.WHITE});let n=t.createLinearGradient(i.x,i.y,i.x+i.width,i.y+i.height);n.addColorStop(0,this.bulbBorderColor.toString()),n.addColorStop(1,this.bulbBorderColor.withAlpha(0).toString()),t.fillEllipse({cx:s,cy:r,rx:o,ry:a,gradient:n});if(o=(i.width-2*this.bulbBorder)/2,a=(i.height-2*this.bulbBorder)/2,t.fillEllipse({cx:s,cy:r,rx:o,ry:a,color:this.bulbColor}),n=t.createLinearGradient(i.x,i.y,i.x+i.width,i.y+i.height),n.addColorStop(0,e.WHITE.toString()),n.addColorStop(1,this.bulbBorderColor.withAlpha(0).toString()),t.fillEllipse({cx:s,cy:r,rx:o,ry:a,gradient:n}),this.pv&&this.pv.navigable&&!this.pv.disconnected){t.addHitRegion(this.areaRegion).addEllipse(s,r,o,a,0,0,2*Math.PI)}}drawSquare2d(t,e){const i=l(e.x,e.y,e.width,e.height,this.bulbBorder);if(t.fillRect(Object.assign(Object.assign({},i),{color:this.bulbColor})),t.strokeRect(Object.assign(Object.assign({},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){if(t.fillRect(Object.assign(Object.assign({},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 w(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 w(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 w(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 w(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)});const s=e.x+this.bulbBorder,r=e.y+this.bulbBorder,o=e.width-2*this.bulbBorder,a=e.height-2*this.bulbBorder;t.fillRect({x:s,y:r,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:s,y:r,width:o,height:a,gradient:i})}get bit(){return this.properties.getValue("bit")}get dataType(){return this.properties.getValue(Yr)}get squareLed(){return this.properties.getValue($r)}get showBooleanLabel(){return this.properties.getValue(io)}get font(){return this.properties.getValue(qr).scale(this.scale)}get effect3d(){return this.properties.getValue(zr)}get stateCount(){return this.properties.getValue(Ur)}get bulbBorder(){return this.scale*this.properties.getValue(Jr)}get bulbBorderColor(){return this.properties.getValue(Qr)}get offLabel(){return this.properties.getValue(Xr)}get offColor(){return this.properties.getValue(jr)}get onLabel(){return this.properties.getValue(Kr)}get onColor(){return this.properties.getValue(Zr)}get stateLabelFallback(){return this.properties.getValue(eo)}get stateColorFallback(){return this.properties.getValue(to)}}const ro=u(45),oo=(1-Math.sin(ro)/2)/(2*Math.cos(ro)),ao="color_hi",no="color_hihi",lo="color_lo",ho="color_lolo",co="font",po="level_hi",uo="level_hihi",go="level_lo",fo="level_lolo",mo="log_scale",yo="minimum",xo="maximum",vo="needle_color",wo="ramp_gradient",bo="scale_font",_o="show_hi",So="show_hihi",To="show_lo",Co="show_lolo",Lo="show_ramp";class Ao extends te{constructor(t,e){super(t,e),this.properties.add(new F(ao)),this.properties.add(new F(no)),this.properties.add(new F(lo)),this.properties.add(new F(ho)),this.properties.add(new G(co)),this.properties.add(new W(po)),this.properties.add(new W(uo)),this.properties.add(new W(go)),this.properties.add(new W(fo)),this.properties.add(new B(mo)),this.properties.add(new W(xo)),this.properties.add(new W(yo)),this.properties.add(new F(vo)),this.properties.add(new B(wo)),this.properties.add(new G(bo)),this.properties.add(new B(_o)),this.properties.add(new B(So)),this.properties.add(new B(To)),this.properties.add(new B(Co)),this.properties.add(new B(Lo,!0))}init(){this.areaRegion={id:`${this.wuid}-area`,click:()=>{const t={pvName:this.pvName};this.display.fireEvent("openpv",t)},cursor:"pointer"}}draw(t){if(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){const e=String(this.minimum),i=t.measureText(e,this.scaleFont),s=String(this.maximum),r=t.measureText(s,this.scaleFont),o=Math.max(i.width,r.width)/2;let a=this.height,n=this.width;a>oo*(n-2*o)&&(a=Math.floor(oo*(n-2*o)));const l=a/(1-Math.sin(ro)/2),h={x:Math.floor(this.x-l*(1-Math.cos(ro))+o),y:this.y,width:Math.floor(2*l),height:Math.floor(2*l)},{rampWidth:c}=this,p=d(h,h.width/4-c,h.height/4-c);p.width=Math.min(p.width,p.height),p.height=p.width;const u=new gr(c,135,45);u.lolo=this.levelLoLo,u.loloColor=this.colorLoLo,u.showLoLo=!0,u.lo=this.levelLo,u.loColor=this.colorLo,u.showLo=!0,u.hi=this.levelHi,u.hiColor=this.colorHi,u.showHi=!0,u.hihi=this.levelHiHi,u.hihiColor=this.colorHiHi,u.showHiHi=!0,u.minimum=this.minimum,u.maximum=this.maximum,u.gradient=this.rampGradient,u.logScale=this.logScale,u.draw(t,h,p),this.drawNeedle(t,h,u);const g=M.ARIAL_12_BOLD.scale(this.scale);if(this.pv&&void 0!==this.pv.value){const e=this.format(this.pv.value),i=t.measureText(e,g);t.fillText({x:h.x+h.width/2-i.width/2,y:h.y+h.height/2-h.height/4-(u.getRadius()-h.height/4)/2-i.height/2,align:"left",baseline:"top",font:g,text:e,color:this.foregroundColor})}}drawNeedle(t,e,i){const s=e.x+e.width/2,r=e.y+e.height/2;let o;if(this.pv&&void 0!==this.pv.value){const t=i.getValueInRange(this.pv.value);o=360-i.getValuePosition(t),this.maximum>this.minimum?t>this.maximum?o+=8:t<this.minimum&&(o-=8):t>this.minimum?o-=8:t<this.maximum&&(o+=8)}else o=360-i.getValuePosition(this.minimum+this.maximum/2);const a=u(o),{needleWidth:n,gapBetweenNeedleScale:l,scale:d}=this,c=h(s+e.width/4,r-n/2+3*d,s,r,a),p=h(s+i.getRadius()-l,r,s,r,a),g=h(s+e.width/4,r+n/2-3*d,s,r,a);t.fillPath({color:this.needleColor,path:new w(c.x,c.y).lineTo(p.x,p.y).lineTo(g.x,g.y).closePath()})}get needleWidth(){return 16*this.scale}get gapBetweenNeedleScale(){return-5*this.scale}get rampWidth(){return 12*this.scale}format(t){return String(Number(t.toFixed(3)))}get colorLo(){return this.properties.getValue(lo)}get colorLoLo(){return this.properties.getValue(ho)}get colorHi(){return this.properties.getValue(ao)}get colorHiHi(){return this.properties.getValue(no)}get font(){return this.properties.getValue(co).scale(this.scale)}get levelLo(){return this.properties.getValue(go)}get levelLoLo(){return this.properties.getValue(fo)}get levelHi(){return this.properties.getValue(po)}get levelHiHi(){return this.properties.getValue(uo)}get logScale(){return this.properties.getValue(mo)}get minimum(){return this.properties.getValue(yo)}get maximum(){return this.properties.getValue(xo)}get needleColor(){return this.properties.getValue(vo)}get rampGradient(){return this.properties.getValue(wo)}get scaleFont(){return this.properties.getValue(bo).scale(this.scale)}get showLo(){return this.properties.getValue(To)}get showLoLo(){return this.properties.getValue(Co)}get showHi(){return this.properties.getValue(_o)}get showHiHi(){return this.properties.getValue(So)}get showRamp(){return this.properties.getValue(Lo)}}class ko{constructor(t,e,i,s,r,o,a,n,l){this.scale=t,this.scaleFont=e,this.minimum=i,this.maximum=s,this.logScale=r,this.majorTickStepHint=o,this.foregroundColor=a,this.showMinorTicks=n,this.showScale=l,this.labels=[],this.labelValues=[],this.labelPositions=[],this.labelVisibilities=[],this.gridStepInPixel=0,this.horizontal=!1,this.x=0,this.y=0,this.length=0,this.margin=0}get scaleLength(){return this.length-2*this.margin}getValuePosition(t){let e=this.minimum,i=this.maximum;e<=0&&(e=.1),i<=e&&(i=e+100);let s=0;const r=this.length-2*this.margin;if(this.logScale)s=t<=0?this.margin:(Math.log10(t)-Math.log10(e))/(Math.log10(i)-Math.log10(e))*r+this.margin;else{const o=Math.max(Math.abs(e),Math.abs(i));i/=o,e/=o;s=(t/o-e)/(i-e)*r+this.margin}return this.horizontal?s+this.x:this.length-s+this.y}calculateMargin(t,e){if(this.showScale){const i=t.measureText(this.format(this.minimum),this.scaleFont),s=t.measureText(this.format(this.maximum),this.scaleFont);return e?Math.ceil(Math.max(i.width,s.width)/2):Math.ceil(Math.max(i.height,s.height)/2)}return 0}drawHorizontal(t,e,i,s){const{scale:r}=this;this.length=s,this.horizontal=!0,this.margin=this.calculateMargin(t,this.horizontal);const o=s-2*this.margin;o>0&&this.updateLabels(t,o);let a=0;for(let e=0;e<this.labels.length;e++){const i=t.measureText(this.labels[e],this.scaleFont);i.height>a&&(a=i.height)}const n=this.showScale?a+this.spaceBetweenMarkAndLabel+this.majorTickLength:0;if(i-=n,this.x=e,this.y=i,this.logScale)for(let e=0;e<this.labelPositions.length;e++){const i=this.x+this.labelPositions[e],s=this.y;let o=0;if(o=this.labelVisibilities[e]?this.majorTickLength:this.minorTickLength,this.labelVisibilities[e]||this.showMinorTicks){const e=Math.round(i)-.5*r;t.strokePath({path:new w(e,s).lineTo(e,s+o),color:this.foregroundColor,lineWidth:1*r,opacity:100/255})}this.labelVisibilities[e]&&t.fillText({x:i,y:this.y+this.spaceBetweenMarkAndLabel+this.majorTickLength,align:"center",baseline:"top",font:this.scaleFont,color:this.foregroundColor,text:this.labels[e]})}else for(let s=0;s<this.labels.length;s++){if(!this.labelVisibilities[s])continue;const o=e+this.labelPositions[s];t.fillText({x:o,y:i+this.majorTickLength+this.spaceBetweenMarkAndLabel,align:"center",baseline:"top",font:this.scaleFont,color:this.foregroundColor,text:this.labels[s]});const a=Math.round(o)-.5*r;t.strokePath({path:new w(a,i).lineTo(a,i+this.majorTickLength),color:this.foregroundColor,lineWidth:1*r,opacity:100/255}),this.showMinorTicks&&this.drawMinorXTicks(t,s,e,i)}return n}drawVertical(t,e,i,s,r){const{scale:o}=this;this.length=s,this.horizontal=!1,this.margin=this.calculateMargin(t,this.horizontal);const a=s-2*this.margin;a>0&&this.updateLabels(t,a);let n=0;for(let e=0;e<this.labels.length;e++){const i=t.measureText(this.labels[e],this.scaleFont);i.width>n&&(n=i.width)}const l=this.showScale?n+this.spaceBetweenMarkAndLabel+this.majorTickLength:0;if(r||(e-=l),this.x=e,this.y=i,this.logScale)for(let r=0;r<this.labelPositions.length;r++){let a;a=this.labelVisibilities[r]?this.majorTickLength:this.minorTickLength;const l=e+n+this.spaceBetweenMarkAndLabel-1*o+this.majorTickLength-a,h=Math.round(i+s-this.labelPositions[r])-.5*o;if((this.labelVisibilities[r]||this.showMinorTicks)&&t.strokePath({path:new w(l,h).lineTo(l+a,h),color:this.foregroundColor,lineWidth:1*o,opacity:100/255}),this.labelVisibilities[r]){const o=i+s-this.labelPositions[r];t.fillText({x:e,y:o,align:"left",baseline:"middle",font:this.scaleFont,color:this.foregroundColor,text:this.labels[r]})}}else for(let r=0;r<this.labels.length;r++){if(!this.labelVisibilities[r])continue;const a=i+s-this.labelPositions[r];t.fillText({x:e,y:a,align:"left",baseline:"middle",font:this.scaleFont,color:this.foregroundColor,text:this.labels[r]});const l=e+n+this.spaceBetweenMarkAndLabel-1*o,h=Math.round(a)-.5*o;t.strokePath({path:new w(l,h).lineTo(l+this.majorTickLength,h),color:this.foregroundColor,lineWidth:1*o,opacity:100/255}),this.showMinorTicks&&this.drawMinorYTicks(t,r,l,i+s)}return l}drawMinorXTicks(t,e,i,s){let r;if(r=this.gridStepInPixel/5>=this.minorTickMarkStepHint?5:this.gridStepInPixel/4>=this.minorTickMarkStepHint?4:2,e>0)for(let o=0;o<r;o++){let a=i+this.labelPositions[e-1]+(this.labelPositions[e]-this.labelPositions[e-1])*o/r;a=Math.round(a)-.5*this.scale,t.strokePath({path:new w(a,s).lineTo(a,s+this.minorTickLength),color:this.foregroundColor,lineWidth:1*this.scale,opacity:100/255})}}drawMinorYTicks(t,e,i,s){let r;if(r=this.gridStepInPixel/5>=this.minorTickMarkStepHint?5:this.gridStepInPixel/4>=this.minorTickMarkStepHint?4:2,e>0)for(let o=0;o<r;o++){let a=s-this.labelPositions[e-1]-(this.labelPositions[e]-this.labelPositions[e-1])*o/r;a=Math.round(a)-.5*this.scale,t.strokePath({path:new w(i+this.majorTickLength-this.minorTickLength,a).lineTo(i+this.majorTickLength,a),color:this.foregroundColor,lineWidth:1*this.scale,opacity:100/255})}}updateLabels(t,e){if(this.labels=[],this.labelValues=[],this.labelPositions=[],this.showScale)if(this.logScale)this.updateLabelsForLogScale(this.minimum,this.maximum,e);else{const t=this.getGridStep(e,this.minimum,this.maximum),i=Math.max(Math.abs(this.minimum),Math.abs(this.maximum)),s=this.maximum/i-this.minimum/i;this.gridStepInPixel=Math.floor(e*(t/i)/s),this.updateLabelsForLinearScale(this.minimum,this.maximum,e,t)}this.updateVisibility(t)}getGridStep(t,e,i){t<=0&&(t=1);let s=!1;if(e>=i)if(i===e)i++;else{s=!0;const t=e;e=i,i=t}const r=Math.abs(i-e);let o=this.majorTickStepHint;o>t&&(o=t);let a,n=r/t*o,l=0;if(n<1){if(0!=n)for(;n<1;)n*=10,l--}else for(;n>=10;)n/=10,l++;return a=n>7.5?10*Math.pow(10,l):n>3.5?5*Math.pow(10,l):n>1.5?2*Math.pow(10,l):Math.pow(10,l),s&&(a=-a),a}updateLabelsForLogScale(t,e,i){t<=0&&(t=.1),e<=t&&(e=t+100);const s=e<t,r=Math.log10(t),o=Math.ceil(r),a=Math.ceil(Math.log10(e));let n,l=Math.pow(10,o-1);n=t%l<=0||s?t-t%l:t-t%l+l,(s&&t>n||!s&&t<n)&&this.addMinMaxTickInfo(t,i,!0);for(let t=o;s?t>=a:t<=a;t+=s?-1:1)if(Math.abs(a-o)>20){const s=Math.pow(10,t);if(s>e)break;this.addTickInfo(s,e,r,i)}else{for(let o=n;(s?o>=Math.pow(10,t-1):o<=Math.pow(10,t))&&!(s?o<e:o>e);o=s?o-l:o+l)this.addTickInfo(o,e,r,i);l=s?l/Math.pow(10,1):l*Math.pow(10,1),n=s?Math.pow(10,t-1):l+Math.pow(10,t)}(s?e<this.labelValues[this.labelValues.length-1]:e>this.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,s){this.labels.push(this.format(t));const r=Math.floor((Math.log10(t)-i)/(Math.log10(e)-i)*s)+this.margin;this.labelPositions.push(r),this.labelValues.push(t)}updateLabelsForLinearScale(t,e,i,s){let r;r=t%s<=0?t-t%s:t-t%s+s,t>r==e<t&&(this.labelValues.push(t),this.labels.push(this.format(t)),this.labelPositions.push(this.margin));let o=1;const a=Math.max(Math.abs(t),Math.abs(e));s/=a,r/=a;const n=(e/=a)-(t/=a);for(let l=r;e>=t?l<e:l>e;l=r+o++*s){const e=l*a;this.labels.push(this.format(e)),this.labelValues.push(e);const s=Math.floor((l-t)/n*i)+this.margin;this.labelPositions.push(s)}e*=a,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 t=0;t<this.labelPositions.length;t++)this.labelVisibilities.push(!0);let e=0,i=null;for(let s=0;s<this.labelPositions.length;s++){let r=!0;const o=this.labels[s],a=this.labelPositions[s];0!==s&&(r=this.hasSpaceToDraw(t,e,a,i||"",o));const n=o===i&&0!==s&&s!==this.labelPositions.length-1;let l=!0;if(this.logScale){const t=Number(this.labels[s]);l=this.isMajorTick(t)||0===s||s===this.labelPositions.length-1}r&&!n&&l?(e=a,i=o):this.labelVisibilities[s]=!1}}hasSpaceToDraw(t,e,i,s,r){const o=t.measureText(r,this.scaleFont),a=t.measureText(s,this.scaleFont);let n=i-e,l=Math.floor(this.horizontal?o.width/2+a.width/2:o.height),h=!0,d=!0;if(i!=this.labelPositions[this.labelPositions.length-1]){h=n>l+this.tickLabelGap;const e=t.measureText(this.labels[this.labels.length-1],this.scaleFont);n=this.labelPositions[this.labelPositions.length-1]-i,l=Math.floor(this.horizontal?o.width/2+e.width/2:o.height),d=n>l+this.tickLabelGap}return h&&d}isMajorTick(t){if(!this.logScale)return!0;const e=Math.log10(t);return e===Math.round(e)}format(t){return String(Number(t.toFixed(2)))}get spaceBetweenMarkAndLabel(){return 2*this.scale}get majorTickLength(){return 6*this.scale}get minorTickLength(){return 3*this.scale}get minorTickMarkStepHint(){return 4*this.scale}get tickLabelGap(){return 2*this.scale}}const Po="color_hi",Ro="color_hihi",Eo="color_lo",Mo="color_lolo",Vo="color_fillbackground",Oo="effect_3d",No="fill_color",Do="fillcolor_alarm_sensitive",Io="font",Wo="horizontal",Ho="indicator_mode",Bo="level_hi",Fo="level_hihi",Go="level_lo",Yo="level_lolo",zo="limits_from_pv",Uo="log_scale",$o="maximum",jo="major_tick_step_hint",Xo="minimum",qo="origin",Zo="origin_ignored",Ko="scale_font",Jo="show_hi",Qo="show_hihi",ta="show_label",ea="show_lo",ia="show_lolo",sa="show_markers",ra="show_minor_ticks",oa="show_scale",aa="transparent_background";class na extends te{constructor(t,e){super(t,e),this.properties.add(new F(Po)),this.properties.add(new F(Ro)),this.properties.add(new F(Eo)),this.properties.add(new F(Mo)),this.properties.add(new F(Vo)),this.properties.add(new B(Oo)),this.properties.add(new F(No)),this.properties.add(new B(Do,!1)),this.properties.add(new G(Io)),this.properties.add(new B(Wo)),this.properties.add(new B(Ho)),this.properties.add(new H(Bo)),this.properties.add(new H(Fo)),this.properties.add(new H(Go)),this.properties.add(new H(Yo)),this.properties.add(new B(zo)),this.properties.add(new B(Uo)),this.properties.add(new H($o)),this.properties.add(new H(jo)),this.properties.add(new H(Xo)),this.properties.add(new H(qo,0)),this.properties.add(new B(Zo,!0)),this.properties.add(new G(Ko)),this.properties.add(new B(Jo)),this.properties.add(new B(Qo)),this.properties.add(new B(ta)),this.properties.add(new B(ea)),this.properties.add(new B(ia)),this.properties.add(new B(sa)),this.properties.add(new B(ra)),this.properties.add(new B(oa)),this.properties.add(new B(aa))}draw(t){let e=this.area;this.borderAlarmSensitive&&(e=d(this.area,2*this.scale));const i=this.alarmSensitiveBackgroundColor;this.transparentBackground||t.fillRect(Object.assign(Object.assign({},e),{color:i})),this.horizontal?this.drawHorizontal(t,e):this.drawVertical(t,e)}drawVertical(t,e){const i=this.alarmSensitiveForegroundColor,s=new ko(this.scale,this.scaleFont,this.min,this.max,this.logScale,this.majorTickStepHint,i,this.showMinorTicks,this.showScale),r=s.drawVertical(t,e.x,e.y,e.height,!0);let o=0;this.showMarkers&&(o=this.drawVerticalMarkers(t,s,e)),this.drawVerticalBar(t,s,{x:e.x+r,y:e.y+s.margin,width:e.width-r-o,height:e.height-2*s.margin})}drawVerticalMarkers(t,e,i){const{lolo:s,lo:r,hi:o,hihi:a}=this,n=M.ARIAL_9.scale(this.scale);let l=0;if(this.showLoLo&&void 0!==s){const e=t.measureText("LOLO",n);l=Math.max(l,e.width)}if(this.showLo&&void 0!==r){const e=t.measureText("LO",n);l=Math.max(l,e.width)}if(this.showHi&&void 0!==o){const e=t.measureText("HI",n);l=Math.max(l,e.width)}if(this.showHiHi&&void 0!==a){const e=t.measureText("HIHI",n);l=Math.max(l,e.width)}const h=i.x+i.width;if(this.showLoLo&&void 0!==s){const i=h-l-this.markerGap,r=Math.round(e.getValuePosition(s));t.strokePath({path:new w(i,r).lineTo(i-this.markerTickLength,r),color:this.colorLoLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:i+this.markerGap,y:r,text:"LOLO",align:"left",baseline:"middle",color:this.colorLoLo,font:n})}if(this.showLo&&void 0!==r){const i=h-l-this.markerGap,s=Math.round(e.getValuePosition(r));t.strokePath({path:new w(i,s).lineTo(i-this.markerTickLength,s),color:this.colorLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:i+this.markerGap,y:s,text:"LO",align:"left",baseline:"middle",color:this.colorLo,font:n})}if(this.showHi&&void 0!==o){const i=h-l-this.markerGap,s=Math.round(e.getValuePosition(o));t.strokePath({path:new w(i,s).lineTo(i-this.markerTickLength,s),color:this.colorHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:i+this.markerGap,y:s,text:"HI",align:"left",baseline:"middle",color:this.colorHi,font:n})}if(this.showHiHi&&void 0!==a){const i=h-l-this.markerGap,s=Math.round(e.getValuePosition(a));t.strokePath({path:new w(i,s).lineTo(i-this.markerTickLength,s),color:this.colorHiHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:i+this.markerGap,y:s,text:"HIHI",align:"left",baseline:"middle",color:this.colorHiHi,font:n})}return this.markerTickLength+this.markerGap+l}drawVerticalBar(t,i,s){var r;const{outlineWidth:o}=this;if(t.fillRect(Object.assign(Object.assign({},s),{color:this.colorFillbackground})),this.effect3d){const i=t.createLinearGradient(s.x,0,s.x+s.width,0);i.addColorStop(0,e.WHITE.toString()),i.addColorStop(1,this.colorFillbackground.withAlpha(0).toString()),t.fillRect(Object.assign(Object.assign({},s),{gradient:i}));const r=d(s,o/2);t.strokeRect(Object.assign(Object.assign({},r),{color:e.GRAY,lineWidth:o}))}const a=this.alarmSensitiveFillColor;if(this.indicatorMode){const r=Math.round(i.getValuePosition(this.getFillValue())),n=s.width,l=this.thumbBreadth,h=p([{x:0,y:l/2},{x:n/2,y:0},{x:n-1,y:l/2},{x:n/2,y:l}],s.x,r-l/2),d=w.fromPoints(h);if(this.effect3d){const{x:i,y:s}=h[0],{x:r,y:n}=h[2],l=t.createLinearGradient(i,s,r,n);l.addColorStop(0,e.WHITE.toString()),l.addColorStop(1,a.toString()),t.fillPath({path:d,gradient:l}),t.strokePath({path:d,color:e.GRAY,lineWidth:o})}else t.fillPath({path:d,color:a})}else{let r=this.originIgnored?this.min:this.origin,n=this.getFillValue();if(n<r){const t=r;r=n,n=t}const l=Math.round(i.getValuePosition(r)),h=Math.round(i.getValuePosition(n)),c=d(Object.assign(Object.assign({},s),{y:l,height:h-l}),o);if(t.fillRect(Object.assign(Object.assign({},c),{color:a})),this.effect3d){const i=t.createLinearGradient(c.x,0,c.x+c.width,0);i.addColorStop(0,e.WHITE.toString()),i.addColorStop(1,a.withAlpha(0).toString()),t.fillRect(Object.assign(Object.assign({},c),{gradient:i}))}}const n=null===(r=this.pv)||void 0===r?void 0:r.value;this.showLabel&&void 0!==n&&t.fillText({x:s.x+s.width/2,y:s.y+s.height/2,align:"center",baseline:"middle",color:this.alarmSensitiveForegroundColor,font:this.font,text:this.format(n)})}drawHorizontal(t,e){const i=this.alarmSensitiveForegroundColor,s=new ko(this.scale,this.scaleFont,this.min,this.max,this.logScale,this.majorTickStepHint,i,this.showMinorTicks,this.showScale),r=s.drawHorizontal(t,e.x,e.y+e.height,e.width);let o=0;this.showMarkers&&(o=this.drawHorizontalMarkers(t,s,e)),this.drawHorizontalBar(t,s,{x:e.x+s.margin,y:e.y+o,width:e.width-2*s.margin,height:e.height-r-o})}drawHorizontalMarkers(t,e,i){const{lolo:s,lo:r,hi:o,hihi:a}=this,n=M.ARIAL_9.scale(this.scale);let l=0;if(this.showLoLo&&void 0!==s){const e=t.measureText("LOLO",n);l=Math.max(l,e.height)}if(this.showLo&&void 0!==r){const e=t.measureText("LO",n);l=Math.max(l,e.height)}if(this.showHi&&void 0!==o){const e=t.measureText("HI",n);l=Math.max(l,e.height)}if(this.showHiHi&&void 0!==a){const e=t.measureText("HIHI",n);l=Math.max(l,e.height)}const h=i.y;if(this.showLoLo&&void 0!==s){const i=Math.round(e.getValuePosition(s)),r=h+l+this.markerGap;t.strokePath({path:new w(i,r).lineTo(i,r+this.markerTickLength),color:this.colorLoLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:i,y:h,text:"LOLO",align:"center",baseline:"top",color:this.colorLoLo,font:n})}if(this.showLo&&void 0!==r){const i=Math.round(e.getValuePosition(r)),s=h+l+this.markerGap;t.strokePath({path:new w(i,s).lineTo(i,s+this.markerTickLength),color:this.colorLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:i,y:h,text:"LO",align:"center",baseline:"top",color:this.colorLo,font:n})}if(this.showHi&&void 0!==o){const i=Math.round(e.getValuePosition(o)),s=h+l+this.markerGap;t.strokePath({path:new w(i,s).lineTo(i,s+this.markerTickLength),color:this.colorHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:i,y:h,text:"HI",align:"center",baseline:"top",color:this.colorHi,font:n})}if(this.showHiHi&&void 0!==a){const i=Math.round(e.getValuePosition(a)),s=h+l+this.markerGap;t.strokePath({path:new w(i,s).lineTo(i,s+this.markerTickLength),color:this.colorHiHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:i,y:h,text:"HIHI",align:"center",baseline:"top",color:this.colorHiHi,font:n})}return this.markerTickLength+this.markerGap+l}drawHorizontalBar(t,i,s){var r;const{outlineWidth:o}=this;if(t.fillRect(Object.assign(Object.assign({},s),{color:this.colorFillbackground})),this.effect3d){const i=t.createLinearGradient(0,s.y,0,s.y+s.height);i.addColorStop(0,e.WHITE.toString()),i.addColorStop(1,this.colorFillbackground.withAlpha(0).toString()),t.fillRect(Object.assign(Object.assign({},s),{gradient:i}));const r=d(s,o/2);t.strokeRect(Object.assign(Object.assign({},r),{color:e.GRAY,lineWidth:o}))}const a=this.alarmSensitiveFillColor;if(this.indicatorMode){const r=Math.round(i.getValuePosition(this.getFillValue())),n=s.height,l=this.thumbBreadth,h=p([{x:l/2,y:0},{x:l,y:n/2},{x:l/2,y:n-1},{x:0,y:n/2}],r-l/2,s.y),d=w.fromPoints(h);if(this.effect3d){const{x:i,y:s}=h[0],{x:r,y:n}=h[2],l=t.createLinearGradient(i,s,r,n);l.addColorStop(0,e.WHITE.toString()),l.addColorStop(1,a.toString()),t.fillPath({path:d,gradient:l}),t.strokePath({path:d,color:e.GRAY,lineWidth:o})}else t.fillPath({path:d,color:a})}else{let r=this.originIgnored?this.min:this.origin,n=this.getFillValue();if(n<r){const t=r;r=n,n=t}const l=Math.round(i.getValuePosition(r)),h=Math.round(i.getValuePosition(n)),c=d(Object.assign(Object.assign({},s),{x:l,width:h-l}),o);if(t.fillRect(Object.assign(Object.assign({},c),{color:a})),this.effect3d){const i=t.createLinearGradient(0,c.y,0,c.y+c.height);i.addColorStop(0,e.WHITE.toString()),i.addColorStop(1,a.withAlpha(0).toString()),t.fillRect(Object.assign(Object.assign({},c),{gradient:i}))}}const n=null===(r=this.pv)||void 0===r?void 0:r.value;this.showLabel&&void 0!==n&&t.fillText({x:s.x+s.width/2,y:s.y+s.height/2,align:"center",baseline:"middle",color:this.alarmSensitiveForegroundColor,font:this.font,text:this.format(n)})}get min(){var t,e;return this.limitsFromPv&&null!==(e=null===(t=this.pv)||void 0===t?void 0:t.lowerDisplayLimit)&&void 0!==e?e:this.minimum}get max(){var t,e;return this.limitsFromPv&&null!==(e=null===(t=this.pv)||void 0===t?void 0:t.upperDisplayLimit)&&void 0!==e?e:this.maximum}get lolo(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.lowerAlarmLimit:this.levelLoLo}get lo(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.lowerWarningLimit:this.levelLo}get hi(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.upperWarningLimit:this.levelHi}get hihi(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.upperAlarmLimit:this.levelHiHi}get markerTickLength(){return 10*this.scale}get markerTickLineWidth(){return 2*this.scale}get markerGap(){return 3*this.scale}get thumbBreadth(){return 13*this.scale}get outlineWidth(){return 1*this.scale}get alarmSensitiveFillColor(){if(this.fillColorAlarmSensitive){if(this.isMajorSeverity())return e.RED;if(this.isMinorSeverity())return e.ORANGE}return this.fillColor}getFillValue(){var t,e;let i=null!==(e=null===(t=this.pv)||void 0===t?void 0:t.value)&&void 0!==e?e:this.min;return i=Math.max(this.min,i),i=Math.min(this.max,i),i}format(t){return String(Number(t.toFixed(2)))}get colorLo(){return this.properties.getValue(Eo)}get colorLoLo(){return this.properties.getValue(Mo)}get colorHi(){return this.properties.getValue(Po)}get colorHiHi(){return this.properties.getValue(Ro)}get scaleFont(){return this.properties.getValue(Ko).scale(this.scale)}get colorFillbackground(){return this.properties.getValue(Vo)}get effect3d(){return this.properties.getValue(Oo)}get fillColorAlarmSensitive(){return this.properties.getValue(Do)}get fillColor(){return this.properties.getValue(No)}get font(){return this.properties.getValue(Io).scale(this.scale)}get horizontal(){return this.properties.getValue(Wo)}get indicatorMode(){return this.properties.getValue(Ho)}get levelLo(){return this.properties.getValue(Go)}get levelLoLo(){return this.properties.getValue(Yo)}get levelHi(){return this.properties.getValue(Bo)}get levelHiHi(){return this.properties.getValue(Fo)}get limitsFromPv(){return this.properties.getValue(zo)}get logScale(){return this.properties.getValue(Uo)}get minimum(){return this.properties.getValue(Xo)}get majorTickStepHint(){return this.scale*this.properties.getValue(jo)}get maximum(){return this.properties.getValue($o)}get origin(){return this.properties.getValue(qo)}get originIgnored(){return this.properties.getValue(Zo)}get showHi(){return this.properties.getValue(Jo)}get showHiHi(){return this.properties.getValue(Qo)}get showLabel(){return this.properties.getValue(ta)}get showLo(){return this.properties.getValue(ea)}get showLoLo(){return this.properties.getValue(ia)}get showMarkers(){return this.properties.getValue(sa)}get showMinorTicks(){return this.properties.getValue(ra)}get showScale(){return this.properties.getValue(oa)}get transparentBackground(){return this.properties.getValue(aa)}}const la="color_hi",ha="color_hihi",da="color_lo",ca="color_lolo",pa="color_fillbackground",ua="fill_color",ga="fillcolor_alarm_sensitive",fa="effect_3d",ma="level_hi",ya="level_hihi",xa="level_lo",va="level_lolo",wa="limits_from_pv",ba="log_scale",_a="maximum",Sa="major_tick_step_hint",Ta="minimum",Ca="scale_font",La="show_hi",Aa="show_hihi",ka="show_lo",Pa="show_lolo",Ra="show_markers",Ea="show_minor_ticks",Ma="show_scale",Va="transparent_background",Oa=new e(160,160,160);class Na extends te{constructor(t,e){super(t,e),this.properties.add(new F(la)),this.properties.add(new F(ha)),this.properties.add(new F(da)),this.properties.add(new F(ca)),this.properties.add(new F(pa)),this.properties.add(new B(fa)),this.properties.add(new F(ua)),this.properties.add(new B(ga,!1)),this.properties.add(new H(ma)),this.properties.add(new H(ya)),this.properties.add(new H(xa)),this.properties.add(new H(va)),this.properties.add(new B(wa)),this.properties.add(new B(ba)),this.properties.add(new H(_a)),this.properties.add(new H(Sa)),this.properties.add(new H(Ta)),this.properties.add(new G(Ca)),this.properties.add(new B(La)),this.properties.add(new B(Aa)),this.properties.add(new B(ka)),this.properties.add(new B(Pa)),this.properties.add(new B(Ra)),this.properties.add(new B(Ea)),this.properties.add(new B(Ma)),this.properties.add(new B(Va))}draw(t){const{scale:e,min:i,max:s}=this;let r=this.area;this.borderAlarmSensitive&&(r=d(r,2*e));const o=this.alarmSensitiveBackgroundColor;this.transparentBackground||t.fillRect(Object.assign(Object.assign({},r),{color:o}));const a=this.alarmSensitiveForegroundColor,n=new ko(e,this.scaleFont,i,s,this.logScale,this.majorTickStepHint,a,this.showMinorTicks,this.showScale),l=n.drawVertical(t,r.x,r.y,r.height,!0);let h=0;this.showMarkers&&(h=this.drawMarkers(t,r,n)),this.drawTank(t,r,l,h,n)}drawMarkers(t,e,i){const{lolo:s,lo:r,hi:o,hihi:a}=this,n=M.ARIAL_9.scale(this.scale);let l=0;if(this.showLoLo&&void 0!==s){const e=t.measureText("LOLO",n);l=Math.max(l,e.width)}if(this.showLo&&void 0!==r){const e=t.measureText("LO",n);l=Math.max(l,e.width)}if(this.showHi&&void 0!==o){const e=t.measureText("HI",n);l=Math.max(l,e.width)}if(this.showHiHi&&void 0!==a){const e=t.measureText("HIHI",n);l=Math.max(l,e.width)}const h=e.x+e.width-l-this.markerGap-this.markerTickLength;if(this.showLoLo&&void 0!==s){const e=Math.round(i.getValuePosition(s));t.strokePath({path:new w(h,e).lineTo(h+this.markerTickLength,e),color:this.colorLoLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:h+this.markerTickLength+this.markerGap,y:e,text:"LOLO",align:"left",baseline:"middle",color:this.colorLoLo,font:n})}if(this.showLo&&void 0!==r){const e=Math.round(i.getValuePosition(r));t.strokePath({path:new w(h,e).lineTo(h+this.markerTickLength,e),color:this.colorLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:h+this.markerTickLength+this.markerGap,y:e,text:"LO",align:"left",baseline:"middle",color:this.colorLo,font:n})}if(this.showHi&&void 0!==o){const e=Math.round(i.getValuePosition(o));t.strokePath({path:new w(h,e).lineTo(h+this.markerTickLength,e),color:this.colorHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:h+this.markerTickLength+this.markerGap,y:e,text:"HI",align:"left",baseline:"middle",color:this.colorHi,font:n})}if(this.showHiHi&&void 0!==a){const e=Math.round(i.getValuePosition(a));t.strokePath({path:new w(h,e).lineTo(h+this.markerTickLength,e),color:this.colorHiHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:h+this.markerTickLength+this.markerGap,y:e,text:"HIHI",align:"left",baseline:"middle",color:this.colorHiHi,font:n})}return this.markerTickLength+this.markerGap+l}drawTank(t,i,s,r,o){const a=this.alarmSensitiveForegroundColor,{scale:n,outlineWidth:l}=this,h=i.x+s,c=i.y+o.margin,p=i.width-s-r,u=i.height-2*o.margin;let g=this.defaultCorner,f=.55;p<2*g&&(f=.6);const m=Math.floor(p*f);g>2*m-p-2*l&&(g=2*m-p);const y=o.getValuePosition(this.getFillValue()),x=this.alarmSensitiveFillColor;if(this.effect3d){t.fillRect({x:h,y:c,width:p,height:u,rx:g/2,ry:g/2,color:e.WHITE});let i=t.createLinearGradient(h,c,h+m+2*n,c);i.addColorStop(0,this.colorFillbackground.toString()),i.addColorStop(1,e.WHITE.withAlpha(0).toString()),t.fillRect({x:h,y:c,width:m,height:u,rx:g/2,ry:g/2,gradient:i}),i=t.createLinearGradient(h+p-m-2*n,c,h+p,c),i.addColorStop(0,e.WHITE.withAlpha(0).toString()),i.addColorStop(1,this.colorFillbackground.toString()),t.fillRect({x:h+p-m,y:c,width:m,height:u,rx:g/2,ry:g/2,gradient:i});const s=y,r=c+u-y;i=t.createLinearGradient(h,s,h+m+2*n,s),i.addColorStop(0,x.toString()),i.addColorStop(1,e.WHITE.withAlpha(0).toString()),t.fillRect({x:h,y:s,width:m,height:r,rx:g/2,ry:g/2,gradient:i}),i=t.createLinearGradient(h+p-m-2*n,s,h+p,s),i.addColorStop(0,e.WHITE.withAlpha(0).toString()),i.addColorStop(1,x.toString()),t.fillRect({x:h+p-m,y:s,width:m,height:r,rx:g/2,ry:g/2,gradient:i})}else t.fillRect({x:h,y:c,width:p,height:u,rx:g/2,ry:g/2,color:this.colorFillbackground}),t.fillRect({x:h,y:y,width:p,height:c+u-y,rx:g/2,ry:g/2,color:x});let v=d({x:h,y:c,width:p,height:u},l/2);t.strokeRect(Object.assign(Object.assign({},v),{rx:g/2,ry:g/2,color:this.effect3d?Oa:a,lineWidth:l}))}get min(){var t,e;return this.limitsFromPv&&null!==(e=null===(t=this.pv)||void 0===t?void 0:t.lowerDisplayLimit)&&void 0!==e?e:this.minimum}get max(){var t,e;return this.limitsFromPv&&null!==(e=null===(t=this.pv)||void 0===t?void 0:t.upperDisplayLimit)&&void 0!==e?e: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 15*this.scale}get markerTickLength(){return 10*this.scale}get markerTickLineWidth(){return 2*this.scale}get markerGap(){return 3*this.scale}get outlineWidth(){return 1*this.scale}get alarmSensitiveFillColor(){if(this.fillColorAlarmSensitive){if(this.isMajorSeverity())return e.RED;if(this.isMinorSeverity())return e.ORANGE}return this.fillColor}getFillValue(){var t,e;let i=null!==(e=null===(t=this.pv)||void 0===t?void 0:t.value)&&void 0!==e?e:this.min;return i=Math.max(this.min,i),i=Math.min(this.max,i),i}get colorLo(){return this.properties.getValue(da)}get colorLoLo(){return this.properties.getValue(ca)}get colorHi(){return this.properties.getValue(la)}get colorHiHi(){return this.properties.getValue(ha)}get scaleFont(){return this.properties.getValue(Ca).scale(this.scale)}get colorFillbackground(){return this.properties.getValue(pa)}get fillColorAlarmSensitive(){return this.properties.getValue(ga)}get fillColor(){return this.properties.getValue(ua)}get effect3d(){return this.properties.getValue(fa)}get levelLo(){return this.properties.getValue(xa)}get levelLoLo(){return this.properties.getValue(va)}get levelHi(){return this.properties.getValue(ma)}get levelHiHi(){return this.properties.getValue(ya)}get limitsFromPv(){return this.properties.getValue(wa)}get logScale(){return this.properties.getValue(ba)}get minimum(){return this.properties.getValue(Ta)}get majorTickStepHint(){return this.scale*this.properties.getValue(Sa)}get maximum(){return this.properties.getValue(_a)}get showLo(){return this.properties.getValue(ka)}get showLoLo(){return this.properties.getValue(Pa)}get showHi(){return this.properties.getValue(La)}get showHiHi(){return this.properties.getValue(Aa)}get showMarkers(){return this.properties.getValue(Ra)}get showMinorTicks(){return this.properties.getValue(Ea)}get showScale(){return this.properties.getValue(Ma)}get transparentBackground(){return this.properties.getValue(Va)}}const Da="font",Ia="format_type",Wa="horizontal_alignment",Ha="precision",Ba="precision_from_pv",Fa="vertical_alignment";class Ga extends te{constructor(t,e){super(t,e),this.properties.add(new G(Da)),this.properties.add(new W(Ia)),this.properties.add(new W(Wa)),this.properties.add(new W(Ha)),this.properties.add(new B(Ba)),this.properties.add(new W(Fa))}init(){this.areaRegion={id:`${this.wuid}-area`,click:()=>{const t={pvName:this.pvName};this.display.fireEvent("openpv",t)},cursor:"pointer"}}draw(t){const e=t.ctx;if(this.transparent?this.backgroundAlarmSensitive&&this.alarm&&t.fillRect(Object.assign(Object.assign({},this.area),{color:this.alarmSensitiveBackgroundColor})):t.fillRect(Object.assign(Object.assign({},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();const{scale:i}=this;let s=this.area;this.borderAlarmSensitive&&(s=d(s,2*i,2*i));let r=s.x;0===this.horizAlignment?e.textAlign="start":1===this.horizAlignment?(r+=s.width/2,e.textAlign="center"):2===this.horizAlignment&&(r+=s.width,e.textAlign="end");let o=s.y;0===this.vertAlignment?e.textBaseline="top":1===this.vertAlignment?(o+=s.height/2,e.textBaseline="middle"):2===this.vertAlignment&&(o+=s.height,e.textBaseline="bottom");let a=this.text;if(this.pv&&void 0!==this.pv.value){const t=this.precisionFromPV?this.pv.precision:this.precision;a=this.pv.formatValue(this.formatType,t)}e.fillText(a,r,o)}get font(){return this.properties.getValue(Da).scale(this.scale)}get formatType(){return this.properties.getValue(Ia)}get horizAlignment(){return this.properties.getValue(Wa)}get precision(){return this.properties.getValue(Ha)}get precisionFromPV(){return this.properties.getValue(Ba)}get vertAlignment(){return this.properties.getValue(Fa)}}const Ya="color_hi",za="color_hihi",Ua="color_lo",$a="color_lolo",ja="color_fillbackground",Xa="fill_color",qa="fillcolor_alarm_sensitive",Za="font",Ka="effect_3d",Ja="level_hi",Qa="level_hihi",tn="level_lo",en="level_lolo",sn="limits_from_pv",rn="log_scale",on="maximum",an="major_tick_step_hint",nn="minimum",ln="scale_font",hn="show_bulb",dn="show_hi",cn="show_hihi",pn="show_lo",un="show_lolo",gn="show_markers",fn="show_minor_ticks",mn="show_scale",yn="transparent_background",xn="unit",vn=new e(160,160,160);class wn extends te{constructor(t,e){super(t,e),this.properties.add(new F(Ya)),this.properties.add(new F(za)),this.properties.add(new F(Ua)),this.properties.add(new F($a)),this.properties.add(new F(ja)),this.properties.add(new F(Xa)),this.properties.add(new B(qa,!1)),this.properties.add(new B(Ka)),this.properties.add(new H(Ja)),this.properties.add(new H(Qa)),this.properties.add(new H(tn)),this.properties.add(new H(en)),this.properties.add(new B(sn)),this.properties.add(new G(Za)),this.properties.add(new B(rn)),this.properties.add(new H(on)),this.properties.add(new H(an)),this.properties.add(new H(nn)),this.properties.add(new G(ln)),this.properties.add(new B(hn)),this.properties.add(new B(dn)),this.properties.add(new B(cn)),this.properties.add(new B(pn)),this.properties.add(new B(un)),this.properties.add(new B(gn)),this.properties.add(new B(fn)),this.properties.add(new B(mn)),this.properties.add(new B(yn)),this.properties.add(new W(xn))}draw(t){var i;const{scale:s,min:r,max:o}=this;let a=this.area;this.borderAlarmSensitive&&(a=d(this.area,2*this.scale));const n=this.alarmSensitiveBackgroundColor,l=this.alarmSensitiveForegroundColor,h=this.alarmSensitiveFillColor;this.transparentBackground||t.fillRect(Object.assign(Object.assign({},a),{color:n}));let c=a.height;if(this.showBulb){let t=Math.min(a.width/2,this.bulbMaxDiameter);c=a.height<t?0:a.height-t}let p=Object.assign(Object.assign({},a),{height:c});const u=new ko(s,this.scaleFont,r,o,this.logScale,this.majorTickStepHint,l,this.showMinorTicks,this.showScale);let g=0,f="";if(0===this.unit?f="°C":1===this.unit?f="°F":2===this.unit&&(f="K"),f){const e=M.ARIAL_9.scale(s),i=2*s;g=t.measureText(f,e).height+2*i,t.fillText({x:a.x+a.width/2-this.pipeWidth/2-i,y:a.y+i,baseline:"top",align:"right",color:l,font:e,text:f})}const m=p.x+p.width/2-this.pipeWidth/2-1*s,y=Object.assign(Object.assign({},p),{y:p.y+g,height:p.height-g+u.calculateMargin(t,!1)});u.drawVertical(t,m,y.y,y.height,!1);const x=Math.floor(this.pipeWidth/2);if(p=Object.assign(Object.assign({},p),{y:u.getValuePosition(o)-x,height:u.scaleLength+2*x}),this.drawPipe(t,p,u),this.showMarkers&&this.drawMarkers(t,a,u),this.showBulb){let o=Math.min(a.width/2,this.bulbMaxDiameter);const n=1*s,d=a.x+a.width/2,g=a.y+c+o/2,f=o/2,m=o/2;if(t.fillEllipse({cx:d,cy:g,rx:f,ry:m,color:h}),this.effect3d){const i=t.createLinearGradient(d-f,g-m,d+f,g+m);i.addColorStop(0,e.WHITE.toString()),i.addColorStop(1,h.withAlpha(0).toString()),t.fillEllipse({cx:d,cy:g,rx:f,ry:m,gradient:i})}t.strokeEllipse({cx:d,cy:g,rx:f-n/2,ry:m-n/2,color:this.effect3d?vn:l,lineWidth:n});const y={x:Math.round(p.x+p.width/2-this.pipeWidth/2)+this.outlineWidth,y:Math.floor(u.getValuePosition(r)),width:this.pipeWidth-2*this.outlineWidth,height:3*s};if(this.effect3d){const i=Math.round(p.x+p.width/2-this.pipeWidth/2),s=i+this.pipeWidth,r=t.createLinearGradient(i,y.y,s,y.y);r.addColorStop(0,e.WHITE.toString()),r.addColorStop(1,h.toString()),t.fillRect(Object.assign(Object.assign({},y),{gradient:r}))}else t.fillRect(Object.assign(Object.assign({},y),{color:h}));const x=null===(i=this.pv)||void 0===i?void 0:i.value;x&&t.fillText({x:d,y:g,align:"center",baseline:"middle",color:h.contrast(),font:this.font,text:this.format(x)})}}drawPipe(t,i,s){const{scale:r,outlineWidth:o,min:a,max:n}=this,l=this.alarmSensitiveForegroundColor,h=this.alarmSensitiveFillColor,c={x:Math.round(i.x+i.width/2-this.pipeWidth/2),y:i.y,width:this.pipeWidth,height:i.height},p=this.getFillValue();let u=s.getValuePosition(p);n>a?p>n?u-=10*r:p<a&&(u+=10*r):p>a?u+=10*r:p<n&&(u-=10*r);const g=this.pipeWidth/2,{x:f,y:m,width:y,height:x}=c;if(this.effect3d){let i=t.createLinearGradient(f,m,f+y,m);i.addColorStop(0,e.WHITE.toString()),i.addColorStop(1,this.colorFillbackground.toString()),t.fillRect(Object.assign(Object.assign({},c),{rx:g/2,ry:g/2,gradient:i})),i=t.createLinearGradient(f,m,f+y,m),i.addColorStop(0,e.WHITE.toString()),i.addColorStop(1,h.toString()),t.fillRect({x:f,y:u,width:y,height:m+x-u,rx:g/2,ry:g/2,gradient:i})}else t.fillRect(Object.assign(Object.assign({},c),{rx:g/2,ry:g/2,color:this.colorFillbackground})),t.fillRect({x:f,y:u,width:y,height:m+x-u,rx:g/2,ry:g/2,color:h});let v=d(c,o/2);t.strokeRect(Object.assign(Object.assign({},v),{rx:g/2,ry:g/2,color:this.effect3d?vn:l,lineWidth:o}))}drawMarkers(t,e,i){const{lolo:s,lo:r,hi:o,hihi:a}=this,n=M.ARIAL_9.scale(this.scale),l=e.x+e.width/2+this.pipeWidth/2;if(this.showLoLo&&void 0!==s){const e=Math.round(i.getValuePosition(s));t.strokePath({path:new w(l,e).lineTo(l+this.markerTickLength,e),color:this.colorLoLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:l+this.markerTickLength+this.markerGap,y:e,text:"LOLO",align:"left",baseline:"middle",color:this.colorLoLo,font:n})}if(this.showLo&&void 0!==r){const e=Math.round(i.getValuePosition(r));t.strokePath({path:new w(l,e).lineTo(l+this.markerTickLength,e),color:this.colorLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:l+this.markerTickLength+this.markerGap,y:e,text:"LO",align:"left",baseline:"middle",color:this.colorLo,font:n})}if(this.showHi&&void 0!==o){const e=Math.round(i.getValuePosition(o));t.strokePath({path:new w(l,e).lineTo(l+this.markerTickLength,e),color:this.colorHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:l+this.markerTickLength+this.markerGap,y:e,text:"HI",align:"left",baseline:"middle",color:this.colorHi,font:n})}if(this.showHiHi&&void 0!==a){const e=Math.round(i.getValuePosition(a));t.strokePath({path:new w(l,e).lineTo(l+this.markerTickLength,e),color:this.colorHiHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:l+this.markerTickLength+this.markerGap,y:e,text:"HIHI",align:"left",baseline:"middle",color:this.colorHiHi,font:n})}}get min(){var t,e;return this.limitsFromPv&&null!==(e=null===(t=this.pv)||void 0===t?void 0:t.lowerDisplayLimit)&&void 0!==e?e:this.minimum}get max(){var t,e;return this.limitsFromPv&&null!==(e=null===(t=this.pv)||void 0===t?void 0:t.upperDisplayLimit)&&void 0!==e?e:this.maximum}get lolo(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.lowerAlarmLimit:this.levelLoLo}get lo(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.lowerWarningLimit:this.levelLo}get hi(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.upperWarningLimit:this.levelHi}get hihi(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.upperAlarmLimit:this.levelHiHi}get pipeWidth(){return 15*this.scale}get bulbMaxDiameter(){return 40*this.scale}get outlineWidth(){return 1*this.scale}get markerTickLength(){return 10*this.scale}get markerTickLineWidth(){return 2*this.scale}get markerGap(){return 3*this.scale}get alarmSensitiveFillColor(){if(this.fillColorAlarmSensitive){if(this.isMajorSeverity())return e.RED;if(this.isMinorSeverity())return e.ORANGE}return this.fillColor}getFillValue(){var t,e;let i=null!==(e=null===(t=this.pv)||void 0===t?void 0:t.value)&&void 0!==e?e:this.min;return i=Math.max(this.min,i),i=Math.min(this.max,i),i}format(t){return String(Number(t.toFixed(3)))}get colorLo(){return this.properties.getValue(Ua)}get colorLoLo(){return this.properties.getValue($a)}get colorHi(){return this.properties.getValue(Ya)}get colorHiHi(){return this.properties.getValue(za)}get scaleFont(){return this.properties.getValue(ln).scale(this.scale)}get colorFillbackground(){return this.properties.getValue(ja)}get fillColorAlarmSensitive(){return this.properties.getValue(qa)}get fillColor(){return this.properties.getValue(Xa)}get font(){return this.properties.getValue(Za).scale(this.scale)}get effect3d(){return this.properties.getValue(Ka)}get levelLo(){return this.properties.getValue(tn)}get levelLoLo(){return this.properties.getValue(en)}get levelHi(){return this.properties.getValue(Ja)}get levelHiHi(){return this.properties.getValue(Qa)}get limitsFromPv(){return this.properties.getValue(sn)}get logScale(){return this.properties.getValue(rn)}get minimum(){return this.properties.getValue(nn)}get majorTickStepHint(){return this.scale*this.properties.getValue(an)}get maximum(){return this.properties.getValue(on)}get showBulb(){return this.properties.getValue(hn)}get showMarkers(){return this.properties.getValue(gn)}get showMinorTicks(){return this.properties.getValue(fn)}get showLo(){return this.properties.getValue(pn)}get showLoLo(){return this.properties.getValue(un)}get showHi(){return this.properties.getValue(dn)}get showHiHi(){return this.properties.getValue(cn)}get showScale(){return this.properties.getValue(mn)}get transparentBackground(){return this.properties.getValue(yn)}get unit(){return this.properties.getValue(xn)}}var bn=function(t,e,i,s,r,o){var a,n,l,h,d=s("pixelsPerLabel"),c=[];if(o)for(a=0;a<o.length;a++)c.push({v:o[a]});else{if(s("logscale")){h=Math.floor(i/d);var p=ol(t,Vn,1),u=ol(e,Vn,-1);-1==p&&(p=0),-1==u&&(u=Vn.length-1);var g=null;if(u-p>=h/4){for(var f=u;f>=p;f--){var m=Vn[f],y=Math.log(m/t)/Math.log(e/t)*i,x={v:m};null===g||Math.abs(y-g.pixel_coord)>=d?g={tickValue:m,pixel_coord:y}:x.label="",c.push(x)}c.reverse()}}if(0===c.length){var v,w;s("labelsKMG2")?(v=[1,2,4,8,16,32,64,128,256],w=16):(v=[1,2,5,10,20,50,100],w=10);var b,_,S,T=Math.ceil(i/d),C=Math.abs(e-t)/T,L=Math.floor(Math.log(C)/Math.log(w)),A=Math.pow(w,L);for(n=0;n<v.length&&(b=A*v[n],_=Math.floor(t/b)*b,S=Math.ceil(e/b)*b,!(i/(h=Math.abs(S-_)/b)>d));n++);for(_>S&&(b*=-1),a=0;a<=h;a++)l=_+a*b,c.push({v:l})}}var k=s("axisLabelFormatter");for(a=0;a<c.length;a++)void 0===c[a].label&&(c[a].label=k.call(r,c[a].v,0,s,r));return c},_n=function(t,e,i,s,r,o){var a=On(t,e,i,s);return a>=0?Dn(t,e,a,s,r):[]},Sn={MILLISECONDLY:0,TWO_MILLISECONDLY:1,FIVE_MILLISECONDLY:2,TEN_MILLISECONDLY:3,FIFTY_MILLISECONDLY:4,HUNDRED_MILLISECONDLY:5,FIVE_HUNDRED_MILLISECONDLY:6,SECONDLY:7,TWO_SECONDLY:8,FIVE_SECONDLY:9,TEN_SECONDLY:10,THIRTY_SECONDLY:11,MINUTELY:12,TWO_MINUTELY:13,FIVE_MINUTELY:14,TEN_MINUTELY:15,THIRTY_MINUTELY:16,HOURLY:17,TWO_HOURLY:18,SIX_HOURLY:19,DAILY:20,TWO_DAILY:21,WEEKLY:22,MONTHLY:23,QUARTERLY:24,BIANNUAL:25,ANNUAL:26,DECADAL:27,CENTENNIAL:28,NUM_GRANULARITIES:29},Tn=0,Cn=1,Ln=2,An=3,kn=4,Pn=5,Rn=6,En=7,Mn=[];Mn[Sn.MILLISECONDLY]={datefield:Rn,step:1,spacing:1},Mn[Sn.TWO_MILLISECONDLY]={datefield:Rn,step:2,spacing:2},Mn[Sn.FIVE_MILLISECONDLY]={datefield:Rn,step:5,spacing:5},Mn[Sn.TEN_MILLISECONDLY]={datefield:Rn,step:10,spacing:10},Mn[Sn.FIFTY_MILLISECONDLY]={datefield:Rn,step:50,spacing:50},Mn[Sn.HUNDRED_MILLISECONDLY]={datefield:Rn,step:100,spacing:100},Mn[Sn.FIVE_HUNDRED_MILLISECONDLY]={datefield:Rn,step:500,spacing:500},Mn[Sn.SECONDLY]={datefield:Pn,step:1,spacing:1e3},Mn[Sn.TWO_SECONDLY]={datefield:Pn,step:2,spacing:2e3},Mn[Sn.FIVE_SECONDLY]={datefield:Pn,step:5,spacing:5e3},Mn[Sn.TEN_SECONDLY]={datefield:Pn,step:10,spacing:1e4},Mn[Sn.THIRTY_SECONDLY]={datefield:Pn,step:30,spacing:3e4},Mn[Sn.MINUTELY]={datefield:kn,step:1,spacing:6e4},Mn[Sn.TWO_MINUTELY]={datefield:kn,step:2,spacing:12e4},Mn[Sn.FIVE_MINUTELY]={datefield:kn,step:5,spacing:3e5},Mn[Sn.TEN_MINUTELY]={datefield:kn,step:10,spacing:6e5},Mn[Sn.THIRTY_MINUTELY]={datefield:kn,step:30,spacing:18e5},Mn[Sn.HOURLY]={datefield:An,step:1,spacing:36e5},Mn[Sn.TWO_HOURLY]={datefield:An,step:2,spacing:72e5},Mn[Sn.SIX_HOURLY]={datefield:An,step:6,spacing:216e5},Mn[Sn.DAILY]={datefield:Ln,step:1,spacing:864e5},Mn[Sn.TWO_DAILY]={datefield:Ln,step:2,spacing:1728e5},Mn[Sn.WEEKLY]={datefield:Ln,step:7,spacing:6048e5},Mn[Sn.MONTHLY]={datefield:Cn,step:1,spacing:2629817280},Mn[Sn.QUARTERLY]={datefield:Cn,step:3,spacing:7889451840.000001},Mn[Sn.BIANNUAL]={datefield:Cn,step:6,spacing:432e5*365.2524},Mn[Sn.ANNUAL]={datefield:Tn,step:1,spacing:864e5*365.2524},Mn[Sn.DECADAL]={datefield:Tn,step:10,spacing:315578073600},Mn[Sn.CENTENNIAL]={datefield:Tn,step:100,spacing:3155780736e3};var Vn=function(){for(var t=[],e=-39;e<=39;e++)for(var i=Math.pow(10,e),s=1;s<=9;s++){var r=i*s;t.push(r)}return t}(),On=function(t,e,i,s){for(var r=s("pixelsPerLabel"),o=0;o<Sn.NUM_GRANULARITIES;o++){if(i/Nn(t,e,o)>=r)return o}return-1},Nn=function(t,e,i){var s=Mn[i].spacing;return Math.round(1*(e-t)/s)},Dn=function(t,e,i,s,r){var o=s("axisLabelFormatter"),a=s("labelsUTC")?el:tl,n=Mn[i].datefield,l=Mn[i].step,h=Mn[i].spacing,d=new Date(t),c=[];c[Tn]=a.getFullYear(d),c[Cn]=a.getMonth(d),c[Ln]=a.getDate(d),c[An]=a.getHours(d),c[kn]=a.getMinutes(d),c[Pn]=a.getSeconds(d),c[Rn]=a.getMilliseconds(d);var p=c[n]%l;i==Sn.WEEKLY&&(p=a.getDay(d)),c[n]-=p;for(var u=n+1;u<En;u++)c[u]=u===Ln?1:0;var g=[],f=a.makeDate.apply(null,c),m=f.getTime();if(i<=Sn.HOURLY)for(m<t&&(m+=h,f=new Date(m));m<=e;)g.push({v:m,label:o.call(r,f,i,s,r)}),m+=h,f=new Date(m);else for(m<t&&(c[n]+=l,m=(f=a.makeDate.apply(null,c)).getTime());m<=e;)(i>=Sn.DAILY||a.getHours(f)%l==0)&&g.push({v:m,label:o.call(r,f,i,s,r)}),c[n]+=l,m=(f=a.makeDate.apply(null,c)).getTime();return g},In=10,Wn=Math.log(In),Hn=function(t){return Math.log(t)/Wn},Bn=function(t,e,i){var s=Hn(t),r=s+i*(Hn(e)-s);return Math.pow(In,r)},Fn=function(t){return t.getContext("2d")},Gn=function(t,e,i){t.addEventListener(e,i,!1)};function Yn(t,e,i){t.removeEventListener(e,i,!1)}function zn(t){return(t=t||window.event).stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),t.cancelBubble=!0,t.cancel=!0,t.returnValue=!1,!1}function Un(t,e,i){var s,r,o;if(0===e)s=i,r=i,o=i;else{var a=Math.floor(6*t),n=6*t-a,l=i*(1-e),h=i*(1-e*n),d=i*(1-e*(1-n));switch(a){case 1:s=h,r=i,o=l;break;case 2:s=l,r=i,o=d;break;case 3:s=l,r=h,o=i;break;case 4:s=d,r=l,o=i;break;case 5:s=i,r=l,o=h;break;case 6:case 0:s=i,r=d,o=l}}return"rgb("+(s=Math.floor(255*s+.5))+","+(r=Math.floor(255*r+.5))+","+(o=Math.floor(255*o+.5))+")"}function $n(t){var e=t.getBoundingClientRect(),i=window,s=document.documentElement;return{x:e.left+(i.pageXOffset||s.scrollLeft),y:e.top+(i.pageYOffset||s.scrollTop)}}function jn(t){return!t.pageX||t.pageX<0?0:t.pageX}function Xn(t){return!t.pageY||t.pageY<0?0:t.pageY}function qn(t,e){return jn(t)-e.px}function Zn(t,e){return Xn(t)-e.py}function Kn(t,e){return!!t&&(null!==t.yval&&(null!==t.x&&void 0!==t.x&&(null!==t.y&&void 0!==t.y&&!(isNaN(t.x)||!e&&isNaN(t.y)))))}function Jn(t,e){var i=Math.min(Math.max(1,e||2),21);return Math.abs(t)<.001&&0!==t?t.toExponential(i-1):t.toPrecision(i)}function Qn(t){return t<10?"0"+t:""+t}var tl={getFullYear:t=>t.getFullYear(),getMonth:t=>t.getMonth(),getDate:t=>t.getDate(),getHours:t=>t.getHours(),getMinutes:t=>t.getMinutes(),getSeconds:t=>t.getSeconds(),getMilliseconds:t=>t.getMilliseconds(),getDay:t=>t.getDay(),makeDate:function(t,e,i,s,r,o,a){return new Date(t,e,i,s,r,o,a)}},el={getFullYear:t=>t.getUTCFullYear(),getMonth:t=>t.getUTCMonth(),getDate:t=>t.getUTCDate(),getHours:t=>t.getUTCHours(),getMinutes:t=>t.getUTCMinutes(),getSeconds:t=>t.getUTCSeconds(),getMilliseconds:t=>t.getUTCMilliseconds(),getDay:t=>t.getUTCDay(),makeDate:function(t,e,i,s,r,o,a){return new Date(Date.UTC(t,e,i,s,r,o,a))}};function il(t,e,i,s){var r=Qn(t)+":"+Qn(e);if(i&&(r+=":"+Qn(i),s)){var o=""+s;r+="."+("000"+o).substring(o.length)}return r}function sl(t,e){var i=e?el:tl,s=new Date(t),r=i.getFullYear(s),o=i.getMonth(s),a=i.getDate(s),n=i.getHours(s),l=i.getMinutes(s),h=i.getSeconds(s),d=i.getMilliseconds(s),c=""+r+"/"+Qn(o+1)+"/"+Qn(a);return 3600*n+60*l+h+.001*d&&(c+=" "+il(n,l,h,d)),c}function rl(t,e){var i=Math.pow(10,e);return Math.round(t*i)/i}function ol(t,e,i,s,r){if(null!=s&&null!=r||(s=0,r=e.length-1),s>r)return-1;null==i&&(i=0);var o,a=function(t){return t>=0&&t<e.length},n=parseInt((s+r)/2,10),l=e[n];return l==t?n:l>t?i>0&&a(o=n-1)&&e[o]<t?n:ol(t,e,i,s,n-1):l<t?i<0&&a(o=n+1)&&e[o]>t?n:ol(t,e,i,n+1,r):-1}function al(t){var e,i;if((-1==t.search("-")||-1!=t.search("T")||-1!=t.search("Z"))&&(i=nl(t))&&!isNaN(i))return i;if(-1!=t.search("-")){for(e=t.replace("-","/","g");-1!=e.search("-");)e=e.replace("-","/");i=nl(e)}else i=8==t.length?nl(e=t.substr(0,4)+"/"+t.substr(4,2)+"/"+t.substr(6,2)):nl(t);return i&&!isNaN(i)||console.error("Couldn't parse "+t+" as a date"),i}function nl(t){return new Date(t).getTime()}function ll(t,e){if(null!=e)for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t}function hl(t,e){function i(t){return"object"==typeof Node?t instanceof Node:"object"==typeof t&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName}if(null!=e)for(var s in e)e.hasOwnProperty(s)&&(null===e[s]?t[s]=null:dl(e[s])?t[s]=e[s].slice():i(e[s])?t[s]=e[s]:"object"==typeof e[s]?("object"==typeof t[s]&&null!==t[s]||(t[s]={}),hl(t[s],e[s])):t[s]=e[s]);return t}function dl(t){var e=typeof t;return("object"==e||"function"==e&&"function"==typeof t.item)&&null!==t&&"number"==typeof t.length&&3!==t.nodeType}function cl(t){return"object"==typeof t&&null!==t&&"function"==typeof t.getTime}function pl(t){for(var e=[],i=0;i<t.length;i++)dl(t[i])?e.push(pl(t[i])):e.push(t[i]);return e}function ul(){return document.createElement("canvas")}function gl(t){try{var e=window.devicePixelRatio,i=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1;return void 0!==e?e/i:1}catch(t){return 1}}function fl(t,e,i,s){e=e||0,i=i||t.length,this.hasNext=!0,this.peek=null,this.start_=e,this.array_=t,this.predicate_=s,this.end_=Math.min(t.length,e+i),this.nextIdx_=e-1,this.next()}function ml(t,e,i,s){return new fl(t,e,i,s)}fl.prototype.next=function(){if(!this.hasNext)return null;for(var t=this.peek,e=this.nextIdx_+1,i=!1;e<this.end_;){if(!this.predicate_||this.predicate_(this.array_,e)){this.peek=this.array_[e],i=!0;break}e++}return this.nextIdx_=e,i||(this.hasNext=!1,this.peek=null),t};var yl=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)};function xl(t,e,i,s){var r,o=0,a=(new Date).getTime();if(t(o),1!=e){var n=e-1;!function l(){o>=e||yl.call(window,(function(){var e=(new Date).getTime()-a;r=o;var h=(o=Math.floor(e/i))-r;o+h>n||o>=n?(t(n),s()):(0!==h&&t(o),l())}))}()}else s()}var vl={annotationClickHandler:!0,annotationDblClickHandler:!0,annotationMouseOutHandler:!0,annotationMouseOverHandler:!0,axisLineColor:!0,axisLineWidth:!0,clickCallback:!0,drawCallback:!0,drawHighlightPointCallback:!0,drawPoints:!0,drawPointCallback:!0,drawGrid:!0,fillAlpha:!0,gridLineColor:!0,gridLineWidth:!0,hideOverlayOnMouseOut:!0,highlightCallback:!0,highlightCircleSize:!0,interactionModel:!0,labelsDiv:!0,labelsKMB:!0,labelsKMG2:!0,labelsSeparateLines:!0,labelsShowZeroValues:!0,legend:!0,panEdgeFraction:!0,pixelsPerYLabel:!0,pointClickCallback:!0,pointSize:!0,rangeSelectorPlotFillColor:!0,rangeSelectorPlotFillGradientColor:!0,rangeSelectorPlotStrokeColor:!0,rangeSelectorBackgroundStrokeColor:!0,rangeSelectorBackgroundLineWidth:!0,rangeSelectorPlotLineWidth:!0,rangeSelectorForegroundStrokeColor:!0,rangeSelectorForegroundLineWidth:!0,rangeSelectorAlpha:!0,showLabelsOnHighlight:!0,showRoller:!0,strokeWidth:!0,underlayCallback:!0,unhighlightCallback:!0,zoomCallback:!0};var wl={DEFAULT:function(t,e,i,s,r,o,a){i.beginPath(),i.fillStyle=o,i.arc(s,r,a,0,2*Math.PI,!1),i.fill()}};function bl(t){for(var e=0;e<t.length;e++){var i=t.charAt(e);if("\r"===i)return e+1<t.length&&"\n"===t.charAt(e+1)?"\r\n":i;if("\n"===i)return e+1<t.length&&"\r"===t.charAt(e+1)?"\n\r":i}return null}function _l(t,e){if(null===e||null===t)return!1;for(var i=t;i&&i!==e;)i=i.parentNode;return i===e}function Sl(t,e){return e<0?1/Math.pow(t,-e):Math.pow(t,e)}var Tl=/^rgba?\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})(?:,\s*([01](?:\.\d+)?))?\)$/;function Cl(t){var e=Tl.exec(t);if(!e)return null;var i=parseInt(e[1],10),s=parseInt(e[2],10),r=parseInt(e[3],10);return e[4]?{r:i,g:s,b:r,a:parseFloat(e[4])}:{r:i,g:s,b:r}}function Ll(t){var e=Cl(t);if(e)return e;var i=document.createElement("div");i.style.backgroundColor=t,i.style.visibility="hidden",document.body.appendChild(i);var s=window.getComputedStyle(i,null).backgroundColor;return document.body.removeChild(i),Cl(s)}function Al(t,e,i){var s=parseFloat(t);if(!isNaN(s))return s;if(/^ *$/.test(t))return null;if(/^ *nan *$/i.test(t))return NaN;var r="Unable to parse '"+t+"' as a number";return void 0!==i&&void 0!==e&&(r+=" on line "+(1+(e||0))+" ('"+i+"') of CSV."),console.error(r),null}var kl=["K","M","B","T","Q"],Pl=["k","M","G","T","P","E","Z","Y"],Rl=["m","u","n","p","f","a","z","y"];function El(t,e){var i=e("sigFigs");if(null!==i)return Jn(t,i);var s,r=e("digitsAfterDecimal"),o=e("maxNumberWidth"),a=e("labelsKMB"),n=e("labelsKMG2");if(s=0!==t&&(Math.abs(t)>=Math.pow(10,o)||Math.abs(t)<Math.pow(10,-r))?t.toExponential(r):""+rl(t,r),a||n){var l,h=[],d=[];a&&(l=1e3,h=kl),n&&(a&&console.warn("Setting both labelsKMB and labelsKMG2. Pick one!"),l=1024,h=Pl,d=Rl);for(var c=Math.abs(t),p=Sl(l,h.length),u=h.length-1;u>=0;u--,p/=l)if(c>=p){s=rl(t/p,r)+h[u];break}if(n){var g=String(t.toExponential()).split("e-");2===g.length&&g[1]>=3&&g[1]<=24&&(s=g[1]%3>0?rl(g[0]/Sl(10,g[1]%3),r):Number(g[0]).toFixed(2),s+=d[Math.floor(g[1]/3)-1])}}return s}function Ml(t,e,i){return El.call(this,t,i)}var Vl=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ol(t,e,i){var s=i("labelsUTC")?el:tl,r=s.getFullYear(t),o=s.getMonth(t),a=s.getDate(t),n=s.getHours(t),l=s.getMinutes(t),h=s.getSeconds(t),d=s.getMilliseconds(t);if(e>=Sn.DECADAL)return""+r;if(e>=Sn.MONTHLY)return Vl[o]+"&#160;"+r;if(0===3600*n+60*l+h+.001*d||e>=Sn.DAILY)return Qn(a)+"&#160;"+Vl[o];if(e<Sn.SECONDLY){var c=""+d;return Qn(h)+"."+("000"+c).substring(c.length)}return il(n,l,h,e>Sn.MINUTELY?0:d)}function Nl(t,e){return sl(t,e("labelsUTC"))}var Dl=function(t){this.dygraph_=t,this.points=[],this.setNames=[],this.annotations=[],this.yAxes_=null,this.xTicks_=null,this.yTicks_=null};Dl.prototype.addDataset=function(t,e){this.points.push(e),this.setNames.push(t)},Dl.prototype.getPlotArea=function(){return this.area_},Dl.prototype.computePlotArea=function(){var t={x:0,y:0};t.w=this.dygraph_.width_-t.x-this.dygraph_.getOption("rightGap"),t.h=this.dygraph_.height_;var e={chart_div:this.dygraph_.graphDiv,reserveSpaceLeft:function(e){var i={x:t.x,y:t.y,w:e,h:t.h};return t.x+=e,t.w-=e,i},reserveSpaceRight:function(e){var i={x:t.x+t.w-e,y:t.y,w:e,h:t.h};return t.w-=e,i},reserveSpaceTop:function(e){var i={x:t.x,y:t.y,w:t.w,h:e};return t.y+=e,t.h-=e,i},reserveSpaceBottom:function(e){var i={x:t.x,y:t.y+t.h-e,w:t.w,h:e};return t.h-=e,i},chartRect:function(){return{x:t.x,y:t.y,w:t.w,h:t.h}}};this.dygraph_.cascadeEvents_("layout",e),this.area_=t},Dl.prototype.setAnnotations=function(t){this.annotations=[];for(var e=this.dygraph_.getOption("xValueParser")||function(t){return t},i=0;i<t.length;i++){var s={};if(!t[i].xval&&void 0===t[i].x)return void console.error("Annotations must have an 'x' property");if(t[i].icon&&(!t[i].hasOwnProperty("width")||!t[i].hasOwnProperty("height")))return void console.error("Must set width and height when setting annotation.icon property");ll(s,t[i]),s.xval||(s.xval=e(s.x)),this.annotations.push(s)}},Dl.prototype.setXTicks=function(t){this.xTicks_=t},Dl.prototype.setYAxes=function(t){this.yAxes_=t},Dl.prototype.evaluate=function(){this._xAxis={},this._evaluateLimits(),this._evaluateLineCharts(),this._evaluateLineTicks(),this._evaluateAnnotations()},Dl.prototype._evaluateLimits=function(){var t=this.dygraph_.xAxisRange();this._xAxis.minval=t[0],this._xAxis.maxval=t[1];var e=t[1]-t[0];this._xAxis.scale=0!==e?1/e:1,this.dygraph_.getOptionForAxis("logscale","x")&&(this._xAxis.xlogrange=Hn(this._xAxis.maxval)-Hn(this._xAxis.minval),this._xAxis.xlogscale=0!==this._xAxis.xlogrange?1/this._xAxis.xlogrange:1);for(var i=0;i<this.yAxes_.length;i++){var s=this.yAxes_[i];s.minyval=s.computedValueRange[0],s.maxyval=s.computedValueRange[1],s.yrange=s.maxyval-s.minyval,s.yscale=0!==s.yrange?1/s.yrange:1,this.dygraph_.getOption("logscale")&&(s.ylogrange=Hn(s.maxyval)-Hn(s.minyval),s.ylogscale=0!==s.ylogrange?1/s.ylogrange:1,isFinite(s.ylogrange)&&!isNaN(s.ylogrange)||console.error("axis "+i+" of graph at "+s.g+" can't be displayed in log scale for range ["+s.minyval+" - "+s.maxyval+"]"))}},Dl.calcXNormal_=function(t,e,i){return i?(Hn(t)-Hn(e.minval))*e.xlogscale:(t-e.minval)*e.scale},Dl.calcYNormal_=function(t,e,i){if(i){var s=1-(Hn(e)-Hn(t.minyval))*t.ylogscale;return isFinite(s)?s:NaN}return 1-(e-t.minyval)*t.yscale},Dl.prototype._evaluateLineCharts=function(){for(var t=this.dygraph_.getOption("stackedGraph"),e=this.dygraph_.getOptionForAxis("logscale","x"),i=0;i<this.points.length;i++){for(var s=this.points[i],r=this.setNames[i],o=this.dygraph_.getOption("connectSeparatedPoints",r),a=this.dygraph_.axisPropertiesForSeries(r),n=this.dygraph_.attributes_.getForSeries("logscale",r),l=0;l<s.length;l++){var h=s[l];h.x=Dl.calcXNormal_(h.xval,this._xAxis,e);var d=h.yval;t&&(h.y_stacked=Dl.calcYNormal_(a,h.yval_stacked,n),null===d||isNaN(d)||(d=h.yval_stacked)),null===d&&(d=NaN,o||(h.yval=NaN)),h.y=Dl.calcYNormal_(a,d,n)}this.dygraph_.dataHandler_.onLineEvaluated(s,a,n)}},Dl.prototype._evaluateLineTicks=function(){var t,e,i,s,r,o;for(this.xticks=[],t=0;t<this.xTicks_.length;t++)i=(e=this.xTicks_[t]).label,r=(o=!("label_v"in e))?e.v:e.label_v,(s=this.dygraph_.toPercentXCoord(r))>=0&&s<1&&this.xticks.push({pos:s,label:i,has_tick:o});for(this.yticks=[],t=0;t<this.yAxes_.length;t++)for(var a=this.yAxes_[t],n=0;n<a.ticks.length;n++)i=(e=a.ticks[n]).label,r=(o=!("label_v"in e))?e.v:e.label_v,(s=this.dygraph_.toPercentYCoord(r,t))>0&&s<=1&&this.yticks.push({axis:t,pos:s,label:i,has_tick:o})},Dl.prototype._evaluateAnnotations=function(){var t,e={};for(t=0;t<this.annotations.length;t++){var i=this.annotations[t];e[i.xval+","+i.series]=i}if(this.annotated_points=[],this.annotations&&this.annotations.length)for(var s=0;s<this.points.length;s++){var r=this.points[s];for(t=0;t<r.length;t++){var o=r[t],a=o.xval+","+o.name;a in e&&(o.annotation=e[a],this.annotated_points.push(o))}}},Dl.prototype.removeAllDatasets=function(){delete this.points,delete this.setNames,delete this.setPointsLengths,delete this.setPointsOffsets,this.points=[],this.setNames=[],this.setPointsLengths=[],this.setPointsOffsets=[]};var Il=function(t,e,i,s){if(this.dygraph_=t,this.layout=s,this.element=e,this.elementContext=i,this.height=t.height_,this.width=t.width_,!function(t){try{(t||document.createElement("canvas")).getContext("2d")}catch(t){return!1}return!0}(this.element))throw"Canvas is not supported.";this.area=s.getPlotArea();var r=this.dygraph_.canvas_ctx_;r.beginPath(),r.rect(this.area.x,this.area.y,this.area.w,this.area.h),r.clip(),(r=this.dygraph_.hidden_ctx_).beginPath(),r.rect(this.area.x,this.area.y,this.area.w,this.area.h),r.clip()};Il.prototype.clear=function(){this.elementContext.clearRect(0,0,this.width,this.height)},Il.prototype.render=function(){this._updatePoints(),this._renderLineChart()},Il._getIteratorPredicate=function(t){return t?Il._predicateThatSkipsEmptyPoints:null},Il._predicateThatSkipsEmptyPoints=function(t,e){return null!==t[e].yval},Il._drawStyledLine=function(t,e,i,s,r,o,a){var n=t.dygraph,l=n.getBooleanOption("stepPlot",t.setName);dl(s)||(s=null);var h=n.getBooleanOption("drawGapEdgePoints",t.setName),d=t.points,c=t.setName,p=ml(d,0,d.length,Il._getIteratorPredicate(n.getBooleanOption("connectSeparatedPoints",c))),u=s&&s.length>=2,g=t.drawingContext;g.save(),u&&g.setLineDash&&g.setLineDash(s);var f=Il._drawSeries(t,p,i,a,r,h,l,e);Il._drawPointsOnLine(t,f,o,e,a),u&&g.setLineDash&&g.setLineDash([]),g.restore()},Il._drawSeries=function(t,e,i,s,r,o,a,n){var l,h,d=null,c=null,p=null,u=[],g=!0,f=t.drawingContext;f.beginPath(),f.strokeStyle=n,f.lineWidth=i;for(var m=e.array_,y=e.end_,x=e.predicate_,v=e.start_;v<y;v++){if(h=m[v],x){for(;v<y&&!x(m,v);)v++;if(v==y)break;h=m[v]}if(null===h.canvasy||h.canvasy!=h.canvasy)a&&null!==d&&(f.moveTo(d,c),f.lineTo(h.canvasx,c)),d=c=null;else{if(l=!1,o||null===d){e.nextIdx_=v,e.next();var w=null===(p=e.hasNext?e.peek.canvasy:null)||p!=p;l=null===d&&w,o&&(!g&&null===d||e.hasNext&&w)&&(l=!0)}null!==d?i&&(a&&(f.moveTo(d,c),f.lineTo(h.canvasx,c)),f.lineTo(h.canvasx,h.canvasy)):f.moveTo(h.canvasx,h.canvasy),(r||l)&&u.push([h.canvasx,h.canvasy,h.idx]),d=h.canvasx,c=h.canvasy}g=!1}return f.stroke(),u},Il._drawPointsOnLine=function(t,e,i,s,r){for(var o=t.drawingContext,a=0;a<e.length;a++){var n=e[a];o.save(),i.call(t.dygraph,t.dygraph,t.setName,o,n[0],n[1],s,r,n[2]),o.restore()}},Il.prototype._updatePoints=function(){for(var t=this.layout.points,e=t.length;e--;)for(var i=t[e],s=i.length;s--;){var r=i[s];r.canvasx=this.area.w*r.x+this.area.x,r.canvasy=this.area.h*r.y+this.area.y}},Il.prototype._renderLineChart=function(t,e){var i,s,r=e||this.elementContext,o=this.layout.points,a=this.layout.setNames;this.colors=this.dygraph_.colorsMap_;var n=this.dygraph_.getOption("plotter"),l=n;dl(l)||(l=[l]);var h={};for(i=0;i<a.length;i++){s=a[i];var d=this.dygraph_.getOption("plotter",s);d!=n&&(h[s]=d)}for(i=0;i<l.length;i++)for(var c=l[i],p=i==l.length-1,u=0;u<o.length;u++)if(s=a[u],!t||s==t){var g=o[u],f=c;if(s in h){if(!p)continue;f=h[s]}var m=this.colors[s],y=this.dygraph_.getOption("strokeWidth",s);r.save(),r.strokeStyle=m,r.lineWidth=y,f({points:g,setName:s,drawingContext:r,color:m,strokeWidth:y,dygraph:this.dygraph_,axis:this.dygraph_.axisPropertiesForSeries(s),plotArea:this.area,seriesIndex:u,seriesCount:o.length,singleSeriesName:t,allSeriesPoints:o}),r.restore()}},Il._Plotters={linePlotter:function(t){Il._linePlotter(t)},fillPlotter:function(t){Il._fillPlotter(t)},errorPlotter:function(t){Il._errorPlotter(t)}},Il._linePlotter=function(t){var e=t.dygraph,i=t.setName,s=t.strokeWidth,r=e.getNumericOption("strokeBorderWidth",i),o=e.getOption("drawPointCallback",i)||wl.DEFAULT,a=e.getOption("strokePattern",i),n=e.getBooleanOption("drawPoints",i),l=e.getNumericOption("pointSize",i);r&&s&&Il._drawStyledLine(t,e.getOption("strokeBorderColor",i),s+2*r,a,n,o,l),Il._drawStyledLine(t,t.color,s,a,n,o,l)},Il._errorPlotter=function(t){var e=t.dygraph,i=t.setName;if(e.getBooleanOption("errorBars")||e.getBooleanOption("customBars")){e.getBooleanOption("fillGraph",i)&&console.warn("Can't use fillGraph option with error bars");var s,r=t.drawingContext,o=t.color,a=e.getNumericOption("fillAlpha",i),n=e.getBooleanOption("stepPlot",i),l=t.points,h=ml(l,0,l.length,Il._getIteratorPredicate(e.getBooleanOption("connectSeparatedPoints",i))),d=NaN,c=NaN,p=[-1,-1],u=Ll(o),g="rgba("+u.r+","+u.g+","+u.b+","+a+")";r.fillStyle=g,r.beginPath();for(var f=function(t){return null==t||isNaN(t)};h.hasNext;){var m=h.next();!n&&f(m.y)||n&&!isNaN(c)&&f(c)?d=NaN:(s=[m.y_bottom,m.y_top],n&&(c=m.y),isNaN(s[0])&&(s[0]=m.y),isNaN(s[1])&&(s[1]=m.y),s[0]=t.plotArea.h*s[0]+t.plotArea.y,s[1]=t.plotArea.h*s[1]+t.plotArea.y,isNaN(d)||(n?(r.moveTo(d,p[0]),r.lineTo(m.canvasx,p[0]),r.lineTo(m.canvasx,p[1])):(r.moveTo(d,p[0]),r.lineTo(m.canvasx,s[0]),r.lineTo(m.canvasx,s[1])),r.lineTo(d,p[1]),r.closePath()),p=s,d=m.canvasx)}r.fill()}},Il._fastCanvasProxy=function(t){var e=[],i=null,s=null,r=0,o=function(i){!function(t){if(!(e.length<=1)){for(var i=e.length-1;i>0;i--)if(2==(n=e[i])[0]){var s=e[i-1];s[1]==n[1]&&s[2]==n[2]&&e.splice(i,1)}for(i=0;i<e.length-1;)2==(n=e[i])[0]&&2==e[i+1][0]?e.splice(i,1):i++;if(e.length>2&&!t){var r=0;2==e[0][0]&&r++;var o=null,a=null;for(i=r;i<e.length;i++){var n;if(1==(n=e[i])[0])if(null===o&&null===a)o=i,a=i;else{var l=n[2];l<e[o][2]?o=i:l>e[a][2]&&(a=i)}}var h=e[o],d=e[a];e.splice(r,e.length-r),o<a?(e.push(h),e.push(d)):o>a?(e.push(d),e.push(h)):e.push(h)}}}(i);for(var o=0,a=e.length;o<a;o++){var n=e[o];1==n[0]?t.lineTo(n[1],n[2]):2==n[0]&&t.moveTo(n[1],n[2])}e.length&&(s=e[e.length-1][1]),r+=e.length,e=[]},a=function(t,r,a){var n=Math.round(r);null!==i&&n==i||(o(i-s>1||n-i>1),i=n);e.push([t,r,a])};return{moveTo:function(t,e){a(2,t,e)},lineTo:function(t,e){a(1,t,e)},stroke:function(){o(!0),t.stroke()},fill:function(){o(!0),t.fill()},beginPath:function(){o(!0),t.beginPath()},closePath:function(){o(!0),t.closePath()},_count:function(){return r}}},Il._fillPlotter=function(t){if(!t.singleSeriesName&&0===t.seriesIndex){for(var e=t.dygraph,i=e.getLabels().slice(1),s=i.length;s>=0;s--)e.visibility()[s]||i.splice(s,1);if(function(){for(var t=0;t<i.length;t++)if(e.getBooleanOption("fillGraph",i[t]))return!0;return!1}())for(var r,o,a,n=t.plotArea,l=t.allSeriesPoints,h=l.length,d=e.getBooleanOption("stackedGraph"),c=e.getColors(),p={},u=function(t,e,i,s){if(t.lineTo(e,i),d)for(var r=s.length-1;r>=0;r--){var o=s[r];t.lineTo(o[0],o[1])}},g=h-1;g>=0;g--){var f=t.drawingContext,m=i[g];if(e.getBooleanOption("fillGraph",m)){var y=e.getNumericOption("fillAlpha",m),x=e.getBooleanOption("stepPlot",m),v=c[g],w=e.axisPropertiesForSeries(m),b=1+w.minyval*w.yscale;b<0?b=0:b>1&&(b=1),b=n.h*b+n.y;var _,S=l[g],T=ml(S,0,S.length,Il._getIteratorPredicate(e.getBooleanOption("connectSeparatedPoints",m))),C=NaN,L=[-1,-1],A=Ll(v),k="rgba("+A.r+","+A.g+","+A.b+","+y+")";f.fillStyle=k,f.beginPath();var P,R=!0;(S.length>2*e.width_||xh.FORCE_FAST_PROXY)&&(f=Il._fastCanvasProxy(f));for(var E,M=[];T.hasNext;)if(E=T.next(),(a=E.y)&&!isNaN(a)||x){if(d){if(!R&&P==E.xval)continue;var V;R=!1,P=E.xval,V=void 0===(r=p[E.canvasx])?b:o?r[0]:r,_=[E.canvasy,V],x?-1===L[0]?p[E.canvasx]=[E.canvasy,b]:p[E.canvasx]=[E.canvasy,L[0]]:p[E.canvasx]=E.canvasy}else _=isNaN(E.canvasy)&&x?[n.y+n.h,b]:[E.canvasy,b];isNaN(C)?(f.moveTo(E.canvasx,_[1]),f.lineTo(E.canvasx,_[0])):(x?(f.lineTo(E.canvasx,L[0]),f.lineTo(E.canvasx,_[0])):f.lineTo(E.canvasx,_[0]),d&&(M.push([C,L[1]]),o&&r?M.push([E.canvasx,r[1]]):M.push([E.canvasx,_[1]]))),L=_,C=E.canvasx}else u(f,C,L[1],M),M=[],C=NaN,null===E.y_stacked||isNaN(E.y_stacked)||(p[E.canvasx]=n.h*E.y_stacked+n.y);o=x,_&&E&&(u(f,E.canvasx,_[1],M),M=[]),f.fill()}}}};var Wl={maybeTreatMouseOpAsClick:function(t,e,i){i.dragEndX=qn(t,i),i.dragEndY=Zn(t,i);var s=Math.abs(i.dragEndX-i.dragStartX),r=Math.abs(i.dragEndY-i.dragStartY);s<2&&r<2&&void 0!==e.lastx_&&-1!=e.lastx_&&Wl.treatMouseOpAsClick(e,t,i),i.regionWidth=s,i.regionHeight=r},startPan:function(t,e,i){var s,r;i.isPanning=!0;var o=e.xAxisRange();if(e.getOptionForAxis("logscale","x")?(i.initialLeftmostDate=Hn(o[0]),i.dateRange=Hn(o[1])-Hn(o[0])):(i.initialLeftmostDate=o[0],i.dateRange=o[1]-o[0]),i.xUnitsPerPixel=i.dateRange/(e.plotter_.area.w-1),e.getNumericOption("panEdgeFraction")){var a=e.width_*e.getNumericOption("panEdgeFraction"),n=e.xAxisExtremes(),l=e.toDomXCoord(n[0])-a,h=e.toDomXCoord(n[1])+a,d=e.toDataXCoord(l),c=e.toDataXCoord(h);i.boundedDates=[d,c];var p=[],u=e.height_*e.getNumericOption("panEdgeFraction");for(s=0;s<e.axes_.length;s++){var g=(r=e.axes_[s]).extremeRange,f=e.toDomYCoord(g[0],s)+u,m=e.toDomYCoord(g[1],s)-u,y=e.toDataYCoord(f,s),x=e.toDataYCoord(m,s);p[s]=[y,x]}i.boundedValues=p}for(i.is2DPan=!1,i.axes=[],s=0;s<e.axes_.length;s++){r=e.axes_[s];var v={},w=e.yAxisRange(s);e.attributes_.getForAxis("logscale",s)?(v.initialTopValue=Hn(w[1]),v.dragValueRange=Hn(w[1])-Hn(w[0])):(v.initialTopValue=w[1],v.dragValueRange=w[1]-w[0]),v.unitsPerPixel=v.dragValueRange/(e.plotter_.area.h-1),i.axes.push(v),r.valueRange&&(i.is2DPan=!0)}},movePan:function(t,e,i){i.dragEndX=qn(t,i),i.dragEndY=Zn(t,i);var s=i.initialLeftmostDate-(i.dragEndX-i.dragStartX)*i.xUnitsPerPixel;i.boundedDates&&(s=Math.max(s,i.boundedDates[0]));var r=s+i.dateRange;if(i.boundedDates&&r>i.boundedDates[1]&&(r=(s-=r-i.boundedDates[1])+i.dateRange),e.getOptionForAxis("logscale","x")?e.dateWindow_=[Math.pow(In,s),Math.pow(In,r)]:e.dateWindow_=[s,r],i.is2DPan)for(var o=i.dragEndY-i.dragStartY,a=0;a<e.axes_.length;a++){var n=e.axes_[a],l=i.axes[a],h=o*l.unitsPerPixel,d=i.boundedValues?i.boundedValues[a]:null,c=l.initialTopValue+h;d&&(c=Math.min(c,d[1]));var p=c-l.dragValueRange;d&&p<d[0]&&(p=(c-=p-d[0])-l.dragValueRange),e.attributes_.getForAxis("logscale",a)?n.valueRange=[Math.pow(In,p),Math.pow(In,c)]:n.valueRange=[p,c]}e.drawGraph_(!1)}};Wl.endPan=Wl.maybeTreatMouseOpAsClick,Wl.startZoom=function(t,e,i){i.isZooming=!0,i.zoomMoved=!1},Wl.moveZoom=function(t,e,i){i.zoomMoved=!0,i.dragEndX=qn(t,i),i.dragEndY=Zn(t,i);var s=Math.abs(i.dragStartX-i.dragEndX),r=Math.abs(i.dragStartY-i.dragEndY);i.dragDirection=s<r/2?2:1,e.drawZoomRect_(i.dragDirection,i.dragStartX,i.dragEndX,i.dragStartY,i.dragEndY,i.prevDragDirection,i.prevEndX,i.prevEndY),i.prevEndX=i.dragEndX,i.prevEndY=i.dragEndY,i.prevDragDirection=i.dragDirection},Wl.treatMouseOpAsClick=function(t,e,i){for(var s=t.getFunctionOption("clickCallback"),r=t.getFunctionOption("pointClickCallback"),o=null,a=-1,n=Number.MAX_VALUE,l=0;l<t.selPoints_.length;l++){var h=t.selPoints_[l],d=Math.pow(h.canvasx-i.dragEndX,2)+Math.pow(h.canvasy-i.dragEndY,2);!isNaN(d)&&(-1==a||d<n)&&(n=d,a=l)}var c=t.getNumericOption("highlightCircleSize")+2;if(n<=c*c&&(o=t.selPoints_[a]),o){var p={cancelable:!0,point:o,canvasx:i.dragEndX,canvasy:i.dragEndY};if(t.cascadeEvents_("pointClick",p))return;r&&r.call(t,e,o)}p={cancelable:!0,xval:t.lastx_,pts:t.selPoints_,canvasx:i.dragEndX,canvasy:i.dragEndY};t.cascadeEvents_("click",p)||s&&s.call(t,e,t.lastx_,t.selPoints_)},Wl.endZoom=function(t,e,i){e.clearZoomRect_(),i.isZooming=!1,Wl.maybeTreatMouseOpAsClick(t,e,i);var s=e.getArea();if(i.regionWidth>=10&&1==i.dragDirection){var r=Math.min(i.dragStartX,i.dragEndX),o=Math.max(i.dragStartX,i.dragEndX);(r=Math.max(r,s.x))<(o=Math.min(o,s.x+s.w))&&e.doZoomX_(r,o),i.cancelNextDblclick=!0}else if(i.regionHeight>=10&&2==i.dragDirection){var a=Math.min(i.dragStartY,i.dragEndY),n=Math.max(i.dragStartY,i.dragEndY);(a=Math.max(a,s.y))<(n=Math.min(n,s.y+s.h))&&e.doZoomY_(a,n),i.cancelNextDblclick=!0}i.dragStartX=null,i.dragStartY=null},Wl.startTouch=function(t,e,i){t.preventDefault(),t.touches.length>1&&(i.startTimeForDoubleTapMs=null);for(var s=[],r=0;r<t.touches.length;r++){var o=t.touches[r];s.push({pageX:o.pageX,pageY:o.pageY,dataX:e.toDataXCoord(o.pageX),dataY:e.toDataYCoord(o.pageY)})}if(i.initialTouches=s,1==s.length)i.initialPinchCenter=s[0],i.touchDirections={x:!0,y:!0};else if(s.length>=2){i.initialPinchCenter={pageX:.5*(s[0].pageX+s[1].pageX),pageY:.5*(s[0].pageY+s[1].pageY),dataX:.5*(s[0].dataX+s[1].dataX),dataY:.5*(s[0].dataY+s[1].dataY)};var a=180/Math.PI*Math.atan2(i.initialPinchCenter.pageY-s[0].pageY,s[0].pageX-i.initialPinchCenter.pageX);(a=Math.abs(a))>90&&(a=90-a),i.touchDirections={x:a<67.5,y:a>22.5}}i.initialRange={x:e.xAxisRange(),y:e.yAxisRange()}},Wl.moveTouch=function(t,e,i){i.startTimeForDoubleTapMs=null;var s,r=[];for(s=0;s<t.touches.length;s++){var o=t.touches[s];r.push({pageX:o.pageX,pageY:o.pageY})}var a,n,l,h=i.initialTouches,d=i.initialPinchCenter,c={pageX:(a=1==r.length?r[0]:{pageX:.5*(r[0].pageX+r[1].pageX),pageY:.5*(r[0].pageY+r[1].pageY)}).pageX-d.pageX,pageY:a.pageY-d.pageY},p=i.initialRange.x[1]-i.initialRange.x[0],u=i.initialRange.y[0]-i.initialRange.y[1];if(c.dataX=c.pageX/e.plotter_.area.w*p,c.dataY=c.pageY/e.plotter_.area.h*u,1==r.length)n=1,l=1;else if(r.length>=2){var g=h[1].pageX-d.pageX;n=(r[1].pageX-a.pageX)/g;var f=h[1].pageY-d.pageY;l=(r[1].pageY-a.pageY)/f}n=Math.min(8,Math.max(.125,n)),l=Math.min(8,Math.max(.125,l));var m=!1;if(i.touchDirections.x&&(e.dateWindow_=[d.dataX-c.dataX+(i.initialRange.x[0]-d.dataX)/n,d.dataX-c.dataX+(i.initialRange.x[1]-d.dataX)/n],m=!0),i.touchDirections.y)for(s=0;s<1;s++){var y=e.axes_[s];e.attributes_.getForAxis("logscale",s)||(y.valueRange=[d.dataY-c.dataY+(i.initialRange.y[0]-d.dataY)/l,d.dataY-c.dataY+(i.initialRange.y[1]-d.dataY)/l],m=!0)}if(e.drawGraph_(!1),m&&r.length>1&&e.getFunctionOption("zoomCallback")){var x=e.xAxisRange();e.getFunctionOption("zoomCallback").call(e,x[0],x[1],e.yAxisRanges())}},Wl.endTouch=function(t,e,i){if(0!==t.touches.length)Wl.startTouch(t,e,i);else if(1==t.changedTouches.length){var s=(new Date).getTime(),r=t.changedTouches[0];i.startTimeForDoubleTapMs&&s-i.startTimeForDoubleTapMs<500&&i.doubleTapX&&Math.abs(i.doubleTapX-r.screenX)<50&&i.doubleTapY&&Math.abs(i.doubleTapY-r.screenY)<50?e.resetZoom():(i.startTimeForDoubleTapMs=s,i.doubleTapX=r.screenX,i.doubleTapY=r.screenY)}};var Hl=function(t,e,i){return t<e?e-t:t>i?t-i:0};Wl.defaultModel={mousedown:function(t,e,i){if(!t.button||2!=t.button){i.initializeMouseDown(t,e,i),t.altKey||t.shiftKey?Wl.startPan(t,e,i):Wl.startZoom(t,e,i);var s=function(t){i.isZooming?function(t,e){var i=$n(e.canvas_),s={left:i.x,right:i.x+e.canvas_.offsetWidth,top:i.y,bottom:i.y+e.canvas_.offsetHeight},r={x:jn(t),y:Xn(t)},o=Hl(r.x,s.left,s.right),a=Hl(r.y,s.top,s.bottom);return Math.max(o,a)}(t,e)<100?Wl.moveZoom(t,e,i):null!==i.dragEndX&&(i.dragEndX=null,i.dragEndY=null,e.clearZoomRect_()):i.isPanning&&Wl.movePan(t,e,i)},r=function(t){i.isZooming?null!==i.dragEndX?Wl.endZoom(t,e,i):Wl.maybeTreatMouseOpAsClick(t,e,i):i.isPanning&&Wl.endPan(t,e,i),Yn(document,"mousemove",s),Yn(document,"mouseup",r),i.destroy()};e.addAndTrackEvent(document,"mousemove",s),e.addAndTrackEvent(document,"mouseup",r)}},willDestroyContextMyself:!0,touchstart:function(t,e,i){Wl.startTouch(t,e,i)},touchmove:function(t,e,i){Wl.moveTouch(t,e,i)},touchend:function(t,e,i){Wl.endTouch(t,e,i)},dblclick:function(t,e,i){if(i.cancelNextDblclick)i.cancelNextDblclick=!1;else{var s={canvasx:i.dragEndX,canvasy:i.dragEndY,cancelable:!0};e.cascadeEvents_("dblclick",s)||t.altKey||t.shiftKey||e.resetZoom()}}},Wl.nonInteractiveModel_={mousedown:function(t,e,i){i.initializeMouseDown(t,e,i)},mouseup:Wl.maybeTreatMouseOpAsClick},Wl.dragIsPanInteractionModel={mousedown:function(t,e,i){i.initializeMouseDown(t,e,i),Wl.startPan(t,e,i)},mousemove:function(t,e,i){i.isPanning&&Wl.movePan(t,e,i)},mouseup:function(t,e,i){i.isPanning&&Wl.endPan(t,e,i)}};var Bl={highlightCircleSize:3,highlightSeriesOpts:null,highlightSeriesBackgroundAlpha:.5,highlightSeriesBackgroundColor:"rgb(255, 255, 255)",labelsSeparateLines:!1,labelsShowZeroValues:!0,labelsKMB:!1,labelsKMG2:!1,showLabelsOnHighlight:!0,digitsAfterDecimal:2,maxNumberWidth:6,sigFigs:null,strokeWidth:1,strokeBorderWidth:0,strokeBorderColor:"white",axisTickSize:3,axisLabelFontSize:14,rightGap:5,showRoller:!1,xValueParser:void 0,delimiter:",",sigma:2,errorBars:!1,fractions:!1,wilsonInterval:!0,customBars:!1,fillGraph:!1,fillAlpha:.15,connectSeparatedPoints:!1,stackedGraph:!1,stackedGraphNaNFill:"all",hideOverlayOnMouseOut:!0,legend:"onmouseover",stepPlot:!1,xRangePad:0,yRangePad:null,drawAxesAtZero:!1,titleHeight:28,xLabelHeight:18,yLabelWidth:18,axisLineColor:"black",axisLineWidth:.3,gridLineWidth:.3,axisLabelWidth:50,gridLineColor:"rgb(128,128,128)",interactionModel:Wl.defaultModel,animatedZooms:!1,showRangeSelector:!1,rangeSelectorHeight:40,rangeSelectorPlotStrokeColor:"#808FAB",rangeSelectorPlotFillGradientColor:"white",rangeSelectorPlotFillColor:"#A7B1C4",rangeSelectorBackgroundStrokeColor:"gray",rangeSelectorBackgroundLineWidth:1,rangeSelectorPlotLineWidth:1.5,rangeSelectorForegroundStrokeColor:"black",rangeSelectorForegroundLineWidth:1,rangeSelectorAlpha:.6,showInRangeSelector:null,plotter:[Il._fillPlotter,Il._errorPlotter,Il._linePlotter],plugins:[],axes:{x:{pixelsPerLabel:70,axisLabelWidth:60,axisLabelFormatter:Ol,valueFormatter:Nl,drawGrid:!0,drawAxis:!0,independentTicks:!0,ticker:_n},y:{axisLabelWidth:50,pixelsPerLabel:30,valueFormatter:El,axisLabelFormatter:Ml,drawGrid:!0,drawAxis:!0,independentTicks:!0,ticker:bn},y2:{axisLabelWidth:50,pixelsPerLabel:30,valueFormatter:El,axisLabelFormatter:Ml,drawAxis:!0,drawGrid:!1,independentTicks:!1,ticker:bn}}},Fl=null;if("undefined"!=typeof process&&"production"!=process.env.NODE_ENV){Fl={xValueParser:{default:"parseFloat() or Date.parse()*",labels:["CSV parsing"],type:"function(str) -> number",description:"A function which parses x-values (i.e. the dependent series). Must return a number, even when the values are dates. In this case, millis since epoch are used. This is used primarily for parsing CSV data. *=Dygraphs is slightly more accepting in the dates which it will parse. See code for details."},stackedGraph:{default:"false",labels:["Data Line display"],type:"boolean",description:"If set, stack series on top of one another rather than drawing them independently. The first series specified in the input data will wind up on top of the chart and the last will be on bottom. NaN values are drawn as white areas without a line on top, see stackedGraphNaNFill for details."},stackedGraphNaNFill:{default:"all",labels:["Data Line display"],type:"string",description:'Controls handling of NaN values inside a stacked graph. NaN values are interpolated/extended for stacking purposes, but the actual point value remains NaN in the legend display. Valid option values are "all" (interpolate internally, repeat leftmost and rightmost value as needed), "inside" (interpolate internally only, use zero outside leftmost and rightmost value), and "none" (treat NaN as zero everywhere).'},pointSize:{default:"1",labels:["Data Line display"],type:"integer",description:'The size of the dot to draw on each point in pixels (see drawPoints). A dot is always drawn when a point is "isolated", i.e. there is a missing point on either side of it. This also controls the size of those dots.'},drawPoints:{default:"false",labels:["Data Line display"],type:"boolean",description:"Draw a small dot at each point, in addition to a line going through the point. This makes the individual data points easier to see, but can increase visual clutter in the chart. The small dot can be replaced with a custom rendering by supplying a <a href='#drawPointCallback'>drawPointCallback</a>."},drawGapEdgePoints:{default:"false",labels:["Data Line display"],type:"boolean",description:"Draw points at the edges of gaps in the data. This improves visibility of small data segments or other data irregularities."},drawPointCallback:{default:"null",labels:["Data Line display"],type:"function(g, seriesName, canvasContext, cx, cy, color, pointSize)",parameters:[["g","the reference graph"],["seriesName","the name of the series"],["canvasContext","the canvas to draw on"],["cx","center x coordinate"],["cy","center y coordinate"],["color","series color"],["pointSize","the radius of the image."],["idx","the row-index of the point in the data."]],description:"Draw a custom item when drawPoints is enabled. Default is a small dot matching the series color. This method should constrain drawing to within pointSize pixels from (cx, cy). Also see <a href='#drawHighlightPointCallback'>drawHighlightPointCallback</a>"},height:{default:"320",labels:["Overall display"],type:"integer",description:"Height, in pixels, of the chart. If the container div has been explicitly sized, this will be ignored."},zoomCallback:{default:"null",labels:["Callbacks"],type:"function(minDate, maxDate, yRanges)",parameters:[["minDate","milliseconds since epoch"],["maxDate","milliseconds since epoch."],["yRanges","is an array of [bottom, top] pairs, one for each y-axis."]],description:"A function to call when the zoom window is changed (either by zooming in or out). When animatedZooms is set, zoomCallback is called once at the end of the transition (it will not be called for intermediate frames)."},pointClickCallback:{snippet:"function(e, point){<br>&nbsp;&nbsp;alert(point);<br>}",default:"null",labels:["Callbacks","Interactive Elements"],type:"function(e, point)",parameters:[["e","the event object for the click"],["point","the point that was clicked See <a href='#point_properties'>Point properties</a> for details"]],description:"A function to call when a data point is clicked. and the point that was clicked."},color:{default:"(see description)",labels:["Data Series Colors"],type:"string",example:"red",description:"A per-series color definition. Used in conjunction with, and overrides, the colors option."},colors:{default:"(see description)",labels:["Data Series Colors"],type:"array<string>",example:"['red', '#00FF00']",description:'List of colors for the data series. These can be of the form "#AABBCC" or "rgb(255,100,200)" or "yellow", etc. If not specified, equally-spaced points around a color wheel are used. Overridden by the \'color\' option.'},connectSeparatedPoints:{default:"false",labels:["Data Line display"],type:"boolean",description:"Usually, when Dygraphs encounters a missing value in a data series, it interprets this as a gap and draws it as such. If, instead, the missing values represents an x-value for which only a different series has data, then you'll want to connect the dots by setting this to true. To explicitly include a gap with this option set, use a value of NaN."},highlightCallback:{default:"null",labels:["Callbacks"],type:"function(event, x, points, row, seriesName)",description:"When set, this callback gets called every time a new point is highlighted.",parameters:[["event","the JavaScript mousemove event"],["x","the x-coordinate of the highlighted points"],["points","an array of highlighted points: <code>[ {name: 'series', yval: y-value}, &hellip; ]</code>"],["row","integer index of the highlighted row in the data table, starting from 0"],["seriesName","name of the highlighted series, only present if highlightSeriesOpts is set."]]},drawHighlightPointCallback:{default:"null",labels:["Data Line display"],type:"function(g, seriesName, canvasContext, cx, cy, color, pointSize)",parameters:[["g","the reference graph"],["seriesName","the name of the series"],["canvasContext","the canvas to draw on"],["cx","center x coordinate"],["cy","center y coordinate"],["color","series color"],["pointSize","the radius of the image."],["idx","the row-index of the point in the data."]],description:"Draw a custom item when a point is highlighted. Default is a small dot matching the series color. This method should constrain drawing to within pointSize pixels from (cx, cy) Also see <a href='#drawPointCallback'>drawPointCallback</a>"},highlightSeriesOpts:{default:"null",labels:["Interactive Elements"],type:"Object",description:"When set, the options from this object are applied to the timeseries closest to the mouse pointer for interactive highlighting. See also 'highlightCallback'. Example: highlightSeriesOpts: { strokeWidth: 3 }."},highlightSeriesBackgroundAlpha:{default:"0.5",labels:["Interactive Elements"],type:"float",description:"Fade the background while highlighting series. 1=fully visible background (disable fading), 0=hiddden background (show highlighted series only)."},highlightSeriesBackgroundColor:{default:"rgb(255, 255, 255)",labels:["Interactive Elements"],type:"string",description:"Sets the background color used to fade out the series in conjunction with 'highlightSeriesBackgroundAlpha'."},includeZero:{default:"false",labels:["Axis display"],type:"boolean",description:"Usually, dygraphs will use the range of the data plus some padding to set the range of the y-axis. If this option is set, the y-axis will always include zero, typically as the lowest value. This can be used to avoid exaggerating the variance in the data"},rollPeriod:{default:"1",labels:["Error Bars","Rolling Averages"],type:"integer &gt;= 1",description:"Number of days over which to average data. Discussed extensively above."},unhighlightCallback:{default:"null",labels:["Callbacks"],type:"function(event)",parameters:[["event","the mouse event"]],description:"When set, this callback gets called every time the user stops highlighting any point by mousing out of the graph."},axisTickSize:{default:"3.0",labels:["Axis display"],type:"number",description:"The size of the line to display next to each tick mark on x- or y-axes."},labelsSeparateLines:{default:"false",labels:["Legend"],type:"boolean",description:"Put <code>&lt;br/&gt;</code> between lines in the label string. Often used in conjunction with <strong>labelsDiv</strong>."},valueFormatter:{default:"Depends on the type of your data.",labels:["Legend","Value display/formatting"],type:"function(num or millis, opts, seriesName, dygraph, row, col)",description:"Function to provide a custom display format for the values displayed on mouseover. This does not affect the values that appear on tick marks next to the axes. To format those, see axisLabelFormatter. This is usually set on a <a href='per-axis.html'>per-axis</a> basis. .",parameters:[["num_or_millis","The value to be formatted. This is always a number. For date axes, it's millis since epoch. You can call new Date(millis) to get a Date object."],["opts","This is a function you can call to access various options (e.g. opts('labelsKMB')). It returns per-axis values for the option when available."],["seriesName","The name of the series from which the point came, e.g. 'X', 'Y', 'A', etc."],["dygraph","The dygraph object for which the formatting is being done"],["row","The row of the data from which this point comes. g.getValue(row, 0) will return the x-value for this point."],["col","The column of the data from which this point comes. g.getValue(row, col) will return the original y-value for this point. This can be used to get the full confidence interval for the point, or access un-rolled values for the point."]]},annotationMouseOverHandler:{default:"null",labels:["Annotations"],type:"function(annotation, point, dygraph, event)",description:"If provided, this function is called whenever the user mouses over an annotation."},annotationMouseOutHandler:{default:"null",labels:["Annotations"],type:"function(annotation, point, dygraph, event)",parameters:[["annotation","the annotation left"],["point","the point associated with the annotation"],["dygraph","the reference graph"],["event","the mouse event"]],description:"If provided, this function is called whenever the user mouses out of an annotation."},annotationClickHandler:{default:"null",labels:["Annotations"],type:"function(annotation, point, dygraph, event)",parameters:[["annotation","the annotation left"],["point","the point associated with the annotation"],["dygraph","the reference graph"],["event","the mouse event"]],description:"If provided, this function is called whenever the user clicks on an annotation."},annotationDblClickHandler:{default:"null",labels:["Annotations"],type:"function(annotation, point, dygraph, event)",parameters:[["annotation","the annotation left"],["point","the point associated with the annotation"],["dygraph","the reference graph"],["event","the mouse event"]],description:"If provided, this function is called whenever the user double-clicks on an annotation."},drawCallback:{default:"null",labels:["Callbacks"],type:"function(dygraph, is_initial)",parameters:[["dygraph","The graph being drawn"],["is_initial","True if this is the initial draw, false for subsequent draws."]],description:"When set, this callback gets called every time the dygraph is drawn. This includes the initial draw, after zooming and repeatedly while panning."},labelsKMG2:{default:"false",labels:["Value display/formatting"],type:"boolean",description:"Show k/M/G for kilo/Mega/Giga on y-axis. This is different than <code>labelsKMB</code> in that it uses base 2, not 10."},delimiter:{default:",",labels:["CSV parsing"],type:"string",description:"The delimiter to look for when separating fields of a CSV file. Setting this to a tab is not usually necessary, since tab-delimited data is auto-detected."},axisLabelFontSize:{default:"14",labels:["Axis display"],type:"integer",description:"Size of the font (in pixels) to use in the axis labels, both x- and y-axis."},underlayCallback:{default:"null",labels:["Callbacks"],type:"function(context, area, dygraph)",parameters:[["context","the canvas drawing context on which to draw"],["area","An object with {x,y,w,h} properties describing the drawing area."],["dygraph","the reference graph"]],description:"When set, this callback gets called before the chart is drawn. It details on how to use this."},width:{default:"480",labels:["Overall display"],type:"integer",description:"Width, in pixels, of the chart. If the container div has been explicitly sized, this will be ignored."},pixelRatio:{default:"(devicePixelRatio / context.backingStoreRatio)",labels:["Overall display"],type:"float",description:"Overrides the pixel ratio scaling factor for the canvas's 2d context. Ordinarily, this is set to the devicePixelRatio / (context.backingStoreRatio || 1), so on mobile devices, where the devicePixelRatio can be somewhere around 3, performance can be improved by overriding this value to something less precise, like 1, at the expense of resolution."},interactionModel:{default:"...",labels:["Interactive Elements"],type:"Object",description:"TODO(konigsberg): document this"},ticker:{default:"Dygraph.dateTicker or Dygraph.numericTicks",labels:["Axis display"],type:"function(min, max, pixels, opts, dygraph, vals) -> [{v: ..., label: ...}, ...]",parameters:[["min",""],["max",""],["pixels",""],["opts",""],["dygraph","the reference graph"],["vals",""]],description:"This lets you specify an arbitrary function to generate tick marks on an axis. The tick marks are an array of (value, label) pairs. The built-in functions go to great lengths to choose good tick marks so, if you set this option, you'll most likely want to call one of them and modify the result. See dygraph-tickers.js for an extensive discussion. This is set on a <a href='per-axis.html'>per-axis</a> basis."},xAxisHeight:{default:"(null)",labels:["Axis display"],type:"integer",description:"Height, in pixels, of the x-axis. If not set explicitly, this is computed based on axisLabelFontSize and axisTickSize."},showLabelsOnHighlight:{default:"true",labels:["Interactive Elements","Legend"],type:"boolean",description:"Whether to show the legend upon mouseover."},axis:{default:"(none)",labels:["Axis display"],type:"string",description:"Set to either 'y1' or 'y2' to assign a series to a y-axis (primary or secondary). Must be set per-series."},pixelsPerLabel:{default:"70 (x-axis) or 30 (y-axes)",labels:["Axis display","Grid"],type:"integer",description:"Number of pixels to require between each x- and y-label. Larger values will yield a sparser axis with fewer ticks. This is set on a <a href='per-axis.html'>per-axis</a> basis."},labelsDiv:{default:"null",labels:["Legend"],type:"DOM element or string",example:"<code style='font-size: small'>document.getElementById('foo')</code>or<code>'foo'",description:"Show data labels in an external div, rather than on the graph. This value can either be a div element or a div id."},fractions:{default:"false",labels:["CSV parsing","Error Bars"],type:"boolean",description:'When set, attempt to parse each cell in the CSV file as "a/b", where a and b are integers. The ratio will be plotted. This allows computation of Wilson confidence intervals (see below).'},logscale:{default:"false",labels:["Axis display"],type:"boolean",description:"When set for the y-axis or x-axis, the graph shows that axis in log scale. Any values less than or equal to zero are not displayed. Showing log scale with ranges that go below zero will result in an unviewable graph.\n\n Not compatible with showZero. connectSeparatedPoints is ignored. This is ignored for date-based x-axes."},strokeWidth:{default:"1.0",labels:["Data Line display"],type:"float",example:"0.5, 2.0",description:"The width of the lines connecting data points. This can be used to increase the contrast or some graphs."},strokePattern:{default:"null",labels:["Data Line display"],type:"array<integer>",example:"[10, 2, 5, 2]",description:"A custom pattern array where the even index is a draw and odd is a space in pixels. If null then it draws a solid line. The array should have a even length as any odd lengthed array could be expressed as a smaller even length array. This is used to create dashed lines."},strokeBorderWidth:{default:"null",labels:["Data Line display"],type:"float",example:"1.0",description:"Draw a border around graph lines to make crossing lines more easily distinguishable. Useful for graphs with many lines."},strokeBorderColor:{default:"white",labels:["Data Line display"],type:"string",example:"red, #ccffdd",description:"Color for the line border used if strokeBorderWidth is set."},wilsonInterval:{default:"true",labels:["Error Bars"],type:"boolean",description:'Use in conjunction with the "fractions" option. Instead of plotting +/- N standard deviations, dygraphs will compute a Wilson confidence interval and plot that. This has more reasonable behavior for ratios close to 0 or 1.'},fillGraph:{default:"false",labels:["Data Line display"],type:"boolean",description:"Should the area underneath the graph be filled? This option is not compatible with error bars. This may be set on a <a href='per-axis.html'>per-series</a> basis."},highlightCircleSize:{default:"3",labels:["Interactive Elements"],type:"integer",description:"The size in pixels of the dot drawn over highlighted points."},gridLineColor:{default:"rgb(128,128,128)",labels:["Grid"],type:"red, blue",description:"The color of the gridlines. This may be set on a per-axis basis to define each axis' grid separately."},gridLinePattern:{default:"null",labels:["Grid"],type:"array<integer>",example:"[10, 2, 5, 2]",description:"A custom pattern array where the even index is a draw and odd is a space in pixels. If null then it draws a solid line. The array should have a even length as any odd lengthed array could be expressed as a smaller even length array. This is used to create dashed gridlines."},visibility:{default:"[true, true, ...]",labels:["Data Line display"],type:"Array of booleans",description:"Which series should initially be visible? Once the Dygraph has been constructed, you can access and modify the visibility of each series using the <code>visibility</code> and <code>setVisibility</code> methods."},valueRange:{default:"Full range of the input is shown",labels:["Axis display"],type:"Array of two numbers",example:"[10, 110]",description:"Explicitly set the vertical range of the graph to [low, high]. This may be set on a per-axis basis to define each y-axis separately. If either limit is unspecified, it will be calculated automatically (e.g. [null, 30] to automatically calculate just the lower bound)"},colorSaturation:{default:"1.0",labels:["Data Series Colors"],type:"float (0.0 - 1.0)",description:"If <strong>colors</strong> is not specified, saturation of the automatically-generated data series colors."},hideOverlayOnMouseOut:{default:"true",labels:["Interactive Elements","Legend"],type:"boolean",description:"Whether to hide the legend when the mouse leaves the chart area."},legend:{default:"onmouseover",labels:["Legend"],type:"string",description:'When to display the legend. By default, it only appears when a user mouses over the chart. Set it to "always" to always display a legend of some sort. When set to "follow", legend follows highlighted points.'},legendFormatter:{default:"null",labels:["Legend"],type:"function(data): string",params:[["data",'An object containing information about the selection (or lack of a selection). This includes formatted values and series information. See <a href="https://github.com/danvk/dygraphs/pull/683">here</a> for sample values.']],description:'Set this to supply a custom formatter for the legend. See <a href="https://github.com/danvk/dygraphs/pull/683">this comment</a> and the <a href="tests/legend-formatter.html">legendFormatter demo</a> for usage.'},labelsShowZeroValues:{default:"true",labels:["Legend"],type:"boolean",description:"Show zero value labels in the labelsDiv."},stepPlot:{default:"false",labels:["Data Line display"],type:"boolean",description:"When set, display the graph as a step plot instead of a line plot. This option may either be set for the whole graph or for single series."},labelsUTC:{default:"false",labels:["Value display/formatting","Axis display"],type:"boolean",description:"Show date/time labels according to UTC (instead of local time)."},labelsKMB:{default:"false",labels:["Value display/formatting"],type:"boolean",description:"Show K/M/B for thousands/millions/billions on y-axis."},rightGap:{default:"5",labels:["Overall display"],type:"integer",description:"Number of pixels to leave blank at the right edge of the Dygraph. This makes it easier to highlight the right-most data point."},drawAxesAtZero:{default:"false",labels:["Axis display"],type:"boolean",description:"When set, draw the X axis at the Y=0 position and the Y axis at the X=0 position if those positions are inside the graph's visible area. Otherwise, draw the axes at the bottom or left graph edge as usual."},xRangePad:{default:"0",labels:["Axis display"],type:"float",description:"Add the specified amount of extra space (in pixels) around the X-axis value range to ensure points at the edges remain visible."},yRangePad:{default:"null",labels:["Axis display"],type:"float",description:"If set, add the specified amount of extra space (in pixels) around the Y-axis value range to ensure points at the edges remain visible. If unset, use the traditional Y padding algorithm."},axisLabelFormatter:{default:"Depends on the data type",labels:["Axis display"],type:"function(number or Date, granularity, opts, dygraph)",parameters:[["number or date","Either a number (for a numeric axis) or a Date object (for a date axis)"],["granularity","specifies how fine-grained the axis is. For date axes, this is a reference to the time granularity enumeration, defined in dygraph-tickers.js, e.g. Dygraph.WEEKLY."],["opts","a function which provides access to various options on the dygraph, e.g. opts('labelsKMB')."],["dygraph","the referenced graph"]],description:"Function to call to format the tick values that appear along an axis. This is usually set on a <a href='per-axis.html'>per-axis</a> basis."},clickCallback:{snippet:"function(e, date_millis){<br>&nbsp;&nbsp;alert(new Date(date_millis));<br>}",default:"null",labels:["Callbacks"],type:"function(e, x, points)",parameters:[["e","The event object for the click"],["x","The x value that was clicked (for dates, this is milliseconds since epoch)"],["points","The closest points along that date. See <a href='#point_properties'>Point properties</a> for details."]],description:"A function to call when the canvas is clicked."},labels:{default:'["X", "Y1", "Y2", ...]*',labels:["Legend"],type:"array<string>",description:"A name for each data series, including the independent (X) series. For CSV files and DataTable objections, this is determined by context. For raw data, this must be specified. If it is not, default values are supplied and a warning is logged."},dateWindow:{default:"Full range of the input is shown",labels:["Axis display"],type:"Array of two numbers",example:"[<br>&nbsp;&nbsp;Date.parse('2006-01-01'),<br>&nbsp;&nbsp;(new Date()).valueOf()<br>]",description:"Initially zoom in on a section of the graph. Is of the form [earliest, latest], where earliest/latest are milliseconds since epoch. If the data for the x-axis is numeric, the values in dateWindow must also be numbers."},showRoller:{default:"false",labels:["Interactive Elements","Rolling Averages"],type:"boolean",description:"If the rolling average period text box should be shown."},sigma:{default:"2.0",labels:["Error Bars"],type:"float",description:"When errorBars is set, shade this many standard deviations above/below each point."},customBars:{default:"false",labels:["CSV parsing","Error Bars"],type:"boolean",description:'When set, parse each CSV cell as "low;middle;high". Error bars will be drawn for each point between low and high, with the series itself going through middle.'},colorValue:{default:"1.0",labels:["Data Series Colors"],type:"float (0.0 - 1.0)",description:"If colors is not specified, value of the data series colors, as in hue/saturation/value. (0.0-1.0, default 0.5)"},errorBars:{default:"false",labels:["CSV parsing","Error Bars"],type:"boolean",description:"Does the data contain standard deviations? Setting this to true alters the input format (see above)."},displayAnnotations:{default:"false",labels:["Annotations"],type:"boolean",description:"Only applies when Dygraphs is used as a GViz chart. Causes string columns following a data series to be interpreted as annotations on points in that series. This is the same format used by Google's AnnotatedTimeLine chart."},panEdgeFraction:{default:"null",labels:["Axis display","Interactive Elements"],type:"float",description:"A value representing the farthest a graph may be panned, in percent of the display. For example, a value of 0.1 means that the graph can only be panned 10% passed the edges of the displayed values. null means no bounds."},title:{labels:["Chart labels"],type:"string",default:"null",description:"Text to display above the chart. You can supply any HTML for this value, not just text. If you wish to style it using CSS, use the 'dygraph-label' or 'dygraph-title' classes."},titleHeight:{default:"18",labels:["Chart labels"],type:"integer",description:"Height of the chart title, in pixels. This also controls the default font size of the title. If you style the title on your own, this controls how much space is set aside above the chart for the title's div."},xlabel:{labels:["Chart labels"],type:"string",default:"null",description:"Text to display below the chart's x-axis. You can supply any HTML for this value, not just text. If you wish to style it using CSS, use the 'dygraph-label' or 'dygraph-xlabel' classes."},xLabelHeight:{labels:["Chart labels"],type:"integer",default:"18",description:"Height of the x-axis label, in pixels. This also controls the default font size of the x-axis label. If you style the label on your own, this controls how much space is set aside below the chart for the x-axis label's div."},ylabel:{labels:["Chart labels"],type:"string",default:"null",description:"Text to display to the left of the chart's y-axis. You can supply any HTML for this value, not just text. If you wish to style it using CSS, use the 'dygraph-label' or 'dygraph-ylabel' classes. The text will be rotated 90 degrees by default, so CSS rules may behave in unintuitive ways. No additional space is set aside for a y-axis label. If you need more space, increase the width of the y-axis tick labels using the yAxisLabelWidth option. If you need a wider div for the y-axis label, either style it that way with CSS (but remember that it's rotated, so width is controlled by the 'height' property) or set the yLabelWidth option."},y2label:{labels:["Chart labels"],type:"string",default:"null",description:"Text to display to the right of the chart's secondary y-axis. This label is only displayed if a secondary y-axis is present. See <a href='http://dygraphs.com/tests/two-axes.html'>this test</a> for an example of how to do this. The comments for the 'ylabel' option generally apply here as well. This label gets a 'dygraph-y2label' instead of a 'dygraph-ylabel' class."},yLabelWidth:{labels:["Chart labels"],type:"integer",default:"18",description:"Width of the div which contains the y-axis label. Since the y-axis label appears rotated 90 degrees, this actually affects the height of its div."},drawGrid:{default:"true for x and y, false for y2",labels:["Grid"],type:"boolean",description:"Whether to display gridlines in the chart. This may be set on a per-axis basis to define the visibility of each axis' grid separately."},independentTicks:{default:"true for y, false for y2",labels:["Axis display","Grid"],type:"boolean",description:"Only valid for y and y2, has no effect on x: This option defines whether the y axes should align their ticks or if they should be independent. Possible combinations: 1.) y=true, y2=false (default): y is the primary axis and the y2 ticks are aligned to the the ones of y. (only 1 grid) 2.) y=false, y2=true: y2 is the primary axis and the y ticks are aligned to the the ones of y2. (only 1 grid) 3.) y=true, y2=true: Both axis are independent and have their own ticks. (2 grids) 4.) y=false, y2=false: Invalid configuration causes an error."},drawAxis:{default:"true for x and y, false for y2",labels:["Axis display"],type:"boolean",description:"Whether to draw the specified axis. This may be set on a per-axis basis to define the visibility of each axis separately. Setting this to false also prevents axis ticks from being drawn and reclaims the space for the chart grid/lines."},gridLineWidth:{default:"0.3",labels:["Grid"],type:"float",description:"Thickness (in pixels) of the gridlines drawn under the chart. The vertical/horizontal gridlines can be turned off entirely by using the drawGrid option. This may be set on a per-axis basis to define each axis' grid separately."},axisLineWidth:{default:"0.3",labels:["Axis display"],type:"float",description:"Thickness (in pixels) of the x- and y-axis lines."},axisLineColor:{default:"black",labels:["Axis display"],type:"string",description:"Color of the x- and y-axis lines. Accepts any value which the HTML canvas strokeStyle attribute understands, e.g. 'black' or 'rgb(0, 100, 255)'."},fillAlpha:{default:"0.15",labels:["Error Bars","Data Series Colors"],type:"float (0.0 - 1.0)",description:"Error bars (or custom bars) for each series are drawn in the same color as the series, but with partial transparency. This sets the transparency. A value of 0.0 means that the error bars will not be drawn, whereas a value of 1.0 means that the error bars will be as dark as the line for the series itself. This can be used to produce chart lines whose thickness varies at each point."},axisLabelWidth:{default:"50 (y-axis), 60 (x-axis)",labels:["Axis display","Chart labels"],type:"integer",description:"Width (in pixels) of the containing divs for x- and y-axis labels. For the y-axis, this also controls the width of the y-axis. Note that for the x-axis, this is independent from pixelsPerLabel, which controls the spacing between labels."},sigFigs:{default:"null",labels:["Value display/formatting"],type:"integer",description:"By default, dygraphs displays numbers with a fixed number of digits after the decimal point. If you'd prefer to have a fixed number of significant figures, set this option to that number of sig figs. A value of 2, for instance, would cause 1 to be display as 1.0 and 1234 to be displayed as 1.23e+3."},digitsAfterDecimal:{default:"2",labels:["Value display/formatting"],type:"integer",description:"Unless it's run in scientific mode (see the <code>sigFigs</code> option), dygraphs displays numbers with <code>digitsAfterDecimal</code> digits after the decimal point. Trailing zeros are not displayed, so with a value of 2 you'll get '0', '0.1', '0.12', '123.45' but not '123.456' (it will be rounded to '123.46'). Numbers with absolute value less than 0.1^digitsAfterDecimal (i.e. those which would show up as '0.00') will be displayed in scientific notation."},maxNumberWidth:{default:"6",labels:["Value display/formatting"],type:"integer",description:"When displaying numbers in normal (not scientific) mode, large numbers will be displayed with many trailing zeros (e.g. 100000000 instead of 1e9). This can lead to unwieldy y-axis labels. If there are more than <code>maxNumberWidth</code> digits to the left of the decimal in a number, dygraphs will switch to scientific notation, even when not operating in scientific mode. If you'd like to see all those digits, set this to something large, like 20 or 30."},file:{default:"(set when constructed)",labels:["Data"],type:"string (URL of CSV or CSV), GViz DataTable or 2D Array",description:"Sets the data being displayed in the chart. This can only be set when calling updateOptions; it cannot be set from the constructor. For a full description of valid data formats, see the <a href='http://dygraphs.com/data.html'>Data Formats</a> page."},timingName:{default:"null",labels:["Debugging","Deprecated"],type:"string",description:"Set this option to log timing information. The value of the option will be logged along with the timimg, so that you can distinguish multiple dygraphs on the same page."},showRangeSelector:{default:"false",labels:["Range Selector"],type:"boolean",description:"Show or hide the range selector widget."},rangeSelectorHeight:{default:"40",labels:["Range Selector"],type:"integer",description:"Height, in pixels, of the range selector widget. This option can only be specified at Dygraph creation time."},rangeSelectorPlotStrokeColor:{default:"#808FAB",labels:["Range Selector"],type:"string",description:'The range selector mini plot stroke color. This can be of the form "#AABBCC" or "rgb(255,100,200)" or "yellow". You can also specify null or "" to turn off stroke.'},rangeSelectorPlotFillColor:{default:"#A7B1C4",labels:["Range Selector"],type:"string",description:'The range selector mini plot fill color. This can be of the form "#AABBCC" or "rgb(255,100,200)" or "yellow". You can also specify null or "" to turn off fill.'},rangeSelectorPlotFillGradientColor:{default:"white",labels:["Range Selector"],type:"string",description:'The top color for the range selector mini plot fill color gradient. This can be of the form "#AABBCC" or "rgb(255,100,200)" or "rgba(255,100,200,42)" or "yellow". You can also specify null or "" to disable the gradient and fill with one single color.'},rangeSelectorBackgroundStrokeColor:{default:"gray",labels:["Range Selector"],type:"string",description:'The color of the lines below and on both sides of the range selector mini plot. This can be of the form "#AABBCC" or "rgb(255,100,200)" or "yellow".'},rangeSelectorBackgroundLineWidth:{default:"1",labels:["Range Selector"],type:"float",description:"The width of the lines below and on both sides of the range selector mini plot."},rangeSelectorPlotLineWidth:{default:"1.5",labels:["Range Selector"],type:"float",description:"The width of the range selector mini plot line."},rangeSelectorForegroundStrokeColor:{default:"black",labels:["Range Selector"],type:"string",description:'The color of the lines in the interactive layer of the range selector. This can be of the form "#AABBCC" or "rgb(255,100,200)" or "yellow".'},rangeSelectorForegroundLineWidth:{default:"1",labels:["Range Selector"],type:"float",description:"The width the lines in the interactive layer of the range selector."},rangeSelectorAlpha:{default:"0.6",labels:["Range Selector"],type:"float (0.0 - 1.0)",description:"The transparency of the veil that is drawn over the unselected portions of the range selector mini plot. A value of 0 represents full transparency and the unselected portions of the mini plot will appear as normal. A value of 1 represents full opacity and the unselected portions of the mini plot will be hidden."},showInRangeSelector:{default:"null",labels:["Range Selector"],type:"boolean",description:"Mark this series for inclusion in the range selector. The mini plot curve will be an average of all such series. If this is not specified for any series, the default behavior is to average all the visible series. Setting it for one series will result in that series being charted alone in the range selector. Once it's set for a single series, it needs to be set for all series which should be included (regardless of visibility)."},animatedZooms:{default:"false",labels:["Interactive Elements"],type:"boolean",description:"Set this option to animate the transition between zoom windows. Applies to programmatic and interactive zooms. Note that if you also set a drawCallback, it will be called several times on each zoom. If you set a zoomCallback, it will only be called after the animation is complete."},plotter:{default:"[DygraphCanvasRenderer.Plotters.fillPlotter, DygraphCanvasRenderer.Plotters.errorPlotter, DygraphCanvasRenderer.Plotters.linePlotter]",labels:["Data Line display"],type:"array or function",description:"A function (or array of functions) which plot each data series on the chart. TODO(danvk): more details! May be set per-series."},axes:{default:"null",labels:["Configuration"],type:"Object",description:"Defines per-axis options. Valid keys are 'x', 'y' and 'y2'. Only some options may be set on a per-axis basis. If an option may be set in this way, it will be noted on this page. See also documentation on <a href='http://dygraphs.com/per-axis.html'>per-series and per-axis options</a>."},series:{default:"null",labels:["Series"],type:"Object",description:"Defines per-series options. Its keys match the y-axis label names, and the values are dictionaries themselves that contain options specific to that series."},plugins:{default:"[]",labels:["Configuration"],type:"Array<plugin>",description:"Defines per-graph plugins. Useful for per-graph customization"},dataHandler:{default:"(depends on data)",labels:["Data"],type:"Dygraph.DataHandler",description:"Custom DataHandler. This is an advanced customization. See http://bit.ly/151E7Aq."}};var Gl,Yl=function(t){window.console&&window.console.warn(t)},zl=["type","default","description"],Ul=["Annotations","Axis display","Chart labels","CSV parsing","Callbacks","Data","Data Line display","Data Series Colors","Error Bars","Grid","Interactive Elements","Range Selector","Legend","Overall display","Rolling Averages","Series","Value display/formatting","Zooming","Debugging","Configuration","Deprecated"],$l={};for(Gl=0;Gl<Ul.length;Gl++)$l[Ul[Gl]]=!0;for(var jl in Fl)if(Fl.hasOwnProperty(jl)){var Xl=Fl[jl];for(Gl=0;Gl<zl.length;Gl++)Xl.hasOwnProperty(zl[Gl])?"string"!=typeof Xl[zl[Gl]]&&Yl(jl+"."+zl[Gl]+" must be of type string"):Yl("Option "+jl+' missing "'+zl[Gl]+'" property');var ql=Xl.labels;if("object"!=typeof ql)Yl('Option "'+jl+'" is missing a "labels": [...] option');else for(Gl=0;Gl<ql.length;Gl++)$l.hasOwnProperty(ql[Gl])||Yl('Option "'+jl+'" has label "'+ql[Gl]+'", which is invalid.')}}var Zl=Fl,Kl=function(t){this.dygraph_=t,this.yAxes_=[],this.xAxis_={},this.series_={},this.global_=this.dygraph_.attrs_,this.user_=this.dygraph_.user_attrs_||{},this.labels_=[],this.highlightSeries_=this.get("highlightSeriesOpts")||{},this.reparseSeries()};if(Kl.AXIS_STRING_MAPPINGS_={y:0,Y:0,y1:0,Y1:0,y2:1,Y2:1},Kl.axisToIndex_=function(t){if("string"==typeof t){if(Kl.AXIS_STRING_MAPPINGS_.hasOwnProperty(t))return Kl.AXIS_STRING_MAPPINGS_[t];throw"Unknown axis : "+t}if("number"==typeof t){if(0===t||1===t)return t;throw"Dygraphs only supports two y-axes, indexed from 0-1."}if(t)throw"Unknown axis : "+t;return 0},Kl.prototype.reparseSeries=function(){var t=this.get("labels");if(t){this.labels_=t.slice(1),this.yAxes_=[{series:[],options:{}}],this.xAxis_={options:{}},this.series_={};for(var e=this.user_.series||{},i=0;i<this.labels_.length;i++){var s=this.labels_[i],r=e[s]||{},o=Kl.axisToIndex_(r.axis);this.series_[s]={idx:i,yAxis:o,options:r},this.yAxes_[o]?this.yAxes_[o].series.push(s):this.yAxes_[o]={series:[s],options:{}}}var a=this.user_.axes||{};ll(this.yAxes_[0].options,a.y||{}),this.yAxes_.length>1&&ll(this.yAxes_[1].options,a.y2||{}),ll(this.xAxis_.options,a.x||{}),"undefined"!=typeof process&&"production"!=process.env.NODE_ENV&&this.validateOptions_()}},Kl.prototype.get=function(t){var e=this.getGlobalUser_(t);return null!==e?e:this.getGlobalDefault_(t)},Kl.prototype.getGlobalUser_=function(t){return this.user_.hasOwnProperty(t)?this.user_[t]:null},Kl.prototype.getGlobalDefault_=function(t){return this.global_.hasOwnProperty(t)?this.global_[t]:Bl.hasOwnProperty(t)?Bl[t]:null},Kl.prototype.getForAxis=function(t,e){var i,s;if("number"==typeof e)s=0===(i=e)?"y":"y2";else{if("y1"==e&&(e="y"),"y"==e)i=0;else if("y2"==e)i=1;else{if("x"!=e)throw"Unknown axis "+e;i=-1}s=e}var r=-1==i?this.xAxis_:this.yAxes_[i];if(r){var o=r.options;if(o.hasOwnProperty(t))return o[t]}if("x"!==e||"logscale"!==t){var a=this.getGlobalUser_(t);if(null!==a)return a}var n=Bl.axes[s];return n.hasOwnProperty(t)?n[t]:this.getGlobalDefault_(t)},Kl.prototype.getForSeries=function(t,e){if(e===this.dygraph_.getHighlightSeries()&&this.highlightSeries_.hasOwnProperty(t))return this.highlightSeries_[t];if(!this.series_.hasOwnProperty(e))throw"Unknown series: "+e;var i=this.series_[e],s=i.options;return s.hasOwnProperty(t)?s[t]:this.getForAxis(t,i.yAxis)},Kl.prototype.numAxes=function(){return this.yAxes_.length},Kl.prototype.axisForSeries=function(t){return this.series_[t].yAxis},Kl.prototype.axisOptions=function(t){return this.yAxes_[t].options},Kl.prototype.seriesForAxis=function(t){return this.yAxes_[t].series},Kl.prototype.seriesNames=function(){return this.labels_},"undefined"!=typeof process&&"production"!=process.env.NODE_ENV){Kl.prototype.validateOptions_=function(){if(void 0===Zl)throw"Called validateOptions_ in prod build.";for(var t=this,e=function(e){Zl[e]||t.warnInvalidOption_(e)},i=[this.xAxis_.options,this.yAxes_[0].options,this.yAxes_[1]&&this.yAxes_[1].options,this.global_,this.user_,this.highlightSeries_],s=this.seriesNames(),r=0;r<s.length;r++){var o=s[r];this.series_.hasOwnProperty(o)&&i.push(this.series_[o].options)}for(r=0;r<i.length;r++){var a=i[r];if(a)for(var n in a)a.hasOwnProperty(n)&&e(n)}};var Jl={};Kl.prototype.warnInvalidOption_=function(t){if(!Jl[t])throw Jl[t]=!0,this.labels_.indexOf(t)>=0?console.warn("Use new-style per-series options (saw "+t+" as top-level options key). See http://bit.ly/1tceaJs"):console.warn("Unknown option "+t+" (full list of options at dygraphs.com/options.html"),"invalid option "+t},Kl.resetWarnings_=function(){Jl={}}}function Ql(){this.tarps=[]}Ql.prototype.cover=function(){for(var t=document.getElementsByTagName("iframe"),e=0;e<t.length;e++){var i=t[e],s=$n(i),r=s.x,o=s.y,a=i.offsetWidth,n=i.offsetHeight,l=document.createElement("div");l.style.position="absolute",l.style.left=r+"px",l.style.top=o+"px",l.style.width=a+"px",l.style.height=n+"px",l.style.zIndex=999,document.body.appendChild(l),this.tarps.push(l)}},Ql.prototype.uncover=function(){for(var t=0;t<this.tarps.length;t++)this.tarps[t].parentNode.removeChild(this.tarps[t]);this.tarps=[]};var th=function(){},eh=th;eh.X=0,eh.Y=1,eh.EXTRAS=2,eh.prototype.extractSeries=function(t,e,i){},eh.prototype.seriesToPoints=function(t,e,i){for(var s=[],r=0;r<t.length;++r){var o=t[r],a=o[1],n=null===a?null:eh.parseFloat(a),l={x:NaN,y:NaN,xval:eh.parseFloat(o[0]),yval:n,name:e,idx:r+i};s.push(l)}return this.onPointsCreated_(t,s),s},eh.prototype.onPointsCreated_=function(t,e){},eh.prototype.rollingAverage=function(t,e,i){},eh.prototype.getExtremeYValues=function(t,e,i){},eh.prototype.onLineEvaluated=function(t,e,i){},eh.parseFloat=function(t){return null===t?NaN:t};var ih=function(){};(ih.prototype=new th).extractSeries=function(t,e,i){for(var s=[],r=i.get("logscale"),o=0;o<t.length;o++){var a=t[o][0],n=t[o][e];r&&n<=0&&(n=null),s.push([a,n])}return s},ih.prototype.rollingAverage=function(t,e,i){var s,r,o,a,n,l=[];if(1==(e=Math.min(e,t.length)))return t;for(s=0;s<t.length;s++){for(a=0,n=0,r=Math.max(0,s-e+1);r<s+1;r++)null===(o=t[r][1])||isNaN(o)||(n++,a+=t[r][1]);l[s]=n?[t[s][0],a/n]:[t[s][0],null]}return l},ih.prototype.getExtremeYValues=function(t,e,i){for(var s,r=null,o=null,a=t.length-1,n=0;n<=a;n++)null===(s=t[n][1])||isNaN(s)||((null===o||s>o)&&(o=s),(null===r||s<r)&&(r=s));return[r,o]};var sh=function(){th.call(this)};(sh.prototype=new th).extractSeries=function(t,e,i){},sh.prototype.rollingAverage=function(t,e,i){},sh.prototype.onPointsCreated_=function(t,e){for(var i=0;i<t.length;++i){var s=t[i],r=e[i];r.y_top=NaN,r.y_bottom=NaN,r.yval_minus=th.parseFloat(s[2][0]),r.yval_plus=th.parseFloat(s[2][1])}},sh.prototype.getExtremeYValues=function(t,e,i){for(var s,r=null,o=null,a=t.length-1,n=0;n<=a;n++)if(null!==(s=t[n][1])&&!isNaN(s)){var l=t[n][2][0],h=t[n][2][1];l>s&&(l=s),h<s&&(h=s),(null===o||h>o)&&(o=h),(null===r||l<r)&&(r=l)}return[r,o]},sh.prototype.onLineEvaluated=function(t,e,i){for(var s,r=0;r<t.length;r++)(s=t[r]).y_top=Dl.calcYNormal_(e,s.yval_minus,i),s.y_bottom=Dl.calcYNormal_(e,s.yval_plus,i)};var rh=function(){};(rh.prototype=new sh).extractSeries=function(t,e,i){for(var s,r,o,a,n=[],l=i.get("sigma"),h=i.get("logscale"),d=0;d<t.length;d++)s=t[d][0],a=t[d][e],h&&null!==a&&(a[0]<=0||a[0]-l*a[1]<=0)&&(a=null),null!==a?null===(r=a[0])||isNaN(r)?n.push([s,r,[r,r,r]]):(o=l*a[1],n.push([s,r,[r-o,r+o,a[1]]])):n.push([s,null,[null,null,null]]);return n},rh.prototype.rollingAverage=function(t,e,i){e=Math.min(e,t.length);var s,r,o,a,n,l,h,d,c,p=[],u=i.get("sigma");for(s=0;s<t.length;s++){for(n=0,d=0,l=0,r=Math.max(0,s-e+1);r<s+1;r++)null===(o=t[r][1])||isNaN(o)||(l++,n+=o,d+=Math.pow(t[r][2][2],2));l?(h=Math.sqrt(d)/l,c=n/l,p[s]=[t[s][0],c,[c-u*h,c+u*h]]):(a=1==e?t[s][1]:null,p[s]=[t[s][0],a,[a,a]])}return p};var oh=function(){};(oh.prototype=new sh).extractSeries=function(t,e,i){for(var s,r,o,a=[],n=i.get("logscale"),l=0;l<t.length;l++)s=t[l][0],o=t[l][e],n&&null!==o&&(o[0]<=0||o[1]<=0||o[2]<=0)&&(o=null),null!==o?null===(r=o[1])||isNaN(r)?a.push([s,r,[r,r]]):a.push([s,r,[o[0],o[2]]]):a.push([s,null,[null,null]]);return a},oh.prototype.rollingAverage=function(t,e,i){e=Math.min(e,t.length);var s,r,o,a,n,l,h,d=[];for(r=0,a=0,o=0,n=0,l=0;l<t.length;l++){if(s=t[l][1],h=t[l][2],d[l]=t[l],null===s||isNaN(s)||(r+=h[0],a+=s,o+=h[1],n+=1),l-e>=0){var c=t[l-e];null===c[1]||isNaN(c[1])||(r-=c[2][0],a-=c[1],o-=c[2][1],n-=1)}d[l]=n?[t[l][0],1*a/n,[1*r/n,1*o/n]]:[t[l][0],null,[null,null]]}return d};var ah=function(){};(ah.prototype=new ih).extractSeries=function(t,e,i){for(var s,r,o,a,n,l=[],h=i.get("logscale"),d=0;d<t.length;d++)s=t[d][0],o=t[d][e],h&&null!==o&&(o[0]<=0||o[1]<=0)&&(o=null),null!==o?(a=o[0],n=o[1],null===a||isNaN(a)?l.push([s,a,[a,n]]):(r=100*(n?a/n:0),l.push([s,r,[a,n]]))):l.push([s,null,[null,null]]);return l},ah.prototype.rollingAverage=function(t,e,i){e=Math.min(e,t.length);var s,r=[],o=0,a=0;for(s=0;s<t.length;s++){o+=t[s][2][0],a+=t[s][2][1],s-e>=0&&(o-=t[s-e][2][0],a-=t[s-e][2][1]);var n=t[s][0],l=a?o/a:0;r[s]=[n,100*l]}return r};var nh=function(){};(nh.prototype=new sh).extractSeries=function(t,e,i){for(var s,r,o,a,n,l,h,d=[],c=i.get("sigma"),p=i.get("logscale"),u=0;u<t.length;u++)s=t[u][0],o=t[u][e],p&&null!==o&&(o[0]<=0||o[1]<=0)&&(o=null),null!==o?(a=o[0],n=o[1],null===a||isNaN(a)?d.push([s,a,[a,a,a,n]]):(l=n?a/n:0,h=100*(n?c*Math.sqrt(l*(1-l)/n):1),r=100*l,d.push([s,r,[r-h,r+h,a,n]]))):d.push([s,null,[null,null,null,null]]);return d},nh.prototype.rollingAverage=function(t,e,i){e=Math.min(e,t.length);var s,r,o,a,n=[],l=i.get("sigma"),h=i.get("wilsonInterval"),d=0,c=0,p=100;for(o=0;o<t.length;o++){d+=t[o][2][2],c+=t[o][2][3],o-e>=0&&(d-=t[o-e][2][2],c-=t[o-e][2][3]);var u=t[o][0],g=c?d/c:0;if(h)if(c){var f=g<0?0:g,m=c,y=l*Math.sqrt(f*(1-f)/m+l*l/(4*m*m)),x=1+l*l/c;s=(f+l*l/(2*c)-y)/x,r=(f+l*l/(2*c)+y)/x,n[o]=[u,f*p,[s*p,r*p]]}else n[o]=[u,0,[0,0]];else a=c?l*Math.sqrt(g*(1-g)/c):1,n[o]=[u,p*g,[p*(g-a),p*(g+a)]]}return n};var lh=function(){this.annotations_=[]};lh.prototype.toString=function(){return"Annotations Plugin"},lh.prototype.activate=function(t){return{clearChart:this.clearChart,didDrawChart:this.didDrawChart}},lh.prototype.detachLabels=function(){for(var t=0;t<this.annotations_.length;t++){var e=this.annotations_[t];e.parentNode&&e.parentNode.removeChild(e),this.annotations_[t]=null}this.annotations_=[]},lh.prototype.clearChart=function(t){this.detachLabels()},lh.prototype.didDrawChart=function(t){var e=t.dygraph,i=e.layout_.annotated_points;if(i&&0!==i.length)for(var s=t.canvas.parentNode,r=function(t,i,s){return function(r){var o=s.annotation;o.hasOwnProperty(t)?o[t](o,s,e,r):e.getOption(i)&&e.getOption(i)(o,s,e,r)}},o=t.dygraph.getArea(),a={},n=0;n<i.length;n++){var l=i[n];if(!(l.canvasx<o.x||l.canvasx>o.x+o.w||l.canvasy<o.y||l.canvasy>o.y+o.h)){var h=l.annotation,d=6;h.hasOwnProperty("tickHeight")&&(d=h.tickHeight);var c=document.createElement("div");c.style.fontSize=e.getOption("axisLabelFontSize")+"px";var p="dygraph-annotation";h.hasOwnProperty("icon")||(p+=" dygraphDefaultAnnotation dygraph-default-annotation"),h.hasOwnProperty("cssClass")&&(p+=" "+h.cssClass),c.className=p;var u=h.hasOwnProperty("width")?h.width:16,g=h.hasOwnProperty("height")?h.height:16;if(h.hasOwnProperty("icon")){var f=document.createElement("img");f.src=h.icon,f.width=u,f.height=g,c.appendChild(f)}else l.annotation.hasOwnProperty("shortText")&&c.appendChild(document.createTextNode(l.annotation.shortText));var m=l.canvasx-u/2;c.style.left=m+"px";var y=0;if(h.attachAtBottom){var x=o.y+o.h-g-d;a[m]?x-=a[m]:a[m]=0,a[m]+=d+g,y=x}else y=l.canvasy-g-d;c.style.top=y+"px",c.style.width=u+"px",c.style.height=g+"px",c.title=l.annotation.text,c.style.color=e.colorsMap_[l.name],c.style.borderColor=e.colorsMap_[l.name],h.div=c,e.addAndTrackEvent(c,"click",r("clickHandler","annotationClickHandler",l)),e.addAndTrackEvent(c,"mouseover",r("mouseOverHandler","annotationMouseOverHandler",l)),e.addAndTrackEvent(c,"mouseout",r("mouseOutHandler","annotationMouseOutHandler",l)),e.addAndTrackEvent(c,"dblclick",r("dblClickHandler","annotationDblClickHandler",l)),s.appendChild(c),this.annotations_.push(c);var v=t.drawingContext;if(v.save(),v.strokeStyle=h.hasOwnProperty("tickColor")?h.tickColor:e.colorsMap_[l.name],v.lineWidth=h.hasOwnProperty("tickWidth")?h.tickWidth:e.getOption("strokeWidth"),v.beginPath(),h.attachAtBottom){x=y+g;v.moveTo(l.canvasx,x),v.lineTo(l.canvasx,x+d)}else v.moveTo(l.canvasx,l.canvasy),v.lineTo(l.canvasx,l.canvasy-2-d);v.closePath(),v.stroke(),v.restore()}}},lh.prototype.destroy=function(){this.detachLabels()};var hh=function(){this.xlabels_=[],this.ylabels_=[]};hh.prototype.toString=function(){return"Axes Plugin"},hh.prototype.activate=function(t){return{layout:this.layout,clearChart:this.clearChart,willDrawChart:this.willDrawChart}},hh.prototype.layout=function(t){var e,i=t.dygraph;if(i.getOptionForAxis("drawAxis","y")){var s=i.getOptionForAxis("axisLabelWidth","y")+2*i.getOptionForAxis("axisTickSize","y");t.reserveSpaceLeft(s)}i.getOptionForAxis("drawAxis","x")&&(e=i.getOption("xAxisHeight")?i.getOption("xAxisHeight"):i.getOptionForAxis("axisLabelFontSize","x")+2*i.getOptionForAxis("axisTickSize","x"),t.reserveSpaceBottom(e));if(2==i.numAxes()){if(i.getOptionForAxis("drawAxis","y2")){s=i.getOptionForAxis("axisLabelWidth","y2")+2*i.getOptionForAxis("axisTickSize","y2");t.reserveSpaceRight(s)}}else i.numAxes()>2&&i.error("Only two y-axes are supported at this time. (Trying to use "+i.numAxes()+")")},hh.prototype.detachLabels=function(){function t(t){for(var e=0;e<t.length;e++){var i=t[e];i.parentNode&&i.parentNode.removeChild(i)}}t(this.xlabels_),t(this.ylabels_),this.xlabels_=[],this.ylabels_=[]},hh.prototype.clearChart=function(t){this.detachLabels()},hh.prototype.willDrawChart=function(t){var e=t.dygraph;if(e.getOptionForAxis("drawAxis","x")||e.getOptionForAxis("drawAxis","y")||e.getOptionForAxis("drawAxis","y2")){var i,s,r,o=t.drawingContext,a=t.canvas.parentNode,n=e.width_,l=e.height_,h=function(t){return{position:"absolute",fontSize:e.getOptionForAxis("axisLabelFontSize",t)+"px",width:e.getOptionForAxis("axisLabelWidth",t)+"px"}},d={x:h("x"),y:h("y"),y2:h("y2")},c=function(t,e,i){var s=document.createElement("div"),r=d["y2"==i?"y2":e];ll(s.style,r);var o=document.createElement("div");return o.className="dygraph-axis-label dygraph-axis-label-"+e+(i?" dygraph-axis-label-"+i:""),o.innerHTML=t,s.appendChild(o),s};o.save();var p=e.layout_,u=t.dygraph.plotter_.area,g=function(t){return function(i){return e.getOptionForAxis(i,t)}};if(e.getOptionForAxis("drawAxis","y")){if(p.yticks&&p.yticks.length>0){var f=e.numAxes(),m=[g("y"),g("y2")];p.yticks.forEach((t=>{if(void 0!==t.label){s=u.x;var e="y1",o=m[0];1==t.axis&&(s=u.x+u.w,e="y2",o=m[1]);var n=o("axisLabelFontSize");r=u.y+t.pos*u.h,i=c(t.label,"y",2==f?e:null);var h=r-n/2;h<0&&(h=0),h+n+3>l?i.style.bottom="0":i.style.top=h+"px",0===t.axis?(i.style.left=u.x-o("axisLabelWidth")-o("axisTickSize")+"px",i.style.textAlign="right"):1==t.axis&&(i.style.left=u.x+u.w+o("axisTickSize")+"px",i.style.textAlign="left"),i.style.width=o("axisLabelWidth")+"px",a.appendChild(i),this.ylabels_.push(i)}}));var y=this.ylabels_[0],x=e.getOptionForAxis("axisLabelFontSize","y");parseInt(y.style.top,10)+x>l-x&&(y.style.top=parseInt(y.style.top,10)-x/2+"px")}var v;if(e.getOption("drawAxesAtZero"))((_=e.toPercentXCoord(0))>1||_<0||isNaN(_))&&(_=0),v=S(u.x+_*u.w);else v=S(u.x);o.strokeStyle=e.getOptionForAxis("axisLineColor","y"),o.lineWidth=e.getOptionForAxis("axisLineWidth","y"),o.beginPath(),o.moveTo(v,T(u.y)),o.lineTo(v,T(u.y+u.h)),o.closePath(),o.stroke(),2==e.numAxes()&&(o.strokeStyle=e.getOptionForAxis("axisLineColor","y2"),o.lineWidth=e.getOptionForAxis("axisLineWidth","y2"),o.beginPath(),o.moveTo(T(u.x+u.w),T(u.y)),o.lineTo(T(u.x+u.w),T(u.y+u.h)),o.closePath(),o.stroke())}if(e.getOptionForAxis("drawAxis","x")){if(p.xticks){var w=g("x");p.xticks.forEach((t=>{if(void 0!==t.label){s=u.x+t.pos*u.w,r=u.y+u.h,(i=c(t.label,"x")).style.textAlign="center",i.style.top=r+w("axisTickSize")+"px";var e=s-w("axisLabelWidth")/2;e+w("axisLabelWidth")>n&&(e=n-w("axisLabelWidth"),i.style.textAlign="right"),e<0&&(e=0,i.style.textAlign="left"),i.style.left=e+"px",i.style.width=w("axisLabelWidth")+"px",a.appendChild(i),this.xlabels_.push(i)}}))}var b,_;if(o.strokeStyle=e.getOptionForAxis("axisLineColor","x"),o.lineWidth=e.getOptionForAxis("axisLineWidth","x"),o.beginPath(),e.getOption("drawAxesAtZero"))((_=e.toPercentYCoord(0,0))>1||_<0)&&(_=1),b=T(u.y+_*u.h);else b=T(u.y+u.h);o.moveTo(S(u.x),b),o.lineTo(S(u.x+u.w),b),o.closePath(),o.stroke()}o.restore()}function S(t){return Math.round(t)+.5}function T(t){return Math.round(t)-.5}};var dh=function(){this.title_div_=null,this.xlabel_div_=null,this.ylabel_div_=null,this.y2label_div_=null};dh.prototype.toString=function(){return"ChartLabels Plugin"},dh.prototype.activate=function(t){return{layout:this.layout,didDrawChart:this.didDrawChart}};var ch=function(t){var e=document.createElement("div");return e.style.position="absolute",e.style.left=t.x+"px",e.style.top=t.y+"px",e.style.width=t.w+"px",e.style.height=t.h+"px",e};dh.prototype.detachLabels_=function(){for(var t=[this.title_div_,this.xlabel_div_,this.ylabel_div_,this.y2label_div_],e=0;e<t.length;e++){var i=t[e];i&&(i.parentNode&&i.parentNode.removeChild(i))}this.title_div_=null,this.xlabel_div_=null,this.ylabel_div_=null,this.y2label_div_=null};var ph=function(t,e,i,s,r){var o=document.createElement("div");o.style.position="absolute",o.style.left=1==i?"0px":e.x+"px",o.style.top=e.y+"px",o.style.width=e.w+"px",o.style.height=e.h+"px",o.style.fontSize=t.getOption("yLabelWidth")-2+"px";var a=document.createElement("div");a.style.position="absolute",a.style.width=e.h+"px",a.style.height=e.w+"px",a.style.top=e.h/2-e.w/2+"px",a.style.left=e.w/2-e.h/2+"px",a.className="dygraph-label-rotate-"+(1==i?"right":"left");var n=document.createElement("div");return n.className=s,n.innerHTML=r,a.appendChild(n),o.appendChild(a),o};dh.prototype.layout=function(t){this.detachLabels_();var e=t.dygraph,i=t.chart_div;if(e.getOption("title")){var s=t.reserveSpaceTop(e.getOption("titleHeight"));this.title_div_=ch(s),this.title_div_.style.fontSize=e.getOption("titleHeight")-8+"px",(r=document.createElement("div")).className="dygraph-label dygraph-title",r.innerHTML=e.getOption("title"),this.title_div_.appendChild(r),i.appendChild(this.title_div_)}if(e.getOption("xlabel")){var r,o=t.reserveSpaceBottom(e.getOption("xLabelHeight"));this.xlabel_div_=ch(o),this.xlabel_div_.style.fontSize=e.getOption("xLabelHeight")-2+"px",(r=document.createElement("div")).className="dygraph-label dygraph-xlabel",r.innerHTML=e.getOption("xlabel"),this.xlabel_div_.appendChild(r),i.appendChild(this.xlabel_div_)}if(e.getOption("ylabel")){var a=t.reserveSpaceLeft(0);this.ylabel_div_=ph(e,a,1,"dygraph-label dygraph-ylabel",e.getOption("ylabel")),i.appendChild(this.ylabel_div_)}if(e.getOption("y2label")&&2==e.numAxes()){var n=t.reserveSpaceRight(0);this.y2label_div_=ph(e,n,2,"dygraph-label dygraph-y2label",e.getOption("y2label")),i.appendChild(this.y2label_div_)}},dh.prototype.didDrawChart=function(t){var e=t.dygraph;this.title_div_&&(this.title_div_.children[0].innerHTML=e.getOption("title")),this.xlabel_div_&&(this.xlabel_div_.children[0].innerHTML=e.getOption("xlabel")),this.ylabel_div_&&(this.ylabel_div_.children[0].children[0].innerHTML=e.getOption("ylabel")),this.y2label_div_&&(this.y2label_div_.children[0].children[0].innerHTML=e.getOption("y2label"))},dh.prototype.clearChart=function(){},dh.prototype.destroy=function(){this.detachLabels_()};var uh=function(){};uh.prototype.toString=function(){return"Gridline Plugin"},uh.prototype.activate=function(t){return{willDrawChart:this.willDrawChart}},uh.prototype.willDrawChart=function(t){var e,i,s,r=t.dygraph,o=t.drawingContext,a=r.layout_,n=t.dygraph.plotter_.area;function l(t){return Math.round(t)+.5}function h(t){return Math.round(t)-.5}if(r.getOptionForAxis("drawGrid","y")){for(var d=["y","y2"],c=[],p=[],u=[],g=[],f=[],m=0;m<d.length;m++)u[m]=r.getOptionForAxis("drawGrid",d[m]),u[m]&&(c[m]=r.getOptionForAxis("gridLineColor",d[m]),p[m]=r.getOptionForAxis("gridLineWidth",d[m]),f[m]=r.getOptionForAxis("gridLinePattern",d[m]),g[m]=f[m]&&f[m].length>=2);s=a.yticks,o.save(),s.forEach((t=>{if(t.has_tick){var s=t.axis;u[s]&&(o.save(),g[s]&&o.setLineDash&&o.setLineDash(f[s]),o.strokeStyle=c[s],o.lineWidth=p[s],e=l(n.x),i=h(n.y+t.pos*n.h),o.beginPath(),o.moveTo(e,i),o.lineTo(e+n.w,i),o.stroke(),o.restore())}})),o.restore()}if(r.getOptionForAxis("drawGrid","x")){s=a.xticks,o.save();f=r.getOptionForAxis("gridLinePattern","x");(g=f&&f.length>=2)&&o.setLineDash&&o.setLineDash(f),o.strokeStyle=r.getOptionForAxis("gridLineColor","x"),o.lineWidth=r.getOptionForAxis("gridLineWidth","x"),s.forEach((t=>{t.has_tick&&(e=l(n.x+t.pos*n.w),i=h(n.y+n.h),o.beginPath(),o.moveTo(e,i),o.lineTo(e,n.y),o.closePath(),o.stroke())})),g&&o.setLineDash&&o.setLineDash([]),o.restore()}},uh.prototype.destroy=function(){};var gh=function(){this.legend_div_=null,this.is_generated_div_=!1};gh.prototype.toString=function(){return"Legend Plugin"},gh.prototype.activate=function(t){var e,i=t.getOption("labelsDiv");return i&&null!==i?e="string"==typeof i||i instanceof String?document.getElementById(i):i:((e=document.createElement("div")).className="dygraph-legend",t.graphDiv.appendChild(e),this.is_generated_div_=!0),this.legend_div_=e,this.one_em_width_=10,{select:this.select,deselect:this.deselect,predraw:this.predraw,didDrawChart:this.didDrawChart}};function fh(t,e,i){if(!t||t.length<=1)return`<div class="dygraph-legend-line" style="border-bottom-color: ${e};"></div>`;var s,r,o,a,n=0,l=0,h=[];for(s=0;s<=t.length;s++)n+=t[s%t.length];if((a=Math.floor(i/(n-t[0])))>1){for(s=0;s<t.length;s++)h[s]=t[s]/i;l=h.length}else{for(a=1,s=0;s<t.length;s++)h[s]=t[s]/n;l=h.length+1}var d="";for(r=0;r<a;r++)for(s=0;s<l;s+=2)o=h[s%h.length],d+=`<div class="dygraph-legend-dash" style="margin-right: ${s<t.length?h[(s+1)%h.length]:0}em; padding-left: ${o}em;"></div>`;return d}gh.prototype.select=function(t){var e=t.selectedX,i=t.selectedPoints,s=t.selectedRow,r=t.dygraph.getOption("legend");if("never"!==r){if("follow"===r){var o=t.dygraph.plotter_.area,a=this.legend_div_.offsetWidth,n=t.dygraph.getOptionForAxis("axisLabelWidth","y"),l=i[0].x*o.w+50,h=i[0].y*o.h-50;l+a+1>o.w&&(l=l-100-a-(n-o.x)),t.dygraph.graphDiv.appendChild(this.legend_div_),this.legend_div_.style.left=n+l+"px",this.legend_div_.style.top=h+"px"}var d=gh.generateLegendHTML(t.dygraph,e,i,this.one_em_width_,s);this.legend_div_.innerHTML=d,this.legend_div_.style.display=""}else this.legend_div_.style.display="none"},gh.prototype.deselect=function(t){"always"!==t.dygraph.getOption("legend")&&(this.legend_div_.style.display="none");var e=function(t){var e=document.createElement("span");e.setAttribute("style","margin: 0; padding: 0 0 0 1em; border: 0;"),t.appendChild(e);var i=e.offsetWidth;return t.removeChild(e),i}(this.legend_div_);this.one_em_width_=e;var i=gh.generateLegendHTML(t.dygraph,void 0,void 0,e,null);this.legend_div_.innerHTML=i},gh.prototype.didDrawChart=function(t){this.deselect(t)},gh.prototype.predraw=function(t){if(this.is_generated_div_){t.dygraph.graphDiv.appendChild(this.legend_div_);var e=t.dygraph.getArea(),i=this.legend_div_.offsetWidth;this.legend_div_.style.left=e.x+e.w-i-1+"px",this.legend_div_.style.top=e.y+"px"}},gh.prototype.destroy=function(){this.legend_div_=null},gh.generateLegendHTML=function(t,e,i,s,r){var o,a={dygraph:t,x:e,series:[]},n={},l=t.getLabels();if(l)for(var h=1;h<l.length;h++){var d=t.getPropertiesForSeries(l[h]),c={dashHTML:fh(t.getOption("strokePattern",l[h]),d.color,s),label:l[h],labelHTML:(o=l[h],o.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")),isVisible:d.visible,color:d.color};a.series.push(c),n[l[h]]=c}if(void 0!==e){var p=t.optionsViewForAxis_("x"),u=p("valueFormatter");a.xHTML=u.call(t,e,p,l[0],t,r,0);var g=[],f=t.numAxes();for(h=0;h<f;h++)g[h]=t.optionsViewForAxis_("y"+(h?1+h:""));var m=t.getOption("labelsShowZeroValues"),y=t.getHighlightSeries();for(h=0;h<i.length;h++){var x=i[h];if((c=n[x.name]).y=x.yval,0===x.yval&&!m||isNaN(x.canvasy))c.isVisible=!1;else{var v=g[(d=t.getPropertiesForSeries(x.name)).axis-1];ll(c,{yHTML:v("valueFormatter").call(t,x.yval,v,x.name,t,r,l.indexOf(x.name))}),x.name==y&&(c.isHighlighted=!0)}}}return(t.getOption("legendFormatter")||gh.defaultFormatter).call(t,a)},gh.defaultFormatter=function(t){var e=t.dygraph;if(!0!==e.getOption("showLabelsOnHighlight"))return"";var i,s=e.getOption("labelsSeparateLines");if(void 0===t.x){if("always"!=e.getOption("legend"))return"";i="";for(var r=0;r<t.series.length;r++){(o=t.series[r]).isVisible&&(""!==i&&(i+=s?"<br/>":" "),i+=`<span style='font-weight: bold; color: ${o.color};'>${o.dashHTML} ${o.labelHTML}</span>`)}return i}i=t.xHTML+":";for(r=0;r<t.series.length;r++){var o;if((o=t.series[r]).isVisible)s&&(i+="<br>"),i+=`<span${o.isHighlighted?' class="highlight"':""}> <b><span style='color: ${o.color};'>${o.labelHTML}</span></b>:&#160;${o.yHTML}</span>`}return i};var mh=function(){this.hasTouchInterface_="undefined"!=typeof TouchEvent,this.isMobileDevice_=/mobile|android/gi.test(navigator.appVersion),this.interfaceCreated_=!1};mh.prototype.toString=function(){return"RangeSelector Plugin"},mh.prototype.activate=function(t){return this.dygraph_=t,this.getOption_("showRangeSelector")&&this.createInterface_(),{layout:this.reserveSpace_,predraw:this.renderStaticLayer_,didDrawChart:this.renderInteractiveLayer_}},mh.prototype.destroy=function(){this.bgcanvas_=null,this.fgcanvas_=null,this.leftZoomHandle_=null,this.rightZoomHandle_=null},mh.prototype.getOption_=function(t,e){return this.dygraph_.getOption(t,e)},mh.prototype.setDefaultOption_=function(t,e){this.dygraph_.attrs_[t]=e},mh.prototype.createInterface_=function(){this.createCanvases_(),this.createZoomHandles_(),this.initInteraction_(),this.getOption_("animatedZooms")&&(console.warn("Animated zooms and range selector are not compatible; disabling animatedZooms."),this.dygraph_.updateOptions({animatedZooms:!1},!0)),this.interfaceCreated_=!0,this.addToGraph_()},mh.prototype.addToGraph_=function(){var t=this.graphDiv_=this.dygraph_.graphDiv;t.appendChild(this.bgcanvas_),t.appendChild(this.fgcanvas_),t.appendChild(this.leftZoomHandle_),t.appendChild(this.rightZoomHandle_)},mh.prototype.removeFromGraph_=function(){var t=this.graphDiv_;t.removeChild(this.bgcanvas_),t.removeChild(this.fgcanvas_),t.removeChild(this.leftZoomHandle_),t.removeChild(this.rightZoomHandle_),this.graphDiv_=null},mh.prototype.reserveSpace_=function(t){this.getOption_("showRangeSelector")&&t.reserveSpaceBottom(this.getOption_("rangeSelectorHeight")+4)},mh.prototype.renderStaticLayer_=function(){this.updateVisibility_()&&(this.resize_(),this.drawStaticLayer_())},mh.prototype.renderInteractiveLayer_=function(){this.updateVisibility_()&&!this.isChangingRange_&&(this.placeZoomHandles_(),this.drawInteractiveLayer_())},mh.prototype.updateVisibility_=function(){var t=this.getOption_("showRangeSelector");if(t)this.interfaceCreated_?this.graphDiv_&&this.graphDiv_.parentNode||this.addToGraph_():this.createInterface_();else if(this.graphDiv_){this.removeFromGraph_();var e=this.dygraph_;setTimeout((function(){e.width_=0,e.resize()}),1)}return t},mh.prototype.resize_=function(){function t(t,e,i,s){var r=s||gl(e);t.style.top=i.y+"px",t.style.left=i.x+"px",t.width=i.w*r,t.height=i.h*r,t.style.width=i.w+"px",t.style.height=i.h+"px",1!=r&&e.scale(r,r)}var e=this.dygraph_.layout_.getPlotArea(),i=0;this.dygraph_.getOptionForAxis("drawAxis","x")&&(i=this.getOption_("xAxisHeight")||this.getOption_("axisLabelFontSize")+2*this.getOption_("axisTickSize")),this.canvasRect_={x:e.x,y:e.y+e.h+i+4,w:e.w,h:this.getOption_("rangeSelectorHeight")};var s=this.dygraph_.getNumericOption("pixelRatio");t(this.bgcanvas_,this.bgcanvas_ctx_,this.canvasRect_,s),t(this.fgcanvas_,this.fgcanvas_ctx_,this.canvasRect_,s)},mh.prototype.createCanvases_=function(){this.bgcanvas_=ul(),this.bgcanvas_.className="dygraph-rangesel-bgcanvas",this.bgcanvas_.style.position="absolute",this.bgcanvas_.style.zIndex=9,this.bgcanvas_ctx_=Fn(this.bgcanvas_),this.fgcanvas_=ul(),this.fgcanvas_.className="dygraph-rangesel-fgcanvas",this.fgcanvas_.style.position="absolute",this.fgcanvas_.style.zIndex=9,this.fgcanvas_.style.cursor="default",this.fgcanvas_ctx_=Fn(this.fgcanvas_)},mh.prototype.createZoomHandles_=function(){var t=new Image;t.className="dygraph-rangesel-zoomhandle",t.style.position="absolute",t.style.zIndex=10,t.style.visibility="hidden",t.style.cursor="col-resize",t.width=9,t.height=16,t.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAQCAYAAADESFVDAAAAAXNSR0IArs4c6QAAAAZiS0dEANAAzwDP4Z7KegAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAAd0SU1FB9sHGw0cMqdt1UwAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAaElEQVQoz+3SsRFAQBCF4Z9WJM8KCDVwownl6YXsTmCUsyKGkZzcl7zkz3YLkypgAnreFmDEpHkIwVOMfpdi9CEEN2nGpFdwD03yEqDtOgCaun7sqSTDH32I1pQA2Pb9sZecAxc5r3IAb21d6878xsAAAAAASUVORK5CYII=",this.isMobileDevice_&&(t.width*=2,t.height*=2),this.leftZoomHandle_=t,this.rightZoomHandle_=t.cloneNode(!1)},mh.prototype.initInteraction_=function(){var t,e,i,s,r,o,a,n,l,h,d,c,p,u,g=this,f=document,m=0,y=null,x=!1,v=!1,w=!this.isMobileDevice_,b=new Ql;t=function(t){var e=g.dygraph_.xAxisExtremes(),i=(e[1]-e[0])/g.canvasRect_.w;return[e[0]+(t.leftHandlePos-g.canvasRect_.x)*i,e[0]+(t.rightHandlePos-g.canvasRect_.x)*i]},e=function(t){return zn(t),x=!0,m=t.clientX,y=t.target?t.target:t.srcElement,"mousedown"!==t.type&&"dragstart"!==t.type||(Gn(f,"mousemove",i),Gn(f,"mouseup",s)),g.fgcanvas_.style.cursor="col-resize",b.cover(),!0},i=function(t){if(!x)return!1;zn(t);var e=t.clientX-m;if(Math.abs(e)<4)return!0;m=t.clientX;var i,s=g.getZoomHandleStatus_();y==g.leftZoomHandle_?(i=s.leftHandlePos+e,i=Math.min(i,s.rightHandlePos-y.width-3),i=Math.max(i,g.canvasRect_.x)):(i=s.rightHandlePos+e,i=Math.min(i,g.canvasRect_.x+g.canvasRect_.w),i=Math.max(i,s.leftHandlePos+y.width+3));var o=y.width/2;return y.style.left=i-o+"px",g.drawInteractiveLayer_(),w&&r(),!0},s=function(t){return!!x&&(x=!1,b.uncover(),Yn(f,"mousemove",i),Yn(f,"mouseup",s),g.fgcanvas_.style.cursor="default",w||r(),!0)},r=function(){try{var e=g.getZoomHandleStatus_();if(g.isChangingRange_=!0,e.isZoomed){var i=t(e);g.dygraph_.doZoomXDates_(i[0],i[1])}else g.dygraph_.resetZoom()}finally{g.isChangingRange_=!1}},o=function(t){var e=g.leftZoomHandle_.getBoundingClientRect(),i=e.left+e.width/2,s=(e=g.rightZoomHandle_.getBoundingClientRect()).left+e.width/2;return t.clientX>i&&t.clientX<s},a=function(t){return!(v||!o(t)||!g.getZoomHandleStatus_().isZoomed)&&(zn(t),v=!0,m=t.clientX,"mousedown"===t.type&&(Gn(f,"mousemove",n),Gn(f,"mouseup",l)),!0)},n=function(t){if(!v)return!1;zn(t);var e=t.clientX-m;if(Math.abs(e)<4)return!0;m=t.clientX;var i=g.getZoomHandleStatus_(),s=i.leftHandlePos,r=i.rightHandlePos,o=r-s;s+e<=g.canvasRect_.x?r=(s=g.canvasRect_.x)+o:r+e>=g.canvasRect_.x+g.canvasRect_.w?s=(r=g.canvasRect_.x+g.canvasRect_.w)-o:(s+=e,r+=e);var a=g.leftZoomHandle_.width/2;return g.leftZoomHandle_.style.left=s-a+"px",g.rightZoomHandle_.style.left=r-a+"px",g.drawInteractiveLayer_(),w&&h(),!0},l=function(t){return!!v&&(v=!1,Yn(f,"mousemove",n),Yn(f,"mouseup",l),w||h(),!0)},h=function(){try{g.isChangingRange_=!0,g.dygraph_.dateWindow_=t(g.getZoomHandleStatus_()),g.dygraph_.drawGraph_(!1)}finally{g.isChangingRange_=!1}},d=function(t){if(!x&&!v){var e=o(t)?"move":"default";e!=g.fgcanvas_.style.cursor&&(g.fgcanvas_.style.cursor=e)}},c=function(t){"touchstart"==t.type&&1==t.targetTouches.length?e(t.targetTouches[0])&&zn(t):"touchmove"==t.type&&1==t.targetTouches.length?i(t.targetTouches[0])&&zn(t):s(t)},p=function(t){"touchstart"==t.type&&1==t.targetTouches.length?a(t.targetTouches[0])&&zn(t):"touchmove"==t.type&&1==t.targetTouches.length?n(t.targetTouches[0])&&zn(t):l(t)},u=function(t,e){for(var i=["touchstart","touchend","touchmove","touchcancel"],s=0;s<i.length;s++)g.dygraph_.addAndTrackEvent(t,i[s],e)},this.setDefaultOption_("interactionModel",Wl.dragIsPanInteractionModel),this.setDefaultOption_("panEdgeFraction",1e-4);var _=window.opera?"mousedown":"dragstart";this.dygraph_.addAndTrackEvent(this.leftZoomHandle_,_,e),this.dygraph_.addAndTrackEvent(this.rightZoomHandle_,_,e),this.dygraph_.addAndTrackEvent(this.fgcanvas_,"mousedown",a),this.dygraph_.addAndTrackEvent(this.fgcanvas_,"mousemove",d),this.hasTouchInterface_&&(u(this.leftZoomHandle_,c),u(this.rightZoomHandle_,c),u(this.fgcanvas_,p))},mh.prototype.drawStaticLayer_=function(){var t=this.bgcanvas_ctx_;t.clearRect(0,0,this.canvasRect_.w,this.canvasRect_.h);try{this.drawMiniPlot_()}catch(t){console.warn(t)}var e=.5;this.bgcanvas_ctx_.lineWidth=this.getOption_("rangeSelectorBackgroundLineWidth"),t.strokeStyle=this.getOption_("rangeSelectorBackgroundStrokeColor"),t.beginPath(),t.moveTo(e,e),t.lineTo(e,this.canvasRect_.h-e),t.lineTo(this.canvasRect_.w-e,this.canvasRect_.h-e),t.lineTo(this.canvasRect_.w-e,e),t.stroke()},mh.prototype.drawMiniPlot_=function(){var t=this.getOption_("rangeSelectorPlotFillColor"),e=this.getOption_("rangeSelectorPlotFillGradientColor"),i=this.getOption_("rangeSelectorPlotStrokeColor");if(t||i){var s=this.getOption_("stepPlot"),r=this.computeCombinedSeriesAndLimits_(),o=r.yMax-r.yMin,a=this.bgcanvas_ctx_,n=.5,l=this.dygraph_.xAxisExtremes(),h=Math.max(l[1]-l[0],1e-30),d=(this.canvasRect_.w-n)/h,c=(this.canvasRect_.h-n)/o,p=this.canvasRect_.w-n,u=this.canvasRect_.h-n,g=null,f=null;a.beginPath(),a.moveTo(n,u);for(var m=0;m<r.data.length;m++){var y=r.data[m],x=null!==y[0]?(y[0]-l[0])*d:NaN,v=null!==y[1]?u-(y[1]-r.yMin)*c:NaN;(s||null===g||Math.round(x)!=Math.round(g))&&(isFinite(x)&&isFinite(v)?(null===g?a.lineTo(x,u):s&&a.lineTo(x,f),a.lineTo(x,v),g=x,f=v):(null!==g&&(s?(a.lineTo(x,f),a.lineTo(x,u)):a.lineTo(g,u)),g=f=null))}if(a.lineTo(p,u),a.closePath(),t){var w=this.bgcanvas_ctx_.createLinearGradient(0,0,0,u);e&&w.addColorStop(0,e),w.addColorStop(1,t),this.bgcanvas_ctx_.fillStyle=w,a.fill()}i&&(this.bgcanvas_ctx_.strokeStyle=i,this.bgcanvas_ctx_.lineWidth=this.getOption_("rangeSelectorPlotLineWidth"),a.stroke())}},mh.prototype.computeCombinedSeriesAndLimits_=function(){var t,e=this.dygraph_,i=this.getOption_("logscale"),s=e.numColumns(),r=e.getLabels(),o=new Array(s),a=!1,n=e.visibility(),l=[];for(t=1;t<s;t++){var h=this.getOption_("showInRangeSelector",r[t]);l.push(h),null!==h&&(a=!0)}if(a)for(t=1;t<s;t++)o[t]=l[t-1];else for(t=1;t<s;t++)o[t]=n[t-1];var d=[],c=e.dataHandler_,p=e.attributes_;for(t=1;t<e.numColumns();t++)if(o[t]){var u=c.extractSeries(e.rawData_,t,p);e.rollPeriod()>1&&(u=c.rollingAverage(u,e.rollPeriod(),p)),d.push(u)}var g=[];for(t=0;t<d[0].length;t++){for(var f=0,m=0,y=0;y<d.length;y++){var x=d[y][t][1];null===x||isNaN(x)||(m++,f+=x)}g.push([d[0][t][0],f/m])}var v=Number.MAX_VALUE,w=-Number.MAX_VALUE;for(t=0;t<g.length;t++){var b=g[t][1];null!==b&&isFinite(b)&&(!i||b>0)&&(v=Math.min(v,b),w=Math.max(w,b))}var _=.25;if(i)for(w=Hn(w),w+=w*_,v=Hn(v),t=0;t<g.length;t++)g[t][1]=Hn(g[t][1]);else{var S,T=w-v;w+=S=T<=Number.MIN_VALUE?w*_:T*_,v-=S}return{data:g,yMin:v,yMax:w}},mh.prototype.placeZoomHandles_=function(){var t=this.dygraph_.xAxisExtremes(),e=this.dygraph_.xAxisRange(),i=t[1]-t[0],s=Math.max(0,(e[0]-t[0])/i),r=Math.max(0,(t[1]-e[1])/i),o=this.canvasRect_.x+this.canvasRect_.w*s,a=this.canvasRect_.x+this.canvasRect_.w*(1-r),n=Math.max(this.canvasRect_.y,this.canvasRect_.y+(this.canvasRect_.h-this.leftZoomHandle_.height)/2),l=this.leftZoomHandle_.width/2;this.leftZoomHandle_.style.left=o-l+"px",this.leftZoomHandle_.style.top=n+"px",this.rightZoomHandle_.style.left=a-l+"px",this.rightZoomHandle_.style.top=this.leftZoomHandle_.style.top,this.leftZoomHandle_.style.visibility="visible",this.rightZoomHandle_.style.visibility="visible"},mh.prototype.drawInteractiveLayer_=function(){var t=this.fgcanvas_ctx_;t.clearRect(0,0,this.canvasRect_.w,this.canvasRect_.h);var e=this.canvasRect_.w-1,i=this.canvasRect_.h-1,s=this.getZoomHandleStatus_();if(t.strokeStyle=this.getOption_("rangeSelectorForegroundStrokeColor"),t.lineWidth=this.getOption_("rangeSelectorForegroundLineWidth"),s.isZoomed){var r=Math.max(1,s.leftHandlePos-this.canvasRect_.x),o=Math.min(e,s.rightHandlePos-this.canvasRect_.x);t.fillStyle="rgba(240, 240, 240, "+this.getOption_("rangeSelectorAlpha").toString()+")",t.fillRect(0,0,r,this.canvasRect_.h),t.fillRect(o,0,this.canvasRect_.w-o,this.canvasRect_.h),t.beginPath(),t.moveTo(1,1),t.lineTo(r,1),t.lineTo(r,i),t.lineTo(o,i),t.lineTo(o,1),t.lineTo(e,1),t.stroke()}else t.beginPath(),t.moveTo(1,1),t.lineTo(1,i),t.lineTo(e,i),t.lineTo(e,1),t.stroke()},mh.prototype.getZoomHandleStatus_=function(){var t=this.leftZoomHandle_.width/2,e=parseFloat(this.leftZoomHandle_.style.left)+t,i=parseFloat(this.rightZoomHandle_.style.left)+t;return{leftHandlePos:e,rightHandlePos:i,isZoomed:e-1>this.canvasRect_.x||i+1<this.canvasRect_.x+this.canvasRect_.w}};var yh=function(t){this.container=t};yh.prototype.draw=function(t,e){this.container.innerHTML="",void 0!==this.date_graph&&this.date_graph.destroy(),this.date_graph=new xh(this.container,t,e)},yh.prototype.setSelection=function(t){var e=!1;t.length&&(e=t[0].row),this.date_graph.setSelection(e)},yh.prototype.getSelection=function(){var t=[],e=this.date_graph.getSelection();if(e<0)return t;for(var i=this.date_graph.layout_.points,s=0;s<i.length;++s)t.push({row:e,column:s+1});return t};var xh=function(t,e,i){this.__init__(t,e,i)};xh.NAME="Dygraph",xh.VERSION="2.0.0",xh.DEFAULT_ROLL_PERIOD=1,xh.DEFAULT_WIDTH=480,xh.DEFAULT_HEIGHT=320,xh.ANIMATION_STEPS=12,xh.ANIMATION_DURATION=200,xh.Plotters=Il._Plotters,xh.addedAnnotationCSS=!1,xh.prototype.__init__=function(t,e,i){if(this.is_initial_draw_=!0,this.readyFns_=[],null==i&&(i={}),i=xh.copyUserAttrs_(i),"string"==typeof t&&(t=document.getElementById(t)),!t)throw new Error("Constructing dygraph with a non-existent div!");this.maindiv_=t,this.file_=e,this.rollPeriod_=i.rollPeriod||xh.DEFAULT_ROLL_PERIOD,this.previousVerticalX_=-1,this.fractions_=i.fractions||!1,this.dateWindow_=i.dateWindow||null,this.annotations_=[],t.innerHTML="",""===t.style.width&&i.width&&(t.style.width=i.width+"px"),""===t.style.height&&i.height&&(t.style.height=i.height+"px"),""===t.style.height&&0===t.clientHeight&&(t.style.height=xh.DEFAULT_HEIGHT+"px",""===t.style.width&&(t.style.width=xh.DEFAULT_WIDTH+"px")),this.width_=t.clientWidth||i.width||0,this.height_=t.clientHeight||i.height||0,i.stackedGraph&&(i.fillGraph=!0),this.user_attrs_={},ll(this.user_attrs_,i),this.attrs_={},hl(this.attrs_,Bl),this.boundaryIds_=[],this.setIndexByName_={},this.datasetIndex_=[],this.registeredEvents_=[],this.eventListeners_={},this.attributes_=new Kl(this),this.createInterface_(),this.plugins_=[];for(var s=xh.PLUGINS.concat(this.getOption("plugins")),r=0;r<s.length;r++){var o,a=s[r],n={plugin:o=void 0!==a.activate?a:new a,events:{},options:{},pluginOptions:{}},l=o.activate(this);for(var h in l)l.hasOwnProperty(h)&&(n.events[h]=l[h]);this.plugins_.push(n)}for(r=0;r<this.plugins_.length;r++){var d=this.plugins_[r];for(var h in d.events)if(d.events.hasOwnProperty(h)){var c=d.events[h],p=[d.plugin,c];h in this.eventListeners_?this.eventListeners_[h].push(p):this.eventListeners_[h]=[p]}}this.createDragInterface_(),this.start_()},xh.prototype.cascadeEvents_=function(t,e){if(!(t in this.eventListeners_))return!1;var i={dygraph:this,cancelable:!1,defaultPrevented:!1,preventDefault:function(){if(!i.cancelable)throw"Cannot call preventDefault on non-cancelable event.";i.defaultPrevented=!0},propagationStopped:!1,stopPropagation:function(){i.propagationStopped=!0}};ll(i,e);var s=this.eventListeners_[t];if(s)for(var r=s.length-1;r>=0;r--){var o=s[r][0];if(s[r][1].call(o,i),i.propagationStopped)break}return i.defaultPrevented},xh.prototype.getPluginInstance_=function(t){for(var e=0;e<this.plugins_.length;e++){var i=this.plugins_[e];if(i.plugin instanceof t)return i.plugin}return null},xh.prototype.isZoomed=function(t){const e=!!this.dateWindow_;if("x"===t)return e;const i=this.axes_.map((t=>!!t.valueRange)).indexOf(!0)>=0;if(null==t)return e||i;if("y"===t)return i;throw new Error(`axis parameter is [${t}] must be null, 'x' or 'y'.`)},xh.prototype.toString=function(){var t=this.maindiv_;return"[Dygraph "+(t&&t.id?t.id:t)+"]"},xh.prototype.attr_=function(t,e){return"undefined"!=typeof process&&"production"!=process.env.NODE_ENV&&(void 0===Zl?console.error("Must include options reference JS for testing"):Zl.hasOwnProperty(t)||(console.error("Dygraphs is using property "+t+", which has no entry in the Dygraphs.OPTIONS_REFERENCE listing."),Zl[t]=!0)),e?this.attributes_.getForSeries(t,e):this.attributes_.get(t)},xh.prototype.getOption=function(t,e){return this.attr_(t,e)},xh.prototype.getNumericOption=function(t,e){return this.getOption(t,e)},xh.prototype.getStringOption=function(t,e){return this.getOption(t,e)},xh.prototype.getBooleanOption=function(t,e){return this.getOption(t,e)},xh.prototype.getFunctionOption=function(t,e){return this.getOption(t,e)},xh.prototype.getOptionForAxis=function(t,e){return this.attributes_.getForAxis(t,e)},xh.prototype.optionsViewForAxis_=function(t){var e=this;return function(i){var s=e.user_attrs_.axes;return s&&s[t]&&s[t].hasOwnProperty(i)?s[t][i]:("x"!==t||"logscale"!==i)&&(void 0!==e.user_attrs_[i]?e.user_attrs_[i]:(s=e.attrs_.axes)&&s[t]&&s[t].hasOwnProperty(i)?s[t][i]:"y"==t&&e.axes_[0].hasOwnProperty(i)?e.axes_[0][i]:"y2"==t&&e.axes_[1].hasOwnProperty(i)?e.axes_[1][i]:e.attr_(i))}},xh.prototype.rollPeriod=function(){return this.rollPeriod_},xh.prototype.xAxisRange=function(){return this.dateWindow_?this.dateWindow_:this.xAxisExtremes()},xh.prototype.xAxisExtremes=function(){var t=this.getNumericOption("xRangePad")/this.plotter_.area.w;if(0===this.numRows())return[0-t,1+t];var e=this.rawData_[0][0],i=this.rawData_[this.rawData_.length-1][0];if(t){var s=i-e;e-=s*t,i+=s*t}return[e,i]},xh.prototype.yAxisExtremes=function(){const t=this.gatherDatasets_(this.rolledSeries_,null),{extremes:e}=t,i=this.axes_;this.computeYAxisRanges_(e);const s=this.axes_;return this.axes_=i,s.map((t=>t.extremeRange))},xh.prototype.yAxisRange=function(t){if(void 0===t&&(t=0),t<0||t>=this.axes_.length)return null;var e=this.axes_[t];return[e.computedValueRange[0],e.computedValueRange[1]]},xh.prototype.yAxisRanges=function(){for(var t=[],e=0;e<this.axes_.length;e++)t.push(this.yAxisRange(e));return t},xh.prototype.toDomCoords=function(t,e,i){return[this.toDomXCoord(t),this.toDomYCoord(e,i)]},xh.prototype.toDomXCoord=function(t){if(null===t)return null;var e=this.plotter_.area,i=this.xAxisRange();return e.x+(t-i[0])/(i[1]-i[0])*e.w},xh.prototype.toDomYCoord=function(t,e){var i=this.toPercentYCoord(t,e);if(null===i)return null;var s=this.plotter_.area;return s.y+i*s.h},xh.prototype.toDataCoords=function(t,e,i){return[this.toDataXCoord(t),this.toDataYCoord(e,i)]},xh.prototype.toDataXCoord=function(t){if(null===t)return null;var e=this.plotter_.area,i=this.xAxisRange();if(this.attributes_.getForAxis("logscale","x")){var s=(t-e.x)/e.w;return Bn(i[0],i[1],s)}return i[0]+(t-e.x)/e.w*(i[1]-i[0])},xh.prototype.toDataYCoord=function(t,e){if(null===t)return null;var i=this.plotter_.area,s=this.yAxisRange(e);if(void 0===e&&(e=0),this.attributes_.getForAxis("logscale",e)){var r=(t-i.y)/i.h;return Bn(s[1],s[0],r)}return s[0]+(i.y+i.h-t)/i.h*(s[1]-s[0])},xh.prototype.toPercentYCoord=function(t,e){if(null===t)return null;void 0===e&&(e=0);var i,s=this.yAxisRange(e);if(this.attributes_.getForAxis("logscale",e)){var r=Hn(s[0]),o=Hn(s[1]);i=(o-Hn(t))/(o-r)}else i=(s[1]-t)/(s[1]-s[0]);return i},xh.prototype.toPercentXCoord=function(t){if(null===t)return null;var e,i=this.xAxisRange();if(!0===this.attributes_.getForAxis("logscale","x")){var s=Hn(i[0]),r=Hn(i[1]);e=(Hn(t)-s)/(r-s)}else e=(t-i[0])/(i[1]-i[0]);return e},xh.prototype.numColumns=function(){return this.rawData_?this.rawData_[0]?this.rawData_[0].length:this.attr_("labels").length:0},xh.prototype.numRows=function(){return this.rawData_?this.rawData_.length:0},xh.prototype.getValue=function(t,e){return t<0||t>this.rawData_.length||e<0||e>this.rawData_[t].length?null:this.rawData_[t][e]},xh.prototype.createInterface_=function(){var t=this.maindiv_;this.graphDiv=document.createElement("div"),this.graphDiv.style.textAlign="left",this.graphDiv.style.position="relative",t.appendChild(this.graphDiv),this.canvas_=ul(),this.canvas_.style.position="absolute",this.hidden_=this.createPlotKitCanvas_(this.canvas_),this.canvas_ctx_=Fn(this.canvas_),this.hidden_ctx_=Fn(this.hidden_),this.resizeElements_(),this.graphDiv.appendChild(this.hidden_),this.graphDiv.appendChild(this.canvas_),this.mouseEventElement_=this.createMouseEventElement_(),this.layout_=new Dl(this);var e=this;this.mouseMoveHandler_=function(t){e.mouseMove_(t)},this.mouseOutHandler_=function(t){var i=t.target||t.fromElement,s=t.relatedTarget||t.toElement;_l(i,e.graphDiv)&&!_l(s,e.graphDiv)&&e.mouseOut_(t)},this.addAndTrackEvent(window,"mouseout",this.mouseOutHandler_),this.addAndTrackEvent(this.mouseEventElement_,"mousemove",this.mouseMoveHandler_),this.resizeHandler_||(this.resizeHandler_=function(t){e.resize()},this.addAndTrackEvent(window,"resize",this.resizeHandler_))},xh.prototype.resizeElements_=function(){this.graphDiv.style.width=this.width_+"px",this.graphDiv.style.height=this.height_+"px";var t=this.getNumericOption("pixelRatio"),e=t||gl(this.canvas_ctx_);this.canvas_.width=this.width_*e,this.canvas_.height=this.height_*e,this.canvas_.style.width=this.width_+"px",this.canvas_.style.height=this.height_+"px",1!==e&&this.canvas_ctx_.scale(e,e);var i=t||gl(this.hidden_ctx_);this.hidden_.width=this.width_*i,this.hidden_.height=this.height_*i,this.hidden_.style.width=this.width_+"px",this.hidden_.style.height=this.height_+"px",1!==i&&this.hidden_ctx_.scale(i,i)},xh.prototype.destroy=function(){this.canvas_ctx_.restore(),this.hidden_ctx_.restore();for(var t=this.plugins_.length-1;t>=0;t--){var e=this.plugins_.pop();e.plugin.destroy&&e.plugin.destroy()}var i=function(t){for(;t.hasChildNodes();)i(t.firstChild),t.removeChild(t.firstChild)};this.removeTrackedEvents_(),Yn(window,"mouseout",this.mouseOutHandler_),Yn(this.mouseEventElement_,"mousemove",this.mouseMoveHandler_),Yn(window,"resize",this.resizeHandler_),this.resizeHandler_=null,i(this.maindiv_);var s=function(t){for(var e in t)"object"==typeof t[e]&&(t[e]=null)};s(this.layout_),s(this.plotter_),s(this)},xh.prototype.createPlotKitCanvas_=function(t){var e=ul();return e.style.position="absolute",e.style.top=t.style.top,e.style.left=t.style.left,e.width=this.width_,e.height=this.height_,e.style.width=this.width_+"px",e.style.height=this.height_+"px",e},xh.prototype.createMouseEventElement_=function(){return this.canvas_},xh.prototype.setColors_=function(){var t=this.getLabels(),e=t.length-1;this.colors_=[],this.colorsMap_={};for(var i=this.getNumericOption("colorSaturation")||1,s=this.getNumericOption("colorValue")||.5,r=Math.ceil(e/2),o=this.getOption("colors"),a=this.visibility(),n=0;n<e;n++)if(a[n]){var l=t[n+1],h=this.attributes_.getForSeries("color",l);if(!h)if(o)h=o[n%o.length];else h=Un(1*(n%2?r+(n+1)/2:Math.ceil((n+1)/2))/(1+e),i,s);this.colors_.push(h),this.colorsMap_[l]=h}},xh.prototype.getColors=function(){return this.colors_},xh.prototype.getPropertiesForSeries=function(t){for(var e=-1,i=this.getLabels(),s=1;s<i.length;s++)if(i[s]==t){e=s;break}return-1==e?null:{name:t,column:e,visible:this.visibility()[e-1],color:this.colorsMap_[t],axis:1+this.attributes_.axisForSeries(t)}},xh.prototype.createRollInterface_=function(){var t=this.roller_;t||(this.roller_=t=document.createElement("input"),t.type="text",t.style.display="none",t.className="dygraph-roller",this.graphDiv.appendChild(t));var e=this.getBooleanOption("showRoller")?"block":"none",i=this.getArea(),s={top:i.y+i.h-25+"px",left:i.x+1+"px",display:e};t.size="2",t.value=this.rollPeriod_,ll(t.style,s),t.onchange=()=>this.adjustRoll(t.value)},xh.prototype.createDragInterface_=function(){var t={isZooming:!1,isPanning:!1,is2DPan:!1,dragStartX:null,dragStartY:null,dragEndX:null,dragEndY:null,dragDirection:null,prevEndX:null,prevEndY:null,prevDragDirection:null,cancelNextDblclick:!1,initialLeftmostDate:null,xUnitsPerPixel:null,dateRange:null,px:0,py:0,boundedDates:null,boundedValues:null,tarp:new Ql,initializeMouseDown:function(t,e,i){t.preventDefault?t.preventDefault():(t.returnValue=!1,t.cancelBubble=!0);var s=$n(e.canvas_);i.px=s.x,i.py=s.y,i.dragStartX=qn(t,i),i.dragStartY=Zn(t,i),i.cancelNextDblclick=!1,i.tarp.cover()},destroy:function(){var t=this;if((t.isZooming||t.isPanning)&&(t.isZooming=!1,t.dragStartX=null,t.dragStartY=null),t.isPanning){t.isPanning=!1,t.draggingDate=null,t.dateRange=null;for(var e=0;e<i.axes_.length;e++)delete i.axes_[e].draggingValue,delete i.axes_[e].dragValueRange}t.tarp.uncover()}},e=this.getOption("interactionModel"),i=this,s=function(e){return function(s){e(s,i,t)}};for(var r in e)e.hasOwnProperty(r)&&this.addAndTrackEvent(this.mouseEventElement_,r,s(e[r]));if(!e.willDestroyContextMyself){this.addAndTrackEvent(document,"mouseup",(function(e){t.destroy()}))}},xh.prototype.drawZoomRect_=function(t,e,i,s,r,o,a,n){var l=this.canvas_ctx_;1==o?l.clearRect(Math.min(e,a),this.layout_.getPlotArea().y,Math.abs(e-a),this.layout_.getPlotArea().h):2==o&&l.clearRect(this.layout_.getPlotArea().x,Math.min(s,n),this.layout_.getPlotArea().w,Math.abs(s-n)),1==t?i&&e&&(l.fillStyle="rgba(128,128,128,0.33)",l.fillRect(Math.min(e,i),this.layout_.getPlotArea().y,Math.abs(i-e),this.layout_.getPlotArea().h)):2==t&&r&&s&&(l.fillStyle="rgba(128,128,128,0.33)",l.fillRect(this.layout_.getPlotArea().x,Math.min(s,r),this.layout_.getPlotArea().w,Math.abs(r-s)))},xh.prototype.clearZoomRect_=function(){this.currentZoomRectArgs_=null,this.canvas_ctx_.clearRect(0,0,this.width_,this.height_)},xh.prototype.doZoomX_=function(t,e){this.currentZoomRectArgs_=null;var i=this.toDataXCoord(t),s=this.toDataXCoord(e);this.doZoomXDates_(i,s)},xh.prototype.doZoomXDates_=function(t,e){var i=this.xAxisRange(),s=[t,e];const r=this.getFunctionOption("zoomCallback");this.doAnimatedZoom(i,s,null,null,(()=>{r&&r.call(this,t,e,this.yAxisRanges())}))},xh.prototype.doZoomY_=function(t,e){this.currentZoomRectArgs_=null;for(var i=this.yAxisRanges(),s=[],r=0;r<this.axes_.length;r++){var o=this.toDataYCoord(t,r),a=this.toDataYCoord(e,r);s.push([a,o])}const n=this.getFunctionOption("zoomCallback");this.doAnimatedZoom(null,null,i,s,(()=>{if(n){const[t,e]=this.xAxisRange();n.call(this,t,e,this.yAxisRanges())}}))},xh.zoomAnimationFunction=function(t,e){return(1-Math.pow(1.5,-t))/(1-Math.pow(1.5,-e))},xh.prototype.resetZoom=function(){const t=this.isZoomed("x"),e=this.isZoomed("y"),i=t||e;if(this.clearSelection(),!i)return;const[s,r]=this.xAxisExtremes(),o=this.getBooleanOption("animatedZooms"),a=this.getFunctionOption("zoomCallback");if(!o)return this.dateWindow_=null,this.axes_.forEach((t=>{t.valueRange&&delete t.valueRange})),this.drawGraph_(),void(a&&a.call(this,s,r,this.yAxisRanges()));var n=null,l=null,h=null,d=null;t&&(n=this.xAxisRange(),l=[s,r]),e&&(h=this.yAxisRanges(),d=this.yAxisExtremes()),this.doAnimatedZoom(n,l,h,d,(()=>{this.dateWindow_=null,this.axes_.forEach((t=>{t.valueRange&&delete t.valueRange})),a&&a.call(this,s,r,this.yAxisRanges())}))},xh.prototype.doAnimatedZoom=function(t,e,i,s,r){var o,a,n=this.getBooleanOption("animatedZooms")?xh.ANIMATION_STEPS:1,l=[],h=[];if(null!==t&&null!==e)for(o=1;o<=n;o++)a=xh.zoomAnimationFunction(o,n),l[o-1]=[t[0]*(1-a)+a*e[0],t[1]*(1-a)+a*e[1]];if(null!==i&&null!==s)for(o=1;o<=n;o++){a=xh.zoomAnimationFunction(o,n);for(var d=[],c=0;c<this.axes_.length;c++)d.push([i[c][0]*(1-a)+a*s[c][0],i[c][1]*(1-a)+a*s[c][1]]);h[o-1]=d}xl((t=>{if(h.length)for(var e=0;e<this.axes_.length;e++){var i=h[t][e];this.axes_[e].valueRange=[i[0],i[1]]}l.length&&(this.dateWindow_=l[t]),this.drawGraph_()}),n,xh.ANIMATION_DURATION/n,r)},xh.prototype.getArea=function(){return this.plotter_.area},xh.prototype.eventToDomCoords=function(t){if(t.offsetX&&t.offsetY)return[t.offsetX,t.offsetY];var e=$n(this.mouseEventElement_);return[jn(t)-e.x,Xn(t)-e.y]},xh.prototype.findClosestRow=function(t){for(var e=1/0,i=-1,s=this.layout_.points,r=0;r<s.length;r++)for(var o=s[r],a=o.length,n=0;n<a;n++){var l=o[n];if(Kn(l,!0)){var h=Math.abs(l.canvasx-t);h<e&&(e=h,i=l.idx)}}return i},xh.prototype.findClosestPoint=function(t,e){for(var i,s,r,o,a,n,l,h=1/0,d=this.layout_.points.length-1;d>=0;--d)for(var c=this.layout_.points[d],p=0;p<c.length;++p)Kn(o=c[p])&&(i=(s=o.canvasx-t)*s+(r=o.canvasy-e)*r)<h&&(h=i,a=o,n=d,l=o.idx);return{row:l,seriesName:this.layout_.setNames[n],point:a}},xh.prototype.findStackedPoint=function(t,e){for(var i,s,r=this.findClosestRow(t),o=0;o<this.layout_.points.length;++o){var a=r-this.getLeftBoundary_(o),n=this.layout_.points[o];if(!(a>=n.length)){var l=n[a];if(Kn(l)){var h=l.canvasy;if(t>l.canvasx&&a+1<n.length){var d=n[a+1];if(Kn(d))if((c=d.canvasx-l.canvasx)>0)h+=(t-l.canvasx)/c*(d.canvasy-l.canvasy)}else if(t<l.canvasx&&a>0){var c,p=n[a-1];if(Kn(p))if((c=l.canvasx-p.canvasx)>0)h+=(l.canvasx-t)/c*(p.canvasy-l.canvasy)}(0===o||h<e)&&(i=l,s=o)}}}return{row:r,seriesName:this.layout_.setNames[s],point:i}},xh.prototype.mouseMove_=function(t){var e=this.layout_.points;if(null!=e){var i=this.eventToDomCoords(t),s=i[0],r=i[1],o=!1;if(this.getOption("highlightSeriesOpts")&&!this.isSeriesLocked()){var a;a=this.getBooleanOption("stackedGraph")?this.findStackedPoint(s,r):this.findClosestPoint(s,r),o=this.setSelection(a.row,a.seriesName)}else{var n=this.findClosestRow(s);o=this.setSelection(n)}var l=this.getFunctionOption("highlightCallback");l&&o&&l.call(this,t,this.lastx_,this.selPoints_,this.lastRow_,this.highlightSet_)}},xh.prototype.getLeftBoundary_=function(t){if(this.boundaryIds_[t])return this.boundaryIds_[t][0];for(var e=0;e<this.boundaryIds_.length;e++)if(void 0!==this.boundaryIds_[e])return this.boundaryIds_[e][0];return 0},xh.prototype.animateSelection_=function(t){void 0===this.fadeLevel&&(this.fadeLevel=0),void 0===this.animateId&&(this.animateId=0);var e=this.fadeLevel,i=t<0?e:10-e;if(i<=0)this.fadeLevel&&this.updateSelection_(1);else{var s=++this.animateId,r=this;xl((function(e){r.animateId==s&&(r.fadeLevel+=t,0===r.fadeLevel?r.clearSelection():r.updateSelection_(r.fadeLevel/10))}),i,30,(function(){0!==r.fadeLevel&&t<0&&(r.fadeLevel=0,r.clearSelection())}))}},xh.prototype.updateSelection_=function(t){var e;this.cascadeEvents_("select",{selectedRow:-1===this.lastRow_?void 0:this.lastRow_,selectedX:-1===this.lastx_?void 0:this.lastx_,selectedPoints:this.selPoints_});var i=this.canvas_ctx_;if(this.getOption("highlightSeriesOpts")){i.clearRect(0,0,this.width_,this.height_);var s=1-this.getNumericOption("highlightSeriesBackgroundAlpha"),r=Ll(this.getOption("highlightSeriesBackgroundColor"));if(s){if(void 0===t)return void this.animateSelection_(1);s*=t,i.fillStyle="rgba("+r.r+","+r.g+","+r.b+","+s+")",i.fillRect(0,0,this.width_,this.height_)}this.plotter_._renderLineChart(this.highlightSet_,i)}else if(this.previousVerticalX_>=0){var o=0,a=this.attr_("labels");for(e=1;e<a.length;e++){var n=this.getNumericOption("highlightCircleSize",a[e]);n>o&&(o=n)}var l=this.previousVerticalX_;i.clearRect(l-o-1,0,2*o+2,this.height_)}if(this.selPoints_.length>0){var h=this.selPoints_[0].canvasx;for(i.save(),e=0;e<this.selPoints_.length;e++){var d=this.selPoints_[e];if(!isNaN(d.canvasy)){var c=this.getNumericOption("highlightCircleSize",d.name),p=this.getFunctionOption("drawHighlightPointCallback",d.name),u=this.plotter_.colors[d.name];p||(p=wl.DEFAULT),i.lineWidth=this.getNumericOption("strokeWidth",d.name),i.strokeStyle=u,i.fillStyle=u,p.call(this,this,d.name,i,h,d.canvasy,u,c,d.idx)}}i.restore(),this.previousVerticalX_=h}},xh.prototype.setSelection=function(t,e,i){this.selPoints_=[];var s=!1;if(!1!==t&&t>=0){t!=this.lastRow_&&(s=!0),this.lastRow_=t;for(var r=0;r<this.layout_.points.length;++r){var o=this.layout_.points[r],a=t-this.getLeftBoundary_(r);if(a>=0&&a<o.length&&o[a].idx==t)null!==(l=o[a]).yval&&this.selPoints_.push(l);else for(var n=0;n<o.length;++n){var l;if((l=o[n]).idx==t){null!==l.yval&&this.selPoints_.push(l);break}}}}else this.lastRow_>=0&&(s=!0),this.lastRow_=-1;return this.selPoints_.length?this.lastx_=this.selPoints_[0].xval:this.lastx_=-1,void 0!==e&&(this.highlightSet_!==e&&(s=!0),this.highlightSet_=e),void 0!==i&&(this.lockedSet_=i),s&&this.updateSelection_(void 0),s},xh.prototype.mouseOut_=function(t){this.getFunctionOption("unhighlightCallback")&&this.getFunctionOption("unhighlightCallback").call(this,t),this.getBooleanOption("hideOverlayOnMouseOut")&&!this.lockedSet_&&this.clearSelection()},xh.prototype.clearSelection=function(){this.cascadeEvents_("deselect",{}),this.lockedSet_=!1,this.fadeLevel?this.animateSelection_(-1):(this.canvas_ctx_.clearRect(0,0,this.width_,this.height_),this.fadeLevel=0,this.selPoints_=[],this.lastx_=-1,this.lastRow_=-1,this.highlightSet_=null)},xh.prototype.getSelection=function(){if(!this.selPoints_||this.selPoints_.length<1)return-1;for(var t=0;t<this.layout_.points.length;t++)for(var e=this.layout_.points[t],i=0;i<e.length;i++)if(e[i].x==this.selPoints_[0].x)return e[i].idx;return-1},xh.prototype.getHighlightSeries=function(){return this.highlightSet_},xh.prototype.isSeriesLocked=function(){return this.lockedSet_},xh.prototype.loadedEvent_=function(t){this.rawData_=this.parseCSV_(t),this.cascadeDataDidUpdateEvent_(),this.predraw_()},xh.prototype.addXTicks_=function(){var t;t=this.dateWindow_?[this.dateWindow_[0],this.dateWindow_[1]]:this.xAxisExtremes();var e=this.optionsViewForAxis_("x"),i=e("ticker")(t[0],t[1],this.plotter_.area.w,e,this);this.layout_.setXTicks(i)},xh.prototype.getHandlerClass_=function(){return this.attr_("dataHandler")?this.attr_("dataHandler"):this.fractions_?this.getBooleanOption("errorBars")?nh:ah:this.getBooleanOption("customBars")?oh:this.getBooleanOption("errorBars")?rh:ih},xh.prototype.predraw_=function(){var t=new Date;this.dataHandler_=new(this.getHandlerClass_()),this.layout_.computePlotArea(),this.computeYAxes_(),this.is_initial_draw_||(this.canvas_ctx_.restore(),this.hidden_ctx_.restore()),this.canvas_ctx_.save(),this.hidden_ctx_.save(),this.plotter_=new Il(this,this.hidden_,this.hidden_ctx_,this.layout_),this.createRollInterface_(),this.cascadeEvents_("predraw"),this.rolledSeries_=[null];for(var e=1;e<this.numColumns();e++){var i=this.dataHandler_.extractSeries(this.rawData_,e,this.attributes_);this.rollPeriod_>1&&(i=this.dataHandler_.rollingAverage(i,this.rollPeriod_,this.attributes_)),this.rolledSeries_.push(i)}this.drawGraph_();var s=new Date;this.drawingTimeMs_=s-t},xh.PointType=void 0,xh.stackPoints_=function(t,e,i,s){for(var r=null,o=null,a=null,n=-1,l=function(e){if(!(n>=e))for(var i=e;i<t.length;++i)if(a=null,!isNaN(t[i].yval)&&null!==t[i].yval){n=i,a=t[i];break}},h=0;h<t.length;++h){var d=t[h],c=d.xval;void 0===e[c]&&(e[c]=0);var p=d.yval;isNaN(p)||null===p?"none"==s?p=0:(l(h),p=o&&a&&"none"!=s?o.yval+(a.yval-o.yval)*((c-o.xval)/(a.xval-o.xval)):o&&"all"==s?o.yval:a&&"all"==s?a.yval:0):o=d;var u=e[c];r!=c&&(u+=p,e[c]=u),r=c,d.yval_stacked=u,u>i[1]&&(i[1]=u),u<i[0]&&(i[0]=u)}},xh.prototype.gatherDatasets_=function(t,e){var i,s,r,o,a,n,l=[],h=[],d=[],c={};for(i=t.length-1;i>=1;i--)if(this.visibility()[i-1]){if(e){n=t[i];var p=e[0],u=e[1];for(r=null,o=null,s=0;s<n.length;s++)n[s][0]>=p&&null===r&&(r=s),n[s][0]<=u&&(o=s);null===r&&(r=0);for(var g=r,f=!0;f&&g>0;)f=null===n[--g][1];null===o&&(o=n.length-1);var m=o;for(f=!0;f&&m<n.length-1;)f=null===n[++m][1];g!==r&&(r=g),m!==o&&(o=m),l[i-1]=[r,o],n=n.slice(r,o+1)}else n=t[i],l[i-1]=[0,n.length-1];var y=this.attr_("labels")[i],x=this.dataHandler_.getExtremeYValues(n,e,this.getBooleanOption("stepPlot",y)),v=this.dataHandler_.seriesToPoints(n,y,l[i-1][0]);this.getBooleanOption("stackedGraph")&&(void 0===d[a=this.attributes_.axisForSeries(y)]&&(d[a]=[]),xh.stackPoints_(v,d[a],x,this.getBooleanOption("stackedGraphNaNFill"))),c[y]=x,h[i]=v}return{points:h,extremes:c,boundaryIds:l}},xh.prototype.drawGraph_=function(){var t=new Date,e=this.is_initial_draw_;this.is_initial_draw_=!1,this.layout_.removeAllDatasets(),this.setColors_(),this.attrs_.pointSize=.5*this.getNumericOption("highlightCircleSize");var i=this.gatherDatasets_(this.rolledSeries_,this.dateWindow_),s=i.points,r=i.extremes;this.boundaryIds_=i.boundaryIds,this.setIndexByName_={};for(var o=this.attr_("labels"),a=0,n=1;n<s.length;n++)this.visibility()[n-1]&&(this.layout_.addDataset(o[n],s[n]),this.datasetIndex_[n]=a++);for(n=0;n<o.length;n++)this.setIndexByName_[o[n]]=n;if(this.computeYAxisRanges_(r),this.layout_.setYAxes(this.axes_),this.addXTicks_(),this.layout_.evaluate(),this.renderGraph_(e),this.getStringOption("timingName")){var l=new Date;console.log(this.getStringOption("timingName")+" - drawGraph: "+(l-t)+"ms")}},xh.prototype.renderGraph_=function(t){this.cascadeEvents_("clearChart"),this.plotter_.clear();const e=this.getFunctionOption("underlayCallback");e&&e.call(this,this.hidden_ctx_,this.layout_.getPlotArea(),this,this);var i={canvas:this.hidden_,drawingContext:this.hidden_ctx_};this.cascadeEvents_("willDrawChart",i),this.plotter_.render(),this.cascadeEvents_("didDrawChart",i),this.lastRow_=-1,this.canvas_.getContext("2d").clearRect(0,0,this.width_,this.height_);const s=this.getFunctionOption("drawCallback");if(null!==s&&s.call(this,this,t),t)for(this.readyFired_=!0;this.readyFns_.length>0;){this.readyFns_.pop()(this)}},xh.prototype.computeYAxes_=function(){var t,e,i;for(this.axes_=[],t=0;t<this.attributes_.numAxes();t++)ll(e={g:this},this.attributes_.axisOptions(t)),this.axes_[t]=e;for(t=0;t<this.axes_.length;t++)if(0===t)(i=(e=this.optionsViewForAxis_("y"+(t?"2":"")))("valueRange"))&&(this.axes_[t].valueRange=i);else{var s=this.user_attrs_.axes;s&&s.y2&&(i=s.y2.valueRange)&&(this.axes_[t].valueRange=i)}},xh.prototype.numAxes=function(){return this.attributes_.numAxes()},xh.prototype.axisPropertiesForSeries=function(t){return this.axes_[this.attributes_.axisForSeries(t)]},xh.prototype.computeYAxisRanges_=function(t){for(var e,i,s,r,o,a=function(t){return isNaN(parseFloat(t))},n=this.attributes_.numAxes(),l=0;l<n;l++){var h=this.axes_[l],d=this.attributes_.getForAxis("logscale",l),c=this.attributes_.getForAxis("includeZero",l),p=this.attributes_.getForAxis("independentTicks",l);s=this.attributes_.seriesForAxis(l),e=!0,r=.1;const n=this.getNumericOption("yRangePad");if(null!==n&&(e=!1,r=n/this.plotter_.area.h),0===s.length)h.extremeRange=[0,1];else{for(var u,g,f=1/0,m=-1/0,y=0;y<s.length;y++)t.hasOwnProperty(s[y])&&(null!==(u=t[s[y]][0])&&(f=Math.min(u,f)),null!==(g=t[s[y]][1])&&(m=Math.max(g,m)));c&&!d&&(f>0&&(f=0),m<0&&(m=0)),f==1/0&&(f=0),m==-1/0&&(m=1),0===(i=m-f)&&(0!==m?i=Math.abs(m):(m=1,i=1));var x=m,v=f;e&&(d?(x=m+r*i,v=f):((v=f-r*i)<0&&f>=0&&(v=0),(x=m+r*i)>0&&m<=0&&(x=0))),h.extremeRange=[v,x]}if(h.valueRange){var w=a(h.valueRange[0])?h.extremeRange[0]:h.valueRange[0],b=a(h.valueRange[1])?h.extremeRange[1]:h.valueRange[1];h.computedValueRange=[w,b]}else h.computedValueRange=h.extremeRange;if(!e)if(d){w=h.computedValueRange[0],b=h.computedValueRange[1];var _=r/(2*r-1),S=(r-1)/(2*r-1);h.computedValueRange[0]=Bn(w,b,_),h.computedValueRange[1]=Bn(w,b,S)}else w=h.computedValueRange[0],i=(b=h.computedValueRange[1])-w,h.computedValueRange[0]=w-i*r,h.computedValueRange[1]=b+i*r;if(p){h.independentTicks=p;var T=(C=this.optionsViewForAxis_("y"+(l?"2":"")))("ticker");h.ticks=T(h.computedValueRange[0],h.computedValueRange[1],this.plotter_.area.h,C,this),o||(o=h)}}if(void 0===o)throw'Configuration Error: At least one axis has to have the "independentTicks" option activated.';for(l=0;l<n;l++){if(!(h=this.axes_[l]).independentTicks){T=(C=this.optionsViewForAxis_("y"+(l?"2":"")))("ticker");for(var C,L=o.ticks,A=o.computedValueRange[1]-o.computedValueRange[0],k=h.computedValueRange[1]-h.computedValueRange[0],P=[],R=0;R<L.length;R++){var E=(L[R].v-o.computedValueRange[0])/A,M=h.computedValueRange[0]+E*k;P.push(M)}h.ticks=T(h.computedValueRange[0],h.computedValueRange[1],this.plotter_.area.h,C,this,P)}}},xh.prototype.detectTypeFromString_=function(t){var e=!1,i=t.indexOf("-");(i>0&&"e"!=t[i-1]&&"E"!=t[i-1]||t.indexOf("/")>=0||isNaN(parseFloat(t))||8==t.length&&t>"19700101"&&t<"20371231")&&(e=!0),this.setXAxisOptions_(e)},xh.prototype.setXAxisOptions_=function(t){t?(this.attrs_.xValueParser=al,this.attrs_.axes.x.valueFormatter=Nl,this.attrs_.axes.x.ticker=_n,this.attrs_.axes.x.axisLabelFormatter=Ol):(this.attrs_.xValueParser=function(t){return parseFloat(t)},this.attrs_.axes.x.valueFormatter=function(t){return t},this.attrs_.axes.x.ticker=bn,this.attrs_.axes.x.axisLabelFormatter=this.attrs_.axes.x.valueFormatter)},xh.prototype.parseCSV_=function(t){var e,i,s=[],r=bl(t),o=t.split(r||"\n"),a=this.getStringOption("delimiter");-1==o[0].indexOf(a)&&o[0].indexOf("\t")>=0&&(a="\t");var n,l=0;"labels"in this.user_attrs_||(l=1,this.attrs_.labels=o[0].split(a),this.attributes_.reparseSeries());for(var h=!1,d=this.attr_("labels").length,c=!1,p=l;p<o.length;p++){var u=o[p];if(0!==u.length&&"#"!=u[0]){var g=u.split(a);if(!(g.length<2)){var f=[];if(h||(this.detectTypeFromString_(g[0]),n=this.getFunctionOption("xValueParser"),h=!0),f[0]=n(g[0],this),this.fractions_)for(i=1;i<g.length;i++)2!=(e=g[i].split("/")).length?(console.error('Expected fractional "num/den" values in CSV data but found a value \''+g[i]+"' on line "+(1+p)+" ('"+u+"') which is not of this form."),f[i]=[0,0]):f[i]=[Al(e[0],p,u),Al(e[1],p,u)];else if(this.getBooleanOption("errorBars"))for(g.length%2!=1&&console.error("Expected alternating (value, stdev.) pairs in CSV data but line "+(1+p)+" has an odd number of values ("+(g.length-1)+"): '"+u+"'"),i=1;i<g.length;i+=2)f[(i+1)/2]=[Al(g[i],p,u),Al(g[i+1],p,u)];else if(this.getBooleanOption("customBars"))for(i=1;i<g.length;i++){var m=g[i];/^ *$/.test(m)?f[i]=[null,null,null]:3==(e=m.split(";")).length?f[i]=[Al(e[0],p,u),Al(e[1],p,u),Al(e[2],p,u)]:console.warn('When using customBars, values must be either blank or "low;center;high" tuples (got "'+m+'" on line '+(1+p))}else for(i=1;i<g.length;i++)f[i]=Al(g[i],p,u);if(s.length>0&&f[0]<s[s.length-1][0]&&(c=!0),f.length!=d&&console.error("Number of columns in line "+p+" ("+f.length+") does not agree with number of labels ("+d+") "+u),0===p&&this.attr_("labels")){var y=!0;for(i=0;y&&i<f.length;i++)f[i]&&(y=!1);if(y){console.warn("The dygraphs 'labels' option is set, but the first row of CSV data ('"+u+"') appears to also contain labels. Will drop the CSV labels and use the option labels.");continue}}s.push(f)}}}return c&&(console.warn("CSV is out of order; order it correctly to speed loading."),s.sort((function(t,e){return t[0]-e[0]}))),s},xh.prototype.parseArray_=function(t){if(0===t.length)return console.error("Can't plot empty data set"),null;if(0===t[0].length)return console.error("Data set cannot contain an empty row"),null;var e;if(function(t){const e=t[0],i=e[0];if("number"!=typeof i&&!cl(i))throw new Error(`Expected number or date but got ${typeof i}: ${i}.`);for(let t=1;t<e.length;t++){const i=e[t];if(null!=i&&"number"!=typeof i&&!dl(i))throw new Error(`Expected number or array but got ${typeof i}: ${i}.`)}}(t),null===this.attr_("labels")){for(console.warn("Using default labels. Set labels explicitly via 'labels' in the options parameter"),this.attrs_.labels=["X"],e=1;e<t[0].length;e++)this.attrs_.labels.push("Y"+e);this.attributes_.reparseSeries()}else{var i=this.attr_("labels");if(i.length!=t[0].length)return console.error("Mismatch between number of labels ("+i+") and number of columns in array ("+t[0].length+")"),null}if(cl(t[0][0])){this.attrs_.axes.x.valueFormatter=Nl,this.attrs_.axes.x.ticker=_n,this.attrs_.axes.x.axisLabelFormatter=Ol;var s=pl(t);for(e=0;e<t.length;e++){if(0===s[e].length)return console.error("Row "+(1+e)+" of data is empty"),null;if(null===s[e][0]||"function"!=typeof s[e][0].getTime||isNaN(s[e][0].getTime()))return console.error("x value in row "+(1+e)+" is not a Date"),null;s[e][0]=s[e][0].getTime()}return s}return this.attrs_.axes.x.valueFormatter=function(t){return t},this.attrs_.axes.x.ticker=bn,this.attrs_.axes.x.axisLabelFormatter=Ml,t},xh.prototype.parseDataTable_=function(t){var e=function(t){var e=String.fromCharCode(65+t%26);for(t=Math.floor(t/26);t>0;)e=String.fromCharCode(65+(t-1)%26)+e.toLowerCase(),t=Math.floor((t-1)/26);return e},i=t.getNumberOfColumns(),s=t.getNumberOfRows(),r=t.getColumnType(0);if("date"==r||"datetime"==r)this.attrs_.xValueParser=al,this.attrs_.axes.x.valueFormatter=Nl,this.attrs_.axes.x.ticker=_n,this.attrs_.axes.x.axisLabelFormatter=Ol;else{if("number"!=r)throw new Error("only 'date', 'datetime' and 'number' types are supported for column 1 of DataTable input (Got '"+r+"')");this.attrs_.xValueParser=function(t){return parseFloat(t)},this.attrs_.axes.x.valueFormatter=function(t){return t},this.attrs_.axes.x.ticker=bn,this.attrs_.axes.x.axisLabelFormatter=this.attrs_.axes.x.valueFormatter}var o,a,n=[],l={},h=!1;for(o=1;o<i;o++){var d=t.getColumnType(o);if("number"==d)n.push(o);else{if("string"!=d||!this.getBooleanOption("displayAnnotations"))throw new Error("Only 'number' is supported as a dependent type with Gviz. 'string' is only supported if displayAnnotations is true");var c=n[n.length-1];l.hasOwnProperty(c)?l[c].push(o):l[c]=[o],h=!0}}var p=[t.getColumnLabel(0)];for(o=0;o<n.length;o++)p.push(t.getColumnLabel(n[o])),this.getBooleanOption("errorBars")&&(o+=1);this.attrs_.labels=p,i=p.length;var u=[],g=!1,f=[];for(o=0;o<s;o++){var m=[];if(void 0!==t.getValue(o,0)&&null!==t.getValue(o,0)){if("date"==r||"datetime"==r?m.push(t.getValue(o,0).getTime()):m.push(t.getValue(o,0)),this.getBooleanOption("errorBars"))for(a=0;a<i-1;a++)m.push([t.getValue(o,1+2*a),t.getValue(o,2+2*a)]);else{for(a=0;a<n.length;a++){var y=n[a];if(m.push(t.getValue(o,y)),h&&l.hasOwnProperty(y)&&null!==t.getValue(o,l[y][0])){var x={};x.series=t.getColumnLabel(y),x.xval=m[0],x.shortText=e(f.length),x.text="";for(var v=0;v<l[y].length;v++)v&&(x.text+="\n"),x.text+=t.getValue(o,l[y][v]);f.push(x)}}for(a=0;a<m.length;a++)isFinite(m[a])||(m[a]=null)}u.length>0&&m[0]<u[u.length-1][0]&&(g=!0),u.push(m)}else console.warn("Ignoring row "+o+" of DataTable because of undefined or null first column.")}g&&(console.warn("DataTable is out of order; order it correctly to speed loading."),u.sort((function(t,e){return t[0]-e[0]}))),this.rawData_=u,f.length>0&&this.setAnnotations(f,!0),this.attributes_.reparseSeries()},xh.prototype.cascadeDataDidUpdateEvent_=function(){this.cascadeEvents_("dataDidUpdate",{})},xh.prototype.start_=function(){var t=this.file_;if("function"==typeof t&&(t=t()),dl(t))this.rawData_=this.parseArray_(t),this.cascadeDataDidUpdateEvent_(),this.predraw_();else if("object"==typeof t&&"function"==typeof t.getColumnRange)this.parseDataTable_(t),this.cascadeDataDidUpdateEvent_(),this.predraw_();else if("string"==typeof t){if(bl(t))this.loadedEvent_(t);else{var e;e=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");var i=this;e.onreadystatechange=function(){4==e.readyState&&(200!==e.status&&0!==e.status||i.loadedEvent_(e.responseText))},e.open("GET",t,!0),e.send(null)}}else console.error("Unknown data format: "+typeof t)},xh.prototype.updateOptions=function(t,e){void 0===e&&(e=!1);var i=t.file,s=xh.copyUserAttrs_(t);"rollPeriod"in s&&(this.rollPeriod_=s.rollPeriod),"dateWindow"in s&&(this.dateWindow_=s.dateWindow);var r=function(t,e){var i={};if(t)for(var s=1;s<t.length;s++)i[t[s]]=!0;var r=function(t){for(var e in t)if(t.hasOwnProperty(e)&&!vl[e])return!0;return!1};for(var o in e)if(e.hasOwnProperty(o))if("highlightSeriesOpts"==o||i[o]&&!e.series){if(r(e[o]))return!0}else if("series"==o||"axes"==o){var a=e[o];for(var n in a)if(a.hasOwnProperty(n)&&r(a[n]))return!0}else if(!vl[o])return!0;return!1}(this.attr_("labels"),s);hl(this.user_attrs_,s),this.attributes_.reparseSeries(),i?(this.cascadeEvents_("dataWillUpdate",{}),this.file_=i,e||this.start_()):e||(r?this.predraw_():this.renderGraph_(!1))},xh.copyUserAttrs_=function(t){var e={};for(var i in t)t.hasOwnProperty(i)&&"file"!=i&&t.hasOwnProperty(i)&&(e[i]=t[i]);return e},xh.prototype.resize=function(t,e){if(!this.resize_lock){this.resize_lock=!0,null===t!=(null===e)&&(console.warn("Dygraph.resize() should be called with zero parameters or two non-NULL parameters. Pretending it was zero."),t=e=null);var i=this.width_,s=this.height_;t?(this.maindiv_.style.width=t+"px",this.maindiv_.style.height=e+"px",this.width_=t,this.height_=e):(this.width_=this.maindiv_.clientWidth,this.height_=this.maindiv_.clientHeight),i==this.width_&&s==this.height_||(this.resizeElements_(),this.predraw_()),this.resize_lock=!1}},xh.prototype.adjustRoll=function(t){this.rollPeriod_=t,this.predraw_()},xh.prototype.visibility=function(){for(this.getOption("visibility")||(this.attrs_.visibility=[]);this.getOption("visibility").length<this.numColumns()-1;)this.attrs_.visibility.push(!0);return this.getOption("visibility")},xh.prototype.setVisibility=function(t,e){var i=this.visibility(),s=!1;if(Array.isArray(t)||(null!==t&&"object"==typeof t?s=!0:t=[t]),s)for(var r in t)t.hasOwnProperty(r)&&(r<0||r>=i.length?console.warn("Invalid series number in setVisibility: "+r):i[r]=t[r]);else for(r=0;r<t.length;r++)"boolean"==typeof t[r]?r>=i.length?console.warn("Invalid series number in setVisibility: "+r):i[r]=t[r]:t[r]<0||t[r]>=i.length?console.warn("Invalid series number in setVisibility: "+t[r]):i[t[r]]=e;this.predraw_()},xh.prototype.size=function(){return{width:this.width_,height:this.height_}},xh.prototype.setAnnotations=function(t,e){this.annotations_=t,this.layout_?(this.layout_.setAnnotations(this.annotations_),e||this.predraw_()):console.warn("Tried to setAnnotations before dygraph was ready. Try setting them in a ready() block. See dygraphs.com/tests/annotation.html")},xh.prototype.annotations=function(){return this.annotations_},xh.prototype.getLabels=function(){var t=this.attr_("labels");return t?t.slice():null},xh.prototype.indexFromSetName=function(t){return this.setIndexByName_[t]},xh.prototype.getRowForX=function(t){for(var e=0,i=this.numRows()-1;e<=i;){var s=i+e>>1,r=this.getValue(s,0);if(r<t)e=s+1;else if(r>t)i=s-1;else{if(e==s)return s;i=s}}return null},xh.prototype.ready=function(t){this.is_initial_draw_?this.readyFns_.push(t):t.call(this,this)},xh.prototype.addAndTrackEvent=function(t,e,i){Gn(t,e,i),this.registeredEvents_.push({elem:t,type:e,fn:i})},xh.prototype.removeTrackedEvents_=function(){if(this.registeredEvents_)for(var t=0;t<this.registeredEvents_.length;t++){var e=this.registeredEvents_[t];Yn(e.elem,e.type,e.fn)}this.registeredEvents_=[]},xh.PLUGINS=[gh,hh,mh,dh,lh,uh],xh.GVizChart=yh,xh.DASHED_LINE=[7,3],xh.DOT_DASH_LINE=[7,2,2,2],xh.dateAxisLabelFormatter=Ol,xh.toRGB_=Ll,xh.findPos=$n,xh.pageX=jn,xh.pageY=Xn,xh.dateString_=sl,xh.defaultInteractionModel=Wl.defaultModel,xh.nonInteractiveModel=xh.nonInteractiveModel_=Wl.nonInteractiveModel_,xh.Circles=wl,xh.Plugins={Legend:gh,Axes:hh,Annotations:lh,ChartLabels:dh,Grid:uh,RangeSelector:mh},xh.DataHandlers={DefaultHandler:ih,BarsHandler:sh,CustomBarsHandler:oh,DefaultFractionHandler:ah,ErrorBarsHandler:rh,FractionsBarsHandler:nh},xh.startPan=Wl.startPan,xh.startZoom=Wl.startZoom,xh.movePan=Wl.movePan,xh.moveZoom=Wl.moveZoom,xh.endPan=Wl.endPan,xh.endZoom=Wl.endZoom,xh.numericLinearTicks=function(t,e,i,s,r,o){return bn(t,e,i,(function(t){return"logscale"!==t&&s(t)}),r,o)},xh.numericTicks=bn,xh.dateTicker=_n,xh.Granularity=Sn,xh.getDateAxis=Dn,xh.floatFormat=Jn;class vh{constructor(t){this.pointer=0,this.buf=Array(t).fill(void 0)}push(t){this.buf[this.pointer]=t,this.pointer=(this.pointer+1)%this.buf.length}snapshot(){return this.buf.filter((t=>void 0!==t)).sort(((t,e)=>t[0].getTime()-e[0].getTime()))}}const wh="axis_count",bh="plot_area_background_color",_h="show_plot_area_border",Sh="title",Th="title_font",Ch="trace_count";let Lh=0;class Ah extends te{constructor(t,e){super(t,e),this.axisDataSet=[],this.traceDataSet=[],this.initialized=!1,this.properties.add(new W(wh)),this.properties.add(new F(bh)),this.properties.add(new B(_h)),this.properties.add(new I(Sh)),this.properties.add(new G(Th)),this.properties.add(new W(Ch)),this.containerId="xygraph"+Lh++,this.containerEl=document.createElement("div"),this.containerEl.id=this.containerId,this.containerEl.style.position="absolute",this.containerEl.style.lineHeight="normal",this.graphEl=document.createElement("div"),this.graphEl.style.backgroundColor=this.backgroundColor.toString(),this.containerEl.appendChild(this.graphEl),this.styleEl=document.createElement("style"),this.containerEl.appendChild(this.styleEl),this.display.rootPanel.appendChild(this.containerEl),this.scaleListener=()=>{this.destroyGraph(),this.graphEl=document.createElement("div"),this.graphEl.style.backgroundColor=this.backgroundColor.toString(),this.containerEl.appendChild(this.graphEl),this.requestRepaint()},this.display.addEventListener("scale",this.scaleListener)}parseNode(t){super.parseNode(t);for(let e=0;e<this.axisCount;e++){const i=new F(`axis_${e}_axis_color`);i.value=t.getColor(`axis_${e}_axis_color`),this.properties.add(i);const s=new F(`axis_${e}_grid_color`);s.value=t.getColor(`axis_${e}_grid_color`),this.properties.add(s);const r=new I(`axis_${e}_axis_title`);r.value=t.getString(`axis_${e}_axis_title`),this.properties.add(r);const o=new G(`axis_${e}_scale_font`);o.value=t.getFont(`axis_${e}_scale_font`),this.properties.add(o);const a=new G(`axis_${e}_title_font`);a.value=t.getFont(`axis_${e}_title_font`),this.properties.add(a);const n=new H(`axis_${e}_minimum`);n.value=t.getFloat(`axis_${e}_minimum`),this.properties.add(n);const l=new H(`axis_${e}_maximum`);l.value=t.getFloat(`axis_${e}_maximum`),this.properties.add(l);const h=new B(`axis_${e}_log_scale`);h.value=t.getBoolean(`axis_${e}_log_scale`),this.properties.add(h);const d=new B(`axis_${e}_auto_scale`);d.value=t.getBoolean(`axis_${e}_auto_scale`),this.properties.add(d);const c=new W(`axis_${e}_time_format`);c.value=t.getInt(`axis_${e}_time_format`),this.properties.add(c);const p=new B(`axis_${e}_dash_grid_line`);p.value=t.getBoolean(`axis_${e}_dash_grid_line`),this.properties.add(p),this.axisDataSet.push({axisTitle:r.value,axisColor:i.value,gridColor:s.value,minimum:n.value,maximum:l.value,logScale:h.value,autoScale:d.value,timeFormat:c.value,dashGridLine:p.value,scaleFont:o.value,titleFont:a.value})}for(let e=0;e<this.traceCount;e++){const i=new F(`trace_${e}_trace_color`);i.value=t.getColor(`trace_${e}_trace_color`),this.properties.add(i);const s=new W(`trace_${e}_buffer_size`);s.value=t.getInt(`trace_${e}_buffer_size`),this.properties.add(s);const r=new I(`trace_${e}_y_pv`);r.value=t.getString(`trace_${e}_y_pv`),this.properties.add(r);const o=new W(`trace_${e}_point_size`);o.value=t.getInt(`trace_${e}_point_size`),this.properties.add(o);const a=new W(`trace_${e}_point_style`);a.value=t.getInt(`trace_${e}_point_style`),this.properties.add(a);const n=this.expandMacro(r.value),l=this.display.pvEngine.createPV(n);if(l){const t=new vh(s.value);this.traceDataSet.push({traceColor:i.value,bufferSize:s.value,pointSize:o.value,pointStyle:a.value,yPVName:n,yPV:l,buffer:t}),l.addListener((()=>{const e=l.toNumber();void 0!==e&&(t.push([l.time||new Date,e]),this.updateGraph())}))}}}updateGraph(){if(!this.graph)return;const t=this.traceDataSet[0].buffer.snapshot();this.graph.updateOptions({file:t.length?t:"X\n"})}draw(t){if(!this.transparent){const{x:e,y:i,width:s,height:r}=this;t.fillRect({x:e,y:i,width:s,height:r,color:this.backgroundColor})}if(this.containerEl.style.display="block",!this.initialized){const{scale:i}=this;let s=this.display.measureAbsoluteArea(t,this);e=d(s,2*i),s={x:Math.round(e.x)+.5,y:Math.round(e.y)+.5,width:Math.round(e.width),height:Math.round(e.height)},this.containerEl.style.left=`${s.x}px`,this.containerEl.style.top=`${s.y}px`,this.containerEl.style.width=`${s.width}px`,this.containerEl.style.height=`${s.height}px`,this.initializeDygraphs(s),this.initialized=!0}var e}initializeDygraphs(t){const{scale:e}=this,i=this.axisDataSet[0],s={axisLineColor:i.axisColor,gridLineColor:i.gridColor,axisLabelWidth:70*e,drawGrid:!0,logscale:i.logScale};i.dashGridLine&&(s.gridLinePattern=[1*e,5*e]);const r=this.axisDataSet[1],o=this.traceDataSet[0],a={};a[r.axisTitle]={drawPoints:!0,strokeWidth:1*e,pointSize:o.pointSize*e,color:o.traceColor.toString()};const n={axisLineColor:r.axisColor,gridLineColor:r.gridColor,axisLabelFontSize:r.scaleFont.scale(e).height,yLabelHeight:r.titleFont.scale(e).height,valueRange:r.autoScale?[null,null]:[r.minimum,r.maximum],drawGrid:!0,logscale:r.logScale};var l;r.dashGridLine&&(n.gridLinePattern=[1*e,5*e]),this.graph=new xh(this.graphEl,"X\n",{title:this.title,titleHeight:this.title?this.titleFont.height:0,fillGraph:!1,interactionModel:{},width:t.width,height:t.height,xlabel:i.axisTitle,ylabel:r.axisTitle,xLabelHeight:i.titleFont.scale(e).height,yLabelWidth:r.titleFont.scale(e).height,labels:[i.axisTitle,r.axisTitle],series:a,labelsUTC:!0,axes:{x:s,y:n},underlayCallback:(t,i,s)=>{t.globalAlpha=1,t.fillStyle=this.plotAreaBackgroundColor.toString(),t.fillRect(i.x,i.y,i.w,i.h),this.showPlotAreaBorder&&(t.lineWidth=1*e,t.strokeStyle="#000",t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(i.x+i.w,i.y),t.stroke(),t.beginPath(),t.moveTo(i.x+i.w,i.y),t.lineTo(i.x+i.w,i.y+i.h),t.stroke())},drawPointCallback:(t,e,i,s,r,a,n)=>{const l=o.pointStyle;this.drawPoint(i,s,r,n/2,a,l)}}),this.styleEl.innerHTML=`\n#${(l={id:this.containerId,titleColor:this.foregroundColor.toString(),titleFont:this.titleFont.getFontString(),xScaleFont:i.scaleFont.scale(e).getFontString(),xAxisColor:i.axisColor.toString(),xLabelFont:i.titleFont.scale(e).getFontString(),xLabelColor:i.axisColor.toString(),yScaleFont:r.scaleFont.scale(e).getFontString(),yAxisColor:r.axisColor.toString(),yLabelFont:r.titleFont.scale(e).getFontString(),yLabelColor:r.axisColor.toString()}).id} .dygraph-legend {\n position: absolute;\n font-size: 14px;\n z-index: 10;\n width: 250px; /* labelsDivWidth */\n /*\n dygraphs determines these based on the presence of chart labels.\n It might make more sense to create a wrapper div around the chart proper.\n top: 0px;\n right: 2px;\n */\n background: white;\n line-height: normal;\n text-align: left;\n overflow: hidden;\n}\n\n/* styles for a solid line in the legend */\n#${l.id} .dygraph-legend-line {\n display: inline-block;\n position: relative;\n bottom: .5ex;\n padding-left: 1em;\n height: 1px;\n border-bottom-width: 2px;\n border-bottom-style: solid;\n /* border-bottom-color is set based on the series color */\n}\n\n/* styles for a dashed line in the legend, e.g. when strokePattern is set */\n#${l.id} .dygraph-legend-dash {\n display: inline-block;\n position: relative;\n bottom: .5ex;\n height: 1px;\n border-bottom-width: 2px;\n border-bottom-style: solid;\n /* border-bottom-color is set based on the series color */\n /* margin-right is set based on the stroke pattern */\n /* padding-left is set based on the stroke pattern */\n}\n\n#${l.id} .dygraph-axis-label {\n z-index: 10;\n line-height: normal;\n overflow: hidden;\n color: black;\n}\n\n#${l.id} .dygraph-axis-label-x {\n color: ${l.xAxisColor};\n font: ${l.xScaleFont};\n}\n\n#${l.id} .dygraph-axis-label-y {\n color: ${l.yAxisColor};\n font: ${l.yScaleFont};\n}\n\n#${l.id} .dygraph-axis-label-y2 {\n}\n\n#${l.id} .dygraph-title {\n z-index: 10;\n text-align: center;\n font: ${l.titleFont}; /* sync with titleHeight */\n color: ${l.titleColor};\n}\n\n#${l.id} .dygraph-xlabel {\n text-align: center;\n color: ${l.xLabelColor};\n font: ${l.xLabelFont};\n /* font-size: based on xLabelHeight option */\n}\n\n/* For y-axis label */\n#${l.id} .dygraph-label-rotate-right {\n text-align: center;\n color: ${l.yLabelColor};\n font: ${l.yLabelFont};\n transform: rotate(-90deg);\n}\n\n/* For y2-axis label */\n#${l.id} .dygraph-label-rotate-left {\n text-align: center;\n transform: rotate(90deg);\n}\n `}drawPoint(t,e,i,s,r,o){switch(t.fillStyle=r,t.strokeStyle=r,o){case 1:t.beginPath(),t.ellipse(e,i,s,s,0,0,2*Math.PI),t.fill();break;case 2:t.beginPath(),t.ellipse(e,i,s,s,0,0,2*Math.PI),t.stroke();break;case 3:t.beginPath(),t.ellipse(e,i,s,s,0,0,2*Math.PI),t.fill();break;case 4:t.lineWidth=1*this.scale,t.beginPath(),t.moveTo(e-s,i+s),t.lineTo(e,i-s),t.lineTo(e+s,i+s),t.closePath(),t.stroke();break;case 5:t.lineWidth=1*this.scale,t.beginPath(),t.moveTo(e-s,i+s),t.lineTo(e,i-s),t.lineTo(e+s,i+s),t.closePath(),t.fill();break;case 6:t.strokeRect(e-s,i-s,2*s,2*s);break;case 7:t.fillRect(e-s,i-s,2*s,2*s);break;case 8:case 9:t.beginPath(),t.moveTo(e-s,i),t.lineTo(e,i-s),t.lineTo(e+s,i),t.lineTo(e,i+s),t.closePath(),t.stroke();break;case 10:t.beginPath(),t.moveTo(e-s,i-s),t.lineTo(e+s,i+s),t.moveTo(e+s,i-s),t.lineTo(e-s,i+s),t.stroke();break;case 11:t.beginPath(),t.moveTo(e-s,i),t.lineTo(e+s,i),t.moveTo(e,i-s),t.lineTo(e,i+s),t.stroke();break;case 12:t.beginPath(),t.moveTo(e,i-s),t.lineTo(e,i+s),t.stroke()}}hide(){this.containerEl.style.display="none"}destroy(){this.display.removeEventListener("scale",this.scaleListener),this.destroyGraph(),this.display.rootPanel.removeChild(this.containerEl)}destroyGraph(){this.graph&&(this.graph.destroy(),this.graph=void 0,this.containerEl.removeChild(this.graphEl),this.initialized=!1)}get axisCount(){return this.properties.getValue(wh)}get title(){return this.properties.getValue(Sh)}get titleFont(){return this.properties.getValue(Th).scale(this.scale)}get traceCount(){return this.properties.getValue(Ch)}get plotAreaBackgroundColor(){return this.properties.getValue(bh)}get showPlotAreaBorder(){return this.properties.getValue(_h)}}const kh="macros";class Ph extends te{constructor(t,e){super(t,e),this._widgets=[],this._connections=[],this.relativeScale=1,this.properties.add(new U(kh))}expandContainerMacros(t){for(const e in this.macros.macros)t=(t=t.replace(`$(${e})`,this.macros.macros[e])).replace(`\${${e}}`,this.macros.macros[e]);return this.parent&&this.macros.includeParentMacros&&(t=this.parent.expandContainerMacros(t)),t}findWidget(t){for(const e of this.widgets){if(e.wuid===t)return e;if(e instanceof Ph){const i=e.findWidget(t);if(i)return i}}}findWidgetByName(t){for(const e of this.widgets){if(e.name===t)return e;if(e instanceof Ph){const i=e.findWidgetByName(t);if(i)return i}}for(const e of this.connections)if(e.name===t)return e}closeMenu(){for(const t of this.widgets)t.closeMenu()}hide(){for(const t of this.widgets)t.hide()}destroy(){for(const t of this.widgets)t.destroy()}get widgets(){return this._widgets}get connections(){return this._connections}get macros(){return this.properties.getValue(kh)}}const Rh="arrow_length",Eh="arrows",Mh="fill_arrow",Vh="name",Oh="line_color",Nh="line_style",Dh="line_width",Ih="src_wuid",Wh="src_term",Hh="tgt_wuid",Bh="tgt_term",Fh="router",Gh="points",Yh="LEFT",zh="UP",Uh="DOWN",$h="RIGHT";class jh extends te{constructor(t){super(t),this.properties.clear(),this.properties.add(new W(Rh)),this.properties.add(new W(Eh)),this.properties.add(new B(Mh)),this.properties.add(new I(Vh)),this.properties.add(new F(Oh)),this.properties.add(new W(Nh)),this.properties.add(new W(Dh)),this.properties.add(new I(Ih)),this.properties.add(new I(Wh)),this.properties.add(new I(Hh)),this.properties.add(new I(Bh)),this.properties.add(new W(Fh)),this.properties.add(new Y(Gh)),this.properties.add(new I("wuid"))}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):0===this.router?this.drawManhattanConnection(t):1===this.router&&this.drawDirectConnection(t))}drawPath(t){const e=this.getPosition(this.sourceWidget,this.sourceTerm),i=this.getPosition(this.targetWidget,this.targetTerm),s=[e,...this.points,i],r=w.fromPoints(s).translate(.5*this.scale,.5*this.scale);t.strokePath({path:r,lineWidth:this.lineWidth,color:this.lineColor,dash:this.getDashArray()}),this.drawStartArrow(t,s[1],s[0]),this.drawStopArrow(t,s[s.length-2],s[s.length-1])}drawManhattanConnection(t){const e=this.getManhattanAnchor(this.sourceWidget,this.sourceTerm),i=this.getManhattanAnchor(this.targetWidget,this.targetTerm),s=this.route(e,i),r=w.fromPoints(s);this.lineWidth&&t.strokePath({lineWidth:this.lineWidth,color:this.lineColor,path:r,dash:this.getDashArray()}),this.drawStartArrow(t,s[s.length-2],s[s.length-1]),this.drawStopArrow(t,s[1],s[0])}getDashArray(){const{scale:t}=this;if(this.lineWidth){if(0===this.lineStyle)return[];if(1===this.lineStyle)return[6*t,2*t];if(2===this.lineStyle)return[2*t,2*t];if(3===this.lineStyle)return[6*t,2*t,2*t,2*t];if(4===this.lineStyle)return[6*t,2*t,2*t,2*t,2*t,2*t];console.warn(`Unsupported connection line style ${this.lineStyle}`)}}drawDirectConnection(t){const e=this.getPosition(this.sourceWidget,this.sourceTerm),i=this.getPosition(this.targetWidget,this.targetTerm);this.lineWidth&&t.strokePath({path:new w(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=zh;break;case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":i=Uh;break;case"LEFT":i=Yh;break;case"RIGHT":i=$h}const s=t.bounds,r=this.getPosition(t,e),o=r.x-s.x,a=s.x+s.width-r.x,n=r.y-s.y,l=s.y+s.height-r.y;return i=Math.min(o,a)<Math.min(n,l)?o<a?Yh:$h:n<l?zh:Uh,{x:r.x,y:r.y,direction:i}}getPosition(t,e){switch(e){case"LEFT":return{x:t.holderX,y:t.holderY+t.holderHeight/2};case"TOP":return{x:t.holderX+t.holderWidth/2,y:t.holderY};case"RIGHT":return{x:t.holderX+t.holderWidth,y:t.holderY+t.holderHeight/2};case"BOTTOM":return{x:t.holderX+t.holderWidth/2,y:t.holderY+t.holderHeight};case"TOP_LEFT":return{x:t.holderX,y:t.holderY};case"TOP_RIGHT":return{x:t.holderX+t.holderWidth,y:t.holderY};case"BOTTOM_LEFT":return{x:t.holderX,y:t.holderY+t.holderHeight};case"BOTTOM_RIGHT":return{x:t.holderX+t.holderWidth,y:t.holderY+t.holderHeight};default:const i=parseInt(e,10),s=t.properties.getProperty("points");if(s)return s.value[i];throw Error(`Unexpected term ${e}`)}}route(t,e){let i,s,r=t.x-e.x,o=t.y-e.y,a={x:0,y:0},n=[];const{tolxtol:l,tol:h,minDist:d}=this;if(r*r<l&&o*o<l)return[{x:e.x,y:e.y}];t.direction===Yh?r>0&&o*o<h&&e.direction===$h?(a=e,i=e.direction):(r<0?a={x:t.x-d,y:t.y}:o>0&&e.direction===Uh||o<0&&e.direction===zh?a={x:e.x,y:t.y}:t.direction===e.direction?(s=Math.min(t.x,e.x)-d,a={x:s,y:t.y}):a={x:t.x-r/2,y:t.y},i=o>0?zh:Uh):t.direction===$h?r<0&&o*o<h&&e.direction===Yh?(a=e,i=e.direction):(r>0?a={x:t.x+d,y:t.y}:o>0&&e.direction===Uh||o<0&&e.direction===zh?a={x:e.x,y:t.y}:t.direction===e.direction?(s=Math.max(t.x,e.x)+d,a={x:s,y:t.y}):a={x:t.x-r/2,y:t.y},i=o>0?zh:Uh):t.direction===Uh?r*r<h&&o<0&&e.direction===zh?(a=e,i=e.direction):(o>0?a={x:t.x,y:t.y+d}:r>0&&e.direction===$h||r<0&&e.direction===Yh?a={x:t.x,y:e.y}:t.direction===e.direction?(s=Math.max(t.y,e.y)+d,a={x:t.x,y:s}):a={x:t.x,y:t.y-o/2},i=r>0?Yh:$h):t.direction===zh&&(r*r<h&&o>0&&e.direction===Uh?(a=e,i=e.direction):(o<0?a={x:t.x,y:t.y-d}:r>0&&e.direction===$h||r<0&&e.direction===Yh?a={x:t.x,y:e.y}:t.direction===e.direction?(s=Math.min(t.y,e.y)-d,a={x:t.x,y:s}):a={x:t.x,y:t.y-o/2},i=r>0?Yh:$h));const c=Object.assign(Object.assign({},a),{direction:i});return n=n.concat(this.route(c,e)),n.push(t),n}drawStartArrow(t,e,i){const s=t.ctx;if(1===this.arrows||3===this.arrows){const t=this.calculateArrowPoints(e,i);if(t[2]=i,this.fillArrow){s.fillStyle=this.lineColor.toString(),s.beginPath();for(let e=0;e<t.length;e++)0===e?s.moveTo(t[e].x,t[e].y):s.lineTo(t[e].x,t[e].y);s.fill()}else s.strokeStyle=this.lineColor.toString(),s.lineWidth=this.lineWidth,s.beginPath(),s.moveTo(i.x,i.y),s.lineTo(t[0].x,t[0].y),s.moveTo(i.x,i.y),s.lineTo(t[1].x,t[1].y),s.stroke()}}drawStopArrow(t,e,i){const s=t.ctx;if(2===this.arrows||3===this.arrows){const t=this.calculateArrowPoints(e,i);if(t[2]=i,this.fillArrow){s.fillStyle=this.lineColor.toString(),s.beginPath();for(let e=0;e<t.length;e++)0===e?s.moveTo(t[e].x,t[e].y):s.lineTo(t[e].x,t[e].y);s.fill()}else s.strokeStyle=this.lineColor.toString(),s.lineWidth=this.lineWidth,s.beginPath(),s.moveTo(i.x,i.y),s.lineTo(t[0].x,t[0].y),s.moveTo(i.x,i.y),s.lineTo(t[1].x,t[1].y),s.stroke()}}calculateArrowPoints(t,e){const i=f(e,t),s=Math.PI/10,r=new m(this.arrowLength,i.theta-s),o=new m(this.arrowLength,i.theta+s),a=new m(Math.floor(this.arrowLength*Math.cos(s)),i.theta);return[c(r.toPoint(),e.x,e.y),c(o.toPoint(),e.x,e.y),c(a.toPoint(),e.x,e.y)]}get minDist(){return 20*this.scale}get tol(){return.1*this.scale}get tolxtol(){return.01*this.scale}get name(){return this.properties.getValue(Vh)}get arrows(){return this.properties.getValue(Eh)}get fillArrow(){return this.properties.getValue(Mh)}get arrowLength(){return this.scale*this.properties.getValue(Rh)}get lineColor(){return this.properties.getValue(Oh)}get lineStyle(){return this.properties.getValue(Nh)}get lineWidth(){return this.scale*this.properties.getValue(Dh)}get router(){return this.properties.getValue(Fh)}get sourceTerm(){return this.properties.getValue(Wh)}get sourceWuid(){return this.properties.getValue(Ih)}get targetTerm(){return this.properties.getValue(Bh)}get targetWuid(){return this.properties.getValue(Hh)}get points(){return y(this.properties.getValue(Gh),this.scale)}}const Xh="auto_scale_widgets";class qh extends Ph{constructor(t,e){super(t,e),this.properties.add(new Z(Xh))}parseNode(t){super.parseNode(t);for(const e of t.getNodes("widget")){const t=e.getString("widget_type"),i=this.display.createWidget(t,this);i&&(i.parseNode(e),this.widgets.push(i))}for(const e of t.getNodes("connection")){const t=new jh(this.display);t.parseNode(e),this.connections.push(t)}}draw(t){for(const e of this.widgets)e.drawHolder(t),e.draw(t),e.drawDecoration(t);for(const e of this.connections)e.draw(t);for(const e of this.widgets)e.drawOverlay(t)}measureContentBounds(t){let e=0,i=0,s=0,r=0;for(const o of this.widgets){const a=t?o.bounds:o.unscaledBounds;e=Math.min(e,a.x),i=Math.min(i,a.y),s=Math.max(s,a.x+a.width),r=Math.max(r,a.y+a.height)}return{x:e,y:i,width:s-e,height:r-i}}get autoScaleWidgets(){return this.properties.getValue(Xh)}}class Zh extends Ph{parseNode(t){super.parseNode(t);for(const e of t.getNodes("widget")){const t=e.getString("widget_type"),i=this.display.createWidget(t,this);i&&(i.parseNode(e),this.widgets.push(i))}}draw(t){this.transparent||t.fillRect({x:this.x,y:this.y,width:this.width,height:this.height,color:this.backgroundColor});const e=t.createChild(this.width,this.height);for(const t of this.widgets)t.drawHolder(e),t.draw(e),t.drawDecoration(e);for(const t of this.widgets)t.drawOverlay(e);t.copy(e,this.x,this.y)}}class Kh{constructor(){this.includeParentMacros=!0,this.macros={}}clear(){this.macros={}}set(t,e){this.macros[t]=e}get(t){if(t in this.macros)return this.macros[t]}}class Jh{constructor(t,e,i){this.autoScaleWidgets=t,this.minWidth=e,this.minHeight=i}}class Qh{constructor(t,e,i){this.widthScalable=t,this.heightScalable=e,this.keepWidthHeightRatio=i}}class td{constructor(){this.scripts=[]}}class ed{constructor(t){this.node=t}get name(){return this.node.nodeName}static parseFromXML(t){const e=(new DOMParser).parseFromString(t,"text/xml");return new ed(e.documentElement)}getNode(t){const e=this.findChild(t);return new ed(e)}getNodes(t){const e=[];for(let i=0;i<this.node.childNodes.length;i++){const s=this.node.childNodes[i];3!==s.nodeType&&(t&&s.nodeName!==t||e.push(new ed(s)))}return e}hasNode(t){for(let e=0;e<this.node.childNodes.length;e++){if(this.node.childNodes[e].nodeName===t)return!0}return!1}hasAttribute(t){return this.node.hasAttribute(t)}getTextContent(t){return this.node.textContent||t||""}getString(t,e){for(let e=0;e<this.node.childNodes.length;e++){const i=this.node.childNodes[e];if(i.nodeName===t&&null!==i.textContent)return i.textContent}if(void 0!==e)return e;throw new Error(`No child node named ${t} could be found`)}getStringAttribute(t){const e=this.node.attributes.getNamedItem(t);if(null===e)throw new Error(`No attribute named ${t}`);return e.textContent||""}getFloat(t,e){for(let e=0;e<this.node.childNodes.length;e++){const i=this.node.childNodes[e];if(i.nodeName===t&&null!==i.textContent)return parseFloat(i.textContent)}if(void 0!==e)return e;throw new Error(`No child node named ${t} could be found`)}getInt(t,e){for(let e=0;e<this.node.childNodes.length;e++){const i=this.node.childNodes[e];if(i.nodeName===t&&null!==i.textContent)return parseInt(i.textContent,10)}if(void 0!==e)return e;throw new Error(`No child node named ${t} could be found`)}getIntAttribute(t){const e=this.node.attributes.getNamedItem(t);if(null===e)throw new Error(`No attribute named ${t}`);return parseInt(e.textContent||"",10)}getBoolean(t,e){for(let e=0;e<this.node.childNodes.length;e++){const i=this.node.childNodes[e];if(i.nodeName===t)return"true"===i.textContent}if(void 0!==e)return e;throw new Error(`No child node named ${t} could be found`)}getBooleanAttribute(t,e){const i=this.node.attributes.getNamedItem(t);if(null===i){if(void 0!==e)return e;throw new Error(`No attribute named ${t}`)}return"true"===i.textContent}getColor(t,e){const i=this.findChild(t);for(let t=0;t<i.childNodes.length;t++){const e=i.childNodes[t];if("color"===e.nodeName)return this.parseColorNode(new ed(e))}if(void 0!==e)return e;throw new Error("No child node named 'color' could be found")}getFont(t){const e=this.getNode(t);if(e.hasNode("opifont.name")){const t=e.getNode("opifont.name"),i=t.getStringAttribute("fontName"),s=t.getIntAttribute("height"),r=t.getIntAttribute("style");let o=!1;return t.hasAttribute("pixels")&&(o=t.getBooleanAttribute("pixels")),new M(i,s,r,o)}{const t=e.getNode("fontdata"),i=t.getStringAttribute("fontName"),s=t.getIntAttribute("height"),r=t.getIntAttribute("style");return new M(i,s,r,!1)}}getPoints(t){const e=this.getNode(t),i=[];for(const t of e.getNodes("point"))i.push({x:t.getIntAttribute("x"),y:t.getIntAttribute("y")});return i}getStringList(t){const e=this.getNode(t),i=[];for(const t of e.getNodes("s"))i.push(t.getTextContent());return i}getScripts(t){const e=this.getNode(t),i=new td;for(const t of e.getNodes("path")){const e=[];for(const i of t.getNodes("pv"))e.push({pvName:i.getTextContent(),trigger:i.getBooleanAttribute("trig")});const s=t.getStringAttribute("pathString");"EmbeddedJs"===s?i.scripts.push({embedded:!0,text:t.getString("scriptText"),checkConnect:t.getBooleanAttribute("checkConnect"),skipFirstExecution:t.getBooleanAttribute("sfe"),inputs:e}):"EmbeddedPy"===s?console.warn("Unsupported EmbeddedPy script"):i.scripts.push({embedded:!1,path:s,checkConnect:t.getBooleanAttribute("checkConnect"),skipFirstExecution:t.getBooleanAttribute("sfe"),inputs:e})}return i}getScaleOptions(t){const e=this.getNode(t);return new Qh(e.getBoolean("width_scalable"),e.getBoolean("height_scalable"),e.getBoolean("keep_wh_ratio"))}getAutoScaleWidgets(t){const e=this.getNode(t);return new Jh(e.getBoolean("auto_scale_widgets"),e.getInt("min_width"),e.getInt("min_height"))}getRules(t){const e=this.getNode(t),i=new Vt;for(const t of e.getNodes("rule")){const e=[];for(const i of t.getNodes("pv"))e.push({pvName:i.getTextContent(),trigger:i.getBooleanAttribute("trig")});const s=[];for(const e of t.getNodes("exp")){e.getNode("value").hasNode("color")?s.push({type:"color",expression:e.getStringAttribute("bool_exp"),outputValue:e.getColor("value")}):s.push({type:"string",expression:e.getStringAttribute("bool_exp"),outputValue:e.getString("value")})}i.rules.push({name:t.getStringAttribute("name"),propertyName:t.getStringAttribute("prop_id"),outputExpression:t.getBooleanAttribute("out_exp"),inputs:e,expressions:s})}return i}getMacros(t){const e=this.getNode(t),i=new Kh;i.includeParentMacros=e.getBoolean("include_parent_macros");for(const t of e.getNodes())"include_parent_macros"!==t.name&&i.set(t.name,e.getString(t.name));return i}getActions(t){const e=this.getNode(t),i=new Ct;i.hookFirstActionToClick=e.getBooleanAttribute("hook"),i.hookAllActionsToClick=e.getBooleanAttribute("hook_all",!1);for(const t of e.getNodes("action")){const e=t.getStringAttribute("type");if("OPEN_DISPLAY"===e){const e=new Lt(t.getString("path"));t.hasNode("mode")&&(e.mode=t.getInt("mode")),e.description=t.getString("description"),i.add(e)}else if("OPEN_FILE"===e){const e=new At;e.path=t.getString("path"),e.description=t.getString("description"),i.add(e)}else if("EXECUTE_CMD"===e){const e=new Pt;e.command=t.getString("command"),e.commandDirectory=t.getString("command_directory"),e.waitTime=t.getInt("wait_time"),e.description=t.getString("description"),i.add(e)}else if("EXECUTE_JAVASCRIPT"===e){const e=new kt(t.getBoolean("embedded"));e.embedded?e.text=t.getString("scriptText"):e.path=t.getString("path"),e.description=t.getString("description"),i.add(e)}else if("WRITE_PV"===e){const e=new Rt(t.getString("pv_name"),t.getString("value"));e.confirmMessage=t.getString("confirm_message",""),e.description=t.getString("description"),i.add(e)}else if("PLAY_SOUND"===e){const e=new Et;e.path=t.getString("path"),e.description=t.getString("description"),i.add(e)}else if("OPEN_WEBPAGE"===e){const e=new Mt;e.hyperlink=t.getString("hyperlink"),e.description=t.getString("description"),i.add(e)}else console.warn(`Unsupported action type ${e}`),i.add(null)}return i}parseColorNode(t){const i=t.getIntAttribute("red"),s=t.getIntAttribute("green"),r=t.getIntAttribute("blue");return new e(i,s,r)}findChild(t){for(let e=0;e<this.node.childNodes.length;e++){const i=this.node.childNodes[e];if(i.nodeName===t)return i}throw new Error(`No child node named ${t} could be found`)}}const id="group_name",sd="opi_file",rd="resize_behaviour";class od extends Ph{constructor(t,e){super(t,e),this.properties.add(new I(id)),this.properties.add(new I(sd)),this.properties.add(new W(rd,0))}init(){this.opiFile&&fetch(this.display.baseUrl+this.opiFile,{credentials:"same-origin"}).then((t=>{t.ok&&t.text().then((t=>{this.linkedDisplay=new qh(this.display,this);const e=ed.parseFromXML(t);this.linkedDisplay.parseNode(e),this.requestRepaint()}))}))}draw(t){this.transparent||t.fillRect(Object.assign(Object.assign({},this.area),{color:this.backgroundColor}));const e=this.getLinkedWidget();if(this.linkedDisplay&&e)if(t.fillRect(Object.assign(Object.assign({},this.area),{color:this.linkedDisplay.backgroundColor})),0===this.resizeBehavior){const e=this.linkedDisplay.measureContentBounds(!1);let{width:i,height:s}=e;const r=this.display.scale;i*=r,s*=r;const o=i/s;let a=this.width,n=a/o,l=a/i;n>this.height&&(n=this.height,a=n*o,l=n/i),this.linkedDisplay.relativeScale=l;const h=t.createChild(Math.ceil(a),Math.ceil(n));h.translate(e.x,e.y),this.linkedDisplay.draw(h),t.copy(h,this.x,this.y)}else if(1===this.resizeBehavior)console.warn("Unsupported resize behavior of LinkingContainer",this.resizeBehavior);else if(2===this.resizeBehavior){const e=this.linkedDisplay.measureContentBounds(!0),i=t.createChild(e.width,e.height);i.translate(e.x,e.y),this.linkedDisplay.draw(i),t.copy(i,this.x,this.y)}else 3===this.resizeBehavior&&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(sd)}get groupName(){return this.properties.getValue(id)}get resizeBehavior(){return this.properties.getValue(rd)}}const ad="active_tab";class nd extends Ph{constructor(t,e){super(t,e),this.tabs=[],this.properties.add(new W("minimum_tab_height")),this.properties.add(new W("active_tab")),this.properties.add(new B("horizontal_tabs")),this.properties.add(new W("tab_count"))}parseNode(t){super.parseNode(t);for(let e=0;e<this.tabCount;e++)this.tabs.push({title:t.getString(`tab_${e}_title`),backgroundColor:t.getColor(`tab_${e}_background_color`),foregroundColor:t.getColor(`tab_${e}_foreground_color`),enabled:t.getBoolean(`tab_${e}_enabled`),font:t.getFont(`tab_${e}_font`),headerRegion:{id:`${this.wuid}-header-${e}`,click:()=>{this.activeTab!==e&&(this.properties.setValue(ad,e),this.requestRepaint())},cursor:"pointer"}});for(const e of t.getNodes("widget")){const t=e.getString("widget_type"),i=this.display.createWidget(t,this);i&&(i.parseNode(e),this.widgets.push(i))}}draw(t){this.horizontalTabs?this.drawHorizontalTabs(t):this.drawVerticalTabs(t)}measureTabOffset(t){return this.horizontalTabs?{x:0,y:this.measureLabelHeight(t)}:{x:this.measureLabelWidth(t),y:0}}measureLabelHeight(t){const{scale:e}=this,i=1*e;let s=this.minimumTabHeight;for(let r=0;r<this.tabs.length;r++){const o=this.tabs[r],a=o.font.scale(e),n=t.measureText(o.title,a).height+i;n>s&&(s=n)}return s+this.margin}measureLabelWidth(t){const{scale:e}=this,i=1*e;let s=this.minimumTabWidth;for(let r=0;r<this.tabs.length;r++){const o=this.tabs[r],a=o.font.scale(e),n=t.measureText(o.title,a).width+i;n>s&&(s=n)}return s+this.margin}drawHorizontalTabs(t){const{margin:i,gap:s,scale:r}=this,o=this.measureLabelHeight(t),a=1*r;let n=this.x;for(let l=0;l<this.tabs.length;l++){const h=this.tabs[l],d=h.font.scale(r),c=t.measureText(h.title,d);let p,u,g,f,m;this.activeTab===l?(p=n,u=this.y,g=c.width+a+i+s,f=o,m=h.backgroundColor):(p=n+s,u=this.y+2*r,g=c.width+a+i-s,f=o-2*r,m=this.darken(h.backgroundColor)),t.fillRect({x:p,y:u,width:g,height:f,color:m});t.addHitRegion(h.headerRegion).addRect(p,u,g,f);const y=t.createLinearGradient(p,u,p,u+f);if(y.addColorStop(0,e.WHITE.toString()),y.addColorStop(1,e.WHITE.withAlpha(0).toString()),t.fillRect({x:p,y:u,width:g,height:f,gradient:y}),t.fillText({x:p+g/2,y:u+f/2,baseline:"middle",align:"center",font:d,color:h.foregroundColor,text:h.title}),n+=c.width+a+i-1*r,this.activeTab===l){const e=this.x,i=this.y+o,s=this.width,r=this.height-o;t.fillRect({x:e,y:i,width:s,height:r,color:h.backgroundColor});const a=this.widgets[l],n=t.createChild(s,r);a.drawHolder(n),a.draw(n),a.drawDecoration(n),a.drawOverlay(n),t.copy(n,e,i)}else{this.widgets[l].hide()}}}drawVerticalTabs(t){const{margin:i,gap:s,scale:r}=this,o=this.measureLabelWidth(t),a=1*r;let n=this.y;for(let l=0;l<this.tabs.length;l++){const h=this.tabs[l],d=h.font.scale(r),c=t.measureText(h.title,d),p=Math.max(c.height+a+a,this.minimumTabHeight);let u,g,f,m,y;this.activeTab===l?(u=this.x,g=n,f=o,m=p+i+s,y=h.backgroundColor):(u=this.x+2*r,g=n+s,f=o-2*r,m=p+i-s,y=this.darken(h.backgroundColor)),t.fillRect({x:u,y:g,width:f,height:m,color:y});t.addHitRegion(h.headerRegion).addRect(u,g,f,m);const x=t.createLinearGradient(u,g,u+f,g);if(x.addColorStop(0,e.WHITE.toString()),x.addColorStop(1,e.WHITE.withAlpha(0).toString()),t.fillRect({x:u,y:g,width:f,height:m,gradient:x}),t.fillText({x:u+f/2,y:g+m/2,baseline:"middle",align:"center",font:d,color:h.foregroundColor,text:h.title}),n+=p+i-1*r,this.activeTab===l){const e=this.x+o-1*r,i=this.y,s=this.width-o,a=this.height-1*r;t.fillRect({x:e,y:i,width:s,height:a,color:h.backgroundColor});const n=this.widgets[l],d=t.createChild(s,a);n.drawHolder(d),n.draw(d),n.drawDecoration(d),n.drawOverlay(d),t.copy(d,e,i)}else{this.widgets[l].destroy()}}}darken(t){const i=Math.max(0,t.red-30),s=Math.max(0,t.green-30),r=Math.max(0,t.blue-30);return new e(i,s,r)}get margin(){return 10*this.scale}get gap(){return 2*this.scale}get minimumTabWidth(){return 20*this.scale}get minimumTabHeight(){return this.scale*this.properties.getValue("minimum_tab_height")}get activeTab(){return this.properties.getValue(ad)}get tabCount(){return this.properties.getValue("tab_count")}get horizontalTabs(){return this.properties.getValue("horizontal_tabs")}}class ld extends te{constructor(t,e){super(t,e),this.properties.add(new I("url"))}init(){this.iframe=document.createElement("iframe"),this.iframe.src="https://yamcs.org",this.iframe.style.display="none",this.iframe.style.border="0",this.display.rootPanel.appendChild(this.iframe)}draw(t){if(this.iframe){const{x:e,y:i,width:s,height:r}=this.display.measureAbsoluteArea(t,this);this.iframe.style.position="absolute",this.iframe.style.display="block",this.iframe.style.left=`${e}px`,this.iframe.style.top=`${i}px`,this.iframe.style.width=`${s}px`,this.iframe.style.height=`${r}px`,this.url&&this.prevUrl!==this.url&&(this.iframe.src=this.url,this.prevUrl=this.url)}}hide(){this.iframe&&(this.iframe.style.display="none")}destroy(){this.iframe&&(this.display.rootPanel.removeChild(this.iframe),this.iframe=void 0)}get url(){return this.properties.getValue("url")}}t.CompiledFormula=_,t.Display=class{constructor(t){this.targetElement=t,this.repaintRequested=!1,this._editMode=!1,this._showGrid=!1,this._showOutline=!1,this._showRuler=!1,this._selection=[],this._scale=1,this._transparent=!1,this.baseUrl="",this.eventListeners={closedisplay:[],opendisplay:[],openpv:[],selection:[],scale:[]},this.rootPanel=document.createElement("div"),this.rootPanel.className="display-root",this.rootPanel.style.overflow="hidden",this.rootPanel.style.position="relative",this.rootPanel.style.fontSize="0",t.appendChild(this.rootPanel);const e=document.createElement("canvas");this.rootPanel.appendChild(e),this.g=new v(e),this.ctx=this.g.ctx,this.pvEngine=new ut(this),this.pvEngine.addProvider(new St),this.pvEngine.addProvider(new A),this.displayRegion={id:"display-root",click:()=>this.closeMenu()},window.requestAnimationFrame((()=>this.step())),new o(this,e,this.g.hitCanvas)}addProvider(t){this.pvEngine.addProvider(t)}addScriptLibrary(t,e){this.pvEngine.addScriptLibrary(t,e)}step(){this.repaintRequested&&(this.g.clearHitCanvas(),this.drawScreen(),this.repaintRequested=!1),window.requestAnimationFrame((()=>this.step()))}drawScreen(){var t;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){const 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(Object.assign(Object.assign({},this.instance.bounds),{color:this.instance.backgroundColor}))}else this.transparent||this.g.fillCanvas((null===(t=this.instance)||void 0===t?void 0:t.backgroundColor)||e.WHITE);if(this.g.addHitRegion(this.displayRegion).addRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.showGrid&&this.instance){const 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(const t of this.selection){const e=this.findWidget(t);e&&e.drawSelection(this.ctx)}}requestRepaint(){this.repaintRequested=!0}closeMenu(){var t;null===(t=this.instance)||void 0===t||t.closeMenu()}createWidget(t,e){switch(t){case"Action Button":return new ae(this,e);case"Arc":return new Ki(this,e);case"Boolean Button":return new _e(this,e);case"Boolean Switch":return new Oe(this,e);case"Byte Monitor":return new ur(this,e);case"Check Box":return new Fe(this,e);case"Choice Button":return new Xe(this,e);case"Combo":case"Combo Box":return new ti(this,e);case"Ellipse":return new ns(this,e);case"Gauge":return new Or(this,e);case"Grouping Container":return new Zh(this,e);case"Image":return new cs(this,e);case"Image Boolean Button":return new gi(this,e);case"Image Boolean Indicator":return new Gr(this,e);case"Label":return new ms(this,e);case"LED":return new so(this,e);case"Linking Container":return new od(this,e);case"Meter":return new Ao(this,e);case"Button":return new fi(this,e);case"Polygon":return new Ts(this,e);case"Polyline":return new Vs(this,e);case"Progress Bar":return new na(this,e);case"Radio Box":return new Ti(this,e);case"Rectangle":return new Ys(this,e);case"Rounded Rectangle":return new er(this,e);case"Scrollbar":return new Ii(this,e);case"Tabbed Container":return new nd(this,e);case"Tank":return new Na(this,e);case"Text Input":return new zi(this,e);case"Text Update":return new Ga(this,e);case"Thermometer":return new wn(this,e);case"Web Browser":return new ld(this,e);case"XY Graph":return new Ah(this,e);default:console.warn(`Unsupported widget type: ${t}`)}}destroy(){var t;null===(t=this.instance)||void 0===t||t.destroy(),this.instance=void 0,this.pvEngine.clearState(),this.requestRepaint()}setSource(t){return this.instance&&(this.clearSelection(),this.pvEngine.clearState(),this.instance=void 0),new Promise(((e,i)=>{fetch(this.baseUrl+t,{credentials:"same-origin"}).then((t=>{t.ok&&t.text().then((t=>{this.setSourceString(t),e()})).catch((t=>i(t)))})).catch((t=>i(t)))}))}setSourceString(t){this.instance=new qh(this);const e=ed.parseFromXML(t);this.instance.parseNode(e),this.requestRepaint()}measureAbsoluteArea(t,e){const i=e.bounds;let s=e.parent;for(;s;){if(i.x+=s.holderX,i.y+=s.holderY,s instanceof nd){const{x:e,y:r}=s.measureTabOffset(t);i.x+=e,i.y+=r}s=s.parent}return i.x+=e.x-e.holderX,i.y+=e.y-e.holderY,i.width+=e.width-e.holderWidth,i.height+=e.height-e.holderHeight,i.x+=1*this.scale,i.y+=1*this.scale,i}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((t=>t!==e))}fireEvent(t,e){this.eventListeners[t].forEach((t=>t(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();const 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();const e={scale:t};this.fireEvent("scale",e)}get transparent(){return this._transparent}set transparent(t){this._transparent=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(){this.pvEngine.getPVNames()}getPV(t){return this.pvEngine.getPV(t)}setValues(t){this.pvEngine.setValues(t)}},t.FormulaCompiler=L,t.PV=lt,Object.defineProperty(t,"__esModule",{value:!0})}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).opi={})}(this,(function(t){"use strict";class e{constructor(t,e,i,s=255){this.red=t,this.green=e,this.blue=i,this.alpha=s}withAlpha(t){return new e(this.red,this.green,this.blue,t)}mixWith(t,i){const s=Math.floor(this.red*i+t.red*(1-i)),r=Math.floor(this.green*i+t.green*(1-i)),o=Math.floor(this.blue*i+t.blue*(1-i));return new e(s,r,o)}brighter(){let{red:t,green:i,blue:s}=this;const r=Math.floor(1/(1-.7));return 0===t&&0===i&&0===s?new e(r,r,r):(t>0&&t<r&&(t=r),i>0&&i<r&&(i=r),s>0&&s<r&&(s=r),new e(Math.min(Math.floor(this.red/.7),255),Math.min(Math.floor(this.green/.7),255),Math.min(Math.floor(this.blue/.7),255)))}darker(){return new e(Math.max(Math.floor(.7*this.red),0),Math.max(Math.floor(.7*this.green),0),Math.max(Math.floor(.7*this.blue),0))}contrast(){return new e(this.red,255-this.green,255-this.blue)}hex(){let t=this.red.toString(16);t=1==t.length?"0"+t:t;let e=this.green.toString(16);e=1==e.length?"0"+e:e;let i=this.blue.toString(16);i=1==i.length?"0"+i:i;let s=this.alpha.toString(16);return s=1==s.length?"0"+s:s,`#${t}${e}${i}${s}`}getRGBValue(){return this}equals(t){return t&&this.toString()===t.toString()}toString(){return`rgba(${this.red},${this.green},${this.blue},${this.alpha})`}}e.TRANSPARENT=new e(0,0,0,0),e.BLACK=new e(0,0,0),e.BLUE=new e(0,0,255),e.CYAN=new e(0,255,255),e.DARK_GRAY=new e(150,150,150),e.GRAY=new e(200,200,200),e.GREEN=new e(0,255,0),e.LIGHT_BLUE=new e(153,186,243),e.ORANGE=new e(255,128,0),e.PINK=new e(255,0,255),e.PURPLE=new e(128,0,255),e.RED=new e(255,0,0),e.WHITE=new e(255,255,255),e.YELLOW=new e(255,255,0),e.BUTTON=new e(239,240,241),e.BUTTON_DARKER=new e(164,168,172),e.BUTTON_DARKEST=e.BLACK,e.BUTTON_LIGHTEST=e.WHITE;const i=t=>(document.removeEventListener("click",i,!0),t.preventDefault(),t.stopPropagation(),!1);function s(t){return 1==(1&t.buttons)||void 0===t.buttons&&1==t.which}function r(t,e){return t&&e&&t.id===e.id}class o{constructor(t,e,i){this.display=t,this.canvas=e,this.hitCanvas=i,this.grabbing=!1,this.documentMouseMoveListener=t=>this.onDocumentMouseMove(t),this.documentMouseUpListener=t=>this.onDocumentMouseUp(t),e.addEventListener("click",(t=>this.onCanvasClick(t)),!1),e.addEventListener("mousedown",(t=>this.onCanvasMouseDown(t)),!1),e.addEventListener("mouseup",(t=>this.onCanvasMouseUp(t)),!1),e.addEventListener("mouseout",(t=>this.onCanvasMouseOut(t)),!1),e.addEventListener("mousemove",(t=>this.onCanvasMouseMove(t)),!1)}toPoint(t){const e=this.canvas.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}}onCanvasClick(t){this.display.clearSelection();const e=this.toPoint(t);if(this.display.editMode)this.selectSingleWidget(e.x,e.y);else{const 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",i,!0),s(t))){const 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=Object.assign({},e),this.grabTarget=i),t.preventDefault(),t.stopPropagation(),!1}}onCanvasMouseUp(t){if(this.display.editMode)return;const 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){const e=this.toPoint(t),i=this.hitCanvas.getActiveRegion(e.x,e.y);this.prevEnteredRegion&&this.prevEnteredRegion.mouseOut&&(r(this.prevEnteredRegion,i)||this.prevEnteredRegion.mouseOut()),i&&i.mouseEnter&&(r(this.prevEnteredRegion,i)||i.mouseEnter()),this.prevEnteredRegion=i;const o=i&&i.cursor?i.cursor:"auto";if(o!=this.canvas.style.cursor&&(this.canvas.style.cursor=o),!this.grabbing&&i&&i.tooltip?this.display.setTooltip(i.tooltip()):this.display.setTooltip(void 0),this.grabPoint&&!this.grabbing&&s(t)){const t=(h=this.grabPoint.x,n=this.grabPoint.y,a=e.x,l=e.y,Math.sqrt((a-h)*(a-h)+(l-n)*(l-n)));Math.abs(t)>5&&(this.initiateGrab(),this.grabPoint&&(this.grabPoint=e))}var h,n,a,l;this.grabbing&&this.grabTarget&&s(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",i,!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);const t=this.grabTarget;this.grabbing=!1,this.grabPoint=void 0,this.grabTarget=void 0,(null==t?void 0:t.grabEnd)&&t.grabEnd()}}onDocumentMouseMove(t){this.onCanvasMouseMove(t)}selectSingleWidget(t,e){const i=this.display.instance;if(i)for(const s of i.widgets.slice().reverse()){const i=s.holderX,r=s.holderY,o=s.holderX+s.holderWidth,h=s.holderY+s.holderHeight;if(i<t&&t<o&&r<e&&e<h)return this.display.selection=[s.wuid],!1}}}const h="rgb(255,255,255)";class n{constructor(t,e,i){this.parent=t,this.regions={};const s=document.createElement("canvas");s.width=null!=e?e:s.width,s.height=null!=i?i:s.height,this.ctx=s.getContext("2d"),this.root=(null==t?void 0:t.root)||t}clear(){this.regions={},this.ctx.fillStyle=h,this.ctx.fillRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height)}beginHitRegion(t){const e=(this.root||this).generateUniqueColor();return(this.root||this).regions[e]=t,this.ctx.beginPath(),this.ctx.fillStyle=e,e}getActiveRegion(t,e){const i=this.ctx.getImageData(t,e,1,1).data,s=`rgb(${i[0]},${i[1]},${i[2]})`;return this.regions[s]||void 0}createChild(t,e){return new n(this,t,e)}transferToParent(t,e,i,s){if(!this.parent)throw new Error("No parent to transfer to");this.parent.ctx.drawImage(this.ctx.canvas,t,e,i,s)}generateUniqueColor(){for(;;){const t=`rgb(${Math.round(255*Math.random())},${Math.round(255*Math.random())},${Math.round(255*Math.random())})`;if(!this.regions[t]&&t!=h)return t}}}function a(t,e,i,s,r){return d({x:t,y:e,width:i,height:s},r/2)}function l(t,e,i,s,r){const o=Math.sin(r),h=Math.cos(r),n=t-i,a=e-s;return{x:n*h-a*o+i,y:n*o+a*h+s}}function d(t,e,i){return void 0===i&&(i=e),{x:t.x+i,y:t.y+e,width:t.width-(i+i),height:t.height-(e+e)}}function c(t){return{x:Math.round(t.x)+.5,y:Math.round(t.y)+.5,width:Math.round(t.width),height:Math.round(t.height)}}function p(t,e,i){return{x:t.x+e,y:t.y+i}}function g(t,e,i){return t.map((t=>p(t,e,i)))}function u(t){return t*Math.PI/180}function m(t,e,i){const s=Math.floor(t*Math.cos(e)),r=Math.floor(-t*Math.sin(e));return{x:i.x+i.width/2+s,y:i.y+i.height/2+r}}function x(t,e){const i=e.x-t.x,s=e.y-t.y,r=Math.sqrt(Math.pow(i,2)+Math.pow(s,2));let o=Math.acos(i/r);return s>0&&(o=2*Math.PI-o),new f(Math.floor(r),o)}class f{constructor(t,e){this.r=t,this.theta=e}toPoint(){return{x:Math.floor(this.r*Math.cos(this.theta)),y:Math.floor(-this.r*Math.sin(this.theta))}}}function w(t,e){return t.map((t=>({x:t.x*e,y:t.y*e})))}function y(t,e,i,s,r,o,h){t.beginPath(),o||h?(s<2*o&&(o=s/2),r<2*h&&(h=r/2),t.moveTo(e+o,i),t.lineTo(e+s-o,i),t.quadraticCurveTo(e+s,i,e+s,i+h),t.lineTo(e+s,i+r-h),t.quadraticCurveTo(e+s,i+r,e+s-o,i+r),t.lineTo(e+o,i+r),t.quadraticCurveTo(e,i+r,e,i+r-h),t.lineTo(e,i+h),t.quadraticCurveTo(e,i,e+o,i)):t.rect(e,i,s,r)}class v{constructor(t,e){this.canvas=t,this.ctx=t.getContext("2d"),this.hitCanvas=e||new n,this.hitCtx=this.hitCanvas.ctx}createChild(t,e){const i=this.hitCanvas.createChild(t,e),s=document.createElement("canvas");return s.width=t,s.height=e,new v(s,i)}translate(t,e){this.ctx.translate(t,e),this.hitCtx.translate(t,e)}copy(t,e,i){this.ctx.drawImage(t.canvas,e,i),t.hitCanvas.transferToParent(e,i,t.canvas.width,t.canvas.height)}copyFitted(t,e,i,s,r){const{width:o,height:h}=t.canvas,n=o/h;let a=s,l=a/n;l>r&&(l=r,a=l*n),this.copyScaled(t,e,i,a,l)}copyScaled(t,e,i,s,r){this.ctx.drawImage(t.canvas,e,i,s,r),t.hitCanvas.transferToParent(e,i,s,r)}clearHitCanvas(){this.hitCanvas.clear()}fillCanvas(t){this.ctx.fillStyle=t.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(t,e){this.ctx.canvas.style.width=t+"px",this.ctx.canvas.style.height=e+"px"}resize(t,e){this.ctx.canvas.width==t&&this.ctx.canvas.height==e||(this.ctx.canvas.width=t,this.ctx.canvas.height=e,this.hitCanvas.ctx.canvas.width=t,this.hitCanvas.ctx.canvas.height=e)}fillRect(t){this.ctx.fillStyle="color"in t?t.color.toString():t.gradient,void 0!==t.opacity&&(this.ctx.globalAlpha=t.opacity),t.rx||t.ry?(y(this.ctx,t.x,t.y,t.width,t.height,t.rx||0,t.ry||0),this.ctx.fill()):this.ctx.fillRect(t.x,t.y,t.width,t.height),void 0!==t.opacity&&(this.ctx.globalAlpha=1)}fillText(t){this.ctx.textBaseline=t.baseline,this.ctx.textAlign=t.align,this.ctx.font=t.font.getFontString(),this.ctx.fillStyle=t.color.toString(),this.ctx.fillText(t.text,t.x,t.y)}fillEllipse(t){this.ctx.beginPath();const e=t.startAngle||0,i=void 0===t.endAngle?2*Math.PI:t.endAngle;this.ctx.ellipse(t.cx,t.cy,t.rx,t.ry,0,e,i,t.anticlockwise),this.ctx.fillStyle="color"in t?t.color.toString():t.gradient,void 0!==t.opacity&&(this.ctx.globalAlpha=t.opacity),this.ctx.fill(),void 0!==t.opacity&&(this.ctx.globalAlpha=1)}strokeEllipse(t){t.dash&&this.ctx.setLineDash(t.dash),this.ctx.lineWidth=t.lineWidth||1,this.ctx.beginPath();const e=t.startAngle||0,i=void 0===t.endAngle?2*Math.PI:t.endAngle;this.ctx.ellipse(t.cx,t.cy,t.rx,t.ry,0,e,i,t.anticlockwise),this.ctx.strokeStyle="color"in t?t.color.toString():t.gradient,this.ctx.stroke(),t.dash&&this.ctx.setLineDash([])}measureText(t,e){this.ctx.font=e.getFontString();return{width:this.ctx.measureText(t).width,height:e.height}}createLinearGradient(t,e,i,s){return this.ctx.createLinearGradient(t,e,i,s)}strokeRect(t){t.dash&&this.ctx.setLineDash(t.dash);const e=t.lineWidth||1;if(this.ctx.lineWidth=e,this.ctx.strokeStyle=t.color.toString(),t.crispen&&e){const i=d(t,e/2,e/2);t.rx||t.ry?(y(this.ctx,i.x,i.y,i.width,i.height,t.rx||0,t.ry||0),this.ctx.stroke()):this.ctx.strokeRect(i.x,i.y,i.width,i.height)}else t.rx||t.ry?(y(this.ctx,t.x,t.y,t.width,t.height,t.rx||0,t.ry||0),this.ctx.stroke()):this.ctx.strokeRect(t.x,t.y,t.width,t.height);t.dash&&this.ctx.setLineDash([])}strokePath(t){t.dash&&this.ctx.setLineDash(t.dash),this.ctx.beginPath();for(const e of t.path.segments)e.line?this.ctx.lineTo(e.x,e.y):this.ctx.moveTo(e.x,e.y);this.ctx.lineWidth=t.lineWidth||1,this.ctx.strokeStyle=t.color.toString(),void 0!==t.opacity&&(this.ctx.globalAlpha=t.opacity),this.ctx.stroke(),void 0!==t.opacity&&(this.ctx.globalAlpha=1),t.dash&&this.ctx.setLineDash([])}fillPath(t){this.ctx.beginPath();for(const e of t.path.segments)e.line?this.ctx.lineTo(e.x,e.y):this.ctx.moveTo(e.x,e.y);this.ctx.fillStyle="color"in t?t.color.toString():t.gradient,void 0!==t.opacity&&(this.ctx.globalAlpha=t.opacity),this.ctx.fill("evenodd"),void 0!==t.opacity&&(this.ctx.globalAlpha=1)}addHitRegion(t){return this.hitCanvas.beginHitRegion(t),new T(this.hitCanvas.ctx)}}class b{constructor(t,e){this.segments=[],this.segments.push({x:t,y:e,line:!1})}static fromPoints(t){const e=new b(t[0].x,t[0].y);for(let i=1;i<t.length;i++)e.lineTo(t[i].x,t[i].y);return e}getBoundingBox(){const t={x:this.segments[0].x,y:this.segments[0].y},e={x:this.segments[0].x,y:this.segments[0].y};for(let i=0;i<this.segments.length;i++){const s=this.segments[i];s.x<t.x&&(t.x=s.x),s.x>e.x&&(e.x=s.x),s.y<t.y&&(t.y=s.y),s.y>e.y&&(e.y=s.y)}return{x:t.x,y:t.y,width:e.x-t.x,height:e.y-t.y}}lineTo(t,e){return this.segments.push({x:t,y:e,line:!0}),this}moveTo(t,e){return this.segments.push({x:t,y:e,line:!1}),this}closePath(){const t=this.segments[0];return this.segments.push({x:t.x,y:t.y,line:!0}),this}translate(t,e){for(const i of this.segments)i.x+=t,i.y+=e;return this}}class T{constructor(t){this.ctx=t}addRect(t,e,i,s){return this.ctx.fillRect(t,e,i,s),this}addEllipse(t,e,i,s,r,o,h,n){this.ctx.beginPath(),this.ctx.ellipse(t,e,i,s,r,o,h,n),this.ctx.fill()}addPath(t){this.ctx.beginPath();for(const e of t.segments)e.line?this.ctx.lineTo(e.x,e.y):this.ctx.moveTo(e.x,e.y);this.ctx.fill()}}class S{constructor(t){this.display=t}resolve(t){return`${this.display.baseUrl}${t}`}}class V{constructor(t,e){this.pvName=t,this.formula=e,this.pvValues=new Map}updateDataSource(t,e){this.pvValues.set(t,e)}clearState(){this.pvValues.clear()}getPVNames(){const t=this.formula.expression,e=[];return this.getExpressionParameters(t,e),e}getExpressionParameters(t,e){switch(t.type){case"ParameterLiteral":-1===e.indexOf(t.value)&&e.push(t.value);break;case"ConditionalExpression":this.getExpressionParameters(t.consequent,e),t.alternate&&this.getExpressionParameters(t.alternate,e);break;case"BinaryExpression":case"LogicalExpression":this.getExpressionParameters(t.left,e),this.getExpressionParameters(t.right,e);break;case"UnaryExpression":this.getExpressionParameters(t.argument,e);break;case"CallExpression":for(const i of t.arguments)this.getExpressionParameters(i,e)}}execute(){const t=this.formula.expression;return this.executeExpression(t)}executeExpression(t){switch(t.type){case"BooleanLiteral":case"ConstantLiteral":case"NumericLiteral":case"StringLiteral":return t.value;case"ParameterLiteral":const e=this.pvValues.get(t.value);return e?e.value:void 0;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){const 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<i;case">=":return e>=i;case">":return e>i;default:throw new Error(`Unexpected binary operator ${t.operator}`)}}executeLogicalExpression(t){const 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){const e=this.executeExpression(t.test),i=this.executeExpression(t.consequent);if(void 0===t.alternate)return e?i:null;{const s=this.executeExpression(t.alternate);return e?i:s}}executeUnaryExpression(t){const 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){const e=t.callee.name,i=[];for(const e of t.arguments)i.push(this.executeExpression(e));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 180*i[0]/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){const e=this.pvValues.get(t);if(e)return e.acquisitionStatus}}function A(t,e,i,s){var r=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(r,A.prototype),r.expected=e,r.found=i,r.location=s,r.name="SyntaxError",r}function _(t,e,i){return i=i||" ",t.length>e?t:(e-=t.length,t+(i+=i.repeat(e)).slice(0,e))}function L(t,e){var i,s,r,o,h={},n=(e=void 0!==e?e:{}).grammarSource,a={Start:kt},l=kt,d=".",c='"',p="'",g="-",u="+",m=",",x="<=",f=">=",w="==",y="!=",v="&&",b="||",T=/^[a-zA-Z]/,S=/^[a-zA-Z0-9_]/,V=/^[0-9]/,_=/^[1-9]/,L=/^[^\n\r\f"]/,C=/^[^\n\r\f']/,P=At("=",!1),M=At(" ",!1),k=At("\t",!1),R=At("false",!0),E=At("true",!0),W=At("PI",!0),B=At("E",!0),I=Lt("identifier"),O=_t([["a","z"],["A","Z"]],!1,!1),H=At("_",!1),F=_t([["a","z"],["A","Z"],["0","9"],"_"],!1,!1),N=Lt("boolean"),D=Lt("constant"),j=Lt("number"),$=At(".",!1),G=At("0",!1),z=_t([["0","9"]],!1,!1),U=_t([["1","9"]],!1,!1),q=Lt("string"),Y=At('"',!1),X=_t(["\n","\r","\f",'"'],!0,!1),K=Lt("parameter"),Z=At("'",!1),J=_t(["\n","\r","\f","'"],!0,!1),Q=At("(",!1),tt=At(")",!1),et=At("-",!1),it=At("+",!1),st=At(",",!1),rt=At("*",!1),ot=At("/",!1),ht=At("^",!1),nt=At("%",!1),at=At("<=",!1),lt=At(">=",!1),dt=At("<",!1),ct=At(">",!1),pt=At("==",!1),gt=At("!=",!1),ut=At("&&",!1),mt=At("||",!1),xt=function(){return{type:"NumericLiteral",value:parseFloat(t.substring(vt,yt))}},ft=function(t,e){return function(t,e,i){return[t].concat(function(t,e){return t.map((function(t){return t[e]}))}(e,i))}(t,e,3)},wt=function(t,e){return function(t,e){return e.reduce((function(t,e){return{type:"BinaryExpression",operator:e[1],left:t,right:e[3]}}),t)}(t,e)},yt=0,vt=0,bt=[{line:1,column:1}],Tt=0,St=[],Vt=0;if("startRule"in e){if(!(e.startRule in a))throw new Error("Can't start parsing from rule \""+e.startRule+'".');l=a[e.startRule]}function At(t,e){return{type:"literal",text:t,ignoreCase:e}}function _t(t,e,i){return{type:"class",parts:t,inverted:e,ignoreCase:i}}function Lt(t){return{type:"other",description:t}}function Ct(e){var i,s=bt[e];if(s)return s;for(i=e-1;!bt[i];)i--;for(s={line:(s=bt[i]).line,column:s.column};i<e;)10===t.charCodeAt(i)?(s.line++,s.column=1):s.column++,i++;return bt[e]=s,s}function Pt(t,e){var i=Ct(t),s=Ct(e);return{source:n,start:{offset:t,line:i.line,column:i.column},end:{offset:e,line:s.line,column:s.column}}}function Mt(t){yt<Tt||(yt>Tt&&(Tt=yt,St=[]),St.push(t))}function kt(){var e,i,s;return e=yt,61===t.charCodeAt(yt)?(i="=",yt++):(i=h,0===Vt&&Mt(P)),i!==h?(Rt(),s=function(){var t,e;t=yt,(e=zt())!==h&&(vt=t,e={type:"Formula",expression:e});return t=e}(),s!==h?(Rt(),vt=e,e=s):(yt=e,e=h)):(yt=e,e=h),e}function Rt(){var t,e;for(t=[],e=Et();e!==h;)t.push(e),e=Et();return t}function Et(){var e;return 32===t.charCodeAt(yt)?(e=" ",yt++):(e=h,0===Vt&&Mt(M)),e===h&&(9===t.charCodeAt(yt)?(e="\t",yt++):(e=h,0===Vt&&Mt(k))),e}function Wt(){var e,i;return e=yt,i=function(){var e,i,s,r;if(Vt++,e=yt,i=function(){var e;T.test(t.charAt(yt))?(e=t.charAt(yt),yt++):(e=h,0===Vt&&Mt(O));e===h&&(95===t.charCodeAt(yt)?(e="_",yt++):(e=h,0===Vt&&Mt(H)));return e}(),i!==h){for(s=[],r=Bt();r!==h;)s.push(r),r=Bt();vt=e,e={type:"Symbol",name:i+s.join("")}}else yt=e,e=h;Vt--,e===h&&(i=h,0===Vt&&Mt(I));return e}(),i!==h&&(vt=e,i=i),e=i}function Bt(){var e;return S.test(t.charAt(yt))?(e=t.charAt(yt),yt++):(e=h,0===Vt&&Mt(F)),e}function It(){var e;return(e=function(){var e,i;Vt++,e=yt,i=function(){var e;return"true"===t.substr(yt,4).toLowerCase()?(e=t.substr(yt,4),yt+=4):(e=h,0===Vt&&Mt(E)),e}(),i!==h&&(vt=e,i={type:"BooleanLiteral",value:!0});(e=i)===h&&(e=yt,i=function(){var e;return"false"===t.substr(yt,5).toLowerCase()?(e=t.substr(yt,5),yt+=5):(e=h,0===Vt&&Mt(R)),e}(),i!==h&&(vt=e,i={type:"BooleanLiteral",value:!1}),e=i);Vt--,e===h&&(i=h,0===Vt&&Mt(N));return e}())===h&&(e=function(){var e,i;Vt++,e=yt,i=function(){var e;return"pi"===t.substr(yt,2).toLowerCase()?(e=t.substr(yt,2),yt+=2):(e=h,0===Vt&&Mt(W)),e}(),i!==h&&(vt=e,i={type:"ConstantLiteral",value:Math.PI});(e=i)===h&&(e=yt,i=function(){var e;return"e"===t.substr(yt,1).toLowerCase()?(e=t.charAt(yt),yt++):(e=h,0===Vt&&Mt(B)),e}(),i!==h&&(vt=e,i={type:"ConstantLiteral",value:Math.E}),e=i);Vt--,e===h&&(i=h,0===Vt&&Mt(D));return e}())===h&&(e=function(){var e,i,s,r,o;if(Vt++,e=yt,(i=Ot())!==h)if(46===t.charCodeAt(yt)?(s=d,yt++):(s=h,0===Vt&&Mt($)),s!==h){for(r=[],o=Ht();o!==h;)r.push(o),o=Ht();vt=e,e=xt()}else yt=e,e=h;else yt=e,e=h;if(e===h){if(e=yt,46===t.charCodeAt(yt)?(i=d,yt++):(i=h,0===Vt&&Mt($)),i!==h){if(s=[],(r=Ht())!==h)for(;r!==h;)s.push(r),r=Ht();else s=h;s!==h?(vt=e,e=xt()):(yt=e,e=h)}else yt=e,e=h;e===h&&(e=yt,(i=Ot())!==h&&(vt=e,i=xt()),e=i)}Vt--,e===h&&(i=h,0===Vt&&Mt(j));return e}())===h&&(e=function(){var e,i,s,r;Vt++,e=yt,34===t.charCodeAt(yt)?(i=c,yt++):(i=h,0===Vt&&Mt(Y));if(i!==h){for(s=[],L.test(t.charAt(yt))?(r=t.charAt(yt),yt++):(r=h,0===Vt&&Mt(X));r!==h;)s.push(r),L.test(t.charAt(yt))?(r=t.charAt(yt),yt++):(r=h,0===Vt&&Mt(X));34===t.charCodeAt(yt)?(r=c,yt++):(r=h,0===Vt&&Mt(Y)),r!==h?(vt=e,e={type:"StringLiteral",value:s.join("")}):(yt=e,e=h)}else yt=e,e=h;Vt--,e===h&&(i=h,0===Vt&&Mt(q));return e}())===h&&(e=function(){var e,i,s,r;Vt++,e=yt,39===t.charCodeAt(yt)?(i=p,yt++):(i=h,0===Vt&&Mt(Z));if(i!==h){for(s=[],C.test(t.charAt(yt))?(r=t.charAt(yt),yt++):(r=h,0===Vt&&Mt(J));r!==h;)s.push(r),C.test(t.charAt(yt))?(r=t.charAt(yt),yt++):(r=h,0===Vt&&Mt(J));39===t.charCodeAt(yt)?(r=p,yt++):(r=h,0===Vt&&Mt(Z)),r!==h?(vt=e,e={type:"ParameterLiteral",value:s.join("")}):(yt=e,e=h)}else yt=e,e=h;Vt--,e===h&&(i=h,0===Vt&&Mt(K));return e}()),e}function Ot(){var e,i,s,r;if(48===t.charCodeAt(yt)?(e="0",yt++):(e=h,0===Vt&&Mt(G)),e===h)if(e=yt,i=function(){var e;_.test(t.charAt(yt))?(e=t.charAt(yt),yt++):(e=h,0===Vt&&Mt(U));return e}(),i!==h){for(s=[],r=Ht();r!==h;)s.push(r),r=Ht();e=i=[i,s]}else yt=e,e=h;return e}function Ht(){var e;return V.test(t.charAt(yt))?(e=t.charAt(yt),yt++):(e=h,0===Vt&&Mt(z)),e}function Ft(){var e,i,s;return e=function(){var e,i,s,r;return(e=It())===h&&(e=yt,40===t.charCodeAt(yt)?(i="(",yt++):(i=h,0===Vt&&Mt(Q)),i!==h?(Rt(),(s=zt())!==h?(Rt(),41===t.charCodeAt(yt)?(r=")",yt++):(r=h,0===Vt&&Mt(tt)),r!==h?(vt=e,e=s):(yt=e,e=h)):(yt=e,e=h)):(yt=e,e=h)),e}(),e===h&&(e=yt,i=function(){var e;45===t.charCodeAt(yt)?(e=g,yt++):(e=h,0===Vt&&Mt(et));e===h&&(43===t.charCodeAt(yt)?(e=u,yt++):(e=h,0===Vt&&Mt(it)));return e}(),i!==h?(Rt(),(s=Ft())!==h?(Rt(),vt=e,e={type:"UnaryExpression",operator:i,argument:s}):(yt=e,e=h)):(yt=e,e=h)),e}function Nt(){var e,i,s;return e=yt,(i=Wt())!==h?(Rt(),s=function(){var e,i,s,r;e=yt,40===t.charCodeAt(yt)?(i="(",yt++):(i=h,0===Vt&&Mt(Q));i!==h?(Rt(),s=yt,r=function(){var e,i,s,r,o,n,a,l;if(e=yt,(i=zt())!==h){for(s=[],r=yt,o=Rt(),44===t.charCodeAt(yt)?(n=m,yt++):(n=h,0===Vt&&Mt(st)),n!==h?(a=Rt(),(l=zt())!==h?r=o=[o,n,a,l]:(yt=r,r=h)):(yt=r,r=h);r!==h;)s.push(r),r=yt,o=Rt(),44===t.charCodeAt(yt)?(n=m,yt++):(n=h,0===Vt&&Mt(st)),n!==h?(a=Rt(),(l=zt())!==h?r=o=[o,n,a,l]:(yt=r,r=h)):(yt=r,r=h);vt=e,e=ft(i,s)}else yt=e,e=h;return e}(),r!==h?s=r=[r,Rt()]:(yt=s,s=h),s===h&&(s=null),41===t.charCodeAt(yt)?(r=")",yt++):(r=h,0===Vt&&Mt(tt)),r!==h?(vt=e,a=0,e=null!==(o=(n=s)?n[a]:null)?o:[]):(yt=e,e=h)):(yt=e,e=h);var o,n,a;return e}(),s!==h?(vt=e,e={type:"CallExpression",callee:i,arguments:s}):(yt=e,e=h)):(yt=e,e=h),e===h&&(e=Ft()),e}function Dt(){var e,i,s,r,o,n,a,l;if(e=yt,(i=Nt())!==h){for(s=[],r=yt,o=Rt(),42===t.charCodeAt(yt)?(n="*",yt++):(n=h,0===Vt&&Mt(rt)),n===h&&(47===t.charCodeAt(yt)?(n="/",yt++):(n=h,0===Vt&&Mt(ot)),n===h&&(94===t.charCodeAt(yt)?(n="^",yt++):(n=h,0===Vt&&Mt(ht)),n===h&&(37===t.charCodeAt(yt)?(n="%",yt++):(n=h,0===Vt&&Mt(nt))))),n!==h?(a=Rt(),(l=Nt())!==h?r=o=[o,n,a,l]:(yt=r,r=h)):(yt=r,r=h);r!==h;)s.push(r),r=yt,o=Rt(),42===t.charCodeAt(yt)?(n="*",yt++):(n=h,0===Vt&&Mt(rt)),n===h&&(47===t.charCodeAt(yt)?(n="/",yt++):(n=h,0===Vt&&Mt(ot)),n===h&&(94===t.charCodeAt(yt)?(n="^",yt++):(n=h,0===Vt&&Mt(ht)),n===h&&(37===t.charCodeAt(yt)?(n="%",yt++):(n=h,0===Vt&&Mt(nt))))),n!==h?(a=Rt(),(l=Nt())!==h?r=o=[o,n,a,l]:(yt=r,r=h)):(yt=r,r=h);vt=e,e=wt(i,s)}else yt=e,e=h;return e}function jt(){var e,i,s,r,o,n,a,l;if(e=yt,(i=Dt())!==h){for(s=[],r=yt,o=Rt(),43===t.charCodeAt(yt)?(n=u,yt++):(n=h,0===Vt&&Mt(it)),n===h&&(45===t.charCodeAt(yt)?(n=g,yt++):(n=h,0===Vt&&Mt(et))),n!==h?(a=Rt(),(l=Dt())!==h?r=o=[o,n,a,l]:(yt=r,r=h)):(yt=r,r=h);r!==h;)s.push(r),r=yt,o=Rt(),43===t.charCodeAt(yt)?(n=u,yt++):(n=h,0===Vt&&Mt(it)),n===h&&(45===t.charCodeAt(yt)?(n=g,yt++):(n=h,0===Vt&&Mt(et))),n!==h?(a=Rt(),(l=Dt())!==h?r=o=[o,n,a,l]:(yt=r,r=h)):(yt=r,r=h);vt=e,e=wt(i,s)}else yt=e,e=h;return e}function $t(){var e,i,s,r,o,n,a,l;if(e=yt,(i=jt())!==h){for(s=[],r=yt,o=Rt(),t.substr(yt,2)===x?(n=x,yt+=2):(n=h,0===Vt&&Mt(at)),n===h&&(t.substr(yt,2)===f?(n=f,yt+=2):(n=h,0===Vt&&Mt(lt)),n===h&&(60===t.charCodeAt(yt)?(n="<",yt++):(n=h,0===Vt&&Mt(dt)),n===h&&(62===t.charCodeAt(yt)?(n=">",yt++):(n=h,0===Vt&&Mt(ct))))),n!==h?(a=Rt(),(l=jt())!==h?r=o=[o,n,a,l]:(yt=r,r=h)):(yt=r,r=h);r!==h;)s.push(r),r=yt,o=Rt(),t.substr(yt,2)===x?(n=x,yt+=2):(n=h,0===Vt&&Mt(at)),n===h&&(t.substr(yt,2)===f?(n=f,yt+=2):(n=h,0===Vt&&Mt(lt)),n===h&&(60===t.charCodeAt(yt)?(n="<",yt++):(n=h,0===Vt&&Mt(dt)),n===h&&(62===t.charCodeAt(yt)?(n=">",yt++):(n=h,0===Vt&&Mt(ct))))),n!==h?(a=Rt(),(l=jt())!==h?r=o=[o,n,a,l]:(yt=r,r=h)):(yt=r,r=h);vt=e,e=wt(i,s)}else yt=e,e=h;return e}function Gt(){var e,i,s,r,o,n,a,l;if(e=yt,(i=$t())!==h){for(s=[],r=yt,o=Rt(),t.substr(yt,2)===w?(n=w,yt+=2):(n=h,0===Vt&&Mt(pt)),n===h&&(t.substr(yt,2)===y?(n=y,yt+=2):(n=h,0===Vt&&Mt(gt))),n!==h?(a=Rt(),(l=$t())!==h?r=o=[o,n,a,l]:(yt=r,r=h)):(yt=r,r=h);r!==h;)s.push(r),r=yt,o=Rt(),t.substr(yt,2)===w?(n=w,yt+=2):(n=h,0===Vt&&Mt(pt)),n===h&&(t.substr(yt,2)===y?(n=y,yt+=2):(n=h,0===Vt&&Mt(gt))),n!==h?(a=Rt(),(l=$t())!==h?r=o=[o,n,a,l]:(yt=r,r=h)):(yt=r,r=h);vt=e,e=wt(i,s)}else yt=e,e=h;return e}function zt(){var e,i,s,r,o,n,a,l;if(e=yt,(i=Gt())!==h){for(s=[],r=yt,o=Rt(),t.substr(yt,2)===v?(n=v,yt+=2):(n=h,0===Vt&&Mt(ut)),n===h&&(t.substr(yt,2)===b?(n=b,yt+=2):(n=h,0===Vt&&Mt(mt))),n!==h?(a=Rt(),(l=Gt())!==h?r=o=[o,n,a,l]:(yt=r,r=h)):(yt=r,r=h);r!==h;)s.push(r),r=yt,o=Rt(),t.substr(yt,2)===v?(n=v,yt+=2):(n=h,0===Vt&&Mt(ut)),n===h&&(t.substr(yt,2)===b?(n=b,yt+=2):(n=h,0===Vt&&Mt(mt))),n!==h?(a=Rt(),(l=Gt())!==h?r=o=[o,n,a,l]:(yt=r,r=h)):(yt=r,r=h);vt=e,e=function(t,e){return e.reduce((function(t,e){return{type:"LogicalExpression",operator:e[1],left:t,right:e[3]}}),t)}(i,s)}else yt=e,e=h;return e}if((i=l())!==h&&yt===t.length)return i;throw i!==h&&yt<t.length&&Mt({type:"end"}),s=St,r=Tt<t.length?t.charAt(Tt):null,o=Tt<t.length?Pt(Tt,Tt+1):Pt(Tt,Tt),new A(A.buildMessage(s,r),s,r,o)}!function(t,e){function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i}(A,Error),A.prototype.format=function(t){var e="Error: "+this.message;if(this.location){var i,s=null;for(i=0;i<t.length;i++)if(t[i].source===this.location.source){s=t[i].text.split(/\r\n|\n|\r/g);break}var r=this.location.start,o=this.location.source+":"+r.line+":"+r.column;if(s){var h=this.location.end,n=_("",r.line.toString().length),a=s[r.line-1],l=r.line===h.line?h.column:a.length+1;e+="\n --\x3e "+o+"\n"+n+" |\n"+r.line+" | "+a+"\n"+n+" | "+_("",r.column-1)+_("",l-r.column,"^")}else e+="\n at "+o}return e},A.buildMessage=function(t,e){var i={literal:function(t){return'"'+r(t.text)+'"'},class:function(t){var e=t.parts.map((function(t){return Array.isArray(t)?o(t[0])+"-"+o(t[1]):o(t)}));return"["+(t.inverted?"^":"")+e+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(t){return t.description}};function s(t){return t.charCodeAt(0).toString(16).toUpperCase()}function r(t){return t.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(t){return"\\x0"+s(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+s(t)}))}function o(t){return t.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(t){return"\\x0"+s(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+s(t)}))}function h(t){return i[t.type](t)}return"Expected "+function(t){var e,i,s=t.map(h);if(s.sort(),s.length>0){for(e=1,i=1;e<s.length;e++)s[e-1]!==s[e]&&(s[i]=s[e],i++);s.length=i}switch(s.length){case 1:return s[0];case 2:return s[0]+" or "+s[1];default:return s.slice(0,-1).join(", ")+", or "+s[s.length-1]}}(t)+" but "+function(t){return t?'"'+r(t)+'"':"end of input"}(e)+" found."};class C{compile(t){const e=L(t,{});return new V(t,e)}execute(t){return this.compile(t).execute()}}class P{constructor(){this.pvs=new Map}canProvide(t){return t.startsWith("=")}startProviding(t){for(const e of t)this.pvs.set(e.name,new M(e))}stopProviding(t){for(const e of t)this.pvs.delete(e.name)}isNavigable(){return!1}shutdown(){}}class M{constructor(t){this.pv=t;const e=new C;this.compiledFormula=e.compile(t.name);for(const e of this.compiledFormula.getPVNames()){const i=t.pvEngine.createPV(e);this.compiledFormula.updateDataSource(i.name,{value:i.value,acquisitionStatus:"good"}),t.pvEngine.addListener(e,(()=>{this.compiledFormula.updateDataSource(e,{value:t.pvEngine.getValue(e),acquisitionStatus:"good"}),this.trigger()}))}this.trigger()}trigger(){const t=this.compiledFormula.execute();this.pv.pvEngine.setValue(new Date,this.pv.name,t)}}var k={exports:{}};!function(t){!function(){function e(t,e){document.addEventListener?t.addEventListener("scroll",e,!1):t.attachEvent("scroll",e)}function i(t){this.a=document.createElement("div"),this.a.setAttribute("aria-hidden","true"),this.a.appendChild(document.createTextNode(t)),this.b=document.createElement("span"),this.c=document.createElement("span"),this.h=document.createElement("span"),this.f=document.createElement("span"),this.g=-1,this.b.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.c.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.f.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.h.style.cssText="display:inline-block;width:200%;height:200%;font-size:16px;max-width:none;",this.b.appendChild(this.h),this.c.appendChild(this.f),this.a.appendChild(this.b),this.a.appendChild(this.c)}function s(t,e){t.a.style.cssText="max-width:none;min-width:20px;min-height:20px;display:inline-block;overflow:hidden;position:absolute;width:auto;margin:0;padding:0;top:-999px;white-space:nowrap;font-synthesis:none;font:"+e+";"}function r(t){var e=t.a.offsetWidth,i=e+100;return t.f.style.width=i+"px",t.c.scrollLeft=i,t.b.scrollLeft=t.b.scrollWidth+100,t.g!==e&&(t.g=e,!0)}function o(t,i){function s(){var t=o;r(t)&&t.a.parentNode&&i(t.g)}var o=t;e(t.b,s),e(t.c,s),r(t)}function h(t,e){var i=e||{};this.family=t,this.style=i.style||"normal",this.weight=i.weight||"normal",this.stretch=i.stretch||"normal"}var n=null,a=null,l=null,d=null;function c(){return null===d&&(d=!!document.fonts),d}function p(){if(null===l){var t=document.createElement("div");try{t.style.font="condensed 100px sans-serif"}catch(t){}l=""!==t.style.font}return l}function g(t,e){return[t.style,t.weight,p()?t.stretch:"","100px",e].join(" ")}h.prototype.load=function(t,e){var r=this,h=t||"BESbswy",l=0,d=e||3e3,p=(new Date).getTime();return new Promise((function(t,e){if(c()&&!function(){if(null===a)if(c()&&/Apple/.test(window.navigator.vendor)){var t=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))(?:\.([0-9]+))/.exec(window.navigator.userAgent);a=!!t&&603>parseInt(t[1],10)}else a=!1;return a}()){var u=new Promise((function(t,e){!function i(){(new Date).getTime()-p>=d?e(Error(d+"ms timeout exceeded")):document.fonts.load(g(r,'"'+r.family+'"'),h).then((function(e){1<=e.length?t():setTimeout(i,25)}),e)}()})),m=new Promise((function(t,e){l=setTimeout((function(){e(Error(d+"ms timeout exceeded"))}),d)}));Promise.race([m,u]).then((function(){clearTimeout(l),t(r)}),e)}else!function(t){document.body?t():document.addEventListener?document.addEventListener("DOMContentLoaded",(function e(){document.removeEventListener("DOMContentLoaded",e),t()})):document.attachEvent("onreadystatechange",(function e(){"interactive"!=document.readyState&&"complete"!=document.readyState||(document.detachEvent("onreadystatechange",e),t())}))}((function(){function a(){var e;(e=-1!=x&&-1!=f||-1!=x&&-1!=w||-1!=f&&-1!=w)&&((e=x!=f&&x!=w&&f!=w)||(null===n&&(e=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent),n=!!e&&(536>parseInt(e[1],10)||536===parseInt(e[1],10)&&11>=parseInt(e[2],10))),e=n&&(x==y&&f==y&&w==y||x==v&&f==v&&w==v||x==b&&f==b&&w==b)),e=!e),e&&(T.parentNode&&T.parentNode.removeChild(T),clearTimeout(l),t(r))}var c=new i(h),u=new i(h),m=new i(h),x=-1,f=-1,w=-1,y=-1,v=-1,b=-1,T=document.createElement("div");T.dir="ltr",s(c,g(r,"sans-serif")),s(u,g(r,"serif")),s(m,g(r,"monospace")),T.appendChild(c.a),T.appendChild(u.a),T.appendChild(m.a),document.body.appendChild(T),y=c.a.offsetWidth,v=u.a.offsetWidth,b=m.a.offsetWidth,function t(){if((new Date).getTime()-p>=d)T.parentNode&&T.parentNode.removeChild(T),e(Error(d+"ms timeout exceeded"));else{var i=document.hidden;!0!==i&&void 0!==i||(x=c.a.offsetWidth,f=u.a.offsetWidth,w=m.a.offsetWidth,a()),l=setTimeout(t,50)}}(),o(c,(function(t){x=t,a()})),s(c,g(r,'"'+r.family+'",sans-serif')),o(u,(function(t){f=t,a()})),s(u,g(r,'"'+r.family+'",serif')),o(m,(function(t){w=t,a()})),s(m,g(r,'"'+r.family+'",monospace'))}))}))},t.exports=h}()}(k);var R=k.exports;const E=["Arial","Arial Black","Courier New","Helvetica","Tahoma","Verdana"];class W{constructor(t,e,i,s){this.name=t,this.style=i,this.height=s?e:Math.round(16*e/15)}scale(t){return new W(this.name,t*this.height,this.style,!0)}getFontString(){return 1===this.style?`bold ${this.height}px ${this.name}`:2===this.style?`italic ${this.height}px ${this.name}`:(0!==this.style&&console.warn(`Unsupported font style ${this.style}`),`normal ${this.height}px ${this.name}`)}preload(){if(-1!==E.indexOf(this.name))return Promise.resolve();let t={weight:"normal",style:"normal"};return 1===this.style?t.weight="bold":2===this.style&&(t.style="italic"),new R(this.name,t).load()}}W.ARIAL_9=new W("Arial",9,0,!1),W.ARIAL_10=new W("Arial",10,0,!1),W.ARIAL_11=new W("Arial",11,0,!1),W.ARIAL_12_BOLD=new W("Arial",12,1,!1);class B{constructor(){this.BLACK=e.BLACK,this.BLUE=e.BLUE,this.CYAN=e.CYAN,this.DARK_GRAY=e.DARK_GRAY,this.GRAY=e.GRAY,this.GREEN=e.GREEN,this.LIGHT_BLUE=e.LIGHT_BLUE,this.ORANGE=e.ORANGE,this.PINK=e.PINK,this.PURPLE=e.PURPLE,this.RED=e.RED,this.WHITE=e.WHITE,this.YELLOW=e.YELLOW}getColorFromRGB(t,i,s){return new e(t,i,s)}getFont(t,e,i){return new W(t,e,i,!1)}}class I{writeInfo(t){console.log(t)}writeError(t){console.error(t)}writeWarning(t){console.warn(t)}}class O{createDoubleArray(t){return Array(t).fill(0)}createIntArray(t){return Array(t).fill(0)}toJavaDoubleArray(t){return[...t]}toJavaIntArray(t){return[...t]}}class H{constructor(t,e,i){this.code=t,this.interpolate=e,this.autoscale=i,this.values=[],this.colors=[],this.entries=[],this.dirty=!0,0===t||(1===t?(this.values=[0,1],this.colors=[[0,0,0],[255,255,255]]):2===t?(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]]):3===t?(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]]):4===t?(this.values=[0,.365,.746,1],this.colors=[[11,0,0],[255,0,0],[255,255,0],[255,255,255]]):5===t?(this.values=[0,1],this.colors=[[0,255,255],[255,0,255]]):6===t&&(this.values=[0,.5,1],this.colors=[[0,0,0],[255,0,0],[255,255,255]]))}addMapping(t,e,i,s){this.values.push(t),this.colors.push([e,i,s]),this.dirty=!0}compile(){this.entries.length=0;for(let t=0;t<this.values.length;t++)this.entries.push([this.values[t],this.colors[t]]);this.entries.sort(((t,e)=>t[0]<e[0]?-1:t[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,0===e)return this.entries[e][1];if(e===this.entries.length)return this.entries[e-1][1];if(this.interpolate){const[i,s]=this.entries[e-1],[r,o]=this.entries[e],h=(t-i)/(r-i);return[Math.floor((o[0]-s[0])*h+s[0]),Math.floor((o[1]-s[1])*h+s[1]),Math.floor((o[2]-s[2])*h+s[2])]}return this.entries[e-1][1]}getMinMax(){return[Math.min.apply(Math,this.values),Math.max.apply(Math,this.values)]}binarySearch(t){let e=0,i=this.entries.length-1;for(;e<=i;){const s=i+e>>1;if(t>this.entries[s][0])e=s+1;else{if(!(t<this.entries[s][0]))return s;i=s-1}}return-e-1}}class F{constructor(t,e=[]){this.widget=t,this.properties=new Map,this.generators=[];for(const t of e)this.properties.set(t.name,t)}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 K)e.value=t.getActions(e.name);else if(e instanceof it)e.value=t.getAutoScaleWidgets(e.name);else if(e instanceof z)e.value=t.getBoolean(e.name);else if(e instanceof Y)e.value=t.getColorMap(e.name);else if(e instanceof U)e.value=t.getColor(e.name);else if(e instanceof G)e.value=t.getFloat(e.name);else if(e instanceof q)e.value=t.getFont(e.name);else if(e instanceof $)e.value=t.getInt(e.name);else if(e instanceof Z)e.value=t.getMacros(e.name);else if(e instanceof X)e.value=t.getPoints(e.name);else if(e instanceof j);else if(e instanceof tt)e.value=t.getRules(e.name);else if(e instanceof et)e.value=t.getScaleOptions(e.name);else if(e instanceof J)e.value=t.getScripts(e.name);else if(e instanceof D)e.rawValue=t.getString(e.name);else{if(!(e instanceof Q))throw new Error(`Property ${e.name} has an unexpected type`);e.value=t.getStringList(e.name)}}loadXMLValues(t){this.properties.forEach((e=>{this.loadProperty(t,e)})),this.resolveStringProperties();for(const e of this.generators)for(const 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((t=>{if(t instanceof D){const e=t;void 0!==e.rawValue?t.value=this.widget.expandMacro(e.rawValue):t.value=e.rawValue}}))}getProperty(t){return this.properties.get(t)}getValue(t,e=!1){const i=this.properties.get(t);if(i&&void 0!==i.value)return i.value;if(!e)throw new Error(`Missing property ${t}`)}setValue(t,e){const i=this.properties.get(t);if(!i)throw new Error(`Cannot set value of unknown property ${t}`);i.value=e}}class N{constructor(t,e){this.name=t,this.defaultValue=e,this.value=e}get value(){return this._value}set value(t){if(this.value!==t){const e=this._value;if(this._value=t,this.listeners)for(const i of this.listeners)i(t,e)}}addListener(t){this.listeners=this.listeners||[],this.listeners.push(t)}removeListener(t){const e=this.listeners||[],i=e.indexOf(t);-1!==i&&e.splice(i,1)}printScriptValue(t){return String(t)}}class D extends N{printScriptValue(t){return`"${t.replace('"','\\"')}"`}}class j extends N{constructor(t,e){super(t),this.pvPropertyName=e}}class $ extends N{}class G extends N{}class z extends N{}class U extends N{printScriptValue(t){const{red:e,green:i,blue:s}=Object.assign({},t);return`ColorFontUtil.getColorFromRGB(${e}, ${i}, ${s})`}}class q extends N{printScriptValue(t){const{name:e,height:i,style:s}=Object.assign({},t);return`ColorFontUtil.getFont("${e}", ${i}, ${s})`}}class Y extends N{printScriptValue(t){return`${t.code}`}}class X extends N{}class K extends N{}class Z extends N{}class J extends N{}class Q extends N{}class tt extends N{}class et extends N{}class it extends N{}class st{constructor(t){this._pv=t}getName(){return this._pv.name}getValue(){return this._pv.value}setValue(t){this._pv.pvEngine.setValue(new Date,this._pv.name,t)}}class rt{constructor(t){this.widget=t}getPVByName(t){const e=this.widget.display.getPV(t);return e?new st(e):null}getPV(t="pv_name"){const e=this.getPropertyValue(t);return e?this.getPVByName(e):null}getPropertyValue(t){const e=this.widget.properties.getProperty(t);return e?e.value:null}setPropertyValue(t,e){const i=this.widget.properties.getProperty(t);if(!i)throw new Error(`Cannot set value of unknown property ${t}`);if(i instanceof D)e=void 0!==e?String(e):e,this.widget.properties.setValue(t,e);else if(i instanceof Y){let i=0;switch(e){case"GrayScale":i=1;break;case"JET":i=2;break;case"ColorSpectrum":i=3;break;case"Hot":i=4;break;case"Cool":i=5;break;case"Shaded":i=6}const s=new H(i,!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)}setVisible(t){this.setPropertyValue("visible",t)}getValue(){var t;return null!==(t=this.widget.value)&&void 0!==t?t:null}setValue(t){this.widget.value=t}setValueInUIThread(t){this.setValue(t)}}class ot extends rt{constructor(t){super(t),this.xyGraph=t}clearGraph(){this.xyGraph.clearGraph()}getXBuffer(t){return this.xyGraph.getTrace(t).snapshot().map((t=>t.x))}getYBuffer(t){return this.xyGraph.getTrace(t).snapshot().map((t=>t.y))}}function ht(t){return"XY Graph"===t.widgetType?new ot(t):new rt(t)}class nt{constructor(t){this.display=t}getWidget(t){const e=this.display.findWidgetByName(t);if(e)return ht(e)}}class at{fullScreen(){document.documentElement.requestFullscreen()}openConfirmDialog(t){return confirm(t)}openInformationDialog(t){alert(t)}openWarningDialog(t){alert(t)}openErrorDialog(t){alert(t)}openPasswordDialog(t,e){let i=prompt(t);if(i)return i===e}}class lt{openInformation(t,e,i){alert(i)}openConfirm(t,e,i){return confirm(i)}openError(t,e,i){alert(i)}}const dt=["yyyy","MM","dd","HH","mm","ss","nnnnnnnnn"];class ct{constructor(t){this.pvEngine=t}getDouble(t){return parseFloat(t.getValue())}getLong(t){return parseInt(t.getValue(),10)}getString(t){return String(t.getValue())}getTimeString(t,e="yyyy-MM-dd HH:mm:ss.nnnnnnnnn"){const i=t._pv.time;if(i){let t=e;for(const e of dt)t=t.replace(e,this.formatDate(i,e));return t}return null}formatDate(t,e){if("yyyy"===e)return String(t.getUTCFullYear());if("MM"===e){const e=t.getUTCMonth()+1;return e<10?"0"+e:""+e}if("dd"===e){const e=t.getUTCDate();return e<10?"0"+e:""+e}if("HH"===e){const e=t.getUTCHours();return e<10?"0"+e:""+e}if("mm"===e){const e=t.getUTCMinutes();return e<10?"0"+e:""+e}if("ss"===e){const e=t.getUTCSeconds();return e<10?"0"+e:""+e}if("nnnnnnnnn"===e){const e=t.getUTCMilliseconds();return e<10?"00"+e:e<100?"0"+e:""+e}throw new Error(`Unexpected format '${e}'`)}}class pt{constructor(t){this.display=t}openOPI(t,e,i,s){if(0!==i)throw new Error(`Unsupported target ${i}`);{const t={path:e,replace:0===i};this.display.fireEvent("opendisplay",t)}}closeCurrentOPI(){this.display.fireEvent("closedisplay",{})}}let gt,ut,mt;class xt{constructor(t,e,i=[]){this.scriptText=e,gt||(gt=document.createElement("iframe"),gt.id="script-e",gt.style.display="none",document.body.appendChild(gt),ut=gt.contentWindow,mt=ut.eval,!mt&&ut.execScript&&(ut.execScript.call(ut,"null"),mt=ut.eval)),this.scriptText=e.replace(/importClass\([^\)]*\)\s*\;?/gi,"").replace(/importPackage\([^\)]*\)\s*\;?/gi,"").trim(),this.context=Object.assign({display:new nt(t.display),pvs:i.map((t=>new st(t))),widget:ht(t),ConsoleUtil:new I,ColorFontUtil:new B,DataUtil:new O,GUIUtil:new at,MessageDialog:new lt,PVUtil:new ct(t.display.pvEngine),ScriptUtil:new pt(t.display)},t.display.pvEngine.scriptLibraries)}run(){const t=[];for(const e in gt.contentWindow)t.push(e);try{for(const t in this.context)this.context.hasOwnProperty(t)&&(ut[t]=this.context[t]);mt.call(ut,this.scriptText);const e={};for(const i in ut)-1===t.indexOf(i)&&(e[i]=ut[i]);this.context=e}finally{for(const e in ut)-1===t.indexOf(e)&&delete ut[e]}}}class ft{constructor(e,i){this.name=e,this.pvEngine=i,this._writable=!1,this._severity=t.AlarmSeverity.NONE,this._precision=3,this._disconnected=!1,this.navigable=!1}get units(){return this._units}set units(t){this._units=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}toNumber(){return null===this.value?null:"number"==typeof this.value?this.value:"boolean"==typeof this.value?this.value?1:0:void 0!==typeof this.indexValue?this.indexValue:void 0}formatValue(t,e){return null===this.value?"":"string"==typeof this.value?this.value:"number"==typeof this.value?this.formatNumber(t,this.value,e):this.value instanceof Date?this.value.toISOString().replace("T"," ").replace("Z",""):String(this.value)}formatNumber(t,e,i){if(null==e||null==e)return"";switch(t){case 0:case 1:return-1===i?String(e):e.toFixed(i);case 2:return e.toExponential().replace("e+","E").toUpperCase();case 3:return"0x"+e.toString(16).toUpperCase();default:return console.warn(`Unexpected format type ${t}`),String(e)}}setSample(t){this._time=t.time,this._value=t.value,this._indexValue=t.valueIndex,this._severity=t.severity,this.pvEngine.requestRepaint()}addListener(t){this.pvEngine.addListener(this.name,t)}removeListener(t){this.pvEngine.addListener(this.name,t)}toString(){if(void 0!==this.value)return String(this.value)}}var wt;t.AlarmSeverity=void 0,(wt=t.AlarmSeverity||(t.AlarmSeverity={}))[wt.NONE=0]="NONE",wt[wt.MINOR=1]="MINOR",wt[wt.MAJOR=2]="MAJOR",wt[wt.INVALID=3]="INVALID",wt[wt.UNDEFINED=4]="UNDEFINED";class yt extends ft{constructor(t,e,i){super(t,e),this.initializer=i,this.writable=!0}}const vt=/(loc\:\/\/[^\(]+)(\((.*)\))?/;function bt(t){if(!t.startsWith("loc://"))return t;const e=t.match(vt);return e?e[1]:t}class Tt{constructor(t){this.display=t,this.rules=[],this.scripts=[],this.pvs=new Map,this.providers=[],this.scriptLibraries={},this.listeners=new Map}clearState(){this.disconnectAll(),this.rules=[],this.scripts=[],this.listeners.clear()}getPVNames(){return[...this.pvs.keys()]}hasPV(t){const e=bt(t);return this.pvs.has(e)}getPV(t){const e=bt(t);return this.pvs.get(e)}disconnectAll(){for(const t of this.providers){const e=[];for(const 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 ft(t,this),this.pvs.set(t,e);for(const i of this.providers)if(i.canProvide(t))return e.navigable=i.isNavigable(),i.startProviding([e]),e;return console.warn(`No provider for PV ${t}`),e.disconnected=!0,e}requestRepaint(){this.display.requestRepaint()}createLocalPV(t){const e=t.match(vt);let i;if(e&&(t=e[1],void 0!==e[3])){const t=e[3];i=t.startsWith('"')&&t.endsWith('"')?t.substring(1,t.length-1):-1!==t.indexOf(",")?t.split(",").map((t=>Number(t.trim()))):Number(t)}let s=this.pvs.get(t),r=!1;if(s){const e=s;void 0===e.initializer||void 0===i||this.initializerEquals(e.initializer,i)?void 0===e.initializer&&void 0!==i&&(r=!0):console.warn(`PV ${t} is defined with different initializers: ${e.initializer} !== ${i}`)}return s||(s=new yt(t,this,i),this.pvs.set(t,s),r=!0),r&&void 0!==i&&this.setValue(new Date,t,i),s}initializerEquals(t,e){if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}return t===e}getValue(t){const e=bt(t),i=this.pvs.get(e);if(i)return i.value}setValue(e,i,s,r=t.AlarmSeverity.NONE){const o=bt(i),h=this.pvs.get(o);if(!h)throw new Error(`Cannot set value of unknown PV ${i}`);h.setSample({time:e,value:s,severity:r});for(const t of this.listeners.get(i)||[])t()}setValues(t){const e=[];for(const i of t.keys()){const s=this.pvs.get(i);if(s){s.setSample(t.get(i));for(const t of this.listeners.get(i)||[])e.push(t)}else console.warn(`Received an update for unknown pv ${i}`)}for(const t of e)t()}createScript(t,e,i){const s=[];for(const i of e.inputs){const e=t.expandMacro(i.pvName);s.push(this.createPV(e))}const r=new St(t,e,i,s);this.scripts.push(r);const o=()=>{if(e.checkConnect)for(const t of s)if(t.disconnected||null===t.value||void 0===t.value)return;r.scriptEngine.run()};for(const i of e.inputs)if(i.trigger){const e=t.expandMacro(i.pvName);this.addListener(e,o)}}createRule(t,e){const i=[];for(const s of e.inputs){const e=t.expandMacro(s.pvName);i.push(this.createPV(e))}const s=new Vt(t,e,i);this.rules.push(s);const r=()=>s.scriptEngine.run();for(const i of e.inputs)if(i.trigger){const e=t.expandMacro(i.pvName);this.addListener(e,r)}}addProvider(t){this.providers.push(t)}addScriptLibrary(t,e){this.scriptLibraries[t]=e}addListener(t,e){const i=bt(t),s=this.listeners.get(i);s?s.push(e):this.listeners.set(i,[e]);const r=this.pvs.get(i);r&&null!==r.value&&void 0!==r.value&&e()}removeListener(t,e){const i=bt(t),s=this.listeners.get(i);if(s){const t=s.indexOf(e);-1!==t&&s.splice(t,1)}}}class St{constructor(t,e,i,s){this.widget=t,this.script=e,this.text=i,this.scriptEngine=new xt(t,i,s)}}class Vt{constructor(t,e,i){this.widget=t,this.rule=e;let s="";const r=t.properties.getProperty(e.propertyName);if(!r)throw new Error(`Cannot create rule for unsupported property ${e.propertyName}`);if(e.expressions.length){let t=!1,o=!1,h=!1,n=!1;for(const i of e.expressions)i.expression.match(/pv[0-9]+/)&&(t=!0),e.outputExpression&&i.outputValue.toString().match(/pv[0-9]+/)&&(t=!0),-1!==i.expression.indexOf("pvInt")&&(o=!0),e.outputExpression&&-1!==i.outputValue.toString().indexOf("pvInt")&&(o=!0),-1!==i.expression.indexOf("pvStr")&&(h=!0),e.outputExpression&&-1!==i.outputValue.toString().indexOf("pvStr")&&(h=!0),-1!==i.expression.indexOf("pvSev")&&(n=!0),e.outputExpression&&-1!==i.outputValue.toString().indexOf("pvSev")&&(n=!0);for(let e=0;e<i.length;e++)t&&(s+=`var pv${e} = PVUtil.getDouble(pvs[${e}]);\n`),o&&(s+=`var pvInt${e} = PVUtil.getLong(pvs[${e}]);\n`),h&&(s+=`var pvStr${e} = PVUtil.getString(pvs[${e}]);\n`),n&&(s+=`var pvSev${e} = PVUtil.getSeverity(pvs[${e}]);\n`);for(let t=0;t<e.expressions.length;t++){const i=e.expressions[t].expression,o=e.expressions[t].outputValue;if(t>0&&(s+="else "),s+=`if (${i}) widget.setPropertyValue("${e.propertyName}", `,e.outputExpression)s+=`${o});\n`;else{s+=`${this.printScriptValue(r,o)});\n`}}const a=r.value,l=this.printScriptValue(r,a);s+=`else widget.setPropertyValue("${e.propertyName}", `,s+=`${l});\n`}this.scriptEngine=new xt(t,s,i)}printScriptValue(t,e){return null==e?"null":t.printScriptValue(e)}}class At{constructor(t,e,i){this.pv=t,this.interval=e,void 0!==i&&t.pvEngine.setValue(new Date,t.name,i),this.interval>0&&(this.timer=window.setInterval((()=>{this.generateSample(new Date)}),e))}emit(e,i){let s=t.AlarmSeverity.NONE;void 0!==this.pv.lowerAlarmLimit&&i<this.pv.lowerAlarmLimit||void 0!==this.pv.upperAlarmLimit&&i>this.pv.upperAlarmLimit?s=t.AlarmSeverity.MAJOR:(void 0!==this.pv.lowerWarningLimit&&i<this.pv.lowerWarningLimit||void 0!==this.pv.upperWarningLimit&&i>this.pv.upperWarningLimit)&&(s=t.AlarmSeverity.MINOR),this.pv.pvEngine.setValue(e,this.pv.name,i,s)}stop(){window.clearInterval(this.timer)}}class _t extends At{constructor(t,e){super(t,-1,e)}generateSample(){}}class Lt extends At{constructor(t,e,i,s){super(t,s),this.min=e,this.max=i;const r=this.max-this.min;t.units="x",t.lowerDisplayLimit=e,t.lowerAlarmLimit=e+.1*r,t.lowerWarningLimit=e+.2*r,t.upperWarningLimit=e+.8*r,t.upperAlarmLimit=e+.9*r,t.upperDisplayLimit=i}generateSample(t){const e=Math.random()*(this.max-this.min)+this.min;this.emit(t,e)}}class Ct extends At{constructor(t,e,i,s){super(t,s),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,s;do{e=2*Math.random()-1,i=2*Math.random()-1,s=e*e+i*i}while(s>=1||0===s);const r=e*Math.sqrt(-2*Math.log(s)/s);this.emit(t,this.avg+r*this.stddev)}}class Pt extends At{constructor(t,e,i,s,r){super(t,r),this.min=e,this.max=i,this.samplesPerCycle=s,this.currentValue=0;const o=this.max-this.min;t.units="x",t.lowerDisplayLimit=e,t.lowerAlarmLimit=e+.1*o,t.lowerWarningLimit=e+.2*o,t.upperWarningLimit=e+.8*o,t.upperAlarmLimit=e+.9*o,t.upperDisplayLimit=i}generateSample(t){const e=this.max-this.min,i=Math.sin(2*this.currentValue*Math.PI/this.samplesPerCycle)*e/2+this.min+e/2;this.currentValue++,this.emit(t,i)}}class Mt extends At{constructor(t,e,i,s,r){super(t,r),this.min=e,this.max=i,this.inc=s,this.currentValue=0,this.currentValue=s>=0?e-s:i-s;const o=this.max-this.min;t.units="x",t.lowerDisplayLimit=e,t.lowerAlarmLimit=e+.1*o,t.lowerWarningLimit=e+.2*o,t.upperWarningLimit=e+.8*o,t.upperAlarmLimit=e+.9*o,t.upperDisplayLimit=i}generateSample(t){this.currentValue=this.currentValue+this.inc,this.currentValue>this.max&&(this.currentValue=this.min),this.currentValue<this.min&&(this.currentValue=this.max),this.emit(t,this.currentValue)}}const kt=/sim\:\/\/([a-zA-Z]+)(\((.*)\))?/;class Rt{constructor(){this.pvs=new Map}canProvide(t){return t.startsWith("sim://")}startProviding(t){for(const e of t){const t=new Et(e);this.pvs.set(e.name,t)}}stopProviding(t){for(const e of t){const t=this.pvs.get(e.name);t&&(t.fn.stop(),this.pvs.delete(e.name))}}isNavigable(){return!1}shutdown(){for(const t of this.pvs.values())t.fn.stop()}}class Et{constructor(t){this.pv=t;const e=t.name.match(kt);if(e){const t=e[3]?e[3].split(","):[];for(let e=0;e<t.length;e++)t[e]=t[e].trim();this.fn=this.createGenerator(e[1],t)}else console.warn(`Unexpected pattern for PV ${t.name}`),this.fn=new _t(t,void 0)}createGenerator(t,e){switch(t){case"const":const i=this.saferEval(e[0]);return new _t(this.pv,i);case"gaussianNoise":return this.createGaussianNoise(e);case"noise":return this.createNoise(e);case"ramp":return this.createRamp(e);case"sine":return this.createSine(e);default:return console.warn(`Unexpected function ${t} for PV ${this.pv.name}`),new _t(this.pv,void 0)}}saferEval(t){return Function('"use strict";return ('+t+")")()}createNoise(t){if(0===t.length)return new Lt(this.pv,-5,5,1e3);{const e=parseFloat(t[0]),i=parseFloat(t[1]),s=1e3*parseFloat(t[2]);return new Lt(this.pv,e,i,s)}}createGaussianNoise(t){if(0===t.length)return new Ct(this.pv,0,1,100);{const e=parseFloat(t[0]),i=parseFloat(t[1]),s=1e3*parseFloat(t[2]);return new Ct(this.pv,e,i,s)}}createRamp(t){let e;if(0===t.length)e=new Mt(this.pv,-5,5,1,1e3);else if(3===t.length){const i=parseFloat(t[0]),s=parseFloat(t[1]),r=1e3*parseFloat(t[2]);e=new Mt(this.pv,i,s,1,r)}else{if(4!==t.length)return console.warn(`Unexpected ramp arguments for PV ${this.pv.name}`),new _t(this.pv,void 0);{const i=parseFloat(t[0]),s=parseFloat(t[1]),r=parseFloat(t[2]),o=1e3*parseFloat(t[3]);e=new Mt(this.pv,i,s,r,o)}}return e}createSine(t){let e;if(0===t.length)e=new Pt(this.pv,-5,5,10,1e3);else if(3===t.length){const i=parseFloat(t[0]),s=parseFloat(t[1]),r=1e3*parseFloat(t[2]);e=new Pt(this.pv,i,s,10,r)}else{if(4!==t.length)return console.warn(`Unexpected sine arguments for PV ${this.pv.name}`),new _t(this.pv,void 0);{const i=parseFloat(t[0]),s=parseFloat(t[1]),r=parseFloat(t[2]),o=1e3*parseFloat(t[3]);e=new Pt(this.pv,i,s,r,o)}}return e}}class Wt{constructor(){this.actions=[],this.hookFirstActionToClick=!1,this.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]}getClickActions(){const t=[];if(this.hookFirstActionToClick)t.push(0);else if(this.hookAllActionsToClick)for(let e=0;e<this.actions.length;e++)t.push(e);return t}toString(){return 1===this.actions.length?String(this.actions[0])||this.actions[0].type:`${this.actions.length} actions`}}class Bt{constructor(t){this.path=t,this.type="OPEN_DISPLAY"}toString(){return`Open ${this.path}`}}class It{constructor(){this.type="OPEN_FILE"}toString(){return`Open ${this.path}`}}class Ot{constructor(t){this.embedded=t,this.type="EXECUTE_JAVASCRIPT"}toString(){return"Execute JavaScript"}}class Ht{constructor(){this.type="EXECUTE_CMD"}toString(){return`Execute Command ${this.command}`}}class Ft{constructor(t,e){this.pvName=t,this.value=e,this.type="WRITE_PV"}toString(){return`Write ${this.value} to ${this.pvName}`}}class Nt{constructor(){this.type="PLAY_SOUND"}toString(){return`Play WAV File ${this.path}`}}class Dt{constructor(){this.type="OPEN_WEBPAGE"}toString(){return`Open Webpage ${this.hyperlink}`}}class jt{constructor(){this.rules=[]}}const $t="actions",Gt="background_color",zt="backcolor_alarm_sensitive",Ut="border_alarm_sensitive",qt="border_color",Yt="border_width",Xt="border_style",Kt="enabled",Zt="foreground_color",Jt="forecolor_alarm_sensitive",Qt="height",te="name",ee="pv_name",ie="pv_value",se="rules",re="scale_options",oe="scripts",he="text",ne="tooltip",ae="transparent",le="visible",de="widget_type",ce="width",pe="wuid";class ge{constructor(t,i){this.display=t,this.parent=i,this.x=0,this.y=0,this.width=0,this.height=0,this.fillRoundRectangleBackgroundBorder=!0,this.properties=new F(this,[new K($t,new Wt),new z(zt,!1),new U(Gt,e.TRANSPARENT),new z(Ut,!1),new U(qt),new $(Xt),new $(Yt),new z(Kt,!0),new z(Jt,!1),new U(Zt),new $(Qt),new D(te),new D(ee),new j(ie,ee),new tt(se,new jt),new J(oe),new D(he,""),new D(ne,""),new z(ae,!1),new z(le),new D(de),new $(ce),new D(pe),new $("x"),new $("y"),new et(re)])}parseNode(t){this.properties.loadXMLValues(t);for(const t of this.properties.all())if(t instanceof q){const e=t.value;e.preload().then((()=>this.requestRepaint())).catch((()=>console.warn(`Failed to load font '${e.getFontString()}'.`)))}this.pvName&&this.display.pvEngine.createPV(this.pvName);for(const t of this.scripts.scripts)t.embedded?this.display.pvEngine.createScript(this,t,t.text):fetch(`${this.display.baseUrl}${t.path}`,{credentials:"same-origin"}).then((e=>{e.ok&&e.text().then((e=>{this.display.pvEngine.createScript(this,t,e)}))}));for(const t of this.rules.rules)this.properties.getProperty(t.propertyName)?this.display.pvEngine.createRule(this,t):console.warn(`Cannot create rule for unsupported property ${t.propertyName}`);(this.tooltip||this.actions.isClickable())&&(this.holderRegion={id:`${this.wuid}-holder`},this.tooltip&&(this.holderRegion.tooltip=()=>this.tooltip),this.actions.isClickable()&&(this.holderRegion.click=()=>{for(const t of this.actions.getClickActions())this.executeAction(t)},this.holderRegion.cursor="pointer")),this.init()}drawHolder(e){var i,s;const{scale:r}=this;let o=[0,0,0,0];const h=this.borderAlarmSensitive&&((null===(i=this.pv)||void 0===i?void 0:i.severity)===t.AlarmSeverity.MINOR||(null===(s=this.pv)||void 0===s?void 0:s.severity)===t.AlarmSeverity.MAJOR);if(!h)switch(this.borderStyle){case 0:break;case 1:case 8:case 9:case 10:case 11:o=[this.borderWidth,this.borderWidth,this.borderWidth,this.borderWidth];break;case 2:case 3:o=[1*r,1*r,1*r,1*r];break;case 4:case 5:case 6:o=[2*r,2*r,2*r,2*r];break;case 7:o=[2*r,2*r,1*r,1*r];break;case 12:o=[17*r,1*r,1*r,1*r];break;case 13:o=[16*r,16*r,16*r,16*r];break;case 14:const t=2*this.borderWidth;o=[t,t,t,t]}this.x=this.holderX+o[1],this.y=this.holderY+o[0],this.width=this.holderWidth-o[1]-o[3],this.height=this.holderHeight-o[0]-o[2],h||this.drawBorderStyle(e),this.holderRegion&&e.addHitRegion(this.holderRegion).addRect(this.holderX,this.holderY,this.holderWidth,this.holderHeight)}drawBorderStyle(t){const{scale:i}=this;if(0===this.borderStyle);else if(1===this.borderStyle)t.strokeRect({x:this.holderX,y:this.holderY,width:this.holderWidth,height:this.holderHeight,color:this.borderColor,lineWidth:this.borderWidth,crispen:!0});else if(2===this.borderStyle){const s=1*i,r=this.holderY+s/2,o=this.holderX+s/2,h=this.holderY+this.holderHeight-s+s/2,n=this.holderX+this.holderWidth-s+s/2;t.strokePath({color:e.BLACK,path:new b(n,h).lineTo(n,r).moveTo(n,h).lineTo(o,h)}),t.strokePath({color:e.WHITE,path:new b(o,r).lineTo(n-s,r).moveTo(o,r).lineTo(o,h-s)})}else if(3===this.borderStyle){const s=1*i,r=this.holderY+s/2,o=this.holderX+s/2,h=this.holderY+this.holderHeight-s+s/2,n=this.holderX+this.holderWidth-s+s/2;t.strokePath({color:e.WHITE,path:new b(n,h).lineTo(n,r).moveTo(n,h).lineTo(o,h)}),t.strokePath({color:e.BLACK,path:new b(o,r).lineTo(n-s,r).moveTo(o,r).lineTo(o,h-s)})}else if(4===this.borderStyle)this.drawShadowBorder(t,e.BUTTON_LIGHTEST,e.BUTTON_DARKER,e.BUTTON_DARKER,e.BUTTON_LIGHTEST);else if(5===this.borderStyle)this.drawShadowBorder(t,e.BUTTON_DARKER,e.BUTTON_LIGHTEST,e.BUTTON_LIGHTEST,e.BUTTON_DARKER);else if(6===this.borderStyle)this.drawShadowBorder(t,e.BUTTON_DARKEST,e.BUTTON_DARKER,e.BUTTON,e.BUTTON_LIGHTEST);else if(7===this.borderStyle)this.drawShadowBorder(t,e.BUTTON_LIGHTEST,e.BUTTON_LIGHTEST,e.BUTTON_DARKEST,e.BUTTON_DARKER);else if(8===this.borderStyle)this.drawDashedBorder(t,[2*i,2*i]);else if(9===this.borderStyle)this.drawDashedBorder(t,[6*i,2*i]);else if(10===this.borderStyle)this.drawDashedBorder(t,[6*i,2*i,2*i,2*i]);else if(11===this.borderStyle)this.drawDashedBorder(t,[6*i,2*i,2*i,2*i,2*i,2*i]);else if(12===this.borderStyle)t.fillRect({x:this.holderX,y:this.holderY+1*i,width:this.holderWidth,height:16*i,color:this.borderColor}),t.fillText({x:this.holderX+1*i+3*i,y:this.holderY+1*i+8*i,baseline:"middle",align:"left",font:W.ARIAL_11.scale(i),color:e.BLACK,text:this.name}),t.strokeRect({x:this.holderX,y:this.holderY,width:this.holderWidth,height:this.holderHeight,color:e.BLACK,crispen:!0});else if(13===this.borderStyle){this.transparent||t.fillRect({x:this.holderX,y:this.holderY,width:this.holderWidth,height:this.holderHeight,color:this.backgroundColor}),t.fillText({x:this.holderX+16*i,y:this.holderY+8*i,baseline:"middle",align:"left",font:W.ARIAL_11.scale(i),color:this.borderColor,text:this.name});const e=t.measureText(this.name,W.ARIAL_11.scale(i)),s=1;let r=a(this.holderX+8*i,this.holderY+8*i,this.holderWidth-16*i-s,this.holderHeight-16*i-s,s);t.strokePath({color:this.backgroundColor.darker(),path:new b(r.x,r.y).lineTo(r.x+8*i,r.y).moveTo(r.x+8*i+e.width,r.y).lineTo(r.x+r.width,r.y).lineTo(r.x+r.width,r.y+r.height).lineTo(r.x,r.y+r.height).lineTo(r.x,r.y)}),r=a(this.holderX+8*i+s,this.holderY+8*i+s,this.holderWidth-16*i-s,this.holderHeight-16*i-s,s),t.strokePath({color:this.backgroundColor.brighter(),path:new b(r.x,r.y).lineTo(r.x+8*i-s,r.y).moveTo(r.x+8*i-s+e.width,r.y).lineTo(r.x+r.width,r.y).lineTo(r.x+r.width,r.y+r.height).lineTo(r.x,r.y+r.height).lineTo(r.x,r.y)})}else if(14===this.borderStyle){const e=a(this.holderX,this.holderY,this.holderWidth,this.holderHeight,this.borderWidth);this.fillRoundRectangleBackgroundBorder&&t.fillRect(Object.assign(Object.assign({},e),{rx:4*i,ry:4*i,color:this.backgroundColor})),this.borderWidth&&t.strokeRect(Object.assign(Object.assign({},e),{rx:4*i,ry:4*i,color:this.borderColor,lineWidth:this.borderWidth}))}else 15===this.borderStyle||console.warn(`Unsupported border style: ${this.borderStyle}`)}drawDecoration(i){var s,r,o;if(this.display.editMode)return;const{scale:h}=this;if(!this.pvName||this.pv&&!this.pv.disconnected)this.pv&&void 0===this.pv.value&&i.strokeRect(Object.assign(Object.assign({},this.bounds),{dash:[2*h,2*h],lineWidth:2*h,color:e.PINK,crispen:!0}));else{const t=1*h;i.fillRect({x:this.holderX-t/2,y:this.holderY-t/2,width:this.holderWidth+t,height:this.holderHeight+t,color:e.PURPLE,opacity:.4}),i.strokeRect({x:this.holderX-t/2,y:this.holderY-t/2,width:this.holderWidth+t,height:this.holderHeight+t,color:e.PURPLE})}if(this.borderAlarmSensitive){let n;8===this.borderStyle?n=[2*h,2*h]:9===this.borderStyle?n=[6*h,2*h]:10===this.borderStyle?n=[6*h,2*h,2*h,2*h]:11===this.borderStyle&&(n=[6*h,2*h,2*h,2*h,2*h,2*h]),(null===(s=this.pv)||void 0===s?void 0:s.severity)===t.AlarmSeverity.MAJOR?i.strokeRect(Object.assign(Object.assign({},this.bounds),{lineWidth:2*h,color:e.RED,crispen:!0,dash:n})):(null===(r=this.pv)||void 0===r?void 0:r.severity)===t.AlarmSeverity.MINOR?i.strokeRect(Object.assign(Object.assign({},this.bounds),{lineWidth:2*h,color:e.ORANGE,crispen:!0,dash:n})):(null===(o=this.pv)||void 0===o?void 0:o.severity)===t.AlarmSeverity.INVALID&&i.strokeRect(Object.assign(Object.assign({},this.bounds),{lineWidth:2*h,color:e.PINK,crispen:!0}))}}drawOverlay(t){}drawSelection(t){t.lineWidth=1,t.strokeStyle="black",t.strokeRect(this.holderX-.5,this.holderY-.5,this.holderWidth+1,this.holderHeight+1),t.fillStyle="black";let e=2;t.fillRect(this.holderX-e,this.holderY-e,e+e,e+e),t.fillRect(this.holderX+this.holderWidth/2-e,this.holderY-e,e+e,e+e),t.fillRect(this.holderX+this.holderWidth-e,this.holderY-e,e+e,e+e),t.fillRect(this.holderX-e,this.holderY+this.holderHeight/2-e,e+e,e+e),t.fillRect(this.holderX+this.holderWidth-e,this.holderY+this.holderHeight/2-e,e+e,e+e),t.fillRect(this.holderX-e,this.holderY+this.holderHeight-e,e+e,e+e),t.fillRect(this.holderX+this.holderWidth/2-e,this.holderY+this.holderHeight-e,e+e,e+e),t.fillRect(this.holderX+this.holderWidth-e,this.holderY+this.holderHeight-e,e+e,e+e),t.strokeStyle="white",e=3,t.strokeRect(this.holderX-e+.5,this.holderY-e+.5,e+e-1,e+e-1),t.strokeRect(this.holderX+this.holderWidth/2-e+.5,this.holderY-e+.5,e+e-1,e+e-1),t.strokeRect(this.holderX+this.holderWidth-e+.5,this.holderY-e+.5,e+e-1,e+e-1),t.strokeRect(this.holderX-e+.5,this.holderY+this.holderHeight/2-e+.5,e+e-1,e+e-1),t.strokeRect(this.holderX+this.holderWidth-e+.5,this.holderY+this.holderHeight/2-e+.5,e+e-1,e+e-1),t.strokeRect(this.holderX-e+.5,this.holderY+this.holderHeight-e+.5,e+e-1,e+e-1),t.strokeRect(this.holderX+this.holderWidth/2-e+.5,this.holderY+this.holderHeight-e+.5,e+e-1,e+e-1),t.strokeRect(this.holderX+this.holderWidth-e+.5,this.holderY+this.holderHeight-e+.5,e+e-1,e+e-1)}requestRepaint(){this.display.requestRepaint()}closeMenu(){}get bounds(){return{x:this.holderX,y:this.holderY,width:this.holderWidth,height:this.holderHeight}}get unscaledBounds(){return{x:this.properties.getValue("x"),y:this.properties.getValue("y"),width:this.properties.getValue(ce),height:this.properties.getValue(Qt)}}get area(){return{x:this.x,y:this.y,width:this.width,height:this.height}}drawShadowBorder(t,e,i,s,r){const o=1*this.scale,h=this.holderY+o/2,n=this.holderX+o/2,a=this.holderY+this.holderHeight-o+o/2,l=this.holderX+this.holderWidth-o+o/2;t.strokePath({color:e,path:new b(l,a).lineTo(l,h).moveTo(l,a).lineTo(n,a)}),t.strokePath({color:i,path:new b(l-o,a-o).lineTo(l-o,h+o).moveTo(l-o,a-o).lineTo(n+o,a-o)}),t.strokePath({color:s,path:new b(n,h).lineTo(l-o,h).moveTo(n,h).lineTo(n,a-o)}),t.strokePath({color:r,path:new b(n+o,h+o).lineTo(l-o-o,h+o).moveTo(n+o,h+o).lineTo(n+o,a-o-o)})}drawDashedBorder(t,e){const i=a(this.holderX,this.holderY,this.holderWidth,this.holderHeight,this.borderWidth);t.strokePath({color:this.borderColor,lineWidth:this.borderWidth,dash:e,path:new b(i.x,i.y).lineTo(i.x+i.width,i.y).lineTo(i.x+i.width,i.y+i.height).lineTo(i.x,i.y+i.height).closePath()})}executeAction(t){const e=this.actions.getAction(t);if(e)switch(e.type){case"OPEN_DISPLAY":const t={path:e.path,replace:0===e.mode};this.display.fireEvent("opendisplay",t);break;case"EXECUTE_JAVASCRIPT":if(e.embedded){new xt(this.display.instance,e.text).run()}else fetch(`${this.display.baseUrl}${e.path}`,{credentials:"same-origin"}).then((t=>{t.ok&&t.text().then((t=>{new xt(this.display.instance,t).run()}))}));break;case"WRITE_PV":if(e.pvName){const t=this.expandMacro(e.pvName);this.display.pvEngine.setValue(new Date,t,e.value)}break;case"PLAY_SOUND":if(e.path){new Audio(`${this.display.baseUrl}${e.path}`).play()}break;case"OPEN_WEBPAGE":e.hyperlink&&(window.location.href=e.hyperlink);break;default:throw new Error(`Unsupported command ${e.type}`)}}expandMacro(t){var e;if(-1===t.indexOf("$"))return t;for(const i of this.properties.all())if(i instanceof j){const s=this.properties.getProperty(i.pvPropertyName);let r="";const o=null==s?void 0:s.value;if(o){const t=this.display.getPV(o);r=null!==(e=null==t?void 0:t.value)&&void 0!==e?e:""}t=(t=t.replace(`$(${i.name})`,r)).replace(`\${${i.name}}`,r)}else t=(t=t.replace(`$(${i.name})`,i.value||"")).replace(`\${${i.name}}`,i.value||"");return this.parent?this.parent.expandContainerMacros(t):t}get pv(){if(this.pvName)return this.display.getPV(this.pvName)}isMinorSeverity(){var e;return(null===(e=this.pv)||void 0===e?void 0:e.severity)===t.AlarmSeverity.MINOR}isMajorSeverity(){var e;return(null===(e=this.pv)||void 0===e?void 0:e.severity)===t.AlarmSeverity.MAJOR}get alarm(){var e,i;return(null===(e=this.pv)||void 0===e?void 0:e.severity)===t.AlarmSeverity.MINOR||(null===(i=this.pv)||void 0===i?void 0:i.severity)===t.AlarmSeverity.MAJOR}get alarmSensitiveBackgroundColor(){if(this.backgroundAlarmSensitive){if(this.isMajorSeverity())return e.RED;if(this.isMinorSeverity())return e.ORANGE}return this.backgroundColor}get alarmSensitiveForegroundColor(){if(this.foregroundAlarmSensitive){if(this.isMajorSeverity())return e.RED;if(this.isMinorSeverity())return e.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){const i=this.display.measureAbsoluteArea(this);return this.display.copyCanvas(i).toDataURL(t,e)}get wuid(){return this.properties.getValue(pe)}get name(){return this.properties.getValue(te)}get holderX(){return this.scale*this.properties.getValue("x")}get holderY(){return this.scale*this.properties.getValue("y")}get holderWidth(){return this.scale*this.properties.getValue(ce)}get holderHeight(){return this.scale*this.properties.getValue(Qt)}get borderAlarmSensitive(){return this.properties.getValue(Ut)}get backgroundAlarmSensitive(){return this.properties.getValue(zt)}get foregroundAlarmSensitive(){return this.properties.getValue(Jt)}get pvName(){return this.properties.getValue(ee,!0)}get pvValue(){return this.properties.getValue(ie,!0)}get borderColor(){return this.properties.getValue(qt)}get borderStyle(){return this.properties.getValue(Xt)}get borderWidth(){return this.scale*this.properties.getValue(Yt)}get backgroundColor(){return this.properties.getValue(Gt)}get enabled(){return this.properties.getValue(Kt)}get foregroundColor(){return this.properties.getValue(Zt)}get tooltip(){const t=this.properties.getProperty(ne);if(t.rawValue)return this.expandMacro(t.rawValue)}get transparent(){return this.properties.getValue(ae)}get visible(){return this.properties.getValue(le)}get actions(){return this.properties.getValue($t)}get scripts(){return this.properties.getValue(oe)}get rules(){return this.properties.getValue(se)}get scaleOptions(){return this.properties.getValue(re)}get widgetType(){return this.properties.getValue(de,!0)}get text(){if(this.display.editMode){return(this.properties.getProperty(he).rawValue||"").split(" ").join(" ")}return this.properties.getValue(he).split(" ").join(" ")}init(){}hide(){}destroy(){}}const ue="font",me="push_action_index",xe="release_action_index",fe="toggle_button",we="image";class ye extends ge{constructor(t,e){super(t,e),this.pushed=!1,this.imageLoaded=!1,this.properties.add(new q(ue)),this.properties.add(new z(fe)),this.properties.add(new $(me)),this.properties.add(new $(xe)),this.properties.add(new D(we))}init(){if(this.image){this.imageElement=new Image,this.imageElement.onload=()=>{this.imageLoaded=!0,this.requestRepaint()};const t=this.display.getImageResolver();this.imageElement.src=t.resolve(this.image)}this.areaRegion={id:`${this.wuid}-area`,mouseDown:()=>{this.toggleButton||(this.pushed=!0,this.requestRepaint())},mouseOut:()=>{this.pushed=!1,this.requestRepaint()},mouseUp:()=>{this.toggleButton||(this.pushed=!1,this.requestRepaint())},click:()=>{this.executeAction(this.pushed?this.releaseActionIndex:this.pushActionIndex),this.toggleButton&&(this.pushed=!this.pushed)},tooltip:()=>this.tooltip,cursor:"pointer"}}draw(t){const i=t.ctx,{scale:s}=this;t.fillRect(Object.assign(Object.assign({},this.area),{color:this.backgroundColor}));t.addHitRegion(this.areaRegion).addRect(this.x,this.y,this.width,this.height);const r=1*s,o=this.holderY+r/2,h=this.holderX+r/2,n=this.holderY+this.holderHeight-r+r/2,a=this.holderX+this.holderWidth-r+r/2;t.strokePath({lineWidth:r,color:this.pushed?e.BUTTON_LIGHTEST:e.BLACK,path:new b(a,n).lineTo(a,o).moveTo(a,n).lineTo(h,n)}),t.strokePath({lineWidth:r,color:this.pushed?this.backgroundColor:e.BUTTON_DARKER,path:new b(a-r,n-r).lineTo(a-r,o+r).moveTo(a-r,n-r).lineTo(h+r,n-r)}),t.strokePath({lineWidth:r,color:this.pushed?e.BLACK:e.BUTTON_LIGHTEST,path:new b(h,o).lineTo(a-r,o).moveTo(h,o).lineTo(h,n-r)}),t.strokePath({lineWidth:r,color:this.pushed?e.BUTTON_DARKER:this.backgroundColor,path:new b(h+r,o+r).lineTo(a-r-r,o+r).moveTo(h+r,o+r).lineTo(h+r,n-r-r)});const l=this.text.split("\n");let d,c;if(i.fillStyle=this.foregroundColor.toString(),i.font=this.font.getFontString(),this.imageElement&&this.imageLoaded){const t=i.measureText(l[0]).width,e=this.font.height,r=this.imageElement.naturalHeight*s,o=this.imageElement.naturalWidth*s,h=(this.height-r)/e,n=5*s;if((this.width-o)/t>h){i.textBaseline="middle",i.textAlign="left",d=this.x+(this.width-t)/2+n,c=this.y+this.height/2;const e=this.x+(this.width-t)/2-o,s=this.y+(this.height-r)/2;i.drawImage(this.imageElement,e,s,o,r)}else{i.textAlign="center",i.textBaseline="top";const t=e+r;d=this.x+this.width/2,c=this.y+(this.height-t)/2+r;const s=this.x+(this.width-o)/2,h=this.y+(this.height-t)/2;i.drawImage(this.imageElement,s,h,o,r)}}else i.textBaseline="middle",i.textAlign="center",d=this.x+this.width/2,c=this.y+this.height/2;this.pushed&&(d+=1*s,c+=1*s),i.fillText(l[0],d,c)}get font(){return this.properties.getValue(ue).scale(this.scale)}get image(){return this.properties.getValue(we)}get toggleButton(){return this.properties.getValue(fe)}get pushActionIndex(){return this.properties.getValue(me)}get releaseActionIndex(){return this.properties.getValue(xe)}get backgroundColor(){const t=this.properties.getProperty("background_color");return t&&t.value!==e.TRANSPARENT?t.value:e.BUTTON}}const ve="data_type",be="effect_3d",Te="font",Se="off_color",Ve="off_label",Ae="off_state",_e="on_color",Le="on_label",Ce="on_state",Pe="push_action_index",Me="released_action_index",ke="show_led",Re="show_boolean_label",Ee="square_button",We="toggle_button";class Be extends ge{constructor(t,e){super(t,e),this.hovered=!1,this.manualToggleState=!1,this.properties.add(new $("bit")),this.properties.add(new $(ve)),this.properties.add(new z(Ee)),this.properties.add(new z(ke)),this.properties.add(new z(be)),this.properties.add(new U(_e)),this.properties.add(new D(Le)),this.properties.add(new D(Ce)),this.properties.add(new U(Se)),this.properties.add(new D(Ve)),this.properties.add(new D(Ae)),this.properties.add(new q(Te)),this.properties.add(new z(We)),this.properties.add(new $(Pe)),this.properties.add(new $(Me)),this.properties.add(new z(Re))}init(){this.areaRegion={id:`${this.wuid}-area`,mouseDown:()=>{this.toggleButton&&this.booleanValue?this.toggleOff():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(0===this.dataType)if(this.bit<0)this.display.pvEngine.setValue(new Date,this.pv.name,1);else{const t=this.pv.value|1<<this.bit;this.display.pvEngine.setValue(new Date,this.pv.name,t)}else this.display.pvEngine.setValue(new Date,this.pv.name,this.onState);this.executeAction(this.pushActionIndex)}toggleOff(){if(this.manualToggleState=!1,this.pv&&this.pv.writable)if(0===this.dataType)if(this.bit<0)this.display.pvEngine.setValue(new Date,this.pv.name,0);else{const t=this.pv.value&~(1<<this.bit);this.display.pvEngine.setValue(new Date,this.pv.name,t)}else this.display.pvEngine.setValue(new Date,this.pv.name,this.offState);void 0!==this.releaseActionIndex&&this.executeAction(this.releaseActionIndex)}get booleanValue(){var t,e;return this.pv&&void 0!==this.pv.value?0===this.dataType?this.bit<0?Boolean(null===(t=this.pv)||void 0===t?void 0:t.toNumber()):((null===(e=this.pv)||void 0===e?void 0:e.value)>>this.bit&1)>0:1===this.dataType&&this.pv.toString()===this.onState:this.manualToggleState}draw(t){const 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,i){t.fillRect({x:this.x,y:this.y,width:this.width,height:this.height,color:e.DARK_GRAY});t.addHitRegion(this.areaRegion).addRect(this.x,this.y,this.width,this.height);const s=2*this.scale,r=i?e.DARK_GRAY:e.WHITE,o=i?e.WHITE:e.DARK_GRAY;this.effect3d&&(t.fillPath({color:r,path:new b(this.x,this.y).lineTo(this.x,this.y+this.height).lineTo(this.x+s,this.y+this.height-s).lineTo(this.x+s,this.y+s).lineTo(this.x+this.width-s,this.y+s).lineTo(this.x+this.width,this.y).closePath()}),t.fillPath({color:o,path:new b(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-s,this.y+s).lineTo(this.x+this.width-s,this.y+this.height-s).lineTo(this.x+s,this.y+this.height-s).closePath()}));let h=this.backgroundColor;this.hovered&&(h=this.backgroundColor.mixWith(e.WHITE,.5)),t.fillRect({x:this.x+s,y:this.y+s,width:this.width-s-s,height:this.height-s-s,color:h})}drawEllipse(t,i){const{scale:s}=this;if(this.effect3d){const r=this.width/2,o=this.height/2,h=Math.sqrt(r*r+o*o),n=this.x+r+(o-r-h)/2-1*s,a=this.y+o-(o-r+h)/2-1*s,l=this.x+r+(o-r+h)/2+5*s,d=this.y+o-(o-r-h)/2+5*s,c=t.createLinearGradient(n,a,l,d);i?(c.addColorStop(0,e.DARK_GRAY.toString()),c.addColorStop(1,e.WHITE.toString())):(c.addColorStop(0,e.WHITE.toString()),c.addColorStop(1,e.DARK_GRAY.toString())),t.ctx.fillStyle=c}else t.ctx.fillStyle=i?e.WHITE.toString():e.DARK_GRAY.toString();const r=this.x+this.width/2,o=this.y+this.height/2,h=this.width/2,n=this.height/2;t.ctx.beginPath(),t.ctx.ellipse(r,o,h,n,0,0,2*Math.PI),t.ctx.fill();t.addHitRegion(this.areaRegion).addEllipse(r,o,h,n,0,0,2*Math.PI),this.hovered?t.ctx.fillStyle=this.backgroundColor.mixWith(e.WHITE,.5).toString():t.ctx.fillStyle=this.backgroundColor.toString(),t.ctx.beginPath(),t.ctx.ellipse(r,o,h-2*s,n-2*s,0,0,2*Math.PI),t.ctx.fill()}drawHorizontal(t,e){const{scale:i}=this;if(this.showLed){let s;this.squareButton?(s=Math.floor(.3*(this.width+this.height)/2),s>Math.min(this.width,this.height)&&(s=Math.min(this.width,this.height)-2*i)):(s=Math.floor(.25*(this.width+this.height)/2),s>Math.min(this.width,this.height)&&(s=Math.min(this.width,this.height)-8*i));const r={x:Math.floor(this.x+.79999*this.width-s/2),y:Math.floor(this.y+this.height/2-s/2),width:s,height:s},o=r.x+r.width/2,h=r.y+r.height/2,n=r.width/2,a=r.height/2,l=e?this.onColor:this.offColor;if(t.fillEllipse({cx:o,cy:h,rx:n,ry:a,color:l}),this.effect3d){const e=t.createLinearGradient(r.x,r.y,r.x+r.width,r.y+r.height);e.addColorStop(0,"white"),e.addColorStop(1,l.withAlpha(0).toString()),t.ctx.beginPath(),t.ctx.ellipse(o,h,n,a,0,0,2*Math.PI),t.ctx.fillStyle=e,t.ctx.fill()}}}drawVertical(t,i){const{scale:s}=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*s)):(r=Math.floor(.25*(this.width+this.height)/2),r>Math.min(this.width,this.height)&&(r=Math.min(this.width,this.height)-8*s));const o={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},h=i?this.onColor:this.offColor,n=o.x+o.width/2,a=o.y+o.height/2,l=o.width/2,d=o.height/2;if(t.fillEllipse({cx:n,cy:a,rx:l,ry:d,color:h}),this.effect3d){const i=t.createLinearGradient(o.x,o.y,o.x+o.width,o.y+o.height);i.addColorStop(0,e.WHITE.toString()),i.addColorStop(1,h.withAlpha(0).toString()),t.ctx.beginPath(),t.ctx.ellipse(n,a,l,d,0,0,2*Math.PI),t.ctx.fillStyle=i,t.ctx.fill()}}}get bit(){return this.properties.getValue("bit")}get dataType(){return this.properties.getValue(ve)}get toggleButton(){return this.properties.getValue(We)}get pushActionIndex(){return this.properties.getValue(Pe)}get releaseActionIndex(){return this.properties.getValue(Me)}get squareButton(){return this.properties.getValue(Ee)}get showLed(){return this.properties.getValue(ke)}get showBooleanLabel(){return this.properties.getValue(Re)}get effect3d(){return this.properties.getValue(be)}get onColor(){return this.properties.getValue(_e)}get onLabel(){return this.properties.getValue(Le)}get onState(){return this.properties.getValue(Ce)}get offColor(){return this.properties.getValue(Se)}get offLabel(){return this.properties.getValue(Ve)}get offState(){return this.properties.getValue(Ae)}get font(){return this.properties.getValue(Te).scale(this.scale)}}const Ie="data_type",Oe="effect_3d",He="off_color",Fe="off_label",Ne="off_state",De="on_color",je="on_label",$e="on_state",Ge="push_action_index",ze="released_action_index",Ue="toggle_button";class qe extends ge{constructor(t,e){super(t,e),this.manualToggleState=!1,this.properties.add(new $("bit")),this.properties.add(new $(Ie)),this.properties.add(new z(Oe)),this.properties.add(new U(De)),this.properties.add(new D(je)),this.properties.add(new D($e)),this.properties.add(new U(He)),this.properties.add(new D(Fe)),this.properties.add(new D(Ne)),this.properties.add(new $(Ge)),this.properties.add(new $(ze)),this.properties.add(new z(Ue))}init(){this.shaftRegion={id:`${this.wuid}-shaft`,mouseDown:()=>{this.toggleButton&&this.booleanValue?this.toggleOff():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(0===this.dataType)if(this.bit<0)this.display.pvEngine.setValue(new Date,this.pv.name,1);else{const t=this.pv.value|1<<this.bit;this.display.pvEngine.setValue(new Date,this.pv.name,t)}else this.display.pvEngine.setValue(new Date,this.pv.name,this.onState);this.executeAction(this.pushActionIndex)}toggleOff(){if(this.manualToggleState=!1,this.pv&&this.pv.writable)if(0===this.dataType)if(this.bit<0)this.display.pvEngine.setValue(new Date,this.pv.name,0);else{const t=this.pv.value&~(1<<this.bit);this.display.pvEngine.setValue(new Date,this.pv.name,t)}else this.display.pvEngine.setValue(new Date,this.pv.name,this.offState);void 0!==this.releaseActionIndex&&this.executeAction(this.releaseActionIndex)}get booleanValue(){var t,e;return this.pv&&void 0!==this.pv.value?0===this.dataType?this.bit<0?Boolean(null===(t=this.pv)||void 0===t?void 0:t.toNumber()):((null===(e=this.pv)||void 0===e?void 0:e.value)>>this.bit&1)>0:1===this.dataType&&this.pv.toString()===this.onState:this.manualToggleState}draw(t){const e=this.booleanValue;this.width>this.height?this.drawHorizontal(t,e):this.drawVertical(t,e)}drawHorizontal(t,e){let i=this.width,s=this.height;s>i/2?s=Math.floor(this.width/2):i=Math.floor(2*this.height);const r={x:Math.floor(63/218*i),y:0,width:s/2,height:s/2};this.drawPedestal(t,r,e);const o=Math.floor(35/218*i),h=Math.floor(45/105*s),n=Math.floor(43/218*i),a=Math.floor(35/105*s),l=Math.floor(1/7*r.width);if(e){const e={x:2*r.x+r.width-o,y:r.height/2-h/2,width:o,height:h},i={x:r.x+r.width/2-n/2+l,y:r.y+r.height/2-a/2,width:n,height:a};this.drawHorizontalBar(t,i,e,!0)}else{const e={x:0,y:r.height/2-h/2,width:o,height:h},i={x:r.x+r.width/2-n/2-l,y:r.y+r.height/2-a/2,width:n,height:a};this.drawHorizontalBar(t,i,e,!1)}}drawVertical(t,e){let i=this.width,s=this.height;i>s/2?i=Math.floor(this.height/2):s=Math.floor(2*this.width);const r={x:0,y:Math.floor(63/218*s),width:i/2,height:i/2};this.drawPedestal(t,r,e);const o=Math.floor(45/105*i),h=Math.floor(35/218*s),n=Math.floor(35/105*i),a=Math.floor(43/218*s);if(e){const e={x:r.width/2-o/2,y:0,width:o,height:h},i={x:r.x+r.width/2-n/2,y:r.y+r.height/2-a/2,width:n,height:a};i.y-=Math.floor(1/7*r.height),this.drawVerticalBar(t,i,e,!0)}else{const e=r.y+r.height/2+a/2+2*this.scale,i={x:r.width/2-o/2,y:r.y+r.height/2-a/2+e-h,width:o,height:h},s={x:r.x+r.width/2-n/2,y:r.y+r.height/2-a/2,width:n,height:a};s.y+=Math.floor(1/7*r.height),this.drawVerticalBar(t,s,i,!1)}}drawPedestal(t,i,s){let r=this.x+i.x+i.width/2,o=this.y+i.y+i.height/2,h=i.width/2,n=i.height/2;if(t.ctx.fillStyle=this.effect3d?e.WHITE.toString():e.GRAY.toString(),t.ctx.beginPath(),t.ctx.ellipse(r,o,h,n,0,0,2*Math.PI),t.ctx.fill(),this.effect3d){const e=t.createLinearGradient(this.x+i.x,this.y+i.y,this.x+i.x+i.width,this.y+i.y+i.height);s?(e.addColorStop(0,`rgba(255,255,255,${10/255})`),e.addColorStop(1,`rgba(0,0,0,${100/255})`)):(e.addColorStop(0,"rgba(0,0,0,0)"),e.addColorStop(1,`rgba(0,0,0,${150/255})`)),t.ctx.fillStyle=e,t.ctx.fill()}}drawHorizontalBar(t,e,i,s){let r=(s?0:10)/255,o=(s?150:220)/255;const h=t.createLinearGradient(this.x+i.x,this.y+i.y,this.x+i.x,this.y+i.y+i.height);h.addColorStop(0,`rgba(0,0,0,${r})`),h.addColorStop(1,`rgba(0,0,0,${o})`);const n=t.addHitRegion(this.shaftRegion);let a=this.x+e.x+e.width/2,l=this.y+e.y+e.height/2,d=e.width/2,c=e.height/2;t.ctx.beginPath(),t.ctx.ellipse(a,l,d,c,0,0,2*Math.PI),n.addEllipse(a,l,d,c,0,0,2*Math.PI),t.ctx.fillStyle=s?this.onColor.toString():this.offColor.toString(),t.ctx.fill(),this.effect3d&&(t.ctx.fillStyle=h,t.ctx.fill());const p=[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(p[0],p[1]),t.ctx.lineTo(p[2],p[3]),t.ctx.lineTo(p[4],p[5]),t.ctx.lineTo(p[6],p[7]),t.ctx.closePath(),n.addPath(new b(p[0],p[1]).lineTo(p[2],p[3]).lineTo(p[4],p[5]).lineTo(p[6],p[7]).closePath()),t.ctx.fillStyle=s?this.onColor.toString():this.offColor.toString(),t.ctx.fill(),this.effect3d&&(t.ctx.fillStyle=h,t.ctx.fill()),a=this.x+i.x+i.width/2,l=this.y+i.y+i.height/2,d=i.width/2,c=i.height/2,t.ctx.beginPath(),t.ctx.ellipse(a,l,d,c,0,0,2*Math.PI),n.addEllipse(a,l,d,c,0,0,2*Math.PI),t.ctx.fillStyle=s?this.onColor.toString():this.offColor.toString(),t.ctx.fill(),this.effect3d){const{scale:e}=this,s=Math.sqrt(d*d+c*c),h=c-d,n=this.x+i.x+d+(h-s)/2-1*e,a=this.x+i.y+c-(h+s)/2-1*e,l=this.x+i.x+d+(h+s)/2+5*e,p=this.x+i.y+c-(h-s)/2+5*e,g=t.createLinearGradient(n,a,l,p);g.addColorStop(0,`rgba(0,0,0,${r})`),g.addColorStop(1,`rgba(0,0,0,${o})`),t.ctx.fillStyle=g,t.ctx.fill()}}drawVerticalBar(t,e,i,s){const r=t.createLinearGradient(this.x+i.x,this.y+i.y,this.x+i.x+i.width,this.y+i.y);r.addColorStop(0,`rgba(0,0,0,${10/255})`),r.addColorStop(1,`rgba(0,0,0,${s?210/255:160/255})`);const o=t.addHitRegion(this.shaftRegion);let h=this.x+e.x+e.width/2,n=this.y+e.y+e.height/2;t.ctx.beginPath(),t.ctx.ellipse(h,n,e.width/2,e.height/2,0,0,2*Math.PI),o.addEllipse(h,n,e.width/2,e.height/2,0,0,2*Math.PI),t.ctx.fillStyle=s?this.onColor.toString():this.offColor.toString(),t.ctx.fill(),this.effect3d&&(t.ctx.fillStyle=r,t.ctx.fill());const a=[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(a[0],a[1]),t.ctx.lineTo(a[2],a[3]),t.ctx.lineTo(a[4],a[5]),t.ctx.lineTo(a[6],a[7]),t.ctx.closePath(),o.addPath(new b(a[0],a[1]).lineTo(a[2],a[3]).lineTo(a[4],a[5]).lineTo(a[6],a[7]).closePath()),t.ctx.fillStyle=s?this.onColor.toString():this.offColor.toString(),t.ctx.fill(),this.effect3d&&(t.ctx.fillStyle=r,t.ctx.fill()),h=this.x+i.x+i.width/2,n=this.y+i.y+i.height/2;const l=i.width/2,d=i.height/2;if(t.ctx.beginPath(),t.ctx.ellipse(h,n,l,d,0,0,2*Math.PI),o.addEllipse(h,n,l,d,0,0,2*Math.PI),t.ctx.fillStyle=s?this.onColor.toString():this.offColor.toString(),t.ctx.fill(),this.effect3d){const e=t.createLinearGradient(this.x+i.x,this.y+i.y,this.x+i.width,this.y+i.height);e.addColorStop(0,`rgba(0,0,0,${(s?5:10)/255})`),e.addColorStop(1,`rgba(0,0,0,${(s?180:160)/255})`),t.ctx.fillStyle=e,t.ctx.fill()}}get bit(){return this.properties.getValue("bit")}get dataType(){return this.properties.getValue(Ie)}get toggleButton(){return this.properties.getValue(Ue)}get pushActionIndex(){return this.properties.getValue(Ge)}get releaseActionIndex(){return this.properties.getValue(ze)}get effect3d(){return this.properties.getValue(Oe)}get onColor(){return this.properties.getValue(De)}get onLabel(){return this.properties.getValue(je)}get onState(){return this.properties.getValue($e)}get offColor(){return this.properties.getValue(He)}get offLabel(){return this.properties.getValue(Fe)}get offState(){return this.properties.getValue(Ne)}}const Ye="enabled",Xe="font",Ke="label",Ze="selected_color",Je=new e(130,130,130),Qe=new e(94,151,230);class ti extends ge{constructor(t,i){super(t,i),this.hovered=!1,this.manualToggleState=!1,this.properties.add(new $("bit")),this.properties.add(new z(Ye)),this.properties.add(new q(Xe)),this.properties.add(new D(Ke)),this.properties.add(new U(Ze,new e(64,64,64)))}init(){this.areaRegion={id:`${this.wuid}-area`,mouseDown:()=>{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{const t=this.pv.value|1<<this.bit;this.display.pvEngine.setValue(new Date,this.pv.name,t)}}toggleOff(){if(this.manualToggleState=!1,this.pv&&this.pv.writable)if(this.bit<0)this.display.pvEngine.setValue(new Date,this.pv.name,0);else{const t=this.pv.value&~(1<<this.bit);this.display.pvEngine.setValue(new Date,this.pv.name,t)}}get booleanValue(){var t,e;return this.pv&&void 0!==this.pv.value?this.bit<0?Boolean(null===(t=this.pv)||void 0===t?void 0:t.toNumber()):((null===(e=this.pv)||void 0===e?void 0:e.value)>>this.bit&1)>0:this.manualToggleState}draw(t){t.addHitRegion(this.areaRegion).addRect(this.x,this.y,this.width,this.height);const i=this.booleanValue,{boxSize:s,gap:r,scale:o}=this;let h=this.backgroundColor;this.hovered&&(h=h.mixWith(Qe,.7));const n={x:this.x,y:this.y+this.height/2-s/2,width:s,height:s},a=t.createLinearGradient(n.x,n.y+1*o,n.x,n.y+n.height);a.addColorStop(0,e.WHITE.toString()),a.addColorStop(1,h.toString()),t.fillRect(Object.assign(Object.assign({},n),{rx:2*o,ry:2*o,gradient:a})),t.strokeRect({x:n.x+.5*o,y:n.y+.5*o,width:n.width-1*o,height:n.height-1*o,rx:2*o,ry:2*o,color:Je}),i&&t.strokePath({lineWidth:3*o,color:this.selectedColor,path:new b(n.x+3*o,n.y+Math.floor(.45*s)).lineTo(n.x+Math.floor(.45*s),n.y+3*s/4-1*o).lineTo(n.x+s-2*o,n.y+3*o)}),this.enabled?t.fillText({x:n.x+n.width+r,y:n.y+n.height/2,align:"left",baseline:"middle",color:this.foregroundColor,font:this.font,text:this.label}):(t.fillText({x:n.x+n.width+r+1*o,y:n.y+n.height/2+1*o,align:"left",baseline:"middle",color:e.BUTTON_LIGHTEST,font:this.font,text:this.label}),t.fillText({x:n.x+n.width+r,y:n.y+n.height/2,align:"left",baseline:"middle",color:e.BUTTON_DARKER,font:this.font,text:this.label}))}get boxSize(){return 16*this.scale}get gap(){return 4*this.scale}get bit(){return this.properties.getValue("bit")}get enabled(){return this.properties.getValue(Ye)}get selectedColor(){return this.properties.getValue(Ze)}get font(){return this.properties.getValue(Xe).scale(this.scale)}get label(){return this.properties.getValue(Ke)}}const ei="enabled",ii="font",si="horizontal",ri="items",oi="items_from_pv",hi="selected_color";class ni extends ge{constructor(t,e){super(t,e),this.itemRegions=[],this.properties.add(new z(ei)),this.properties.add(new q(ii)),this.properties.add(new z(si)),this.properties.add(new Q(ri,[])),this.properties.add(new z(oi)),this.properties.add(new U(hi))}init(){for(let t=0;t<this.items.length;t++)this.itemRegions.push({id:`${this.wuid}-item-${t}`,cursor:"pointer",mouseDown:()=>{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){const e=this.area.width/this.items.length;let i=this.area.x;for(let s=0;s<this.items.length;s++){const r={x:i,y:this.area.y,width:e,height:this.area.height};i+=e,this.drawButton(t,r,s)}}drawVertical(t){const e=this.area.height/this.items.length;let i=this.area.y;for(let s=0;s<this.items.length;s++){const r={x:Math.round(this.area.x),y:Math.round(i),width:Math.round(this.area.width),height:Math.round(e)};i+=e,this.drawButton(t,r,s)}}drawButton(t,i,s){var r;const o=(null===(r=this.pv)||void 0===r?void 0:r.value)===this.items[s],h=o||s===this.pushedItem;t.fillRect(Object.assign(Object.assign({},i),{color:o?this.selectedColor:this.backgroundColor}));t.addHitRegion(this.itemRegions[s]).addRect(i.x,i.y,i.width,i.height);const n=1*this.scale,a=i.y+n/2,l=i.x+n/2,d=i.y+i.height-n+n/2,c=i.x+i.width-n+n/2;t.strokePath({lineWidth:n,color:h?e.BUTTON_LIGHTEST:e.BLACK,path:new b(c,d).lineTo(c,a).moveTo(c,d).lineTo(l,d)}),t.strokePath({lineWidth:n,color:h?this.backgroundColor:e.BUTTON_DARKER,path:new b(c-n,d-n).lineTo(c-n,a+n).moveTo(c-n,d-n).lineTo(l+n,d-n)}),t.strokePath({lineWidth:n,color:h?e.BLACK:e.BUTTON_LIGHTEST,path:new b(l,a).lineTo(c-n,a).moveTo(l,a).lineTo(l,d-n)}),t.strokePath({lineWidth:n,color:h?e.BUTTON_DARKER:this.backgroundColor,path:new b(l+n,a+n).lineTo(c-n-n,a+n).moveTo(l+n,a+n).lineTo(l+n,d-n-n)}),t.fillText({x:i.x+i.width/2,y:i.y+i.height/2,text:this.items[s],align:"center",baseline:"middle",color:this.foregroundColor,font:this.font})}writeValue(t){this.pv&&this.pv.writable&&this.display.pvEngine.setValue(new Date,this.pv.name,t)}get enabled(){return this.properties.getValue(ei)}get font(){return this.properties.getValue(ii).scale(this.scale)}get horizontal(){return this.properties.getValue(si)}get items(){return this.properties.getValue(ri)}get itemsFromPV(){return this.properties.getValue(oi)}get selectedColor(){return this.properties.getValue(hi)}}const ai="enabled",li="font",di="items",ci="items_from_pv",pi=new e(240,240,240);class gi extends ge{constructor(t,e){super(t,e),this.listVisible=!1,this.itemRegions=[],this.properties.add(new z(ai)),this.properties.add(new q(li)),this.properties.add(new Q(di,[])),this.properties.add(new z(ci))}init(){this.areaRegion={id:`${this.wuid}-area`,click:()=>{const t=this.listVisible;this.display.closeMenu(),this.items.length&&!t&&(this.listVisible=!0,this.hoveredItem=0,this.requestRepaint())},tooltip:()=>this.tooltip};for(let t=0;t<this.items.length;t++)this.itemRegions.push({id:`${this.wuid}-item-${t}`,click:()=>{this.writeValue(this.items[t]),this.listVisible=!1,this.hoveredItem=void 0,this.requestRepaint()},mouseEnter:()=>{this.hoveredItem=t,this.requestRepaint()},mouseOut:()=>{this.hoveredItem=void 0,this.requestRepaint()},tooltip:()=>this.tooltip})}draw(t){var e,i;let s=d(this.bounds,2*this.scale);t.fillRect(Object.assign(Object.assign({},s),{color:this.backgroundColor})),t.strokeRect(Object.assign(Object.assign({},s),{color:pi,crispen:!0}));t.addHitRegion(this.areaRegion).addRect(s.x,s.y,s.width,s.height),(null===(e=this.pv)||void 0===e?void 0:e.value)&&-1!==this.items.indexOf(this.pv.value)&&t.fillText({x:5*this.scale+s.x,y:s.y+s.height/2,align:"left",baseline:"middle",color:this.foregroundColor,font:this.font,text:null===(i=this.pv)||void 0===i?void 0:i.value});const{selectorWidth:r}=this,o=Math.min(s.height,r/2),h={x:s.x+s.width-r-5*this.scale+r/2,y:s.y+(s.height-o)/2+o};t.fillPath({color:this.foregroundColor,path:new b(h.x,h.y).lineTo(h.x-o,h.y-o).lineTo(h.x+o,h.y-o).closePath()})}closeMenu(){this.listVisible=!1,this.requestRepaint()}drawOverlay(t){if(!this.listVisible||!this.items.length)return;let i=0,s=0;for(const e of this.items){const r=t.measureText(e,this.font);i=Math.max(i,r.width),s=Math.max(s,r.height)}const{scale:r}=this,o=5*r,h=o+s+o,n={x:this.bounds.x+5*r,y:this.bounds.y+this.bounds.height-5*r,width:o+i+o,height:h*this.items.length+2*r+2*r};t.fillRect(Object.assign(Object.assign({},n),{color:this.backgroundColor}));for(let i=0;i<this.items.length;i++){const s={x:n.x,y:n.y+2*r+i*h,width:n.width,height:h};t.addHitRegion(this.itemRegions[i]).addRect(s.x,s.y,s.width,s.height),i===this.hoveredItem&&t.fillRect(Object.assign(Object.assign({},s),{color:e.LIGHT_BLUE}))}t.strokeRect(Object.assign(Object.assign({},n),{color:pi,lineWidth:1*r,crispen:!0}));for(let e=0;e<this.items.length;e++)t.fillText({x:n.x+o,y:n.y+2*r+e*h+h/2,font:this.font,color:this.foregroundColor,align:"left",baseline:"middle",text:this.items[e]})}writeValue(t){this.pv&&this.pv.writable&&this.display.pvEngine.setValue(new Date,this.pv.name,t)}get selectorWidth(){return 8*this.scale}get enabled(){return this.properties.getValue(ai)}get font(){return this.properties.getValue(li).scale(this.scale)}get items(){return this.properties.getValue(di)}get itemsFromPV(){return this.properties.getValue(ci)}}const ui="data_type",mi="effect_3d",xi="font",fi="off_image",wi="off_label",yi="off_state",vi="on_image",bi="on_label",Ti="on_state",Si="push_action_index",Vi="released_action_index",Ai="show_boolean_label",_i="toggle_button";class Li extends ge{constructor(t,e){super(t,e),this.onImageLoaded=!1,this.offImageLoaded=!1,this.manualToggleState=!1,this.properties.add(new $("bit")),this.properties.add(new $(ui)),this.properties.add(new z(mi)),this.properties.add(new D(vi)),this.properties.add(new D(bi)),this.properties.add(new D(Ti)),this.properties.add(new D(fi)),this.properties.add(new D(wi)),this.properties.add(new D(yi)),this.properties.add(new q(xi)),this.properties.add(new z(_i)),this.properties.add(new $(Si)),this.properties.add(new $(Vi)),this.properties.add(new z(Ai))}init(){if(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){const t=this.display.getImageResolver();this.onImageElement.src=t.resolve(this.onImage)}if(this.offImage){const t=this.display.getImageResolver();this.offImageElement.src=t.resolve(this.offImage)}this.areaRegion={id:`${this.wuid}-area`,mouseDown:()=>{this.toggleButton&&this.booleanValue?this.toggleOff():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(0===this.dataType)if(this.bit<0)this.display.pvEngine.setValue(new Date,this.pv.name,1);else{const t=this.pv.value|1<<this.bit;this.display.pvEngine.setValue(new Date,this.pv.name,t)}else this.display.pvEngine.setValue(new Date,this.pv.name,this.onState);this.executeAction(this.pushActionIndex)}toggleOff(){if(this.manualToggleState=!1,this.pv&&this.pv.writable)if(0===this.dataType)if(this.bit<0)this.display.pvEngine.setValue(new Date,this.pv.name,0);else{const t=this.pv.value&~(1<<this.bit);this.display.pvEngine.setValue(new Date,this.pv.name,t)}else this.display.pvEngine.setValue(new Date,this.pv.name,this.offState);void 0!==this.releaseActionIndex&&this.executeAction(this.releaseActionIndex)}get booleanValue(){var t,e;return this.pv&&void 0!==this.pv.value?0===this.dataType?this.bit<0?Boolean(null===(t=this.pv)||void 0===t?void 0:t.toNumber()):((null===(e=this.pv)||void 0===e?void 0:e.value)>>this.bit&1)>0:1===this.dataType&&this.pv.toString()===this.onState:this.manualToggleState}draw(t){let e=this.bounds;this.borderAlarmSensitive&&(e=d(e,2*this.scale,2*this.scale));const 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("bit")}get dataType(){return this.properties.getValue(ui)}get toggleButton(){return this.properties.getValue(_i)}get pushActionIndex(){return this.properties.getValue(Si)}get releaseActionIndex(){return this.properties.getValue(Vi)}get showBooleanLabel(){return this.properties.getValue(Ai)}get effect3d(){return this.properties.getValue(mi)}get onImage(){return this.properties.getValue(vi)}get onLabel(){return this.properties.getValue(bi)}get onState(){return this.properties.getValue(Ti)}get offImage(){return this.properties.getValue(fi)}get offLabel(){return this.properties.getValue(wi)}get offState(){return this.properties.getValue(yi)}get font(){return this.properties.getValue(xi).scale(this.scale)}}class Ci extends ye{}const Pi="enabled",Mi="font",ki="horizontal",Ri="items",Ei="items_from_pv",Wi="selected_color",Bi=new e(120,120,120),Ii=new e(94,151,230);class Oi extends ge{constructor(t,e){super(t,e),this.itemRegions=[],this.properties.add(new z(Pi)),this.properties.add(new q(Mi)),this.properties.add(new z(ki)),this.properties.add(new Q(Ri,[])),this.properties.add(new z(Ei)),this.properties.add(new U(Wi))}init(){for(let t=0;t<this.items.length;t++)this.itemRegions.push({id:`${this.wuid}-item-${t}`,cursor:"pointer",click:()=>{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){const e=this.area.width/this.items.length;let i=this.area.x;for(let s=0;s<this.items.length;s++){const r={x:i,y:this.area.y,width:e,height:this.area.height};i+=e,this.drawRadio(t,r,s)}}drawVertical(t){const e=this.area.height/this.items.length;let i=this.area.y;for(let s=0;s<this.items.length;s++){const r={x:this.area.x,y:i,width:this.area.width,height:e};i+=e,this.drawRadio(t,r,s)}}drawRadio(t,i,s){var r;const{radioRadius:o,dotRadius:h,gap:n}=this;let a=this.backgroundColor;s===this.hoveredItem&&(a=a.mixWith(Ii,.7));const l=t.createLinearGradient(i.x,i.y,i.x+i.width,i.y+i.height);l.addColorStop(0,e.WHITE.toString()),l.addColorStop(1,a.toString()),t.fillEllipse({cx:i.x+o,cy:i.y+i.height/2,rx:o,ry:o,gradient:l});const d=1*this.scale;t.strokeEllipse({cx:i.x+o,cy:i.y+i.height/2,rx:o,ry:o,color:Bi,lineWidth:d}),(null===(r=this.pv)||void 0===r?void 0:r.value)===this.items[s]&&t.fillEllipse({cx:i.x+o,cy:i.y+i.height/2,rx:h+d/2,ry:h+d/2,color:this.selectedColor});t.addHitRegion(this.itemRegions[s]).addRect(i.x,i.y,i.width,i.height),t.fillText({x:i.x+o+o+n,y:i.y+i.height/2,text:this.items[s],align:"left",baseline:"middle",color:this.foregroundColor,font:this.font})}writeValue(t){this.pv&&this.pv.writable&&this.display.pvEngine.setValue(new Date,this.pv.name,t)}get radioRadius(){return 7*this.scale}get dotRadius(){return 2*this.scale}get gap(){return 4*this.scale}get enabled(){return this.properties.getValue(Pi)}get font(){return this.properties.getValue(Mi).scale(this.scale)}get horizontal(){return this.properties.getValue(ki)}get items(){return this.properties.getValue(Ri)}get itemsFromPV(){return this.properties.getValue(Ei)}get selectedColor(){return this.properties.getValue(Wi)}}const Hi="enabled",Fi="font",Ni="maximum",Di="minimum",ji="horizontal",$i="step_increment",Gi="page_increment",zi="bar_length",Ui="show_value_tip",qi=new e(243,243,243),Yi=new e(232,232,231),Xi=150;class Ki extends ge{constructor(t,e){super(t,e),this.decreasePressed=!1,this.increasePressed=!1,this.pageDecreasePressed=!1,this.pageIncreasePressed=!1,this.properties.add(new z(Hi)),this.properties.add(new z(ji)),this.properties.add(new z(Ui)),this.properties.add(new q(Fi)),this.properties.add(new G(Ni)),this.properties.add(new G(Di)),this.properties.add(new G($i)),this.properties.add(new G(Gi)),this.properties.add(new G(zi))}init(){this.decreaseRegion={id:`${this.wuid}-decrease`,mouseDown:()=>{this.decreasePressed=!0,this.stepDecreaseRepeatedly()},mouseUp:()=>{window.clearTimeout(this.actionTimeout),this.decreasePressed=!1,this.requestRepaint()},mouseOut:()=>{window.clearTimeout(this.actionTimeout),this.decreasePressed=!1,this.requestRepaint()},tooltip:()=>this.tooltip},this.increaseRegion={id:`${this.wuid}-increase`,mouseDown:()=>{this.increasePressed=!0,this.stepIncreaseRepeatedly()},mouseUp:()=>{window.clearTimeout(this.actionTimeout),this.increasePressed=!1,this.requestRepaint()},mouseOut:()=>{window.clearTimeout(this.actionTimeout),this.increasePressed=!1,this.requestRepaint()},tooltip:()=>this.tooltip},this.thumbRegion={id:`${this.wuid}-thumb`,mouseDown:()=>{this.grabStartValue=this.getCoercedValue()},grab:t=>{const 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){const{scale:i}=this,s=d(this.bounds,2*i);t.fillRect(Object.assign(Object.assign({},s),{color:qi}));const r=Math.min(s.height,s.width/2);this.drawLeftButton(t,{x:s.x,y:s.y,width:r,height:s.height}),this.drawRightButton(t,{x:s.x+s.width-r,y:s.y,width:r,height:s.height});const o=this.barLength,h=this.maximum+o,n=this.minimum,a=h-n,l=a-o,c=s.width-r-r,p=Math.floor(Math.max(6*i,c*o/a));this.dragRange=c-p;const g=this.getCoercedValue(),u=Math.floor((c-p)*(g-n)/l),m=c-u-p,x={x:s.x+r+u,y:s.y,width:p,height:s.height};t.fillRect(Object.assign(Object.assign({},x),{color:Yi})),this.drawRaisedButtonBorder(t,x);t.addHitRegion(this.thumbRegion).addRect(x.x,x.y,x.width,x.height);const f={x:s.x+r,y:s.y,width:u,height:s.height};t.addHitRegion(this.pageDecreaseRegion).addRect(f.x,f.y,f.width,f.height),this.pageDecreasePressed&&t.fillRect(Object.assign(Object.assign({},f),{color:e.BLACK}));const w={x:s.x+r+u+p,y:s.y,width:m,height:s.height};t.addHitRegion(this.pageIncreaseRegion).addRect(w.x,w.y,w.width,w.height),this.pageIncreasePressed&&t.fillRect(Object.assign(Object.assign({},w),{color:e.BLACK}))}drawVertical(t){const{scale:i}=this,s=d(this.bounds,i);t.fillRect(Object.assign(Object.assign({},s),{color:qi}));const r=Math.min(s.width,s.height/2);this.drawUpButton(t,{x:s.x,y:s.y,width:s.width,height:r}),this.drawDownButton(t,{x:s.x,y:s.y+s.height-r,width:s.width,height:r});const o=this.barLength,h=this.maximum+o,n=this.minimum,a=h-n,l=a-o,c=s.height-r-r,p=Math.floor(Math.max(6*i,c*o/a));this.dragRange=c-p;const g=this.getCoercedValue(),u=Math.floor((c-p)*(g-n)/l),m=c-u-p,x={x:s.x,y:s.y+r+u,width:s.width,height:p};t.fillRect(Object.assign(Object.assign({},x),{color:Yi})),this.drawRaisedButtonBorder(t,x);t.addHitRegion(this.thumbRegion).addRect(x.x,x.y,x.width,x.height);const f={x:s.x,y:s.y+r,width:s.width,height:u};t.addHitRegion(this.pageDecreaseRegion).addRect(f.x,f.y,f.width,f.height),this.pageDecreasePressed&&t.fillRect(Object.assign(Object.assign({},f),{color:e.BLACK}));const w={x:s.x,y:s.y+r+u+p,width:s.width,height:m};t.addHitRegion(this.pageIncreaseRegion).addRect(w.x,w.y,w.width,w.height),this.pageIncreasePressed&&t.fillRect(Object.assign(Object.assign({},w),{color:e.BLACK}))}drawLeftButton(t,i){t.fillRect(Object.assign(Object.assign({},i),{color:Yi})),this.decreasePressed?this.drawPressedButtonBorder(t,i):this.drawRaisedButtonBorder(t,i);t.addHitRegion(this.decreaseRegion).addRect(i.x,i.y,i.width,i.height);const s=d(i,3*this.scale);let r=Math.min(s.height/2,s.width);s.x+=(s.width-r)/2,r=Math.max(r,1);const o={x:s.x,y:s.y+s.height/2};t.fillPath({color:e.BLACK,path:new b(o.x,o.y).lineTo(o.x+r,o.y-r).lineTo(o.x+r,o.y+r).closePath()})}drawRightButton(t,i){t.fillRect(Object.assign(Object.assign({},i),{color:Yi})),this.increasePressed?this.drawPressedButtonBorder(t,i):this.drawRaisedButtonBorder(t,i);t.addHitRegion(this.increaseRegion).addRect(i.x,i.y,i.width,i.height);const s=d(i,3*this.scale);let r=Math.min(s.height/2,s.width);s.x+=(s.width-r)/2,r=Math.max(r,1);const o={x:s.x+r,y:s.y+s.height/2};t.fillPath({color:e.BLACK,path:new b(o.x,o.y).lineTo(o.x-r,o.y-r).lineTo(o.x-r,o.y+r).closePath()})}drawUpButton(t,i){t.fillRect(Object.assign(Object.assign({},i),{color:Yi})),this.decreasePressed?this.drawPressedButtonBorder(t,i):this.drawRaisedButtonBorder(t,i);t.addHitRegion(this.decreaseRegion).addRect(i.x,i.y,i.width,i.height);const s=d(i,3*this.scale);let r=Math.min(s.height,s.width/2);s.y+=(s.height-r)/2,r=Math.max(r,1);const o={x:s.x+s.width/2,y:s.y};t.fillPath({color:e.BLACK,path:new b(o.x,o.y).lineTo(o.x-r,o.y+r).lineTo(o.x+r,o.y+r).closePath()})}drawDownButton(t,i){t.fillRect(Object.assign(Object.assign({},i),{color:Yi})),this.increasePressed?this.drawPressedButtonBorder(t,i):this.drawRaisedButtonBorder(t,i);t.addHitRegion(this.increaseRegion).addRect(i.x,i.y,i.width,i.height);const s=d(i,3*this.scale);let r=Math.min(s.height,s.width/2);s.y+=(s.height-r)/2,r=Math.max(r,1);const o={x:s.x+s.width/2,y:s.y+r};t.fillPath({color:e.BLACK,path:new b(o.x,o.y).lineTo(o.x-r,o.y-r).lineTo(o.x+r,o.y-r).closePath()})}drawRaisedButtonBorder(t,i){this.drawButtonBorder(t,i,e.BUTTON_DARKEST,e.BUTTON_DARKER,e.BUTTON,e.BUTTON_LIGHTEST)}drawPressedButtonBorder(t,i){this.drawButtonBorder(t,i,e.BUTTON_LIGHTEST,e.BUTTON_LIGHTEST,e.BUTTON_DARKEST,e.BUTTON_DARKER)}drawButtonBorder(t,e,i,s,r,o){const h=1*this.scale,n=e.y+h/2,a=e.x+h/2,l=e.y+e.height-h+h/2,d=e.x+e.width-h+h/2;t.strokePath({color:i,path:new b(d,l).lineTo(d,n).moveTo(d,l).lineTo(a,l)}),t.strokePath({color:s,path:new b(d-h,l-h).lineTo(d-h,n+h).moveTo(d-h,l-h).lineTo(a+h,l-h)}),t.strokePath({color:r,path:new b(a,n).lineTo(d-h,n).moveTo(a,n).lineTo(a,l-h)}),t.strokePath({color:o,path:new b(a+h,n+h).lineTo(d-h-h,n+h).moveTo(a+h,n+h).lineTo(a+h,l-h-h)})}stepIncreaseRepeatedly(){window.clearTimeout(this.actionTimeout),this.stepIncrease(),this.requestRepaint(),this.actionTimeout=window.setTimeout((()=>this.stepIncreaseRepeatedly()),Xi)}stepDecreaseRepeatedly(){window.clearTimeout(this.actionTimeout),this.stepDecrease(),this.requestRepaint(),this.actionTimeout=window.setTimeout((()=>this.stepDecreaseRepeatedly()),Xi)}stepIncrease(){var t,e;const i=null!==(e=null===(t=this.pv)||void 0===t?void 0:t.value)&&void 0!==e?e:(this.maximum-this.minimum)/2;this.setCoercedValue(i+this.stepIncrement)}stepDecrease(){var t,e;const i=null!==(e=null===(t=this.pv)||void 0===t?void 0:t.value)&&void 0!==e?e:(this.maximum-this.minimum)/2;this.setCoercedValue(i-this.stepIncrement)}pageIncreaseRepeatedly(){window.clearTimeout(this.actionTimeout),this.pageIncrease(),this.requestRepaint(),this.actionTimeout=window.setTimeout((()=>this.pageIncreaseRepeatedly()),Xi)}pageDecreaseRepeatedly(){window.clearTimeout(this.actionTimeout),this.pageDecrease(),this.requestRepaint(),this.actionTimeout=window.setTimeout((()=>this.pageDecreaseRepeatedly()),Xi)}pageIncrease(){var t,e;const i=null!==(e=null===(t=this.pv)||void 0===t?void 0:t.value)&&void 0!==e?e:(this.maximum-this.minimum)/2;this.setCoercedValue(i+this.pageIncrement)}pageDecrease(){var t,e;const i=null!==(e=null===(t=this.pv)||void 0===t?void 0:t.value)&&void 0!==e?e:(this.maximum-this.minimum)/2;this.setCoercedValue(i-this.pageIncrement)}setCoercedValue(t){this.pv&&this.pv.writable&&(t=t<this.minimum?this.minimum:t>this.maximum?this.maximum:t,this.display.pvEngine.setValue(new Date,this.pv.name,t))}getCoercedValue(){var t,e;const i=null!==(e=null===(t=this.pv)||void 0===t?void 0:t.value)&&void 0!==e?e:(this.maximum-this.minimum)/2;return i<this.minimum?this.minimum:i>this.maximum?this.maximum:i}destroy(){window.clearTimeout(this.actionTimeout)}get enabled(){return this.properties.getValue(Hi)}get horizontal(){return this.properties.getValue(ji)}get showValueTip(){return this.properties.getValue(Ui)}get font(){return this.properties.getValue(Fi).scale(this.scale)}get minimum(){return this.properties.getValue(Di)}get maximum(){return this.properties.getValue(Ni)}get stepIncrement(){return this.properties.getValue($i)}get pageIncrement(){return this.properties.getValue(Gi)}get barLength(){return this.properties.getValue(zi)}}const Zi="font",Ji="format_type",Qi="horizontal_alignment",ts="precision",es="precision_from_pv",is="vertical_alignment";class ss extends ge{constructor(t,e){super(t,e),this.properties.add(new q(Zi)),this.properties.add(new $(Ji)),this.properties.add(new $(Qi)),this.properties.add(new $(ts)),this.properties.add(new z(es)),this.properties.add(new $(is,1))}draw(t){const e=t.ctx;this.transparent?this.backgroundAlarmSensitive&&this.alarm&&t.fillRect(Object.assign(Object.assign({},this.area),{color:this.alarmSensitiveBackgroundColor})):t.fillRect(Object.assign(Object.assign({},this.area),{color:this.backgroundColor}));const i=document.createElement("canvas");i.width=this.area.width,i.height=this.area.height;const s=i.getContext("2d");s.fillStyle=this.alarmSensitiveForegroundColor.toString(),s.font=this.font.getFontString();let r=this.x;0===this.horizAlignment?s.textAlign="start":1===this.horizAlignment?(r+=this.width/2,s.textAlign="center"):2===this.horizAlignment&&(r+=this.width,s.textAlign="end");let o=this.y;0===this.vertAlignment?s.textBaseline="top":1===this.vertAlignment?(o+=this.height/2,s.textBaseline="middle"):2===this.vertAlignment&&(o+=this.height,s.textBaseline="bottom");let h=this.text;if(this.pv&&void 0!==this.pv.value){const t=this.precisionFromPV?this.pv.precision:this.precision;h=this.pv.formatValue(this.formatType,t)}s.fillText(h,r-this.area.x,o-this.area.y),e.drawImage(i,this.area.x,this.area.y)}get font(){return this.properties.getValue(Zi).scale(this.scale)}get formatType(){return this.properties.getValue(Ji)}get horizAlignment(){return this.properties.getValue(Qi)}get precision(){return this.properties.getValue(ts)}get precisionFromPV(){return this.properties.getValue(es)}get vertAlignment(){return this.properties.getValue(is)}}const rs="alpha",os="fill",hs="line_width",ns="line_style",as="start_angle",ls="total_angle";class ds extends ge{constructor(t,e){super(t,e),this.properties.add(new $(rs,255)),this.properties.add(new $(hs)),this.properties.add(new $(as)),this.properties.add(new $(ls)),this.properties.add(new z(os)),this.properties.add(new $(ns))}draw(t){t.ctx.globalAlpha=this.alpha/255,this.drawShape(t),t.ctx.globalAlpha=1}drawShape(t){const e=this.x+this.width/2,i=this.y+this.height/2,s=this.width/2,r=this.height/2,o=-u(this.startAngle),h=-u(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,s,r,0,o,h,!0),t.ctx.closePath(),t.ctx.fill()),this.lineWidth&&0!==this.totalAngle){let n;const{scale:a}=this;0===this.lineStyle?n=[]:1===this.lineStyle?n=[6*a,2*a]:2===this.lineStyle?n=[2*a,2*a]:console.warn(`Unsupported arc line style ${this.lineStyle}`),t.strokeEllipse({cx:e,cy:i,rx:s,ry:r,startAngle:o,endAngle:h,lineWidth:this.lineWidth,anticlockwise:!0,color:this.alarmSensitiveForegroundColor,dash:n})}}get alpha(){return this.properties.getValue(rs)}get lineWidth(){return this.scale*this.properties.getValue(hs)}get lineStyle(){return this.properties.getValue(ns)}get startAngle(){return this.properties.getValue(as)}get totalAngle(){return this.properties.getValue(ls)}get fill(){return this.properties.getValue(os)}}const cs="alpha",ps="bg_gradient_color",gs="fg_gradient_color",us="fill_level",ms="gradient",xs="horizontal_fill",fs="line_color",ws="line_width",ys="line_style";class vs extends ge{constructor(t,e){super(t,e),this.properties.add(new $(cs,255)),this.properties.add(new U(ps)),this.properties.add(new U(gs)),this.properties.add(new z(ms)),this.properties.add(new $(ws)),this.properties.add(new G(us)),this.properties.add(new z(xs)),this.properties.add(new U(fs)),this.properties.add(new $(ys))}draw(t){t.ctx.globalAlpha=this.alpha/255,this.drawBackground(t),this.fillLevel&&this.drawFill(t),t.ctx.globalAlpha=1}drawBackground(t){const e=this.x+this.width/2,i=this.y+this.height/2,s=this.width/2,r=this.height/2;if(!this.transparent){const o=this.alarmSensitiveBackgroundColor;if(this.gradient){const h=this.horizontalFill?this.x:this.x+this.width,n=this.horizontalFill?this.y+this.height:this.y,a=t.createLinearGradient(this.x,this.y,h,n);a.addColorStop(0,this.backgroundGradientStartColor.toString()),a.addColorStop(1,o.toString()),t.fillEllipse({cx:e,cy:i,rx:s,ry:r,gradient:a})}else t.fillEllipse({cx:e,cy:i,rx:s,ry:r,color:o})}this.lineWidth&&(0===this.lineStyle?t.strokeEllipse({cx:e,cy:i,rx:s,ry:r,color:this.lineColor,lineWidth:this.lineWidth}):1===this.lineStyle?t.strokeEllipse({cx:e,cy:i,rx:s,ry:r,color:this.lineColor,lineWidth:this.lineWidth,dash:[6*this.scale,2*this.scale]}):console.warn(`Unsupported ellipse line style ${this.lineStyle}`))}drawFill(t){const e=d(this,this.lineWidth);if(t.ctx.save(),this.horizontalFill){const i=e.width*(this.fillLevel/100);t.ctx.beginPath(),t.ctx.rect(e.x,e.y,i,e.height)}else{const i=e.height*(this.fillLevel/100),s=e.y+e.height-i;t.ctx.beginPath(),t.ctx.rect(e.x,s,e.width,e.height)}t.ctx.clip();const i=this.x+this.width/2,s=this.y+this.height/2,r=(this.width-this.lineWidth)/2,o=(this.height-this.lineWidth)/2,h=this.alarmSensitiveForegroundColor;if(this.gradient){const e=this.horizontalFill?this.x:this.x+this.width,n=this.horizontalFill?this.y+this.height:this.y,a=t.createLinearGradient(this.x,this.y,e,n);a.addColorStop(0,this.foregroundGradientStartColor.toString()),a.addColorStop(1,h.toString()),t.fillEllipse({cx:i,cy:s,rx:r,ry:o,gradient:a})}else t.fillEllipse({cx:i,cy:s,rx:r,ry:o,color:h});t.ctx.restore()}get alpha(){return this.properties.getValue(cs)}get lineWidth(){return this.scale*this.properties.getValue(ws)}get fillLevel(){return this.properties.getValue(us)}get horizontalFill(){return this.properties.getValue(xs)}get lineColor(){return this.properties.getValue(fs)}get lineStyle(){return this.properties.getValue(ys)}get gradient(){return this.properties.getValue(ms)}get backgroundGradientStartColor(){return this.properties.getValue(ps)}get foregroundGradientStartColor(){return this.properties.getValue(gs)}}const bs="image_file",Ts="no_animation",Ss="transparency";class Vs extends ge{constructor(t,e){super(t,e),this.imageLoading=!1,this.imageLoaded=!1,this.properties.add(new D(bs)),this.properties.add(new D(Ts)),this.properties.add(new z(Ss,!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(){if(this.imageLoading=!0,this.imageLoaded=!1,this.imageElement&&this.imageFile){this.currentImageFile=this.imageFile;const t=this.display.getImageResolver();this.imageElement.src=t.resolve(this.imageFile)}}snapshotImage(t){const 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(Ss)}get imageFile(){return this.properties.getValue(bs)}get noAnimation(){return this.properties.getValue(Ts)}}const As="font",_s="horizontal_alignment",Ls="vertical_alignment",Cs="wrap_words";class Ps extends ge{constructor(t,e){super(t,e),this.properties.add(new q(As)),this.properties.add(new $(_s)),this.properties.add(new $(Ls)),this.properties.add(new z(Cs))}draw(t){const e=t.ctx;this.transparent||t.fillRect({x:this.x,y:this.y,width:this.width,height:this.height,color:this.backgroundColor});const 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 s=0;for(const t of i){const i=e.measureText(t).width;s=Math.max(s,i)}let r=this.x;1===this.horizAlignment?r=this.x+(this.width-s)/2:2===this.horizAlignment&&(r=this.x+(this.width-s));const o=i.length*this.font.height+(i.length-1)*this.font.height*.2;let h=this.y;1===this.vertAlignment?h+=(this.height-o)/2:2===this.vertAlignment&&(h+=this.height-o);for(const t of i)e.fillText(t,r,h),h+=1.2*this.font.height}wrapText(t,e,i){let s=[];for(const r of e.split("\n"))s=s.concat(this.wrapLine(t,r,i));return s}wrapLine(t,e,i){if(!e)return[""];const s=[];let r,o,h,n=0;for(;e.length;){for(o=e.length;t.measureText(e.substr(0,o),this.font).width>i;o--);if(r=e.substr(0,o),o!==e.length)for(h=0;-1!==r.indexOf(" ",h);h=r.indexOf(" ",h)+1);s.push(r.substr(0,h||r.length)),n=Math.max(n,t.measureText(s[s.length-1],this.font).width),e=e.substr(s[s.length-1].length,e.length)}return s}get font(){return this.properties.getValue(As).scale(this.scale)}get horizAlignment(){return this.properties.getValue(_s)}get vertAlignment(){return this.properties.getValue(Ls)}get wrapWords(){return this.properties.getValue(Cs)}}const Ms="alpha",ks="fill_level",Rs="horizontal_fill",Es="line_color",Ws="line_style",Bs="line_width",Is="points";class Os extends ge{constructor(t,e){super(t,e),this.properties.add(new $(Ms,255)),this.properties.add(new $(Bs)),this.properties.add(new G(ks)),this.properties.add(new z(Rs)),this.properties.add(new U(Es)),this.properties.add(new $(Ws)),this.properties.add(new X(Is,[]))}init(){this.addPropertyListener("x",((t,e)=>{const i=g(this.properties.getValue(Is),t-e,0);this.properties.setValue(Is,i),this.requestRepaint()})),this.addPropertyListener("y",((t,e)=>{const i=g(this.properties.getValue(Is),0,t-e);this.properties.setValue(Is,i),this.requestRepaint()}))}draw(t){const{scale:e}=this;t.ctx.globalAlpha=this.alpha/255;const i=b.fromPoints(this.points).closePath();if(!this.transparent){const e=this.alarmSensitiveBackgroundColor;t.fillPath({path:i,color:e})}this.lineWidth&&(0===this.lineStyle?t.strokePath({path:i,lineWidth:this.lineWidth,color:this.lineColor}):2===this.lineStyle?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,s=this.width,r=this.height;this.horizontalFill?s*=this.fillLevel/100:(r*=this.fillLevel/100,i+=r),t.ctx.save();let o=this.x-this.lineWidth/2,h=i-this.lineWidth/2,n=s+this.lineWidth,a=r+this.lineWidth;t.ctx.beginPath(),t.ctx.rect(o,h,n,a),t.ctx.clip();const l=this.alarmSensitiveForegroundColor;t.fillPath({path:e,color:l}),t.ctx.restore()}get alpha(){return this.properties.getValue(Ms)}get lineWidth(){return this.scale*this.properties.getValue(Bs)}get fillLevel(){return this.properties.getValue(ks)}get horizontalFill(){return this.properties.getValue(Rs)}get lineColor(){return this.properties.getValue(Es)}get lineStyle(){return this.properties.getValue(Ws)}get points(){return w(this.properties.getValue(Is),this.scale)}}const Hs="alpha",Fs="arrows",Ns="arrow_length",Ds="fill_arrow",js="fill_level",$s="horizontal_fill",Gs="line_width",zs="points";class Us extends ge{constructor(t,e){super(t,e),this.properties.add(new $(Hs,255)),this.properties.add(new $(Gs)),this.properties.add(new G(js)),this.properties.add(new z($s)),this.properties.add(new X(zs,[])),this.properties.add(new $(Ns)),this.properties.add(new z(Ds)),this.properties.add(new $(Fs))}draw(t){const 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,s=this.height;this.horizontalFill?i*=this.fillLevel/100:(s*=this.fillLevel/100,e+=s),t.save();let r=this.x-this.lineWidth/2,o=e-this.lineWidth/2,h=i+this.lineWidth,n=s+this.lineWidth;t.beginPath(),t.rect(r,o,h,n),t.clip(),this.drawShape(t,this.foregroundColor),t.restore()}drawShape(t,e){t.strokeStyle=e.toString(),t.lineWidth=this.lineWidth,t.beginPath();for(let e=0;e<this.points.length;e++)0===e?t.moveTo(this.points[e].x,this.points[e].y):t.lineTo(this.points[e].x,this.points[e].y);if(t.stroke(),this.points.length>=2){const i=this.points[0],s=this.points[this.points.length-1];if(2===this.arrows||3===this.arrows){const i=this.calculateArrowPoints(this.points[this.points.length-2],s);if(i[2]=s,this.fillArrow){t.fillStyle=e.toString(),t.beginPath();for(let e=0;e<i.length;e++)0===e?t.moveTo(i[e].x,i[e].y):t.lineTo(i[e].x,i[e].y);t.fill()}else t.strokeStyle=e.toString(),t.lineWidth=this.lineWidth,t.beginPath(),t.moveTo(s.x,s.y),t.lineTo(i[0].x,i[0].y),t.moveTo(s.x,s.y),t.lineTo(i[1].x,i[1].y),t.stroke()}if(1===this.arrows||3===this.arrows){const s=this.calculateArrowPoints(this.points[1],i);if(s[2]=i,this.fillArrow){t.fillStyle=e.toString(),t.beginPath();for(let e=0;e<s.length;e++)0===e?t.moveTo(s[e].x,s[e].y):t.lineTo(s[e].x,s[e].y);t.fill()}else t.strokeStyle=e.toString(),t.lineWidth=this.lineWidth,t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(s[0].x,s[0].y),t.moveTo(i.x,i.y),t.lineTo(s[1].x,s[1].y),t.stroke()}}}calculateArrowPoints(t,e){const i=x(e,t),s=Math.PI/10,r=new f(this.arrowLength,i.theta-s),o=new f(this.arrowLength,i.theta+s),h=new f(Math.floor(this.arrowLength*Math.cos(s)),i.theta);return[p(r.toPoint(),e.x,e.y),p(o.toPoint(),e.x,e.y),p(h.toPoint(),e.x,e.y)]}get alpha(){return this.properties.getValue(Hs)}get lineWidth(){return this.scale*this.properties.getValue(Gs)}get fillLevel(){return this.properties.getValue(js)}get horizontalFill(){return this.properties.getValue($s)}get points(){return w(this.properties.getValue(zs),this.scale)}get arrows(){return this.properties.getValue(Fs)}get fillArrow(){return this.properties.getValue(Ds)}get arrowLength(){return this.properties.getValue(Ns)}}const qs="alpha",Ys="bg_gradient_color",Xs="fg_gradient_color",Ks="fill_level",Zs="gradient",Js="horizontal_fill",Qs="line_color",tr="line_width",er="line_style";class ir extends ge{constructor(t,e){super(t,e),this.fillRoundRectangleBackgroundBorder=!1,this.properties.add(new $(qs,255)),this.properties.add(new U(Ys)),this.properties.add(new U(Xs)),this.properties.add(new z(Zs)),this.properties.add(new $(tr)),this.properties.add(new G(Ks)),this.properties.add(new z(Js)),this.properties.add(new U(Qs)),this.properties.add(new $(er))}draw(t){t.ctx.globalAlpha=this.alpha/255,this.drawBackground(t),this.fillLevel&&this.drawFill(t),t.ctx.globalAlpha=1}drawBackground(t){if(!this.transparent){const e=this.alarmSensitiveBackgroundColor;if(this.gradient){const i=this.horizontalFill?this.x:this.x+this.width,s=this.horizontalFill?this.y+this.height:this.y,r=t.createLinearGradient(this.x,this.y,i,s);r.addColorStop(0,this.backgroundGradientStartColor.toString()),r.addColorStop(1,e.toString()),t.fillRect(Object.assign(Object.assign({},this.area),{gradient:r}))}else t.fillRect(Object.assign(Object.assign({},this.area),{color:e}))}this.lineWidth&&(0===this.lineStyle?t.strokeRect(Object.assign(Object.assign({},this.area),{color:this.lineColor,lineWidth:this.lineWidth,crispen:!0})):1===this.lineStyle?t.strokeRect(Object.assign(Object.assign({},this.area),{color:this.lineColor,lineWidth:this.lineWidth,crispen:!0,dash:[6*this.scale,2*this.scale]})):console.warn(`Unsupported rectangle line style ${this.lineStyle}`))}drawFill(t){const e=d(this,this.lineWidth);if(t.ctx.save(),this.horizontalFill){const i=e.width*(this.fillLevel/100);t.ctx.beginPath(),t.ctx.rect(e.x,e.y,i,e.height)}else{const i=e.height*(this.fillLevel/100),s=e.y+e.height-i;t.ctx.beginPath(),t.ctx.rect(e.x,s,e.width,e.height)}t.ctx.clip();const i=this.alarmSensitiveForegroundColor;if(this.gradient){const s=this.horizontalFill?e.x:e.x+e.width,r=this.horizontalFill?e.y+e.height:e.y,o=t.createLinearGradient(e.x,e.y,s,r);o.addColorStop(0,this.foregroundGradientStartColor.toString()),o.addColorStop(1,i.toString()),t.fillRect(Object.assign(Object.assign({},e),{gradient:o}))}else t.fillRect(Object.assign(Object.assign({},e),{color:i}));t.ctx.restore()}get alpha(){return this.properties.getValue(qs)}get lineWidth(){return this.scale*this.properties.getValue(tr)}get fillLevel(){return this.properties.getValue(Ks)}get horizontalFill(){return this.properties.getValue(Js)}get lineColor(){return this.properties.getValue(Qs)}get lineStyle(){return this.properties.getValue(er)}get gradient(){return this.properties.getValue(Zs)}get backgroundGradientStartColor(){return this.properties.getValue(Ys)}get foregroundGradientStartColor(){return this.properties.getValue(Xs)}}const sr="alpha",rr="bg_gradient_color",or="corner_width",hr="corner_height",nr="fg_gradient_color",ar="fill_level",lr="gradient",dr="horizontal_fill",cr="line_color",pr="line_width",gr="line_style";class ur extends ge{constructor(t,e){super(t,e),this.fillRoundRectangleBackgroundBorder=!1,this.properties.add(new $(sr,255)),this.properties.add(new U(rr)),this.properties.add(new U(nr)),this.properties.add(new z(lr)),this.properties.add(new $(pr)),this.properties.add(new G(ar)),this.properties.add(new z(dr)),this.properties.add(new U(cr)),this.properties.add(new $(or)),this.properties.add(new $(hr)),this.properties.add(new $(gr))}draw(t){t.ctx.globalAlpha=this.alpha/255,this.drawBackground(t),this.fillLevel&&this.drawFill(t),t.ctx.globalAlpha=1}drawBackground(t){if(!this.transparent){const e=this.alarmSensitiveBackgroundColor;if(this.gradient){const i=this.horizontalFill?this.x:this.x+this.width,s=this.horizontalFill?this.y+this.height:this.y,r=t.createLinearGradient(this.x,this.y,i,s);r.addColorStop(0,this.backgroundGradientStartColor.toString()),r.addColorStop(1,e.toString()),t.fillRect(Object.assign(Object.assign({},this.area),{rx:this.cornerWidth/2,ry:this.cornerHeight/2,gradient:r}))}else t.fillRect(Object.assign(Object.assign({},this.area),{rx:this.cornerWidth/2,ry:this.cornerHeight/2,color:e}))}this.lineWidth&&(0===this.lineStyle?t.strokeRect(Object.assign(Object.assign({},this.area),{rx:this.cornerWidth/2,ry:this.cornerHeight/2,color:this.lineColor,lineWidth:this.lineWidth,crispen:!0})):1===this.lineStyle?t.strokeRect(Object.assign(Object.assign({},this.area),{rx:this.cornerWidth/2,ry:this.cornerHeight/2,color:this.lineColor,lineWidth:this.lineWidth,crispen:!0,dash:[6*this.scale,2*this.scale]})):console.warn(`Unsupported RoundedRectangle line style ${this.lineStyle}`))}drawFill(t){const e=this.cornerWidth/2,i=this.cornerHeight/2,s=d(this,this.lineWidth);if(t.ctx.save(),this.horizontalFill){const e=s.width*(this.fillLevel/100);t.ctx.beginPath(),t.ctx.rect(s.x,s.y,e,s.height)}else{const e=s.height*(this.fillLevel/100),i=s.y+s.height-e;t.ctx.beginPath(),t.ctx.rect(s.x,i,s.width,s.height)}t.ctx.clip();const r=this.alarmSensitiveForegroundColor;if(this.gradient){const o=this.horizontalFill?s.x:s.x+s.width,h=this.horizontalFill?s.y+s.height:s.y,n=t.createLinearGradient(s.x,s.y,o,h);n.addColorStop(0,this.foregroundGradientStartColor.toString()),n.addColorStop(1,r.toString()),t.fillRect(Object.assign(Object.assign({},s),{rx:e,ry:i,gradient:n}))}else t.fillRect(Object.assign(Object.assign({},s),{rx:e,ry:i,color:r}));t.ctx.restore()}get alpha(){return this.properties.getValue(sr)}get lineWidth(){return this.scale*this.properties.getValue(pr)}get fillLevel(){return this.properties.getValue(ar)}get horizontalFill(){return this.properties.getValue(dr)}get lineColor(){return this.properties.getValue(cr)}get lineStyle(){return this.properties.getValue(gr)}get gradient(){return this.properties.getValue(lr)}get cornerWidth(){return this.scale*this.properties.getValue(or)}get cornerHeight(){return this.scale*this.properties.getValue(hr)}get backgroundGradientStartColor(){return this.properties.getValue(rr)}get foregroundGradientStartColor(){return this.properties.getValue(nr)}}const mr="bitReverse",xr="effect_3d",fr="horizontal",wr="led_border",yr="led_border_color",vr="led_packed",br="numBits",Tr="off_color",Sr="on_color",Vr="startBit",Ar="square_led";class _r extends ge{constructor(t,i){super(t,i),this.properties.add(new z(mr)),this.properties.add(new z(xr)),this.properties.add(new z(fr)),this.properties.add(new $(br)),this.properties.add(new U(Tr)),this.properties.add(new U(Sr)),this.properties.add(new $(Vr)),this.properties.add(new z(Ar)),this.properties.add(new $(wr,3)),this.properties.add(new U(yr,e.DARK_GRAY)),this.properties.add(new z(vr,!1))}getLedColor(t){var e,i;let s=!1;if(void 0!==(null===(e=this.pv)||void 0===e?void 0:e.value))for(let e=this.startBit;e<this.startBit+this.numBits;e++){let r=0;if(r=this.bitReverse?e-this.startBit:this.numBits-1-(e-this.startBit),r===t){s=((null===(i=this.pv)||void 0===i?void 0:i.value)>>e&1)>0;break}}return s?this.onColor:this.offColor}draw(t){if(this.numBits<1)return;let e=this.bounds;this.borderAlarmSensitive&&(e=d(e,2*this.scale)),this.horizontal?this.drawHorizontal(t,e):this.drawVertical(t,e)}drawHorizontal(t,e){let i,s;this.ledPacked?(i=Math.floor((e.width-this.ledBorder)/this.numBits+this.ledBorder),s=i-this.ledBorder):(i=Math.floor(e.width/this.numBits),s=i);let r=0;r=i>e.height||this.squareLed?e.height:i;for(let o=0;o<this.numBits;o++)if(this.squareLed){const h={x:e.x+o*s,y:e.y,width:i,height:r};this.effect3d?this.drawSquare3d(t,h,o):this.drawSquare2d(t,h,o)}else{const h=Math.min(i,r),n={x:e.x+o*s,y:e.y,width:h,height:h};this.effect3d?this.drawCircle3d(t,n,o):this.drawCircle2d(t,n,o)}}drawVertical(t,e){let i,s;this.ledPacked?(i=Math.floor((e.height-this.ledBorder)/this.numBits+this.ledBorder),s=i-this.ledBorder):(i=Math.floor(e.height/this.numBits),s=i);let r=0;r=i>e.width||this.squareLed?e.width:i;for(let o=0;o<this.numBits;o++)if(this.squareLed){const h={x:e.x,y:e.y+o*s,width:r,height:i};this.effect3d?this.drawSquare3d(t,h,o):this.drawSquare2d(t,h,o)}else{const h=Math.min(r,i),n={x:e.x,y:e.y+o*s,width:h,height:h};this.effect3d?this.drawCircle3d(t,n,o):this.drawCircle2d(t,n,o)}}drawCircle2d(t,e,i){const s=e.x+e.width/2,r=e.y+e.height/2;let o=e.width/2,h=e.height/2;this.ledBorder>0&&(o-=this.ledBorder/2,h-=this.ledBorder/2),t.fillEllipse({cx:s,cy:r,rx:o,ry:h,color:this.getLedColor(i)}),t.strokeEllipse({cx:s,cy:r,rx:o,ry:h,color:this.ledBorderColor,lineWidth:this.ledBorder})}drawCircle3d(t,i,s){const r=i.x+i.width/2,o=i.y+i.height/2;let h=i.width/2,n=i.height/2;t.fillEllipse({cx:r,cy:o,rx:h,ry:n,color:e.WHITE});let a=t.createLinearGradient(i.x,i.y,i.x+i.width,i.y+i.height);a.addColorStop(0,this.ledBorderColor.toString()),a.addColorStop(1,this.ledBorderColor.withAlpha(0).toString()),t.fillEllipse({cx:r,cy:o,rx:h,ry:n,gradient:a});h=(i.width-2*this.ledBorder)/2,n=(i.height-2*this.ledBorder)/2,t.fillEllipse({cx:r,cy:o,rx:h,ry:n,color:this.getLedColor(s)}),a=t.createLinearGradient(i.x,i.y,i.x+i.width,i.y+i.height),a.addColorStop(0,e.WHITE.toString()),a.addColorStop(1,this.ledBorderColor.withAlpha(0).toString()),t.fillEllipse({cx:r,cy:o,rx:h,ry:n,gradient:a})}drawSquare2d(t,e,i){const s=a(e.x,e.y,e.width,e.height,this.ledBorder);t.fillRect(Object.assign(Object.assign({},s),{color:this.getLedColor(i)})),t.strokeRect(Object.assign(Object.assign({},s),{color:this.ledBorderColor,lineWidth:this.ledBorder}))}drawSquare3d(t,e,i){t.fillRect(Object.assign(Object.assign({},e),{color:this.ledBorderColor}));let s=t.createLinearGradient(e.x,e.y,e.x+e.width,e.y);s.addColorStop(0,"rgba(0,0,0,0.078)"),s.addColorStop(1,"rgba(0,0,0,0.39)"),t.fillPath({gradient:s,path:new b(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)}),s=t.createLinearGradient(e.x,e.y,e.x,e.y+e.height),s.addColorStop(0,"rgba(0,0,0,0.078)"),s.addColorStop(1,"rgba(0,0,0,0.39)"),t.fillPath({gradient:s,path:new b(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)}),s=t.createLinearGradient(e.x,e.y,e.x+e.width,e.y),s.addColorStop(0,"rgba(255,255,255,0.078)"),s.addColorStop(1,"rgba(255,255,255,0.39)"),t.fillPath({gradient:s,path:new b(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)}),s=t.createLinearGradient(e.x,e.y,e.x,e.y+e.height),s.addColorStop(0,"rgba(255,255,255,0.078)"),s.addColorStop(1,"rgba(255,255,255,0.39)"),t.fillPath({gradient:s,path:new b(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)});const r=e.x+this.ledBorder,o=e.y+this.ledBorder,h=e.width-2*this.ledBorder,n=e.height-2*this.ledBorder,a=this.getLedColor(i);t.fillRect({x:r,y:o,width:h,height:n,color:a}),s=t.createLinearGradient(e.x,e.y,e.x+e.width,e.y+e.height),s.addColorStop(0,"rgba(255,255,255,0.784)"),s.addColorStop(1,a.withAlpha(0).toString()),t.fillRect({x:r,y:o,width:h,height:n,gradient:s})}get bitReverse(){return this.properties.getValue(mr)}get horizontal(){return this.properties.getValue(fr)}get numBits(){return this.properties.getValue(br)}get startBit(){return this.properties.getValue(Vr)}get ledPacked(){return this.properties.getValue(vr)}get ledBorder(){return this.scale*this.properties.getValue(wr)}get ledBorderColor(){return this.properties.getValue(yr)}get offColor(){return this.properties.getValue(Tr)}get onColor(){return this.properties.getValue(Sr)}get effect3d(){return this.properties.getValue(xr)}get squareLed(){return this.properties.getValue(Ar)}}class Lr{constructor(t){this.prefix="",this.suffix="",this.comma=0,this.minInt=1,this.minFrac=0,this.maxFrac=0;for(let e=0;e<t.length;e++)if("#"==t.charAt(e)||"0"==t.charAt(e)){this.prefix=t.substring(0,e),t=t.substring(e);break}this.suffix=t.replace(/[#]|[0]|[,]|[.]/g,"");const e=t.replace(/[^0#,.]/g,"");let i="",s="";const r=e.indexOf(".");-1!==r?(i=e.substring(0,r),s=e.substring(r+1)):i=e;const o=i.lastIndexOf(",");-1!==o&&(this.comma=i.length-1-o),i=i.replace(/[,]/g,""),s=s.replace(/[,]|[.]+/g,""),this.maxFrac=s.length;let h=i.replace(/[^0]/g,"");h.length>this.minInt&&(this.minInt=h.length),h=s.replace(/[^0]/g,""),this.minFrac=h.length}format(t){let e=this.formatBack(t).toLowerCase();if(isNaN(e)||0==e.length)return t;if(-1!=e.indexOf("e")){const t=Number(e);if(t===1/0||t===-1/0)return e;if(e=t+"",-1!==e.indexOf("e"))return e}let i=!1;"-"===e.charAt(0)?(i=!0,e=e.substring(1)):"+"===e.charAt(0)&&(e=e.substring(1));const s=e.indexOf(".");let r="",o="";-1!=s?(r=e.substring(0,s),o=e.substring(s+1)):r=e,o=o.replace(/[.]/,"");const h=this.suffix&&"%"===this.suffix.charAt(0);let n=this.minInt,a=this.minFrac,l=this.maxFrac;if(h&&(n-=2,a+=2,l+=2),o.length>l){let t=Number("0."+o);t=0==l?Math.round(t):t.toFixed(l),o=t.toString(10).substr(2);let e,i=t>=1?1:0,s=r.length-1;for(;i;){if(-1==s){r="1"+r;break}e=Number(r.charAt(s)),9===e?(e="0",i=1):(e=++e+"",i=0),r=r.substring(0,s)+e+r.substring(s+1,r.length),s--}}for(let t=o.length;t<a;t++)o+="0";for(;o.length>a&&"0"==o.charAt(o.length-1);)o=o.substring(0,o.length-1);for(let t=r.length;t<n;t++)r="0"+r;for(;r.length>n&&"0"==r.charAt(0);)r=r.substring(1);h&&(r+=o.substring(0,2),o=o.substring(2));let d,c=0;for(let t=r.length;t>0;t--)0!=c&&c%this.comma==0&&(r=r.substring(0,t)+","+r.substring(t),c=0),c++;return d=o.length>0?this.prefix+r+"."+o+this.suffix:this.prefix+r+this.suffix,i&&(d="-"+d),d}formatBack(t){if(!(t+=""))return"";if(!isNaN(t))return this.getNumericString(t);let e=t,i=!1;"-"===t.charAt(0)&&(e=e.substr(1),i=!0);const s=e.indexOf(this.prefix),r=""==this.suffix?e.length:e.indexOf(this.suffix,this.prefix.length+1);return 0==s&&r>0&&(e=e.substr(0,r),e=e.substr(this.prefix.length),e=e.replace(/,/g,""),i&&(e="-"+e),!isNaN(e))?this.getNumericString(e):t}getNumericString(t){const e=Number(t)+"";if(t.indexOf(".")>-1&&e.indexOf(".")<0){for(var i=t.indexOf(".")+1;i<t.length;i++)if("0"!==t.charAt(i))return t;return e}return t}}class Cr{constructor(t,i,s){this.rampWidth=t,this.startAngle=i,this.endAngle=s,this.lolo=10,this.loloColor=e.RED,this.showLoLo=!0,this.lo=25,this.loColor=e.ORANGE,this.showLo=!0,this.hi=75,this.hiColor=e.ORANGE,this.showHi=!0,this.hihi=90,this.hihiColor=e.RED,this.showHiHi=!0,this.minimum=0,this.maximum=100,this.gradient=!0,this.logScale=!1,this.effect3d=!0,this.labelsOutside=!0,this.range={min:this.minimum,max:this.maximum},this.lengthInDegrees=0,this.radius=0}draw(t,e,i){if(this.labelsOutside){const t=9;this.radius=e.width/2-t}else this.radius=e.width/2-1;this.range=this.getRenderedRange(),this.endAngle-this.startAngle>0?this.lengthInDegrees=360-(this.endAngle-this.startAngle):this.lengthInDegrees=this.startAngle-this.endAngle,this.drawRamp(t,i)}drawRamp(t,i){const s=i.x+i.width/2,r=i.y+i.height/2,o=i.width/2,h=i.height/2;let n,a=360-this.endAngle;if(n=this.endAngle-this.startAngle>0?this.startAngle-90:this.startAngle+90,this.showLoLo){let e=n,i=360-this.getValuePosition(this.lolo,!0);t.strokeEllipse({cx:s,cy:r,rx:o-this.rampWidth/2,ry:h-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:u(e),endAngle:u(i),color:this.loloColor})}if(this.showLo){let e;e=this.showLoLo?this.lolo:this.minimum;const n=360-this.getValuePosition(e,!0),a=360-this.getValuePosition(this.lo,!0);if(this.effect3d&&this.gradient&&this.showLoLo){const l=u(this.getValuePosition(e,!0)-2),d=m(i.width/2,l,i),c=u(this.getValuePosition(this.lo,!0)+2),p=m(i.width/2,c,i),g=t.createLinearGradient(d.x,d.y,p.x,p.y);g.addColorStop(0,this.loloColor.toString()),g.addColorStop(1,this.loColor.toString()),t.strokeEllipse({cx:s,cy:r,rx:o-this.rampWidth/2,ry:h-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:u(n-1),endAngle:u(a+1),gradient:g})}else t.strokeEllipse({cx:s,cy:r,rx:o-this.rampWidth/2,ry:h-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:u(n),endAngle:u(a),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);const c=(l+d)/2;let p=360-this.getValuePosition(l,!0),g=360-this.getValuePosition(c,!0);if(this.effect3d&&this.gradient&&(this.showLoLo||this.showLo)){const n=u(this.getValuePosition(l,!0)-2),a=m(i.width/2,n,i),d=u(this.getValuePosition(c,!0)+2),x=m(i.width/2,d,i),f=t.createLinearGradient(a.x,a.y,x.x,x.y);f.addColorStop(0,(this.showLo?this.loColor:this.loloColor).toString()),f.addColorStop(1,e.GREEN.toString()),t.strokeEllipse({cx:s,cy:r,rx:o-this.rampWidth/2,ry:h-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:u(p-1),endAngle:u(g+1),gradient:f})}else t.strokeEllipse({cx:s,cy:r,rx:o-this.rampWidth/2,ry:h-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:u(p),endAngle:u(g),color:e.GREEN});if(p=360-this.getValuePosition(c,!0),g=360-this.getValuePosition(d,!0),this.effect3d&&this.gradient&&(this.showHi||this.showHiHi)){const n=u(this.getValuePosition(c,!0)-2),l=m(i.width/2,n,i),x=u(this.getValuePosition(d,!0)+2),f=m(i.width/2,x,i),w=t.createLinearGradient(l.x,l.y,f.x,f.y);w.addColorStop(0,e.GREEN.toString()),w.addColorStop(1,(this.showHi?this.hiColor:this.hihiColor).toString());const y=g!==a?1:0;t.strokeEllipse({cx:s,cy:r,rx:o-this.rampWidth/2,ry:h-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:u(p-1),endAngle:u(g+y),gradient:w})}else t.strokeEllipse({cx:s,cy:r,rx:o-this.rampWidth/2,ry:h-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:u(p),endAngle:u(g),color:e.GREEN});if(this.showHi){let e;e=this.showHiHi?this.hihi:this.maximum;const n=360-this.getValuePosition(this.hi,!0),l=360-this.getValuePosition(e,!0);if(this.effect3d&&this.gradient&&this.showHiHi){const d=u(this.getValuePosition(this.hi,!0)-2),c=m(i.width/2,d,i),p=u(this.getValuePosition(e,!0)+2),g=m(i.width/2,p,i),x=t.createLinearGradient(c.x,c.y,g.x,g.y);x.addColorStop(0,this.hiColor.toString()),x.addColorStop(1,this.hihiColor.toString());const f=l!==a?1:0;t.strokeEllipse({cx:s,cy:r,rx:o-this.rampWidth/2,ry:h-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:u(n-1),endAngle:u(l+f),gradient:x})}else t.strokeEllipse({cx:s,cy:r,rx:o-this.rampWidth/2,ry:h-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:u(n),endAngle:u(l),color:this.hiColor})}if(this.showHiHi){p=360-this.getValuePosition(this.hihi,!0),g=a;const e=this.gradient?1:0;t.strokeEllipse({cx:s,cy:r,rx:o-this.rampWidth/2,ry:h-this.rampWidth/2,lineWidth:this.rampWidth,startAngle:u(p-e),endAngle:u(g),color:this.hihiColor})}}getRadius(){return this.radius}getValuePosition(t,e=!1){let i;return e&&(t=this.getValueInRange(t)),i=this.logScale?this.startAngle-(Math.log10(t)-Math.log10(this.range.min))/(Math.log10(this.range.max)-Math.log10(this.range.min))*this.lengthInDegrees: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(){const 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}}const Pr=new e(100,100,100),Mr="color_hi",kr="color_hihi",Rr="color_lo",Er="color_lolo",Wr="effect_3d",Br="font",Ir="value_label_format",Or="level_hi",Hr="level_hihi",Fr="level_lo",Nr="level_lolo",Dr="limits_from_pv",jr="log_scale",$r="minimum",Gr="maximum",zr="needle_color",Ur="ramp_gradient",qr="show_ramp";class Yr extends ge{constructor(t,e){super(t,e),this.properties.add(new U(Mr)),this.properties.add(new U(kr)),this.properties.add(new U(Rr)),this.properties.add(new U(Er)),this.properties.add(new z(Wr)),this.properties.add(new q(Br)),this.properties.add(new G(Or)),this.properties.add(new G(Hr)),this.properties.add(new G(Fr)),this.properties.add(new G(Nr)),this.properties.add(new z(jr)),this.properties.add(new z(Dr)),this.properties.add(new G(Gr)),this.properties.add(new G($r)),this.properties.add(new U(zr)),this.properties.add(new z(Ur)),this.properties.add(new z(qr,!0)),this.properties.add(new D(Ir))}draw(t){var e,i;let s;s=this.limitsFromPv&&this.pv&&!this.pv.disconnected?{min:null!==(e=this.pv.lowerDisplayLimit)&&void 0!==e?e:this.minimum,lolo:this.pv.lowerAlarmLimit,lo:this.pv.lowerWarningLimit,hi:this.pv.upperWarningLimit,hihi:this.pv.upperAlarmLimit,max:null!==(i=this.pv.upperDisplayLimit)&&void 0!==i?i:this.maximum}:{min:this.minimum,lolo:this.levelLoLo,lo:this.levelLo,hi:this.levelHi,hihi:this.levelHiHi,max:this.maximum},this.logScale&&(s.min=Math.max(.1,s.min),s.max<=s.min&&(s.max=s.min+100));const r=Math.min(this.width,this.height),o=r;this.drawBackground(t,r,o),this.showRamp&&this.drawRamp(t,r,o,s),this.drawLabel(t,r,o),this.drawNeedle(t,r,o,s),this.drawNeedleCenter(t,r,o)}drawBackground(t,i,s){if(t.fillEllipse({cx:this.x+i/2,cy:this.y+s/2,rx:i/2,ry:s/2,color:e.GRAY}),this.effect3d){const r=t.createLinearGradient(this.x,this.y,this.x+this.width,this.y+this.height);r.addColorStop(0,Pr.toString()),r.addColorStop(1,e.WHITE.toString()),t.fillEllipse({cx:this.x+i/2,cy:this.y+s/2,rx:i/2,ry:s/2,gradient:r})}const r=(this.effect3d?2:1)*this.scale;if(t.fillEllipse({cx:this.x+i/2,cy:this.y+s/2,rx:i/2-r,ry:s/2-r,color:this.backgroundColor}),this.effect3d){const r=i/2,o=.95,h=.5,n=.85,a=u(0),l=u(35);let d={x:Math.floor(this.x+i/2-r*n*Math.cos(a)),y:Math.floor(this.y+s/2-r*o),width:Math.floor(2*r*n*Math.cos(a)),height:Math.floor(r*o+r*h)},c=t.createLinearGradient(d.x,d.y,d.x,d.y+d.height);c.addColorStop(0,e.WHITE.withAlpha(90/255).toString()),c.addColorStop(1,e.WHITE.withAlpha(0).toString()),t.fillEllipse({cx:d.x+d.width/2,cy:d.y+d.height/2,rx:d.width/2,ry:d.height/2,gradient:c}),d={x:Math.floor(this.x+i/2-r*n*Math.sin(l)),y:Math.floor(Math.ceil(this.y+s/2+r*h)),width:Math.floor(2*r*n*Math.sin(l)),height:Math.floor(Math.ceil(r*o-r*h))},c=t.createLinearGradient(d.x,d.y,d.x,d.y+d.height),c.addColorStop(0,e.WHITE.withAlpha(0).toString()),c.addColorStop(1,e.WHITE.withAlpha(40/255).toString()),t.fillEllipse({cx:d.x+d.width/2,cy:d.y+d.height/2,rx:d.width/2,ry:d.height/2,gradient:c})}}drawRamp(t,e,i,s){const r=d({x:this.x,y:this.y,width:e,height:i},e/4,i/4),o=Object.assign({},r);o.width=Math.min(r.width,r.height),o.height=r.width;const h=new Cr(10*this.scale,225,315);h.lolo=s.lolo,h.loloColor=this.colorLoLo,h.lo=s.lo,h.loColor=this.colorLo,h.hi=s.hi,h.hiColor=this.colorHi,h.hihi=s.hihi,h.hihiColor=this.colorHiHi,h.minimum=s.min,h.maximum=s.max,h.effect3d=this.effect3d,h.gradient=this.rampGradient,h.logScale=this.logScale,h.draw(t,r,o)}drawLabel(t,e,i){var s;const r=W.ARIAL_12_BOLD.scale(this.scale);if(void 0!==(null===(s=this.pv)||void 0===s?void 0:s.value)){const s=this.formatLabelValue(this.pv.value),o=t.measureText(s,r);t.fillText({x:this.x+e/2-o.width/2,y:this.y+7*i/8-o.height/2,color:this.foregroundColor,align:"left",baseline:"top",font:r,text:s})}}drawNeedle(t,e,i,s){var r;const o=this.x+e/2,h=this.y+i/2;let n;if(void 0!==(null===(r=this.pv)||void 0===r?void 0:r.value)){const t=this.getValueInRange(this.pv.value,s);n=360-this.getValuePosition(t,s),s.max>s.min?t>s.max?n+=10:t<s.min&&(n-=10):t>s.min?n-=10:t<s.max&&(n+=10)}else n=360-this.getValuePosition((s.min+s.max)/2,s);const a=u(n),{scale:d}=this,{needleDiameter:c,majorTickLength:p,gapBetweenNeedleScale:g}=this,m=l(o,h-c/2+3*d,o,h,a),x=l(o+e/2-p-g,h,o,h,a),f=l(o,h+c/2-3*d,o,h,a);t.fillPath({color:this.needleColor,path:new b(m.x,m.y).lineTo(x.x,x.y).lineTo(f.x,f.y).closePath()})}drawNeedleCenter(t,i,s){const{needleDiameter:r}=this,o=this.x+i/2,h=this.y+s/2,n=r/2,a=r/2;if(this.effect3d){const i=t.createLinearGradient(o-n,h-a,o+n,h+a);i.addColorStop(0,e.WHITE.toString()),i.addColorStop(1,Pr.toString()),t.fillEllipse({cx:o,cy:h,rx:n,ry:a,gradient:i})}else t.fillEllipse({cx:o,cy:h,rx:n,ry:a,color:e.GRAY})}getValueInRange(t,e){return e.min<=t&&t<=e.max?t:t>e.max?e.max:e.min}getValuePosition(t,e){let i;return i=this.logScale?225-(Math.log10(t)-Math.log10(e.min))/(Math.log10(e.max)-Math.log10(e.min))*270:225-(t-e.min)/(e.max-e.min)*270,i<0&&(i+=360),i}formatLabelValue(t){return this.valueLabelFormat?new Lr(this.valueLabelFormat).format(t):String(Number(t.toFixed(3)))}get needleDiameter(){return 16*this.scale}get majorTickLength(){return 8*this.scale}get minorTickLength(){return 5*this.scale}get gapBetweenNeedleScale(){return-1*this.scale}get colorLo(){return this.properties.getValue(Rr)}get colorLoLo(){return this.properties.getValue(Er)}get colorHi(){return this.properties.getValue(Mr)}get colorHiHi(){return this.properties.getValue(kr)}get effect3d(){return this.properties.getValue(Wr)}get font(){return this.properties.getValue(Br).scale(this.scale)}get levelLo(){return this.properties.getValue(Fr)}get levelLoLo(){return this.properties.getValue(Nr)}get levelHi(){return this.properties.getValue(Or)}get levelHiHi(){return this.properties.getValue(Hr)}get limitsFromPv(){return this.properties.getValue(Dr)}get logScale(){return this.properties.getValue(jr)}get minimum(){return this.properties.getValue($r)}get maximum(){return this.properties.getValue(Gr)}get needleColor(){return this.properties.getValue(zr)}get rampGradient(){return this.properties.getValue(Ur)}get showRamp(){return this.properties.getValue(qr)}get valueLabelFormat(){return this.properties.getValue(Ir)}}const Xr="data_type",Kr="off_image",Zr="off_label",Jr="font",Qr="on_image",to="on_label",eo="show_boolean_label";class io extends ge{constructor(t,e){super(t,e),this.onImageLoaded=!1,this.offImageLoaded=!1,this.properties.add(new $("bit")),this.properties.add(new $(Xr)),this.properties.add(new D(Kr)),this.properties.add(new D(Zr)),this.properties.add(new D(Qr)),this.properties.add(new D(to)),this.properties.add(new q(Jr)),this.properties.add(new z(eo))}init(){if(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){const t=this.display.getImageResolver();this.onImageElement.src=t.resolve(this.onImage)}if(this.offImage){const t=this.display.getImageResolver();this.offImageElement.src=t.resolve(this.offImage)}}get booleanValue(){var t,e,i;return this.bit<0?Boolean(null===(t=this.pv)||void 0===t?void 0:t.toNumber()):void 0!==(null===(e=this.pv)||void 0===e?void 0:e.value)&&((null===(i=this.pv)||void 0===i?void 0:i.value)>>this.bit&1)>0}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("bit")}get dataType(){return this.properties.getValue(Xr)}get showBooleanLabel(){return this.properties.getValue(eo)}get font(){return this.properties.getValue(Jr).scale(this.scale)}get offLabel(){return this.properties.getValue(Zr)}get offImage(){return this.properties.getValue(Kr)}get onLabel(){return this.properties.getValue(to)}get onImage(){return this.properties.getValue(Qr)}}const so=["January","February","March","April","May","June","July","August","September","October","November","December"];class ro{constructor(t,e,i,s,r,o,h,n,a){this.scale=t,this.scaleFont=e,this.minimum=i,this.maximum=s,this.logScale=r,this.majorTickStepHint=o,this.foregroundColor=h,this.showMinorTicks=n,this.showScale=a,this.labels=[],this.labelValues=[],this.labelPositions=[],this.labelVisibilities=[],this.gridStepInPixel=0,this.horizontal=!1,this.x=0,this.y=0,this.scaleFormat="",this.timeFormat=0,this.length=0,this.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((t=>this.length-t))),t.pop(),t.shift(),t}setDimensions(t,e,i,s){this.x=t,this.y=e,this.length=i,this.horizontal=s}getValuePosition(t){let{start:e,stop:i}=this.getMinMax(),s=0;const r=this.length-2*this.margin;if(this.logScale)s=t<=0?this.margin:(Math.log10(t)-Math.log10(e))/(Math.log10(i)-Math.log10(e))*r+this.margin;else{const o=Math.max(Math.abs(e),Math.abs(i));i/=o,e/=o;s=(t/o-e)/(i-e)*r+this.margin}return this.horizontal?s+this.x:this.length-s+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){const e=this.getMinMax();let{start:i,stop:s}=e;const r=this.horizontal?t-this.x:this.length+this.y-t,o=this.length-2*this.margin;let h;if(this.logScale)h=Math.pow(10,(r-this.margin)*(Math.log10(s)-Math.log10(i))/o+Math.log10(i));else{const t=Math.max(Math.abs(i),Math.abs(s));s/=t,i/=t;const e=s-i;h=((r-this.margin)/o*e+i)*t}return h}calculateMargin(t,e){if(this.showScale){const i=t.measureText(this.format(this.minimum),this.scaleFont),s=t.measureText(this.format(this.maximum),this.scaleFont);return e?Math.ceil(Math.max(i.width,s.width)/2):Math.ceil(Math.max(i.height,s.height)/2)}return 0}measureHorizontalHeight(t){const e=t.measureText("dummy",this.scaleFont);return this.showScale?e.height+this.spaceBetweenMarkAndLabel+this.majorTickLength:0}drawHorizontal(t,e,i,s){const{scale:r}=this;this.length=s,this.horizontal=!0,this.margin=this.calculateMargin(t,this.horizontal);const o=s-2*this.margin;o>0&&this.updateLabels(t,o);let h=0;for(let e=0;e<this.labels.length;e++){const i=t.measureText(this.labels[e],this.scaleFont);i.height>h&&(h=i.height)}const n=this.showScale?h+this.spaceBetweenMarkAndLabel+this.majorTickLength:0;if(i-=n,this.x=e,this.y=i,this.logScale)for(let e=0;e<this.labelPositions.length;e++){const i=this.x+this.labelPositions[e],s=this.y;let o=0;if(o=this.labelVisibilities[e]?this.majorTickLength:this.minorTickLength,this.labelVisibilities[e]||this.showMinorTicks){const e=Math.round(i)-.5*r;t.strokePath({path:new b(e,s).lineTo(e,s+o),color:this.foregroundColor,lineWidth:1*r,opacity:100/255})}this.labelVisibilities[e]&&t.fillText({x:i,y:this.y+this.spaceBetweenMarkAndLabel+this.majorTickLength,align:"center",baseline:"top",font:this.scaleFont,color:this.foregroundColor,text:this.labels[e]})}else for(let s=0;s<this.labels.length;s++){const o=e+this.labelPositions[s];this.labelVisibilities[s]&&t.fillText({x:o,y:i+this.majorTickLength+this.spaceBetweenMarkAndLabel,align:"center",baseline:"top",font:this.scaleFont,color:this.foregroundColor,text:this.labels[s]});const h=Math.round(o)-.5*r;t.strokePath({path:new b(h,i).lineTo(h,i+this.majorTickLength),color:this.foregroundColor,lineWidth:1*r,opacity:100/255}),this.showMinorTicks&&this.drawMinorXTicks(t,s,e,i)}return n}drawVertical(t,e,i,s,r,o=!1){const{scale:h}=this;this.length=s,this.horizontal=!1,this.margin=this.calculateMargin(t,this.horizontal);const n=s-2*this.margin;n>0&&this.updateLabels(t,n);let a=0;for(let e=0;e<this.labels.length;e++){const i=t.measureText(this.labels[e],this.scaleFont);i.width>a&&(a=i.width)}const l=this.showScale?a+this.spaceBetweenMarkAndLabel+this.majorTickLength:0;if(r||(e-=l),this.x=e,this.y=i,this.logScale)for(let r=0;r<this.labelPositions.length;r++){let o;o=this.labelVisibilities[r]?this.majorTickLength:this.minorTickLength;const n=e+a+this.spaceBetweenMarkAndLabel-1*h+this.majorTickLength-o,l=Math.round(i+s-this.labelPositions[r])-.5*h;if((this.labelVisibilities[r]||this.showMinorTicks)&&t.strokePath({path:new b(n,l).lineTo(n+o,l),color:this.foregroundColor,lineWidth:1*h,opacity:100/255}),this.labelVisibilities[r]){const o=i+s-this.labelPositions[r];t.fillText({x:e,y:o,align:"left",baseline:"middle",font:this.scaleFont,color:this.foregroundColor,text:this.labels[r]})}}else for(let r=0;r<this.labels.length;r++){const n=i+s-this.labelPositions[r],l=Math.round(n)-.5*h;if(o){if(t.strokePath({path:new b(e,l).lineTo(e+this.majorTickLength,l),color:this.foregroundColor,lineWidth:1*h,opacity:100/255}),this.labelVisibilities[r]){const i=e+this.majorTickLength+this.spaceBetweenMarkAndLabel;t.fillText({x:i,y:n,align:"left",baseline:"middle",font:this.scaleFont,color:this.foregroundColor,text:this.labels[r]})}}else{this.labelVisibilities[r]&&t.fillText({x:e,y:n,align:"left",baseline:"middle",font:this.scaleFont,color:this.foregroundColor,text:this.labels[r]});const o=e+a+this.spaceBetweenMarkAndLabel-1*h;t.strokePath({path:new b(o,l).lineTo(o+this.majorTickLength,l),color:this.foregroundColor,lineWidth:1*h,opacity:100/255}),this.showMinorTicks&&this.drawMinorYTicks(t,r,o,i+s)}}return l}drawMinorXTicks(t,e,i,s){const{gridStepInPixel:r}=this;let o,h;r/5>=this.minorTickMarkStepHint?(o=5,h=Math.floor(r/5)):r/4>=this.minorTickMarkStepHint?(o=4,h=Math.floor(r/4)):(o=2,h=Math.floor(r/2));const{labelPositions:n,minorTickLength:a,scale:l}=this;if(e>0)if(1===e&&n[1]-n[0]<r){let e=n[1];for(;e-n[0]>h+3*l;){e-=h;const r=Math.round(i+e)-.5*l;t.strokePath({path:new b(r,s).lineTo(r,s+a),color:this.foregroundColor,lineWidth:1*l,opacity:100/255})}}else if(e===n.length-1&&n[e]-n[e-1]<r){let r=n[e-1];for(;n[e]-r>h+3*l;){r+=h;const e=Math.round(i+r)-.5*l;t.strokePath({path:new b(e,s).lineTo(e,s+a),color:this.foregroundColor,lineWidth:1*l,opacity:100/255})}}else for(let r=0;r<o;r++){let h=i+n[e-1]+(n[e]-n[e-1])*r/o;h=Math.round(h)-.5*l,t.strokePath({path:new b(h,s).lineTo(h,s+a),color:this.foregroundColor,lineWidth:1*l,opacity:100/255})}}drawMinorYTicks(t,e,i,s){const{gridStepInPixel:r}=this;let o,h;r/5>=this.minorTickMarkStepHint?(o=5,h=Math.floor(r/5)):r/4>=this.minorTickMarkStepHint?(o=4,h=Math.floor(r/4)):(o=2,h=Math.floor(r/2));const{labelPositions:n,minorTickLength:a,majorTickLength:l,scale:d}=this;if(e>0)if(1===e&&n[1]-n[0]<r){let e=n[1];for(;e-n[0]>h+3*d;){e-=h;const r=Math.round(s-e)-.5*d;t.strokePath({path:new b(i+l-a,r).lineTo(i+l,r),color:this.foregroundColor,lineWidth:1*d,opacity:100/255})}}else if(e===n.length-1&&n[e]-n[e-1]<r){let r=n[e-1];for(;n[e]-r>h+3*d;){r+=h;const e=Math.round(s-r)-.5*d;t.strokePath({path:new b(i+l-a,e).lineTo(i+l,e),color:this.foregroundColor,lineWidth:1*d,opacity:100/255})}}else for(let r=0;r<o;r++){let h=s-n[e-1]-(n[e]-n[e-1])*r/o;h=Math.round(h)-.5*d,t.strokePath({path:new b(i+l-a,h).lineTo(i+l,h),color:this.foregroundColor,lineWidth:1*d,opacity:100/255})}}updateLabels(t,e){if(this.labels=[],this.labelValues=[],this.labelPositions=[],this.showScale)if(this.logScale)this.updateLabelsForLogScale(this.minimum,this.maximum,e);else{const t=this.getGridStep(e,this.minimum,this.maximum),i=Math.max(Math.abs(this.minimum),Math.abs(this.maximum)),s=this.maximum/i-this.minimum/i;this.gridStepInPixel=Math.floor(e*(t/i)/s),this.updateLabelsForLinearScale(this.minimum,this.maximum,e,t)}this.updateVisibility(t)}getGridStep(t,e,i){t<=0&&(t=1);let s=!1;if(e>=i)if(i===e)i++;else{s=!0;const t=e;e=i,i=t}const r=Math.abs(i-e);let o=this.majorTickStepHint;o>t&&(o=t);let h,n=r/t*o,a=0;if(n<1){if(0!=n)for(;n<1;)n*=10,a--}else for(;n>=10;)n/=10,a++;return h=n>7.5?10*Math.pow(10,a):n>3.5?5*Math.pow(10,a):n>1.5?2*Math.pow(10,a):Math.pow(10,a),s&&(h=-h),h}updateLabelsForLogScale(t,e,i){t<=0&&(t=.1),e<=t&&(e=t+100);const s=e<t,r=Math.log10(t),o=Math.ceil(r),h=Math.ceil(Math.log10(e));let n,a=Math.pow(10,o-1);n=t%a<=0||s?t-t%a:t-t%a+a,(s&&t>n||!s&&t<n)&&this.addMinMaxTickInfo(t,i,!0);for(let t=o;s?t>=h:t<=h;t+=s?-1:1)if(Math.abs(h-o)>20){const s=Math.pow(10,t);if(s>e)break;this.addTickInfo(s,e,r,i)}else{for(let o=n;(s?o>=Math.pow(10,t-1):o<=Math.pow(10,t))&&!(s?o<e:o>e);o=s?o-a:o+a)this.addTickInfo(o,e,r,i);a=s?a/Math.pow(10,1):a*Math.pow(10,1),n=s?Math.pow(10,t-1):a+Math.pow(10,t)}(s?e<this.labelValues[this.labelValues.length-1]:e>this.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,s){this.labels.push(this.format(t));const r=Math.floor((Math.log10(t)-i)/(Math.log10(e)-i)*s)+this.margin;this.labelPositions.push(r),this.labelValues.push(t)}updateLabelsForLinearScale(t,e,i,s){let r;r=t%s<=0?t-t%s:t-t%s+s,t>r==e<t&&(this.labelValues.push(t),this.labels.push(this.format(t)),this.labelPositions.push(this.margin));let o=1;const h=Math.max(Math.abs(t),Math.abs(e));s/=h,r/=h;const n=(e/=h)-(t/=h);for(let a=r;e>=t?a<e:a>e;a=r+o++*s){const e=a*h;this.labels.push(this.format(e)),this.labelValues.push(e);const s=Math.floor((a-t)/n*i)+this.margin;this.labelPositions.push(s)}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 t=0;t<this.labelPositions.length;t++)this.labelVisibilities.push(!0);let e=0,i=null;for(let s=0;s<this.labelPositions.length;s++){let r=!0;const o=this.labels[s],h=this.labelPositions[s];0!==s&&(r=this.hasSpaceToDraw(t,e,h,i||"",o));const n=o===i&&0!==s&&s!==this.labelPositions.length-1;let a=!0;if(this.logScale){const t=Number(this.labels[s]);a=this.isMajorTick(t)||0===s||s===this.labelPositions.length-1}r&&!n&&a?(e=h,i=o):this.labelVisibilities[s]=!1}}hasSpaceToDraw(t,e,i,s,r){const o=t.measureText(r,this.scaleFont),h=t.measureText(s,this.scaleFont);let n=i-e,a=Math.floor(this.horizontal?o.width/2+h.width/2:o.height),l=!0,d=!0;if(i!=this.labelPositions[this.labelPositions.length-1]){l=n>a+this.tickLabelGap;const e=t.measureText(this.labels[this.labels.length-1],this.scaleFont);n=this.labelPositions[this.labelPositions.length-1]-i,a=Math.floor(this.horizontal?o.width/2+e.width/2:o.height),d=n>a+this.tickLabelGap}return l&&d}isMajorTick(t){if(!this.logScale)return!0;const e=Math.log10(t);return e===Math.round(e)}format(t){if(0===this.timeFormat)return this.scaleFormat?new Lr(this.scaleFormat).format(t):String(Number(t.toFixed(2)));const e=new Date(t);switch(this.timeFormat){case 1:return this.formatDate(e,{year:!0,month:!0,day:!0})+"\n"+this.formatTime(e,{hours:!0,minutes:!0,seconds:!0,milliseconds:!1});case 2:return this.formatDate(e,{year:!0,month:!0,day:!0})+"\n"+this.formatTime(e,{hours:!0,minutes:!0,seconds:!0,milliseconds:!0});case 3:return this.formatTime(e,{hours:!0,minutes:!0,seconds:!0,milliseconds:!1});case 4:return this.formatTime(e,{hours:!0,minutes:!0,seconds:!0,milliseconds:!0});case 5:return this.formatTime(e,{hours:!0,minutes:!0,seconds:!1,milliseconds:!1});case 6:return this.formatDate(e,{year:!0,month:!0,day:!0});case 7:return`${so[e.getUTCMonth()]} ${e.getUTCDate()}`;case 8:const t=Math.abs(this.maximum-this.minimum);return t<=5e3?this.formatTime(e,{hours:!1,minutes:!1,seconds:!0,milliseconds:!0}):t<=18e5?this.formatTime(e,{hours:!0,minutes:!0,seconds:!0,milliseconds:!1}):t<=864e5?this.formatTime(e,{hours:!0,minutes:!0,seconds:!1,milliseconds:!1}):t<=6048e5?this.formatDate(e,{year:!1,month:!0,day:!0})+"\n"+this.formatTime(e,{hours:!0,minutes:!0,seconds:!1,milliseconds:!1}):t<=2592e6?this.formatDate(e,{year:!1,month:!0,day:!0}):this.formatDate(e,{year:!0,month:!0,day:!0})}return""}formatDate(t,e){let i="";if(e.year&&(i+=t.getUTCFullYear()),e.month){e.year&&(i+="-");const s=t.getUTCMonth();i+=(s<10?"0":"")+s}if(e.day){e.month&&(i+="-");const s=t.getUTCDate();i+=(s<10?"0":"")+s}return i}formatTime(t,e){let i="";if(e.hours){const e=t.getUTCHours();i+=(e<10?"0":"")+e}if(e.minutes){e.hours&&(i+=":");const s=t.getUTCMinutes();i+=(s<10?"0":"")+s}if(e.seconds){e.minutes&&(i+=":");const s=t.getUTCSeconds();i+=(s<10?"0":"")+s}if(e.milliseconds){e.seconds&&(i+=".");const s=t.getUTCMilliseconds();i+=(s<10?"00":s<100?"0":"")+s}return i}get spaceBetweenMarkAndLabel(){return 2*this.scale}get majorTickLength(){return 6*this.scale}get minorTickLength(){return 3*this.scale}get minorTickMarkStepHint(){return 4*this.scale}get tickLabelGap(){return 2*this.scale}}const oo="color_map",ho="crop_bottom",no="crop_left",ao="crop_right",lo="crop_top",co="data_height",po="data_width",go="font",uo="graph_area_height",mo="graph_area_width",xo="maximum",fo="minimum",wo="show_ramp",yo="x_axis_axis_color",vo="x_axis_axis_title",bo="x_axis_major_tick_step_hint",To="x_axis_maximum",So="x_axis_minimum",Vo="x_axis_scale_font",Ao="x_axis_show_minor_ticks",_o="x_axis_title_font",Lo="x_axis_visible",Co="y_axis_axis_color",Po="y_axis_axis_title",Mo="y_axis_major_tick_step_hint",ko="y_axis_maximum",Ro="y_axis_minimum",Eo="y_axis_scale_font",Wo="y_axis_show_minor_ticks",Bo="y_axis_title_font",Io="y_axis_visible";class Oo extends ge{constructor(t,e){super(t,e),this.properties.add(new Y(oo)),this.properties.add(new $(ho)),this.properties.add(new $(no)),this.properties.add(new $(ao)),this.properties.add(new $(lo)),this.properties.add(new $(co)),this.properties.add(new $(po)),this.properties.add(new $(uo)),this.properties.add(new $(mo)),this.properties.add(new q(go)),this.properties.add(new G(xo)),this.properties.add(new G(fo)),this.properties.add(new z(wo)),this.properties.add(new U(yo)),this.properties.add(new D(vo)),this.properties.add(new $(bo)),this.properties.add(new G(To)),this.properties.add(new G(So)),this.properties.add(new q(Vo)),this.properties.add(new z(Ao)),this.properties.add(new q(_o)),this.properties.add(new z(Lo)),this.properties.add(new U(Co)),this.properties.add(new D(Po)),this.properties.add(new $(Mo)),this.properties.add(new G(ko)),this.properties.add(new G(Ro)),this.properties.add(new q(Eo)),this.properties.add(new z(Wo)),this.properties.add(new q(Bo)),this.properties.add(new z(Io))}draw(t){const{scale:e}=this;let i=this.area;this.borderAlarmSensitive&&(i=d(i,2*e));const s=this.alarmSensitiveBackgroundColor;t.fillRect(Object.assign(Object.assign({},i),{color:s}));const{graphAreaWidth:r,graphAreaHeight:o}=this;this.xAxisVisible&&t.measureText(this.xAxisAxisTitle,this.xAxisTitleFont).height;let h=0;this.yAxisVisible&&(h=t.measureText(this.yAxisAxisTitle,this.yAxisTitleFont).height);const n=new ro(e,this.xAxisScaleFont,this.xAxisMinimum,this.xAxisMaximum,!1,this.xAxisMajorTickStepHint,this.xAxisAxisColor,this.xAxisShowMinorTicks,this.xAxisVisible),a=n.calculateMargin(t,!0),l=new ro(e,this.yAxisScaleFont,this.yAxisMinimum,this.yAxisMaximum,!1,this.yAxisMajorTickStepHint,this.yAxisAxisColor,this.yAxisShowMinorTicks,this.yAxisVisible),c=l.calculateMargin(t,!1),p=n.measureHorizontalHeight(t),g=o+2*c,u=l.drawVertical(t,i.x+h,i.y,g,!0),m=r+2*a,x=i.x+h+u-a,f=i.y+g+p-c;n.drawHorizontal(t,x,f,m);const w=1*e,y=Math.round(i.x+h+u)-w/2,v=Math.round(i.y+c)-w/2;t.strokePath({path:new b(y,v).lineTo(y,v+o),color:this.yAxisAxisColor,opacity:100/255,lineWidth:w});const T=y,S=v+o+w;t.strokePath({path:new b(T,S).lineTo(T+r,S),color:this.xAxisAxisColor,opacity:100/255,lineWidth:w});const{dataWidth:V,dataHeight:A,colorMap:_}=this,{minimum:L,maximum:C}=this,[P,M]=_.getMinMax();if(this.value&&this.value.length){const e=document.createElement("canvas"),{cropLeft:s,cropRight:n,cropTop:a,cropBottom:d}=this;e.width=V-s-n,e.height=A-a-d;const c=e.getContext("2d");for(let t=s;t<V-n;t++)for(let e=a;e<A-d;e++){let i=this.value[e*V+t];if(_.autoscale){i=P+(i-L)/(C-L)*(M-P)}const[r,o,h]=_.lookup(i);c.fillStyle=`rgb(${r},${o},${h})`,c.fillRect(t-s,e-a,1,1)}const p=Math.round(i.x+h+u),g=Math.round(i.y+l.margin);t.ctx.drawImage(e,p,g,r,o)}if(this.showRamp){const s=new ro(e,this.font,L,C,!1,50*e,this.alarmSensitiveForegroundColor,!1,!0),n=i.y+l.margin,a=o,d=s.drawVertical(t,i.x+i.width,n,a,!1,!0),c=i.x+h+u+r+this.gap,p=i.width-h-u-r-d-this.gap,g=a-2*s.margin,m=document.createElement("canvas");m.width=p,m.height=g;const x=m.getContext("2d");for(let t=0;t<g;t++){let e=C-t/g*(C-L);if(_.autoscale){e=P+(e-L)/(C-L)*(M-P)}const[i,s,r]=_.lookup(e);x.fillStyle=`rgb(${i},${s},${r})`,x.fillRect(0,t,p,1)}t.ctx.drawImage(m,c,n+s.margin)}if(this.xAxisVisible){let e=i.x+u+r/2;this.yAxisVisible&&(e+=h),t.fillText({x:e,y:i.y+i.height,align:"center",baseline:"bottom",font:this.xAxisTitleFont,color:this.xAxisAxisColor,text:this.xAxisAxisTitle})}this.yAxisVisible&&(t.ctx.save(),t.ctx.translate(i.x+h/2,i.y+g/2),t.ctx.rotate(-Math.PI/2),t.fillText({x:0,y:0,align:"center",baseline:"middle",font:this.yAxisTitleFont,color:this.yAxisAxisColor,text:this.yAxisAxisTitle}),t.ctx.restore())}get gap(){return 3*this.scale}get colorMap(){return this.properties.getValue(oo)}get cropBottom(){return this.properties.getValue(ho)}get cropLeft(){return this.properties.getValue(no)}get cropRight(){return this.properties.getValue(ao)}get cropTop(){return this.properties.getValue(lo)}get dataHeight(){return this.properties.getValue(co)}get dataWidth(){return this.properties.getValue(po)}get font(){return this.properties.getValue(go).scale(this.scale)}get graphAreaHeight(){return this.scale*this.properties.getValue(uo)}get graphAreaWidth(){return this.scale*this.properties.getValue(mo)}get maximum(){return this.properties.getValue(xo)}get minimum(){return this.properties.getValue(fo)}get showRamp(){return this.properties.getValue(wo)}get xAxisAxisColor(){return this.properties.getValue(yo)}get xAxisAxisTitle(){return this.properties.getValue(vo)}get xAxisMajorTickStepHint(){return this.scale*this.properties.getValue(bo)}get xAxisMaximum(){return this.properties.getValue(To)}get xAxisMinimum(){return this.properties.getValue(So)}get xAxisScaleFont(){return this.properties.getValue(Vo).scale(this.scale)}get xAxisShowMinorTicks(){return this.properties.getValue(Ao)}get xAxisTitleFont(){return this.properties.getValue(_o).scale(this.scale)}get xAxisVisible(){return this.properties.getValue(Lo)}get yAxisAxisColor(){return this.properties.getValue(Co)}get yAxisAxisTitle(){return this.properties.getValue(Po)}get yAxisMajorTickStepHint(){return this.scale*this.properties.getValue(Mo)}get yAxisMaximum(){return this.properties.getValue(ko)}get yAxisMinimum(){return this.properties.getValue(Ro)}get yAxisScaleFont(){return this.properties.getValue(Eo).scale(this.scale)}get yAxisShowMinorTicks(){return this.properties.getValue(Wo)}get yAxisTitleFont(){return this.properties.getValue(Bo).scale(this.scale)}get yAxisVisible(){return this.properties.getValue(Io)}}const Ho="data_type",Fo="effect_3d",No="state_count",Do="square_led",jo="off_color",$o="off_label",Go="font",zo="on_color",Uo="on_label",qo="bulb_border",Yo="bulb_border_color",Xo="state_color_fallback",Ko="state_label_fallback",Zo="show_boolean_label";class Jo extends ge{constructor(t,i){super(t,i),this.states=[],this.properties.add(new $("bit")),this.properties.add(new $(Ho)),this.properties.add(new z(Fo)),this.properties.add(new z(Do)),this.properties.add(new $(No,2)),this.properties.add(new U(jo)),this.properties.add(new D($o)),this.properties.add(new U(zo)),this.properties.add(new D(Uo)),this.properties.add(new q(Go)),this.properties.add(new z(Zo)),this.properties.add(new U(Xo)),this.properties.add(new D(Ko)),this.properties.add(new $(qo,3)),this.properties.add(new U(Yo,e.DARK_GRAY))}parseNode(t){if(super.parseNode(t),this.stateCount>2)for(let e=0;e<this.stateCount;e++){const i=new U(`state_color_${e}`);i.value=t.getColor(`state_color_${e}`),this.properties.add(i);const s=new D(`state_label_${e}`);s.value=t.getString(`state_label_${e}`),this.properties.add(s);const r=new G(`state_value_${e}`);r.value=t.getFloat(`state_value_${e}`),this.properties.add(r),this.states.push({label:this.properties.getValue(s.name),color:this.properties.getValue(i.name),value:this.properties.getValue(r.name)})}}init(){this.areaRegion={id:`${this.wuid}-area`,click:()=>{const t={pvName:this.pvName};this.display.fireEvent("openpv",t)},cursor:"pointer",tooltip:()=>this.tooltip}}get booleanValue(){var t,e,i;return 0===this.dataType?this.bit<0?Boolean(null===(t=this.pv)||void 0===t?void 0:t.toNumber()):void 0!==(null===(e=this.pv)||void 0===e?void 0:e.value)&&((null===(i=this.pv)||void 0===i?void 0:i.value)>>this.bit&1)>0:(this.dataType,!1)}get bulbColor(){var t;if(this.stateCount<=2)return this.booleanValue?this.onColor:this.offColor;for(const e of this.states)if(e.value===(null===(t=this.pv)||void 0===t?void 0:t.value))return e.color;return this.stateColorFallback}get label(){var t;if(2===this.stateCount)return this.booleanValue?this.onLabel:this.offLabel;for(const e of this.states)if(e.value===(null===(t=this.pv)||void 0===t?void 0:t.value))return e.label;return this.stateLabelFallback}draw(t){const e=d(this.bounds,3*this.scale);this.squareLed?this.effect3d?this.drawSquare3d(t,e):this.drawSquare2d(t,e):this.effect3d?this.drawCircle3d(t,e):this.drawCircle2d(t,e),this.showBooleanLabel&&t.fillText({x:e.x+e.width/2,y:e.y+e.height/2,font:this.font,baseline:"middle",align:"center",color:this.foregroundColor,text:this.label})}drawCircle2d(t,e){const i=e.x+e.width/2,s=e.y+e.height/2;let r=e.width/2,o=e.height/2;if(this.bulbBorder>0&&(r-=this.bulbBorder/2,o-=this.bulbBorder/2),t.fillEllipse({cx:i,cy:s,rx:r,ry:o,color:this.bulbColor}),t.strokeEllipse({cx:i,cy:s,rx:r,ry:o,color:this.bulbBorderColor,lineWidth:this.bulbBorder}),this.pv&&this.pv.navigable&&!this.pv.disconnected){t.addHitRegion(this.areaRegion).addEllipse(i,s,r,o,0,0,2*Math.PI)}}drawCircle3d(t,i){const s=i.x+i.width/2,r=i.y+i.height/2;let o=i.width/2,h=i.height/2;t.fillEllipse({cx:s,cy:r,rx:o,ry:h,color:e.WHITE});let n=t.createLinearGradient(i.x,i.y,i.x+i.width,i.y+i.height);n.addColorStop(0,this.bulbBorderColor.toString()),n.addColorStop(1,this.bulbBorderColor.withAlpha(0).toString()),t.fillEllipse({cx:s,cy:r,rx:o,ry:h,gradient:n});if(o=(i.width-2*this.bulbBorder)/2,h=(i.height-2*this.bulbBorder)/2,t.fillEllipse({cx:s,cy:r,rx:o,ry:h,color:this.bulbColor}),n=t.createLinearGradient(i.x,i.y,i.x+i.width,i.y+i.height),n.addColorStop(0,e.WHITE.toString()),n.addColorStop(1,this.bulbBorderColor.withAlpha(0).toString()),t.fillEllipse({cx:s,cy:r,rx:o,ry:h,gradient:n}),this.pv&&this.pv.navigable&&!this.pv.disconnected){t.addHitRegion(this.areaRegion).addEllipse(s,r,o,h,0,0,2*Math.PI)}}drawSquare2d(t,e){const i=a(e.x,e.y,e.width,e.height,this.bulbBorder);if(t.fillRect(Object.assign(Object.assign({},i),{color:this.bulbColor})),t.strokeRect(Object.assign(Object.assign({},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){if(t.fillRect(Object.assign(Object.assign({},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 b(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 b(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 b(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 b(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)});const s=e.x+this.bulbBorder,r=e.y+this.bulbBorder,o=e.width-2*this.bulbBorder,h=e.height-2*this.bulbBorder;t.fillRect({x:s,y:r,width:o,height:h,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:s,y:r,width:o,height:h,gradient:i})}get bit(){return this.properties.getValue("bit")}get dataType(){return this.properties.getValue(Ho)}get squareLed(){return this.properties.getValue(Do)}get showBooleanLabel(){return this.properties.getValue(Zo)}get font(){return this.properties.getValue(Go).scale(this.scale)}get effect3d(){return this.properties.getValue(Fo)}get stateCount(){return this.properties.getValue(No)}get bulbBorder(){return this.scale*this.properties.getValue(qo)}get bulbBorderColor(){return this.properties.getValue(Yo)}get offLabel(){return this.properties.getValue($o)}get offColor(){return this.properties.getValue(jo)}get onLabel(){return this.properties.getValue(Uo)}get onColor(){return this.properties.getValue(zo)}get stateLabelFallback(){return this.properties.getValue(Ko)}get stateColorFallback(){return this.properties.getValue(Xo)}}const Qo=u(45),th=(1-Math.sin(Qo)/2)/(2*Math.cos(Qo)),eh="color_hi",ih="color_hihi",sh="color_lo",rh="color_lolo",oh="font",hh="level_hi",nh="level_hihi",ah="level_lo",lh="level_lolo",dh="log_scale",ch="minimum",ph="maximum",gh="needle_color",uh="ramp_gradient",mh="scale_font",xh="show_hi",fh="show_hihi",wh="show_lo",yh="show_lolo",vh="show_ramp",bh="value_label_format";class Th extends ge{constructor(t,e){super(t,e),this.properties.add(new U(eh)),this.properties.add(new U(ih)),this.properties.add(new U(sh)),this.properties.add(new U(rh)),this.properties.add(new q(oh)),this.properties.add(new $(hh)),this.properties.add(new $(nh)),this.properties.add(new $(ah)),this.properties.add(new $(lh)),this.properties.add(new z(dh)),this.properties.add(new $(ph)),this.properties.add(new $(ch)),this.properties.add(new U(gh)),this.properties.add(new z(uh)),this.properties.add(new q(mh)),this.properties.add(new z(xh)),this.properties.add(new z(fh)),this.properties.add(new z(wh)),this.properties.add(new z(yh)),this.properties.add(new z(vh,!0)),this.properties.add(new D(bh))}init(){this.areaRegion={id:`${this.wuid}-area`,click:()=>{const t={pvName:this.pvName};this.display.fireEvent("openpv",t)},tooltip:()=>this.tooltip,cursor:"pointer"}}draw(t){if(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){const e=String(this.minimum),i=t.measureText(e,this.scaleFont),s=String(this.maximum),r=t.measureText(s,this.scaleFont),o=Math.max(i.width,r.width)/2;let h=this.height,n=this.width;h>th*(n-2*o)&&(h=Math.floor(th*(n-2*o)));const a=h/(1-Math.sin(Qo)/2),l={x:Math.floor(this.x-a*(1-Math.cos(Qo))+o),y:this.y,width:Math.floor(2*a),height:Math.floor(2*a)},{rampWidth:c}=this,p=d(l,l.width/4-c,l.height/4-c);p.width=Math.min(p.width,p.height),p.height=p.width;const g=new Cr(c,135,45);g.lolo=this.levelLoLo,g.loloColor=this.colorLoLo,g.showLoLo=!0,g.lo=this.levelLo,g.loColor=this.colorLo,g.showLo=!0,g.hi=this.levelHi,g.hiColor=this.colorHi,g.showHi=!0,g.hihi=this.levelHiHi,g.hihiColor=this.colorHiHi,g.showHiHi=!0,g.minimum=this.minimum,g.maximum=this.maximum,g.gradient=this.rampGradient,g.logScale=this.logScale,g.draw(t,l,p),this.drawNeedle(t,l,g);const u=W.ARIAL_12_BOLD.scale(this.scale);if(this.pv&&void 0!==this.pv.value){const e=this.format(this.pv.value),i=t.measureText(e,u);t.fillText({x:l.x+l.width/2-i.width/2,y:l.y+l.height/2-l.height/4-(g.getRadius()-l.height/4)/2-i.height/2,align:"left",baseline:"top",font:u,text:e,color:this.foregroundColor})}}drawNeedle(t,e,i){const s=e.x+e.width/2,r=e.y+e.height/2;let o;if(this.pv&&void 0!==this.pv.value){const t=i.getValueInRange(this.pv.value);o=360-i.getValuePosition(t),this.maximum>this.minimum?t>this.maximum?o+=8:t<this.minimum&&(o-=8):t>this.minimum?o-=8:t<this.maximum&&(o+=8)}else o=360-i.getValuePosition(this.minimum+this.maximum/2);const h=u(o),{needleWidth:n,gapBetweenNeedleScale:a,scale:d}=this,c=l(s+e.width/4,r-n/2+3*d,s,r,h),p=l(s+i.getRadius()-a,r,s,r,h),g=l(s+e.width/4,r+n/2-3*d,s,r,h);t.fillPath({color:this.needleColor,path:new b(c.x,c.y).lineTo(p.x,p.y).lineTo(g.x,g.y).closePath()})}get needleWidth(){return 16*this.scale}get gapBetweenNeedleScale(){return-5*this.scale}get rampWidth(){return 12*this.scale}format(t){return this.valueLabelFormat?new Lr(this.valueLabelFormat).format(t):String(Number(t.toFixed(3)))}get colorLo(){return this.properties.getValue(sh)}get colorLoLo(){return this.properties.getValue(rh)}get colorHi(){return this.properties.getValue(eh)}get colorHiHi(){return this.properties.getValue(ih)}get font(){return this.properties.getValue(oh).scale(this.scale)}get levelLo(){return this.properties.getValue(ah)}get levelLoLo(){return this.properties.getValue(lh)}get levelHi(){return this.properties.getValue(hh)}get levelHiHi(){return this.properties.getValue(nh)}get logScale(){return this.properties.getValue(dh)}get minimum(){return this.properties.getValue(ch)}get maximum(){return this.properties.getValue(ph)}get needleColor(){return this.properties.getValue(gh)}get rampGradient(){return this.properties.getValue(uh)}get scaleFont(){return this.properties.getValue(mh).scale(this.scale)}get showLo(){return this.properties.getValue(wh)}get showLoLo(){return this.properties.getValue(yh)}get showHi(){return this.properties.getValue(xh)}get showHiHi(){return this.properties.getValue(fh)}get showRamp(){return this.properties.getValue(vh)}get valueLabelFormat(){return this.properties.getValue(bh)}}const Sh="color_hi",Vh="color_hihi",Ah="color_lo",_h="color_lolo",Lh="color_fillbackground",Ch="effect_3d",Ph="fill_color",Mh="fillcolor_alarm_sensitive",kh="font",Rh="horizontal",Eh="indicator_mode",Wh="level_hi",Bh="level_hihi",Ih="level_lo",Oh="level_lolo",Hh="limits_from_pv",Fh="log_scale",Nh="maximum",Dh="major_tick_step_hint",jh="minimum",$h="origin",Gh="origin_ignored",zh="scale_font",Uh="scale_format",qh="show_hi",Yh="show_hihi",Xh="show_label",Kh="show_lo",Zh="show_lolo",Jh="show_markers",Qh="show_minor_ticks",tn="show_scale",en="transparent_background",sn="value_label_format";class rn extends ge{constructor(t,e){super(t,e),this.properties.add(new U(Sh)),this.properties.add(new U(Vh)),this.properties.add(new U(Ah)),this.properties.add(new U(_h)),this.properties.add(new U(Lh)),this.properties.add(new z(Ch)),this.properties.add(new U(Ph)),this.properties.add(new z(Mh,!1)),this.properties.add(new q(kh)),this.properties.add(new z(Rh)),this.properties.add(new z(Eh)),this.properties.add(new G(Wh)),this.properties.add(new G(Bh)),this.properties.add(new G(Ih)),this.properties.add(new G(Oh)),this.properties.add(new z(Hh)),this.properties.add(new z(Fh)),this.properties.add(new G(Nh)),this.properties.add(new G(Dh)),this.properties.add(new G(jh)),this.properties.add(new G($h,0)),this.properties.add(new z(Gh,!0)),this.properties.add(new q(zh)),this.properties.add(new D(Uh)),this.properties.add(new z(qh)),this.properties.add(new z(Yh)),this.properties.add(new z(Xh)),this.properties.add(new z(Kh)),this.properties.add(new z(Zh)),this.properties.add(new z(Jh)),this.properties.add(new z(Qh)),this.properties.add(new z(tn)),this.properties.add(new z(en)),this.properties.add(new D(sn))}draw(t){let e=this.area;this.borderAlarmSensitive&&(e=d(this.area,2*this.scale));const i=this.alarmSensitiveBackgroundColor;this.transparentBackground||t.fillRect(Object.assign(Object.assign({},e),{color:i})),this.horizontal?this.drawHorizontal(t,e):this.drawVertical(t,e)}drawVertical(t,e){const i=this.alarmSensitiveForegroundColor,s=new ro(this.scale,this.scaleFont,this.min,this.max,this.logScale,this.majorTickStepHint,i,this.showMinorTicks,this.showScale);s.scaleFormat=this.scaleFormat;const r=s.drawVertical(t,e.x,e.y,e.height,!0);let o=0;this.showMarkers&&(o=this.drawVerticalMarkers(t,s,e)),this.drawVerticalBar(t,s,{x:e.x+r,y:e.y+s.margin,width:e.width-r-o,height:e.height-2*s.margin})}drawVerticalMarkers(t,e,i){const{lolo:s,lo:r,hi:o,hihi:h}=this,n=W.ARIAL_9.scale(this.scale);let a=0;if(this.showLoLo&&void 0!==s){const e=t.measureText("LOLO",n);a=Math.max(a,e.width)}if(this.showLo&&void 0!==r){const e=t.measureText("LO",n);a=Math.max(a,e.width)}if(this.showHi&&void 0!==o){const e=t.measureText("HI",n);a=Math.max(a,e.width)}if(this.showHiHi&&void 0!==h){const e=t.measureText("HIHI",n);a=Math.max(a,e.width)}const l=i.x+i.width;if(this.showLoLo&&void 0!==s){const i=l-a-this.markerGap,r=Math.round(e.getValuePosition(s));t.strokePath({path:new b(i,r).lineTo(i-this.markerTickLength,r),color:this.colorLoLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:i+this.markerGap,y:r,text:"LOLO",align:"left",baseline:"middle",color:this.colorLoLo,font:n})}if(this.showLo&&void 0!==r){const i=l-a-this.markerGap,s=Math.round(e.getValuePosition(r));t.strokePath({path:new b(i,s).lineTo(i-this.markerTickLength,s),color:this.colorLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:i+this.markerGap,y:s,text:"LO",align:"left",baseline:"middle",color:this.colorLo,font:n})}if(this.showHi&&void 0!==o){const i=l-a-this.markerGap,s=Math.round(e.getValuePosition(o));t.strokePath({path:new b(i,s).lineTo(i-this.markerTickLength,s),color:this.colorHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:i+this.markerGap,y:s,text:"HI",align:"left",baseline:"middle",color:this.colorHi,font:n})}if(this.showHiHi&&void 0!==h){const i=l-a-this.markerGap,s=Math.round(e.getValuePosition(h));t.strokePath({path:new b(i,s).lineTo(i-this.markerTickLength,s),color:this.colorHiHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:i+this.markerGap,y:s,text:"HIHI",align:"left",baseline:"middle",color:this.colorHiHi,font:n})}return this.markerTickLength+this.markerGap+a}drawVerticalBar(t,i,s){var r;const{outlineWidth:o}=this;if(t.fillRect(Object.assign(Object.assign({},s),{color:this.colorFillbackground})),this.effect3d){const i=t.createLinearGradient(s.x,0,s.x+s.width,0);i.addColorStop(0,e.WHITE.toString()),i.addColorStop(1,this.colorFillbackground.withAlpha(0).toString()),t.fillRect(Object.assign(Object.assign({},s),{gradient:i}));const r=d(s,o/2);t.strokeRect(Object.assign(Object.assign({},r),{color:e.GRAY,lineWidth:o}))}const h=this.alarmSensitiveFillColor;if(this.indicatorMode){const r=Math.round(i.getValuePosition(this.getFillValue())),n=s.width,a=this.thumbBreadth,l=g([{x:0,y:a/2},{x:n/2,y:0},{x:n-1,y:a/2},{x:n/2,y:a}],s.x,r-a/2),d=b.fromPoints(l);if(this.effect3d){const{x:i,y:s}=l[0],{x:r,y:n}=l[2],a=t.createLinearGradient(i,s,r,n);a.addColorStop(0,e.WHITE.toString()),a.addColorStop(1,h.toString()),t.fillPath({path:d,gradient:a}),t.strokePath({path:d,color:e.GRAY,lineWidth:o})}else t.fillPath({path:d,color:h})}else{let r=this.originIgnored?this.min:this.origin,n=this.getFillValue();if(n<r){const t=r;r=n,n=t}const a=Math.round(i.getValuePosition(r)),l=Math.round(i.getValuePosition(n)),c=d(Object.assign(Object.assign({},s),{y:a,height:l-a}),o);if(t.fillRect(Object.assign(Object.assign({},c),{color:h})),this.effect3d){const i=t.createLinearGradient(c.x,0,c.x+c.width,0);i.addColorStop(0,e.WHITE.toString()),i.addColorStop(1,h.withAlpha(0).toString()),t.fillRect(Object.assign(Object.assign({},c),{gradient:i}))}}const n=null===(r=this.pv)||void 0===r?void 0:r.value;this.showLabel&&void 0!==n&&t.fillText({x:s.x+s.width/2,y:s.y+s.height/2,align:"center",baseline:"middle",color:this.alarmSensitiveForegroundColor,font:this.font,text:this.format(n)})}drawHorizontal(t,e){const i=this.alarmSensitiveForegroundColor,s=new ro(this.scale,this.scaleFont,this.min,this.max,this.logScale,this.majorTickStepHint,i,this.showMinorTicks,this.showScale);s.scaleFormat=this.scaleFormat;const r=s.drawHorizontal(t,e.x,e.y+e.height,e.width);let o=0;this.showMarkers&&(o=this.drawHorizontalMarkers(t,s,e)),this.drawHorizontalBar(t,s,{x:e.x+s.margin,y:e.y+o,width:e.width-2*s.margin,height:e.height-r-o})}drawHorizontalMarkers(t,e,i){const{lolo:s,lo:r,hi:o,hihi:h}=this,n=W.ARIAL_9.scale(this.scale);let a=0;if(this.showLoLo&&void 0!==s){const e=t.measureText("LOLO",n);a=Math.max(a,e.height)}if(this.showLo&&void 0!==r){const e=t.measureText("LO",n);a=Math.max(a,e.height)}if(this.showHi&&void 0!==o){const e=t.measureText("HI",n);a=Math.max(a,e.height)}if(this.showHiHi&&void 0!==h){const e=t.measureText("HIHI",n);a=Math.max(a,e.height)}const l=i.y;if(this.showLoLo&&void 0!==s){const i=Math.round(e.getValuePosition(s)),r=l+a+this.markerGap;t.strokePath({path:new b(i,r).lineTo(i,r+this.markerTickLength),color:this.colorLoLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:i,y:l,text:"LOLO",align:"center",baseline:"top",color:this.colorLoLo,font:n})}if(this.showLo&&void 0!==r){const i=Math.round(e.getValuePosition(r)),s=l+a+this.markerGap;t.strokePath({path:new b(i,s).lineTo(i,s+this.markerTickLength),color:this.colorLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:i,y:l,text:"LO",align:"center",baseline:"top",color:this.colorLo,font:n})}if(this.showHi&&void 0!==o){const i=Math.round(e.getValuePosition(o)),s=l+a+this.markerGap;t.strokePath({path:new b(i,s).lineTo(i,s+this.markerTickLength),color:this.colorHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:i,y:l,text:"HI",align:"center",baseline:"top",color:this.colorHi,font:n})}if(this.showHiHi&&void 0!==h){const i=Math.round(e.getValuePosition(h)),s=l+a+this.markerGap;t.strokePath({path:new b(i,s).lineTo(i,s+this.markerTickLength),color:this.colorHiHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:i,y:l,text:"HIHI",align:"center",baseline:"top",color:this.colorHiHi,font:n})}return this.markerTickLength+this.markerGap+a}drawHorizontalBar(t,i,s){var r;const{outlineWidth:o}=this;if(t.fillRect(Object.assign(Object.assign({},s),{color:this.colorFillbackground})),this.effect3d){const i=t.createLinearGradient(0,s.y,0,s.y+s.height);i.addColorStop(0,e.WHITE.toString()),i.addColorStop(1,this.colorFillbackground.withAlpha(0).toString()),t.fillRect(Object.assign(Object.assign({},s),{gradient:i}));const r=d(s,o/2);t.strokeRect(Object.assign(Object.assign({},r),{color:e.GRAY,lineWidth:o}))}const h=this.alarmSensitiveFillColor;if(this.indicatorMode){const r=Math.round(i.getValuePosition(this.getFillValue())),n=s.height,a=this.thumbBreadth,l=g([{x:a/2,y:0},{x:a,y:n/2},{x:a/2,y:n-1},{x:0,y:n/2}],r-a/2,s.y),d=b.fromPoints(l);if(this.effect3d){const{x:i,y:s}=l[0],{x:r,y:n}=l[2],a=t.createLinearGradient(i,s,r,n);a.addColorStop(0,e.WHITE.toString()),a.addColorStop(1,h.toString()),t.fillPath({path:d,gradient:a}),t.strokePath({path:d,color:e.GRAY,lineWidth:o})}else t.fillPath({path:d,color:h})}else{let r=this.originIgnored?this.min:this.origin,n=this.getFillValue();if(n<r){const t=r;r=n,n=t}const a=Math.round(i.getValuePosition(r)),l=Math.round(i.getValuePosition(n)),c=d(Object.assign(Object.assign({},s),{x:a,width:l-a}),o);if(t.fillRect(Object.assign(Object.assign({},c),{color:h})),this.effect3d){const i=t.createLinearGradient(0,c.y,0,c.y+c.height);i.addColorStop(0,e.WHITE.toString()),i.addColorStop(1,h.withAlpha(0).toString()),t.fillRect(Object.assign(Object.assign({},c),{gradient:i}))}}const n=null===(r=this.pv)||void 0===r?void 0:r.value;this.showLabel&&void 0!==n&&t.fillText({x:s.x+s.width/2,y:s.y+s.height/2,align:"center",baseline:"middle",color:this.alarmSensitiveForegroundColor,font:this.font,text:this.format(n)})}get min(){var t,e;return this.limitsFromPv&&null!==(e=null===(t=this.pv)||void 0===t?void 0:t.lowerDisplayLimit)&&void 0!==e?e:this.minimum}get max(){var t,e;return this.limitsFromPv&&null!==(e=null===(t=this.pv)||void 0===t?void 0:t.upperDisplayLimit)&&void 0!==e?e:this.maximum}get lolo(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.lowerAlarmLimit:this.levelLoLo}get lo(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.lowerWarningLimit:this.levelLo}get hi(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.upperWarningLimit:this.levelHi}get hihi(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.upperAlarmLimit:this.levelHiHi}get markerTickLength(){return 10*this.scale}get markerTickLineWidth(){return 2*this.scale}get markerGap(){return 3*this.scale}get thumbBreadth(){return 13*this.scale}get outlineWidth(){return 1*this.scale}get alarmSensitiveFillColor(){if(this.fillColorAlarmSensitive){if(this.isMajorSeverity())return e.RED;if(this.isMinorSeverity())return e.ORANGE}return this.fillColor}getFillValue(){var t,e;let i=null!==(e=null===(t=this.pv)||void 0===t?void 0:t.value)&&void 0!==e?e:this.min;return i=Math.max(this.min,i),i=Math.min(this.max,i),i}format(t){return this.valueLabelFormat?new Lr(this.valueLabelFormat).format(t):String(Number(t.toFixed(2)))}get colorLo(){return this.properties.getValue(Ah)}get colorLoLo(){return this.properties.getValue(_h)}get colorHi(){return this.properties.getValue(Sh)}get colorHiHi(){return this.properties.getValue(Vh)}get colorFillbackground(){return this.properties.getValue(Lh)}get effect3d(){return this.properties.getValue(Ch)}get fillColorAlarmSensitive(){return this.properties.getValue(Mh)}get fillColor(){return this.properties.getValue(Ph)}get font(){return this.properties.getValue(kh).scale(this.scale)}get horizontal(){return this.properties.getValue(Rh)}get indicatorMode(){return this.properties.getValue(Eh)}get levelLo(){return this.properties.getValue(Ih)}get levelLoLo(){return this.properties.getValue(Oh)}get levelHi(){return this.properties.getValue(Wh)}get levelHiHi(){return this.properties.getValue(Bh)}get limitsFromPv(){return this.properties.getValue(Hh)}get logScale(){return this.properties.getValue(Fh)}get minimum(){return this.properties.getValue(jh)}get majorTickStepHint(){return this.scale*this.properties.getValue(Dh)}get maximum(){return this.properties.getValue(Nh)}get origin(){return this.properties.getValue($h)}get originIgnored(){return this.properties.getValue(Gh)}get scaleFont(){return this.properties.getValue(zh).scale(this.scale)}get scaleFormat(){return this.properties.getValue(Uh)}get showHi(){return this.properties.getValue(qh)}get showHiHi(){return this.properties.getValue(Yh)}get showLabel(){return this.properties.getValue(Xh)}get showLo(){return this.properties.getValue(Kh)}get showLoLo(){return this.properties.getValue(Zh)}get showMarkers(){return this.properties.getValue(Jh)}get showMinorTicks(){return this.properties.getValue(Qh)}get showScale(){return this.properties.getValue(tn)}get transparentBackground(){return this.properties.getValue(en)}get valueLabelFormat(){return this.properties.getValue(sn)}}const on="color_hi",hn="color_hihi",nn="color_lo",an="color_lolo",ln="color_fillbackground",dn="fill_color",cn="fillcolor_alarm_sensitive",pn="effect_3d",gn="level_hi",un="level_hihi",mn="level_lo",xn="level_lolo",fn="limits_from_pv",wn="log_scale",yn="maximum",vn="major_tick_step_hint",bn="minimum",Tn="scale_font",Sn="scale_format",Vn="show_hi",An="show_hihi",_n="show_lo",Ln="show_lolo",Cn="show_markers",Pn="show_minor_ticks",Mn="show_scale",kn="transparent_background",Rn=new e(160,160,160);class En extends ge{constructor(t,e){super(t,e),this.properties.add(new U(on)),this.properties.add(new U(hn)),this.properties.add(new U(nn)),this.properties.add(new U(an)),this.properties.add(new U(ln)),this.properties.add(new z(pn)),this.properties.add(new U(dn)),this.properties.add(new z(cn,!1)),this.properties.add(new G(gn)),this.properties.add(new G(un)),this.properties.add(new G(mn)),this.properties.add(new G(xn)),this.properties.add(new z(fn)),this.properties.add(new z(wn)),this.properties.add(new G(yn)),this.properties.add(new G(vn)),this.properties.add(new G(bn)),this.properties.add(new q(Tn)),this.properties.add(new D(Sn)),this.properties.add(new z(Vn)),this.properties.add(new z(An)),this.properties.add(new z(_n)),this.properties.add(new z(Ln)),this.properties.add(new z(Cn)),this.properties.add(new z(Pn)),this.properties.add(new z(Mn)),this.properties.add(new z(kn))}draw(t){const{scale:e,min:i,max:s}=this;let r=this.area;this.borderAlarmSensitive&&(r=d(r,2*e));const o=this.alarmSensitiveBackgroundColor;this.transparentBackground||t.fillRect(Object.assign(Object.assign({},r),{color:o}));const h=this.alarmSensitiveForegroundColor,n=new ro(e,this.scaleFont,i,s,this.logScale,this.majorTickStepHint,h,this.showMinorTicks,this.showScale);n.scaleFormat=this.scaleFormat;const a=n.drawVertical(t,r.x,r.y,r.height,!0);let l=0;this.showMarkers&&(l=this.drawMarkers(t,r,n)),this.drawTank(t,r,a,l,n)}drawMarkers(t,e,i){const{lolo:s,lo:r,hi:o,hihi:h}=this,n=W.ARIAL_9.scale(this.scale);let a=0;if(this.showLoLo&&void 0!==s){const e=t.measureText("LOLO",n);a=Math.max(a,e.width)}if(this.showLo&&void 0!==r){const e=t.measureText("LO",n);a=Math.max(a,e.width)}if(this.showHi&&void 0!==o){const e=t.measureText("HI",n);a=Math.max(a,e.width)}if(this.showHiHi&&void 0!==h){const e=t.measureText("HIHI",n);a=Math.max(a,e.width)}const l=e.x+e.width-a-this.markerGap-this.markerTickLength;if(this.showLoLo&&void 0!==s){const e=Math.round(i.getValuePosition(s));t.strokePath({path:new b(l,e).lineTo(l+this.markerTickLength,e),color:this.colorLoLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:l+this.markerTickLength+this.markerGap,y:e,text:"LOLO",align:"left",baseline:"middle",color:this.colorLoLo,font:n})}if(this.showLo&&void 0!==r){const e=Math.round(i.getValuePosition(r));t.strokePath({path:new b(l,e).lineTo(l+this.markerTickLength,e),color:this.colorLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:l+this.markerTickLength+this.markerGap,y:e,text:"LO",align:"left",baseline:"middle",color:this.colorLo,font:n})}if(this.showHi&&void 0!==o){const e=Math.round(i.getValuePosition(o));t.strokePath({path:new b(l,e).lineTo(l+this.markerTickLength,e),color:this.colorHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:l+this.markerTickLength+this.markerGap,y:e,text:"HI",align:"left",baseline:"middle",color:this.colorHi,font:n})}if(this.showHiHi&&void 0!==h){const e=Math.round(i.getValuePosition(h));t.strokePath({path:new b(l,e).lineTo(l+this.markerTickLength,e),color:this.colorHiHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:l+this.markerTickLength+this.markerGap,y:e,text:"HIHI",align:"left",baseline:"middle",color:this.colorHiHi,font:n})}return this.markerTickLength+this.markerGap+a}drawTank(t,i,s,r,o){const h=this.alarmSensitiveForegroundColor,{scale:n,outlineWidth:a}=this,l=i.x+s,c=i.y+o.margin,p=i.width-s-r,g=i.height-2*o.margin;let u=this.defaultCorner,m=.55;p<2*u&&(m=.6);const x=Math.floor(p*m);u>2*x-p-2*a&&(u=2*x-p);const f=o.getValuePosition(this.getFillValue()),w=this.alarmSensitiveFillColor;if(this.effect3d){t.fillRect({x:l,y:c,width:p,height:g,rx:u/2,ry:u/2,color:e.WHITE});let i=t.createLinearGradient(l,c,l+x+2*n,c);i.addColorStop(0,this.colorFillbackground.toString()),i.addColorStop(1,e.WHITE.withAlpha(0).toString()),t.fillRect({x:l,y:c,width:x,height:g,rx:u/2,ry:u/2,gradient:i}),i=t.createLinearGradient(l+p-x-2*n,c,l+p,c),i.addColorStop(0,e.WHITE.withAlpha(0).toString()),i.addColorStop(1,this.colorFillbackground.toString()),t.fillRect({x:l+p-x,y:c,width:x,height:g,rx:u/2,ry:u/2,gradient:i});const s=f,r=c+g-f;i=t.createLinearGradient(l,s,l+x+2*n,s),i.addColorStop(0,w.toString()),i.addColorStop(1,e.WHITE.withAlpha(0).toString()),t.fillRect({x:l,y:s,width:x,height:r,rx:u/2,ry:u/2,gradient:i}),i=t.createLinearGradient(l+p-x-2*n,s,l+p,s),i.addColorStop(0,e.WHITE.withAlpha(0).toString()),i.addColorStop(1,w.toString()),t.fillRect({x:l+p-x,y:s,width:x,height:r,rx:u/2,ry:u/2,gradient:i})}else t.fillRect({x:l,y:c,width:p,height:g,rx:u/2,ry:u/2,color:this.colorFillbackground}),t.fillRect({x:l,y:f,width:p,height:c+g-f,rx:u/2,ry:u/2,color:w});let y=d({x:l,y:c,width:p,height:g},a/2);t.strokeRect(Object.assign(Object.assign({},y),{rx:u/2,ry:u/2,color:this.effect3d?Rn:h,lineWidth:a}))}get min(){var t,e;return this.limitsFromPv&&null!==(e=null===(t=this.pv)||void 0===t?void 0:t.lowerDisplayLimit)&&void 0!==e?e:this.minimum}get max(){var t,e;return this.limitsFromPv&&null!==(e=null===(t=this.pv)||void 0===t?void 0:t.upperDisplayLimit)&&void 0!==e?e: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 15*this.scale}get markerTickLength(){return 10*this.scale}get markerTickLineWidth(){return 2*this.scale}get markerGap(){return 3*this.scale}get outlineWidth(){return 1*this.scale}get alarmSensitiveFillColor(){if(this.fillColorAlarmSensitive){if(this.isMajorSeverity())return e.RED;if(this.isMinorSeverity())return e.ORANGE}return this.fillColor}getFillValue(){var t,e;let i=null!==(e=null===(t=this.pv)||void 0===t?void 0:t.value)&&void 0!==e?e:this.min;return i=Math.max(this.min,i),i=Math.min(this.max,i),i}get colorLo(){return this.properties.getValue(nn)}get colorLoLo(){return this.properties.getValue(an)}get colorHi(){return this.properties.getValue(on)}get colorHiHi(){return this.properties.getValue(hn)}get colorFillbackground(){return this.properties.getValue(ln)}get fillColorAlarmSensitive(){return this.properties.getValue(cn)}get fillColor(){return this.properties.getValue(dn)}get effect3d(){return this.properties.getValue(pn)}get levelLo(){return this.properties.getValue(mn)}get levelLoLo(){return this.properties.getValue(xn)}get levelHi(){return this.properties.getValue(gn)}get levelHiHi(){return this.properties.getValue(un)}get limitsFromPv(){return this.properties.getValue(fn)}get logScale(){return this.properties.getValue(wn)}get minimum(){return this.properties.getValue(bn)}get majorTickStepHint(){return this.scale*this.properties.getValue(vn)}get maximum(){return this.properties.getValue(yn)}get scaleFont(){return this.properties.getValue(Tn).scale(this.scale)}get scaleFormat(){return this.properties.getValue(Sn)}get showLo(){return this.properties.getValue(_n)}get showLoLo(){return this.properties.getValue(Ln)}get showHi(){return this.properties.getValue(Vn)}get showHiHi(){return this.properties.getValue(An)}get showMarkers(){return this.properties.getValue(Cn)}get showMinorTicks(){return this.properties.getValue(Pn)}get showScale(){return this.properties.getValue(Mn)}get transparentBackground(){return this.properties.getValue(kn)}}const Wn="font",Bn="format_type",In="horizontal_alignment",On="precision",Hn="precision_from_pv",Fn="vertical_alignment";class Nn extends ge{constructor(t,e){super(t,e),this.properties.add(new q(Wn)),this.properties.add(new $(Bn)),this.properties.add(new $(In)),this.properties.add(new $(On)),this.properties.add(new z(Hn)),this.properties.add(new $(Fn))}init(){this.areaRegion={id:`${this.wuid}-area`,click:()=>{const t={pvName:this.pvName};this.display.fireEvent("openpv",t)},tooltip:()=>this.tooltip,cursor:"pointer"}}draw(t){const e=t.ctx;if(this.transparent?this.backgroundAlarmSensitive&&this.alarm&&t.fillRect(Object.assign(Object.assign({},this.area),{color:this.alarmSensitiveBackgroundColor})):t.fillRect(Object.assign(Object.assign({},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();const{scale:i}=this;let s=this.area;this.borderAlarmSensitive&&(s=d(s,2*i,2*i));let r=s.x;0===this.horizAlignment?e.textAlign="start":1===this.horizAlignment?(r+=s.width/2,e.textAlign="center"):2===this.horizAlignment&&(r+=s.width,e.textAlign="end");let o=s.y;0===this.vertAlignment?e.textBaseline="top":1===this.vertAlignment?(o+=s.height/2,e.textBaseline="middle"):2===this.vertAlignment&&(o+=s.height,e.textBaseline="bottom");let h=this.text;if(this.pv&&void 0!==this.pv.value){const t=this.precisionFromPV?this.pv.precision:this.precision;h=this.pv.formatValue(this.formatType,t)}e.fillText(h,r,o)}get font(){return this.properties.getValue(Wn).scale(this.scale)}get formatType(){return this.properties.getValue(Bn)}get horizAlignment(){return this.properties.getValue(In)}get precision(){return this.properties.getValue(On)}get precisionFromPV(){return this.properties.getValue(Hn)}get vertAlignment(){return this.properties.getValue(Fn)}}const Dn="color_hi",jn="color_hihi",$n="color_lo",Gn="color_lolo",zn="color_fillbackground",Un="fill_color",qn="fillcolor_alarm_sensitive",Yn="font",Xn="effect_3d",Kn="level_hi",Zn="level_hihi",Jn="level_lo",Qn="level_lolo",ta="limits_from_pv",ea="log_scale",ia="maximum",sa="major_tick_step_hint",ra="minimum",oa="scale_font",ha="scale_format",na="show_bulb",aa="show_hi",la="show_hihi",da="show_lo",ca="show_lolo",pa="show_markers",ga="show_minor_ticks",ua="show_scale",ma="transparent_background",xa="unit",fa="value_label_format",wa=new e(160,160,160);class ya extends ge{constructor(t,e){super(t,e),this.properties.add(new U(Dn)),this.properties.add(new U(jn)),this.properties.add(new U($n)),this.properties.add(new U(Gn)),this.properties.add(new U(zn)),this.properties.add(new U(Un)),this.properties.add(new z(qn,!1)),this.properties.add(new z(Xn)),this.properties.add(new G(Kn)),this.properties.add(new G(Zn)),this.properties.add(new G(Jn)),this.properties.add(new G(Qn)),this.properties.add(new z(ta)),this.properties.add(new q(Yn)),this.properties.add(new z(ea)),this.properties.add(new G(ia)),this.properties.add(new G(sa)),this.properties.add(new G(ra)),this.properties.add(new q(oa)),this.properties.add(new D(ha)),this.properties.add(new z(na)),this.properties.add(new z(aa)),this.properties.add(new z(la)),this.properties.add(new z(da)),this.properties.add(new z(ca)),this.properties.add(new z(pa)),this.properties.add(new z(ga)),this.properties.add(new z(ua)),this.properties.add(new z(ma)),this.properties.add(new $(xa)),this.properties.add(new D(fa))}draw(t){var i;const{scale:s,min:r,max:o}=this;let h=this.area;this.borderAlarmSensitive&&(h=d(this.area,2*this.scale));const n=this.alarmSensitiveBackgroundColor,a=this.alarmSensitiveForegroundColor,l=this.alarmSensitiveFillColor;this.transparentBackground||t.fillRect(Object.assign(Object.assign({},h),{color:n}));let c=h.height;if(this.showBulb){let t=Math.min(h.width/2,this.bulbMaxDiameter);c=h.height<t?0:h.height-t}let p=Object.assign(Object.assign({},h),{height:c});const g=new ro(s,this.scaleFont,r,o,this.logScale,this.majorTickStepHint,a,this.showMinorTicks,this.showScale);g.scaleFormat=this.scaleFormat;let u=0,m="";if(0===this.unit?m="°C":1===this.unit?m="°F":2===this.unit&&(m="K"),m){const e=W.ARIAL_9.scale(s),i=2*s;u=t.measureText(m,e).height+2*i,t.fillText({x:h.x+h.width/2-this.pipeWidth/2-i,y:h.y+i,baseline:"top",align:"right",color:a,font:e,text:m})}const x=p.x+p.width/2-this.pipeWidth/2-1*s,f=Object.assign(Object.assign({},p),{y:p.y+u,height:p.height-u+g.calculateMargin(t,!1)});g.drawVertical(t,x,f.y,f.height,!1);const w=Math.floor(this.pipeWidth/2);if(p=Object.assign(Object.assign({},p),{y:g.getValuePosition(o)-w,height:g.scaleLength+2*w}),this.drawPipe(t,p,g),this.showMarkers&&this.drawMarkers(t,h,g),this.showBulb){let o=Math.min(h.width/2,this.bulbMaxDiameter);const n=1*s,d=h.x+h.width/2,u=h.y+c+o/2,m=o/2,x=o/2;if(t.fillEllipse({cx:d,cy:u,rx:m,ry:x,color:l}),this.effect3d){const i=t.createLinearGradient(d-m,u-x,d+m,u+x);i.addColorStop(0,e.WHITE.toString()),i.addColorStop(1,l.withAlpha(0).toString()),t.fillEllipse({cx:d,cy:u,rx:m,ry:x,gradient:i})}t.strokeEllipse({cx:d,cy:u,rx:m-n/2,ry:x-n/2,color:this.effect3d?wa:a,lineWidth:n});const f={x:Math.round(p.x+p.width/2-this.pipeWidth/2)+this.outlineWidth,y:Math.floor(g.getValuePosition(r)),width:this.pipeWidth-2*this.outlineWidth,height:3*s};if(this.effect3d){const i=Math.round(p.x+p.width/2-this.pipeWidth/2),s=i+this.pipeWidth,r=t.createLinearGradient(i,f.y,s,f.y);r.addColorStop(0,e.WHITE.toString()),r.addColorStop(1,l.toString()),t.fillRect(Object.assign(Object.assign({},f),{gradient:r}))}else t.fillRect(Object.assign(Object.assign({},f),{color:l}));const w=null===(i=this.pv)||void 0===i?void 0:i.value;w&&t.fillText({x:d,y:u,align:"center",baseline:"middle",color:l.contrast(),font:this.font,text:this.format(w)})}}drawPipe(t,i,s){const{scale:r,outlineWidth:o,min:h,max:n}=this,a=this.alarmSensitiveForegroundColor,l=this.alarmSensitiveFillColor,c={x:Math.round(i.x+i.width/2-this.pipeWidth/2),y:i.y,width:this.pipeWidth,height:i.height},p=this.getFillValue();let g=s.getValuePosition(p);n>h?p>n?g-=10*r:p<h&&(g+=10*r):p>h?g+=10*r:p<n&&(g-=10*r);const u=this.pipeWidth/2,{x:m,y:x,width:f,height:w}=c;if(this.effect3d){let i=t.createLinearGradient(m,x,m+f,x);i.addColorStop(0,e.WHITE.toString()),i.addColorStop(1,this.colorFillbackground.toString()),t.fillRect(Object.assign(Object.assign({},c),{rx:u/2,ry:u/2,gradient:i})),i=t.createLinearGradient(m,x,m+f,x),i.addColorStop(0,e.WHITE.toString()),i.addColorStop(1,l.toString()),t.fillRect({x:m,y:g,width:f,height:x+w-g,rx:u/2,ry:u/2,gradient:i})}else t.fillRect(Object.assign(Object.assign({},c),{rx:u/2,ry:u/2,color:this.colorFillbackground})),t.fillRect({x:m,y:g,width:f,height:x+w-g,rx:u/2,ry:u/2,color:l});let y=d(c,o/2);t.strokeRect(Object.assign(Object.assign({},y),{rx:u/2,ry:u/2,color:this.effect3d?wa:a,lineWidth:o}))}drawMarkers(t,e,i){const{lolo:s,lo:r,hi:o,hihi:h}=this,n=W.ARIAL_9.scale(this.scale),a=e.x+e.width/2+this.pipeWidth/2;if(this.showLoLo&&void 0!==s){const e=Math.round(i.getValuePosition(s));t.strokePath({path:new b(a,e).lineTo(a+this.markerTickLength,e),color:this.colorLoLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:a+this.markerTickLength+this.markerGap,y:e,text:"LOLO",align:"left",baseline:"middle",color:this.colorLoLo,font:n})}if(this.showLo&&void 0!==r){const e=Math.round(i.getValuePosition(r));t.strokePath({path:new b(a,e).lineTo(a+this.markerTickLength,e),color:this.colorLo,lineWidth:this.markerTickLineWidth}),t.fillText({x:a+this.markerTickLength+this.markerGap,y:e,text:"LO",align:"left",baseline:"middle",color:this.colorLo,font:n})}if(this.showHi&&void 0!==o){const e=Math.round(i.getValuePosition(o));t.strokePath({path:new b(a,e).lineTo(a+this.markerTickLength,e),color:this.colorHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:a+this.markerTickLength+this.markerGap,y:e,text:"HI",align:"left",baseline:"middle",color:this.colorHi,font:n})}if(this.showHiHi&&void 0!==h){const e=Math.round(i.getValuePosition(h));t.strokePath({path:new b(a,e).lineTo(a+this.markerTickLength,e),color:this.colorHiHi,lineWidth:this.markerTickLineWidth}),t.fillText({x:a+this.markerTickLength+this.markerGap,y:e,text:"HIHI",align:"left",baseline:"middle",color:this.colorHiHi,font:n})}}get min(){var t,e;return this.limitsFromPv&&null!==(e=null===(t=this.pv)||void 0===t?void 0:t.lowerDisplayLimit)&&void 0!==e?e:this.minimum}get max(){var t,e;return this.limitsFromPv&&null!==(e=null===(t=this.pv)||void 0===t?void 0:t.upperDisplayLimit)&&void 0!==e?e:this.maximum}get lolo(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.lowerAlarmLimit:this.levelLoLo}get lo(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.lowerWarningLimit:this.levelLo}get hi(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.upperWarningLimit:this.levelHi}get hihi(){return this.limitsFromPv&&this.pv&&!this.pv.disconnected?this.pv.upperAlarmLimit:this.levelHiHi}get pipeWidth(){return 15*this.scale}get bulbMaxDiameter(){return 40*this.scale}get outlineWidth(){return 1*this.scale}get markerTickLength(){return 10*this.scale}get markerTickLineWidth(){return 2*this.scale}get markerGap(){return 3*this.scale}get alarmSensitiveFillColor(){if(this.fillColorAlarmSensitive){if(this.isMajorSeverity())return e.RED;if(this.isMinorSeverity())return e.ORANGE}return this.fillColor}getFillValue(){var t,e;let i=null!==(e=null===(t=this.pv)||void 0===t?void 0:t.value)&&void 0!==e?e:this.min;return i=Math.max(this.min,i),i=Math.min(this.max,i),i}format(t){return this.valueLabelFormat?new Lr(this.valueLabelFormat).format(t):String(Number(t.toFixed(3)))}get colorLo(){return this.properties.getValue($n)}get colorLoLo(){return this.properties.getValue(Gn)}get colorHi(){return this.properties.getValue(Dn)}get colorHiHi(){return this.properties.getValue(jn)}get colorFillbackground(){return this.properties.getValue(zn)}get fillColorAlarmSensitive(){return this.properties.getValue(qn)}get fillColor(){return this.properties.getValue(Un)}get font(){return this.properties.getValue(Yn).scale(this.scale)}get effect3d(){return this.properties.getValue(Xn)}get levelLo(){return this.properties.getValue(Jn)}get levelLoLo(){return this.properties.getValue(Qn)}get levelHi(){return this.properties.getValue(Kn)}get levelHiHi(){return this.properties.getValue(Zn)}get limitsFromPv(){return this.properties.getValue(ta)}get logScale(){return this.properties.getValue(ea)}get minimum(){return this.properties.getValue(ra)}get majorTickStepHint(){return this.scale*this.properties.getValue(sa)}get maximum(){return this.properties.getValue(ia)}get scaleFont(){return this.properties.getValue(oa).scale(this.scale)}get scaleFormat(){return this.properties.getValue(ha)}get showBulb(){return this.properties.getValue(na)}get showMarkers(){return this.properties.getValue(pa)}get showMinorTicks(){return this.properties.getValue(ga)}get showLo(){return this.properties.getValue(da)}get showLoLo(){return this.properties.getValue(ca)}get showHi(){return this.properties.getValue(aa)}get showHiHi(){return this.properties.getValue(la)}get showScale(){return this.properties.getValue(ua)}get transparentBackground(){return this.properties.getValue(ma)}get unit(){return this.properties.getValue(xa)}get valueLabelFormat(){return this.properties.getValue(fa)}}const va=-323.3062,ba=308.2547;class Ta{constructor(t,e){this.widget=t,this.index=e}get scale(){return this.widget.scale}getValue(t){return this.widget.properties.getValue(`axis_${this.index}_${t}`)}isDateEnabled(){return 0!==this.timeFormat}isHorizontal(){return 0===this.index||1!==this.index&&!this.yAxis}isVertical(){return!this.isHorizontal()}isPrimary(){return this.index<=1}get effectiveMinimum(){var t;return null!==(t=this._effectiveMinimum)&&void 0!==t?t:this.minimum}set effectiveMinimum(t){this._effectiveMinimum=t}get effectiveMaximum(){var t;return null!==(t=this._effectiveMaximum)&&void 0!==t?t:this.maximum}set effectiveMaximum(t){this._effectiveMaximum=t}performAutoScale(){const t=this.widget.calculateAutoscaledRange(this);t&&(this.effectiveMinimum=t.start,this.effectiveMaximum=t.stop,this.widget.requestRepaint())}applyZoom(t,e){let i,s,r=this.effectiveMinimum,o=this.effectiveMaximum;if(this.logScale){o=Math.log10(o),r=Math.log10(r);const h=Math.log10(t)*e,n=1-e;i=h+r*n,s=h+o*n,i<va&&(i=va),i=Math.pow(10,i),s>ba&&(s=ba),s=Math.pow(10,s)}else{const h=Math.max(Math.abs(r),Math.abs(o));r/=h,o/=h;const n=t/h*e,a=1-e;i=(n+r*a)*h,s=(n+o*a)*h}this.effectiveMinimum=i,this.effectiveMaximum=s,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")}}class Sa{constructor(t,e){this.xAxis=t,this.yAxis=e,this.beforeXRanges=[],this.beforeYRanges=[],this.afterXRanges=[],this.afterYRanges=[];for(const e of t)this.beforeXRanges.push({min:e.effectiveMinimum,max:e.effectiveMaximum});for(const t of e)this.beforeYRanges.push({min:t.effectiveMinimum,max:t.effectiveMaximum})}saveState(){for(const t of this.xAxis)this.afterXRanges.push({min:t.effectiveMinimum,max:t.effectiveMaximum});for(const t of this.yAxis)this.afterYRanges.push({min:t.effectiveMinimum,max:t.effectiveMaximum})}undo(){for(let t=0;t<this.xAxis.length;t++){const e=this.xAxis[t],i=this.beforeXRanges[t];e.effectiveMinimum=i.min,e.effectiveMaximum=i.max}for(let t=0;t<this.yAxis.length;t++){const e=this.yAxis[t],i=this.beforeYRanges[t];e.effectiveMinimum=i.min,e.effectiveMaximum=i.max}}redo(){for(let t=0;t<this.xAxis.length;t++){const e=this.xAxis[t],i=this.afterXRanges[t];e.effectiveMinimum=i.min,e.effectiveMaximum=i.max}for(let t=0;t<this.yAxis.length;t++){const e=this.yAxis[t],i=this.afterYRanges[t];e.effectiveMinimum=i.min,e.effectiveMaximum=i.max}}}class Va{constructor(){this.undoStack=[],this.redoStack=[]}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}add(t){this.undoStack.push(t),this.redoStack.length=0}undo(){const t=this.undoStack.pop();t&&(t.undo(),this.redoStack.push(t))}redo(){const t=this.redoStack.pop();t&&(t.redo(),this.undoStack.push(t))}}class Aa{constructor(t,e){this.widget=e,this.id=t}tooltip(){return this.widget.tooltip}mouseDown(t){var e;const{widget:i}=this;switch(null===(e=i.toolbar)||void 0===e?void 0:e.currentTool){case"rubberband-zoom":case"horizontal-zoom":case"vertical-zoom":this.grabStart=t;break;case"panning":this.grabZoomCommand=new Sa(i.getXAxes(),i.getYAxes())}}grab(t){var e;switch(null===(e=this.widget.toolbar)||void 0===e?void 0:e.currentTool){case"rubberband-zoom":case"horizontal-zoom":case"vertical-zoom":this.grabStart&&(this.selection=Object.assign(Object.assign({},this.grabStart.point),{width:t.dx,height:t.dy}),this.widget.requestRepaint());break;case"panning":this.pan(t),this.prevGrabEvent=t,this.widget.requestRepaint()}}grabEnd(){var t;const{grabZoomCommand:e,selection:i,widget:s}=this;switch(null===(t=s.toolbar)||void 0===t?void 0:t.currentTool){case"rubberband-zoom":if(i){const t=new Sa(s.getXAxes(),s.getYAxes());this.rangeZoomXAxes(i),this.rangeZoomYAxes(i),t.saveState(),s.toolbar.addCommand(t)}break;case"horizontal-zoom":if(i){const t=new Sa(s.getXAxes(),s.getYAxes());this.rangeZoomXAxes(i),t.saveState(),s.toolbar.addCommand(t)}break;case"vertical-zoom":if(i){const t=new Sa(s.getXAxes(),s.getYAxes());this.rangeZoomYAxes(i),t.saveState(),s.toolbar.addCommand(t)}break;case"panning":e&&(e.saveState(),s.toolbar.addCommand(e))}this.selection=void 0,this.prevGrabEvent=void 0,this.grabZoomCommand=void 0,this.widget.requestRepaint()}click(t){var e;const{widget:i}=this;switch(null===(e=i.toolbar)||void 0===e?void 0:e.currentTool){case"zoom-in":const e=new Sa(i.getXAxes(),i.getYAxes());for(const e of i.getAxes()){const i=e.isHorizontal()?t.point.x:t.point.y,s=e.linearScale.getPositionValue(i);e.applyZoom(s,.1)}e.saveState(),i.toolbar.addCommand(e);break;case"zoom-out":const s=new Sa(i.getXAxes(),i.getYAxes());for(const e of i.getAxes()){const i=e.isHorizontal()?t.point.x:t.point.y,s=e.linearScale.getPositionValue(i);e.applyZoom(s,-.1)}s.saveState(),i.toolbar.addCommand(s)}}rangeZoomXAxes(t){for(const e of this.widget.getXAxes()){let i=e.linearScale.getPositionValue(t.x),s=e.linearScale.getPositionValue(t.x+t.width);if(i>s){const t=i;i=s,s=t}const r=e.linearScale.getMinMax();i=Math.max(r.start,i),s=Math.min(r.stop,s),e.effectiveMinimum=i,e.effectiveMaximum=s}}rangeZoomYAxes(t){for(const e of this.widget.getYAxes()){let i=e.linearScale.getPositionValue(t.y),s=e.linearScale.getPositionValue(t.y+t.height);if(i>s){const t=i;i=s,s=t}const r=e.linearScale.getMinMax();i=Math.max(r.start,i),s=Math.min(r.stop,s),e.effectiveMinimum=i,e.effectiveMaximum=s}}pan(t){const{prevGrabEvent:e,widget:i}=this;if(e){const s=e.dx-t.dx;if(0!==s)for(const t of i.getXAxes()){const e=t.linearScale,i=e.getMinMax(),r=e.getValuePosition(i.start)+s,o=e.getValuePosition(i.stop)+s;t.effectiveMinimum=e.getPositionValue(r),t.effectiveMaximum=e.getPositionValue(o)}const r=e.dy-t.dy;if(0!==r)for(const t of i.getYAxes()){const e=t.linearScale,i=e.getMinMax(),s=e.getValuePosition(i.start)+r,o=e.getValuePosition(i.stop)+r;t.effectiveMinimum=e.getPositionValue(s),t.effectiveMaximum=e.getPositionValue(o)}}}}class _a{constructor(t){this.pointer=0,this.samples=[],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(){const t=(this.pointer+1)%this.samples.length;return void 0!==this.samples[t]}isEmpty(){return void 0===this.tail()}tail(){return 0===this.pointer?this.samples[this.samples.length-1]:this.samples[this.pointer-1]}snapshot(t=!1){if(t){return this.samples.filter((t=>void 0!==t)).sort(((t,e)=>t.x-e.x))}{const t=this.samples.slice(this.pointer).filter((t=>void 0!==t)),e=this.samples.slice(0,this.pointer).filter((t=>void 0!==t));return t.concat(e)}}}class La{constructor(t,e,i,s,r){this.bufferSize=t,this.plotMode=e,this.updateMode=i,this.concatenateData=s,this.chronological=r,this.x=0,this.xPending=!1,this.y=0,this.yTimestamp=0,this.yPending=!1,this.xArray=[],this.xArrayPending=!1,this.yArray=[],this.yArrayPending=!1,this.traceData=new _a(t)}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.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(1===this.plotMode&&this.traceData.isFull())return;const{xPending:t,yPending:e,chronological:i,updateMode:s}=this;0===s?(i&&e||!i&&(t||e))&&this.addPoint():1===s?(i&&e||!i&&t&&e)&&this.addPoint():2===s?(i&&e||!i&&t)&&this.addPoint():3===s&&this.yPending&&this.addPoint()}maybeAddArray(){if(1===this.plotMode&&this.traceData.isFull())return;const{xArrayPending:t,yArrayPending:e,chronological:i,updateMode:s}=this;0===s?(i&&e||!i&&(t||e))&&this.addArray():1===s?(i&&e||!i&&t&&e)&&this.addArray():2===s?(i&&e||!i&&t)&&this.addArray():3===s&&this.yArrayPending&&this.addArray()}addPoint(){this.concatenateData||this.traceData.clear();let t=this.x;if(this.chronological)if(5===this.updateMode)t=(new Date).getTime();else if(void 0!==this.yTimestamp)t=this.yTimestamp;else{const 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 i=0;i<e.length;i++)t[i]=i;else{const i=this.traceData.tail();for(let s=1;s<e.length;s++)t[s-1]=i.x+s}let i=Math.min(t.length,e.length),s=Math.min(i,this.bufferSize);for(let i=0;i<s;i++)this.traceData.push(t[i],e[i]);this.xArrayPending=!1,this.yArrayPending=!1}}class Ca{constructor(t,e){this.widget=t,this.i=e,this.xPVListener=()=>{var t,e;const i=this.xPVInstance;if(i)if(Array.isArray(i.value))null===(t=this.traceData)||void 0===t||t.updateXArray(i.value);else{const t=i.toNumber();null!=t&&(null===(e=this.traceData)||void 0===e||e.updateX(t))}},this.yPVListener=()=>{var t,e,i;const s=this.yPVInstance;if(s)if(Array.isArray(s.value))null===(t=this.traceData)||void 0===t||t.updateYArray(s.value);else{const t=this.widget.getAxis(this.xAxisIndex),r=s.toNumber();if(null!=r)if(t.isDateEnabled()){const t=(s.time||new Date).getTime();null===(e=this.traceData)||void 0===e||e.updateY(r,t)}else null===(i=this.traceData)||void 0===i||i.updateY(r)}}}init(){const{bufferSize:t,plotMode:e,updateMode:i,concatenateData:s}=this,r=!this.xPV;this.traceData=new La(t,e,i,s,r),this.xPV&&(this.xPVInstance=this.widget.display.pvEngine.createPV(this.xPV),this.xPVInstance.addListener(this.xPVListener)),this.yPV&&(this.yPVInstance=this.widget.display.pvEngine.createPV(this.yPV),this.yPVInstance.addListener(this.yPVListener)),this.widget.addPropertyListener(`trace_${this.i}_x_pv`,(()=>{var t;const e=this.widget.display.pvEngine.createPV(this.xPV);e!==this.xPVInstance&&(null===(t=this.xPVInstance)||void 0===t||t.removeListener(this.xPVListener),this.xPVInstance=e,this.xPVInstance.addListener(this.xPVListener))})),this.widget.addPropertyListener(`trace_${this.i}_y_pv`,(()=>{var t;const e=this.widget.display.pvEngine.createPV(this.yPV);e!==this.yPVInstance&&(null===(t=this.yPVInstance)||void 0===t||t.removeListener(this.yPVListener),this.yPVInstance=e,this.yPVInstance.addListener(this.yPVListener))}))}snapshot(){var t;return(null===(t=this.traceData)||void 0===t?void 0:t.snapshot())||[]}drawTrace(t,e){const{lineWidth:i}=this;if(0===this.traceType)t.strokePath({path:b.fromPoints(e),color:this.traceColor,lineWidth:i});else if(1===this.traceType)t.strokePath({path:b.fromPoints(e),color:this.traceColor,lineWidth:i,dash:[6*this.scale,2*this.scale]});else if(2===this.traceType);else if(3===this.traceType){const s=this.widget.getAxis(this.yAxisIndex).linearScale.getValuePosition(0);for(const r of e)t.strokePath({path:new b(r.x,r.y).lineTo(r.x,s),lineWidth:i,color:this.traceColor,opacity:100/255})}else if(4===this.traceType||5===this.traceType){const s=this.widget.getAxis(this.yAxisIndex).linearScale.getValuePosition(0);for(let i=1;i<e.length;i++){const r=e[i-1],o=e[i];t.fillPath({path:new b(r.x,r.y).lineTo(r.x,s).lineTo(o.x,s).lineTo(o.x,o.y),color:this.traceColor,opacity:100/255})}5===this.traceType&&t.strokePath({path:b.fromPoints(e),color:this.traceColor,lineWidth:i})}else if(6===this.traceType)for(let s=1;s<e.length;s++){const r=e[s-1],o=e[s];t.strokePath({path:new b(r.x,r.y).lineTo(r.x,o.y).lineTo(o.x,o.y),color:this.traceColor,lineWidth:i})}else if(7===this.traceType)for(let s=1;s<e.length;s++){const r=e[s-1],o=e[s];t.strokePath({path:new b(r.x,r.y).lineTo(o.x,r.y).lineTo(o.x,o.y),color:this.traceColor,lineWidth:i})}else if(8===this.traceType){const{scale:s}=this;t.strokePath({path:b.fromPoints(e),color:this.traceColor,lineWidth:i,dash:[6*s,2*s,2*s,2*s]})}else if(9===this.traceType){const{scale:s}=this;t.strokePath({path:b.fromPoints(e),color:this.traceColor,lineWidth:i,dash:[6*s,2*s,2*s,2*s,2*s,2*s]})}else if(10===this.traceType){const{scale:s}=this;t.strokePath({path:b.fromPoints(e),color:this.traceColor,lineWidth:i,dash:[2*s,2*s]})}}drawPoint(t,e){t.ctx.fillStyle=this.traceColor.toString(),t.ctx.strokeStyle=this.traceColor.toString(),t.ctx.lineWidth=1*this.scale;const i=this.pointSize/2,s=e.x,r=e.y;switch(this.pointStyle){case 1:case 3:t.ctx.beginPath(),t.ctx.ellipse(s,r,i,i,0,0,2*Math.PI),t.ctx.fill();break;case 2:t.ctx.beginPath(),t.ctx.ellipse(s,r,i,i,0,0,2*Math.PI),t.ctx.stroke();break;case 4:t.ctx.lineWidth=1*this.scale,t.ctx.beginPath(),t.ctx.moveTo(s-i,r+i),t.ctx.lineTo(s,r-i),t.ctx.lineTo(s+i,r+i),t.ctx.closePath(),t.ctx.stroke();break;case 5:t.ctx.lineWidth=1*this.scale,t.ctx.beginPath(),t.ctx.moveTo(s-i,r+i),t.ctx.lineTo(s,r-i),t.ctx.lineTo(s+i,r+i),t.ctx.closePath(),t.ctx.fill();break;case 6:t.ctx.strokeRect(s-i,r-i,2*i,2*i);break;case 7:t.ctx.fillRect(s-i,r-i,2*i,2*i);break;case 8:case 9:t.ctx.beginPath(),t.ctx.moveTo(s-i,r),t.ctx.lineTo(s,r-i),t.ctx.lineTo(s+i,r),t.ctx.lineTo(s,r+i),t.ctx.closePath(),t.ctx.stroke();break;case 10:t.ctx.beginPath(),t.ctx.moveTo(s-i,r-i),t.ctx.lineTo(s+i,r+i),t.ctx.moveTo(s+i,r-i),t.ctx.lineTo(s-i,r+i),t.ctx.stroke();break;case 11:t.ctx.beginPath(),t.ctx.moveTo(s-i,r),t.ctx.lineTo(s+i,r),t.ctx.moveTo(s,r-i),t.ctx.lineTo(s,r+i),t.ctx.stroke();break;case 12:t.ctx.beginPath(),t.ctx.moveTo(s,r-i),t.ctx.lineTo(s,r+i),t.ctx.stroke()}}clearData(){var t;null===(t=this.traceData)||void 0===t||t.clear()}get scale(){return this.widget.scale}getValue(t){return this.widget.properties.getValue(`trace_${this.i}_${t}`)}get antiAlias(){return this.getValue("anti_alias")}get bufferSize(){return this.getValue("buffer_size")}get concatenateData(){return this.getValue("concatenate_data")}get lineWidth(){return this.scale*this.getValue("line_width")}get name(){return this.getValue("name")}get plotMode(){return this.getValue("plot_mode")}get pointSize(){return this.scale*this.getValue("point_size")}get pointStyle(){return this.getValue("point_style")}get traceColor(){return this.getValue("trace_color")}get traceType(){return this.getValue("trace_type")}get updateDelay(){return this.getValue("update_delay")}get updateMode(){return this.getValue("update_mode")}get visible(){return this.getValue("visible")}get xAxisIndex(){return this.getValue("x_axis_index")}get xPV(){return this.getValue("x_pv")}get yAxisIndex(){return this.getValue("y_axis_index")}get yPV(){return this.getValue("y_pv")}}const Pa=new e(236,236,236),Ma=new e(130,130,130);class ka{constructor(t,e,i,s,r){this.imageFile=e,this.disabledImageFile=i,this.action=r,this.imageElement=new Image,this.disabledImageElement=new Image,this.toggleButton=!1,this.toolButton=!1,this.pushed=!1,this.disabled=!1,this.loadPromise=new Promise(((t,e)=>{this.imageElement.onload=()=>t()})),this.disabledLoadPromise=new Promise(((t,e)=>{this.disabledImageElement.onload=()=>t()})),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:()=>s}}loadImage(t){this.imageElement.src=t+this.imageFile,this.disabledImageElement.src=t+this.disabledImageFile}}class Ra{constructor(t){this.xyGraph=t,this.buttons=[],this.imagesLoaded=!1,this.currentTool="default",this.commandBuffer=new Va,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",(t=>{this.showLegend.pushed=t})),this.autoScale=this.createButton("AutoScale.png","AutoScale.png","Perform Auto Scale",(()=>{const e=new Sa(t.getXAxes(),t.getYAxes());t.performAutoScale(),e.saveState(),this.addCommand(e)})),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",(()=>{const e=document.createElement("a");try{e.href=t.toDataURL(),e.download=`${t.name}_export.png`,document.body.appendChild(e),e.click()}finally{document.body.removeChild(e)}})),this.toggleTool(this.mouseArrow);const e=this.buttons.map((t=>t.loadPromise)).concat(this.buttons.map((t=>t.disabledLoadPromise)));Promise.all(e).finally((()=>{this.imagesLoaded=!0,t.requestRepaint()}));for(const e of this.buttons)e.loadImage(t.display.imagesPrefix)}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){const e=t.pushed;for(const t of this.buttons)t.toolButton&&(t.pushed=!1);e?t.pushed=!0:this.mouseArrow.pushed=!0,this.xyGraph.requestRepaint()}createToolButton(t,e,i){const s=this.createToggleButton(t,e,i);return s.toolButton=!0,s}createToggleButton(t,e,i){const s=this.createButton(t,t,e,i);return s.toggleButton=!0,s}createButton(t,e,i,s){const r=new ka(this,t,e,i,s);return this.buttons.push(r),r}draw(t,e){const{buttonSize:i}=this,s={x:e.x,y:e.y};return this.drawButton(t,s.x,s.y,this.showLegend),s.x+=i,this.maybeWrap(s,e),this.drawButton(t,s.x,s.y,this.autoScale),s.x+=i,this.maybeWrap(s,e,i/2),this.drawSeparator(t,s.x,s.y),s.x+=i/2,this.maybeWrap(s,e),this.drawButton(t,s.x,s.y,this.rubberbandZoom),s.x+=i,this.maybeWrap(s,e),this.drawButton(t,s.x,s.y,this.horizontalZoom),s.x+=i,this.maybeWrap(s,e),this.drawButton(t,s.x,s.y,this.verticalZoom),s.x+=i,this.maybeWrap(s,e),this.drawButton(t,s.x,s.y,this.zoomIn),s.x+=i,this.maybeWrap(s,e),this.drawButton(t,s.x,s.y,this.zoomOut),s.x+=i,this.maybeWrap(s,e),this.drawButton(t,s.x,s.y,this.panning),s.x+=i,this.maybeWrap(s,e),this.drawButton(t,s.x,s.y,this.mouseArrow),s.x+=i,this.maybeWrap(s,e,i/2),this.drawSeparator(t,s.x,s.y),s.x+=i/2,this.maybeWrap(s,e),this.drawButton(t,s.x,s.y,this.undo),s.x+=i,this.maybeWrap(s,e),this.drawButton(t,s.x,s.y,this.redo),s.x+=i,this.maybeWrap(s,e,i/2),this.drawSeparator(t,s.x,s.y),s.x+=i/2,this.maybeWrap(s,e),this.drawButton(t,s.x,s.y,this.camera),s.x+=i,s.y+i-e.y}maybeWrap(t,e,i){i=null!=i?i:this.buttonSize,t.x+i>e.x+e.width&&(t.x=e.x,t.y+=this.buttonSize)}drawSeparator(t,e,i){const{buttonSize:s}=this,r=1*this.scale,o=Math.round(e+s/4)-r/2;t.strokePath({path:new b(o,i).lineTo(o,i+s),color:Ma,lineWidth:r})}drawButton(t,i,s,r){const{buttonSize:o,scale:h}=this;t.fillRect({x:i,y:s,width:o,height:o,color:Pa}),this.xyGraph.enabled&&!r.disabled&&t.addHitRegion(r.region).addRect(i,s,o,o);const n=1*h,a=Math.round(s+n/2)-.5,l=Math.round(i+n/2)-.5,d=Math.round(s+o-n+n/2)-.5,c=Math.round(i+o-n+n/2)-.5;if(t.strokePath({color:r.pushed?e.WHITE:e.BLACK,path:new b(c,d).lineTo(c,a).moveTo(c,d).lineTo(l,d),lineWidth:n}),t.strokePath({color:r.pushed?e.BLACK:e.WHITE,path:new b(l,a).lineTo(c-n,a).moveTo(l,a).lineTo(l,d-n),lineWidth:n}),this.imagesLoaded){const e=r.disabled?r.disabledImageElement:r.imageElement,n=e.naturalHeight*h,a=e.naturalWidth*h,l=Math.round(i+(o-a)/2),d=Math.round(s+(o-n)/2);t.ctx.drawImage(e,l,d,a,n)}}get scale(){return this.xyGraph.scale}get buttonSize(){return 25*this.scale}}const Ea="axis_count",Wa="plot_area_background_color",Ba="show_legend",Ia="show_plot_area_border",Oa="show_toolbar",Ha="title",Fa="title_font",Na="trace_count",Da="transparent";class ja extends ge{constructor(t,e){super(t,e),this.axes=[],this.traces=[],this.autoScaleAllowed=!0,this.properties.add(new $(Ea)),this.properties.add(new U(Wa)),this.properties.add(new z(Ba)),this.properties.add(new z(Ia)),this.properties.add(new z(Oa)),this.properties.add(new D(Ha)),this.properties.add(new q(Fa)),this.properties.add(new $(Na)),this.properties.add(new z(Da)),this.properties.addGenerator((()=>{const t=[];this.axes=[];const e=this.properties.getValue(Ea);for(let i=0;i<e;i++)this.axes.push(new Ta(this,i)),t.push(new z(`axis_${i}_auto_scale`),new G(`axis_${i}_auto_scale_treshold`),new U(`axis_${i}_axis_color`),new D(`axis_${i}_axis_title`),new z(`axis_${i}_dash_grid_line`),new U(`axis_${i}_grid_color`),new z(`axis_${i}_log_scale`),new G(`axis_${i}_maximum`),new G(`axis_${i}_minimum`),new q(`axis_${i}_scale_font`),new D(`axis_${i}_scale_format`),new z(`axis_${i}_show_grid`),new $(`axis_${i}_time_format`),new q(`axis_${i}_title_font`),new z(`axis_${i}_visible`)),i>1&&t.push(new z(`axis_${i}_left_bottom_side`),new z(`axis_${i}_y_axis`));this.traces=[];const i=this.properties.getValue(Na);for(let e=0;e<i;e++)this.traces.push(new Ca(this,e)),t.push(new z(`trace_${e}_anti_alias`),new $(`trace_${e}_buffer_size`),new z(`trace_${e}_concatenate_data`),new $(`trace_${e}_line_width`),new D(`trace_${e}_name`),new $(`trace_${e}_plot_mode`),new $(`trace_${e}_point_size`),new $(`trace_${e}_point_style`),new U(`trace_${e}_trace_color`),new $(`trace_${e}_trace_type`),new $(`trace_${e}_update_delay`),new $(`trace_${e}_update_mode`),new z(`trace_${e}_visible`),new $(`trace_${e}_x_axis_index`),new D(`trace_${e}_x_pv`),new j(`trace_${e}_x_pv_value`,`trace_${e}_x_pv`),new $(`trace_${e}_y_axis_index`),new D(`trace_${e}_y_pv`),new j(`trace_${e}_y_pv_value`,`trace_${e}_y_pv`));return t}))}init(){this.plotAreaRegion=new Aa(`${this.wuid}-plotarea`,this),this.traces.forEach((t=>t.init()))}draw(t){var e;const{scale:i}=this;let s=this.area;if(this.borderAlarmSensitive&&(s=d(this.area,2*i)),!this.transparent){const e=this.alarmSensitiveBackgroundColor;t.fillRect(Object.assign(Object.assign({},s),{color:e}))}this.showToolbar&&this.drawToolbar(t,s),this.title&&this.drawTitle(t,s);for(const t of this.axes){if(t.autoScale&&this.autoScaleAllowed){const e=this.calculateAutoscaledRange(t);e&&(t.effectiveMinimum=e.start,t.effectiveMaximum=e.stop)}const e=t.effectiveMinimum,s=t.effectiveMaximum;t.linearScale=new ro(i,t.scaleFont,e,s,t.logScale,50*i,t.axisColor,!0,t.visible),t.linearScale.scaleFormat=t.scaleFormat,t.linearScale.timeFormat=t.timeFormat}this.showLegend&&this.drawLegend(t,s),t.addHitRegion(this.plotAreaRegion).addRect(s.x,s.y,s.width,s.height);const r=this.drawAxes(t,s);this.drawPlotArea(t,r);const o=null===(e=this.plotAreaRegion)||void 0===e?void 0:e.selection;o&&this.drawZoomSelection(t,r,function(t,e){let i=t.x,s=t.y,r=i+t.width,o=s+t.height;if(r<i){const t=i;i=r,r=t}if(o<s){const t=s;s=o,o=t}let h=e.x,n=e.y,a=h+e.width,l=n+e.height;if(a<h){const t=h;h=a,a=t}if(l<n){const t=n;n=l,l=t}const d=Math.max(i,h),c=Math.max(s,n);return{x:d,y:c,width:Math.min(r,a)-d,height:Math.min(o,l)-c}}(r,o))}drawToolbar(t,e){this.toolbar||(this.toolbar=new Ra(this));const i=3*this.scale,s=d(e,i),r=this.toolbar.draw(t,s);e.y+=i+r+i,e.height-=i+r+i}drawTitle(t,e){const 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});const s=2*this.scale;e.y+=i+s,e.height-=i+s}drawAxes(t,e){const{scale:i}=this,s=5*i,r=Object.assign({},e);let o=0;for(const e of this.getXAxes())if(e.visible){let i=0;e.axisTitle&&(i=s+t.measureText(e.axisTitle,e.titleFont).height),o+=i+e.linearScale.measureHorizontalHeight(t)}let h=0,n=0;for(const a of this.getYAxes().reverse()){const l=a.linearScale;if(a.visible){const d=l.calculateMargin(t,!1),c=r.height-o+(o>0?d:0);let p=0;a.axisTitle&&(p=t.measureText(a.axisTitle,a.titleFont).height,t.ctx.save(),t.ctx.translate(r.x+s+p/2,e.y+c/2),t.ctx.rotate(-Math.PI/2),t.fillText({x:0,y:0,align:"center",baseline:"middle",font:a.titleFont,color:a.axisColor,text:a.axisTitle}),t.ctx.restore(),p+=s);const g=p+l.drawVertical(t,r.x+p,e.y,c,!0,!1);r.x+=g,r.width-=g,h+=g;const u=l.margin;n=0===n?u:Math.min(n,u);const m=1*i,x=Math.round(r.x)-m/2,f=Math.round(e.y+d)-m/2;t.strokePath({path:new b(x,f).lineTo(x,f+c-2*d),color:a.axisColor,opacity:100/255,lineWidth:m})}else{const t=r.height-o;l.setDimensions(0,e.y,t,!1)}}let a=0;for(const o of this.getXAxes().reverse()){const n=o.linearScale;if(o.visible){const l=n.calculateMargin(t,!0),d=h-l;let c=0;if(o.axisTitle){c=t.measureText(o.axisTitle,o.titleFont).height;const i=e.x+h+(e.width-h)/2;t.fillText({x:i,y:r.y+r.height-c/2,align:"center",baseline:"middle",font:o.titleFont,color:o.axisColor,text:o.axisTitle}),c+=s}const p=c+n.drawHorizontal(t,e.x+d,r.y+r.height-c,e.width-d);r.height-=p;const g=n.margin;a=0===a?g:Math.min(a,g);const u=1*i,m=Math.round(e.x+d+l)-u/2,x=Math.round(r.y+r.height)-u/2;t.strokePath({path:new b(m,x).lineTo(m+r.width-l,x),color:o.axisColor,opacity:100/255,lineWidth:u})}else{const t=e.x+h,i=e.width-h;n.setDimensions(t,0,i,!0)}}return r.y+=n,r.width-=a,r.height-=o>0?n:2*n,r}drawPlotArea(t,i){const{scale:s}=this,r=1*s;if(t.fillRect(Object.assign(Object.assign({},i),{color:this.plotAreaBackgroundColor})),this.showPlotAreaBorder){const{x:s,y:o,width:h,height:n}=d(i,r/2);t.strokePath({path:new b(s,o).lineTo(s+h,o).lineTo(s+h,o+n),color:e.BLACK,lineWidth:r})}for(const e of this.axes.filter((t=>t.visible&&t.showGrid))){const o=e.linearScale;if(e.isHorizontal())for(const h of o.getGridPositions()){const n=Math.round(o.getX()+h)-r/2;t.strokePath({path:new b(n,i.y).lineTo(n,i.y+i.height),color:e.gridColor,lineWidth:r,dash:e.dashGridLine?[6*s,2*s]:void 0})}else for(const h of o.getGridPositions()){const n=Math.round(o.getY()+h)-r/2;t.strokePath({path:new b(i.x,n).lineTo(i.x+i.width,n),color:e.gridColor,lineWidth:r,dash:e.dashGridLine?[6*s,2*s]:void 0})}}t.ctx.save(),t.ctx.beginPath(),t.ctx.rect(i.x,i.y,i.width,i.height),t.ctx.clip();for(const e of this.traces.filter((t=>t.visible))){const i=this.getAxis(e.xAxisIndex).linearScale,s=this.getAxis(e.yAxisIndex).linearScale,r=[];for(const t of e.snapshot()){const e=i.getValuePosition(t.x),o=s.getValuePosition(t.y);r.push({x:e,y:o})}if(r.length){e.drawTrace(t,r);for(const i of r)e.drawPoint(t,i)}}t.ctx.restore()}drawZoomSelection(t,i,s){var r;const{scale:o}=this;switch(null===(r=this.toolbar)||void 0===r?void 0:r.currentTool){case"rubberband-zoom":t.strokeRect(Object.assign(Object.assign({},s),{color:e.BLACK,lineWidth:1*o}));break;case"horizontal-zoom":const r=s;r.y=i.y,r.height=i.height,t.strokeRect(Object.assign(Object.assign({},c(r)),{color:e.BLACK,lineWidth:1*o}));break;case"vertical-zoom":const h=s;h.x=i.x,h.width=i.width,t.strokeRect(Object.assign(Object.assign({},c(h)),{color:e.BLACK,lineWidth:1*o}))}}drawLegend(t,e){const{scale:i}=this,s=25*i,r=2*i,o=5*i,h=W.ARIAL_10.scale(i);for(const n of this.getYAxes()){const a=this.traces.filter((t=>t.visible&&t.yAxisIndex===n.index)),l=[];let c=[],p=0,g=0;for(const i of a){let n=s+r+o;i.name&&(n+=t.measureText(i.name,h).width),p+n<e.width?(c.push(i),p+=n):(l.push(c),n=Math.max(n,p),c=[i],p=n)}if(c.length&&(l.push(c),g=Math.max(g,p)),!l.length)continue;const u=s*l.length,m={x:Math.round(e.x+(e.width-g)/2),y:Math.round(e.y+e.height-u),width:g,height:u};e.height-=m.height,t.fillRect(Object.assign(Object.assign({},m),{color:this.plotAreaBackgroundColor})),t.strokeRect(Object.assign(Object.assign({},d(m,1*i/2)),{color:n.axisColor}));let x=m.x,f=m.y;for(let e=0;e<l.length;e++){const n=l[e],a=f+e*s,d=a+s/2;for(const e of n){const n=e.pointSize>Math.floor((s-o)/2)?Math.floor(s-o):e.pointSize;switch(e.traceType){case 3:const r=x+s/2;t.strokePath({path:new b(r,a+n).lineTo(r,a+s),lineWidth:e.lineWidth,color:e.traceColor,opacity:100/255}),e.drawPoint(t,{x:r,y:a+n});break;case 4:case 5:const o=[{x:x,y:a+s/2},{x:x+s/2,y:a+n},{x:x+s,y:a+s/2},{x:x+s,y:a+s},{x:x,y:a+s}];t.fillPath({path:b.fromPoints(o),color:e.traceColor,opacity:100/255}),5===e.traceType&&t.strokePath({path:b.fromPoints(o.slice(0,3)),color:e.traceColor,lineWidth:1*i}),e.drawPoint(t,{x:x+s/2,y:a+n});break;default:e.drawTrace(t,[{x:x,y:d},{x:x+s,y:d}]),e.drawPoint(t,{x:x+s/2,y:d})}x+=s+r,e.name&&(t.fillText({x:x,y:d,align:"left",baseline:"middle",color:e.traceColor,font:h,text:e.name}),x+=t.measureText(e.name,h).width),x+=o}}}}setCursor(t){this.plotAreaRegion.cursor=t}calculateAutoscaledRange(t){let e,i;const s=t.logScale;for(const r of this.traces)if(r.visible&&(this.axes[r.xAxisIndex]===t||this.axes[r.yAxisIndex]===t))for(const o of r.snapshot()){const r=t.isHorizontal()?o.x:o.y;(void 0===e||e>r)&&(!s||r>0)&&(e=r),(void 0===i||i<r)&&(!s||r>0)&&(i=r)}if(void 0!==e&&void 0!==i)return{start:e,stop:i}}performAutoScale(){for(const t of this.axes)t.visible&&t.performAutoScale()}clearGraph(){for(const 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(Ea)}get plotAreaBackgroundColor(){return this.properties.getValue(Wa)}get showLegend(){return this.properties.getValue(Ba)}get showPlotAreaBorder(){return this.properties.getValue(Ia)}get showToolbar(){return this.properties.getValue(Oa)}get title(){return this.properties.getValue(Ha)}get titleFont(){return this.properties.getValue(Fa).scale(this.scale)}get traceCount(){return this.properties.getValue(Na)}get transparent(){return this.properties.getValue(Da)}}const $a="macros";class Ga extends ge{constructor(t,e){super(t,e),this._widgets=[],this._connections=[],this.relativeScale=1,this.properties.add(new Z($a))}expandContainerMacros(t){for(const e in this.macros.macros)t=(t=t.replace(`$(${e})`,this.macros.macros[e])).replace(`\${${e}}`,this.macros.macros[e]);return this.parent&&this.macros.includeParentMacros&&(t=this.parent.expandContainerMacros(t)),t}findWidget(t){for(const e of this.widgets){if(e.wuid===t)return e;if(e instanceof Ga){const i=e.findWidget(t);if(i)return i}}}findWidgetByName(t){for(const e of this.widgets){if(e.name===t)return e;if(e instanceof Ga){const i=e.findWidgetByName(t);if(i)return i}}for(const e of this.connections)if(e.name===t)return e}closeMenu(){for(const t of this.widgets)t.closeMenu()}hide(){for(const t of this.widgets)t.hide()}destroy(){for(const t of this.widgets)t.destroy()}get widgets(){return this._widgets}get connections(){return this._connections}get macros(){return this.properties.getValue($a)}}const za="arrow_length",Ua="arrows",qa="fill_arrow",Ya="name",Xa="line_color",Ka="line_style",Za="line_width",Ja="src_wuid",Qa="src_term",tl="tgt_wuid",el="tgt_term",il="router",sl="points",rl="LEFT",ol="UP",hl="DOWN",nl="RIGHT";class al extends ge{constructor(t){super(t),this.properties.clear(),this.properties.add(new $(za)),this.properties.add(new $(Ua)),this.properties.add(new z(qa)),this.properties.add(new D(Ya)),this.properties.add(new U(Xa)),this.properties.add(new $(Ka)),this.properties.add(new $(Za)),this.properties.add(new D(Ja)),this.properties.add(new D(Qa)),this.properties.add(new D(tl)),this.properties.add(new D(el)),this.properties.add(new $(il)),this.properties.add(new X(sl)),this.properties.add(new D("wuid"))}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):0===this.router?this.drawManhattanConnection(t):1===this.router&&this.drawDirectConnection(t))}drawPath(t){const e=this.getPosition(this.sourceWidget,this.sourceTerm),i=this.getPosition(this.targetWidget,this.targetTerm),s=[e,...this.points,i],r=b.fromPoints(s).translate(.5*this.scale,.5*this.scale);t.strokePath({path:r,lineWidth:this.lineWidth,color:this.lineColor,dash:this.getDashArray()}),this.drawStartArrow(t,s[1],s[0]),this.drawStopArrow(t,s[s.length-2],s[s.length-1])}drawManhattanConnection(t){const e=this.getManhattanAnchor(this.sourceWidget,this.sourceTerm),i=this.getManhattanAnchor(this.targetWidget,this.targetTerm),s=this.route(e,i),r=b.fromPoints(s);this.lineWidth&&t.strokePath({lineWidth:this.lineWidth,color:this.lineColor,path:r,dash:this.getDashArray()}),this.drawStartArrow(t,s[s.length-2],s[s.length-1]),this.drawStopArrow(t,s[1],s[0])}getDashArray(){const{scale:t}=this;if(this.lineWidth){if(0===this.lineStyle)return[];if(1===this.lineStyle)return[6*t,2*t];if(2===this.lineStyle)return[2*t,2*t];if(3===this.lineStyle)return[6*t,2*t,2*t,2*t];if(4===this.lineStyle)return[6*t,2*t,2*t,2*t,2*t,2*t];console.warn(`Unsupported connection line style ${this.lineStyle}`)}}drawDirectConnection(t){const e=this.getPosition(this.sourceWidget,this.sourceTerm),i=this.getPosition(this.targetWidget,this.targetTerm);this.lineWidth&&t.strokePath({path:new b(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=ol;break;case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":i=hl;break;case"LEFT":i=rl;break;case"RIGHT":i=nl}const s=t.bounds,r=this.getPosition(t,e),o=r.x-s.x,h=s.x+s.width-r.x,n=r.y-s.y,a=s.y+s.height-r.y;return i=Math.min(o,h)<Math.min(n,a)?o<h?rl:nl:n<a?ol:hl,{x:r.x,y:r.y,direction:i}}getPosition(t,e){switch(e){case"LEFT":return{x:t.holderX,y:t.holderY+t.holderHeight/2};case"TOP":return{x:t.holderX+t.holderWidth/2,y:t.holderY};case"RIGHT":return{x:t.holderX+t.holderWidth,y:t.holderY+t.holderHeight/2};case"BOTTOM":return{x:t.holderX+t.holderWidth/2,y:t.holderY+t.holderHeight};case"TOP_LEFT":return{x:t.holderX,y:t.holderY};case"TOP_RIGHT":return{x:t.holderX+t.holderWidth,y:t.holderY};case"BOTTOM_LEFT":return{x:t.holderX,y:t.holderY+t.holderHeight};case"BOTTOM_RIGHT":return{x:t.holderX+t.holderWidth,y:t.holderY+t.holderHeight};default:const i=parseInt(e,10);let s=t.properties.getProperty("points");if(s){let t=s.value;return t=w(t,this.scale),t[i]}throw Error(`Unexpected term ${e}`)}}route(t,e){let i,s,r=t.x-e.x,o=t.y-e.y,h={x:0,y:0},n=[];const{tolxtol:a,tol:l,minDist:d}=this;if(r*r<a&&o*o<a)return[{x:e.x,y:e.y}];t.direction===rl?r>0&&o*o<l&&e.direction===nl?(h=e,i=e.direction):(r<0?h={x:t.x-d,y:t.y}:o>0&&e.direction===hl||o<0&&e.direction===ol?h={x:e.x,y:t.y}:t.direction===e.direction?(s=Math.min(t.x,e.x)-d,h={x:s,y:t.y}):h={x:t.x-r/2,y:t.y},i=o>0?ol:hl):t.direction===nl?r<0&&o*o<l&&e.direction===rl?(h=e,i=e.direction):(r>0?h={x:t.x+d,y:t.y}:o>0&&e.direction===hl||o<0&&e.direction===ol?h={x:e.x,y:t.y}:t.direction===e.direction?(s=Math.max(t.x,e.x)+d,h={x:s,y:t.y}):h={x:t.x-r/2,y:t.y},i=o>0?ol:hl):t.direction===hl?r*r<l&&o<0&&e.direction===ol?(h=e,i=e.direction):(o>0?h={x:t.x,y:t.y+d}:r>0&&e.direction===nl||r<0&&e.direction===rl?h={x:t.x,y:e.y}:t.direction===e.direction?(s=Math.max(t.y,e.y)+d,h={x:t.x,y:s}):h={x:t.x,y:t.y-o/2},i=r>0?rl:nl):t.direction===ol&&(r*r<l&&o>0&&e.direction===hl?(h=e,i=e.direction):(o<0?h={x:t.x,y:t.y-d}:r>0&&e.direction===nl||r<0&&e.direction===rl?h={x:t.x,y:e.y}:t.direction===e.direction?(s=Math.min(t.y,e.y)-d,h={x:t.x,y:s}):h={x:t.x,y:t.y-o/2},i=r>0?rl:nl));const c=Object.assign(Object.assign({},h),{direction:i});return n=n.concat(this.route(c,e)),n.push(t),n}drawStartArrow(t,e,i){const s=t.ctx;if(1===this.arrows||3===this.arrows){const t=this.calculateArrowPoints(e,i);if(t[2]=i,this.fillArrow){s.fillStyle=this.lineColor.toString(),s.beginPath();for(let e=0;e<t.length;e++)0===e?s.moveTo(t[e].x,t[e].y):s.lineTo(t[e].x,t[e].y);s.fill()}else s.strokeStyle=this.lineColor.toString(),s.lineWidth=this.lineWidth,s.beginPath(),s.moveTo(i.x,i.y),s.lineTo(t[0].x,t[0].y),s.moveTo(i.x,i.y),s.lineTo(t[1].x,t[1].y),s.stroke()}}drawStopArrow(t,e,i){const s=t.ctx;if(2===this.arrows||3===this.arrows){const t=this.calculateArrowPoints(e,i);if(t[2]=i,this.fillArrow){s.fillStyle=this.lineColor.toString(),s.beginPath();for(let e=0;e<t.length;e++)0===e?s.moveTo(t[e].x,t[e].y):s.lineTo(t[e].x,t[e].y);s.fill()}else s.strokeStyle=this.lineColor.toString(),s.lineWidth=this.lineWidth,s.beginPath(),s.moveTo(i.x,i.y),s.lineTo(t[0].x,t[0].y),s.moveTo(i.x,i.y),s.lineTo(t[1].x,t[1].y),s.stroke()}}calculateArrowPoints(t,e){const i=x(e,t),s=Math.PI/10,r=new f(this.arrowLength,i.theta-s),o=new f(this.arrowLength,i.theta+s),h=new f(Math.floor(this.arrowLength*Math.cos(s)),i.theta);return[p(r.toPoint(),e.x,e.y),p(o.toPoint(),e.x,e.y),p(h.toPoint(),e.x,e.y)]}get minDist(){return 20*this.scale}get tol(){return.1*this.scale}get tolxtol(){return.01*this.scale}get name(){return this.properties.getValue(Ya)}get arrows(){return this.properties.getValue(Ua)}get fillArrow(){return this.properties.getValue(qa)}get arrowLength(){return this.scale*this.properties.getValue(za)}get lineColor(){return this.properties.getValue(Xa)}get lineStyle(){return this.properties.getValue(Ka)}get lineWidth(){return this.scale*this.properties.getValue(Za)}get router(){return this.properties.getValue(il)}get sourceTerm(){return this.properties.getValue(Qa)}get sourceWuid(){return this.properties.getValue(Ja)}get targetTerm(){return this.properties.getValue(el)}get targetWuid(){return this.properties.getValue(tl)}get points(){return w(this.properties.getValue(sl),this.scale)}}let ll=0;const dl="auto_scale_widgets";class cl extends Ga{constructor(t,e){super(t,e),this.properties.add(new it(dl))}parseNode(t){super.parseNode(t);const e=ll++;this.macros.set("DID",`DID_${e}`);const i=this.properties.getValue("name");this.macros.set("DNAME",i);for(const e of t.getNodes("widget")){const t=e.getString("widget_type"),i=this.display.createWidget(t,this);i&&(i.parseNode(e),this.widgets.push(i))}for(const e of t.getNodes("connection")){const t=new al(this.display);t.parseNode(e),this.connections.push(t)}}draw(t){for(const e of this.widgets.filter((t=>t.visible)))e.drawHolder(t),e.draw(t),e.drawDecoration(t);for(const e of this.connections)e.draw(t);for(const e of this.widgets.filter((t=>t.visible)))e.drawOverlay(t)}measureContentBounds(t){let e=0,i=0,s=0,r=0;for(const o of this.widgets.filter((t=>t.visible))){const h=t?o.bounds:o.unscaledBounds;e=Math.min(e,h.x),i=Math.min(i,h.y),s=Math.max(s,h.x+h.width),r=Math.max(r,h.y+h.height)}return{x:e,y:i,width:s-e,height:r-i}}get autoScaleWidgets(){return this.properties.getValue(dl)}}class pl extends Ga{parseNode(t){super.parseNode(t);for(const e of t.getNodes("widget")){const t=e.getString("widget_type"),i=this.display.createWidget(t,this);i&&(i.parseNode(e),this.widgets.push(i))}}draw(t){this.transparent||t.fillRect({x:this.x,y:this.y,width:this.width,height:this.height,color:this.backgroundColor});const e=t.createChild(this.width,this.height);for(const t of this.widgets.filter((t=>t.visible)))t.drawHolder(e),t.draw(e),t.drawDecoration(e);for(const t of this.widgets.filter((t=>t.visible)))t.drawOverlay(e);t.copy(e,this.x,this.y)}}class gl{constructor(){this.includeParentMacros=!0,this.macros={}}clear(){this.macros={}}set(t,e){this.macros[t]=e}get(t){if(t in this.macros)return this.macros[t]}}class ul{constructor(t,e,i){this.autoScaleWidgets=t,this.minWidth=e,this.minHeight=i}}class ml{constructor(t,e,i){this.widthScalable=t,this.heightScalable=e,this.keepWidthHeightRatio=i}}class xl{constructor(){this.scripts=[]}}class fl{constructor(t){this.node=t}get name(){return this.node.nodeName}static parseFromXML(t){const e=(new DOMParser).parseFromString(t,"text/xml");return new fl(e.documentElement)}getNode(t){const e=this.findChild(t);return new fl(e)}getNodes(t){const e=[];for(let i=0;i<this.node.childNodes.length;i++){const s=this.node.childNodes[i];3!==s.nodeType&&(t&&s.nodeName!==t||e.push(new fl(s)))}return e}hasNode(t){for(let e=0;e<this.node.childNodes.length;e++){if(this.node.childNodes[e].nodeName===t)return!0}return!1}hasAttribute(t){return this.node.hasAttribute(t)}getTextContent(t){return this.node.textContent||t||""}getString(t,e){for(let e=0;e<this.node.childNodes.length;e++){const i=this.node.childNodes[e];if(i.nodeName===t&&null!==i.textContent)return i.textContent}if(void 0!==e)return e;throw new Error(`No child node named ${t} could be found`)}getStringAttribute(t){const e=this.node.attributes.getNamedItem(t);if(null===e)throw new Error(`No attribute named ${t}`);return e.textContent||""}getFloat(t,e){for(let e=0;e<this.node.childNodes.length;e++){const i=this.node.childNodes[e];if(i.nodeName===t&&null!==i.textContent)return parseFloat(i.textContent)}if(void 0!==e)return e;throw new Error(`No child node named ${t} could be found`)}getInt(t,e){for(let e=0;e<this.node.childNodes.length;e++){const i=this.node.childNodes[e];if(i.nodeName===t&&null!==i.textContent)return parseInt(i.textContent,10)}if(void 0!==e)return e;throw new Error(`No child node named ${t} could be found`)}getIntAttribute(t){const e=this.node.attributes.getNamedItem(t);if(null===e)throw new Error(`No attribute named ${t}`);return parseInt(e.textContent||"",10)}getBoolean(t,e){for(let e=0;e<this.node.childNodes.length;e++){const i=this.node.childNodes[e];if(i.nodeName===t)return"true"===i.textContent}if(void 0!==e)return e;throw new Error(`No child node named ${t} could be found`)}getBooleanAttribute(t,e){const i=this.node.attributes.getNamedItem(t);if(null===i){if(void 0!==e)return e;throw new Error(`No attribute named ${t}`)}return"true"===i.textContent}getColor(t,e){const i=this.findChild(t);for(let t=0;t<i.childNodes.length;t++){const e=i.childNodes[t];if("color"===e.nodeName)return this.parseColorNode(new fl(e))}if(void 0!==e)return e;throw new Error("No child node named 'color' could be found")}getFont(t){const e=this.getNode(t);if(e.hasNode("opifont.name")){const t=e.getNode("opifont.name"),i=t.getStringAttribute("fontName"),s=t.getIntAttribute("height"),r=t.getIntAttribute("style");let o=!1;return t.hasAttribute("pixels")&&(o=t.getBooleanAttribute("pixels")),new W(i,s,r,o)}{const t=e.getNode("fontdata"),i=t.getStringAttribute("fontName"),s=t.getIntAttribute("height"),r=t.getIntAttribute("style");return new W(i,s,r,!1)}}getPoints(t){const e=this.getNode(t),i=[];for(const t of e.getNodes("point"))i.push({x:t.getIntAttribute("x"),y:t.getIntAttribute("y")});return i}getStringList(t){const e=this.getNode(t),i=[];for(const t of e.getNodes("s"))i.push(t.getTextContent());return i}getScripts(t){const e=this.getNode(t),i=new xl;for(const t of e.getNodes("path")){const e=[];for(const i of t.getNodes("pv"))e.push({pvName:i.getTextContent(),trigger:i.getBooleanAttribute("trig")});const s=t.getStringAttribute("pathString");"EmbeddedJs"===s?i.scripts.push({embedded:!0,text:t.getString("scriptText"),checkConnect:t.getBooleanAttribute("checkConnect"),skipFirstExecution:t.getBooleanAttribute("sfe",!1),inputs:e}):"EmbeddedPy"===s?console.warn("Unsupported EmbeddedPy script"):i.scripts.push({embedded:!1,path:s,checkConnect:t.getBooleanAttribute("checkConnect"),skipFirstExecution:t.getBooleanAttribute("sfe",!1),inputs:e})}return i}getScaleOptions(t){const e=this.getNode(t);return new ml(e.getBoolean("width_scalable"),e.getBoolean("height_scalable"),e.getBoolean("keep_wh_ratio"))}getAutoScaleWidgets(t){const e=this.getNode(t);return new ul(e.getBoolean("auto_scale_widgets"),e.getInt("min_width"),e.getInt("min_height"))}getColorMap(t){const e=this.getNode(t);if(!e.hasNode("e"))return new H(e.getInt("map"),e.getBoolean("interpolate"),e.getBoolean("autoscale"));{const t=new H(0,e.getBoolean("interpolate"),e.getBoolean("autoscale"));for(const i of e.getNodes("e")){const e=Number(i.getTextContent()),s=i.getIntAttribute("red"),r=i.getIntAttribute("green"),o=i.getIntAttribute("blue");t.addMapping(e,s,r,o)}}}getRules(t){const e=this.getNode(t),i=new jt;for(const t of e.getNodes("rule")){const e=[];for(const i of t.getNodes("pv"))e.push({pvName:i.getTextContent(),trigger:i.getBooleanAttribute("trig")});const s=[];for(const e of t.getNodes("exp")){e.getNode("value").hasNode("color")?s.push({type:"color",expression:e.getStringAttribute("bool_exp"),outputValue:e.getColor("value")}):s.push({type:"string",expression:e.getStringAttribute("bool_exp"),outputValue:e.getString("value")})}i.rules.push({name:t.getStringAttribute("name"),propertyName:t.getStringAttribute("prop_id"),outputExpression:t.getBooleanAttribute("out_exp"),inputs:e,expressions:s})}return i}getMacros(t){const e=this.getNode(t),i=new gl;i.includeParentMacros=e.getBoolean("include_parent_macros");for(const t of e.getNodes())"include_parent_macros"!==t.name&&i.set(t.name,e.getString(t.name));return i}getActions(t){const e=this.getNode(t),i=new Wt;i.hookFirstActionToClick=e.getBooleanAttribute("hook"),i.hookAllActionsToClick=e.getBooleanAttribute("hook_all",!1);for(const t of e.getNodes("action")){const e=t.getStringAttribute("type");if("OPEN_DISPLAY"===e){const e=new Bt(t.getString("path"));t.hasNode("mode")&&(e.mode=t.getInt("mode")),e.description=t.getString("description"),i.add(e)}else if("OPEN_FILE"===e){const e=new It;e.path=t.getString("path"),e.description=t.getString("description"),i.add(e)}else if("EXECUTE_CMD"===e){const e=new Ht;e.command=t.getString("command"),e.commandDirectory=t.getString("command_directory"),e.waitTime=t.getInt("wait_time"),e.description=t.getString("description"),i.add(e)}else if("EXECUTE_JAVASCRIPT"===e){const e=new Ot(t.getBoolean("embedded"));e.embedded?e.text=t.getString("scriptText"):e.path=t.getString("path"),e.description=t.getString("description"),i.add(e)}else if("WRITE_PV"===e){const e=new Ft(t.getString("pv_name"),t.getString("value"));e.confirmMessage=t.getString("confirm_message",""),e.description=t.getString("description"),i.add(e)}else if("PLAY_SOUND"===e){const e=new Nt;e.path=t.getString("path"),e.description=t.getString("description"),i.add(e)}else if("OPEN_WEBPAGE"===e){const e=new Dt;e.hyperlink=t.getString("hyperlink"),e.description=t.getString("description"),i.add(e)}else console.warn(`Unsupported action type ${e}`),i.add(null)}return i}parseColorNode(t){const i=t.getIntAttribute("red"),s=t.getIntAttribute("green"),r=t.getIntAttribute("blue");return new e(i,s,r)}findChild(t){for(let e=0;e<this.node.childNodes.length;e++){const i=this.node.childNodes[e];if(i.nodeName===t)return i}throw new Error(`No child node named ${t} could be found`)}}let wl=0;const yl="group_name",vl="opi_file",bl="resize_behaviour";class Tl extends Ga{constructor(t,e){super(t,e),this.properties.add(new D(yl)),this.properties.add(new D(vl)),this.properties.add(new $(bl,0))}parseNode(t){super.parseNode(t);const e=wl++;this.macros.set("LCID",`LCID_${e}`)}init(){this.opiFile&&fetch(this.display.baseUrl+this.opiFile,{credentials:"same-origin"}).then((t=>{t.ok&&t.text().then((t=>{this.linkedDisplay=new cl(this.display,this);const e=fl.parseFromXML(t);this.linkedDisplay.parseNode(e),this.requestRepaint()}))}))}draw(t){this.transparent||t.fillRect(Object.assign(Object.assign({},this.area),{color:this.backgroundColor}));const e=this.getLinkedWidget();if(this.linkedDisplay&&e)if(t.fillRect(Object.assign(Object.assign({},this.area),{color:this.linkedDisplay.backgroundColor})),0===this.resizeBehavior){const e=this.linkedDisplay.measureContentBounds(!1);let{width:i,height:s}=e;const r=this.display.scale;i*=r,s*=r;const o=i/s;let h=this.width,n=h/o,a=h/i;n>this.height&&(n=this.height,h=n*o,a=n/i),this.linkedDisplay.relativeScale=a;const l=t.createChild(Math.ceil(h),Math.ceil(n));l.translate(e.x,e.y),this.linkedDisplay.draw(l),t.copy(l,this.x,this.y)}else if(1===this.resizeBehavior)console.warn("Unsupported resize behavior of LinkingContainer",this.resizeBehavior);else if(2===this.resizeBehavior){const e=this.linkedDisplay.measureContentBounds(!0),i=t.createChild(e.width,e.height);i.translate(e.x,e.y),this.linkedDisplay.draw(i),t.copy(i,this.x,this.y)}else 3===this.resizeBehavior&&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(vl)}get groupName(){return this.properties.getValue(yl)}get resizeBehavior(){return this.properties.getValue(bl)}}const Sl="minimum_tab_height",Vl="active_tab",Al="horizontal_tabs",_l="tab_count";class Ll{constructor(t,e){this.widget=t,this.i=e,this.headerRegion={id:`${t.wuid}-header-${e}`,click:()=>{t.activeTab!==e&&(t.properties.setValue(Vl,e),t.requestRepaint())},cursor:"pointer"}}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)}}class Cl extends Ga{constructor(t,e){super(t,e),this.tabs=[],this.properties.add(new $(Sl)),this.properties.add(new $(Vl)),this.properties.add(new z(Al)),this.properties.add(new $(_l)),this.properties.addGenerator((()=>{this.tabs=[];const t=this.properties.getValue(_l),e=[];for(let i=0;i<t;i++)this.tabs.push(new Ll(this,i)),e.push(new D(`tab_${i}_title`),new U(`tab_${i}_background_color`),new U(`tab_${i}_foreground_color`),new z(`tab_${i}_enabled`),new q(`tab_${i}_font`));return e}))}parseNode(t){super.parseNode(t);for(const e of t.getNodes("widget")){const t=e.getString("widget_type"),i=this.display.createWidget(t,this);i&&(i.parseNode(e),this.widgets.push(i))}}draw(t){this.horizontalTabs?this.drawHorizontalTabs(t):this.drawVerticalTabs(t)}measureTabOffset(t){return this.horizontalTabs?{x:0,y:this.measureLabelHeight(t)}:{x:this.measureLabelWidth(t),y:0}}measureLabelHeight(t){const{scale:e}=this,i=1*e;let s=this.minimumTabHeight;for(let e=0;e<this.tabs.length;e++){const r=this.tabs[e],o=t.measureText(r.title,r.font).height+i;o>s&&(s=o)}return s+this.margin}measureLabelWidth(t){const{scale:e}=this,i=1*e;let s=this.minimumTabWidth;for(let e=0;e<this.tabs.length;e++){const r=this.tabs[e],o=t.measureText(r.title,r.font).width+i;o>s&&(s=o)}return s+this.margin}drawHorizontalTabs(t){const{margin:i,gap:s,scale:r}=this,o=this.measureLabelHeight(t),h=1*r;let n=this.x;for(let a=0;a<this.tabs.length;a++){const l=this.tabs[a],d=t.measureText(l.title,l.font);let c,p,g,u,m;this.activeTab===a?(c=n,p=this.y,g=d.width+h+i+s,u=o,m=l.backgroundColor):(c=n+s,p=this.y+2*r,g=d.width+h+i-s,u=o-2*r,m=this.darken(l.backgroundColor)),t.fillRect({x:c,y:p,width:g,height:u,color:m});t.addHitRegion(l.headerRegion).addRect(c,p,g,u);const x=t.createLinearGradient(c,p,c,p+u);if(x.addColorStop(0,e.WHITE.toString()),x.addColorStop(1,e.WHITE.withAlpha(0).toString()),t.fillRect({x:c,y:p,width:g,height:u,gradient:x}),t.fillText({x:c+g/2,y:p+u/2,baseline:"middle",align:"center",font:l.font,color:l.foregroundColor,text:l.title}),n+=d.width+h+i-1*r,this.activeTab===a){const e=this.x,i=this.y+o,s=this.width,r=this.height-o;t.fillRect({x:e,y:i,width:s,height:r,color:l.backgroundColor});const h=this.widgets[a],n=t.createChild(s,r);h.drawHolder(n),h.draw(n),h.drawDecoration(n),h.drawOverlay(n),t.copy(n,e,i)}else{this.widgets[a].hide()}}}drawVerticalTabs(t){const{margin:i,gap:s,scale:r}=this,o=this.measureLabelWidth(t),h=1*r;let n=this.y;for(let a=0;a<this.tabs.length;a++){const l=this.tabs[a],d=t.measureText(l.title,l.font),c=Math.max(d.height+h+h,this.minimumTabHeight);let p,g,u,m,x;this.activeTab===a?(p=this.x,g=n,u=o,m=c+i+s,x=l.backgroundColor):(p=this.x+2*r,g=n+s,u=o-2*r,m=c+i-s,x=this.darken(l.backgroundColor)),t.fillRect({x:p,y:g,width:u,height:m,color:x});t.addHitRegion(l.headerRegion).addRect(p,g,u,m);const f=t.createLinearGradient(p,g,p+u,g);if(f.addColorStop(0,e.WHITE.toString()),f.addColorStop(1,e.WHITE.withAlpha(0).toString()),t.fillRect({x:p,y:g,width:u,height:m,gradient:f}),t.fillText({x:p+u/2,y:g+m/2,baseline:"middle",align:"center",font:l.font,color:l.foregroundColor,text:l.title}),n+=c+i-1*r,this.activeTab===a){const e=this.x+o-1*r,i=this.y,s=this.width-o,h=this.height-1*r;t.fillRect({x:e,y:i,width:s,height:h,color:l.backgroundColor});const n=this.widgets[a],d=t.createChild(s,h);n.drawHolder(d),n.draw(d),n.drawDecoration(d),n.drawOverlay(d),t.copy(d,e,i)}else{this.widgets[a].destroy()}}}darken(t){const i=Math.max(0,t.red-30),s=Math.max(0,t.green-30),r=Math.max(0,t.blue-30);return new e(i,s,r)}get margin(){return 10*this.scale}get gap(){return 2*this.scale}get minimumTabWidth(){return 20*this.scale}get minimumTabHeight(){return this.scale*this.properties.getValue(Sl)}get activeTab(){return this.properties.getValue(Vl)}get tabCount(){return this.properties.getValue(_l)}get horizontalTabs(){return this.properties.getValue(Al)}}class Pl extends ge{constructor(t,e){super(t,e),this.properties.add(new D("url"))}init(){this.iframe=document.createElement("iframe"),this.iframe.src="https://yamcs.org",this.iframe.style.display="none",this.iframe.style.border="0",this.display.rootPanel.appendChild(this.iframe)}draw(t){if(this.iframe){const{x:t,y:e,width:i,height:s}=this.display.measureAbsoluteArea(this);this.iframe.style.position="absolute",this.iframe.style.display="block",this.iframe.style.left=`${t}px`,this.iframe.style.top=`${e}px`,this.iframe.style.width=`${i}px`,this.iframe.style.height=`${s}px`,this.url&&this.prevUrl!==this.url&&(this.iframe.src=this.url,this.prevUrl=this.url)}}hide(){this.iframe&&(this.iframe.style.display="none")}destroy(){this.iframe&&(this.display.rootPanel.removeChild(this.iframe),this.iframe=void 0)}get url(){return this.properties.getValue("url")}}t.CompiledFormula=V,t.DefaultImageResolver=S,t.Display=class{constructor(t){this.targetElement=t,this.repaintRequested=!1,this._editMode=!1,this._showGrid=!1,this._showOutline=!1,this._showRuler=!1,this._selection=[],this._scale=1,this._transparent=!1,this.imagesPrefix="",this.baseUrl="",this.eventListeners={closedisplay:[],opendisplay:[],openpv:[],selection:[],scale:[]},this.rootPanel=document.createElement("div"),this.rootPanel.className="display-root",this.rootPanel.style.overflow="hidden",this.rootPanel.style.position="relative",this.rootPanel.style.fontSize="0",t.appendChild(this.rootPanel);const e=document.createElement("canvas");this.rootPanel.appendChild(e),this.g=new v(e),this.ctx=this.g.ctx,this.pvEngine=new Tt(this),this.pvEngine.addProvider(new Rt),this.pvEngine.addProvider(new P),this.displayRegion={id:"display-root",click:()=>this.closeMenu()},this.imageResolver=new S(this),window.requestAnimationFrame((()=>this.step())),new o(this,e,this.g.hitCanvas)}addProvider(t){this.pvEngine.addProvider(t)}addScriptLibrary(t,e){this.pvEngine.addScriptLibrary(t,e)}setImageResolver(t){this.imageResolver=t}getImageResolver(){return this.imageResolver}step(){this.repaintRequested&&(this.g.clearHitCanvas(),this.drawScreen(),this.repaintRequested=!1),window.requestAnimationFrame((()=>this.step()))}drawScreen(){var t;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){const 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(Object.assign(Object.assign({},this.instance.bounds),{color:this.instance.backgroundColor}))}else this.transparent||this.g.fillCanvas((null===(t=this.instance)||void 0===t?void 0:t.backgroundColor)||e.WHITE);if(this.g.addHitRegion(this.displayRegion).addRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.showGrid&&this.instance){const 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(const t of this.selection){const e=this.findWidget(t);e&&e.drawSelection(this.ctx)}}requestRepaint(){this.repaintRequested=!0}setTooltip(t){var e;this.rootPanel.title=null!==(e=null==t?void 0:t.trim())&&void 0!==e?e:""}closeMenu(){var t;null===(t=this.instance)||void 0===t||t.closeMenu()}createWidget(t,e){switch(t){case"Action Button":return new ye(this,e);case"Arc":return new ds(this,e);case"Boolean Button":return new Be(this,e);case"Boolean Switch":return new qe(this,e);case"Byte Monitor":return new _r(this,e);case"Check Box":return new ti(this,e);case"Choice Button":return new ni(this,e);case"Combo":case"Combo Box":return new gi(this,e);case"Ellipse":return new vs(this,e);case"Gauge":return new Yr(this,e);case"Grouping Container":return new pl(this,e);case"Image":return new Vs(this,e);case"Image Boolean Button":return new Li(this,e);case"Image Boolean Indicator":return new io(this,e);case"Intensity Graph":return new Oo(this,e);case"Label":return new Ps(this,e);case"LED":return new Jo(this,e);case"Linking Container":return new Tl(this,e);case"Meter":return new Th(this,e);case"Button":return new Ci(this,e);case"Polygon":return new Os(this,e);case"Polyline":return new Us(this,e);case"Progress Bar":return new rn(this,e);case"Radio Box":return new Oi(this,e);case"Rectangle":return new ir(this,e);case"Rounded Rectangle":return new ur(this,e);case"Scrollbar":return new Ki(this,e);case"Tabbed Container":return new Cl(this,e);case"Tank":return new En(this,e);case"Text Input":return new ss(this,e);case"Text Update":return new Nn(this,e);case"Thermometer":return new ya(this,e);case"Web Browser":return new Pl(this,e);case"XY Graph":return new ja(this,e);default:console.warn(`Unsupported widget type: ${t}`)}}destroy(){var t;null===(t=this.instance)||void 0===t||t.destroy(),this.instance=void 0,this.pvEngine.clearState(),this.requestRepaint()}setSource(t){return this.reset(),new Promise(((e,i)=>{fetch(this.baseUrl+t,{credentials:"same-origin"}).then((t=>{t.ok&&t.text().then((t=>{this.setSourceString(t),e()})).catch((t=>i(t)))})).catch((t=>i(t)))}))}setSourceString(t){this.reset(),this.instance=new cl(this);const e=fl.parseFromXML(t);this.instance.parseNode(e),this.requestRepaint()}reset(){this.instance&&(this.clearSelection(),this.pvEngine.clearState(),this.instance.destroy(),this.instance=void 0)}measureAbsoluteArea(t){const e=t.bounds;let i=t.parent;for(;i;){if(e.x+=i.holderX,e.y+=i.holderY,i instanceof Cl){const{x:t,y:s}=i.measureTabOffset(this.g);e.x+=t,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+=1*this.scale,e.y+=1*this.scale,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((t=>t!==e))}fireEvent(t,e){this.eventListeners[t].forEach((t=>t(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();const 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();const e={scale:t};this.fireEvent("scale",e)}get transparent(){return this._transparent}set transparent(t){this._transparent=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.setValues(t)}copyCanvas(t){t||(t={x:0,y:0,width:this.g.canvas.width,height:this.g.canvas.height});const 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)}},t.FormulaCompiler=C,t.PV=ft,Object.defineProperty(t,"__esModule",{value:!0})}));
2
2
  //# sourceMappingURL=opi.umd.js.map