@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 {f}from'./chunk-H9_eqTYx.js';import {d1 as Hj,w,du as p,dv as rt,dD as _,cu as T,a as G,aR as lt,W as Wp,D as Dt,v as vt,cw as z,cv as G$1,F as Fa,dn as ge,J as JD,dC as x,_ as _w,P as Pi,cn as wd,c as $h,u as ul,X as xw,M as Mw,e as EE,an as Hh,Y as Aw,g as qw,B as Bh,h as Fw,k as Qh,l as ud,m as dd,T as TT,d as ig,s as sg,t as pT,cr as mg}from'./main-BNR44HGB.js';import {c}from'./chunk-D_wrJJxl.js';var Y=(n,i)=>i.raw.value;function K(n,i){if(n&1&&$h(0,"widget-title",0),n&2){let t=qw();Bh("text",t.displayName())("color",t.accentColor());}}function Q(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.fullRoundedItemPathD())("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function X(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.topRoundedItemPathD())("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function ee(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.bottomRoundedItemPathD())("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function te(n,i){if(n&1&&(wd(),$h(0,"rect",18)),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("width",e.menuWidth)("height",e.itemHeight)("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function ie(n,i){if(n&1){let t=Fw();wd(),Pi(0,"g",15),Qh("pointerdown",function(s){ud(t);let o=qw();return dd(o.onPointerDown(s))})("pointermove",function(s){ud(t);let o=qw();return dd(o.onPointerMove(s))})("pointerup",function(s){let o=ud(t).$implicit,l=qw();return dd(l.onPointerUp(s,o))})("pointercancel",function(s){ud(t);let o=qw();return dd(o.onPointerCancel(s))})("keyup.enter",function(){let s=ud(t).$implicit,o=qw();return dd(o.canPut()&&o.selectUi(s))})("keyup.space",function(){let s=ud(t).$implicit,o=qw();return dd(o.canPut()&&o.selectUi(s))}),_w(1,Q,1,4,":svg:path",16)(2,X,1,4,":svg:path",16)(3,ee,1,4,":svg:path",16)(4,te,1,5,":svg:rect",17),Pi(5,"text"),TT(6),ul()();}if(n&2){let t=i.$implicit,e=qw();ig("cursor",e.canPut()?"pointer":"not-allowed"),sg("is-selected",e.isSelected(t.raw))("is-off",t.raw.isOn===false),Hh("transform","translate(0 "+t.index*(e.itemHeight+e.itemGap)+")")("tabindex",e.canPut()?0:-1)("aria-label",t.label)("aria-pressed",e.isSelected(t.raw))("aria-disabled",!e.canPut()),EE(),Mw(t.index===0&&t.index===e.optionsCount()-1?1:t.index===0?2:t.index===e.optionsCount()-1?3:4),EE(4),pT(e.isSelected(t.raw)?"svg-menu-item-current-text":t.raw.isOn===false?"svg-menu-item-off-text":"svg-menu-item-text"),Hh("x",e.menuWidth/2)("y",e.itemHeight/2)("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",(e.isSelected(t.raw)||t.raw.isOn===false,e.textColor())),EE(),mg(" ",e.isSelected(t.raw)?"\u2713 ":"","",t.label," ");}}function ne(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.fullRoundedItemPathD())("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function oe(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.topRoundedItemPathD())("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function re(n,i){if(n&1&&(wd(),$h(0,"path")),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("d",e.bottomRoundedItemPathD())("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function ae(n,i){if(n&1&&(wd(),$h(0,"rect",18)),n&2){let t=qw().$implicit,e=qw();pT(e.isSelected(t.raw)?"svg-menu-item-current":t.raw.isOn===false?"svg-menu-item-off":"svg-menu-item"),Hh("width",e.menuWidth)("height",e.itemHeight)("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",e.isSelected(t.raw)?e.accentColor():(t.raw.isOn===false,e.accentDim()));}}function se(n,i){if(n&1){let t=Fw();wd(),Pi(0,"g",15),Qh("pointerdown",function(s){ud(t);let o=qw();return dd(o.onPointerDown(s))})("pointermove",function(s){ud(t);let o=qw();return dd(o.onPointerMove(s))})("pointerup",function(s){let o=ud(t).$implicit,l=qw();return dd(l.onPointerUp(s,o))})("pointercancel",function(s){ud(t);let o=qw();return dd(o.onPointerCancel(s))})("keyup.enter",function(){let s=ud(t).$implicit,o=qw();return dd(o.canPut()&&o.selectUi(s))})("keyup.space",function(){let s=ud(t).$implicit,o=qw();return dd(o.canPut()&&o.selectUi(s))}),_w(1,ne,1,5,":svg:path",16)(2,oe,1,5,":svg:path",16)(3,re,1,5,":svg:path",16)(4,ae,1,6,":svg:rect",17),Pi(5,"text"),TT(6),ul()();}if(n&2){let t=i.$implicit,e=qw();ig("cursor",e.canPut()?"pointer":"not-allowed"),sg("is-selected",e.isSelected(t.raw))("is-off",t.raw.isOn===false),Hh("transform","translate(0 "+t.index*(e.itemHeight+e.itemGap)+")")("tabindex",e.canPut()?0:-1)("aria-label",t.label)("aria-pressed",e.isSelected(t.raw))("aria-disabled",!e.canPut()),EE(),Mw(t.index===0&&t.index===e.optionsCount()-1?1:t.index===0?2:t.index===e.optionsCount()-1?3:4),EE(4),pT(e.isSelected(t.raw)?"svg-menu-item-current-text":t.raw.isOn===false?"svg-menu-item-off-text":"svg-menu-item-text"),Hh("x",e.menuWidth/2)("y",e.itemHeight/2)("filter",e.isSelected(t.raw)?"url(#glow)":null)("fill",(e.isSelected(t.raw)||t.raw.isOn===false,e.textColor())),EE(),mg(" ",e.isSelected(t.raw)?"\u2713 ":"","",t.label," ");}}function le(n,i){n&1&&$h(0,"div",14);}var J=class n{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={displayName:"Switch Label",showLabel:true,filterSelfPaths:true,paths:{controlPath:{description:"Multi-state control path",path:null,source:null,pathType:"multiple",supportsPut:true,isPathConfigurable:true,pathRequired:true,showPathSkUnitsFilter:false,pathSkUnitsFilter:null,showConvertUnitTo:false,convertUnitTo:void 0,sampleTime:500}},enableTimeout:false,dataTimeout:5,color:"contrast"};runtime=w(p);streams=w(rt);meta=w(_);signalkRequestsService=w(T);dashboard=w(G);toast=w(lt);skRequest=Wp(this.signalkRequestsService.subscribeRequest(),{initialValue:null});cfg=Dt(()=>this.runtime.options()??n.DEFAULT_CONFIG);displayName=Dt(()=>this.cfg().displayName??"Switch Label");showLabel=Dt(()=>this.cfg().showLabel??true);controlPath=Dt(()=>this.getControlPath(this.cfg()));accentColor=vt("");accentDim=vt("");accentDimmer=vt("");textColor=vt("");textDim=vt("");textDimmer=vt("");currentValue=vt(null);sortedOptions=Dt(()=>{let i=this.meta.possibleValues();if(!i.length)return [];let t=i.map(e=>({raw:e,label:e.title||e.abbrev||String(e.value),comparable:this.toComparable(e.value)}));return t.sort((e,s)=>{let o=e.comparable,l=s.comparable;return o.kind==="num"&&l.kind==="num"?o.value-l.value:o.kind==="str"&&l.kind==="str"?o.value.localeCompare(l.value):o.kind==="num"?-1:1}),t.map((e,s)=>z(G$1({},e),{index:s}))});menuWidth=220;itemHeight=50;itemGap=1;svgPadding=Math.max(1,Math.round(this.itemHeight*.2));optionsCount=Dt(()=>this.sortedOptions().length);menuHeight=Dt(()=>{let i=this.sortedOptions().length;return i<=0?0:i*this.itemHeight+(i-1)*this.itemGap});hasOptions=Dt(()=>this.meta.possibleValues().length>0);selectedValue=Dt(()=>this.currentValue());canPut=Dt(()=>this.meta.supportsPut());swipeGuard=f();unselectedOptions=Dt(()=>this.sortedOptions().filter(i=>!this.isSelected(i.raw)));selectedOptions=Dt(()=>this.sortedOptions().filter(i=>this.isSelected(i.raw)));fullRoundedItemPathD=Dt(()=>this.buildRoundedRectPath(this.menuWidth,this.itemHeight,this.cornerRadius,true,true));topRoundedItemPathD=Dt(()=>this.buildRoundedRectPath(this.menuWidth,this.itemHeight,this.cornerRadius,true,false));bottomRoundedItemPathD=Dt(()=>this.buildRoundedRectPath(this.menuWidth,this.itemHeight,this.cornerRadius,false,true));cornerRadius=7;constructor(){Fa(()=>{let i=this.theme(),t=this.cfg().color??"contrast";!i||!t||ge(()=>{this.accentColor.set(c(t,i).color),this.accentDim.set(c(t,i).dim),this.accentDimmer.set(c(t,i).dimmer),t==="contrast"?(this.textColor.set(i.background),this.textDim.set(i.contrastDim),this.textDimmer.set(i.contrastDimmer)):(this.textColor.set(i.contrast),this.textDim.set(c(t,i).dim),this.textDimmer.set(c(t,i).dimmer));});}),Fa(()=>{if(!this.controlPath()){this.currentValue.set(null);return}ge(()=>{this.streams.observe("controlPath",t=>{this.currentValue.set(t?.data?.value??null);}),this.meta.observe("controlPath");});});}select(i){let t=this.getControlPath(this.cfg());t&&this.signalkRequestsService.putRequest(t,i.value,this.id());}selectUi(i){this.select(i.raw);}onPointerDown(i){this.canPut()&&this.swipeGuard.onPointerDown(i);}onPointerMove(i){this.canPut()&&this.swipeGuard.onPointerMove(i);}onPointerUp(i,t){this.canPut()&&this.swipeGuard.onPointerUp(i)&&this.selectUi(t);}onPointerCancel(i){this.swipeGuard.onPointerCancel(i);}getControlPath(i){let t=i?.paths;return !t||Array.isArray(t)?null:t.controlPath?.path??null}isSelected(i){let t=this.selectedValue();return typeof i.value=="number"&&typeof t=="string"?i.value===Number(t):typeof i.value=="string"&&typeof t=="number"?Number(i.value)===t||i.value===String(t):Object.is(i.value,t)}toComparable(i){if(typeof i=="number"&&Number.isFinite(i))return {kind:"num",value:i};if(typeof i=="boolean")return {kind:"num",value:i?1:0};if(typeof i=="string"){let t=i.trim();if(/^-?\d+(\.\d+)?$/.test(t)){let e=Number(t);if(Number.isFinite(e))return {kind:"num",value:e}}return {kind:"str",value:t}}return {kind:"str",value:String(i)}}buildRoundedRectPath(i,t,e,s,o){let l=Math.max(0,i),f=Math.max(0,t),r=Math.max(0,Math.min(e,l/2,f/2));return l===0||f===0?"":r===0?`M0 0H${l}V${f}H0Z`:s&&o?[`M${r} 0`,`H${l-r}`,`A${r} ${r} 0 0 1 ${l} ${r}`,`V${f-r}`,`A${r} ${r} 0 0 1 ${l-r} ${f}`,`H${r}`,`A${r} ${r} 0 0 1 0 ${f-r}`,`V${r}`,`A${r} ${r} 0 0 1 ${r} 0`,"Z"].join(""):s?[`M0 ${r}`,`A${r} ${r} 0 0 1 ${r} 0`,`H${l-r}`,`A${r} ${r} 0 0 1 ${l} ${r}`,`V${f}`,"H0","Z"].join(""):o?["M0 0",`H${l}`,`V${f-r}`,`A${r} ${r} 0 0 1 ${l-r} ${f}`,`H${r}`,`A${r} ${r} 0 0 1 0 ${f-r}`,"V0","Z"].join(""):`M0 0H${l}V${f}H0Z`}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=JD({type:n,selectors:[["widget-multi-state-switch"]],inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:23,vars:6,consts:[[3,"text","color"],["role","group",1,"widgets-container"],["preserveAspectRatio","xMidYMid meet","role","presentation",1,"svg-menu"],["id","glow","x","-50%","y","-50%","width","200%","height","200%"],["stdDeviation","5","result","coloredBlur"],["in","coloredBlur"],["in","SourceGraphic"],["id","focus-inner-ring","x","0","y","0","width","100%","height","100%","color-interpolation-filters","sRGB"],["in","SourceAlpha","operator","erode","radius","2","result","eroded"],["in","SourceAlpha","in2","eroded","operator","out","result","border"],["flood-color","#ffffff","flood-opacity","0.9","result","ringColor"],["in","ringColor","in2","border","operator","in","result","ring"],["in","ring"],["role","button",1,"svg-menu-item-group",3,"is-selected","is-off","cursor"],[1,"widgetOverlay"],["role","button",1,"svg-menu-item-group",3,"pointerdown","pointermove","pointerup","pointercancel","keyup.enter","keyup.space"],[3,"class"],["x","0","y","0",3,"class"],["x","0","y","0"]],template:function(t,e){t&1&&(_w(0,K,1,2,"widget-title",0),Pi(1,"div",1),wd(),Pi(2,"svg",2)(3,"defs")(4,"filter",3),$h(5,"feGaussianBlur",4),Pi(6,"feMerge"),$h(7,"feMergeNode",5)(8,"feMergeNode",6),ul()(),Pi(9,"filter",7),$h(10,"feMorphology",8)(11,"feComposite",9)(12,"feFlood",10)(13,"feComposite",11),Pi(14,"feMerge"),$h(15,"feMergeNode",6)(16,"feMergeNode",12),ul()()(),Pi(17,"g"),xw(18,ie,7,20,":svg:g",13,Y),xw(20,se,7,20,":svg:g",13,Y),ul()()(),_w(22,le,1,0,"div",14)),t&2&&(Mw(e.showLabel()?0:-1),EE(),Hh("aria-label",e.displayName()),EE(),Hh("viewBox","0 0 "+(e.menuWidth+e.svgPadding*2)+" "+((e.menuHeight()||e.itemHeight)+e.svgPadding*2))("aria-label",e.displayName()),EE(15),Hh("transform","translate("+e.svgPadding+" "+e.svgPadding+")"),EE(),Aw(e.unselectedOptions()),EE(2),Aw(e.selectedOptions()),EE(2),Mw(e.dashboard.isDashboardStatic()?-1:22));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent;z-index:21}.widgets-container[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;padding:2px}.svg-menu[_ngcontent-%COMP%]{width:100%;height:100%;display:block;background:transparent;border-radius:12px;z-index:20;font-family:Roboto;font-size:1.3rem;font-weight:700;text-anchor:middle;text-align:center;alignment-baseline:middle}.svg-menu-item-current[_ngcontent-%COMP%]{stroke:var(--mat-sys-on-background);stroke-width:3px;stroke-dasharray:none;stroke-opacity:1}.svg-menu-item[_ngcontent-%COMP%]{fill:var(--mat-sys-outline);stroke:#000;stroke-width:2px;stroke-dasharray:none;stroke-opacity:.2}.svg-menu-item-off[_ngcontent-%COMP%]{stroke:#000;stroke-width:2;stroke-dasharray:none;stroke-opacity:.2}.svg-menu-item-current-text[_ngcontent-%COMP%]{font-size:1.5rem;font-weight:700;text-anchor:middle;dominant-baseline:middle;alignment-baseline:middle}.svg-menu-item-text[_ngcontent-%COMP%], .svg-menu-item-off-text[_ngcontent-%COMP%]{font-weight:600;text-anchor:middle;dominant-baseline:middle;alignment-baseline:middle}.svg-menu-item-group[_ngcontent-%COMP%]:focus{outline:none}.svg-menu-item-group[_ngcontent-%COMP%]:focus-visible :is(rect[_ngcontent-%COMP%], path[_ngcontent-%COMP%]){filter:url(#focus-inner-ring)}"]})};export{J as WidgetMultiStateSwitchComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {d1 as Hj,w,du as p$1,aZ as R,$ as $j,v as vt,F as Fa,dn as ge,J as JD,cp as Uh,f as eg,K as Kw}from'./main-BNR44HGB.js';var p=["canvasMainRef"],M=(()=>{class s{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p$1);canvas=w(R);static DEFAULT_CONFIG={displayName:"Static Label",color:"green",bgColor:"grey",noColor:false,noBgColor:true};canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;maxTextWidth=0;maxTextHeight=0;disposed=false;fgColor=vt("");bgColor=vt("");constructor(){Fa(()=>{let t=this.runtime.options(),e=this.theme();!t||!e||ge(()=>{this.fgColor.set(this.mapColor(t.color??"contrast",e)),this.bgColor.set(this.mapColor(t.bgColor??"grey",e)),this.draw();});}),Fa(()=>{let t=this.runtime.options()?.displayName;ge(()=>{t!==void 0&&this.draw();});});}mapColor(t,e){switch(t){case "contrast":return e.contrast;case "blue":return e.blue;case "green":return e.green;case "pink":return e.pink;case "orange":return e.orange;case "purple":return e.purple;case "grey":return e.grey;case "yellow":return e.yellow;default:return e.contrast}}ngAfterViewInit(){this.canvasElement=this.canvasRef().nativeElement,this.ctx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(t,e)=>{this.cssWidth=t,this.cssHeight=e,this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.draw();}draw(){if(!this.ctx||!this.canvasElement)return;let t=this.runtime.options();if(!t)return;this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),t.noBgColor||this.canvas.drawRectangle(this.ctx,0,0,this.canvasElement.width,this.canvasElement.height,this.bgColor());let e=t.displayName||"";this.canvas.drawText(this.ctx,e,Math.floor(this.cssWidth/2),Math.floor(this.cssHeight/2+10),this.cssWidth-40,this.cssHeight-40,"bold",this.fgColor());}ngOnDestroy(){this.disposed=true;try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(t){}}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=JD({type:s,selectors:[["widget-label"]],viewQuery:function(e,c){e&1&&eg(c.canvasRef,p,5),e&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:0,consts:[["canvasMainRef",""],[1,"label-canvas"]],template:function(e,c){e&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%;overflow:hidden}.label-canvas[_ngcontent-%COMP%]{width:100%!important;height:100%!important;display:block;border-radius:var(--mat-card-elevated-container-shape, var(--mat-sys-corner-medium))}"]})}return s})();export{M as WidgetLabelComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-DVB9tiW3.js';import {d1 as Hj,w,du as p,a as G,H as Dr,$ as $j,v as vt,F as Fa,dn as ge,J as JD,_ as _w,cp as Uh,M as Mw,e as EE,d as ig,f as eg,K as Kw,g as qw,b_ as Gh,ci as dl,T as TT,cj as fl,dP as pp}from'./main-BNR44HGB.js';var W=["plainIframe"];function M(n,e){if(n&1&&Uh(0,"iframe",1,0),n&2){let t=qw();Gh("src",t.widgetUrl(),pp);}}function N(n,e){n&1&&(dl(0,"div",2)(1,"h2"),TT(2,"Empty or bad URL"),fl(),dl(3,"p"),TT(4," IMPORTANT: cross-domain security rules (CORS) apply to this widget. "),fl(),dl(5,"p"),TT(6,"Typically, you can load Grafana graphs, Signal K apps or other related tools. "),fl()());}var O=class n{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);_dashboard=w(G);_sanitizer=w(Dr);static DEFAULT_CONFIG={widgetUrl:void 0,allowInput:false};iframe=$j.required("plainIframe");widgetUrl=vt(null);displayTransparentOverlay=vt("block");constructor(){Fa(()=>{let e=this.runtime.options(),t=this._dashboard.isDashboardStatic();e&&ge(()=>{t?this.displayTransparentOverlay.set(e.allowInput?"none":"block"):this.displayTransparentOverlay.set("block");});}),Fa(()=>{let e=this.runtime.options()?.widgetUrl;this.widgetUrl.set(this.resolveUrl(e));}),window.addEventListener("message",this.handleIframeGesture);}ngAfterViewInit(){if(this.iframe()){this.iframe().nativeElement.onload=()=>this.injectSwipeScript();try{let e=this.iframe().nativeElement.contentDocument;e&&(e.readyState==="complete"||e.readyState==="interactive")&&this.injectSwipeScript();}catch(e){}}}ngOnDestroy(){window.removeEventListener("message",this.handleIframeGesture),this.iframe()&&(this.iframe().nativeElement.onload=null);try{let e=this.iframe()?.nativeElement.contentDocument;if(e){let t=`kip-gesture-inject-${this.id()}`,i=e.getElementById(t);i&&i.parentNode&&i.parentNode.removeChild(i);}}catch(e){}}handleIframeGesture=e=>{if(!e.data)return;let t=e.data?.eventData?.instanceId||e.data?.keyEventData?.instanceId;if(!(!t||t!==this.id())){if(e.data.gesture)switch(e.data.gesture){case "swipeup":this._dashboard.navigateToPreviousDashboard();break;case "swipedown":this._dashboard.navigateToNextDashboard();break;case "swipeleft":{let i=new Event("openLeftSidenav",{bubbles:true,cancelable:true});window.document.dispatchEvent(i);break}case "swiperight":{let i=new Event("openRightSidenav",{bubbles:true,cancelable:true});window.document.dispatchEvent(i);break}}if(e.data.type==="keydown"&&e.data.keyEventData){let{key:i,ctrlKey:l,shiftKey:r}=e.data.keyEventData,x=new KeyboardEvent("keydown",{key:i,ctrlKey:l,shiftKey:r,bubbles:true,cancelable:true});document.dispatchEvent(x);}}};injectSwipeScript(){let e=this.iframe().nativeElement.contentWindow,t=this.iframe().nativeElement.contentDocument;if(!t||!e){console.error("[WidgetIframe] Iframe contentDocument or contentWindow is undefined. Possible cross-origin issue or iframe not fully loaded.");return}try{let i=`kip-gesture-inject-${this.id()}`;if(t.getElementById(i))return;let l=a$1({instanceId:this.id()}),r=t.createElement("script");r.id=i,r.textContent=l,t.body.appendChild(r);}catch(i){console.warn("[WidgetIframe] Failed to inject swipe script into iframe:",i);}}isValidProtocol(e){try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch(t){return console.warn(`[Embed Widget] Invalid Url: ${e}, Error: ${t}`),false}}resolveUrl(e){if(!e)return null;try{let t=new URL(e,window.location.origin);return this.isValidProtocol(t.href)?this._sanitizer.bypassSecurityTrustResourceUrl(t.href):null}catch(t){return console.warn(`[Embed Widget] Can't resolve Url: ${e}, Error: ${t}`),null}}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=JD({type:n,selectors:[["widget-iframe"]],viewQuery:function(t,i){t&1&&eg(i.iframe,W,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:3,vars:3,consts:[["plainIframe",""],["width","100%","height","100%","frameborder","0",1,"widgetIframe",3,"src"],[2,"padding","15px"],[1,"widgetOverlay"]],template:function(t,i){t&1&&(_w(0,M,2,1,"iframe",1)(1,N,7,0,"div",2),Uh(2,"div",3)),t&2&&(Mw(i.widgetUrl()?0:1),EE(2),ig("display",i.displayTransparentOverlay()));},styles:["[_nghost-%COMP%]{overflow:hidden}.widgetIframe[_ngcontent-%COMP%]{background-color:#fff;border-radius:var(--mat-card-elevated-container-shape, var(--mat-sys-corner-medium))}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent}"]})};export{O as WidgetIframeComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-DVB9tiW3.js';import {d1 as Hj,w,du as p,a as G,H as Dr,G as Gi,$ as $j,v as vt,F as Fa,dn as ge,J as JD,cp as Uh,b_ as Gh,e as EE,d as ig,f as eg,K as Kw,dP as pp}from'./main-BNR44HGB.js';var C=["plainIframe"],j=(()=>{class a{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);_dashboard=w(G);_sanitizer=w(Dr);settings=w(Gi);static DEFAULT_CONFIG={};iframe=$j.required("plainIframe");widgetUrl=null;displayTransparentOverlay=vt("block");constructor(){let e=new URL("/signalk-anchoralarm-plugin/",window.location.origin);this.widgetUrl=this.toSafeResourceUrl(e),Fa(()=>{let i=this.runtime.options(),t=this._dashboard.isDashboardStatic();i&&ge(()=>{t?this.displayTransparentOverlay.set("none"):this.displayTransparentOverlay.set("block");});}),window.addEventListener("message",this.handleIframeGesture);}toSafeResourceUrl(e){return e.origin!==window.location.origin||!e.pathname.startsWith("/signalk-anchoralarm-plugin/")?null:this._sanitizer.bypassSecurityTrustResourceUrl(e.toString())}ngAfterViewInit(){if(this.iframe()){this.iframe().nativeElement.onload=()=>this.injectSwipeScript();try{let e=this.iframe().nativeElement.contentDocument;e&&(e.readyState==="complete"||e.readyState==="interactive")&&this.injectSwipeScript();}catch(e){}}}handleIframeGesture=e=>{if(!e.data)return;let i=e.data?.eventData?.instanceId||e.data?.keyEventData?.instanceId;if(!(!i||i!==this.id())){if(e.data.gesture)switch(e.data.gesture){case "swipeup":this._dashboard.navigateToPreviousDashboard();break;case "swipedown":this._dashboard.navigateToNextDashboard();break;case "swipeleft":{let t=new Event("openLeftSidenav",{bubbles:true,cancelable:true});window.document.dispatchEvent(t);break}case "swiperight":{let t=new Event("openRightSidenav",{bubbles:true,cancelable:true});window.document.dispatchEvent(t);break}}if(e.data.type==="keydown"&&e.data.keyEventData){let{key:t,ctrlKey:s,shiftKey:n}=e.data.keyEventData,I=new KeyboardEvent("keydown",{key:t,ctrlKey:s,shiftKey:n,bubbles:true,cancelable:true});document.dispatchEvent(I);}}};injectSwipeScript(){let e=this.iframe().nativeElement.contentWindow,i=this.iframe().nativeElement.contentDocument;if(!i||!e){console.error("[WidgetIframe] Iframe contentDocument or contentWindow is undefined. Possible cross-origin issue or iframe not fully loaded.");return}try{let t=`kip-gesture-inject-${this.id()}`;if(i.getElementById(t))return;let s=a$1({instanceId:this.id()}),n=i.createElement("script");n.id=t,n.textContent=s,i.body.appendChild(n);}catch(t){console.warn("[WidgetIframe] Failed to inject swipe script into iframe:",t);}}ngOnDestroy(){window.removeEventListener("message",this.handleIframeGesture),this.iframe()&&(this.iframe().nativeElement.onload=null);try{let e=this.iframe()?.nativeElement.contentDocument;if(e){let i=`kip-gesture-inject-${this.id()}`,t=e.getElementById(i);t&&t.parentNode&&t.parentNode.removeChild(t);}}catch(e){}}static \u0275fac=function(i){return new(i||a)};static \u0275cmp=JD({type:a,selectors:[["widget-anchor-alarm"]],viewQuery:function(i,t){i&1&&eg(t.iframe,C,5),i&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:3,vars:3,consts:[["plainIframe",""],["width","100%","height","100%","frameborder","0",1,"widgetIframe",3,"src"],[1,"widgetOverlay"]],template:function(i,t){i&1&&Uh(0,"iframe",1,0)(2,"div",2),i&2&&(Gh("src",t.widgetUrl,pp),EE(2),ig("display",t.displayTransparentOverlay()));},styles:["[_nghost-%COMP%]{overflow:hidden}.widgetIframe[_ngcontent-%COMP%]{background-color:#fff;border-radius:var(--mat-card-elevated-container-shape, var(--mat-sys-corner-medium))}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent}"]})}return a})();export{j as WidgetAnchorAlarmComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {d1 as Hj,w,du as p,dv as rt,aZ as R,$ as $j,v as vt,D as Dt,F as Fa,dn as ge,J as JD,cp as Uh,f as eg,K as Kw}from'./main-BNR44HGB.js';import {c}from'./chunk-D_wrJJxl.js';var P=["canvasMainRef"],B=(()=>{class s{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);canvas=w(R);canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;titleBitmap=null;titleBitmapText=null;titleBitmapColor=null;maxTextWidth=0;maxTextHeight=0;middle=0;center=0;fontSizeOffset=0;latPos="";longPos="";labelColor=vt("");valueColor="";normalizedConfig=Dt(()=>this.runtime.options()??s.DEFAULT_CONFIG);positionPaths=Dt(()=>this.normalizedConfig().paths??{});static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:false,displayName:"Position",filterSelfPaths:true,paths:{longPath:{description:"Longitude",path:"self.navigation.position.longitude",source:"default",pathType:"number",isPathConfigurable:true,convertUnitTo:"longitudeMin",showPathSkUnitsFilter:true,pathSkUnitsFilter:null,sampleTime:500},latPath:{description:"Latitude",path:"self.navigation.position.latitude",source:"default",pathType:"number",isPathConfigurable:true,convertUnitTo:"latitudeMin",showPathSkUnitsFilter:true,pathSkUnitsFilter:null,sampleTime:500}},color:"contrast",enableTimeout:false,dataTimeout:5};constructor(){Fa(()=>{let e=this.normalizedConfig(),t=this.theme();t&&ge(()=>{let i=c(e.color??"contrast",t);this.labelColor.set(i.dim),this.valueColor=i.color,this.draw();});}),Fa(()=>{let e=this.positionPaths().longPath;e?.path&&ge(()=>this.streams.observe("longPath",t=>{let i=t?.data?.value;i==null?this.longPos="":e.convertUnitTo==="pdeg"?this.longPos=i.toFixed(6)+"\xB0":this.longPos=String(i),this.calculateFontSizeAndPositions(),this.draw();}));}),Fa(()=>{let e=this.positionPaths().latPath;e?.path&&ge(()=>this.streams.observe("latPath",t=>{let i=t?.data?.value;i==null?this.latPos="":e.convertUnitTo==="pdeg"?this.latPos=i.toFixed(7)+"\xB0":this.latPos=String(i),this.calculateFontSizeAndPositions(),this.draw();}));});}ngAfterViewInit(){this.canvasElement=this.canvasRef().nativeElement,this.ctx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(e,t)=>{this.cssWidth=e,this.cssHeight=t,this.calculateFontSizeAndPositions(),this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.calculateFontSizeAndPositions(),this.draw();}calculateFontSizeAndPositions(){if(!this.cssWidth||!this.cssHeight)return;this.maxTextHeight=Math.floor(this.cssHeight*.6/2),this.maxTextWidth=Math.floor(this.cssWidth*.85),this.center=this.cssWidth/2,this.middle=this.cssHeight*.57;let e=this.latPos.length>this.longPos.length?this.latPos:this.longPos;if(this.ctx){let t=this.canvas.calculateOptimalFontSize(this.ctx,e,this.maxTextWidth,this.maxTextHeight,"bold");this.fontSizeOffset=Math.floor(t*5e-4);}}draw(){if(!this.ctx||!this.canvasElement)return;let t=this.normalizedConfig().displayName||"Position",i=this.labelColor();(!this.titleBitmap||this.titleBitmap.width!==this.canvasElement.width||this.titleBitmap.height!==this.canvasElement.height||this.titleBitmapText!==t||this.titleBitmapColor!==i)&&(this.titleBitmap=this.canvas.createTitleBitmap(t,i,"normal",this.cssWidth,this.cssHeight),this.titleBitmapText=t,this.titleBitmapColor=i),this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),this.titleBitmap&&this.titleBitmap.width>0&&this.titleBitmap.height>0&&this.ctx.drawImage(this.titleBitmap,0,0,this.cssWidth,this.cssHeight),this.canvas.drawText(this.ctx,this.latPos,this.center,this.middle-this.fontSizeOffset,this.maxTextWidth,this.maxTextHeight,"bold",this.valueColor,"center","bottom"),this.canvas.drawText(this.ctx,this.longPos,this.center,this.middle+this.fontSizeOffset,this.maxTextWidth,this.maxTextHeight,"bold",this.valueColor,"center","top");}ngOnDestroy(){try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(e){}}static \u0275fac=function(t){return new(t||s)};static \u0275cmp=JD({type:s,selectors:[["widget-position"]],viewQuery:function(t,i){t&1&&eg(i.canvasRef,P,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:0,consts:[["canvasMainRef",""],[1,"position-canvas"]],template:function(t,i){t&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%;overflow:hidden}.position-canvas[_ngcontent-%COMP%]{display:block;width:100%!important;height:100%!important;min-height:1px}"]})}return s})();export{B as WidgetPositionComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import'./chunk-h2q_pbbF.js';import {d1 as Hj,w,du as p,dv as rt,aZ as R,dw as S,$ as $j,v as vt,D as Dt,dx as n$1,F as Fa,dn as ge,J as JD,_ as _w,c as $h,M as Mw,f as eg,K as Kw,bu as ut,dy as K,ao as ue,a6 as Lr,b0 as Wl,cp as Uh,g as qw,B as Bh}from'./main-BNR44HGB.js';import {c}from'./chunk-D_wrJJxl.js';var H=["widgetDataChart"],C=(()=>{class n{theme=Hj.required();color=null;dataPath=null;dataSource=null;convertUnitTo=null;numDecimal=null;yScaleMin=null;yScaleMax=null;inverseYAxis=false;verticalChart=null;datasetUUID=null;unitsService=w(ut);dsService=w(K);ngZone=w(ue);canvasService=w(R);widgetDataChart=$j("widgetDataChart",{read:Lr});lineChartData={datasets:[]};lineChartOptions={parsing:false,datasets:{line:{pointRadius:0,pointHoverRadius:0,tension:.4}},animations:{tension:{easing:"easeInOutCubic"}}};lineChartType="line";chart=null;dsServiceSub=null;datasetConfig=null;dataSourceInfo=null;isDestroyed=false;lastChartSignature=null;config={datasetAverageArray:"sma",showAverageData:false,trackAgainstAverage:false,startScaleAtZero:false,yScaleSuggestedMin:null,yScaleSuggestedMax:null,enableMinMaxScaleLimit:false};constructor(){Fa(()=>{this.theme()&&ge(()=>{this.datasetConfig&&(this.setChartOptions(),this.setDatasetsColors());});});}startChart(){if(!(this.isDestroyed||!this.datasetUUID)&&(this.datasetConfig=this.dsService.getDatasetConfig(this.datasetUUID)??null,this.dataSourceInfo=this.dsService.getDataSourceInfo(this.datasetUUID)??null,this.datasetConfig&&this.dataSourceInfo)){let t=this.buildChartSignature();if(this.chart&&t===this.lastChartSignature)return;this.chart&&t!==this.lastChartSignature&&this.destroyChart(),this.setChartOptions(),this.createDatasets();let i=this.widgetDataChart()?.nativeElement?.getContext("2d");if(!i)return;this.chart=new Wl(i,{type:this.lineChartType,data:this.lineChartData,options:this.lineChartOptions}),this.lastChartSignature=t,this.startStreaming();}}buildChartSignature(){return [this.datasetUUID,this.dataPath,this.dataSource,this.convertUnitTo,this.numDecimal,this.yScaleMin,this.yScaleMax,this.inverseYAxis?"1":"0",this.verticalChart?"1":"0",this.color].join("|")}setChartOptions(){let t=this.datasetConfig,e=this.dataSourceInfo;!t||!e||(this.lineChartOptions.maintainAspectRatio=false,this.lineChartOptions.animation=false,this.lineChartOptions.indexAxis=this.verticalChart?"y":"x",this.verticalChart?this.lineChartOptions.scales={x:{display:false,position:"right",suggestedMin:this.config.enableMinMaxScaleLimit?void 0:this.numberOrUndefined(this.yScaleMin),suggestedMax:this.config.enableMinMaxScaleLimit?void 0:this.numberOrUndefined(this.yScaleMax),min:this.config.enableMinMaxScaleLimit?this.numberOrUndefined(this.yScaleMin):void 0,max:this.config.enableMinMaxScaleLimit?this.numberOrUndefined(this.yScaleMax):void 0,beginAtZero:this.config.startScaleAtZero,reverse:this.inverseYAxis,title:{display:false,text:"Value Axis",align:"center"},ticks:{maxTicksLimit:8,precision:this.numberOrUndefined(this.numDecimal),color:this.getThemeColors().averageChartLine,major:{enabled:true}},grid:{display:false,color:this.theme().contrastDimmer}},y:{type:"realtime",display:false,title:{display:false},time:{unit:t.timeScaleFormat,minUnit:"second",round:"second",displayFormats:{hour:"k:mm''",minute:"mm''",second:'ss"',millisecond:"SSS"}},ticks:{autoSkip:false,color:this.getThemeColors().averageChartLine,major:{enabled:true}},grid:{display:false,color:this.theme().contrastDimmer}}}:this.lineChartOptions.scales={x:{type:"realtime",display:false,title:{display:false},time:{unit:t.timeScaleFormat,minUnit:"second",round:"second",displayFormats:{hour:"k:mm''",minute:"mm''",second:'ss"',millisecond:"SSS"}},ticks:{autoSkip:false,color:this.getThemeColors().averageChartLine,major:{enabled:true}},grid:{display:false,color:this.theme().contrastDimmer}},y:{display:false,position:"right",suggestedMin:this.config.enableMinMaxScaleLimit?void 0:this.numberOrUndefined(this.yScaleMin),suggestedMax:this.config.enableMinMaxScaleLimit?void 0:this.numberOrUndefined(this.yScaleMax),min:this.config.enableMinMaxScaleLimit?this.numberOrUndefined(this.yScaleMin):void 0,max:this.config.enableMinMaxScaleLimit?this.numberOrUndefined(this.yScaleMax):void 0,beginAtZero:this.config.startScaleAtZero,reverse:this.inverseYAxis,title:{display:false,text:"Value Axis",align:"center"},ticks:{maxTicksLimit:8,precision:this.numberOrUndefined(this.numDecimal),color:this.getThemeColors().averageChartLine,major:{enabled:true}},grid:{display:false,color:this.theme().contrastDimmer}}},this.lineChartOptions.plugins={legend:{display:false},annotation:{annotations:{}},streaming:{duration:e.maxDataPoints*e.sampleTime,delay:e.sampleTime,frameRate:t.timeScaleFormat==="day"?5:t.timeScaleFormat==="hour"?8:t.timeScaleFormat==="minute"?15:30}});}numberOrUndefined(t){return t??void 0}createDatasets(){let t=this.lineChartOptions.scales?.y?.reverse?"start":true;this.lineChartData.datasets=[],this.lineChartData.datasets.push({label:"Value",data:[],order:0,parsing:false,tension:.4,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:3,fill:t}),this.lineChartData.datasets.push({label:"Average",data:[],order:1,parsing:false,tension:.4,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:3,fill:t}),this.setDatasetsColors();}setDatasetsColors(){this.lineChartData.datasets.forEach(t=>{t.borderColor=this.getThemeColors().averageLine,t.backgroundColor=this.getThemeColors().averageFill;});}getThemeColors(){let t=this.color,e={valueLine:"",valueFill:"",averageLine:"",averageFill:"",averageChartLine:"",chartLabel:"",chartValue:""};switch(t){case "contrast":this.config.trackAgainstAverage?(e.valueLine=this.theme().contrastDimmer,e.valueFill=this.theme().contrastDimmer,e.averageLine=this.theme().contrast,e.averageFill=this.theme().contrast,e.chartValue=e.averageLine):(e.valueLine=this.theme().contrast,e.valueFill=this.theme().contrast,e.averageLine=this.theme().contrastDimmer,e.averageFill=this.theme().contrastDimmer,e.chartValue=this.theme().contrast),e.averageChartLine=this.theme().contrastDim,e.chartLabel=this.theme().contrastDim;break;case "blue":this.config.trackAgainstAverage?(e.valueLine=this.theme().blueDimmer,e.valueFill=this.theme().blueDimmer,e.averageLine=this.theme().blue,e.averageFill=this.theme().blue,e.chartValue=e.averageLine):(e.valueLine=this.theme().blue,e.valueFill=this.theme().blue,e.averageLine=this.theme().blueDimmer,e.averageFill=this.theme().blueDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().blueDim,e.chartLabel=this.theme().contrastDim;break;case "green":this.config.trackAgainstAverage?(e.valueLine=this.theme().greenDimmer,e.valueFill=this.theme().greenDimmer,e.averageLine=this.theme().green,e.averageFill=this.theme().green,e.chartValue=e.averageLine):(e.valueLine=this.theme().green,e.valueFill=this.theme().green,e.averageLine=this.theme().greenDimmer,e.averageFill=this.theme().greenDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().greenDim,e.chartLabel=this.theme().contrastDim;break;case "pink":this.config.trackAgainstAverage?(e.valueLine=this.theme().pinkDimmer,e.valueFill=this.theme().pinkDimmer,e.averageLine=this.theme().pink,e.averageFill=this.theme().pink,e.chartValue=e.averageLine):(e.valueLine=this.theme().pink,e.valueFill=this.theme().pink,e.averageLine=this.theme().pinkDimmer,e.averageFill=this.theme().pinkDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().pinkDim,e.chartLabel=this.theme().contrastDim;break;case "orange":this.config.trackAgainstAverage?(e.valueLine=this.theme().orangeDimmer,e.valueFill=this.theme().orangeDimmer,e.averageLine=this.theme().orange,e.averageFill=this.theme().orange,e.chartValue=e.averageLine):(e.valueLine=this.theme().orange,e.valueFill=this.theme().orange,e.averageLine=this.theme().orangeDimmer,e.averageFill=this.theme().orangeDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().orangeDim,e.chartLabel=this.theme().contrastDim;break;case "purple":this.config.trackAgainstAverage?(e.valueLine=this.theme().purpleDimmer,e.valueFill=this.theme().purpleDimmer,e.averageLine=this.theme().purple,e.averageFill=this.theme().purple,e.chartValue=e.averageLine):(e.valueLine=this.theme().purple,e.valueFill=this.theme().purple,e.averageLine=this.theme().purpleDimmer,e.averageFill=this.theme().purpleDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().purpleDim,e.chartLabel=this.theme().contrastDim;break;case "grey":this.config.trackAgainstAverage?(e.valueLine=this.theme().greyDimmer,e.valueFill=this.theme().greyDimmer,e.averageLine=this.theme().grey,e.averageFill=this.theme().grey,e.chartValue=e.averageLine):(e.valueLine=this.theme().grey,e.valueFill=this.theme().grey,e.averageLine=this.theme().greyDimmer,e.averageFill=this.theme().greyDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().greyDim,e.chartLabel=this.theme().contrastDim;break;case "yellow":this.config.trackAgainstAverage?(e.valueLine=this.theme().yellowDimmer,e.valueFill=this.theme().yellowDimmer,e.averageLine=this.theme().yellow,e.averageFill=this.theme().yellow,e.chartValue=e.averageLine):(e.valueLine=this.theme().yellow,e.valueFill=this.theme().yellow,e.averageLine=this.theme().yellowDimmer,e.averageFill=this.theme().yellowDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().yellowDim,e.chartLabel=this.theme().contrastDim;break}return e}startStreaming(){if(this.dsServiceSub?.unsubscribe(),!this.datasetUUID||!this.chart)return;let t=this.dsService.getDatasetBatchThenLiveObservable(this.datasetUUID);t&&(this.dsServiceSub=t.subscribe(e=>{if(!(this.isDestroyed||!this.chart||!this.chart.ctx)){if(Array.isArray(e)){let s=this.transformDatasetRows(e,0);if(this.chart.data.datasets[0].data.push(...s),this.config.showAverageData){let r=this.transformDatasetRows(e,this.config.datasetAverageArray);this.chart.data.datasets[1].data.push(...r);}}else {let s=this.transformDatasetRows([e],0)[0];if(this.chart.data.datasets[0].data.push(s),this.config.showAverageData){let r=this.transformDatasetRows([e],this.config.datasetAverageArray)[0];this.chart.data.datasets[1].data.push(r);}}this.ngZone.runOutsideAngular(()=>{if(this.isDestroyed||!this.chart)return;let s=this.chart;s.ctx&&s.update("none");});}}));}destroyChart(){this.dsServiceSub?.unsubscribe(),this.dsServiceSub=null,this.chart?.destroy(),this.chart=null,this.lastChartSignature=null;}transformDatasetRows(t,e){let i=a=>this.unitsService.convertToUnit(this.convertUnitTo??"",a)??a,s=this.verticalChart===true,r=this.config.datasetAverageArray;return t.map(a=>{if(s){if(e===0)return {x:i(a.data.value),y:a.timestamp};{let D={sma:a.data.sma,ema:a.data.ema,dema:a.data.doubleEma,avg:a.data.lastAverage};return {x:i(D[r]??a.data.value),y:a.timestamp}}}else {if(e===0)return {x:a.timestamp,y:i(a.data.value)};{let D={sma:a.data.sma,ema:a.data.ema,dema:a.data.doubleEma,avg:a.data.lastAverage};return {x:a.timestamp,y:i(D[r]??a.data.value)}}}})}ngOnDestroy(){this.isDestroyed=true,this.destroyChart();let t=this.widgetDataChart?.()?.nativeElement;this.canvasService.releaseCanvas(t,{clear:true,removeFromDom:true});}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=JD({type:n,selectors:[["minichart"]],viewQuery:function(e,i){e&1&&eg(i.widgetDataChart,H,5,Lr),e&2&&Kw();},inputs:{theme:[1,"theme"]},decls:2,vars:0,consts:[["widgetDataChart",""],[2,"z-index","inherit"]],template:function(e,i){e&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:calc(90% - 10px);position:absolute;bottom:0;border-radius:12px;overflow:hidden}"]})}return n})();var I=["canvasMainRef"];function E(n,P){if(n&1&&$h(0,"minichart",1),n&2){let t=qw();Bh("theme",t.theme());}}var se=(()=>{class n{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:true,displayName:"Gauge Label",filterSelfPaths:true,paths:{numericPath:{description:"Numeric Data",path:null,source:null,pathType:"number",suppressBootstrapNull:true,isPathConfigurable:true,convertUnitTo:"unitless",showPathSkUnitsFilter:true,pathSkUnitsFilter:null,sampleTime:500}},showMax:false,showMin:false,numDecimal:1,showMiniChart:false,yScaleMin:0,yScaleMax:10,inverseYAxis:false,verticalChart:false,color:"contrast",enableTimeout:false,dataTimeout:5,ignoreZones:false};runtime=w(p);stream=w(rt);canvas=w(R);datasetLifecycle=w(S);miniChart=$j(C);canvasMainRef=$j.required("canvasMainRef");showMiniChart=vt(false);labelColor=vt("");canvasElement;canvasCtx=null;cssWidth=0;cssHeight=0;backgroundBitmap=null;backgroundBitmapText=null;dataValue=null;maxValue=null;minValue=null;valueColor="";valueStateColor="";maxValueTextWidth=0;maxValueTextHeight=0;maxMinMaxTextWidth=0;maxMinMaxTextHeight=0;streamRegistered=false;pathDataState=null;isDestroyed=false;lastSubscriptionSignature=null;normalizedConfig=Dt(()=>this.runtime.options()??n.DEFAULT_CONFIG);numericPathConfig=Dt(()=>this.normalizedConfig().paths?.numericPath);subscriptionSignature=Dt(()=>{this.normalizedConfig();let e=this.numericPathConfig();if(!e?.path)return null;let i=e.source?.trim()||"default";return [e.path,e.pathType,e.sampleTime,e.convertUnitTo,i,e.suppressBootstrapNull?"1":"0"].join("|")});onNumericValue=t=>{if(this.dataValue=t.data.value,this.minValue===null||this.dataValue<this.minValue?this.minValue=this.dataValue:(this.maxValue===null||this.dataValue>this.maxValue)&&(this.maxValue=this.dataValue),!this.normalizedConfig().ignoreZones&&this.pathDataState!==t.state)switch(this.pathDataState=t.state,t.state){case n$1.Alarm:this.valueStateColor=this.theme().zoneAlarm;break;case n$1.Warn:this.valueStateColor=this.theme().zoneWarn;break;case n$1.Alert:this.valueStateColor=this.theme().zoneAlert;break;default:this.valueStateColor=this.valueColor;break}this.drawWidget();};constructor(){this.showMiniChart.set(this.normalizedConfig().showMiniChart??false),Fa(()=>{let t=this.theme(),e=this.normalizedConfig().color;ge(()=>{t&&e!==void 0&&(this.setColors(),this.drawWidget());});}),Fa(()=>{let t=this.subscriptionSignature();ge(()=>{this.isDestroyed||!this.canvasCtx||t===this.lastSubscriptionSignature&&this.streamRegistered||(this.minValue=null,this.maxValue=null,this.dataValue=null,this.pathDataState=null,this.lastSubscriptionSignature=t,t&&(this.stream?.observe("numericPath",this.onNumericValue),this.streamRegistered=true,this.manageDatasetAndChart()));});}),Fa(()=>{let t=this.showMiniChart(),e=this.miniChart(),i=this.normalizedConfig(),s=this.numericPathConfig();[i?.showMiniChart?"1":"0",s?.path??"",s?.source??"default",s?.convertUnitTo??"",i?.numDecimal??"",i?.yScaleMin??"",i?.yScaleMax??"",i?.inverseYAxis?"1":"0",i?.verticalChart?"1":"0",i?.color??""].join("|")&&t&&e&&(this.setMiniChart(),e.startChart());});}ngOnInit(){this.setColors(),this.canvasElement=this.canvasMainRef().nativeElement,this.canvasCtx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(t,e)=>{this.cssWidth=t,this.cssHeight=e,this.calculateMaxMinTextDimensions(),this.drawWidget();}});}ngAfterViewInit(){this.isDestroyed||!this.streamRegistered&&this.subscriptionSignature()&&(this.stream?.observe("numericPath",this.onNumericValue),this.streamRegistered=true,this.manageDatasetAndChart());}calculateMaxMinTextDimensions(){this.maxValueTextWidth=Math.floor(this.cssWidth*.85),this.maxValueTextHeight=Math.floor(this.cssHeight*.7),this.maxMinMaxTextWidth=Math.floor(this.cssWidth*.57),this.maxMinMaxTextHeight=Math.floor(this.cssHeight*.1);}manageDatasetAndChart(){let t=this.normalizedConfig(),e=this.numericPathConfig(),i=!!t.showMiniChart;if(this.showMiniChart.set(i),!i){this.datasetLifecycle.removeDatasetIfExists(this.id(),false);return}if(!e||!e.path)return;let s=e.source??"default";this.datasetLifecycle.syncNumericMiniChartDataset(this.id(),e.path,s);}setMiniChart(){let t=this.miniChart(),e=this.normalizedConfig(),i=this.numericPathConfig();t&&(t.dataPath=i?.path??null,t.dataSource=i?.source??"default",t.color=e.color??"contrast",t.convertUnitTo=i?.convertUnitTo??null,t.numDecimal=e.numDecimal??null,t.yScaleMin=e.yScaleMin??null,t.yScaleMax=e.yScaleMax??null,t.inverseYAxis=e.inverseYAxis??false,t.verticalChart=e.verticalChart??null,t.datasetUUID=this.id());}setColors(){let t=this.normalizedConfig(),e=this.theme(),i=t.color??"contrast";this.labelColor.set(c(i,e).dim),this.valueStateColor=this.valueColor=c(i,e).color,this.backgroundBitmap=null,this.backgroundBitmapText=null;}drawWidget(){if(!this.canvasCtx)return;let t=this.normalizedConfig(),e=this.numericPathConfig()?.convertUnitTo??"",i=10*this.canvas.scaleFactor,s=5*this.canvas.scaleFactor,r=(t.displayName??"")+"|"+e;(!this.backgroundBitmap||this.backgroundBitmap.width!==this.canvasElement.width||this.backgroundBitmap.height!==this.canvasElement.height||this.backgroundBitmapText!==r)&&(this.backgroundBitmap=this.canvas.renderStaticToBitmap(this.canvasCtx,this.cssWidth,this.cssHeight,a=>{this.canvas.drawTitleInternal(a,t.displayName??"",this.labelColor(),"normal",this.cssWidth,this.cssHeight,.1),["unitless","percent","ratio","latitudeSec","latitudeMin","longitudeSec","longitudeMin"].includes(e)||this.canvas.drawText(a,e,this.cssWidth-i,this.cssHeight-s,Math.floor(this.cssWidth*.25),Math.floor(this.cssHeight*.15),"bold",this.valueColor,"end","bottom");}),this.backgroundBitmapText=r),this.canvas.clearCanvas(this.canvasCtx,this.cssWidth,this.cssHeight),this.backgroundBitmap&&this.backgroundBitmap.width>0&&this.backgroundBitmap.height>0&&this.canvasCtx.drawImage(this.backgroundBitmap,0,0,this.cssWidth,this.cssHeight),this.drawValue(),(t.showMax||t.showMin)&&this.drawMinMax();}drawValue(){let t=this.getValueText(),e=this.canvasCtx;e&&this.canvas.drawText(e,t,Math.floor(this.cssWidth/2),Math.floor(this.cssHeight/2*1.15),this.maxValueTextWidth,this.maxValueTextHeight,"bold",this.valueStateColor);}getValueText(){if(this.dataValue===null)return "--";let t=this.normalizedConfig(),e=this.numericPathConfig()?.convertUnitTo??"";return ["latitudeSec","latitudeMin","longitudeSec","longitudeMin","D HH:MM:SS"].includes(e)?this.dataValue.toString():this.applyDecorations(this.dataValue.toFixed(t.numDecimal??1))}drawMinMax(){let t=this.normalizedConfig();if(!t.showMin&&!t.showMax)return;let e=t.numDecimal??1,i="";t.showMin&&(i=this.minValue!=null?` Min: ${this.applyDecorations(this.minValue.toFixed(e))}`:" Min: --"),t.showMax&&(i+=this.maxValue!=null?` Max: ${this.applyDecorations(this.maxValue.toFixed(e))}`:" Max: --"),i=i.trim();let s=10*this.canvas.scaleFactor,r=5*this.canvas.scaleFactor,a=this.canvasCtx;a&&this.canvas.drawText(a,i,s,Math.floor(this.cssHeight-r),this.maxMinMaxTextWidth,this.maxMinMaxTextHeight,"normal",this.valueColor,"start","bottom");}applyDecorations(t){switch(this.numericPathConfig()?.convertUnitTo??""){case "percent":case "percentraw":t+="%";break}return t}ngOnDestroy(){this.isDestroyed=true,this.datasetLifecycle.removeDatasetIfExists(this.id(),false);try{this.canvas.unregisterCanvas(this.canvasElement);}catch(t){}}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=JD({type:n,selectors:[["widget-numeric"]],viewQuery:function(e,i){e&1&&eg(i.miniChart,C,5)(i.canvasMainRef,I,5),e&2&&Kw(2);},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:3,vars:1,consts:[["canvasMainRef",""],[3,"theme"],[1,"numeric-canvas"]],template:function(e,i){e&1&&(_w(0,E,1,1,"minichart",1),$h(1,"canvas",2,0)),e&2&&Mw(i.showMiniChart()?0:-1);},dependencies:[C],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%}.numeric-wrapper[_ngcontent-%COMP%]{width:100%;height:100%;min-height:1px}.numeric-canvas[_ngcontent-%COMP%]{position:relative;width:100%!important;height:100%!important;display:block}"]})}return n})();export{se as WidgetNumericComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {WidgetFreeboardskComponent as ae}from'./chunk-Di5pPpU7.js';import {$ as $j,w,G as Gi,a as G$1,i as ir,v as vt,D as Dt,W as Wp,E as Em,F as Fa,J as JD,Q as Qn,z as za,q as qo,O as Op,R as Rp,y as yt,b as wt,P as Pi,_ as _w,c as $h,u as ul,d as ig,B as Bh,j as jT,e as EE,M as Mw,s as sg,f as eg,K as Kw,g as qw,h as Fw,k as Qh,l as ud,m as dd}from'./main-BNR44HGB.js';import'./chunk-DVB9tiW3.js';var G=["panel"],Q=(i,f)=>[i,f];function j(i,f){if(i&1&&$h(0,"div",7),i&2){let t=qw();ig("transform",t.ghostTransform());}}function H(i,f){if(i&1){let t=Fw();Pi(0,"div",8),Qh("pointerdown",function(n){ud(t);let o=qw();return dd(o.startResize(n))}),Pi(1,"button",9),Qh("pointerdown",function(n){ud(t);let o=qw();return dd(o.startResize(n))}),$h(2,"mat-icon",10),ul()();}}var pt=(()=>{class i{panelEl=$j.required("panel");_settings=w(Gi);_dashboard=w(G$1);breakpointObserver=w(ir);side=vt(this._settings.getSplitShellSide());panelRatio=vt(this._settings.getSplitShellWidth());originalPanelRatio=null;panelWidth=vt(0);panelCollapsed=Dt(()=>{let t=this._dashboard.dashboards(),e=this._dashboard.activeDashboard();return e==null||e<0?false:!!t[e]?.collapseSplitShell});_fskShellSwipeDisabled=Wp(this._settings.getSplitShellSwipeDisabledAsO(),{initialValue:false});fskShellSwipeDisabled=Dt(()=>this._fskShellSwipeDisabled()??false);handset$=this.breakpointObserver.observe(Em.HandsetPortrait);handset=Wp(this.handset$,{initialValue:{matches:false,breakpoints:{}}});freeboardWidgetStub={uuid:"persistent-freeboard-shell",type:"widget-freeboardsk",config:{}};chartplotterModeInPortrait=Dt(()=>this.handset().matches&&!this.panelCollapsed());canResize=Dt(()=>!this._dashboard.isDashboardStatic()&&!this.panelCollapsed());resizing=false;startX=0;startW=0;boundMove=t=>this.onMove(t);boundUp=()=>this.onUp();static MIN_DELTA_PX=1;ghostActive=vt(false);ghostTransform=vt("");ghostWidth=0;recomputeWidth=()=>{let t=this.panelEl()?.nativeElement.parentElement;if(!t)return;let e=t.clientWidth;this.panelWidth.set(Math.round(e*this.panelRatio()));};constructor(){window.addEventListener("resize",this.recomputeWidth,{passive:true}),queueMicrotask(this.recomputeWidth),Fa(()=>{this.chartplotterModeInPortrait(),this.panelRatio(),this.recomputeWidth(),setTimeout(()=>window.dispatchEvent(new Event("resize")),0);}),Fa(()=>{let t=this._dashboard.isDashboardStatic();t||this.originalPanelRatio===null&&(this.originalPanelRatio=this.panelRatio()),t&&this.originalPanelRatio;}),Fa(()=>{if(this._dashboard.layoutEditSaved(),this.originalPanelRatio!==null){let t=this.panelRatio();this._settings.setSplitShellWidth(t),this.originalPanelRatio=null;}}),Fa(()=>{if(this._dashboard.layoutEditCanceled(),this.originalPanelRatio!==null){let t=this.originalPanelRatio;this.panelRatio.set(t),queueMicrotask(()=>this.recomputeWidth()),this.originalPanelRatio=null;}});}startResize(t){this.canResize()&&(this.resizing=true,this.startX=t.clientX,this.startW=this.panelWidth(),this.ghostWidth=this.startW,this.ghostActive.set(true),this.updateGhostTransform(this.startW),t.target.setPointerCapture(t.pointerId),window.addEventListener("pointermove",this.boundMove,{passive:true}),window.addEventListener("pointerup",this.boundUp,{passive:true}));}onMove(t){if(!this.resizing)return;let e=this.side()==="left"?t.clientX-this.startX:this.startX-t.clientX,o=this.panelEl()?.nativeElement.parentElement?.clientWidth??1,p=this.startW+e,_=o*.1,$=o*.9,v=Math.min($,Math.max(_,p));Math.abs(v-this.ghostWidth)<i.MIN_DELTA_PX||(this.ghostWidth=v,this.updateGhostTransform(v));}onUp(){if(!this.resizing)return;this.resizing=false,window.removeEventListener("pointermove",this.boundMove),window.removeEventListener("pointerup",this.boundUp);let t=this.ghostWidth;this.ghostActive.set(false);let e=this.panelEl();e&&!this.panelCollapsed()&&(e.nativeElement.style.width=t+"px"),this.panelWidth.set(t);let o=this.panelEl()?.nativeElement.parentElement?.clientWidth??t,p=o?t/o:.3,_=this.panelRatio();Math.abs(p-_)>5e-4&&this.panelRatio.set(p);}updateGhostTransform(t){this.side()==="left"?this.ghostTransform.set(`translateX(${t}px)`):this.ghostTransform.set(`translateX(-${t}px)`);}ngOnDestroy(){window.removeEventListener("resize",this.recomputeWidth),this.resizing&&(window.removeEventListener("pointermove",this.boundMove),window.removeEventListener("pointerup",this.boundUp));}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=JD({type:i,selectors:[["split-shell"]],viewQuery:function(e,n){e&1&&eg(n.panelEl,G,5),e&2&&Kw();},decls:8,vars:18,consts:[["panel",""],[1,"split-root",3,"ngClass"],[1,"resize-ghost",3,"transform"],[1,"fsk-shell"],["role","separator","aria-label","Resize Freeboard chartplotter panel","aria-orientation","vertical",1,"drag-handle"],[1,"fsk-iframe",3,"type","id","swipeDisabled","disableWidgetShell"],[1,"dash-container"],[1,"resize-ghost"],["role","separator","aria-label","Resize Freeboard chartplotter panel","aria-orientation","vertical",1,"drag-handle",3,"pointerdown"],["mat-mini-fab","","tabindex","-1","aria-hidden","true",1,"drag-fab",3,"pointerdown"],["fontIcon","drag_indicator"]],template:function(e,n){e&1&&(Pi(0,"div",1),_w(1,j,1,2,"div",2),Pi(2,"div",3,0),_w(4,H,3,0,"div",4),$h(5,"widget-freeboardsk",5),ul(),Pi(6,"div",6),$h(7,"dashboard"),ul()()),e&2&&(ig("--panel-ratio",n.panelRatio()),Bh("ngClass",jT(15,Q,n.side()==="left"?"side-left":"side-right",n.chartplotterModeInPortrait()?"portrait-column":"")),EE(),Mw(n.ghostActive()?1:-1),EE(),ig("width",n.chartplotterModeInPortrait()?null:n.panelWidth(),"px"),sg("collapsed",n.panelCollapsed())("drag-disabled",!n.canResize()),EE(2),Mw(n.canResize()?4:-1),EE(),Bh("type",n.freeboardWidgetStub.type)("id",n.freeboardWidgetStub.uuid)("swipeDisabled",n.fskShellSwipeDisabled())("disableWidgetShell",true));},dependencies:[Qn,za,ae,qo,Op,Rp,yt,wt],styles:[".split-root[_ngcontent-%COMP%]{position:relative;width:100%;height:100%;display:flex;overflow:hidden}.split-root.side-left[_ngcontent-%COMP%]{flex-direction:row}.split-root.side-right[_ngcontent-%COMP%]{flex-direction:row-reverse}.split-root.portrait-column[_ngcontent-%COMP%]{flex-direction:column}.split-root.portrait-column[_ngcontent-%COMP%] .fsk-shell[_ngcontent-%COMP%], .split-root.portrait-column[_ngcontent-%COMP%] .dash-container[_ngcontent-%COMP%]{width:100%!important;min-height:0}.split-root.portrait-column[_ngcontent-%COMP%] .fsk-shell[_ngcontent-%COMP%]{flex:0 0 calc(var(--panel-ratio, .3) * 100%)}.split-root.portrait-column[_ngcontent-%COMP%] .dash-container[_ngcontent-%COMP%]{flex:1 1 auto;min-height:0;overflow:hidden}.split-root.side-left.portrait-column[_ngcontent-%COMP%] .dash-container[_ngcontent-%COMP%]{order:2}.split-root.side-left.portrait-column[_ngcontent-%COMP%] .fsk-shell[_ngcontent-%COMP%]{order:1}.split-root.side-right.portrait-column[_ngcontent-%COMP%] .fsk-shell[_ngcontent-%COMP%]{order:2}.split-root.side-right.portrait-column[_ngcontent-%COMP%] .dash-container[_ngcontent-%COMP%]{order:1}.split-root.portrait-column[_ngcontent-%COMP%] .fsk-shell.collapsed[_ngcontent-%COMP%]{flex:0 0 0!important}.split-root.portrait-column[_ngcontent-%COMP%] .drag-handle[_ngcontent-%COMP%], .split-root.portrait-column[_ngcontent-%COMP%] .resize-ghost[_ngcontent-%COMP%]{display:none}.fsk-shell[_ngcontent-%COMP%]{position:relative;height:100%;display:flex;flex-direction:column;background:var(--mat-sys-surface-container, #111);transition:width .2s ease}.fsk-shell.collapsed[_ngcontent-%COMP%]{width:1px!important;visibility:hidden;opacity:0;pointer-events:none}.fsk-iframe[_ngcontent-%COMP%]{flex:1 1 auto;min-width:0}.dash-container[_ngcontent-%COMP%]{flex:1 1 auto;min-width:0;height:100%}.drag-handle[_ngcontent-%COMP%]{position:absolute;top:0;bottom:0;width:3px;cursor:col-resize;background:var(--mat-sys-inverse-primary);z-index:5}.drag-handle[_ngcontent-%COMP%] .drag-fab[_ngcontent-%COMP%]{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:28px;height:28px;min-width:28px;cursor:col-resize;pointer-events:auto}.drag-handle[_ngcontent-%COMP%] .drag-fab[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px;line-height:20px}.side-left[_ngcontent-%COMP%] .drag-handle[_ngcontent-%COMP%]{right:-2px}.side-right[_ngcontent-%COMP%] .drag-handle[_ngcontent-%COMP%]{left:-2px}.drag-handle[_ngcontent-%COMP%]:hover{background:var(--mat-sys-error-container)}.side-left[_ngcontent-%COMP%] .collapse-toggle[_ngcontent-%COMP%]{left:.25rem}.side-right[_ngcontent-%COMP%] .collapse-toggle[_ngcontent-%COMP%]{right:.25rem}.fsk-shell.drag-disabled[_ngcontent-%COMP%] .drag-handle[_ngcontent-%COMP%]{cursor:not-allowed;opacity:.4}.resize-ghost[_ngcontent-%COMP%]{position:absolute;top:0;bottom:0;width:2px;background:var(--mat-sys-error-container);opacity:.9;pointer-events:none;z-index:30;will-change:transform;transition:none}.side-left[_ngcontent-%COMP%] .resize-ghost[_ngcontent-%COMP%]{left:0}.side-right[_ngcontent-%COMP%] .resize-ghost[_ngcontent-%COMP%]{right:0}"]})}return i})();export{pt as SplitShellComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {cv as G}from'./main-BNR44HGB.js';var e={cardCornerRadius:4,stateBarCornerRadius:2.5,titleX:0,titleY:10,titleFontSize:12.5,primaryX:135,primaryY:48,primaryFontSize:34,primaryFontWeight:700,lineOneX:5,lineOneY:30,lineOneFontSize:20,lineTwoX:10,lineTwoY:93,lineTwoFontSize:8,idX:194,idY:26,idFontSize:7.5,metaLeftX:5,metaRightX:194,metaY:63,metaFontSize:8},C=G({},e);export{C,e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {e as e$1}from'./chunk-CyURmwWh.js';import {g as ge$1}from'./chunk-TakPRI3t.js';import {e9 as a,d1 as Hj,w,du as p,aS as De,bu as ut,aY as xe,D as Dt,$ as $j,v as vt,dx as n$1,F as Fa,dn as ge,a_ as Gp,cv as G,cw as z,J as JD,dC as x,c as $h,cn as wd,_ as _w,B as Bh,e as EE,M as Mw,f as eg,K as Kw,P as Pi,T as TT,u as ul}from'./main-BNR44HGB.js';import {c,e}from'./chunk-D_wrJJxl.js';var pe=["solarSvg"];function he(l,e){l&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No solar chargers detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K solar paths or select chargers in widget settings."),ul()());}var te=class l{static SOLAR_DESCRIPTOR=a("widget-solar-charger");static SELF_ROOT_PATH=(()=>{let e=l.SOLAR_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetSolarChargerComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${l.SELF_ROOT_PATH}.*`;id=Hj.required();type=Hj.required();theme=Hj.required();renderMode=Hj(null);static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,solarCharger:{trackedDevices:[],optionsById:{}}};static VIEWBOX_WIDTH=200;static CARD_HEIGHT=100;static CARD_GAP=8;static SOLAR_PANEL_SYMBOL_WIDTH=158.90796;static SOLAR_PANEL_SYMBOL_HEIGHT=94.949027;static SOLAR_PANEL_SCALE=.77;static SOLAR_PANEL_TRANSLATE_X=-36;static SOLAR_PANEL_TRANSLATE_Y=0;static SOLAR_PANEL_X=(135+l.SOLAR_PANEL_TRANSLATE_X)*l.SOLAR_PANEL_SCALE;static SOLAR_PANEL_Y=(0+l.SOLAR_PANEL_TRANSLATE_Y)*l.SOLAR_PANEL_SCALE;static SOLAR_PANEL_WIDTH=l.SOLAR_PANEL_SYMBOL_WIDTH*l.SOLAR_PANEL_SCALE;static SOLAR_PANEL_HEIGHT=l.SOLAR_PANEL_SYMBOL_HEIGHT*l.SOLAR_PANEL_SCALE;static PATH_BATCH_WINDOW_MS=500;runtime=w(p);data=w(De);units=w(ut);destroyRef=w(xe);displayLabel=Dt(()=>{let e=this.visibleSolarUnits();return e.length!==1?"Solar Chargers":this.resolveTitleText(e[0])});labelColor=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e).dim:"var(--kip-contrast-dim-color)"});svgRef=$j.required("solarSvg");svg;layer;glowFilterId="";renderFrameId=null;pendingRenderSnapshot=null;pathBatchTimerId=null;initialPathPaintDone=false;pendingPathUpdates=new Map;discoveredSolarIds=vt([]);trackedDevices=vt([]);optionsById=vt({});cardMode=vt({displayMode:"full",metrics:["panelVoltage","panelCurrent","voltage","current"]});chargersByKey=vt({});visibleSolarKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(a=>a.key);let r=this.chargersByKey(),t=new Set(this.discoveredSolarIds());return Object.keys(r).filter(a=>{let s=r[a];return !!s&&t.has(s.id)}).sort((a,s)=>a.localeCompare(s))});visibleSolarUnits=Dt(()=>{let e=this.visibleSolarKeys(),r=this.chargersByKey();return e.map(t=>r[t]).filter(t=>!!t)});activeDisplayMode=Dt(()=>this.renderMode()??this.cardMode().displayMode??"full");isCompactCardMode=Dt(()=>this.activeDisplayMode()==="compact");colorRole=Dt(()=>this.runtime.options()?.color??"contrast");ignoreZones=Dt(()=>this.runtime.options()?.ignoreZones??false);widgetColors=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e):null});displayModels=Dt(()=>{let e$1=this.visibleSolarUnits(),r=this.optionsById(),t=this.theme(),a=this.widgetColors(),s=this.ignoreZones()??false,i={};for(let n of e$1){let u=r[n.id]?.arrayRatedPowerW??null,c=n.panelPower??null,g=this.formatPowerAuto(c),m=u&&u>0&&c!=null?Math.max(0,Math.min(1,c/u)):0,d=n.panelPowerState??n.panelCurrentState??null,o=n.currentState??null,p=e(d,a?.dim??"var(--kip-contrast-dim-color)",t,s),T=!s&&(d===n$1.Warn||d===n$1.Alarm||d===n$1.Alert),y=e(o,"var(--kip-contrast-color)",t,s),w=this.resolveMostSevereState(n.voltageState??null,n.temperatureState??null),v=e(w,"var(--kip-contrast-color)",t,s),S=this.resolveMostSevereState(n.panelCurrentState??null,n.panelVoltageState??null,n.panelTemperatureState??null),re=e(S,"var(--kip-contrast-color)",t,s),ae=!s&&(S===n$1.Warn||S===n$1.Alarm||S===n$1.Alert),ne=e(n.loadCurrentState??null,"var(--kip-contrast-color)",t,s),I=this.valueOrDash(n.controllerMode),V=this.isRelayActive(n.load),oe=V?`${this.formatRelayState(n.load)}\xA0\xA0\xA0\xA04.5A${this.formatCurrent(n.loadCurrent)}`.trim():"",se=n.yieldToday!=null?`${this.formatEnergyYield(n.yieldToday)} Today`:"",ie=n.yieldYesterday!=null?`${this.formatEnergyYield(n.yieldYesterday)} Yesterday`:"",le=n.deviceKey??n.id;i[le]={id:n.id,source:n.source??null,deviceKey:n.deviceKey,titleText:this.resolveTitleText(n),panelPowerText:g.value,panelPowerUnitText:g.unit,panelPowerColor:p,panelPowerGlowEnabled:T,chargerCurrentTextColor:y,chargerMetaTextColor:v,panelValuesTextColor:re,panelValuesGlowEnabled:ae,gaugeProgress:m,gaugeSectionText:`${this.formatVoltage(n.panelVoltage)}`+(n.panelCurrent!=null?`, ${this.formatCurrent(n.panelCurrent)}`:"")+(n.panelTemperature!=null?`, ${this.formatTemperature(n.panelTemperature)}`:""),yieldTodayText:se,yieldYesterdayText:ie,chargerSectionCurrent:`${this.formatCurrent(n.current)}`,chargerMode:`${I.charAt(0).toUpperCase()+I.slice(1)} mode`,chargerSectionMetadata:`${n.voltage!=null?this.formatVoltage(n.voltage):""}\xA0\xA0\xA0\xA0${n.temperature!=null?this.formatTemperature(n.temperature):""}`.trim(),relaySectionVisible:V,relaySectionText:oe,relayValuesTextColor:ne};}return i});hasChargers=Dt(()=>this.visibleSolarUnits().length>0);constructor(){Fa(()=>{let r=this.runtime.options();r&&ge(()=>{this.applyConfig(r);});}),Fa(()=>{let r=this.displayModels(),t=this.visibleSolarUnits(),a=this.widgetColors();!this.svg||!a||this.requestRender({solarUnits:t,displayModels:r,widgetColors:a});});let e=this.data.subscribePathTreeWithInitial(l.ROOT_PATTERN);if(e.initial.length){for(let r of e.initial)this.enqueuePathUpdate(r,true);this.flushPendingPathUpdates(),this.initialPathPaintDone=true;}e.live$.pipe(Gp(this.destroyRef)).subscribe(r=>{this.enqueuePathUpdate(r);});}ngAfterViewInit(){this.initializeSvg(),this.requestRender();}ngOnDestroy(){this.pathBatchTimerId!==null&&(clearTimeout(this.pathBatchTimerId),this.pathBatchTimerId=null),this.renderFrameId!==null&&(cancelAnimationFrame(this.renderFrameId),this.renderFrameId=null),this.pendingRenderSnapshot=null;}initializeSvg(){this.svg=ge$1(this.svgRef().nativeElement),this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${l.CARD_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","Solar Charger View"),this.glowFilterId=`solar-panel-glow-${this.id()}`;let r=this.svg.append("defs").append("filter").attr("id",this.glowFilterId).attr("x","-30%").attr("y","-30%").attr("width","160%").attr("height","160%");r.append("feFlood").attr("class","solar-panel-glow-flood").attr("flood-color","var(--kip-widget-card-background-color)").attr("flood-opacity",.9).attr("result","color"),r.append("feComposite").attr("in","color").attr("in2","SourceGraphic").attr("operator","in").attr("result","coloredGlow"),r.append("feGaussianBlur").attr("in","coloredGlow").attr("stdDeviation",2).attr("result","blur");let t=r.append("feMerge");t.append("feMergeNode").attr("in","blur"),t.append("feMergeNode").attr("in","blur"),t.append("feMergeNode").attr("in","SourceGraphic"),this.layer=this.svg.append("g").attr("class","solar-layer");}applyConfig(e){let r=this.resolveSolarConfig(e);this.trackedDevices.set(r.trackedDevices??[]),this.reprojectSnapshotsToDeviceKeys(r.trackedDevices??[]),this.optionsById.set(r.optionsById??{}),this.cardMode.set(this.normalizeCardMode(r.cardMode));}resolveSolarConfig(e){let r=e.solarCharger,t=this.normalizeTrackedDevices(r?.trackedDevices),a=this.normalizeOptionsById(r?.optionsById);return {trackedDevices:t,optionsById:a,cardMode:this.normalizeCardMode(r?.cardMode)}}normalizeTrackedDevices(e){if(!Array.isArray(e))return [];let r=new Map;return e.forEach(t=>{if(typeof t=="string"){let u=t.trim();if(!u)return;let c=`${u}||default`;r.set(c,{id:u,source:"default",key:c});return}if(!t||typeof t!="object")return;let a=t,s=typeof a.id=="string"?a.id.trim():"",i=typeof a.source=="string"?a.source.trim():"default";if(!s||!i)return;let n=typeof a.key=="string"&&a.key.trim().length>0?a.key.trim():`${s}||${i}`;r.set(n,{id:s,source:i,key:n});}),[...r.values()].sort((t,a)=>t.key.localeCompare(a.key))}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let r=new Map;e.forEach(t=>{let a=r.get(t.id)??[];a.push(t.key),r.set(t.id,a);}),this.chargersByKey.update(t=>{let a=t,s=false;return r.forEach((i,n)=>{let u=t[n];if(u){for(let c of i){if(t[c])continue;let g=e.find(m=>m.key===c);s||(a=G({},t),s=true),a[c]=z(G({},u),{source:g?.source??null,deviceKey:c});}s&&a[n]?.deviceKey===void 0&&delete a[n];}}),s?a:t});}normalizeCardMode(e){let r=e&&typeof e=="object"?e:null,t=this.normalizeStringList(r?.metrics);return {displayMode:r?.displayMode==="compact"?"compact":"full",metrics:t.length?t:["panelVoltage","panelCurrent","voltage","current"]}}normalizeStringList(e){if(!Array.isArray(e))return [];let r=new Set;return e.forEach(t=>{if(typeof t!="string")return;let a=t.trim();a.length>0&&r.add(a);}),[...r].sort((t,a)=>t.localeCompare(a))}normalizeOptionsById(e){if(!e||typeof e!="object")return {};let r=Object.entries(e),t={};return r.forEach(([a,s])=>{let i=this.normalizeOptionalString(a);if(!i)return;let n=s?.arrayRatedPowerW;t[i]={arrayRatedPowerW:typeof n=="number"&&Number.isFinite(n)?n:null};}),t}normalizeOptionalString(e){if(typeof e!="string")return null;let r=e.trim();return r.length>0?r:null}enqueuePathUpdate(e,r=false){let t=this.parseSolarPath(e.path);if(!t)return;let{id:a,key:s}=t,i=e.update?.data?.value??null,n=e.update?.state??null,u=`${a}::${s}`;if(this.pendingPathUpdates.set(u,{id:a,key:s,value:i,state:n}),!r){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=window.setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},l.PATH_BATCH_WINDOW_MS));}}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let e=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(e.map(t=>t.id)).forEach(t=>this.trackDiscoveredSolar(t)),this.chargersByKey.update(t=>{let a=t,s=false,i=this.trackedDevices(),n=i.length>0,u=new Map;n&&i.forEach(c=>{let g=u.get(c.id)??[];g.push(c.key),u.set(c.id,g);});for(let c of e){let g=n?u.get(c.id)??[]:[c.id];for(let m of g){let d=i.find(S=>S.key===m),o=a[m]??{id:c.id,source:d?.source??null,deviceKey:n?m:void 0},p=G({},o),T=this.applyChargerValue(p,c.key,c.value,c.state),y=false,w=this.resolvePowerValue(p.rawBatteryPower,p.voltage,p.current);Object.is(p.power,w)||(p.power=w,y=true);let v=this.resolvePowerValue(p.rawPanelPower,p.panelVoltage,p.panelCurrent);Object.is(p.panelPower,v)||(p.panelPower=v,y=true),!(!T&&!y)&&(s||(a=G({},a),s=true),a[m]=p);}}return s?a:t});}parseSolarPath(e){let r=e.match(/self\.electrical\.solar\.([^.]+)\.(.+)$/);if(!r)return null;let t=r[1],a=r[2],s=this.normalizeSolarMetricKey(a);return {id:t,key:s}}normalizeSolarMetricKey(e){if(e.startsWith("controller."))return e.slice(11);switch(e){case "solar.power":return "panelPower";case "solar.voltage":return "panelVoltage";case "solar.current":return "panelCurrent";case "solar.temperature":return "panelTemperature";case "charge.status":return "controllerMode";default:return e}}trackDiscoveredSolar(e){let r=this.discoveredSolarIds();r.includes(e)||this.discoveredSolarIds.set([...r,e].sort());}applyChargerValue(e,r,t,a){switch(r){case "name":return this.setValue(e,"name",this.toStringValue(t));case "location":return this.setValue(e,"location",this.toStringValue(t));case "associatedBus":return this.setValue(e,"associatedBus",this.toStringValue(t));case "voltage":{let s=this.toNumber(t,"V"),i=!Object.is(e.voltageState??null,a??null);return Object.is(e.voltage,s)&&!i?false:(e.voltage=s,e.voltageState=a,true)}case "current":{let s=this.toNumber(t,"A"),i=!Object.is(e.currentState??null,a??null);return Object.is(e.current,s)&&!i?false:(e.current=s,e.currentState=a,true)}case "power":return this.setPowerPathValue(e,"rawBatteryPower",t);case "temperature":{let s=this.toNumber(t,this.units.getDefaults().Temperature),i=!Object.is(e.temperatureState??null,a??null);return Object.is(e.temperature,s)&&!i?false:(e.temperature=s,e.temperatureState=a,true)}case "chargingAlgorithm":return this.setValue(e,"chargingAlgorithm",this.toStringValue(t));case "chargerRole":return this.setValue(e,"chargerRole",this.toStringValue(t));case "chargingMode":return this.setValue(e,"chargingMode",this.toStringValue(t));case "setpointVoltage":return this.setValue(e,"setpointVoltage",this.toNumber(t,"V"));case "setpointCurrent":return this.setValue(e,"setpointCurrent",this.toNumber(t,"A"));case "controllerMode":return this.setValue(e,"controllerMode",this.toStringValue(t));case "panelVoltage":{let s=this.toNumber(t,"V"),i=!Object.is(e.panelVoltageState??null,a??null);return Object.is(e.panelVoltage,s)&&!i?false:(e.panelVoltage=s,e.panelVoltageState=a,true)}case "panelCurrent":{let s=this.toNumber(t,"A"),i=!Object.is(e.panelCurrentState??null,a??null);return Object.is(e.panelCurrent,s)&&!i?false:(e.panelCurrent=s,e.panelCurrentState=a,true)}case "panelPower":{let s=this.toNumber(t,"W"),i=!Object.is(e.panelPowerState??null,a??null);return Object.is(e.rawPanelPower,s)&&!i?false:(e.rawPanelPower=s,e.panelPowerState=a,true)}case "yieldToday":return this.setValue(e,"yieldToday",this.toNumber(t,"kWh"));case "yieldYesterday":return this.setValue(e,"yieldYesterday",this.toNumber(t,"kWh"));case "panelTemperature":{let s=this.toNumber(t,this.units.getDefaults().Temperature),i=!Object.is(e.panelTemperatureState??null,a??null);return Object.is(e.panelTemperature,s)&&!i?false:(e.panelTemperature=s,e.panelTemperatureState=a,true)}case "load":case "loadState":case "load.state":return this.setValue(e,"load",t);case "loadCurrent":{let s=this.toNumber(t,"A"),i=!Object.is(e.loadCurrentState??null,a??null);return Object.is(e.loadCurrent,s)&&!i?false:(e.loadCurrent=s,e.loadCurrentState=a,true)}default:return false}}setPowerPathValue(e,r,t){let a=this.toNumber(t,"W");return this.setValue(e,r,a)}setValue(e,r,t){return Object.is(e[r],t)?false:(e[r]=t,true)}resolvePowerValue(e,r,t){if(e!=null)return e;if(r!=null&&t!=null)return r*t}requestRender(e){this.svg&&(this.pendingRenderSnapshot=e??this.buildRenderSnapshot(),this.pendingRenderSnapshot&&this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;let r=this.pendingRenderSnapshot;this.pendingRenderSnapshot=null,r&&this.render(r);})));}buildRenderSnapshot(){let e=this.widgetColors();return e?{solarUnits:this.visibleSolarUnits(),displayModels:this.displayModels(),widgetColors:e}:null}render(e){if(!this.layer||!this.svg)return;let t=this.isCompactCardMode()?e$1:e$1,a=e.solarUnits.map((o,p)=>({key:o.deviceKey??o.id,model:e.displayModels[o.deviceKey??o.id],y:p*(l.CARD_HEIGHT+l.CARD_GAP)})),s=a.length?a[a.length-1].y+l.CARD_HEIGHT:l.CARD_HEIGHT;this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${s}`);let i=this.layer.selectAll("g.solar-card").data(a,o=>o.key),n=i.enter().append("g").attr("class","solar-card");n.append("text").attr("class","solar-charger-title");let u=n.append("text").attr("class","solar-charger-current");u.append("tspan").attr("class","current-metric-value"),u.append("tspan").attr("class","current-metric-unit"),n.append("text").attr("class","solar-charger"),n.append("text").attr("class","solar-charger-meta"),n.append("text").attr("class","solar-relay-label"),n.append("text").attr("class","solar-relay-values"),n.append("text").attr("class","solar-panel-values"),n.append("text").attr("class","solar-yield-label"),n.append("text").attr("class","solar-yield-today"),n.append("text").attr("class","solar-yield-yesterday");let c=n.append("g").attr("class","solar-panel-icon").attr("transform",`translate(${l.SOLAR_PANEL_X}, ${l.SOLAR_PANEL_Y})`);c.append("use").attr("class","solar-panel-bg").attr("href","assets/svg/symbols.svg#solar-panel-cells").attr("x",0).attr("y",0).attr("width",l.SOLAR_PANEL_WIDTH).attr("height",l.SOLAR_PANEL_HEIGHT);let g=c.append("g").attr("class","solar-panel-progress");g.append("defs").append("clipPath").attr("clipPathUnits","objectBoundingBox").attr("id",o=>`solar-panel-clip-${this.id()}-${o.key}`).append("rect").attr("x",0).attr("y",0).attr("height",1).attr("width",0),g.append("use").attr("class","solar-panel-colored").attr("href","assets/svg/symbols.svg#solar-panel-cells").attr("x",0).attr("y",0).attr("width",l.SOLAR_PANEL_WIDTH).attr("height",l.SOLAR_PANEL_HEIGHT).attr("clip-path",o=>`url(#solar-panel-clip-${this.id()}-${o.key})`);let m=n.append("text").attr("class","solar-panel-power");m.append("tspan").attr("class","solar-panel-power-value"),m.append("tspan").attr("class","solar-panel-power-unit");let d=n.merge(i);d.attr("transform",o=>`translate(0, ${o.y})`),e.solarUnits.length>1?d.select("text.solar-charger-title").attr("x",t.titleX).attr("y",t.titleY).attr("font-size",t.titleFontSize).attr("fill","var(--kip-contrast-dim-color)").text(o=>e.displayModels[o.key]?.titleText??this.displayName(o.model)):d.select("text.solar-charger-title").text(""),d.select("text.solar-charger-current").attr("x",t.lineOneX).attr("y",t.lineOneY).attr("font-size",t.lineOneFontSize).attr("fill",o=>o.model.chargerCurrentTextColor),d.select("tspan.current-metric-value").text(o=>o.model.chargerSectionCurrent),d.select("tspan.current-metric-unit").attr("dx",1).attr("font-size",12).attr("fill","var(--kip-contrast-color)").text("A"),d.select("text.solar-charger").attr("x",5).attr("y",40).attr("fill","var(--kip-contrast-color)").attr("font-size",8).attr("opacity",.8).text(o=>o.model.chargerMode),d.select("text.solar-charger-meta").attr("x",t.metaLeftX).attr("y",48).attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",o=>o.model.chargerMetaTextColor).text(o=>o.model.chargerSectionMetadata),d.select("text.solar-relay-label").attr("x",5).attr("y",73).attr("font-size",10).attr("fill","var(--kip-contrast-color)").text(o=>o.model.relaySectionVisible?"Load Output":""),d.select("text.solar-relay-values").attr("x",10).attr("y",83).attr("font-size",t.lineTwoFontSize).attr("fill",o=>o.model.relayValuesTextColor).attr("opacity",o=>o.model.relaySectionVisible?.8:0).text(o=>o.model.relaySectionText),d.select("g.solar-panel-icon").attr("transform",`translate(${l.SOLAR_PANEL_X}, ${l.SOLAR_PANEL_Y})`),d.select("use.solar-panel-bg").attr("color","var(--kip-contrast-dimmer-color)"),d.select("g.solar-panel-progress").each((o,p,T)=>{ge$1(T[p]).select("rect").attr("x",0).attr("y",0).attr("height",1).attr("width",Math.max(0,Math.min(1,o.model.gaugeProgress))),this.debugSolarLayout(o.key,o.model.gaugeProgress);}),d.select("use.solar-panel-colored").attr("color",o=>o.model.panelPowerColor),d.select("text.solar-panel-power").attr("x",137.5).attr("y",t.primaryY).attr("text-anchor","middle").attr("font-size",t.primaryFontSize).attr("font-weight",t.primaryFontWeight).attr("filter",o=>o.model.panelPowerGlowEnabled?`url(#${this.glowFilterId})`:null).attr("fill","var(--kip-contrast-color)"),d.select("tspan.solar-panel-power-value").text(o=>o.model.panelPowerText),d.select("tspan.solar-panel-power-unit").attr("dx",o=>o.model.panelPowerUnitText?1:0).attr("font-size",20).attr("font-weight",500).attr("fill","var(--kip-contrast-color)").attr("opacity",o=>o.model.panelPowerUnitText?1:0).text(o=>o.model.panelPowerUnitText),d.select("text.solar-panel-values").attr("x",137.5).attr("y",60).attr("text-anchor","middle").attr("font-size",10).attr("font-weight",500).attr("opacity",.8).attr("filter",o=>o.model.panelValuesGlowEnabled?`url(#${this.glowFilterId})`:null).attr("fill",o=>o.model.panelValuesTextColor).text(o=>o.model.gaugeSectionText).raise(),d.select("text.solar-yield-label").attr("x",104).attr("y",88).attr("text-anchor","middle").attr("font-size",8).attr("fill","var(--kip-contrast-dim-color)").attr("opacity",.8).text("Yield (kWh):"),d.select("text.solar-yield-today").attr("x",130).attr("y",88).attr("text-anchor","start").attr("font-size",8).attr("fill","var(--kip-contrast-dim-color)").attr("opacity",.8).text(o=>o.model.yieldTodayText),d.select("text.solar-yield-yesterday").attr("x",130).attr("y",97.5).attr("text-anchor","start").attr("font-size",8).attr("fill","var(--kip-contrast-dim-color)").attr("opacity",.8).text(o=>o.model.yieldYesterdayText),i.exit().remove();}displayName(e){return e.name?.trim()||e.id}resolveTitleText(e){return e.name||`Solar ${e.id}`}toNumber(e,r){return e==null||typeof e!="number"?null:this.units.convertToUnit(r,e)??e}isRelayActive(e){if(e==null)return false;if(typeof e=="boolean")return e;if(typeof e=="number")return e>0;let r=e.trim().toLowerCase();return !(!r||r==="off"||r==="false"||r==="0")}toStringValue(e){return typeof e=="string"?e:e==null?null:`${e}`}valueOrDash(e){return e===null?"--":e===void 0?"":e}formatVoltage(e){return e===null?"--":e===void 0?"":`${e.toFixed(1)}V`}formatCurrent(e){return e===null?"--":e===void 0?"":`${e.toFixed(1)}`}formatTemperature(e){return e===null?"--":e===void 0?"":`${e.toFixed(1)} ${this.units.getDefaults().Temperature==="celsius"?"\xB0C":"\xB0F"}`}formatRelayState(e){return e===null?"--":e===void 0?"":typeof e=="boolean"?e?"On":"Off":typeof e=="number"?e>0?"On":"Off":e}formatPowerAuto(e){return e===null?{value:"--",unit:""}:e===void 0?{value:"",unit:""}:Math.abs(e)>=1e3?{value:(e/1e3).toFixed(2),unit:"kW"}:{value:e.toFixed(0),unit:"W"}}formatEnergyYield(e){return e===null?"--":e===void 0?"":`${e.toFixed(2)}`}resolveMostSevereState(...e){let r=null,t={[n$1.Normal]:0,[n$1.Nominal]:1,[n$1.Alert]:2,[n$1.Warn]:3,[n$1.Alarm]:4,[n$1.Emergency]:5};for(let a of e)a&&(!r||t[a]>t[r])&&(r=a);return r}debugSolarLayout(e,r){typeof window<"u"&&window.__KIP_DEBUG_SOLAR_LAYOUT===true&&console.debug("[solar-layout]",{id:e,gaugeProgress:r,panelX:l.SOLAR_PANEL_X,panelY:l.SOLAR_PANEL_Y,panelWidth:l.SOLAR_PANEL_WIDTH,panelHeight:l.SOLAR_PANEL_HEIGHT,clippedWidth:l.SOLAR_PANEL_WIDTH*r});}static \u0275fac=function(r){return new(r||l)};static \u0275cmp=JD({type:l,selectors:[["widget-solar-charger"]],viewQuery:function(r,t){r&1&&eg(t.svgRef,pe,5),r&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["solarSvg",""],[3,"text","color"],["aria-hidden","false",1,"solar-svg"],[1,"solar-empty"],[1,"solar-empty-title"],[1,"solar-empty-sub"]],template:function(r,t){r&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,he,5,0,"div",3)),r&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasChargers()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.solar-svg[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;z-index:20;padding:0 10px 10px}.solar-empty[_ngcontent-%COMP%]{position:absolute;inset:0;margin:10px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;text-align:center;color:var(--mat-sys-on-surface);background:color-mix(in srgb,var(--kip-widget-card-background-color) 92%,transparent)}.solar-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.solar-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{te as WidgetSolarChargerComponent};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {w as w$1,n as G$1,N,i as ir,W as Wp,E as Em,D as Dt,J as JD,y as yt,b as wt,O as Op,o as eu,p as R,r as f,P as Pi,k as Qh,u as ul,T as TT,c as $h,e as EE,t as pT,B as Bh,x as DA,a as G$2,A as re,C as Ff,H as Dr,I as zA,L as Fp,S as ca,U as Kh,V as L,X as xw,Y as Aw,Z as TI,a0 as _,a1 as vA,a2 as Jt,a3 as Xt$1,a4 as Zt$1,a5 as st,_ as _w,M as Mw,a6 as Lr,a7 as Gj,a8 as H,a9 as ru,aa as N$1,ab as te,ac as Mr,ad as Qe,ae as be,af as Tu,ag as bu,ah as nn,ai as Ar,aj as zm,ak as nw,al as Zj,am as LT,an as Hh,s as sg,ao as ue,ap as Ki,aq as Bn,ar as S,as as ke$1,at as Tp,au as be$1,av as _t,aw as Cu,ax as ry,ay as lv,az as Yj,h as Fw,l as ud,g as qw,m as dd,aA as gg,d as ig,aB as gr,aC as L$1,aD as Ce$1,aE as Sr,v as vt,aF as Pr,aG as tD,aH as j,aI as ms,aJ as wm,aK as wr,aL as me,aM as At$1,aN as wt$1}from'./main-BNR44HGB.js';function Pe(o){let t=o.cloneNode(true),e=t.querySelectorAll("[id]"),i=o.nodeName.toLowerCase();t.removeAttribute("id");for(let n=0;n<e.length;n++)e[n].removeAttribute("id");return i==="canvas"?Tt(o,t):(i==="input"||i==="select"||i==="textarea")&&It(o,t),Rt("canvas",o,t,Tt),Rt("input, textarea, select",o,t,It),t}function Rt(o,t,e,i){let n=t.querySelectorAll(o);if(n.length){let s=e.querySelectorAll(o);for(let r=0;r<n.length;r++)i(n[r],s[r]);}}var si=0;function It(o,t){t.type!=="file"&&(t.value=o.value),t.type==="radio"&&t.name&&(t.name=`mat-clone-${t.name}-${si++}`);}function Tt(o,t){let e=t.getContext("2d");if(e)try{e.drawImage(o,0,0);}catch(i){}}function Te(o){let t=o.getBoundingClientRect();return {top:t.top,right:t.right,bottom:t.bottom,left:t.left,width:t.width,height:t.height,x:t.x,y:t.y}}function ye(o,t,e){let{top:i,bottom:n,left:s,right:r}=o;return e>=i&&e<=n&&t>=s&&t<=r}function oi(o,t){let e=t.left<o.left,i=t.left+t.width>o.right,n=t.top<o.top,s=t.top+t.height>o.bottom;return e||i||n||s}function G(o,t,e){o.top+=t,o.bottom=o.top+o.height,o.left+=e,o.right=o.left+o.width;}function kt(o,t,e,i){let{top:n,right:s,bottom:r,left:a,width:l,height:d}=o,h=l*t,v=d*t;return i>n-v&&i<r+v&&e>a-h&&e<s+h}var X=class{_document;positions=new Map;constructor(t){this._document=t;}clear(){this.positions.clear();}cache(t){this.clear(),this.positions.set(this._document,{scrollPosition:this.getViewportScrollPosition()}),t.forEach(e=>{this.positions.set(e,{scrollPosition:{top:e.scrollTop,left:e.scrollLeft},clientRect:Te(e)});});}handleScroll(t){let e=me(t),i=this.positions.get(e);if(!i)return null;let n=i.scrollPosition,s,r;if(e===this._document){let d=this.getViewportScrollPosition();s=d.top,r=d.left;}else s=e.scrollTop,r=e.scrollLeft;let a=n.top-s,l=n.left-r;return this.positions.forEach((d,h)=>{d.clientRect&&e!==h&&e.contains(h)&&G(d.clientRect,a,l);}),n.top=s,n.left=r,{top:a,left:l}}getViewportScrollPosition(){return {top:window.scrollY,left:window.scrollX}}};function Wt(o,t){let e=o.rootNodes;if(e.length===1&&e[0].nodeType===t.ELEMENT_NODE)return e[0];let i=t.createElement("div");return e.forEach(n=>i.appendChild(n)),i}function ke(o,t,e){for(let i in t)if(t.hasOwnProperty(i)){let n=t[i];n?o.setProperty(i,n,e?.has(i)?"important":""):o.removeProperty(i);}return o}function A(o,t){let e=t?"":"none";ke(o.style,{"touch-action":t?"":"none","-webkit-user-drag":t?"":"none","-webkit-tap-highlight-color":t?"":"transparent","user-select":e,"-ms-user-select":e,"-webkit-user-select":e,"-moz-user-select":e});}function Ot(o,t,e){ke(o.style,{position:t?"":"fixed",top:t?"":"0",opacity:t?"":"0",left:t?"":"-999em"},e);}function J(o,t){return t&&t!="none"?o+" "+t:o}function Mt(o,t){o.style.width=`${t.width}px`,o.style.height=`${t.height}px`,o.style.transform=$(t.left,t.top);}function $(o,t){return `translate3d(${Math.round(o)}px, ${Math.round(t)}px, 0)`}var V={capture:true},we={passive:false,capture:true},ri=(()=>{class o{static \u0275fac=function(i){return new(i||o)};static \u0275cmp=JD({type:o,selectors:[["ng-component"]],hostAttrs:["cdk-drag-resets-container",""],decls:0,vars:0,template:function(i,n){},styles:[`@layer cdk-resets {
|
|
2
|
+
.cdk-drag-preview {
|
|
3
|
+
background: none;
|
|
4
|
+
border: none;
|
|
5
|
+
padding: 0;
|
|
6
|
+
color: inherit;
|
|
7
|
+
inset: auto;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
.cdk-drag-placeholder *,
|
|
11
|
+
.cdk-drag-preview * {
|
|
12
|
+
pointer-events: none !important;
|
|
13
|
+
}
|
|
14
|
+
`],encapsulation:2})}return o})(),Oe=(()=>{class o{_ngZone=w$1(ue);_document=w$1(gr);_styleLoader=w$1(Ce$1);_renderer=w$1(Sr).createRenderer(null,null);_cleanupDocumentTouchmove;_scroll=new te;_dropInstances=new Set;_dragInstances=new Set;_activeDragInstances=vt([]);_globalListeners;_draggingPredicate=e=>e.isDragging();_domNodesToDirectives=null;pointerMove=new te;pointerUp=new te;registerDropContainer(e){this._dropInstances.has(e)||this._dropInstances.add(e);}registerDragItem(e){this._dragInstances.add(e),this._dragInstances.size===1&&this._ngZone.runOutsideAngular(()=>{this._cleanupDocumentTouchmove?.(),this._cleanupDocumentTouchmove=this._renderer.listen(this._document,"touchmove",this._persistentTouchmoveListener,we);});}removeDropContainer(e){this._dropInstances.delete(e);}removeDragItem(e){this._dragInstances.delete(e),this.stopDragging(e),this._dragInstances.size===0&&this._cleanupDocumentTouchmove?.();}startDragging(e,i){if(!(this._activeDragInstances().indexOf(e)>-1)&&(this._styleLoader.load(ri),this._activeDragInstances.update(n=>[...n,e]),this._activeDragInstances().length===1)){let n=i.type.startsWith("touch"),s=a=>this.pointerUp.next(a),r=[["scroll",a=>this._scroll.next(a),V],["selectstart",this._preventDefaultWhileDragging,we]];n?r.push(["touchend",s,V],["touchcancel",s,V]):r.push(["mouseup",s,V]),n||r.push(["mousemove",a=>this.pointerMove.next(a),we]),this._ngZone.runOutsideAngular(()=>{this._globalListeners=r.map(([a,l,d])=>this._renderer.listen(this._document,a,l,d));});}}stopDragging(e){this._activeDragInstances.update(i=>{let n=i.indexOf(e);return n>-1?(i.splice(n,1),[...i]):i}),this._activeDragInstances().length===0&&this._clearGlobalListeners();}isDragging(e){return this._activeDragInstances().indexOf(e)>-1}scrolled(e){let i=[this._scroll];return e&&e!==this._document&&i.push(new S(n=>this._ngZone.runOutsideAngular(()=>{let s=this._renderer.listen(e,"scroll",r=>{this._activeDragInstances().length&&n.next(r);},V);return ()=>{s();}}))),zm(...i)}registerDirectiveNode(e,i){this._domNodesToDirectives??=new WeakMap,this._domNodesToDirectives.set(e,i);}removeDirectiveNode(e){this._domNodesToDirectives?.delete(e);}getDragDirectiveForNode(e){return this._domNodesToDirectives?.get(e)||null}ngOnDestroy(){this._dragInstances.forEach(e=>this.removeDragItem(e)),this._dropInstances.forEach(e=>this.removeDropContainer(e)),this._domNodesToDirectives=null,this._clearGlobalListeners(),this.pointerMove.complete(),this.pointerUp.complete();}_preventDefaultWhileDragging=e=>{this._activeDragInstances().length>0&&e.preventDefault();};_persistentTouchmoveListener=e=>{this._activeDragInstances().length>0&&(this._activeDragInstances().some(this._draggingPredicate)&&e.preventDefault(),this.pointerMove.next(e));};_clearGlobalListeners(){this._globalListeners?.forEach(e=>e()),this._globalListeners=void 0;}static \u0275fac=function(i){return new(i||o)};static \u0275prov=Pr({token:o,factory:o.\u0275fac})}return o})();function Lt(o){let t=o.toLowerCase().indexOf("ms")>-1?1:1e3;return parseFloat(o)*t}function ai(o){let t=getComputedStyle(o),e=Se(t,"transition-property"),i=e.find(a=>a==="transform"||a==="all");if(!i)return 0;let n=e.indexOf(i),s=Se(t,"transition-duration"),r=Se(t,"transition-delay");return Lt(s[n])+Lt(r[n])}function Se(o,t){return o.getPropertyValue(t).split(",").map(i=>i.trim())}var li=new Set(["position"]),xe=class{_document;_rootElement;_direction;_initialDomRect;_previewTemplate;_previewClass;_pickupPositionOnPage;_initialTransform;_zIndex;_renderer;_previewEmbeddedView=null;_preview;get element(){return this._preview}constructor(t,e,i,n,s,r,a,l,d,h){this._document=t,this._rootElement=e,this._direction=i,this._initialDomRect=n,this._previewTemplate=s,this._previewClass=r,this._pickupPositionOnPage=a,this._initialTransform=l,this._zIndex=d,this._renderer=h;}attach(t){this._preview=this._createPreview(),t.appendChild(this._preview),At(this._preview)&&this._preview.showPopover();}destroy(){this._preview.remove(),this._previewEmbeddedView?.destroy(),this._preview=this._previewEmbeddedView=null;}setTransform(t){this._preview.style.transform=t;}getBoundingClientRect(){return this._preview.getBoundingClientRect()}addClass(t){this._preview.classList.add(t);}getTransitionDuration(){return ai(this._preview)}addEventListener(t,e){return this._renderer.listen(this._preview,t,e)}_createPreview(){let t=this._previewTemplate,e=this._previewClass,i=t?t.template:null,n;if(i&&t){let s=t.matchSize?this._initialDomRect:null,r=t.viewContainer.createEmbeddedView(i,t.context);r.detectChanges(),n=Wt(r,this._document),this._previewEmbeddedView=r,t.matchSize?Mt(n,s):n.style.transform=$(this._pickupPositionOnPage.x,this._pickupPositionOnPage.y);}else n=Pe(this._rootElement),Mt(n,this._initialDomRect),this._initialTransform&&(n.style.transform=this._initialTransform);return ke(n.style,{"pointer-events":"none",margin:At(n)?"0 auto 0 0":"0",position:"fixed",top:"0",left:"0","z-index":this._zIndex+""},li),A(n,false),n.classList.add("cdk-drag-preview"),n.setAttribute("popover","manual"),n.setAttribute("dir",this._direction),e&&(Array.isArray(e)?e.forEach(s=>n.classList.add(s)):n.classList.add(e)),n}};function At(o){return "showPopover"in o}var di={passive:true},Nt={passive:false},ci={passive:false,capture:true},hi=800,Ft="cdk-drag-placeholder",Ht=new Set(["position"]);function pi(o,t,e={dragStartThreshold:5,pointerDirectionChangeThreshold:5}){let i=o.get(tD,null,{optional:true})||o.get(Sr).createRenderer(null,null);return new Ee(t,e,o.get(gr),o.get(ue),o.get(L$1),o.get(Oe),i)}var Ee=class{_config;_document;_ngZone;_viewportRuler;_dragDropRegistry;_renderer;_rootElementCleanups;_cleanupShadowRootSelectStart;_preview=null;_previewContainer;_placeholderRef=null;_placeholder;_pickupPositionInElement;_pickupPositionOnPage;_marker;_anchor=null;_passiveTransform={x:0,y:0};_activeTransform={x:0,y:0};_initialTransform;_hasStartedDragging=vt(false);_hasMoved=false;_initialContainer;_initialIndex;_parentPositions;_moveEvents=new te;_pointerDirectionDelta;_pointerPositionAtLastDirectionChange;_lastKnownPointerPosition;_rootElement;_ownerSVGElement=null;_rootElementTapHighlight;_pointerMoveSubscription=j.EMPTY;_pointerUpSubscription=j.EMPTY;_scrollSubscription=j.EMPTY;_resizeSubscription=j.EMPTY;_lastTouchEventTime;_dragStartTime;_boundaryElement=null;_nativeInteractionsEnabled=true;_initialDomRect;_previewRect;_boundaryRect;_previewTemplate;_placeholderTemplate;_handles=[];_disabledHandles=new Set;_dropContainer;_direction="ltr";_parentDragRef=null;_cachedShadowRoot;lockAxis=null;dragStartDelay=0;previewClass;scale=1;get disabled(){return this._disabled||!!(this._dropContainer&&this._dropContainer.disabled)}set disabled(t){t!==this._disabled&&(this._disabled=t,this._toggleNativeDragInteractions(),this._handles.forEach(e=>A(e,t)));}_disabled=false;beforeStarted=new te;started=new te;released=new te;ended=new te;entered=new te;exited=new te;dropped=new te;moved=this._moveEvents;data;constrainPosition;constructor(t,e,i,n,s,r,a){this._config=e,this._document=i,this._ngZone=n,this._viewportRuler=s,this._dragDropRegistry=r,this._renderer=a,this.withRootElement(t).withParent(e.parentDragRef||null),this._parentPositions=new X(i),r.registerDragItem(this);}getPlaceholderElement(){return this._placeholder}getRootElement(){return this._rootElement}getVisibleElement(){return this.isDragging()?this.getPlaceholderElement():this.getRootElement()}withHandles(t){this._handles=t.map(i=>be$1(i)),this._handles.forEach(i=>A(i,this.disabled)),this._toggleNativeDragInteractions();let e=new Set;return this._disabledHandles.forEach(i=>{this._handles.indexOf(i)>-1&&e.add(i);}),this._disabledHandles=e,this}withPreviewTemplate(t){return this._previewTemplate=t,this}withPlaceholderTemplate(t){return this._placeholderTemplate=t,this}withRootElement(t){let e=be$1(t);if(e!==this._rootElement){this._removeRootElementListeners();let i=this._renderer;this._rootElementCleanups=this._ngZone.runOutsideAngular(()=>[i.listen(e,"mousedown",this._pointerDown,Nt),i.listen(e,"touchstart",this._pointerDown,di),i.listen(e,"dragstart",this._nativeDragStart,Nt)]),this._initialTransform=void 0,this._rootElement=e;}return typeof SVGElement<"u"&&this._rootElement instanceof SVGElement&&(this._ownerSVGElement=this._rootElement.ownerSVGElement),this}withBoundaryElement(t){return this._boundaryElement=t?be$1(t):null,this._resizeSubscription.unsubscribe(),t&&(this._resizeSubscription=this._viewportRuler.change(10).subscribe(()=>this._containInsideBoundaryOnResize())),this}withParent(t){return this._parentDragRef=t,this}dispose(){this._removeRootElementListeners(),this.isDragging()&&this._rootElement?.remove(),this._marker?.remove(),this._destroyPreview(),this._destroyPlaceholder(),this._dragDropRegistry.removeDragItem(this),this._removeListeners(),this.beforeStarted.complete(),this.started.complete(),this.released.complete(),this.ended.complete(),this.entered.complete(),this.exited.complete(),this.dropped.complete(),this._moveEvents.complete(),this._handles=[],this._disabledHandles.clear(),this._dropContainer=void 0,this._resizeSubscription.unsubscribe(),this._parentPositions.clear(),this._boundaryElement=this._rootElement=this._ownerSVGElement=this._placeholderTemplate=this._previewTemplate=this._marker=this._parentDragRef=null;}isDragging(){return this._hasStartedDragging()&&this._dragDropRegistry.isDragging(this)}reset(){this._rootElement.style.transform=this._initialTransform||"",this._activeTransform={x:0,y:0},this._passiveTransform={x:0,y:0};}resetToBoundary(){if(this._boundaryElement&&this._rootElement&&oi(this._boundaryElement.getBoundingClientRect(),this._rootElement.getBoundingClientRect())){let t=this._boundaryElement.getBoundingClientRect(),e=this._rootElement.getBoundingClientRect(),i=0,n=0;e.left<t.left?i=t.left-e.left:e.right>t.right&&(i=t.right-e.right),e.top<t.top?n=t.top-e.top:e.bottom>t.bottom&&(n=t.bottom-e.bottom);let s=this._activeTransform.x,r=this._activeTransform.y,a=s+i,l=r+n;this._rootElement.style.transform=$(a,l),this._activeTransform={x:a,y:l},this._passiveTransform={x:a,y:l};}}disableHandle(t){!this._disabledHandles.has(t)&&this._handles.indexOf(t)>-1&&(this._disabledHandles.add(t),A(t,true));}enableHandle(t){this._disabledHandles.has(t)&&(this._disabledHandles.delete(t),A(t,this.disabled));}withDirection(t){return this._direction=t,this}_withDropContainer(t){this._dropContainer=t;}getFreeDragPosition(){let t=this.isDragging()?this._activeTransform:this._passiveTransform;return {x:t.x,y:t.y}}setFreeDragPosition(t){return this._activeTransform={x:0,y:0},this._passiveTransform.x=t.x,this._passiveTransform.y=t.y,this._dropContainer||this._applyRootElementTransform(t.x,t.y),this}withPreviewContainer(t){return this._previewContainer=t,this}_sortFromLastPointerPosition(){let t=this._lastKnownPointerPosition;t&&this._dropContainer&&this._updateActiveDropContainer(this._getConstrainedPointerPosition(t),t);}_removeListeners(){this._pointerMoveSubscription.unsubscribe(),this._pointerUpSubscription.unsubscribe(),this._scrollSubscription.unsubscribe(),this._cleanupShadowRootSelectStart?.(),this._cleanupShadowRootSelectStart=void 0;}_destroyPreview(){this._preview?.destroy(),this._preview=null;}_destroyPlaceholder(){this._anchor?.remove(),this._placeholder?.remove(),this._placeholderRef?.destroy(),this._placeholder=this._anchor=this._placeholderRef=null;}_pointerDown=t=>{if(this.beforeStarted.next(),this._handles.length){let e=this._getTargetHandle(t);e&&!this._disabledHandles.has(e)&&!this.disabled&&this._initializeDragSequence(e,t);}else this.disabled||this._initializeDragSequence(this._rootElement,t);};_pointerMove=t=>{let e=this._getPointerPositionOnPage(t);if(!this._hasStartedDragging()){let n=Math.abs(e.x-this._pickupPositionOnPage.x),s=Math.abs(e.y-this._pickupPositionOnPage.y);if(n+s>=this._config.dragStartThreshold){let a=Date.now()>=this._dragStartTime+this._getDragStartDelay(t),l=this._dropContainer;if(!a){this._endDragSequence(t);return}(!l||!l.isDragging()&&!l.isReceiving())&&(t.cancelable&&t.preventDefault(),this._hasStartedDragging.set(true),this._ngZone.run(()=>this._startDragSequence(t)));}return}t.cancelable&&t.preventDefault();let i=this._getConstrainedPointerPosition(e);if(this._hasMoved=true,this._lastKnownPointerPosition=e,this._updatePointerDirectionDelta(i),this._dropContainer)this._updateActiveDropContainer(i,e);else {let n=this.constrainPosition?this._initialDomRect:this._pickupPositionOnPage,s=this._activeTransform;s.x=i.x-n.x+this._passiveTransform.x,s.y=i.y-n.y+this._passiveTransform.y,this._applyRootElementTransform(s.x,s.y);}this._moveEvents.observers.length&&this._ngZone.run(()=>{this._moveEvents.next({source:this,pointerPosition:i,event:t,distance:this._getDragDistance(i),delta:this._pointerDirectionDelta});});};_pointerUp=t=>{this._endDragSequence(t);};_endDragSequence(t){if(this._dragDropRegistry.isDragging(this)&&(this._removeListeners(),this._dragDropRegistry.stopDragging(this),this._toggleNativeDragInteractions(),this._handles&&(this._rootElement.style.webkitTapHighlightColor=this._rootElementTapHighlight),!!this._hasStartedDragging()))if(this.released.next({source:this,event:t}),this._dropContainer)this._dropContainer._stopScrolling(),this._animatePreviewToPlaceholder().then(()=>{this._cleanupDragArtifacts(t),this._cleanupCachedDimensions(),this._dragDropRegistry.stopDragging(this);});else {this._passiveTransform.x=this._activeTransform.x;let e=this._getPointerPositionOnPage(t);this._passiveTransform.y=this._activeTransform.y,this._ngZone.run(()=>{this.ended.next({source:this,distance:this._getDragDistance(e),dropPoint:e,event:t});}),this._cleanupCachedDimensions(),this._dragDropRegistry.stopDragging(this);}}_startDragSequence(t){z(t)&&(this._lastTouchEventTime=Date.now()),this._toggleNativeDragInteractions();let e=this._getShadowRoot(),i=this._dropContainer;if(e&&this._ngZone.runOutsideAngular(()=>{this._cleanupShadowRootSelectStart=this._renderer.listen(e,"selectstart",_i,ci);}),i){let n=this._rootElement,s=n.parentNode,r=this._placeholder=this._createPlaceholderElement(),a=this._marker=this._marker||this._document.createComment("");s.insertBefore(a,n),this._initialTransform=n.style.transform||"",this._preview=new xe(this._document,this._rootElement,this._direction,this._initialDomRect,this._previewTemplate||null,this.previewClass||null,this._pickupPositionOnPage,this._initialTransform,this._config.zIndex||1e3,this._renderer),this._preview.attach(this._getPreviewInsertionPoint(s,e)),Ot(n,false,Ht),this._document.body.appendChild(s.replaceChild(r,n)),this.started.next({source:this,event:t}),i.start(),this._initialContainer=i,this._initialIndex=i.getItemIndex(this);}else this.started.next({source:this,event:t}),this._initialContainer=this._initialIndex=void 0;this._parentPositions.cache(i?i.getScrollableParents():[]);}_initializeDragSequence(t,e){this._parentDragRef&&e.stopPropagation();let i=this.isDragging(),n=z(e),s=!n&&e.button!==0,r=this._rootElement,a=me(e),l=!n&&this._lastTouchEventTime&&this._lastTouchEventTime+hi>Date.now(),d=n?At$1(e):wt$1(e);if(a&&a.draggable&&e.type==="mousedown"&&e.preventDefault(),i||s||l||d)return;if(this._handles.length){let E=r.style;this._rootElementTapHighlight=E.webkitTapHighlightColor||"",E.webkitTapHighlightColor="transparent";}this._hasMoved=false,this._hasStartedDragging.set(this._hasMoved),this._removeListeners(),this._initialDomRect=this._rootElement.getBoundingClientRect(),this._pointerMoveSubscription=this._dragDropRegistry.pointerMove.subscribe(this._pointerMove),this._pointerUpSubscription=this._dragDropRegistry.pointerUp.subscribe(this._pointerUp),this._scrollSubscription=this._dragDropRegistry.scrolled(this._getShadowRoot()).subscribe(E=>this._updateOnScroll(E)),this._boundaryElement&&(this._boundaryRect=Te(this._boundaryElement));let h=this._previewTemplate;this._pickupPositionInElement=h&&h.template&&!h.matchSize?{x:0,y:0}:this._getPointerPositionInElement(this._initialDomRect,t,e);let v=this._pickupPositionOnPage=this._lastKnownPointerPosition=this._getPointerPositionOnPage(e);this._pointerDirectionDelta={x:0,y:0},this._pointerPositionAtLastDirectionChange={x:v.x,y:v.y},this._dragStartTime=Date.now(),this._dragDropRegistry.startDragging(this,e);}_cleanupDragArtifacts(t){Ot(this._rootElement,true,Ht),this._marker.parentNode.replaceChild(this._rootElement,this._marker),this._destroyPreview(),this._destroyPlaceholder(),this._initialDomRect=this._boundaryRect=this._previewRect=this._initialTransform=void 0,this._ngZone.run(()=>{let e=this._dropContainer,i=e.getItemIndex(this),n=this._getPointerPositionOnPage(t),s=this._getDragDistance(n),r=e._isOverContainer(n.x,n.y);this.ended.next({source:this,distance:s,dropPoint:n,event:t}),this.dropped.next({item:this,currentIndex:i,previousIndex:this._initialIndex,container:e,previousContainer:this._initialContainer,isPointerOverContainer:r,distance:s,dropPoint:n,event:t}),e.drop(this,i,this._initialIndex,this._initialContainer,r,s,n,t),this._dropContainer=this._initialContainer;});}_updateActiveDropContainer({x:t,y:e},{x:i,y:n}){let s=this._initialContainer._getSiblingContainerFromPosition(this,t,e);!s&&this._dropContainer!==this._initialContainer&&this._initialContainer._isOverContainer(t,e)&&(s=this._initialContainer),s&&s!==this._dropContainer&&this._ngZone.run(()=>{let r=this._dropContainer.getItemIndex(this),a=this._dropContainer.getItemAtIndex(r+1)?.getVisibleElement()||null;this.exited.next({item:this,container:this._dropContainer}),this._dropContainer.exit(this),this._conditionallyInsertAnchor(s,this._dropContainer,a),this._dropContainer=s,this._dropContainer.enter(this,t,e,s===this._initialContainer&&s.sortingDisabled?this._initialIndex:void 0),this.entered.next({item:this,container:s,currentIndex:s.getItemIndex(this)});}),this.isDragging()&&(this._dropContainer._startScrollingIfNecessary(i,n),this._dropContainer._sortItem(this,t,e,this._pointerDirectionDelta),this.constrainPosition?this._applyPreviewTransform(t,e):this._applyPreviewTransform(t-this._pickupPositionInElement.x,e-this._pickupPositionInElement.y));}_animatePreviewToPlaceholder(){if(!this._hasMoved)return Promise.resolve();let t=this._placeholder.getBoundingClientRect();this._preview.addClass("cdk-drag-animating"),this._applyPreviewTransform(t.left,t.top);let e=this._preview.getTransitionDuration();return e===0?Promise.resolve():this._ngZone.runOutsideAngular(()=>new Promise(i=>{let n=a=>{(!a||this._preview&&me(a)===this._preview.element&&a.propertyName==="transform")&&(r(),i(),clearTimeout(s));},s=setTimeout(n,e*1.5),r=this._preview.addEventListener("transitionend",n);}))}_createPlaceholderElement(){let t=this._placeholderTemplate,e=t?t.template:null,i;return e?(this._placeholderRef=t.viewContainer.createEmbeddedView(e,t.context),this._placeholderRef.detectChanges(),i=Wt(this._placeholderRef,this._document)):i=Pe(this._rootElement),i.style.pointerEvents="none",i.classList.add(Ft),i}_getPointerPositionInElement(t,e,i){let n=e===this._rootElement?null:e,s=n?n.getBoundingClientRect():t,r=z(i)?i.targetTouches[0]:i,a=this._getViewportScrollPosition(),l=r.pageX-s.left-a.left,d=r.pageY-s.top-a.top;return {x:s.left-t.left+l,y:s.top-t.top+d}}_getPointerPositionOnPage(t){let e=this._getViewportScrollPosition(),i=z(t)?t.touches[0]||t.changedTouches[0]||{pageX:0,pageY:0}:t,n=i.pageX-e.left,s=i.pageY-e.top;if(this._ownerSVGElement){let r=this._ownerSVGElement.getScreenCTM();if(r){let a=this._ownerSVGElement.createSVGPoint();return a.x=n,a.y=s,a.matrixTransform(r.inverse())}}return {x:n,y:s}}_getConstrainedPointerPosition(t){let e=this._dropContainer?this._dropContainer.lockAxis:null,{x:i,y:n}=this.constrainPosition?this.constrainPosition(t,this,this._initialDomRect,this._pickupPositionInElement):t;if(this.lockAxis==="x"||e==="x"?n=this._pickupPositionOnPage.y-(this.constrainPosition?this._pickupPositionInElement.y:0):(this.lockAxis==="y"||e==="y")&&(i=this._pickupPositionOnPage.x-(this.constrainPosition?this._pickupPositionInElement.x:0)),this._boundaryRect){let{x:s,y:r}=this.constrainPosition?{x:0,y:0}:this._pickupPositionInElement,a=this._boundaryRect,{width:l,height:d}=this._getPreviewRect(),h=a.top+r,v=a.bottom-(d-r),E=a.left+s,te=a.right-(l-s);i=Bt(i,E,te),n=Bt(n,h,v);}return {x:i,y:n}}_updatePointerDirectionDelta(t){let{x:e,y:i}=t,n=this._pointerDirectionDelta,s=this._pointerPositionAtLastDirectionChange,r=Math.abs(e-s.x),a=Math.abs(i-s.y);return r>this._config.pointerDirectionChangeThreshold&&(n.x=e>s.x?1:-1,s.x=e),a>this._config.pointerDirectionChangeThreshold&&(n.y=i>s.y?1:-1,s.y=i),n}_toggleNativeDragInteractions(){if(!this._rootElement||!this._handles)return;let t=this._handles.length>0||!this.isDragging();t!==this._nativeInteractionsEnabled&&(this._nativeInteractionsEnabled=t,A(this._rootElement,t));}_removeRootElementListeners(){this._rootElementCleanups?.forEach(t=>t()),this._rootElementCleanups=void 0;}_applyRootElementTransform(t,e){let i=1/this.scale,n=$(t*i,e*i),s=this._rootElement.style;this._initialTransform==null&&(this._initialTransform=s.transform&&s.transform!="none"?s.transform:""),s.transform=J(n,this._initialTransform);}_applyPreviewTransform(t,e){let i=this._previewTemplate?.template?void 0:this._initialTransform,n=$(t,e);this._preview.setTransform(J(n,i));}_getDragDistance(t){let e=this._pickupPositionOnPage;return e?{x:t.x-e.x,y:t.y-e.y}:{x:0,y:0}}_cleanupCachedDimensions(){this._boundaryRect=this._previewRect=void 0,this._parentPositions.clear();}_containInsideBoundaryOnResize(){let{x:t,y:e}=this._passiveTransform;if(t===0&&e===0||this.isDragging()||!this._boundaryElement)return;let i=this._rootElement.getBoundingClientRect(),n=this._boundaryElement.getBoundingClientRect();if(n.width===0&&n.height===0||i.width===0&&i.height===0)return;let s=n.left-i.left,r=i.right-n.right,a=n.top-i.top,l=i.bottom-n.bottom;n.width>i.width?(s>0&&(t+=s),r>0&&(t-=r)):t=0,n.height>i.height?(a>0&&(e+=a),l>0&&(e-=l)):e=0,(t!==this._passiveTransform.x||e!==this._passiveTransform.y)&&this.setFreeDragPosition({y:e,x:t});}_getDragStartDelay(t){let e=this.dragStartDelay;return typeof e=="number"?e:z(t)?e.touch:e?e.mouse:0}_updateOnScroll(t){let e=this._parentPositions.handleScroll(t);if(e){let i=me(t);this._boundaryRect&&i!==this._boundaryElement&&i.contains(this._boundaryElement)&&G(this._boundaryRect,e.top,e.left),this._pickupPositionOnPage.x+=e.left,this._pickupPositionOnPage.y+=e.top,this._dropContainer||(this._activeTransform.x-=e.left,this._activeTransform.y-=e.top,this._applyRootElementTransform(this._activeTransform.x,this._activeTransform.y));}}_getViewportScrollPosition(){return this._parentPositions.positions.get(this._document)?.scrollPosition||this._parentPositions.getViewportScrollPosition()}_getShadowRoot(){return this._cachedShadowRoot===void 0&&(this._cachedShadowRoot=wr(this._rootElement)),this._cachedShadowRoot}_getPreviewInsertionPoint(t,e){let i=this._previewContainer||"global";if(i==="parent")return t;if(i==="global"){let n=this._document;return e||n.fullscreenElement||n.webkitFullscreenElement||n.mozFullScreenElement||n.msFullscreenElement||n.body}return be$1(i)}_getPreviewRect(){return (!this._previewRect||!this._previewRect.width&&!this._previewRect.height)&&(this._previewRect=this._preview?this._preview.getBoundingClientRect():this._initialDomRect),this._previewRect}_nativeDragStart=t=>{if(this._handles.length){let e=this._getTargetHandle(t);e&&!this._disabledHandles.has(e)&&!this.disabled&&t.preventDefault();}else this.disabled||t.preventDefault();};_getTargetHandle(t){return this._handles.find(e=>t.target&&(t.target===e||e.contains(t.target)))}_conditionallyInsertAnchor(t,e,i){if(t===this._initialContainer)this._anchor?.remove(),this._anchor=null;else if(e===this._initialContainer&&e.hasAnchor){let n=this._anchor??=Pe(this._placeholder);n.classList.remove(Ft),n.classList.add("cdk-drag-anchor"),n.style.transform="",i?i.before(n):be$1(e.element).appendChild(n);}}};function Bt(o,t,e){return Math.max(t,Math.min(e,o))}function z(o){return o.type[0]==="t"}function _i(o){o.preventDefault();}function ee(o,t,e){let i=Vt(t,o.length-1),n=Vt(e,o.length-1);if(i===n)return;let s=o[i],r=n<i?-1:1;for(let a=i;a!==n;a+=r)o[a]=o[a+r];o[n]=s;}function Vt(o,t){return Math.max(0,Math.min(t,o))}var Q=class{_dragDropRegistry;_element;_sortPredicate;_itemPositions=[];_activeDraggables;orientation="vertical";direction="ltr";constructor(t){this._dragDropRegistry=t;}_previousSwap={drag:null,delta:0,overlaps:false};start(t){this.withItems(t);}sort(t,e,i,n){let s=this._itemPositions,r=this._getItemIndexFromPointerPosition(t,e,i,n);if(r===-1&&s.length>0)return null;let a=this.orientation==="horizontal",l=s.findIndex(D=>D.drag===t),d=s[r],h=s[l].clientRect,v=d.clientRect,E=l>r?1:-1,te=this._getItemOffsetPx(h,v,E),ti=this._getSiblingOffsetPx(l,s,E),ii=s.slice();return ee(s,l,r),s.forEach((D,ni)=>{if(ii[ni]===D)return;let Me=D.drag===t,ie=Me?te:ti,Le=Me?t.getPlaceholderElement():D.drag.getRootElement();D.offset+=ie;let Ae=Math.round(D.offset*(1/D.drag.scale));a?(Le.style.transform=J(`translate3d(${Ae}px, 0, 0)`,D.initialTransform),G(D.clientRect,0,ie)):(Le.style.transform=J(`translate3d(0, ${Ae}px, 0)`,D.initialTransform),G(D.clientRect,ie,0));}),this._previousSwap.overlaps=ye(v,e,i),this._previousSwap.drag=d.drag,this._previousSwap.delta=a?n.x:n.y,{previousIndex:l,currentIndex:r}}enter(t,e,i,n){let s=this._activeDraggables,r=s.indexOf(t),a=t.getPlaceholderElement();r>-1&&s.splice(r,1);let l=n==null||n<0?this._getItemIndexFromPointerPosition(t,e,i):n,d=s[l];if(d===t&&(d=s[l+1]),!d&&(l==null||l===-1||l<s.length-1)&&this._shouldEnterAsFirstChild(e,i)&&(d=s[0]),d&&!this._dragDropRegistry.isDragging(d)){let h=d.getRootElement();h.parentElement.insertBefore(a,h),s.splice(l,0,t);}else this._element.appendChild(a),s.push(t);a.style.transform="",this._cacheItemPositions();}withItems(t){this._activeDraggables=t.slice(),this._cacheItemPositions();}withSortPredicate(t){this._sortPredicate=t;}reset(){this._activeDraggables?.forEach(t=>{let e=t.getRootElement();if(e){let i=this._itemPositions.find(n=>n.drag===t)?.initialTransform;e.style.transform=i||"";}}),this._itemPositions=[],this._activeDraggables=[],this._previousSwap.drag=null,this._previousSwap.delta=0,this._previousSwap.overlaps=false;}getActiveItemsSnapshot(){return this._activeDraggables}getItemIndex(t){return this._getVisualItemPositions().findIndex(e=>e.drag===t)}getItemAtIndex(t){return this._getVisualItemPositions()[t]?.drag||null}updateOnScroll(t,e){this._itemPositions.forEach(({clientRect:i})=>{G(i,t,e);}),this._itemPositions.forEach(({drag:i})=>{this._dragDropRegistry.isDragging(i)&&i._sortFromLastPointerPosition();});}withElementContainer(t){this._element=t;}_cacheItemPositions(){let t=this.orientation==="horizontal";this._itemPositions=this._activeDraggables.map(e=>{let i=e.getVisibleElement();return {drag:e,offset:0,initialTransform:i.style.transform||"",clientRect:Te(i)}}).sort((e,i)=>t?e.clientRect.left-i.clientRect.left:e.clientRect.top-i.clientRect.top);}_getVisualItemPositions(){return this.orientation==="horizontal"&&this.direction==="rtl"?this._itemPositions.slice().reverse():this._itemPositions}_getItemOffsetPx(t,e,i){let n=this.orientation==="horizontal",s=n?e.left-t.left:e.top-t.top;return i===-1&&(s+=n?e.width-t.width:e.height-t.height),s}_getSiblingOffsetPx(t,e,i){let n=this.orientation==="horizontal",s=e[t].clientRect,r=e[t+i*-1],a=s[n?"width":"height"]*i;if(r){let l=n?"left":"top",d=n?"right":"bottom";i===-1?a-=r.clientRect[l]-s[d]:a+=s[l]-r.clientRect[d];}return a}_shouldEnterAsFirstChild(t,e){if(!this._activeDraggables.length)return false;let i=this._itemPositions,n=this.orientation==="horizontal";if(i[0].drag!==this._activeDraggables[0]){let r=i[i.length-1].clientRect;return n?t>=r.right:e>=r.bottom}else {let r=i[0].clientRect;return n?t<=r.left:e<=r.top}}_getItemIndexFromPointerPosition(t,e,i,n){let s=this.orientation==="horizontal",r=this._itemPositions.findIndex(({drag:a,clientRect:l})=>{if(a===t)return false;if(n){let d=s?n.x:n.y;if(a===this._previousSwap.drag&&this._previousSwap.overlaps&&d===this._previousSwap.delta)return false}return s?e>=Math.floor(l.left)&&e<Math.floor(l.right):i>=Math.floor(l.top)&&i<Math.floor(l.bottom)});return r===-1||!this._sortPredicate(r,t)?-1:r}},Ce=class{_document;_dragDropRegistry;_element;_sortPredicate;_rootNode;_activeItems;_previousSwap={drag:null,deltaX:0,deltaY:0,overlaps:false};_relatedNodes=[];constructor(t,e){this._document=t,this._dragDropRegistry=e;}start(t){let e=this._element.childNodes;this._relatedNodes=[];for(let i=0;i<e.length;i++){let n=e[i];this._relatedNodes.push([n,n.nextSibling]);}this.withItems(t);}sort(t,e,i,n){let s=this._getItemIndexFromPointerPosition(t,e,i),r=this._previousSwap;if(s===-1||this._activeItems[s]===t)return null;let a=this._activeItems[s];if(r.drag===a&&r.overlaps&&r.deltaX===n.x&&r.deltaY===n.y)return null;let l=this.getItemIndex(t),d=t.getPlaceholderElement(),h=a.getRootElement();s>l?h.after(d):h.before(d),ee(this._activeItems,l,s);let v=this._getRootNode().elementFromPoint(e,i);return r.deltaX=n.x,r.deltaY=n.y,r.drag=a,r.overlaps=h===v||h.contains(v),{previousIndex:l,currentIndex:s}}enter(t,e,i,n){let s=this._activeItems.indexOf(t);s>-1&&this._activeItems.splice(s,1);let r=n==null||n<0?this._getItemIndexFromPointerPosition(t,e,i):n;r===-1&&(r=this._getClosestItemIndexToPointer(t,e,i));let a=this._activeItems[r];a&&!this._dragDropRegistry.isDragging(a)?(this._activeItems.splice(r,0,t),a.getRootElement().before(t.getPlaceholderElement())):(this._activeItems.push(t),this._element.appendChild(t.getPlaceholderElement()));}withItems(t){this._activeItems=t.slice();}withSortPredicate(t){this._sortPredicate=t;}reset(){let t=this._element,e=this._previousSwap;for(let i=this._relatedNodes.length-1;i>-1;i--){let[n,s]=this._relatedNodes[i];n.parentNode===t&&n.nextSibling!==s&&(s===null?t.appendChild(n):s.parentNode===t&&t.insertBefore(n,s));}this._relatedNodes=[],this._activeItems=[],e.drag=null,e.deltaX=e.deltaY=0,e.overlaps=false;}getActiveItemsSnapshot(){return this._activeItems}getItemIndex(t){return this._activeItems.indexOf(t)}getItemAtIndex(t){return this._activeItems[t]||null}updateOnScroll(){this._activeItems.forEach(t=>{this._dragDropRegistry.isDragging(t)&&t._sortFromLastPointerPosition();});}withElementContainer(t){t!==this._element&&(this._element=t,this._rootNode=void 0);}_getItemIndexFromPointerPosition(t,e,i){let n=this._getRootNode().elementFromPoint(Math.floor(e),Math.floor(i)),s=n?this._activeItems.findIndex(r=>{let a=r.getRootElement();return n===a||a.contains(n)}):-1;return s===-1||!this._sortPredicate(s,t)?-1:s}_getRootNode(){return this._rootNode||(this._rootNode=wr(this._element)||this._document),this._rootNode}_getClosestItemIndexToPointer(t,e,i){if(this._activeItems.length===0)return -1;if(this._activeItems.length===1)return 0;let n=1/0,s=-1;for(let r=0;r<this._activeItems.length;r++){let a=this._activeItems[r];if(a!==t){let{x:l,y:d}=a.getRootElement().getBoundingClientRect(),h=Math.hypot(e-l,i-d);h<n&&(n=h,s=r);}}return s}},zt=.05,Ut=.05,w=(function(o){return o[o.NONE=0]="NONE",o[o.UP=1]="UP",o[o.DOWN=2]="DOWN",o})(w||{}),u=(function(o){return o[o.NONE=0]="NONE",o[o.LEFT=1]="LEFT",o[o.RIGHT=2]="RIGHT",o})(u||{});function gi(o,t){return new Re(t,o.get(Oe),o.get(gr),o.get(ue),o.get(L$1))}var Re=class{_dragDropRegistry;_ngZone;_viewportRuler;element;disabled=false;sortingDisabled=false;lockAxis=null;autoScrollDisabled=false;autoScrollStep=2;hasAnchor=false;enterPredicate=()=>true;sortPredicate=()=>true;beforeStarted=new te;entered=new te;exited=new te;dropped=new te;sorted=new te;receivingStarted=new te;receivingStopped=new te;data;_container;_isDragging=false;_parentPositions;_sortStrategy;_domRect;_draggables=[];_siblings=[];_activeSiblings=new Set;_viewportScrollSubscription=j.EMPTY;_verticalScrollDirection=w.NONE;_horizontalScrollDirection=u.NONE;_scrollNode;_stopScrollTimers=new te;_cachedShadowRoot=null;_document;_scrollableElements=[];_initialScrollSnap;_direction="ltr";constructor(t,e,i,n,s){this._dragDropRegistry=e,this._ngZone=n,this._viewportRuler=s;let r=this.element=be$1(t);this._document=i,this.withOrientation("vertical").withElementContainer(r),e.registerDropContainer(this),this._parentPositions=new X(i);}dispose(){this._stopScrolling(),this._stopScrollTimers.complete(),this._viewportScrollSubscription.unsubscribe(),this.beforeStarted.complete(),this.entered.complete(),this.exited.complete(),this.dropped.complete(),this.sorted.complete(),this.receivingStarted.complete(),this.receivingStopped.complete(),this._activeSiblings.clear(),this._scrollNode=null,this._parentPositions.clear(),this._dragDropRegistry.removeDropContainer(this);}isDragging(){return this._isDragging}start(){this._draggingStarted(),this._notifyReceivingSiblings();}enter(t,e,i,n){this._draggingStarted(),n==null&&this.sortingDisabled&&(n=this._draggables.indexOf(t)),this._sortStrategy.enter(t,e,i,n),this._cacheParentPositions(),this._notifyReceivingSiblings(),this.entered.next({item:t,container:this,currentIndex:this.getItemIndex(t)});}exit(t){this._reset(),this.exited.next({item:t,container:this});}drop(t,e,i,n,s,r,a,l){this._reset(),this.dropped.next({item:t,currentIndex:e,previousIndex:i,container:this,previousContainer:n,isPointerOverContainer:s,distance:r,dropPoint:a,event:l});}withItems(t){let e=this._draggables;return this._draggables=t,t.forEach(i=>i._withDropContainer(this)),this.isDragging()&&(e.filter(n=>n.isDragging()).every(n=>t.indexOf(n)===-1)?this._reset():this._sortStrategy.withItems(this._draggables)),this}withDirection(t){return this._direction=t,this._sortStrategy instanceof Q&&(this._sortStrategy.direction=t),this}connectedTo(t){return this._siblings=t.slice(),this}withOrientation(t){if(t==="mixed")this._sortStrategy=new Ce(this._document,this._dragDropRegistry);else {let e=new Q(this._dragDropRegistry);e.direction=this._direction,e.orientation=t,this._sortStrategy=e;}return this._sortStrategy.withElementContainer(this._container),this._sortStrategy.withSortPredicate((e,i)=>this.sortPredicate(e,i,this)),this}withScrollableParents(t){let e=this._container;return this._scrollableElements=t.indexOf(e)===-1?[e,...t]:t.slice(),this}withElementContainer(t){if(t===this._container)return this;be$1(this.element);let i=this._scrollableElements.indexOf(this._container),n=this._scrollableElements.indexOf(t);return i>-1&&this._scrollableElements.splice(i,1),n>-1&&this._scrollableElements.splice(n,1),this._sortStrategy&&this._sortStrategy.withElementContainer(t),this._cachedShadowRoot=null,this._scrollableElements.unshift(t),this._container=t,this}getScrollableParents(){return this._scrollableElements}getItemIndex(t){return this._isDragging?this._sortStrategy.getItemIndex(t):this._draggables.indexOf(t)}getItemAtIndex(t){return this._isDragging?this._sortStrategy.getItemAtIndex(t):this._draggables[t]||null}isReceiving(){return this._activeSiblings.size>0}_sortItem(t,e,i,n){if(this.sortingDisabled||!this._domRect||!kt(this._domRect,zt,e,i))return;let s=this._sortStrategy.sort(t,e,i,n);s&&this.sorted.next({previousIndex:s.previousIndex,currentIndex:s.currentIndex,container:this,item:t});}_startScrollingIfNecessary(t,e){if(this.autoScrollDisabled)return;let i,n=w.NONE,s=u.NONE;if(this._parentPositions.positions.forEach((r,a)=>{a===this._document||!r.clientRect||i||kt(r.clientRect,zt,t,e)&&([n,s]=mi(a,r.clientRect,this._direction,t,e),(n||s)&&(i=a));}),!n&&!s){let{width:r,height:a}=this._viewportRuler.getViewportSize(),l={width:r,height:a,top:0,right:r,bottom:a,left:0};n=Zt(l,e),s=qt(l,t),i=window;}i&&(n!==this._verticalScrollDirection||s!==this._horizontalScrollDirection||i!==this._scrollNode)&&(this._verticalScrollDirection=n,this._horizontalScrollDirection=s,this._scrollNode=i,(n||s)&&i?this._ngZone.runOutsideAngular(this._startScrollInterval):this._stopScrolling());}_stopScrolling(){this._stopScrollTimers.next();}_draggingStarted(){let t=this._container.style;this.beforeStarted.next(),this._isDragging=true,this._initialScrollSnap=t.msScrollSnapType||t.scrollSnapType||"",t.scrollSnapType=t.msScrollSnapType="none",this._sortStrategy.start(this._draggables),this._cacheParentPositions(),this._viewportScrollSubscription.unsubscribe(),this._listenToScrollEvents();}_cacheParentPositions(){this._parentPositions.cache(this._scrollableElements),this._domRect=this._parentPositions.positions.get(this._container).clientRect;}_reset(){this._isDragging=false;let t=this._container.style;t.scrollSnapType=t.msScrollSnapType=this._initialScrollSnap,this._siblings.forEach(e=>e._stopReceiving(this)),this._sortStrategy.reset(),this._stopScrolling(),this._viewportScrollSubscription.unsubscribe(),this._parentPositions.clear();}_startScrollInterval=()=>{this._stopScrolling(),ms(0,wm).pipe(bu(this._stopScrollTimers)).subscribe(()=>{let t=this._scrollNode,e=this.autoScrollStep;this._verticalScrollDirection===w.UP?t.scrollBy(0,-e):this._verticalScrollDirection===w.DOWN&&t.scrollBy(0,e),this._horizontalScrollDirection===u.LEFT?t.scrollBy(-e,0):this._horizontalScrollDirection===u.RIGHT&&t.scrollBy(e,0);});};_isOverContainer(t,e){return this._domRect!=null&&ye(this._domRect,t,e)}_getSiblingContainerFromPosition(t,e,i){return this._siblings.find(n=>n._canReceive(t,e,i))}_canReceive(t,e,i){if(!this._domRect||!ye(this._domRect,e,i)||!this.enterPredicate(t,this))return false;let n=this._getShadowRoot().elementFromPoint(e,i);return n?n===this._container||this._container.contains(n):false}_startReceiving(t,e){let i=this._activeSiblings;!i.has(t)&&e.every(n=>this.enterPredicate(n,this)||this._draggables.indexOf(n)>-1)&&(i.add(t),this._cacheParentPositions(),this._listenToScrollEvents(),this.receivingStarted.next({initiator:t,receiver:this,items:e}));}_stopReceiving(t){this._activeSiblings.delete(t),this._viewportScrollSubscription.unsubscribe(),this.receivingStopped.next({initiator:t,receiver:this});}_listenToScrollEvents(){this._viewportScrollSubscription=this._dragDropRegistry.scrolled(this._getShadowRoot()).subscribe(t=>{if(this.isDragging()){let e=this._parentPositions.handleScroll(t);e&&this._sortStrategy.updateOnScroll(e.top,e.left);}else this.isReceiving()&&this._cacheParentPositions();});}_getShadowRoot(){if(!this._cachedShadowRoot){let t=wr(this._container);this._cachedShadowRoot=t||this._document;}return this._cachedShadowRoot}_notifyReceivingSiblings(){let t=this._sortStrategy.getActiveItemsSnapshot().filter(e=>e.isDragging());this._siblings.forEach(e=>e._startReceiving(this,t));}};function Zt(o,t){let{top:e,bottom:i,height:n}=o,s=n*Ut;return t>=e-s&&t<=e+s?w.UP:t>=i-s&&t<=i+s?w.DOWN:w.NONE}function qt(o,t){let{left:e,right:i,width:n}=o,s=n*Ut;return t>=e-s&&t<=e+s?u.LEFT:t>=i-s&&t<=i+s?u.RIGHT:u.NONE}function mi(o,t,e,i,n){let s=Zt(t,n),r=qt(t,i),a=w.NONE,l=u.NONE;if(s){let d=o.scrollTop;s===w.UP?d>0&&(a=w.UP):o.scrollHeight-d>o.clientHeight&&(a=w.DOWN);}if(r){let d=o.scrollLeft;e==="rtl"?r===u.RIGHT?d<0&&(l=u.RIGHT):o.scrollWidth+d>o.clientWidth&&(l=u.LEFT):r===u.LEFT?d>0&&(l=u.LEFT):o.scrollWidth-d>o.clientWidth&&(l=u.RIGHT);}return [a,l]}var Gt=new N$1("CDK_DRAG_PARENT");var ui=new N$1("CdkDragHandle");var jt=new N$1("CDK_DRAG_CONFIG"),Kt=new N$1("CdkDropList"),Yt=(()=>{class o{element=w$1(Lr);dropContainer=w$1(Kt,{optional:true,skipSelf:true});_ngZone=w$1(ue);_viewContainerRef=w$1(Ki);_dir=w$1(ru,{optional:true});_changeDetectorRef=w$1(Gj);_selfHandle=w$1(ui,{optional:true,self:true});_parentDrag=w$1(Gt,{optional:true,skipSelf:true});_dragDropRegistry=w$1(Oe);_destroyed=new te;_handles=new Bn([]);_previewTemplate=null;_placeholderTemplate=null;_dragRef;data;lockAxis=null;rootElementSelector;boundaryElement;dragStartDelay;freeDragPosition;get disabled(){return this._disabled||!!(this.dropContainer&&this.dropContainer.disabled)}set disabled(e){this._disabled=e,this._dragRef.disabled=this._disabled;}_disabled=false;constrainPosition;previewClass;previewContainer;scale=1;started=new Qe;released=new Qe;ended=new Qe;entered=new Qe;exited=new Qe;dropped=new Qe;moved=new S(e=>{let i=this._dragRef.moved.pipe(ke$1(n=>({source:this,pointerPosition:n.pointerPosition,event:n.event,delta:n.delta,distance:n.distance}))).subscribe(e);return ()=>{i.unsubscribe();}});_injector=w$1(be);constructor(){let e=this.dropContainer,i=w$1(jt,{optional:true});this._dragRef=pi(this._injector,this.element,{dragStartThreshold:i&&i.dragStartThreshold!=null?i.dragStartThreshold:5,pointerDirectionChangeThreshold:i&&i.pointerDirectionChangeThreshold!=null?i.pointerDirectionChangeThreshold:5,zIndex:i?.zIndex}),this._dragRef.data=this,this._dragDropRegistry.registerDirectiveNode(this.element.nativeElement,this),i&&this._assignDefaults(i),e&&(e.addItem(this),e._dropListRef.beforeStarted.pipe(bu(this._destroyed)).subscribe(()=>{this._dragRef.scale=this.scale;})),this._syncInputs(this._dragRef),this._handleEvents(this._dragRef);}getPlaceholderElement(){return this._dragRef.getPlaceholderElement()}getRootElement(){return this._dragRef.getRootElement()}reset(){this._dragRef.reset();}resetToBoundary(){this._dragRef.resetToBoundary();}getFreeDragPosition(){return this._dragRef.getFreeDragPosition()}setFreeDragPosition(e){this._dragRef.setFreeDragPosition(e);}ngAfterViewInit(){Tp(()=>{this._updateRootElement(),this._setupHandlesListener(),this._dragRef.scale=this.scale,this.freeDragPosition&&this._dragRef.setFreeDragPosition(this.freeDragPosition);},{injector:this._injector});}ngOnChanges(e){let i=e.rootElementSelector,n=e.freeDragPosition;i&&!i.firstChange&&this._updateRootElement(),this._dragRef.scale=this.scale,n&&!n.firstChange&&this.freeDragPosition&&this._dragRef.setFreeDragPosition(this.freeDragPosition);}ngOnDestroy(){this.dropContainer&&this.dropContainer.removeItem(this),this._dragDropRegistry.removeDirectiveNode(this.element.nativeElement),this._ngZone.runOutsideAngular(()=>{this._handles.complete(),this._destroyed.next(),this._destroyed.complete(),this._dragRef.dispose();});}_addHandle(e){let i=this._handles.getValue();i.push(e),this._handles.next(i);}_removeHandle(e){let i=this._handles.getValue(),n=i.indexOf(e);n>-1&&(i.splice(n,1),this._handles.next(i));}_setPreviewTemplate(e){this._previewTemplate=e;}_resetPreviewTemplate(e){e===this._previewTemplate&&(this._previewTemplate=null);}_setPlaceholderTemplate(e){this._placeholderTemplate=e;}_resetPlaceholderTemplate(e){e===this._placeholderTemplate&&(this._placeholderTemplate=null);}_updateRootElement(){let e=this.element.nativeElement,i=e;this.rootElementSelector&&(i=e.closest!==void 0?e.closest(this.rootElementSelector):e.parentElement?.closest(this.rootElementSelector)),this._dragRef.withRootElement(i||e);}_getBoundaryElement(){let e=this.boundaryElement;return e?typeof e=="string"?this.element.nativeElement.closest(e):be$1(e):null}_syncInputs(e){e.beforeStarted.subscribe(()=>{if(!e.isDragging()){let i=this._dir,n=this.dragStartDelay,s=this._placeholderTemplate?{template:this._placeholderTemplate.templateRef,context:this._placeholderTemplate.data,viewContainer:this._viewContainerRef}:null,r=this._previewTemplate?{template:this._previewTemplate.templateRef,context:this._previewTemplate.data,matchSize:this._previewTemplate.matchSize,viewContainer:this._viewContainerRef}:null;e.disabled=this.disabled,e.lockAxis=this.lockAxis,e.scale=this.scale,e.dragStartDelay=typeof n=="object"&&n?n:Ar(n),e.constrainPosition=this.constrainPosition,e.previewClass=this.previewClass,e.withBoundaryElement(this._getBoundaryElement()).withPlaceholderTemplate(s).withPreviewTemplate(r).withPreviewContainer(this.previewContainer||"global"),i&&e.withDirection(i.value);}}),e.beforeStarted.pipe(_t(1)).subscribe(()=>{if(this._parentDrag){e.withParent(this._parentDrag._dragRef);return}let i=this.element.nativeElement.parentElement;for(;i;){let n=this._dragDropRegistry.getDragDirectiveForNode(i);if(n){e.withParent(n._dragRef);break}i=i.parentElement;}});}_handleEvents(e){e.started.subscribe(i=>{this.started.emit({source:this,event:i.event}),this._changeDetectorRef.markForCheck();}),e.released.subscribe(i=>{this.released.emit({source:this,event:i.event});}),e.ended.subscribe(i=>{this.ended.emit({source:this,distance:i.distance,dropPoint:i.dropPoint,event:i.event}),this._changeDetectorRef.markForCheck();}),e.entered.subscribe(i=>{this.entered.emit({container:i.container.data,item:this,currentIndex:i.currentIndex});}),e.exited.subscribe(i=>{this.exited.emit({container:i.container.data,item:this});}),e.dropped.subscribe(i=>{this.dropped.emit({previousIndex:i.previousIndex,currentIndex:i.currentIndex,previousContainer:i.previousContainer.data,container:i.container.data,isPointerOverContainer:i.isPointerOverContainer,item:this,distance:i.distance,dropPoint:i.dropPoint,event:i.event});});}_assignDefaults(e){let{lockAxis:i,dragStartDelay:n,constrainPosition:s,previewClass:r,boundaryElement:a,draggingDisabled:l,rootElementSelector:d,previewContainer:h}=e;this.disabled=l??false,this.dragStartDelay=n||0,this.lockAxis=i||null,s&&(this.constrainPosition=s),r&&(this.previewClass=r),a&&(this.boundaryElement=a),d&&(this.rootElementSelector=d),h&&(this.previewContainer=h);}_setupHandlesListener(){this._handles.pipe(Cu(e=>{let i=e.map(n=>n.element);this._selfHandle&&this.rootElementSelector&&i.push(this.element),this._dragRef.withHandles(i);}),ry(e=>zm(...e.map(i=>i._stateChanges.pipe(Tu(i))))),bu(this._destroyed)).subscribe(e=>{let i=this._dragRef,n=e.element.nativeElement;e.disabled?i.disableHandle(n):i.enableHandle(n);});}static \u0275fac=function(i){return new(i||o)};static \u0275dir=nw({type:o,selectors:[["","cdkDrag",""]],hostAttrs:[1,"cdk-drag"],hostVars:4,hostBindings:function(i,n){i&2&&sg("cdk-drag-disabled",n.disabled)("cdk-drag-dragging",n._dragRef.isDragging());},inputs:{data:[0,"cdkDragData","data"],lockAxis:[0,"cdkDragLockAxis","lockAxis"],rootElementSelector:[0,"cdkDragRootElement","rootElementSelector"],boundaryElement:[0,"cdkDragBoundary","boundaryElement"],dragStartDelay:[0,"cdkDragStartDelay","dragStartDelay"],freeDragPosition:[0,"cdkDragFreeDragPosition","freeDragPosition"],disabled:[2,"cdkDragDisabled","disabled",Zj],constrainPosition:[0,"cdkDragConstrainPosition","constrainPosition"],previewClass:[0,"cdkDragPreviewClass","previewClass"],previewContainer:[0,"cdkDragPreviewContainer","previewContainer"],scale:[2,"cdkDragScale","scale",Yj]},outputs:{started:"cdkDragStarted",released:"cdkDragReleased",ended:"cdkDragEnded",entered:"cdkDragEntered",exited:"cdkDragExited",dropped:"cdkDragDropped",moved:"cdkDragMoved"},exportAs:["cdkDrag"],features:[LT([{provide:Gt,useExisting:o}]),lv]})}return o})(),$t=new N$1("CdkDropListGroup");var Xt=(()=>{class o{element=w$1(Lr);_changeDetectorRef=w$1(Gj);_scrollDispatcher=w$1(H);_dir=w$1(ru,{optional:true});_group=w$1($t,{optional:true,skipSelf:true});_latestSortedRefs;_destroyed=new te;_scrollableParentsResolved=false;static _dropLists=[];_dropListRef;connectedTo=[];data;orientation="vertical";id=w$1(Mr).getId("cdk-drop-list-");lockAxis=null;get disabled(){return this._disabled||!!this._group&&this._group.disabled}set disabled(e){this._dropListRef.disabled=this._disabled=e;}_disabled=false;sortingDisabled=false;enterPredicate=()=>true;sortPredicate=()=>true;autoScrollDisabled=false;autoScrollStep;elementContainerSelector=null;hasAnchor=false;dropped=new Qe;entered=new Qe;exited=new Qe;sorted=new Qe;_unsortedItems=new Set;constructor(){let e=w$1(jt,{optional:true}),i=w$1(be);this._dropListRef=gi(i,this.element),this._dropListRef.data=this,e&&this._assignDefaults(e),this._dropListRef.enterPredicate=(n,s)=>this.enterPredicate(n.data,s.data),this._dropListRef.sortPredicate=(n,s,r)=>this.sortPredicate(n,s.data,r.data),this._setupInputSyncSubscription(this._dropListRef),this._handleEvents(this._dropListRef),o._dropLists.push(this),this._group&&this._group._items.add(this);}addItem(e){this._unsortedItems.add(e),e._dragRef._withDropContainer(this._dropListRef),this._dropListRef.isDragging()&&this._syncItemsWithRef(this.getSortedItems().map(i=>i._dragRef));}removeItem(e){if(this._unsortedItems.delete(e),this._latestSortedRefs){let i=this._latestSortedRefs.indexOf(e._dragRef);i>-1&&(this._latestSortedRefs.splice(i,1),this._syncItemsWithRef(this._latestSortedRefs));}}getSortedItems(){return Array.from(this._unsortedItems).sort((e,i)=>e._dragRef.getVisibleElement().compareDocumentPosition(i._dragRef.getVisibleElement())&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)}ngOnDestroy(){let e=o._dropLists.indexOf(this);e>-1&&o._dropLists.splice(e,1),this._group&&this._group._items.delete(this),this._latestSortedRefs=void 0,this._unsortedItems.clear(),this._dropListRef.dispose(),this._destroyed.next(),this._destroyed.complete();}_setupInputSyncSubscription(e){this._dir&&this._dir.change.pipe(Tu(this._dir.value),bu(this._destroyed)).subscribe(i=>e.withDirection(i)),e.beforeStarted.subscribe(()=>{let i=nn(this.connectedTo).map(n=>{if(typeof n=="string"){let s=o._dropLists.find(r=>r.id===n);return s}return n});if(this._group&&this._group._items.forEach(n=>{i.indexOf(n)===-1&&i.push(n);}),!this._scrollableParentsResolved){let n=this._scrollDispatcher.getAncestorScrollContainers(this.element).map(s=>s.getElementRef().nativeElement);this._dropListRef.withScrollableParents(n),this._scrollableParentsResolved=true;}if(this.elementContainerSelector){let n=this.element.nativeElement.querySelector(this.elementContainerSelector);e.withElementContainer(n);}e.disabled=this.disabled,e.lockAxis=this.lockAxis,e.sortingDisabled=this.sortingDisabled,e.autoScrollDisabled=this.autoScrollDisabled,e.autoScrollStep=Ar(this.autoScrollStep,2),e.hasAnchor=this.hasAnchor,e.connectedTo(i.filter(n=>n&&n!==this).map(n=>n._dropListRef)).withOrientation(this.orientation);});}_handleEvents(e){e.beforeStarted.subscribe(()=>{this._syncItemsWithRef(this.getSortedItems().map(i=>i._dragRef)),this._changeDetectorRef.markForCheck();}),e.entered.subscribe(i=>{this.entered.emit({container:this,item:i.item.data,currentIndex:i.currentIndex});}),e.exited.subscribe(i=>{this.exited.emit({container:this,item:i.item.data}),this._changeDetectorRef.markForCheck();}),e.sorted.subscribe(i=>{this.sorted.emit({previousIndex:i.previousIndex,currentIndex:i.currentIndex,container:this,item:i.item.data});}),e.dropped.subscribe(i=>{this.dropped.emit({previousIndex:i.previousIndex,currentIndex:i.currentIndex,previousContainer:i.previousContainer.data,container:i.container.data,item:i.item.data,isPointerOverContainer:i.isPointerOverContainer,distance:i.distance,dropPoint:i.dropPoint,event:i.event}),this._changeDetectorRef.markForCheck();}),zm(e.receivingStarted,e.receivingStopped).subscribe(()=>this._changeDetectorRef.markForCheck());}_assignDefaults(e){let{lockAxis:i,draggingDisabled:n,sortingDisabled:s,listAutoScrollDisabled:r,listOrientation:a}=e;this.disabled=n??false,this.sortingDisabled=s??false,this.autoScrollDisabled=r??false,this.orientation=a||"vertical",this.lockAxis=i||null;}_syncItemsWithRef(e){this._latestSortedRefs=e,this._dropListRef.withItems(e);}static \u0275fac=function(i){return new(i||o)};static \u0275dir=nw({type:o,selectors:[["","cdkDropList",""],["cdk-drop-list"]],hostAttrs:[1,"cdk-drop-list"],hostVars:7,hostBindings:function(i,n){i&2&&(Hh("id",n.id),sg("cdk-drop-list-disabled",n.disabled)("cdk-drop-list-dragging",n._dropListRef.isDragging())("cdk-drop-list-receiving",n._dropListRef.isReceiving()));},inputs:{connectedTo:[0,"cdkDropListConnectedTo","connectedTo"],data:[0,"cdkDropListData","data"],orientation:[0,"cdkDropListOrientation","orientation"],id:"id",lockAxis:[0,"cdkDropListLockAxis","lockAxis"],disabled:[2,"cdkDropListDisabled","disabled",Zj],sortingDisabled:[2,"cdkDropListSortingDisabled","sortingDisabled",Zj],enterPredicate:[0,"cdkDropListEnterPredicate","enterPredicate"],sortPredicate:[0,"cdkDropListSortPredicate","sortPredicate"],autoScrollDisabled:[2,"cdkDropListAutoScrollDisabled","autoScrollDisabled",Zj],autoScrollStep:[0,"cdkDropListAutoScrollStep","autoScrollStep"],elementContainerSelector:[0,"cdkDropListElementContainer","elementContainerSelector"],hasAnchor:[2,"cdkDropListHasAnchor","hasAnchor",Zj]},outputs:{dropped:"cdkDropListDropped",entered:"cdkDropListEntered",exited:"cdkDropListExited",sorted:"cdkDropListSorted"},exportAs:["cdkDropList"],features:[LT([{provide:$t,useValue:void 0},{provide:Kt,useExisting:o}])]})}return o})();function fi(o,t){if(o&1){let e=Fw();Pi(0,"button",0),Qh("click",function(){ud(e);let n=qw();return dd(n.clickAction("cancel"))}),Pi(1,"mat-icon",1),TT(2,"close"),ul(),Pi(3,"span"),TT(4,"Close"),ul()();}}var Qt=(()=>{class o{_bottomSheetRef=w$1(_);data=w$1(vA);showCancel=!!(this.data&&this.data.showCancel);clickAction(e){this._bottomSheetRef.dismiss(e);}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=JD({type:o,selectors:[["dashboards-bottom-sheet"]],decls:12,vars:1,consts:[["mat-list-item","",3,"click"],["matListItemIcon",""],["mat-list-item",""]],template:function(i,n){i&1&&(Pi(0,"mat-action-list")(1,"button",0),Qh("click",function(){return n.clickAction("duplicate")}),Pi(2,"mat-icon",1),TT(3,"content_copy"),ul(),Pi(4,"span"),TT(5,"Duplicate"),ul()(),Pi(6,"button",0),Qh("click",function(){return n.clickAction("delete")}),Pi(7,"mat-icon",1),TT(8,"delete_forever"),ul(),Pi(9,"span"),TT(10,"Delete"),ul()(),_w(11,fi,5,0,"button",2),ul()),i&2&&(EE(11),Mw(n.showCancel?11:-1));},dependencies:[Jt,Xt$1,Zt$1,st,yt,wt],encapsulation:2})}return o})();var Di=(o,t)=>t.id;function bi(o,t){if(o&1){let e=Fw();Pi(0,"div",5),Qh("cdkDragStarted",function(){ud(e);let n=qw();return dd(n.dragStart())})("cdkDragMoved",function(n){ud(e);let s=qw();return dd(s.onDragMoved(n))})("cdkDragEnded",function(){ud(e);let n=qw();return dd(n.dragEnd())})("press",function(){let n=ud(e).$index,s=qw();return dd(s.onPress(n))})("doubletap",function(){let n=ud(e).$index,s=qw();return dd(s.editDashboard(n))})("keydown.enter",function(){let n=ud(e).$index,s=qw();return dd(s.editDashboard(n))})("keydown.space",function(){let n=ud(e).$index,s=qw();return dd(s.onPress(n))}),Pi(1,"div",6),TT(2),ul(),Pi(3,"div"),$h(4,"mat-icon",7),ul(),Pi(5,"p",8),TT(6),ul()();}if(o&2){let e=t.$implicit,i=t.$index,n=qw();Bh("mode","editor")("disableGestures",n._sheetOpen||n.suppressDrag)("cdkDragDisabled",n._sheetOpen||n.suppressDrag),Hh("aria-label",e.name),EE(2),gg(i+1),EE(2),ig("width",72,"px")("height",72,"px"),Bh("svgIcon",e.icon||"dashboard"),EE(2),gg(e.name);}}var ei=(()=>{class o{pageTitle="Dashboards";_bottomSheet=w$1(DA);_dashboard=w$1(G$2);_uiEvent=w$1(re);_dialog=w$1(Ff);_sanitizer=w$1(Dr);_sheetOpen=false;suppressDrag=false;_dragActive=false;_dragMoved=false;_dragSuppressThresholdPx=4;addDashboard(){this._dialog.openDashboardPageEditorDialog({title:"New Dashboard",name:`Dashboard ${this._dashboard.dashboards().length+1}`,icon:"dashboard-dashboard",confirmBtnText:"Create",cancelBtnText:"Cancel"}).afterClosed().subscribe(e=>{e&&this._dashboard.add(e.name,[],e.icon,e.collapseSplitShell);});}openBottomSheet(e){if(this._sheetOpen)return;this._sheetOpen=true;let i=typeof navigator<"u"&&/Linux/.test(navigator.platform)&&/Firefox/.test(navigator.userAgent);this._bottomSheet.open(Qt,i?{disableClose:true,data:{showCancel:true}}:{}).afterDismissed().subscribe(s=>{switch(this._sheetOpen=false,s){case "delete":this.deleteDashboard(e);break;case "duplicate":this.duplicateDashboard(e,`${this._dashboard.dashboards()[e].name}`);break;}});}editDashboard(e){let i=this._dashboard.dashboards()[e];i&&this._dialog.openDashboardPageEditorDialog({title:"Dashboard Options",name:i.name??"",icon:i.icon||"dashboard-dashboard",confirmBtnText:"Save",cancelBtnText:"Cancel",collapseSplitShell:i.collapseSplitShell??false}).afterClosed().subscribe(n=>{n&&this._dashboard.update(e,n.name,n.icon,n.collapseSplitShell);});}deleteDashboard(e){this._dashboard.delete(e);}duplicateDashboard(e,i){let n=this._dashboard.dashboards()[e];this._dialog.openDashboardPageEditorDialog({title:"Duplicate Dashboard",name:`${i} copy`,icon:n.icon||"dashboard-dashboard",confirmBtnText:"Save",cancelBtnText:"Cancel",collapseSplitShell:n.collapseSplitShell??false}).afterClosed().subscribe(s=>{s&&this._dashboard.duplicate(e,s.name,s.icon,s.collapseSplitShell);});}drop(e){this._dashboard.dashboards.update(i=>{let n=[...i];ee(n,e.previousIndex,e.currentIndex);let s=this._dashboard.activeDashboard();return s===null||(s===e.previousIndex?this._dashboard.activeDashboard.set(e.currentIndex):s>e.previousIndex&&s<=e.currentIndex?this._dashboard.activeDashboard.set(s-1):s<e.previousIndex&&s>=e.currentIndex&&this._dashboard.activeDashboard.set(s+1)),n});}dragStart(){this._sheetOpen||this.suppressDrag||(this._uiEvent.isDragging.set(true),this._dragActive=true,this._dragMoved=false);}dragEnd(){this._uiEvent.isDragging.set(false),this._dragActive=false,setTimeout(()=>{this._dragMoved=false;},60);}onDragMoved(e){if(!this._dragActive||this._dragMoved)return;Math.hypot(e.distance.x,e.distance.y)>this._dragSuppressThresholdPx&&(this._dragMoved=true);}onPress(e){this._sheetOpen||this._dragMoved||(this.cancelPointerSequence(),this.openBottomSheet(e));}cancelPointerSequence(){this.suppressDrag=true,this._dragActive=false,this._dragMoved=false,["pointerup","mouseup","touchend"].forEach(e=>{document.dispatchEvent(new Event(e,{bubbles:true}));});}onPointerRelease(){this._sheetOpen||(this.suppressDrag=false);}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=JD({type:o,selectors:[["dashboards-editor"]],hostBindings:function(i,n){i&1&&Qh("mouseup",function(){return n.onPointerRelease()},TI)("touchend",function(){return n.onPointerRelease()},TI);},decls:10,vars:0,consts:[["cdkDropList","","cdkDropListOrientation","mixed",1,"dashboard-manage",3,"cdkDropListDropped"],["kipGestures","","matRipple","","cdkDrag","","cdkDragBoundary",".dashboard-manage","tabindex","0",1,"dashboard-card","dashboard-item",3,"mode","disableGestures","cdkDragDisabled"],["tabindex","0",1,"dashboard-card","dashboard-item-add","dashboard-add-btn",3,"click","keydown"],["mat-fab",""],[2,"margin-top","10px"],["kipGestures","","matRipple","","cdkDrag","","cdkDragBoundary",".dashboard-manage","tabindex","0",1,"dashboard-card","dashboard-item",3,"cdkDragStarted","cdkDragMoved","cdkDragEnded","press","doubletap","keydown.enter","keydown.space","mode","disableGestures","cdkDragDisabled"],[1,"item-index"],["aria-hidden","false",1,"dashboard-icon",3,"svgIcon"],[1,"dashboard-name"]],template:function(i,n){i&1&&(Pi(0,"div",0),Qh("cdkDropListDropped",function(r){return n.drop(r)}),xw(1,bi,7,11,"div",1,Di),Pi(3,"div",2),Qh("click",function(){return n.addDashboard()})("keydown",function(){return n.addDashboard()}),Pi(4,"button",3)(5,"mat-icon"),TT(6,"add_box"),ul()(),Pi(7,"p",4)(8,"i"),TT(9,"Add Dashboard"),ul()()()()),i&2&&(EE(),Aw(n._dashboard.dashboards()));},dependencies:[zA,Op,Fp,yt,wt,Xt,Yt,ca,Kh,L],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%;overflow-y:auto;scroll-behavior:smooth}.dashboard-manage[_ngcontent-%COMP%]{box-sizing:border-box;padding:0 60px;width:100%;height:100%;display:flex;flex-wrap:wrap;align-items:flex-start;justify-content:space-around;overflow-y:auto;scroll-behavior:smooth}.dashboard-card[_ngcontent-%COMP%]{position:relative;height:200px;width:300px;margin:10px;border-radius:15px;padding:10px;align-content:center;text-align:center;border:2px solid transparent}@media(max-width:600px)and (orientation:portrait){.dashboard-manage[_ngcontent-%COMP%]{padding:0 70px}.dashboard-card[_ngcontent-%COMP%]{height:175px}}.dashboard-item[_ngcontent-%COMP%]{background-color:var(--mat-sys-surface-container-highest);cursor:pointer}.dashboard-item[_ngcontent-%COMP%]:hover{border:2px solid var(--mat-sys-outline)}.dashboard-item-add[_ngcontent-%COMP%]{background-color:var(--mat-sys-surface-container);cursor:pointer}.dashboard-item-add[_ngcontent-%COMP%]:hover{border:2px solid var(--mat-sys-outline)}.dashboard-add-btn[_ngcontent-%COMP%]{align-content:center;text-align:center;border:dashed 1px var(--mat-sys-outline)}.item-index[_ngcontent-%COMP%]{position:absolute;top:20px;left:20px;display:inline-flex;flex-wrap:wrap;height:42px;width:42px;background-color:var(--kip-contrast-dim-color);color:var(--mat-sys-surface-bright);border-radius:25%;align-content:center;align-items:center;justify-content:center;font-weight:700;font-size:1.25em;z-index:1}.dashboard-icon[_ngcontent-%COMP%]{opacity:.5}.dashboard-name[_ngcontent-%COMP%]{margin-top:10px;margin-bottom:0;font-size:1.1em}.cdk-drag-preview[_ngcontent-%COMP%]{box-sizing:border-box;border-radius:4px;box-shadow:0 5px 5px -3px var(--mat-sys-on-primary-container),0 8px 10px 1px var(--mat-sys-on-primary-container),0 3px 14px 2px var(--mat-sys-on-primary-container)}.cdk-drag-placeholder[_ngcontent-%COMP%]{opacity:0}.cdk-drag-animating[_ngcontent-%COMP%]{transition:transform .25s cubic-bezier(0,0,.2,1)}"]})}return o})();var yn=(()=>{class o{_router=w$1(G$1);app=w$1(N);_responsive=w$1(ir);_isPhonePortrait=Wp(this._responsive.observe(Em.HandsetPortrait),{initialValue:{matches:false,breakpoints:{}}});_isPhoneLandscape=Wp(this._responsive.observe(Em.HandsetLandscape),{initialValue:{matches:false,breakpoints:{}}});isPhonePortrait=Dt(()=>this._isPhonePortrait()?.matches??false);isPhoneLandscape=Dt(()=>this._isPhoneLandscape()?.matches??false);closePage(){this._router.navigate(["/dashboard"]);}onActionItem(e){switch(e){case "help":this._router.navigate(["/help"]);break;case "datainspector":this._router.navigate(["/data"]);break;case "remotecontrol":this._router.navigate(["/remote"]);break;case "options":this._router.navigate(["/options"]);break;}}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=JD({type:o,selectors:[["settings"]],decls:11,vars:20,consts:[[1,"home-container"],[1,"actions-header-container"],[1,"actions-buttons-container"],["svgIcon","settings","label","Options",3,"click","keydown.enter","keydown.space","iconOnly","compact","iconSize"],["svgIcon","troubleshoot","label","Data Inspector",3,"click","keydown.enter","keydown.space","iconOnly","compact","iconSize"],["svgIcon","remote-control","label","Remote Control",3,"click","keydown.enter","keydown.space","iconOnly","compact","iconSize"],["svgIcon","help-center","label","Help",3,"click","keydown.enter","keydown.space","iconOnly","compact","iconSize"],["mat-icon-button","",1,"dialog-close-icon",3,"click"],[1,"dashboards-editor"]],template:function(i,n){i&1&&(Pi(0,"div",0)(1,"div",1)(2,"div",2)(3,"tile-large-icon",3),Qh("click",function(){return n.onActionItem("options")})("keydown.enter",function(){return n.onActionItem("options")})("keydown.space",function(){return n.onActionItem("options")}),ul(),Pi(4,"tile-large-icon",4),Qh("click",function(){return n.onActionItem("datainspector")})("keydown.enter",function(){return n.onActionItem("datainspector")})("keydown.space",function(){return n.onActionItem("datainspector")}),ul(),Pi(5,"tile-large-icon",5),Qh("click",function(){return n.onActionItem("remotecontrol")})("keydown.enter",function(){return n.onActionItem("remotecontrol")})("keydown.space",function(){return n.onActionItem("remotecontrol")}),ul(),Pi(6,"tile-large-icon",6),Qh("click",function(){return n.onActionItem("help")})("keydown.enter",function(){return n.onActionItem("help")})("keydown.space",function(){return n.onActionItem("help ")}),ul()(),Pi(7,"button",7),Qh("click",function(){return n.closePage()}),Pi(8,"mat-icon"),TT(9,"close"),ul()()(),$h(10,"dashboards-editor",8),ul()),i&2&&(EE(3),pT(`${n.isPhonePortrait()?"no-label":"with-label"}`),Bh("iconOnly",n.isPhonePortrait())("compact",true)("iconSize",48),EE(),pT(`${n.isPhonePortrait()?"no-label":"with-label"}`),Bh("iconOnly",n.isPhonePortrait())("compact",true)("iconSize",48),EE(),pT(`${n.isPhonePortrait()?"no-label":"with-label"}`),Bh("iconOnly",n.isPhonePortrait())("compact",true)("iconSize",48),EE(),pT(`${n.isPhonePortrait()?"no-label":"with-label"}`),Bh("iconOnly",n.isPhonePortrait())("compact",true)("iconSize",48));},dependencies:[yt,wt,Op,eu,R,f,ei],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%}.home-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%}.actions-header-container[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:flex-start;width:100%;padding:5px 0 5px 10px}.with-label[_ngcontent-%COMP%]{height:80px;width:100px}.no-label[_ngcontent-%COMP%]{height:58px;width:63px}.dashboard-editor[_ngcontent-%COMP%]{flex:1 1 auto;min-height:0;overflow:auto}.actions-buttons-container[_ngcontent-%COMP%]{display:flex;flex-direction:row;flex-wrap:nowrap;gap:5px}.dialog-close-icon[_ngcontent-%COMP%]{margin-right:15px;margin-top:6px}.mat-mdc-dialog-content[_ngcontent-%COMP%]{max-height:max-content}"]})}return o})();export{yn as SettingsComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {e as e$1}from'./chunk-CyURmwWh.js';import {g as ge$1}from'./chunk-TakPRI3t.js';import {e9 as a,d1 as Hj,w,du as p,aS as De,bu as ut,ea as K,aY as xe,$ as $j,v as vt,D as Dt,dx as n$1,F as Fa,dn as ge,a_ as Gp,av as _t,cv as G,J as JD,y as yt,dC as x,_ as _w,cn as wd,c as $h,M as Mw,e as EE,s as sg,f as eg,K as Kw,g as qw,B as Bh,P as Pi,T as TT,u as ul}from'./main-BNR44HGB.js';import {c,e}from'./chunk-D_wrJJxl.js';function H(i){return function(){return i}}var Mt=Math.abs,_=Math.atan2,z=Math.cos,qt=Math.max,rt=Math.min,$=Math.sin,W=Math.sqrt,S=1e-12,Z=Math.PI,tt=Z/2,Xt=2*Z;function jt(i){return i>1?0:i<-1?Z:Math.acos(i)}function Tt(i){return i>=1?tt:i<=-1?-tt:Math.asin(i)}var Ct=Math.PI,At=2*Ct,L=1e-6,ae=At-L;function Zt(i){this._+=i[0];for(let t=1,a=i.length;t<a;++t)this._+=arguments[t]+i[t];}function re(i){let t=Math.floor(i);if(!(t>=0))throw new Error(`invalid digits: ${i}`);if(t>15)return Zt;let a=10**t;return function(r){this._+=r[0];for(let e=1,n=r.length;e<n;++e)this._+=Math.round(arguments[e]*a)/a+r[e];}}var F=class{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?Zt:re(t);}moveTo(t,a){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+a}`;}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`);}lineTo(t,a){this._append`L${this._x1=+t},${this._y1=+a}`;}quadraticCurveTo(t,a,r,e){this._append`Q${+t},${+a},${this._x1=+r},${this._y1=+e}`;}bezierCurveTo(t,a,r,e,n,o){this._append`C${+t},${+a},${+r},${+e},${this._x1=+n},${this._y1=+o}`;}arcTo(t,a,r,e,n){if(t=+t,a=+a,r=+r,e=+e,n=+n,n<0)throw new Error(`negative radius: ${n}`);let o=this._x1,l=this._y1,m=r-t,d=e-a,s=o-t,g=l-a,c=s*s+g*g;if(this._x1===null)this._append`M${this._x1=t},${this._y1=a}`;else if(c>L)if(!(Math.abs(g*m-d*s)>L)||!n)this._append`L${this._x1=t},${this._y1=a}`;else {let y=r-o,v=e-l,k=m*m+d*d,R=y*y+v*v,x=Math.sqrt(k),h=Math.sqrt(c),M=n*Math.tan((Ct-Math.acos((k+c-R)/(2*x*h)))/2),T=M/h,f=M/x;Math.abs(T-1)>L&&this._append`L${t+T*s},${a+T*g}`,this._append`A${n},${n},0,0,${+(g*y>s*v)},${this._x1=t+f*m},${this._y1=a+f*d}`;}}arc(t,a,r,e,n,o){if(t=+t,a=+a,r=+r,o=!!o,r<0)throw new Error(`negative radius: ${r}`);let l=r*Math.cos(e),m=r*Math.sin(e),d=t+l,s=a+m,g=1^o,c=o?e-n:n-e;this._x1===null?this._append`M${d},${s}`:(Math.abs(this._x1-d)>L||Math.abs(this._y1-s)>L)&&this._append`L${d},${s}`,r&&(c<0&&(c=c%At+At),c>ae?this._append`A${r},${r},0,1,${g},${t-l},${a-m}A${r},${r},0,1,${g},${this._x1=d},${this._y1=s}`:c>L&&this._append`A${r},${r},0,${+(c>=Ct)},${g},${this._x1=t+r*Math.cos(n)},${this._y1=a+r*Math.sin(n)}`);}rect(t,a,r,e){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+a}h${r=+r}v${+e}h${-r}Z`;}toString(){return this._}};function Jt(i){let t=3;return i.digits=function(a){if(!arguments.length)return t;if(a==null)t=null;else {let r=Math.floor(a);if(!(r>=0))throw new RangeError(`invalid digits: ${a}`);t=r;}return i},()=>new F(t)}function ne(i){return i.innerRadius}function ie(i){return i.outerRadius}function se(i){return i.startAngle}function oe(i){return i.endAngle}function le(i){return i&&i.padAngle}function ce(i,t,a,r,e,n,o,l){var m=a-i,d=r-t,s=o-e,g=l-n,c=g*m-s*d;if(!(c*c<S))return c=(s*(t-n)-g*(i-e))/c,[i+c*m,t+c*d]}function nt(i,t,a,r,e,n,o){var l=i-a,m=t-r,d=(o?n:-n)/W(l*l+m*m),s=d*m,g=-d*l,c=i+s,y=t+g,v=a+s,k=r+g,R=(c+v)/2,x=(y+k)/2,h=v-c,M=k-y,T=h*h+M*M,f=e-n,u=c*k-v*y,N=(M<0?-1:1)*W(qt(0,f*f*T-u*u)),w=(u*M-h*N)/T,E=(-u*h-M*N)/T,B=(u*M+h*N)/T,C=(-u*h+M*N)/T,I=w-R,p=E-x,b=B-R,O=C-x;return I*I+p*p>b*b+O*O&&(w=B,E=C),{cx:w,cy:E,x01:-s,y01:-g,x11:w*(e/f-1),y11:E*(e/f-1)}}function Bt(){var i=ne,t=ie,a=H(0),r=null,e=se,n=oe,o=le,l=null,m=Jt(d);function d(){var s,g,c=+i.apply(this,arguments),y=+t.apply(this,arguments),v=e.apply(this,arguments)-tt,k=n.apply(this,arguments)-tt,R=Mt(k-v),x=k>v;if(l||(l=s=m()),y<c&&(g=y,y=c,c=g),!(y>S))l.moveTo(0,0);else if(R>Xt-S)l.moveTo(y*z(v),y*$(v)),l.arc(0,0,y,v,k,!x),c>S&&(l.moveTo(c*z(k),c*$(k)),l.arc(0,0,c,k,v,x));else {var h=v,M=k,T=v,f=k,u=R,N=R,w=o.apply(this,arguments)/2,E=w>S&&(r?+r.apply(this,arguments):W(c*c+y*y)),B=rt(Mt(y-c)/2,+a.apply(this,arguments)),C=B,I=B,p,b;if(E>S){var O=Tt(E/c*$(w)),U=Tt(E/y*$(w));(u-=O*2)>S?(O*=x?1:-1,T+=O,f-=O):(u=0,T=f=(v+k)/2),(N-=U*2)>S?(U*=x?1:-1,h+=U,M-=U):(N=0,h=M=(v+k)/2);}var A=y*z(h),P=y*$(h),K=c*z(f),V=c*$(f);if(B>S){var Y=y*z(M),q=y*$(M),it=c*z(T),st=c*$(T),G;if(R<Z)if(G=ce(A,P,it,st,Y,q,K,V)){var ot=A-G[0],lt=P-G[1],ct=Y-G[0],dt=q-G[1],_t=1/$(jt((ot*ct+lt*dt)/(W(ot*ot+lt*lt)*W(ct*ct+dt*dt)))/2),Rt=W(G[0]*G[0]+G[1]*G[1]);C=rt(B,(c-Rt)/(_t-1)),I=rt(B,(y-Rt)/(_t+1));}else C=I=0;}N>S?I>S?(p=nt(it,st,A,P,y,I,x),b=nt(Y,q,K,V,y,I,x),l.moveTo(p.cx+p.x01,p.cy+p.y01),I<B?l.arc(p.cx,p.cy,I,_(p.y01,p.x01),_(b.y01,b.x01),!x):(l.arc(p.cx,p.cy,I,_(p.y01,p.x01),_(p.y11,p.x11),!x),l.arc(0,0,y,_(p.cy+p.y11,p.cx+p.x11),_(b.cy+b.y11,b.cx+b.x11),!x),l.arc(b.cx,b.cy,I,_(b.y11,b.x11),_(b.y01,b.x01),!x))):(l.moveTo(A,P),l.arc(0,0,y,h,M,!x)):l.moveTo(A,P),!(c>S)||!(u>S)?l.lineTo(K,V):C>S?(p=nt(K,V,Y,q,c,-C,x),b=nt(A,P,it,st,c,-C,x),l.lineTo(p.cx+p.x01,p.cy+p.y01),C<B?l.arc(p.cx,p.cy,C,_(p.y01,p.x01),_(b.y01,b.x01),!x):(l.arc(p.cx,p.cy,C,_(p.y01,p.x01),_(p.y11,p.x11),!x),l.arc(0,0,c,_(p.cy+p.y11,p.cx+p.x11),_(b.cy+b.y11,b.cx+b.x11),x),l.arc(b.cx,b.cy,C,_(b.y11,b.x11),_(b.y01,b.x01),!x))):l.arc(0,0,c,f,T,x);}if(l.closePath(),s)return l=null,s+""||null}return d.centroid=function(){var s=(+i.apply(this,arguments)+ +t.apply(this,arguments))/2,g=(+e.apply(this,arguments)+ +n.apply(this,arguments))/2-Z/2;return [z(g)*s,$(g)*s]},d.innerRadius=function(s){return arguments.length?(i=typeof s=="function"?s:H(+s),d):i},d.outerRadius=function(s){return arguments.length?(t=typeof s=="function"?s:H(+s),d):t},d.cornerRadius=function(s){return arguments.length?(a=typeof s=="function"?s:H(+s),d):a},d.padRadius=function(s){return arguments.length?(r=s==null?null:typeof s=="function"?s:H(+s),d):r},d.startAngle=function(s){return arguments.length?(e=typeof s=="function"?s:H(+s),d):e},d.endAngle=function(s){return arguments.length?(n=typeof s=="function"?s:H(+s),d):n},d.padAngle=function(s){return arguments.length?(o=typeof s=="function"?s:H(+s),d):o},d.context=function(s){return arguments.length?(l=s??null,d):l},d}var ue=["bmsSvg"];function pe(i,t){if(i&1&&$h(0,"widget-title",1),i&2){let a=qw();Bh("text",a.displayLabel())("color",a.labelColor());}}function me(i,t){i&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No batteries detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K battery paths or select batteries in widget settings."),ul()());}var ee=class i{static BMS_DESCRIPTOR=a("widget-bms");static ROOT_PATTERN=`${i.BMS_DESCRIPTOR?.selfRootPath??"self.electrical.batteries"}.*`;id=Hj.required();type=Hj.required();theme=Hj.required();renderMode=Hj(null);static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,bms:{trackedDevices:[],groups:[],banks:[]}};static VIEWBOX_WIDTH=200;static MIN_VIEWBOX_HEIGHT=1;static BANK_CARD_WIDTH=200;static BATTERY_CARD_HEIGHT=50;static BATTERY_CARD_WIDTH=200;static CARD_GAP=8;static BANK_HEADER_HEIGHT=80;static BANK_MIN_HEIGHT=75;static SINGLE_ROW_BANK_HEIGHT=100;static IN_BANK_COLUMNS=2;static IN_BANK_COLUMN_GAP=5;static IN_BANK_PADDING_X=0;static BANK_GAUGE_RADIUS=50;static BANK_GAUGE_BG_STROKE=10;static BANK_GAUGE_VALUE_STROKE=10;static COMPACT_UNASSIGNED_BATTERY_SCALE=.82;static PATH_BATCH_WINDOW_MS=500;runtime=w(p);data=w(De);units=w(ut);iconRegistry=w(K);destroyRef=w(xe);svgRef=$j.required("bmsSvg");svg;root;bankLayer;batteryLayer;bankGaugeBackgroundPath=this.buildSemiGaugeArcPath(i.BANK_GAUGE_RADIUS,1);glowFilterId="";renderFrameId=null;pendingRenderSnapshot=null;pathBatchTimerId=null;initialPathPaintDone=false;pendingPathUpdates=new Map;powerAvailableIconTemplate=null;powerRenewalIconTemplate=null;discoveredBatteryIds=vt([]);trackedBatteryDeviceIds=vt([]);banks=vt([]);cardMode=vt({displayMode:"full",metrics:[]});batteries=vt({});visibleBatteryIds=Dt(()=>{let t=this.trackedBatteryDeviceIds();return t.length?t:this.discoveredBatteryIds()});visibleBatteries=Dt(()=>{let t=this.visibleBatteryIds(),a=this.batteries();return t.map(r=>a[r]).filter(r=>!!r)});bankSummaries=Dt(()=>{let t=this.banks(),a=this.batteries();return t.map(r=>this.buildBankSummary(r,a))});activeDisplayMode=Dt(()=>this.renderMode()??this.cardMode().displayMode??"full");isCompactCardMode=Dt(()=>this.activeDisplayMode()==="compact");colorRole=Dt(()=>this.runtime.options()?.color??"contrast");ignoreZones=Dt(()=>this.runtime.options()?.ignoreZones??false);displayLabel=Dt(()=>{let t=this.bankSummaries();if(t.length===1)return t[0].name||"Bank";if(t.length>1)return "Batteries";let a=this.visibleBatteries();return a.length!==1?"Batteries":this.resolveBatteryTitleText(a[0])});labelColor=Dt(()=>{let t=this.theme();return t?c(this.colorRole(),t).dim:"var(--kip-contrast-dim-color)"});widgetColors=Dt(()=>{let t=this.theme();return t?c(this.colorRole(),t):null});batteryDisplayModels=Dt(()=>{let t=this.visibleBatteries(),a=this.theme(),r=this.widgetColors(),e$1=this.ignoreZones(),n={};for(let o of t){let l=e(o.stateOfChargeState,r?.dimmer??"var(--kip-contrast-dimmer-color)",a,e$1),m=e(o.stateOfChargeState,r?.dim??"var(--kip-contrast-dim-color)",a,e$1),d=e(o.currentState,"var(--kip-contrast-dim-color)",a,e$1),s=e(o.currentState,"var(--kip-contrast-color)",a,e$1);n[o.id]={id:o.id,titleText:this.resolveBatteryTitleText(o),chargeWidth:(i.BATTERY_CARD_WIDTH-3)*(o.stateOfCharge??0),chargeBarColorCompact:l,chargeBarColorRegular:m,currentTextColorCompact:d,currentTextColorRegular:s,currentText:`${this.formatCurrent(o.current)}`.trim(),detailLineCompact:`${this.formatVoltage(o.voltage)}\xA0\xA0\xA0\xA0${this.formatTemperature(o.temperature)}`,detailLineRegular:`${this.formatVoltage(o.voltage)}\xA0\xA0\xA0\xA0${this.formatPower(o.power)}\xA0\xA0\xA0\xA0${this.formatTemperature(o.temperature)}`.trim(),socText:this.formatSoc(o.stateOfCharge),socGlowEnabled:!e$1&&(o.stateOfChargeState===n$1.Warn||o.stateOfChargeState===n$1.Alarm||o.stateOfChargeState===n$1.Alert),remainingCapacityText:o.capacityActual?`${this.formatEnergy(o.capacityRemaining)}`:"",remainingTimeText:`${this.formatDuration(o.timeRemaining)}`.trim(),iconKey:o.current!=null&&o.current>0?"power_renewal":"power_available"};}return n});bankDisplayModels=Dt(()=>{let t=this.bankSummaries(),a=this.widgetColors(),r={};for(let e of t)r[e.id]={id:e.id,titleText:e.name||"Bank",currentText:this.formatCurrent(e.totalCurrent),powerText:this.formatPower(e.totalPower),socText:this.formatSoc(e.avgSoc),remainingTimeText:`${this.formatDuration(e.timeRemaining)}`.trim(),remainingCapacityText:e.remainingCapacity?`${this.formatEnergy(e.remainingCapacity)}`:"",gaugeValuePath:this.buildSemiGaugeArcPath(i.BANK_GAUGE_RADIUS,e.avgSoc),gaugeValueColor:a?.color??"var(--kip-contrast-color)",zoneState:null,zoneColor:null};return r});hasBatteries=Dt(()=>this.visibleBatteries().length>0);hasBanks=Dt(()=>this.bankSummaries().length>0);constructor(){Fa(()=>{let a=this.runtime.options();a&&ge(()=>this.applyConfig(a));}),Fa(()=>{let a=this.bankSummaries(),r=this.visibleBatteries(),e=this.widgetColors(),n=this.batteryDisplayModels(),o=this.bankDisplayModels();!this.svg||!e||this.requestRender({banks:a,batteries:r,batteryDisplayModels:n,bankDisplayModels:o,widgetColors:e});});let t=this.data.subscribePathTreeWithInitial(i.ROOT_PATTERN);if(t.initial.length){for(let a of t.initial)this.enqueuePathUpdate(a,true);this.flushPendingPathUpdates(),this.initialPathPaintDone=true;}t.live$.pipe(Gp(this.destroyRef)).subscribe(a=>{this.enqueuePathUpdate(a);});}ngAfterViewInit(){this.initializeSvg(),this.loadPowerIcons(),this.requestRender();}ngOnDestroy(){this.pathBatchTimerId!==null&&(clearTimeout(this.pathBatchTimerId),this.pathBatchTimerId=null),this.renderFrameId!==null&&(cancelAnimationFrame(this.renderFrameId),this.renderFrameId=null),this.pendingRenderSnapshot=null;}initializeSvg(){this.svg=ge$1(this.svgRef().nativeElement),this.svg.attr("viewBox",`0 0 ${i.VIEWBOX_WIDTH} ${i.MIN_VIEWBOX_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","Battery Management System View"),this.glowFilterId=`bms-soc-glow-${this.id()}`;let a=this.svg.append("defs").append("filter").attr("id",this.glowFilterId).attr("x","-30%").attr("y","-30%").attr("width","160%").attr("height","160%");a.append("feFlood").attr("class","bms-soc-glow-flood").attr("flood-color","var(--kip-widget-card-background-color)").attr("flood-opacity",.9).attr("result","color"),a.append("feComposite").attr("in","color").attr("in2","SourceGraphic").attr("operator","in").attr("result","coloredGlow"),a.append("feGaussianBlur").attr("in","coloredGlow").attr("stdDeviation",2).attr("result","blur");let r=a.append("feMerge");r.append("feMergeNode").attr("in","blur"),r.append("feMergeNode").attr("in","blur"),r.append("feMergeNode").attr("in","SourceGraphic"),this.root=this.svg.append("g").attr("class","bms-root"),this.bankLayer=this.root.append("g").attr("class","bms-banks"),this.batteryLayer=this.root.append("g").attr("class","bms-batteries");}loadPowerIcons(){this.loadNamedIcon("power_available",t=>{this.powerAvailableIconTemplate=t;}),this.loadNamedIcon("power_renewal",t=>{this.powerRenewalIconTemplate=t;});}loadNamedIcon(t,a){this.iconRegistry.getNamedSvgIcon(t).pipe(_t(1)).subscribe({next:r=>{a(r),this.requestRender();},error:()=>{}});}applyConfig(t){let a=this.resolveBmsConfig(t);this.trackedBatteryDeviceIds.set([...new Set((a.trackedDevices??[]).map(r=>r.id))]),this.banks.set(a.banks),this.cardMode.set(this.normalizeCardMode(a.cardMode));}resolveBmsConfig(t){let a=t.bms,r=this.normalizeTrackedDevices(a?.trackedDevices),e=this.normalizeBanksFromGroups(a?.groups),n=this.normalizeBanksFromLegacy(a?.banks);return {trackedDevices:r,groups:e,banks:e.length>0?e:n,cardMode:this.normalizeCardMode(a?.cardMode)}}normalizeTrackedDevices(t){if(!Array.isArray(t))return [];let a=new Map;return t.forEach(r=>{if(!r||typeof r!="object")return;let e=r,n=typeof e.id=="string"?e.id.trim():"",o=typeof e.source=="string"?e.source.trim():"default";if(!n||!o)return;let l=typeof e.key=="string"&&e.key.trim().length>0?e.key.trim():`${n}||${o}`;a.set(l,{id:n,source:o,key:l});}),[...a.values()].sort((r,e)=>r.key.localeCompare(e.key))}normalizeCardMode(t){let a=t&&typeof t=="object"?t:null,r=this.normalizeStringList(a?.metrics);return {displayMode:a?.displayMode==="compact"?"compact":"full",metrics:r}}normalizeStringList(t){if(!Array.isArray(t))return [];let a=new Set;return t.forEach(r=>{if(typeof r!="string")return;let e=r.trim();e.length>0&&a.add(e);}),[...a].sort((r,e)=>r.localeCompare(e))}normalizeBanksFromGroups(t){return Array.isArray(t)?t.map(a=>{let r=this.normalizeOptionalString(a?.id)??`bank-${Date.now()}`,e=this.normalizeOptionalString(a?.name)??r,n=this.normalizeStringList(a?.memberIds);return {id:r,name:e,batteryIds:n,connectionMode:this.normalizeConnectionMode(a?.connectionMode)}}).filter(a=>a.id.length>0):[]}normalizeBanksFromLegacy(t){return Array.isArray(t)?t.map(a=>{let r=this.normalizeOptionalString(a?.id)??`bank-${Date.now()}`,e=this.normalizeOptionalString(a?.name)??r,n=this.normalizeStringList(a?.batteryIds);return {id:r,name:e,batteryIds:n,connectionMode:this.normalizeConnectionMode(a?.connectionMode)}}).filter(a=>a.id.length>0):[]}normalizeOptionalString(t){if(typeof t!="string")return null;let a=t.trim();return a.length>0?a:null}normalizeConnectionMode(t){return t==="series"?"series":"parallel"}enqueuePathUpdate(t,a=false){let r=this.parseBatteryPath(t.path);if(!r)return;let{id:e,key:n}=r,o=t.update?.data?.value??null,l=t.update?.state??null,m=`${e}::${n}`;if(this.pendingPathUpdates.set(m,{id:e,key:n,value:o,state:l}),!a){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=window.setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},i.PATH_BATCH_WINDOW_MS));}}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let t=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(t.map(r=>r.id)).forEach(r=>this.trackDiscoveredBattery(r)),this.batteries.update(r=>{let e=r,n=false;for(let o of t){let l=e[o.id]??{id:o.id},m=G({},l),d=this.applyBatteryValue(m,o.key,o.value,o.state),s=false;if(m.voltage!=null&&m.current!=null){let g=Number.isFinite(m.voltage)&&Number.isFinite(m.current)?m.voltage*m.current:null;Object.is(m.power,g)||(m.power=g,s=true);}!d&&!s||(n||(e=G({},e),n=true),e[o.id]=m);}return n?e:r});}parseBatteryPath(t){let a=t.match(/self\.electrical\.batteries\.([^.]+)\.(.+)$/);return a?{id:a[1],key:a[2]}:null}trackDiscoveredBattery(t){let a=this.discoveredBatteryIds();if(a.includes(t))return;let r=[...a,t].sort();this.discoveredBatteryIds.set(r);}applyBatteryValue(t,a,r,e){switch(a){case "name":{let n=r;return t.name===n?false:(t.name=n,true)}case "location":{let n=r;return t.location===n?false:(t.location=n,true)}case "associatedBus":{let n=r;return t.associatedBus===n?false:(t.associatedBus=n,true)}case "chemistry":{let n=r;return t.chemistry===n?false:(t.chemistry=n,true)}case "voltage":{let n=this.toNumber(r);return Object.is(t.voltage,n)?false:(t.voltage=n,true)}case "current":{let n=this.toNumber(r),o=!Object.is(t.currentState??null,e??null);return Object.is(t.current,n)&&!o?false:(t.current=n,t.currentState=e,true)}case "temperature":{let n=this.toNumber(r);return Object.is(t.temperature,n)?false:(t.temperature=n,true)}case "capacity.nominal":{let n=this.toNumber(r);return Object.is(t.capacityNominal,n)?false:(t.capacityNominal=n,true)}case "capacity.actual":{let n=this.toNumber(r);return Object.is(t.capacityActual,n)?false:(t.capacityActual=n,true)}case "capacity.remaining":{let n=this.toNumber(r);return Object.is(t.capacityRemaining,n)?false:(t.capacityRemaining=n,true)}case "capacity.stateOfCharge":{let n=this.toNumber(r),o=!Object.is(t.stateOfChargeState??null,e??null);return Object.is(t.stateOfCharge,n)&&!o?false:(t.stateOfCharge=n,t.stateOfChargeState=e,true)}case "capacity.timeRemaining":{let n=this.toNumber(r);return Object.is(t.timeRemaining,n)?false:(t.timeRemaining=n,true)}default:return false}}buildBankSummary(t,a){let r=t.batteryIds.map(s=>a[s]).filter(s=>!!s),e=this.normalizeConnectionMode(t.connectionMode),n=this.calculateBankCurrent(r,e),o=this.sumNumbers(r.map(s=>s.power)),l=this.sumNumbers(r.map(s=>s.capacityRemaining)),m=this.calculateBankSoc(r),d=this.calculateBankTimeRemaining(r,e);return {id:t.id,name:t.name,batteryIds:t.batteryIds,totalCurrent:n,totalPower:o,remainingCapacity:l,avgSoc:m,timeRemaining:d}}calculateBankSoc(t){let a=this.sumNumbers(t.map(n=>n.capacityRemaining)),r=this.sumNumbers(t.map(n=>n.capacityActual));if(a!=null&&r!=null&&r>0)return Math.max(0,Math.min(1,a/r));let e=this.sumNumbers(t.map(n=>n.capacityNominal));return a!=null&&e!=null&&e>0?Math.max(0,Math.min(1,a/e)):this.averageNumbers(t.map(n=>n.stateOfCharge))}calculateBankCurrent(t,a){let r=t.map(e=>e.current);return a==="series"?this.averageNumbers(r):this.sumNumbers(r)}calculateBankTimeRemaining(t,a){let r=t.map(e=>e.timeRemaining);return a==="series"?this.minNumber(r):this.averageNumbers(r)}requestRender(t){this.svg&&(this.pendingRenderSnapshot=t??this.buildRenderSnapshot(),this.pendingRenderSnapshot&&this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;let a=this.pendingRenderSnapshot;this.pendingRenderSnapshot=null,a&&this.render(a);})));}buildRenderSnapshot(){let t=this.widgetColors();return t?{banks:this.bankSummaries(),batteries:this.visibleBatteries(),batteryDisplayModels:this.batteryDisplayModels(),bankDisplayModels:this.bankDisplayModels(),widgetColors:t}:null}render(t){if(!this.bankLayer||!this.batteryLayer)return;let{banks:a,batteries:r,bankDisplayModels:e,batteryDisplayModels:n,widgetColors:o}=t,l=this.buildRenderLayout(a,r,e,n,this.isCompactCardMode()),d=this.isCompactCardMode()?e$1:e$1,s=Math.max(i.MIN_VIEWBOX_HEIGHT,l.contentHeight);this.svg?.attr("viewBox",`0 0 ${i.VIEWBOX_WIDTH} ${s}`),this.root?.attr("transform",null);let g=this.bankLayer.selectAll("g.bank-card").data(l.banks,u=>u.id),c=g.enter().append("g").attr("class","bank-card"),y=c.append("text").attr("class","bank-card-power");y.append("tspan").attr("class","bank-card-power-value"),y.append("tspan").attr("class","bank-card-power-unit");let v=c.append("text").attr("class","bank-card-current");v.append("tspan").attr("class","bank-card-current-value"),v.append("tspan").attr("class","bank-card-current-unit");let k=c.append("g").attr("class","bank-gauge");k.append("path").attr("class","bank-gauge-bg"),k.append("path").attr("class","bank-gauge-value");let R=k.append("text").attr("class","bank-gauge-soc");R.append("tspan").attr("class","bank-gauge-soc-value"),R.append("tspan").attr("class","bank-gauge-soc-unit");let x=c.append("text").attr("class","bank-actualCapacity");x.append("tspan").attr("class","bank-actualCapacity-value"),x.append("tspan").attr("class","bank-actualCapacity-unit"),c.append("text").attr("class","bank-remaining"),c.append("g").attr("class","bank-bms-batteries"),c.append("text").attr("class","bank-title");let h=c.merge(g);h.attr("transform",u=>`translate(${u.x},${u.y})`),l.banks.length>1?h.select("text.bank-title").attr("x",d.titleX).attr("y",d.titleY).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",d.titleFontSize).text(u=>u.displayModel.titleText):h.select("text.bank-title").text(""),h.select("text.bank-card-current").attr("x",d.lineOneX).attr("y",d.lineOneY).attr("fill","var(--kip-contrast-color)").attr("font-size",d.lineOneFontSize),h.select("tspan.bank-card-current-value").text(u=>this.splitMetricText(u.displayModel.currentText,"A").valueText),h.select("tspan.bank-card-current-unit").attr("dx",1).attr("font-size",12).attr("fill","var(--kip-contrast-color)").text(u=>this.splitMetricText(u.displayModel.currentText,"A").unitText),h.select("text.bank-card-power").attr("x",5).attr("y",42).attr("fill","var(--kip-contrast-color)").attr("font-size",10).attr("opacity",.8),h.select("tspan.bank-card-power-value").text(u=>this.splitMetricText(u.displayModel.powerText,"W").valueText),h.select("tspan.bank-card-power-unit").attr("dx",1).attr("font-size",6).attr("fill","var(--kip-contrast-color)").text(u=>this.splitMetricText(u.displayModel.powerText,"W").unitText),h.select("g.bank-gauge").attr("transform","translate(143, 60)"),h.select("path.bank-gauge-bg").attr("d",this.bankGaugeBackgroundPath).attr("fill","none").attr("stroke","var(--kip-contrast-dimmer-color)").attr("stroke-width",i.BANK_GAUGE_BG_STROKE).attr("stroke-linecap","round"),h.select("path.bank-gauge-value").attr("d",u=>u.displayModel.gaugeValuePath).attr("fill","none").attr("stroke",u=>u.displayModel.gaugeValueColor).attr("stroke-width",i.BANK_GAUGE_VALUE_STROKE).attr("stroke-linecap","round"),h.select("text.bank-gauge-soc").attr("x",0).attr("y",-5).attr("text-anchor","middle").attr("fill","var(--kip-contrast-color)").attr("font-size",d.primaryFontSize).attr("font-weight",d.primaryFontWeight),h.select("tspan.bank-gauge-soc-value").text(u=>this.splitMetricText(u.displayModel.socText,"%").valueText),h.select("tspan.bank-gauge-soc-unit").attr("dx",1).attr("font-size",22).attr("font-weight",500).attr("fill","var(--kip-contrast-color)").text(u=>this.splitMetricText(u.displayModel.socText,"%").unitText),h.select("text.bank-remaining").attr("x",143).attr("y",26).attr("fill","var(--kip-contrast-dim-color)").attr("text-anchor","middle").attr("font-size",8).text(u=>u.displayModel.remainingTimeText),h.select("text.bank-actualCapacity").attr("x",143).attr("y",66).attr("fill","var(--kip-contrast-dim-color)").attr("text-anchor","middle").attr("font-size",8),h.select("tspan.bank-actualCapacity-value").text(u=>this.splitMetricText(u.displayModel.remainingCapacityText,"kWh").valueText),h.select("tspan.bank-actualCapacity-unit").attr("dx",1).attr("font-size",6).attr("fill","var(--kip-contrast-dim-color)").text(u=>this.splitMetricText(u.displayModel.remainingCapacityText,"kWh").unitText),h.select("g.bank-bms-batteries").each((u,N,w)=>{let B=ge$1(w[N]).selectAll("g.battery-card").data(u.batteries,p=>p.key),C=B.enter().append("g").attr("class","battery-card battery-card--in-bank");this.appendBatteryCardSkeleton(C);let I=C.merge(B);this.renderBatteryCards(I,o,t.batteries.length>1),B.exit().remove();}),g.exit().remove();let M=this.batteryLayer.selectAll("g.battery-card").data(l.unassignedBatteries,u=>u.key),T=M.enter().append("g").attr("class","battery-card battery-card--unassigned");this.appendBatteryCardSkeleton(T);let f=T.merge(M);this.renderBatteryCards(f,o,true),M.exit().remove(),this.root?.attr("data-theme","ready");}buildRenderLayout(t,a,r,e,n){let o=new Map(a.map(f=>[f.id,f])),l=new Set,m=this.computeInBankBatterySlotWidth(),d=Math.max(.35,Math.min(1,m/i.BATTERY_CARD_WIDTH)),s=i.BATTERY_CARD_HEIGHT*d,g=0,c=t.map(f=>{let u=new Set,N=f.batteryIds.map(A=>o.get(A)).filter(A=>!A||u.has(A.id)?false:(u.add(A.id),true));N.forEach(A=>l.add(A.id));let w=Math.ceil(N.length/i.IN_BANK_COLUMNS),E=i.SINGLE_ROW_BANK_HEIGHT,B=!n&&w===1,C=B?Math.max(0,E-s-i.CARD_GAP):i.BANK_HEADER_HEIGHT,I=w>0?w*s+(w-1)*i.CARD_GAP:0,p=Math.max(i.BANK_MIN_HEIGHT,C+I+i.CARD_GAP),b=B?E:p,O=N.map((A,P)=>{let K=P%i.IN_BANK_COLUMNS,V=Math.floor(P/i.IN_BANK_COLUMNS),Y=i.IN_BANK_PADDING_X+K*(m+i.IN_BANK_COLUMN_GAP),q=C+7+V*(s+i.CARD_GAP);return {id:A.id,displayModel:e[A.id],key:`${f.id}::${A.id}`,x:Y,y:q,scale:d,inBank:true,compact:true}}),U={id:f.id,name:f.name,batteryIds:f.batteryIds,totalCurrent:f.totalCurrent,totalPower:f.totalPower,avgSoc:f.avgSoc,remainingCapacity:f.remainingCapacity,timeRemaining:f.timeRemaining,displayModel:r[f.id],x:0,y:g,width:i.BANK_CARD_WIDTH,height:b,batteries:O};return g+=b+i.CARD_GAP,U}),y=c.length>0?g:0,v=n?i.COMPACT_UNASSIGNED_BATTERY_SCALE:1,k=i.BATTERY_CARD_HEIGHT*v,R=a.filter(f=>!l.has(f.id)).sort((f,u)=>f.id.localeCompare(u.id)).map((f,u)=>({id:f.id,displayModel:e[f.id],key:f.id,x:0,y:y+u*(k+i.CARD_GAP),scale:v,inBank:false,compact:n})),x=c[c.length-1],h=x?x.y+x.height:0,M=R[R.length-1],T=M?M.y+k:0;return {banks:c,unassignedBatteries:R,contentHeight:Math.max(h,T)}}computeInBankBatterySlotWidth(){return (i.BANK_CARD_WIDTH-i.IN_BANK_PADDING_X*2-i.IN_BANK_COLUMN_GAP)/i.IN_BANK_COLUMNS}appendBatteryCardSkeleton(t){t.append("rect").attr("class","bms-battery").attr("rx",4).attr("ry",4),t.append("rect").attr("class","bms-battery-tip").attr("rx",1).attr("ry",1),t.append("rect").attr("class","bms-charge-fill").attr("rx",3).attr("ry",3),t.append("g").attr("class","bms-state-icon"),t.append("text").attr("class","bms-ampere"),t.append("text").attr("class","bms-volt-power");let a=t.append("text").attr("class","bms-soc");a.append("tspan").attr("class","bms-soc-value"),a.append("tspan").attr("class","bms-soc-unit"),t.append("text").attr("class","bms-actualCapacity"),t.append("text").attr("class","bms-remaining"),t.append("text").attr("class","bms-title");}renderBatteryCards(t,a,r){t.attr("transform",e=>`translate(${e.x},${e.y}) scale(${e.scale})`),t.select("rect.bms-battery").attr("width",e=>e.inBank?i.BATTERY_CARD_WIDTH:e.compact?i.BATTERY_CARD_WIDTH-i.CARD_GAP:i.BATTERY_CARD_WIDTH).attr("height",i.BATTERY_CARD_HEIGHT).attr("fill",e=>e.compact?"var(--mat-sys-background)":"var(--kip-contrast-dimmer-color)").attr("stroke","var(--kip-contrast-dimmer-color)").attr("stroke-width",0),t.select("rect.bms-battery-tip").attr("x",i.BATTERY_CARD_WIDTH).attr("y",i.BATTERY_CARD_HEIGHT/2-10).attr("width",4).attr("height",20).attr("fill",e=>e.compact?"var(--mat-sys-background)":"var(--kip-contrast-dimmer-color)").attr("stroke",a.color).attr("stroke-width",0),t.select("rect.bms-charge-fill").attr("x",1.5).attr("y",1.5).attr("width",e=>e.displayModel.chargeWidth).attr("height",i.BATTERY_CARD_HEIGHT-3).attr("fill",e=>e.compact?e.displayModel.chargeBarColorCompact:e.displayModel.chargeBarColorRegular),r?t.select("text.bms-title").attr("x",5).attr("y",e=>e.compact?11:14).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",e=>e.compact?8:12).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.displayModel.titleText):t.select("text.bms-title").text(""),t.select("text.bms-ampere").attr("x",10).attr("y",33).attr("fill",e=>e.compact?e.displayModel.currentTextColorCompact:e.displayModel.currentTextColorRegular).attr("font-size",16).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.displayModel.currentText),t.select("text.bms-volt-power").attr("x",10).attr("y",45).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",8).attr("opacity",.8).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.compact?e.displayModel.detailLineCompact:e.displayModel.detailLineRegular),t.select("text.bms-soc").attr("x",i.BATTERY_CARD_WIDTH-33).attr("y",34).attr("fill",e=>e.compact?"var(--kip-contrast-dim-color)":"var(--kip-contrast-color)").attr("text-anchor","middle").attr("font-size",25).attr("font-weight",700).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null),t.select("tspan.bms-soc-value").text(e=>this.splitMetricText(e.displayModel.socText,"%").valueText),t.select("tspan.bms-soc-unit").attr("dx",1).attr("font-size",16).attr("font-weight",500).text(e=>this.splitMetricText(e.displayModel.socText,"%").unitText),t.select("text.bms-actualCapacity").attr("x",i.BATTERY_CARD_WIDTH-33).attr("y",45).attr("fill","var(--kip-contrast-dim-color)").attr("text-anchor","middle").attr("font-size",8).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.compact?"":e.displayModel.remainingCapacityText),t.select("text.bms-remaining").attr("x",i.BATTERY_CARD_WIDTH-33).attr("y",12).attr("fill","var(--kip-contrast-dim-color)").attr("text-anchor","middle").attr("font-size",6).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.compact?"":e.displayModel.remainingTimeText),t.select("g.bms-state-icon").attr("transform",`translate(${i.BATTERY_CARD_WIDTH/2-18}, ${i.BATTERY_CARD_HEIGHT/2-18})`).attr("display",e=>e.compact&&e.scale<.45?"none":null).attr("color",e=>e.compact?a.dim:a.color).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).each((e,n,o)=>{let l=ge$1(o[n]),m=e.displayModel.iconKey,d=m==="power_renewal"?this.powerRenewalIconTemplate:this.powerAvailableIconTemplate;if(!d){l.selectAll("*").remove(),l.attr("data-icon-key",null);return}let s=l.node();if(!s||l.attr("data-icon-key")===m&&s.firstElementChild)return;l.selectAll("*").remove();let c=d.cloneNode(true);c.removeAttribute("id"),c.setAttribute("width","36"),c.setAttribute("height","36"),c.getAttribute("viewBox")||c.setAttribute("viewBox","0 0 24 24"),s.appendChild(c),l.attr("data-icon-key",m);});}formatVoltage(t){return t==null?"-- V":`${t.toFixed(1)}V`}formatCurrent(t){return t==null?"-- A":`${t.toFixed(1)}A`}formatPower(t){return t==null?"":`${t.toFixed(0)}W`}formatEnergy(t){return t==null?"":(t=this.units.convertToUnit("kWh",t),`${t}kWh`)}formatSoc(t){return t==null?"--%":`${Math.round(t*100)}%`}resolveBatteryTitleText(t){return t.name||`Battery ${t.id}`}formatDuration(t){if(t==null)return "";let a=this.units.convertToUnit("D HH:MM:SS",t);return a==null?"":typeof a=="string"?a:`${a}`}formatTemperature(t){if(t==null||typeof t!="number")return "";let a=this.units.getDefaults().Temperature,r=this.units.convertToUnit(a,t);return r===null?"":`${r.toFixed(1)} ${a==="celsius"?"\xB0C":"\xB0F"}`}splitMetricText(t,a){if(!t)return {valueText:"",unitText:""};let r=t.trim();return r?r.endsWith(a)?{valueText:r.slice(0,Math.max(0,r.length-a.length)).trim(),unitText:a}:{valueText:r,unitText:""}:{valueText:"",unitText:""}}sumNumbers(t){let a=t.filter(r=>typeof r=="number");return a.length?a.reduce((r,e)=>r+e,0):null}averageNumbers(t){let a=t.filter(r=>typeof r=="number");return a.length?a.reduce((r,e)=>r+e,0)/a.length:null}minNumber(t){let a=t.filter(r=>typeof r=="number");return a.length?Math.min(...a):null}toNumber(t){return t==null||typeof t!="number"?null:t}buildSemiGaugeArcPath(t,a){let r=Math.max(0,Math.min(1,a??0)),e=-Math.PI*.55,n=Math.PI*1.1,o=e+n*r;if(r<=0){let l=t*Math.cos(e),m=t*Math.sin(e);return `M ${l} ${m}`}return Bt()({innerRadius:t,outerRadius:t,startAngle:e,endAngle:o})??""}static \u0275fac=function(a){return new(a||i)};static \u0275cmp=JD({type:i,selectors:[["widget-bms"]],viewQuery:function(a,r){a&1&&eg(r.svgRef,ue,5),a&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:4,consts:[["bmsSvg",""],[3,"text","color"],["aria-hidden","false",1,"bms-svg"],[1,"bms-empty"],[1,"bms-empty-title"],[1,"bms-empty-sub"]],template:function(a,r){a&1&&(_w(0,pe,1,2,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,me,5,0,"div",3)),a&2&&(Mw(r.hasBanks()?0:-1),EE(),sg("bms-svg--full",!r.hasBanks()),EE(2),Mw(r.hasBatteries()?-1:3));},dependencies:[yt,x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.bms-svg[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;padding:0 10px 10px}.bms-svg.bms-svg--full[_ngcontent-%COMP%]{top:0;height:100%;padding-top:10px}.bms-card-metric[_ngcontent-%COMP%]{fill:var(--mat-sys-on-surface);font-size:30px;font-weight:700}.bms-card-sub[_ngcontent-%COMP%]{fill:var(--mat-sys-on-surface);font-size:18px;opacity:.9}.bms-card-meta[_ngcontent-%COMP%]{fill:var(--mat-sys-on-surface);font-size:15px;opacity:.75}.bms-card-footer[_ngcontent-%COMP%]{fill:var(--mat-sys-on-surface);font-size:16px;opacity:.8}.bms-flow-line[_ngcontent-%COMP%]{stroke:var(--kip-zone-nominal-color);stroke-width:3px;stroke-dasharray:6 6;animation:_ngcontent-%COMP%_flow-dash 2s linear infinite}.bms-flow-line--out[_ngcontent-%COMP%]{stroke:var(--kip-zone-warn-color)}.bms-flow-line--in[_ngcontent-%COMP%]{stroke:var(--kip-zone-nominal-color)}.bms-flow-line--neutral[_ngcontent-%COMP%]{stroke:var(--kip-widget-card-border-color);animation:none}.bms-empty[_ngcontent-%COMP%]{position:absolute;inset:0;margin:10px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;text-align:center;color:var(--mat-sys-on-surface);background:color-mix(in srgb,var(--kip-widget-card-background-color) 92%,transparent)}.bms-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.bms-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}@keyframes _ngcontent-%COMP%_flow-dash{to{stroke-dashoffset:-12}}"]})};export{ee as WidgetBmsComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {C,e as e$1}from'./chunk-CyURmwWh.js';import {g as ge$1}from'./chunk-TakPRI3t.js';import {e9 as a,d1 as Hj,w,du as p,aS as De,bu as ut,aY as xe,$ as $j,v as vt,D as Dt,F as Fa,dn as ge,a_ as Gp,cv as G,cw as z,dx as n$1,J as JD,dC as x,c as $h,cn as wd,_ as _w,B as Bh,e as EE,M as Mw,f as eg,K as Kw,P as Pi,T as TT,u as ul}from'./main-BNR44HGB.js';import {c,e}from'./chunk-D_wrJJxl.js';var ie=["alternatorSvg"];function oe(d,e){d&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No alternators detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K alternator paths or select alternators in widget settings."),ul()());}function ne(d){return d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Z=class d{static ALTERNATOR_DESCRIPTOR=a("widget-alternator");static SELF_ROOT_PATH=(()=>{let e=d.ALTERNATOR_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetAlternatorComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${d.SELF_ROOT_PATH}.*`;static PATH_REGEX=new RegExp(`^${ne(d.SELF_ROOT_PATH)}\\.([^.]+)\\.(.+)$`);static VIEWBOX_WIDTH=200;static CARD_HEIGHT=100;static COMPACT_CARD_HEIGHT=100;static CARD_GAP=8;static PATH_BATCH_WINDOW_MS=500;static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,alternator:{trackedDevices:[],optionsById:{}}};id=Hj.required();type=Hj.required();theme=Hj.required();renderMode=Hj(null);runtime=w(p);data=w(De);units=w(ut);destroyRef=w(xe);svgRef=$j.required("alternatorSvg");svg;layer;pendingPathUpdates=new Map;pathBatchTimerId=null;initialPathPaintDone=false;renderFrameId=null;pendingRenderSnapshot=null;discoveredAlternatorIds=vt([]);trackedDevices=vt([]);optionsById=vt({});cardMode=vt({displayMode:"full",metrics:["voltage","current","power","revolutions"]});alternatorsByKey=vt({});visibleAlternatorKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(i=>i.key);let r=this.alternatorsByKey(),t=new Set(this.discoveredAlternatorIds());return Object.keys(r).filter(i=>{let a=r[i];return !!a&&t.has(a.id)}).sort((i,a)=>i.localeCompare(a))});visibleAlternators=Dt(()=>{let e=this.visibleAlternatorKeys(),r=this.alternatorsByKey();return e.map(t=>r[t]).filter(t=>!!t)});hasAlternators=Dt(()=>this.visibleAlternators().length>0);activeDisplayMode=Dt(()=>this.renderMode()??this.cardMode().displayMode??"full");isCompactCardMode=Dt(()=>this.activeDisplayMode()==="compact");colorRole=Dt(()=>this.runtime.options()?.color??"contrast");ignoreZones=Dt(()=>this.runtime.options()?.ignoreZones??false);displayLabel=Dt(()=>{let e=this.visibleAlternators();return e.length!==1?"Alternators":this.resolveTitleText(e[0])});labelColor=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e).dim:"var(--kip-contrast-dim-color)"});widgetColors=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e):null});displayModels=Dt(()=>{let e$1=this.visibleAlternators(),r=this.theme(),t=this.widgetColors(),i=this.ignoreZones(),a=new Map;e$1.forEach(o=>a.set(o.id,(a.get(o.id)??0)+1));let l=new Set([...a.entries()].filter(([,o])=>o>1).map(([o])=>o)),s={};for(let o of e$1){let c=o.deviceKey??o.id,n=!!o.source&&l.has(o.id),p=this.resolveMostSevereState(o.powerState??null,o.currentState??null,o.voltageState??null,o.temperatureState??null,o.chargingModeState??null,o.revolutionsState??null,o.fieldDriveState??null,o.regulatorTemperatureState??null),T=this.resolveMostSevereState(o.voltageState??null,o.currentState??null),C=this.resolveMostSevereState(o.powerState??null,o.revolutionsState??null,o.temperatureState??null,o.regulatorTemperatureState??null),[u,I]=this.buildMetricRows(o);s[c]={id:o.id,titleText:this.resolveTitleText(o),modeText:this.isCompactCardMode()?"":this.resolveModeText(o),busText:this.isCompactCardMode()?"":n?o.source??"-":o.associatedBus||o.location||"-",metricsLineOne:u,metricsLineTwo:I,stateBarColor:e(p,t?.dim??"var(--kip-contrast-color)",r,i),titleTextColor:e(p,"var(--kip-contrast-color)",r,i),metaTextColor:e(this.resolveMostSevereState(o.chargingModeState??null,o.fieldDriveState??null),"var(--kip-contrast-dim-color)",r,i),primaryMetricsTextColor:e(T,"var(--kip-contrast-color)",r,i),secondaryMetricsTextColor:e(C,"var(--kip-contrast-color)",r,i)};}return s});constructor(){Fa(()=>{let t=this.runtime.options();t&&ge(()=>this.applyConfig(t));}),Fa(()=>{let t=this.displayModels(),i=this.visibleAlternators(),a=this.widgetColors();!this.svg||!a||this.requestRender({alternators:i,displayModels:t,widgetColors:a});});let e=[this.data.subscribePathTreeWithInitial(d.ROOT_PATTERN)],r=false;for(let t of e)if(t.initial.length){r=true;for(let i of t.initial)this.enqueuePathUpdate(i,true);}r&&(this.flushPendingPathUpdates(),this.initialPathPaintDone=true);for(let t of e)t.live$.pipe(Gp(this.destroyRef)).subscribe(i=>{this.enqueuePathUpdate(i);});}ngAfterViewInit(){this.initializeSvg(),this.requestRender();}ngOnDestroy(){this.pathBatchTimerId!==null&&(clearTimeout(this.pathBatchTimerId),this.pathBatchTimerId=null),this.renderFrameId!==null&&(cancelAnimationFrame(this.renderFrameId),this.renderFrameId=null),this.pendingRenderSnapshot=null;}initializeSvg(){this.svg=ge$1(this.svgRef().nativeElement),this.svg.attr("viewBox",`0 0 ${d.VIEWBOX_WIDTH} ${d.CARD_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","Alternator View"),this.layer=this.svg.append("g").attr("class","alternator-layer");}applyConfig(e){let r=this.resolveAlternatorConfig(e);this.trackedDevices.set(r.trackedDevices??[]),this.reprojectSnapshotsToDeviceKeys(r.trackedDevices??[]),this.optionsById.set(r.optionsById),this.cardMode.set(this.normalizeCardMode(r.cardMode));}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let r=new Map;e.forEach(t=>{let i=r.get(t.id)??[];i.push(t.key),r.set(t.id,i);}),this.alternatorsByKey.update(t=>{let i=t,a=false;return r.forEach((l,s)=>{let o=t[s];if(o){for(let c of l){if(t[c])continue;let n=e.find(p=>p.key===c);a||(i=G({},t),a=true),i[c]=z(G({},o),{source:n?.source??null,deviceKey:c});}a&&i[s]?.deviceKey===void 0&&delete i[s];}}),a?i:t});}resolveAlternatorConfig(e){let r=e.alternator,t=this.normalizeOptionsById(r?.optionsById??r?.alternatorOptionsById);return {trackedDevices:this.normalizeTrackedDevices(r?.trackedDevices),optionsById:t,cardMode:this.normalizeCardMode(r?.cardMode)}}normalizeTrackedDevices(e){if(!Array.isArray(e))return [];let r=new Map;return e.forEach(t=>{if(!t||typeof t!="object")return;let i=t,a=this.normalizeOptionalString(i.id),l=this.normalizeOptionalString(i.source);if(!a||!l)return;let s=this.normalizeOptionalString(i.key)??`${a}||${l}`;r.set(s,{id:a,source:l,key:s});}),[...r.values()].sort((t,i)=>t.key.localeCompare(i.key))}buildIdToDeviceKeysMap(){let e=new Map;return this.trackedDevices().forEach(r=>{let t=e.get(r.id)??[];t.push(r.key),e.set(r.id,t);}),e}normalizeCardMode(e){let r=e&&typeof e=="object"?e:null;if(!r)return {displayMode:"full",metrics:["voltage","current","power","revolutions"]};let t=this.normalizeStringList(r?.metrics);return {displayMode:r?.displayMode==="compact"?"compact":"full",metrics:t.length?t:["voltage","current","power","revolutions"]}}normalizeStringList(e){if(!Array.isArray(e))return [];let r=new Set;return e.forEach(t=>{if(typeof t!="string")return;let i=t.trim();i.length>0&&r.add(i);}),[...r].sort((t,i)=>t.localeCompare(i))}normalizeOptionsById(e){if(!e||typeof e!="object")return {};let r={};return Object.entries(e).forEach(([t])=>{let i=this.normalizeOptionalString(t);i&&(r[i]={});}),r}normalizeOptionalString(e){if(typeof e!="string")return null;let r=e.trim();return r.length>0?r:null}enqueuePathUpdate(e,r=false){let t=this.parsePath(e.path);if(!t)return;let i=e.update?.data?.value??null,a=e.update?.state??null,l=`${t.id}::${t.key}`;if(this.pendingPathUpdates.set(l,{id:t.id,key:t.key,value:i,state:a}),!r){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=window.setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},d.PATH_BATCH_WINDOW_MS));}}parsePath(e){let r=e.match(d.PATH_REGEX);return r?{id:r[1],key:r[2]}:null}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let e=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(e.map(i=>i.id)).forEach(i=>this.trackDiscoveredAlternator(i));let t=this.buildIdToDeviceKeysMap();this.alternatorsByKey.update(i=>{let a=i,l=false;for(let s of e){let o=t.get(s.id),c=o?.length?o:[s.id];for(let n of c){let p=!!o?.length,T=p?this.trackedDevices().find(Q=>Q.key===n):null,C=a[n]??{id:s.id,source:T?.source??null,deviceKey:p?n:void 0},u=G({},C);if(!this.applyValue(u,s.key,s.value,s.state))continue;let D=u.rawPower!=null?u.rawPower:u.voltage!=null&&u.current!=null?u.voltage*u.current:null;D!=null?u.power=Number.isFinite(D)?D:null:u.power=null,u.rawPower==null&&(u.powerState=this.resolveMostSevereState(u.voltageState??null,u.currentState??null)),l||(a=G({},a),l=true),a[n]=u;}}return l?a:i});}trackDiscoveredAlternator(e){let r=this.discoveredAlternatorIds();r.includes(e)||this.discoveredAlternatorIds.set([...r,e].sort((t,i)=>t.localeCompare(i)));}applyValue(e,r,t,i){switch(r){case "name":return this.setValue(e,"name",this.toStringValue(t));case "location":return this.setValue(e,"location",this.toStringValue(t));case "associatedBus":return this.setValue(e,"associatedBus",this.toStringValue(t));case "chargingMode":return this.setMetricValue(e,"chargingMode","chargingModeState",this.toStringValue(t),i);case "voltage":return this.setMetricValue(e,"voltage","voltageState",this.toNumber(t,"V"),i);case "current":return this.setMetricValue(e,"current","currentState",this.toNumber(t,"A"),i);case "power":case "realPower":return this.setMetricValue(e,"rawPower","powerState",this.toNumber(t,"W"),i);case "temperature":return this.setMetricValue(e,"temperature","temperatureState",this.toNumber(t,this.units.getDefaults().Temperature),i);case "revolutions":return this.setMetricValue(e,"revolutions","revolutionsState",this.toNumber(t,"Hz"),i);case "fieldDrive":return this.setMetricValue(e,"fieldDrive","fieldDriveState",this.toNumber(t,"%"),i);case "regulatorTemperature":return this.setMetricValue(e,"regulatorTemperature","regulatorTemperatureState",this.toNumber(t,this.units.getDefaults().Temperature),i);case "setpointVoltage":return this.setMetricValue(e,"setpointVoltage","setpointVoltageState",this.toNumber(t,"V"),i);case "setpointCurrent":return this.setMetricValue(e,"setpointCurrent","setpointCurrentState",this.toNumber(t,"A"),i);default:return false}}setValue(e,r,t){return Object.is(e[r],t)?false:(e[r]=t,true)}setMetricValue(e,r,t,i,a){let l=!Object.is(e[r],i),s=!Object.is(e[t],a);return !l&&!s?false:(e[r]=i,e[t]=a,true)}requestRender(e){let r=this.widgetColors();!this.svg||!r||(this.pendingRenderSnapshot=e??{alternators:this.visibleAlternators(),displayModels:this.displayModels(),widgetColors:r},this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;let t=this.pendingRenderSnapshot;this.pendingRenderSnapshot=null,t&&this.render(t);})));}render(e){if(!this.layer||!this.svg)return;let r=this.isCompactCardMode(),t=r?C:e$1,i=r?d.COMPACT_CARD_HEIGHT:d.CARD_HEIGHT,a=e.alternators.map((n,p)=>({key:n.deviceKey??n.id,alternator:n,y:p*(i+d.CARD_GAP)})),l=a.length?a[a.length-1].y+i:i;this.svg.attr("viewBox",`0 0 ${d.VIEWBOX_WIDTH} ${l}`);let s=this.layer.selectAll("g.alternator-card").data(a,n=>n.key),o=s.enter().append("g").attr("class","alternator-card");o.append("rect").attr("class","alternator-card-bg"),o.append("rect").attr("class","alternator-state-bar"),o.append("text").attr("class","alternator-title"),o.append("text").attr("class","alternator-id"),o.append("text").attr("class","alternator-mode"),o.append("text").attr("class","alternator-bus"),o.append("text").attr("class","alternator-metrics-1"),o.append("text").attr("class","alternator-metrics-2");let c=o.merge(s);c.attr("transform",n=>`translate(0, ${n.y})`),c.select("rect.alternator-card-bg").attr("x",.5).attr("y",.5).attr("rx",t.cardCornerRadius).attr("ry",t.cardCornerRadius).attr("width",d.VIEWBOX_WIDTH-1).attr("height",i-1).attr("stroke","var(--mat-sys-outline-variant)").attr("stroke-width",.5).attr("fill","none"),c.select("rect.alternator-state-bar").attr("x",1.5).attr("y",1.5).attr("rx",t.stateBarCornerRadius).attr("ry",t.stateBarCornerRadius).attr("width",3).attr("height",i-3).attr("fill",n=>e.displayModels[n.key]?.stateBarColor??e.widgetColors.dim),e.alternators.length>1?c.select("text.alternator-title").attr("x",t.titleX).attr("y",t.titleY).attr("font-size",t.titleFontSize).attr("fill",n=>e.displayModels[n.key]?.titleTextColor??"var(--kip-contrast-color)").text(n=>e.displayModels[n.key]?.titleText??this.resolveTitleText(n.alternator)):c.select("text.alternator-title").text(""),c.select("text.alternator-id").attr("x",t.idX).attr("y",t.idY).attr("text-anchor","end").attr("font-size",t.idFontSize).attr("fill","var(--kip-contrast-dim-color)").text(n=>n.alternator.id),c.select("text.alternator-mode").attr("x",t.metaLeftX).attr("y",t.metaY).attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",n=>e.displayModels[n.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(n=>e.displayModels[n.key]?.modeText??""),c.select("text.alternator-bus").attr("x",t.metaRightX).attr("y",t.metaY).attr("text-anchor","end").attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",n=>e.displayModels[n.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(n=>e.displayModels[n.key]?.busText??""),c.select("text.alternator-metrics-1").attr("x",t.lineOneX).attr("y",t.lineOneY).attr("font-size",t.lineOneFontSize).attr("fill",n=>e.displayModels[n.key]?.primaryMetricsTextColor??"var(--kip-contrast-color)").text(n=>e.displayModels[n.key]?.metricsLineOne??""),c.select("text.alternator-metrics-2").attr("x",t.lineTwoX).attr("y",t.lineTwoY).attr("font-size",t.lineTwoFontSize).attr("opacity",.85).attr("fill",n=>e.displayModels[n.key]?.secondaryMetricsTextColor??"var(--kip-contrast-color)").text(n=>e.displayModels[n.key]?.metricsLineTwo??""),s.exit().remove();}displayName(e){return e.name?.trim()||e.id}resolveTitleText(e){return e.name||`Alternator ${e.id}`}resolveModeText(e){return e.chargingMode?`Mode ${e.chargingMode}`:e.fieldDrive!=null?`Field ${e.fieldDrive.toFixed(0)} %`:"Mode -"}buildMetricRows(e){let r=this.cardMode();if(this.activeDisplayMode()==="full")return [`V ${this.formatValue(e.voltage,"V")} A ${this.formatValue(e.current,"A")}`,`P ${this.formatValue(e.power,"W")} RPM ${this.formatRevolutions(e.revolutions)}`];let t=r.metrics.map(l=>this.toMetricLabel(l,e)).filter(l=>!!l);if(!t.length)return ["V - A -","P - RPM -"];let i=t.slice(0,2).join(" "),a=t.slice(2,4).join(" ");return [i||" ",a||" "]}toMetricLabel(e,r){switch(e){case "voltage":return `V ${this.formatValue(r.voltage,"V")}`;case "current":return `A ${this.formatValue(r.current,"A")}`;case "power":return `P ${this.formatValue(r.power,"W")}`;case "temperature":return `T ${this.formatTemperature(r.temperature)}`;case "revolutions":return `RPM ${this.formatRevolutions(r.revolutions)}`;case "fieldDrive":return `FD ${this.formatPercent(r.fieldDrive)}`;case "regulatorTemperature":return `RT ${this.formatTemperature(r.regulatorTemperature)}`;default:return null}}formatValue(e,r){return e==null||Number.isNaN(e)?"-":`${e.toFixed(1)} ${r}`}formatTemperature(e){return e==null||Number.isNaN(e)?"-":`${e.toFixed(1)} ${this.units.getDefaults().Temperature==="celsius"?"\xB0C":"\xB0F"}`}formatRevolutions(e){return e==null||Number.isNaN(e)?"-":Math.round(e*60).toString()}formatPercent(e){return e==null||Number.isNaN(e)?"-":`${e.toFixed(0)} %`}toStringValue(e){return typeof e=="string"?e:null}resolveMostSevereState(...e){return e.some(r=>r===n$1.Alert)?n$1.Alert:e.some(r=>r===n$1.Alarm)?n$1.Alarm:e.some(r=>r===n$1.Warn)?n$1.Warn:e.some(r=>r===n$1.Normal)?n$1.Normal:null}toNumber(e,r){if(e==null||typeof e=="boolean")return null;let t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return null;let i=this.units.convertToUnit(r,t);return Number.isFinite(i)?i:t}static \u0275fac=function(r){return new(r||d)};static \u0275cmp=JD({type:d,selectors:[["widget-alternator"]],viewQuery:function(r,t){r&1&&eg(t.svgRef,ie,5),r&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["alternatorSvg",""],[3,"text","color"],["aria-hidden","false",1,"alternator-svg"],[1,"alternator-empty"],[1,"alternator-empty-title"],[1,"alternator-empty-sub"]],template:function(r,t){r&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,oe,5,0,"div",3)),r&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasAlternators()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.alternator-svg[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;z-index:20;padding:0 10px 10px}.alternator-empty[_ngcontent-%COMP%]{position:absolute;inset:0;margin:10px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;text-align:center;color:var(--mat-sys-on-surface);background:color-mix(in srgb,var(--kip-widget-card-background-color) 92%,transparent)}.alternator-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.alternator-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{Z as WidgetAlternatorComponent};
|