0&&e.stroke()}_updateAnimationTarget(t){let e=this.chart,s=this.$animations,n=s&&s.x,o=s&&s.y;if(n||o){let a=ks[t.position].call(this,this._active,this._eventPosition);if(!a)return;let l=this._size=Ta(this,t),d=Object.assign({},a,this._size),g=Da(e,t,d),y=Aa(t,d,g,e);n._to===y.x&&o._to===y.y||(this.xAlign=g.xAlign,this.yAlign=g.yAlign,this.width=l.width,this.height=l.height,this.caretX=a.x,this.caretY=a.y,this._resolveAnimations().update(this,y))}}_willRender(){return!!this.opacity}draw(t){let e=this.options.setContext(this.getContext()),s=this.opacity;if(!s)return;this._updateAnimationTarget(e);let n={width:this.width,height:this.height},o={x:this.x,y:this.y};s=Math.abs(s)<.001?0:s;let a=Kt(e.padding),l=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&l&&(t.save(),t.globalAlpha=s,this.drawBackground(o,t,n,e),oo(t,e.textDirection),o.y+=a.top,this.drawTitle(o,t,e),this.drawBody(o,t,e),this.drawFooter(o,t,e),ro(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){let s=this._active,n=t.map(({datasetIndex:l,index:d})=>{let g=this.chart.getDatasetMeta(l);if(!g)throw new Error("Cannot find a dataset at index "+l);return{datasetIndex:l,element:g.data[d],index:d}}),o=!ft(s,n),a=this._positionChanged(n,e);(o||a)&&(this._active=n,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,s=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let n=this.options,o=this._active||[],a=this._getActiveElements(t,o,e,s),l=this._positionChanged(a,t),d=e||!ft(a,o)||l;return d&&(this._active=a,(n.enabled||n.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),d}_getActiveElements(t,e,s,n){let o=this.options;if(t.type==="mouseout")return[];if(!n)return e.filter(l=>this.chart.data.datasets[l.datasetIndex]&&this.chart.getDatasetMeta(l.datasetIndex).controller.getParsed(l.index)!==void 0);let a=this.chart.getElementsAtEventForMode(t,o.mode,o,s);return o.reverse&&a.reverse(),a}_positionChanged(t,e){let{caretX:s,caretY:n,options:o}=this,a=ks[o.position].call(this,t,e);return a!==!1&&(s!==a.x||n!==a.y)}}var Dh={id:"tooltip",_element:La,positioners:ks,afterInit(i,t,e){e&&(i.tooltip=new La({chart:i,options:e}))},beforeUpdate(i,t,e){i.tooltip&&i.tooltip.initialize(e)},reset(i,t,e){i.tooltip&&i.tooltip.initialize(e)},afterDraw(i){let t=i.tooltip;if(t&&t._willRender()){let e={tooltip:t};if(i.notifyPlugins("beforeTooltipDraw",{...e,cancelable:!0})===!1)return;t.draw(i.ctx),i.notifyPlugins("afterTooltipDraw",e)}},afterEvent(i,t){if(i.tooltip){let e=t.replay;i.tooltip.handleEvent(t.event,e,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(i,t)=>t.bodyFont.size,boxWidth:(i,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:Oa},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:i=>i!=="filter"&&i!=="itemSort"&&i!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};return Wt.register(Xr,da,So,_),Wt.helpers={...xl},Wt._adapters=Wr,Wt.Animation=yr,Wt.Animations=po,Wt.animator=ve,Wt.controllers=Pe.controllers.items,Wt.DatasetController=qe,Wt.Element=Be,Wt.elements=So,Wt.Interaction=sr,Wt.layouts=Qt,Wt.platforms=mr,Wt.Scale=oi,Wt.Ticks=fi,Object.assign(Wt,Xr,da,So,_,mr),Wt.Chart=Wt,typeof window<"u"&&(window.Chart=Wt),Wt});(function(_,h){typeof exports=="object"&&typeof module<"u"?h(Ah("chart.js")):typeof define=="function"&&define.amd?define(["chart.js"],h):h((_=typeof globalThis<"u"?globalThis:_||self).Chart)})(void 0,function(_){"use strict";function h(p){if(p===null||p===!0||p===!1)return NaN;var x=Number(p);return isNaN(x)?x:x<0?Math.ceil(x):Math.floor(x)}function u(p,x){if(x.length1?"s":"")+" required, but only "+x.length+" present")}function k(p){u(1,arguments);var x=Object.prototype.toString.call(p);return p instanceof Date||typeof p=="object"&&x==="[object Date]"?new Date(p.getTime()):typeof p=="number"||x==="[object Number]"?new Date(p):(typeof p!="string"&&x!=="[object String]"||typeof console>"u"||(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"),console.warn(new Error().stack)),new Date(NaN))}function P(p,x){u(2,arguments);var m=k(p),S=h(x);return isNaN(S)?new Date(NaN):(S&&m.setDate(m.getDate()+S),m)}function z(p,x){u(2,arguments);var m=k(p),S=h(x);if(isNaN(S))return new Date(NaN);if(!S)return m;var A=m.getDate(),F=new Date(m.getTime());F.setMonth(m.getMonth()+S+1,0);var q=F.getDate();return A>=q?F:(m.setFullYear(F.getFullYear(),F.getMonth(),A),m)}function L(p,x){u(2,arguments);var m=k(p).getTime(),S=h(x);return new Date(m+S)}var G=36e5;function U(p,x){u(1,arguments);var m=x||{},S=m.locale,A=S&&S.options&&S.options.weekStartsOn,F=A==null?0:h(A),q=m.weekStartsOn==null?F:h(m.weekStartsOn);if(!(q>=0&&q<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var Q=k(p),st=Q.getDay(),mt=(st0?1:A}function bt(p){u(1,arguments);var x=k(p);return!isNaN(x)}function Tt(p,x){u(2,arguments);var m=k(p),S=k(x),A=m.getFullYear()-S.getFullYear(),F=m.getMonth()-S.getMonth();return 12*A+F}function Dt(p,x){u(2,arguments);var m=k(p),S=k(x);return m.getFullYear()-S.getFullYear()}function kt(p,x){var m=p.getFullYear()-x.getFullYear()||p.getMonth()-x.getMonth()||p.getDate()-x.getDate()||p.getHours()-x.getHours()||p.getMinutes()-x.getMinutes()||p.getSeconds()-x.getSeconds()||p.getMilliseconds()-x.getMilliseconds();return m<0?-1:m>0?1:m}function $t(p,x){u(2,arguments);var m=k(p),S=k(x),A=kt(m,S),F=Math.abs(it(m,S));m.setDate(m.getDate()-A*F);var q=kt(m,S)===-A,Q=A*(F-q);return Q===0?0:Q}function zt(p,x){u(2,arguments);var m=k(p),S=k(x);return m.getTime()-S.getTime()}var te=36e5;function De(p){u(1,arguments);var x=k(p);return x.setHours(23,59,59,999),x}function vt(p){u(1,arguments);var x=k(p),m=x.getMonth();return x.setFullYear(x.getFullYear(),m+1,0),x.setHours(23,59,59,999),x}function At(p){u(1,arguments);var x=k(p);return De(x).getTime()===vt(x).getTime()}function pt(p,x){u(2,arguments);var m,S=k(p),A=k(x),F=ft(S,A),q=Math.abs(Tt(S,A));if(q<1)m=0;else{S.getMonth()===1&&S.getDate()>27&&S.setDate(30),S.setMonth(S.getMonth()-F*q);var Q=ft(S,A)===-F;At(k(p))&&q===1&&ft(p,A)===1&&(Q=!1),m=F*(q-Q)}return m===0?0:m}var J={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function r(p){return function(x){var m=x||{},S=m.width?String(m.width):p.defaultWidth;return p.formats[S]||p.formats[p.defaultWidth]}}var c={date:r({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:r({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:r({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},b={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function w(p){return function(x,m){var S,A=m||{};if((A.context?String(A.context):"standalone")==="formatting"&&p.formattingValues){var F=p.defaultFormattingWidth||p.defaultWidth,q=A.width?String(A.width):F;S=p.formattingValues[q]||p.formattingValues[F]}else{var Q=p.defaultWidth,st=A.width?String(A.width):p.defaultWidth;S=p.values[st]||p.values[Q]}return S[p.argumentCallback?p.argumentCallback(x):x]}}function E(p){return function(x,m){var S=String(x),A=m||{},F=A.width,q=F&&p.matchPatterns[F]||p.matchPatterns[p.defaultMatchWidth],Q=S.match(q);if(!Q)return null;var st,mt=Q[0],xt=F&&p.parsePatterns[F]||p.parsePatterns[p.defaultParseWidth];return st=Object.prototype.toString.call(xt)==="[object Array]"?function(wt,Pt){for(var Mt=0;Mt0?"in "+S:S+" ago":S},formatLong:c,formatRelative:function(p,x,m,S){return b[p]},localize:{ordinalNumber:function(p,x){var m=Number(p),S=m%100;if(S>20||S<10)switch(S%10){case 1:return m+"st";case 2:return m+"nd";case 3:return m+"rd"}return m+"th"},era:w({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:w({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:function(p){return Number(p)-1}}),month:w({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:w({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:w({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},match:{ordinalNumber:(O={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:function(p){return parseInt(p,10)}},function(p,x){var m=String(p),S=x||{},A=m.match(O.matchPattern);if(!A)return null;var F=A[0],q=m.match(O.parsePattern);if(!q)return null;var Q=O.valueCallback?O.valueCallback(q[0]):q[0];return{value:Q=S.valueCallback?S.valueCallback(Q):Q,rest:m.slice(F.length)}}),era:E({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:E({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:function(p){return p+1}}),month:E({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:E({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:E({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},options:{weekStartsOn:0,firstWeekContainsDate:1}};function V(p,x){u(2,arguments);var m=h(x);return L(p,-m)}function B(p,x){for(var m=p<0?"-":"",S=Math.abs(p).toString();S.length0?m:1-m;return B(x==="yy"?S%100:S,x.length)},M:function(p,x){var m=p.getUTCMonth();return x==="M"?String(m+1):B(m+1,2)},d:function(p,x){return B(p.getUTCDate(),x.length)},a:function(p,x){var m=p.getUTCHours()/12>=1?"pm":"am";switch(x){case"a":case"aa":return m.toUpperCase();case"aaa":return m;case"aaaaa":return m[0];default:return m==="am"?"a.m.":"p.m."}},h:function(p,x){return B(p.getUTCHours()%12||12,x.length)},H:function(p,x){return B(p.getUTCHours(),x.length)},m:function(p,x){return B(p.getUTCMinutes(),x.length)},s:function(p,x){return B(p.getUTCSeconds(),x.length)},S:function(p,x){var m=x.length,S=p.getUTCMilliseconds();return B(Math.floor(S*Math.pow(10,m-3)),x.length)}},tt=864e5;function ot(p){u(1,arguments);var x=1,m=k(p),S=m.getUTCDay(),A=(S=A.getTime()?m+1:x.getTime()>=q.getTime()?m:m-1}function ne(p){u(1,arguments);var x=_t(p),m=new Date(0);m.setUTCFullYear(x,0,4),m.setUTCHours(0,0,0,0);var S=ot(m);return S}var Ue=6048e5;function Xt(p){u(1,arguments);var x=k(p),m=ot(x).getTime()-ne(x).getTime();return Math.round(m/Ue)+1}function ae(p,x){u(1,arguments);var m=x||{},S=m.locale,A=S&&S.options&&S.options.weekStartsOn,F=A==null?0:h(A),q=m.weekStartsOn==null?F:h(m.weekStartsOn);if(!(q>=0&&q<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var Q=k(p),st=Q.getUTCDay(),mt=(st=1&&st<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var mt=new Date(0);mt.setUTCFullYear(S+1,0,st),mt.setUTCHours(0,0,0,0);var xt=ae(mt,x),wt=new Date(0);wt.setUTCFullYear(S,0,st),wt.setUTCHours(0,0,0,0);var Pt=ae(wt,x);return m.getTime()>=xt.getTime()?S+1:m.getTime()>=Pt.getTime()?S:S-1}function ee(p,x){u(1,arguments);var m=x||{},S=m.locale,A=S&&S.options&&S.options.firstWeekContainsDate,F=A==null?1:h(A),q=m.firstWeekContainsDate==null?F:h(m.firstWeekContainsDate),Q=We(p,x),st=new Date(0);st.setUTCFullYear(Q,0,q),st.setUTCHours(0,0,0,0);var mt=ae(st,x);return mt}var $e=6048e5;function He(p,x){u(1,arguments);var m=k(p),S=ae(m,x).getTime()-ee(m,x).getTime();return Math.round(S/$e)+1}var ji="midnight",Ti="noon",Ls="morning",ie="afternoon",Ke="evening",Ut="night",zs={G:function(p,x,m){var S=p.getUTCFullYear()>0?1:0;switch(x){case"G":case"GG":case"GGG":return m.era(S,{width:"abbreviated"});case"GGGGG":return m.era(S,{width:"narrow"});default:return m.era(S,{width:"wide"})}},y:function(p,x,m){if(x==="yo"){var S=p.getUTCFullYear(),A=S>0?S:1-S;return m.ordinalNumber(A,{unit:"year"})}return W.y(p,x)},Y:function(p,x,m,S){var A=We(p,S),F=A>0?A:1-A;return x==="YY"?B(F%100,2):x==="Yo"?m.ordinalNumber(F,{unit:"year"}):B(F,x.length)},R:function(p,x){return B(_t(p),x.length)},u:function(p,x){return B(p.getUTCFullYear(),x.length)},Q:function(p,x,m){var S=Math.ceil((p.getUTCMonth()+1)/3);switch(x){case"Q":return String(S);case"QQ":return B(S,2);case"Qo":return m.ordinalNumber(S,{unit:"quarter"});case"QQQ":return m.quarter(S,{width:"abbreviated",context:"formatting"});case"QQQQQ":return m.quarter(S,{width:"narrow",context:"formatting"});default:return m.quarter(S,{width:"wide",context:"formatting"})}},q:function(p,x,m){var S=Math.ceil((p.getUTCMonth()+1)/3);switch(x){case"q":return String(S);case"qq":return B(S,2);case"qo":return m.ordinalNumber(S,{unit:"quarter"});case"qqq":return m.quarter(S,{width:"abbreviated",context:"standalone"});case"qqqqq":return m.quarter(S,{width:"narrow",context:"standalone"});default:return m.quarter(S,{width:"wide",context:"standalone"})}},M:function(p,x,m){var S=p.getUTCMonth();switch(x){case"M":case"MM":return W.M(p,x);case"Mo":return m.ordinalNumber(S+1,{unit:"month"});case"MMM":return m.month(S,{width:"abbreviated",context:"formatting"});case"MMMMM":return m.month(S,{width:"narrow",context:"formatting"});default:return m.month(S,{width:"wide",context:"formatting"})}},L:function(p,x,m){var S=p.getUTCMonth();switch(x){case"L":return String(S+1);case"LL":return B(S+1,2);case"Lo":return m.ordinalNumber(S+1,{unit:"month"});case"LLL":return m.month(S,{width:"abbreviated",context:"standalone"});case"LLLLL":return m.month(S,{width:"narrow",context:"standalone"});default:return m.month(S,{width:"wide",context:"standalone"})}},w:function(p,x,m,S){var A=He(p,S);return x==="wo"?m.ordinalNumber(A,{unit:"week"}):B(A,x.length)},I:function(p,x,m){var S=Xt(p);return x==="Io"?m.ordinalNumber(S,{unit:"week"}):B(S,x.length)},d:function(p,x,m){return x==="do"?m.ordinalNumber(p.getUTCDate(),{unit:"date"}):W.d(p,x)},D:function(p,x,m){var S=function(A){u(1,arguments);var F=k(A),q=F.getTime();F.setUTCMonth(0,1),F.setUTCHours(0,0,0,0);var Q=F.getTime(),st=q-Q;return Math.floor(st/tt)+1}(p);return x==="Do"?m.ordinalNumber(S,{unit:"dayOfYear"}):B(S,x.length)},E:function(p,x,m){var S=p.getUTCDay();switch(x){case"E":case"EE":case"EEE":return m.day(S,{width:"abbreviated",context:"formatting"});case"EEEEE":return m.day(S,{width:"narrow",context:"formatting"});case"EEEEEE":return m.day(S,{width:"short",context:"formatting"});default:return m.day(S,{width:"wide",context:"formatting"})}},e:function(p,x,m,S){var A=p.getUTCDay(),F=(A-S.weekStartsOn+8)%7||7;switch(x){case"e":return String(F);case"ee":return B(F,2);case"eo":return m.ordinalNumber(F,{unit:"day"});case"eee":return m.day(A,{width:"abbreviated",context:"formatting"});case"eeeee":return m.day(A,{width:"narrow",context:"formatting"});case"eeeeee":return m.day(A,{width:"short",context:"formatting"});default:return m.day(A,{width:"wide",context:"formatting"})}},c:function(p,x,m,S){var A=p.getUTCDay(),F=(A-S.weekStartsOn+8)%7||7;switch(x){case"c":return String(F);case"cc":return B(F,x.length);case"co":return m.ordinalNumber(F,{unit:"day"});case"ccc":return m.day(A,{width:"abbreviated",context:"standalone"});case"ccccc":return m.day(A,{width:"narrow",context:"standalone"});case"cccccc":return m.day(A,{width:"short",context:"standalone"});default:return m.day(A,{width:"wide",context:"standalone"})}},i:function(p,x,m){var S=p.getUTCDay(),A=S===0?7:S;switch(x){case"i":return String(A);case"ii":return B(A,x.length);case"io":return m.ordinalNumber(A,{unit:"day"});case"iii":return m.day(S,{width:"abbreviated",context:"formatting"});case"iiiii":return m.day(S,{width:"narrow",context:"formatting"});case"iiiiii":return m.day(S,{width:"short",context:"formatting"});default:return m.day(S,{width:"wide",context:"formatting"})}},a:function(p,x,m){var S=p.getUTCHours()/12>=1?"pm":"am";switch(x){case"a":case"aa":return m.dayPeriod(S,{width:"abbreviated",context:"formatting"});case"aaa":return m.dayPeriod(S,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return m.dayPeriod(S,{width:"narrow",context:"formatting"});default:return m.dayPeriod(S,{width:"wide",context:"formatting"})}},b:function(p,x,m){var S,A=p.getUTCHours();switch(S=A===12?Ti:A===0?ji:A/12>=1?"pm":"am",x){case"b":case"bb":return m.dayPeriod(S,{width:"abbreviated",context:"formatting"});case"bbb":return m.dayPeriod(S,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return m.dayPeriod(S,{width:"narrow",context:"formatting"});default:return m.dayPeriod(S,{width:"wide",context:"formatting"})}},B:function(p,x,m){var S,A=p.getUTCHours();switch(S=A>=17?Ke:A>=12?ie:A>=4?Ls:Ut,x){case"B":case"BB":case"BBB":return m.dayPeriod(S,{width:"abbreviated",context:"formatting"});case"BBBBB":return m.dayPeriod(S,{width:"narrow",context:"formatting"});default:return m.dayPeriod(S,{width:"wide",context:"formatting"})}},h:function(p,x,m){if(x==="ho"){var S=p.getUTCHours()%12;return S===0&&(S=12),m.ordinalNumber(S,{unit:"hour"})}return W.h(p,x)},H:function(p,x,m){return x==="Ho"?m.ordinalNumber(p.getUTCHours(),{unit:"hour"}):W.H(p,x)},K:function(p,x,m){var S=p.getUTCHours()%12;return x==="Ko"?m.ordinalNumber(S,{unit:"hour"}):B(S,x.length)},k:function(p,x,m){var S=p.getUTCHours();return S===0&&(S=24),x==="ko"?m.ordinalNumber(S,{unit:"hour"}):B(S,x.length)},m:function(p,x,m){return x==="mo"?m.ordinalNumber(p.getUTCMinutes(),{unit:"minute"}):W.m(p,x)},s:function(p,x,m){return x==="so"?m.ordinalNumber(p.getUTCSeconds(),{unit:"second"}):W.s(p,x)},S:function(p,x){return W.S(p,x)},X:function(p,x,m,S){var A=(S._originalDate||p).getTimezoneOffset();if(A===0)return"Z";switch(x){case"X":return ci(A);case"XXXX":case"XX":return Yt(A);default:return Yt(A,":")}},x:function(p,x,m,S){var A=(S._originalDate||p).getTimezoneOffset();switch(x){case"x":return ci(A);case"xxxx":case"xx":return Yt(A);default:return Yt(A,":")}},O:function(p,x,m,S){var A=(S._originalDate||p).getTimezoneOffset();switch(x){case"O":case"OO":case"OOO":return"GMT"+fe(A,":");default:return"GMT"+Yt(A,":")}},z:function(p,x,m,S){var A=(S._originalDate||p).getTimezoneOffset();switch(x){case"z":case"zz":case"zzz":return"GMT"+fe(A,":");default:return"GMT"+Yt(A,":")}},t:function(p,x,m,S){var A=S._originalDate||p;return B(Math.floor(A.getTime()/1e3),x.length)},T:function(p,x,m,S){return B((S._originalDate||p).getTime(),x.length)}};function fe(p,x){var m=p>0?"-":"+",S=Math.abs(p),A=Math.floor(S/60),F=S%60;if(F===0)return m+String(A);var q=x||"";return m+String(A)+q+B(F,2)}function ci(p,x){return p%60==0?(p>0?"-":"+")+B(Math.abs(p)/60,2):Yt(p,x)}function Yt(p,x){var m=x||"",S=p>0?"-":"+",A=Math.abs(p);return S+B(Math.floor(A/60),2)+m+B(A%60,2)}var $s=zs;function Yi(p,x){switch(p){case"P":return x.date({width:"short"});case"PP":return x.date({width:"medium"});case"PPP":return x.date({width:"long"});default:return x.date({width:"full"})}}function Gi(p,x){switch(p){case"p":return x.time({width:"short"});case"pp":return x.time({width:"medium"});case"ppp":return x.time({width:"long"});default:return x.time({width:"full"})}}var Hs={p:Gi,P:function(p,x){var m,S=p.match(/(P+)(p+)?/),A=S[1],F=S[2];if(!F)return Yi(p,x);switch(A){case"P":m=x.dateTime({width:"short"});break;case"PP":m=x.dateTime({width:"medium"});break;case"PPP":m=x.dateTime({width:"long"});break;default:m=x.dateTime({width:"full"})}return m.replace("{{date}}",Yi(A,x)).replace("{{time}}",Gi(F,x))}},Di=Hs,qi=["D","DD"],Xi=["YY","YYYY"];function Ai(p){return qi.indexOf(p)!==-1}function Zi(p){return Xi.indexOf(p)!==-1}function Ve(p,x,m){if(p==="YYYY")throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(x,"`) for formatting years to the input `").concat(m,"`; see: https://git.io/fxCyr"));if(p==="YY")throw new RangeError("Use `yy` instead of `YY` (in `".concat(x,"`) for formatting years to the input `").concat(m,"`; see: https://git.io/fxCyr"));if(p==="D")throw new RangeError("Use `d` instead of `D` (in `".concat(x,"`) for formatting days of the month to the input `").concat(m,"`; see: https://git.io/fxCyr"));if(p==="DD")throw new RangeError("Use `dd` instead of `DD` (in `".concat(x,"`) for formatting days of the month to the input `").concat(m,"`; see: https://git.io/fxCyr"))}var jt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Ns=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Ki=/^'([^]*?)'?$/,Qi=/''/g,Yn=/[a-zA-Z]/;function ve(p){return p.match(Ki)[1].replace(Qi,"'")}function di(p,x){if(p==null)throw new TypeError("assign requires that input parameter not be null or undefined");for(var m in x=x||{})x.hasOwnProperty(m)&&(p[m]=x[m]);return p}function we(p,x,m){u(2,arguments);var S=m||{},A=S.locale,F=A&&A.options&&A.options.weekStartsOn,q=F==null?0:h(F),Q=S.weekStartsOn==null?q:h(S.weekStartsOn);if(!(Q>=0&&Q<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var st=k(p),mt=h(x),xt=st.getUTCDay(),wt=mt%7,Pt=(wt+7)%7,Mt=(Pt0,A=S?x:1-x;if(A<=50)m=p||100;else{var F=A+50;m=p+100*Math.floor(F/100)-(p>=F%100?100:0)}return S?m:1-m}var Ri=[31,28,31,30,31,30,31,31,30,31,30,31],ls=[31,29,31,30,31,30,31,31,30,31,30,31];function pi(p){return p%400==0||p%4==0&&p%100!=0}var to={G:{priority:140,parse:function(p,x,m,S){switch(x){case"G":case"GG":case"GGG":return m.era(p,{width:"abbreviated"})||m.era(p,{width:"narrow"});case"GGGGG":return m.era(p,{width:"narrow"});default:return m.era(p,{width:"wide"})||m.era(p,{width:"abbreviated"})||m.era(p,{width:"narrow"})}},set:function(p,x,m,S){return x.era=m,p.setUTCFullYear(m,0,1),p.setUTCHours(0,0,0,0),p},incompatibleTokens:["R","u","t","T"]},y:{priority:130,parse:function(p,x,m,S){var A=function(F){return{year:F,isTwoDigitYear:x==="yy"}};switch(x){case"y":return Ht(4,p,A);case"yo":return m.ordinalNumber(p,{unit:"year",valueCallback:A});default:return Ht(x.length,p,A)}},validate:function(p,x,m){return x.isTwoDigitYear||x.year>0},set:function(p,x,m,S){var A=p.getUTCFullYear();if(m.isTwoDigitYear){var F=Je(m.year,A);return p.setUTCFullYear(F,0,1),p.setUTCHours(0,0,0,0),p}var q="era"in x&&x.era!==1?1-m.year:m.year;return p.setUTCFullYear(q,0,1),p.setUTCHours(0,0,0,0),p},incompatibleTokens:["Y","R","u","w","I","i","e","c","t","T"]},Y:{priority:130,parse:function(p,x,m,S){var A=function(F){return{year:F,isTwoDigitYear:x==="YY"}};switch(x){case"Y":return Ht(4,p,A);case"Yo":return m.ordinalNumber(p,{unit:"year",valueCallback:A});default:return Ht(x.length,p,A)}},validate:function(p,x,m){return x.isTwoDigitYear||x.year>0},set:function(p,x,m,S){var A=We(p,S);if(m.isTwoDigitYear){var F=Je(m.year,A);return p.setUTCFullYear(F,0,S.firstWeekContainsDate),p.setUTCHours(0,0,0,0),ae(p,S)}var q="era"in x&&x.era!==1?1-m.year:m.year;return p.setUTCFullYear(q,0,S.firstWeekContainsDate),p.setUTCHours(0,0,0,0),ae(p,S)},incompatibleTokens:["y","R","u","Q","q","M","L","I","d","D","i","t","T"]},R:{priority:130,parse:function(p,x,m,S){return rs(x==="R"?4:x.length,p)},set:function(p,x,m,S){var A=new Date(0);return A.setUTCFullYear(m,0,4),A.setUTCHours(0,0,0,0),ot(A)},incompatibleTokens:["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"]},u:{priority:130,parse:function(p,x,m,S){return rs(x==="u"?4:x.length,p)},set:function(p,x,m,S){return p.setUTCFullYear(m,0,1),p.setUTCHours(0,0,0,0),p},incompatibleTokens:["G","y","Y","R","w","I","i","e","c","t","T"]},Q:{priority:120,parse:function(p,x,m,S){switch(x){case"Q":case"QQ":return Ht(x.length,p);case"Qo":return m.ordinalNumber(p,{unit:"quarter"});case"QQQ":return m.quarter(p,{width:"abbreviated",context:"formatting"})||m.quarter(p,{width:"narrow",context:"formatting"});case"QQQQQ":return m.quarter(p,{width:"narrow",context:"formatting"});default:return m.quarter(p,{width:"wide",context:"formatting"})||m.quarter(p,{width:"abbreviated",context:"formatting"})||m.quarter(p,{width:"narrow",context:"formatting"})}},validate:function(p,x,m){return x>=1&&x<=4},set:function(p,x,m,S){return p.setUTCMonth(3*(m-1),1),p.setUTCHours(0,0,0,0),p},incompatibleTokens:["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"]},q:{priority:120,parse:function(p,x,m,S){switch(x){case"q":case"qq":return Ht(x.length,p);case"qo":return m.ordinalNumber(p,{unit:"quarter"});case"qqq":return m.quarter(p,{width:"abbreviated",context:"standalone"})||m.quarter(p,{width:"narrow",context:"standalone"});case"qqqqq":return m.quarter(p,{width:"narrow",context:"standalone"});default:return m.quarter(p,{width:"wide",context:"standalone"})||m.quarter(p,{width:"abbreviated",context:"standalone"})||m.quarter(p,{width:"narrow",context:"standalone"})}},validate:function(p,x,m){return x>=1&&x<=4},set:function(p,x,m,S){return p.setUTCMonth(3*(m-1),1),p.setUTCHours(0,0,0,0),p},incompatibleTokens:["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"]},M:{priority:110,parse:function(p,x,m,S){var A=function(F){return F-1};switch(x){case"M":return Ot(Qe,p,A);case"MM":return Ht(2,p,A);case"Mo":return m.ordinalNumber(p,{unit:"month",valueCallback:A});case"MMM":return m.month(p,{width:"abbreviated",context:"formatting"})||m.month(p,{width:"narrow",context:"formatting"});case"MMMMM":return m.month(p,{width:"narrow",context:"formatting"});default:return m.month(p,{width:"wide",context:"formatting"})||m.month(p,{width:"abbreviated",context:"formatting"})||m.month(p,{width:"narrow",context:"formatting"})}},validate:function(p,x,m){return x>=0&&x<=11},set:function(p,x,m,S){return p.setUTCMonth(m,1),p.setUTCHours(0,0,0,0),p},incompatibleTokens:["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]},L:{priority:110,parse:function(p,x,m,S){var A=function(F){return F-1};switch(x){case"L":return Ot(Qe,p,A);case"LL":return Ht(2,p,A);case"Lo":return m.ordinalNumber(p,{unit:"month",valueCallback:A});case"LLL":return m.month(p,{width:"abbreviated",context:"standalone"})||m.month(p,{width:"narrow",context:"standalone"});case"LLLLL":return m.month(p,{width:"narrow",context:"standalone"});default:return m.month(p,{width:"wide",context:"standalone"})||m.month(p,{width:"abbreviated",context:"standalone"})||m.month(p,{width:"narrow",context:"standalone"})}},validate:function(p,x,m){return x>=0&&x<=11},set:function(p,x,m,S){return p.setUTCMonth(m,1),p.setUTCHours(0,0,0,0),p},incompatibleTokens:["Y","R","q","Q","M","w","I","D","i","e","c","t","T"]},w:{priority:100,parse:function(p,x,m,S){switch(x){case"w":return Ot(Ji,p);case"wo":return m.ordinalNumber(p,{unit:"week"});default:return Ht(x.length,p)}},validate:function(p,x,m){return x>=1&&x<=53},set:function(p,x,m,S){return ae(function(A,F,q){u(2,arguments);var Q=k(A),st=h(F),mt=He(Q,q)-st;return Q.setUTCDate(Q.getUTCDate()-7*mt),Q}(p,m,S),S)},incompatibleTokens:["y","R","u","q","Q","M","L","I","d","D","i","t","T"]},I:{priority:100,parse:function(p,x,m,S){switch(x){case"I":return Ot(Ji,p);case"Io":return m.ordinalNumber(p,{unit:"week"});default:return Ht(x.length,p)}},validate:function(p,x,m){return x>=1&&x<=53},set:function(p,x,m,S){return ot(function(A,F){u(2,arguments);var q=k(A),Q=h(F),st=Xt(q)-Q;return q.setUTCDate(q.getUTCDate()-7*st),q}(p,m,S),S)},incompatibleTokens:["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"]},d:{priority:90,subPriority:1,parse:function(p,x,m,S){switch(x){case"d":return Ot(Ne,p);case"do":return m.ordinalNumber(p,{unit:"date"});default:return Ht(x.length,p)}},validate:function(p,x,m){var S=pi(p.getUTCFullYear()),A=p.getUTCMonth();return S?x>=1&&x<=ls[A]:x>=1&&x<=Ri[A]},set:function(p,x,m,S){return p.setUTCDate(m),p.setUTCHours(0,0,0,0),p},incompatibleTokens:["Y","R","q","Q","w","I","D","i","e","c","t","T"]},D:{priority:90,subPriority:1,parse:function(p,x,m,S){switch(x){case"D":case"DD":return Ot(Ae,p);case"Do":return m.ordinalNumber(p,{unit:"date"});default:return Ht(x.length,p)}},validate:function(p,x,m){return pi(p.getUTCFullYear())?x>=1&&x<=366:x>=1&&x<=365},set:function(p,x,m,S){return p.setUTCMonth(0,m),p.setUTCHours(0,0,0,0),p},incompatibleTokens:["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"]},E:{priority:90,parse:function(p,x,m,S){switch(x){case"E":case"EE":case"EEE":return m.day(p,{width:"abbreviated",context:"formatting"})||m.day(p,{width:"short",context:"formatting"})||m.day(p,{width:"narrow",context:"formatting"});case"EEEEE":return m.day(p,{width:"narrow",context:"formatting"});case"EEEEEE":return m.day(p,{width:"short",context:"formatting"})||m.day(p,{width:"narrow",context:"formatting"});default:return m.day(p,{width:"wide",context:"formatting"})||m.day(p,{width:"abbreviated",context:"formatting"})||m.day(p,{width:"short",context:"formatting"})||m.day(p,{width:"narrow",context:"formatting"})}},validate:function(p,x,m){return x>=0&&x<=6},set:function(p,x,m,S){return(p=we(p,m,S)).setUTCHours(0,0,0,0),p},incompatibleTokens:["D","i","e","c","t","T"]},e:{priority:90,parse:function(p,x,m,S){var A=function(F){var q=7*Math.floor((F-1)/7);return(F+S.weekStartsOn+6)%7+q};switch(x){case"e":case"ee":return Ht(x.length,p,A);case"eo":return m.ordinalNumber(p,{unit:"day",valueCallback:A});case"eee":return m.day(p,{width:"abbreviated",context:"formatting"})||m.day(p,{width:"short",context:"formatting"})||m.day(p,{width:"narrow",context:"formatting"});case"eeeee":return m.day(p,{width:"narrow",context:"formatting"});case"eeeeee":return m.day(p,{width:"short",context:"formatting"})||m.day(p,{width:"narrow",context:"formatting"});default:return m.day(p,{width:"wide",context:"formatting"})||m.day(p,{width:"abbreviated",context:"formatting"})||m.day(p,{width:"short",context:"formatting"})||m.day(p,{width:"narrow",context:"formatting"})}},validate:function(p,x,m){return x>=0&&x<=6},set:function(p,x,m,S){return(p=we(p,m,S)).setUTCHours(0,0,0,0),p},incompatibleTokens:["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"]},c:{priority:90,parse:function(p,x,m,S){var A=function(F){var q=7*Math.floor((F-1)/7);return(F+S.weekStartsOn+6)%7+q};switch(x){case"c":case"cc":return Ht(x.length,p,A);case"co":return m.ordinalNumber(p,{unit:"day",valueCallback:A});case"ccc":return m.day(p,{width:"abbreviated",context:"standalone"})||m.day(p,{width:"short",context:"standalone"})||m.day(p,{width:"narrow",context:"standalone"});case"ccccc":return m.day(p,{width:"narrow",context:"standalone"});case"cccccc":return m.day(p,{width:"short",context:"standalone"})||m.day(p,{width:"narrow",context:"standalone"});default:return m.day(p,{width:"wide",context:"standalone"})||m.day(p,{width:"abbreviated",context:"standalone"})||m.day(p,{width:"short",context:"standalone"})||m.day(p,{width:"narrow",context:"standalone"})}},validate:function(p,x,m){return x>=0&&x<=6},set:function(p,x,m,S){return(p=we(p,m,S)).setUTCHours(0,0,0,0),p},incompatibleTokens:["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"]},i:{priority:90,parse:function(p,x,m,S){var A=function(F){return F===0?7:F};switch(x){case"i":case"ii":return Ht(x.length,p);case"io":return m.ordinalNumber(p,{unit:"day"});case"iii":return m.day(p,{width:"abbreviated",context:"formatting",valueCallback:A})||m.day(p,{width:"short",context:"formatting",valueCallback:A})||m.day(p,{width:"narrow",context:"formatting",valueCallback:A});case"iiiii":return m.day(p,{width:"narrow",context:"formatting",valueCallback:A});case"iiiiii":return m.day(p,{width:"short",context:"formatting",valueCallback:A})||m.day(p,{width:"narrow",context:"formatting",valueCallback:A});default:return m.day(p,{width:"wide",context:"formatting",valueCallback:A})||m.day(p,{width:"abbreviated",context:"formatting",valueCallback:A})||m.day(p,{width:"short",context:"formatting",valueCallback:A})||m.day(p,{width:"narrow",context:"formatting",valueCallback:A})}},validate:function(p,x,m){return x>=1&&x<=7},set:function(p,x,m,S){return p=function(A,F){u(2,arguments);var q=h(F);q%7==0&&(q-=7);var Q=1,st=k(A),mt=st.getUTCDay(),xt=((q%7+7)%7=1&&x<=12},set:function(p,x,m,S){var A=p.getUTCHours()>=12;return A&&m<12?p.setUTCHours(m+12,0,0,0):A||m!==12?p.setUTCHours(m,0,0,0):p.setUTCHours(0,0,0,0),p},incompatibleTokens:["H","K","k","t","T"]},H:{priority:70,parse:function(p,x,m,S){switch(x){case"H":return Ot(le,p);case"Ho":return m.ordinalNumber(p,{unit:"hour"});default:return Ht(x.length,p)}},validate:function(p,x,m){return x>=0&&x<=23},set:function(p,x,m,S){return p.setUTCHours(m,0,0,0),p},incompatibleTokens:["a","b","h","K","k","t","T"]},K:{priority:70,parse:function(p,x,m,S){switch(x){case"K":return Ot(Gn,p);case"Ko":return m.ordinalNumber(p,{unit:"hour"});default:return Ht(x.length,p)}},validate:function(p,x,m){return x>=0&&x<=11},set:function(p,x,m,S){return p.getUTCHours()>=12&&m<12?p.setUTCHours(m+12,0,0,0):p.setUTCHours(m,0,0,0),p},incompatibleTokens:["a","b","h","H","k","t","T"]},k:{priority:70,parse:function(p,x,m,S){switch(x){case"k":return Ot(ts,p);case"ko":return m.ordinalNumber(p,{unit:"hour"});default:return Ht(x.length,p)}},validate:function(p,x,m){return x>=1&&x<=24},set:function(p,x,m,S){var A=m<=24?m%24:m;return p.setUTCHours(A,0,0,0),p},incompatibleTokens:["a","b","h","H","K","t","T"]},m:{priority:60,parse:function(p,x,m,S){switch(x){case"m":return Ot(Pi,p);case"mo":return m.ordinalNumber(p,{unit:"minute"});default:return Ht(x.length,p)}},validate:function(p,x,m){return x>=0&&x<=59},set:function(p,x,m,S){return p.setUTCMinutes(m,0,0),p},incompatibleTokens:["t","T"]},s:{priority:50,parse:function(p,x,m,S){switch(x){case"s":return Ot(Xn,p);case"so":return m.ordinalNumber(p,{unit:"second"});default:return Ht(x.length,p)}},validate:function(p,x,m){return x>=0&&x<=59},set:function(p,x,m,S){return p.setUTCSeconds(m,0),p},incompatibleTokens:["t","T"]},S:{priority:30,parse:function(p,x,m,S){return Ht(x.length,p,function(A){return Math.floor(A*Math.pow(10,3-x.length))})},set:function(p,x,m,S){return p.setUTCMilliseconds(m),p},incompatibleTokens:["t","T"]},X:{priority:10,parse:function(p,x,m,S){switch(x){case"X":return Zt(ns,p);case"XX":return Zt(os,p);case"XXXX":return Zt(ui,p);case"XXXXX":return Zt(Us,p);default:return Zt(Fs,p)}},set:function(p,x,m,S){return x.timestampIsSet?p:new Date(p.getTime()-m)},incompatibleTokens:["t","T","x"]},x:{priority:10,parse:function(p,x,m,S){switch(x){case"x":return Zt(ns,p);case"xx":return Zt(os,p);case"xxxx":return Zt(ui,p);case"xxxxx":return Zt(Us,p);default:return Zt(Fs,p)}},set:function(p,x,m,S){return x.timestampIsSet?p:new Date(p.getTime()-m)},incompatibleTokens:["t","T","X"]},t:{priority:40,parse:function(p,x,m,S){return gi(p)},set:function(p,x,m,S){return[new Date(1e3*m),{timestampIsSet:!0}]},incompatibleTokens:"*"},T:{priority:20,parse:function(p,x,m,S){return gi(p)},set:function(p,x,m,S){return[new Date(m),{timestampIsSet:!0}]},incompatibleTokens:"*"}},eo=to,Ws=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,ti=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Vs=/^'([^]*?)'?$/,fi=/''/g,je=/\S/,hs=/[a-zA-Z]/;function mi(p,x){if(x.timestampIsSet)return p;var m=new Date(0);return m.setFullYear(p.getUTCFullYear(),p.getUTCMonth(),p.getUTCDate()),m.setHours(p.getUTCHours(),p.getUTCMinutes(),p.getUTCSeconds(),p.getUTCMilliseconds()),m}function cs(p){return p.match(Vs)[1].replace(fi,"'")}var js=36e5,Lt={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Oi=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Li=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,zi=/^([+-])(\d{2})(?::?(\d{2}))?$/;function $i(p){var x,m={},S=p.split(Lt.dateTimeDelimiter);if(S.length>2)return m;if(/:/.test(S[0])?(m.date=null,x=S[0]):(m.date=S[0],x=S[1],Lt.timeZoneDelimiter.test(m.date)&&(m.date=p.split(Lt.timeZoneDelimiter)[0],x=p.substr(m.date.length,p.length))),x){var A=Lt.timezone.exec(x);A?(m.time=x.replace(A[1],""),m.timezone=A[1]):m.time=x}return m}function Ys(p,x){var m=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+x)+"})|(\\d{2}|[+-]\\d{"+(2+x)+"})$)"),S=p.match(m);if(!S)return{year:null};var A=S[1]&&parseInt(S[1]),F=S[2]&&parseInt(S[2]);return{year:F==null?A:100*F,restDateString:p.slice((S[1]||S[2]).length)}}function io(p,x){if(x===null)return null;var m=p.match(Oi);if(!m)return null;var S=!!m[4],A=me(m[1]),F=me(m[2])-1,q=me(m[3]),Q=me(m[4]),st=me(m[5])-1;if(S)return function(xt,wt,Pt){return wt>=1&&wt<=53&&Pt>=0&&Pt<=6}(0,Q,st)?function(xt,wt,Pt){var Mt=new Date(0);Mt.setUTCFullYear(xt,0,4);var oe=Mt.getUTCDay()||7,he=7*(wt-1)+Pt+1-oe;return Mt.setUTCDate(Mt.getUTCDate()+he),Mt}(x,Q,st):new Date(NaN);var mt=new Date(0);return function(xt,wt,Pt){return wt>=0&&wt<=11&&Pt>=1&&Pt<=(Gs[wt]||(Ni(xt)?29:28))}(x,F,q)&&function(xt,wt){return wt>=1&&wt<=(Ni(xt)?366:365)}(x,A)?(mt.setUTCFullYear(x,F,Math.max(A,q)),mt):new Date(NaN)}function me(p){return p?parseInt(p):1}function so(p){var x=p.match(Li);if(!x)return null;var m=_e(x[1]),S=_e(x[2]),A=_e(x[3]);return function(F,q,Q){return F===24?q===0&&Q===0:Q>=0&&Q<60&&q>=0&&q<60&&F>=0&&F<25}(m,S,A)?m*js+6e4*S+1e3*A:NaN}function _e(p){return p&&parseFloat(p.replace(",","."))||0}function Hi(p){if(p==="Z")return 0;var x=p.match(zi);if(!x)return 0;var m=x[1]==="+"?-1:1,S=parseInt(x[2]),A=x[3]&&parseInt(x[3])||0;return function(F,q){return q>=0&&q<=59}(0,A)?m*(S*js+6e4*A):NaN}var Gs=[31,null,31,30,31,30,31,31,30,31,30,31];function Ni(p){return p%400==0||p%4==0&&p%100}let qs={datetime:"MMM d, yyyy, h:mm:ss aaaa",millisecond:"h:mm:ss.SSS aaaa",second:"h:mm:ss aaaa",minute:"h:mm aaaa",hour:"ha",day:"MMM d",week:"PP",month:"MMM yyyy",quarter:"qqq - yyyy",year:"yyyy"};_._adapters._date.override({_id:"date-fns",formats:function(){return qs},parse:function(p,x){if(p==null)return null;let m=typeof p;return m==="number"||p instanceof Date?p=k(p):m==="string"&&(p=typeof x=="string"?function(S,A,F,q){u(3,arguments);var Q=String(S),st=String(A),mt=q||{},xt=mt.locale||$;if(!xt.match)throw new RangeError("locale must contain match property");var wt=xt.options&&xt.options.firstWeekContainsDate,Pt=wt==null?1:h(wt),Mt=mt.firstWeekContainsDate==null?Pt:h(mt.firstWeekContainsDate);if(!(Mt>=1&&Mt<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var oe=xt.options&&xt.options.weekStartsOn,he=oe==null?0:h(oe),ke=mt.weekStartsOn==null?he:h(mt.weekStartsOn);if(!(ke>=0&&ke<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(st==="")return Q===""?k(F):new Date(NaN);var se,ce={firstWeekContainsDate:Mt,weekStartsOn:ke,locale:xt},It=[{priority:10,subPriority:-1,set:mi,index:0}],be=st.match(ti).map(function(qt){var de=qt[0];return de==="p"||de==="P"?(0,Di[de])(qt,xt.formatLong,ce):qt}).join("").match(Ws),Me=[];for(se=0;se0&&je.test(Q))return new Date(NaN);var Bi=It.map(function(qt){return qt.priority}).sort(function(qt,de){return de-qt}).filter(function(qt,de,ii){return ii.indexOf(qt)===de}).map(function(qt){return It.filter(function(de){return de.priority===qt}).sort(function(de,ii){return ii.subPriority-de.subPriority})}).map(function(qt){return qt[0]}),us=k(F);if(isNaN(us))return new Date(NaN);var Se=V(us,K(us)),gs={};for(se=0;se=1&&xt<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var wt=Q.options&&Q.options.weekStartsOn,Pt=wt==null?0:h(wt),Mt=q.weekStartsOn==null?Pt:h(q.weekStartsOn);if(!(Mt>=0&&Mt<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!Q.localize)throw new RangeError("locale must contain localize property");if(!Q.formatLong)throw new RangeError("locale must contain formatLong property");var oe=k(m);if(!bt(oe))throw new RangeError("Invalid time value");var he=K(oe),ke=V(oe,he),se={firstWeekContainsDate:xt,weekStartsOn:Mt,locale:Q,_originalDate:oe},ce=F.match(Ns).map(function(It){var be=It[0];return be==="p"||be==="P"?(0,Di[be])(It,Q.formatLong,se):It}).join("").match(jt).map(function(It){if(It==="''")return"'";var be=It[0];if(be==="'")return ve(It);var Me=$s[be];if(Me)return!q.useAdditionalWeekYearTokens&&Zi(It)&&Ve(It,S,m),!q.useAdditionalDayOfYearTokens&&Ai(It)&&Ve(It,S,m),Me(ke,It,Q.localize,se);if(be.match(Yn))throw new RangeError("Format string contains an unescaped latin alphabet character `"+be+"`");return It}).join("");return ce}(p,x,this.options)},add:function(p,x,m){switch(m){case"millisecond":return L(p,x);case"second":return function(S,A){u(2,arguments);var F=h(A);return L(S,1e3*F)}(p,x);case"minute":return function(S,A){u(2,arguments);var F=h(A);return L(S,6e4*F)}(p,x);case"hour":return function(S,A){u(2,arguments);var F=h(A);return L(S,F*G)}(p,x);case"day":return P(p,x);case"week":return function(S,A){u(2,arguments);var F=h(A),q=7*F;return P(S,q)}(p,x);case"month":return z(p,x);case"quarter":return function(S,A){u(2,arguments);var F=h(A),q=3*F;return z(S,q)}(p,x);case"year":return function(S,A){u(2,arguments);var F=h(A);return z(S,12*F)}(p,x);default:return p}},diff:function(p,x,m){switch(m){case"millisecond":return zt(p,x);case"second":return function(S,A){u(2,arguments);var F=zt(S,A)/1e3;return F>0?Math.floor(F):Math.ceil(F)}(p,x);case"minute":return function(S,A){u(2,arguments);var F=zt(S,A)/6e4;return F>0?Math.floor(F):Math.ceil(F)}(p,x);case"hour":return function(S,A){u(2,arguments);var F=zt(S,A)/te;return F>0?Math.floor(F):Math.ceil(F)}(p,x);case"day":return $t(p,x);case"week":return function(S,A){u(2,arguments);var F=$t(S,A)/7;return F>0?Math.floor(F):Math.ceil(F)}(p,x);case"month":return pt(p,x);case"quarter":return function(S,A){u(2,arguments);var F=pt(S,A)/3;return F>0?Math.floor(F):Math.ceil(F)}(p,x);case"year":return function(S,A){u(2,arguments);var F=k(S),q=k(A),Q=ft(F,q),st=Math.abs(Dt(F,q));F.setFullYear("1584"),q.setFullYear("1584");var mt=ft(F,q)===-Q,xt=Q*(st-mt);return xt===0?0:xt}(p,x);default:return 0}},startOf:function(p,x,m){switch(x){case"second":return function(S){u(1,arguments);var A=k(S);return A.setMilliseconds(0),A}(p);case"minute":return function(S){u(1,arguments);var A=k(S);return A.setSeconds(0,0),A}(p);case"hour":return function(S){u(1,arguments);var A=k(S);return A.setMinutes(0,0,0),A}(p);case"day":return ut(p);case"week":return U(p);case"isoWeek":return U(p,{weekStartsOn:+m});case"month":return function(S){u(1,arguments);var A=k(S);return A.setDate(1),A.setHours(0,0,0,0),A}(p);case"quarter":return function(S){u(1,arguments);var A=k(S),F=A.getMonth(),q=F-F%3;return A.setMonth(q,1),A.setHours(0,0,0,0),A}(p);case"year":return function(S){u(1,arguments);var A=k(S),F=new Date(0);return F.setFullYear(A.getFullYear(),0,1),F.setHours(0,0,0,0),F}(p);default:return p}},endOf:function(p,x){switch(x){case"second":return function(m){u(1,arguments);var S=k(m);return S.setMilliseconds(999),S}(p);case"minute":return function(m){u(1,arguments);var S=k(m);return S.setSeconds(59,999),S}(p);case"hour":return function(m){u(1,arguments);var S=k(m);return S.setMinutes(59,59,999),S}(p);case"day":return De(p);case"week":return function(m,S){u(1,arguments);var A=S||{},F=A.locale,q=F&&F.options&&F.options.weekStartsOn,Q=q==null?0:h(q),st=A.weekStartsOn==null?Q:h(A.weekStartsOn);if(!(st>=0&&st<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var mt=k(m),xt=mt.getDay(),wt=6+(xt{if(!u.ok)throw new Error(`DatastoreHelper.fetchAndCache(${h}) - HTTP error, status = ${u.status}`);return u.text()}).then(u=>JSON.parse(u)).catch(u=>{console.error(u),alert(u.message),reject(u)}),this.CACHE[h])}static async fetchDeviceData({dev:h,precision:u,attr1:k,attr2:P,mm1:z,mm2:L,z1:G,z2:U}){let K={attr1:[],attr2:[],min1:[],max1:[],min2:[],max2:[]};try{let ut=await fetch(new Request(this.buildCsvUrl(h,u)),{cache:"no-store"});if(ut.status==404)return K;if(!ut.ok)throw new Error(`DatastoreHelper.fetchDeviceData() - HTTP error, status = ${ut.status}`);let X=(await ut.text()).split(`
`),it=X.shift().split(","),ft=it.indexOf(k),bt=P==null?-1:it.indexOf(P),Tt=it.indexOf(`${k}_min`),Dt=it.indexOf(`${k}_max`),kt=it.indexOf(`${P}_min`),$t=it.indexOf(`${P}_max`),zt=z===!0&&u!=="5m"&&Tt!==-1&&Dt!==-1,te=L===!0&&u!=="5m"&&kt!==-1&&$t!==-1;return X.forEach(De=>{let vt=De.split(","),At=parseInt(vt[0])*1e3;K.attr1.push({x:At,y:vt[ft]===""||vt[ft]==="-"?G===!0?0:null:parseFloat(vt[ft])}),bt!==-1&&K.attr2.push({x:At,y:vt[bt]===""||vt[bt]==="-"?U===!0?0:null:parseFloat(vt[bt])}),zt&&(K.min1.push({x:At,y:vt[Tt]===void 0||vt[Tt]===""||vt[Tt]==="-"?G===!0?0:null:parseFloat(vt[Tt])}),K.max1.push({x:At,y:vt[Dt]===void 0||vt[Dt]===""||vt[Dt]==="-"?G===!0?0:null:parseFloat(vt[Dt])})),te&&(K.min2.push({x:At,y:vt[kt]===void 0||vt[kt]===""||vt[kt]==="-"?U===!0?0:null:parseFloat(vt[kt])}),K.max2.push({x:At,y:vt[$t]===void 0||vt[$t]===""||vt[$t]==="-"?U===!0?0:null:parseFloat(vt[$t])}))}),K}catch(ut){console.error(ut),alert(ut.message)}}static buildCsvUrl(h,u){return window.location.host!=="cloud.hubitat.com"?`/local/wt_${h}_${u}.csv`:`./watchtower.csv?device=${h}&precision=${u}&access_token=${this.accessToken()}`}static async fetchAttributeData({attr:h,devs:u,precision:k,z:P}){let z={};for(let L of u){let G=await this.fetchDeviceData({dev:L,precision:k,attr1:h,z1:P});z[`dev_${L}`]=G.attr1}return z}static async fetchStatusmapData({ds:h,precision:u}){let k={},P={};h.forEach(L=>{k[L.dev]===void 0&&(k[L.dev]=new Set),k[L.dev].add(L.attr),P[`${L.dev}_${L.attr}`]=[]}),Object.keys(k).forEach(L=>k[L]=Array.from(k[L]));let z=L=>L===""||L==="-"?0:parseFloat(L);for(let[L,G]of Object.entries(k)){let U=G.length;try{let K=await fetch(new Request(this.buildCsvUrl(L,u)),{cache:"no-store"});if(K.status==404)continue;if(!K.ok)throw new Error(`DatastoreHelper.fetchStatusmapData() - HTTP error, status = ${K.status}`);let ut=(await K.text()).split(`
`),X=ut.shift().split(","),it=G.map(Dt=>X.indexOf(Dt)),ft=ut.shift().split(","),bt=it.map(Dt=>({x:parseInt(ft[0])*1e3,v:z(ft[Dt])}));ut.forEach(Dt=>{let kt=Dt.split(","),$t=parseInt(kt[0])*1e3;for(let zt=0;zt{let $t=parseInt(Tt[0])*1e3,zt=z(Tt[Dt]);if($t==bt[kt].x)return;let te=G[kt];P[`${L}_${te}`].push({x:[bt[kt].x,$t],v:zt})})}catch(K){console.error(K),alert(K.message)}}return P}static async fetchHubInfo(){try{let h=await fetch(new Request(`./hub-info.json?access_token=${this.accessToken()}`),{cache:"no-store"});if(!h.ok)throw new Error(`DatastoreHelper.fetchHubInfo() - HTTP error, status = ${h.status}`);let u=await h.text();return JSON.parse(u)}catch(h){console.error(h),alert(h.message)}}static async fetchHubData(){try{let h=await fetch(new Request("/hub2/hubData"),{cache:"no-store"});if(!h.ok)throw new Error(`DatastoreHelper.fetchHubData() - HTTP error, status = ${h.status}`);let u=await h.text();return JSON.parse(u)}catch(h){console.error(h),alert(h.message)}}};var Tn=class extends Ct{static styles=Ft`
:host {
display: block;
height: calc(100vh - 10px);
}
`;static properties={halt:{type:Boolean,state:!0},embedded:{type:Boolean,state:!0}};constructor(){if(super(),this.menuElm=void 0,this.gridElm=void 0,this.dialogElm=void 0,this.params=new URLSearchParams(window.location.search),this.name=this.params.get("name"),this.name===null)throw this.bailOut("0001"),new Error("Query parameter [name] is missing!");if(this.params.get("access_token")===null)throw this.bailOut("0002"),new Error("Query parameter [access_token] is missing!");this.mobileView=window.innerWidth<768,window.addEventListener("resize",()=>{let h=window.innerWidth<768;this.mobileView!=h&&(this.mobileView=h,this.applyMobileView())}),window.addEventListener("load",()=>{window.top!==window.self&&(document.body.classList.add("embedded"),this.embedded=!0)}),this.halt=!1}render(){return this.halt!==!1?"":at`
${this.embedded===!0?"":at`
`}
`}connectedCallback(){super.connectedCallback(),window.addEventListener("keydown",h=>this.onKeyDown(h)),document.body.classList.remove("spinner")}async firstUpdated(){this.menuElm=this.renderRoot.querySelector("dashboard-menu"),this.gridElm=this.renderRoot.querySelector("dashboard-grid"),this.dialogElm=this.renderRoot.querySelector("dashboard-add-dialog");let h=await Nt.fetchGridLayout(this.params.get("name")),u=h.refresh?parseInt(h.refresh):0,k=h.theme==="dark"?"dark":"light",P=h.yScale=="fixed"?"fixed":"auto",z=h.cellHeight?parseInt(h.cellHeight):206;h.panels.length===0&&(this.menuElm.open=!0),await this.gridElm.updateComplete,this.gridElm.init(h.panels),this.gridElm.setRefreshInterval(u),this.gridElm.setYScale(P),this.gridElm.setCellHeight(z),this.menuElm.refreshInterval=u,this.menuElm.yScale=P,this.menuElm.cellHeight=z,this.menuElm.setTheme(k),this.applyMobileView()}onKeyDown(h){if(h.key==="Escape"){if(this.dialogElm.open){this.dialogElm.open=!1;return}this.menuElm.open=!this.menuElm.open}}bailOut(h){alert(`
This file is part of the Watchtower application.
To load or create a Watchtower dashboard, please got to:
\u2022 Apps -> Watchtower -> Dashboards
Error Code: #${h}
`)}applyMobileView(){this.gridElm.applyMobileView(this.mobileView),this.menuElm.applyMobileView(this.mobileView)}async saveDashboard(h){let u={...h.detail,panels:this.gridElm.getPanelsConfig()};console.info("Saving dashboard to Hubitat",this.name,u),await Nt.saveGridLayout(this.name,u)}showAddDialog(){this.dialogElm.resetForm(),this.dialogElm.setAttribute("open",!0)}editPanel(h){this.dialogElm.config=JSON.parse(JSON.stringify(h.detail)),this.dialogElm.setAttribute("open",!0)}compactPanels(){this.gridElm.compact()}addDashboardPanel(h){this.gridElm.addPanel(h.detail)}applyRefreshInterval(h){let u=parseInt(h.detail);this.gridElm.setRefreshInterval(u)}applyYScale(h){this.gridElm.setYScale(h.detail)}applyCellHeight(h){this.gridElm.setCellHeight(h.detail)}};var Dn=class extends Ct{static styles=Ft`
:host {
display: block;
position: fixed;
top: 0;
left: 0;
height: 100%;
}
nav {
box-sizing: border-box;
position: absolute;
top: 0;
left: -15em;
width: 15em;
height: 100%;
padding: 1em;
background-color: var(--bg-color-darker);
color: var(--text-color);
border-right: 1px var(--border-color) solid;
animation: hideme .3s;
}
:host([open]) nav {
box-shadow: 0 0 1em var(--shadow-color);
left: 0;
animation: showme .3s;
}
@keyframes hideme {
from { left: 0 }
to { left: -15em }
}
@keyframes showme {
from { left: -15em }
to { left: 0px }
}
hr {
border: 0;
border-top: 1px var(--separator-color) solid;
margin: 1em 0;
}
button {
background-color: var(--bg-color);
color: var(--text-color);
border: 1px var(--border-color) solid;
border-radius: 5px;
margin-bottom: 5px;
padding: .5em 1em;
cursor: pointer;
display: block;
width: 100%;
text-align: left;
box-shadow: 0 0 0.3em var(--shadow-color);
}
button:hover {
background-color: var(--Blue);
color: var(--Base3);
}
label {
display: block;
margin: 1em 0 .5em 0;
font-size: .85rem;
}
select {
display: block;
width: 100%;
margin-bottom: 5px;
height: 30px;
background-color: var(--bg-color-darker);
color: var(--text-color);
border: 1px var(--border-color) solid;
border-radius: 5px;
}
select:focus, button:focus {
outline: 1px var(--Blue) solid;
border-color: var(--Blue);
}
aside {
color: var(--text-color-darker);
position: absolute;
bottom: .5em;
left: 50%;
transform: translateX(-50%);
user-select: none;
font-size: .75rem;
}
form {
border: 1px solid grey;
padding: 0;
background-color: var(--bg-color-darker);
color: var(--text-color);
border: 1px var(--border-color) solid;
border-radius: 5px;
position: relative;
display: block;
width: 100%;
}
form input[type="text"] {
box-sizing: border-box;
border: none;
color: var(--text-color);
background-color: transparent;
padding-right: 30px;
padding-left: 5px;
width: 100%;
height: 28px;
}
form input:focus {
outline: none;
}
form:focus-within {
border-color: var(--Blue);
outline: 1px solid var(--Blue);
}
form:invalid {
border-color: var(--Red);
outline: 1px solid var(--Red);
}
form input[type="submit"] {
border: none;
color: var(--text-color-darker);
background-color: transparent;
position: absolute;
top: 50%;
right: 0px;
transform: translateY(-50%);
cursor: pointer;
width: 30px;
}
`;static properties={open:{type:Boolean,reflect:!0},refreshInterval:{type:String,state:!0},theme:{type:String,state:!0},yScale:{type:String,state:!0},cellHeight:{type:Number,state:!0},mobileView:{type:Boolean,state:!0}};constructor(){super(),this.open=!1,this.refreshInterval="0",this.theme="light",this.yScale="auto",this.cellHeight=206}render(){return at`
`}connectedCallback(){super.connectedCallback(),window.addEventListener("touchstart",h=>this.touchStart(h)),window.addEventListener("touchend",h=>this.touchEnd(h))}applyMobileView(h){this.mobileView=h}addTile(){this.dispatchEvent(new CustomEvent("add"))}compactTiles(){this.dispatchEvent(new CustomEvent("compact"))}saveDashboard(){this.dispatchEvent(new CustomEvent("save",{detail:{theme:this.theme,refresh:this.refreshInterval,yScale:this.yScale,cellHeight:this.cellHeight}}))}changeRefreshInterval(h){this.refreshInterval=h.target.value,this.dispatchEvent(new CustomEvent("changeRefreshInterval",{detail:this.refreshInterval}))}changeTheme(h){this.setTheme(h.target.value)}changeYScale(h){this.yScale=h.target.value,this.dispatchEvent(new CustomEvent("changeYScale",{detail:this.yScale}))}changeCellHeight(h){h.preventDefault();let u=Object.fromEntries(new FormData(h.target));this.cellHeight=parseInt(u.cellHeight),this.dispatchEvent(new CustomEvent("changeCellHeight",{detail:this.cellHeight}))}setTheme(h){this.theme=h,this.dispatchEvent(new CustomEvent("changeTheme",{detail:this.theme})),document.documentElement.setAttribute("data-theme",this.theme);let u=new URLSearchParams(window.location.search);document.querySelector('meta[name="theme-color"]').setAttribute("content",h=="dark"?"#1b1b1b":"#eee8d5"),document.querySelector('link[rel="manifest"]').setAttribute("href",`./app.webmanifest?access_token=${u.get("access_token")}&name=${encodeURIComponent(u.get("name"))}&theme=${h}`)}touchStart(h){this.startX=h.changedTouches[0].clientX}touchEnd(h){if(this.startX==null)return;let u=h.changedTouches[0].clientX,k=u-this.startX;if(!this.open&&this.startX<60&&k>50){this.open=!0;return}this.open&&u<150&&k<-50&&(this.open=!1)}};var An=class _ extends Ct{static styles=Ft`
:host {
display: none;
position: fixed;
width: 100%; height: 100%;
top: 0; left: 0;
background-color: rgba(0, 0, 0, 0.3);
font-size: 0.84rem;
}
:host([open="true"]) {
display: block;
}
.spinner:after {
position: absolute;
top: calc(50% - 0.5em);
left: 0.5em;
content: ' ';
display: block;
width: 1em;
height: 1em;
border-radius: 50%;
border: 1px solid var(--text-color-darker);
border-color: var(--text-color-darker) transparent var(--text-color-darker) transparent;
animation: spinner 1.2s linear infinite;
}
@keyframes spinner {
0% { transform: rotate(0deg) }
100% { transform: rotate(360deg) }
}
article {
box-sizing: border-box;
display: block;
position: absolute;
top: -50%;
left: 50%;
transform: translate(-50%, -50%);
min-width: 300px;
background-color: var(--bg-color-darker);
color: var(--text-color);
border: 1px var(--border-color) solid;
box-shadow: 0 0 1em var(--shadow-color);
border-radius: 5px;
padding: 0;
}
:host([open="true"]) article {
animation: showme .5s;
animation-fill-mode: forwards;
}
@keyframes showme {
to { top: 50% }
}
header {
text-align: center;
font-weight: bold;
padding: 1em;
}
section.modal-body {
max-height: 70vh;
overflow-y: auto;
padding: 0 1em;
}
section.modal-body fieldset {
border: 0;
border-radius: 5px;
background-color: var(--bg-color);
padding: 10px;
}
section.modal-body fieldset:not(:last-child) {
margin-bottom: 10px;
}
section.modal-body fieldset nav {
text-align: right;
border-top: 1px var(--border-color) solid;
margin-top: 5px;
padding-top: 5px;
color: var(--border-color);
}
section.modal-body fieldset a {
color: var(--Blue);
text-decoration: none;
}
fieldset section:not(:last-child) {
margin-bottom: 10px;
}
section.modal-body section > div {
margin-top: .3em;
}
footer {
padding: 1em;
text-align: right;
}
button {
padding: .5em 1em;
cursor: pointer;
background-color: var(--bg-color);
color: var(--text-color);
border: 1px var(--border-color) solid;
border-radius: 5px;
box-shadow: 0 0 0.3em var(--shadow-color);
}
button:not(:first-child) {
margin-left: 10px;
}
button:hover {
background-color: var(--Blue);
color: var(--Base3);
}
label { display: block; user-select: none; margin-bottom: 5px }
select { display: block; line-height: 32px }
input, select {
box-sizing: border-box;
display: block;
width: 100%;
height: 32px;
background-color: var(--bg-color-darker);
color: var(--text-color);
border: 1px var(--border-color) solid;
border-radius: 5px;
padding: 6px;
margin: 0;
}
.checkbox:not(:last-child) { margin-bottom: 9px }
.checkbox input { display: none }
.checkbox label {
align-items: center;
cursor: pointer;
display: flex;
line-height: 15px;
height: 15px;
position: relative;
magin-bottom: 0;
}
.checkbox label::before, .checkbox label::after { content: ''; display: block }
.checkbox label::before {
background-color: var(--Base00);
border-radius: 500px;
height: 15px;
margin-right: 8px;
width: 25px;
}
.checkbox input:user-invalid + label::before { background-color: var(--Red) }
.checkbox label::after {
background-color: #fff;
border-radius: 13px;
height: 13px;
left: 1px;
position: absolute;
top: 1px;
transition: transform 0.125s ease-out;
width: 13px;
}
.checkbox input:checked + label::before { background-color: var(--Blue) }
.checkbox input:checked + label::after { transform: translate3d(10px, 0, 0) }
input:focus, select:focus, button:focus {
outline: 1px var(--Blue) solid;
border-color: var(--Blue)
}
input:user-invalid, select:user-invalid {
border-color: var(--Red) !important;
}
aside {
display: block;
position: relative;
background-color: var(--bg-color);
color: var(--text-color-darker);
border: 1px var(--border-color) solid;
padding: .5em .5em .5em 2.3em;
}
`;static panels={"device-panel":"Device","attribute-panel":"Attribute","statusmap-panel":"Status Map","text-panel":"Text","iframe-panel":"Iframe","hub-info-panel":"Hub Info"};static properties={open:{type:Boolean,reflect:!0},config:{type:Object,state:!0}};constructor(){super(),this.open=!1,this.resetForm()}render(){return setTimeout(()=>this.renderRoot.querySelector(".panel-config")?.addEventListener("suggestTitle",h=>this.suggestTitle(h)),0),this.open?at`
`:Rt}renderPanelConfig(){return En(`
<${this.config.type}-config class="panel-config"
config='${JSON.stringify(this.config).replace(/'/g,"'")}'>${this.config.type}-config
@suggestTitle=${this.suggestTitle}
>${this.config.type}-config>
`)}connectedCallback(){super.connectedCallback(),window.addEventListener("keydown",h=>h.key==="Escape"&&this.close(h))}onTileTypeChange(h){this.config={id:this.config.id,title:this.config.title,type:h.target.value}}suggestTitle(h){this.config.title==""&&(this.config.title=h.detail)}updated(h){h.size==0||h.open}resetForm(){this.config={title:""}}close(){this.resetForm(),this.open=!1}submit(h){h.preventDefault();let u=this.renderRoot.querySelector(".panel-config").decorateConfig({id:this.config.id,title:this.config.title,type:this.config.type});Object.keys(u).forEach(k=>u[k]===void 0&&delete u[k]),console.info("**** Adding panel with config",u),this.close(),this.resetForm(),this.dispatchEvent(new CustomEvent("done",{detail:u}))}};var Pn=class extends Ct{static styles=Ft`
.grid-stack{position:relative}.grid-stack-rtl{direction:ltr}.grid-stack-rtl>.grid-stack-item{direction:rtl}.grid-stack-placeholder>.placeholder-content{background-color:rgba(0,0,0,.1);margin:0;position:absolute;width:auto;z-index:0!important}.grid-stack>.grid-stack-item{position:absolute;padding:0}.grid-stack>.grid-stack-item>.grid-stack-item-content{margin:0;position:absolute;width:auto;overflow-x:hidden;overflow-y:auto}.grid-stack>.grid-stack-item.size-to-content:not(.size-to-content-max)>.grid-stack-item-content{overflow-y:hidden}.grid-stack-item>.ui-resizable-handle{position:absolute;font-size:.1px;display:block;-ms-touch-action:none;touch-action:none}.grid-stack-item.ui-resizable-autohide>.ui-resizable-handle,.grid-stack-item.ui-resizable-disabled>.ui-resizable-handle{display:none}.grid-stack-item>.ui-resizable-ne,.grid-stack-item>.ui-resizable-nw,.grid-stack-item>.ui-resizable-se,.grid-stack-item>.ui-resizable-sw{background-image:url('data:image/svg+xml;utf8,');background-repeat:no-repeat;background-position:center}.grid-stack-item>.ui-resizable-ne{transform:translate(0,10px) rotate(45deg)}.grid-stack-item>.ui-resizable-sw{transform:rotate(45deg)}.grid-stack-item>.ui-resizable-nw{transform:translate(0,10px) rotate(-45deg)}.grid-stack-item>.ui-resizable-se{transform:rotate(-45deg)}.grid-stack-item>.ui-resizable-nw{cursor:nw-resize;width:20px;height:20px;top:0}.grid-stack-item>.ui-resizable-n{cursor:n-resize;height:10px;top:0;left:25px;right:25px}.grid-stack-item>.ui-resizable-ne{cursor:ne-resize;width:20px;height:20px;top:0}.grid-stack-item>.ui-resizable-e{cursor:e-resize;width:10px;top:15px;bottom:15px}.grid-stack-item>.ui-resizable-se{cursor:se-resize;width:20px;height:20px}.grid-stack-item>.ui-resizable-s{cursor:s-resize;height:10px;left:25px;bottom:0;right:25px}.grid-stack-item>.ui-resizable-sw{cursor:sw-resize;width:20px;height:20px}.grid-stack-item>.ui-resizable-w{cursor:w-resize;width:10px;top:15px;bottom:15px}.grid-stack-item.ui-draggable-dragging>.ui-resizable-handle{display:none!important}.grid-stack-item.ui-draggable-dragging{will-change:left,top;cursor:move}.grid-stack-item.ui-resizable-resizing{will-change:width,height}.ui-draggable-dragging,.ui-resizable-resizing{z-index:10000}.ui-draggable-dragging>.grid-stack-item-content,.ui-resizable-resizing>.grid-stack-item-content{box-shadow:1px 4px 6px rgba(0,0,0,.2);opacity:.8}.grid-stack-animate,.grid-stack-animate .grid-stack-item{transition:left .3s,top .3s,height .3s,width .3s}.grid-stack-animate .grid-stack-item.grid-stack-placeholder,.grid-stack-animate .grid-stack-item.ui-draggable-dragging,.grid-stack-animate .grid-stack-item.ui-resizable-resizing{transition:left 0s,top 0s,height 0s,width 0s}.grid-stack>.grid-stack-item[gs-y="0"]{top:0}.grid-stack>.grid-stack-item[gs-x="0"]{left:0}.gs-12>.grid-stack-item{width:8.333%}.gs-12>.grid-stack-item[gs-x="1"]{left:8.333%}.gs-12>.grid-stack-item[gs-w="2"]{width:16.667%}.gs-12>.grid-stack-item[gs-x="2"]{left:16.667%}.gs-12>.grid-stack-item[gs-w="3"]{width:25%}.gs-12>.grid-stack-item[gs-x="3"]{left:25%}.gs-12>.grid-stack-item[gs-w="4"]{width:33.333%}.gs-12>.grid-stack-item[gs-x="4"]{left:33.333%}.gs-12>.grid-stack-item[gs-w="5"]{width:41.667%}.gs-12>.grid-stack-item[gs-x="5"]{left:41.667%}.gs-12>.grid-stack-item[gs-w="6"]{width:50%}.gs-12>.grid-stack-item[gs-x="6"]{left:50%}.gs-12>.grid-stack-item[gs-w="7"]{width:58.333%}.gs-12>.grid-stack-item[gs-x="7"]{left:58.333%}.gs-12>.grid-stack-item[gs-w="8"]{width:66.667%}.gs-12>.grid-stack-item[gs-x="8"]{left:66.667%}.gs-12>.grid-stack-item[gs-w="9"]{width:75%}.gs-12>.grid-stack-item[gs-x="9"]{left:75%}.gs-12>.grid-stack-item[gs-w="10"]{width:83.333%}.gs-12>.grid-stack-item[gs-x="10"]{left:83.333%}.gs-12>.grid-stack-item[gs-w="11"]{width:91.667%}.gs-12>.grid-stack-item[gs-x="11"]{left:91.667%}.gs-12>.grid-stack-item[gs-w="12"]{width:100%}.gs-1>.grid-stack-item{width:100%}
.gs-2>.grid-stack-item{width:50%}.gs-2>.grid-stack-item[gs-x="1"]{left:50%}.gs-2>.grid-stack-item[gs-w="2"]{width:100%}.gs-3>.grid-stack-item{width:33.333%}.gs-3>.grid-stack-item[gs-x="1"]{left:33.333%}.gs-3>.grid-stack-item[gs-w="2"]{width:66.667%}.gs-3>.grid-stack-item[gs-x="2"]{left:66.667%}.gs-3>.grid-stack-item[gs-w="3"]{width:100%}.gs-4>.grid-stack-item{width:25%}.gs-4>.grid-stack-item[gs-x="1"]{left:25%}.gs-4>.grid-stack-item[gs-w="2"]{width:50%}.gs-4>.grid-stack-item[gs-x="2"]{left:50%}.gs-4>.grid-stack-item[gs-w="3"]{width:75%}.gs-4>.grid-stack-item[gs-x="3"]{left:75%}.gs-4>.grid-stack-item[gs-w="4"]{width:100%}.gs-5>.grid-stack-item{width:20%}.gs-5>.grid-stack-item[gs-x="1"]{left:20%}.gs-5>.grid-stack-item[gs-w="2"]{width:40%}.gs-5>.grid-stack-item[gs-x="2"]{left:40%}.gs-5>.grid-stack-item[gs-w="3"]{width:60%}.gs-5>.grid-stack-item[gs-x="3"]{left:60%}.gs-5>.grid-stack-item[gs-w="4"]{width:80%}.gs-5>.grid-stack-item[gs-x="4"]{left:80%}.gs-5>.grid-stack-item[gs-w="5"]{width:100%}.gs-6>.grid-stack-item{width:16.667%}.gs-6>.grid-stack-item[gs-x="1"]{left:16.667%}.gs-6>.grid-stack-item[gs-w="2"]{width:33.333%}.gs-6>.grid-stack-item[gs-x="2"]{left:33.333%}.gs-6>.grid-stack-item[gs-w="3"]{width:50%}.gs-6>.grid-stack-item[gs-x="3"]{left:50%}.gs-6>.grid-stack-item[gs-w="4"]{width:66.667%}.gs-6>.grid-stack-item[gs-x="4"]{left:66.667%}.gs-6>.grid-stack-item[gs-w="5"]{width:83.333%}.gs-6>.grid-stack-item[gs-x="5"]{left:83.333%}.gs-6>.grid-stack-item[gs-w="6"]{width:100%}.gs-7>.grid-stack-item{width:14.286%}.gs-7>.grid-stack-item[gs-x="1"]{left:14.286%}.gs-7>.grid-stack-item[gs-w="2"]{width:28.571%}.gs-7>.grid-stack-item[gs-x="2"]{left:28.571%}.gs-7>.grid-stack-item[gs-w="3"]{width:42.857%}.gs-7>.grid-stack-item[gs-x="3"]{left:42.857%}.gs-7>.grid-stack-item[gs-w="4"]{width:57.143%}.gs-7>.grid-stack-item[gs-x="4"]{left:57.143%}.gs-7>.grid-stack-item[gs-w="5"]{width:71.429%}.gs-7>.grid-stack-item[gs-x="5"]{left:71.429%}.gs-7>.grid-stack-item[gs-w="6"]{width:85.714%}.gs-7>.grid-stack-item[gs-x="6"]{left:85.714%}.gs-7>.grid-stack-item[gs-w="7"]{width:100%}.gs-8>.grid-stack-item{width:12.5%}.gs-8>.grid-stack-item[gs-x="1"]{left:12.5%}.gs-8>.grid-stack-item[gs-w="2"]{width:25%}.gs-8>.grid-stack-item[gs-x="2"]{left:25%}.gs-8>.grid-stack-item[gs-w="3"]{width:37.5%}.gs-8>.grid-stack-item[gs-x="3"]{left:37.5%}.gs-8>.grid-stack-item[gs-w="4"]{width:50%}.gs-8>.grid-stack-item[gs-x="4"]{left:50%}.gs-8>.grid-stack-item[gs-w="5"]{width:62.5%}.gs-8>.grid-stack-item[gs-x="5"]{left:62.5%}.gs-8>.grid-stack-item[gs-w="6"]{width:75%}.gs-8>.grid-stack-item[gs-x="6"]{left:75%}.gs-8>.grid-stack-item[gs-w="7"]{width:87.5%}.gs-8>.grid-stack-item[gs-x="7"]{left:87.5%}.gs-8>.grid-stack-item[gs-w="8"]{width:100%}.gs-9>.grid-stack-item{width:11.111%}.gs-9>.grid-stack-item[gs-x="1"]{left:11.111%}.gs-9>.grid-stack-item[gs-w="2"]{width:22.222%}.gs-9>.grid-stack-item[gs-x="2"]{left:22.222%}.gs-9>.grid-stack-item[gs-w="3"]{width:33.333%}.gs-9>.grid-stack-item[gs-x="3"]{left:33.333%}.gs-9>.grid-stack-item[gs-w="4"]{width:44.444%}.gs-9>.grid-stack-item[gs-x="4"]{left:44.444%}.gs-9>.grid-stack-item[gs-w="5"]{width:55.556%}.gs-9>.grid-stack-item[gs-x="5"]{left:55.556%}.gs-9>.grid-stack-item[gs-w="6"]{width:66.667%}.gs-9>.grid-stack-item[gs-x="6"]{left:66.667%}.gs-9>.grid-stack-item[gs-w="7"]{width:77.778%}.gs-9>.grid-stack-item[gs-x="7"]{left:77.778%}.gs-9>.grid-stack-item[gs-w="8"]{width:88.889%}.gs-9>.grid-stack-item[gs-x="8"]{left:88.889%}.gs-9>.grid-stack-item[gs-w="9"]{width:100%}.gs-10>.grid-stack-item{width:10%}.gs-10>.grid-stack-item[gs-x="1"]{left:10%}.gs-10>.grid-stack-item[gs-w="2"]{width:20%}.gs-10>.grid-stack-item[gs-x="2"]{left:20%}.gs-10>.grid-stack-item[gs-w="3"]{width:30%}.gs-10>.grid-stack-item[gs-x="3"]{left:30%}.gs-10>.grid-stack-item[gs-w="4"]{width:40%}.gs-10>.grid-stack-item[gs-x="4"]{left:40%}.gs-10>.grid-stack-item[gs-w="5"]{width:50%}.gs-10>.grid-stack-item[gs-x="5"]{left:50%}.gs-10>.grid-stack-item[gs-w="6"]{width:60%}.gs-10>.grid-stack-item[gs-x="6"]{left:60%}.gs-10>.grid-stack-item[gs-w="7"]{width:70%}.gs-10>.grid-stack-item[gs-x="7"]{left:70%}.gs-10>.grid-stack-item[gs-w="8"]{width:80%}.gs-10>.grid-stack-item[gs-x="8"]{left:80%}.gs-10>.grid-stack-item[gs-w="9"]{width:90%}.gs-10>.grid-stack-item[gs-x="9"]{left:90%}.gs-10>.grid-stack-item[gs-w="10"]{width:100%}.gs-11>.grid-stack-item{width:9.091%}.gs-11>.grid-stack-item[gs-x="1"]{left:9.091%}.gs-11>.grid-stack-item[gs-w="2"]{width:18.182%}.gs-11>.grid-stack-item[gs-x="2"]{left:18.182%}.gs-11>.grid-stack-item[gs-w="3"]{width:27.273%}.gs-11>.grid-stack-item[gs-x="3"]{left:27.273%}.gs-11>.grid-stack-item[gs-w="4"]{width:36.364%}.gs-11>.grid-stack-item[gs-x="4"]{left:36.364%}.gs-11>.grid-stack-item[gs-w="5"]{width:45.455%}.gs-11>.grid-stack-item[gs-x="5"]{left:45.455%}.gs-11>.grid-stack-item[gs-w="6"]{width:54.545%}.gs-11>.grid-stack-item[gs-x="6"]{left:54.545%}.gs-11>.grid-stack-item[gs-w="7"]{width:63.636%}.gs-11>.grid-stack-item[gs-x="7"]{left:63.636%}.gs-11>.grid-stack-item[gs-w="8"]{width:72.727%}.gs-11>.grid-stack-item[gs-x="8"]{left:72.727%}.gs-11>.grid-stack-item[gs-w="9"]{width:81.818%}.gs-11>.grid-stack-item[gs-x="9"]{left:81.818%}.gs-11>.grid-stack-item[gs-w="10"]{width:90.909%}.gs-11>.grid-stack-item[gs-x="10"]{left:90.909%}.gs-11>.grid-stack-item[gs-w="11"]{width:100%}
.grid-stack { min-height: 100% }
.grid-stack-item-content {
box-sizing: border-box;
background-color: var(--bg-color-darker);
color: var(--text-color);
border: 1px transparent solid;
border-radius: 5px;
box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
}
.grid-stack-item-content:hover {
border-color: var(--border-color);
}
.grid-stack-item[gs-id^="tr-"] .grid-stack-item-content {
border: none;
box-shadow: none;
overflow: hidden;
}
.panel-container {
width: 100%;
height: 100%;
position: relative;
}
.grid-stack-item[gs-id^="tr-"] .grid-stack-item-content {
background-color: transparent;
}
.panel-title {
position: absolute;
top: 0;
left: 50%;
transform: translate(-50%, 0);
background-color: transparent;
color: var(--text-color-darker);
text-align: center;
padding: 0.2em 1em 0.2em 1em;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
user-select: none;
}
.grid-stack:not([mobile-view]) .panel-container:hover .panel-title {
cursor: move;
background-color: var(--bg-color);
color: var(--text-color);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
border: 1px var(--border-color) solid;
border-radius: 0 0 5px 5px;
border-top: 0;
}
.grid-stack-item-removing .panel-container {
background-color: rgba(255, 0, 0, 0.3);
}
.spinner:after {
position: absolute;
top: calc(50% - 32px);
left: calc(50% - 32px);
content: ' ';
display: block;
width: 64px;
height: 64px;
border-radius: 50%;
border: 1px solid var(--text-color-darker);
border-color: var(--text-color-darker) transparent var(--text-color-darker) transparent;
animation: spinner 1.2s linear infinite;
}
@keyframes spinner {
0% { transform: rotate(0deg) }
100% { transform: rotate(360deg) }
}
`;static properties={name:{type:String,reflect:!0},mobileView:{type:Boolean,state:!0}};constructor(){super(),this.yScale=void 0}render(){return at`
`}firstUpdated(){this.grid=GridStack.init({sizeToContent:!1,margin:5,animate:!1,float:!0,cellHeight:206,column:8,columnOpts:{layout:"move",columnMax:8,breakpointForWindow:!0,breakpoints:[{w:420,c:1},{w:800,c:2},{w:1024,c:4},{w:1366,c:6}]},handle:".panel-title",removable:!0,alwaysShowResizeHandle:!1},this.renderRoot.querySelector(".grid-stack"))}async init(h){h.length===0?this.addPanel({type:"text-panel",title:"Quick Instructions",message:`
\u{1F60E} Welcome to your new dashboard!
- Press the ESC (Escape) key on your keyboard, or swipe from the left margin, to show or hide the left menu.
- Click the Add dashboard tile button to add new tiles to your dashboard.
- Rearrange tiles by dragging their titles. Resize tiles by dragging the bottom-right corner.
- Remove tiles by dragging them outside the dashboard grid.
- Remember to click the Save dashboard button when you're happy with the layout.
For more information, refer to the official documentation.
`},2,2,1,0):(this.grid.batchUpdate(!0),h.forEach(u=>this.addPanel(u.config,u.w,u.h,u.x,u.y)),this.grid.batchUpdate(!1)),this.renderRoot.querySelector(".grid-stack").classList.remove("spinner")}applyMobileView(h){this.mobileView=h,this.renderRoot.querySelectorAll(".panel").forEach(u=>u.mobileView=this.mobileView),this.grid.enableResize(!this.mobileView),this.grid.enableMove(!this.mobileView),setTimeout(()=>this.grid.setAnimation(!this.mobileView),1e3)}setRefreshInterval(h){this.interval&&clearInterval(this.interval),h!=0&&(this.interval=setInterval(()=>{this.renderRoot.querySelectorAll(".panel").forEach(u=>u.refresh())},h*60*1e3),console.info(`Setting auto-refresh timer for ${h} minutes`))}setYScale(h){this.yScale=h,this.renderRoot.querySelectorAll("device-panel, attribute-panel").forEach(u=>u.setYScale(h))}setCellHeight(h){this.grid.cellHeight(h,!0)}addPanel(h,u=2,k=1,P=void 0,z=void 0){let L=u,G=k,U=P,K=z,ut=this.grid.engine.nodes.find(it=>it.config?.id==h.id);ut?(L=ut.w,G=ut.h,U=ut.x,K=ut.y,this.grid.removeWidget(ut.el)):h.id=this.randomUUID();let X=`
<${h.type} config='${JSON.stringify(h).replace(/'/g,"'")}' yScale="${this.yScale}" class="panel empty spinner">${h.type}>
${h.title||" "}
`;this.grid.addWidget({w:L,h:G,x:U,y:K,config:h,content:X,id:`${h.noBorder===!0?"tr-":""}${h.id}`})}editPanel(h){this.dispatchEvent(new CustomEvent("edit",{bubbles:!0,detail:h.detail}))}randomUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(h){var u=Math.random()*16|0,k=h=="x"?u:u&3|8;return k.toString(16)})}compact(){this.grid.compact()}getPanelsConfig(){return this.grid.engine.nodes.map(h=>{let u=h.el.querySelector(".panel");return{w:h.w,h:h.h,x:h.x,y:h.y,config:u.decorateConfig(h.config)}})}};var On={"5m":{amount:5,unit:"minute",description:"View data with 5 minutes precision"},"1h":{amount:1,unit:"hour",description:"View data with 1 hour precision"},"1d":{amount:1,unit:"day",description:"View data with 1 day precision"},"1w":{amount:1,unit:"week",description:"View data with 1 week precision"}},Rn=class extends Ct{static styles=Ft`
ul {
margin: 0;
padding: 0;
list-style: none;
background-color: var(--bg-color);
color: var(--text-color);
border: 1px var(--border-color) solid;
border-bottom: 0;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
border-radius: 5px 5px 0 0;
display: flex;
user-select: none;
}
ul li {
list-style-type: none;
display: inline-block;
margin: 0;
padding: .4em 0;
border-right: 1px var(--border-color) solid;
cursor: pointer;
width: 2.85em;
text-align: center;
}
ul li:first-child { border-radius: 4px 0 0 0 }
ul li:last-child { border: 0; border-radius: 0 4px 0 0 }
ul li:hover {
background-color: var(--bg-color-darker);
}
ul li[data-selected] {
background-color: var(--Blue);
color: var(--Base3);
}
.ui-resizable-handle { opacity:0 }
`;static properties={precision:{type:Object,state:!0}};render(){return at`
`}selectPrecision(h){this.precision=h.target.textContent,this.dispatchEvent(new CustomEvent("change",{detail:this.precision}))}};var Te=class _{static colors(){let h=getComputedStyle(document.documentElement);return{BgColor:h.getPropertyValue("--bg-color"),BgColorDarker:h.getPropertyValue("--bg-color-darker"),TextColor:h.getPropertyValue("--text-color"),TextColorDarker:h.getPropertyValue("--text-color-darker"),BorderColor:h.getPropertyValue("--border-color"),Yellow:h.getPropertyValue("--Yellow"),Orange:h.getPropertyValue("--Orange"),Red:h.getPropertyValue("--Red"),Magenta:h.getPropertyValue("--Magenta"),Violet:h.getPropertyValue("--Violet"),Blue:h.getPropertyValue("--Blue"),Cyan:h.getPropertyValue("--Cyan"),Green:h.getPropertyValue("--Green"),Gray:h.getPropertyValue("--Gray")}}static{let h=getComputedStyle(document.documentElement);_.chartColors=[h.getPropertyValue("--Magenta"),h.getPropertyValue("--Blue")]}};var ul={callbacks:{afterZoom:function(){}}},gl={id:"crosshair",afterInit:function(_){if(_.config.options.scales.x){var h=_.config.options.scales.x.type;h!=="linear"&&h!=="time"&&h!=="category"&&h!=="logarithmic"||(_.options.plugins.crosshair===void 0&&(_.options.plugins.crosshair=ul),_.crosshair={x:null,originalXRange:null,button:null,dragStarted:!1,dragStartX:null,dragEndX:null,ignoreNextEvents:0,canStartDrag:!1,timeout:null,resetZoom:()=>this.resetZoom(_),panZoom:u=>this.panZoom(_,u)},window.addEventListener("crosshair",u=>this.syncCrosshair(_,u.detail)))}},syncCrosshair(_,{id:h,time:u}){if(_.id===h)return;var k=this.getXScale(_);if(!k)return;if(u===null){if(_.crosshair.x===null)return;_.crosshair.x=null,_.draw();return}u=Math.min(Math.max(u,k.min),k.max);let P=Math.round(k.getPixelForValue(u));_.crosshair.x!=P&&(_.crosshair.x=P,_.draw())},panZoom:function(_,h){if(_.crosshair.originalXRange===null)return;let{min:u,max:k}=_.crosshair.originalXRange,P=_.options.scales.x.min,z=_.options.scales.x.max;if(P===u&&h==="left"||z===k&&h==="right")return;let L=z-P,G=L/10;h==="left"?(_.options.scales.x.min=Math.max(P-G,u),_.options.scales.x.max=_.options.scales.x.min+L):(_.options.scales.x.max=Math.min(z+G,k),_.options.scales.x.min=_.options.scales.x.max-L),_.update()},getOption:function(_,h,u){let k=_.options.plugins.crosshair[h]?_.options.plugins.crosshair[h][u]:void 0;return k!==void 0?k:ul[h][u]},getXScale:function(_){return _.data.datasets.length?_.scales[_.getDatasetMeta(0).xAxisID]:null},getYScale:function(_){return _.scales[_.getDatasetMeta(0).yAxisID]},afterEvent:function(_,h){if(_.config.options.scales.x.length==0)return!1;var u=this.getXScale(_);if(!u)return!1;if(_.crosshair.ignoreNextEvents>0)return _.crosshair.ignoreNextEvents-=1,!1;let k=u.getPixelForValue(u.min),P=u.getPixelForValue(u.max),z=h.event;z.x=Math.round(Math.min(Math.max(z.x,k),P));let L=Math.round(u.getValueForPixel(z.x));if(z.type==="click"){_.crosshair.canStartDrag=!0,_.crosshair.dragStarted=!1,clearTimeout(_.crosshair.timeout),_.crosshair.timeout=setTimeout(()=>_.crosshair.canStartDrag=!1,1e3);return}if(z.type==="mousedown"&&!_.crosshair.dragStarted){if(z.native.type==="mousedown"&&(_.crosshair.canStartDrag=!0),!_.crosshair.canStartDrag)return;_.crosshair.x=z.x,_.crosshair.dragStartX=z.x,_.crosshair.dragStarted=!0,_.draw();return}if(z.type==="mouseout"){_.crosshair.x=null,_.crosshair.canStartDrag=!1,_.crosshair.dragStarted=!1,_.draw(),window.dispatchEvent(new CustomEvent("crosshair",{detail:{id:_.id,time:null}}));return}if(_.crosshair.dragStarted&&z.type==="mouseup"){if(_.crosshair.dragStarted=!1,Math.abs(_.crosshair.dragStartX-z.x)<3)return _.draw(),!1;var G=u.getValueForPixel(_.crosshair.dragStartX);this.doZoom(_,G,L),z.native.ctrlKey&&Chart.helpers.each(Chart.instances,U=>{U.id!=_.id&&this.doZoom(U,G,L)});return}if(_.crosshair.x==z.x)return!1;_.crosshair.x=z.x,_.draw(),window.dispatchEvent(new CustomEvent("crosshair",{detail:{id:_.id,time:L}}))},afterDraw:function(_){return _.crosshair.x===null?!1:(_.crosshair.dragStarted?this.drawZoombox(_):this.drawTraceLine(_),!0)},resetZoom:function(_,h=!1){_.crosshair.originalXRange!==null&&(_.options.scales.x.min=_.crosshair.originalXRange.min,_.options.scales.x.max=_.crosshair.originalXRange.max,_.crosshair.button&&_.crosshair.button.parentNode&&(_.crosshair.button.parentNode.removeChild(_.crosshair.button),_.crosshair.button=null),_.update(),this.getOption(_,"callbacks","afterZoom")({chart:_}),h&&Chart.helpers.each(Chart.instances,u=>{u.id!=_.id&&this.resetZoom(u)}))},doZoom:function(_,h,u){if(_.crosshair.dragStarted=!1,h==u||(_.crosshair.originalXRange===null&&(_.crosshair.originalXRange={min:_.scales.x.min,max:_.scales.x.max}),h>u&&([h,u]=[u,h]),h=Math.max(h,_.crosshair.originalXRange.min),u=Math.min(u,_.crosshair.originalXRange.max),h>u))return!1;if(_.crosshair.button==null){var k=document.createElement("button"),P=document.createTextNode("\u25C0\u2022\u2022\u2022\u25B6");k.appendChild(P),k.className="reset-zoom",k.setAttribute("title","Reset Zoom"),k.addEventListener("click",z=>this.resetZoom(_,z.ctrlKey)),_.canvas.parentNode.appendChild(k),_.crosshair.button=k}_.options.scales.x.min=h,_.options.scales.x.max=u,_.update(),_.crosshair.ignoreNextEvents=2,this.getOption(_,"callbacks","afterZoom")(h,u)},drawZoombox:function(_){_.ctx.beginPath(),_.ctx.rect(_.crosshair.dragStartX,_.chartArea.top,_.crosshair.x-_.crosshair.dragStartX,_.chartArea.bottom-_.chartArea.top),_.ctx.lineWidth=1,_.ctx.strokeStyle="#48F",_.ctx.fillStyle="rgba(66,133,244,0.2)",_.ctx.fill(),_.ctx.fillStyle="",_.ctx.stroke(),_.ctx.closePath()},drawTraceLine:function(_){_.crosshair.x!=null&&(_.ctx.beginPath(),_.ctx.setLineDash([]),_.ctx.moveTo(_.crosshair.x,_.chartArea.top),_.ctx.lineWidth=1,_.ctx.strokeStyle="#dc322f",_.ctx.lineTo(_.crosshair.x,_.chartArea.bottom),_.ctx.stroke(),_.ctx.setLineDash([]))}};Chart.register(gl);var Vo=Chart.Tooltip.positioners;Vo.custom=function(_,h){let u=Vo.nearest(_,h);if(u===!1)return!1;let k=this.chart.chartArea;return u.yk.bottom-25&&(u.yAlign="bottom",u.xAlign=u.x<(k.left+k.right)/2?"left":"right"),u};Vo.mouse=function(_,h){if(!_?.length)return!1;let u=h,k=this.chart.chartArea;return u.yk.bottom-25&&(u.yAlign="bottom",u.xAlign=u.x<(k.left+k.right)/2?"left":"right"),u};var Os=Chart._adapters._date.prototype;function sc(_,h,u){return`${Os.format(Os.add(_,0-h.amount,h.unit),u[h.unit])} - ${Os.format(_,u[h.unit])}`}function nc(_,h,u){return`${Os.format(_[0],u[h.unit])} - ${Os.format(_[1],u[h.unit])}`}var re=class _{static lineConfig(){let h=Te.colors();return{type:"line",options:{events:["click","mousedown","mousemove","mouseup","mouseout","touchstart","touchmove","touchend"],parsing:!1,normalized:!0,responsive:!0,maintainAspectRatio:!1,onResize:u=>_.updateChartType(u),animation:{duration:500,onComplete:({initial:u,chart:k})=>u?_.updateChartType(k):void 0},layout:{padding:{top:25,bottom:4}},stacked:!1,pointStyle:!1,scales:{x:{type:"time",time:{minUnit:"minute",displayFormats:{minute:"d LLL HH:mm",hour:"d LLL HH:mm",day:"d LLL",week:"d LLL"}},title:{display:!1},ticks:{color:h.TextColorDarker,maxRotation:0,autoSkipPadding:15},grid:{color:h.TextColorDarker+"44"}}},interaction:{mode:"nearest",axis:"x",intersect:!1},plugins:{legend:{display:!1},tooltip:{itemSort:(u,k)=>k.raw.y-u.raw.y,callbacks:{title:u=>sc(u[0].parsed.x,On[u[0].chart.precision],u[0].chart.options.scales.x.time.displayFormats),label:u=>` ${u.dataset.label}: ${u.parsed.y}${u.dataset.unit}`},backgroundColor:h.BgColorDarker,titleColor:h.TextColor,bodyColor:h.TextColorDarker,borderColor:h.BorderColor,borderWidth:1,position:"custom",intersect:!1},crosshair:{line:{color:h.Red,width:1},zoom:{zoomButtonText:"\u25C0\u2022\u2022\u2022\u25B6"},callbacks:{afterZoom:u=>this.updateChartType(u.chart)}}}}}}static statusmapConfig(){let h=Te.colors();return{type:"bar",options:{events:["mousedown","mousemove","mouseup","mouseout","click","touchstart","touchmove","touchend"],barPercentage:1,categoryPercentage:.9,indexAxis:"y",maintainAspectRatio:!1,layout:{padding:{top:25,bottom:4,right:10}},scales:{x:{type:"time",time:{minUnit:"minute",displayFormats:{minute:"d LLL HH:mm",hour:"d LLL HH:mm",day:"d LLL",week:"d LLL"}},title:{display:!1},ticks:{color:h.TextColorDarker,maxRotation:0,autoSkipPadding:15},grid:{color:h.TextColorDarker+"44"}},y:{beginAtZero:!0,stacked:!0}},plugins:{legend:{display:!1},tooltip:{itemSort:(u,k)=>k.raw.y-u.raw.y,callbacks:{title:u=>nc(u[0].raw.x,On[u[0].chart.precision],u[0].chart.options.scales.x.time.displayFormats),label:u=>` ${u.dataset.label}: ${u.raw.v}${u.dataset.unit}`},backgroundColor:h.BgColorDarker,titleColor:h.TextColor,bodyColor:h.TextColorDarker,borderColor:h.BorderColor,borderWidth:1,position:"mouse",intersect:!0},crosshair:{callbacks:{afterZoom:u=>this.updatePointStyle(u.chart)}}}}}}static updateChartType(h){return this.updatePointStyle(h)}static updatePointStyle(h){if(h.scales.x===void 0||h.data.datasets[0]===void 0)return;let u=h.scales.x.min,k=h.scales.x.max,z=h.data.datasets[0].data.filter(G=>G.x>=u&&G.x<=k).length,L=h.width/z>30?"circle":!1;h.data.datasets[0].pointStyle!==L&&(h.data.datasets.forEach(G=>G.pointStyle=L),h.update())}static prettyName(h){return(h[0].toUpperCase()+h.slice(1)).replace(/([A-Z])(?=[A-Z][a-z])|([a-z])(?=[A-Z])/g,"$& ").replace("Hub ","")}};var Ln=class extends Ct{static styles=Ft`
:host {
display: block;
width: 100%;
height: 100%;
}
canvas {
width: 100%;
height: 100%;
touch-action: pan-y;
}
:host(.empty) canvas { visibility: hidden }
precision-selector {
position: absolute;
bottom: 0;
left: 50%;
transform: translate(-50%, 0);
visibility: hidden;
}
:host(:hover) precision-selector,
:host(:hover) nav {
visibility: visible;
}
aside {
position: absolute;
top: 50%;
left: 0;
transform: translate(0, -50%);
display: block;
color: var(--text-color-darker);
width: 100%;
text-align: center;
}
.reset-zoom {
position: absolute;
top: 0px;
right: 0px;
border: none;
background-color: var(--Blue);
color: var(--Base3);
border-radius: 0 0 0 5px;
padding: 5px 10px;
line-height: 1rem;
z-index: 100;
cursor: pointer;
letter-spacing: 1px;
}
nav {
position: absolute;
top: 0px; left: 2px;
cursor: pointer;
visibility: hidden;
}
`;static properties={config:{type:Object,reflect:!0},yScale:{type:String,reflect:!0},mobileView:{type:Boolean,state:!0},chart:{type:Object,state:!0},nodata:{type:Boolean,state:!0}};render(){return at`
${this.nodata===!0?at``:""}
`}updated(h){h.mobileView!=this.mobileView}async connectedCallback(){super.connectedCallback(),this.config.precision===void 0&&(this.config.precision="5m")}async firstUpdated(){await this.initChart()}onKeyDown(h){this.chart!==void 0&&(h.keyCode===37?this.chart.crosshair.panZoom("left"):h.keyCode===39&&this.chart.crosshair.panZoom("right"))}async initChart(){let h=re.lineConfig();this.classList.add("spinner");let u=await Nt.fetchSupportedAttributes(),k=Te.colors(),P=await Nt.fetchDeviceData(this.config);this.nodata=P.attr1.length==0;let z=re.prettyName(this.config.attr1),L=u[this.config.attr1].unit,G=[{label:z,data:P.attr1,pointStyle:!1,backgroundColor:k.Blue+"44",borderColor:k.Blue,borderWidth:1.2,tension:.5,fill:this.config.mm1!==!0&&this.config.mm2!==!0,yAxisID:"attr1",unit:L}];if(this.config.mm1&&(G.push({label:`${z} min`,data:P.min1,pointStyle:!1,backgroundColor:k.Blue+"22",borderColor:k.Blue,borderWidth:1.2,borderDash:[2,2],tension:.5,fill:"+1",yAxisID:"attr1",unit:L}),G.push({label:`${z} max`,data:P.max1,pointStyle:!1,borderColor:k.Blue,backgroundColor:k.Blue+"22",borderWidth:1.2,borderDash:[2,2],tension:.5,fill:!1,yAxisID:"attr1",unit:L})),h.options.scales.attr1={position:"left",display:!0,title:{display:!0,text:`${z} ${L}`,color:k.Blue},ticks:{color:k.TextColorDarker,precision:0},grid:{color:k.TextColorDarker+"33"}},this.attr1Min=u[this.config.attr1].min,this.attr1Max=u[this.config.attr1].max,this.yScale==="fixed"&&(this.attr1Min!==void 0&&(h.options.scales.attr1.suggestedMin=this.attr1Min),this.attr1Max!==void 0&&(h.options.scales.attr1.suggestedMax=this.attr1Max)),this.config.attr2!==void 0){let U=re.prettyName(this.config.attr2),K=u[this.config.attr2].unit;G.push({label:U,data:P.attr2,pointStyle:!1,backgroundColor:k.Green+"44",borderColor:k.Green,borderWidth:1.2,tension:.5,fill:this.config.mm1!==!0&&this.config.mm2!==!0,yAxisID:"attr2",unit:K}),this.config.mm2&&(G.push({label:`${U} min`,data:P.min2,pointStyle:!1,backgroundColor:k.Green+"22",borderColor:k.Green,borderWidth:1.2,borderDash:[2,2],tension:.5,fill:"+1",yAxisID:"attr2",unit:K}),G.push({label:`${U} max`,data:P.max2,pointStyle:!1,borderColor:k.Green,backgroundColor:k.Green+"22",borderWidth:1.2,borderDash:[2,2],tension:.5,fill:!1,yAxisID:"attr2",unit:K})),h.options.scales.attr2={position:"right",display:!0,title:{display:!0,text:`${U} ${K}`,color:k.Green},ticks:{color:k.TextColorDarker,precision:0},grid:{drawOnChartArea:!1}},this.attr2Min=u[this.config.attr2].min,this.attr2Max=u[this.config.attr2].max,this.yScale==="fixed"&&(this.attr2Min!==void 0&&(h.options.scales.attr2.suggestedMin=this.attr2Min),this.attr2Max!==void 0&&(h.options.scales.attr2.suggestedMax=this.attr2Max))}h.data={datasets:G},this.chart!==void 0&&this.chart.destroy(),this.chart=new Chart(this.renderRoot.querySelector("canvas"),h),this.chart.precision=this.config.precision,re.updateChartType(this.chart),setTimeout(()=>this.classList.remove("empty","spinner"),200)}async changePrecision(h){this.chart.crosshair.resetZoom(),this.config.precision=h.detail,await this.refresh()}async refresh(){await this.initChart()}editPanel(){this.dispatchEvent(new CustomEvent("edit",{bubbles:!0,detail:this.config}))}decorateConfig(h){return{...h,...this.config}}setYScale(h){this.yScale=h,this.chart&&(h=="auto"?(delete this.chart.options.scales.attr1.suggestedMin,delete this.chart.options.scales.attr1.suggestedMax,this.config.attr2!==void 0&&(delete this.chart.options.scales.attr2.suggestedMin,delete this.chart.options.scales.attr2.suggestedMax)):(this.attr1Min!==void 0&&(this.chart.options.scales.attr1.suggestedMin=this.attr1Min),this.attr1Max!==void 0&&(this.chart.options.scales.attr1.suggestedMax=this.attr1Max),this.attr2Min!==void 0&&(this.chart.options.scales.attr2.suggestedMin=this.attr2Min),this.attr2Max!==void 0&&(this.chart.options.scales.attr2.suggestedMax=this.attr2Max)),this.chart.update())}},zn=class extends Ct{static properties={config:{type:Object,reflect:!0},devices:{type:Object,state:!0},supportedAttributes:{type:Object,state:!0},attributes:{type:Object,state:!0}};constructor(){super(),this.config={},this.devices=void 0,this.supportedAttributes=void 0,this.attributes=void 0}render(){return at`
${this.config.attr1!==void 0&&this.attributes.length>1?this.renderOptionalAttributesSelect():""}
`}async connectedCallback(){if(super.connectedCallback(),await Nt.fetchMonitoredDevices().then(u=>{this.devices=u}),await Nt.fetchSupportedAttributes().then(u=>{this.supportedAttributes=u}),this.config.dev===void 0)return;let h=this.devices.find(u=>u.id==this.config.dev);this.attributes=h.attrs.sort()}createRenderRoot(){return this}renderDevicesSelect(){return at`
`}renderAttributesSelect(){return at`
${this.config.attr1?at`
`:""}
`}renderOptionalAttributesSelect(){return at`
`}onDeviceSelect(h){let u=h.target.value!==""?h.target.value:void 0;if(u==this.config.dev)return;if(this.config={...this.config,dev:u,attr1:void 0,attr2:void 0,mm1:!1,mm2:!1,z1:!1,z2:!1},this.config.dev===void 0){this.attributes=void 0;return}let k=this.devices.find(P=>P.id==u);this.attributes=k.attrs.sort(),this.dispatchEvent(new CustomEvent("suggestTitle",{detail:k.name})),setTimeout(()=>{let P=this.renderRoot.querySelector("#attr1");P.scrollIntoView({behavior:"smooth",block:"center"}),P.focus({preventScroll:!0})},0)}onAttribute1Select(h){let u=h.target.value!==""?h.target.value:void 0;u!=this.config.attr1&&(this.config={...this.config,attr1:u,mm1:!1,z1:!1},setTimeout(()=>{let k=this.renderRoot.querySelector("#attr1");k.scrollIntoView({behavior:"smooth",block:"center"}),k.focus({preventScroll:!0})},0))}onAttribute2Select(h){let u=h.target.value!==""?h.target.value:void 0;u!=this.config.attr2&&(this.config={...this.config,attr2:u,mm2:!1,z2:!1},setTimeout(()=>{let k=this.renderRoot.querySelector("#attr2");k.scrollIntoView({behavior:"smooth",block:"center"}),k.focus({preventScroll:!0})},0))}decorateConfig(h){return{...h,dev:parseInt(this.config.dev),precision:"5m",attr1:this.config.attr1,attr2:this.config.attr2,mm1:this.config.mm1===!0?!0:void 0,mm2:this.config.mm2===!0?!0:void 0,z1:this.config.z1===!0?!0:void 0,z2:this.config.z2===!0?!0:void 0}}};var $n=class extends Ct{static styles=Ft`
:host {
display: block;
width: 100%;
height: 100%;
}
canvas {
width: 100%;
height: 100%;
touch-action: pan-y;
}
:host(.empty) canvas { visibility: hidden }
precision-selector {
position: absolute;
bottom: 0;
left: 50%;
transform: translate(-50%, 0);
visibility: hidden;
}
:host(:hover) precision-selector,
:host(:hover) nav {
visibility: visible;
}
aside {
position: absolute;
top: 50%;
left: 0;
transform: translate(0, -50%);
display: block;
color: var(--text-color-darker);
width: 100%;
text-align: center;
}
.reset-zoom {
position: absolute;
top: 0px;
right: 0px;
border: none;
background-color: var(--Blue);
color: var(--Base3);
border-radius: 0 0 0 5px;
padding: 5px 10px;
line-height: 1rem;
z-index: 100;
cursor: pointer;
letter-spacing: 1px;
}
aside {
position: absolute;
top: 0;
right: 0;
}
nav {
position: absolute;
top: 0px; left: 2px;
cursor: pointer;
visibility: hidden;
}
`;static properties={config:{type:Object,reflect:!0},yScale:{type:String,reflect:!0},mobileView:{type:Boolean,state:!0},chart:{type:Object,state:!0},nodata:{type:Boolean,state:!0}};render(){return at`
${this.nodata===!0?at``:""}
`}updated(h){h.mobileView!=this.mobileView}async connectedCallback(){super.connectedCallback(),this.config.precision===void 0&&(this.config.precision="5m")}async firstUpdated(){await this.initChart()}onKeyDown(h){this.chart!==void 0&&(h.keyCode===37?this.chart.crosshair.panZoom("left"):h.keyCode===39&&this.chart.crosshair.panZoom("right"))}async initChart(){this.classList.add("spinner");let h=await Nt.fetchSupportedAttributes(),u=await Nt.fetchMonitoredDevices(),k=Te.colors(),P=await Nt.fetchAttributeData(this.config),z=re.lineConfig(),L=[];for(let U of this.config.devs)L.push({label:u.find(K=>K.id==U).name,data:P[`dev_${U}`],pointStyle:!1,borderWidth:1.2,tension:.5,unit:h[this.config.attr].unit,ref:`dev_${U}`});if(this.config.devs.length<=2)for(let U=0;Uthis.classList.remove("empty","spinner"),200)}async changePrecision(h){this.chart.crosshair.resetZoom(),this.config.precision=h.detail,this.config.precision=h.detail,await this.refresh()}async refresh(){await this.initChart()}editPanel(){this.dispatchEvent(new CustomEvent("edit",{bubbles:!0,detail:this.config}))}decorateConfig(h){return{...h,...this.config}}setYScale(h){this.yScale=h,this.chart&&(h=="auto"?(delete this.chart.options.scales.y.suggestedMin,delete this.chart.options.scales.y.suggestedMax):(this.chart.options.scales.y.suggestedMin=this.attrMin,this.chart.options.scales.y.suggestedMax=this.attrMax),this.chart.update())}},Hn=class extends Ct{static properties={config:{type:Object,reflect:!0},devices:{type:Object,state:!0},attributes:{type:Object,state:!0}};constructor(){super(),this.config={devs:[]},this.devices=void 0,this.attributes=void 0}render(){return at`
${this.config.attr&&this.devices?this.renderDevicesSelect():""}
`}async connectedCallback(){super.connectedCallback(),this.devices=await Nt.fetchMonitoredDevices();let h=new Set;this.devices.forEach(u=>u.attrs.forEach(k=>h.add(k))),this.attributes=[...h].sort()}createRenderRoot(){return this}renderAttributesSelect(){return at`
${this.config.attr?at`
`:""}
`}renderDevicesSelect(){let h=this.devices.filter(u=>u.attrs.includes(this.config.attr));return at`
`}onAttributeSelect(h){let u=h.target.value!==""?h.target.value:void 0;this.config={...this.config,attr:u,z:!1,devs:[]},u&&this.dispatchEvent(new CustomEvent("suggestTitle",{detail:re.prettyName(u)}))}onDeviceSelect(){this.config={...this.config,devs:[...this.renderRoot.querySelectorAll('#devlist input[type="checkbox"]:checked')].map(h=>h.value)}}decorateConfig(h){return{...h,attr:this.config.attr,devs:this.config.devs.map(u=>parseInt(u)),z:this.config.z===!0?!0:void 0}}};var Nn=class extends Ct{static styles=Ft`
:host {
display: block;
width: 100%;
height: 100%;
}
canvas {
width: 100%;
height: 100%;
touch-action: pan-y;
}
:host(.empty) canvas { visibility: hidden }
precision-selector {
position: absolute;
bottom: 0;
left: 50%;
transform: translate(-50%, 0);
visibility: hidden;
}
:host(:hover) precision-selector,
:host(:hover) nav {
visibility: visible;
}
aside {
position: absolute;
top: 50%;
left: 0;
transform: translate(0, -50%);
display: block;
color: var(--text-color-darker);
width: 100%;
text-align: center;
}
.reset-zoom {
position: absolute;
top: 0px;
right: 0px;
border: none;
background-color: var(--Blue);
color: var(--Base3);
border-radius: 0 0 0 5px;
padding: 5px 10px;
line-height: 1rem;
z-index: 100;
cursor: pointer;
letter-spacing: 1px;
}
nav {
position: absolute;
top: 0px; left: 2px;
cursor: pointer;
visibility: hidden;
}
`;static properties={config:{type:Object,reflect:!0},mobileView:{type:Boolean,state:!0},chart:{type:Object,state:!0},nodata:{type:Boolean,state:!0}};render(){return at`
${this.nodata===!0?at``:""}
`}updated(h){h.mobileView!=this.mobileView}async connectedCallback(){super.connectedCallback(),this.config.precision===void 0&&(this.config.precision="5m")}async firstUpdated(){await this.initChart()}onKeyDown(h){this.chart!==void 0&&(h.keyCode===37?this.chart.crosshair.panZoom("left"):h.keyCode===39&&this.chart.crosshair.panZoom("right"))}async initChart(){this.classList.add("spinner");let h=await Nt.fetchSupportedAttributes(),u=await Nt.fetchMonitoredDevices(),k=Te.colors(),P=await Nt.fetchStatusmapData(this.config);if(this.nodata=Object.entries(P).find(ut=>ut[1]?.length>0)===void 0,this.nodata){this.chart!==void 0&&this.chart.destroy(),setTimeout(()=>this.classList.remove("empty","spinner"),200);return}let z=re.statusmapConfig(),L=[],G=[],U=1/0,K=0;this.config.ds.forEach(({dev:ut,attr:X})=>{let it=u.find(kt=>kt.id==ut).name,ft=h[X].unit,bt=re.prettyName(X),Tt=`${it}: ${bt}`;L.push(Tt);let Dt=P[`${ut}_${X}`].map(kt=>({...kt,y:Tt}));G.push({label:bt,unit:ft,backgroundColor:kt=>`rgba(133, 153, 0, ${Math.round(Math.min(100,Math.max(0,kt.raw?.v||0))*9)/1e3+.1})`,borderColor:k.Green,data:[...Dt]}),U=Math.min(U,Dt[0].x[0]),K=Math.max(K,Dt.pop().x[1])}),z.data={labels:L,datasets:G},z.options.scales.x.min=U,z.options.scales.x.max=K,this.chart!==void 0&&this.chart.destroy(),this.chart=new Chart(this.renderRoot.querySelector("canvas"),z),this.chart.precision=this.config.precision,setTimeout(()=>this.classList.remove("empty","spinner"),200)}async changePrecision(h){this.chart?.crosshair.resetZoom(),this.config.precision=h.detail,await this.refresh()}async refresh(){await this.initChart()}editPanel(){this.dispatchEvent(new CustomEvent("edit",{bubbles:!0,detail:this.config}))}decorateConfig(h){return{...h,...this.config}}},In=class extends Ct{static properties={config:{type:Object,reflect:!0},devices:{type:Object,state:!0},supportedAttributes:{type:Object,state:!0},attributes:{type:Object,state:!0},dev:{type:Number,state:!0},add:{type:Boolean,state:!0}};constructor(){super(),this.config={ds:[]},this.devices=void 0,this.supportedAttributes=void 0,this.attributes=void 0,this.dev=void 0,this.add=!0}render(){return at`
${this.devices&&this.config.ds?.length?this.renderDatasets():""}
`}async connectedCallback(){super.connectedCallback(),this.devices=await Nt.fetchMonitoredDevices(),this.supportedAttributes=await Nt.fetchSupportedAttributes(),this.config.ds===void 0&&(this.config={...this.config,ds:[]}),this.add=!this.config.ds.length}createRenderRoot(){return this}renderDatasets(){return this.config.ds.map((h,u)=>at`