@mxtommy/kip 4.8.4 → 4.9.0-beta.1

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 (68) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/package.json +2 -2
  3. package/plugin/history-series.service.js +637 -0
  4. package/plugin/index.js +1322 -0
  5. package/plugin/kip-series-contract.js +31 -0
  6. package/plugin/openApi.json +855 -0
  7. package/plugin/sqlite-history-storage.service.js +1124 -0
  8. package/public/3rdpartylicenses.txt +78 -78
  9. package/public/assets/help-docs/ais-radar.md +261 -0
  10. package/public/assets/help-docs/dashboards.md +1 -1
  11. package/public/assets/help-docs/kiosk.md +4 -2
  12. package/public/assets/help-docs/menu.json +17 -2
  13. package/public/{chunk-CIGP2YJm.js → chunk-5jtM3b20.js} +1 -1
  14. package/public/{chunk-_zRMMvCu.js → chunk-B1H8b4W3.js} +1 -1
  15. package/public/{chunk-BJ-wyixK.js → chunk-BJObkbow.js} +1 -1
  16. package/public/{chunk-C6b8CVno.js → chunk-BLEfD_P7.js} +1 -1
  17. package/public/{chunk-BLEZOsfR.js → chunk-BO34LrGA.js} +1 -1
  18. package/public/{chunk-BeM64etA.js → chunk-BSNfaGK3.js} +1 -1
  19. package/public/{chunk-07zHjmg-.js → chunk-BbE36LU3.js} +1 -1
  20. package/public/{chunk-JhFkJS7i.js → chunk-BoY2UDvb.js} +1 -1
  21. package/public/{chunk-x7L6DXVK.js → chunk-BrjwTjz7.js} +1 -1
  22. package/public/{chunk-BFpzxIIT.js → chunk-BufDbUf3.js} +1 -1
  23. package/public/{chunk-C_OZJltF.js → chunk-C11zYqw7.js} +1 -1
  24. package/public/{chunk-CLs_NL1y.js → chunk-C8uxDv1M.js} +1 -1
  25. package/public/{chunk-DIl1k00y.js → chunk-CDG3g9Eq.js} +1 -1
  26. package/public/{chunk-q9NoPvcx.js → chunk-CEtt0kr-.js} +1 -1
  27. package/public/{chunk-BpcNrtxJ.js → chunk-CKnQ07BR.js} +1 -1
  28. package/public/{chunk-0z3nIRXw.js → chunk-COM48ir-.js} +1 -1
  29. package/public/{chunk-eQ1pa34Q.js → chunk-CSCVkGWE.js} +1 -1
  30. package/public/{chunk-BuvyF0y5.js → chunk-C_mCGLT_.js} +1 -1
  31. package/public/{chunk-BUguZ7cK.js → chunk-CnVELVOx.js} +1 -1
  32. package/public/{chunk-CLTHuhlN.js → chunk-Csxy6yVz.js} +1 -1
  33. package/public/{chunk-BZx964-p.js → chunk-CvG4thmf.js} +1 -1
  34. package/public/{chunk-CCfhzpE8.js → chunk-CxOyBrqL.js} +1 -1
  35. package/public/{chunk-otzyItXL.js → chunk-CzY2nk08.js} +1 -1
  36. package/public/{chunk-D-_-GUVr.js → chunk-CzquTNBp.js} +1 -1
  37. package/public/{chunk-ibauGmSP.js → chunk-D59G2Xua.js} +1 -1
  38. package/public/chunk-D8CQ-x45.js +1 -0
  39. package/public/{chunk-BTOTKeBo.js → chunk-DA2JBQHi.js} +1 -1
  40. package/public/chunk-DCdZRAXa.js +1 -0
  41. package/public/{chunk-BN7A4g6c.js → chunk-DES7U9G6.js} +1 -1
  42. package/public/{chunk-BIb-xYiS.js → chunk-DHj2hm9r.js} +1 -1
  43. package/public/{chunk-DPnbM-aB.js → chunk-DJVnrrxC.js} +1 -1
  44. package/public/{chunk-CxPx4NZv.js → chunk-DN6HP97P.js} +1 -1
  45. package/public/{chunk-COI6IBXH.js → chunk-DTznNQod.js} +1 -1
  46. package/public/{chunk-szQs8fiq.js → chunk-DZQzZeIV.js} +1 -1
  47. package/public/{chunk-DTN-sa1K.js → chunk-DakdT7bi.js} +1 -1
  48. package/public/{chunk-CHAFm_nM.js → chunk-DizMY7FW.js} +1 -1
  49. package/public/{chunk-OeQDZKFO.js → chunk-DjPkdMGz.js} +1 -1
  50. package/public/{chunk-BfiyH3nV.js → chunk-DlLiKS0n.js} +1 -1
  51. package/public/{chunk-CYYBxjrc.js → chunk-Dt2HCrSr.js} +1 -1
  52. package/public/{chunk-CyVRpGoJ.js → chunk-Duhmjpm9.js} +1 -1
  53. package/public/{chunk-B9nVBlGj.js → chunk-DulH4zwM.js} +1 -1
  54. package/public/{chunk-B09jfNia.js → chunk-DwAXe6Wn.js} +1 -1
  55. package/public/{chunk-CoCQ3DW2.js → chunk-DxD20B-E.js} +1 -1
  56. package/public/{chunk-DmkAKXR1.js → chunk-DzQ_fUpO.js} +1 -1
  57. package/public/{chunk-B0eE4udE.js → chunk-GyA81uXZ.js} +1 -1
  58. package/public/{chunk-Co2wVrD6.js → chunk-GzqVKhHm.js} +1 -1
  59. package/public/{chunk-BjINKQ03.js → chunk-MPbL1AwE.js} +1 -1
  60. package/public/{chunk-CQMVIDcp.js → chunk-Qlya07CF.js} +1 -1
  61. package/public/{chunk-CXvWM_vF.js → chunk-VshNFG3q.js} +1 -1
  62. package/public/{chunk-DUEKoZhd.js → chunk-YBp9CH_2.js} +1 -1
  63. package/public/{chunk-D1HYfaL_.js → chunk-_S08GvV8.js} +1 -1
  64. package/public/{chunk-B0D54iJs.js → chunk-dvm9QV-B.js} +1 -1
  65. package/public/{chunk-D2953Rfp.js → chunk-ipFM9wbJ.js} +1 -1
  66. package/public/index.html +1 -1
  67. package/public/{main-YKDNK5VZ.js → main-IINF7HD6.js} +473 -473
  68. package/public/chunk-Do8wqING.js +0 -1
