@mxtommy/kip 4.8.1 → 4.8.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 (69) hide show
  1. package/CHANGELOG.md +17 -3
  2. package/package.json +27 -4
  3. package/public/{chunk-Bp0MQwPM.js → chunk-07zHjmg-.js} +1 -1
  4. package/public/{chunk-AANk-NXH.js → chunk-0z3nIRXw.js} +3 -3
  5. package/public/{chunk-sNakMDHi.js → chunk-B09jfNia.js} +1 -1
  6. package/public/{chunk-DDqeRiB0.js → chunk-B0D54iJs.js} +1 -1
  7. package/public/{chunk-BwOIef42.js → chunk-B0eE4udE.js} +1 -1
  8. package/public/{chunk-BX6skw5k.js → chunk-B9nVBlGj.js} +1 -1
  9. package/public/{chunk-C2VQxCXa.js → chunk-BFpzxIIT.js} +1 -1
  10. package/public/{chunk-Dxlia2NE.js → chunk-BIb-xYiS.js} +1 -1
  11. package/public/{chunk-dgaOX1wC.js → chunk-BJ-wyixK.js} +1 -1
  12. package/public/chunk-BLEZOsfR.js +1 -0
  13. package/public/{chunk-CNMFlw_H.js → chunk-BN7A4g6c.js} +1 -1
  14. package/public/{chunk-By8ZVvDx.js → chunk-BTOTKeBo.js} +1 -1
  15. package/public/{chunk-BoNDCNGE.js → chunk-BUguZ7cK.js} +1 -1
  16. package/public/{chunk-DE4ylhpq.js → chunk-BZx964-p.js} +1 -1
  17. package/public/{chunk-CNNTuNlM.js → chunk-BeM64etA.js} +1 -1
  18. package/public/chunk-BfiyH3nV.js +1 -0
  19. package/public/{chunk-Ii9n-oiL.js → chunk-BjINKQ03.js} +1 -1
  20. package/public/{chunk-MjWuPUhu.js → chunk-BpcNrtxJ.js} +1 -1
  21. package/public/{chunk-CkXTl3su.js → chunk-BuvyF0y5.js} +1 -1
  22. package/public/{chunk-BKj60jdq.js → chunk-C6b8CVno.js} +1 -1
  23. package/public/{chunk-hd2_AKwt.js → chunk-CCfhzpE8.js} +1 -1
  24. package/public/{chunk-nu4vZg-z.js → chunk-CHAFm_nM.js} +1 -1
  25. package/public/{chunk-5U8d2Ygo.js → chunk-CIGP2YJm.js} +1 -1
  26. package/public/{chunk-JbEkcxJm.js → chunk-CLTHuhlN.js} +1 -1
  27. package/public/{chunk-CwSa_BNV.js → chunk-CLs_NL1y.js} +1 -1
  28. package/public/{chunk-DNS-qsFC.js → chunk-COI6IBXH.js} +1 -1
  29. package/public/{chunk-CpuB_ZZz.js → chunk-CQMVIDcp.js} +1 -1
  30. package/public/{chunk-00hwknVI.js → chunk-CXvWM_vF.js} +1 -1
  31. package/public/{chunk-BdokyhBM.js → chunk-CYYBxjrc.js} +1 -1
  32. package/public/{chunk-DzTTqoF_.js → chunk-C_OZJltF.js} +1 -1
  33. package/public/{chunk-DQnoPLyC.js → chunk-Co2wVrD6.js} +1 -1
  34. package/public/{chunk-CXvG8mMq.js → chunk-CoCQ3DW2.js} +1 -1
  35. package/public/{chunk-DchvLV_Y.js → chunk-CxPx4NZv.js} +1 -1
  36. package/public/{chunk-CA6RRaxd.js → chunk-CyVRpGoJ.js} +1 -1
  37. package/public/{chunk-CL2xiH57.js → chunk-D-_-GUVr.js} +1 -1
  38. package/public/{chunk-C6UXF7BI.js → chunk-D1HYfaL_.js} +1 -1
  39. package/public/{chunk-DjZgzSiH.js → chunk-D2953Rfp.js} +1 -1
  40. package/public/{chunk-BJz7Ij9E.js → chunk-DIl1k00y.js} +1 -1
  41. package/public/{chunk-B6bEhzNR.js → chunk-DPnbM-aB.js} +1 -1
  42. package/public/{chunk-CIlfzV9R.js → chunk-DTN-sa1K.js} +1 -1
  43. package/public/{chunk-BOAD0N2a.js → chunk-DUEKoZhd.js} +1 -1
  44. package/public/{chunk-DumLX5k_.js → chunk-DmkAKXR1.js} +1 -1
  45. package/public/chunk-Do8wqING.js +1 -0
  46. package/public/{chunk-DXkKj21H.js → chunk-JhFkJS7i.js} +1 -1
  47. package/public/{chunk-B82ADJSs.js → chunk-OeQDZKFO.js} +1 -1
  48. package/public/{chunk-PheXEqie.js → chunk-_zRMMvCu.js} +1 -1
  49. package/public/{chunk-CrBxxZCe.js → chunk-eQ1pa34Q.js} +1 -1
  50. package/public/{chunk-D4xZ2tGB.js → chunk-ibauGmSP.js} +1 -1
  51. package/public/{chunk-VgxMqRPk.js → chunk-otzyItXL.js} +1 -1
  52. package/public/{chunk-BQr-tSkv.js → chunk-q9NoPvcx.js} +1 -1
  53. package/public/{chunk-DWLISAZi.js → chunk-szQs8fiq.js} +1 -1
  54. package/public/{chunk-tAiV3ARh.js → chunk-x7L6DXVK.js} +1 -1
  55. package/public/index.html +1 -1
  56. package/public/{main-BAV5VDOD.js → main-YKDNK5VZ.js} +20 -20
  57. package/plugin/history-series.service.js +0 -637
  58. package/plugin/index.js +0 -1322
  59. package/plugin/kip-series-contract.js +0 -31
  60. package/plugin/openApi.json +0 -855
  61. package/plugin/sqlite-history-storage.service.js +0 -1124
  62. package/plugin/src/history-series.service.js +0 -634
  63. package/plugin/src/index.js +0 -1322
  64. package/plugin/src/kip-series-contract.js +0 -31
  65. package/plugin/src/openApi.json +0 -855
  66. package/plugin/src/sqlite-history-storage.service.js +0 -1122
  67. package/public/chunk-Blokg6Ds.js +0 -1
  68. package/public/chunk-CpMCBDvH.js +0 -1
  69. package/public/chunk-y1imvaA-.js +0 -1
