@mxtommy/kip 4.8.0-beta.1 → 4.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/LICENSE +3 -0
- package/README.md +56 -49
- package/package.json +24 -21
- package/plugin/history-series.service.js +108 -30
- package/plugin/index.js +157 -115
- package/plugin/kip-series-contract.js +12 -3
- package/plugin/openApi.json +64 -13
- package/plugin/sqlite-history-storage.service.js +4 -2
- package/plugin/src/history-series.service.js +634 -0
- package/plugin/src/index.js +1322 -0
- package/plugin/src/kip-series-contract.js +31 -0
- package/plugin/src/openApi.json +855 -0
- package/plugin/src/sqlite-history-storage.service.js +1122 -0
- package/public/3rdpartylicenses.txt +569 -727
- package/public/assets/help-docs/chartplotter.md +1 -1
- package/public/assets/help-docs/contributing-widgets.md +40 -0
- package/public/assets/help-docs/dashboards.md +6 -0
- package/public/assets/help-docs/history-api.md +69 -71
- package/public/assets/help-docs/menu.json +27 -7
- package/public/assets/help-docs/time-series.md +81 -0
- package/public/assets/help-docs/welcome.md +1 -1
- package/public/assets/svg/icons.svg +36 -1
- package/public/chunk-00hwknVI.js +1 -0
- package/public/chunk-5U8d2Ygo.js +14 -0
- package/public/chunk-AANk-NXH.js +1015 -0
- package/public/chunk-B6bEhzNR.js +1 -0
- package/public/chunk-B82ADJSs.js +1 -0
- package/public/chunk-BJz7Ij9E.js +1 -0
- package/public/chunk-BKj60jdq.js +1 -0
- package/public/chunk-BOAD0N2a.js +2 -0
- package/public/chunk-BQr-tSkv.js +1 -0
- package/public/chunk-BX6skw5k.js +1 -0
- package/public/chunk-BdokyhBM.js +1 -0
- package/public/chunk-Blokg6Ds.js +1 -0
- package/public/chunk-BoNDCNGE.js +1 -0
- package/public/chunk-Bp0MQwPM.js +1 -0
- package/public/chunk-BwOIef42.js +1 -0
- package/public/chunk-By8ZVvDx.js +2 -0
- package/public/chunk-C2VQxCXa.js +1 -0
- package/public/chunk-C6UXF7BI.js +1 -0
- package/public/chunk-CA6RRaxd.js +1 -0
- package/public/chunk-CIlfzV9R.js +1 -0
- package/public/chunk-CL2xiH57.js +1 -0
- package/public/chunk-CNMFlw_H.js +1 -0
- package/public/chunk-CNNTuNlM.js +1 -0
- package/public/chunk-CQNVyz8q.js +1 -0
- package/public/chunk-CXvG8mMq.js +1 -0
- package/public/chunk-CaD3zVfK.js +1 -0
- package/public/chunk-CkXTl3su.js +1 -0
- package/public/chunk-CpMCBDvH.js +1 -0
- package/public/chunk-CpuB_ZZz.js +2 -0
- package/public/chunk-CrBxxZCe.js +1 -0
- package/public/chunk-CwSa_BNV.js +1 -0
- package/public/chunk-D4xZ2tGB.js +39 -0
- package/public/chunk-DDqeRiB0.js +1 -0
- package/public/chunk-DE4ylhpq.js +1 -0
- package/public/chunk-DNS-qsFC.js +1 -0
- package/public/chunk-DQnoPLyC.js +1 -0
- package/public/chunk-DWLISAZi.js +1 -0
- package/public/chunk-DXkKj21H.js +1 -0
- package/public/chunk-DchvLV_Y.js +1 -0
- package/public/chunk-DjZgzSiH.js +1 -0
- package/public/chunk-DumLX5k_.js +1 -0
- package/public/chunk-Dxlia2NE.js +1 -0
- package/public/chunk-DzTTqoF_.js +1 -0
- package/public/chunk-H9_eqTYx.js +1 -0
- package/public/chunk-Ii9n-oiL.js +1 -0
- package/public/chunk-JbEkcxJm.js +2 -0
- package/public/chunk-MjWuPUhu.js +1 -0
- package/public/chunk-PheXEqie.js +1 -0
- package/public/chunk-TakPRI3t.js +2 -0
- package/public/chunk-VgxMqRPk.js +3 -0
- package/public/chunk-dgaOX1wC.js +382 -0
- package/public/chunk-hd2_AKwt.js +1 -0
- package/public/chunk-nu4vZg-z.js +1 -0
- package/public/chunk-sNakMDHi.js +1 -0
- package/public/chunk-tAiV3ARh.js +1 -0
- package/public/chunk-y1imvaA-.js +1 -0
- package/public/index.html +4 -4
- package/public/main-BAV5VDOD.js +7109 -0
- package/public/polyfills-5MJXXCNC.js +1 -0
- package/public/styles-JZSMCSRO.css +1 -0
- package/public/assets/help-docs/widget-historical-series.md +0 -110
- package/public/chunk-2TP7C66X.js +0 -5
- package/public/chunk-4KHUCTYN.js +0 -3
- package/public/chunk-6ISGIPNP.js +0 -1
- package/public/chunk-7JGTAL26.js +0 -10
- package/public/chunk-C23GLDFH.js +0 -62
- package/public/chunk-CB4E7PPA.js +0 -4
- package/public/chunk-DNM5XUIF.js +0 -1
- package/public/chunk-HF7V6XFA.js +0 -2
- package/public/chunk-HXR2BKDL.js +0 -4
- package/public/chunk-ILQQCGMJ.js +0 -5
- package/public/chunk-IXUKD73N.js +0 -5
- package/public/chunk-JMZYPL54.js +0 -2
- package/public/chunk-KJCBQE6W.js +0 -6
- package/public/chunk-LEY6MANN.js +0 -16
- package/public/chunk-O5BTKN5D.js +0 -1
- package/public/chunk-OH5KNIQ7.js +0 -50
- package/public/chunk-Q32FSCUX.js +0 -1
- package/public/chunk-RIX4VQJ2.js +0 -1
- package/public/chunk-SHJMXSDM.js +0 -1
- package/public/chunk-T4VTC6GW.js +0 -1
- package/public/chunk-VFJD3XKT.js +0 -1
- package/public/chunk-VFZSH4TC.js +0 -1
- package/public/chunk-W6MCE3GH.js +0 -6
- package/public/chunk-WAOG456B.js +0 -2
- package/public/chunk-XBOM6DMF.js +0 -9
- package/public/main-BECMST5R.js +0 -1
- package/public/polyfills-BWA36QKG.js +0 -1
- package/public/scripts-M6PHZBML.js +0 -14
- package/public/styles-DYEO23GZ.css +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {C,e}from'./chunk-B6bEhzNR.js';import {g as ge$2}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$1,a_ as Gp,cv as G,cw as z,dx as n$1,J as JD,dC as x,c as $h,cn as wd,_ as _w,B as Bh,e as EE,M as Mw,f as eg,K as Kw,P as Pi,T as TT,u as ul}from'./main-BAV5VDOD.js';import {c}from'./chunk-Dxlia2NE.js';var ge=["chargerSvg"];function me(c,e){c&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No chargers detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K charger paths or select chargers in widget settings."),ul()());}function fe(c){return c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var le=class c$1{static CHARGER_DESCRIPTOR=a("widget-charger");static SELF_ROOT_PATH=(()=>{let e=c$1.CHARGER_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetChargerComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${c$1.SELF_ROOT_PATH}.*`;static PATH_REGEX=new RegExp(`^${fe(c$1.SELF_ROOT_PATH)}\\.([^.]+)\\.(.+)$`);static VIEWBOX_WIDTH=200;static CARD_HEIGHT=100;static COMPACT_CARD_HEIGHT=100;static CARD_GAP=8;static PATH_BATCH_WINDOW_MS=500;static CHARGER_DISPLAY_BASE_WIDTH=145;static CHARGER_DISPLAY_BASE_HEIGHT=37;static CHARGER_DISPLAY_HORIZONTAL_MARGIN=40;static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,charger:{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("chargerSvg");svg;layer;pendingPathUpdates=new Map;pathBatchTimerId=null;initialPathPaintDone=false;renderFrameId=null;pendingRenderSnapshot=null;discoveredChargerIds=vt([]);trackedDevices=vt([]);chargersByKey=vt({});visibleChargerKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(s=>s.key);let r=this.chargersByKey(),t=new Set(this.discoveredChargerIds()),i=Object.keys(r).filter(s=>{let o=r[s];return !!o&&t.has(o.id)}).sort((s,o)=>s.localeCompare(o)),a=new Map;return i.forEach(s=>{let o=r[s];o&&s!==o.id&&a.set(o.id,true);}),i.filter(s=>{let o=r[s];return o?s!==o.id?true:!a.get(o.id):false})});visibleChargers=Dt(()=>{let e=this.visibleChargerKeys(),r=this.chargersByKey();return e.map(t=>r[t]).filter(t=>!!t)});hasChargers=Dt(()=>this.visibleChargers().length>0);isCompactCardMode=Dt(()=>this.renderMode()==="compact");colorRole=Dt(()=>this.runtime.options()?.color??"contrast");ignoreZones=Dt(()=>this.runtime.options()?.ignoreZones??false);displayLabel=Dt(()=>{let e=this.visibleChargers();return e.length!==1?"Chargers":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=this.visibleChargers(),r=new Map;e.forEach(a=>r.set(a.id,(r.get(a.id)??0)+1));let t=new Set([...r.entries()].filter(([,a])=>a>1).map(([a])=>a)),i={};for(let a of e){let s=a.deviceKey??a.id,o=!!a.source&&t.has(a.id),[n,m,p,h]=this.buildMetricRows(a);i[s]={id:a.id,source:a.source??null,deviceKey:a.deviceKey,titleText:this.resolveTitleText(a,o),modeText:this.isCompactCardMode()?"":this.resolveModeText(a),voltageText:n,currentText:m,powerText:p,temperatureText:h};}return i});constructor(){Fa(()=>{let t=this.runtime.options();t&&ge$1(()=>this.applyConfig(t));}),Fa(()=>{let t=this.displayModels(),i=this.visibleChargers(),a=this.widgetColors();!this.svg||!a||this.requestRender({chargers:i,displayModels:t,widgetColors:a});});let e=[this.data.subscribePathTreeWithInitial(c$1.ROOT_PATTERN)],r=false;for(let t of e)if(t.initial.length){r=true;for(let i of t.initial)this.enqueuePathUpdate(i,true);}r&&(this.flushPendingPathUpdates(),this.initialPathPaintDone=true);for(let t of e)t.live$.pipe(Gp(this.destroyRef)).subscribe(i=>{this.enqueuePathUpdate(i);});}ngAfterViewInit(){this.initializeSvg(),this.requestRender();}ngOnDestroy(){this.pathBatchTimerId!==null&&(clearTimeout(this.pathBatchTimerId),this.pathBatchTimerId=null),this.renderFrameId!==null&&(cancelAnimationFrame(this.renderFrameId),this.renderFrameId=null),this.pendingRenderSnapshot=null;}initializeSvg(){this.svg=ge$2(this.svgRef().nativeElement),this.svg.attr("viewBox",`0 0 ${c$1.VIEWBOX_WIDTH} ${c$1.CARD_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","Charger View"),this.layer=this.svg.append("g").attr("class","charger-layer");}applyConfig(e){let r=this.normalizeTrackedDevices(e.charger?.trackedDevices);this.trackedDevices.set(r),this.reprojectSnapshotsToDeviceKeys(r);}normalizeTrackedDevices(e){if(!Array.isArray(e))return [];let r=new Map;return e.forEach(t=>{if(!t||typeof t!="object")return;let i=t,a=this.normalizeOptionalString(i.id),s=this.normalizeOptionalString(i.source);if(!a||!s)return;let o=this.normalizeOptionalString(i.key)??`${a}||${s}`;r.set(o,{id:a,source:s,key:o});}),[...r.values()].sort((t,i)=>t.key.localeCompare(i.key))}buildIdToDeviceKeysMap(){let e=new Map;return this.trackedDevices().forEach(r=>{let t=e.get(r.id)??[];t.push(r.key),e.set(r.id,t);}),e}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let r=new Map,t=new Map;e.forEach(i=>{let a=r.get(i.id)??[];a.push(i.key),r.set(i.id,a),t.set(i.key,i);}),this.chargersByKey.update(i=>{let a=i,s=false;return r.forEach((o,n)=>{let m=i[n];if(m){for(let p of o){if(i[p])continue;let h=t.get(p);s||(a=G({},i),s=true),a[p]=z(G({},m),{source:h?.source??null,deviceKey:p});}a[n]&&(a[n].deviceKey===void 0||a[n].deviceKey===n)&&(s||(a=G({},i),s=true),delete a[n]);}}),s?a:i});}normalizeOptionalString(e){if(typeof e!="string")return null;let r=e.trim();return r.length>0?r:null}enqueuePathUpdate(e,r=false){let t=this.parsePath(e.path);if(!t)return;let i=e.update?.data?.value??null,a=e.update?.state??null,s=this.extractUpdateSource(e),o=`${t.id}::${s??"*"}::${t.key}`;if(this.pendingPathUpdates.set(o,{id:t.id,key:t.key,source:s,value:i,state:a}),!r){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=window.setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},c$1.PATH_BATCH_WINDOW_MS));}}parsePath(e){let r=e.match(c$1.PATH_REGEX);return r?{id:r[1],key:r[2]}:null}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let e=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(e.map(a=>a.id)).forEach(a=>this.trackDiscoveredCharger(a));let t=this.buildIdToDeviceKeysMap(),i=new Map;this.trackedDevices().forEach(a=>i.set(a.key,a)),this.chargersByKey.update(a=>{let s=a,o=false;for(let n of e){let m=t.get(n.id),p=!!m?.length,h=[];if(p)if(n.source){let y=`${n.id}||${n.source}`;h=m?.includes(y)?[y]:[];}else h=m??[];else h=[n.source?`${n.id}||${n.source}`:n.id];for(let y of h){let b=p?i.get(y):null,f=s[y]??{id:n.id,source:b?.source??n.source??null,deviceKey:p||n.source?y:void 0},d=G({},f);if(!this.applyValue(d,n.key,n.value,n.state))continue;let M=d.rawPower!=null?d.rawPower:d.voltage!=null&&d.current!=null?d.voltage*d.current:null;M!=null?d.power=Number.isFinite(M)?M:null:d.power=null,d.rawPower==null&&(d.powerState=this.resolveMostSevereState(d.voltageState??null,d.currentState??null)),o||(s=G({},s),o=true),s[y]=d;}}return o?s:a});}extractUpdateSource(e){let r=this.normalizeOptionalString(e.source);return r||(this.normalizeOptionalString(e.update?.data?.source)??null)}trackDiscoveredCharger(e){let r=this.discoveredChargerIds();r.includes(e)||this.discoveredChargerIds.set([...r,e].sort((t,i)=>t.localeCompare(i)));}applyValue(e,r,t,i){switch(r){case "name":return this.setValue(e,"name",this.toStringValue(t));case "location":return this.setValue(e,"location",this.toStringValue(t));case "associatedBus":return this.setValue(e,"associatedBus",this.toStringValue(t));case "state":return this.setMetricValue(e,"state","stateState",this.toStringValue(t),i);case "offReason":return this.setMetricValue(e,"offReason","offReasonState",this.toStringValue(t),i);case "error":return this.setMetricValue(e,"error","errorState",this.toStringValue(t),i);case "mode":return this.setMetricValue(e,"mode","modeState",this.toStringValue(t),i);case "modeState":return this.setMetricValue(e,"mode","modeState",this.toStringValue(t),i);case "modeNumber":return this.setMetricValue(e,"modeNumber","modeNumberState",this.toNumber(t,""),i);case "chargingMode":return this.setMetricValue(e,"chargingMode","chargingModeState",this.toStringValue(t),i);case "chargingModeNumber":return this.setMetricValue(e,"chargingModeNumber","chargingModeNumberState",this.toNumber(t,""),i);case "output.voltage":{let a=this.toNumber(t,"V"),s=this.setMetricValue(e,"outputVoltage","outputVoltageState",a,i),o=this.setMetricValue(e,"voltage","voltageState",a,i);return s||o}case "input.voltage":return this.setMetricValue(e,"inputVoltage","inputVoltageState",this.toNumber(t,"V"),i);case "voltage":return this.setMetricValue(e,"voltage","voltageState",this.toNumber(t,"V"),i);case "current":return this.setMetricValue(e,"current","currentState",this.toNumber(t,"A"),i);case "power":return this.setMetricValue(e,"rawPower","powerState",this.toNumber(t,"W"),i);case "temperature":return this.setMetricValue(e,"temperature","temperatureState",this.toNumber(t,this.units.getDefaults().Temperature),i);case "leds.absorption":return this.setMetricValue(e,"ledsAbsorption","ledsAbsorptionState",this.toBoolean(t),i);case "leds.bulk":return this.setMetricValue(e,"ledsBulk","ledsBulkState",this.toBoolean(t),i);case "leds.float":return this.setMetricValue(e,"ledsFloat","ledsFloatState",this.toBoolean(t),i);case "leds.inverter":return this.setMetricValue(e,"ledsInverter","ledsInverterState",this.toBoolean(t),i);case "leds.lowBattery":return this.setMetricValue(e,"ledsLowBattery","ledsLowBatteryState",this.toBoolean(t),i);case "leds.mains":return this.setMetricValue(e,"ledsMains","ledsMainsState",this.toBoolean(t),i);case "leds.overload":return this.setMetricValue(e,"ledsOverload","ledsOverloadState",this.toBoolean(t),i);case "leds.temperature":return this.setMetricValue(e,"ledsTemperature","ledsTemperatureState",this.toBoolean(t),i);default:return false}}setValue(e,r,t){return Object.is(e[r],t)?false:(e[r]=t,true)}setMetricValue(e,r,t,i,a){let s=!Object.is(e[r],i),o=!Object.is(e[t],a);return !s&&!o?false:(e[r]=i,e[t]=a,true)}requestRender(e){let r=this.widgetColors();!this.svg||!r||(this.pendingRenderSnapshot=e??{chargers:this.visibleChargers(),displayModels:this.displayModels(),widgetColors:r},this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;let t=this.pendingRenderSnapshot;this.pendingRenderSnapshot=null,t&&this.render(t);})));}render(e$1){if(!this.layer||!this.svg)return;let r=this.isCompactCardMode(),t=r?C:e,i=r?c$1.COMPACT_CARD_HEIGHT:c$1.CARD_HEIGHT,a=c$1.VIEWBOX_WIDTH-c$1.CHARGER_DISPLAY_HORIZONTAL_MARGIN,s=a/c$1.CHARGER_DISPLAY_BASE_WIDTH,o=a,n=(c$1.VIEWBOX_WIDTH-o)/2,m=r?8:t.titleY,p=r?33:60,h=e$1.chargers.map((l,P)=>({key:l.deviceKey??l.id,id:l.id,charger:l,y:P*(i+c$1.CARD_GAP)})),y=h.length?h[h.length-1].y+i:i;this.svg.attr("viewBox",`0 0 ${c$1.VIEWBOX_WIDTH} ${y}`);let b=this.layer.selectAll("g.charger-card").data(h,l=>l.key),f=b.enter().append("g").attr("class","charger-card"),d=f.append("g").attr("class","charger-display-group");d.append("path").attr("class","charger-shape-bulk").attr("d","m 39.280608,10.70371 1.604609,-3.7808024 c 0.06926,-0.1631805 0.314475,-0.553581 0.314475,-0.4368876 v 27.475177 c 0,0.116694 -0.142713,0.210638 -0.319983,0.210638 H 9.2681756 c -0.1772706,0 -0.3711555,-0.105758 -0.319983,-0.210638 l 1.2797184,-2.622833 c 1.150699,-2.358403 3.86281,-5.455024 6.286778,-6.406312 3.251217,-1.275942 7.834296,-2.821704 11.746419,-4.103315 4.312764,-1.412861 9.246151,-5.946636 11.0195,-10.125027 z").attr("transform","matrix(1.1068428,0,0,1.1601894,-8.804611,-6.1382561)").attr("fill","var(--mat-sys-background)").attr("stroke",e$1.widgetColors.color).attr("stroke-width",2).attr("stroke-linejoin","miter").attr("stroke-miterlimit",0).attr("paint-order","markers stroke fill"),d.append("rect").attr("class","charger-shape-absorption").attr("width",19.67485).attr("height",32.383526).attr("x",40.545158).attr("y",1.1331999).attr("rx",.19520389).attr("ry",.24451913).attr("fill","var(--mat-sys-background)").attr("stroke",e$1.widgetColors.color).attr("stroke-width",2).attr("stroke-linecap","butt").attr("stroke-linejoin","miter").attr("stroke-miterlimit",0).attr("paint-order","markers stroke fill"),d.append("path").attr("class","charger-shape-float").attr("d","m 66.03898,6.4101715 4.16646,3.2472635 c 1.876083,1.462185 5.139444,3.529899 7.448846,4.069504 5.055358,1.181215 11.386089,1.251612 11.38595,1.349059 l -0.02667,18.73082 c 0,0.127151 -0.103075,0.230227 -0.230226,0.230227 H 66.03898 c -0.127151,0 -0.230226,-0.103076 -0.230226,-0.230227 V 6.6403978 c 0,-0.1271504 0.103076,-0.2302261 0.230226,-0.2302263 z").attr("transform","matrix(1.1068428,0,0,1.1601894,-8.7228087,-6.1382561)").attr("fill","var(--mat-sys-background)").attr("stroke",e$1.widgetColors.color).attr("stroke-width",2).attr("stroke-linecap","butt").attr("stroke-linejoin","miter").attr("stroke-miterlimit",0).attr("paint-order","markers stroke fill"),d.append("path").attr("class","charger-shape-storage").attr("d","m 93.39395,15.253553 c 2.347866,2.587905 8.59059,4.802212 13.94479,4.852641 11.92289,0.112298 30.60094,0.205911 30.60096,0.259031 l 0.006,13.361558 c 3e-5,0.07786 -0.19912,0.140548 -0.44645,0.140548 h -44.1053 c -0.247332,0 -0.446448,-0.06269 -0.446448,-0.140548 V 15.394101 c 0,-0.07786 0.280259,-0.323728 0.446448,-0.140548 z").attr("transform","matrix(1.1077284,0,0,1.1178939,-8.9068494,-4.6850995)").attr("fill","var(--mat-sys-background)").attr("stroke",e$1.widgetColors.color).attr("stroke-width",2).attr("stroke-linejoin","miter").attr("stroke-miterlimit",0).attr("paint-order","markers stroke fill"),f.append("text").attr("class","charger-title"),f.append("text").attr("class","charger-mode");let E=f.append("text").attr("class","charger-voltage");E.append("tspan").attr("class","voltage-metric-value"),E.append("tspan").attr("class","voltage-metric-unit");let M=f.append("text").attr("class","charger-current");M.append("tspan").attr("class","current-metric-value"),M.append("tspan").attr("class","current-metric-unit");let L=f.append("text").attr("class","charger-power");L.append("tspan").attr("class","power-metric-value"),L.append("tspan").attr("class","power-metric-unit");let z=f.append("text").attr("class","charger-temperature");z.append("tspan").attr("class","temperature-metric-value"),z.append("tspan").attr("class","temperature-metric-unit");let u=f.merge(b);u.attr("transform",l=>`translate(0, ${l.y})`),u.select("g.charger-display-group").attr("transform",`translate(${n}, ${p}) scale(${s})`).each((l,P,ce)=>{let v=this.resolveShapeMode(l.charger),S=this.isShapeMode(v,"power supply"),D=e$1.widgetColors.dim,x="var(--mat-sys-background)",R=this.isShapeMode(v,"sustain")||S?"none":this.isShapeMode(v,"equalization")?"var(--kip-zone-alert-color)":this.isShapeMode(v,"overload")?"var(--kip-zone-alarm-color)":e$1.widgetColors.color,I=ge$2(ce[P]);I.select("path.charger-shape-bulk").attr("fill",this.isShapeMode(v,"bulk")||this.isShapeMode(v,"boost")||S?D:x).attr("stroke",R),I.select("rect.charger-shape-absorption").attr("fill",this.isShapeMode(v,"absorption")||S?D:x).attr("stroke",R),I.select("path.charger-shape-float").attr("fill",this.isShapeMode(v,"float")||S?D:x).attr("stroke",R),I.select("path.charger-shape-storage").attr("fill",this.isShapeMode(v,"storage")||S?D:x).attr("stroke",R);}),e$1.chargers.length>1?u.select("text.charger-title").attr("x",t.titleX).attr("y",m).attr("font-size",t.titleFontSize).attr("fill","var(--kip-contrast-dim-color)").text(l=>e$1.displayModels[l.key]?.titleText??this.resolveTitleText(l.charger)):u.select("text.charger-title").text(""),u.select("text.charger-voltage").attr("x",197).attr("y",25).attr("text-anchor","end").attr("font-size",t.primaryFontSize).attr("font-weight",t.primaryFontWeight).attr("fill","var(--kip-contrast-color)"),u.select("tspan.voltage-metric-value").text(l=>e$1.displayModels[l.key]?.voltageText??""),u.select("tspan.voltage-metric-unit").attr("dx",1).attr("font-size",22).attr("font-weight",500).attr("fill","var(--kip-contrast-color)").text("V"),u.select("text.charger-current").attr("x",197).attr("y",48).attr("text-anchor","end").attr("font-size",t.lineOneFontSize).attr("fill","var(--kip-contrast-color)"),u.select("tspan.current-metric-value").text(l=>e$1.displayModels[l.key]?.currentText??""),u.select("tspan.current-metric-unit").attr("dx",1).attr("font-size",12).attr("fill","var(--kip-contrast-color)").text("A"),u.select("text.charger-power").attr("x",5).attr("y",22).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",10),u.select("tspan.power-metric-value").text(l=>e$1.displayModels[l.key]?.powerText??""),u.select("tspan.power-metric-unit").attr("dx",1).attr("font-size",6).attr("fill","var(--kip-contrast-dim-color)").text("W"),u.select("text.charger-temperature").attr("x",5).attr("y",34).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",10),u.select("tspan.temperature-metric-value").text(l=>e$1.displayModels[l.key]?.temperatureText??""),u.select("tspan.temperature-metric-unit").attr("dx",1).attr("font-size",6).attr("fill","var(--kip-contrast-dim-color)").text(`${this.units.getDefaults().Temperature==="celsius"?"\xB0C":"\xB0F"}`),u.select("text.charger-mode").attr("x",5).attr("y",46).attr("font-size",10).attr("fill","var(--kip-contrast-dim-color)").text(l=>e$1.displayModels[l.key]?.modeText??""),b.exit().remove();}resolveTitleText(e,r=false){let t=e.name||`Charger ${e.id}`;return !r||!e.source?t:`${t} [${e.source}]`}resolveModeText(e){if(e.chargingMode)return `Mode: ${e.chargingMode.charAt(0).toUpperCase()+e.chargingMode.slice(1)}`;if(e.mode)return `Mode: ${e.mode}`;let t=[{active:e.ledsAbsorption,label:"Absorption"},{active:e.ledsBulk,label:"Bulk"},{active:e.ledsFloat,label:"Float"},{active:e.ledsInverter,label:"Inverter"},{active:e.ledsLowBattery,label:"Low Battery"},{active:e.ledsMains,label:"Mains"},{active:e.ledsOverload,label:"Overload"},{active:e.ledsTemperature,label:"Temperature"}].filter(i=>i.active===true).map(i=>i.label);return t.length?`Mode: ${t.join(" / ")}`:"Mode --"}resolveShapeMode(e){return (e.chargingMode??e.mode??"").trim().toLowerCase()}isShapeMode(e,r){return !e||!r?false:e===r||e.includes(r)}buildMetricRows(e){return this.renderMode()==="full"||this.renderMode()===null?[`${this.formatValue(e.voltage,1)}`,`${this.formatValue(e.current,1)}`,`Power: ${this.formatValue(e.power,0)}`,`Temp: ${this.formatTemperature(e.temperature)}`]:[`${this.formatValue(e.voltage,1)}`,`${this.formatValue(e.current,1)}`,`P: ${this.formatValue(e.power,0)}`,`T: ${this.formatTemperature(e.temperature)}`]}formatValue(e,r){return e==null||Number.isNaN(e)?"-":`${e.toFixed(r)}`}formatTemperature(e){return e==null||Number.isNaN(e)?"-":`${e.toFixed(0)}`}toStringValue(e){return typeof e=="string"?e:null}toBoolean(e){if(typeof e=="boolean")return e;if(typeof e=="number"){if(e===1)return true;if(e===0)return false}if(typeof e=="string"){let r=e.trim().toLowerCase();if(r==="true"||r==="1"||r==="on")return true;if(r==="false"||r==="0"||r==="off")return false}return null}resolveMostSevereState(...e){return e.some(r=>r===n$1.Alert)?n$1.Alert:e.some(r=>r===n$1.Alarm)?n$1.Alarm:e.some(r=>r===n$1.Warn)?n$1.Warn:e.some(r=>r===n$1.Normal)?n$1.Normal:null}toNumber(e,r){if(e==null||typeof e=="boolean")return null;let t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return null;let i=this.units.convertToUnit(r,t);return Number.isFinite(i)?i:t}static \u0275fac=function(r){return new(r||c$1)};static \u0275cmp=JD({type:c$1,selectors:[["widget-charger"]],viewQuery:function(r,t){r&1&&eg(t.svgRef,ge,5),r&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["chargerSvg",""],[3,"text","color"],["aria-hidden","false",1,"charger-svg"],[1,"charger-empty"],[1,"charger-empty-title"],[1,"charger-empty-sub"]],template:function(r,t){r&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,me,5,0,"div",3)),r&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasChargers()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.charger-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}.charger-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)}.charger-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.charger-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{le as WidgetChargerComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {C,e as e$1}from'./chunk-B6bEhzNR.js';import {g as ge$1}from'./chunk-TakPRI3t.js';import {e9 as a,d1 as Hj,w,du as p,aS as De,bu as ut,aY as xe,$ as $j,v as vt,D as Dt,F as Fa,dn as ge,a_ as Gp,cv as G,cw as z,dx as n$1,J as JD,dC as x,c as $h,cn as wd,_ as _w,B as Bh,e as EE,M as Mw,f as eg,K as Kw,P as Pi,T as TT,u as ul}from'./main-BAV5VDOD.js';import {c,e}from'./chunk-Dxlia2NE.js';var re=["inverterSvg"];function ie(c,e){c&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No inverters detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K inverter paths or select inverters in widget settings."),ul()());}function ne(c){return c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Z=class c$1{static INVERTER_DESCRIPTOR=a("widget-inverter");static SELF_ROOT_PATH=(()=>{let e=c$1.INVERTER_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetInverterComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${c$1.SELF_ROOT_PATH}.*`;static PATH_REGEX=new RegExp(`^${ne(c$1.SELF_ROOT_PATH)}\\.([^.]+)\\.(.+)$`);static VIEWBOX_WIDTH=200;static CARD_HEIGHT=100;static COMPACT_CARD_HEIGHT=100;static CARD_GAP=8;static PATH_BATCH_WINDOW_MS=500;static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,inverter:{trackedDevices:[],optionsById:{}}};id=Hj.required();type=Hj.required();theme=Hj.required();renderMode=Hj(null);runtime=w(p);data=w(De);units=w(ut);destroyRef=w(xe);svgRef=$j.required("inverterSvg");svg;layer;pendingPathUpdates=new Map;pathBatchTimerId=null;initialPathPaintDone=false;renderFrameId=null;pendingRenderSnapshot=null;discoveredInverterIds=vt([]);trackedDevices=vt([]);optionsById=vt({});cardMode=vt({displayMode:"full",metrics:["dcVoltage","dcCurrent","acVoltage","acFrequency"]});invertersByKey=vt({});visibleInverterKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(i=>i.key);let r=this.invertersByKey(),t=new Set(this.discoveredInverterIds());return Object.keys(r).filter(i=>{let o=r[i];return !!o&&t.has(o.id)}).sort((i,o)=>i.localeCompare(o))});visibleInverters=Dt(()=>{let e=this.visibleInverterKeys(),r=this.invertersByKey();return e.map(t=>r[t]).filter(t=>!!t)});hasInverters=Dt(()=>this.visibleInverters().length>0);activeDisplayMode=Dt(()=>this.renderMode()??this.cardMode().displayMode??"full");isCompactCardMode=Dt(()=>this.activeDisplayMode()==="compact");colorRole=Dt(()=>this.runtime.options()?.color??"contrast");ignoreZones=Dt(()=>this.runtime.options()?.ignoreZones??false);displayLabel=Dt(()=>{let e=this.visibleInverters();return e.length!==1?"Inverters":this.resolveTitleText(e[0])});labelColor=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e).dim:"var(--kip-contrast-dim-color)"});widgetColors=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e):null});displayModels=Dt(()=>{let e$1=this.visibleInverters(),r=this.theme(),t=this.widgetColors(),i=this.ignoreZones(),o=new Map;e$1.forEach(n=>o.set(n.id,(o.get(n.id)??0)+1));let d=new Set([...o.entries()].filter(([,n])=>n>1).map(([n])=>n)),s={};for(let n of e$1){let l=n.deviceKey??n.id,a=!!n.source&&d.has(n.id),h=this.resolveMostSevereState(n.dcVoltageState??null,n.dcCurrentState??null,n.acVoltageState??null,n.acCurrentState??null,n.acFrequencyState??null,n.temperatureState??null,n.inverterModeState??null),M=this.resolveMostSevereState(n.dcVoltageState??null,n.dcCurrentState??null),b=this.resolveMostSevereState(n.acVoltageState??null,n.acCurrentState??null,n.acFrequencyState??null),[u,x]=this.buildMetricRows(n);s[l]={id:n.id,source:n.source??null,deviceKey:n.deviceKey,titleText:this.resolveTitleText(n),modeText:this.isCompactCardMode()?"":n.inverterMode?`Mode ${n.inverterMode}`:"Mode -",busText:this.isCompactCardMode()?"":a?n.source??"-":n.associatedBus||n.location||"-",metricsLineOne:u,metricsLineTwo:x,stateBarColor:e(h,t?.dim??"var(--kip-contrast-color)",r,i),titleTextColor:e(h,"var(--kip-contrast-color)",r,i),metaTextColor:e(n.inverterModeState??null,"var(--kip-contrast-dim-color)",r,i),primaryMetricsTextColor:e(M,"var(--kip-contrast-color)",r,i),secondaryMetricsTextColor:e(b,"var(--kip-contrast-color)",r,i)};}return s});constructor(){Fa(()=>{let t=this.runtime.options();t&&ge(()=>this.applyConfig(t));}),Fa(()=>{let t=this.displayModels(),i=this.visibleInverters(),o=this.widgetColors();!this.svg||!o||this.requestRender({inverters:i,displayModels:t,widgetColors:o});});let e=[this.data.subscribePathTreeWithInitial(c$1.ROOT_PATTERN)],r=false;for(let t of e)if(t.initial.length){r=true;for(let i of t.initial)this.enqueuePathUpdate(i,true);}r&&(this.flushPendingPathUpdates(),this.initialPathPaintDone=true);for(let t of e)t.live$.pipe(Gp(this.destroyRef)).subscribe(i=>this.enqueuePathUpdate(i));}ngAfterViewInit(){this.initializeSvg(),this.requestRender();}ngOnDestroy(){this.pathBatchTimerId!==null&&(clearTimeout(this.pathBatchTimerId),this.pathBatchTimerId=null),this.renderFrameId!==null&&(cancelAnimationFrame(this.renderFrameId),this.renderFrameId=null),this.pendingRenderSnapshot=null;}initializeSvg(){this.svg=ge$1(this.svgRef().nativeElement),this.svg.attr("viewBox",`0 0 ${c$1.VIEWBOX_WIDTH} ${c$1.CARD_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","Inverter View"),this.layer=this.svg.append("g").attr("class","inverter-layer");}applyConfig(e){let r=this.resolveInverterConfig(e);this.trackedDevices.set(r.trackedDevices??[]),this.reprojectSnapshotsToDeviceKeys(r.trackedDevices??[]),this.optionsById.set(r.optionsById),this.cardMode.set(this.normalizeCardMode(r.cardMode));}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let r=new Map;e.forEach(t=>{let i=r.get(t.id)??[];i.push(t.key),r.set(t.id,i);}),this.invertersByKey.update(t=>{let i=t,o=false;return r.forEach((d,s)=>{let n=t[s];if(n){for(let l of d){if(t[l])continue;let a=e.find(h=>h.key===l);o||(i=G({},t),o=true),i[l]=z(G({},n),{source:a?.source??null,deviceKey:l});}o&&i[s]?.deviceKey===void 0&&delete i[s];}}),o?i:t});}resolveInverterConfig(e){let r=e.inverter;return {trackedDevices:this.normalizeTrackedDevices(r?.trackedDevices),optionsById:this.normalizeOptionsById(r?.optionsById),cardMode:this.normalizeCardMode(r?.cardMode)}}normalizeTrackedDevices(e){if(!Array.isArray(e))return [];let r=new Map;return e.forEach(t=>{if(!t||typeof t!="object")return;let i=t,o=this.normalizeOptionalString(i.id),d=this.normalizeOptionalString(i.source);if(!o||!d)return;let s=this.normalizeOptionalString(i.key)??`${o}||${d}`;r.set(s,{id:o,source:d,key:s});}),[...r.values()].sort((t,i)=>t.key.localeCompare(i.key))}buildIdToDeviceKeysMap(){let e=new Map;return this.trackedDevices().forEach(r=>{let t=e.get(r.id)??[];t.push(r.key),e.set(r.id,t);}),e}normalizeCardMode(e){let r=e&&typeof e=="object"?e:null,t=this.normalizeStringList(r?.metrics);return {displayMode:r?.displayMode==="compact"?"compact":"full",metrics:t.length?t:["dcVoltage","dcCurrent","acVoltage","acFrequency"]}}normalizeStringList(e){if(!Array.isArray(e))return [];let r=new Set;return e.forEach(t=>{if(typeof t!="string")return;let i=t.trim();i.length>0&&r.add(i);}),[...r].sort((t,i)=>t.localeCompare(i))}normalizeOptionsById(e){if(!e||typeof e!="object")return {};let r={};return Object.entries(e).forEach(([t])=>{let i=this.normalizeOptionalString(t);i&&(r[i]={});}),r}normalizeOptionalString(e){if(typeof e!="string")return null;let r=e.trim();return r.length>0?r:null}enqueuePathUpdate(e,r=false){let t=this.parsePath(e.path);if(!t)return;let i=e.update?.data?.value??null,o=e.update?.state??null;if(this.pendingPathUpdates.set(`${t.id}::${t.key}`,{id:t.id,key:t.key,value:i,state:o}),!r){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=window.setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},c$1.PATH_BATCH_WINDOW_MS));}}parsePath(e){let r=e.match(c$1.PATH_REGEX);return r?{id:r[1],key:r[2]}:null}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let e=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(e.map(i=>i.id)).forEach(i=>this.trackDiscoveredInverter(i));let t=this.buildIdToDeviceKeysMap();this.invertersByKey.update(i=>{let o=i,d=false;for(let s of e){let n=t.get(s.id),l=n?.length?n:[s.id];for(let a of l){let h=!!n?.length,M=h?this.trackedDevices().find(I=>I.key===a):null,b=o[a]??{id:s.id,source:M?.source??null,deviceKey:h?a:void 0},u=G({},b);if(this.applyValue(u,s.key,s.value,s.state)){if(u.dcVoltage!=null&&u.dcCurrent!=null){let I=u.dcVoltage*u.dcCurrent;u.dcPower=Number.isFinite(I)?I:null,u.dcPowerState=this.resolveMostSevereState(u.dcVoltageState??null,u.dcCurrentState??null);}else u.dcPower=null,u.dcPowerState=null;d||(o=G({},o),d=true),o[a]=u;}}}return d?o:i});}trackDiscoveredInverter(e){let r=this.discoveredInverterIds();r.includes(e)||this.discoveredInverterIds.set([...r,e].sort((t,i)=>t.localeCompare(i)));}applyValue(e,r,t,i){switch(r){case "name":return this.setValue(e,"name",this.toStringValue(t));case "location":return this.setValue(e,"location",this.toStringValue(t));case "associatedBus":return this.setValue(e,"associatedBus",this.toStringValue(t));case "dc.voltage":return this.setMetricValue(e,"dcVoltage","dcVoltageState",this.toNumber(t,"V"),i);case "dc.current":return this.setMetricValue(e,"dcCurrent","dcCurrentState",this.toNumber(t,"A"),i);case "acin.voltage":return this.setMetricValue(e,"acInVoltage","acInVoltageState",this.toNumber(t,"V"),i);case "acin.current":return this.setMetricValue(e,"acInCurrent","acInCurrentState",this.toNumber(t,"A"),i);case "acin.frequency":return this.setMetricValue(e,"acInFrequency","acInFrequencyState",this.toNumber(t,"Hz"),i);case "acin.power":return this.setMetricValue(e,"acInPower","acInPowerState",this.toNumber(t,"W"),i);case "acin.1.currentLimit":return this.setMetricValue(e,"acIn1CurrentLimit","acIn1CurrentLimitState",this.toNumber(t,"A"),i);case "acin.currentLimit":return this.setMetricValue(e,"acInCurrentLimit","acInCurrentLimitState",this.toNumber(t,"A"),i);case "acState.acIn1Available":return this.setMetricValue(e,"acIn1Available","acIn1AvailableState",this.toBoolean(t),i);case "acState.ignoreAcIn1.state":return this.setMetricValue(e,"ignoreAcIn1","ignoreAcIn1State",this.toBoolean(t),i);case "ac.voltage":return this.setMetricValue(e,"acVoltage","acVoltageState",this.toNumber(t,"V"),i);case "ac.current":return this.setMetricValue(e,"acCurrent","acCurrentState",this.toNumber(t,"A"),i);case "ac.frequency":return this.setMetricValue(e,"acFrequency","acFrequencyState",this.toNumber(t,"Hz"),i);case "acout.voltage":return this.setMetricValue(e,"acOutVoltage","acOutVoltageState",this.toNumber(t,"V"),i);case "acout.current":return this.setMetricValue(e,"acOutCurrent","acOutCurrentState",this.toNumber(t,"A"),i);case "acout.frequency":return this.setMetricValue(e,"acOutFrequency","acOutFrequencyState",this.toNumber(t,"Hz"),i);case "acout.power":return this.setMetricValue(e,"acOutPower","acOutPowerState",this.toNumber(t,"W"),i);case "inverterMode":return this.setMetricValue(e,"inverterMode","inverterModeState",this.toStringValue(t),i);case "inverterModeNumber":return this.setMetricValue(e,"inverterModeNumber","inverterModeNumberState",this.toNumber(t,""),i);case "preferRenewableEnergy":return this.setMetricValue(e,"preferRenewableEnergy","preferRenewableEnergyState",this.toBoolean(t),i);case "preferRenewableEnergyActive":return this.setMetricValue(e,"preferRenewableEnergyActive","preferRenewableEnergyActiveState",this.toBoolean(t),i);case "temperature":return this.setMetricValue(e,"temperature","temperatureState",this.toNumber(t,this.units.getDefaults().Temperature),i);default:return false}}setValue(e,r,t){return Object.is(e[r],t)?false:(e[r]=t,true)}setMetricValue(e,r,t,i,o){let d=!Object.is(e[r],i),s=!Object.is(e[t],o);return !d&&!s?false:(e[r]=i,e[t]=o,true)}requestRender(e){let r=this.widgetColors();!this.svg||!r||(this.pendingRenderSnapshot=e??{inverters:this.visibleInverters(),displayModels:this.displayModels(),widgetColors:r},this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;let t=this.pendingRenderSnapshot;this.pendingRenderSnapshot=null,t&&this.render(t);})));}render(e){if(!this.layer||!this.svg)return;let r=this.isCompactCardMode(),t=r?C:e$1,i=r?c$1.COMPACT_CARD_HEIGHT:c$1.CARD_HEIGHT,o=e.inverters.map((a,h)=>({key:a.deviceKey??a.id,inverter:a,y:h*(i+c$1.CARD_GAP)})),d=o.length?o[o.length-1].y+i:i;this.svg.attr("viewBox",`0 0 ${c$1.VIEWBOX_WIDTH} ${d}`);let s=this.layer.selectAll("g.inverter-card").data(o,a=>a.key),n=s.enter().append("g").attr("class","inverter-card");n.append("rect").attr("class","inverter-card-bg"),n.append("rect").attr("class","inverter-state-bar"),n.append("text").attr("class","inverter-title"),n.append("text").attr("class","inverter-id"),n.append("text").attr("class","inverter-mode"),n.append("text").attr("class","inverter-bus"),n.append("text").attr("class","inverter-metrics-1"),n.append("text").attr("class","inverter-metrics-2");let l=n.merge(s);l.attr("transform",a=>`translate(0, ${a.y})`),l.select("rect.inverter-card-bg").attr("x",.5).attr("y",.5).attr("rx",t.cardCornerRadius).attr("ry",t.cardCornerRadius).attr("width",c$1.VIEWBOX_WIDTH-1).attr("height",i-1).attr("stroke","var(--mat-sys-outline-variant)").attr("stroke-width",.5).attr("fill","none"),l.select("rect.inverter-state-bar").attr("x",1.5).attr("y",1.5).attr("rx",t.stateBarCornerRadius).attr("ry",t.stateBarCornerRadius).attr("width",3).attr("height",i-3).attr("fill",a=>e.displayModels[a.key]?.stateBarColor??e.widgetColors.dim),e.inverters.length>1?l.select("text.inverter-title").attr("x",t.titleX).attr("y",t.titleY).attr("font-size",t.titleFontSize).attr("fill",a=>e.displayModels[a.key]?.titleTextColor??"var(--kip-contrast-color)").text(a=>e.displayModels[a.key]?.titleText??this.resolveTitleText(a.inverter)):l.select("text.inverter-title").text(""),l.select("text.inverter-id").attr("x",t.idX).attr("y",t.idY).attr("text-anchor","end").attr("font-size",t.idFontSize).attr("fill","var(--kip-contrast-dim-color)").text(a=>a.inverter.id),l.select("text.inverter-mode").attr("x",t.metaLeftX).attr("y",t.metaY).attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",a=>e.displayModels[a.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(a=>e.displayModels[a.key]?.modeText??""),l.select("text.inverter-bus").attr("x",t.metaRightX).attr("y",t.metaY).attr("text-anchor","end").attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",a=>e.displayModels[a.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(a=>e.displayModels[a.key]?.busText??""),l.select("text.inverter-metrics-1").attr("x",t.lineOneX).attr("y",t.lineOneY).attr("font-size",t.lineOneFontSize).attr("fill",a=>e.displayModels[a.key]?.primaryMetricsTextColor??"var(--kip-contrast-color)").text(a=>e.displayModels[a.key]?.metricsLineOne??""),l.select("text.inverter-metrics-2").attr("x",t.lineTwoX).attr("y",t.lineTwoY).attr("font-size",t.lineTwoFontSize).attr("opacity",.85).attr("fill",a=>e.displayModels[a.key]?.secondaryMetricsTextColor??"var(--kip-contrast-color)").text(a=>e.displayModels[a.key]?.metricsLineTwo??""),s.exit().remove();}displayName(e){return e.name?.trim()||e.id}resolveTitleText(e){return e.name||`Inverter ${e.id}`}buildMetricRows(e){let r=this.cardMode();if(this.activeDisplayMode()==="full"){let i=e.acInVoltage!=null||e.acInCurrent!=null,o=this.formatValue(e.acInVoltage,"V"),d=this.formatValue(e.acInCurrent,"A"),s=this.formatValue(e.acOutVoltage??e.acVoltage,"V"),n=this.formatValue(e.acOutFrequency??e.acFrequency,"Hz");return [`DC ${this.formatValue(e.dcVoltage,"V")} ${this.formatValue(e.dcCurrent,"A")}`,i?`ACin ${o} ${d}`:`AC ${s} ${n}`]}let t=r.metrics.map(i=>this.toMetricLabel(i,e)).filter(i=>!!i);return t.length?[t.slice(0,2).join(" ")||" ",t.slice(2,4).join(" ")||" "]:["DC - -","AC - -"]}toMetricLabel(e,r){switch(e){case "dcVoltage":return `DC V ${this.formatValue(r.dcVoltage,"V")}`;case "dcCurrent":return `DC A ${this.formatValue(r.dcCurrent,"A")}`;case "dcPower":return `DC P ${this.formatValue(r.dcPower,"W")}`;case "acVoltage":return `AC V ${this.formatValue(r.acVoltage,"V")}`;case "acCurrent":return `AC A ${this.formatValue(r.acCurrent,"A")}`;case "acFrequency":return `Hz ${this.formatValue(r.acFrequency,"Hz")}`;case "acInVoltage":return `ACin V ${this.formatValue(r.acInVoltage,"V")}`;case "acInCurrent":return `ACin A ${this.formatValue(r.acInCurrent,"A")}`;case "acInFrequency":return `ACin Hz ${this.formatValue(r.acInFrequency,"Hz")}`;case "acInPower":return `ACin P ${this.formatValue(r.acInPower,"W")}`;case "acOutVoltage":return `ACout V ${this.formatValue(r.acOutVoltage,"V")}`;case "acOutCurrent":return `ACout A ${this.formatValue(r.acOutCurrent,"A")}`;case "acOutFrequency":return `ACout Hz ${this.formatValue(r.acOutFrequency,"Hz")}`;case "acOutPower":return `ACout P ${this.formatValue(r.acOutPower,"W")}`;case "acIn1CurrentLimit":return `ACin1 Lim ${this.formatValue(r.acIn1CurrentLimit,"A")}`;case "acInCurrentLimit":return `ACin Lim ${this.formatValue(r.acInCurrentLimit,"A")}`;case "temperature":return `T ${this.formatTemperature(r.temperature)}`;case "inverterModeNumber":return `Mode# ${r.inverterModeNumber?.toString()??"-"}`;default:return null}}formatValue(e,r){return e==null||Number.isNaN(e)?"-":`${e.toFixed(1)} ${r}`}formatTemperature(e){return e==null||Number.isNaN(e)?"-":`${e.toFixed(1)} ${this.units.getDefaults().Temperature==="celsius"?"\xB0C":"\xB0F"}`}toStringValue(e){return typeof e=="string"?e:null}resolveMostSevereState(...e){return e.some(r=>r===n$1.Alert)?n$1.Alert:e.some(r=>r===n$1.Alarm)?n$1.Alarm:e.some(r=>r===n$1.Warn)?n$1.Warn:e.some(r=>r===n$1.Normal)?n$1.Normal:null}toNumber(e,r){if(e==null||typeof e=="boolean")return null;let t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return null;let i=this.units.convertToUnit(r,t);return typeof i=="number"&&Number.isFinite(i)?i:null}toBoolean(e){if(typeof e=="boolean")return e;if(typeof e=="number"){if(e===1)return true;if(e===0)return false}if(typeof e=="string"){let r=e.trim().toLowerCase();if(r==="true"||r==="1"||r==="on")return true;if(r==="false"||r==="0"||r==="off")return false}return null}static \u0275fac=function(r){return new(r||c$1)};static \u0275cmp=JD({type:c$1,selectors:[["widget-inverter"]],viewQuery:function(r,t){r&1&&eg(t.svgRef,re,5),r&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["inverterSvg",""],[3,"text","color"],["aria-hidden","false",1,"inverter-svg"],[1,"inverter-empty"],[1,"inverter-empty-title"],[1,"inverter-empty-sub"]],template:function(r,t){r&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,ie,5,0,"div",3)),r&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasInverters()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.inverter-svg[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;z-index:20;padding:0 10px 10px}.inverter-empty[_ngcontent-%COMP%]{position:absolute;inset:0;margin:10px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;text-align:center;color:var(--mat-sys-on-surface);background:color-mix(in srgb,var(--kip-widget-card-background-color) 92%,transparent)}.inverter-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.inverter-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{Z as WidgetInverterComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {d1 as Hj,w,du as p$1,aZ as F,$ as $j,v as vt,F as Fa,dn as ge,J as JD,cp as Uh,f as eg,K as Kw}from'./main-BAV5VDOD.js';var p=["canvasMainRef"],M=(()=>{class s{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p$1);canvas=w(F);static DEFAULT_CONFIG={displayName:"Static Label",color:"green",bgColor:"grey",noColor:false,noBgColor:true};canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;maxTextWidth=0;maxTextHeight=0;disposed=false;fgColor=vt("");bgColor=vt("");constructor(){Fa(()=>{let t=this.runtime.options(),e=this.theme();!t||!e||ge(()=>{this.fgColor.set(this.mapColor(t.color??"contrast",e)),this.bgColor.set(this.mapColor(t.bgColor??"grey",e)),this.draw();});}),Fa(()=>{let t=this.runtime.options()?.displayName;ge(()=>{t!==void 0&&this.draw();});});}mapColor(t,e){switch(t){case "contrast":return e.contrast;case "blue":return e.blue;case "green":return e.green;case "pink":return e.pink;case "orange":return e.orange;case "purple":return e.purple;case "grey":return e.grey;case "yellow":return e.yellow;default:return e.contrast}}ngAfterViewInit(){this.canvasElement=this.canvasRef().nativeElement,this.ctx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(t,e)=>{this.cssWidth=t,this.cssHeight=e,this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.draw();}draw(){if(!this.ctx||!this.canvasElement)return;let t=this.runtime.options();if(!t)return;this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),t.noBgColor||this.canvas.drawRectangle(this.ctx,0,0,this.canvasElement.width,this.canvasElement.height,this.bgColor());let e=t.displayName||"";this.canvas.drawText(this.ctx,e,Math.floor(this.cssWidth/2),Math.floor(this.cssHeight/2+10),this.cssWidth-40,this.cssHeight-40,"bold",this.fgColor());}ngOnDestroy(){this.disposed=true;try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(t){}}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=JD({type:s,selectors:[["widget-label"]],viewQuery:function(e,c){e&1&&eg(c.canvasRef,p,5),e&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:0,consts:[["canvasMainRef",""],[1,"label-canvas"]],template:function(e,c){e&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%;overflow:hidden}.label-canvas[_ngcontent-%COMP%]{width:100%!important;height:100%!important;display:block;border-radius:var(--mat-card-elevated-container-shape, var(--mat-sys-corner-medium))}"]})}return s})();export{M as WidgetLabelComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {O}from'./chunk-tAiV3ARh.js';import {w,G as Gi,aS as De$1,cu as T,aY as xe,v as vt,D as Dt,a_ as Gp,F as Fa,cv as G,cw as z,J as JD,cx as ut,cy as He,cz as ht,cA as Te,a2 as Jt,a3 as Xt,a4 as Zt,O as Op,cB as Mt,cC as Dt$1,p as R,y as yt,b as wt,c as $h,P as Pi,X as xw,cs as Sw,u as ul,_ as _w,B as Bh,e as EE,Y as Aw,M as Mw,T as TT,h as Fw,k as Qh,l as ud,g as qw,m as dd,s as sg,aA as gg}from'./main-BAV5VDOD.js';var te=(n,a)=>a.id;function ie(n,a){if(n&1){let e=Fw();Pi(0,"button",9),Qh("click",function(){let t=ud(e).$implicit,o=qw();return dd(o.displayDashboards(t.displayId))}),TT(1),ul();}if(n&2){let e=a.$implicit,i=qw();sg("selected",i.selectedDisplayButtonId()===e.displayId),EE(),gg(e.displayName);}}function ne(n,a){n&1&&(Pi(0,"button",5)(1,"i"),TT(2,'"No Remote"'),ul()());}function se(n,a){n&1&&(Pi(0,"div",7),$h(1,"mat-progress-spinner",10),ul());}function oe(n,a){if(n&1){let e=Fw();Pi(0,"tile-large-icon",12,0),Qh("click",function(){let t=ud(e).$index,o=qw(2);return dd(o.setActiveScreen(t))}),ul();}if(n&2){let e=a.$implicit,i=a.$index,t=qw(2);Bh("active",t.activeScreenIdx()===i)("svgIcon",e.icon)("iconSize",72)("label",e.name);}}function ae(n,a){if(n&1&&xw(0,oe,2,4,"tile-large-icon",11,te),n&2){let e=qw();Aw(e.screens());}}function re(n,a){n&1&&(Pi(0,"div",8)(1,"mat-icon",13),TT(2,"cast"),ul(),Pi(3,"div",14)(4,"p"),TT(5,"Select an available remote KIP in the menu."),ul(),Pi(6,"p"),TT(7,"To allow remote control of a dashboard, on that KIP device open Options \u2192 Display \u2192 Remote Control and enable it."),ul()()());}var De=(()=>{class n{COMMAND_REQUEST_ACTIVE_SCREEN_PATH="self.kip.remote.requestActiveScreen";_settings=w(Gi);_data=w(De$1);_requests=w(T);_destroyRef=w(xe);pageTitle="Remote Control";appID=this._settings.KipUUID;displayId=vt(null);selectedDisplayButtonId=vt(null);screensLoading=vt(false);displaysMap=vt({});selectedDisplaySub=null;selectedScreenIndexSub=null;displays=Dt(()=>Object.values(this.displaysMap()).filter(i=>i.displayId!==this.appID).sort((i,t)=>{let o=(i.displayName??"").toLowerCase(),s=(t.displayName??"").toLowerCase();return o&&s?o.localeCompare(s):o?-1:s?1:i.displayId.localeCompare(t.displayId)}));screens=vt([]);activeScreenIdx=vt(null);constructor(){this._data.subscribePathTree("self.displays.*").pipe(Gp(this._destroyRef)).subscribe(({path:e,update:i})=>{this.updateDisplayCatalog(e,i.data.value);}),Fa(()=>{let e=this.displays(),i=this.selectedDisplayButtonId();if(!e.length){this.displayDashboards(null);return}(!i||!e.some(t=>t.displayId===i))&&this.displayDashboards(e[0].displayId);}),Fa(()=>{this.rebindSelectedDisplaySubscriptions(this.displayId());});}updateDisplayCatalog(e,i){let t=this.extractDisplayId(e);if(!t||t===this.appID)return;let o=`self.displays.${t}`;this.displaysMap.update(s=>{let r=G({},s);if(e===o&&(i===null||typeof i>"u"))return delete r[t],r;let _=(r[t]??{displayName:null}).displayName;if(e===o&&i&&typeof i=="object"){let x=i;typeof x.displayName=="string"?_=x.displayName:x.displayName===null&&(_=null);}return r[t]={displayId:t,displayName:_},r});}rebindSelectedDisplaySubscriptions(e){if(this.selectedDisplaySub?.unsubscribe(),this.selectedDisplaySub=null,this.selectedScreenIndexSub?.unsubscribe(),this.selectedScreenIndexSub=null,!e){this.screensLoading.set(false),this.screens.set([]),this.activeScreenIdx.set(null);return}this.screensLoading.set(true),this.selectedDisplaySub=this._data.subscribePath(`self.displays.${e}`,"default").pipe(Gp(this._destroyRef)).subscribe(i=>{this.screensLoading.set(false);let t=i.data.value,o=Array.isArray(t?.screens)?t.screens.filter(s=>!!s&&typeof s=="object"&&typeof s.id=="string"&&typeof s.name=="string"&&typeof s.icon=="string"):[];this.screens.set(o),t&&Object.prototype.hasOwnProperty.call(t,"displayName")&&this.displaysMap.update(s=>{let r=s[e];if(!r)return s;let h=typeof t.displayName=="string"?t.displayName:t.displayName===null?null:r.displayName;return h===r.displayName?s:z(G({},s),{[e]:z(G({},r),{displayName:h})})});}),this.selectedScreenIndexSub=this._data.subscribePath(`self.displays.${e}.screenIndex`,"default").pipe(Gp(this._destroyRef)).subscribe(i=>{let t=i.data.value;this.activeScreenIdx.set(typeof t=="number"?t:null);});}extractDisplayId(e){return e.match(/^self\.displays\.([^.]+)(?:\.|$)/)?.[1]??null}displayDashboards(e){this.displayId.set(e),this.selectedDisplayButtonId.set(e);}setActiveScreen(e){let i=this.activeScreenIdx(),t=this.displayId();if(!t)return;this.activeScreenIdx.set(e),this._requests.putRequest(this.COMMAND_REQUEST_ACTIVE_SCREEN_PATH,{displayId:t,screenIdx:e},this.appID)||(console.error("Failed to set active screen: request was not accepted"),this.activeScreenIdx.set(i));}static \u0275fac=function(i){return new(i||n)};static \u0275cmp=JD({type:n,selectors:[["remote-control"]],decls:11,vars:3,consts:[["tile",""],["svgIconId","remote-control",3,"pageTitle"],[1,"sidenav-remote-control-container"],["mode","side","opened",""],["mat-list-item","","tabindex","0",3,"selected"],["mat-list-item","","tabindex","0","disabled","true",2,"text-align","center"],[1,"sidenav-remote-control-content"],["aria-label","Loading screens",1,"loading-container"],["role","status","aria-live","polite",1,"empty-state-msg"],["mat-list-item","","tabindex","0",3,"click"],["mode","indeterminate","diameter","64","strokeWidth","5"],[3,"active","svgIcon","iconSize","label"],[3,"click","active","svgIcon","iconSize","label"],["aria-hidden","true","color","primary",1,"empty-state-icon"],[1,"copy"]],template:function(i,t){i&1&&($h(0,"page-header",1),Pi(1,"mat-sidenav-container",2)(2,"mat-sidenav",3)(3,"mat-action-list"),xw(4,ie,2,3,"button",4,Sw,false,ne,3,0,"button",5),ul()(),Pi(7,"mat-sidenav-content",6),_w(8,se,2,0,"div",7)(9,ae,2,0)(10,re,8,0,"div",8),ul()()),i&2&&(Bh("pageTitle",t.pageTitle),EE(4),Aw(t.displays()),EE(4),Mw(t.screensLoading()?8:t.screens().length?9:10));},dependencies:[O,ut,He,ht,Te,Jt,Xt,Zt,Op,Mt,Dt$1,R,yt,wt],styles:[".sidenav-remote-control-container[_ngcontent-%COMP%]{height:calc(100% - 87px);width:calc(100% - 48px);margin:0 24px 24px;border:1px solid var(--mat-sys-outline-variant)}mat-sidenav[_ngcontent-%COMP%]{width:150px;--mat-sidenav-container-shape: square}.selected[_ngcontent-%COMP%]{background-color:var(--mat-sys-inverse-on-surface)}.loading-container[_ngcontent-%COMP%]{min-height:100%;display:flex;align-items:center;justify-content:center;padding:24px}.sidenav-remote-control-content[_ngcontent-%COMP%]{display:flex;flex-direction:row;flex-wrap:wrap;align-content:flex-start;height:100%;width:100%;padding:5px;gap:5px;overflow-y:auto;scrollbar-width:none;overflow-x:hidden;scroll-behavior:smooth;flex:1 1 auto;min-height:0}tile-large-icon[_ngcontent-%COMP%]{width:190px}.empty-state-msg[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex-wrap:nowrap;align-items:center;justify-content:center;height:100%;width:calc(100% - 150px);min-height:70vh;padding:2rem;text-align:center;color:var(--mat-sys-outline-variant);font-style:italic}.empty-state-icon[_ngcontent-%COMP%]{font-size:4rem;width:4rem;height:4rem;color:var(--mat-sys-outline-variant);margin-bottom:1rem}"]})}return n})();export{De as RemoteControlComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {d1 as Hj,w,du as p,dv as rt,aZ as F,a as G,cu as T,aY as xe,$ as $j,v as vt,F as Fa,dn as ge,a_ as Gp,J as JD,O as Op,bh as xp,y as yt,b as wt,cR as zt,bg as mt,P as Pi,c as $h,u as ul,k as Qh,cn as wd,T as TT,_ as _w,e as EE,M as Mw,f as eg,K as Kw,h as Fw,cV as Td,g as qw,t as pT,dE as RT,B as Bh,aA as gg,l as ud,m as dd,bp as gl}from'./main-BAV5VDOD.js';import {c}from'./chunk-Dxlia2NE.js';var J=["canvasMainRef"];function Z(o,e){if(o&1&&(Pi(0,"div",10),wd(),Pi(1,"svg",11)(2,"text",12),TT(3),ul()()(),Td(),Pi(4,"div",13),wd(),Pi(5,"svg",14)(6,"text",15)(7,"tspan",16),TT(8,"\u2691"),ul(),TT(9),Pi(10,"tspan",17),TT(11,"\u2691"),ul()()()(),Td(),Pi(12,"div",18),wd(),Pi(13,"svg",19)(14,"text",12),TT(15),ul()()()),o&2){let t=qw();EE(3),gg(t.portBiasValue()),EE(6),gl(" ",t.lineLengthValue()," "),EE(6),gg(t.stbBiasValue());}}function K(o,e){if(o&1){let t=Fw();Pi(0,"button",20),Qh("click",function(){ud(t);let i=qw();return dd(i.setLineEnd("port"))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",21)(3,"text",22),TT(4,"Port End"),ul()()()(),Td(),Pi(5,"button",23),Qh("click",function(){ud(t);let i=qw();return dd(i.setLineEnd("stb"))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",21)(8,"text",22),TT(9,"Stbd End"),ul()()()();}}function X(o,e){if(o&1){let t=Fw();Pi(0,"button",24),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",5,0))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"+5m"),ul()()()(),Td(),Pi(5,"button",27),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",-5,0))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",25)(8,"text",26),TT(9,"-5m"),ul()()()(),Td(),Pi(10,"button",28),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",-5,0))}),Pi(11,"mat-icon",6),wd(),Pi(12,"svg",25)(13,"text",26),TT(14,"-5m"),ul()()()(),Td(),Pi(15,"button",29),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",5,0))}),Pi(16,"mat-icon",6),wd(),Pi(17,"svg",25)(18,"text",26),TT(19,"+5m"),ul()()()();}}function tt(o,e){if(o&1){let t=Fw();Pi(0,"button",30),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",0,i.toRadians(1)))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"\u21911\xB0"),ul()()()(),Td(),Pi(5,"button",31),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",0,i.toRadians(-1)))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",25)(8,"text",26),TT(9,"\u21931\xB0"),ul()()()(),Td(),Pi(10,"button",32),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",0,i.toRadians(1)))}),Pi(11,"mat-icon",6),wd(),Pi(12,"svg",25)(13,"text",26),TT(14,"\u21931\xB0"),ul()()()(),Td(),Pi(15,"button",33),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",0,i.toRadians(-1)))}),Pi(16,"mat-icon",6),wd(),Pi(17,"svg",25)(18,"text",26),TT(19,"\u21911\xB0"),ul()()()();}}function et(o,e){if(o&1){let t=Fw();Pi(0,"button",34),Qh("click",function(){ud(t);let i=qw();return dd(i.nextDisplayLineName())}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"Line"),ul()()()(),Td(),Pi(5,"button",35),Qh("click",function(){ud(t);let i=qw();return dd(i.setStartLine(i.getDisplayLineName()))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",36)(8,"text",37),TT(9),ul()()()();}if(o&2){let t=qw();EE(5),pT(RT("button ",t.isDisplayLineCurrent()?"line-button-current":"line-button")),Bh("matTooltip",RT("Set the ",t.getDisplayLineName()," line as the current line")),EE(4),gg(t.getDisplayLineName());}}function it(o,e){o&1&&$h(0,"div",9);}var Q=class o{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);canvas=w(F);dashboard=w(G);signalk=w(T);destroyRef=w(xe);static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:false,displayName:"DTS",filterSelfPaths:true,playBeeps:true,convertUnitTo:"m",convertUnitToGroup:"Length",numDecimal:0,ignoreZones:true,color:"contrast",enableTimeout:false,dataTimeout:5,paths:{dtsPath:{description:"Distance to Start Line",path:"self.navigation.racing.distanceStartline",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:500},lineLengthPath:{description:"Length of the start line",path:"self.navigation.racing.startLineLength",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:1e3},lineBiasPath:{description:"Bias of the start line to starboard end",path:"self.navigation.racing.stbLineBias",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:1e3},startLineNamePath:{description:"The current named start line",path:"self.navigation.racing.lines.startLineName",source:"default",pathType:"string",pathRequired:false,isPathConfigurable:false,convertUnitTo:void 0,showPathSkUnitsFilter:false,pathSkUnitsFilter:null,sampleTime:1e3},linesPath:{description:"The known named lines",path:"self.navigation.racing.lines.lines",source:"default",pathType:null,pathRequired:false,isPathConfigurable:false,convertUnitTo:void 0,showPathSkUnitsFilter:false,pathSkUnitsFilter:null,sampleTime:1e3},ttlPath:{description:"Time to sail to the start line in seconds",path:"self.navigation.racing.timeToLine",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"s",showConvertUnitTo:false,showPathSkUnitsFilter:false,pathSkUnitsFilter:"s",sampleTime:500},ttbPath:{description:"Time to delay before sailing to the start line in seconds",path:"self.navigation.racing.timeToBurn",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"s",showConvertUnitTo:false,showPathSkUnitsFilter:false,pathSkUnitsFilter:"s",sampleTime:500}}};canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;titleBitmap=null;titleBitmapText=null;titleBitmapColor=null;dtsValue=null;lengthValue=null;biasValue=null;ttlValue=null;ttbValue=null;labelColor=vt("");valueColor="";dtsColor="";maxValueTextWidth=0;maxValueTextHeight=0;displayLineIndex=0;lines=[];startLineName=null;portBiasValue=vt("");lineLengthValue=vt("");stbBiasValue=vt("");mode=vt(0);normalizedConfig=vt(o.DEFAULT_CONFIG);get pathsRecord(){return (this.runtime.options()??o.DEFAULT_CONFIG).paths??{}}constructor(){Fa(()=>{let e=this.runtime.options()??o.DEFAULT_CONFIG,t=this.theme();t&&ge(()=>{let a=c(e.color??"contrast",t);this.labelColor.set(a.dim),this.valueColor=a.color,this.draw();});}),Fa(()=>{this.pathsRecord.dtsPath?.path&&ge(()=>this.streams.observe("dtsPath",t=>{this.dtsValue=t?.data?.value??null,this.updateDtsColor(),this.draw();}));}),Fa(()=>{this.pathsRecord.lineLengthPath?.path&&ge(()=>this.streams.observe("lineLengthPath",t=>{this.lengthValue=t?.data?.value??null,this.setLenBias(),this.draw();}));}),Fa(()=>{this.pathsRecord.lineBiasPath?.path&&ge(()=>this.streams.observe("lineBiasPath",t=>{this.biasValue=t?.data?.value??null,this.setLenBias();}));}),Fa(()=>{this.pathsRecord.startLineNamePath?.path&&ge(()=>this.streams.observe("startLineNamePath",t=>{console.log("startLineName: "+JSON.stringify(t??"no data")),this.startLineName=t?.data?.value??null,this.displayLineIndex=0;for(let a=0;a<this.lines.length;a++)if(this.lines[a]===this.startLineName){this.displayLineIndex=a;break}this.draw();}));}),Fa(()=>{this.pathsRecord.linesPath?.path&&ge(()=>this.streams.observe("linesPath",t=>{if(console.log("lines: "+JSON.stringify(t??"no data")),this.lines=["Default"],this.displayLineIndex=0,t?.data?.value&&Array.isArray(t.data.value))for(let a of t.data.value)a.startLineName&&(a.startLineName===this.startLineName&&(this.displayLineIndex=this.lines.length),this.lines.push(a.startLineName));}));}),Fa(()=>{this.pathsRecord.ttlPath?.path&&ge(()=>this.streams.observe("ttlPath",t=>{this.ttlValue=t?.data?.value??null,this.draw();}));}),Fa(()=>{this.pathsRecord.ttbPath?.path&&ge(()=>this.streams.observe("ttbPath",t=>{this.ttbValue=t?.data?.value??null,this.draw();}));}),this.signalk.subscribeRequest().pipe(Gp(this.destroyRef)).subscribe(e=>{e.widgetUUID===this.id()&&e.statusCode===200&&this.beep(600,20);});}ngAfterViewInit(){this.canvasElement=this.canvasRef().nativeElement,this.ctx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(e,t)=>{this.cssWidth=e,this.cssHeight=t,this.maxValueTextWidth=Math.floor(this.cssWidth*.95),this.maxValueTextHeight=Math.floor(this.cssHeight*.95),this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.maxValueTextWidth=Math.floor(this.cssWidth*.95),this.maxValueTextHeight=Math.floor(this.cssHeight*.95),this.draw();}toggleMode(){this.mode.update(e=>(e+1)%5),this.draw();}setLineEnd(e){return this.signalk.putRequest("navigation.racing.setStartLine",{end:e,position:"bow"},this.id())??""}adjustLineEnd(e,t,a){return this.signalk.putRequest("navigation.racing.setStartLine",{end:e,delta:t,rotate:a},this.id())??""}nextDisplayLineName(){++this.displayLineIndex>=this.lines.length&&(this.displayLineIndex=0);}getDisplayLineName(){return this.lines[this.displayLineIndex]||"Default"}isDisplayLineCurrent(){return this.getDisplayLineName()===(this.startLineName||"Default")}setStartLine(e){let t=e==="Default"||!e?null:e;this.signalk.putRequest("navigation.racing.setStartLineName",{startLineName:t},this.id()),this.mode.set(0),this.draw();}toRadians(e){return e*(Math.PI/180)}draw(){if(!this.ctx||!this.canvasElement)return;let e=this.runtime.options()??o.DEFAULT_CONFIG,t=e?.displayName||"DTS",a=this.labelColor();(!this.titleBitmap||!e||this.titleBitmap.width!==this.canvasElement.width||this.titleBitmap.height!==this.canvasElement.height||this.titleBitmapText!==t||this.titleBitmapColor!==a)&&(this.titleBitmap=this.canvas.createTitleBitmap(t,a,"normal",this.cssWidth,this.cssHeight),this.titleBitmapText=t,this.titleBitmapColor=a),this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),this.titleBitmap&&this.ctx.drawImage(this.titleBitmap,0,0,this.cssWidth,this.cssHeight),this.canvas.drawText(this.ctx,this.getValueText(),Math.floor(this.cssWidth*.5),Math.floor(this.cssHeight*.325),Math.floor(this.cssWidth*.95),Math.floor(this.cssHeight*.55),"bold",this.dtsColor,"center","middle"),this.canvas.drawText(this.ctx,this.pathsRecord.dtsPath?.convertUnitTo||"m",Math.floor(this.cssWidth*.975),Math.floor(this.cssHeight*.6),Math.floor(this.cssWidth*.95),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"right","bottom"),this.canvas.drawText(this.ctx,"TTL",Math.floor(this.cssWidth*.025),Math.floor(this.cssHeight*.7),Math.floor(this.cssWidth*.1),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"left","middle"),this.canvas.drawText(this.ctx,this.getTimeToLineText(),Math.floor(this.cssWidth*.15),Math.floor(this.cssHeight-.8),Math.floor(this.cssWidth*.35),Math.floor(this.cssHeight*.35),"bold",this.dtsColor,"left","bottom"),this.canvas.drawText(this.ctx,"TTB",Math.floor(this.cssWidth*.525),Math.floor(this.cssHeight*.7),Math.floor(this.cssWidth*.1),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"left","middle"),this.canvas.drawText(this.ctx,this.getTimeToBurnText(),Math.floor(this.cssWidth*.65),Math.floor(this.cssHeight-.8),Math.floor(this.cssWidth*.35),Math.floor(this.cssHeight*.35),"bold",this.dtsColor,"left","bottom"),this.setLenBias();}getValueText(){if(this.dtsValue===null)return "--";let e=this.runtime.options()??o.DEFAULT_CONFIG;return this.dtsValue.toFixed(e?.numDecimal??0)}toHHMMSS(e){if(e==null||isNaN(e))return "-:--";let t=e<0;t&&(e=-e);let a=Math.floor(e/3600),i=Math.floor(e%3600/60),f=Math.floor(e%60),C=t?"-":"";return a===0?`${C}${i.toString().padStart(1,"0")}:${f.toString().padStart(2,"0")}`:`${C}${a.toString().padStart(1,"0")}:${i.toString().padStart(2,"0")}:${f.toString().padStart(2,"0")}`}getTimeToLineText(){return this.toHHMMSS(this.ttlValue??0)}getTimeToBurnText(){return this.toHHMMSS(this.ttbValue??0)}setLenBias(){let e=this.runtime.options()??o.DEFAULT_CONFIG,t=this.pathsRecord.lineLengthPath,a=this.pathsRecord.lineBiasPath;if(t?.path&&this.lengthValue!=null){let i=t.convertUnitTo;i==="feet"&&(i="\u2032"),this.lineLengthValue.set(`\u2015${this.applyDecorations(this.lengthValue.toFixed(e.numDecimal??0))}${i??""}\u2015`);}if(a?.path&&this.biasValue!=null){let i=a.convertUnitTo;i==="feet"&&(i="\u2032"),this.biasValue<0?(this.portBiasValue.set("+"+(-this.biasValue).toFixed(e.numDecimal??0)+(i??"")),this.stbBiasValue.set(this.biasValue.toFixed(e.numDecimal??0)+(i??""))):(this.portBiasValue.set(" "+(-this.biasValue).toFixed(e.numDecimal??0)+(i??"")),this.stbBiasValue.set(" +"+this.biasValue.toFixed(e.numDecimal??0)+(i??"")));}}applyDecorations(e){switch(this.pathsRecord.dtsPath?.convertUnitTo){case "percent":case "percentraw":return e+"%";default:return e}}updateDtsColor(){let e=this.theme(),t=this.runtime.options()??o.DEFAULT_CONFIG;e&&(t.ignoreZones?this.dtsValue?this.dtsValue<0?this.dtsColor=e.zoneAlarm:this.dtsValue<10?this.dtsColor=e.zoneWarn:this.dtsValue<20?this.dtsColor=e.zoneAlert:this.dtsColor=this.valueColor:this.dtsColor=this.valueColor:this.dtsColor=this.valueColor);}beep(e=440,t=100){if(!this.runtime.options()?.playBeeps)return;let a=window.AudioContext||window.webkitAudioContext,i=new a,f=i.createOscillator(),C=i.createGain();f.connect(C),C.connect(i.destination),f.type="sine",f.frequency.value=e,C.gain.value=.1,f.start(),f.stop(i.currentTime+t/1e3);}ngOnDestroy(){try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(e){}}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=JD({type:o,selectors:[["widget-racer-line"]],viewQuery:function(t,a){t&1&&eg(a.canvasRef,J,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:16,vars:2,consts:[["canvasMainRef",""],[1,"line-wrapper"],[1,"filler"],[1,"line-canvas"],[1,"buttons-container"],["mat-flat-button","","matTooltip","Select the control mode",1,"button","select-button",3,"click"],[1,"buttons-svg-icon"],["width","100%","height","100%","viewBox","0 0 80 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","40","y","9"],[1,"widgetOverlay"],[1,"pin-container"],["width","100%","height","100%","viewBox","0 0 70 18","preserveAspectRatio","xMidYMid meet",1,"svg-content","pin"],["x","33","y","14"],[1,"len-bias-container"],["width","100%","height","100%","viewBox","0 0 90 12","preserveAspectRatio","xMidYMid meet",1,"svg-content","len-bias"],["x","45","y","9"],[1,"pin"],[1,"boat"],[1,"boat-container"],["width","100%","height","100%","viewBox","0 0 70 18","preserveAspectRatio","xMidYMid meet",1,"svg-content","boat"],["mat-flat-button","","matTooltip","Set the port(pin) end of the line to the current position",1,"button","port-button",3,"click"],["width","100%","height","100%","viewBox","0 0 100 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","50","y","11"],["mat-flat-button","","matTooltip","Set the starboard(boat) end of the line to the current position",1,"button","starboard-button",3,"click"],["mat-flat-button","","matTooltip","Increase the line length by 5m at the port(pin) end",1,"button","port-small-button",3,"click"],["width","100%","height","100%","viewBox","0 0 50 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","25","y","11"],["mat-flat-button","","matTooltip","Decrease the line length by 5m at the port(pin) end",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Decrease the line length by 5m at the starboard(boat) end",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Increase the line length by 5m at the starboard(boat) end",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the port(pin) end 1\xB0 clockwise",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the port(pin) end 1\xB0 counter-clockwise",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the starboard(boat) end 1\xB0 counter-clockwise",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the starboard(boat) end 1\xB0 clockwise",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Display the next named line",1,"button","select-button",3,"click"],["mat-flat-button","",3,"click","matTooltip"],["width","100%","height","100%","viewBox","0 0 150 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","75","y","11"]],template:function(t,a){if(t&1&&(Pi(0,"div",1)(1,"div",2),$h(2,"canvas",3,0),ul(),Pi(4,"div",4)(5,"button",5),Qh("click",function(){return a.toggleMode()}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",7)(8,"text",8),TT(9,"\u22EE"),ul()()()(),_w(10,Z,16,3)(11,K,10,0)(12,X,20,0)(13,tt,20,0)(14,et,10,6),ul(),_w(15,it,1,0,"div",9),ul()),t&2){let i;EE(10),Mw((i=a.mode())===0?10:i===1?11:i===2?12:i===3?13:i===4?14:-1),EE(5),Mw(a.dashboard.isDashboardStatic()?-1:15);}},dependencies:[Op,xp,yt,wt,zt,mt],styles:["[_nghost-%COMP%]{overflow:clip;display:block;height:100%;width:100%}.line-wrapper[_ngcontent-%COMP%]{width:100%;height:100%;min-height:1px}.line-canvas[_ngcontent-%COMP%]{position:absolute;width:100%!important;height:76%!important;display:block;top:0;left:0}.filler[_ngcontent-%COMP%]{width:100%;height:76%}.buttons-container[_ngcontent-%COMP%]{display:flex;flex-wrap:nowrap;justify-content:space-between;column-gap:2%;position:relative;height:24%;width:100%;padding:0 10px 14px;z-index:20;pointer-events:auto;align-items:center}.button[_ngcontent-%COMP%]{min-width:0px;width:100%;border-radius:12px;align-items:center;justify-content:center;cursor:pointer;--mat-button-filled-container-height: 100%;--mat-button-filled-horizontal-padding: 0px;--mat-button-filled-icon-spacing: 0px}.select-button[_ngcontent-%COMP%]{flex:none;width:18%;--mat-button-filled-container-color: var(--kip-blue-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.line-button[_ngcontent-%COMP%]{flex:none;width:58%;--mat-button-filled-container-color: var(--kip-grey-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.line-button-current[_ngcontent-%COMP%]{flex:none;width:58%;--mat-button-filled-container-color: var(--kip-orange-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.port-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.starboard-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-starboard-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.port-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.starboard-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-starboard-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.buttons-svg-icon[_ngcontent-%COMP%]{width:100%;height:100%;margin:0;padding:0}.svg-content[_ngcontent-%COMP%]{width:100%;height:100%;padding:0;margin:0}.svg-content[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-family:Roboto;font-size:15px;font-weight:700;text-align:center;text-anchor:middle;font-style:normal;font-variant:normal;font-stretch:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke:none}.pin-container[_ngcontent-%COMP%]{flex-basis:18%}.pin[_ngcontent-%COMP%]{fill:var(--kip-port-color)}.pin[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:19px}.len-bias-container[_ngcontent-%COMP%]{flex-basis:35%}.len-bias[_ngcontent-%COMP%]{fill:var(--kip-contrast-color)}.len-bias[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:12px}.boat-container[_ngcontent-%COMP%]{flex-basis:18%}.boat[_ngcontent-%COMP%]{fill:var(--kip-starboard-color)}.boat[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:19px}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent;z-index:21}"]})};export{Q as WidgetRacerLineComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {m as me}from'./chunk-Bp0MQwPM.js';import {w as w$1,aQ as ee,aX as He,aR as lt,G as Gi,J as JD}from'./main-BAV5VDOD.js';var w=(()=>{class o{dialog=w$1(ee);auth=w$1(He);toast=w$1(lt);settings=w$1(Gi);connectionConfig=null;ngOnInit(){this.connectionConfig=this.settings.getConnectionConfig(),this.openUserCredentialModal("Sign in failed: Incorrect user/password. Enter valide credentials or access the Confifuration/Settings menu, validate the server URL or/and disable the user Sign in option");}openUserCredentialModal(t){let n=this.connectionConfig;if(!n)return;this.dialog.open(me,{disableClose:true,data:{user:n.loginName,password:n.loginPassword,error:t}}).afterClosed().subscribe(s=>{s===void 0||!s||(n.loginName=s.user,n.loginPassword=s.password,this.settings.setConnectionConfig(n),this.serverLogin());});}serverLogin(t){let n=this.connectionConfig;n&&this.auth.login({usr:n.loginName,pwd:n.loginPassword,newUrl:t}).then(()=>{this.settings.reloadApp();}).catch(e=>{e.status==401?(this.openUserCredentialModal("Sign in failed: Invalide user/password. Enter valide credentials"),console.log("[Setting-SignalK Component] Sign in failed: "+e.error.message)):e.status==404?(this.toast.show("Login API not found at URL. See connection detail status in Configuration/Settings",5e3,false,"error"),console.log("[Setting-SignalK Component] Sign in failed: "+e.error.message)):e.status==0?(this.toast.show("Cannot reach server at Signal K URL. See connection detail status in Configuration/Settings",5e3,false,"error"),console.log("[Setting-SignalK Component] Sign in failed: Cannot reach server at Signal K URL:"+e.message)):(this.toast.show("Unknown authentication failure: "+JSON.stringify(e),5e3,false,"error"),console.log("[Setting-SignalK Component] Unknown login error response: "+JSON.stringify(e)));});}static \u0275fac=function(n){return new(n||o)};static \u0275cmp=JD({type:o,selectors:[["app-widget-login"]],decls:0,vars:0,template:function(n,e){},encapsulation:2})}return o})();export{w as WidgetLoginComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {f}from'./chunk-H9_eqTYx.js';import {d1 as Hj,w,du as p,dv as rt,dD as _,cu as T,a as G,aR as lt,W as Wp,D as Dt,v as vt,cw as z,cv as G$1,F as Fa,dn as ge,J as JD,dC as x,_ as _w,P as Pi,cn as wd,c as $h,u as ul,X as xw,M as Mw,e as EE,an as Hh,Y as Aw,g as qw,B as Bh,h as Fw,k as Qh,l as ud,m as dd,T as TT,d as ig,s as sg,t as pT,cr as mg}from'./main-BAV5VDOD.js';import {c}from'./chunk-Dxlia2NE.js';var Y=(n,i)=>i.raw.value;function K(n,i){if(n&1&&$h(0,"widget-title",0),n&2){let t=qw();Bh("text",t.displayName())("color",t.accentColor());}}function Q(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.fullRoundedItemPathD())("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function X(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.topRoundedItemPathD())("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function ee(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.bottomRoundedItemPathD())("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function te(n,i){if(n&1&&(wd(),$h(0,"rect",18)),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("width",e.menuWidth)("height",e.itemHeight)("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function ie(n,i){if(n&1){let t=Fw();wd(),Pi(0,"g",15),Qh("pointerdown",function(s){ud(t);let o=qw();return dd(o.onPointerDown(s))})("pointermove",function(s){ud(t);let o=qw();return dd(o.onPointerMove(s))})("pointerup",function(s){let o=ud(t).$implicit,l=qw();return dd(l.onPointerUp(s,o))})("pointercancel",function(s){ud(t);let o=qw();return dd(o.onPointerCancel(s))})("keyup.enter",function(){let s=ud(t).$implicit,o=qw();return dd(o.canPut()&&o.selectUi(s))})("keyup.space",function(){let s=ud(t).$implicit,o=qw();return dd(o.canPut()&&o.selectUi(s))}),_w(1,Q,1,4,":svg:path",16)(2,X,1,4,":svg:path",16)(3,ee,1,4,":svg:path",16)(4,te,1,5,":svg:rect",17),Pi(5,"text"),TT(6),ul()();}if(n&2){let t=i.$implicit,e=qw();ig("cursor",e.canPut()?"pointer":"not-allowed"),sg("is-selected",e.isSelected(t.raw))("is-off",t.raw.isOn===false),Hh("transform","translate(0 "+t.index*(e.itemHeight+e.itemGap)+")")("tabindex",e.canPut()?0:-1)("aria-label",t.label)("aria-pressed",e.isSelected(t.raw))("aria-disabled",!e.canPut()),EE(),Mw(t.index===0&&t.index===e.optionsCount()-1?1:t.index===0?2:t.index===e.optionsCount()-1?3:4),EE(4),pT(e.isSelected(t.raw)?"svg-menu-item-current-text":t.raw.isOn===false?"svg-menu-item-off-text":"svg-menu-item-text"),Hh("x",e.menuWidth/2)("y",e.itemHeight/2)("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",(e.isSelected(t.raw)||t.raw.isOn===false,e.textColor())),EE(),mg(" ",e.isSelected(t.raw)?"\u2713 ":"","",t.label," ");}}function ne(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.fullRoundedItemPathD())("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function oe(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.topRoundedItemPathD())("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function re(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.bottomRoundedItemPathD())("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function ae(n,i){if(n&1&&(wd(),$h(0,"rect",18)),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("width",e.menuWidth)("height",e.itemHeight)("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function se(n,i){if(n&1){let t=Fw();wd(),Pi(0,"g",15),Qh("pointerdown",function(s){ud(t);let o=qw();return dd(o.onPointerDown(s))})("pointermove",function(s){ud(t);let o=qw();return dd(o.onPointerMove(s))})("pointerup",function(s){let o=ud(t).$implicit,l=qw();return dd(l.onPointerUp(s,o))})("pointercancel",function(s){ud(t);let o=qw();return dd(o.onPointerCancel(s))})("keyup.enter",function(){let s=ud(t).$implicit,o=qw();return dd(o.canPut()&&o.selectUi(s))})("keyup.space",function(){let s=ud(t).$implicit,o=qw();return dd(o.canPut()&&o.selectUi(s))}),_w(1,ne,1,5,":svg:path",16)(2,oe,1,5,":svg:path",16)(3,re,1,5,":svg:path",16)(4,ae,1,6,":svg:rect",17),Pi(5,"text"),TT(6),ul()();}if(n&2){let t=i.$implicit,e=qw();ig("cursor",e.canPut()?"pointer":"not-allowed"),sg("is-selected",e.isSelected(t.raw))("is-off",t.raw.isOn===false),Hh("transform","translate(0 "+t.index*(e.itemHeight+e.itemGap)+")")("tabindex",e.canPut()?0:-1)("aria-label",t.label)("aria-pressed",e.isSelected(t.raw))("aria-disabled",!e.canPut()),EE(),Mw(t.index===0&&t.index===e.optionsCount()-1?1:t.index===0?2:t.index===e.optionsCount()-1?3:4),EE(4),pT(e.isSelected(t.raw)?"svg-menu-item-current-text":t.raw.isOn===false?"svg-menu-item-off-text":"svg-menu-item-text"),Hh("x",e.menuWidth/2)("y",e.itemHeight/2)("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",(e.isSelected(t.raw)||t.raw.isOn===false,e.textColor())),EE(),mg(" ",e.isSelected(t.raw)?"\u2713 ":"","",t.label," ");}}function le(n,i){n&1&&$h(0,"div",14);}var J=class n{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={displayName:"Switch Label",showLabel:true,filterSelfPaths:true,paths:{controlPath:{description:"Multi-state control path",path:null,source:null,pathType:"multiple",supportsPut:true,isPathConfigurable:true,pathRequired:true,showPathSkUnitsFilter:false,pathSkUnitsFilter:null,showConvertUnitTo:false,convertUnitTo:void 0,sampleTime:500}},enableTimeout:false,dataTimeout:5,color:"contrast"};runtime=w(p);streams=w(rt);meta=w(_);signalkRequestsService=w(T);dashboard=w(G);toast=w(lt);skRequest=Wp(this.signalkRequestsService.subscribeRequest(),{initialValue:null});cfg=Dt(()=>this.runtime.options()??n.DEFAULT_CONFIG);displayName=Dt(()=>this.cfg().displayName??"Switch Label");showLabel=Dt(()=>this.cfg().showLabel??true);controlPath=Dt(()=>this.getControlPath(this.cfg()));accentColor=vt("");accentDim=vt("");accentDimmer=vt("");textColor=vt("");textDim=vt("");textDimmer=vt("");currentValue=vt(null);sortedOptions=Dt(()=>{let i=this.meta.possibleValues();if(!i.length)return [];let t=i.map(e=>({raw:e,label:e.title||e.abbrev||String(e.value),comparable:this.toComparable(e.value)}));return t.sort((e,s)=>{let o=e.comparable,l=s.comparable;return o.kind==="num"&&l.kind==="num"?o.value-l.value:o.kind==="str"&&l.kind==="str"?o.value.localeCompare(l.value):o.kind==="num"?-1:1}),t.map((e,s)=>z(G$1({},e),{index:s}))});menuWidth=220;itemHeight=50;itemGap=1;svgPadding=Math.max(1,Math.round(this.itemHeight*.2));optionsCount=Dt(()=>this.sortedOptions().length);menuHeight=Dt(()=>{let i=this.sortedOptions().length;return i<=0?0:i*this.itemHeight+(i-1)*this.itemGap});hasOptions=Dt(()=>this.meta.possibleValues().length>0);selectedValue=Dt(()=>this.currentValue());canPut=Dt(()=>this.meta.supportsPut());swipeGuard=f();unselectedOptions=Dt(()=>this.sortedOptions().filter(i=>!this.isSelected(i.raw)));selectedOptions=Dt(()=>this.sortedOptions().filter(i=>this.isSelected(i.raw)));fullRoundedItemPathD=Dt(()=>this.buildRoundedRectPath(this.menuWidth,this.itemHeight,this.cornerRadius,true,true));topRoundedItemPathD=Dt(()=>this.buildRoundedRectPath(this.menuWidth,this.itemHeight,this.cornerRadius,true,false));bottomRoundedItemPathD=Dt(()=>this.buildRoundedRectPath(this.menuWidth,this.itemHeight,this.cornerRadius,false,true));cornerRadius=7;constructor(){Fa(()=>{let i=this.theme(),t=this.cfg().color??"contrast";!i||!t||ge(()=>{this.accentColor.set(c(t,i).color),this.accentDim.set(c(t,i).dim),this.accentDimmer.set(c(t,i).dimmer),t==="contrast"?(this.textColor.set(i.background),this.textDim.set(i.contrastDim),this.textDimmer.set(i.contrastDimmer)):(this.textColor.set(i.contrast),this.textDim.set(c(t,i).dim),this.textDimmer.set(c(t,i).dimmer));});}),Fa(()=>{if(!this.controlPath()){this.currentValue.set(null);return}ge(()=>{this.streams.observe("controlPath",t=>{this.currentValue.set(t?.data?.value??null);}),this.meta.observe("controlPath");});});}select(i){let t=this.getControlPath(this.cfg());t&&this.signalkRequestsService.putRequest(t,i.value,this.id());}selectUi(i){this.select(i.raw);}onPointerDown(i){this.canPut()&&this.swipeGuard.onPointerDown(i);}onPointerMove(i){this.canPut()&&this.swipeGuard.onPointerMove(i);}onPointerUp(i,t){this.canPut()&&this.swipeGuard.onPointerUp(i)&&this.selectUi(t);}onPointerCancel(i){this.swipeGuard.onPointerCancel(i);}getControlPath(i){let t=i?.paths;return !t||Array.isArray(t)?null:t.controlPath?.path??null}isSelected(i){let t=this.selectedValue();return typeof i.value=="number"&&typeof t=="string"?i.value===Number(t):typeof i.value=="string"&&typeof t=="number"?Number(i.value)===t||i.value===String(t):Object.is(i.value,t)}toComparable(i){if(typeof i=="number"&&Number.isFinite(i))return {kind:"num",value:i};if(typeof i=="boolean")return {kind:"num",value:i?1:0};if(typeof i=="string"){let t=i.trim();if(/^-?\d+(\.\d+)?$/.test(t)){let e=Number(t);if(Number.isFinite(e))return {kind:"num",value:e}}return {kind:"str",value:t}}return {kind:"str",value:String(i)}}buildRoundedRectPath(i,t,e,s,o){let l=Math.max(0,i),f=Math.max(0,t),r=Math.max(0,Math.min(e,l/2,f/2));return l===0||f===0?"":r===0?`M0 0H${l}V${f}H0Z`:s&&o?[`M${r} 0`,`H${l-r}`,`A${r} ${r} 0 0 1 ${l} ${r}`,`V${f-r}`,`A${r} ${r} 0 0 1 ${l-r} ${f}`,`H${r}`,`A${r} ${r} 0 0 1 0 ${f-r}`,`V${r}`,`A${r} ${r} 0 0 1 ${r} 0`,"Z"].join(""):s?[`M0 ${r}`,`A${r} ${r} 0 0 1 ${r} 0`,`H${l-r}`,`A${r} ${r} 0 0 1 ${l} ${r}`,`V${f}`,"H0","Z"].join(""):o?["M0 0",`H${l}`,`V${f-r}`,`A${r} ${r} 0 0 1 ${l-r} ${f}`,`H${r}`,`A${r} ${r} 0 0 1 0 ${f-r}`,"V0","Z"].join(""):`M0 0H${l}V${f}H0Z`}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=JD({type:n,selectors:[["widget-multi-state-switch"]],inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:23,vars:6,consts:[[3,"text","color"],["role","group",1,"widgets-container"],["preserveAspectRatio","xMidYMid meet","role","presentation",1,"svg-menu"],["id","glow","x","-50%","y","-50%","width","200%","height","200%"],["stdDeviation","5","result","coloredBlur"],["in","coloredBlur"],["in","SourceGraphic"],["id","focus-inner-ring","x","0","y","0","width","100%","height","100%","color-interpolation-filters","sRGB"],["in","SourceAlpha","operator","erode","radius","2","result","eroded"],["in","SourceAlpha","in2","eroded","operator","out","result","border"],["flood-color","#ffffff","flood-opacity","0.9","result","ringColor"],["in","ringColor","in2","border","operator","in","result","ring"],["in","ring"],["role","button",1,"svg-menu-item-group",3,"is-selected","is-off","cursor"],[1,"widgetOverlay"],["role","button",1,"svg-menu-item-group",3,"pointerdown","pointermove","pointerup","pointercancel","keyup.enter","keyup.space"],[3,"class"],["x","0","y","0",3,"class"],["x","0","y","0"]],template:function(t,e){t&1&&(_w(0,K,1,2,"widget-title",0),Pi(1,"div",1),wd(),Pi(2,"svg",2)(3,"defs")(4,"filter",3),$h(5,"feGaussianBlur",4),Pi(6,"feMerge"),$h(7,"feMergeNode",5)(8,"feMergeNode",6),ul()(),Pi(9,"filter",7),$h(10,"feMorphology",8)(11,"feComposite",9)(12,"feFlood",10)(13,"feComposite",11),Pi(14,"feMerge"),$h(15,"feMergeNode",6)(16,"feMergeNode",12),ul()()(),Pi(17,"g"),xw(18,ie,7,20,":svg:g",13,Y),xw(20,se,7,20,":svg:g",13,Y),ul()()(),_w(22,le,1,0,"div",14)),t&2&&(Mw(e.showLabel()?0:-1),EE(),Hh("aria-label",e.displayName()),EE(),Hh("viewBox","0 0 "+(e.menuWidth+e.svgPadding*2)+" "+((e.menuHeight()||e.itemHeight)+e.svgPadding*2))("aria-label",e.displayName()),EE(15),Hh("transform","translate("+e.svgPadding+" "+e.svgPadding+")"),EE(),Aw(e.unselectedOptions()),EE(2),Aw(e.selectedOptions()),EE(2),Mw(e.dashboard.isDashboardStatic()?-1:22));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent;z-index:21}.widgets-container[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;padding:2px}.svg-menu[_ngcontent-%COMP%]{width:100%;height:100%;display:block;background:transparent;border-radius:12px;z-index:20;font-family:Roboto;font-size:1.3rem;font-weight:700;text-anchor:middle;text-align:center;alignment-baseline:middle}.svg-menu-item-current[_ngcontent-%COMP%]{stroke:var(--mat-sys-on-background);stroke-width:3px;stroke-dasharray:none;stroke-opacity:1}.svg-menu-item[_ngcontent-%COMP%]{fill:var(--mat-sys-outline);stroke:#000;stroke-width:2px;stroke-dasharray:none;stroke-opacity:.2}.svg-menu-item-off[_ngcontent-%COMP%]{stroke:#000;stroke-width:2;stroke-dasharray:none;stroke-opacity:.2}.svg-menu-item-current-text[_ngcontent-%COMP%]{font-size:1.5rem;font-weight:700;text-anchor:middle;dominant-baseline:middle;alignment-baseline:middle}.svg-menu-item-text[_ngcontent-%COMP%], .svg-menu-item-off-text[_ngcontent-%COMP%]{font-weight:600;text-anchor:middle;dominant-baseline:middle;alignment-baseline:middle}.svg-menu-item-group[_ngcontent-%COMP%]:focus{outline:none}.svg-menu-item-group[_ngcontent-%COMP%]:focus-visible :is(rect[_ngcontent-%COMP%], path[_ngcontent-%COMP%]){filter:url(#focus-inner-ring)}"]})};export{J as WidgetMultiStateSwitchComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function S(t,e,r,l=1e3,u,n,o=[500,500],a){if(n){let s=n.get(t);s&&cancelAnimationFrame(s);}e=(()=>{let s=t.getAttribute("transform");if(s){let A=/rotate\((-?\d+(\.\d+)?)/.exec(s);if(A)return parseFloat(A[1])}return e})();let i=s=>(s+360)%360;e=i(e),r=i(r);let c=r-e;c>180&&(c-=360),c<-180&&(c+=360);let h=s=>s<.5?4*s*s*s:1-Math.pow(-2*s+2,3)/2,m=s=>a?a.runOutsideAngular(s):s();m(()=>{let s=performance.now(),A=p=>{let w=p-s,O=Math.min(w/l,1),g=h(O),q=e+c*g;if(t.setAttribute("transform",`rotate(${q} ${o[0]} ${o[1]})`),O<1){let b=requestAnimationFrame(A);n&&n.set(t,b);}else t.setAttribute("transform",`rotate(${r} ${o[0]} ${o[1]})`),n&&n.delete(t);},I=requestAnimationFrame(A);n&&n.set(t,I);});}function _(t,e,r,l=500,u,n,o){if(n){let i=n.get(t);i&&cancelAnimationFrame(i);}let a=i=>o?o.runOutsideAngular(i):i();a(()=>{let i=performance.now(),c=r-e,h=s=>s<.5?4*s*s*s:1-Math.pow(-2*s+2,3)/2,m=s=>{let A=s-i,I=Math.min(A/l,1),p=h(I),w=e+c*p;if(t.setAttribute("width",w.toString()),I<1){let O=requestAnimationFrame(m);n&&n.set(t,O);}else t.setAttribute("width",r.toString()),n&&n.delete(t);},F=requestAnimationFrame(m);n&&n.set(t,F);});}var x=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,f=t=>(t%360+360)%360,$=(t,e)=>{let r=f(e)-f(t);return r>180&&(r-=360),r<=-180&&(r+=360),r};function v(t,e,r,l,u,n){let o=i=>n?n.runOutsideAngular(i):i(),a=i=>n?n.run(i):i(),d=0;return o(()=>{let i=performance.now(),c=$(t,e),h=f(t),m=F=>{let s=Math.min((F-i)/r,1),A=x(s),I=h+c*A;l(f(I)),s<1?d=requestAnimationFrame(m):u&&a(u);};d=requestAnimationFrame(m);}),d}var C=(t,e,r)=>({min:t.min+(e.min-t.min)*r,mid:t.mid+(e.mid-t.mid)*r,max:t.max+(e.max-t.max)*r});function R(t,e,r,l,u,n){let o=i=>n?n.runOutsideAngular(i):i(),a=i=>n?n.run(i):i(),d=0;return o(()=>{let i=performance.now(),c=h=>{let m=Math.min((h-i)/r,1),F=x(m);l(C(t,e,F)),m<1?d=requestAnimationFrame(c):u&&a(u);};d=requestAnimationFrame(c);}),d}export{R,S,_,v};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import'./chunk-By8ZVvDx.js';import {d1 as Hj,w,du as p,ao as ue,dy as K,dw as S,aZ as F,bu as ut,i as ir,$ as $j,a6 as Lr,b0 as Wl,W as Wp,E as Em,F as Fa,dn as ge,cw as z,cv as G,J as JD,cp as Uh,f as eg,K as Kw}from'./main-BAV5VDOD.js';var tt=["widgetDataChart"],mt=(()=>{class O{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p,{optional:true});static DEFAULT_CONFIG={filterSelfPaths:true,color:"contrast",timeScale:"Last 30 Minutes"};ngZone=w(ue);_dataset=w(K);datasetLifecycle=w(S);canvasService=w(F);unitsService=w(ut);responsive=w(ir);isPhonePortrait;widgetDataChart=$j("widgetDataChart",{read:Lr});lineChartData={datasets:[]};lineChartOptions={parsing:false,datasets:{line:{pointRadius:0,pointHoverRadius:0,tension:.3}},animations:{tension:{easing:"easeInOutCubic"}}};lineChartType="line";chart=null;_dsDirectionSub=null;_dsSpeedSub=null;_chartUpdateRafId=null;datasetConfig=null;dataSourceInfo=null;xCenter=null;xStep=null;xCenterSpeed=null;xStepSpeed=null;CENTER_LINE_WIDTH=4;GRID_LINE_WIDTH=1;EDGE_EXTEND_UP_PX=42;EDGE_SPEED_LABEL_OFFSET=5;EDGE_DIR_LABEL_OFFSET=5;TICK_LABEL_FONT_SIZE=20;TICK_LABEL_PHONE_PORTRAIT_FONT_SIZE=11;CENTER_LABEL_FONT_SIZE=22;CENTER_LABEL_PHONE_PORTRAIT_FONT_SIZE=13;SPEED_VALUE_FONT_SIZE=62;SPEED_VALUE_PHONE_PORTRAIT_FONT_SIZE=32;TOP_VALUE_Y_OFFSET=62;TOP_VALUE_PHONE_PORTRAIT_Y_OFFSET=44;TOP_UNIT_Y_OFFSET=51;TOP_UNIT_PHONE_PORTRAIT_Y_OFFSET=38;UNIT_FONT_SIZE=28;UNIT_PHONE_PORTRAIT_FONT_SIZE=14;UNIT_PADDING=8;UNIT_PHONE_PORTRAIT_PADDING=3;isPortrait=()=>this.isPhonePortrait()?.matches===true;gridBackgroundPlugin={id:"xSpeedGridBackground",beforeDraw:e=>{let t=e.chartArea;if(!t)return;let a=e.ctx,i=this.theme();a.save(),a.globalCompositeOperation="destination-over",a.fillStyle=i.background,a.fillRect(t.left,t.top,t.width/2,t.height),a.restore();}};centerTickPlugin={id:"centerTickStyle",afterDraw:e=>{let t=e.ctx,a=e.chartArea,i=this.theme(),n=this.getThemeColors(),o=Wl.defaults.font,u=e.scales,c=e.options?.scales,r=e.data?.datasets?.[0]?.data,d=e.data?.datasets?.[5]?.data,f=(r?.length??0)>=2&&(d?.length??0)>=2,h=(p,g)=>{let l=u?.[p],x=c;if(!l)return;let E=l,v=x?.[p]?.min??E.min,C=x?.[p]?.max??E.max;if(typeof v!="number"||typeof C!="number"||!isFinite(v)||!isFinite(C))return;let y=(v+C)/2,L=l.getPixelForValue(y);t.save(),t.strokeStyle=i.contrastDim,t.lineWidth=this.CENTER_LINE_WIDTH,t.beginPath(),t.moveTo(L,a.top),t.lineTo(L,a.bottom),t.stroke(),t.restore(),t.save(),t.fillStyle=i.contrastDim,t.font=this.isPortrait()?`bold ${this.CENTER_LABEL_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.CENTER_LABEL_FONT_SIZE}px ${o.family}`,t.textAlign="center",t.textBaseline="top";let J=this.axisTopLabelY(l);t.fillText(g(y),L,J),t.restore();};h("x",p=>`${((p%360+360)%360).toFixed(0)}\xB0`),h("xSpeed",p=>`${p.toFixed(1)}`);let s=u?.xSpeed;if(s){let p=c,g=s,l=p?.xSpeed?.max??g.max;if(typeof l=="number"&&isFinite(l)){let x=s.getPixelForValue(l);t.save(),t.fillStyle=this.resolveTickColor(e,s,l),t.font=this.isPortrait()?`normal ${this.TICK_LABEL_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`normal ${this.TICK_LABEL_FONT_SIZE}px ${o.family}`,t.textAlign="right",t.textBaseline="top";let E=this.axisTopLabelY(s),v=this.xStepSpeed??1,C=Math.max(0,Math.min(3,Math.ceil(-Math.log10(v))));t.fillText(`${l.toFixed(C)}`,x-this.EDGE_SPEED_LABEL_OFFSET,E),t.restore(),t.save(),t.strokeStyle=i.contrastDim,t.lineWidth=this.GRID_LINE_WIDTH,t.beginPath();let y=Math.round(x)+.5;t.moveTo(y,a.bottom),t.lineTo(y,a.top-this.EDGE_EXTEND_UP_PX),t.stroke(),t.restore();}}let m=u?.x;if(m){let p=c,g=m,l=p?.x?.min??g.min;if(typeof l=="number"&&isFinite(l)){let x=m.getPixelForValue(l);t.save(),t.fillStyle=this.resolveTickColor(e,m,l),t.font=this.isPortrait()?`normal ${this.TICK_LABEL_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`normal ${this.TICK_LABEL_FONT_SIZE}px ${o.family}`,t.textAlign="left",t.textBaseline="top";let E=this.axisTopLabelY(m),v=this.normalizeAngle(l);t.fillText(`${v.toFixed(0)}\xB0`,x+this.EDGE_DIR_LABEL_OFFSET,E),t.restore();}}let _=e.data?.datasets,S=_?.[5]?.data,D=S?.length?S.length-1:-1,b=D>=0?S[D]?.x:void 0;if(typeof b=="number"&&isFinite(b)){t.save(),t.fillStyle=n.chartValue,t.font=this.isPortrait()?`bold ${this.SPEED_VALUE_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.SPEED_VALUE_FONT_SIZE}px ${o.family}`,t.textAlign="center",t.textBaseline="middle";let p=`${b.toFixed(1)}`,g=a.left+a.width/4,l=a.top-(this.isPortrait()?this.TOP_VALUE_PHONE_PORTRAIT_Y_OFFSET:this.TOP_VALUE_Y_OFFSET);t.fillText(p,g,l);let x=t.measureText(p),E=g+x.width/2+(this.isPortrait()?this.UNIT_PHONE_PORTRAIT_PADDING:this.UNIT_PADDING),v=a.top-(this.isPortrait()?this.TOP_UNIT_PHONE_PORTRAIT_Y_OFFSET:this.TOP_UNIT_Y_OFFSET);t.font=this.isPortrait()?`bold ${this.UNIT_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.UNIT_FONT_SIZE}px ${o.family}`,t.textAlign="left",t.fillText("kts",E,v),t.restore();}let F=_?.[0]?.data,N=F?.length?F.length-1:-1,T=N>=0?F[N]?.x:void 0;if(typeof T=="number"&&isFinite(T)){let p=this.normalizeAngle(T);t.save(),t.fillStyle=n.chartValue,t.font=this.isPortrait()?`bold ${this.SPEED_VALUE_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.SPEED_VALUE_FONT_SIZE}px ${o.family}`,t.textAlign="center",t.textBaseline="middle",t.fillText(`${p.toFixed(0)}\xB0`,a.left+3*a.width/4,a.top-(this.isPortrait()?this.TOP_VALUE_PHONE_PORTRAIT_Y_OFFSET:this.TOP_VALUE_Y_OFFSET)),t.restore();}if(!f){let p=Math.min(a.width*.7,420),g=90,l=a.left+(a.width-p)/2,x=a.top+(a.height-g)/2;t.save(),t.globalAlpha=.82,t.fillStyle=i.background,t.fillRect(l,x,p,g),t.restore(),t.save(),t.strokeStyle=i.contrastDim,t.lineWidth=2,t.strokeRect(l,x,p,g),t.restore(),t.save(),t.fillStyle=this.getThemeColors().chartLabel,t.textAlign="center",t.textBaseline="middle",t.font=`bold 18px ${o.family}`,t.fillText("Data acquisition...",l+p/2,x+g/2),t.restore();}}};constructor(){this.isPhonePortrait=Wp(this.responsive.observe(Em.HandsetPortrait),{initialValue:void 0}),Fa(()=>{let e=this.theme(),t=this.runtime?.options();!e||!t||ge(()=>{this.datasetConfig&&this.chart&&(this.setChartOptions(),this.setDatasetsColors(),this.ngZone.runOutsideAngular(()=>this.chart?.update("none")));});}),Fa(()=>{let e=this.runtime?.options();if(!e)return;!this.datasetConfig||this.datasetConfig.timeScaleFormat!==e.timeScale?(this.syncServiceDatasets(),this.startWidget()):this.chart&&this.setChartOptions();});}startWidget(){if(this.widgetDataChart()&&(this.datasetConfig=this._dataset.getDatasetConfig(`${this.id()}-twd`)??null,this.dataSourceInfo=this._dataset.getDataSourceInfo(`${this.id()}-twd`)??null,!!this.datasetConfig)){if(this.createDatasets(),this.setChartOptions(),this.chart)this.ngZone.runOutsideAngular(()=>this.chart?.update("none"));else {let e=this.widgetDataChart()?.nativeElement.getContext("2d");if(!e)return;this.chart=new Wl(e,{type:this.lineChartType,data:this.lineChartData,options:this.lineChartOptions,plugins:[this.gridBackgroundPlugin,this.centerTickPlugin]}),this.ngZone.runOutsideAngular(()=>this.chart?.update("none"));}this.startStreaming();}}syncServiceDatasets(){let e=this.runtime?.options();!e||e.timeScale===""||this.datasetLifecycle.syncWindTrendsDatasets(this.id(),e.timeScale);}setChartOptions(){let e=this.datasetConfig,t=this.dataSourceInfo;if(!e||!t)return;this.lineChartOptions.maintainAspectRatio=false,this.lineChartOptions.animation=false,this.lineChartOptions.indexAxis="y";let a=0,i=360,n=(i-a)/4,o=0,u=20,c=(u-o)/4;this.lineChartOptions.scales={y:{type:"linear",display:true,position:"right",reverse:true,title:{display:true,text:`${e.timeScaleFormat}`,align:"center"},ticks:{count:6,autoSkip:false,includeBounds:true,align:"inner",major:{enabled:true},font:this.isPortrait()?{size:12}:{size:16},callback:r=>{let d=Number(r),f=e.timeScaleFormat,h=this.getWindowMs(f);return f==="Last 5 Minutes"?`${Math.round(d/6e4)}'`:h>=10*6e4?`${Math.round(d/6e4)}'`:`${Math.round(d/1e3)}"`}},grid:{display:true,color:this.theme().contrastDimmer}},x:{type:"linear",position:"top",stack:"trends",beginAtZero:false,bounds:"ticks",min:a,max:i,title:{display:false},ticks:{count:5,align:"inner",autoSkip:false,includeBounds:true,stepSize:n,minRotation:0,maxRotation:0,callback:r=>{let d=Number(r),f=this.xCenter??Number.NaN;if(this.nearlyEqual(d,f))return "";let s=this.chart?.options?.scales?.x?.min;return typeof s=="number"&&this.nearlyEqual(d,s)?"":`${((d%360+360)%360).toFixed(0)}\xB0`},font:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenter??Number.NaN,h=this.nearlyEqual(d,f);return this.isPortrait()?{size:11,weight:h?"bold":"normal"}:{size:20,weight:h?"bold":"normal"}},color:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenter??Number.NaN;return this.nearlyEqual(d,f)?this.theme().contrast:void 0}},grid:{display:true,color:r=>{let d=r.tick?.value??Number.NaN,f=r.scale,h=this.chart?.options?.scales,s=f,m=h?.x?.min??s.min;return this.nearlyEqual(d,m)?"rgba(0,0,0,0)":this.theme().contrastDimmer},lineWidth:1}},xSpeed:{type:"linear",position:"top",stack:"trends",beginAtZero:false,bounds:"ticks",min:o,max:u,title:{display:false},ticks:{count:5,align:"inner",autoSkip:false,includeBounds:true,stepSize:c,minRotation:0,maxRotation:0,callback:r=>{let d=this.xCenterSpeed??Number.NaN;if(this.nearlyEqual(r,d))return "";let h=this.chart?.options?.scales?.xSpeed?.max;if(typeof h=="number"&&this.nearlyEqual(r,h))return "";let s=this.xStepSpeed??Number.NaN,m=Number.isFinite(s)?s:1,_=Math.max(0,Math.min(3,Math.ceil(-Math.log10(m))));return `${r.toFixed(_)}`},font:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenterSpeed??Number.NaN,h=this.nearlyEqual(d,f);return this.isPortrait()?{size:11,weight:h?"bold":"normal"}:{size:20,weight:h?"bold":"normal"}},color:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenterSpeed??Number.NaN;return this.nearlyEqual(d,f)?this.theme().contrast:void 0}},grid:{display:true,color:r=>{let d=r.tick?.value??Number.NaN,f=r.scale,h=this.chart?.options?.scales,s=f,m=h?.xSpeed?.max??s.max;return this.nearlyEqual(d,m)?"rgba(0,0,0,0)":this.theme().contrastDimmer},lineWidth:1}}},this.lineChartOptions.plugins={title:{display:true,align:"end",text:"TWD ",color:this.getThemeColors().chartLabel,padding:this.isPortrait()?{top:3,bottom:0}:{top:3,bottom:0},font:this.isPortrait()?{size:16,weight:"normal"}:{size:35,weight:"normal"}},subtitle:{display:true,align:"start",text:" TWS",color:this.getThemeColors().chartLabel,padding:this.isPortrait()?{top:-18,bottom:12}:{top:-41,bottom:12},font:this.isPortrait()?{size:16}:{size:35}},legend:{display:false},annotation:{annotations:{}},streaming:{duration:t.maxDataPoints*t.sampleTime,delay:t.sampleTime,frameRate:e.timeScaleFormat==="day"?5:e.timeScaleFormat==="hour"?8:e.timeScaleFormat==="minute"?15:30}},this.xCenter=(a+i)/2,this.xStep=n,this.xCenterSpeed=(o+u)/2,this.xStepSpeed=c;}createDatasets(){this.lineChartData.datasets=[],this.lineChartData.datasets.push({label:"Value",data:[],order:2,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:1,fill:false,xAxisID:"x"},{label:"SMA",data:[],order:0,parsing:false,normalized:true,tension:.3,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:10,fill:false,borderColor:e=>{let t=e.chart,{ctx:a}=t;return this.lineGradientForAxis(a,t,"x")??this.getThemeColors().averageLine},backgroundColor:"red",xAxisID:"x"},{label:"lastAverage",data:[],order:1,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:0,borderColor:"",fill:false,hidden:true,xAxisID:"x"},{label:"lastMinimum",data:[],order:3,parsing:false,normalized:true,hidden:true,xAxisID:"x"},{label:"lastMaximum",data:[],order:4,parsing:false,normalized:true,hidden:true,xAxisID:"x"},{label:"Value Speed",data:[],order:2,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:1,fill:false,xAxisID:"xSpeed"},{label:"SMA Speed",data:[],order:0,parsing:false,normalized:true,tension:.2,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:3,fill:false,borderColor:e=>{let t=e.chart,{ctx:a}=t;return this.lineGradientForAxis(a,t,"xSpeed")??this.getThemeColors().averageLine},xAxisID:"xSpeed"},{label:"lastAverage Speed",data:[],order:1,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:0,borderColor:"",fill:false,hidden:true,xAxisID:"xSpeed"},{label:"lastMinimum Speed",data:[],order:3,parsing:false,normalized:true,hidden:true,xAxisID:"xSpeed"},{label:"lastMaximum Speed",data:[],order:4,parsing:false,normalized:true,hidden:true,xAxisID:"xSpeed"}),this.setDatasetsColors();}startStreaming(){if(this._dsDirectionSub?.unsubscribe(),this._dsSpeedSub?.unsubscribe(),!this.chart||!this.dataSourceInfo)return;let e=this._dataset.getDatasetBatchThenLiveObservable(`${this.id()}-twd`),t=this._dataset.getDatasetBatchThenLiveObservable(`${this.id()}-tws`);!e||!t||(this._dsDirectionSub=e.subscribe(a=>{let i=this.chart,n=this.dataSourceInfo;if(!(!i||!n)){if(Array.isArray(a))this.pushRowsToDatasets(a);else {this.pushRowsToDatasets([a]);let o=i.data.datasets[0]?.data;if(Array.isArray(o)&&o.length>n.maxDataPoints)for(let u=0;u<=4;u++){let c=i.data.datasets[u]?.data;Array.isArray(c)&&c.shift();}}this.scheduleChartUpdate();}}),this._dsSpeedSub=t.subscribe(a=>{let i=this.chart,n=this.dataSourceInfo;if(!(!i||!n)){if(Array.isArray(a))this.pushRowsToSpeedDatasets(a);else {this.pushRowsToSpeedDatasets([a]);let o=i.data.datasets[5]?.data;if(Array.isArray(o)&&o.length>n.maxDataPoints)for(let u=5;u<=9;u++){let c=i.data.datasets[u]?.data;Array.isArray(c)&&c.shift();}}this.scheduleChartUpdate();}}));}unwrapAngles(e){if(e.length===0)return [];let t=[],a=null;for(let i of e){if(i==null){t.push(null);continue}if(a==null){t.push(i),a=i;continue}let n=i-a;n>180&&(n-=360),n<-180&&(n+=360),t.push(t[t.length-1]+n),a=i;}return t}pushRowsToDatasets(e){this.pushRowsGeneric(e,0,"deg",true);}pushRowsToSpeedDatasets(e){this.pushRowsGeneric(e,5,"knots",false);}getRowValue(e,t){switch(t){case "value":return e.data.value??null;case "sma":return e.data.sma??null;case "ema":return e.data.ema??null;case "dema":return e.data.doubleEma??null;case "avg":return e.data.lastAverage??null;case "min":return e.data.lastMinimum??null;case "max":return e.data.lastMaximum??null;default:return null}}transformRows(e,t,a,i){let n=e.map(u=>{let c=this.getRowValue(u,t);return c==null?null:this.unitsService.convertToUnit(a,c)}),o=i?this.unwrapAngles(n):n;return e.map((u,c)=>({x:o[c],y:u.timestamp,ts:u.timestamp}))}pushRowsGeneric(e,t,a,i){let n=this.chart;if(!n)return;["value","sma","avg","min","max"].forEach((u,c)=>{let r=n.data.datasets[t+c];!r||!Array.isArray(r.data)||r.data.push(...this.transformRows(e,u,a,i));});}normalizeAngle(e){return (e%360+360)%360}angularDiff(e,t){let a=(e-t+540)%360-180;return Math.abs(a)}niceStepFromMantissas(e,t){if(!isFinite(e)||e<=0)return 1;let a=Math.floor(Math.log10(e)),i=e/Math.pow(10,a);return (t.find(o=>i<=o)??t[t.length-1])*Math.pow(10,a)}scheduleChartUpdate(){this._chartUpdateRafId==null&&(this._chartUpdateRafId=requestAnimationFrame(()=>{this._chartUpdateRafId=null,!(!this.chart||!this.hasValidDatasets())&&(this.updateChartAfterDataChange(),this.ngZone.runOutsideAngular(()=>this.chart?.update("none")));}));}hasValidDatasets(){let e=this.chart?.data?.datasets;if(!Array.isArray(e)||e.length<10)return false;for(let t=0;t<10;t++){let a=e[t];if(!a||!Array.isArray(a.data))return false}return true}updateChartAfterDataChange(){let e=this.chart;if(!e)return;let t=e.data.datasets[2]?.data,a=e.data.datasets[1]?.data,i=e.data.datasets[0]?.data,n=!!t?.length,o=!!a?.length,u=!!i?.length,c=n?t[t.length-1].x:o?a[a.length-1].x:u?i[i.length-1].x:void 0;if(typeof c=="number"&&isFinite(c)){let h=e.data.datasets[3]?.data,s=e.data.datasets[4]?.data,m=h?.length?h[h.length-1].x:void 0,_=s?.length?s[s.length-1].x:void 0,S=typeof m=="number"&&isFinite(m)?this.angularDiff(c,m):Number.NaN,D=typeof _=="number"&&isFinite(_)?this.angularDiff(c,_):Number.NaN,b=Number.isFinite(S)||Number.isFinite(D)?Math.max(Number.isFinite(S)?S:0,Number.isFinite(D)?D:0):Number.NaN;if(!Number.isFinite(b)){let x=n?t:o?a:i,E=Math.min(30,x?.length??0);if(E>1){let C=x.slice(x.length-E).map(y=>y.x).filter(y=>typeof y=="number"&&isFinite(y));C.length&&(b=C.reduce((y,L)=>Math.max(y,this.angularDiff(c,L)),0));}}b=Math.max(b||0,15);let N=2*b/4,T=this.niceStepFromMantissas(N,[1,1.5,2,2.5,5,7.5,10]),p=c-2*T,g=c+2*T,l=e.options.scales;l.x&&(l.x.min=p,l.x.max=g,l.x.ticks=z(G({},l.x.ticks??{}),{stepSize:T})),this.xCenter=c,this.xStep=T;}let r=e.data.datasets[7]?.data;if(r&&r.length){let h=r.length-1,s=r[h]?.x??0,m=e.data.datasets[8].data[h]?.x??s,_=e.data.datasets[9].data[h]?.x??s,S=Math.abs(s-m),D=Math.abs(_-s),b=Math.max(S,D);b=Math.max(b,.5);let N=2*b/4,T=this.niceStepFromMantissas(N,[1,2,2.5,5,10]),p=s-2*T,g=s+2*T,l=e.options.scales;l.xSpeed&&(l.xSpeed.min=p,l.xSpeed.max=g,l.xSpeed.ticks=z(G({},l.xSpeed.ticks??{}),{stepSize:T})),this.xCenterSpeed=s,this.xStepSpeed=T;}let d=this.getWindowMs(this.datasetConfig?.timeScaleFormat);if(e.data.datasets[0].data.length>0){let h=Date.now();e.data.datasets.forEach(S=>{S.data.forEach(D=>{let b=D.ts??D.y;D.y=Math.max(0,Math.min(d,h-b));});});let s=e.options.scales;s.y&&(s.y.min=0,s.y.max=d);let m;switch(this.datasetConfig?.timeScaleFormat){case "Last Minute":m=15e3;break;case "Last 5 Minutes":m=6e4;break;case "Last 30 Minutes":m=5*6e4;break;default:m=d/5;break}if(s.y){let S=G({},s.y.ticks??{});delete S.count,S.stepSize=m,s.y.ticks=S;}}}getWindowMs(e){switch(e){case "Last 30 Minutes":return 30*6e4;case "Last 5 Minutes":return 5*6e4;case "Last Minute":return 6e4;default:return 6e4}}lineGradientForAxis(e,t,a){let i=t.chartArea;if(!i)return null;let n=t.scales?.[a];if(!n)return null;let o=t.options?.scales,u=n,c=o?.[a]?.min??u.min,r=o?.[a]?.max??u.max;if(typeof c!="number"||typeof r!="number"||!isFinite(c)||!isFinite(r))return null;let d=(c+r)/2,f=n.getPixelForValue(d),h=Math.max(0,Math.min(1,(f-i.left)/i.width)),s=e.createLinearGradient(i.left,0,i.right,0);return s.addColorStop(0,this.theme().port),s.addColorStop(h,this.theme().port),s.addColorStop(h,this.theme().starboard),s.addColorStop(1,this.theme().starboard),s}setDatasetsColors(){this.lineChartData.datasets.forEach(e=>{e.label==="Value"&&(e.borderColor=this.getThemeColors().valueLine,e.backgroundColor=this.getThemeColors().valueFill),e.label==="Value Speed"&&(e.borderColor=this.getThemeColors().valueLine,e.backgroundColor=this.getThemeColors().valueFill);});}getThemeColors(){let e=this.runtime?.options()?.color,t={valueLine:"",valueFill:"",averageLine:"",averageFill:"",averageChartLine:"",chartLabel:"",chartValue:""};switch(e){case "contrast":t.valueLine=this.theme().contrastDim,t.valueFill=this.theme().contrastDimmer,t.averageLine=this.theme().contrast,t.averageFill=this.theme().contrast,t.chartValue=this.theme().contrast,t.averageChartLine=this.theme().contrast,t.chartLabel=this.theme().contrastDim;break;case "blue":t.valueLine=this.theme().blueDim,t.valueFill=this.theme().blueDimmer,t.averageLine=this.theme().blue,t.averageFill=this.theme().blue,t.chartValue=this.theme().blue,t.averageChartLine=this.theme().blueDim,t.chartLabel=this.theme().blueDim;break;case "green":t.valueLine=this.theme().greenDim,t.valueFill=this.theme().greenDimmer,t.averageLine=this.theme().green,t.averageFill=this.theme().green,t.chartValue=this.theme().green,t.averageChartLine=this.theme().greenDim,t.chartLabel=this.theme().greenDim;break;case "pink":t.valueLine=this.theme().pinkDim,t.valueFill=this.theme().pinkDimmer,t.averageLine=this.theme().pink,t.averageFill=this.theme().pink,t.chartValue=this.theme().pink,t.averageChartLine=this.theme().pinkDim,t.chartLabel=this.theme().pinkDim;break;case "orange":t.valueLine=this.theme().orangeDim,t.valueFill=this.theme().orangeDimmer,t.averageLine=this.theme().orange,t.averageFill=this.theme().orange,t.chartValue=this.theme().orange,t.averageChartLine=this.theme().orangeDim,t.chartLabel=this.theme().orangeDim;break;case "purple":t.valueLine=this.theme().purpleDim,t.valueFill=this.theme().purpleDimmer,t.averageLine=this.theme().purple,t.averageFill=this.theme().purple,t.chartValue=this.theme().purple,t.averageChartLine=this.theme().purpleDim,t.chartLabel=this.theme().purpleDim;break;case "grey":t.valueLine=this.theme().greyDim,t.valueFill=this.theme().greyDimmer,t.averageLine=this.theme().grey,t.averageFill=this.theme().grey,t.chartValue=this.theme().grey,t.averageChartLine=this.theme().greyDim,t.chartLabel=this.theme().greyDim;break;case "yellow":t.valueLine=this.theme().yellowDim,t.valueFill=this.theme().yellowDimmer,t.averageLine=this.theme().yellow,t.averageFill=this.theme().yellow,t.chartValue=this.theme().yellow,t.averageChartLine=this.theme().yellowDim,t.chartLabel=this.theme().yellowDim;break}return t}nearlyEqual(e,t,a=1e-6){if(!Number.isFinite(e)||!Number.isFinite(t))return false;let i=Math.max(1,Math.max(Math.abs(e),Math.abs(t)));return Math.abs(e-t)<=a*i}resolveTickColor(e,t,a){let n=t.options.ticks?.color;return typeof n=="function"?n({chart:e,scale:t,tick:{value:a}})??Wl.defaults.color:typeof n=="string"?n:Wl.defaults.color}axisTopLabelY(e){return e.options?.position==="top"?e.top+4:e.bottom+2}ngOnDestroy(){this._dsDirectionSub?.unsubscribe(),this._dsSpeedSub?.unsubscribe(),this._chartUpdateRafId!=null&&(cancelAnimationFrame(this._chartUpdateRafId),this._chartUpdateRafId=null),this.chart?.destroy();let e=this.widgetDataChart?.()?.nativeElement;this.canvasService.releaseCanvas(e,{clear:true,removeFromDom:true});}static \u0275fac=function(t){return new(t||O)};static \u0275cmp=JD({type:O,selectors:[["widget-windtrends-chart"]],viewQuery:function(t,a){t&1&&eg(a.widgetDataChart,tt,5,Lr),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:0,consts:[["widgetDataChart",""],[2,"z-index","inherit"]],template:function(t,a){t&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%}"]})}return O})();export{mt as WidgetWindTrendsChartComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function p(r,i,s=false){let e=[],t=i-r,n=0,l=10;t=a(i-r,false),n=a(t/(l-1),true);let f=Math.floor(r/n)*n,o=Math.ceil(i/n)*n;e.push(f);let h=t/n;for(let c=0;c<h;c++)if(e[c]<o){let k=(Number(e[c].toFixed(2))*100+Number(n.toFixed(2))*100)/100;e.push(k);}if(e[e.length-1]!==o&&e.push(o),s){let c=[...e].reverse();return {min:f,max:o,majorTicks:c}}return {min:f,max:o,majorTicks:e}}function a(r,i){let s=Math.floor(Math.log10(r)),e=r/Math.pow(10,s),t=1;return i?1.5>e?t=1:3>e?t=2:7>e?t=5:t=10:1>=e?t=1:2>=e?t=2:5>=e?t=5:t=10,t*Math.pow(10,s)}export{p};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {w as w$1,dl as E,dm as G,N,aY as xe,bu as ut,dd as $e,$ as $j,W as Wp,v as vt,bG as Bj,D as Dt,F as Fa,dn as ge,a$ as Zr,dp as n,cw as z,cv as G$1,b0 as Wl,J as JD,dq as Ht,di as jt,de as Nt,df as Vt,dr as Ot,ds as bt,dt as nt,O as Op,o as eu,y as yt,b as wt,b2 as Ln,b5 as Pn,b9 as rn,P as Pi,T as TT,u as ul,bi as Eg,k as Qh,bk as cD,_ as _w,e as EE,aA as gg,B as Bh,bm as Ig,bo as lD,M as Mw,f as eg,K as Kw,g as qw,bp as gl,c as $h,bj as ST}from'./main-BAV5VDOD.js';import'./chunk-By8ZVvDx.js';var y={"widget-bms":{expansionMode:"bms-battery-tree",metricOrder:["soc","current"],metrics:{soc:{metric:"soc",axisId:"ySoc",pathSuffixes:[".capacity.stateOfCharge",".stateOfCharge"],transform:a=>a*100},current:{metric:"current",axisId:"yCurrent",pathSuffixes:[".current"],transform:a=>a}},axes:{ySoc:{axisId:"ySoc",position:"left",title:"SoC (%)",tickSuffix:"%",min:0,max:100},yCurrent:{axisId:"yCurrent",position:"right",title:"Current (A)",tickSuffix:"A",drawOnChartArea:false}},pathRules:[{metric:"soc",axisId:"ySoc",regex:/^electrical\.batteries\.([^.]+)\.(?:capacity\.)?stateOfCharge$/i},{metric:"current",axisId:"yCurrent",regex:/^electrical\.batteries\.([^.]+)\.current$/i}]},"widget-solar-charger":{expansionMode:"solar-tree",metricOrder:["panelPower","current"],metrics:{panelPower:{metric:"panelPower",axisId:"yPower",pathSuffixes:[".panelPower"],transform:a=>a/1e3},current:{metric:"current",axisId:"yCurrent",pathSuffixes:[".current"],transform:a=>a}},axes:{yPower:{axisId:"yPower",position:"left",title:"Power (kW)",tickSuffix:"kW"},yCurrent:{axisId:"yCurrent",position:"right",title:"Current (A)",tickSuffix:"A",drawOnChartArea:false}},pathRules:[{metric:"current",axisId:"yCurrent",regex:/^electrical\.solar\.([^.]+)\.current$/i},{metric:"panelPower",axisId:"yPower",regex:/^electrical\.solar\.([^.]+)\.panelPower$/i}]},"widget-charger":{expansionMode:"charger-tree",metricOrder:["voltage","current"],metrics:{voltage:{metric:"voltage",axisId:"yVoltage",pathSuffixes:[".voltage"],transform:a=>a},current:{metric:"current",axisId:"yCurrent",pathSuffixes:[".current"],transform:a=>a}},axes:{yVoltage:{axisId:"yVoltage",position:"left",title:"Voltage (V)",tickSuffix:"V"},yCurrent:{axisId:"yCurrent",position:"right",title:"Current (A)",tickSuffix:"A",drawOnChartArea:false}},pathRules:[{metric:"voltage",axisId:"yVoltage",regex:/^electrical\.chargers\.([^.]+)\.voltage$/i},{metric:"current",axisId:"yCurrent",regex:/^electrical\.chargers\.([^.]+)\.current$/i}]},"widget-inverter":{expansionMode:"inverter-tree",metricOrder:["voltage","current"],metrics:{voltage:{metric:"voltage",axisId:"yVoltage",pathSuffixes:[".voltage"],transform:a=>a},current:{metric:"current",axisId:"yCurrent",pathSuffixes:[".current"],transform:a=>a}},axes:{yVoltage:{axisId:"yVoltage",position:"left",title:"Voltage (V)",tickSuffix:"V"},yCurrent:{axisId:"yCurrent",position:"right",title:"Current (A)",tickSuffix:"A",drawOnChartArea:false}},pathRules:[{metric:"voltage",axisId:"yVoltage",regex:/^electrical\.inverters\.([^.]+)\.voltage$/i},{metric:"current",axisId:"yCurrent",regex:/^electrical\.inverters\.([^.]+)\.current$/i}]},"widget-alternator":{expansionMode:"alternator-tree",metricOrder:["voltage","current"],metrics:{voltage:{metric:"voltage",axisId:"yVoltage",pathSuffixes:[".voltage"],transform:a=>a},current:{metric:"current",axisId:"yCurrent",pathSuffixes:[".current"],transform:a=>a}},axes:{yVoltage:{axisId:"yVoltage",position:"left",title:"Voltage (V)",tickSuffix:"V"},yCurrent:{axisId:"yCurrent",position:"right",title:"Current (A)",tickSuffix:"A",drawOnChartArea:false}},pathRules:[{metric:"voltage",axisId:"yVoltage",regex:/^electrical\.alternators\.([^.]+)\.voltage$/i},{metric:"current",axisId:"yCurrent",regex:/^electrical\.alternators\.([^.]+)\.current$/i}]},"widget-ac":{expansionMode:"ac-tree",metricOrder:["voltage","current","frequency"],metrics:{voltage:{metric:"voltage",axisId:"yVoltage",pathSuffixes:[".line1.voltage",".line2.voltage",".line3.voltage"],transform:a=>a},current:{metric:"current",axisId:"yCurrent",pathSuffixes:[".line1.current",".line2.current",".line3.current"],transform:a=>a},frequency:{metric:"frequency",axisId:"yFrequency",pathSuffixes:[".line1.frequency",".line2.frequency",".line3.frequency"],transform:a=>a}},axes:{yVoltage:{axisId:"yVoltage",position:"left",title:"Voltage (V)",tickSuffix:"V"},yCurrent:{axisId:"yCurrent",position:"right",title:"Current (A)",tickSuffix:"A",drawOnChartArea:false},yFrequency:{axisId:"yFrequency",position:"left",title:"Frequency (Hz)",tickSuffix:"Hz",drawOnChartArea:false}},pathRules:[{metric:"voltage",axisId:"yVoltage",regex:/^electrical\.ac\.([^.]+)\.line[123]\.voltage$/i},{metric:"current",axisId:"yCurrent",regex:/^electrical\.ac\.([^.]+)\.line[123]\.current$/i},{metric:"frequency",axisId:"yFrequency",regex:/^electrical\.ac\.([^.]+)\.line[123]\.frequency$/i}]}},Ie={"bms-battery-tree":"widget-bms","solar-tree":"widget-solar-charger","charger-tree":"widget-charger","inverter-tree":"widget-inverter","alternator-tree":"widget-alternator","ac-tree":"widget-ac"};function Me(a){return !!a&&a in y}function D(a){return y[a]}function w(a){let l=Ie[a],e=y[l],t=[];return e.metricOrder.forEach(r=>{let i=e.metrics[r];i&&i.pathSuffixes.forEach(n=>{t.includes(n)||t.push(n);});}),t}function ve(a,l){let e=y[a.widgetType].metrics[a.metric];return e?e.transform(l):l}function P(a){let l=y[a],e=[];return l.metricOrder.forEach(t=>{let r=l.metrics[t]?.axisId;!r||e.includes(r)||e.push(r);}),e.map(t=>l.axes[t]).filter(t=>!!t)}function De(a,l){if(!Me(a))return null;let e=P(a),t=new Set(e.map(i=>i.axisId));return t.size===0?null:l.some(i=>!!i&&t.has(i))?a:null}function Se(a){for(let[l,e]of Object.entries(y))for(let t of e.pathRules){let r=t.regex.exec(a);if(r)return {widgetType:l,entityId:r[1],metric:t.metric,axisId:t.axisId}}return null}var Ae=["historyCanvas"];function we(a,l){a&1&&(Pi(0,"p",12),TT(1,"Loading historical data\u2026"),ul());}function Pe(a,l){if(a&1&&(Pi(0,"p",13),TT(1),ul()),a&2){let e=qw();EE(),gl("503: ",e.error());}}function Te(a,l){a&1&&(Pi(0,"p",12),TT(1,"No historical data is available for this widget. If you are not using the built-in KIP History API provider, validate your plugin configuration supports the widget's path and try again."),ul());}function _e(a,l){a&1&&(Pi(0,"div",14),$h(1,"canvas",null,0),ul());}var rt=(()=>{class a{historyApiClient=w$1(E);historyMapper=w$1(G);app=w$1(N);destroyRef=w$1(xe);units=w$1(ut);data=w$1($e);chartCanvas=$j("historyCanvas");theme=Wp(this.app.cssThemeColorRoles$,{requireSync:true});loading=vt(true);error=vt(null);datasetCount=vt(0);selectedPeriod=Bj("PT1H");hasNoData=Dt(()=>!this.loading()&&!this.error()&&this.datasetCount()===0);chart=null;viewReady=false;pendingDatasets=[];dualAxisDescriptorCache=new Map;constructor(){Fa(()=>{let e=this.chartCanvas(),t=this.loading(),r=this.datasetCount();!e||t||r<=0||ge(()=>{this.tryRenderChart();});});}loadHistoryDatasets(){return Zr(this,null,function*(){this.loading.set(true),this.error.set(null),this.dualAxisDescriptorCache.clear();try{let e=yield this.resolveQueryableSeriesDefinitions(),t=yield Promise.all(e.map((r,i)=>this.buildDatasetForSeries(r,i)));this.pendingDatasets=t.filter(r=>!!r),this.datasetCount.set(this.pendingDatasets.length),this.tryRenderChart();}catch(e){console.error("[WidgetHistoryChartDialogComponent] Failed to load widget history datasets:",e),this.error.set("Unable to load historical data for this widget."),this.pendingDatasets=[],this.datasetCount.set(0);}finally{this.loading.set(false),queueMicrotask(()=>{this.tryRenderChart();});}})}ngOnInit(){this.loadHistoryDatasets(),this.destroyRef.onDestroy(()=>{this.chart?.destroy(),this.chart=null;});}ngAfterViewInit(){this.onCanvasReady();}ngOnDestroy(){this.chart?.destroy(),this.chart=null;}onCanvasReady(){this.viewReady=true,this.tryRenderChart();}buildDatasetForSeries(e,t){return Zr(this,null,function*(){let r=e.path;if(!r)return null;let i=this.resolveDuration(e),n=this.resolveResolutionSeconds(i),o=this.buildHistoryRequestCandidates(r,e.context),s=this.describeDualAxisSeries(r),u=[],x=this.normalizeHistoryPath(r),T=this.resolveConvertUnitTo(r);for(let I of o){let k=yield this.historyApiClient.getValues({paths:I.paths,context:I.context,duration:i,resolution:n});if(!k?.data?.length)continue;if(u=this.historyMapper.mapValuesToChartDatapoints(k,{unit:"number",domain:"scalar"}).map(O=>{let m=O.data.value;return typeof m=="number"&&Number.isFinite(m)&&(s?m=ve(s,m):T&&(m=this.units.convertToUnit(T,m)??m)),{x:O.timestamp,y:m}}),u.length){x=I.labelPath;break}}if(!u.length)return null;let _=this.resolveSeriesColor(t,s),be=e.source?` (${e.source})`:"";return {label:`${x}${be}`,data:u,borderColor:_,backgroundColor:_,pointRadius:0,borderWidth:2,tension:.25,yAxisID:s?.axisId??"y",borderDash:this.isDualAxisDashedSeries(s)?[6,4]:void 0,fill:false}})}describeDualAxisSeries(e){let t=this.normalizeHistoryPath(e??"");if(!t.length)return null;if(this.dualAxisDescriptorCache.has(t))return this.dualAxisDescriptorCache.get(t)??null;let r=Se(t);return this.dualAxisDescriptorCache.set(t,r),r}resolveSeriesColor(e,t){let r=this.getSeriesPalette();return t?this.getDualAxisMetricColor(t.widgetType,t.metric):r[e%r.length]}getSeriesPalette(){let e=this.data.widget?.config?.color||"blue",t=this.resolveThemeColor(e),r=[this.theme().green,this.theme().orange,this.theme().pink,this.theme().purple,this.theme().yellow,this.theme().grey,this.theme().blue,this.theme().contrast],i=r.findIndex(n=>n?.toLowerCase()===t.toLowerCase());return i!==-1?r=[r[i],...r.slice(0,i),...r.slice(i+1)]:r=[t,...r],r}resolveThemeColor(e){let t=this.theme()[e];return typeof t=="string"&&t.length>0?t:e}isDualAxisDashedSeries(e){return e?this.getDualAxisEntityOrderIndex(e.entityId,e.widgetType)%2===1:false}getDualAxisEntityOrderIndex(e,t){let r=[];this.data.seriesDefinitions.forEach(n=>{let o=this.describeDualAxisSeries(n.path);!o||o.widgetType!==t||r.includes(o.entityId)||r.push(o.entityId);});let i=r.indexOf(e);return i>=0?i:0}getDualAxisMetricColor(e,t){let r=this.getSeriesPalette(),n=D(e).metricOrder.indexOf(t),o=n>=0?n:0;return r[o%r.length]}buildHistoryRequestCandidates(e,t){let r=this.normalizeHistoryPath(e),i=this.resolveHistoryContext(e,t),n=[r].filter(s=>s.length>0),o=[];return n.forEach(s=>{o.push({paths:`${s}:avg`,context:i,labelPath:this.normalizeHistoryPath(s)});}),o}resolveQueryableSeriesDefinitions(){return Zr(this,null,function*(){let e=[];for(let t of this.data.seriesDefinitions){let r=yield this.expandTemplateSeries(t);e.push(...r);}return this.sortExpandedSeries(e)})}sortExpandedSeries(e){return e.some(r=>this.describeDualAxisSeries(r.path)!==null)?[...e].sort((r,i)=>{let n=this.describeDualAxisSeries(r.path),o=this.describeDualAxisSeries(i.path);if(!n&&!o)return 0;if(!n)return 1;if(!o)return -1;if(n.entityId!==o.entityId)return n.entityId.localeCompare(o.entityId);let s=D(n.widgetType).metricOrder.indexOf(n.metric),u=D(o.widgetType).metricOrder.indexOf(o.metric);return s-u}):e}expandTemplateSeries(e){return Zr(this,null,function*(){let t=this.normalizeHistoryPath(e.path??""),r=t.endsWith(".*");if(!n(e)&&!r)return [e];let i=t.replace(/\.\*$/,"");if(!i.length)return [e];let n$1=this.resolveDuration(e),o=yield this.historyApiClient.getPaths({duration:n$1});if(!o?.length)return [e];let s=this.findConcreteTemplatePaths(e,i,o);return s.length===0?[e]:s.map((u,x)=>z(G$1({},e),{seriesId:`${e.seriesId}:resolved:${x}`,datasetUuid:`${e.datasetUuid}:resolved:${x}`,path:u,expansionMode:null,familyKey:null,allowedIds:null,trackedDevices:void 0}))})}findConcreteTemplatePaths(e,t,r){let i=Array.from(new Set(r.map(o=>this.normalizeHistoryPath(o)).filter(o=>o.startsWith(`${t}.`))));return i.length===0?[]:n(e)?i.filter(o=>this.matchesTemplateMetric(o,t,e)).filter(o=>this.matchesTemplateAllowedIds(o,t,e)):i}matchesTemplateMetric(e,t,r){let i=e.slice(t.length+1);return w(r.expansionMode).some(o=>i.endsWith(o))}matchesTemplateAllowedIds(e,t,r){let i=Array.isArray(r.allowedIds)?r.allowedIds.map(o=>String(o).trim()).filter(o=>o.length>0):[];if(i.length===0)return true;let n=this.extractEntityId(e,t,r);return !!n&&i.includes(n)}extractEntityId(e,t,r){let i=e.slice(t.length+1);if(!i.length)return null;let o=w(r.expansionMode).find(u=>i.endsWith(u));if(!o)return null;let s=i.slice(0,-o.length).replace(/\.$/,"").trim();return s.length?s:null}normalizeHistoryPath(e){let t=e.trim();return t.length?t.replace(/^(vessels\.)?self\./,""):""}resolveHistoryContext(e,t){let r=this.normalizeContext(t);if(r)return r;if(/^(vessels\.)?self\./.test(e))return "vessels.self"}tryRenderChart(){if(!this.viewReady)return;if(!this.pendingDatasets.length){this.chart?.destroy(),this.chart=null;return}let e=this.chartCanvas();if(!e)return;this.chart?.destroy();let t=this.getPrimaryAxisUnitLabel(),r={type:"line",data:{datasets:this.pendingDatasets},options:{responsive:true,maintainAspectRatio:false,parsing:false,interaction:{mode:"nearest",intersect:false,axis:"x"},scales:G$1({x:{type:"time",time:{tooltipFormat:"PPpp",displayFormats:{second:"HH:mm:ss",minute:"HH:mm",hour:"HH:mm",day:"MMM d",week:"MMM d",month:"MMM yyyy"},unit:"minute",minUnit:"second"},ticks:{color:this.theme().contrastDim},grid:{color:this.theme().contrastDimmer}}},this.buildYScales(t)),plugins:{legend:{labels:{color:this.theme().contrastDim,generateLabels:i=>this.buildLegendLabels(i)}},tooltip:{boxWidth:15,boxHeight:15,bodyFont:{size:14},multiKeyBackground:"rgba(0, 0, 0, 0)",callbacks:{labelColor:i=>{let n=this.getLegendItemForDataset(i.chart,i.datasetIndex),o=Array.isArray(n?.lineDash)&&n.lineDash.length>=2?[n.lineDash[0],n.lineDash[1]]:void 0;return {borderColor:n?.strokeStyle??this.theme().contrast,backgroundColor:"rgba(0, 0, 0, 0)",borderWidth:2,borderRadius:0,borderDash:o}}}}}}};this.chart=new Wl(e.nativeElement.getContext("2d"),r);}getPrimaryAxisUnitLabel(){let e=this.resolveConvertUnitTo();return this.getUnitsLabel(e)}getWidgetPathConfig(e,t){let r=e?.config?.paths;if(!(!r||Array.isArray(r)))return r[t]}resolveConvertUnitTo(e){let t=this.data.widget?.config;if(!t)return null;if(t.paths&&!Array.isArray(t.paths)){if(e)for(let n of Object.keys(t.paths)){let o=this.getWidgetPathConfig(this.data.widget,n);if(o?.path===e&&o.convertUnitTo)return o.convertUnitTo}let r=Object.keys(t.paths)[0],i=r?this.getWidgetPathConfig(this.data.widget,r):void 0;if(i?.convertUnitTo)return i.convertUnitTo}return t.convertUnitTo??null}buildYScales(e){let t=this.resolveDualAxisWidgetType();if(!t)return {y:{ticks:{color:this.theme().contrastDim},grid:{color:this.theme().contrastDimmer},title:{display:!!e,text:e?`${e}`:"",color:this.theme().contrastDim}}};let r=P(t),i={};return r.forEach(n=>{let o=this.resolvePrimaryMetricForAxis(t,n.axisId),s=o?this.getDualAxisMetricColor(t,o):this.theme().contrastDim;i[n.axisId]=z(G$1(G$1({type:"linear",position:n.position},n.min!=null?{min:n.min}:{}),n.max!=null?{max:n.max}:{}),{ticks:{color:this.theme().contrastDim,callback:u=>this.formatAxisTick(u,n.tickSuffix)},grid:G$1({color:this.theme().contrastDimmer},n.drawOnChartArea===false?{drawOnChartArea:false}:{}),title:{display:true,text:n.title,color:s}});}),i}resolvePrimaryMetricForAxis(e,t){let r=D(e);return r.metricOrder.find(n=>r.metrics[n]?.axisId===t)??null}formatAxisTick(e,t){return t==="%"?`${e}%`:`${e} ${t}`}buildLegendLabels(e){return Wl.defaults.plugins.legend.labels.generateLabels(e).map(t=>{let r=t.datasetIndex!=null?e.data.datasets[t.datasetIndex]:null,i=Array.isArray(r?.borderDash)?r.borderDash.filter(n=>typeof n=="number"):[];return z(G$1({},t),{fillStyle:"transparent",lineDash:i})})}getLegendItemForDataset(e,t){return this.buildLegendLabels(e).find(r=>r.datasetIndex===t)??null}resolveDualAxisWidgetType(){return De(this.data.widget?.type,this.pendingDatasets.map(e=>typeof e.yAxisID=="string"?e.yAxisID:null))}setPeriod(e){this.selectedPeriod.set(e),this.loadHistoryDatasets();}resolveDuration(e){return e.timeScale&&e.period&&Number.isFinite(e.period)?this.durationFromScaleAndPeriod(e.timeScale,e.period):this.selectedPeriod()}durationFromScaleAndPeriod(e,t){let r=Math.max(1,Math.round(t)),i=e.trim().toLowerCase(),n=i.match(/^last\s+(\d+)\s+([a-z]+)/i);if(n){let o=Number(n[1]),s=n[2];if(Number.isFinite(o)&&o>0)return this.durationFromToken(s,o)}return this.durationFromToken(i,r)}durationFromToken(e,t){let r=e.toLowerCase();return r.startsWith("second")?`PT${t}S`:r.startsWith("minute")?`PT${t}M`:r.startsWith("hour")?`PT${t}H`:r.startsWith("day")?`P${t}D`:r.startsWith("week")?`P${t*7}D`:r.startsWith("month")?`P${t}M`:"PT24H"}resolveResolutionSeconds(e){let t=this.parseDurationToSeconds(e);return !Number.isFinite(t)||t<=0?1:Math.max(1,Math.round(t/120))}parseDurationToSeconds(e){let r=/^P(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/i.exec(e.trim());if(!r)return NaN;let i=Number(r[1]??0),n=Number(r[2]??0),o=Number(r[3]??0),s=Number(r[4]??0);return i*86400+n*3600+o*60+s}normalizeContext(e){let t=typeof e=="string"?e.trim():"";return t.length?t:void 0}getUnitsLabel(e){if(!e)return "";switch(e){case "percent":case "percentraw":return "%";case "latitudeMin":return "latitude in minutes";case "latitudeSec":return "latitude in secondes";case "longitudeMin":return "longitude in minutes";case "longitudeSec":return "longitude in secondes";default:return e}}static \u0275fac=function(t){return new(t||a)};static \u0275cmp=JD({type:a,selectors:[["widget-history-chart-dialog"]],viewQuery:function(t,r){t&1&&eg(r.chartCanvas,Ae,5),t&2&&Kw();},inputs:{selectedPeriod:[1,"selectedPeriod"]},outputs:{selectedPeriod:"selectedPeriodChange"},decls:22,vars:4,consts:[["historyCanvas",""],[1,"dialogue-header"],["mat-dialog-title",""],["mat-icon-button","",1,"dialog-close-icon",3,"mat-dialog-close"],[1,"history-dialog-content"],[1,"time-select"],["hideSingleSelectionIndicator","true","aria-label","Chart Time Span Selection",3,"ngModelChange","ngModel"],["value","PT15M",3,"click"],["value","PT1H",3,"click"],["value","PT8H",3,"click"],["value","PT24H",3,"click"],[1,"chart-area"],[1,"history-message"],[1,"history-message","error"],[1,"chart-wrapper"]],template:function(t,r){t&1&&(Pi(0,"div",1)(1,"h5",2),TT(2),ul(),Pi(3,"button",3)(4,"mat-icon"),TT(5,"close"),ul()()(),Pi(6,"mat-dialog-content",4)(7,"div",5)(8,"mat-button-toggle-group",6),Eg("ngModelChange",function(n){return ST(r.selectedPeriod,n)||(r.selectedPeriod=n),n}),Pi(9,"mat-button-toggle",7),Qh("click",function(){return r.setPeriod("PT15M")}),TT(10,"15 Minutes"),ul(),Pi(11,"mat-button-toggle",8),Qh("click",function(){return r.setPeriod("PT1H")}),TT(12,"1 Hour"),ul(),Pi(13,"mat-button-toggle",9),Qh("click",function(){return r.setPeriod("PT8H")}),TT(14,"8 Hours"),ul(),Pi(15,"mat-button-toggle",10),Qh("click",function(){return r.setPeriod("PT24H")}),TT(16,"24 Hours"),ul()(),cD(),ul(),Pi(17,"div",11),_w(18,we,2,0,"p",12)(19,Pe,2,1,"p",13)(20,Te,2,0,"p",12)(21,_e,3,0,"div",14),ul()()),t&2&&(EE(2),gg(r.data.title),EE(),Bh("mat-dialog-close",false),EE(5),Ig("ngModel",r.selectedPeriod),lD(),EE(10),Mw(r.loading()?18:r.error()?19:r.hasNoData()?20:21));},dependencies:[Ht,jt,Nt,Vt,Ot,bt,nt,Op,eu,yt,wt,Ln,Pn,rn],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%}.dialogue-header[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:baseline}.dialog-close-icon[_ngcontent-%COMP%]{margin-right:15px}mat-dialog-content.history-dialog-content[_ngcontent-%COMP%]{padding:0 24px 20px;display:flex;flex-direction:column;width:100%;height:100%;min-width:70vw;min-height:55vh;justify-content:flex-start;align-items:stretch}.time-select[_ngcontent-%COMP%]{flex-grow:0;text-align:center;width:100%}.chart-area[_ngcontent-%COMP%], .chart-wrapper[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex:1 1 0;min-height:0;width:100%}.chart-wrapper[_ngcontent-%COMP%] canvas[_ngcontent-%COMP%]{flex:1 1 0;min-height:0}.history-message[_ngcontent-%COMP%]{margin:0;padding:1rem 0}.error[_ngcontent-%COMP%]{color:var(--mat-sys-error)}"]})}return a})();export{rt as WidgetHistoryChartDialogComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {d1 as Hj,w,du as p,dv as rt,$ as $j,aZ as F,v as vt,D as Dt,F as Fa,dn as ge,dS as Da,J as JD,cp as Uh,f as eg,K as Kw}from'./main-BAV5VDOD.js';import {c}from'./chunk-Dxlia2NE.js';var x=["canvasMainRef"],R=(()=>{class s{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);static DEFAULT_CONFIG={displayName:"Time Label",filterSelfPaths:true,paths:{gaugePath:{description:"Date / Time",path:null,source:null,pathType:"Date",isPathConfigurable:true,sampleTime:1e3}},dateFormat:"dd/MM/yyyy HH:mm:ss",dateTimezone:"Atlantic/Azores",color:"contrast",enableTimeout:false,dataTimeout:5};canvasMainRef=$j.required("canvasMainRef");canvasElement;canvasCtx=null;titleBitmap=null;titleBitmapText=null;titleBitmapColor=null;canvas=w(F);cssWidth=0;cssHeight=0;dataValue=vt(null);_timeZoneGTM="";isDestroyed=false;labelColor=vt("");valueColor="";maxTextWidth=0;maxTextHeight=0;displayName=Dt(()=>this.runtime.options()?.displayName??"Time Label");dateFormat=Dt(()=>this.runtime.options()?.dateFormat??"dd/MM/yyyy HH:mm:ss");dateTimezone=Dt(()=>this.runtime.options()?.dateTimezone??"System Timezone -");constructor(){Fa(()=>{let e=this.runtime.options(),t=this.theme();!e||!t||ge(()=>{this.applyColors(),e.paths?.gaugePath?.path&&(this._timeZoneGTM=this.getGMTOffset(this.dateTimezone()),this.streams.observe("gaugePath",a=>{this.dataValue.set(a?.data?.value??null),this.drawWidget();}));});}),Fa(()=>{let e=this.theme(),t=this.runtime.options();!e||!t||ge(()=>{this.applyColors(),this.drawWidget();});});}ngAfterViewInit(){this.canvasElement=this.canvasMainRef().nativeElement,this.canvasCtx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(e,t)=>{this.cssWidth=e,this.cssHeight=t,this.maxTextWidth=Math.floor(this.cssWidth*.85),this.maxTextHeight=Math.floor(this.cssHeight*.7),this.drawWidget();}}),!this.isDestroyed&&(this.cssHeight=Math.floor(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.floor(this.canvasElement.getBoundingClientRect().width),this.maxTextWidth=Math.floor(this.canvasElement.width*.85),this.maxTextHeight=Math.floor(this.canvasElement.height*.7),this.applyColors(),this.drawWidget());}getGMTOffset(e){try{if(e==="System Timezone -")return "";let a=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"short"}).formatToParts(new Date).find(M=>M.type==="timeZoneName");return a?a.value:"GMT"}catch(t){return console.error(`Error getting GMT offset for timezone "${e}":`,t),"GMT"}}applyColors(){let e=this.runtime.options(),t=this.theme();!e||!t||(this.labelColor.set(c(e.color??"contrast",t).dim),this.valueColor=c(e.color??"contrast",t).color);}ngOnDestroy(){this.isDestroyed=true;try{this.canvas.unregisterCanvas(this.canvasElement);}catch(e){}}drawWidget(){if(!this.canvasCtx)return;let e=this.labelColor();(!this.titleBitmap||this.titleBitmap.width!==this.canvasElement.width||this.titleBitmap.height!==this.canvasElement.height||this.titleBitmapText!==`${this.displayName()}-${this.runtime.options()?.color??"contrast"}`||this.titleBitmapColor!==e)&&(this.titleBitmap=this.canvas.createTitleBitmap(this.displayName(),e,"normal",this.cssWidth,this.cssHeight),this.titleBitmapText=`${this.displayName()}-${this.runtime.options()?.color??"contrast"}`,this.titleBitmapColor=e),this.canvas.clearCanvas(this.canvasCtx,this.cssWidth,this.cssHeight),this.titleBitmap&&this.titleBitmap.width>0&&this.titleBitmap.height>0&&this.canvasCtx.drawImage(this.titleBitmap,0,0,this.cssWidth,this.cssHeight);let t,i=this.dataValue();if(!i||isNaN(Date.parse(i)))t="--";else try{t=Da(i,this.dateFormat(),"en-US",this._timeZoneGTM);}catch(a){t=String(a),console.log("[Date Time Widget]: "+String(a));}this.canvas.drawText(this.canvasCtx,t,Math.floor(this.cssWidth/2),Math.floor(this.cssHeight/2*1.15),this.maxTextWidth,this.maxTextHeight,"bold",this.valueColor);}static \u0275fac=function(t){return new(t||s)};static \u0275cmp=JD({type:s,selectors:[["widget-datetime"]],viewQuery:function(t,i){t&1&&eg(i.canvasMainRef,x,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:0,consts:[["canvasMainRef",""],[1,"date-canvas"]],template:function(t,i){t&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%;overflow:hidden}.date-canvas[_ngcontent-%COMP%]{width:100%!important;height:100%!important;min-height:1px;display:block}"]})}return s})();export{R as WidgetDatetimeComponent};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {f}from'./chunk-H9_eqTYx.js';import {u}from'./chunk-hd2_AKwt.js';import {d1 as Hj,w,du as p,dv as rt,a as G,cu as T,aR as lt$1,aZ as F,v as vt,D as Dt,aH as j,F as Fa,dn as ge$1,cw as z,cv as G$1,J as JD,dC as x,dT as wg,_ as _w,P as Pi,k as Qh,X as xw,cs as Sw,u as ul,dU as NT,e as EE,M as Mw,t as pT,Y as Aw,dV as Vj,cn as wd,ci as dl,dW as Zh,cp as Uh,cj as fl,cV as Td,T as TT,an as Hh,d as ig,bp as gl,bs as dp,c as $h,g as qw,dX as xT,B as Bh,cS as pl,cT as hl,h as Fw,l as ud,m as dd}from'./main-BAV5VDOD.js';import {c}from'./chunk-Dxlia2NE.js';function ye(i){return Math.max(i,1)/35}function v(i,u,o){let e=Math.max(u,0),t=ye(o),n=i==="2"?0:48*t,l=i==="2"?12*t:6*t,d=i==="2"?12*t:n,C=Math.max(0,e-d-l);return {labelX:d,labelWidth:C,labelFontSize:14*t,shapeLaneWidth:n,switchTrackX:6*t,switchTrackY:6*t,switchTrackWidth:37.714306*t,switchTrackHeight:22*t,switchTrackRadius:11*t,switchKnobOffX:17.5*t,switchKnobOnX:32.5*t,switchKnobY:17*t,switchKnobRadius:10*t,switchStrokeWidth:1.5*t,lightCenterX:24.5*t,lightCenterY:17.5*t,lightRadius:13.5*t,lightStrokeWidth:3*t,buttonX:6*t,buttonY:5*t,buttonWidth:Math.max(0,e-12*t),buttonHeight:25.025183*t,buttonRadius:3.6672263*t}}function ge(i,u,o,e){if(o.length===0)return 0;let t=Math.max(1,Math.floor(u/o.length)),n=1,l=t,d=1;for(;n<=l;){let C=Math.floor((n+l)/2);if(o.every(w=>{let L=v(w.type,i,C);return e(w.ctrlLabel??"",L.labelFontSize)<=L.labelWidth})){d=C,n=C+1;continue}l=C-1;}return Math.min(d,t)}var fe=(()=>{class i{data=Hj(null,{alias:"controlData"});theme=Hj(null);dimensions=Hj.required();toggleClick=Vj();ctrlState=null;ctrlColor="";oldTheme=null;offColor=null;labelColor=null;valueColor=null;constructor(){}ngDoCheck(){let o=this.data();if(!o)return;o.value!=this.ctrlState&&(this.ctrlState=o.value),o.color!=this.ctrlColor&&(this.ctrlColor=o.color,this.getColors(o.color));let e=this.theme();this.oldTheme!=e&&(this.oldTheme=e,this.getColors(o.color));}toggle(o){let e=this.data();e&&(e.value=o,this.toggleClick.emit(e));}get layout(){let o=this.dimensions();return v("3",o.width,o.height)}get isEnabled(){return !!this.ctrlState}getColors(o){let e=this.theme();if(e)switch(o){case "contrast":this.offColor=e.contrastDimmer,this.labelColor=e.contrastDim,this.valueColor=e.contrast;break;case "blue":this.offColor=e.blueDimmer,this.labelColor=e.blueDim,this.valueColor=e.blue;break;case "green":this.offColor=e.greenDimmer,this.labelColor=e.greenDim,this.valueColor=e.green;break;case "pink":this.offColor=e.pinkDimmer,this.labelColor=e.pinkDim,this.valueColor=e.pink;break;case "orange":this.offColor=e.orangeDimmer,this.labelColor=e.orangeDim,this.valueColor=e.orange;break;case "purple":this.offColor=e.purpleDimmer,this.labelColor=e.purpleDim,this.valueColor=e.purple;break;case "grey":this.offColor=e.greyDimmer,this.labelColor=e.greyDim,this.valueColor=e.grey;break;case "yellow":this.offColor=e.yellowDimmer,this.labelColor=e.yellowDim,this.valueColor=e.yellow;break;default:this.offColor=e.contrastDimmer,this.labelColor=e.contrastDim,this.valueColor=e.contrast;break}}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=JD({type:i,selectors:[["app-svg-boolean-light"]],inputs:{data:[1,"controlData","data"],theme:[1,"theme"],dimensions:[1,"dimensions"]},outputs:{toggleClick:"toggleClick"},decls:21,vars:33,consts:[["version","1.1","id","svg9","xmlns","http://www.w3.org/2000/svg",0,"xmlns","svg","http://www.w3.org/2000/svg"],["id","defs1"],["id","lightSpecular","cx","36%","cy","32%","r","68%"],["offset","0","stop-color","#ffffff","stop-opacity","0.5"],["offset","0.55","stop-color","#ffffff","stop-opacity","0.16"],["offset","1","stop-color","#ffffff","stop-opacity","0"],["id","lightDepth","cx","68%","cy","70%","r","68%"],["offset","0","stop-color","#000000","stop-opacity","0"],["offset","0.62","stop-color","#000000","stop-opacity","0.05"],["offset","1","stop-color","#000000","stop-opacity","0.22"],["id","lightRim","x1","0","y1","0","x2","1","y2","1"],["offset","0","stop-color","#ffffff","stop-opacity","0.36"],["offset","0.45","stop-color","#ffffff","stop-opacity","0.09"],["offset","1","stop-color","#000000","stop-opacity","0.3"],["y","0"],["xmlns","http://www.w3.org/1999/xhtml",2,"width","100%","height","100%","display","flex","align-items","center","justify-content","flex-start","font-family","Roboto,sans-serif","font-weight","700","line-height","1","white-space","nowrap","overflow","hidden","text-overflow","clip"],[2,"stroke","url(#lightRim)","stroke-opacity","0.4","stroke-dasharray","none"],["fill","url(#lightSpecular)"],["fill","url(#lightDepth)"],["fill","#ffffff"]],template:function(e,t){e&1&&(wd(),dl(0,"svg",0)(1,"defs",1)(2,"radialGradient",2),Uh(3,"stop",3)(4,"stop",4)(5,"stop",5),fl(),dl(6,"radialGradient",6),Uh(7,"stop",7)(8,"stop",8)(9,"stop",9),fl(),dl(10,"linearGradient",10),Uh(11,"stop",11)(12,"stop",12)(13,"stop",13),fl()(),dl(14,"foreignObject",14),Td(),dl(15,"div",15),TT(16),fl()(),wd(),Uh(17,"circle",16)(18,"circle",17)(19,"circle",18)(20,"ellipse",19),fl()),e&2&&(Hh("height",t.dimensions().height)("width",t.dimensions().width)("viewBox","0 0 "+t.dimensions().width+" "+t.dimensions().height),EE(14),Hh("x",t.layout.labelX)("width",t.layout.labelWidth)("height",t.dimensions().height),EE(),ig("color",t.isEnabled?t.valueColor:t.labelColor)("opacity",t.isEnabled?1:.6)("font-size",t.layout.labelFontSize,"px")("text-shadow",t.isEnabled?"0 0 4px currentColor, 0 0 4px currentColor":"none"),EE(),gl(" ",t.data()?.ctrlLabel," "),EE(),Hh("cx",t.layout.lightCenterX)("cy",t.layout.lightCenterY)("r",t.layout.lightRadius)("fill",t.isEnabled?t.valueColor:t.offColor)("stroke-width",t.layout.lightStrokeWidth),EE(),Hh("cx",t.layout.lightCenterX)("cy",t.layout.lightCenterY)("r",t.layout.lightRadius)("opacity",t.isEnabled?.62:.42),EE(),Hh("cx",t.layout.lightCenterX)("cy",t.layout.lightCenterY)("r",t.layout.lightRadius)("opacity",t.isEnabled?.62:.48),EE(),Hh("cx",t.layout.lightCenterX-t.layout.lightRadius*.32)("cy",t.layout.lightCenterY-t.layout.lightRadius*.34)("rx",t.layout.lightRadius*.34)("ry",t.layout.lightRadius*.2)("opacity",t.isEnabled?.2:.12));},encapsulation:2})}return i})();var Ce=(()=>{class i{data=Hj(null,{alias:"controlData"});theme=Hj(null);dimensions=Hj.required();toggleClick=Vj();oldTheme=null;emitIntervalId=null;pressed=false;isSwiping=false;pointerStartX=0;pointerStartY=0;labelColorEnabled=null;labelColorDisabled=null;valueColor=null;ctrlColor="";ngDoCheck(){let o=this.data();if(!o)return;o.color!=this.ctrlColor&&(this.ctrlColor=o.color,this.getColors(o.color));let e=this.theme();this.oldTheme!=e&&(this.oldTheme=e,this.getColors(o.color));}handleClickDown(o){let e=this.data();if(!e)return;this.isSwiping=false,this.pointerStartX=o.clientX,this.pointerStartY=o.clientY,this.clearTimers(),this.pressed=true;let t=dp(e);t.value=this.pressed,this.toggleClick.emit(t),this.emitIntervalId=setInterval(()=>{this.toggleClick.emit(t);},100);}handlePointerMove(o){let e=Math.abs(o.clientX-this.pointerStartX),t=Math.abs(o.clientY-this.pointerStartY);(e>30||t>30)&&(this.isSwiping=true,this.pressed=false,this.clearTimers());}handleClickUp(){this.isSwiping&&(this.isSwiping=false),this.pressed=false,this.clearTimers();}handlePointerCancel(){this.isSwiping=false,this.pressed=false,this.clearTimers();}get layout(){let o=this.dimensions();return v("2",o.width,o.height)}get isPressed(){return this.pressed}getColors(o){let e=this.theme();if(e)switch(o){case "contrast":this.labelColorEnabled="black",this.labelColorDisabled=e.contrastDim,this.valueColor=e.contrast;break;case "blue":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.blueDim,this.valueColor=e.blue;break;case "green":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.greenDim,this.valueColor=e.green;break;case "pink":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.pinkDim,this.valueColor=e.pink;break;case "orange":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.orangeDim,this.valueColor=e.orange;break;case "purple":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.purpleDim,this.valueColor=e.purple;break;case "grey":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.greyDim,this.valueColor=e.grey;break;case "yellow":this.labelColorEnabled=e.contrast,this.labelColorDisabled=e.yellowDim,this.valueColor=e.yellow;break;default:this.labelColorEnabled="black",this.labelColorDisabled=e.contrastDim,this.valueColor=e.contrast;break}}clearTimers(){this.emitIntervalId&&(clearInterval(this.emitIntervalId),this.emitIntervalId=null);}ngOnDestroy(){this.clearTimers();}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=JD({type:i,selectors:[["app-svg-boolean-button"]],inputs:{data:[1,"controlData","data"],theme:[1,"theme"],dimensions:[1,"dimensions"]},outputs:{toggleClick:"toggleClick"},decls:6,vars:19,consts:[["version","1.1","id","svg9","xmlns","http://www.w3.org/2000/svg",0,"xmlns","svg","http://www.w3.org/2000/svg",3,"pointerup","pointerleave","pointerdown","pointermove","pointercancel"],["x","0","y","0","pointer-events","all",2,"display","inline","opacity","1","fill","transparent","fill-opacity","1","stroke","none","stroke-width","0"],[2,"display","inline","mix-blend-mode","normal","stroke","black","stroke-width","1.5","stroke-opacity","0.2"],["y","0",2,"pointer-events","none"],["xmlns","http://www.w3.org/1999/xhtml",2,"width","100%","height","100%","display","flex","align-items","center","justify-content","center","font-family","Roboto,sans-serif","font-weight","700","line-height","1","white-space","nowrap","overflow","hidden","text-overflow","clip"]],template:function(e,t){e&1&&(wd(),dl(0,"svg",0),Zh("pointerup",function(){return t.handleClickUp()})("pointerleave",function(){return t.handleClickUp()})("pointerdown",function(l){return t.handleClickDown(l)})("pointermove",function(l){return t.handlePointerMove(l)})("pointercancel",function(){return t.handlePointerCancel()}),Uh(1,"rect",1)(2,"rect",2),dl(3,"foreignObject",3),Td(),dl(4,"div",4),TT(5),fl()()()),e&2&&(Hh("height",t.dimensions().height)("width",t.dimensions().width)("viewBox","0 0 "+t.dimensions().width+" "+t.dimensions().height),EE(),Hh("width",t.dimensions().width)("height",t.dimensions().height),EE(),Hh("x",t.layout.buttonX)("y",t.layout.buttonY)("width",t.layout.buttonWidth)("height",t.layout.buttonHeight)("rx",t.layout.buttonRadius)("fill",t.isPressed?t.valueColor:t.labelColorDisabled),EE(),Hh("x",t.layout.labelX)("width",t.layout.labelWidth)("height",t.dimensions().height),EE(),ig("color",t.isPressed?t.labelColorEnabled:t.labelColorDisabled)("font-size",t.layout.labelFontSize,"px"),EE(),gl(" ",t.data()?.ctrlLabel," "));},encapsulation:2})}return i})();var be=(()=>{class i{data=Hj(null,{alias:"controlData"});theme=Hj(null);dimensions=Hj.required();toggleClick=Vj();ctrlState=null;oldTheme=null;swipeGuard=f();offColor=null;labelColor=null;valueColor=null;ctrlColor="";constructor(){}ngDoCheck(){let o=this.data();if(!o)return;o.value!=this.ctrlState&&(this.ctrlState=o.value),o.color!=this.ctrlColor&&(this.ctrlColor=o.color,this.getColors(o.color));let e=this.theme();this.oldTheme!=e&&(this.oldTheme=e,this.getColors(o.color));}onPointerDown(o){this.swipeGuard.onPointerDown(o);}onPointerMove(o){this.swipeGuard.onPointerMove(o);}onPointerUp(o,e){this.swipeGuard.onPointerUp(o)&&this.toggle(e);}onPointerCancel(o){this.swipeGuard.onPointerCancel(o);}get layout(){let o=this.dimensions();return v("1",o.width,o.height)}get isEnabled(){return !!this.ctrlState}get nextState(){return !this.isEnabled}toggle(o){let e=this.data();e&&(e.value=o,this.toggleClick.emit(e));}getColors(o){let e=this.theme();if(e)switch(o){case "contrast":this.offColor=e.contrastDimmer,this.labelColor=e.contrastDim,this.valueColor=e.contrast;break;case "blue":this.offColor=e.blueDimmer,this.labelColor=e.blueDim,this.valueColor=e.blue;break;case "green":this.offColor=e.greenDimmer,this.labelColor=e.greenDim,this.valueColor=e.green;break;case "pink":this.offColor=e.pinkDimmer,this.labelColor=e.pinkDim,this.valueColor=e.pink;break;case "orange":this.offColor=e.orangeDimmer,this.labelColor=e.orangeDim,this.valueColor=e.orange;break;case "purple":this.offColor=e.purpleDimmer,this.labelColor=e.purpleDim,this.valueColor=e.purple;break;case "grey":this.offColor=e.greyDimmer,this.labelColor=e.greyDim,this.valueColor=e.grey;break;case "yellow":this.offColor=e.yellowDimmer,this.labelColor=e.yellowDim,this.valueColor=e.yellow;break;default:this.offColor=e.contrastDimmer,this.labelColor=e.contrastDim,this.valueColor=e.contrast;break}}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=JD({type:i,selectors:[["app-svg-boolean-switch"]],inputs:{data:[1,"controlData","data"],theme:[1,"theme"],dimensions:[1,"dimensions"]},outputs:{toggleClick:"toggleClick"},decls:12,vars:28,consts:[["version","1.1","id","svg9","xmlns","http://www.w3.org/2000/svg",0,"xmlns","svg","http://www.w3.org/2000/svg",3,"pointerdown","pointermove","pointerup","pointercancel"],["id","defs1"],["id","linearGradient32"],["offset","0",2,"stop-color","#000000","stop-opacity","0.88486844"],["offset","1",2,"stop-color","#f7f7f7","stop-opacity","0.17763157"],[0,"xlink","href","#linearGradient32","id","linearGradient33","x1","0","y1","0","x2","1","y2","1"],["x","0","y","0","pointer-events","all",2,"display","inline","opacity","0.001","fill","black","fill-opacity","0.001","stroke","none","stroke-width","0"],["y","0",2,"pointer-events","none"],[2,"width","100%","height","100%","display","flex","align-items","center","justify-content","flex-start","font-family","Roboto,sans-serif","font-weight","700","line-height","1","white-space","nowrap","overflow","hidden","text-overflow","clip"],[2,"stroke-width","1.5","stroke","black","stroke-opacity","0.12"],[2,"stroke","url(#linearGradient33)","stroke-opacity","0.4","stroke-dasharray","none"]],template:function(e,t){e&1&&(wd(),dl(0,"svg",0),Zh("pointerdown",function(l){return t.onPointerDown(l)})("pointermove",function(l){return t.onPointerMove(l)})("pointerup",function(l){return t.onPointerUp(l,t.nextState)})("pointercancel",function(l){return t.onPointerCancel(l)}),dl(1,"defs",1)(2,"linearGradient",2),Uh(3,"stop",3)(4,"stop",4),fl(),Uh(5,"linearGradient",5),fl(),Uh(6,"rect",6),dl(7,"foreignObject",7),Td(),dl(8,"div",8),TT(9),fl()(),wd(),Uh(10,"rect",9)(11,"circle",10),fl()),e&2&&(Hh("height",t.dimensions().height)("width",t.dimensions().width)("viewBox","0 0 "+t.dimensions().width+" "+t.dimensions().height),EE(6),Hh("width",t.dimensions().width)("height",t.dimensions().height),EE(),Hh("x",t.layout.labelX)("width",t.layout.labelWidth)("height",t.dimensions().height),EE(),ig("color",t.isEnabled?t.valueColor:t.labelColor)("opacity",t.isEnabled?1:.6)("font-size",t.layout.labelFontSize,"px")("text-shadow",t.isEnabled?"0 0 4px currentColor, 0 0 4px currentColor":"none"),EE(),gl(" ",t.data()?.ctrlLabel," "),EE(),Hh("x",t.layout.switchTrackX)("y",t.layout.switchTrackY)("width",t.layout.switchTrackWidth)("height",t.layout.switchTrackHeight)("rx",t.layout.switchTrackRadius)("fill",t.isEnabled?t.labelColor:t.offColor),EE(),Hh("cx",t.isEnabled?t.layout.switchKnobOnX:t.layout.switchKnobOffX)("cy",t.layout.switchKnobY)("r",t.layout.switchKnobRadius)("fill",t.isEnabled?t.valueColor:t.offColor)("stroke-width",t.layout.switchStrokeWidth));},encapsulation:2})}return i})();function _e(i,u){if(i&1&&$h(0,"widget-title",1),i&2){let o=qw(),e=xT(0);Bh("text",(e==null?null:e.displayName)??"")("color",o.labelColor());}}function De(i,u){if(i&1){let o=Fw();Pi(0,"app-svg-boolean-switch",5),Qh("toggleClick",function(t){ud(o);let n=qw(2);return dd(n.toggle(t))}),ul();}if(i&2){let o=qw().$implicit,e=qw();Bh("controlData",o)("theme",e.theme())("dimensions",e.ctrlDimensions);}}function Se(i,u){if(i&1){let o=Fw();Pi(0,"app-svg-boolean-button",5),Qh("toggleClick",function(t){ud(o);let n=qw(2);return dd(n.toggle(t))}),ul();}if(i&2){let o=qw().$implicit,e=qw();Bh("controlData",o)("theme",e.theme())("dimensions",e.ctrlDimensions);}}function ke(i,u){if(i&1){let o=Fw();Pi(0,"app-svg-boolean-light",5),Qh("toggleClick",function(t){ud(o);let n=qw(2);return dd(n.toggle(t))}),ul();}if(i&2){let o=qw().$implicit,e=qw();Bh("controlData",o)("theme",e.theme())("dimensions",e.ctrlDimensions);}}function Ee(i,u){if(i&1&&(pl(0),_w(1,De,1,3,"app-svg-boolean-switch",4)(2,Se,1,3,"app-svg-boolean-button",4)(3,ke,1,3,"app-svg-boolean-light",4),hl()),i&2){let o,e=u.$implicit;EE(),Mw((o=e.type)==="1"?1:o==="2"?2:o==="3"?3:-1);}}function Te(i,u){i&1&&$h(0,"div",3);}var lt=(()=>{class i{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={displayName:"Switch Panel Label",showLabel:true,filterSelfPaths:true,paths:[],enableTimeout:false,dataTimeout:5,color:"contrast",zonesOnlyPaths:false,putEnable:true,putMomentary:false,multiChildCtrls:[]};runtime=w(p,{optional:true});streams=w(rt,{optional:true});dashboard=w(G);signalkRequestsService=w(T);toast=w(lt$1);canvas=w(F);switchControls=vt([]);labelColor=vt("");noTitleClass=Dt(()=>this.runtime?.options()?.showLabel===false?"widgets-container-no-title":"widgets-container");nbCtrl=null;ctrlDimensions={width:0,height:0};hostSize={width:0,height:0};skRequestSub=new j;measureCtx=typeof document<"u"?document.createElement("canvas").getContext("2d"):null;constructor(){Fa(()=>{let o=this.theme(),e=this.runtime?.options();!o||!e||ge$1(()=>{this.labelColor.set(c(e.color??"contrast",o).dim);});}),Fa(()=>{let o=this.runtime?.options();if(!o)return;let e=(o.multiChildCtrls||[]).map(t=>z(G$1({},t),{isNumeric:t.isNumeric??false}));this.nbCtrl=e.length,ge$1(()=>{this.switchControls.set(e),this.updateCtrlDimensions();let t=this.streams;t&&e.forEach(n=>{let l=o.paths;if(!l?.length)return;let d=l.findIndex(R=>R.pathID===n.pathID);d<0||!l[d]?.path||t.observe(String(d),R=>{let w=R?.data?.value,L=n.isNumeric?[0,1,null].includes(w)?!!w:n.value:w;this.switchControls.update(E=>{let N=E.findIndex(we=>we.pathID===n.pathID);if(N===-1)return E;let ve=z(G$1({},E[N]),{value:L});return [...E.slice(0,N),ve,...E.slice(N+1)]});});});});});}onResized(o){this.hostSize={width:o.contentRect.width,height:o.contentRect.height},this.updateCtrlDimensions();}updateCtrlDimensions(){let o=this.hostSize.width,e=this.hostSize.height,t=this.switchControls();if(!o||!e||!t.length){this.ctrlDimensions={width:o,height:0};return}let n=this.measureCtx?ge(o,e,t,(l,d)=>(this.measureCtx.font=`700 ${d}px ${this.canvas.DEFAULT_FONT}`,this.measureCtx.measureText(l).width)):Math.max(1,Math.floor(e/t.length));this.ctrlDimensions={width:o,height:n};}toggle(o){let e=this.runtime?.options();if(!e?.putEnable)return;let t=e.paths;if(!t)return;let n=t.findIndex(d=>d.pathID===o.pathID);if(n<0)return;let l=t[n].path;l&&(o.isNumeric?this.signalkRequestsService.putRequest(l,o.value?1:0,this.id()):this.signalkRequestsService.putRequest(l,o.value,this.id()));}ngOnDestroy(){this.skRequestSub?.unsubscribe();}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=JD({type:i,selectors:[["widget-boolean-switch"]],inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:7,vars:5,consts:[["widgetContainer",""],[3,"text","color"],["kipResizeObserver","",3,"resizeChange"],[1,"widgetOverlay"],[1,"svg-widget",3,"controlData","theme","dimensions"],[1,"svg-widget",3,"toggleClick","controlData","theme","dimensions"]],template:function(e,t){if(e&1&&(wg(0),_w(1,_e,1,2,"widget-title",1),Pi(2,"div",2,0),Qh("resizeChange",function(l){return t.onResized(l)}),xw(4,Ee,4,1,"ng-container",null,Sw),ul(),_w(6,Te,1,0,"div",3)),e&2){let n=NT(t.runtime==null?null:t.runtime.options());EE(),Mw(n?.showLabel?1:-1),EE(),pT(t.noTitleClass()),EE(2),Aw(t.switchControls()),EE(2),Mw(t.dashboard.isDashboardStatic()?-1:6);}},dependencies:[u,be,Ce,fe,x],styles:[".widgets-container[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;z-index:20}.widgets-container-no-title[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;padding:3px 0 0;height:100%;width:100%;overflow:hidden;z-index:20}.svg-widget[_ngcontent-%COMP%]{display:flex}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent;z-index:21}"]})}return i})();
|
|
2
|
+
export{lt as WidgetBooleanSwitchComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {e as e$1}from'./chunk-B6bEhzNR.js';import {g as ge$1}from'./chunk-TakPRI3t.js';import {e9 as a,d1 as Hj,w,du as p,aS as De,bu as ut,aY as xe,D as Dt,$ as $j,v as vt,dx as n$1,F as Fa,dn as ge,a_ as Gp,cv as G,cw as z,J as JD,dC as x,c as $h,cn as wd,_ as _w,B as Bh,e as EE,M as Mw,f as eg,K as Kw,P as Pi,T as TT,u as ul}from'./main-BAV5VDOD.js';import {c,e}from'./chunk-Dxlia2NE.js';var pe=["solarSvg"];function he(l,e){l&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No solar chargers detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K solar paths or select chargers in widget settings."),ul()());}var te=class l{static SOLAR_DESCRIPTOR=a("widget-solar-charger");static SELF_ROOT_PATH=(()=>{let e=l.SOLAR_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetSolarChargerComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${l.SELF_ROOT_PATH}.*`;id=Hj.required();type=Hj.required();theme=Hj.required();renderMode=Hj(null);static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,solarCharger:{trackedDevices:[],optionsById:{}}};static VIEWBOX_WIDTH=200;static CARD_HEIGHT=100;static CARD_GAP=8;static SOLAR_PANEL_SYMBOL_WIDTH=158.90796;static SOLAR_PANEL_SYMBOL_HEIGHT=94.949027;static SOLAR_PANEL_SCALE=.77;static SOLAR_PANEL_TRANSLATE_X=-36;static SOLAR_PANEL_TRANSLATE_Y=0;static SOLAR_PANEL_X=(135+l.SOLAR_PANEL_TRANSLATE_X)*l.SOLAR_PANEL_SCALE;static SOLAR_PANEL_Y=(0+l.SOLAR_PANEL_TRANSLATE_Y)*l.SOLAR_PANEL_SCALE;static SOLAR_PANEL_WIDTH=l.SOLAR_PANEL_SYMBOL_WIDTH*l.SOLAR_PANEL_SCALE;static SOLAR_PANEL_HEIGHT=l.SOLAR_PANEL_SYMBOL_HEIGHT*l.SOLAR_PANEL_SCALE;static PATH_BATCH_WINDOW_MS=500;runtime=w(p);data=w(De);units=w(ut);destroyRef=w(xe);displayLabel=Dt(()=>{let e=this.visibleSolarUnits();return e.length!==1?"Solar Chargers":this.resolveTitleText(e[0])});labelColor=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e).dim:"var(--kip-contrast-dim-color)"});svgRef=$j.required("solarSvg");svg;layer;glowFilterId="";renderFrameId=null;pendingRenderSnapshot=null;pathBatchTimerId=null;initialPathPaintDone=false;pendingPathUpdates=new Map;discoveredSolarIds=vt([]);trackedDevices=vt([]);optionsById=vt({});cardMode=vt({displayMode:"full",metrics:["panelVoltage","panelCurrent","voltage","current"]});chargersByKey=vt({});visibleSolarKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(a=>a.key);let r=this.chargersByKey(),t=new Set(this.discoveredSolarIds());return Object.keys(r).filter(a=>{let s=r[a];return !!s&&t.has(s.id)}).sort((a,s)=>a.localeCompare(s))});visibleSolarUnits=Dt(()=>{let e=this.visibleSolarKeys(),r=this.chargersByKey();return e.map(t=>r[t]).filter(t=>!!t)});activeDisplayMode=Dt(()=>this.renderMode()??this.cardMode().displayMode??"full");isCompactCardMode=Dt(()=>this.activeDisplayMode()==="compact");colorRole=Dt(()=>this.runtime.options()?.color??"contrast");ignoreZones=Dt(()=>this.runtime.options()?.ignoreZones??false);widgetColors=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e):null});displayModels=Dt(()=>{let e$1=this.visibleSolarUnits(),r=this.optionsById(),t=this.theme(),a=this.widgetColors(),s=this.ignoreZones()??false,i={};for(let n of e$1){let u=r[n.id]?.arrayRatedPowerW??null,c=n.panelPower??null,g=this.formatPowerAuto(c),m=u&&u>0&&c!=null?Math.max(0,Math.min(1,c/u)):0,d=n.panelPowerState??n.panelCurrentState??null,o=n.currentState??null,p=e(d,a?.dim??"var(--kip-contrast-dim-color)",t,s),T=!s&&(d===n$1.Warn||d===n$1.Alarm||d===n$1.Alert),y=e(o,"var(--kip-contrast-color)",t,s),w=this.resolveMostSevereState(n.voltageState??null,n.temperatureState??null),v=e(w,"var(--kip-contrast-color)",t,s),S=this.resolveMostSevereState(n.panelCurrentState??null,n.panelVoltageState??null,n.panelTemperatureState??null),re=e(S,"var(--kip-contrast-color)",t,s),ae=!s&&(S===n$1.Warn||S===n$1.Alarm||S===n$1.Alert),ne=e(n.loadCurrentState??null,"var(--kip-contrast-color)",t,s),I=this.valueOrDash(n.controllerMode),V=this.isRelayActive(n.load),oe=V?`${this.formatRelayState(n.load)}\xA0\xA0\xA0\xA04.5A${this.formatCurrent(n.loadCurrent)}`.trim():"",se=n.yieldToday!=null?`${this.formatEnergyYield(n.yieldToday)} Today`:"",ie=n.yieldYesterday!=null?`${this.formatEnergyYield(n.yieldYesterday)} Yesterday`:"",le=n.deviceKey??n.id;i[le]={id:n.id,source:n.source??null,deviceKey:n.deviceKey,titleText:this.resolveTitleText(n),panelPowerText:g.value,panelPowerUnitText:g.unit,panelPowerColor:p,panelPowerGlowEnabled:T,chargerCurrentTextColor:y,chargerMetaTextColor:v,panelValuesTextColor:re,panelValuesGlowEnabled:ae,gaugeProgress:m,gaugeSectionText:`${this.formatVoltage(n.panelVoltage)}`+(n.panelCurrent!=null?`, ${this.formatCurrent(n.panelCurrent)}`:"")+(n.panelTemperature!=null?`, ${this.formatTemperature(n.panelTemperature)}`:""),yieldTodayText:se,yieldYesterdayText:ie,chargerSectionCurrent:`${this.formatCurrent(n.current)}`,chargerMode:`${I.charAt(0).toUpperCase()+I.slice(1)} mode`,chargerSectionMetadata:`${n.voltage!=null?this.formatVoltage(n.voltage):""}\xA0\xA0\xA0\xA0${n.temperature!=null?this.formatTemperature(n.temperature):""}`.trim(),relaySectionVisible:V,relaySectionText:oe,relayValuesTextColor:ne};}return i});hasChargers=Dt(()=>this.visibleSolarUnits().length>0);constructor(){Fa(()=>{let r=this.runtime.options();r&&ge(()=>{this.applyConfig(r);});}),Fa(()=>{let r=this.displayModels(),t=this.visibleSolarUnits(),a=this.widgetColors();!this.svg||!a||this.requestRender({solarUnits:t,displayModels:r,widgetColors:a});});let e=this.data.subscribePathTreeWithInitial(l.ROOT_PATTERN);if(e.initial.length){for(let r of e.initial)this.enqueuePathUpdate(r,true);this.flushPendingPathUpdates(),this.initialPathPaintDone=true;}e.live$.pipe(Gp(this.destroyRef)).subscribe(r=>{this.enqueuePathUpdate(r);});}ngAfterViewInit(){this.initializeSvg(),this.requestRender();}ngOnDestroy(){this.pathBatchTimerId!==null&&(clearTimeout(this.pathBatchTimerId),this.pathBatchTimerId=null),this.renderFrameId!==null&&(cancelAnimationFrame(this.renderFrameId),this.renderFrameId=null),this.pendingRenderSnapshot=null;}initializeSvg(){this.svg=ge$1(this.svgRef().nativeElement),this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${l.CARD_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","Solar Charger View"),this.glowFilterId=`solar-panel-glow-${this.id()}`;let r=this.svg.append("defs").append("filter").attr("id",this.glowFilterId).attr("x","-30%").attr("y","-30%").attr("width","160%").attr("height","160%");r.append("feFlood").attr("class","solar-panel-glow-flood").attr("flood-color","var(--kip-widget-card-background-color)").attr("flood-opacity",.9).attr("result","color"),r.append("feComposite").attr("in","color").attr("in2","SourceGraphic").attr("operator","in").attr("result","coloredGlow"),r.append("feGaussianBlur").attr("in","coloredGlow").attr("stdDeviation",2).attr("result","blur");let t=r.append("feMerge");t.append("feMergeNode").attr("in","blur"),t.append("feMergeNode").attr("in","blur"),t.append("feMergeNode").attr("in","SourceGraphic"),this.layer=this.svg.append("g").attr("class","solar-layer");}applyConfig(e){let r=this.resolveSolarConfig(e);this.trackedDevices.set(r.trackedDevices??[]),this.reprojectSnapshotsToDeviceKeys(r.trackedDevices??[]),this.optionsById.set(r.optionsById??{}),this.cardMode.set(this.normalizeCardMode(r.cardMode));}resolveSolarConfig(e){let r=e.solarCharger,t=this.normalizeTrackedDevices(r?.trackedDevices),a=this.normalizeOptionsById(r?.optionsById);return {trackedDevices:t,optionsById:a,cardMode:this.normalizeCardMode(r?.cardMode)}}normalizeTrackedDevices(e){if(!Array.isArray(e))return [];let r=new Map;return e.forEach(t=>{if(typeof t=="string"){let u=t.trim();if(!u)return;let c=`${u}||default`;r.set(c,{id:u,source:"default",key:c});return}if(!t||typeof t!="object")return;let a=t,s=typeof a.id=="string"?a.id.trim():"",i=typeof a.source=="string"?a.source.trim():"default";if(!s||!i)return;let n=typeof a.key=="string"&&a.key.trim().length>0?a.key.trim():`${s}||${i}`;r.set(n,{id:s,source:i,key:n});}),[...r.values()].sort((t,a)=>t.key.localeCompare(a.key))}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let r=new Map;e.forEach(t=>{let a=r.get(t.id)??[];a.push(t.key),r.set(t.id,a);}),this.chargersByKey.update(t=>{let a=t,s=false;return r.forEach((i,n)=>{let u=t[n];if(u){for(let c of i){if(t[c])continue;let g=e.find(m=>m.key===c);s||(a=G({},t),s=true),a[c]=z(G({},u),{source:g?.source??null,deviceKey:c});}s&&a[n]?.deviceKey===void 0&&delete a[n];}}),s?a:t});}normalizeCardMode(e){let r=e&&typeof e=="object"?e:null,t=this.normalizeStringList(r?.metrics);return {displayMode:r?.displayMode==="compact"?"compact":"full",metrics:t.length?t:["panelVoltage","panelCurrent","voltage","current"]}}normalizeStringList(e){if(!Array.isArray(e))return [];let r=new Set;return e.forEach(t=>{if(typeof t!="string")return;let a=t.trim();a.length>0&&r.add(a);}),[...r].sort((t,a)=>t.localeCompare(a))}normalizeOptionsById(e){if(!e||typeof e!="object")return {};let r=Object.entries(e),t={};return r.forEach(([a,s])=>{let i=this.normalizeOptionalString(a);if(!i)return;let n=s?.arrayRatedPowerW;t[i]={arrayRatedPowerW:typeof n=="number"&&Number.isFinite(n)?n:null};}),t}normalizeOptionalString(e){if(typeof e!="string")return null;let r=e.trim();return r.length>0?r:null}enqueuePathUpdate(e,r=false){let t=this.parseSolarPath(e.path);if(!t)return;let{id:a,key:s}=t,i=e.update?.data?.value??null,n=e.update?.state??null,u=`${a}::${s}`;if(this.pendingPathUpdates.set(u,{id:a,key:s,value:i,state:n}),!r){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=window.setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},l.PATH_BATCH_WINDOW_MS));}}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let e=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(e.map(t=>t.id)).forEach(t=>this.trackDiscoveredSolar(t)),this.chargersByKey.update(t=>{let a=t,s=false,i=this.trackedDevices(),n=i.length>0,u=new Map;n&&i.forEach(c=>{let g=u.get(c.id)??[];g.push(c.key),u.set(c.id,g);});for(let c of e){let g=n?u.get(c.id)??[]:[c.id];for(let m of g){let d=i.find(S=>S.key===m),o=a[m]??{id:c.id,source:d?.source??null,deviceKey:n?m:void 0},p=G({},o),T=this.applyChargerValue(p,c.key,c.value,c.state),y=false,w=this.resolvePowerValue(p.rawBatteryPower,p.voltage,p.current);Object.is(p.power,w)||(p.power=w,y=true);let v=this.resolvePowerValue(p.rawPanelPower,p.panelVoltage,p.panelCurrent);Object.is(p.panelPower,v)||(p.panelPower=v,y=true),!(!T&&!y)&&(s||(a=G({},a),s=true),a[m]=p);}}return s?a:t});}parseSolarPath(e){let r=e.match(/self\.electrical\.solar\.([^.]+)\.(.+)$/);if(!r)return null;let t=r[1],a=r[2],s=this.normalizeSolarMetricKey(a);return {id:t,key:s}}normalizeSolarMetricKey(e){if(e.startsWith("controller."))return e.slice(11);switch(e){case "solar.power":return "panelPower";case "solar.voltage":return "panelVoltage";case "solar.current":return "panelCurrent";case "solar.temperature":return "panelTemperature";case "charge.status":return "controllerMode";default:return e}}trackDiscoveredSolar(e){let r=this.discoveredSolarIds();r.includes(e)||this.discoveredSolarIds.set([...r,e].sort());}applyChargerValue(e,r,t,a){switch(r){case "name":return this.setValue(e,"name",this.toStringValue(t));case "location":return this.setValue(e,"location",this.toStringValue(t));case "associatedBus":return this.setValue(e,"associatedBus",this.toStringValue(t));case "voltage":{let s=this.toNumber(t,"V"),i=!Object.is(e.voltageState??null,a??null);return Object.is(e.voltage,s)&&!i?false:(e.voltage=s,e.voltageState=a,true)}case "current":{let s=this.toNumber(t,"A"),i=!Object.is(e.currentState??null,a??null);return Object.is(e.current,s)&&!i?false:(e.current=s,e.currentState=a,true)}case "power":return this.setPowerPathValue(e,"rawBatteryPower",t);case "temperature":{let s=this.toNumber(t,this.units.getDefaults().Temperature),i=!Object.is(e.temperatureState??null,a??null);return Object.is(e.temperature,s)&&!i?false:(e.temperature=s,e.temperatureState=a,true)}case "chargingAlgorithm":return this.setValue(e,"chargingAlgorithm",this.toStringValue(t));case "chargerRole":return this.setValue(e,"chargerRole",this.toStringValue(t));case "chargingMode":return this.setValue(e,"chargingMode",this.toStringValue(t));case "setpointVoltage":return this.setValue(e,"setpointVoltage",this.toNumber(t,"V"));case "setpointCurrent":return this.setValue(e,"setpointCurrent",this.toNumber(t,"A"));case "controllerMode":return this.setValue(e,"controllerMode",this.toStringValue(t));case "panelVoltage":{let s=this.toNumber(t,"V"),i=!Object.is(e.panelVoltageState??null,a??null);return Object.is(e.panelVoltage,s)&&!i?false:(e.panelVoltage=s,e.panelVoltageState=a,true)}case "panelCurrent":{let s=this.toNumber(t,"A"),i=!Object.is(e.panelCurrentState??null,a??null);return Object.is(e.panelCurrent,s)&&!i?false:(e.panelCurrent=s,e.panelCurrentState=a,true)}case "panelPower":{let s=this.toNumber(t,"W"),i=!Object.is(e.panelPowerState??null,a??null);return Object.is(e.rawPanelPower,s)&&!i?false:(e.rawPanelPower=s,e.panelPowerState=a,true)}case "yieldToday":return this.setValue(e,"yieldToday",this.toNumber(t,"kWh"));case "yieldYesterday":return this.setValue(e,"yieldYesterday",this.toNumber(t,"kWh"));case "panelTemperature":{let s=this.toNumber(t,this.units.getDefaults().Temperature),i=!Object.is(e.panelTemperatureState??null,a??null);return Object.is(e.panelTemperature,s)&&!i?false:(e.panelTemperature=s,e.panelTemperatureState=a,true)}case "load":case "loadState":case "load.state":return this.setValue(e,"load",t);case "loadCurrent":{let s=this.toNumber(t,"A"),i=!Object.is(e.loadCurrentState??null,a??null);return Object.is(e.loadCurrent,s)&&!i?false:(e.loadCurrent=s,e.loadCurrentState=a,true)}default:return false}}setPowerPathValue(e,r,t){let a=this.toNumber(t,"W");return this.setValue(e,r,a)}setValue(e,r,t){return Object.is(e[r],t)?false:(e[r]=t,true)}resolvePowerValue(e,r,t){if(e!=null)return e;if(r!=null&&t!=null)return r*t}requestRender(e){this.svg&&(this.pendingRenderSnapshot=e??this.buildRenderSnapshot(),this.pendingRenderSnapshot&&this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;let r=this.pendingRenderSnapshot;this.pendingRenderSnapshot=null,r&&this.render(r);})));}buildRenderSnapshot(){let e=this.widgetColors();return e?{solarUnits:this.visibleSolarUnits(),displayModels:this.displayModels(),widgetColors:e}:null}render(e){if(!this.layer||!this.svg)return;let t=this.isCompactCardMode()?e$1:e$1,a=e.solarUnits.map((o,p)=>({key:o.deviceKey??o.id,model:e.displayModels[o.deviceKey??o.id],y:p*(l.CARD_HEIGHT+l.CARD_GAP)})),s=a.length?a[a.length-1].y+l.CARD_HEIGHT:l.CARD_HEIGHT;this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${s}`);let i=this.layer.selectAll("g.solar-card").data(a,o=>o.key),n=i.enter().append("g").attr("class","solar-card");n.append("text").attr("class","solar-charger-title");let u=n.append("text").attr("class","solar-charger-current");u.append("tspan").attr("class","current-metric-value"),u.append("tspan").attr("class","current-metric-unit"),n.append("text").attr("class","solar-charger"),n.append("text").attr("class","solar-charger-meta"),n.append("text").attr("class","solar-relay-label"),n.append("text").attr("class","solar-relay-values"),n.append("text").attr("class","solar-panel-values"),n.append("text").attr("class","solar-yield-label"),n.append("text").attr("class","solar-yield-today"),n.append("text").attr("class","solar-yield-yesterday");let c=n.append("g").attr("class","solar-panel-icon").attr("transform",`translate(${l.SOLAR_PANEL_X}, ${l.SOLAR_PANEL_Y})`);c.append("use").attr("class","solar-panel-bg").attr("href","assets/svg/symbols.svg#solar-panel-cells").attr("x",0).attr("y",0).attr("width",l.SOLAR_PANEL_WIDTH).attr("height",l.SOLAR_PANEL_HEIGHT);let g=c.append("g").attr("class","solar-panel-progress");g.append("defs").append("clipPath").attr("clipPathUnits","objectBoundingBox").attr("id",o=>`solar-panel-clip-${this.id()}-${o.key}`).append("rect").attr("x",0).attr("y",0).attr("height",1).attr("width",0),g.append("use").attr("class","solar-panel-colored").attr("href","assets/svg/symbols.svg#solar-panel-cells").attr("x",0).attr("y",0).attr("width",l.SOLAR_PANEL_WIDTH).attr("height",l.SOLAR_PANEL_HEIGHT).attr("clip-path",o=>`url(#solar-panel-clip-${this.id()}-${o.key})`);let m=n.append("text").attr("class","solar-panel-power");m.append("tspan").attr("class","solar-panel-power-value"),m.append("tspan").attr("class","solar-panel-power-unit");let d=n.merge(i);d.attr("transform",o=>`translate(0, ${o.y})`),e.solarUnits.length>1?d.select("text.solar-charger-title").attr("x",t.titleX).attr("y",t.titleY).attr("font-size",t.titleFontSize).attr("fill","var(--kip-contrast-dim-color)").text(o=>e.displayModels[o.key]?.titleText??this.displayName(o.model)):d.select("text.solar-charger-title").text(""),d.select("text.solar-charger-current").attr("x",t.lineOneX).attr("y",t.lineOneY).attr("font-size",t.lineOneFontSize).attr("fill",o=>o.model.chargerCurrentTextColor),d.select("tspan.current-metric-value").text(o=>o.model.chargerSectionCurrent),d.select("tspan.current-metric-unit").attr("dx",1).attr("font-size",12).attr("fill","var(--kip-contrast-color)").text("A"),d.select("text.solar-charger").attr("x",5).attr("y",40).attr("fill","var(--kip-contrast-color)").attr("font-size",8).attr("opacity",.8).text(o=>o.model.chargerMode),d.select("text.solar-charger-meta").attr("x",t.metaLeftX).attr("y",48).attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",o=>o.model.chargerMetaTextColor).text(o=>o.model.chargerSectionMetadata),d.select("text.solar-relay-label").attr("x",5).attr("y",73).attr("font-size",10).attr("fill","var(--kip-contrast-color)").text(o=>o.model.relaySectionVisible?"Load Output":""),d.select("text.solar-relay-values").attr("x",10).attr("y",83).attr("font-size",t.lineTwoFontSize).attr("fill",o=>o.model.relayValuesTextColor).attr("opacity",o=>o.model.relaySectionVisible?.8:0).text(o=>o.model.relaySectionText),d.select("g.solar-panel-icon").attr("transform",`translate(${l.SOLAR_PANEL_X}, ${l.SOLAR_PANEL_Y})`),d.select("use.solar-panel-bg").attr("color","var(--kip-contrast-dimmer-color)"),d.select("g.solar-panel-progress").each((o,p,T)=>{ge$1(T[p]).select("rect").attr("x",0).attr("y",0).attr("height",1).attr("width",Math.max(0,Math.min(1,o.model.gaugeProgress))),this.debugSolarLayout(o.key,o.model.gaugeProgress);}),d.select("use.solar-panel-colored").attr("color",o=>o.model.panelPowerColor),d.select("text.solar-panel-power").attr("x",137.5).attr("y",t.primaryY).attr("text-anchor","middle").attr("font-size",t.primaryFontSize).attr("font-weight",t.primaryFontWeight).attr("filter",o=>o.model.panelPowerGlowEnabled?`url(#${this.glowFilterId})`:null).attr("fill","var(--kip-contrast-color)"),d.select("tspan.solar-panel-power-value").text(o=>o.model.panelPowerText),d.select("tspan.solar-panel-power-unit").attr("dx",o=>o.model.panelPowerUnitText?1:0).attr("font-size",20).attr("font-weight",500).attr("fill","var(--kip-contrast-color)").attr("opacity",o=>o.model.panelPowerUnitText?1:0).text(o=>o.model.panelPowerUnitText),d.select("text.solar-panel-values").attr("x",137.5).attr("y",60).attr("text-anchor","middle").attr("font-size",10).attr("font-weight",500).attr("opacity",.8).attr("filter",o=>o.model.panelValuesGlowEnabled?`url(#${this.glowFilterId})`:null).attr("fill",o=>o.model.panelValuesTextColor).text(o=>o.model.gaugeSectionText).raise(),d.select("text.solar-yield-label").attr("x",104).attr("y",88).attr("text-anchor","middle").attr("font-size",8).attr("fill","var(--kip-contrast-dim-color)").attr("opacity",.8).text("Yield (kWh):"),d.select("text.solar-yield-today").attr("x",130).attr("y",88).attr("text-anchor","start").attr("font-size",8).attr("fill","var(--kip-contrast-dim-color)").attr("opacity",.8).text(o=>o.model.yieldTodayText),d.select("text.solar-yield-yesterday").attr("x",130).attr("y",97.5).attr("text-anchor","start").attr("font-size",8).attr("fill","var(--kip-contrast-dim-color)").attr("opacity",.8).text(o=>o.model.yieldYesterdayText),i.exit().remove();}displayName(e){return e.name?.trim()||e.id}resolveTitleText(e){return e.name||`Solar ${e.id}`}toNumber(e,r){return e==null||typeof e!="number"?null:this.units.convertToUnit(r,e)??e}isRelayActive(e){if(e==null)return false;if(typeof e=="boolean")return e;if(typeof e=="number")return e>0;let r=e.trim().toLowerCase();return !(!r||r==="off"||r==="false"||r==="0")}toStringValue(e){return typeof e=="string"?e:e==null?null:`${e}`}valueOrDash(e){return e===null?"--":e===void 0?"":e}formatVoltage(e){return e===null?"--":e===void 0?"":`${e.toFixed(1)}V`}formatCurrent(e){return e===null?"--":e===void 0?"":`${e.toFixed(1)}`}formatTemperature(e){return e===null?"--":e===void 0?"":`${e.toFixed(1)} ${this.units.getDefaults().Temperature==="celsius"?"\xB0C":"\xB0F"}`}formatRelayState(e){return e===null?"--":e===void 0?"":typeof e=="boolean"?e?"On":"Off":typeof e=="number"?e>0?"On":"Off":e}formatPowerAuto(e){return e===null?{value:"--",unit:""}:e===void 0?{value:"",unit:""}:Math.abs(e)>=1e3?{value:(e/1e3).toFixed(2),unit:"kW"}:{value:e.toFixed(0),unit:"W"}}formatEnergyYield(e){return e===null?"--":e===void 0?"":`${e.toFixed(2)}`}resolveMostSevereState(...e){let r=null,t={[n$1.Normal]:0,[n$1.Nominal]:1,[n$1.Alert]:2,[n$1.Warn]:3,[n$1.Alarm]:4,[n$1.Emergency]:5};for(let a of e)a&&(!r||t[a]>t[r])&&(r=a);return r}debugSolarLayout(e,r){typeof window<"u"&&window.__KIP_DEBUG_SOLAR_LAYOUT===true&&console.debug("[solar-layout]",{id:e,gaugeProgress:r,panelX:l.SOLAR_PANEL_X,panelY:l.SOLAR_PANEL_Y,panelWidth:l.SOLAR_PANEL_WIDTH,panelHeight:l.SOLAR_PANEL_HEIGHT,clippedWidth:l.SOLAR_PANEL_WIDTH*r});}static \u0275fac=function(r){return new(r||l)};static \u0275cmp=JD({type:l,selectors:[["widget-solar-charger"]],viewQuery:function(r,t){r&1&&eg(t.svgRef,pe,5),r&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["solarSvg",""],[3,"text","color"],["aria-hidden","false",1,"solar-svg"],[1,"solar-empty"],[1,"solar-empty-title"],[1,"solar-empty-sub"]],template:function(r,t){r&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,he,5,0,"div",3)),r&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasChargers()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.solar-svg[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;z-index:20;padding:0 10px 10px}.solar-empty[_ngcontent-%COMP%]{position:absolute;inset:0;margin:10px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;text-align:center;color:var(--mat-sys-on-surface);background:color-mix(in srgb,var(--kip-widget-card-background-color) 92%,transparent)}.solar-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.solar-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{te as WidgetSolarChargerComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {G as Gt,L as Lt}from'./chunk-BQr-tSkv.js';import {u}from'./chunk-hd2_AKwt.js';import {c}from'./chunk-Dxlia2NE.js';import {d1 as Hj,w,du as p,dv as rt,v as vt,D as Dt,$ as $j,a6 as Lr,dx as n$1,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}from'./main-BAV5VDOD.js';var O=["compassGauge"];function L(n,p){if(n&1){let a=Fw();Pi(0,"radial-gauge",2,0),Qh("resizeChange",function(e){ud(a);let o=qw();return dd(o.onResized(e))}),ul();}if(n&2){let a=qw();Bh("options",a.gaugeOptions)("value",a.displayValue()),Hh("value-text",a.textValue())("color-stroke-ticks",a.colorStrokeTicks);}}function z(n){let p=n.match(/(\d+(\.\d+)?|\.\d+)/g);if(!p||p.length<3)throw new Error("Invalid RGBA format");let[a,t,e,o=1]=p.map(Number),s=o===1?"":Math.round(o*255).toString(16).padStart(2,"0").toUpperCase();return "#"+((1<<24)+(a<<16)+(t<<8)+e).toString(16).slice(1).toUpperCase()+s}function U(n){return n<0&&(n=360+n),n}var $=(()=>{class n{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);static DEFAULT_CONFIG={displayName:"Gauge Label",filterSelfPaths:true,paths:{gaugePath:{description:"Numeric Data",path:null,source:null,pathType:"number",suppressBootstrapNull:true,isPathConfigurable:true,showPathSkUnitsFilter:false,pathSkUnitsFilter:"rad",showConvertUnitTo:false,convertUnitTo:"deg",sampleTime:500}},supportAutomaticHistoricalSeries:true,gauge:{type:"ngRadial",subType:"baseplateCompass",enableTicks:true,compassUseNumbers:false,showValueBox:false},enableTimeout:false,color:"contrast",dataTimeout:5};LINE="line";NEEDLE_START=40;NEEDLE_END=100;NEEDLE_CIRCLE_SIZE=15;BORDER_MIDDLE_WIDTH=2;BORDER_INNER_WIDTH=2;ANIMATION_TARGET_PLATE="plate";ANIMATION_TARGET_NEEDLE="needle";textValue=vt("--");value=vt(void 0);displayValue=Dt(()=>this.value()??0);shouldRenderGauge=Dt(()=>this.value()!==void 0);gaugeBootstrapped=vt(false);animationEnabled=Dt(()=>this.gaugeBootstrapped());ngGauge=$j("compassGauge");gauge=$j("compassGauge",{read:Lr});viewReady=vt(false);gaugeOptions={};colorStrokeTicks="";currentState=vt(n$1.Normal);lastAppliedState=null;negToPortPaths=["self.environment.wind.angleApparent","self.environment.wind.angleTrueGround","self.environment.wind.angleTrueWater","self.environment.wind.angleTrueWaterDamped","self.performance.beatAngle","self.performance.gybeAngle","self.performance.targetAngle","self.performance.optimumWindAngle"];displayName=Dt(()=>this.runtime.options()?.displayName);constructor(){Fa(()=>{let a=this.runtime.options(),t=this.theme();if(!a||!t)return;let e=a.paths?.gaugePath;e?.path&&ge(()=>this.streams.observe("gaugePath",o=>{let s=o?.data?.value??null;if(s==null)this.value.set(0),this.textValue.set("--");else {let r=e.path;r&&this.negToPortPaths.includes(r)&&(s=U(s));let T=Math.min(Math.max(s,0),360);this.value.set(T),this.textValue.set(T.toFixed(0));}let i=o?.state??n$1.Normal;i!==this.currentState()&&this.currentState.set(i);}));}),Fa(()=>{let a=this.runtime.options(),t=this.theme();!a||!t||ge(()=>{if(this.buildGaugeOptions(a,t),this.viewReady())try{this.ngGauge()?.update(this.gaugeOptions);}catch(e){}});}),Fa(()=>{let a=this.ngGauge();!a||this.gaugeBootstrapped()||ge(()=>{try{requestAnimationFrame(()=>{this.gaugeBootstrapped.set(!0);try{a.update({animation:!0,animatedValue:!0});}catch(t){}});}catch(t){}});}),Fa(()=>{let a=this.runtime.options(),t=this.theme(),e=this.currentState();!a||!t||this.viewReady()&&e!==this.lastAppliedState&&ge(()=>{let o={};switch(e){case n$1.Emergency:o.colorValueText=t.zoneEmergency;break;case n$1.Alarm:o.colorValueText=t.zoneAlarm;break;case n$1.Warn:o.colorValueText=t.zoneWarn;break;case n$1.Alert:o.colorValueText=t.zoneAlert;break;default:o.colorValueText=t.contrast;break}try{this.ngGauge()?.update(o);}catch(s){}this.lastAppliedState=e;});});}buildGaugeOptions(a,t){let e=this.gaugeOptions={},o=a.paths?.gaugePath;e.title=this.displayName(),e.minValue=0,e.maxValue=360,e.units=o?.convertUnitTo||"",e.valueDec=a.numDecimal??0,e.valueInt=a.numInt??1,e.barProgress=false,e.barWidth=0,e.valueBox=!!a.gauge?.showValueBox,e.fontValueSize=60,e.valueBoxWidth=30,e.valueBoxBorderRadius=10,e.valueBoxStroke=0,e.ticksAngle=360,e.startAngle=180,e.exactTicks=false,e.strokeTicks="",e.majorTicks=a.gauge?.compassUseNumbers?["N","30","60","E","120","150","S","210","240","W","300","330","N"]:["N","NE","E","SE","S","SW","W","NW","N"],e.majorTicksDec=0,e.majorTicksInt=1,e.numbersMargin=5,e.fontNumbersSize=25,e.minorTicks=a.gauge?.compassUseNumbers?3:2,e.needle=true,e.needleType=this.LINE,e.needleStart=this.NEEDLE_START,e.needleEnd=this.NEEDLE_END,e.needleCircleSize=this.NEEDLE_CIRCLE_SIZE,e.needleWidth=4,e.needleShadow=false,e.needleCircleInner=false,e.needleCircleOuter=false,e.borders=true,e.borderOuterWidth=0,e.borderMiddleWidth=this.BORDER_MIDDLE_WIDTH,e.borderInnerWidth=this.BORDER_INNER_WIDTH,e.borderShadowWidth=0,e.highlights=[],e.highlightsWidth=0,e.fontTitle="Roboto",e.fontTitleWeight="normal",e.fontTitleSize=25,e.fontUnits="Roboto",e.fontUnitsSize=25,e.fontUnitsWeight="normal",e.barStrokeWidth=0,e.barShadow=0,e.fontValue="Roboto",e.fontValueWeight="bold",e.valueTextShadow=false,e.colorValueBoxShadow="",e.fontNumbers="Roboto",e.fontNumbersWeight="bold",a.gauge?.subType==="marineCompass"?(e.animationTarget=this.ANIMATION_TARGET_PLATE,e.useMinPath=true):(e.animationTarget=this.ANIMATION_TARGET_NEEDLE,e.useMinPath=true),e.animateOnInit=false,e.animation=this.animationEnabled(),e.animatedValue=this.animationEnabled(),e.animationRule="linear",e.animationDuration=(o?.sampleTime??500)-50;let s=c(a.color??"contrast",t),i=z(s.dim),r=z(c("contrast",t).dim);e.colorBarProgress=s.color,e.colorBorderMiddle=i,e.colorBorderMiddleEnd=i,e.colorNeedle=s.color,e.colorNeedleEnd=s.color,e.colorTitle=r,e.colorUnits=r,e.colorValueText=s.color,e.colorMinorTicks=r,e.colorNumbers=a.gauge?.compassUseNumbers?[t.port,r,r,i,r,r,i,r,r,i,r,r,t.port]:[t.port,i,i,i,i,i,i,i,t.port],e.colorMajorTicks=a.gauge?.compassUseNumbers?[t.port,t.contrast,t.contrast,t.contrast,t.contrast,t.contrast,t.contrast,t.contrast,t.contrast,t.contrast,t.contrast,t.contrast,t.port]:[t.port,t.contrast,t.contrast,t.contrast,t.contrast,t.contrast,t.contrast,t.contrast,t.port],e.colorPlate=e.colorPlateEnd=e.colorBorderInner=e.colorBorderInnerEnd=t.cardColor,e.colorBar=t.background,e.colorBarStroke="",e.colorValueBoxBackground=t.background,e.colorNeedleShadowUp="",e.colorNeedleShadowDown="",e.colorNeedleCircleInner=e.colorPlate,e.colorNeedleCircleInnerEnd=e.colorPlate,e.colorNeedleCircleOuter=e.colorPlate,e.colorNeedleCircleOuterEnd=e.colorPlate;}setCanvasSize(){let a=this.gauge()?.nativeElement;if(!a)return;let t=a.getBoundingClientRect(),e={height:t.height,width:t.width};try{this.ngGauge()?.update(e);}catch(o){}}ngAfterViewInit(){this.viewReady.set(true),this.setCanvasSize();try{this.ngGauge()?.update(this.gaugeOptions);}catch(a){}}onResized(a){let t={height:a.contentRect.height,width:a.contentRect.width};try{this.ngGauge()?.update(t);}catch(e){}}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=JD({type:n,selectors:[["widget-gauge-ng-compass"]],viewQuery:function(t,e){t&1&&eg(e.ngGauge,O,5)(e.gauge,O,5,Lr),t&2&&Kw(2);},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:1,vars:1,consts:[["compassGauge",""],["kipResizeObserver","",3,"options","value"],["kipResizeObserver","",3,"resizeChange","options","value"]],template:function(t,e){t&1&&_w(0,L,2,4,"radial-gauge",1),t&2&&Mw(e.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:10px}"]})}return n})();export{$ as WidgetGaugeNgCompassComponent};
|