@mxtommy/kip 4.8.0 → 4.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/README.md +19 -17
- package/package.json +24 -21
- package/plugin/history-series.service.js +3 -0
- package/plugin/index.js +1 -1
- 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/history-api.md +69 -71
- package/public/assets/help-docs/menu.json +25 -7
- package/public/assets/help-docs/time-series.md +81 -0
- package/public/assets/help-docs/welcome.md +1 -1
- package/public/chunk-7lulvsGI.js +1 -0
- package/public/chunk-8hkXyEzG.js +1 -0
- package/public/chunk-B15lj2T8.js +1 -0
- package/public/chunk-B6AwCAvV.js +1 -0
- package/public/chunk-B6XxnPxk.js +1 -0
- package/public/chunk-B8gfh4xf.js +1 -0
- package/public/chunk-B8zRhoG8.js +1 -0
- package/public/chunk-BIYHVfJl.js +1 -0
- package/public/chunk-BW4m3O2L.js +1 -0
- package/public/chunk-B_PiPxb4.js +1 -0
- package/public/chunk-Bb1mO304.js +1 -0
- package/public/chunk-BdBWqZzL.js +1 -0
- package/public/chunk-BgyxBAyq.js +1 -0
- package/public/chunk-Bhah8DNM.js +2 -0
- package/public/chunk-Bq-eHuZV.js +1 -0
- package/public/chunk-BxV0O2fU.js +2 -0
- package/public/chunk-Bz9bswDl.js +1 -0
- package/public/chunk-C3CwUYvD.js +2 -0
- package/public/chunk-C4FGoLDg.js +1 -0
- package/public/chunk-CCiqU2uY.js +1 -0
- package/public/chunk-CHKQxw6E.js +1 -0
- package/public/chunk-CJIxuzvd.js +1 -0
- package/public/chunk-COMZv7NY.js +1 -0
- package/public/chunk-CQNVyz8q.js +1 -0
- package/public/chunk-CSpA60X7.js +382 -0
- package/public/chunk-CU8RPnsi.js +1 -0
- package/public/chunk-CaD3zVfK.js +1 -0
- package/public/chunk-CcvYOops.js +1 -0
- package/public/chunk-CdSWuWKr.js +1 -0
- package/public/chunk-CjsnWLUr.js +1 -0
- package/public/chunk-CkfPr-c5.js +1 -0
- package/public/chunk-CoEM_FqS.js +1 -0
- package/public/chunk-Cr34s2uQ.js +1 -0
- package/public/chunk-Cu9FE8cB.js +1 -0
- package/public/chunk-CyURmwWh.js +1 -0
- package/public/chunk-D-xDPCf7.js +1 -0
- package/public/chunk-D0MyVrEL.js +14 -0
- package/public/chunk-DBA0eRqb.js +1 -0
- package/public/chunk-DGOvRnAo.js +1 -0
- package/public/chunk-DMhuBqKs.js +1 -0
- package/public/chunk-DMoEBcor.js +1 -0
- package/public/chunk-DSvdWjO4.js +1 -0
- package/public/chunk-DVB9tiW3.js +39 -0
- package/public/chunk-D_wrJJxl.js +1 -0
- package/public/chunk-DfGLo6Tb.js +1 -0
- package/public/chunk-Di5pPpU7.js +1 -0
- package/public/chunk-DjavLLpP.js +1 -0
- package/public/chunk-Dv77RFHm.js +1 -0
- package/public/chunk-H9_eqTYx.js +1 -0
- package/public/chunk-NnB8OYZt.js +1015 -0
- package/public/chunk-TakPRI3t.js +2 -0
- package/public/chunk-h2q_pbbF.js +2 -0
- package/public/chunk-o977r5_s.js +1 -0
- package/public/chunk-oPq9Nexl.js +1 -0
- package/public/chunk-oZiyAw_P.js +3 -0
- package/public/chunk-zg7II0hz.js +1 -0
- package/public/index.html +4 -4
- package/public/main-BNR44HGB.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-3SJSLBCV.js +0 -6
- package/public/chunk-5SMHTIVS.js +0 -50
- package/public/chunk-6ISGIPNP.js +0 -1
- package/public/chunk-6ZR3M3IQ.js +0 -3
- package/public/chunk-ACY7HYMZ.js +0 -4
- package/public/chunk-C23GLDFH.js +0 -62
- package/public/chunk-CB4E7PPA.js +0 -4
- package/public/chunk-DNM5XUIF.js +0 -1
- package/public/chunk-GSM7FZE2.js +0 -2
- package/public/chunk-HF7V6XFA.js +0 -2
- package/public/chunk-HUCDJ6CS.js +0 -10
- package/public/chunk-ILQQCGMJ.js +0 -5
- package/public/chunk-IXUKD73N.js +0 -5
- package/public/chunk-JMZYPL54.js +0 -2
- package/public/chunk-KG4C6HZC.js +0 -1
- package/public/chunk-LEY6MANN.js +0 -16
- package/public/chunk-NS2OV2OW.js +0 -9
- package/public/chunk-O5BTKN5D.js +0 -1
- package/public/chunk-Q32FSCUX.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/main-UBENKC2D.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'./chunk-h2q_pbbF.js';import {d1 as Hj,w,du as p,ao as ue,dy as K,dw as S,aZ as R,bu as ut,i as ir,$ as $j,a6 as Lr,b0 as Wl,W as Wp,E as Em,F as Fa,dn as ge,cw as z,cv as G,J as JD,cp as Uh,f as eg,K as Kw}from'./main-BNR44HGB.js';var tt=["widgetDataChart"],mt=(()=>{class O{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p,{optional:true});static DEFAULT_CONFIG={filterSelfPaths:true,color:"contrast",timeScale:"Last 30 Minutes"};ngZone=w(ue);_dataset=w(K);datasetLifecycle=w(S);canvasService=w(R);unitsService=w(ut);responsive=w(ir);isPhonePortrait;widgetDataChart=$j("widgetDataChart",{read:Lr});lineChartData={datasets:[]};lineChartOptions={parsing:false,datasets:{line:{pointRadius:0,pointHoverRadius:0,tension:.3}},animations:{tension:{easing:"easeInOutCubic"}}};lineChartType="line";chart=null;_dsDirectionSub=null;_dsSpeedSub=null;_chartUpdateRafId=null;datasetConfig=null;dataSourceInfo=null;xCenter=null;xStep=null;xCenterSpeed=null;xStepSpeed=null;CENTER_LINE_WIDTH=4;GRID_LINE_WIDTH=1;EDGE_EXTEND_UP_PX=42;EDGE_SPEED_LABEL_OFFSET=5;EDGE_DIR_LABEL_OFFSET=5;TICK_LABEL_FONT_SIZE=20;TICK_LABEL_PHONE_PORTRAIT_FONT_SIZE=11;CENTER_LABEL_FONT_SIZE=22;CENTER_LABEL_PHONE_PORTRAIT_FONT_SIZE=13;SPEED_VALUE_FONT_SIZE=62;SPEED_VALUE_PHONE_PORTRAIT_FONT_SIZE=32;TOP_VALUE_Y_OFFSET=62;TOP_VALUE_PHONE_PORTRAIT_Y_OFFSET=44;TOP_UNIT_Y_OFFSET=51;TOP_UNIT_PHONE_PORTRAIT_Y_OFFSET=38;UNIT_FONT_SIZE=28;UNIT_PHONE_PORTRAIT_FONT_SIZE=14;UNIT_PADDING=8;UNIT_PHONE_PORTRAIT_PADDING=3;isPortrait=()=>this.isPhonePortrait()?.matches===true;gridBackgroundPlugin={id:"xSpeedGridBackground",beforeDraw:e=>{let t=e.chartArea;if(!t)return;let a=e.ctx,i=this.theme();a.save(),a.globalCompositeOperation="destination-over",a.fillStyle=i.background,a.fillRect(t.left,t.top,t.width/2,t.height),a.restore();}};centerTickPlugin={id:"centerTickStyle",afterDraw:e=>{let t=e.ctx,a=e.chartArea,i=this.theme(),n=this.getThemeColors(),o=Wl.defaults.font,u=e.scales,c=e.options?.scales,r=e.data?.datasets?.[0]?.data,d=e.data?.datasets?.[5]?.data,f=(r?.length??0)>=2&&(d?.length??0)>=2,h=(p,g)=>{let l=u?.[p],x=c;if(!l)return;let E=l,v=x?.[p]?.min??E.min,C=x?.[p]?.max??E.max;if(typeof v!="number"||typeof C!="number"||!isFinite(v)||!isFinite(C))return;let y=(v+C)/2,L=l.getPixelForValue(y);t.save(),t.strokeStyle=i.contrastDim,t.lineWidth=this.CENTER_LINE_WIDTH,t.beginPath(),t.moveTo(L,a.top),t.lineTo(L,a.bottom),t.stroke(),t.restore(),t.save(),t.fillStyle=i.contrastDim,t.font=this.isPortrait()?`bold ${this.CENTER_LABEL_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.CENTER_LABEL_FONT_SIZE}px ${o.family}`,t.textAlign="center",t.textBaseline="top";let J=this.axisTopLabelY(l);t.fillText(g(y),L,J),t.restore();};h("x",p=>`${((p%360+360)%360).toFixed(0)}\xB0`),h("xSpeed",p=>`${p.toFixed(1)}`);let s=u?.xSpeed;if(s){let p=c,g=s,l=p?.xSpeed?.max??g.max;if(typeof l=="number"&&isFinite(l)){let x=s.getPixelForValue(l);t.save(),t.fillStyle=this.resolveTickColor(e,s,l),t.font=this.isPortrait()?`normal ${this.TICK_LABEL_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`normal ${this.TICK_LABEL_FONT_SIZE}px ${o.family}`,t.textAlign="right",t.textBaseline="top";let E=this.axisTopLabelY(s),v=this.xStepSpeed??1,C=Math.max(0,Math.min(3,Math.ceil(-Math.log10(v))));t.fillText(`${l.toFixed(C)}`,x-this.EDGE_SPEED_LABEL_OFFSET,E),t.restore(),t.save(),t.strokeStyle=i.contrastDim,t.lineWidth=this.GRID_LINE_WIDTH,t.beginPath();let y=Math.round(x)+.5;t.moveTo(y,a.bottom),t.lineTo(y,a.top-this.EDGE_EXTEND_UP_PX),t.stroke(),t.restore();}}let m=u?.x;if(m){let p=c,g=m,l=p?.x?.min??g.min;if(typeof l=="number"&&isFinite(l)){let x=m.getPixelForValue(l);t.save(),t.fillStyle=this.resolveTickColor(e,m,l),t.font=this.isPortrait()?`normal ${this.TICK_LABEL_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`normal ${this.TICK_LABEL_FONT_SIZE}px ${o.family}`,t.textAlign="left",t.textBaseline="top";let E=this.axisTopLabelY(m),v=this.normalizeAngle(l);t.fillText(`${v.toFixed(0)}\xB0`,x+this.EDGE_DIR_LABEL_OFFSET,E),t.restore();}}let _=e.data?.datasets,S=_?.[5]?.data,D=S?.length?S.length-1:-1,b=D>=0?S[D]?.x:void 0;if(typeof b=="number"&&isFinite(b)){t.save(),t.fillStyle=n.chartValue,t.font=this.isPortrait()?`bold ${this.SPEED_VALUE_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.SPEED_VALUE_FONT_SIZE}px ${o.family}`,t.textAlign="center",t.textBaseline="middle";let p=`${b.toFixed(1)}`,g=a.left+a.width/4,l=a.top-(this.isPortrait()?this.TOP_VALUE_PHONE_PORTRAIT_Y_OFFSET:this.TOP_VALUE_Y_OFFSET);t.fillText(p,g,l);let x=t.measureText(p),E=g+x.width/2+(this.isPortrait()?this.UNIT_PHONE_PORTRAIT_PADDING:this.UNIT_PADDING),v=a.top-(this.isPortrait()?this.TOP_UNIT_PHONE_PORTRAIT_Y_OFFSET:this.TOP_UNIT_Y_OFFSET);t.font=this.isPortrait()?`bold ${this.UNIT_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.UNIT_FONT_SIZE}px ${o.family}`,t.textAlign="left",t.fillText("kts",E,v),t.restore();}let F=_?.[0]?.data,N=F?.length?F.length-1:-1,T=N>=0?F[N]?.x:void 0;if(typeof T=="number"&&isFinite(T)){let p=this.normalizeAngle(T);t.save(),t.fillStyle=n.chartValue,t.font=this.isPortrait()?`bold ${this.SPEED_VALUE_PHONE_PORTRAIT_FONT_SIZE}px ${o.family}`:`bold ${this.SPEED_VALUE_FONT_SIZE}px ${o.family}`,t.textAlign="center",t.textBaseline="middle",t.fillText(`${p.toFixed(0)}\xB0`,a.left+3*a.width/4,a.top-(this.isPortrait()?this.TOP_VALUE_PHONE_PORTRAIT_Y_OFFSET:this.TOP_VALUE_Y_OFFSET)),t.restore();}if(!f){let p=Math.min(a.width*.7,420),g=90,l=a.left+(a.width-p)/2,x=a.top+(a.height-g)/2;t.save(),t.globalAlpha=.82,t.fillStyle=i.background,t.fillRect(l,x,p,g),t.restore(),t.save(),t.strokeStyle=i.contrastDim,t.lineWidth=2,t.strokeRect(l,x,p,g),t.restore(),t.save(),t.fillStyle=this.getThemeColors().chartLabel,t.textAlign="center",t.textBaseline="middle",t.font=`bold 18px ${o.family}`,t.fillText("Data acquisition...",l+p/2,x+g/2),t.restore();}}};constructor(){this.isPhonePortrait=Wp(this.responsive.observe(Em.HandsetPortrait),{initialValue:void 0}),Fa(()=>{let e=this.theme(),t=this.runtime?.options();!e||!t||ge(()=>{this.datasetConfig&&this.chart&&(this.setChartOptions(),this.setDatasetsColors(),this.ngZone.runOutsideAngular(()=>this.chart?.update("none")));});}),Fa(()=>{let e=this.runtime?.options();if(!e)return;!this.datasetConfig||this.datasetConfig.timeScaleFormat!==e.timeScale?(this.syncServiceDatasets(),this.startWidget()):this.chart&&this.setChartOptions();});}startWidget(){if(this.widgetDataChart()&&(this.datasetConfig=this._dataset.getDatasetConfig(`${this.id()}-twd`)??null,this.dataSourceInfo=this._dataset.getDataSourceInfo(`${this.id()}-twd`)??null,!!this.datasetConfig)){if(this.createDatasets(),this.setChartOptions(),this.chart)this.ngZone.runOutsideAngular(()=>this.chart?.update("none"));else {let e=this.widgetDataChart()?.nativeElement.getContext("2d");if(!e)return;this.chart=new Wl(e,{type:this.lineChartType,data:this.lineChartData,options:this.lineChartOptions,plugins:[this.gridBackgroundPlugin,this.centerTickPlugin]}),this.ngZone.runOutsideAngular(()=>this.chart?.update("none"));}this.startStreaming();}}syncServiceDatasets(){let e=this.runtime?.options();!e||e.timeScale===""||this.datasetLifecycle.syncWindTrendsDatasets(this.id(),e.timeScale);}setChartOptions(){let e=this.datasetConfig,t=this.dataSourceInfo;if(!e||!t)return;this.lineChartOptions.maintainAspectRatio=false,this.lineChartOptions.animation=false,this.lineChartOptions.indexAxis="y";let a=0,i=360,n=(i-a)/4,o=0,u=20,c=(u-o)/4;this.lineChartOptions.scales={y:{type:"linear",display:true,position:"right",reverse:true,title:{display:true,text:`${e.timeScaleFormat}`,align:"center"},ticks:{count:6,autoSkip:false,includeBounds:true,align:"inner",major:{enabled:true},font:this.isPortrait()?{size:12}:{size:16},callback:r=>{let d=Number(r),f=e.timeScaleFormat,h=this.getWindowMs(f);return f==="Last 5 Minutes"?`${Math.round(d/6e4)}'`:h>=10*6e4?`${Math.round(d/6e4)}'`:`${Math.round(d/1e3)}"`}},grid:{display:true,color:this.theme().contrastDimmer}},x:{type:"linear",position:"top",stack:"trends",beginAtZero:false,bounds:"ticks",min:a,max:i,title:{display:false},ticks:{count:5,align:"inner",autoSkip:false,includeBounds:true,stepSize:n,minRotation:0,maxRotation:0,callback:r=>{let d=Number(r),f=this.xCenter??Number.NaN;if(this.nearlyEqual(d,f))return "";let s=this.chart?.options?.scales?.x?.min;return typeof s=="number"&&this.nearlyEqual(d,s)?"":`${((d%360+360)%360).toFixed(0)}\xB0`},font:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenter??Number.NaN,h=this.nearlyEqual(d,f);return this.isPortrait()?{size:11,weight:h?"bold":"normal"}:{size:20,weight:h?"bold":"normal"}},color:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenter??Number.NaN;return this.nearlyEqual(d,f)?this.theme().contrast:void 0}},grid:{display:true,color:r=>{let d=r.tick?.value??Number.NaN,f=r.scale,h=this.chart?.options?.scales,s=f,m=h?.x?.min??s.min;return this.nearlyEqual(d,m)?"rgba(0,0,0,0)":this.theme().contrastDimmer},lineWidth:1}},xSpeed:{type:"linear",position:"top",stack:"trends",beginAtZero:false,bounds:"ticks",min:o,max:u,title:{display:false},ticks:{count:5,align:"inner",autoSkip:false,includeBounds:true,stepSize:c,minRotation:0,maxRotation:0,callback:r=>{let d=this.xCenterSpeed??Number.NaN;if(this.nearlyEqual(r,d))return "";let h=this.chart?.options?.scales?.xSpeed?.max;if(typeof h=="number"&&this.nearlyEqual(r,h))return "";let s=this.xStepSpeed??Number.NaN,m=Number.isFinite(s)?s:1,_=Math.max(0,Math.min(3,Math.ceil(-Math.log10(m))));return `${r.toFixed(_)}`},font:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenterSpeed??Number.NaN,h=this.nearlyEqual(d,f);return this.isPortrait()?{size:11,weight:h?"bold":"normal"}:{size:20,weight:h?"bold":"normal"}},color:r=>{let d=r.tick?.value??Number.NaN,f=this.xCenterSpeed??Number.NaN;return this.nearlyEqual(d,f)?this.theme().contrast:void 0}},grid:{display:true,color:r=>{let d=r.tick?.value??Number.NaN,f=r.scale,h=this.chart?.options?.scales,s=f,m=h?.xSpeed?.max??s.max;return this.nearlyEqual(d,m)?"rgba(0,0,0,0)":this.theme().contrastDimmer},lineWidth:1}}},this.lineChartOptions.plugins={title:{display:true,align:"end",text:"TWD ",color:this.getThemeColors().chartLabel,padding:this.isPortrait()?{top:3,bottom:0}:{top:3,bottom:0},font:this.isPortrait()?{size:16,weight:"normal"}:{size:35,weight:"normal"}},subtitle:{display:true,align:"start",text:" TWS",color:this.getThemeColors().chartLabel,padding:this.isPortrait()?{top:-18,bottom:12}:{top:-41,bottom:12},font:this.isPortrait()?{size:16}:{size:35}},legend:{display:false},annotation:{annotations:{}},streaming:{duration:t.maxDataPoints*t.sampleTime,delay:t.sampleTime,frameRate:e.timeScaleFormat==="day"?5:e.timeScaleFormat==="hour"?8:e.timeScaleFormat==="minute"?15:30}},this.xCenter=(a+i)/2,this.xStep=n,this.xCenterSpeed=(o+u)/2,this.xStepSpeed=c;}createDatasets(){this.lineChartData.datasets=[],this.lineChartData.datasets.push({label:"Value",data:[],order:2,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:1,fill:false,xAxisID:"x"},{label:"SMA",data:[],order:0,parsing:false,normalized:true,tension:.3,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:10,fill:false,borderColor:e=>{let t=e.chart,{ctx:a}=t;return this.lineGradientForAxis(a,t,"x")??this.getThemeColors().averageLine},backgroundColor:"red",xAxisID:"x"},{label:"lastAverage",data:[],order:1,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:0,borderColor:"",fill:false,hidden:true,xAxisID:"x"},{label:"lastMinimum",data:[],order:3,parsing:false,normalized:true,hidden:true,xAxisID:"x"},{label:"lastMaximum",data:[],order:4,parsing:false,normalized:true,hidden:true,xAxisID:"x"},{label:"Value Speed",data:[],order:2,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:1,fill:false,xAxisID:"xSpeed"},{label:"SMA Speed",data:[],order:0,parsing:false,normalized:true,tension:.2,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:3,fill:false,borderColor:e=>{let t=e.chart,{ctx:a}=t;return this.lineGradientForAxis(a,t,"xSpeed")??this.getThemeColors().averageLine},xAxisID:"xSpeed"},{label:"lastAverage Speed",data:[],order:1,parsing:false,normalized:true,tension:0,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:0,borderColor:"",fill:false,hidden:true,xAxisID:"xSpeed"},{label:"lastMinimum Speed",data:[],order:3,parsing:false,normalized:true,hidden:true,xAxisID:"xSpeed"},{label:"lastMaximum Speed",data:[],order:4,parsing:false,normalized:true,hidden:true,xAxisID:"xSpeed"}),this.setDatasetsColors();}startStreaming(){if(this._dsDirectionSub?.unsubscribe(),this._dsSpeedSub?.unsubscribe(),!this.chart||!this.dataSourceInfo)return;let e=this._dataset.getDatasetBatchThenLiveObservable(`${this.id()}-twd`),t=this._dataset.getDatasetBatchThenLiveObservable(`${this.id()}-tws`);!e||!t||(this._dsDirectionSub=e.subscribe(a=>{let i=this.chart,n=this.dataSourceInfo;if(!(!i||!n)){if(Array.isArray(a))this.pushRowsToDatasets(a);else {this.pushRowsToDatasets([a]);let o=i.data.datasets[0]?.data;if(Array.isArray(o)&&o.length>n.maxDataPoints)for(let u=0;u<=4;u++){let c=i.data.datasets[u]?.data;Array.isArray(c)&&c.shift();}}this.scheduleChartUpdate();}}),this._dsSpeedSub=t.subscribe(a=>{let i=this.chart,n=this.dataSourceInfo;if(!(!i||!n)){if(Array.isArray(a))this.pushRowsToSpeedDatasets(a);else {this.pushRowsToSpeedDatasets([a]);let o=i.data.datasets[5]?.data;if(Array.isArray(o)&&o.length>n.maxDataPoints)for(let u=5;u<=9;u++){let c=i.data.datasets[u]?.data;Array.isArray(c)&&c.shift();}}this.scheduleChartUpdate();}}));}unwrapAngles(e){if(e.length===0)return [];let t=[],a=null;for(let i of e){if(i==null){t.push(null);continue}if(a==null){t.push(i),a=i;continue}let n=i-a;n>180&&(n-=360),n<-180&&(n+=360),t.push(t[t.length-1]+n),a=i;}return t}pushRowsToDatasets(e){this.pushRowsGeneric(e,0,"deg",true);}pushRowsToSpeedDatasets(e){this.pushRowsGeneric(e,5,"knots",false);}getRowValue(e,t){switch(t){case "value":return e.data.value??null;case "sma":return e.data.sma??null;case "ema":return e.data.ema??null;case "dema":return e.data.doubleEma??null;case "avg":return e.data.lastAverage??null;case "min":return e.data.lastMinimum??null;case "max":return e.data.lastMaximum??null;default:return null}}transformRows(e,t,a,i){let n=e.map(u=>{let c=this.getRowValue(u,t);return c==null?null:this.unitsService.convertToUnit(a,c)}),o=i?this.unwrapAngles(n):n;return e.map((u,c)=>({x:o[c],y:u.timestamp,ts:u.timestamp}))}pushRowsGeneric(e,t,a,i){let n=this.chart;if(!n)return;["value","sma","avg","min","max"].forEach((u,c)=>{let r=n.data.datasets[t+c];!r||!Array.isArray(r.data)||r.data.push(...this.transformRows(e,u,a,i));});}normalizeAngle(e){return (e%360+360)%360}angularDiff(e,t){let a=(e-t+540)%360-180;return Math.abs(a)}niceStepFromMantissas(e,t){if(!isFinite(e)||e<=0)return 1;let a=Math.floor(Math.log10(e)),i=e/Math.pow(10,a);return (t.find(o=>i<=o)??t[t.length-1])*Math.pow(10,a)}scheduleChartUpdate(){this._chartUpdateRafId==null&&(this._chartUpdateRafId=requestAnimationFrame(()=>{this._chartUpdateRafId=null,!(!this.chart||!this.hasValidDatasets())&&(this.updateChartAfterDataChange(),this.ngZone.runOutsideAngular(()=>this.chart?.update("none")));}));}hasValidDatasets(){let e=this.chart?.data?.datasets;if(!Array.isArray(e)||e.length<10)return false;for(let t=0;t<10;t++){let a=e[t];if(!a||!Array.isArray(a.data))return false}return true}updateChartAfterDataChange(){let e=this.chart;if(!e)return;let t=e.data.datasets[2]?.data,a=e.data.datasets[1]?.data,i=e.data.datasets[0]?.data,n=!!t?.length,o=!!a?.length,u=!!i?.length,c=n?t[t.length-1].x:o?a[a.length-1].x:u?i[i.length-1].x:void 0;if(typeof c=="number"&&isFinite(c)){let h=e.data.datasets[3]?.data,s=e.data.datasets[4]?.data,m=h?.length?h[h.length-1].x:void 0,_=s?.length?s[s.length-1].x:void 0,S=typeof m=="number"&&isFinite(m)?this.angularDiff(c,m):Number.NaN,D=typeof _=="number"&&isFinite(_)?this.angularDiff(c,_):Number.NaN,b=Number.isFinite(S)||Number.isFinite(D)?Math.max(Number.isFinite(S)?S:0,Number.isFinite(D)?D:0):Number.NaN;if(!Number.isFinite(b)){let x=n?t:o?a:i,E=Math.min(30,x?.length??0);if(E>1){let C=x.slice(x.length-E).map(y=>y.x).filter(y=>typeof y=="number"&&isFinite(y));C.length&&(b=C.reduce((y,L)=>Math.max(y,this.angularDiff(c,L)),0));}}b=Math.max(b||0,15);let N=2*b/4,T=this.niceStepFromMantissas(N,[1,1.5,2,2.5,5,7.5,10]),p=c-2*T,g=c+2*T,l=e.options.scales;l.x&&(l.x.min=p,l.x.max=g,l.x.ticks=z(G({},l.x.ticks??{}),{stepSize:T})),this.xCenter=c,this.xStep=T;}let r=e.data.datasets[7]?.data;if(r&&r.length){let h=r.length-1,s=r[h]?.x??0,m=e.data.datasets[8].data[h]?.x??s,_=e.data.datasets[9].data[h]?.x??s,S=Math.abs(s-m),D=Math.abs(_-s),b=Math.max(S,D);b=Math.max(b,.5);let N=2*b/4,T=this.niceStepFromMantissas(N,[1,2,2.5,5,10]),p=s-2*T,g=s+2*T,l=e.options.scales;l.xSpeed&&(l.xSpeed.min=p,l.xSpeed.max=g,l.xSpeed.ticks=z(G({},l.xSpeed.ticks??{}),{stepSize:T})),this.xCenterSpeed=s,this.xStepSpeed=T;}let d=this.getWindowMs(this.datasetConfig?.timeScaleFormat);if(e.data.datasets[0].data.length>0){let h=Date.now();e.data.datasets.forEach(S=>{S.data.forEach(D=>{let b=D.ts??D.y;D.y=Math.max(0,Math.min(d,h-b));});});let s=e.options.scales;s.y&&(s.y.min=0,s.y.max=d);let m;switch(this.datasetConfig?.timeScaleFormat){case "Last Minute":m=15e3;break;case "Last 5 Minutes":m=6e4;break;case "Last 30 Minutes":m=5*6e4;break;default:m=d/5;break}if(s.y){let S=G({},s.y.ticks??{});delete S.count,S.stepSize=m,s.y.ticks=S;}}}getWindowMs(e){switch(e){case "Last 30 Minutes":return 30*6e4;case "Last 5 Minutes":return 5*6e4;case "Last Minute":return 6e4;default:return 6e4}}lineGradientForAxis(e,t,a){let i=t.chartArea;if(!i)return null;let n=t.scales?.[a];if(!n)return null;let o=t.options?.scales,u=n,c=o?.[a]?.min??u.min,r=o?.[a]?.max??u.max;if(typeof c!="number"||typeof r!="number"||!isFinite(c)||!isFinite(r))return null;let d=(c+r)/2,f=n.getPixelForValue(d),h=Math.max(0,Math.min(1,(f-i.left)/i.width)),s=e.createLinearGradient(i.left,0,i.right,0);return s.addColorStop(0,this.theme().port),s.addColorStop(h,this.theme().port),s.addColorStop(h,this.theme().starboard),s.addColorStop(1,this.theme().starboard),s}setDatasetsColors(){this.lineChartData.datasets.forEach(e=>{e.label==="Value"&&(e.borderColor=this.getThemeColors().valueLine,e.backgroundColor=this.getThemeColors().valueFill),e.label==="Value Speed"&&(e.borderColor=this.getThemeColors().valueLine,e.backgroundColor=this.getThemeColors().valueFill);});}getThemeColors(){let e=this.runtime?.options()?.color,t={valueLine:"",valueFill:"",averageLine:"",averageFill:"",averageChartLine:"",chartLabel:"",chartValue:""};switch(e){case "contrast":t.valueLine=this.theme().contrastDim,t.valueFill=this.theme().contrastDimmer,t.averageLine=this.theme().contrast,t.averageFill=this.theme().contrast,t.chartValue=this.theme().contrast,t.averageChartLine=this.theme().contrast,t.chartLabel=this.theme().contrastDim;break;case "blue":t.valueLine=this.theme().blueDim,t.valueFill=this.theme().blueDimmer,t.averageLine=this.theme().blue,t.averageFill=this.theme().blue,t.chartValue=this.theme().blue,t.averageChartLine=this.theme().blueDim,t.chartLabel=this.theme().blueDim;break;case "green":t.valueLine=this.theme().greenDim,t.valueFill=this.theme().greenDimmer,t.averageLine=this.theme().green,t.averageFill=this.theme().green,t.chartValue=this.theme().green,t.averageChartLine=this.theme().greenDim,t.chartLabel=this.theme().greenDim;break;case "pink":t.valueLine=this.theme().pinkDim,t.valueFill=this.theme().pinkDimmer,t.averageLine=this.theme().pink,t.averageFill=this.theme().pink,t.chartValue=this.theme().pink,t.averageChartLine=this.theme().pinkDim,t.chartLabel=this.theme().pinkDim;break;case "orange":t.valueLine=this.theme().orangeDim,t.valueFill=this.theme().orangeDimmer,t.averageLine=this.theme().orange,t.averageFill=this.theme().orange,t.chartValue=this.theme().orange,t.averageChartLine=this.theme().orangeDim,t.chartLabel=this.theme().orangeDim;break;case "purple":t.valueLine=this.theme().purpleDim,t.valueFill=this.theme().purpleDimmer,t.averageLine=this.theme().purple,t.averageFill=this.theme().purple,t.chartValue=this.theme().purple,t.averageChartLine=this.theme().purpleDim,t.chartLabel=this.theme().purpleDim;break;case "grey":t.valueLine=this.theme().greyDim,t.valueFill=this.theme().greyDimmer,t.averageLine=this.theme().grey,t.averageFill=this.theme().grey,t.chartValue=this.theme().grey,t.averageChartLine=this.theme().greyDim,t.chartLabel=this.theme().greyDim;break;case "yellow":t.valueLine=this.theme().yellowDim,t.valueFill=this.theme().yellowDimmer,t.averageLine=this.theme().yellow,t.averageFill=this.theme().yellow,t.chartValue=this.theme().yellow,t.averageChartLine=this.theme().yellowDim,t.chartLabel=this.theme().yellowDim;break}return t}nearlyEqual(e,t,a=1e-6){if(!Number.isFinite(e)||!Number.isFinite(t))return false;let i=Math.max(1,Math.max(Math.abs(e),Math.abs(t)));return Math.abs(e-t)<=a*i}resolveTickColor(e,t,a){let n=t.options.ticks?.color;return typeof n=="function"?n({chart:e,scale:t,tick:{value:a}})??Wl.defaults.color:typeof n=="string"?n:Wl.defaults.color}axisTopLabelY(e){return e.options?.position==="top"?e.top+4:e.bottom+2}ngOnDestroy(){this._dsDirectionSub?.unsubscribe(),this._dsSpeedSub?.unsubscribe(),this._chartUpdateRafId!=null&&(cancelAnimationFrame(this._chartUpdateRafId),this._chartUpdateRafId=null),this.chart?.destroy();let e=this.widgetDataChart?.()?.nativeElement;this.canvasService.releaseCanvas(e,{clear:true,removeFromDom:true});}static \u0275fac=function(t){return new(t||O)};static \u0275cmp=JD({type:O,selectors:[["widget-windtrends-chart"]],viewQuery:function(t,a){t&1&&eg(a.widgetDataChart,tt,5,Lr),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:0,consts:[["widgetDataChart",""],[2,"z-index","inherit"]],template:function(t,a){t&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%}"]})}return O})();export{mt as WidgetWindTrendsChartComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {p as p$1}from'./chunk-CaD3zVfK.js';import {G as Gt,L as Lt}from'./chunk-B6AwCAvV.js';import {u}from'./chunk-BgyxBAyq.js';import {k}from'./chunk-DfGLo6Tb.js';import {d1 as Hj,w,du as p,dv as rt,dD as _,bu as ut,$ as $j,a6 as Lr,v as vt,D as Dt,F as Fa,dn as ge,J as JD,_ as _w,M as Mw,f as eg,K as Kw,h as Fw,P as Pi,k as Qh,u as ul,g as qw,B as Bh,an as Hh,l as ud,m as dd,dx as n$1}from'./main-BNR44HGB.js';import {c}from'./chunk-D_wrJJxl.js';var L=["radialGauge"];function F(n,q){if(n&1){let t=Fw();Pi(0,"radial-gauge",2,0),Qh("resizeChange",function(a){ud(t);let e=qw();return dd(e.onResized(a))}),ul();}if(n&2){let t=qw();Bh("options",t.gaugeOptions)("value",t.displayValue()),Hh("value-text",t.textValue());}}var ne=(()=>{class n{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);metadata=w(_);unitsService=w(ut);static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:true,displayName:"Gauge Label",filterSelfPaths:true,paths:{gaugePath:{description:"Numeric Data",path:null,source:null,pathType:"number",suppressBootstrapNull:true,isPathConfigurable:true,showPathSkUnitsFilter:true,pathSkUnitsFilter:null,convertUnitTo:"unitless",sampleTime:500}},displayScale:{lower:0,upper:100,type:"linear"},gauge:{type:"ngRadial",subType:"measuring",highlightsWidth:5,scaleStart:180,barStartPosition:"left",enableTicks:true,enableProgressbar:true,enableNeedle:true},numInt:1,numDecimal:0,enableTimeout:false,color:"contrast",dataTimeout:5,ignoreZones:false};LINE="line";ANIMATION_TARGET_NEEDLE="needle";ngGauge=$j("radialGauge");gauge=$j("radialGauge",{read:Lr});value=vt(void 0);displayValue=Dt(()=>this.value()??0);shouldRenderGauge=Dt(()=>this.value()!==void 0);textValue=vt("--");colorStrokeTicks=vt("");gaugeBootstrapped=vt(false);animationEnabled=Dt(()=>this.gaugeBootstrapped());normalizedConfig=Dt(()=>this.runtime.options()??n.DEFAULT_CONFIG);gaugePathConfig=Dt(()=>this.normalizedConfig().paths?.gaugePath);adjustedScale=Dt(()=>{let t=this.normalizedConfig();return t.gauge?.subType==="capacity"?{min:t.displayScale?.lower??0,max:t.displayScale?.upper??100,majorTicks:[]}:p$1(t.displayScale?.lower??0,t.displayScale?.upper??100,t.gauge?.barStartPosition==="right")});highlights=Dt(()=>{let t=this.metadata.zones(),i=this.normalizedConfig(),a=this.theme(),e=this.gaugePathConfig();if(!t?.length)return [];if(!a)return [];if(i.ignoreZones)return [];if(i.gauge?.subType!=="measuring")return [];if(!e)return [];let o=this.adjustedScale(),r=i.gauge?.barStartPosition==="right";return k(t,a,e.convertUnitTo??"",this.unitsService,o.min,o.max,r)});displayName=Dt(()=>this.normalizedConfig().displayName??"Gauge Label");pathDataState=vt(null);viewReady=vt(false);gaugeOptions={};constructor(){Fa(()=>{let t=this.normalizedConfig(),i=this.theme(),a=this.gaugePathConfig();!i||!a?.path||ge(()=>this.streams.observe("gaugePath",e=>{e.state!==this.pathDataState()&&this.pathDataState.set(e.state||null);let o=e?.data?.value??null;if(o==null)this.value.set(t.displayScale?.lower??0),this.textValue.set("--");else {let r=t.displayScale?.lower??0,h=t.displayScale?.upper??100,f=Math.min(Math.max(o,r),h);this.value.set(f),this.textValue()==="--"&&this.textValue.set("");}}));}),Fa(()=>{this.normalizedConfig().ignoreZones||ge(()=>this.metadata.observe("gaugePath"));}),Fa(()=>{let t=this.highlights();this.viewReady()&&ge(()=>{try{if(!t.length)this.ngGauge()?.update({highlights:[]});else {let i=JSON.stringify(t);this.ngGauge()?.update({highlights:i,highlightsWidth:this.normalizedConfig().gauge?.highlightsWidth});}}catch(i){}});}),Fa(()=>{let t=this.normalizedConfig(),i=this.theme(),a=this.adjustedScale();i&&ge(()=>{if(this.buildGaugeOptions(t,i,a),this.viewReady())try{this.ngGauge()?.update(this.gaugeOptions);}catch(e){}});}),Fa(()=>{let t=this.ngGauge();!t||this.gaugeBootstrapped()||ge(()=>{try{requestAnimationFrame(()=>{this.gaugeBootstrapped.set(!0);try{t.update({animation:!0,animatedValue:!0});}catch(i){}});}catch(i){}});}),Fa(()=>{let t=this.pathDataState();this.viewReady()&&ge(()=>{let i=this.normalizedConfig(),a=this.theme();if(!a||i.ignoreZones)return;let e={},o=c(i.color??"contrast",a);switch(t){case n$1.Alarm:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=a.zoneAlarm,e.colorValueText=a.zoneAlarm;break;case n$1.Warn:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=a.zoneWarn,e.colorValueText=a.zoneWarn;break;case n$1.Alert:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=a.zoneAlert,e.colorValueText=a.zoneAlert;break;default:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=i.gauge?.subType==="measuring"?o.color:o.dim,e.colorValueText=o.color;}try{this.ngGauge()?.update(e);}catch(r){}});});}ngAfterViewInit(){this.viewReady.set(true),this.setCanvasSize();try{this.ngGauge()?.update(this.gaugeOptions);}catch(t){}}onResized(t){let i={height:t.contentRect.height,width:t.contentRect.width};try{this.ngGauge()?.update(i);}catch(a){}}setCanvasSize(){let t=this.gauge()?.nativeElement;if(!t)return;let i=t.getBoundingClientRect(),a={height:i.height,width:i.width};try{this.ngGauge()?.update(a);}catch(e){}}buildGaugeOptions(t,i,a){let e={},o=this.gaugePathConfig(),r=t.gauge??n.DEFAULT_CONFIG.gauge;e.title=this.displayName(),e.minValue=a.min,e.maxValue=a.max,e.units=o?.convertUnitTo??"",e.highlights=[];let h=this.highlights();h.length&&(e.highlights=JSON.stringify(h),e.highlightsWidth=t.gauge?.highlightsWidth),e.fontTitle="Roboto",e.fontTitleWeight="bold",e.fontUnits="Roboto",e.fontUnitsSize=25,e.fontUnitsWeight="normal",e.barStrokeWidth=0,e.barShadow=0,e.colorBarStroke="",e.fontValue="Roboto",e.fontValueWeight="bold",e.valueTextShadow=false,e.colorValueBoxShadow="",e.fontNumbers="Roboto",e.fontNumbersWeight="bold",e.valueInt=t.numInt??1,e.valueDec=t.numDecimal??2,e.majorTicksInt=e.valueInt,e.majorTicksDec=e.valueDec,e.highlightsWidth=t.gauge?.highlightsWidth,e.animation=this.animationEnabled(),e.animateOnInit=false,e.animatedValue=this.animationEnabled(),e.animationRule="linear";let f=o?.sampleTime??500;e.animationDuration=f-25,e.colorBorderShadow=false,e.colorBorderOuter=i.cardColor,e.colorBorderOuterEnd="",e.colorBorderMiddle=i.cardColor,e.colorBorderMiddleEnd="",e.colorPlate=e.colorPlateEnd=i.cardColor,e.colorBar=i.background;let g=c(t.color??"contrast",i);e.barProgress=t.gauge?.enableProgressbar,e.colorBarProgress=g.color,e.colorNeedle=g.color,e.colorNeedleEnd=g.color,e.needleShadow=true,e.colorNeedleShadowUp="black",e.colorNeedleShadowDown="black",e.colorNeedleCircleInner=e.colorPlate,e.colorNeedleCircleInnerEnd=e.colorPlate,e.colorNeedleCircleOuter=e.colorPlate,e.colorNeedleCircleOuterEnd=e.colorPlate,e.colorTitle=i.contrastDim,e.colorUnits=i.contrastDim,e.colorValueText=g.color,this.colorStrokeTicks.set(i.contrastDim),e.colorMinorTicks=i.contrastDim,e.animationTarget=this.ANIMATION_TARGET_NEEDLE,e.useMinPath=false,r.subType==="capacity"?(e.fontTitleSize=40,e.valueBox=true,e.fontValueSize=60,e.valueBoxWidth=10,e.valueBoxBorderRadius=5,e.valueBoxStroke=0,e.colorValueBoxBackground="",e.colorMajorTicks=e.colorPlate,e.colorNumbers=e.colorMinorTicks="",e.barWidth=20,e.colorBarProgress=g.dim,e.needle=r.enableNeedle,e.needleType=this.LINE,e.needleWidth=2,e.needleStart=75,e.needleEnd=95,e.needleCircleSize=1,e.needleCircleInner=false,e.needleCircleOuter=false,e.ticksAngle=360,e.startAngle=r.scaleStart||180,e.majorTicks=0,e.exactTicks=true,e.strokeTicks=false,e.minorTicks=0,e.numbersMargin=0,e.fontNumbersSize=0,e.borders=true,e.borderOuterWidth=2,e.borderMiddleWidth=1,e.borderInnerWidth=0,e.borderShadowWidth=0):(e.fontTitleSize=24,e.barWidth=15,e.valueBox=true,e.fontValueSize=60,e.valueBoxWidth=100,e.valueBoxBorderRadius=0,e.valueBoxStroke=0,e.colorValueBoxBackground="",e.needle=r.enableNeedle,e.needleType=this.LINE,e.needleWidth=2,e.needleStart=0,e.needleEnd=95,e.needleCircleSize=10,e.needleCircleInner=false,e.needleCircleOuter=false,e.ticksAngle=270,e.startAngle=45,e.barStartPosition=r.barStartPosition||"left",r.enableTicks?(e.strokeTicks=true,e.majorTicks=a.majorTicks,e.minorTicks=2,e.exactTicks=false,e.numbersMargin=3,e.fontNumbersSize=15,e.colorMajorTicks=i.contrastDim,e.colorNumbers=i.contrastDim):(e.strokeTicks=false,e.majorTicks=0,e.minorTicks=0,e.exactTicks=true,e.numbersMargin=0,e.fontNumbersSize=0,e.colorMajorTicks=e.colorPlate,e.colorNumbers=e.colorMinorTicks=""),e.borders=true,e.borderOuterWidth=2,e.borderMiddleWidth=1,e.borderInnerWidth=0,e.borderShadowWidth=0,e.animationTarget=this.ANIMATION_TARGET_NEEDLE,e.useMinPath=false),this.gaugeOptions=e;}static \u0275fac=function(i){return new(i||n)};static \u0275cmp=JD({type:n,selectors:[["widget-gauge-ng-radial"]],viewQuery:function(i,a){i&1&&eg(a.ngGauge,L,5)(a.gauge,L,5,Lr),i&2&&Kw(2);},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:1,vars:1,consts:[["radialGauge",""],["kipResizeObserver","",3,"options","value"],["kipResizeObserver","",3,"resizeChange","options","value"]],template:function(i,a){i&1&&_w(0,F,2,3,"radial-gauge",1),i&2&&Mw(a.shouldRenderGauge()?0:-1);},dependencies:[u,Gt,Lt],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%} radial-gauge{display:block;position:relative;width:100%;min-width:8px;height:100%;overflow:clip} radial-gauge>canvas{display:block;position:absolute;height:100%;width:100%;left:50%;top:50%;transform:translate(-50%,-50%);padding:0}"]})}return n})();export{ne as WidgetGaugeNgRadialComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {g as ge$1}from'./chunk-TakPRI3t.js';import {d1 as Hj,w,du as p,C as Ff,ao as ue,bu as ut$1,G as Gi,aR as lt$1,a as G,$ as $j,v as vt$1,D as Dt,dG as rn,F as Fa,dn as ge,dH as ac,cw as z,cv as G$1,dI as cn,dJ as nc,dK as qn,dL as zn,dM as pa,J as JD,O as Op,R as Rp,y as yt$1,b as wt,cG as Ht,cH as R,cI as ee,cJ as Nt,cK as Lt,cR as zt,bg as mt$1,P as Pi,k as Qh,_ as _w,u as ul,T as TT,cn as wd,c as $h,cV as Td,cf as xh,bl as Jw,e as EE,B as Bh,an as Hh,M as Mw,s as sg,f as eg,K as Kw,aS as De,aY as xe,ab as te,aj as zm,a_ as Gp,cO as eu,aI as ms,dN as Q,h as Fw,g as qw,X as xw,Y as Aw,bp as gl,dj as Nw,d as ig,aA as gg,l as ud,m as dd,dO as fp}from'./main-BNR44HGB.js';import {u}from'./chunk-BgyxBAyq.js';import {c}from'./chunk-D_wrJJxl.js';var K=false,Je=250,it=600*1e3,st=500,nt=15e3,rt=["atons.urn:mrn:imo:mmsi:*","shore.basestations.urn:mrn:imo:mmsi:*","vessels.urn:mrn:imo:mmsi:*","sar.urn:mrn:imo:mmsi:*"],ot=[{prefix:"atons.urn:mrn:imo:mmsi:",type:"aton"},{prefix:"shore.basestations.urn:mrn:imo:mmsi:",type:"basestation"},{prefix:"vessels.urn:mrn:imo:mmsi:",type:"vessel"},{prefix:"sar.urn:mrn:imo:mmsi:",type:"sar"}],at="self.navigation.*",et=(()=>{class l{data=w(De);destroyRef=w(xe);tracks=new Map;contextIndex=new Map;mmsiIndex=new Map;maxTargets=st;targetTtlMs=it;targetsDirty$=new te;ownShipDirty$=new te;pendingOwnShip={};_targets=vt$1([]);_ownShip=vt$1({});_hasCollisionRiskData=vt$1(false);targets=this._targets.asReadonly();ownShip=this._ownShip.asReadonly();hasCollisionRiskData=this._hasCollisionRiskData.asReadonly();getBearingTrue(e,t){if(typeof e.latitude!="number"||typeof e.longitude!="number"||typeof t.latitude!="number"||typeof t.longitude!="number")return null;let i=e.latitude*Math.PI/180,s=t.latitude*Math.PI/180,r=(t.longitude-e.longitude)*Math.PI/180,o=Math.sin(r)*Math.cos(s),n=Math.cos(i)*Math.sin(s)-Math.sin(i)*Math.cos(s)*Math.cos(r),d=Math.atan2(o,n)*180/Math.PI;return this.wrapDegrees(d)}constructor(){zm(...rt.map(t=>this.data.subscribePathTree(t))).pipe(Gp(this.destroyRef)).subscribe(t=>this.handleAisTreeUpdate(t)),this.data.subscribePathTree(at).pipe(Gp(this.destroyRef)).subscribe(t=>this.handleOwnShipTreeUpdate(t)),this.targetsDirty$.pipe(eu(Je,void 0,{leading:true,trailing:true}),Gp(this.destroyRef)).subscribe(()=>this.flushTargetsSignal()),ms(nt).pipe(Gp(this.destroyRef)).subscribe(()=>this.evictStaleTracks(Date.now())),this.ownShipDirty$.pipe(eu(Je,void 0,{leading:true,trailing:true}),Gp(this.destroyRef)).subscribe(()=>this.flushOwnShip());}handleAisTreeUpdate(e){let t=this.matchAisContext(e.path);t&&(this.applyAisUpdate({context:t.context,type:t.type,path:t.path,value:e.update.data.value,timestampMs:this.toTimestampMs(e.update.data.timestamp)}));}handleOwnShipTreeUpdate(e){if(!e.path.startsWith("self."))return;let t=e.path.slice(5);this.applyOwnShipUpdate(t,e.update.data.value);}matchAisContext(e){for(let t of ot){if(!e.startsWith(t.prefix))continue;let i=e.indexOf(".",t.prefix.length);return i===-1?null:{context:e.slice(0,i),path:e.slice(i+1),type:t.type}}return null}applyOwnShipUpdate(e,t){let i=G$1({},this.pendingOwnShip),s=this.readPositionValue(t);switch(e){case "navigation.position":s&&(i.position=s);break;case "navigation.position.latitude":{let r=this.toNumberOrUndefined(t);if(r===void 0)return;i.position=z(G$1({},i.position??{}),{latitude:r});}break;case "navigation.position.longitude":{let r=this.toNumberOrUndefined(t);if(r===void 0)return;i.position=z(G$1({},i.position??{}),{longitude:r});}break;case "navigation.headingTrue":i.headingTrue=this.toNumberOrUndefined(t);break;case "navigation.courseOverGroundTrue":i.courseOverGroundTrue=this.toNumberOrUndefined(t);break;case "navigation.speedOverGround":i.speedOverGround=this.toNumberOrUndefined(t);break;default:return}this.pendingOwnShip=i,this.ownShipDirty$.next();}flushOwnShip(){this.ownShipChanged(this._ownShip(),this.pendingOwnShip)&&this._ownShip.set(this.pendingOwnShip);}ownShipChanged(e,t){return e.headingTrue!==t.headingTrue||e.courseOverGroundTrue!==t.courseOverGroundTrue||e.speedOverGround!==t.speedOverGround||e.position?.latitude!==t.position?.latitude||e.position?.longitude!==t.position?.longitude}applyAisUpdate(e){let t=this.resolveTrack(e);if(t){switch(t.lastUpdateAt=e.timestampMs,e.path.startsWith("navigation.closestApproach.")&&this.isVesselLike(t)&&!t.closestApproach&&(t.closestApproach={}),e.path){case "mmsi":this.applyMmsi(t,e.value);break;case "name":t.name=this.toStringOrUndefined(e.value);break;case "communication.callsignVhf":this.isVesselLike(t)&&(t.callsign=this.toStringOrUndefined(e.value));break;case "navigation.destination":case "navigation.destination.commonName":this.isVesselLike(t)&&(t.destination=this.toStringOrUndefined(e.value));break;case "navigation.destination.eta":this.isVesselLike(t)&&(t.eta=this.toStringOrUndefined(e.value));break;case "design.beam":this.isVesselLike(t)&&(t.design=z(G$1({},t.design??{}),{beam:this.toNumberOrUndefined(e.value)}));break;case "design.length.overall":this.isVesselLike(t)&&(t.design=z(G$1({},t.design??{}),{length:z(G$1({},t.design?.length??{}),{overall:this.toNumberOrUndefined(e.value)})}));break;case "design.length.hull":this.isVesselLike(t)&&(t.design=z(G$1({},t.design??{}),{length:z(G$1({},t.design?.length??{}),{hull:this.toNumberOrUndefined(e.value)})}));break;case "design.length.waterline":this.isVesselLike(t)&&(t.design=z(G$1({},t.design??{}),{length:z(G$1({},t.design?.length??{}),{waterline:this.toNumberOrUndefined(e.value)})}));break;case "design.draft.maximum":this.isVesselLike(t)&&(t.design=z(G$1({},t.design??{}),{draft:z(G$1({},t.design?.draft??{}),{maximum:this.toNumberOrUndefined(e.value)})}));break;case "design.draft.minimum":this.isVesselLike(t)&&(t.design=z(G$1({},t.design??{}),{draft:z(G$1({},t.design?.draft??{}),{minimum:this.toNumberOrUndefined(e.value)})}));break;case "design.draft.current":this.isVesselLike(t)&&(t.design=z(G$1({},t.design??{}),{draft:z(G$1({},t.design?.draft??{}),{current:this.toNumberOrUndefined(e.value)})}));break;case "design.draft.canoe":this.isVesselLike(t)&&(t.design=z(G$1({},t.design??{}),{draft:z(G$1({},t.design?.draft??{}),{canoe:this.toNumberOrUndefined(e.value)})}));break;case "registrations.imo":this.isVesselLike(t)&&(t.imo=this.toStringOrUndefined(e.value));break;case "navigation.courseOverGroundTrue":this.isVesselLike(t)&&(t.courseOverGroundTrue=this.toNumberOrUndefined(e.value));break;case "navigation.headingTrue":this.isVesselLike(t)&&(t.headingTrue=this.toNumberOrUndefined(e.value));break;case "navigation.rateOfTurn":this.isVesselLike(t)&&(t.rateOfTurn=this.toNumberOrUndefined(e.value));break;case "navigation.specialManeuver":this.isVesselLike(t)&&(t.specialManeuver=this.toStringOrUndefined(e.value));break;case "navigation.speedOverGround":this.isVesselLike(t)&&(t.speedOverGround=this.toNumberOrUndefined(e.value));break;case "navigation.state":this.isVesselLike(t)&&(t.navState=this.toStringOrUndefined(e.value));break;case "sensors.ais.class":t.ais.class=this.normalizeAisClass(e.value);break;case "sensors.ais.status":{let i=this.normalizeAisStatus(e.value);if(!i)break;if(i==="remove"){this.removeTrack(t);return}t.ais.status=i;}break;case "sensors.ais.fromBow":this.isVesselLike(t)&&(t.fromBow=this.toNumberOrUndefined(e.value));break;case "sensors.ais.fromCenter":this.isVesselLike(t)&&(t.fromCenter=this.toNumberOrUndefined(e.value));break;case "navigation.position.latitude":{let i=this.toNumberOrUndefined(e.value);if(i===void 0)break;t.position=z(G$1({},t.position??{}),{latitude:i}),t.lastPositionAt=e.timestampMs;}break;case "navigation.position.longitude":{let i=this.toNumberOrUndefined(e.value);if(i===void 0)break;t.position=z(G$1({},t.position??{}),{longitude:i}),t.lastPositionAt=e.timestampMs;}break;case "navigation.position.altitude":{let i=this.toNumberOrUndefined(e.value);t.position&&(t.position=z(G$1({},t.position),{altitude:i}));}break;case "navigation.position":{let i=this.readPositionValue(e.value);i&&(t.position=i,t.lastPositionAt=e.timestampMs);}break;case "atonType.id":this.isAton(t)&&(t.typeId=this.toNumberOrUndefined(e.value));break;case "atonType.name":this.isAton(t)&&(t.typeName=this.toStringOrUndefined(e.value));break;case "virtual":this.isAton(t)&&(t.virtual=!!e.value);break;case "offPosition":this.isAton(t)&&(t.offPosition=!!e.value);break;case "design.aisShipType.id":this.isVesselLike(t)&&(t.design=z(G$1({},t.design??{}),{aisShipType:z(G$1({},t.design?.aisShipType??{}),{id:this.toNumberOrUndefined(e.value)})}));break;case "design.aisShipType.name":this.isVesselLike(t)&&(t.design=z(G$1({},t.design??{}),{aisShipType:z(G$1({},t.design?.aisShipType??{}),{name:this.toStringOrUndefined(e.value)})}));break;case "navigation.closestApproach.distance":this.isVesselLike(t)&&t.closestApproach&&(t.closestApproach.distance=this.toNumberOrUndefined(e.value));break;case "navigation.closestApproach.timeTo":this.isVesselLike(t)&&t.closestApproach&&(t.closestApproach.timeTo=this.toNumberOrUndefined(e.value));break;case "navigation.closestApproach.range":this.isVesselLike(t)&&t.closestApproach&&(t.closestApproach.range=this.toNumberOrUndefined(e.value));break;case "navigation.closestApproach.bearing":this.isVesselLike(t)&&t.closestApproach&&(t.closestApproach.bearing=this.toNumberOrUndefined(e.value));break;case "navigation.closestApproach.collisionRiskRating":this.isVesselLike(t)&&t.closestApproach&&(t.closestApproach.collisionRiskRating=this.toNumberOrUndefined(e.value));break}this.updateTargetsSignal();}}resolveTrack(e){let t=this.contextIndex.get(e.context),i=e.timestampMs,s=t?this.tracks.get(t):null;if(s)return s;let r=this.createTrack(e.context,e.type,i,void 0);return this.contextIndex.set(e.context,r.id),r}createTrack(e,t,i,s){let r=this.buildTrackId(s??e),o=this.buildBaseTarget(e,t,i,s,r),n;switch(t){case "vessel":n=z(G$1({},o),{type:"vessel",closestApproach:{}});break;case "sar":n=z(G$1({},o),{type:"sar",closestApproach:{}});break;case "aton":n=z(G$1({},o),{type:"aton"});break;default:n=z(G$1({},o),{type:"basestation"});break}return this.tracks.set(n.id,n),s&&this.addMmsiIndex(s,n.id),this.enforceTargetCap(),this.updateTargetsSignal(),n}buildTrackId(e){if(!this.tracks.has(e))return e;let t=1;for(;this.tracks.has(`${e}-${t}`);)t+=1;return `${e}-${t}`}applyMmsi(e,t){let i=this.toStringOrUndefined(t);if(!i)return;let s=this.getTracksByMmsi(i).filter(r=>r.id!==e.id);s.length&&(this.markConflict(i),K),e.mmsi&&e.mmsi!==i&&this.removeMmsiIndex(e.mmsi,e.id),e.mmsi=i,this.addMmsiIndex(i,e.id);}removeTrack(e){this.tracks.delete(e.id),e.mmsi&&this.removeMmsiIndex(e.mmsi,e.id);for(let[t,i]of this.contextIndex.entries())i===e.id&&this.contextIndex.delete(t);this.updateTargetsSignal();}updateTargetsSignal(){this.targetsDirty$.next();}enforceTargetCap(){for(;this.tracks.size>this.maxTargets;){let e=null;for(let t of this.tracks.values())(!e||t.lastUpdateAt<e.lastUpdateAt)&&(e=t);if(!e)break;this.removeTrack(e);}}evictStaleTracks(e){let t=e-this.targetTtlMs,i=[];for(let s of this.tracks.values())s.lastUpdateAt<t&&i.push(s);for(let s of i)this.removeTrack(s);this.enforceTargetCap();}flushTargetsSignal(){let e=Array.from(this.tracks.values()).filter(i=>!!i.mmsi||!!i.position),t=e.some(i=>{if(!this.isVesselLike(i))return false;let s=i.closestApproach??{};return Object.prototype.hasOwnProperty.call(s,"collisionRiskRating")});this._targets.set(e),this._hasCollisionRiskData.set(t);}getTracksByMmsi(e){let t=this.mmsiIndex.get(e);return t?Array.from(t).map(i=>this.tracks.get(i)).filter(i=>!!i):[]}addMmsiIndex(e,t){this.mmsiIndex.has(e)||this.mmsiIndex.set(e,new Set),this.mmsiIndex.get(e).add(t);}removeMmsiIndex(e,t){let i=this.mmsiIndex.get(e);i&&(i.delete(t),i.size||this.mmsiIndex.delete(e));}markConflict(e){let t=this.getTracksByMmsi(e);for(let i of t)i.conflicted=true;}normalizeAisClass(e){let t=typeof e=="string"?e.toUpperCase():"";if(t==="A")return "A";if(t==="B")return "B"}normalizeAisStatus(e){if(e==null)return;let t=String(e).toLowerCase();if(t==="unconfirmed"||t==="confirmed"||t==="lost"||t==="remove")return t}toTimestampMs(e){if(!e)return Date.now();let t=e instanceof Date?e.getTime():Date.parse(e);return Number.isFinite(t)?t:Date.now()}toNumberOrUndefined(e){let t=Number(e);return Number.isFinite(t)?t:void 0}toStringOrUndefined(e){if(e==null)return;let t=String(e).trim();return t.length?t:void 0}wrapDegrees(e){let t=e%360;return t<0?t+360:t}buildBaseTarget(e,t,i,s,r){return {id:r,context:e,type:t,ais:{class:void 0,status:"unconfirmed"},conflicted:false,mmsi:s,position:void 0,lastUpdateAt:i,lastPositionAt:void 0}}isVesselLike(e){return e.type==="vessel"||e.type==="sar"}isAton(e){return e.type==="aton"}readPositionValue(e){if(!e||typeof e!="object")return;let t=this.toNumberOrUndefined(e.latitude),i=this.toNumberOrUndefined(e.longitude);if(t===void 0||i===void 0)return;let s=this.toNumberOrUndefined(e.altitude);return {latitude:t,longitude:i,altitude:s}}static \u0275fac=function(t){return new(t||l)};static \u0275prov=Q({token:l,factory:l.\u0275fac,providedIn:"root"})}return l})();var lt=["radarSvg"],ct=["menuAnchor"],dt=["menuTrigger"],ht=(l,I)=>I.id;function ut(l,I){l&1&&(wd(),Pi(0,"svg",7),$h(1,"path",17),Pi(2,"text",18),TT(3,"N"),ul()());}function mt(l,I){l&1&&(wd(),Pi(0,"svg",7),$h(1,"path",19),ul());}function gt(l,I){if(l&1){let e=Fw();Pi(0,"button",20),Qh("click",function(){ud(e);let i=qw();return dd(i.toggleFilter("noCollisionRisk"))}),Pi(1,"mat-icon"),TT(2,"security"),ul()();}if(l&2){let e=qw();sg("is-active",e.isFilterEnabled("noCollisionRisk"));}}function pt(l,I){if(l&1){let e=Fw();Pi(0,"button",22),Qh("click",function(){let i=ud(e).$implicit,s=qw(2);return dd(s.onMenuItemSelect(i))}),$h(1,"img",23),Pi(2,"span",24),TT(3),ul()();}if(l&2){let e=I.$implicit;EE(),ig("visibility",e.iconHref?"visible":"hidden"),Hh("src",e.iconHref??null,fp),EE(2),gg(e.label);}}function ft(l,I){if(l&1&&xw(0,pt,4,4,"button",21,ht),l&2){let e=qw();Aw(e.menuItems());}}function St(l,I){if(l&1){let e=Fw();Pi(0,"button",25),TT(1,"Filter Targets"),ul(),Pi(2,"button",26),Qh("click",function(){ud(e);let i=qw();return dd(i.toggleFilter("anchoredMoored"))}),Pi(3,"mat-icon",27),TT(4),ul(),Pi(5,"span"),TT(6,"Anchored/Moored"),ul()(),Pi(7,"button",26),Qh("click",function(){ud(e);let i=qw();return dd(i.toggleFilter("allAton"))}),Pi(8,"mat-icon",27),TT(9),ul(),Pi(10,"span"),TT(11,"All AtoN"),ul()(),Pi(12,"button",26),Qh("click",function(){ud(e);let i=qw();return dd(i.toggleFilter("allButSar"))}),Pi(13,"mat-icon",27),TT(14),ul(),Pi(15,"span"),TT(16,"All but SAR"),ul()(),Pi(17,"button",26),Qh("click",function(){ud(e);let i=qw();return dd(i.toggleFilter("allVessels"))}),Pi(18,"mat-icon",27),TT(19),ul(),Pi(20,"span"),TT(21,"All Vessels"),ul()(),Pi(22,"button",28)(23,"span"),TT(24,"Vessel Type"),ul(),Pi(25,"mat-icon"),TT(26,"chevron_right"),ul()();}if(l&2){let e=qw(),t=Jw(26);EE(4),gl(" ",e.isFilterEnabled("anchoredMoored")?"check_box":"check_box_outline_blank"," "),EE(5),gl(" ",e.isFilterEnabled("allAton")?"check_box":"check_box_outline_blank"," "),EE(5),gl(" ",e.isFilterEnabled("allButSar")?"check_box":"check_box_outline_blank"," "),EE(5),gl(" ",e.isFilterEnabled("allVessels")?"check_box":"check_box_outline_blank"," "),EE(3),Bh("matMenuTriggerFor",t);}}function vt(l,I){if(l&1){let e=Fw();Pi(0,"button",26),Qh("click",function(){let i=ud(e).$implicit,s=qw(2);return dd(s.toggleVesselTypeFilter(i))}),Pi(1,"mat-icon",27),TT(2),ul(),Pi(3,"span"),TT(4),ul()();}if(l&2){let e=I.$implicit,t=qw(2);EE(2),gl(" ",t.isVesselTypeFilterEnabled(e)?"check_box":"check_box_outline_blank"," "),EE(2),gg(t.formatVesselTypeLabel(e));}}function bt(l,I){if(l&1&&xw(0,vt,5,2,"button",29,Nw),l&2){let e=qw();Aw(e.vesselTypeFilters);}}function yt(l,I){l&1&&$h(0,"div",16);}var Qt=(()=>{class l{static TARGET_ICON_SIZE_PX=16;static OWN_SHIP_ICON_SIZE_PX=84;static HIT_RADIUS_PX=28;static ICON_RENDER_DEBOUNCE_MS=50;static ROTATION_SETTLE_DEADBAND_DEG=1;static ROTATION_ONLY_FRAME_MS=33;id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);ais=w(et);dialog=w(Ff);ngZone=w(ue);units=w(ut$1);settings=w(Gi);toast=w(lt$1);dashboard=w(G);static DEFAULT_CONFIG={filterSelfPaths:false,enableTimeout:false,dataTimeout:5,ais:{filters:{anchoredMoored:false,noCollisionRisk:false,allAton:false,allButSar:false,allVessels:false,vesselTypes:[]},viewMode:"course-up",rangeRings:[1,3,6,12,24,48],rangeIndex:"3",showCogVectors:true,cogVectorsMinutes:10,showLostTargets:true,showUnconfirmedTargets:true,showSelf:true},color:"grey"};svgRef=$j.required("radarSvg");menuAnchorRef=$j.required("menuAnchor");menuTrigger=$j.required("menuTrigger");hostSize=vt$1(null);renderState=null;selectedId=vt$1(null);localViewMode=vt$1(null);localRangeIndex=vt$1(null);effectiveViewMode=Dt(()=>this.localViewMode()??this.runtime.options()?.ais?.viewMode??"course-up");effectiveRangeIndex=Dt(()=>{let e=this.resolveRangeIndex(this.runtime.options()?.ais),t=this.runtime.options()?.ais?.rangeRings??[3,6,12,24,48],i=Math.max(0,t.length-1),s=this.localRangeIndex()??e;return Math.min(Math.max(s,0),i)});svg;root;ringsLayer;rotationGroup;vectorsLayer;targetsLayer;selectedLayer;ownShipLayer;viewRotationSmoothed=null;lastRotationAt=null;lastViewRotation=0;hasRenderedOnce=false;renderFrame=null;rotationFrameTimer=null;iconRenderTimer=null;iconCache=new Map;targetCache=new Map;lastOriginKey=null;ringCache=null;ownShipIconHref=null;menuItems=vt$1([]);menuPoint=null;lastRenderTargets=[];lastRenderScale=1;lastRenderSize=null;hitRadiusPx=l.HIT_RADIUS_PX;lastFiltersSignature=null;lastRenderSignature=null;ownShipVectorCache=null;filterState=vt$1({anchoredMoored:false,noCollisionRisk:false,allAton:false,allButSar:false,allVessels:false,vesselTypes:new Set});vesselTypeFilters=rn.filter(e=>e!=="vessel/self"&&e!=="vessel/unknown"&&e!=="vessel/spare");hasActiveFilters=Dt(()=>{let e=this.filterState();return e.anchoredMoored||e.allAton||e.allButSar||e.allVessels||e.vesselTypes.size>0});hasCollisionRiskData=this.ais.hasCollisionRiskData;constructor(){this.warnIfRemoteDataDisabled(),this.loadOwnShipIcon(),Fa(()=>{let e=this.hostSize(),t=this.runtime.options(),i=this.theme(),s=this.ais.targets(),r=this.ais.ownShip();!e||!t||!i||(ge(()=>{this.renderState={size:e,cfg:t,theme:i,targets:s,ownShip:r},this.syncFiltersFromConfig(t);}),this.scheduleRender());}),Fa(()=>{this.localViewMode(),this.localRangeIndex(),this.selectedId(),this.filterState(),ge(()=>{this.scheduleRender();});});}warnIfRemoteDataDisabled(){this.settings.signalKSubscribeAll||this.toast.show('AIS data is disabled in your connection. To see radar targets, go to Settings -> Options -> Connectivity, enable "Subscribe to remote sources messages", then reconnect.',0,false,"warn");}loadOwnShipIcon(){this.ngZone.runOutsideAngular(()=>{ac().then(e=>{this.ownShipIconHref=e,this.scheduleRenderDebounced();});});}ngAfterViewInit(){this.initSvg(),this.scheduleRender();}onResized(e){this.hostSize.set({width:e.width,height:e.height});}initSvg(){this.svg=ge$1(this.svgRef().nativeElement),this.svg.attr("class","ais-radar"),this.root=this.svg.append("g").attr("class","radar-root"),this.ringsLayer=this.root.append("g").attr("class","radar-rings"),this.rotationGroup=this.root.append("g").attr("class","radar-rotation"),this.vectorsLayer=this.rotationGroup.append("g").attr("class","radar-vectors"),this.targetsLayer=this.rotationGroup.append("g").attr("class","radar-targets"),this.selectedLayer=this.rotationGroup.append("g").attr("class","radar-selected"),this.ownShipLayer=this.root.append("g").attr("class","radar-ownship-layer"),this.svg.on("click",()=>{this.selectedId.set(null),this.closeTargetMenu();});}scheduleRender(){this.renderFrame===null&&this.ngZone.runOutsideAngular(()=>{this.renderFrame=requestAnimationFrame(()=>{this.renderFrame=null,this.render();});});}scheduleRenderDebounced(){this.iconRenderTimer===null&&this.ngZone.runOutsideAngular(()=>{this.iconRenderTimer=window.setTimeout(()=>{this.iconRenderTimer=null,this.scheduleRender();},l.ICON_RENDER_DEBOUNCE_MS);});}scheduleRotationOnlyRender(){this.rotationFrameTimer!==null||this.renderFrame!==null||this.ngZone.runOutsideAngular(()=>{this.rotationFrameTimer=window.setTimeout(()=>{this.rotationFrameTimer=null,this.scheduleRender();},l.ROTATION_ONLY_FRAME_MS);});}render(){if(!this.renderState||!this.svg||!this.root||!this.rotationGroup)return;let{size:e,cfg:t,theme:i,targets:s,ownShip:r}=this.renderState,o=Math.max(1,e.width),n=Math.max(1,e.height),d=Math.min(o,n)/2,u=(Math.min(o,n)-35)/Math.min(o,n),b=Math.hypot(o,n)/2/u,c$1=t.ais??{},T=c$1.rangeRings?.length?c$1.rangeRings:[3,6,12,24,48],x=this.effectiveRangeIndex(),a=T[x]??T[0],M=this.resolveRingCountForRange(a),S=this.localViewMode()??c$1.viewMode??"course-up",_=this.toDegreesIfRadians(r.courseOverGroundTrue),C=this.toDegreesIfRadians(r.headingTrue),V=_!==null||C!==null,m=S==="course-up"?_??C??0:0,B=this.viewRotationSmoothed!==null&&Math.abs(this.shortestAngleDelta(this.viewRotationSmoothed,m))<=l.ROTATION_SETTLE_DEADBAND_DEG,$=this.buildFilterStateSignature(this.filterState()),U=r.position?`${r.position.latitude},${r.position.longitude}`:"none",F={sizeKey:`${o}x${n}`,viewMode:S,rangeIndex:x,rangesKey:T.join(","),showSelf:c$1.showSelf??true,showCogVectors:c$1.showCogVectors??true,showLostTargets:c$1.showLostTargets??true,showUnconfirmedTargets:c$1.showUnconfirmedTargets??true,filtersKey:$,selectedId:this.selectedId(),targetsRef:s,ownPosKey:U,themeRef:i,color:t.color},L=!this.lastRenderSignature||!this.signaturesEqual(this.lastRenderSignature,F);if(!L&&B&&this.hasRenderedOnce)return;this.lastRenderSignature=F;let v=S==="course-up"&&V?this.smoothRotation(m):0,te=S==="course-up"?Math.abs(this.shortestAngleDelta(v,m)):0;this.lastViewRotation=v,this.svg.attr("viewBox",`${-o/2} ${-n/2} ${o} ${n}`),this.root.attr("transform",`scale(${u})`),this.rotationGroup.attr("transform",`rotate(${this.wrapDegrees(-v)})`);let me=this.wrapDegrees((_??C??0)-v);if(L){let ie=c(t.color??"contrast",i).dim;this.renderRings(M,a,d,b,v,u,c$1.showSelf??true,me,ie);}if(this.ownShipLayer?.select("g.radar-ownship").attr("transform",`rotate(${me})`),r.position&&this.hasValidPosition(r.position)&&(this.renderOwnShipVector(r,a,d,v,c$1),L)){let ie=b/d*a,W=this.buildTargets(s,r.position,a,ie,d,0,c$1);this.lastRenderTargets=W,this.lastRenderScale=u,this.lastRenderSize=e,this.renderTargetVectors(W,a,d,0,c$1),this.renderTargets(W,u),this.renderSelected(W,u);}this.raiseOwnshipAndVector(),this.hasRenderedOnce=true,te>l.ROTATION_SETTLE_DEADBAND_DEG&&(L?this.scheduleRender():this.scheduleRotationOnlyRender());}signaturesEqual(e,t){return e.sizeKey===t.sizeKey&&e.viewMode===t.viewMode&&e.rangeIndex===t.rangeIndex&&e.rangesKey===t.rangesKey&&e.showSelf===t.showSelf&&e.showCogVectors===t.showCogVectors&&e.showLostTargets===t.showLostTargets&&e.showUnconfirmedTargets===t.showUnconfirmedTargets&&e.filtersKey===t.filtersKey&&e.selectedId===t.selectedId&&e.targetsRef===t.targetsRef&&e.ownPosKey===t.ownPosKey&&e.themeRef===t.themeRef&&e.color===t.color}renderRings(e,t,i,s,r,o,n,d,u){if(!this.ringsLayer)return;let b=`${t.toFixed(3)}|${i.toFixed(3)}|${s.toFixed(3)}|${e}`;if(!this.ringCache||this.ringCache.key!==b){let m=t/Math.max(1,e),B=s/i*t,$=[];for(let v=m;v<=B+1e-6;v+=m)$.push(v);let U=$.map(v=>({value:v,radius:v/t*i})).filter(v=>v.radius<=s+1e-6),F=20,L=U.flatMap(v=>[{key:`${v.value}-top`,value:v.value,x:0,y:-v.radius+F},{key:`${v.value}-bottom`,value:v.value,x:0,y:v.radius-F}]);this.ringCache={key:b,rings:U,labels:L};}let c=this.ringCache;if(!c)return;let T=c.rings,x=this.ringsLayer.selectAll("circle.ring").data(T,m=>m.value.toString());x.enter().append("circle").attr("class","ring").merge(x).attr("r",m=>m.radius).attr("stroke",u),x.exit().remove();let a=c.labels,M=this.ringsLayer.selectAll("text.ring-label").data(a,m=>m.key);M.enter().append("text").attr("class","ring-label").merge(M).attr("x",m=>m.x).attr("y",m=>m.y).attr("text-anchor","middle").attr("dominant-baseline","middle").text(m=>`${m.value}`),M.exit().remove();let S=this.ringsLayer.selectAll("circle.radar-center").data(n?[]:[{r:Math.max(3,i*.01)}]);S.enter().append("circle").attr("class","radar-center").merge(S).attr("cx",0).attr("cy",0).attr("r",m=>m.r).attr("fill",u),S.exit().remove();let _=this.ownShipLayer.selectAll("g.radar-ownship").data(n?[{size:this.resolveOwnShipBaseSize(o)}]:[]),C=_.enter().append("g").attr("class","radar-ownship");C.append("image").attr("class","ownship-icon").attr("href",this.ownShipIconHref??null).attr("xlink:href",this.ownShipIconHref??null);let V=C.merge(_);V.attr("transform",`rotate(${d})`),V.select("image.ownship-icon").attr("href",this.ownShipIconHref??null).attr("xlink:href",this.ownShipIconHref??null).attr("display",this.ownShipIconHref?null:"none").attr("width",m=>m.size).attr("height",m=>m.size).attr("x",m=>-m.size/2).attr("y",m=>-m.size/2),_.exit().remove();}toggleViewMode(){let e=this.localViewMode()??this.runtime.options()?.ais?.viewMode??"course-up";this.localViewMode.set(e==="course-up"?"north-up":"course-up");}incrementRange(){this.localRangeIndex.set(Math.max(this.effectiveRangeIndex()-1,0));}decrementRange(){let e=this.runtime.options()?.ais?.rangeRings??[3,6,12,24,48],t=Math.max(0,e.length-1);this.localRangeIndex.set(Math.min(this.effectiveRangeIndex()+1,t));}toggleFilter(e){this.filterState.update(t=>z(G$1({},t),{[e]:!t[e]}));}toggleVesselTypeFilter(e){this.filterState.update(t=>{let i=new Set(t.vesselTypes);return i.has(e)?i.delete(e):i.add(e),z(G$1({},t),{vesselTypes:i})});}isFilterEnabled(e){return this.filterState()[e]}isVesselTypeFilterEnabled(e){return this.filterState().vesselTypes.has(e)}formatVesselTypeLabel(e){let t=e.replace("vessel/","");switch(t){case "pleasurecraft":return "Pleasure Craft";case "highspeed":return "High Speed";case "sar":return "SAR";case "law":return "Law Enforcement";default:return `${t.charAt(0).toUpperCase()}${t.slice(1)}`}}syncFiltersFromConfig(e){let t=e.ais?.filters;if(!t)return;let i=this.buildFilterSignature(t);i!==this.lastFiltersSignature&&(this.lastFiltersSignature=i,this.filterState.set({anchoredMoored:t.anchoredMoored??false,noCollisionRisk:t.noCollisionRisk??false,allAton:t.allAton??false,allButSar:t.allButSar??false,allVessels:t.allVessels??false,vesselTypes:new Set(t.vesselTypes??[])}));}buildFilterSignature(e){let t=[...e?.vesselTypes??[]].sort();return JSON.stringify({anchoredMoored:e?.anchoredMoored??false,noCollisionRisk:e?.noCollisionRisk??false,allAton:e?.allAton??false,allButSar:e?.allButSar??false,allVessels:e?.allVessels??false,vesselTypes:t})}buildFilterStateSignature(e){let t=[...e.vesselTypes].sort();return JSON.stringify({anchoredMoored:e.anchoredMoored,noCollisionRisk:e.noCollisionRisk,allAton:e.allAton,allButSar:e.allButSar,allVessels:e.allVessels,vesselTypes:t})}resolveRingCountForRange(e){return [3].find(i=>this.isNiceStep(e/i))??4}isNiceStep(e){return [.5,1,2,2.5,3,4,5,6,8,10,12,15,20,25].some(i=>Math.abs(e-i)<1e-6)}resolveRangeIndex(e){return e?Number(e.rangeIndex):0}buildTargets(e,t,i,s,r,o,n){let d=n.showLostTargets??true,u=n.showUnconfirmedTargets??true,b=`${t.latitude?.toFixed(6)}|${t.longitude?.toFixed(6)}`;this.lastOriginKey!==b&&(this.targetCache.clear(),this.lastOriginKey=b);let c=new Set;for(let a of e)c.add(a.id);for(let a of this.targetCache.keys())c.has(a)||this.targetCache.delete(a);for(let a of this.iconCache.keys())c.has(a)||this.iconCache.delete(a);let T=[];for(let a of e)a.ais.status==="remove"&&(this.targetCache.delete(a.id),this.iconCache.delete(a.id),this.selectedId()===a.id&&this.selectedId.set(null));let x=e.filter(a=>a.ais.status==="remove"||a.ais.status==="lost"&&!d||a.ais.status==="unconfirmed"&&!u||!a.position||!this.hasValidPosition(a.position)?false:!this.shouldFilterTarget(a));for(let a of x){let M=this.buildTrackSignature(a),S=this.targetCache.get(a.id);if(!S||S.signature!==M){let F=this.distanceNm(t,a.position),L=this.ais.getBearingTrue(t,a.position)??0,v=this.toDegreesIfRadians(this.isVesselLike(a)?a.headingTrue:null),te=this.toDegreesIfRadians(this.isVesselLike(a)?a.courseOverGroundTrue:null);S={signature:M,distanceNm:F,bearing:L,trackHeading:v,trackCog:te},this.targetCache.set(a.id,S);}if(S.distanceNm>s)continue;let{href:_,scale:C}=this.resolveIconCached(a),V=this.wrapDegrees(S.bearing-o),{x:m,y:B}=this.polarToCartesian(V,S.distanceNm,i,r),$=a.type==="aton"||a.type==="basestation"?0:this.wrapDegrees((S.trackHeading??S.trackCog??0)-o),U=this.buildClassName({id:a.id,status:a.ais.status,aisClass:a.ais.class,type:a.type,navState:this.isVesselLike(a)?a.navState:void 0});T.push({id:a.id,raw:a,x:m,y:B,heading:$,status:a.ais.status,aisClass:a.ais.class,type:a.type,iconHref:_,iconScale:C,navState:this.isVesselLike(a)?a.navState:void 0,sog:this.isVesselLike(a)?a.speedOverGround:void 0,cog:S.trackCog??null,className:U});}return T}renderTargetVectors(e,t,i,s,r){if(!this.vectorsLayer)return;let o=r.showCogVectors??true,n=Math.max(6,i*.04),d=(r.cogVectorsMinutes??5)*60,u=n*.8,b=[];for(let c of e)if(this.isVesselLike(c.raw)&&!this.isStationaryNavState(c.raw.navState)&&o&&typeof c.sog=="number"&&typeof c.cog=="number"){let T=this.wrapDegrees(c.cog-s),x=this.offsetPoint(c.x,c.y,T,u),a=c.sog*d/1852,M=Math.max(0,a/t*i-u);if(M<=0)continue;let S=this.offsetPoint(x.x,x.y,T,M),_=this.resolveTargetVectorStroke(c.raw);b.push({id:c.id,x1:x.x,y1:x.y,x2:S.x,y2:S.y,className:c.className,stroke:_});}this.renderVectorLines(this.vectorsLayer,"motion-vector",b);}renderOwnShipVector(e,t,i,s,r){if(!this.ownShipLayer)return;let o=Math.max(6,i*.04),n=(r.cogVectorsMinutes??5)*60,d=o*.8,u=[];if(!(r.showSelf??true)){this.ownShipVectorCache=null,this.renderVectorLines(this.ownShipLayer,"ownship-vector",u);return}let c=this.toDegreesIfRadians(e.courseOverGroundTrue),T=e.speedOverGround;if(c===null||typeof T!="number"){this.ownShipVectorCache=null,this.renderVectorLines(this.ownShipLayer,"ownship-vector",u);return}let x=T*n/1852,a=Math.max(0,x/t*i-d);if(a<=0){this.ownShipVectorCache=null,this.renderVectorLines(this.ownShipLayer,"ownship-vector",u);return}let M=[c.toFixed(6),T.toFixed(6),t.toFixed(6),i.toFixed(6),n,d.toFixed(6)].join("|");if(!this.ownShipVectorCache||this.ownShipVectorCache.key!==M){let C=this.wrapDegrees(c),V=this.offsetPoint(0,0,C,d),m=this.offsetPoint(V.x,V.y,C,a);this.ownShipVectorCache={key:M,tipX:V.x,tipY:V.y,endX:m.x,endY:m.y};}let S=this.rotatePoint(this.ownShipVectorCache.tipX,this.ownShipVectorCache.tipY,-s),_=this.rotatePoint(this.ownShipVectorCache.endX,this.ownShipVectorCache.endY,-s);u.push({id:"ownship",x1:S.x,y1:S.y,x2:_.x,y2:_.y,className:"ownship-vector",stroke:"var(--kip-orange-color)"}),this.renderVectorLines(this.ownShipLayer,"ownship-vector",u);}rotatePoint(e,t,i){let s=i*Math.PI/180,r=Math.cos(s),o=Math.sin(s);return {x:e*r-t*o,y:e*o+t*r}}renderVectorLines(e,t,i){let s=e.selectAll(`line.${t}`).data(i,o=>o.id);s.enter().append("line").attr("class",o=>`${t} ${o.className}`).merge(s).attr("x1",o=>o.x1).attr("y1",o=>o.y1).attr("x2",o=>o.x2).attr("y2",o=>o.y2).style("stroke",o=>o.stroke??"#50505f").style("stroke-width",2).style("opacity",1).style("stroke-dasharray","15, 7"),s.exit().remove();let r=e.selectAll(`circle.${t}-tip`).data(i,o=>o.id);r.enter().append("circle").attr("class",o=>`${t}-tip ${o.className}`).merge(r).attr("cx",o=>o.x2).attr("cy",o=>o.y2).attr("r",2.5).style("fill",o=>o.stroke??"#50505f").style("stroke",o=>o.stroke??"#50505f").style("stroke-width",2).style("opacity",1).style("stroke-dasharray","15, 7"),r.exit().remove();}renderTargets(e,t){if(!this.targetsLayer)return;let i=this.resolveTargetBaseSize(t),s=this.targetsLayer.selectAll("g.target").data(e,n=>n.id),r=s.enter().append("g").on("click",(n,d)=>{n.stopPropagation(),this.handleTargetClick(n,d);});r.append("image").attr("class","target-icon"),r.append("title");let o=r.merge(s);o.attr("transform",n=>`translate(${n.x}, ${n.y}) rotate(${n.heading})`).attr("class",n=>`target ${n.className}`),o.select("image.target-icon").attr("href",n=>n.iconHref??null).attr("xlink:href",n=>n.iconHref??null).attr("display",n=>n.iconHref?null:"none").attr("width",n=>i*n.iconScale).attr("height",n=>i*n.iconScale).attr("x",n=>-(i*n.iconScale)/2).attr("y",n=>-(i*n.iconScale)/2),o.select("title").text(n=>`${n.raw.name??n.raw.mmsi??"AIS Target"}`),s.exit().remove();}renderSelected(e,t){if(!this.selectedLayer)return;let i=e.filter(u=>u.id===this.selectedId()),s=this.resolveTargetBaseSize(t),r=s*1.4,o=Math.min(r,Math.max(4,s*.6)),n=this.buildCornerBoxPath(r,o),d=this.selectedLayer.selectAll("path.selected-ring").data(i,u=>u.id);d.enter().append("path").attr("class","selected-ring").merge(d).attr("transform",u=>`translate(${u.x}, ${u.y})`).attr("d",n),d.exit().remove();}resolveTargetBaseSize(e){let t=Math.max(.2,e);return l.TARGET_ICON_SIZE_PX/t}resolveOwnShipBaseSize(e){let t=Math.max(.2,e);return l.OWN_SHIP_ICON_SIZE_PX/t}raiseOwnshipAndVector(){this.ownShipLayer?.raise();}onMenuItemSelect(e){this.openTargetDialog(e.target,e.iconHref),this.selectedId.set(null),this.closeTargetMenu();}handleTargetClick(e,t){let i=this.resolveMenuItems(e,t);if(i.length<=1){this.openTargetDialog(t.raw,t.iconHref);return}this.menuItems.set(i),this.menuPoint=this.resolveMenuPoint(e),this.positionMenuAnchor(),this.menuTrigger().openMenu();}openTargetDialog(e,t){this.selectedId.set(e.id);let i=this.snapshotAisTrack(e);this.dialog.openAisDetailDialog({title:this.buildTargetTitle(i),iconHref:t??void 0,component:"ais-target",componentType:cn,payload:{target:i}}).subscribe();}snapshotAisTrack(e){return structuredClone(e)}resolveMenuItems(e,t){return this.findTargetsNearEvent(e,t).map(s=>({id:s.id,label:this.buildTargetMenuLabel(s.raw),iconHref:s.iconHref,target:s.raw}))}findTargetsNearEvent(e,t){let i=this.lastRenderTargets.length?this.lastRenderTargets:[t],s=this.eventToRadarPoint(e);if(!s)return [t];let r=this.hitRadiusPx/this.lastRenderScale,o=i.map((n,d)=>{let u=n.x-s.x,b=n.y-s.y,c=Math.hypot(u,b);return {candidate:n,distance:c,index:d}}).filter(n=>n.distance<=r).sort((n,d)=>n.distance-d.distance||n.index-d.index).map(n=>n.candidate);return o.length?o:[t]}eventToRadarPoint(e){if(!this.lastRenderSize)return null;let s=this.svgRef().nativeElement.getBoundingClientRect(),r=e.clientX-s.left,o=e.clientY-s.top,n=(r-s.width/2)/this.lastRenderScale,d=(o-s.height/2)/this.lastRenderScale,u=this.lastViewRotation*Math.PI/180,b=Math.cos(u),c=Math.sin(u);return {x:n*b-d*c,y:n*c+d*b}}resolveMenuPoint(e){let t=this.svgRef().nativeElement.closest(".ais-radar-container");if(!t)return null;let i=t.getBoundingClientRect();return {x:e.clientX-i.left,y:e.clientY-i.top}}positionMenuAnchor(){let e=this.menuAnchorRef().nativeElement;this.menuPoint&&(e.style.left=`${this.menuPoint.x}px`,e.style.top=`${this.menuPoint.y}px`);}closeTargetMenu(){this.resetTargetMenuState(),this.menuTrigger().menuOpen&&this.menuTrigger().closeMenu();}resetTargetMenuState(){this.menuItems.set([]),this.menuPoint=null;}buildTargetMenuLabel(e){return this.isAton(e)&&e.typeName?e.typeName:e.name??e.mmsi??"AIS Target"}buildTargetTitle(e){let t=this.isAton(e)&&e.typeName?e.typeName:e.name??e.type??"AIS Target",i=e.ais.status;return i==="unconfirmed"||i==="lost"||i==="remove"?`${t} - ${i}`:t}resolveIconCached(e){let t=this.buildIconSignature(e),i=this.iconCache.get(e.id);if(i&&i.signature===t)return i.icon;let s=this.resolveIconScale(e.type),r={href:i?.icon.href??null,scale:s};this.iconCache.set(e.id,{signature:t,icon:r});let o=e.ais.status==="remove"?void 0:e.ais.status;return this.ngZone.runOutsideAngular(()=>{nc({mmsi:e.mmsi??"",type:e.type,navState:this.isVesselLike(e)?e.navState:void 0,aisShipTypeId:this.isVesselLike(e)?e.design?.aisShipType?.id:void 0,atonVirtual:this.isAton(e)?e.virtual:void 0,atonTypeId:this.isAton(e)?e.typeId:void 0,status:o,collisionRiskRating:this.isVesselLike(e)?e.closestApproach?.collisionRiskRating:void 0}).then(n=>{let d=this.iconCache.get(e.id);!d||d.signature!==t||(d.icon={href:n,scale:s},this.scheduleRenderDebounced());});}),r}resolveIconScale(e){switch(e){case "aton":return 3.5;case "basestation":return 3;case "sar":return 2.4;case "vessel":return 3;default:return 2.4}}buildIconSignature(e){let t=e.ais.status==="lost"?"unconfirmed":e.ais.status;return [e.mmsi,e.type,this.isVesselLike(e)?e.navState:void 0,this.isVesselLike(e)?e.design?.aisShipType?.id:void 0,this.isAton(e)?e.virtual:void 0,this.isAton(e)?e.typeId:void 0,t,this.isVesselLike(e)?e.closestApproach?.collisionRiskRating:void 0].join("|")}buildClassName(e){let t=[`status-${e.status}`,`type-${e.type}`,e.aisClass?`class-${e.aisClass.toLowerCase()}`:"class-unknown"];if(e.navState){let i=e.navState.toLowerCase();i.includes("moored")&&t.push("state-moored"),i.includes("anchored")&&t.push("state-anchored");}return e.id===this.selectedId()&&t.push("is-selected"),t.join(" ")}resolveTargetVectorStroke(e){if(e.ais.status!=="confirmed")return "#50505f";let t=e.closestApproach?.collisionRiskRating,i=typeof t=="number"?t:Number(t);return Number.isFinite(i)?i<qn?"red":i<zn?"yellow":"#50505f":"#50505f"}shouldFilterTarget(e){let t=this.filterState();if(!t.anchoredMoored&&!t.noCollisionRisk&&!t.allAton&&!t.allButSar&&!t.allVessels&&t.vesselTypes.size===0)return false;if(t.anchoredMoored&&this.isVesselLike(e)&&this.isStationaryNavState(e.navState)||t.noCollisionRisk&&this.isVesselLike(e)&&(e.ais.status!=="confirmed"||this.isStationaryNavState(e.navState)||this.isNoCollisionRisk(e))||t.allAton&&e.type==="aton"||t.allButSar&&e.type!=="sar"||t.allVessels&&this.isVesselLike(e))return true;if(t.vesselTypes.size>0&&this.isVesselLike(e)){let i=this.resolveVesselIconKey(e);if(i&&t.vesselTypes.has(i))return true}return false}isNoCollisionRisk(e){let t=e.closestApproach?.collisionRiskRating;if(!Object.prototype.hasOwnProperty.call(e.closestApproach??{},"collisionRiskRating"))return false;if(t==null)return true;let i=typeof t=="number"?t:Number(t);return Number.isFinite(i)?i>=zn:true}resolveVesselIconKey(e){if(!this.isVesselLike(e))return null;let t=pa({mmsi:e.mmsi??e.id??"",type:e.type,aisShipTypeId:e.design?.aisShipType?.id});return t.startsWith("vessel/")?t:null}polarToCartesian(e,t,i,s){let r=e*Math.PI/180,o=t/i*s;return {x:o*Math.sin(r),y:-o*Math.cos(r)}}hasValidPosition(e){return typeof e?.latitude=="number"&&Number.isFinite(e.latitude)&&typeof e?.longitude=="number"&&Number.isFinite(e.longitude)}offsetPoint(e,t,i,s){let r=i*Math.PI/180;return {x:e+s*Math.sin(r),y:t-s*Math.cos(r)}}wrapDegrees(e){let t=e%360;return t<0?t+360:t}isStationaryNavState(e){if(typeof e=="number"&&Number.isFinite(e))return e===1||e===5;if(typeof e!="string")return false;let t=e.trim().toLowerCase().replace(/\s+/g," ");if(!t.length)return false;let i=Number(t);return Number.isFinite(i)?i===1||i===5:t.includes("moored")||t.includes("anchored")||t.includes("at anchor")}shortestAngleDelta(e,t){return (t-e+540)%360-180}buildTrackSignature(e){let t=e.position??{};return [t.latitude,t.longitude,this.isVesselLike(e)?e.headingTrue:void 0,this.isVesselLike(e)?e.courseOverGroundTrue:void 0].join("|")}isVesselLike(e){return e.type==="vessel"||e.type==="sar"}isAton(e){return e.type==="aton"}buildCornerBoxPath(e,t){let i=e,s=Math.min(Math.max(t,0),i);return [`M ${-i} ${-i} h ${s}`,`M ${-i} ${-i} v ${s}`,`M ${i} ${-i} h ${-s}`,`M ${i} ${-i} v ${s}`,`M ${-i} ${i} h ${s}`,`M ${-i} ${i} v ${-s}`,`M ${i} ${i} h ${-s}`,`M ${i} ${i} v ${-s}`].join(" ")}smoothRotation(e){let t=performance.now();if(this.viewRotationSmoothed===null||this.lastRotationAt===null)return this.viewRotationSmoothed=this.wrapDegrees(e),this.lastRotationAt=t,this.viewRotationSmoothed;let i=Math.min(250,Math.max(0,t-this.lastRotationAt)),s=Math.min(1,i/200),r=this.shortestAngleDelta(this.viewRotationSmoothed,e);return this.viewRotationSmoothed=this.wrapDegrees(this.viewRotationSmoothed+r*s),this.lastRotationAt=t,this.viewRotationSmoothed}toDegreesIfRadians(e){return typeof e!="number"||!Number.isFinite(e)?null:this.units.convertToUnit("deg",e)}distanceNm(e,t){let s=e.latitude*Math.PI/180,r=t.latitude*Math.PI/180,o=(t.latitude-e.latitude)*Math.PI/180,n=(t.longitude-e.longitude)*Math.PI/180,d=Math.sin(o/2),u=Math.sin(n/2),b=d*d+Math.cos(s)*Math.cos(r)*u*u;return 6371e3*(2*Math.atan2(Math.sqrt(b),Math.sqrt(1-b)))/1852}ngOnDestroy(){this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.rotationFrameTimer!==null&&(window.clearTimeout(this.rotationFrameTimer),this.rotationFrameTimer=null),this.iconRenderTimer!==null&&(window.clearTimeout(this.iconRenderTimer),this.iconRenderTimer=null);}static \u0275fac=function(t){return new(t||l)};static \u0275cmp=JD({type:l,selectors:[["widget-ais-radar"]],viewQuery:function(t,i){t&1&&eg(i.svgRef,lt,5)(i.menuAnchorRef,ct,5)(i.menuTrigger,dt,5),t&2&&Kw(3);},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:29,vars:9,consts:[["radarSvg",""],["menuAnchor","","menuTrigger","matMenuTrigger"],["targetMenu","matMenu"],["filterMenu","matMenu"],["vesselTypeMenu","matMenu"],["kipResizeObserver","",1,"ais-radar-container",3,"kipResize"],["type","button","matMiniFab","",1,"ais-radar-mode-toggle-button",3,"click","matTooltip"],["viewBox","0 0 40 40","aria-hidden","true",1,"ais-mode-icon"],["type","button","matMiniFab","","matTooltip","Increase range","aria-label","Increase range",1,"ais-radar-range-button","ais-radar-range-plus",3,"click"],["type","button","matMiniFab","","matTooltip","Decrease range","aria-label","Decrease range",1,"ais-radar-range-button","ais-radar-range-minus",3,"click"],["type","button","matMiniFab","","matTooltip","Filter targets","aria-label","Filter targets",1,"ais-radar-range-button","ais-radar-filter-button",3,"matMenuTriggerFor"],["type","button","matMiniFab","","matTooltip","Show only collision risk targets","aria-label","No collision risk filter",1,"ais-radar-range-button","ais-radar-collision-button",3,"is-active"],["role","img","aria-label","AIS radar display",1,"ais-radar"],["type","button","aria-hidden","true","tabindex","-1",1,"ais-radar-menu-anchor",3,"matMenuTriggerFor"],[3,"closed"],["matMenuContent",""],[1,"widgetOverlay"],["stroke","currentColor","d","M10 8 L20 2 L30 8",1,"ais-mode-icon-chev"],["fill","currentColor","x","20","y","31",1,"ais-mode-icon-letter"],["fill","currentColor","d","M20 4 L34 36 L20 28 L6 36 Z",1,"ais-mode-icon-vessel"],["type","button","matMiniFab","","matTooltip","Show only collision risk targets","aria-label","No collision risk filter",1,"ais-radar-range-button","ais-radar-collision-button",3,"click"],["mat-menu-item","","type","button",1,"ais-radar-menu-item"],["mat-menu-item","","type","button",1,"ais-radar-menu-item",3,"click"],["alt","","aria-hidden","true",1,"target-menu-icon"],[1,"target-menu-label"],["mat-menu-item","","disabled","",1,"ais-filter-menu-header"],["mat-menu-item","","type","button",3,"click"],["aria-hidden","true",1,"ais-filter-check"],["mat-menu-item","",3,"matMenuTriggerFor"],["mat-menu-item","","type","button"]],template:function(t,i){if(t&1&&(Pi(0,"div",5),Qh("kipResize",function(r){return i.onResized(r)}),Pi(1,"button",6),Qh("click",function(){return i.toggleViewMode()}),_w(2,ut,4,0,":svg:svg",7)(3,mt,2,0,":svg:svg",7),ul(),Pi(4,"button",8),Qh("click",function(){return i.incrementRange()}),Pi(5,"mat-icon"),TT(6,"add"),ul()(),Pi(7,"button",9),Qh("click",function(){return i.decrementRange()}),Pi(8,"mat-icon"),TT(9,"remove"),ul()(),Pi(10,"button",10)(11,"mat-icon"),TT(12,"filter_list"),ul()(),_w(13,gt,3,2,"button",11),wd(),$h(14,"svg",12,0),Td(),$h(16,"button",13,1),ul(),Pi(19,"mat-menu",14,2),Qh("closed",function(){return i.resetTargetMenuState()}),xh(21,ft,2,0,"ng-template",15),ul(),Pi(22,"mat-menu",null,3),xh(24,St,27,5,"ng-template",15),ul(),Pi(25,"mat-menu",null,4),xh(27,bt,2,0,"ng-template",15),ul(),_w(28,yt,1,0,"div",16)),t&2){let s=Jw(20),r=Jw(23);EE(),Bh("matTooltip",i.effectiveViewMode()==="north-up"?"Change to North-Up mode":"Change to Course-Up mode"),Hh("aria-label",i.effectiveViewMode()==="north-up"?"North up mode":"Course up mode"),EE(),Mw(i.effectiveViewMode()==="north-up"?2:3),EE(8),sg("is-active",i.hasActiveFilters()),Bh("matMenuTriggerFor",r),EE(3),Mw(i.hasCollisionRiskData()?13:-1),EE(3),Bh("matMenuTriggerFor",s),EE(12),Mw(i.dashboard.isDashboardStatic()?-1:28);}},dependencies:[u,Op,Rp,yt$1,wt,Ht,R,ee,Nt,Lt,zt,mt$1],encapsulation:2})}return l})();export{Qt as WidgetAisRadarComponent};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {cv as G}from'./main-BNR44HGB.js';var r={minDist:230,maxDur:550,minVelocity:1.5,axisDominance:1.8,deadzoneMs:160,purityRatio:.8,lockThreshold:28,directionLockAngle:25,reversalPrimaryThreshold:34};function a$1(n){let e=G(G({},r),n);return `(() => {
|
|
2
|
+
if (window.__kipSwipeInit) return; window.__kipSwipeInit = true;
|
|
3
|
+
const instanceId='${e.instanceId}';
|
|
4
|
+
let pointerId=null; let startX=0; let startY=0; let startT=0; let peakPrimary=0; let peakCross=0; let cancelled=false;
|
|
5
|
+
let lockedAxis=null; let lockedPrimarySign=0; let reversed=false;
|
|
6
|
+
const minDist=${e.minDist};
|
|
7
|
+
const maxDur=${e.maxDur};
|
|
8
|
+
const minVelocity=${e.minVelocity};
|
|
9
|
+
const axisDominance=${e.axisDominance};
|
|
10
|
+
const deadzoneMs=${e.deadzoneMs};
|
|
11
|
+
const purityRatio=${e.purityRatio};
|
|
12
|
+
const lockThreshold=${e.lockThreshold};
|
|
13
|
+
const directionLockAngle=${e.directionLockAngle};
|
|
14
|
+
const reversalPrimaryThreshold=${e.reversalPrimaryThreshold};
|
|
15
|
+
function reset(){pointerId=null; cancelled=false; lockedAxis=null; lockedPrimarySign=0; reversed=false;}
|
|
16
|
+
function onDown(e){ if(pointerId!==null) return; pointerId=e.pointerId; startX=e.clientX; startY=e.clientY; startT=performance.now(); peakPrimary=0; peakCross=0; cancelled=false; lockedAxis=null; lockedPrimarySign=0; reversed=false; }
|
|
17
|
+
function track(e){ if(e.pointerId!==pointerId||cancelled) return; const dx=e.clientX-startX; const dy=e.clientY-startY; const adx=Math.abs(dx); const ady=Math.abs(dy); const primary=adx>ady?adx:ady; const cross=adx>ady?ady:adx; peakPrimary=Math.max(peakPrimary,primary); peakCross=Math.max(peakCross,cross);
|
|
18
|
+
if(!lockedAxis && primary>=lockThreshold){ lockedAxis = adx>ady?'x':'y'; lockedPrimarySign = lockedAxis==='x' ? (Math.sign(dx)||1) : (Math.sign(dy)||1); }
|
|
19
|
+
if(lockedAxis){
|
|
20
|
+
const angleRad = Math.atan2(lockedAxis==='x'?ady:adx, lockedAxis==='x'?adx:ady); // angle from primary axis
|
|
21
|
+
const angleDeg = angleRad * 180 / Math.PI;
|
|
22
|
+
if(angleDeg > directionLockAngle){ cancelled=true; return; }
|
|
23
|
+
if(lockedAxis==='x' && Math.sign(dx) && Math.sign(dx)!==lockedPrimarySign && Math.abs(dx) > reversalPrimaryThreshold){ reversed=true; cancelled=true; return; }
|
|
24
|
+
if(lockedAxis==='y' && Math.sign(dy) && Math.sign(dy)!==lockedPrimarySign && Math.abs(dy) > reversalPrimaryThreshold){ reversed=true; cancelled=true; return; }
|
|
25
|
+
}
|
|
26
|
+
if (!cancelled && peakCross>42 && peakCross*axisDominance>peakPrimary) { cancelled=true; }
|
|
27
|
+
}
|
|
28
|
+
function onUp(e){ if(e.pointerId!==pointerId) return; const endT=performance.now(); const dt=endT-startT; const dx=e.clientX-startX; const dy=e.clientY-startY; const adx=Math.abs(dx); const ady=Math.abs(dy); const dist=Math.hypot(dx,dy); const velocity=dist/dt; const primary=adx>ady?adx:ady; const cross=adx>ady?ady:adx; const purity= primary? (primary/dist):0; if(!cancelled && !reversed && dt>=deadzoneMs && dt<=maxDur && dist>=minDist && velocity>=minVelocity && purity>=purityRatio && primary/Math.max(cross,1)>=axisDominance){ if(adx>ady){ window.parent.postMessage({gesture: dx>0?'swiperight':'swipeleft', eventData:{dx,dy,duration:dt,velocity,instanceId}}, '*'); } else { window.parent.postMessage({gesture: dy>0?'swipedown':'swipeup', eventData:{dx,dy,duration:dt,velocity,instanceId}}, '*'); } } reset(); }
|
|
29
|
+
function onCancel(e){ if(e.pointerId===pointerId) reset(); }
|
|
30
|
+
document.addEventListener('pointerdown', onDown, {passive:true});
|
|
31
|
+
document.addEventListener('pointermove', track, {passive:true});
|
|
32
|
+
document.addEventListener('pointerup', onUp, {passive:true});
|
|
33
|
+
document.addEventListener('pointercancel', onCancel, {passive:true});
|
|
34
|
+
document.addEventListener('keydown', (event) => {
|
|
35
|
+
if (event.ctrlKey && event.shiftKey && ['ArrowLeft','ArrowRight','ArrowUp','ArrowDown','E','F','N'].includes(event.key)) {
|
|
36
|
+
window.parent.postMessage({ type:'keydown', keyEventData:{ key:event.key, ctrlKey:event.ctrlKey, shiftKey:event.shiftKey, instanceId }}, '*');
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
})();`}export{a$1 as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {dx as n$1}from'./main-BNR44HGB.js';function c(n,r){let i={contrast:{color:r.contrast,dim:r.contrastDim,dimmer:r.contrastDimmer},blue:{color:r.blue,dim:r.blueDim,dimmer:r.blueDimmer},green:{color:r.green,dim:r.greenDim,dimmer:r.greenDimmer},pink:{color:r.pink,dim:r.pinkDim,dimmer:r.pinkDimmer},orange:{color:r.orange,dim:r.orangeDim,dimmer:r.orangeDimmer},purple:{color:r.purple,dim:r.purpleDim,dimmer:r.purpleDimmer},yellow:{color:r.yellow,dim:r.yellowDim,dimmer:r.yellowDimmer},grey:{color:r.grey,dim:r.greyDim,dimmer:r.greyDimmer}},l=n in i?n:"contrast";return i[l]}function e(n,r,i,l){if(l||!n||!i)return r;switch(n){case n$1.Nominal:return i.zoneNominal;case n$1.Alarm:return i.zoneAlarm;case n$1.Warn:return i.zoneWarn;case n$1.Alert:return i.zoneAlert;default:return r}}export{c,e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {dx as n$1}from'./main-BNR44HGB.js';function k(g,s,l,m,f,r,b=false){let a=[],c=[...g].sort((o,n)=>(o.lower??-1/0)-(n.lower??-1/0));for(let o of c){let n=f,t=r,i;switch(o.state){case n$1.Emergency:i=s.zoneEmergency;break;case n$1.Alarm:i=s.zoneAlarm;break;case n$1.Warn:i=s.zoneWarn;break;case n$1.Alert:i=s.zoneAlert;break;case n$1.Nominal:i=s.zoneNominal;break;default:i="rgba(0,0,0,0)";}if(o.lower==null?n=f:n=m.convertToUnit(l,o.lower)??f,o.upper==null?t=r:t=m.convertToUnit(l,o.upper)??r,!(!Number.isFinite(n)||!Number.isFinite(t))&&!(t<f||n>r)){if(n=Math.max(n,f),t>r){t=r,a.push({from:n,to:t,color:i});break}a.push({from:n,to:t,color:i});}}return b&&(a=a.map(o=>({from:r-o.to,to:r-o.from,color:o.color}))),a}export{k};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-DVB9tiW3.js';import {d1 as Hj,w,du as p,G as Gi,N,aX as He,a as G,$ as $j,W as Wp,F as Fa,dn as ge,J as JD,_ as _w,M as Mw,f as eg,K as Kw,H as Dr,eb as rw,cp as Uh,bD as HT,g as qw,b_ as Gh,bE as $T,ci as dl,cj as fl,e as EE,dP as pp}from'./main-BNR44HGB.js';var R=(()=>{class n{sanitizer=w(Dr);transform(e){return this.sanitizer.bypassSecurityTrustResourceUrl(e)}static \u0275fac=function(t){return new(t||n)};static \u0275pipe=rw({name:"safe",type:n,pure:true})}return n})();var $=["freeboardSkIframe"];function z(n,v){if(n&1&&(Uh(0,"iframe",1,0),HT(2,"safe")),n&2){let e=qw();Gh("src",$T(2,1,e.widgetUrlSafe),pp);}}function A(n,v){n&1&&Uh(0,"div",4);}function B(n,v){if(n&1&&(dl(0,"div",2),Uh(1,"iframe",3,0),HT(3,"safe"),_w(4,A,1,0,"div",4),fl()),n&2){let e=qw();EE(),Gh("src",$T(3,2,e.widgetUrlSafe),pp),EE(3),Mw(e.dashboard.isDashboardStatic()?-1:4);}}var ae=(()=>{class n{id=Hj();type=Hj();theme=Hj();disableWidgetShell=Hj(false);swipeDisabled=Hj(false);runtime=w(p,{optional:true});appSettings=w(Gi);app=w(N);auth=w(He);dashboard=w(G);iframe=$j.required("freeboardSkIframe");authToken=Wp(this.auth.authToken$,{initialValue:null});viewReady=false;iframeLoaded=false;widgetUrl=null;widgetUrlSafe="";static DEFAULT_CONFIG={};constructor(){window.addEventListener("message",this.handleIframeGesture),Fa(()=>{let e=this.authToken();ge(()=>{let t=e?.token,i=this.appSettings.signalkUrl?.url;this.widgetUrl=i?t?`${i}/@signalk/freeboard-sk/?token=${t}`:`${i}/@signalk/freeboard-sk/`:null,this.widgetUrlSafe=this.widgetUrl??"";});}),Fa(()=>{let e=this.app.isNightMode();ge(()=>{!this.iframeLoaded||!this.viewReady||this.appSettings.getRedNightMode()&&this.sendMessage({commands:{nightModeEnable:e}});});});}ngAfterViewInit(){this.viewReady=true;try{this.iframe().nativeElement.onload=()=>{this.iframeLoaded=!0,this.sendMessage({settings:{autoNightMode:!1}}),this.injectSwipeScript();};}catch(e){}}sendMessage(e,t="*"){let i=this.iframe()?.nativeElement?.contentWindow;i&&this.iframeLoaded&&i.postMessage(e,t);}injectSwipeScript(){if(this.swipeDisabled())return;let e=this.iframe().nativeElement.contentWindow,t=this.iframe().nativeElement.contentDocument;if(!t||!e){console.error("[FSK Widget] Iframe contentDocument or contentWindow is undefined.");return}try{let i=`kip-gesture-inject-${this.id()}`;if(t.getElementById(i))return;let s=a$1({instanceId:this.id()}),r=t.createElement("script");r.id=i,r.textContent=s,t.body.appendChild(r);}catch(i){console.warn("[FSK Widget] Failed to inject swipe script into iframe:",i);}}handleIframeGesture=e=>{if(!e.data||!this.viewReady)return;let t=null;try{t=this.iframe()?.nativeElement?.contentWindow??null;}catch(r){t=null;}if(!t||e.source!==t)return;let i=this.getExpectedIframeOrigin();if(i&&e.origin!==i)return;let s=this.id();if(e.data.gesture&&e.data.eventData?.instanceId===s)switch(e.data.gesture){case "swipeup":this.dashboard.isDashboardStatic()&&this.dashboard.navigateToPreviousDashboard();break;case "swipedown":this.dashboard.isDashboardStatic()&&this.dashboard.navigateToNextDashboard();break;case "swipeleft":window.document.dispatchEvent(new Event("openLeftSidenav",{bubbles:true,cancelable:true}));break;case "swiperight":window.document.dispatchEvent(new Event("openRightSidenav",{bubbles:true,cancelable:true}));break}if(e.data.type==="keydown"&&e.data.keyEventData?.instanceId===s){let{key:r,ctrlKey:L,shiftKey:O}=e.data.keyEventData,P=new KeyboardEvent("keydown",{key:r,ctrlKey:L,shiftKey:O,bubbles:true,cancelable:true});document.dispatchEvent(P);}};getExpectedIframeOrigin(){let e=this.widgetUrl||this.appSettings.signalkUrl?.url;if(!e)return null;try{return new URL(e).origin}catch(t){return null}}ngOnDestroy(){if(window.removeEventListener("message",this.handleIframeGesture),this.iframe){try{this.iframe().nativeElement.onload=null;}catch(e){}try{let e=this.iframe()?.nativeElement.contentDocument;if(e){let t=`kip-gesture-inject-${this.id()}`,i=e.getElementById(t);i&&i.parentNode&&i.parentNode.removeChild(i);}}catch(e){}}}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=JD({type:n,selectors:[["widget-freeboardsk"]],viewQuery:function(t,i){t&1&&eg(i.iframe,$,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],disableWidgetShell:[1,"disableWidgetShell"],swipeDisabled:[1,"swipeDisabled"]},decls:2,vars:1,consts:[["freeboardSkIframe",""],["width","100%","height","100%","frameborder","0","sandbox","allow-same-origin allow-scripts allow-forms",1,"freeboardsk-iframe","no-shell",3,"src"],[1,"widget-shell",2,"overflow","clip","position","relative","width","100%","height","100%"],["width","100%","height","100%","frameborder","0","sandbox","allow-same-origin allow-scripts allow-forms",1,"freeboardsk-iframe",3,"src"],[1,"widgetOverlay"]],template:function(t,i){t&1&&_w(0,z,3,3,"iframe",1)(1,B,5,4,"div",2),t&2&&Mw(i.disableWidgetShell()?0:1);},dependencies:[R],styles:[".widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent}"]})}return n})();export{ae as WidgetFreeboardskComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {c}from'./chunk-D_wrJJxl.js';import {d1 as Hj,w,du as p,dv as rt,ao as ue,$ as $j,v as vt,D as Dt,F as Fa,dn as ge,J as JD,ci as dl,cn as wd,cp as Uh,cj as fl,X as xw,cs as Sw,T as TT,e as EE,Y as Aw,d as ig,s as sg,an as Hh,aA as gg,bp as gl,f as eg,K as Kw}from'./main-BNR44HGB.js';var ae=["finePath"],oe=["coarsePath"];function re(i,c){if(i&1&&(wd(),Uh(0,"line")),i&2){let e=c.$implicit;Hh("x1",e.x1)("y1",e.y1)("x2",e.x2)("y2",e.y2)("stroke-width",e.major?1.5:1);}}function se(i,c){if(i&1&&(wd(),Uh(0,"line",20)),i&2){let e=c.$implicit;Hh("x1",e.x1)("y1",e.y1)("x2",e.x2)("y2",e.y2)("stroke-width",e.major?1.2:.8);}}function le(i,c){if(i&1&&(wd(),dl(0,"text"),TT(1),fl()),i&2){let e=c.$implicit;Hh("x",e.x)("y",e.y),EE(),gl("",e.text,"\xB0");}}function ce(i,c){if(i&1&&(wd(),Uh(0,"line")),i&2){let e=c.$implicit;Hh("x1",e.x1)("y1",e.y1)("x2",e.x2)("y2",e.y2)("stroke-width",e.major?1.5:1);}}function me(i,c){if(i&1&&(wd(),Uh(0,"line",20)),i&2){let e=c.$implicit;Hh("x1",e.x1)("y1",e.y1)("x2",e.x2)("y2",e.y2)("stroke-width",e.major?1.2:.8);}}function de(i,c){if(i&1&&(wd(),dl(0,"text"),TT(1),fl()),i&2){let e=c.$implicit;Hh("x",e.x)("y",e.y),EE(),gl("",e.text,"\xB0");}}var be=(()=>{class i{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);ngZone=w(ue);finePathRef=$j("finePath");coarsePathRef=$j("coarsePath");angleDeg=vt(0);absAngle=Dt(()=>{let e=this.angleDeg();return e==null?null:Math.abs(e)});angleSide=Dt(()=>{let e=this.angleDeg();if(e==null)return "";let n=e>0?"Stbd":e<0?"Port":"Level";return this.runtime.options()?.gauge?.sideLabel?n:""});displayValue=Dt(()=>{let e=this.absAngle();if(e==null)return "--";let n=this.runtime.options()?.numDecimal??1;return e.toFixed(n)});themeColorValue=vt("contrast");normalizedConfig=Dt(()=>this.runtime.options()??i.DEFAULT_CONFIG);anglePathConfig=Dt(()=>this.normalizedConfig().paths?.angle);ready=vt(false);pointerTransition=Dt(()=>{let e=this.anglePathConfig()?.sampleTime??1e3;return `transform ${Math.max(100,e*.95)}ms ease-in-out`});fineTicks=vt([]);fineInnerTicks=vt([]);fineLabels=vt([]);coarseTicks=vt([]);coarseInnerTicks=vt([]);coarseLabels=vt([]);finePointerTransform=this.makePointerTransform("fine");coarsePointerTransform=this.makePointerTransform("coarse");displayName=Dt(()=>this.runtime.options()?.displayName||"Heel");static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:true,displayName:"Heel",filterSelfPaths:true,paths:{angle:{description:"Heel / Roll / Other Angle",path:"self.navigation.attitude.roll",source:"default",pathType:"number",isPathConfigurable:true,convertUnitTo:"deg",sampleTime:1e3,pathRequired:true}},gauge:{type:"angle",invertAngle:false,sideLabel:true},numInt:2,numDecimal:0,color:"contrast",enableTimeout:false,dataTimeout:5};constructor(){Fa(()=>{let e=this.normalizedConfig();this.anglePathConfig()?.path&&ge(()=>this.streams.observe("angle",t=>{let s=t?.data?.value;if(s==null){this.angleDeg.set(null);return}let m=e.gauge?.invertAngle?-s:s;this.angleDeg.set(m);}));}),Fa(()=>{let e=this.theme(),n=this.runtime.options();!e||!n||this.themeColorValue.set(c(n.color||"contrast",e).color);});}ngAfterViewInit(){this.ngZone.runOutsideAngular(()=>{requestAnimationFrame(()=>{let e=this.finePathRef()?.nativeElement,n=this.coarsePathRef()?.nativeElement;if(e){let t=this.buildScale(e,-5,5,1,.5);this.fineTicks.set(t.ticks),this.fineInnerTicks.set(t.innerTicks),this.fineLabels.set(t.labels);}if(n){let t=this.buildScale(n,-40,40,10,5);this.coarseTicks.set(t.ticks),this.coarseInnerTicks.set(t.innerTicks),this.coarseLabels.set(t.labels);}this.angleDeg()==null&&this.angleDeg.set(0),this.ready.set(true);});});}makePointerTransform(e){return Dt(()=>this.computePointerTransform(this.angleDeg(),e))}setColors(e){let n=this.runtime.options();!e||!n||this.themeColorValue.set(c(n.color||"contrast",e).color);}computePointerTransform(e,n){let t=e??0,s=n==="fine"?this.finePathRef()?.nativeElement:this.coarsePathRef()?.nativeElement;if(!s)return n==="fine"?"translate(200px, 20px) rotate(0deg)":"translate(200px, 10px) rotate(0deg)";let m=n==="fine"?{min:-5,max:5}:{min:-40,max:40},A=Math.max(m.min,Math.min(m.max,t)),C=s.getTotalLength(),h=(A-m.min)/(m.max-m.min)*C,D=s.getPointAtLength(h),k=h<10||h>C-10?5:1,N=s.getPointAtLength(Math.max(0,h-k)),p=s.getPointAtLength(Math.min(C,h+k)),x=p.x-N.x,_=p.y-N.y,S=Math.atan2(_,x)*180/Math.PI,f=Math.hypot(x,_)||1,L=-_/f,O=x/f,y=-10,v=D.x+L*y,I=D.y+O*y;return `translate(${v}px, ${I}px) rotate(${S}deg)`}buildScale(e,n,t,s,m){let A=e.getTotalLength(),C=[],V=[],h=[],D=t-n,k=Math.round(D/m),N=Math.round(s/m);for(let p=0;p<=k;p++){let x=n+p*m,_=p/k,S=p===k?A:_*A,f=e.getPointAtLength(S),L=e.getPointAtLength(Math.max(0,S-1)),O=e.getPointAtLength(Math.min(A,S+1)),y=Math.atan2(O.y-L.y,O.x-L.x)*180/Math.PI,v=p%N===0||Math.abs(x)<1e-9,I=v?8:4,ie=v?6:3,W=this.pointFromAngle(f,y+90,0),Z=this.pointFromAngle(f,y+90,I);C.push({x1:W.x,y1:W.y,x2:Z.x,y2:Z.y,major:v});let q=this.pointFromAngle(f,y-90,0),Q=this.pointFromAngle(f,y-90,ie);if(V.push({x1:q.x,y1:q.y,x2:Q.x,y2:Q.y,major:v}),v){let U=this.pointFromAngle(f,y+90,I+8);h.push({x:U.x,y:U.y,text:`${Math.abs(x)}`,value:x});}}return {ticks:C,innerTicks:V,labels:h}}pointFromAngle(e,n,t){let s=n*Math.PI/180;return {x:e.x+Math.cos(s)*t,y:e.y+Math.sin(s)*t}}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=JD({type:i,selectors:[["widget-heel-gauge"]],viewQuery:function(n,t){n&1&&eg(t.finePathRef,ae,5)(t.coarsePathRef,oe,5),n&2&&Kw(2);},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:54,vars:18,consts:[["finePath",""],["coarsePath",""],[1,"container"],["viewBox","0 0 400 105","preserveAspectRatio","xMidYMid meet",1,"flex-element","scale","fine"],["id","fineTubeGradient","x1","0%","y1","0%","x2","0%","y2","100%"],["offset","0%",1,"tube-highlight-color","opacity1"],["offset","45%",1,"tube-highlight-color","opacity2"],["offset","100%",1,"tube-highlight-color","opacity3"],["id","tubeEffect"],["in","SourceAlpha","stdDeviation","1.5","result","blur"],["in","blur","surfaceScale","4","specularConstant",".6","specularExponent","30","lighting-color","currentColor","result","specular"],["x","200","y","-50","z","150"],["x","200","y","150","z","80"],["in","specular","in2","SourceAlpha","operator","in","result","specular"],["in","SourceGraphic","in2","specular","operator","arithmetic","k1","0","k2","1","k3","0.7","k4","0"],["d","M 60,10 A 2400,2400 0 0,0 340,10 A 10,10 0 0,1 340,30 A 2400,2400 0 0,1 60,30 A 10,10 0 0,1 60,10 Z",1,"tube-background"],["d","M 60,11 A 2400,2400 0 0,0 340,11 A 8,8 0 0,1 340,17 A 2400,2400 0 0,1 60,17 A 8,8 0 0,1 60,11 Z",1,"tube-highlight"],["d","M 60,23 A 2400,2400 0 0,0 340,23 A 8,8 0 0,1 340,26 A 2400,2400 0 0,1 60,26 A 8,8 0 0,1 60,23 Z",1,"tube-highlight-secondary"],["d","M 60,30 A 2400,2400 0 0,0 340,30",1,"scale-line"],[1,"tick-marks"],["opacity","0.6"],[1,"scale-values"],["transform","translate(200 20) rotate(0)",1,"pointer"],["rx","6","ry","9"],["x","200","y","93","text-anchor","middle",1,"brand"],["viewBox","0 0 400 115","preserveAspectRatio","xMidYMid meet",1,"flex-element","scale"],["transform","translate(0,15)"],["x","200","y","22","text-anchor","middle",1,"angle"],["dx","-16",1,"side"],["d","M 40,0 A 400,400 0 0,0 360,0 A 10,10 0 0,1 360,20 A 400,400 0 0,1 40,20 A 10,10 0 0,1 40,0 Z",1,"tube-background"],["d","M 40,1 A 400,400 0 0,0 360,1 A 8,8 0 0,1 360,7 A 400,400 0 0,1 40,7 A 8,8 0 0,1 40,1 Z",1,"tube-highlight"],["d","M 40,13 A 400,400 0 0,0 360,13 A 8,8 0 0,1 360,16 A 400,400 0 0,1 40,16 A 8,8 0 0,1 40,13 Z",1,"tube-highlight-secondary"],["d","M 40,20 A 400,400 0 0,0 360,20",1,"scale-line"],["transform","translate(200 10) rotate(0)",1,"pointer"]],template:function(n,t){n&1&&(dl(0,"div",2),wd(),dl(1,"svg",3)(2,"defs")(3,"linearGradient",4),Uh(4,"stop",5)(5,"stop",6)(6,"stop",7),fl(),dl(7,"filter",8),Uh(8,"feGaussianBlur",9),dl(9,"feSpecularLighting",10),Uh(10,"fePointLight",11)(11,"fePointLight",12),fl(),Uh(12,"feComposite",13)(13,"feComposite",14),fl()(),Uh(14,"path",15)(15,"path",16)(16,"path",17)(17,"path",18,0),dl(19,"g",19),xw(20,re,1,5,":svg:line",null,Sw),fl(),dl(22,"g",19),xw(23,se,1,5,":svg:line",20,Sw),fl(),dl(25,"g",21),xw(26,le,2,3,":svg:text",null,Sw),fl(),dl(28,"g",22),Uh(29,"ellipse",23),fl(),dl(30,"text",24),TT(31),fl()(),dl(32,"svg",25)(33,"g",26)(34,"text",27),TT(35),dl(36,"tspan",28),TT(37),fl()(),Uh(38,"path",29)(39,"path",30)(40,"path",31)(41,"path",32,1),dl(43,"g",19),xw(44,ce,1,5,":svg:line",null,Sw),fl(),dl(46,"g",19),xw(47,me,1,5,":svg:line",20,Sw),fl(),dl(49,"g",21),xw(50,de,2,3,":svg:text",null,Sw),fl(),dl(52,"g",33),Uh(53,"ellipse",23),fl()()()()),n&2&&(EE(20),Aw(t.fineTicks()),EE(3),Aw(t.fineInnerTicks()),EE(3),Aw(t.fineLabels()),EE(2),ig("transition",t.ready()?t.pointerTransition():"none")("transform",t.finePointerTransform()),sg("ready",t.ready()),EE(),Hh("fill",t.themeColorValue()),EE(2),gg(t.displayName()),EE(3),Hh("fill",t.themeColorValue()),EE(),gl(" ",t.displayValue(),"\xB0 "),EE(2),gg(t.angleSide()),EE(7),Aw(t.coarseTicks()),EE(3),Aw(t.coarseInnerTicks()),EE(3),Aw(t.coarseLabels()),EE(2),ig("transition",t.ready()?t.pointerTransition():"none")("transform",t.coarsePointerTransform()),sg("ready",t.ready()),EE(),Hh("fill",t.themeColorValue()));},styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;font-family:Roboto}.container[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex-wrap:nowrap;align-items:stretch;justify-content:center;height:100%;width:100%;box-sizing:border-box;gap:0px}.brand[_ngcontent-%COMP%]{font-size:25px;font-weight:700;fill:var(--kip-contrast-dim-color)}.angle[_ngcontent-%COMP%]{font-size:50px;font-weight:700}.side[_ngcontent-%COMP%]{font-size:16px}svg.scale[_ngcontent-%COMP%]{width:100%;height:auto}svg.scale[_ngcontent-%COMP%] .tube-background[_ngcontent-%COMP%]{fill:var(--mat-sys-surface-container);filter:url(#tubeEffect)}svg.scale[_ngcontent-%COMP%] .tube-highlight[_ngcontent-%COMP%]{fill:url(#fineTubeGradient);opacity:.15;mix-blend-mode:soft-light;transition:fill .3s ease,opacity .3s ease}svg.scale[_ngcontent-%COMP%] .tube-highlight-secondary[_ngcontent-%COMP%]{fill:url(#fineTubeGradient);opacity:.2;mix-blend-mode:overlay;transition:fill .3s ease,opacity .3s ease}.tube-highlight-color[_ngcontent-%COMP%]{stop-color:var(--kip-contrast-color)}.opacity1[_ngcontent-%COMP%]{stop-opacity:.12}.opacity2[_ngcontent-%COMP%]{stop-opacity:.05}.opacity3[_ngcontent-%COMP%]{stop-opacity:0}svg.scale[_ngcontent-%COMP%] .scale-line[_ngcontent-%COMP%]{stroke:none;fill:none}.tick-marks[_ngcontent-%COMP%]{stroke:var(--kip-contrast-dim-color)}.scale-values[_ngcontent-%COMP%]{fill:var(--kip-contrast-color);text-anchor:middle;dominant-baseline:hanging;font-size:12;font-weight:700}.pointer[_ngcontent-%COMP%] ellipse[_ngcontent-%COMP%]{stroke:#ffffff59;stroke-width:.7;paint-order:stroke fill;filter:drop-shadow(0 0 1px rgba(0,0,0,.55)) drop-shadow(0 1px 1.5px rgba(0,0,0,.55)) drop-shadow(0 -1px 1px rgba(255,255,255,.25));transition:filter .25s,stroke .25s}"]})}return i})();export{be as WidgetHeelGaugeComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {d1 as Hj,w,du as p,dv as rt,aZ as R,a as G,cu as T,aY as xe,$ as $j,v as vt,F as Fa,dn as ge,a_ as Gp,J as JD,O as Op,bh as xp,y as yt,b as wt,cR as zt,bg as mt,P as Pi,c as $h,u as ul,k as Qh,cn as wd,T as TT,_ as _w,e as EE,M as Mw,f as eg,K as Kw,h as Fw,cV as Td,g as qw,t as pT,dE as RT,B as Bh,aA as gg,l as ud,m as dd,bp as gl}from'./main-BNR44HGB.js';import {c}from'./chunk-D_wrJJxl.js';var J=["canvasMainRef"];function Z(o,e){if(o&1&&(Pi(0,"div",10),wd(),Pi(1,"svg",11)(2,"text",12),TT(3),ul()()(),Td(),Pi(4,"div",13),wd(),Pi(5,"svg",14)(6,"text",15)(7,"tspan",16),TT(8,"\u2691"),ul(),TT(9),Pi(10,"tspan",17),TT(11,"\u2691"),ul()()()(),Td(),Pi(12,"div",18),wd(),Pi(13,"svg",19)(14,"text",12),TT(15),ul()()()),o&2){let t=qw();EE(3),gg(t.portBiasValue()),EE(6),gl(" ",t.lineLengthValue()," "),EE(6),gg(t.stbBiasValue());}}function K(o,e){if(o&1){let t=Fw();Pi(0,"button",20),Qh("click",function(){ud(t);let i=qw();return dd(i.setLineEnd("port"))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",21)(3,"text",22),TT(4,"Port End"),ul()()()(),Td(),Pi(5,"button",23),Qh("click",function(){ud(t);let i=qw();return dd(i.setLineEnd("stb"))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",21)(8,"text",22),TT(9,"Stbd End"),ul()()()();}}function X(o,e){if(o&1){let t=Fw();Pi(0,"button",24),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",5,0))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"+5m"),ul()()()(),Td(),Pi(5,"button",27),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",-5,0))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",25)(8,"text",26),TT(9,"-5m"),ul()()()(),Td(),Pi(10,"button",28),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",-5,0))}),Pi(11,"mat-icon",6),wd(),Pi(12,"svg",25)(13,"text",26),TT(14,"-5m"),ul()()()(),Td(),Pi(15,"button",29),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",5,0))}),Pi(16,"mat-icon",6),wd(),Pi(17,"svg",25)(18,"text",26),TT(19,"+5m"),ul()()()();}}function tt(o,e){if(o&1){let t=Fw();Pi(0,"button",30),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",0,i.toRadians(1)))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"\u21911\xB0"),ul()()()(),Td(),Pi(5,"button",31),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",0,i.toRadians(-1)))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",25)(8,"text",26),TT(9,"\u21931\xB0"),ul()()()(),Td(),Pi(10,"button",32),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",0,i.toRadians(1)))}),Pi(11,"mat-icon",6),wd(),Pi(12,"svg",25)(13,"text",26),TT(14,"\u21931\xB0"),ul()()()(),Td(),Pi(15,"button",33),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",0,i.toRadians(-1)))}),Pi(16,"mat-icon",6),wd(),Pi(17,"svg",25)(18,"text",26),TT(19,"\u21911\xB0"),ul()()()();}}function et(o,e){if(o&1){let t=Fw();Pi(0,"button",34),Qh("click",function(){ud(t);let i=qw();return dd(i.nextDisplayLineName())}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"Line"),ul()()()(),Td(),Pi(5,"button",35),Qh("click",function(){ud(t);let i=qw();return dd(i.setStartLine(i.getDisplayLineName()))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",36)(8,"text",37),TT(9),ul()()()();}if(o&2){let t=qw();EE(5),pT(RT("button ",t.isDisplayLineCurrent()?"line-button-current":"line-button")),Bh("matTooltip",RT("Set the ",t.getDisplayLineName()," line as the current line")),EE(4),gg(t.getDisplayLineName());}}function it(o,e){o&1&&$h(0,"div",9);}var Q=class o{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);canvas=w(R);dashboard=w(G);signalk=w(T);destroyRef=w(xe);static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:false,displayName:"DTS",filterSelfPaths:true,playBeeps:true,convertUnitTo:"m",convertUnitToGroup:"Length",numDecimal:0,ignoreZones:true,color:"contrast",enableTimeout:false,dataTimeout:5,paths:{dtsPath:{description:"Distance to Start Line",path:"self.navigation.racing.distanceStartline",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:500},lineLengthPath:{description:"Length of the start line",path:"self.navigation.racing.startLineLength",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:1e3},lineBiasPath:{description:"Bias of the start line to starboard end",path:"self.navigation.racing.stbLineBias",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:1e3},startLineNamePath:{description:"The current named start line",path:"self.navigation.racing.lines.startLineName",source:"default",pathType:"string",pathRequired:false,isPathConfigurable:false,convertUnitTo:void 0,showPathSkUnitsFilter:false,pathSkUnitsFilter:null,sampleTime:1e3},linesPath:{description:"The known named lines",path:"self.navigation.racing.lines.lines",source:"default",pathType:null,pathRequired:false,isPathConfigurable:false,convertUnitTo:void 0,showPathSkUnitsFilter:false,pathSkUnitsFilter:null,sampleTime:1e3},ttlPath:{description:"Time to sail to the start line in seconds",path:"self.navigation.racing.timeToLine",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"s",showConvertUnitTo:false,showPathSkUnitsFilter:false,pathSkUnitsFilter:"s",sampleTime:500},ttbPath:{description:"Time to delay before sailing to the start line in seconds",path:"self.navigation.racing.timeToBurn",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"s",showConvertUnitTo:false,showPathSkUnitsFilter:false,pathSkUnitsFilter:"s",sampleTime:500}}};canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;titleBitmap=null;titleBitmapText=null;titleBitmapColor=null;dtsValue=null;lengthValue=null;biasValue=null;ttlValue=null;ttbValue=null;labelColor=vt("");valueColor="";dtsColor="";maxValueTextWidth=0;maxValueTextHeight=0;displayLineIndex=0;lines=[];startLineName=null;portBiasValue=vt("");lineLengthValue=vt("");stbBiasValue=vt("");mode=vt(0);normalizedConfig=vt(o.DEFAULT_CONFIG);get pathsRecord(){return (this.runtime.options()??o.DEFAULT_CONFIG).paths??{}}constructor(){Fa(()=>{let e=this.runtime.options()??o.DEFAULT_CONFIG,t=this.theme();t&&ge(()=>{let a=c(e.color??"contrast",t);this.labelColor.set(a.dim),this.valueColor=a.color,this.draw();});}),Fa(()=>{this.pathsRecord.dtsPath?.path&&ge(()=>this.streams.observe("dtsPath",t=>{this.dtsValue=t?.data?.value??null,this.updateDtsColor(),this.draw();}));}),Fa(()=>{this.pathsRecord.lineLengthPath?.path&&ge(()=>this.streams.observe("lineLengthPath",t=>{this.lengthValue=t?.data?.value??null,this.setLenBias(),this.draw();}));}),Fa(()=>{this.pathsRecord.lineBiasPath?.path&&ge(()=>this.streams.observe("lineBiasPath",t=>{this.biasValue=t?.data?.value??null,this.setLenBias();}));}),Fa(()=>{this.pathsRecord.startLineNamePath?.path&&ge(()=>this.streams.observe("startLineNamePath",t=>{console.log("startLineName: "+JSON.stringify(t??"no data")),this.startLineName=t?.data?.value??null,this.displayLineIndex=0;for(let a=0;a<this.lines.length;a++)if(this.lines[a]===this.startLineName){this.displayLineIndex=a;break}this.draw();}));}),Fa(()=>{this.pathsRecord.linesPath?.path&&ge(()=>this.streams.observe("linesPath",t=>{if(console.log("lines: "+JSON.stringify(t??"no data")),this.lines=["Default"],this.displayLineIndex=0,t?.data?.value&&Array.isArray(t.data.value))for(let a of t.data.value)a.startLineName&&(a.startLineName===this.startLineName&&(this.displayLineIndex=this.lines.length),this.lines.push(a.startLineName));}));}),Fa(()=>{this.pathsRecord.ttlPath?.path&&ge(()=>this.streams.observe("ttlPath",t=>{this.ttlValue=t?.data?.value??null,this.draw();}));}),Fa(()=>{this.pathsRecord.ttbPath?.path&&ge(()=>this.streams.observe("ttbPath",t=>{this.ttbValue=t?.data?.value??null,this.draw();}));}),this.signalk.subscribeRequest().pipe(Gp(this.destroyRef)).subscribe(e=>{e.widgetUUID===this.id()&&e.statusCode===200&&this.beep(600,20);});}ngAfterViewInit(){this.canvasElement=this.canvasRef().nativeElement,this.ctx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(e,t)=>{this.cssWidth=e,this.cssHeight=t,this.maxValueTextWidth=Math.floor(this.cssWidth*.95),this.maxValueTextHeight=Math.floor(this.cssHeight*.95),this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.maxValueTextWidth=Math.floor(this.cssWidth*.95),this.maxValueTextHeight=Math.floor(this.cssHeight*.95),this.draw();}toggleMode(){this.mode.update(e=>(e+1)%5),this.draw();}setLineEnd(e){return this.signalk.putRequest("navigation.racing.setStartLine",{end:e,position:"bow"},this.id())??""}adjustLineEnd(e,t,a){return this.signalk.putRequest("navigation.racing.setStartLine",{end:e,delta:t,rotate:a},this.id())??""}nextDisplayLineName(){++this.displayLineIndex>=this.lines.length&&(this.displayLineIndex=0);}getDisplayLineName(){return this.lines[this.displayLineIndex]||"Default"}isDisplayLineCurrent(){return this.getDisplayLineName()===(this.startLineName||"Default")}setStartLine(e){let t=e==="Default"||!e?null:e;this.signalk.putRequest("navigation.racing.setStartLineName",{startLineName:t},this.id()),this.mode.set(0),this.draw();}toRadians(e){return e*(Math.PI/180)}draw(){if(!this.ctx||!this.canvasElement)return;let e=this.runtime.options()??o.DEFAULT_CONFIG,t=e?.displayName||"DTS",a=this.labelColor();(!this.titleBitmap||!e||this.titleBitmap.width!==this.canvasElement.width||this.titleBitmap.height!==this.canvasElement.height||this.titleBitmapText!==t||this.titleBitmapColor!==a)&&(this.titleBitmap=this.canvas.createTitleBitmap(t,a,"normal",this.cssWidth,this.cssHeight),this.titleBitmapText=t,this.titleBitmapColor=a),this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),this.titleBitmap&&this.ctx.drawImage(this.titleBitmap,0,0,this.cssWidth,this.cssHeight),this.canvas.drawText(this.ctx,this.getValueText(),Math.floor(this.cssWidth*.5),Math.floor(this.cssHeight*.325),Math.floor(this.cssWidth*.95),Math.floor(this.cssHeight*.55),"bold",this.dtsColor,"center","middle"),this.canvas.drawText(this.ctx,this.pathsRecord.dtsPath?.convertUnitTo||"m",Math.floor(this.cssWidth*.975),Math.floor(this.cssHeight*.6),Math.floor(this.cssWidth*.95),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"right","bottom"),this.canvas.drawText(this.ctx,"TTL",Math.floor(this.cssWidth*.025),Math.floor(this.cssHeight*.7),Math.floor(this.cssWidth*.1),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"left","middle"),this.canvas.drawText(this.ctx,this.getTimeToLineText(),Math.floor(this.cssWidth*.15),Math.floor(this.cssHeight-.8),Math.floor(this.cssWidth*.35),Math.floor(this.cssHeight*.35),"bold",this.dtsColor,"left","bottom"),this.canvas.drawText(this.ctx,"TTB",Math.floor(this.cssWidth*.525),Math.floor(this.cssHeight*.7),Math.floor(this.cssWidth*.1),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"left","middle"),this.canvas.drawText(this.ctx,this.getTimeToBurnText(),Math.floor(this.cssWidth*.65),Math.floor(this.cssHeight-.8),Math.floor(this.cssWidth*.35),Math.floor(this.cssHeight*.35),"bold",this.dtsColor,"left","bottom"),this.setLenBias();}getValueText(){if(this.dtsValue===null)return "--";let e=this.runtime.options()??o.DEFAULT_CONFIG;return this.dtsValue.toFixed(e?.numDecimal??0)}toHHMMSS(e){if(e==null||isNaN(e))return "-:--";let t=e<0;t&&(e=-e);let a=Math.floor(e/3600),i=Math.floor(e%3600/60),f=Math.floor(e%60),C=t?"-":"";return a===0?`${C}${i.toString().padStart(1,"0")}:${f.toString().padStart(2,"0")}`:`${C}${a.toString().padStart(1,"0")}:${i.toString().padStart(2,"0")}:${f.toString().padStart(2,"0")}`}getTimeToLineText(){return this.toHHMMSS(this.ttlValue??0)}getTimeToBurnText(){return this.toHHMMSS(this.ttbValue??0)}setLenBias(){let e=this.runtime.options()??o.DEFAULT_CONFIG,t=this.pathsRecord.lineLengthPath,a=this.pathsRecord.lineBiasPath;if(t?.path&&this.lengthValue!=null){let i=t.convertUnitTo;i==="feet"&&(i="\u2032"),this.lineLengthValue.set(`\u2015${this.applyDecorations(this.lengthValue.toFixed(e.numDecimal??0))}${i??""}\u2015`);}if(a?.path&&this.biasValue!=null){let i=a.convertUnitTo;i==="feet"&&(i="\u2032"),this.biasValue<0?(this.portBiasValue.set("+"+(-this.biasValue).toFixed(e.numDecimal??0)+(i??"")),this.stbBiasValue.set(this.biasValue.toFixed(e.numDecimal??0)+(i??""))):(this.portBiasValue.set(" "+(-this.biasValue).toFixed(e.numDecimal??0)+(i??"")),this.stbBiasValue.set(" +"+this.biasValue.toFixed(e.numDecimal??0)+(i??"")));}}applyDecorations(e){switch(this.pathsRecord.dtsPath?.convertUnitTo){case "percent":case "percentraw":return e+"%";default:return e}}updateDtsColor(){let e=this.theme(),t=this.runtime.options()??o.DEFAULT_CONFIG;e&&(t.ignoreZones?this.dtsValue?this.dtsValue<0?this.dtsColor=e.zoneAlarm:this.dtsValue<10?this.dtsColor=e.zoneWarn:this.dtsValue<20?this.dtsColor=e.zoneAlert:this.dtsColor=this.valueColor:this.dtsColor=this.valueColor:this.dtsColor=this.valueColor);}beep(e=440,t=100){if(!this.runtime.options()?.playBeeps)return;let a=window.AudioContext||window.webkitAudioContext,i=new a,f=i.createOscillator(),C=i.createGain();f.connect(C),C.connect(i.destination),f.type="sine",f.frequency.value=e,C.gain.value=.1,f.start(),f.stop(i.currentTime+t/1e3);}ngOnDestroy(){try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(e){}}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=JD({type:o,selectors:[["widget-racer-line"]],viewQuery:function(t,a){t&1&&eg(a.canvasRef,J,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:16,vars:2,consts:[["canvasMainRef",""],[1,"line-wrapper"],[1,"filler"],[1,"line-canvas"],[1,"buttons-container"],["mat-flat-button","","matTooltip","Select the control mode",1,"button","select-button",3,"click"],[1,"buttons-svg-icon"],["width","100%","height","100%","viewBox","0 0 80 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","40","y","9"],[1,"widgetOverlay"],[1,"pin-container"],["width","100%","height","100%","viewBox","0 0 70 18","preserveAspectRatio","xMidYMid meet",1,"svg-content","pin"],["x","33","y","14"],[1,"len-bias-container"],["width","100%","height","100%","viewBox","0 0 90 12","preserveAspectRatio","xMidYMid meet",1,"svg-content","len-bias"],["x","45","y","9"],[1,"pin"],[1,"boat"],[1,"boat-container"],["width","100%","height","100%","viewBox","0 0 70 18","preserveAspectRatio","xMidYMid meet",1,"svg-content","boat"],["mat-flat-button","","matTooltip","Set the port(pin) end of the line to the current position",1,"button","port-button",3,"click"],["width","100%","height","100%","viewBox","0 0 100 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","50","y","11"],["mat-flat-button","","matTooltip","Set the starboard(boat) end of the line to the current position",1,"button","starboard-button",3,"click"],["mat-flat-button","","matTooltip","Increase the line length by 5m at the port(pin) end",1,"button","port-small-button",3,"click"],["width","100%","height","100%","viewBox","0 0 50 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","25","y","11"],["mat-flat-button","","matTooltip","Decrease the line length by 5m at the port(pin) end",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Decrease the line length by 5m at the starboard(boat) end",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Increase the line length by 5m at the starboard(boat) end",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the port(pin) end 1\xB0 clockwise",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the port(pin) end 1\xB0 counter-clockwise",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the starboard(boat) end 1\xB0 counter-clockwise",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the starboard(boat) end 1\xB0 clockwise",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Display the next named line",1,"button","select-button",3,"click"],["mat-flat-button","",3,"click","matTooltip"],["width","100%","height","100%","viewBox","0 0 150 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","75","y","11"]],template:function(t,a){if(t&1&&(Pi(0,"div",1)(1,"div",2),$h(2,"canvas",3,0),ul(),Pi(4,"div",4)(5,"button",5),Qh("click",function(){return a.toggleMode()}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",7)(8,"text",8),TT(9,"\u22EE"),ul()()()(),_w(10,Z,16,3)(11,K,10,0)(12,X,20,0)(13,tt,20,0)(14,et,10,6),ul(),_w(15,it,1,0,"div",9),ul()),t&2){let i;EE(10),Mw((i=a.mode())===0?10:i===1?11:i===2?12:i===3?13:i===4?14:-1),EE(5),Mw(a.dashboard.isDashboardStatic()?-1:15);}},dependencies:[Op,xp,yt,wt,zt,mt],styles:["[_nghost-%COMP%]{overflow:clip;display:block;height:100%;width:100%}.line-wrapper[_ngcontent-%COMP%]{width:100%;height:100%;min-height:1px}.line-canvas[_ngcontent-%COMP%]{position:absolute;width:100%!important;height:76%!important;display:block;top:0;left:0}.filler[_ngcontent-%COMP%]{width:100%;height:76%}.buttons-container[_ngcontent-%COMP%]{display:flex;flex-wrap:nowrap;justify-content:space-between;column-gap:2%;position:relative;height:24%;width:100%;padding:0 10px 14px;z-index:20;pointer-events:auto;align-items:center}.button[_ngcontent-%COMP%]{min-width:0px;width:100%;border-radius:12px;align-items:center;justify-content:center;cursor:pointer;--mat-button-filled-container-height: 100%;--mat-button-filled-horizontal-padding: 0px;--mat-button-filled-icon-spacing: 0px}.select-button[_ngcontent-%COMP%]{flex:none;width:18%;--mat-button-filled-container-color: var(--kip-blue-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.line-button[_ngcontent-%COMP%]{flex:none;width:58%;--mat-button-filled-container-color: var(--kip-grey-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.line-button-current[_ngcontent-%COMP%]{flex:none;width:58%;--mat-button-filled-container-color: var(--kip-orange-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.port-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.starboard-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-starboard-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.port-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.starboard-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-starboard-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.buttons-svg-icon[_ngcontent-%COMP%]{width:100%;height:100%;margin:0;padding:0}.svg-content[_ngcontent-%COMP%]{width:100%;height:100%;padding:0;margin:0}.svg-content[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-family:Roboto;font-size:15px;font-weight:700;text-align:center;text-anchor:middle;font-style:normal;font-variant:normal;font-stretch:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke:none}.pin-container[_ngcontent-%COMP%]{flex-basis:18%}.pin[_ngcontent-%COMP%]{fill:var(--kip-port-color)}.pin[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:19px}.len-bias-container[_ngcontent-%COMP%]{flex-basis:35%}.len-bias[_ngcontent-%COMP%]{fill:var(--kip-contrast-color)}.len-bias[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:12px}.boat-container[_ngcontent-%COMP%]{flex-basis:18%}.boat[_ngcontent-%COMP%]{fill:var(--kip-starboard-color)}.boat[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:19px}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent;z-index:21}"]})};export{Q as WidgetRacerLineComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function f(u={}){let c=u.threshold??30,a=false,i=0,l=0,o=null,r=null,s=()=>{a=false,i=0,l=0,o=null,r=null;};return {onPointerDown(t){a=false,i=t.clientX,l=t.clientY;let e=t.currentTarget;if(e&&typeof e.setPointerCapture=="function")try{e.setPointerCapture(t.pointerId),o=e,r=t.pointerId;}catch(n){}},onPointerMove(t){let e=Math.abs(t.clientX-i),n=Math.abs(t.clientY-l);(e>c||n>c)&&(a=true);},onPointerUp(t){if(o&&r!==null){let n=o;if(typeof n.releasePointerCapture=="function")try{(!t||n.hasPointerCapture?.(r))&&n.releasePointerCapture(r);}catch(p){}}let e=!a;return s(),e},onPointerCancel(t){if(o&&r!==null){let e=o;if(typeof e.releasePointerCapture=="function")try{(!t||e.hasPointerCapture?.(r))&&e.releasePointerCapture(r);}catch(n){}}s();},reset:s}}export{f};
|