@@ -1 +1 @@
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
+ import'./chunk-DA2JBQHi.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-IINF7HD6.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,D as Dt$1}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,dx as n$1,cw as z,cv as G,F as Fa,dn as ge$1,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}from'./main-YKDNK5VZ.js';import {c}from'./chunk-BIb-xYiS.js';var Z=["linearGauge"];function Q(s,H){if(s&1){let t=Fw();Pi(0,"linear-gauge",2,0),Qh("resizeChange",function(a){ud(t);let e=qw();return dd(e.onResized(a))}),ul();}if(s&2){let t=qw();Bh("options",t.gaugeOptions)("value",t.displayValue()),Hh("value-text",t.textValue());}}var ge=(()=>{class s{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:"ngLinear",subType:"vertical",highlightsWidth:5,enableTicks:true,enableNeedle:false},numInt:1,numDecimal:0,color:"contrast",enableTimeout:false,dataTimeout:5,ignoreZones:false};ngGauge=$j("linearGauge");gauge=$j("linearGauge",{read:Lr});textValue=vt("--");value=vt(void 0);displayValue=Dt(()=>this.value()??0);shouldRenderGauge=Dt(()=>this.value()!==void 0);gaugeOptions={};viewReady=vt(false);gaugeBootstrapped=vt(false);animationEnabled=Dt(()=>this.gaugeBootstrapped());currentState=vt(n$1.Normal);normalizedConfig=Dt(()=>this.runtime.options()??s.DEFAULT_CONFIG);gaugePathConfig=Dt(()=>this.normalizedConfig().paths?.gaugePath);normalizedScale=Dt(()=>{let t=this.normalizedConfig().displayScale??s.DEFAULT_CONFIG.displayScale;return z(G({},t),{lower:t.lower??0,upper:t.upper??100})});adjustedScale=Dt(()=>{let t=this.normalizedConfig(),i=this.normalizedScale();return t.gauge?.enableTicks?p$1(i.lower,i.upper):{min:i.lower,max:i.upper,majorTicks:[]}});highlights=Dt(()=>{let t=this.metadata.zones(),i=this.normalizedConfig(),a=this.theme(),e=this.gaugePathConfig();return t?.length?a?i.ignoreZones?[]:e?k(t,a,e.convertUnitTo??"",this.unitsService,this.adjustedScale().min,this.adjustedScale().max):[]:[]:[]});displayName=Dt(()=>this.normalizedConfig().displayName||"Gauge Label");constructor(){Fa(()=>{this.normalizedConfig();let i=this.theme(),a=this.gaugePathConfig(),e=this.normalizedScale();!i||!a?.path||ge$1(()=>this.streams.observe("gaugePath",o=>{let n=o?.data?.value??null;if(n==null)this.value.set(e.lower),this.textValue.set("--");else {let r=Math.min(Math.max(n,e.lower),e.upper);this.value.set(r),this.textValue()==="--"&&this.textValue.set("");}o.state!==this.currentState()&&this.currentState.set(o.state);}));}),Fa(()=>{this.normalizedConfig().ignoreZones||ge$1(()=>this.metadata.observe("gaugePath"));}),Fa(()=>{let t=this.highlights();this.viewReady()&&ge$1(()=>{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$1(()=>{if(this.buildGaugeOptions(t,i,a),this.viewReady())try{this.ngGauge()?.update(this.gaugeOptions),this.applyInitialSize();}catch(e){}});}),Fa(()=>{let t=this.ngGauge();!t||this.gaugeBootstrapped()||ge$1(()=>{try{requestAnimationFrame(()=>{this.gaugeBootstrapped.set(!0);try{t.update({animation:!0,animatedValue:!0});}catch(i){}});}catch(i){}});}),Fa(()=>{let t=this.currentState();this.viewReady()&&ge$1(()=>{let i=this.normalizedConfig(),a=this.theme();if(!a||i.ignoreZones)return;let e={},o=i.gauge?.enableNeedle,n=c(i.color??"contrast",a);switch(t){case n$1.Alarm:o?(e.colorNeedle=a.zoneAlarm,e.colorValueText=a.zoneAlarm):(e.colorBarProgress=a.zoneAlarm,e.colorValueText=a.zoneAlarm);break;case n$1.Warn:o?(e.colorNeedle=a.zoneWarn,e.colorValueText=a.zoneWarn):(e.colorBarProgress=a.zoneWarn,e.colorValueText=a.zoneWarn);break;case n$1.Alert:o?(e.colorNeedle=a.zoneAlert,e.colorValueText=a.zoneAlert):(e.colorBarProgress=a.zoneAlert,e.colorValueText=a.zoneAlert);break;default:o?(e.colorNeedle=n.color,e.colorValueText=n.color):(e.colorBarProgress=n.color,e.colorValueText=n.color);}try{this.ngGauge()?.update(e);}catch(r){}});});}buildGaugeOptions(t,i,a){let e=this.gaugeOptions={},o=t.gauge?.subType==="vertical",n=t.gauge?.enableNeedle,r=t.gauge?.enableTicks,m=this.gaugePathConfig();e.minValue=a.min,e.maxValue=a.max,e.valueInt=t.numInt??1,e.valueDec=t.numDecimal??2,e.title=this.displayName(),e.fontTitleSize=40,e.fontTitle="Roboto",e.fontTitleWeight="bold",e.barLength=o?80:90,e.barWidth=r?n?0:30:60,e.barProgress=true,e.barBeginCircle=0,e.barStrokeWidth=0,e.barShadow=0,e.needle=!!n,e.needleType=n?"arrow":"line",e.needleStart=n?o?200:155:-45,e.needleEnd=n?o?175:180:55,e.needleShadow=true,e.needleSide="both",e.units=m?.convertUnitTo??"",e.fontUnits="Roboto",e.fontUnitsWeight="normal",e.borders=false,e.borderOuterWidth=0,e.borderMiddleWidth=0,e.borderInnerWidth=0,e.borderShadowWidth=0,e.borderRadius=0,e.valueBox=true,e.valueBoxWidth=35,e.valueBoxStroke=0,e.valueBoxBorderRadius=10,e.colorValueBoxRect="",e.colorValueBoxRectEnd="",e.colorValueBoxShadow="",e.fontValueSize=50,e.fontValue="Roboto",e.fontValueWeight="bold",e.valueTextShadow=false,e.fontNumbers="Roboto",e.fontNumbersWeight="normal",e.fontUnitsSize=o?40:35,e.colorTitle=c("contrast",i).dim,e.colorUnits=c("contrast",i).dim,e.colorValueBoxBackground=i.background;let u=c(t.color??"contrast",i);e.colorValueText=u.color,n?(e.colorNeedle=u.color,e.colorNeedleEnd=u.color,e.needleWidth=45,e.colorNeedleShadowUp=u.color,e.colorNeedleShadowDown=u.color):(e.colorBarProgress=u.color,e.colorBarProgressEnd="",e.needleWidth=0),e.colorPlate=i.cardColor,e.colorBar=i.background,e.colorBarEnd="",e.colorBarStroke="0",e.colorMajorTicks=c("contrast",i).dim,e.colorMinorTicks=c("contrast",i).dim,e.colorNumbers=c("contrast",i).dim,e.majorTicks=r?a.majorTicks:[],e.majorTicksInt=t.numInt??1,e.majorTicksDec=t.numDecimal??2,e.strokeTicks=!!r,e.minorTicks=r?2:0,e.ticksWidthMinor=r?6:0,e.numberSide=n?"right":"left",e.fontNumbersSize=r?o?22:30:0,e.numbersMargin=o?n?-7:-3:n?-33:-5,e.ticksWidth=r?n&&o?15:10:0,e.ticksPadding=r?o?n?0:5:n?9:8:0,e.tickSide="left",e.animation=this.animationEnabled(),e.animationRule="linear",e.animatedValue=this.animationEnabled(),e.animateOnInit=false,e.animationDuration=(m?.sampleTime??500)-25,e.highlights=[],e.highlightsWidth=t.gauge?.highlightsWidth;let N=this.highlights();N.length&&(e.highlights=JSON.stringify(N));}ngAfterViewInit(){this.viewReady.set(true),this.applyInitialSize();try{this.ngGauge()?.update(this.gaugeOptions);}catch(t){}}applyInitialSize(){let t=this.gauge()?.nativeElement;if(!t)return;let i=t.getBoundingClientRect(),a=.3,e,o;this.normalizedConfig().gauge?.subType==="vertical"?(e=i.height,o=i.height*a):(o=i.width,e=i.width*a);let m={height:e,width:o};try{this.ngGauge()?.update(m);}catch(u){}}onResized(t){let i=this.normalizedConfig(),a=.3,e=i.gauge?.subType==="vertical",o=0,n=0;e?(n=t.contentRect.height,o=n*a,o>t.contentRect.width&&(o=t.contentRect.width,n=o/a)):(o=t.contentRect.width,n=o*a,n>t.contentRect.height&&(n=t.contentRect.height,o=n/a));let r={width:o,height:n-10};try{this.ngGauge()?.update(r);}catch(m){}}static \u0275fac=function(i){return new(i||s)};static \u0275cmp=JD({type:s,selectors:[["widget-gauge-ng-linear"]],viewQuery:function(i,a){i&1&&eg(a.ngGauge,Z,5)(a.gauge,Z,5,Lr),i&2&&Kw(2);},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:1,vars:1,consts:[["linearGauge",""],["kipResizeObserver","",1,"linearGauge",3,"options","value"],["kipResizeObserver","",1,"linearGauge",3,"resizeChange","options","value"]],template:function(i,a){i&1&&_w(0,Q,2,3,"linear-gauge",1),i&2&&Mw(a.shouldRenderGauge()?0:-1);},dependencies:[u,Gt,Dt$1],styles:["[_nghost-%COMP%]{width:100%;height:100%;display:block} linear-gauge{display:block;position:relative;width:100%;min-width:8px;height:100%;overflow:clip} linear-gauge>canvas{display:block;position:absolute;height:100%;width:100%;left:50%;top:50%;transform:translate(-50%,-50%);margin-top:5px}"]})}return s})();export{ge as WidgetGaugeNgLinearComponent};
1
+ import {p as p$1}from'./chunk-CaD3zVfK.js';import {G as Gt,D as Dt$1}from'./chunk-CEtt0kr-.js';import {u}from'./chunk-CxOyBrqL.js';import {k}from'./chunk-GyA81uXZ.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,dx as n$1,cw as z,cv as G,F as Fa,dn as ge$1,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}from'./main-IINF7HD6.js';import {c}from'./chunk-DHj2hm9r.js';var Z=["linearGauge"];function Q(s,H){if(s&1){let t=Fw();Pi(0,"linear-gauge",2,0),Qh("resizeChange",function(a){ud(t);let e=qw();return dd(e.onResized(a))}),ul();}if(s&2){let t=qw();Bh("options",t.gaugeOptions)("value",t.displayValue()),Hh("value-text",t.textValue());}}var ge=(()=>{class s{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:"ngLinear",subType:"vertical",highlightsWidth:5,enableTicks:true,enableNeedle:false},numInt:1,numDecimal:0,color:"contrast",enableTimeout:false,dataTimeout:5,ignoreZones:false};ngGauge=$j("linearGauge");gauge=$j("linearGauge",{read:Lr});textValue=vt("--");value=vt(void 0);displayValue=Dt(()=>this.value()??0);shouldRenderGauge=Dt(()=>this.value()!==void 0);gaugeOptions={};viewReady=vt(false);gaugeBootstrapped=vt(false);animationEnabled=Dt(()=>this.gaugeBootstrapped());currentState=vt(n$1.Normal);normalizedConfig=Dt(()=>this.runtime.options()??s.DEFAULT_CONFIG);gaugePathConfig=Dt(()=>this.normalizedConfig().paths?.gaugePath);normalizedScale=Dt(()=>{let t=this.normalizedConfig().displayScale??s.DEFAULT_CONFIG.displayScale;return z(G({},t),{lower:t.lower??0,upper:t.upper??100})});adjustedScale=Dt(()=>{let t=this.normalizedConfig(),i=this.normalizedScale();return t.gauge?.enableTicks?p$1(i.lower,i.upper):{min:i.lower,max:i.upper,majorTicks:[]}});highlights=Dt(()=>{let t=this.metadata.zones(),i=this.normalizedConfig(),a=this.theme(),e=this.gaugePathConfig();return t?.length?a?i.ignoreZones?[]:e?k(t,a,e.convertUnitTo??"",this.unitsService,this.adjustedScale().min,this.adjustedScale().max):[]:[]:[]});displayName=Dt(()=>this.normalizedConfig().displayName||"Gauge Label");constructor(){Fa(()=>{this.normalizedConfig();let i=this.theme(),a=this.gaugePathConfig(),e=this.normalizedScale();!i||!a?.path||ge$1(()=>this.streams.observe("gaugePath",o=>{let n=o?.data?.value??null;if(n==null)this.value.set(e.lower),this.textValue.set("--");else {let r=Math.min(Math.max(n,e.lower),e.upper);this.value.set(r),this.textValue()==="--"&&this.textValue.set("");}o.state!==this.currentState()&&this.currentState.set(o.state);}));}),Fa(()=>{this.normalizedConfig().ignoreZones||ge$1(()=>this.metadata.observe("gaugePath"));}),Fa(()=>{let t=this.highlights();this.viewReady()&&ge$1(()=>{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$1(()=>{if(this.buildGaugeOptions(t,i,a),this.viewReady())try{this.ngGauge()?.update(this.gaugeOptions),this.applyInitialSize();}catch(e){}});}),Fa(()=>{let t=this.ngGauge();!t||this.gaugeBootstrapped()||ge$1(()=>{try{requestAnimationFrame(()=>{this.gaugeBootstrapped.set(!0);try{t.update({animation:!0,animatedValue:!0});}catch(i){}});}catch(i){}});}),Fa(()=>{let t=this.currentState();this.viewReady()&&ge$1(()=>{let i=this.normalizedConfig(),a=this.theme();if(!a||i.ignoreZones)return;let e={},o=i.gauge?.enableNeedle,n=c(i.color??"contrast",a);switch(t){case n$1.Alarm:o?(e.colorNeedle=a.zoneAlarm,e.colorValueText=a.zoneAlarm):(e.colorBarProgress=a.zoneAlarm,e.colorValueText=a.zoneAlarm);break;case n$1.Warn:o?(e.colorNeedle=a.zoneWarn,e.colorValueText=a.zoneWarn):(e.colorBarProgress=a.zoneWarn,e.colorValueText=a.zoneWarn);break;case n$1.Alert:o?(e.colorNeedle=a.zoneAlert,e.colorValueText=a.zoneAlert):(e.colorBarProgress=a.zoneAlert,e.colorValueText=a.zoneAlert);break;default:o?(e.colorNeedle=n.color,e.colorValueText=n.color):(e.colorBarProgress=n.color,e.colorValueText=n.color);}try{this.ngGauge()?.update(e);}catch(r){}});});}buildGaugeOptions(t,i,a){let e=this.gaugeOptions={},o=t.gauge?.subType==="vertical",n=t.gauge?.enableNeedle,r=t.gauge?.enableTicks,m=this.gaugePathConfig();e.minValue=a.min,e.maxValue=a.max,e.valueInt=t.numInt??1,e.valueDec=t.numDecimal??2,e.title=this.displayName(),e.fontTitleSize=40,e.fontTitle="Roboto",e.fontTitleWeight="bold",e.barLength=o?80:90,e.barWidth=r?n?0:30:60,e.barProgress=true,e.barBeginCircle=0,e.barStrokeWidth=0,e.barShadow=0,e.needle=!!n,e.needleType=n?"arrow":"line",e.needleStart=n?o?200:155:-45,e.needleEnd=n?o?175:180:55,e.needleShadow=true,e.needleSide="both",e.units=m?.convertUnitTo??"",e.fontUnits="Roboto",e.fontUnitsWeight="normal",e.borders=false,e.borderOuterWidth=0,e.borderMiddleWidth=0,e.borderInnerWidth=0,e.borderShadowWidth=0,e.borderRadius=0,e.valueBox=true,e.valueBoxWidth=35,e.valueBoxStroke=0,e.valueBoxBorderRadius=10,e.colorValueBoxRect="",e.colorValueBoxRectEnd="",e.colorValueBoxShadow="",e.fontValueSize=50,e.fontValue="Roboto",e.fontValueWeight="bold",e.valueTextShadow=false,e.fontNumbers="Roboto",e.fontNumbersWeight="normal",e.fontUnitsSize=o?40:35,e.colorTitle=c("contrast",i).dim,e.colorUnits=c("contrast",i).dim,e.colorValueBoxBackground=i.background;let u=c(t.color??"contrast",i);e.colorValueText=u.color,n?(e.colorNeedle=u.color,e.colorNeedleEnd=u.color,e.needleWidth=45,e.colorNeedleShadowUp=u.color,e.colorNeedleShadowDown=u.color):(e.colorBarProgress=u.color,e.colorBarProgressEnd="",e.needleWidth=0),e.colorPlate=i.cardColor,e.colorBar=i.background,e.colorBarEnd="",e.colorBarStroke="0",e.colorMajorTicks=c("contrast",i).dim,e.colorMinorTicks=c("contrast",i).dim,e.colorNumbers=c("contrast",i).dim,e.majorTicks=r?a.majorTicks:[],e.majorTicksInt=t.numInt??1,e.majorTicksDec=t.numDecimal??2,e.strokeTicks=!!r,e.minorTicks=r?2:0,e.ticksWidthMinor=r?6:0,e.numberSide=n?"right":"left",e.fontNumbersSize=r?o?22:30:0,e.numbersMargin=o?n?-7:-3:n?-33:-5,e.ticksWidth=r?n&&o?15:10:0,e.ticksPadding=r?o?n?0:5:n?9:8:0,e.tickSide="left",e.animation=this.animationEnabled(),e.animationRule="linear",e.animatedValue=this.animationEnabled(),e.animateOnInit=false,e.animationDuration=(m?.sampleTime??500)-25,e.highlights=[],e.highlightsWidth=t.gauge?.highlightsWidth;let N=this.highlights();N.length&&(e.highlights=JSON.stringify(N));}ngAfterViewInit(){this.viewReady.set(true),this.applyInitialSize();try{this.ngGauge()?.update(this.gaugeOptions);}catch(t){}}applyInitialSize(){let t=this.gauge()?.nativeElement;if(!t)return;let i=t.getBoundingClientRect(),a=.3,e,o;this.normalizedConfig().gauge?.subType==="vertical"?(e=i.height,o=i.height*a):(o=i.width,e=i.width*a);let m={height:e,width:o};try{this.ngGauge()?.update(m);}catch(u){}}onResized(t){let i=this.normalizedConfig(),a=.3,e=i.gauge?.subType==="vertical",o=0,n=0;e?(n=t.contentRect.height,o=n*a,o>t.contentRect.width&&(o=t.contentRect.width,n=o/a)):(o=t.contentRect.width,n=o*a,n>t.contentRect.height&&(n=t.contentRect.height,o=n/a));let r={width:o,height:n-10};try{this.ngGauge()?.update(r);}catch(m){}}static \u0275fac=function(i){return new(i||s)};static \u0275cmp=JD({type:s,selectors:[["widget-gauge-ng-linear"]],viewQuery:function(i,a){i&1&&eg(a.ngGauge,Z,5)(a.gauge,Z,5,Lr),i&2&&Kw(2);},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:1,vars:1,consts:[["linearGauge",""],["kipResizeObserver","",1,"linearGauge",3,"options","value"],["kipResizeObserver","",1,"linearGauge",3,"resizeChange","options","value"]],template:function(i,a){i&1&&_w(0,Q,2,3,"linear-gauge",1),i&2&&Mw(a.shouldRenderGauge()?0:-1);},dependencies:[u,Gt,Dt$1],styles:["[_nghost-%COMP%]{width:100%;height:100%;display:block} linear-gauge{display:block;position:relative;width:100%;min-width:8px;height:100%;overflow:clip} linear-gauge>canvas{display:block;position:absolute;height:100%;width:100%;left:50%;top:50%;transform:translate(-50%,-50%);margin-top:5px}"]})}return s})();export{ge as WidgetGaugeNgLinearComponent};
@@ -1 +1 @@
1
- import {dx as n$1}from'./main-YKDNK5VZ.js';function k(g,s,l,m,f,r,b=false){let a=[],c=[...g].sort((o,n)=>(o.lower??-1/0)-(n.lower??-1/0));for(let o of c){let n=f,t=r,i;switch(o.state){case n$1.Emergency:i=s.zoneEmergency;break;case n$1.Alarm:i=s.zoneAlarm;break;case n$1.Warn:i=s.zoneWarn;break;case n$1.Alert:i=s.zoneAlert;break;case n$1.Nominal:i=s.zoneNominal;break;default:i="rgba(0,0,0,0)";}if(o.lower==null?n=f:n=m.convertToUnit(l,o.lower)??f,o.upper==null?t=r:t=m.convertToUnit(l,o.upper)??r,!(!Number.isFinite(n)||!Number.isFinite(t))&&!(t<f||n>r)){if(n=Math.max(n,f),t>r){t=r,a.push({from:n,to:t,color:i});break}a.push({from:n,to:t,color:i});}}return b&&(a=a.map(o=>({from:r-o.to,to:r-o.from,color:o.color}))),a}export{k};
1
+ import {dx as n$1}from'./main-IINF7HD6.js';function k(g,s,l,m,f,r,b=false){let a=[],c=[...g].sort((o,n)=>(o.lower??-1/0)-(n.lower??-1/0));for(let o of c){let n=f,t=r,i;switch(o.state){case n$1.Emergency:i=s.zoneEmergency;break;case n$1.Alarm:i=s.zoneAlarm;break;case n$1.Warn:i=s.zoneWarn;break;case n$1.Alert:i=s.zoneAlert;break;case n$1.Nominal:i=s.zoneNominal;break;default:i="rgba(0,0,0,0)";}if(o.lower==null?n=f:n=m.convertToUnit(l,o.lower)??f,o.upper==null?t=r:t=m.convertToUnit(l,o.upper)??r,!(!Number.isFinite(n)||!Number.isFinite(t))&&!(t<f||n>r)){if(n=Math.max(n,f),t>r){t=r,a.push({from:n,to:t,color:i});break}a.push({from:n,to:t,color:i});}}return b&&(a=a.map(o=>({from:r-o.to,to:r-o.from,color:o.color}))),a}export{k};
@@ -1 +1 @@
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
+ import {a as a$1}from'./chunk-D59G2Xua.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-IINF7HD6.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 {d1 as Hj,w,du as p,dv as rt,aZ as R,D as Dt,$ 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';import {c}from'./chunk-BIb-xYiS.js';var E=["canvasMainRef"],O=(()=>{class s{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={displayName:"Gauge Label",filterSelfPaths:true,paths:{stringPath:{description:"String Data",path:null,source:null,pathType:"string",isPathConfigurable:true,sampleTime:500}},color:"contrast",enableTimeout:false,dataTimeout:5};runtime=w(p);stream=w(rt);canvas=w(R);normalizedConfig=Dt(()=>this.runtime.options()??s.DEFAULT_CONFIG);stringPathConfig=Dt(()=>this.normalizedConfig().paths?.stringPath);canvasMainRef=$j.required("canvasMainRef");canvasElement;canvasCtx=null;titleBitmap=null;titleBitmapText=null;cssWidth=0;cssHeight=0;dataValue=null;labelColor=vt("");valueColor="";isDestroyed=false;streamRegistered=false;constructor(){Fa(()=>{let t=this.theme();ge(()=>{t&&(this.setColors(),this.drawWidget());});}),Fa(()=>{this.normalizedConfig();this.isDestroyed||!this.canvasCtx||ge(()=>{this.setColors(),this.startWidget(),this.drawWidget();});});}ngOnInit(){this.setColors();}ngAfterViewInit(){this.canvasElement=this.canvasMainRef().nativeElement,this.canvasCtx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(t,e)=>{this.cssWidth=t,this.cssHeight=e,this.drawWidget();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),!this.isDestroyed&&this.startWidget();}startWidget(){this.dataValue=null,this.streamRegistered||(this.stringPathConfig()?.path?(this.stream.observe("stringPath",e=>{this.dataValue=e.data.value,this.drawWidget();}),this.streamRegistered=true):this.drawWidget());}setColors(){let e=this.normalizedConfig().color??"contrast";this.labelColor.set(c(e,this.theme()).dim),this.valueColor=c(e,this.theme()).color;}ngOnDestroy(){this.isDestroyed=true;try{this.canvas.unregisterCanvas(this.canvasElement);}catch(t){}}drawWidget(){if(!this.canvasCtx)return;let t=Math.floor(this.cssHeight*.1),i=this.normalizedConfig().displayName??"Gauge Label",y=i+"|"+this.labelColor();(!this.titleBitmap||this.titleBitmap.width!==this.canvasElement.width||this.titleBitmap.height!==this.canvasElement.height||this.titleBitmapText!==y)&&(this.titleBitmap=this.canvas.createTitleBitmap(i,this.labelColor(),"normal",this.cssWidth,this.cssHeight),this.titleBitmapText=i+"|"+this.labelColor()),this.canvas.clearCanvas(this.canvasCtx,this.cssWidth,this.cssHeight),this.titleBitmap&&this.titleBitmap.width>0&&this.titleBitmap.height>0&&this.canvasCtx.drawImage(this.titleBitmap,0,0,this.cssWidth,this.cssHeight);let b=this.dataValue===null?"--":this.dataValue,h=this.canvas.EDGE_BUFFER||10,d=Math.max(0,this.cssHeight-t-2*h),W=Math.max(0,Math.floor(this.cssWidth-2*h)),w=Math.max(0,Math.floor(d)),D=Math.floor(this.cssWidth/2),B=Math.floor(t+h+d/2);this.canvas.drawText(this.canvasCtx,b,D,B,W,w,"bold",this.valueColor,"center","middle");}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=JD({type:s,selectors:[["widget-text"]],viewQuery:function(e,i){e&1&&eg(i.canvasMainRef,E,5),e&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:0,consts:[["canvasMainRef",""],[1,"text-canvas"]],template:function(e,i){e&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%;overflow:hidden}.text-canvas[_ngcontent-%COMP%]{display:block;width:100%!important;height:100%!important;min-height:1px}"]})}return s})();export{O as WidgetTextComponent};
1
+ import {d1 as Hj,w,du as p,dv as rt,aZ as R,D as Dt,$ 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-IINF7HD6.js';import {c}from'./chunk-DHj2hm9r.js';var E=["canvasMainRef"],O=(()=>{class s{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={displayName:"Gauge Label",filterSelfPaths:true,paths:{stringPath:{description:"String Data",path:null,source:null,pathType:"string",isPathConfigurable:true,sampleTime:500}},color:"contrast",enableTimeout:false,dataTimeout:5};runtime=w(p);stream=w(rt);canvas=w(R);normalizedConfig=Dt(()=>this.runtime.options()??s.DEFAULT_CONFIG);stringPathConfig=Dt(()=>this.normalizedConfig().paths?.stringPath);canvasMainRef=$j.required("canvasMainRef");canvasElement;canvasCtx=null;titleBitmap=null;titleBitmapText=null;cssWidth=0;cssHeight=0;dataValue=null;labelColor=vt("");valueColor="";isDestroyed=false;streamRegistered=false;constructor(){Fa(()=>{let t=this.theme();ge(()=>{t&&(this.setColors(),this.drawWidget());});}),Fa(()=>{this.normalizedConfig();this.isDestroyed||!this.canvasCtx||ge(()=>{this.setColors(),this.startWidget(),this.drawWidget();});});}ngOnInit(){this.setColors();}ngAfterViewInit(){this.canvasElement=this.canvasMainRef().nativeElement,this.canvasCtx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(t,e)=>{this.cssWidth=t,this.cssHeight=e,this.drawWidget();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),!this.isDestroyed&&this.startWidget();}startWidget(){this.dataValue=null,this.streamRegistered||(this.stringPathConfig()?.path?(this.stream.observe("stringPath",e=>{this.dataValue=e.data.value,this.drawWidget();}),this.streamRegistered=true):this.drawWidget());}setColors(){let e=this.normalizedConfig().color??"contrast";this.labelColor.set(c(e,this.theme()).dim),this.valueColor=c(e,this.theme()).color;}ngOnDestroy(){this.isDestroyed=true;try{this.canvas.unregisterCanvas(this.canvasElement);}catch(t){}}drawWidget(){if(!this.canvasCtx)return;let t=Math.floor(this.cssHeight*.1),i=this.normalizedConfig().displayName??"Gauge Label",y=i+"|"+this.labelColor();(!this.titleBitmap||this.titleBitmap.width!==this.canvasElement.width||this.titleBitmap.height!==this.canvasElement.height||this.titleBitmapText!==y)&&(this.titleBitmap=this.canvas.createTitleBitmap(i,this.labelColor(),"normal",this.cssWidth,this.cssHeight),this.titleBitmapText=i+"|"+this.labelColor()),this.canvas.clearCanvas(this.canvasCtx,this.cssWidth,this.cssHeight),this.titleBitmap&&this.titleBitmap.width>0&&this.titleBitmap.height>0&&this.canvasCtx.drawImage(this.titleBitmap,0,0,this.cssWidth,this.cssHeight);let b=this.dataValue===null?"--":this.dataValue,h=this.canvas.EDGE_BUFFER||10,d=Math.max(0,this.cssHeight-t-2*h),W=Math.max(0,Math.floor(this.cssWidth-2*h)),w=Math.max(0,Math.floor(d)),D=Math.floor(this.cssWidth/2),B=Math.floor(t+h+d/2);this.canvas.drawText(this.canvasCtx,b,D,B,W,w,"bold",this.valueColor,"center","middle");}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=JD({type:s,selectors:[["widget-text"]],viewQuery:function(e,i){e&1&&eg(i.canvasMainRef,E,5),e&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:0,consts:[["canvasMainRef",""],[1,"text-canvas"]],template:function(e,i){e&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%;overflow:hidden}.text-canvas[_ngcontent-%COMP%]{display:block;width:100%!important;height:100%!important;min-height:1px}"]})}return s})();export{O as WidgetTextComponent};
@@ -1,2 +1,2 @@
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})();
1
+ import {f}from'./chunk-H9_eqTYx.js';import {u}from'./chunk-CxOyBrqL.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-IINF7HD6.js';import {c}from'./chunk-DHj2hm9r.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-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
+ import {C,e as e$1}from'./chunk-DJVnrrxC.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-IINF7HD6.js';import {c,e}from'./chunk-DHj2hm9r.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,2 +1,2 @@
1
- import {d1 as Hj,w,du as p,dY as O,a as G,W as Wp,v as vt,D as Dt,F as Fa,dn as ge,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,cp as Uh,cV as Td,T as TT,cj as fl,an as Hh,d as ig,bp as gl,s as sg,c as $h,g as qw,dX as xT,B as Bh,cS as pl,cT as hl,dx as n$1}from'./main-YKDNK5VZ.js';import {u}from'./chunk-CCfhzpE8.js';import {c}from'./chunk-BIb-xYiS.js';var ne=(()=>{class o{data=Hj(null,{alias:"controlData"});theme=Hj(null);dimensions=Hj.required();toggleClick=Vj();ctrlLabelColor=vt("");ctrlStateColor=vt("");messageTxtColor=vt("");shouldEmergencyBlink=Dt(()=>(this.data()?.notificationState??"").toLowerCase()==="emergency");shouldAlarmBlink=Dt(()=>(this.data()?.notificationState??"").toLowerCase()==="alarm");constructor(){Fa(()=>{let t=this.data(),e=this.theme();!t||!e||ge(()=>{switch(t.notificationState){case n$1.Emergency:this.ctrlStateColor.set(e.zoneEmergency),this.messageTxtColor.set(e.background);break;case n$1.Alarm:this.ctrlStateColor.set(e.zoneAlarm),this.messageTxtColor.set(e.background);break;case n$1.Warn:this.ctrlStateColor.set(e.zoneWarn),this.messageTxtColor.set(e.background);break;case n$1.Alert:this.ctrlStateColor.set(e.zoneAlert),this.messageTxtColor.set(e.background);break;default:this.ctrlStateColor.set(e.background),this.messageTxtColor.set(c(t.color,e).dim);break}this.ctrlLabelColor.set(c(t.color,e).color);});});}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=JD({type:o,selectors:[["app-svg-zone-states"]],inputs:{data:[1,"controlData","data"],theme:[1,"theme"],dimensions:[1,"dimensions"]},outputs:{toggleClick:"toggleClick"},decls:12,vars:14,consts:[["viewBox","0 0 180 75","version","1.1","id","svg9","xmlns","http://www.w3.org/2000/svg",0,"xmlns","svg","http://www.w3.org/2000/svg"],["id","defs9"],["id","zoneStateCtrl"],["id","touchRect","width","180","height","75","x","0","y","0","pointer-events","all",2,"display","inline","opacity","1","fill","transparent","fill-opacity","1","stroke","none","stroke-width","0","stroke-dasharray","none","stroke-opacity","0"],["x","0","y","0","width","180","height","20"],["xmlns","http://www.w3.org/1999/xhtml",2,"width","180px","height","20px","display","flex","align-items","center","justify-content","center","font-weight","bold","font-size","14px","line-height","1.1","text-align","center","overflow","hidden","word-break","break-word","white-space","normal"],["id","outlineRect","x","6","y","22","width","168","height","43","rx","3.5","fill","none",2,"display","inline","opacity","1","mix-blend-mode","normals","stroke-width","1","stroke-dasharray","none","stroke-opacity","0.65"],["id","innerRect","x","7","y","23","width","166","height","41","rx","3.5",2,"display","inline","opacity","1","mix-blend-mode","normal","stroke","none","stroke-width","0"],["x","7","y","23","width","166","height","41"],["xmlns","http://www.w3.org/1999/xhtml",2,"width","166px","height","41px","display","flex","align-items","center","justify-content","center","font-weight","regular","font-size","12px","line-height","1.1","text-align","center","overflow","hidden","word-break","break-word","white-space","normal","padding","2px"]],template:function(e,i){e&1&&(wd(),dl(0,"svg",0),Uh(1,"defs",1),dl(2,"g",2),Uh(3,"rect",3),dl(4,"foreignObject",4),Td(),dl(5,"div",5),TT(6),fl()(),wd(),Uh(7,"rect",6)(8,"rect",7),dl(9,"foreignObject",8),Td(),dl(10,"div",9),TT(11),fl()()()()),e&2&&(Hh("height",i.dimensions().height)("width",i.dimensions().width),EE(5),ig("color",i.ctrlLabelColor()),EE(),gl(" ",i.data()?.ctrlLabel," "),EE(),Hh("stroke",i.ctrlLabelColor()),EE(),sg("emergency-blink-fill",i.shouldEmergencyBlink())("alarm-blink-fill",i.shouldAlarmBlink()),Hh("fill",i.ctrlStateColor()),EE(2),ig("color",i.messageTxtColor()),EE(),gl(" ",i.data()?.notificationMessage," "));},styles:["@keyframes _ngcontent-%COMP%_AlarmBlinkFill{0%,49%{opacity:1}50%,to{opacity:.6}}.alarm-blink-fill[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_AlarmBlinkFill 1s step-end infinite}@keyframes _ngcontent-%COMP%_EmergencyBlinkFill{0%,49%{opacity:1}50%,to{opacity:.1}}.emergency-blink-fill[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_EmergencyBlinkFill .3s step-end infinite}"]})}return o})();function se(o,f){if(o&1&&$h(0,"widget-title",1),o&2){let t=qw(),e=xT(0);Bh("text",(e==null?null:e.displayName)??"")("color",t.labelColor());}}function re(o,f){if(o&1&&$h(0,"app-svg-zone-states",4),o&2){let t=qw().$implicit,e=qw();Bh("controlData",t)("theme",e.theme())("dimensions",e.ctrlDimensions());}}function le(o,f){if(o&1&&(pl(0),_w(1,re,1,3,"app-svg-zone-states",4),hl()),o&2){let e=f.$implicit;EE(),Mw((e.type)==="4"?1:-1);}}function ce(o,f){o&1&&$h(0,"div",3);}var _e=(()=>{class o{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={displayName:"Zones State Panel Label",showLabel:true,filterSelfPaths:true,paths:[],enableTimeout:false,dataTimeout:5,color:"contrast",putEnable:false,zonesOnlyPaths:true,putMomentary:false,multiChildCtrls:[]};runtime=w(p,{optional:true});notificationsService=w(O);dashboard=w(G);notifications=Wp(this.notificationsService.observeNotifications());zonesControls=vt([]);labelColor=vt("");noTitleClass=Dt(()=>this.runtime?.options()?.showLabel===false?"widgets-container-no-title":"widgets-container");pathIdToNotificationPath=new Map;hostSize=vt(null);ctrlDimensions=Dt(()=>{let t=this.hostSize();if(!t)return {width:0,height:0};let e=Math.max(1,this.zonesControls().length),i=t.height/e,n=75*t.width/180,s=Math.min(n,i);return {width:t.width,height:s}});constructor(){Fa(()=>{let t=this.theme(),e=this.runtime?.options();!t||!e||ge(()=>{this.labelColor.set(c(e.color??"contrast",t).dim);});}),Fa(()=>{let t=this.runtime?.options();t&&ge(()=>{let e=(t.multiChildCtrls||[]).map(n=>z(G$1({},n),{isNumeric:n.isNumeric??false}));this.zonesControls.set(e);let i=t.paths;if(i?.length){this.pathIdToNotificationPath.clear();for(let n of i){if(!n?.pathID||!n?.path)continue;let s=n.path.replace(/^self(\.|$)/,"notifications$1");this.pathIdToNotificationPath.set(n.pathID,s);}this.applyNotificationsSnapshot(this.notifications());}});}),Fa(()=>{let t=this.notifications();ge(()=>this.applyNotificationsSnapshot(t));});}applyNotificationsSnapshot(t){if(!this.pathIdToNotificationPath.size||!t?.length)return;let e=new Map;for(let i of t)i?.path&&e.set(i.path,i);this.zonesControls.update(i=>{let n=null;for(let s=0;s<i.length;s++){let u=i[s],B=this.pathIdToNotificationPath.get(u.pathID),_=B?e.get(B):void 0;if(!_)continue;let I=_.value?.state,A=_.value?.message;u.notificationState===I&&u.notificationMessage===A||(n||(n=[...i]),n[s]=z(G$1({},u),{notificationState:I,notificationMessage:A}));}return n??i});}onResized(t){this.hostSize.set({width:t.contentRect.width,height:t.contentRect.height});}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=JD({type:o,selectors:[["widget-zones-state-panel"]],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"]],template:function(e,i){if(e&1&&(wg(0),_w(1,se,1,2,"widget-title",1),Pi(2,"div",2,0),Qh("resizeChange",function(s){return i.onResized(s)}),xw(4,le,2,1,"ng-container",null,Sw),ul(),_w(6,ce,1,0,"div",3)),e&2){let n=NT(i.runtime==null?null:i.runtime.options());EE(),Mw(n?.showLabel?1:-1),EE(),pT(i.noTitleClass()),EE(2),Aw(i.zonesControls()),EE(2),Mw(i.dashboard.isDashboardStatic()?-1:6);}},dependencies:[u,ne,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:6px 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 o})();
1
+ import {d1 as Hj,w,du as p,dY as O,a as G,W as Wp,v as vt,D as Dt,F as Fa,dn as ge,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,cp as Uh,cV as Td,T as TT,cj as fl,an as Hh,d as ig,bp as gl,s as sg,c as $h,g as qw,dX as xT,B as Bh,cS as pl,cT as hl,dx as n$1}from'./main-IINF7HD6.js';import {u}from'./chunk-CxOyBrqL.js';import {c}from'./chunk-DHj2hm9r.js';var ne=(()=>{class o{data=Hj(null,{alias:"controlData"});theme=Hj(null);dimensions=Hj.required();toggleClick=Vj();ctrlLabelColor=vt("");ctrlStateColor=vt("");messageTxtColor=vt("");shouldEmergencyBlink=Dt(()=>(this.data()?.notificationState??"").toLowerCase()==="emergency");shouldAlarmBlink=Dt(()=>(this.data()?.notificationState??"").toLowerCase()==="alarm");constructor(){Fa(()=>{let t=this.data(),e=this.theme();!t||!e||ge(()=>{switch(t.notificationState){case n$1.Emergency:this.ctrlStateColor.set(e.zoneEmergency),this.messageTxtColor.set(e.background);break;case n$1.Alarm:this.ctrlStateColor.set(e.zoneAlarm),this.messageTxtColor.set(e.background);break;case n$1.Warn:this.ctrlStateColor.set(e.zoneWarn),this.messageTxtColor.set(e.background);break;case n$1.Alert:this.ctrlStateColor.set(e.zoneAlert),this.messageTxtColor.set(e.background);break;default:this.ctrlStateColor.set(e.background),this.messageTxtColor.set(c(t.color,e).dim);break}this.ctrlLabelColor.set(c(t.color,e).color);});});}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=JD({type:o,selectors:[["app-svg-zone-states"]],inputs:{data:[1,"controlData","data"],theme:[1,"theme"],dimensions:[1,"dimensions"]},outputs:{toggleClick:"toggleClick"},decls:12,vars:14,consts:[["viewBox","0 0 180 75","version","1.1","id","svg9","xmlns","http://www.w3.org/2000/svg",0,"xmlns","svg","http://www.w3.org/2000/svg"],["id","defs9"],["id","zoneStateCtrl"],["id","touchRect","width","180","height","75","x","0","y","0","pointer-events","all",2,"display","inline","opacity","1","fill","transparent","fill-opacity","1","stroke","none","stroke-width","0","stroke-dasharray","none","stroke-opacity","0"],["x","0","y","0","width","180","height","20"],["xmlns","http://www.w3.org/1999/xhtml",2,"width","180px","height","20px","display","flex","align-items","center","justify-content","center","font-weight","bold","font-size","14px","line-height","1.1","text-align","center","overflow","hidden","word-break","break-word","white-space","normal"],["id","outlineRect","x","6","y","22","width","168","height","43","rx","3.5","fill","none",2,"display","inline","opacity","1","mix-blend-mode","normals","stroke-width","1","stroke-dasharray","none","stroke-opacity","0.65"],["id","innerRect","x","7","y","23","width","166","height","41","rx","3.5",2,"display","inline","opacity","1","mix-blend-mode","normal","stroke","none","stroke-width","0"],["x","7","y","23","width","166","height","41"],["xmlns","http://www.w3.org/1999/xhtml",2,"width","166px","height","41px","display","flex","align-items","center","justify-content","center","font-weight","regular","font-size","12px","line-height","1.1","text-align","center","overflow","hidden","word-break","break-word","white-space","normal","padding","2px"]],template:function(e,i){e&1&&(wd(),dl(0,"svg",0),Uh(1,"defs",1),dl(2,"g",2),Uh(3,"rect",3),dl(4,"foreignObject",4),Td(),dl(5,"div",5),TT(6),fl()(),wd(),Uh(7,"rect",6)(8,"rect",7),dl(9,"foreignObject",8),Td(),dl(10,"div",9),TT(11),fl()()()()),e&2&&(Hh("height",i.dimensions().height)("width",i.dimensions().width),EE(5),ig("color",i.ctrlLabelColor()),EE(),gl(" ",i.data()?.ctrlLabel," "),EE(),Hh("stroke",i.ctrlLabelColor()),EE(),sg("emergency-blink-fill",i.shouldEmergencyBlink())("alarm-blink-fill",i.shouldAlarmBlink()),Hh("fill",i.ctrlStateColor()),EE(2),ig("color",i.messageTxtColor()),EE(),gl(" ",i.data()?.notificationMessage," "));},styles:["@keyframes _ngcontent-%COMP%_AlarmBlinkFill{0%,49%{opacity:1}50%,to{opacity:.6}}.alarm-blink-fill[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_AlarmBlinkFill 1s step-end infinite}@keyframes _ngcontent-%COMP%_EmergencyBlinkFill{0%,49%{opacity:1}50%,to{opacity:.1}}.emergency-blink-fill[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_EmergencyBlinkFill .3s step-end infinite}"]})}return o})();function se(o,f){if(o&1&&$h(0,"widget-title",1),o&2){let t=qw(),e=xT(0);Bh("text",(e==null?null:e.displayName)??"")("color",t.labelColor());}}function re(o,f){if(o&1&&$h(0,"app-svg-zone-states",4),o&2){let t=qw().$implicit,e=qw();Bh("controlData",t)("theme",e.theme())("dimensions",e.ctrlDimensions());}}function le(o,f){if(o&1&&(pl(0),_w(1,re,1,3,"app-svg-zone-states",4),hl()),o&2){let e=f.$implicit;EE(),Mw((e.type)==="4"?1:-1);}}function ce(o,f){o&1&&$h(0,"div",3);}var _e=(()=>{class o{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={displayName:"Zones State Panel Label",showLabel:true,filterSelfPaths:true,paths:[],enableTimeout:false,dataTimeout:5,color:"contrast",putEnable:false,zonesOnlyPaths:true,putMomentary:false,multiChildCtrls:[]};runtime=w(p,{optional:true});notificationsService=w(O);dashboard=w(G);notifications=Wp(this.notificationsService.observeNotifications());zonesControls=vt([]);labelColor=vt("");noTitleClass=Dt(()=>this.runtime?.options()?.showLabel===false?"widgets-container-no-title":"widgets-container");pathIdToNotificationPath=new Map;hostSize=vt(null);ctrlDimensions=Dt(()=>{let t=this.hostSize();if(!t)return {width:0,height:0};let e=Math.max(1,this.zonesControls().length),i=t.height/e,n=75*t.width/180,s=Math.min(n,i);return {width:t.width,height:s}});constructor(){Fa(()=>{let t=this.theme(),e=this.runtime?.options();!t||!e||ge(()=>{this.labelColor.set(c(e.color??"contrast",t).dim);});}),Fa(()=>{let t=this.runtime?.options();t&&ge(()=>{let e=(t.multiChildCtrls||[]).map(n=>z(G$1({},n),{isNumeric:n.isNumeric??false}));this.zonesControls.set(e);let i=t.paths;if(i?.length){this.pathIdToNotificationPath.clear();for(let n of i){if(!n?.pathID||!n?.path)continue;let s=n.path.replace(/^self(\.|$)/,"notifications$1");this.pathIdToNotificationPath.set(n.pathID,s);}this.applyNotificationsSnapshot(this.notifications());}});}),Fa(()=>{let t=this.notifications();ge(()=>this.applyNotificationsSnapshot(t));});}applyNotificationsSnapshot(t){if(!this.pathIdToNotificationPath.size||!t?.length)return;let e=new Map;for(let i of t)i?.path&&e.set(i.path,i);this.zonesControls.update(i=>{let n=null;for(let s=0;s<i.length;s++){let u=i[s],B=this.pathIdToNotificationPath.get(u.pathID),_=B?e.get(B):void 0;if(!_)continue;let I=_.value?.state,A=_.value?.message;u.notificationState===I&&u.notificationMessage===A||(n||(n=[...i]),n[s]=z(G$1({},u),{notificationState:I,notificationMessage:A}));}return n??i});}onResized(t){this.hostSize.set({width:t.contentRect.width,height:t.contentRect.height});}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=JD({type:o,selectors:[["widget-zones-state-panel"]],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"]],template:function(e,i){if(e&1&&(wg(0),_w(1,se,1,2,"widget-title",1),Pi(2,"div",2,0),Qh("resizeChange",function(s){return i.onResized(s)}),xw(4,le,2,1,"ng-container",null,Sw),ul(),_w(6,ce,1,0,"div",3)),e&2){let n=NT(i.runtime==null?null:i.runtime.options());EE(),Mw(n?.showLabel?1:-1),EE(),pT(i.noTitleClass()),EE(2),Aw(i.zonesControls()),EE(2),Mw(i.dashboard.isDashboardStatic()?-1:6);}},dependencies:[u,ne,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:6px 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 o})();
2
2
  export{_e as WidgetZonesStatePanelComponent};