@mxtommy/kip 4.8.2 → 4.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/package.json +27 -4
  3. package/public/{chunk-BIYHVfJl.js → chunk-07zHjmg-.js} +1 -1
  4. package/public/{chunk-NnB8OYZt.js → chunk-0z3nIRXw.js} +1 -1
  5. package/public/{chunk-CCiqU2uY.js → chunk-B09jfNia.js} +1 -1
  6. package/public/{chunk-Bq-eHuZV.js → chunk-B0D54iJs.js} +1 -1
  7. package/public/{chunk-DfGLo6Tb.js → chunk-B0eE4udE.js} +1 -1
  8. package/public/{chunk-CkfPr-c5.js → chunk-B9nVBlGj.js} +1 -1
  9. package/public/{chunk-B8zRhoG8.js → chunk-BFpzxIIT.js} +1 -1
  10. package/public/{chunk-D_wrJJxl.js → chunk-BIb-xYiS.js} +1 -1
  11. package/public/{chunk-CSpA60X7.js → chunk-BJ-wyixK.js} +1 -1
  12. package/public/{chunk-Bb1mO304.js → chunk-BLEZOsfR.js} +1 -1
  13. package/public/{chunk-7lulvsGI.js → chunk-BN7A4g6c.js} +1 -1
  14. package/public/{chunk-h2q_pbbF.js → chunk-BTOTKeBo.js} +1 -1
  15. package/public/{chunk-DjavLLpP.js → chunk-BUguZ7cK.js} +1 -1
  16. package/public/{chunk-B8gfh4xf.js → chunk-BZx964-p.js} +1 -1
  17. package/public/{chunk-CcvYOops.js → chunk-BeM64etA.js} +1 -1
  18. package/public/{chunk-DSvdWjO4.js → chunk-BfiyH3nV.js} +1 -1
  19. package/public/{chunk-B_PiPxb4.js → chunk-BjINKQ03.js} +1 -1
  20. package/public/{chunk-BdBWqZzL.js → chunk-BpcNrtxJ.js} +1 -1
  21. package/public/{chunk-C4FGoLDg.js → chunk-BuvyF0y5.js} +1 -1
  22. package/public/{chunk-DGOvRnAo.js → chunk-C6b8CVno.js} +1 -1
  23. package/public/{chunk-BgyxBAyq.js → chunk-CCfhzpE8.js} +1 -1
  24. package/public/{chunk-CoEM_FqS.js → chunk-CHAFm_nM.js} +1 -1
  25. package/public/{chunk-D0MyVrEL.js → chunk-CIGP2YJm.js} +1 -1
  26. package/public/{chunk-Bhah8DNM.js → chunk-CLTHuhlN.js} +1 -1
  27. package/public/{chunk-B6XxnPxk.js → chunk-CLs_NL1y.js} +1 -1
  28. package/public/{chunk-Cr34s2uQ.js → chunk-COI6IBXH.js} +1 -1
  29. package/public/{chunk-BxV0O2fU.js → chunk-CQMVIDcp.js} +1 -1
  30. package/public/{chunk-CHKQxw6E.js → chunk-CXvWM_vF.js} +1 -1
  31. package/public/{chunk-Di5pPpU7.js → chunk-CYYBxjrc.js} +1 -1
  32. package/public/{chunk-BW4m3O2L.js → chunk-C_OZJltF.js} +1 -1
  33. package/public/{chunk-CjsnWLUr.js → chunk-Co2wVrD6.js} +1 -1
  34. package/public/{chunk-DMhuBqKs.js → chunk-CoCQ3DW2.js} +1 -1
  35. package/public/{chunk-DMoEBcor.js → chunk-CxPx4NZv.js} +1 -1
  36. package/public/{chunk-CdSWuWKr.js → chunk-CyVRpGoJ.js} +1 -1
  37. package/public/{chunk-Dv77RFHm.js → chunk-D-_-GUVr.js} +1 -1
  38. package/public/{chunk-CU8RPnsi.js → chunk-D1HYfaL_.js} +1 -1
  39. package/public/{chunk-DBA0eRqb.js → chunk-D2953Rfp.js} +1 -1
  40. package/public/{chunk-Cu9FE8cB.js → chunk-DIl1k00y.js} +1 -1
  41. package/public/{chunk-CyURmwWh.js → chunk-DPnbM-aB.js} +1 -1
  42. package/public/{chunk-8hkXyEzG.js → chunk-DTN-sa1K.js} +1 -1
  43. package/public/{chunk-C3CwUYvD.js → chunk-DUEKoZhd.js} +1 -1
  44. package/public/{chunk-COMZv7NY.js → chunk-DmkAKXR1.js} +1 -1
  45. package/public/{chunk-zg7II0hz.js → chunk-Do8wqING.js} +1 -1
  46. package/public/{chunk-oPq9Nexl.js → chunk-JhFkJS7i.js} +1 -1
  47. package/public/{chunk-CJIxuzvd.js → chunk-OeQDZKFO.js} +1 -1
  48. package/public/{chunk-Bz9bswDl.js → chunk-_zRMMvCu.js} +1 -1
  49. package/public/{chunk-D-xDPCf7.js → chunk-eQ1pa34Q.js} +1 -1
  50. package/public/{chunk-DVB9tiW3.js → chunk-ibauGmSP.js} +1 -1
  51. package/public/{chunk-oZiyAw_P.js → chunk-otzyItXL.js} +1 -1
  52. package/public/{chunk-B6AwCAvV.js → chunk-q9NoPvcx.js} +1 -1
  53. package/public/{chunk-B15lj2T8.js → chunk-szQs8fiq.js} +1 -1
  54. package/public/{chunk-o977r5_s.js → chunk-x7L6DXVK.js} +1 -1
  55. package/public/index.html +1 -1
  56. package/public/{main-BNR44HGB.js → main-YKDNK5VZ.js} +4 -4
  57. package/plugin/history-series.service.js +0 -637
  58. package/plugin/index.js +0 -1322
  59. package/plugin/kip-series-contract.js +0 -31
  60. package/plugin/openApi.json +0 -855
  61. package/plugin/sqlite-history-storage.service.js +0 -1124
  62. package/plugin/src/history-series.service.js +0 -634
  63. package/plugin/src/index.js +0 -1322
  64. package/plugin/src/kip-series-contract.js +0 -31
  65. package/plugin/src/openApi.json +0 -855
  66. package/plugin/src/sqlite-history-storage.service.js +0 -1122
