@mxtommy/kip 4.8.1 → 4.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +12 -3
  2. package/package.json +1 -1
  3. package/public/{chunk-CNMFlw_H.js → chunk-7lulvsGI.js} +1 -1
  4. package/public/{chunk-CIlfzV9R.js → chunk-8hkXyEzG.js} +1 -1
  5. package/public/{chunk-DWLISAZi.js → chunk-B15lj2T8.js} +1 -1
  6. package/public/{chunk-BQr-tSkv.js → chunk-B6AwCAvV.js} +1 -1
  7. package/public/{chunk-CwSa_BNV.js → chunk-B6XxnPxk.js} +1 -1
  8. package/public/{chunk-DE4ylhpq.js → chunk-B8gfh4xf.js} +1 -1
  9. package/public/{chunk-C2VQxCXa.js → chunk-B8zRhoG8.js} +1 -1
  10. package/public/{chunk-Bp0MQwPM.js → chunk-BIYHVfJl.js} +1 -1
  11. package/public/{chunk-DzTTqoF_.js → chunk-BW4m3O2L.js} +1 -1
  12. package/public/{chunk-Ii9n-oiL.js → chunk-B_PiPxb4.js} +1 -1
  13. package/public/chunk-Bb1mO304.js +1 -0
  14. package/public/{chunk-MjWuPUhu.js → chunk-BdBWqZzL.js} +1 -1
  15. package/public/{chunk-hd2_AKwt.js → chunk-BgyxBAyq.js} +1 -1
  16. package/public/{chunk-JbEkcxJm.js → chunk-Bhah8DNM.js} +1 -1
  17. package/public/{chunk-DDqeRiB0.js → chunk-Bq-eHuZV.js} +1 -1
  18. package/public/{chunk-CpuB_ZZz.js → chunk-BxV0O2fU.js} +1 -1
  19. package/public/{chunk-PheXEqie.js → chunk-Bz9bswDl.js} +1 -1
  20. package/public/{chunk-BOAD0N2a.js → chunk-C3CwUYvD.js} +1 -1
  21. package/public/{chunk-CkXTl3su.js → chunk-C4FGoLDg.js} +1 -1
  22. package/public/{chunk-sNakMDHi.js → chunk-CCiqU2uY.js} +1 -1
  23. package/public/{chunk-00hwknVI.js → chunk-CHKQxw6E.js} +1 -1
  24. package/public/{chunk-B82ADJSs.js → chunk-CJIxuzvd.js} +1 -1
  25. package/public/{chunk-DumLX5k_.js → chunk-COMZv7NY.js} +1 -1
  26. package/public/{chunk-dgaOX1wC.js → chunk-CSpA60X7.js} +1 -1
  27. package/public/{chunk-C6UXF7BI.js → chunk-CU8RPnsi.js} +1 -1
  28. package/public/{chunk-CNNTuNlM.js → chunk-CcvYOops.js} +1 -1
  29. package/public/{chunk-CA6RRaxd.js → chunk-CdSWuWKr.js} +1 -1
  30. package/public/{chunk-DQnoPLyC.js → chunk-CjsnWLUr.js} +1 -1
  31. package/public/{chunk-BX6skw5k.js → chunk-CkfPr-c5.js} +1 -1
  32. package/public/{chunk-nu4vZg-z.js → chunk-CoEM_FqS.js} +1 -1
  33. package/public/{chunk-DNS-qsFC.js → chunk-Cr34s2uQ.js} +1 -1
  34. package/public/{chunk-BJz7Ij9E.js → chunk-Cu9FE8cB.js} +1 -1
  35. package/public/{chunk-B6bEhzNR.js → chunk-CyURmwWh.js} +1 -1
  36. package/public/{chunk-CrBxxZCe.js → chunk-D-xDPCf7.js} +1 -1
  37. package/public/{chunk-5U8d2Ygo.js → chunk-D0MyVrEL.js} +1 -1
  38. package/public/{chunk-DjZgzSiH.js → chunk-DBA0eRqb.js} +1 -1
  39. package/public/{chunk-BKj60jdq.js → chunk-DGOvRnAo.js} +1 -1
  40. package/public/{chunk-CXvG8mMq.js → chunk-DMhuBqKs.js} +1 -1
  41. package/public/{chunk-DchvLV_Y.js → chunk-DMoEBcor.js} +1 -1
  42. package/public/chunk-DSvdWjO4.js +1 -0
  43. package/public/{chunk-D4xZ2tGB.js → chunk-DVB9tiW3.js} +1 -1
  44. package/public/{chunk-Dxlia2NE.js → chunk-D_wrJJxl.js} +1 -1
  45. package/public/{chunk-BwOIef42.js → chunk-DfGLo6Tb.js} +1 -1
  46. package/public/{chunk-BdokyhBM.js → chunk-Di5pPpU7.js} +1 -1
  47. package/public/{chunk-BoNDCNGE.js → chunk-DjavLLpP.js} +1 -1
  48. package/public/{chunk-CL2xiH57.js → chunk-Dv77RFHm.js} +1 -1
  49. package/public/{chunk-AANk-NXH.js → chunk-NnB8OYZt.js} +3 -3
  50. package/public/{chunk-By8ZVvDx.js → chunk-h2q_pbbF.js} +1 -1
  51. package/public/{chunk-tAiV3ARh.js → chunk-o977r5_s.js} +1 -1
  52. package/public/{chunk-DXkKj21H.js → chunk-oPq9Nexl.js} +1 -1
  53. package/public/{chunk-VgxMqRPk.js → chunk-oZiyAw_P.js} +1 -1
  54. package/public/chunk-zg7II0hz.js +1 -0
  55. package/public/index.html +1 -1
  56. package/public/{main-BAV5VDOD.js → main-BNR44HGB.js} +20 -20
  57. package/public/chunk-Blokg6Ds.js +0 -1
  58. package/public/chunk-CpMCBDvH.js +0 -1
  59. package/public/chunk-y1imvaA-.js +0 -1