@@ -1,2 +1,2 @@
1
- import {f}from'./chunk-H9_eqTYx.js';import {u}from'./chunk-hd2_AKwt.js';import {d1 as Hj,w,du as p,dv as rt,a as G,cu as T,aR as lt$1,aZ as F,v as vt,D as Dt,aH as j,F as Fa,dn as ge$1,cw as z,cv as G$1,J as JD,dC as x,dT as wg,_ as _w,P as Pi,k as Qh,X as xw,cs as Sw,u as ul,dU as NT,e as EE,M as Mw,t as pT,Y as Aw,dV as Vj,cn as wd,ci as dl,dW as Zh,cp as Uh,cj as fl,cV as Td,T as TT,an as Hh,d as ig,bp as gl,bs as dp,c as $h,g as qw,dX as xT,B as Bh,cS as pl,cT as hl,h as Fw,l as ud,m as dd}from'./main-BAV5VDOD.js';import {c}from'./chunk-Dxlia2NE.js';function ye(i){return Math.max(i,1)/35}function v(i,u,o){let e=Math.max(u,0),t=ye(o),n=i==="2"?0:48*t,l=i==="2"?12*t:6*t,d=i==="2"?12*t:n,C=Math.max(0,e-d-l);return {labelX:d,labelWidth:C,labelFontSize:14*t,shapeLaneWidth:n,switchTrackX:6*t,switchTrackY:6*t,switchTrackWidth:37.714306*t,switchTrackHeight:22*t,switchTrackRadius:11*t,switchKnobOffX:17.5*t,switchKnobOnX:32.5*t,switchKnobY:17*t,switchKnobRadius:10*t,switchStrokeWidth:1.5*t,lightCenterX:24.5*t,lightCenterY:17.5*t,lightRadius:13.5*t,lightStrokeWidth:3*t,buttonX:6*t,buttonY:5*t,buttonWidth:Math.max(0,e-12*t),buttonHeight:25.025183*t,buttonRadius:3.6672263*t}}function ge(i,u,o,e){if(o.length===0)return 0;let t=Math.max(1,Math.floor(u/o.length)),n=1,l=t,d=1;for(;n<=l;){let C=Math.floor((n+l)/2);if(o.every(w=>{let L=v(w.type,i,C);return e(w.ctrlLabel??"",L.labelFontSize)<=L.labelWidth})){d=C,n=C+1;continue}l=C-1;}return Math.min(d,t)}var fe=(()=>{class i{data=Hj(null,{alias:"controlData"});theme=Hj(null);dimensions=Hj.required();toggleClick=Vj();ctrlState=null;ctrlColor="";oldTheme=null;offColor=null;labelColor=null;valueColor=null;constructor(){}ngDoCheck(){let o=this.data();if(!o)return;o.value!=this.ctrlState&&(this.ctrlState=o.value),o.color!=this.ctrlColor&&(this.ctrlColor=o.color,this.getColors(o.color));let e=this.theme();this.oldTheme!=e&&(this.oldTheme=e,this.getColors(o.color));}toggle(o){let e=this.data();e&&(e.value=o,this.toggleClick.emit(e));}get layout(){let o=this.dimensions();return v("3",o.width,o.height)}get isEnabled(){return !!this.ctrlState}getColors(o){let e=this.theme();if(e)switch(o){case "contrast":this.offColor=e.contrastDimmer,this.labelColor=e.contrastDim,this.valueColor=e.contrast;break;case "blue":this.offColor=e.blueDimmer,this.labelColor=e.blueDim,this.valueColor=e.blue;break;case "green":this.offColor=e.greenDimmer,this.labelColor=e.greenDim,this.valueColor=e.green;break;case "pink":this.offColor=e.pinkDimmer,this.labelColor=e.pinkDim,this.valueColor=e.pink;break;case "orange":this.offColor=e.orangeDimmer,this.labelColor=e.orangeDim,this.valueColor=e.orange;break;case "purple":this.offColor=e.purpleDimmer,this.labelColor=e.purpleDim,this.valueColor=e.purple;break;case "grey":this.offColor=e.greyDimmer,this.labelColor=e.greyDim,this.valueColor=e.grey;break;case "yellow":this.offColor=e.yellowDimmer,this.labelColor=e.yellowDim,this.valueColor=e.yellow;break;default:this.offColor=e.contrastDimmer,this.labelColor=e.contrastDim,this.valueColor=e.contrast;break}}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=JD({type:i,selectors:[["app-svg-boolean-light"]],inputs:{data:[1,"controlData","data"],theme:[1,"theme"],dimensions:[1,"dimensions"]},outputs:{toggleClick:"toggleClick"},decls:21,vars:33,consts:[["version","1.1","id","svg9","xmlns","http://www.w3.org/2000/svg",0,"xmlns","svg","http://www.w3.org/2000/svg"],["id","defs1"],["id","lightSpecular","cx","36%","cy","32%","r","68%"],["offset","0","stop-color","#ffffff","stop-opacity","0.5"],["offset","0.55","stop-color","#ffffff","stop-opacity","0.16"],["offset","1","stop-color","#ffffff","stop-opacity","0"],["id","lightDepth","cx","68%","cy","70%","r","68%"],["offset","0","stop-color","#000000","stop-opacity","0"],["offset","0.62","stop-color","#000000","stop-opacity","0.05"],["offset","1","stop-color","#000000","stop-opacity","0.22"],["id","lightRim","x1","0","y1","0","x2","1","y2","1"],["offset","0","stop-color","#ffffff","stop-opacity","0.36"],["offset","0.45","stop-color","#ffffff","stop-opacity","0.09"],["offset","1","stop-color","#000000","stop-opacity","0.3"],["y","0"],["xmlns","http://www.w3.org/1999/xhtml",2,"width","100%","height","100%","display","flex","align-items","center","justify-content","flex-start","font-family","Roboto,sans-serif","font-weight","700","line-height","1","white-space","nowrap","overflow","hidden","text-overflow","clip"],[2,"stroke","url(#lightRim)","stroke-opacity","0.4","stroke-dasharray","none"],["fill","url(#lightSpecular)"],["fill","url(#lightDepth)"],["fill","#ffffff"]],template:function(e,t){e&1&&(wd(),dl(0,"svg",0)(1,"defs",1)(2,"radialGradient",2),Uh(3,"stop",3)(4,"stop",4)(5,"stop",5),fl(),dl(6,"radialGradient",6),Uh(7,"stop",7)(8,"stop",8)(9,"stop",9),fl(),dl(10,"linearGradient",10),Uh(11,"stop",11)(12,"stop",12)(13,"stop",13),fl()(),dl(14,"foreignObject",14),Td(),dl(15,"div",15),TT(16),fl()(),wd(),Uh(17,"circle",16)(18,"circle",17)(19,"circle",18)(20,"ellipse",19),fl()),e&2&&(Hh("height",t.dimensions().height)("width",t.dimensions().width)("viewBox","0 0 "+t.dimensions().width+" "+t.dimensions().height),EE(14),Hh("x",t.layout.labelX)("width",t.layout.labelWidth)("height",t.dimensions().height),EE(),ig("color",t.isEnabled?t.valueColor:t.labelColor)("opacity",t.isEnabled?1:.6)("font-size",t.layout.labelFontSize,"px")("text-shadow",t.isEnabled?"0 0 4px currentColor, 0 0 4px currentColor":"none"),EE(),gl(" ",t.data()?.ctrlLabel," "),EE(),Hh("cx",t.layout.lightCenterX)("cy",t.layout.lightCenterY)("r",t.layout.lightRadius)("fill",t.isEnabled?t.valueColor:t.offColor)("stroke-width",t.layout.lightStrokeWidth),EE(),Hh("cx",t.layout.lightCenterX)("cy",t.layout.lightCenterY)("r",t.layout.lightRadius)("opacity",t.isEnabled?.62:.42),EE(),Hh("cx",t.layout.lightCenterX)("cy",t.layout.lightCenterY)("r",t.layout.lightRadius)("opacity",t.isEnabled?.62:.48),EE(),Hh("cx",t.layout.lightCenterX-t.layout.lightRadius*.32)("cy",t.layout.lightCenterY-t.layout.lightRadius*.34)("rx",t.layout.lightRadius*.34)("ry",t.layout.lightRadius*.2)("opacity",t.isEnabled?.2:.12));},encapsulation:2})}return i})();var Ce=(()=>{class i{data=Hj(null,{alias:"controlData"});theme=Hj(null);dimensions=Hj.required();toggleClick=Vj();oldTheme=null;emitIntervalId=null;pressed=false;isSwiping=false;pointerStartX=0;pointerStartY=0;labelColorEnabled=null;labelColorDisabled=null;valueColor=null;ctrlColor="";ngDoCheck(){let o=this.data();if(!o)return;o.color!=this.ctrlColor&&(this.ctrlColor=o.color,this.getColors(o.color));let e=this.theme();this.oldTheme!=e&&(this.oldTheme=e,this.getColors(o.color));}handleClickDown(o){let e=this.data();if(!e)return;this.isSwiping=false,this.pointerStartX=o.clientX,this.pointerStartY=o.clientY,this.clearTimers(),this.pressed=true;let t=dp(e);t.value=this.pressed,this.toggleClick.emit(t),this.emitIntervalId=setInterval(()=>{this.toggleClick.emit(t);},100);}handlePointerMove(o){let e=Math.abs(o.clientX-this.pointerStartX),t=Math.abs(o.clientY-this.pointerStartY);(e>30||t>30)&&(this.isSwiping=true,this.pressed=false,this.clearTimers());}handleClickUp(){this.isSwiping&&(this.isSwiping=false),this.pressed=false,this.clearTimers();}handlePointerCancel(){this.isSwiping=false,this.pressed=false,this.clearTimers();}get layout(){let o=this.dimensions();return v("2",o.width,o.height)}get isPressed(){return this.pressed}getColors(o){let e=this.theme();if(e)switch(o){case "contrast":this.labelColorEnabled="black",this.labelColorDisabled=e.contrastDim,this.valueColor=e.contrast;break;case "blue":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.blueDim,this.valueColor=e.blue;break;case "green":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.greenDim,this.valueColor=e.green;break;case "pink":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.pinkDim,this.valueColor=e.pink;break;case "orange":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.orangeDim,this.valueColor=e.orange;break;case "purple":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.purpleDim,this.valueColor=e.purple;break;case "grey":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.greyDim,this.valueColor=e.grey;break;case "yellow":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.yellowDim,this.valueColor=e.yellow;break;default:this.labelColorEnabled="black",this.labelColorDisabled=e.contrastDim,this.valueColor=e.contrast;break}}clearTimers(){this.emitIntervalId&&(clearInterval(this.emitIntervalId),this.emitIntervalId=null);}ngOnDestroy(){this.clearTimers();}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=JD({type:i,selectors:[["app-svg-boolean-button"]],inputs:{data:[1,"controlData","data"],theme:[1,"theme"],dimensions:[1,"dimensions"]},outputs:{toggleClick:"toggleClick"},decls:6,vars:19,consts:[["version","1.1","id","svg9","xmlns","http://www.w3.org/2000/svg",0,"xmlns","svg","http://www.w3.org/2000/svg",3,"pointerup","pointerleave","pointerdown","pointermove","pointercancel"],["x","0","y","0","pointer-events","all",2,"display","inline","opacity","1","fill","transparent","fill-opacity","1","stroke","none","stroke-width","0"],[2,"display","inline","mix-blend-mode","normal","stroke","black","stroke-width","1.5","stroke-opacity","0.2"],["y","0",2,"pointer-events","none"],["xmlns","http://www.w3.org/1999/xhtml",2,"width","100%","height","100%","display","flex","align-items","center","justify-content","center","font-family","Roboto,sans-serif","font-weight","700","line-height","1","white-space","nowrap","overflow","hidden","text-overflow","clip"]],template:function(e,t){e&1&&(wd(),dl(0,"svg",0),Zh("pointerup",function(){return t.handleClickUp()})("pointerleave",function(){return t.handleClickUp()})("pointerdown",function(l){return t.handleClickDown(l)})("pointermove",function(l){return t.handlePointerMove(l)})("pointercancel",function(){return t.handlePointerCancel()}),Uh(1,"rect",1)(2,"rect",2),dl(3,"foreignObject",3),Td(),dl(4,"div",4),TT(5),fl()()()),e&2&&(Hh("height",t.dimensions().height)("width",t.dimensions().width)("viewBox","0 0 "+t.dimensions().width+" "+t.dimensions().height),EE(),Hh("width",t.dimensions().width)("height",t.dimensions().height),EE(),Hh("x",t.layout.buttonX)("y",t.layout.buttonY)("width",t.layout.buttonWidth)("height",t.layout.buttonHeight)("rx",t.layout.buttonRadius)("fill",t.isPressed?t.valueColor:t.labelColorDisabled),EE(),Hh("x",t.layout.labelX)("width",t.layout.labelWidth)("height",t.dimensions().height),EE(),ig("color",t.isPressed?t.labelColorEnabled:t.labelColorDisabled)("font-size",t.layout.labelFontSize,"px"),EE(),gl(" ",t.data()?.ctrlLabel," "));},encapsulation:2})}return i})();var be=(()=>{class i{data=Hj(null,{alias:"controlData"});theme=Hj(null);dimensions=Hj.required();toggleClick=Vj();ctrlState=null;oldTheme=null;swipeGuard=f();offColor=null;labelColor=null;valueColor=null;ctrlColor="";constructor(){}ngDoCheck(){let o=this.data();if(!o)return;o.value!=this.ctrlState&&(this.ctrlState=o.value),o.color!=this.ctrlColor&&(this.ctrlColor=o.color,this.getColors(o.color));let e=this.theme();this.oldTheme!=e&&(this.oldTheme=e,this.getColors(o.color));}onPointerDown(o){this.swipeGuard.onPointerDown(o);}onPointerMove(o){this.swipeGuard.onPointerMove(o);}onPointerUp(o,e){this.swipeGuard.onPointerUp(o)&&this.toggle(e);}onPointerCancel(o){this.swipeGuard.onPointerCancel(o);}get layout(){let o=this.dimensions();return v("1",o.width,o.height)}get isEnabled(){return !!this.ctrlState}get nextState(){return !this.isEnabled}toggle(o){let e=this.data();e&&(e.value=o,this.toggleClick.emit(e));}getColors(o){let e=this.theme();if(e)switch(o){case "contrast":this.offColor=e.contrastDimmer,this.labelColor=e.contrastDim,this.valueColor=e.contrast;break;case "blue":this.offColor=e.blueDimmer,this.labelColor=e.blueDim,this.valueColor=e.blue;break;case "green":this.offColor=e.greenDimmer,this.labelColor=e.greenDim,this.valueColor=e.green;break;case "pink":this.offColor=e.pinkDimmer,this.labelColor=e.pinkDim,this.valueColor=e.pink;break;case "orange":this.offColor=e.orangeDimmer,this.labelColor=e.orangeDim,this.valueColor=e.orange;break;case "purple":this.offColor=e.purpleDimmer,this.labelColor=e.purpleDim,this.valueColor=e.purple;break;case "grey":this.offColor=e.greyDimmer,this.labelColor=e.greyDim,this.valueColor=e.grey;break;case "yellow":this.offColor=e.yellowDimmer,this.labelColor=e.yellowDim,this.valueColor=e.yellow;break;default:this.offColor=e.contrastDimmer,this.labelColor=e.contrastDim,this.valueColor=e.contrast;break}}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=JD({type:i,selectors:[["app-svg-boolean-switch"]],inputs:{data:[1,"controlData","data"],theme:[1,"theme"],dimensions:[1,"dimensions"]},outputs:{toggleClick:"toggleClick"},decls:12,vars:28,consts:[["version","1.1","id","svg9","xmlns","http://www.w3.org/2000/svg",0,"xmlns","svg","http://www.w3.org/2000/svg",3,"pointerdown","pointermove","pointerup","pointercancel"],["id","defs1"],["id","linearGradient32"],["offset","0",2,"stop-color","#000000","stop-opacity","0.88486844"],["offset","1",2,"stop-color","#f7f7f7","stop-opacity","0.17763157"],[0,"xlink","href","#linearGradient32","id","linearGradient33","x1","0","y1","0","x2","1","y2","1"],["x","0","y","0","pointer-events","all",2,"display","inline","opacity","0.001","fill","black","fill-opacity","0.001","stroke","none","stroke-width","0"],["y","0",2,"pointer-events","none"],[2,"width","100%","height","100%","display","flex","align-items","center","justify-content","flex-start","font-family","Roboto,sans-serif","font-weight","700","line-height","1","white-space","nowrap","overflow","hidden","text-overflow","clip"],[2,"stroke-width","1.5","stroke","black","stroke-opacity","0.12"],[2,"stroke","url(#linearGradient33)","stroke-opacity","0.4","stroke-dasharray","none"]],template:function(e,t){e&1&&(wd(),dl(0,"svg",0),Zh("pointerdown",function(l){return t.onPointerDown(l)})("pointermove",function(l){return t.onPointerMove(l)})("pointerup",function(l){return t.onPointerUp(l,t.nextState)})("pointercancel",function(l){return t.onPointerCancel(l)}),dl(1,"defs",1)(2,"linearGradient",2),Uh(3,"stop",3)(4,"stop",4),fl(),Uh(5,"linearGradient",5),fl(),Uh(6,"rect",6),dl(7,"foreignObject",7),Td(),dl(8,"div",8),TT(9),fl()(),wd(),Uh(10,"rect",9)(11,"circle",10),fl()),e&2&&(Hh("height",t.dimensions().height)("width",t.dimensions().width)("viewBox","0 0 "+t.dimensions().width+" "+t.dimensions().height),EE(6),Hh("width",t.dimensions().width)("height",t.dimensions().height),EE(),Hh("x",t.layout.labelX)("width",t.layout.labelWidth)("height",t.dimensions().height),EE(),ig("color",t.isEnabled?t.valueColor:t.labelColor)("opacity",t.isEnabled?1:.6)("font-size",t.layout.labelFontSize,"px")("text-shadow",t.isEnabled?"0 0 4px currentColor, 0 0 4px currentColor":"none"),EE(),gl(" ",t.data()?.ctrlLabel," "),EE(),Hh("x",t.layout.switchTrackX)("y",t.layout.switchTrackY)("width",t.layout.switchTrackWidth)("height",t.layout.switchTrackHeight)("rx",t.layout.switchTrackRadius)("fill",t.isEnabled?t.labelColor:t.offColor),EE(),Hh("cx",t.isEnabled?t.layout.switchKnobOnX:t.layout.switchKnobOffX)("cy",t.layout.switchKnobY)("r",t.layout.switchKnobRadius)("fill",t.isEnabled?t.valueColor:t.offColor)("stroke-width",t.layout.switchStrokeWidth));},encapsulation:2})}return i})();function _e(i,u){if(i&1&&$h(0,"widget-title",1),i&2){let o=qw(),e=xT(0);Bh("text",(e==null?null:e.displayName)??"")("color",o.labelColor());}}function De(i,u){if(i&1){let o=Fw();Pi(0,"app-svg-boolean-switch",5),Qh("toggleClick",function(t){ud(o);let n=qw(2);return dd(n.toggle(t))}),ul();}if(i&2){let o=qw().$implicit,e=qw();Bh("controlData",o)("theme",e.theme())("dimensions",e.ctrlDimensions);}}function Se(i,u){if(i&1){let o=Fw();Pi(0,"app-svg-boolean-button",5),Qh("toggleClick",function(t){ud(o);let n=qw(2);return dd(n.toggle(t))}),ul();}if(i&2){let o=qw().$implicit,e=qw();Bh("controlData",o)("theme",e.theme())("dimensions",e.ctrlDimensions);}}function ke(i,u){if(i&1){let o=Fw();Pi(0,"app-svg-boolean-light",5),Qh("toggleClick",function(t){ud(o);let n=qw(2);return dd(n.toggle(t))}),ul();}if(i&2){let o=qw().$implicit,e=qw();Bh("controlData",o)("theme",e.theme())("dimensions",e.ctrlDimensions);}}function Ee(i,u){if(i&1&&(pl(0),_w(1,De,1,3,"app-svg-boolean-switch",4)(2,Se,1,3,"app-svg-boolean-button",4)(3,ke,1,3,"app-svg-boolean-light",4),hl()),i&2){let o,e=u.$implicit;EE(),Mw((o=e.type)==="1"?1:o==="2"?2:o==="3"?3:-1);}}function Te(i,u){i&1&&$h(0,"div",3);}var lt=(()=>{class i{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={displayName:"Switch Panel Label",showLabel:true,filterSelfPaths:true,paths:[],enableTimeout:false,dataTimeout:5,color:"contrast",zonesOnlyPaths:false,putEnable:true,putMomentary:false,multiChildCtrls:[]};runtime=w(p,{optional:true});streams=w(rt,{optional:true});dashboard=w(G);signalkRequestsService=w(T);toast=w(lt$1);canvas=w(F);switchControls=vt([]);labelColor=vt("");noTitleClass=Dt(()=>this.runtime?.options()?.showLabel===false?"widgets-container-no-title":"widgets-container");nbCtrl=null;ctrlDimensions={width:0,height:0};hostSize={width:0,height:0};skRequestSub=new j;measureCtx=typeof document<"u"?document.createElement("canvas").getContext("2d"):null;constructor(){Fa(()=>{let o=this.theme(),e=this.runtime?.options();!o||!e||ge$1(()=>{this.labelColor.set(c(e.color??"contrast",o).dim);});}),Fa(()=>{let o=this.runtime?.options();if(!o)return;let e=(o.multiChildCtrls||[]).map(t=>z(G$1({},t),{isNumeric:t.isNumeric??false}));this.nbCtrl=e.length,ge$1(()=>{this.switchControls.set(e),this.updateCtrlDimensions();let t=this.streams;t&&e.forEach(n=>{let l=o.paths;if(!l?.length)return;let d=l.findIndex(R=>R.pathID===n.pathID);d<0||!l[d]?.path||t.observe(String(d),R=>{let w=R?.data?.value,L=n.isNumeric?[0,1,null].includes(w)?!!w:n.value:w;this.switchControls.update(E=>{let N=E.findIndex(we=>we.pathID===n.pathID);if(N===-1)return E;let ve=z(G$1({},E[N]),{value:L});return [...E.slice(0,N),ve,...E.slice(N+1)]});});});});});}onResized(o){this.hostSize={width:o.contentRect.width,height:o.contentRect.height},this.updateCtrlDimensions();}updateCtrlDimensions(){let o=this.hostSize.width,e=this.hostSize.height,t=this.switchControls();if(!o||!e||!t.length){this.ctrlDimensions={width:o,height:0};return}let n=this.measureCtx?ge(o,e,t,(l,d)=>(this.measureCtx.font=`700 ${d}px ${this.canvas.DEFAULT_FONT}`,this.measureCtx.measureText(l).width)):Math.max(1,Math.floor(e/t.length));this.ctrlDimensions={width:o,height:n};}toggle(o){let e=this.runtime?.options();if(!e?.putEnable)return;let t=e.paths;if(!t)return;let n=t.findIndex(d=>d.pathID===o.pathID);if(n<0)return;let l=t[n].path;l&&(o.isNumeric?this.signalkRequestsService.putRequest(l,o.value?1:0,this.id()):this.signalkRequestsService.putRequest(l,o.value,this.id()));}ngOnDestroy(){this.skRequestSub?.unsubscribe();}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=JD({type:i,selectors:[["widget-boolean-switch"]],inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:7,vars:5,consts:[["widgetContainer",""],[3,"text","color"],["kipResizeObserver","",3,"resizeChange"],[1,"widgetOverlay"],[1,"svg-widget",3,"controlData","theme","dimensions"],[1,"svg-widget",3,"toggleClick","controlData","theme","dimensions"]],template:function(e,t){if(e&1&&(wg(0),_w(1,_e,1,2,"widget-title",1),Pi(2,"div",2,0),Qh("resizeChange",function(l){return t.onResized(l)}),xw(4,Ee,4,1,"ng-container",null,Sw),ul(),_w(6,Te,1,0,"div",3)),e&2){let n=NT(t.runtime==null?null:t.runtime.options());EE(),Mw(n?.showLabel?1:-1),EE(),pT(t.noTitleClass()),EE(2),Aw(t.switchControls()),EE(2),Mw(t.dashboard.isDashboardStatic()?-1:6);}},dependencies:[u,be,Ce,fe,x],styles:[".widgets-container[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;z-index:20}.widgets-container-no-title[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;padding:3px 0 0;height:100%;width:100%;overflow:hidden;z-index:20}.svg-widget[_ngcontent-%COMP%]{display:flex}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent;z-index:21}"]})}return i})();
1
+ import {f}from'./chunk-H9_eqTYx.js';import {u}from'./chunk-CCfhzpE8.js';import {d1 as Hj,w,du as p,dv as rt,a as G,cu as T,aR as lt$1,aZ as R,v as vt,D as Dt,aH as j,F as Fa,dn as ge$1,cw as z,cv as G$1,J as JD,dC as x,dT as wg,_ as _w,P as Pi,k as Qh,X as xw,cs as Sw,u as ul,dU as NT,e as EE,M as Mw,t as pT,Y as Aw,dV as Vj,cn as wd,ci as dl,dW as Zh,cp as Uh,cj as fl,cV as Td,T as TT,an as Hh,d as ig,bp as gl,bs as dp,c as $h,g as qw,dX as xT,B as Bh,cS as pl,cT as hl,h as Fw,l as ud,m as dd}from'./main-YKDNK5VZ.js';import {c}from'./chunk-BIb-xYiS.js';function ye(i){return Math.max(i,1)/35}function v(i,u,o){let e=Math.max(u,0),t=ye(o),n=i==="2"?0:48*t,l=i==="2"?12*t:6*t,d=i==="2"?12*t:n,C=Math.max(0,e-d-l);return {labelX:d,labelWidth:C,labelFontSize:14*t,shapeLaneWidth:n,switchTrackX:6*t,switchTrackY:6*t,switchTrackWidth:37.714306*t,switchTrackHeight:22*t,switchTrackRadius:11*t,switchKnobOffX:17.5*t,switchKnobOnX:32.5*t,switchKnobY:17*t,switchKnobRadius:10*t,switchStrokeWidth:1.5*t,lightCenterX:24.5*t,lightCenterY:17.5*t,lightRadius:13.5*t,lightStrokeWidth:3*t,buttonX:6*t,buttonY:5*t,buttonWidth:Math.max(0,e-12*t),buttonHeight:25.025183*t,buttonRadius:3.6672263*t}}function ge(i,u,o,e){if(o.length===0)return 0;let t=Math.max(1,Math.floor(u/o.length)),n=1,l=t,d=1;for(;n<=l;){let C=Math.floor((n+l)/2);if(o.every(w=>{let L=v(w.type,i,C);return e(w.ctrlLabel??"",L.labelFontSize)<=L.labelWidth})){d=C,n=C+1;continue}l=C-1;}return Math.min(d,t)}var fe=(()=>{class i{data=Hj(null,{alias:"controlData"});theme=Hj(null);dimensions=Hj.required();toggleClick=Vj();ctrlState=null;ctrlColor="";oldTheme=null;offColor=null;labelColor=null;valueColor=null;constructor(){}ngDoCheck(){let o=this.data();if(!o)return;o.value!=this.ctrlState&&(this.ctrlState=o.value),o.color!=this.ctrlColor&&(this.ctrlColor=o.color,this.getColors(o.color));let e=this.theme();this.oldTheme!=e&&(this.oldTheme=e,this.getColors(o.color));}toggle(o){let e=this.data();e&&(e.value=o,this.toggleClick.emit(e));}get layout(){let o=this.dimensions();return v("3",o.width,o.height)}get isEnabled(){return !!this.ctrlState}getColors(o){let e=this.theme();if(e)switch(o){case "contrast":this.offColor=e.contrastDimmer,this.labelColor=e.contrastDim,this.valueColor=e.contrast;break;case "blue":this.offColor=e.blueDimmer,this.labelColor=e.blueDim,this.valueColor=e.blue;break;case "green":this.offColor=e.greenDimmer,this.labelColor=e.greenDim,this.valueColor=e.green;break;case "pink":this.offColor=e.pinkDimmer,this.labelColor=e.pinkDim,this.valueColor=e.pink;break;case "orange":this.offColor=e.orangeDimmer,this.labelColor=e.orangeDim,this.valueColor=e.orange;break;case "purple":this.offColor=e.purpleDimmer,this.labelColor=e.purpleDim,this.valueColor=e.purple;break;case "grey":this.offColor=e.greyDimmer,this.labelColor=e.greyDim,this.valueColor=e.grey;break;case "yellow":this.offColor=e.yellowDimmer,this.labelColor=e.yellowDim,this.valueColor=e.yellow;break;default:this.offColor=e.contrastDimmer,this.labelColor=e.contrastDim,this.valueColor=e.contrast;break}}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=JD({type:i,selectors:[["app-svg-boolean-light"]],inputs:{data:[1,"controlData","data"],theme:[1,"theme"],dimensions:[1,"dimensions"]},outputs:{toggleClick:"toggleClick"},decls:21,vars:33,consts:[["version","1.1","id","svg9","xmlns","http://www.w3.org/2000/svg",0,"xmlns","svg","http://www.w3.org/2000/svg"],["id","defs1"],["id","lightSpecular","cx","36%","cy","32%","r","68%"],["offset","0","stop-color","#ffffff","stop-opacity","0.5"],["offset","0.55","stop-color","#ffffff","stop-opacity","0.16"],["offset","1","stop-color","#ffffff","stop-opacity","0"],["id","lightDepth","cx","68%","cy","70%","r","68%"],["offset","0","stop-color","#000000","stop-opacity","0"],["offset","0.62","stop-color","#000000","stop-opacity","0.05"],["offset","1","stop-color","#000000","stop-opacity","0.22"],["id","lightRim","x1","0","y1","0","x2","1","y2","1"],["offset","0","stop-color","#ffffff","stop-opacity","0.36"],["offset","0.45","stop-color","#ffffff","stop-opacity","0.09"],["offset","1","stop-color","#000000","stop-opacity","0.3"],["y","0"],["xmlns","http://www.w3.org/1999/xhtml",2,"width","100%","height","100%","display","flex","align-items","center","justify-content","flex-start","font-family","Roboto,sans-serif","font-weight","700","line-height","1","white-space","nowrap","overflow","hidden","text-overflow","clip"],[2,"stroke","url(#lightRim)","stroke-opacity","0.4","stroke-dasharray","none"],["fill","url(#lightSpecular)"],["fill","url(#lightDepth)"],["fill","#ffffff"]],template:function(e,t){e&1&&(wd(),dl(0,"svg",0)(1,"defs",1)(2,"radialGradient",2),Uh(3,"stop",3)(4,"stop",4)(5,"stop",5),fl(),dl(6,"radialGradient",6),Uh(7,"stop",7)(8,"stop",8)(9,"stop",9),fl(),dl(10,"linearGradient",10),Uh(11,"stop",11)(12,"stop",12)(13,"stop",13),fl()(),dl(14,"foreignObject",14),Td(),dl(15,"div",15),TT(16),fl()(),wd(),Uh(17,"circle",16)(18,"circle",17)(19,"circle",18)(20,"ellipse",19),fl()),e&2&&(Hh("height",t.dimensions().height)("width",t.dimensions().width)("viewBox","0 0 "+t.dimensions().width+" "+t.dimensions().height),EE(14),Hh("x",t.layout.labelX)("width",t.layout.labelWidth)("height",t.dimensions().height),EE(),ig("color",t.isEnabled?t.valueColor:t.labelColor)("opacity",t.isEnabled?1:.6)("font-size",t.layout.labelFontSize,"px")("text-shadow",t.isEnabled?"0 0 4px currentColor, 0 0 4px currentColor":"none"),EE(),gl(" ",t.data()?.ctrlLabel," "),EE(),Hh("cx",t.layout.lightCenterX)("cy",t.layout.lightCenterY)("r",t.layout.lightRadius)("fill",t.isEnabled?t.valueColor:t.offColor)("stroke-width",t.layout.lightStrokeWidth),EE(),Hh("cx",t.layout.lightCenterX)("cy",t.layout.lightCenterY)("r",t.layout.lightRadius)("opacity",t.isEnabled?.62:.42),EE(),Hh("cx",t.layout.lightCenterX)("cy",t.layout.lightCenterY)("r",t.layout.lightRadius)("opacity",t.isEnabled?.62:.48),EE(),Hh("cx",t.layout.lightCenterX-t.layout.lightRadius*.32)("cy",t.layout.lightCenterY-t.layout.lightRadius*.34)("rx",t.layout.lightRadius*.34)("ry",t.layout.lightRadius*.2)("opacity",t.isEnabled?.2:.12));},encapsulation:2})}return i})();var Ce=(()=>{class i{data=Hj(null,{alias:"controlData"});theme=Hj(null);dimensions=Hj.required();toggleClick=Vj();oldTheme=null;emitIntervalId=null;pressed=false;isSwiping=false;pointerStartX=0;pointerStartY=0;labelColorEnabled=null;labelColorDisabled=null;valueColor=null;ctrlColor="";ngDoCheck(){let o=this.data();if(!o)return;o.color!=this.ctrlColor&&(this.ctrlColor=o.color,this.getColors(o.color));let e=this.theme();this.oldTheme!=e&&(this.oldTheme=e,this.getColors(o.color));}handleClickDown(o){let e=this.data();if(!e)return;this.isSwiping=false,this.pointerStartX=o.clientX,this.pointerStartY=o.clientY,this.clearTimers(),this.pressed=true;let t=dp(e);t.value=this.pressed,this.toggleClick.emit(t),this.emitIntervalId=setInterval(()=>{this.toggleClick.emit(t);},100);}handlePointerMove(o){let e=Math.abs(o.clientX-this.pointerStartX),t=Math.abs(o.clientY-this.pointerStartY);(e>30||t>30)&&(this.isSwiping=true,this.pressed=false,this.clearTimers());}handleClickUp(){this.isSwiping&&(this.isSwiping=false),this.pressed=false,this.clearTimers();}handlePointerCancel(){this.isSwiping=false,this.pressed=false,this.clearTimers();}get layout(){let o=this.dimensions();return v("2",o.width,o.height)}get isPressed(){return this.pressed}getColors(o){let e=this.theme();if(e)switch(o){case "contrast":this.labelColorEnabled="black",this.labelColorDisabled=e.contrastDim,this.valueColor=e.contrast;break;case "blue":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.blueDim,this.valueColor=e.blue;break;case "green":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.greenDim,this.valueColor=e.green;break;case "pink":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.pinkDim,this.valueColor=e.pink;break;case "orange":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.orangeDim,this.valueColor=e.orange;break;case "purple":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.purpleDim,this.valueColor=e.purple;break;case "grey":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.greyDim,this.valueColor=e.grey;break;case "yellow":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.yellowDim,this.valueColor=e.yellow;break;default:this.labelColorEnabled="black",this.labelColorDisabled=e.contrastDim,this.valueColor=e.contrast;break}}clearTimers(){this.emitIntervalId&&(clearInterval(this.emitIntervalId),this.emitIntervalId=null);}ngOnDestroy(){this.clearTimers();}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=JD({type:i,selectors:[["app-svg-boolean-button"]],inputs:{data:[1,"controlData","data"],theme:[1,"theme"],dimensions:[1,"dimensions"]},outputs:{toggleClick:"toggleClick"},decls:6,vars:19,consts:[["version","1.1","id","svg9","xmlns","http://www.w3.org/2000/svg",0,"xmlns","svg","http://www.w3.org/2000/svg",3,"pointerup","pointerleave","pointerdown","pointermove","pointercancel"],["x","0","y","0","pointer-events","all",2,"display","inline","opacity","1","fill","transparent","fill-opacity","1","stroke","none","stroke-width","0"],[2,"display","inline","mix-blend-mode","normal","stroke","black","stroke-width","1.5","stroke-opacity","0.2"],["y","0",2,"pointer-events","none"],["xmlns","http://www.w3.org/1999/xhtml",2,"width","100%","height","100%","display","flex","align-items","center","justify-content","center","font-family","Roboto,sans-serif","font-weight","700","line-height","1","white-space","nowrap","overflow","hidden","text-overflow","clip"]],template:function(e,t){e&1&&(wd(),dl(0,"svg",0),Zh("pointerup",function(){return t.handleClickUp()})("pointerleave",function(){return t.handleClickUp()})("pointerdown",function(l){return t.handleClickDown(l)})("pointermove",function(l){return t.handlePointerMove(l)})("pointercancel",function(){return t.handlePointerCancel()}),Uh(1,"rect",1)(2,"rect",2),dl(3,"foreignObject",3),Td(),dl(4,"div",4),TT(5),fl()()()),e&2&&(Hh("height",t.dimensions().height)("width",t.dimensions().width)("viewBox","0 0 "+t.dimensions().width+" "+t.dimensions().height),EE(),Hh("width",t.dimensions().width)("height",t.dimensions().height),EE(),Hh("x",t.layout.buttonX)("y",t.layout.buttonY)("width",t.layout.buttonWidth)("height",t.layout.buttonHeight)("rx",t.layout.buttonRadius)("fill",t.isPressed?t.valueColor:t.labelColorDisabled),EE(),Hh("x",t.layout.labelX)("width",t.layout.labelWidth)("height",t.dimensions().height),EE(),ig("color",t.isPressed?t.labelColorEnabled:t.labelColorDisabled)("font-size",t.layout.labelFontSize,"px"),EE(),gl(" ",t.data()?.ctrlLabel," "));},encapsulation:2})}return i})();var be=(()=>{class i{data=Hj(null,{alias:"controlData"});theme=Hj(null);dimensions=Hj.required();toggleClick=Vj();ctrlState=null;oldTheme=null;swipeGuard=f();offColor=null;labelColor=null;valueColor=null;ctrlColor="";constructor(){}ngDoCheck(){let o=this.data();if(!o)return;o.value!=this.ctrlState&&(this.ctrlState=o.value),o.color!=this.ctrlColor&&(this.ctrlColor=o.color,this.getColors(o.color));let e=this.theme();this.oldTheme!=e&&(this.oldTheme=e,this.getColors(o.color));}onPointerDown(o){this.swipeGuard.onPointerDown(o);}onPointerMove(o){this.swipeGuard.onPointerMove(o);}onPointerUp(o,e){this.swipeGuard.onPointerUp(o)&&this.toggle(e);}onPointerCancel(o){this.swipeGuard.onPointerCancel(o);}get layout(){let o=this.dimensions();return v("1",o.width,o.height)}get isEnabled(){return !!this.ctrlState}get nextState(){return !this.isEnabled}toggle(o){let e=this.data();e&&(e.value=o,this.toggleClick.emit(e));}getColors(o){let e=this.theme();if(e)switch(o){case "contrast":this.offColor=e.contrastDimmer,this.labelColor=e.contrastDim,this.valueColor=e.contrast;break;case "blue":this.offColor=e.blueDimmer,this.labelColor=e.blueDim,this.valueColor=e.blue;break;case "green":this.offColor=e.greenDimmer,this.labelColor=e.greenDim,this.valueColor=e.green;break;case "pink":this.offColor=e.pinkDimmer,this.labelColor=e.pinkDim,this.valueColor=e.pink;break;case "orange":this.offColor=e.orangeDimmer,this.labelColor=e.orangeDim,this.valueColor=e.orange;break;case "purple":this.offColor=e.purpleDimmer,this.labelColor=e.purpleDim,this.valueColor=e.purple;break;case "grey":this.offColor=e.greyDimmer,this.labelColor=e.greyDim,this.valueColor=e.grey;break;case "yellow":this.offColor=e.yellowDimmer,this.labelColor=e.yellowDim,this.valueColor=e.yellow;break;default:this.offColor=e.contrastDimmer,this.labelColor=e.contrastDim,this.valueColor=e.contrast;break}}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=JD({type:i,selectors:[["app-svg-boolean-switch"]],inputs:{data:[1,"controlData","data"],theme:[1,"theme"],dimensions:[1,"dimensions"]},outputs:{toggleClick:"toggleClick"},decls:12,vars:28,consts:[["version","1.1","id","svg9","xmlns","http://www.w3.org/2000/svg",0,"xmlns","svg","http://www.w3.org/2000/svg",3,"pointerdown","pointermove","pointerup","pointercancel"],["id","defs1"],["id","linearGradient32"],["offset","0",2,"stop-color","#000000","stop-opacity","0.88486844"],["offset","1",2,"stop-color","#f7f7f7","stop-opacity","0.17763157"],[0,"xlink","href","#linearGradient32","id","linearGradient33","x1","0","y1","0","x2","1","y2","1"],["x","0","y","0","pointer-events","all",2,"display","inline","opacity","0.001","fill","black","fill-opacity","0.001","stroke","none","stroke-width","0"],["y","0",2,"pointer-events","none"],[2,"width","100%","height","100%","display","flex","align-items","center","justify-content","flex-start","font-family","Roboto,sans-serif","font-weight","700","line-height","1","white-space","nowrap","overflow","hidden","text-overflow","clip"],[2,"stroke-width","1.5","stroke","black","stroke-opacity","0.12"],[2,"stroke","url(#linearGradient33)","stroke-opacity","0.4","stroke-dasharray","none"]],template:function(e,t){e&1&&(wd(),dl(0,"svg",0),Zh("pointerdown",function(l){return t.onPointerDown(l)})("pointermove",function(l){return t.onPointerMove(l)})("pointerup",function(l){return t.onPointerUp(l,t.nextState)})("pointercancel",function(l){return t.onPointerCancel(l)}),dl(1,"defs",1)(2,"linearGradient",2),Uh(3,"stop",3)(4,"stop",4),fl(),Uh(5,"linearGradient",5),fl(),Uh(6,"rect",6),dl(7,"foreignObject",7),Td(),dl(8,"div",8),TT(9),fl()(),wd(),Uh(10,"rect",9)(11,"circle",10),fl()),e&2&&(Hh("height",t.dimensions().height)("width",t.dimensions().width)("viewBox","0 0 "+t.dimensions().width+" "+t.dimensions().height),EE(6),Hh("width",t.dimensions().width)("height",t.dimensions().height),EE(),Hh("x",t.layout.labelX)("width",t.layout.labelWidth)("height",t.dimensions().height),EE(),ig("color",t.isEnabled?t.valueColor:t.labelColor)("opacity",t.isEnabled?1:.6)("font-size",t.layout.labelFontSize,"px")("text-shadow",t.isEnabled?"0 0 4px currentColor, 0 0 4px currentColor":"none"),EE(),gl(" ",t.data()?.ctrlLabel," "),EE(),Hh("x",t.layout.switchTrackX)("y",t.layout.switchTrackY)("width",t.layout.switchTrackWidth)("height",t.layout.switchTrackHeight)("rx",t.layout.switchTrackRadius)("fill",t.isEnabled?t.labelColor:t.offColor),EE(),Hh("cx",t.isEnabled?t.layout.switchKnobOnX:t.layout.switchKnobOffX)("cy",t.layout.switchKnobY)("r",t.layout.switchKnobRadius)("fill",t.isEnabled?t.valueColor:t.offColor)("stroke-width",t.layout.switchStrokeWidth));},encapsulation:2})}return i})();function _e(i,u){if(i&1&&$h(0,"widget-title",1),i&2){let o=qw(),e=xT(0);Bh("text",(e==null?null:e.displayName)??"")("color",o.labelColor());}}function De(i,u){if(i&1){let o=Fw();Pi(0,"app-svg-boolean-switch",5),Qh("toggleClick",function(t){ud(o);let n=qw(2);return dd(n.toggle(t))}),ul();}if(i&2){let o=qw().$implicit,e=qw();Bh("controlData",o)("theme",e.theme())("dimensions",e.ctrlDimensions);}}function Se(i,u){if(i&1){let o=Fw();Pi(0,"app-svg-boolean-button",5),Qh("toggleClick",function(t){ud(o);let n=qw(2);return dd(n.toggle(t))}),ul();}if(i&2){let o=qw().$implicit,e=qw();Bh("controlData",o)("theme",e.theme())("dimensions",e.ctrlDimensions);}}function ke(i,u){if(i&1){let o=Fw();Pi(0,"app-svg-boolean-light",5),Qh("toggleClick",function(t){ud(o);let n=qw(2);return dd(n.toggle(t))}),ul();}if(i&2){let o=qw().$implicit,e=qw();Bh("controlData",o)("theme",e.theme())("dimensions",e.ctrlDimensions);}}function Ee(i,u){if(i&1&&(pl(0),_w(1,De,1,3,"app-svg-boolean-switch",4)(2,Se,1,3,"app-svg-boolean-button",4)(3,ke,1,3,"app-svg-boolean-light",4),hl()),i&2){let o,e=u.$implicit;EE(),Mw((o=e.type)==="1"?1:o==="2"?2:o==="3"?3:-1);}}function Te(i,u){i&1&&$h(0,"div",3);}var lt=(()=>{class i{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={displayName:"Switch Panel Label",showLabel:true,filterSelfPaths:true,paths:[],enableTimeout:false,dataTimeout:5,color:"contrast",zonesOnlyPaths:false,putEnable:true,putMomentary:false,multiChildCtrls:[]};runtime=w(p,{optional:true});streams=w(rt,{optional:true});dashboard=w(G);signalkRequestsService=w(T);toast=w(lt$1);canvas=w(R);switchControls=vt([]);labelColor=vt("");noTitleClass=Dt(()=>this.runtime?.options()?.showLabel===false?"widgets-container-no-title":"widgets-container");nbCtrl=null;ctrlDimensions={width:0,height:0};hostSize={width:0,height:0};skRequestSub=new j;measureCtx=typeof document<"u"?document.createElement("canvas").getContext("2d"):null;constructor(){Fa(()=>{let o=this.theme(),e=this.runtime?.options();!o||!e||ge$1(()=>{this.labelColor.set(c(e.color??"contrast",o).dim);});}),Fa(()=>{let o=this.runtime?.options();if(!o)return;let e=(o.multiChildCtrls||[]).map(t=>z(G$1({},t),{isNumeric:t.isNumeric??false}));this.nbCtrl=e.length,ge$1(()=>{this.switchControls.set(e),this.updateCtrlDimensions();let t=this.streams;t&&e.forEach(n=>{let l=o.paths;if(!l?.length)return;let d=l.findIndex(R=>R.pathID===n.pathID);d<0||!l[d]?.path||t.observe(String(d),R=>{let w=R?.data?.value,L=n.isNumeric?[0,1,null].includes(w)?!!w:n.value:w;this.switchControls.update(E=>{let N=E.findIndex(we=>we.pathID===n.pathID);if(N===-1)return E;let ve=z(G$1({},E[N]),{value:L});return [...E.slice(0,N),ve,...E.slice(N+1)]});});});});});}onResized(o){this.hostSize={width:o.contentRect.width,height:o.contentRect.height},this.updateCtrlDimensions();}updateCtrlDimensions(){let o=this.hostSize.width,e=this.hostSize.height,t=this.switchControls();if(!o||!e||!t.length){this.ctrlDimensions={width:o,height:0};return}let n=this.measureCtx?ge(o,e,t,(l,d)=>(this.measureCtx.font=`700 ${d}px ${this.canvas.DEFAULT_FONT}`,this.measureCtx.measureText(l).width)):Math.max(1,Math.floor(e/t.length));this.ctrlDimensions={width:o,height:n};}toggle(o){let e=this.runtime?.options();if(!e?.putEnable)return;let t=e.paths;if(!t)return;let n=t.findIndex(d=>d.pathID===o.pathID);if(n<0)return;let l=t[n].path;l&&(o.isNumeric?this.signalkRequestsService.putRequest(l,o.value?1:0,this.id()):this.signalkRequestsService.putRequest(l,o.value,this.id()));}ngOnDestroy(){this.skRequestSub?.unsubscribe();}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=JD({type:i,selectors:[["widget-boolean-switch"]],inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:7,vars:5,consts:[["widgetContainer",""],[3,"text","color"],["kipResizeObserver","",3,"resizeChange"],[1,"widgetOverlay"],[1,"svg-widget",3,"controlData","theme","dimensions"],[1,"svg-widget",3,"toggleClick","controlData","theme","dimensions"]],template:function(e,t){if(e&1&&(wg(0),_w(1,_e,1,2,"widget-title",1),Pi(2,"div",2,0),Qh("resizeChange",function(l){return t.onResized(l)}),xw(4,Ee,4,1,"ng-container",null,Sw),ul(),_w(6,Te,1,0,"div",3)),e&2){let n=NT(t.runtime==null?null:t.runtime.options());EE(),Mw(n?.showLabel?1:-1),EE(),pT(t.noTitleClass()),EE(2),Aw(t.switchControls()),EE(2),Mw(t.dashboard.isDashboardStatic()?-1:6);}},dependencies:[u,be,Ce,fe,x],styles:[".widgets-container[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;z-index:20}.widgets-container-no-title[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;padding:3px 0 0;height:100%;width:100%;overflow:hidden;z-index:20}.svg-widget[_ngcontent-%COMP%]{display:flex}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent;z-index:21}"]})}return i})();
2
2
  export{lt as WidgetBooleanSwitchComponent};
