@mxtommy/kip 4.8.1 → 4.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -3
- package/package.json +27 -4
- package/public/{chunk-Bp0MQwPM.js → chunk-07zHjmg-.js} +1 -1
- package/public/{chunk-AANk-NXH.js → chunk-0z3nIRXw.js} +3 -3
- package/public/{chunk-sNakMDHi.js → chunk-B09jfNia.js} +1 -1
- package/public/{chunk-DDqeRiB0.js → chunk-B0D54iJs.js} +1 -1
- package/public/{chunk-BwOIef42.js → chunk-B0eE4udE.js} +1 -1
- package/public/{chunk-BX6skw5k.js → chunk-B9nVBlGj.js} +1 -1
- package/public/{chunk-C2VQxCXa.js → chunk-BFpzxIIT.js} +1 -1
- package/public/{chunk-Dxlia2NE.js → chunk-BIb-xYiS.js} +1 -1
- package/public/{chunk-dgaOX1wC.js → chunk-BJ-wyixK.js} +1 -1
- package/public/chunk-BLEZOsfR.js +1 -0
- package/public/{chunk-CNMFlw_H.js → chunk-BN7A4g6c.js} +1 -1
- package/public/{chunk-By8ZVvDx.js → chunk-BTOTKeBo.js} +1 -1
- package/public/{chunk-BoNDCNGE.js → chunk-BUguZ7cK.js} +1 -1
- package/public/{chunk-DE4ylhpq.js → chunk-BZx964-p.js} +1 -1
- package/public/{chunk-CNNTuNlM.js → chunk-BeM64etA.js} +1 -1
- package/public/chunk-BfiyH3nV.js +1 -0
- package/public/{chunk-Ii9n-oiL.js → chunk-BjINKQ03.js} +1 -1
- package/public/{chunk-MjWuPUhu.js → chunk-BpcNrtxJ.js} +1 -1
- package/public/{chunk-CkXTl3su.js → chunk-BuvyF0y5.js} +1 -1
- package/public/{chunk-BKj60jdq.js → chunk-C6b8CVno.js} +1 -1
- package/public/{chunk-hd2_AKwt.js → chunk-CCfhzpE8.js} +1 -1
- package/public/{chunk-nu4vZg-z.js → chunk-CHAFm_nM.js} +1 -1
- package/public/{chunk-5U8d2Ygo.js → chunk-CIGP2YJm.js} +1 -1
- package/public/{chunk-JbEkcxJm.js → chunk-CLTHuhlN.js} +1 -1
- package/public/{chunk-CwSa_BNV.js → chunk-CLs_NL1y.js} +1 -1
- package/public/{chunk-DNS-qsFC.js → chunk-COI6IBXH.js} +1 -1
- package/public/{chunk-CpuB_ZZz.js → chunk-CQMVIDcp.js} +1 -1
- package/public/{chunk-00hwknVI.js → chunk-CXvWM_vF.js} +1 -1
- package/public/{chunk-BdokyhBM.js → chunk-CYYBxjrc.js} +1 -1
- package/public/{chunk-DzTTqoF_.js → chunk-C_OZJltF.js} +1 -1
- package/public/{chunk-DQnoPLyC.js → chunk-Co2wVrD6.js} +1 -1
- package/public/{chunk-CXvG8mMq.js → chunk-CoCQ3DW2.js} +1 -1
- package/public/{chunk-DchvLV_Y.js → chunk-CxPx4NZv.js} +1 -1
- package/public/{chunk-CA6RRaxd.js → chunk-CyVRpGoJ.js} +1 -1
- package/public/{chunk-CL2xiH57.js → chunk-D-_-GUVr.js} +1 -1
- package/public/{chunk-C6UXF7BI.js → chunk-D1HYfaL_.js} +1 -1
- package/public/{chunk-DjZgzSiH.js → chunk-D2953Rfp.js} +1 -1
- package/public/{chunk-BJz7Ij9E.js → chunk-DIl1k00y.js} +1 -1
- package/public/{chunk-B6bEhzNR.js → chunk-DPnbM-aB.js} +1 -1
- package/public/{chunk-CIlfzV9R.js → chunk-DTN-sa1K.js} +1 -1
- package/public/{chunk-BOAD0N2a.js → chunk-DUEKoZhd.js} +1 -1
- package/public/{chunk-DumLX5k_.js → chunk-DmkAKXR1.js} +1 -1
- package/public/chunk-Do8wqING.js +1 -0
- package/public/{chunk-DXkKj21H.js → chunk-JhFkJS7i.js} +1 -1
- package/public/{chunk-B82ADJSs.js → chunk-OeQDZKFO.js} +1 -1
- package/public/{chunk-PheXEqie.js → chunk-_zRMMvCu.js} +1 -1
- package/public/{chunk-CrBxxZCe.js → chunk-eQ1pa34Q.js} +1 -1
- package/public/{chunk-D4xZ2tGB.js → chunk-ibauGmSP.js} +1 -1
- package/public/{chunk-VgxMqRPk.js → chunk-otzyItXL.js} +1 -1
- package/public/{chunk-BQr-tSkv.js → chunk-q9NoPvcx.js} +1 -1
- package/public/{chunk-DWLISAZi.js → chunk-szQs8fiq.js} +1 -1
- package/public/{chunk-tAiV3ARh.js → chunk-x7L6DXVK.js} +1 -1
- package/public/index.html +1 -1
- package/public/{main-BAV5VDOD.js → main-YKDNK5VZ.js} +20 -20
- package/plugin/history-series.service.js +0 -637
- package/plugin/index.js +0 -1322
- package/plugin/kip-series-contract.js +0 -31
- package/plugin/openApi.json +0 -855
- package/plugin/sqlite-history-storage.service.js +0 -1124
- package/plugin/src/history-series.service.js +0 -634
- package/plugin/src/index.js +0 -1322
- package/plugin/src/kip-series-contract.js +0 -31
- package/plugin/src/openApi.json +0 -855
- package/plugin/src/sqlite-history-storage.service.js +0 -1122
- package/public/chunk-Blokg6Ds.js +0 -1
- package/public/chunk-CpMCBDvH.js +0 -1
- package/public/chunk-y1imvaA-.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import {d1 as Hj,w,du as p,dv as rt,aZ as F,a as G,cu as T,aY as xe,$ as $j,v as vt,F as Fa,dn as ge,a_ as Gp,J as JD,O as Op,bh as xp,y as yt,b as wt,cR as zt,bg as mt,P as Pi,c as $h,u as ul,k as Qh,cn as wd,T as TT,_ as _w,e as EE,M as Mw,f as eg,K as Kw,h as Fw,cV as Td,g as qw,t as pT,dE as RT,B as Bh,aA as gg,l as ud,m as dd,bp as gl}from'./main-BAV5VDOD.js';import {c}from'./chunk-Dxlia2NE.js';var J=["canvasMainRef"];function Z(o,e){if(o&1&&(Pi(0,"div",10),wd(),Pi(1,"svg",11)(2,"text",12),TT(3),ul()()(),Td(),Pi(4,"div",13),wd(),Pi(5,"svg",14)(6,"text",15)(7,"tspan",16),TT(8,"\u2691"),ul(),TT(9),Pi(10,"tspan",17),TT(11,"\u2691"),ul()()()(),Td(),Pi(12,"div",18),wd(),Pi(13,"svg",19)(14,"text",12),TT(15),ul()()()),o&2){let t=qw();EE(3),gg(t.portBiasValue()),EE(6),gl(" ",t.lineLengthValue()," "),EE(6),gg(t.stbBiasValue());}}function K(o,e){if(o&1){let t=Fw();Pi(0,"button",20),Qh("click",function(){ud(t);let i=qw();return dd(i.setLineEnd("port"))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",21)(3,"text",22),TT(4,"Port End"),ul()()()(),Td(),Pi(5,"button",23),Qh("click",function(){ud(t);let i=qw();return dd(i.setLineEnd("stb"))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",21)(8,"text",22),TT(9,"Stbd End"),ul()()()();}}function X(o,e){if(o&1){let t=Fw();Pi(0,"button",24),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",5,0))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"+5m"),ul()()()(),Td(),Pi(5,"button",27),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",-5,0))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",25)(8,"text",26),TT(9,"-5m"),ul()()()(),Td(),Pi(10,"button",28),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",-5,0))}),Pi(11,"mat-icon",6),wd(),Pi(12,"svg",25)(13,"text",26),TT(14,"-5m"),ul()()()(),Td(),Pi(15,"button",29),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",5,0))}),Pi(16,"mat-icon",6),wd(),Pi(17,"svg",25)(18,"text",26),TT(19,"+5m"),ul()()()();}}function tt(o,e){if(o&1){let t=Fw();Pi(0,"button",30),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",0,i.toRadians(1)))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"\u21911\xB0"),ul()()()(),Td(),Pi(5,"button",31),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",0,i.toRadians(-1)))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",25)(8,"text",26),TT(9,"\u21931\xB0"),ul()()()(),Td(),Pi(10,"button",32),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",0,i.toRadians(1)))}),Pi(11,"mat-icon",6),wd(),Pi(12,"svg",25)(13,"text",26),TT(14,"\u21931\xB0"),ul()()()(),Td(),Pi(15,"button",33),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",0,i.toRadians(-1)))}),Pi(16,"mat-icon",6),wd(),Pi(17,"svg",25)(18,"text",26),TT(19,"\u21911\xB0"),ul()()()();}}function et(o,e){if(o&1){let t=Fw();Pi(0,"button",34),Qh("click",function(){ud(t);let i=qw();return dd(i.nextDisplayLineName())}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"Line"),ul()()()(),Td(),Pi(5,"button",35),Qh("click",function(){ud(t);let i=qw();return dd(i.setStartLine(i.getDisplayLineName()))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",36)(8,"text",37),TT(9),ul()()()();}if(o&2){let t=qw();EE(5),pT(RT("button ",t.isDisplayLineCurrent()?"line-button-current":"line-button")),Bh("matTooltip",RT("Set the ",t.getDisplayLineName()," line as the current line")),EE(4),gg(t.getDisplayLineName());}}function it(o,e){o&1&&$h(0,"div",9);}var Q=class o{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);canvas=w(F);dashboard=w(G);signalk=w(T);destroyRef=w(xe);static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:false,displayName:"DTS",filterSelfPaths:true,playBeeps:true,convertUnitTo:"m",convertUnitToGroup:"Length",numDecimal:0,ignoreZones:true,color:"contrast",enableTimeout:false,dataTimeout:5,paths:{dtsPath:{description:"Distance to Start Line",path:"self.navigation.racing.distanceStartline",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:500},lineLengthPath:{description:"Length of the start line",path:"self.navigation.racing.startLineLength",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:1e3},lineBiasPath:{description:"Bias of the start line to starboard end",path:"self.navigation.racing.stbLineBias",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:1e3},startLineNamePath:{description:"The current named start line",path:"self.navigation.racing.lines.startLineName",source:"default",pathType:"string",pathRequired:false,isPathConfigurable:false,convertUnitTo:void 0,showPathSkUnitsFilter:false,pathSkUnitsFilter:null,sampleTime:1e3},linesPath:{description:"The known named lines",path:"self.navigation.racing.lines.lines",source:"default",pathType:null,pathRequired:false,isPathConfigurable:false,convertUnitTo:void 0,showPathSkUnitsFilter:false,pathSkUnitsFilter:null,sampleTime:1e3},ttlPath:{description:"Time to sail to the start line in seconds",path:"self.navigation.racing.timeToLine",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"s",showConvertUnitTo:false,showPathSkUnitsFilter:false,pathSkUnitsFilter:"s",sampleTime:500},ttbPath:{description:"Time to delay before sailing to the start line in seconds",path:"self.navigation.racing.timeToBurn",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"s",showConvertUnitTo:false,showPathSkUnitsFilter:false,pathSkUnitsFilter:"s",sampleTime:500}}};canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;titleBitmap=null;titleBitmapText=null;titleBitmapColor=null;dtsValue=null;lengthValue=null;biasValue=null;ttlValue=null;ttbValue=null;labelColor=vt("");valueColor="";dtsColor="";maxValueTextWidth=0;maxValueTextHeight=0;displayLineIndex=0;lines=[];startLineName=null;portBiasValue=vt("");lineLengthValue=vt("");stbBiasValue=vt("");mode=vt(0);normalizedConfig=vt(o.DEFAULT_CONFIG);get pathsRecord(){return (this.runtime.options()??o.DEFAULT_CONFIG).paths??{}}constructor(){Fa(()=>{let e=this.runtime.options()??o.DEFAULT_CONFIG,t=this.theme();t&&ge(()=>{let a=c(e.color??"contrast",t);this.labelColor.set(a.dim),this.valueColor=a.color,this.draw();});}),Fa(()=>{this.pathsRecord.dtsPath?.path&&ge(()=>this.streams.observe("dtsPath",t=>{this.dtsValue=t?.data?.value??null,this.updateDtsColor(),this.draw();}));}),Fa(()=>{this.pathsRecord.lineLengthPath?.path&&ge(()=>this.streams.observe("lineLengthPath",t=>{this.lengthValue=t?.data?.value??null,this.setLenBias(),this.draw();}));}),Fa(()=>{this.pathsRecord.lineBiasPath?.path&&ge(()=>this.streams.observe("lineBiasPath",t=>{this.biasValue=t?.data?.value??null,this.setLenBias();}));}),Fa(()=>{this.pathsRecord.startLineNamePath?.path&&ge(()=>this.streams.observe("startLineNamePath",t=>{console.log("startLineName: "+JSON.stringify(t??"no data")),this.startLineName=t?.data?.value??null,this.displayLineIndex=0;for(let a=0;a<this.lines.length;a++)if(this.lines[a]===this.startLineName){this.displayLineIndex=a;break}this.draw();}));}),Fa(()=>{this.pathsRecord.linesPath?.path&&ge(()=>this.streams.observe("linesPath",t=>{if(console.log("lines: "+JSON.stringify(t??"no data")),this.lines=["Default"],this.displayLineIndex=0,t?.data?.value&&Array.isArray(t.data.value))for(let a of t.data.value)a.startLineName&&(a.startLineName===this.startLineName&&(this.displayLineIndex=this.lines.length),this.lines.push(a.startLineName));}));}),Fa(()=>{this.pathsRecord.ttlPath?.path&&ge(()=>this.streams.observe("ttlPath",t=>{this.ttlValue=t?.data?.value??null,this.draw();}));}),Fa(()=>{this.pathsRecord.ttbPath?.path&&ge(()=>this.streams.observe("ttbPath",t=>{this.ttbValue=t?.data?.value??null,this.draw();}));}),this.signalk.subscribeRequest().pipe(Gp(this.destroyRef)).subscribe(e=>{e.widgetUUID===this.id()&&e.statusCode===200&&this.beep(600,20);});}ngAfterViewInit(){this.canvasElement=this.canvasRef().nativeElement,this.ctx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(e,t)=>{this.cssWidth=e,this.cssHeight=t,this.maxValueTextWidth=Math.floor(this.cssWidth*.95),this.maxValueTextHeight=Math.floor(this.cssHeight*.95),this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.maxValueTextWidth=Math.floor(this.cssWidth*.95),this.maxValueTextHeight=Math.floor(this.cssHeight*.95),this.draw();}toggleMode(){this.mode.update(e=>(e+1)%5),this.draw();}setLineEnd(e){return this.signalk.putRequest("navigation.racing.setStartLine",{end:e,position:"bow"},this.id())??""}adjustLineEnd(e,t,a){return this.signalk.putRequest("navigation.racing.setStartLine",{end:e,delta:t,rotate:a},this.id())??""}nextDisplayLineName(){++this.displayLineIndex>=this.lines.length&&(this.displayLineIndex=0);}getDisplayLineName(){return this.lines[this.displayLineIndex]||"Default"}isDisplayLineCurrent(){return this.getDisplayLineName()===(this.startLineName||"Default")}setStartLine(e){let t=e==="Default"||!e?null:e;this.signalk.putRequest("navigation.racing.setStartLineName",{startLineName:t},this.id()),this.mode.set(0),this.draw();}toRadians(e){return e*(Math.PI/180)}draw(){if(!this.ctx||!this.canvasElement)return;let e=this.runtime.options()??o.DEFAULT_CONFIG,t=e?.displayName||"DTS",a=this.labelColor();(!this.titleBitmap||!e||this.titleBitmap.width!==this.canvasElement.width||this.titleBitmap.height!==this.canvasElement.height||this.titleBitmapText!==t||this.titleBitmapColor!==a)&&(this.titleBitmap=this.canvas.createTitleBitmap(t,a,"normal",this.cssWidth,this.cssHeight),this.titleBitmapText=t,this.titleBitmapColor=a),this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),this.titleBitmap&&this.ctx.drawImage(this.titleBitmap,0,0,this.cssWidth,this.cssHeight),this.canvas.drawText(this.ctx,this.getValueText(),Math.floor(this.cssWidth*.5),Math.floor(this.cssHeight*.325),Math.floor(this.cssWidth*.95),Math.floor(this.cssHeight*.55),"bold",this.dtsColor,"center","middle"),this.canvas.drawText(this.ctx,this.pathsRecord.dtsPath?.convertUnitTo||"m",Math.floor(this.cssWidth*.975),Math.floor(this.cssHeight*.6),Math.floor(this.cssWidth*.95),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"right","bottom"),this.canvas.drawText(this.ctx,"TTL",Math.floor(this.cssWidth*.025),Math.floor(this.cssHeight*.7),Math.floor(this.cssWidth*.1),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"left","middle"),this.canvas.drawText(this.ctx,this.getTimeToLineText(),Math.floor(this.cssWidth*.15),Math.floor(this.cssHeight-.8),Math.floor(this.cssWidth*.35),Math.floor(this.cssHeight*.35),"bold",this.dtsColor,"left","bottom"),this.canvas.drawText(this.ctx,"TTB",Math.floor(this.cssWidth*.525),Math.floor(this.cssHeight*.7),Math.floor(this.cssWidth*.1),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"left","middle"),this.canvas.drawText(this.ctx,this.getTimeToBurnText(),Math.floor(this.cssWidth*.65),Math.floor(this.cssHeight-.8),Math.floor(this.cssWidth*.35),Math.floor(this.cssHeight*.35),"bold",this.dtsColor,"left","bottom"),this.setLenBias();}getValueText(){if(this.dtsValue===null)return "--";let e=this.runtime.options()??o.DEFAULT_CONFIG;return this.dtsValue.toFixed(e?.numDecimal??0)}toHHMMSS(e){if(e==null||isNaN(e))return "-:--";let t=e<0;t&&(e=-e);let a=Math.floor(e/3600),i=Math.floor(e%3600/60),f=Math.floor(e%60),C=t?"-":"";return a===0?`${C}${i.toString().padStart(1,"0")}:${f.toString().padStart(2,"0")}`:`${C}${a.toString().padStart(1,"0")}:${i.toString().padStart(2,"0")}:${f.toString().padStart(2,"0")}`}getTimeToLineText(){return this.toHHMMSS(this.ttlValue??0)}getTimeToBurnText(){return this.toHHMMSS(this.ttbValue??0)}setLenBias(){let e=this.runtime.options()??o.DEFAULT_CONFIG,t=this.pathsRecord.lineLengthPath,a=this.pathsRecord.lineBiasPath;if(t?.path&&this.lengthValue!=null){let i=t.convertUnitTo;i==="feet"&&(i="\u2032"),this.lineLengthValue.set(`\u2015${this.applyDecorations(this.lengthValue.toFixed(e.numDecimal??0))}${i??""}\u2015`);}if(a?.path&&this.biasValue!=null){let i=a.convertUnitTo;i==="feet"&&(i="\u2032"),this.biasValue<0?(this.portBiasValue.set("+"+(-this.biasValue).toFixed(e.numDecimal??0)+(i??"")),this.stbBiasValue.set(this.biasValue.toFixed(e.numDecimal??0)+(i??""))):(this.portBiasValue.set(" "+(-this.biasValue).toFixed(e.numDecimal??0)+(i??"")),this.stbBiasValue.set(" +"+this.biasValue.toFixed(e.numDecimal??0)+(i??"")));}}applyDecorations(e){switch(this.pathsRecord.dtsPath?.convertUnitTo){case "percent":case "percentraw":return e+"%";default:return e}}updateDtsColor(){let e=this.theme(),t=this.runtime.options()??o.DEFAULT_CONFIG;e&&(t.ignoreZones?this.dtsValue?this.dtsValue<0?this.dtsColor=e.zoneAlarm:this.dtsValue<10?this.dtsColor=e.zoneWarn:this.dtsValue<20?this.dtsColor=e.zoneAlert:this.dtsColor=this.valueColor:this.dtsColor=this.valueColor:this.dtsColor=this.valueColor);}beep(e=440,t=100){if(!this.runtime.options()?.playBeeps)return;let a=window.AudioContext||window.webkitAudioContext,i=new a,f=i.createOscillator(),C=i.createGain();f.connect(C),C.connect(i.destination),f.type="sine",f.frequency.value=e,C.gain.value=.1,f.start(),f.stop(i.currentTime+t/1e3);}ngOnDestroy(){try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(e){}}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=JD({type:o,selectors:[["widget-racer-line"]],viewQuery:function(t,a){t&1&&eg(a.canvasRef,J,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:16,vars:2,consts:[["canvasMainRef",""],[1,"line-wrapper"],[1,"filler"],[1,"line-canvas"],[1,"buttons-container"],["mat-flat-button","","matTooltip","Select the control mode",1,"button","select-button",3,"click"],[1,"buttons-svg-icon"],["width","100%","height","100%","viewBox","0 0 80 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","40","y","9"],[1,"widgetOverlay"],[1,"pin-container"],["width","100%","height","100%","viewBox","0 0 70 18","preserveAspectRatio","xMidYMid meet",1,"svg-content","pin"],["x","33","y","14"],[1,"len-bias-container"],["width","100%","height","100%","viewBox","0 0 90 12","preserveAspectRatio","xMidYMid meet",1,"svg-content","len-bias"],["x","45","y","9"],[1,"pin"],[1,"boat"],[1,"boat-container"],["width","100%","height","100%","viewBox","0 0 70 18","preserveAspectRatio","xMidYMid meet",1,"svg-content","boat"],["mat-flat-button","","matTooltip","Set the port(pin) end of the line to the current position",1,"button","port-button",3,"click"],["width","100%","height","100%","viewBox","0 0 100 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","50","y","11"],["mat-flat-button","","matTooltip","Set the starboard(boat) end of the line to the current position",1,"button","starboard-button",3,"click"],["mat-flat-button","","matTooltip","Increase the line length by 5m at the port(pin) end",1,"button","port-small-button",3,"click"],["width","100%","height","100%","viewBox","0 0 50 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","25","y","11"],["mat-flat-button","","matTooltip","Decrease the line length by 5m at the port(pin) end",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Decrease the line length by 5m at the starboard(boat) end",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Increase the line length by 5m at the starboard(boat) end",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the port(pin) end 1\xB0 clockwise",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the port(pin) end 1\xB0 counter-clockwise",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the starboard(boat) end 1\xB0 counter-clockwise",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the starboard(boat) end 1\xB0 clockwise",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Display the next named line",1,"button","select-button",3,"click"],["mat-flat-button","",3,"click","matTooltip"],["width","100%","height","100%","viewBox","0 0 150 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","75","y","11"]],template:function(t,a){if(t&1&&(Pi(0,"div",1)(1,"div",2),$h(2,"canvas",3,0),ul(),Pi(4,"div",4)(5,"button",5),Qh("click",function(){return a.toggleMode()}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",7)(8,"text",8),TT(9,"\u22EE"),ul()()()(),_w(10,Z,16,3)(11,K,10,0)(12,X,20,0)(13,tt,20,0)(14,et,10,6),ul(),_w(15,it,1,0,"div",9),ul()),t&2){let i;EE(10),Mw((i=a.mode())===0?10:i===1?11:i===2?12:i===3?13:i===4?14:-1),EE(5),Mw(a.dashboard.isDashboardStatic()?-1:15);}},dependencies:[Op,xp,yt,wt,zt,mt],styles:["[_nghost-%COMP%]{overflow:clip;display:block;height:100%;width:100%}.line-wrapper[_ngcontent-%COMP%]{width:100%;height:100%;min-height:1px}.line-canvas[_ngcontent-%COMP%]{position:absolute;width:100%!important;height:76%!important;display:block;top:0;left:0}.filler[_ngcontent-%COMP%]{width:100%;height:76%}.buttons-container[_ngcontent-%COMP%]{display:flex;flex-wrap:nowrap;justify-content:space-between;column-gap:2%;position:relative;height:24%;width:100%;padding:0 10px 14px;z-index:20;pointer-events:auto;align-items:center}.button[_ngcontent-%COMP%]{min-width:0px;width:100%;border-radius:12px;align-items:center;justify-content:center;cursor:pointer;--mat-button-filled-container-height: 100%;--mat-button-filled-horizontal-padding: 0px;--mat-button-filled-icon-spacing: 0px}.select-button[_ngcontent-%COMP%]{flex:none;width:18%;--mat-button-filled-container-color: var(--kip-blue-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.line-button[_ngcontent-%COMP%]{flex:none;width:58%;--mat-button-filled-container-color: var(--kip-grey-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.line-button-current[_ngcontent-%COMP%]{flex:none;width:58%;--mat-button-filled-container-color: var(--kip-orange-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.port-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.starboard-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-starboard-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.port-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.starboard-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-starboard-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.buttons-svg-icon[_ngcontent-%COMP%]{width:100%;height:100%;margin:0;padding:0}.svg-content[_ngcontent-%COMP%]{width:100%;height:100%;padding:0;margin:0}.svg-content[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-family:Roboto;font-size:15px;font-weight:700;text-align:center;text-anchor:middle;font-style:normal;font-variant:normal;font-stretch:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke:none}.pin-container[_ngcontent-%COMP%]{flex-basis:18%}.pin[_ngcontent-%COMP%]{fill:var(--kip-port-color)}.pin[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:19px}.len-bias-container[_ngcontent-%COMP%]{flex-basis:35%}.len-bias[_ngcontent-%COMP%]{fill:var(--kip-contrast-color)}.len-bias[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:12px}.boat-container[_ngcontent-%COMP%]{flex-basis:18%}.boat[_ngcontent-%COMP%]{fill:var(--kip-starboard-color)}.boat[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:19px}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent;z-index:21}"]})};export{Q as WidgetRacerLineComponent};
|
|
1
|
+
import {d1 as Hj,w,du as p,dv as rt,aZ as R,a as G,cu as T,aY as xe,$ as $j,v as vt,F as Fa,dn as ge,a_ as Gp,J as JD,O as Op,bh as xp,y as yt,b as wt,cR as zt,bg as mt,P as Pi,c as $h,u as ul,k as Qh,cn as wd,T as TT,_ as _w,e as EE,M as Mw,f as eg,K as Kw,h as Fw,cV as Td,g as qw,t as pT,dE as RT,B as Bh,aA as gg,l as ud,m as dd,bp as gl}from'./main-YKDNK5VZ.js';import {c}from'./chunk-BIb-xYiS.js';var J=["canvasMainRef"];function Z(o,e){if(o&1&&(Pi(0,"div",10),wd(),Pi(1,"svg",11)(2,"text",12),TT(3),ul()()(),Td(),Pi(4,"div",13),wd(),Pi(5,"svg",14)(6,"text",15)(7,"tspan",16),TT(8,"\u2691"),ul(),TT(9),Pi(10,"tspan",17),TT(11,"\u2691"),ul()()()(),Td(),Pi(12,"div",18),wd(),Pi(13,"svg",19)(14,"text",12),TT(15),ul()()()),o&2){let t=qw();EE(3),gg(t.portBiasValue()),EE(6),gl(" ",t.lineLengthValue()," "),EE(6),gg(t.stbBiasValue());}}function K(o,e){if(o&1){let t=Fw();Pi(0,"button",20),Qh("click",function(){ud(t);let i=qw();return dd(i.setLineEnd("port"))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",21)(3,"text",22),TT(4,"Port End"),ul()()()(),Td(),Pi(5,"button",23),Qh("click",function(){ud(t);let i=qw();return dd(i.setLineEnd("stb"))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",21)(8,"text",22),TT(9,"Stbd End"),ul()()()();}}function X(o,e){if(o&1){let t=Fw();Pi(0,"button",24),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",5,0))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"+5m"),ul()()()(),Td(),Pi(5,"button",27),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",-5,0))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",25)(8,"text",26),TT(9,"-5m"),ul()()()(),Td(),Pi(10,"button",28),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",-5,0))}),Pi(11,"mat-icon",6),wd(),Pi(12,"svg",25)(13,"text",26),TT(14,"-5m"),ul()()()(),Td(),Pi(15,"button",29),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",5,0))}),Pi(16,"mat-icon",6),wd(),Pi(17,"svg",25)(18,"text",26),TT(19,"+5m"),ul()()()();}}function tt(o,e){if(o&1){let t=Fw();Pi(0,"button",30),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",0,i.toRadians(1)))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"\u21911\xB0"),ul()()()(),Td(),Pi(5,"button",31),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",0,i.toRadians(-1)))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",25)(8,"text",26),TT(9,"\u21931\xB0"),ul()()()(),Td(),Pi(10,"button",32),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",0,i.toRadians(1)))}),Pi(11,"mat-icon",6),wd(),Pi(12,"svg",25)(13,"text",26),TT(14,"\u21931\xB0"),ul()()()(),Td(),Pi(15,"button",33),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",0,i.toRadians(-1)))}),Pi(16,"mat-icon",6),wd(),Pi(17,"svg",25)(18,"text",26),TT(19,"\u21911\xB0"),ul()()()();}}function et(o,e){if(o&1){let t=Fw();Pi(0,"button",34),Qh("click",function(){ud(t);let i=qw();return dd(i.nextDisplayLineName())}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"Line"),ul()()()(),Td(),Pi(5,"button",35),Qh("click",function(){ud(t);let i=qw();return dd(i.setStartLine(i.getDisplayLineName()))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",36)(8,"text",37),TT(9),ul()()()();}if(o&2){let t=qw();EE(5),pT(RT("button ",t.isDisplayLineCurrent()?"line-button-current":"line-button")),Bh("matTooltip",RT("Set the ",t.getDisplayLineName()," line as the current line")),EE(4),gg(t.getDisplayLineName());}}function it(o,e){o&1&&$h(0,"div",9);}var Q=class o{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);canvas=w(R);dashboard=w(G);signalk=w(T);destroyRef=w(xe);static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:false,displayName:"DTS",filterSelfPaths:true,playBeeps:true,convertUnitTo:"m",convertUnitToGroup:"Length",numDecimal:0,ignoreZones:true,color:"contrast",enableTimeout:false,dataTimeout:5,paths:{dtsPath:{description:"Distance to Start Line",path:"self.navigation.racing.distanceStartline",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:500},lineLengthPath:{description:"Length of the start line",path:"self.navigation.racing.startLineLength",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:1e3},lineBiasPath:{description:"Bias of the start line to starboard end",path:"self.navigation.racing.stbLineBias",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:1e3},startLineNamePath:{description:"The current named start line",path:"self.navigation.racing.lines.startLineName",source:"default",pathType:"string",pathRequired:false,isPathConfigurable:false,convertUnitTo:void 0,showPathSkUnitsFilter:false,pathSkUnitsFilter:null,sampleTime:1e3},linesPath:{description:"The known named lines",path:"self.navigation.racing.lines.lines",source:"default",pathType:null,pathRequired:false,isPathConfigurable:false,convertUnitTo:void 0,showPathSkUnitsFilter:false,pathSkUnitsFilter:null,sampleTime:1e3},ttlPath:{description:"Time to sail to the start line in seconds",path:"self.navigation.racing.timeToLine",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"s",showConvertUnitTo:false,showPathSkUnitsFilter:false,pathSkUnitsFilter:"s",sampleTime:500},ttbPath:{description:"Time to delay before sailing to the start line in seconds",path:"self.navigation.racing.timeToBurn",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"s",showConvertUnitTo:false,showPathSkUnitsFilter:false,pathSkUnitsFilter:"s",sampleTime:500}}};canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;titleBitmap=null;titleBitmapText=null;titleBitmapColor=null;dtsValue=null;lengthValue=null;biasValue=null;ttlValue=null;ttbValue=null;labelColor=vt("");valueColor="";dtsColor="";maxValueTextWidth=0;maxValueTextHeight=0;displayLineIndex=0;lines=[];startLineName=null;portBiasValue=vt("");lineLengthValue=vt("");stbBiasValue=vt("");mode=vt(0);normalizedConfig=vt(o.DEFAULT_CONFIG);get pathsRecord(){return (this.runtime.options()??o.DEFAULT_CONFIG).paths??{}}constructor(){Fa(()=>{let e=this.runtime.options()??o.DEFAULT_CONFIG,t=this.theme();t&&ge(()=>{let a=c(e.color??"contrast",t);this.labelColor.set(a.dim),this.valueColor=a.color,this.draw();});}),Fa(()=>{this.pathsRecord.dtsPath?.path&&ge(()=>this.streams.observe("dtsPath",t=>{this.dtsValue=t?.data?.value??null,this.updateDtsColor(),this.draw();}));}),Fa(()=>{this.pathsRecord.lineLengthPath?.path&&ge(()=>this.streams.observe("lineLengthPath",t=>{this.lengthValue=t?.data?.value??null,this.setLenBias(),this.draw();}));}),Fa(()=>{this.pathsRecord.lineBiasPath?.path&&ge(()=>this.streams.observe("lineBiasPath",t=>{this.biasValue=t?.data?.value??null,this.setLenBias();}));}),Fa(()=>{this.pathsRecord.startLineNamePath?.path&&ge(()=>this.streams.observe("startLineNamePath",t=>{console.log("startLineName: "+JSON.stringify(t??"no data")),this.startLineName=t?.data?.value??null,this.displayLineIndex=0;for(let a=0;a<this.lines.length;a++)if(this.lines[a]===this.startLineName){this.displayLineIndex=a;break}this.draw();}));}),Fa(()=>{this.pathsRecord.linesPath?.path&&ge(()=>this.streams.observe("linesPath",t=>{if(console.log("lines: "+JSON.stringify(t??"no data")),this.lines=["Default"],this.displayLineIndex=0,t?.data?.value&&Array.isArray(t.data.value))for(let a of t.data.value)a.startLineName&&(a.startLineName===this.startLineName&&(this.displayLineIndex=this.lines.length),this.lines.push(a.startLineName));}));}),Fa(()=>{this.pathsRecord.ttlPath?.path&&ge(()=>this.streams.observe("ttlPath",t=>{this.ttlValue=t?.data?.value??null,this.draw();}));}),Fa(()=>{this.pathsRecord.ttbPath?.path&&ge(()=>this.streams.observe("ttbPath",t=>{this.ttbValue=t?.data?.value??null,this.draw();}));}),this.signalk.subscribeRequest().pipe(Gp(this.destroyRef)).subscribe(e=>{e.widgetUUID===this.id()&&e.statusCode===200&&this.beep(600,20);});}ngAfterViewInit(){this.canvasElement=this.canvasRef().nativeElement,this.ctx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(e,t)=>{this.cssWidth=e,this.cssHeight=t,this.maxValueTextWidth=Math.floor(this.cssWidth*.95),this.maxValueTextHeight=Math.floor(this.cssHeight*.95),this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.maxValueTextWidth=Math.floor(this.cssWidth*.95),this.maxValueTextHeight=Math.floor(this.cssHeight*.95),this.draw();}toggleMode(){this.mode.update(e=>(e+1)%5),this.draw();}setLineEnd(e){return this.signalk.putRequest("navigation.racing.setStartLine",{end:e,position:"bow"},this.id())??""}adjustLineEnd(e,t,a){return this.signalk.putRequest("navigation.racing.setStartLine",{end:e,delta:t,rotate:a},this.id())??""}nextDisplayLineName(){++this.displayLineIndex>=this.lines.length&&(this.displayLineIndex=0);}getDisplayLineName(){return this.lines[this.displayLineIndex]||"Default"}isDisplayLineCurrent(){return this.getDisplayLineName()===(this.startLineName||"Default")}setStartLine(e){let t=e==="Default"||!e?null:e;this.signalk.putRequest("navigation.racing.setStartLineName",{startLineName:t},this.id()),this.mode.set(0),this.draw();}toRadians(e){return e*(Math.PI/180)}draw(){if(!this.ctx||!this.canvasElement)return;let e=this.runtime.options()??o.DEFAULT_CONFIG,t=e?.displayName||"DTS",a=this.labelColor();(!this.titleBitmap||!e||this.titleBitmap.width!==this.canvasElement.width||this.titleBitmap.height!==this.canvasElement.height||this.titleBitmapText!==t||this.titleBitmapColor!==a)&&(this.titleBitmap=this.canvas.createTitleBitmap(t,a,"normal",this.cssWidth,this.cssHeight),this.titleBitmapText=t,this.titleBitmapColor=a),this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),this.titleBitmap&&this.ctx.drawImage(this.titleBitmap,0,0,this.cssWidth,this.cssHeight),this.canvas.drawText(this.ctx,this.getValueText(),Math.floor(this.cssWidth*.5),Math.floor(this.cssHeight*.325),Math.floor(this.cssWidth*.95),Math.floor(this.cssHeight*.55),"bold",this.dtsColor,"center","middle"),this.canvas.drawText(this.ctx,this.pathsRecord.dtsPath?.convertUnitTo||"m",Math.floor(this.cssWidth*.975),Math.floor(this.cssHeight*.6),Math.floor(this.cssWidth*.95),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"right","bottom"),this.canvas.drawText(this.ctx,"TTL",Math.floor(this.cssWidth*.025),Math.floor(this.cssHeight*.7),Math.floor(this.cssWidth*.1),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"left","middle"),this.canvas.drawText(this.ctx,this.getTimeToLineText(),Math.floor(this.cssWidth*.15),Math.floor(this.cssHeight-.8),Math.floor(this.cssWidth*.35),Math.floor(this.cssHeight*.35),"bold",this.dtsColor,"left","bottom"),this.canvas.drawText(this.ctx,"TTB",Math.floor(this.cssWidth*.525),Math.floor(this.cssHeight*.7),Math.floor(this.cssWidth*.1),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"left","middle"),this.canvas.drawText(this.ctx,this.getTimeToBurnText(),Math.floor(this.cssWidth*.65),Math.floor(this.cssHeight-.8),Math.floor(this.cssWidth*.35),Math.floor(this.cssHeight*.35),"bold",this.dtsColor,"left","bottom"),this.setLenBias();}getValueText(){if(this.dtsValue===null)return "--";let e=this.runtime.options()??o.DEFAULT_CONFIG;return this.dtsValue.toFixed(e?.numDecimal??0)}toHHMMSS(e){if(e==null||isNaN(e))return "-:--";let t=e<0;t&&(e=-e);let a=Math.floor(e/3600),i=Math.floor(e%3600/60),f=Math.floor(e%60),C=t?"-":"";return a===0?`${C}${i.toString().padStart(1,"0")}:${f.toString().padStart(2,"0")}`:`${C}${a.toString().padStart(1,"0")}:${i.toString().padStart(2,"0")}:${f.toString().padStart(2,"0")}`}getTimeToLineText(){return this.toHHMMSS(this.ttlValue??0)}getTimeToBurnText(){return this.toHHMMSS(this.ttbValue??0)}setLenBias(){let e=this.runtime.options()??o.DEFAULT_CONFIG,t=this.pathsRecord.lineLengthPath,a=this.pathsRecord.lineBiasPath;if(t?.path&&this.lengthValue!=null){let i=t.convertUnitTo;i==="feet"&&(i="\u2032"),this.lineLengthValue.set(`\u2015${this.applyDecorations(this.lengthValue.toFixed(e.numDecimal??0))}${i??""}\u2015`);}if(a?.path&&this.biasValue!=null){let i=a.convertUnitTo;i==="feet"&&(i="\u2032"),this.biasValue<0?(this.portBiasValue.set("+"+(-this.biasValue).toFixed(e.numDecimal??0)+(i??"")),this.stbBiasValue.set(this.biasValue.toFixed(e.numDecimal??0)+(i??""))):(this.portBiasValue.set(" "+(-this.biasValue).toFixed(e.numDecimal??0)+(i??"")),this.stbBiasValue.set(" +"+this.biasValue.toFixed(e.numDecimal??0)+(i??"")));}}applyDecorations(e){switch(this.pathsRecord.dtsPath?.convertUnitTo){case "percent":case "percentraw":return e+"%";default:return e}}updateDtsColor(){let e=this.theme(),t=this.runtime.options()??o.DEFAULT_CONFIG;e&&(t.ignoreZones?this.dtsValue?this.dtsValue<0?this.dtsColor=e.zoneAlarm:this.dtsValue<10?this.dtsColor=e.zoneWarn:this.dtsValue<20?this.dtsColor=e.zoneAlert:this.dtsColor=this.valueColor:this.dtsColor=this.valueColor:this.dtsColor=this.valueColor);}beep(e=440,t=100){if(!this.runtime.options()?.playBeeps)return;let a=window.AudioContext||window.webkitAudioContext,i=new a,f=i.createOscillator(),C=i.createGain();f.connect(C),C.connect(i.destination),f.type="sine",f.frequency.value=e,C.gain.value=.1,f.start(),f.stop(i.currentTime+t/1e3);}ngOnDestroy(){try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(e){}}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=JD({type:o,selectors:[["widget-racer-line"]],viewQuery:function(t,a){t&1&&eg(a.canvasRef,J,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:16,vars:2,consts:[["canvasMainRef",""],[1,"line-wrapper"],[1,"filler"],[1,"line-canvas"],[1,"buttons-container"],["mat-flat-button","","matTooltip","Select the control mode",1,"button","select-button",3,"click"],[1,"buttons-svg-icon"],["width","100%","height","100%","viewBox","0 0 80 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","40","y","9"],[1,"widgetOverlay"],[1,"pin-container"],["width","100%","height","100%","viewBox","0 0 70 18","preserveAspectRatio","xMidYMid meet",1,"svg-content","pin"],["x","33","y","14"],[1,"len-bias-container"],["width","100%","height","100%","viewBox","0 0 90 12","preserveAspectRatio","xMidYMid meet",1,"svg-content","len-bias"],["x","45","y","9"],[1,"pin"],[1,"boat"],[1,"boat-container"],["width","100%","height","100%","viewBox","0 0 70 18","preserveAspectRatio","xMidYMid meet",1,"svg-content","boat"],["mat-flat-button","","matTooltip","Set the port(pin) end of the line to the current position",1,"button","port-button",3,"click"],["width","100%","height","100%","viewBox","0 0 100 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","50","y","11"],["mat-flat-button","","matTooltip","Set the starboard(boat) end of the line to the current position",1,"button","starboard-button",3,"click"],["mat-flat-button","","matTooltip","Increase the line length by 5m at the port(pin) end",1,"button","port-small-button",3,"click"],["width","100%","height","100%","viewBox","0 0 50 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","25","y","11"],["mat-flat-button","","matTooltip","Decrease the line length by 5m at the port(pin) end",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Decrease the line length by 5m at the starboard(boat) end",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Increase the line length by 5m at the starboard(boat) end",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the port(pin) end 1\xB0 clockwise",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the port(pin) end 1\xB0 counter-clockwise",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the starboard(boat) end 1\xB0 counter-clockwise",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the starboard(boat) end 1\xB0 clockwise",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Display the next named line",1,"button","select-button",3,"click"],["mat-flat-button","",3,"click","matTooltip"],["width","100%","height","100%","viewBox","0 0 150 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","75","y","11"]],template:function(t,a){if(t&1&&(Pi(0,"div",1)(1,"div",2),$h(2,"canvas",3,0),ul(),Pi(4,"div",4)(5,"button",5),Qh("click",function(){return a.toggleMode()}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",7)(8,"text",8),TT(9,"\u22EE"),ul()()()(),_w(10,Z,16,3)(11,K,10,0)(12,X,20,0)(13,tt,20,0)(14,et,10,6),ul(),_w(15,it,1,0,"div",9),ul()),t&2){let i;EE(10),Mw((i=a.mode())===0?10:i===1?11:i===2?12:i===3?13:i===4?14:-1),EE(5),Mw(a.dashboard.isDashboardStatic()?-1:15);}},dependencies:[Op,xp,yt,wt,zt,mt],styles:["[_nghost-%COMP%]{overflow:clip;display:block;height:100%;width:100%}.line-wrapper[_ngcontent-%COMP%]{width:100%;height:100%;min-height:1px}.line-canvas[_ngcontent-%COMP%]{position:absolute;width:100%!important;height:76%!important;display:block;top:0;left:0}.filler[_ngcontent-%COMP%]{width:100%;height:76%}.buttons-container[_ngcontent-%COMP%]{display:flex;flex-wrap:nowrap;justify-content:space-between;column-gap:2%;position:relative;height:24%;width:100%;padding:0 10px 14px;z-index:20;pointer-events:auto;align-items:center}.button[_ngcontent-%COMP%]{min-width:0px;width:100%;border-radius:12px;align-items:center;justify-content:center;cursor:pointer;--mat-button-filled-container-height: 100%;--mat-button-filled-horizontal-padding: 0px;--mat-button-filled-icon-spacing: 0px}.select-button[_ngcontent-%COMP%]{flex:none;width:18%;--mat-button-filled-container-color: var(--kip-blue-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.line-button[_ngcontent-%COMP%]{flex:none;width:58%;--mat-button-filled-container-color: var(--kip-grey-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.line-button-current[_ngcontent-%COMP%]{flex:none;width:58%;--mat-button-filled-container-color: var(--kip-orange-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.port-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.starboard-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-starboard-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.port-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.starboard-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-starboard-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.buttons-svg-icon[_ngcontent-%COMP%]{width:100%;height:100%;margin:0;padding:0}.svg-content[_ngcontent-%COMP%]{width:100%;height:100%;padding:0;margin:0}.svg-content[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-family:Roboto;font-size:15px;font-weight:700;text-align:center;text-anchor:middle;font-style:normal;font-variant:normal;font-stretch:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke:none}.pin-container[_ngcontent-%COMP%]{flex-basis:18%}.pin[_ngcontent-%COMP%]{fill:var(--kip-port-color)}.pin[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:19px}.len-bias-container[_ngcontent-%COMP%]{flex-basis:35%}.len-bias[_ngcontent-%COMP%]{fill:var(--kip-contrast-color)}.len-bias[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:12px}.boat-container[_ngcontent-%COMP%]{flex-basis:18%}.boat[_ngcontent-%COMP%]{fill:var(--kip-starboard-color)}.boat[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:19px}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent;z-index:21}"]})};export{Q as WidgetRacerLineComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {C,e as e$1}from'./chunk-B6bEhzNR.js';import {g as ge$1}from'./chunk-TakPRI3t.js';import {e9 as a,d1 as Hj,w,du as p,aS as De,bu as ut,aY as xe,$ as $j,v as vt,D as Dt,F as Fa,dn as ge,a_ as Gp,cv as G,cw as z,dx as n$1,J as JD,dC as x,c as $h,cn as wd,_ as _w,B as Bh,e as EE,M as Mw,f as eg,K as Kw,P as Pi,T as TT,u as ul}from'./main-BAV5VDOD.js';import {c,e}from'./chunk-Dxlia2NE.js';var re=["inverterSvg"];function ie(c,e){c&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No inverters detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K inverter paths or select inverters in widget settings."),ul()());}function ne(c){return c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Z=class c$1{static INVERTER_DESCRIPTOR=a("widget-inverter");static SELF_ROOT_PATH=(()=>{let e=c$1.INVERTER_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetInverterComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${c$1.SELF_ROOT_PATH}.*`;static PATH_REGEX=new RegExp(`^${ne(c$1.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 DEFAULT_CONFIG={color:"contrast",ignoreZones:false,inverter:{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("inverterSvg");svg;layer;pendingPathUpdates=new Map;pathBatchTimerId=null;initialPathPaintDone=false;renderFrameId=null;pendingRenderSnapshot=null;discoveredInverterIds=vt([]);trackedDevices=vt([]);optionsById=vt({});cardMode=vt({displayMode:"full",metrics:["dcVoltage","dcCurrent","acVoltage","acFrequency"]});invertersByKey=vt({});visibleInverterKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(i=>i.key);let r=this.invertersByKey(),t=new Set(this.discoveredInverterIds());return Object.keys(r).filter(i=>{let o=r[i];return !!o&&t.has(o.id)}).sort((i,o)=>i.localeCompare(o))});visibleInverters=Dt(()=>{let e=this.visibleInverterKeys(),r=this.invertersByKey();return e.map(t=>r[t]).filter(t=>!!t)});hasInverters=Dt(()=>this.visibleInverters().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.visibleInverters();return e.length!==1?"Inverters":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.visibleInverters(),r=this.theme(),t=this.widgetColors(),i=this.ignoreZones(),o=new Map;e$1.forEach(n=>o.set(n.id,(o.get(n.id)??0)+1));let d=new Set([...o.entries()].filter(([,n])=>n>1).map(([n])=>n)),s={};for(let n of e$1){let l=n.deviceKey??n.id,a=!!n.source&&d.has(n.id),h=this.resolveMostSevereState(n.dcVoltageState??null,n.dcCurrentState??null,n.acVoltageState??null,n.acCurrentState??null,n.acFrequencyState??null,n.temperatureState??null,n.inverterModeState??null),M=this.resolveMostSevereState(n.dcVoltageState??null,n.dcCurrentState??null),b=this.resolveMostSevereState(n.acVoltageState??null,n.acCurrentState??null,n.acFrequencyState??null),[u,x]=this.buildMetricRows(n);s[l]={id:n.id,source:n.source??null,deviceKey:n.deviceKey,titleText:this.resolveTitleText(n),modeText:this.isCompactCardMode()?"":n.inverterMode?`Mode ${n.inverterMode}`:"Mode -",busText:this.isCompactCardMode()?"":a?n.source??"-":n.associatedBus||n.location||"-",metricsLineOne:u,metricsLineTwo:x,stateBarColor:e(h,t?.dim??"var(--kip-contrast-color)",r,i),titleTextColor:e(h,"var(--kip-contrast-color)",r,i),metaTextColor:e(n.inverterModeState??null,"var(--kip-contrast-dim-color)",r,i),primaryMetricsTextColor:e(M,"var(--kip-contrast-color)",r,i),secondaryMetricsTextColor:e(b,"var(--kip-contrast-color)",r,i)};}return s});constructor(){Fa(()=>{let t=this.runtime.options();t&&ge(()=>this.applyConfig(t));}),Fa(()=>{let t=this.displayModels(),i=this.visibleInverters(),o=this.widgetColors();!this.svg||!o||this.requestRender({inverters:i,displayModels:t,widgetColors:o});});let e=[this.data.subscribePathTreeWithInitial(c$1.ROOT_PATTERN)],r=false;for(let t of e)if(t.initial.length){r=true;for(let i of t.initial)this.enqueuePathUpdate(i,true);}r&&(this.flushPendingPathUpdates(),this.initialPathPaintDone=true);for(let t of e)t.live$.pipe(Gp(this.destroyRef)).subscribe(i=>this.enqueuePathUpdate(i));}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 ${c$1.VIEWBOX_WIDTH} ${c$1.CARD_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","Inverter View"),this.layer=this.svg.append("g").attr("class","inverter-layer");}applyConfig(e){let r=this.resolveInverterConfig(e);this.trackedDevices.set(r.trackedDevices??[]),this.reprojectSnapshotsToDeviceKeys(r.trackedDevices??[]),this.optionsById.set(r.optionsById),this.cardMode.set(this.normalizeCardMode(r.cardMode));}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let r=new Map;e.forEach(t=>{let i=r.get(t.id)??[];i.push(t.key),r.set(t.id,i);}),this.invertersByKey.update(t=>{let i=t,o=false;return r.forEach((d,s)=>{let n=t[s];if(n){for(let l of d){if(t[l])continue;let a=e.find(h=>h.key===l);o||(i=G({},t),o=true),i[l]=z(G({},n),{source:a?.source??null,deviceKey:l});}o&&i[s]?.deviceKey===void 0&&delete i[s];}}),o?i:t});}resolveInverterConfig(e){let r=e.inverter;return {trackedDevices:this.normalizeTrackedDevices(r?.trackedDevices),optionsById:this.normalizeOptionsById(r?.optionsById),cardMode:this.normalizeCardMode(r?.cardMode)}}normalizeTrackedDevices(e){if(!Array.isArray(e))return [];let r=new Map;return e.forEach(t=>{if(!t||typeof t!="object")return;let i=t,o=this.normalizeOptionalString(i.id),d=this.normalizeOptionalString(i.source);if(!o||!d)return;let s=this.normalizeOptionalString(i.key)??`${o}||${d}`;r.set(s,{id:o,source:d,key:s});}),[...r.values()].sort((t,i)=>t.key.localeCompare(i.key))}buildIdToDeviceKeysMap(){let e=new Map;return this.trackedDevices().forEach(r=>{let t=e.get(r.id)??[];t.push(r.key),e.set(r.id,t);}),e}normalizeCardMode(e){let r=e&&typeof e=="object"?e:null,t=this.normalizeStringList(r?.metrics);return {displayMode:r?.displayMode==="compact"?"compact":"full",metrics:t.length?t:["dcVoltage","dcCurrent","acVoltage","acFrequency"]}}normalizeStringList(e){if(!Array.isArray(e))return [];let r=new Set;return e.forEach(t=>{if(typeof t!="string")return;let i=t.trim();i.length>0&&r.add(i);}),[...r].sort((t,i)=>t.localeCompare(i))}normalizeOptionsById(e){if(!e||typeof e!="object")return {};let r={};return Object.entries(e).forEach(([t])=>{let i=this.normalizeOptionalString(t);i&&(r[i]={});}),r}normalizeOptionalString(e){if(typeof e!="string")return null;let r=e.trim();return r.length>0?r:null}enqueuePathUpdate(e,r=false){let t=this.parsePath(e.path);if(!t)return;let i=e.update?.data?.value??null,o=e.update?.state??null;if(this.pendingPathUpdates.set(`${t.id}::${t.key}`,{id:t.id,key:t.key,value:i,state:o}),!r){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=window.setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},c$1.PATH_BATCH_WINDOW_MS));}}parsePath(e){let r=e.match(c$1.PATH_REGEX);return r?{id:r[1],key:r[2]}:null}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let e=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(e.map(i=>i.id)).forEach(i=>this.trackDiscoveredInverter(i));let t=this.buildIdToDeviceKeysMap();this.invertersByKey.update(i=>{let o=i,d=false;for(let s of e){let n=t.get(s.id),l=n?.length?n:[s.id];for(let a of l){let h=!!n?.length,M=h?this.trackedDevices().find(I=>I.key===a):null,b=o[a]??{id:s.id,source:M?.source??null,deviceKey:h?a:void 0},u=G({},b);if(this.applyValue(u,s.key,s.value,s.state)){if(u.dcVoltage!=null&&u.dcCurrent!=null){let I=u.dcVoltage*u.dcCurrent;u.dcPower=Number.isFinite(I)?I:null,u.dcPowerState=this.resolveMostSevereState(u.dcVoltageState??null,u.dcCurrentState??null);}else u.dcPower=null,u.dcPowerState=null;d||(o=G({},o),d=true),o[a]=u;}}}return d?o:i});}trackDiscoveredInverter(e){let r=this.discoveredInverterIds();r.includes(e)||this.discoveredInverterIds.set([...r,e].sort((t,i)=>t.localeCompare(i)));}applyValue(e,r,t,i){switch(r){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 "dc.voltage":return this.setMetricValue(e,"dcVoltage","dcVoltageState",this.toNumber(t,"V"),i);case "dc.current":return this.setMetricValue(e,"dcCurrent","dcCurrentState",this.toNumber(t,"A"),i);case "acin.voltage":return this.setMetricValue(e,"acInVoltage","acInVoltageState",this.toNumber(t,"V"),i);case "acin.current":return this.setMetricValue(e,"acInCurrent","acInCurrentState",this.toNumber(t,"A"),i);case "acin.frequency":return this.setMetricValue(e,"acInFrequency","acInFrequencyState",this.toNumber(t,"Hz"),i);case "acin.power":return this.setMetricValue(e,"acInPower","acInPowerState",this.toNumber(t,"W"),i);case "acin.1.currentLimit":return this.setMetricValue(e,"acIn1CurrentLimit","acIn1CurrentLimitState",this.toNumber(t,"A"),i);case "acin.currentLimit":return this.setMetricValue(e,"acInCurrentLimit","acInCurrentLimitState",this.toNumber(t,"A"),i);case "acState.acIn1Available":return this.setMetricValue(e,"acIn1Available","acIn1AvailableState",this.toBoolean(t),i);case "acState.ignoreAcIn1.state":return this.setMetricValue(e,"ignoreAcIn1","ignoreAcIn1State",this.toBoolean(t),i);case "ac.voltage":return this.setMetricValue(e,"acVoltage","acVoltageState",this.toNumber(t,"V"),i);case "ac.current":return this.setMetricValue(e,"acCurrent","acCurrentState",this.toNumber(t,"A"),i);case "ac.frequency":return this.setMetricValue(e,"acFrequency","acFrequencyState",this.toNumber(t,"Hz"),i);case "acout.voltage":return this.setMetricValue(e,"acOutVoltage","acOutVoltageState",this.toNumber(t,"V"),i);case "acout.current":return this.setMetricValue(e,"acOutCurrent","acOutCurrentState",this.toNumber(t,"A"),i);case "acout.frequency":return this.setMetricValue(e,"acOutFrequency","acOutFrequencyState",this.toNumber(t,"Hz"),i);case "acout.power":return this.setMetricValue(e,"acOutPower","acOutPowerState",this.toNumber(t,"W"),i);case "inverterMode":return this.setMetricValue(e,"inverterMode","inverterModeState",this.toStringValue(t),i);case "inverterModeNumber":return this.setMetricValue(e,"inverterModeNumber","inverterModeNumberState",this.toNumber(t,""),i);case "preferRenewableEnergy":return this.setMetricValue(e,"preferRenewableEnergy","preferRenewableEnergyState",this.toBoolean(t),i);case "preferRenewableEnergyActive":return this.setMetricValue(e,"preferRenewableEnergyActive","preferRenewableEnergyActiveState",this.toBoolean(t),i);case "temperature":return this.setMetricValue(e,"temperature","temperatureState",this.toNumber(t,this.units.getDefaults().Temperature),i);default:return false}}setValue(e,r,t){return Object.is(e[r],t)?false:(e[r]=t,true)}setMetricValue(e,r,t,i,o){let d=!Object.is(e[r],i),s=!Object.is(e[t],o);return !d&&!s?false:(e[r]=i,e[t]=o,true)}requestRender(e){let r=this.widgetColors();!this.svg||!r||(this.pendingRenderSnapshot=e??{inverters:this.visibleInverters(),displayModels:this.displayModels(),widgetColors:r},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 r=this.isCompactCardMode(),t=r?C:e$1,i=r?c$1.COMPACT_CARD_HEIGHT:c$1.CARD_HEIGHT,o=e.inverters.map((a,h)=>({key:a.deviceKey??a.id,inverter:a,y:h*(i+c$1.CARD_GAP)})),d=o.length?o[o.length-1].y+i:i;this.svg.attr("viewBox",`0 0 ${c$1.VIEWBOX_WIDTH} ${d}`);let s=this.layer.selectAll("g.inverter-card").data(o,a=>a.key),n=s.enter().append("g").attr("class","inverter-card");n.append("rect").attr("class","inverter-card-bg"),n.append("rect").attr("class","inverter-state-bar"),n.append("text").attr("class","inverter-title"),n.append("text").attr("class","inverter-id"),n.append("text").attr("class","inverter-mode"),n.append("text").attr("class","inverter-bus"),n.append("text").attr("class","inverter-metrics-1"),n.append("text").attr("class","inverter-metrics-2");let l=n.merge(s);l.attr("transform",a=>`translate(0, ${a.y})`),l.select("rect.inverter-card-bg").attr("x",.5).attr("y",.5).attr("rx",t.cardCornerRadius).attr("ry",t.cardCornerRadius).attr("width",c$1.VIEWBOX_WIDTH-1).attr("height",i-1).attr("stroke","var(--mat-sys-outline-variant)").attr("stroke-width",.5).attr("fill","none"),l.select("rect.inverter-state-bar").attr("x",1.5).attr("y",1.5).attr("rx",t.stateBarCornerRadius).attr("ry",t.stateBarCornerRadius).attr("width",3).attr("height",i-3).attr("fill",a=>e.displayModels[a.key]?.stateBarColor??e.widgetColors.dim),e.inverters.length>1?l.select("text.inverter-title").attr("x",t.titleX).attr("y",t.titleY).attr("font-size",t.titleFontSize).attr("fill",a=>e.displayModels[a.key]?.titleTextColor??"var(--kip-contrast-color)").text(a=>e.displayModels[a.key]?.titleText??this.resolveTitleText(a.inverter)):l.select("text.inverter-title").text(""),l.select("text.inverter-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(a=>a.inverter.id),l.select("text.inverter-mode").attr("x",t.metaLeftX).attr("y",t.metaY).attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",a=>e.displayModels[a.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(a=>e.displayModels[a.key]?.modeText??""),l.select("text.inverter-bus").attr("x",t.metaRightX).attr("y",t.metaY).attr("text-anchor","end").attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",a=>e.displayModels[a.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(a=>e.displayModels[a.key]?.busText??""),l.select("text.inverter-metrics-1").attr("x",t.lineOneX).attr("y",t.lineOneY).attr("font-size",t.lineOneFontSize).attr("fill",a=>e.displayModels[a.key]?.primaryMetricsTextColor??"var(--kip-contrast-color)").text(a=>e.displayModels[a.key]?.metricsLineOne??""),l.select("text.inverter-metrics-2").attr("x",t.lineTwoX).attr("y",t.lineTwoY).attr("font-size",t.lineTwoFontSize).attr("opacity",.85).attr("fill",a=>e.displayModels[a.key]?.secondaryMetricsTextColor??"var(--kip-contrast-color)").text(a=>e.displayModels[a.key]?.metricsLineTwo??""),s.exit().remove();}displayName(e){return e.name?.trim()||e.id}resolveTitleText(e){return e.name||`Inverter ${e.id}`}buildMetricRows(e){let r=this.cardMode();if(this.activeDisplayMode()==="full"){let i=e.acInVoltage!=null||e.acInCurrent!=null,o=this.formatValue(e.acInVoltage,"V"),d=this.formatValue(e.acInCurrent,"A"),s=this.formatValue(e.acOutVoltage??e.acVoltage,"V"),n=this.formatValue(e.acOutFrequency??e.acFrequency,"Hz");return [`DC ${this.formatValue(e.dcVoltage,"V")} ${this.formatValue(e.dcCurrent,"A")}`,i?`ACin ${o} ${d}`:`AC ${s} ${n}`]}let t=r.metrics.map(i=>this.toMetricLabel(i,e)).filter(i=>!!i);return t.length?[t.slice(0,2).join(" ")||" ",t.slice(2,4).join(" ")||" "]:["DC - -","AC - -"]}toMetricLabel(e,r){switch(e){case "dcVoltage":return `DC V ${this.formatValue(r.dcVoltage,"V")}`;case "dcCurrent":return `DC A ${this.formatValue(r.dcCurrent,"A")}`;case "dcPower":return `DC P ${this.formatValue(r.dcPower,"W")}`;case "acVoltage":return `AC V ${this.formatValue(r.acVoltage,"V")}`;case "acCurrent":return `AC A ${this.formatValue(r.acCurrent,"A")}`;case "acFrequency":return `Hz ${this.formatValue(r.acFrequency,"Hz")}`;case "acInVoltage":return `ACin V ${this.formatValue(r.acInVoltage,"V")}`;case "acInCurrent":return `ACin A ${this.formatValue(r.acInCurrent,"A")}`;case "acInFrequency":return `ACin Hz ${this.formatValue(r.acInFrequency,"Hz")}`;case "acInPower":return `ACin P ${this.formatValue(r.acInPower,"W")}`;case "acOutVoltage":return `ACout V ${this.formatValue(r.acOutVoltage,"V")}`;case "acOutCurrent":return `ACout A ${this.formatValue(r.acOutCurrent,"A")}`;case "acOutFrequency":return `ACout Hz ${this.formatValue(r.acOutFrequency,"Hz")}`;case "acOutPower":return `ACout P ${this.formatValue(r.acOutPower,"W")}`;case "acIn1CurrentLimit":return `ACin1 Lim ${this.formatValue(r.acIn1CurrentLimit,"A")}`;case "acInCurrentLimit":return `ACin Lim ${this.formatValue(r.acInCurrentLimit,"A")}`;case "temperature":return `T ${this.formatTemperature(r.temperature)}`;case "inverterModeNumber":return `Mode# ${r.inverterModeNumber?.toString()??"-"}`;default:return null}}formatValue(e,r){return e==null||Number.isNaN(e)?"-":`${e.toFixed(1)} ${r}`}formatTemperature(e){return e==null||Number.isNaN(e)?"-":`${e.toFixed(1)} ${this.units.getDefaults().Temperature==="celsius"?"\xB0C":"\xB0F"}`}toStringValue(e){return typeof e=="string"?e:null}resolveMostSevereState(...e){return e.some(r=>r===n$1.Alert)?n$1.Alert:e.some(r=>r===n$1.Alarm)?n$1.Alarm:e.some(r=>r===n$1.Warn)?n$1.Warn:e.some(r=>r===n$1.Normal)?n$1.Normal:null}toNumber(e,r){if(e==null||typeof e=="boolean")return null;let t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return null;let i=this.units.convertToUnit(r,t);return typeof i=="number"&&Number.isFinite(i)?i:null}toBoolean(e){if(typeof e=="boolean")return e;if(typeof e=="number"){if(e===1)return true;if(e===0)return false}if(typeof e=="string"){let r=e.trim().toLowerCase();if(r==="true"||r==="1"||r==="on")return true;if(r==="false"||r==="0"||r==="off")return false}return null}static \u0275fac=function(r){return new(r||c$1)};static \u0275cmp=JD({type:c$1,selectors:[["widget-inverter"]],viewQuery:function(r,t){r&1&&eg(t.svgRef,re,5),r&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["inverterSvg",""],[3,"text","color"],["aria-hidden","false",1,"inverter-svg"],[1,"inverter-empty"],[1,"inverter-empty-title"],[1,"inverter-empty-sub"]],template:function(r,t){r&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,ie,5,0,"div",3)),r&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasInverters()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.inverter-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}.inverter-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)}.inverter-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.inverter-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{Z as WidgetInverterComponent};
|
|
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 re=["inverterSvg"];function ie(c,e){c&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No inverters detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K inverter paths or select inverters in widget settings."),ul()());}function ne(c){return c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Z=class c$1{static INVERTER_DESCRIPTOR=a("widget-inverter");static SELF_ROOT_PATH=(()=>{let e=c$1.INVERTER_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetInverterComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${c$1.SELF_ROOT_PATH}.*`;static PATH_REGEX=new RegExp(`^${ne(c$1.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 DEFAULT_CONFIG={color:"contrast",ignoreZones:false,inverter:{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("inverterSvg");svg;layer;pendingPathUpdates=new Map;pathBatchTimerId=null;initialPathPaintDone=false;renderFrameId=null;pendingRenderSnapshot=null;discoveredInverterIds=vt([]);trackedDevices=vt([]);optionsById=vt({});cardMode=vt({displayMode:"full",metrics:["dcVoltage","dcCurrent","acVoltage","acFrequency"]});invertersByKey=vt({});visibleInverterKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(i=>i.key);let r=this.invertersByKey(),t=new Set(this.discoveredInverterIds());return Object.keys(r).filter(i=>{let o=r[i];return !!o&&t.has(o.id)}).sort((i,o)=>i.localeCompare(o))});visibleInverters=Dt(()=>{let e=this.visibleInverterKeys(),r=this.invertersByKey();return e.map(t=>r[t]).filter(t=>!!t)});hasInverters=Dt(()=>this.visibleInverters().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.visibleInverters();return e.length!==1?"Inverters":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.visibleInverters(),r=this.theme(),t=this.widgetColors(),i=this.ignoreZones(),o=new Map;e$1.forEach(n=>o.set(n.id,(o.get(n.id)??0)+1));let d=new Set([...o.entries()].filter(([,n])=>n>1).map(([n])=>n)),s={};for(let n of e$1){let l=n.deviceKey??n.id,a=!!n.source&&d.has(n.id),h=this.resolveMostSevereState(n.dcVoltageState??null,n.dcCurrentState??null,n.acVoltageState??null,n.acCurrentState??null,n.acFrequencyState??null,n.temperatureState??null,n.inverterModeState??null),M=this.resolveMostSevereState(n.dcVoltageState??null,n.dcCurrentState??null),b=this.resolveMostSevereState(n.acVoltageState??null,n.acCurrentState??null,n.acFrequencyState??null),[u,x]=this.buildMetricRows(n);s[l]={id:n.id,source:n.source??null,deviceKey:n.deviceKey,titleText:this.resolveTitleText(n),modeText:this.isCompactCardMode()?"":n.inverterMode?`Mode ${n.inverterMode}`:"Mode -",busText:this.isCompactCardMode()?"":a?n.source??"-":n.associatedBus||n.location||"-",metricsLineOne:u,metricsLineTwo:x,stateBarColor:e(h,t?.dim??"var(--kip-contrast-color)",r,i),titleTextColor:e(h,"var(--kip-contrast-color)",r,i),metaTextColor:e(n.inverterModeState??null,"var(--kip-contrast-dim-color)",r,i),primaryMetricsTextColor:e(M,"var(--kip-contrast-color)",r,i),secondaryMetricsTextColor:e(b,"var(--kip-contrast-color)",r,i)};}return s});constructor(){Fa(()=>{let t=this.runtime.options();t&&ge(()=>this.applyConfig(t));}),Fa(()=>{let t=this.displayModels(),i=this.visibleInverters(),o=this.widgetColors();!this.svg||!o||this.requestRender({inverters:i,displayModels:t,widgetColors:o});});let e=[this.data.subscribePathTreeWithInitial(c$1.ROOT_PATTERN)],r=false;for(let t of e)if(t.initial.length){r=true;for(let i of t.initial)this.enqueuePathUpdate(i,true);}r&&(this.flushPendingPathUpdates(),this.initialPathPaintDone=true);for(let t of e)t.live$.pipe(Gp(this.destroyRef)).subscribe(i=>this.enqueuePathUpdate(i));}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 ${c$1.VIEWBOX_WIDTH} ${c$1.CARD_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","Inverter View"),this.layer=this.svg.append("g").attr("class","inverter-layer");}applyConfig(e){let r=this.resolveInverterConfig(e);this.trackedDevices.set(r.trackedDevices??[]),this.reprojectSnapshotsToDeviceKeys(r.trackedDevices??[]),this.optionsById.set(r.optionsById),this.cardMode.set(this.normalizeCardMode(r.cardMode));}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let r=new Map;e.forEach(t=>{let i=r.get(t.id)??[];i.push(t.key),r.set(t.id,i);}),this.invertersByKey.update(t=>{let i=t,o=false;return r.forEach((d,s)=>{let n=t[s];if(n){for(let l of d){if(t[l])continue;let a=e.find(h=>h.key===l);o||(i=G({},t),o=true),i[l]=z(G({},n),{source:a?.source??null,deviceKey:l});}o&&i[s]?.deviceKey===void 0&&delete i[s];}}),o?i:t});}resolveInverterConfig(e){let r=e.inverter;return {trackedDevices:this.normalizeTrackedDevices(r?.trackedDevices),optionsById:this.normalizeOptionsById(r?.optionsById),cardMode:this.normalizeCardMode(r?.cardMode)}}normalizeTrackedDevices(e){if(!Array.isArray(e))return [];let r=new Map;return e.forEach(t=>{if(!t||typeof t!="object")return;let i=t,o=this.normalizeOptionalString(i.id),d=this.normalizeOptionalString(i.source);if(!o||!d)return;let s=this.normalizeOptionalString(i.key)??`${o}||${d}`;r.set(s,{id:o,source:d,key:s});}),[...r.values()].sort((t,i)=>t.key.localeCompare(i.key))}buildIdToDeviceKeysMap(){let e=new Map;return this.trackedDevices().forEach(r=>{let t=e.get(r.id)??[];t.push(r.key),e.set(r.id,t);}),e}normalizeCardMode(e){let r=e&&typeof e=="object"?e:null,t=this.normalizeStringList(r?.metrics);return {displayMode:r?.displayMode==="compact"?"compact":"full",metrics:t.length?t:["dcVoltage","dcCurrent","acVoltage","acFrequency"]}}normalizeStringList(e){if(!Array.isArray(e))return [];let r=new Set;return e.forEach(t=>{if(typeof t!="string")return;let i=t.trim();i.length>0&&r.add(i);}),[...r].sort((t,i)=>t.localeCompare(i))}normalizeOptionsById(e){if(!e||typeof e!="object")return {};let r={};return Object.entries(e).forEach(([t])=>{let i=this.normalizeOptionalString(t);i&&(r[i]={});}),r}normalizeOptionalString(e){if(typeof e!="string")return null;let r=e.trim();return r.length>0?r:null}enqueuePathUpdate(e,r=false){let t=this.parsePath(e.path);if(!t)return;let i=e.update?.data?.value??null,o=e.update?.state??null;if(this.pendingPathUpdates.set(`${t.id}::${t.key}`,{id:t.id,key:t.key,value:i,state:o}),!r){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=window.setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},c$1.PATH_BATCH_WINDOW_MS));}}parsePath(e){let r=e.match(c$1.PATH_REGEX);return r?{id:r[1],key:r[2]}:null}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let e=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(e.map(i=>i.id)).forEach(i=>this.trackDiscoveredInverter(i));let t=this.buildIdToDeviceKeysMap();this.invertersByKey.update(i=>{let o=i,d=false;for(let s of e){let n=t.get(s.id),l=n?.length?n:[s.id];for(let a of l){let h=!!n?.length,M=h?this.trackedDevices().find(I=>I.key===a):null,b=o[a]??{id:s.id,source:M?.source??null,deviceKey:h?a:void 0},u=G({},b);if(this.applyValue(u,s.key,s.value,s.state)){if(u.dcVoltage!=null&&u.dcCurrent!=null){let I=u.dcVoltage*u.dcCurrent;u.dcPower=Number.isFinite(I)?I:null,u.dcPowerState=this.resolveMostSevereState(u.dcVoltageState??null,u.dcCurrentState??null);}else u.dcPower=null,u.dcPowerState=null;d||(o=G({},o),d=true),o[a]=u;}}}return d?o:i});}trackDiscoveredInverter(e){let r=this.discoveredInverterIds();r.includes(e)||this.discoveredInverterIds.set([...r,e].sort((t,i)=>t.localeCompare(i)));}applyValue(e,r,t,i){switch(r){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 "dc.voltage":return this.setMetricValue(e,"dcVoltage","dcVoltageState",this.toNumber(t,"V"),i);case "dc.current":return this.setMetricValue(e,"dcCurrent","dcCurrentState",this.toNumber(t,"A"),i);case "acin.voltage":return this.setMetricValue(e,"acInVoltage","acInVoltageState",this.toNumber(t,"V"),i);case "acin.current":return this.setMetricValue(e,"acInCurrent","acInCurrentState",this.toNumber(t,"A"),i);case "acin.frequency":return this.setMetricValue(e,"acInFrequency","acInFrequencyState",this.toNumber(t,"Hz"),i);case "acin.power":return this.setMetricValue(e,"acInPower","acInPowerState",this.toNumber(t,"W"),i);case "acin.1.currentLimit":return this.setMetricValue(e,"acIn1CurrentLimit","acIn1CurrentLimitState",this.toNumber(t,"A"),i);case "acin.currentLimit":return this.setMetricValue(e,"acInCurrentLimit","acInCurrentLimitState",this.toNumber(t,"A"),i);case "acState.acIn1Available":return this.setMetricValue(e,"acIn1Available","acIn1AvailableState",this.toBoolean(t),i);case "acState.ignoreAcIn1.state":return this.setMetricValue(e,"ignoreAcIn1","ignoreAcIn1State",this.toBoolean(t),i);case "ac.voltage":return this.setMetricValue(e,"acVoltage","acVoltageState",this.toNumber(t,"V"),i);case "ac.current":return this.setMetricValue(e,"acCurrent","acCurrentState",this.toNumber(t,"A"),i);case "ac.frequency":return this.setMetricValue(e,"acFrequency","acFrequencyState",this.toNumber(t,"Hz"),i);case "acout.voltage":return this.setMetricValue(e,"acOutVoltage","acOutVoltageState",this.toNumber(t,"V"),i);case "acout.current":return this.setMetricValue(e,"acOutCurrent","acOutCurrentState",this.toNumber(t,"A"),i);case "acout.frequency":return this.setMetricValue(e,"acOutFrequency","acOutFrequencyState",this.toNumber(t,"Hz"),i);case "acout.power":return this.setMetricValue(e,"acOutPower","acOutPowerState",this.toNumber(t,"W"),i);case "inverterMode":return this.setMetricValue(e,"inverterMode","inverterModeState",this.toStringValue(t),i);case "inverterModeNumber":return this.setMetricValue(e,"inverterModeNumber","inverterModeNumberState",this.toNumber(t,""),i);case "preferRenewableEnergy":return this.setMetricValue(e,"preferRenewableEnergy","preferRenewableEnergyState",this.toBoolean(t),i);case "preferRenewableEnergyActive":return this.setMetricValue(e,"preferRenewableEnergyActive","preferRenewableEnergyActiveState",this.toBoolean(t),i);case "temperature":return this.setMetricValue(e,"temperature","temperatureState",this.toNumber(t,this.units.getDefaults().Temperature),i);default:return false}}setValue(e,r,t){return Object.is(e[r],t)?false:(e[r]=t,true)}setMetricValue(e,r,t,i,o){let d=!Object.is(e[r],i),s=!Object.is(e[t],o);return !d&&!s?false:(e[r]=i,e[t]=o,true)}requestRender(e){let r=this.widgetColors();!this.svg||!r||(this.pendingRenderSnapshot=e??{inverters:this.visibleInverters(),displayModels:this.displayModels(),widgetColors:r},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 r=this.isCompactCardMode(),t=r?C:e$1,i=r?c$1.COMPACT_CARD_HEIGHT:c$1.CARD_HEIGHT,o=e.inverters.map((a,h)=>({key:a.deviceKey??a.id,inverter:a,y:h*(i+c$1.CARD_GAP)})),d=o.length?o[o.length-1].y+i:i;this.svg.attr("viewBox",`0 0 ${c$1.VIEWBOX_WIDTH} ${d}`);let s=this.layer.selectAll("g.inverter-card").data(o,a=>a.key),n=s.enter().append("g").attr("class","inverter-card");n.append("rect").attr("class","inverter-card-bg"),n.append("rect").attr("class","inverter-state-bar"),n.append("text").attr("class","inverter-title"),n.append("text").attr("class","inverter-id"),n.append("text").attr("class","inverter-mode"),n.append("text").attr("class","inverter-bus"),n.append("text").attr("class","inverter-metrics-1"),n.append("text").attr("class","inverter-metrics-2");let l=n.merge(s);l.attr("transform",a=>`translate(0, ${a.y})`),l.select("rect.inverter-card-bg").attr("x",.5).attr("y",.5).attr("rx",t.cardCornerRadius).attr("ry",t.cardCornerRadius).attr("width",c$1.VIEWBOX_WIDTH-1).attr("height",i-1).attr("stroke","var(--mat-sys-outline-variant)").attr("stroke-width",.5).attr("fill","none"),l.select("rect.inverter-state-bar").attr("x",1.5).attr("y",1.5).attr("rx",t.stateBarCornerRadius).attr("ry",t.stateBarCornerRadius).attr("width",3).attr("height",i-3).attr("fill",a=>e.displayModels[a.key]?.stateBarColor??e.widgetColors.dim),e.inverters.length>1?l.select("text.inverter-title").attr("x",t.titleX).attr("y",t.titleY).attr("font-size",t.titleFontSize).attr("fill",a=>e.displayModels[a.key]?.titleTextColor??"var(--kip-contrast-color)").text(a=>e.displayModels[a.key]?.titleText??this.resolveTitleText(a.inverter)):l.select("text.inverter-title").text(""),l.select("text.inverter-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(a=>a.inverter.id),l.select("text.inverter-mode").attr("x",t.metaLeftX).attr("y",t.metaY).attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",a=>e.displayModels[a.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(a=>e.displayModels[a.key]?.modeText??""),l.select("text.inverter-bus").attr("x",t.metaRightX).attr("y",t.metaY).attr("text-anchor","end").attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",a=>e.displayModels[a.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(a=>e.displayModels[a.key]?.busText??""),l.select("text.inverter-metrics-1").attr("x",t.lineOneX).attr("y",t.lineOneY).attr("font-size",t.lineOneFontSize).attr("fill",a=>e.displayModels[a.key]?.primaryMetricsTextColor??"var(--kip-contrast-color)").text(a=>e.displayModels[a.key]?.metricsLineOne??""),l.select("text.inverter-metrics-2").attr("x",t.lineTwoX).attr("y",t.lineTwoY).attr("font-size",t.lineTwoFontSize).attr("opacity",.85).attr("fill",a=>e.displayModels[a.key]?.secondaryMetricsTextColor??"var(--kip-contrast-color)").text(a=>e.displayModels[a.key]?.metricsLineTwo??""),s.exit().remove();}displayName(e){return e.name?.trim()||e.id}resolveTitleText(e){return e.name||`Inverter ${e.id}`}buildMetricRows(e){let r=this.cardMode();if(this.activeDisplayMode()==="full"){let i=e.acInVoltage!=null||e.acInCurrent!=null,o=this.formatValue(e.acInVoltage,"V"),d=this.formatValue(e.acInCurrent,"A"),s=this.formatValue(e.acOutVoltage??e.acVoltage,"V"),n=this.formatValue(e.acOutFrequency??e.acFrequency,"Hz");return [`DC ${this.formatValue(e.dcVoltage,"V")} ${this.formatValue(e.dcCurrent,"A")}`,i?`ACin ${o} ${d}`:`AC ${s} ${n}`]}let t=r.metrics.map(i=>this.toMetricLabel(i,e)).filter(i=>!!i);return t.length?[t.slice(0,2).join(" ")||" ",t.slice(2,4).join(" ")||" "]:["DC - -","AC - -"]}toMetricLabel(e,r){switch(e){case "dcVoltage":return `DC V ${this.formatValue(r.dcVoltage,"V")}`;case "dcCurrent":return `DC A ${this.formatValue(r.dcCurrent,"A")}`;case "dcPower":return `DC P ${this.formatValue(r.dcPower,"W")}`;case "acVoltage":return `AC V ${this.formatValue(r.acVoltage,"V")}`;case "acCurrent":return `AC A ${this.formatValue(r.acCurrent,"A")}`;case "acFrequency":return `Hz ${this.formatValue(r.acFrequency,"Hz")}`;case "acInVoltage":return `ACin V ${this.formatValue(r.acInVoltage,"V")}`;case "acInCurrent":return `ACin A ${this.formatValue(r.acInCurrent,"A")}`;case "acInFrequency":return `ACin Hz ${this.formatValue(r.acInFrequency,"Hz")}`;case "acInPower":return `ACin P ${this.formatValue(r.acInPower,"W")}`;case "acOutVoltage":return `ACout V ${this.formatValue(r.acOutVoltage,"V")}`;case "acOutCurrent":return `ACout A ${this.formatValue(r.acOutCurrent,"A")}`;case "acOutFrequency":return `ACout Hz ${this.formatValue(r.acOutFrequency,"Hz")}`;case "acOutPower":return `ACout P ${this.formatValue(r.acOutPower,"W")}`;case "acIn1CurrentLimit":return `ACin1 Lim ${this.formatValue(r.acIn1CurrentLimit,"A")}`;case "acInCurrentLimit":return `ACin Lim ${this.formatValue(r.acInCurrentLimit,"A")}`;case "temperature":return `T ${this.formatTemperature(r.temperature)}`;case "inverterModeNumber":return `Mode# ${r.inverterModeNumber?.toString()??"-"}`;default:return null}}formatValue(e,r){return e==null||Number.isNaN(e)?"-":`${e.toFixed(1)} ${r}`}formatTemperature(e){return e==null||Number.isNaN(e)?"-":`${e.toFixed(1)} ${this.units.getDefaults().Temperature==="celsius"?"\xB0C":"\xB0F"}`}toStringValue(e){return typeof e=="string"?e:null}resolveMostSevereState(...e){return e.some(r=>r===n$1.Alert)?n$1.Alert:e.some(r=>r===n$1.Alarm)?n$1.Alarm:e.some(r=>r===n$1.Warn)?n$1.Warn:e.some(r=>r===n$1.Normal)?n$1.Normal:null}toNumber(e,r){if(e==null||typeof e=="boolean")return null;let t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return null;let i=this.units.convertToUnit(r,t);return typeof i=="number"&&Number.isFinite(i)?i:null}toBoolean(e){if(typeof e=="boolean")return e;if(typeof e=="number"){if(e===1)return true;if(e===0)return false}if(typeof e=="string"){let r=e.trim().toLowerCase();if(r==="true"||r==="1"||r==="on")return true;if(r==="false"||r==="0"||r==="off")return false}return null}static \u0275fac=function(r){return new(r||c$1)};static \u0275cmp=JD({type:c$1,selectors:[["widget-inverter"]],viewQuery:function(r,t){r&1&&eg(t.svgRef,re,5),r&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["inverterSvg",""],[3,"text","color"],["aria-hidden","false",1,"inverter-svg"],[1,"inverter-empty"],[1,"inverter-empty-title"],[1,"inverter-empty-sub"]],template:function(r,t){r&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,ie,5,0,"div",3)),r&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasInverters()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.inverter-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}.inverter-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)}.inverter-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.inverter-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{Z as WidgetInverterComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {e as e$1}from'./chunk-B6bEhzNR.js';import {g as ge$1}from'./chunk-TakPRI3t.js';import {e9 as a,d1 as Hj,w,du as p,aS as De,bu as ut,ea as K,aY as xe,$ as $j,v as vt,D as Dt,dx as n$1,F as Fa,dn as ge,a_ as Gp,av as _t,cv as G,J as JD,y as yt,dC as x,_ as _w,cn as wd,c as $h,M as Mw,e as EE,s as sg,f as eg,K as Kw,g as qw,B as Bh,P as Pi,T as TT,u as ul}from'./main-BAV5VDOD.js';import {c,e}from'./chunk-Dxlia2NE.js';function H(i){return function(){return i}}var Mt=Math.abs,_=Math.atan2,z=Math.cos,qt=Math.max,rt=Math.min,$=Math.sin,W=Math.sqrt,S=1e-12,Z=Math.PI,tt=Z/2,Xt=2*Z;function jt(i){return i>1?0:i<-1?Z:Math.acos(i)}function Tt(i){return i>=1?tt:i<=-1?-tt:Math.asin(i)}var Ct=Math.PI,At=2*Ct,L=1e-6,ae=At-L;function Zt(i){this._+=i[0];for(let t=1,a=i.length;t<a;++t)this._+=arguments[t]+i[t];}function re(i){let t=Math.floor(i);if(!(t>=0))throw new Error(`invalid digits: ${i}`);if(t>15)return Zt;let a=10**t;return function(r){this._+=r[0];for(let e=1,n=r.length;e<n;++e)this._+=Math.round(arguments[e]*a)/a+r[e];}}var F=class{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?Zt:re(t);}moveTo(t,a){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+a}`;}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`);}lineTo(t,a){this._append`L${this._x1=+t},${this._y1=+a}`;}quadraticCurveTo(t,a,r,e){this._append`Q${+t},${+a},${this._x1=+r},${this._y1=+e}`;}bezierCurveTo(t,a,r,e,n,o){this._append`C${+t},${+a},${+r},${+e},${this._x1=+n},${this._y1=+o}`;}arcTo(t,a,r,e,n){if(t=+t,a=+a,r=+r,e=+e,n=+n,n<0)throw new Error(`negative radius: ${n}`);let o=this._x1,l=this._y1,m=r-t,d=e-a,s=o-t,g=l-a,c=s*s+g*g;if(this._x1===null)this._append`M${this._x1=t},${this._y1=a}`;else if(c>L)if(!(Math.abs(g*m-d*s)>L)||!n)this._append`L${this._x1=t},${this._y1=a}`;else {let y=r-o,v=e-l,k=m*m+d*d,R=y*y+v*v,x=Math.sqrt(k),h=Math.sqrt(c),M=n*Math.tan((Ct-Math.acos((k+c-R)/(2*x*h)))/2),T=M/h,f=M/x;Math.abs(T-1)>L&&this._append`L${t+T*s},${a+T*g}`,this._append`A${n},${n},0,0,${+(g*y>s*v)},${this._x1=t+f*m},${this._y1=a+f*d}`;}}arc(t,a,r,e,n,o){if(t=+t,a=+a,r=+r,o=!!o,r<0)throw new Error(`negative radius: ${r}`);let l=r*Math.cos(e),m=r*Math.sin(e),d=t+l,s=a+m,g=1^o,c=o?e-n:n-e;this._x1===null?this._append`M${d},${s}`:(Math.abs(this._x1-d)>L||Math.abs(this._y1-s)>L)&&this._append`L${d},${s}`,r&&(c<0&&(c=c%At+At),c>ae?this._append`A${r},${r},0,1,${g},${t-l},${a-m}A${r},${r},0,1,${g},${this._x1=d},${this._y1=s}`:c>L&&this._append`A${r},${r},0,${+(c>=Ct)},${g},${this._x1=t+r*Math.cos(n)},${this._y1=a+r*Math.sin(n)}`);}rect(t,a,r,e){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+a}h${r=+r}v${+e}h${-r}Z`;}toString(){return this._}};function Jt(i){let t=3;return i.digits=function(a){if(!arguments.length)return t;if(a==null)t=null;else {let r=Math.floor(a);if(!(r>=0))throw new RangeError(`invalid digits: ${a}`);t=r;}return i},()=>new F(t)}function ne(i){return i.innerRadius}function ie(i){return i.outerRadius}function se(i){return i.startAngle}function oe(i){return i.endAngle}function le(i){return i&&i.padAngle}function ce(i,t,a,r,e,n,o,l){var m=a-i,d=r-t,s=o-e,g=l-n,c=g*m-s*d;if(!(c*c<S))return c=(s*(t-n)-g*(i-e))/c,[i+c*m,t+c*d]}function nt(i,t,a,r,e,n,o){var l=i-a,m=t-r,d=(o?n:-n)/W(l*l+m*m),s=d*m,g=-d*l,c=i+s,y=t+g,v=a+s,k=r+g,R=(c+v)/2,x=(y+k)/2,h=v-c,M=k-y,T=h*h+M*M,f=e-n,u=c*k-v*y,N=(M<0?-1:1)*W(qt(0,f*f*T-u*u)),w=(u*M-h*N)/T,E=(-u*h-M*N)/T,B=(u*M+h*N)/T,C=(-u*h+M*N)/T,I=w-R,p=E-x,b=B-R,O=C-x;return I*I+p*p>b*b+O*O&&(w=B,E=C),{cx:w,cy:E,x01:-s,y01:-g,x11:w*(e/f-1),y11:E*(e/f-1)}}function Bt(){var i=ne,t=ie,a=H(0),r=null,e=se,n=oe,o=le,l=null,m=Jt(d);function d(){var s,g,c=+i.apply(this,arguments),y=+t.apply(this,arguments),v=e.apply(this,arguments)-tt,k=n.apply(this,arguments)-tt,R=Mt(k-v),x=k>v;if(l||(l=s=m()),y<c&&(g=y,y=c,c=g),!(y>S))l.moveTo(0,0);else if(R>Xt-S)l.moveTo(y*z(v),y*$(v)),l.arc(0,0,y,v,k,!x),c>S&&(l.moveTo(c*z(k),c*$(k)),l.arc(0,0,c,k,v,x));else {var h=v,M=k,T=v,f=k,u=R,N=R,w=o.apply(this,arguments)/2,E=w>S&&(r?+r.apply(this,arguments):W(c*c+y*y)),B=rt(Mt(y-c)/2,+a.apply(this,arguments)),C=B,I=B,p,b;if(E>S){var O=Tt(E/c*$(w)),U=Tt(E/y*$(w));(u-=O*2)>S?(O*=x?1:-1,T+=O,f-=O):(u=0,T=f=(v+k)/2),(N-=U*2)>S?(U*=x?1:-1,h+=U,M-=U):(N=0,h=M=(v+k)/2);}var A=y*z(h),P=y*$(h),K=c*z(f),V=c*$(f);if(B>S){var Y=y*z(M),q=y*$(M),it=c*z(T),st=c*$(T),G;if(R<Z)if(G=ce(A,P,it,st,Y,q,K,V)){var ot=A-G[0],lt=P-G[1],ct=Y-G[0],dt=q-G[1],_t=1/$(jt((ot*ct+lt*dt)/(W(ot*ot+lt*lt)*W(ct*ct+dt*dt)))/2),Rt=W(G[0]*G[0]+G[1]*G[1]);C=rt(B,(c-Rt)/(_t-1)),I=rt(B,(y-Rt)/(_t+1));}else C=I=0;}N>S?I>S?(p=nt(it,st,A,P,y,I,x),b=nt(Y,q,K,V,y,I,x),l.moveTo(p.cx+p.x01,p.cy+p.y01),I<B?l.arc(p.cx,p.cy,I,_(p.y01,p.x01),_(b.y01,b.x01),!x):(l.arc(p.cx,p.cy,I,_(p.y01,p.x01),_(p.y11,p.x11),!x),l.arc(0,0,y,_(p.cy+p.y11,p.cx+p.x11),_(b.cy+b.y11,b.cx+b.x11),!x),l.arc(b.cx,b.cy,I,_(b.y11,b.x11),_(b.y01,b.x01),!x))):(l.moveTo(A,P),l.arc(0,0,y,h,M,!x)):l.moveTo(A,P),!(c>S)||!(u>S)?l.lineTo(K,V):C>S?(p=nt(K,V,Y,q,c,-C,x),b=nt(A,P,it,st,c,-C,x),l.lineTo(p.cx+p.x01,p.cy+p.y01),C<B?l.arc(p.cx,p.cy,C,_(p.y01,p.x01),_(b.y01,b.x01),!x):(l.arc(p.cx,p.cy,C,_(p.y01,p.x01),_(p.y11,p.x11),!x),l.arc(0,0,c,_(p.cy+p.y11,p.cx+p.x11),_(b.cy+b.y11,b.cx+b.x11),x),l.arc(b.cx,b.cy,C,_(b.y11,b.x11),_(b.y01,b.x01),!x))):l.arc(0,0,c,f,T,x);}if(l.closePath(),s)return l=null,s+""||null}return d.centroid=function(){var s=(+i.apply(this,arguments)+ +t.apply(this,arguments))/2,g=(+e.apply(this,arguments)+ +n.apply(this,arguments))/2-Z/2;return [z(g)*s,$(g)*s]},d.innerRadius=function(s){return arguments.length?(i=typeof s=="function"?s:H(+s),d):i},d.outerRadius=function(s){return arguments.length?(t=typeof s=="function"?s:H(+s),d):t},d.cornerRadius=function(s){return arguments.length?(a=typeof s=="function"?s:H(+s),d):a},d.padRadius=function(s){return arguments.length?(r=s==null?null:typeof s=="function"?s:H(+s),d):r},d.startAngle=function(s){return arguments.length?(e=typeof s=="function"?s:H(+s),d):e},d.endAngle=function(s){return arguments.length?(n=typeof s=="function"?s:H(+s),d):n},d.padAngle=function(s){return arguments.length?(o=typeof s=="function"?s:H(+s),d):o},d.context=function(s){return arguments.length?(l=s??null,d):l},d}var ue=["bmsSvg"];function pe(i,t){if(i&1&&$h(0,"widget-title",1),i&2){let a=qw();Bh("text",a.displayLabel())("color",a.labelColor());}}function me(i,t){i&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No batteries detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K battery paths or select batteries in widget settings."),ul()());}var ee=class i{static BMS_DESCRIPTOR=a("widget-bms");static ROOT_PATTERN=`${i.BMS_DESCRIPTOR?.selfRootPath??"self.electrical.batteries"}.*`;id=Hj.required();type=Hj.required();theme=Hj.required();renderMode=Hj(null);static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,bms:{trackedDevices:[],groups:[],banks:[]}};static VIEWBOX_WIDTH=200;static MIN_VIEWBOX_HEIGHT=1;static BANK_CARD_WIDTH=200;static BATTERY_CARD_HEIGHT=50;static BATTERY_CARD_WIDTH=200;static CARD_GAP=8;static BANK_HEADER_HEIGHT=80;static BANK_MIN_HEIGHT=75;static SINGLE_ROW_BANK_HEIGHT=100;static IN_BANK_COLUMNS=2;static IN_BANK_COLUMN_GAP=5;static IN_BANK_PADDING_X=0;static BANK_GAUGE_RADIUS=50;static BANK_GAUGE_BG_STROKE=10;static BANK_GAUGE_VALUE_STROKE=10;static COMPACT_UNASSIGNED_BATTERY_SCALE=.82;static PATH_BATCH_WINDOW_MS=500;runtime=w(p);data=w(De);units=w(ut);iconRegistry=w(K);destroyRef=w(xe);svgRef=$j.required("bmsSvg");svg;root;bankLayer;batteryLayer;bankGaugeBackgroundPath=this.buildSemiGaugeArcPath(i.BANK_GAUGE_RADIUS,1);glowFilterId="";renderFrameId=null;pendingRenderSnapshot=null;pathBatchTimerId=null;initialPathPaintDone=false;pendingPathUpdates=new Map;powerAvailableIconTemplate=null;powerRenewalIconTemplate=null;discoveredBatteryIds=vt([]);trackedBatteryDeviceIds=vt([]);banks=vt([]);cardMode=vt({displayMode:"full",metrics:[]});batteries=vt({});visibleBatteryIds=Dt(()=>{let t=this.trackedBatteryDeviceIds();return t.length?t:this.discoveredBatteryIds()});visibleBatteries=Dt(()=>{let t=this.visibleBatteryIds(),a=this.batteries();return t.map(r=>a[r]).filter(r=>!!r)});bankSummaries=Dt(()=>{let t=this.banks(),a=this.batteries();return t.map(r=>this.buildBankSummary(r,a))});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 t=this.bankSummaries();if(t.length===1)return t[0].name||"Bank";if(t.length>1)return "Batteries";let a=this.visibleBatteries();return a.length!==1?"Batteries":this.resolveBatteryTitleText(a[0])});labelColor=Dt(()=>{let t=this.theme();return t?c(this.colorRole(),t).dim:"var(--kip-contrast-dim-color)"});widgetColors=Dt(()=>{let t=this.theme();return t?c(this.colorRole(),t):null});batteryDisplayModels=Dt(()=>{let t=this.visibleBatteries(),a=this.theme(),r=this.widgetColors(),e$1=this.ignoreZones(),n={};for(let o of t){let l=e(o.stateOfChargeState,r?.dimmer??"var(--kip-contrast-dimmer-color)",a,e$1),m=e(o.stateOfChargeState,r?.dim??"var(--kip-contrast-dim-color)",a,e$1),d=e(o.currentState,"var(--kip-contrast-dim-color)",a,e$1),s=e(o.currentState,"var(--kip-contrast-color)",a,e$1);n[o.id]={id:o.id,titleText:this.resolveBatteryTitleText(o),chargeWidth:(i.BATTERY_CARD_WIDTH-3)*(o.stateOfCharge??0),chargeBarColorCompact:l,chargeBarColorRegular:m,currentTextColorCompact:d,currentTextColorRegular:s,currentText:`${this.formatCurrent(o.current)}`.trim(),detailLineCompact:`${this.formatVoltage(o.voltage)}\xA0\xA0\xA0\xA0${this.formatTemperature(o.temperature)}`,detailLineRegular:`${this.formatVoltage(o.voltage)}\xA0\xA0\xA0\xA0${this.formatPower(o.power)}\xA0\xA0\xA0\xA0${this.formatTemperature(o.temperature)}`.trim(),socText:this.formatSoc(o.stateOfCharge),socGlowEnabled:!e$1&&(o.stateOfChargeState===n$1.Warn||o.stateOfChargeState===n$1.Alarm||o.stateOfChargeState===n$1.Alert),remainingCapacityText:o.capacityActual?`${this.formatEnergy(o.capacityRemaining)}`:"",remainingTimeText:`${this.formatDuration(o.timeRemaining)}`.trim(),iconKey:o.current!=null&&o.current>0?"power_renewal":"power_available"};}return n});bankDisplayModels=Dt(()=>{let t=this.bankSummaries(),a=this.widgetColors(),r={};for(let e of t)r[e.id]={id:e.id,titleText:e.name||"Bank",currentText:this.formatCurrent(e.totalCurrent),powerText:this.formatPower(e.totalPower),socText:this.formatSoc(e.avgSoc),remainingTimeText:`${this.formatDuration(e.timeRemaining)}`.trim(),remainingCapacityText:e.remainingCapacity?`${this.formatEnergy(e.remainingCapacity)}`:"",gaugeValuePath:this.buildSemiGaugeArcPath(i.BANK_GAUGE_RADIUS,e.avgSoc),gaugeValueColor:a?.color??"var(--kip-contrast-color)",zoneState:null,zoneColor:null};return r});hasBatteries=Dt(()=>this.visibleBatteries().length>0);hasBanks=Dt(()=>this.bankSummaries().length>0);constructor(){Fa(()=>{let a=this.runtime.options();a&&ge(()=>this.applyConfig(a));}),Fa(()=>{let a=this.bankSummaries(),r=this.visibleBatteries(),e=this.widgetColors(),n=this.batteryDisplayModels(),o=this.bankDisplayModels();!this.svg||!e||this.requestRender({banks:a,batteries:r,batteryDisplayModels:n,bankDisplayModels:o,widgetColors:e});});let t=this.data.subscribePathTreeWithInitial(i.ROOT_PATTERN);if(t.initial.length){for(let a of t.initial)this.enqueuePathUpdate(a,true);this.flushPendingPathUpdates(),this.initialPathPaintDone=true;}t.live$.pipe(Gp(this.destroyRef)).subscribe(a=>{this.enqueuePathUpdate(a);});}ngAfterViewInit(){this.initializeSvg(),this.loadPowerIcons(),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 ${i.VIEWBOX_WIDTH} ${i.MIN_VIEWBOX_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","Battery Management System View"),this.glowFilterId=`bms-soc-glow-${this.id()}`;let a=this.svg.append("defs").append("filter").attr("id",this.glowFilterId).attr("x","-30%").attr("y","-30%").attr("width","160%").attr("height","160%");a.append("feFlood").attr("class","bms-soc-glow-flood").attr("flood-color","var(--kip-widget-card-background-color)").attr("flood-opacity",.9).attr("result","color"),a.append("feComposite").attr("in","color").attr("in2","SourceGraphic").attr("operator","in").attr("result","coloredGlow"),a.append("feGaussianBlur").attr("in","coloredGlow").attr("stdDeviation",2).attr("result","blur");let r=a.append("feMerge");r.append("feMergeNode").attr("in","blur"),r.append("feMergeNode").attr("in","blur"),r.append("feMergeNode").attr("in","SourceGraphic"),this.root=this.svg.append("g").attr("class","bms-root"),this.bankLayer=this.root.append("g").attr("class","bms-banks"),this.batteryLayer=this.root.append("g").attr("class","bms-batteries");}loadPowerIcons(){this.loadNamedIcon("power_available",t=>{this.powerAvailableIconTemplate=t;}),this.loadNamedIcon("power_renewal",t=>{this.powerRenewalIconTemplate=t;});}loadNamedIcon(t,a){this.iconRegistry.getNamedSvgIcon(t).pipe(_t(1)).subscribe({next:r=>{a(r),this.requestRender();},error:()=>{}});}applyConfig(t){let a=this.resolveBmsConfig(t);this.trackedBatteryDeviceIds.set([...new Set((a.trackedDevices??[]).map(r=>r.id))]),this.banks.set(a.banks),this.cardMode.set(this.normalizeCardMode(a.cardMode));}resolveBmsConfig(t){let a=t.bms,r=this.normalizeTrackedDevices(a?.trackedDevices),e=this.normalizeBanksFromGroups(a?.groups),n=this.normalizeBanksFromLegacy(a?.banks);return {trackedDevices:r,groups:e,banks:e.length>0?e:n,cardMode:this.normalizeCardMode(a?.cardMode)}}normalizeTrackedDevices(t){if(!Array.isArray(t))return [];let a=new Map;return t.forEach(r=>{if(!r||typeof r!="object")return;let e=r,n=typeof e.id=="string"?e.id.trim():"",o=typeof e.source=="string"?e.source.trim():"default";if(!n||!o)return;let l=typeof e.key=="string"&&e.key.trim().length>0?e.key.trim():`${n}||${o}`;a.set(l,{id:n,source:o,key:l});}),[...a.values()].sort((r,e)=>r.key.localeCompare(e.key))}normalizeCardMode(t){let a=t&&typeof t=="object"?t:null,r=this.normalizeStringList(a?.metrics);return {displayMode:a?.displayMode==="compact"?"compact":"full",metrics:r}}normalizeStringList(t){if(!Array.isArray(t))return [];let a=new Set;return t.forEach(r=>{if(typeof r!="string")return;let e=r.trim();e.length>0&&a.add(e);}),[...a].sort((r,e)=>r.localeCompare(e))}normalizeBanksFromGroups(t){return Array.isArray(t)?t.map(a=>{let r=this.normalizeOptionalString(a?.id)??`bank-${Date.now()}`,e=this.normalizeOptionalString(a?.name)??r,n=this.normalizeStringList(a?.memberIds);return {id:r,name:e,batteryIds:n,connectionMode:this.normalizeConnectionMode(a?.connectionMode)}}).filter(a=>a.id.length>0):[]}normalizeBanksFromLegacy(t){return Array.isArray(t)?t.map(a=>{let r=this.normalizeOptionalString(a?.id)??`bank-${Date.now()}`,e=this.normalizeOptionalString(a?.name)??r,n=this.normalizeStringList(a?.batteryIds);return {id:r,name:e,batteryIds:n,connectionMode:this.normalizeConnectionMode(a?.connectionMode)}}).filter(a=>a.id.length>0):[]}normalizeOptionalString(t){if(typeof t!="string")return null;let a=t.trim();return a.length>0?a:null}normalizeConnectionMode(t){return t==="series"?"series":"parallel"}enqueuePathUpdate(t,a=false){let r=this.parseBatteryPath(t.path);if(!r)return;let{id:e,key:n}=r,o=t.update?.data?.value??null,l=t.update?.state??null,m=`${e}::${n}`;if(this.pendingPathUpdates.set(m,{id:e,key:n,value:o,state:l}),!a){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=window.setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},i.PATH_BATCH_WINDOW_MS));}}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let t=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(t.map(r=>r.id)).forEach(r=>this.trackDiscoveredBattery(r)),this.batteries.update(r=>{let e=r,n=false;for(let o of t){let l=e[o.id]??{id:o.id},m=G({},l),d=this.applyBatteryValue(m,o.key,o.value,o.state),s=false;if(m.voltage!=null&&m.current!=null){let g=Number.isFinite(m.voltage)&&Number.isFinite(m.current)?m.voltage*m.current:null;Object.is(m.power,g)||(m.power=g,s=true);}!d&&!s||(n||(e=G({},e),n=true),e[o.id]=m);}return n?e:r});}parseBatteryPath(t){let a=t.match(/self\.electrical\.batteries\.([^.]+)\.(.+)$/);return a?{id:a[1],key:a[2]}:null}trackDiscoveredBattery(t){let a=this.discoveredBatteryIds();if(a.includes(t))return;let r=[...a,t].sort();this.discoveredBatteryIds.set(r);}applyBatteryValue(t,a,r,e){switch(a){case "name":{let n=r;return t.name===n?false:(t.name=n,true)}case "location":{let n=r;return t.location===n?false:(t.location=n,true)}case "associatedBus":{let n=r;return t.associatedBus===n?false:(t.associatedBus=n,true)}case "chemistry":{let n=r;return t.chemistry===n?false:(t.chemistry=n,true)}case "voltage":{let n=this.toNumber(r);return Object.is(t.voltage,n)?false:(t.voltage=n,true)}case "current":{let n=this.toNumber(r),o=!Object.is(t.currentState??null,e??null);return Object.is(t.current,n)&&!o?false:(t.current=n,t.currentState=e,true)}case "temperature":{let n=this.toNumber(r);return Object.is(t.temperature,n)?false:(t.temperature=n,true)}case "capacity.nominal":{let n=this.toNumber(r);return Object.is(t.capacityNominal,n)?false:(t.capacityNominal=n,true)}case "capacity.actual":{let n=this.toNumber(r);return Object.is(t.capacityActual,n)?false:(t.capacityActual=n,true)}case "capacity.remaining":{let n=this.toNumber(r);return Object.is(t.capacityRemaining,n)?false:(t.capacityRemaining=n,true)}case "capacity.stateOfCharge":{let n=this.toNumber(r),o=!Object.is(t.stateOfChargeState??null,e??null);return Object.is(t.stateOfCharge,n)&&!o?false:(t.stateOfCharge=n,t.stateOfChargeState=e,true)}case "capacity.timeRemaining":{let n=this.toNumber(r);return Object.is(t.timeRemaining,n)?false:(t.timeRemaining=n,true)}default:return false}}buildBankSummary(t,a){let r=t.batteryIds.map(s=>a[s]).filter(s=>!!s),e=this.normalizeConnectionMode(t.connectionMode),n=this.calculateBankCurrent(r,e),o=this.sumNumbers(r.map(s=>s.power)),l=this.sumNumbers(r.map(s=>s.capacityRemaining)),m=this.calculateBankSoc(r),d=this.calculateBankTimeRemaining(r,e);return {id:t.id,name:t.name,batteryIds:t.batteryIds,totalCurrent:n,totalPower:o,remainingCapacity:l,avgSoc:m,timeRemaining:d}}calculateBankSoc(t){let a=this.sumNumbers(t.map(n=>n.capacityRemaining)),r=this.sumNumbers(t.map(n=>n.capacityActual));if(a!=null&&r!=null&&r>0)return Math.max(0,Math.min(1,a/r));let e=this.sumNumbers(t.map(n=>n.capacityNominal));return a!=null&&e!=null&&e>0?Math.max(0,Math.min(1,a/e)):this.averageNumbers(t.map(n=>n.stateOfCharge))}calculateBankCurrent(t,a){let r=t.map(e=>e.current);return a==="series"?this.averageNumbers(r):this.sumNumbers(r)}calculateBankTimeRemaining(t,a){let r=t.map(e=>e.timeRemaining);return a==="series"?this.minNumber(r):this.averageNumbers(r)}requestRender(t){this.svg&&(this.pendingRenderSnapshot=t??this.buildRenderSnapshot(),this.pendingRenderSnapshot&&this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;let a=this.pendingRenderSnapshot;this.pendingRenderSnapshot=null,a&&this.render(a);})));}buildRenderSnapshot(){let t=this.widgetColors();return t?{banks:this.bankSummaries(),batteries:this.visibleBatteries(),batteryDisplayModels:this.batteryDisplayModels(),bankDisplayModels:this.bankDisplayModels(),widgetColors:t}:null}render(t){if(!this.bankLayer||!this.batteryLayer)return;let{banks:a,batteries:r,bankDisplayModels:e,batteryDisplayModels:n,widgetColors:o}=t,l=this.buildRenderLayout(a,r,e,n,this.isCompactCardMode()),d=this.isCompactCardMode()?e$1:e$1,s=Math.max(i.MIN_VIEWBOX_HEIGHT,l.contentHeight);this.svg?.attr("viewBox",`0 0 ${i.VIEWBOX_WIDTH} ${s}`),this.root?.attr("transform",null);let g=this.bankLayer.selectAll("g.bank-card").data(l.banks,u=>u.id),c=g.enter().append("g").attr("class","bank-card"),y=c.append("text").attr("class","bank-card-power");y.append("tspan").attr("class","bank-card-power-value"),y.append("tspan").attr("class","bank-card-power-unit");let v=c.append("text").attr("class","bank-card-current");v.append("tspan").attr("class","bank-card-current-value"),v.append("tspan").attr("class","bank-card-current-unit");let k=c.append("g").attr("class","bank-gauge");k.append("path").attr("class","bank-gauge-bg"),k.append("path").attr("class","bank-gauge-value");let R=k.append("text").attr("class","bank-gauge-soc");R.append("tspan").attr("class","bank-gauge-soc-value"),R.append("tspan").attr("class","bank-gauge-soc-unit");let x=c.append("text").attr("class","bank-actualCapacity");x.append("tspan").attr("class","bank-actualCapacity-value"),x.append("tspan").attr("class","bank-actualCapacity-unit"),c.append("text").attr("class","bank-remaining"),c.append("g").attr("class","bank-bms-batteries"),c.append("text").attr("class","bank-title");let h=c.merge(g);h.attr("transform",u=>`translate(${u.x},${u.y})`),l.banks.length>1?h.select("text.bank-title").attr("x",d.titleX).attr("y",d.titleY).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",d.titleFontSize).text(u=>u.displayModel.titleText):h.select("text.bank-title").text(""),h.select("text.bank-card-current").attr("x",d.lineOneX).attr("y",d.lineOneY).attr("fill","var(--kip-contrast-color)").attr("font-size",d.lineOneFontSize),h.select("tspan.bank-card-current-value").text(u=>this.splitMetricText(u.displayModel.currentText,"A").valueText),h.select("tspan.bank-card-current-unit").attr("dx",1).attr("font-size",12).attr("fill","var(--kip-contrast-color)").text(u=>this.splitMetricText(u.displayModel.currentText,"A").unitText),h.select("text.bank-card-power").attr("x",5).attr("y",42).attr("fill","var(--kip-contrast-color)").attr("font-size",10).attr("opacity",.8),h.select("tspan.bank-card-power-value").text(u=>this.splitMetricText(u.displayModel.powerText,"W").valueText),h.select("tspan.bank-card-power-unit").attr("dx",1).attr("font-size",6).attr("fill","var(--kip-contrast-color)").text(u=>this.splitMetricText(u.displayModel.powerText,"W").unitText),h.select("g.bank-gauge").attr("transform","translate(143, 60)"),h.select("path.bank-gauge-bg").attr("d",this.bankGaugeBackgroundPath).attr("fill","none").attr("stroke","var(--kip-contrast-dimmer-color)").attr("stroke-width",i.BANK_GAUGE_BG_STROKE).attr("stroke-linecap","round"),h.select("path.bank-gauge-value").attr("d",u=>u.displayModel.gaugeValuePath).attr("fill","none").attr("stroke",u=>u.displayModel.gaugeValueColor).attr("stroke-width",i.BANK_GAUGE_VALUE_STROKE).attr("stroke-linecap","round"),h.select("text.bank-gauge-soc").attr("x",0).attr("y",-5).attr("text-anchor","middle").attr("fill","var(--kip-contrast-color)").attr("font-size",d.primaryFontSize).attr("font-weight",d.primaryFontWeight),h.select("tspan.bank-gauge-soc-value").text(u=>this.splitMetricText(u.displayModel.socText,"%").valueText),h.select("tspan.bank-gauge-soc-unit").attr("dx",1).attr("font-size",22).attr("font-weight",500).attr("fill","var(--kip-contrast-color)").text(u=>this.splitMetricText(u.displayModel.socText,"%").unitText),h.select("text.bank-remaining").attr("x",143).attr("y",26).attr("fill","var(--kip-contrast-dim-color)").attr("text-anchor","middle").attr("font-size",8).text(u=>u.displayModel.remainingTimeText),h.select("text.bank-actualCapacity").attr("x",143).attr("y",66).attr("fill","var(--kip-contrast-dim-color)").attr("text-anchor","middle").attr("font-size",8),h.select("tspan.bank-actualCapacity-value").text(u=>this.splitMetricText(u.displayModel.remainingCapacityText,"kWh").valueText),h.select("tspan.bank-actualCapacity-unit").attr("dx",1).attr("font-size",6).attr("fill","var(--kip-contrast-dim-color)").text(u=>this.splitMetricText(u.displayModel.remainingCapacityText,"kWh").unitText),h.select("g.bank-bms-batteries").each((u,N,w)=>{let B=ge$1(w[N]).selectAll("g.battery-card").data(u.batteries,p=>p.key),C=B.enter().append("g").attr("class","battery-card battery-card--in-bank");this.appendBatteryCardSkeleton(C);let I=C.merge(B);this.renderBatteryCards(I,o,t.batteries.length>1),B.exit().remove();}),g.exit().remove();let M=this.batteryLayer.selectAll("g.battery-card").data(l.unassignedBatteries,u=>u.key),T=M.enter().append("g").attr("class","battery-card battery-card--unassigned");this.appendBatteryCardSkeleton(T);let f=T.merge(M);this.renderBatteryCards(f,o,true),M.exit().remove(),this.root?.attr("data-theme","ready");}buildRenderLayout(t,a,r,e,n){let o=new Map(a.map(f=>[f.id,f])),l=new Set,m=this.computeInBankBatterySlotWidth(),d=Math.max(.35,Math.min(1,m/i.BATTERY_CARD_WIDTH)),s=i.BATTERY_CARD_HEIGHT*d,g=0,c=t.map(f=>{let u=new Set,N=f.batteryIds.map(A=>o.get(A)).filter(A=>!A||u.has(A.id)?false:(u.add(A.id),true));N.forEach(A=>l.add(A.id));let w=Math.ceil(N.length/i.IN_BANK_COLUMNS),E=i.SINGLE_ROW_BANK_HEIGHT,B=!n&&w===1,C=B?Math.max(0,E-s-i.CARD_GAP):i.BANK_HEADER_HEIGHT,I=w>0?w*s+(w-1)*i.CARD_GAP:0,p=Math.max(i.BANK_MIN_HEIGHT,C+I+i.CARD_GAP),b=B?E:p,O=N.map((A,P)=>{let K=P%i.IN_BANK_COLUMNS,V=Math.floor(P/i.IN_BANK_COLUMNS),Y=i.IN_BANK_PADDING_X+K*(m+i.IN_BANK_COLUMN_GAP),q=C+7+V*(s+i.CARD_GAP);return {id:A.id,displayModel:e[A.id],key:`${f.id}::${A.id}`,x:Y,y:q,scale:d,inBank:true,compact:true}}),U={id:f.id,name:f.name,batteryIds:f.batteryIds,totalCurrent:f.totalCurrent,totalPower:f.totalPower,avgSoc:f.avgSoc,remainingCapacity:f.remainingCapacity,timeRemaining:f.timeRemaining,displayModel:r[f.id],x:0,y:g,width:i.BANK_CARD_WIDTH,height:b,batteries:O};return g+=b+i.CARD_GAP,U}),y=c.length>0?g:0,v=n?i.COMPACT_UNASSIGNED_BATTERY_SCALE:1,k=i.BATTERY_CARD_HEIGHT*v,R=a.filter(f=>!l.has(f.id)).sort((f,u)=>f.id.localeCompare(u.id)).map((f,u)=>({id:f.id,displayModel:e[f.id],key:f.id,x:0,y:y+u*(k+i.CARD_GAP),scale:v,inBank:false,compact:n})),x=c[c.length-1],h=x?x.y+x.height:0,M=R[R.length-1],T=M?M.y+k:0;return {banks:c,unassignedBatteries:R,contentHeight:Math.max(h,T)}}computeInBankBatterySlotWidth(){return (i.BANK_CARD_WIDTH-i.IN_BANK_PADDING_X*2-i.IN_BANK_COLUMN_GAP)/i.IN_BANK_COLUMNS}appendBatteryCardSkeleton(t){t.append("rect").attr("class","bms-battery").attr("rx",4).attr("ry",4),t.append("rect").attr("class","bms-battery-tip").attr("rx",1).attr("ry",1),t.append("rect").attr("class","bms-charge-fill").attr("rx",3).attr("ry",3),t.append("g").attr("class","bms-state-icon"),t.append("text").attr("class","bms-ampere"),t.append("text").attr("class","bms-volt-power");let a=t.append("text").attr("class","bms-soc");a.append("tspan").attr("class","bms-soc-value"),a.append("tspan").attr("class","bms-soc-unit"),t.append("text").attr("class","bms-actualCapacity"),t.append("text").attr("class","bms-remaining"),t.append("text").attr("class","bms-title");}renderBatteryCards(t,a,r){t.attr("transform",e=>`translate(${e.x},${e.y}) scale(${e.scale})`),t.select("rect.bms-battery").attr("width",e=>e.inBank?i.BATTERY_CARD_WIDTH:e.compact?i.BATTERY_CARD_WIDTH-i.CARD_GAP:i.BATTERY_CARD_WIDTH).attr("height",i.BATTERY_CARD_HEIGHT).attr("fill",e=>e.compact?"var(--mat-sys-background)":"var(--kip-contrast-dimmer-color)").attr("stroke","var(--kip-contrast-dimmer-color)").attr("stroke-width",0),t.select("rect.bms-battery-tip").attr("x",i.BATTERY_CARD_WIDTH).attr("y",i.BATTERY_CARD_HEIGHT/2-10).attr("width",4).attr("height",20).attr("fill",e=>e.compact?"var(--mat-sys-background)":"var(--kip-contrast-dimmer-color)").attr("stroke",a.color).attr("stroke-width",0),t.select("rect.bms-charge-fill").attr("x",1.5).attr("y",1.5).attr("width",e=>e.displayModel.chargeWidth).attr("height",i.BATTERY_CARD_HEIGHT-3).attr("fill",e=>e.compact?e.displayModel.chargeBarColorCompact:e.displayModel.chargeBarColorRegular),r?t.select("text.bms-title").attr("x",5).attr("y",e=>e.compact?11:14).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",e=>e.compact?8:12).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.displayModel.titleText):t.select("text.bms-title").text(""),t.select("text.bms-ampere").attr("x",10).attr("y",33).attr("fill",e=>e.compact?e.displayModel.currentTextColorCompact:e.displayModel.currentTextColorRegular).attr("font-size",16).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.displayModel.currentText),t.select("text.bms-volt-power").attr("x",10).attr("y",45).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",8).attr("opacity",.8).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.compact?e.displayModel.detailLineCompact:e.displayModel.detailLineRegular),t.select("text.bms-soc").attr("x",i.BATTERY_CARD_WIDTH-33).attr("y",34).attr("fill",e=>e.compact?"var(--kip-contrast-dim-color)":"var(--kip-contrast-color)").attr("text-anchor","middle").attr("font-size",25).attr("font-weight",700).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null),t.select("tspan.bms-soc-value").text(e=>this.splitMetricText(e.displayModel.socText,"%").valueText),t.select("tspan.bms-soc-unit").attr("dx",1).attr("font-size",16).attr("font-weight",500).text(e=>this.splitMetricText(e.displayModel.socText,"%").unitText),t.select("text.bms-actualCapacity").attr("x",i.BATTERY_CARD_WIDTH-33).attr("y",45).attr("fill","var(--kip-contrast-dim-color)").attr("text-anchor","middle").attr("font-size",8).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.compact?"":e.displayModel.remainingCapacityText),t.select("text.bms-remaining").attr("x",i.BATTERY_CARD_WIDTH-33).attr("y",12).attr("fill","var(--kip-contrast-dim-color)").attr("text-anchor","middle").attr("font-size",6).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.compact?"":e.displayModel.remainingTimeText),t.select("g.bms-state-icon").attr("transform",`translate(${i.BATTERY_CARD_WIDTH/2-18}, ${i.BATTERY_CARD_HEIGHT/2-18})`).attr("display",e=>e.compact&&e.scale<.45?"none":null).attr("color",e=>e.compact?a.dim:a.color).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).each((e,n,o)=>{let l=ge$1(o[n]),m=e.displayModel.iconKey,d=m==="power_renewal"?this.powerRenewalIconTemplate:this.powerAvailableIconTemplate;if(!d){l.selectAll("*").remove(),l.attr("data-icon-key",null);return}let s=l.node();if(!s||l.attr("data-icon-key")===m&&s.firstElementChild)return;l.selectAll("*").remove();let c=d.cloneNode(true);c.removeAttribute("id"),c.setAttribute("width","36"),c.setAttribute("height","36"),c.getAttribute("viewBox")||c.setAttribute("viewBox","0 0 24 24"),s.appendChild(c),l.attr("data-icon-key",m);});}formatVoltage(t){return t==null?"-- V":`${t.toFixed(1)}V`}formatCurrent(t){return t==null?"-- A":`${t.toFixed(1)}A`}formatPower(t){return t==null?"":`${t.toFixed(0)}W`}formatEnergy(t){return t==null?"":(t=this.units.convertToUnit("kWh",t),`${t}kWh`)}formatSoc(t){return t==null?"--%":`${Math.round(t*100)}%`}resolveBatteryTitleText(t){return t.name||`Battery ${t.id}`}formatDuration(t){if(t==null)return "";let a=this.units.convertToUnit("D HH:MM:SS",t);return a==null?"":typeof a=="string"?a:`${a}`}formatTemperature(t){if(t==null||typeof t!="number")return "";let a=this.units.getDefaults().Temperature,r=this.units.convertToUnit(a,t);return r===null?"":`${r.toFixed(1)} ${a==="celsius"?"\xB0C":"\xB0F"}`}splitMetricText(t,a){if(!t)return {valueText:"",unitText:""};let r=t.trim();return r?r.endsWith(a)?{valueText:r.slice(0,Math.max(0,r.length-a.length)).trim(),unitText:a}:{valueText:r,unitText:""}:{valueText:"",unitText:""}}sumNumbers(t){let a=t.filter(r=>typeof r=="number");return a.length?a.reduce((r,e)=>r+e,0):null}averageNumbers(t){let a=t.filter(r=>typeof r=="number");return a.length?a.reduce((r,e)=>r+e,0)/a.length:null}minNumber(t){let a=t.filter(r=>typeof r=="number");return a.length?Math.min(...a):null}toNumber(t){return t==null||typeof t!="number"?null:t}buildSemiGaugeArcPath(t,a){let r=Math.max(0,Math.min(1,a??0)),e=-Math.PI*.55,n=Math.PI*1.1,o=e+n*r;if(r<=0){let l=t*Math.cos(e),m=t*Math.sin(e);return `M ${l} ${m}`}return Bt()({innerRadius:t,outerRadius:t,startAngle:e,endAngle:o})??""}static \u0275fac=function(a){return new(a||i)};static \u0275cmp=JD({type:i,selectors:[["widget-bms"]],viewQuery:function(a,r){a&1&&eg(r.svgRef,ue,5),a&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:4,consts:[["bmsSvg",""],[3,"text","color"],["aria-hidden","false",1,"bms-svg"],[1,"bms-empty"],[1,"bms-empty-title"],[1,"bms-empty-sub"]],template:function(a,r){a&1&&(_w(0,pe,1,2,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,me,5,0,"div",3)),a&2&&(Mw(r.hasBanks()?0:-1),EE(),sg("bms-svg--full",!r.hasBanks()),EE(2),Mw(r.hasBatteries()?-1:3));},dependencies:[yt,x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.bms-svg[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;padding:0 10px 10px}.bms-svg.bms-svg--full[_ngcontent-%COMP%]{top:0;height:100%;padding-top:10px}.bms-card-metric[_ngcontent-%COMP%]{fill:var(--mat-sys-on-surface);font-size:30px;font-weight:700}.bms-card-sub[_ngcontent-%COMP%]{fill:var(--mat-sys-on-surface);font-size:18px;opacity:.9}.bms-card-meta[_ngcontent-%COMP%]{fill:var(--mat-sys-on-surface);font-size:15px;opacity:.75}.bms-card-footer[_ngcontent-%COMP%]{fill:var(--mat-sys-on-surface);font-size:16px;opacity:.8}.bms-flow-line[_ngcontent-%COMP%]{stroke:var(--kip-zone-nominal-color);stroke-width:3px;stroke-dasharray:6 6;animation:_ngcontent-%COMP%_flow-dash 2s linear infinite}.bms-flow-line--out[_ngcontent-%COMP%]{stroke:var(--kip-zone-warn-color)}.bms-flow-line--in[_ngcontent-%COMP%]{stroke:var(--kip-zone-nominal-color)}.bms-flow-line--neutral[_ngcontent-%COMP%]{stroke:var(--kip-widget-card-border-color);animation:none}.bms-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)}.bms-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.bms-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}@keyframes _ngcontent-%COMP%_flow-dash{to{stroke-dashoffset:-12}}"]})};export{ee as WidgetBmsComponent};
|
|
1
|
+
import {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,ea as K,aY as xe,$ as $j,v as vt,D as Dt,dx as n$1,F as Fa,dn as ge,a_ as Gp,av as _t,cv as G,J as JD,y as yt,dC as x,_ as _w,cn as wd,c as $h,M as Mw,e as EE,s as sg,f as eg,K as Kw,g as qw,B as Bh,P as Pi,T as TT,u as ul}from'./main-YKDNK5VZ.js';import {c,e}from'./chunk-BIb-xYiS.js';function H(i){return function(){return i}}var Mt=Math.abs,_=Math.atan2,z=Math.cos,qt=Math.max,rt=Math.min,$=Math.sin,W=Math.sqrt,S=1e-12,Z=Math.PI,tt=Z/2,Xt=2*Z;function jt(i){return i>1?0:i<-1?Z:Math.acos(i)}function Tt(i){return i>=1?tt:i<=-1?-tt:Math.asin(i)}var Ct=Math.PI,At=2*Ct,L=1e-6,ae=At-L;function Zt(i){this._+=i[0];for(let t=1,a=i.length;t<a;++t)this._+=arguments[t]+i[t];}function re(i){let t=Math.floor(i);if(!(t>=0))throw new Error(`invalid digits: ${i}`);if(t>15)return Zt;let a=10**t;return function(r){this._+=r[0];for(let e=1,n=r.length;e<n;++e)this._+=Math.round(arguments[e]*a)/a+r[e];}}var F=class{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?Zt:re(t);}moveTo(t,a){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+a}`;}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`);}lineTo(t,a){this._append`L${this._x1=+t},${this._y1=+a}`;}quadraticCurveTo(t,a,r,e){this._append`Q${+t},${+a},${this._x1=+r},${this._y1=+e}`;}bezierCurveTo(t,a,r,e,n,o){this._append`C${+t},${+a},${+r},${+e},${this._x1=+n},${this._y1=+o}`;}arcTo(t,a,r,e,n){if(t=+t,a=+a,r=+r,e=+e,n=+n,n<0)throw new Error(`negative radius: ${n}`);let o=this._x1,l=this._y1,m=r-t,d=e-a,s=o-t,g=l-a,c=s*s+g*g;if(this._x1===null)this._append`M${this._x1=t},${this._y1=a}`;else if(c>L)if(!(Math.abs(g*m-d*s)>L)||!n)this._append`L${this._x1=t},${this._y1=a}`;else {let y=r-o,v=e-l,k=m*m+d*d,R=y*y+v*v,x=Math.sqrt(k),h=Math.sqrt(c),M=n*Math.tan((Ct-Math.acos((k+c-R)/(2*x*h)))/2),T=M/h,f=M/x;Math.abs(T-1)>L&&this._append`L${t+T*s},${a+T*g}`,this._append`A${n},${n},0,0,${+(g*y>s*v)},${this._x1=t+f*m},${this._y1=a+f*d}`;}}arc(t,a,r,e,n,o){if(t=+t,a=+a,r=+r,o=!!o,r<0)throw new Error(`negative radius: ${r}`);let l=r*Math.cos(e),m=r*Math.sin(e),d=t+l,s=a+m,g=1^o,c=o?e-n:n-e;this._x1===null?this._append`M${d},${s}`:(Math.abs(this._x1-d)>L||Math.abs(this._y1-s)>L)&&this._append`L${d},${s}`,r&&(c<0&&(c=c%At+At),c>ae?this._append`A${r},${r},0,1,${g},${t-l},${a-m}A${r},${r},0,1,${g},${this._x1=d},${this._y1=s}`:c>L&&this._append`A${r},${r},0,${+(c>=Ct)},${g},${this._x1=t+r*Math.cos(n)},${this._y1=a+r*Math.sin(n)}`);}rect(t,a,r,e){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+a}h${r=+r}v${+e}h${-r}Z`;}toString(){return this._}};function Jt(i){let t=3;return i.digits=function(a){if(!arguments.length)return t;if(a==null)t=null;else {let r=Math.floor(a);if(!(r>=0))throw new RangeError(`invalid digits: ${a}`);t=r;}return i},()=>new F(t)}function ne(i){return i.innerRadius}function ie(i){return i.outerRadius}function se(i){return i.startAngle}function oe(i){return i.endAngle}function le(i){return i&&i.padAngle}function ce(i,t,a,r,e,n,o,l){var m=a-i,d=r-t,s=o-e,g=l-n,c=g*m-s*d;if(!(c*c<S))return c=(s*(t-n)-g*(i-e))/c,[i+c*m,t+c*d]}function nt(i,t,a,r,e,n,o){var l=i-a,m=t-r,d=(o?n:-n)/W(l*l+m*m),s=d*m,g=-d*l,c=i+s,y=t+g,v=a+s,k=r+g,R=(c+v)/2,x=(y+k)/2,h=v-c,M=k-y,T=h*h+M*M,f=e-n,u=c*k-v*y,N=(M<0?-1:1)*W(qt(0,f*f*T-u*u)),w=(u*M-h*N)/T,E=(-u*h-M*N)/T,B=(u*M+h*N)/T,C=(-u*h+M*N)/T,I=w-R,p=E-x,b=B-R,O=C-x;return I*I+p*p>b*b+O*O&&(w=B,E=C),{cx:w,cy:E,x01:-s,y01:-g,x11:w*(e/f-1),y11:E*(e/f-1)}}function Bt(){var i=ne,t=ie,a=H(0),r=null,e=se,n=oe,o=le,l=null,m=Jt(d);function d(){var s,g,c=+i.apply(this,arguments),y=+t.apply(this,arguments),v=e.apply(this,arguments)-tt,k=n.apply(this,arguments)-tt,R=Mt(k-v),x=k>v;if(l||(l=s=m()),y<c&&(g=y,y=c,c=g),!(y>S))l.moveTo(0,0);else if(R>Xt-S)l.moveTo(y*z(v),y*$(v)),l.arc(0,0,y,v,k,!x),c>S&&(l.moveTo(c*z(k),c*$(k)),l.arc(0,0,c,k,v,x));else {var h=v,M=k,T=v,f=k,u=R,N=R,w=o.apply(this,arguments)/2,E=w>S&&(r?+r.apply(this,arguments):W(c*c+y*y)),B=rt(Mt(y-c)/2,+a.apply(this,arguments)),C=B,I=B,p,b;if(E>S){var O=Tt(E/c*$(w)),U=Tt(E/y*$(w));(u-=O*2)>S?(O*=x?1:-1,T+=O,f-=O):(u=0,T=f=(v+k)/2),(N-=U*2)>S?(U*=x?1:-1,h+=U,M-=U):(N=0,h=M=(v+k)/2);}var A=y*z(h),P=y*$(h),K=c*z(f),V=c*$(f);if(B>S){var Y=y*z(M),q=y*$(M),it=c*z(T),st=c*$(T),G;if(R<Z)if(G=ce(A,P,it,st,Y,q,K,V)){var ot=A-G[0],lt=P-G[1],ct=Y-G[0],dt=q-G[1],_t=1/$(jt((ot*ct+lt*dt)/(W(ot*ot+lt*lt)*W(ct*ct+dt*dt)))/2),Rt=W(G[0]*G[0]+G[1]*G[1]);C=rt(B,(c-Rt)/(_t-1)),I=rt(B,(y-Rt)/(_t+1));}else C=I=0;}N>S?I>S?(p=nt(it,st,A,P,y,I,x),b=nt(Y,q,K,V,y,I,x),l.moveTo(p.cx+p.x01,p.cy+p.y01),I<B?l.arc(p.cx,p.cy,I,_(p.y01,p.x01),_(b.y01,b.x01),!x):(l.arc(p.cx,p.cy,I,_(p.y01,p.x01),_(p.y11,p.x11),!x),l.arc(0,0,y,_(p.cy+p.y11,p.cx+p.x11),_(b.cy+b.y11,b.cx+b.x11),!x),l.arc(b.cx,b.cy,I,_(b.y11,b.x11),_(b.y01,b.x01),!x))):(l.moveTo(A,P),l.arc(0,0,y,h,M,!x)):l.moveTo(A,P),!(c>S)||!(u>S)?l.lineTo(K,V):C>S?(p=nt(K,V,Y,q,c,-C,x),b=nt(A,P,it,st,c,-C,x),l.lineTo(p.cx+p.x01,p.cy+p.y01),C<B?l.arc(p.cx,p.cy,C,_(p.y01,p.x01),_(b.y01,b.x01),!x):(l.arc(p.cx,p.cy,C,_(p.y01,p.x01),_(p.y11,p.x11),!x),l.arc(0,0,c,_(p.cy+p.y11,p.cx+p.x11),_(b.cy+b.y11,b.cx+b.x11),x),l.arc(b.cx,b.cy,C,_(b.y11,b.x11),_(b.y01,b.x01),!x))):l.arc(0,0,c,f,T,x);}if(l.closePath(),s)return l=null,s+""||null}return d.centroid=function(){var s=(+i.apply(this,arguments)+ +t.apply(this,arguments))/2,g=(+e.apply(this,arguments)+ +n.apply(this,arguments))/2-Z/2;return [z(g)*s,$(g)*s]},d.innerRadius=function(s){return arguments.length?(i=typeof s=="function"?s:H(+s),d):i},d.outerRadius=function(s){return arguments.length?(t=typeof s=="function"?s:H(+s),d):t},d.cornerRadius=function(s){return arguments.length?(a=typeof s=="function"?s:H(+s),d):a},d.padRadius=function(s){return arguments.length?(r=s==null?null:typeof s=="function"?s:H(+s),d):r},d.startAngle=function(s){return arguments.length?(e=typeof s=="function"?s:H(+s),d):e},d.endAngle=function(s){return arguments.length?(n=typeof s=="function"?s:H(+s),d):n},d.padAngle=function(s){return arguments.length?(o=typeof s=="function"?s:H(+s),d):o},d.context=function(s){return arguments.length?(l=s??null,d):l},d}var ue=["bmsSvg"];function pe(i,t){if(i&1&&$h(0,"widget-title",1),i&2){let a=qw();Bh("text",a.displayLabel())("color",a.labelColor());}}function me(i,t){i&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No batteries detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K battery paths or select batteries in widget settings."),ul()());}var ee=class i{static BMS_DESCRIPTOR=a("widget-bms");static ROOT_PATTERN=`${i.BMS_DESCRIPTOR?.selfRootPath??"self.electrical.batteries"}.*`;id=Hj.required();type=Hj.required();theme=Hj.required();renderMode=Hj(null);static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,bms:{trackedDevices:[],groups:[],banks:[]}};static VIEWBOX_WIDTH=200;static MIN_VIEWBOX_HEIGHT=1;static BANK_CARD_WIDTH=200;static BATTERY_CARD_HEIGHT=50;static BATTERY_CARD_WIDTH=200;static CARD_GAP=8;static BANK_HEADER_HEIGHT=80;static BANK_MIN_HEIGHT=75;static SINGLE_ROW_BANK_HEIGHT=100;static IN_BANK_COLUMNS=2;static IN_BANK_COLUMN_GAP=5;static IN_BANK_PADDING_X=0;static BANK_GAUGE_RADIUS=50;static BANK_GAUGE_BG_STROKE=10;static BANK_GAUGE_VALUE_STROKE=10;static COMPACT_UNASSIGNED_BATTERY_SCALE=.82;static PATH_BATCH_WINDOW_MS=500;runtime=w(p);data=w(De);units=w(ut);iconRegistry=w(K);destroyRef=w(xe);svgRef=$j.required("bmsSvg");svg;root;bankLayer;batteryLayer;bankGaugeBackgroundPath=this.buildSemiGaugeArcPath(i.BANK_GAUGE_RADIUS,1);glowFilterId="";renderFrameId=null;pendingRenderSnapshot=null;pathBatchTimerId=null;initialPathPaintDone=false;pendingPathUpdates=new Map;powerAvailableIconTemplate=null;powerRenewalIconTemplate=null;discoveredBatteryIds=vt([]);trackedBatteryDeviceIds=vt([]);banks=vt([]);cardMode=vt({displayMode:"full",metrics:[]});batteries=vt({});visibleBatteryIds=Dt(()=>{let t=this.trackedBatteryDeviceIds();return t.length?t:this.discoveredBatteryIds()});visibleBatteries=Dt(()=>{let t=this.visibleBatteryIds(),a=this.batteries();return t.map(r=>a[r]).filter(r=>!!r)});bankSummaries=Dt(()=>{let t=this.banks(),a=this.batteries();return t.map(r=>this.buildBankSummary(r,a))});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 t=this.bankSummaries();if(t.length===1)return t[0].name||"Bank";if(t.length>1)return "Batteries";let a=this.visibleBatteries();return a.length!==1?"Batteries":this.resolveBatteryTitleText(a[0])});labelColor=Dt(()=>{let t=this.theme();return t?c(this.colorRole(),t).dim:"var(--kip-contrast-dim-color)"});widgetColors=Dt(()=>{let t=this.theme();return t?c(this.colorRole(),t):null});batteryDisplayModels=Dt(()=>{let t=this.visibleBatteries(),a=this.theme(),r=this.widgetColors(),e$1=this.ignoreZones(),n={};for(let o of t){let l=e(o.stateOfChargeState,r?.dimmer??"var(--kip-contrast-dimmer-color)",a,e$1),m=e(o.stateOfChargeState,r?.dim??"var(--kip-contrast-dim-color)",a,e$1),d=e(o.currentState,"var(--kip-contrast-dim-color)",a,e$1),s=e(o.currentState,"var(--kip-contrast-color)",a,e$1);n[o.id]={id:o.id,titleText:this.resolveBatteryTitleText(o),chargeWidth:(i.BATTERY_CARD_WIDTH-3)*(o.stateOfCharge??0),chargeBarColorCompact:l,chargeBarColorRegular:m,currentTextColorCompact:d,currentTextColorRegular:s,currentText:`${this.formatCurrent(o.current)}`.trim(),detailLineCompact:`${this.formatVoltage(o.voltage)}\xA0\xA0\xA0\xA0${this.formatTemperature(o.temperature)}`,detailLineRegular:`${this.formatVoltage(o.voltage)}\xA0\xA0\xA0\xA0${this.formatPower(o.power)}\xA0\xA0\xA0\xA0${this.formatTemperature(o.temperature)}`.trim(),socText:this.formatSoc(o.stateOfCharge),socGlowEnabled:!e$1&&(o.stateOfChargeState===n$1.Warn||o.stateOfChargeState===n$1.Alarm||o.stateOfChargeState===n$1.Alert),remainingCapacityText:o.capacityActual?`${this.formatEnergy(o.capacityRemaining)}`:"",remainingTimeText:`${this.formatDuration(o.timeRemaining)}`.trim(),iconKey:o.current!=null&&o.current>0?"power_renewal":"power_available"};}return n});bankDisplayModels=Dt(()=>{let t=this.bankSummaries(),a=this.widgetColors(),r={};for(let e of t)r[e.id]={id:e.id,titleText:e.name||"Bank",currentText:this.formatCurrent(e.totalCurrent),powerText:this.formatPower(e.totalPower),socText:this.formatSoc(e.avgSoc),remainingTimeText:`${this.formatDuration(e.timeRemaining)}`.trim(),remainingCapacityText:e.remainingCapacity?`${this.formatEnergy(e.remainingCapacity)}`:"",gaugeValuePath:this.buildSemiGaugeArcPath(i.BANK_GAUGE_RADIUS,e.avgSoc),gaugeValueColor:a?.color??"var(--kip-contrast-color)",zoneState:null,zoneColor:null};return r});hasBatteries=Dt(()=>this.visibleBatteries().length>0);hasBanks=Dt(()=>this.bankSummaries().length>0);constructor(){Fa(()=>{let a=this.runtime.options();a&&ge(()=>this.applyConfig(a));}),Fa(()=>{let a=this.bankSummaries(),r=this.visibleBatteries(),e=this.widgetColors(),n=this.batteryDisplayModels(),o=this.bankDisplayModels();!this.svg||!e||this.requestRender({banks:a,batteries:r,batteryDisplayModels:n,bankDisplayModels:o,widgetColors:e});});let t=this.data.subscribePathTreeWithInitial(i.ROOT_PATTERN);if(t.initial.length){for(let a of t.initial)this.enqueuePathUpdate(a,true);this.flushPendingPathUpdates(),this.initialPathPaintDone=true;}t.live$.pipe(Gp(this.destroyRef)).subscribe(a=>{this.enqueuePathUpdate(a);});}ngAfterViewInit(){this.initializeSvg(),this.loadPowerIcons(),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 ${i.VIEWBOX_WIDTH} ${i.MIN_VIEWBOX_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","Battery Management System View"),this.glowFilterId=`bms-soc-glow-${this.id()}`;let a=this.svg.append("defs").append("filter").attr("id",this.glowFilterId).attr("x","-30%").attr("y","-30%").attr("width","160%").attr("height","160%");a.append("feFlood").attr("class","bms-soc-glow-flood").attr("flood-color","var(--kip-widget-card-background-color)").attr("flood-opacity",.9).attr("result","color"),a.append("feComposite").attr("in","color").attr("in2","SourceGraphic").attr("operator","in").attr("result","coloredGlow"),a.append("feGaussianBlur").attr("in","coloredGlow").attr("stdDeviation",2).attr("result","blur");let r=a.append("feMerge");r.append("feMergeNode").attr("in","blur"),r.append("feMergeNode").attr("in","blur"),r.append("feMergeNode").attr("in","SourceGraphic"),this.root=this.svg.append("g").attr("class","bms-root"),this.bankLayer=this.root.append("g").attr("class","bms-banks"),this.batteryLayer=this.root.append("g").attr("class","bms-batteries");}loadPowerIcons(){this.loadNamedIcon("power_available",t=>{this.powerAvailableIconTemplate=t;}),this.loadNamedIcon("power_renewal",t=>{this.powerRenewalIconTemplate=t;});}loadNamedIcon(t,a){this.iconRegistry.getNamedSvgIcon(t).pipe(_t(1)).subscribe({next:r=>{a(r),this.requestRender();},error:()=>{}});}applyConfig(t){let a=this.resolveBmsConfig(t);this.trackedBatteryDeviceIds.set([...new Set((a.trackedDevices??[]).map(r=>r.id))]),this.banks.set(a.banks),this.cardMode.set(this.normalizeCardMode(a.cardMode));}resolveBmsConfig(t){let a=t.bms,r=this.normalizeTrackedDevices(a?.trackedDevices),e=this.normalizeBanksFromGroups(a?.groups),n=this.normalizeBanksFromLegacy(a?.banks);return {trackedDevices:r,groups:e,banks:e.length>0?e:n,cardMode:this.normalizeCardMode(a?.cardMode)}}normalizeTrackedDevices(t){if(!Array.isArray(t))return [];let a=new Map;return t.forEach(r=>{if(!r||typeof r!="object")return;let e=r,n=typeof e.id=="string"?e.id.trim():"",o=typeof e.source=="string"?e.source.trim():"default";if(!n||!o)return;let l=typeof e.key=="string"&&e.key.trim().length>0?e.key.trim():`${n}||${o}`;a.set(l,{id:n,source:o,key:l});}),[...a.values()].sort((r,e)=>r.key.localeCompare(e.key))}normalizeCardMode(t){let a=t&&typeof t=="object"?t:null,r=this.normalizeStringList(a?.metrics);return {displayMode:a?.displayMode==="compact"?"compact":"full",metrics:r}}normalizeStringList(t){if(!Array.isArray(t))return [];let a=new Set;return t.forEach(r=>{if(typeof r!="string")return;let e=r.trim();e.length>0&&a.add(e);}),[...a].sort((r,e)=>r.localeCompare(e))}normalizeBanksFromGroups(t){return Array.isArray(t)?t.map(a=>{let r=this.normalizeOptionalString(a?.id)??`bank-${Date.now()}`,e=this.normalizeOptionalString(a?.name)??r,n=this.normalizeStringList(a?.memberIds);return {id:r,name:e,batteryIds:n,connectionMode:this.normalizeConnectionMode(a?.connectionMode)}}).filter(a=>a.id.length>0):[]}normalizeBanksFromLegacy(t){return Array.isArray(t)?t.map(a=>{let r=this.normalizeOptionalString(a?.id)??`bank-${Date.now()}`,e=this.normalizeOptionalString(a?.name)??r,n=this.normalizeStringList(a?.batteryIds);return {id:r,name:e,batteryIds:n,connectionMode:this.normalizeConnectionMode(a?.connectionMode)}}).filter(a=>a.id.length>0):[]}normalizeOptionalString(t){if(typeof t!="string")return null;let a=t.trim();return a.length>0?a:null}normalizeConnectionMode(t){return t==="series"?"series":"parallel"}enqueuePathUpdate(t,a=false){let r=this.parseBatteryPath(t.path);if(!r)return;let{id:e,key:n}=r,o=t.update?.data?.value??null,l=t.update?.state??null,m=`${e}::${n}`;if(this.pendingPathUpdates.set(m,{id:e,key:n,value:o,state:l}),!a){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=window.setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},i.PATH_BATCH_WINDOW_MS));}}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let t=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(t.map(r=>r.id)).forEach(r=>this.trackDiscoveredBattery(r)),this.batteries.update(r=>{let e=r,n=false;for(let o of t){let l=e[o.id]??{id:o.id},m=G({},l),d=this.applyBatteryValue(m,o.key,o.value,o.state),s=false;if(m.voltage!=null&&m.current!=null){let g=Number.isFinite(m.voltage)&&Number.isFinite(m.current)?m.voltage*m.current:null;Object.is(m.power,g)||(m.power=g,s=true);}!d&&!s||(n||(e=G({},e),n=true),e[o.id]=m);}return n?e:r});}parseBatteryPath(t){let a=t.match(/self\.electrical\.batteries\.([^.]+)\.(.+)$/);return a?{id:a[1],key:a[2]}:null}trackDiscoveredBattery(t){let a=this.discoveredBatteryIds();if(a.includes(t))return;let r=[...a,t].sort();this.discoveredBatteryIds.set(r);}applyBatteryValue(t,a,r,e){switch(a){case "name":{let n=r;return t.name===n?false:(t.name=n,true)}case "location":{let n=r;return t.location===n?false:(t.location=n,true)}case "associatedBus":{let n=r;return t.associatedBus===n?false:(t.associatedBus=n,true)}case "chemistry":{let n=r;return t.chemistry===n?false:(t.chemistry=n,true)}case "voltage":{let n=this.toNumber(r);return Object.is(t.voltage,n)?false:(t.voltage=n,true)}case "current":{let n=this.toNumber(r),o=!Object.is(t.currentState??null,e??null);return Object.is(t.current,n)&&!o?false:(t.current=n,t.currentState=e,true)}case "temperature":{let n=this.toNumber(r);return Object.is(t.temperature,n)?false:(t.temperature=n,true)}case "capacity.nominal":{let n=this.toNumber(r);return Object.is(t.capacityNominal,n)?false:(t.capacityNominal=n,true)}case "capacity.actual":{let n=this.toNumber(r);return Object.is(t.capacityActual,n)?false:(t.capacityActual=n,true)}case "capacity.remaining":{let n=this.toNumber(r);return Object.is(t.capacityRemaining,n)?false:(t.capacityRemaining=n,true)}case "capacity.stateOfCharge":{let n=this.toNumber(r),o=!Object.is(t.stateOfChargeState??null,e??null);return Object.is(t.stateOfCharge,n)&&!o?false:(t.stateOfCharge=n,t.stateOfChargeState=e,true)}case "capacity.timeRemaining":{let n=this.toNumber(r);return Object.is(t.timeRemaining,n)?false:(t.timeRemaining=n,true)}default:return false}}buildBankSummary(t,a){let r=t.batteryIds.map(s=>a[s]).filter(s=>!!s),e=this.normalizeConnectionMode(t.connectionMode),n=this.calculateBankCurrent(r,e),o=this.sumNumbers(r.map(s=>s.power)),l=this.sumNumbers(r.map(s=>s.capacityRemaining)),m=this.calculateBankSoc(r),d=this.calculateBankTimeRemaining(r,e);return {id:t.id,name:t.name,batteryIds:t.batteryIds,totalCurrent:n,totalPower:o,remainingCapacity:l,avgSoc:m,timeRemaining:d}}calculateBankSoc(t){let a=this.sumNumbers(t.map(n=>n.capacityRemaining)),r=this.sumNumbers(t.map(n=>n.capacityActual));if(a!=null&&r!=null&&r>0)return Math.max(0,Math.min(1,a/r));let e=this.sumNumbers(t.map(n=>n.capacityNominal));return a!=null&&e!=null&&e>0?Math.max(0,Math.min(1,a/e)):this.averageNumbers(t.map(n=>n.stateOfCharge))}calculateBankCurrent(t,a){let r=t.map(e=>e.current);return a==="series"?this.averageNumbers(r):this.sumNumbers(r)}calculateBankTimeRemaining(t,a){let r=t.map(e=>e.timeRemaining);return a==="series"?this.minNumber(r):this.averageNumbers(r)}requestRender(t){this.svg&&(this.pendingRenderSnapshot=t??this.buildRenderSnapshot(),this.pendingRenderSnapshot&&this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;let a=this.pendingRenderSnapshot;this.pendingRenderSnapshot=null,a&&this.render(a);})));}buildRenderSnapshot(){let t=this.widgetColors();return t?{banks:this.bankSummaries(),batteries:this.visibleBatteries(),batteryDisplayModels:this.batteryDisplayModels(),bankDisplayModels:this.bankDisplayModels(),widgetColors:t}:null}render(t){if(!this.bankLayer||!this.batteryLayer)return;let{banks:a,batteries:r,bankDisplayModels:e,batteryDisplayModels:n,widgetColors:o}=t,l=this.buildRenderLayout(a,r,e,n,this.isCompactCardMode()),d=this.isCompactCardMode()?e$1:e$1,s=Math.max(i.MIN_VIEWBOX_HEIGHT,l.contentHeight);this.svg?.attr("viewBox",`0 0 ${i.VIEWBOX_WIDTH} ${s}`),this.root?.attr("transform",null);let g=this.bankLayer.selectAll("g.bank-card").data(l.banks,u=>u.id),c=g.enter().append("g").attr("class","bank-card"),y=c.append("text").attr("class","bank-card-power");y.append("tspan").attr("class","bank-card-power-value"),y.append("tspan").attr("class","bank-card-power-unit");let v=c.append("text").attr("class","bank-card-current");v.append("tspan").attr("class","bank-card-current-value"),v.append("tspan").attr("class","bank-card-current-unit");let k=c.append("g").attr("class","bank-gauge");k.append("path").attr("class","bank-gauge-bg"),k.append("path").attr("class","bank-gauge-value");let R=k.append("text").attr("class","bank-gauge-soc");R.append("tspan").attr("class","bank-gauge-soc-value"),R.append("tspan").attr("class","bank-gauge-soc-unit");let x=c.append("text").attr("class","bank-actualCapacity");x.append("tspan").attr("class","bank-actualCapacity-value"),x.append("tspan").attr("class","bank-actualCapacity-unit"),c.append("text").attr("class","bank-remaining"),c.append("g").attr("class","bank-bms-batteries"),c.append("text").attr("class","bank-title");let h=c.merge(g);h.attr("transform",u=>`translate(${u.x},${u.y})`),l.banks.length>1?h.select("text.bank-title").attr("x",d.titleX).attr("y",d.titleY).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",d.titleFontSize).text(u=>u.displayModel.titleText):h.select("text.bank-title").text(""),h.select("text.bank-card-current").attr("x",d.lineOneX).attr("y",d.lineOneY).attr("fill","var(--kip-contrast-color)").attr("font-size",d.lineOneFontSize),h.select("tspan.bank-card-current-value").text(u=>this.splitMetricText(u.displayModel.currentText,"A").valueText),h.select("tspan.bank-card-current-unit").attr("dx",1).attr("font-size",12).attr("fill","var(--kip-contrast-color)").text(u=>this.splitMetricText(u.displayModel.currentText,"A").unitText),h.select("text.bank-card-power").attr("x",5).attr("y",42).attr("fill","var(--kip-contrast-color)").attr("font-size",10).attr("opacity",.8),h.select("tspan.bank-card-power-value").text(u=>this.splitMetricText(u.displayModel.powerText,"W").valueText),h.select("tspan.bank-card-power-unit").attr("dx",1).attr("font-size",6).attr("fill","var(--kip-contrast-color)").text(u=>this.splitMetricText(u.displayModel.powerText,"W").unitText),h.select("g.bank-gauge").attr("transform","translate(143, 60)"),h.select("path.bank-gauge-bg").attr("d",this.bankGaugeBackgroundPath).attr("fill","none").attr("stroke","var(--kip-contrast-dimmer-color)").attr("stroke-width",i.BANK_GAUGE_BG_STROKE).attr("stroke-linecap","round"),h.select("path.bank-gauge-value").attr("d",u=>u.displayModel.gaugeValuePath).attr("fill","none").attr("stroke",u=>u.displayModel.gaugeValueColor).attr("stroke-width",i.BANK_GAUGE_VALUE_STROKE).attr("stroke-linecap","round"),h.select("text.bank-gauge-soc").attr("x",0).attr("y",-5).attr("text-anchor","middle").attr("fill","var(--kip-contrast-color)").attr("font-size",d.primaryFontSize).attr("font-weight",d.primaryFontWeight),h.select("tspan.bank-gauge-soc-value").text(u=>this.splitMetricText(u.displayModel.socText,"%").valueText),h.select("tspan.bank-gauge-soc-unit").attr("dx",1).attr("font-size",22).attr("font-weight",500).attr("fill","var(--kip-contrast-color)").text(u=>this.splitMetricText(u.displayModel.socText,"%").unitText),h.select("text.bank-remaining").attr("x",143).attr("y",26).attr("fill","var(--kip-contrast-dim-color)").attr("text-anchor","middle").attr("font-size",8).text(u=>u.displayModel.remainingTimeText),h.select("text.bank-actualCapacity").attr("x",143).attr("y",66).attr("fill","var(--kip-contrast-dim-color)").attr("text-anchor","middle").attr("font-size",8),h.select("tspan.bank-actualCapacity-value").text(u=>this.splitMetricText(u.displayModel.remainingCapacityText,"kWh").valueText),h.select("tspan.bank-actualCapacity-unit").attr("dx",1).attr("font-size",6).attr("fill","var(--kip-contrast-dim-color)").text(u=>this.splitMetricText(u.displayModel.remainingCapacityText,"kWh").unitText),h.select("g.bank-bms-batteries").each((u,N,w)=>{let B=ge$1(w[N]).selectAll("g.battery-card").data(u.batteries,p=>p.key),C=B.enter().append("g").attr("class","battery-card battery-card--in-bank");this.appendBatteryCardSkeleton(C);let I=C.merge(B);this.renderBatteryCards(I,o,t.batteries.length>1),B.exit().remove();}),g.exit().remove();let M=this.batteryLayer.selectAll("g.battery-card").data(l.unassignedBatteries,u=>u.key),T=M.enter().append("g").attr("class","battery-card battery-card--unassigned");this.appendBatteryCardSkeleton(T);let f=T.merge(M);this.renderBatteryCards(f,o,true),M.exit().remove(),this.root?.attr("data-theme","ready");}buildRenderLayout(t,a,r,e,n){let o=new Map(a.map(f=>[f.id,f])),l=new Set,m=this.computeInBankBatterySlotWidth(),d=Math.max(.35,Math.min(1,m/i.BATTERY_CARD_WIDTH)),s=i.BATTERY_CARD_HEIGHT*d,g=0,c=t.map(f=>{let u=new Set,N=f.batteryIds.map(A=>o.get(A)).filter(A=>!A||u.has(A.id)?false:(u.add(A.id),true));N.forEach(A=>l.add(A.id));let w=Math.ceil(N.length/i.IN_BANK_COLUMNS),E=i.SINGLE_ROW_BANK_HEIGHT,B=!n&&w===1,C=B?Math.max(0,E-s-i.CARD_GAP):i.BANK_HEADER_HEIGHT,I=w>0?w*s+(w-1)*i.CARD_GAP:0,p=Math.max(i.BANK_MIN_HEIGHT,C+I+i.CARD_GAP),b=B?E:p,O=N.map((A,P)=>{let K=P%i.IN_BANK_COLUMNS,V=Math.floor(P/i.IN_BANK_COLUMNS),Y=i.IN_BANK_PADDING_X+K*(m+i.IN_BANK_COLUMN_GAP),q=C+7+V*(s+i.CARD_GAP);return {id:A.id,displayModel:e[A.id],key:`${f.id}::${A.id}`,x:Y,y:q,scale:d,inBank:true,compact:true}}),U={id:f.id,name:f.name,batteryIds:f.batteryIds,totalCurrent:f.totalCurrent,totalPower:f.totalPower,avgSoc:f.avgSoc,remainingCapacity:f.remainingCapacity,timeRemaining:f.timeRemaining,displayModel:r[f.id],x:0,y:g,width:i.BANK_CARD_WIDTH,height:b,batteries:O};return g+=b+i.CARD_GAP,U}),y=c.length>0?g:0,v=n?i.COMPACT_UNASSIGNED_BATTERY_SCALE:1,k=i.BATTERY_CARD_HEIGHT*v,R=a.filter(f=>!l.has(f.id)).sort((f,u)=>f.id.localeCompare(u.id)).map((f,u)=>({id:f.id,displayModel:e[f.id],key:f.id,x:0,y:y+u*(k+i.CARD_GAP),scale:v,inBank:false,compact:n})),x=c[c.length-1],h=x?x.y+x.height:0,M=R[R.length-1],T=M?M.y+k:0;return {banks:c,unassignedBatteries:R,contentHeight:Math.max(h,T)}}computeInBankBatterySlotWidth(){return (i.BANK_CARD_WIDTH-i.IN_BANK_PADDING_X*2-i.IN_BANK_COLUMN_GAP)/i.IN_BANK_COLUMNS}appendBatteryCardSkeleton(t){t.append("rect").attr("class","bms-battery").attr("rx",4).attr("ry",4),t.append("rect").attr("class","bms-battery-tip").attr("rx",1).attr("ry",1),t.append("rect").attr("class","bms-charge-fill").attr("rx",3).attr("ry",3),t.append("g").attr("class","bms-state-icon"),t.append("text").attr("class","bms-ampere"),t.append("text").attr("class","bms-volt-power");let a=t.append("text").attr("class","bms-soc");a.append("tspan").attr("class","bms-soc-value"),a.append("tspan").attr("class","bms-soc-unit"),t.append("text").attr("class","bms-actualCapacity"),t.append("text").attr("class","bms-remaining"),t.append("text").attr("class","bms-title");}renderBatteryCards(t,a,r){t.attr("transform",e=>`translate(${e.x},${e.y}) scale(${e.scale})`),t.select("rect.bms-battery").attr("width",e=>e.inBank?i.BATTERY_CARD_WIDTH:e.compact?i.BATTERY_CARD_WIDTH-i.CARD_GAP:i.BATTERY_CARD_WIDTH).attr("height",i.BATTERY_CARD_HEIGHT).attr("fill",e=>e.compact?"var(--mat-sys-background)":"var(--kip-contrast-dimmer-color)").attr("stroke","var(--kip-contrast-dimmer-color)").attr("stroke-width",0),t.select("rect.bms-battery-tip").attr("x",i.BATTERY_CARD_WIDTH).attr("y",i.BATTERY_CARD_HEIGHT/2-10).attr("width",4).attr("height",20).attr("fill",e=>e.compact?"var(--mat-sys-background)":"var(--kip-contrast-dimmer-color)").attr("stroke",a.color).attr("stroke-width",0),t.select("rect.bms-charge-fill").attr("x",1.5).attr("y",1.5).attr("width",e=>e.displayModel.chargeWidth).attr("height",i.BATTERY_CARD_HEIGHT-3).attr("fill",e=>e.compact?e.displayModel.chargeBarColorCompact:e.displayModel.chargeBarColorRegular),r?t.select("text.bms-title").attr("x",5).attr("y",e=>e.compact?11:14).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",e=>e.compact?8:12).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.displayModel.titleText):t.select("text.bms-title").text(""),t.select("text.bms-ampere").attr("x",10).attr("y",33).attr("fill",e=>e.compact?e.displayModel.currentTextColorCompact:e.displayModel.currentTextColorRegular).attr("font-size",16).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.displayModel.currentText),t.select("text.bms-volt-power").attr("x",10).attr("y",45).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",8).attr("opacity",.8).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.compact?e.displayModel.detailLineCompact:e.displayModel.detailLineRegular),t.select("text.bms-soc").attr("x",i.BATTERY_CARD_WIDTH-33).attr("y",34).attr("fill",e=>e.compact?"var(--kip-contrast-dim-color)":"var(--kip-contrast-color)").attr("text-anchor","middle").attr("font-size",25).attr("font-weight",700).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null),t.select("tspan.bms-soc-value").text(e=>this.splitMetricText(e.displayModel.socText,"%").valueText),t.select("tspan.bms-soc-unit").attr("dx",1).attr("font-size",16).attr("font-weight",500).text(e=>this.splitMetricText(e.displayModel.socText,"%").unitText),t.select("text.bms-actualCapacity").attr("x",i.BATTERY_CARD_WIDTH-33).attr("y",45).attr("fill","var(--kip-contrast-dim-color)").attr("text-anchor","middle").attr("font-size",8).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.compact?"":e.displayModel.remainingCapacityText),t.select("text.bms-remaining").attr("x",i.BATTERY_CARD_WIDTH-33).attr("y",12).attr("fill","var(--kip-contrast-dim-color)").attr("text-anchor","middle").attr("font-size",6).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.compact?"":e.displayModel.remainingTimeText),t.select("g.bms-state-icon").attr("transform",`translate(${i.BATTERY_CARD_WIDTH/2-18}, ${i.BATTERY_CARD_HEIGHT/2-18})`).attr("display",e=>e.compact&&e.scale<.45?"none":null).attr("color",e=>e.compact?a.dim:a.color).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).each((e,n,o)=>{let l=ge$1(o[n]),m=e.displayModel.iconKey,d=m==="power_renewal"?this.powerRenewalIconTemplate:this.powerAvailableIconTemplate;if(!d){l.selectAll("*").remove(),l.attr("data-icon-key",null);return}let s=l.node();if(!s||l.attr("data-icon-key")===m&&s.firstElementChild)return;l.selectAll("*").remove();let c=d.cloneNode(true);c.removeAttribute("id"),c.setAttribute("width","36"),c.setAttribute("height","36"),c.getAttribute("viewBox")||c.setAttribute("viewBox","0 0 24 24"),s.appendChild(c),l.attr("data-icon-key",m);});}formatVoltage(t){return t==null?"-- V":`${t.toFixed(1)}V`}formatCurrent(t){return t==null?"-- A":`${t.toFixed(1)}A`}formatPower(t){return t==null?"":`${t.toFixed(0)}W`}formatEnergy(t){return t==null?"":(t=this.units.convertToUnit("kWh",t),`${t}kWh`)}formatSoc(t){return t==null?"--%":`${Math.round(t*100)}%`}resolveBatteryTitleText(t){return t.name||`Battery ${t.id}`}formatDuration(t){if(t==null)return "";let a=this.units.convertToUnit("D HH:MM:SS",t);return a==null?"":typeof a=="string"?a:`${a}`}formatTemperature(t){if(t==null||typeof t!="number")return "";let a=this.units.getDefaults().Temperature,r=this.units.convertToUnit(a,t);return r===null?"":`${r.toFixed(1)} ${a==="celsius"?"\xB0C":"\xB0F"}`}splitMetricText(t,a){if(!t)return {valueText:"",unitText:""};let r=t.trim();return r?r.endsWith(a)?{valueText:r.slice(0,Math.max(0,r.length-a.length)).trim(),unitText:a}:{valueText:r,unitText:""}:{valueText:"",unitText:""}}sumNumbers(t){let a=t.filter(r=>typeof r=="number");return a.length?a.reduce((r,e)=>r+e,0):null}averageNumbers(t){let a=t.filter(r=>typeof r=="number");return a.length?a.reduce((r,e)=>r+e,0)/a.length:null}minNumber(t){let a=t.filter(r=>typeof r=="number");return a.length?Math.min(...a):null}toNumber(t){return t==null||typeof t!="number"?null:t}buildSemiGaugeArcPath(t,a){let r=Math.max(0,Math.min(1,a??0)),e=-Math.PI*.55,n=Math.PI*1.1,o=e+n*r;if(r<=0){let l=t*Math.cos(e),m=t*Math.sin(e);return `M ${l} ${m}`}return Bt()({innerRadius:t,outerRadius:t,startAngle:e,endAngle:o})??""}static \u0275fac=function(a){return new(a||i)};static \u0275cmp=JD({type:i,selectors:[["widget-bms"]],viewQuery:function(a,r){a&1&&eg(r.svgRef,ue,5),a&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:4,consts:[["bmsSvg",""],[3,"text","color"],["aria-hidden","false",1,"bms-svg"],[1,"bms-empty"],[1,"bms-empty-title"],[1,"bms-empty-sub"]],template:function(a,r){a&1&&(_w(0,pe,1,2,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,me,5,0,"div",3)),a&2&&(Mw(r.hasBanks()?0:-1),EE(),sg("bms-svg--full",!r.hasBanks()),EE(2),Mw(r.hasBatteries()?-1:3));},dependencies:[yt,x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.bms-svg[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;padding:0 10px 10px}.bms-svg.bms-svg--full[_ngcontent-%COMP%]{top:0;height:100%;padding-top:10px}.bms-card-metric[_ngcontent-%COMP%]{fill:var(--mat-sys-on-surface);font-size:30px;font-weight:700}.bms-card-sub[_ngcontent-%COMP%]{fill:var(--mat-sys-on-surface);font-size:18px;opacity:.9}.bms-card-meta[_ngcontent-%COMP%]{fill:var(--mat-sys-on-surface);font-size:15px;opacity:.75}.bms-card-footer[_ngcontent-%COMP%]{fill:var(--mat-sys-on-surface);font-size:16px;opacity:.8}.bms-flow-line[_ngcontent-%COMP%]{stroke:var(--kip-zone-nominal-color);stroke-width:3px;stroke-dasharray:6 6;animation:_ngcontent-%COMP%_flow-dash 2s linear infinite}.bms-flow-line--out[_ngcontent-%COMP%]{stroke:var(--kip-zone-warn-color)}.bms-flow-line--in[_ngcontent-%COMP%]{stroke:var(--kip-zone-nominal-color)}.bms-flow-line--neutral[_ngcontent-%COMP%]{stroke:var(--kip-widget-card-border-color);animation:none}.bms-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)}.bms-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.bms-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}@keyframes _ngcontent-%COMP%_flow-dash{to{stroke-dashoffset:-12}}"]})};export{ee as WidgetBmsComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {WidgetFreeboardskComponent as ae}from'./chunk-
|
|
1
|
+
import {WidgetFreeboardskComponent as ae}from'./chunk-CYYBxjrc.js';import {$ as $j,w,G as Gi,a as G$1,i as ir,v as vt,D as Dt,W as Wp,E as Em,F as Fa,J as JD,Q as Qn,z as za,q as qo,O as Op,R as Rp,y as yt,b as wt,P as Pi,_ as _w,c as $h,u as ul,d as ig,B as Bh,j as jT,e as EE,M as Mw,s as sg,f as eg,K as Kw,g as qw,h as Fw,k as Qh,l as ud,m as dd}from'./main-YKDNK5VZ.js';import'./chunk-ibauGmSP.js';var G=["panel"],Q=(i,f)=>[i,f];function j(i,f){if(i&1&&$h(0,"div",7),i&2){let t=qw();ig("transform",t.ghostTransform());}}function H(i,f){if(i&1){let t=Fw();Pi(0,"div",8),Qh("pointerdown",function(n){ud(t);let o=qw();return dd(o.startResize(n))}),Pi(1,"button",9),Qh("pointerdown",function(n){ud(t);let o=qw();return dd(o.startResize(n))}),$h(2,"mat-icon",10),ul()();}}var pt=(()=>{class i{panelEl=$j.required("panel");_settings=w(Gi);_dashboard=w(G$1);breakpointObserver=w(ir);side=vt(this._settings.getSplitShellSide());panelRatio=vt(this._settings.getSplitShellWidth());originalPanelRatio=null;panelWidth=vt(0);panelCollapsed=Dt(()=>{let t=this._dashboard.dashboards(),e=this._dashboard.activeDashboard();return e==null||e<0?false:!!t[e]?.collapseSplitShell});_fskShellSwipeDisabled=Wp(this._settings.getSplitShellSwipeDisabledAsO(),{initialValue:false});fskShellSwipeDisabled=Dt(()=>this._fskShellSwipeDisabled()??false);handset$=this.breakpointObserver.observe(Em.HandsetPortrait);handset=Wp(this.handset$,{initialValue:{matches:false,breakpoints:{}}});freeboardWidgetStub={uuid:"persistent-freeboard-shell",type:"widget-freeboardsk",config:{}};chartplotterModeInPortrait=Dt(()=>this.handset().matches&&!this.panelCollapsed());canResize=Dt(()=>!this._dashboard.isDashboardStatic()&&!this.panelCollapsed());resizing=false;startX=0;startW=0;boundMove=t=>this.onMove(t);boundUp=()=>this.onUp();static MIN_DELTA_PX=1;ghostActive=vt(false);ghostTransform=vt("");ghostWidth=0;recomputeWidth=()=>{let t=this.panelEl()?.nativeElement.parentElement;if(!t)return;let e=t.clientWidth;this.panelWidth.set(Math.round(e*this.panelRatio()));};constructor(){window.addEventListener("resize",this.recomputeWidth,{passive:true}),queueMicrotask(this.recomputeWidth),Fa(()=>{this.chartplotterModeInPortrait(),this.panelRatio(),this.recomputeWidth(),setTimeout(()=>window.dispatchEvent(new Event("resize")),0);}),Fa(()=>{let t=this._dashboard.isDashboardStatic();t||this.originalPanelRatio===null&&(this.originalPanelRatio=this.panelRatio()),t&&this.originalPanelRatio;}),Fa(()=>{if(this._dashboard.layoutEditSaved(),this.originalPanelRatio!==null){let t=this.panelRatio();this._settings.setSplitShellWidth(t),this.originalPanelRatio=null;}}),Fa(()=>{if(this._dashboard.layoutEditCanceled(),this.originalPanelRatio!==null){let t=this.originalPanelRatio;this.panelRatio.set(t),queueMicrotask(()=>this.recomputeWidth()),this.originalPanelRatio=null;}});}startResize(t){this.canResize()&&(this.resizing=true,this.startX=t.clientX,this.startW=this.panelWidth(),this.ghostWidth=this.startW,this.ghostActive.set(true),this.updateGhostTransform(this.startW),t.target.setPointerCapture(t.pointerId),window.addEventListener("pointermove",this.boundMove,{passive:true}),window.addEventListener("pointerup",this.boundUp,{passive:true}));}onMove(t){if(!this.resizing)return;let e=this.side()==="left"?t.clientX-this.startX:this.startX-t.clientX,o=this.panelEl()?.nativeElement.parentElement?.clientWidth??1,p=this.startW+e,_=o*.1,$=o*.9,v=Math.min($,Math.max(_,p));Math.abs(v-this.ghostWidth)<i.MIN_DELTA_PX||(this.ghostWidth=v,this.updateGhostTransform(v));}onUp(){if(!this.resizing)return;this.resizing=false,window.removeEventListener("pointermove",this.boundMove),window.removeEventListener("pointerup",this.boundUp);let t=this.ghostWidth;this.ghostActive.set(false);let e=this.panelEl();e&&!this.panelCollapsed()&&(e.nativeElement.style.width=t+"px"),this.panelWidth.set(t);let o=this.panelEl()?.nativeElement.parentElement?.clientWidth??t,p=o?t/o:.3,_=this.panelRatio();Math.abs(p-_)>5e-4&&this.panelRatio.set(p);}updateGhostTransform(t){this.side()==="left"?this.ghostTransform.set(`translateX(${t}px)`):this.ghostTransform.set(`translateX(-${t}px)`);}ngOnDestroy(){window.removeEventListener("resize",this.recomputeWidth),this.resizing&&(window.removeEventListener("pointermove",this.boundMove),window.removeEventListener("pointerup",this.boundUp));}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=JD({type:i,selectors:[["split-shell"]],viewQuery:function(e,n){e&1&&eg(n.panelEl,G,5),e&2&&Kw();},decls:8,vars:18,consts:[["panel",""],[1,"split-root",3,"ngClass"],[1,"resize-ghost",3,"transform"],[1,"fsk-shell"],["role","separator","aria-label","Resize Freeboard chartplotter panel","aria-orientation","vertical",1,"drag-handle"],[1,"fsk-iframe",3,"type","id","swipeDisabled","disableWidgetShell"],[1,"dash-container"],[1,"resize-ghost"],["role","separator","aria-label","Resize Freeboard chartplotter panel","aria-orientation","vertical",1,"drag-handle",3,"pointerdown"],["mat-mini-fab","","tabindex","-1","aria-hidden","true",1,"drag-fab",3,"pointerdown"],["fontIcon","drag_indicator"]],template:function(e,n){e&1&&(Pi(0,"div",1),_w(1,j,1,2,"div",2),Pi(2,"div",3,0),_w(4,H,3,0,"div",4),$h(5,"widget-freeboardsk",5),ul(),Pi(6,"div",6),$h(7,"dashboard"),ul()()),e&2&&(ig("--panel-ratio",n.panelRatio()),Bh("ngClass",jT(15,Q,n.side()==="left"?"side-left":"side-right",n.chartplotterModeInPortrait()?"portrait-column":"")),EE(),Mw(n.ghostActive()?1:-1),EE(),ig("width",n.chartplotterModeInPortrait()?null:n.panelWidth(),"px"),sg("collapsed",n.panelCollapsed())("drag-disabled",!n.canResize()),EE(2),Mw(n.canResize()?4:-1),EE(),Bh("type",n.freeboardWidgetStub.type)("id",n.freeboardWidgetStub.uuid)("swipeDisabled",n.fskShellSwipeDisabled())("disableWidgetShell",true));},dependencies:[Qn,za,ae,qo,Op,Rp,yt,wt],styles:[".split-root[_ngcontent-%COMP%]{position:relative;width:100%;height:100%;display:flex;overflow:hidden}.split-root.side-left[_ngcontent-%COMP%]{flex-direction:row}.split-root.side-right[_ngcontent-%COMP%]{flex-direction:row-reverse}.split-root.portrait-column[_ngcontent-%COMP%]{flex-direction:column}.split-root.portrait-column[_ngcontent-%COMP%] .fsk-shell[_ngcontent-%COMP%], .split-root.portrait-column[_ngcontent-%COMP%] .dash-container[_ngcontent-%COMP%]{width:100%!important;min-height:0}.split-root.portrait-column[_ngcontent-%COMP%] .fsk-shell[_ngcontent-%COMP%]{flex:0 0 calc(var(--panel-ratio, .3) * 100%)}.split-root.portrait-column[_ngcontent-%COMP%] .dash-container[_ngcontent-%COMP%]{flex:1 1 auto;min-height:0;overflow:hidden}.split-root.side-left.portrait-column[_ngcontent-%COMP%] .dash-container[_ngcontent-%COMP%]{order:2}.split-root.side-left.portrait-column[_ngcontent-%COMP%] .fsk-shell[_ngcontent-%COMP%]{order:1}.split-root.side-right.portrait-column[_ngcontent-%COMP%] .fsk-shell[_ngcontent-%COMP%]{order:2}.split-root.side-right.portrait-column[_ngcontent-%COMP%] .dash-container[_ngcontent-%COMP%]{order:1}.split-root.portrait-column[_ngcontent-%COMP%] .fsk-shell.collapsed[_ngcontent-%COMP%]{flex:0 0 0!important}.split-root.portrait-column[_ngcontent-%COMP%] .drag-handle[_ngcontent-%COMP%], .split-root.portrait-column[_ngcontent-%COMP%] .resize-ghost[_ngcontent-%COMP%]{display:none}.fsk-shell[_ngcontent-%COMP%]{position:relative;height:100%;display:flex;flex-direction:column;background:var(--mat-sys-surface-container, #111);transition:width .2s ease}.fsk-shell.collapsed[_ngcontent-%COMP%]{width:1px!important;visibility:hidden;opacity:0;pointer-events:none}.fsk-iframe[_ngcontent-%COMP%]{flex:1 1 auto;min-width:0}.dash-container[_ngcontent-%COMP%]{flex:1 1 auto;min-width:0;height:100%}.drag-handle[_ngcontent-%COMP%]{position:absolute;top:0;bottom:0;width:3px;cursor:col-resize;background:var(--mat-sys-inverse-primary);z-index:5}.drag-handle[_ngcontent-%COMP%] .drag-fab[_ngcontent-%COMP%]{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:28px;height:28px;min-width:28px;cursor:col-resize;pointer-events:auto}.drag-handle[_ngcontent-%COMP%] .drag-fab[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px;line-height:20px}.side-left[_ngcontent-%COMP%] .drag-handle[_ngcontent-%COMP%]{right:-2px}.side-right[_ngcontent-%COMP%] .drag-handle[_ngcontent-%COMP%]{left:-2px}.drag-handle[_ngcontent-%COMP%]:hover{background:var(--mat-sys-error-container)}.side-left[_ngcontent-%COMP%] .collapse-toggle[_ngcontent-%COMP%]{left:.25rem}.side-right[_ngcontent-%COMP%] .collapse-toggle[_ngcontent-%COMP%]{right:.25rem}.fsk-shell.drag-disabled[_ngcontent-%COMP%] .drag-handle[_ngcontent-%COMP%]{cursor:not-allowed;opacity:.4}.resize-ghost[_ngcontent-%COMP%]{position:absolute;top:0;bottom:0;width:2px;background:var(--mat-sys-error-container);opacity:.9;pointer-events:none;z-index:30;will-change:transform;transition:none}.side-left[_ngcontent-%COMP%] .resize-ghost[_ngcontent-%COMP%]{left:0}.side-right[_ngcontent-%COMP%] .resize-ghost[_ngcontent-%COMP%]{right:0}"]})}return i})();export{pt as SplitShellComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {cv as G}from'./main-
|
|
1
|
+
import {cv as G}from'./main-YKDNK5VZ.js';var e={cardCornerRadius:4,stateBarCornerRadius:2.5,titleX:0,titleY:10,titleFontSize:12.5,primaryX:135,primaryY:48,primaryFontSize:34,primaryFontWeight:700,lineOneX:5,lineOneY:30,lineOneFontSize:20,lineTwoX:10,lineTwoY:93,lineTwoFontSize:8,idX:194,idY:26,idFontSize:7.5,metaLeftX:5,metaRightX:194,metaY:63,metaFontSize:8},C=G({},e);export{C,e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {O}from'./chunk-
|
|
1
|
+
import {O}from'./chunk-x7L6DXVK.js';import {w,G as Gi,aS as De$1,cu as T,aY as xe,v as vt,D as Dt,a_ as Gp,F as Fa,cv as G,cw as z,J as JD,cx as ut,cy as He,cz as ht,cA as Te,a2 as Jt,a3 as Xt,a4 as Zt,O as Op,cB as Mt,cC as Dt$1,p as R,y as yt,b as wt,c as $h,P as Pi,X as xw,cs as Sw,u as ul,_ as _w,B as Bh,e as EE,Y as Aw,M as Mw,T as TT,h as Fw,k as Qh,l as ud,g as qw,m as dd,s as sg,aA as gg}from'./main-YKDNK5VZ.js';var te=(n,a)=>a.id;function ie(n,a){if(n&1){let e=Fw();Pi(0,"button",9),Qh("click",function(){let t=ud(e).$implicit,o=qw();return dd(o.displayDashboards(t.displayId))}),TT(1),ul();}if(n&2){let e=a.$implicit,i=qw();sg("selected",i.selectedDisplayButtonId()===e.displayId),EE(),gg(e.displayName);}}function ne(n,a){n&1&&(Pi(0,"button",5)(1,"i"),TT(2,'"No Remote"'),ul()());}function se(n,a){n&1&&(Pi(0,"div",7),$h(1,"mat-progress-spinner",10),ul());}function oe(n,a){if(n&1){let e=Fw();Pi(0,"tile-large-icon",12,0),Qh("click",function(){let t=ud(e).$index,o=qw(2);return dd(o.setActiveScreen(t))}),ul();}if(n&2){let e=a.$implicit,i=a.$index,t=qw(2);Bh("active",t.activeScreenIdx()===i)("svgIcon",e.icon)("iconSize",72)("label",e.name);}}function ae(n,a){if(n&1&&xw(0,oe,2,4,"tile-large-icon",11,te),n&2){let e=qw();Aw(e.screens());}}function re(n,a){n&1&&(Pi(0,"div",8)(1,"mat-icon",13),TT(2,"cast"),ul(),Pi(3,"div",14)(4,"p"),TT(5,"Select an available remote KIP in the menu."),ul(),Pi(6,"p"),TT(7,"To allow remote control of a dashboard, on that KIP device open Options \u2192 Display \u2192 Remote Control and enable it."),ul()()());}var De=(()=>{class n{COMMAND_REQUEST_ACTIVE_SCREEN_PATH="self.kip.remote.requestActiveScreen";_settings=w(Gi);_data=w(De$1);_requests=w(T);_destroyRef=w(xe);pageTitle="Remote Control";appID=this._settings.KipUUID;displayId=vt(null);selectedDisplayButtonId=vt(null);screensLoading=vt(false);displaysMap=vt({});selectedDisplaySub=null;selectedScreenIndexSub=null;displays=Dt(()=>Object.values(this.displaysMap()).filter(i=>i.displayId!==this.appID).sort((i,t)=>{let o=(i.displayName??"").toLowerCase(),s=(t.displayName??"").toLowerCase();return o&&s?o.localeCompare(s):o?-1:s?1:i.displayId.localeCompare(t.displayId)}));screens=vt([]);activeScreenIdx=vt(null);constructor(){this._data.subscribePathTree("self.displays.*").pipe(Gp(this._destroyRef)).subscribe(({path:e,update:i})=>{this.updateDisplayCatalog(e,i.data.value);}),Fa(()=>{let e=this.displays(),i=this.selectedDisplayButtonId();if(!e.length){this.displayDashboards(null);return}(!i||!e.some(t=>t.displayId===i))&&this.displayDashboards(e[0].displayId);}),Fa(()=>{this.rebindSelectedDisplaySubscriptions(this.displayId());});}updateDisplayCatalog(e,i){let t=this.extractDisplayId(e);if(!t||t===this.appID)return;let o=`self.displays.${t}`;this.displaysMap.update(s=>{let r=G({},s);if(e===o&&(i===null||typeof i>"u"))return delete r[t],r;let _=(r[t]??{displayName:null}).displayName;if(e===o&&i&&typeof i=="object"){let x=i;typeof x.displayName=="string"?_=x.displayName:x.displayName===null&&(_=null);}return r[t]={displayId:t,displayName:_},r});}rebindSelectedDisplaySubscriptions(e){if(this.selectedDisplaySub?.unsubscribe(),this.selectedDisplaySub=null,this.selectedScreenIndexSub?.unsubscribe(),this.selectedScreenIndexSub=null,!e){this.screensLoading.set(false),this.screens.set([]),this.activeScreenIdx.set(null);return}this.screensLoading.set(true),this.selectedDisplaySub=this._data.subscribePath(`self.displays.${e}`,"default").pipe(Gp(this._destroyRef)).subscribe(i=>{this.screensLoading.set(false);let t=i.data.value,o=Array.isArray(t?.screens)?t.screens.filter(s=>!!s&&typeof s=="object"&&typeof s.id=="string"&&typeof s.name=="string"&&typeof s.icon=="string"):[];this.screens.set(o),t&&Object.prototype.hasOwnProperty.call(t,"displayName")&&this.displaysMap.update(s=>{let r=s[e];if(!r)return s;let h=typeof t.displayName=="string"?t.displayName:t.displayName===null?null:r.displayName;return h===r.displayName?s:z(G({},s),{[e]:z(G({},r),{displayName:h})})});}),this.selectedScreenIndexSub=this._data.subscribePath(`self.displays.${e}.screenIndex`,"default").pipe(Gp(this._destroyRef)).subscribe(i=>{let t=i.data.value;this.activeScreenIdx.set(typeof t=="number"?t:null);});}extractDisplayId(e){return e.match(/^self\.displays\.([^.]+)(?:\.|$)/)?.[1]??null}displayDashboards(e){this.displayId.set(e),this.selectedDisplayButtonId.set(e);}setActiveScreen(e){let i=this.activeScreenIdx(),t=this.displayId();if(!t)return;this.activeScreenIdx.set(e),this._requests.putRequest(this.COMMAND_REQUEST_ACTIVE_SCREEN_PATH,{displayId:t,screenIdx:e},this.appID)||(console.error("Failed to set active screen: request was not accepted"),this.activeScreenIdx.set(i));}static \u0275fac=function(i){return new(i||n)};static \u0275cmp=JD({type:n,selectors:[["remote-control"]],decls:11,vars:3,consts:[["tile",""],["svgIconId","remote-control",3,"pageTitle"],[1,"sidenav-remote-control-container"],["mode","side","opened",""],["mat-list-item","","tabindex","0",3,"selected"],["mat-list-item","","tabindex","0","disabled","true",2,"text-align","center"],[1,"sidenav-remote-control-content"],["aria-label","Loading screens",1,"loading-container"],["role","status","aria-live","polite",1,"empty-state-msg"],["mat-list-item","","tabindex","0",3,"click"],["mode","indeterminate","diameter","64","strokeWidth","5"],[3,"active","svgIcon","iconSize","label"],[3,"click","active","svgIcon","iconSize","label"],["aria-hidden","true","color","primary",1,"empty-state-icon"],[1,"copy"]],template:function(i,t){i&1&&($h(0,"page-header",1),Pi(1,"mat-sidenav-container",2)(2,"mat-sidenav",3)(3,"mat-action-list"),xw(4,ie,2,3,"button",4,Sw,false,ne,3,0,"button",5),ul()(),Pi(7,"mat-sidenav-content",6),_w(8,se,2,0,"div",7)(9,ae,2,0)(10,re,8,0,"div",8),ul()()),i&2&&(Bh("pageTitle",t.pageTitle),EE(4),Aw(t.displays()),EE(4),Mw(t.screensLoading()?8:t.screens().length?9:10));},dependencies:[O,ut,He,ht,Te,Jt,Xt,Zt,Op,Mt,Dt$1,R,yt,wt],styles:[".sidenav-remote-control-container[_ngcontent-%COMP%]{height:calc(100% - 87px);width:calc(100% - 48px);margin:0 24px 24px;border:1px solid var(--mat-sys-outline-variant)}mat-sidenav[_ngcontent-%COMP%]{width:150px;--mat-sidenav-container-shape: square}.selected[_ngcontent-%COMP%]{background-color:var(--mat-sys-inverse-on-surface)}.loading-container[_ngcontent-%COMP%]{min-height:100%;display:flex;align-items:center;justify-content:center;padding:24px}.sidenav-remote-control-content[_ngcontent-%COMP%]{display:flex;flex-direction:row;flex-wrap:wrap;align-content:flex-start;height:100%;width:100%;padding:5px;gap:5px;overflow-y:auto;scrollbar-width:none;overflow-x:hidden;scroll-behavior:smooth;flex:1 1 auto;min-height:0}tile-large-icon[_ngcontent-%COMP%]{width:190px}.empty-state-msg[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex-wrap:nowrap;align-items:center;justify-content:center;height:100%;width:calc(100% - 150px);min-height:70vh;padding:2rem;text-align:center;color:var(--mat-sys-outline-variant);font-style:italic}.empty-state-icon[_ngcontent-%COMP%]{font-size:4rem;width:4rem;height:4rem;color:var(--mat-sys-outline-variant);margin-bottom:1rem}"]})}return n})();export{De as RemoteControlComponent};
|
|
@@ -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-
|
|
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})();
|
|
2
2
|
export{_e as WidgetZonesStatePanelComponent};
|