@@ -1 +1 @@
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 ie=["acSvg"];function re(l,e){l&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No AC buses detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K AC paths or select buses in widget settings."),ul()());}var Y=class l{static AC_DESCRIPTOR=a("widget-ac");static SELF_ROOT_PATH=(()=>{let e=l.AC_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetAcComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${l.SELF_ROOT_PATH}.*`;static ROOT_PREFIX=`${l.SELF_ROOT_PATH}.`;static VIEWBOX_WIDTH=200;static CARD_HEIGHT=100;static COMPACT_CARD_HEIGHT=100;static CARD_GAP=8;static PATH_BATCH_WINDOW_MS=500;static RESERVED_AC_AGGREGATE_IDS=new Set(["totalCurrent","totalPower"]);static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,ac:{trackedDevices:[],optionsById:{}}};id=Hj.required();type=Hj.required();theme=Hj.required();renderMode=Hj(null);runtime=w(p);data=w(De);units=w(ut);destroyRef=w(xe);svgRef=$j.required("acSvg");svg;layer;pendingPathUpdates=new Map;pathBatchTimerId=null;initialPathPaintDone=false;renderFrameId=null;pendingRenderSnapshot=null;discoveredBusIds=vt([]);trackedDevices=vt([]);optionsById=vt({});cardMode=vt({displayMode:"full",metrics:["line1Voltage","line1Current","line1Frequency","line2Voltage"]});busesByKey=vt({});visibleBusKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(r=>r.key);let i=this.busesByKey(),t=new Set(this.discoveredBusIds());return Object.keys(i).filter(r=>{let s=i[r];return !!s&&t.has(s.id)}).sort((r,s)=>r.localeCompare(s))});visibleBuses=Dt(()=>{let e=this.visibleBusKeys(),i=this.busesByKey();return e.map(t=>i[t]).filter(t=>!!t)});hasBuses=Dt(()=>this.visibleBuses().length>0);activeDisplayMode=Dt(()=>this.renderMode()??this.cardMode().displayMode??"full");isCompactCardMode=Dt(()=>this.activeDisplayMode()==="compact");colorRole=Dt(()=>this.runtime.options()?.color??"contrast");ignoreZones=Dt(()=>this.runtime.options()?.ignoreZones??false);displayLabel=Dt(()=>{let e=this.visibleBuses();return e.length!==1?"AC Buses":this.resolveTitleText(e[0])});labelColor=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e).dim:"var(--kip-contrast-dim-color)"});widgetColors=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e):null});displayModels=Dt(()=>{let e$1=this.visibleBuses(),i=this.theme(),t=this.widgetColors(),r=this.ignoreZones(),s=new Map;e$1.forEach(n=>s.set(n.id,(s.get(n.id)??0)+1));let c=new Set([...s.entries()].filter(([,n])=>n>1).map(([n])=>n)),a={};for(let n of e$1){let d=n.deviceKey??n.id,o=!!n.source&&c.has(n.id),h=this.resolveMostSevereState(n.line1VoltageState??null,n.line1CurrentState??null,n.line2VoltageState??null,n.line2CurrentState??null,n.line3VoltageState??null,n.line3CurrentState??null,n.modeState??null),v=this.resolveMostSevereState(n.line1VoltageState??null,n.line1CurrentState??null,n.line1FrequencyState??null),T=this.resolveMostSevereState(n.line2VoltageState??null,n.line2CurrentState??null,n.line3VoltageState??null,n.line3CurrentState??null),[M,I]=this.buildMetricRows(n);a[d]={id:n.id,titleText:this.resolveTitleText(n),modeText:this.isCompactCardMode()?"":this.resolveModeText(n),busText:this.isCompactCardMode()?"":o?n.source??"-":n.associatedBus||n.location||"-",metricsLineOne:M,metricsLineTwo:I,stateBarColor:e(h,t?.dim??"var(--kip-contrast-color)",i,r),titleTextColor:e(h,"var(--kip-contrast-color)",i,r),metaTextColor:e(n.modeState??null,"var(--kip-contrast-dim-color)",i,r),primaryMetricsTextColor:e(v,"var(--kip-contrast-color)",i,r),secondaryMetricsTextColor:e(T,"var(--kip-contrast-color)",i,r)};}return a});constructor(){Fa(()=>{let t=this.runtime.options();t&&ge(()=>this.applyConfig(t));}),Fa(()=>{let t=this.displayModels(),r=this.visibleBuses(),s=this.widgetColors();!this.svg||!s||this.requestRender({buses:r,displayModels:t,widgetColors:s});});let e=[this.data.subscribePathTreeWithInitial(l.ROOT_PATTERN)],i=false;for(let t of e)if(t.initial.length){i=true;for(let r of t.initial)this.enqueuePathUpdate(r,true);}i&&(this.flushPendingPathUpdates(),this.initialPathPaintDone=true);for(let t of e)t.live$.pipe(Gp(this.destroyRef)).subscribe(r=>this.enqueuePathUpdate(r));}ngAfterViewInit(){this.initializeSvg(),this.requestRender();}ngOnDestroy(){this.pathBatchTimerId!==null&&(clearTimeout(this.pathBatchTimerId),this.pathBatchTimerId=null),this.renderFrameId!==null&&(cancelAnimationFrame(this.renderFrameId),this.renderFrameId=null),this.pendingRenderSnapshot=null;}initializeSvg(){this.svg=ge$1(this.svgRef().nativeElement),this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${l.CARD_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","AC View"),this.layer=this.svg.append("g").attr("class","ac-layer");}applyConfig(e){let i=this.resolveAcConfig(e);this.trackedDevices.set(i.trackedDevices??[]),this.reprojectSnapshotsToDeviceKeys(i.trackedDevices??[]),this.optionsById.set(i.optionsById),this.cardMode.set(this.normalizeCardMode(i.cardMode));}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let i=new Map;e.forEach(t=>{let r=i.get(t.id)??[];r.push(t.key),i.set(t.id,r);}),this.busesByKey.update(t=>{let r=t,s=false;return i.forEach((c,a)=>{let n=t[a];if(n){for(let d of c){if(t[d])continue;let o=e.find(h=>h.key===d);s||(r=G({},t),s=true),r[d]=z(G({},n),{source:o?.source??null,deviceKey:d});}s&&r[a]?.deviceKey===void 0&&delete r[a];}}),s?r:t});}resolveAcConfig(e){let i=e.ac;return {trackedDevices:this.normalizeAcTrackedDevices(i?.trackedDevices),optionsById:this.normalizeOptionsById(i?.optionsById),cardMode:this.normalizeCardMode(i?.cardMode)}}normalizeAcTrackedDevices(e){if(!Array.isArray(e))return [];let i=new Map;return e.forEach(t=>{if(!t||typeof t!="object")return;let r=t,s=this.normalizeOptionalString(r.id),c=this.normalizeOptionalString(r.source);if(!s||!c||l.RESERVED_AC_AGGREGATE_IDS.has(s))return;let a=this.normalizeOptionalString(r.key)??`${s}||${c}`;i.set(a,{id:s,source:c,key:a});}),[...i.values()].sort((t,r)=>t.key.localeCompare(r.key))}buildIdToDeviceKeysMap(){let e=new Map;return this.trackedDevices().forEach(i=>{let t=e.get(i.id)??[];t.push(i.key),e.set(i.id,t);}),e}normalizeCardMode(e){let i=e&&typeof e=="object"?e:null,t=this.normalizeStringList(i?.metrics);return {displayMode:i?.displayMode==="compact"?"compact":"full",metrics:t.length?t:["line1Voltage","line1Current","line1Frequency","line2Voltage"]}}normalizeStringList(e){if(!Array.isArray(e))return [];let i=new Set;return e.forEach(t=>{if(typeof t!="string")return;let r=t.trim();r.length>0&&i.add(r);}),[...i].sort((t,r)=>t.localeCompare(r))}normalizeOptionsById(e){if(!e||typeof e!="object")return {};let i={};return Object.entries(e).forEach(([t])=>{let r=this.normalizeOptionalString(t);r&&(i[r]={});}),i}normalizeOptionalString(e){if(typeof e!="string")return null;let i=e.trim();return i.length>0?i:null}enqueuePathUpdate(e,i=false){let t=this.parsePath(e.path);if(!t)return;let r=e.update?.data?.value??null,s=e.update?.state??null;if(this.pendingPathUpdates.set(`${t.id}::${t.key}`,{id:t.id,key:t.key,value:r,state:s}),!i){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},l.PATH_BATCH_WINDOW_MS));}}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let e=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(e.map(r=>r.id)).forEach(r=>this.trackDiscoveredBus(r));let t=this.buildIdToDeviceKeysMap();this.busesByKey.update(r=>{let s=r,c=false;for(let a of e){let n=t.get(a.id),d=n?.length?n:[a.id];for(let o of d){let h=!!n?.length,v=h?this.trackedDevices().find(Z=>Z.key===o):null,T=s[o]??{id:a.id,source:v?.source??null,deviceKey:h?o:void 0},M=G({},T);this.applyValue(M,a.key,a.value,a.state)&&(c||(s=G({},s),c=true),s[o]=M);}}return c?s:r});}parsePath(e){if(!e.startsWith(l.ROOT_PREFIX))return null;let i=e.slice(l.ROOT_PREFIX.length),t=i.indexOf(".");return t<=0||t===i.length-1?null:{id:i.slice(0,t),key:i.slice(t+1)}}normalizeMetricKey(e){let i=e.match(/^phase\.([^.]+)\.(current|frequency|lineNeutralVoltage|realPower)$/);if(i){let t=this.resolveLineKey(i[1]);if(!t)return null;let r=i[2];return r==="current"?`${t}.current`:r==="frequency"?`${t}.frequency`:r==="lineNeutralVoltage"?`${t}.voltage`:`${t}.realPower`}return e==="total.realPower"?"power":e}resolveLineKey(e){let i=e.trim().toLowerCase();return ["0","1","l1","line1","phase1","a"].includes(i)?"line1":["2","l2","line2","phase2","b"].includes(i)?"line2":["3","l3","line3","phase3","c"].includes(i)?"line3":null}trackDiscoveredBus(e){let i=this.discoveredBusIds();i.includes(e)||this.discoveredBusIds.set([...i,e].sort((t,r)=>t.localeCompare(r)));}applyValue(e,i,t,r){let s=this.normalizeMetricKey(i);if(!s)return false;switch(s){case "name":return this.setValue(e,"name",this.toStringValue(t));case "location":return this.setValue(e,"location",this.toStringValue(t));case "associatedBus":return this.setValue(e,"associatedBus",this.toStringValue(t));case "mode":return this.setMetricValue(e,"mode","modeState",this.toStringValue(t),r);case "voltage":return this.setMetricValue(e,"line1Voltage","line1VoltageState",this.toNumber(t,"V"),r);case "current":return this.setMetricValue(e,"line1Current","line1CurrentState",this.toNumber(t,"A"),r);case "frequency":return this.setMetricValue(e,"line1Frequency","line1FrequencyState",this.toNumber(t,"Hz"),r);case "line1.voltage":return this.setMetricValue(e,"line1Voltage","line1VoltageState",this.toNumber(t,"V"),r);case "line1.current":return this.setMetricValue(e,"line1Current","line1CurrentState",this.toNumber(t,"A"),r);case "line1.frequency":return this.setMetricValue(e,"line1Frequency","line1FrequencyState",this.toNumber(t,"Hz"),r);case "line1.realPower":return this.setMetricValue(e,"power","line1CurrentState",this.toNumber(t,"W"),r);case "line2.voltage":return this.setMetricValue(e,"line2Voltage","line2VoltageState",this.toNumber(t,"V"),r);case "line2.current":return this.setMetricValue(e,"line2Current","line2CurrentState",this.toNumber(t,"A"),r);case "line2.frequency":return this.setMetricValue(e,"line2Frequency","line2FrequencyState",this.toNumber(t,"Hz"),r);case "line2.realPower":return this.setMetricValue(e,"power","line2CurrentState",this.toNumber(t,"W"),r);case "line3.voltage":return this.setMetricValue(e,"line3Voltage","line3VoltageState",this.toNumber(t,"V"),r);case "line3.current":return this.setMetricValue(e,"line3Current","line3CurrentState",this.toNumber(t,"A"),r);case "line3.frequency":return this.setMetricValue(e,"line3Frequency","line3FrequencyState",this.toNumber(t,"Hz"),r);case "line3.realPower":return this.setMetricValue(e,"power","line3CurrentState",this.toNumber(t,"W"),r);case "power":return this.setMetricValue(e,"power","line1CurrentState",this.toNumber(t,"W"),r);default:return false}}setValue(e,i,t){return Object.is(e[i],t)?false:(e[i]=t,true)}setMetricValue(e,i,t,r,s){let c=!Object.is(e[i],r),a=!Object.is(e[t],s);return !c&&!a?false:(e[i]=r,e[t]=s,true)}requestRender(e){let i=this.widgetColors();!this.svg||!i||(this.pendingRenderSnapshot=e??{buses:this.visibleBuses(),displayModels:this.displayModels(),widgetColors:i},this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;let t=this.pendingRenderSnapshot;this.pendingRenderSnapshot=null,t&&this.render(t);})));}render(e){if(!this.layer||!this.svg)return;let i=this.isCompactCardMode(),t=i?C:e$1,r=i?l.COMPACT_CARD_HEIGHT:l.CARD_HEIGHT,s=e.buses.map((o,h)=>({key:o.deviceKey??o.id,bus:o,y:h*(r+l.CARD_GAP)})),c=s.length?s[s.length-1].y+r:r;this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${c}`);let a=this.layer.selectAll("g.ac-card").data(s,o=>o.key),n=a.enter().append("g").attr("class","ac-card");n.append("rect").attr("class","ac-state-bar"),n.append("text").attr("class","ac-title"),n.append("text").attr("class","ac-id"),n.append("text").attr("class","ac-mode"),n.append("text").attr("class","ac-bus"),n.append("text").attr("class","ac-metrics-1"),n.append("text").attr("class","ac-metrics-2");let d=n.merge(a);d.attr("transform",o=>`translate(0, ${o.y})`),d.select("rect.ac-state-bar").attr("x",1.5).attr("y",1.5).attr("rx",t.stateBarCornerRadius).attr("ry",t.stateBarCornerRadius).attr("width",3).attr("height",r-3).attr("fill",o=>e.displayModels[o.key]?.stateBarColor??e.widgetColors.dim),e.buses.length>1?d.select("text.ac-title").attr("x",t.titleX).attr("y",t.titleY).attr("font-size",t.titleFontSize).attr("fill",o=>e.displayModels[o.key]?.titleTextColor??"var(--kip-contrast-color)").text(o=>e.displayModels[o.key]?.titleText??this.resolveTitleText(o.bus)):d.select("text.ac-title").text(""),d.select("text.ac-id").attr("x",t.idX).attr("y",t.idY).attr("text-anchor","end").attr("font-size",t.idFontSize).attr("fill","var(--kip-contrast-dim-color)").text(o=>o.bus.id),d.select("text.ac-mode").attr("x",t.metaLeftX).attr("y",t.metaY).attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",o=>e.displayModels[o.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(o=>e.displayModels[o.key]?.modeText??""),d.select("text.ac-bus").attr("x",t.metaRightX).attr("y",t.metaY).attr("text-anchor","end").attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",o=>e.displayModels[o.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(o=>e.displayModels[o.key]?.busText??""),d.select("text.ac-metrics-1").attr("x",t.lineOneX).attr("y",t.lineOneY).attr("font-size",t.lineOneFontSize).attr("fill",o=>e.displayModels[o.key]?.primaryMetricsTextColor??"var(--kip-contrast-color)").text(o=>e.displayModels[o.key]?.metricsLineOne??""),d.select("text.ac-metrics-2").attr("x",t.lineTwoX).attr("y",t.lineTwoY).attr("font-size",t.lineTwoFontSize).attr("opacity",.85).attr("fill",o=>e.displayModels[o.key]?.secondaryMetricsTextColor??"var(--kip-contrast-color)").text(o=>e.displayModels[o.key]?.metricsLineTwo??""),a.exit().remove();}displayName(e){return e.name?.trim()||e.id}resolveTitleText(e){return e.name||`AC ${e.id}`}resolveModeText(e){return e.mode?`Mode ${e.mode}`:"Mode -"}buildMetricRows(e){let i=this.cardMode(),t=(i.metrics.length?i.metrics:l.DEFAULT_CONFIG.ac?.cardMode?.metrics??[]).map(c=>this.toMetricLabel(c,e)).filter(c=>!!c);if(!t.length)return ["L1 - - -","L2 - - L3 - -"];let r=t.slice(0,2).join(" "),s=t.slice(2,4).join(" ");return [r||" ",s||" "]}toMetricLabel(e,i){switch(e){case "line1Voltage":return `L1V ${this.formatValue(i.line1Voltage,"V")}`;case "line1Current":return `L1A ${this.formatValue(i.line1Current,"A")}`;case "line1Frequency":return `L1Hz ${this.formatValue(i.line1Frequency,"Hz")}`;case "line2Voltage":return `L2V ${this.formatValue(i.line2Voltage,"V")}`;case "line2Current":return `L2A ${this.formatValue(i.line2Current,"A")}`;case "line2Frequency":return `L2Hz ${this.formatValue(i.line2Frequency,"Hz")}`;case "line3Voltage":return `L3V ${this.formatValue(i.line3Voltage,"V")}`;case "line3Current":return `L3A ${this.formatValue(i.line3Current,"A")}`;case "line3Frequency":return `L3Hz ${this.formatValue(i.line3Frequency,"Hz")}`;default:return null}}formatValue(e,i){return e==null||Number.isNaN(e)?"-":`${e.toFixed(1)} ${i}`}toStringValue(e){return typeof e=="string"?e:null}resolveMostSevereState(...e){return e.some(i=>i===n$1.Alert)?n$1.Alert:e.some(i=>i===n$1.Alarm)?n$1.Alarm:e.some(i=>i===n$1.Warn)?n$1.Warn:e.some(i=>i===n$1.Normal)?n$1.Normal:null}toNumber(e,i){if(e==null||typeof e=="boolean")return null;let t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return null;let r=this.units.convertToUnit(i,t);return typeof r=="number"&&Number.isFinite(r)?r:null}static \u0275fac=function(i){return new(i||l)};static \u0275cmp=JD({type:l,selectors:[["widget-ac"]],viewQuery:function(i,t){i&1&&eg(t.svgRef,ie,5),i&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["acSvg",""],[3,"text","color"],["aria-hidden","false",1,"ac-svg"],[1,"ac-empty"],[1,"ac-empty-title"],[1,"ac-empty-sub"]],template:function(i,t){i&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,re,5,0,"div",3)),i&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasBuses()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.ac-svg[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;z-index:20;padding:0 10px 10px}.ac-empty[_ngcontent-%COMP%]{position:absolute;inset:0;margin:10px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;text-align:center;color:var(--mat-sys-on-surface);background:color-mix(in srgb,var(--kip-widget-card-background-color) 92%,transparent)}.ac-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.ac-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{Y as WidgetAcComponent};
1
+ import {C,e as e$1}from'./chunk-DPnbM-aB.js';import {g as ge$1}from'./chunk-TakPRI3t.js';import {e9 as a,d1 as Hj,w,du as p,aS as De,bu as ut,aY as xe,$ as $j,v as vt,D as Dt,F as Fa,dn as ge,a_ as Gp,cv as G,cw as z,dx as n$1,J as JD,dC as x,c as $h,cn as wd,_ as _w,B as Bh,e as EE,M as Mw,f as eg,K as Kw,P as Pi,T as TT,u as ul}from'./main-YKDNK5VZ.js';import {c,e}from'./chunk-BIb-xYiS.js';var ie=["acSvg"];function re(l,e){l&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No AC buses detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K AC paths or select buses in widget settings."),ul()());}var Y=class l{static AC_DESCRIPTOR=a("widget-ac");static SELF_ROOT_PATH=(()=>{let e=l.AC_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetAcComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${l.SELF_ROOT_PATH}.*`;static ROOT_PREFIX=`${l.SELF_ROOT_PATH}.`;static VIEWBOX_WIDTH=200;static CARD_HEIGHT=100;static COMPACT_CARD_HEIGHT=100;static CARD_GAP=8;static PATH_BATCH_WINDOW_MS=500;static RESERVED_AC_AGGREGATE_IDS=new Set(["totalCurrent","totalPower"]);static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,ac:{trackedDevices:[],optionsById:{}}};id=Hj.required();type=Hj.required();theme=Hj.required();renderMode=Hj(null);runtime=w(p);data=w(De);units=w(ut);destroyRef=w(xe);svgRef=$j.required("acSvg");svg;layer;pendingPathUpdates=new Map;pathBatchTimerId=null;initialPathPaintDone=false;renderFrameId=null;pendingRenderSnapshot=null;discoveredBusIds=vt([]);trackedDevices=vt([]);optionsById=vt({});cardMode=vt({displayMode:"full",metrics:["line1Voltage","line1Current","line1Frequency","line2Voltage"]});busesByKey=vt({});visibleBusKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(r=>r.key);let i=this.busesByKey(),t=new Set(this.discoveredBusIds());return Object.keys(i).filter(r=>{let s=i[r];return !!s&&t.has(s.id)}).sort((r,s)=>r.localeCompare(s))});visibleBuses=Dt(()=>{let e=this.visibleBusKeys(),i=this.busesByKey();return e.map(t=>i[t]).filter(t=>!!t)});hasBuses=Dt(()=>this.visibleBuses().length>0);activeDisplayMode=Dt(()=>this.renderMode()??this.cardMode().displayMode??"full");isCompactCardMode=Dt(()=>this.activeDisplayMode()==="compact");colorRole=Dt(()=>this.runtime.options()?.color??"contrast");ignoreZones=Dt(()=>this.runtime.options()?.ignoreZones??false);displayLabel=Dt(()=>{let e=this.visibleBuses();return e.length!==1?"AC Buses":this.resolveTitleText(e[0])});labelColor=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e).dim:"var(--kip-contrast-dim-color)"});widgetColors=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e):null});displayModels=Dt(()=>{let e$1=this.visibleBuses(),i=this.theme(),t=this.widgetColors(),r=this.ignoreZones(),s=new Map;e$1.forEach(n=>s.set(n.id,(s.get(n.id)??0)+1));let c=new Set([...s.entries()].filter(([,n])=>n>1).map(([n])=>n)),a={};for(let n of e$1){let d=n.deviceKey??n.id,o=!!n.source&&c.has(n.id),h=this.resolveMostSevereState(n.line1VoltageState??null,n.line1CurrentState??null,n.line2VoltageState??null,n.line2CurrentState??null,n.line3VoltageState??null,n.line3CurrentState??null,n.modeState??null),v=this.resolveMostSevereState(n.line1VoltageState??null,n.line1CurrentState??null,n.line1FrequencyState??null),T=this.resolveMostSevereState(n.line2VoltageState??null,n.line2CurrentState??null,n.line3VoltageState??null,n.line3CurrentState??null),[M,I]=this.buildMetricRows(n);a[d]={id:n.id,titleText:this.resolveTitleText(n),modeText:this.isCompactCardMode()?"":this.resolveModeText(n),busText:this.isCompactCardMode()?"":o?n.source??"-":n.associatedBus||n.location||"-",metricsLineOne:M,metricsLineTwo:I,stateBarColor:e(h,t?.dim??"var(--kip-contrast-color)",i,r),titleTextColor:e(h,"var(--kip-contrast-color)",i,r),metaTextColor:e(n.modeState??null,"var(--kip-contrast-dim-color)",i,r),primaryMetricsTextColor:e(v,"var(--kip-contrast-color)",i,r),secondaryMetricsTextColor:e(T,"var(--kip-contrast-color)",i,r)};}return a});constructor(){Fa(()=>{let t=this.runtime.options();t&&ge(()=>this.applyConfig(t));}),Fa(()=>{let t=this.displayModels(),r=this.visibleBuses(),s=this.widgetColors();!this.svg||!s||this.requestRender({buses:r,displayModels:t,widgetColors:s});});let e=[this.data.subscribePathTreeWithInitial(l.ROOT_PATTERN)],i=false;for(let t of e)if(t.initial.length){i=true;for(let r of t.initial)this.enqueuePathUpdate(r,true);}i&&(this.flushPendingPathUpdates(),this.initialPathPaintDone=true);for(let t of e)t.live$.pipe(Gp(this.destroyRef)).subscribe(r=>this.enqueuePathUpdate(r));}ngAfterViewInit(){this.initializeSvg(),this.requestRender();}ngOnDestroy(){this.pathBatchTimerId!==null&&(clearTimeout(this.pathBatchTimerId),this.pathBatchTimerId=null),this.renderFrameId!==null&&(cancelAnimationFrame(this.renderFrameId),this.renderFrameId=null),this.pendingRenderSnapshot=null;}initializeSvg(){this.svg=ge$1(this.svgRef().nativeElement),this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${l.CARD_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","AC View"),this.layer=this.svg.append("g").attr("class","ac-layer");}applyConfig(e){let i=this.resolveAcConfig(e);this.trackedDevices.set(i.trackedDevices??[]),this.reprojectSnapshotsToDeviceKeys(i.trackedDevices??[]),this.optionsById.set(i.optionsById),this.cardMode.set(this.normalizeCardMode(i.cardMode));}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let i=new Map;e.forEach(t=>{let r=i.get(t.id)??[];r.push(t.key),i.set(t.id,r);}),this.busesByKey.update(t=>{let r=t,s=false;return i.forEach((c,a)=>{let n=t[a];if(n){for(let d of c){if(t[d])continue;let o=e.find(h=>h.key===d);s||(r=G({},t),s=true),r[d]=z(G({},n),{source:o?.source??null,deviceKey:d});}s&&r[a]?.deviceKey===void 0&&delete r[a];}}),s?r:t});}resolveAcConfig(e){let i=e.ac;return {trackedDevices:this.normalizeAcTrackedDevices(i?.trackedDevices),optionsById:this.normalizeOptionsById(i?.optionsById),cardMode:this.normalizeCardMode(i?.cardMode)}}normalizeAcTrackedDevices(e){if(!Array.isArray(e))return [];let i=new Map;return e.forEach(t=>{if(!t||typeof t!="object")return;let r=t,s=this.normalizeOptionalString(r.id),c=this.normalizeOptionalString(r.source);if(!s||!c||l.RESERVED_AC_AGGREGATE_IDS.has(s))return;let a=this.normalizeOptionalString(r.key)??`${s}||${c}`;i.set(a,{id:s,source:c,key:a});}),[...i.values()].sort((t,r)=>t.key.localeCompare(r.key))}buildIdToDeviceKeysMap(){let e=new Map;return this.trackedDevices().forEach(i=>{let t=e.get(i.id)??[];t.push(i.key),e.set(i.id,t);}),e}normalizeCardMode(e){let i=e&&typeof e=="object"?e:null,t=this.normalizeStringList(i?.metrics);return {displayMode:i?.displayMode==="compact"?"compact":"full",metrics:t.length?t:["line1Voltage","line1Current","line1Frequency","line2Voltage"]}}normalizeStringList(e){if(!Array.isArray(e))return [];let i=new Set;return e.forEach(t=>{if(typeof t!="string")return;let r=t.trim();r.length>0&&i.add(r);}),[...i].sort((t,r)=>t.localeCompare(r))}normalizeOptionsById(e){if(!e||typeof e!="object")return {};let i={};return Object.entries(e).forEach(([t])=>{let r=this.normalizeOptionalString(t);r&&(i[r]={});}),i}normalizeOptionalString(e){if(typeof e!="string")return null;let i=e.trim();return i.length>0?i:null}enqueuePathUpdate(e,i=false){let t=this.parsePath(e.path);if(!t)return;let r=e.update?.data?.value??null,s=e.update?.state??null;if(this.pendingPathUpdates.set(`${t.id}::${t.key}`,{id:t.id,key:t.key,value:r,state:s}),!i){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},l.PATH_BATCH_WINDOW_MS));}}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let e=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(e.map(r=>r.id)).forEach(r=>this.trackDiscoveredBus(r));let t=this.buildIdToDeviceKeysMap();this.busesByKey.update(r=>{let s=r,c=false;for(let a of e){let n=t.get(a.id),d=n?.length?n:[a.id];for(let o of d){let h=!!n?.length,v=h?this.trackedDevices().find(Z=>Z.key===o):null,T=s[o]??{id:a.id,source:v?.source??null,deviceKey:h?o:void 0},M=G({},T);this.applyValue(M,a.key,a.value,a.state)&&(c||(s=G({},s),c=true),s[o]=M);}}return c?s:r});}parsePath(e){if(!e.startsWith(l.ROOT_PREFIX))return null;let i=e.slice(l.ROOT_PREFIX.length),t=i.indexOf(".");return t<=0||t===i.length-1?null:{id:i.slice(0,t),key:i.slice(t+1)}}normalizeMetricKey(e){let i=e.match(/^phase\.([^.]+)\.(current|frequency|lineNeutralVoltage|realPower)$/);if(i){let t=this.resolveLineKey(i[1]);if(!t)return null;let r=i[2];return r==="current"?`${t}.current`:r==="frequency"?`${t}.frequency`:r==="lineNeutralVoltage"?`${t}.voltage`:`${t}.realPower`}return e==="total.realPower"?"power":e}resolveLineKey(e){let i=e.trim().toLowerCase();return ["0","1","l1","line1","phase1","a"].includes(i)?"line1":["2","l2","line2","phase2","b"].includes(i)?"line2":["3","l3","line3","phase3","c"].includes(i)?"line3":null}trackDiscoveredBus(e){let i=this.discoveredBusIds();i.includes(e)||this.discoveredBusIds.set([...i,e].sort((t,r)=>t.localeCompare(r)));}applyValue(e,i,t,r){let s=this.normalizeMetricKey(i);if(!s)return false;switch(s){case "name":return this.setValue(e,"name",this.toStringValue(t));case "location":return this.setValue(e,"location",this.toStringValue(t));case "associatedBus":return this.setValue(e,"associatedBus",this.toStringValue(t));case "mode":return this.setMetricValue(e,"mode","modeState",this.toStringValue(t),r);case "voltage":return this.setMetricValue(e,"line1Voltage","line1VoltageState",this.toNumber(t,"V"),r);case "current":return this.setMetricValue(e,"line1Current","line1CurrentState",this.toNumber(t,"A"),r);case "frequency":return this.setMetricValue(e,"line1Frequency","line1FrequencyState",this.toNumber(t,"Hz"),r);case "line1.voltage":return this.setMetricValue(e,"line1Voltage","line1VoltageState",this.toNumber(t,"V"),r);case "line1.current":return this.setMetricValue(e,"line1Current","line1CurrentState",this.toNumber(t,"A"),r);case "line1.frequency":return this.setMetricValue(e,"line1Frequency","line1FrequencyState",this.toNumber(t,"Hz"),r);case "line1.realPower":return this.setMetricValue(e,"power","line1CurrentState",this.toNumber(t,"W"),r);case "line2.voltage":return this.setMetricValue(e,"line2Voltage","line2VoltageState",this.toNumber(t,"V"),r);case "line2.current":return this.setMetricValue(e,"line2Current","line2CurrentState",this.toNumber(t,"A"),r);case "line2.frequency":return this.setMetricValue(e,"line2Frequency","line2FrequencyState",this.toNumber(t,"Hz"),r);case "line2.realPower":return this.setMetricValue(e,"power","line2CurrentState",this.toNumber(t,"W"),r);case "line3.voltage":return this.setMetricValue(e,"line3Voltage","line3VoltageState",this.toNumber(t,"V"),r);case "line3.current":return this.setMetricValue(e,"line3Current","line3CurrentState",this.toNumber(t,"A"),r);case "line3.frequency":return this.setMetricValue(e,"line3Frequency","line3FrequencyState",this.toNumber(t,"Hz"),r);case "line3.realPower":return this.setMetricValue(e,"power","line3CurrentState",this.toNumber(t,"W"),r);case "power":return this.setMetricValue(e,"power","line1CurrentState",this.toNumber(t,"W"),r);default:return false}}setValue(e,i,t){return Object.is(e[i],t)?false:(e[i]=t,true)}setMetricValue(e,i,t,r,s){let c=!Object.is(e[i],r),a=!Object.is(e[t],s);return !c&&!a?false:(e[i]=r,e[t]=s,true)}requestRender(e){let i=this.widgetColors();!this.svg||!i||(this.pendingRenderSnapshot=e??{buses:this.visibleBuses(),displayModels:this.displayModels(),widgetColors:i},this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;let t=this.pendingRenderSnapshot;this.pendingRenderSnapshot=null,t&&this.render(t);})));}render(e){if(!this.layer||!this.svg)return;let i=this.isCompactCardMode(),t=i?C:e$1,r=i?l.COMPACT_CARD_HEIGHT:l.CARD_HEIGHT,s=e.buses.map((o,h)=>({key:o.deviceKey??o.id,bus:o,y:h*(r+l.CARD_GAP)})),c=s.length?s[s.length-1].y+r:r;this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${c}`);let a=this.layer.selectAll("g.ac-card").data(s,o=>o.key),n=a.enter().append("g").attr("class","ac-card");n.append("rect").attr("class","ac-state-bar"),n.append("text").attr("class","ac-title"),n.append("text").attr("class","ac-id"),n.append("text").attr("class","ac-mode"),n.append("text").attr("class","ac-bus"),n.append("text").attr("class","ac-metrics-1"),n.append("text").attr("class","ac-metrics-2");let d=n.merge(a);d.attr("transform",o=>`translate(0, ${o.y})`),d.select("rect.ac-state-bar").attr("x",1.5).attr("y",1.5).attr("rx",t.stateBarCornerRadius).attr("ry",t.stateBarCornerRadius).attr("width",3).attr("height",r-3).attr("fill",o=>e.displayModels[o.key]?.stateBarColor??e.widgetColors.dim),e.buses.length>1?d.select("text.ac-title").attr("x",t.titleX).attr("y",t.titleY).attr("font-size",t.titleFontSize).attr("fill",o=>e.displayModels[o.key]?.titleTextColor??"var(--kip-contrast-color)").text(o=>e.displayModels[o.key]?.titleText??this.resolveTitleText(o.bus)):d.select("text.ac-title").text(""),d.select("text.ac-id").attr("x",t.idX).attr("y",t.idY).attr("text-anchor","end").attr("font-size",t.idFontSize).attr("fill","var(--kip-contrast-dim-color)").text(o=>o.bus.id),d.select("text.ac-mode").attr("x",t.metaLeftX).attr("y",t.metaY).attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",o=>e.displayModels[o.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(o=>e.displayModels[o.key]?.modeText??""),d.select("text.ac-bus").attr("x",t.metaRightX).attr("y",t.metaY).attr("text-anchor","end").attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",o=>e.displayModels[o.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(o=>e.displayModels[o.key]?.busText??""),d.select("text.ac-metrics-1").attr("x",t.lineOneX).attr("y",t.lineOneY).attr("font-size",t.lineOneFontSize).attr("fill",o=>e.displayModels[o.key]?.primaryMetricsTextColor??"var(--kip-contrast-color)").text(o=>e.displayModels[o.key]?.metricsLineOne??""),d.select("text.ac-metrics-2").attr("x",t.lineTwoX).attr("y",t.lineTwoY).attr("font-size",t.lineTwoFontSize).attr("opacity",.85).attr("fill",o=>e.displayModels[o.key]?.secondaryMetricsTextColor??"var(--kip-contrast-color)").text(o=>e.displayModels[o.key]?.metricsLineTwo??""),a.exit().remove();}displayName(e){return e.name?.trim()||e.id}resolveTitleText(e){return e.name||`AC ${e.id}`}resolveModeText(e){return e.mode?`Mode ${e.mode}`:"Mode -"}buildMetricRows(e){let i=this.cardMode(),t=(i.metrics.length?i.metrics:l.DEFAULT_CONFIG.ac?.cardMode?.metrics??[]).map(c=>this.toMetricLabel(c,e)).filter(c=>!!c);if(!t.length)return ["L1 - - -","L2 - - L3 - -"];let r=t.slice(0,2).join(" "),s=t.slice(2,4).join(" ");return [r||" ",s||" "]}toMetricLabel(e,i){switch(e){case "line1Voltage":return `L1V ${this.formatValue(i.line1Voltage,"V")}`;case "line1Current":return `L1A ${this.formatValue(i.line1Current,"A")}`;case "line1Frequency":return `L1Hz ${this.formatValue(i.line1Frequency,"Hz")}`;case "line2Voltage":return `L2V ${this.formatValue(i.line2Voltage,"V")}`;case "line2Current":return `L2A ${this.formatValue(i.line2Current,"A")}`;case "line2Frequency":return `L2Hz ${this.formatValue(i.line2Frequency,"Hz")}`;case "line3Voltage":return `L3V ${this.formatValue(i.line3Voltage,"V")}`;case "line3Current":return `L3A ${this.formatValue(i.line3Current,"A")}`;case "line3Frequency":return `L3Hz ${this.formatValue(i.line3Frequency,"Hz")}`;default:return null}}formatValue(e,i){return e==null||Number.isNaN(e)?"-":`${e.toFixed(1)} ${i}`}toStringValue(e){return typeof e=="string"?e:null}resolveMostSevereState(...e){return e.some(i=>i===n$1.Alert)?n$1.Alert:e.some(i=>i===n$1.Alarm)?n$1.Alarm:e.some(i=>i===n$1.Warn)?n$1.Warn:e.some(i=>i===n$1.Normal)?n$1.Normal:null}toNumber(e,i){if(e==null||typeof e=="boolean")return null;let t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return null;let r=this.units.convertToUnit(i,t);return typeof r=="number"&&Number.isFinite(r)?r:null}static \u0275fac=function(i){return new(i||l)};static \u0275cmp=JD({type:l,selectors:[["widget-ac"]],viewQuery:function(i,t){i&1&&eg(t.svgRef,ie,5),i&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["acSvg",""],[3,"text","color"],["aria-hidden","false",1,"ac-svg"],[1,"ac-empty"],[1,"ac-empty-title"],[1,"ac-empty-sub"]],template:function(i,t){i&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,re,5,0,"div",3)),i&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasBuses()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.ac-svg[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;z-index:20;padding:0 10px 10px}.ac-empty[_ngcontent-%COMP%]{position:absolute;inset:0;margin:10px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;text-align:center;color:var(--mat-sys-on-surface);background:color-mix(in srgb,var(--kip-widget-card-background-color) 92%,transparent)}.ac-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.ac-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{Y as WidgetAcComponent};
@@ -1 +1 @@
1
- import {a as a$1}from'./chunk-DVB9tiW3.js';import {d1 as Hj,w,du as p,G as Gi,N,aX as He,a as G,$ as $j,W as Wp,F as Fa,dn as ge,J as JD,_ as _w,M as Mw,f as eg,K as Kw,H as Dr,eb as rw,cp as Uh,bD as HT,g as qw,b_ as Gh,bE as $T,ci as dl,cj as fl,e as EE,dP as pp}from'./main-BNR44HGB.js';var R=(()=>{class n{sanitizer=w(Dr);transform(e){return this.sanitizer.bypassSecurityTrustResourceUrl(e)}static \u0275fac=function(t){return new(t||n)};static \u0275pipe=rw({name:"safe",type:n,pure:true})}return n})();var $=["freeboardSkIframe"];function z(n,v){if(n&1&&(Uh(0,"iframe",1,0),HT(2,"safe")),n&2){let e=qw();Gh("src",$T(2,1,e.widgetUrlSafe),pp);}}function A(n,v){n&1&&Uh(0,"div",4);}function B(n,v){if(n&1&&(dl(0,"div",2),Uh(1,"iframe",3,0),HT(3,"safe"),_w(4,A,1,0,"div",4),fl()),n&2){let e=qw();EE(),Gh("src",$T(3,2,e.widgetUrlSafe),pp),EE(3),Mw(e.dashboard.isDashboardStatic()?-1:4);}}var ae=(()=>{class n{id=Hj();type=Hj();theme=Hj();disableWidgetShell=Hj(false);swipeDisabled=Hj(false);runtime=w(p,{optional:true});appSettings=w(Gi);app=w(N);auth=w(He);dashboard=w(G);iframe=$j.required("freeboardSkIframe");authToken=Wp(this.auth.authToken$,{initialValue:null});viewReady=false;iframeLoaded=false;widgetUrl=null;widgetUrlSafe="";static DEFAULT_CONFIG={};constructor(){window.addEventListener("message",this.handleIframeGesture),Fa(()=>{let e=this.authToken();ge(()=>{let t=e?.token,i=this.appSettings.signalkUrl?.url;this.widgetUrl=i?t?`${i}/@signalk/freeboard-sk/?token=${t}`:`${i}/@signalk/freeboard-sk/`:null,this.widgetUrlSafe=this.widgetUrl??"";});}),Fa(()=>{let e=this.app.isNightMode();ge(()=>{!this.iframeLoaded||!this.viewReady||this.appSettings.getRedNightMode()&&this.sendMessage({commands:{nightModeEnable:e}});});});}ngAfterViewInit(){this.viewReady=true;try{this.iframe().nativeElement.onload=()=>{this.iframeLoaded=!0,this.sendMessage({settings:{autoNightMode:!1}}),this.injectSwipeScript();};}catch(e){}}sendMessage(e,t="*"){let i=this.iframe()?.nativeElement?.contentWindow;i&&this.iframeLoaded&&i.postMessage(e,t);}injectSwipeScript(){if(this.swipeDisabled())return;let e=this.iframe().nativeElement.contentWindow,t=this.iframe().nativeElement.contentDocument;if(!t||!e){console.error("[FSK Widget] Iframe contentDocument or contentWindow is undefined.");return}try{let i=`kip-gesture-inject-${this.id()}`;if(t.getElementById(i))return;let s=a$1({instanceId:this.id()}),r=t.createElement("script");r.id=i,r.textContent=s,t.body.appendChild(r);}catch(i){console.warn("[FSK Widget] Failed to inject swipe script into iframe:",i);}}handleIframeGesture=e=>{if(!e.data||!this.viewReady)return;let t=null;try{t=this.iframe()?.nativeElement?.contentWindow??null;}catch(r){t=null;}if(!t||e.source!==t)return;let i=this.getExpectedIframeOrigin();if(i&&e.origin!==i)return;let s=this.id();if(e.data.gesture&&e.data.eventData?.instanceId===s)switch(e.data.gesture){case "swipeup":this.dashboard.isDashboardStatic()&&this.dashboard.navigateToPreviousDashboard();break;case "swipedown":this.dashboard.isDashboardStatic()&&this.dashboard.navigateToNextDashboard();break;case "swipeleft":window.document.dispatchEvent(new Event("openLeftSidenav",{bubbles:true,cancelable:true}));break;case "swiperight":window.document.dispatchEvent(new Event("openRightSidenav",{bubbles:true,cancelable:true}));break}if(e.data.type==="keydown"&&e.data.keyEventData?.instanceId===s){let{key:r,ctrlKey:L,shiftKey:O}=e.data.keyEventData,P=new KeyboardEvent("keydown",{key:r,ctrlKey:L,shiftKey:O,bubbles:true,cancelable:true});document.dispatchEvent(P);}};getExpectedIframeOrigin(){let e=this.widgetUrl||this.appSettings.signalkUrl?.url;if(!e)return null;try{return new URL(e).origin}catch(t){return null}}ngOnDestroy(){if(window.removeEventListener("message",this.handleIframeGesture),this.iframe){try{this.iframe().nativeElement.onload=null;}catch(e){}try{let e=this.iframe()?.nativeElement.contentDocument;if(e){let t=`kip-gesture-inject-${this.id()}`,i=e.getElementById(t);i&&i.parentNode&&i.parentNode.removeChild(i);}}catch(e){}}}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=JD({type:n,selectors:[["widget-freeboardsk"]],viewQuery:function(t,i){t&1&&eg(i.iframe,$,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],disableWidgetShell:[1,"disableWidgetShell"],swipeDisabled:[1,"swipeDisabled"]},decls:2,vars:1,consts:[["freeboardSkIframe",""],["width","100%","height","100%","frameborder","0","sandbox","allow-same-origin allow-scripts allow-forms",1,"freeboardsk-iframe","no-shell",3,"src"],[1,"widget-shell",2,"overflow","clip","position","relative","width","100%","height","100%"],["width","100%","height","100%","frameborder","0","sandbox","allow-same-origin allow-scripts allow-forms",1,"freeboardsk-iframe",3,"src"],[1,"widgetOverlay"]],template:function(t,i){t&1&&_w(0,z,3,3,"iframe",1)(1,B,5,4,"div",2),t&2&&Mw(i.disableWidgetShell()?0:1);},dependencies:[R],styles:[".widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent}"]})}return n})();export{ae as WidgetFreeboardskComponent};
1
+ import {a as a$1}from'./chunk-ibauGmSP.js';import {d1 as Hj,w,du as p,G as Gi,N,aX as He,a as G,$ as $j,W as Wp,F as Fa,dn as ge,J as JD,_ as _w,M as Mw,f as eg,K as Kw,H as Dr,eb as rw,cp as Uh,bD as HT,g as qw,b_ as Gh,bE as $T,ci as dl,cj as fl,e as EE,dP as pp}from'./main-YKDNK5VZ.js';var R=(()=>{class n{sanitizer=w(Dr);transform(e){return this.sanitizer.bypassSecurityTrustResourceUrl(e)}static \u0275fac=function(t){return new(t||n)};static \u0275pipe=rw({name:"safe",type:n,pure:true})}return n})();var $=["freeboardSkIframe"];function z(n,v){if(n&1&&(Uh(0,"iframe",1,0),HT(2,"safe")),n&2){let e=qw();Gh("src",$T(2,1,e.widgetUrlSafe),pp);}}function A(n,v){n&1&&Uh(0,"div",4);}function B(n,v){if(n&1&&(dl(0,"div",2),Uh(1,"iframe",3,0),HT(3,"safe"),_w(4,A,1,0,"div",4),fl()),n&2){let e=qw();EE(),Gh("src",$T(3,2,e.widgetUrlSafe),pp),EE(3),Mw(e.dashboard.isDashboardStatic()?-1:4);}}var ae=(()=>{class n{id=Hj();type=Hj();theme=Hj();disableWidgetShell=Hj(false);swipeDisabled=Hj(false);runtime=w(p,{optional:true});appSettings=w(Gi);app=w(N);auth=w(He);dashboard=w(G);iframe=$j.required("freeboardSkIframe");authToken=Wp(this.auth.authToken$,{initialValue:null});viewReady=false;iframeLoaded=false;widgetUrl=null;widgetUrlSafe="";static DEFAULT_CONFIG={};constructor(){window.addEventListener("message",this.handleIframeGesture),Fa(()=>{let e=this.authToken();ge(()=>{let t=e?.token,i=this.appSettings.signalkUrl?.url;this.widgetUrl=i?t?`${i}/@signalk/freeboard-sk/?token=${t}`:`${i}/@signalk/freeboard-sk/`:null,this.widgetUrlSafe=this.widgetUrl??"";});}),Fa(()=>{let e=this.app.isNightMode();ge(()=>{!this.iframeLoaded||!this.viewReady||this.appSettings.getRedNightMode()&&this.sendMessage({commands:{nightModeEnable:e}});});});}ngAfterViewInit(){this.viewReady=true;try{this.iframe().nativeElement.onload=()=>{this.iframeLoaded=!0,this.sendMessage({settings:{autoNightMode:!1}}),this.injectSwipeScript();};}catch(e){}}sendMessage(e,t="*"){let i=this.iframe()?.nativeElement?.contentWindow;i&&this.iframeLoaded&&i.postMessage(e,t);}injectSwipeScript(){if(this.swipeDisabled())return;let e=this.iframe().nativeElement.contentWindow,t=this.iframe().nativeElement.contentDocument;if(!t||!e){console.error("[FSK Widget] Iframe contentDocument or contentWindow is undefined.");return}try{let i=`kip-gesture-inject-${this.id()}`;if(t.getElementById(i))return;let s=a$1({instanceId:this.id()}),r=t.createElement("script");r.id=i,r.textContent=s,t.body.appendChild(r);}catch(i){console.warn("[FSK Widget] Failed to inject swipe script into iframe:",i);}}handleIframeGesture=e=>{if(!e.data||!this.viewReady)return;let t=null;try{t=this.iframe()?.nativeElement?.contentWindow??null;}catch(r){t=null;}if(!t||e.source!==t)return;let i=this.getExpectedIframeOrigin();if(i&&e.origin!==i)return;let s=this.id();if(e.data.gesture&&e.data.eventData?.instanceId===s)switch(e.data.gesture){case "swipeup":this.dashboard.isDashboardStatic()&&this.dashboard.navigateToPreviousDashboard();break;case "swipedown":this.dashboard.isDashboardStatic()&&this.dashboard.navigateToNextDashboard();break;case "swipeleft":window.document.dispatchEvent(new Event("openLeftSidenav",{bubbles:true,cancelable:true}));break;case "swiperight":window.document.dispatchEvent(new Event("openRightSidenav",{bubbles:true,cancelable:true}));break}if(e.data.type==="keydown"&&e.data.keyEventData?.instanceId===s){let{key:r,ctrlKey:L,shiftKey:O}=e.data.keyEventData,P=new KeyboardEvent("keydown",{key:r,ctrlKey:L,shiftKey:O,bubbles:true,cancelable:true});document.dispatchEvent(P);}};getExpectedIframeOrigin(){let e=this.widgetUrl||this.appSettings.signalkUrl?.url;if(!e)return null;try{return new URL(e).origin}catch(t){return null}}ngOnDestroy(){if(window.removeEventListener("message",this.handleIframeGesture),this.iframe){try{this.iframe().nativeElement.onload=null;}catch(e){}try{let e=this.iframe()?.nativeElement.contentDocument;if(e){let t=`kip-gesture-inject-${this.id()}`,i=e.getElementById(t);i&&i.parentNode&&i.parentNode.removeChild(i);}}catch(e){}}}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=JD({type:n,selectors:[["widget-freeboardsk"]],viewQuery:function(t,i){t&1&&eg(i.iframe,$,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],disableWidgetShell:[1,"disableWidgetShell"],swipeDisabled:[1,"swipeDisabled"]},decls:2,vars:1,consts:[["freeboardSkIframe",""],["width","100%","height","100%","frameborder","0","sandbox","allow-same-origin allow-scripts allow-forms",1,"freeboardsk-iframe","no-shell",3,"src"],[1,"widget-shell",2,"overflow","clip","position","relative","width","100%","height","100%"],["width","100%","height","100%","frameborder","0","sandbox","allow-same-origin allow-scripts allow-forms",1,"freeboardsk-iframe",3,"src"],[1,"widgetOverlay"]],template:function(t,i){t&1&&_w(0,z,3,3,"iframe",1)(1,B,5,4,"div",2),t&2&&Mw(i.disableWidgetShell()?0:1);},dependencies:[R],styles:[".widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent}"]})}return n})();export{ae as WidgetFreeboardskComponent};
@@ -1 +1 @@
1
- import {d1 as Hj,w,du as p,dv as rt$1,cu as T,a as G,aZ as R,aY as xe,$ as $j,v as vt,bG as Bj,D as Dt,F as Fa,dn as ge,a_ as Gp,J as JD,b2 as Ln,b4 as Xe,b5 as Pn,b9 as rn,O as Op,bh as xp,y as yt,b as wt,cR as zt,bg as mt$1,bd as an,P as Pi,c as $h,u as ul,k as Qh,cn as wd,T as TT,_ as _w,e as EE,M as Mw,f as eg,K as Kw,g as qw,bp as gl,h as Fw,cV as Td,bi as Eg,bk as cD,bm as Ig,bo as lD,l as ud,m as dd,bj as ST}from'./main-BNR44HGB.js';import {c}from'./chunk-D_wrJJxl.js';var at=["canvasMainRef"];function ot(o,v){if(o&1&&(Pi(0,"div",8),wd(),Pi(1,"svg",11)(2,"text",12),TT(3),ul()()()),o&2){let t=qw();EE(3),gl("@ ",t.startAtTime());}}function st(o,v){if(o&1){let t=Fw();Pi(0,"button",13),Qh("click",function(){ud(t);let i=qw();return dd(i.sendStartTimerCommand("start"))}),Pi(1,"mat-icon",5),wd(),Pi(2,"svg",6)(3,"text",14),TT(4,"Start"),ul()()()(),Td(),Pi(5,"button",15),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(-60))}),Pi(6,"mat-icon",5),wd(),Pi(7,"svg",6)(8,"text",14),TT(9,"-1m"),ul()()()(),Td(),Pi(10,"button",16),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(60))}),Pi(11,"mat-icon",5),wd(),Pi(12,"svg",6)(13,"text",14),TT(14,"+1m"),ul()()()();}}function rt(o,v){if(o&1){let t=Fw();Pi(0,"button",17),Qh("click",function(){ud(t);let i=qw();return dd(i.sendStartTimerCommand("sync"))}),Pi(1,"mat-icon",5),wd(),Pi(2,"svg",18)(3,"text",19),TT(4,"Sync"),ul()()()(),Td(),Pi(5,"button",20),Qh("click",function(){ud(t);let i=qw();return dd(i.sendStartTimerCommand("reset"))}),Pi(6,"mat-icon",5),wd(),Pi(7,"svg",18)(8,"text",19),TT(9,"Reset"),ul()()()();}}function lt(o,v){if(o&1){let t=Fw();Pi(0,"button",21),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(-60))}),Pi(1,"mat-icon",5),wd(),Pi(2,"svg",22)(3,"text",23),TT(4,"-1m"),ul()()()(),Td(),Pi(5,"button",24),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(-1))}),Pi(6,"mat-icon",5),wd(),Pi(7,"svg",22)(8,"text",23),TT(9,"-1s"),ul()()()(),Td(),Pi(10,"button",25),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(1))}),Pi(11,"mat-icon",5),wd(),Pi(12,"svg",22)(13,"text",23),TT(14,"+1s"),ul()()()(),Td(),Pi(15,"button",26),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(60))}),Pi(16,"mat-icon",5),wd(),Pi(17,"svg",22)(18,"text",23),TT(19,"+1m"),ul()()()();}}function mt(o,v){if(o&1){let t=Fw();Pi(0,"input",27),Eg("ngModelChange",function(i){ud(t);let a=qw();return ST(a.startAtTimeEdit,i)||(a.startAtTimeEdit=i),dd(i)}),Qh("change",function(){ud(t);let i=qw();return dd(i.setStartTime())}),ul(),cD();}if(o&2){let t=qw();Ig("ngModel",t.startAtTimeEdit),lD();}}function ct(o,v){o&1&&$h(0,"div",10);}var Et=(()=>{class o{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:false,displayName:"TTS",nextDashboard:0,playBeeps:true,filterSelfPaths:true,paths:{ttsPath:{description:"Time to the Start in seconds",path:"self.navigation.racing.timeToStart",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"s",showConvertUnitTo:false,showPathSkUnitsFilter:false,pathSkUnitsFilter:"s",sampleTime:500},startTimePath:{description:"Time of the start",path:"self.navigation.racing.startTime",source:"default",pathType:"Date",pathRequired:false,isPathConfigurable:false,sampleTime:500},dtsPath:{description:"Distance to Start Line path, used to determine OCS",path:"self.navigation.racing.distanceStartline",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:false,pathSkUnitsFilter:"m",sampleTime:500}},color:"contrast",enableTimeout:false,dataTimeout:5,ignoreZones:true};runtime=w(p);streams=w(rt$1);signalk=w(T);dashboard=w(G);canvas=w(R);destroyRef=w(xe);canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;titleBitmap=null;titleBitmapText=null;titleBitmapColor=null;labelColor=vt("");mode=vt(1);ttsValue=null;dtsValue=null;valueColor="";valueStateColor="";startAtTime=vt("00:00:00");startAtTimeEdit=Bj("");normalizedConfig=Dt(()=>this.runtime.options()??o.DEFAULT_CONFIG);constructor(){Fa(()=>{let t=this.normalizedConfig(),e=this.theme();e&&ge(()=>{let i=c(t.color??"contrast",e);this.labelColor.set(i.dim),this.valueColor=i.color,this.valueStateColor=i.color,this.draw();});}),Fa(()=>{let t=this.normalizedConfig();t.paths?.ttsPath?.path&&ge(()=>this.streams.observe("ttsPath",a=>{let s=this.ttsValue;this.ttsValue=a?.data?.value??null,this.updateValueColor(),this.draw(),this.shouldBeep(s,this.ttsValue)&&this.beepForValue(this.ttsValue),(t.nextDashboard??-1)>=0&&s===1&&this.ttsValue===0&&(!this.dtsValue||this.dtsValue>=0);}));}),Fa(()=>{this.normalizedConfig().paths?.startTimePath?.path&&ge(()=>this.streams.observe("startTimePath",a=>{let s=a?.data?.value;if(!s)this.startAtTime.set("HH:MM:SS"),this.startAtTimeEdit.set("HH:MM:SS"),this.mode()===2&&this.mode.set(1);else {let l=new Date(s);this.startAtTimeEdit.set(l.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})),this.startAtTime.set(this.startAtTimeEdit());}this.draw();}));}),Fa(()=>{this.normalizedConfig().paths?.dtsPath?.path&&ge(()=>this.streams.observe("dtsPath",a=>{this.dtsValue=a?.data?.value??null;}));}),this.signalk.subscribeRequest().pipe(Gp(this.destroyRef)).subscribe(t=>{t.widgetUUID===this.id()&&t.statusCode===200&&this.beep(600,20);});}ngAfterViewInit(){this.canvasElement=this.canvasRef().nativeElement,this.ctx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(t,e)=>{this.cssWidth=t,this.cssHeight=e,this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.draw();}ngOnDestroy(){try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(t){}}toggleMode(){this.mode.update(e=>(e+1)%5);let t=this.ttsValue;this.mode()===1&&this.isStartTimerRunning()&&this.mode.set(2),this.mode()===2&&t!==0&&!this.isStartTimerRunning()&&this.mode.set(3),this.draw();}sendStartTimerCommand(t){this.signalk.putRequest("navigation.racing.setStartTime",{command:t},this.id()),t==="start"&&this.mode.set(0),t==="reset"&&(this.startAtTime.set("HH:MM:SS"),this.mode.set(1));}adjustStartTime(t){this.signalk.putRequest("navigation.racing.setStartTime",{command:"adjust",delta:t},this.id());}setStartTime(){let t=new Date,e=this.startAtTimeEdit().split(":").map(Number),i=e[0],a=e[1],s=e.length>=3?e[2]:0,l=new Date(t);l.setHours(i,a,s,0),l<=t&&l.setDate(l.getDate()+1),this.mode.set(0),this.signalk.putRequest("navigation.racing.setStartTime",{command:"set",startTime:l.toISOString()},this.id());}isStartTimerRunning(){return (this.ttsValue??0)>0&&this.startAtTime()!==null&&this.startAtTime()!=="HH:MM:SS"}shouldBeep(t,e){return e==null||this.startAtTime()==="HH:MM:SS"||!this.runtime.options()?.playBeeps?false:e===0&&t!==0||e<10&&e>=0||e<60&&e%10===0?true:e%60===0}beepForValue(t){t===0?this.beep(500,1e3):t<10?this.beep(450,100):t<60&&t%10===0?this.beep(400,150):t%60===0&&this.beep(350,200);}updateValueColor(){let t=this.theme(),e=this.normalizedConfig();t&&(e.ignoreZones?this.ttsValue?this.ttsValue===0?this.valueStateColor=this.valueColor:this.ttsValue<10?this.valueStateColor=(this.dtsValue??0)<0?t.zoneAlarm:t.zoneWarn:this.ttsValue<60?this.valueStateColor=t.zoneAlert:this.valueStateColor=this.valueColor:this.valueStateColor=this.valueColor:this.valueStateColor=this.valueColor,this.ttsValue===0?(this.mode.set(2),(this.dtsValue??0)<0&&(this.valueStateColor=t.zoneAlarm)):this.mode()===1&&this.isStartTimerRunning()&&this.mode.set(2));}toHHMMSS(t){if(t==null||isNaN(t))return "-:--";let e=t<0;e&&(t=-t);let i=Math.floor(t/3600),a=Math.floor(t%3600/60),s=Math.floor(t%60),l=e?"-":"";return i===0?`${l}${a.toString().padStart(1,"0")}:${s.toString().padStart(2,"0")}`:`${l}${i.toString().padStart(1,"0")}:${a.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`}getValueText(){return this.toHHMMSS(this.ttsValue??0)}draw(){if(!this.ctx||!this.canvasElement)return;let e=this.runtime.options()?.displayName||"TTS",i=this.labelColor();(!this.titleBitmap||this.titleBitmap.width!==this.canvasElement.width||this.titleBitmap.height!==this.canvasElement.height||this.titleBitmapText!==e||this.titleBitmapColor!==i)&&(this.titleBitmap=this.canvas.createTitleBitmap(e,i,"normal",this.cssWidth,this.cssHeight),this.titleBitmapText=e,this.titleBitmapColor=i),this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),this.titleBitmap&&this.ctx.drawImage(this.titleBitmap,0,0,this.cssWidth,this.cssHeight),this.canvas.drawText(this.ctx,this.getValueText(),Math.floor(this.cssWidth*.5),Math.floor(this.cssHeight*.55),Math.floor(this.cssWidth*.95),Math.floor(this.cssHeight*.9),"bold",this.valueStateColor,"center","middle");}beep(t=440,e=100){if(!this.runtime.options()?.playBeeps)return;let i=window.AudioContext||window.webkitAudioContext,a=new i,s=a.createOscillator(),l=a.createGain();s.connect(l),l.connect(a.destination),s.type="sine",s.frequency.value=t,l.gain.value=.1,s.start(),s.stop(a.currentTime+e/1e3);}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=JD({type:o,selectors:[["widget-racer-timer"]],viewQuery:function(e,i){e&1&&eg(i.canvasRef,at,5),e&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],startAtTimeEdit:[1,"startAtTimeEdit"]},outputs:{startAtTimeEdit:"startAtTimeEditChange"},decls:15,vars:2,consts:[["canvasMainRef",""],[1,"filler"],[1,"timer-canvas"],[1,"buttons-container"],["mat-flat-button","","matTooltip","Select the control mode",1,"button","select-button",3,"click"],[1,"buttons-svg-icon"],["width","100%","height","100%","viewBox","0 0 80 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","40","y","9"],[1,"start-at"],["matInput","","type","time","step","1","matTooltip","Set an absolute start time",1,"set-start-at",3,"ngModel"],[1,"widgetOverlay"],["width","100%","height","100%","viewBox","0 0 80 12","preserveAspectRatio","xMidYMid meet",1,"svg-content","svg-start-at"],["x","40","y","10"],["mat-flat-button","","matTooltip","Start the race timer",1,"button","main-button",3,"click"],["x","40","y","11"],["mat-flat-button","","matTooltip","Remove 1 minute from the timer",1,"button","other-small-button",3,"click"],["mat-flat-button","","matTooltip","Add 1 minute to the timer",1,"button","other-small-button",3,"click"],["mat-flat-button","","matTooltip","Sync the timer to nearest minute",1,"button","main-button",3,"click"],["width","100%","height","100%","viewBox","0 0 100 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","50","y","11"],["mat-flat-button","","matTooltip","Stop and reset the timer",1,"button","other-button",3,"click"],["mat-flat-button","","matTooltip","Reduce the timer by 1 minute",1,"button","main-small-button",3,"click"],["width","100%","height","100%","viewBox","0 0 50 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","25","y","11"],["mat-flat-button","","matTooltip","Reduce the timer by 1 second",1,"button","other-small-button",3,"click"],["mat-flat-button","","matTooltip","Increase the timer by 1 second",1,"button","other-small-button",3,"click"],["mat-flat-button","","matTooltip","Increase the timer by 1 minute",1,"button","main-small-button",3,"click"],["matInput","","type","time","step","1","matTooltip","Set an absolute start time",1,"set-start-at",3,"ngModelChange","change","ngModel"]],template:function(e,i){if(e&1&&(Pi(0,"div",1),$h(1,"canvas",2,0),ul(),Pi(3,"div",3)(4,"button",4),Qh("click",function(){return i.toggleMode()}),Pi(5,"mat-icon",5),wd(),Pi(6,"svg",6)(7,"text",7),TT(8,"\u22EE"),ul()()()(),_w(9,ot,4,1,"div",8)(10,st,15,0)(11,rt,10,0)(12,lt,20,0)(13,mt,1,1,"input",9),ul(),_w(14,ct,1,0,"div",10)),e&2){let a;EE(9),Mw((a=i.mode())===0?9:a===1?10:a===2?11:a===3?12:a===4?13:-1),EE(5),Mw(i.dashboard.isDashboardStatic()?-1:14);}},dependencies:[Ln,Xe,Pn,rn,Op,xp,yt,wt,zt,mt$1,an],styles:["[_nghost-%COMP%]{overflow:clip;display:block;height:100%;width:100%}.timer-wrapper[_ngcontent-%COMP%]{width:100%;height:100%;min-height:1px}.timer-canvas[_ngcontent-%COMP%]{width:100%!important;height:100%!important;display:block}.filler[_ngcontent-%COMP%]{width:100%;height:76%}.buttons-container[_ngcontent-%COMP%]{display:flex;flex-wrap:nowrap;justify-content:space-between;column-gap:2%;position:relative;height:24%;width:100%;padding:0 10px 14px;z-index:20;pointer-events:auto;align-items:center}.button[_ngcontent-%COMP%]{min-width:0px;width:100%;border-radius:12px;align-items:center;justify-content:center;cursor:pointer;--mat-button-filled-container-height: 100%;--mat-button-filled-horizontal-padding: 0px;--mat-button-filled-icon-spacing: 0px}.select-button[_ngcontent-%COMP%]{flex:none;width:18%;--mat-button-filled-container-color: var(--kip-blue-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.main-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.other-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-blue-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.main-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.other-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-blue-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.set-start-at[_ngcontent-%COMP%]{flex:1 1 auto;background-color:var(--kip-contrast-color)}.start-at[_ngcontent-%COMP%]{height:100%;width:100%;flex:1 1 auto}.start-at[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{fill:var(--kip-contrast-color)}.start-at[_ngcontent-%COMP%] svg[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-family:Roboto;font-size:9px;font-weight:400;text-align:center;text-anchor:middle;font-style:normal;font-variant:normal;font-stretch:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke:none}.buttons-svg-icon[_ngcontent-%COMP%]{width:100%;height:100%;margin:0;padding:0}.svg-content[_ngcontent-%COMP%]{width:100%;height:100%;padding:0;margin:0}.svg-content[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-family:Roboto;font-size:15px;font-weight:700;text-align:center;text-anchor:middle;font-style:normal;font-variant:normal;font-stretch:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke:none}.svg-start-at[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{fill:var(--kip-contrast-dim-color)}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent;z-index:21}"]})}return o})();export{Et as WidgetRacerTimerComponent};
1
+ import {d1 as Hj,w,du as p,dv as rt$1,cu as T,a as G,aZ as R,aY as xe,$ as $j,v as vt,bG as Bj,D as Dt,F as Fa,dn as ge,a_ as Gp,J as JD,b2 as Ln,b4 as Xe,b5 as Pn,b9 as rn,O as Op,bh as xp,y as yt,b as wt,cR as zt,bg as mt$1,bd as an,P as Pi,c as $h,u as ul,k as Qh,cn as wd,T as TT,_ as _w,e as EE,M as Mw,f as eg,K as Kw,g as qw,bp as gl,h as Fw,cV as Td,bi as Eg,bk as cD,bm as Ig,bo as lD,l as ud,m as dd,bj as ST}from'./main-YKDNK5VZ.js';import {c}from'./chunk-BIb-xYiS.js';var at=["canvasMainRef"];function ot(o,v){if(o&1&&(Pi(0,"div",8),wd(),Pi(1,"svg",11)(2,"text",12),TT(3),ul()()()),o&2){let t=qw();EE(3),gl("@ ",t.startAtTime());}}function st(o,v){if(o&1){let t=Fw();Pi(0,"button",13),Qh("click",function(){ud(t);let i=qw();return dd(i.sendStartTimerCommand("start"))}),Pi(1,"mat-icon",5),wd(),Pi(2,"svg",6)(3,"text",14),TT(4,"Start"),ul()()()(),Td(),Pi(5,"button",15),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(-60))}),Pi(6,"mat-icon",5),wd(),Pi(7,"svg",6)(8,"text",14),TT(9,"-1m"),ul()()()(),Td(),Pi(10,"button",16),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(60))}),Pi(11,"mat-icon",5),wd(),Pi(12,"svg",6)(13,"text",14),TT(14,"+1m"),ul()()()();}}function rt(o,v){if(o&1){let t=Fw();Pi(0,"button",17),Qh("click",function(){ud(t);let i=qw();return dd(i.sendStartTimerCommand("sync"))}),Pi(1,"mat-icon",5),wd(),Pi(2,"svg",18)(3,"text",19),TT(4,"Sync"),ul()()()(),Td(),Pi(5,"button",20),Qh("click",function(){ud(t);let i=qw();return dd(i.sendStartTimerCommand("reset"))}),Pi(6,"mat-icon",5),wd(),Pi(7,"svg",18)(8,"text",19),TT(9,"Reset"),ul()()()();}}function lt(o,v){if(o&1){let t=Fw();Pi(0,"button",21),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(-60))}),Pi(1,"mat-icon",5),wd(),Pi(2,"svg",22)(3,"text",23),TT(4,"-1m"),ul()()()(),Td(),Pi(5,"button",24),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(-1))}),Pi(6,"mat-icon",5),wd(),Pi(7,"svg",22)(8,"text",23),TT(9,"-1s"),ul()()()(),Td(),Pi(10,"button",25),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(1))}),Pi(11,"mat-icon",5),wd(),Pi(12,"svg",22)(13,"text",23),TT(14,"+1s"),ul()()()(),Td(),Pi(15,"button",26),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustStartTime(60))}),Pi(16,"mat-icon",5),wd(),Pi(17,"svg",22)(18,"text",23),TT(19,"+1m"),ul()()()();}}function mt(o,v){if(o&1){let t=Fw();Pi(0,"input",27),Eg("ngModelChange",function(i){ud(t);let a=qw();return ST(a.startAtTimeEdit,i)||(a.startAtTimeEdit=i),dd(i)}),Qh("change",function(){ud(t);let i=qw();return dd(i.setStartTime())}),ul(),cD();}if(o&2){let t=qw();Ig("ngModel",t.startAtTimeEdit),lD();}}function ct(o,v){o&1&&$h(0,"div",10);}var Et=(()=>{class o{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:false,displayName:"TTS",nextDashboard:0,playBeeps:true,filterSelfPaths:true,paths:{ttsPath:{description:"Time to the Start in seconds",path:"self.navigation.racing.timeToStart",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"s",showConvertUnitTo:false,showPathSkUnitsFilter:false,pathSkUnitsFilter:"s",sampleTime:500},startTimePath:{description:"Time of the start",path:"self.navigation.racing.startTime",source:"default",pathType:"Date",pathRequired:false,isPathConfigurable:false,sampleTime:500},dtsPath:{description:"Distance to Start Line path, used to determine OCS",path:"self.navigation.racing.distanceStartline",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:false,pathSkUnitsFilter:"m",sampleTime:500}},color:"contrast",enableTimeout:false,dataTimeout:5,ignoreZones:true};runtime=w(p);streams=w(rt$1);signalk=w(T);dashboard=w(G);canvas=w(R);destroyRef=w(xe);canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;titleBitmap=null;titleBitmapText=null;titleBitmapColor=null;labelColor=vt("");mode=vt(1);ttsValue=null;dtsValue=null;valueColor="";valueStateColor="";startAtTime=vt("00:00:00");startAtTimeEdit=Bj("");normalizedConfig=Dt(()=>this.runtime.options()??o.DEFAULT_CONFIG);constructor(){Fa(()=>{let t=this.normalizedConfig(),e=this.theme();e&&ge(()=>{let i=c(t.color??"contrast",e);this.labelColor.set(i.dim),this.valueColor=i.color,this.valueStateColor=i.color,this.draw();});}),Fa(()=>{let t=this.normalizedConfig();t.paths?.ttsPath?.path&&ge(()=>this.streams.observe("ttsPath",a=>{let s=this.ttsValue;this.ttsValue=a?.data?.value??null,this.updateValueColor(),this.draw(),this.shouldBeep(s,this.ttsValue)&&this.beepForValue(this.ttsValue),(t.nextDashboard??-1)>=0&&s===1&&this.ttsValue===0&&(!this.dtsValue||this.dtsValue>=0);}));}),Fa(()=>{this.normalizedConfig().paths?.startTimePath?.path&&ge(()=>this.streams.observe("startTimePath",a=>{let s=a?.data?.value;if(!s)this.startAtTime.set("HH:MM:SS"),this.startAtTimeEdit.set("HH:MM:SS"),this.mode()===2&&this.mode.set(1);else {let l=new Date(s);this.startAtTimeEdit.set(l.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})),this.startAtTime.set(this.startAtTimeEdit());}this.draw();}));}),Fa(()=>{this.normalizedConfig().paths?.dtsPath?.path&&ge(()=>this.streams.observe("dtsPath",a=>{this.dtsValue=a?.data?.value??null;}));}),this.signalk.subscribeRequest().pipe(Gp(this.destroyRef)).subscribe(t=>{t.widgetUUID===this.id()&&t.statusCode===200&&this.beep(600,20);});}ngAfterViewInit(){this.canvasElement=this.canvasRef().nativeElement,this.ctx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(t,e)=>{this.cssWidth=t,this.cssHeight=e,this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.draw();}ngOnDestroy(){try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(t){}}toggleMode(){this.mode.update(e=>(e+1)%5);let t=this.ttsValue;this.mode()===1&&this.isStartTimerRunning()&&this.mode.set(2),this.mode()===2&&t!==0&&!this.isStartTimerRunning()&&this.mode.set(3),this.draw();}sendStartTimerCommand(t){this.signalk.putRequest("navigation.racing.setStartTime",{command:t},this.id()),t==="start"&&this.mode.set(0),t==="reset"&&(this.startAtTime.set("HH:MM:SS"),this.mode.set(1));}adjustStartTime(t){this.signalk.putRequest("navigation.racing.setStartTime",{command:"adjust",delta:t},this.id());}setStartTime(){let t=new Date,e=this.startAtTimeEdit().split(":").map(Number),i=e[0],a=e[1],s=e.length>=3?e[2]:0,l=new Date(t);l.setHours(i,a,s,0),l<=t&&l.setDate(l.getDate()+1),this.mode.set(0),this.signalk.putRequest("navigation.racing.setStartTime",{command:"set",startTime:l.toISOString()},this.id());}isStartTimerRunning(){return (this.ttsValue??0)>0&&this.startAtTime()!==null&&this.startAtTime()!=="HH:MM:SS"}shouldBeep(t,e){return e==null||this.startAtTime()==="HH:MM:SS"||!this.runtime.options()?.playBeeps?false:e===0&&t!==0||e<10&&e>=0||e<60&&e%10===0?true:e%60===0}beepForValue(t){t===0?this.beep(500,1e3):t<10?this.beep(450,100):t<60&&t%10===0?this.beep(400,150):t%60===0&&this.beep(350,200);}updateValueColor(){let t=this.theme(),e=this.normalizedConfig();t&&(e.ignoreZones?this.ttsValue?this.ttsValue===0?this.valueStateColor=this.valueColor:this.ttsValue<10?this.valueStateColor=(this.dtsValue??0)<0?t.zoneAlarm:t.zoneWarn:this.ttsValue<60?this.valueStateColor=t.zoneAlert:this.valueStateColor=this.valueColor:this.valueStateColor=this.valueColor:this.valueStateColor=this.valueColor,this.ttsValue===0?(this.mode.set(2),(this.dtsValue??0)<0&&(this.valueStateColor=t.zoneAlarm)):this.mode()===1&&this.isStartTimerRunning()&&this.mode.set(2));}toHHMMSS(t){if(t==null||isNaN(t))return "-:--";let e=t<0;e&&(t=-t);let i=Math.floor(t/3600),a=Math.floor(t%3600/60),s=Math.floor(t%60),l=e?"-":"";return i===0?`${l}${a.toString().padStart(1,"0")}:${s.toString().padStart(2,"0")}`:`${l}${i.toString().padStart(1,"0")}:${a.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`}getValueText(){return this.toHHMMSS(this.ttsValue??0)}draw(){if(!this.ctx||!this.canvasElement)return;let e=this.runtime.options()?.displayName||"TTS",i=this.labelColor();(!this.titleBitmap||this.titleBitmap.width!==this.canvasElement.width||this.titleBitmap.height!==this.canvasElement.height||this.titleBitmapText!==e||this.titleBitmapColor!==i)&&(this.titleBitmap=this.canvas.createTitleBitmap(e,i,"normal",this.cssWidth,this.cssHeight),this.titleBitmapText=e,this.titleBitmapColor=i),this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),this.titleBitmap&&this.ctx.drawImage(this.titleBitmap,0,0,this.cssWidth,this.cssHeight),this.canvas.drawText(this.ctx,this.getValueText(),Math.floor(this.cssWidth*.5),Math.floor(this.cssHeight*.55),Math.floor(this.cssWidth*.95),Math.floor(this.cssHeight*.9),"bold",this.valueStateColor,"center","middle");}beep(t=440,e=100){if(!this.runtime.options()?.playBeeps)return;let i=window.AudioContext||window.webkitAudioContext,a=new i,s=a.createOscillator(),l=a.createGain();s.connect(l),l.connect(a.destination),s.type="sine",s.frequency.value=t,l.gain.value=.1,s.start(),s.stop(a.currentTime+e/1e3);}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=JD({type:o,selectors:[["widget-racer-timer"]],viewQuery:function(e,i){e&1&&eg(i.canvasRef,at,5),e&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],startAtTimeEdit:[1,"startAtTimeEdit"]},outputs:{startAtTimeEdit:"startAtTimeEditChange"},decls:15,vars:2,consts:[["canvasMainRef",""],[1,"filler"],[1,"timer-canvas"],[1,"buttons-container"],["mat-flat-button","","matTooltip","Select the control mode",1,"button","select-button",3,"click"],[1,"buttons-svg-icon"],["width","100%","height","100%","viewBox","0 0 80 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","40","y","9"],[1,"start-at"],["matInput","","type","time","step","1","matTooltip","Set an absolute start time",1,"set-start-at",3,"ngModel"],[1,"widgetOverlay"],["width","100%","height","100%","viewBox","0 0 80 12","preserveAspectRatio","xMidYMid meet",1,"svg-content","svg-start-at"],["x","40","y","10"],["mat-flat-button","","matTooltip","Start the race timer",1,"button","main-button",3,"click"],["x","40","y","11"],["mat-flat-button","","matTooltip","Remove 1 minute from the timer",1,"button","other-small-button",3,"click"],["mat-flat-button","","matTooltip","Add 1 minute to the timer",1,"button","other-small-button",3,"click"],["mat-flat-button","","matTooltip","Sync the timer to nearest minute",1,"button","main-button",3,"click"],["width","100%","height","100%","viewBox","0 0 100 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","50","y","11"],["mat-flat-button","","matTooltip","Stop and reset the timer",1,"button","other-button",3,"click"],["mat-flat-button","","matTooltip","Reduce the timer by 1 minute",1,"button","main-small-button",3,"click"],["width","100%","height","100%","viewBox","0 0 50 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","25","y","11"],["mat-flat-button","","matTooltip","Reduce the timer by 1 second",1,"button","other-small-button",3,"click"],["mat-flat-button","","matTooltip","Increase the timer by 1 second",1,"button","other-small-button",3,"click"],["mat-flat-button","","matTooltip","Increase the timer by 1 minute",1,"button","main-small-button",3,"click"],["matInput","","type","time","step","1","matTooltip","Set an absolute start time",1,"set-start-at",3,"ngModelChange","change","ngModel"]],template:function(e,i){if(e&1&&(Pi(0,"div",1),$h(1,"canvas",2,0),ul(),Pi(3,"div",3)(4,"button",4),Qh("click",function(){return i.toggleMode()}),Pi(5,"mat-icon",5),wd(),Pi(6,"svg",6)(7,"text",7),TT(8,"\u22EE"),ul()()()(),_w(9,ot,4,1,"div",8)(10,st,15,0)(11,rt,10,0)(12,lt,20,0)(13,mt,1,1,"input",9),ul(),_w(14,ct,1,0,"div",10)),e&2){let a;EE(9),Mw((a=i.mode())===0?9:a===1?10:a===2?11:a===3?12:a===4?13:-1),EE(5),Mw(i.dashboard.isDashboardStatic()?-1:14);}},dependencies:[Ln,Xe,Pn,rn,Op,xp,yt,wt,zt,mt$1,an],styles:["[_nghost-%COMP%]{overflow:clip;display:block;height:100%;width:100%}.timer-wrapper[_ngcontent-%COMP%]{width:100%;height:100%;min-height:1px}.timer-canvas[_ngcontent-%COMP%]{width:100%!important;height:100%!important;display:block}.filler[_ngcontent-%COMP%]{width:100%;height:76%}.buttons-container[_ngcontent-%COMP%]{display:flex;flex-wrap:nowrap;justify-content:space-between;column-gap:2%;position:relative;height:24%;width:100%;padding:0 10px 14px;z-index:20;pointer-events:auto;align-items:center}.button[_ngcontent-%COMP%]{min-width:0px;width:100%;border-radius:12px;align-items:center;justify-content:center;cursor:pointer;--mat-button-filled-container-height: 100%;--mat-button-filled-horizontal-padding: 0px;--mat-button-filled-icon-spacing: 0px}.select-button[_ngcontent-%COMP%]{flex:none;width:18%;--mat-button-filled-container-color: var(--kip-blue-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.main-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.other-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-blue-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.main-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.other-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-blue-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.set-start-at[_ngcontent-%COMP%]{flex:1 1 auto;background-color:var(--kip-contrast-color)}.start-at[_ngcontent-%COMP%]{height:100%;width:100%;flex:1 1 auto}.start-at[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{fill:var(--kip-contrast-color)}.start-at[_ngcontent-%COMP%] svg[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-family:Roboto;font-size:9px;font-weight:400;text-align:center;text-anchor:middle;font-style:normal;font-variant:normal;font-stretch:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke:none}.buttons-svg-icon[_ngcontent-%COMP%]{width:100%;height:100%;margin:0;padding:0}.svg-content[_ngcontent-%COMP%]{width:100%;height:100%;padding:0;margin:0}.svg-content[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-family:Roboto;font-size:15px;font-weight:700;text-align:center;text-anchor:middle;font-style:normal;font-variant:normal;font-stretch:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke:none}.svg-start-at[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{fill:var(--kip-contrast-dim-color)}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent;z-index:21}"]})}return o})();export{Et as WidgetRacerTimerComponent};
@@ -1 +1 @@
1
- import {a as a$1}from'./chunk-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
+ import {a as a$1}from'./chunk-ibauGmSP.js';import {d1 as Hj,w,du as p,a as G,H as Dr,$ as $j,v as vt,F as Fa,dn as ge,J as JD,_ as _w,cp as Uh,M as Mw,e as EE,d as ig,f as eg,K as Kw,g as qw,b_ as Gh,ci as dl,T as TT,cj as fl,dP as pp}from'./main-YKDNK5VZ.js';var W=["plainIframe"];function M(n,e){if(n&1&&Uh(0,"iframe",1,0),n&2){let t=qw();Gh("src",t.widgetUrl(),pp);}}function N(n,e){n&1&&(dl(0,"div",2)(1,"h2"),TT(2,"Empty or bad URL"),fl(),dl(3,"p"),TT(4," IMPORTANT: cross-domain security rules (CORS) apply to this widget. "),fl(),dl(5,"p"),TT(6,"Typically, you can load Grafana graphs, Signal K apps or other related tools. "),fl()());}var O=class n{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);_dashboard=w(G);_sanitizer=w(Dr);static DEFAULT_CONFIG={widgetUrl:void 0,allowInput:false};iframe=$j.required("plainIframe");widgetUrl=vt(null);displayTransparentOverlay=vt("block");constructor(){Fa(()=>{let e=this.runtime.options(),t=this._dashboard.isDashboardStatic();e&&ge(()=>{t?this.displayTransparentOverlay.set(e.allowInput?"none":"block"):this.displayTransparentOverlay.set("block");});}),Fa(()=>{let e=this.runtime.options()?.widgetUrl;this.widgetUrl.set(this.resolveUrl(e));}),window.addEventListener("message",this.handleIframeGesture);}ngAfterViewInit(){if(this.iframe()){this.iframe().nativeElement.onload=()=>this.injectSwipeScript();try{let e=this.iframe().nativeElement.contentDocument;e&&(e.readyState==="complete"||e.readyState==="interactive")&&this.injectSwipeScript();}catch(e){}}}ngOnDestroy(){window.removeEventListener("message",this.handleIframeGesture),this.iframe()&&(this.iframe().nativeElement.onload=null);try{let e=this.iframe()?.nativeElement.contentDocument;if(e){let t=`kip-gesture-inject-${this.id()}`,i=e.getElementById(t);i&&i.parentNode&&i.parentNode.removeChild(i);}}catch(e){}}handleIframeGesture=e=>{if(!e.data)return;let t=e.data?.eventData?.instanceId||e.data?.keyEventData?.instanceId;if(!(!t||t!==this.id())){if(e.data.gesture)switch(e.data.gesture){case "swipeup":this._dashboard.navigateToPreviousDashboard();break;case "swipedown":this._dashboard.navigateToNextDashboard();break;case "swipeleft":{let i=new Event("openLeftSidenav",{bubbles:true,cancelable:true});window.document.dispatchEvent(i);break}case "swiperight":{let i=new Event("openRightSidenav",{bubbles:true,cancelable:true});window.document.dispatchEvent(i);break}}if(e.data.type==="keydown"&&e.data.keyEventData){let{key:i,ctrlKey:l,shiftKey:r}=e.data.keyEventData,x=new KeyboardEvent("keydown",{key:i,ctrlKey:l,shiftKey:r,bubbles:true,cancelable:true});document.dispatchEvent(x);}}};injectSwipeScript(){let e=this.iframe().nativeElement.contentWindow,t=this.iframe().nativeElement.contentDocument;if(!t||!e){console.error("[WidgetIframe] Iframe contentDocument or contentWindow is undefined. Possible cross-origin issue or iframe not fully loaded.");return}try{let i=`kip-gesture-inject-${this.id()}`;if(t.getElementById(i))return;let l=a$1({instanceId:this.id()}),r=t.createElement("script");r.id=i,r.textContent=l,t.body.appendChild(r);}catch(i){console.warn("[WidgetIframe] Failed to inject swipe script into iframe:",i);}}isValidProtocol(e){try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch(t){return console.warn(`[Embed Widget] Invalid Url: ${e}, Error: ${t}`),false}}resolveUrl(e){if(!e)return null;try{let t=new URL(e,window.location.origin);return this.isValidProtocol(t.href)?this._sanitizer.bypassSecurityTrustResourceUrl(t.href):null}catch(t){return console.warn(`[Embed Widget] Can't resolve Url: ${e}, Error: ${t}`),null}}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=JD({type:n,selectors:[["widget-iframe"]],viewQuery:function(t,i){t&1&&eg(i.iframe,W,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:3,vars:3,consts:[["plainIframe",""],["width","100%","height","100%","frameborder","0",1,"widgetIframe",3,"src"],[2,"padding","15px"],[1,"widgetOverlay"]],template:function(t,i){t&1&&(_w(0,M,2,1,"iframe",1)(1,N,7,0,"div",2),Uh(2,"div",3)),t&2&&(Mw(i.widgetUrl()?0:1),EE(2),ig("display",i.displayTransparentOverlay()));},styles:["[_nghost-%COMP%]{overflow:hidden}.widgetIframe[_ngcontent-%COMP%]{background-color:#fff;border-radius:var(--mat-card-elevated-container-shape, var(--mat-sys-corner-medium))}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent}"]})};export{O as WidgetIframeComponent};
@@ -1 +1 @@
1
- import'./chunk-h2q_pbbF.js';import {d1 as Hj,w,du as p,ao as ue,dy as K,dw as S,aZ as R,bu as ut,i as ir,$ as $j,a6 as Lr,b0 as Wl,W as Wp,E as Em,F as Fa,dn as ge,cw as z,cv as G,J as JD,cp as Uh,f as eg,K as Kw}from'./main-BNR44HGB.js';var tt=["widgetDataChart"],mt=(()=>{class O{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p,{optional:true});static DEFAULT_CONFIG={filterSelfPaths:true,color:"contrast",timeScale:"Last 30 Minutes"};ngZone=w(ue);_dataset=w(K);datasetLifecycle=w(S);canvasService=w(R);unitsService=w(ut);responsive=w(ir);isPhonePortrait;widgetDataChart=$j("widgetDataChart",{read:Lr});lineChartData={datasets:[]};lineChartOptions={parsing:false,datasets:{line:{pointRadius:0,pointHoverRadius:0,tension:.3}},animations:{tension:{easing:"easeInOutCubic"}}};lineChartType="line";chart=null;_dsDirectionSub=null;_dsSpeedSub=null;_chartUpdateRafId=null;datasetConfig=null;dataSourceInfo=null;xCenter=null;xStep=null;xCenterSpeed=null;xStepSpeed=null;CENTER_LINE_WIDTH=4;GRID_LINE_WIDTH=1;EDGE_EXTEND_UP_PX=42;EDGE_SPEED_LABEL_OFFSET=5;EDGE_DIR_LABEL_OFFSET=5;TICK_LABEL_FONT_SIZE=20;TICK_LABEL_PHONE_PORTRAIT_FONT_SIZE=11;CENTER_LABEL_FONT_SIZE=22;CENTER_LABEL_PHONE_PORTRAIT_FONT_SIZE=13;SPEED_VALUE_FONT_SIZE=62;SPEED_VALUE_PHONE_PORTRAIT_FONT_SIZE=32;TOP_VALUE_Y_OFFSET=62;TOP_VALUE_PHONE_PORTRAIT_Y_OFFSET=44;TOP_UNIT_Y_OFFSET=51;TOP_UNIT_PHONE_PORTRAIT_Y_OFFSET=38;UNIT_FONT_SIZE=28;UNIT_PHONE_PORTRAIT_FONT_SIZE=14;UNIT_PADDING=8;UNIT_PHONE_PORTRAIT_PADDING=3;isPortrait=()=>this.isPhonePortrait()?.matches===true;gridBackgroundPlugin={id:"xSpeedGridBackground",beforeDraw:e=>{let t=e.chartArea;if(!t)return;let a=e.ctx,i=this.theme();a.save(),a.globalCompositeOperation="destination-over",a.fillStyle=i.background,a.fillRect(t.left,t.top,t.width/2,t.height),a.restore();}};centerTickPlugin={id:"centerTickStyle",afterDraw:e=>{let t=e.ctx,a=e.chartArea,i=this.theme(),n=this.getThemeColors(),o=Wl.defaults.font,u=e.scales,c=e.options?.scales,r=e.data?.datasets?.[0]?.data,d=e.data?.datasets?.[5]?.data,f=(r?.length??0)>=2&&(d?.length??0)>=2,h=(p,g)=>{let l=u?.[p],x=c;if(!l)return;let E=l,v=x?.[p]?.min??E.min,C=x?.[p]?.max??E.max;if(typeof v!="number"||typeof C!="number"||!isFinite(v)||!isFinite(C))return;let y=(v+C)/2,L=l.getPixelForValue(y);t.save(),t.strokeStyle=i.contrastDim,t.lineWidth=this.CENTER_LINE_WIDTH,t.beginPath(),t.moveTo(L,a.top),t.lineTo(L,a.bottom),t.stroke(),t.restore(),t.save(),t.fillStyle=i.contrastDim,t.font=this.isPortrait()?`bold ${this.CENTER_LABEL_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.CENTER_LABEL_FONT_SIZE}px ${o.family}`,t.textAlign="center",t.textBaseline="top";let J=this.axisTopLabelY(l);t.fillText(g(y),L,J),t.restore();};h("x",p=>`${((p%360+360)%360).toFixed(0)}\xB0`),h("xSpeed",p=>`${p.toFixed(1)}`);let s=u?.xSpeed;if(s){let p=c,g=s,l=p?.xSpeed?.max??g.max;if(typeof l=="number"&&isFinite(l)){let x=s.getPixelForValue(l);t.save(),t.fillStyle=this.resolveTickColor(e,s,l),t.font=this.isPortrait()?`normal ${this.TICK_LABEL_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`normal ${this.TICK_LABEL_FONT_SIZE}px ${o.family}`,t.textAlign="right",t.textBaseline="top";let E=this.axisTopLabelY(s),v=this.xStepSpeed??1,C=Math.max(0,Math.min(3,Math.ceil(-Math.log10(v))));t.fillText(`${l.toFixed(C)}`,x-this.EDGE_SPEED_LABEL_OFFSET,E),t.restore(),t.save(),t.strokeStyle=i.contrastDim,t.lineWidth=this.GRID_LINE_WIDTH,t.beginPath();let y=Math.round(x)+.5;t.moveTo(y,a.bottom),t.lineTo(y,a.top-this.EDGE_EXTEND_UP_PX),t.stroke(),t.restore();}}let m=u?.x;if(m){let p=c,g=m,l=p?.x?.min??g.min;if(typeof l=="number"&&isFinite(l)){let x=m.getPixelForValue(l);t.save(),t.fillStyle=this.resolveTickColor(e,m,l),t.font=this.isPortrait()?`normal ${this.TICK_LABEL_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`normal ${this.TICK_LABEL_FONT_SIZE}px ${o.family}`,t.textAlign="left",t.textBaseline="top";let E=this.axisTopLabelY(m),v=this.normalizeAngle(l);t.fillText(`${v.toFixed(0)}\xB0`,x+this.EDGE_DIR_LABEL_OFFSET,E),t.restore();}}let _=e.data?.datasets,S=_?.[5]?.data,D=S?.length?S.length-1:-1,b=D>=0?S[D]?.x:void 0;if(typeof b=="number"&&isFinite(b)){t.save(),t.fillStyle=n.chartValue,t.font=this.isPortrait()?`bold ${this.SPEED_VALUE_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.SPEED_VALUE_FONT_SIZE}px ${o.family}`,t.textAlign="center",t.textBaseline="middle";let p=`${b.toFixed(1)}`,g=a.left+a.width/4,l=a.top-(this.isPortrait()?this.TOP_VALUE_PHONE_PORTRAIT_Y_OFFSET:this.TOP_VALUE_Y_OFFSET);t.fillText(p,g,l);let x=t.measureText(p),E=g+x.width/2+(this.isPortrait()?this.UNIT_PHONE_PORTRAIT_PADDING:this.UNIT_PADDING),v=a.top-(this.isPortrait()?this.TOP_UNIT_PHONE_PORTRAIT_Y_OFFSET:this.TOP_UNIT_Y_OFFSET);t.font=this.isPortrait()?`bold ${this.UNIT_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.UNIT_FONT_SIZE}px ${o.family}`,t.textAlign="left",t.fillText("kts",E,v),t.restore();}let F=_?.[0]?.data,N=F?.length?F.length-1:-1,T=N>=0?F[N]?.x:void 0;if(typeof T=="number"&&isFinite(T)){let p=this.normalizeAngle(T);t.save(),t.fillStyle=n.chartValue,t.font=this.isPortrait()?`bold ${this.SPEED_VALUE_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.SPEED_VALUE_FONT_SIZE}px ${o.family}`,t.textAlign="center",t.textBaseline="middle",t.fillText(`${p.toFixed(0)}\xB0`,a.left+3*a.width/4,a.top-(this.isPortrait()?this.TOP_VALUE_PHONE_PORTRAIT_Y_OFFSET:this.TOP_VALUE_Y_OFFSET)),t.restore();}if(!f){let p=Math.min(a.width*.7,420),g=90,l=a.left+(a.width-p)/2,x=a.top+(a.height-g)/2;t.save(),t.globalAlpha=.82,t.fillStyle=i.background,t.fillRect(l,x,p,g),t.restore(),t.save(),t.strokeStyle=i.contrastDim,t.lineWidth=2,t.strokeRect(l,x,p,g),t.restore(),t.save(),t.fillStyle=this.getThemeColors().chartLabel,t.textAlign="center",t.textBaseline="middle",t.font=`bold 18px ${o.family}`,t.fillText("Data acquisition...",l+p/2,x+g/2),t.restore();}}};constructor(){this.isPhonePortrait=Wp(this.responsive.observe(Em.HandsetPortrait),{initialValue:void 0}),Fa(()=>{let e=this.theme(),t=this.runtime?.options();!e||!t||ge(()=>{this.datasetConfig&&this.chart&&(this.setChartOptions(),this.setDatasetsColors(),this.ngZone.runOutsideAngular(()=>this.chart?.update("none")));});}),Fa(()=>{let e=this.runtime?.options();if(!e)return;!this.datasetConfig||this.datasetConfig.timeScaleFormat!==e.timeScale?(this.syncServiceDatasets(),this.startWidget()):this.chart&&this.setChartOptions();});}startWidget(){if(this.widgetDataChart()&&(this.datasetConfig=this._dataset.getDatasetConfig(`${this.id()}-twd`)??null,this.dataSourceInfo=this._dataset.getDataSourceInfo(`${this.id()}-twd`)??null,!!this.datasetConfig)){if(this.createDatasets(),this.setChartOptions(),this.chart)this.ngZone.runOutsideAngular(()=>this.chart?.update("none"));else {let e=this.widgetDataChart()?.nativeElement.getContext("2d");if(!e)return;this.chart=new Wl(e,{type:this.lineChartType,data:this.lineChartData,options:this.lineChartOptions,plugins:[this.gridBackgroundPlugin,this.centerTickPlugin]}),this.ngZone.runOutsideAngular(()=>this.chart?.update("none"));}this.startStreaming();}}syncServiceDatasets(){let e=this.runtime?.options();!e||e.timeScale===""||this.datasetLifecycle.syncWindTrendsDatasets(this.id(),e.timeScale);}setChartOptions(){let e=this.datasetConfig,t=this.dataSourceInfo;if(!e||!t)return;this.lineChartOptions.maintainAspectRatio=false,this.lineChartOptions.animation=false,this.lineChartOptions.indexAxis="y";let a=0,i=360,n=(i-a)/4,o=0,u=20,c=(u-o)/4;this.lineChartOptions.scales={y:{type:"linear",display:true,position:"right",reverse:true,title:{display:true,text:`${e.timeScaleFormat}`,align:"center"},ticks:{count:6,autoSkip:false,includeBounds:true,align:"inner",major:{enabled:true},font:this.isPortrait()?{size:12}:{size:16},callback:r=>{let d=Number(r),f=e.timeScaleFormat,h=this.getWindowMs(f);return f==="Last 5 Minutes"?`${Math.round(d/6e4)}'`:h>=10*6e4?`${Math.round(d/6e4)}'`:`${Math.round(d/1e3)}"`}},grid:{display:true,color:this.theme().contrastDimmer}},x:{type:"linear",position:"top",stack:"trends",beginAtZero:false,bounds:"ticks",min:a,max:i,title:{display:false},ticks:{count:5,align:"inner",autoSkip:false,includeBounds:true,stepSize:n,minRotation:0,maxRotation:0,callback:r=>{let d=Number(r),f=this.xCenter??Number.NaN;if(this.nearlyEqual(d,f))return "";let s=this.chart?.options?.scales?.x?.min;return typeof s=="number"&&this.nearlyEqual(d,s)?"":`${((d%360+360)%360).toFixed(0)}\xB0`},font:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenter??Number.NaN,h=this.nearlyEqual(d,f);return this.isPortrait()?{size:11,weight:h?"bold":"normal"}:{size:20,weight:h?"bold":"normal"}},color:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenter??Number.NaN;return this.nearlyEqual(d,f)?this.theme().contrast:void 0}},grid:{display:true,color:r=>{let d=r.tick?.value??Number.NaN,f=r.scale,h=this.chart?.options?.scales,s=f,m=h?.x?.min??s.min;return this.nearlyEqual(d,m)?"rgba(0,0,0,0)":this.theme().contrastDimmer},lineWidth:1}},xSpeed:{type:"linear",position:"top",stack:"trends",beginAtZero:false,bounds:"ticks",min:o,max:u,title:{display:false},ticks:{count:5,align:"inner",autoSkip:false,includeBounds:true,stepSize:c,minRotation:0,maxRotation:0,callback:r=>{let d=this.xCenterSpeed??Number.NaN;if(this.nearlyEqual(r,d))return "";let h=this.chart?.options?.scales?.xSpeed?.max;if(typeof h=="number"&&this.nearlyEqual(r,h))return "";let s=this.xStepSpeed??Number.NaN,m=Number.isFinite(s)?s:1,_=Math.max(0,Math.min(3,Math.ceil(-Math.log10(m))));return `${r.toFixed(_)}`},font:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenterSpeed??Number.NaN,h=this.nearlyEqual(d,f);return this.isPortrait()?{size:11,weight:h?"bold":"normal"}:{size:20,weight:h?"bold":"normal"}},color:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenterSpeed??Number.NaN;return this.nearlyEqual(d,f)?this.theme().contrast:void 0}},grid:{display:true,color:r=>{let d=r.tick?.value??Number.NaN,f=r.scale,h=this.chart?.options?.scales,s=f,m=h?.xSpeed?.max??s.max;return this.nearlyEqual(d,m)?"rgba(0,0,0,0)":this.theme().contrastDimmer},lineWidth:1}}},this.lineChartOptions.plugins={title:{display:true,align:"end",text:"TWD ",color:this.getThemeColors().chartLabel,padding:this.isPortrait()?{top:3,bottom:0}:{top:3,bottom:0},font:this.isPortrait()?{size:16,weight:"normal"}:{size:35,weight:"normal"}},subtitle:{display:true,align:"start",text:" TWS",color:this.getThemeColors().chartLabel,padding:this.isPortrait()?{top:-18,bottom:12}:{top:-41,bottom:12},font:this.isPortrait()?{size:16}:{size:35}},legend:{display:false},annotation:{annotations:{}},streaming:{duration:t.maxDataPoints*t.sampleTime,delay:t.sampleTime,frameRate:e.timeScaleFormat==="day"?5:e.timeScaleFormat==="hour"?8:e.timeScaleFormat==="minute"?15:30}},this.xCenter=(a+i)/2,this.xStep=n,this.xCenterSpeed=(o+u)/2,this.xStepSpeed=c;}createDatasets(){this.lineChartData.datasets=[],this.lineChartData.datasets.push({label:"Value",data:[],order:2,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:1,fill:false,xAxisID:"x"},{label:"SMA",data:[],order:0,parsing:false,normalized:true,tension:.3,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:10,fill:false,borderColor:e=>{let t=e.chart,{ctx:a}=t;return this.lineGradientForAxis(a,t,"x")??this.getThemeColors().averageLine},backgroundColor:"red",xAxisID:"x"},{label:"lastAverage",data:[],order:1,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:0,borderColor:"",fill:false,hidden:true,xAxisID:"x"},{label:"lastMinimum",data:[],order:3,parsing:false,normalized:true,hidden:true,xAxisID:"x"},{label:"lastMaximum",data:[],order:4,parsing:false,normalized:true,hidden:true,xAxisID:"x"},{label:"Value Speed",data:[],order:2,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:1,fill:false,xAxisID:"xSpeed"},{label:"SMA Speed",data:[],order:0,parsing:false,normalized:true,tension:.2,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:3,fill:false,borderColor:e=>{let t=e.chart,{ctx:a}=t;return this.lineGradientForAxis(a,t,"xSpeed")??this.getThemeColors().averageLine},xAxisID:"xSpeed"},{label:"lastAverage Speed",data:[],order:1,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:0,borderColor:"",fill:false,hidden:true,xAxisID:"xSpeed"},{label:"lastMinimum Speed",data:[],order:3,parsing:false,normalized:true,hidden:true,xAxisID:"xSpeed"},{label:"lastMaximum Speed",data:[],order:4,parsing:false,normalized:true,hidden:true,xAxisID:"xSpeed"}),this.setDatasetsColors();}startStreaming(){if(this._dsDirectionSub?.unsubscribe(),this._dsSpeedSub?.unsubscribe(),!this.chart||!this.dataSourceInfo)return;let e=this._dataset.getDatasetBatchThenLiveObservable(`${this.id()}-twd`),t=this._dataset.getDatasetBatchThenLiveObservable(`${this.id()}-tws`);!e||!t||(this._dsDirectionSub=e.subscribe(a=>{let i=this.chart,n=this.dataSourceInfo;if(!(!i||!n)){if(Array.isArray(a))this.pushRowsToDatasets(a);else {this.pushRowsToDatasets([a]);let o=i.data.datasets[0]?.data;if(Array.isArray(o)&&o.length>n.maxDataPoints)for(let u=0;u<=4;u++){let c=i.data.datasets[u]?.data;Array.isArray(c)&&c.shift();}}this.scheduleChartUpdate();}}),this._dsSpeedSub=t.subscribe(a=>{let i=this.chart,n=this.dataSourceInfo;if(!(!i||!n)){if(Array.isArray(a))this.pushRowsToSpeedDatasets(a);else {this.pushRowsToSpeedDatasets([a]);let o=i.data.datasets[5]?.data;if(Array.isArray(o)&&o.length>n.maxDataPoints)for(let u=5;u<=9;u++){let c=i.data.datasets[u]?.data;Array.isArray(c)&&c.shift();}}this.scheduleChartUpdate();}}));}unwrapAngles(e){if(e.length===0)return [];let t=[],a=null;for(let i of e){if(i==null){t.push(null);continue}if(a==null){t.push(i),a=i;continue}let n=i-a;n>180&&(n-=360),n<-180&&(n+=360),t.push(t[t.length-1]+n),a=i;}return t}pushRowsToDatasets(e){this.pushRowsGeneric(e,0,"deg",true);}pushRowsToSpeedDatasets(e){this.pushRowsGeneric(e,5,"knots",false);}getRowValue(e,t){switch(t){case "value":return e.data.value??null;case "sma":return e.data.sma??null;case "ema":return e.data.ema??null;case "dema":return e.data.doubleEma??null;case "avg":return e.data.lastAverage??null;case "min":return e.data.lastMinimum??null;case "max":return e.data.lastMaximum??null;default:return null}}transformRows(e,t,a,i){let n=e.map(u=>{let c=this.getRowValue(u,t);return c==null?null:this.unitsService.convertToUnit(a,c)}),o=i?this.unwrapAngles(n):n;return e.map((u,c)=>({x:o[c],y:u.timestamp,ts:u.timestamp}))}pushRowsGeneric(e,t,a,i){let n=this.chart;if(!n)return;["value","sma","avg","min","max"].forEach((u,c)=>{let r=n.data.datasets[t+c];!r||!Array.isArray(r.data)||r.data.push(...this.transformRows(e,u,a,i));});}normalizeAngle(e){return (e%360+360)%360}angularDiff(e,t){let a=(e-t+540)%360-180;return Math.abs(a)}niceStepFromMantissas(e,t){if(!isFinite(e)||e<=0)return 1;let a=Math.floor(Math.log10(e)),i=e/Math.pow(10,a);return (t.find(o=>i<=o)??t[t.length-1])*Math.pow(10,a)}scheduleChartUpdate(){this._chartUpdateRafId==null&&(this._chartUpdateRafId=requestAnimationFrame(()=>{this._chartUpdateRafId=null,!(!this.chart||!this.hasValidDatasets())&&(this.updateChartAfterDataChange(),this.ngZone.runOutsideAngular(()=>this.chart?.update("none")));}));}hasValidDatasets(){let e=this.chart?.data?.datasets;if(!Array.isArray(e)||e.length<10)return false;for(let t=0;t<10;t++){let a=e[t];if(!a||!Array.isArray(a.data))return false}return true}updateChartAfterDataChange(){let e=this.chart;if(!e)return;let t=e.data.datasets[2]?.data,a=e.data.datasets[1]?.data,i=e.data.datasets[0]?.data,n=!!t?.length,o=!!a?.length,u=!!i?.length,c=n?t[t.length-1].x:o?a[a.length-1].x:u?i[i.length-1].x:void 0;if(typeof c=="number"&&isFinite(c)){let h=e.data.datasets[3]?.data,s=e.data.datasets[4]?.data,m=h?.length?h[h.length-1].x:void 0,_=s?.length?s[s.length-1].x:void 0,S=typeof m=="number"&&isFinite(m)?this.angularDiff(c,m):Number.NaN,D=typeof _=="number"&&isFinite(_)?this.angularDiff(c,_):Number.NaN,b=Number.isFinite(S)||Number.isFinite(D)?Math.max(Number.isFinite(S)?S:0,Number.isFinite(D)?D:0):Number.NaN;if(!Number.isFinite(b)){let x=n?t:o?a:i,E=Math.min(30,x?.length??0);if(E>1){let C=x.slice(x.length-E).map(y=>y.x).filter(y=>typeof y=="number"&&isFinite(y));C.length&&(b=C.reduce((y,L)=>Math.max(y,this.angularDiff(c,L)),0));}}b=Math.max(b||0,15);let N=2*b/4,T=this.niceStepFromMantissas(N,[1,1.5,2,2.5,5,7.5,10]),p=c-2*T,g=c+2*T,l=e.options.scales;l.x&&(l.x.min=p,l.x.max=g,l.x.ticks=z(G({},l.x.ticks??{}),{stepSize:T})),this.xCenter=c,this.xStep=T;}let r=e.data.datasets[7]?.data;if(r&&r.length){let h=r.length-1,s=r[h]?.x??0,m=e.data.datasets[8].data[h]?.x??s,_=e.data.datasets[9].data[h]?.x??s,S=Math.abs(s-m),D=Math.abs(_-s),b=Math.max(S,D);b=Math.max(b,.5);let N=2*b/4,T=this.niceStepFromMantissas(N,[1,2,2.5,5,10]),p=s-2*T,g=s+2*T,l=e.options.scales;l.xSpeed&&(l.xSpeed.min=p,l.xSpeed.max=g,l.xSpeed.ticks=z(G({},l.xSpeed.ticks??{}),{stepSize:T})),this.xCenterSpeed=s,this.xStepSpeed=T;}let d=this.getWindowMs(this.datasetConfig?.timeScaleFormat);if(e.data.datasets[0].data.length>0){let h=Date.now();e.data.datasets.forEach(S=>{S.data.forEach(D=>{let b=D.ts??D.y;D.y=Math.max(0,Math.min(d,h-b));});});let s=e.options.scales;s.y&&(s.y.min=0,s.y.max=d);let m;switch(this.datasetConfig?.timeScaleFormat){case "Last Minute":m=15e3;break;case "Last 5 Minutes":m=6e4;break;case "Last 30 Minutes":m=5*6e4;break;default:m=d/5;break}if(s.y){let S=G({},s.y.ticks??{});delete S.count,S.stepSize=m,s.y.ticks=S;}}}getWindowMs(e){switch(e){case "Last 30 Minutes":return 30*6e4;case "Last 5 Minutes":return 5*6e4;case "Last Minute":return 6e4;default:return 6e4}}lineGradientForAxis(e,t,a){let i=t.chartArea;if(!i)return null;let n=t.scales?.[a];if(!n)return null;let o=t.options?.scales,u=n,c=o?.[a]?.min??u.min,r=o?.[a]?.max??u.max;if(typeof c!="number"||typeof r!="number"||!isFinite(c)||!isFinite(r))return null;let d=(c+r)/2,f=n.getPixelForValue(d),h=Math.max(0,Math.min(1,(f-i.left)/i.width)),s=e.createLinearGradient(i.left,0,i.right,0);return s.addColorStop(0,this.theme().port),s.addColorStop(h,this.theme().port),s.addColorStop(h,this.theme().starboard),s.addColorStop(1,this.theme().starboard),s}setDatasetsColors(){this.lineChartData.datasets.forEach(e=>{e.label==="Value"&&(e.borderColor=this.getThemeColors().valueLine,e.backgroundColor=this.getThemeColors().valueFill),e.label==="Value Speed"&&(e.borderColor=this.getThemeColors().valueLine,e.backgroundColor=this.getThemeColors().valueFill);});}getThemeColors(){let e=this.runtime?.options()?.color,t={valueLine:"",valueFill:"",averageLine:"",averageFill:"",averageChartLine:"",chartLabel:"",chartValue:""};switch(e){case "contrast":t.valueLine=this.theme().contrastDim,t.valueFill=this.theme().contrastDimmer,t.averageLine=this.theme().contrast,t.averageFill=this.theme().contrast,t.chartValue=this.theme().contrast,t.averageChartLine=this.theme().contrast,t.chartLabel=this.theme().contrastDim;break;case "blue":t.valueLine=this.theme().blueDim,t.valueFill=this.theme().blueDimmer,t.averageLine=this.theme().blue,t.averageFill=this.theme().blue,t.chartValue=this.theme().blue,t.averageChartLine=this.theme().blueDim,t.chartLabel=this.theme().blueDim;break;case "green":t.valueLine=this.theme().greenDim,t.valueFill=this.theme().greenDimmer,t.averageLine=this.theme().green,t.averageFill=this.theme().green,t.chartValue=this.theme().green,t.averageChartLine=this.theme().greenDim,t.chartLabel=this.theme().greenDim;break;case "pink":t.valueLine=this.theme().pinkDim,t.valueFill=this.theme().pinkDimmer,t.averageLine=this.theme().pink,t.averageFill=this.theme().pink,t.chartValue=this.theme().pink,t.averageChartLine=this.theme().pinkDim,t.chartLabel=this.theme().pinkDim;break;case "orange":t.valueLine=this.theme().orangeDim,t.valueFill=this.theme().orangeDimmer,t.averageLine=this.theme().orange,t.averageFill=this.theme().orange,t.chartValue=this.theme().orange,t.averageChartLine=this.theme().orangeDim,t.chartLabel=this.theme().orangeDim;break;case "purple":t.valueLine=this.theme().purpleDim,t.valueFill=this.theme().purpleDimmer,t.averageLine=this.theme().purple,t.averageFill=this.theme().purple,t.chartValue=this.theme().purple,t.averageChartLine=this.theme().purpleDim,t.chartLabel=this.theme().purpleDim;break;case "grey":t.valueLine=this.theme().greyDim,t.valueFill=this.theme().greyDimmer,t.averageLine=this.theme().grey,t.averageFill=this.theme().grey,t.chartValue=this.theme().grey,t.averageChartLine=this.theme().greyDim,t.chartLabel=this.theme().greyDim;break;case "yellow":t.valueLine=this.theme().yellowDim,t.valueFill=this.theme().yellowDimmer,t.averageLine=this.theme().yellow,t.averageFill=this.theme().yellow,t.chartValue=this.theme().yellow,t.averageChartLine=this.theme().yellowDim,t.chartLabel=this.theme().yellowDim;break}return t}nearlyEqual(e,t,a=1e-6){if(!Number.isFinite(e)||!Number.isFinite(t))return false;let i=Math.max(1,Math.max(Math.abs(e),Math.abs(t)));return Math.abs(e-t)<=a*i}resolveTickColor(e,t,a){let n=t.options.ticks?.color;return typeof n=="function"?n({chart:e,scale:t,tick:{value:a}})??Wl.defaults.color:typeof n=="string"?n:Wl.defaults.color}axisTopLabelY(e){return e.options?.position==="top"?e.top+4:e.bottom+2}ngOnDestroy(){this._dsDirectionSub?.unsubscribe(),this._dsSpeedSub?.unsubscribe(),this._chartUpdateRafId!=null&&(cancelAnimationFrame(this._chartUpdateRafId),this._chartUpdateRafId=null),this.chart?.destroy();let e=this.widgetDataChart?.()?.nativeElement;this.canvasService.releaseCanvas(e,{clear:true,removeFromDom:true});}static \u0275fac=function(t){return new(t||O)};static \u0275cmp=JD({type:O,selectors:[["widget-windtrends-chart"]],viewQuery:function(t,a){t&1&&eg(a.widgetDataChart,tt,5,Lr),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:0,consts:[["widgetDataChart",""],[2,"z-index","inherit"]],template:function(t,a){t&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%}"]})}return O})();export{mt as WidgetWindTrendsChartComponent};
1
+ import'./chunk-BTOTKeBo.js';import {d1 as Hj,w,du as p,ao as ue,dy as K,dw as S,aZ as R,bu as ut,i as ir,$ as $j,a6 as Lr,b0 as Wl,W as Wp,E as Em,F as Fa,dn as ge,cw as z,cv as G,J as JD,cp as Uh,f as eg,K as Kw}from'./main-YKDNK5VZ.js';var tt=["widgetDataChart"],mt=(()=>{class O{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p,{optional:true});static DEFAULT_CONFIG={filterSelfPaths:true,color:"contrast",timeScale:"Last 30 Minutes"};ngZone=w(ue);_dataset=w(K);datasetLifecycle=w(S);canvasService=w(R);unitsService=w(ut);responsive=w(ir);isPhonePortrait;widgetDataChart=$j("widgetDataChart",{read:Lr});lineChartData={datasets:[]};lineChartOptions={parsing:false,datasets:{line:{pointRadius:0,pointHoverRadius:0,tension:.3}},animations:{tension:{easing:"easeInOutCubic"}}};lineChartType="line";chart=null;_dsDirectionSub=null;_dsSpeedSub=null;_chartUpdateRafId=null;datasetConfig=null;dataSourceInfo=null;xCenter=null;xStep=null;xCenterSpeed=null;xStepSpeed=null;CENTER_LINE_WIDTH=4;GRID_LINE_WIDTH=1;EDGE_EXTEND_UP_PX=42;EDGE_SPEED_LABEL_OFFSET=5;EDGE_DIR_LABEL_OFFSET=5;TICK_LABEL_FONT_SIZE=20;TICK_LABEL_PHONE_PORTRAIT_FONT_SIZE=11;CENTER_LABEL_FONT_SIZE=22;CENTER_LABEL_PHONE_PORTRAIT_FONT_SIZE=13;SPEED_VALUE_FONT_SIZE=62;SPEED_VALUE_PHONE_PORTRAIT_FONT_SIZE=32;TOP_VALUE_Y_OFFSET=62;TOP_VALUE_PHONE_PORTRAIT_Y_OFFSET=44;TOP_UNIT_Y_OFFSET=51;TOP_UNIT_PHONE_PORTRAIT_Y_OFFSET=38;UNIT_FONT_SIZE=28;UNIT_PHONE_PORTRAIT_FONT_SIZE=14;UNIT_PADDING=8;UNIT_PHONE_PORTRAIT_PADDING=3;isPortrait=()=>this.isPhonePortrait()?.matches===true;gridBackgroundPlugin={id:"xSpeedGridBackground",beforeDraw:e=>{let t=e.chartArea;if(!t)return;let a=e.ctx,i=this.theme();a.save(),a.globalCompositeOperation="destination-over",a.fillStyle=i.background,a.fillRect(t.left,t.top,t.width/2,t.height),a.restore();}};centerTickPlugin={id:"centerTickStyle",afterDraw:e=>{let t=e.ctx,a=e.chartArea,i=this.theme(),n=this.getThemeColors(),o=Wl.defaults.font,u=e.scales,c=e.options?.scales,r=e.data?.datasets?.[0]?.data,d=e.data?.datasets?.[5]?.data,f=(r?.length??0)>=2&&(d?.length??0)>=2,h=(p,g)=>{let l=u?.[p],x=c;if(!l)return;let E=l,v=x?.[p]?.min??E.min,C=x?.[p]?.max??E.max;if(typeof v!="number"||typeof C!="number"||!isFinite(v)||!isFinite(C))return;let y=(v+C)/2,L=l.getPixelForValue(y);t.save(),t.strokeStyle=i.contrastDim,t.lineWidth=this.CENTER_LINE_WIDTH,t.beginPath(),t.moveTo(L,a.top),t.lineTo(L,a.bottom),t.stroke(),t.restore(),t.save(),t.fillStyle=i.contrastDim,t.font=this.isPortrait()?`bold ${this.CENTER_LABEL_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.CENTER_LABEL_FONT_SIZE}px ${o.family}`,t.textAlign="center",t.textBaseline="top";let J=this.axisTopLabelY(l);t.fillText(g(y),L,J),t.restore();};h("x",p=>`${((p%360+360)%360).toFixed(0)}\xB0`),h("xSpeed",p=>`${p.toFixed(1)}`);let s=u?.xSpeed;if(s){let p=c,g=s,l=p?.xSpeed?.max??g.max;if(typeof l=="number"&&isFinite(l)){let x=s.getPixelForValue(l);t.save(),t.fillStyle=this.resolveTickColor(e,s,l),t.font=this.isPortrait()?`normal ${this.TICK_LABEL_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`normal ${this.TICK_LABEL_FONT_SIZE}px ${o.family}`,t.textAlign="right",t.textBaseline="top";let E=this.axisTopLabelY(s),v=this.xStepSpeed??1,C=Math.max(0,Math.min(3,Math.ceil(-Math.log10(v))));t.fillText(`${l.toFixed(C)}`,x-this.EDGE_SPEED_LABEL_OFFSET,E),t.restore(),t.save(),t.strokeStyle=i.contrastDim,t.lineWidth=this.GRID_LINE_WIDTH,t.beginPath();let y=Math.round(x)+.5;t.moveTo(y,a.bottom),t.lineTo(y,a.top-this.EDGE_EXTEND_UP_PX),t.stroke(),t.restore();}}let m=u?.x;if(m){let p=c,g=m,l=p?.x?.min??g.min;if(typeof l=="number"&&isFinite(l)){let x=m.getPixelForValue(l);t.save(),t.fillStyle=this.resolveTickColor(e,m,l),t.font=this.isPortrait()?`normal ${this.TICK_LABEL_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`normal ${this.TICK_LABEL_FONT_SIZE}px ${o.family}`,t.textAlign="left",t.textBaseline="top";let E=this.axisTopLabelY(m),v=this.normalizeAngle(l);t.fillText(`${v.toFixed(0)}\xB0`,x+this.EDGE_DIR_LABEL_OFFSET,E),t.restore();}}let _=e.data?.datasets,S=_?.[5]?.data,D=S?.length?S.length-1:-1,b=D>=0?S[D]?.x:void 0;if(typeof b=="number"&&isFinite(b)){t.save(),t.fillStyle=n.chartValue,t.font=this.isPortrait()?`bold ${this.SPEED_VALUE_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.SPEED_VALUE_FONT_SIZE}px ${o.family}`,t.textAlign="center",t.textBaseline="middle";let p=`${b.toFixed(1)}`,g=a.left+a.width/4,l=a.top-(this.isPortrait()?this.TOP_VALUE_PHONE_PORTRAIT_Y_OFFSET:this.TOP_VALUE_Y_OFFSET);t.fillText(p,g,l);let x=t.measureText(p),E=g+x.width/2+(this.isPortrait()?this.UNIT_PHONE_PORTRAIT_PADDING:this.UNIT_PADDING),v=a.top-(this.isPortrait()?this.TOP_UNIT_PHONE_PORTRAIT_Y_OFFSET:this.TOP_UNIT_Y_OFFSET);t.font=this.isPortrait()?`bold ${this.UNIT_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.UNIT_FONT_SIZE}px ${o.family}`,t.textAlign="left",t.fillText("kts",E,v),t.restore();}let F=_?.[0]?.data,N=F?.length?F.length-1:-1,T=N>=0?F[N]?.x:void 0;if(typeof T=="number"&&isFinite(T)){let p=this.normalizeAngle(T);t.save(),t.fillStyle=n.chartValue,t.font=this.isPortrait()?`bold ${this.SPEED_VALUE_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.SPEED_VALUE_FONT_SIZE}px ${o.family}`,t.textAlign="center",t.textBaseline="middle",t.fillText(`${p.toFixed(0)}\xB0`,a.left+3*a.width/4,a.top-(this.isPortrait()?this.TOP_VALUE_PHONE_PORTRAIT_Y_OFFSET:this.TOP_VALUE_Y_OFFSET)),t.restore();}if(!f){let p=Math.min(a.width*.7,420),g=90,l=a.left+(a.width-p)/2,x=a.top+(a.height-g)/2;t.save(),t.globalAlpha=.82,t.fillStyle=i.background,t.fillRect(l,x,p,g),t.restore(),t.save(),t.strokeStyle=i.contrastDim,t.lineWidth=2,t.strokeRect(l,x,p,g),t.restore(),t.save(),t.fillStyle=this.getThemeColors().chartLabel,t.textAlign="center",t.textBaseline="middle",t.font=`bold 18px ${o.family}`,t.fillText("Data acquisition...",l+p/2,x+g/2),t.restore();}}};constructor(){this.isPhonePortrait=Wp(this.responsive.observe(Em.HandsetPortrait),{initialValue:void 0}),Fa(()=>{let e=this.theme(),t=this.runtime?.options();!e||!t||ge(()=>{this.datasetConfig&&this.chart&&(this.setChartOptions(),this.setDatasetsColors(),this.ngZone.runOutsideAngular(()=>this.chart?.update("none")));});}),Fa(()=>{let e=this.runtime?.options();if(!e)return;!this.datasetConfig||this.datasetConfig.timeScaleFormat!==e.timeScale?(this.syncServiceDatasets(),this.startWidget()):this.chart&&this.setChartOptions();});}startWidget(){if(this.widgetDataChart()&&(this.datasetConfig=this._dataset.getDatasetConfig(`${this.id()}-twd`)??null,this.dataSourceInfo=this._dataset.getDataSourceInfo(`${this.id()}-twd`)??null,!!this.datasetConfig)){if(this.createDatasets(),this.setChartOptions(),this.chart)this.ngZone.runOutsideAngular(()=>this.chart?.update("none"));else {let e=this.widgetDataChart()?.nativeElement.getContext("2d");if(!e)return;this.chart=new Wl(e,{type:this.lineChartType,data:this.lineChartData,options:this.lineChartOptions,plugins:[this.gridBackgroundPlugin,this.centerTickPlugin]}),this.ngZone.runOutsideAngular(()=>this.chart?.update("none"));}this.startStreaming();}}syncServiceDatasets(){let e=this.runtime?.options();!e||e.timeScale===""||this.datasetLifecycle.syncWindTrendsDatasets(this.id(),e.timeScale);}setChartOptions(){let e=this.datasetConfig,t=this.dataSourceInfo;if(!e||!t)return;this.lineChartOptions.maintainAspectRatio=false,this.lineChartOptions.animation=false,this.lineChartOptions.indexAxis="y";let a=0,i=360,n=(i-a)/4,o=0,u=20,c=(u-o)/4;this.lineChartOptions.scales={y:{type:"linear",display:true,position:"right",reverse:true,title:{display:true,text:`${e.timeScaleFormat}`,align:"center"},ticks:{count:6,autoSkip:false,includeBounds:true,align:"inner",major:{enabled:true},font:this.isPortrait()?{size:12}:{size:16},callback:r=>{let d=Number(r),f=e.timeScaleFormat,h=this.getWindowMs(f);return f==="Last 5 Minutes"?`${Math.round(d/6e4)}'`:h>=10*6e4?`${Math.round(d/6e4)}'`:`${Math.round(d/1e3)}"`}},grid:{display:true,color:this.theme().contrastDimmer}},x:{type:"linear",position:"top",stack:"trends",beginAtZero:false,bounds:"ticks",min:a,max:i,title:{display:false},ticks:{count:5,align:"inner",autoSkip:false,includeBounds:true,stepSize:n,minRotation:0,maxRotation:0,callback:r=>{let d=Number(r),f=this.xCenter??Number.NaN;if(this.nearlyEqual(d,f))return "";let s=this.chart?.options?.scales?.x?.min;return typeof s=="number"&&this.nearlyEqual(d,s)?"":`${((d%360+360)%360).toFixed(0)}\xB0`},font:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenter??Number.NaN,h=this.nearlyEqual(d,f);return this.isPortrait()?{size:11,weight:h?"bold":"normal"}:{size:20,weight:h?"bold":"normal"}},color:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenter??Number.NaN;return this.nearlyEqual(d,f)?this.theme().contrast:void 0}},grid:{display:true,color:r=>{let d=r.tick?.value??Number.NaN,f=r.scale,h=this.chart?.options?.scales,s=f,m=h?.x?.min??s.min;return this.nearlyEqual(d,m)?"rgba(0,0,0,0)":this.theme().contrastDimmer},lineWidth:1}},xSpeed:{type:"linear",position:"top",stack:"trends",beginAtZero:false,bounds:"ticks",min:o,max:u,title:{display:false},ticks:{count:5,align:"inner",autoSkip:false,includeBounds:true,stepSize:c,minRotation:0,maxRotation:0,callback:r=>{let d=this.xCenterSpeed??Number.NaN;if(this.nearlyEqual(r,d))return "";let h=this.chart?.options?.scales?.xSpeed?.max;if(typeof h=="number"&&this.nearlyEqual(r,h))return "";let s=this.xStepSpeed??Number.NaN,m=Number.isFinite(s)?s:1,_=Math.max(0,Math.min(3,Math.ceil(-Math.log10(m))));return `${r.toFixed(_)}`},font:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenterSpeed??Number.NaN,h=this.nearlyEqual(d,f);return this.isPortrait()?{size:11,weight:h?"bold":"normal"}:{size:20,weight:h?"bold":"normal"}},color:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenterSpeed??Number.NaN;return this.nearlyEqual(d,f)?this.theme().contrast:void 0}},grid:{display:true,color:r=>{let d=r.tick?.value??Number.NaN,f=r.scale,h=this.chart?.options?.scales,s=f,m=h?.xSpeed?.max??s.max;return this.nearlyEqual(d,m)?"rgba(0,0,0,0)":this.theme().contrastDimmer},lineWidth:1}}},this.lineChartOptions.plugins={title:{display:true,align:"end",text:"TWD ",color:this.getThemeColors().chartLabel,padding:this.isPortrait()?{top:3,bottom:0}:{top:3,bottom:0},font:this.isPortrait()?{size:16,weight:"normal"}:{size:35,weight:"normal"}},subtitle:{display:true,align:"start",text:" TWS",color:this.getThemeColors().chartLabel,padding:this.isPortrait()?{top:-18,bottom:12}:{top:-41,bottom:12},font:this.isPortrait()?{size:16}:{size:35}},legend:{display:false},annotation:{annotations:{}},streaming:{duration:t.maxDataPoints*t.sampleTime,delay:t.sampleTime,frameRate:e.timeScaleFormat==="day"?5:e.timeScaleFormat==="hour"?8:e.timeScaleFormat==="minute"?15:30}},this.xCenter=(a+i)/2,this.xStep=n,this.xCenterSpeed=(o+u)/2,this.xStepSpeed=c;}createDatasets(){this.lineChartData.datasets=[],this.lineChartData.datasets.push({label:"Value",data:[],order:2,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:1,fill:false,xAxisID:"x"},{label:"SMA",data:[],order:0,parsing:false,normalized:true,tension:.3,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:10,fill:false,borderColor:e=>{let t=e.chart,{ctx:a}=t;return this.lineGradientForAxis(a,t,"x")??this.getThemeColors().averageLine},backgroundColor:"red",xAxisID:"x"},{label:"lastAverage",data:[],order:1,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:0,borderColor:"",fill:false,hidden:true,xAxisID:"x"},{label:"lastMinimum",data:[],order:3,parsing:false,normalized:true,hidden:true,xAxisID:"x"},{label:"lastMaximum",data:[],order:4,parsing:false,normalized:true,hidden:true,xAxisID:"x"},{label:"Value Speed",data:[],order:2,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:1,fill:false,xAxisID:"xSpeed"},{label:"SMA Speed",data:[],order:0,parsing:false,normalized:true,tension:.2,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:3,fill:false,borderColor:e=>{let t=e.chart,{ctx:a}=t;return this.lineGradientForAxis(a,t,"xSpeed")??this.getThemeColors().averageLine},xAxisID:"xSpeed"},{label:"lastAverage Speed",data:[],order:1,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:0,borderColor:"",fill:false,hidden:true,xAxisID:"xSpeed"},{label:"lastMinimum Speed",data:[],order:3,parsing:false,normalized:true,hidden:true,xAxisID:"xSpeed"},{label:"lastMaximum Speed",data:[],order:4,parsing:false,normalized:true,hidden:true,xAxisID:"xSpeed"}),this.setDatasetsColors();}startStreaming(){if(this._dsDirectionSub?.unsubscribe(),this._dsSpeedSub?.unsubscribe(),!this.chart||!this.dataSourceInfo)return;let e=this._dataset.getDatasetBatchThenLiveObservable(`${this.id()}-twd`),t=this._dataset.getDatasetBatchThenLiveObservable(`${this.id()}-tws`);!e||!t||(this._dsDirectionSub=e.subscribe(a=>{let i=this.chart,n=this.dataSourceInfo;if(!(!i||!n)){if(Array.isArray(a))this.pushRowsToDatasets(a);else {this.pushRowsToDatasets([a]);let o=i.data.datasets[0]?.data;if(Array.isArray(o)&&o.length>n.maxDataPoints)for(let u=0;u<=4;u++){let c=i.data.datasets[u]?.data;Array.isArray(c)&&c.shift();}}this.scheduleChartUpdate();}}),this._dsSpeedSub=t.subscribe(a=>{let i=this.chart,n=this.dataSourceInfo;if(!(!i||!n)){if(Array.isArray(a))this.pushRowsToSpeedDatasets(a);else {this.pushRowsToSpeedDatasets([a]);let o=i.data.datasets[5]?.data;if(Array.isArray(o)&&o.length>n.maxDataPoints)for(let u=5;u<=9;u++){let c=i.data.datasets[u]?.data;Array.isArray(c)&&c.shift();}}this.scheduleChartUpdate();}}));}unwrapAngles(e){if(e.length===0)return [];let t=[],a=null;for(let i of e){if(i==null){t.push(null);continue}if(a==null){t.push(i),a=i;continue}let n=i-a;n>180&&(n-=360),n<-180&&(n+=360),t.push(t[t.length-1]+n),a=i;}return t}pushRowsToDatasets(e){this.pushRowsGeneric(e,0,"deg",true);}pushRowsToSpeedDatasets(e){this.pushRowsGeneric(e,5,"knots",false);}getRowValue(e,t){switch(t){case "value":return e.data.value??null;case "sma":return e.data.sma??null;case "ema":return e.data.ema??null;case "dema":return e.data.doubleEma??null;case "avg":return e.data.lastAverage??null;case "min":return e.data.lastMinimum??null;case "max":return e.data.lastMaximum??null;default:return null}}transformRows(e,t,a,i){let n=e.map(u=>{let c=this.getRowValue(u,t);return c==null?null:this.unitsService.convertToUnit(a,c)}),o=i?this.unwrapAngles(n):n;return e.map((u,c)=>({x:o[c],y:u.timestamp,ts:u.timestamp}))}pushRowsGeneric(e,t,a,i){let n=this.chart;if(!n)return;["value","sma","avg","min","max"].forEach((u,c)=>{let r=n.data.datasets[t+c];!r||!Array.isArray(r.data)||r.data.push(...this.transformRows(e,u,a,i));});}normalizeAngle(e){return (e%360+360)%360}angularDiff(e,t){let a=(e-t+540)%360-180;return Math.abs(a)}niceStepFromMantissas(e,t){if(!isFinite(e)||e<=0)return 1;let a=Math.floor(Math.log10(e)),i=e/Math.pow(10,a);return (t.find(o=>i<=o)??t[t.length-1])*Math.pow(10,a)}scheduleChartUpdate(){this._chartUpdateRafId==null&&(this._chartUpdateRafId=requestAnimationFrame(()=>{this._chartUpdateRafId=null,!(!this.chart||!this.hasValidDatasets())&&(this.updateChartAfterDataChange(),this.ngZone.runOutsideAngular(()=>this.chart?.update("none")));}));}hasValidDatasets(){let e=this.chart?.data?.datasets;if(!Array.isArray(e)||e.length<10)return false;for(let t=0;t<10;t++){let a=e[t];if(!a||!Array.isArray(a.data))return false}return true}updateChartAfterDataChange(){let e=this.chart;if(!e)return;let t=e.data.datasets[2]?.data,a=e.data.datasets[1]?.data,i=e.data.datasets[0]?.data,n=!!t?.length,o=!!a?.length,u=!!i?.length,c=n?t[t.length-1].x:o?a[a.length-1].x:u?i[i.length-1].x:void 0;if(typeof c=="number"&&isFinite(c)){let h=e.data.datasets[3]?.data,s=e.data.datasets[4]?.data,m=h?.length?h[h.length-1].x:void 0,_=s?.length?s[s.length-1].x:void 0,S=typeof m=="number"&&isFinite(m)?this.angularDiff(c,m):Number.NaN,D=typeof _=="number"&&isFinite(_)?this.angularDiff(c,_):Number.NaN,b=Number.isFinite(S)||Number.isFinite(D)?Math.max(Number.isFinite(S)?S:0,Number.isFinite(D)?D:0):Number.NaN;if(!Number.isFinite(b)){let x=n?t:o?a:i,E=Math.min(30,x?.length??0);if(E>1){let C=x.slice(x.length-E).map(y=>y.x).filter(y=>typeof y=="number"&&isFinite(y));C.length&&(b=C.reduce((y,L)=>Math.max(y,this.angularDiff(c,L)),0));}}b=Math.max(b||0,15);let N=2*b/4,T=this.niceStepFromMantissas(N,[1,1.5,2,2.5,5,7.5,10]),p=c-2*T,g=c+2*T,l=e.options.scales;l.x&&(l.x.min=p,l.x.max=g,l.x.ticks=z(G({},l.x.ticks??{}),{stepSize:T})),this.xCenter=c,this.xStep=T;}let r=e.data.datasets[7]?.data;if(r&&r.length){let h=r.length-1,s=r[h]?.x??0,m=e.data.datasets[8].data[h]?.x??s,_=e.data.datasets[9].data[h]?.x??s,S=Math.abs(s-m),D=Math.abs(_-s),b=Math.max(S,D);b=Math.max(b,.5);let N=2*b/4,T=this.niceStepFromMantissas(N,[1,2,2.5,5,10]),p=s-2*T,g=s+2*T,l=e.options.scales;l.xSpeed&&(l.xSpeed.min=p,l.xSpeed.max=g,l.xSpeed.ticks=z(G({},l.xSpeed.ticks??{}),{stepSize:T})),this.xCenterSpeed=s,this.xStepSpeed=T;}let d=this.getWindowMs(this.datasetConfig?.timeScaleFormat);if(e.data.datasets[0].data.length>0){let h=Date.now();e.data.datasets.forEach(S=>{S.data.forEach(D=>{let b=D.ts??D.y;D.y=Math.max(0,Math.min(d,h-b));});});let s=e.options.scales;s.y&&(s.y.min=0,s.y.max=d);let m;switch(this.datasetConfig?.timeScaleFormat){case "Last Minute":m=15e3;break;case "Last 5 Minutes":m=6e4;break;case "Last 30 Minutes":m=5*6e4;break;default:m=d/5;break}if(s.y){let S=G({},s.y.ticks??{});delete S.count,S.stepSize=m,s.y.ticks=S;}}}getWindowMs(e){switch(e){case "Last 30 Minutes":return 30*6e4;case "Last 5 Minutes":return 5*6e4;case "Last Minute":return 6e4;default:return 6e4}}lineGradientForAxis(e,t,a){let i=t.chartArea;if(!i)return null;let n=t.scales?.[a];if(!n)return null;let o=t.options?.scales,u=n,c=o?.[a]?.min??u.min,r=o?.[a]?.max??u.max;if(typeof c!="number"||typeof r!="number"||!isFinite(c)||!isFinite(r))return null;let d=(c+r)/2,f=n.getPixelForValue(d),h=Math.max(0,Math.min(1,(f-i.left)/i.width)),s=e.createLinearGradient(i.left,0,i.right,0);return s.addColorStop(0,this.theme().port),s.addColorStop(h,this.theme().port),s.addColorStop(h,this.theme().starboard),s.addColorStop(1,this.theme().starboard),s}setDatasetsColors(){this.lineChartData.datasets.forEach(e=>{e.label==="Value"&&(e.borderColor=this.getThemeColors().valueLine,e.backgroundColor=this.getThemeColors().valueFill),e.label==="Value Speed"&&(e.borderColor=this.getThemeColors().valueLine,e.backgroundColor=this.getThemeColors().valueFill);});}getThemeColors(){let e=this.runtime?.options()?.color,t={valueLine:"",valueFill:"",averageLine:"",averageFill:"",averageChartLine:"",chartLabel:"",chartValue:""};switch(e){case "contrast":t.valueLine=this.theme().contrastDim,t.valueFill=this.theme().contrastDimmer,t.averageLine=this.theme().contrast,t.averageFill=this.theme().contrast,t.chartValue=this.theme().contrast,t.averageChartLine=this.theme().contrast,t.chartLabel=this.theme().contrastDim;break;case "blue":t.valueLine=this.theme().blueDim,t.valueFill=this.theme().blueDimmer,t.averageLine=this.theme().blue,t.averageFill=this.theme().blue,t.chartValue=this.theme().blue,t.averageChartLine=this.theme().blueDim,t.chartLabel=this.theme().blueDim;break;case "green":t.valueLine=this.theme().greenDim,t.valueFill=this.theme().greenDimmer,t.averageLine=this.theme().green,t.averageFill=this.theme().green,t.chartValue=this.theme().green,t.averageChartLine=this.theme().greenDim,t.chartLabel=this.theme().greenDim;break;case "pink":t.valueLine=this.theme().pinkDim,t.valueFill=this.theme().pinkDimmer,t.averageLine=this.theme().pink,t.averageFill=this.theme().pink,t.chartValue=this.theme().pink,t.averageChartLine=this.theme().pinkDim,t.chartLabel=this.theme().pinkDim;break;case "orange":t.valueLine=this.theme().orangeDim,t.valueFill=this.theme().orangeDimmer,t.averageLine=this.theme().orange,t.averageFill=this.theme().orange,t.chartValue=this.theme().orange,t.averageChartLine=this.theme().orangeDim,t.chartLabel=this.theme().orangeDim;break;case "purple":t.valueLine=this.theme().purpleDim,t.valueFill=this.theme().purpleDimmer,t.averageLine=this.theme().purple,t.averageFill=this.theme().purple,t.chartValue=this.theme().purple,t.averageChartLine=this.theme().purpleDim,t.chartLabel=this.theme().purpleDim;break;case "grey":t.valueLine=this.theme().greyDim,t.valueFill=this.theme().greyDimmer,t.averageLine=this.theme().grey,t.averageFill=this.theme().grey,t.chartValue=this.theme().grey,t.averageChartLine=this.theme().greyDim,t.chartLabel=this.theme().greyDim;break;case "yellow":t.valueLine=this.theme().yellowDim,t.valueFill=this.theme().yellowDimmer,t.averageLine=this.theme().yellow,t.averageFill=this.theme().yellow,t.chartValue=this.theme().yellow,t.averageChartLine=this.theme().yellowDim,t.chartLabel=this.theme().yellowDim;break}return t}nearlyEqual(e,t,a=1e-6){if(!Number.isFinite(e)||!Number.isFinite(t))return false;let i=Math.max(1,Math.max(Math.abs(e),Math.abs(t)));return Math.abs(e-t)<=a*i}resolveTickColor(e,t,a){let n=t.options.ticks?.color;return typeof n=="function"?n({chart:e,scale:t,tick:{value:a}})??Wl.defaults.color:typeof n=="string"?n:Wl.defaults.color}axisTopLabelY(e){return e.options?.position==="top"?e.top+4:e.bottom+2}ngOnDestroy(){this._dsDirectionSub?.unsubscribe(),this._dsSpeedSub?.unsubscribe(),this._chartUpdateRafId!=null&&(cancelAnimationFrame(this._chartUpdateRafId),this._chartUpdateRafId=null),this.chart?.destroy();let e=this.widgetDataChart?.()?.nativeElement;this.canvasService.releaseCanvas(e,{clear:true,removeFromDom:true});}static \u0275fac=function(t){return new(t||O)};static \u0275cmp=JD({type:O,selectors:[["widget-windtrends-chart"]],viewQuery:function(t,a){t&1&&eg(a.widgetDataChart,tt,5,Lr),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:0,consts:[["widgetDataChart",""],[2,"z-index","inherit"]],template:function(t,a){t&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%}"]})}return O})();export{mt as WidgetWindTrendsChartComponent};
@@ -1 +1 @@
1
- import {p as p$1}from'./chunk-CaD3zVfK.js';import {G as Gt,L as Lt}from'./chunk-B6AwCAvV.js';import {u}from'./chunk-BgyxBAyq.js';import {k}from'./chunk-DfGLo6Tb.js';import {d1 as Hj,w,du as p,dv as rt,dD as _,bu as ut,$ as $j,a6 as Lr,v as vt,D as Dt,F as Fa,dn as ge,J as JD,_ as _w,M as Mw,f as eg,K as Kw,h as Fw,P as Pi,k as Qh,u as ul,g as qw,B as Bh,an as Hh,l as ud,m as dd,dx as n$1}from'./main-BNR44HGB.js';import {c}from'./chunk-D_wrJJxl.js';var L=["radialGauge"];function F(n,q){if(n&1){let t=Fw();Pi(0,"radial-gauge",2,0),Qh("resizeChange",function(a){ud(t);let e=qw();return dd(e.onResized(a))}),ul();}if(n&2){let t=qw();Bh("options",t.gaugeOptions)("value",t.displayValue()),Hh("value-text",t.textValue());}}var ne=(()=>{class n{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);metadata=w(_);unitsService=w(ut);static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:true,displayName:"Gauge Label",filterSelfPaths:true,paths:{gaugePath:{description:"Numeric Data",path:null,source:null,pathType:"number",suppressBootstrapNull:true,isPathConfigurable:true,showPathSkUnitsFilter:true,pathSkUnitsFilter:null,convertUnitTo:"unitless",sampleTime:500}},displayScale:{lower:0,upper:100,type:"linear"},gauge:{type:"ngRadial",subType:"measuring",highlightsWidth:5,scaleStart:180,barStartPosition:"left",enableTicks:true,enableProgressbar:true,enableNeedle:true},numInt:1,numDecimal:0,enableTimeout:false,color:"contrast",dataTimeout:5,ignoreZones:false};LINE="line";ANIMATION_TARGET_NEEDLE="needle";ngGauge=$j("radialGauge");gauge=$j("radialGauge",{read:Lr});value=vt(void 0);displayValue=Dt(()=>this.value()??0);shouldRenderGauge=Dt(()=>this.value()!==void 0);textValue=vt("--");colorStrokeTicks=vt("");gaugeBootstrapped=vt(false);animationEnabled=Dt(()=>this.gaugeBootstrapped());normalizedConfig=Dt(()=>this.runtime.options()??n.DEFAULT_CONFIG);gaugePathConfig=Dt(()=>this.normalizedConfig().paths?.gaugePath);adjustedScale=Dt(()=>{let t=this.normalizedConfig();return t.gauge?.subType==="capacity"?{min:t.displayScale?.lower??0,max:t.displayScale?.upper??100,majorTicks:[]}:p$1(t.displayScale?.lower??0,t.displayScale?.upper??100,t.gauge?.barStartPosition==="right")});highlights=Dt(()=>{let t=this.metadata.zones(),i=this.normalizedConfig(),a=this.theme(),e=this.gaugePathConfig();if(!t?.length)return [];if(!a)return [];if(i.ignoreZones)return [];if(i.gauge?.subType!=="measuring")return [];if(!e)return [];let o=this.adjustedScale(),r=i.gauge?.barStartPosition==="right";return k(t,a,e.convertUnitTo??"",this.unitsService,o.min,o.max,r)});displayName=Dt(()=>this.normalizedConfig().displayName??"Gauge Label");pathDataState=vt(null);viewReady=vt(false);gaugeOptions={};constructor(){Fa(()=>{let t=this.normalizedConfig(),i=this.theme(),a=this.gaugePathConfig();!i||!a?.path||ge(()=>this.streams.observe("gaugePath",e=>{e.state!==this.pathDataState()&&this.pathDataState.set(e.state||null);let o=e?.data?.value??null;if(o==null)this.value.set(t.displayScale?.lower??0),this.textValue.set("--");else {let r=t.displayScale?.lower??0,h=t.displayScale?.upper??100,f=Math.min(Math.max(o,r),h);this.value.set(f),this.textValue()==="--"&&this.textValue.set("");}}));}),Fa(()=>{this.normalizedConfig().ignoreZones||ge(()=>this.metadata.observe("gaugePath"));}),Fa(()=>{let t=this.highlights();this.viewReady()&&ge(()=>{try{if(!t.length)this.ngGauge()?.update({highlights:[]});else {let i=JSON.stringify(t);this.ngGauge()?.update({highlights:i,highlightsWidth:this.normalizedConfig().gauge?.highlightsWidth});}}catch(i){}});}),Fa(()=>{let t=this.normalizedConfig(),i=this.theme(),a=this.adjustedScale();i&&ge(()=>{if(this.buildGaugeOptions(t,i,a),this.viewReady())try{this.ngGauge()?.update(this.gaugeOptions);}catch(e){}});}),Fa(()=>{let t=this.ngGauge();!t||this.gaugeBootstrapped()||ge(()=>{try{requestAnimationFrame(()=>{this.gaugeBootstrapped.set(!0);try{t.update({animation:!0,animatedValue:!0});}catch(i){}});}catch(i){}});}),Fa(()=>{let t=this.pathDataState();this.viewReady()&&ge(()=>{let i=this.normalizedConfig(),a=this.theme();if(!a||i.ignoreZones)return;let e={},o=c(i.color??"contrast",a);switch(t){case n$1.Alarm:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=a.zoneAlarm,e.colorValueText=a.zoneAlarm;break;case n$1.Warn:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=a.zoneWarn,e.colorValueText=a.zoneWarn;break;case n$1.Alert:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=a.zoneAlert,e.colorValueText=a.zoneAlert;break;default:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=i.gauge?.subType==="measuring"?o.color:o.dim,e.colorValueText=o.color;}try{this.ngGauge()?.update(e);}catch(r){}});});}ngAfterViewInit(){this.viewReady.set(true),this.setCanvasSize();try{this.ngGauge()?.update(this.gaugeOptions);}catch(t){}}onResized(t){let i={height:t.contentRect.height,width:t.contentRect.width};try{this.ngGauge()?.update(i);}catch(a){}}setCanvasSize(){let t=this.gauge()?.nativeElement;if(!t)return;let i=t.getBoundingClientRect(),a={height:i.height,width:i.width};try{this.ngGauge()?.update(a);}catch(e){}}buildGaugeOptions(t,i,a){let e={},o=this.gaugePathConfig(),r=t.gauge??n.DEFAULT_CONFIG.gauge;e.title=this.displayName(),e.minValue=a.min,e.maxValue=a.max,e.units=o?.convertUnitTo??"",e.highlights=[];let h=this.highlights();h.length&&(e.highlights=JSON.stringify(h),e.highlightsWidth=t.gauge?.highlightsWidth),e.fontTitle="Roboto",e.fontTitleWeight="bold",e.fontUnits="Roboto",e.fontUnitsSize=25,e.fontUnitsWeight="normal",e.barStrokeWidth=0,e.barShadow=0,e.colorBarStroke="",e.fontValue="Roboto",e.fontValueWeight="bold",e.valueTextShadow=false,e.colorValueBoxShadow="",e.fontNumbers="Roboto",e.fontNumbersWeight="bold",e.valueInt=t.numInt??1,e.valueDec=t.numDecimal??2,e.majorTicksInt=e.valueInt,e.majorTicksDec=e.valueDec,e.highlightsWidth=t.gauge?.highlightsWidth,e.animation=this.animationEnabled(),e.animateOnInit=false,e.animatedValue=this.animationEnabled(),e.animationRule="linear";let f=o?.sampleTime??500;e.animationDuration=f-25,e.colorBorderShadow=false,e.colorBorderOuter=i.cardColor,e.colorBorderOuterEnd="",e.colorBorderMiddle=i.cardColor,e.colorBorderMiddleEnd="",e.colorPlate=e.colorPlateEnd=i.cardColor,e.colorBar=i.background;let g=c(t.color??"contrast",i);e.barProgress=t.gauge?.enableProgressbar,e.colorBarProgress=g.color,e.colorNeedle=g.color,e.colorNeedleEnd=g.color,e.needleShadow=true,e.colorNeedleShadowUp="black",e.colorNeedleShadowDown="black",e.colorNeedleCircleInner=e.colorPlate,e.colorNeedleCircleInnerEnd=e.colorPlate,e.colorNeedleCircleOuter=e.colorPlate,e.colorNeedleCircleOuterEnd=e.colorPlate,e.colorTitle=i.contrastDim,e.colorUnits=i.contrastDim,e.colorValueText=g.color,this.colorStrokeTicks.set(i.contrastDim),e.colorMinorTicks=i.contrastDim,e.animationTarget=this.ANIMATION_TARGET_NEEDLE,e.useMinPath=false,r.subType==="capacity"?(e.fontTitleSize=40,e.valueBox=true,e.fontValueSize=60,e.valueBoxWidth=10,e.valueBoxBorderRadius=5,e.valueBoxStroke=0,e.colorValueBoxBackground="",e.colorMajorTicks=e.colorPlate,e.colorNumbers=e.colorMinorTicks="",e.barWidth=20,e.colorBarProgress=g.dim,e.needle=r.enableNeedle,e.needleType=this.LINE,e.needleWidth=2,e.needleStart=75,e.needleEnd=95,e.needleCircleSize=1,e.needleCircleInner=false,e.needleCircleOuter=false,e.ticksAngle=360,e.startAngle=r.scaleStart||180,e.majorTicks=0,e.exactTicks=true,e.strokeTicks=false,e.minorTicks=0,e.numbersMargin=0,e.fontNumbersSize=0,e.borders=true,e.borderOuterWidth=2,e.borderMiddleWidth=1,e.borderInnerWidth=0,e.borderShadowWidth=0):(e.fontTitleSize=24,e.barWidth=15,e.valueBox=true,e.fontValueSize=60,e.valueBoxWidth=100,e.valueBoxBorderRadius=0,e.valueBoxStroke=0,e.colorValueBoxBackground="",e.needle=r.enableNeedle,e.needleType=this.LINE,e.needleWidth=2,e.needleStart=0,e.needleEnd=95,e.needleCircleSize=10,e.needleCircleInner=false,e.needleCircleOuter=false,e.ticksAngle=270,e.startAngle=45,e.barStartPosition=r.barStartPosition||"left",r.enableTicks?(e.strokeTicks=true,e.majorTicks=a.majorTicks,e.minorTicks=2,e.exactTicks=false,e.numbersMargin=3,e.fontNumbersSize=15,e.colorMajorTicks=i.contrastDim,e.colorNumbers=i.contrastDim):(e.strokeTicks=false,e.majorTicks=0,e.minorTicks=0,e.exactTicks=true,e.numbersMargin=0,e.fontNumbersSize=0,e.colorMajorTicks=e.colorPlate,e.colorNumbers=e.colorMinorTicks=""),e.borders=true,e.borderOuterWidth=2,e.borderMiddleWidth=1,e.borderInnerWidth=0,e.borderShadowWidth=0,e.animationTarget=this.ANIMATION_TARGET_NEEDLE,e.useMinPath=false),this.gaugeOptions=e;}static \u0275fac=function(i){return new(i||n)};static \u0275cmp=JD({type:n,selectors:[["widget-gauge-ng-radial"]],viewQuery:function(i,a){i&1&&eg(a.ngGauge,L,5)(a.gauge,L,5,Lr),i&2&&Kw(2);},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:1,vars:1,consts:[["radialGauge",""],["kipResizeObserver","",3,"options","value"],["kipResizeObserver","",3,"resizeChange","options","value"]],template:function(i,a){i&1&&_w(0,F,2,3,"radial-gauge",1),i&2&&Mw(a.shouldRenderGauge()?0:-1);},dependencies:[u,Gt,Lt],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%} radial-gauge{display:block;position:relative;width:100%;min-width:8px;height:100%;overflow:clip} radial-gauge>canvas{display:block;position:absolute;height:100%;width:100%;left:50%;top:50%;transform:translate(-50%,-50%);padding:0}"]})}return n})();export{ne as WidgetGaugeNgRadialComponent};
1
+ import {p as p$1}from'./chunk-CaD3zVfK.js';import {G as Gt,L as Lt}from'./chunk-q9NoPvcx.js';import {u}from'./chunk-CCfhzpE8.js';import {k}from'./chunk-B0eE4udE.js';import {d1 as Hj,w,du as p,dv as rt,dD as _,bu as ut,$ as $j,a6 as Lr,v as vt,D as Dt,F as Fa,dn as ge,J as JD,_ as _w,M as Mw,f as eg,K as Kw,h as Fw,P as Pi,k as Qh,u as ul,g as qw,B as Bh,an as Hh,l as ud,m as dd,dx as n$1}from'./main-YKDNK5VZ.js';import {c}from'./chunk-BIb-xYiS.js';var L=["radialGauge"];function F(n,q){if(n&1){let t=Fw();Pi(0,"radial-gauge",2,0),Qh("resizeChange",function(a){ud(t);let e=qw();return dd(e.onResized(a))}),ul();}if(n&2){let t=qw();Bh("options",t.gaugeOptions)("value",t.displayValue()),Hh("value-text",t.textValue());}}var ne=(()=>{class n{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);metadata=w(_);unitsService=w(ut);static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:true,displayName:"Gauge Label",filterSelfPaths:true,paths:{gaugePath:{description:"Numeric Data",path:null,source:null,pathType:"number",suppressBootstrapNull:true,isPathConfigurable:true,showPathSkUnitsFilter:true,pathSkUnitsFilter:null,convertUnitTo:"unitless",sampleTime:500}},displayScale:{lower:0,upper:100,type:"linear"},gauge:{type:"ngRadial",subType:"measuring",highlightsWidth:5,scaleStart:180,barStartPosition:"left",enableTicks:true,enableProgressbar:true,enableNeedle:true},numInt:1,numDecimal:0,enableTimeout:false,color:"contrast",dataTimeout:5,ignoreZones:false};LINE="line";ANIMATION_TARGET_NEEDLE="needle";ngGauge=$j("radialGauge");gauge=$j("radialGauge",{read:Lr});value=vt(void 0);displayValue=Dt(()=>this.value()??0);shouldRenderGauge=Dt(()=>this.value()!==void 0);textValue=vt("--");colorStrokeTicks=vt("");gaugeBootstrapped=vt(false);animationEnabled=Dt(()=>this.gaugeBootstrapped());normalizedConfig=Dt(()=>this.runtime.options()??n.DEFAULT_CONFIG);gaugePathConfig=Dt(()=>this.normalizedConfig().paths?.gaugePath);adjustedScale=Dt(()=>{let t=this.normalizedConfig();return t.gauge?.subType==="capacity"?{min:t.displayScale?.lower??0,max:t.displayScale?.upper??100,majorTicks:[]}:p$1(t.displayScale?.lower??0,t.displayScale?.upper??100,t.gauge?.barStartPosition==="right")});highlights=Dt(()=>{let t=this.metadata.zones(),i=this.normalizedConfig(),a=this.theme(),e=this.gaugePathConfig();if(!t?.length)return [];if(!a)return [];if(i.ignoreZones)return [];if(i.gauge?.subType!=="measuring")return [];if(!e)return [];let o=this.adjustedScale(),r=i.gauge?.barStartPosition==="right";return k(t,a,e.convertUnitTo??"",this.unitsService,o.min,o.max,r)});displayName=Dt(()=>this.normalizedConfig().displayName??"Gauge Label");pathDataState=vt(null);viewReady=vt(false);gaugeOptions={};constructor(){Fa(()=>{let t=this.normalizedConfig(),i=this.theme(),a=this.gaugePathConfig();!i||!a?.path||ge(()=>this.streams.observe("gaugePath",e=>{e.state!==this.pathDataState()&&this.pathDataState.set(e.state||null);let o=e?.data?.value??null;if(o==null)this.value.set(t.displayScale?.lower??0),this.textValue.set("--");else {let r=t.displayScale?.lower??0,h=t.displayScale?.upper??100,f=Math.min(Math.max(o,r),h);this.value.set(f),this.textValue()==="--"&&this.textValue.set("");}}));}),Fa(()=>{this.normalizedConfig().ignoreZones||ge(()=>this.metadata.observe("gaugePath"));}),Fa(()=>{let t=this.highlights();this.viewReady()&&ge(()=>{try{if(!t.length)this.ngGauge()?.update({highlights:[]});else {let i=JSON.stringify(t);this.ngGauge()?.update({highlights:i,highlightsWidth:this.normalizedConfig().gauge?.highlightsWidth});}}catch(i){}});}),Fa(()=>{let t=this.normalizedConfig(),i=this.theme(),a=this.adjustedScale();i&&ge(()=>{if(this.buildGaugeOptions(t,i,a),this.viewReady())try{this.ngGauge()?.update(this.gaugeOptions);}catch(e){}});}),Fa(()=>{let t=this.ngGauge();!t||this.gaugeBootstrapped()||ge(()=>{try{requestAnimationFrame(()=>{this.gaugeBootstrapped.set(!0);try{t.update({animation:!0,animatedValue:!0});}catch(i){}});}catch(i){}});}),Fa(()=>{let t=this.pathDataState();this.viewReady()&&ge(()=>{let i=this.normalizedConfig(),a=this.theme();if(!a||i.ignoreZones)return;let e={},o=c(i.color??"contrast",a);switch(t){case n$1.Alarm:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=a.zoneAlarm,e.colorValueText=a.zoneAlarm;break;case n$1.Warn:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=a.zoneWarn,e.colorValueText=a.zoneWarn;break;case n$1.Alert:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=a.zoneAlert,e.colorValueText=a.zoneAlert;break;default:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=i.gauge?.subType==="measuring"?o.color:o.dim,e.colorValueText=o.color;}try{this.ngGauge()?.update(e);}catch(r){}});});}ngAfterViewInit(){this.viewReady.set(true),this.setCanvasSize();try{this.ngGauge()?.update(this.gaugeOptions);}catch(t){}}onResized(t){let i={height:t.contentRect.height,width:t.contentRect.width};try{this.ngGauge()?.update(i);}catch(a){}}setCanvasSize(){let t=this.gauge()?.nativeElement;if(!t)return;let i=t.getBoundingClientRect(),a={height:i.height,width:i.width};try{this.ngGauge()?.update(a);}catch(e){}}buildGaugeOptions(t,i,a){let e={},o=this.gaugePathConfig(),r=t.gauge??n.DEFAULT_CONFIG.gauge;e.title=this.displayName(),e.minValue=a.min,e.maxValue=a.max,e.units=o?.convertUnitTo??"",e.highlights=[];let h=this.highlights();h.length&&(e.highlights=JSON.stringify(h),e.highlightsWidth=t.gauge?.highlightsWidth),e.fontTitle="Roboto",e.fontTitleWeight="bold",e.fontUnits="Roboto",e.fontUnitsSize=25,e.fontUnitsWeight="normal",e.barStrokeWidth=0,e.barShadow=0,e.colorBarStroke="",e.fontValue="Roboto",e.fontValueWeight="bold",e.valueTextShadow=false,e.colorValueBoxShadow="",e.fontNumbers="Roboto",e.fontNumbersWeight="bold",e.valueInt=t.numInt??1,e.valueDec=t.numDecimal??2,e.majorTicksInt=e.valueInt,e.majorTicksDec=e.valueDec,e.highlightsWidth=t.gauge?.highlightsWidth,e.animation=this.animationEnabled(),e.animateOnInit=false,e.animatedValue=this.animationEnabled(),e.animationRule="linear";let f=o?.sampleTime??500;e.animationDuration=f-25,e.colorBorderShadow=false,e.colorBorderOuter=i.cardColor,e.colorBorderOuterEnd="",e.colorBorderMiddle=i.cardColor,e.colorBorderMiddleEnd="",e.colorPlate=e.colorPlateEnd=i.cardColor,e.colorBar=i.background;let g=c(t.color??"contrast",i);e.barProgress=t.gauge?.enableProgressbar,e.colorBarProgress=g.color,e.colorNeedle=g.color,e.colorNeedleEnd=g.color,e.needleShadow=true,e.colorNeedleShadowUp="black",e.colorNeedleShadowDown="black",e.colorNeedleCircleInner=e.colorPlate,e.colorNeedleCircleInnerEnd=e.colorPlate,e.colorNeedleCircleOuter=e.colorPlate,e.colorNeedleCircleOuterEnd=e.colorPlate,e.colorTitle=i.contrastDim,e.colorUnits=i.contrastDim,e.colorValueText=g.color,this.colorStrokeTicks.set(i.contrastDim),e.colorMinorTicks=i.contrastDim,e.animationTarget=this.ANIMATION_TARGET_NEEDLE,e.useMinPath=false,r.subType==="capacity"?(e.fontTitleSize=40,e.valueBox=true,e.fontValueSize=60,e.valueBoxWidth=10,e.valueBoxBorderRadius=5,e.valueBoxStroke=0,e.colorValueBoxBackground="",e.colorMajorTicks=e.colorPlate,e.colorNumbers=e.colorMinorTicks="",e.barWidth=20,e.colorBarProgress=g.dim,e.needle=r.enableNeedle,e.needleType=this.LINE,e.needleWidth=2,e.needleStart=75,e.needleEnd=95,e.needleCircleSize=1,e.needleCircleInner=false,e.needleCircleOuter=false,e.ticksAngle=360,e.startAngle=r.scaleStart||180,e.majorTicks=0,e.exactTicks=true,e.strokeTicks=false,e.minorTicks=0,e.numbersMargin=0,e.fontNumbersSize=0,e.borders=true,e.borderOuterWidth=2,e.borderMiddleWidth=1,e.borderInnerWidth=0,e.borderShadowWidth=0):(e.fontTitleSize=24,e.barWidth=15,e.valueBox=true,e.fontValueSize=60,e.valueBoxWidth=100,e.valueBoxBorderRadius=0,e.valueBoxStroke=0,e.colorValueBoxBackground="",e.needle=r.enableNeedle,e.needleType=this.LINE,e.needleWidth=2,e.needleStart=0,e.needleEnd=95,e.needleCircleSize=10,e.needleCircleInner=false,e.needleCircleOuter=false,e.ticksAngle=270,e.startAngle=45,e.barStartPosition=r.barStartPosition||"left",r.enableTicks?(e.strokeTicks=true,e.majorTicks=a.majorTicks,e.minorTicks=2,e.exactTicks=false,e.numbersMargin=3,e.fontNumbersSize=15,e.colorMajorTicks=i.contrastDim,e.colorNumbers=i.contrastDim):(e.strokeTicks=false,e.majorTicks=0,e.minorTicks=0,e.exactTicks=true,e.numbersMargin=0,e.fontNumbersSize=0,e.colorMajorTicks=e.colorPlate,e.colorNumbers=e.colorMinorTicks=""),e.borders=true,e.borderOuterWidth=2,e.borderMiddleWidth=1,e.borderInnerWidth=0,e.borderShadowWidth=0,e.animationTarget=this.ANIMATION_TARGET_NEEDLE,e.useMinPath=false),this.gaugeOptions=e;}static \u0275fac=function(i){return new(i||n)};static \u0275cmp=JD({type:n,selectors:[["widget-gauge-ng-radial"]],viewQuery:function(i,a){i&1&&eg(a.ngGauge,L,5)(a.gauge,L,5,Lr),i&2&&Kw(2);},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:1,vars:1,consts:[["radialGauge",""],["kipResizeObserver","",3,"options","value"],["kipResizeObserver","",3,"resizeChange","options","value"]],template:function(i,a){i&1&&_w(0,F,2,3,"radial-gauge",1),i&2&&Mw(a.shouldRenderGauge()?0:-1);},dependencies:[u,Gt,Lt],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%} radial-gauge{display:block;position:relative;width:100%;min-width:8px;height:100%;overflow:clip} radial-gauge>canvas{display:block;position:absolute;height:100%;width:100%;left:50%;top:50%;transform:translate(-50%,-50%);padding:0}"]})}return n})();export{ne as WidgetGaugeNgRadialComponent};
@@ -1 +1 @@
1
- import {d1 as Hj,w,du as p$1,aZ as 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
+ import {d1 as Hj,w,du as p$1,aZ as R,$ as $j,v as vt,F as Fa,dn as ge,J as JD,cp as Uh,f as eg,K as Kw}from'./main-YKDNK5VZ.js';var p=["canvasMainRef"],M=(()=>{class s{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p$1);canvas=w(R);static DEFAULT_CONFIG={displayName:"Static Label",color:"green",bgColor:"grey",noColor:false,noBgColor:true};canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;maxTextWidth=0;maxTextHeight=0;disposed=false;fgColor=vt("");bgColor=vt("");constructor(){Fa(()=>{let t=this.runtime.options(),e=this.theme();!t||!e||ge(()=>{this.fgColor.set(this.mapColor(t.color??"contrast",e)),this.bgColor.set(this.mapColor(t.bgColor??"grey",e)),this.draw();});}),Fa(()=>{let t=this.runtime.options()?.displayName;ge(()=>{t!==void 0&&this.draw();});});}mapColor(t,e){switch(t){case "contrast":return e.contrast;case "blue":return e.blue;case "green":return e.green;case "pink":return e.pink;case "orange":return e.orange;case "purple":return e.purple;case "grey":return e.grey;case "yellow":return e.yellow;default:return e.contrast}}ngAfterViewInit(){this.canvasElement=this.canvasRef().nativeElement,this.ctx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(t,e)=>{this.cssWidth=t,this.cssHeight=e,this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.draw();}draw(){if(!this.ctx||!this.canvasElement)return;let t=this.runtime.options();if(!t)return;this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),t.noBgColor||this.canvas.drawRectangle(this.ctx,0,0,this.canvasElement.width,this.canvasElement.height,this.bgColor());let e=t.displayName||"";this.canvas.drawText(this.ctx,e,Math.floor(this.cssWidth/2),Math.floor(this.cssHeight/2+10),this.cssWidth-40,this.cssHeight-40,"bold",this.fgColor());}ngOnDestroy(){this.disposed=true;try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(t){}}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=JD({type:s,selectors:[["widget-label"]],viewQuery:function(e,c){e&1&&eg(c.canvasRef,p,5),e&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:0,consts:[["canvasMainRef",""],[1,"label-canvas"]],template:function(e,c){e&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%;overflow:hidden}.label-canvas[_ngcontent-%COMP%]{width:100%!important;height:100%!important;display:block;border-radius:var(--mat-card-elevated-container-shape, var(--mat-sys-corner-medium))}"]})}return s})();export{M as WidgetLabelComponent};
@@ -1 +1 @@
1
- import {d1 as Hj,w,du as p,dv as rt,aZ as R,a as G,cu as T,aY as xe,$ as $j,v as vt,F as Fa,dn as ge,a_ as Gp,J as JD,O as Op,bh as xp,y as yt,b as wt,cR as zt,bg as mt,P as Pi,c as $h,u as ul,k as Qh,cn as wd,T as TT,_ as _w,e as EE,M as Mw,f as eg,K as Kw,h as Fw,cV as Td,g as qw,t as pT,dE as RT,B as Bh,aA as gg,l as ud,m as dd,bp as gl}from'./main-BNR44HGB.js';import {c}from'./chunk-D_wrJJxl.js';var J=["canvasMainRef"];function Z(o,e){if(o&1&&(Pi(0,"div",10),wd(),Pi(1,"svg",11)(2,"text",12),TT(3),ul()()(),Td(),Pi(4,"div",13),wd(),Pi(5,"svg",14)(6,"text",15)(7,"tspan",16),TT(8,"\u2691"),ul(),TT(9),Pi(10,"tspan",17),TT(11,"\u2691"),ul()()()(),Td(),Pi(12,"div",18),wd(),Pi(13,"svg",19)(14,"text",12),TT(15),ul()()()),o&2){let t=qw();EE(3),gg(t.portBiasValue()),EE(6),gl(" ",t.lineLengthValue()," "),EE(6),gg(t.stbBiasValue());}}function K(o,e){if(o&1){let t=Fw();Pi(0,"button",20),Qh("click",function(){ud(t);let i=qw();return dd(i.setLineEnd("port"))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",21)(3,"text",22),TT(4,"Port End"),ul()()()(),Td(),Pi(5,"button",23),Qh("click",function(){ud(t);let i=qw();return dd(i.setLineEnd("stb"))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",21)(8,"text",22),TT(9,"Stbd End"),ul()()()();}}function X(o,e){if(o&1){let t=Fw();Pi(0,"button",24),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",5,0))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"+5m"),ul()()()(),Td(),Pi(5,"button",27),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",-5,0))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",25)(8,"text",26),TT(9,"-5m"),ul()()()(),Td(),Pi(10,"button",28),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",-5,0))}),Pi(11,"mat-icon",6),wd(),Pi(12,"svg",25)(13,"text",26),TT(14,"-5m"),ul()()()(),Td(),Pi(15,"button",29),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",5,0))}),Pi(16,"mat-icon",6),wd(),Pi(17,"svg",25)(18,"text",26),TT(19,"+5m"),ul()()()();}}function tt(o,e){if(o&1){let t=Fw();Pi(0,"button",30),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",0,i.toRadians(1)))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"\u21911\xB0"),ul()()()(),Td(),Pi(5,"button",31),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",0,i.toRadians(-1)))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",25)(8,"text",26),TT(9,"\u21931\xB0"),ul()()()(),Td(),Pi(10,"button",32),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",0,i.toRadians(1)))}),Pi(11,"mat-icon",6),wd(),Pi(12,"svg",25)(13,"text",26),TT(14,"\u21931\xB0"),ul()()()(),Td(),Pi(15,"button",33),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",0,i.toRadians(-1)))}),Pi(16,"mat-icon",6),wd(),Pi(17,"svg",25)(18,"text",26),TT(19,"\u21911\xB0"),ul()()()();}}function et(o,e){if(o&1){let t=Fw();Pi(0,"button",34),Qh("click",function(){ud(t);let i=qw();return dd(i.nextDisplayLineName())}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"Line"),ul()()()(),Td(),Pi(5,"button",35),Qh("click",function(){ud(t);let i=qw();return dd(i.setStartLine(i.getDisplayLineName()))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",36)(8,"text",37),TT(9),ul()()()();}if(o&2){let t=qw();EE(5),pT(RT("button ",t.isDisplayLineCurrent()?"line-button-current":"line-button")),Bh("matTooltip",RT("Set the ",t.getDisplayLineName()," line as the current line")),EE(4),gg(t.getDisplayLineName());}}function it(o,e){o&1&&$h(0,"div",9);}var Q=class o{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);canvas=w(R);dashboard=w(G);signalk=w(T);destroyRef=w(xe);static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:false,displayName:"DTS",filterSelfPaths:true,playBeeps:true,convertUnitTo:"m",convertUnitToGroup:"Length",numDecimal:0,ignoreZones:true,color:"contrast",enableTimeout:false,dataTimeout:5,paths:{dtsPath:{description:"Distance to Start Line",path:"self.navigation.racing.distanceStartline",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:500},lineLengthPath:{description:"Length of the start line",path:"self.navigation.racing.startLineLength",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:1e3},lineBiasPath:{description:"Bias of the start line to starboard end",path:"self.navigation.racing.stbLineBias",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:1e3},startLineNamePath:{description:"The current named start line",path:"self.navigation.racing.lines.startLineName",source:"default",pathType:"string",pathRequired:false,isPathConfigurable:false,convertUnitTo:void 0,showPathSkUnitsFilter:false,pathSkUnitsFilter:null,sampleTime:1e3},linesPath:{description:"The known named lines",path:"self.navigation.racing.lines.lines",source:"default",pathType:null,pathRequired:false,isPathConfigurable:false,convertUnitTo:void 0,showPathSkUnitsFilter:false,pathSkUnitsFilter:null,sampleTime:1e3},ttlPath:{description:"Time to sail to the start line in seconds",path:"self.navigation.racing.timeToLine",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"s",showConvertUnitTo:false,showPathSkUnitsFilter:false,pathSkUnitsFilter:"s",sampleTime:500},ttbPath:{description:"Time to delay before sailing to the start line in seconds",path:"self.navigation.racing.timeToBurn",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"s",showConvertUnitTo:false,showPathSkUnitsFilter:false,pathSkUnitsFilter:"s",sampleTime:500}}};canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;titleBitmap=null;titleBitmapText=null;titleBitmapColor=null;dtsValue=null;lengthValue=null;biasValue=null;ttlValue=null;ttbValue=null;labelColor=vt("");valueColor="";dtsColor="";maxValueTextWidth=0;maxValueTextHeight=0;displayLineIndex=0;lines=[];startLineName=null;portBiasValue=vt("");lineLengthValue=vt("");stbBiasValue=vt("");mode=vt(0);normalizedConfig=vt(o.DEFAULT_CONFIG);get pathsRecord(){return (this.runtime.options()??o.DEFAULT_CONFIG).paths??{}}constructor(){Fa(()=>{let e=this.runtime.options()??o.DEFAULT_CONFIG,t=this.theme();t&&ge(()=>{let a=c(e.color??"contrast",t);this.labelColor.set(a.dim),this.valueColor=a.color,this.draw();});}),Fa(()=>{this.pathsRecord.dtsPath?.path&&ge(()=>this.streams.observe("dtsPath",t=>{this.dtsValue=t?.data?.value??null,this.updateDtsColor(),this.draw();}));}),Fa(()=>{this.pathsRecord.lineLengthPath?.path&&ge(()=>this.streams.observe("lineLengthPath",t=>{this.lengthValue=t?.data?.value??null,this.setLenBias(),this.draw();}));}),Fa(()=>{this.pathsRecord.lineBiasPath?.path&&ge(()=>this.streams.observe("lineBiasPath",t=>{this.biasValue=t?.data?.value??null,this.setLenBias();}));}),Fa(()=>{this.pathsRecord.startLineNamePath?.path&&ge(()=>this.streams.observe("startLineNamePath",t=>{console.log("startLineName: "+JSON.stringify(t??"no data")),this.startLineName=t?.data?.value??null,this.displayLineIndex=0;for(let a=0;a<this.lines.length;a++)if(this.lines[a]===this.startLineName){this.displayLineIndex=a;break}this.draw();}));}),Fa(()=>{this.pathsRecord.linesPath?.path&&ge(()=>this.streams.observe("linesPath",t=>{if(console.log("lines: "+JSON.stringify(t??"no data")),this.lines=["Default"],this.displayLineIndex=0,t?.data?.value&&Array.isArray(t.data.value))for(let a of t.data.value)a.startLineName&&(a.startLineName===this.startLineName&&(this.displayLineIndex=this.lines.length),this.lines.push(a.startLineName));}));}),Fa(()=>{this.pathsRecord.ttlPath?.path&&ge(()=>this.streams.observe("ttlPath",t=>{this.ttlValue=t?.data?.value??null,this.draw();}));}),Fa(()=>{this.pathsRecord.ttbPath?.path&&ge(()=>this.streams.observe("ttbPath",t=>{this.ttbValue=t?.data?.value??null,this.draw();}));}),this.signalk.subscribeRequest().pipe(Gp(this.destroyRef)).subscribe(e=>{e.widgetUUID===this.id()&&e.statusCode===200&&this.beep(600,20);});}ngAfterViewInit(){this.canvasElement=this.canvasRef().nativeElement,this.ctx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(e,t)=>{this.cssWidth=e,this.cssHeight=t,this.maxValueTextWidth=Math.floor(this.cssWidth*.95),this.maxValueTextHeight=Math.floor(this.cssHeight*.95),this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.maxValueTextWidth=Math.floor(this.cssWidth*.95),this.maxValueTextHeight=Math.floor(this.cssHeight*.95),this.draw();}toggleMode(){this.mode.update(e=>(e+1)%5),this.draw();}setLineEnd(e){return this.signalk.putRequest("navigation.racing.setStartLine",{end:e,position:"bow"},this.id())??""}adjustLineEnd(e,t,a){return this.signalk.putRequest("navigation.racing.setStartLine",{end:e,delta:t,rotate:a},this.id())??""}nextDisplayLineName(){++this.displayLineIndex>=this.lines.length&&(this.displayLineIndex=0);}getDisplayLineName(){return this.lines[this.displayLineIndex]||"Default"}isDisplayLineCurrent(){return this.getDisplayLineName()===(this.startLineName||"Default")}setStartLine(e){let t=e==="Default"||!e?null:e;this.signalk.putRequest("navigation.racing.setStartLineName",{startLineName:t},this.id()),this.mode.set(0),this.draw();}toRadians(e){return e*(Math.PI/180)}draw(){if(!this.ctx||!this.canvasElement)return;let e=this.runtime.options()??o.DEFAULT_CONFIG,t=e?.displayName||"DTS",a=this.labelColor();(!this.titleBitmap||!e||this.titleBitmap.width!==this.canvasElement.width||this.titleBitmap.height!==this.canvasElement.height||this.titleBitmapText!==t||this.titleBitmapColor!==a)&&(this.titleBitmap=this.canvas.createTitleBitmap(t,a,"normal",this.cssWidth,this.cssHeight),this.titleBitmapText=t,this.titleBitmapColor=a),this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),this.titleBitmap&&this.ctx.drawImage(this.titleBitmap,0,0,this.cssWidth,this.cssHeight),this.canvas.drawText(this.ctx,this.getValueText(),Math.floor(this.cssWidth*.5),Math.floor(this.cssHeight*.325),Math.floor(this.cssWidth*.95),Math.floor(this.cssHeight*.55),"bold",this.dtsColor,"center","middle"),this.canvas.drawText(this.ctx,this.pathsRecord.dtsPath?.convertUnitTo||"m",Math.floor(this.cssWidth*.975),Math.floor(this.cssHeight*.6),Math.floor(this.cssWidth*.95),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"right","bottom"),this.canvas.drawText(this.ctx,"TTL",Math.floor(this.cssWidth*.025),Math.floor(this.cssHeight*.7),Math.floor(this.cssWidth*.1),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"left","middle"),this.canvas.drawText(this.ctx,this.getTimeToLineText(),Math.floor(this.cssWidth*.15),Math.floor(this.cssHeight-.8),Math.floor(this.cssWidth*.35),Math.floor(this.cssHeight*.35),"bold",this.dtsColor,"left","bottom"),this.canvas.drawText(this.ctx,"TTB",Math.floor(this.cssWidth*.525),Math.floor(this.cssHeight*.7),Math.floor(this.cssWidth*.1),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"left","middle"),this.canvas.drawText(this.ctx,this.getTimeToBurnText(),Math.floor(this.cssWidth*.65),Math.floor(this.cssHeight-.8),Math.floor(this.cssWidth*.35),Math.floor(this.cssHeight*.35),"bold",this.dtsColor,"left","bottom"),this.setLenBias();}getValueText(){if(this.dtsValue===null)return "--";let e=this.runtime.options()??o.DEFAULT_CONFIG;return this.dtsValue.toFixed(e?.numDecimal??0)}toHHMMSS(e){if(e==null||isNaN(e))return "-:--";let t=e<0;t&&(e=-e);let a=Math.floor(e/3600),i=Math.floor(e%3600/60),f=Math.floor(e%60),C=t?"-":"";return a===0?`${C}${i.toString().padStart(1,"0")}:${f.toString().padStart(2,"0")}`:`${C}${a.toString().padStart(1,"0")}:${i.toString().padStart(2,"0")}:${f.toString().padStart(2,"0")}`}getTimeToLineText(){return this.toHHMMSS(this.ttlValue??0)}getTimeToBurnText(){return this.toHHMMSS(this.ttbValue??0)}setLenBias(){let e=this.runtime.options()??o.DEFAULT_CONFIG,t=this.pathsRecord.lineLengthPath,a=this.pathsRecord.lineBiasPath;if(t?.path&&this.lengthValue!=null){let i=t.convertUnitTo;i==="feet"&&(i="\u2032"),this.lineLengthValue.set(`\u2015${this.applyDecorations(this.lengthValue.toFixed(e.numDecimal??0))}${i??""}\u2015`);}if(a?.path&&this.biasValue!=null){let i=a.convertUnitTo;i==="feet"&&(i="\u2032"),this.biasValue<0?(this.portBiasValue.set("+"+(-this.biasValue).toFixed(e.numDecimal??0)+(i??"")),this.stbBiasValue.set(this.biasValue.toFixed(e.numDecimal??0)+(i??""))):(this.portBiasValue.set(" "+(-this.biasValue).toFixed(e.numDecimal??0)+(i??"")),this.stbBiasValue.set(" +"+this.biasValue.toFixed(e.numDecimal??0)+(i??"")));}}applyDecorations(e){switch(this.pathsRecord.dtsPath?.convertUnitTo){case "percent":case "percentraw":return e+"%";default:return e}}updateDtsColor(){let e=this.theme(),t=this.runtime.options()??o.DEFAULT_CONFIG;e&&(t.ignoreZones?this.dtsValue?this.dtsValue<0?this.dtsColor=e.zoneAlarm:this.dtsValue<10?this.dtsColor=e.zoneWarn:this.dtsValue<20?this.dtsColor=e.zoneAlert:this.dtsColor=this.valueColor:this.dtsColor=this.valueColor:this.dtsColor=this.valueColor);}beep(e=440,t=100){if(!this.runtime.options()?.playBeeps)return;let a=window.AudioContext||window.webkitAudioContext,i=new a,f=i.createOscillator(),C=i.createGain();f.connect(C),C.connect(i.destination),f.type="sine",f.frequency.value=e,C.gain.value=.1,f.start(),f.stop(i.currentTime+t/1e3);}ngOnDestroy(){try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(e){}}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=JD({type:o,selectors:[["widget-racer-line"]],viewQuery:function(t,a){t&1&&eg(a.canvasRef,J,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:16,vars:2,consts:[["canvasMainRef",""],[1,"line-wrapper"],[1,"filler"],[1,"line-canvas"],[1,"buttons-container"],["mat-flat-button","","matTooltip","Select the control mode",1,"button","select-button",3,"click"],[1,"buttons-svg-icon"],["width","100%","height","100%","viewBox","0 0 80 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","40","y","9"],[1,"widgetOverlay"],[1,"pin-container"],["width","100%","height","100%","viewBox","0 0 70 18","preserveAspectRatio","xMidYMid meet",1,"svg-content","pin"],["x","33","y","14"],[1,"len-bias-container"],["width","100%","height","100%","viewBox","0 0 90 12","preserveAspectRatio","xMidYMid meet",1,"svg-content","len-bias"],["x","45","y","9"],[1,"pin"],[1,"boat"],[1,"boat-container"],["width","100%","height","100%","viewBox","0 0 70 18","preserveAspectRatio","xMidYMid meet",1,"svg-content","boat"],["mat-flat-button","","matTooltip","Set the port(pin) end of the line to the current position",1,"button","port-button",3,"click"],["width","100%","height","100%","viewBox","0 0 100 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","50","y","11"],["mat-flat-button","","matTooltip","Set the starboard(boat) end of the line to the current position",1,"button","starboard-button",3,"click"],["mat-flat-button","","matTooltip","Increase the line length by 5m at the port(pin) end",1,"button","port-small-button",3,"click"],["width","100%","height","100%","viewBox","0 0 50 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","25","y","11"],["mat-flat-button","","matTooltip","Decrease the line length by 5m at the port(pin) end",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Decrease the line length by 5m at the starboard(boat) end",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Increase the line length by 5m at the starboard(boat) end",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the port(pin) end 1\xB0 clockwise",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the port(pin) end 1\xB0 counter-clockwise",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the starboard(boat) end 1\xB0 counter-clockwise",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the starboard(boat) end 1\xB0 clockwise",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Display the next named line",1,"button","select-button",3,"click"],["mat-flat-button","",3,"click","matTooltip"],["width","100%","height","100%","viewBox","0 0 150 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","75","y","11"]],template:function(t,a){if(t&1&&(Pi(0,"div",1)(1,"div",2),$h(2,"canvas",3,0),ul(),Pi(4,"div",4)(5,"button",5),Qh("click",function(){return a.toggleMode()}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",7)(8,"text",8),TT(9,"\u22EE"),ul()()()(),_w(10,Z,16,3)(11,K,10,0)(12,X,20,0)(13,tt,20,0)(14,et,10,6),ul(),_w(15,it,1,0,"div",9),ul()),t&2){let i;EE(10),Mw((i=a.mode())===0?10:i===1?11:i===2?12:i===3?13:i===4?14:-1),EE(5),Mw(a.dashboard.isDashboardStatic()?-1:15);}},dependencies:[Op,xp,yt,wt,zt,mt],styles:["[_nghost-%COMP%]{overflow:clip;display:block;height:100%;width:100%}.line-wrapper[_ngcontent-%COMP%]{width:100%;height:100%;min-height:1px}.line-canvas[_ngcontent-%COMP%]{position:absolute;width:100%!important;height:76%!important;display:block;top:0;left:0}.filler[_ngcontent-%COMP%]{width:100%;height:76%}.buttons-container[_ngcontent-%COMP%]{display:flex;flex-wrap:nowrap;justify-content:space-between;column-gap:2%;position:relative;height:24%;width:100%;padding:0 10px 14px;z-index:20;pointer-events:auto;align-items:center}.button[_ngcontent-%COMP%]{min-width:0px;width:100%;border-radius:12px;align-items:center;justify-content:center;cursor:pointer;--mat-button-filled-container-height: 100%;--mat-button-filled-horizontal-padding: 0px;--mat-button-filled-icon-spacing: 0px}.select-button[_ngcontent-%COMP%]{flex:none;width:18%;--mat-button-filled-container-color: var(--kip-blue-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.line-button[_ngcontent-%COMP%]{flex:none;width:58%;--mat-button-filled-container-color: var(--kip-grey-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.line-button-current[_ngcontent-%COMP%]{flex:none;width:58%;--mat-button-filled-container-color: var(--kip-orange-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.port-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.starboard-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-starboard-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.port-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.starboard-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-starboard-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.buttons-svg-icon[_ngcontent-%COMP%]{width:100%;height:100%;margin:0;padding:0}.svg-content[_ngcontent-%COMP%]{width:100%;height:100%;padding:0;margin:0}.svg-content[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-family:Roboto;font-size:15px;font-weight:700;text-align:center;text-anchor:middle;font-style:normal;font-variant:normal;font-stretch:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke:none}.pin-container[_ngcontent-%COMP%]{flex-basis:18%}.pin[_ngcontent-%COMP%]{fill:var(--kip-port-color)}.pin[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:19px}.len-bias-container[_ngcontent-%COMP%]{flex-basis:35%}.len-bias[_ngcontent-%COMP%]{fill:var(--kip-contrast-color)}.len-bias[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:12px}.boat-container[_ngcontent-%COMP%]{flex-basis:18%}.boat[_ngcontent-%COMP%]{fill:var(--kip-starboard-color)}.boat[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:19px}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent;z-index:21}"]})};export{Q as WidgetRacerLineComponent};
1
+ import {d1 as Hj,w,du as p,dv as rt,aZ as R,a as G,cu as T,aY as xe,$ as $j,v as vt,F as Fa,dn as ge,a_ as Gp,J as JD,O as Op,bh as xp,y as yt,b as wt,cR as zt,bg as mt,P as Pi,c as $h,u as ul,k as Qh,cn as wd,T as TT,_ as _w,e as EE,M as Mw,f as eg,K as Kw,h as Fw,cV as Td,g as qw,t as pT,dE as RT,B as Bh,aA as gg,l as ud,m as dd,bp as gl}from'./main-YKDNK5VZ.js';import {c}from'./chunk-BIb-xYiS.js';var J=["canvasMainRef"];function Z(o,e){if(o&1&&(Pi(0,"div",10),wd(),Pi(1,"svg",11)(2,"text",12),TT(3),ul()()(),Td(),Pi(4,"div",13),wd(),Pi(5,"svg",14)(6,"text",15)(7,"tspan",16),TT(8,"\u2691"),ul(),TT(9),Pi(10,"tspan",17),TT(11,"\u2691"),ul()()()(),Td(),Pi(12,"div",18),wd(),Pi(13,"svg",19)(14,"text",12),TT(15),ul()()()),o&2){let t=qw();EE(3),gg(t.portBiasValue()),EE(6),gl(" ",t.lineLengthValue()," "),EE(6),gg(t.stbBiasValue());}}function K(o,e){if(o&1){let t=Fw();Pi(0,"button",20),Qh("click",function(){ud(t);let i=qw();return dd(i.setLineEnd("port"))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",21)(3,"text",22),TT(4,"Port End"),ul()()()(),Td(),Pi(5,"button",23),Qh("click",function(){ud(t);let i=qw();return dd(i.setLineEnd("stb"))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",21)(8,"text",22),TT(9,"Stbd End"),ul()()()();}}function X(o,e){if(o&1){let t=Fw();Pi(0,"button",24),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",5,0))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"+5m"),ul()()()(),Td(),Pi(5,"button",27),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",-5,0))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",25)(8,"text",26),TT(9,"-5m"),ul()()()(),Td(),Pi(10,"button",28),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",-5,0))}),Pi(11,"mat-icon",6),wd(),Pi(12,"svg",25)(13,"text",26),TT(14,"-5m"),ul()()()(),Td(),Pi(15,"button",29),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",5,0))}),Pi(16,"mat-icon",6),wd(),Pi(17,"svg",25)(18,"text",26),TT(19,"+5m"),ul()()()();}}function tt(o,e){if(o&1){let t=Fw();Pi(0,"button",30),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",0,i.toRadians(1)))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"\u21911\xB0"),ul()()()(),Td(),Pi(5,"button",31),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",0,i.toRadians(-1)))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",25)(8,"text",26),TT(9,"\u21931\xB0"),ul()()()(),Td(),Pi(10,"button",32),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",0,i.toRadians(1)))}),Pi(11,"mat-icon",6),wd(),Pi(12,"svg",25)(13,"text",26),TT(14,"\u21931\xB0"),ul()()()(),Td(),Pi(15,"button",33),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",0,i.toRadians(-1)))}),Pi(16,"mat-icon",6),wd(),Pi(17,"svg",25)(18,"text",26),TT(19,"\u21911\xB0"),ul()()()();}}function et(o,e){if(o&1){let t=Fw();Pi(0,"button",34),Qh("click",function(){ud(t);let i=qw();return dd(i.nextDisplayLineName())}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"Line"),ul()()()(),Td(),Pi(5,"button",35),Qh("click",function(){ud(t);let i=qw();return dd(i.setStartLine(i.getDisplayLineName()))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",36)(8,"text",37),TT(9),ul()()()();}if(o&2){let t=qw();EE(5),pT(RT("button ",t.isDisplayLineCurrent()?"line-button-current":"line-button")),Bh("matTooltip",RT("Set the ",t.getDisplayLineName()," line as the current line")),EE(4),gg(t.getDisplayLineName());}}function it(o,e){o&1&&$h(0,"div",9);}var Q=class o{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);canvas=w(R);dashboard=w(G);signalk=w(T);destroyRef=w(xe);static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:false,displayName:"DTS",filterSelfPaths:true,playBeeps:true,convertUnitTo:"m",convertUnitToGroup:"Length",numDecimal:0,ignoreZones:true,color:"contrast",enableTimeout:false,dataTimeout:5,paths:{dtsPath:{description:"Distance to Start Line",path:"self.navigation.racing.distanceStartline",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:500},lineLengthPath:{description:"Length of the start line",path:"self.navigation.racing.startLineLength",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:1e3},lineBiasPath:{description:"Bias of the start line to starboard end",path:"self.navigation.racing.stbLineBias",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:1e3},startLineNamePath:{description:"The current named start line",path:"self.navigation.racing.lines.startLineName",source:"default",pathType:"string",pathRequired:false,isPathConfigurable:false,convertUnitTo:void 0,showPathSkUnitsFilter:false,pathSkUnitsFilter:null,sampleTime:1e3},linesPath:{description:"The known named lines",path:"self.navigation.racing.lines.lines",source:"default",pathType:null,pathRequired:false,isPathConfigurable:false,convertUnitTo:void 0,showPathSkUnitsFilter:false,pathSkUnitsFilter:null,sampleTime:1e3},ttlPath:{description:"Time to sail to the start line in seconds",path:"self.navigation.racing.timeToLine",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"s",showConvertUnitTo:false,showPathSkUnitsFilter:false,pathSkUnitsFilter:"s",sampleTime:500},ttbPath:{description:"Time to delay before sailing to the start line in seconds",path:"self.navigation.racing.timeToBurn",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"s",showConvertUnitTo:false,showPathSkUnitsFilter:false,pathSkUnitsFilter:"s",sampleTime:500}}};canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;titleBitmap=null;titleBitmapText=null;titleBitmapColor=null;dtsValue=null;lengthValue=null;biasValue=null;ttlValue=null;ttbValue=null;labelColor=vt("");valueColor="";dtsColor="";maxValueTextWidth=0;maxValueTextHeight=0;displayLineIndex=0;lines=[];startLineName=null;portBiasValue=vt("");lineLengthValue=vt("");stbBiasValue=vt("");mode=vt(0);normalizedConfig=vt(o.DEFAULT_CONFIG);get pathsRecord(){return (this.runtime.options()??o.DEFAULT_CONFIG).paths??{}}constructor(){Fa(()=>{let e=this.runtime.options()??o.DEFAULT_CONFIG,t=this.theme();t&&ge(()=>{let a=c(e.color??"contrast",t);this.labelColor.set(a.dim),this.valueColor=a.color,this.draw();});}),Fa(()=>{this.pathsRecord.dtsPath?.path&&ge(()=>this.streams.observe("dtsPath",t=>{this.dtsValue=t?.data?.value??null,this.updateDtsColor(),this.draw();}));}),Fa(()=>{this.pathsRecord.lineLengthPath?.path&&ge(()=>this.streams.observe("lineLengthPath",t=>{this.lengthValue=t?.data?.value??null,this.setLenBias(),this.draw();}));}),Fa(()=>{this.pathsRecord.lineBiasPath?.path&&ge(()=>this.streams.observe("lineBiasPath",t=>{this.biasValue=t?.data?.value??null,this.setLenBias();}));}),Fa(()=>{this.pathsRecord.startLineNamePath?.path&&ge(()=>this.streams.observe("startLineNamePath",t=>{console.log("startLineName: "+JSON.stringify(t??"no data")),this.startLineName=t?.data?.value??null,this.displayLineIndex=0;for(let a=0;a<this.lines.length;a++)if(this.lines[a]===this.startLineName){this.displayLineIndex=a;break}this.draw();}));}),Fa(()=>{this.pathsRecord.linesPath?.path&&ge(()=>this.streams.observe("linesPath",t=>{if(console.log("lines: "+JSON.stringify(t??"no data")),this.lines=["Default"],this.displayLineIndex=0,t?.data?.value&&Array.isArray(t.data.value))for(let a of t.data.value)a.startLineName&&(a.startLineName===this.startLineName&&(this.displayLineIndex=this.lines.length),this.lines.push(a.startLineName));}));}),Fa(()=>{this.pathsRecord.ttlPath?.path&&ge(()=>this.streams.observe("ttlPath",t=>{this.ttlValue=t?.data?.value??null,this.draw();}));}),Fa(()=>{this.pathsRecord.ttbPath?.path&&ge(()=>this.streams.observe("ttbPath",t=>{this.ttbValue=t?.data?.value??null,this.draw();}));}),this.signalk.subscribeRequest().pipe(Gp(this.destroyRef)).subscribe(e=>{e.widgetUUID===this.id()&&e.statusCode===200&&this.beep(600,20);});}ngAfterViewInit(){this.canvasElement=this.canvasRef().nativeElement,this.ctx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(e,t)=>{this.cssWidth=e,this.cssHeight=t,this.maxValueTextWidth=Math.floor(this.cssWidth*.95),this.maxValueTextHeight=Math.floor(this.cssHeight*.95),this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.maxValueTextWidth=Math.floor(this.cssWidth*.95),this.maxValueTextHeight=Math.floor(this.cssHeight*.95),this.draw();}toggleMode(){this.mode.update(e=>(e+1)%5),this.draw();}setLineEnd(e){return this.signalk.putRequest("navigation.racing.setStartLine",{end:e,position:"bow"},this.id())??""}adjustLineEnd(e,t,a){return this.signalk.putRequest("navigation.racing.setStartLine",{end:e,delta:t,rotate:a},this.id())??""}nextDisplayLineName(){++this.displayLineIndex>=this.lines.length&&(this.displayLineIndex=0);}getDisplayLineName(){return this.lines[this.displayLineIndex]||"Default"}isDisplayLineCurrent(){return this.getDisplayLineName()===(this.startLineName||"Default")}setStartLine(e){let t=e==="Default"||!e?null:e;this.signalk.putRequest("navigation.racing.setStartLineName",{startLineName:t},this.id()),this.mode.set(0),this.draw();}toRadians(e){return e*(Math.PI/180)}draw(){if(!this.ctx||!this.canvasElement)return;let e=this.runtime.options()??o.DEFAULT_CONFIG,t=e?.displayName||"DTS",a=this.labelColor();(!this.titleBitmap||!e||this.titleBitmap.width!==this.canvasElement.width||this.titleBitmap.height!==this.canvasElement.height||this.titleBitmapText!==t||this.titleBitmapColor!==a)&&(this.titleBitmap=this.canvas.createTitleBitmap(t,a,"normal",this.cssWidth,this.cssHeight),this.titleBitmapText=t,this.titleBitmapColor=a),this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),this.titleBitmap&&this.ctx.drawImage(this.titleBitmap,0,0,this.cssWidth,this.cssHeight),this.canvas.drawText(this.ctx,this.getValueText(),Math.floor(this.cssWidth*.5),Math.floor(this.cssHeight*.325),Math.floor(this.cssWidth*.95),Math.floor(this.cssHeight*.55),"bold",this.dtsColor,"center","middle"),this.canvas.drawText(this.ctx,this.pathsRecord.dtsPath?.convertUnitTo||"m",Math.floor(this.cssWidth*.975),Math.floor(this.cssHeight*.6),Math.floor(this.cssWidth*.95),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"right","bottom"),this.canvas.drawText(this.ctx,"TTL",Math.floor(this.cssWidth*.025),Math.floor(this.cssHeight*.7),Math.floor(this.cssWidth*.1),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"left","middle"),this.canvas.drawText(this.ctx,this.getTimeToLineText(),Math.floor(this.cssWidth*.15),Math.floor(this.cssHeight-.8),Math.floor(this.cssWidth*.35),Math.floor(this.cssHeight*.35),"bold",this.dtsColor,"left","bottom"),this.canvas.drawText(this.ctx,"TTB",Math.floor(this.cssWidth*.525),Math.floor(this.cssHeight*.7),Math.floor(this.cssWidth*.1),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"left","middle"),this.canvas.drawText(this.ctx,this.getTimeToBurnText(),Math.floor(this.cssWidth*.65),Math.floor(this.cssHeight-.8),Math.floor(this.cssWidth*.35),Math.floor(this.cssHeight*.35),"bold",this.dtsColor,"left","bottom"),this.setLenBias();}getValueText(){if(this.dtsValue===null)return "--";let e=this.runtime.options()??o.DEFAULT_CONFIG;return this.dtsValue.toFixed(e?.numDecimal??0)}toHHMMSS(e){if(e==null||isNaN(e))return "-:--";let t=e<0;t&&(e=-e);let a=Math.floor(e/3600),i=Math.floor(e%3600/60),f=Math.floor(e%60),C=t?"-":"";return a===0?`${C}${i.toString().padStart(1,"0")}:${f.toString().padStart(2,"0")}`:`${C}${a.toString().padStart(1,"0")}:${i.toString().padStart(2,"0")}:${f.toString().padStart(2,"0")}`}getTimeToLineText(){return this.toHHMMSS(this.ttlValue??0)}getTimeToBurnText(){return this.toHHMMSS(this.ttbValue??0)}setLenBias(){let e=this.runtime.options()??o.DEFAULT_CONFIG,t=this.pathsRecord.lineLengthPath,a=this.pathsRecord.lineBiasPath;if(t?.path&&this.lengthValue!=null){let i=t.convertUnitTo;i==="feet"&&(i="\u2032"),this.lineLengthValue.set(`\u2015${this.applyDecorations(this.lengthValue.toFixed(e.numDecimal??0))}${i??""}\u2015`);}if(a?.path&&this.biasValue!=null){let i=a.convertUnitTo;i==="feet"&&(i="\u2032"),this.biasValue<0?(this.portBiasValue.set("+"+(-this.biasValue).toFixed(e.numDecimal??0)+(i??"")),this.stbBiasValue.set(this.biasValue.toFixed(e.numDecimal??0)+(i??""))):(this.portBiasValue.set(" "+(-this.biasValue).toFixed(e.numDecimal??0)+(i??"")),this.stbBiasValue.set(" +"+this.biasValue.toFixed(e.numDecimal??0)+(i??"")));}}applyDecorations(e){switch(this.pathsRecord.dtsPath?.convertUnitTo){case "percent":case "percentraw":return e+"%";default:return e}}updateDtsColor(){let e=this.theme(),t=this.runtime.options()??o.DEFAULT_CONFIG;e&&(t.ignoreZones?this.dtsValue?this.dtsValue<0?this.dtsColor=e.zoneAlarm:this.dtsValue<10?this.dtsColor=e.zoneWarn:this.dtsValue<20?this.dtsColor=e.zoneAlert:this.dtsColor=this.valueColor:this.dtsColor=this.valueColor:this.dtsColor=this.valueColor);}beep(e=440,t=100){if(!this.runtime.options()?.playBeeps)return;let a=window.AudioContext||window.webkitAudioContext,i=new a,f=i.createOscillator(),C=i.createGain();f.connect(C),C.connect(i.destination),f.type="sine",f.frequency.value=e,C.gain.value=.1,f.start(),f.stop(i.currentTime+t/1e3);}ngOnDestroy(){try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(e){}}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=JD({type:o,selectors:[["widget-racer-line"]],viewQuery:function(t,a){t&1&&eg(a.canvasRef,J,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:16,vars:2,consts:[["canvasMainRef",""],[1,"line-wrapper"],[1,"filler"],[1,"line-canvas"],[1,"buttons-container"],["mat-flat-button","","matTooltip","Select the control mode",1,"button","select-button",3,"click"],[1,"buttons-svg-icon"],["width","100%","height","100%","viewBox","0 0 80 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","40","y","9"],[1,"widgetOverlay"],[1,"pin-container"],["width","100%","height","100%","viewBox","0 0 70 18","preserveAspectRatio","xMidYMid meet",1,"svg-content","pin"],["x","33","y","14"],[1,"len-bias-container"],["width","100%","height","100%","viewBox","0 0 90 12","preserveAspectRatio","xMidYMid meet",1,"svg-content","len-bias"],["x","45","y","9"],[1,"pin"],[1,"boat"],[1,"boat-container"],["width","100%","height","100%","viewBox","0 0 70 18","preserveAspectRatio","xMidYMid meet",1,"svg-content","boat"],["mat-flat-button","","matTooltip","Set the port(pin) end of the line to the current position",1,"button","port-button",3,"click"],["width","100%","height","100%","viewBox","0 0 100 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","50","y","11"],["mat-flat-button","","matTooltip","Set the starboard(boat) end of the line to the current position",1,"button","starboard-button",3,"click"],["mat-flat-button","","matTooltip","Increase the line length by 5m at the port(pin) end",1,"button","port-small-button",3,"click"],["width","100%","height","100%","viewBox","0 0 50 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","25","y","11"],["mat-flat-button","","matTooltip","Decrease the line length by 5m at the port(pin) end",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Decrease the line length by 5m at the starboard(boat) end",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Increase the line length by 5m at the starboard(boat) end",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the port(pin) end 1\xB0 clockwise",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the port(pin) end 1\xB0 counter-clockwise",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the starboard(boat) end 1\xB0 counter-clockwise",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the starboard(boat) end 1\xB0 clockwise",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Display the next named line",1,"button","select-button",3,"click"],["mat-flat-button","",3,"click","matTooltip"],["width","100%","height","100%","viewBox","0 0 150 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","75","y","11"]],template:function(t,a){if(t&1&&(Pi(0,"div",1)(1,"div",2),$h(2,"canvas",3,0),ul(),Pi(4,"div",4)(5,"button",5),Qh("click",function(){return a.toggleMode()}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",7)(8,"text",8),TT(9,"\u22EE"),ul()()()(),_w(10,Z,16,3)(11,K,10,0)(12,X,20,0)(13,tt,20,0)(14,et,10,6),ul(),_w(15,it,1,0,"div",9),ul()),t&2){let i;EE(10),Mw((i=a.mode())===0?10:i===1?11:i===2?12:i===3?13:i===4?14:-1),EE(5),Mw(a.dashboard.isDashboardStatic()?-1:15);}},dependencies:[Op,xp,yt,wt,zt,mt],styles:["[_nghost-%COMP%]{overflow:clip;display:block;height:100%;width:100%}.line-wrapper[_ngcontent-%COMP%]{width:100%;height:100%;min-height:1px}.line-canvas[_ngcontent-%COMP%]{position:absolute;width:100%!important;height:76%!important;display:block;top:0;left:0}.filler[_ngcontent-%COMP%]{width:100%;height:76%}.buttons-container[_ngcontent-%COMP%]{display:flex;flex-wrap:nowrap;justify-content:space-between;column-gap:2%;position:relative;height:24%;width:100%;padding:0 10px 14px;z-index:20;pointer-events:auto;align-items:center}.button[_ngcontent-%COMP%]{min-width:0px;width:100%;border-radius:12px;align-items:center;justify-content:center;cursor:pointer;--mat-button-filled-container-height: 100%;--mat-button-filled-horizontal-padding: 0px;--mat-button-filled-icon-spacing: 0px}.select-button[_ngcontent-%COMP%]{flex:none;width:18%;--mat-button-filled-container-color: var(--kip-blue-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.line-button[_ngcontent-%COMP%]{flex:none;width:58%;--mat-button-filled-container-color: var(--kip-grey-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.line-button-current[_ngcontent-%COMP%]{flex:none;width:58%;--mat-button-filled-container-color: var(--kip-orange-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.port-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.starboard-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-starboard-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.port-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.starboard-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-starboard-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.buttons-svg-icon[_ngcontent-%COMP%]{width:100%;height:100%;margin:0;padding:0}.svg-content[_ngcontent-%COMP%]{width:100%;height:100%;padding:0;margin:0}.svg-content[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-family:Roboto;font-size:15px;font-weight:700;text-align:center;text-anchor:middle;font-style:normal;font-variant:normal;font-stretch:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke:none}.pin-container[_ngcontent-%COMP%]{flex-basis:18%}.pin[_ngcontent-%COMP%]{fill:var(--kip-port-color)}.pin[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:19px}.len-bias-container[_ngcontent-%COMP%]{flex-basis:35%}.len-bias[_ngcontent-%COMP%]{fill:var(--kip-contrast-color)}.len-bias[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:12px}.boat-container[_ngcontent-%COMP%]{flex-basis:18%}.boat[_ngcontent-%COMP%]{fill:var(--kip-starboard-color)}.boat[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:19px}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent;z-index:21}"]})};export{Q as WidgetRacerLineComponent};