@@ -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-CyURmwWh.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-BNR44HGB.js';import {c,e}from'./chunk-D_wrJJxl.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 {f}from'./chunk-H9_eqTYx.js';import {d1 as Hj,w,du as p,dv as rt,dD as _,cu as T,a as G,aR as lt,W as Wp,D as Dt,v as vt,cw as z,cv as G$1,F as Fa,dn as ge,J as JD,dC as x,_ as _w,P as Pi,cn as wd,c as $h,u as ul,X as xw,M as Mw,e as EE,an as Hh,Y as Aw,g as qw,B as Bh,h as Fw,k as Qh,l as ud,m as dd,T as TT,d as ig,s as sg,t as pT,cr as mg}from'./main-BAV5VDOD.js';import {c}from'./chunk-Dxlia2NE.js';var Y=(n,i)=>i.raw.value;function K(n,i){if(n&1&&$h(0,"widget-title",0),n&2){let t=qw();Bh("text",t.displayName())("color",t.accentColor());}}function Q(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.fullRoundedItemPathD())("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function X(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.topRoundedItemPathD())("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function ee(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.bottomRoundedItemPathD())("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function te(n,i){if(n&1&&(wd(),$h(0,"rect",18)),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("width",e.menuWidth)("height",e.itemHeight)("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function ie(n,i){if(n&1){let t=Fw();wd(),Pi(0,"g",15),Qh("pointerdown",function(s){ud(t);let o=qw();return dd(o.onPointerDown(s))})("pointermove",function(s){ud(t);let o=qw();return dd(o.onPointerMove(s))})("pointerup",function(s){let o=ud(t).$implicit,l=qw();return dd(l.onPointerUp(s,o))})("pointercancel",function(s){ud(t);let o=qw();return dd(o.onPointerCancel(s))})("keyup.enter",function(){let s=ud(t).$implicit,o=qw();return dd(o.canPut()&&o.selectUi(s))})("keyup.space",function(){let s=ud(t).$implicit,o=qw();return dd(o.canPut()&&o.selectUi(s))}),_w(1,Q,1,4,":svg:path",16)(2,X,1,4,":svg:path",16)(3,ee,1,4,":svg:path",16)(4,te,1,5,":svg:rect",17),Pi(5,"text"),TT(6),ul()();}if(n&2){let t=i.$implicit,e=qw();ig("cursor",e.canPut()?"pointer":"not-allowed"),sg("is-selected",e.isSelected(t.raw))("is-off",t.raw.isOn===false),Hh("transform","translate(0 "+t.index*(e.itemHeight+e.itemGap)+")")("tabindex",e.canPut()?0:-1)("aria-label",t.label)("aria-pressed",e.isSelected(t.raw))("aria-disabled",!e.canPut()),EE(),Mw(t.index===0&&t.index===e.optionsCount()-1?1:t.index===0?2:t.index===e.optionsCount()-1?3:4),EE(4),pT(e.isSelected(t.raw)?"svg-menu-item-current-text":t.raw.isOn===false?"svg-menu-item-off-text":"svg-menu-item-text"),Hh("x",e.menuWidth/2)("y",e.itemHeight/2)("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",(e.isSelected(t.raw)||t.raw.isOn===false,e.textColor())),EE(),mg(" ",e.isSelected(t.raw)?"\u2713 ":"","",t.label," ");}}function ne(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.fullRoundedItemPathD())("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function oe(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.topRoundedItemPathD())("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function re(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.bottomRoundedItemPathD())("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function ae(n,i){if(n&1&&(wd(),$h(0,"rect",18)),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("width",e.menuWidth)("height",e.itemHeight)("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function se(n,i){if(n&1){let t=Fw();wd(),Pi(0,"g",15),Qh("pointerdown",function(s){ud(t);let o=qw();return dd(o.onPointerDown(s))})("pointermove",function(s){ud(t);let o=qw();return dd(o.onPointerMove(s))})("pointerup",function(s){let o=ud(t).$implicit,l=qw();return dd(l.onPointerUp(s,o))})("pointercancel",function(s){ud(t);let o=qw();return dd(o.onPointerCancel(s))})("keyup.enter",function(){let s=ud(t).$implicit,o=qw();return dd(o.canPut()&&o.selectUi(s))})("keyup.space",function(){let s=ud(t).$implicit,o=qw();return dd(o.canPut()&&o.selectUi(s))}),_w(1,ne,1,5,":svg:path",16)(2,oe,1,5,":svg:path",16)(3,re,1,5,":svg:path",16)(4,ae,1,6,":svg:rect",17),Pi(5,"text"),TT(6),ul()();}if(n&2){let t=i.$implicit,e=qw();ig("cursor",e.canPut()?"pointer":"not-allowed"),sg("is-selected",e.isSelected(t.raw))("is-off",t.raw.isOn===false),Hh("transform","translate(0 "+t.index*(e.itemHeight+e.itemGap)+")")("tabindex",e.canPut()?0:-1)("aria-label",t.label)("aria-pressed",e.isSelected(t.raw))("aria-disabled",!e.canPut()),EE(),Mw(t.index===0&&t.index===e.optionsCount()-1?1:t.index===0?2:t.index===e.optionsCount()-1?3:4),EE(4),pT(e.isSelected(t.raw)?"svg-menu-item-current-text":t.raw.isOn===false?"svg-menu-item-off-text":"svg-menu-item-text"),Hh("x",e.menuWidth/2)("y",e.itemHeight/2)("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",(e.isSelected(t.raw)||t.raw.isOn===false,e.textColor())),EE(),mg(" ",e.isSelected(t.raw)?"\u2713 ":"","",t.label," ");}}function le(n,i){n&1&&$h(0,"div",14);}var J=class n{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={displayName:"Switch Label",showLabel:true,filterSelfPaths:true,paths:{controlPath:{description:"Multi-state control path",path:null,source:null,pathType:"multiple",supportsPut:true,isPathConfigurable:true,pathRequired:true,showPathSkUnitsFilter:false,pathSkUnitsFilter:null,showConvertUnitTo:false,convertUnitTo:void 0,sampleTime:500}},enableTimeout:false,dataTimeout:5,color:"contrast"};runtime=w(p);streams=w(rt);meta=w(_);signalkRequestsService=w(T);dashboard=w(G);toast=w(lt);skRequest=Wp(this.signalkRequestsService.subscribeRequest(),{initialValue:null});cfg=Dt(()=>this.runtime.options()??n.DEFAULT_CONFIG);displayName=Dt(()=>this.cfg().displayName??"Switch Label");showLabel=Dt(()=>this.cfg().showLabel??true);controlPath=Dt(()=>this.getControlPath(this.cfg()));accentColor=vt("");accentDim=vt("");accentDimmer=vt("");textColor=vt("");textDim=vt("");textDimmer=vt("");currentValue=vt(null);sortedOptions=Dt(()=>{let i=this.meta.possibleValues();if(!i.length)return [];let t=i.map(e=>({raw:e,label:e.title||e.abbrev||String(e.value),comparable:this.toComparable(e.value)}));return t.sort((e,s)=>{let o=e.comparable,l=s.comparable;return o.kind==="num"&&l.kind==="num"?o.value-l.value:o.kind==="str"&&l.kind==="str"?o.value.localeCompare(l.value):o.kind==="num"?-1:1}),t.map((e,s)=>z(G$1({},e),{index:s}))});menuWidth=220;itemHeight=50;itemGap=1;svgPadding=Math.max(1,Math.round(this.itemHeight*.2));optionsCount=Dt(()=>this.sortedOptions().length);menuHeight=Dt(()=>{let i=this.sortedOptions().length;return i<=0?0:i*this.itemHeight+(i-1)*this.itemGap});hasOptions=Dt(()=>this.meta.possibleValues().length>0);selectedValue=Dt(()=>this.currentValue());canPut=Dt(()=>this.meta.supportsPut());swipeGuard=f();unselectedOptions=Dt(()=>this.sortedOptions().filter(i=>!this.isSelected(i.raw)));selectedOptions=Dt(()=>this.sortedOptions().filter(i=>this.isSelected(i.raw)));fullRoundedItemPathD=Dt(()=>this.buildRoundedRectPath(this.menuWidth,this.itemHeight,this.cornerRadius,true,true));topRoundedItemPathD=Dt(()=>this.buildRoundedRectPath(this.menuWidth,this.itemHeight,this.cornerRadius,true,false));bottomRoundedItemPathD=Dt(()=>this.buildRoundedRectPath(this.menuWidth,this.itemHeight,this.cornerRadius,false,true));cornerRadius=7;constructor(){Fa(()=>{let i=this.theme(),t=this.cfg().color??"contrast";!i||!t||ge(()=>{this.accentColor.set(c(t,i).color),this.accentDim.set(c(t,i).dim),this.accentDimmer.set(c(t,i).dimmer),t==="contrast"?(this.textColor.set(i.background),this.textDim.set(i.contrastDim),this.textDimmer.set(i.contrastDimmer)):(this.textColor.set(i.contrast),this.textDim.set(c(t,i).dim),this.textDimmer.set(c(t,i).dimmer));});}),Fa(()=>{if(!this.controlPath()){this.currentValue.set(null);return}ge(()=>{this.streams.observe("controlPath",t=>{this.currentValue.set(t?.data?.value??null);}),this.meta.observe("controlPath");});});}select(i){let t=this.getControlPath(this.cfg());t&&this.signalkRequestsService.putRequest(t,i.value,this.id());}selectUi(i){this.select(i.raw);}onPointerDown(i){this.canPut()&&this.swipeGuard.onPointerDown(i);}onPointerMove(i){this.canPut()&&this.swipeGuard.onPointerMove(i);}onPointerUp(i,t){this.canPut()&&this.swipeGuard.onPointerUp(i)&&this.selectUi(t);}onPointerCancel(i){this.swipeGuard.onPointerCancel(i);}getControlPath(i){let t=i?.paths;return !t||Array.isArray(t)?null:t.controlPath?.path??null}isSelected(i){let t=this.selectedValue();return typeof i.value=="number"&&typeof t=="string"?i.value===Number(t):typeof i.value=="string"&&typeof t=="number"?Number(i.value)===t||i.value===String(t):Object.is(i.value,t)}toComparable(i){if(typeof i=="number"&&Number.isFinite(i))return {kind:"num",value:i};if(typeof i=="boolean")return {kind:"num",value:i?1:0};if(typeof i=="string"){let t=i.trim();if(/^-?\d+(\.\d+)?$/.test(t)){let e=Number(t);if(Number.isFinite(e))return {kind:"num",value:e}}return {kind:"str",value:t}}return {kind:"str",value:String(i)}}buildRoundedRectPath(i,t,e,s,o){let l=Math.max(0,i),f=Math.max(0,t),r=Math.max(0,Math.min(e,l/2,f/2));return l===0||f===0?"":r===0?`M0 0H${l}V${f}H0Z`:s&&o?[`M${r} 0`,`H${l-r}`,`A${r} ${r} 0 0 1 ${l} ${r}`,`V${f-r}`,`A${r} ${r} 0 0 1 ${l-r} ${f}`,`H${r}`,`A${r} ${r} 0 0 1 0 ${f-r}`,`V${r}`,`A${r} ${r} 0 0 1 ${r} 0`,"Z"].join(""):s?[`M0 ${r}`,`A${r} ${r} 0 0 1 ${r} 0`,`H${l-r}`,`A${r} ${r} 0 0 1 ${l} ${r}`,`V${f}`,"H0","Z"].join(""):o?["M0 0",`H${l}`,`V${f-r}`,`A${r} ${r} 0 0 1 ${l-r} ${f}`,`H${r}`,`A${r} ${r} 0 0 1 0 ${f-r}`,"V0","Z"].join(""):`M0 0H${l}V${f}H0Z`}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=JD({type:n,selectors:[["widget-multi-state-switch"]],inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:23,vars:6,consts:[[3,"text","color"],["role","group",1,"widgets-container"],["preserveAspectRatio","xMidYMid meet","role","presentation",1,"svg-menu"],["id","glow","x","-50%","y","-50%","width","200%","height","200%"],["stdDeviation","5","result","coloredBlur"],["in","coloredBlur"],["in","SourceGraphic"],["id","focus-inner-ring","x","0","y","0","width","100%","height","100%","color-interpolation-filters","sRGB"],["in","SourceAlpha","operator","erode","radius","2","result","eroded"],["in","SourceAlpha","in2","eroded","operator","out","result","border"],["flood-color","#ffffff","flood-opacity","0.9","result","ringColor"],["in","ringColor","in2","border","operator","in","result","ring"],["in","ring"],["role","button",1,"svg-menu-item-group",3,"is-selected","is-off","cursor"],[1,"widgetOverlay"],["role","button",1,"svg-menu-item-group",3,"pointerdown","pointermove","pointerup","pointercancel","keyup.enter","keyup.space"],[3,"class"],["x","0","y","0",3,"class"],["x","0","y","0"]],template:function(t,e){t&1&&(_w(0,K,1,2,"widget-title",0),Pi(1,"div",1),wd(),Pi(2,"svg",2)(3,"defs")(4,"filter",3),$h(5,"feGaussianBlur",4),Pi(6,"feMerge"),$h(7,"feMergeNode",5)(8,"feMergeNode",6),ul()(),Pi(9,"filter",7),$h(10,"feMorphology",8)(11,"feComposite",9)(12,"feFlood",10)(13,"feComposite",11),Pi(14,"feMerge"),$h(15,"feMergeNode",6)(16,"feMergeNode",12),ul()()(),Pi(17,"g"),xw(18,ie,7,20,":svg:g",13,Y),xw(20,se,7,20,":svg:g",13,Y),ul()()(),_w(22,le,1,0,"div",14)),t&2&&(Mw(e.showLabel()?0:-1),EE(),Hh("aria-label",e.displayName()),EE(),Hh("viewBox","0 0 "+(e.menuWidth+e.svgPadding*2)+" "+((e.menuHeight()||e.itemHeight)+e.svgPadding*2))("aria-label",e.displayName()),EE(15),Hh("transform","translate("+e.svgPadding+" "+e.svgPadding+")"),EE(),Aw(e.unselectedOptions()),EE(2),Aw(e.selectedOptions()),EE(2),Mw(e.dashboard.isDashboardStatic()?-1:22));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent;z-index:21}.widgets-container[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;padding:2px}.svg-menu[_ngcontent-%COMP%]{width:100%;height:100%;display:block;background:transparent;border-radius:12px;z-index:20;font-family:Roboto;font-size:1.3rem;font-weight:700;text-anchor:middle;text-align:center;alignment-baseline:middle}.svg-menu-item-current[_ngcontent-%COMP%]{stroke:var(--mat-sys-on-background);stroke-width:3px;stroke-dasharray:none;stroke-opacity:1}.svg-menu-item[_ngcontent-%COMP%]{fill:var(--mat-sys-outline);stroke:#000;stroke-width:2px;stroke-dasharray:none;stroke-opacity:.2}.svg-menu-item-off[_ngcontent-%COMP%]{stroke:#000;stroke-width:2;stroke-dasharray:none;stroke-opacity:.2}.svg-menu-item-current-text[_ngcontent-%COMP%]{font-size:1.5rem;font-weight:700;text-anchor:middle;dominant-baseline:middle;alignment-baseline:middle}.svg-menu-item-text[_ngcontent-%COMP%], .svg-menu-item-off-text[_ngcontent-%COMP%]{font-weight:600;text-anchor:middle;dominant-baseline:middle;alignment-baseline:middle}.svg-menu-item-group[_ngcontent-%COMP%]:focus{outline:none}.svg-menu-item-group[_ngcontent-%COMP%]:focus-visible :is(rect[_ngcontent-%COMP%], path[_ngcontent-%COMP%]){filter:url(#focus-inner-ring)}"]})};export{J as WidgetMultiStateSwitchComponent};
1
+ import {f}from'./chunk-H9_eqTYx.js';import {d1 as Hj,w,du as p,dv as rt,dD as _,cu as T,a as G,aR as lt,W as Wp,D as Dt,v as vt,cw as z,cv as G$1,F as Fa,dn as ge,J as JD,dC as x,_ as _w,P as Pi,cn as wd,c as $h,u as ul,X as xw,M as Mw,e as EE,an as Hh,Y as Aw,g as qw,B as Bh,h as Fw,k as Qh,l as ud,m as dd,T as TT,d as ig,s as sg,t as pT,cr as mg}from'./main-BNR44HGB.js';import {c}from'./chunk-D_wrJJxl.js';var Y=(n,i)=>i.raw.value;function K(n,i){if(n&1&&$h(0,"widget-title",0),n&2){let t=qw();Bh("text",t.displayName())("color",t.accentColor());}}function Q(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.fullRoundedItemPathD())("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function X(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.topRoundedItemPathD())("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function ee(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.bottomRoundedItemPathD())("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function te(n,i){if(n&1&&(wd(),$h(0,"rect",18)),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("width",e.menuWidth)("height",e.itemHeight)("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function ie(n,i){if(n&1){let t=Fw();wd(),Pi(0,"g",15),Qh("pointerdown",function(s){ud(t);let o=qw();return dd(o.onPointerDown(s))})("pointermove",function(s){ud(t);let o=qw();return dd(o.onPointerMove(s))})("pointerup",function(s){let o=ud(t).$implicit,l=qw();return dd(l.onPointerUp(s,o))})("pointercancel",function(s){ud(t);let o=qw();return dd(o.onPointerCancel(s))})("keyup.enter",function(){let s=ud(t).$implicit,o=qw();return dd(o.canPut()&&o.selectUi(s))})("keyup.space",function(){let s=ud(t).$implicit,o=qw();return dd(o.canPut()&&o.selectUi(s))}),_w(1,Q,1,4,":svg:path",16)(2,X,1,4,":svg:path",16)(3,ee,1,4,":svg:path",16)(4,te,1,5,":svg:rect",17),Pi(5,"text"),TT(6),ul()();}if(n&2){let t=i.$implicit,e=qw();ig("cursor",e.canPut()?"pointer":"not-allowed"),sg("is-selected",e.isSelected(t.raw))("is-off",t.raw.isOn===false),Hh("transform","translate(0 "+t.index*(e.itemHeight+e.itemGap)+")")("tabindex",e.canPut()?0:-1)("aria-label",t.label)("aria-pressed",e.isSelected(t.raw))("aria-disabled",!e.canPut()),EE(),Mw(t.index===0&&t.index===e.optionsCount()-1?1:t.index===0?2:t.index===e.optionsCount()-1?3:4),EE(4),pT(e.isSelected(t.raw)?"svg-menu-item-current-text":t.raw.isOn===false?"svg-menu-item-off-text":"svg-menu-item-text"),Hh("x",e.menuWidth/2)("y",e.itemHeight/2)("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",(e.isSelected(t.raw)||t.raw.isOn===false,e.textColor())),EE(),mg(" ",e.isSelected(t.raw)?"\u2713 ":"","",t.label," ");}}function ne(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.fullRoundedItemPathD())("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function oe(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.topRoundedItemPathD())("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function re(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.bottomRoundedItemPathD())("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function ae(n,i){if(n&1&&(wd(),$h(0,"rect",18)),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("width",e.menuWidth)("height",e.itemHeight)("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function se(n,i){if(n&1){let t=Fw();wd(),Pi(0,"g",15),Qh("pointerdown",function(s){ud(t);let o=qw();return dd(o.onPointerDown(s))})("pointermove",function(s){ud(t);let o=qw();return dd(o.onPointerMove(s))})("pointerup",function(s){let o=ud(t).$implicit,l=qw();return dd(l.onPointerUp(s,o))})("pointercancel",function(s){ud(t);let o=qw();return dd(o.onPointerCancel(s))})("keyup.enter",function(){let s=ud(t).$implicit,o=qw();return dd(o.canPut()&&o.selectUi(s))})("keyup.space",function(){let s=ud(t).$implicit,o=qw();return dd(o.canPut()&&o.selectUi(s))}),_w(1,ne,1,5,":svg:path",16)(2,oe,1,5,":svg:path",16)(3,re,1,5,":svg:path",16)(4,ae,1,6,":svg:rect",17),Pi(5,"text"),TT(6),ul()();}if(n&2){let t=i.$implicit,e=qw();ig("cursor",e.canPut()?"pointer":"not-allowed"),sg("is-selected",e.isSelected(t.raw))("is-off",t.raw.isOn===false),Hh("transform","translate(0 "+t.index*(e.itemHeight+e.itemGap)+")")("tabindex",e.canPut()?0:-1)("aria-label",t.label)("aria-pressed",e.isSelected(t.raw))("aria-disabled",!e.canPut()),EE(),Mw(t.index===0&&t.index===e.optionsCount()-1?1:t.index===0?2:t.index===e.optionsCount()-1?3:4),EE(4),pT(e.isSelected(t.raw)?"svg-menu-item-current-text":t.raw.isOn===false?"svg-menu-item-off-text":"svg-menu-item-text"),Hh("x",e.menuWidth/2)("y",e.itemHeight/2)("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",(e.isSelected(t.raw)||t.raw.isOn===false,e.textColor())),EE(),mg(" ",e.isSelected(t.raw)?"\u2713 ":"","",t.label," ");}}function le(n,i){n&1&&$h(0,"div",14);}var J=class n{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={displayName:"Switch Label",showLabel:true,filterSelfPaths:true,paths:{controlPath:{description:"Multi-state control path",path:null,source:null,pathType:"multiple",supportsPut:true,isPathConfigurable:true,pathRequired:true,showPathSkUnitsFilter:false,pathSkUnitsFilter:null,showConvertUnitTo:false,convertUnitTo:void 0,sampleTime:500}},enableTimeout:false,dataTimeout:5,color:"contrast"};runtime=w(p);streams=w(rt);meta=w(_);signalkRequestsService=w(T);dashboard=w(G);toast=w(lt);skRequest=Wp(this.signalkRequestsService.subscribeRequest(),{initialValue:null});cfg=Dt(()=>this.runtime.options()??n.DEFAULT_CONFIG);displayName=Dt(()=>this.cfg().displayName??"Switch Label");showLabel=Dt(()=>this.cfg().showLabel??true);controlPath=Dt(()=>this.getControlPath(this.cfg()));accentColor=vt("");accentDim=vt("");accentDimmer=vt("");textColor=vt("");textDim=vt("");textDimmer=vt("");currentValue=vt(null);sortedOptions=Dt(()=>{let i=this.meta.possibleValues();if(!i.length)return [];let t=i.map(e=>({raw:e,label:e.title||e.abbrev||String(e.value),comparable:this.toComparable(e.value)}));return t.sort((e,s)=>{let o=e.comparable,l=s.comparable;return o.kind==="num"&&l.kind==="num"?o.value-l.value:o.kind==="str"&&l.kind==="str"?o.value.localeCompare(l.value):o.kind==="num"?-1:1}),t.map((e,s)=>z(G$1({},e),{index:s}))});menuWidth=220;itemHeight=50;itemGap=1;svgPadding=Math.max(1,Math.round(this.itemHeight*.2));optionsCount=Dt(()=>this.sortedOptions().length);menuHeight=Dt(()=>{let i=this.sortedOptions().length;return i<=0?0:i*this.itemHeight+(i-1)*this.itemGap});hasOptions=Dt(()=>this.meta.possibleValues().length>0);selectedValue=Dt(()=>this.currentValue());canPut=Dt(()=>this.meta.supportsPut());swipeGuard=f();unselectedOptions=Dt(()=>this.sortedOptions().filter(i=>!this.isSelected(i.raw)));selectedOptions=Dt(()=>this.sortedOptions().filter(i=>this.isSelected(i.raw)));fullRoundedItemPathD=Dt(()=>this.buildRoundedRectPath(this.menuWidth,this.itemHeight,this.cornerRadius,true,true));topRoundedItemPathD=Dt(()=>this.buildRoundedRectPath(this.menuWidth,this.itemHeight,this.cornerRadius,true,false));bottomRoundedItemPathD=Dt(()=>this.buildRoundedRectPath(this.menuWidth,this.itemHeight,this.cornerRadius,false,true));cornerRadius=7;constructor(){Fa(()=>{let i=this.theme(),t=this.cfg().color??"contrast";!i||!t||ge(()=>{this.accentColor.set(c(t,i).color),this.accentDim.set(c(t,i).dim),this.accentDimmer.set(c(t,i).dimmer),t==="contrast"?(this.textColor.set(i.background),this.textDim.set(i.contrastDim),this.textDimmer.set(i.contrastDimmer)):(this.textColor.set(i.contrast),this.textDim.set(c(t,i).dim),this.textDimmer.set(c(t,i).dimmer));});}),Fa(()=>{if(!this.controlPath()){this.currentValue.set(null);return}ge(()=>{this.streams.observe("controlPath",t=>{this.currentValue.set(t?.data?.value??null);}),this.meta.observe("controlPath");});});}select(i){let t=this.getControlPath(this.cfg());t&&this.signalkRequestsService.putRequest(t,i.value,this.id());}selectUi(i){this.select(i.raw);}onPointerDown(i){this.canPut()&&this.swipeGuard.onPointerDown(i);}onPointerMove(i){this.canPut()&&this.swipeGuard.onPointerMove(i);}onPointerUp(i,t){this.canPut()&&this.swipeGuard.onPointerUp(i)&&this.selectUi(t);}onPointerCancel(i){this.swipeGuard.onPointerCancel(i);}getControlPath(i){let t=i?.paths;return !t||Array.isArray(t)?null:t.controlPath?.path??null}isSelected(i){let t=this.selectedValue();return typeof i.value=="number"&&typeof t=="string"?i.value===Number(t):typeof i.value=="string"&&typeof t=="number"?Number(i.value)===t||i.value===String(t):Object.is(i.value,t)}toComparable(i){if(typeof i=="number"&&Number.isFinite(i))return {kind:"num",value:i};if(typeof i=="boolean")return {kind:"num",value:i?1:0};if(typeof i=="string"){let t=i.trim();if(/^-?\d+(\.\d+)?$/.test(t)){let e=Number(t);if(Number.isFinite(e))return {kind:"num",value:e}}return {kind:"str",value:t}}return {kind:"str",value:String(i)}}buildRoundedRectPath(i,t,e,s,o){let l=Math.max(0,i),f=Math.max(0,t),r=Math.max(0,Math.min(e,l/2,f/2));return l===0||f===0?"":r===0?`M0 0H${l}V${f}H0Z`:s&&o?[`M${r} 0`,`H${l-r}`,`A${r} ${r} 0 0 1 ${l} ${r}`,`V${f-r}`,`A${r} ${r} 0 0 1 ${l-r} ${f}`,`H${r}`,`A${r} ${r} 0 0 1 0 ${f-r}`,`V${r}`,`A${r} ${r} 0 0 1 ${r} 0`,"Z"].join(""):s?[`M0 ${r}`,`A${r} ${r} 0 0 1 ${r} 0`,`H${l-r}`,`A${r} ${r} 0 0 1 ${l} ${r}`,`V${f}`,"H0","Z"].join(""):o?["M0 0",`H${l}`,`V${f-r}`,`A${r} ${r} 0 0 1 ${l-r} ${f}`,`H${r}`,`A${r} ${r} 0 0 1 0 ${f-r}`,"V0","Z"].join(""):`M0 0H${l}V${f}H0Z`}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=JD({type:n,selectors:[["widget-multi-state-switch"]],inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:23,vars:6,consts:[[3,"text","color"],["role","group",1,"widgets-container"],["preserveAspectRatio","xMidYMid meet","role","presentation",1,"svg-menu"],["id","glow","x","-50%","y","-50%","width","200%","height","200%"],["stdDeviation","5","result","coloredBlur"],["in","coloredBlur"],["in","SourceGraphic"],["id","focus-inner-ring","x","0","y","0","width","100%","height","100%","color-interpolation-filters","sRGB"],["in","SourceAlpha","operator","erode","radius","2","result","eroded"],["in","SourceAlpha","in2","eroded","operator","out","result","border"],["flood-color","#ffffff","flood-opacity","0.9","result","ringColor"],["in","ringColor","in2","border","operator","in","result","ring"],["in","ring"],["role","button",1,"svg-menu-item-group",3,"is-selected","is-off","cursor"],[1,"widgetOverlay"],["role","button",1,"svg-menu-item-group",3,"pointerdown","pointermove","pointerup","pointercancel","keyup.enter","keyup.space"],[3,"class"],["x","0","y","0",3,"class"],["x","0","y","0"]],template:function(t,e){t&1&&(_w(0,K,1,2,"widget-title",0),Pi(1,"div",1),wd(),Pi(2,"svg",2)(3,"defs")(4,"filter",3),$h(5,"feGaussianBlur",4),Pi(6,"feMerge"),$h(7,"feMergeNode",5)(8,"feMergeNode",6),ul()(),Pi(9,"filter",7),$h(10,"feMorphology",8)(11,"feComposite",9)(12,"feFlood",10)(13,"feComposite",11),Pi(14,"feMerge"),$h(15,"feMergeNode",6)(16,"feMergeNode",12),ul()()(),Pi(17,"g"),xw(18,ie,7,20,":svg:g",13,Y),xw(20,se,7,20,":svg:g",13,Y),ul()()(),_w(22,le,1,0,"div",14)),t&2&&(Mw(e.showLabel()?0:-1),EE(),Hh("aria-label",e.displayName()),EE(),Hh("viewBox","0 0 "+(e.menuWidth+e.svgPadding*2)+" "+((e.menuHeight()||e.itemHeight)+e.svgPadding*2))("aria-label",e.displayName()),EE(15),Hh("transform","translate("+e.svgPadding+" "+e.svgPadding+")"),EE(),Aw(e.unselectedOptions()),EE(2),Aw(e.selectedOptions()),EE(2),Mw(e.dashboard.isDashboardStatic()?-1:22));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent;z-index:21}.widgets-container[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;padding:2px}.svg-menu[_ngcontent-%COMP%]{width:100%;height:100%;display:block;background:transparent;border-radius:12px;z-index:20;font-family:Roboto;font-size:1.3rem;font-weight:700;text-anchor:middle;text-align:center;alignment-baseline:middle}.svg-menu-item-current[_ngcontent-%COMP%]{stroke:var(--mat-sys-on-background);stroke-width:3px;stroke-dasharray:none;stroke-opacity:1}.svg-menu-item[_ngcontent-%COMP%]{fill:var(--mat-sys-outline);stroke:#000;stroke-width:2px;stroke-dasharray:none;stroke-opacity:.2}.svg-menu-item-off[_ngcontent-%COMP%]{stroke:#000;stroke-width:2;stroke-dasharray:none;stroke-opacity:.2}.svg-menu-item-current-text[_ngcontent-%COMP%]{font-size:1.5rem;font-weight:700;text-anchor:middle;dominant-baseline:middle;alignment-baseline:middle}.svg-menu-item-text[_ngcontent-%COMP%], .svg-menu-item-off-text[_ngcontent-%COMP%]{font-weight:600;text-anchor:middle;dominant-baseline:middle;alignment-baseline:middle}.svg-menu-item-group[_ngcontent-%COMP%]:focus{outline:none}.svg-menu-item-group[_ngcontent-%COMP%]:focus-visible :is(rect[_ngcontent-%COMP%], path[_ngcontent-%COMP%]){filter:url(#focus-inner-ring)}"]})};export{J as WidgetMultiStateSwitchComponent};
@@ -1 +1 @@
1
- import {d1 as Hj,w,du as p$1,aZ as F,$ as $j,v as vt,F as Fa,dn as ge,J as JD,cp as Uh,f as eg,K as Kw}from'./main-BAV5VDOD.js';var p=["canvasMainRef"],M=(()=>{class s{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p$1);canvas=w(F);static DEFAULT_CONFIG={displayName:"Static Label",color:"green",bgColor:"grey",noColor:false,noBgColor:true};canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;maxTextWidth=0;maxTextHeight=0;disposed=false;fgColor=vt("");bgColor=vt("");constructor(){Fa(()=>{let t=this.runtime.options(),e=this.theme();!t||!e||ge(()=>{this.fgColor.set(this.mapColor(t.color??"contrast",e)),this.bgColor.set(this.mapColor(t.bgColor??"grey",e)),this.draw();});}),Fa(()=>{let t=this.runtime.options()?.displayName;ge(()=>{t!==void 0&&this.draw();});});}mapColor(t,e){switch(t){case "contrast":return e.contrast;case "blue":return e.blue;case "green":return e.green;case "pink":return e.pink;case "orange":return e.orange;case "purple":return e.purple;case "grey":return e.grey;case "yellow":return e.yellow;default:return e.contrast}}ngAfterViewInit(){this.canvasElement=this.canvasRef().nativeElement,this.ctx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(t,e)=>{this.cssWidth=t,this.cssHeight=e,this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.draw();}draw(){if(!this.ctx||!this.canvasElement)return;let t=this.runtime.options();if(!t)return;this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),t.noBgColor||this.canvas.drawRectangle(this.ctx,0,0,this.canvasElement.width,this.canvasElement.height,this.bgColor());let e=t.displayName||"";this.canvas.drawText(this.ctx,e,Math.floor(this.cssWidth/2),Math.floor(this.cssHeight/2+10),this.cssWidth-40,this.cssHeight-40,"bold",this.fgColor());}ngOnDestroy(){this.disposed=true;try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(t){}}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=JD({type:s,selectors:[["widget-label"]],viewQuery:function(e,c){e&1&&eg(c.canvasRef,p,5),e&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:0,consts:[["canvasMainRef",""],[1,"label-canvas"]],template:function(e,c){e&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%;overflow:hidden}.label-canvas[_ngcontent-%COMP%]{width:100%!important;height:100%!important;display:block;border-radius:var(--mat-card-elevated-container-shape, var(--mat-sys-corner-medium))}"]})}return s})();export{M as WidgetLabelComponent};
1
+ import {d1 as Hj,w,du as p$1,aZ as R,$ as $j,v as vt,F as Fa,dn as ge,J as JD,cp as Uh,f as eg,K as Kw}from'./main-BNR44HGB.js';var p=["canvasMainRef"],M=(()=>{class s{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p$1);canvas=w(R);static DEFAULT_CONFIG={displayName:"Static Label",color:"green",bgColor:"grey",noColor:false,noBgColor:true};canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;maxTextWidth=0;maxTextHeight=0;disposed=false;fgColor=vt("");bgColor=vt("");constructor(){Fa(()=>{let t=this.runtime.options(),e=this.theme();!t||!e||ge(()=>{this.fgColor.set(this.mapColor(t.color??"contrast",e)),this.bgColor.set(this.mapColor(t.bgColor??"grey",e)),this.draw();});}),Fa(()=>{let t=this.runtime.options()?.displayName;ge(()=>{t!==void 0&&this.draw();});});}mapColor(t,e){switch(t){case "contrast":return e.contrast;case "blue":return e.blue;case "green":return e.green;case "pink":return e.pink;case "orange":return e.orange;case "purple":return e.purple;case "grey":return e.grey;case "yellow":return e.yellow;default:return e.contrast}}ngAfterViewInit(){this.canvasElement=this.canvasRef().nativeElement,this.ctx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(t,e)=>{this.cssWidth=t,this.cssHeight=e,this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.draw();}draw(){if(!this.ctx||!this.canvasElement)return;let t=this.runtime.options();if(!t)return;this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),t.noBgColor||this.canvas.drawRectangle(this.ctx,0,0,this.canvasElement.width,this.canvasElement.height,this.bgColor());let e=t.displayName||"";this.canvas.drawText(this.ctx,e,Math.floor(this.cssWidth/2),Math.floor(this.cssHeight/2+10),this.cssWidth-40,this.cssHeight-40,"bold",this.fgColor());}ngOnDestroy(){this.disposed=true;try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(t){}}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=JD({type:s,selectors:[["widget-label"]],viewQuery:function(e,c){e&1&&eg(c.canvasRef,p,5),e&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:0,consts:[["canvasMainRef",""],[1,"label-canvas"]],template:function(e,c){e&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%;overflow:hidden}.label-canvas[_ngcontent-%COMP%]{width:100%!important;height:100%!important;display:block;border-radius:var(--mat-card-elevated-container-shape, var(--mat-sys-corner-medium))}"]})}return s})();export{M as WidgetLabelComponent};
@@ -1 +1 @@
1
- import {a as a$1}from'./chunk-D4xZ2tGB.js';import {d1 as Hj,w,du as p,a as G,H as Dr,$ as $j,v as vt,F as Fa,dn as ge,J as JD,_ as _w,cp as Uh,M as Mw,e as EE,d as ig,f as eg,K as Kw,g as qw,b_ as Gh,ci as dl,T as TT,cj as fl,dP as pp}from'./main-BAV5VDOD.js';var W=["plainIframe"];function M(n,e){if(n&1&&Uh(0,"iframe",1,0),n&2){let t=qw();Gh("src",t.widgetUrl(),pp);}}function N(n,e){n&1&&(dl(0,"div",2)(1,"h2"),TT(2,"Empty or bad URL"),fl(),dl(3,"p"),TT(4," IMPORTANT: cross-domain security rules (CORS) apply to this widget. "),fl(),dl(5,"p"),TT(6,"Typically, you can load Grafana graphs, Signal K apps or other related tools. "),fl()());}var O=class n{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);_dashboard=w(G);_sanitizer=w(Dr);static DEFAULT_CONFIG={widgetUrl:void 0,allowInput:false};iframe=$j.required("plainIframe");widgetUrl=vt(null);displayTransparentOverlay=vt("block");constructor(){Fa(()=>{let e=this.runtime.options(),t=this._dashboard.isDashboardStatic();e&&ge(()=>{t?this.displayTransparentOverlay.set(e.allowInput?"none":"block"):this.displayTransparentOverlay.set("block");});}),Fa(()=>{let e=this.runtime.options()?.widgetUrl;this.widgetUrl.set(this.resolveUrl(e));}),window.addEventListener("message",this.handleIframeGesture);}ngAfterViewInit(){if(this.iframe()){this.iframe().nativeElement.onload=()=>this.injectSwipeScript();try{let e=this.iframe().nativeElement.contentDocument;e&&(e.readyState==="complete"||e.readyState==="interactive")&&this.injectSwipeScript();}catch(e){}}}ngOnDestroy(){window.removeEventListener("message",this.handleIframeGesture),this.iframe()&&(this.iframe().nativeElement.onload=null);try{let e=this.iframe()?.nativeElement.contentDocument;if(e){let t=`kip-gesture-inject-${this.id()}`,i=e.getElementById(t);i&&i.parentNode&&i.parentNode.removeChild(i);}}catch(e){}}handleIframeGesture=e=>{if(!e.data)return;let t=e.data?.eventData?.instanceId||e.data?.keyEventData?.instanceId;if(!(!t||t!==this.id())){if(e.data.gesture)switch(e.data.gesture){case "swipeup":this._dashboard.navigateToPreviousDashboard();break;case "swipedown":this._dashboard.navigateToNextDashboard();break;case "swipeleft":{let i=new Event("openLeftSidenav",{bubbles:true,cancelable:true});window.document.dispatchEvent(i);break}case "swiperight":{let i=new Event("openRightSidenav",{bubbles:true,cancelable:true});window.document.dispatchEvent(i);break}}if(e.data.type==="keydown"&&e.data.keyEventData){let{key:i,ctrlKey:l,shiftKey:r}=e.data.keyEventData,x=new KeyboardEvent("keydown",{key:i,ctrlKey:l,shiftKey:r,bubbles:true,cancelable:true});document.dispatchEvent(x);}}};injectSwipeScript(){let e=this.iframe().nativeElement.contentWindow,t=this.iframe().nativeElement.contentDocument;if(!t||!e){console.error("[WidgetIframe] Iframe contentDocument or contentWindow is undefined. Possible cross-origin issue or iframe not fully loaded.");return}try{let i=`kip-gesture-inject-${this.id()}`;if(t.getElementById(i))return;let l=a$1({instanceId:this.id()}),r=t.createElement("script");r.id=i,r.textContent=l,t.body.appendChild(r);}catch(i){console.warn("[WidgetIframe] Failed to inject swipe script into iframe:",i);}}isValidProtocol(e){try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch(t){return console.warn(`[Embed Widget] Invalid Url: ${e}, Error: ${t}`),false}}resolveUrl(e){if(!e)return null;try{let t=new URL(e,window.location.origin);return this.isValidProtocol(t.href)?this._sanitizer.bypassSecurityTrustResourceUrl(t.href):null}catch(t){return console.warn(`[Embed Widget] Can't resolve Url: ${e}, Error: ${t}`),null}}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=JD({type:n,selectors:[["widget-iframe"]],viewQuery:function(t,i){t&1&&eg(i.iframe,W,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:3,vars:3,consts:[["plainIframe",""],["width","100%","height","100%","frameborder","0",1,"widgetIframe",3,"src"],[2,"padding","15px"],[1,"widgetOverlay"]],template:function(t,i){t&1&&(_w(0,M,2,1,"iframe",1)(1,N,7,0,"div",2),Uh(2,"div",3)),t&2&&(Mw(i.widgetUrl()?0:1),EE(2),ig("display",i.displayTransparentOverlay()));},styles:["[_nghost-%COMP%]{overflow:hidden}.widgetIframe[_ngcontent-%COMP%]{background-color:#fff;border-radius:var(--mat-card-elevated-container-shape, var(--mat-sys-corner-medium))}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent}"]})};export{O as WidgetIframeComponent};
1
+ import {a as a$1}from'./chunk-DVB9tiW3.js';import {d1 as Hj,w,du as p,a as G,H as Dr,$ as $j,v as vt,F as Fa,dn as ge,J as JD,_ as _w,cp as Uh,M as Mw,e as EE,d as ig,f as eg,K as Kw,g as qw,b_ as Gh,ci as dl,T as TT,cj as fl,dP as pp}from'./main-BNR44HGB.js';var W=["plainIframe"];function M(n,e){if(n&1&&Uh(0,"iframe",1,0),n&2){let t=qw();Gh("src",t.widgetUrl(),pp);}}function N(n,e){n&1&&(dl(0,"div",2)(1,"h2"),TT(2,"Empty or bad URL"),fl(),dl(3,"p"),TT(4," IMPORTANT: cross-domain security rules (CORS) apply to this widget. "),fl(),dl(5,"p"),TT(6,"Typically, you can load Grafana graphs, Signal K apps or other related tools. "),fl()());}var O=class n{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);_dashboard=w(G);_sanitizer=w(Dr);static DEFAULT_CONFIG={widgetUrl:void 0,allowInput:false};iframe=$j.required("plainIframe");widgetUrl=vt(null);displayTransparentOverlay=vt("block");constructor(){Fa(()=>{let e=this.runtime.options(),t=this._dashboard.isDashboardStatic();e&&ge(()=>{t?this.displayTransparentOverlay.set(e.allowInput?"none":"block"):this.displayTransparentOverlay.set("block");});}),Fa(()=>{let e=this.runtime.options()?.widgetUrl;this.widgetUrl.set(this.resolveUrl(e));}),window.addEventListener("message",this.handleIframeGesture);}ngAfterViewInit(){if(this.iframe()){this.iframe().nativeElement.onload=()=>this.injectSwipeScript();try{let e=this.iframe().nativeElement.contentDocument;e&&(e.readyState==="complete"||e.readyState==="interactive")&&this.injectSwipeScript();}catch(e){}}}ngOnDestroy(){window.removeEventListener("message",this.handleIframeGesture),this.iframe()&&(this.iframe().nativeElement.onload=null);try{let e=this.iframe()?.nativeElement.contentDocument;if(e){let t=`kip-gesture-inject-${this.id()}`,i=e.getElementById(t);i&&i.parentNode&&i.parentNode.removeChild(i);}}catch(e){}}handleIframeGesture=e=>{if(!e.data)return;let t=e.data?.eventData?.instanceId||e.data?.keyEventData?.instanceId;if(!(!t||t!==this.id())){if(e.data.gesture)switch(e.data.gesture){case "swipeup":this._dashboard.navigateToPreviousDashboard();break;case "swipedown":this._dashboard.navigateToNextDashboard();break;case "swipeleft":{let i=new Event("openLeftSidenav",{bubbles:true,cancelable:true});window.document.dispatchEvent(i);break}case "swiperight":{let i=new Event("openRightSidenav",{bubbles:true,cancelable:true});window.document.dispatchEvent(i);break}}if(e.data.type==="keydown"&&e.data.keyEventData){let{key:i,ctrlKey:l,shiftKey:r}=e.data.keyEventData,x=new KeyboardEvent("keydown",{key:i,ctrlKey:l,shiftKey:r,bubbles:true,cancelable:true});document.dispatchEvent(x);}}};injectSwipeScript(){let e=this.iframe().nativeElement.contentWindow,t=this.iframe().nativeElement.contentDocument;if(!t||!e){console.error("[WidgetIframe] Iframe contentDocument or contentWindow is undefined. Possible cross-origin issue or iframe not fully loaded.");return}try{let i=`kip-gesture-inject-${this.id()}`;if(t.getElementById(i))return;let l=a$1({instanceId:this.id()}),r=t.createElement("script");r.id=i,r.textContent=l,t.body.appendChild(r);}catch(i){console.warn("[WidgetIframe] Failed to inject swipe script into iframe:",i);}}isValidProtocol(e){try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch(t){return console.warn(`[Embed Widget] Invalid Url: ${e}, Error: ${t}`),false}}resolveUrl(e){if(!e)return null;try{let t=new URL(e,window.location.origin);return this.isValidProtocol(t.href)?this._sanitizer.bypassSecurityTrustResourceUrl(t.href):null}catch(t){return console.warn(`[Embed Widget] Can't resolve Url: ${e}, Error: ${t}`),null}}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=JD({type:n,selectors:[["widget-iframe"]],viewQuery:function(t,i){t&1&&eg(i.iframe,W,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:3,vars:3,consts:[["plainIframe",""],["width","100%","height","100%","frameborder","0",1,"widgetIframe",3,"src"],[2,"padding","15px"],[1,"widgetOverlay"]],template:function(t,i){t&1&&(_w(0,M,2,1,"iframe",1)(1,N,7,0,"div",2),Uh(2,"div",3)),t&2&&(Mw(i.widgetUrl()?0:1),EE(2),ig("display",i.displayTransparentOverlay()));},styles:["[_nghost-%COMP%]{overflow:hidden}.widgetIframe[_ngcontent-%COMP%]{background-color:#fff;border-radius:var(--mat-card-elevated-container-shape, var(--mat-sys-corner-medium))}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent}"]})};export{O as WidgetIframeComponent};
@@ -1 +1 @@
1
- import {a as a$1}from'./chunk-D4xZ2tGB.js';import {d1 as Hj,w,du as p,a as G,H as Dr,G as Gi,$ as $j,v as vt,F as Fa,dn as ge,J as JD,cp as Uh,b_ as Gh,e as EE,d as ig,f as eg,K as Kw,dP as pp}from'./main-BAV5VDOD.js';var C=["plainIframe"],j=(()=>{class a{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);_dashboard=w(G);_sanitizer=w(Dr);settings=w(Gi);static DEFAULT_CONFIG={};iframe=$j.required("plainIframe");widgetUrl=null;displayTransparentOverlay=vt("block");constructor(){let e=new URL("/signalk-anchoralarm-plugin/",window.location.origin);this.widgetUrl=this.toSafeResourceUrl(e),Fa(()=>{let i=this.runtime.options(),t=this._dashboard.isDashboardStatic();i&&ge(()=>{t?this.displayTransparentOverlay.set("none"):this.displayTransparentOverlay.set("block");});}),window.addEventListener("message",this.handleIframeGesture);}toSafeResourceUrl(e){return e.origin!==window.location.origin||!e.pathname.startsWith("/signalk-anchoralarm-plugin/")?null:this._sanitizer.bypassSecurityTrustResourceUrl(e.toString())}ngAfterViewInit(){if(this.iframe()){this.iframe().nativeElement.onload=()=>this.injectSwipeScript();try{let e=this.iframe().nativeElement.contentDocument;e&&(e.readyState==="complete"||e.readyState==="interactive")&&this.injectSwipeScript();}catch(e){}}}handleIframeGesture=e=>{if(!e.data)return;let i=e.data?.eventData?.instanceId||e.data?.keyEventData?.instanceId;if(!(!i||i!==this.id())){if(e.data.gesture)switch(e.data.gesture){case "swipeup":this._dashboard.navigateToPreviousDashboard();break;case "swipedown":this._dashboard.navigateToNextDashboard();break;case "swipeleft":{let t=new Event("openLeftSidenav",{bubbles:true,cancelable:true});window.document.dispatchEvent(t);break}case "swiperight":{let t=new Event("openRightSidenav",{bubbles:true,cancelable:true});window.document.dispatchEvent(t);break}}if(e.data.type==="keydown"&&e.data.keyEventData){let{key:t,ctrlKey:s,shiftKey:n}=e.data.keyEventData,I=new KeyboardEvent("keydown",{key:t,ctrlKey:s,shiftKey:n,bubbles:true,cancelable:true});document.dispatchEvent(I);}}};injectSwipeScript(){let e=this.iframe().nativeElement.contentWindow,i=this.iframe().nativeElement.contentDocument;if(!i||!e){console.error("[WidgetIframe] Iframe contentDocument or contentWindow is undefined. Possible cross-origin issue or iframe not fully loaded.");return}try{let t=`kip-gesture-inject-${this.id()}`;if(i.getElementById(t))return;let s=a$1({instanceId:this.id()}),n=i.createElement("script");n.id=t,n.textContent=s,i.body.appendChild(n);}catch(t){console.warn("[WidgetIframe] Failed to inject swipe script into iframe:",t);}}ngOnDestroy(){window.removeEventListener("message",this.handleIframeGesture),this.iframe()&&(this.iframe().nativeElement.onload=null);try{let e=this.iframe()?.nativeElement.contentDocument;if(e){let i=`kip-gesture-inject-${this.id()}`,t=e.getElementById(i);t&&t.parentNode&&t.parentNode.removeChild(t);}}catch(e){}}static \u0275fac=function(i){return new(i||a)};static \u0275cmp=JD({type:a,selectors:[["widget-anchor-alarm"]],viewQuery:function(i,t){i&1&&eg(t.iframe,C,5),i&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:3,vars:3,consts:[["plainIframe",""],["width","100%","height","100%","frameborder","0",1,"widgetIframe",3,"src"],[1,"widgetOverlay"]],template:function(i,t){i&1&&Uh(0,"iframe",1,0)(2,"div",2),i&2&&(Gh("src",t.widgetUrl,pp),EE(2),ig("display",t.displayTransparentOverlay()));},styles:["[_nghost-%COMP%]{overflow:hidden}.widgetIframe[_ngcontent-%COMP%]{background-color:#fff;border-radius:var(--mat-card-elevated-container-shape, var(--mat-sys-corner-medium))}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent}"]})}return a})();export{j as WidgetAnchorAlarmComponent};
1
+ import {a as a$1}from'./chunk-DVB9tiW3.js';import {d1 as Hj,w,du as p,a as G,H as Dr,G as Gi,$ as $j,v as vt,F as Fa,dn as ge,J as JD,cp as Uh,b_ as Gh,e as EE,d as ig,f as eg,K as Kw,dP as pp}from'./main-BNR44HGB.js';var C=["plainIframe"],j=(()=>{class a{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);_dashboard=w(G);_sanitizer=w(Dr);settings=w(Gi);static DEFAULT_CONFIG={};iframe=$j.required("plainIframe");widgetUrl=null;displayTransparentOverlay=vt("block");constructor(){let e=new URL("/signalk-anchoralarm-plugin/",window.location.origin);this.widgetUrl=this.toSafeResourceUrl(e),Fa(()=>{let i=this.runtime.options(),t=this._dashboard.isDashboardStatic();i&&ge(()=>{t?this.displayTransparentOverlay.set("none"):this.displayTransparentOverlay.set("block");});}),window.addEventListener("message",this.handleIframeGesture);}toSafeResourceUrl(e){return e.origin!==window.location.origin||!e.pathname.startsWith("/signalk-anchoralarm-plugin/")?null:this._sanitizer.bypassSecurityTrustResourceUrl(e.toString())}ngAfterViewInit(){if(this.iframe()){this.iframe().nativeElement.onload=()=>this.injectSwipeScript();try{let e=this.iframe().nativeElement.contentDocument;e&&(e.readyState==="complete"||e.readyState==="interactive")&&this.injectSwipeScript();}catch(e){}}}handleIframeGesture=e=>{if(!e.data)return;let i=e.data?.eventData?.instanceId||e.data?.keyEventData?.instanceId;if(!(!i||i!==this.id())){if(e.data.gesture)switch(e.data.gesture){case "swipeup":this._dashboard.navigateToPreviousDashboard();break;case "swipedown":this._dashboard.navigateToNextDashboard();break;case "swipeleft":{let t=new Event("openLeftSidenav",{bubbles:true,cancelable:true});window.document.dispatchEvent(t);break}case "swiperight":{let t=new Event("openRightSidenav",{bubbles:true,cancelable:true});window.document.dispatchEvent(t);break}}if(e.data.type==="keydown"&&e.data.keyEventData){let{key:t,ctrlKey:s,shiftKey:n}=e.data.keyEventData,I=new KeyboardEvent("keydown",{key:t,ctrlKey:s,shiftKey:n,bubbles:true,cancelable:true});document.dispatchEvent(I);}}};injectSwipeScript(){let e=this.iframe().nativeElement.contentWindow,i=this.iframe().nativeElement.contentDocument;if(!i||!e){console.error("[WidgetIframe] Iframe contentDocument or contentWindow is undefined. Possible cross-origin issue or iframe not fully loaded.");return}try{let t=`kip-gesture-inject-${this.id()}`;if(i.getElementById(t))return;let s=a$1({instanceId:this.id()}),n=i.createElement("script");n.id=t,n.textContent=s,i.body.appendChild(n);}catch(t){console.warn("[WidgetIframe] Failed to inject swipe script into iframe:",t);}}ngOnDestroy(){window.removeEventListener("message",this.handleIframeGesture),this.iframe()&&(this.iframe().nativeElement.onload=null);try{let e=this.iframe()?.nativeElement.contentDocument;if(e){let i=`kip-gesture-inject-${this.id()}`,t=e.getElementById(i);t&&t.parentNode&&t.parentNode.removeChild(t);}}catch(e){}}static \u0275fac=function(i){return new(i||a)};static \u0275cmp=JD({type:a,selectors:[["widget-anchor-alarm"]],viewQuery:function(i,t){i&1&&eg(t.iframe,C,5),i&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:3,vars:3,consts:[["plainIframe",""],["width","100%","height","100%","frameborder","0",1,"widgetIframe",3,"src"],[1,"widgetOverlay"]],template:function(i,t){i&1&&Uh(0,"iframe",1,0)(2,"div",2),i&2&&(Gh("src",t.widgetUrl,pp),EE(2),ig("display",t.displayTransparentOverlay()));},styles:["[_nghost-%COMP%]{overflow:hidden}.widgetIframe[_ngcontent-%COMP%]{background-color:#fff;border-radius:var(--mat-card-elevated-container-shape, var(--mat-sys-corner-medium))}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent}"]})}return a})();export{j as WidgetAnchorAlarmComponent};
@@ -1 +1 @@
1
- import {d1 as Hj,w,du as p,dv as rt,aZ as F,$ as $j,v as vt,D as Dt,F as Fa,dn as ge,J as JD,cp as Uh,f as eg,K as Kw}from'./main-BAV5VDOD.js';import {c}from'./chunk-Dxlia2NE.js';var P=["canvasMainRef"],B=(()=>{class s{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);canvas=w(F);canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;titleBitmap=null;titleBitmapText=null;titleBitmapColor=null;maxTextWidth=0;maxTextHeight=0;middle=0;center=0;fontSizeOffset=0;latPos="";longPos="";labelColor=vt("");valueColor="";normalizedConfig=Dt(()=>this.runtime.options()??s.DEFAULT_CONFIG);positionPaths=Dt(()=>this.normalizedConfig().paths??{});static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:false,displayName:"Position",filterSelfPaths:true,paths:{longPath:{description:"Longitude",path:"self.navigation.position.longitude",source:"default",pathType:"number",isPathConfigurable:true,convertUnitTo:"longitudeMin",showPathSkUnitsFilter:true,pathSkUnitsFilter:null,sampleTime:500},latPath:{description:"Latitude",path:"self.navigation.position.latitude",source:"default",pathType:"number",isPathConfigurable:true,convertUnitTo:"latitudeMin",showPathSkUnitsFilter:true,pathSkUnitsFilter:null,sampleTime:500}},color:"contrast",enableTimeout:false,dataTimeout:5};constructor(){Fa(()=>{let e=this.normalizedConfig(),t=this.theme();t&&ge(()=>{let i=c(e.color??"contrast",t);this.labelColor.set(i.dim),this.valueColor=i.color,this.draw();});}),Fa(()=>{let e=this.positionPaths().longPath;e?.path&&ge(()=>this.streams.observe("longPath",t=>{let i=t?.data?.value;i==null?this.longPos="":e.convertUnitTo==="pdeg"?this.longPos=i.toFixed(6)+"\xB0":this.longPos=String(i),this.calculateFontSizeAndPositions(),this.draw();}));}),Fa(()=>{let e=this.positionPaths().latPath;e?.path&&ge(()=>this.streams.observe("latPath",t=>{let i=t?.data?.value;i==null?this.latPos="":e.convertUnitTo==="pdeg"?this.latPos=i.toFixed(7)+"\xB0":this.latPos=String(i),this.calculateFontSizeAndPositions(),this.draw();}));});}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.calculateFontSizeAndPositions(),this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.calculateFontSizeAndPositions(),this.draw();}calculateFontSizeAndPositions(){if(!this.cssWidth||!this.cssHeight)return;this.maxTextHeight=Math.floor(this.cssHeight*.6/2),this.maxTextWidth=Math.floor(this.cssWidth*.85),this.center=this.cssWidth/2,this.middle=this.cssHeight*.57;let e=this.latPos.length>this.longPos.length?this.latPos:this.longPos;if(this.ctx){let t=this.canvas.calculateOptimalFontSize(this.ctx,e,this.maxTextWidth,this.maxTextHeight,"bold");this.fontSizeOffset=Math.floor(t*5e-4);}}draw(){if(!this.ctx||!this.canvasElement)return;let t=this.normalizedConfig().displayName||"Position",i=this.labelColor();(!this.titleBitmap||this.titleBitmap.width!==this.canvasElement.width||this.titleBitmap.height!==this.canvasElement.height||this.titleBitmapText!==t||this.titleBitmapColor!==i)&&(this.titleBitmap=this.canvas.createTitleBitmap(t,i,"normal",this.cssWidth,this.cssHeight),this.titleBitmapText=t,this.titleBitmapColor=i),this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),this.titleBitmap&&this.titleBitmap.width>0&&this.titleBitmap.height>0&&this.ctx.drawImage(this.titleBitmap,0,0,this.cssWidth,this.cssHeight),this.canvas.drawText(this.ctx,this.latPos,this.center,this.middle-this.fontSizeOffset,this.maxTextWidth,this.maxTextHeight,"bold",this.valueColor,"center","bottom"),this.canvas.drawText(this.ctx,this.longPos,this.center,this.middle+this.fontSizeOffset,this.maxTextWidth,this.maxTextHeight,"bold",this.valueColor,"center","top");}ngOnDestroy(){try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(e){}}static \u0275fac=function(t){return new(t||s)};static \u0275cmp=JD({type:s,selectors:[["widget-position"]],viewQuery:function(t,i){t&1&&eg(i.canvasRef,P,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:0,consts:[["canvasMainRef",""],[1,"position-canvas"]],template:function(t,i){t&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%;overflow:hidden}.position-canvas[_ngcontent-%COMP%]{display:block;width:100%!important;height:100%!important;min-height:1px}"]})}return s})();export{B as WidgetPositionComponent};
1
+ import {d1 as Hj,w,du as p,dv as rt,aZ as R,$ as $j,v as vt,D as Dt,F as Fa,dn as ge,J as JD,cp as Uh,f as eg,K as Kw}from'./main-BNR44HGB.js';import {c}from'./chunk-D_wrJJxl.js';var P=["canvasMainRef"],B=(()=>{class s{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);canvas=w(R);canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;titleBitmap=null;titleBitmapText=null;titleBitmapColor=null;maxTextWidth=0;maxTextHeight=0;middle=0;center=0;fontSizeOffset=0;latPos="";longPos="";labelColor=vt("");valueColor="";normalizedConfig=Dt(()=>this.runtime.options()??s.DEFAULT_CONFIG);positionPaths=Dt(()=>this.normalizedConfig().paths??{});static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:false,displayName:"Position",filterSelfPaths:true,paths:{longPath:{description:"Longitude",path:"self.navigation.position.longitude",source:"default",pathType:"number",isPathConfigurable:true,convertUnitTo:"longitudeMin",showPathSkUnitsFilter:true,pathSkUnitsFilter:null,sampleTime:500},latPath:{description:"Latitude",path:"self.navigation.position.latitude",source:"default",pathType:"number",isPathConfigurable:true,convertUnitTo:"latitudeMin",showPathSkUnitsFilter:true,pathSkUnitsFilter:null,sampleTime:500}},color:"contrast",enableTimeout:false,dataTimeout:5};constructor(){Fa(()=>{let e=this.normalizedConfig(),t=this.theme();t&&ge(()=>{let i=c(e.color??"contrast",t);this.labelColor.set(i.dim),this.valueColor=i.color,this.draw();});}),Fa(()=>{let e=this.positionPaths().longPath;e?.path&&ge(()=>this.streams.observe("longPath",t=>{let i=t?.data?.value;i==null?this.longPos="":e.convertUnitTo==="pdeg"?this.longPos=i.toFixed(6)+"\xB0":this.longPos=String(i),this.calculateFontSizeAndPositions(),this.draw();}));}),Fa(()=>{let e=this.positionPaths().latPath;e?.path&&ge(()=>this.streams.observe("latPath",t=>{let i=t?.data?.value;i==null?this.latPos="":e.convertUnitTo==="pdeg"?this.latPos=i.toFixed(7)+"\xB0":this.latPos=String(i),this.calculateFontSizeAndPositions(),this.draw();}));});}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.calculateFontSizeAndPositions(),this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.calculateFontSizeAndPositions(),this.draw();}calculateFontSizeAndPositions(){if(!this.cssWidth||!this.cssHeight)return;this.maxTextHeight=Math.floor(this.cssHeight*.6/2),this.maxTextWidth=Math.floor(this.cssWidth*.85),this.center=this.cssWidth/2,this.middle=this.cssHeight*.57;let e=this.latPos.length>this.longPos.length?this.latPos:this.longPos;if(this.ctx){let t=this.canvas.calculateOptimalFontSize(this.ctx,e,this.maxTextWidth,this.maxTextHeight,"bold");this.fontSizeOffset=Math.floor(t*5e-4);}}draw(){if(!this.ctx||!this.canvasElement)return;let t=this.normalizedConfig().displayName||"Position",i=this.labelColor();(!this.titleBitmap||this.titleBitmap.width!==this.canvasElement.width||this.titleBitmap.height!==this.canvasElement.height||this.titleBitmapText!==t||this.titleBitmapColor!==i)&&(this.titleBitmap=this.canvas.createTitleBitmap(t,i,"normal",this.cssWidth,this.cssHeight),this.titleBitmapText=t,this.titleBitmapColor=i),this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),this.titleBitmap&&this.titleBitmap.width>0&&this.titleBitmap.height>0&&this.ctx.drawImage(this.titleBitmap,0,0,this.cssWidth,this.cssHeight),this.canvas.drawText(this.ctx,this.latPos,this.center,this.middle-this.fontSizeOffset,this.maxTextWidth,this.maxTextHeight,"bold",this.valueColor,"center","bottom"),this.canvas.drawText(this.ctx,this.longPos,this.center,this.middle+this.fontSizeOffset,this.maxTextWidth,this.maxTextHeight,"bold",this.valueColor,"center","top");}ngOnDestroy(){try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(e){}}static \u0275fac=function(t){return new(t||s)};static \u0275cmp=JD({type:s,selectors:[["widget-position"]],viewQuery:function(t,i){t&1&&eg(i.canvasRef,P,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:0,consts:[["canvasMainRef",""],[1,"position-canvas"]],template:function(t,i){t&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%;overflow:hidden}.position-canvas[_ngcontent-%COMP%]{display:block;width:100%!important;height:100%!important;min-height:1px}"]})}return s})();export{B as WidgetPositionComponent};
@@ -1 +1 @@
1
- import'./chunk-By8ZVvDx.js';import {d1 as Hj,w,du as p,dv as rt,aZ as F,dw as S,$ as $j,v as vt,D as Dt,dx as n$1,F as Fa,dn as ge,J as JD,_ as _w,c as $h,M as Mw,f as eg,K as Kw,bu as ut,dy as K,ao as ue,a6 as Lr,b0 as Wl,cp as Uh,g as qw,B as Bh}from'./main-BAV5VDOD.js';import {c}from'./chunk-Dxlia2NE.js';var H=["widgetDataChart"],C=(()=>{class n{theme=Hj.required();color=null;dataPath=null;dataSource=null;convertUnitTo=null;numDecimal=null;yScaleMin=null;yScaleMax=null;inverseYAxis=false;verticalChart=null;datasetUUID=null;unitsService=w(ut);dsService=w(K);ngZone=w(ue);canvasService=w(F);widgetDataChart=$j("widgetDataChart",{read:Lr});lineChartData={datasets:[]};lineChartOptions={parsing:false,datasets:{line:{pointRadius:0,pointHoverRadius:0,tension:.4}},animations:{tension:{easing:"easeInOutCubic"}}};lineChartType="line";chart=null;dsServiceSub=null;datasetConfig=null;dataSourceInfo=null;isDestroyed=false;lastChartSignature=null;config={datasetAverageArray:"sma",showAverageData:false,trackAgainstAverage:false,startScaleAtZero:false,yScaleSuggestedMin:null,yScaleSuggestedMax:null,enableMinMaxScaleLimit:false};constructor(){Fa(()=>{this.theme()&&ge(()=>{this.datasetConfig&&(this.setChartOptions(),this.setDatasetsColors());});});}startChart(){if(!(this.isDestroyed||!this.datasetUUID)&&(this.datasetConfig=this.dsService.getDatasetConfig(this.datasetUUID)??null,this.dataSourceInfo=this.dsService.getDataSourceInfo(this.datasetUUID)??null,this.datasetConfig&&this.dataSourceInfo)){let t=this.buildChartSignature();if(this.chart&&t===this.lastChartSignature)return;this.chart&&t!==this.lastChartSignature&&this.destroyChart(),this.setChartOptions(),this.createDatasets();let i=this.widgetDataChart()?.nativeElement?.getContext("2d");if(!i)return;this.chart=new Wl(i,{type:this.lineChartType,data:this.lineChartData,options:this.lineChartOptions}),this.lastChartSignature=t,this.startStreaming();}}buildChartSignature(){return [this.datasetUUID,this.dataPath,this.dataSource,this.convertUnitTo,this.numDecimal,this.yScaleMin,this.yScaleMax,this.inverseYAxis?"1":"0",this.verticalChart?"1":"0",this.color].join("|")}setChartOptions(){let t=this.datasetConfig,e=this.dataSourceInfo;!t||!e||(this.lineChartOptions.maintainAspectRatio=false,this.lineChartOptions.animation=false,this.lineChartOptions.indexAxis=this.verticalChart?"y":"x",this.verticalChart?this.lineChartOptions.scales={x:{display:false,position:"right",suggestedMin:this.config.enableMinMaxScaleLimit?void 0:this.numberOrUndefined(this.yScaleMin),suggestedMax:this.config.enableMinMaxScaleLimit?void 0:this.numberOrUndefined(this.yScaleMax),min:this.config.enableMinMaxScaleLimit?this.numberOrUndefined(this.yScaleMin):void 0,max:this.config.enableMinMaxScaleLimit?this.numberOrUndefined(this.yScaleMax):void 0,beginAtZero:this.config.startScaleAtZero,reverse:this.inverseYAxis,title:{display:false,text:"Value Axis",align:"center"},ticks:{maxTicksLimit:8,precision:this.numberOrUndefined(this.numDecimal),color:this.getThemeColors().averageChartLine,major:{enabled:true}},grid:{display:false,color:this.theme().contrastDimmer}},y:{type:"realtime",display:false,title:{display:false},time:{unit:t.timeScaleFormat,minUnit:"second",round:"second",displayFormats:{hour:"k:mm''",minute:"mm''",second:'ss"',millisecond:"SSS"}},ticks:{autoSkip:false,color:this.getThemeColors().averageChartLine,major:{enabled:true}},grid:{display:false,color:this.theme().contrastDimmer}}}:this.lineChartOptions.scales={x:{type:"realtime",display:false,title:{display:false},time:{unit:t.timeScaleFormat,minUnit:"second",round:"second",displayFormats:{hour:"k:mm''",minute:"mm''",second:'ss"',millisecond:"SSS"}},ticks:{autoSkip:false,color:this.getThemeColors().averageChartLine,major:{enabled:true}},grid:{display:false,color:this.theme().contrastDimmer}},y:{display:false,position:"right",suggestedMin:this.config.enableMinMaxScaleLimit?void 0:this.numberOrUndefined(this.yScaleMin),suggestedMax:this.config.enableMinMaxScaleLimit?void 0:this.numberOrUndefined(this.yScaleMax),min:this.config.enableMinMaxScaleLimit?this.numberOrUndefined(this.yScaleMin):void 0,max:this.config.enableMinMaxScaleLimit?this.numberOrUndefined(this.yScaleMax):void 0,beginAtZero:this.config.startScaleAtZero,reverse:this.inverseYAxis,title:{display:false,text:"Value Axis",align:"center"},ticks:{maxTicksLimit:8,precision:this.numberOrUndefined(this.numDecimal),color:this.getThemeColors().averageChartLine,major:{enabled:true}},grid:{display:false,color:this.theme().contrastDimmer}}},this.lineChartOptions.plugins={legend:{display:false},annotation:{annotations:{}},streaming:{duration:e.maxDataPoints*e.sampleTime,delay:e.sampleTime,frameRate:t.timeScaleFormat==="day"?5:t.timeScaleFormat==="hour"?8:t.timeScaleFormat==="minute"?15:30}});}numberOrUndefined(t){return t??void 0}createDatasets(){let t=this.lineChartOptions.scales?.y?.reverse?"start":true;this.lineChartData.datasets=[],this.lineChartData.datasets.push({label:"Value",data:[],order:0,parsing:false,tension:.4,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:3,fill:t}),this.lineChartData.datasets.push({label:"Average",data:[],order:1,parsing:false,tension:.4,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:3,fill:t}),this.setDatasetsColors();}setDatasetsColors(){this.lineChartData.datasets.forEach(t=>{t.borderColor=this.getThemeColors().averageLine,t.backgroundColor=this.getThemeColors().averageFill;});}getThemeColors(){let t=this.color,e={valueLine:"",valueFill:"",averageLine:"",averageFill:"",averageChartLine:"",chartLabel:"",chartValue:""};switch(t){case "contrast":this.config.trackAgainstAverage?(e.valueLine=this.theme().contrastDimmer,e.valueFill=this.theme().contrastDimmer,e.averageLine=this.theme().contrast,e.averageFill=this.theme().contrast,e.chartValue=e.averageLine):(e.valueLine=this.theme().contrast,e.valueFill=this.theme().contrast,e.averageLine=this.theme().contrastDimmer,e.averageFill=this.theme().contrastDimmer,e.chartValue=this.theme().contrast),e.averageChartLine=this.theme().contrastDim,e.chartLabel=this.theme().contrastDim;break;case "blue":this.config.trackAgainstAverage?(e.valueLine=this.theme().blueDimmer,e.valueFill=this.theme().blueDimmer,e.averageLine=this.theme().blue,e.averageFill=this.theme().blue,e.chartValue=e.averageLine):(e.valueLine=this.theme().blue,e.valueFill=this.theme().blue,e.averageLine=this.theme().blueDimmer,e.averageFill=this.theme().blueDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().blueDim,e.chartLabel=this.theme().contrastDim;break;case "green":this.config.trackAgainstAverage?(e.valueLine=this.theme().greenDimmer,e.valueFill=this.theme().greenDimmer,e.averageLine=this.theme().green,e.averageFill=this.theme().green,e.chartValue=e.averageLine):(e.valueLine=this.theme().green,e.valueFill=this.theme().green,e.averageLine=this.theme().greenDimmer,e.averageFill=this.theme().greenDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().greenDim,e.chartLabel=this.theme().contrastDim;break;case "pink":this.config.trackAgainstAverage?(e.valueLine=this.theme().pinkDimmer,e.valueFill=this.theme().pinkDimmer,e.averageLine=this.theme().pink,e.averageFill=this.theme().pink,e.chartValue=e.averageLine):(e.valueLine=this.theme().pink,e.valueFill=this.theme().pink,e.averageLine=this.theme().pinkDimmer,e.averageFill=this.theme().pinkDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().pinkDim,e.chartLabel=this.theme().contrastDim;break;case "orange":this.config.trackAgainstAverage?(e.valueLine=this.theme().orangeDimmer,e.valueFill=this.theme().orangeDimmer,e.averageLine=this.theme().orange,e.averageFill=this.theme().orange,e.chartValue=e.averageLine):(e.valueLine=this.theme().orange,e.valueFill=this.theme().orange,e.averageLine=this.theme().orangeDimmer,e.averageFill=this.theme().orangeDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().orangeDim,e.chartLabel=this.theme().contrastDim;break;case "purple":this.config.trackAgainstAverage?(e.valueLine=this.theme().purpleDimmer,e.valueFill=this.theme().purpleDimmer,e.averageLine=this.theme().purple,e.averageFill=this.theme().purple,e.chartValue=e.averageLine):(e.valueLine=this.theme().purple,e.valueFill=this.theme().purple,e.averageLine=this.theme().purpleDimmer,e.averageFill=this.theme().purpleDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().purpleDim,e.chartLabel=this.theme().contrastDim;break;case "grey":this.config.trackAgainstAverage?(e.valueLine=this.theme().greyDimmer,e.valueFill=this.theme().greyDimmer,e.averageLine=this.theme().grey,e.averageFill=this.theme().grey,e.chartValue=e.averageLine):(e.valueLine=this.theme().grey,e.valueFill=this.theme().grey,e.averageLine=this.theme().greyDimmer,e.averageFill=this.theme().greyDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().greyDim,e.chartLabel=this.theme().contrastDim;break;case "yellow":this.config.trackAgainstAverage?(e.valueLine=this.theme().yellowDimmer,e.valueFill=this.theme().yellowDimmer,e.averageLine=this.theme().yellow,e.averageFill=this.theme().yellow,e.chartValue=e.averageLine):(e.valueLine=this.theme().yellow,e.valueFill=this.theme().yellow,e.averageLine=this.theme().yellowDimmer,e.averageFill=this.theme().yellowDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().yellowDim,e.chartLabel=this.theme().contrastDim;break}return e}startStreaming(){if(this.dsServiceSub?.unsubscribe(),!this.datasetUUID||!this.chart)return;let t=this.dsService.getDatasetBatchThenLiveObservable(this.datasetUUID);t&&(this.dsServiceSub=t.subscribe(e=>{if(!(this.isDestroyed||!this.chart||!this.chart.ctx)){if(Array.isArray(e)){let s=this.transformDatasetRows(e,0);if(this.chart.data.datasets[0].data.push(...s),this.config.showAverageData){let r=this.transformDatasetRows(e,this.config.datasetAverageArray);this.chart.data.datasets[1].data.push(...r);}}else {let s=this.transformDatasetRows([e],0)[0];if(this.chart.data.datasets[0].data.push(s),this.config.showAverageData){let r=this.transformDatasetRows([e],this.config.datasetAverageArray)[0];this.chart.data.datasets[1].data.push(r);}}this.ngZone.runOutsideAngular(()=>{if(this.isDestroyed||!this.chart)return;let s=this.chart;s.ctx&&s.update("none");});}}));}destroyChart(){this.dsServiceSub?.unsubscribe(),this.dsServiceSub=null,this.chart?.destroy(),this.chart=null,this.lastChartSignature=null;}transformDatasetRows(t,e){let i=a=>this.unitsService.convertToUnit(this.convertUnitTo??"",a)??a,s=this.verticalChart===true,r=this.config.datasetAverageArray;return t.map(a=>{if(s){if(e===0)return {x:i(a.data.value),y:a.timestamp};{let D={sma:a.data.sma,ema:a.data.ema,dema:a.data.doubleEma,avg:a.data.lastAverage};return {x:i(D[r]??a.data.value),y:a.timestamp}}}else {if(e===0)return {x:a.timestamp,y:i(a.data.value)};{let D={sma:a.data.sma,ema:a.data.ema,dema:a.data.doubleEma,avg:a.data.lastAverage};return {x:a.timestamp,y:i(D[r]??a.data.value)}}}})}ngOnDestroy(){this.isDestroyed=true,this.destroyChart();let t=this.widgetDataChart?.()?.nativeElement;this.canvasService.releaseCanvas(t,{clear:true,removeFromDom:true});}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=JD({type:n,selectors:[["minichart"]],viewQuery:function(e,i){e&1&&eg(i.widgetDataChart,H,5,Lr),e&2&&Kw();},inputs:{theme:[1,"theme"]},decls:2,vars:0,consts:[["widgetDataChart",""],[2,"z-index","inherit"]],template:function(e,i){e&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:calc(90% - 10px);position:absolute;bottom:0;border-radius:12px;overflow:hidden}"]})}return n})();var I=["canvasMainRef"];function E(n,P){if(n&1&&$h(0,"minichart",1),n&2){let t=qw();Bh("theme",t.theme());}}var se=(()=>{class n{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:true,displayName:"Gauge Label",filterSelfPaths:true,paths:{numericPath:{description:"Numeric Data",path:null,source:null,pathType:"number",suppressBootstrapNull:true,isPathConfigurable:true,convertUnitTo:"unitless",showPathSkUnitsFilter:true,pathSkUnitsFilter:null,sampleTime:500}},showMax:false,showMin:false,numDecimal:1,showMiniChart:false,yScaleMin:0,yScaleMax:10,inverseYAxis:false,verticalChart:false,color:"contrast",enableTimeout:false,dataTimeout:5,ignoreZones:false};runtime=w(p);stream=w(rt);canvas=w(F);datasetLifecycle=w(S);miniChart=$j(C);canvasMainRef=$j.required("canvasMainRef");showMiniChart=vt(false);labelColor=vt("");canvasElement;canvasCtx=null;cssWidth=0;cssHeight=0;backgroundBitmap=null;backgroundBitmapText=null;dataValue=null;maxValue=null;minValue=null;valueColor="";valueStateColor="";maxValueTextWidth=0;maxValueTextHeight=0;maxMinMaxTextWidth=0;maxMinMaxTextHeight=0;streamRegistered=false;pathDataState=null;isDestroyed=false;lastSubscriptionSignature=null;normalizedConfig=Dt(()=>this.runtime.options()??n.DEFAULT_CONFIG);numericPathConfig=Dt(()=>this.normalizedConfig().paths?.numericPath);subscriptionSignature=Dt(()=>{this.normalizedConfig();let e=this.numericPathConfig();if(!e?.path)return null;let i=e.source?.trim()||"default";return [e.path,e.pathType,e.sampleTime,e.convertUnitTo,i,e.suppressBootstrapNull?"1":"0"].join("|")});onNumericValue=t=>{if(this.dataValue=t.data.value,this.minValue===null||this.dataValue<this.minValue?this.minValue=this.dataValue:(this.maxValue===null||this.dataValue>this.maxValue)&&(this.maxValue=this.dataValue),!this.normalizedConfig().ignoreZones&&this.pathDataState!==t.state)switch(this.pathDataState=t.state,t.state){case n$1.Alarm:this.valueStateColor=this.theme().zoneAlarm;break;case n$1.Warn:this.valueStateColor=this.theme().zoneWarn;break;case n$1.Alert:this.valueStateColor=this.theme().zoneAlert;break;default:this.valueStateColor=this.valueColor;break}this.drawWidget();};constructor(){this.showMiniChart.set(this.normalizedConfig().showMiniChart??false),Fa(()=>{let t=this.theme(),e=this.normalizedConfig().color;ge(()=>{t&&e!==void 0&&(this.setColors(),this.drawWidget());});}),Fa(()=>{let t=this.subscriptionSignature();ge(()=>{this.isDestroyed||!this.canvasCtx||t===this.lastSubscriptionSignature&&this.streamRegistered||(this.minValue=null,this.maxValue=null,this.dataValue=null,this.pathDataState=null,this.lastSubscriptionSignature=t,t&&(this.stream?.observe("numericPath",this.onNumericValue),this.streamRegistered=true,this.manageDatasetAndChart()));});}),Fa(()=>{let t=this.showMiniChart(),e=this.miniChart(),i=this.normalizedConfig(),s=this.numericPathConfig();[i?.showMiniChart?"1":"0",s?.path??"",s?.source??"default",s?.convertUnitTo??"",i?.numDecimal??"",i?.yScaleMin??"",i?.yScaleMax??"",i?.inverseYAxis?"1":"0",i?.verticalChart?"1":"0",i?.color??""].join("|")&&t&&e&&(this.setMiniChart(),e.startChart());});}ngOnInit(){this.setColors(),this.canvasElement=this.canvasMainRef().nativeElement,this.canvasCtx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(t,e)=>{this.cssWidth=t,this.cssHeight=e,this.calculateMaxMinTextDimensions(),this.drawWidget();}});}ngAfterViewInit(){this.isDestroyed||!this.streamRegistered&&this.subscriptionSignature()&&(this.stream?.observe("numericPath",this.onNumericValue),this.streamRegistered=true,this.manageDatasetAndChart());}calculateMaxMinTextDimensions(){this.maxValueTextWidth=Math.floor(this.cssWidth*.85),this.maxValueTextHeight=Math.floor(this.cssHeight*.7),this.maxMinMaxTextWidth=Math.floor(this.cssWidth*.57),this.maxMinMaxTextHeight=Math.floor(this.cssHeight*.1);}manageDatasetAndChart(){let t=this.normalizedConfig(),e=this.numericPathConfig(),i=!!t.showMiniChart;if(this.showMiniChart.set(i),!i){this.datasetLifecycle.removeDatasetIfExists(this.id(),false);return}if(!e||!e.path)return;let s=e.source??"default";this.datasetLifecycle.syncNumericMiniChartDataset(this.id(),e.path,s);}setMiniChart(){let t=this.miniChart(),e=this.normalizedConfig(),i=this.numericPathConfig();t&&(t.dataPath=i?.path??null,t.dataSource=i?.source??"default",t.color=e.color??"contrast",t.convertUnitTo=i?.convertUnitTo??null,t.numDecimal=e.numDecimal??null,t.yScaleMin=e.yScaleMin??null,t.yScaleMax=e.yScaleMax??null,t.inverseYAxis=e.inverseYAxis??false,t.verticalChart=e.verticalChart??null,t.datasetUUID=this.id());}setColors(){let t=this.normalizedConfig(),e=this.theme(),i=t.color??"contrast";this.labelColor.set(c(i,e).dim),this.valueStateColor=this.valueColor=c(i,e).color,this.backgroundBitmap=null,this.backgroundBitmapText=null;}drawWidget(){if(!this.canvasCtx)return;let t=this.normalizedConfig(),e=this.numericPathConfig()?.convertUnitTo??"",i=10*this.canvas.scaleFactor,s=5*this.canvas.scaleFactor,r=(t.displayName??"")+"|"+e;(!this.backgroundBitmap||this.backgroundBitmap.width!==this.canvasElement.width||this.backgroundBitmap.height!==this.canvasElement.height||this.backgroundBitmapText!==r)&&(this.backgroundBitmap=this.canvas.renderStaticToBitmap(this.canvasCtx,this.cssWidth,this.cssHeight,a=>{this.canvas.drawTitleInternal(a,t.displayName??"",this.labelColor(),"normal",this.cssWidth,this.cssHeight,.1),["unitless","percent","ratio","latitudeSec","latitudeMin","longitudeSec","longitudeMin"].includes(e)||this.canvas.drawText(a,e,this.cssWidth-i,this.cssHeight-s,Math.floor(this.cssWidth*.25),Math.floor(this.cssHeight*.15),"bold",this.valueColor,"end","bottom");}),this.backgroundBitmapText=r),this.canvas.clearCanvas(this.canvasCtx,this.cssWidth,this.cssHeight),this.backgroundBitmap&&this.backgroundBitmap.width>0&&this.backgroundBitmap.height>0&&this.canvasCtx.drawImage(this.backgroundBitmap,0,0,this.cssWidth,this.cssHeight),this.drawValue(),(t.showMax||t.showMin)&&this.drawMinMax();}drawValue(){let t=this.getValueText(),e=this.canvasCtx;e&&this.canvas.drawText(e,t,Math.floor(this.cssWidth/2),Math.floor(this.cssHeight/2*1.15),this.maxValueTextWidth,this.maxValueTextHeight,"bold",this.valueStateColor);}getValueText(){if(this.dataValue===null)return "--";let t=this.normalizedConfig(),e=this.numericPathConfig()?.convertUnitTo??"";return ["latitudeSec","latitudeMin","longitudeSec","longitudeMin","D HH:MM:SS"].includes(e)?this.dataValue.toString():this.applyDecorations(this.dataValue.toFixed(t.numDecimal??1))}drawMinMax(){let t=this.normalizedConfig();if(!t.showMin&&!t.showMax)return;let e=t.numDecimal??1,i="";t.showMin&&(i=this.minValue!=null?` Min: ${this.applyDecorations(this.minValue.toFixed(e))}`:" Min: --"),t.showMax&&(i+=this.maxValue!=null?` Max: ${this.applyDecorations(this.maxValue.toFixed(e))}`:" Max: --"),i=i.trim();let s=10*this.canvas.scaleFactor,r=5*this.canvas.scaleFactor,a=this.canvasCtx;a&&this.canvas.drawText(a,i,s,Math.floor(this.cssHeight-r),this.maxMinMaxTextWidth,this.maxMinMaxTextHeight,"normal",this.valueColor,"start","bottom");}applyDecorations(t){switch(this.numericPathConfig()?.convertUnitTo??""){case "percent":case "percentraw":t+="%";break}return t}ngOnDestroy(){this.isDestroyed=true,this.datasetLifecycle.removeDatasetIfExists(this.id(),false);try{this.canvas.unregisterCanvas(this.canvasElement);}catch(t){}}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=JD({type:n,selectors:[["widget-numeric"]],viewQuery:function(e,i){e&1&&eg(i.miniChart,C,5)(i.canvasMainRef,I,5),e&2&&Kw(2);},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:3,vars:1,consts:[["canvasMainRef",""],[3,"theme"],[1,"numeric-canvas"]],template:function(e,i){e&1&&(_w(0,E,1,1,"minichart",1),$h(1,"canvas",2,0)),e&2&&Mw(i.showMiniChart()?0:-1);},dependencies:[C],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%}.numeric-wrapper[_ngcontent-%COMP%]{width:100%;height:100%;min-height:1px}.numeric-canvas[_ngcontent-%COMP%]{position:relative;width:100%!important;height:100%!important;display:block}"]})}return n})();export{se as WidgetNumericComponent};
1
+ import'./chunk-h2q_pbbF.js';import {d1 as Hj,w,du as p,dv as rt,aZ as R,dw as S,$ as $j,v as vt,D as Dt,dx as n$1,F as Fa,dn as ge,J as JD,_ as _w,c as $h,M as Mw,f as eg,K as Kw,bu as ut,dy as K,ao as ue,a6 as Lr,b0 as Wl,cp as Uh,g as qw,B as Bh}from'./main-BNR44HGB.js';import {c}from'./chunk-D_wrJJxl.js';var H=["widgetDataChart"],C=(()=>{class n{theme=Hj.required();color=null;dataPath=null;dataSource=null;convertUnitTo=null;numDecimal=null;yScaleMin=null;yScaleMax=null;inverseYAxis=false;verticalChart=null;datasetUUID=null;unitsService=w(ut);dsService=w(K);ngZone=w(ue);canvasService=w(R);widgetDataChart=$j("widgetDataChart",{read:Lr});lineChartData={datasets:[]};lineChartOptions={parsing:false,datasets:{line:{pointRadius:0,pointHoverRadius:0,tension:.4}},animations:{tension:{easing:"easeInOutCubic"}}};lineChartType="line";chart=null;dsServiceSub=null;datasetConfig=null;dataSourceInfo=null;isDestroyed=false;lastChartSignature=null;config={datasetAverageArray:"sma",showAverageData:false,trackAgainstAverage:false,startScaleAtZero:false,yScaleSuggestedMin:null,yScaleSuggestedMax:null,enableMinMaxScaleLimit:false};constructor(){Fa(()=>{this.theme()&&ge(()=>{this.datasetConfig&&(this.setChartOptions(),this.setDatasetsColors());});});}startChart(){if(!(this.isDestroyed||!this.datasetUUID)&&(this.datasetConfig=this.dsService.getDatasetConfig(this.datasetUUID)??null,this.dataSourceInfo=this.dsService.getDataSourceInfo(this.datasetUUID)??null,this.datasetConfig&&this.dataSourceInfo)){let t=this.buildChartSignature();if(this.chart&&t===this.lastChartSignature)return;this.chart&&t!==this.lastChartSignature&&this.destroyChart(),this.setChartOptions(),this.createDatasets();let i=this.widgetDataChart()?.nativeElement?.getContext("2d");if(!i)return;this.chart=new Wl(i,{type:this.lineChartType,data:this.lineChartData,options:this.lineChartOptions}),this.lastChartSignature=t,this.startStreaming();}}buildChartSignature(){return [this.datasetUUID,this.dataPath,this.dataSource,this.convertUnitTo,this.numDecimal,this.yScaleMin,this.yScaleMax,this.inverseYAxis?"1":"0",this.verticalChart?"1":"0",this.color].join("|")}setChartOptions(){let t=this.datasetConfig,e=this.dataSourceInfo;!t||!e||(this.lineChartOptions.maintainAspectRatio=false,this.lineChartOptions.animation=false,this.lineChartOptions.indexAxis=this.verticalChart?"y":"x",this.verticalChart?this.lineChartOptions.scales={x:{display:false,position:"right",suggestedMin:this.config.enableMinMaxScaleLimit?void 0:this.numberOrUndefined(this.yScaleMin),suggestedMax:this.config.enableMinMaxScaleLimit?void 0:this.numberOrUndefined(this.yScaleMax),min:this.config.enableMinMaxScaleLimit?this.numberOrUndefined(this.yScaleMin):void 0,max:this.config.enableMinMaxScaleLimit?this.numberOrUndefined(this.yScaleMax):void 0,beginAtZero:this.config.startScaleAtZero,reverse:this.inverseYAxis,title:{display:false,text:"Value Axis",align:"center"},ticks:{maxTicksLimit:8,precision:this.numberOrUndefined(this.numDecimal),color:this.getThemeColors().averageChartLine,major:{enabled:true}},grid:{display:false,color:this.theme().contrastDimmer}},y:{type:"realtime",display:false,title:{display:false},time:{unit:t.timeScaleFormat,minUnit:"second",round:"second",displayFormats:{hour:"k:mm''",minute:"mm''",second:'ss"',millisecond:"SSS"}},ticks:{autoSkip:false,color:this.getThemeColors().averageChartLine,major:{enabled:true}},grid:{display:false,color:this.theme().contrastDimmer}}}:this.lineChartOptions.scales={x:{type:"realtime",display:false,title:{display:false},time:{unit:t.timeScaleFormat,minUnit:"second",round:"second",displayFormats:{hour:"k:mm''",minute:"mm''",second:'ss"',millisecond:"SSS"}},ticks:{autoSkip:false,color:this.getThemeColors().averageChartLine,major:{enabled:true}},grid:{display:false,color:this.theme().contrastDimmer}},y:{display:false,position:"right",suggestedMin:this.config.enableMinMaxScaleLimit?void 0:this.numberOrUndefined(this.yScaleMin),suggestedMax:this.config.enableMinMaxScaleLimit?void 0:this.numberOrUndefined(this.yScaleMax),min:this.config.enableMinMaxScaleLimit?this.numberOrUndefined(this.yScaleMin):void 0,max:this.config.enableMinMaxScaleLimit?this.numberOrUndefined(this.yScaleMax):void 0,beginAtZero:this.config.startScaleAtZero,reverse:this.inverseYAxis,title:{display:false,text:"Value Axis",align:"center"},ticks:{maxTicksLimit:8,precision:this.numberOrUndefined(this.numDecimal),color:this.getThemeColors().averageChartLine,major:{enabled:true}},grid:{display:false,color:this.theme().contrastDimmer}}},this.lineChartOptions.plugins={legend:{display:false},annotation:{annotations:{}},streaming:{duration:e.maxDataPoints*e.sampleTime,delay:e.sampleTime,frameRate:t.timeScaleFormat==="day"?5:t.timeScaleFormat==="hour"?8:t.timeScaleFormat==="minute"?15:30}});}numberOrUndefined(t){return t??void 0}createDatasets(){let t=this.lineChartOptions.scales?.y?.reverse?"start":true;this.lineChartData.datasets=[],this.lineChartData.datasets.push({label:"Value",data:[],order:0,parsing:false,tension:.4,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:3,fill:t}),this.lineChartData.datasets.push({label:"Average",data:[],order:1,parsing:false,tension:.4,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:3,fill:t}),this.setDatasetsColors();}setDatasetsColors(){this.lineChartData.datasets.forEach(t=>{t.borderColor=this.getThemeColors().averageLine,t.backgroundColor=this.getThemeColors().averageFill;});}getThemeColors(){let t=this.color,e={valueLine:"",valueFill:"",averageLine:"",averageFill:"",averageChartLine:"",chartLabel:"",chartValue:""};switch(t){case "contrast":this.config.trackAgainstAverage?(e.valueLine=this.theme().contrastDimmer,e.valueFill=this.theme().contrastDimmer,e.averageLine=this.theme().contrast,e.averageFill=this.theme().contrast,e.chartValue=e.averageLine):(e.valueLine=this.theme().contrast,e.valueFill=this.theme().contrast,e.averageLine=this.theme().contrastDimmer,e.averageFill=this.theme().contrastDimmer,e.chartValue=this.theme().contrast),e.averageChartLine=this.theme().contrastDim,e.chartLabel=this.theme().contrastDim;break;case "blue":this.config.trackAgainstAverage?(e.valueLine=this.theme().blueDimmer,e.valueFill=this.theme().blueDimmer,e.averageLine=this.theme().blue,e.averageFill=this.theme().blue,e.chartValue=e.averageLine):(e.valueLine=this.theme().blue,e.valueFill=this.theme().blue,e.averageLine=this.theme().blueDimmer,e.averageFill=this.theme().blueDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().blueDim,e.chartLabel=this.theme().contrastDim;break;case "green":this.config.trackAgainstAverage?(e.valueLine=this.theme().greenDimmer,e.valueFill=this.theme().greenDimmer,e.averageLine=this.theme().green,e.averageFill=this.theme().green,e.chartValue=e.averageLine):(e.valueLine=this.theme().green,e.valueFill=this.theme().green,e.averageLine=this.theme().greenDimmer,e.averageFill=this.theme().greenDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().greenDim,e.chartLabel=this.theme().contrastDim;break;case "pink":this.config.trackAgainstAverage?(e.valueLine=this.theme().pinkDimmer,e.valueFill=this.theme().pinkDimmer,e.averageLine=this.theme().pink,e.averageFill=this.theme().pink,e.chartValue=e.averageLine):(e.valueLine=this.theme().pink,e.valueFill=this.theme().pink,e.averageLine=this.theme().pinkDimmer,e.averageFill=this.theme().pinkDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().pinkDim,e.chartLabel=this.theme().contrastDim;break;case "orange":this.config.trackAgainstAverage?(e.valueLine=this.theme().orangeDimmer,e.valueFill=this.theme().orangeDimmer,e.averageLine=this.theme().orange,e.averageFill=this.theme().orange,e.chartValue=e.averageLine):(e.valueLine=this.theme().orange,e.valueFill=this.theme().orange,e.averageLine=this.theme().orangeDimmer,e.averageFill=this.theme().orangeDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().orangeDim,e.chartLabel=this.theme().contrastDim;break;case "purple":this.config.trackAgainstAverage?(e.valueLine=this.theme().purpleDimmer,e.valueFill=this.theme().purpleDimmer,e.averageLine=this.theme().purple,e.averageFill=this.theme().purple,e.chartValue=e.averageLine):(e.valueLine=this.theme().purple,e.valueFill=this.theme().purple,e.averageLine=this.theme().purpleDimmer,e.averageFill=this.theme().purpleDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().purpleDim,e.chartLabel=this.theme().contrastDim;break;case "grey":this.config.trackAgainstAverage?(e.valueLine=this.theme().greyDimmer,e.valueFill=this.theme().greyDimmer,e.averageLine=this.theme().grey,e.averageFill=this.theme().grey,e.chartValue=e.averageLine):(e.valueLine=this.theme().grey,e.valueFill=this.theme().grey,e.averageLine=this.theme().greyDimmer,e.averageFill=this.theme().greyDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().greyDim,e.chartLabel=this.theme().contrastDim;break;case "yellow":this.config.trackAgainstAverage?(e.valueLine=this.theme().yellowDimmer,e.valueFill=this.theme().yellowDimmer,e.averageLine=this.theme().yellow,e.averageFill=this.theme().yellow,e.chartValue=e.averageLine):(e.valueLine=this.theme().yellow,e.valueFill=this.theme().yellow,e.averageLine=this.theme().yellowDimmer,e.averageFill=this.theme().yellowDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().yellowDim,e.chartLabel=this.theme().contrastDim;break}return e}startStreaming(){if(this.dsServiceSub?.unsubscribe(),!this.datasetUUID||!this.chart)return;let t=this.dsService.getDatasetBatchThenLiveObservable(this.datasetUUID);t&&(this.dsServiceSub=t.subscribe(e=>{if(!(this.isDestroyed||!this.chart||!this.chart.ctx)){if(Array.isArray(e)){let s=this.transformDatasetRows(e,0);if(this.chart.data.datasets[0].data.push(...s),this.config.showAverageData){let r=this.transformDatasetRows(e,this.config.datasetAverageArray);this.chart.data.datasets[1].data.push(...r);}}else {let s=this.transformDatasetRows([e],0)[0];if(this.chart.data.datasets[0].data.push(s),this.config.showAverageData){let r=this.transformDatasetRows([e],this.config.datasetAverageArray)[0];this.chart.data.datasets[1].data.push(r);}}this.ngZone.runOutsideAngular(()=>{if(this.isDestroyed||!this.chart)return;let s=this.chart;s.ctx&&s.update("none");});}}));}destroyChart(){this.dsServiceSub?.unsubscribe(),this.dsServiceSub=null,this.chart?.destroy(),this.chart=null,this.lastChartSignature=null;}transformDatasetRows(t,e){let i=a=>this.unitsService.convertToUnit(this.convertUnitTo??"",a)??a,s=this.verticalChart===true,r=this.config.datasetAverageArray;return t.map(a=>{if(s){if(e===0)return {x:i(a.data.value),y:a.timestamp};{let D={sma:a.data.sma,ema:a.data.ema,dema:a.data.doubleEma,avg:a.data.lastAverage};return {x:i(D[r]??a.data.value),y:a.timestamp}}}else {if(e===0)return {x:a.timestamp,y:i(a.data.value)};{let D={sma:a.data.sma,ema:a.data.ema,dema:a.data.doubleEma,avg:a.data.lastAverage};return {x:a.timestamp,y:i(D[r]??a.data.value)}}}})}ngOnDestroy(){this.isDestroyed=true,this.destroyChart();let t=this.widgetDataChart?.()?.nativeElement;this.canvasService.releaseCanvas(t,{clear:true,removeFromDom:true});}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=JD({type:n,selectors:[["minichart"]],viewQuery:function(e,i){e&1&&eg(i.widgetDataChart,H,5,Lr),e&2&&Kw();},inputs:{theme:[1,"theme"]},decls:2,vars:0,consts:[["widgetDataChart",""],[2,"z-index","inherit"]],template:function(e,i){e&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:calc(90% - 10px);position:absolute;bottom:0;border-radius:12px;overflow:hidden}"]})}return n})();var I=["canvasMainRef"];function E(n,P){if(n&1&&$h(0,"minichart",1),n&2){let t=qw();Bh("theme",t.theme());}}var se=(()=>{class n{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:true,displayName:"Gauge Label",filterSelfPaths:true,paths:{numericPath:{description:"Numeric Data",path:null,source:null,pathType:"number",suppressBootstrapNull:true,isPathConfigurable:true,convertUnitTo:"unitless",showPathSkUnitsFilter:true,pathSkUnitsFilter:null,sampleTime:500}},showMax:false,showMin:false,numDecimal:1,showMiniChart:false,yScaleMin:0,yScaleMax:10,inverseYAxis:false,verticalChart:false,color:"contrast",enableTimeout:false,dataTimeout:5,ignoreZones:false};runtime=w(p);stream=w(rt);canvas=w(R);datasetLifecycle=w(S);miniChart=$j(C);canvasMainRef=$j.required("canvasMainRef");showMiniChart=vt(false);labelColor=vt("");canvasElement;canvasCtx=null;cssWidth=0;cssHeight=0;backgroundBitmap=null;backgroundBitmapText=null;dataValue=null;maxValue=null;minValue=null;valueColor="";valueStateColor="";maxValueTextWidth=0;maxValueTextHeight=0;maxMinMaxTextWidth=0;maxMinMaxTextHeight=0;streamRegistered=false;pathDataState=null;isDestroyed=false;lastSubscriptionSignature=null;normalizedConfig=Dt(()=>this.runtime.options()??n.DEFAULT_CONFIG);numericPathConfig=Dt(()=>this.normalizedConfig().paths?.numericPath);subscriptionSignature=Dt(()=>{this.normalizedConfig();let e=this.numericPathConfig();if(!e?.path)return null;let i=e.source?.trim()||"default";return [e.path,e.pathType,e.sampleTime,e.convertUnitTo,i,e.suppressBootstrapNull?"1":"0"].join("|")});onNumericValue=t=>{if(this.dataValue=t.data.value,this.minValue===null||this.dataValue<this.minValue?this.minValue=this.dataValue:(this.maxValue===null||this.dataValue>this.maxValue)&&(this.maxValue=this.dataValue),!this.normalizedConfig().ignoreZones&&this.pathDataState!==t.state)switch(this.pathDataState=t.state,t.state){case n$1.Alarm:this.valueStateColor=this.theme().zoneAlarm;break;case n$1.Warn:this.valueStateColor=this.theme().zoneWarn;break;case n$1.Alert:this.valueStateColor=this.theme().zoneAlert;break;default:this.valueStateColor=this.valueColor;break}this.drawWidget();};constructor(){this.showMiniChart.set(this.normalizedConfig().showMiniChart??false),Fa(()=>{let t=this.theme(),e=this.normalizedConfig().color;ge(()=>{t&&e!==void 0&&(this.setColors(),this.drawWidget());});}),Fa(()=>{let t=this.subscriptionSignature();ge(()=>{this.isDestroyed||!this.canvasCtx||t===this.lastSubscriptionSignature&&this.streamRegistered||(this.minValue=null,this.maxValue=null,this.dataValue=null,this.pathDataState=null,this.lastSubscriptionSignature=t,t&&(this.stream?.observe("numericPath",this.onNumericValue),this.streamRegistered=true,this.manageDatasetAndChart()));});}),Fa(()=>{let t=this.showMiniChart(),e=this.miniChart(),i=this.normalizedConfig(),s=this.numericPathConfig();[i?.showMiniChart?"1":"0",s?.path??"",s?.source??"default",s?.convertUnitTo??"",i?.numDecimal??"",i?.yScaleMin??"",i?.yScaleMax??"",i?.inverseYAxis?"1":"0",i?.verticalChart?"1":"0",i?.color??""].join("|")&&t&&e&&(this.setMiniChart(),e.startChart());});}ngOnInit(){this.setColors(),this.canvasElement=this.canvasMainRef().nativeElement,this.canvasCtx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(t,e)=>{this.cssWidth=t,this.cssHeight=e,this.calculateMaxMinTextDimensions(),this.drawWidget();}});}ngAfterViewInit(){this.isDestroyed||!this.streamRegistered&&this.subscriptionSignature()&&(this.stream?.observe("numericPath",this.onNumericValue),this.streamRegistered=true,this.manageDatasetAndChart());}calculateMaxMinTextDimensions(){this.maxValueTextWidth=Math.floor(this.cssWidth*.85),this.maxValueTextHeight=Math.floor(this.cssHeight*.7),this.maxMinMaxTextWidth=Math.floor(this.cssWidth*.57),this.maxMinMaxTextHeight=Math.floor(this.cssHeight*.1);}manageDatasetAndChart(){let t=this.normalizedConfig(),e=this.numericPathConfig(),i=!!t.showMiniChart;if(this.showMiniChart.set(i),!i){this.datasetLifecycle.removeDatasetIfExists(this.id(),false);return}if(!e||!e.path)return;let s=e.source??"default";this.datasetLifecycle.syncNumericMiniChartDataset(this.id(),e.path,s);}setMiniChart(){let t=this.miniChart(),e=this.normalizedConfig(),i=this.numericPathConfig();t&&(t.dataPath=i?.path??null,t.dataSource=i?.source??"default",t.color=e.color??"contrast",t.convertUnitTo=i?.convertUnitTo??null,t.numDecimal=e.numDecimal??null,t.yScaleMin=e.yScaleMin??null,t.yScaleMax=e.yScaleMax??null,t.inverseYAxis=e.inverseYAxis??false,t.verticalChart=e.verticalChart??null,t.datasetUUID=this.id());}setColors(){let t=this.normalizedConfig(),e=this.theme(),i=t.color??"contrast";this.labelColor.set(c(i,e).dim),this.valueStateColor=this.valueColor=c(i,e).color,this.backgroundBitmap=null,this.backgroundBitmapText=null;}drawWidget(){if(!this.canvasCtx)return;let t=this.normalizedConfig(),e=this.numericPathConfig()?.convertUnitTo??"",i=10*this.canvas.scaleFactor,s=5*this.canvas.scaleFactor,r=(t.displayName??"")+"|"+e;(!this.backgroundBitmap||this.backgroundBitmap.width!==this.canvasElement.width||this.backgroundBitmap.height!==this.canvasElement.height||this.backgroundBitmapText!==r)&&(this.backgroundBitmap=this.canvas.renderStaticToBitmap(this.canvasCtx,this.cssWidth,this.cssHeight,a=>{this.canvas.drawTitleInternal(a,t.displayName??"",this.labelColor(),"normal",this.cssWidth,this.cssHeight,.1),["unitless","percent","ratio","latitudeSec","latitudeMin","longitudeSec","longitudeMin"].includes(e)||this.canvas.drawText(a,e,this.cssWidth-i,this.cssHeight-s,Math.floor(this.cssWidth*.25),Math.floor(this.cssHeight*.15),"bold",this.valueColor,"end","bottom");}),this.backgroundBitmapText=r),this.canvas.clearCanvas(this.canvasCtx,this.cssWidth,this.cssHeight),this.backgroundBitmap&&this.backgroundBitmap.width>0&&this.backgroundBitmap.height>0&&this.canvasCtx.drawImage(this.backgroundBitmap,0,0,this.cssWidth,this.cssHeight),this.drawValue(),(t.showMax||t.showMin)&&this.drawMinMax();}drawValue(){let t=this.getValueText(),e=this.canvasCtx;e&&this.canvas.drawText(e,t,Math.floor(this.cssWidth/2),Math.floor(this.cssHeight/2*1.15),this.maxValueTextWidth,this.maxValueTextHeight,"bold",this.valueStateColor);}getValueText(){if(this.dataValue===null)return "--";let t=this.normalizedConfig(),e=this.numericPathConfig()?.convertUnitTo??"";return ["latitudeSec","latitudeMin","longitudeSec","longitudeMin","D HH:MM:SS"].includes(e)?this.dataValue.toString():this.applyDecorations(this.dataValue.toFixed(t.numDecimal??1))}drawMinMax(){let t=this.normalizedConfig();if(!t.showMin&&!t.showMax)return;let e=t.numDecimal??1,i="";t.showMin&&(i=this.minValue!=null?` Min: ${this.applyDecorations(this.minValue.toFixed(e))}`:" Min: --"),t.showMax&&(i+=this.maxValue!=null?` Max: ${this.applyDecorations(this.maxValue.toFixed(e))}`:" Max: --"),i=i.trim();let s=10*this.canvas.scaleFactor,r=5*this.canvas.scaleFactor,a=this.canvasCtx;a&&this.canvas.drawText(a,i,s,Math.floor(this.cssHeight-r),this.maxMinMaxTextWidth,this.maxMinMaxTextHeight,"normal",this.valueColor,"start","bottom");}applyDecorations(t){switch(this.numericPathConfig()?.convertUnitTo??""){case "percent":case "percentraw":t+="%";break}return t}ngOnDestroy(){this.isDestroyed=true,this.datasetLifecycle.removeDatasetIfExists(this.id(),false);try{this.canvas.unregisterCanvas(this.canvasElement);}catch(t){}}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=JD({type:n,selectors:[["widget-numeric"]],viewQuery:function(e,i){e&1&&eg(i.miniChart,C,5)(i.canvasMainRef,I,5),e&2&&Kw(2);},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:3,vars:1,consts:[["canvasMainRef",""],[3,"theme"],[1,"numeric-canvas"]],template:function(e,i){e&1&&(_w(0,E,1,1,"minichart",1),$h(1,"canvas",2,0)),e&2&&Mw(i.showMiniChart()?0:-1);},dependencies:[C],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%}.numeric-wrapper[_ngcontent-%COMP%]{width:100%;height:100%;min-height:1px}.numeric-canvas[_ngcontent-%COMP%]{position:relative;width:100%!important;height:100%!important;display:block}"]})}return n})();export{se as WidgetNumericComponent};
@@ -1 +1 @@
1
- import {WidgetFreeboardskComponent as ae}from'./chunk-BdokyhBM.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-BAV5VDOD.js';import'./chunk-D4xZ2tGB.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
+ import {WidgetFreeboardskComponent as ae}from'./chunk-Di5pPpU7.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-BNR44HGB.js';import'./chunk-DVB9tiW3.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-BAV5VDOD.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
+ import {cv as G}from'./main-BNR44HGB.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 {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,D as Dt,$ as $j,v as vt,dx as n$1,F as Fa,dn as ge,a_ as Gp,cv as G,cw as z,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 pe=["solarSvg"];function he(l,e){l&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No solar chargers detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K solar paths or select chargers in widget settings."),ul()());}var te=class l{static SOLAR_DESCRIPTOR=a("widget-solar-charger");static SELF_ROOT_PATH=(()=>{let e=l.SOLAR_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetSolarChargerComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${l.SELF_ROOT_PATH}.*`;id=Hj.required();type=Hj.required();theme=Hj.required();renderMode=Hj(null);static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,solarCharger:{trackedDevices:[],optionsById:{}}};static VIEWBOX_WIDTH=200;static CARD_HEIGHT=100;static CARD_GAP=8;static SOLAR_PANEL_SYMBOL_WIDTH=158.90796;static SOLAR_PANEL_SYMBOL_HEIGHT=94.949027;static SOLAR_PANEL_SCALE=.77;static SOLAR_PANEL_TRANSLATE_X=-36;static SOLAR_PANEL_TRANSLATE_Y=0;static SOLAR_PANEL_X=(135+l.SOLAR_PANEL_TRANSLATE_X)*l.SOLAR_PANEL_SCALE;static SOLAR_PANEL_Y=(0+l.SOLAR_PANEL_TRANSLATE_Y)*l.SOLAR_PANEL_SCALE;static SOLAR_PANEL_WIDTH=l.SOLAR_PANEL_SYMBOL_WIDTH*l.SOLAR_PANEL_SCALE;static SOLAR_PANEL_HEIGHT=l.SOLAR_PANEL_SYMBOL_HEIGHT*l.SOLAR_PANEL_SCALE;static PATH_BATCH_WINDOW_MS=500;runtime=w(p);data=w(De);units=w(ut);destroyRef=w(xe);displayLabel=Dt(()=>{let e=this.visibleSolarUnits();return e.length!==1?"Solar Chargers":this.resolveTitleText(e[0])});labelColor=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e).dim:"var(--kip-contrast-dim-color)"});svgRef=$j.required("solarSvg");svg;layer;glowFilterId="";renderFrameId=null;pendingRenderSnapshot=null;pathBatchTimerId=null;initialPathPaintDone=false;pendingPathUpdates=new Map;discoveredSolarIds=vt([]);trackedDevices=vt([]);optionsById=vt({});cardMode=vt({displayMode:"full",metrics:["panelVoltage","panelCurrent","voltage","current"]});chargersByKey=vt({});visibleSolarKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(a=>a.key);let r=this.chargersByKey(),t=new Set(this.discoveredSolarIds());return Object.keys(r).filter(a=>{let s=r[a];return !!s&&t.has(s.id)}).sort((a,s)=>a.localeCompare(s))});visibleSolarUnits=Dt(()=>{let e=this.visibleSolarKeys(),r=this.chargersByKey();return e.map(t=>r[t]).filter(t=>!!t)});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);widgetColors=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e):null});displayModels=Dt(()=>{let e$1=this.visibleSolarUnits(),r=this.optionsById(),t=this.theme(),a=this.widgetColors(),s=this.ignoreZones()??false,i={};for(let n of e$1){let u=r[n.id]?.arrayRatedPowerW??null,c=n.panelPower??null,g=this.formatPowerAuto(c),m=u&&u>0&&c!=null?Math.max(0,Math.min(1,c/u)):0,d=n.panelPowerState??n.panelCurrentState??null,o=n.currentState??null,p=e(d,a?.dim??"var(--kip-contrast-dim-color)",t,s),T=!s&&(d===n$1.Warn||d===n$1.Alarm||d===n$1.Alert),y=e(o,"var(--kip-contrast-color)",t,s),w=this.resolveMostSevereState(n.voltageState??null,n.temperatureState??null),v=e(w,"var(--kip-contrast-color)",t,s),S=this.resolveMostSevereState(n.panelCurrentState??null,n.panelVoltageState??null,n.panelTemperatureState??null),re=e(S,"var(--kip-contrast-color)",t,s),ae=!s&&(S===n$1.Warn||S===n$1.Alarm||S===n$1.Alert),ne=e(n.loadCurrentState??null,"var(--kip-contrast-color)",t,s),I=this.valueOrDash(n.controllerMode),V=this.isRelayActive(n.load),oe=V?`${this.formatRelayState(n.load)}\xA0\xA0\xA0\xA04.5A${this.formatCurrent(n.loadCurrent)}`.trim():"",se=n.yieldToday!=null?`${this.formatEnergyYield(n.yieldToday)} Today`:"",ie=n.yieldYesterday!=null?`${this.formatEnergyYield(n.yieldYesterday)} Yesterday`:"",le=n.deviceKey??n.id;i[le]={id:n.id,source:n.source??null,deviceKey:n.deviceKey,titleText:this.resolveTitleText(n),panelPowerText:g.value,panelPowerUnitText:g.unit,panelPowerColor:p,panelPowerGlowEnabled:T,chargerCurrentTextColor:y,chargerMetaTextColor:v,panelValuesTextColor:re,panelValuesGlowEnabled:ae,gaugeProgress:m,gaugeSectionText:`${this.formatVoltage(n.panelVoltage)}`+(n.panelCurrent!=null?`, ${this.formatCurrent(n.panelCurrent)}`:"")+(n.panelTemperature!=null?`, ${this.formatTemperature(n.panelTemperature)}`:""),yieldTodayText:se,yieldYesterdayText:ie,chargerSectionCurrent:`${this.formatCurrent(n.current)}`,chargerMode:`${I.charAt(0).toUpperCase()+I.slice(1)} mode`,chargerSectionMetadata:`${n.voltage!=null?this.formatVoltage(n.voltage):""}\xA0\xA0\xA0\xA0${n.temperature!=null?this.formatTemperature(n.temperature):""}`.trim(),relaySectionVisible:V,relaySectionText:oe,relayValuesTextColor:ne};}return i});hasChargers=Dt(()=>this.visibleSolarUnits().length>0);constructor(){Fa(()=>{let r=this.runtime.options();r&&ge(()=>{this.applyConfig(r);});}),Fa(()=>{let r=this.displayModels(),t=this.visibleSolarUnits(),a=this.widgetColors();!this.svg||!a||this.requestRender({solarUnits:t,displayModels:r,widgetColors:a});});let e=this.data.subscribePathTreeWithInitial(l.ROOT_PATTERN);if(e.initial.length){for(let r of e.initial)this.enqueuePathUpdate(r,true);this.flushPendingPathUpdates(),this.initialPathPaintDone=true;}e.live$.pipe(Gp(this.destroyRef)).subscribe(r=>{this.enqueuePathUpdate(r);});}ngAfterViewInit(){this.initializeSvg(),this.requestRender();}ngOnDestroy(){this.pathBatchTimerId!==null&&(clearTimeout(this.pathBatchTimerId),this.pathBatchTimerId=null),this.renderFrameId!==null&&(cancelAnimationFrame(this.renderFrameId),this.renderFrameId=null),this.pendingRenderSnapshot=null;}initializeSvg(){this.svg=ge$1(this.svgRef().nativeElement),this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${l.CARD_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","Solar Charger View"),this.glowFilterId=`solar-panel-glow-${this.id()}`;let r=this.svg.append("defs").append("filter").attr("id",this.glowFilterId).attr("x","-30%").attr("y","-30%").attr("width","160%").attr("height","160%");r.append("feFlood").attr("class","solar-panel-glow-flood").attr("flood-color","var(--kip-widget-card-background-color)").attr("flood-opacity",.9).attr("result","color"),r.append("feComposite").attr("in","color").attr("in2","SourceGraphic").attr("operator","in").attr("result","coloredGlow"),r.append("feGaussianBlur").attr("in","coloredGlow").attr("stdDeviation",2).attr("result","blur");let t=r.append("feMerge");t.append("feMergeNode").attr("in","blur"),t.append("feMergeNode").attr("in","blur"),t.append("feMergeNode").attr("in","SourceGraphic"),this.layer=this.svg.append("g").attr("class","solar-layer");}applyConfig(e){let r=this.resolveSolarConfig(e);this.trackedDevices.set(r.trackedDevices??[]),this.reprojectSnapshotsToDeviceKeys(r.trackedDevices??[]),this.optionsById.set(r.optionsById??{}),this.cardMode.set(this.normalizeCardMode(r.cardMode));}resolveSolarConfig(e){let r=e.solarCharger,t=this.normalizeTrackedDevices(r?.trackedDevices),a=this.normalizeOptionsById(r?.optionsById);return {trackedDevices:t,optionsById:a,cardMode:this.normalizeCardMode(r?.cardMode)}}normalizeTrackedDevices(e){if(!Array.isArray(e))return [];let r=new Map;return e.forEach(t=>{if(typeof t=="string"){let u=t.trim();if(!u)return;let c=`${u}||default`;r.set(c,{id:u,source:"default",key:c});return}if(!t||typeof t!="object")return;let a=t,s=typeof a.id=="string"?a.id.trim():"",i=typeof a.source=="string"?a.source.trim():"default";if(!s||!i)return;let n=typeof a.key=="string"&&a.key.trim().length>0?a.key.trim():`${s}||${i}`;r.set(n,{id:s,source:i,key:n});}),[...r.values()].sort((t,a)=>t.key.localeCompare(a.key))}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let r=new Map;e.forEach(t=>{let a=r.get(t.id)??[];a.push(t.key),r.set(t.id,a);}),this.chargersByKey.update(t=>{let a=t,s=false;return r.forEach((i,n)=>{let u=t[n];if(u){for(let c of i){if(t[c])continue;let g=e.find(m=>m.key===c);s||(a=G({},t),s=true),a[c]=z(G({},u),{source:g?.source??null,deviceKey:c});}s&&a[n]?.deviceKey===void 0&&delete a[n];}}),s?a:t});}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:["panelVoltage","panelCurrent","voltage","current"]}}normalizeStringList(e){if(!Array.isArray(e))return [];let r=new Set;return e.forEach(t=>{if(typeof t!="string")return;let a=t.trim();a.length>0&&r.add(a);}),[...r].sort((t,a)=>t.localeCompare(a))}normalizeOptionsById(e){if(!e||typeof e!="object")return {};let r=Object.entries(e),t={};return r.forEach(([a,s])=>{let i=this.normalizeOptionalString(a);if(!i)return;let n=s?.arrayRatedPowerW;t[i]={arrayRatedPowerW:typeof n=="number"&&Number.isFinite(n)?n:null};}),t}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.parseSolarPath(e.path);if(!t)return;let{id:a,key:s}=t,i=e.update?.data?.value??null,n=e.update?.state??null,u=`${a}::${s}`;if(this.pendingPathUpdates.set(u,{id:a,key:s,value:i,state:n}),!r){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=window.setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},l.PATH_BATCH_WINDOW_MS));}}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let e=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(e.map(t=>t.id)).forEach(t=>this.trackDiscoveredSolar(t)),this.chargersByKey.update(t=>{let a=t,s=false,i=this.trackedDevices(),n=i.length>0,u=new Map;n&&i.forEach(c=>{let g=u.get(c.id)??[];g.push(c.key),u.set(c.id,g);});for(let c of e){let g=n?u.get(c.id)??[]:[c.id];for(let m of g){let d=i.find(S=>S.key===m),o=a[m]??{id:c.id,source:d?.source??null,deviceKey:n?m:void 0},p=G({},o),T=this.applyChargerValue(p,c.key,c.value,c.state),y=false,w=this.resolvePowerValue(p.rawBatteryPower,p.voltage,p.current);Object.is(p.power,w)||(p.power=w,y=true);let v=this.resolvePowerValue(p.rawPanelPower,p.panelVoltage,p.panelCurrent);Object.is(p.panelPower,v)||(p.panelPower=v,y=true),!(!T&&!y)&&(s||(a=G({},a),s=true),a[m]=p);}}return s?a:t});}parseSolarPath(e){let r=e.match(/self\.electrical\.solar\.([^.]+)\.(.+)$/);if(!r)return null;let t=r[1],a=r[2],s=this.normalizeSolarMetricKey(a);return {id:t,key:s}}normalizeSolarMetricKey(e){if(e.startsWith("controller."))return e.slice(11);switch(e){case "solar.power":return "panelPower";case "solar.voltage":return "panelVoltage";case "solar.current":return "panelCurrent";case "solar.temperature":return "panelTemperature";case "charge.status":return "controllerMode";default:return e}}trackDiscoveredSolar(e){let r=this.discoveredSolarIds();r.includes(e)||this.discoveredSolarIds.set([...r,e].sort());}applyChargerValue(e,r,t,a){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 "voltage":{let s=this.toNumber(t,"V"),i=!Object.is(e.voltageState??null,a??null);return Object.is(e.voltage,s)&&!i?false:(e.voltage=s,e.voltageState=a,true)}case "current":{let s=this.toNumber(t,"A"),i=!Object.is(e.currentState??null,a??null);return Object.is(e.current,s)&&!i?false:(e.current=s,e.currentState=a,true)}case "power":return this.setPowerPathValue(e,"rawBatteryPower",t);case "temperature":{let s=this.toNumber(t,this.units.getDefaults().Temperature),i=!Object.is(e.temperatureState??null,a??null);return Object.is(e.temperature,s)&&!i?false:(e.temperature=s,e.temperatureState=a,true)}case "chargingAlgorithm":return this.setValue(e,"chargingAlgorithm",this.toStringValue(t));case "chargerRole":return this.setValue(e,"chargerRole",this.toStringValue(t));case "chargingMode":return this.setValue(e,"chargingMode",this.toStringValue(t));case "setpointVoltage":return this.setValue(e,"setpointVoltage",this.toNumber(t,"V"));case "setpointCurrent":return this.setValue(e,"setpointCurrent",this.toNumber(t,"A"));case "controllerMode":return this.setValue(e,"controllerMode",this.toStringValue(t));case "panelVoltage":{let s=this.toNumber(t,"V"),i=!Object.is(e.panelVoltageState??null,a??null);return Object.is(e.panelVoltage,s)&&!i?false:(e.panelVoltage=s,e.panelVoltageState=a,true)}case "panelCurrent":{let s=this.toNumber(t,"A"),i=!Object.is(e.panelCurrentState??null,a??null);return Object.is(e.panelCurrent,s)&&!i?false:(e.panelCurrent=s,e.panelCurrentState=a,true)}case "panelPower":{let s=this.toNumber(t,"W"),i=!Object.is(e.panelPowerState??null,a??null);return Object.is(e.rawPanelPower,s)&&!i?false:(e.rawPanelPower=s,e.panelPowerState=a,true)}case "yieldToday":return this.setValue(e,"yieldToday",this.toNumber(t,"kWh"));case "yieldYesterday":return this.setValue(e,"yieldYesterday",this.toNumber(t,"kWh"));case "panelTemperature":{let s=this.toNumber(t,this.units.getDefaults().Temperature),i=!Object.is(e.panelTemperatureState??null,a??null);return Object.is(e.panelTemperature,s)&&!i?false:(e.panelTemperature=s,e.panelTemperatureState=a,true)}case "load":case "loadState":case "load.state":return this.setValue(e,"load",t);case "loadCurrent":{let s=this.toNumber(t,"A"),i=!Object.is(e.loadCurrentState??null,a??null);return Object.is(e.loadCurrent,s)&&!i?false:(e.loadCurrent=s,e.loadCurrentState=a,true)}default:return false}}setPowerPathValue(e,r,t){let a=this.toNumber(t,"W");return this.setValue(e,r,a)}setValue(e,r,t){return Object.is(e[r],t)?false:(e[r]=t,true)}resolvePowerValue(e,r,t){if(e!=null)return e;if(r!=null&&t!=null)return r*t}requestRender(e){this.svg&&(this.pendingRenderSnapshot=e??this.buildRenderSnapshot(),this.pendingRenderSnapshot&&this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;let r=this.pendingRenderSnapshot;this.pendingRenderSnapshot=null,r&&this.render(r);})));}buildRenderSnapshot(){let e=this.widgetColors();return e?{solarUnits:this.visibleSolarUnits(),displayModels:this.displayModels(),widgetColors:e}:null}render(e){if(!this.layer||!this.svg)return;let t=this.isCompactCardMode()?e$1:e$1,a=e.solarUnits.map((o,p)=>({key:o.deviceKey??o.id,model:e.displayModels[o.deviceKey??o.id],y:p*(l.CARD_HEIGHT+l.CARD_GAP)})),s=a.length?a[a.length-1].y+l.CARD_HEIGHT:l.CARD_HEIGHT;this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${s}`);let i=this.layer.selectAll("g.solar-card").data(a,o=>o.key),n=i.enter().append("g").attr("class","solar-card");n.append("text").attr("class","solar-charger-title");let u=n.append("text").attr("class","solar-charger-current");u.append("tspan").attr("class","current-metric-value"),u.append("tspan").attr("class","current-metric-unit"),n.append("text").attr("class","solar-charger"),n.append("text").attr("class","solar-charger-meta"),n.append("text").attr("class","solar-relay-label"),n.append("text").attr("class","solar-relay-values"),n.append("text").attr("class","solar-panel-values"),n.append("text").attr("class","solar-yield-label"),n.append("text").attr("class","solar-yield-today"),n.append("text").attr("class","solar-yield-yesterday");let c=n.append("g").attr("class","solar-panel-icon").attr("transform",`translate(${l.SOLAR_PANEL_X}, ${l.SOLAR_PANEL_Y})`);c.append("use").attr("class","solar-panel-bg").attr("href","assets/svg/symbols.svg#solar-panel-cells").attr("x",0).attr("y",0).attr("width",l.SOLAR_PANEL_WIDTH).attr("height",l.SOLAR_PANEL_HEIGHT);let g=c.append("g").attr("class","solar-panel-progress");g.append("defs").append("clipPath").attr("clipPathUnits","objectBoundingBox").attr("id",o=>`solar-panel-clip-${this.id()}-${o.key}`).append("rect").attr("x",0).attr("y",0).attr("height",1).attr("width",0),g.append("use").attr("class","solar-panel-colored").attr("href","assets/svg/symbols.svg#solar-panel-cells").attr("x",0).attr("y",0).attr("width",l.SOLAR_PANEL_WIDTH).attr("height",l.SOLAR_PANEL_HEIGHT).attr("clip-path",o=>`url(#solar-panel-clip-${this.id()}-${o.key})`);let m=n.append("text").attr("class","solar-panel-power");m.append("tspan").attr("class","solar-panel-power-value"),m.append("tspan").attr("class","solar-panel-power-unit");let d=n.merge(i);d.attr("transform",o=>`translate(0, ${o.y})`),e.solarUnits.length>1?d.select("text.solar-charger-title").attr("x",t.titleX).attr("y",t.titleY).attr("font-size",t.titleFontSize).attr("fill","var(--kip-contrast-dim-color)").text(o=>e.displayModels[o.key]?.titleText??this.displayName(o.model)):d.select("text.solar-charger-title").text(""),d.select("text.solar-charger-current").attr("x",t.lineOneX).attr("y",t.lineOneY).attr("font-size",t.lineOneFontSize).attr("fill",o=>o.model.chargerCurrentTextColor),d.select("tspan.current-metric-value").text(o=>o.model.chargerSectionCurrent),d.select("tspan.current-metric-unit").attr("dx",1).attr("font-size",12).attr("fill","var(--kip-contrast-color)").text("A"),d.select("text.solar-charger").attr("x",5).attr("y",40).attr("fill","var(--kip-contrast-color)").attr("font-size",8).attr("opacity",.8).text(o=>o.model.chargerMode),d.select("text.solar-charger-meta").attr("x",t.metaLeftX).attr("y",48).attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",o=>o.model.chargerMetaTextColor).text(o=>o.model.chargerSectionMetadata),d.select("text.solar-relay-label").attr("x",5).attr("y",73).attr("font-size",10).attr("fill","var(--kip-contrast-color)").text(o=>o.model.relaySectionVisible?"Load Output":""),d.select("text.solar-relay-values").attr("x",10).attr("y",83).attr("font-size",t.lineTwoFontSize).attr("fill",o=>o.model.relayValuesTextColor).attr("opacity",o=>o.model.relaySectionVisible?.8:0).text(o=>o.model.relaySectionText),d.select("g.solar-panel-icon").attr("transform",`translate(${l.SOLAR_PANEL_X}, ${l.SOLAR_PANEL_Y})`),d.select("use.solar-panel-bg").attr("color","var(--kip-contrast-dimmer-color)"),d.select("g.solar-panel-progress").each((o,p,T)=>{ge$1(T[p]).select("rect").attr("x",0).attr("y",0).attr("height",1).attr("width",Math.max(0,Math.min(1,o.model.gaugeProgress))),this.debugSolarLayout(o.key,o.model.gaugeProgress);}),d.select("use.solar-panel-colored").attr("color",o=>o.model.panelPowerColor),d.select("text.solar-panel-power").attr("x",137.5).attr("y",t.primaryY).attr("text-anchor","middle").attr("font-size",t.primaryFontSize).attr("font-weight",t.primaryFontWeight).attr("filter",o=>o.model.panelPowerGlowEnabled?`url(#${this.glowFilterId})`:null).attr("fill","var(--kip-contrast-color)"),d.select("tspan.solar-panel-power-value").text(o=>o.model.panelPowerText),d.select("tspan.solar-panel-power-unit").attr("dx",o=>o.model.panelPowerUnitText?1:0).attr("font-size",20).attr("font-weight",500).attr("fill","var(--kip-contrast-color)").attr("opacity",o=>o.model.panelPowerUnitText?1:0).text(o=>o.model.panelPowerUnitText),d.select("text.solar-panel-values").attr("x",137.5).attr("y",60).attr("text-anchor","middle").attr("font-size",10).attr("font-weight",500).attr("opacity",.8).attr("filter",o=>o.model.panelValuesGlowEnabled?`url(#${this.glowFilterId})`:null).attr("fill",o=>o.model.panelValuesTextColor).text(o=>o.model.gaugeSectionText).raise(),d.select("text.solar-yield-label").attr("x",104).attr("y",88).attr("text-anchor","middle").attr("font-size",8).attr("fill","var(--kip-contrast-dim-color)").attr("opacity",.8).text("Yield (kWh):"),d.select("text.solar-yield-today").attr("x",130).attr("y",88).attr("text-anchor","start").attr("font-size",8).attr("fill","var(--kip-contrast-dim-color)").attr("opacity",.8).text(o=>o.model.yieldTodayText),d.select("text.solar-yield-yesterday").attr("x",130).attr("y",97.5).attr("text-anchor","start").attr("font-size",8).attr("fill","var(--kip-contrast-dim-color)").attr("opacity",.8).text(o=>o.model.yieldYesterdayText),i.exit().remove();}displayName(e){return e.name?.trim()||e.id}resolveTitleText(e){return e.name||`Solar ${e.id}`}toNumber(e,r){return e==null||typeof e!="number"?null:this.units.convertToUnit(r,e)??e}isRelayActive(e){if(e==null)return false;if(typeof e=="boolean")return e;if(typeof e=="number")return e>0;let r=e.trim().toLowerCase();return !(!r||r==="off"||r==="false"||r==="0")}toStringValue(e){return typeof e=="string"?e:e==null?null:`${e}`}valueOrDash(e){return e===null?"--":e===void 0?"":e}formatVoltage(e){return e===null?"--":e===void 0?"":`${e.toFixed(1)}V`}formatCurrent(e){return e===null?"--":e===void 0?"":`${e.toFixed(1)}`}formatTemperature(e){return e===null?"--":e===void 0?"":`${e.toFixed(1)} ${this.units.getDefaults().Temperature==="celsius"?"\xB0C":"\xB0F"}`}formatRelayState(e){return e===null?"--":e===void 0?"":typeof e=="boolean"?e?"On":"Off":typeof e=="number"?e>0?"On":"Off":e}formatPowerAuto(e){return e===null?{value:"--",unit:""}:e===void 0?{value:"",unit:""}:Math.abs(e)>=1e3?{value:(e/1e3).toFixed(2),unit:"kW"}:{value:e.toFixed(0),unit:"W"}}formatEnergyYield(e){return e===null?"--":e===void 0?"":`${e.toFixed(2)}`}resolveMostSevereState(...e){let r=null,t={[n$1.Normal]:0,[n$1.Nominal]:1,[n$1.Alert]:2,[n$1.Warn]:3,[n$1.Alarm]:4,[n$1.Emergency]:5};for(let a of e)a&&(!r||t[a]>t[r])&&(r=a);return r}debugSolarLayout(e,r){typeof window<"u"&&window.__KIP_DEBUG_SOLAR_LAYOUT===true&&console.debug("[solar-layout]",{id:e,gaugeProgress:r,panelX:l.SOLAR_PANEL_X,panelY:l.SOLAR_PANEL_Y,panelWidth:l.SOLAR_PANEL_WIDTH,panelHeight:l.SOLAR_PANEL_HEIGHT,clippedWidth:l.SOLAR_PANEL_WIDTH*r});}static \u0275fac=function(r){return new(r||l)};static \u0275cmp=JD({type:l,selectors:[["widget-solar-charger"]],viewQuery:function(r,t){r&1&&eg(t.svgRef,pe,5),r&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["solarSvg",""],[3,"text","color"],["aria-hidden","false",1,"solar-svg"],[1,"solar-empty"],[1,"solar-empty-title"],[1,"solar-empty-sub"]],template:function(r,t){r&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,he,5,0,"div",3)),r&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasChargers()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.solar-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}.solar-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)}.solar-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.solar-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{te as WidgetSolarChargerComponent};
1
+ import {e as e$1}from'./chunk-CyURmwWh.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,D as Dt,$ as $j,v as vt,dx as n$1,F as Fa,dn as ge,a_ as Gp,cv as G,cw as z,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-BNR44HGB.js';import {c,e}from'./chunk-D_wrJJxl.js';var pe=["solarSvg"];function he(l,e){l&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No solar chargers detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K solar paths or select chargers in widget settings."),ul()());}var te=class l{static SOLAR_DESCRIPTOR=a("widget-solar-charger");static SELF_ROOT_PATH=(()=>{let e=l.SOLAR_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetSolarChargerComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${l.SELF_ROOT_PATH}.*`;id=Hj.required();type=Hj.required();theme=Hj.required();renderMode=Hj(null);static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,solarCharger:{trackedDevices:[],optionsById:{}}};static VIEWBOX_WIDTH=200;static CARD_HEIGHT=100;static CARD_GAP=8;static SOLAR_PANEL_SYMBOL_WIDTH=158.90796;static SOLAR_PANEL_SYMBOL_HEIGHT=94.949027;static SOLAR_PANEL_SCALE=.77;static SOLAR_PANEL_TRANSLATE_X=-36;static SOLAR_PANEL_TRANSLATE_Y=0;static SOLAR_PANEL_X=(135+l.SOLAR_PANEL_TRANSLATE_X)*l.SOLAR_PANEL_SCALE;static SOLAR_PANEL_Y=(0+l.SOLAR_PANEL_TRANSLATE_Y)*l.SOLAR_PANEL_SCALE;static SOLAR_PANEL_WIDTH=l.SOLAR_PANEL_SYMBOL_WIDTH*l.SOLAR_PANEL_SCALE;static SOLAR_PANEL_HEIGHT=l.SOLAR_PANEL_SYMBOL_HEIGHT*l.SOLAR_PANEL_SCALE;static PATH_BATCH_WINDOW_MS=500;runtime=w(p);data=w(De);units=w(ut);destroyRef=w(xe);displayLabel=Dt(()=>{let e=this.visibleSolarUnits();return e.length!==1?"Solar Chargers":this.resolveTitleText(e[0])});labelColor=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e).dim:"var(--kip-contrast-dim-color)"});svgRef=$j.required("solarSvg");svg;layer;glowFilterId="";renderFrameId=null;pendingRenderSnapshot=null;pathBatchTimerId=null;initialPathPaintDone=false;pendingPathUpdates=new Map;discoveredSolarIds=vt([]);trackedDevices=vt([]);optionsById=vt({});cardMode=vt({displayMode:"full",metrics:["panelVoltage","panelCurrent","voltage","current"]});chargersByKey=vt({});visibleSolarKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(a=>a.key);let r=this.chargersByKey(),t=new Set(this.discoveredSolarIds());return Object.keys(r).filter(a=>{let s=r[a];return !!s&&t.has(s.id)}).sort((a,s)=>a.localeCompare(s))});visibleSolarUnits=Dt(()=>{let e=this.visibleSolarKeys(),r=this.chargersByKey();return e.map(t=>r[t]).filter(t=>!!t)});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);widgetColors=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e):null});displayModels=Dt(()=>{let e$1=this.visibleSolarUnits(),r=this.optionsById(),t=this.theme(),a=this.widgetColors(),s=this.ignoreZones()??false,i={};for(let n of e$1){let u=r[n.id]?.arrayRatedPowerW??null,c=n.panelPower??null,g=this.formatPowerAuto(c),m=u&&u>0&&c!=null?Math.max(0,Math.min(1,c/u)):0,d=n.panelPowerState??n.panelCurrentState??null,o=n.currentState??null,p=e(d,a?.dim??"var(--kip-contrast-dim-color)",t,s),T=!s&&(d===n$1.Warn||d===n$1.Alarm||d===n$1.Alert),y=e(o,"var(--kip-contrast-color)",t,s),w=this.resolveMostSevereState(n.voltageState??null,n.temperatureState??null),v=e(w,"var(--kip-contrast-color)",t,s),S=this.resolveMostSevereState(n.panelCurrentState??null,n.panelVoltageState??null,n.panelTemperatureState??null),re=e(S,"var(--kip-contrast-color)",t,s),ae=!s&&(S===n$1.Warn||S===n$1.Alarm||S===n$1.Alert),ne=e(n.loadCurrentState??null,"var(--kip-contrast-color)",t,s),I=this.valueOrDash(n.controllerMode),V=this.isRelayActive(n.load),oe=V?`${this.formatRelayState(n.load)}\xA0\xA0\xA0\xA04.5A${this.formatCurrent(n.loadCurrent)}`.trim():"",se=n.yieldToday!=null?`${this.formatEnergyYield(n.yieldToday)} Today`:"",ie=n.yieldYesterday!=null?`${this.formatEnergyYield(n.yieldYesterday)} Yesterday`:"",le=n.deviceKey??n.id;i[le]={id:n.id,source:n.source??null,deviceKey:n.deviceKey,titleText:this.resolveTitleText(n),panelPowerText:g.value,panelPowerUnitText:g.unit,panelPowerColor:p,panelPowerGlowEnabled:T,chargerCurrentTextColor:y,chargerMetaTextColor:v,panelValuesTextColor:re,panelValuesGlowEnabled:ae,gaugeProgress:m,gaugeSectionText:`${this.formatVoltage(n.panelVoltage)}`+(n.panelCurrent!=null?`, ${this.formatCurrent(n.panelCurrent)}`:"")+(n.panelTemperature!=null?`, ${this.formatTemperature(n.panelTemperature)}`:""),yieldTodayText:se,yieldYesterdayText:ie,chargerSectionCurrent:`${this.formatCurrent(n.current)}`,chargerMode:`${I.charAt(0).toUpperCase()+I.slice(1)} mode`,chargerSectionMetadata:`${n.voltage!=null?this.formatVoltage(n.voltage):""}\xA0\xA0\xA0\xA0${n.temperature!=null?this.formatTemperature(n.temperature):""}`.trim(),relaySectionVisible:V,relaySectionText:oe,relayValuesTextColor:ne};}return i});hasChargers=Dt(()=>this.visibleSolarUnits().length>0);constructor(){Fa(()=>{let r=this.runtime.options();r&&ge(()=>{this.applyConfig(r);});}),Fa(()=>{let r=this.displayModels(),t=this.visibleSolarUnits(),a=this.widgetColors();!this.svg||!a||this.requestRender({solarUnits:t,displayModels:r,widgetColors:a});});let e=this.data.subscribePathTreeWithInitial(l.ROOT_PATTERN);if(e.initial.length){for(let r of e.initial)this.enqueuePathUpdate(r,true);this.flushPendingPathUpdates(),this.initialPathPaintDone=true;}e.live$.pipe(Gp(this.destroyRef)).subscribe(r=>{this.enqueuePathUpdate(r);});}ngAfterViewInit(){this.initializeSvg(),this.requestRender();}ngOnDestroy(){this.pathBatchTimerId!==null&&(clearTimeout(this.pathBatchTimerId),this.pathBatchTimerId=null),this.renderFrameId!==null&&(cancelAnimationFrame(this.renderFrameId),this.renderFrameId=null),this.pendingRenderSnapshot=null;}initializeSvg(){this.svg=ge$1(this.svgRef().nativeElement),this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${l.CARD_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","Solar Charger View"),this.glowFilterId=`solar-panel-glow-${this.id()}`;let r=this.svg.append("defs").append("filter").attr("id",this.glowFilterId).attr("x","-30%").attr("y","-30%").attr("width","160%").attr("height","160%");r.append("feFlood").attr("class","solar-panel-glow-flood").attr("flood-color","var(--kip-widget-card-background-color)").attr("flood-opacity",.9).attr("result","color"),r.append("feComposite").attr("in","color").attr("in2","SourceGraphic").attr("operator","in").attr("result","coloredGlow"),r.append("feGaussianBlur").attr("in","coloredGlow").attr("stdDeviation",2).attr("result","blur");let t=r.append("feMerge");t.append("feMergeNode").attr("in","blur"),t.append("feMergeNode").attr("in","blur"),t.append("feMergeNode").attr("in","SourceGraphic"),this.layer=this.svg.append("g").attr("class","solar-layer");}applyConfig(e){let r=this.resolveSolarConfig(e);this.trackedDevices.set(r.trackedDevices??[]),this.reprojectSnapshotsToDeviceKeys(r.trackedDevices??[]),this.optionsById.set(r.optionsById??{}),this.cardMode.set(this.normalizeCardMode(r.cardMode));}resolveSolarConfig(e){let r=e.solarCharger,t=this.normalizeTrackedDevices(r?.trackedDevices),a=this.normalizeOptionsById(r?.optionsById);return {trackedDevices:t,optionsById:a,cardMode:this.normalizeCardMode(r?.cardMode)}}normalizeTrackedDevices(e){if(!Array.isArray(e))return [];let r=new Map;return e.forEach(t=>{if(typeof t=="string"){let u=t.trim();if(!u)return;let c=`${u}||default`;r.set(c,{id:u,source:"default",key:c});return}if(!t||typeof t!="object")return;let a=t,s=typeof a.id=="string"?a.id.trim():"",i=typeof a.source=="string"?a.source.trim():"default";if(!s||!i)return;let n=typeof a.key=="string"&&a.key.trim().length>0?a.key.trim():`${s}||${i}`;r.set(n,{id:s,source:i,key:n});}),[...r.values()].sort((t,a)=>t.key.localeCompare(a.key))}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let r=new Map;e.forEach(t=>{let a=r.get(t.id)??[];a.push(t.key),r.set(t.id,a);}),this.chargersByKey.update(t=>{let a=t,s=false;return r.forEach((i,n)=>{let u=t[n];if(u){for(let c of i){if(t[c])continue;let g=e.find(m=>m.key===c);s||(a=G({},t),s=true),a[c]=z(G({},u),{source:g?.source??null,deviceKey:c});}s&&a[n]?.deviceKey===void 0&&delete a[n];}}),s?a:t});}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:["panelVoltage","panelCurrent","voltage","current"]}}normalizeStringList(e){if(!Array.isArray(e))return [];let r=new Set;return e.forEach(t=>{if(typeof t!="string")return;let a=t.trim();a.length>0&&r.add(a);}),[...r].sort((t,a)=>t.localeCompare(a))}normalizeOptionsById(e){if(!e||typeof e!="object")return {};let r=Object.entries(e),t={};return r.forEach(([a,s])=>{let i=this.normalizeOptionalString(a);if(!i)return;let n=s?.arrayRatedPowerW;t[i]={arrayRatedPowerW:typeof n=="number"&&Number.isFinite(n)?n:null};}),t}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.parseSolarPath(e.path);if(!t)return;let{id:a,key:s}=t,i=e.update?.data?.value??null,n=e.update?.state??null,u=`${a}::${s}`;if(this.pendingPathUpdates.set(u,{id:a,key:s,value:i,state:n}),!r){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=window.setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},l.PATH_BATCH_WINDOW_MS));}}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let e=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(e.map(t=>t.id)).forEach(t=>this.trackDiscoveredSolar(t)),this.chargersByKey.update(t=>{let a=t,s=false,i=this.trackedDevices(),n=i.length>0,u=new Map;n&&i.forEach(c=>{let g=u.get(c.id)??[];g.push(c.key),u.set(c.id,g);});for(let c of e){let g=n?u.get(c.id)??[]:[c.id];for(let m of g){let d=i.find(S=>S.key===m),o=a[m]??{id:c.id,source:d?.source??null,deviceKey:n?m:void 0},p=G({},o),T=this.applyChargerValue(p,c.key,c.value,c.state),y=false,w=this.resolvePowerValue(p.rawBatteryPower,p.voltage,p.current);Object.is(p.power,w)||(p.power=w,y=true);let v=this.resolvePowerValue(p.rawPanelPower,p.panelVoltage,p.panelCurrent);Object.is(p.panelPower,v)||(p.panelPower=v,y=true),!(!T&&!y)&&(s||(a=G({},a),s=true),a[m]=p);}}return s?a:t});}parseSolarPath(e){let r=e.match(/self\.electrical\.solar\.([^.]+)\.(.+)$/);if(!r)return null;let t=r[1],a=r[2],s=this.normalizeSolarMetricKey(a);return {id:t,key:s}}normalizeSolarMetricKey(e){if(e.startsWith("controller."))return e.slice(11);switch(e){case "solar.power":return "panelPower";case "solar.voltage":return "panelVoltage";case "solar.current":return "panelCurrent";case "solar.temperature":return "panelTemperature";case "charge.status":return "controllerMode";default:return e}}trackDiscoveredSolar(e){let r=this.discoveredSolarIds();r.includes(e)||this.discoveredSolarIds.set([...r,e].sort());}applyChargerValue(e,r,t,a){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 "voltage":{let s=this.toNumber(t,"V"),i=!Object.is(e.voltageState??null,a??null);return Object.is(e.voltage,s)&&!i?false:(e.voltage=s,e.voltageState=a,true)}case "current":{let s=this.toNumber(t,"A"),i=!Object.is(e.currentState??null,a??null);return Object.is(e.current,s)&&!i?false:(e.current=s,e.currentState=a,true)}case "power":return this.setPowerPathValue(e,"rawBatteryPower",t);case "temperature":{let s=this.toNumber(t,this.units.getDefaults().Temperature),i=!Object.is(e.temperatureState??null,a??null);return Object.is(e.temperature,s)&&!i?false:(e.temperature=s,e.temperatureState=a,true)}case "chargingAlgorithm":return this.setValue(e,"chargingAlgorithm",this.toStringValue(t));case "chargerRole":return this.setValue(e,"chargerRole",this.toStringValue(t));case "chargingMode":return this.setValue(e,"chargingMode",this.toStringValue(t));case "setpointVoltage":return this.setValue(e,"setpointVoltage",this.toNumber(t,"V"));case "setpointCurrent":return this.setValue(e,"setpointCurrent",this.toNumber(t,"A"));case "controllerMode":return this.setValue(e,"controllerMode",this.toStringValue(t));case "panelVoltage":{let s=this.toNumber(t,"V"),i=!Object.is(e.panelVoltageState??null,a??null);return Object.is(e.panelVoltage,s)&&!i?false:(e.panelVoltage=s,e.panelVoltageState=a,true)}case "panelCurrent":{let s=this.toNumber(t,"A"),i=!Object.is(e.panelCurrentState??null,a??null);return Object.is(e.panelCurrent,s)&&!i?false:(e.panelCurrent=s,e.panelCurrentState=a,true)}case "panelPower":{let s=this.toNumber(t,"W"),i=!Object.is(e.panelPowerState??null,a??null);return Object.is(e.rawPanelPower,s)&&!i?false:(e.rawPanelPower=s,e.panelPowerState=a,true)}case "yieldToday":return this.setValue(e,"yieldToday",this.toNumber(t,"kWh"));case "yieldYesterday":return this.setValue(e,"yieldYesterday",this.toNumber(t,"kWh"));case "panelTemperature":{let s=this.toNumber(t,this.units.getDefaults().Temperature),i=!Object.is(e.panelTemperatureState??null,a??null);return Object.is(e.panelTemperature,s)&&!i?false:(e.panelTemperature=s,e.panelTemperatureState=a,true)}case "load":case "loadState":case "load.state":return this.setValue(e,"load",t);case "loadCurrent":{let s=this.toNumber(t,"A"),i=!Object.is(e.loadCurrentState??null,a??null);return Object.is(e.loadCurrent,s)&&!i?false:(e.loadCurrent=s,e.loadCurrentState=a,true)}default:return false}}setPowerPathValue(e,r,t){let a=this.toNumber(t,"W");return this.setValue(e,r,a)}setValue(e,r,t){return Object.is(e[r],t)?false:(e[r]=t,true)}resolvePowerValue(e,r,t){if(e!=null)return e;if(r!=null&&t!=null)return r*t}requestRender(e){this.svg&&(this.pendingRenderSnapshot=e??this.buildRenderSnapshot(),this.pendingRenderSnapshot&&this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;let r=this.pendingRenderSnapshot;this.pendingRenderSnapshot=null,r&&this.render(r);})));}buildRenderSnapshot(){let e=this.widgetColors();return e?{solarUnits:this.visibleSolarUnits(),displayModels:this.displayModels(),widgetColors:e}:null}render(e){if(!this.layer||!this.svg)return;let t=this.isCompactCardMode()?e$1:e$1,a=e.solarUnits.map((o,p)=>({key:o.deviceKey??o.id,model:e.displayModels[o.deviceKey??o.id],y:p*(l.CARD_HEIGHT+l.CARD_GAP)})),s=a.length?a[a.length-1].y+l.CARD_HEIGHT:l.CARD_HEIGHT;this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${s}`);let i=this.layer.selectAll("g.solar-card").data(a,o=>o.key),n=i.enter().append("g").attr("class","solar-card");n.append("text").attr("class","solar-charger-title");let u=n.append("text").attr("class","solar-charger-current");u.append("tspan").attr("class","current-metric-value"),u.append("tspan").attr("class","current-metric-unit"),n.append("text").attr("class","solar-charger"),n.append("text").attr("class","solar-charger-meta"),n.append("text").attr("class","solar-relay-label"),n.append("text").attr("class","solar-relay-values"),n.append("text").attr("class","solar-panel-values"),n.append("text").attr("class","solar-yield-label"),n.append("text").attr("class","solar-yield-today"),n.append("text").attr("class","solar-yield-yesterday");let c=n.append("g").attr("class","solar-panel-icon").attr("transform",`translate(${l.SOLAR_PANEL_X}, ${l.SOLAR_PANEL_Y})`);c.append("use").attr("class","solar-panel-bg").attr("href","assets/svg/symbols.svg#solar-panel-cells").attr("x",0).attr("y",0).attr("width",l.SOLAR_PANEL_WIDTH).attr("height",l.SOLAR_PANEL_HEIGHT);let g=c.append("g").attr("class","solar-panel-progress");g.append("defs").append("clipPath").attr("clipPathUnits","objectBoundingBox").attr("id",o=>`solar-panel-clip-${this.id()}-${o.key}`).append("rect").attr("x",0).attr("y",0).attr("height",1).attr("width",0),g.append("use").attr("class","solar-panel-colored").attr("href","assets/svg/symbols.svg#solar-panel-cells").attr("x",0).attr("y",0).attr("width",l.SOLAR_PANEL_WIDTH).attr("height",l.SOLAR_PANEL_HEIGHT).attr("clip-path",o=>`url(#solar-panel-clip-${this.id()}-${o.key})`);let m=n.append("text").attr("class","solar-panel-power");m.append("tspan").attr("class","solar-panel-power-value"),m.append("tspan").attr("class","solar-panel-power-unit");let d=n.merge(i);d.attr("transform",o=>`translate(0, ${o.y})`),e.solarUnits.length>1?d.select("text.solar-charger-title").attr("x",t.titleX).attr("y",t.titleY).attr("font-size",t.titleFontSize).attr("fill","var(--kip-contrast-dim-color)").text(o=>e.displayModels[o.key]?.titleText??this.displayName(o.model)):d.select("text.solar-charger-title").text(""),d.select("text.solar-charger-current").attr("x",t.lineOneX).attr("y",t.lineOneY).attr("font-size",t.lineOneFontSize).attr("fill",o=>o.model.chargerCurrentTextColor),d.select("tspan.current-metric-value").text(o=>o.model.chargerSectionCurrent),d.select("tspan.current-metric-unit").attr("dx",1).attr("font-size",12).attr("fill","var(--kip-contrast-color)").text("A"),d.select("text.solar-charger").attr("x",5).attr("y",40).attr("fill","var(--kip-contrast-color)").attr("font-size",8).attr("opacity",.8).text(o=>o.model.chargerMode),d.select("text.solar-charger-meta").attr("x",t.metaLeftX).attr("y",48).attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",o=>o.model.chargerMetaTextColor).text(o=>o.model.chargerSectionMetadata),d.select("text.solar-relay-label").attr("x",5).attr("y",73).attr("font-size",10).attr("fill","var(--kip-contrast-color)").text(o=>o.model.relaySectionVisible?"Load Output":""),d.select("text.solar-relay-values").attr("x",10).attr("y",83).attr("font-size",t.lineTwoFontSize).attr("fill",o=>o.model.relayValuesTextColor).attr("opacity",o=>o.model.relaySectionVisible?.8:0).text(o=>o.model.relaySectionText),d.select("g.solar-panel-icon").attr("transform",`translate(${l.SOLAR_PANEL_X}, ${l.SOLAR_PANEL_Y})`),d.select("use.solar-panel-bg").attr("color","var(--kip-contrast-dimmer-color)"),d.select("g.solar-panel-progress").each((o,p,T)=>{ge$1(T[p]).select("rect").attr("x",0).attr("y",0).attr("height",1).attr("width",Math.max(0,Math.min(1,o.model.gaugeProgress))),this.debugSolarLayout(o.key,o.model.gaugeProgress);}),d.select("use.solar-panel-colored").attr("color",o=>o.model.panelPowerColor),d.select("text.solar-panel-power").attr("x",137.5).attr("y",t.primaryY).attr("text-anchor","middle").attr("font-size",t.primaryFontSize).attr("font-weight",t.primaryFontWeight).attr("filter",o=>o.model.panelPowerGlowEnabled?`url(#${this.glowFilterId})`:null).attr("fill","var(--kip-contrast-color)"),d.select("tspan.solar-panel-power-value").text(o=>o.model.panelPowerText),d.select("tspan.solar-panel-power-unit").attr("dx",o=>o.model.panelPowerUnitText?1:0).attr("font-size",20).attr("font-weight",500).attr("fill","var(--kip-contrast-color)").attr("opacity",o=>o.model.panelPowerUnitText?1:0).text(o=>o.model.panelPowerUnitText),d.select("text.solar-panel-values").attr("x",137.5).attr("y",60).attr("text-anchor","middle").attr("font-size",10).attr("font-weight",500).attr("opacity",.8).attr("filter",o=>o.model.panelValuesGlowEnabled?`url(#${this.glowFilterId})`:null).attr("fill",o=>o.model.panelValuesTextColor).text(o=>o.model.gaugeSectionText).raise(),d.select("text.solar-yield-label").attr("x",104).attr("y",88).attr("text-anchor","middle").attr("font-size",8).attr("fill","var(--kip-contrast-dim-color)").attr("opacity",.8).text("Yield (kWh):"),d.select("text.solar-yield-today").attr("x",130).attr("y",88).attr("text-anchor","start").attr("font-size",8).attr("fill","var(--kip-contrast-dim-color)").attr("opacity",.8).text(o=>o.model.yieldTodayText),d.select("text.solar-yield-yesterday").attr("x",130).attr("y",97.5).attr("text-anchor","start").attr("font-size",8).attr("fill","var(--kip-contrast-dim-color)").attr("opacity",.8).text(o=>o.model.yieldYesterdayText),i.exit().remove();}displayName(e){return e.name?.trim()||e.id}resolveTitleText(e){return e.name||`Solar ${e.id}`}toNumber(e,r){return e==null||typeof e!="number"?null:this.units.convertToUnit(r,e)??e}isRelayActive(e){if(e==null)return false;if(typeof e=="boolean")return e;if(typeof e=="number")return e>0;let r=e.trim().toLowerCase();return !(!r||r==="off"||r==="false"||r==="0")}toStringValue(e){return typeof e=="string"?e:e==null?null:`${e}`}valueOrDash(e){return e===null?"--":e===void 0?"":e}formatVoltage(e){return e===null?"--":e===void 0?"":`${e.toFixed(1)}V`}formatCurrent(e){return e===null?"--":e===void 0?"":`${e.toFixed(1)}`}formatTemperature(e){return e===null?"--":e===void 0?"":`${e.toFixed(1)} ${this.units.getDefaults().Temperature==="celsius"?"\xB0C":"\xB0F"}`}formatRelayState(e){return e===null?"--":e===void 0?"":typeof e=="boolean"?e?"On":"Off":typeof e=="number"?e>0?"On":"Off":e}formatPowerAuto(e){return e===null?{value:"--",unit:""}:e===void 0?{value:"",unit:""}:Math.abs(e)>=1e3?{value:(e/1e3).toFixed(2),unit:"kW"}:{value:e.toFixed(0),unit:"W"}}formatEnergyYield(e){return e===null?"--":e===void 0?"":`${e.toFixed(2)}`}resolveMostSevereState(...e){let r=null,t={[n$1.Normal]:0,[n$1.Nominal]:1,[n$1.Alert]:2,[n$1.Warn]:3,[n$1.Alarm]:4,[n$1.Emergency]:5};for(let a of e)a&&(!r||t[a]>t[r])&&(r=a);return r}debugSolarLayout(e,r){typeof window<"u"&&window.__KIP_DEBUG_SOLAR_LAYOUT===true&&console.debug("[solar-layout]",{id:e,gaugeProgress:r,panelX:l.SOLAR_PANEL_X,panelY:l.SOLAR_PANEL_Y,panelWidth:l.SOLAR_PANEL_WIDTH,panelHeight:l.SOLAR_PANEL_HEIGHT,clippedWidth:l.SOLAR_PANEL_WIDTH*r});}static \u0275fac=function(r){return new(r||l)};static \u0275cmp=JD({type:l,selectors:[["widget-solar-charger"]],viewQuery:function(r,t){r&1&&eg(t.svgRef,pe,5),r&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["solarSvg",""],[3,"text","color"],["aria-hidden","false",1,"solar-svg"],[1,"solar-empty"],[1,"solar-empty-title"],[1,"solar-empty-sub"]],template:function(r,t){r&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,he,5,0,"div",3)),r&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasChargers()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.solar-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}.solar-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)}.solar-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.solar-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{te as WidgetSolarChargerComponent};