@@ -1 +1 @@
1
- import {C,e as e$1}from'./chunk-B6bEhzNR.js';import {g as ge$1}from'./chunk-TakPRI3t.js';import {e9 as a,d1 as Hj,w,du as p,aS as De,bu as ut,aY as xe,$ as $j,v as vt,D as Dt,F as Fa,dn as ge,a_ as Gp,cv as G,cw as z,dx as n$1,J as JD,dC as x,c as $h,cn as wd,_ as _w,B as Bh,e as EE,M as Mw,f as eg,K as Kw,P as Pi,T as TT,u as ul}from'./main-BAV5VDOD.js';import {c,e}from'./chunk-Dxlia2NE.js';var ie=["acSvg"];function re(l,e){l&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No AC buses detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K AC paths or select buses in widget settings."),ul()());}var Y=class l{static AC_DESCRIPTOR=a("widget-ac");static SELF_ROOT_PATH=(()=>{let e=l.AC_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetAcComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${l.SELF_ROOT_PATH}.*`;static ROOT_PREFIX=`${l.SELF_ROOT_PATH}.`;static VIEWBOX_WIDTH=200;static CARD_HEIGHT=100;static COMPACT_CARD_HEIGHT=100;static CARD_GAP=8;static PATH_BATCH_WINDOW_MS=500;static RESERVED_AC_AGGREGATE_IDS=new Set(["totalCurrent","totalPower"]);static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,ac:{trackedDevices:[],optionsById:{}}};id=Hj.required();type=Hj.required();theme=Hj.required();renderMode=Hj(null);runtime=w(p);data=w(De);units=w(ut);destroyRef=w(xe);svgRef=$j.required("acSvg");svg;layer;pendingPathUpdates=new Map;pathBatchTimerId=null;initialPathPaintDone=false;renderFrameId=null;pendingRenderSnapshot=null;discoveredBusIds=vt([]);trackedDevices=vt([]);optionsById=vt({});cardMode=vt({displayMode:"full",metrics:["line1Voltage","line1Current","line1Frequency","line2Voltage"]});busesByKey=vt({});visibleBusKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(r=>r.key);let i=this.busesByKey(),t=new Set(this.discoveredBusIds());return Object.keys(i).filter(r=>{let s=i[r];return !!s&&t.has(s.id)}).sort((r,s)=>r.localeCompare(s))});visibleBuses=Dt(()=>{let e=this.visibleBusKeys(),i=this.busesByKey();return e.map(t=>i[t]).filter(t=>!!t)});hasBuses=Dt(()=>this.visibleBuses().length>0);activeDisplayMode=Dt(()=>this.renderMode()??this.cardMode().displayMode??"full");isCompactCardMode=Dt(()=>this.activeDisplayMode()==="compact");colorRole=Dt(()=>this.runtime.options()?.color??"contrast");ignoreZones=Dt(()=>this.runtime.options()?.ignoreZones??false);displayLabel=Dt(()=>{let e=this.visibleBuses();return e.length!==1?"AC Buses":this.resolveTitleText(e[0])});labelColor=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e).dim:"var(--kip-contrast-dim-color)"});widgetColors=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e):null});displayModels=Dt(()=>{let e$1=this.visibleBuses(),i=this.theme(),t=this.widgetColors(),r=this.ignoreZones(),s=new Map;e$1.forEach(n=>s.set(n.id,(s.get(n.id)??0)+1));let c=new Set([...s.entries()].filter(([,n])=>n>1).map(([n])=>n)),a={};for(let n of e$1){let d=n.deviceKey??n.id,o=!!n.source&&c.has(n.id),h=this.resolveMostSevereState(n.line1VoltageState??null,n.line1CurrentState??null,n.line2VoltageState??null,n.line2CurrentState??null,n.line3VoltageState??null,n.line3CurrentState??null,n.modeState??null),v=this.resolveMostSevereState(n.line1VoltageState??null,n.line1CurrentState??null,n.line1FrequencyState??null),T=this.resolveMostSevereState(n.line2VoltageState??null,n.line2CurrentState??null,n.line3VoltageState??null,n.line3CurrentState??null),[M,I]=this.buildMetricRows(n);a[d]={id:n.id,titleText:this.resolveTitleText(n),modeText:this.isCompactCardMode()?"":this.resolveModeText(n),busText:this.isCompactCardMode()?"":o?n.source??"-":n.associatedBus||n.location||"-",metricsLineOne:M,metricsLineTwo:I,stateBarColor:e(h,t?.dim??"var(--kip-contrast-color)",i,r),titleTextColor:e(h,"var(--kip-contrast-color)",i,r),metaTextColor:e(n.modeState??null,"var(--kip-contrast-dim-color)",i,r),primaryMetricsTextColor:e(v,"var(--kip-contrast-color)",i,r),secondaryMetricsTextColor:e(T,"var(--kip-contrast-color)",i,r)};}return a});constructor(){Fa(()=>{let t=this.runtime.options();t&&ge(()=>this.applyConfig(t));}),Fa(()=>{let t=this.displayModels(),r=this.visibleBuses(),s=this.widgetColors();!this.svg||!s||this.requestRender({buses:r,displayModels:t,widgetColors:s});});let e=[this.data.subscribePathTreeWithInitial(l.ROOT_PATTERN)],i=false;for(let t of e)if(t.initial.length){i=true;for(let r of t.initial)this.enqueuePathUpdate(r,true);}i&&(this.flushPendingPathUpdates(),this.initialPathPaintDone=true);for(let t of e)t.live$.pipe(Gp(this.destroyRef)).subscribe(r=>this.enqueuePathUpdate(r));}ngAfterViewInit(){this.initializeSvg(),this.requestRender();}ngOnDestroy(){this.pathBatchTimerId!==null&&(clearTimeout(this.pathBatchTimerId),this.pathBatchTimerId=null),this.renderFrameId!==null&&(cancelAnimationFrame(this.renderFrameId),this.renderFrameId=null),this.pendingRenderSnapshot=null;}initializeSvg(){this.svg=ge$1(this.svgRef().nativeElement),this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${l.CARD_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","AC View"),this.layer=this.svg.append("g").attr("class","ac-layer");}applyConfig(e){let i=this.resolveAcConfig(e);this.trackedDevices.set(i.trackedDevices??[]),this.reprojectSnapshotsToDeviceKeys(i.trackedDevices??[]),this.optionsById.set(i.optionsById),this.cardMode.set(this.normalizeCardMode(i.cardMode));}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let i=new Map;e.forEach(t=>{let r=i.get(t.id)??[];r.push(t.key),i.set(t.id,r);}),this.busesByKey.update(t=>{let r=t,s=false;return i.forEach((c,a)=>{let n=t[a];if(n){for(let d of c){if(t[d])continue;let o=e.find(h=>h.key===d);s||(r=G({},t),s=true),r[d]=z(G({},n),{source:o?.source??null,deviceKey:d});}s&&r[a]?.deviceKey===void 0&&delete r[a];}}),s?r:t});}resolveAcConfig(e){let i=e.ac;return {trackedDevices:this.normalizeAcTrackedDevices(i?.trackedDevices),optionsById:this.normalizeOptionsById(i?.optionsById),cardMode:this.normalizeCardMode(i?.cardMode)}}normalizeAcTrackedDevices(e){if(!Array.isArray(e))return [];let i=new Map;return e.forEach(t=>{if(!t||typeof t!="object")return;let r=t,s=this.normalizeOptionalString(r.id),c=this.normalizeOptionalString(r.source);if(!s||!c||l.RESERVED_AC_AGGREGATE_IDS.has(s))return;let a=this.normalizeOptionalString(r.key)??`${s}||${c}`;i.set(a,{id:s,source:c,key:a});}),[...i.values()].sort((t,r)=>t.key.localeCompare(r.key))}buildIdToDeviceKeysMap(){let e=new Map;return this.trackedDevices().forEach(i=>{let t=e.get(i.id)??[];t.push(i.key),e.set(i.id,t);}),e}normalizeCardMode(e){let i=e&&typeof e=="object"?e:null,t=this.normalizeStringList(i?.metrics);return {displayMode:i?.displayMode==="compact"?"compact":"full",metrics:t.length?t:["line1Voltage","line1Current","line1Frequency","line2Voltage"]}}normalizeStringList(e){if(!Array.isArray(e))return [];let i=new Set;return e.forEach(t=>{if(typeof t!="string")return;let r=t.trim();r.length>0&&i.add(r);}),[...i].sort((t,r)=>t.localeCompare(r))}normalizeOptionsById(e){if(!e||typeof e!="object")return {};let i={};return Object.entries(e).forEach(([t])=>{let r=this.normalizeOptionalString(t);r&&(i[r]={});}),i}normalizeOptionalString(e){if(typeof e!="string")return null;let i=e.trim();return i.length>0?i:null}enqueuePathUpdate(e,i=false){let t=this.parsePath(e.path);if(!t)return;let r=e.update?.data?.value??null,s=e.update?.state??null;if(this.pendingPathUpdates.set(`${t.id}::${t.key}`,{id:t.id,key:t.key,value:r,state:s}),!i){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},l.PATH_BATCH_WINDOW_MS));}}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let e=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(e.map(r=>r.id)).forEach(r=>this.trackDiscoveredBus(r));let t=this.buildIdToDeviceKeysMap();this.busesByKey.update(r=>{let s=r,c=false;for(let a of e){let n=t.get(a.id),d=n?.length?n:[a.id];for(let o of d){let h=!!n?.length,v=h?this.trackedDevices().find(Z=>Z.key===o):null,T=s[o]??{id:a.id,source:v?.source??null,deviceKey:h?o:void 0},M=G({},T);this.applyValue(M,a.key,a.value,a.state)&&(c||(s=G({},s),c=true),s[o]=M);}}return c?s:r});}parsePath(e){if(!e.startsWith(l.ROOT_PREFIX))return null;let i=e.slice(l.ROOT_PREFIX.length),t=i.indexOf(".");return t<=0||t===i.length-1?null:{id:i.slice(0,t),key:i.slice(t+1)}}normalizeMetricKey(e){let i=e.match(/^phase\.([^.]+)\.(current|frequency|lineNeutralVoltage|realPower)$/);if(i){let t=this.resolveLineKey(i[1]);if(!t)return null;let r=i[2];return r==="current"?`${t}.current`:r==="frequency"?`${t}.frequency`:r==="lineNeutralVoltage"?`${t}.voltage`:`${t}.realPower`}return e==="total.realPower"?"power":e}resolveLineKey(e){let i=e.trim().toLowerCase();return ["0","1","l1","line1","phase1","a"].includes(i)?"line1":["2","l2","line2","phase2","b"].includes(i)?"line2":["3","l3","line3","phase3","c"].includes(i)?"line3":null}trackDiscoveredBus(e){let i=this.discoveredBusIds();i.includes(e)||this.discoveredBusIds.set([...i,e].sort((t,r)=>t.localeCompare(r)));}applyValue(e,i,t,r){let s=this.normalizeMetricKey(i);if(!s)return false;switch(s){case "name":return this.setValue(e,"name",this.toStringValue(t));case "location":return this.setValue(e,"location",this.toStringValue(t));case "associatedBus":return this.setValue(e,"associatedBus",this.toStringValue(t));case "mode":return this.setMetricValue(e,"mode","modeState",this.toStringValue(t),r);case "voltage":return this.setMetricValue(e,"line1Voltage","line1VoltageState",this.toNumber(t,"V"),r);case "current":return this.setMetricValue(e,"line1Current","line1CurrentState",this.toNumber(t,"A"),r);case "frequency":return this.setMetricValue(e,"line1Frequency","line1FrequencyState",this.toNumber(t,"Hz"),r);case "line1.voltage":return this.setMetricValue(e,"line1Voltage","line1VoltageState",this.toNumber(t,"V"),r);case "line1.current":return this.setMetricValue(e,"line1Current","line1CurrentState",this.toNumber(t,"A"),r);case "line1.frequency":return this.setMetricValue(e,"line1Frequency","line1FrequencyState",this.toNumber(t,"Hz"),r);case "line1.realPower":return this.setMetricValue(e,"power","line1CurrentState",this.toNumber(t,"W"),r);case "line2.voltage":return this.setMetricValue(e,"line2Voltage","line2VoltageState",this.toNumber(t,"V"),r);case "line2.current":return this.setMetricValue(e,"line2Current","line2CurrentState",this.toNumber(t,"A"),r);case "line2.frequency":return this.setMetricValue(e,"line2Frequency","line2FrequencyState",this.toNumber(t,"Hz"),r);case "line2.realPower":return this.setMetricValue(e,"power","line2CurrentState",this.toNumber(t,"W"),r);case "line3.voltage":return this.setMetricValue(e,"line3Voltage","line3VoltageState",this.toNumber(t,"V"),r);case "line3.current":return this.setMetricValue(e,"line3Current","line3CurrentState",this.toNumber(t,"A"),r);case "line3.frequency":return this.setMetricValue(e,"line3Frequency","line3FrequencyState",this.toNumber(t,"Hz"),r);case "line3.realPower":return this.setMetricValue(e,"power","line3CurrentState",this.toNumber(t,"W"),r);case "power":return this.setMetricValue(e,"power","line1CurrentState",this.toNumber(t,"W"),r);default:return false}}setValue(e,i,t){return Object.is(e[i],t)?false:(e[i]=t,true)}setMetricValue(e,i,t,r,s){let c=!Object.is(e[i],r),a=!Object.is(e[t],s);return !c&&!a?false:(e[i]=r,e[t]=s,true)}requestRender(e){let i=this.widgetColors();!this.svg||!i||(this.pendingRenderSnapshot=e??{buses:this.visibleBuses(),displayModels:this.displayModels(),widgetColors:i},this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;let t=this.pendingRenderSnapshot;this.pendingRenderSnapshot=null,t&&this.render(t);})));}render(e){if(!this.layer||!this.svg)return;let i=this.isCompactCardMode(),t=i?C:e$1,r=i?l.COMPACT_CARD_HEIGHT:l.CARD_HEIGHT,s=e.buses.map((o,h)=>({key:o.deviceKey??o.id,bus:o,y:h*(r+l.CARD_GAP)})),c=s.length?s[s.length-1].y+r:r;this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${c}`);let a=this.layer.selectAll("g.ac-card").data(s,o=>o.key),n=a.enter().append("g").attr("class","ac-card");n.append("rect").attr("class","ac-state-bar"),n.append("text").attr("class","ac-title"),n.append("text").attr("class","ac-id"),n.append("text").attr("class","ac-mode"),n.append("text").attr("class","ac-bus"),n.append("text").attr("class","ac-metrics-1"),n.append("text").attr("class","ac-metrics-2");let d=n.merge(a);d.attr("transform",o=>`translate(0, ${o.y})`),d.select("rect.ac-state-bar").attr("x",1.5).attr("y",1.5).attr("rx",t.stateBarCornerRadius).attr("ry",t.stateBarCornerRadius).attr("width",3).attr("height",r-3).attr("fill",o=>e.displayModels[o.key]?.stateBarColor??e.widgetColors.dim),e.buses.length>1?d.select("text.ac-title").attr("x",t.titleX).attr("y",t.titleY).attr("font-size",t.titleFontSize).attr("fill",o=>e.displayModels[o.key]?.titleTextColor??"var(--kip-contrast-color)").text(o=>e.displayModels[o.key]?.titleText??this.resolveTitleText(o.bus)):d.select("text.ac-title").text(""),d.select("text.ac-id").attr("x",t.idX).attr("y",t.idY).attr("text-anchor","end").attr("font-size",t.idFontSize).attr("fill","var(--kip-contrast-dim-color)").text(o=>o.bus.id),d.select("text.ac-mode").attr("x",t.metaLeftX).attr("y",t.metaY).attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",o=>e.displayModels[o.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(o=>e.displayModels[o.key]?.modeText??""),d.select("text.ac-bus").attr("x",t.metaRightX).attr("y",t.metaY).attr("text-anchor","end").attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",o=>e.displayModels[o.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(o=>e.displayModels[o.key]?.busText??""),d.select("text.ac-metrics-1").attr("x",t.lineOneX).attr("y",t.lineOneY).attr("font-size",t.lineOneFontSize).attr("fill",o=>e.displayModels[o.key]?.primaryMetricsTextColor??"var(--kip-contrast-color)").text(o=>e.displayModels[o.key]?.metricsLineOne??""),d.select("text.ac-metrics-2").attr("x",t.lineTwoX).attr("y",t.lineTwoY).attr("font-size",t.lineTwoFontSize).attr("opacity",.85).attr("fill",o=>e.displayModels[o.key]?.secondaryMetricsTextColor??"var(--kip-contrast-color)").text(o=>e.displayModels[o.key]?.metricsLineTwo??""),a.exit().remove();}displayName(e){return e.name?.trim()||e.id}resolveTitleText(e){return e.name||`AC ${e.id}`}resolveModeText(e){return e.mode?`Mode ${e.mode}`:"Mode -"}buildMetricRows(e){let i=this.cardMode(),t=(i.metrics.length?i.metrics:l.DEFAULT_CONFIG.ac?.cardMode?.metrics??[]).map(c=>this.toMetricLabel(c,e)).filter(c=>!!c);if(!t.length)return ["L1 - - -","L2 - - L3 - -"];let r=t.slice(0,2).join(" "),s=t.slice(2,4).join(" ");return [r||" ",s||" "]}toMetricLabel(e,i){switch(e){case "line1Voltage":return `L1V ${this.formatValue(i.line1Voltage,"V")}`;case "line1Current":return `L1A ${this.formatValue(i.line1Current,"A")}`;case "line1Frequency":return `L1Hz ${this.formatValue(i.line1Frequency,"Hz")}`;case "line2Voltage":return `L2V ${this.formatValue(i.line2Voltage,"V")}`;case "line2Current":return `L2A ${this.formatValue(i.line2Current,"A")}`;case "line2Frequency":return `L2Hz ${this.formatValue(i.line2Frequency,"Hz")}`;case "line3Voltage":return `L3V ${this.formatValue(i.line3Voltage,"V")}`;case "line3Current":return `L3A ${this.formatValue(i.line3Current,"A")}`;case "line3Frequency":return `L3Hz ${this.formatValue(i.line3Frequency,"Hz")}`;default:return null}}formatValue(e,i){return e==null||Number.isNaN(e)?"-":`${e.toFixed(1)} ${i}`}toStringValue(e){return typeof e=="string"?e:null}resolveMostSevereState(...e){return e.some(i=>i===n$1.Alert)?n$1.Alert:e.some(i=>i===n$1.Alarm)?n$1.Alarm:e.some(i=>i===n$1.Warn)?n$1.Warn:e.some(i=>i===n$1.Normal)?n$1.Normal:null}toNumber(e,i){if(e==null||typeof e=="boolean")return null;let t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return null;let r=this.units.convertToUnit(i,t);return typeof r=="number"&&Number.isFinite(r)?r:null}static \u0275fac=function(i){return new(i||l)};static \u0275cmp=JD({type:l,selectors:[["widget-ac"]],viewQuery:function(i,t){i&1&&eg(t.svgRef,ie,5),i&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["acSvg",""],[3,"text","color"],["aria-hidden","false",1,"ac-svg"],[1,"ac-empty"],[1,"ac-empty-title"],[1,"ac-empty-sub"]],template:function(i,t){i&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,re,5,0,"div",3)),i&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasBuses()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.ac-svg[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;z-index:20;padding:0 10px 10px}.ac-empty[_ngcontent-%COMP%]{position:absolute;inset:0;margin:10px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;text-align:center;color:var(--mat-sys-on-surface);background:color-mix(in srgb,var(--kip-widget-card-background-color) 92%,transparent)}.ac-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.ac-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{Y as WidgetAcComponent};
1
+ import {C,e as e$1}from'./chunk-DPnbM-aB.js';import {g as ge$1}from'./chunk-TakPRI3t.js';import {e9 as a,d1 as Hj,w,du as p,aS as De,bu as ut,aY as xe,$ as $j,v as vt,D as Dt,F as Fa,dn as ge,a_ as Gp,cv as G,cw as z,dx as n$1,J as JD,dC as x,c as $h,cn as wd,_ as _w,B as Bh,e as EE,M as Mw,f as eg,K as Kw,P as Pi,T as TT,u as ul}from'./main-YKDNK5VZ.js';import {c,e}from'./chunk-BIb-xYiS.js';var ie=["acSvg"];function re(l,e){l&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No AC buses detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K AC paths or select buses in widget settings."),ul()());}var Y=class l{static AC_DESCRIPTOR=a("widget-ac");static SELF_ROOT_PATH=(()=>{let e=l.AC_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetAcComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${l.SELF_ROOT_PATH}.*`;static ROOT_PREFIX=`${l.SELF_ROOT_PATH}.`;static VIEWBOX_WIDTH=200;static CARD_HEIGHT=100;static COMPACT_CARD_HEIGHT=100;static CARD_GAP=8;static PATH_BATCH_WINDOW_MS=500;static RESERVED_AC_AGGREGATE_IDS=new Set(["totalCurrent","totalPower"]);static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,ac:{trackedDevices:[],optionsById:{}}};id=Hj.required();type=Hj.required();theme=Hj.required();renderMode=Hj(null);runtime=w(p);data=w(De);units=w(ut);destroyRef=w(xe);svgRef=$j.required("acSvg");svg;layer;pendingPathUpdates=new Map;pathBatchTimerId=null;initialPathPaintDone=false;renderFrameId=null;pendingRenderSnapshot=null;discoveredBusIds=vt([]);trackedDevices=vt([]);optionsById=vt({});cardMode=vt({displayMode:"full",metrics:["line1Voltage","line1Current","line1Frequency","line2Voltage"]});busesByKey=vt({});visibleBusKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(r=>r.key);let i=this.busesByKey(),t=new Set(this.discoveredBusIds());return Object.keys(i).filter(r=>{let s=i[r];return !!s&&t.has(s.id)}).sort((r,s)=>r.localeCompare(s))});visibleBuses=Dt(()=>{let e=this.visibleBusKeys(),i=this.busesByKey();return e.map(t=>i[t]).filter(t=>!!t)});hasBuses=Dt(()=>this.visibleBuses().length>0);activeDisplayMode=Dt(()=>this.renderMode()??this.cardMode().displayMode??"full");isCompactCardMode=Dt(()=>this.activeDisplayMode()==="compact");colorRole=Dt(()=>this.runtime.options()?.color??"contrast");ignoreZones=Dt(()=>this.runtime.options()?.ignoreZones??false);displayLabel=Dt(()=>{let e=this.visibleBuses();return e.length!==1?"AC Buses":this.resolveTitleText(e[0])});labelColor=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e).dim:"var(--kip-contrast-dim-color)"});widgetColors=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e):null});displayModels=Dt(()=>{let e$1=this.visibleBuses(),i=this.theme(),t=this.widgetColors(),r=this.ignoreZones(),s=new Map;e$1.forEach(n=>s.set(n.id,(s.get(n.id)??0)+1));let c=new Set([...s.entries()].filter(([,n])=>n>1).map(([n])=>n)),a={};for(let n of e$1){let d=n.deviceKey??n.id,o=!!n.source&&c.has(n.id),h=this.resolveMostSevereState(n.line1VoltageState??null,n.line1CurrentState??null,n.line2VoltageState??null,n.line2CurrentState??null,n.line3VoltageState??null,n.line3CurrentState??null,n.modeState??null),v=this.resolveMostSevereState(n.line1VoltageState??null,n.line1CurrentState??null,n.line1FrequencyState??null),T=this.resolveMostSevereState(n.line2VoltageState??null,n.line2CurrentState??null,n.line3VoltageState??null,n.line3CurrentState??null),[M,I]=this.buildMetricRows(n);a[d]={id:n.id,titleText:this.resolveTitleText(n),modeText:this.isCompactCardMode()?"":this.resolveModeText(n),busText:this.isCompactCardMode()?"":o?n.source??"-":n.associatedBus||n.location||"-",metricsLineOne:M,metricsLineTwo:I,stateBarColor:e(h,t?.dim??"var(--kip-contrast-color)",i,r),titleTextColor:e(h,"var(--kip-contrast-color)",i,r),metaTextColor:e(n.modeState??null,"var(--kip-contrast-dim-color)",i,r),primaryMetricsTextColor:e(v,"var(--kip-contrast-color)",i,r),secondaryMetricsTextColor:e(T,"var(--kip-contrast-color)",i,r)};}return a});constructor(){Fa(()=>{let t=this.runtime.options();t&&ge(()=>this.applyConfig(t));}),Fa(()=>{let t=this.displayModels(),r=this.visibleBuses(),s=this.widgetColors();!this.svg||!s||this.requestRender({buses:r,displayModels:t,widgetColors:s});});let e=[this.data.subscribePathTreeWithInitial(l.ROOT_PATTERN)],i=false;for(let t of e)if(t.initial.length){i=true;for(let r of t.initial)this.enqueuePathUpdate(r,true);}i&&(this.flushPendingPathUpdates(),this.initialPathPaintDone=true);for(let t of e)t.live$.pipe(Gp(this.destroyRef)).subscribe(r=>this.enqueuePathUpdate(r));}ngAfterViewInit(){this.initializeSvg(),this.requestRender();}ngOnDestroy(){this.pathBatchTimerId!==null&&(clearTimeout(this.pathBatchTimerId),this.pathBatchTimerId=null),this.renderFrameId!==null&&(cancelAnimationFrame(this.renderFrameId),this.renderFrameId=null),this.pendingRenderSnapshot=null;}initializeSvg(){this.svg=ge$1(this.svgRef().nativeElement),this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${l.CARD_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","AC View"),this.layer=this.svg.append("g").attr("class","ac-layer");}applyConfig(e){let i=this.resolveAcConfig(e);this.trackedDevices.set(i.trackedDevices??[]),this.reprojectSnapshotsToDeviceKeys(i.trackedDevices??[]),this.optionsById.set(i.optionsById),this.cardMode.set(this.normalizeCardMode(i.cardMode));}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let i=new Map;e.forEach(t=>{let r=i.get(t.id)??[];r.push(t.key),i.set(t.id,r);}),this.busesByKey.update(t=>{let r=t,s=false;return i.forEach((c,a)=>{let n=t[a];if(n){for(let d of c){if(t[d])continue;let o=e.find(h=>h.key===d);s||(r=G({},t),s=true),r[d]=z(G({},n),{source:o?.source??null,deviceKey:d});}s&&r[a]?.deviceKey===void 0&&delete r[a];}}),s?r:t});}resolveAcConfig(e){let i=e.ac;return {trackedDevices:this.normalizeAcTrackedDevices(i?.trackedDevices),optionsById:this.normalizeOptionsById(i?.optionsById),cardMode:this.normalizeCardMode(i?.cardMode)}}normalizeAcTrackedDevices(e){if(!Array.isArray(e))return [];let i=new Map;return e.forEach(t=>{if(!t||typeof t!="object")return;let r=t,s=this.normalizeOptionalString(r.id),c=this.normalizeOptionalString(r.source);if(!s||!c||l.RESERVED_AC_AGGREGATE_IDS.has(s))return;let a=this.normalizeOptionalString(r.key)??`${s}||${c}`;i.set(a,{id:s,source:c,key:a});}),[...i.values()].sort((t,r)=>t.key.localeCompare(r.key))}buildIdToDeviceKeysMap(){let e=new Map;return this.trackedDevices().forEach(i=>{let t=e.get(i.id)??[];t.push(i.key),e.set(i.id,t);}),e}normalizeCardMode(e){let i=e&&typeof e=="object"?e:null,t=this.normalizeStringList(i?.metrics);return {displayMode:i?.displayMode==="compact"?"compact":"full",metrics:t.length?t:["line1Voltage","line1Current","line1Frequency","line2Voltage"]}}normalizeStringList(e){if(!Array.isArray(e))return [];let i=new Set;return e.forEach(t=>{if(typeof t!="string")return;let r=t.trim();r.length>0&&i.add(r);}),[...i].sort((t,r)=>t.localeCompare(r))}normalizeOptionsById(e){if(!e||typeof e!="object")return {};let i={};return Object.entries(e).forEach(([t])=>{let r=this.normalizeOptionalString(t);r&&(i[r]={});}),i}normalizeOptionalString(e){if(typeof e!="string")return null;let i=e.trim();return i.length>0?i:null}enqueuePathUpdate(e,i=false){let t=this.parsePath(e.path);if(!t)return;let r=e.update?.data?.value??null,s=e.update?.state??null;if(this.pendingPathUpdates.set(`${t.id}::${t.key}`,{id:t.id,key:t.key,value:r,state:s}),!i){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},l.PATH_BATCH_WINDOW_MS));}}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let e=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(e.map(r=>r.id)).forEach(r=>this.trackDiscoveredBus(r));let t=this.buildIdToDeviceKeysMap();this.busesByKey.update(r=>{let s=r,c=false;for(let a of e){let n=t.get(a.id),d=n?.length?n:[a.id];for(let o of d){let h=!!n?.length,v=h?this.trackedDevices().find(Z=>Z.key===o):null,T=s[o]??{id:a.id,source:v?.source??null,deviceKey:h?o:void 0},M=G({},T);this.applyValue(M,a.key,a.value,a.state)&&(c||(s=G({},s),c=true),s[o]=M);}}return c?s:r});}parsePath(e){if(!e.startsWith(l.ROOT_PREFIX))return null;let i=e.slice(l.ROOT_PREFIX.length),t=i.indexOf(".");return t<=0||t===i.length-1?null:{id:i.slice(0,t),key:i.slice(t+1)}}normalizeMetricKey(e){let i=e.match(/^phase\.([^.]+)\.(current|frequency|lineNeutralVoltage|realPower)$/);if(i){let t=this.resolveLineKey(i[1]);if(!t)return null;let r=i[2];return r==="current"?`${t}.current`:r==="frequency"?`${t}.frequency`:r==="lineNeutralVoltage"?`${t}.voltage`:`${t}.realPower`}return e==="total.realPower"?"power":e}resolveLineKey(e){let i=e.trim().toLowerCase();return ["0","1","l1","line1","phase1","a"].includes(i)?"line1":["2","l2","line2","phase2","b"].includes(i)?"line2":["3","l3","line3","phase3","c"].includes(i)?"line3":null}trackDiscoveredBus(e){let i=this.discoveredBusIds();i.includes(e)||this.discoveredBusIds.set([...i,e].sort((t,r)=>t.localeCompare(r)));}applyValue(e,i,t,r){let s=this.normalizeMetricKey(i);if(!s)return false;switch(s){case "name":return this.setValue(e,"name",this.toStringValue(t));case "location":return this.setValue(e,"location",this.toStringValue(t));case "associatedBus":return this.setValue(e,"associatedBus",this.toStringValue(t));case "mode":return this.setMetricValue(e,"mode","modeState",this.toStringValue(t),r);case "voltage":return this.setMetricValue(e,"line1Voltage","line1VoltageState",this.toNumber(t,"V"),r);case "current":return this.setMetricValue(e,"line1Current","line1CurrentState",this.toNumber(t,"A"),r);case "frequency":return this.setMetricValue(e,"line1Frequency","line1FrequencyState",this.toNumber(t,"Hz"),r);case "line1.voltage":return this.setMetricValue(e,"line1Voltage","line1VoltageState",this.toNumber(t,"V"),r);case "line1.current":return this.setMetricValue(e,"line1Current","line1CurrentState",this.toNumber(t,"A"),r);case "line1.frequency":return this.setMetricValue(e,"line1Frequency","line1FrequencyState",this.toNumber(t,"Hz"),r);case "line1.realPower":return this.setMetricValue(e,"power","line1CurrentState",this.toNumber(t,"W"),r);case "line2.voltage":return this.setMetricValue(e,"line2Voltage","line2VoltageState",this.toNumber(t,"V"),r);case "line2.current":return this.setMetricValue(e,"line2Current","line2CurrentState",this.toNumber(t,"A"),r);case "line2.frequency":return this.setMetricValue(e,"line2Frequency","line2FrequencyState",this.toNumber(t,"Hz"),r);case "line2.realPower":return this.setMetricValue(e,"power","line2CurrentState",this.toNumber(t,"W"),r);case "line3.voltage":return this.setMetricValue(e,"line3Voltage","line3VoltageState",this.toNumber(t,"V"),r);case "line3.current":return this.setMetricValue(e,"line3Current","line3CurrentState",this.toNumber(t,"A"),r);case "line3.frequency":return this.setMetricValue(e,"line3Frequency","line3FrequencyState",this.toNumber(t,"Hz"),r);case "line3.realPower":return this.setMetricValue(e,"power","line3CurrentState",this.toNumber(t,"W"),r);case "power":return this.setMetricValue(e,"power","line1CurrentState",this.toNumber(t,"W"),r);default:return false}}setValue(e,i,t){return Object.is(e[i],t)?false:(e[i]=t,true)}setMetricValue(e,i,t,r,s){let c=!Object.is(e[i],r),a=!Object.is(e[t],s);return !c&&!a?false:(e[i]=r,e[t]=s,true)}requestRender(e){let i=this.widgetColors();!this.svg||!i||(this.pendingRenderSnapshot=e??{buses:this.visibleBuses(),displayModels:this.displayModels(),widgetColors:i},this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;let t=this.pendingRenderSnapshot;this.pendingRenderSnapshot=null,t&&this.render(t);})));}render(e){if(!this.layer||!this.svg)return;let i=this.isCompactCardMode(),t=i?C:e$1,r=i?l.COMPACT_CARD_HEIGHT:l.CARD_HEIGHT,s=e.buses.map((o,h)=>({key:o.deviceKey??o.id,bus:o,y:h*(r+l.CARD_GAP)})),c=s.length?s[s.length-1].y+r:r;this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${c}`);let a=this.layer.selectAll("g.ac-card").data(s,o=>o.key),n=a.enter().append("g").attr("class","ac-card");n.append("rect").attr("class","ac-state-bar"),n.append("text").attr("class","ac-title"),n.append("text").attr("class","ac-id"),n.append("text").attr("class","ac-mode"),n.append("text").attr("class","ac-bus"),n.append("text").attr("class","ac-metrics-1"),n.append("text").attr("class","ac-metrics-2");let d=n.merge(a);d.attr("transform",o=>`translate(0, ${o.y})`),d.select("rect.ac-state-bar").attr("x",1.5).attr("y",1.5).attr("rx",t.stateBarCornerRadius).attr("ry",t.stateBarCornerRadius).attr("width",3).attr("height",r-3).attr("fill",o=>e.displayModels[o.key]?.stateBarColor??e.widgetColors.dim),e.buses.length>1?d.select("text.ac-title").attr("x",t.titleX).attr("y",t.titleY).attr("font-size",t.titleFontSize).attr("fill",o=>e.displayModels[o.key]?.titleTextColor??"var(--kip-contrast-color)").text(o=>e.displayModels[o.key]?.titleText??this.resolveTitleText(o.bus)):d.select("text.ac-title").text(""),d.select("text.ac-id").attr("x",t.idX).attr("y",t.idY).attr("text-anchor","end").attr("font-size",t.idFontSize).attr("fill","var(--kip-contrast-dim-color)").text(o=>o.bus.id),d.select("text.ac-mode").attr("x",t.metaLeftX).attr("y",t.metaY).attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",o=>e.displayModels[o.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(o=>e.displayModels[o.key]?.modeText??""),d.select("text.ac-bus").attr("x",t.metaRightX).attr("y",t.metaY).attr("text-anchor","end").attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",o=>e.displayModels[o.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(o=>e.displayModels[o.key]?.busText??""),d.select("text.ac-metrics-1").attr("x",t.lineOneX).attr("y",t.lineOneY).attr("font-size",t.lineOneFontSize).attr("fill",o=>e.displayModels[o.key]?.primaryMetricsTextColor??"var(--kip-contrast-color)").text(o=>e.displayModels[o.key]?.metricsLineOne??""),d.select("text.ac-metrics-2").attr("x",t.lineTwoX).attr("y",t.lineTwoY).attr("font-size",t.lineTwoFontSize).attr("opacity",.85).attr("fill",o=>e.displayModels[o.key]?.secondaryMetricsTextColor??"var(--kip-contrast-color)").text(o=>e.displayModels[o.key]?.metricsLineTwo??""),a.exit().remove();}displayName(e){return e.name?.trim()||e.id}resolveTitleText(e){return e.name||`AC ${e.id}`}resolveModeText(e){return e.mode?`Mode ${e.mode}`:"Mode -"}buildMetricRows(e){let i=this.cardMode(),t=(i.metrics.length?i.metrics:l.DEFAULT_CONFIG.ac?.cardMode?.metrics??[]).map(c=>this.toMetricLabel(c,e)).filter(c=>!!c);if(!t.length)return ["L1 - - -","L2 - - L3 - -"];let r=t.slice(0,2).join(" "),s=t.slice(2,4).join(" ");return [r||" ",s||" "]}toMetricLabel(e,i){switch(e){case "line1Voltage":return `L1V ${this.formatValue(i.line1Voltage,"V")}`;case "line1Current":return `L1A ${this.formatValue(i.line1Current,"A")}`;case "line1Frequency":return `L1Hz ${this.formatValue(i.line1Frequency,"Hz")}`;case "line2Voltage":return `L2V ${this.formatValue(i.line2Voltage,"V")}`;case "line2Current":return `L2A ${this.formatValue(i.line2Current,"A")}`;case "line2Frequency":return `L2Hz ${this.formatValue(i.line2Frequency,"Hz")}`;case "line3Voltage":return `L3V ${this.formatValue(i.line3Voltage,"V")}`;case "line3Current":return `L3A ${this.formatValue(i.line3Current,"A")}`;case "line3Frequency":return `L3Hz ${this.formatValue(i.line3Frequency,"Hz")}`;default:return null}}formatValue(e,i){return e==null||Number.isNaN(e)?"-":`${e.toFixed(1)} ${i}`}toStringValue(e){return typeof e=="string"?e:null}resolveMostSevereState(...e){return e.some(i=>i===n$1.Alert)?n$1.Alert:e.some(i=>i===n$1.Alarm)?n$1.Alarm:e.some(i=>i===n$1.Warn)?n$1.Warn:e.some(i=>i===n$1.Normal)?n$1.Normal:null}toNumber(e,i){if(e==null||typeof e=="boolean")return null;let t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return null;let r=this.units.convertToUnit(i,t);return typeof r=="number"&&Number.isFinite(r)?r:null}static \u0275fac=function(i){return new(i||l)};static \u0275cmp=JD({type:l,selectors:[["widget-ac"]],viewQuery:function(i,t){i&1&&eg(t.svgRef,ie,5),i&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["acSvg",""],[3,"text","color"],["aria-hidden","false",1,"ac-svg"],[1,"ac-empty"],[1,"ac-empty-title"],[1,"ac-empty-sub"]],template:function(i,t){i&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,re,5,0,"div",3)),i&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasBuses()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.ac-svg[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;z-index:20;padding:0 10px 10px}.ac-empty[_ngcontent-%COMP%]{position:absolute;inset:0;margin:10px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;text-align:center;color:var(--mat-sys-on-surface);background:color-mix(in srgb,var(--kip-widget-card-background-color) 92%,transparent)}.ac-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.ac-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{Y as WidgetAcComponent};
@@ -1 +1 @@
1
- import {a as a$1}from'./chunk-D4xZ2tGB.js';import {d1 as Hj,w,du as p,G as Gi,N,aX as He,a as G,$ as $j,W as Wp,F as Fa,dn as ge,J as JD,_ as _w,M as Mw,f as eg,K as Kw,H as Dr,eb as rw,cp as Uh,bD as HT,g as qw,b_ as Gh,bE as $T,ci as dl,cj as fl,e as EE,dP as pp}from'./main-BAV5VDOD.js';var R=(()=>{class n{sanitizer=w(Dr);transform(e){return this.sanitizer.bypassSecurityTrustResourceUrl(e)}static \u0275fac=function(t){return new(t||n)};static \u0275pipe=rw({name:"safe",type:n,pure:true})}return n})();var $=["freeboardSkIframe"];function z(n,v){if(n&1&&(Uh(0,"iframe",1,0),HT(2,"safe")),n&2){let e=qw();Gh("src",$T(2,1,e.widgetUrlSafe),pp);}}function A(n,v){n&1&&Uh(0,"div",4);}function B(n,v){if(n&1&&(dl(0,"div",2),Uh(1,"iframe",3,0),HT(3,"safe"),_w(4,A,1,0,"div",4),fl()),n&2){let e=qw();EE(),Gh("src",$T(3,2,e.widgetUrlSafe),pp),EE(3),Mw(e.dashboard.isDashboardStatic()?-1:4);}}var ae=(()=>{class n{id=Hj();type=Hj();theme=Hj();disableWidgetShell=Hj(false);swipeDisabled=Hj(false);runtime=w(p,{optional:true});appSettings=w(Gi);app=w(N);auth=w(He);dashboard=w(G);iframe=$j.required("freeboardSkIframe");authToken=Wp(this.auth.authToken$,{initialValue:null});viewReady=false;iframeLoaded=false;widgetUrl=null;widgetUrlSafe="";static DEFAULT_CONFIG={};constructor(){window.addEventListener("message",this.handleIframeGesture),Fa(()=>{let e=this.authToken();ge(()=>{let t=e?.token,i=this.appSettings.signalkUrl?.url;this.widgetUrl=i?t?`${i}/@signalk/freeboard-sk/?token=${t}`:`${i}/@signalk/freeboard-sk/`:null,this.widgetUrlSafe=this.widgetUrl??"";});}),Fa(()=>{let e=this.app.isNightMode();ge(()=>{!this.iframeLoaded||!this.viewReady||this.appSettings.getRedNightMode()&&this.sendMessage({commands:{nightModeEnable:e}});});});}ngAfterViewInit(){this.viewReady=true;try{this.iframe().nativeElement.onload=()=>{this.iframeLoaded=!0,this.sendMessage({settings:{autoNightMode:!1}}),this.injectSwipeScript();};}catch(e){}}sendMessage(e,t="*"){let i=this.iframe()?.nativeElement?.contentWindow;i&&this.iframeLoaded&&i.postMessage(e,t);}injectSwipeScript(){if(this.swipeDisabled())return;let e=this.iframe().nativeElement.contentWindow,t=this.iframe().nativeElement.contentDocument;if(!t||!e){console.error("[FSK Widget] Iframe contentDocument or contentWindow is undefined.");return}try{let i=`kip-gesture-inject-${this.id()}`;if(t.getElementById(i))return;let s=a$1({instanceId:this.id()}),r=t.createElement("script");r.id=i,r.textContent=s,t.body.appendChild(r);}catch(i){console.warn("[FSK Widget] Failed to inject swipe script into iframe:",i);}}handleIframeGesture=e=>{if(!e.data||!this.viewReady)return;let t=null;try{t=this.iframe()?.nativeElement?.contentWindow??null;}catch(r){t=null;}if(!t||e.source!==t)return;let i=this.getExpectedIframeOrigin();if(i&&e.origin!==i)return;let s=this.id();if(e.data.gesture&&e.data.eventData?.instanceId===s)switch(e.data.gesture){case "swipeup":this.dashboard.isDashboardStatic()&&this.dashboard.navigateToPreviousDashboard();break;case "swipedown":this.dashboard.isDashboardStatic()&&this.dashboard.navigateToNextDashboard();break;case "swipeleft":window.document.dispatchEvent(new Event("openLeftSidenav",{bubbles:true,cancelable:true}));break;case "swiperight":window.document.dispatchEvent(new Event("openRightSidenav",{bubbles:true,cancelable:true}));break}if(e.data.type==="keydown"&&e.data.keyEventData?.instanceId===s){let{key:r,ctrlKey:L,shiftKey:O}=e.data.keyEventData,P=new KeyboardEvent("keydown",{key:r,ctrlKey:L,shiftKey:O,bubbles:true,cancelable:true});document.dispatchEvent(P);}};getExpectedIframeOrigin(){let e=this.widgetUrl||this.appSettings.signalkUrl?.url;if(!e)return null;try{return new URL(e).origin}catch(t){return null}}ngOnDestroy(){if(window.removeEventListener("message",this.handleIframeGesture),this.iframe){try{this.iframe().nativeElement.onload=null;}catch(e){}try{let e=this.iframe()?.nativeElement.contentDocument;if(e){let t=`kip-gesture-inject-${this.id()}`,i=e.getElementById(t);i&&i.parentNode&&i.parentNode.removeChild(i);}}catch(e){}}}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=JD({type:n,selectors:[["widget-freeboardsk"]],viewQuery:function(t,i){t&1&&eg(i.iframe,$,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],disableWidgetShell:[1,"disableWidgetShell"],swipeDisabled:[1,"swipeDisabled"]},decls:2,vars:1,consts:[["freeboardSkIframe",""],["width","100%","height","100%","frameborder","0","sandbox","allow-same-origin allow-scripts allow-forms",1,"freeboardsk-iframe","no-shell",3,"src"],[1,"widget-shell",2,"overflow","clip","position","relative","width","100%","height","100%"],["width","100%","height","100%","frameborder","0","sandbox","allow-same-origin allow-scripts allow-forms",1,"freeboardsk-iframe",3,"src"],[1,"widgetOverlay"]],template:function(t,i){t&1&&_w(0,z,3,3,"iframe",1)(1,B,5,4,"div",2),t&2&&Mw(i.disableWidgetShell()?0:1);},dependencies:[R],styles:[".widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent}"]})}return n})();export{ae as WidgetFreeboardskComponent};
1
+ import {a as a$1}from'./chunk-ibauGmSP.js';import {d1 as Hj,w,du as p,G as Gi,N,aX as He,a as G,$ as $j,W as Wp,F as Fa,dn as ge,J as JD,_ as _w,M as Mw,f as eg,K as Kw,H as Dr,eb as rw,cp as Uh,bD as HT,g as qw,b_ as Gh,bE as $T,ci as dl,cj as fl,e as EE,dP as pp}from'./main-YKDNK5VZ.js';var R=(()=>{class n{sanitizer=w(Dr);transform(e){return this.sanitizer.bypassSecurityTrustResourceUrl(e)}static \u0275fac=function(t){return new(t||n)};static \u0275pipe=rw({name:"safe",type:n,pure:true})}return n})();var $=["freeboardSkIframe"];function z(n,v){if(n&1&&(Uh(0,"iframe",1,0),HT(2,"safe")),n&2){let e=qw();Gh("src",$T(2,1,e.widgetUrlSafe),pp);}}function A(n,v){n&1&&Uh(0,"div",4);}function B(n,v){if(n&1&&(dl(0,"div",2),Uh(1,"iframe",3,0),HT(3,"safe"),_w(4,A,1,0,"div",4),fl()),n&2){let e=qw();EE(),Gh("src",$T(3,2,e.widgetUrlSafe),pp),EE(3),Mw(e.dashboard.isDashboardStatic()?-1:4);}}var ae=(()=>{class n{id=Hj();type=Hj();theme=Hj();disableWidgetShell=Hj(false);swipeDisabled=Hj(false);runtime=w(p,{optional:true});appSettings=w(Gi);app=w(N);auth=w(He);dashboard=w(G);iframe=$j.required("freeboardSkIframe");authToken=Wp(this.auth.authToken$,{initialValue:null});viewReady=false;iframeLoaded=false;widgetUrl=null;widgetUrlSafe="";static DEFAULT_CONFIG={};constructor(){window.addEventListener("message",this.handleIframeGesture),Fa(()=>{let e=this.authToken();ge(()=>{let t=e?.token,i=this.appSettings.signalkUrl?.url;this.widgetUrl=i?t?`${i}/@signalk/freeboard-sk/?token=${t}`:`${i}/@signalk/freeboard-sk/`:null,this.widgetUrlSafe=this.widgetUrl??"";});}),Fa(()=>{let e=this.app.isNightMode();ge(()=>{!this.iframeLoaded||!this.viewReady||this.appSettings.getRedNightMode()&&this.sendMessage({commands:{nightModeEnable:e}});});});}ngAfterViewInit(){this.viewReady=true;try{this.iframe().nativeElement.onload=()=>{this.iframeLoaded=!0,this.sendMessage({settings:{autoNightMode:!1}}),this.injectSwipeScript();};}catch(e){}}sendMessage(e,t="*"){let i=this.iframe()?.nativeElement?.contentWindow;i&&this.iframeLoaded&&i.postMessage(e,t);}injectSwipeScript(){if(this.swipeDisabled())return;let e=this.iframe().nativeElement.contentWindow,t=this.iframe().nativeElement.contentDocument;if(!t||!e){console.error("[FSK Widget] Iframe contentDocument or contentWindow is undefined.");return}try{let i=`kip-gesture-inject-${this.id()}`;if(t.getElementById(i))return;let s=a$1({instanceId:this.id()}),r=t.createElement("script");r.id=i,r.textContent=s,t.body.appendChild(r);}catch(i){console.warn("[FSK Widget] Failed to inject swipe script into iframe:",i);}}handleIframeGesture=e=>{if(!e.data||!this.viewReady)return;let t=null;try{t=this.iframe()?.nativeElement?.contentWindow??null;}catch(r){t=null;}if(!t||e.source!==t)return;let i=this.getExpectedIframeOrigin();if(i&&e.origin!==i)return;let s=this.id();if(e.data.gesture&&e.data.eventData?.instanceId===s)switch(e.data.gesture){case "swipeup":this.dashboard.isDashboardStatic()&&this.dashboard.navigateToPreviousDashboard();break;case "swipedown":this.dashboard.isDashboardStatic()&&this.dashboard.navigateToNextDashboard();break;case "swipeleft":window.document.dispatchEvent(new Event("openLeftSidenav",{bubbles:true,cancelable:true}));break;case "swiperight":window.document.dispatchEvent(new Event("openRightSidenav",{bubbles:true,cancelable:true}));break}if(e.data.type==="keydown"&&e.data.keyEventData?.instanceId===s){let{key:r,ctrlKey:L,shiftKey:O}=e.data.keyEventData,P=new KeyboardEvent("keydown",{key:r,ctrlKey:L,shiftKey:O,bubbles:true,cancelable:true});document.dispatchEvent(P);}};getExpectedIframeOrigin(){let e=this.widgetUrl||this.appSettings.signalkUrl?.url;if(!e)return null;try{return new URL(e).origin}catch(t){return null}}ngOnDestroy(){if(window.removeEventListener("message",this.handleIframeGesture),this.iframe){try{this.iframe().nativeElement.onload=null;}catch(e){}try{let e=this.iframe()?.nativeElement.contentDocument;if(e){let t=`kip-gesture-inject-${this.id()}`,i=e.getElementById(t);i&&i.parentNode&&i.parentNode.removeChild(i);}}catch(e){}}}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=JD({type:n,selectors:[["widget-freeboardsk"]],viewQuery:function(t,i){t&1&&eg(i.iframe,$,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],disableWidgetShell:[1,"disableWidgetShell"],swipeDisabled:[1,"swipeDisabled"]},decls:2,vars:1,consts:[["freeboardSkIframe",""],["width","100%","height","100%","frameborder","0","sandbox","allow-same-origin allow-scripts allow-forms",1,"freeboardsk-iframe","no-shell",3,"src"],[1,"widget-shell",2,"overflow","clip","position","relative","width","100%","height","100%"],["width","100%","height","100%","frameborder","0","sandbox","allow-same-origin allow-scripts allow-forms",1,"freeboardsk-iframe",3,"src"],[1,"widgetOverlay"]],template:function(t,i){t&1&&_w(0,z,3,3,"iframe",1)(1,B,5,4,"div",2),t&2&&Mw(i.disableWidgetShell()?0:1);},dependencies:[R],styles:[".widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent}"]})}return n})();export{ae as WidgetFreeboardskComponent};
@@ -1 +1 @@
1
- import {d1 as Hj,w,du as p,dv as rt$1,cu as T,a as G,aZ as F,aY as xe,$ as $j,v as vt,bG as Bj,D as Dt,F as Fa,dn as ge,a_ as Gp,J as JD,b2 as Ln,b4 as Xe,b5 as Pn,b9 as rn,O as Op,bh as xp,y as yt,b as wt,cR as zt,bg as mt$1,bd as an,P as Pi,c as $h,u as ul,k as Qh,cn as wd,T as TT,_ as _w,e as EE,M as Mw,f as eg,K as Kw,g as qw,bp as gl,h as Fw,cV as Td,bi as Eg,bk as cD,bm as Ig,bo as lD,l as ud,m as dd,bj as ST}from'./main-BAV5VDOD.js';import {c}from'./chunk-Dxlia2NE.js';var at=["canvasMainRef"];function ot(o,v){if(o&1&&(Pi(0,"div",8),wd(),Pi(1,"svg",11)(2,"text",12),TT(3),ul()()()),o&2){let t=qw();EE(3),gl("@ ",t.startAtTime());}}function st(o,v){if(o&1){let t=Fw();Pi(0,"button",13),Qh("click",function(){ud(t);let i=qw();return dd(i.sendStartTimerCommand("start"))}),Pi(1,"mat-icon",5),wd(),Pi(2,"svg",6)(3,"text",14),TT(4,"Start"),ul()()()(),Td(),Pi(5,"button",15),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(-60))}),Pi(6,"mat-icon",5),wd(),Pi(7,"svg",6)(8,"text",14),TT(9,"-1m"),ul()()()(),Td(),Pi(10,"button",16),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(60))}),Pi(11,"mat-icon",5),wd(),Pi(12,"svg",6)(13,"text",14),TT(14,"+1m"),ul()()()();}}function rt(o,v){if(o&1){let t=Fw();Pi(0,"button",17),Qh("click",function(){ud(t);let i=qw();return dd(i.sendStartTimerCommand("sync"))}),Pi(1,"mat-icon",5),wd(),Pi(2,"svg",18)(3,"text",19),TT(4,"Sync"),ul()()()(),Td(),Pi(5,"button",20),Qh("click",function(){ud(t);let i=qw();return dd(i.sendStartTimerCommand("reset"))}),Pi(6,"mat-icon",5),wd(),Pi(7,"svg",18)(8,"text",19),TT(9,"Reset"),ul()()()();}}function lt(o,v){if(o&1){let t=Fw();Pi(0,"button",21),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(-60))}),Pi(1,"mat-icon",5),wd(),Pi(2,"svg",22)(3,"text",23),TT(4,"-1m"),ul()()()(),Td(),Pi(5,"button",24),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(-1))}),Pi(6,"mat-icon",5),wd(),Pi(7,"svg",22)(8,"text",23),TT(9,"-1s"),ul()()()(),Td(),Pi(10,"button",25),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(1))}),Pi(11,"mat-icon",5),wd(),Pi(12,"svg",22)(13,"text",23),TT(14,"+1s"),ul()()()(),Td(),Pi(15,"button",26),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(60))}),Pi(16,"mat-icon",5),wd(),Pi(17,"svg",22)(18,"text",23),TT(19,"+1m"),ul()()()();}}function mt(o,v){if(o&1){let t=Fw();Pi(0,"input",27),Eg("ngModelChange",function(i){ud(t);let a=qw();return ST(a.startAtTimeEdit,i)||(a.startAtTimeEdit=i),dd(i)}),Qh("change",function(){ud(t);let i=qw();return dd(i.setStartTime())}),ul(),cD();}if(o&2){let t=qw();Ig("ngModel",t.startAtTimeEdit),lD();}}function ct(o,v){o&1&&$h(0,"div",10);}var Et=(()=>{class o{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:false,displayName:"TTS",nextDashboard:0,playBeeps:true,filterSelfPaths:true,paths:{ttsPath:{description:"Time to the Start in seconds",path:"self.navigation.racing.timeToStart",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"s",showConvertUnitTo:false,showPathSkUnitsFilter:false,pathSkUnitsFilter:"s",sampleTime:500},startTimePath:{description:"Time of the start",path:"self.navigation.racing.startTime",source:"default",pathType:"Date",pathRequired:false,isPathConfigurable:false,sampleTime:500},dtsPath:{description:"Distance to Start Line path, used to determine OCS",path:"self.navigation.racing.distanceStartline",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:false,pathSkUnitsFilter:"m",sampleTime:500}},color:"contrast",enableTimeout:false,dataTimeout:5,ignoreZones:true};runtime=w(p);streams=w(rt$1);signalk=w(T);dashboard=w(G);canvas=w(F);destroyRef=w(xe);canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;titleBitmap=null;titleBitmapText=null;titleBitmapColor=null;labelColor=vt("");mode=vt(1);ttsValue=null;dtsValue=null;valueColor="";valueStateColor="";startAtTime=vt("00:00:00");startAtTimeEdit=Bj("");normalizedConfig=Dt(()=>this.runtime.options()??o.DEFAULT_CONFIG);constructor(){Fa(()=>{let t=this.normalizedConfig(),e=this.theme();e&&ge(()=>{let i=c(t.color??"contrast",e);this.labelColor.set(i.dim),this.valueColor=i.color,this.valueStateColor=i.color,this.draw();});}),Fa(()=>{let t=this.normalizedConfig();t.paths?.ttsPath?.path&&ge(()=>this.streams.observe("ttsPath",a=>{let s=this.ttsValue;this.ttsValue=a?.data?.value??null,this.updateValueColor(),this.draw(),this.shouldBeep(s,this.ttsValue)&&this.beepForValue(this.ttsValue),(t.nextDashboard??-1)>=0&&s===1&&this.ttsValue===0&&(!this.dtsValue||this.dtsValue>=0);}));}),Fa(()=>{this.normalizedConfig().paths?.startTimePath?.path&&ge(()=>this.streams.observe("startTimePath",a=>{let s=a?.data?.value;if(!s)this.startAtTime.set("HH:MM:SS"),this.startAtTimeEdit.set("HH:MM:SS"),this.mode()===2&&this.mode.set(1);else {let l=new Date(s);this.startAtTimeEdit.set(l.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})),this.startAtTime.set(this.startAtTimeEdit());}this.draw();}));}),Fa(()=>{this.normalizedConfig().paths?.dtsPath?.path&&ge(()=>this.streams.observe("dtsPath",a=>{this.dtsValue=a?.data?.value??null;}));}),this.signalk.subscribeRequest().pipe(Gp(this.destroyRef)).subscribe(t=>{t.widgetUUID===this.id()&&t.statusCode===200&&this.beep(600,20);});}ngAfterViewInit(){this.canvasElement=this.canvasRef().nativeElement,this.ctx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(t,e)=>{this.cssWidth=t,this.cssHeight=e,this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.draw();}ngOnDestroy(){try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(t){}}toggleMode(){this.mode.update(e=>(e+1)%5);let t=this.ttsValue;this.mode()===1&&this.isStartTimerRunning()&&this.mode.set(2),this.mode()===2&&t!==0&&!this.isStartTimerRunning()&&this.mode.set(3),this.draw();}sendStartTimerCommand(t){this.signalk.putRequest("navigation.racing.setStartTime",{command:t},this.id()),t==="start"&&this.mode.set(0),t==="reset"&&(this.startAtTime.set("HH:MM:SS"),this.mode.set(1));}adjustStartTime(t){this.signalk.putRequest("navigation.racing.setStartTime",{command:"adjust",delta:t},this.id());}setStartTime(){let t=new Date,e=this.startAtTimeEdit().split(":").map(Number),i=e[0],a=e[1],s=e.length>=3?e[2]:0,l=new Date(t);l.setHours(i,a,s,0),l<=t&&l.setDate(l.getDate()+1),this.mode.set(0),this.signalk.putRequest("navigation.racing.setStartTime",{command:"set",startTime:l.toISOString()},this.id());}isStartTimerRunning(){return (this.ttsValue??0)>0&&this.startAtTime()!==null&&this.startAtTime()!=="HH:MM:SS"}shouldBeep(t,e){return e==null||this.startAtTime()==="HH:MM:SS"||!this.runtime.options()?.playBeeps?false:e===0&&t!==0||e<10&&e>=0||e<60&&e%10===0?true:e%60===0}beepForValue(t){t===0?this.beep(500,1e3):t<10?this.beep(450,100):t<60&&t%10===0?this.beep(400,150):t%60===0&&this.beep(350,200);}updateValueColor(){let t=this.theme(),e=this.normalizedConfig();t&&(e.ignoreZones?this.ttsValue?this.ttsValue===0?this.valueStateColor=this.valueColor:this.ttsValue<10?this.valueStateColor=(this.dtsValue??0)<0?t.zoneAlarm:t.zoneWarn:this.ttsValue<60?this.valueStateColor=t.zoneAlert:this.valueStateColor=this.valueColor:this.valueStateColor=this.valueColor:this.valueStateColor=this.valueColor,this.ttsValue===0?(this.mode.set(2),(this.dtsValue??0)<0&&(this.valueStateColor=t.zoneAlarm)):this.mode()===1&&this.isStartTimerRunning()&&this.mode.set(2));}toHHMMSS(t){if(t==null||isNaN(t))return "-:--";let e=t<0;e&&(t=-t);let i=Math.floor(t/3600),a=Math.floor(t%3600/60),s=Math.floor(t%60),l=e?"-":"";return i===0?`${l}${a.toString().padStart(1,"0")}:${s.toString().padStart(2,"0")}`:`${l}${i.toString().padStart(1,"0")}:${a.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`}getValueText(){return this.toHHMMSS(this.ttsValue??0)}draw(){if(!this.ctx||!this.canvasElement)return;let e=this.runtime.options()?.displayName||"TTS",i=this.labelColor();(!this.titleBitmap||this.titleBitmap.width!==this.canvasElement.width||this.titleBitmap.height!==this.canvasElement.height||this.titleBitmapText!==e||this.titleBitmapColor!==i)&&(this.titleBitmap=this.canvas.createTitleBitmap(e,i,"normal",this.cssWidth,this.cssHeight),this.titleBitmapText=e,this.titleBitmapColor=i),this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),this.titleBitmap&&this.ctx.drawImage(this.titleBitmap,0,0,this.cssWidth,this.cssHeight),this.canvas.drawText(this.ctx,this.getValueText(),Math.floor(this.cssWidth*.5),Math.floor(this.cssHeight*.55),Math.floor(this.cssWidth*.95),Math.floor(this.cssHeight*.9),"bold",this.valueStateColor,"center","middle");}beep(t=440,e=100){if(!this.runtime.options()?.playBeeps)return;let i=window.AudioContext||window.webkitAudioContext,a=new i,s=a.createOscillator(),l=a.createGain();s.connect(l),l.connect(a.destination),s.type="sine",s.frequency.value=t,l.gain.value=.1,s.start(),s.stop(a.currentTime+e/1e3);}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=JD({type:o,selectors:[["widget-racer-timer"]],viewQuery:function(e,i){e&1&&eg(i.canvasRef,at,5),e&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],startAtTimeEdit:[1,"startAtTimeEdit"]},outputs:{startAtTimeEdit:"startAtTimeEditChange"},decls:15,vars:2,consts:[["canvasMainRef",""],[1,"filler"],[1,"timer-canvas"],[1,"buttons-container"],["mat-flat-button","","matTooltip","Select the control mode",1,"button","select-button",3,"click"],[1,"buttons-svg-icon"],["width","100%","height","100%","viewBox","0 0 80 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","40","y","9"],[1,"start-at"],["matInput","","type","time","step","1","matTooltip","Set an absolute start time",1,"set-start-at",3,"ngModel"],[1,"widgetOverlay"],["width","100%","height","100%","viewBox","0 0 80 12","preserveAspectRatio","xMidYMid meet",1,"svg-content","svg-start-at"],["x","40","y","10"],["mat-flat-button","","matTooltip","Start the race timer",1,"button","main-button",3,"click"],["x","40","y","11"],["mat-flat-button","","matTooltip","Remove 1 minute from the timer",1,"button","other-small-button",3,"click"],["mat-flat-button","","matTooltip","Add 1 minute to the timer",1,"button","other-small-button",3,"click"],["mat-flat-button","","matTooltip","Sync the timer to nearest minute",1,"button","main-button",3,"click"],["width","100%","height","100%","viewBox","0 0 100 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","50","y","11"],["mat-flat-button","","matTooltip","Stop and reset the timer",1,"button","other-button",3,"click"],["mat-flat-button","","matTooltip","Reduce the timer by 1 minute",1,"button","main-small-button",3,"click"],["width","100%","height","100%","viewBox","0 0 50 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","25","y","11"],["mat-flat-button","","matTooltip","Reduce the timer by 1 second",1,"button","other-small-button",3,"click"],["mat-flat-button","","matTooltip","Increase the timer by 1 second",1,"button","other-small-button",3,"click"],["mat-flat-button","","matTooltip","Increase the timer by 1 minute",1,"button","main-small-button",3,"click"],["matInput","","type","time","step","1","matTooltip","Set an absolute start time",1,"set-start-at",3,"ngModelChange","change","ngModel"]],template:function(e,i){if(e&1&&(Pi(0,"div",1),$h(1,"canvas",2,0),ul(),Pi(3,"div",3)(4,"button",4),Qh("click",function(){return i.toggleMode()}),Pi(5,"mat-icon",5),wd(),Pi(6,"svg",6)(7,"text",7),TT(8,"\u22EE"),ul()()()(),_w(9,ot,4,1,"div",8)(10,st,15,0)(11,rt,10,0)(12,lt,20,0)(13,mt,1,1,"input",9),ul(),_w(14,ct,1,0,"div",10)),e&2){let a;EE(9),Mw((a=i.mode())===0?9:a===1?10:a===2?11:a===3?12:a===4?13:-1),EE(5),Mw(i.dashboard.isDashboardStatic()?-1:14);}},dependencies:[Ln,Xe,Pn,rn,Op,xp,yt,wt,zt,mt$1,an],styles:["[_nghost-%COMP%]{overflow:clip;display:block;height:100%;width:100%}.timer-wrapper[_ngcontent-%COMP%]{width:100%;height:100%;min-height:1px}.timer-canvas[_ngcontent-%COMP%]{width:100%!important;height:100%!important;display:block}.filler[_ngcontent-%COMP%]{width:100%;height:76%}.buttons-container[_ngcontent-%COMP%]{display:flex;flex-wrap:nowrap;justify-content:space-between;column-gap:2%;position:relative;height:24%;width:100%;padding:0 10px 14px;z-index:20;pointer-events:auto;align-items:center}.button[_ngcontent-%COMP%]{min-width:0px;width:100%;border-radius:12px;align-items:center;justify-content:center;cursor:pointer;--mat-button-filled-container-height: 100%;--mat-button-filled-horizontal-padding: 0px;--mat-button-filled-icon-spacing: 0px}.select-button[_ngcontent-%COMP%]{flex:none;width:18%;--mat-button-filled-container-color: var(--kip-blue-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.main-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.other-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-blue-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.main-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.other-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-blue-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.set-start-at[_ngcontent-%COMP%]{flex:1 1 auto;background-color:var(--kip-contrast-color)}.start-at[_ngcontent-%COMP%]{height:100%;width:100%;flex:1 1 auto}.start-at[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{fill:var(--kip-contrast-color)}.start-at[_ngcontent-%COMP%] svg[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-family:Roboto;font-size:9px;font-weight:400;text-align:center;text-anchor:middle;font-style:normal;font-variant:normal;font-stretch:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke:none}.buttons-svg-icon[_ngcontent-%COMP%]{width:100%;height:100%;margin:0;padding:0}.svg-content[_ngcontent-%COMP%]{width:100%;height:100%;padding:0;margin:0}.svg-content[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-family:Roboto;font-size:15px;font-weight:700;text-align:center;text-anchor:middle;font-style:normal;font-variant:normal;font-stretch:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke:none}.svg-start-at[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{fill:var(--kip-contrast-dim-color)}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent;z-index:21}"]})}return o})();export{Et as WidgetRacerTimerComponent};
1
+ import {d1 as Hj,w,du as p,dv as rt$1,cu as T,a as G,aZ as R,aY as xe,$ as $j,v as vt,bG as Bj,D as Dt,F as Fa,dn as ge,a_ as Gp,J as JD,b2 as Ln,b4 as Xe,b5 as Pn,b9 as rn,O as Op,bh as xp,y as yt,b as wt,cR as zt,bg as mt$1,bd as an,P as Pi,c as $h,u as ul,k as Qh,cn as wd,T as TT,_ as _w,e as EE,M as Mw,f as eg,K as Kw,g as qw,bp as gl,h as Fw,cV as Td,bi as Eg,bk as cD,bm as Ig,bo as lD,l as ud,m as dd,bj as ST}from'./main-YKDNK5VZ.js';import {c}from'./chunk-BIb-xYiS.js';var at=["canvasMainRef"];function ot(o,v){if(o&1&&(Pi(0,"div",8),wd(),Pi(1,"svg",11)(2,"text",12),TT(3),ul()()()),o&2){let t=qw();EE(3),gl("@ ",t.startAtTime());}}function st(o,v){if(o&1){let t=Fw();Pi(0,"button",13),Qh("click",function(){ud(t);let i=qw();return dd(i.sendStartTimerCommand("start"))}),Pi(1,"mat-icon",5),wd(),Pi(2,"svg",6)(3,"text",14),TT(4,"Start"),ul()()()(),Td(),Pi(5,"button",15),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(-60))}),Pi(6,"mat-icon",5),wd(),Pi(7,"svg",6)(8,"text",14),TT(9,"-1m"),ul()()()(),Td(),Pi(10,"button",16),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(60))}),Pi(11,"mat-icon",5),wd(),Pi(12,"svg",6)(13,"text",14),TT(14,"+1m"),ul()()()();}}function rt(o,v){if(o&1){let t=Fw();Pi(0,"button",17),Qh("click",function(){ud(t);let i=qw();return dd(i.sendStartTimerCommand("sync"))}),Pi(1,"mat-icon",5),wd(),Pi(2,"svg",18)(3,"text",19),TT(4,"Sync"),ul()()()(),Td(),Pi(5,"button",20),Qh("click",function(){ud(t);let i=qw();return dd(i.sendStartTimerCommand("reset"))}),Pi(6,"mat-icon",5),wd(),Pi(7,"svg",18)(8,"text",19),TT(9,"Reset"),ul()()()();}}function lt(o,v){if(o&1){let t=Fw();Pi(0,"button",21),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(-60))}),Pi(1,"mat-icon",5),wd(),Pi(2,"svg",22)(3,"text",23),TT(4,"-1m"),ul()()()(),Td(),Pi(5,"button",24),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(-1))}),Pi(6,"mat-icon",5),wd(),Pi(7,"svg",22)(8,"text",23),TT(9,"-1s"),ul()()()(),Td(),Pi(10,"button",25),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(1))}),Pi(11,"mat-icon",5),wd(),Pi(12,"svg",22)(13,"text",23),TT(14,"+1s"),ul()()()(),Td(),Pi(15,"button",26),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(60))}),Pi(16,"mat-icon",5),wd(),Pi(17,"svg",22)(18,"text",23),TT(19,"+1m"),ul()()()();}}function mt(o,v){if(o&1){let t=Fw();Pi(0,"input",27),Eg("ngModelChange",function(i){ud(t);let a=qw();return ST(a.startAtTimeEdit,i)||(a.startAtTimeEdit=i),dd(i)}),Qh("change",function(){ud(t);let i=qw();return dd(i.setStartTime())}),ul(),cD();}if(o&2){let t=qw();Ig("ngModel",t.startAtTimeEdit),lD();}}function ct(o,v){o&1&&$h(0,"div",10);}var Et=(()=>{class o{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:false,displayName:"TTS",nextDashboard:0,playBeeps:true,filterSelfPaths:true,paths:{ttsPath:{description:"Time to the Start in seconds",path:"self.navigation.racing.timeToStart",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"s",showConvertUnitTo:false,showPathSkUnitsFilter:false,pathSkUnitsFilter:"s",sampleTime:500},startTimePath:{description:"Time of the start",path:"self.navigation.racing.startTime",source:"default",pathType:"Date",pathRequired:false,isPathConfigurable:false,sampleTime:500},dtsPath:{description:"Distance to Start Line path, used to determine OCS",path:"self.navigation.racing.distanceStartline",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:false,pathSkUnitsFilter:"m",sampleTime:500}},color:"contrast",enableTimeout:false,dataTimeout:5,ignoreZones:true};runtime=w(p);streams=w(rt$1);signalk=w(T);dashboard=w(G);canvas=w(R);destroyRef=w(xe);canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;titleBitmap=null;titleBitmapText=null;titleBitmapColor=null;labelColor=vt("");mode=vt(1);ttsValue=null;dtsValue=null;valueColor="";valueStateColor="";startAtTime=vt("00:00:00");startAtTimeEdit=Bj("");normalizedConfig=Dt(()=>this.runtime.options()??o.DEFAULT_CONFIG);constructor(){Fa(()=>{let t=this.normalizedConfig(),e=this.theme();e&&ge(()=>{let i=c(t.color??"contrast",e);this.labelColor.set(i.dim),this.valueColor=i.color,this.valueStateColor=i.color,this.draw();});}),Fa(()=>{let t=this.normalizedConfig();t.paths?.ttsPath?.path&&ge(()=>this.streams.observe("ttsPath",a=>{let s=this.ttsValue;this.ttsValue=a?.data?.value??null,this.updateValueColor(),this.draw(),this.shouldBeep(s,this.ttsValue)&&this.beepForValue(this.ttsValue),(t.nextDashboard??-1)>=0&&s===1&&this.ttsValue===0&&(!this.dtsValue||this.dtsValue>=0);}));}),Fa(()=>{this.normalizedConfig().paths?.startTimePath?.path&&ge(()=>this.streams.observe("startTimePath",a=>{let s=a?.data?.value;if(!s)this.startAtTime.set("HH:MM:SS"),this.startAtTimeEdit.set("HH:MM:SS"),this.mode()===2&&this.mode.set(1);else {let l=new Date(s);this.startAtTimeEdit.set(l.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})),this.startAtTime.set(this.startAtTimeEdit());}this.draw();}));}),Fa(()=>{this.normalizedConfig().paths?.dtsPath?.path&&ge(()=>this.streams.observe("dtsPath",a=>{this.dtsValue=a?.data?.value??null;}));}),this.signalk.subscribeRequest().pipe(Gp(this.destroyRef)).subscribe(t=>{t.widgetUUID===this.id()&&t.statusCode===200&&this.beep(600,20);});}ngAfterViewInit(){this.canvasElement=this.canvasRef().nativeElement,this.ctx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(t,e)=>{this.cssWidth=t,this.cssHeight=e,this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.draw();}ngOnDestroy(){try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(t){}}toggleMode(){this.mode.update(e=>(e+1)%5);let t=this.ttsValue;this.mode()===1&&this.isStartTimerRunning()&&this.mode.set(2),this.mode()===2&&t!==0&&!this.isStartTimerRunning()&&this.mode.set(3),this.draw();}sendStartTimerCommand(t){this.signalk.putRequest("navigation.racing.setStartTime",{command:t},this.id()),t==="start"&&this.mode.set(0),t==="reset"&&(this.startAtTime.set("HH:MM:SS"),this.mode.set(1));}adjustStartTime(t){this.signalk.putRequest("navigation.racing.setStartTime",{command:"adjust",delta:t},this.id());}setStartTime(){let t=new Date,e=this.startAtTimeEdit().split(":").map(Number),i=e[0],a=e[1],s=e.length>=3?e[2]:0,l=new Date(t);l.setHours(i,a,s,0),l<=t&&l.setDate(l.getDate()+1),this.mode.set(0),this.signalk.putRequest("navigation.racing.setStartTime",{command:"set",startTime:l.toISOString()},this.id());}isStartTimerRunning(){return (this.ttsValue??0)>0&&this.startAtTime()!==null&&this.startAtTime()!=="HH:MM:SS"}shouldBeep(t,e){return e==null||this.startAtTime()==="HH:MM:SS"||!this.runtime.options()?.playBeeps?false:e===0&&t!==0||e<10&&e>=0||e<60&&e%10===0?true:e%60===0}beepForValue(t){t===0?this.beep(500,1e3):t<10?this.beep(450,100):t<60&&t%10===0?this.beep(400,150):t%60===0&&this.beep(350,200);}updateValueColor(){let t=this.theme(),e=this.normalizedConfig();t&&(e.ignoreZones?this.ttsValue?this.ttsValue===0?this.valueStateColor=this.valueColor:this.ttsValue<10?this.valueStateColor=(this.dtsValue??0)<0?t.zoneAlarm:t.zoneWarn:this.ttsValue<60?this.valueStateColor=t.zoneAlert:this.valueStateColor=this.valueColor:this.valueStateColor=this.valueColor:this.valueStateColor=this.valueColor,this.ttsValue===0?(this.mode.set(2),(this.dtsValue??0)<0&&(this.valueStateColor=t.zoneAlarm)):this.mode()===1&&this.isStartTimerRunning()&&this.mode.set(2));}toHHMMSS(t){if(t==null||isNaN(t))return "-:--";let e=t<0;e&&(t=-t);let i=Math.floor(t/3600),a=Math.floor(t%3600/60),s=Math.floor(t%60),l=e?"-":"";return i===0?`${l}${a.toString().padStart(1,"0")}:${s.toString().padStart(2,"0")}`:`${l}${i.toString().padStart(1,"0")}:${a.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`}getValueText(){return this.toHHMMSS(this.ttsValue??0)}draw(){if(!this.ctx||!this.canvasElement)return;let e=this.runtime.options()?.displayName||"TTS",i=this.labelColor();(!this.titleBitmap||this.titleBitmap.width!==this.canvasElement.width||this.titleBitmap.height!==this.canvasElement.height||this.titleBitmapText!==e||this.titleBitmapColor!==i)&&(this.titleBitmap=this.canvas.createTitleBitmap(e,i,"normal",this.cssWidth,this.cssHeight),this.titleBitmapText=e,this.titleBitmapColor=i),this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),this.titleBitmap&&this.ctx.drawImage(this.titleBitmap,0,0,this.cssWidth,this.cssHeight),this.canvas.drawText(this.ctx,this.getValueText(),Math.floor(this.cssWidth*.5),Math.floor(this.cssHeight*.55),Math.floor(this.cssWidth*.95),Math.floor(this.cssHeight*.9),"bold",this.valueStateColor,"center","middle");}beep(t=440,e=100){if(!this.runtime.options()?.playBeeps)return;let i=window.AudioContext||window.webkitAudioContext,a=new i,s=a.createOscillator(),l=a.createGain();s.connect(l),l.connect(a.destination),s.type="sine",s.frequency.value=t,l.gain.value=.1,s.start(),s.stop(a.currentTime+e/1e3);}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=JD({type:o,selectors:[["widget-racer-timer"]],viewQuery:function(e,i){e&1&&eg(i.canvasRef,at,5),e&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],startAtTimeEdit:[1,"startAtTimeEdit"]},outputs:{startAtTimeEdit:"startAtTimeEditChange"},decls:15,vars:2,consts:[["canvasMainRef",""],[1,"filler"],[1,"timer-canvas"],[1,"buttons-container"],["mat-flat-button","","matTooltip","Select the control mode",1,"button","select-button",3,"click"],[1,"buttons-svg-icon"],["width","100%","height","100%","viewBox","0 0 80 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","40","y","9"],[1,"start-at"],["matInput","","type","time","step","1","matTooltip","Set an absolute start time",1,"set-start-at",3,"ngModel"],[1,"widgetOverlay"],["width","100%","height","100%","viewBox","0 0 80 12","preserveAspectRatio","xMidYMid meet",1,"svg-content","svg-start-at"],["x","40","y","10"],["mat-flat-button","","matTooltip","Start the race timer",1,"button","main-button",3,"click"],["x","40","y","11"],["mat-flat-button","","matTooltip","Remove 1 minute from the timer",1,"button","other-small-button",3,"click"],["mat-flat-button","","matTooltip","Add 1 minute to the timer",1,"button","other-small-button",3,"click"],["mat-flat-button","","matTooltip","Sync the timer to nearest minute",1,"button","main-button",3,"click"],["width","100%","height","100%","viewBox","0 0 100 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","50","y","11"],["mat-flat-button","","matTooltip","Stop and reset the timer",1,"button","other-button",3,"click"],["mat-flat-button","","matTooltip","Reduce the timer by 1 minute",1,"button","main-small-button",3,"click"],["width","100%","height","100%","viewBox","0 0 50 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","25","y","11"],["mat-flat-button","","matTooltip","Reduce the timer by 1 second",1,"button","other-small-button",3,"click"],["mat-flat-button","","matTooltip","Increase the timer by 1 second",1,"button","other-small-button",3,"click"],["mat-flat-button","","matTooltip","Increase the timer by 1 minute",1,"button","main-small-button",3,"click"],["matInput","","type","time","step","1","matTooltip","Set an absolute start time",1,"set-start-at",3,"ngModelChange","change","ngModel"]],template:function(e,i){if(e&1&&(Pi(0,"div",1),$h(1,"canvas",2,0),ul(),Pi(3,"div",3)(4,"button",4),Qh("click",function(){return i.toggleMode()}),Pi(5,"mat-icon",5),wd(),Pi(6,"svg",6)(7,"text",7),TT(8,"\u22EE"),ul()()()(),_w(9,ot,4,1,"div",8)(10,st,15,0)(11,rt,10,0)(12,lt,20,0)(13,mt,1,1,"input",9),ul(),_w(14,ct,1,0,"div",10)),e&2){let a;EE(9),Mw((a=i.mode())===0?9:a===1?10:a===2?11:a===3?12:a===4?13:-1),EE(5),Mw(i.dashboard.isDashboardStatic()?-1:14);}},dependencies:[Ln,Xe,Pn,rn,Op,xp,yt,wt,zt,mt$1,an],styles:["[_nghost-%COMP%]{overflow:clip;display:block;height:100%;width:100%}.timer-wrapper[_ngcontent-%COMP%]{width:100%;height:100%;min-height:1px}.timer-canvas[_ngcontent-%COMP%]{width:100%!important;height:100%!important;display:block}.filler[_ngcontent-%COMP%]{width:100%;height:76%}.buttons-container[_ngcontent-%COMP%]{display:flex;flex-wrap:nowrap;justify-content:space-between;column-gap:2%;position:relative;height:24%;width:100%;padding:0 10px 14px;z-index:20;pointer-events:auto;align-items:center}.button[_ngcontent-%COMP%]{min-width:0px;width:100%;border-radius:12px;align-items:center;justify-content:center;cursor:pointer;--mat-button-filled-container-height: 100%;--mat-button-filled-horizontal-padding: 0px;--mat-button-filled-icon-spacing: 0px}.select-button[_ngcontent-%COMP%]{flex:none;width:18%;--mat-button-filled-container-color: var(--kip-blue-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.main-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.other-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-blue-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.main-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.other-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-blue-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.set-start-at[_ngcontent-%COMP%]{flex:1 1 auto;background-color:var(--kip-contrast-color)}.start-at[_ngcontent-%COMP%]{height:100%;width:100%;flex:1 1 auto}.start-at[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{fill:var(--kip-contrast-color)}.start-at[_ngcontent-%COMP%] svg[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-family:Roboto;font-size:9px;font-weight:400;text-align:center;text-anchor:middle;font-style:normal;font-variant:normal;font-stretch:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke:none}.buttons-svg-icon[_ngcontent-%COMP%]{width:100%;height:100%;margin:0;padding:0}.svg-content[_ngcontent-%COMP%]{width:100%;height:100%;padding:0;margin:0}.svg-content[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-family:Roboto;font-size:15px;font-weight:700;text-align:center;text-anchor:middle;font-style:normal;font-variant:normal;font-stretch:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke:none}.svg-start-at[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{fill:var(--kip-contrast-dim-color)}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent;z-index:21}"]})}return o})();export{Et as WidgetRacerTimerComponent};
@@ -1 +1 @@
1
- import {a as a$1}from'./chunk-D4xZ2tGB.js';import {d1 as Hj,w,du as p,a as G,H as Dr,$ as $j,v as vt,F as Fa,dn as ge,J as JD,_ as _w,cp as Uh,M as Mw,e as EE,d as ig,f as eg,K as Kw,g as qw,b_ as Gh,ci as dl,T as TT,cj as fl,dP as pp}from'./main-BAV5VDOD.js';var W=["plainIframe"];function M(n,e){if(n&1&&Uh(0,"iframe",1,0),n&2){let t=qw();Gh("src",t.widgetUrl(),pp);}}function N(n,e){n&1&&(dl(0,"div",2)(1,"h2"),TT(2,"Empty or bad URL"),fl(),dl(3,"p"),TT(4," IMPORTANT: cross-domain security rules (CORS) apply to this widget. "),fl(),dl(5,"p"),TT(6,"Typically, you can load Grafana graphs, Signal K apps or other related tools. "),fl()());}var O=class n{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);_dashboard=w(G);_sanitizer=w(Dr);static DEFAULT_CONFIG={widgetUrl:void 0,allowInput:false};iframe=$j.required("plainIframe");widgetUrl=vt(null);displayTransparentOverlay=vt("block");constructor(){Fa(()=>{let e=this.runtime.options(),t=this._dashboard.isDashboardStatic();e&&ge(()=>{t?this.displayTransparentOverlay.set(e.allowInput?"none":"block"):this.displayTransparentOverlay.set("block");});}),Fa(()=>{let e=this.runtime.options()?.widgetUrl;this.widgetUrl.set(this.resolveUrl(e));}),window.addEventListener("message",this.handleIframeGesture);}ngAfterViewInit(){if(this.iframe()){this.iframe().nativeElement.onload=()=>this.injectSwipeScript();try{let e=this.iframe().nativeElement.contentDocument;e&&(e.readyState==="complete"||e.readyState==="interactive")&&this.injectSwipeScript();}catch(e){}}}ngOnDestroy(){window.removeEventListener("message",this.handleIframeGesture),this.iframe()&&(this.iframe().nativeElement.onload=null);try{let e=this.iframe()?.nativeElement.contentDocument;if(e){let t=`kip-gesture-inject-${this.id()}`,i=e.getElementById(t);i&&i.parentNode&&i.parentNode.removeChild(i);}}catch(e){}}handleIframeGesture=e=>{if(!e.data)return;let t=e.data?.eventData?.instanceId||e.data?.keyEventData?.instanceId;if(!(!t||t!==this.id())){if(e.data.gesture)switch(e.data.gesture){case "swipeup":this._dashboard.navigateToPreviousDashboard();break;case "swipedown":this._dashboard.navigateToNextDashboard();break;case "swipeleft":{let i=new Event("openLeftSidenav",{bubbles:true,cancelable:true});window.document.dispatchEvent(i);break}case "swiperight":{let i=new Event("openRightSidenav",{bubbles:true,cancelable:true});window.document.dispatchEvent(i);break}}if(e.data.type==="keydown"&&e.data.keyEventData){let{key:i,ctrlKey:l,shiftKey:r}=e.data.keyEventData,x=new KeyboardEvent("keydown",{key:i,ctrlKey:l,shiftKey:r,bubbles:true,cancelable:true});document.dispatchEvent(x);}}};injectSwipeScript(){let e=this.iframe().nativeElement.contentWindow,t=this.iframe().nativeElement.contentDocument;if(!t||!e){console.error("[WidgetIframe] Iframe contentDocument or contentWindow is undefined. Possible cross-origin issue or iframe not fully loaded.");return}try{let i=`kip-gesture-inject-${this.id()}`;if(t.getElementById(i))return;let l=a$1({instanceId:this.id()}),r=t.createElement("script");r.id=i,r.textContent=l,t.body.appendChild(r);}catch(i){console.warn("[WidgetIframe] Failed to inject swipe script into iframe:",i);}}isValidProtocol(e){try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch(t){return console.warn(`[Embed Widget] Invalid Url: ${e}, Error: ${t}`),false}}resolveUrl(e){if(!e)return null;try{let t=new URL(e,window.location.origin);return this.isValidProtocol(t.href)?this._sanitizer.bypassSecurityTrustResourceUrl(t.href):null}catch(t){return console.warn(`[Embed Widget] Can't resolve Url: ${e}, Error: ${t}`),null}}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=JD({type:n,selectors:[["widget-iframe"]],viewQuery:function(t,i){t&1&&eg(i.iframe,W,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:3,vars:3,consts:[["plainIframe",""],["width","100%","height","100%","frameborder","0",1,"widgetIframe",3,"src"],[2,"padding","15px"],[1,"widgetOverlay"]],template:function(t,i){t&1&&(_w(0,M,2,1,"iframe",1)(1,N,7,0,"div",2),Uh(2,"div",3)),t&2&&(Mw(i.widgetUrl()?0:1),EE(2),ig("display",i.displayTransparentOverlay()));},styles:["[_nghost-%COMP%]{overflow:hidden}.widgetIframe[_ngcontent-%COMP%]{background-color:#fff;border-radius:var(--mat-card-elevated-container-shape, var(--mat-sys-corner-medium))}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent}"]})};export{O as WidgetIframeComponent};
1
+ import {a as a$1}from'./chunk-ibauGmSP.js';import {d1 as Hj,w,du as p,a as G,H as Dr,$ as $j,v as vt,F as Fa,dn as ge,J as JD,_ as _w,cp as Uh,M as Mw,e as EE,d as ig,f as eg,K as Kw,g as qw,b_ as Gh,ci as dl,T as TT,cj as fl,dP as pp}from'./main-YKDNK5VZ.js';var W=["plainIframe"];function M(n,e){if(n&1&&Uh(0,"iframe",1,0),n&2){let t=qw();Gh("src",t.widgetUrl(),pp);}}function N(n,e){n&1&&(dl(0,"div",2)(1,"h2"),TT(2,"Empty or bad URL"),fl(),dl(3,"p"),TT(4," IMPORTANT: cross-domain security rules (CORS) apply to this widget. "),fl(),dl(5,"p"),TT(6,"Typically, you can load Grafana graphs, Signal K apps or other related tools. "),fl()());}var O=class n{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);_dashboard=w(G);_sanitizer=w(Dr);static DEFAULT_CONFIG={widgetUrl:void 0,allowInput:false};iframe=$j.required("plainIframe");widgetUrl=vt(null);displayTransparentOverlay=vt("block");constructor(){Fa(()=>{let e=this.runtime.options(),t=this._dashboard.isDashboardStatic();e&&ge(()=>{t?this.displayTransparentOverlay.set(e.allowInput?"none":"block"):this.displayTransparentOverlay.set("block");});}),Fa(()=>{let e=this.runtime.options()?.widgetUrl;this.widgetUrl.set(this.resolveUrl(e));}),window.addEventListener("message",this.handleIframeGesture);}ngAfterViewInit(){if(this.iframe()){this.iframe().nativeElement.onload=()=>this.injectSwipeScript();try{let e=this.iframe().nativeElement.contentDocument;e&&(e.readyState==="complete"||e.readyState==="interactive")&&this.injectSwipeScript();}catch(e){}}}ngOnDestroy(){window.removeEventListener("message",this.handleIframeGesture),this.iframe()&&(this.iframe().nativeElement.onload=null);try{let e=this.iframe()?.nativeElement.contentDocument;if(e){let t=`kip-gesture-inject-${this.id()}`,i=e.getElementById(t);i&&i.parentNode&&i.parentNode.removeChild(i);}}catch(e){}}handleIframeGesture=e=>{if(!e.data)return;let t=e.data?.eventData?.instanceId||e.data?.keyEventData?.instanceId;if(!(!t||t!==this.id())){if(e.data.gesture)switch(e.data.gesture){case "swipeup":this._dashboard.navigateToPreviousDashboard();break;case "swipedown":this._dashboard.navigateToNextDashboard();break;case "swipeleft":{let i=new Event("openLeftSidenav",{bubbles:true,cancelable:true});window.document.dispatchEvent(i);break}case "swiperight":{let i=new Event("openRightSidenav",{bubbles:true,cancelable:true});window.document.dispatchEvent(i);break}}if(e.data.type==="keydown"&&e.data.keyEventData){let{key:i,ctrlKey:l,shiftKey:r}=e.data.keyEventData,x=new KeyboardEvent("keydown",{key:i,ctrlKey:l,shiftKey:r,bubbles:true,cancelable:true});document.dispatchEvent(x);}}};injectSwipeScript(){let e=this.iframe().nativeElement.contentWindow,t=this.iframe().nativeElement.contentDocument;if(!t||!e){console.error("[WidgetIframe] Iframe contentDocument or contentWindow is undefined. Possible cross-origin issue or iframe not fully loaded.");return}try{let i=`kip-gesture-inject-${this.id()}`;if(t.getElementById(i))return;let l=a$1({instanceId:this.id()}),r=t.createElement("script");r.id=i,r.textContent=l,t.body.appendChild(r);}catch(i){console.warn("[WidgetIframe] Failed to inject swipe script into iframe:",i);}}isValidProtocol(e){try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch(t){return console.warn(`[Embed Widget] Invalid Url: ${e}, Error: ${t}`),false}}resolveUrl(e){if(!e)return null;try{let t=new URL(e,window.location.origin);return this.isValidProtocol(t.href)?this._sanitizer.bypassSecurityTrustResourceUrl(t.href):null}catch(t){return console.warn(`[Embed Widget] Can't resolve Url: ${e}, Error: ${t}`),null}}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=JD({type:n,selectors:[["widget-iframe"]],viewQuery:function(t,i){t&1&&eg(i.iframe,W,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:3,vars:3,consts:[["plainIframe",""],["width","100%","height","100%","frameborder","0",1,"widgetIframe",3,"src"],[2,"padding","15px"],[1,"widgetOverlay"]],template:function(t,i){t&1&&(_w(0,M,2,1,"iframe",1)(1,N,7,0,"div",2),Uh(2,"div",3)),t&2&&(Mw(i.widgetUrl()?0:1),EE(2),ig("display",i.displayTransparentOverlay()));},styles:["[_nghost-%COMP%]{overflow:hidden}.widgetIframe[_ngcontent-%COMP%]{background-color:#fff;border-radius:var(--mat-card-elevated-container-shape, var(--mat-sys-corner-medium))}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent}"]})};export{O as WidgetIframeComponent};
@@ -1 +1 @@
1
- import'./chunk-By8ZVvDx.js';import {d1 as Hj,w,du as p,ao as ue,dy as K,dw as S,aZ as F,bu as ut,i as ir,$ as $j,a6 as Lr,b0 as Wl,W as Wp,E as Em,F as Fa,dn as ge,cw as z,cv as G,J as JD,cp as Uh,f as eg,K as Kw}from'./main-BAV5VDOD.js';var tt=["widgetDataChart"],mt=(()=>{class O{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p,{optional:true});static DEFAULT_CONFIG={filterSelfPaths:true,color:"contrast",timeScale:"Last 30 Minutes"};ngZone=w(ue);_dataset=w(K);datasetLifecycle=w(S);canvasService=w(F);unitsService=w(ut);responsive=w(ir);isPhonePortrait;widgetDataChart=$j("widgetDataChart",{read:Lr});lineChartData={datasets:[]};lineChartOptions={parsing:false,datasets:{line:{pointRadius:0,pointHoverRadius:0,tension:.3}},animations:{tension:{easing:"easeInOutCubic"}}};lineChartType="line";chart=null;_dsDirectionSub=null;_dsSpeedSub=null;_chartUpdateRafId=null;datasetConfig=null;dataSourceInfo=null;xCenter=null;xStep=null;xCenterSpeed=null;xStepSpeed=null;CENTER_LINE_WIDTH=4;GRID_LINE_WIDTH=1;EDGE_EXTEND_UP_PX=42;EDGE_SPEED_LABEL_OFFSET=5;EDGE_DIR_LABEL_OFFSET=5;TICK_LABEL_FONT_SIZE=20;TICK_LABEL_PHONE_PORTRAIT_FONT_SIZE=11;CENTER_LABEL_FONT_SIZE=22;CENTER_LABEL_PHONE_PORTRAIT_FONT_SIZE=13;SPEED_VALUE_FONT_SIZE=62;SPEED_VALUE_PHONE_PORTRAIT_FONT_SIZE=32;TOP_VALUE_Y_OFFSET=62;TOP_VALUE_PHONE_PORTRAIT_Y_OFFSET=44;TOP_UNIT_Y_OFFSET=51;TOP_UNIT_PHONE_PORTRAIT_Y_OFFSET=38;UNIT_FONT_SIZE=28;UNIT_PHONE_PORTRAIT_FONT_SIZE=14;UNIT_PADDING=8;UNIT_PHONE_PORTRAIT_PADDING=3;isPortrait=()=>this.isPhonePortrait()?.matches===true;gridBackgroundPlugin={id:"xSpeedGridBackground",beforeDraw:e=>{let t=e.chartArea;if(!t)return;let a=e.ctx,i=this.theme();a.save(),a.globalCompositeOperation="destination-over",a.fillStyle=i.background,a.fillRect(t.left,t.top,t.width/2,t.height),a.restore();}};centerTickPlugin={id:"centerTickStyle",afterDraw:e=>{let t=e.ctx,a=e.chartArea,i=this.theme(),n=this.getThemeColors(),o=Wl.defaults.font,u=e.scales,c=e.options?.scales,r=e.data?.datasets?.[0]?.data,d=e.data?.datasets?.[5]?.data,f=(r?.length??0)>=2&&(d?.length??0)>=2,h=(p,g)=>{let l=u?.[p],x=c;if(!l)return;let E=l,v=x?.[p]?.min??E.min,C=x?.[p]?.max??E.max;if(typeof v!="number"||typeof C!="number"||!isFinite(v)||!isFinite(C))return;let y=(v+C)/2,L=l.getPixelForValue(y);t.save(),t.strokeStyle=i.contrastDim,t.lineWidth=this.CENTER_LINE_WIDTH,t.beginPath(),t.moveTo(L,a.top),t.lineTo(L,a.bottom),t.stroke(),t.restore(),t.save(),t.fillStyle=i.contrastDim,t.font=this.isPortrait()?`bold ${this.CENTER_LABEL_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.CENTER_LABEL_FONT_SIZE}px ${o.family}`,t.textAlign="center",t.textBaseline="top";let J=this.axisTopLabelY(l);t.fillText(g(y),L,J),t.restore();};h("x",p=>`${((p%360+360)%360).toFixed(0)}\xB0`),h("xSpeed",p=>`${p.toFixed(1)}`);let s=u?.xSpeed;if(s){let p=c,g=s,l=p?.xSpeed?.max??g.max;if(typeof l=="number"&&isFinite(l)){let x=s.getPixelForValue(l);t.save(),t.fillStyle=this.resolveTickColor(e,s,l),t.font=this.isPortrait()?`normal ${this.TICK_LABEL_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`normal ${this.TICK_LABEL_FONT_SIZE}px ${o.family}`,t.textAlign="right",t.textBaseline="top";let E=this.axisTopLabelY(s),v=this.xStepSpeed??1,C=Math.max(0,Math.min(3,Math.ceil(-Math.log10(v))));t.fillText(`${l.toFixed(C)}`,x-this.EDGE_SPEED_LABEL_OFFSET,E),t.restore(),t.save(),t.strokeStyle=i.contrastDim,t.lineWidth=this.GRID_LINE_WIDTH,t.beginPath();let y=Math.round(x)+.5;t.moveTo(y,a.bottom),t.lineTo(y,a.top-this.EDGE_EXTEND_UP_PX),t.stroke(),t.restore();}}let m=u?.x;if(m){let p=c,g=m,l=p?.x?.min??g.min;if(typeof l=="number"&&isFinite(l)){let x=m.getPixelForValue(l);t.save(),t.fillStyle=this.resolveTickColor(e,m,l),t.font=this.isPortrait()?`normal ${this.TICK_LABEL_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`normal ${this.TICK_LABEL_FONT_SIZE}px ${o.family}`,t.textAlign="left",t.textBaseline="top";let E=this.axisTopLabelY(m),v=this.normalizeAngle(l);t.fillText(`${v.toFixed(0)}\xB0`,x+this.EDGE_DIR_LABEL_OFFSET,E),t.restore();}}let _=e.data?.datasets,S=_?.[5]?.data,D=S?.length?S.length-1:-1,b=D>=0?S[D]?.x:void 0;if(typeof b=="number"&&isFinite(b)){t.save(),t.fillStyle=n.chartValue,t.font=this.isPortrait()?`bold ${this.SPEED_VALUE_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.SPEED_VALUE_FONT_SIZE}px ${o.family}`,t.textAlign="center",t.textBaseline="middle";let p=`${b.toFixed(1)}`,g=a.left+a.width/4,l=a.top-(this.isPortrait()?this.TOP_VALUE_PHONE_PORTRAIT_Y_OFFSET:this.TOP_VALUE_Y_OFFSET);t.fillText(p,g,l);let x=t.measureText(p),E=g+x.width/2+(this.isPortrait()?this.UNIT_PHONE_PORTRAIT_PADDING:this.UNIT_PADDING),v=a.top-(this.isPortrait()?this.TOP_UNIT_PHONE_PORTRAIT_Y_OFFSET:this.TOP_UNIT_Y_OFFSET);t.font=this.isPortrait()?`bold ${this.UNIT_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.UNIT_FONT_SIZE}px ${o.family}`,t.textAlign="left",t.fillText("kts",E,v),t.restore();}let F=_?.[0]?.data,N=F?.length?F.length-1:-1,T=N>=0?F[N]?.x:void 0;if(typeof T=="number"&&isFinite(T)){let p=this.normalizeAngle(T);t.save(),t.fillStyle=n.chartValue,t.font=this.isPortrait()?`bold ${this.SPEED_VALUE_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.SPEED_VALUE_FONT_SIZE}px ${o.family}`,t.textAlign="center",t.textBaseline="middle",t.fillText(`${p.toFixed(0)}\xB0`,a.left+3*a.width/4,a.top-(this.isPortrait()?this.TOP_VALUE_PHONE_PORTRAIT_Y_OFFSET:this.TOP_VALUE_Y_OFFSET)),t.restore();}if(!f){let p=Math.min(a.width*.7,420),g=90,l=a.left+(a.width-p)/2,x=a.top+(a.height-g)/2;t.save(),t.globalAlpha=.82,t.fillStyle=i.background,t.fillRect(l,x,p,g),t.restore(),t.save(),t.strokeStyle=i.contrastDim,t.lineWidth=2,t.strokeRect(l,x,p,g),t.restore(),t.save(),t.fillStyle=this.getThemeColors().chartLabel,t.textAlign="center",t.textBaseline="middle",t.font=`bold 18px ${o.family}`,t.fillText("Data acquisition...",l+p/2,x+g/2),t.restore();}}};constructor(){this.isPhonePortrait=Wp(this.responsive.observe(Em.HandsetPortrait),{initialValue:void 0}),Fa(()=>{let e=this.theme(),t=this.runtime?.options();!e||!t||ge(()=>{this.datasetConfig&&this.chart&&(this.setChartOptions(),this.setDatasetsColors(),this.ngZone.runOutsideAngular(()=>this.chart?.update("none")));});}),Fa(()=>{let e=this.runtime?.options();if(!e)return;!this.datasetConfig||this.datasetConfig.timeScaleFormat!==e.timeScale?(this.syncServiceDatasets(),this.startWidget()):this.chart&&this.setChartOptions();});}startWidget(){if(this.widgetDataChart()&&(this.datasetConfig=this._dataset.getDatasetConfig(`${this.id()}-twd`)??null,this.dataSourceInfo=this._dataset.getDataSourceInfo(`${this.id()}-twd`)??null,!!this.datasetConfig)){if(this.createDatasets(),this.setChartOptions(),this.chart)this.ngZone.runOutsideAngular(()=>this.chart?.update("none"));else {let e=this.widgetDataChart()?.nativeElement.getContext("2d");if(!e)return;this.chart=new Wl(e,{type:this.lineChartType,data:this.lineChartData,options:this.lineChartOptions,plugins:[this.gridBackgroundPlugin,this.centerTickPlugin]}),this.ngZone.runOutsideAngular(()=>this.chart?.update("none"));}this.startStreaming();}}syncServiceDatasets(){let e=this.runtime?.options();!e||e.timeScale===""||this.datasetLifecycle.syncWindTrendsDatasets(this.id(),e.timeScale);}setChartOptions(){let e=this.datasetConfig,t=this.dataSourceInfo;if(!e||!t)return;this.lineChartOptions.maintainAspectRatio=false,this.lineChartOptions.animation=false,this.lineChartOptions.indexAxis="y";let a=0,i=360,n=(i-a)/4,o=0,u=20,c=(u-o)/4;this.lineChartOptions.scales={y:{type:"linear",display:true,position:"right",reverse:true,title:{display:true,text:`${e.timeScaleFormat}`,align:"center"},ticks:{count:6,autoSkip:false,includeBounds:true,align:"inner",major:{enabled:true},font:this.isPortrait()?{size:12}:{size:16},callback:r=>{let d=Number(r),f=e.timeScaleFormat,h=this.getWindowMs(f);return f==="Last 5 Minutes"?`${Math.round(d/6e4)}'`:h>=10*6e4?`${Math.round(d/6e4)}'`:`${Math.round(d/1e3)}"`}},grid:{display:true,color:this.theme().contrastDimmer}},x:{type:"linear",position:"top",stack:"trends",beginAtZero:false,bounds:"ticks",min:a,max:i,title:{display:false},ticks:{count:5,align:"inner",autoSkip:false,includeBounds:true,stepSize:n,minRotation:0,maxRotation:0,callback:r=>{let d=Number(r),f=this.xCenter??Number.NaN;if(this.nearlyEqual(d,f))return "";let s=this.chart?.options?.scales?.x?.min;return typeof s=="number"&&this.nearlyEqual(d,s)?"":`${((d%360+360)%360).toFixed(0)}\xB0`},font:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenter??Number.NaN,h=this.nearlyEqual(d,f);return this.isPortrait()?{size:11,weight:h?"bold":"normal"}:{size:20,weight:h?"bold":"normal"}},color:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenter??Number.NaN;return this.nearlyEqual(d,f)?this.theme().contrast:void 0}},grid:{display:true,color:r=>{let d=r.tick?.value??Number.NaN,f=r.scale,h=this.chart?.options?.scales,s=f,m=h?.x?.min??s.min;return this.nearlyEqual(d,m)?"rgba(0,0,0,0)":this.theme().contrastDimmer},lineWidth:1}},xSpeed:{type:"linear",position:"top",stack:"trends",beginAtZero:false,bounds:"ticks",min:o,max:u,title:{display:false},ticks:{count:5,align:"inner",autoSkip:false,includeBounds:true,stepSize:c,minRotation:0,maxRotation:0,callback:r=>{let d=this.xCenterSpeed??Number.NaN;if(this.nearlyEqual(r,d))return "";let h=this.chart?.options?.scales?.xSpeed?.max;if(typeof h=="number"&&this.nearlyEqual(r,h))return "";let s=this.xStepSpeed??Number.NaN,m=Number.isFinite(s)?s:1,_=Math.max(0,Math.min(3,Math.ceil(-Math.log10(m))));return `${r.toFixed(_)}`},font:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenterSpeed??Number.NaN,h=this.nearlyEqual(d,f);return this.isPortrait()?{size:11,weight:h?"bold":"normal"}:{size:20,weight:h?"bold":"normal"}},color:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenterSpeed??Number.NaN;return this.nearlyEqual(d,f)?this.theme().contrast:void 0}},grid:{display:true,color:r=>{let d=r.tick?.value??Number.NaN,f=r.scale,h=this.chart?.options?.scales,s=f,m=h?.xSpeed?.max??s.max;return this.nearlyEqual(d,m)?"rgba(0,0,0,0)":this.theme().contrastDimmer},lineWidth:1}}},this.lineChartOptions.plugins={title:{display:true,align:"end",text:"TWD ",color:this.getThemeColors().chartLabel,padding:this.isPortrait()?{top:3,bottom:0}:{top:3,bottom:0},font:this.isPortrait()?{size:16,weight:"normal"}:{size:35,weight:"normal"}},subtitle:{display:true,align:"start",text:" TWS",color:this.getThemeColors().chartLabel,padding:this.isPortrait()?{top:-18,bottom:12}:{top:-41,bottom:12},font:this.isPortrait()?{size:16}:{size:35}},legend:{display:false},annotation:{annotations:{}},streaming:{duration:t.maxDataPoints*t.sampleTime,delay:t.sampleTime,frameRate:e.timeScaleFormat==="day"?5:e.timeScaleFormat==="hour"?8:e.timeScaleFormat==="minute"?15:30}},this.xCenter=(a+i)/2,this.xStep=n,this.xCenterSpeed=(o+u)/2,this.xStepSpeed=c;}createDatasets(){this.lineChartData.datasets=[],this.lineChartData.datasets.push({label:"Value",data:[],order:2,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:1,fill:false,xAxisID:"x"},{label:"SMA",data:[],order:0,parsing:false,normalized:true,tension:.3,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:10,fill:false,borderColor:e=>{let t=e.chart,{ctx:a}=t;return this.lineGradientForAxis(a,t,"x")??this.getThemeColors().averageLine},backgroundColor:"red",xAxisID:"x"},{label:"lastAverage",data:[],order:1,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:0,borderColor:"",fill:false,hidden:true,xAxisID:"x"},{label:"lastMinimum",data:[],order:3,parsing:false,normalized:true,hidden:true,xAxisID:"x"},{label:"lastMaximum",data:[],order:4,parsing:false,normalized:true,hidden:true,xAxisID:"x"},{label:"Value Speed",data:[],order:2,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:1,fill:false,xAxisID:"xSpeed"},{label:"SMA Speed",data:[],order:0,parsing:false,normalized:true,tension:.2,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:3,fill:false,borderColor:e=>{let t=e.chart,{ctx:a}=t;return this.lineGradientForAxis(a,t,"xSpeed")??this.getThemeColors().averageLine},xAxisID:"xSpeed"},{label:"lastAverage Speed",data:[],order:1,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:0,borderColor:"",fill:false,hidden:true,xAxisID:"xSpeed"},{label:"lastMinimum Speed",data:[],order:3,parsing:false,normalized:true,hidden:true,xAxisID:"xSpeed"},{label:"lastMaximum Speed",data:[],order:4,parsing:false,normalized:true,hidden:true,xAxisID:"xSpeed"}),this.setDatasetsColors();}startStreaming(){if(this._dsDirectionSub?.unsubscribe(),this._dsSpeedSub?.unsubscribe(),!this.chart||!this.dataSourceInfo)return;let e=this._dataset.getDatasetBatchThenLiveObservable(`${this.id()}-twd`),t=this._dataset.getDatasetBatchThenLiveObservable(`${this.id()}-tws`);!e||!t||(this._dsDirectionSub=e.subscribe(a=>{let i=this.chart,n=this.dataSourceInfo;if(!(!i||!n)){if(Array.isArray(a))this.pushRowsToDatasets(a);else {this.pushRowsToDatasets([a]);let o=i.data.datasets[0]?.data;if(Array.isArray(o)&&o.length>n.maxDataPoints)for(let u=0;u<=4;u++){let c=i.data.datasets[u]?.data;Array.isArray(c)&&c.shift();}}this.scheduleChartUpdate();}}),this._dsSpeedSub=t.subscribe(a=>{let i=this.chart,n=this.dataSourceInfo;if(!(!i||!n)){if(Array.isArray(a))this.pushRowsToSpeedDatasets(a);else {this.pushRowsToSpeedDatasets([a]);let o=i.data.datasets[5]?.data;if(Array.isArray(o)&&o.length>n.maxDataPoints)for(let u=5;u<=9;u++){let c=i.data.datasets[u]?.data;Array.isArray(c)&&c.shift();}}this.scheduleChartUpdate();}}));}unwrapAngles(e){if(e.length===0)return [];let t=[],a=null;for(let i of e){if(i==null){t.push(null);continue}if(a==null){t.push(i),a=i;continue}let n=i-a;n>180&&(n-=360),n<-180&&(n+=360),t.push(t[t.length-1]+n),a=i;}return t}pushRowsToDatasets(e){this.pushRowsGeneric(e,0,"deg",true);}pushRowsToSpeedDatasets(e){this.pushRowsGeneric(e,5,"knots",false);}getRowValue(e,t){switch(t){case "value":return e.data.value??null;case "sma":return e.data.sma??null;case "ema":return e.data.ema??null;case "dema":return e.data.doubleEma??null;case "avg":return e.data.lastAverage??null;case "min":return e.data.lastMinimum??null;case "max":return e.data.lastMaximum??null;default:return null}}transformRows(e,t,a,i){let n=e.map(u=>{let c=this.getRowValue(u,t);return c==null?null:this.unitsService.convertToUnit(a,c)}),o=i?this.unwrapAngles(n):n;return e.map((u,c)=>({x:o[c],y:u.timestamp,ts:u.timestamp}))}pushRowsGeneric(e,t,a,i){let n=this.chart;if(!n)return;["value","sma","avg","min","max"].forEach((u,c)=>{let r=n.data.datasets[t+c];!r||!Array.isArray(r.data)||r.data.push(...this.transformRows(e,u,a,i));});}normalizeAngle(e){return (e%360+360)%360}angularDiff(e,t){let a=(e-t+540)%360-180;return Math.abs(a)}niceStepFromMantissas(e,t){if(!isFinite(e)||e<=0)return 1;let a=Math.floor(Math.log10(e)),i=e/Math.pow(10,a);return (t.find(o=>i<=o)??t[t.length-1])*Math.pow(10,a)}scheduleChartUpdate(){this._chartUpdateRafId==null&&(this._chartUpdateRafId=requestAnimationFrame(()=>{this._chartUpdateRafId=null,!(!this.chart||!this.hasValidDatasets())&&(this.updateChartAfterDataChange(),this.ngZone.runOutsideAngular(()=>this.chart?.update("none")));}));}hasValidDatasets(){let e=this.chart?.data?.datasets;if(!Array.isArray(e)||e.length<10)return false;for(let t=0;t<10;t++){let a=e[t];if(!a||!Array.isArray(a.data))return false}return true}updateChartAfterDataChange(){let e=this.chart;if(!e)return;let t=e.data.datasets[2]?.data,a=e.data.datasets[1]?.data,i=e.data.datasets[0]?.data,n=!!t?.length,o=!!a?.length,u=!!i?.length,c=n?t[t.length-1].x:o?a[a.length-1].x:u?i[i.length-1].x:void 0;if(typeof c=="number"&&isFinite(c)){let h=e.data.datasets[3]?.data,s=e.data.datasets[4]?.data,m=h?.length?h[h.length-1].x:void 0,_=s?.length?s[s.length-1].x:void 0,S=typeof m=="number"&&isFinite(m)?this.angularDiff(c,m):Number.NaN,D=typeof _=="number"&&isFinite(_)?this.angularDiff(c,_):Number.NaN,b=Number.isFinite(S)||Number.isFinite(D)?Math.max(Number.isFinite(S)?S:0,Number.isFinite(D)?D:0):Number.NaN;if(!Number.isFinite(b)){let x=n?t:o?a:i,E=Math.min(30,x?.length??0);if(E>1){let C=x.slice(x.length-E).map(y=>y.x).filter(y=>typeof y=="number"&&isFinite(y));C.length&&(b=C.reduce((y,L)=>Math.max(y,this.angularDiff(c,L)),0));}}b=Math.max(b||0,15);let N=2*b/4,T=this.niceStepFromMantissas(N,[1,1.5,2,2.5,5,7.5,10]),p=c-2*T,g=c+2*T,l=e.options.scales;l.x&&(l.x.min=p,l.x.max=g,l.x.ticks=z(G({},l.x.ticks??{}),{stepSize:T})),this.xCenter=c,this.xStep=T;}let r=e.data.datasets[7]?.data;if(r&&r.length){let h=r.length-1,s=r[h]?.x??0,m=e.data.datasets[8].data[h]?.x??s,_=e.data.datasets[9].data[h]?.x??s,S=Math.abs(s-m),D=Math.abs(_-s),b=Math.max(S,D);b=Math.max(b,.5);let N=2*b/4,T=this.niceStepFromMantissas(N,[1,2,2.5,5,10]),p=s-2*T,g=s+2*T,l=e.options.scales;l.xSpeed&&(l.xSpeed.min=p,l.xSpeed.max=g,l.xSpeed.ticks=z(G({},l.xSpeed.ticks??{}),{stepSize:T})),this.xCenterSpeed=s,this.xStepSpeed=T;}let d=this.getWindowMs(this.datasetConfig?.timeScaleFormat);if(e.data.datasets[0].data.length>0){let h=Date.now();e.data.datasets.forEach(S=>{S.data.forEach(D=>{let b=D.ts??D.y;D.y=Math.max(0,Math.min(d,h-b));});});let s=e.options.scales;s.y&&(s.y.min=0,s.y.max=d);let m;switch(this.datasetConfig?.timeScaleFormat){case "Last Minute":m=15e3;break;case "Last 5 Minutes":m=6e4;break;case "Last 30 Minutes":m=5*6e4;break;default:m=d/5;break}if(s.y){let S=G({},s.y.ticks??{});delete S.count,S.stepSize=m,s.y.ticks=S;}}}getWindowMs(e){switch(e){case "Last 30 Minutes":return 30*6e4;case "Last 5 Minutes":return 5*6e4;case "Last Minute":return 6e4;default:return 6e4}}lineGradientForAxis(e,t,a){let i=t.chartArea;if(!i)return null;let n=t.scales?.[a];if(!n)return null;let o=t.options?.scales,u=n,c=o?.[a]?.min??u.min,r=o?.[a]?.max??u.max;if(typeof c!="number"||typeof r!="number"||!isFinite(c)||!isFinite(r))return null;let d=(c+r)/2,f=n.getPixelForValue(d),h=Math.max(0,Math.min(1,(f-i.left)/i.width)),s=e.createLinearGradient(i.left,0,i.right,0);return s.addColorStop(0,this.theme().port),s.addColorStop(h,this.theme().port),s.addColorStop(h,this.theme().starboard),s.addColorStop(1,this.theme().starboard),s}setDatasetsColors(){this.lineChartData.datasets.forEach(e=>{e.label==="Value"&&(e.borderColor=this.getThemeColors().valueLine,e.backgroundColor=this.getThemeColors().valueFill),e.label==="Value Speed"&&(e.borderColor=this.getThemeColors().valueLine,e.backgroundColor=this.getThemeColors().valueFill);});}getThemeColors(){let e=this.runtime?.options()?.color,t={valueLine:"",valueFill:"",averageLine:"",averageFill:"",averageChartLine:"",chartLabel:"",chartValue:""};switch(e){case "contrast":t.valueLine=this.theme().contrastDim,t.valueFill=this.theme().contrastDimmer,t.averageLine=this.theme().contrast,t.averageFill=this.theme().contrast,t.chartValue=this.theme().contrast,t.averageChartLine=this.theme().contrast,t.chartLabel=this.theme().contrastDim;break;case "blue":t.valueLine=this.theme().blueDim,t.valueFill=this.theme().blueDimmer,t.averageLine=this.theme().blue,t.averageFill=this.theme().blue,t.chartValue=this.theme().blue,t.averageChartLine=this.theme().blueDim,t.chartLabel=this.theme().blueDim;break;case "green":t.valueLine=this.theme().greenDim,t.valueFill=this.theme().greenDimmer,t.averageLine=this.theme().green,t.averageFill=this.theme().green,t.chartValue=this.theme().green,t.averageChartLine=this.theme().greenDim,t.chartLabel=this.theme().greenDim;break;case "pink":t.valueLine=this.theme().pinkDim,t.valueFill=this.theme().pinkDimmer,t.averageLine=this.theme().pink,t.averageFill=this.theme().pink,t.chartValue=this.theme().pink,t.averageChartLine=this.theme().pinkDim,t.chartLabel=this.theme().pinkDim;break;case "orange":t.valueLine=this.theme().orangeDim,t.valueFill=this.theme().orangeDimmer,t.averageLine=this.theme().orange,t.averageFill=this.theme().orange,t.chartValue=this.theme().orange,t.averageChartLine=this.theme().orangeDim,t.chartLabel=this.theme().orangeDim;break;case "purple":t.valueLine=this.theme().purpleDim,t.valueFill=this.theme().purpleDimmer,t.averageLine=this.theme().purple,t.averageFill=this.theme().purple,t.chartValue=this.theme().purple,t.averageChartLine=this.theme().purpleDim,t.chartLabel=this.theme().purpleDim;break;case "grey":t.valueLine=this.theme().greyDim,t.valueFill=this.theme().greyDimmer,t.averageLine=this.theme().grey,t.averageFill=this.theme().grey,t.chartValue=this.theme().grey,t.averageChartLine=this.theme().greyDim,t.chartLabel=this.theme().greyDim;break;case "yellow":t.valueLine=this.theme().yellowDim,t.valueFill=this.theme().yellowDimmer,t.averageLine=this.theme().yellow,t.averageFill=this.theme().yellow,t.chartValue=this.theme().yellow,t.averageChartLine=this.theme().yellowDim,t.chartLabel=this.theme().yellowDim;break}return t}nearlyEqual(e,t,a=1e-6){if(!Number.isFinite(e)||!Number.isFinite(t))return false;let i=Math.max(1,Math.max(Math.abs(e),Math.abs(t)));return Math.abs(e-t)<=a*i}resolveTickColor(e,t,a){let n=t.options.ticks?.color;return typeof n=="function"?n({chart:e,scale:t,tick:{value:a}})??Wl.defaults.color:typeof n=="string"?n:Wl.defaults.color}axisTopLabelY(e){return e.options?.position==="top"?e.top+4:e.bottom+2}ngOnDestroy(){this._dsDirectionSub?.unsubscribe(),this._dsSpeedSub?.unsubscribe(),this._chartUpdateRafId!=null&&(cancelAnimationFrame(this._chartUpdateRafId),this._chartUpdateRafId=null),this.chart?.destroy();let e=this.widgetDataChart?.()?.nativeElement;this.canvasService.releaseCanvas(e,{clear:true,removeFromDom:true});}static \u0275fac=function(t){return new(t||O)};static \u0275cmp=JD({type:O,selectors:[["widget-windtrends-chart"]],viewQuery:function(t,a){t&1&&eg(a.widgetDataChart,tt,5,Lr),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:0,consts:[["widgetDataChart",""],[2,"z-index","inherit"]],template:function(t,a){t&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%}"]})}return O})();export{mt as WidgetWindTrendsChartComponent};
1
+ import'./chunk-BTOTKeBo.js';import {d1 as Hj,w,du as p,ao as ue,dy as K,dw as S,aZ as R,bu as ut,i as ir,$ as $j,a6 as Lr,b0 as Wl,W as Wp,E as Em,F as Fa,dn as ge,cw as z,cv as G,J as JD,cp as Uh,f as eg,K as Kw}from'./main-YKDNK5VZ.js';var tt=["widgetDataChart"],mt=(()=>{class O{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p,{optional:true});static DEFAULT_CONFIG={filterSelfPaths:true,color:"contrast",timeScale:"Last 30 Minutes"};ngZone=w(ue);_dataset=w(K);datasetLifecycle=w(S);canvasService=w(R);unitsService=w(ut);responsive=w(ir);isPhonePortrait;widgetDataChart=$j("widgetDataChart",{read:Lr});lineChartData={datasets:[]};lineChartOptions={parsing:false,datasets:{line:{pointRadius:0,pointHoverRadius:0,tension:.3}},animations:{tension:{easing:"easeInOutCubic"}}};lineChartType="line";chart=null;_dsDirectionSub=null;_dsSpeedSub=null;_chartUpdateRafId=null;datasetConfig=null;dataSourceInfo=null;xCenter=null;xStep=null;xCenterSpeed=null;xStepSpeed=null;CENTER_LINE_WIDTH=4;GRID_LINE_WIDTH=1;EDGE_EXTEND_UP_PX=42;EDGE_SPEED_LABEL_OFFSET=5;EDGE_DIR_LABEL_OFFSET=5;TICK_LABEL_FONT_SIZE=20;TICK_LABEL_PHONE_PORTRAIT_FONT_SIZE=11;CENTER_LABEL_FONT_SIZE=22;CENTER_LABEL_PHONE_PORTRAIT_FONT_SIZE=13;SPEED_VALUE_FONT_SIZE=62;SPEED_VALUE_PHONE_PORTRAIT_FONT_SIZE=32;TOP_VALUE_Y_OFFSET=62;TOP_VALUE_PHONE_PORTRAIT_Y_OFFSET=44;TOP_UNIT_Y_OFFSET=51;TOP_UNIT_PHONE_PORTRAIT_Y_OFFSET=38;UNIT_FONT_SIZE=28;UNIT_PHONE_PORTRAIT_FONT_SIZE=14;UNIT_PADDING=8;UNIT_PHONE_PORTRAIT_PADDING=3;isPortrait=()=>this.isPhonePortrait()?.matches===true;gridBackgroundPlugin={id:"xSpeedGridBackground",beforeDraw:e=>{let t=e.chartArea;if(!t)return;let a=e.ctx,i=this.theme();a.save(),a.globalCompositeOperation="destination-over",a.fillStyle=i.background,a.fillRect(t.left,t.top,t.width/2,t.height),a.restore();}};centerTickPlugin={id:"centerTickStyle",afterDraw:e=>{let t=e.ctx,a=e.chartArea,i=this.theme(),n=this.getThemeColors(),o=Wl.defaults.font,u=e.scales,c=e.options?.scales,r=e.data?.datasets?.[0]?.data,d=e.data?.datasets?.[5]?.data,f=(r?.length??0)>=2&&(d?.length??0)>=2,h=(p,g)=>{let l=u?.[p],x=c;if(!l)return;let E=l,v=x?.[p]?.min??E.min,C=x?.[p]?.max??E.max;if(typeof v!="number"||typeof C!="number"||!isFinite(v)||!isFinite(C))return;let y=(v+C)/2,L=l.getPixelForValue(y);t.save(),t.strokeStyle=i.contrastDim,t.lineWidth=this.CENTER_LINE_WIDTH,t.beginPath(),t.moveTo(L,a.top),t.lineTo(L,a.bottom),t.stroke(),t.restore(),t.save(),t.fillStyle=i.contrastDim,t.font=this.isPortrait()?`bold ${this.CENTER_LABEL_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.CENTER_LABEL_FONT_SIZE}px ${o.family}`,t.textAlign="center",t.textBaseline="top";let J=this.axisTopLabelY(l);t.fillText(g(y),L,J),t.restore();};h("x",p=>`${((p%360+360)%360).toFixed(0)}\xB0`),h("xSpeed",p=>`${p.toFixed(1)}`);let s=u?.xSpeed;if(s){let p=c,g=s,l=p?.xSpeed?.max??g.max;if(typeof l=="number"&&isFinite(l)){let x=s.getPixelForValue(l);t.save(),t.fillStyle=this.resolveTickColor(e,s,l),t.font=this.isPortrait()?`normal ${this.TICK_LABEL_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`normal ${this.TICK_LABEL_FONT_SIZE}px ${o.family}`,t.textAlign="right",t.textBaseline="top";let E=this.axisTopLabelY(s),v=this.xStepSpeed??1,C=Math.max(0,Math.min(3,Math.ceil(-Math.log10(v))));t.fillText(`${l.toFixed(C)}`,x-this.EDGE_SPEED_LABEL_OFFSET,E),t.restore(),t.save(),t.strokeStyle=i.contrastDim,t.lineWidth=this.GRID_LINE_WIDTH,t.beginPath();let y=Math.round(x)+.5;t.moveTo(y,a.bottom),t.lineTo(y,a.top-this.EDGE_EXTEND_UP_PX),t.stroke(),t.restore();}}let m=u?.x;if(m){let p=c,g=m,l=p?.x?.min??g.min;if(typeof l=="number"&&isFinite(l)){let x=m.getPixelForValue(l);t.save(),t.fillStyle=this.resolveTickColor(e,m,l),t.font=this.isPortrait()?`normal ${this.TICK_LABEL_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`normal ${this.TICK_LABEL_FONT_SIZE}px ${o.family}`,t.textAlign="left",t.textBaseline="top";let E=this.axisTopLabelY(m),v=this.normalizeAngle(l);t.fillText(`${v.toFixed(0)}\xB0`,x+this.EDGE_DIR_LABEL_OFFSET,E),t.restore();}}let _=e.data?.datasets,S=_?.[5]?.data,D=S?.length?S.length-1:-1,b=D>=0?S[D]?.x:void 0;if(typeof b=="number"&&isFinite(b)){t.save(),t.fillStyle=n.chartValue,t.font=this.isPortrait()?`bold ${this.SPEED_VALUE_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.SPEED_VALUE_FONT_SIZE}px ${o.family}`,t.textAlign="center",t.textBaseline="middle";let p=`${b.toFixed(1)}`,g=a.left+a.width/4,l=a.top-(this.isPortrait()?this.TOP_VALUE_PHONE_PORTRAIT_Y_OFFSET:this.TOP_VALUE_Y_OFFSET);t.fillText(p,g,l);let x=t.measureText(p),E=g+x.width/2+(this.isPortrait()?this.UNIT_PHONE_PORTRAIT_PADDING:this.UNIT_PADDING),v=a.top-(this.isPortrait()?this.TOP_UNIT_PHONE_PORTRAIT_Y_OFFSET:this.TOP_UNIT_Y_OFFSET);t.font=this.isPortrait()?`bold ${this.UNIT_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.UNIT_FONT_SIZE}px ${o.family}`,t.textAlign="left",t.fillText("kts",E,v),t.restore();}let F=_?.[0]?.data,N=F?.length?F.length-1:-1,T=N>=0?F[N]?.x:void 0;if(typeof T=="number"&&isFinite(T)){let p=this.normalizeAngle(T);t.save(),t.fillStyle=n.chartValue,t.font=this.isPortrait()?`bold ${this.SPEED_VALUE_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.SPEED_VALUE_FONT_SIZE}px ${o.family}`,t.textAlign="center",t.textBaseline="middle",t.fillText(`${p.toFixed(0)}\xB0`,a.left+3*a.width/4,a.top-(this.isPortrait()?this.TOP_VALUE_PHONE_PORTRAIT_Y_OFFSET:this.TOP_VALUE_Y_OFFSET)),t.restore();}if(!f){let p=Math.min(a.width*.7,420),g=90,l=a.left+(a.width-p)/2,x=a.top+(a.height-g)/2;t.save(),t.globalAlpha=.82,t.fillStyle=i.background,t.fillRect(l,x,p,g),t.restore(),t.save(),t.strokeStyle=i.contrastDim,t.lineWidth=2,t.strokeRect(l,x,p,g),t.restore(),t.save(),t.fillStyle=this.getThemeColors().chartLabel,t.textAlign="center",t.textBaseline="middle",t.font=`bold 18px ${o.family}`,t.fillText("Data acquisition...",l+p/2,x+g/2),t.restore();}}};constructor(){this.isPhonePortrait=Wp(this.responsive.observe(Em.HandsetPortrait),{initialValue:void 0}),Fa(()=>{let e=this.theme(),t=this.runtime?.options();!e||!t||ge(()=>{this.datasetConfig&&this.chart&&(this.setChartOptions(),this.setDatasetsColors(),this.ngZone.runOutsideAngular(()=>this.chart?.update("none")));});}),Fa(()=>{let e=this.runtime?.options();if(!e)return;!this.datasetConfig||this.datasetConfig.timeScaleFormat!==e.timeScale?(this.syncServiceDatasets(),this.startWidget()):this.chart&&this.setChartOptions();});}startWidget(){if(this.widgetDataChart()&&(this.datasetConfig=this._dataset.getDatasetConfig(`${this.id()}-twd`)??null,this.dataSourceInfo=this._dataset.getDataSourceInfo(`${this.id()}-twd`)??null,!!this.datasetConfig)){if(this.createDatasets(),this.setChartOptions(),this.chart)this.ngZone.runOutsideAngular(()=>this.chart?.update("none"));else {let e=this.widgetDataChart()?.nativeElement.getContext("2d");if(!e)return;this.chart=new Wl(e,{type:this.lineChartType,data:this.lineChartData,options:this.lineChartOptions,plugins:[this.gridBackgroundPlugin,this.centerTickPlugin]}),this.ngZone.runOutsideAngular(()=>this.chart?.update("none"));}this.startStreaming();}}syncServiceDatasets(){let e=this.runtime?.options();!e||e.timeScale===""||this.datasetLifecycle.syncWindTrendsDatasets(this.id(),e.timeScale);}setChartOptions(){let e=this.datasetConfig,t=this.dataSourceInfo;if(!e||!t)return;this.lineChartOptions.maintainAspectRatio=false,this.lineChartOptions.animation=false,this.lineChartOptions.indexAxis="y";let a=0,i=360,n=(i-a)/4,o=0,u=20,c=(u-o)/4;this.lineChartOptions.scales={y:{type:"linear",display:true,position:"right",reverse:true,title:{display:true,text:`${e.timeScaleFormat}`,align:"center"},ticks:{count:6,autoSkip:false,includeBounds:true,align:"inner",major:{enabled:true},font:this.isPortrait()?{size:12}:{size:16},callback:r=>{let d=Number(r),f=e.timeScaleFormat,h=this.getWindowMs(f);return f==="Last 5 Minutes"?`${Math.round(d/6e4)}'`:h>=10*6e4?`${Math.round(d/6e4)}'`:`${Math.round(d/1e3)}"`}},grid:{display:true,color:this.theme().contrastDimmer}},x:{type:"linear",position:"top",stack:"trends",beginAtZero:false,bounds:"ticks",min:a,max:i,title:{display:false},ticks:{count:5,align:"inner",autoSkip:false,includeBounds:true,stepSize:n,minRotation:0,maxRotation:0,callback:r=>{let d=Number(r),f=this.xCenter??Number.NaN;if(this.nearlyEqual(d,f))return "";let s=this.chart?.options?.scales?.x?.min;return typeof s=="number"&&this.nearlyEqual(d,s)?"":`${((d%360+360)%360).toFixed(0)}\xB0`},font:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenter??Number.NaN,h=this.nearlyEqual(d,f);return this.isPortrait()?{size:11,weight:h?"bold":"normal"}:{size:20,weight:h?"bold":"normal"}},color:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenter??Number.NaN;return this.nearlyEqual(d,f)?this.theme().contrast:void 0}},grid:{display:true,color:r=>{let d=r.tick?.value??Number.NaN,f=r.scale,h=this.chart?.options?.scales,s=f,m=h?.x?.min??s.min;return this.nearlyEqual(d,m)?"rgba(0,0,0,0)":this.theme().contrastDimmer},lineWidth:1}},xSpeed:{type:"linear",position:"top",stack:"trends",beginAtZero:false,bounds:"ticks",min:o,max:u,title:{display:false},ticks:{count:5,align:"inner",autoSkip:false,includeBounds:true,stepSize:c,minRotation:0,maxRotation:0,callback:r=>{let d=this.xCenterSpeed??Number.NaN;if(this.nearlyEqual(r,d))return "";let h=this.chart?.options?.scales?.xSpeed?.max;if(typeof h=="number"&&this.nearlyEqual(r,h))return "";let s=this.xStepSpeed??Number.NaN,m=Number.isFinite(s)?s:1,_=Math.max(0,Math.min(3,Math.ceil(-Math.log10(m))));return `${r.toFixed(_)}`},font:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenterSpeed??Number.NaN,h=this.nearlyEqual(d,f);return this.isPortrait()?{size:11,weight:h?"bold":"normal"}:{size:20,weight:h?"bold":"normal"}},color:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenterSpeed??Number.NaN;return this.nearlyEqual(d,f)?this.theme().contrast:void 0}},grid:{display:true,color:r=>{let d=r.tick?.value??Number.NaN,f=r.scale,h=this.chart?.options?.scales,s=f,m=h?.xSpeed?.max??s.max;return this.nearlyEqual(d,m)?"rgba(0,0,0,0)":this.theme().contrastDimmer},lineWidth:1}}},this.lineChartOptions.plugins={title:{display:true,align:"end",text:"TWD ",color:this.getThemeColors().chartLabel,padding:this.isPortrait()?{top:3,bottom:0}:{top:3,bottom:0},font:this.isPortrait()?{size:16,weight:"normal"}:{size:35,weight:"normal"}},subtitle:{display:true,align:"start",text:" TWS",color:this.getThemeColors().chartLabel,padding:this.isPortrait()?{top:-18,bottom:12}:{top:-41,bottom:12},font:this.isPortrait()?{size:16}:{size:35}},legend:{display:false},annotation:{annotations:{}},streaming:{duration:t.maxDataPoints*t.sampleTime,delay:t.sampleTime,frameRate:e.timeScaleFormat==="day"?5:e.timeScaleFormat==="hour"?8:e.timeScaleFormat==="minute"?15:30}},this.xCenter=(a+i)/2,this.xStep=n,this.xCenterSpeed=(o+u)/2,this.xStepSpeed=c;}createDatasets(){this.lineChartData.datasets=[],this.lineChartData.datasets.push({label:"Value",data:[],order:2,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:1,fill:false,xAxisID:"x"},{label:"SMA",data:[],order:0,parsing:false,normalized:true,tension:.3,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:10,fill:false,borderColor:e=>{let t=e.chart,{ctx:a}=t;return this.lineGradientForAxis(a,t,"x")??this.getThemeColors().averageLine},backgroundColor:"red",xAxisID:"x"},{label:"lastAverage",data:[],order:1,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:0,borderColor:"",fill:false,hidden:true,xAxisID:"x"},{label:"lastMinimum",data:[],order:3,parsing:false,normalized:true,hidden:true,xAxisID:"x"},{label:"lastMaximum",data:[],order:4,parsing:false,normalized:true,hidden:true,xAxisID:"x"},{label:"Value Speed",data:[],order:2,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:1,fill:false,xAxisID:"xSpeed"},{label:"SMA Speed",data:[],order:0,parsing:false,normalized:true,tension:.2,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:3,fill:false,borderColor:e=>{let t=e.chart,{ctx:a}=t;return this.lineGradientForAxis(a,t,"xSpeed")??this.getThemeColors().averageLine},xAxisID:"xSpeed"},{label:"lastAverage Speed",data:[],order:1,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:0,borderColor:"",fill:false,hidden:true,xAxisID:"xSpeed"},{label:"lastMinimum Speed",data:[],order:3,parsing:false,normalized:true,hidden:true,xAxisID:"xSpeed"},{label:"lastMaximum Speed",data:[],order:4,parsing:false,normalized:true,hidden:true,xAxisID:"xSpeed"}),this.setDatasetsColors();}startStreaming(){if(this._dsDirectionSub?.unsubscribe(),this._dsSpeedSub?.unsubscribe(),!this.chart||!this.dataSourceInfo)return;let e=this._dataset.getDatasetBatchThenLiveObservable(`${this.id()}-twd`),t=this._dataset.getDatasetBatchThenLiveObservable(`${this.id()}-tws`);!e||!t||(this._dsDirectionSub=e.subscribe(a=>{let i=this.chart,n=this.dataSourceInfo;if(!(!i||!n)){if(Array.isArray(a))this.pushRowsToDatasets(a);else {this.pushRowsToDatasets([a]);let o=i.data.datasets[0]?.data;if(Array.isArray(o)&&o.length>n.maxDataPoints)for(let u=0;u<=4;u++){let c=i.data.datasets[u]?.data;Array.isArray(c)&&c.shift();}}this.scheduleChartUpdate();}}),this._dsSpeedSub=t.subscribe(a=>{let i=this.chart,n=this.dataSourceInfo;if(!(!i||!n)){if(Array.isArray(a))this.pushRowsToSpeedDatasets(a);else {this.pushRowsToSpeedDatasets([a]);let o=i.data.datasets[5]?.data;if(Array.isArray(o)&&o.length>n.maxDataPoints)for(let u=5;u<=9;u++){let c=i.data.datasets[u]?.data;Array.isArray(c)&&c.shift();}}this.scheduleChartUpdate();}}));}unwrapAngles(e){if(e.length===0)return [];let t=[],a=null;for(let i of e){if(i==null){t.push(null);continue}if(a==null){t.push(i),a=i;continue}let n=i-a;n>180&&(n-=360),n<-180&&(n+=360),t.push(t[t.length-1]+n),a=i;}return t}pushRowsToDatasets(e){this.pushRowsGeneric(e,0,"deg",true);}pushRowsToSpeedDatasets(e){this.pushRowsGeneric(e,5,"knots",false);}getRowValue(e,t){switch(t){case "value":return e.data.value??null;case "sma":return e.data.sma??null;case "ema":return e.data.ema??null;case "dema":return e.data.doubleEma??null;case "avg":return e.data.lastAverage??null;case "min":return e.data.lastMinimum??null;case "max":return e.data.lastMaximum??null;default:return null}}transformRows(e,t,a,i){let n=e.map(u=>{let c=this.getRowValue(u,t);return c==null?null:this.unitsService.convertToUnit(a,c)}),o=i?this.unwrapAngles(n):n;return e.map((u,c)=>({x:o[c],y:u.timestamp,ts:u.timestamp}))}pushRowsGeneric(e,t,a,i){let n=this.chart;if(!n)return;["value","sma","avg","min","max"].forEach((u,c)=>{let r=n.data.datasets[t+c];!r||!Array.isArray(r.data)||r.data.push(...this.transformRows(e,u,a,i));});}normalizeAngle(e){return (e%360+360)%360}angularDiff(e,t){let a=(e-t+540)%360-180;return Math.abs(a)}niceStepFromMantissas(e,t){if(!isFinite(e)||e<=0)return 1;let a=Math.floor(Math.log10(e)),i=e/Math.pow(10,a);return (t.find(o=>i<=o)??t[t.length-1])*Math.pow(10,a)}scheduleChartUpdate(){this._chartUpdateRafId==null&&(this._chartUpdateRafId=requestAnimationFrame(()=>{this._chartUpdateRafId=null,!(!this.chart||!this.hasValidDatasets())&&(this.updateChartAfterDataChange(),this.ngZone.runOutsideAngular(()=>this.chart?.update("none")));}));}hasValidDatasets(){let e=this.chart?.data?.datasets;if(!Array.isArray(e)||e.length<10)return false;for(let t=0;t<10;t++){let a=e[t];if(!a||!Array.isArray(a.data))return false}return true}updateChartAfterDataChange(){let e=this.chart;if(!e)return;let t=e.data.datasets[2]?.data,a=e.data.datasets[1]?.data,i=e.data.datasets[0]?.data,n=!!t?.length,o=!!a?.length,u=!!i?.length,c=n?t[t.length-1].x:o?a[a.length-1].x:u?i[i.length-1].x:void 0;if(typeof c=="number"&&isFinite(c)){let h=e.data.datasets[3]?.data,s=e.data.datasets[4]?.data,m=h?.length?h[h.length-1].x:void 0,_=s?.length?s[s.length-1].x:void 0,S=typeof m=="number"&&isFinite(m)?this.angularDiff(c,m):Number.NaN,D=typeof _=="number"&&isFinite(_)?this.angularDiff(c,_):Number.NaN,b=Number.isFinite(S)||Number.isFinite(D)?Math.max(Number.isFinite(S)?S:0,Number.isFinite(D)?D:0):Number.NaN;if(!Number.isFinite(b)){let x=n?t:o?a:i,E=Math.min(30,x?.length??0);if(E>1){let C=x.slice(x.length-E).map(y=>y.x).filter(y=>typeof y=="number"&&isFinite(y));C.length&&(b=C.reduce((y,L)=>Math.max(y,this.angularDiff(c,L)),0));}}b=Math.max(b||0,15);let N=2*b/4,T=this.niceStepFromMantissas(N,[1,1.5,2,2.5,5,7.5,10]),p=c-2*T,g=c+2*T,l=e.options.scales;l.x&&(l.x.min=p,l.x.max=g,l.x.ticks=z(G({},l.x.ticks??{}),{stepSize:T})),this.xCenter=c,this.xStep=T;}let r=e.data.datasets[7]?.data;if(r&&r.length){let h=r.length-1,s=r[h]?.x??0,m=e.data.datasets[8].data[h]?.x??s,_=e.data.datasets[9].data[h]?.x??s,S=Math.abs(s-m),D=Math.abs(_-s),b=Math.max(S,D);b=Math.max(b,.5);let N=2*b/4,T=this.niceStepFromMantissas(N,[1,2,2.5,5,10]),p=s-2*T,g=s+2*T,l=e.options.scales;l.xSpeed&&(l.xSpeed.min=p,l.xSpeed.max=g,l.xSpeed.ticks=z(G({},l.xSpeed.ticks??{}),{stepSize:T})),this.xCenterSpeed=s,this.xStepSpeed=T;}let d=this.getWindowMs(this.datasetConfig?.timeScaleFormat);if(e.data.datasets[0].data.length>0){let h=Date.now();e.data.datasets.forEach(S=>{S.data.forEach(D=>{let b=D.ts??D.y;D.y=Math.max(0,Math.min(d,h-b));});});let s=e.options.scales;s.y&&(s.y.min=0,s.y.max=d);let m;switch(this.datasetConfig?.timeScaleFormat){case "Last Minute":m=15e3;break;case "Last 5 Minutes":m=6e4;break;case "Last 30 Minutes":m=5*6e4;break;default:m=d/5;break}if(s.y){let S=G({},s.y.ticks??{});delete S.count,S.stepSize=m,s.y.ticks=S;}}}getWindowMs(e){switch(e){case "Last 30 Minutes":return 30*6e4;case "Last 5 Minutes":return 5*6e4;case "Last Minute":return 6e4;default:return 6e4}}lineGradientForAxis(e,t,a){let i=t.chartArea;if(!i)return null;let n=t.scales?.[a];if(!n)return null;let o=t.options?.scales,u=n,c=o?.[a]?.min??u.min,r=o?.[a]?.max??u.max;if(typeof c!="number"||typeof r!="number"||!isFinite(c)||!isFinite(r))return null;let d=(c+r)/2,f=n.getPixelForValue(d),h=Math.max(0,Math.min(1,(f-i.left)/i.width)),s=e.createLinearGradient(i.left,0,i.right,0);return s.addColorStop(0,this.theme().port),s.addColorStop(h,this.theme().port),s.addColorStop(h,this.theme().starboard),s.addColorStop(1,this.theme().starboard),s}setDatasetsColors(){this.lineChartData.datasets.forEach(e=>{e.label==="Value"&&(e.borderColor=this.getThemeColors().valueLine,e.backgroundColor=this.getThemeColors().valueFill),e.label==="Value Speed"&&(e.borderColor=this.getThemeColors().valueLine,e.backgroundColor=this.getThemeColors().valueFill);});}getThemeColors(){let e=this.runtime?.options()?.color,t={valueLine:"",valueFill:"",averageLine:"",averageFill:"",averageChartLine:"",chartLabel:"",chartValue:""};switch(e){case "contrast":t.valueLine=this.theme().contrastDim,t.valueFill=this.theme().contrastDimmer,t.averageLine=this.theme().contrast,t.averageFill=this.theme().contrast,t.chartValue=this.theme().contrast,t.averageChartLine=this.theme().contrast,t.chartLabel=this.theme().contrastDim;break;case "blue":t.valueLine=this.theme().blueDim,t.valueFill=this.theme().blueDimmer,t.averageLine=this.theme().blue,t.averageFill=this.theme().blue,t.chartValue=this.theme().blue,t.averageChartLine=this.theme().blueDim,t.chartLabel=this.theme().blueDim;break;case "green":t.valueLine=this.theme().greenDim,t.valueFill=this.theme().greenDimmer,t.averageLine=this.theme().green,t.averageFill=this.theme().green,t.chartValue=this.theme().green,t.averageChartLine=this.theme().greenDim,t.chartLabel=this.theme().greenDim;break;case "pink":t.valueLine=this.theme().pinkDim,t.valueFill=this.theme().pinkDimmer,t.averageLine=this.theme().pink,t.averageFill=this.theme().pink,t.chartValue=this.theme().pink,t.averageChartLine=this.theme().pinkDim,t.chartLabel=this.theme().pinkDim;break;case "orange":t.valueLine=this.theme().orangeDim,t.valueFill=this.theme().orangeDimmer,t.averageLine=this.theme().orange,t.averageFill=this.theme().orange,t.chartValue=this.theme().orange,t.averageChartLine=this.theme().orangeDim,t.chartLabel=this.theme().orangeDim;break;case "purple":t.valueLine=this.theme().purpleDim,t.valueFill=this.theme().purpleDimmer,t.averageLine=this.theme().purple,t.averageFill=this.theme().purple,t.chartValue=this.theme().purple,t.averageChartLine=this.theme().purpleDim,t.chartLabel=this.theme().purpleDim;break;case "grey":t.valueLine=this.theme().greyDim,t.valueFill=this.theme().greyDimmer,t.averageLine=this.theme().grey,t.averageFill=this.theme().grey,t.chartValue=this.theme().grey,t.averageChartLine=this.theme().greyDim,t.chartLabel=this.theme().greyDim;break;case "yellow":t.valueLine=this.theme().yellowDim,t.valueFill=this.theme().yellowDimmer,t.averageLine=this.theme().yellow,t.averageFill=this.theme().yellow,t.chartValue=this.theme().yellow,t.averageChartLine=this.theme().yellowDim,t.chartLabel=this.theme().yellowDim;break}return t}nearlyEqual(e,t,a=1e-6){if(!Number.isFinite(e)||!Number.isFinite(t))return false;let i=Math.max(1,Math.max(Math.abs(e),Math.abs(t)));return Math.abs(e-t)<=a*i}resolveTickColor(e,t,a){let n=t.options.ticks?.color;return typeof n=="function"?n({chart:e,scale:t,tick:{value:a}})??Wl.defaults.color:typeof n=="string"?n:Wl.defaults.color}axisTopLabelY(e){return e.options?.position==="top"?e.top+4:e.bottom+2}ngOnDestroy(){this._dsDirectionSub?.unsubscribe(),this._dsSpeedSub?.unsubscribe(),this._chartUpdateRafId!=null&&(cancelAnimationFrame(this._chartUpdateRafId),this._chartUpdateRafId=null),this.chart?.destroy();let e=this.widgetDataChart?.()?.nativeElement;this.canvasService.releaseCanvas(e,{clear:true,removeFromDom:true});}static \u0275fac=function(t){return new(t||O)};static \u0275cmp=JD({type:O,selectors:[["widget-windtrends-chart"]],viewQuery:function(t,a){t&1&&eg(a.widgetDataChart,tt,5,Lr),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:0,consts:[["widgetDataChart",""],[2,"z-index","inherit"]],template:function(t,a){t&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%}"]})}return O})();export{mt as WidgetWindTrendsChartComponent};
@@ -1 +1 @@
1
- import {p as p$1}from'./chunk-CaD3zVfK.js';import {G as Gt,L as Lt}from'./chunk-BQr-tSkv.js';import {u}from'./chunk-hd2_AKwt.js';import {k}from'./chunk-BwOIef42.js';import {d1 as Hj,w,du as p,dv as rt,dD as _,bu as ut,$ as $j,a6 as Lr,v as vt,D as Dt,F as Fa,dn as ge,J as JD,_ as _w,M as Mw,f as eg,K as Kw,h as Fw,P as Pi,k as Qh,u as ul,g as qw,B as Bh,an as Hh,l as ud,m as dd,dx as n$1}from'./main-BAV5VDOD.js';import {c}from'./chunk-Dxlia2NE.js';var L=["radialGauge"];function F(n,q){if(n&1){let t=Fw();Pi(0,"radial-gauge",2,0),Qh("resizeChange",function(a){ud(t);let e=qw();return dd(e.onResized(a))}),ul();}if(n&2){let t=qw();Bh("options",t.gaugeOptions)("value",t.displayValue()),Hh("value-text",t.textValue());}}var ne=(()=>{class n{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);metadata=w(_);unitsService=w(ut);static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:true,displayName:"Gauge Label",filterSelfPaths:true,paths:{gaugePath:{description:"Numeric Data",path:null,source:null,pathType:"number",suppressBootstrapNull:true,isPathConfigurable:true,showPathSkUnitsFilter:true,pathSkUnitsFilter:null,convertUnitTo:"unitless",sampleTime:500}},displayScale:{lower:0,upper:100,type:"linear"},gauge:{type:"ngRadial",subType:"measuring",highlightsWidth:5,scaleStart:180,barStartPosition:"left",enableTicks:true,enableProgressbar:true,enableNeedle:true},numInt:1,numDecimal:0,enableTimeout:false,color:"contrast",dataTimeout:5,ignoreZones:false};LINE="line";ANIMATION_TARGET_NEEDLE="needle";ngGauge=$j("radialGauge");gauge=$j("radialGauge",{read:Lr});value=vt(void 0);displayValue=Dt(()=>this.value()??0);shouldRenderGauge=Dt(()=>this.value()!==void 0);textValue=vt("--");colorStrokeTicks=vt("");gaugeBootstrapped=vt(false);animationEnabled=Dt(()=>this.gaugeBootstrapped());normalizedConfig=Dt(()=>this.runtime.options()??n.DEFAULT_CONFIG);gaugePathConfig=Dt(()=>this.normalizedConfig().paths?.gaugePath);adjustedScale=Dt(()=>{let t=this.normalizedConfig();return t.gauge?.subType==="capacity"?{min:t.displayScale?.lower??0,max:t.displayScale?.upper??100,majorTicks:[]}:p$1(t.displayScale?.lower??0,t.displayScale?.upper??100,t.gauge?.barStartPosition==="right")});highlights=Dt(()=>{let t=this.metadata.zones(),i=this.normalizedConfig(),a=this.theme(),e=this.gaugePathConfig();if(!t?.length)return [];if(!a)return [];if(i.ignoreZones)return [];if(i.gauge?.subType!=="measuring")return [];if(!e)return [];let o=this.adjustedScale(),r=i.gauge?.barStartPosition==="right";return k(t,a,e.convertUnitTo??"",this.unitsService,o.min,o.max,r)});displayName=Dt(()=>this.normalizedConfig().displayName??"Gauge Label");pathDataState=vt(null);viewReady=vt(false);gaugeOptions={};constructor(){Fa(()=>{let t=this.normalizedConfig(),i=this.theme(),a=this.gaugePathConfig();!i||!a?.path||ge(()=>this.streams.observe("gaugePath",e=>{e.state!==this.pathDataState()&&this.pathDataState.set(e.state||null);let o=e?.data?.value??null;if(o==null)this.value.set(t.displayScale?.lower??0),this.textValue.set("--");else {let r=t.displayScale?.lower??0,h=t.displayScale?.upper??100,f=Math.min(Math.max(o,r),h);this.value.set(f),this.textValue()==="--"&&this.textValue.set("");}}));}),Fa(()=>{this.normalizedConfig().ignoreZones||ge(()=>this.metadata.observe("gaugePath"));}),Fa(()=>{let t=this.highlights();this.viewReady()&&ge(()=>{try{if(!t.length)this.ngGauge()?.update({highlights:[]});else {let i=JSON.stringify(t);this.ngGauge()?.update({highlights:i,highlightsWidth:this.normalizedConfig().gauge?.highlightsWidth});}}catch(i){}});}),Fa(()=>{let t=this.normalizedConfig(),i=this.theme(),a=this.adjustedScale();i&&ge(()=>{if(this.buildGaugeOptions(t,i,a),this.viewReady())try{this.ngGauge()?.update(this.gaugeOptions);}catch(e){}});}),Fa(()=>{let t=this.ngGauge();!t||this.gaugeBootstrapped()||ge(()=>{try{requestAnimationFrame(()=>{this.gaugeBootstrapped.set(!0);try{t.update({animation:!0,animatedValue:!0});}catch(i){}});}catch(i){}});}),Fa(()=>{let t=this.pathDataState();this.viewReady()&&ge(()=>{let i=this.normalizedConfig(),a=this.theme();if(!a||i.ignoreZones)return;let e={},o=c(i.color??"contrast",a);switch(t){case n$1.Alarm:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=a.zoneAlarm,e.colorValueText=a.zoneAlarm;break;case n$1.Warn:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=a.zoneWarn,e.colorValueText=a.zoneWarn;break;case n$1.Alert:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=a.zoneAlert,e.colorValueText=a.zoneAlert;break;default:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=i.gauge?.subType==="measuring"?o.color:o.dim,e.colorValueText=o.color;}try{this.ngGauge()?.update(e);}catch(r){}});});}ngAfterViewInit(){this.viewReady.set(true),this.setCanvasSize();try{this.ngGauge()?.update(this.gaugeOptions);}catch(t){}}onResized(t){let i={height:t.contentRect.height,width:t.contentRect.width};try{this.ngGauge()?.update(i);}catch(a){}}setCanvasSize(){let t=this.gauge()?.nativeElement;if(!t)return;let i=t.getBoundingClientRect(),a={height:i.height,width:i.width};try{this.ngGauge()?.update(a);}catch(e){}}buildGaugeOptions(t,i,a){let e={},o=this.gaugePathConfig(),r=t.gauge??n.DEFAULT_CONFIG.gauge;e.title=this.displayName(),e.minValue=a.min,e.maxValue=a.max,e.units=o?.convertUnitTo??"",e.highlights=[];let h=this.highlights();h.length&&(e.highlights=JSON.stringify(h),e.highlightsWidth=t.gauge?.highlightsWidth),e.fontTitle="Roboto",e.fontTitleWeight="bold",e.fontUnits="Roboto",e.fontUnitsSize=25,e.fontUnitsWeight="normal",e.barStrokeWidth=0,e.barShadow=0,e.colorBarStroke="",e.fontValue="Roboto",e.fontValueWeight="bold",e.valueTextShadow=false,e.colorValueBoxShadow="",e.fontNumbers="Roboto",e.fontNumbersWeight="bold",e.valueInt=t.numInt??1,e.valueDec=t.numDecimal??2,e.majorTicksInt=e.valueInt,e.majorTicksDec=e.valueDec,e.highlightsWidth=t.gauge?.highlightsWidth,e.animation=this.animationEnabled(),e.animateOnInit=false,e.animatedValue=this.animationEnabled(),e.animationRule="linear";let f=o?.sampleTime??500;e.animationDuration=f-25,e.colorBorderShadow=false,e.colorBorderOuter=i.cardColor,e.colorBorderOuterEnd="",e.colorBorderMiddle=i.cardColor,e.colorBorderMiddleEnd="",e.colorPlate=e.colorPlateEnd=i.cardColor,e.colorBar=i.background;let g=c(t.color??"contrast",i);e.barProgress=t.gauge?.enableProgressbar,e.colorBarProgress=g.color,e.colorNeedle=g.color,e.colorNeedleEnd=g.color,e.needleShadow=true,e.colorNeedleShadowUp="black",e.colorNeedleShadowDown="black",e.colorNeedleCircleInner=e.colorPlate,e.colorNeedleCircleInnerEnd=e.colorPlate,e.colorNeedleCircleOuter=e.colorPlate,e.colorNeedleCircleOuterEnd=e.colorPlate,e.colorTitle=i.contrastDim,e.colorUnits=i.contrastDim,e.colorValueText=g.color,this.colorStrokeTicks.set(i.contrastDim),e.colorMinorTicks=i.contrastDim,e.animationTarget=this.ANIMATION_TARGET_NEEDLE,e.useMinPath=false,r.subType==="capacity"?(e.fontTitleSize=40,e.valueBox=true,e.fontValueSize=60,e.valueBoxWidth=10,e.valueBoxBorderRadius=5,e.valueBoxStroke=0,e.colorValueBoxBackground="",e.colorMajorTicks=e.colorPlate,e.colorNumbers=e.colorMinorTicks="",e.barWidth=20,e.colorBarProgress=g.dim,e.needle=r.enableNeedle,e.needleType=this.LINE,e.needleWidth=2,e.needleStart=75,e.needleEnd=95,e.needleCircleSize=1,e.needleCircleInner=false,e.needleCircleOuter=false,e.ticksAngle=360,e.startAngle=r.scaleStart||180,e.majorTicks=0,e.exactTicks=true,e.strokeTicks=false,e.minorTicks=0,e.numbersMargin=0,e.fontNumbersSize=0,e.borders=true,e.borderOuterWidth=2,e.borderMiddleWidth=1,e.borderInnerWidth=0,e.borderShadowWidth=0):(e.fontTitleSize=24,e.barWidth=15,e.valueBox=true,e.fontValueSize=60,e.valueBoxWidth=100,e.valueBoxBorderRadius=0,e.valueBoxStroke=0,e.colorValueBoxBackground="",e.needle=r.enableNeedle,e.needleType=this.LINE,e.needleWidth=2,e.needleStart=0,e.needleEnd=95,e.needleCircleSize=10,e.needleCircleInner=false,e.needleCircleOuter=false,e.ticksAngle=270,e.startAngle=45,e.barStartPosition=r.barStartPosition||"left",r.enableTicks?(e.strokeTicks=true,e.majorTicks=a.majorTicks,e.minorTicks=2,e.exactTicks=false,e.numbersMargin=3,e.fontNumbersSize=15,e.colorMajorTicks=i.contrastDim,e.colorNumbers=i.contrastDim):(e.strokeTicks=false,e.majorTicks=0,e.minorTicks=0,e.exactTicks=true,e.numbersMargin=0,e.fontNumbersSize=0,e.colorMajorTicks=e.colorPlate,e.colorNumbers=e.colorMinorTicks=""),e.borders=true,e.borderOuterWidth=2,e.borderMiddleWidth=1,e.borderInnerWidth=0,e.borderShadowWidth=0,e.animationTarget=this.ANIMATION_TARGET_NEEDLE,e.useMinPath=false),this.gaugeOptions=e;}static \u0275fac=function(i){return new(i||n)};static \u0275cmp=JD({type:n,selectors:[["widget-gauge-ng-radial"]],viewQuery:function(i,a){i&1&&eg(a.ngGauge,L,5)(a.gauge,L,5,Lr),i&2&&Kw(2);},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:1,vars:1,consts:[["radialGauge",""],["kipResizeObserver","",3,"options","value"],["kipResizeObserver","",3,"resizeChange","options","value"]],template:function(i,a){i&1&&_w(0,F,2,3,"radial-gauge",1),i&2&&Mw(a.shouldRenderGauge()?0:-1);},dependencies:[u,Gt,Lt],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%} radial-gauge{display:block;position:relative;width:100%;min-width:8px;height:100%;overflow:clip} radial-gauge>canvas{display:block;position:absolute;height:100%;width:100%;left:50%;top:50%;transform:translate(-50%,-50%);padding:0}"]})}return n})();export{ne as WidgetGaugeNgRadialComponent};
1
+ import {p as p$1}from'./chunk-CaD3zVfK.js';import {G as Gt,L as Lt}from'./chunk-q9NoPvcx.js';import {u}from'./chunk-CCfhzpE8.js';import {k}from'./chunk-B0eE4udE.js';import {d1 as Hj,w,du as p,dv as rt,dD as _,bu as ut,$ as $j,a6 as Lr,v as vt,D as Dt,F as Fa,dn as ge,J as JD,_ as _w,M as Mw,f as eg,K as Kw,h as Fw,P as Pi,k as Qh,u as ul,g as qw,B as Bh,an as Hh,l as ud,m as dd,dx as n$1}from'./main-YKDNK5VZ.js';import {c}from'./chunk-BIb-xYiS.js';var L=["radialGauge"];function F(n,q){if(n&1){let t=Fw();Pi(0,"radial-gauge",2,0),Qh("resizeChange",function(a){ud(t);let e=qw();return dd(e.onResized(a))}),ul();}if(n&2){let t=qw();Bh("options",t.gaugeOptions)("value",t.displayValue()),Hh("value-text",t.textValue());}}var ne=(()=>{class n{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);metadata=w(_);unitsService=w(ut);static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:true,displayName:"Gauge Label",filterSelfPaths:true,paths:{gaugePath:{description:"Numeric Data",path:null,source:null,pathType:"number",suppressBootstrapNull:true,isPathConfigurable:true,showPathSkUnitsFilter:true,pathSkUnitsFilter:null,convertUnitTo:"unitless",sampleTime:500}},displayScale:{lower:0,upper:100,type:"linear"},gauge:{type:"ngRadial",subType:"measuring",highlightsWidth:5,scaleStart:180,barStartPosition:"left",enableTicks:true,enableProgressbar:true,enableNeedle:true},numInt:1,numDecimal:0,enableTimeout:false,color:"contrast",dataTimeout:5,ignoreZones:false};LINE="line";ANIMATION_TARGET_NEEDLE="needle";ngGauge=$j("radialGauge");gauge=$j("radialGauge",{read:Lr});value=vt(void 0);displayValue=Dt(()=>this.value()??0);shouldRenderGauge=Dt(()=>this.value()!==void 0);textValue=vt("--");colorStrokeTicks=vt("");gaugeBootstrapped=vt(false);animationEnabled=Dt(()=>this.gaugeBootstrapped());normalizedConfig=Dt(()=>this.runtime.options()??n.DEFAULT_CONFIG);gaugePathConfig=Dt(()=>this.normalizedConfig().paths?.gaugePath);adjustedScale=Dt(()=>{let t=this.normalizedConfig();return t.gauge?.subType==="capacity"?{min:t.displayScale?.lower??0,max:t.displayScale?.upper??100,majorTicks:[]}:p$1(t.displayScale?.lower??0,t.displayScale?.upper??100,t.gauge?.barStartPosition==="right")});highlights=Dt(()=>{let t=this.metadata.zones(),i=this.normalizedConfig(),a=this.theme(),e=this.gaugePathConfig();if(!t?.length)return [];if(!a)return [];if(i.ignoreZones)return [];if(i.gauge?.subType!=="measuring")return [];if(!e)return [];let o=this.adjustedScale(),r=i.gauge?.barStartPosition==="right";return k(t,a,e.convertUnitTo??"",this.unitsService,o.min,o.max,r)});displayName=Dt(()=>this.normalizedConfig().displayName??"Gauge Label");pathDataState=vt(null);viewReady=vt(false);gaugeOptions={};constructor(){Fa(()=>{let t=this.normalizedConfig(),i=this.theme(),a=this.gaugePathConfig();!i||!a?.path||ge(()=>this.streams.observe("gaugePath",e=>{e.state!==this.pathDataState()&&this.pathDataState.set(e.state||null);let o=e?.data?.value??null;if(o==null)this.value.set(t.displayScale?.lower??0),this.textValue.set("--");else {let r=t.displayScale?.lower??0,h=t.displayScale?.upper??100,f=Math.min(Math.max(o,r),h);this.value.set(f),this.textValue()==="--"&&this.textValue.set("");}}));}),Fa(()=>{this.normalizedConfig().ignoreZones||ge(()=>this.metadata.observe("gaugePath"));}),Fa(()=>{let t=this.highlights();this.viewReady()&&ge(()=>{try{if(!t.length)this.ngGauge()?.update({highlights:[]});else {let i=JSON.stringify(t);this.ngGauge()?.update({highlights:i,highlightsWidth:this.normalizedConfig().gauge?.highlightsWidth});}}catch(i){}});}),Fa(()=>{let t=this.normalizedConfig(),i=this.theme(),a=this.adjustedScale();i&&ge(()=>{if(this.buildGaugeOptions(t,i,a),this.viewReady())try{this.ngGauge()?.update(this.gaugeOptions);}catch(e){}});}),Fa(()=>{let t=this.ngGauge();!t||this.gaugeBootstrapped()||ge(()=>{try{requestAnimationFrame(()=>{this.gaugeBootstrapped.set(!0);try{t.update({animation:!0,animatedValue:!0});}catch(i){}});}catch(i){}});}),Fa(()=>{let t=this.pathDataState();this.viewReady()&&ge(()=>{let i=this.normalizedConfig(),a=this.theme();if(!a||i.ignoreZones)return;let e={},o=c(i.color??"contrast",a);switch(t){case n$1.Alarm:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=a.zoneAlarm,e.colorValueText=a.zoneAlarm;break;case n$1.Warn:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=a.zoneWarn,e.colorValueText=a.zoneWarn;break;case n$1.Alert:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=a.zoneAlert,e.colorValueText=a.zoneAlert;break;default:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=i.gauge?.subType==="measuring"?o.color:o.dim,e.colorValueText=o.color;}try{this.ngGauge()?.update(e);}catch(r){}});});}ngAfterViewInit(){this.viewReady.set(true),this.setCanvasSize();try{this.ngGauge()?.update(this.gaugeOptions);}catch(t){}}onResized(t){let i={height:t.contentRect.height,width:t.contentRect.width};try{this.ngGauge()?.update(i);}catch(a){}}setCanvasSize(){let t=this.gauge()?.nativeElement;if(!t)return;let i=t.getBoundingClientRect(),a={height:i.height,width:i.width};try{this.ngGauge()?.update(a);}catch(e){}}buildGaugeOptions(t,i,a){let e={},o=this.gaugePathConfig(),r=t.gauge??n.DEFAULT_CONFIG.gauge;e.title=this.displayName(),e.minValue=a.min,e.maxValue=a.max,e.units=o?.convertUnitTo??"",e.highlights=[];let h=this.highlights();h.length&&(e.highlights=JSON.stringify(h),e.highlightsWidth=t.gauge?.highlightsWidth),e.fontTitle="Roboto",e.fontTitleWeight="bold",e.fontUnits="Roboto",e.fontUnitsSize=25,e.fontUnitsWeight="normal",e.barStrokeWidth=0,e.barShadow=0,e.colorBarStroke="",e.fontValue="Roboto",e.fontValueWeight="bold",e.valueTextShadow=false,e.colorValueBoxShadow="",e.fontNumbers="Roboto",e.fontNumbersWeight="bold",e.valueInt=t.numInt??1,e.valueDec=t.numDecimal??2,e.majorTicksInt=e.valueInt,e.majorTicksDec=e.valueDec,e.highlightsWidth=t.gauge?.highlightsWidth,e.animation=this.animationEnabled(),e.animateOnInit=false,e.animatedValue=this.animationEnabled(),e.animationRule="linear";let f=o?.sampleTime??500;e.animationDuration=f-25,e.colorBorderShadow=false,e.colorBorderOuter=i.cardColor,e.colorBorderOuterEnd="",e.colorBorderMiddle=i.cardColor,e.colorBorderMiddleEnd="",e.colorPlate=e.colorPlateEnd=i.cardColor,e.colorBar=i.background;let g=c(t.color??"contrast",i);e.barProgress=t.gauge?.enableProgressbar,e.colorBarProgress=g.color,e.colorNeedle=g.color,e.colorNeedleEnd=g.color,e.needleShadow=true,e.colorNeedleShadowUp="black",e.colorNeedleShadowDown="black",e.colorNeedleCircleInner=e.colorPlate,e.colorNeedleCircleInnerEnd=e.colorPlate,e.colorNeedleCircleOuter=e.colorPlate,e.colorNeedleCircleOuterEnd=e.colorPlate,e.colorTitle=i.contrastDim,e.colorUnits=i.contrastDim,e.colorValueText=g.color,this.colorStrokeTicks.set(i.contrastDim),e.colorMinorTicks=i.contrastDim,e.animationTarget=this.ANIMATION_TARGET_NEEDLE,e.useMinPath=false,r.subType==="capacity"?(e.fontTitleSize=40,e.valueBox=true,e.fontValueSize=60,e.valueBoxWidth=10,e.valueBoxBorderRadius=5,e.valueBoxStroke=0,e.colorValueBoxBackground="",e.colorMajorTicks=e.colorPlate,e.colorNumbers=e.colorMinorTicks="",e.barWidth=20,e.colorBarProgress=g.dim,e.needle=r.enableNeedle,e.needleType=this.LINE,e.needleWidth=2,e.needleStart=75,e.needleEnd=95,e.needleCircleSize=1,e.needleCircleInner=false,e.needleCircleOuter=false,e.ticksAngle=360,e.startAngle=r.scaleStart||180,e.majorTicks=0,e.exactTicks=true,e.strokeTicks=false,e.minorTicks=0,e.numbersMargin=0,e.fontNumbersSize=0,e.borders=true,e.borderOuterWidth=2,e.borderMiddleWidth=1,e.borderInnerWidth=0,e.borderShadowWidth=0):(e.fontTitleSize=24,e.barWidth=15,e.valueBox=true,e.fontValueSize=60,e.valueBoxWidth=100,e.valueBoxBorderRadius=0,e.valueBoxStroke=0,e.colorValueBoxBackground="",e.needle=r.enableNeedle,e.needleType=this.LINE,e.needleWidth=2,e.needleStart=0,e.needleEnd=95,e.needleCircleSize=10,e.needleCircleInner=false,e.needleCircleOuter=false,e.ticksAngle=270,e.startAngle=45,e.barStartPosition=r.barStartPosition||"left",r.enableTicks?(e.strokeTicks=true,e.majorTicks=a.majorTicks,e.minorTicks=2,e.exactTicks=false,e.numbersMargin=3,e.fontNumbersSize=15,e.colorMajorTicks=i.contrastDim,e.colorNumbers=i.contrastDim):(e.strokeTicks=false,e.majorTicks=0,e.minorTicks=0,e.exactTicks=true,e.numbersMargin=0,e.fontNumbersSize=0,e.colorMajorTicks=e.colorPlate,e.colorNumbers=e.colorMinorTicks=""),e.borders=true,e.borderOuterWidth=2,e.borderMiddleWidth=1,e.borderInnerWidth=0,e.borderShadowWidth=0,e.animationTarget=this.ANIMATION_TARGET_NEEDLE,e.useMinPath=false),this.gaugeOptions=e;}static \u0275fac=function(i){return new(i||n)};static \u0275cmp=JD({type:n,selectors:[["widget-gauge-ng-radial"]],viewQuery:function(i,a){i&1&&eg(a.ngGauge,L,5)(a.gauge,L,5,Lr),i&2&&Kw(2);},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:1,vars:1,consts:[["radialGauge",""],["kipResizeObserver","",3,"options","value"],["kipResizeObserver","",3,"resizeChange","options","value"]],template:function(i,a){i&1&&_w(0,F,2,3,"radial-gauge",1),i&2&&Mw(a.shouldRenderGauge()?0:-1);},dependencies:[u,Gt,Lt],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%} radial-gauge{display:block;position:relative;width:100%;min-width:8px;height:100%;overflow:clip} radial-gauge>canvas{display:block;position:absolute;height:100%;width:100%;left:50%;top:50%;transform:translate(-50%,-50%);padding:0}"]})}return n})();export{ne as WidgetGaugeNgRadialComponent};
@@ -1 +1 @@
1
- import {d1 as Hj,w,du as p$1,aZ as F,$ as $j,v as vt,F as Fa,dn as ge,J as JD,cp as Uh,f as eg,K as Kw}from'./main-BAV5VDOD.js';var p=["canvasMainRef"],M=(()=>{class s{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p$1);canvas=w(F);static DEFAULT_CONFIG={displayName:"Static Label",color:"green",bgColor:"grey",noColor:false,noBgColor:true};canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;maxTextWidth=0;maxTextHeight=0;disposed=false;fgColor=vt("");bgColor=vt("");constructor(){Fa(()=>{let t=this.runtime.options(),e=this.theme();!t||!e||ge(()=>{this.fgColor.set(this.mapColor(t.color??"contrast",e)),this.bgColor.set(this.mapColor(t.bgColor??"grey",e)),this.draw();});}),Fa(()=>{let t=this.runtime.options()?.displayName;ge(()=>{t!==void 0&&this.draw();});});}mapColor(t,e){switch(t){case "contrast":return e.contrast;case "blue":return e.blue;case "green":return e.green;case "pink":return e.pink;case "orange":return e.orange;case "purple":return e.purple;case "grey":return e.grey;case "yellow":return e.yellow;default:return e.contrast}}ngAfterViewInit(){this.canvasElement=this.canvasRef().nativeElement,this.ctx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(t,e)=>{this.cssWidth=t,this.cssHeight=e,this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.draw();}draw(){if(!this.ctx||!this.canvasElement)return;let t=this.runtime.options();if(!t)return;this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),t.noBgColor||this.canvas.drawRectangle(this.ctx,0,0,this.canvasElement.width,this.canvasElement.height,this.bgColor());let e=t.displayName||"";this.canvas.drawText(this.ctx,e,Math.floor(this.cssWidth/2),Math.floor(this.cssHeight/2+10),this.cssWidth-40,this.cssHeight-40,"bold",this.fgColor());}ngOnDestroy(){this.disposed=true;try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(t){}}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=JD({type:s,selectors:[["widget-label"]],viewQuery:function(e,c){e&1&&eg(c.canvasRef,p,5),e&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:0,consts:[["canvasMainRef",""],[1,"label-canvas"]],template:function(e,c){e&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%;overflow:hidden}.label-canvas[_ngcontent-%COMP%]{width:100%!important;height:100%!important;display:block;border-radius:var(--mat-card-elevated-container-shape, var(--mat-sys-corner-medium))}"]})}return s})();export{M as WidgetLabelComponent};
1
+ import {d1 as Hj,w,du as p$1,aZ as R,$ as $j,v as vt,F as Fa,dn as ge,J as JD,cp as Uh,f as eg,K as Kw}from'./main-YKDNK5VZ.js';var p=["canvasMainRef"],M=(()=>{class s{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p$1);canvas=w(R);static DEFAULT_CONFIG={displayName:"Static Label",color:"green",bgColor:"grey",noColor:false,noBgColor:true};canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;maxTextWidth=0;maxTextHeight=0;disposed=false;fgColor=vt("");bgColor=vt("");constructor(){Fa(()=>{let t=this.runtime.options(),e=this.theme();!t||!e||ge(()=>{this.fgColor.set(this.mapColor(t.color??"contrast",e)),this.bgColor.set(this.mapColor(t.bgColor??"grey",e)),this.draw();});}),Fa(()=>{let t=this.runtime.options()?.displayName;ge(()=>{t!==void 0&&this.draw();});});}mapColor(t,e){switch(t){case "contrast":return e.contrast;case "blue":return e.blue;case "green":return e.green;case "pink":return e.pink;case "orange":return e.orange;case "purple":return e.purple;case "grey":return e.grey;case "yellow":return e.yellow;default:return e.contrast}}ngAfterViewInit(){this.canvasElement=this.canvasRef().nativeElement,this.ctx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(t,e)=>{this.cssWidth=t,this.cssHeight=e,this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.draw();}draw(){if(!this.ctx||!this.canvasElement)return;let t=this.runtime.options();if(!t)return;this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),t.noBgColor||this.canvas.drawRectangle(this.ctx,0,0,this.canvasElement.width,this.canvasElement.height,this.bgColor());let e=t.displayName||"";this.canvas.drawText(this.ctx,e,Math.floor(this.cssWidth/2),Math.floor(this.cssHeight/2+10),this.cssWidth-40,this.cssHeight-40,"bold",this.fgColor());}ngOnDestroy(){this.disposed=true;try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(t){}}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=JD({type:s,selectors:[["widget-label"]],viewQuery:function(e,c){e&1&&eg(c.canvasRef,p,5),e&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:0,consts:[["canvasMainRef",""],[1,"label-canvas"]],template:function(e,c){e&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%;overflow:hidden}.label-canvas[_ngcontent-%COMP%]{width:100%!important;height:100%!important;display:block;border-radius:var(--mat-card-elevated-container-shape, var(--mat-sys-corner-medium))}"]})}return s})();export{M as WidgetLabelComponent};