diff --git a/www/community/lovelace-wallpanel/wallpanel.js b/www/community/lovelace-wallpanel/wallpanel.js index 29ada67f..c300c54a 100644 --- a/www/community/lovelace-wallpanel/wallpanel.js +++ b/www/community/lovelace-wallpanel/wallpanel.js @@ -1 +1 @@ -!function(){"use strict";function e(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function n(n){for(var r=1;r0&&e[0]<4?1:+(e[0]+e[1])),!t&&r&&(!(e=r.match(/Edge\/(\d+)/))||e[1]>=74)&&(e=r.match(/Chrome\/(\d+)/))&&(t=+e[1]),Y=t}function Ee(){if($)return X;$=1;var e=we(),t=v(),n=s().String;return X=!!Object.getOwnPropertySymbols&&!t(function(){var t=Symbol("symbol detection");return!n(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&e&&e<41})}function xe(){if(Q)return J;Q=1;var e=Ee();return J=e&&!Symbol.sham&&"symbol"==typeof Symbol.iterator}function Se(){if(K)return Z;K=1;var e=Ae(),t=ve(),n=_e(),r=xe(),i=Object;return Z=r?function(e){return"symbol"==typeof e}:function(r){var o=e("Symbol");return t(o)&&n(o.prototype,i(r))}}function Ce(){if(te)return ee;te=1;var e=String;return ee=function(t){try{return e(t)}catch(e){return"Object"}}}function Ie(){if(re)return ne;re=1;var e=ve(),t=Ce(),n=TypeError;return ne=function(r){if(e(r))return r;throw new n(t(r)+" is not a function")}}function Te(){if(oe)return ie;oe=1;var e=Ie(),t=me();return ie=function(n,r){var i=n[r];return t(i)?void 0:e(i)}}function Re(){if(se)return ae;se=1;var e=_(),t=ve(),n=ye(),r=TypeError;return ae=function(i,o){var a,s;if("string"===o&&t(a=i.toString)&&!n(s=e(a,i)))return s;if(t(a=i.valueOf)&&!n(s=e(a,i)))return s;if("string"!==o&&t(a=i.toString)&&!n(s=e(a,i)))return s;throw new r("Can't convert object to primitive value")}}var ke,Oe,Pe,Me,Le,Be,De,Ue,Fe,Ne,je,We,ze,He,Ge,qe,Ye,Ve,Xe,$e,Je,Qe,Ze,Ke,et={exports:{}};function tt(){return Oe?ke:(Oe=1,ke=!1)}function nt(){if(Me)return Pe;Me=1;var e=s(),t=Object.defineProperty;return Pe=function(n,r){try{t(e,n,{value:r,configurable:!0,writable:!0})}catch(t){e[n]=r}return r}}function rt(){if(Le)return et.exports;Le=1;var e=tt(),t=s(),n=nt(),r="__core-js_shared__",i=et.exports=t[r]||n(r,{});return(i.versions||(i.versions=[])).push({version:"3.43.0",mode:e?"pure":"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.43.0/LICENSE",source:"https://github.com/zloirock/core-js"}),et.exports}function it(){if(De)return Be;De=1;var e=rt();return Be=function(t,n){return e[t]||(e[t]=n||{})}}function ot(){if(Fe)return Ue;Fe=1;var e=ge(),t=Object;return Ue=function(n){return t(e(n))}}function at(){if(je)return Ne;je=1;var e=he(),t=ot(),n=e({}.hasOwnProperty);return Ne=Object.hasOwn||function(e,r){return n(t(e),r)}}function st(){if(ze)return We;ze=1;var e=he(),t=0,n=Math.random(),r=e(1.1.toString);return We=function(e){return"Symbol("+(void 0===e?"":e)+")_"+r(++t+n,36)}}function ct(){if(Ge)return He;Ge=1;var e=s(),t=it(),n=at(),r=st(),i=Ee(),o=xe(),a=e.Symbol,c=t("wks"),l=o?a.for||a:a&&a.withoutSetter||r;return He=function(e){return n(c,e)||(c[e]=i&&n(a,e)?a[e]:l("Symbol."+e)),c[e]}}function lt(){if(Ye)return qe;Ye=1;var e=_(),t=ye(),n=Se(),r=Te(),i=Re(),o=ct(),a=TypeError,s=o("toPrimitive");return qe=function(o,c){if(!t(o)||n(o))return o;var l,u=r(o,s);if(u){if(void 0===c&&(c="default"),l=e(u,o,c),!t(l)||n(l))return l;throw new a("Can't convert object to primitive value")}return void 0===c&&(c="number"),i(o,c)}}function ut(){if(Xe)return Ve;Xe=1;var e=lt(),t=Se();return Ve=function(n){var r=e(n,"string");return t(r)?r:r+""}}function ht(){if(Je)return $e;Je=1;var e=s(),t=ye(),n=e.document,r=t(n)&&t(n.createElement);return $e=function(e){return r?n.createElement(e):{}}}function dt(){if(Ze)return Qe;Ze=1;var e=y(),t=v(),n=ht();return Qe=!e&&!t(function(){return 7!==Object.defineProperty(n("div"),"a",{get:function(){return 7}}).a})}function ft(){if(Ke)return p;Ke=1;var e=y(),t=_(),n=le(),r=ue(),i=pe(),o=ut(),a=at(),s=dt(),c=Object.getOwnPropertyDescriptor;return p.f=e?c:function(e,l){if(e=i(e),l=o(l),s)try{return c(e,l)}catch(e){}if(a(e,l))return r(!t(n.f,e,l),e[l])},p}var mt,gt,pt,vt,yt,At,_t,bt={};function wt(){if(gt)return mt;gt=1;var e=y(),t=v();return mt=e&&t(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype})}function Et(){if(vt)return pt;vt=1;var e=ye(),t=String,n=TypeError;return pt=function(r){if(e(r))return r;throw new n(t(r)+" is not an object")}}function xt(){if(yt)return bt;yt=1;var e=y(),t=dt(),n=wt(),r=Et(),i=ut(),o=TypeError,a=Object.defineProperty,s=Object.getOwnPropertyDescriptor,c="enumerable",l="configurable",u="writable";return bt.f=e?n?function(e,t,n){if(r(e),t=i(t),r(n),"function"==typeof e&&"prototype"===t&&"value"in n&&u in n&&!n[u]){var o=s(e,t);o&&o[u]&&(e[t]=n.value,n={configurable:l in n?n[l]:o[l],enumerable:c in n?n[c]:o[c],writable:!1})}return a(e,t,n)}:a:function(e,n,s){if(r(e),n=i(n),r(s),t)try{return a(e,n,s)}catch(e){}if("get"in s||"set"in s)throw new o("Accessors not supported");return"value"in s&&(e[n]=s.value),e},bt}function St(){if(_t)return At;_t=1;var e=y(),t=xt(),n=ue();return At=e?function(e,r,i){return t.f(e,r,n(1,i))}:function(e,t,n){return e[t]=n,e}}var Ct,It,Tt,Rt,kt,Ot,Pt,Mt,Lt,Bt,Dt,Ut,Ft,Nt,jt,Wt={exports:{}};function zt(){if(It)return Ct;It=1;var e=y(),t=at(),n=Function.prototype,r=e&&Object.getOwnPropertyDescriptor,i=t(n,"name"),o=i&&"something"===function(){}.name,a=i&&(!e||e&&r(n,"name").configurable);return Ct={EXISTS:i,PROPER:o,CONFIGURABLE:a}}function Ht(){if(Rt)return Tt;Rt=1;var e=he(),t=ve(),n=rt(),r=e(Function.toString);return t(n.inspectSource)||(n.inspectSource=function(e){return r(e)}),Tt=n.inspectSource}function Gt(){if(Mt)return Pt;Mt=1;var e=it(),t=st(),n=e("keys");return Pt=function(e){return n[e]||(n[e]=t(e))}}function qt(){return Bt?Lt:(Bt=1,Lt={})}function Yt(){if(Ut)return Dt;Ut=1;var e,t,n,r=function(){if(Ot)return kt;Ot=1;var e=s(),t=ve(),n=e.WeakMap;return kt=t(n)&&/native code/.test(String(n))}(),i=s(),o=ye(),a=St(),c=at(),l=rt(),u=Gt(),h=qt(),d="Object already initialized",f=i.TypeError,m=i.WeakMap;if(r||l.state){var g=l.state||(l.state=new m);g.get=g.get,g.has=g.has,g.set=g.set,e=function(e,t){if(g.has(e))throw new f(d);return t.facade=e,g.set(e,t),t},t=function(e){return g.get(e)||{}},n=function(e){return g.has(e)}}else{var p=u("state");h[p]=!0,e=function(e,t){if(c(e,p))throw new f(d);return t.facade=e,a(e,p,t),t},t=function(e){return c(e,p)?e[p]:{}},n=function(e){return c(e,p)}}return Dt={set:e,get:t,has:n,enforce:function(r){return n(r)?t(r):e(r,{})},getterFor:function(e){return function(n){var r;if(!o(n)||(r=t(n)).type!==e)throw new f("Incompatible receiver, "+e+" required");return r}}}}function Vt(){if(Ft)return Wt.exports;Ft=1;var e=he(),t=v(),n=ve(),r=at(),i=y(),o=zt().CONFIGURABLE,a=Ht(),s=Yt(),c=s.enforce,l=s.get,u=String,h=Object.defineProperty,d=e("".slice),f=e("".replace),m=e([].join),g=i&&!t(function(){return 8!==h(function(){},"length",{value:8}).length}),p=String(String).split("String"),A=Wt.exports=function(e,t,n){"Symbol("===d(u(t),0,7)&&(t="["+f(u(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!r(e,"name")||o&&e.name!==t)&&(i?h(e,"name",{value:t,configurable:!0}):e.name=t),g&&n&&r(n,"arity")&&e.length!==n.arity&&h(e,"length",{value:n.arity});try{n&&r(n,"constructor")&&n.constructor?i&&h(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var a=c(e);return r(a,"source")||(a.source=m(p,"string"==typeof t?t:"")),e};return Function.prototype.toString=A(function(){return n(this)&&l(this).source||a(this)},"toString"),Wt.exports}function Xt(){if(jt)return Nt;jt=1;var e=ve(),t=xt(),n=Vt(),r=nt();return Nt=function(i,o,a,s){s||(s={});var c=s.enumerable,l=void 0!==s.name?s.name:o;if(e(a)&&n(a,l,s),s.global)c?i[o]=a:r(o,a);else{try{s.unsafe?i[o]&&(c=!0):delete i[o]}catch(e){}c?i[o]=a:t.f(i,o,{value:a,enumerable:!1,configurable:!s.nonConfigurable,writable:!s.nonWritable})}return i}}var $t,Jt,Qt,Zt,Kt,en,tn,nn,rn,on,an,sn,cn,ln,un,hn,dn,fn={};function mn(){if(Zt)return Qt;Zt=1;var e=function(){if(Jt)return $t;Jt=1;var e=Math.ceil,t=Math.floor;return $t=Math.trunc||function(n){var r=+n;return(r>0?t:e)(r)}}();return Qt=function(t){var n=+t;return n!=n||0===n?0:e(n)}}function gn(){if(en)return Kt;en=1;var e=mn(),t=Math.max,n=Math.min;return Kt=function(r,i){var o=e(r);return o<0?t(o+i,0):n(o,i)}}function pn(){if(nn)return tn;nn=1;var e=mn(),t=Math.min;return tn=function(n){var r=e(n);return r>0?t(r,9007199254740991):0}}function vn(){if(on)return rn;on=1;var e=pn();return rn=function(t){return e(t.length)}}function yn(){if(ln)return cn;ln=1;var e=he(),t=at(),n=pe(),r=function(){if(sn)return an;sn=1;var e=pe(),t=gn(),n=vn(),r=function(r){return function(i,o,a){var s=e(i),c=n(s);if(0===c)return!r&&-1;var l,u=t(a,c);if(r&&o!=o){for(;c>u;)if((l=s[u++])!=l)return!0}else for(;c>u;u++)if((r||u in s)&&s[u]===o)return r||u||0;return!r&&-1}};return an={includes:r(!0),indexOf:r(!1)}}().indexOf,i=qt(),o=e([].push);return cn=function(e,a){var s,c=n(e),l=0,u=[];for(s in c)!t(i,s)&&t(c,s)&&o(u,s);for(;a.length>l;)t(c,s=a[l++])&&(~r(u,s)||o(u,s));return u}}function An(){return hn?un:(hn=1,un=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])}function _n(){if(dn)return fn;dn=1;var e=yn(),t=An().concat("length","prototype");return fn.f=Object.getOwnPropertyNames||function(n){return e(n,t)},fn}var bn,wn,En,xn,Sn,Cn,In,Tn,Rn,kn,On,Pn,Mn,Ln,Bn,Dn,Un,Fn,Nn,jn,Wn,zn,Hn,Gn,qn,Yn,Vn,Xn,$n,Jn,Qn,Zn,Kn,er,tr,nr,rr,ir,or,ar,sr,cr,lr={};function ur(){return bn||(bn=1,lr.f=Object.getOwnPropertySymbols),lr}function hr(){if(En)return wn;En=1;var e=Ae(),t=he(),n=_n(),r=ur(),i=Et(),o=t([].concat);return wn=e("Reflect","ownKeys")||function(e){var t=n.f(i(e)),a=r.f;return a?o(t,a(e)):t}}function dr(){if(Sn)return xn;Sn=1;var e=at(),t=hr(),n=ft(),r=xt();return xn=function(i,o,a){for(var s=t(o),c=r.f,l=n.f,u=0;uy&&l(o,arguments[y]),o});if(x.prototype=w,"Error"!==_?i?i(x,E):o(x,E,{name:!0}):h&&v in b&&(a(x,b,v),a(x,b,"prepareStackTrace")),o(x,b),!d)try{w.name!==_&&n(w,"name",_),w.constructor=x}catch(e){}return x}},ar}!function(){if(cr)return a;cr=1;var e=mr(),t=s(),n=gr(),r=Tr(),i="WebAssembly",o=t[i],c=7!==new Error("e",{cause:7}).cause,l=function(t,n){var i={};i[t]=r(t,n,c),e({global:!0,constructor:!0,arity:1,forced:c},i)},u=function(t,n){if(o&&o[t]){var a={};a[t]=r(i+"."+t,n,c),e({target:i,stat:!0,constructor:!0,arity:1,forced:c},a)}};l("Error",function(e){return function(t){return n(e,this,arguments)}}),l("EvalError",function(e){return function(t){return n(e,this,arguments)}}),l("RangeError",function(e){return function(t){return n(e,this,arguments)}}),l("ReferenceError",function(e){return function(t){return n(e,this,arguments)}}),l("SyntaxError",function(e){return function(t){return n(e,this,arguments)}}),l("TypeError",function(e){return function(t){return n(e,this,arguments)}}),l("URIError",function(e){return function(t){return n(e,this,arguments)}}),u("CompileError",function(e){return function(t){return n(e,this,arguments)}}),u("LinkError",function(e){return function(t){return n(e,this,arguments)}}),u("RuntimeError",function(e){return function(t){return n(e,this,arguments)}})}();var Rr,kr,Or,Pr,Mr,Lr,Br,Dr,Ur,Fr,Nr,jr,Wr,zr,Hr,Gr,qr,Yr={};function Vr(){if(kr)return Rr;kr=1;var e=de();return Rr=Array.isArray||function(t){return"Array"===e(t)}}function Xr(){if(Pr)return Or;Pr=1;var e=TypeError;return Or=function(t){if(t>9007199254740991)throw e("Maximum allowed index exceeded");return t}}function $r(){if(Lr)return Mr;Lr=1;var e=de(),t=he();return Mr=function(n){if("Function"===e(n))return t(n)}}function Jr(){if(Dr)return Br;Dr=1;var e=$r(),t=Ie(),n=A(),r=e(e.bind);return Br=function(e,i){return t(e),void 0===i?e:n?r(e,i):function(){return e.apply(i,arguments)}},Br}function Qr(){if(jr)return Nr;jr=1;var e=he(),t=v(),n=ve(),r=wr(),i=Ae(),o=Ht(),a=function(){},s=i("Reflect","construct"),c=/^\s*(?:class|function)\b/,l=e(c.exec),u=!c.test(a),h=function(e){if(!n(e))return!1;try{return s(a,[],e),!0}catch(e){return!1}},d=function(e){if(!n(e))return!1;switch(r(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return u||!!l(c,o(e))}catch(e){return!0}};return d.sham=!0,Nr=!s||t(function(){var e;return h(h.call)||!h(Object)||!h(function(){e=!0})||e})?d:h}function Zr(){if(zr)return Wr;zr=1;var e=Vr(),t=Qr(),n=ye(),r=ct()("species"),i=Array;return Wr=function(o){var a;return e(o)&&(a=o.constructor,(t(a)&&(a===i||e(a.prototype))||n(a)&&null===(a=a[r]))&&(a=void 0)),void 0===a?i:a}}function Kr(){if(Gr)return Hr;Gr=1;var e=Zr();return Hr=function(t,n){return new(e(t))(0===n?0:n)}}!function(){if(qr)return Yr;qr=1;var e=mr(),t=function(){if(Fr)return Ur;Fr=1;var e=Vr(),t=vn(),n=Xr(),r=Jr(),i=function(o,a,s,c,l,u,h,d){for(var f,m,g=l,p=0,v=!!h&&r(h,d);p0&&e(f)?(m=t(f),g=i(o,a,f,m,g,u-1)-1):(n(g+1),o[g]=f),g++),p++;return g};return Ur=i}(),n=ot(),r=vn(),i=mn(),o=Kr();e({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,a=n(this),s=r(a),c=o(a,0);return c.length=t(c,a,a,s,0,void 0===e?1:i(e)),c}})}();var ei,ti,ni,ri={};!function(){if(ni)return ri;ni=1;var e=mr(),t=ot(),n=vn(),r=function(){if(ti)return ei;ti=1;var e=y(),t=Vr(),n=TypeError,r=Object.getOwnPropertyDescriptor,i=e&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}();return ei=i?function(e,i){if(t(e)&&!r(e,"length").writable)throw new n("Cannot set read only .length");return e.length=i}:function(e,t){return e.length=t}}(),i=Xr();e({target:"Array",proto:!0,arity:1,forced:v()(function(){return 4294967297!==[].push.call({length:4294967296},1)})||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(e){return e instanceof TypeError}}()},{push:function(e){var o=t(this),a=n(o),s=arguments.length;i(a+s);for(var c=0;c0;)r[s]=r[--s];s!==c++&&(r[s]=a)}else for(var l=t(o/2),u=n(e(r,0,l),i),h=n(e(r,l),i),d=u.length,f=h.length,m=0,g=0;m3)){if(h)return!0;if(f)return f<603;var e,t,n,r,i="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:n=3;break;case 68:case 71:n=4;break;default:n=2}for(r=0;r<47;r++)m.push({k:t+r,v:n})}for(m.sort(function(e,t){return t.v-e.v}),r=0;ra(n)?1:-1}}(e)),s=i(u),l=0;lu;)n.f(e,a=c[u++],s[a]);return e},Ui}(),r=An(),i=qt(),o=Ni(),a=ht(),s=Gt(),c="prototype",l="script",u=s("IE_PROTO"),h=function(){},d=function(e){return"<"+l+">"+e+""},f=function(e){e.write(d("")),e.close();var t=e.parentWindow.Object;return e=null,t},m=function(){try{e=new ActiveXObject("htmlfile")}catch(e){}var t,n,i;m="undefined"!=typeof document?document.domain&&e?f(e):(n=a("iframe"),i="java"+l+":",n.style.display="none",o.appendChild(n),n.src=String(i),(t=n.contentWindow.document).open(),t.write(d("document.F=Object")),t.close(),t.F):f(e);for(var s=r.length;s--;)delete m[c][r[s]];return m()};return i[u]=!0,Pi=Object.create||function(e,r){var i;return null!==e?(h[c]=t(e),i=new h,h[c]=null,i[u]=e):i=m(),void 0===r?i:n.f(i,r)}}function Wi(){if(Bi)return Li;Bi=1;var e=ct(),t=ji(),n=xt().f,r=e("unscopables"),i=Array.prototype;return void 0===i[r]&&n(i,r,{configurable:!0,value:t(null)}),Li=function(e){i[r][e]=!0}}Di||(Di=1,Wi()("flat"));var zi,Hi,Gi,qi,Yi,Vi,Xi,$i,Ji,Qi,Zi,Ki,eo,to,no,ro,io,oo,ao,so,co,lo,uo,ho,fo,mo,go,po,vo,yo,Ao,_o,bo,wo={};function Eo(){return Hi?zi:(Hi=1,zi="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView)}function xo(){if(qi)return Gi;qi=1;var e=Vt(),t=xt();return Gi=function(n,r,i){return i.get&&e(i.get,r,{getter:!0}),i.set&&e(i.set,r,{setter:!0}),t.f(n,r,i)}}function So(){if(Vi)return Yi;Vi=1;var e=Xt();return Yi=function(t,n,r){for(var i in n)e(t,i,n[i],r);return t}}function Co(){if($i)return Xi;$i=1;var e=_e(),t=TypeError;return Xi=function(n,r){if(e(r,n))return n;throw new t("Incorrect invocation")}}function Io(){if(Qi)return Ji;Qi=1;var e=mn(),t=pn(),n=RangeError;return Ji=function(r){if(void 0===r)return 0;var i=e(r),o=t(i);if(i!==o)throw new n("Wrong length or index");return o}}function To(){if(ro)return no;ro=1;var e=Ki?Zi:(Ki=1,Zi=Math.sign||function(e){var t=+e;return 0===t||t!=t?t:t<0?-1:1}),t=function(){if(to)return eo;to=1;var e=4503599627370496;return eo=function(t){return t+e-e}}(),n=Math.abs;return no=function(r,i,o,a){var s=+r,c=n(s),l=e(s);if(co||h!=h?l*(1/0):l*h}}function Ro(){if(so)return ao;so=1;var e=Array,t=Math.abs,n=Math.pow,r=Math.floor,i=Math.log,o=Math.LN2;return ao={pack:function(a,s,c){var l,u,h,d=e(c),f=8*c-s-1,m=(1<>1,p=23===s?n(2,-24)-n(2,-77):0,v=a<0||0===a&&1/a<0?1:0,y=0;for((a=t(a))!=a||a===1/0?(u=a!=a?1:0,l=m):(l=r(i(a)/o),a*(h=n(2,-l))<1&&(l--,h*=2),(a+=l+g>=1?p/h:p*n(2,1-g))*h>=2&&(l++,h/=2),l+g>=m?(u=0,l=m):l+g>=1?(u=(a*h-1)*n(2,s),l+=g):(u=a*n(2,g-1)*n(2,s),l=0));s>=8;)d[y++]=255&u,u/=256,s-=8;for(l=l<0;)d[y++]=255&l,l/=256,f-=8;return d[y-1]|=128*v,d},unpack:function(e,t){var r,i=e.length,o=8*i-t-1,a=(1<>1,c=o-7,l=i-1,u=e[l--],h=127&u;for(u>>=7;c>0;)h=256*h+e[l--],c-=8;for(r=h&(1<<-c)-1,h>>=-c,c+=t;c>0;)r=256*r+e[l--],c-=8;if(0===h)h=1-s;else{if(h===a)return r?NaN:u?-1/0:1/0;r+=n(2,t),h-=s}return(u?-1:1)*r*n(2,h-t)}}}function ko(){if(ho)return uo;ho=1;var e=at(),t=ve(),n=ot(),r=Gt(),i=function(){if(lo)return co;lo=1;var e=v();return co=!e(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})}(),o=r("IE_PROTO"),a=Object,s=a.prototype;return uo=i?a.getPrototypeOf:function(r){var i=n(r);if(e(i,o))return i[o];var c=i.constructor;return t(c)&&i instanceof c?c.prototype:i instanceof a?s:null}}function Oo(){if(mo)return fo;mo=1;var e=ot(),t=gn(),n=vn();return fo=function(r){for(var i=e(this),o=n(i),a=arguments.length,s=t(a>1?arguments[1]:void 0,o),c=a>2?arguments[2]:void 0,l=void 0===c?o:t(c,o);l>s;)i[s++]=r;return i},fo}function Po(){if(po)return go;po=1;var e=xt().f,t=at(),n=ct()("toStringTag");return go=function(r,i,o){r&&!o&&(r=r.prototype),r&&!t(r,n)&&e(r,n,{configurable:!0,value:i})}}function Mo(){if(yo)return vo;yo=1;var e=s(),t=he(),n=y(),r=Eo(),i=zt(),o=St(),a=xo(),c=So(),l=v(),u=Co(),h=mn(),d=pn(),f=Io(),m=function(){if(oo)return io;oo=1;var e=To();return io=Math.fround||function(t){return e(t,1.1920928955078125e-7,34028234663852886e22,11754943508222875e-54)}}(),g=Ro(),p=ko(),A=Ar(),_=Oo(),b=bi(),w=br(),E=dr(),x=Po(),S=Yt(),C=i.PROPER,I=i.CONFIGURABLE,T="ArrayBuffer",R="DataView",k="prototype",O="Wrong index",P=S.getterFor(T),M=S.getterFor(R),L=S.set,B=e[T],D=B,U=D&&D[k],F=e[R],N=F&&F[k],j=Object.prototype,W=e.Array,z=e.RangeError,H=t(_),G=t([].reverse),q=g.pack,Y=g.unpack,V=function(e){return[255&e]},X=function(e){return[255&e,e>>8&255]},$=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},J=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},Q=function(e){return q(m(e),23,4)},Z=function(e){return q(e,52,8)},K=function(e,t,n){a(e[k],t,{configurable:!0,get:function(){return n(this)[t]}})},ee=function(e,t,n,r){var i=M(e),o=f(n),a=!!r;if(o+t>i.byteLength)throw new z(O);var s=i.bytes,c=o+i.byteOffset,l=b(s,c,c+t);return a?l:G(l)},te=function(e,t,n,r,i,o){var a=M(e),s=f(n),c=r(+i),l=!!o;if(s+t>a.byteLength)throw new z(O);for(var u=a.bytes,h=s+a.byteOffset,d=0;d>24)},setUint8:function(e,t){ie(this,e,t<<24>>24)}},{unsafe:!0})}else U=(D=function(e){u(this,U);var t=f(e);L(this,{type:T,bytes:H(W(t),0),byteLength:t}),n||(this.byteLength=t,this.detached=!1)})[k],N=(F=function(e,t,r){u(this,N),u(e,U);var i=P(e),o=i.byteLength,a=h(t);if(a<0||a>o)throw new z("Wrong offset");if(a+(r=void 0===r?o-a:d(r))>o)throw new z("Wrong length");L(this,{type:R,buffer:e,byteLength:r,byteOffset:a,bytes:i.bytes}),n||(this.buffer=e,this.byteLength=r,this.byteOffset=a)})[k],n&&(K(D,"byteLength",P),K(F,"buffer",M),K(F,"byteLength",M),K(F,"byteOffset",M)),c(N,{getInt8:function(e){return ee(this,1,e)[0]<<24>>24},getUint8:function(e){return ee(this,1,e)[0]},getInt16:function(e){var t=ee(this,2,e,arguments.length>1&&arguments[1]);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=ee(this,2,e,arguments.length>1&&arguments[1]);return t[1]<<8|t[0]},getInt32:function(e){return J(ee(this,4,e,arguments.length>1&&arguments[1]))},getUint32:function(e){return J(ee(this,4,e,arguments.length>1&&arguments[1]))>>>0},getFloat32:function(e){return Y(ee(this,4,e,arguments.length>1&&arguments[1]),23)},getFloat64:function(e){return Y(ee(this,8,e,arguments.length>1&&arguments[1]),52)},setInt8:function(e,t){te(this,1,e,V,t)},setUint8:function(e,t){te(this,1,e,V,t)},setInt16:function(e,t){te(this,2,e,X,t,arguments.length>2&&arguments[2])},setUint16:function(e,t){te(this,2,e,X,t,arguments.length>2&&arguments[2])},setInt32:function(e,t){te(this,4,e,$,t,arguments.length>2&&arguments[2])},setUint32:function(e,t){te(this,4,e,$,t,arguments.length>2&&arguments[2])},setFloat32:function(e,t){te(this,4,e,Q,t,arguments.length>2&&arguments[2])},setFloat64:function(e,t){te(this,8,e,Z,t,arguments.length>2&&arguments[2])}});return x(D,T),x(F,R),vo={ArrayBuffer:D,DataView:F}}function Lo(){if(_o)return Ao;_o=1;var e=Ae(),t=xo(),n=ct(),r=y(),i=n("species");return Ao=function(n){var o=e(n);r&&o&&!o[i]&&t(o,i,{configurable:!0,get:function(){return this}})}}!function(){if(bo)return wo;bo=1;var e=mr(),t=s(),n=Mo(),r=Lo(),i="ArrayBuffer",o=n[i];e({global:!0,constructor:!0,forced:t[i]!==o},{ArrayBuffer:o}),r(i)}();var Bo,Do={};!function(){if(Bo)return Do;Bo=1;var e=mr(),t=$r(),n=v(),r=Mo(),i=Et(),o=gn(),a=pn(),s=r.ArrayBuffer,c=r.DataView,l=c.prototype,u=t(s.prototype.slice),h=t(l.getUint8),d=t(l.setUint8);e({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:n(function(){return!new s(2).slice(1,void 0).byteLength})},{slice:function(e,t){if(u&&void 0===t)return u(i(this),e);for(var n=i(this).byteLength,r=o(e,n),l=o(void 0===t?n:t,n),f=new s(a(l-r)),m=new c(this),g=new c(f),p=0;r92||"NODE"===r&&n>94||"BROWSER"===r&&n>97)return!1;var e=new ArrayBuffer(8),t=i(e,{transfer:[e]});return 0!==e.byteLength||8!==t.byteLength})}function ua(){if(na)return ta;na=1;var e,t,n,r,i=s(),o=ca(),a=la(),c=i.structuredClone,l=i.ArrayBuffer,u=i.MessageChannel,h=!1;if(a)h=function(e){c(e,{transfer:[e]})};else if(l)try{u||(e=o("worker_threads"))&&(u=e.MessageChannel),u&&(t=new u,n=new l(2),r=function(e){t.port1.postMessage(null,[e])},2===n.byteLength&&(r(n),0===n.byteLength&&(h=r)))}catch(e){}return ta=h}function ha(){if(ia)return ra;ia=1;var e=s(),t=he(),n=pr(),r=Io(),i=function(){if(Yo)return qo;Yo=1;var e=Go(),t=TypeError;return qo=function(n){if(e(n))throw new t("ArrayBuffer is detached");return n}}(),o=Ho(),a=ua(),c=la(),l=e.structuredClone,u=e.ArrayBuffer,h=e.DataView,d=Math.min,f=u.prototype,m=h.prototype,g=t(f.slice),p=n(f,"resizable","get"),v=n(f,"maxByteLength","get"),y=t(m.getInt8),A=t(m.setInt8);return ra=(c||a)&&function(e,t,n){var s,f=o(e),m=void 0===t?f:r(t),_=!p||!p(e);if(i(e),c&&(e=l(e,{transfer:[e]}),f===m&&(n||_)))return e;if(f>=m&&(!n||_))s=g(e,0,m);else{var b=n&&!_&&v?{maxByteLength:v(e)}:void 0;s=new u(m,b);for(var w=new h(e),E=new h(s),x=d(m,f),S=0;S=0;i--)if(void 0!==t[i])try{r=e(t[i].iterator,n,r)}catch(e){n="throw",r=e}if("throw"===n)throw r;return r}}function Ga(){if(Oa)return ka;Oa=1;var e=_(),t=ji(),n=St(),r=So(),i=ct(),o=Yt(),a=Te(),s=ba().IteratorPrototype,c=Wa(),l=za(),u=Ha(),h=i("toStringTag"),d="IteratorHelper",f="WrapForValidIterator",m="normal",g="throw",p=o.set,v=function(n){var i=o.getterFor(n?f:d);return r(t(s),{next:function(){var e=i(this);if(n)return e.nextHandler();if(e.done)return c(void 0,!0);try{var t=e.nextHandler();return e.returnHandlerResult?t:c(t,e.done)}catch(t){throw e.done=!0,t}},return:function(){var t=i(this),r=t.iterator;if(t.done=!0,n){var o=a(r,"return");return o?e(o,r):c(void 0,!0)}if(t.inner)try{l(t.inner.iterator,m)}catch(e){return l(r,g,e)}if(t.openIters)try{u(t.openIters,m)}catch(e){return l(r,g,e)}return r&&l(r,m),c(void 0,!0)}})},y=v(!0),A=v(!1);return n(A,h,"Iterator Helper"),ka=function(e,t,n){var r=function(r,i){i?(i.iterator=r.iterator,i.next=r.next):i=r,i.type=t?f:d,i.returnHandlerResult=!!n,i.nextHandler=e,i.counter=0,i.done=!1,p(this,i)};return r.prototype=t?y:A,r}}function qa(){if(Ma)return Pa;Ma=1;var e=Et(),t=za();return Pa=function(n,r,i,o){try{return o?r(e(i)[0],i[1]):r(i)}catch(e){t(n,"throw",e)}}}function Ya(){return Ba?La:(Ba=1,La=function(e,t){var n="function"==typeof Iterator&&Iterator.prototype[e];if(n)try{n.call({next:null},t).next()}catch(e){return!0}})}function Va(){if(Ua)return Da;Ua=1;var e=s();return Da=function(t,n){var r=e.Iterator,i=r&&r.prototype,o=i&&i[t],a=!1;if(o)try{o.call({next:function(){return{done:!0}},return:function(){a=!0}},-1)}catch(e){e instanceof n||(a=!1)}if(!a)return o}}!function(){if(Fa)return Na;Fa=1;var e=mr(),t=_(),n=Ie(),r=Et(),i=ja(),o=Ga(),a=qa(),s=tt(),c=za(),l=Ya(),u=Va(),h=!s&&!l("filter",function(){}),d=!s&&!h&&u("filter",TypeError),f=s||h||d,m=o(function(){for(var e,n,i=this.iterator,o=this.predicate,s=this.next;;){if(e=r(t(s,i)),this.done=!!e.done)return;if(n=e.value,a(i,o,[n,this.counter++],!0))return n}});e({target:"Iterator",proto:!0,real:!0,forced:f},{filter:function(e){r(this);try{n(e)}catch(e){c(this,"throw",e)}return d?t(d,this,e):new m(i(this),{predicate:e})}})}();var Xa,$a,Ja,Qa,Za,Ka,es,ts,ns,rs,is,os={};function as(){return $a?Xa:($a=1,Xa={})}function ss(){if(Qa)return Ja;Qa=1;var e=ct(),t=as(),n=e("iterator"),r=Array.prototype;return Ja=function(e){return void 0!==e&&(t.Array===e||r[n]===e)}}function cs(){if(Ka)return Za;Ka=1;var e=wr(),t=Te(),n=me(),r=as(),i=ct()("iterator");return Za=function(o){if(!n(o))return t(o,i)||t(o,"@@iterator")||r[e(o)]}}function ls(){if(ts)return es;ts=1;var e=_(),t=Ie(),n=Et(),r=Ce(),i=cs(),o=TypeError;return es=function(a,s){var c=arguments.length<2?i(a):s;if(t(c))return n(e(c,a));throw new o(r(a)+" is not iterable")},es}function us(){if(rs)return ns;rs=1;var e=Jr(),t=_(),n=Et(),r=Ce(),i=ss(),o=vn(),a=_e(),s=ls(),c=cs(),l=za(),u=TypeError,h=function(e,t){this.stopped=e,this.result=t},d=h.prototype;return ns=function(f,m,g){var p,v,y,A,_,b,w,E=g&&g.that,x=!(!g||!g.AS_ENTRIES),S=!(!g||!g.IS_RECORD),C=!(!g||!g.IS_ITERATOR),I=!(!g||!g.INTERRUPTED),T=e(m,E),R=function(e){return p&&l(p,"normal"),new h(!0,e)},k=function(e){return x?(n(e),I?T(e[0],e[1],R):T(e[0],e[1])):I?T(e,R):T(e)};if(S)p=f.iterator;else if(C)p=f;else{if(!(v=c(f)))throw new u(r(f)+" is not iterable");if(i(v)){for(y=0,A=o(f);A>y;y++)if((_=k(f[y]))&&a(d,_))return _;return new h(!1)}p=s(f,v)}for(b=S?f.next:p.next;!(w=t(b,p)).done;){try{_=k(w.value)}catch(e){l(p,"throw",e)}if("object"==typeof _&&_&&a(d,_))return _}return new h(!1)}}!function(){if(is)return os;is=1;var e=mr(),t=_(),n=us(),r=Ie(),i=Et(),o=ja(),a=za(),s=Va()("forEach",TypeError);e({target:"Iterator",proto:!0,real:!0,forced:s},{forEach:function(e){i(this);try{r(e)}catch(e){a(this,"throw",e)}if(s)return t(s,this,e);var c=o(this),l=0;n(c,function(t){e(t,l++)},{IS_RECORD:!0})}})}();var hs,ds={};!function(){if(hs)return ds;hs=1;var e=mr(),t=_(),n=Ie(),r=Et(),i=ja(),o=Ga(),a=qa(),s=za(),c=Ya(),l=Va(),u=tt(),h=!u&&!c("map",function(){}),d=!u&&!h&&l("map",TypeError),f=u||h||d,m=o(function(){var e=this.iterator,n=r(t(this.next,e));if(!(this.done=!!n.done))return a(e,this.mapper,[n.value,this.counter++],!0)});e({target:"Iterator",proto:!0,real:!0,forced:f},{map:function(e){r(this);try{n(e)}catch(e){s(this,"throw",e)}return d?t(d,this,e):new m(i(this),{mapper:e})}})}();var fs,ms,gs,ps={};!function(){if(gs)return ps;gs=1;var e=mr(),t=Ae(),n=gr(),r=_(),i=he(),o=v(),a=ve(),s=Se(),c=bi(),l=function(){if(ms)return fs;ms=1;var e=he(),t=Vr(),n=ve(),r=de(),i=Er(),o=e([].push);return fs=function(e){if(n(e))return e;if(t(e)){for(var a=e.length,s=[],c=0;cb)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$c")})}!function(){if(Ms)return Ls;Ms=1;var e=y(),t=s(),n=he(),r=fr(),i=br(),o=St(),a=ji(),c=_n().f,l=_e(),u=function(){if(_s)return As;_s=1;var e=ye(),t=de(),n=ct()("match");return As=function(r){var i;return e(r)&&(void 0!==(i=r[n])?!!i:"RegExp"===t(r))}}(),h=Er(),d=Ds(),f=Us(),m=_r(),g=Xt(),p=v(),A=at(),_=Yt().enforce,b=Lo(),w=ct(),E=Fs(),x=Ns(),S=w("match"),C=t.RegExp,I=C.prototype,T=t.SyntaxError,R=n(I.exec),k=n("".charAt),O=n("".replace),P=n("".indexOf),M=n("".slice),L=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,B=/a/g,D=/a/g,U=new C(B)!==B,F=f.MISSED_STICKY,N=f.UNSUPPORTED_Y,j=e&&(!U||F||E||x||p(function(){return D[S]=!1,C(B)!==B||C(D)===D||"/a/i"!==String(C(B,"i"))}));if(r("RegExp",j)){for(var W=function(e,t){var n,r,s,c,f,m,g=l(I,this),p=u(e),v=void 0===t,y=[],b=e;if(!g&&p&&v&&e.constructor===W)return e;if((p||l(I,e))&&(e=e.source,v&&(t=d(b))),e=void 0===e?"":h(e),t=void 0===t?"":h(t),b=e,E&&"dotAll"in B&&(r=!!t&&P(t,"s")>-1)&&(t=O(t,/s/g,"")),n=t,F&&"sticky"in B&&(s=!!t&&P(t,"y")>-1)&&N&&(t=O(t,/y/g,"")),x&&(c=function(e){for(var t,n=e.length,r=0,i="",o=[],s=a(null),c=!1,l=!1,u=0,h="";r<=n;r++){if("\\"===(t=k(e,r)))t+=k(e,++r);else if("]"===t)c=!1;else if(!c)switch(!0){case"["===t:c=!0;break;case"("===t:if(i+=t,"?:"===M(e,r+1,r+3))continue;R(L,M(e,r+1))&&(r+=2,l=!0),u++;continue;case">"===t&&l:if(""===h||A(s,h))throw new T("Invalid capture group name");s[h]=!0,o[o.length]=[h,u],l=!1,h="";continue}l?h+=t:i+=t}return[i,o]}(e),e=c[0],y=c[1]),f=i(C(e,t),g?this:I,W),(r||s||y.length)&&(m=_(f),r&&(m.dotAll=!0,m.raw=W(function(e){for(var t,n=e.length,r=0,i="",o=!1;r<=n;r++)"\\"!==(t=k(e,r))?o||"."!==t?("["===t?o=!0:"]"===t&&(o=!1),i+=t):i+="[\\s\\S]":i+=t+k(e,++r);return i}(e),n)),s&&(m.sticky=!0),y.length&&(m.groups=y)),e!==b)try{o(f,"source",""===b?"(?:)":b)}catch(e){}return f},z=c(C),H=0;z.length>H;)m(W,C,z[H++]);I.constructor=W,W.prototype=I,g(t,"RegExp",W,{constructor:!0})}b("RegExp")}();var js,Ws={};!function(){if(js)return Ws;js=1;var e=y(),t=Fs(),n=de(),r=xo(),i=Yt().get,o=RegExp.prototype,a=TypeError;e&&t&&r(o,"dotAll",{configurable:!0,get:function(){if(this!==o){if("RegExp"===n(this))return!!i(this).dotAll;throw new a("Incompatible receiver, RegExp required")}}})}();var zs,Hs,Gs,qs={};function Ys(){if(Hs)return zs;Hs=1;var e,t,n=_(),r=he(),i=Er(),o=Bs(),a=Us(),s=it(),c=ji(),l=Yt().get,u=Fs(),h=Ns(),d=s("native-string-replace",String.prototype.replace),f=RegExp.prototype.exec,m=f,g=r("".charAt),p=r("".indexOf),v=r("".replace),y=r("".slice),A=(t=/b*/g,n(f,e=/a/,"a"),n(f,t,"a"),0!==e.lastIndex||0!==t.lastIndex),b=a.BROKEN_CARET,w=void 0!==/()??/.exec("")[1];return(A||w||b||u||h)&&(m=function(e){var t,r,a,s,u,h,_,E=this,x=l(E),S=i(e),C=x.raw;if(C)return C.lastIndex=E.lastIndex,t=n(m,C,S),E.lastIndex=C.lastIndex,t;var I=x.groups,T=b&&E.sticky,R=n(o,E),k=E.source,O=0,P=S;if(T&&(R=v(R,"y",""),-1===p(R,"g")&&(R+="g"),P=y(S,E.lastIndex),E.lastIndex>0&&(!E.multiline||E.multiline&&"\n"!==g(S,E.lastIndex-1))&&(k="(?: "+k+")",P=" "+P,O++),r=new RegExp("^(?:"+k+")",R)),w&&(r=new RegExp("^"+k+"$(?!\\s)",R)),A&&(a=E.lastIndex),s=n(f,T?r:E,P),T?s?(s.input=y(s.input,O),s[0]=y(s[0],O),s.index=E.lastIndex,E.lastIndex+=s[0].length):E.lastIndex=0:A&&s&&(E.lastIndex=E.global?s.index+s[0].length:a),w&&s&&s.length>1&&n(d,s[0],r,function(){for(u=1;u=f?e?"":void 0:(l=o(h,d))<55296||l>56319||d+1===f||(u=o(h,d+1))<56320||u>57343?e?i(h,d):l:e?a(h,d,d+2):u-56320+(l-55296<<10)+65536}};return Js={codeAt:s(!1),charAt:s(!0)}}function sc(){if(Ks)return Zs;Ks=1;var e=ac().charAt;return Zs=function(t,n,r){return n+(r?e(t,n).length:1)}}function cc(){if(tc)return ec;tc=1;var e=he(),t=ot(),n=Math.floor,r=e("".charAt),i=e("".replace),o=e("".slice),a=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,s=/\$([$&'`]|\d{1,2})/g;return ec=function(e,c,l,u,h,d){var f=l+e.length,m=u.length,g=s;return void 0!==h&&(h=t(h),g=a),i(d,g,function(t,i){var a;switch(r(i,0)){case"$":return"$";case"&":return e;case"`":return o(c,0,l);case"'":return o(c,f);case"<":a=h[o(i,1,-1)];break;default:var s=+i;if(0===s)return t;if(s>m){var d=n(s/10);return 0===d?t:d<=m?void 0===u[d-1]?r(i,1):u[d-1]+r(i,1):t}a=u[s-1]}return void 0===a?"":a})}}!function(){if(ic)return oc;ic=1;var e=gr(),t=_(),n=he(),r=function(){if($s)return Xs;$s=1,Vs();var e=_(),t=Xt(),n=Ys(),r=v(),i=ct(),o=St(),a=i("species"),s=RegExp.prototype;return Xs=function(c,l,u,h){var d=i(c),f=!r(function(){var e={};return e[d]=function(){return 7},7!==""[c](e)}),m=f&&!r(function(){var e=!1,t=/a/;return"split"===c&&((t={}).constructor={},t.constructor[a]=function(){return t},t.flags="",t[d]=/./[d]),t.exec=function(){return e=!0,null},t[d](""),!e});if(!f||!m||u){var g=/./[d],p=l(d,""[c],function(t,r,i,o,a){var c=r.exec;return c===n||c===s.exec?f&&!a?{done:!0,value:e(g,r,i,o)}:{done:!0,value:e(t,i,r,o)}:{done:!1}});t(String.prototype,c,p[0]),t(s,d,p[1])}h&&o(s[d],"sham",!0)}}(),i=v(),o=Et(),a=ve(),s=ye(),c=mn(),l=pn(),u=Er(),h=ge(),d=sc(),f=Te(),m=cc(),g=Ds(),p=function(){if(rc)return nc;rc=1;var e=_(),t=Et(),n=ve(),r=de(),i=Ys(),o=TypeError;return nc=function(a,s){var c=a.exec;if(n(c)){var l=e(c,a,s);return null!==l&&t(l),l}if("RegExp"===r(a))return e(i,a,s);throw new o("RegExp#exec called on incompatible receiver")}}(),y=ct()("replace"),A=Math.max,b=Math.min,w=n([].concat),E=n([].push),x=n("".indexOf),S=n("".slice),C=function(e){return void 0===e?e:String(e)},I="$0"==="a".replace(/./,"$0"),T=!!/./[y]&&""===/./[y]("a","$0");r("replace",function(n,r,i){var v=T?"$":"$0";return[function(e,n){var i=h(this),o=s(e)?f(e,y):void 0;return o?t(o,e,i,n):t(r,u(i),e,n)},function(t,n){var s=o(this),h=u(t);if("string"==typeof n&&-1===x(n,v)&&-1===x(n,"$<")){var f=i(r,s,h,n);if(f.done)return f.value}var y=a(n);y||(n=u(n));var _,I=u(g(s)),T=-1!==x(I,"g");T&&(_=-1!==x(I,"u"),s.lastIndex=0);for(var R,k=[];null!==(R=p(s,h))&&(E(k,R),T);){""===u(R[0])&&(s.lastIndex=d(h,l(s.lastIndex),_))}for(var O="",P=0,M=0;M=P&&(O+=S(h,P,D)+L,P=D+B.length)}return O+S(h,P)}]},!!i(function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$")})||!I||T)}();var lc,uc,hc,dc,fc,mc,gc,pc={};function vc(){return uc?lc:(uc=1,lc="\t\n\v\f\r                 \u2028\u2029\ufeff")}!function(){if(gc)return pc;gc=1;var e=mr(),t=function(){if(dc)return hc;dc=1;var e=he(),t=ge(),n=Er(),r=vc(),i=e("".replace),o=RegExp("^["+r+"]+"),a=RegExp("(^|[^"+r+"])["+r+"]+$"),s=function(e){return function(r){var s=n(t(r));return 1&e&&(s=i(s,o,"")),2&e&&(s=i(s,a,"$1")),s}};return hc={start:s(1),end:s(2),trim:s(3)}}().trim,n=function(){if(mc)return fc;mc=1;var e=zt().PROPER,t=v(),n=vc();return fc=function(r){return t(function(){return!!n[r]()||"​…᠎"!=="​…᠎"[r]()||e&&n[r].name!==r})}}();e({target:"String",proto:!0,forced:n("trim")},{trim:function(){return t(this)}})}();var yc,Ac,_c,bc,wc,Ec,xc,Sc,Cc,Ic,Tc,Rc,kc,Oc,Pc,Mc,Lc,Bc,Dc,Uc,Fc,Nc,jc,Wc,zc,Hc,Gc,qc,Yc={exports:{}};function Vc(){if(Ac)return yc;Ac=1;var e=ct()("iterator"),t=!1;try{var n=0,r={next:function(){return{done:!!n++}},return:function(){t=!0}};r[e]=function(){return this},Array.from(r,function(){throw 2})}catch(e){}return yc=function(n,r){try{if(!r&&!t)return!1}catch(e){return!1}var i=!1;try{var o={};o[e]=function(){return{next:function(){return{done:i=!0}}}},n(o)}catch(e){}return i}}function Xc(){if(bc)return _c;bc=1;var e,t,n,r=Eo(),i=y(),o=s(),a=ve(),c=ye(),l=at(),u=wr(),h=Ce(),d=St(),f=Xt(),m=xo(),g=_e(),p=ko(),v=Ar(),A=ct(),_=st(),b=Yt(),w=b.enforce,E=b.get,x=o.Int8Array,S=x&&x.prototype,C=o.Uint8ClampedArray,I=C&&C.prototype,T=x&&p(x),R=S&&p(S),k=Object.prototype,O=o.TypeError,P=A("toStringTag"),M=_("TYPED_ARRAY_TAG"),L="TypedArrayConstructor",B=r&&!!v&&"Opera"!==u(o.opera),D=!1,U={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},F={BigInt64Array:8,BigUint64Array:8},N=function(e){var t=p(e);if(c(t)){var n=E(t);return n&&l(n,L)?n[L]:N(t)}},j=function(e){if(!c(e))return!1;var t=u(e);return l(U,t)||l(F,t)};for(e in U)(n=(t=o[e])&&t.prototype)?w(n)[L]=t:B=!1;for(e in F)(n=(t=o[e])&&t.prototype)&&(w(n)[L]=t);if((!B||!a(T)||T===Function.prototype)&&(T=function(){throw new O("Incorrect invocation")},B))for(e in U)o[e]&&v(o[e],T);if((!B||!R||R===k)&&(R=T.prototype,B))for(e in U)o[e]&&v(o[e].prototype,R);if(B&&p(I)!==R&&v(I,R),i&&!l(R,P))for(e in D=!0,m(R,P,{configurable:!0,get:function(){return c(this)?this[M]:void 0}}),U)o[e]&&d(o[e],M,e);return _c={NATIVE_ARRAY_BUFFER_VIEWS:B,TYPED_ARRAY_TAG:D&&M,aTypedArray:function(e){if(j(e))return e;throw new O("Target is not a typed array")},aTypedArrayConstructor:function(e){if(a(e)&&(!v||g(T,e)))return e;throw new O(h(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,r){if(i){if(n)for(var a in U){var s=o[a];if(s&&l(s.prototype,e))try{delete s.prototype[e]}catch(n){try{s.prototype[e]=t}catch(e){}}}R[e]&&!n||f(R,e,n?t:B&&S[e]||t,r)}},exportTypedArrayStaticMethod:function(e,t,n){var r,a;if(i){if(v){if(n)for(r in U)if((a=o[r])&&l(a,e))try{delete a[e]}catch(e){}if(T[e]&&!n)return;try{return f(T,e,n?t:B&&T[e]||t)}catch(e){}}for(r in U)!(a=o[r])||a[e]&&!n||f(a,e,t)}},getTypedArrayConstructor:N,isView:function(e){if(!c(e))return!1;var t=u(e);return"DataView"===t||l(U,t)||l(F,t)},isTypedArray:j,TypedArray:T,TypedArrayPrototype:R}}function $c(){if(Sc)return xc;Sc=1;var e=ye(),t=Math.floor;return xc=Number.isInteger||function(n){return!e(n)&&isFinite(n)&&t(n)===n}}function Jc(){if(Ic)return Cc;Ic=1;var e=mn(),t=RangeError;return Cc=function(n){var r=e(n);if(r<0)throw new t("The argument can't be less than 0");return r}}function Qc(){if(Rc)return Tc;Rc=1;var e=Jc(),t=RangeError;return Tc=function(n,r){var i=e(n);if(i%r)throw new t("Wrong offset");return i}}function Zc(){if(Oc)return kc;Oc=1;var e=Math.round;return kc=function(t){var n=e(t);return n<0?0:n>255?255:255&n}}function Kc(){if(Mc)return Pc;Mc=1;var e=Qr(),t=Ce(),n=TypeError;return Pc=function(r){if(e(r))return r;throw new n(t(r)+" is not a constructor")}}function el(){if(Bc)return Lc;Bc=1;var e=wr();return Lc=function(t){var n=e(t);return"BigInt64Array"===n||"BigUint64Array"===n}}function tl(){if(Uc)return Dc;Uc=1;var e=lt(),t=TypeError;return Dc=function(n){var r=e(n,"number");if("number"==typeof r)throw new t("Can't convert number to bigint");return BigInt(r)}}function nl(){if(Nc)return Fc;Nc=1;var e=Jr(),t=_(),n=Kc(),r=ot(),i=vn(),o=ls(),a=cs(),s=ss(),c=el(),l=Xc().aTypedArrayConstructor,u=tl();return Fc=function(h){var d,f,m,g,p,v,y,A,_=n(this),b=r(h),w=arguments.length,E=w>1?arguments[1]:void 0,x=void 0!==E,S=a(b);if(S&&!s(S))for(A=(y=o(b,S)).next,b=[];!(v=t(A,y)).done;)b.push(v.value);for(x&&w>2&&(E=e(E,arguments[2])),f=i(b),m=new(l(_))(f),g=c(m),d=0;f>d;d++)p=x?E(b[d],d):b[d],m[d]=g?u(p):+p;return m},Fc}function rl(){if(Hc)return zc;Hc=1;var e=vn();return zc=function(t,n,r){for(var i=0,o=arguments.length>2?r:e(n),a=new t(o);o>i;)a[i]=n[i++];return a},zc}function il(){if(Gc)return Yc.exports;Gc=1;var e=mr(),t=s(),n=_(),r=y(),i=function(){if(Ec)return wc;Ec=1;var e=s(),t=v(),n=Vc(),r=Xc().NATIVE_ARRAY_BUFFER_VIEWS,i=e.ArrayBuffer,o=e.Int8Array;return wc=!r||!t(function(){o(1)})||!t(function(){new o(-1)})||!n(function(e){new o,new o(null),new o(1.5),new o(e)},!0)||t(function(){return 1!==new o(new i(2),1,void 0).length})}(),o=Xc(),a=Mo(),c=Co(),l=ue(),u=St(),h=$c(),d=pn(),f=Io(),m=Qc(),g=Zc(),p=ut(),A=at(),b=wr(),w=ye(),E=Se(),x=ji(),S=_e(),C=Ar(),I=_n().f,T=nl(),R=function(){if(Wc)return jc;Wc=1;var e=Jr(),t=he(),n=fe(),r=ot(),i=vn(),o=Kr(),a=t([].push),s=function(t){var s=1===t,c=2===t,l=3===t,u=4===t,h=6===t,d=7===t,f=5===t||h;return function(m,g,p,v){for(var y,A,_=r(m),b=n(_),w=i(b),E=e(g,p),x=0,S=v||o,C=s?S(m,w):c||d?S(m,0):void 0;w>x;x++)if((f||x in b)&&(A=E(y=b[x],x,_),t))if(s)C[x]=A;else if(A)switch(t){case 3:return!0;case 5:return y;case 6:return x;case 2:a(C,y)}else switch(t){case 4:return!1;case 7:a(C,y)}return h?-1:l||u?u:C}};return jc={forEach:s(0),map:s(1),filter:s(2),some:s(3),every:s(4),find:s(5),findIndex:s(6),filterReject:s(7)}}().forEach,k=Lo(),O=xo(),P=xt(),M=ft(),L=rl(),B=Yt(),D=br(),U=B.get,F=B.set,N=B.enforce,j=P.f,W=M.f,z=t.RangeError,H=a.ArrayBuffer,G=H.prototype,q=a.DataView,Y=o.NATIVE_ARRAY_BUFFER_VIEWS,V=o.TYPED_ARRAY_TAG,X=o.TypedArray,$=o.TypedArrayPrototype,J=o.isTypedArray,Q="BYTES_PER_ELEMENT",Z="Wrong length",K=function(e,t){O(e,t,{configurable:!0,get:function(){return U(this)[t]}})},ee=function(e){var t;return S(G,e)||"ArrayBuffer"===(t=b(e))||"SharedArrayBuffer"===t},te=function(e,t){return J(e)&&!E(t)&&t in e&&h(+t)&&t>=0},ne=function(e,t){return t=p(t),te(e,t)?l(2,e[t]):W(e,t)},re=function(e,t,n){return t=p(t),!(te(e,t)&&w(n)&&A(n,"value"))||A(n,"get")||A(n,"set")||n.configurable||A(n,"writable")&&!n.writable||A(n,"enumerable")&&!n.enumerable?j(e,t,n):(e[t]=n.value,e)};return r?(Y||(M.f=ne,P.f=re,K($,"buffer"),K($,"byteOffset"),K($,"byteLength"),K($,"length")),e({target:"Object",stat:!0,forced:!Y},{getOwnPropertyDescriptor:ne,defineProperty:re}),Yc.exports=function(r,o,a){var s=r.match(/\d+/)[0]/8,l=r+(a?"Clamped":"")+"Array",h="get"+r,p="set"+r,v=t[l],y=v,A=y&&y.prototype,_={},b=function(e,t){j(e,t,{get:function(){return function(e,t){var n=U(e);return n.view[h](t*s+n.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,n){var r=U(e);r.view[p](t*s+r.byteOffset,a?g(n):n,!0)}(this,t,e)},enumerable:!0})};Y?i&&(y=o(function(e,t,r,i){return c(e,A),D(w(t)?ee(t)?void 0!==i?new v(t,m(r,s),i):void 0!==r?new v(t,m(r,s)):new v(t):J(t)?L(y,t):n(T,y,t):new v(f(t)),e,y)}),C&&C(y,X),R(I(v),function(e){e in y||u(y,e,v[e])}),y.prototype=A):(y=o(function(e,t,r,i){c(e,A);var o,a,l,u=0,h=0;if(w(t)){if(!ee(t))return J(t)?L(y,t):n(T,y,t);o=t,h=m(r,s);var g=t.byteLength;if(void 0===i){if(g%s)throw new z(Z);if((a=g-h)<0)throw new z(Z)}else if((a=d(i)*s)+h>g)throw new z(Z);l=a/s}else l=f(t),o=new H(a=l*s);for(F(e,{buffer:o,byteOffset:h,byteLength:a,length:l,view:new q(o)});u=0?a:o+a;return s<0||s>=o?void 0:i[s]})}();var sl,cl={};!function(){if(sl)return cl;sl=1;var e=Xc(),t=Oo(),n=tl(),r=wr(),i=_(),o=he(),a=v(),s=e.aTypedArray,c=e.exportTypedArrayMethod,l=o("".slice);c("fill",function(e){var o=arguments.length;s(this);var a="Big"===l(r(this),0,3)?n(e):+e;return i(t,this,a,o>1?arguments[1]:void 0,o>2?arguments[2]:void 0)},a(function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e}))}();var ll,ul,hl,dl={};function fl(){if(ul)return ll;ul=1;var e=Jr(),t=fe(),n=ot(),r=vn(),i=function(i){var o=1===i;return function(a,s,c){for(var l,u=n(a),h=t(u),d=r(h),f=e(s,c);d-- >0;)if(f(l=h[d],d,u))switch(i){case 0:return l;case 1:return d}return o?-1:void 0}};return ll={findLast:i(0),findLastIndex:i(1)}}!function(){if(hl)return dl;hl=1;var e=Xc(),t=fl().findLast,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("findLast",function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)})}();var ml,gl={};!function(){if(ml)return gl;ml=1;var e=Xc(),t=fl().findLastIndex,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("findLastIndex",function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)})}();var pl,vl={};!function(){if(pl)return vl;pl=1;var e=s(),t=_(),n=Xc(),r=vn(),i=Qc(),o=ot(),a=v(),c=e.RangeError,l=e.Int8Array,u=l&&l.prototype,h=u&&u.set,d=n.aTypedArray,f=n.exportTypedArrayMethod,m=!a(function(){var e=new Uint8ClampedArray(2);return t(h,e,{length:1,0:3},1),3!==e[1]}),g=m&&n.NATIVE_ARRAY_BUFFER_VIEWS&&a(function(){var e=new l(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]});f("set",function(e){d(this);var n=i(arguments.length>1?arguments[1]:void 0,1),a=o(e);if(m)return t(h,this,a,n);var s=this.length,l=r(a),u=0;if(l+n>s)throw new c("Wrong length");for(;u0&&1/n<0?1:-1:t>n}}(e))},!p||g)}();var _l,bl,wl,El={};function xl(){if(bl)return _l;bl=1;var e=vn();return _l=function(t,n){for(var r=e(t),i=new n(r),o=0;o=s||l<0)throw new n("Incorrect index");for(var u=new i(s),h=0;h=t.length)return e.target=null,a(void 0,!0);switch(e.kind){case"keys":return a(n,!1);case"values":return a(t[n],!1)}return a([n,t[n]],!1)},"values");var d=n.Arguments=n.Array;if(t("keys"),t("values"),t("entries"),!s&&c&&"values"!==d.name)try{i(d,"name",{value:"values"})}catch(e){}return jl}!function(){if(zl)return Hl;zl=1;var e=s(),t=Ml?Pl:(Ml=1,Pl={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}),n=function(){if(Bl)return Ll;Bl=1;var e=ht()("span").classList,t=e&&e.constructor&&e.constructor.prototype;return Ll=t===Object.prototype?void 0:t}(),r=Yl(),i=St(),o=Po(),a=ct()("iterator"),c=r.values,l=function(e,n){if(e){if(e[a]!==c)try{i(e,a,c)}catch(t){e[a]=c}if(o(e,n,!0),t[n])for(var s in r)if(e[s]!==r[s])try{i(e,s,r[s])}catch(t){e[s]=r[s]}}};for(var u in t)l(e[u]&&e[u].prototype,u);l(n,"DOMTokenList")}();var Vl,Xl,$l,Jl,Ql,Zl={};function Kl(){if(Xl)return Vl;Xl=1;var e=y(),t=v(),n=Et(),r=xr(),i=Error.prototype.toString,o=t(function(){if(e){var t=Object.create(Object.defineProperty({},"name",{get:function(){return this===t}}));if("true"!==i.call(t))return!0}return"2: 1"!==i.call({message:1,name:2})||"Error"!==i.call({})});return Vl=o?function(){var e=n(this),t=r(e.name,"Error"),i=r(e.message);return t?i?t+": "+i:t:i}:i}function eu(){return Jl?$l:(Jl=1,$l={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}})}!function(){if(Ql)return Zl;Ql=1;var e=mr(),t=Ae(),n=ca(),r=v(),i=ji(),o=ue(),a=xt().f,s=Xt(),c=xo(),l=at(),u=Co(),h=Et(),d=Kl(),f=xr(),m=eu(),g=Cr(),p=Yt(),A=y(),_=tt(),b="DOMException",w="DATA_CLONE_ERR",E=t("Error"),x=t(b)||function(){try{(new(t("MessageChannel")||n("worker_threads").MessageChannel)).port1.postMessage(new WeakMap)}catch(e){if(e.name===w&&25===e.code)return e.constructor}}(),S=x&&x.prototype,C=E.prototype,I=p.set,T=p.getterFor(b),R="stack"in new E(b),k=function(e){return l(m,e)&&m[e].m?m[e].c:0},O=function(){u(this,P);var e=arguments.length,t=f(e<1?void 0:arguments[0]),n=f(e<2?void 0:arguments[1],"Error"),r=k(n);if(I(this,{type:b,name:n,message:t,code:r}),A||(this.name=n,this.message=t,this.code=r),R){var i=new E(t);i.name=b,a(this,"stack",o(1,g(i.stack,1)))}},P=O.prototype=i(C),M=function(e){return{enumerable:!0,configurable:!0,get:e}},L=function(e){return M(function(){return T(this)[e]})};A&&(c(P,"code",L("code")),c(P,"message",L("message")),c(P,"name",L("name"))),a(P,"constructor",o(1,O));var B=r(function(){return!(new x instanceof E)}),D=B||r(function(){return C.toString!==d||"2: 1"!==String(new x(1,2))}),U=B||r(function(){return 25!==new x(1,"DataCloneError").code}),F=B||25!==x[w]||25!==S[w],N=_?D||U||F:B;e({global:!0,constructor:!0,forced:N},{DOMException:N?O:x});var j=t(b),W=j.prototype;for(var z in D&&(_||x===j)&&s(W,"toString",d),U&&A&&x===j&&c(W,"code",M(function(){return k(h(this).name)})),m)if(l(m,z)){var H=m[z],G=H.s,q=o(6,H.c);l(j,G)||a(j,G,q),l(W,G)||a(W,G,q)}}();var tu,nu={};!function(){if(tu)return nu;tu=1;var e=mr(),t=s(),n=Ae(),r=ue(),i=xt().f,o=at(),a=Co(),c=br(),l=xr(),u=eu(),h=Cr(),d=y(),f=tt(),m="DOMException",g=n("Error"),p=n(m),v=function(){a(this,A);var e=arguments.length,t=l(e<1?void 0:arguments[0]),n=l(e<2?void 0:arguments[1],"Error"),o=new p(t,n),s=new g(t);return s.name=m,i(o,"stack",r(1,h(s.stack,1))),c(o,this,v),o},A=v.prototype=p.prototype,_="stack"in new g(m),b="stack"in new p(1,2),w=p&&d&&Object.getOwnPropertyDescriptor(t,m),E=!(!w||w.writable&&w.configurable),x=_&&!E&&!b;e({global:!0,constructor:!0,forced:f||x},{DOMException:x?v:p});var S=n(m),C=S.prototype;if(C.constructor!==S)for(var I in f||i(C,"constructor",r(1,S)),u)if(o(u,I)){var T=u[I],R=T.s;o(S,R)||i(S,R,r(6,T.c))}}();var ru,iu={};!function(){if(ru)return iu;ru=1;var e=Ae(),t="DOMException";Po()(e(t),t)}();var ou,au={};!function(){if(ou)return au;ou=1;var e=mr(),t=s(),n=xo(),r=y(),i=TypeError,o=Object.defineProperty,a=t.self!==t;try{if(r){var c=Object.getOwnPropertyDescriptor(t,"self");!a&&c&&c.get&&c.enumerable||n(t,"self",{get:function(){return t},set:function(e){if(this!==t)throw new i("Illegal invocation");o(t,"self",{value:e,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}else e({global:!0,simple:!0,forced:a},{self:t})}catch(e){}}();var su,cu,lu,uu,hu,du,fu,mu,gu,pu,vu,yu={},Au={};function _u(){if(lu)return cu;lu=1;var e=v(),t=ct(),n=y(),r=tt(),i=t("iterator");return cu=!e(function(){var e=new URL("b?a=1&b=2&c=3","https://a"),t=e.searchParams,o=new URLSearchParams("a=1&a=2&b=3"),a="";return e.pathname="c%20d",t.forEach(function(e,n){t.delete("b"),a+=n+e}),o.delete("a",2),o.delete("b",void 0),r&&(!e.toJSON||!o.has("a",1)||o.has("a",2)||!o.has("a",void 0)||o.has("b"))||!t.size&&(r||!n)||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[i]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==a||"x"!==new URL("https://x",void 0).host})}function bu(){if(fu)return du;fu=1;var e=Jr(),t=_(),n=ot(),r=qa(),i=ss(),o=Qr(),a=vn(),s=_a(),c=ls(),l=cs(),u=Array;return du=function(h){var d=n(h),f=o(this),m=arguments.length,g=m>1?arguments[1]:void 0,p=void 0!==g;p&&(g=e(g,m>2?arguments[2]:void 0));var v,y,A,_,b,w,E=l(d),x=0;if(!E||this===u&&i(E))for(v=a(d),y=f?new this(v):u(v);v>x;x++)w=p?g(d[x],x):d[x],s(y,x,w);else for(y=f?new this:[],b=(_=c(d,E)).next;!(A=t(b,_)).done;x++)w=p?r(_,g,[A.value,x],!0):A.value,s(y,x,w);return y.length=x,y},du}function wu(){if(gu)return mu;gu=1;var e=he(),t=2147483647,n=/[^\0-\u007E]/,r=/[.\u3002\uFF0E\uFF61]/g,i="Overflow: input needs wider integers to process",o=RangeError,a=e(r.exec),s=Math.floor,c=String.fromCharCode,l=e("".charCodeAt),u=e([].join),h=e([].push),d=e("".replace),f=e("".split),m=e("".toLowerCase),g=function(e){return e+22+75*(e<26)},p=function(e,t,n){var r=0;for(e=n?s(e/700):e>>1,e+=s(e/t);e>455;)e=s(e/35),r+=36;return s(r+36*e/(e+38))},v=function(e){var n=[];e=function(e){for(var t=[],n=0,r=e.length;n=55296&&i<=56319&&n=f&&a<_&&(_=a);var b=A+1;if(_-f>s((t-m)/b))throw new o(i);for(m+=(_-f)*b,f=_,r=0;rt)throw new o(i);if(a===f){for(var w=m,E=36;;){var x=E<=v?1:E>=v+26?26:E-v;if(wc;){if(t=+arguments[c++],n(t,1114111)!==t)throw new r(t+" is not a valid code point");o[c]=t<65536?i(t):i(55296+((t-=65536)>>10),t%1024+56320)}return a(o,"")}})}();var e=mr(),t=s(),n=Pu(),r=Ae(),i=_(),o=he(),a=y(),c=_u(),l=Xt(),u=xo(),h=So(),d=Po(),f=Gl(),m=Yt(),g=Co(),p=ve(),v=at(),A=Jr(),b=wr(),w=Et(),E=ye(),x=Er(),S=ji(),C=ue(),I=ls(),T=cs(),R=Wa(),k=Eu(),O=ct(),P=wi(),M=O("iterator"),L="URLSearchParams",B=L+"Iterator",D=m.set,U=m.getterFor(L),F=m.getterFor(B),N=n("fetch"),j=n("Request"),W=n("Headers"),z=j&&j.prototype,H=W&&W.prototype,G=t.TypeError,q=t.encodeURIComponent,Y=String.fromCharCode,V=r("String","fromCodePoint"),X=parseInt,$=o("".charAt),J=o([].join),Q=o([].push),Z=o("".replace),K=o([].shift),ee=o([].splice),te=o("".split),ne=o("".slice),re=o(/./.exec),ie=/\+/g,oe=/^[0-9a-f]+$/i,ae=function(e,t){var n=ne(e,t,t+2);return re(oe,n)?X(n,16):NaN},se=function(e){for(var t=0,n=128;n>0&&0!==(e&n);n>>=1)t++;return t},ce=function(e){var t=null;switch(e.length){case 1:t=e[0];break;case 2:t=(31&e[0])<<6|63&e[1];break;case 3:t=(15&e[0])<<12|(63&e[1])<<6|63&e[2];break;case 4:t=(7&e[0])<<18|(63&e[1])<<12|(63&e[2])<<6|63&e[3]}return t>1114111?null:t},le=function(e){for(var t=(e=Z(e,ie," ")).length,n="",r=0;rt){n+="%",r++;continue}var o=ae(e,r+1);if(o!=o){n+=i,r++;continue}r+=2;var a=se(o);if(0===a)i=Y(o);else{if(1===a||a>4){n+="�",r++;continue}for(var s=[o],c=1;ct||"%"!==$(e,r));){var l=ae(e,r+1);if(l!=l){r+=3;break}if(l>191||l<128)break;Q(s,l),r+=2,c++}if(s.length!==a){n+="�";continue}var u=ce(s);null===u?n+="�":i=V(u)}}n+=i,r++}return n},de=/[!'()~]|%20/g,fe={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},me=function(e){return fe[e]},ge=function(e){return Z(q(e),de,me)},pe=f(function(e,t){D(this,{type:B,target:U(e).entries,index:0,kind:t})},L,function(){var e=F(this),t=e.target,n=e.index++;if(!t||n>=t.length)return e.target=null,R(void 0,!0);var r=t[n];switch(e.kind){case"keys":return R(r.key,!1);case"values":return R(r.value,!1)}return R([r.key,r.value],!1)},!0),_e=function(e){this.entries=[],this.url=null,void 0!==e&&(E(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===$(e,0)?ne(e,1):e:x(e)))};_e.prototype={type:L,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,r,o,a,s,c,l=this.entries,u=T(e);if(u)for(n=(t=I(e,u)).next;!(r=i(n,t)).done;){if(a=(o=I(w(r.value))).next,(s=i(a,o)).done||(c=i(a,o)).done||!i(a,o).done)throw new G("Expected sequence with length 2");Q(l,{key:x(s.value),value:x(c.value)})}else for(var h in e)v(e,h)&&Q(l,{key:h,value:x(e[h])})},parseQuery:function(e){if(e)for(var t,n,r=this.entries,i=te(e,"&"),o=0;o0?arguments[0]:void 0));a||(this.size=e.entries.length)},we=be.prototype;if(h(we,{append:function(e,t){var n=U(this);k(arguments.length,2),Q(n.entries,{key:x(e),value:x(t)}),a||this.length++,n.updateURL()},delete:function(e){for(var t=U(this),n=k(arguments.length,1),r=t.entries,i=x(e),o=n<2?void 0:arguments[1],s=void 0===o?o:x(o),c=0;ct.key?1:-1}),e.updateURL()},forEach:function(e){for(var t,n=U(this).entries,r=A(e,arguments.length>1?arguments[1]:void 0),i=0;i1?Se(arguments[1]):{})}}),p(j)){var Ce=function(e){return g(this,z),new j(e,arguments.length>1?Se(arguments[1]):{})};z.constructor=Ce,Ce.prototype=z,e({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Ce})}}return Iu={URLSearchParams:be,getState:U}}function Lu(){if(Ru)return yu;Ru=1,function(){if(su)return Au;su=1;var e=ac().charAt,t=Er(),n=Yt(),r=ql(),i=Wa(),o="String Iterator",a=n.set,s=n.getterFor(o);r(String,"String",function(e){a(this,{type:o,string:t(e),index:0})},function(){var t,n=s(this),r=n.string,o=n.index;return o>=r.length?i(void 0,!0):(t=e(r,o),n.index+=t.length,i(t,!1))})}();var e,t=mr(),n=y(),r=_u(),i=s(),o=Jr(),a=he(),c=Xt(),l=xo(),u=Co(),h=at(),d=function(){if(hu)return uu;hu=1;var e=y(),t=he(),n=_(),r=v(),i=Fi(),o=ur(),a=le(),s=ot(),c=fe(),l=Object.assign,u=Object.defineProperty,h=t([].concat);return uu=!l||r(function(){if(e&&1!==l({b:1},l(u({},"a",{enumerable:!0,get:function(){u(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var t={},n={},r=Symbol("assign detection"),o="abcdefghijklmnopqrst";return t[r]=7,o.split("").forEach(function(e){n[e]=e}),7!==l({},t)[r]||i(l({},n)).join("")!==o})?function(t,r){for(var l=s(t),u=arguments.length,d=1,f=o.f,m=a.f;u>d;)for(var g,p=c(arguments[d++]),v=f?h(i(p),f(p)):i(p),y=v.length,A=0;y>A;)g=v[A++],e&&!n(m,p,g)||(l[g]=p[g]);return l}:l,uu}(),f=bu(),m=bi(),g=ac().codeAt,p=wu(),A=Er(),b=Po(),w=Eu(),E=Mu(),x=Yt(),S=x.set,C=x.getterFor("URL"),I=E.URLSearchParams,T=E.getState,R=i.URL,k=i.TypeError,O=i.parseInt,P=Math.floor,M=Math.pow,L=a("".charAt),B=a(/./.exec),D=a([].join),U=a(1.1.toString),F=a([].pop),N=a([].push),j=a("".replace),W=a([].shift),z=a("".split),H=a("".slice),G=a("".toLowerCase),q=a([].unshift),Y="Invalid scheme",V="Invalid host",X="Invalid port",$=/[a-z]/i,J=/[\d+-.a-z]/i,Q=/\d/,Z=/^0x/i,K=/^[0-7]+$/,ee=/^\d+$/,te=/^[\da-f]+$/i,ne=/[\0\t\n\r #%/:<>?@[\\\]^|]/,re=/[\0\t\n\r #/:<>?@[\\\]^|]/,ie=/^[\u0000-\u0020]+/,oe=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,ae=/[\t\n\r]/g,se=function(e){var t,n,r,i;if("number"==typeof e){for(t=[],n=0;n<4;n++)q(t,e%256),e=P(e/256);return D(t,".")}if("object"==typeof e){for(t="",r=function(e){for(var t=null,n=1,r=null,i=0,o=0;o<8;o++)0!==e[o]?(i>n&&(t=r,n=i),r=null,i=0):(null===r&&(r=o),++i);return i>n?r:t}(e),n=0;n<8;n++)i&&0===e[n]||(i&&(i=!1),r===n?(t+=n?":":"::",i=!0):(t+=U(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},ce={},ue=d({},ce,{" ":1,'"':1,"<":1,">":1,"`":1}),de=d({},ue,{"#":1,"?":1,"{":1,"}":1}),me=d({},de,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),ge=function(e,t){var n=g(e,0);return n>32&&n<127&&!h(t,e)?e:encodeURIComponent(e)},pe={ftp:21,file:null,http:80,https:443,ws:80,wss:443},ve=function(e,t){var n;return 2===e.length&&B($,L(e,0))&&(":"===(n=L(e,1))||!t&&"|"===n)},ye=function(e){var t;return e.length>1&&ve(H(e,0,2))&&(2===e.length||"/"===(t=L(e,2))||"\\"===t||"?"===t||"#"===t)},Ae=function(e){return"."===e||"%2e"===G(e)},_e=function(e){return".."===(e=G(e))||"%2e."===e||".%2e"===e||"%2e%2e"===e},be={},we={},Ee={},xe={},Se={},Ce={},Ie={},Te={},Re={},ke={},Oe={},Pe={},Me={},Le={},Be={},De={},Ue={},Fe={},Ne={},je={},We={},ze=function(e,t,n){var r,i,o,a=A(e);if(t){if(i=this.parse(a))throw new k(i);this.searchParams=null}else{if(void 0!==n&&(r=new ze(n,!0)),i=this.parse(a,null,r))throw new k(i);(o=T(new I)).bindURL(this),this.searchParams=o}};ze.prototype={type:"URL",parse:function(t,n,r){var i,o,a,s,c=this,l=n||be,u=0,d="",g=!1,p=!1,v=!1;for(t=A(t),n||(c.scheme="",c.username="",c.password="",c.host=null,c.port=null,c.path=[],c.query=null,c.fragment=null,c.cannotBeABaseURL=!1,t=j(t,ie,""),t=j(t,oe,"$1")),t=j(t,ae,""),i=f(t);u<=i.length;){switch(o=i[u],l){case be:if(!o||!B($,o)){if(n)return Y;l=Ee;continue}d+=G(o),l=we;break;case we:if(o&&(B(J,o)||"+"===o||"-"===o||"."===o))d+=G(o);else{if(":"!==o){if(n)return Y;d="",l=Ee,u=0;continue}if(n&&(c.isSpecial()!==h(pe,d)||"file"===d&&(c.includesCredentials()||null!==c.port)||"file"===c.scheme&&!c.host))return;if(c.scheme=d,n)return void(c.isSpecial()&&pe[c.scheme]===c.port&&(c.port=null));d="","file"===c.scheme?l=Le:c.isSpecial()&&r&&r.scheme===c.scheme?l=xe:c.isSpecial()?l=Te:"/"===i[u+1]?(l=Se,u++):(c.cannotBeABaseURL=!0,N(c.path,""),l=Ne)}break;case Ee:if(!r||r.cannotBeABaseURL&&"#"!==o)return Y;if(r.cannotBeABaseURL&&"#"===o){c.scheme=r.scheme,c.path=m(r.path),c.query=r.query,c.fragment="",c.cannotBeABaseURL=!0,l=We;break}l="file"===r.scheme?Le:Ce;continue;case xe:if("/"!==o||"/"!==i[u+1]){l=Ce;continue}l=Re,u++;break;case Se:if("/"===o){l=ke;break}l=Fe;continue;case Ce:if(c.scheme=r.scheme,o===e)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=m(r.path),c.query=r.query;else if("/"===o||"\\"===o&&c.isSpecial())l=Ie;else if("?"===o)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=m(r.path),c.query="",l=je;else{if("#"!==o){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=m(r.path),c.path.length--,l=Fe;continue}c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=m(r.path),c.query=r.query,c.fragment="",l=We}break;case Ie:if(!c.isSpecial()||"/"!==o&&"\\"!==o){if("/"!==o){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,l=Fe;continue}l=ke}else l=Re;break;case Te:if(l=Re,"/"!==o||"/"!==L(d,u+1))continue;u++;break;case Re:if("/"!==o&&"\\"!==o){l=ke;continue}break;case ke:if("@"===o){g&&(d="%40"+d),g=!0,a=f(d);for(var y=0;y65535)return X;c.port=c.isSpecial()&&w===pe[c.scheme]?null:w,d=""}if(n)return;l=Ue;continue}return X}d+=o;break;case Le:if(c.scheme="file","/"===o||"\\"===o)l=Be;else{if(!r||"file"!==r.scheme){l=Fe;continue}switch(o){case e:c.host=r.host,c.path=m(r.path),c.query=r.query;break;case"?":c.host=r.host,c.path=m(r.path),c.query="",l=je;break;case"#":c.host=r.host,c.path=m(r.path),c.query=r.query,c.fragment="",l=We;break;default:ye(D(m(i,u),""))||(c.host=r.host,c.path=m(r.path),c.shortenPath()),l=Fe;continue}}break;case Be:if("/"===o||"\\"===o){l=De;break}r&&"file"===r.scheme&&!ye(D(m(i,u),""))&&(ve(r.path[0],!0)?N(c.path,r.path[0]):c.host=r.host),l=Fe;continue;case De:if(o===e||"/"===o||"\\"===o||"?"===o||"#"===o){if(!n&&ve(d))l=Fe;else if(""===d){if(c.host="",n)return;l=Ue}else{if(s=c.parseHost(d))return s;if("localhost"===c.host&&(c.host=""),n)return;d="",l=Ue}continue}d+=o;break;case Ue:if(c.isSpecial()){if(l=Fe,"/"!==o&&"\\"!==o)continue}else if(n||"?"!==o)if(n||"#"!==o){if(o!==e&&(l=Fe,"/"!==o))continue}else c.fragment="",l=We;else c.query="",l=je;break;case Fe:if(o===e||"/"===o||"\\"===o&&c.isSpecial()||!n&&("?"===o||"#"===o)){if(_e(d)?(c.shortenPath(),"/"===o||"\\"===o&&c.isSpecial()||N(c.path,"")):Ae(d)?"/"===o||"\\"===o&&c.isSpecial()||N(c.path,""):("file"===c.scheme&&!c.path.length&&ve(d)&&(c.host&&(c.host=""),d=L(d,0)+":"),N(c.path,d)),d="","file"===c.scheme&&(o===e||"?"===o||"#"===o))for(;c.path.length>1&&""===c.path[0];)W(c.path);"?"===o?(c.query="",l=je):"#"===o&&(c.fragment="",l=We)}else d+=ge(o,de);break;case Ne:"?"===o?(c.query="",l=je):"#"===o?(c.fragment="",l=We):o!==e&&(c.path[0]+=ge(o,ce));break;case je:n||"#"!==o?o!==e&&("'"===o&&c.isSpecial()?c.query+="%27":c.query+="#"===o?"%23":ge(o,ce)):(c.fragment="",l=We);break;case We:o!==e&&(c.fragment+=ge(o,ue))}u++}},parseHost:function(e){var t,n,r;if("["===L(e,0)){if("]"!==L(e,e.length-1))return V;if(t=function(e){var t,n,r,i,o,a,s,c=[0,0,0,0,0,0,0,0],l=0,u=null,h=0,d=function(){return L(e,h)};if(":"===d()){if(":"!==L(e,1))return;h+=2,u=++l}for(;d();){if(8===l)return;if(":"!==d()){for(t=n=0;n<4&&B(te,d());)t=16*t+O(d(),16),h++,n++;if("."===d()){if(0===n)return;if(h-=n,l>6)return;for(r=0;d();){if(i=null,r>0){if(!("."===d()&&r<4))return;h++}if(!B(Q,d()))return;for(;B(Q,d());){if(o=O(d(),10),null===i)i=o;else{if(0===i)return;i=10*i+o}if(i>255)return;h++}c[l]=256*c[l]+i,2!==++r&&4!==r||l++}if(4!==r)return;break}if(":"===d()){if(h++,!d())return}else if(d())return;c[l++]=t}else{if(null!==u)return;h++,u=++l}}if(null!==u)for(a=l-u,l=7;0!==l&&a>0;)s=c[l],c[l--]=c[u+a-1],c[u+--a]=s;else if(8!==l)return;return c}(H(e,1,-1)),!t)return V;this.host=t}else if(this.isSpecial()){if(e=p(e),B(ne,e))return V;if(t=function(e){var t,n,r,i,o,a,s,c=z(e,".");if(c.length&&""===c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(n=[],r=0;r1&&"0"===L(i,0)&&(o=B(Z,i)?16:8,i=H(i,8===o?1:2)),""===i)a=0;else{if(!B(10===o?ee:8===o?K:te,i))return e;a=O(i,o)}N(n,a)}for(r=0;r=M(256,5-t))return null}else if(a>255)return null;for(s=F(n),r=0;r1?arguments[1]:void 0,i=S(t,new ze(e,!1,r));n||(t.href=i.serialize(),t.origin=i.getOrigin(),t.protocol=i.getProtocol(),t.username=i.getUsername(),t.password=i.getPassword(),t.host=i.getHost(),t.hostname=i.getHostname(),t.port=i.getPort(),t.pathname=i.getPathname(),t.search=i.getSearch(),t.searchParams=i.getSearchParams(),t.hash=i.getHash())},Ge=He.prototype,qe=function(e,t){return{get:function(){return C(this)[e]()},set:t&&function(e){return C(this)[t](e)},configurable:!0,enumerable:!0}};if(n&&(l(Ge,"href",qe("serialize","setHref")),l(Ge,"origin",qe("getOrigin")),l(Ge,"protocol",qe("getProtocol","setProtocol")),l(Ge,"username",qe("getUsername","setUsername")),l(Ge,"password",qe("getPassword","setPassword")),l(Ge,"host",qe("getHost","setHost")),l(Ge,"hostname",qe("getHostname","setHostname")),l(Ge,"port",qe("getPort","setPort")),l(Ge,"pathname",qe("getPathname","setPathname")),l(Ge,"search",qe("getSearch","setSearch")),l(Ge,"searchParams",qe("getSearchParams")),l(Ge,"hash",qe("getHash","setHash"))),c(Ge,"toJSON",function(){return C(this).serialize()},{enumerable:!0}),c(Ge,"toString",function(){return C(this).serialize()},{enumerable:!0}),R){var Ye=R.createObjectURL,Ve=R.revokeObjectURL;Ye&&c(He,"createObjectURL",o(Ye,R)),Ve&&c(He,"revokeObjectURL",o(Ve,R))}return b(He,"URL"),t({global:!0,constructor:!0,forced:!r,sham:!n},{URL:He}),yu}ku||(ku=1,Lu());var Bu,Du={};!function(){if(Bu)return Du;Bu=1;var e=mr(),t=_();e({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return t(URL.prototype.toString,this)}})}();var Uu;Uu||(Uu=1,Mu());var Fu,Nu={};!function(){if(Fu)return Nu;Fu=1;var e=Xt(),t=he(),n=Er(),r=Eu(),i=URLSearchParams,o=i.prototype,a=t(o.append),s=t(o.delete),c=t(o.forEach),l=t([].push),u=new i("a=1&a=2&b=3");u.delete("a",1),u.delete("b",void 0),u+""!="a=2"&&e(o,"delete",function(e){var t=arguments.length,i=t<2?void 0:arguments[1];if(t&&void 0===i)return s(this,e);var o=[];c(this,function(e,t){l(o,{key:t,value:e})}),r(t,1);for(var u,h=n(e),d=n(i),f=0,m=0,g=!1,p=o.length;f=n;){const e=nh.keys().next().value;nh.delete(e)}nh.set(e,t)}}const ih={};let oh=null,ah=null,sh=null,ch=null,lh=null,uh=null,hh=null;function dh(e){return e&&"object"==typeof e&&!Array.isArray(e)}function fh(e){const t=[];return JSON.stringify(e,function(e,n){if("object"==typeof n&&null!==n){if(-1!==t.indexOf(n))return;t.push(n)}return n})}const mh={messages:[],logLevelConsole:"warning",logLevelSystem:"error",systemTargetLogLevel:"",addMessage:function(e,t){if(!Xu.debug)return;const n={level:e,date:(new Date).toISOString(),text:"",objs:[],stack:""},r=new Error;r.stack&&(n.stack=r.stack.toString().replace(/^Error\r?\n/,""));for(let e=0;e1e3&&mh.messages.shift()},systemLog(e,t){ah&&ah.hass&&ah.hass.callService("system_log","write",{logger:"frontend.wallpanel".concat(ch?"."+ch:""),message:t,level:mh.systemTargetLogLevel||e},void 0,!1).catch(()=>{})},downloadMessages:function(){const e=new Blob([fh(mh.messages)],{type:"text/plain"}),t=URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.target="_blank",n.download="wallpanel_log.txt",document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(t),0)},purgeMessages:function(){mh.messages=[]},debug:function(){["debug"].includes(mh.logLevelConsole)&&console.debug.apply(this,arguments),["debug"].includes(mh.logLevelSystem)&&mh.systemLog("debug",fh(arguments)),mh.addMessage("debug",arguments)},info:function(){["debug","info"].includes(mh.logLevelConsole)&&console.info.apply(this,arguments),["debug","info"].includes(mh.logLevelSystem)&&mh.systemLog("info",fh(arguments)),mh.addMessage("info",arguments)},log:function(){mh.info.apply(this,arguments)},warning:function(){["debug","info","warning"].includes(mh.logLevelConsole)&&console.warn.apply(this,arguments),["debug","info","warning"].includes(mh.logLevelSystem)&&mh.systemLog("warning",fh(arguments)),mh.addMessage("warning",arguments)},warn:function(){mh.warning.apply(this,arguments)},error:function(){if(["debug","info","warning","error"].includes(mh.logLevelConsole)&&console.error.apply(this,arguments),["debug","info","warning","error"].includes(mh.logLevelSystem)&&mh.systemLog("error",fh(arguments)),mh.addMessage("error",arguments),Xu.alert_errors){const e="Wallpanel error: ".concat(fh(arguments));Ku?Ku.showMessage("error","Error",e,1e4):alert(e)}},err:function(){mh.error.apply(this,arguments)}};class gh{constructor(){this.enabled=!1,this.error=null,this.nativeWakeLockSupported="wakeLock"in navigator,this._lock=null,this._player=null,this._isPlaying=!1,this._onWakeLockRelease=null;const e=()=>{mh.debug("handleVisibilityChange"),this.enabled&&!document.hidden&&this.enable()};if(document.addEventListener("visibilitychange",e),document.addEventListener("fullscreenchange",e),!this.nativeWakeLockSupported){const e="data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAA1NtZGF0AAACrwYF//+r3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE2NCByMzA5NSBiYWVlNDAwIC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMjAyMiAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG9wdGlvbnM6IGNhYmFjPTEgcmVmPTMgZGVibG9jaz0xOi0zOi0zIGFuYWx5c2U9MHgzOjB4MTEzIG1lPWhleCBzdWJtZT03IHBzeT0xIHBzeV9yZD0yLjAwOjAuNzAgbWl4ZWRfcmVmPTEgbWVfcmFuZ2U9MTYgY2hyb21hX21lPTEgdHJlbGxpcz0xIDh4OGRjdD0xIGNxbT0wIGRlYWR6b25lPTIxLDExIGZhc3RfcHNraXA9MSBjaHJvbWFfcXBfb2Zmc2V0PS00IHRocmVhZHM9MSBsb29rYWhlYWRfdGhyZWFkcz0xIHNsaWNlZF90aHJlYWRzPTAgbnI9MCBkZWNpbWF0ZT0xIGludGVybGFjZWQ9MCBibHVyYXlfY29tcGF0PTAgY29uc3RyYWluZWRfaW50cmE9MCBiZnJhbWVzPTMgYl9weXJhbWlkPTIgYl9hZGFwdD0xIGJfYmlhcz0wIGRpcmVjdD0xIHdlaWdodGI9MSBvcGVuX2dvcD0wIHdlaWdodHA9MiBrZXlpbnQ9MjUwIGtleWludF9taW49MSBzY2VuZWN1dD00MCBpbnRyYV9yZWZyZXNoPTAgcmNfbG9va2FoZWFkPTQwIHJjPWNyZiBtYnRyZWU9MSBjcmY9MjMuMCBxY29tcD0wLjYwIHFwbWluPTAgcXBtYXg9NjkgcXBzdGVwPTQgaXBfcmF0aW89MS40MCBhcT0xOjEuMjAAgAAAABFliIQAF85//vfUt8yy7VNwgQAAAAlBmiRsQXzn/vAAAAAJQZ5CeIL5z4aBAAAACQGeYXRBfOeGgAAAAAkBnmNqQXznhoEAAAAPQZpoSahBaJlMCC+c//7xAAAAC0GehkURLBfOf4aBAAAACQGepXRBfOeGgQAAAAkBnqdqQXznhoAAAAAPQZqpSahBbJlMCC+c//7wAAADs21vb3YAAABsbXZoZAAAAAAAAAAAAAAAAAAAA+gAACcQAAEAAAEAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAALddHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAQAAAAAAACcQAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAIAAAACAAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAAnEAAAgAAAAQAAAAACVW1kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAAQAAAAoAAVcQAAAAAAC1oZGxyAAAAAAAAAAB2aWRlAAAAAAAAAAAAAAAAVmlkZW9IYW5kbGVyAAAAAgBtaW5mAAAAFHZtaGQAAAABAAAAAAAAAAAAAAAkZGluZgAAABxkcmVmAAAAAAAAAAEAAAAMdXJsIAAAAAEAAAHAc3RibAAAAMBzdHNkAAAAAAAAAAEAAACwYXZjMQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAIAAgASAAAAEgAAAAAAAAAARVMYXZjNTkuMzcuMTAwIGxpYngyNjQAAAAAAAAAAAAAABj//wAAADZhdmNDAWQACv/hABlnZAAKrNlfllwEQAAAAwBAAAADAIPEiWWAAQAGaOvjxMhM/fj4AAAAABBwYXNwAAAAAQAAAAEAAAAUYnRydAAAAAAAAAKiAAACogAAABhzdHRzAAAAAAAAAAEAAAAKAABAAAAAABRzdHNzAAAAAAAAAAEAAAABAAAAYGN0dHMAAAAAAAAACgAAAAEAAIAAAAAAAQABQAAAAAABAACAAAAAAAEAAAAAAAAAAQAAQAAAAAABAAFAAAAAAAEAAIAAAAAAAQAAAAAAAAABAABAAAAAAAEAAIAAAAAAHHN0c2MAAAAAAAAAAQAAAAEAAAAKAAAAAQAAADxzdHN6AAAAAAAAAAAAAAAKAAACyAAAAA0AAAANAAAADQAAAA0AAAATAAAADwAAAA0AAAANAAAAEwAAABRzdGNvAAAAAAAAAAEAAAAwAAAAYnVkdGEAAABabWV0YQAAAAAAAAAhaGRscgAAAAAAAAAAbWRpcmFwcGwAAAAAAAAAAAAAAAAtaWxzdAAAACWpdG9vAAAAHWRhdGEAAAABAAAAAExhdmY1OS4yNy4xMDA=";this._player=document.createElement("video"),this._player.setAttribute("id","ScreenWakeLockVideo"),this._player.setAttribute("src",e),this._player.setAttribute("playsinline",""),this._player.setAttribute("muted",""),this._player.style.display="none",document.getElementById("ScreenWakeLockVideo")||document.body.appendChild(this._player),this._player.addEventListener("ended",()=>{mh.debug("Video ended"),this.enabled&&this.enable()}),this._player.addEventListener("playing",()=>{mh.debug("Video playing"),this._isPlaying=!0}),this._player.addEventListener("pause",()=>{mh.debug("Video pause"),this._isPlaying=!1})}}enable(){if(this.nativeWakeLockSupported){if(mh.debug("Requesting native screen wakelock"),this._lock)return void mh.debug("Screen wakelock already active");navigator.wakeLock.request("screen").then(e=>{mh.debug("Request screen wakelock successful"),this._lock=e,this._onWakeLockRelease=()=>{mh.debug("Screen wakelock released"),this.enabled=!1,this._lock=null},e.addEventListener("release",this._onWakeLockRelease),this.enabled=!0,this.error=null}).catch(e=>{this.enabled=!1,this.error=e,mh.warning("Failed to request screen wakeLock: ".concat(e))})}else{mh.debug("Starting video player"),!this._player.paused&&this._isPlaying&&this._player.pause();const e=this._player.play();e&&e.then(()=>{this.enabled=!0,this.error=null,mh.debug("Video play successful")}).catch(e=>{this.enabled=!1,this.error=e,mh.warning("Failed to play video: ".concat(e))})}}disable(){this.nativeWakeLockSupported?(mh.debug("Releasing native screen wakelock"),this._lock&&(this._onWakeLockRelease&&(this._lock.removeEventListener("release",this._onWakeLockRelease),this._onWakeLockRelease=null),this._lock.release()),this._lock=null):(mh.debug("Stopping video player"),!this._player.paused&&this._isPlaying&&this._player.pause()),this.enabled=!1}}class ph{constructor(){this.enabled=!1,this.error=!1,this.width=64,this.height=48,this.thresholdRatio=.05,this.threshold=this.width*this.height*this.thresholdRatio,this.captureInterval=300,this.motionActive=!1,this.motionStartDelay=0,this.motionStopDelay=2e3,this.motionDetectionRequiredRatio=.8,this.roomSettledRequiredRatio=1,this.motionStopTimeout=null,this.captureTimer=null,this.referenceImageData=null,this.previousImageData=null,this.referenceChangeRatios=[],this.previousChangeRatios=[],this.maxRatioHistorySize=Math.ceil(6e4/this.captureInterval),this.videoElement=document.createElement("video"),this.videoElement.setAttribute("id","wallpanelMotionDetectionVideo"),this.videoElement.style.display="none",document.body.appendChild(this.videoElement),this.canvasElement=document.createElement("canvas"),this.canvasElement.setAttribute("id","wallpanelMotionDetectionCanvas"),this.canvasElement.style.display="none",document.body.appendChild(this.canvasElement),this.context=this.canvasElement.getContext("2d",{willReadFrequently:!0}),this._elementsAppended=!0}compareImageData(e,t){if(!e||!t)return 0;let n=0;const r=e.data,i=t.data;for(let e=0;e=256&&n++}return n/(this.width*this.height)}storeRatio(e,t){for(e.push(t);e.length>this.maxRatioHistorySize;)e.shift()}getRatiosForInterval(e,t){const n=Math.max(1,Math.ceil(t/this.captureInterval));return e.length0&&e.filter(e=>e>=this.thresholdRatio).length/e.length>=t}hasRequiredRatioBelowThreshold(e,t){return e.length>0&&e.filter(e=>e=t}resetMotionState(){this.motionActive=!1,this.motionStopTimeout&&(clearTimeout(this.motionStopTimeout),this.motionStopTimeout=null),this.referenceImageData=null,this.previousImageData=null,this.referenceChangeRatios=[],this.previousChangeRatios=[]}capture(){this.context.globalCompositeOperation="source-over",this.context.drawImage(this.videoElement,0,0,this.width,this.height);const e=this.context.getImageData(0,0,this.width,this.height);if(!this.referenceImageData)return this.referenceImageData=e,void(this.previousImageData=e);const t=this.compareImageData(e,this.referenceImageData),n=this.compareImageData(e,this.previousImageData);this.previousImageData=e,this.storeRatio(this.referenceChangeRatios,t),this.storeRatio(this.previousChangeRatios,n);const r=this.getRatiosForInterval(this.referenceChangeRatios,this.motionStartDelay),i=this.hasRequiredRatioAboveThreshold(r,this.motionDetectionRequiredRatio),o=this.previousChangeRatios.length>=this.maxRatioHistorySize&&this.hasRequiredRatioBelowThreshold(this.previousChangeRatios,this.roomSettledRequiredRatio);i?(this.motionActive||(mh.debug("Motion started"),this.motionActive=!0,Ku.motionDetected()),this.motionStopTimeout&&(clearTimeout(this.motionStopTimeout),this.motionStopTimeout=null)):this.motionActive&&!this.motionStopTimeout&&(this.motionStopTimeout=setTimeout(()=>{mh.debug("Motion stopped"),this.motionActive=!1,this.motionStopTimeout=null,Ku.motionStopped()},this.motionStopDelay)),o&&(mh.info("Room settled, new reference image stored"),this.referenceImageData=e,this.referenceChangeRatios=[])}start(){if(!this.enabled&&!this.error){if(!navigator.mediaDevices)return this.error=!0,void mh.error("No media devices found");this._elementsAppended||(document.body.appendChild(this.videoElement),document.body.appendChild(this.canvasElement),this._elementsAppended=!0),this.enabled=!0,this.width=Xu.camera_motion_detection_capture_width,this.height=Xu.camera_motion_detection_capture_height,this.thresholdRatio=.01*Xu.camera_motion_detection_threshold,this.threshold=this.width*this.height*this.thresholdRatio,this.captureInterval=1e3*Xu.camera_motion_detection_capture_interval,this.motionStartDelay=1e3*Xu.camera_motion_detection_motion_start_delay,this.motionStopDelay=1e3*Xu.camera_motion_detection_motion_stop_delay,this.maxRatioHistorySize=Math.ceil(6e4/this.captureInterval),this.resetMotionState(),this.videoElement.width=this.width,this.videoElement.height=this.height,this.canvasElement.width=this.width,this.canvasElement.height=this.height,Xu.camera_motion_detection_capture_visible?(this.canvasElement.style.position="fixed",this.canvasElement.style.top=0,this.canvasElement.style.left=0,this.canvasElement.style.zIndex=1e4,this.canvasElement.style.border="1px solid black",this.canvasElement.style.display="block"):this.canvasElement.style.display="none",navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:{ideal:Xu.camera_motion_detection_facing_mode},width:this.width,height:this.height}}).then(e=>{this.videoElement.srcObject=e;const t=this.videoElement.play();t&&t.catch(e=>{mh.warning("Camera motion detection video play failed: ".concat(e))}),this.enabled&&(this.captureTimer=setInterval(this.capture.bind(this),this.captureInterval))}).catch(e=>{this.enabled=!1,mh.error("Camera motion detection error:",e),this._elementsAppended&&(this.videoElement.remove(),this.canvasElement.remove(),this._elementsAppended=!1)})}}stop(){if(!this.enabled)return;this.enabled=!1,this.resetMotionState(),this.captureTimer&&(clearInterval(this.captureTimer),this.captureTimer=null),this.videoElement.pause();const e=this.videoElement.srcObject;e&&"function"==typeof e.getTracks&&e.getTracks().forEach(e=>{e.stop()}),this.videoElement.srcObject=null,this._elementsAppended&&(this.videoElement.remove(),this.canvasElement.remove(),this._elementsAppended=!1)}}const vh=1592614637;function yh(e){return function(){e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function Ah(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Math.random;const n=e.slice();for(let e=n.length-1;e>0;e--){const r=Math.floor(t()*(e+1));[n[e],n[r]]=[n[r],n[e]]}return n}function _h(e){if(!e.shadowRoot)return[null,null];const t=e.shadowRoot.querySelector("ha-web-rtc-player")||e.shadowRoot.querySelector("ha-hls-player");if(!t||!t.shadowRoot)return[t,null];const n=t.shadowRoot.querySelector("video");return[t,n]}function bh(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;rc(e)):dh(t)&&(t=Object.fromEntries(Object.entries(t).map(e=>{let[t,n]=e;return[t,c(n)]}))),"boolean"==typeof e[o]&&(t=null!=t&&["true","on","yes","1"].includes(String(t).toLowerCase())),t}a=c(a),Array.isArray(e[o])&&"string"==typeof a&&(a=a.split(",").map(e=>e.trim())),Object.assign(e,{[o]:a})}}return bh(e,...n)}function wh(){const e=new URLSearchParams(window.location.search),t=Xu;Xu={},bh(Xu,qu),0===Object.keys(Vu).length&&(Vu=Th(),0===Object.keys(Vu).length&&mh.debug("No wallpanel config found in dashboard config")),bh(Xu,Vu);const n={};for(let[t,r]of e)if(t.startsWith("wp_")&&(t=t.substring(3),Yu[t]&&(mh.warn("The configuration option '".concat(t,"' has been renamed to '").concat(Yu[t],"'. Please update your wallpanel configuration accordingly.")),t=Yu[t]),t in qu&&r)){try{r=JSON.parse(r)}catch(e){}const e=qu[t];if(Array.isArray(e))Array.isArray(r)?n[t]=r:n[t]="string"==typeof r?r.split(",").map(e=>e.trim()):[r];else if("boolean"==typeof e)n[t]=["true","on","yes","1"].includes(String(r));else if("number"==typeof e){const e=Number(r);Number.isFinite(e)?n[t]=e:mh.warn("Invalid numeric wp_ param '".concat(t,"': ").concat(r))}else n[t]=r}Xu=bh(Xu,n);const r=Xu.profile;if(Xu.profiles&&r&&Xu.profiles[r]&&(Xu=bh(Xu,Xu.profiles[r]),mh.debug("Profile set from config: ".concat(r))),Xu.profiles&&ch&&Xu.profiles["device.".concat(ch)]){const e="device.".concat(ch);Xu=bh(Xu,Xu.profiles[e]),mh.debug("Profile set from device: ".concat(e))}if(Xu.profiles){const e=[lh,uh,hh];for(let t=0;t{t.tagName.toLowerCase().startsWith("browser-mod-popup")&&t.shadowRoot&&t.shadowRoot.querySelector("ha-dialog")&&e.push(t)}),e):e}function xh(){const e=Eh();return e&&0!=e.length?e[0]:null}function Sh(){if("1"==new URLSearchParams(window.location.search).get("edit"))return mh.debug("Edit mode active"),!1;if(!Xu.enabled)return mh.debug("Wallpanel not enabled in config"),!1;if(Xu.enabled_on_views&&Xu.enabled_on_views.length>0&&Qu&&!Xu.enabled_on_views.includes(Qu))return mh.debug("Wallpanel not enabled on current tab ".concat(Qu)),!1;if(Xu.disable_screensaver_when_assist_active){const e=ah.shadowRoot.querySelector("ha-voice-command-dialog");if(e&&e.shadowRoot&&e.shadowRoot.querySelector("ha-dialog"))return mh.debug("Assist is active, wallpanel disabled"),!1}return Ku&&Ku.disable_screensaver_on_browser_mod_popup_function&&xh()&&Ku.disable_screensaver_on_browser_mod_popup_function(xh())?(mh.debug("Browser mod popup function returned true, wallpanel disabled"),!1):!Xu.disable_screensaver_on_browser_mod_popup||!xh()||(mh.debug("Browser mod popup active, wallpanel disabled"),!1)}function Ch(){return Xu.show_images&&Xu.image_url?Xu.image_url.startsWith("media-entity-video://")?"media-entity-video":Xu.image_url.startsWith("media-entity-image://")?"media-entity-image":Xu.image_url.startsWith("media-source://")?"media-source":Xu.image_url.startsWith("https://api.unsplash")?"unsplash-api":Xu.image_url.startsWith("immich+")?"immich-api":Xu.image_url.startsWith("iframe+")?"iframe":Xu.image_url.startsWith("embed+")?"embed":"url":""}function Ih(){try{return sh.shadowRoot.querySelector("ha-panel-lovelace")}catch(e){mh.error("Failed to get ha-panel-lovelace:",e)}}function Th(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const t=Ih(),n={};if(t&&t.lovelace){let r;t.lovelace.config&&t.lovelace.config.wallpanel?r=t.lovelace.config.wallpanel:t.lovelace.rawConfig&&t.lovelace.rawConfig.wallpanel&&(r=t.lovelace.rawConfig.wallpanel),r&&(0===e.length&&(e=Object.keys(r)),e.forEach(e=>{(e in qu||e in Yu)&&(n[e]=r[e])}))}return n}function Rh(e){mh.debug("setSidebarVisibility: hidden=".concat(e));try{const t=sh.shadowRoot.querySelector("ha-panel-lovelace");if(t){const n=t.shadowRoot.querySelector("hui-root");if(n){const t=n.shadowRoot.querySelector("ha-menu-button");t&&(e?t.style.display="none":t.style.removeProperty("display"))}}}catch(e){mh.warn(e)}try{const t=sh.shadowRoot.querySelector("ha-drawer");if(t){const n=t.shadowRoot.querySelector(".sidebar-shell")||t.shadowRoot.querySelector("aside"),r=n&&n.classList.contains("sidebar-shell")?"--ha-sidebar-width":"--mdc-drawer-width";n&&(e?(n.style.opacity=0,n.style.maxWidth="0px",sh.style.setProperty(r,"env(safe-area-inset-left)")):(n.style.opacity=1,n.style.maxWidth="",sh.style.removeProperty(r)),window.dispatchEvent(new Event("resize")))}}catch(e){mh.warn(e)}}function kh(e,t){mh.debug("setToolbarVisibility: hideToolbar=".concat(e,", hideActionItems=").concat(t));try{const n=sh.shadowRoot.querySelector("ha-panel-lovelace");if(!n)return;let r=n.shadowRoot.querySelector("hui-root");if(!r)return;r=r.shadowRoot;const i=r.querySelector("#view");let o=r.querySelector("app-toolbar");if(o||(o=r.querySelector("div.toolbar")),e)o.style.setProperty("display","none"),Xu.keep_toolbar_space||(i.style.minHeight="100vh",i.style.marginTop="0",i.style.paddingTop="0");else{o.style.removeProperty("display"),i.style.removeProperty("min-height"),i.style.removeProperty("margin-top"),i.style.removeProperty("padding-top");const e=o.querySelector("div.action-items");t?e.style.setProperty("display","none"):e.style.setProperty("display","flex")}window.dispatchEvent(new Event("resize"))}catch(e){mh.warn(e)}}function Oh(){return void 0!==document.fullscreenElement?Boolean(document.fullscreenElement):void 0!==document.webkitCurrentFullScreenElement&&Boolean(document.webkitCurrentFullScreenElement)}function Ph(){mh.debug("Enter fullscreen");const e=document.documentElement;e.requestFullscreen?e.requestFullscreen().then(()=>{mh.debug("Successfully requested fullscreen")},e=>{mh.debug("Failed to enter fullscreen:",e)}):e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen?e.msRequestFullscreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen()}function Mh(){const e=customElements.get("hui-view-container"),t=customElements.get("hui-view");if(!e||!t){throw new Error("Failed to get hui-view-container / hui-view from customElements")}class r extends e{}class i extends t{constructor(){super(),this.mediaList=[],this.mediaIndex=-1,this.mediaListDirection="forwards",this.lastMediaListUpdate,this.updatingMediaList=!1,this.updatingMedia=!1,this.lastMediaUpdate=0,this.isPaused=!1,this.displayTime=null,this.mediaTimeElapsedBeforePause=0,this.lastImageUrlEntityValue=null,this.blockEventsUntil=0,this.screensaverStartedAt,this.screensaverStoppedAt=new Date,this.infoBoxContentCreatedDate,this.idleSince=Date.now(),this.lastProfileSet=Xu.profile,this.lastMove=null,this.lastCorner=0,this.translateTimeout=null,this.lastClickTime=0,this.clickCount=0,this.touchStartX=-1,this.touchStartY=-1,this.currentWidth=0,this.currentHeight=0,this.energyCollectionUpdateEnabled=!1,this.energyCollectionUpdateInterval=60,this.lastEnergyCollectionUpdate=0,this.screensaverStopNavigationPathTimeout=null,this.disable_screensaver_on_browser_mod_popup_function=null,this.moreInfoDialogOpenedAt=0,this.timerInterval=null,this.windowEventHandlers=[],this.infoBoxResizeObserver=null,this.screenWakeLock=new gh,this.cameraMotionDetection=new ph,this.lovelace=null,this.__hass=ah.hass||ah.__hass,this.__cards=[],this.__badges=[],this.__views=[],ah.provideHass(this),this.timerInterval=setInterval(this.timer.bind(this),1e3),Zu.hass=this.__hass}set hass(e){mh.debug("Update hass"),this.__hass=e;let t=!1;for(const e in ih){const n=this.__hass.states[e];n&&n.state!=ih[e]&&(ih[e]=n.state,t=!0)}if(!this.updateProfile()&&t&&wh(),!Sh())return;const n=Xu.screensaver_entity;if(n&&this.__hass.states[n]){const e=new Date(this.__hass.states[n].last_changed),t=this.__hass.states[n].state;"off"==t&&this.screensaverStartedAt&&e.getTime()-this.screensaverStartedAt>0?this.stopScreensaver(Xu.fade_out_time_screensaver_entity):"on"==t&&this.screensaverStoppedAt&&e.getTime()-this.screensaverStoppedAt>0&&this.startScreensaver()}this.screensaverRunning()&&(this.__cards.forEach(e=>{e.hass=this.hass}),this.__badges.forEach(e=>{e.hass=this.hass}),this.__views.forEach(e=>{e.hass=this.hass}),"media-entity-image"==Ch()&&this.switchActiveMedia("entity_update"))}get hass(){return this.__hass}setScreensaverEntityState(){const e=Xu.screensaver_entity;if(!e||!this.__hass.states[e])return;if(this.screensaverRunning()&&"on"==this.__hass.states[e].state)return;if(!this.screensaverRunning()&&"off"==this.__hass.states[e].state)return;const t=this.screensaverRunning()?"turn_on":"turn_off";mh.debug("Updating screensaver_entity",e,t),this.__hass.callService("input_boolean",t,{entity_id:e}).then(e=>{mh.debug(e)},e=>{mh.error("Failed to set screensaver entity state:",e)})}setImageURLEntityState(){const e=Xu.image_url_entity;if(!e||!this.__hass.states[e])return;const t=this.getActiveMediaElement();if(!t||!t.mediaUrl)return;const n=t.mediaUrl.substring(0,255);this.lastImageUrlEntityValue!==n&&(mh.debug("Updating image_url_entity",e,n),this.__hass.callService("input_text","set_value",{entity_id:e,value:n}).then(e=>{mh.debug(e),this.lastImageUrlEntityValue=n},e=>{mh.error("Failed to set image url entity state:",e)}))}updateProfile(){const e=Xu.profile_entity;if(e&&this.__hass.states[e]){const t=this.__hass.states[e].state;if(t&&t!=this.lastProfileSet||!t&&this.lastProfileSet)return mh.debug("Set profile to ".concat(t)),this.lastProfileSet=t,wh(),!0}return!1}timer(){Xu.enabled&&Ju&&(this.screensaverRunning()?Xu.disable_screensaver_on_browser_mod_popup&&xh()?this.stopScreensaver(Xu.fade_out_time_browser_mod_popup):this.updateScreensaver():Sh()&&Xu.idle_time>0&&Date.now()-this.idleSince>=1e3*Xu.idle_time&&(Xu.camera_motion_detection_stop_screensaver&&this.cameraMotionDetection&&this.cameraMotionDetection.motionActive||this.startScreensaver()))}setDefaultStyle(){this.messageContainer.removeAttribute("style"),this.messageContainer.style.position="fixed",this.messageContainer.style.top="1rem",this.messageContainer.style.left="1rem",this.messageContainer.style.bottom="1rem",this.messageContainer.style.right="1rem",this.messageContainer.style.alignItems="flex-end",this.messageContainer.style.display="flex",this.messageContainer.style.flexDirection="column",this.messageContainer.style.gap="0.5rem",this.messageContainer.style.zIndex=this.style.zIndex+1,this.messageContainer.style.pointerEvents="none",this.messageContainer.style.visibility="hidden",this.debugBox.removeAttribute("style"),this.debugBox.style.position="fixed",this.debugBox.style.pointerEvents="none",this.debugBox.style.top="0%",this.debugBox.style.left="0%",this.debugBox.style.width="100%",this.debugBox.style.height="100%",this.debugBox.style.background="#00000099",this.debugBox.style.color="#ffffff",this.debugBox.style.zIndex=this.style.zIndex+2,this.debugBox.style.fontFamily="monospace",this.debugBox.style.fontSize="12px",this.debugBox.style.overflowWrap="break-word",this.debugBox.style.overflowY="auto",this.debugBox.style.visibility="hidden",this.screensaverContainer.removeAttribute("style"),this.screensaverContainer.style.position="fixed",this.screensaverContainer.style.pointerEvents="auto",this.screensaverContainer.style.top=0,this.screensaverContainer.style.right=0,this.screensaverContainer.style.bottom=0,this.screensaverContainer.style.left=0,this.screensaverContainer.style.background="#000000",this.screensaverContainer.style.overflow="hidden",this.imageOneContainer.removeAttribute("style"),this.imageOneContainer.style.opacity=0,this.imageOneContainer.style.position="absolute",this.imageOneContainer.style.pointerEvents="none",this.imageOneContainer.style.top=0,this.imageOneContainer.style.left=0,this.imageOneContainer.style.width="100%",this.imageOneContainer.style.height="100%",this.imageOneContainer.style.border="none",this.imageOneBackground.style.position="absolute",this.imageOneBackground.style.pointerEvents="none",this.imageOneBackground.style.top=0,this.imageOneBackground.style.left=0,this.imageOneBackground.style.width="100%",this.imageOneBackground.style.height="100%",this.imageOneBackground.style.border="none",this.imageOne.removeAttribute("style"),this.imageOne.style.position="relative",this.imageOne.style.pointerEvents="none",this.imageOne.style.width="100%",this.imageOne.style.height="100%",this.imageOne.style.border="none",this.imageOneInfoContainer.removeAttribute("style"),this.imageOneInfoContainer.style.position="absolute",this.imageOneInfoContainer.style.pointerEvents="none",this.imageOneInfoContainer.style.top=0,this.imageOneInfoContainer.style.left=0,this.imageOneInfoContainer.style.width="100%",this.imageOneInfoContainer.style.height="100%",this.imageOneInfoContainer.style.border="none",this.imageOneInfo.style.overflowY="auto",this.imageTwoContainer.removeAttribute("style"),this.imageTwoContainer.style.opacity=0,this.imageTwoContainer.style.position="absolute",this.imageTwoContainer.style.pointerEvents="none",this.imageTwoContainer.style.top=0,this.imageTwoContainer.style.left=0,this.imageTwoContainer.style.width="100%",this.imageTwoContainer.style.height="100%",this.imageTwoContainer.style.border="none",this.imageTwoBackground.style.position="absolute",this.imageTwoBackground.style.pointerEvents="none",this.imageTwoBackground.style.top=0,this.imageTwoBackground.style.left=0,this.imageTwoBackground.style.width="100%",this.imageTwoBackground.style.height="100%",this.imageTwoBackground.style.border="none",this.imageTwo.removeAttribute("style"),this.imageTwo.style.position="relative",this.imageTwo.style.pointerEvents="none",this.imageTwo.style.width="100%",this.imageTwo.style.height="100%",this.imageTwo.style.border="none",this.imageTwoInfoContainer.removeAttribute("style"),this.imageTwoInfoContainer.style.position="absolute",this.imageTwoInfoContainer.style.pointerEvents="none",this.imageTwoInfoContainer.style.top=0,this.imageTwoInfoContainer.style.left=0,this.imageTwoInfoContainer.style.width="100%",this.imageTwoInfoContainer.style.height="100%",this.imageTwoInfoContainer.style.border="none",this.imageTwoInfo.style.overflowY="auto",this.screensaverImageOverlay.removeAttribute("style"),this.screensaverImageOverlay.style.position="absolute",this.screensaverImageOverlay.style.top=0,this.screensaverImageOverlay.style.left=0,this.screensaverImageOverlay.style.width="100%",this.screensaverImageOverlay.style.height="100%",this.screensaverImageOverlay.style.background="#00000000",this.infoContainer.removeAttribute("style"),this.infoContainer.style.position="absolute",this.infoContainer.style.pointerEvents="none",this.infoContainer.style.top=0,this.infoContainer.style.left=0,this.infoContainer.style.width="100%",this.infoContainer.style.height="100%",this.infoContainer.style.transition="opacity 2000ms ease-in-out",this.infoContainer.style.padding="25px",this.infoContainer.style.boxSizing="border-box",this.infoBox.removeAttribute("style"),this.infoBox.style.pointerEvents="none",this.infoBox.style.width="fit-content",this.infoBox.style.maxHeight="100%",this.infoBox.style.borderRadius="10px",this.infoBox.style.overflowY="auto",this.infoBox.style.scrollbarWidth="none",this.infoBox.style.setProperty("--wp-card-width","500px"),this.infoBox.style.setProperty("--wp-card-padding","0"),this.infoBox.style.setProperty("--wp-card-margin","5px"),this.infoBox.style.setProperty("--wp-card-backdrop-filter","none"),this.infoBox.style.setProperty("--wp-badges-minwidth","200px"),this.infoBoxPosX.style.pointerEvents="none",this.infoBoxPosX.style.height="100%",this.infoBoxPosX.style.width="100%",this.infoBoxPosY.style.pointerEvents="none",this.infoBoxPosY.style.height="100%",this.infoBoxPosY.style.width="100%",this.infoBoxContent.style.pointerEvents="none",this.infoBoxContent.style.width="fit-content",this.infoBoxContent.style.height="100%",this.infoBoxContent.style.display="grid",this.fixedInfoContainer.removeAttribute("style"),this.fixedInfoContainer.style.position="fixed",this.fixedInfoContainer.style.pointerEvents="none",this.fixedInfoContainer.style.top=0,this.fixedInfoContainer.style.left=0,this.fixedInfoContainer.style.width="100%",this.fixedInfoContainer.style.height="100%",this.fixedInfoBox.style.pointerEvents="none",this.fixedInfoBox.style.cssText=this.infoBox.style.cssText,this.screensaverOverlay.removeAttribute("style"),this.screensaverOverlay.style.position="absolute",this.screensaverOverlay.style.pointerEvents="none",this.screensaverOverlay.style.top=0,this.screensaverOverlay.style.left=0,this.screensaverOverlay.style.width="100%",this.screensaverOverlay.style.height="100%",this.screensaverOverlay.style.background="#00000000"}updateStyle(){this.screensaverOverlay.style.background="#00000000",this.debugBox.style.visibility=Xu.debug?"visible":"hidden",this.debugBox.style.pointerEvents=Xu.debug?"auto":"none",this.style.transition=Xu.fade_in_time>0?"opacity ".concat(Math.round(1e3*Xu.fade_in_time),"ms ease-in-out"):"",this.imageOneContainer.style.transition=Xu.crossfade_time>0?"opacity ".concat(Math.round(1e3*Xu.crossfade_time),"ms ease-in-out"):"",this.imageTwoContainer.style.transition=Xu.crossfade_time>0?"opacity ".concat(Math.round(1e3*Xu.crossfade_time),"ms ease-in-out"):"",this.messageContainer.style.visibility=this.screensaverRunning()?"visible":"hidden",this.screensaverImageOverlay.style.pointerEvents=Xu.content_interaction?"none":"auto";const e=Xu.show_image_info&&Boolean(Xu.image_info_template);if(this.imageOneInfoContainer.style.display=e?"block":"none",this.imageTwoInfoContainer.style.display=e?"block":"none",Xu.info_animation_duration_x?this.infoBoxPosX.style.animation="moveX ".concat(Xu.info_animation_duration_x,"s ").concat(Xu.info_animation_timing_function_x," infinite alternate"):this.infoBoxPosX.style.animation="",Xu.info_animation_duration_y?this.infoBoxPosY.style.animation="moveY ".concat(Xu.info_animation_duration_y,"s ").concat(Xu.info_animation_timing_function_y," infinite alternate"):this.infoBoxPosY.style.animation="",Xu.style)for(const e in Xu.style)if(e.startsWith("wallpanel-")&&"wallpanel-shadow-host"!=e&&"wallpanel-screensaver-info-box-badges"!=e&&"wallpanel-screensaver-info-box-views"!=e&&!th[e]){const t=this.shadowRoot.getElementById(e);if(t){mh.debug("Setting style attributes for element #".concat(e));for(const n in Xu.style[e])mh.debug("Setting style attribute ".concat(n," to ").concat(Xu.style[e][n])),t.style.setProperty(n,Xu.style[e][n]);t==this.infoBox?this.fixedInfoBox.style.cssText=this.infoBox.style.cssText:t==this.infoBoxContent&&(this.fixedInfoBoxContent.style.cssText=this.infoBoxContent.style.cssText)}else mh.error("Element #".concat(e," not found"))}}updateShadowStyle(){const e=getComputedStyle(this.infoContainer),t=this.infoContainer.offsetWidth-parseInt(e.paddingLeft)-parseInt(e.paddingRight)-this.infoBox.offsetWidth,n=this.infoContainer.offsetHeight-parseInt(e.paddingTop)-parseInt(e.paddingBottom)-this.infoBox.offsetHeight;let r="";if(Xu.style){if(Xu.style["wallpanel-shadow-host"])for(const e in Xu.style["wallpanel-shadow-host"])r+="".concat(e,": ").concat(Xu.style["wallpanel-shadow-host"][e],";\n");for(const e in th)Xu.style[e]&&bh(th[e],Xu.style[e])}let i="";for(const e in th){i+=".".concat(e," {\n");for(const t in th[e])i+="".concat(t,": ").concat(th[e][t],";\n");i+="}\n"}this.shadowStyle.innerHTML="\n\t\t\t\t:host {\n\t\t\t\t\t".concat(r,"\n\t\t\t\t}\n\t\t\t\t@keyframes moveX {\n\t\t\t\t\t100% {\n\t\t\t\t\t\ttransform: translate3d(").concat(t,"px, 0, 0);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t@keyframes moveY {\n\t\t\t\t\t100% {\n\t\t\t\t\t\ttransform: translate3d(0, ").concat(n,"px, 0);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t@keyframes horizontalProgress {\n\t\t\t\t\t0% {\n\t\t\t\t\t\twidth: 0%;\n\t\t\t\t\t}\n\t\t\t\t\t100% {\n\t\t\t\t\t\twidth: 100%;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t@keyframes kenBurnsEffect-experimental {\n\t\t\t\t\t0% {\n\t\t\t\t\t\ttransform: scale(1.0) translateX(calc(var(--hidden-width) / -2 * 1px)) translateY(calc(var(--hidden-height) / -2 * 1px));\n\t\t\t\t\t}\n\t\t\t\t\t50% {\n\t\t\t\t\t\ttransform: scale(var(--ken-burns-zoom));\n\t\t\t\t\t}\n\t\t\t\t\t90% {\n\t\t\t\t\t\ttransform: scale(calc(1.0 + ((var(--ken-burns-zoom) - 1.0)/2))) translateX(calc(var(--hidden-width) / 2 * 1px)) translateY(calc(var(--hidden-height) / 2 * 1px));\n\t\t\t\t\t}\n\t\t\t\t\t100% {\n\t\t\t\t\t\ttransform: scale(1.0);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t@keyframes kenBurnsEffect-experimental2 {\n\t\t\t\t\t0% {\n\t\t\t\t\t\ttransform: scale(1.0);\n\t\t\t\t\t}\n\t\t\t\t\t25% {\n\t\t\t\t\t\ttransform: scale(calc(1.0 + ((var(--ken-burns-zoom) - 1.0)/2))) translateX(calc(var(--hidden-width) / 2 * 1px)) translateY(calc(var(--hidden-height) / 2 * 1px));\n\t\t\t\t\t}\n\t\t\t\t\t50% {\n\t\t\t\t\t\ttransform: scale(var(--ken-burns-zoom));\n\t\t\t\t\t}\n\t\t\t\t\t75% {\n\t\t\t\t\t\ttransform: scale(calc(1.0 + ((var(--ken-burns-zoom) - 1.0)/2))) translateX(calc(var(--hidden-width) / -2 * 1px)) translateY(calc(var(--hidden-height) / -2 * 1px));\n\t\t\t\t\t}\n\t\t\t\t\t100% {\n\t\t\t\t\t\ttransform: scale(1.0);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t@keyframes kenBurnsEffect-simple {\n\t\t\t\t\t0% {\n\t\t\t\t\t\ttransform-origin: bottom left;\n\t\t\t\t\t\ttransform: scale(1.0);\n\t\t\t\t\t}\n\t\t\t\t\t100% {\n\t\t\t\t\t\ttransform: scale(var(--ken-burns-zoom));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t").concat(i,"\n\t\t\t\t").concat(Xu.custom_css,"\n\t\t\t")}randomMove(){const e=getComputedStyle(this.infoContainer),t=this.infoContainer.offsetWidth-parseInt(e.paddingLeft)-parseInt(e.paddingRight)-this.infoBox.offsetWidth,n=this.infoContainer.offsetHeight-parseInt(e.paddingTop)-parseInt(e.paddingBottom)-this.infoBox.offsetHeight,r=Math.floor(Math.random()*t),i=Math.floor(Math.random()*n);this.moveInfoBox(r,i)}moveAroundCorners(){let e=null;arguments.length>0&&void 0!==arguments[0]&&arguments[0]?e=0:this.lastCorner=(this.lastCorner+1)%4;const t=getComputedStyle(this.infoContainer),n=[2,3].includes(this.lastCorner)?this.infoContainer.offsetWidth-parseInt(t.paddingLeft)-parseInt(t.paddingRight)-this.infoBox.offsetWidth:0,r=[1,2].includes(this.lastCorner)?this.infoContainer.offsetHeight-parseInt(t.paddingTop)-parseInt(t.paddingBottom)-this.infoBox.offsetHeight:0;this.moveInfoBox(n,r,e)}moveInfoBox(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(this.lastMove=Date.now(),null===n&&(n=Xu.info_move_fade_duration),n>0)if(this.infoBox.animate){const e=[{opacity:1},{opacity:0,offset:.5},{opacity:1}];this.infoBox.animate(e,{duration:Math.round(1e3*n),iterations:1})}else mh.warn("This browser does not support the animate() method, please set info_move_fade_duration to 0");const r=this;let i=Math.round(500*n);i<0&&(i=0),r.translateTimeout&&clearTimeout(r.translateTimeout),r.translateTimeout=setTimeout(function(){r.infoBoxPosX.style.transform="translate3d(".concat(e,"px, 0, 0)"),r.infoBoxPosY.style.transform="translate3d(0, ".concat(t,"px, 0)")},i)}createInfoBoxContent(){mh.debug("Creating info box content");const e=Ih();if(e){if(this.lovelace=e.lovelace||e.__lovelace,this.infoBoxContentCreatedDate=new Date,this.infoBoxContent.innerHTML="",this.__badges=[],this.__cards=[],this.__views=[],this.energyCollectionUpdateEnabled=!1,this.shadowRoot.querySelectorAll(".wp-card").forEach(e=>{e.parentElement.removeChild(e)}),Xu.badges&&Xu.badges.length>0){const e=document.createElement("div");if(e.id="wallpanel-screensaver-info-box-badges",e.classList.add("wp-badges"),e.style.padding="var(--wp-card-padding)",e.style.margin="var(--wp-card-margin)",e.style.textAlign="center",e.style.display="flex",e.style.alignItems="flex-start",e.style.flexWrap="wrap",e.style.justifyContent="center",e.style.gap="8px",e.style.margin="0px",e.style.minWidth="var(--wp-badges-minwidth)",Xu.style[e.id])for(const t in Xu.style[e.id])mh.debug("Setting style attribute ".concat(t," to ").concat(Xu.style[e.id][t])),e.style.setProperty(t,Xu.style[e.id][t]);Xu.badges.forEach(t=>{const n=JSON.parse(JSON.stringify(t));mh.debug("Creating badge:",n);let r={};n.wp_style&&(r=n.wp_style,delete n.wp_style);const i=(this._createBadgeElement?this._createBadgeElement:this.createBadgeElement).bind(this)(n);i.hass=this.hass;for(const e in r)i.style.setProperty(e,r[e]);this.__badges.push(i),e.append(i)}),this.infoBoxContent.appendChild(e)}if(Xu.views&&Xu.views.length>0){const e=document.createElement("div");if(e.id="wallpanel-screensaver-info-box-views",e.classList.add("wp-views"),Xu.style[e.id])for(const t in Xu.style[e.id])mh.debug("Setting style attribute ".concat(t," to ").concat(Xu.style[e.id][t])),e.style.setProperty(t,Xu.style[e.id][t]);const t=this.lovelace.config.views;Xu.views.forEach(n=>{let r=-1;const i=JSON.parse(JSON.stringify(n));for(var o=0;o0&&Xu.cards.forEach(e=>{const t=JSON.parse(JSON.stringify(e));mh.debug("Creating card:",t);let n={};t.wp_style&&(n=t.wp_style,delete t.wp_style),t.type&&t.type.includes("energy")&&(t.collection_key="energy_wallpanel",this.energyCollectionUpdateEnabled=!0);const r=(this._createCardElement?this._createCardElement:this.createCardElement).bind(this)(t);r.hass=this.hass,this.__cards.push(r);let i=this.infoBoxContent;const o=document.createElement("div");o.classList.add("wp-card"),o.style.width="var(--wp-card-width)",o.style.padding="var(--wp-card-padding)",o.style.margin="var(--wp-card-margin)",o.style.backdropFilter="var(--wp-card-backdrop-filter)",Xu.content_interaction?o.style.pointerEvents="auto":o.style.pointerEvents="none";for(const e in n)if("parent"==e){const t=this.shadowRoot.getElementById(n[e]);t&&(i=t)}else o.style.setProperty(e,n[e]);o.append(r),i.appendChild(o)}),setTimeout(this.updateShadowStyle.bind(this),500)}}setDisplayTime(){const e=Xu.display_time,t=this.getActiveMediaElement(!0);t.updateMediaError?this.displayTime=0:t.play_to_end&&!t.loop?this.displayTime=t.duration:this.displayTime=e}getDisplayTime(){return this.displayTime}restartProgressBarAnimation(){if(!this.progressBarContainer)return;if(this.progressBar.style.animation="none",!Xu.show_progress_bar)return;const e=this;setTimeout(function(){e.progressBar.style.animation="horizontalProgress ".concat(e.getDisplayTime(),"s linear"),e.progressBar.style.animationPlayState=e.isPaused?"paused":"running"},25)}restartKenBurnsEffect(){if(!Xu.image_animation_ken_burns||!Xu.image_animation_ken_burns_animations.length)return;const e=this.getActiveMediaElement();e.style.animation="none",e.style.setProperty("--ken-burns-zoom",Xu.image_animation_ken_burns_zoom);let t=Math.floor(1e3*Xu.image_animation_ken_burns_delay);t<50&&(t=50);const n=Math.ceil(Xu.image_animation_ken_burns_duration||1.2*(this.getDisplayTime()+2*Xu.crossfade_time)),r=Xu.image_animation_ken_burns_animations[Math.floor(Math.random()*Xu.image_animation_ken_burns_animations.length)];this.kenburnsDelayStartTimer&&clearTimeout(this.kenburnsDelayStartTimer),e.animationIterationCount=1,this.kenburnsDelayStartTimer=setTimeout(function(){e.style.animation="kenBurnsEffect-".concat(r," ").concat(n,"s linear forwards")},t)}getMediaElement(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this.imageOneContainer.style.opacity==(e?1:0)?this.imageOne:this.imageTwo;if(t&&"ha-camera-stream"==n.tagName.toLowerCase()){const e=_h(n)[1];e&&(n=e)}return n}getActiveMediaElement(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.getMediaElement(!0,e)}getInactiveMediaElement(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.getMediaElement(!1,e)}replaceMediaElement(e,t){if("string"==typeof e.src&&e.src.startsWith("blob:")&&URL.revokeObjectURL(e.src),"function"==typeof e.pause&&e.pause(),"ha-camera-stream"==e.tagName.toLowerCase()){const[t,n]=_h(e);n&&n.pause(),t&&"function"==typeof t.stop&&t.stop()}t=t.toLowerCase();const n=document.createElement(t);return[...e.attributes].filter(e=>"src"!=e.name).forEach(e=>n.setAttribute(e.name,e.value)),n.mediaUrl=e.mediaUrl,n.infoCacheUrl=e.infoCacheUrl,"video"===t&&Object.assign(n,{preload:"auto",muted:!1,volume:Xu.video_volume}),e.replaceWith(n),e===this.imageOne?this.imageOne=n:this.imageTwo=n,e.remove(),n}loadBackgroundImage(e){let t=e.src;const n=e.tagName.toLowerCase();if("ha-camera-stream"===n){const n=_h(e)[1];if(!n||!n.poster)return;t=n.poster}else if("video"===n){const n=document.createElement("canvas");n.width=e.videoWidth,n.height=e.videoHeight;n.getContext("2d").drawImage(e,0,0,n.width,n.height);try{t=n.toDataURL("image/png")}catch(e){t=null,mh.error("Error extracting canvas image:",e)}}let r=this.imageOneBackground;e==this.imageTwo&&(r=this.imageTwoBackground),r.style.backgroundImage=t?"url('".concat(t.replace(/'/g,"%27"),"')"):""}connectedCallback(){this.style.zIndex=Xu.z_index,this.style.visibility="hidden",this.style.opacity=0,this.style.position="fixed",this.timerInterval||(this.timerInterval=setInterval(this.timer.bind(this),1e3)),this.messageContainer=document.createElement("div"),this.messageContainer.id="wallpanel-message-container",this.debugBox=document.createElement("div"),this.debugBox.id="wallpanel-debug-box",this.screensaverContainer=document.createElement("div"),this.screensaverContainer.id="wallpanel-screensaver-container",this.imageOneContainer=document.createElement("div"),this.imageOneContainer.id="wallpanel-screensaver-image-one-container",this.imageOneBackground=document.createElement("div"),this.imageOneBackground.className="wallpanel-screensaver-image-background",this.imageOneBackground.id="wallpanel-screensaver-image-one-background",this.imageOne=document.createElement("img"),this.imageOne.id="wallpanel-screensaver-image-one",this.imageOneInfoContainer=document.createElement("div"),this.imageOneInfoContainer.className="wallpanel-screensaver-image-info-container",this.imageOneInfoContainer.id="wallpanel-screensaver-image-one-info-container",this.imageOneInfo=document.createElement("div"),this.imageOneInfo.className="wallpanel-screensaver-image-info",this.imageOneInfo.id="wallpanel-screensaver-image-one-info",this.imageOneInfoContainer.appendChild(this.imageOneInfo),this.imageOneContainer.appendChild(this.imageOneBackground),this.imageOneContainer.appendChild(this.imageOne),this.imageOneContainer.appendChild(this.imageOneInfoContainer),this.screensaverContainer.appendChild(this.imageOneContainer),this.imageTwoContainer=document.createElement("div"),this.imageTwoContainer.id="wallpanel-screensaver-image-two-container",this.imageTwoBackground=document.createElement("div"),this.imageTwoBackground.className="wallpanel-screensaver-image-background",this.imageTwoBackground.id="wallpanel-screensaver-image-two-background",this.imageTwo=document.createElement("img"),this.imageTwo.id="wallpanel-screensaver-image-two",this.imageTwoInfoContainer=document.createElement("div"),this.imageTwoInfoContainer.className="wallpanel-screensaver-image-info-container",this.imageTwoInfoContainer.id="wallpanel-screensaver-image-two-info-container",this.imageTwoInfo=document.createElement("div"),this.imageTwoInfo.className="wallpanel-screensaver-image-info",this.imageTwoInfo.id="wallpanel-screensaver-image-two-info",this.imageTwoInfoContainer.appendChild(this.imageTwoInfo),this.imageTwoContainer.appendChild(this.imageTwoBackground),this.imageTwoContainer.appendChild(this.imageTwo),this.imageTwoContainer.appendChild(this.imageTwoInfoContainer),this.screensaverContainer.appendChild(this.imageTwoContainer),this.screensaverImageOverlay=document.createElement("div"),this.screensaverImageOverlay.id="wallpanel-screensaver-image-overlay",this.screensaverContainer.appendChild(this.screensaverImageOverlay),this.progressBarContainer=document.createElement("div"),this.progressBarContainer.className="wallpanel-progress",this.progressBar=document.createElement("div"),this.progressBar.className="wallpanel-progress-inner",this.progressBar.id="wallpanel-progress-inner",this.progressBarContainer.appendChild(this.progressBar),Xu.show_progress_bar&&this.screensaverContainer.appendChild(this.progressBarContainer),this.pauseIndicator=document.createElement("div"),this.pauseIndicator.id="wp-pause-indicator",this.pauseIndicator.innerHTML="⏸️",this.pauseIndicator.style.position="absolute",this.pauseIndicator.style.top="1rem",this.pauseIndicator.style.left="1rem",this.pauseIndicator.style.fontSize="4rem",this.pauseIndicator.style.lineHeight="1",this.pauseIndicator.style.color="white",this.pauseIndicator.style.filter="drop-shadow(0 0 8px rgba(0,0,0,0.8))",this.pauseIndicator.style.zIndex="9999",this.pauseIndicator.style.pointerEvents="none",this.pauseIndicator.style.display="none",this.screensaverContainer.appendChild(this.pauseIndicator),this.infoContainer=document.createElement("div"),this.infoContainer.id="wallpanel-screensaver-info-container",this.fixedInfoContainer=document.createElement("div"),this.fixedInfoContainer.id="wallpanel-screensaver-fixed-info-container",this.fixedInfoBox=document.createElement("div"),this.fixedInfoBox.id="wallpanel-screensaver-fixed-info-box",this.fixedInfoBoxContent=document.createElement("div"),this.fixedInfoBoxContent.id="wallpanel-screensaver-fixed-info-box-content",this.screensaverContainer.appendChild(this.infoContainer),this.infoBoxPosX=document.createElement("div"),this.infoBoxPosX.id="wallpanel-screensaver-info-box-pos-x",this.infoBoxPosX.x="0",this.infoBoxPosY=document.createElement("div"),this.infoBoxPosY.id="wallpanel-screensaver-info-box-pos-y",this.infoBoxPosY.y="0",this.infoBox=document.createElement("div"),this.infoBox.id="wallpanel-screensaver-info-box",this.infoBoxContent=document.createElement("div"),this.infoBoxContent.id="wallpanel-screensaver-info-box-content",this.infoBoxContent.style.display="grid",this.infoBox.appendChild(this.infoBoxContent),this.infoBoxPosX.appendChild(this.infoBox),this.infoBoxPosY.appendChild(this.infoBoxPosX),this.infoContainer.appendChild(this.infoBoxPosY),this.fixedInfoBox.appendChild(this.fixedInfoBoxContent),this.fixedInfoContainer.appendChild(this.fixedInfoBox),this.infoContainer.appendChild(this.fixedInfoContainer),this.screensaverOverlay=document.createElement("div"),this.screensaverOverlay.id="wallpanel-screensaver-overlay",this.screensaverContainer.appendChild(this.screensaverOverlay),this.shadowStyle=document.createElement("style");const e=this.attachShadow({mode:"open"});e.appendChild(this.shadowStyle),e.appendChild(this.screensaverContainer),e.appendChild(this.messageContainer),e.appendChild(this.debugBox);const t=this,n=["click","touchstart","touchend","wheel"];Xu.stop_screensaver_on_key_down&&n.push("keydown"),Xu.stop_screensaver_on_mouse_move&&n.push("mousemove");const r=e=>{try{t.handleInteractionEvent(e)}catch(e){mh.error(e.stack)}};n.forEach(function(e){window.addEventListener(e,r,!0),t.windowEventHandlers.push({eventName:e,handler:r,options:!0})});const i=e=>{Xu.disable_context_menu&&t.screensaverRunning()&&e.preventDefault()};window.addEventListener("contextmenu",i),this.windowEventHandlers.push({eventName:"contextmenu",handler:i});const o=()=>{try{const e=this.screensaverContainer.clientWidth,n=this.screensaverContainer.clientHeight;!t.screensaverRunning()||t.currentWidth==e&&t.currentHeight==n||(mh.debug("Size changed from ".concat(t.currentWidth,"x").concat(t.currentHeight," to ").concat(e,"x").concat(n)),t.currentWidth=e,t.currentHeight=n,t.updateShadowStyle(),t.setMediaDimensions())}catch(e){mh.error(e.stack)}};window.addEventListener("resize",o),this.windowEventHandlers.push({eventName:"resize",handler:o});const a=()=>{try{t.screensaverRunning()&&t.moreInfoDialogToForeground()}catch(e){mh.error(e.stack)}};window.addEventListener("hass-more-info",a),this.windowEventHandlers.push({eventName:"hass-more-info",handler:a}),this.infoBoxResizeObserver=new ResizeObserver(()=>{"corners"===Xu.info_move_pattern&&this.moveAroundCorners(!0)}),this.infoBoxResizeObserver.observe(this.infoBoxContent),this.setScreensaverEntityState()}disconnectedCallback(){this.timerInterval&&(clearInterval(this.timerInterval),this.timerInterval=null),this.translateTimeout&&(clearTimeout(this.translateTimeout),this.translateTimeout=null),this.windowEventHandlers.length&&(this.windowEventHandlers.forEach(e=>{let{eventName:t,handler:n,options:r}=e;window.removeEventListener(t,n,r)}),this.windowEventHandlers=[]),this.infoBoxResizeObserver&&(this.infoBoxResizeObserver.disconnect(),this.infoBoxResizeObserver=null)}reconfigure(e){const t=e&&Object.keys(e).length>0;!t||e.hide_toolbar==Xu.hide_toolbar&&e.hide_toolbar_action_icons==Xu.hide_toolbar_action_icons&&e.hide_toolbar_on_subviews==Xu.hide_toolbar_on_subviews&&e.hide_sidebar==Xu.hide_sidebar&&e.fullscreen==Xu.fullscreen||Lh(),Xu.theme&&(mh.info("Apply theme",Xu.theme),Zu.theme=Xu.theme,Zu._applyTheme()),this.updateStyle(),this.screensaverRunning()&&this.createInfoBoxContent(),!Xu.info_move_interval&&t&&e.info_move_interval&&Ku.moveInfoBox(0,0);const n=e.image_url!=Xu.image_url||"immich-api"==Ch()&&(Xu.immich_shared_albums!=e.immich_shared_albums||Xu.immich_memories!=e.immich_memories||Xu.immich_favorites!=e.immich_favorites||JSON.stringify(Xu.immich_album_names)!=JSON.stringify(e.immich_album_names)||JSON.stringify(Xu.immich_tag_names)!=JSON.stringify(e.immich_tag_names)||JSON.stringify(Xu.immich_persons)!=JSON.stringify(e.immich_persons));if(Xu.show_images&&(!this.mediaList||!this.mediaList.length||!t||!e.show_images||n)){const e=this,r=this.screensaverRunning()&&t;n&&(this.mediaList=[],this.mediaIndex=-1),this.updateMediaList(function(){r&&e.switchActiveMedia("reconfigure")},n)}if(Xu.disable_screensaver_on_browser_mod_popup_func)try{this.disable_screensaver_on_browser_mod_popup_function=new Function("bmp",Xu.disable_screensaver_on_browser_mod_popup_func)}catch(e){this.disable_screensaver_on_browser_mod_popup_function=null,mh.error("Invalid disable_screensaver_on_browser_mod_popup_func:",e)}Sh()&&Xu.camera_motion_detection_enabled?this.cameraMotionDetection.start():this.cameraMotionDetection.stop()}getMoreInfoDialog(){const e=ah.shadowRoot.querySelector("ha-more-info-dialog");if(!e)return;const t=e.shadowRoot.querySelector("ha-dialog");return t||void 0}moreInfoDialogToForeground(){const e=this;!function t(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;const r=e.getMoreInfoDialog();if(r)return r.style.position="absolute",void(r.style.zIndex=e.style.zIndex+1);n<10&&setTimeout(t,50,n+1)}()}fetchEXIFInfo(e){const t=this;if(nh.get(e.infoCacheUrl))return;const n=document.createElement("img");n.src=e.src,n.mediaUrl=e.mediaUrl,n.infoCacheUrl=e.infoCacheUrl,Vh(n,function(){mh.debug("EXIF data:",n.exifdata),rh(n.infoCacheUrl,n.exifdata),t.setMediaDataInfo(n);const e=n.exifdata.GPSLongitude,r=n.exifdata.GPSLatitude;if(Xu.fetch_address_data&&e&&!isNaN(e[0])&&r&&!isNaN(r[0])){let i="S"==n.exifdata.GPSLatitudeRef?-1:1;const o=r[0]*i+(r[1]*i*60+r[2]*i)/3600;i="W"==n.exifdata.GPSLongitudeRef?-1:1;const a=e[0]*i+(e[1]*i*60+e[2]*i)/3600;mh.debug("Fetching nominatim data for lat=".concat(o," lon=").concat(a));const s=new XMLHttpRequest;s.onload=function(){if(200==this.status||0===this.status){const e=JSON.parse(s.responseText);if(mh.debug("nominatim data:",e),e&&e.address){const r=nh.get(n.infoCacheUrl);r?(r.address=e.address,t.setMediaDataInfo(n)):mh.warn("URL not in cache:",n.infoCacheUrl)}}else mh.error("nominatim error:",this.status,s.status,s.responseText)},s.onerror=function(e){mh.error("nominatim error:",e)},s.ontimeout=function(e){mh.error("nominatim timeout:",e)},s.open("GET","https://nominatim.openstreetmap.org/reverse?lat=".concat(o,"&lon=").concat(a,"&format=json")),s.timeout=15e3,s.send()}})}setMediaDataInfo(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;const t=Xu.show_image_info&&Boolean(Xu.image_info_template);if(this.imageOneInfoContainer.style.display=t?"block":"none",this.imageTwoInfoContainer.style.display=t?"block":"none",!t)return this.imageOneInfo.innerHTML="",void(this.imageTwoInfo.innerHTML="");e||(e=this.getActiveMediaElement());const n=e.infoCacheUrl;let r=e.mediaUrl;if(!n)return void mh.debug("infoCacheUrl missing:",e);if(!r)return void mh.debug("mediaUrl missing:",e);r=decodeURI(r);const i=[];if(this.imageOne.infoCacheUrl==n&&i.push(this.imageOneInfo),this.imageTwo.infoCacheUrl==n&&i.push(this.imageTwoInfo),0==i.length)return;let o=nh.get(n);o||(o={}),o.image||(o.image={}),void 0===o.image.url&&(o.image.url=r);const a=r.replace(/\?[^?]*$/,"").replace(/\/+$/,"");if(void 0===o.image.path&&(o.image.path=a.replace(/^[^:]+:\/\/[^/]+/,"")),void 0===o.image.relativePath){const c="media-source"===Ch()?n.replace(/\?[^?]*$/,"").replace(/\/+$/,""):a;o.image.relativePath=c.replace(Xu.image_url,"").replace(/^\/+/,"")}if(void 0===o.image.filename&&(o.image.filename=a.replace(/^.*[\\/]/,"")),void 0===o.image.folderName){o.image.folderName="";const l=a.split("/");l.length>=2&&(o.image.folderName=l[l.length-2])}o.mediaPosition=this.mediaIndex+1,o.mediaCount=this.mediaList.length,mh.debug("Media info:",o);let s=Xu.image_info_template||"";if("analyze"==s){function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const n=Object.keys(e);n.sort(),n.forEach(n=>{const r=e[n];"object"==typeof r&&null!==r?u(r,n+"."):s+="".concat(t).concat(n,": ").concat(fh(r),"
")})}s="",u(o),this.imageOneInfo.style.pointerEvents="none",this.imageTwoInfo.style.pointerEvents="none",i.forEach(e=>{e.style.pointerEvents="auto"})}else s=s.replace(/\${([^}]+)}/g,(e,t)=>{const n=t.split("||");for(let e=0;e{const t=e.split(":",2);t[0]&&t[1]&&(a[t[0].replace(/\s/g,"")]=t[1].replace(/\s/g,""))}))}}let s="";const c=t.split("|");let l="";for(let e=0;e{s&&(s=s[e])}),s)break}if(s){if(/DateTime/i.test(l)){const e=new Date(s.replace(/(\d\d\d\d):(\d\d):(\d\d) (\d\d):(\d\d):(\d\d)/,"$1-$2-$3T$4:$5:$6"));if(isNaN(e))continue;a||(a={year:"numeric",month:"2-digit",day:"2-digit"}),s=e.toLocaleDateString((ah.hass||ah.__hass).locale.language,a)}return"object"==typeof s&&(s=JSON.stringify(s)),r+s+i}}return""});i.forEach(e=>{e.innerHTML=s,e.style.display="block"})}async updateMediaList(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!Xu.image_url)return;if(this.updatingMediaList)return;if(!t&&(new Date).getTime()-this.lastMediaListUpdate<1e3*Xu.media_list_update_interval)return;const r=this;let i=null;const o=Ch();if("unsplash-api"==o)i=r.updateMediaListFromUnsplashAPI;else if("immich-api"==o)i=r.updateMediaListFromImmichAPI;else{if("media-source"!=o){let t=Xu.image_url;return"iframe"==o?t=t.replace(/^iframe\+/,""):"embed"==o&&(t=t.replace(/^embed\+/,"")),this.mediaList=[t],void(e&&e())}i=r.updateMediaListFromMediaSource}this.updatingMediaList=!0,this.lastMediaListUpdate=Date.now();try{await i.bind(r)(),mh.debug("Media list from ".concat(o," is now:"),r.mediaList),e&&e()}catch(t){const i=3,a=3e3;if(mh.warn("Failed to update media list from ".concat(o,":"),t),nr.updateMediaList(e,!0,n+1),a);else{const e="Failed to update media list from ".concat(Xu.image_url," after ").concat(i," retries: ").concat(t.message||fh(t));mh.error(e)}}this.updatingMediaList=!1}async findMedias(e){const t=this;mh.debug("findMedias: ".concat(e));const n=[];if(Xu.exclude_filenames)for(const e of Xu.exclude_filenames)n.push(new RegExp(e));try{const r=await t.hass.callWS({type:"media_source/browse_media",media_content_id:e});mh.debug("Found media entry",r);const i=r.children.map(async e=>{const r=e.media_content_id.replace(/^media-source:\/\/[^/]+/,"");for(const e of n)if(e.test(r))return null;return["image","video"].includes(e.media_class)?Xu.exclude_media_types&&Xu.exclude_media_types.includes(e.media_class)?null:e.media_content_id:"directory"==e.media_class?await t.findMedias(e.media_content_id):null});return(await Promise.all(i)).flat().filter(e=>null!==e)}catch(t){throw mh.warn("Error browsing media ".concat(e,":"),t),t}}async updateMediaListFromMediaSource(){const e=Xu.image_url,t=this;try{let n=await t.findMedias(e);n="random"==Xu.media_order?Ah(n):"random_but_synced"==Xu.media_order?Ah(n.slice().sort(),yh(vh)):n.sort(),n.length>Xu.media_list_max_size&&(mh.info("Using only ".concat(Xu.media_list_max_size," of ").concat(n.length," media items")),n=n.slice(0,Xu.media_list_max_size)),t.mediaList=n}catch(e){throw new Error("Failed to update image list from ".concat(Xu.image_url,": ").concat(e.message||fh(e)))}}async updateMediaListFromUnsplashAPI(){const e=[],t="".concat(Xu.image_url,"&count=30");mh.debug("Unsplash API request: ".concat(t));try{const n={method:"GET",headers:{Accept:"application/json"}};"undefined"!=typeof AbortSignal&&void 0!==AbortSignal.timeout&&(mh.debug("Using AbortSignal"),n.signal=AbortSignal.timeout(1e3*Xu.immich_api_request_timeout));const r=await fetch(t,n);if(!r.ok){const e=await r.text();throw new Error("Unsplash API request failed: ".concat(r.status," ").concat(r.statusText," - ").concat(e))}const i=await r.json();mh.debug("Got Unsplash API response"),i.forEach(t=>{mh.debug(t);const n="".concat(t.urls.raw,"&w=${width}&h=${height}&auto=format");e.push(n),rh(n,t)}),this.mediaList=e}catch(e){if("AbortError"===e.name)throw new Error("Unsplash API request timed out: ".concat(t));throw e}}async _immichFetch(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i={headers:{"x-api-key":t,"Content-Type":"application/json",Accept:"application/json"}},o=n(n({},i),r);o.headers=n(n({},i.headers),r.headers),"undefined"!=typeof AbortSignal&&void 0!==AbortSignal.timeout&&(mh.debug("Using AbortSignal"),o.signal=AbortSignal.timeout(1e4)),mh.debug("Immich API request: ".concat(e));try{const t=await fetch(e,o);if(!t.ok){const e=await t.text();throw new Error("Immich API request failed: ".concat(t.status," ").concat(t.statusText," - ").concat(e))}return await t.json()}catch(t){if("AbortError"===t.name)throw new Error("Immich API request timed out: ".concat(e));throw t}}async updateMediaListFromImmichAPI(){if(!Xu.immich_api_keys||!Xu.immich_api_keys.length)throw new Error("No immich_api_key configured");const e=this,t=this.screensaverContainer.clientWidth>=this.screensaverContainer.clientHeight?"landscape":"portrait";let n=Xu.exclude_media_orientation;"auto"==n&&(n="landscape"==t?"portrait":"landscape"),mh.debug("config.exclude_media_orientation=".concat(Xu.exclude_media_orientation,", screenOrientation=").concat(t,", exclude_media_orientation=").concat(n));let r=[];const i={},o=Xu.image_url.replace(/^immich\+/,""),a=[];if(Xu.exclude_filenames)for(const e of Xu.exclude_filenames)a.push(new RegExp(e));function s(e){return null!=e.width&&null!=e.height?{width:e.width,height:e.height}:function(e){if(null==e||!e.exifImageWidth||null==e||!e.exifImageHeight)return null;let t=e.exifImageWidth,n=e.exifImageHeight;if(e.orientation){const r=Number(e.orientation);[5,6,7,8,90,-90].includes(r)&&([t,n]=[n,t])}return{width:t,height:n}}(e.exifInfo)}function c(e){const t=s(e);return t?t.width>=t.height?"landscape":"portrait":null}async function l(t,s){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;await async function(t,r){const i=Xu.immich_exclude_tag_names&&Xu.immich_exclude_tag_names.length,a=!!n;for(let n=0;n{var n;const s="image"===(null===(n=t.type)||void 0===n?void 0:n.toLowerCase()),c=s&&!0!==t.isEdited&&(null==t.width||null==t.height||void 0===t.isEdited),l=s&&a&&(null==t.width||null==t.height);if(!t.exifInfo||i&&!t.tags||l||c){mh.debug("Fetching asset info for ".concat(t.id));const n=await e._immichFetch("".concat(o,"/assets/").concat(t.id),r);t.exifInfo=n.exifInfo,t.tags=(n.tags||[]).map(e=>e.value),t.width=n.width,t.height=n.height,t.isEdited=n.isEdited}}))}}(t,s);for(const e of t){mh.debug("Processing immich asset",e);const t=e.type.toLowerCase();if(!["image","video"].includes(t)){mh.debug("Neither image nor video, skipping");continue}if(Xu.exclude_media_types&&Xu.exclude_media_types.includes(t)){mh.debug('Media type "'.concat(t,'" excluded'));continue}let u=!1;for(const t of a)t.test(e.originalFileName)&&(mh.debug('Media item excluded by regex "'.concat(t,'"')),u=!0);if(u)continue;if(Xu.immich_exclude_tag_names&&Xu.immich_exclude_tag_names.length){const t=e.tags.filter(e=>Xu.immich_exclude_tag_names.includes(e));if(t.length>0){mh.debug("Media item excluded due to tag(s): ".concat(t.join(", ")));continue}}if(n){const t=c(e);if(t===n){mh.debug('Media item with orientation "'.concat(t,'" excluded'));continue}}let h="original";"preview"==Xu.immich_resolution&&(h="video"==t?"video/playback":"thumbnail?size=preview");let d="".concat(o,"/assets/").concat(e.id,"/").concat(h);if("image"==t&&(d+=d.includes("?")?"&edited=true":"?edited=true"),r.indexOf(d)>=0)continue;r.push(d);const f=e.exifInfo||{};f.immichApiKey=s,f.mediaType=t,f.image={filename:e.originalFileName,folderName:l},i[d]=f}}try{for(const t of Xu.immich_api_keys)if(mh.debug("Using immich API key ".concat(t)),Xu.immich_persons&&Xu.immich_persons.length){mh.debug("Searching for assets based on persons");const n=Xu.immich_persons.map(e=>(Array.isArray(e)?e:[e]).map(e=>e.toLowerCase())),r={};let i=[],a=1,s=!0;for(;s;){const n=await e._immichFetch("".concat(o,"/people?size=1000&page=").concat(a),t);i=i.concat(n.people),s=n.hasNextPage,a++}i.forEach(e=>{e.name&&e.id&&(r[e.name.toLowerCase()]=e.id)});for(const i of n){const n=[];if(i.forEach(e=>{const t=r[e.toLowerCase()];t?n.push(t):mh.error("Person not found in immich: ".concat(e))}),n.length>0){mh.debug("Searching asset metadata for persons: ",n);let r=1;for(;;){mh.debug("Fetching asset metadata page ".concat(r));const a=await e._immichFetch("".concat(o,"/search/metadata"),t,{method:"POST",body:JSON.stringify({personIds:n,withExif:!0,page:r,size:1e3})});if(mh.debug("Got immich API response",a),!a.assets.count){if(1==r){const e="No media items found in immich that contain all these people: ".concat(i);mh.error(e)}break}if(await l(a.assets.items,t),!a.assets.nextPage)break;r=parseInt(a.assets.nextPage,10)}}}}else if(Xu.immich_memories){mh.debug("Fetching immich memories (on_this_day)");const n=await e._immichFetch("".concat(o,"/memories?type=on_this_day"),t);mh.debug("Got immich API response",n);const r=new Date,i=n.filter(e=>{const t=new Date(e.showAt),n=new Date(e.hideAt);return r>=t&&r<=n});mh.debug("Found ".concat(i.length," visible memories")),await Promise.all(i.map(async e=>{mh.debug("Processing memory:",e),await l(e.assets,t)}))}else if(Xu.immich_favorites){mh.debug("Search for favorites in asset metadata");let n=1;for(;;){mh.debug("Fetching asset metadata page ".concat(n));const r=await e._immichFetch("".concat(o,"/search/metadata"),t,{method:"POST",body:JSON.stringify({isFavorite:!0,withExif:!0,page:n,size:1e3})});if(mh.debug("Got immich API response",r),!r.assets.count){if(1==n){const e="No favorite media items found in immich";mh.error(e)}break}if(await l(r.assets.items,t),!r.assets.nextPage)break;n=parseInt(r.assets.nextPage,10)}}else if(Xu.immich_tag_names&&Xu.immich_tag_names.length){mh.debug("Searching for assets based on tag names");const n=Xu.immich_tag_names.map(e=>e.toLowerCase());mh.debug("Fetching immich tags");const r=await e._immichFetch("".concat(o,"/tags"),t);mh.debug("Got immich API response",r);const i=r.filter(e=>{const t=n.includes(e.name.toLowerCase());return mh.debug("".concat(t?"Adding":"Skipping"," tag: ").concat(e.name)),t}).map(e=>e.id);if(i.length>0){mh.debug("Searching asset metadata for tags: ",i);let r=1;for(;;){mh.debug("Fetching asset metadata page ".concat(r));const a=await e._immichFetch("".concat(o,"/search/metadata"),t,{method:"POST",body:JSON.stringify({tagIds:i,withExif:!0,page:r,size:1e3})});if(mh.debug("Got immich API response",a),!a.assets.count){if(1==r){const e="No media items found in immich that contain these tags: ".concat(n);mh.error(e)}break}if(await l(a.assets.items,t),!a.assets.nextPage)break;r=parseInt(a.assets.nextPage,10)}}else{const e="No matching immich tags found or selected.";mh.error(e)}}else{mh.debug("Searching for assets based on albums");const n=(Xu.immich_album_names||[]).map(e=>e.toLowerCase());mh.debug("Fetching immich albums (shared=".concat(Xu.immich_shared_albums,")"));const r=await e._immichFetch("".concat(o,"/server/version"),t);mh.debug("Immich server version:",r);const i=r.major<3?"shared":"isShared",a=await e._immichFetch("".concat(o,"/albums?").concat(i,"=").concat(Xu.immich_shared_albums),t);mh.debug("Got immich API response",a);const s=a.filter(e=>{const t=!n.length||n.includes(e.albumName.toLowerCase());return mh.debug("".concat(t?"Adding":"Skipping"," album: ").concat(e.albumName)),t});if(s.length>0)for(const n of s){mh.debug("Fetching assets for album: ",n.albumName);let r=1;for(;;){const i=await e._immichFetch("".concat(o,"/search/metadata"),t,{method:"POST",body:JSON.stringify({albumIds:[n.id],withExif:!0,page:r})});if(mh.debug("Got immich album assets (page ".concat(r,")"),i),await l(i.assets.items,t,n.albumName),!i.assets.nextPage)break;r=parseInt(i.assets.nextPage,10)}}else mh.debug("No matching immich albums found or selected.")}!function(){if(0==r.length){const e="No matching media assets found";mh.error(e)}r="random"==Xu.media_order?Ah(r):"random_but_synced"==Xu.media_order?Ah(r.slice().sort(),yh(vh)):r.sort(),r.length>Xu.media_list_max_size&&(mh.info("Using only ".concat(Xu.media_list_max_size," of ").concat(r.length," media items")),r=r.slice(0,Xu.media_list_max_size)),r.forEach(e=>{rh(e,i[e])}),e.mediaList=r}()}catch(e){throw mh.error("Immich API processing failed:",e),e}}fillPlaceholders(e){const t=this.screensaverContainer.clientWidth,n=this.screensaverContainer.clientHeight,r=Date.now(),i=Math.floor(r/1e3);return e=(e=(e=(e=e.replace(/\${width}/g,t)).replace(/\${height}/g,n)).replace(/\${timestamp_ms}/g,r)).replace(/\${timestamp}/g,i)}async updateMediaFromUrl(e,t){var n=this;let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];Xu.force_load_media_with_fetch&&(o=!0);const a=async e=>{const n=e.tagName.toLowerCase(),r={img:"load",video:"loadeddata",iframe:"load",embed:"load"}[n];if(!r)throw new Error('Unsupported element tag "'.concat(e.tagName,'"'));const a=new Promise((i,o)=>{const a=()=>{e.onerror=null,e.removeEventListener(r,s)},s=async()=>{a();try{"img"===n&&"function"==typeof e.decode&&await e.decode(),i()}catch(e){o(e)}};e.addEventListener(r,s),e.onerror=()=>{a(),o(new Error("Failed to load ".concat(e.tagName,' "').concat(t,'"')))}});if(o)if(Xu.stream_load_media)fetch(t,{headers:i}).then(n=>{if(!n.ok)throw new Error("Failed to load ".concat(e.tagName,' "').concat(t,'": ').concat(n));if(!n.body)throw new Error("Failed to load ".concat(e.tagName,' "').concat(t,'": empty body'));const r=n.body.getReader();return new ReadableStream({start:e=>function t(){return r.read().then(n=>{let{done:r,value:i}=n;if(!r)return e.enqueue(i),t();e.close()})}()})}).then(e=>new Response(e)).then(e=>e.blob()).then(t=>{"string"==typeof e.src&&e.src.startsWith("blob:")&&URL.revokeObjectURL(e.src),e.src=URL.createObjectURL(t)});else{i=i||{};const n=await fetch(t,{headers:i});if(mh.debug("Got respone",n),!n.ok)throw new Error("Failed to load ".concat(e.tagName,' "').concat(t,'": ').concat(n));"string"==typeof e.src&&e.src.startsWith("blob:")&&URL.revokeObjectURL(e.src);const r=await n.blob();e.src=URL.createObjectURL(r)}else e.src=t;return a},s=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;t||(t="img"===e.tagName.toLowerCase()?"video":"img");const i=n.replaceMediaElement(e,t);try{return await a(i),i}catch(e){throw r||e}},c=async(e,t)=>{try{return await a(e),e}catch(n){if(t)return await s(e,null,n);throw n}};return r?r===e.tagName.toLowerCase()?await c(e,!1):await s(e,r):await c(e,!0)}getNextMediaURL(){let e,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.mediaList.length?("random_but_synced"==Xu.media_order?e=Math.floor(Date.now()/(1e3*Xu.display_time))%this.mediaList.length:(e=this.mediaIndex,"forwards"==this.mediaListDirection?e++:e--,e>=this.mediaList.length?e=0:e<0&&(e=this.mediaList.length-1)),t&&(this.mediaIndex=e),this.mediaList[e]):null}async updateMediaFromMediaSource(e){var t;const n=await this.hass.callWS({type:"media_source/resolve_media",media_content_id:e.mediaUrl}),r=null===(t=n.mime_type)||void 0===t?void 0:t.match(/^(image|video)\//),i={image:"img",video:"video"}[null==r?void 0:r[1]]||null;let o=n.url;return o.startsWith("http://")||o.startsWith("https://")||(o="".concat(document.location.origin).concat(o)),mh.debug("Setting image src: ".concat(o)),e.mediaUrl=o,await this.updateMediaFromUrl(e,e.mediaUrl,i)}async updateMediaFromImmichAPI(e){const t=nh.get(e.mediaUrl)||{},n="video"==t.mediaType?"video":"img";return await this.updateMediaFromUrl(e,e.mediaUrl,n,{"x-api-key":t.immichApiKey},!0)}async updateMediaFromMediaEntity(e){const t=e.mediaUrl.match(/^media-entity-(image|video):\/\/(.*)/);if(!t)throw new Error('Invalid URL "'.concat(e.mediaUrl,'"'));const n=t[1],r=t[2],i=this.hass.states[r];if(!i)throw new Error('Entity "'.concat(r,'" not available'));function o(){"media_exif"in i.attributes?rh(e.infoCacheUrl,i.attributes.media_exif):rh(e.infoCacheUrl,i.attributes)}if(oh=i.state,"video"==n)return e.infoCacheUrl=e.mediaUrl,o(),(e=this.replaceMediaElement(e,"ha-camera-stream")).style.visibility="hidden",Object.assign(e,{hass:this.__hass,stateObj:this.__hass.states[r],"allow-exoplayer":!1,controls:!1}),new Promise((t,n)=>{let r=0;e.addEventListener("load",async function e(i){const o=i.currentTarget;o.removeEventListener("load",e),await o.updateComplete;const[a,s]=_h(o);if(!a||!s)return r++,r<=20?void setTimeout(()=>e(i),100):void n(new Error("Failed to initialize camera stream player"));if(a.style.height="100%",s.autoplay=!1,s.muted=!1,s.volume=Xu.video_volume,s.style.maxHeight="100%",s.style.height="100%",s.readyState>=s.HAVE_ENOUGH_DATA)t(o);else{const e=()=>{s.removeEventListener("canplay",e),t(o)};s.addEventListener("canplay",e)}})});{if(!i.attributes||!i.attributes.entity_picture)throw new Error('Entity "'.concat(r,'" has no entity_picture attribute'));const t=i.attributes.entity_picture;let n=t.indexOf("?")>0?"&":"?";return n+=this.fillPlaceholders("width=${width}&height=${height}&ts=${timestamp_ms}"),e.mediaUrl=t+n,e.infoCacheUrl=e.mediaUrl,o(),await this.updateMediaFromUrl(e,e.mediaUrl,"img",null,!0)}}async updateMediaFromUnsplashAPI(e){const t=nh.get(e.mediaUrl);return e.mediaUrl=this.fillPlaceholders(e.mediaUrl),t&&rh(e.mediaUrl,t),await this.updateMediaFromUrl(e,e.mediaUrl,"img")}async updateMediaFromMediaIframe(e){return await this.updateMediaFromUrl(e,e.mediaUrl,"iframe")}async updateMediaFromMediaEmbed(e){return await this.updateMediaFromUrl(e,e.mediaUrl,"embed")}async updateMediaFromOtherSrc(e){return e.mediaUrl=this.fillPlaceholders(e.mediaUrl),await this.updateMediaFromUrl(e,e.mediaUrl)}async updateMedia(e){if(Xu.show_images){this.updatingMedia=!0,e.updateMediaError=!1,e.style.visibility="hidden";try{if(e==this.getActiveMediaElement()){const e=this.getInactiveMediaElement();if("video"===e.tagName.toLowerCase())try{e.pause()}catch(e){mh.debug(e)}else if("ha-camera-stream"===e.tagName.toLowerCase())try{const[t,n]=_h(e);n&&n.pause(),t&&"function"==typeof t.stop&&t.stop()}catch(e){mh.debug(e)}}if(e.mediaUrl=this.getNextMediaURL(),!e.mediaUrl)return;if(e.infoCacheUrl=e.mediaUrl,e="media-source"==Ch()?await this.updateMediaFromMediaSource(e):"unsplash-api"==Ch()?await this.updateMediaFromUnsplashAPI(e):"immich-api"==Ch()?await this.updateMediaFromImmichAPI(e):Ch().startsWith("media-entity")?await this.updateMediaFromMediaEntity(e):"iframe"==Ch()?await this.updateMediaFromMediaIframe(e):"embed"==Ch()?await this.updateMediaFromMediaEmbed(e):await this.updateMediaFromOtherSrc(e)){e.style.visibility="visible";const t="video"===e.tagName.toLowerCase();t&&await new Promise((t,n)=>{if(e.readyState>=e.HAVE_ENOUGH_DATA)t();else{const r=()=>{e.removeEventListener("canplay",r),e.removeEventListener("error",i),t()},i=()=>{e.removeEventListener("canplay",r),e.removeEventListener("error",i),n(new Error("Video failed to load"))};e.addEventListener("canplay",r),e.addEventListener("error",i)}}),"image"===Xu.image_background&&this.loadBackgroundImage(e),!t&&Xu.show_image_info&&/.*\.jpe?g$/i.test(e.mediaUrl.split("?")[0].replace(/\/*$/,""))&&this.fetchEXIFInfo(e)}}catch(t){e.updateMediaError=!0,e.style.visibility="visible",mh.error("Failed to update media from ".concat(e.mediaUrl,":"),t)}finally{this.updatingMedia=!1}return e}}setMediaDimensions(){if(!Xu.calculate_media_size)return;const e=this.getActiveMediaElement(),t=this.getActiveMediaElement(!0);if(mh.debug("Setting dimensions for media element",e),!e.mediaUrl)return;const n=t.tagName.toLowerCase();let r=0,i=0;"video"===n?(r=t.videoWidth,i=t.videoHeight):"img"===n&&(r=t.naturalWidth,i=t.naturalHeight);const o=!r||!i||r>=i?Xu.image_fit_landscape:Xu.image_fit_portrait;e.style.position="absolute",e.style.left="0px",e.style.top="0px",e.style.objectFit=o;const a=this.screensaverContainer.clientWidth,s=this.screensaverContainer.clientHeight;let c=s,l=a,u=0,h=0,d=0,f=0;if(mh.debug("Available size is ".concat(a,"x").concat(s,", media size is ").concat(r,"x").concat(i)),r&&i){const e=a/r,t=s/i,n=a-r*t,m=s-i*e;mh.debug("Diff is ".concat(n,"x").concat(m)),"contain"==o&&n=m?(mh.debug("Using available width"),l=a,c=Math.floor(i*e),d="top"==Xu.media_vertical_align?0:"bottom"==Xu.media_vertical_align?s-c:Math.floor((c-s)/-2),u=Math.max(c-s,0)):(mh.debug("Using available height"),c=s,l=Math.floor(r*t),f="left"==Xu.media_horizontal_align?0:"right"==Xu.media_horizontal_align?a-l:Math.floor((l-a)/-2),h=Math.max(l-a,0))}else"iframe"!==n&&"embed"!==n&&mh.warn("Size not available for media element",t);mh.debug("Setting dimensions: size=".concat(l,"x").concat(c," - position=").concat(f,"x").concat(d," - hidden=").concat(h,"x").concat(u)),e.style.width="".concat(l,"px"),e.style.height="".concat(c,"px"),e.style.top="".concat(d,"px"),e.style.left="".concat(f,"px"),e.style.setProperty("--hidden-width",h),e.style.setProperty("--hidden-height",u)}startPlayingActiveMedia(){const e=this.getActiveMediaElement(),t=this.getActiveMediaElement(!0);if("function"!=typeof t.play)return void this.setDisplayTime();const n=()=>{t._wp_video_playback_listeners&&(Object.entries(t._wp_video_playback_listeners).forEach(e=>{let[n,r]=e;t.removeEventListener(n,r)}),t._wp_video_playback_listeners=null)};if(t.loop=Xu.video_loop&&t.duration{if(this.getActiveMediaElement()===t){if(t.currentTime>Xu.crossfade_time){t.duration-t.currentTime<=Xu.crossfade_time&&(this.switchActiveMedia("display_time_elapsed"),n())}}else n()},r=()=>{this.getActiveMediaElement()===t&&this.switchActiveMedia("media_end"),n()},i=()=>{n()};t._wp_video_playback_listeners={timeupdate:e,ended:r,pause:i},Object.entries(t._wp_video_playback_listeners).forEach(e=>{let[n,r]=e;t.addEventListener(n,r)})}t.play().catch(r=>{n(),e===this.getActiveMediaElement()&&mh.error('Failed to play media "'.concat(e.mediaUrl,'" (src=').concat(t.src,"):"),r)})}async switchActiveMedia(e){this.afterFadeoutTimer&&clearTimeout(this.afterFadeoutTimer);const t=Ch();if(t.startsWith("media-entity")){const t=Xu.image_url.replace(/^media-entity-(image|video):\/\//,""),n=this.hass.states[t];if(!n)return void mh.error('Media entity "'.concat(t,'" not available'));if(oh!=n.state)mh.debug("Media entity ".concat(t," state has changed"));else{if("entity_update"==e)return;if("start"==e||"user_action"==e)mh.debug("Media entity ".concat(t," state unchanged, but eventType = ").concat(e));else{if(!Xu.media_entity_load_unchanged)return this.lastMediaUpdate=Date.now(),this.isPaused&&(this.mediaTimeElapsedBeforePause=0),void this.restartProgressBarAnimation();mh.debug("Media entity ".concat(t," state unchanged, but media_entity_load_unchanged = true"))}}oh=n.state}this.lastMediaUpdate=Date.now(),this.isPaused&&(this.mediaTimeElapsedBeforePause=0);const n=this.getActiveMediaElement();if(("iframe"===t||"embed"===t)&&!Xu.iframe_load_unchanged&&this.getNextMediaURL(!1)==n.mediaUrl)return;let r=0;"start"!=e&&(Xu.crossfade_time>0&&(r=Math.round(1e3*Xu.crossfade_time)),"user_action"==e&&r>250&&(r=250));const i=this.getInactiveMediaElement(),o=await this.updateMedia(i);o&&this._switchActiveMedia(o,r)}_switchActiveMedia(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.lastMediaUpdate=Date.now(),this.isPaused&&(this.mediaTimeElapsedBeforePause=0),this.imageOneContainer.style.transition="opacity ".concat(t,"ms ease-in-out"),this.imageTwoContainer.style.transition="opacity ".concat(t,"ms ease-in-out");let n=this.imageOneContainer,r=this.imageTwoContainer,i=this.imageOne,o=this.imageTwo;e==this.imageOne&&(n=this.imageTwoContainer,r=this.imageOneContainer,i=this.imageTwo,o=this.imageOne),mh.debug("Switching active media to '".concat(r.id,"'")),1!=r.style.opacity&&(r.style.opacity=1),0!=n.style.opacity&&(n.style.opacity=0),"iframe"==o.tagName.toLowerCase()&&Xu.iframe_interaction?o.style.pointerEvents="auto":o.style.pointerEvents="none",this.setMediaDataInfo(),this.setMediaDimensions(),this.setImageURLEntityState(),this.startPlayingActiveMedia(),this.restartProgressBarAnimation(),this.restartKenBurnsEffect(),"video"===i.tagName.toLowerCase()&&(this.afterFadeoutTimer=setTimeout(function(){if("video"===i.tagName.toLowerCase())try{i.pause()}catch(e){mh.debug(e)}},t))}showMessage(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5e3;if(!this.messageContainer)return;const i=document.createElement("div");i.className="wallpanel-message ".concat(e);const o=document.createElement("div");o.className="wallpanel-message-title",o.textContent=t,i.appendChild(o);const a=document.createElement("div");a.className="wallpanel-message-text",a.textContent=n,i.appendChild(a),this.messageContainer.appendChild(i),requestAnimationFrame(()=>i.classList.add("show"));const s=this;setTimeout(()=>s.hideMessage(i),r)}hideMessage(e){e.classList.remove("show"),e.addEventListener("transitionend",()=>e.remove())}hideAllMessages(){const e=this.messageContainer.querySelectorAll(".wallpanel-message");if(!e.length)return!1;const t=this;return e.forEach(e=>t.hideMessage(e)),!0}setupScreensaver(){mh.debug("Setup screensaver"),Xu.keep_screen_on_time>0&&!this.screenWakeLock.enabled&&this.screenWakeLock.enable(),Xu.fullscreen&&!Oh()&&Ph()}async startScreensaver(){if(mh.debug("Start screensaver"),this.screensaverStartedAt=Date.now(),this.screensaverStoppedAt=null,this.currentWidth=this.screensaverContainer.clientWidth,this.currentHeight=this.screensaverContainer.clientHeight,this.setDefaultStyle(),wh(),!Sh())return mh.debug("Wallpanel not active, not starting screensaver"),this.screensaverStartedAt=null,void(this.screensaverStoppedAt=Date.now());if(this.getActiveMediaElement()==this.imageOne?(this.imageOneContainer.style.opacity=1,this.imageTwoContainer.style.opacity=0):(this.imageOneContainer.style.opacity=0,this.imageTwoContainer.style.opacity=1),this.setDisplayTime(),await this.switchActiveMedia("start"),this.setupScreensaver(),Xu.keep_screen_on_time>0){const e=this;setTimeout(function(){e.screensaverRunning()&&!e.screenWakeLock.enabled&&(mh.warning("Keep screen on will not work because the user didn't interact with the document first. https://goo.gl/xX8pDD"),e.showMessage("info","Keep screen on","Please tap the screen for a moment to keep it awake and prevent it from turning off.",15e3))},2e3)}this.lastMove=Date.now(),this.lastMediaUpdate=Date.now(),document.documentElement.style.overflow="hidden",this.isPaused=!1,this.mediaTimeElapsedBeforePause=0,this.pauseIndicator.style.display="none",this.createInfoBoxContent(),this.style.visibility="visible",this.style.opacity=1,this.style.pointerEvents="auto",this.setScreensaverEntityState(),(Xu.screensaver_start_navigation_path||Xu.screensaver_stop_close_browser_mod_popup)&&(this.screensaverStopNavigationPathTimeout=setTimeout(()=>{Xu.screensaver_start_navigation_path&&(eh=!0,function(e){(!(arguments.length>1&&void 0!==arguments[1])||arguments[1])&&!e.includes("?")&&(e+=window.location.search),history.pushState(null,"",e),ah.dispatchEvent(new Event("location-changed",{bubbles:!0,cancelable:!1,composed:!0}))}(Xu.screensaver_start_navigation_path),setTimeout(()=>{eh=!1},5e3)),Xu.screensaver_stop_close_browser_mod_popup&&Eh().forEach(e=>{e.closeDialog()})},1e3*(Xu.fade_in_time+1)))}screensaverRunning(){return Boolean(this.screensaverStartedAt)&&this.screensaverStartedAt>0}stopScreensaver(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;mh.debug("Stop screensaver"),this.screensaverStartedAt=null,this.screensaverStoppedAt=Date.now(),document.documentElement.style.removeProperty("overflow"),this.screensaverStopNavigationPathTimeout&&clearTimeout(this.screensaverStopNavigationPathTimeout),this.hideAllMessages(),this.debugBox.style.pointerEvents="none",this.style.transition=e>0?"opacity ".concat(Math.round(1e3*e),"ms ease-in-out"):"",this.style.opacity=0,this.style.visibility="hidden",this.style.pointerEvents="none",this.imageOneInfo.style.pointerEvents="none",this.imageTwoInfo.style.pointerEvents="none",this.infoBoxPosX.style.animation="",this.infoBoxPosY.style.animation="",this.idleSince=Date.now(),this.screenWakeLock.enabled&&this.screenWakeLock.disable(),setTimeout(this.setScreensaverEntityState.bind(this),25)}updateScreensaver(){const e=new Date,t=e.getTime();if(this.energyCollectionUpdateEnabled&&t-this.lastEnergyCollectionUpdate>=1e3*this.energyCollectionUpdateInterval&&(this.hass.connection._energy_wallpanel&&this.hass.connection._energy_wallpanel.refresh(),this.lastEnergyCollectionUpdate=t),this.infoBoxContentCreatedDate&&this.infoBoxContentCreatedDate.getDate()!=e.getDate()&&this.createInfoBoxContent(),Xu.info_move_interval>0&&t-this.lastMove>=1e3*Xu.info_move_interval&&("random"===Xu.info_move_pattern?this.randomMove():"corners"===Xu.info_move_pattern?this.moveAroundCorners():mh.error("Unknown info move type ".concat(Xu.info_move_pattern))),Xu.black_screen_after_time>0&&t-this.screensaverStartedAt>=1e3*Xu.black_screen_after_time)mh.debug("Setting screen to black"),this.screensaverOverlay.style.background="#000000";else if(Xu.show_images){let e;e="random_but_synced"==Xu.media_order?Math.floor(t/(1e3*Xu.display_time))!=Math.floor(this.lastMediaUpdate/(1e3*Xu.display_time)):t-this.lastMediaUpdate>=1e3*this.getDisplayTime(),!this.isPaused&&e&&this.switchActiveMedia("display_time_elapsed"),t-this.lastMediaListUpdate>=1e3*Xu.media_list_update_interval&&this.updateMediaList(null,!0),"visible"!=this.imageOneContainer.style.visibility&&(this.imageOneContainer.style.visibility="visible"),"visible"!=this.imageOne.style.visibility&&(this.imageOne.style.visibility="visible"),"visible"!=this.imageTwoContainer.style.visibility&&(this.imageTwoContainer.style.visibility="visible"),"visible"!=this.imageTwo.style.visibility&&(this.imageTwo.style.visibility="visible")}else"hidden"!=this.imageOneContainer.style.visibility&&(this.imageOneContainer.style.visibility="hidden"),"hidden"!=this.imageOne.style.visibility&&(this.imageOne.style.visibility="hidden"),"hidden"!=this.imageTwoContainer.style.visibility&&(this.imageTwoContainer.style.visibility="hidden"),"hidden"!=this.imageTwo.style.visibility&&(this.imageTwo.style.visibility="hidden");if(Xu.close_more_info_dialog_time>0){const e=this.getMoreInfoDialog();if(e){const t=new Date;this.moreInfoDialogOpenedAt?t-this.moreInfoDialogOpenedAt>=1e3*Xu.close_more_info_dialog_time&&e.close():this.moreInfoDialogOpenedAt=t}else this.moreInfoDialogOpenedAt=0}if(Xu.debug){let e="";const t={};for(const e in Xu)["profiles"].includes(e)?t[e]="...":t[e]=Xu[e];if(e+='
Download log
',e+="Version: ".concat(Gu,"
"),e+="User-Agent: ".concat(navigator.userAgent,"
"),e+="Config: ".concat(JSON.stringify(t),"
"),e+="Fullscreen: ".concat(Oh(),"
"),e+="Screensaver started at: ".concat(Ku.screensaverStartedAt,"
"),e+="Screen wake lock: enabled=".concat(this.screenWakeLock.enabled," native=").concat(this.screenWakeLock.nativeWakeLockSupported," lock=").concat(this.screenWakeLock._lock," player=").concat(this.screenWakeLock._player," error=").concat(this.screenWakeLock.error,"
"),this.screenWakeLock._player){const t=this.screenWakeLock._player;e+="Screen wake lock video: readyState=".concat(t.readyState," currentTime=").concat(t.currentTime," paused=").concat(t.paused," ended=").concat(t.ended,"
")}e+="Media list size: ".concat(this.mediaList.length,"
");const n=this.getActiveMediaElement();if(n){e+="Current media: ".concat(n.mediaUrl,"
");const t=nh.get(n.infoCacheUrl);t&&(e+="Media info: ".concat(JSON.stringify(t),"
"))}this.debugBox.innerHTML!==e&&(this.debugBox.innerHTML=e,this.debugBox.querySelector("#download_log").addEventListener("click",function(e){mh.downloadMessages(),e.preventDefault()})),this.debugBox.scrollTop=this.debugBox.scrollHeight}this.screenWakeLock.enabled&&Xu.keep_screen_on_time>0&&t-this.screensaverStartedAt>=1e3*Xu.keep_screen_on_time&&(mh.info("Disable wake lock after ".concat(Xu.keep_screen_on_time," seconds")),this.screenWakeLock.disable())}switchMediaDirection(e){this.mediaListDirection=e,this.switchActiveMedia("user_action")}async nextImage(){if(this.updatingMedia)return void mh.debug("Already switching media");mh.debug("Next image");const e=this.mediaListDirection;this.mediaListDirection="forwards";try{await this.switchActiveMedia("user_action")}finally{this.mediaListDirection=e}}async previousImage(){if(this.updatingMedia)return void mh.debug("Already switching media");mh.debug("Previous image");const e=this.mediaListDirection;this.mediaListDirection="backwards";try{await this.switchActiveMedia("user_action")}finally{this.mediaListDirection=e}}togglePlayPause(){if(mh.debug("Toggle play/pause"),this.screensaverRunning())if(this.isPaused)this.isPaused=!1,this.lastMediaUpdate=Date.now()-(this.mediaTimeElapsedBeforePause||0),this.pauseIndicator.style.display="none",this.progressBar.style.animationPlayState="running",this.startPlayingActiveMedia();else{this.isPaused=!0,this.mediaTimeElapsedBeforePause=Date.now()-this.lastMediaUpdate,this.lastMediaUpdate=Date.now(),this.pauseIndicator.style.display="block",this.progressBar.style.animationPlayState="paused";const e=this.getActiveMediaElement(!0);e&&"function"==typeof e.pause&&e.pause()}}setCameraMotionDetectionEntityState(e){const t=Xu.camera_motion_detection_set_entity;t&&this.__hass.states[t]&&(mh.debug("Updating camera motion detection entity",t,e),this.__hass.callService("input_boolean",e?"turn_on":"turn_off",{entity_id:t}).then(e=>{mh.debug(e)},e=>{mh.error("Failed to set camera motion detection entity state:",e)}))}motionDetected(){Xu.camera_motion_detection_stop_screensaver&&this.screensaverRunning()&&this.stopScreensaver(Xu.fade_out_time_motion_detected),this.setCameraMotionDetectionEntityState(!0)}motionStopped(){this.setCameraMotionDetectionEntityState(!1)}handleInteractionEvent(e){const t=["click","touchend"].includes(e.type),n=Date.now();this.idleSince=n;let r="";if("touchstart"==e.type)return void(e.touches&&e.touches[0]&&(this.touchStartX=e.touches[0].clientX,this.touchStartY=e.touches[0].clientY));if("touchend"==e.type&&this.touchStartX>=0&&e.changedTouches&&e.changedTouches[0]){const t=e.changedTouches[0].clientX-this.touchStartX,n=e.changedTouches[0].clientY-this.touchStartY,i=Math.max(20,.03*window.innerWidth);t>=i&&Math.abs(t)>Math.abs(n)?r="right":t<=-i&&Math.abs(t)>Math.abs(n)&&(r="left"),this.touchStartX=-1,this.touchStartY=-1}if(!this.screensaverRunning())return this.blockEventsUntil>n&&(t&&e.preventDefault(),e.stopImmediatePropagation()),void(t&&this.setupScreensaver());if(t&&this.hideAllMessages())return void(this.blockEventsUntil=n+1e3);let i=e.clientX,o=e.clientY;if(!i&&e.changedTouches&&e.changedTouches[0]&&(i=e.changedTouches[0].clientX),!o&&e.changedTouches&&e.changedTouches[0]&&(o=e.changedTouches[0].clientY),Xu.debug&&i&&i<100&&o&&o<100)return;const a=xh();if(a){const e=[a.shadowRoot.querySelector(".content"),a.shadowRoot.querySelector("ha-dialog-header")];for(let t=0;t=n.left&&i<=n.right&&o>=n.top&&o<=n.bottom)return void mh.debug("Event on browser mod popup:",e[t])}}if(Xu.iframe_interaction&&"iframe"==Ch())return;if(Xu.content_interaction){if(this.getMoreInfoDialog())return;let e=[];e=e.concat(this.__cards||[]),e=e.concat(this.__badges||[]),e=e.concat(this.__views||[]),e.push(this.shadowRoot.getElementById("wallpanel-screensaver-info-box-content")),e.push(this.shadowRoot.getElementById("wallpanel-screensaver-fixed-info-box-content")),"analyze"==Xu.image_info_template&&(e.push(this.imageOneInfo),e.push(this.imageTwoInfo));for(let t=0;t=n.left&&i<=n.right&&o>=n.top&&o<=n.bottom)return void mh.debug("Event on:",e[t])}}let s="";if(r)s="left"==r?"forwards":"backwards",e.stopImmediatePropagation();else if(e instanceof MouseEvent||"TouchEvent"in window&&e instanceof TouchEvent){let n=0,r=0;const a=this.screensaverContainer.getBoundingClientRect();if(i&&(n=(a.right-i)/this.screensaverContainer.clientWidth),o&&(r=(a.bottom-o)/this.screensaverContainer.clientHeight),mh.debug("Event position screensaver:",i,o,a.left,a.right,a.top,a.bottom),r>1||r<0||n>1||n<0)return;if(t&&e.preventDefault(),e.stopImmediatePropagation(),Xu.touch_zone_size_next_image>0&&n<=Xu.touch_zone_size_next_image/100){if(!t)return;s="forwards"}else if(Xu.touch_zone_size_previous_image>0&&n>=(100-Xu.touch_zone_size_previous_image)/100){if(!t)return;s="backwards"}else if(n>=.4&&n<=.6&&r<=.1){const e=new Date;return t&&e-this.lastClickTime<500?(this.clickCount+=1,3==this.clickCount&&(mh.purgeMessages(),Xu.debug=!Xu.debug,this.debugBox.style.visibility=Xu.debug?"visible":"hidden",this.debugBox.style.pointerEvents=Xu.debug?"auto":"none")):this.clickCount=1,void(this.lastClickTime=e)}}s?this.updatingMedia?mh.debug("Already switching media"):(mh.debug("Switching media, direction ".concat(s)),this.mediaListDirection!=s?this.switchMediaDirection(s):this.switchActiveMedia("user_action")):t&&!Xu.stop_screensaver_on_mouse_click||(this.blockEventsUntil=n+1e3*Xu.control_reactivation_time,this.stopScreensaver(Xu.fade_out_time_interaction))}}customElements.get("wallpanel-view-container")||customElements.define("wallpanel-view-container",r),customElements.get("wallpanel-view")||customElements.define("wallpanel-view",i),Zu=document.createElement("wallpanel-view-container"),Ku=document.createElement("wallpanel-view"),Zu.appendChild(Ku),sh.shadowRoot.appendChild(Zu)}function Lh(){mh.debug("activateWallpanel");let e=Xu.hide_toolbar,t=Xu.hide_toolbar_action_icons;if(e&&!Xu.hide_toolbar_on_subviews&&Qu){const n=Ih();if(n&&n.lovelace&&n.lovelace.rawConfig&&n.lovelace.rawConfig.views)for(let r=0;r{mh.debug("Successfully exited fullscreen")},e=>{mh.debug("Failed to exit fullscreen:",e)}):document.mozCancelFullScreen?document.mozCancelFullScreen():document.msRequestFullscreen?document.msRequestFullscreen():document.webkitExitFullscreen&&document.webkitExitFullscreen())}function Dh(){Ju&&Qu?(wh(),Sh()?Lh():Bh()):Bh()}function Uh(){if(mh.debug("Location changed from '".concat($u,"' to '").concat(window.location.href,"'")),window.location.href==$u)return;$u=window.location.href,Ku&&Ku.screensaverRunning&&Ku.screensaverRunning()&&Xu.stop_screensaver_on_location_change&&(eh?(eh=!1,Ku.screensaverStopNavigationPathTimeout&&clearTimeout(Ku.screensaverStopNavigationPathTimeout)):Ku.stopScreensaver());let e=null,t=null;const n=window.location.pathname.split("/");n.length>1&&(e=n[1],n.length>2&&(t=n[2]));const r=Ju&&e!=Ju;Ju=e,Qu=t,r?(mh.debug("Reset dashboard config"),Vu={},Fh(Dh)):Dh()}function Fh(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const n=Date.now();null===t&&(t=n);const r=(n-t)/1e3;if(ah=document.querySelector("body > home-assistant"),ah&&ah.shadowRoot&&(sh=ah.shadowRoot.querySelector("home-assistant-main")),!ah||!ah.shadowRoot||!sh)return r>=5?void mh.error("Wallpanel startup failed after ".concat(r," seconds, element home-assistant / home-assistant-main not found.")):void setTimeout(Fh,100,e,t);const i=Ih();if(!(i&&i.lovelace&&i.lovelace.config&&i.lovelace.config))return r>=5?void mh.info("No lovelace config found after ".concat(r," seconds")):void setTimeout(Fh,100,e,t);if(!customElements.get("hui-view"))return r>=5?void mh.error("Wallpanel startup failed after ".concat(r," seconds, hui-view not found.")):void setTimeout(Fh,100,e,t);if(!window.browser_mod){let n=Th(["wait_for_browser_mod_time"]).wait_for_browser_mod_time;if(void 0===n&&(n=qu.wait_for_browser_mod_time),r{let t=null;try{t=e.target.location.href}catch(e){mh.debug(e)}mh.debug("location-changed",t,e),setTimeout(Uh,20)}),window.navigation&&window.navigation.addEventListener("navigate",e=>{let t=null;try{t=e.destination.url}catch(e){mh.debug(e)}mh.debug("navigate",t,e),setTimeout(Uh,30)}),(ah.hass||ah.__hass).connection.subscribeEvents(function(e){mh.debug("lovelace_updated",e),(e.data.url_path?e.data.url_path:"lovelace")==Ju&&(ah.hass||ah.__hass).connection.sendMessagePromise({type:"lovelace/config",url_path:e.data.url_path}).then(e=>{if(Vu={},e.wallpanel)for(const t in e.wallpanel)(t in qu||t in Yu)&&(Vu[t]=e.wallpanel[t]);Dh()})},"lovelace_updated"),setTimeout(Uh,0)})}catch(e){mh.error(e.stack)}var Nh=!1,jh=function(e){return e instanceof jh?e:this instanceof jh?void(this.EXIFwrapped=e):new jh(e)},Wh=jh.Tags={36864:"ExifVersion",40960:"FlashpixVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",37121:"ComponentsConfiguration",37122:"CompressedBitsPerPixel",37500:"MakerNote",37510:"UserComment",40964:"RelatedSoundFile",36867:"DateTimeOriginal",36868:"DateTimeDigitized",37520:"SubsecTime",37521:"SubsecTimeOriginal",37522:"SubsecTimeDigitized",33434:"ExposureTime",33437:"FNumber",34850:"ExposureProgram",34852:"SpectralSensitivity",34855:"ISOSpeedRatings",34856:"OECF",37377:"ShutterSpeedValue",37378:"ApertureValue",37379:"BrightnessValue",37380:"ExposureBias",37381:"MaxApertureValue",37382:"SubjectDistance",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37396:"SubjectArea",37386:"FocalLength",41483:"FlashEnergy",41484:"SpatialFrequencyResponse",41486:"FocalPlaneXResolution",41487:"FocalPlaneYResolution",41488:"FocalPlaneResolutionUnit",41492:"SubjectLocation",41493:"ExposureIndex",41495:"SensingMethod",41728:"FileSource",41729:"SceneType",41730:"CFAPattern",41985:"CustomRendered",41986:"ExposureMode",41987:"WhiteBalance",41988:"DigitalZoomRation",41989:"FocalLengthIn35mmFilm",41990:"SceneCaptureType",41991:"GainControl",41992:"Contrast",41993:"Saturation",41994:"Sharpness",41995:"DeviceSettingDescription",41996:"SubjectDistanceRange",40965:"InteroperabilityIFDPointer",42016:"ImageUniqueID"},zh=jh.TiffTags={256:"ImageWidth",257:"ImageHeight",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer",40965:"InteroperabilityIFDPointer",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",274:"Orientation",277:"SamplesPerPixel",284:"PlanarConfiguration",530:"YCbCrSubSampling",531:"YCbCrPositioning",282:"XResolution",283:"YResolution",296:"ResolutionUnit",273:"StripOffsets",278:"RowsPerStrip",279:"StripByteCounts",513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength",301:"TransferFunction",318:"WhitePoint",319:"PrimaryChromaticities",529:"YCbCrCoefficients",532:"ReferenceBlackWhite",306:"DateTime",270:"ImageDescription",271:"Make",272:"Model",305:"Software",315:"Artist",33432:"Copyright"},Hh=jh.GPSTags={0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude",5:"GPSAltitudeRef",6:"GPSAltitude",7:"GPSTimeStamp",8:"GPSSatellites",9:"GPSStatus",10:"GPSMeasureMode",11:"GPSDOP",12:"GPSSpeedRef",13:"GPSSpeed",14:"GPSTrackRef",15:"GPSTrack",16:"GPSImgDirectionRef",17:"GPSImgDirection",18:"GPSMapDatum",19:"GPSDestLatitudeRef",20:"GPSDestLatitude",21:"GPSDestLongitudeRef",22:"GPSDestLongitude",23:"GPSDestBearingRef",24:"GPSDestBearing",25:"GPSDestDistanceRef",26:"GPSDestDistance",27:"GPSProcessingMethod",28:"GPSAreaInformation",29:"GPSDateStamp",30:"GPSDifferential"},Gh=jh.IFD1Tags={256:"ImageWidth",257:"ImageHeight",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",273:"StripOffsets",274:"Orientation",277:"SamplesPerPixel",278:"RowsPerStrip",279:"StripByteCounts",282:"XResolution",283:"YResolution",284:"PlanarConfiguration",296:"ResolutionUnit",513:"JpegIFOffset",514:"JpegIFByteCount",529:"YCbCrCoefficients",530:"YCbCrSubSampling",531:"YCbCrPositioning",532:"ReferenceBlackWhite"},qh=jh.StringValues={ExposureProgram:{0:"Not defined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},SensingMethod:{1:"Not defined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},SceneType:{1:"Directly photographed"},CustomRendered:{0:"Normal process",1:"Custom process"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},GainControl:{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},SubjectDistanceRange:{0:"Unknown",1:"Macro",2:"Close view",3:"Distant view"},FileSource:{3:"DSC"},Components:{0:"",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"}};function Yh(e){return!!e.exifdata}function Vh(e,t){function n(n){var r=Xh(n);e.exifdata=r||{};var i=function(e){var t=new DataView(e);if(255!=t.getUint8(0)||216!=t.getUint8(1))return!1;var n=2,r=e.byteLength,i=function(e,t){return 56===e.getUint8(t)&&66===e.getUint8(t+1)&&73===e.getUint8(t+2)&&77===e.getUint8(t+3)&&4===e.getUint8(t+4)&&4===e.getUint8(t+5)};for(;n")+8,l=(s=s.substring(s.indexOf("4?f:t+8,a=[],c=0;c4?f:t+8,d-1);case 3:if(1==d)return e.getUint16(t+8,!i);for(o=d>2?f:t+8,a=[],c=0;c>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:t+=String.fromCharCode(i);break;case 12:case 13:o=e[n++],t+=String.fromCharCode((31&i)<<6|63&o);break;case 14:o=e[n++],a=e[n++],t+=String.fromCharCode((15&i)<<12|(63&o)<<6|63&a)}return t}(r)}function ed(e,t){if("Exif"!=Kh(e,t,4))return!1;var n,r,i,o,a,s=t+6;if(18761==e.getUint16(s))n=!1;else{if(19789!=e.getUint16(s))return!1;n=!0}if(42!=e.getUint16(s+2,!n))return!1;var c=e.getUint32(s+4,!n);if(c<8)return!1;if((r=Qh(e,s,s+c,zh,n)).ExifIFDPointer)for(i in o=Qh(e,s,s+r.ExifIFDPointer,Wh,n)){switch(i){case"LightSource":case"Flash":case"MeteringMode":case"ExposureProgram":case"SensingMethod":case"SceneCaptureType":case"SceneType":case"CustomRendered":case"WhiteBalance":case"GainControl":case"Contrast":case"Saturation":case"Sharpness":case"SubjectDistanceRange":case"FileSource":o[i]=qh[i][o[i]];break;case"ExifVersion":case"FlashpixVersion":o[i]=String.fromCharCode(o[i][0],o[i][1],o[i][2],o[i][3]);break;case"ComponentsConfiguration":o[i]=qh.Components[o[i][0]]+qh.Components[o[i][1]]+qh.Components[o[i][2]]+qh.Components[o[i][3]]}r[i]=o[i]}if(r.GPSInfoIFDPointer)for(i in a=Qh(e,s,s+r.GPSInfoIFDPointer,Hh,n)){if("GPSVersionID"==i)try{a[i]=a[i][0]+"."+a[i][1]+"."+a[i][2]+"."+a[i][3]}catch(e){}r[i]=a[i]}return r.thumbnail=function(e,t,n,r){var i=function(e,t,n){var r=e.getUint16(t,!n);return e.getUint32(t+2+12*r,!n)}(e,t+n,r);if(!i)return{};if(i>e.byteLength)return{};var o=Qh(e,t,t+i,Gh,r);if(o.Compression)switch(o.Compression){case 6:if(o.JpegIFOffset&&o.JpegIFByteCount){var a=t+o.JpegIFOffset,s=o.JpegIFByteCount;o.blob=new Blob([new Uint8Array(e.buffer,a,s)],{type:"image/jpeg"})}break;case 1:mh.log("Thumbnail image format is TIFF, which is not implemented.");break;default:mh.log("Unknown thumbnail image format '%s'",o.Compression)}else 2==o.PhotometricInterpretation&&mh.log("Thumbnail image format is RGB, which is not implemented.");return o}(e,s,c,n),r}function td(e){var t={};if(1==e.nodeType){if(e.attributes.length>0){t["@attributes"]={};for(var n=0;n0)for(var n=0;n0&&e[0]<4?1:+(e[0]+e[1])),!t&&r&&(!(e=r.match(/Edge\/(\d+)/))||e[1]>=74)&&(e=r.match(/Chrome\/(\d+)/))&&(t=+e[1]),Y=t}function Ee(){if($)return X;$=1;var e=we(),t=v(),n=s().String;return X=!!Object.getOwnPropertySymbols&&!t(function(){var t=Symbol("symbol detection");return!n(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&e&&e<41})}function xe(){if(Q)return J;Q=1;var e=Ee();return J=e&&!Symbol.sham&&"symbol"==typeof Symbol.iterator}function Se(){if(K)return Z;K=1;var e=Ae(),t=ve(),n=_e(),r=xe(),i=Object;return Z=r?function(e){return"symbol"==typeof e}:function(r){var o=e("Symbol");return t(o)&&n(o.prototype,i(r))}}function Ce(){if(te)return ee;te=1;var e=String;return ee=function(t){try{return e(t)}catch(e){return"Object"}}}function Ie(){if(re)return ne;re=1;var e=ve(),t=Ce(),n=TypeError;return ne=function(r){if(e(r))return r;throw new n(t(r)+" is not a function")}}function Te(){if(oe)return ie;oe=1;var e=Ie(),t=me();return ie=function(n,r){var i=n[r];return t(i)?void 0:e(i)}}function Re(){if(se)return ae;se=1;var e=_(),t=ve(),n=ye(),r=TypeError;return ae=function(i,o){var a,s;if("string"===o&&t(a=i.toString)&&!n(s=e(a,i)))return s;if(t(a=i.valueOf)&&!n(s=e(a,i)))return s;if("string"!==o&&t(a=i.toString)&&!n(s=e(a,i)))return s;throw new r("Can't convert object to primitive value")}}var ke,Oe,Pe,Me,Le,Be,De,Ue,Fe,Ne,je,We,ze,He,Ge,qe,Ye,Ve,Xe,$e,Je,Qe,Ze,Ke,et={exports:{}};function tt(){return Oe?ke:(Oe=1,ke=!1)}function nt(){if(Me)return Pe;Me=1;var e=s(),t=Object.defineProperty;return Pe=function(n,r){try{t(e,n,{value:r,configurable:!0,writable:!0})}catch(t){e[n]=r}return r}}function rt(){if(Le)return et.exports;Le=1;var e=tt(),t=s(),n=nt(),r="__core-js_shared__",i=et.exports=t[r]||n(r,{});return(i.versions||(i.versions=[])).push({version:"3.43.0",mode:e?"pure":"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.43.0/LICENSE",source:"https://github.com/zloirock/core-js"}),et.exports}function it(){if(De)return Be;De=1;var e=rt();return Be=function(t,n){return e[t]||(e[t]=n||{})}}function ot(){if(Fe)return Ue;Fe=1;var e=ge(),t=Object;return Ue=function(n){return t(e(n))}}function at(){if(je)return Ne;je=1;var e=he(),t=ot(),n=e({}.hasOwnProperty);return Ne=Object.hasOwn||function(e,r){return n(t(e),r)}}function st(){if(ze)return We;ze=1;var e=he(),t=0,n=Math.random(),r=e(1.1.toString);return We=function(e){return"Symbol("+(void 0===e?"":e)+")_"+r(++t+n,36)}}function ct(){if(Ge)return He;Ge=1;var e=s(),t=it(),n=at(),r=st(),i=Ee(),o=xe(),a=e.Symbol,c=t("wks"),l=o?a.for||a:a&&a.withoutSetter||r;return He=function(e){return n(c,e)||(c[e]=i&&n(a,e)?a[e]:l("Symbol."+e)),c[e]}}function lt(){if(Ye)return qe;Ye=1;var e=_(),t=ye(),n=Se(),r=Te(),i=Re(),o=ct(),a=TypeError,s=o("toPrimitive");return qe=function(o,c){if(!t(o)||n(o))return o;var l,u=r(o,s);if(u){if(void 0===c&&(c="default"),l=e(u,o,c),!t(l)||n(l))return l;throw new a("Can't convert object to primitive value")}return void 0===c&&(c="number"),i(o,c)}}function ut(){if(Xe)return Ve;Xe=1;var e=lt(),t=Se();return Ve=function(n){var r=e(n,"string");return t(r)?r:r+""}}function ht(){if(Je)return $e;Je=1;var e=s(),t=ye(),n=e.document,r=t(n)&&t(n.createElement);return $e=function(e){return r?n.createElement(e):{}}}function dt(){if(Ze)return Qe;Ze=1;var e=y(),t=v(),n=ht();return Qe=!e&&!t(function(){return 7!==Object.defineProperty(n("div"),"a",{get:function(){return 7}}).a})}function ft(){if(Ke)return p;Ke=1;var e=y(),t=_(),n=le(),r=ue(),i=pe(),o=ut(),a=at(),s=dt(),c=Object.getOwnPropertyDescriptor;return p.f=e?c:function(e,l){if(e=i(e),l=o(l),s)try{return c(e,l)}catch(e){}if(a(e,l))return r(!t(n.f,e,l),e[l])},p}var mt,gt,pt,vt,yt,At,_t,bt={};function wt(){if(gt)return mt;gt=1;var e=y(),t=v();return mt=e&&t(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype})}function Et(){if(vt)return pt;vt=1;var e=ye(),t=String,n=TypeError;return pt=function(r){if(e(r))return r;throw new n(t(r)+" is not an object")}}function xt(){if(yt)return bt;yt=1;var e=y(),t=dt(),n=wt(),r=Et(),i=ut(),o=TypeError,a=Object.defineProperty,s=Object.getOwnPropertyDescriptor,c="enumerable",l="configurable",u="writable";return bt.f=e?n?function(e,t,n){if(r(e),t=i(t),r(n),"function"==typeof e&&"prototype"===t&&"value"in n&&u in n&&!n[u]){var o=s(e,t);o&&o[u]&&(e[t]=n.value,n={configurable:l in n?n[l]:o[l],enumerable:c in n?n[c]:o[c],writable:!1})}return a(e,t,n)}:a:function(e,n,s){if(r(e),n=i(n),r(s),t)try{return a(e,n,s)}catch(e){}if("get"in s||"set"in s)throw new o("Accessors not supported");return"value"in s&&(e[n]=s.value),e},bt}function St(){if(_t)return At;_t=1;var e=y(),t=xt(),n=ue();return At=e?function(e,r,i){return t.f(e,r,n(1,i))}:function(e,t,n){return e[t]=n,e}}var Ct,It,Tt,Rt,kt,Ot,Pt,Mt,Lt,Bt,Dt,Ut,Ft,Nt,jt,Wt={exports:{}};function zt(){if(It)return Ct;It=1;var e=y(),t=at(),n=Function.prototype,r=e&&Object.getOwnPropertyDescriptor,i=t(n,"name"),o=i&&"something"===function(){}.name,a=i&&(!e||e&&r(n,"name").configurable);return Ct={EXISTS:i,PROPER:o,CONFIGURABLE:a}}function Ht(){if(Rt)return Tt;Rt=1;var e=he(),t=ve(),n=rt(),r=e(Function.toString);return t(n.inspectSource)||(n.inspectSource=function(e){return r(e)}),Tt=n.inspectSource}function Gt(){if(Mt)return Pt;Mt=1;var e=it(),t=st(),n=e("keys");return Pt=function(e){return n[e]||(n[e]=t(e))}}function qt(){return Bt?Lt:(Bt=1,Lt={})}function Yt(){if(Ut)return Dt;Ut=1;var e,t,n,r=function(){if(Ot)return kt;Ot=1;var e=s(),t=ve(),n=e.WeakMap;return kt=t(n)&&/native code/.test(String(n))}(),i=s(),o=ye(),a=St(),c=at(),l=rt(),u=Gt(),h=qt(),d="Object already initialized",f=i.TypeError,m=i.WeakMap;if(r||l.state){var g=l.state||(l.state=new m);g.get=g.get,g.has=g.has,g.set=g.set,e=function(e,t){if(g.has(e))throw new f(d);return t.facade=e,g.set(e,t),t},t=function(e){return g.get(e)||{}},n=function(e){return g.has(e)}}else{var p=u("state");h[p]=!0,e=function(e,t){if(c(e,p))throw new f(d);return t.facade=e,a(e,p,t),t},t=function(e){return c(e,p)?e[p]:{}},n=function(e){return c(e,p)}}return Dt={set:e,get:t,has:n,enforce:function(r){return n(r)?t(r):e(r,{})},getterFor:function(e){return function(n){var r;if(!o(n)||(r=t(n)).type!==e)throw new f("Incompatible receiver, "+e+" required");return r}}}}function Vt(){if(Ft)return Wt.exports;Ft=1;var e=he(),t=v(),n=ve(),r=at(),i=y(),o=zt().CONFIGURABLE,a=Ht(),s=Yt(),c=s.enforce,l=s.get,u=String,h=Object.defineProperty,d=e("".slice),f=e("".replace),m=e([].join),g=i&&!t(function(){return 8!==h(function(){},"length",{value:8}).length}),p=String(String).split("String"),A=Wt.exports=function(e,t,n){"Symbol("===d(u(t),0,7)&&(t="["+f(u(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!r(e,"name")||o&&e.name!==t)&&(i?h(e,"name",{value:t,configurable:!0}):e.name=t),g&&n&&r(n,"arity")&&e.length!==n.arity&&h(e,"length",{value:n.arity});try{n&&r(n,"constructor")&&n.constructor?i&&h(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var a=c(e);return r(a,"source")||(a.source=m(p,"string"==typeof t?t:"")),e};return Function.prototype.toString=A(function(){return n(this)&&l(this).source||a(this)},"toString"),Wt.exports}function Xt(){if(jt)return Nt;jt=1;var e=ve(),t=xt(),n=Vt(),r=nt();return Nt=function(i,o,a,s){s||(s={});var c=s.enumerable,l=void 0!==s.name?s.name:o;if(e(a)&&n(a,l,s),s.global)c?i[o]=a:r(o,a);else{try{s.unsafe?i[o]&&(c=!0):delete i[o]}catch(e){}c?i[o]=a:t.f(i,o,{value:a,enumerable:!1,configurable:!s.nonConfigurable,writable:!s.nonWritable})}return i}}var $t,Jt,Qt,Zt,Kt,en,tn,nn,rn,on,an,sn,cn,ln,un,hn,dn,fn={};function mn(){if(Zt)return Qt;Zt=1;var e=function(){if(Jt)return $t;Jt=1;var e=Math.ceil,t=Math.floor;return $t=Math.trunc||function(n){var r=+n;return(r>0?t:e)(r)}}();return Qt=function(t){var n=+t;return n!=n||0===n?0:e(n)}}function gn(){if(en)return Kt;en=1;var e=mn(),t=Math.max,n=Math.min;return Kt=function(r,i){var o=e(r);return o<0?t(o+i,0):n(o,i)}}function pn(){if(nn)return tn;nn=1;var e=mn(),t=Math.min;return tn=function(n){var r=e(n);return r>0?t(r,9007199254740991):0}}function vn(){if(on)return rn;on=1;var e=pn();return rn=function(t){return e(t.length)}}function yn(){if(ln)return cn;ln=1;var e=he(),t=at(),n=pe(),r=function(){if(sn)return an;sn=1;var e=pe(),t=gn(),n=vn(),r=function(r){return function(i,o,a){var s=e(i),c=n(s);if(0===c)return!r&&-1;var l,u=t(a,c);if(r&&o!=o){for(;c>u;)if((l=s[u++])!=l)return!0}else for(;c>u;u++)if((r||u in s)&&s[u]===o)return r||u||0;return!r&&-1}};return an={includes:r(!0),indexOf:r(!1)}}().indexOf,i=qt(),o=e([].push);return cn=function(e,a){var s,c=n(e),l=0,u=[];for(s in c)!t(i,s)&&t(c,s)&&o(u,s);for(;a.length>l;)t(c,s=a[l++])&&(~r(u,s)||o(u,s));return u}}function An(){return hn?un:(hn=1,un=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])}function _n(){if(dn)return fn;dn=1;var e=yn(),t=An().concat("length","prototype");return fn.f=Object.getOwnPropertyNames||function(n){return e(n,t)},fn}var bn,wn,En,xn,Sn,Cn,In,Tn,Rn,kn,On,Pn,Mn,Ln,Bn,Dn,Un,Fn,Nn,jn,Wn,zn,Hn,Gn,qn,Yn,Vn,Xn,$n,Jn,Qn,Zn,Kn,er,tr,nr,rr,ir,or,ar,sr,cr,lr={};function ur(){return bn||(bn=1,lr.f=Object.getOwnPropertySymbols),lr}function hr(){if(En)return wn;En=1;var e=Ae(),t=he(),n=_n(),r=ur(),i=Et(),o=t([].concat);return wn=e("Reflect","ownKeys")||function(e){var t=n.f(i(e)),a=r.f;return a?o(t,a(e)):t}}function dr(){if(Sn)return xn;Sn=1;var e=at(),t=hr(),n=ft(),r=xt();return xn=function(i,o,a){for(var s=t(o),c=r.f,l=n.f,u=0;uy&&l(o,arguments[y]),o});if(x.prototype=w,"Error"!==_?i?i(x,E):o(x,E,{name:!0}):h&&v in b&&(a(x,b,v),a(x,b,"prepareStackTrace")),o(x,b),!d)try{w.name!==_&&n(w,"name",_),w.constructor=x}catch(e){}return x}},ar}!function(){if(cr)return a;cr=1;var e=mr(),t=s(),n=gr(),r=Tr(),i="WebAssembly",o=t[i],c=7!==new Error("e",{cause:7}).cause,l=function(t,n){var i={};i[t]=r(t,n,c),e({global:!0,constructor:!0,arity:1,forced:c},i)},u=function(t,n){if(o&&o[t]){var a={};a[t]=r(i+"."+t,n,c),e({target:i,stat:!0,constructor:!0,arity:1,forced:c},a)}};l("Error",function(e){return function(t){return n(e,this,arguments)}}),l("EvalError",function(e){return function(t){return n(e,this,arguments)}}),l("RangeError",function(e){return function(t){return n(e,this,arguments)}}),l("ReferenceError",function(e){return function(t){return n(e,this,arguments)}}),l("SyntaxError",function(e){return function(t){return n(e,this,arguments)}}),l("TypeError",function(e){return function(t){return n(e,this,arguments)}}),l("URIError",function(e){return function(t){return n(e,this,arguments)}}),u("CompileError",function(e){return function(t){return n(e,this,arguments)}}),u("LinkError",function(e){return function(t){return n(e,this,arguments)}}),u("RuntimeError",function(e){return function(t){return n(e,this,arguments)}})}();var Rr,kr,Or,Pr,Mr,Lr,Br,Dr,Ur,Fr,Nr,jr,Wr,zr,Hr,Gr,qr,Yr={};function Vr(){if(kr)return Rr;kr=1;var e=de();return Rr=Array.isArray||function(t){return"Array"===e(t)}}function Xr(){if(Pr)return Or;Pr=1;var e=TypeError;return Or=function(t){if(t>9007199254740991)throw e("Maximum allowed index exceeded");return t}}function $r(){if(Lr)return Mr;Lr=1;var e=de(),t=he();return Mr=function(n){if("Function"===e(n))return t(n)}}function Jr(){if(Dr)return Br;Dr=1;var e=$r(),t=Ie(),n=A(),r=e(e.bind);return Br=function(e,i){return t(e),void 0===i?e:n?r(e,i):function(){return e.apply(i,arguments)}},Br}function Qr(){if(jr)return Nr;jr=1;var e=he(),t=v(),n=ve(),r=wr(),i=Ae(),o=Ht(),a=function(){},s=i("Reflect","construct"),c=/^\s*(?:class|function)\b/,l=e(c.exec),u=!c.test(a),h=function(e){if(!n(e))return!1;try{return s(a,[],e),!0}catch(e){return!1}},d=function(e){if(!n(e))return!1;switch(r(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return u||!!l(c,o(e))}catch(e){return!0}};return d.sham=!0,Nr=!s||t(function(){var e;return h(h.call)||!h(Object)||!h(function(){e=!0})||e})?d:h}function Zr(){if(zr)return Wr;zr=1;var e=Vr(),t=Qr(),n=ye(),r=ct()("species"),i=Array;return Wr=function(o){var a;return e(o)&&(a=o.constructor,(t(a)&&(a===i||e(a.prototype))||n(a)&&null===(a=a[r]))&&(a=void 0)),void 0===a?i:a}}function Kr(){if(Gr)return Hr;Gr=1;var e=Zr();return Hr=function(t,n){return new(e(t))(0===n?0:n)}}!function(){if(qr)return Yr;qr=1;var e=mr(),t=function(){if(Fr)return Ur;Fr=1;var e=Vr(),t=vn(),n=Xr(),r=Jr(),i=function(o,a,s,c,l,u,h,d){for(var f,m,g=l,p=0,v=!!h&&r(h,d);p0&&e(f)?(m=t(f),g=i(o,a,f,m,g,u-1)-1):(n(g+1),o[g]=f),g++),p++;return g};return Ur=i}(),n=ot(),r=vn(),i=mn(),o=Kr();e({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,a=n(this),s=r(a),c=o(a,0);return c.length=t(c,a,a,s,0,void 0===e?1:i(e)),c}})}();var ei,ti,ni,ri={};!function(){if(ni)return ri;ni=1;var e=mr(),t=ot(),n=vn(),r=function(){if(ti)return ei;ti=1;var e=y(),t=Vr(),n=TypeError,r=Object.getOwnPropertyDescriptor,i=e&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}();return ei=i?function(e,i){if(t(e)&&!r(e,"length").writable)throw new n("Cannot set read only .length");return e.length=i}:function(e,t){return e.length=t}}(),i=Xr();e({target:"Array",proto:!0,arity:1,forced:v()(function(){return 4294967297!==[].push.call({length:4294967296},1)})||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(e){return e instanceof TypeError}}()},{push:function(e){var o=t(this),a=n(o),s=arguments.length;i(a+s);for(var c=0;c0;)r[s]=r[--s];s!==c++&&(r[s]=a)}else for(var l=t(o/2),u=n(e(r,0,l),i),h=n(e(r,l),i),d=u.length,f=h.length,m=0,g=0;m3)){if(h)return!0;if(f)return f<603;var e,t,n,r,i="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:n=3;break;case 68:case 71:n=4;break;default:n=2}for(r=0;r<47;r++)m.push({k:t+r,v:n})}for(m.sort(function(e,t){return t.v-e.v}),r=0;ra(n)?1:-1}}(e)),s=i(u),l=0;lu;)n.f(e,a=c[u++],s[a]);return e},Ui}(),r=An(),i=qt(),o=Ni(),a=ht(),s=Gt(),c="prototype",l="script",u=s("IE_PROTO"),h=function(){},d=function(e){return"<"+l+">"+e+""},f=function(e){e.write(d("")),e.close();var t=e.parentWindow.Object;return e=null,t},m=function(){try{e=new ActiveXObject("htmlfile")}catch(e){}var t,n,i;m="undefined"!=typeof document?document.domain&&e?f(e):(n=a("iframe"),i="java"+l+":",n.style.display="none",o.appendChild(n),n.src=String(i),(t=n.contentWindow.document).open(),t.write(d("document.F=Object")),t.close(),t.F):f(e);for(var s=r.length;s--;)delete m[c][r[s]];return m()};return i[u]=!0,Pi=Object.create||function(e,r){var i;return null!==e?(h[c]=t(e),i=new h,h[c]=null,i[u]=e):i=m(),void 0===r?i:n.f(i,r)}}function Wi(){if(Bi)return Li;Bi=1;var e=ct(),t=ji(),n=xt().f,r=e("unscopables"),i=Array.prototype;return void 0===i[r]&&n(i,r,{configurable:!0,value:t(null)}),Li=function(e){i[r][e]=!0}}Di||(Di=1,Wi()("flat"));var zi,Hi,Gi,qi,Yi,Vi,Xi,$i,Ji,Qi,Zi,Ki,eo,to,no,ro,io,oo,ao,so,co,lo,uo,ho,fo,mo,go,po,vo,yo,Ao,_o,bo,wo={};function Eo(){return Hi?zi:(Hi=1,zi="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView)}function xo(){if(qi)return Gi;qi=1;var e=Vt(),t=xt();return Gi=function(n,r,i){return i.get&&e(i.get,r,{getter:!0}),i.set&&e(i.set,r,{setter:!0}),t.f(n,r,i)}}function So(){if(Vi)return Yi;Vi=1;var e=Xt();return Yi=function(t,n,r){for(var i in n)e(t,i,n[i],r);return t}}function Co(){if($i)return Xi;$i=1;var e=_e(),t=TypeError;return Xi=function(n,r){if(e(r,n))return n;throw new t("Incorrect invocation")}}function Io(){if(Qi)return Ji;Qi=1;var e=mn(),t=pn(),n=RangeError;return Ji=function(r){if(void 0===r)return 0;var i=e(r),o=t(i);if(i!==o)throw new n("Wrong length or index");return o}}function To(){if(ro)return no;ro=1;var e=Ki?Zi:(Ki=1,Zi=Math.sign||function(e){var t=+e;return 0===t||t!=t?t:t<0?-1:1}),t=function(){if(to)return eo;to=1;var e=4503599627370496;return eo=function(t){return t+e-e}}(),n=Math.abs;return no=function(r,i,o,a){var s=+r,c=n(s),l=e(s);if(co||h!=h?l*(1/0):l*h}}function Ro(){if(so)return ao;so=1;var e=Array,t=Math.abs,n=Math.pow,r=Math.floor,i=Math.log,o=Math.LN2;return ao={pack:function(a,s,c){var l,u,h,d=e(c),f=8*c-s-1,m=(1<>1,p=23===s?n(2,-24)-n(2,-77):0,v=a<0||0===a&&1/a<0?1:0,y=0;for((a=t(a))!=a||a===1/0?(u=a!=a?1:0,l=m):(l=r(i(a)/o),a*(h=n(2,-l))<1&&(l--,h*=2),(a+=l+g>=1?p/h:p*n(2,1-g))*h>=2&&(l++,h/=2),l+g>=m?(u=0,l=m):l+g>=1?(u=(a*h-1)*n(2,s),l+=g):(u=a*n(2,g-1)*n(2,s),l=0));s>=8;)d[y++]=255&u,u/=256,s-=8;for(l=l<0;)d[y++]=255&l,l/=256,f-=8;return d[y-1]|=128*v,d},unpack:function(e,t){var r,i=e.length,o=8*i-t-1,a=(1<>1,c=o-7,l=i-1,u=e[l--],h=127&u;for(u>>=7;c>0;)h=256*h+e[l--],c-=8;for(r=h&(1<<-c)-1,h>>=-c,c+=t;c>0;)r=256*r+e[l--],c-=8;if(0===h)h=1-s;else{if(h===a)return r?NaN:u?-1/0:1/0;r+=n(2,t),h-=s}return(u?-1:1)*r*n(2,h-t)}}}function ko(){if(ho)return uo;ho=1;var e=at(),t=ve(),n=ot(),r=Gt(),i=function(){if(lo)return co;lo=1;var e=v();return co=!e(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})}(),o=r("IE_PROTO"),a=Object,s=a.prototype;return uo=i?a.getPrototypeOf:function(r){var i=n(r);if(e(i,o))return i[o];var c=i.constructor;return t(c)&&i instanceof c?c.prototype:i instanceof a?s:null}}function Oo(){if(mo)return fo;mo=1;var e=ot(),t=gn(),n=vn();return fo=function(r){for(var i=e(this),o=n(i),a=arguments.length,s=t(a>1?arguments[1]:void 0,o),c=a>2?arguments[2]:void 0,l=void 0===c?o:t(c,o);l>s;)i[s++]=r;return i},fo}function Po(){if(po)return go;po=1;var e=xt().f,t=at(),n=ct()("toStringTag");return go=function(r,i,o){r&&!o&&(r=r.prototype),r&&!t(r,n)&&e(r,n,{configurable:!0,value:i})}}function Mo(){if(yo)return vo;yo=1;var e=s(),t=he(),n=y(),r=Eo(),i=zt(),o=St(),a=xo(),c=So(),l=v(),u=Co(),h=mn(),d=pn(),f=Io(),m=function(){if(oo)return io;oo=1;var e=To();return io=Math.fround||function(t){return e(t,1.1920928955078125e-7,34028234663852886e22,11754943508222875e-54)}}(),g=Ro(),p=ko(),A=Ar(),_=Oo(),b=bi(),w=br(),E=dr(),x=Po(),S=Yt(),C=i.PROPER,I=i.CONFIGURABLE,T="ArrayBuffer",R="DataView",k="prototype",O="Wrong index",P=S.getterFor(T),M=S.getterFor(R),L=S.set,B=e[T],D=B,U=D&&D[k],F=e[R],N=F&&F[k],j=Object.prototype,W=e.Array,z=e.RangeError,H=t(_),G=t([].reverse),q=g.pack,Y=g.unpack,V=function(e){return[255&e]},X=function(e){return[255&e,e>>8&255]},$=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},J=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},Q=function(e){return q(m(e),23,4)},Z=function(e){return q(e,52,8)},K=function(e,t,n){a(e[k],t,{configurable:!0,get:function(){return n(this)[t]}})},ee=function(e,t,n,r){var i=M(e),o=f(n),a=!!r;if(o+t>i.byteLength)throw new z(O);var s=i.bytes,c=o+i.byteOffset,l=b(s,c,c+t);return a?l:G(l)},te=function(e,t,n,r,i,o){var a=M(e),s=f(n),c=r(+i),l=!!o;if(s+t>a.byteLength)throw new z(O);for(var u=a.bytes,h=s+a.byteOffset,d=0;d>24)},setUint8:function(e,t){ie(this,e,t<<24>>24)}},{unsafe:!0})}else U=(D=function(e){u(this,U);var t=f(e);L(this,{type:T,bytes:H(W(t),0),byteLength:t}),n||(this.byteLength=t,this.detached=!1)})[k],N=(F=function(e,t,r){u(this,N),u(e,U);var i=P(e),o=i.byteLength,a=h(t);if(a<0||a>o)throw new z("Wrong offset");if(a+(r=void 0===r?o-a:d(r))>o)throw new z("Wrong length");L(this,{type:R,buffer:e,byteLength:r,byteOffset:a,bytes:i.bytes}),n||(this.buffer=e,this.byteLength=r,this.byteOffset=a)})[k],n&&(K(D,"byteLength",P),K(F,"buffer",M),K(F,"byteLength",M),K(F,"byteOffset",M)),c(N,{getInt8:function(e){return ee(this,1,e)[0]<<24>>24},getUint8:function(e){return ee(this,1,e)[0]},getInt16:function(e){var t=ee(this,2,e,arguments.length>1&&arguments[1]);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=ee(this,2,e,arguments.length>1&&arguments[1]);return t[1]<<8|t[0]},getInt32:function(e){return J(ee(this,4,e,arguments.length>1&&arguments[1]))},getUint32:function(e){return J(ee(this,4,e,arguments.length>1&&arguments[1]))>>>0},getFloat32:function(e){return Y(ee(this,4,e,arguments.length>1&&arguments[1]),23)},getFloat64:function(e){return Y(ee(this,8,e,arguments.length>1&&arguments[1]),52)},setInt8:function(e,t){te(this,1,e,V,t)},setUint8:function(e,t){te(this,1,e,V,t)},setInt16:function(e,t){te(this,2,e,X,t,arguments.length>2&&arguments[2])},setUint16:function(e,t){te(this,2,e,X,t,arguments.length>2&&arguments[2])},setInt32:function(e,t){te(this,4,e,$,t,arguments.length>2&&arguments[2])},setUint32:function(e,t){te(this,4,e,$,t,arguments.length>2&&arguments[2])},setFloat32:function(e,t){te(this,4,e,Q,t,arguments.length>2&&arguments[2])},setFloat64:function(e,t){te(this,8,e,Z,t,arguments.length>2&&arguments[2])}});return x(D,T),x(F,R),vo={ArrayBuffer:D,DataView:F}}function Lo(){if(_o)return Ao;_o=1;var e=Ae(),t=xo(),n=ct(),r=y(),i=n("species");return Ao=function(n){var o=e(n);r&&o&&!o[i]&&t(o,i,{configurable:!0,get:function(){return this}})}}!function(){if(bo)return wo;bo=1;var e=mr(),t=s(),n=Mo(),r=Lo(),i="ArrayBuffer",o=n[i];e({global:!0,constructor:!0,forced:t[i]!==o},{ArrayBuffer:o}),r(i)}();var Bo,Do={};!function(){if(Bo)return Do;Bo=1;var e=mr(),t=$r(),n=v(),r=Mo(),i=Et(),o=gn(),a=pn(),s=r.ArrayBuffer,c=r.DataView,l=c.prototype,u=t(s.prototype.slice),h=t(l.getUint8),d=t(l.setUint8);e({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:n(function(){return!new s(2).slice(1,void 0).byteLength})},{slice:function(e,t){if(u&&void 0===t)return u(i(this),e);for(var n=i(this).byteLength,r=o(e,n),l=o(void 0===t?n:t,n),f=new s(a(l-r)),m=new c(this),g=new c(f),p=0;r92||"NODE"===r&&n>94||"BROWSER"===r&&n>97)return!1;var e=new ArrayBuffer(8),t=i(e,{transfer:[e]});return 0!==e.byteLength||8!==t.byteLength})}function ua(){if(na)return ta;na=1;var e,t,n,r,i=s(),o=ca(),a=la(),c=i.structuredClone,l=i.ArrayBuffer,u=i.MessageChannel,h=!1;if(a)h=function(e){c(e,{transfer:[e]})};else if(l)try{u||(e=o("worker_threads"))&&(u=e.MessageChannel),u&&(t=new u,n=new l(2),r=function(e){t.port1.postMessage(null,[e])},2===n.byteLength&&(r(n),0===n.byteLength&&(h=r)))}catch(e){}return ta=h}function ha(){if(ia)return ra;ia=1;var e=s(),t=he(),n=pr(),r=Io(),i=function(){if(Yo)return qo;Yo=1;var e=Go(),t=TypeError;return qo=function(n){if(e(n))throw new t("ArrayBuffer is detached");return n}}(),o=Ho(),a=ua(),c=la(),l=e.structuredClone,u=e.ArrayBuffer,h=e.DataView,d=Math.min,f=u.prototype,m=h.prototype,g=t(f.slice),p=n(f,"resizable","get"),v=n(f,"maxByteLength","get"),y=t(m.getInt8),A=t(m.setInt8);return ra=(c||a)&&function(e,t,n){var s,f=o(e),m=void 0===t?f:r(t),_=!p||!p(e);if(i(e),c&&(e=l(e,{transfer:[e]}),f===m&&(n||_)))return e;if(f>=m&&(!n||_))s=g(e,0,m);else{var b=n&&!_&&v?{maxByteLength:v(e)}:void 0;s=new u(m,b);for(var w=new h(e),E=new h(s),x=d(m,f),S=0;S=0;i--)if(void 0!==t[i])try{r=e(t[i].iterator,n,r)}catch(e){n="throw",r=e}if("throw"===n)throw r;return r}}function Ga(){if(Oa)return ka;Oa=1;var e=_(),t=ji(),n=St(),r=So(),i=ct(),o=Yt(),a=Te(),s=ba().IteratorPrototype,c=Wa(),l=za(),u=Ha(),h=i("toStringTag"),d="IteratorHelper",f="WrapForValidIterator",m="normal",g="throw",p=o.set,v=function(n){var i=o.getterFor(n?f:d);return r(t(s),{next:function(){var e=i(this);if(n)return e.nextHandler();if(e.done)return c(void 0,!0);try{var t=e.nextHandler();return e.returnHandlerResult?t:c(t,e.done)}catch(t){throw e.done=!0,t}},return:function(){var t=i(this),r=t.iterator;if(t.done=!0,n){var o=a(r,"return");return o?e(o,r):c(void 0,!0)}if(t.inner)try{l(t.inner.iterator,m)}catch(e){return l(r,g,e)}if(t.openIters)try{u(t.openIters,m)}catch(e){return l(r,g,e)}return r&&l(r,m),c(void 0,!0)}})},y=v(!0),A=v(!1);return n(A,h,"Iterator Helper"),ka=function(e,t,n){var r=function(r,i){i?(i.iterator=r.iterator,i.next=r.next):i=r,i.type=t?f:d,i.returnHandlerResult=!!n,i.nextHandler=e,i.counter=0,i.done=!1,p(this,i)};return r.prototype=t?y:A,r}}function qa(){if(Ma)return Pa;Ma=1;var e=Et(),t=za();return Pa=function(n,r,i,o){try{return o?r(e(i)[0],i[1]):r(i)}catch(e){t(n,"throw",e)}}}function Ya(){return Ba?La:(Ba=1,La=function(e,t){var n="function"==typeof Iterator&&Iterator.prototype[e];if(n)try{n.call({next:null},t).next()}catch(e){return!0}})}function Va(){if(Ua)return Da;Ua=1;var e=s();return Da=function(t,n){var r=e.Iterator,i=r&&r.prototype,o=i&&i[t],a=!1;if(o)try{o.call({next:function(){return{done:!0}},return:function(){a=!0}},-1)}catch(e){e instanceof n||(a=!1)}if(!a)return o}}!function(){if(Fa)return Na;Fa=1;var e=mr(),t=_(),n=Ie(),r=Et(),i=ja(),o=Ga(),a=qa(),s=tt(),c=za(),l=Ya(),u=Va(),h=!s&&!l("filter",function(){}),d=!s&&!h&&u("filter",TypeError),f=s||h||d,m=o(function(){for(var e,n,i=this.iterator,o=this.predicate,s=this.next;;){if(e=r(t(s,i)),this.done=!!e.done)return;if(n=e.value,a(i,o,[n,this.counter++],!0))return n}});e({target:"Iterator",proto:!0,real:!0,forced:f},{filter:function(e){r(this);try{n(e)}catch(e){c(this,"throw",e)}return d?t(d,this,e):new m(i(this),{predicate:e})}})}();var Xa,$a,Ja,Qa,Za,Ka,es,ts,ns,rs,is,os={};function as(){return $a?Xa:($a=1,Xa={})}function ss(){if(Qa)return Ja;Qa=1;var e=ct(),t=as(),n=e("iterator"),r=Array.prototype;return Ja=function(e){return void 0!==e&&(t.Array===e||r[n]===e)}}function cs(){if(Ka)return Za;Ka=1;var e=wr(),t=Te(),n=me(),r=as(),i=ct()("iterator");return Za=function(o){if(!n(o))return t(o,i)||t(o,"@@iterator")||r[e(o)]}}function ls(){if(ts)return es;ts=1;var e=_(),t=Ie(),n=Et(),r=Ce(),i=cs(),o=TypeError;return es=function(a,s){var c=arguments.length<2?i(a):s;if(t(c))return n(e(c,a));throw new o(r(a)+" is not iterable")},es}function us(){if(rs)return ns;rs=1;var e=Jr(),t=_(),n=Et(),r=Ce(),i=ss(),o=vn(),a=_e(),s=ls(),c=cs(),l=za(),u=TypeError,h=function(e,t){this.stopped=e,this.result=t},d=h.prototype;return ns=function(f,m,g){var p,v,y,A,_,b,w,E=g&&g.that,x=!(!g||!g.AS_ENTRIES),S=!(!g||!g.IS_RECORD),C=!(!g||!g.IS_ITERATOR),I=!(!g||!g.INTERRUPTED),T=e(m,E),R=function(e){return p&&l(p,"normal"),new h(!0,e)},k=function(e){return x?(n(e),I?T(e[0],e[1],R):T(e[0],e[1])):I?T(e,R):T(e)};if(S)p=f.iterator;else if(C)p=f;else{if(!(v=c(f)))throw new u(r(f)+" is not iterable");if(i(v)){for(y=0,A=o(f);A>y;y++)if((_=k(f[y]))&&a(d,_))return _;return new h(!1)}p=s(f,v)}for(b=S?f.next:p.next;!(w=t(b,p)).done;){try{_=k(w.value)}catch(e){l(p,"throw",e)}if("object"==typeof _&&_&&a(d,_))return _}return new h(!1)}}!function(){if(is)return os;is=1;var e=mr(),t=_(),n=us(),r=Ie(),i=Et(),o=ja(),a=za(),s=Va()("forEach",TypeError);e({target:"Iterator",proto:!0,real:!0,forced:s},{forEach:function(e){i(this);try{r(e)}catch(e){a(this,"throw",e)}if(s)return t(s,this,e);var c=o(this),l=0;n(c,function(t){e(t,l++)},{IS_RECORD:!0})}})}();var hs,ds={};!function(){if(hs)return ds;hs=1;var e=mr(),t=_(),n=Ie(),r=Et(),i=ja(),o=Ga(),a=qa(),s=za(),c=Ya(),l=Va(),u=tt(),h=!u&&!c("map",function(){}),d=!u&&!h&&l("map",TypeError),f=u||h||d,m=o(function(){var e=this.iterator,n=r(t(this.next,e));if(!(this.done=!!n.done))return a(e,this.mapper,[n.value,this.counter++],!0)});e({target:"Iterator",proto:!0,real:!0,forced:f},{map:function(e){r(this);try{n(e)}catch(e){s(this,"throw",e)}return d?t(d,this,e):new m(i(this),{mapper:e})}})}();var fs,ms,gs,ps={};!function(){if(gs)return ps;gs=1;var e=mr(),t=Ae(),n=gr(),r=_(),i=he(),o=v(),a=ve(),s=Se(),c=bi(),l=function(){if(ms)return fs;ms=1;var e=he(),t=Vr(),n=ve(),r=de(),i=Er(),o=e([].push);return fs=function(e){if(n(e))return e;if(t(e)){for(var a=e.length,s=[],c=0;cb)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$c")})}!function(){if(Ms)return Ls;Ms=1;var e=y(),t=s(),n=he(),r=fr(),i=br(),o=St(),a=ji(),c=_n().f,l=_e(),u=function(){if(_s)return As;_s=1;var e=ye(),t=de(),n=ct()("match");return As=function(r){var i;return e(r)&&(void 0!==(i=r[n])?!!i:"RegExp"===t(r))}}(),h=Er(),d=Ds(),f=Us(),m=_r(),g=Xt(),p=v(),A=at(),_=Yt().enforce,b=Lo(),w=ct(),E=Fs(),x=Ns(),S=w("match"),C=t.RegExp,I=C.prototype,T=t.SyntaxError,R=n(I.exec),k=n("".charAt),O=n("".replace),P=n("".indexOf),M=n("".slice),L=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,B=/a/g,D=/a/g,U=new C(B)!==B,F=f.MISSED_STICKY,N=f.UNSUPPORTED_Y,j=e&&(!U||F||E||x||p(function(){return D[S]=!1,C(B)!==B||C(D)===D||"/a/i"!==String(C(B,"i"))}));if(r("RegExp",j)){for(var W=function(e,t){var n,r,s,c,f,m,g=l(I,this),p=u(e),v=void 0===t,y=[],b=e;if(!g&&p&&v&&e.constructor===W)return e;if((p||l(I,e))&&(e=e.source,v&&(t=d(b))),e=void 0===e?"":h(e),t=void 0===t?"":h(t),b=e,E&&"dotAll"in B&&(r=!!t&&P(t,"s")>-1)&&(t=O(t,/s/g,"")),n=t,F&&"sticky"in B&&(s=!!t&&P(t,"y")>-1)&&N&&(t=O(t,/y/g,"")),x&&(c=function(e){for(var t,n=e.length,r=0,i="",o=[],s=a(null),c=!1,l=!1,u=0,h="";r<=n;r++){if("\\"===(t=k(e,r)))t+=k(e,++r);else if("]"===t)c=!1;else if(!c)switch(!0){case"["===t:c=!0;break;case"("===t:if(i+=t,"?:"===M(e,r+1,r+3))continue;R(L,M(e,r+1))&&(r+=2,l=!0),u++;continue;case">"===t&&l:if(""===h||A(s,h))throw new T("Invalid capture group name");s[h]=!0,o[o.length]=[h,u],l=!1,h="";continue}l?h+=t:i+=t}return[i,o]}(e),e=c[0],y=c[1]),f=i(C(e,t),g?this:I,W),(r||s||y.length)&&(m=_(f),r&&(m.dotAll=!0,m.raw=W(function(e){for(var t,n=e.length,r=0,i="",o=!1;r<=n;r++)"\\"!==(t=k(e,r))?o||"."!==t?("["===t?o=!0:"]"===t&&(o=!1),i+=t):i+="[\\s\\S]":i+=t+k(e,++r);return i}(e),n)),s&&(m.sticky=!0),y.length&&(m.groups=y)),e!==b)try{o(f,"source",""===b?"(?:)":b)}catch(e){}return f},z=c(C),H=0;z.length>H;)m(W,C,z[H++]);I.constructor=W,W.prototype=I,g(t,"RegExp",W,{constructor:!0})}b("RegExp")}();var js,Ws={};!function(){if(js)return Ws;js=1;var e=y(),t=Fs(),n=de(),r=xo(),i=Yt().get,o=RegExp.prototype,a=TypeError;e&&t&&r(o,"dotAll",{configurable:!0,get:function(){if(this!==o){if("RegExp"===n(this))return!!i(this).dotAll;throw new a("Incompatible receiver, RegExp required")}}})}();var zs,Hs,Gs,qs={};function Ys(){if(Hs)return zs;Hs=1;var e,t,n=_(),r=he(),i=Er(),o=Bs(),a=Us(),s=it(),c=ji(),l=Yt().get,u=Fs(),h=Ns(),d=s("native-string-replace",String.prototype.replace),f=RegExp.prototype.exec,m=f,g=r("".charAt),p=r("".indexOf),v=r("".replace),y=r("".slice),A=(t=/b*/g,n(f,e=/a/,"a"),n(f,t,"a"),0!==e.lastIndex||0!==t.lastIndex),b=a.BROKEN_CARET,w=void 0!==/()??/.exec("")[1];return(A||w||b||u||h)&&(m=function(e){var t,r,a,s,u,h,_,E=this,x=l(E),S=i(e),C=x.raw;if(C)return C.lastIndex=E.lastIndex,t=n(m,C,S),E.lastIndex=C.lastIndex,t;var I=x.groups,T=b&&E.sticky,R=n(o,E),k=E.source,O=0,P=S;if(T&&(R=v(R,"y",""),-1===p(R,"g")&&(R+="g"),P=y(S,E.lastIndex),E.lastIndex>0&&(!E.multiline||E.multiline&&"\n"!==g(S,E.lastIndex-1))&&(k="(?: "+k+")",P=" "+P,O++),r=new RegExp("^(?:"+k+")",R)),w&&(r=new RegExp("^"+k+"$(?!\\s)",R)),A&&(a=E.lastIndex),s=n(f,T?r:E,P),T?s?(s.input=y(s.input,O),s[0]=y(s[0],O),s.index=E.lastIndex,E.lastIndex+=s[0].length):E.lastIndex=0:A&&s&&(E.lastIndex=E.global?s.index+s[0].length:a),w&&s&&s.length>1&&n(d,s[0],r,function(){for(u=1;u=f?e?"":void 0:(l=o(h,d))<55296||l>56319||d+1===f||(u=o(h,d+1))<56320||u>57343?e?i(h,d):l:e?a(h,d,d+2):u-56320+(l-55296<<10)+65536}};return Js={codeAt:s(!1),charAt:s(!0)}}function sc(){if(Ks)return Zs;Ks=1;var e=ac().charAt;return Zs=function(t,n,r){return n+(r?e(t,n).length:1)}}function cc(){if(tc)return ec;tc=1;var e=he(),t=ot(),n=Math.floor,r=e("".charAt),i=e("".replace),o=e("".slice),a=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,s=/\$([$&'`]|\d{1,2})/g;return ec=function(e,c,l,u,h,d){var f=l+e.length,m=u.length,g=s;return void 0!==h&&(h=t(h),g=a),i(d,g,function(t,i){var a;switch(r(i,0)){case"$":return"$";case"&":return e;case"`":return o(c,0,l);case"'":return o(c,f);case"<":a=h[o(i,1,-1)];break;default:var s=+i;if(0===s)return t;if(s>m){var d=n(s/10);return 0===d?t:d<=m?void 0===u[d-1]?r(i,1):u[d-1]+r(i,1):t}a=u[s-1]}return void 0===a?"":a})}}!function(){if(ic)return oc;ic=1;var e=gr(),t=_(),n=he(),r=function(){if($s)return Xs;$s=1,Vs();var e=_(),t=Xt(),n=Ys(),r=v(),i=ct(),o=St(),a=i("species"),s=RegExp.prototype;return Xs=function(c,l,u,h){var d=i(c),f=!r(function(){var e={};return e[d]=function(){return 7},7!==""[c](e)}),m=f&&!r(function(){var e=!1,t=/a/;return"split"===c&&((t={}).constructor={},t.constructor[a]=function(){return t},t.flags="",t[d]=/./[d]),t.exec=function(){return e=!0,null},t[d](""),!e});if(!f||!m||u){var g=/./[d],p=l(d,""[c],function(t,r,i,o,a){var c=r.exec;return c===n||c===s.exec?f&&!a?{done:!0,value:e(g,r,i,o)}:{done:!0,value:e(t,i,r,o)}:{done:!1}});t(String.prototype,c,p[0]),t(s,d,p[1])}h&&o(s[d],"sham",!0)}}(),i=v(),o=Et(),a=ve(),s=ye(),c=mn(),l=pn(),u=Er(),h=ge(),d=sc(),f=Te(),m=cc(),g=Ds(),p=function(){if(rc)return nc;rc=1;var e=_(),t=Et(),n=ve(),r=de(),i=Ys(),o=TypeError;return nc=function(a,s){var c=a.exec;if(n(c)){var l=e(c,a,s);return null!==l&&t(l),l}if("RegExp"===r(a))return e(i,a,s);throw new o("RegExp#exec called on incompatible receiver")}}(),y=ct()("replace"),A=Math.max,b=Math.min,w=n([].concat),E=n([].push),x=n("".indexOf),S=n("".slice),C=function(e){return void 0===e?e:String(e)},I="$0"==="a".replace(/./,"$0"),T=!!/./[y]&&""===/./[y]("a","$0");r("replace",function(n,r,i){var v=T?"$":"$0";return[function(e,n){var i=h(this),o=s(e)?f(e,y):void 0;return o?t(o,e,i,n):t(r,u(i),e,n)},function(t,n){var s=o(this),h=u(t);if("string"==typeof n&&-1===x(n,v)&&-1===x(n,"$<")){var f=i(r,s,h,n);if(f.done)return f.value}var y=a(n);y||(n=u(n));var _,I=u(g(s)),T=-1!==x(I,"g");T&&(_=-1!==x(I,"u"),s.lastIndex=0);for(var R,k=[];null!==(R=p(s,h))&&(E(k,R),T);){""===u(R[0])&&(s.lastIndex=d(h,l(s.lastIndex),_))}for(var O="",P=0,M=0;M=P&&(O+=S(h,P,D)+L,P=D+B.length)}return O+S(h,P)}]},!!i(function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$")})||!I||T)}();var lc,uc,hc,dc,fc,mc,gc,pc={};function vc(){return uc?lc:(uc=1,lc="\t\n\v\f\r                 \u2028\u2029\ufeff")}!function(){if(gc)return pc;gc=1;var e=mr(),t=function(){if(dc)return hc;dc=1;var e=he(),t=ge(),n=Er(),r=vc(),i=e("".replace),o=RegExp("^["+r+"]+"),a=RegExp("(^|[^"+r+"])["+r+"]+$"),s=function(e){return function(r){var s=n(t(r));return 1&e&&(s=i(s,o,"")),2&e&&(s=i(s,a,"$1")),s}};return hc={start:s(1),end:s(2),trim:s(3)}}().trim,n=function(){if(mc)return fc;mc=1;var e=zt().PROPER,t=v(),n=vc();return fc=function(r){return t(function(){return!!n[r]()||"​…᠎"!=="​…᠎"[r]()||e&&n[r].name!==r})}}();e({target:"String",proto:!0,forced:n("trim")},{trim:function(){return t(this)}})}();var yc,Ac,_c,bc,wc,Ec,xc,Sc,Cc,Ic,Tc,Rc,kc,Oc,Pc,Mc,Lc,Bc,Dc,Uc,Fc,Nc,jc,Wc,zc,Hc,Gc,qc,Yc={exports:{}};function Vc(){if(Ac)return yc;Ac=1;var e=ct()("iterator"),t=!1;try{var n=0,r={next:function(){return{done:!!n++}},return:function(){t=!0}};r[e]=function(){return this},Array.from(r,function(){throw 2})}catch(e){}return yc=function(n,r){try{if(!r&&!t)return!1}catch(e){return!1}var i=!1;try{var o={};o[e]=function(){return{next:function(){return{done:i=!0}}}},n(o)}catch(e){}return i}}function Xc(){if(bc)return _c;bc=1;var e,t,n,r=Eo(),i=y(),o=s(),a=ve(),c=ye(),l=at(),u=wr(),h=Ce(),d=St(),f=Xt(),m=xo(),g=_e(),p=ko(),v=Ar(),A=ct(),_=st(),b=Yt(),w=b.enforce,E=b.get,x=o.Int8Array,S=x&&x.prototype,C=o.Uint8ClampedArray,I=C&&C.prototype,T=x&&p(x),R=S&&p(S),k=Object.prototype,O=o.TypeError,P=A("toStringTag"),M=_("TYPED_ARRAY_TAG"),L="TypedArrayConstructor",B=r&&!!v&&"Opera"!==u(o.opera),D=!1,U={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},F={BigInt64Array:8,BigUint64Array:8},N=function(e){var t=p(e);if(c(t)){var n=E(t);return n&&l(n,L)?n[L]:N(t)}},j=function(e){if(!c(e))return!1;var t=u(e);return l(U,t)||l(F,t)};for(e in U)(n=(t=o[e])&&t.prototype)?w(n)[L]=t:B=!1;for(e in F)(n=(t=o[e])&&t.prototype)&&(w(n)[L]=t);if((!B||!a(T)||T===Function.prototype)&&(T=function(){throw new O("Incorrect invocation")},B))for(e in U)o[e]&&v(o[e],T);if((!B||!R||R===k)&&(R=T.prototype,B))for(e in U)o[e]&&v(o[e].prototype,R);if(B&&p(I)!==R&&v(I,R),i&&!l(R,P))for(e in D=!0,m(R,P,{configurable:!0,get:function(){return c(this)?this[M]:void 0}}),U)o[e]&&d(o[e],M,e);return _c={NATIVE_ARRAY_BUFFER_VIEWS:B,TYPED_ARRAY_TAG:D&&M,aTypedArray:function(e){if(j(e))return e;throw new O("Target is not a typed array")},aTypedArrayConstructor:function(e){if(a(e)&&(!v||g(T,e)))return e;throw new O(h(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,r){if(i){if(n)for(var a in U){var s=o[a];if(s&&l(s.prototype,e))try{delete s.prototype[e]}catch(n){try{s.prototype[e]=t}catch(e){}}}R[e]&&!n||f(R,e,n?t:B&&S[e]||t,r)}},exportTypedArrayStaticMethod:function(e,t,n){var r,a;if(i){if(v){if(n)for(r in U)if((a=o[r])&&l(a,e))try{delete a[e]}catch(e){}if(T[e]&&!n)return;try{return f(T,e,n?t:B&&T[e]||t)}catch(e){}}for(r in U)!(a=o[r])||a[e]&&!n||f(a,e,t)}},getTypedArrayConstructor:N,isView:function(e){if(!c(e))return!1;var t=u(e);return"DataView"===t||l(U,t)||l(F,t)},isTypedArray:j,TypedArray:T,TypedArrayPrototype:R}}function $c(){if(Sc)return xc;Sc=1;var e=ye(),t=Math.floor;return xc=Number.isInteger||function(n){return!e(n)&&isFinite(n)&&t(n)===n}}function Jc(){if(Ic)return Cc;Ic=1;var e=mn(),t=RangeError;return Cc=function(n){var r=e(n);if(r<0)throw new t("The argument can't be less than 0");return r}}function Qc(){if(Rc)return Tc;Rc=1;var e=Jc(),t=RangeError;return Tc=function(n,r){var i=e(n);if(i%r)throw new t("Wrong offset");return i}}function Zc(){if(Oc)return kc;Oc=1;var e=Math.round;return kc=function(t){var n=e(t);return n<0?0:n>255?255:255&n}}function Kc(){if(Mc)return Pc;Mc=1;var e=Qr(),t=Ce(),n=TypeError;return Pc=function(r){if(e(r))return r;throw new n(t(r)+" is not a constructor")}}function el(){if(Bc)return Lc;Bc=1;var e=wr();return Lc=function(t){var n=e(t);return"BigInt64Array"===n||"BigUint64Array"===n}}function tl(){if(Uc)return Dc;Uc=1;var e=lt(),t=TypeError;return Dc=function(n){var r=e(n,"number");if("number"==typeof r)throw new t("Can't convert number to bigint");return BigInt(r)}}function nl(){if(Nc)return Fc;Nc=1;var e=Jr(),t=_(),n=Kc(),r=ot(),i=vn(),o=ls(),a=cs(),s=ss(),c=el(),l=Xc().aTypedArrayConstructor,u=tl();return Fc=function(h){var d,f,m,g,p,v,y,A,_=n(this),b=r(h),w=arguments.length,E=w>1?arguments[1]:void 0,x=void 0!==E,S=a(b);if(S&&!s(S))for(A=(y=o(b,S)).next,b=[];!(v=t(A,y)).done;)b.push(v.value);for(x&&w>2&&(E=e(E,arguments[2])),f=i(b),m=new(l(_))(f),g=c(m),d=0;f>d;d++)p=x?E(b[d],d):b[d],m[d]=g?u(p):+p;return m},Fc}function rl(){if(Hc)return zc;Hc=1;var e=vn();return zc=function(t,n,r){for(var i=0,o=arguments.length>2?r:e(n),a=new t(o);o>i;)a[i]=n[i++];return a},zc}function il(){if(Gc)return Yc.exports;Gc=1;var e=mr(),t=s(),n=_(),r=y(),i=function(){if(Ec)return wc;Ec=1;var e=s(),t=v(),n=Vc(),r=Xc().NATIVE_ARRAY_BUFFER_VIEWS,i=e.ArrayBuffer,o=e.Int8Array;return wc=!r||!t(function(){o(1)})||!t(function(){new o(-1)})||!n(function(e){new o,new o(null),new o(1.5),new o(e)},!0)||t(function(){return 1!==new o(new i(2),1,void 0).length})}(),o=Xc(),a=Mo(),c=Co(),l=ue(),u=St(),h=$c(),d=pn(),f=Io(),m=Qc(),g=Zc(),p=ut(),A=at(),b=wr(),w=ye(),E=Se(),x=ji(),S=_e(),C=Ar(),I=_n().f,T=nl(),R=function(){if(Wc)return jc;Wc=1;var e=Jr(),t=he(),n=fe(),r=ot(),i=vn(),o=Kr(),a=t([].push),s=function(t){var s=1===t,c=2===t,l=3===t,u=4===t,h=6===t,d=7===t,f=5===t||h;return function(m,g,p,v){for(var y,A,_=r(m),b=n(_),w=i(b),E=e(g,p),x=0,S=v||o,C=s?S(m,w):c||d?S(m,0):void 0;w>x;x++)if((f||x in b)&&(A=E(y=b[x],x,_),t))if(s)C[x]=A;else if(A)switch(t){case 3:return!0;case 5:return y;case 6:return x;case 2:a(C,y)}else switch(t){case 4:return!1;case 7:a(C,y)}return h?-1:l||u?u:C}};return jc={forEach:s(0),map:s(1),filter:s(2),some:s(3),every:s(4),find:s(5),findIndex:s(6),filterReject:s(7)}}().forEach,k=Lo(),O=xo(),P=xt(),M=ft(),L=rl(),B=Yt(),D=br(),U=B.get,F=B.set,N=B.enforce,j=P.f,W=M.f,z=t.RangeError,H=a.ArrayBuffer,G=H.prototype,q=a.DataView,Y=o.NATIVE_ARRAY_BUFFER_VIEWS,V=o.TYPED_ARRAY_TAG,X=o.TypedArray,$=o.TypedArrayPrototype,J=o.isTypedArray,Q="BYTES_PER_ELEMENT",Z="Wrong length",K=function(e,t){O(e,t,{configurable:!0,get:function(){return U(this)[t]}})},ee=function(e){var t;return S(G,e)||"ArrayBuffer"===(t=b(e))||"SharedArrayBuffer"===t},te=function(e,t){return J(e)&&!E(t)&&t in e&&h(+t)&&t>=0},ne=function(e,t){return t=p(t),te(e,t)?l(2,e[t]):W(e,t)},re=function(e,t,n){return t=p(t),!(te(e,t)&&w(n)&&A(n,"value"))||A(n,"get")||A(n,"set")||n.configurable||A(n,"writable")&&!n.writable||A(n,"enumerable")&&!n.enumerable?j(e,t,n):(e[t]=n.value,e)};return r?(Y||(M.f=ne,P.f=re,K($,"buffer"),K($,"byteOffset"),K($,"byteLength"),K($,"length")),e({target:"Object",stat:!0,forced:!Y},{getOwnPropertyDescriptor:ne,defineProperty:re}),Yc.exports=function(r,o,a){var s=r.match(/\d+/)[0]/8,l=r+(a?"Clamped":"")+"Array",h="get"+r,p="set"+r,v=t[l],y=v,A=y&&y.prototype,_={},b=function(e,t){j(e,t,{get:function(){return function(e,t){var n=U(e);return n.view[h](t*s+n.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,n){var r=U(e);r.view[p](t*s+r.byteOffset,a?g(n):n,!0)}(this,t,e)},enumerable:!0})};Y?i&&(y=o(function(e,t,r,i){return c(e,A),D(w(t)?ee(t)?void 0!==i?new v(t,m(r,s),i):void 0!==r?new v(t,m(r,s)):new v(t):J(t)?L(y,t):n(T,y,t):new v(f(t)),e,y)}),C&&C(y,X),R(I(v),function(e){e in y||u(y,e,v[e])}),y.prototype=A):(y=o(function(e,t,r,i){c(e,A);var o,a,l,u=0,h=0;if(w(t)){if(!ee(t))return J(t)?L(y,t):n(T,y,t);o=t,h=m(r,s);var g=t.byteLength;if(void 0===i){if(g%s)throw new z(Z);if((a=g-h)<0)throw new z(Z)}else if((a=d(i)*s)+h>g)throw new z(Z);l=a/s}else l=f(t),o=new H(a=l*s);for(F(e,{buffer:o,byteOffset:h,byteLength:a,length:l,view:new q(o)});u=0?a:o+a;return s<0||s>=o?void 0:i[s]})}();var sl,cl={};!function(){if(sl)return cl;sl=1;var e=Xc(),t=Oo(),n=tl(),r=wr(),i=_(),o=he(),a=v(),s=e.aTypedArray,c=e.exportTypedArrayMethod,l=o("".slice);c("fill",function(e){var o=arguments.length;s(this);var a="Big"===l(r(this),0,3)?n(e):+e;return i(t,this,a,o>1?arguments[1]:void 0,o>2?arguments[2]:void 0)},a(function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e}))}();var ll,ul,hl,dl={};function fl(){if(ul)return ll;ul=1;var e=Jr(),t=fe(),n=ot(),r=vn(),i=function(i){var o=1===i;return function(a,s,c){for(var l,u=n(a),h=t(u),d=r(h),f=e(s,c);d-- >0;)if(f(l=h[d],d,u))switch(i){case 0:return l;case 1:return d}return o?-1:void 0}};return ll={findLast:i(0),findLastIndex:i(1)}}!function(){if(hl)return dl;hl=1;var e=Xc(),t=fl().findLast,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("findLast",function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)})}();var ml,gl={};!function(){if(ml)return gl;ml=1;var e=Xc(),t=fl().findLastIndex,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("findLastIndex",function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)})}();var pl,vl={};!function(){if(pl)return vl;pl=1;var e=s(),t=_(),n=Xc(),r=vn(),i=Qc(),o=ot(),a=v(),c=e.RangeError,l=e.Int8Array,u=l&&l.prototype,h=u&&u.set,d=n.aTypedArray,f=n.exportTypedArrayMethod,m=!a(function(){var e=new Uint8ClampedArray(2);return t(h,e,{length:1,0:3},1),3!==e[1]}),g=m&&n.NATIVE_ARRAY_BUFFER_VIEWS&&a(function(){var e=new l(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]});f("set",function(e){d(this);var n=i(arguments.length>1?arguments[1]:void 0,1),a=o(e);if(m)return t(h,this,a,n);var s=this.length,l=r(a),u=0;if(l+n>s)throw new c("Wrong length");for(;u0&&1/n<0?1:-1:t>n}}(e))},!p||g)}();var _l,bl,wl,El={};function xl(){if(bl)return _l;bl=1;var e=vn();return _l=function(t,n){for(var r=e(t),i=new n(r),o=0;o=s||l<0)throw new n("Incorrect index");for(var u=new i(s),h=0;h=t.length)return e.target=null,a(void 0,!0);switch(e.kind){case"keys":return a(n,!1);case"values":return a(t[n],!1)}return a([n,t[n]],!1)},"values");var d=n.Arguments=n.Array;if(t("keys"),t("values"),t("entries"),!s&&c&&"values"!==d.name)try{i(d,"name",{value:"values"})}catch(e){}return jl}!function(){if(zl)return Hl;zl=1;var e=s(),t=Ml?Pl:(Ml=1,Pl={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}),n=function(){if(Bl)return Ll;Bl=1;var e=ht()("span").classList,t=e&&e.constructor&&e.constructor.prototype;return Ll=t===Object.prototype?void 0:t}(),r=Yl(),i=St(),o=Po(),a=ct()("iterator"),c=r.values,l=function(e,n){if(e){if(e[a]!==c)try{i(e,a,c)}catch(t){e[a]=c}if(o(e,n,!0),t[n])for(var s in r)if(e[s]!==r[s])try{i(e,s,r[s])}catch(t){e[s]=r[s]}}};for(var u in t)l(e[u]&&e[u].prototype,u);l(n,"DOMTokenList")}();var Vl,Xl,$l,Jl,Ql,Zl={};function Kl(){if(Xl)return Vl;Xl=1;var e=y(),t=v(),n=Et(),r=xr(),i=Error.prototype.toString,o=t(function(){if(e){var t=Object.create(Object.defineProperty({},"name",{get:function(){return this===t}}));if("true"!==i.call(t))return!0}return"2: 1"!==i.call({message:1,name:2})||"Error"!==i.call({})});return Vl=o?function(){var e=n(this),t=r(e.name,"Error"),i=r(e.message);return t?i?t+": "+i:t:i}:i}function eu(){return Jl?$l:(Jl=1,$l={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}})}!function(){if(Ql)return Zl;Ql=1;var e=mr(),t=Ae(),n=ca(),r=v(),i=ji(),o=ue(),a=xt().f,s=Xt(),c=xo(),l=at(),u=Co(),h=Et(),d=Kl(),f=xr(),m=eu(),g=Cr(),p=Yt(),A=y(),_=tt(),b="DOMException",w="DATA_CLONE_ERR",E=t("Error"),x=t(b)||function(){try{(new(t("MessageChannel")||n("worker_threads").MessageChannel)).port1.postMessage(new WeakMap)}catch(e){if(e.name===w&&25===e.code)return e.constructor}}(),S=x&&x.prototype,C=E.prototype,I=p.set,T=p.getterFor(b),R="stack"in new E(b),k=function(e){return l(m,e)&&m[e].m?m[e].c:0},O=function(){u(this,P);var e=arguments.length,t=f(e<1?void 0:arguments[0]),n=f(e<2?void 0:arguments[1],"Error"),r=k(n);if(I(this,{type:b,name:n,message:t,code:r}),A||(this.name=n,this.message=t,this.code=r),R){var i=new E(t);i.name=b,a(this,"stack",o(1,g(i.stack,1)))}},P=O.prototype=i(C),M=function(e){return{enumerable:!0,configurable:!0,get:e}},L=function(e){return M(function(){return T(this)[e]})};A&&(c(P,"code",L("code")),c(P,"message",L("message")),c(P,"name",L("name"))),a(P,"constructor",o(1,O));var B=r(function(){return!(new x instanceof E)}),D=B||r(function(){return C.toString!==d||"2: 1"!==String(new x(1,2))}),U=B||r(function(){return 25!==new x(1,"DataCloneError").code}),F=B||25!==x[w]||25!==S[w],N=_?D||U||F:B;e({global:!0,constructor:!0,forced:N},{DOMException:N?O:x});var j=t(b),W=j.prototype;for(var z in D&&(_||x===j)&&s(W,"toString",d),U&&A&&x===j&&c(W,"code",M(function(){return k(h(this).name)})),m)if(l(m,z)){var H=m[z],G=H.s,q=o(6,H.c);l(j,G)||a(j,G,q),l(W,G)||a(W,G,q)}}();var tu,nu={};!function(){if(tu)return nu;tu=1;var e=mr(),t=s(),n=Ae(),r=ue(),i=xt().f,o=at(),a=Co(),c=br(),l=xr(),u=eu(),h=Cr(),d=y(),f=tt(),m="DOMException",g=n("Error"),p=n(m),v=function(){a(this,A);var e=arguments.length,t=l(e<1?void 0:arguments[0]),n=l(e<2?void 0:arguments[1],"Error"),o=new p(t,n),s=new g(t);return s.name=m,i(o,"stack",r(1,h(s.stack,1))),c(o,this,v),o},A=v.prototype=p.prototype,_="stack"in new g(m),b="stack"in new p(1,2),w=p&&d&&Object.getOwnPropertyDescriptor(t,m),E=!(!w||w.writable&&w.configurable),x=_&&!E&&!b;e({global:!0,constructor:!0,forced:f||x},{DOMException:x?v:p});var S=n(m),C=S.prototype;if(C.constructor!==S)for(var I in f||i(C,"constructor",r(1,S)),u)if(o(u,I)){var T=u[I],R=T.s;o(S,R)||i(S,R,r(6,T.c))}}();var ru,iu={};!function(){if(ru)return iu;ru=1;var e=Ae(),t="DOMException";Po()(e(t),t)}();var ou,au={};!function(){if(ou)return au;ou=1;var e=mr(),t=s(),n=xo(),r=y(),i=TypeError,o=Object.defineProperty,a=t.self!==t;try{if(r){var c=Object.getOwnPropertyDescriptor(t,"self");!a&&c&&c.get&&c.enumerable||n(t,"self",{get:function(){return t},set:function(e){if(this!==t)throw new i("Illegal invocation");o(t,"self",{value:e,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}else e({global:!0,simple:!0,forced:a},{self:t})}catch(e){}}();var su,cu,lu,uu,hu,du,fu,mu,gu,pu,vu,yu={},Au={};function _u(){if(lu)return cu;lu=1;var e=v(),t=ct(),n=y(),r=tt(),i=t("iterator");return cu=!e(function(){var e=new URL("b?a=1&b=2&c=3","https://a"),t=e.searchParams,o=new URLSearchParams("a=1&a=2&b=3"),a="";return e.pathname="c%20d",t.forEach(function(e,n){t.delete("b"),a+=n+e}),o.delete("a",2),o.delete("b",void 0),r&&(!e.toJSON||!o.has("a",1)||o.has("a",2)||!o.has("a",void 0)||o.has("b"))||!t.size&&(r||!n)||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[i]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==a||"x"!==new URL("https://x",void 0).host})}function bu(){if(fu)return du;fu=1;var e=Jr(),t=_(),n=ot(),r=qa(),i=ss(),o=Qr(),a=vn(),s=_a(),c=ls(),l=cs(),u=Array;return du=function(h){var d=n(h),f=o(this),m=arguments.length,g=m>1?arguments[1]:void 0,p=void 0!==g;p&&(g=e(g,m>2?arguments[2]:void 0));var v,y,A,_,b,w,E=l(d),x=0;if(!E||this===u&&i(E))for(v=a(d),y=f?new this(v):u(v);v>x;x++)w=p?g(d[x],x):d[x],s(y,x,w);else for(y=f?new this:[],b=(_=c(d,E)).next;!(A=t(b,_)).done;x++)w=p?r(_,g,[A.value,x],!0):A.value,s(y,x,w);return y.length=x,y},du}function wu(){if(gu)return mu;gu=1;var e=he(),t=2147483647,n=/[^\0-\u007E]/,r=/[.\u3002\uFF0E\uFF61]/g,i="Overflow: input needs wider integers to process",o=RangeError,a=e(r.exec),s=Math.floor,c=String.fromCharCode,l=e("".charCodeAt),u=e([].join),h=e([].push),d=e("".replace),f=e("".split),m=e("".toLowerCase),g=function(e){return e+22+75*(e<26)},p=function(e,t,n){var r=0;for(e=n?s(e/700):e>>1,e+=s(e/t);e>455;)e=s(e/35),r+=36;return s(r+36*e/(e+38))},v=function(e){var n=[];e=function(e){for(var t=[],n=0,r=e.length;n=55296&&i<=56319&&n=f&&a<_&&(_=a);var b=A+1;if(_-f>s((t-m)/b))throw new o(i);for(m+=(_-f)*b,f=_,r=0;rt)throw new o(i);if(a===f){for(var w=m,E=36;;){var x=E<=v?1:E>=v+26?26:E-v;if(wc;){if(t=+arguments[c++],n(t,1114111)!==t)throw new r(t+" is not a valid code point");o[c]=t<65536?i(t):i(55296+((t-=65536)>>10),t%1024+56320)}return a(o,"")}})}();var e=mr(),t=s(),n=Pu(),r=Ae(),i=_(),o=he(),a=y(),c=_u(),l=Xt(),u=xo(),h=So(),d=Po(),f=Gl(),m=Yt(),g=Co(),p=ve(),v=at(),A=Jr(),b=wr(),w=Et(),E=ye(),x=Er(),S=ji(),C=ue(),I=ls(),T=cs(),R=Wa(),k=Eu(),O=ct(),P=wi(),M=O("iterator"),L="URLSearchParams",B=L+"Iterator",D=m.set,U=m.getterFor(L),F=m.getterFor(B),N=n("fetch"),j=n("Request"),W=n("Headers"),z=j&&j.prototype,H=W&&W.prototype,G=t.TypeError,q=t.encodeURIComponent,Y=String.fromCharCode,V=r("String","fromCodePoint"),X=parseInt,$=o("".charAt),J=o([].join),Q=o([].push),Z=o("".replace),K=o([].shift),ee=o([].splice),te=o("".split),ne=o("".slice),re=o(/./.exec),ie=/\+/g,oe=/^[0-9a-f]+$/i,ae=function(e,t){var n=ne(e,t,t+2);return re(oe,n)?X(n,16):NaN},se=function(e){for(var t=0,n=128;n>0&&0!==(e&n);n>>=1)t++;return t},ce=function(e){var t=null;switch(e.length){case 1:t=e[0];break;case 2:t=(31&e[0])<<6|63&e[1];break;case 3:t=(15&e[0])<<12|(63&e[1])<<6|63&e[2];break;case 4:t=(7&e[0])<<18|(63&e[1])<<12|(63&e[2])<<6|63&e[3]}return t>1114111?null:t},le=function(e){for(var t=(e=Z(e,ie," ")).length,n="",r=0;rt){n+="%",r++;continue}var o=ae(e,r+1);if(o!=o){n+=i,r++;continue}r+=2;var a=se(o);if(0===a)i=Y(o);else{if(1===a||a>4){n+="�",r++;continue}for(var s=[o],c=1;ct||"%"!==$(e,r));){var l=ae(e,r+1);if(l!=l){r+=3;break}if(l>191||l<128)break;Q(s,l),r+=2,c++}if(s.length!==a){n+="�";continue}var u=ce(s);null===u?n+="�":i=V(u)}}n+=i,r++}return n},de=/[!'()~]|%20/g,fe={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},me=function(e){return fe[e]},ge=function(e){return Z(q(e),de,me)},pe=f(function(e,t){D(this,{type:B,target:U(e).entries,index:0,kind:t})},L,function(){var e=F(this),t=e.target,n=e.index++;if(!t||n>=t.length)return e.target=null,R(void 0,!0);var r=t[n];switch(e.kind){case"keys":return R(r.key,!1);case"values":return R(r.value,!1)}return R([r.key,r.value],!1)},!0),_e=function(e){this.entries=[],this.url=null,void 0!==e&&(E(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===$(e,0)?ne(e,1):e:x(e)))};_e.prototype={type:L,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,r,o,a,s,c,l=this.entries,u=T(e);if(u)for(n=(t=I(e,u)).next;!(r=i(n,t)).done;){if(a=(o=I(w(r.value))).next,(s=i(a,o)).done||(c=i(a,o)).done||!i(a,o).done)throw new G("Expected sequence with length 2");Q(l,{key:x(s.value),value:x(c.value)})}else for(var h in e)v(e,h)&&Q(l,{key:h,value:x(e[h])})},parseQuery:function(e){if(e)for(var t,n,r=this.entries,i=te(e,"&"),o=0;o0?arguments[0]:void 0));a||(this.size=e.entries.length)},we=be.prototype;if(h(we,{append:function(e,t){var n=U(this);k(arguments.length,2),Q(n.entries,{key:x(e),value:x(t)}),a||this.length++,n.updateURL()},delete:function(e){for(var t=U(this),n=k(arguments.length,1),r=t.entries,i=x(e),o=n<2?void 0:arguments[1],s=void 0===o?o:x(o),c=0;ct.key?1:-1}),e.updateURL()},forEach:function(e){for(var t,n=U(this).entries,r=A(e,arguments.length>1?arguments[1]:void 0),i=0;i1?Se(arguments[1]):{})}}),p(j)){var Ce=function(e){return g(this,z),new j(e,arguments.length>1?Se(arguments[1]):{})};z.constructor=Ce,Ce.prototype=z,e({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Ce})}}return Iu={URLSearchParams:be,getState:U}}function Lu(){if(Ru)return yu;Ru=1,function(){if(su)return Au;su=1;var e=ac().charAt,t=Er(),n=Yt(),r=ql(),i=Wa(),o="String Iterator",a=n.set,s=n.getterFor(o);r(String,"String",function(e){a(this,{type:o,string:t(e),index:0})},function(){var t,n=s(this),r=n.string,o=n.index;return o>=r.length?i(void 0,!0):(t=e(r,o),n.index+=t.length,i(t,!1))})}();var e,t=mr(),n=y(),r=_u(),i=s(),o=Jr(),a=he(),c=Xt(),l=xo(),u=Co(),h=at(),d=function(){if(hu)return uu;hu=1;var e=y(),t=he(),n=_(),r=v(),i=Fi(),o=ur(),a=le(),s=ot(),c=fe(),l=Object.assign,u=Object.defineProperty,h=t([].concat);return uu=!l||r(function(){if(e&&1!==l({b:1},l(u({},"a",{enumerable:!0,get:function(){u(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var t={},n={},r=Symbol("assign detection"),o="abcdefghijklmnopqrst";return t[r]=7,o.split("").forEach(function(e){n[e]=e}),7!==l({},t)[r]||i(l({},n)).join("")!==o})?function(t,r){for(var l=s(t),u=arguments.length,d=1,f=o.f,m=a.f;u>d;)for(var g,p=c(arguments[d++]),v=f?h(i(p),f(p)):i(p),y=v.length,A=0;y>A;)g=v[A++],e&&!n(m,p,g)||(l[g]=p[g]);return l}:l,uu}(),f=bu(),m=bi(),g=ac().codeAt,p=wu(),A=Er(),b=Po(),w=Eu(),E=Mu(),x=Yt(),S=x.set,C=x.getterFor("URL"),I=E.URLSearchParams,T=E.getState,R=i.URL,k=i.TypeError,O=i.parseInt,P=Math.floor,M=Math.pow,L=a("".charAt),B=a(/./.exec),D=a([].join),U=a(1.1.toString),F=a([].pop),N=a([].push),j=a("".replace),W=a([].shift),z=a("".split),H=a("".slice),G=a("".toLowerCase),q=a([].unshift),Y="Invalid scheme",V="Invalid host",X="Invalid port",$=/[a-z]/i,J=/[\d+-.a-z]/i,Q=/\d/,Z=/^0x/i,K=/^[0-7]+$/,ee=/^\d+$/,te=/^[\da-f]+$/i,ne=/[\0\t\n\r #%/:<>?@[\\\]^|]/,re=/[\0\t\n\r #/:<>?@[\\\]^|]/,ie=/^[\u0000-\u0020]+/,oe=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,ae=/[\t\n\r]/g,se=function(e){var t,n,r,i;if("number"==typeof e){for(t=[],n=0;n<4;n++)q(t,e%256),e=P(e/256);return D(t,".")}if("object"==typeof e){for(t="",r=function(e){for(var t=null,n=1,r=null,i=0,o=0;o<8;o++)0!==e[o]?(i>n&&(t=r,n=i),r=null,i=0):(null===r&&(r=o),++i);return i>n?r:t}(e),n=0;n<8;n++)i&&0===e[n]||(i&&(i=!1),r===n?(t+=n?":":"::",i=!0):(t+=U(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},ce={},ue=d({},ce,{" ":1,'"':1,"<":1,">":1,"`":1}),de=d({},ue,{"#":1,"?":1,"{":1,"}":1}),me=d({},de,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),ge=function(e,t){var n=g(e,0);return n>32&&n<127&&!h(t,e)?e:encodeURIComponent(e)},pe={ftp:21,file:null,http:80,https:443,ws:80,wss:443},ve=function(e,t){var n;return 2===e.length&&B($,L(e,0))&&(":"===(n=L(e,1))||!t&&"|"===n)},ye=function(e){var t;return e.length>1&&ve(H(e,0,2))&&(2===e.length||"/"===(t=L(e,2))||"\\"===t||"?"===t||"#"===t)},Ae=function(e){return"."===e||"%2e"===G(e)},_e=function(e){return".."===(e=G(e))||"%2e."===e||".%2e"===e||"%2e%2e"===e},be={},we={},Ee={},xe={},Se={},Ce={},Ie={},Te={},Re={},ke={},Oe={},Pe={},Me={},Le={},Be={},De={},Ue={},Fe={},Ne={},je={},We={},ze=function(e,t,n){var r,i,o,a=A(e);if(t){if(i=this.parse(a))throw new k(i);this.searchParams=null}else{if(void 0!==n&&(r=new ze(n,!0)),i=this.parse(a,null,r))throw new k(i);(o=T(new I)).bindURL(this),this.searchParams=o}};ze.prototype={type:"URL",parse:function(t,n,r){var i,o,a,s,c=this,l=n||be,u=0,d="",g=!1,p=!1,v=!1;for(t=A(t),n||(c.scheme="",c.username="",c.password="",c.host=null,c.port=null,c.path=[],c.query=null,c.fragment=null,c.cannotBeABaseURL=!1,t=j(t,ie,""),t=j(t,oe,"$1")),t=j(t,ae,""),i=f(t);u<=i.length;){switch(o=i[u],l){case be:if(!o||!B($,o)){if(n)return Y;l=Ee;continue}d+=G(o),l=we;break;case we:if(o&&(B(J,o)||"+"===o||"-"===o||"."===o))d+=G(o);else{if(":"!==o){if(n)return Y;d="",l=Ee,u=0;continue}if(n&&(c.isSpecial()!==h(pe,d)||"file"===d&&(c.includesCredentials()||null!==c.port)||"file"===c.scheme&&!c.host))return;if(c.scheme=d,n)return void(c.isSpecial()&&pe[c.scheme]===c.port&&(c.port=null));d="","file"===c.scheme?l=Le:c.isSpecial()&&r&&r.scheme===c.scheme?l=xe:c.isSpecial()?l=Te:"/"===i[u+1]?(l=Se,u++):(c.cannotBeABaseURL=!0,N(c.path,""),l=Ne)}break;case Ee:if(!r||r.cannotBeABaseURL&&"#"!==o)return Y;if(r.cannotBeABaseURL&&"#"===o){c.scheme=r.scheme,c.path=m(r.path),c.query=r.query,c.fragment="",c.cannotBeABaseURL=!0,l=We;break}l="file"===r.scheme?Le:Ce;continue;case xe:if("/"!==o||"/"!==i[u+1]){l=Ce;continue}l=Re,u++;break;case Se:if("/"===o){l=ke;break}l=Fe;continue;case Ce:if(c.scheme=r.scheme,o===e)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=m(r.path),c.query=r.query;else if("/"===o||"\\"===o&&c.isSpecial())l=Ie;else if("?"===o)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=m(r.path),c.query="",l=je;else{if("#"!==o){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=m(r.path),c.path.length--,l=Fe;continue}c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=m(r.path),c.query=r.query,c.fragment="",l=We}break;case Ie:if(!c.isSpecial()||"/"!==o&&"\\"!==o){if("/"!==o){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,l=Fe;continue}l=ke}else l=Re;break;case Te:if(l=Re,"/"!==o||"/"!==L(d,u+1))continue;u++;break;case Re:if("/"!==o&&"\\"!==o){l=ke;continue}break;case ke:if("@"===o){g&&(d="%40"+d),g=!0,a=f(d);for(var y=0;y65535)return X;c.port=c.isSpecial()&&w===pe[c.scheme]?null:w,d=""}if(n)return;l=Ue;continue}return X}d+=o;break;case Le:if(c.scheme="file","/"===o||"\\"===o)l=Be;else{if(!r||"file"!==r.scheme){l=Fe;continue}switch(o){case e:c.host=r.host,c.path=m(r.path),c.query=r.query;break;case"?":c.host=r.host,c.path=m(r.path),c.query="",l=je;break;case"#":c.host=r.host,c.path=m(r.path),c.query=r.query,c.fragment="",l=We;break;default:ye(D(m(i,u),""))||(c.host=r.host,c.path=m(r.path),c.shortenPath()),l=Fe;continue}}break;case Be:if("/"===o||"\\"===o){l=De;break}r&&"file"===r.scheme&&!ye(D(m(i,u),""))&&(ve(r.path[0],!0)?N(c.path,r.path[0]):c.host=r.host),l=Fe;continue;case De:if(o===e||"/"===o||"\\"===o||"?"===o||"#"===o){if(!n&&ve(d))l=Fe;else if(""===d){if(c.host="",n)return;l=Ue}else{if(s=c.parseHost(d))return s;if("localhost"===c.host&&(c.host=""),n)return;d="",l=Ue}continue}d+=o;break;case Ue:if(c.isSpecial()){if(l=Fe,"/"!==o&&"\\"!==o)continue}else if(n||"?"!==o)if(n||"#"!==o){if(o!==e&&(l=Fe,"/"!==o))continue}else c.fragment="",l=We;else c.query="",l=je;break;case Fe:if(o===e||"/"===o||"\\"===o&&c.isSpecial()||!n&&("?"===o||"#"===o)){if(_e(d)?(c.shortenPath(),"/"===o||"\\"===o&&c.isSpecial()||N(c.path,"")):Ae(d)?"/"===o||"\\"===o&&c.isSpecial()||N(c.path,""):("file"===c.scheme&&!c.path.length&&ve(d)&&(c.host&&(c.host=""),d=L(d,0)+":"),N(c.path,d)),d="","file"===c.scheme&&(o===e||"?"===o||"#"===o))for(;c.path.length>1&&""===c.path[0];)W(c.path);"?"===o?(c.query="",l=je):"#"===o&&(c.fragment="",l=We)}else d+=ge(o,de);break;case Ne:"?"===o?(c.query="",l=je):"#"===o?(c.fragment="",l=We):o!==e&&(c.path[0]+=ge(o,ce));break;case je:n||"#"!==o?o!==e&&("'"===o&&c.isSpecial()?c.query+="%27":c.query+="#"===o?"%23":ge(o,ce)):(c.fragment="",l=We);break;case We:o!==e&&(c.fragment+=ge(o,ue))}u++}},parseHost:function(e){var t,n,r;if("["===L(e,0)){if("]"!==L(e,e.length-1))return V;if(t=function(e){var t,n,r,i,o,a,s,c=[0,0,0,0,0,0,0,0],l=0,u=null,h=0,d=function(){return L(e,h)};if(":"===d()){if(":"!==L(e,1))return;h+=2,u=++l}for(;d();){if(8===l)return;if(":"!==d()){for(t=n=0;n<4&&B(te,d());)t=16*t+O(d(),16),h++,n++;if("."===d()){if(0===n)return;if(h-=n,l>6)return;for(r=0;d();){if(i=null,r>0){if(!("."===d()&&r<4))return;h++}if(!B(Q,d()))return;for(;B(Q,d());){if(o=O(d(),10),null===i)i=o;else{if(0===i)return;i=10*i+o}if(i>255)return;h++}c[l]=256*c[l]+i,2!==++r&&4!==r||l++}if(4!==r)return;break}if(":"===d()){if(h++,!d())return}else if(d())return;c[l++]=t}else{if(null!==u)return;h++,u=++l}}if(null!==u)for(a=l-u,l=7;0!==l&&a>0;)s=c[l],c[l--]=c[u+a-1],c[u+--a]=s;else if(8!==l)return;return c}(H(e,1,-1)),!t)return V;this.host=t}else if(this.isSpecial()){if(e=p(e),B(ne,e))return V;if(t=function(e){var t,n,r,i,o,a,s,c=z(e,".");if(c.length&&""===c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(n=[],r=0;r1&&"0"===L(i,0)&&(o=B(Z,i)?16:8,i=H(i,8===o?1:2)),""===i)a=0;else{if(!B(10===o?ee:8===o?K:te,i))return e;a=O(i,o)}N(n,a)}for(r=0;r=M(256,5-t))return null}else if(a>255)return null;for(s=F(n),r=0;r1?arguments[1]:void 0,i=S(t,new ze(e,!1,r));n||(t.href=i.serialize(),t.origin=i.getOrigin(),t.protocol=i.getProtocol(),t.username=i.getUsername(),t.password=i.getPassword(),t.host=i.getHost(),t.hostname=i.getHostname(),t.port=i.getPort(),t.pathname=i.getPathname(),t.search=i.getSearch(),t.searchParams=i.getSearchParams(),t.hash=i.getHash())},Ge=He.prototype,qe=function(e,t){return{get:function(){return C(this)[e]()},set:t&&function(e){return C(this)[t](e)},configurable:!0,enumerable:!0}};if(n&&(l(Ge,"href",qe("serialize","setHref")),l(Ge,"origin",qe("getOrigin")),l(Ge,"protocol",qe("getProtocol","setProtocol")),l(Ge,"username",qe("getUsername","setUsername")),l(Ge,"password",qe("getPassword","setPassword")),l(Ge,"host",qe("getHost","setHost")),l(Ge,"hostname",qe("getHostname","setHostname")),l(Ge,"port",qe("getPort","setPort")),l(Ge,"pathname",qe("getPathname","setPathname")),l(Ge,"search",qe("getSearch","setSearch")),l(Ge,"searchParams",qe("getSearchParams")),l(Ge,"hash",qe("getHash","setHash"))),c(Ge,"toJSON",function(){return C(this).serialize()},{enumerable:!0}),c(Ge,"toString",function(){return C(this).serialize()},{enumerable:!0}),R){var Ye=R.createObjectURL,Ve=R.revokeObjectURL;Ye&&c(He,"createObjectURL",o(Ye,R)),Ve&&c(He,"revokeObjectURL",o(Ve,R))}return b(He,"URL"),t({global:!0,constructor:!0,forced:!r,sham:!n},{URL:He}),yu}ku||(ku=1,Lu());var Bu,Du={};!function(){if(Bu)return Du;Bu=1;var e=mr(),t=_();e({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return t(URL.prototype.toString,this)}})}();var Uu;Uu||(Uu=1,Mu());var Fu,Nu={};!function(){if(Fu)return Nu;Fu=1;var e=Xt(),t=he(),n=Er(),r=Eu(),i=URLSearchParams,o=i.prototype,a=t(o.append),s=t(o.delete),c=t(o.forEach),l=t([].push),u=new i("a=1&a=2&b=3");u.delete("a",1),u.delete("b",void 0),u+""!="a=2"&&e(o,"delete",function(e){var t=arguments.length,i=t<2?void 0:arguments[1];if(t&&void 0===i)return s(this,e);var o=[];c(this,function(e,t){l(o,{key:t,value:e})}),r(t,1);for(var u,h=n(e),d=n(i),f=0,m=0,g=!1,p=o.length;f=n;){const e=nh.keys().next().value;nh.delete(e)}nh.set(e,t)}}const ih={};let oh=null,ah=null,sh=null,ch=null,lh=null,uh=null,hh=null;function dh(e){return e&&"object"==typeof e&&!Array.isArray(e)}function fh(e){const t=[];return JSON.stringify(e,function(e,n){if("object"==typeof n&&null!==n){if(-1!==t.indexOf(n))return;t.push(n)}return n})}const mh={messages:[],logLevelConsole:"warning",logLevelSystem:"error",systemTargetLogLevel:"",addMessage:function(e,t){if(!Xu.debug)return;const n={level:e,date:(new Date).toISOString(),text:"",objs:[],stack:""},r=new Error;r.stack&&(n.stack=r.stack.toString().replace(/^Error\r?\n/,""));for(let e=0;e1e3&&mh.messages.shift()},systemLog(e,t){ah&&ah.hass&&ah.hass.callService("system_log","write",{logger:"frontend.wallpanel".concat(ch?"."+ch:""),message:t,level:mh.systemTargetLogLevel||e},void 0,!1).catch(()=>{})},downloadMessages:function(){const e=new Blob([fh(mh.messages)],{type:"text/plain"}),t=URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.target="_blank",n.download="wallpanel_log.txt",document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(t),0)},purgeMessages:function(){mh.messages=[]},debug:function(){["debug"].includes(mh.logLevelConsole)&&console.debug.apply(this,arguments),["debug"].includes(mh.logLevelSystem)&&mh.systemLog("debug",fh(arguments)),mh.addMessage("debug",arguments)},info:function(){["debug","info"].includes(mh.logLevelConsole)&&console.info.apply(this,arguments),["debug","info"].includes(mh.logLevelSystem)&&mh.systemLog("info",fh(arguments)),mh.addMessage("info",arguments)},log:function(){mh.info.apply(this,arguments)},warning:function(){["debug","info","warning"].includes(mh.logLevelConsole)&&console.warn.apply(this,arguments),["debug","info","warning"].includes(mh.logLevelSystem)&&mh.systemLog("warning",fh(arguments)),mh.addMessage("warning",arguments)},warn:function(){mh.warning.apply(this,arguments)},error:function(){if(["debug","info","warning","error"].includes(mh.logLevelConsole)&&console.error.apply(this,arguments),["debug","info","warning","error"].includes(mh.logLevelSystem)&&mh.systemLog("error",fh(arguments)),mh.addMessage("error",arguments),Xu.alert_errors){const e="Wallpanel error: ".concat(fh(arguments));Ku?Ku.showMessage("error","Error",e,1e4):alert(e)}},err:function(){mh.error.apply(this,arguments)}};class gh{constructor(){this.enabled=!1,this.error=null,this.nativeWakeLockSupported="wakeLock"in navigator,this._lock=null,this._player=null,this._isPlaying=!1,this._onWakeLockRelease=null;const e=()=>{mh.debug("handleVisibilityChange"),this.enabled&&!document.hidden&&this.enable()};if(document.addEventListener("visibilitychange",e),document.addEventListener("fullscreenchange",e),!this.nativeWakeLockSupported){const e="data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAA1NtZGF0AAACrwYF//+r3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE2NCByMzA5NSBiYWVlNDAwIC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMjAyMiAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG9wdGlvbnM6IGNhYmFjPTEgcmVmPTMgZGVibG9jaz0xOi0zOi0zIGFuYWx5c2U9MHgzOjB4MTEzIG1lPWhleCBzdWJtZT03IHBzeT0xIHBzeV9yZD0yLjAwOjAuNzAgbWl4ZWRfcmVmPTEgbWVfcmFuZ2U9MTYgY2hyb21hX21lPTEgdHJlbGxpcz0xIDh4OGRjdD0xIGNxbT0wIGRlYWR6b25lPTIxLDExIGZhc3RfcHNraXA9MSBjaHJvbWFfcXBfb2Zmc2V0PS00IHRocmVhZHM9MSBsb29rYWhlYWRfdGhyZWFkcz0xIHNsaWNlZF90aHJlYWRzPTAgbnI9MCBkZWNpbWF0ZT0xIGludGVybGFjZWQ9MCBibHVyYXlfY29tcGF0PTAgY29uc3RyYWluZWRfaW50cmE9MCBiZnJhbWVzPTMgYl9weXJhbWlkPTIgYl9hZGFwdD0xIGJfYmlhcz0wIGRpcmVjdD0xIHdlaWdodGI9MSBvcGVuX2dvcD0wIHdlaWdodHA9MiBrZXlpbnQ9MjUwIGtleWludF9taW49MSBzY2VuZWN1dD00MCBpbnRyYV9yZWZyZXNoPTAgcmNfbG9va2FoZWFkPTQwIHJjPWNyZiBtYnRyZWU9MSBjcmY9MjMuMCBxY29tcD0wLjYwIHFwbWluPTAgcXBtYXg9NjkgcXBzdGVwPTQgaXBfcmF0aW89MS40MCBhcT0xOjEuMjAAgAAAABFliIQAF85//vfUt8yy7VNwgQAAAAlBmiRsQXzn/vAAAAAJQZ5CeIL5z4aBAAAACQGeYXRBfOeGgAAAAAkBnmNqQXznhoEAAAAPQZpoSahBaJlMCC+c//7xAAAAC0GehkURLBfOf4aBAAAACQGepXRBfOeGgQAAAAkBnqdqQXznhoAAAAAPQZqpSahBbJlMCC+c//7wAAADs21vb3YAAABsbXZoZAAAAAAAAAAAAAAAAAAAA+gAACcQAAEAAAEAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAALddHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAQAAAAAAACcQAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAIAAAACAAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAAnEAAAgAAAAQAAAAACVW1kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAAQAAAAoAAVcQAAAAAAC1oZGxyAAAAAAAAAAB2aWRlAAAAAAAAAAAAAAAAVmlkZW9IYW5kbGVyAAAAAgBtaW5mAAAAFHZtaGQAAAABAAAAAAAAAAAAAAAkZGluZgAAABxkcmVmAAAAAAAAAAEAAAAMdXJsIAAAAAEAAAHAc3RibAAAAMBzdHNkAAAAAAAAAAEAAACwYXZjMQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAIAAgASAAAAEgAAAAAAAAAARVMYXZjNTkuMzcuMTAwIGxpYngyNjQAAAAAAAAAAAAAABj//wAAADZhdmNDAWQACv/hABlnZAAKrNlfllwEQAAAAwBAAAADAIPEiWWAAQAGaOvjxMhM/fj4AAAAABBwYXNwAAAAAQAAAAEAAAAUYnRydAAAAAAAAAKiAAACogAAABhzdHRzAAAAAAAAAAEAAAAKAABAAAAAABRzdHNzAAAAAAAAAAEAAAABAAAAYGN0dHMAAAAAAAAACgAAAAEAAIAAAAAAAQABQAAAAAABAACAAAAAAAEAAAAAAAAAAQAAQAAAAAABAAFAAAAAAAEAAIAAAAAAAQAAAAAAAAABAABAAAAAAAEAAIAAAAAAHHN0c2MAAAAAAAAAAQAAAAEAAAAKAAAAAQAAADxzdHN6AAAAAAAAAAAAAAAKAAACyAAAAA0AAAANAAAADQAAAA0AAAATAAAADwAAAA0AAAANAAAAEwAAABRzdGNvAAAAAAAAAAEAAAAwAAAAYnVkdGEAAABabWV0YQAAAAAAAAAhaGRscgAAAAAAAAAAbWRpcmFwcGwAAAAAAAAAAAAAAAAtaWxzdAAAACWpdG9vAAAAHWRhdGEAAAABAAAAAExhdmY1OS4yNy4xMDA=";this._player=document.createElement("video"),this._player.setAttribute("id","ScreenWakeLockVideo"),this._player.setAttribute("src",e),this._player.setAttribute("playsinline",""),this._player.setAttribute("muted",""),this._player.style.display="none",document.getElementById("ScreenWakeLockVideo")||document.body.appendChild(this._player),this._player.addEventListener("ended",()=>{mh.debug("Video ended"),this.enabled&&this.enable()}),this._player.addEventListener("playing",()=>{mh.debug("Video playing"),this._isPlaying=!0}),this._player.addEventListener("pause",()=>{mh.debug("Video pause"),this._isPlaying=!1})}}enable(){if(this.nativeWakeLockSupported){if(mh.debug("Requesting native screen wakelock"),this._lock)return void mh.debug("Screen wakelock already active");navigator.wakeLock.request("screen").then(e=>{mh.debug("Request screen wakelock successful"),this._lock=e,this._onWakeLockRelease=()=>{mh.debug("Screen wakelock released"),this.enabled=!1,this._lock=null},e.addEventListener("release",this._onWakeLockRelease),this.enabled=!0,this.error=null}).catch(e=>{this.enabled=!1,this.error=e,mh.warning("Failed to request screen wakeLock: ".concat(e))})}else{mh.debug("Starting video player"),!this._player.paused&&this._isPlaying&&this._player.pause();const e=this._player.play();e&&e.then(()=>{this.enabled=!0,this.error=null,mh.debug("Video play successful")}).catch(e=>{this.enabled=!1,this.error=e,mh.warning("Failed to play video: ".concat(e))})}}disable(){this.nativeWakeLockSupported?(mh.debug("Releasing native screen wakelock"),this._lock&&(this._onWakeLockRelease&&(this._lock.removeEventListener("release",this._onWakeLockRelease),this._onWakeLockRelease=null),this._lock.release()),this._lock=null):(mh.debug("Stopping video player"),!this._player.paused&&this._isPlaying&&this._player.pause()),this.enabled=!1}}class ph{constructor(){this.enabled=!1,this.error=!1,this.width=64,this.height=48,this.thresholdRatio=.05,this.threshold=this.width*this.height*this.thresholdRatio,this.captureInterval=300,this.motionActive=!1,this.motionStartDelay=0,this.motionStopDelay=2e3,this.motionDetectionRequiredRatio=.8,this.roomSettledRequiredRatio=1,this.motionStopTimeout=null,this.captureTimer=null,this.referenceImageData=null,this.previousImageData=null,this.referenceChangeRatios=[],this.previousChangeRatios=[],this.maxRatioHistorySize=Math.ceil(6e4/this.captureInterval),this.videoElement=document.createElement("video"),this.videoElement.setAttribute("id","wallpanelMotionDetectionVideo"),this.videoElement.style.display="none",document.body.appendChild(this.videoElement),this.canvasElement=document.createElement("canvas"),this.canvasElement.setAttribute("id","wallpanelMotionDetectionCanvas"),this.canvasElement.style.display="none",document.body.appendChild(this.canvasElement),this.context=this.canvasElement.getContext("2d",{willReadFrequently:!0}),this._elementsAppended=!0}compareImageData(e,t){if(!e||!t)return 0;let n=0;const r=e.data,i=t.data;for(let e=0;e=256&&n++}return n/(this.width*this.height)}storeRatio(e,t){for(e.push(t);e.length>this.maxRatioHistorySize;)e.shift()}getRatiosForInterval(e,t){const n=Math.max(1,Math.ceil(t/this.captureInterval));return e.length0&&e.filter(e=>e>=this.thresholdRatio).length/e.length>=t}hasRequiredRatioBelowThreshold(e,t){return e.length>0&&e.filter(e=>e=t}resetMotionState(){this.motionActive=!1,this.motionStopTimeout&&(clearTimeout(this.motionStopTimeout),this.motionStopTimeout=null),this.referenceImageData=null,this.previousImageData=null,this.referenceChangeRatios=[],this.previousChangeRatios=[]}capture(){this.context.globalCompositeOperation="source-over",this.context.drawImage(this.videoElement,0,0,this.width,this.height);const e=this.context.getImageData(0,0,this.width,this.height);if(!this.referenceImageData)return this.referenceImageData=e,void(this.previousImageData=e);const t=this.compareImageData(e,this.referenceImageData),n=this.compareImageData(e,this.previousImageData);this.previousImageData=e,this.storeRatio(this.referenceChangeRatios,t),this.storeRatio(this.previousChangeRatios,n);const r=this.getRatiosForInterval(this.referenceChangeRatios,this.motionStartDelay),i=this.hasRequiredRatioAboveThreshold(r,this.motionDetectionRequiredRatio),o=this.previousChangeRatios.length>=this.maxRatioHistorySize&&this.hasRequiredRatioBelowThreshold(this.previousChangeRatios,this.roomSettledRequiredRatio);i?(this.motionActive||(mh.debug("Motion started"),this.motionActive=!0,Ku.motionDetected()),this.motionStopTimeout&&(clearTimeout(this.motionStopTimeout),this.motionStopTimeout=null)):this.motionActive&&!this.motionStopTimeout&&(this.motionStopTimeout=setTimeout(()=>{mh.debug("Motion stopped"),this.motionActive=!1,this.motionStopTimeout=null,Ku.motionStopped()},this.motionStopDelay)),o&&(mh.info("Room settled, new reference image stored"),this.referenceImageData=e,this.referenceChangeRatios=[])}start(){if(!this.enabled&&!this.error){if(!navigator.mediaDevices)return this.error=!0,void mh.error("No media devices found");this._elementsAppended||(document.body.appendChild(this.videoElement),document.body.appendChild(this.canvasElement),this._elementsAppended=!0),this.enabled=!0,this.width=Xu.camera_motion_detection_capture_width,this.height=Xu.camera_motion_detection_capture_height,this.thresholdRatio=.01*Xu.camera_motion_detection_threshold,this.threshold=this.width*this.height*this.thresholdRatio,this.captureInterval=1e3*Xu.camera_motion_detection_capture_interval,this.motionStartDelay=1e3*Xu.camera_motion_detection_motion_start_delay,this.motionStopDelay=1e3*Xu.camera_motion_detection_motion_stop_delay,this.maxRatioHistorySize=Math.ceil(6e4/this.captureInterval),this.resetMotionState(),this.videoElement.width=this.width,this.videoElement.height=this.height,this.canvasElement.width=this.width,this.canvasElement.height=this.height,Xu.camera_motion_detection_capture_visible?(this.canvasElement.style.position="fixed",this.canvasElement.style.top=0,this.canvasElement.style.left=0,this.canvasElement.style.zIndex=1e4,this.canvasElement.style.border="1px solid black",this.canvasElement.style.display="block"):this.canvasElement.style.display="none",navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:{ideal:Xu.camera_motion_detection_facing_mode},width:this.width,height:this.height}}).then(e=>{this.videoElement.srcObject=e;const t=this.videoElement.play();t&&t.catch(e=>{mh.warning("Camera motion detection video play failed: ".concat(e))}),this.enabled&&(this.captureTimer=setInterval(this.capture.bind(this),this.captureInterval))}).catch(e=>{this.enabled=!1,mh.error("Camera motion detection error:",e),this._elementsAppended&&(this.videoElement.remove(),this.canvasElement.remove(),this._elementsAppended=!1)})}}stop(){if(!this.enabled)return;this.enabled=!1,this.resetMotionState(),this.captureTimer&&(clearInterval(this.captureTimer),this.captureTimer=null),this.videoElement.pause();const e=this.videoElement.srcObject;e&&"function"==typeof e.getTracks&&e.getTracks().forEach(e=>{e.stop()}),this.videoElement.srcObject=null,this._elementsAppended&&(this.videoElement.remove(),this.canvasElement.remove(),this._elementsAppended=!1)}}const vh=1592614637;function yh(e){return function(){e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function Ah(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Math.random;const n=e.slice();for(let e=n.length-1;e>0;e--){const r=Math.floor(t()*(e+1));[n[e],n[r]]=[n[r],n[e]]}return n}function _h(e){if(!e.shadowRoot)return[null,null];const t=e.shadowRoot.querySelector("ha-web-rtc-player")||e.shadowRoot.querySelector("ha-hls-player");if(!t||!t.shadowRoot)return[t,null];const n=t.shadowRoot.querySelector("video");return[t,n]}function bh(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;rc(e)):dh(t)&&(t=Object.fromEntries(Object.entries(t).map(e=>{let[t,n]=e;return[t,c(n)]}))),"boolean"==typeof e[o]&&(t=null!=t&&["true","on","yes","1"].includes(String(t).toLowerCase())),t}a=c(a),Array.isArray(e[o])&&"string"==typeof a&&(a=a.split(",").map(e=>e.trim())),Object.assign(e,{[o]:a})}}return bh(e,...n)}function wh(){const e=new URLSearchParams(window.location.search),t=Xu;Xu={},bh(Xu,qu),0===Object.keys(Vu).length&&(Vu=Th(),0===Object.keys(Vu).length&&mh.debug("No wallpanel config found in dashboard config")),bh(Xu,Vu);const n={};for(let[t,r]of e)if(t.startsWith("wp_")&&(t=t.substring(3),Yu[t]&&(mh.warn("The configuration option '".concat(t,"' has been renamed to '").concat(Yu[t],"'. Please update your wallpanel configuration accordingly.")),t=Yu[t]),t in qu&&r)){try{r=JSON.parse(r)}catch(e){}const e=qu[t];if(Array.isArray(e))Array.isArray(r)?n[t]=r:n[t]="string"==typeof r?r.split(",").map(e=>e.trim()):[r];else if("boolean"==typeof e)n[t]=["true","on","yes","1"].includes(String(r));else if("number"==typeof e){const e=Number(r);Number.isFinite(e)?n[t]=e:mh.warn("Invalid numeric wp_ param '".concat(t,"': ").concat(r))}else n[t]=r}Xu=bh(Xu,n);const r=Xu.profile;if(Xu.profiles&&r&&Xu.profiles[r]&&(Xu=bh(Xu,Xu.profiles[r]),mh.debug("Profile set from config: ".concat(r))),Xu.profiles&&ch&&Xu.profiles["device.".concat(ch)]){const e="device.".concat(ch);Xu=bh(Xu,Xu.profiles[e]),mh.debug("Profile set from device: ".concat(e))}if(Xu.profiles){const e=[lh,uh,hh];for(let t=0;t{t.tagName.toLowerCase().startsWith("browser-mod-popup")&&t.shadowRoot&&t.shadowRoot.querySelector("ha-dialog")&&e.push(t)}),e):e}function xh(){const e=Eh();return e&&0!=e.length?e[0]:null}function Sh(){if("1"==new URLSearchParams(window.location.search).get("edit"))return mh.debug("Edit mode active"),!1;if(!Xu.enabled)return mh.debug("Wallpanel not enabled in config"),!1;if(Xu.enabled_on_views&&Xu.enabled_on_views.length>0&&Qu&&!Xu.enabled_on_views.includes(Qu))return mh.debug("Wallpanel not enabled on current tab ".concat(Qu)),!1;if(Xu.disable_screensaver_when_assist_active){const e=ah.shadowRoot.querySelector("ha-voice-command-dialog");if(e&&e.shadowRoot&&e.shadowRoot.querySelector("ha-dialog"))return mh.debug("Assist is active, wallpanel disabled"),!1}return Ku&&Ku.disable_screensaver_on_browser_mod_popup_function&&xh()&&Ku.disable_screensaver_on_browser_mod_popup_function(xh())?(mh.debug("Browser mod popup function returned true, wallpanel disabled"),!1):!Xu.disable_screensaver_on_browser_mod_popup||!xh()||(mh.debug("Browser mod popup active, wallpanel disabled"),!1)}function Ch(){return Xu.show_images&&Xu.image_url?Xu.image_url.startsWith("media-entity-video://")?"media-entity-video":Xu.image_url.startsWith("media-entity-image://")?"media-entity-image":Xu.image_url.startsWith("media-source://")?"media-source":Xu.image_url.startsWith("https://api.unsplash")?"unsplash-api":Xu.image_url.startsWith("immich+")?"immich-api":Xu.image_url.startsWith("iframe+")?"iframe":Xu.image_url.startsWith("embed+")?"embed":"url":""}function Ih(){try{return sh.shadowRoot.querySelector("ha-panel-lovelace")}catch(e){mh.error("Failed to get ha-panel-lovelace:",e)}}function Th(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const t=Ih(),n={};if(t&&t.lovelace){let r;t.lovelace.config&&t.lovelace.config.wallpanel?r=t.lovelace.config.wallpanel:t.lovelace.rawConfig&&t.lovelace.rawConfig.wallpanel&&(r=t.lovelace.rawConfig.wallpanel),r&&(0===e.length&&(e=Object.keys(r)),e.forEach(e=>{(e in qu||e in Yu)&&(n[e]=r[e])}))}return n}function Rh(e){mh.debug("setSidebarVisibility: hidden=".concat(e));try{const t=sh.shadowRoot.querySelector("ha-panel-lovelace");if(t){const n=t.shadowRoot.querySelector("hui-root");if(n){const t=n.shadowRoot.querySelector("ha-menu-button");t&&(e?t.style.display="none":t.style.removeProperty("display"))}}}catch(e){mh.warn(e)}try{const t=sh.shadowRoot.querySelector("ha-drawer");if(t){const n=t.shadowRoot.querySelector(".sidebar-shell")||t.shadowRoot.querySelector("aside"),r=n&&n.classList.contains("sidebar-shell")?"--ha-sidebar-width":"--mdc-drawer-width";n&&(e?(n.style.opacity=0,n.style.maxWidth="0px",sh.style.setProperty(r,"env(safe-area-inset-left)")):(n.style.opacity=1,n.style.maxWidth="",sh.style.removeProperty(r)),window.dispatchEvent(new Event("resize")))}}catch(e){mh.warn(e)}}function kh(e,t){mh.debug("setToolbarVisibility: hideToolbar=".concat(e,", hideActionItems=").concat(t));try{const n=sh.shadowRoot.querySelector("ha-panel-lovelace");if(!n)return;let r=n.shadowRoot.querySelector("hui-root");if(!r)return;r=r.shadowRoot;const i=r.querySelector("#view");let o=r.querySelector("app-toolbar");if(o||(o=r.querySelector("div.toolbar")),e)o.style.setProperty("display","none"),Xu.keep_toolbar_space||(i.style.minHeight="100vh",i.style.marginTop="0",i.style.paddingTop="0");else{o.style.removeProperty("display"),i.style.removeProperty("min-height"),i.style.removeProperty("margin-top"),i.style.removeProperty("padding-top");const e=o.querySelector("div.action-items");t?e.style.setProperty("display","none"):e.style.setProperty("display","flex")}window.dispatchEvent(new Event("resize"))}catch(e){mh.warn(e)}}function Oh(){return void 0!==document.fullscreenElement?Boolean(document.fullscreenElement):void 0!==document.webkitCurrentFullScreenElement&&Boolean(document.webkitCurrentFullScreenElement)}function Ph(){mh.debug("Enter fullscreen");const e=document.documentElement;e.requestFullscreen?e.requestFullscreen().then(()=>{mh.debug("Successfully requested fullscreen")},e=>{mh.debug("Failed to enter fullscreen:",e)}):e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen?e.msRequestFullscreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen()}function Mh(){const e=customElements.get("hui-view-container"),t=customElements.get("hui-view");if(!e||!t){throw new Error("Failed to get hui-view-container / hui-view from customElements")}class r extends e{}class i extends t{constructor(){super(),this.mediaList=[],this.mediaIndex=-1,this.mediaListDirection="forwards",this.lastMediaListUpdate,this.updatingMediaList=!1,this.updatingMedia=!1,this.lastMediaUpdate=0,this.isPaused=!1,this.displayTime=null,this.mediaTimeElapsedBeforePause=0,this.lastImageUrlEntityValue=null,this.blockEventsUntil=0,this.screensaverStartedAt,this.screensaverStoppedAt=new Date,this.infoBoxContentCreatedDate,this.idleSince=Date.now(),this.lastProfileSet=Xu.profile,this.lastMove=null,this.lastCorner=0,this.translateTimeout=null,this.lastClickTime=0,this.clickCount=0,this.touchStartX=-1,this.touchStartY=-1,this.currentWidth=0,this.currentHeight=0,this.energyCollectionUpdateEnabled=!1,this.energyCollectionUpdateInterval=60,this.lastEnergyCollectionUpdate=0,this.screensaverStopNavigationPathTimeout=null,this.disable_screensaver_on_browser_mod_popup_function=null,this.moreInfoDialogOpenedAt=0,this.timerInterval=null,this.windowEventHandlers=[],this.infoBoxResizeObserver=null,this.screenWakeLock=new gh,this.cameraMotionDetection=new ph,this.lovelace=null,this.__hass=ah.hass||ah.__hass,this.__cards=[],this.__badges=[],this.__views=[],ah.provideHass(this),this.timerInterval=setInterval(this.timer.bind(this),1e3),Zu.hass=this.__hass}set hass(e){mh.debug("Update hass"),this.__hass=e;let t=!1;for(const e in ih){const n=this.__hass.states[e];n&&n.state!=ih[e]&&(ih[e]=n.state,t=!0)}if(!this.updateProfile()&&t&&wh(),!Sh())return;const n=Xu.screensaver_entity;if(n&&this.__hass.states[n]){const e=new Date(this.__hass.states[n].last_changed),t=this.__hass.states[n].state;"off"==t&&this.screensaverStartedAt&&e.getTime()-this.screensaverStartedAt>0?this.stopScreensaver(Xu.fade_out_time_screensaver_entity):"on"==t&&this.screensaverStoppedAt&&e.getTime()-this.screensaverStoppedAt>0&&this.startScreensaver()}this.screensaverRunning()&&(this.__cards.forEach(e=>{e.hass=this.hass}),this.__badges.forEach(e=>{e.hass=this.hass}),this.__views.forEach(e=>{e.hass=this.hass}),"media-entity-image"==Ch()&&this.switchActiveMedia("entity_update"))}get hass(){return this.__hass}setScreensaverEntityState(){const e=Xu.screensaver_entity;if(!e||!this.__hass.states[e])return;if(this.screensaverRunning()&&"on"==this.__hass.states[e].state)return;if(!this.screensaverRunning()&&"off"==this.__hass.states[e].state)return;const t=this.screensaverRunning()?"turn_on":"turn_off";mh.debug("Updating screensaver_entity",e,t),this.__hass.callService("input_boolean",t,{entity_id:e}).then(e=>{mh.debug(e)},e=>{mh.error("Failed to set screensaver entity state:",e)})}setImageURLEntityState(){const e=Xu.image_url_entity;if(!e||!this.__hass.states[e])return;const t=this.getActiveMediaElement();if(!t||!t.mediaUrl)return;const n=t.mediaUrl.substring(0,255);this.lastImageUrlEntityValue!==n&&(mh.debug("Updating image_url_entity",e,n),this.__hass.callService("input_text","set_value",{entity_id:e,value:n}).then(e=>{mh.debug(e),this.lastImageUrlEntityValue=n},e=>{mh.error("Failed to set image url entity state:",e)}))}updateProfile(){const e=Xu.profile_entity;if(e&&this.__hass.states[e]){const t=this.__hass.states[e].state;if(t&&t!=this.lastProfileSet||!t&&this.lastProfileSet)return mh.debug("Set profile to ".concat(t)),this.lastProfileSet=t,wh(),!0}return!1}timer(){Xu.enabled&&Ju&&(this.screensaverRunning()?Xu.disable_screensaver_on_browser_mod_popup&&xh()?this.stopScreensaver(Xu.fade_out_time_browser_mod_popup):this.updateScreensaver():Sh()&&Xu.idle_time>0&&Date.now()-this.idleSince>=1e3*Xu.idle_time&&(Xu.camera_motion_detection_stop_screensaver&&this.cameraMotionDetection&&this.cameraMotionDetection.motionActive||this.startScreensaver()))}setDefaultStyle(){this.messageContainer.removeAttribute("style"),this.messageContainer.style.position="fixed",this.messageContainer.style.top="1rem",this.messageContainer.style.left="1rem",this.messageContainer.style.bottom="1rem",this.messageContainer.style.right="1rem",this.messageContainer.style.alignItems="flex-end",this.messageContainer.style.display="flex",this.messageContainer.style.flexDirection="column",this.messageContainer.style.gap="0.5rem",this.messageContainer.style.zIndex=this.style.zIndex+1,this.messageContainer.style.pointerEvents="none",this.messageContainer.style.visibility="hidden",this.debugBox.removeAttribute("style"),this.debugBox.style.position="fixed",this.debugBox.style.pointerEvents="none",this.debugBox.style.top="0%",this.debugBox.style.left="0%",this.debugBox.style.width="100%",this.debugBox.style.height="100%",this.debugBox.style.background="#00000099",this.debugBox.style.color="#ffffff",this.debugBox.style.zIndex=this.style.zIndex+2,this.debugBox.style.fontFamily="monospace",this.debugBox.style.fontSize="12px",this.debugBox.style.overflowWrap="break-word",this.debugBox.style.overflowY="auto",this.debugBox.style.visibility="hidden",this.screensaverContainer.removeAttribute("style"),this.screensaverContainer.style.position="fixed",this.screensaverContainer.style.pointerEvents="auto",this.screensaverContainer.style.top=0,this.screensaverContainer.style.right=0,this.screensaverContainer.style.bottom=0,this.screensaverContainer.style.left=0,this.screensaverContainer.style.background="#000000",this.screensaverContainer.style.overflow="hidden",this.imageOneContainer.removeAttribute("style"),this.imageOneContainer.style.opacity=0,this.imageOneContainer.style.position="absolute",this.imageOneContainer.style.pointerEvents="none",this.imageOneContainer.style.top=0,this.imageOneContainer.style.left=0,this.imageOneContainer.style.width="100%",this.imageOneContainer.style.height="100%",this.imageOneContainer.style.border="none",this.imageOneBackground.style.position="absolute",this.imageOneBackground.style.pointerEvents="none",this.imageOneBackground.style.top=0,this.imageOneBackground.style.left=0,this.imageOneBackground.style.width="100%",this.imageOneBackground.style.height="100%",this.imageOneBackground.style.border="none",this.imageOne.removeAttribute("style"),this.imageOne.style.position="relative",this.imageOne.style.pointerEvents="none",this.imageOne.style.width="100%",this.imageOne.style.height="100%",this.imageOne.style.border="none",this.imageOneInfoContainer.removeAttribute("style"),this.imageOneInfoContainer.style.position="absolute",this.imageOneInfoContainer.style.pointerEvents="none",this.imageOneInfoContainer.style.top=0,this.imageOneInfoContainer.style.left=0,this.imageOneInfoContainer.style.width="100%",this.imageOneInfoContainer.style.height="100%",this.imageOneInfoContainer.style.border="none",this.imageOneInfo.style.overflowY="auto",this.imageTwoContainer.removeAttribute("style"),this.imageTwoContainer.style.opacity=0,this.imageTwoContainer.style.position="absolute",this.imageTwoContainer.style.pointerEvents="none",this.imageTwoContainer.style.top=0,this.imageTwoContainer.style.left=0,this.imageTwoContainer.style.width="100%",this.imageTwoContainer.style.height="100%",this.imageTwoContainer.style.border="none",this.imageTwoBackground.style.position="absolute",this.imageTwoBackground.style.pointerEvents="none",this.imageTwoBackground.style.top=0,this.imageTwoBackground.style.left=0,this.imageTwoBackground.style.width="100%",this.imageTwoBackground.style.height="100%",this.imageTwoBackground.style.border="none",this.imageTwo.removeAttribute("style"),this.imageTwo.style.position="relative",this.imageTwo.style.pointerEvents="none",this.imageTwo.style.width="100%",this.imageTwo.style.height="100%",this.imageTwo.style.border="none",this.imageTwoInfoContainer.removeAttribute("style"),this.imageTwoInfoContainer.style.position="absolute",this.imageTwoInfoContainer.style.pointerEvents="none",this.imageTwoInfoContainer.style.top=0,this.imageTwoInfoContainer.style.left=0,this.imageTwoInfoContainer.style.width="100%",this.imageTwoInfoContainer.style.height="100%",this.imageTwoInfoContainer.style.border="none",this.imageTwoInfo.style.overflowY="auto",this.screensaverImageOverlay.removeAttribute("style"),this.screensaverImageOverlay.style.position="absolute",this.screensaverImageOverlay.style.top=0,this.screensaverImageOverlay.style.left=0,this.screensaverImageOverlay.style.width="100%",this.screensaverImageOverlay.style.height="100%",this.screensaverImageOverlay.style.background="#00000000",this.infoContainer.removeAttribute("style"),this.infoContainer.style.position="absolute",this.infoContainer.style.pointerEvents="none",this.infoContainer.style.top=0,this.infoContainer.style.left=0,this.infoContainer.style.width="100%",this.infoContainer.style.height="100%",this.infoContainer.style.transition="opacity 2000ms ease-in-out",this.infoContainer.style.padding="25px",this.infoContainer.style.boxSizing="border-box",this.infoBox.removeAttribute("style"),this.infoBox.style.pointerEvents="none",this.infoBox.style.width="fit-content",this.infoBox.style.maxHeight="100%",this.infoBox.style.borderRadius="10px",this.infoBox.style.overflowY="auto",this.infoBox.style.scrollbarWidth="none",this.infoBox.style.setProperty("--wp-card-width","500px"),this.infoBox.style.setProperty("--wp-card-padding","0"),this.infoBox.style.setProperty("--wp-card-margin","5px"),this.infoBox.style.setProperty("--wp-card-backdrop-filter","none"),this.infoBox.style.setProperty("--wp-badges-minwidth","200px"),this.infoBoxPosX.style.pointerEvents="none",this.infoBoxPosX.style.height="100%",this.infoBoxPosX.style.width="100%",this.infoBoxPosY.style.pointerEvents="none",this.infoBoxPosY.style.height="100%",this.infoBoxPosY.style.width="100%",this.infoBoxContent.style.pointerEvents="none",this.infoBoxContent.style.width="fit-content",this.infoBoxContent.style.height="100%",this.infoBoxContent.style.display="grid",this.fixedInfoContainer.removeAttribute("style"),this.fixedInfoContainer.style.position="fixed",this.fixedInfoContainer.style.pointerEvents="none",this.fixedInfoContainer.style.top=0,this.fixedInfoContainer.style.left=0,this.fixedInfoContainer.style.width="100%",this.fixedInfoContainer.style.height="100%",this.fixedInfoBox.style.pointerEvents="none",this.fixedInfoBox.style.cssText=this.infoBox.style.cssText,this.screensaverOverlay.removeAttribute("style"),this.screensaverOverlay.style.position="absolute",this.screensaverOverlay.style.pointerEvents="none",this.screensaverOverlay.style.top=0,this.screensaverOverlay.style.left=0,this.screensaverOverlay.style.width="100%",this.screensaverOverlay.style.height="100%",this.screensaverOverlay.style.background="#00000000"}updateStyle(){this.screensaverOverlay.style.background="#00000000",this.debugBox.style.visibility=Xu.debug?"visible":"hidden",this.debugBox.style.pointerEvents=Xu.debug?"auto":"none",this.style.transition=Xu.fade_in_time>0?"opacity ".concat(Math.round(1e3*Xu.fade_in_time),"ms ease-in-out"):"",this.imageOneContainer.style.transition=Xu.crossfade_time>0?"opacity ".concat(Math.round(1e3*Xu.crossfade_time),"ms ease-in-out"):"",this.imageTwoContainer.style.transition=Xu.crossfade_time>0?"opacity ".concat(Math.round(1e3*Xu.crossfade_time),"ms ease-in-out"):"",this.messageContainer.style.visibility=this.screensaverRunning()?"visible":"hidden",this.screensaverImageOverlay.style.pointerEvents=Xu.content_interaction?"none":"auto";const e=Xu.show_image_info&&Boolean(Xu.image_info_template);if(this.imageOneInfoContainer.style.display=e?"block":"none",this.imageTwoInfoContainer.style.display=e?"block":"none",Xu.info_animation_duration_x?this.infoBoxPosX.style.animation="moveX ".concat(Xu.info_animation_duration_x,"s ").concat(Xu.info_animation_timing_function_x," infinite alternate"):this.infoBoxPosX.style.animation="",Xu.info_animation_duration_y?this.infoBoxPosY.style.animation="moveY ".concat(Xu.info_animation_duration_y,"s ").concat(Xu.info_animation_timing_function_y," infinite alternate"):this.infoBoxPosY.style.animation="",Xu.style)for(const e in Xu.style)if(e.startsWith("wallpanel-")&&"wallpanel-shadow-host"!=e&&"wallpanel-screensaver-info-box-badges"!=e&&"wallpanel-screensaver-info-box-views"!=e&&!th[e]){const t=this.shadowRoot.getElementById(e);if(t){mh.debug("Setting style attributes for element #".concat(e));for(const n in Xu.style[e])mh.debug("Setting style attribute ".concat(n," to ").concat(Xu.style[e][n])),t.style.setProperty(n,Xu.style[e][n]);t==this.infoBox?this.fixedInfoBox.style.cssText=this.infoBox.style.cssText:t==this.infoBoxContent&&(this.fixedInfoBoxContent.style.cssText=this.infoBoxContent.style.cssText)}else mh.error("Element #".concat(e," not found"))}}updateShadowStyle(){const e=getComputedStyle(this.infoContainer),t=this.infoContainer.offsetWidth-parseInt(e.paddingLeft)-parseInt(e.paddingRight)-this.infoBox.offsetWidth,n=this.infoContainer.offsetHeight-parseInt(e.paddingTop)-parseInt(e.paddingBottom)-this.infoBox.offsetHeight;let r="";if(Xu.style){if(Xu.style["wallpanel-shadow-host"])for(const e in Xu.style["wallpanel-shadow-host"])r+="".concat(e,": ").concat(Xu.style["wallpanel-shadow-host"][e],";\n");for(const e in th)Xu.style[e]&&bh(th[e],Xu.style[e])}let i="";for(const e in th){i+=".".concat(e," {\n");for(const t in th[e])i+="".concat(t,": ").concat(th[e][t],";\n");i+="}\n"}this.shadowStyle.innerHTML="\n\t\t\t\t:host {\n\t\t\t\t\t".concat(r,"\n\t\t\t\t}\n\t\t\t\t@keyframes moveX {\n\t\t\t\t\t100% {\n\t\t\t\t\t\ttransform: translate3d(").concat(t,"px, 0, 0);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t@keyframes moveY {\n\t\t\t\t\t100% {\n\t\t\t\t\t\ttransform: translate3d(0, ").concat(n,"px, 0);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t@keyframes horizontalProgress {\n\t\t\t\t\t0% {\n\t\t\t\t\t\twidth: 0%;\n\t\t\t\t\t}\n\t\t\t\t\t100% {\n\t\t\t\t\t\twidth: 100%;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t@keyframes kenBurnsEffect-experimental {\n\t\t\t\t\t0% {\n\t\t\t\t\t\ttransform: scale(1.0) translateX(calc(var(--hidden-width) / -2 * 1px)) translateY(calc(var(--hidden-height) / -2 * 1px));\n\t\t\t\t\t}\n\t\t\t\t\t50% {\n\t\t\t\t\t\ttransform: scale(var(--ken-burns-zoom));\n\t\t\t\t\t}\n\t\t\t\t\t90% {\n\t\t\t\t\t\ttransform: scale(calc(1.0 + ((var(--ken-burns-zoom) - 1.0)/2))) translateX(calc(var(--hidden-width) / 2 * 1px)) translateY(calc(var(--hidden-height) / 2 * 1px));\n\t\t\t\t\t}\n\t\t\t\t\t100% {\n\t\t\t\t\t\ttransform: scale(1.0);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t@keyframes kenBurnsEffect-experimental2 {\n\t\t\t\t\t0% {\n\t\t\t\t\t\ttransform: scale(1.0);\n\t\t\t\t\t}\n\t\t\t\t\t25% {\n\t\t\t\t\t\ttransform: scale(calc(1.0 + ((var(--ken-burns-zoom) - 1.0)/2))) translateX(calc(var(--hidden-width) / 2 * 1px)) translateY(calc(var(--hidden-height) / 2 * 1px));\n\t\t\t\t\t}\n\t\t\t\t\t50% {\n\t\t\t\t\t\ttransform: scale(var(--ken-burns-zoom));\n\t\t\t\t\t}\n\t\t\t\t\t75% {\n\t\t\t\t\t\ttransform: scale(calc(1.0 + ((var(--ken-burns-zoom) - 1.0)/2))) translateX(calc(var(--hidden-width) / -2 * 1px)) translateY(calc(var(--hidden-height) / -2 * 1px));\n\t\t\t\t\t}\n\t\t\t\t\t100% {\n\t\t\t\t\t\ttransform: scale(1.0);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t@keyframes kenBurnsEffect-simple {\n\t\t\t\t\t0% {\n\t\t\t\t\t\ttransform-origin: bottom left;\n\t\t\t\t\t\ttransform: scale(1.0);\n\t\t\t\t\t}\n\t\t\t\t\t100% {\n\t\t\t\t\t\ttransform: scale(var(--ken-burns-zoom));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t").concat(i,"\n\t\t\t\t").concat(Xu.custom_css,"\n\t\t\t")}randomMove(){const e=getComputedStyle(this.infoContainer),t=this.infoContainer.offsetWidth-parseInt(e.paddingLeft)-parseInt(e.paddingRight)-this.infoBox.offsetWidth,n=this.infoContainer.offsetHeight-parseInt(e.paddingTop)-parseInt(e.paddingBottom)-this.infoBox.offsetHeight,r=Math.floor(Math.random()*t),i=Math.floor(Math.random()*n);this.moveInfoBox(r,i)}moveAroundCorners(){let e=null;arguments.length>0&&void 0!==arguments[0]&&arguments[0]?e=0:this.lastCorner=(this.lastCorner+1)%4;const t=getComputedStyle(this.infoContainer),n=[2,3].includes(this.lastCorner)?this.infoContainer.offsetWidth-parseInt(t.paddingLeft)-parseInt(t.paddingRight)-this.infoBox.offsetWidth:0,r=[1,2].includes(this.lastCorner)?this.infoContainer.offsetHeight-parseInt(t.paddingTop)-parseInt(t.paddingBottom)-this.infoBox.offsetHeight:0;this.moveInfoBox(n,r,e)}moveInfoBox(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(this.lastMove=Date.now(),null===n&&(n=Xu.info_move_fade_duration),n>0)if(this.infoBox.animate){const e=[{opacity:1},{opacity:0,offset:.5},{opacity:1}];this.infoBox.animate(e,{duration:Math.round(1e3*n),iterations:1})}else mh.warn("This browser does not support the animate() method, please set info_move_fade_duration to 0");const r=this;let i=Math.round(500*n);i<0&&(i=0),r.translateTimeout&&clearTimeout(r.translateTimeout),r.translateTimeout=setTimeout(function(){r.infoBoxPosX.style.transform="translate3d(".concat(e,"px, 0, 0)"),r.infoBoxPosY.style.transform="translate3d(0, ".concat(t,"px, 0)")},i)}createInfoBoxContent(){mh.debug("Creating info box content");const e=Ih();if(e){if(this.lovelace=e.lovelace||e.__lovelace,this.infoBoxContentCreatedDate=new Date,this.infoBoxContent.innerHTML="",this.__badges=[],this.__cards=[],this.__views=[],this.energyCollectionUpdateEnabled=!1,this.shadowRoot.querySelectorAll(".wp-card").forEach(e=>{e.parentElement.removeChild(e)}),Xu.badges&&Xu.badges.length>0){const e=document.createElement("div");if(e.id="wallpanel-screensaver-info-box-badges",e.classList.add("wp-badges"),e.style.padding="var(--wp-card-padding)",e.style.margin="var(--wp-card-margin)",e.style.textAlign="center",e.style.display="flex",e.style.alignItems="flex-start",e.style.flexWrap="wrap",e.style.justifyContent="center",e.style.gap="8px",e.style.margin="0px",e.style.minWidth="var(--wp-badges-minwidth)",Xu.style[e.id])for(const t in Xu.style[e.id])mh.debug("Setting style attribute ".concat(t," to ").concat(Xu.style[e.id][t])),e.style.setProperty(t,Xu.style[e.id][t]);Xu.badges.forEach(t=>{const n=JSON.parse(JSON.stringify(t));mh.debug("Creating badge:",n);let r={};n.wp_style&&(r=n.wp_style,delete n.wp_style);const i=(this._createBadgeElement?this._createBadgeElement:this.createBadgeElement).bind(this)(n);i.hass=this.hass;for(const e in r)i.style.setProperty(e,r[e]);this.__badges.push(i),e.append(i)}),this.infoBoxContent.appendChild(e)}if(Xu.views&&Xu.views.length>0){const e=document.createElement("div");if(e.id="wallpanel-screensaver-info-box-views",e.classList.add("wp-views"),Xu.style[e.id])for(const t in Xu.style[e.id])mh.debug("Setting style attribute ".concat(t," to ").concat(Xu.style[e.id][t])),e.style.setProperty(t,Xu.style[e.id][t]);const t=this.lovelace.config.views;Xu.views.forEach(n=>{let r=-1;const i=JSON.parse(JSON.stringify(n));for(var o=0;o0&&Xu.cards.forEach(e=>{const t=JSON.parse(JSON.stringify(e));mh.debug("Creating card:",t);let n={};t.wp_style&&(n=t.wp_style,delete t.wp_style),t.type&&t.type.includes("energy")&&(t.collection_key="energy_wallpanel",this.energyCollectionUpdateEnabled=!0);const r=(this._createCardElement?this._createCardElement:this.createCardElement).bind(this)(t);r.hass=this.hass,this.__cards.push(r);let i=this.infoBoxContent;const o=document.createElement("div");o.classList.add("wp-card"),o.style.width="var(--wp-card-width)",o.style.padding="var(--wp-card-padding)",o.style.margin="var(--wp-card-margin)",o.style.backdropFilter="var(--wp-card-backdrop-filter)",Xu.content_interaction?o.style.pointerEvents="auto":o.style.pointerEvents="none";for(const e in n)if("parent"==e){const t=this.shadowRoot.getElementById(n[e]);t&&(i=t)}else o.style.setProperty(e,n[e]);o.append(r),i.appendChild(o)}),setTimeout(this.updateShadowStyle.bind(this),500)}}setDisplayTime(){const e=Xu.display_time,t=this.getActiveMediaElement(!0);t.updateMediaError?this.displayTime=0:t.play_to_end&&!t.loop?this.displayTime=t.duration:this.displayTime=e}getDisplayTime(){return this.displayTime}restartProgressBarAnimation(){if(!this.progressBarContainer)return;if(this.progressBar.style.animation="none",!Xu.show_progress_bar)return;const e=this;setTimeout(function(){e.progressBar.style.animation="horizontalProgress ".concat(e.getDisplayTime(),"s linear"),e.progressBar.style.animationPlayState=e.isPaused?"paused":"running"},25)}restartKenBurnsEffect(){if(!Xu.image_animation_ken_burns||!Xu.image_animation_ken_burns_animations.length)return;const e=this.getActiveMediaElement();e.style.animation="none",e.style.setProperty("--ken-burns-zoom",Xu.image_animation_ken_burns_zoom);let t=Math.floor(1e3*Xu.image_animation_ken_burns_delay);t<50&&(t=50);const n=Math.ceil(Xu.image_animation_ken_burns_duration||1.2*(this.getDisplayTime()+2*Xu.crossfade_time)),r=Xu.image_animation_ken_burns_animations[Math.floor(Math.random()*Xu.image_animation_ken_burns_animations.length)];this.kenburnsDelayStartTimer&&clearTimeout(this.kenburnsDelayStartTimer),e.animationIterationCount=1,this.kenburnsDelayStartTimer=setTimeout(function(){e.style.animation="kenBurnsEffect-".concat(r," ").concat(n,"s linear forwards")},t)}getMediaElement(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this.imageOneContainer.style.opacity==(e?1:0)?this.imageOne:this.imageTwo;if(t&&"ha-camera-stream"==n.tagName.toLowerCase()){const e=_h(n)[1];e&&(n=e)}return n}getActiveMediaElement(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.getMediaElement(!0,e)}getInactiveMediaElement(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.getMediaElement(!1,e)}replaceMediaElement(e,t){if("string"==typeof e.src&&e.src.startsWith("blob:")&&URL.revokeObjectURL(e.src),"function"==typeof e.pause&&e.pause(),"ha-camera-stream"==e.tagName.toLowerCase()){const[t,n]=_h(e);n&&n.pause(),t&&"function"==typeof t.stop&&t.stop()}t=t.toLowerCase();const n=document.createElement(t);return[...e.attributes].filter(e=>"src"!=e.name).forEach(e=>n.setAttribute(e.name,e.value)),n.mediaUrl=e.mediaUrl,n.infoCacheUrl=e.infoCacheUrl,"video"===t&&Object.assign(n,{preload:"auto",muted:!1,volume:Xu.video_volume}),e.replaceWith(n),e===this.imageOne?this.imageOne=n:this.imageTwo=n,e.remove(),n}loadBackgroundImage(e){let t=e.src;const n=e.tagName.toLowerCase();if("ha-camera-stream"===n){const n=_h(e)[1];if(!n||!n.poster)return;t=n.poster}else if("video"===n){const n=document.createElement("canvas");n.width=e.videoWidth,n.height=e.videoHeight;n.getContext("2d").drawImage(e,0,0,n.width,n.height);try{t=n.toDataURL("image/png")}catch(e){t=null,mh.error("Error extracting canvas image:",e)}}let r=this.imageOneBackground;e==this.imageTwo&&(r=this.imageTwoBackground),r.style.backgroundImage=t?"url('".concat(t.replace(/'/g,"%27"),"')"):""}connectedCallback(){this.style.zIndex=Xu.z_index,this.style.visibility="hidden",this.style.opacity=0,this.style.position="fixed",this.timerInterval||(this.timerInterval=setInterval(this.timer.bind(this),1e3)),this.messageContainer=document.createElement("div"),this.messageContainer.id="wallpanel-message-container",this.debugBox=document.createElement("div"),this.debugBox.id="wallpanel-debug-box",this.screensaverContainer=document.createElement("div"),this.screensaverContainer.id="wallpanel-screensaver-container",this.imageOneContainer=document.createElement("div"),this.imageOneContainer.id="wallpanel-screensaver-image-one-container",this.imageOneBackground=document.createElement("div"),this.imageOneBackground.className="wallpanel-screensaver-image-background",this.imageOneBackground.id="wallpanel-screensaver-image-one-background",this.imageOne=document.createElement("img"),this.imageOne.id="wallpanel-screensaver-image-one",this.imageOneInfoContainer=document.createElement("div"),this.imageOneInfoContainer.className="wallpanel-screensaver-image-info-container",this.imageOneInfoContainer.id="wallpanel-screensaver-image-one-info-container",this.imageOneInfo=document.createElement("div"),this.imageOneInfo.className="wallpanel-screensaver-image-info",this.imageOneInfo.id="wallpanel-screensaver-image-one-info",this.imageOneInfoContainer.appendChild(this.imageOneInfo),this.imageOneContainer.appendChild(this.imageOneBackground),this.imageOneContainer.appendChild(this.imageOne),this.imageOneContainer.appendChild(this.imageOneInfoContainer),this.screensaverContainer.appendChild(this.imageOneContainer),this.imageTwoContainer=document.createElement("div"),this.imageTwoContainer.id="wallpanel-screensaver-image-two-container",this.imageTwoBackground=document.createElement("div"),this.imageTwoBackground.className="wallpanel-screensaver-image-background",this.imageTwoBackground.id="wallpanel-screensaver-image-two-background",this.imageTwo=document.createElement("img"),this.imageTwo.id="wallpanel-screensaver-image-two",this.imageTwoInfoContainer=document.createElement("div"),this.imageTwoInfoContainer.className="wallpanel-screensaver-image-info-container",this.imageTwoInfoContainer.id="wallpanel-screensaver-image-two-info-container",this.imageTwoInfo=document.createElement("div"),this.imageTwoInfo.className="wallpanel-screensaver-image-info",this.imageTwoInfo.id="wallpanel-screensaver-image-two-info",this.imageTwoInfoContainer.appendChild(this.imageTwoInfo),this.imageTwoContainer.appendChild(this.imageTwoBackground),this.imageTwoContainer.appendChild(this.imageTwo),this.imageTwoContainer.appendChild(this.imageTwoInfoContainer),this.screensaverContainer.appendChild(this.imageTwoContainer),this.screensaverImageOverlay=document.createElement("div"),this.screensaverImageOverlay.id="wallpanel-screensaver-image-overlay",this.screensaverContainer.appendChild(this.screensaverImageOverlay),this.progressBarContainer=document.createElement("div"),this.progressBarContainer.className="wallpanel-progress",this.progressBar=document.createElement("div"),this.progressBar.className="wallpanel-progress-inner",this.progressBar.id="wallpanel-progress-inner",this.progressBarContainer.appendChild(this.progressBar),Xu.show_progress_bar&&this.screensaverContainer.appendChild(this.progressBarContainer),this.pauseIndicator=document.createElement("div"),this.pauseIndicator.id="wp-pause-indicator",this.pauseIndicator.innerHTML="⏸️",this.pauseIndicator.style.position="absolute",this.pauseIndicator.style.top="1rem",this.pauseIndicator.style.left="1rem",this.pauseIndicator.style.fontSize="4rem",this.pauseIndicator.style.lineHeight="1",this.pauseIndicator.style.color="white",this.pauseIndicator.style.filter="drop-shadow(0 0 8px rgba(0,0,0,0.8))",this.pauseIndicator.style.zIndex="9999",this.pauseIndicator.style.pointerEvents="none",this.pauseIndicator.style.display="none",this.screensaverContainer.appendChild(this.pauseIndicator),this.infoContainer=document.createElement("div"),this.infoContainer.id="wallpanel-screensaver-info-container",this.fixedInfoContainer=document.createElement("div"),this.fixedInfoContainer.id="wallpanel-screensaver-fixed-info-container",this.fixedInfoBox=document.createElement("div"),this.fixedInfoBox.id="wallpanel-screensaver-fixed-info-box",this.fixedInfoBoxContent=document.createElement("div"),this.fixedInfoBoxContent.id="wallpanel-screensaver-fixed-info-box-content",this.screensaverContainer.appendChild(this.infoContainer),this.infoBoxPosX=document.createElement("div"),this.infoBoxPosX.id="wallpanel-screensaver-info-box-pos-x",this.infoBoxPosX.x="0",this.infoBoxPosY=document.createElement("div"),this.infoBoxPosY.id="wallpanel-screensaver-info-box-pos-y",this.infoBoxPosY.y="0",this.infoBox=document.createElement("div"),this.infoBox.id="wallpanel-screensaver-info-box",this.infoBoxContent=document.createElement("div"),this.infoBoxContent.id="wallpanel-screensaver-info-box-content",this.infoBoxContent.style.display="grid",this.infoBox.appendChild(this.infoBoxContent),this.infoBoxPosX.appendChild(this.infoBox),this.infoBoxPosY.appendChild(this.infoBoxPosX),this.infoContainer.appendChild(this.infoBoxPosY),this.fixedInfoBox.appendChild(this.fixedInfoBoxContent),this.fixedInfoContainer.appendChild(this.fixedInfoBox),this.infoContainer.appendChild(this.fixedInfoContainer),this.screensaverOverlay=document.createElement("div"),this.screensaverOverlay.id="wallpanel-screensaver-overlay",this.screensaverContainer.appendChild(this.screensaverOverlay),this.shadowStyle=document.createElement("style");const e=this.attachShadow({mode:"open"});e.appendChild(this.shadowStyle),e.appendChild(this.screensaverContainer),e.appendChild(this.messageContainer),e.appendChild(this.debugBox);const t=this,n=["click","touchstart","touchend","wheel"];Xu.stop_screensaver_on_key_down&&n.push("keydown"),Xu.stop_screensaver_on_mouse_move&&n.push("mousemove");const r=e=>{try{t.handleInteractionEvent(e)}catch(e){mh.error(e.stack)}};n.forEach(function(e){window.addEventListener(e,r,!0),t.windowEventHandlers.push({eventName:e,handler:r,options:!0})});const i=e=>{Xu.disable_context_menu&&t.screensaverRunning()&&e.preventDefault()};window.addEventListener("contextmenu",i),this.windowEventHandlers.push({eventName:"contextmenu",handler:i});const o=()=>{try{const e=this.screensaverContainer.clientWidth,n=this.screensaverContainer.clientHeight;!t.screensaverRunning()||t.currentWidth==e&&t.currentHeight==n||(mh.debug("Size changed from ".concat(t.currentWidth,"x").concat(t.currentHeight," to ").concat(e,"x").concat(n)),t.currentWidth=e,t.currentHeight=n,t.updateShadowStyle(),t.setMediaDimensions())}catch(e){mh.error(e.stack)}};window.addEventListener("resize",o),this.windowEventHandlers.push({eventName:"resize",handler:o});const a=()=>{try{t.screensaverRunning()&&t.moreInfoDialogToForeground()}catch(e){mh.error(e.stack)}};window.addEventListener("hass-more-info",a),this.windowEventHandlers.push({eventName:"hass-more-info",handler:a}),this.infoBoxResizeObserver=new ResizeObserver(()=>{"corners"===Xu.info_move_pattern&&this.moveAroundCorners(!0)}),this.infoBoxResizeObserver.observe(this.infoBoxContent),this.setScreensaverEntityState()}disconnectedCallback(){this.timerInterval&&(clearInterval(this.timerInterval),this.timerInterval=null),this.translateTimeout&&(clearTimeout(this.translateTimeout),this.translateTimeout=null),this.windowEventHandlers.length&&(this.windowEventHandlers.forEach(e=>{let{eventName:t,handler:n,options:r}=e;window.removeEventListener(t,n,r)}),this.windowEventHandlers=[]),this.infoBoxResizeObserver&&(this.infoBoxResizeObserver.disconnect(),this.infoBoxResizeObserver=null)}reconfigure(e){const t=e&&Object.keys(e).length>0;!t||e.hide_toolbar==Xu.hide_toolbar&&e.hide_toolbar_action_icons==Xu.hide_toolbar_action_icons&&e.hide_toolbar_on_subviews==Xu.hide_toolbar_on_subviews&&e.hide_sidebar==Xu.hide_sidebar&&e.fullscreen==Xu.fullscreen||Lh(),Xu.theme&&(mh.info("Apply theme",Xu.theme),Zu.theme=Xu.theme,Zu._applyTheme()),this.updateStyle(),this.screensaverRunning()&&this.createInfoBoxContent(),!Xu.info_move_interval&&t&&e.info_move_interval&&Ku.moveInfoBox(0,0);const n=e.image_url!=Xu.image_url||"immich-api"==Ch()&&(Xu.immich_shared_albums!=e.immich_shared_albums||Xu.immich_memories!=e.immich_memories||Xu.immich_favorites!=e.immich_favorites||JSON.stringify(Xu.immich_album_names)!=JSON.stringify(e.immich_album_names)||JSON.stringify(Xu.immich_tag_names)!=JSON.stringify(e.immich_tag_names)||JSON.stringify(Xu.immich_persons)!=JSON.stringify(e.immich_persons));if(Xu.show_images&&(!this.mediaList||!this.mediaList.length||!t||!e.show_images||n)){const e=this,r=this.screensaverRunning()&&t;n&&(this.mediaList=[],this.mediaIndex=-1),this.updateMediaList(function(){r&&e.switchActiveMedia("reconfigure")},n)}if(Xu.disable_screensaver_on_browser_mod_popup_func)try{this.disable_screensaver_on_browser_mod_popup_function=new Function("bmp",Xu.disable_screensaver_on_browser_mod_popup_func)}catch(e){this.disable_screensaver_on_browser_mod_popup_function=null,mh.error("Invalid disable_screensaver_on_browser_mod_popup_func:",e)}Sh()&&Xu.camera_motion_detection_enabled?this.cameraMotionDetection.start():this.cameraMotionDetection.stop()}getMoreInfoDialog(){const e=ah.shadowRoot.querySelector("ha-more-info-dialog");if(!e)return;const t=e.shadowRoot.querySelector("ha-dialog");return t||void 0}moreInfoDialogToForeground(){const e=this;!function t(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;const r=e.getMoreInfoDialog();if(r)return r.style.position="absolute",void(r.style.zIndex=e.style.zIndex+1);n<10&&setTimeout(t,50,n+1)}()}fetchEXIFInfo(e){const t=this;if(nh.get(e.infoCacheUrl))return;const n=document.createElement("img");n.src=e.src,n.mediaUrl=e.mediaUrl,n.infoCacheUrl=e.infoCacheUrl,Vh(n,function(){mh.debug("EXIF data:",n.exifdata),rh(n.infoCacheUrl,n.exifdata),t.setMediaDataInfo(n);const e=n.exifdata.GPSLongitude,r=n.exifdata.GPSLatitude;if(Xu.fetch_address_data&&e&&!isNaN(e[0])&&r&&!isNaN(r[0])){let i="S"==n.exifdata.GPSLatitudeRef?-1:1;const o=r[0]*i+(r[1]*i*60+r[2]*i)/3600;i="W"==n.exifdata.GPSLongitudeRef?-1:1;const a=e[0]*i+(e[1]*i*60+e[2]*i)/3600;mh.debug("Fetching nominatim data for lat=".concat(o," lon=").concat(a));const s=new XMLHttpRequest;s.onload=function(){if(200==this.status||0===this.status){const e=JSON.parse(s.responseText);if(mh.debug("nominatim data:",e),e&&e.address){const r=nh.get(n.infoCacheUrl);r?(r.address=e.address,t.setMediaDataInfo(n)):mh.warn("URL not in cache:",n.infoCacheUrl)}}else mh.error("nominatim error:",this.status,s.status,s.responseText)},s.onerror=function(e){mh.error("nominatim error:",e)},s.ontimeout=function(e){mh.error("nominatim timeout:",e)},s.open("GET","https://nominatim.openstreetmap.org/reverse?lat=".concat(o,"&lon=").concat(a,"&format=json")),s.timeout=15e3,s.send()}})}setMediaDataInfo(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;const t=Xu.show_image_info&&Boolean(Xu.image_info_template);if(this.imageOneInfoContainer.style.display=t?"block":"none",this.imageTwoInfoContainer.style.display=t?"block":"none",!t)return this.imageOneInfo.innerHTML="",void(this.imageTwoInfo.innerHTML="");e||(e=this.getActiveMediaElement());const n=e.infoCacheUrl;let r=e.mediaUrl;if(!n)return void mh.debug("infoCacheUrl missing:",e);if(!r)return void mh.debug("mediaUrl missing:",e);r=decodeURI(r);const i=[];if(this.imageOne.infoCacheUrl==n&&i.push(this.imageOneInfo),this.imageTwo.infoCacheUrl==n&&i.push(this.imageTwoInfo),0==i.length)return;let o=nh.get(n);o||(o={}),o.image||(o.image={}),void 0===o.image.url&&(o.image.url=r);const a=r.replace(/\?[^?]*$/,"").replace(/\/+$/,"");if(void 0===o.image.path&&(o.image.path=a.replace(/^[^:]+:\/\/[^/]+/,"")),void 0===o.image.relativePath){const c="media-source"===Ch()?n.replace(/\?[^?]*$/,"").replace(/\/+$/,""):a;o.image.relativePath=c.replace(Xu.image_url,"").replace(/^\/+/,"")}if(void 0===o.image.filename&&(o.image.filename=a.replace(/^.*[\\/]/,"")),void 0===o.image.folderName){o.image.folderName="";const l=a.split("/");l.length>=2&&(o.image.folderName=l[l.length-2])}o.mediaPosition=this.mediaIndex+1,o.mediaCount=this.mediaList.length,mh.debug("Media info:",o);let s=Xu.image_info_template||"";if("analyze"==s){function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const n=Object.keys(e);n.sort(),n.forEach(n=>{const r=e[n];"object"==typeof r&&null!==r?u(r,n+"."):s+="".concat(t).concat(n,": ").concat(fh(r),"
")})}s="",u(o),this.imageOneInfo.style.pointerEvents="none",this.imageTwoInfo.style.pointerEvents="none",i.forEach(e=>{e.style.pointerEvents="auto"})}else s=s.replace(/\${([^}]+)}/g,(e,t)=>{const n=t.split("||");for(let e=0;e{const t=e.split(":",2);t[0]&&t[1]&&(a[t[0].replace(/\s/g,"")]=t[1].replace(/\s/g,""))}))}}let s="";const c=t.split("|");let l="";for(let e=0;e{s&&(s=s[e])}),s)break}if(s){if(/DateTime/i.test(l)){const e=new Date(s.replace(/(\d\d\d\d):(\d\d):(\d\d) (\d\d):(\d\d):(\d\d)/,"$1-$2-$3T$4:$5:$6"));if(isNaN(e))continue;a||(a={year:"numeric",month:"2-digit",day:"2-digit"}),s=e.toLocaleDateString((ah.hass||ah.__hass).locale.language,a)}return"object"==typeof s&&(s=JSON.stringify(s)),r+s+i}}return""});i.forEach(e=>{e.innerHTML=s,e.style.display="block"})}async updateMediaList(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!Xu.image_url)return;if(this.updatingMediaList)return;if(!t&&(new Date).getTime()-this.lastMediaListUpdate<1e3*Xu.media_list_update_interval)return;const r=this;let i=null;const o=Ch();if("unsplash-api"==o)i=r.updateMediaListFromUnsplashAPI;else if("immich-api"==o)i=r.updateMediaListFromImmichAPI;else{if("media-source"!=o){let t=Xu.image_url;return"iframe"==o?t=t.replace(/^iframe\+/,""):"embed"==o&&(t=t.replace(/^embed\+/,"")),this.mediaList=[t],void(e&&e())}i=r.updateMediaListFromMediaSource}this.updatingMediaList=!0,this.lastMediaListUpdate=Date.now();try{await i.bind(r)(),mh.debug("Media list from ".concat(o," is now:"),r.mediaList),e&&e()}catch(t){const i=3,a=3e3;if(mh.warn("Failed to update media list from ".concat(o,":"),t),nr.updateMediaList(e,!0,n+1),a);else{const e="Failed to update media list from ".concat(Xu.image_url," after ").concat(i," retries: ").concat(t.message||fh(t));mh.error(e)}}this.updatingMediaList=!1}async findMedias(e){const t=this;mh.debug("findMedias: ".concat(e));const n=[];if(Xu.exclude_filenames)for(const e of Xu.exclude_filenames)n.push(new RegExp(e));try{const r=await t.hass.callWS({type:"media_source/browse_media",media_content_id:e});mh.debug("Found media entry",r);const i=r.children.map(async e=>{const r=e.media_content_id.replace(/^media-source:\/\/[^/]+/,"");for(const e of n)if(e.test(r))return null;return["image","video"].includes(e.media_class)?Xu.exclude_media_types&&Xu.exclude_media_types.includes(e.media_class)?null:e.media_content_id:"directory"==e.media_class?await t.findMedias(e.media_content_id):null});return(await Promise.all(i)).flat().filter(e=>null!==e)}catch(t){throw mh.warn("Error browsing media ".concat(e,":"),t),t}}async updateMediaListFromMediaSource(){const e=Xu.image_url,t=this;try{let n=await t.findMedias(e);n="random"==Xu.media_order?Ah(n):"random_but_synced"==Xu.media_order?Ah(n.slice().sort(),yh(vh)):n.sort(),n.length>Xu.media_list_max_size&&(mh.info("Using only ".concat(Xu.media_list_max_size," of ").concat(n.length," media items")),n=n.slice(0,Xu.media_list_max_size)),t.mediaList=n}catch(e){throw new Error("Failed to update image list from ".concat(Xu.image_url,": ").concat(e.message||fh(e)))}}async updateMediaListFromUnsplashAPI(){const e=[],t="".concat(Xu.image_url,"&count=30");mh.debug("Unsplash API request: ".concat(t));try{const n={method:"GET",headers:{Accept:"application/json"}};"undefined"!=typeof AbortSignal&&void 0!==AbortSignal.timeout&&(mh.debug("Using AbortSignal"),n.signal=AbortSignal.timeout(1e3*Xu.immich_api_request_timeout));const r=await fetch(t,n);if(!r.ok){const e=await r.text();throw new Error("Unsplash API request failed: ".concat(r.status," ").concat(r.statusText," - ").concat(e))}const i=await r.json();mh.debug("Got Unsplash API response"),i.forEach(t=>{mh.debug(t);const n="".concat(t.urls.raw,"&w=${width}&h=${height}&auto=format");e.push(n),rh(n,t)}),this.mediaList=e}catch(e){if("AbortError"===e.name)throw new Error("Unsplash API request timed out: ".concat(t));throw e}}async _immichFetch(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i={headers:{"x-api-key":t,"Content-Type":"application/json",Accept:"application/json"}},o=n(n({},i),r);o.headers=n(n({},i.headers),r.headers),"undefined"!=typeof AbortSignal&&void 0!==AbortSignal.timeout&&(mh.debug("Using AbortSignal"),o.signal=AbortSignal.timeout(1e4)),mh.debug("Immich API request: ".concat(e));try{const t=await fetch(e,o);if(!t.ok){const e=await t.text();throw new Error("Immich API request failed: ".concat(t.status," ").concat(t.statusText," - ").concat(e))}return await t.json()}catch(t){if("AbortError"===t.name)throw new Error("Immich API request timed out: ".concat(e));throw t}}async updateMediaListFromImmichAPI(){if(!Xu.immich_api_keys||!Xu.immich_api_keys.length)throw new Error("No immich_api_key configured");const e=this,t=this.screensaverContainer.clientWidth>=this.screensaverContainer.clientHeight?"landscape":"portrait";let n=Xu.exclude_media_orientation;"auto"==n&&(n="landscape"==t?"portrait":"landscape"),mh.debug("config.exclude_media_orientation=".concat(Xu.exclude_media_orientation,", screenOrientation=").concat(t,", exclude_media_orientation=").concat(n));let r=[];const i={},o=Xu.image_url.replace(/^immich\+/,""),a=[];if(Xu.exclude_filenames)for(const e of Xu.exclude_filenames)a.push(new RegExp(e));function s(e){return null!=e.width&&null!=e.height?{width:e.width,height:e.height}:function(e){if(null==e||!e.exifImageWidth||null==e||!e.exifImageHeight)return null;let t=e.exifImageWidth,n=e.exifImageHeight;if(e.orientation){const r=Number(e.orientation);[5,6,7,8,90,-90].includes(r)&&([t,n]=[n,t])}return{width:t,height:n}}(e.exifInfo)}function c(e){const t=s(e);return t?t.width>=t.height?"landscape":"portrait":null}async function l(t,s){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;await async function(t,r){const i=Xu.immich_exclude_tag_names&&Xu.immich_exclude_tag_names.length,a=!!n;for(let n=0;n{var n;const s="image"===(null===(n=t.type)||void 0===n?void 0:n.toLowerCase()),c=s&&!0!==t.isEdited&&(null==t.width||null==t.height||void 0===t.isEdited),l=s&&a&&(null==t.width||null==t.height);if(!t.exifInfo||i&&!t.tags||l||c){mh.debug("Fetching asset info for ".concat(t.id));const n=await e._immichFetch("".concat(o,"/assets/").concat(t.id),r);t.exifInfo=n.exifInfo,t.tags=(n.tags||[]).map(e=>e.value),t.width=n.width,t.height=n.height,t.isEdited=n.isEdited}}))}}(t,s);for(const e of t){mh.debug("Processing immich asset",e);const t=e.type.toLowerCase();if(!["image","video"].includes(t)){mh.debug("Neither image nor video, skipping");continue}if(Xu.exclude_media_types&&Xu.exclude_media_types.includes(t)){mh.debug('Media type "'.concat(t,'" excluded'));continue}let u=!1;for(const t of a)t.test(e.originalFileName)&&(mh.debug('Media item excluded by regex "'.concat(t,'"')),u=!0);if(u)continue;if(Xu.immich_exclude_tag_names&&Xu.immich_exclude_tag_names.length){const t=e.tags.filter(e=>Xu.immich_exclude_tag_names.includes(e));if(t.length>0){mh.debug("Media item excluded due to tag(s): ".concat(t.join(", ")));continue}}if(n){const t=c(e);if(t===n){mh.debug('Media item with orientation "'.concat(t,'" excluded'));continue}}let h="original";"preview"==Xu.immich_resolution&&(h="video"==t?"video/playback":"thumbnail?size=preview");let d="".concat(o,"/assets/").concat(e.id,"/").concat(h);if("image"==t&&(d+=d.includes("?")?"&edited=true":"?edited=true"),r.indexOf(d)>=0)continue;r.push(d);const f=e.exifInfo||{};f.immichApiKey=s,f.mediaType=t,f.image={filename:e.originalFileName,folderName:l},i[d]=f}}try{for(const t of Xu.immich_api_keys)if(mh.debug("Using immich API key ".concat(t)),Xu.immich_persons&&Xu.immich_persons.length){mh.debug("Searching for assets based on persons");const n=Xu.immich_persons.map(e=>(Array.isArray(e)?e:[e]).map(e=>e.toLowerCase())),r={};let i=[],a=1,s=!0;for(;s;){const n=await e._immichFetch("".concat(o,"/people?size=1000&page=").concat(a),t);i=i.concat(n.people),s=n.hasNextPage,a++}i.forEach(e=>{e.name&&e.id&&(r[e.name.toLowerCase()]=e.id)});for(const i of n){const n=[];if(i.forEach(e=>{const t=r[e.toLowerCase()];t?n.push(t):mh.error("Person not found in immich: ".concat(e))}),n.length>0){mh.debug("Searching asset metadata for persons: ",n);let r=1;for(;;){mh.debug("Fetching asset metadata page ".concat(r));const a=await e._immichFetch("".concat(o,"/search/metadata"),t,{method:"POST",body:JSON.stringify({personIds:n,withExif:!0,page:r,size:1e3})});if(mh.debug("Got immich API response",a),!a.assets.count){if(1==r){const e="No media items found in immich that contain all these people: ".concat(i);mh.error(e)}break}if(await l(a.assets.items,t),!a.assets.nextPage)break;r=parseInt(a.assets.nextPage,10)}}}}else if(Xu.immich_memories){mh.debug("Fetching immich memories (on_this_day)");const n=await e._immichFetch("".concat(o,"/memories?type=on_this_day"),t);mh.debug("Got immich API response",n);const r=new Date,i=n.filter(e=>{const t=new Date(e.showAt),n=new Date(e.hideAt);return r>=t&&r<=n});mh.debug("Found ".concat(i.length," visible memories")),await Promise.all(i.map(async e=>{mh.debug("Processing memory:",e),await l(e.assets,t)}))}else if(Xu.immich_favorites){mh.debug("Search for favorites in asset metadata");let n=1;for(;;){mh.debug("Fetching asset metadata page ".concat(n));const r=await e._immichFetch("".concat(o,"/search/metadata"),t,{method:"POST",body:JSON.stringify({isFavorite:!0,withExif:!0,page:n,size:1e3})});if(mh.debug("Got immich API response",r),!r.assets.count){if(1==n){const e="No favorite media items found in immich";mh.error(e)}break}if(await l(r.assets.items,t),!r.assets.nextPage)break;n=parseInt(r.assets.nextPage,10)}}else if(Xu.immich_tag_names&&Xu.immich_tag_names.length){mh.debug("Searching for assets based on tag names");const n=Xu.immich_tag_names.map(e=>e.toLowerCase());mh.debug("Fetching immich tags");const r=await e._immichFetch("".concat(o,"/tags"),t);mh.debug("Got immich API response",r);const i=r.filter(e=>{const t=n.includes(e.name.toLowerCase());return mh.debug("".concat(t?"Adding":"Skipping"," tag: ").concat(e.name)),t}).map(e=>e.id);if(i.length>0){mh.debug("Searching asset metadata for tags: ",i);let r=1;for(;;){mh.debug("Fetching asset metadata page ".concat(r));const a=await e._immichFetch("".concat(o,"/search/metadata"),t,{method:"POST",body:JSON.stringify({tagIds:i,withExif:!0,page:r,size:1e3})});if(mh.debug("Got immich API response",a),!a.assets.count){if(1==r){const e="No media items found in immich that contain these tags: ".concat(n);mh.error(e)}break}if(await l(a.assets.items,t),!a.assets.nextPage)break;r=parseInt(a.assets.nextPage,10)}}else{const e="No matching immich tags found or selected.";mh.error(e)}}else{mh.debug("Searching for assets based on albums");const n=(Xu.immich_album_names||[]).map(e=>e.toLowerCase());mh.debug("Fetching immich albums (shared=".concat(Xu.immich_shared_albums,")"));const r=await e._immichFetch("".concat(o,"/server/version"),t);mh.debug("Immich server version:",r);const i=r.major<3?"shared":"isShared",a=await e._immichFetch("".concat(o,"/albums?").concat(i,"=").concat(Xu.immich_shared_albums),t);mh.debug("Got immich API response",a);const s=a.filter(e=>{const t=!n.length||n.includes(e.albumName.toLowerCase());return mh.debug("".concat(t?"Adding":"Skipping"," album: ").concat(e.albumName)),t});if(s.length>0)for(const n of s){mh.debug("Fetching assets for album: ",n.albumName);let r=1;for(;;){const i=await e._immichFetch("".concat(o,"/search/metadata"),t,{method:"POST",body:JSON.stringify({albumIds:[n.id],withExif:!0,page:r})});if(mh.debug("Got immich album assets (page ".concat(r,")"),i),await l(i.assets.items,t,n.albumName),!i.assets.nextPage)break;r=parseInt(i.assets.nextPage,10)}}else mh.debug("No matching immich albums found or selected.")}!function(){if(0==r.length){const e="No matching media assets found";mh.error(e)}r="random"==Xu.media_order?Ah(r):"random_but_synced"==Xu.media_order?Ah(r.slice().sort(),yh(vh)):r.sort(),r.length>Xu.media_list_max_size&&(mh.info("Using only ".concat(Xu.media_list_max_size," of ").concat(r.length," media items")),r=r.slice(0,Xu.media_list_max_size)),r.forEach(e=>{rh(e,i[e])}),e.mediaList=r}()}catch(e){throw mh.error("Immich API processing failed:",e),e}}fillPlaceholders(e){const t=this.screensaverContainer.clientWidth,n=this.screensaverContainer.clientHeight,r=Date.now(),i=Math.floor(r/1e3);return e=(e=(e=(e=e.replace(/\${width}/g,t)).replace(/\${height}/g,n)).replace(/\${timestamp_ms}/g,r)).replace(/\${timestamp}/g,i)}async updateMediaFromUrl(e,t){var n=this;let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];Xu.force_load_media_with_fetch&&(o=!0);const a=async e=>{const n=e.tagName.toLowerCase(),r={img:"load",video:"loadeddata",iframe:"load",embed:"load"}[n];if(!r)throw new Error('Unsupported element tag "'.concat(e.tagName,'"'));const a=new Promise((i,o)=>{const a=()=>{e.onerror=null,e.removeEventListener(r,s)},s=async()=>{if(a(),"img"===n&&"function"==typeof e.decode)try{await e.decode()}catch(e){mh.debug('Failed to pre-decode loaded image "'.concat(t,'":'),e)}i()};e.addEventListener(r,s),e.onerror=()=>{a(),o(new Error("Failed to load ".concat(e.tagName,' "').concat(t,'"')))}});if(o)if(Xu.stream_load_media)fetch(t,{headers:i}).then(n=>{if(!n.ok)throw new Error("Failed to load ".concat(e.tagName,' "').concat(t,'": ').concat(n));if(!n.body)throw new Error("Failed to load ".concat(e.tagName,' "').concat(t,'": empty body'));const r=n.body.getReader();return new ReadableStream({start:e=>function t(){return r.read().then(n=>{let{done:r,value:i}=n;if(!r)return e.enqueue(i),t();e.close()})}()})}).then(e=>new Response(e)).then(e=>e.blob()).then(t=>{"string"==typeof e.src&&e.src.startsWith("blob:")&&URL.revokeObjectURL(e.src),e.src=URL.createObjectURL(t)});else{i=i||{};const n=await fetch(t,{headers:i});if(mh.debug("Got respone",n),!n.ok)throw new Error("Failed to load ".concat(e.tagName,' "').concat(t,'": ').concat(n));"string"==typeof e.src&&e.src.startsWith("blob:")&&URL.revokeObjectURL(e.src);const r=await n.blob();e.src=URL.createObjectURL(r)}else e.src=t;return a},s=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;t||(t="img"===e.tagName.toLowerCase()?"video":"img");const i=n.replaceMediaElement(e,t);try{return await a(i),i}catch(e){throw r||e}},c=async(e,t)=>{try{return await a(e),e}catch(n){if(t)return await s(e,null,n);throw n}};return r?r===e.tagName.toLowerCase()?await c(e,!1):await s(e,r):await c(e,!0)}getNextMediaURL(){let e,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.mediaList.length?("random_but_synced"==Xu.media_order?e=Math.floor(Date.now()/(1e3*Xu.display_time))%this.mediaList.length:(e=this.mediaIndex,"forwards"==this.mediaListDirection?e++:e--,e>=this.mediaList.length?e=0:e<0&&(e=this.mediaList.length-1)),t&&(this.mediaIndex=e),this.mediaList[e]):null}async updateMediaFromMediaSource(e){var t;const n=await this.hass.callWS({type:"media_source/resolve_media",media_content_id:e.mediaUrl}),r=null===(t=n.mime_type)||void 0===t?void 0:t.match(/^(image|video)\//),i={image:"img",video:"video"}[null==r?void 0:r[1]]||null;let o=n.url;return o.startsWith("http://")||o.startsWith("https://")||(o="".concat(document.location.origin).concat(o)),mh.debug("Setting image src: ".concat(o)),e.mediaUrl=o,await this.updateMediaFromUrl(e,e.mediaUrl,i)}async updateMediaFromImmichAPI(e){const t=nh.get(e.mediaUrl)||{},n="video"==t.mediaType?"video":"img";return await this.updateMediaFromUrl(e,e.mediaUrl,n,{"x-api-key":t.immichApiKey},!0)}async updateMediaFromMediaEntity(e){const t=e.mediaUrl.match(/^media-entity-(image|video):\/\/(.*)/);if(!t)throw new Error('Invalid URL "'.concat(e.mediaUrl,'"'));const n=t[1],r=t[2],i=this.hass.states[r];if(!i)throw new Error('Entity "'.concat(r,'" not available'));function o(){"media_exif"in i.attributes?rh(e.infoCacheUrl,i.attributes.media_exif):rh(e.infoCacheUrl,i.attributes)}if(oh=i.state,"video"==n)return e.infoCacheUrl=e.mediaUrl,o(),(e=this.replaceMediaElement(e,"ha-camera-stream")).style.visibility="hidden",Object.assign(e,{hass:this.__hass,stateObj:this.__hass.states[r],"allow-exoplayer":!1,controls:!1}),new Promise((t,n)=>{let r=0;e.addEventListener("load",async function e(i){const o=i.currentTarget;o.removeEventListener("load",e),await o.updateComplete;const[a,s]=_h(o);if(!a||!s)return r++,r<=20?void setTimeout(()=>e(i),100):void n(new Error("Failed to initialize camera stream player"));if(a.style.height="100%",s.autoplay=!1,s.muted=!1,s.volume=Xu.video_volume,s.style.maxHeight="100%",s.style.height="100%",s.readyState>=s.HAVE_ENOUGH_DATA)t(o);else{const e=()=>{s.removeEventListener("canplay",e),t(o)};s.addEventListener("canplay",e)}})});{if(!i.attributes||!i.attributes.entity_picture)throw new Error('Entity "'.concat(r,'" has no entity_picture attribute'));const t=i.attributes.entity_picture;let n=t.indexOf("?")>0?"&":"?";return n+=this.fillPlaceholders("width=${width}&height=${height}&ts=${timestamp_ms}"),e.mediaUrl=t+n,e.infoCacheUrl=e.mediaUrl,o(),await this.updateMediaFromUrl(e,e.mediaUrl,"img",null,!0)}}async updateMediaFromUnsplashAPI(e){const t=nh.get(e.mediaUrl);return e.mediaUrl=this.fillPlaceholders(e.mediaUrl),t&&rh(e.mediaUrl,t),await this.updateMediaFromUrl(e,e.mediaUrl,"img")}async updateMediaFromMediaIframe(e){return await this.updateMediaFromUrl(e,e.mediaUrl,"iframe")}async updateMediaFromMediaEmbed(e){return await this.updateMediaFromUrl(e,e.mediaUrl,"embed")}async updateMediaFromOtherSrc(e){return e.mediaUrl=this.fillPlaceholders(e.mediaUrl),await this.updateMediaFromUrl(e,e.mediaUrl)}async updateMedia(e){if(Xu.show_images){this.updatingMedia=!0,e.updateMediaError=!1,e.style.visibility="hidden";try{if(e==this.getActiveMediaElement()){const e=this.getInactiveMediaElement();if("video"===e.tagName.toLowerCase())try{e.pause()}catch(e){mh.debug(e)}else if("ha-camera-stream"===e.tagName.toLowerCase())try{const[t,n]=_h(e);n&&n.pause(),t&&"function"==typeof t.stop&&t.stop()}catch(e){mh.debug(e)}}if(e.mediaUrl=this.getNextMediaURL(),!e.mediaUrl)return;if(e.infoCacheUrl=e.mediaUrl,e="media-source"==Ch()?await this.updateMediaFromMediaSource(e):"unsplash-api"==Ch()?await this.updateMediaFromUnsplashAPI(e):"immich-api"==Ch()?await this.updateMediaFromImmichAPI(e):Ch().startsWith("media-entity")?await this.updateMediaFromMediaEntity(e):"iframe"==Ch()?await this.updateMediaFromMediaIframe(e):"embed"==Ch()?await this.updateMediaFromMediaEmbed(e):await this.updateMediaFromOtherSrc(e)){e.style.visibility="visible";const t="video"===e.tagName.toLowerCase();t&&await new Promise((t,n)=>{if(e.readyState>=e.HAVE_ENOUGH_DATA)t();else{const r=()=>{e.removeEventListener("canplay",r),e.removeEventListener("error",i),t()},i=()=>{e.removeEventListener("canplay",r),e.removeEventListener("error",i),n(new Error("Video failed to load"))};e.addEventListener("canplay",r),e.addEventListener("error",i)}}),"image"===Xu.image_background&&this.loadBackgroundImage(e),!t&&Xu.show_image_info&&/.*\.jpe?g$/i.test(e.mediaUrl.split("?")[0].replace(/\/*$/,""))&&this.fetchEXIFInfo(e)}}catch(t){e.updateMediaError=!0,e.style.visibility="visible",mh.error("Failed to update media from ".concat(e.mediaUrl,":"),t)}finally{this.updatingMedia=!1}return e}}setMediaDimensions(){if(!Xu.calculate_media_size)return;const e=this.getActiveMediaElement(),t=this.getActiveMediaElement(!0);if(mh.debug("Setting dimensions for media element",e),!e.mediaUrl)return;const n=t.tagName.toLowerCase();let r=0,i=0;"video"===n?(r=t.videoWidth,i=t.videoHeight):"img"===n&&(r=t.naturalWidth,i=t.naturalHeight);const o=!r||!i||r>=i?Xu.image_fit_landscape:Xu.image_fit_portrait;e.style.position="absolute",e.style.left="0px",e.style.top="0px",e.style.objectFit=o;const a=this.screensaverContainer.clientWidth,s=this.screensaverContainer.clientHeight;let c=s,l=a,u=0,h=0,d=0,f=0;if(mh.debug("Available size is ".concat(a,"x").concat(s,", media size is ").concat(r,"x").concat(i)),r&&i){const e=a/r,t=s/i,n=a-r*t,m=s-i*e;mh.debug("Diff is ".concat(n,"x").concat(m)),"contain"==o&&n=m?(mh.debug("Using available width"),l=a,c=Math.floor(i*e),d="top"==Xu.media_vertical_align?0:"bottom"==Xu.media_vertical_align?s-c:Math.floor((c-s)/-2),u=Math.max(c-s,0)):(mh.debug("Using available height"),c=s,l=Math.floor(r*t),f="left"==Xu.media_horizontal_align?0:"right"==Xu.media_horizontal_align?a-l:Math.floor((l-a)/-2),h=Math.max(l-a,0))}else"iframe"!==n&&"embed"!==n&&mh.warn("Size not available for media element",t);mh.debug("Setting dimensions: size=".concat(l,"x").concat(c," - position=").concat(f,"x").concat(d," - hidden=").concat(h,"x").concat(u)),e.style.width="".concat(l,"px"),e.style.height="".concat(c,"px"),e.style.top="".concat(d,"px"),e.style.left="".concat(f,"px"),e.style.setProperty("--hidden-width",h),e.style.setProperty("--hidden-height",u)}startPlayingActiveMedia(){const e=this.getActiveMediaElement(),t=this.getActiveMediaElement(!0);if("function"!=typeof t.play)return void this.setDisplayTime();const n=()=>{t._wp_video_playback_listeners&&(Object.entries(t._wp_video_playback_listeners).forEach(e=>{let[n,r]=e;t.removeEventListener(n,r)}),t._wp_video_playback_listeners=null)};if(t.loop=Xu.video_loop&&t.duration{if(this.getActiveMediaElement()===t){if(t.currentTime>Xu.crossfade_time){t.duration-t.currentTime<=Xu.crossfade_time&&(this.switchActiveMedia("display_time_elapsed"),n())}}else n()},r=()=>{this.getActiveMediaElement()===t&&this.switchActiveMedia("media_end"),n()},i=()=>{n()};t._wp_video_playback_listeners={timeupdate:e,ended:r,pause:i},Object.entries(t._wp_video_playback_listeners).forEach(e=>{let[n,r]=e;t.addEventListener(n,r)})}t.play().catch(r=>{n(),e===this.getActiveMediaElement()&&mh.error('Failed to play media "'.concat(e.mediaUrl,'" (src=').concat(t.src,"):"),r)})}async switchActiveMedia(e){this.afterFadeoutTimer&&clearTimeout(this.afterFadeoutTimer);const t=Ch();if(t.startsWith("media-entity")){const t=Xu.image_url.replace(/^media-entity-(image|video):\/\//,""),n=this.hass.states[t];if(!n)return void mh.error('Media entity "'.concat(t,'" not available'));if(oh!=n.state)mh.debug("Media entity ".concat(t," state has changed"));else{if("entity_update"==e)return;if("start"==e||"user_action"==e)mh.debug("Media entity ".concat(t," state unchanged, but eventType = ").concat(e));else{if(!Xu.media_entity_load_unchanged)return this.lastMediaUpdate=Date.now(),this.isPaused&&(this.mediaTimeElapsedBeforePause=0),void this.restartProgressBarAnimation();mh.debug("Media entity ".concat(t," state unchanged, but media_entity_load_unchanged = true"))}}oh=n.state}this.lastMediaUpdate=Date.now(),this.isPaused&&(this.mediaTimeElapsedBeforePause=0);const n=this.getActiveMediaElement();if(("iframe"===t||"embed"===t)&&!Xu.iframe_load_unchanged&&this.getNextMediaURL(!1)==n.mediaUrl)return;let r=0;"start"!=e&&(Xu.crossfade_time>0&&(r=Math.round(1e3*Xu.crossfade_time)),"user_action"==e&&r>250&&(r=250));const i=this.getInactiveMediaElement(),o=await this.updateMedia(i);o&&this._switchActiveMedia(o,r)}_switchActiveMedia(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.lastMediaUpdate=Date.now(),this.isPaused&&(this.mediaTimeElapsedBeforePause=0),this.imageOneContainer.style.transition="opacity ".concat(t,"ms ease-in-out"),this.imageTwoContainer.style.transition="opacity ".concat(t,"ms ease-in-out");let n=this.imageOneContainer,r=this.imageTwoContainer,i=this.imageOne,o=this.imageTwo;e==this.imageOne&&(n=this.imageTwoContainer,r=this.imageOneContainer,i=this.imageTwo,o=this.imageOne),mh.debug("Switching active media to '".concat(r.id,"'")),1!=r.style.opacity&&(r.style.opacity=1),0!=n.style.opacity&&(n.style.opacity=0),"iframe"==o.tagName.toLowerCase()&&Xu.iframe_interaction?o.style.pointerEvents="auto":o.style.pointerEvents="none",this.setMediaDataInfo(),this.setMediaDimensions(),this.setImageURLEntityState(),this.startPlayingActiveMedia(),this.restartProgressBarAnimation(),this.restartKenBurnsEffect(),"video"===i.tagName.toLowerCase()&&(this.afterFadeoutTimer=setTimeout(function(){if("video"===i.tagName.toLowerCase())try{i.pause()}catch(e){mh.debug(e)}},t))}showMessage(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5e3;if(!this.messageContainer)return;const i=document.createElement("div");i.className="wallpanel-message ".concat(e);const o=document.createElement("div");o.className="wallpanel-message-title",o.textContent=t,i.appendChild(o);const a=document.createElement("div");a.className="wallpanel-message-text",a.textContent=n,i.appendChild(a),this.messageContainer.appendChild(i),requestAnimationFrame(()=>i.classList.add("show"));const s=this;setTimeout(()=>s.hideMessage(i),r)}hideMessage(e){e.classList.remove("show"),e.addEventListener("transitionend",()=>e.remove())}hideAllMessages(){const e=this.messageContainer.querySelectorAll(".wallpanel-message");if(!e.length)return!1;const t=this;return e.forEach(e=>t.hideMessage(e)),!0}setupScreensaver(){mh.debug("Setup screensaver"),Xu.keep_screen_on_time>0&&!this.screenWakeLock.enabled&&this.screenWakeLock.enable(),Xu.fullscreen&&!Oh()&&Ph()}async startScreensaver(){if(mh.debug("Start screensaver"),this.screensaverStartedAt=Date.now(),this.screensaverStoppedAt=null,this.currentWidth=this.screensaverContainer.clientWidth,this.currentHeight=this.screensaverContainer.clientHeight,this.setDefaultStyle(),wh(),!Sh())return mh.debug("Wallpanel not active, not starting screensaver"),this.screensaverStartedAt=null,void(this.screensaverStoppedAt=Date.now());if(this.getActiveMediaElement()==this.imageOne?(this.imageOneContainer.style.opacity=1,this.imageTwoContainer.style.opacity=0):(this.imageOneContainer.style.opacity=0,this.imageTwoContainer.style.opacity=1),this.setDisplayTime(),await this.switchActiveMedia("start"),this.setupScreensaver(),Xu.keep_screen_on_time>0){const e=this;setTimeout(function(){e.screensaverRunning()&&!e.screenWakeLock.enabled&&(mh.warning("Keep screen on will not work because the user didn't interact with the document first. https://goo.gl/xX8pDD"),e.showMessage("info","Keep screen on","Please tap the screen for a moment to keep it awake and prevent it from turning off.",15e3))},2e3)}this.lastMove=Date.now(),this.lastMediaUpdate=Date.now(),document.documentElement.style.overflow="hidden",this.isPaused=!1,this.mediaTimeElapsedBeforePause=0,this.pauseIndicator.style.display="none",this.createInfoBoxContent(),this.style.visibility="visible",this.style.opacity=1,this.style.pointerEvents="auto",this.setScreensaverEntityState(),(Xu.screensaver_start_navigation_path||Xu.screensaver_stop_close_browser_mod_popup)&&(this.screensaverStopNavigationPathTimeout=setTimeout(()=>{Xu.screensaver_start_navigation_path&&(eh=!0,function(e){(!(arguments.length>1&&void 0!==arguments[1])||arguments[1])&&!e.includes("?")&&(e+=window.location.search),history.pushState(null,"",e),ah.dispatchEvent(new Event("location-changed",{bubbles:!0,cancelable:!1,composed:!0}))}(Xu.screensaver_start_navigation_path),setTimeout(()=>{eh=!1},5e3)),Xu.screensaver_stop_close_browser_mod_popup&&Eh().forEach(e=>{e.closeDialog()})},1e3*(Xu.fade_in_time+1)))}screensaverRunning(){return Boolean(this.screensaverStartedAt)&&this.screensaverStartedAt>0}stopScreensaver(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;mh.debug("Stop screensaver"),this.screensaverStartedAt=null,this.screensaverStoppedAt=Date.now(),document.documentElement.style.removeProperty("overflow"),this.screensaverStopNavigationPathTimeout&&clearTimeout(this.screensaverStopNavigationPathTimeout),this.hideAllMessages(),this.debugBox.style.pointerEvents="none",this.style.transition=e>0?"opacity ".concat(Math.round(1e3*e),"ms ease-in-out"):"",this.style.opacity=0,this.style.visibility="hidden",this.style.pointerEvents="none",this.imageOneInfo.style.pointerEvents="none",this.imageTwoInfo.style.pointerEvents="none",this.infoBoxPosX.style.animation="",this.infoBoxPosY.style.animation="",this.idleSince=Date.now(),this.screenWakeLock.enabled&&this.screenWakeLock.disable(),setTimeout(this.setScreensaverEntityState.bind(this),25)}updateScreensaver(){const e=new Date,t=e.getTime();if(this.energyCollectionUpdateEnabled&&t-this.lastEnergyCollectionUpdate>=1e3*this.energyCollectionUpdateInterval&&(this.hass.connection._energy_wallpanel&&this.hass.connection._energy_wallpanel.refresh(),this.lastEnergyCollectionUpdate=t),this.infoBoxContentCreatedDate&&this.infoBoxContentCreatedDate.getDate()!=e.getDate()&&this.createInfoBoxContent(),Xu.info_move_interval>0&&t-this.lastMove>=1e3*Xu.info_move_interval&&("random"===Xu.info_move_pattern?this.randomMove():"corners"===Xu.info_move_pattern?this.moveAroundCorners():mh.error("Unknown info move type ".concat(Xu.info_move_pattern))),Xu.black_screen_after_time>0&&t-this.screensaverStartedAt>=1e3*Xu.black_screen_after_time)mh.debug("Setting screen to black"),this.screensaverOverlay.style.background="#000000";else if(Xu.show_images){let e;e="random_but_synced"==Xu.media_order?Math.floor(t/(1e3*Xu.display_time))!=Math.floor(this.lastMediaUpdate/(1e3*Xu.display_time)):t-this.lastMediaUpdate>=1e3*this.getDisplayTime(),!this.isPaused&&e&&this.switchActiveMedia("display_time_elapsed"),t-this.lastMediaListUpdate>=1e3*Xu.media_list_update_interval&&this.updateMediaList(null,!0),"visible"!=this.imageOneContainer.style.visibility&&(this.imageOneContainer.style.visibility="visible"),"visible"!=this.imageOne.style.visibility&&(this.imageOne.style.visibility="visible"),"visible"!=this.imageTwoContainer.style.visibility&&(this.imageTwoContainer.style.visibility="visible"),"visible"!=this.imageTwo.style.visibility&&(this.imageTwo.style.visibility="visible")}else"hidden"!=this.imageOneContainer.style.visibility&&(this.imageOneContainer.style.visibility="hidden"),"hidden"!=this.imageOne.style.visibility&&(this.imageOne.style.visibility="hidden"),"hidden"!=this.imageTwoContainer.style.visibility&&(this.imageTwoContainer.style.visibility="hidden"),"hidden"!=this.imageTwo.style.visibility&&(this.imageTwo.style.visibility="hidden");if(Xu.close_more_info_dialog_time>0){const e=this.getMoreInfoDialog();if(e){const t=new Date;this.moreInfoDialogOpenedAt?t-this.moreInfoDialogOpenedAt>=1e3*Xu.close_more_info_dialog_time&&e.close():this.moreInfoDialogOpenedAt=t}else this.moreInfoDialogOpenedAt=0}if(Xu.debug){let e="";const t={};for(const e in Xu)["profiles"].includes(e)?t[e]="...":t[e]=Xu[e];if(e+='
Download log
',e+="Version: ".concat(Gu,"
"),e+="User-Agent: ".concat(navigator.userAgent,"
"),e+="Config: ".concat(JSON.stringify(t),"
"),e+="Fullscreen: ".concat(Oh(),"
"),e+="Screensaver started at: ".concat(Ku.screensaverStartedAt,"
"),e+="Screen wake lock: enabled=".concat(this.screenWakeLock.enabled," native=").concat(this.screenWakeLock.nativeWakeLockSupported," lock=").concat(this.screenWakeLock._lock," player=").concat(this.screenWakeLock._player," error=").concat(this.screenWakeLock.error,"
"),this.screenWakeLock._player){const t=this.screenWakeLock._player;e+="Screen wake lock video: readyState=".concat(t.readyState," currentTime=").concat(t.currentTime," paused=").concat(t.paused," ended=").concat(t.ended,"
")}e+="Media list size: ".concat(this.mediaList.length,"
");const n=this.getActiveMediaElement();if(n){e+="Current media: ".concat(n.mediaUrl,"
");const t=nh.get(n.infoCacheUrl);t&&(e+="Media info: ".concat(JSON.stringify(t),"
"))}this.debugBox.innerHTML!==e&&(this.debugBox.innerHTML=e,this.debugBox.querySelector("#download_log").addEventListener("click",function(e){mh.downloadMessages(),e.preventDefault()})),this.debugBox.scrollTop=this.debugBox.scrollHeight}this.screenWakeLock.enabled&&Xu.keep_screen_on_time>0&&t-this.screensaverStartedAt>=1e3*Xu.keep_screen_on_time&&(mh.info("Disable wake lock after ".concat(Xu.keep_screen_on_time," seconds")),this.screenWakeLock.disable())}switchMediaDirection(e){this.mediaListDirection=e,this.switchActiveMedia("user_action")}async nextImage(){if(this.updatingMedia)return void mh.debug("Already switching media");mh.debug("Next image");const e=this.mediaListDirection;this.mediaListDirection="forwards";try{await this.switchActiveMedia("user_action")}finally{this.mediaListDirection=e}}async previousImage(){if(this.updatingMedia)return void mh.debug("Already switching media");mh.debug("Previous image");const e=this.mediaListDirection;this.mediaListDirection="backwards";try{await this.switchActiveMedia("user_action")}finally{this.mediaListDirection=e}}togglePlayPause(){if(mh.debug("Toggle play/pause"),this.screensaverRunning())if(this.isPaused)this.isPaused=!1,this.lastMediaUpdate=Date.now()-(this.mediaTimeElapsedBeforePause||0),this.pauseIndicator.style.display="none",this.progressBar.style.animationPlayState="running",this.startPlayingActiveMedia();else{this.isPaused=!0,this.mediaTimeElapsedBeforePause=Date.now()-this.lastMediaUpdate,this.lastMediaUpdate=Date.now(),this.pauseIndicator.style.display="block",this.progressBar.style.animationPlayState="paused";const e=this.getActiveMediaElement(!0);e&&"function"==typeof e.pause&&e.pause()}}setCameraMotionDetectionEntityState(e){const t=Xu.camera_motion_detection_set_entity;t&&this.__hass.states[t]&&(mh.debug("Updating camera motion detection entity",t,e),this.__hass.callService("input_boolean",e?"turn_on":"turn_off",{entity_id:t}).then(e=>{mh.debug(e)},e=>{mh.error("Failed to set camera motion detection entity state:",e)}))}motionDetected(){Xu.camera_motion_detection_stop_screensaver&&this.screensaverRunning()&&this.stopScreensaver(Xu.fade_out_time_motion_detected),this.setCameraMotionDetectionEntityState(!0)}motionStopped(){this.setCameraMotionDetectionEntityState(!1)}handleInteractionEvent(e){const t=["click","touchend"].includes(e.type),n=Date.now();this.idleSince=n;let r="";if("touchstart"==e.type)return void(e.touches&&e.touches[0]&&(this.touchStartX=e.touches[0].clientX,this.touchStartY=e.touches[0].clientY));if("touchend"==e.type&&this.touchStartX>=0&&e.changedTouches&&e.changedTouches[0]){const t=e.changedTouches[0].clientX-this.touchStartX,n=e.changedTouches[0].clientY-this.touchStartY,i=Math.max(20,.03*window.innerWidth);t>=i&&Math.abs(t)>Math.abs(n)?r="right":t<=-i&&Math.abs(t)>Math.abs(n)&&(r="left"),this.touchStartX=-1,this.touchStartY=-1}if(!this.screensaverRunning())return this.blockEventsUntil>n&&(t&&e.preventDefault(),e.stopImmediatePropagation()),void(t&&this.setupScreensaver());if(t&&this.hideAllMessages())return void(this.blockEventsUntil=n+1e3);let i=e.clientX,o=e.clientY;if(!i&&e.changedTouches&&e.changedTouches[0]&&(i=e.changedTouches[0].clientX),!o&&e.changedTouches&&e.changedTouches[0]&&(o=e.changedTouches[0].clientY),Xu.debug&&i&&i<100&&o&&o<100)return;const a=xh();if(a){const e=[a.shadowRoot.querySelector(".content"),a.shadowRoot.querySelector("ha-dialog-header")];for(let t=0;t=n.left&&i<=n.right&&o>=n.top&&o<=n.bottom)return void mh.debug("Event on browser mod popup:",e[t])}}if(Xu.iframe_interaction&&"iframe"==Ch())return;if(Xu.content_interaction){if(this.getMoreInfoDialog())return;let e=[];e=e.concat(this.__cards||[]),e=e.concat(this.__badges||[]),e=e.concat(this.__views||[]),e.push(this.shadowRoot.getElementById("wallpanel-screensaver-info-box-content")),e.push(this.shadowRoot.getElementById("wallpanel-screensaver-fixed-info-box-content")),"analyze"==Xu.image_info_template&&(e.push(this.imageOneInfo),e.push(this.imageTwoInfo));for(let t=0;t=n.left&&i<=n.right&&o>=n.top&&o<=n.bottom)return void mh.debug("Event on:",e[t])}}let s="";if(r)s="left"==r?"forwards":"backwards",e.stopImmediatePropagation();else if(e instanceof MouseEvent||"TouchEvent"in window&&e instanceof TouchEvent){let n=0,r=0;const a=this.screensaverContainer.getBoundingClientRect();if(i&&(n=(a.right-i)/this.screensaverContainer.clientWidth),o&&(r=(a.bottom-o)/this.screensaverContainer.clientHeight),mh.debug("Event position screensaver:",i,o,a.left,a.right,a.top,a.bottom),r>1||r<0||n>1||n<0)return;if(t&&e.preventDefault(),e.stopImmediatePropagation(),Xu.touch_zone_size_next_image>0&&n<=Xu.touch_zone_size_next_image/100){if(!t)return;s="forwards"}else if(Xu.touch_zone_size_previous_image>0&&n>=(100-Xu.touch_zone_size_previous_image)/100){if(!t)return;s="backwards"}else if(n>=.4&&n<=.6&&r<=.1){const e=new Date;return t&&e-this.lastClickTime<500?(this.clickCount+=1,3==this.clickCount&&(mh.purgeMessages(),Xu.debug=!Xu.debug,this.debugBox.style.visibility=Xu.debug?"visible":"hidden",this.debugBox.style.pointerEvents=Xu.debug?"auto":"none")):this.clickCount=1,void(this.lastClickTime=e)}}s?this.updatingMedia?mh.debug("Already switching media"):(mh.debug("Switching media, direction ".concat(s)),this.mediaListDirection!=s?this.switchMediaDirection(s):this.switchActiveMedia("user_action")):t&&!Xu.stop_screensaver_on_mouse_click||(this.blockEventsUntil=n+1e3*Xu.control_reactivation_time,this.stopScreensaver(Xu.fade_out_time_interaction))}}customElements.get("wallpanel-view-container")||customElements.define("wallpanel-view-container",r),customElements.get("wallpanel-view")||customElements.define("wallpanel-view",i),Zu=document.createElement("wallpanel-view-container"),Ku=document.createElement("wallpanel-view"),Zu.appendChild(Ku),sh.shadowRoot.appendChild(Zu)}function Lh(){mh.debug("activateWallpanel");let e=Xu.hide_toolbar,t=Xu.hide_toolbar_action_icons;if(e&&!Xu.hide_toolbar_on_subviews&&Qu){const n=Ih();if(n&&n.lovelace&&n.lovelace.rawConfig&&n.lovelace.rawConfig.views)for(let r=0;r{mh.debug("Successfully exited fullscreen")},e=>{mh.debug("Failed to exit fullscreen:",e)}):document.mozCancelFullScreen?document.mozCancelFullScreen():document.msRequestFullscreen?document.msRequestFullscreen():document.webkitExitFullscreen&&document.webkitExitFullscreen())}function Dh(){Ju&&Qu?(wh(),Sh()?Lh():Bh()):Bh()}function Uh(){if(mh.debug("Location changed from '".concat($u,"' to '").concat(window.location.href,"'")),window.location.href==$u)return;$u=window.location.href,Ku&&Ku.screensaverRunning&&Ku.screensaverRunning()&&Xu.stop_screensaver_on_location_change&&(eh?(eh=!1,Ku.screensaverStopNavigationPathTimeout&&clearTimeout(Ku.screensaverStopNavigationPathTimeout)):Ku.stopScreensaver());let e=null,t=null;const n=window.location.pathname.split("/");n.length>1&&(e=n[1],n.length>2&&(t=n[2]));const r=Ju&&e!=Ju;Ju=e,Qu=t,r?(mh.debug("Reset dashboard config"),Vu={},Fh(Dh)):Dh()}function Fh(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const n=Date.now();null===t&&(t=n);const r=(n-t)/1e3;if(ah=document.querySelector("body > home-assistant"),ah&&ah.shadowRoot&&(sh=ah.shadowRoot.querySelector("home-assistant-main")),!ah||!ah.shadowRoot||!sh)return r>=5?void mh.error("Wallpanel startup failed after ".concat(r," seconds, element home-assistant / home-assistant-main not found.")):void setTimeout(Fh,100,e,t);const i=Ih();if(!(i&&i.lovelace&&i.lovelace.config&&i.lovelace.config))return r>=5?void mh.info("No lovelace config found after ".concat(r," seconds")):void setTimeout(Fh,100,e,t);if(!customElements.get("hui-view"))return r>=5?void mh.error("Wallpanel startup failed after ".concat(r," seconds, hui-view not found.")):void setTimeout(Fh,100,e,t);if(!window.browser_mod){let n=Th(["wait_for_browser_mod_time"]).wait_for_browser_mod_time;if(void 0===n&&(n=qu.wait_for_browser_mod_time),r{let t=null;try{t=e.target.location.href}catch(e){mh.debug(e)}mh.debug("location-changed",t,e),setTimeout(Uh,20)}),window.navigation&&window.navigation.addEventListener("navigate",e=>{let t=null;try{t=e.destination.url}catch(e){mh.debug(e)}mh.debug("navigate",t,e),setTimeout(Uh,30)}),(ah.hass||ah.__hass).connection.subscribeEvents(function(e){mh.debug("lovelace_updated",e),(e.data.url_path?e.data.url_path:"lovelace")==Ju&&(ah.hass||ah.__hass).connection.sendMessagePromise({type:"lovelace/config",url_path:e.data.url_path}).then(e=>{if(Vu={},e.wallpanel)for(const t in e.wallpanel)(t in qu||t in Yu)&&(Vu[t]=e.wallpanel[t]);Dh()})},"lovelace_updated"),setTimeout(Uh,0)})}catch(e){mh.error(e.stack)}var Nh=!1,jh=function(e){return e instanceof jh?e:this instanceof jh?void(this.EXIFwrapped=e):new jh(e)},Wh=jh.Tags={36864:"ExifVersion",40960:"FlashpixVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",37121:"ComponentsConfiguration",37122:"CompressedBitsPerPixel",37500:"MakerNote",37510:"UserComment",40964:"RelatedSoundFile",36867:"DateTimeOriginal",36868:"DateTimeDigitized",37520:"SubsecTime",37521:"SubsecTimeOriginal",37522:"SubsecTimeDigitized",33434:"ExposureTime",33437:"FNumber",34850:"ExposureProgram",34852:"SpectralSensitivity",34855:"ISOSpeedRatings",34856:"OECF",37377:"ShutterSpeedValue",37378:"ApertureValue",37379:"BrightnessValue",37380:"ExposureBias",37381:"MaxApertureValue",37382:"SubjectDistance",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37396:"SubjectArea",37386:"FocalLength",41483:"FlashEnergy",41484:"SpatialFrequencyResponse",41486:"FocalPlaneXResolution",41487:"FocalPlaneYResolution",41488:"FocalPlaneResolutionUnit",41492:"SubjectLocation",41493:"ExposureIndex",41495:"SensingMethod",41728:"FileSource",41729:"SceneType",41730:"CFAPattern",41985:"CustomRendered",41986:"ExposureMode",41987:"WhiteBalance",41988:"DigitalZoomRation",41989:"FocalLengthIn35mmFilm",41990:"SceneCaptureType",41991:"GainControl",41992:"Contrast",41993:"Saturation",41994:"Sharpness",41995:"DeviceSettingDescription",41996:"SubjectDistanceRange",40965:"InteroperabilityIFDPointer",42016:"ImageUniqueID"},zh=jh.TiffTags={256:"ImageWidth",257:"ImageHeight",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer",40965:"InteroperabilityIFDPointer",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",274:"Orientation",277:"SamplesPerPixel",284:"PlanarConfiguration",530:"YCbCrSubSampling",531:"YCbCrPositioning",282:"XResolution",283:"YResolution",296:"ResolutionUnit",273:"StripOffsets",278:"RowsPerStrip",279:"StripByteCounts",513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength",301:"TransferFunction",318:"WhitePoint",319:"PrimaryChromaticities",529:"YCbCrCoefficients",532:"ReferenceBlackWhite",306:"DateTime",270:"ImageDescription",271:"Make",272:"Model",305:"Software",315:"Artist",33432:"Copyright"},Hh=jh.GPSTags={0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude",5:"GPSAltitudeRef",6:"GPSAltitude",7:"GPSTimeStamp",8:"GPSSatellites",9:"GPSStatus",10:"GPSMeasureMode",11:"GPSDOP",12:"GPSSpeedRef",13:"GPSSpeed",14:"GPSTrackRef",15:"GPSTrack",16:"GPSImgDirectionRef",17:"GPSImgDirection",18:"GPSMapDatum",19:"GPSDestLatitudeRef",20:"GPSDestLatitude",21:"GPSDestLongitudeRef",22:"GPSDestLongitude",23:"GPSDestBearingRef",24:"GPSDestBearing",25:"GPSDestDistanceRef",26:"GPSDestDistance",27:"GPSProcessingMethod",28:"GPSAreaInformation",29:"GPSDateStamp",30:"GPSDifferential"},Gh=jh.IFD1Tags={256:"ImageWidth",257:"ImageHeight",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",273:"StripOffsets",274:"Orientation",277:"SamplesPerPixel",278:"RowsPerStrip",279:"StripByteCounts",282:"XResolution",283:"YResolution",284:"PlanarConfiguration",296:"ResolutionUnit",513:"JpegIFOffset",514:"JpegIFByteCount",529:"YCbCrCoefficients",530:"YCbCrSubSampling",531:"YCbCrPositioning",532:"ReferenceBlackWhite"},qh=jh.StringValues={ExposureProgram:{0:"Not defined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},SensingMethod:{1:"Not defined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},SceneType:{1:"Directly photographed"},CustomRendered:{0:"Normal process",1:"Custom process"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},GainControl:{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},SubjectDistanceRange:{0:"Unknown",1:"Macro",2:"Close view",3:"Distant view"},FileSource:{3:"DSC"},Components:{0:"",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"}};function Yh(e){return!!e.exifdata}function Vh(e,t){function n(n){var r=Xh(n);e.exifdata=r||{};var i=function(e){var t=new DataView(e);if(255!=t.getUint8(0)||216!=t.getUint8(1))return!1;var n=2,r=e.byteLength,i=function(e,t){return 56===e.getUint8(t)&&66===e.getUint8(t+1)&&73===e.getUint8(t+2)&&77===e.getUint8(t+3)&&4===e.getUint8(t+4)&&4===e.getUint8(t+5)};for(;n")+8,l=(s=s.substring(s.indexOf("4?f:t+8,a=[],c=0;c4?f:t+8,d-1);case 3:if(1==d)return e.getUint16(t+8,!i);for(o=d>2?f:t+8,a=[],c=0;c>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:t+=String.fromCharCode(i);break;case 12:case 13:o=e[n++],t+=String.fromCharCode((31&i)<<6|63&o);break;case 14:o=e[n++],a=e[n++],t+=String.fromCharCode((15&i)<<12|(63&o)<<6|63&a)}return t}(r)}function ed(e,t){if("Exif"!=Kh(e,t,4))return!1;var n,r,i,o,a,s=t+6;if(18761==e.getUint16(s))n=!1;else{if(19789!=e.getUint16(s))return!1;n=!0}if(42!=e.getUint16(s+2,!n))return!1;var c=e.getUint32(s+4,!n);if(c<8)return!1;if((r=Qh(e,s,s+c,zh,n)).ExifIFDPointer)for(i in o=Qh(e,s,s+r.ExifIFDPointer,Wh,n)){switch(i){case"LightSource":case"Flash":case"MeteringMode":case"ExposureProgram":case"SensingMethod":case"SceneCaptureType":case"SceneType":case"CustomRendered":case"WhiteBalance":case"GainControl":case"Contrast":case"Saturation":case"Sharpness":case"SubjectDistanceRange":case"FileSource":o[i]=qh[i][o[i]];break;case"ExifVersion":case"FlashpixVersion":o[i]=String.fromCharCode(o[i][0],o[i][1],o[i][2],o[i][3]);break;case"ComponentsConfiguration":o[i]=qh.Components[o[i][0]]+qh.Components[o[i][1]]+qh.Components[o[i][2]]+qh.Components[o[i][3]]}r[i]=o[i]}if(r.GPSInfoIFDPointer)for(i in a=Qh(e,s,s+r.GPSInfoIFDPointer,Hh,n)){if("GPSVersionID"==i)try{a[i]=a[i][0]+"."+a[i][1]+"."+a[i][2]+"."+a[i][3]}catch(e){}r[i]=a[i]}return r.thumbnail=function(e,t,n,r){var i=function(e,t,n){var r=e.getUint16(t,!n);return e.getUint32(t+2+12*r,!n)}(e,t+n,r);if(!i)return{};if(i>e.byteLength)return{};var o=Qh(e,t,t+i,Gh,r);if(o.Compression)switch(o.Compression){case 6:if(o.JpegIFOffset&&o.JpegIFByteCount){var a=t+o.JpegIFOffset,s=o.JpegIFByteCount;o.blob=new Blob([new Uint8Array(e.buffer,a,s)],{type:"image/jpeg"})}break;case 1:mh.log("Thumbnail image format is TIFF, which is not implemented.");break;default:mh.log("Unknown thumbnail image format '%s'",o.Compression)}else 2==o.PhotometricInterpretation&&mh.log("Thumbnail image format is RGB, which is not implemented.");return o}(e,s,c,n),r}function td(e){var t={};if(1==e.nodeType){if(e.attributes.length>0){t["@attributes"]={};for(var n=0;n0)for(var n=0;n option.value); const ENTITY_ALIGNMENT_OPTIONS = [ { value: 'right', label: 'Right' }, { value: 'left', label: 'Left' }, @@ -2251,6 +2382,7 @@ const DIRECT_FORM_PATHS = [ 'layout.mode.icons', 'layout.mode.headings', 'layout.entities.type', + 'layout.entities.display', 'layout.entities.labels', 'layout.entities.separator', 'layout.entities.alignment', @@ -2310,6 +2442,16 @@ function deleteNested(obj, path) { } delete target[parts[0]]; } +function getSelectValue(ev) { + const target = ev.target; + const detail = ev.detail; + return (detail?.value ?? + detail?.item?.value ?? + target.selected?.value ?? + target.selected?.getAttribute?.('value') ?? + target.value ?? + ''); +} function isModeEnabled(config, type, adapter) { const control = config.control; if (control === false) @@ -2596,6 +2738,15 @@ function buildSchema(config, hass) { }, }, }, + { + name: 'layout.entities.display', + selector: { + select: { + mode: 'dropdown', + options: ENTITY_DISPLAY_SELECT_OPTIONS, + }, + }, + }, { name: 'layout.entities.labels', selector: { boolean: {} } }, { name: 'layout.entities.separator', selector: { boolean: {} } }, { @@ -2764,6 +2915,7 @@ class SimpleThermostatEditor extends i$1 { 'label.state': this.config.label?.state ?? '', 'label.setpoint': this.config.label?.setpoint ?? '', 'layout.entities.type': this.config.layout?.entities?.type ?? 'table', + 'layout.entities.display': this.config.layout?.entities?.display ?? '', 'layout.entities.labels': this.config.layout?.entities?.labels !== false, 'layout.entities.separator': this.config.layout?.entities?.separator !== false, 'layout.entities.alignment': this.config.layout?.entities?.alignment ?? 'right', @@ -2874,6 +3026,9 @@ class SimpleThermostatEditor extends i$1 { _getExtraEntities() { return Array.isArray(this.config.entities) ? this.config.entities : []; } + _getFooterRows() { + return Array.isArray(this.config.footer) ? this.config.footer : []; + } _commitEntityRows(entities) { const copy = cloneDeep(this.config); if (entities.length > 0) @@ -2894,6 +3049,16 @@ class SimpleThermostatEditor extends i$1 { if (entityIndex !== index) return entity; const next = { ...entity }; + if (field === 'display') { + if (typeof value === 'string' && + ENTITY_DISPLAY_VALUES.includes(value)) { + next.display = value; + } + else { + delete next.display; + } + return next; + } if (typeof value === 'string' && value) next[field] = value; else @@ -2902,6 +3067,34 @@ class SimpleThermostatEditor extends i$1 { }); this._commitEntityRows(entities); } + _commitFooterRows(footer) { + const copy = cloneDeep(this.config); + if (footer.length > 0) + copy.footer = footer; + else + delete copy.footer; + this.config = copy; + fireEvent(this, 'config-changed', { config: copy }); + } + _addFooterRow() { + this._commitFooterRows([...this._getFooterRows(), { entity: '' }]); + } + _removeFooterRow(index) { + this._commitFooterRows(this._getFooterRows().filter((_, footerIndex) => footerIndex !== index)); + } + _updateFooterRow(index, field, value) { + const footer = this._getFooterRows().map((row, footerIndex) => { + if (footerIndex !== index) + return row; + const next = { ...row }; + if (typeof value === 'string' && value) + next[field] = value; + else + delete next[field]; + return next; + }); + this._commitFooterRows(footer); + } _renderExtraEntityRows() { const entities = this._getExtraEntities(); return b ` @@ -2936,6 +3129,21 @@ class SimpleThermostatEditor extends i$1 { .value=${entity.icon ?? ''} @value-changed=${(ev) => this._updateEntityRow(index, 'icon', ev.detail.value)} > + this._updateEntityRow(index, 'display', getSelectValue(ev))} + @selected=${(ev) => this._updateEntityRow(index, 'display', getSelectValue(ev))} + @change=${(ev) => this._updateEntityRow(index, 'display', getSelectValue(ev))} + > + Default + ${ENTITY_DISPLAY_OPTIONS.map((option) => b ` + + ${option.label} + + `)} + this._removeEntityRow(index)}> Remove @@ -2944,6 +3152,48 @@ class SimpleThermostatEditor extends i$1 { `; } + _renderFooterRows() { + const footer = this._getFooterRows(); + return b ` +
+
+
+

Footer controls

+

Add switch-style controls shown below the mode rows.

+
+ Add control +
+ + ${footer.length === 0 + ? b `

+ No footer controls configured. +

` + : footer.map((row, index) => b ` +
+ this._updateFooterRow(index, 'entity', ev.detail.value)} + > + this._updateFooterRow(index, 'name', ev.target.value)} + > + this._updateFooterRow(index, 'icon', ev.detail.value)} + > + this._removeFooterRow(index)}> + Remove + +
+ `)} +
+ `; + } render() { if (!this.hass || !this.config) return b ``; @@ -2958,6 +3208,7 @@ class SimpleThermostatEditor extends i$1 { > ${this._renderExtraEntityRows()} + ${this._renderFooterRows()}
+
+
+ Selector style + Choose the normal arrow/menu header or visible tab + buttons. +
+
+ ${this.renderSelectorStyleOption('Header navigation', 'header', (selector.style ?? DEFAULT_SELECTOR$1.style) === 'header')} + ${this.renderSelectorStyleOption('Tabbed buttons', 'tabs', selector.style === 'tabs')} +
+
${this.renderOption('Follow active device', 'Switch to a card when its mode or on/off activity changes.', this.isAutoSelectEnabled(), (checked) => this.updateAutoSelect(checked))} ${this.renderOption('Remember selection', 'Keep the last selected card after the dashboard reloads.', this.config.remember_selection !== false, (checked) => this.updateRememberSelection(checked))} ${this.renderOption('Show icons', 'Show each card icon in the selector and menu.', selector.icons !== false, (checked) => this.updateSelector('icons', checked))} @@ -3698,6 +4004,7 @@ function parseFaults(config, hass) { } const DEFAULT_SELECTOR = { + style: 'header', icons: true, names: true, states: false, @@ -3707,7 +4014,7 @@ const DEFAULT_AUTO_SELECT_MANUAL_PAUSE_MS = 30000; function getDomain(entityId) { return entityId.split('.')[0]; } -function safeClass$2(value) { +function safeClass$3(value) { return typeof value === 'string' ? value.replace(/[^a-z0-9_-]/gi, '') : ''; } function getCardStyle$1(entityDomain, attributes = {}) { @@ -3807,6 +4114,171 @@ class SimpleThermostatGroup extends i$1 { transform: translateY(var(--st-group-header-top-buffer, 2px)); } + .group-selector.tabs { + display: block; + padding: calc(var(--st-spacing, var(--st-default-spacing, 4px)) * 3) + calc(var(--st-spacing, var(--st-default-spacing, 4px)) * 3) 0; + height: auto; + transform: translateY(var(--st-group-header-top-buffer, 2px)); + } + + .group-tabs { + display: grid; + grid-template-columns: repeat( + auto-fit, + minmax(var(--st-group-tab-min-width, 120px), 1fr) + ); + gap: calc(var(--st-spacing, var(--st-default-spacing, 4px)) * 2); + min-width: 0; + } + + .group-tab { + appearance: none; + border: 0; + border-radius: var(--st-group-tab-radius, 10px); + min-width: 0; + min-height: var(--st-group-tab-height, 46px); + padding: 7px 12px; + display: inline-flex; + align-items: center; + justify-content: center; + gap: 8px; + color: var(--st-group-tab-color, var(--primary-text-color)); + background: var( + --st-group-tab-background, + color-mix(in srgb, var(--primary-text-color) 12%, transparent) + ); + font: inherit; + font-weight: 600; + line-height: 1.15; + cursor: pointer; + transition: + background 160ms var(--st-motion-ease, ease), + color 160ms var(--st-motion-ease, ease), + opacity 160ms var(--st-motion-ease, ease); + } + + .group-tab:hover, + .group-tab:focus-visible { + background: var( + --st-group-tab-hover-background, + color-mix(in srgb, currentColor 22%, transparent) + ); + } + + .group-tab:focus-visible { + outline: 2px solid var(--primary-color); + outline-offset: 2px; + } + + .group-tab.selected { + color: var(--st-group-tab-selected-color, #fff); + background: var( + --st-group-tab-selected-background, + var(--primary-color) + ); + } + + .group-tab ha-icon { + --mdc-icon-size: 21px; + --iron-icon-width: 21px; + --iron-icon-height: 21px; + flex: 0 0 auto; + } + + .group-tab-labels { + display: grid; + min-width: 0; + gap: 1px; + text-align: center; + } + + .group-tab-name, + .group-tab-state { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + + .group-tab-state { + color: currentColor; + opacity: 0.78; + font-size: var(--ha-font-size-xs, 11px); + font-weight: 500; + } + + .group-tab.state-off { + --st-group-tab-background: color-mix( + in srgb, + var(--state-icon-color, var(--secondary-text-color)) 20%, + transparent + ); + --st-group-tab-color: var(--secondary-text-color); + } + + .group-tab.cooling, + .group-tab.state-cool { + --st-group-tab-background: color-mix( + in srgb, + var(--state-climate-cool-color, var(--cool-color, #2b9af9)) 22%, + transparent + ); + --st-group-tab-color: var( + --state-climate-cool-color, + var(--cool-color, #2b9af9) + ); + --st-group-tab-selected-background: var( + --state-climate-cool-color, + var(--cool-color, #2b9af9) + ); + } + + .group-tab.heating, + .group-tab.state-heat { + --st-group-tab-background: color-mix( + in srgb, + var(--state-climate-heat-color, var(--heat-color, #ff8100)) 22%, + transparent + ); + --st-group-tab-color: var( + --state-climate-heat-color, + var(--heat-color, #ff8100) + ); + --st-group-tab-selected-background: var( + --state-climate-heat-color, + var(--heat-color, #ff8100) + ); + } + + .group-tab.drying, + .group-tab.state-dry { + --st-group-tab-background: color-mix( + in srgb, + var(--state-climate-dry-color, var(--dry-color, #efbd07)) 24%, + transparent + ); + --st-group-tab-color: var( + --state-climate-dry-color, + var(--dry-color, #efbd07) + ); + --st-group-tab-selected-background: var( + --state-climate-dry-color, + var(--dry-color, #efbd07) + ); + } + + .group-tab.domain-fan:not(.state-off), + .group-tab.humidifying { + --st-group-tab-background: color-mix( + in srgb, + var(--primary-color) 22%, + transparent + ); + --st-group-tab-color: var(--primary-color); + --st-group-tab-selected-background: var(--primary-color); + } + .group-title { flex: 1 1 auto; min-width: 0; @@ -4444,13 +4916,27 @@ class SimpleThermostatGroup extends i$1 { const classes = [ 'group-card', 'group-shell', - `domain-${safeClass$2(domain)}`, - `state-${safeClass$2(state.state)}`, - safeClass$2(action), - unavailable && safeClass$2(state.state), + `domain-${safeClass$3(domain)}`, + `state-${safeClass$3(state.state)}`, + safeClass$3(action), + unavailable && safeClass$3(state.state), ].filter(Boolean); return classes.join(' '); } + getTargetClasses(target) { + const state = this.hass?.states?.[target.entity]; + if (!state) + return ''; + const domain = getDomain(state.entity_id); + const action = getEntityAction(state); + return [ + `domain-${safeClass$3(domain)}`, + `state-${safeClass$3(state.state)}`, + safeClass$3(action), + ] + .filter(Boolean) + .join(' '); + } getGroupCardStyle() { const state = this.getSelectedState(); if (!state) @@ -5069,8 +5555,8 @@ class SimpleThermostatGroup extends i$1 { : header.icon; if (!icon) return A; - const actionClass = action && action !== state.state ? ` ${safeClass$2(action)}` : ''; - const stateClass = safeClass$2(state.state); + const actionClass = action && action !== state.state ? ` ${safeClass$3(action)}` : ''; + const stateClass = safeClass$3(state.state); return b ` +
+ ${this.targets.map((target) => { + const label = this.getTargetLabel(target); + const icon = this.getTargetIcon(target); + const selected = target.entity === this.selectedEntity; + const stateLabel = selector.states + ? this.getTargetStateLabel(target) + : ''; + return b ` + + `; + })} +
+
+ `; + } renderSelector() { + if (this.config?.selector?.style === 'tabs') { + return this.renderTabSelector(); + } const target = this.getSelectedTarget(); const label = this.getTargetLabel(target); return b ` @@ -5309,7 +5854,7 @@ function formatNumber(number, { decimals = 1, fallback = 'N/A', locale } = {}) { }).format(value); } -function safeClass$1(value) { +function safeClass$2(value) { return String(value ?? '').replace(/[^a-z0-9_-]/gi, ''); } const SEMANTIC_KIND_PATTERNS = [ @@ -5366,7 +5911,7 @@ function getKindFromText(text, hass) { function getKindFromIcon(icon) { if (typeof icon !== 'string' || !icon) return ''; - const kind = safeClass$1(icon.replace(/^[a-z]+:/, '')); + const kind = safeClass$2(icon.replace(/^[a-z]+:/, '')); const semanticKind = getKindFromText(kind.replace(/-/g, ' ')); if (semanticKind) return semanticKind; @@ -5603,7 +6148,7 @@ function safeCssValue(value) { return String(value ?? '') .replace(/url\s*\([^)]*\)/gi, '') .replace(/expression\s*\([^)]*\)/gi, '') - .replace(/javascript:/gi, '') + .replace(/(?:javascript|data|vbscript)\s*:/gi, '') .replace(/[<>"'`;{}]/g, ''); } squirrelly_minExports.filters.define('icon', (icon) => ``); @@ -5790,6 +6335,8 @@ const TOGGLE_DOMAINS = [ 'light', 'switch', ]; +const BUTTON_DOMAINS = ['button', 'input_button', 'script', 'scene']; +const DISPLAY_VALUES = ['row', 'auto', 'button', 'toggle', 'chip']; function toggleEntity(hass, entityId, checked) { const service = `turn_${checked ? 'on' : 'off'}`; if (typeof hass.performAction === 'function') { @@ -5802,9 +6349,28 @@ function toggleEntity(hass, entityId, checked) { hass.callService('homeassistant', service, { entity_id: entityId }); } } -function safeClass(value) { +function safeClass$1(value) { return String(value ?? '').replace(/[^a-z0-9_-]/gi, ''); } +function callEntityAction(hass, entityId, domain) { + if (TOGGLE_DOMAINS.includes(domain)) { + const checked = hass.states?.[entityId]?.state !== 'on'; + toggleEntity(hass, entityId, checked); + return; + } + const service = domain === 'button' || domain === 'input_button' + ? 'press' + : 'turn_on'; + if (typeof hass.performAction === 'function') { + hass.performAction({ + action: `${domain}.${service}`, + data: { entity_id: entityId }, + }); + } + else { + hass.callService(domain, service, { entity_id: entityId }); + } +} function renderIconTemplate({ icon, state, attribute, hass, config, variables, localize, }) { if (typeof icon !== 'string' || !icon.includes('{{') || @@ -5839,10 +6405,36 @@ function renderHeadingTemplate({ heading, state, attribute, hass, config, variab localize, }).trim(); } +function resolveDisplay(display, domain) { + if (typeof display !== 'string' || !DISPLAY_VALUES.includes(display)) { + return 'row'; + } + if (display !== 'auto') + return display; + if (TOGGLE_DOMAINS.includes(domain)) + return 'toggle'; + if (BUTTON_DOMAINS.includes(domain)) + return 'button'; + return 'chip'; +} +function getEntityDisplayValue({ state, domain, hass, localize, }) { + if (domain === 'timer') { + return b ``; + } + if (typeof hass.formatEntityState === 'function') { + return hass.formatEntityState(state); + } + return localize + ? localize(state.state, `component.${domain}.state._.`) + : String(state.state); +} function renderInfoItem({ hide = false, hass, state, details, localize, openEntityPopover, }) { if (hide || typeof state === 'undefined') return; - const { type, heading, icon, unit, decimals, tooltip: configuredTooltip, entity, template, attribute, variables, config, separator = true, } = details; + const { type, heading, icon, unit, decimals, tooltip: configuredTooltip, entity, template, attribute, variables, config, separator = true, display, } = details; const renderedIcon = renderIconTemplate({ icon, state, @@ -5873,6 +6465,7 @@ function renderInfoItem({ hide = false, hass, state, details, localize, openEnti let entityDomain = ''; let entityState = ''; let isToggleEntity = false; + let usesCompactEntityDisplay = false; let valueCell; if (template && typeof state === 'object') { const value = renderTemplate({ @@ -5904,10 +6497,12 @@ function renderInfoItem({ hide = false, hass, state, details, localize, openEnti entityDomain = domain; entityState = state.state; isToggleEntity = TOGGLE_DOMAINS.includes(domain); + const displayMode = resolveDisplay(display, domain); const entityClasses = [ isToggleEntity && 'toggle-entity', - entityDomain && `domain-${safeClass(entityDomain)}`, - entityState && `state-${safeClass(entityState)}`, + entityDomain && `domain-${safeClass$1(entityDomain)}`, + entityState && `state-${safeClass$1(entityState)}`, + displayMode !== 'row' && `display-${displayMode}`, isToggleEntity && getToggleKindClass(getToggleKind({ icon: renderedIcon || state.attributes?.icon, @@ -5918,7 +6513,45 @@ function renderInfoItem({ hide = false, hass, state, details, localize, openEnti ] .filter(Boolean) .join(' '); - if (domain === 'timer') { + if (displayMode !== 'row') { + usesCompactEntityDisplay = true; + const supportsAction = isToggleEntity || BUTTON_DOMAINS.includes(domain); + const active = state.state === 'on'; + const actionLabel = typeof heading === 'string' + ? heading + : state.attributes?.friendly_name || state.entity_id; + const fallbackIcon = renderedIcon || state.attributes?.icon || (isToggleEntity + ? 'mdi:toggle-switch' + : BUTTON_DOMAINS.includes(domain) + ? 'mdi:gesture-tap-button' + : undefined); + const displayValue = getEntityDisplayValue({ + state, + domain, + hass, + localize, + }); + valueCell = b ` + + `; + } + else if (domain === 'timer') { valueCell = b `
`; } + if (usesCompactEntityDisplay) { + return valueCell; + } if (heading === false) { return valueCell; } @@ -6006,8 +6642,8 @@ function renderInfoItem({ hide = false, hass, state, details, localize, openEnti 'entity-heading', canOpenEntity && 'clickable', isToggleEntity && 'toggle-entity', - entityDomain && `domain-${safeClass(entityDomain)}`, - entityState && `state-${safeClass(entityState)}`, + entityDomain && `domain-${safeClass$1(entityDomain)}`, + entityState && `state-${safeClass$1(entityState)}`, isToggleEntity && getToggleKindClass(getToggleKind({ icon: renderedIcon || state?.attributes?.icon, @@ -6108,7 +6744,7 @@ function renderEntities({ _hide, entity, unit, hass, entities, config, localize, separator: showSeparator, }, }), - ...((entities ?? []).map(({ name, state, show, _hide_when_off, hide_when_off, ...rest }) => { + ...((entities ?? []).map(({ name, state, show, display, _hide_when_off, hide_when_off, ...rest }) => { const hideWhenOff = _hide_when_off === true || hide_when_off === true; return renderInfoItem({ hide: show === false || (hideWhenOff && entity.state === HVAC_MODES.OFF), @@ -6123,6 +6759,7 @@ function renderEntities({ _hide, entity, unit, hass, entities, config, localize, config, variables: config.variables, separator: showSeparator, + display: display ?? config?.layout?.entities?.display, }, }); }) || null), @@ -6130,6 +6767,35 @@ function renderEntities({ _hide, entity, unit, hass, entities, config, localize, return wrapEntities(config, entityHtml); } +const STACKABLE_MODES = new Set(['heat_cool', 'fan_only']); +function getModeLabelPresentation(modeValue, label, sparse) { + if (!label || !sparse) { + return { layout: 'inline', lines: label ? [label] : [] }; + } + const trimmed = label.trim(); + if (!trimmed) { + return { layout: 'inline', lines: [] }; + } + if (modeValue === 'heat_cool') { + const slashParts = trimmed.split(/\s*\/\s*/).filter(Boolean); + if (slashParts.length === 2 && + slashParts.every((part) => part.length > 0 && part.length <= 12)) { + return { layout: 'stacked', lines: slashParts }; + } + } + if (modeValue === 'fan_only') { + const wordParts = trimmed.split(/\s+/).filter(Boolean); + if (wordParts.length === 2 && + wordParts.every((part) => part.length > 0 && part.length <= 10)) { + return { layout: 'stacked', lines: wordParts }; + } + } + if (STACKABLE_MODES.has(modeValue) && trimmed.length > 10) { + return { layout: 'column', lines: [trimmed] }; + } + return { layout: 'inline', lines: [trimmed] }; +} + const CUSTOM_FAN_ICON_PATH = 'M13 19C13 17.59 13.5 16.3 14.3 15.28C14.17 14.97 14.03 14.65 13.86 14.34C14.26 14 14.57 13.59 14.77 13.11C15.26 13.21 15.78 13.39 16.25 13.67C17.07 13.25 18 13 19 13C20.05 13 21.03 13.27 21.89 13.74C21.95 13.37 22 12.96 22 12.5C22 8.92 18.03 8.13 14.33 10.13C14 9.73 13.59 9.42 13.11 9.22C13.3 8.29 13.74 7.24 14.73 6.75C17.09 5.57 17 2 12.5 2C8.93 2 8.14 5.96 10.13 9.65C9.72 9.97 9.4 10.39 9.21 10.87C8.28 10.68 7.23 10.25 6.73 9.26C5.56 6.89 2 7 2 11.5C2 15.07 5.95 15.85 9.64 13.87C9.96 14.27 10.39 14.59 10.88 14.79C10.68 15.71 10.24 16.75 9.26 17.24C6.9 18.42 7 22 11.5 22C12.31 22 13 21.78 13.5 21.41C13.19 20.67 13 19.86 13 19M12 13C11.43 13 11 12.55 11 12S11.43 11 12 11C12.54 11 13 11.45 13 12S12.54 13 12 13'; const CUSTOM_MODE_ICONS = { 'st:fan-speed-4': { @@ -6296,6 +6962,17 @@ function renderModeType({ state, entity, hass, mode: options, adapter, modeOptio (type === 'hvac' && list.length > 4) || (type === 'fan' && list.length > 4); const safeClass = (value) => String(value).replace(/[^a-z0-9_-]/gi, ''); + const renderModeLabel = (modeValue, label) => { + if (!label) + return null; + const presentation = getModeLabelPresentation(modeValue, label, sparseMainControls); + if (presentation.layout === 'stacked') { + return b ` + ${presentation.lines.map((line) => b `${line}`)} + `; + } + return b `${presentation.lines[0] ?? label}`; + }; return b `
${maybeRenderIcon(icon, iconConfigured)} - ${displayName - ? b `${displayName}` - : null} + ${renderModeLabel(String(value), displayName)}
`; })} @@ -6340,6 +7021,59 @@ function renderModeType({ state, entity, hass, mode: options, adapter, modeOptio `; } +const safeClass = (value) => String(value).replace(/[^a-z0-9_-]/gi, ''); +function renderFooter({ toggles, mainState, toggleFooterEntity, openEntityPopover, }) { + const visibleToggles = toggles.filter((toggle) => !(toggle.hide_when_off === true && mainState === HVAC_MODES.OFF)); + if (!visibleToggles.length) + return A; + return b ` + + `; +} + function parseSetpoints(setpoints, attributes, adapter = climateAdapter, entityState) { if (setpoints === false) { return {}; @@ -6401,6 +7135,9 @@ const CONTROL_METADATA_KEYS = ['entity', 'hide_when_off', 'hide_off_when_off']; function getConfiguredEntities(config) { return config.entities ?? []; } +function getConfiguredFooter(config) { + return Array.isArray(config.footer) ? config.footer : []; +} function shouldShowModeControl(type, modeOption, config) { const modeKey = String(modeOption); const configuredMode = getConfiguredModeValue(modeKey, config); @@ -6682,6 +7419,7 @@ class SimpleThermostat extends i$1 { this.modes = []; this._hass = {}; this.entities = []; + this.footer = []; this.showEntities = true; this.name = ''; this.stepSize = STEP_SIZE; @@ -6708,6 +7446,12 @@ class SimpleThermostat extends i$1 { entity_id: entityId, }); }; + this.toggleFooterEntity = (entityId, checked) => { + this._callAction(`homeassistant.turn_${checked ? 'on' : 'off'}`, { + entity_id: entityId, + }); + fireEvent(this, 'haptic', 'light'); + }; this.setMode = (type, mode) => { if (type && mode) { const adapter = getAdapter(this.config.entity); @@ -6856,6 +7600,7 @@ class SimpleThermostat extends i$1 { this._setpointDebounce = setpointDebounce; } this.entities = []; + this.footer = []; this.showEntities = true; this.toggleAttribute('embedded', this.config.embedded === true); if (this._hass?.states) { @@ -6978,6 +7723,20 @@ class SimpleThermostat extends i$1 { this.showEntities = true; this.entities = []; } + this.footer = getConfiguredFooter(this.config) + .map(({ entity, name, icon, hide_when_off }) => { + const state = hass.states?.[entity]; + if (!state) + return null; + return { + entity, + name, + icon, + hide_when_off, + state, + }; + }) + .filter((toggle) => !!toggle); } render({ _hide, _values, _updatingValues, config, entity } = this) { if (!config) { @@ -7019,9 +7778,12 @@ class SimpleThermostat extends i$1 { const unit = this.getUnit(); const entityDomain = config.entity.split('.')[0]; const setpointCount = Object.keys(_values).length; - const stepLayout = this.config.enhanced_visuals === false - ? (this.config?.layout?.step ?? 'column') - : (this.config?.layout?.step ?? 'row'); + const configuredStepLayout = this.config?.layout?.step; + const compactDualEntitySetpoints = !configuredStepLayout && this.showEntities && setpointCount > 1; + const stepLayout = configuredStepLayout ?? + (this.config.enhanced_visuals === false || compactDualEntitySetpoints + ? 'column' + : 'row'); const row = stepLayout === 'row'; const isUnavailable = ['unavailable', 'unknown'].includes(entity.state); const safeClass = (value) => typeof value === 'string' ? value.replace(/[^a-z0-9_-]/gi, '') : ''; @@ -7107,6 +7869,12 @@ class SimpleThermostat extends i$1 { ` : A} + ${renderFooter({ + toggles: this.footer, + mainState: entity.state, + toggleFooterEntity: this.toggleFooterEntity, + openEntityPopover: this.openEntityPopover, + })} `; } @@ -7291,8 +8059,16 @@ class SimpleThermostat extends i$1 { } return (mode.list ?? []).some(({ hide_when_off }) => !(hide_when_off === true && this.entity?.state === HVAC_MODES.OFF)); }).length ?? 0; + const footerRows = this.footer?.some(({ hide_when_off }) => !(hide_when_off === true && this.entity?.state === HVAC_MODES.OFF)) + ? 1 + : 0; const warningRows = this.stepSize < 1 && this.config.decimals === 0 ? 1 : 0; - return Math.max(1, headerRows + entityRows + setpointRows + modeRows + warningRows); + return Math.max(1, headerRows + + entityRows + + setpointRows + + modeRows + + footerRows + + warningRows); } getUnit() { if (['boolean', 'string'].includes(typeof this.config.unit)) { @@ -7325,6 +8101,9 @@ __decorate([ __decorate([ n$2() ], SimpleThermostat.prototype, "entities", void 0); +__decorate([ + n$2() +], SimpleThermostat.prototype, "footer", void 0); __decorate([ n$2() ], SimpleThermostat.prototype, "showEntities", void 0); diff --git a/www/community/simple-thermostat/simple-thermostat.debug.js.gz b/www/community/simple-thermostat/simple-thermostat.debug.js.gz index 8b43870e..eb6e7640 100644 Binary files a/www/community/simple-thermostat/simple-thermostat.debug.js.gz and b/www/community/simple-thermostat/simple-thermostat.debug.js.gz differ diff --git a/www/community/simple-thermostat/simple-thermostat.js b/www/community/simple-thermostat/simple-thermostat.js index 5cccb7d4..a15b6373 100644 --- a/www/community/simple-thermostat/simple-thermostat.js +++ b/www/community/simple-thermostat/simple-thermostat.js @@ -1,4 +1,4 @@ -!function(){const t={DEBUG:!1,BUILD_TIME:"2026-08-05, 05:24 p.m."};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,t)}catch(t){}globalThis.process={env:t}}();var t="simple-thermostat",e="4.2.0";function i(t,e,i,o){var a,r=arguments.length,n=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,o);else for(var s=t.length-1;s>=0;s--)(a=t[s])&&(n=(r<3?a(n):r>3?a(e,i,n):a(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n}"function"==typeof SuppressedError&&SuppressedError;const o=globalThis,a=o.ShadowRoot&&(void 0===o.ShadyCSS||o.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,r=Symbol(),n=new WeakMap;let s=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==r)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(a&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=n.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&n.set(e,t))}return t}toString(){return this.cssText}};const c=(t,...e)=>{const i=1===t.length?t[0]:e.reduce((e,i,o)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[o+1],t[0]);return new s(i,t,r)},l=a?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new s("string"==typeof t?t:t+"",void 0,r))(e)})(t):t,{is:d,defineProperty:h,getOwnPropertyDescriptor:u,getOwnPropertyNames:p,getOwnPropertySymbols:g,getPrototypeOf:m}=Object,f=globalThis,v=f.trustedTypes,y=v?v.emptyScript:"",_=f.reactiveElementPolyfillSupport,b=(t,e)=>t,w={toAttribute(t,e){switch(e){case Boolean:t=t?y:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},x=(t,e)=>!d(t,e),$={attribute:!0,type:String,converter:w,reflect:!1,useDefault:!1,hasChanged:x};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;let S=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=$){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),o=this.getPropertyDescriptor(t,i,e);void 0!==o&&h(this.prototype,t,o)}}static getPropertyDescriptor(t,e,i){const{get:o,set:a}=u(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:o,set(e){const r=o?.call(this);a?.call(this,e),this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??$}static _$Ei(){if(this.hasOwnProperty(b("elementProperties")))return;const t=m(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(b("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(b("properties"))){const t=this.properties,e=[...p(t),...g(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(l(t))}else void 0!==t&&e.push(l(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(a)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const i of e){const e=document.createElement("style"),a=o.litNonce;void 0!==a&&e.setAttribute("nonce",a),e.textContent=i.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$ET(t,e){const i=this.constructor.elementProperties.get(t),o=this.constructor._$Eu(t,i);if(void 0!==o&&!0===i.reflect){const a=(void 0!==i.converter?.toAttribute?i.converter:w).toAttribute(e,i.type);this._$Em=t,null==a?this.removeAttribute(o):this.setAttribute(o,a),this._$Em=null}}_$AK(t,e){const i=this.constructor,o=i._$Eh.get(t);if(void 0!==o&&this._$Em!==o){const t=i.getPropertyOptions(o),a="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:w;this._$Em=o;const r=a.fromAttribute(e,t.type);this[o]=r??this._$Ej?.get(o)??r,this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){const o=this.constructor,a=this[t];if(i??=o.getPropertyOptions(t),!((i.hasChanged??x)(a,e)||i.useDefault&&i.reflect&&a===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,i))))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:i,reflect:o,wrapped:a},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??e??this[t]),!0!==a||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(e=void 0),this._$AL.set(t,e)),!0===o&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t){const{wrapped:t}=i,o=this[e];!0!==t||this._$AL.has(e)||void 0===o||this.C(e,void 0,i,o)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}};S.elementStyles=[],S.shadowRootOptions={mode:"open"},S[b("elementProperties")]=new Map,S[b("finalized")]=new Map,_?.({ReactiveElement:S}),(f.reactiveElementVersions??=[]).push("2.1.1");const A=globalThis,k=t=>t,C=A.trustedTypes,E=C?C.createPolicy("lit-html",{createHTML:t=>t}):void 0,z="$lit$",T=`lit$${Math.random().toFixed(9).slice(2)}$`,O="?"+T,N=`<${O}>`,M=document,R=()=>M.createComment(""),j=t=>null===t||"object"!=typeof t&&"function"!=typeof t,P=Array.isArray,H="[ \t\n\f\r]",I=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,V=/-->/g,F=/>/g,L=RegExp(`>|${H}(?:([^\\s"'>=/]+)(${H}*=${H}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),D=/'/g,U=/"/g,W=/^(?:script|style|textarea|title)$/i,B=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),G=Symbol.for("lit-noChange"),q=Symbol.for("lit-nothing"),K=new WeakMap,Z=M.createTreeWalker(M,129);function J(t,e){if(!P(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==E?E.createHTML(e):e}const Y=(t,e)=>{const i=t.length-1,o=[];let a,r=2===e?"":3===e?"":"",n=I;for(let e=0;e"===c[0]?(n=a??I,l=-1):void 0===c[1]?l=-2:(l=n.lastIndex-c[2].length,s=c[1],n=void 0===c[3]?L:'"'===c[3]?U:D):n===U||n===D?n=L:n===V||n===F?n=I:(n=L,a=void 0);const h=n===L&&t[e+1].startsWith("/>")?" ":"";r+=n===I?i+N:l>=0?(o.push(s),i.slice(0,l)+z+i.slice(l)+T+h):i+T+(-2===l?e:h)}return[J(t,r+(t[i]||"")+(2===e?"":3===e?"":"")),o]};class X{constructor({strings:t,_$litType$:e},i){let o;this.parts=[];let a=0,r=0;const n=t.length-1,s=this.parts,[c,l]=Y(t,e);if(this.el=X.createElement(c,i),Z.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(o=Z.nextNode())&&s.length0){o.textContent=C?C.emptyScript:"";for(let i=0;iP(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==q&&j(this._$AH)?this._$AA.nextSibling.data=t:this.T(M.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:i}=t,o="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(J(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===o)this._$AH.p(e);else{const t=new tt(o,this),i=t.u(this.options);t.p(e),this.T(i),this._$AH=t}}_$AC(t){let e=K.get(t.strings);return void 0===e&&K.set(t.strings,e=new X(t)),e}k(t){P(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,o=0;for(const a of t)o===e.length?e.push(i=new et(this.O(R()),this.O(R()),this,this.options)):i=e[o],i._$AI(a),o++;o2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=q}_$AI(t,e=this,i,o){const a=this.strings;let r=!1;if(void 0===a)t=Q(this,t,e,0),r=!j(t)||t!==this._$AH&&t!==G,r&&(this._$AH=t);else{const o=t;let n,s;for(t=a[0],n=0;n{const o=i?.renderBefore??e;let a=o._$litPart$;if(void 0===a){const t=i?.renderBefore??null;o._$litPart$=a=new et(e.insertBefore(R(),t),t,void 0,i??{})}return a._$AI(t),a})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return G}};lt._$litElement$=!0,lt.finalized=!0,ct.litElementHydrateSupport?.({LitElement:lt});const dt=ct.litElementPolyfillSupport;dt?.({LitElement:lt}),(ct.litElementVersions??=[]).push("4.2.2");const ht={attribute:!0,type:String,converter:w,reflect:!1,hasChanged:x},ut=(t=ht,e,i)=>{const{kind:o,metadata:a}=i;let r=globalThis.litPropertyMetadata.get(a);if(void 0===r&&globalThis.litPropertyMetadata.set(a,r=new Map),"setter"===o&&((t=Object.create(t)).wrapped=!0),r.set(i.name,t),"accessor"===o){const{name:o}=i;return{set(i){const a=e.get.call(this);e.set.call(this,i),this.requestUpdate(o,a,t)},init(e){return void 0!==e&&this.C(o,void 0,t,e),e}}}if("setter"===o){const{name:o}=i;return function(i){const a=this[o];e.call(this,i),this.requestUpdate(o,a,t)}}throw Error("Unsupported decorator location: "+o)};function pt(t){return(e,i)=>"object"==typeof i?ut(t,e,i):((t,e,i)=>{const o=e.hasOwnProperty(i);return e.constructor.createProperty(i,t),o?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function gt(t){return pt({...t,state:!0,attribute:!1})}var mt,ft=c`:host { +!function(){const t={DEBUG:!1,BUILD_TIME:"2026-08-23, 12:22 p.m."};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,t)}catch(t){}globalThis.process={env:t}}();var t="simple-thermostat",e="4.3.0";function i(t,e,i,o){var a,r=arguments.length,n=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,o);else for(var s=t.length-1;s>=0;s--)(a=t[s])&&(n=(r<3?a(n):r>3?a(e,i,n):a(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n}"function"==typeof SuppressedError&&SuppressedError;const o=globalThis,a=o.ShadowRoot&&(void 0===o.ShadyCSS||o.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,r=Symbol(),n=new WeakMap;let s=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==r)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(a&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=n.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&n.set(e,t))}return t}toString(){return this.cssText}};const c=(t,...e)=>{const i=1===t.length?t[0]:e.reduce((e,i,o)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[o+1],t[0]);return new s(i,t,r)},l=a?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new s("string"==typeof t?t:t+"",void 0,r))(e)})(t):t,{is:d,defineProperty:h,getOwnPropertyDescriptor:u,getOwnPropertyNames:p,getOwnPropertySymbols:m,getPrototypeOf:g}=Object,f=globalThis,v=f.trustedTypes,y=v?v.emptyScript:"",b=f.reactiveElementPolyfillSupport,_=(t,e)=>t,w={toAttribute(t,e){switch(e){case Boolean:t=t?y:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},x=(t,e)=>!d(t,e),$={attribute:!0,type:String,converter:w,reflect:!1,useDefault:!1,hasChanged:x};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;let S=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=$){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),o=this.getPropertyDescriptor(t,i,e);void 0!==o&&h(this.prototype,t,o)}}static getPropertyDescriptor(t,e,i){const{get:o,set:a}=u(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:o,set(e){const r=o?.call(this);a?.call(this,e),this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??$}static _$Ei(){if(this.hasOwnProperty(_("elementProperties")))return;const t=g(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(_("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(_("properties"))){const t=this.properties,e=[...p(t),...m(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(l(t))}else void 0!==t&&e.push(l(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(a)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const i of e){const e=document.createElement("style"),a=o.litNonce;void 0!==a&&e.setAttribute("nonce",a),e.textContent=i.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$ET(t,e){const i=this.constructor.elementProperties.get(t),o=this.constructor._$Eu(t,i);if(void 0!==o&&!0===i.reflect){const a=(void 0!==i.converter?.toAttribute?i.converter:w).toAttribute(e,i.type);this._$Em=t,null==a?this.removeAttribute(o):this.setAttribute(o,a),this._$Em=null}}_$AK(t,e){const i=this.constructor,o=i._$Eh.get(t);if(void 0!==o&&this._$Em!==o){const t=i.getPropertyOptions(o),a="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:w;this._$Em=o;const r=a.fromAttribute(e,t.type);this[o]=r??this._$Ej?.get(o)??r,this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){const o=this.constructor,a=this[t];if(i??=o.getPropertyOptions(t),!((i.hasChanged??x)(a,e)||i.useDefault&&i.reflect&&a===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,i))))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:i,reflect:o,wrapped:a},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??e??this[t]),!0!==a||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(e=void 0),this._$AL.set(t,e)),!0===o&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t){const{wrapped:t}=i,o=this[e];!0!==t||this._$AL.has(e)||void 0===o||this.C(e,void 0,i,o)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}};S.elementStyles=[],S.shadowRootOptions={mode:"open"},S[_("elementProperties")]=new Map,S[_("finalized")]=new Map,b?.({ReactiveElement:S}),(f.reactiveElementVersions??=[]).push("2.1.1");const A=globalThis,k=t=>t,C=A.trustedTypes,E=C?C.createPolicy("lit-html",{createHTML:t=>t}):void 0,z="$lit$",T=`lit$${Math.random().toFixed(9).slice(2)}$`,O="?"+T,R=`<${O}>`,N=document,M=()=>N.createComment(""),j=t=>null===t||"object"!=typeof t&&"function"!=typeof t,P=Array.isArray,F="[ \t\n\f\r]",H=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,I=/-->/g,V=/>/g,L=RegExp(`>|${F}(?:([^\\s"'>=/]+)(${F}*=${F}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),D=/'/g,U=/"/g,W=/^(?:script|style|textarea|title)$/i,B=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),G=Symbol.for("lit-noChange"),q=Symbol.for("lit-nothing"),K=new WeakMap,Z=N.createTreeWalker(N,129);function J(t,e){if(!P(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==E?E.createHTML(e):e}const Y=(t,e)=>{const i=t.length-1,o=[];let a,r=2===e?"":3===e?"":"",n=H;for(let e=0;e"===c[0]?(n=a??H,l=-1):void 0===c[1]?l=-2:(l=n.lastIndex-c[2].length,s=c[1],n=void 0===c[3]?L:'"'===c[3]?U:D):n===U||n===D?n=L:n===I||n===V?n=H:(n=L,a=void 0);const h=n===L&&t[e+1].startsWith("/>")?" ":"";r+=n===H?i+R:l>=0?(o.push(s),i.slice(0,l)+z+i.slice(l)+T+h):i+T+(-2===l?e:h)}return[J(t,r+(t[i]||"")+(2===e?"":3===e?"":"")),o]};class X{constructor({strings:t,_$litType$:e},i){let o;this.parts=[];let a=0,r=0;const n=t.length-1,s=this.parts,[c,l]=Y(t,e);if(this.el=X.createElement(c,i),Z.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(o=Z.nextNode())&&s.length0){o.textContent=C?C.emptyScript:"";for(let i=0;iP(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==q&&j(this._$AH)?this._$AA.nextSibling.data=t:this.T(N.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:i}=t,o="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(J(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===o)this._$AH.p(e);else{const t=new tt(o,this),i=t.u(this.options);t.p(e),this.T(i),this._$AH=t}}_$AC(t){let e=K.get(t.strings);return void 0===e&&K.set(t.strings,e=new X(t)),e}k(t){P(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,o=0;for(const a of t)o===e.length?e.push(i=new et(this.O(M()),this.O(M()),this,this.options)):i=e[o],i._$AI(a),o++;o2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=q}_$AI(t,e=this,i,o){const a=this.strings;let r=!1;if(void 0===a)t=Q(this,t,e,0),r=!j(t)||t!==this._$AH&&t!==G,r&&(this._$AH=t);else{const o=t;let n,s;for(t=a[0],n=0;n{const o=i?.renderBefore??e;let a=o._$litPart$;if(void 0===a){const t=i?.renderBefore??null;o._$litPart$=a=new et(e.insertBefore(M(),t),t,void 0,i??{})}return a._$AI(t),a})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return G}};lt._$litElement$=!0,lt.finalized=!0,ct.litElementHydrateSupport?.({LitElement:lt});const dt=ct.litElementPolyfillSupport;dt?.({LitElement:lt}),(ct.litElementVersions??=[]).push("4.2.2");const ht={attribute:!0,type:String,converter:w,reflect:!1,hasChanged:x},ut=(t=ht,e,i)=>{const{kind:o,metadata:a}=i;let r=globalThis.litPropertyMetadata.get(a);if(void 0===r&&globalThis.litPropertyMetadata.set(a,r=new Map),"setter"===o&&((t=Object.create(t)).wrapped=!0),r.set(i.name,t),"accessor"===o){const{name:o}=i;return{set(i){const a=e.get.call(this);e.set.call(this,i),this.requestUpdate(o,a,t)},init(e){return void 0!==e&&this.C(o,void 0,t,e),e}}}if("setter"===o){const{name:o}=i;return function(i){const a=this[o];e.call(this,i),this.requestUpdate(o,a,t)}}throw Error("Unsupported decorator location: "+o)};function pt(t){return(e,i)=>"object"==typeof i?ut(t,e,i):((t,e,i)=>{const o=e.hasOwnProperty(i);return e.constructor.createProperty(i,t),o?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function mt(t){return pt({...t,state:!0,attribute:!1})}var gt,ft=c`:host { display: block; isolation: isolate; max-width: 100%; @@ -44,14 +44,14 @@ ha-card { padding-bottom: calc(var(--st-spacing, var(--st-default-spacing)) * 2); - --auto-color: green; - --heat_cool-color: springgreen; - --cool-color: #2b9af9; - --heat-color: #ff8100; + --auto-color: var(--state-climate-auto-color, green); + --heat_cool-color: var(--state-climate-heat-cool-color, #efbd07); + --cool-color: var(--state-climate-cool-color, #2b9af9); + --heat-color: var(--state-climate-heat-color, #ff8100); --manual-color: #44739e; --on-color: var(--primary-color); - --off-color: #8a8a8a; - --dry-color: #efbd07; + --off-color: var(--state-inactive-color, #8a8a8a); + --dry-color: var(--state-climate-dry-color, #efbd07); --st-mode-surface-background: color-mix( in srgb, var(--primary-text-color) 14%, @@ -340,6 +340,66 @@ ha-card.loading { justify-self: start; text-align: left; } +.entity-action { + grid-column: 1 / -1; + width: 100%; + min-width: 0; + min-height: 28px; + border: 0; + border-radius: var(--st-mode-border-radius, var(--st-default-mode-radius)); + padding: var(--st-spacing, var(--st-default-spacing)) + calc(var(--st-spacing, var(--st-default-spacing)) * 2); + display: inline-flex; + align-items: center; + justify-content: center; + gap: calc(var(--st-spacing, var(--st-default-spacing)) * 1.5); + color: var(--secondary-text-color); + background: var(--st-mode-background, var(--st-mode-surface-background)); + font: inherit; + line-height: 1.2; + cursor: pointer; + white-space: nowrap; + overflow: hidden; + transition: + background-color + var(--st-mode-transition, var(--st-default-mode-transition)), color var(--st-mode-transition, var(--st-default-mode-transition)), box-shadow var(--st-mode-transition, var(--st-default-mode-transition)), filter var(--st-mode-transition, var(--st-default-mode-transition)); +} +.entity-action ha-icon { + --mdc-icon-size: var(--st-entity-action-icon-size, 20px); + width: 20px; + width: var(--st-entity-action-icon-size, 20px); + height: 20px; + height: var(--st-entity-action-icon-size, 20px); + flex: 0 0 auto; +} +.entity-action__label, +.entity-action__state { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; +} +.entity-action__state { + color: var(--secondary-text-color); + font-size: 0.9em; +} +.entity-action.display-chip { + width: auto; + justify-self: start; + border-radius: 999px; + padding-left: calc(var(--st-spacing, var(--st-default-spacing)) * 2.5); + padding-right: calc(var(--st-spacing, var(--st-default-spacing)) * 2.5); +} +.entity-action.active, +.entity-action.state-on { + color: var(--st-mode-active-color, var(--text-primary-color)); + background: var( + --st-mode-active-background, + var(--st-toggle-color, var(--primary-color)) + ); +} +.entity-action:hover { + filter: brightness(1.08); +} .entities:empty { display: none; @@ -463,6 +523,7 @@ ha-card.embedded .body { ); will-change: opacity, transform; } + @supports (color: color-mix(in lch, red, blue)) { .header__icon-wrap::before { background: radial-gradient( @@ -809,6 +870,9 @@ ha-card.cooling .header__icon-wrap::before { .modes.preset { flex-wrap: nowrap; } +.modes.footer { + flex-wrap: nowrap; +} .mode-title { padding: 0 16px; align-self: center; @@ -853,6 +917,11 @@ ha-card.cooling .header__icon-wrap::before { var(--st-mode-color, var(--primary-color)) 68%, var(--primary-text-color) 32% ); + --st-mode-computed-active-background: var( + --st-mode-color, + var(--primary-color) + ); + --st-mode-computed-active-accent-color: var(--st-mode-accent-color); --st-mode-active-icon-color: color-mix( in srgb, var(--st-mode-color, var(--primary-color)) 42%, @@ -863,7 +932,6 @@ ha-card.cooling .header__icon-wrap::before { currentColor 50%, var(--st-mode-color, var(--primary-color)) 50% ); - --st-mode-active-accent-color: var(--st-mode-accent-color); --st-mode-neutral-hover-background: color-mix( in srgb, var(--st-mode-background, var(--secondary-background-color)) 88%, @@ -921,13 +989,16 @@ ha-card.cooling .header__icon-wrap::before { .mode-item.active,.mode-item.active:hover { background: var( --st-mode-active-background, - var(--st-mode-color, var(--primary-color)) + var(--st-mode-computed-active-background) ); color: var(--st-mode-active-color, var(--text-primary-color)); box-shadow: inset 0 -2px 0 var( --st-mode-active-accent-color, - color-mix(in srgb, var(--text-primary-color) 72%, transparent) + var( + --st-mode-computed-active-accent-color, + color-mix(in srgb, var(--text-primary-color) 72%, transparent) + ) ); filter: none; transform: none; @@ -951,7 +1022,10 @@ ha-card.cooling .header__icon-wrap::before { .mode-item.active::after { background: var( --st-mode-active-accent-color, - color-mix(in srgb, var(--text-primary-color) 72%, transparent) + var( + --st-mode-computed-active-accent-color, + color-mix(in srgb, var(--text-primary-color) 72%, transparent) + ) ); opacity: 0.64; opacity: var(--st-mode-active-accent-opacity, 0.64); @@ -970,6 +1044,10 @@ ha-card:not(.standard-visuals) .mode-item.active .mode-icon { line-height: 1; } +.mode-label-line { + display: block; +} + ha-card:not(.standard-visuals) .header__toggle.on .toggle-label.clickable, ha-card:not(.standard-visuals) .entity-heading.toggle-entity.state-on ha-icon { color: var(--st-toggle-color, var(--primary-color)); @@ -1118,7 +1196,7 @@ ha-card:not(.standard-visuals) ha-card.standard-visuals .mode-item.active:hover { background: var( --st-mode-active-background, - var(--st-mode-color, var(--primary-color)) + var(--st-mode-computed-active-background) ); color: var(--st-mode-active-color, var(--text-primary-color)); } @@ -1189,11 +1267,42 @@ ha-card.drying { padding-bottom: var(--st-spacing, var(--st-default-spacing)); } -.modes.hvac.sparse .mode-label, -.modes.state.sparse .mode-label { +.modes.hvac.sparse .mode-item:not(.label-stacked):not(.label-column) .mode-label, +.modes.state.sparse .mode-item:not(.label-stacked):not(.label-column) .mode-label { white-space: nowrap; } +.modes.hvac.sparse .mode-item.label-stacked, +.modes.state.sparse .mode-item.label-stacked { + align-items: center; +} + +.modes.hvac.sparse .mode-item.label-stacked .mode-label, +.modes.state.sparse .mode-item.label-stacked .mode-label { + white-space: normal; + line-height: 1.1; + text-align: left; +} + +.modes.hvac.sparse .mode-item.label-stacked .mode-label-line + .mode-label-line, +.modes.state.sparse .mode-item.label-stacked .mode-label-line + .mode-label-line { + margin-top: 1px; +} + +.modes.hvac.sparse .mode-item.label-column, +.modes.state.sparse .mode-item.label-column { + flex-direction: column; + gap: 4px; + min-height: calc(var(--st-control-icon-size) + 24px); +} + +.modes.hvac.sparse .mode-item.label-column .mode-label, +.modes.state.sparse .mode-item.label-column .mode-label { + white-space: normal; + text-align: center; + line-height: 1.1; +} + @media (max-width: 560px) { .modes.hvac .mode-item, .modes.state .mode-item { @@ -1210,6 +1319,12 @@ ha-card.drying { gap: var(--st-sparse-control-gap, 2px); min-width: 0; } + + ha-card:not(.standard-visuals) .modes.hvac.sparse .mode-item.label-column, + ha-card:not(.standard-visuals) .modes.state.sparse .mode-item.label-column { + flex-direction: column; + gap: 4px; + } } .modes.dense { display: grid; @@ -1312,7 +1427,8 @@ ha-card.drying { .modes.swing_horizontal .mode-item, .modes.swing_vertical .mode-item, .modes.vane_horizontal .mode-item, -.modes.vane_vertical .mode-item { +.modes.vane_vertical .mode-item, +.modes.footer .mode-item { --st-mode-min-width: 58px; flex-direction: row; align-items: center; @@ -1496,7 +1612,8 @@ ha-card.standard-visuals .modes.swing, ha-card.standard-visuals .modes.swing_horizontal, ha-card.standard-visuals .modes.swing_vertical, ha-card.standard-visuals .modes.vane_horizontal, -ha-card.standard-visuals .modes.vane_vertical { +ha-card.standard-visuals .modes.vane_vertical, +ha-card.standard-visuals .modes.footer { display: grid; grid-template-columns: none; grid-auto-columns: minmax(0, 1fr); @@ -1517,7 +1634,8 @@ ha-card.standard-visuals .modes.swing .mode-item, ha-card.standard-visuals .modes.swing_horizontal .mode-item, ha-card.standard-visuals .modes.swing_vertical .mode-item, ha-card.standard-visuals .modes.vane_horizontal .mode-item, -ha-card.standard-visuals .modes.vane_vertical .mode-item { +ha-card.standard-visuals .modes.vane_vertical .mode-item, +ha-card.standard-visuals .modes.footer .mode-item { display: flex; flex: initial; flex-direction: column; @@ -1573,72 +1691,65 @@ ha-card.standard-visuals .mode-item.active { ha-card .mode-item.active.off, ha-card .mode-item.active.off:hover { - background: var(--off-color); - --st-mode-active-background: var(--off-color); + --st-mode-computed-active-background: var(--off-color); } ha-card .mode-item.active.heat, ha-card .mode-item.active.heat:hover { - background: var(--heat-color); - --st-mode-active-background: var(--heat-color); + --st-mode-computed-active-background: var(--heat-color); } ha-card .mode-item.active.cool, ha-card .mode-item.active.cool:hover { - background: var(--cool-color); - --st-mode-active-background: var(--cool-color); + --st-mode-computed-active-background: var(--cool-color); } ha-card .mode-item.active.heat_cool, ha-card .mode-item.active.heat_cool:hover { - background: var(--heat_cool-color); - --st-mode-active-background: var(--heat_cool-color); + --st-mode-computed-active-background: var(--heat_cool-color); } ha-card .mode-item.active.auto, ha-card .mode-item.active.auto:hover { - background: var(--auto-color); - --st-mode-active-background: var(--auto-color); + --st-mode-computed-active-background: var(--auto-color); } ha-card .mode-item.active.dry, ha-card .mode-item.active.dry:hover { - background: var(--dry-color); - --st-mode-active-background: var(--dry-color); + --st-mode-computed-active-background: var(--dry-color); } ha-card .mode-item.active.fan_only, ha-card .mode-item.active.fan_only:hover { - background: var(--fan_only-color); - --st-mode-active-background: var(--fan_only-color); + --st-mode-computed-active-background: var(--fan_only-color); } ha-card.standard-visuals .mode-item.active.off { - background: var(--off-color); + --st-mode-computed-active-background: var(--off-color); } ha-card.standard-visuals .mode-item.active.heat { - background: var(--heat-color); + --st-mode-computed-active-background: var(--heat-color); } ha-card.standard-visuals .mode-item.active.cool { - background: var(--cool-color); + --st-mode-computed-active-background: var(--cool-color); } ha-card.standard-visuals .mode-item.active.heat_cool { - background: var(--heat_cool-color); + --st-mode-computed-active-background: var(--heat_cool-color); } ha-card.standard-visuals .mode-item.active.auto { - background: var(--auto-color); + --st-mode-computed-active-background: var(--auto-color); } ha-card.standard-visuals .mode-item.active.dry { - background: var(--dry-color); + --st-mode-computed-active-background: var(--dry-color); } ha-card.standard-visuals .mode-item.active.fan_only { - background: var(--fan_only-color); + --st-mode-computed-active-background: var(--fan_only-color); } ha-card.standard-visuals .mode-item:active, @@ -1721,7 +1832,7 @@ ha-card.standard-visuals .thermostat-trigger:active { font-size: 12px; font-size: var(--ha-font-size-s, 12px); } -`;function vt(t,e,i,o={}){o=o||{},i=null==i?{}:i;const a=new Event(e,{bubbles:void 0===o.bubbles||o.bubbles,cancelable:Boolean(o.cancelable),composed:void 0===o.composed||o.composed});return a.detail=i,t.dispatchEvent(a),a}function yt(t){return Array.isArray(t)?t.map(t=>{const{label:e,...i}=t;return!i.name&&e&&(i.name=e),i}):t}function _t(t){const e={...t,layout:t.layout?{...t.layout}:void 0};return 3===e.version&&!e.layout?.step&&(e.layout={...e.layout??{},step:"column"}),!e.current_value_entity&&e.current_temperature_entity&&(e.current_value_entity=e.current_temperature_entity),void 0===e.entities&&void 0!==e.sensors&&function(t){if(!Array.isArray(t.sensors))return;const e=[];t.sensors.forEach(i=>{const o=i;return"temperature"===o.id?(o.label&&(t.label={...t.label??{},temperature:o.label}),void(!1===o.show&&(t.hide={...t.hide??{},temperature:!0}))):"state"===o.id?(o.label&&(t.label={...t.label??{},state:o.label}),void(!1===o.show&&(t.hide={...t.hide??{},state:!0}))):void e.push(i)}),t.entities=yt(e)}(e),e.entities=yt(e.entities),e.layout&&void 0===e.layout.entities&&void 0!==e.layout.sensors&&(e.layout.entities=e.layout.sensors),delete e.current_temperature_entity,delete e.sensors,delete e.layout?.sensors,delete e.version,e}!function(t,e){void 0===e&&(e={});var i=e.insertAt;if(t&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===i&&o.firstChild?o.insertBefore(a,o.firstChild):o.appendChild(a),a.styleSheet?a.styleSheet.cssText=t:a.appendChild(document.createTextNode(t))}}(ft),function(t){t.HVAC="hvac",t.FAN="fan",t.STATE="state",t.PRESET="preset",t.SWING="swing",t.SWING_HORIZONTAL="swing_horizontal",t.SWING_VERTICAL="swing_vertical",t.VANE_HORIZONTAL="vane_horizontal",t.VANE_VERTICAL="vane_vertical",t.DIRECTION="direction",t.OSCILLATING="oscillating",t.MODE="mode"}(mt||(mt={}));const bt="dual";const wt={getSetpoints:t=>function(t){return"number"==typeof t.target_temp_high&&"number"==typeof t.target_temp_low?bt:"single"}(t)===bt?{target_temp_low:t.target_temp_low,target_temp_high:t.target_temp_high}:{temperature:t.temperature},getRange:t=>({min:t?.min_temp??null,max:t?.max_temp??null,step:t?.target_temp_step??null}),getCurrentValue:t=>t?.current_temperature??null,getCurrentValueTemplate:()=>"{{current_temperature|formatNumber}}",getSetpointService:()=>({domain:"climate",service:"set_temperature"}),getModeService:t=>"vane_horizontal"===t||"vane_vertical"===t?`set_${t}`:`set_${t}_mode`,getModePayloadKey:t=>"vane_horizontal"===t||"vane_vertical"===t?t:`${t}_mode`,getModeAttribute:t=>"vane_horizontal"===t||"vane_vertical"===t?`${t}_positions`:`${t}_modes`,getDefaultControl:()=>["hvac","preset"],getLocalizationDomain:()=>"climate"},xt={climate:wt,fan:{getSetpoints:t=>"number"!=typeof t?.percentage?{}:{percentage:t.percentage},getRange(t){const e=Number(t?.percentage_step);return{min:0,max:100,step:Number.isFinite(e)&&e>0?e:1}},getCurrentValue:t=>t?.current_temperature??t?.temperature??null,getCurrentValueUnit:(t,e)=>null!=t?.current_temperature?e?.unit_system?.temperature??!1:null!=t?.temperature&&(t?.unit_of_measurement??e?.unit_system?.temperature??!1),getCurrentValueTemplate:()=>"{{current_temperature|formatNumber}}",getSetpointService:()=>({domain:"fan",service:"set_percentage"}),getModeService:t=>"state"===t?"turn_on":"direction"===t?"set_direction":"oscillating"===t?"oscillate":`set_${t}_mode`,getModePayloadKey:t=>"state"===t?"state":"direction"===t?"direction":"oscillating"===t?"oscillating":`${t}_mode`,getModeAttribute:t=>"state"===t?"state":"direction"===t?"direction":"oscillating"===t?"oscillating":`${t}_modes`,getDefaultControl:()=>["preset","direction","oscillating","state"],transformModePayloadValue:(t,e)=>"oscillating"===t?"true"===e:e,getLocalizationDomain:()=>"fan"},humidifier:{getSetpoints:t=>({humidity:t?.humidity}),getRange:t=>({min:t?.min_humidity??0,max:t?.max_humidity??100,step:1}),getCurrentValue:t=>t?.current_humidity??null,getCurrentValueTemplate:()=>"{{current_humidity|formatNumber}}",getSetpointService:()=>({domain:"humidifier",service:"set_humidity"}),getModeService:t=>"state"===t?"turn_on":"mode"===t?"set_mode":`set_${t}`,getModePayloadKey:t=>"state"===t?"state":"mode"===t?"mode":t,getModeAttribute:t=>"state"===t?"state":"mode"===t?"available_modes":`${t}_modes`,getDefaultControl:()=>["mode","state"],getLocalizationDomain:()=>"humidifier"}};function $t(t){if(!t)return wt;const e=t.split(".")[0];return xt[e]??wt}const St=process.env.BUILD_TIME,At=["climate","fan","humidifier"],kt=[mt.HVAC,mt.FAN,mt.STATE,mt.PRESET,mt.SWING,mt.SWING_HORIZONTAL,mt.SWING_VERTICAL,mt.VANE_HORIZONTAL,mt.VANE_VERTICAL,mt.DIRECTION,mt.OSCILLATING,mt.MODE],Ct=Object.values(mt),Et={[mt.HVAC]:"HVAC modes",[mt.FAN]:"Fan modes",[mt.STATE]:"On/off state",[mt.PRESET]:"Preset modes",[mt.SWING]:"Swing modes",[mt.SWING_HORIZONTAL]:"Horizontal swing",[mt.SWING_VERTICAL]:"Vertical swing",[mt.VANE_HORIZONTAL]:"Horizontal vane",[mt.VANE_VERTICAL]:"Vertical vane",[mt.DIRECTION]:"Direction",[mt.OSCILLATING]:"Oscillating",[mt.MODE]:"Modes"},zt={header:{},layout:{mode:{}}},Tt={entity:"Entity (required)",current_value_entity:"Current value source",show_header:"Show header",name:"Name",icon:"Icon","toggle.entity":"Toggle entity","toggle.name":"Toggle label","toggle.icon":"Toggle icon","layout.mode.names":"Mode names","layout.mode.icons":"Mode icons","layout.mode.headings":"Mode headings",decimals:"Decimals",unit:"Unit","layout.step":"Step layout",step_size:"Step size",setpoint_debounce_ms:"Target debounce",fallback:"Fallback text","hide.temperature":"Hide current value",hide_current_value_when_off:"Hide current value while off","hide.state":"Hide state","hide.setpoint_label":"Hide target label",hide_setpoint_when_off:"Hide target controls while off",hide_setpoint:"Hide target controls",disable_setpoint_change_when_off:"Disable target changes while off","label.temperature":"Current value label","label.state":"State label","label.setpoint":"Target label","layout.entities.type":"Entity row layout","layout.entities.labels":"Show entity row labels","layout.entities.separator":"Show entity label separator","layout.entities.alignment":"Entity label alignment",enhanced_visuals:"Enhanced visuals","tap_action.action":"Tap action","hold_action.action":"Hold action","double_tap_action.action":"Double-tap action"};for(const t of kt)Tt[`control.${t}`]=Et[t];const Ot=t=>"function"==typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t)),Nt=t=>!Array.isArray(t.schema)||0!==t.schema.length,Mt=[{value:"more-info",label:"More info"},{value:"toggle",label:"Toggle"},{value:"none",label:"None"}],Rt=[{value:"row",label:"Row"},{value:"column",label:"Column"}],jt=[{value:"auto",label:"Auto (from entity)"},{value:"0.1",label:"0.1"},{value:"0.5",label:"0.5"},{value:"1",label:"1"}],Pt=[{value:"table",label:"Table"},{value:"list",label:"List"}],Ht=[{value:"right",label:"Right"},{value:"left",label:"Left"}],It=["entity","current_value_entity","decimals","unit","fallback","layout.step","layout.mode.names","layout.mode.icons","layout.mode.headings","layout.entities.type","layout.entities.labels","layout.entities.separator","layout.entities.alignment","setpoint_debounce_ms","hide.temperature","hide_current_value_when_off","hide.state","hide.setpoint_label","hide_setpoint_when_off","hide_setpoint","disable_setpoint_change_when_off","label.temperature","label.state","label.setpoint","tap_action.action","hold_action.action","double_tap_action.action"],Vt=["show_header","name","icon","toggle.entity","toggle.name","toggle.icon"];function Ft(t,e,i){const o=e.split(".");let a=t;for(;o.length>1;){const t=o.shift();Object.prototype.hasOwnProperty.call(a,t)||(a[t]={}),a=a[t]}a[o[0]]=i}function Lt(t,e){const i=e.split(".");let o=t;for(;i.length>1;){const t=i.shift();if(!o[t])return;o=o[t]}delete o[i[0]]}function Dt(t){const e=$t(t.entity);return kt.reduce((i,o)=>(i[`control.${o}`]=function(t,e,i){const o=t.control;return!1!==o&&(Array.isArray(o)?o.includes(e):o&&"object"==typeof o?void 0!==o[e]&&!1!==o[e]:i.getDefaultControl().includes(e))}(t,o,e),i),{})}function Ut(t,e){if(!t.entity||!e?.states?.[t.entity])return[];const i=e.states[t.entity].attributes??{},[o]=t.entity.split("."),a=$t(t.entity);return kt.filter(t=>Ct.includes(t)&&(t===mt.STATE?"fan"===o||"humidifier"===o:void 0!==i[a.getModeAttribute(t)]))}function Wt(t){const e=t._order,i=Object.keys(t).filter(t=>!t.startsWith("_"));if(!Array.isArray(e))return i;const o=new Set,a=e.map(String).filter(t=>i.includes(t)).filter(t=>!o.has(t)&&(o.add(t),!0));return i.forEach(t=>{o.has(t)||a.push(t)}),a}function Bt(t,e){return t.length===e.length&&t.every((t,i)=>String(t)===e[i])}function Gt(t){if(!function(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}(t))return{value:t,changed:!1};const e=Object.keys(t).filter(t=>!t.startsWith("_"));if(0===e.length&&!Array.isArray(t._order))return{value:t,changed:!1};const i=Array.isArray(t._order)?t._order.map(String):e,o=!Array.isArray(t._order)||!Bt(t._order,i);return{value:{...t,_order:i},changed:o}}function qt(t){if(!function(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}(t.control))return{config:t,changed:!1};const e=t.control,i=Wt(e);if(0===i.length&&!Array.isArray(e._order))return{config:t,changed:!1};let o=Array.isArray(e._order)&&!Bt(e._order,i);const a={...t,control:i.reduce((t,i)=>{const a=Gt(e[i]);return t[i]=a.value,o=o||a.changed,t},Array.isArray(e._order)?{_order:i}:{})};return{config:o?a:t,changed:o}}class Kt extends lt{constructor(){super(...arguments),this._valueChanged=t=>{const e=this._applyFormChange(t.detail.value);this.config=e,vt(this,"config-changed",{config:e})},this._computeLabel=t=>Tt[String(t.name)]??String(t.name)}static get styles(){return ft}static getStubConfig(){return{...zt}}setConfig(t){const e=qt(_t(t||{...zt}));this.config=e.config,e.changed&&queueMicrotask(()=>{this.config===e.config&&vt(this,"config-changed",{config:e.config})})}_openLink(){window.open("https://github.com/Wheemer/simple-thermostat/blob/master/README.md","_blank","noopener")}_buildFormData(){const t=this.config.header&&"object"==typeof this.config.header?this.config.header:{};return{entity:this.config.entity??"",current_value_entity:this.config.current_value_entity??"",show_header:!1!==this.config.header,"layout.mode.names":!1!==this.config.layout?.mode?.names,"layout.mode.icons":!1!==this.config.layout?.mode?.icons,"layout.mode.headings":!0===this.config.layout?.mode?.headings,decimals:this.config.decimals??"",unit:"string"==typeof this.config.unit?this.config.unit:"","layout.step":!1===this.config.enhanced_visuals?this.config.layout?.step??"column":this.config.layout?.step??"row",step_size:null!=this.config.step_size?String(this.config.step_size):"auto",fallback:this.config.fallback??"",setpoint_debounce_ms:this.config.setpoint_debounce_ms??"","hide.temperature":!0===this.config.hide?.temperature,hide_current_value_when_off:!0===this.config.hide_current_value_when_off||!0===this.config.hide?.current_value_when_off||!0===this.config.hide?.temperature_when_off,"hide.state":!0===this.config.hide?.state,hide_setpoint:!0===this.config.hide_setpoint,disable_setpoint_change_when_off:!0===this.config.disable_setpoint_change_when_off,"hide.setpoint_label":!0===this.config.hide?.setpoint_label,hide_setpoint_when_off:!0===this.config.hide_setpoint_when_off||!0===this.config.hide?.setpoint_when_off,"label.temperature":this.config.label?.temperature??"","label.state":this.config.label?.state??"","label.setpoint":this.config.label?.setpoint??"","layout.entities.type":this.config.layout?.entities?.type??"table","layout.entities.labels":!1!==this.config.layout?.entities?.labels,"layout.entities.separator":!1!==this.config.layout?.entities?.separator,"layout.entities.alignment":this.config.layout?.entities?.alignment??"right",enhanced_visuals:!1!==this.config.enhanced_visuals,name:t.name??"",icon:"string"==typeof t.icon?t.icon:"","toggle.entity":t.toggle?.entity??"","toggle.name":t.toggle?.name??"","toggle.icon":"string"==typeof t.toggle?.icon?t.toggle.icon:"","tap_action.action":this.config.tap_action?.action??"more-info","hold_action.action":this.config.hold_action?.action??"none","double_tap_action.action":this.config.double_tap_action?.action??"none",...Dt(this.config)}}_applyFormChange(t){const e=this._buildFormData(),i=function(t,e){return new Set(Object.keys(e).filter(i=>t[i]!==e[i]))}(e,t);!function(t,e){t.has("enhanced_visuals")&&(e.layout?.step||t.delete("layout.step"))}(i,this.config);const o={...e,...t},a=Ot(this.config);if(this._applyDirectFormPaths(a,o,i),!1===o.enhanced_visuals?a.enhanced_visuals=!1:delete a.enhanced_visuals,Vt.some(t=>i.has(t))&&(!1===o.show_header?a.header=!1:this._applyHeaderFormChange(a,o)),i.has("step_size")&&this._applyStepSize(a,o.step_size),i.has("entity")||kt.some(t=>i.has(`control.${t}`))){const t=function(t,e,i){const o=String(t.entity??e.entity??""),a=$t(o),r=Ut({...e,entity:o},i).filter(e=>t[`control.${e}`]),n=a.getDefaultControl();if(0===r.length)return!1;if(e.control&&!Array.isArray(e.control)&&"object"==typeof e.control){const t=new Set(r.map(String)),i=Wt(e.control).filter(e=>t.has(e)),o=r.filter(t=>!i.includes(t)),a=[...i,...o];return a.reduce((t,i)=>(t[i]=Gt(e.control[i]||{}).value,t),{_order:a})}return r.length===n.length&&r.every((t,e)=>t===n[e])?void 0:r}(o,this.config,this.hass);void 0===t?delete a.control:a.control=t}return a}_applyDirectFormPaths(t,e,i){for(const o of It){if(!i.has(o))continue;const a=e[o];null==a||""===a?Lt(t,o):Ft(t,o,a)}}_applyHeaderFormChange(t,e){!1!==t.header&&null!=t.header||(t.header={});const i=t.header,o=e.name,a=e.icon,r=e["toggle.entity"],n=e["toggle.name"],s=e["toggle.icon"];"string"==typeof o&&o?i.name=o:delete i.name,"string"==typeof a&&a?i.icon=a:delete i.icon,"string"==typeof r&&r?(i.toggle=i.toggle||{entity:r},i.toggle.entity=r,"string"==typeof n&&n?i.toggle.name=n:delete i.toggle.name,"string"==typeof s&&s?i.toggle.icon=s:delete i.toggle.icon):delete i.toggle}_applyStepSize(t,e){if("auto"===e||""===e||null==e)return void delete t.step_size;const i=Number(e);t.step_size=Number.isNaN(i)?e:i}_getExtraEntities(){return Array.isArray(this.config.entities)?this.config.entities:[]}_commitEntityRows(t){const e=Ot(this.config);t.length>0?e.entities=t:delete e.entities,this.config=e,vt(this,"config-changed",{config:e})}_addEntityRow(){this._commitEntityRows([...this._getExtraEntities(),{entity:""}])}_removeEntityRow(t){this._commitEntityRows(this._getExtraEntities().filter((e,i)=>i!==t))}_updateEntityRow(t,e,i){const o=this._getExtraEntities().map((o,a)=>{if(a!==t)return o;const r={...o};return"string"==typeof i&&i?r[e]=i:delete r[e],r});this._commitEntityRows(o)}_renderExtraEntityRows(){const t=this._getExtraEntities();return B` +`;function vt(t,e,i,o={}){o=o||{},i=null==i?{}:i;const a=new Event(e,{bubbles:void 0===o.bubbles||o.bubbles,cancelable:Boolean(o.cancelable),composed:void 0===o.composed||o.composed});return a.detail=i,t.dispatchEvent(a),a}function yt(t){return Array.isArray(t)?t.map(t=>{const{label:e,...i}=t;return!i.name&&e&&(i.name=e),i}):t}function bt(t){const e={...t,layout:t.layout?{...t.layout}:void 0},i=3===e.version;return i&&void 0===e.enhanced_visuals&&(e.enhanced_visuals=!1),i&&!e.layout?.step&&(e.layout={...e.layout??{},step:"column"}),!e.current_value_entity&&e.current_temperature_entity&&(e.current_value_entity=e.current_temperature_entity),void 0===e.entities&&void 0!==e.sensors&&function(t){if(!Array.isArray(t.sensors))return;const e=[];t.sensors.forEach(i=>{const o=i;return"temperature"===o.id?(o.label&&(t.label={...t.label??{},temperature:o.label}),void(!1===o.show&&(t.hide={...t.hide??{},temperature:!0}))):"state"===o.id?(o.label&&(t.label={...t.label??{},state:o.label}),void(!1===o.show&&(t.hide={...t.hide??{},state:!0}))):void e.push(i)}),t.entities=yt(e)}(e),e.entities=yt(e.entities),e.layout&&void 0===e.layout.entities&&void 0!==e.layout.sensors&&(e.layout.entities=e.layout.sensors),delete e.current_temperature_entity,delete e.sensors,delete e.layout?.sensors,delete e.version,e}!function(t,e){void 0===e&&(e={});var i=e.insertAt;if(t&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===i&&o.firstChild?o.insertBefore(a,o.firstChild):o.appendChild(a),a.styleSheet?a.styleSheet.cssText=t:a.appendChild(document.createTextNode(t))}}(ft),function(t){t.HVAC="hvac",t.FAN="fan",t.STATE="state",t.PRESET="preset",t.SWING="swing",t.SWING_HORIZONTAL="swing_horizontal",t.SWING_VERTICAL="swing_vertical",t.VANE_HORIZONTAL="vane_horizontal",t.VANE_VERTICAL="vane_vertical",t.DIRECTION="direction",t.OSCILLATING="oscillating",t.MODE="mode"}(gt||(gt={}));const _t="dual";const wt={getSetpoints:t=>function(t){return"number"==typeof t.target_temp_high&&"number"==typeof t.target_temp_low?_t:"single"}(t)===_t?{target_temp_low:t.target_temp_low,target_temp_high:t.target_temp_high}:{temperature:t.temperature},getRange:t=>({min:t?.min_temp??null,max:t?.max_temp??null,step:t?.target_temp_step??null}),getCurrentValue:t=>t?.current_temperature??null,getCurrentValueTemplate:()=>"{{current_temperature|formatNumber}}",getSetpointService:()=>({domain:"climate",service:"set_temperature"}),getModeService:t=>"vane_horizontal"===t||"vane_vertical"===t?`set_${t}`:`set_${t}_mode`,getModePayloadKey:t=>"vane_horizontal"===t||"vane_vertical"===t?t:`${t}_mode`,getModeAttribute:t=>"vane_horizontal"===t||"vane_vertical"===t?`${t}_positions`:`${t}_modes`,getDefaultControl:()=>["hvac","preset"],getLocalizationDomain:()=>"climate"},xt={climate:wt,fan:{getSetpoints:t=>"number"!=typeof t?.percentage?{}:{percentage:t.percentage},getRange(t){const e=Number(t?.percentage_step);return{min:0,max:100,step:Number.isFinite(e)&&e>0?e:1}},getCurrentValue:t=>t?.current_temperature??t?.temperature??null,getCurrentValueUnit:(t,e)=>null!=t?.current_temperature?e?.unit_system?.temperature??!1:null!=t?.temperature&&(t?.unit_of_measurement??e?.unit_system?.temperature??!1),getCurrentValueTemplate:()=>"{{current_temperature|formatNumber}}",getSetpointService:()=>({domain:"fan",service:"set_percentage"}),getModeService:t=>"state"===t?"turn_on":"direction"===t?"set_direction":"oscillating"===t?"oscillate":`set_${t}_mode`,getModePayloadKey:t=>"state"===t?"state":"direction"===t?"direction":"oscillating"===t?"oscillating":`${t}_mode`,getModeAttribute:t=>"state"===t?"state":"direction"===t?"direction":"oscillating"===t?"oscillating":`${t}_modes`,getDefaultControl:()=>["preset","direction","oscillating","state"],transformModePayloadValue:(t,e)=>"oscillating"===t?"true"===e:e,getLocalizationDomain:()=>"fan"},humidifier:{getSetpoints:t=>({humidity:t?.humidity}),getRange:t=>({min:t?.min_humidity??0,max:t?.max_humidity??100,step:1}),getCurrentValue:t=>t?.current_humidity??null,getCurrentValueTemplate:()=>"{{current_humidity|formatNumber}}",getSetpointService:()=>({domain:"humidifier",service:"set_humidity"}),getModeService:t=>"state"===t?"turn_on":"mode"===t?"set_mode":`set_${t}`,getModePayloadKey:t=>"state"===t?"state":"mode"===t?"mode":t,getModeAttribute:t=>"state"===t?"state":"mode"===t?"available_modes":`${t}_modes`,getDefaultControl:()=>["mode","state"],getLocalizationDomain:()=>"humidifier"}};function $t(t){if(!t)return wt;const e=t.split(".")[0];return xt[e]??wt}const St=process.env.BUILD_TIME,At=["climate","fan","humidifier"],kt=[gt.HVAC,gt.FAN,gt.STATE,gt.PRESET,gt.SWING,gt.SWING_HORIZONTAL,gt.SWING_VERTICAL,gt.VANE_HORIZONTAL,gt.VANE_VERTICAL,gt.DIRECTION,gt.OSCILLATING,gt.MODE],Ct=Object.values(gt),Et={[gt.HVAC]:"HVAC modes",[gt.FAN]:"Fan modes",[gt.STATE]:"On/off state",[gt.PRESET]:"Preset modes",[gt.SWING]:"Swing modes",[gt.SWING_HORIZONTAL]:"Horizontal swing",[gt.SWING_VERTICAL]:"Vertical swing",[gt.VANE_HORIZONTAL]:"Horizontal vane",[gt.VANE_VERTICAL]:"Vertical vane",[gt.DIRECTION]:"Direction",[gt.OSCILLATING]:"Oscillating",[gt.MODE]:"Modes"},zt={header:{},layout:{mode:{}}},Tt={entity:"Entity (required)",current_value_entity:"Current value source",show_header:"Show header",name:"Name",icon:"Icon","toggle.entity":"Toggle entity","toggle.name":"Toggle label","toggle.icon":"Toggle icon","layout.mode.names":"Mode names","layout.mode.icons":"Mode icons","layout.mode.headings":"Mode headings",decimals:"Decimals",unit:"Unit","layout.step":"Step layout",step_size:"Step size",setpoint_debounce_ms:"Target debounce",fallback:"Fallback text","hide.temperature":"Hide current value",hide_current_value_when_off:"Hide current value while off","hide.state":"Hide state","hide.setpoint_label":"Hide target label",hide_setpoint_when_off:"Hide target controls while off",hide_setpoint:"Hide target controls",disable_setpoint_change_when_off:"Disable target changes while off","label.temperature":"Current value label","label.state":"State label","label.setpoint":"Target label","layout.entities.type":"Entity row layout","layout.entities.display":"Entity display","layout.entities.labels":"Show entity row labels","layout.entities.separator":"Show entity label separator","layout.entities.alignment":"Entity label alignment","footer.entity":"Footer toggle entity","footer.name":"Footer toggle label","footer.icon":"Footer toggle icon",enhanced_visuals:"Enhanced visuals","tap_action.action":"Tap action","hold_action.action":"Hold action","double_tap_action.action":"Double-tap action"};for(const t of kt)Tt[`control.${t}`]=Et[t];const Ot=t=>"function"==typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t)),Rt=t=>!Array.isArray(t.schema)||0!==t.schema.length,Nt=[{value:"more-info",label:"More info"},{value:"toggle",label:"Toggle"},{value:"none",label:"None"}],Mt=[{value:"row",label:"Row"},{value:"column",label:"Column"}],jt=[{value:"auto",label:"Auto (from entity)"},{value:"0.1",label:"0.1"},{value:"0.5",label:"0.5"},{value:"1",label:"1"}],Pt=[{value:"table",label:"Table"},{value:"list",label:"List"}],Ft=[{value:"row",label:"Rows"},{value:"auto",label:"Auto"},{value:"button",label:"Buttons"},{value:"toggle",label:"Toggles"},{value:"chip",label:"Chips"}],Ht=[{value:"",label:"Default"},...Ft],It=Ft.map(t=>t.value),Vt=[{value:"right",label:"Right"},{value:"left",label:"Left"}],Lt=["entity","current_value_entity","decimals","unit","fallback","layout.step","layout.mode.names","layout.mode.icons","layout.mode.headings","layout.entities.type","layout.entities.display","layout.entities.labels","layout.entities.separator","layout.entities.alignment","setpoint_debounce_ms","hide.temperature","hide_current_value_when_off","hide.state","hide.setpoint_label","hide_setpoint_when_off","hide_setpoint","disable_setpoint_change_when_off","label.temperature","label.state","label.setpoint","tap_action.action","hold_action.action","double_tap_action.action"],Dt=["show_header","name","icon","toggle.entity","toggle.name","toggle.icon"];function Ut(t,e,i){const o=e.split(".");let a=t;for(;o.length>1;){const t=o.shift();Object.prototype.hasOwnProperty.call(a,t)||(a[t]={}),a=a[t]}a[o[0]]=i}function Wt(t,e){const i=e.split(".");let o=t;for(;i.length>1;){const t=i.shift();if(!o[t])return;o=o[t]}delete o[i[0]]}function Bt(t){const e=t.target,i=t.detail;return i?.value??i?.item?.value??e.selected?.value??e.selected?.getAttribute?.("value")??e.value??""}function Gt(t){const e=$t(t.entity);return kt.reduce((i,o)=>(i[`control.${o}`]=function(t,e,i){const o=t.control;return!1!==o&&(Array.isArray(o)?o.includes(e):o&&"object"==typeof o?void 0!==o[e]&&!1!==o[e]:i.getDefaultControl().includes(e))}(t,o,e),i),{})}function qt(t,e){if(!t.entity||!e?.states?.[t.entity])return[];const i=e.states[t.entity].attributes??{},[o]=t.entity.split("."),a=$t(t.entity);return kt.filter(t=>Ct.includes(t)&&(t===gt.STATE?"fan"===o||"humidifier"===o:void 0!==i[a.getModeAttribute(t)]))}function Kt(t){const e=t._order,i=Object.keys(t).filter(t=>!t.startsWith("_"));if(!Array.isArray(e))return i;const o=new Set,a=e.map(String).filter(t=>i.includes(t)).filter(t=>!o.has(t)&&(o.add(t),!0));return i.forEach(t=>{o.has(t)||a.push(t)}),a}function Zt(t,e){return t.length===e.length&&t.every((t,i)=>String(t)===e[i])}function Jt(t){if(!function(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}(t))return{value:t,changed:!1};const e=Object.keys(t).filter(t=>!t.startsWith("_"));if(0===e.length&&!Array.isArray(t._order))return{value:t,changed:!1};const i=Array.isArray(t._order)?t._order.map(String):e,o=!Array.isArray(t._order)||!Zt(t._order,i);return{value:{...t,_order:i},changed:o}}function Yt(t){if(!function(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}(t.control))return{config:t,changed:!1};const e=t.control,i=Kt(e);if(0===i.length&&!Array.isArray(e._order))return{config:t,changed:!1};let o=Array.isArray(e._order)&&!Zt(e._order,i);const a={...t,control:i.reduce((t,i)=>{const a=Jt(e[i]);return t[i]=a.value,o=o||a.changed,t},Array.isArray(e._order)?{_order:i}:{})};return{config:o?a:t,changed:o}}class Xt extends lt{constructor(){super(...arguments),this._valueChanged=t=>{const e=this._applyFormChange(t.detail.value);this.config=e,vt(this,"config-changed",{config:e})},this._computeLabel=t=>Tt[String(t.name)]??String(t.name)}static get styles(){return ft}static getStubConfig(){return{...zt}}setConfig(t){const e=Yt(bt(t||{...zt}));this.config=e.config,e.changed&&queueMicrotask(()=>{this.config===e.config&&vt(this,"config-changed",{config:e.config})})}_openLink(){window.open("https://github.com/Wheemer/simple-thermostat/blob/master/README.md","_blank","noopener")}_buildFormData(){const t=this.config.header&&"object"==typeof this.config.header?this.config.header:{};return{entity:this.config.entity??"",current_value_entity:this.config.current_value_entity??"",show_header:!1!==this.config.header,"layout.mode.names":!1!==this.config.layout?.mode?.names,"layout.mode.icons":!1!==this.config.layout?.mode?.icons,"layout.mode.headings":!0===this.config.layout?.mode?.headings,decimals:this.config.decimals??"",unit:"string"==typeof this.config.unit?this.config.unit:"","layout.step":!1===this.config.enhanced_visuals?this.config.layout?.step??"column":this.config.layout?.step??"row",step_size:null!=this.config.step_size?String(this.config.step_size):"auto",fallback:this.config.fallback??"",setpoint_debounce_ms:this.config.setpoint_debounce_ms??"","hide.temperature":!0===this.config.hide?.temperature,hide_current_value_when_off:!0===this.config.hide_current_value_when_off||!0===this.config.hide?.current_value_when_off||!0===this.config.hide?.temperature_when_off,"hide.state":!0===this.config.hide?.state,hide_setpoint:!0===this.config.hide_setpoint,disable_setpoint_change_when_off:!0===this.config.disable_setpoint_change_when_off,"hide.setpoint_label":!0===this.config.hide?.setpoint_label,hide_setpoint_when_off:!0===this.config.hide_setpoint_when_off||!0===this.config.hide?.setpoint_when_off,"label.temperature":this.config.label?.temperature??"","label.state":this.config.label?.state??"","label.setpoint":this.config.label?.setpoint??"","layout.entities.type":this.config.layout?.entities?.type??"table","layout.entities.display":this.config.layout?.entities?.display??"","layout.entities.labels":!1!==this.config.layout?.entities?.labels,"layout.entities.separator":!1!==this.config.layout?.entities?.separator,"layout.entities.alignment":this.config.layout?.entities?.alignment??"right",enhanced_visuals:!1!==this.config.enhanced_visuals,name:t.name??"",icon:"string"==typeof t.icon?t.icon:"","toggle.entity":t.toggle?.entity??"","toggle.name":t.toggle?.name??"","toggle.icon":"string"==typeof t.toggle?.icon?t.toggle.icon:"","tap_action.action":this.config.tap_action?.action??"more-info","hold_action.action":this.config.hold_action?.action??"none","double_tap_action.action":this.config.double_tap_action?.action??"none",...Gt(this.config)}}_applyFormChange(t){const e=this._buildFormData(),i=function(t,e){return new Set(Object.keys(e).filter(i=>t[i]!==e[i]))}(e,t);!function(t,e){t.has("enhanced_visuals")&&(e.layout?.step||t.delete("layout.step"))}(i,this.config);const o={...e,...t},a=Ot(this.config);if(this._applyDirectFormPaths(a,o,i),!1===o.enhanced_visuals?a.enhanced_visuals=!1:delete a.enhanced_visuals,Dt.some(t=>i.has(t))&&(!1===o.show_header?a.header=!1:this._applyHeaderFormChange(a,o)),i.has("step_size")&&this._applyStepSize(a,o.step_size),i.has("entity")||kt.some(t=>i.has(`control.${t}`))){const t=function(t,e,i){const o=String(t.entity??e.entity??""),a=$t(o),r=qt({...e,entity:o},i).filter(e=>t[`control.${e}`]),n=a.getDefaultControl();if(0===r.length)return!1;if(e.control&&!Array.isArray(e.control)&&"object"==typeof e.control){const t=new Set(r.map(String)),i=Kt(e.control).filter(e=>t.has(e)),o=r.filter(t=>!i.includes(t)),a=[...i,...o];return a.reduce((t,i)=>(t[i]=Jt(e.control[i]||{}).value,t),{_order:a})}return r.length===n.length&&r.every((t,e)=>t===n[e])?void 0:r}(o,this.config,this.hass);void 0===t?delete a.control:a.control=t}return a}_applyDirectFormPaths(t,e,i){for(const o of Lt){if(!i.has(o))continue;const a=e[o];null==a||""===a?Wt(t,o):Ut(t,o,a)}}_applyHeaderFormChange(t,e){!1!==t.header&&null!=t.header||(t.header={});const i=t.header,o=e.name,a=e.icon,r=e["toggle.entity"],n=e["toggle.name"],s=e["toggle.icon"];"string"==typeof o&&o?i.name=o:delete i.name,"string"==typeof a&&a?i.icon=a:delete i.icon,"string"==typeof r&&r?(i.toggle=i.toggle||{entity:r},i.toggle.entity=r,"string"==typeof n&&n?i.toggle.name=n:delete i.toggle.name,"string"==typeof s&&s?i.toggle.icon=s:delete i.toggle.icon):delete i.toggle}_applyStepSize(t,e){if("auto"===e||""===e||null==e)return void delete t.step_size;const i=Number(e);t.step_size=Number.isNaN(i)?e:i}_getExtraEntities(){return Array.isArray(this.config.entities)?this.config.entities:[]}_getFooterRows(){return Array.isArray(this.config.footer)?this.config.footer:[]}_commitEntityRows(t){const e=Ot(this.config);t.length>0?e.entities=t:delete e.entities,this.config=e,vt(this,"config-changed",{config:e})}_addEntityRow(){this._commitEntityRows([...this._getExtraEntities(),{entity:""}])}_removeEntityRow(t){this._commitEntityRows(this._getExtraEntities().filter((e,i)=>i!==t))}_updateEntityRow(t,e,i){const o=this._getExtraEntities().map((o,a)=>{if(a!==t)return o;const r={...o};return"display"===e?("string"==typeof i&&It.includes(i)?r.display=i:delete r.display,r):("string"==typeof i&&i?r[e]=i:delete r[e],r)});this._commitEntityRows(o)}_commitFooterRows(t){const e=Ot(this.config);t.length>0?e.footer=t:delete e.footer,this.config=e,vt(this,"config-changed",{config:e})}_addFooterRow(){this._commitFooterRows([...this._getFooterRows(),{entity:""}])}_removeFooterRow(t){this._commitFooterRows(this._getFooterRows().filter((e,i)=>i!==t))}_updateFooterRow(t,e,i){const o=this._getFooterRows().map((o,a)=>{if(a!==t)return o;const r={...o};return"string"==typeof i&&i?r[e]=i:delete r[e],r});this._commitFooterRows(o)}_renderExtraEntityRows(){const t=this._getExtraEntities();return B`
@@ -1751,23 +1862,75 @@ ha-card.standard-visuals .thermostat-trigger:active { .value=${t.icon??""} @value-changed=${t=>this._updateEntityRow(e,"icon",t.detail.value)} > + this._updateEntityRow(e,"display",Bt(t))} + @selected=${t=>this._updateEntityRow(e,"display",Bt(t))} + @change=${t=>this._updateEntityRow(e,"display",Bt(t))} + > + Default + ${Ft.map(t=>B` + + ${t.label} + + `)} + this._removeEntityRow(e)}> Remove
`)}
+ `}_renderFooterRows(){const t=this._getFooterRows();return B` +
+
+
+

Footer controls

+

Add switch-style controls shown below the mode rows.

+
+ Add control +
+ + ${0===t.length?B`

+ No footer controls configured. +

`:t.map((t,e)=>B` +
+ this._updateFooterRow(e,"entity",t.detail.value)} + > + this._updateFooterRow(e,"name",t.target.value)} + > + this._updateFooterRow(e,"icon",t.detail.value)} + > + this._removeFooterRow(e)}> + Remove + +
+ `)} +
`}render(){return this.hass&&this.config?B`
0,s="fan"!==o&&("climate"===o||"humidifier"===o),c="fan"===o?[]:[{name:"current_value_entity",selector:{entity:{domain:["sensor","input_number"]}}}],l=[...s?[{name:"hide.temperature",selector:{boolean:{}}},{name:"hide_current_value_when_off",selector:{boolean:{}}}]:[],{name:"hide.state",selector:{boolean:{}}}],d=[...s?[{name:"label.temperature",selector:{text:{}}}]:[],{name:"label.state",selector:{text:{}}},...n?[{name:"label.setpoint",selector:{text:{}}}]:[]],h=!1===t.header?[]:[{type:"grid",schema:[{name:"name",selector:{text:{}}},{name:"icon",selector:{icon:{}}}]},{name:"toggle.entity",selector:{entity:{}}},{name:"toggle.name",selector:{text:{}}},...t.header&&"object"==typeof t.header&&t.header.toggle?.entity?[{name:"toggle.icon",selector:{icon:{}}}]:[]];return[{name:"entity",required:!0,selector:{entity:{domain:At}}},{type:"expandable",title:"Card header",schema:[{name:"show_header",selector:{boolean:{}}},...h]},...i.length>0?[{type:"expandable",title:"Controls",schema:[{type:"grid",column_min_width:"150px",schema:i.map(t=>({name:`control.${t}`,selector:{boolean:{}}}))}]}]:[],...n?[{type:"expandable",title:"Target",schema:[{type:"grid",schema:[{name:"layout.step",selector:{select:{mode:"dropdown",options:Rt}}},{name:"step_size",selector:{select:{mode:"dropdown",options:jt}}}]},{type:"grid",column_min_width:"160px",schema:[{name:"hide_setpoint",selector:{boolean:{}}},{name:"hide_setpoint_when_off",selector:{boolean:{}}},{name:"hide.setpoint_label",selector:{boolean:{}}},{name:"disable_setpoint_change_when_off",selector:{boolean:{}}}]}]}]:[],{type:"expandable",title:"Extra entity rows",schema:[{type:"grid",column_min_width:"160px",schema:[{name:"layout.entities.type",selector:{select:{mode:"dropdown",options:Pt}}},{name:"layout.entities.labels",selector:{boolean:{}}},{name:"layout.entities.separator",selector:{boolean:{}}},{name:"layout.entities.alignment",selector:{select:{mode:"dropdown",options:Ht}}}]}]},{type:"expandable",title:"Appearance",schema:[{name:"enhanced_visuals",selector:{boolean:{}}},{type:"grid",column_min_width:"160px",schema:l}].filter(Nt)},{type:"expandable",title:"Advanced",schema:[...c,...s?[{type:"grid",schema:[{name:"decimals",selector:{number:{min:0,max:5,step:1,mode:"box"}}},{name:"unit",selector:{text:{}}}]}]:[],{name:"fallback",selector:{text:{}}},{name:"setpoint_debounce_ms",selector:{number:{min:0,step:100,mode:"box"}}},{type:"grid",column_min_width:"160px",schema:d},{type:"grid",column_min_width:"150px",schema:[{name:"layout.mode.names",selector:{boolean:{}}},{name:"layout.mode.icons",selector:{boolean:{}}},{name:"layout.mode.headings",selector:{boolean:{}}}]},{type:"grid",column_min_width:"150px",schema:[{name:"tap_action.action",selector:{select:{mode:"dropdown",options:Mt}}},{name:"hold_action.action",selector:{select:{mode:"dropdown",options:Mt}}},{name:"double_tap_action.action",selector:{select:{mode:"dropdown",options:Mt}}}]}].filter(Nt)}]}(this.config,this.hass)} + .schema=${function(t,e){const i=qt(t,e),o=t.entity?.split(".")[0],a=$t(t.entity),r=t.entity?e?.states?.[t.entity]:void 0,n=!0===t.hide_setpoint||!r||Object.keys(a.getSetpoints(r.attributes??{})).length>0,s="fan"!==o&&("climate"===o||"humidifier"===o),c="fan"===o?[]:[{name:"current_value_entity",selector:{entity:{domain:["sensor","input_number"]}}}],l=[...s?[{name:"hide.temperature",selector:{boolean:{}}},{name:"hide_current_value_when_off",selector:{boolean:{}}}]:[],{name:"hide.state",selector:{boolean:{}}}],d=[...s?[{name:"label.temperature",selector:{text:{}}}]:[],{name:"label.state",selector:{text:{}}},...n?[{name:"label.setpoint",selector:{text:{}}}]:[]],h=!1===t.header?[]:[{type:"grid",schema:[{name:"name",selector:{text:{}}},{name:"icon",selector:{icon:{}}}]},{name:"toggle.entity",selector:{entity:{}}},{name:"toggle.name",selector:{text:{}}},...t.header&&"object"==typeof t.header&&t.header.toggle?.entity?[{name:"toggle.icon",selector:{icon:{}}}]:[]];return[{name:"entity",required:!0,selector:{entity:{domain:At}}},{type:"expandable",title:"Card header",schema:[{name:"show_header",selector:{boolean:{}}},...h]},...i.length>0?[{type:"expandable",title:"Controls",schema:[{type:"grid",column_min_width:"150px",schema:i.map(t=>({name:`control.${t}`,selector:{boolean:{}}}))}]}]:[],...n?[{type:"expandable",title:"Target",schema:[{type:"grid",schema:[{name:"layout.step",selector:{select:{mode:"dropdown",options:Mt}}},{name:"step_size",selector:{select:{mode:"dropdown",options:jt}}}]},{type:"grid",column_min_width:"160px",schema:[{name:"hide_setpoint",selector:{boolean:{}}},{name:"hide_setpoint_when_off",selector:{boolean:{}}},{name:"hide.setpoint_label",selector:{boolean:{}}},{name:"disable_setpoint_change_when_off",selector:{boolean:{}}}]}]}]:[],{type:"expandable",title:"Extra entity rows",schema:[{type:"grid",column_min_width:"160px",schema:[{name:"layout.entities.type",selector:{select:{mode:"dropdown",options:Pt}}},{name:"layout.entities.display",selector:{select:{mode:"dropdown",options:Ht}}},{name:"layout.entities.labels",selector:{boolean:{}}},{name:"layout.entities.separator",selector:{boolean:{}}},{name:"layout.entities.alignment",selector:{select:{mode:"dropdown",options:Vt}}}]}]},{type:"expandable",title:"Appearance",schema:[{name:"enhanced_visuals",selector:{boolean:{}}},{type:"grid",column_min_width:"160px",schema:l}].filter(Rt)},{type:"expandable",title:"Advanced",schema:[...c,...s?[{type:"grid",schema:[{name:"decimals",selector:{number:{min:0,max:5,step:1,mode:"box"}}},{name:"unit",selector:{text:{}}}]}]:[],{name:"fallback",selector:{text:{}}},{name:"setpoint_debounce_ms",selector:{number:{min:0,step:100,mode:"box"}}},{type:"grid",column_min_width:"160px",schema:d},{type:"grid",column_min_width:"150px",schema:[{name:"layout.mode.names",selector:{boolean:{}}},{name:"layout.mode.icons",selector:{boolean:{}}},{name:"layout.mode.headings",selector:{boolean:{}}}]},{type:"grid",column_min_width:"150px",schema:[{name:"tap_action.action",selector:{select:{mode:"dropdown",options:Nt}}},{name:"hold_action.action",selector:{select:{mode:"dropdown",options:Nt}}},{name:"double_tap_action.action",selector:{select:{mode:"dropdown",options:Nt}}}]}].filter(Rt)}]}(this.config,this.hass)} .computeLabel=${this._computeLabel} @value-changed=${this._valueChanged} > ${this._renderExtraEntityRows()} + ${this._renderFooterRows()}
- `:B``}}i([gt()],Kt.prototype,"config",void 0),i([pt({attribute:!1})],Kt.prototype,"hass",void 0);const Zt=2,Jt=t=>(...e)=>({_$litDirective$:t,values:e});class Yt{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}const Xt=(t,e)=>{const i=t._$AN;if(void 0===i)return!1;for(const t of i)t._$AO?.(e,!1),Xt(t,e);return!0},Qt=t=>{let e,i;do{if(void 0===(e=t._$AM))break;i=e._$AN,i.delete(t),t=e}while(0===i?.size)},te=t=>{for(let e;e=t._$AM;t=e){let i=e._$AN;if(void 0===i)e._$AN=i=new Set;else if(i.has(t))break;i.add(t),oe(e)}};function ee(t){void 0!==this._$AN?(Qt(this),this._$AM=t,te(this)):this._$AM=t}function ie(t,e=!1,i=0){const o=this._$AH,a=this._$AN;if(void 0!==a&&0!==a.size)if(e)if(Array.isArray(o))for(let t=i;t{t.type==Zt&&(t._$AP??=ie,t._$AQ??=ee)};class ae extends Yt{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,i){super._$AT(t,e,i),te(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(Xt(this,t),Qt(this))}setValue(t){if((t=>void 0===t.strings)(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}}const re=new WeakMap,ne=Jt(class extends ae{render(t){return q}update(t,[e]){const i=e!==this.G;return i&&this.rt(void 0),(i||this.lt!==this.ct)&&(this.G=e,this.ht=t.options?.host,this.rt(this.ct=t.element)),q}rt(t){if(void 0!==this.G)if(this.isConnected||(t=void 0),"function"==typeof this.G){const e=this.ht??globalThis;let i=re.get(e);void 0===i&&(i=new WeakMap,re.set(e,i)),void 0!==i.get(this.G)&&this.G.call(this.ht,void 0),i.set(this.G,t),void 0!==t&&this.G.call(this.ht,t)}else this.G.value=t}get lt(){return"function"==typeof this.G?re.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}}),se=["climate","fan","humidifier"],ce={icons:!0,names:!0,states:!1};function le(t){if("string"==typeof t)return{entity:t};const e=t?.header&&"object"==typeof t.header?t.header:{};return{...t,entity:t?.entity??"",name:t?.name??e.name,icon:t?.icon??e.icon}}class de extends lt{constructor(){super(...arguments),this.config={entities:[]},this.expandedTargetIndex=null,this.editorConfigKeys=new WeakMap}static get styles(){return c` + `:B``}}i([mt()],Xt.prototype,"config",void 0),i([pt({attribute:!1})],Xt.prototype,"hass",void 0);const Qt=2,te=t=>(...e)=>({_$litDirective$:t,values:e});class ee{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}const ie=(t,e)=>{const i=t._$AN;if(void 0===i)return!1;for(const t of i)t._$AO?.(e,!1),ie(t,e);return!0},oe=t=>{let e,i;do{if(void 0===(e=t._$AM))break;i=e._$AN,i.delete(t),t=e}while(0===i?.size)},ae=t=>{for(let e;e=t._$AM;t=e){let i=e._$AN;if(void 0===i)e._$AN=i=new Set;else if(i.has(t))break;i.add(t),se(e)}};function re(t){void 0!==this._$AN?(oe(this),this._$AM=t,ae(this)):this._$AM=t}function ne(t,e=!1,i=0){const o=this._$AH,a=this._$AN;if(void 0!==a&&0!==a.size)if(e)if(Array.isArray(o))for(let t=i;t{t.type==Qt&&(t._$AP??=ne,t._$AQ??=re)};class ce extends ee{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,i){super._$AT(t,e,i),ae(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(ie(this,t),oe(this))}setValue(t){if((t=>void 0===t.strings)(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}}const le=new WeakMap,de=te(class extends ce{render(t){return q}update(t,[e]){const i=e!==this.G;return i&&this.rt(void 0),(i||this.lt!==this.ct)&&(this.G=e,this.ht=t.options?.host,this.rt(this.ct=t.element)),q}rt(t){if(void 0!==this.G)if(this.isConnected||(t=void 0),"function"==typeof this.G){const e=this.ht??globalThis;let i=le.get(e);void 0===i&&(i=new WeakMap,le.set(e,i)),void 0!==i.get(this.G)&&this.G.call(this.ht,void 0),i.set(this.G,t),void 0!==t&&this.G.call(this.ht,t)}else this.G.value=t}get lt(){return"function"==typeof this.G?le.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}}),he=["climate","fan","humidifier"],ue={style:"header",icons:!0,names:!0,states:!1};function pe(t){if("string"==typeof t)return{entity:t};const e=t?.header&&"object"==typeof t.header?t.header:{};return{...t,entity:t?.entity??"",name:t?.name??e.name,icon:t?.icon??e.icon}}class me extends lt{constructor(){super(...arguments),this.config={entities:[]},this.expandedTargetIndex=null,this.editorConfigKeys=new WeakMap}static get styles(){return c` :host { display: block; } @@ -1862,6 +2025,25 @@ ha-card.standard-visuals .thermostat-trigger:active { gap: 8px; } + .selector-style-row { + display: grid; + gap: 6px; + } + + .selector-style-actions { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 8px; + } + + .selector-style-actions ha-button { + width: 100%; + } + + .selector-style-actions ha-button.selected { + --mdc-theme-primary: var(--primary-color); + } + .option-row { display: flex; align-items: center; @@ -1905,11 +2087,19 @@ ha-card.standard-visuals .thermostat-trigger:active { grid-template-columns: 1fr; } } - `}setConfig(t){this.config={...t}}commit(t){const e=this.cleanConfig(t);this.config=e,vt(this,"config-changed",{config:e})}cleanConfig(t){const e={...t};for(const t of Object.keys(e))void 0===e[t]&&delete e[t];return e.selector&&0===Object.keys(e.selector).length&&delete e.selector,e}getTargets(){return function(t){const e=(t.cards??t.entities??[]).map(le);return e.length?e:[{entity:""},{entity:""}]}(this.config)}updateTarget(t,e){const i=this.getTargets();i[t]={...i[t],...e},this.commitTargets(i)}cleanTargets(t){return t.map(t=>{const e=t.entity?.trim()??"",i=t.name?.trim(),o=t.icon?.trim(),{name:a,icon:r,entity:n,...s}=t;return i||o||0!==Object.keys(s).length?{...s,entity:e,...i?{name:i}:{},...o?{icon:o}:{}}:e})}addTarget(){const t=[...this.getTargets(),{entity:""}];this.commitTargets(t)}removeTarget(t){const e=this.getTargets().filter((e,i)=>i!==t);this.commitTargets(e.length?e:[{entity:""}])}commitTargets(t){const{entities:e,...i}=this.config;this.commit({...i,cards:this.cleanTargets(t)})}updateSelector(t,e){const i={...this.config.selector??{}},o=Boolean(e);o===ce[t]?delete i[t]:i[t]=o,this.commit({...this.config,selector:i})}isAutoSelectEnabled(){const t=this.config.auto_select;return!0===t||"recent_activity"===t||"object"==typeof t&&"recent_activity"===t?.mode}updateAutoSelect(t){const{auto_select:e,...i}=this.config;this.commit({...i,...t?{auto_select:{mode:"recent_activity"}}:{}})}updateRememberSelection(t){const{remember_selection:e,...i}=this.config;this.commit({...i,...t?{}:{remember_selection:!1}})}updateStorageKey(t){const e=t.trim(),{storage_key:i,...o}=this.config;this.commit({...o,...e?{storage_key:e}:{}})}getTargetCardConfig(e){const{name:i,icon:o,...a}=e,r=a.header&&"object"==typeof a.header?{...a.header}:{};return i&&!1!==a.header&&void 0===r.name&&(r.name=i),o&&!1!==a.header&&void 0===r.icon&&(r.icon=o),{type:a.type??`custom:${t}`,...a,...!1===a.header?{header:!1}:{header:r}}}configureNestedEditor(t,e){if(!t)return;const i=t,o=this.getTargetCardConfig(e),a=JSON.stringify(o);i.hass=this.hass,this.editorConfigKeys.get(t)!==a&&(i.setConfig?.(o),this.editorConfigKeys.set(t,a))}updateTargetCardConfig(t,e){e.stopPropagation();const i=this.getTargets();i[t]=le(e.detail.config),this.commitTargets(i)}toggleTargetEditor(t){this.expandedTargetIndex=this.expandedTargetIndex===t?null:t}renderEntityPicker(t,e){return B` + `}setConfig(t){this.config={...t}}commit(t){const e=this.cleanConfig(t);this.config=e,vt(this,"config-changed",{config:e})}cleanConfig(t){const e={...t};for(const t of Object.keys(e))void 0===e[t]&&delete e[t];return e.selector&&0===Object.keys(e.selector).length&&delete e.selector,e}getTargets(){return function(t){const e=(t.cards??t.entities??[]).map(pe);return e.length?e:[{entity:""},{entity:""}]}(this.config)}updateTarget(t,e){const i=this.getTargets();i[t]={...i[t],...e},this.commitTargets(i)}cleanTargets(t){return t.map(t=>{const e=t.entity?.trim()??"",i=t.name?.trim(),o=t.icon?.trim(),{name:a,icon:r,entity:n,...s}=t;return i||o||0!==Object.keys(s).length?{...s,entity:e,...i?{name:i}:{},...o?{icon:o}:{}}:e})}addTarget(){const t=[...this.getTargets(),{entity:""}];this.commitTargets(t)}removeTarget(t){const e=this.getTargets().filter((e,i)=>i!==t);this.commitTargets(e.length?e:[{entity:""}])}commitTargets(t){const{entities:e,...i}=this.config;this.commit({...i,cards:this.cleanTargets(t)})}updateSelector(t,e){const i={...this.config.selector??{}},o=Boolean(e);o===ue[t]?delete i[t]:i[t]=o,this.commit({...this.config,selector:i})}updateSelectorStyle(t){const e={...this.config.selector??{}},i="tabs"===t?"tabs":"header";i===ue.style?delete e.style:e.style=i,this.commit({...this.config,selector:e})}renderSelectorStyleOption(t,e,i){return B` + this.updateSelectorStyle(e)} + > + ${t} + + `}isAutoSelectEnabled(){const t=this.config.auto_select;return!0===t||"recent_activity"===t||"object"==typeof t&&"recent_activity"===t?.mode}updateAutoSelect(t){const{auto_select:e,...i}=this.config;this.commit({...i,...t?{auto_select:{mode:"recent_activity"}}:{}})}updateRememberSelection(t){const{remember_selection:e,...i}=this.config;this.commit({...i,...t?{}:{remember_selection:!1}})}updateStorageKey(t){const e=t.trim(),{storage_key:i,...o}=this.config;this.commit({...o,...e?{storage_key:e}:{}})}getTargetCardConfig(e){const{name:i,icon:o,...a}=e,r=a.header&&"object"==typeof a.header?{...a.header}:{};return i&&!1!==a.header&&void 0===r.name&&(r.name=i),o&&!1!==a.header&&void 0===r.icon&&(r.icon=o),{type:a.type??`custom:${t}`,...a,...!1===a.header?{header:!1}:{header:r}}}configureNestedEditor(t,e){if(!t)return;const i=t,o=this.getTargetCardConfig(e),a=JSON.stringify(o);i.hass=this.hass,this.editorConfigKeys.get(t)!==a&&(i.setConfig?.(o),this.editorConfigKeys.set(t,a))}updateTargetCardConfig(t,e){e.stopPropagation();const i=this.getTargets();i[t]=pe(e.detail.config),this.commitTargets(i)}toggleTargetEditor(t){this.expandedTargetIndex=this.expandedTargetIndex===t?null:t}renderEntityPicker(t,e){return B` this.updateTarget(e,{entity:t.detail.value})} @@ -1948,7 +2138,7 @@ ha-card.standard-visuals .thermostat-trigger:active {
this.configureNestedEditor(e,t))} + ${de(e=>this.configureNestedEditor(e,t))} @config-changed=${t=>this.updateTargetCardConfig(e,t)} >
@@ -1972,6 +2162,19 @@ ha-card.standard-visuals .thermostat-trigger:active {

Control how the group chooses and labels the active card.

+
+
+ Selector style + Choose the normal arrow/menu header or visible tab + buttons. +
+
+ ${this.renderSelectorStyleOption("Header navigation","header","header"===(t.style??ue.style))} + ${this.renderSelectorStyleOption("Tabbed buttons","tabs","tabs"===t.style)} +
+
${this.renderOption("Follow active device","Switch to a card when its mode or on/off activity changes.",this.isAutoSelectEnabled(),t=>this.updateAutoSelect(t))} ${this.renderOption("Remember selection","Keep the last selected card after the dashboard reloads.",!1!==this.config.remember_selection,t=>this.updateRememberSelection(t))} ${this.renderOption("Show icons","Show each card icon in the selector and menu.",!1!==t.icons,t=>this.updateSelector("icons",t))} @@ -1995,7 +2198,7 @@ ha-card.standard-visuals .thermostat-trigger:active { @change=${t=>o(t.currentTarget.checked)} >
- `}}function he(t){if("string"!=typeof t.entity_id)return;const[e]=t.entity_id.split(".");return"climate"===e?"hvac_action":"humidifier"===e?"action":void 0}function ue(t){const e=he(t),i=e?t.attributes?.[e]:void 0;return"string"==typeof i&&i?i:void 0}function pe(t,e,i){if("string"!=typeof t.entity_id)return void 0===t.state?"":String(t.state);const[o]=t.entity_id.split("."),a=ue(t),r=he(t);if(a)return"function"==typeof e.formatEntityAttributeValue&&r?e.formatEntityAttributeValue(t,r):i(a,function(t){if("string"!=typeof t.entity_id)return"";const[e]=t.entity_id.split("."),i=he(t);return e&&i?`state_attributes.${e}.${i}.`:""}(t));if("fan"===o&&"on"===t.state){if(t.attributes?.preset_mode)return"function"==typeof e.formatEntityAttributeValue?e.formatEntityAttributeValue(t,"preset_mode"):i(t.attributes.preset_mode,"state_attributes.fan.preset_mode.");if("number"==typeof t.attributes?.percentage)return`${t.attributes.percentage}%`;if(t.attributes?.speed)return String(t.attributes.speed)}return"function"==typeof e.formatEntityState?e.formatEntityState(t):i(String(t.state),`component.${o}.state._.`)}i([pt({attribute:!1})],de.prototype,"hass",void 0),i([gt()],de.prototype,"config",void 0),i([gt()],de.prototype,"expandedTargetIndex",void 0);const ge={auto:"mdi:radiator",cooling:"mdi:snowflake",fan:"mdi:fan",heating:"mdi:radiator",idle:"mdi:radiator-disabled",on:"mdi:power",off:"mdi:radiator-off"},me={auto:"mdi:air-conditioner",cooling:"mdi:snowflake",fan:"mdi:fan",heating:"mdi:radiator",idle:"mdi:air-conditioner",on:"mdi:air-conditioner",off:"mdi:air-conditioner"},fe={...ge,auto:"mdi:radiator",idle:ge.idle,off:"mdi:radiator"},ve={fan:{on:"mdi:fan",off:"mdi:fan-off"},humidifier:{on:"mdi:air-humidifier",off:"mdi:air-humidifier-off"}},ye={auto:"hass:autorenew",cool:"hass:snowflake",dry:"hass:water-percent",fan_only:"hass:fan",heat_cool:"hass:autorenew",heat:"hass:fire",on:"hass:power",off:"hass:power",forward:"mdi:arrow-right",reverse:"mdi:arrow-left",true:"mdi:fan",false:"mdi:fan-off",low:"mdi:fan-speed-1",mid:"mdi:fan-speed-2",medium:"mdi:fan-speed-2",high:"mdi:fan-speed-3",max:"st:fan-speed-4",turbo:"st:fan-speed-5",1:"mdi:fan-speed-1",2:"mdi:fan-speed-2",3:"mdi:fan-speed-3",4:"st:fan-speed-4",5:"st:fan-speed-5",automatic:"mdi:fan-auto",powerful:"mdi:fan-plus",quiet:"mdi:fan-minus",silent:"mdi:fan-minus",normal:"mdi:water-percent",vertical:"mdi:arrow-up-down",top:"mdi:arrow-up","top-middle":"mdi:arrow-top-right",middle:"mdi:arrow-collapse-vertical","middle-bottom":"mdi:arrow-bottom-right",bottom:"mdi:arrow-down",upper:"mdi:arrow-up",lower:"mdi:arrow-down",horizontal:"mdi:arrow-left-right",left:"mdi:arrow-left","center-left":"mdi:arrow-top-left",center:"mdi:arrow-collapse-horizontal","center-right":"mdi:arrow-top-right",right:"mdi:arrow-right",both:"mdi:arrow-all",swing:"mdi:arrow-oscillating",wide:"mdi:arrow-expand-horizontal",narrow:"mdi:arrow-collapse-horizontal",split:"mdi:arrow-split-vertical",none:"mdi:circle-off-outline",away:"mdi:home-export-outline",eco:"mdi:leaf",boost:"mdi:weather-windy",comfort:"mdi:sofa",auto_comfort:"mdi:sofa","auto-comfort":"mdi:sofa","auto comfort":"mdi:sofa",home:"mdi:home",sleep:"mdi:sleep",activity:"mdi:run"};function _e(t){const e=String(t),i=e.toLowerCase().replace(/\s+/g,"_");return ye[e]??ye[i]}function be(t){const e=String(t);return{low:"Low",mid:"Mid",medium:"Medium",high:"High",max:"Max",turbo:"Turbo",auto:"Auto"}[e.toLowerCase().replace(/\s+/g,"_")]??e}function we(t,e,i,o=!0){if(!1===t)return!1;let a;a="string"==typeof t?.name?t.name:!1!==t?.name&&("function"==typeof i.formatEntityName?i.formatEntityName(e):e.attributes.friendly_name);let r=o?function(t){const[e]=t.entity_id.split("."),i=ue(t),o=i?Se(t):void 0;return o??t.attributes.icon??Se(t)??ve[e]?.[t.state]??(i?ge:ye)}(e):function(t){return ue(t)?ge:ye}(e);return void 0!==t?.icon&&(r=t.icon),{name:a,icon:r,slashOffIcon:o&&Ae(e,r),toggle:t?.toggle?xe(t.toggle,i):null,toggles:$e(t,i),faults:ke(t?.faults,i)}}function xe(t,e){const i=e.states[t.entity];if(!i)return null;let o="";return o=!0===t?.name?i.attributes.friendly_name:t?.name??"",{entity:i,label:o,icon:t?.icon??!1,hide_when_off:t?.hide_when_off}}function $e(t,e){return[...t?.toggle?[t.toggle]:[],...Array.isArray(t?.toggles)?t.toggles:[]].map(t=>xe(t,e)).filter(t=>!!t)}function Se(t){const[e]=t.entity_id.split(".");if("climate"!==e)return;const i=Array.isArray(t.attributes?.hvac_modes)?t.attributes.hvac_modes:[],o=ue(t),a=String(o||t.state);return i.includes("cool")||i.includes("dry")||i.includes("fan_only")||["cool","cooling","dry","fan_only","fan"].includes(a)?me:fe}function Ae(t,e){if("off"!==t.state)return!1;const i="object"==typeof e?e[ue(t)||t.state]??!1:e;if("string"!=typeof i)return!1;const[o]=t.entity_id.split("."),a="climate"===o?ge.off:ve[o]?.off;return Boolean(a)&&i!==a&&!i.endsWith("-off")}function ke(t,e){return Array.isArray(t)?t.filter(({entity:t})=>Boolean(e.states?.[t])).map(({entity:t,...i})=>({...i,state:e.states[t],entity:t})):[]}const Ce={icons:!0,names:!0,states:!1},Ee=["climate","fan","humidifier"];function ze(t){return t.split(".")[0]}function Te(t){return"string"==typeof t?t.replace(/[^a-z0-9_-]/gi,""):""}function Oe(e){if("string"==typeof e){const i=e.trim();return i?{entity:i,config:{type:`custom:${t}`,entity:i}}:null}if(!e?.entity)return null;const{entity:i,name:o,icon:a,...r}=e,n="object"==typeof r.header&&r.header?{...r.header}:{};return o&&!1!==r.header&&void 0===n.name&&(n.name=o),a&&!1!==r.header&&void 0===n.icon&&(n.icon=a),{entity:i,config:{type:r.type??`custom:${t}`,...r,entity:i,...!1===r.header?{header:!1}:{header:n}}}}class Ne extends lt{constructor(){super(...arguments),this.targets=[],this.selectedEntity="",this.menuOpen=!1,this.cardFading=!1,this.embeddedCardEntity="",this.embeddedCardConfigSignature="",this.embeddedCardPendingSignature="",this.fadeInAfterSync=!1,this.activitySignatures=new Map,this.activitySignaturesInitialized=!1,this.persistedActivityApplied=!1,this.lastManualSelectionAt=0}static get styles(){return c` + `}}function ge(t){if("string"!=typeof t.entity_id)return;const[e]=t.entity_id.split(".");return"climate"===e?"hvac_action":"humidifier"===e?"action":void 0}function fe(t){const e=ge(t),i=e?t.attributes?.[e]:void 0;return"string"==typeof i&&i?i:void 0}function ve(t,e,i){if("string"!=typeof t.entity_id)return void 0===t.state?"":String(t.state);const[o]=t.entity_id.split("."),a=fe(t),r=ge(t);if(a)return"function"==typeof e.formatEntityAttributeValue&&r?e.formatEntityAttributeValue(t,r):i(a,function(t){if("string"!=typeof t.entity_id)return"";const[e]=t.entity_id.split("."),i=ge(t);return e&&i?`state_attributes.${e}.${i}.`:""}(t));if("fan"===o&&"on"===t.state){if(t.attributes?.preset_mode)return"function"==typeof e.formatEntityAttributeValue?e.formatEntityAttributeValue(t,"preset_mode"):i(t.attributes.preset_mode,"state_attributes.fan.preset_mode.");if("number"==typeof t.attributes?.percentage)return`${t.attributes.percentage}%`;if(t.attributes?.speed)return String(t.attributes.speed)}return"function"==typeof e.formatEntityState?e.formatEntityState(t):i(String(t.state),`component.${o}.state._.`)}i([pt({attribute:!1})],me.prototype,"hass",void 0),i([mt()],me.prototype,"config",void 0),i([mt()],me.prototype,"expandedTargetIndex",void 0);const ye={auto:"mdi:radiator",cooling:"mdi:snowflake",fan:"mdi:fan",heating:"mdi:radiator",idle:"mdi:radiator-disabled",on:"mdi:power",off:"mdi:radiator-off"},be={auto:"mdi:air-conditioner",cooling:"mdi:snowflake",fan:"mdi:fan",heating:"mdi:radiator",idle:"mdi:air-conditioner",on:"mdi:air-conditioner",off:"mdi:air-conditioner"},_e={...ye,auto:"mdi:radiator",idle:ye.idle,off:"mdi:radiator"},we={fan:{on:"mdi:fan",off:"mdi:fan-off"},humidifier:{on:"mdi:air-humidifier",off:"mdi:air-humidifier-off"}},xe={auto:"hass:autorenew",cool:"hass:snowflake",dry:"hass:water-percent",fan_only:"hass:fan",heat_cool:"hass:autorenew",heat:"hass:fire",on:"hass:power",off:"hass:power",forward:"mdi:arrow-right",reverse:"mdi:arrow-left",true:"mdi:fan",false:"mdi:fan-off",low:"mdi:fan-speed-1",mid:"mdi:fan-speed-2",medium:"mdi:fan-speed-2",high:"mdi:fan-speed-3",max:"st:fan-speed-4",turbo:"st:fan-speed-5",1:"mdi:fan-speed-1",2:"mdi:fan-speed-2",3:"mdi:fan-speed-3",4:"st:fan-speed-4",5:"st:fan-speed-5",automatic:"mdi:fan-auto",powerful:"mdi:fan-plus",quiet:"mdi:fan-minus",silent:"mdi:fan-minus",normal:"mdi:water-percent",vertical:"mdi:arrow-up-down",top:"mdi:arrow-up","top-middle":"mdi:arrow-top-right",middle:"mdi:arrow-collapse-vertical","middle-bottom":"mdi:arrow-bottom-right",bottom:"mdi:arrow-down",upper:"mdi:arrow-up",lower:"mdi:arrow-down",horizontal:"mdi:arrow-left-right",left:"mdi:arrow-left","center-left":"mdi:arrow-top-left",center:"mdi:arrow-collapse-horizontal","center-right":"mdi:arrow-top-right",right:"mdi:arrow-right",both:"mdi:arrow-all",swing:"mdi:arrow-oscillating",wide:"mdi:arrow-expand-horizontal",narrow:"mdi:arrow-collapse-horizontal",split:"mdi:arrow-split-vertical",none:"mdi:circle-off-outline",away:"mdi:home-export-outline",eco:"mdi:leaf",boost:"mdi:weather-windy",comfort:"mdi:sofa",auto_comfort:"mdi:sofa","auto-comfort":"mdi:sofa","auto comfort":"mdi:sofa",home:"mdi:home",sleep:"mdi:sleep",activity:"mdi:run"};function $e(t){const e=String(t),i=e.toLowerCase().replace(/\s+/g,"_");return xe[e]??xe[i]}function Se(t){const e=String(t);return{low:"Low",mid:"Mid",medium:"Medium",high:"High",max:"Max",turbo:"Turbo",auto:"Auto"}[e.toLowerCase().replace(/\s+/g,"_")]??e}function Ae(t,e,i,o=!0){if(!1===t)return!1;let a;a="string"==typeof t?.name?t.name:!1!==t?.name&&("function"==typeof i.formatEntityName?i.formatEntityName(e):e.attributes.friendly_name);let r=o?function(t){const[e]=t.entity_id.split("."),i=fe(t),o=i?Ee(t):void 0;return o??t.attributes.icon??Ee(t)??we[e]?.[t.state]??(i?ye:xe)}(e):function(t){return fe(t)?ye:xe}(e);return void 0!==t?.icon&&(r=t.icon),{name:a,icon:r,slashOffIcon:o&&ze(e,r),toggle:t?.toggle?ke(t.toggle,i):null,toggles:Ce(t,i),faults:Te(t?.faults,i)}}function ke(t,e){const i=e.states[t.entity];if(!i)return null;let o="";return o=!0===t?.name?i.attributes.friendly_name:t?.name??"",{entity:i,label:o,icon:t?.icon??!1,hide_when_off:t?.hide_when_off}}function Ce(t,e){return[...t?.toggle?[t.toggle]:[],...Array.isArray(t?.toggles)?t.toggles:[]].map(t=>ke(t,e)).filter(t=>!!t)}function Ee(t){const[e]=t.entity_id.split(".");if("climate"!==e)return;const i=Array.isArray(t.attributes?.hvac_modes)?t.attributes.hvac_modes:[],o=fe(t),a=String(o||t.state);return i.includes("cool")||i.includes("dry")||i.includes("fan_only")||["cool","cooling","dry","fan_only","fan"].includes(a)?be:_e}function ze(t,e){if("off"!==t.state)return!1;const i="object"==typeof e?e[fe(t)||t.state]??!1:e;if("string"!=typeof i)return!1;const[o]=t.entity_id.split("."),a="climate"===o?ye.off:we[o]?.off;return Boolean(a)&&i!==a&&!i.endsWith("-off")}function Te(t,e){return Array.isArray(t)?t.filter(({entity:t})=>Boolean(e.states?.[t])).map(({entity:t,...i})=>({...i,state:e.states[t],entity:t})):[]}const Oe={style:"header",icons:!0,names:!0,states:!1},Re=["climate","fan","humidifier"];function Ne(t){return t.split(".")[0]}function Me(t){return"string"==typeof t?t.replace(/[^a-z0-9_-]/gi,""):""}function je(e){if("string"==typeof e){const i=e.trim();return i?{entity:i,config:{type:`custom:${t}`,entity:i}}:null}if(!e?.entity)return null;const{entity:i,name:o,icon:a,...r}=e,n="object"==typeof r.header&&r.header?{...r.header}:{};return o&&!1!==r.header&&void 0===n.name&&(n.name=o),a&&!1!==r.header&&void 0===n.icon&&(n.icon=a),{entity:i,config:{type:r.type??`custom:${t}`,...r,entity:i,...!1===r.header?{header:!1}:{header:n}}}}class Pe extends lt{constructor(){super(...arguments),this.targets=[],this.selectedEntity="",this.menuOpen=!1,this.cardFading=!1,this.embeddedCardEntity="",this.embeddedCardConfigSignature="",this.embeddedCardPendingSignature="",this.fadeInAfterSync=!1,this.activitySignatures=new Map,this.activitySignaturesInitialized=!1,this.persistedActivityApplied=!1,this.lastManualSelectionAt=0}static get styles(){return c` :host { display: block; } @@ -2033,6 +2236,171 @@ ha-card.standard-visuals .thermostat-trigger:active { transform: translateY(var(--st-group-header-top-buffer, 2px)); } + .group-selector.tabs { + display: block; + padding: calc(var(--st-spacing, var(--st-default-spacing, 4px)) * 3) + calc(var(--st-spacing, var(--st-default-spacing, 4px)) * 3) 0; + height: auto; + transform: translateY(var(--st-group-header-top-buffer, 2px)); + } + + .group-tabs { + display: grid; + grid-template-columns: repeat( + auto-fit, + minmax(var(--st-group-tab-min-width, 120px), 1fr) + ); + gap: calc(var(--st-spacing, var(--st-default-spacing, 4px)) * 2); + min-width: 0; + } + + .group-tab { + appearance: none; + border: 0; + border-radius: var(--st-group-tab-radius, 10px); + min-width: 0; + min-height: var(--st-group-tab-height, 46px); + padding: 7px 12px; + display: inline-flex; + align-items: center; + justify-content: center; + gap: 8px; + color: var(--st-group-tab-color, var(--primary-text-color)); + background: var( + --st-group-tab-background, + color-mix(in srgb, var(--primary-text-color) 12%, transparent) + ); + font: inherit; + font-weight: 600; + line-height: 1.15; + cursor: pointer; + transition: + background 160ms var(--st-motion-ease, ease), + color 160ms var(--st-motion-ease, ease), + opacity 160ms var(--st-motion-ease, ease); + } + + .group-tab:hover, + .group-tab:focus-visible { + background: var( + --st-group-tab-hover-background, + color-mix(in srgb, currentColor 22%, transparent) + ); + } + + .group-tab:focus-visible { + outline: 2px solid var(--primary-color); + outline-offset: 2px; + } + + .group-tab.selected { + color: var(--st-group-tab-selected-color, #fff); + background: var( + --st-group-tab-selected-background, + var(--primary-color) + ); + } + + .group-tab ha-icon { + --mdc-icon-size: 21px; + --iron-icon-width: 21px; + --iron-icon-height: 21px; + flex: 0 0 auto; + } + + .group-tab-labels { + display: grid; + min-width: 0; + gap: 1px; + text-align: center; + } + + .group-tab-name, + .group-tab-state { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + + .group-tab-state { + color: currentColor; + opacity: 0.78; + font-size: var(--ha-font-size-xs, 11px); + font-weight: 500; + } + + .group-tab.state-off { + --st-group-tab-background: color-mix( + in srgb, + var(--state-icon-color, var(--secondary-text-color)) 20%, + transparent + ); + --st-group-tab-color: var(--secondary-text-color); + } + + .group-tab.cooling, + .group-tab.state-cool { + --st-group-tab-background: color-mix( + in srgb, + var(--state-climate-cool-color, var(--cool-color, #2b9af9)) 22%, + transparent + ); + --st-group-tab-color: var( + --state-climate-cool-color, + var(--cool-color, #2b9af9) + ); + --st-group-tab-selected-background: var( + --state-climate-cool-color, + var(--cool-color, #2b9af9) + ); + } + + .group-tab.heating, + .group-tab.state-heat { + --st-group-tab-background: color-mix( + in srgb, + var(--state-climate-heat-color, var(--heat-color, #ff8100)) 22%, + transparent + ); + --st-group-tab-color: var( + --state-climate-heat-color, + var(--heat-color, #ff8100) + ); + --st-group-tab-selected-background: var( + --state-climate-heat-color, + var(--heat-color, #ff8100) + ); + } + + .group-tab.drying, + .group-tab.state-dry { + --st-group-tab-background: color-mix( + in srgb, + var(--state-climate-dry-color, var(--dry-color, #efbd07)) 24%, + transparent + ); + --st-group-tab-color: var( + --state-climate-dry-color, + var(--dry-color, #efbd07) + ); + --st-group-tab-selected-background: var( + --state-climate-dry-color, + var(--dry-color, #efbd07) + ); + } + + .group-tab.domain-fan:not(.state-off), + .group-tab.humidifying { + --st-group-tab-background: color-mix( + in srgb, + var(--primary-color) 22%, + transparent + ); + --st-group-tab-color: var(--primary-color); + --st-group-tab-selected-background: var(--primary-color); + } + .group-title { flex: 1 1 auto; min-width: 0; @@ -2469,7 +2837,7 @@ ha-card.standard-visuals .thermostat-trigger:active { animation: st-group-fan-spin var(--st-fan-spin-duration, 2.4s) linear infinite; } - `}static getConfigElement(){return window.document.createElement(`${t}-group-editor`)}static getStubConfig(t){return{entities:Object.keys(t?.states??{}).filter(t=>Ee.includes(ze(t))).slice(0,2),card:{}}}setConfig(t){this.clearAutoSelectResumeTimer();const e=(t.cards??t.entities??[]).map(Oe).filter(Boolean);if(!e.length)throw new Error("Simple Thermostat Group requires at least one card");this.config={...t,selector:{...Ce,...t.selector??{}}},this.targets=e,this.selectedEntity=this.getInitialSelection(t,e),this.activitySignatures.clear(),this.activitySignaturesInitialized=!1,this.persistedActivityApplied=!1}updated(){this.syncAutoSelectRecentActivity(),this.syncEmbeddedCard(),this.syncOutsideClickListener(),this.syncTitleFit()}getCardSize(){if(!this.config||!this.targets.length)return 1;const t=this.getSelectedTarget(),e=this.getTargetCardConfig(t),i=Array.isArray(e.entities)?e.entities.length:0,o=i?Math.max(1,Math.ceil(i/2)):0,a=this.getConfiguredModeRowCount(e),r=!0===e.hide_setpoint?0:1;return Math.max(2,1+o+r+a)}disconnectedCallback(){this.clearOutsideClickListener(),this.clearAutoSelectResumeTimer(),super.disconnectedCallback()}getInitialSelection(t,e){const i=new Set(e.map(t=>t.entity)),o=!1===t.remember_selection?"":this.readStoredSelection(t);return o&&i.has(o)?o:t.selected&&i.has(t.selected)?t.selected:e[0].entity}readStoredSelection(t){return this.readStoredSelectionRecord(t)?.entity??""}readStoredSelectionRecord(t){try{const e=window.localStorage?.getItem(this.getStorageKey(t));if(!e)return;if(!e.trim().startsWith("{"))return{entity:e,timestamp:0};const i=JSON.parse(e);if("string"==typeof i.entity)return{entity:i.entity,timestamp:Number.isFinite(i.timestamp)?Number(i.timestamp):0}}catch(t){return}}writeStoredSelection(t){if(this.config&&!1!==this.config.remember_selection)try{window.localStorage?.setItem(this.getStorageKey(this.config),JSON.stringify({entity:t,timestamp:Date.now()}))}catch(t){}}readStoredActivity(t){try{const e=window.localStorage?.getItem(this.getActivityStorageKey(t));if(!e)return;const i=JSON.parse(e);if("string"==typeof i.entity&&"string"==typeof i.signature&&Number.isFinite(i.timestamp))return{entity:i.entity,signature:i.signature,timestamp:Number(i.timestamp)}}catch(t){return}}writeStoredActivity(t){if(this.config)try{window.localStorage?.setItem(this.getActivityStorageKey(this.config),JSON.stringify(t))}catch(t){}}getStorageKey(t){if(t.storage_key)return`simple-thermostat-group:${t.storage_key}`;return`simple-thermostat-group:${this.targets.map(t=>t.entity).join("|")}`}getActivityStorageKey(t){return`${this.getStorageKey(t)}:recent-activity`}getConfiguredModeRowCount(t){const e=t.control;return!1===e?0:Array.isArray(e)?e.filter(Boolean).length:e&&"object"==typeof e?Object.entries(e).filter(([t,e])=>!t.startsWith("_")&&!1!==e).length:1}clearAutoSelectResumeTimer(){void 0!==this.autoSelectResumeTimer&&(window.clearTimeout(this.autoSelectResumeTimer),this.autoSelectResumeTimer=void 0)}getSelectedTarget(){return this.targets.find(t=>t.entity===this.selectedEntity)??this.targets[0]}getSelectedState(){const t=this.getSelectedTarget();return this.hass?.states?.[t.entity]}openSelectedPopover(){const t=this.getSelectedTarget();t?.entity&&vt(this,"hass-more-info",{entityId:t.entity})}onSelectorHeaderKeyDown(t){"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.openSelectedPopover())}getGroupCardClasses(){const t=this.getSelectedState();if(!t)return"group-card group-shell";const e=ze(t.entity_id),i=ue(t),o=["unavailable","unknown"].includes(String(t.state));return["group-card","group-shell",`domain-${Te(e)}`,`state-${Te(t.state)}`,Te(i),o&&Te(t.state)].filter(Boolean).join(" ")}getGroupCardStyle(){const t=this.getSelectedState();return t?function(t,e={}){if("fan"!==t)return"";const i=Number(e?.percentage);if(Number.isNaN(i))return"";const o=Math.min(Math.max(i,0),100);return`--st-fan-spin-duration: ${Math.max(.9,3.2-o/100*2.1).toFixed(2)}s;`}(ze(t.entity_id),t.attributes):""}getSelectedIndex(){const t=this.targets.findIndex(t=>t.entity===this.selectedEntity);return-1===t?0:t}isRecentActivityAutoSelectEnabled(){const t=this.config?.auto_select;return!!t&&(!0===t||"recent_activity"===t||"object"==typeof t&&"recent_activity"===t.mode)}getAutoSelectManualPauseMs(){const t=this.config?.auto_select;if(t&&"object"==typeof t){const e=Number(t.manual_pause_ms??t.cooldown_ms);if(Number.isFinite(e)&&e>=0)return e}return 3e4}pauseAutoSelectAfterManualSelection(){this.lastManualSelectionAt=Date.now(),this.clearAutoSelectResumeTimer(),this.isRecentActivityAutoSelectEnabled()&&(this.autoSelectResumeTimer=window.setTimeout(()=>{this.autoSelectResumeTimer=void 0,this.lastManualSelectionAt=0,this.isRecentActivityAutoSelectEnabled()&&!this.menuOpen&&this.selectMostRecentStateActivity()},this.getAutoSelectManualPauseMs()))}getActivitySignature(t){const e=this.hass?.states?.[t.entity];if(!e)return"";const i=ze(t.entity),o=e.attributes??{},a=ue(e)??"",r="climate"===i?["hvac_action","temperature","target_temp_low","target_temp_high","preset_mode","fan_mode","swing_mode","swing_horizontal_mode","swing_vertical_mode"]:"fan"===i?["percentage","preset_mode","direction","oscillating"]:"humidifier"===i?["action","humidity","mode"]:[],n=[`state:${e.state}`,`action:${a}`];return r.forEach(t=>{n.push(`${t}:${JSON.stringify(o[t]??null)}`)}),n.join("|")}getActivityTimestamp(t){const e=this.hass?.states?.[t.entity],i=this.getActivityActiveRank(t)>1?e?.last_updated??e?.last_changed:e?.last_changed??e?.last_updated,o="string"==typeof i?Date.parse(i):NaN;return Number.isFinite(o)?o:0}getActivityCandidate(t,e=this.getActivityTimestamp(t)){return{target:t,timestamp:e,activeRank:this.getActivityActiveRank(t)}}isBetterActivityCandidate(t,e){return!e||(t.activeRank!==e.activeRank?t.activeRank>e.activeRank:t.timestamp>=e.timestamp)}getMostRecentStateActivityCandidate(){return this.targets.map(t=>this.getActivityCandidate(t)).filter(t=>t.timestamp>0).reduce((t,e)=>this.isBetterActivityCandidate(e,t)?e:t,void 0)}applyPersistedActivitySelection(t){if(this.persistedActivityApplied||!this.config||!this.isRecentActivityAutoSelectEnabled())return;this.persistedActivityApplied=!0;const e=this.readStoredSelectionRecord(this.config),i=e&&this.targets.some(t=>t.entity===e.entity),o=this.getMostRecentStateActivityCandidate();if(i&&(!o||o.timestamp<=e.timestamp))return void this.selectEntity(e.entity,!1);const a=this.readStoredActivity(this.config);if(!a)return void this.selectMostRecentStateActivity(t);if(!this.targets.some(t=>t.entity===a.entity))return void this.selectMostRecentStateActivity(t);const r=this.targets.find(t=>t.entity===a.entity),n=t.get(a.entity);if(r&&n&&n===a.signature){const e=this.getActivityCandidate(r,a.timestamp);return o&&this.isBetterActivityCandidate(o,e)?void this.selectMostRecentStateActivity(t):void this.selectEntity(a.entity,!1)}this.selectMostRecentStateActivity(t)}selectMostRecentStateActivity(t){const e=this.getMostRecentStateActivityCandidate();if(e&&e.target.entity!==this.selectedEntity&&this.selectEntity(e.target.entity,!1),e&&t){const i=t.get(e.target.entity);i&&this.writeStoredActivity({entity:e.target.entity,signature:i,timestamp:e.timestamp})}}getActivityActiveRank(t){const e=this.hass?.states?.[t.entity];if(!e)return 0;const i=ze(t.entity),o=ue(e)??e.attributes?.action,a="string"==typeof e.state?e.state.toLowerCase():"",r="string"==typeof o?o.toLowerCase():"";if("climate"===i)return["heating","cooling","drying"].includes(r)?2:a&&"off"!==a?1:0;if("fan"===i){const t=Number(e.attributes?.percentage);return"on"===a||t>0?2:0}return"humidifier"===i?["drying","humidifying"].includes(r)?2:a&&!["off","idle"].includes(a)?1:0:a&&"off"!==a?1:0}syncAutoSelectRecentActivity(){if(!this.config||!this.hass||!this.targets.length)return;const t=[],e=new Map;if(this.targets.forEach(i=>{const o=this.getActivitySignature(i);e.set(i.entity,o),this.activitySignaturesInitialized&&o&&o!==this.activitySignatures.get(i.entity)&&(this.writeStoredActivity({entity:i.entity,signature:o,timestamp:Date.now()}),t.push(this.getActivityCandidate(i,Date.now())))}),this.activitySignatures=e,!this.activitySignaturesInitialized)return this.activitySignaturesInitialized=!0,void this.applyPersistedActivitySelection(e);if(!t.length||!this.isRecentActivityAutoSelectEnabled()||this.menuOpen||Date.now()-this.lastManualSelectionAtthis.isBetterActivityCandidate(e,t)?e:t);this.selectEntity(i.target.entity,!1)}getTargetLabel(t){const e=this.parseTargetHeader(t);if(e&&"string"==typeof e.name)return e.name;const i=this.hass?.states?.[t.entity];return i&&"function"==typeof this.hass?.formatEntityName?this.hass.formatEntityName(i):i?.attributes?.friendly_name??t.entity}getTargetIcon(t){if(!(this.config?.selector??Ce).icons)return"";const e=this.parseTargetHeader(t);if(e&&e.icon)return this.resolveHeaderIcon(e.icon,t);const i=this.hass?.states?.[t.entity];if(i?.attributes?.icon)return i.attributes.icon;const o=ze(t.entity);return"fan"===o?"mdi:fan":"humidifier"===o?"mdi:air-humidifier":"mdi:air-conditioner"}getTargetHeaderData(t){return this.parseTargetHeader(t)}parseTargetHeader(t){const e=this.hass?.states?.[t.entity];if(!e||!this.hass)return null;const i=this.getTargetCardConfig(t);return we(i.header,e,this.hass,!1!==i.enhanced_visuals)}resolveHeaderIcon(t,e){if("string"==typeof t)return t;if(!t||"object"!=typeof t)return"";const i=this.hass?.states?.[e.entity];if(!i)return"";const o=t[ue(i)||String(i.state)];return"string"==typeof o?o:""}getHeaderToggleConfigs(t){const e=t.config.header;return e&&"object"==typeof e?[...e.toggle?[e.toggle]:[],...Array.isArray(e.toggles)?e.toggles:[]].filter(t=>t?.entity&&this.hass?.states?.[t.entity]):[]}getEmbeddedConfig(){const t=this.getSelectedTarget();return this.getTargetCardConfig(t)}getEmbeddedConfigSignature(t){return JSON.stringify(t,(t,e)=>!e||"object"!=typeof e||Array.isArray(e)?e:Object.keys(e).sort().reduce((t,i)=>(t[i]=e[i],t),{}))}getTargetCardConfig(e){const i={...this.config?.card??{},...this.getSourceTargetConfig(e),...e.config};if(!i.card_mod){const t=this.getFallbackCardMod();t&&(i.card_mod=t)}return{...i,embedded:!0,entity:e.entity,type:e.config.type??`custom:${t}`}}getSourceTargetConfig(t){const e=(this.config?.cards??this.config?.entities??[]).find(e=>!!e&&"object"==typeof e&&e.entity===t.entity);return e&&"object"==typeof e?e:{}}getFallbackCardMod(){const t=(this.config?.card??{}).card_mod;if(t)return t;const e=(this.config?.cards??this.config?.entities??[]).find(t=>!!t&&"object"==typeof t&&!!t.card_mod);return e?.card_mod}getCardHelpers(){return this.cardHelpersPromise||(this.cardHelpersPromise="function"==typeof window.loadCardHelpers?window.loadCardHelpers():Promise.reject(new Error("Home Assistant card helpers unavailable"))),this.cardHelpersPromise}createFallbackEmbeddedCardElement(e){const i=window.document.createElement(t);if("function"==typeof i.setConfig)return i.setConfig(e),i}installEmbeddedCard(t,e,i,o){this.config&&this.hass&&(e&&"function"==typeof e.setConfig?this.getEmbeddedConfigSignature(this.getEmbeddedConfig())===o&&(this.embeddedCard=e,this.embeddedCardEntity=String(i.entity??""),this.embeddedCardConfigSignature=o,this.embeddedCardPendingSignature="",t.replaceChildren(e),"function"==typeof e.setConfig&&e.setConfig(i),e.hass=this.hass,this.syncEmbeddedPresentation()):this.embeddedCardPendingSignature="")}syncEmbeddedCard(){if(!this.config||!this.hass)return;const e=this.renderRoot.querySelector(".embedded-card-host");if(!e)return;const i=this.getEmbeddedConfig(),o=this.getEmbeddedConfigSignature(i);if(!this.embeddedCard||this.embeddedCardEntity!==i.entity||this.embeddedCardConfigSignature!==o){if("function"!=typeof window.loadCardHelpers){const a=window.customElements.get(t)?this.createFallbackEmbeddedCardElement(i):void 0;return a?void this.installEmbeddedCard(e,a,i,o):void(this.embeddedCardPendingSignature="")}if(this.embeddedCardPendingSignature===o)return;return this.embeddedCardPendingSignature=o,void this.getCardHelpers().then(t=>t.createCardElement(i)).catch(()=>window.customElements.get(t)?this.createFallbackEmbeddedCardElement(i):void 0).then(t=>this.installEmbeddedCard(e,t,i,o))}this.embeddedCard.hass=this.hass,this.syncEmbeddedPresentation()}syncEmbeddedPresentation(){const t=this.embeddedCard;(t?.updateComplete??Promise.resolve()).catch(()=>{}).then(()=>window.requestAnimationFrame(()=>this.applyEmbeddedPresentation()))}applyEmbeddedPresentation(){const t=this.renderRoot.querySelector(".embedded-card-host"),e=this.renderRoot.querySelector(".group-selector"),i=this.embeddedCard;t&&i&&(t.style.removeProperty("--st-group-cropped-header-height"),i.style.setProperty("--st-group-embedded-header-min-height",this.getEmbeddedHeaderReserve(i,e)),this.fadeInAfterSync&&(this.fadeInAfterSync=!1,window.requestAnimationFrame(()=>{this.cardFading=!1})))}getEmbeddedHeaderReserve(t,e){const i="calc(var(--st-group-header-control-height, 34px) + var(--st-group-header-top-buffer, 2px) + calc(var(--st-spacing, var(--st-default-spacing, 4px)) * 6))",o=this.getEmbeddedHeaderReserveMinimum();if(!e)return i;const a=t.getBoundingClientRect(),r=e.getBoundingClientRect(),n=Math.ceil(r.bottom-a.top+8),s=Math.max(n,o);return Number.isFinite(s)&&s>24?`${s}px`:i}getEmbeddedHeaderReserveMinimum(){const t=getComputedStyle(this),e=parseFloat(t.getPropertyValue("--st-group-header-control-height"))||34,i=parseFloat(t.getPropertyValue("--st-group-header-top-buffer"))||2,o=parseFloat(t.getPropertyValue("--st-spacing"))||parseFloat(t.getPropertyValue("--st-default-spacing"))||4;return Math.ceil(e+i+4*o)}selectEntity(t,e=!0){if(this.menuOpen=!1,t===this.selectedEntity)return;e&&this.pauseAutoSelectAfterManualSelection();const i=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;if(!this.embeddedCard||i)return this.fadeInAfterSync=!1,this.cardFading=!1,this.selectedEntity=t,void(e&&this.writeStoredSelection(t));this.cardFading=!0,this.fadeInAfterSync=!0,this.selectedEntity=t,e&&this.writeStoredSelection(t)}selectOffset(t){if(this.targets.length<2)return;const e=(this.getSelectedIndex()+t+this.targets.length)%this.targets.length;this.selectEntity(this.targets[e].entity)}toggleHeaderEntity(t,e){t.stopPropagation();const i=Boolean(t.target.checked);this.hass?.callService?.("homeassistant","turn_"+(i?"on":"off"),{entity_id:e})}renderHeaderToggles(t){const e=this.getHeaderToggleConfigs(t);return e.length?B` + `}static getConfigElement(){return window.document.createElement(`${t}-group-editor`)}static getStubConfig(t){return{entities:Object.keys(t?.states??{}).filter(t=>Re.includes(Ne(t))).slice(0,2),card:{}}}setConfig(t){this.clearAutoSelectResumeTimer();const e=(t.cards??t.entities??[]).map(je).filter(Boolean);if(!e.length)throw new Error("Simple Thermostat Group requires at least one card");this.config={...t,selector:{...Oe,...t.selector??{}}},this.targets=e,this.selectedEntity=this.getInitialSelection(t,e),this.activitySignatures.clear(),this.activitySignaturesInitialized=!1,this.persistedActivityApplied=!1}updated(){this.syncAutoSelectRecentActivity(),this.syncEmbeddedCard(),this.syncOutsideClickListener(),this.syncTitleFit()}getCardSize(){if(!this.config||!this.targets.length)return 1;const t=this.getSelectedTarget(),e=this.getTargetCardConfig(t),i=Array.isArray(e.entities)?e.entities.length:0,o=i?Math.max(1,Math.ceil(i/2)):0,a=this.getConfiguredModeRowCount(e),r=!0===e.hide_setpoint?0:1;return Math.max(2,1+o+r+a)}disconnectedCallback(){this.clearOutsideClickListener(),this.clearAutoSelectResumeTimer(),super.disconnectedCallback()}getInitialSelection(t,e){const i=new Set(e.map(t=>t.entity)),o=!1===t.remember_selection?"":this.readStoredSelection(t);return o&&i.has(o)?o:t.selected&&i.has(t.selected)?t.selected:e[0].entity}readStoredSelection(t){return this.readStoredSelectionRecord(t)?.entity??""}readStoredSelectionRecord(t){try{const e=window.localStorage?.getItem(this.getStorageKey(t));if(!e)return;if(!e.trim().startsWith("{"))return{entity:e,timestamp:0};const i=JSON.parse(e);if("string"==typeof i.entity)return{entity:i.entity,timestamp:Number.isFinite(i.timestamp)?Number(i.timestamp):0}}catch(t){return}}writeStoredSelection(t){if(this.config&&!1!==this.config.remember_selection)try{window.localStorage?.setItem(this.getStorageKey(this.config),JSON.stringify({entity:t,timestamp:Date.now()}))}catch(t){}}readStoredActivity(t){try{const e=window.localStorage?.getItem(this.getActivityStorageKey(t));if(!e)return;const i=JSON.parse(e);if("string"==typeof i.entity&&"string"==typeof i.signature&&Number.isFinite(i.timestamp))return{entity:i.entity,signature:i.signature,timestamp:Number(i.timestamp)}}catch(t){return}}writeStoredActivity(t){if(this.config)try{window.localStorage?.setItem(this.getActivityStorageKey(this.config),JSON.stringify(t))}catch(t){}}getStorageKey(t){if(t.storage_key)return`simple-thermostat-group:${t.storage_key}`;return`simple-thermostat-group:${this.targets.map(t=>t.entity).join("|")}`}getActivityStorageKey(t){return`${this.getStorageKey(t)}:recent-activity`}getConfiguredModeRowCount(t){const e=t.control;return!1===e?0:Array.isArray(e)?e.filter(Boolean).length:e&&"object"==typeof e?Object.entries(e).filter(([t,e])=>!t.startsWith("_")&&!1!==e).length:1}clearAutoSelectResumeTimer(){void 0!==this.autoSelectResumeTimer&&(window.clearTimeout(this.autoSelectResumeTimer),this.autoSelectResumeTimer=void 0)}getSelectedTarget(){return this.targets.find(t=>t.entity===this.selectedEntity)??this.targets[0]}getSelectedState(){const t=this.getSelectedTarget();return this.hass?.states?.[t.entity]}openSelectedPopover(){const t=this.getSelectedTarget();t?.entity&&vt(this,"hass-more-info",{entityId:t.entity})}onSelectorHeaderKeyDown(t){"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.openSelectedPopover())}getGroupCardClasses(){const t=this.getSelectedState();if(!t)return"group-card group-shell";const e=Ne(t.entity_id),i=fe(t),o=["unavailable","unknown"].includes(String(t.state));return["group-card","group-shell",`domain-${Me(e)}`,`state-${Me(t.state)}`,Me(i),o&&Me(t.state)].filter(Boolean).join(" ")}getTargetClasses(t){const e=this.hass?.states?.[t.entity];if(!e)return"";const i=Ne(e.entity_id),o=fe(e);return[`domain-${Me(i)}`,`state-${Me(e.state)}`,Me(o)].filter(Boolean).join(" ")}getGroupCardStyle(){const t=this.getSelectedState();return t?function(t,e={}){if("fan"!==t)return"";const i=Number(e?.percentage);if(Number.isNaN(i))return"";const o=Math.min(Math.max(i,0),100);return`--st-fan-spin-duration: ${Math.max(.9,3.2-o/100*2.1).toFixed(2)}s;`}(Ne(t.entity_id),t.attributes):""}getSelectedIndex(){const t=this.targets.findIndex(t=>t.entity===this.selectedEntity);return-1===t?0:t}isRecentActivityAutoSelectEnabled(){const t=this.config?.auto_select;return!!t&&(!0===t||"recent_activity"===t||"object"==typeof t&&"recent_activity"===t.mode)}getAutoSelectManualPauseMs(){const t=this.config?.auto_select;if(t&&"object"==typeof t){const e=Number(t.manual_pause_ms??t.cooldown_ms);if(Number.isFinite(e)&&e>=0)return e}return 3e4}pauseAutoSelectAfterManualSelection(){this.lastManualSelectionAt=Date.now(),this.clearAutoSelectResumeTimer(),this.isRecentActivityAutoSelectEnabled()&&(this.autoSelectResumeTimer=window.setTimeout(()=>{this.autoSelectResumeTimer=void 0,this.lastManualSelectionAt=0,this.isRecentActivityAutoSelectEnabled()&&!this.menuOpen&&this.selectMostRecentStateActivity()},this.getAutoSelectManualPauseMs()))}getActivitySignature(t){const e=this.hass?.states?.[t.entity];if(!e)return"";const i=Ne(t.entity),o=e.attributes??{},a=fe(e)??"",r="climate"===i?["hvac_action","temperature","target_temp_low","target_temp_high","preset_mode","fan_mode","swing_mode","swing_horizontal_mode","swing_vertical_mode"]:"fan"===i?["percentage","preset_mode","direction","oscillating"]:"humidifier"===i?["action","humidity","mode"]:[],n=[`state:${e.state}`,`action:${a}`];return r.forEach(t=>{n.push(`${t}:${JSON.stringify(o[t]??null)}`)}),n.join("|")}getActivityTimestamp(t){const e=this.hass?.states?.[t.entity],i=this.getActivityActiveRank(t)>1?e?.last_updated??e?.last_changed:e?.last_changed??e?.last_updated,o="string"==typeof i?Date.parse(i):NaN;return Number.isFinite(o)?o:0}getActivityCandidate(t,e=this.getActivityTimestamp(t)){return{target:t,timestamp:e,activeRank:this.getActivityActiveRank(t)}}isBetterActivityCandidate(t,e){return!e||(t.activeRank!==e.activeRank?t.activeRank>e.activeRank:t.timestamp>=e.timestamp)}getMostRecentStateActivityCandidate(){return this.targets.map(t=>this.getActivityCandidate(t)).filter(t=>t.timestamp>0).reduce((t,e)=>this.isBetterActivityCandidate(e,t)?e:t,void 0)}applyPersistedActivitySelection(t){if(this.persistedActivityApplied||!this.config||!this.isRecentActivityAutoSelectEnabled())return;this.persistedActivityApplied=!0;const e=this.readStoredSelectionRecord(this.config),i=e&&this.targets.some(t=>t.entity===e.entity),o=this.getMostRecentStateActivityCandidate();if(i&&(!o||o.timestamp<=e.timestamp))return void this.selectEntity(e.entity,!1);const a=this.readStoredActivity(this.config);if(!a)return void this.selectMostRecentStateActivity(t);if(!this.targets.some(t=>t.entity===a.entity))return void this.selectMostRecentStateActivity(t);const r=this.targets.find(t=>t.entity===a.entity),n=t.get(a.entity);if(r&&n&&n===a.signature){const e=this.getActivityCandidate(r,a.timestamp);return o&&this.isBetterActivityCandidate(o,e)?void this.selectMostRecentStateActivity(t):void this.selectEntity(a.entity,!1)}this.selectMostRecentStateActivity(t)}selectMostRecentStateActivity(t){const e=this.getMostRecentStateActivityCandidate();if(e&&e.target.entity!==this.selectedEntity&&this.selectEntity(e.target.entity,!1),e&&t){const i=t.get(e.target.entity);i&&this.writeStoredActivity({entity:e.target.entity,signature:i,timestamp:e.timestamp})}}getActivityActiveRank(t){const e=this.hass?.states?.[t.entity];if(!e)return 0;const i=Ne(t.entity),o=fe(e)??e.attributes?.action,a="string"==typeof e.state?e.state.toLowerCase():"",r="string"==typeof o?o.toLowerCase():"";if("climate"===i)return["heating","cooling","drying"].includes(r)?2:a&&"off"!==a?1:0;if("fan"===i){const t=Number(e.attributes?.percentage);return"on"===a||t>0?2:0}return"humidifier"===i?["drying","humidifying"].includes(r)?2:a&&!["off","idle"].includes(a)?1:0:a&&"off"!==a?1:0}syncAutoSelectRecentActivity(){if(!this.config||!this.hass||!this.targets.length)return;const t=[],e=new Map;if(this.targets.forEach(i=>{const o=this.getActivitySignature(i);e.set(i.entity,o),this.activitySignaturesInitialized&&o&&o!==this.activitySignatures.get(i.entity)&&(this.writeStoredActivity({entity:i.entity,signature:o,timestamp:Date.now()}),t.push(this.getActivityCandidate(i,Date.now())))}),this.activitySignatures=e,!this.activitySignaturesInitialized)return this.activitySignaturesInitialized=!0,void this.applyPersistedActivitySelection(e);if(!t.length||!this.isRecentActivityAutoSelectEnabled()||this.menuOpen||Date.now()-this.lastManualSelectionAtthis.isBetterActivityCandidate(e,t)?e:t);this.selectEntity(i.target.entity,!1)}getTargetLabel(t){const e=this.parseTargetHeader(t);if(e&&"string"==typeof e.name)return e.name;const i=this.hass?.states?.[t.entity];return i&&"function"==typeof this.hass?.formatEntityName?this.hass.formatEntityName(i):i?.attributes?.friendly_name??t.entity}getTargetIcon(t){if(!(this.config?.selector??Oe).icons)return"";const e=this.parseTargetHeader(t);if(e&&e.icon)return this.resolveHeaderIcon(e.icon,t);const i=this.hass?.states?.[t.entity];if(i?.attributes?.icon)return i.attributes.icon;const o=Ne(t.entity);return"fan"===o?"mdi:fan":"humidifier"===o?"mdi:air-humidifier":"mdi:air-conditioner"}getTargetHeaderData(t){return this.parseTargetHeader(t)}parseTargetHeader(t){const e=this.hass?.states?.[t.entity];if(!e||!this.hass)return null;const i=this.getTargetCardConfig(t);return Ae(i.header,e,this.hass,!1!==i.enhanced_visuals)}resolveHeaderIcon(t,e){if("string"==typeof t)return t;if(!t||"object"!=typeof t)return"";const i=this.hass?.states?.[e.entity];if(!i)return"";const o=t[fe(i)||String(i.state)];return"string"==typeof o?o:""}getHeaderToggleConfigs(t){const e=t.config.header;return e&&"object"==typeof e?[...e.toggle?[e.toggle]:[],...Array.isArray(e.toggles)?e.toggles:[]].filter(t=>t?.entity&&this.hass?.states?.[t.entity]):[]}getEmbeddedConfig(){const t=this.getSelectedTarget();return this.getTargetCardConfig(t)}getEmbeddedConfigSignature(t){return JSON.stringify(t,(t,e)=>!e||"object"!=typeof e||Array.isArray(e)?e:Object.keys(e).sort().reduce((t,i)=>(t[i]=e[i],t),{}))}getTargetCardConfig(e){const i={...this.config?.card??{},...this.getSourceTargetConfig(e),...e.config};if(!i.card_mod){const t=this.getFallbackCardMod();t&&(i.card_mod=t)}return{...i,embedded:!0,entity:e.entity,type:e.config.type??`custom:${t}`}}getSourceTargetConfig(t){const e=(this.config?.cards??this.config?.entities??[]).find(e=>!!e&&"object"==typeof e&&e.entity===t.entity);return e&&"object"==typeof e?e:{}}getFallbackCardMod(){const t=(this.config?.card??{}).card_mod;if(t)return t;const e=(this.config?.cards??this.config?.entities??[]).find(t=>!!t&&"object"==typeof t&&!!t.card_mod);return e?.card_mod}getCardHelpers(){return this.cardHelpersPromise||(this.cardHelpersPromise="function"==typeof window.loadCardHelpers?window.loadCardHelpers():Promise.reject(new Error("Home Assistant card helpers unavailable"))),this.cardHelpersPromise}createFallbackEmbeddedCardElement(e){const i=window.document.createElement(t);if("function"==typeof i.setConfig)return i.setConfig(e),i}installEmbeddedCard(t,e,i,o){this.config&&this.hass&&(e&&"function"==typeof e.setConfig?this.getEmbeddedConfigSignature(this.getEmbeddedConfig())===o&&(this.embeddedCard=e,this.embeddedCardEntity=String(i.entity??""),this.embeddedCardConfigSignature=o,this.embeddedCardPendingSignature="",t.replaceChildren(e),"function"==typeof e.setConfig&&e.setConfig(i),e.hass=this.hass,this.syncEmbeddedPresentation()):this.embeddedCardPendingSignature="")}syncEmbeddedCard(){if(!this.config||!this.hass)return;const e=this.renderRoot.querySelector(".embedded-card-host");if(!e)return;const i=this.getEmbeddedConfig(),o=this.getEmbeddedConfigSignature(i);if(!this.embeddedCard||this.embeddedCardEntity!==i.entity||this.embeddedCardConfigSignature!==o){if("function"!=typeof window.loadCardHelpers){const a=window.customElements.get(t)?this.createFallbackEmbeddedCardElement(i):void 0;return a?void this.installEmbeddedCard(e,a,i,o):void(this.embeddedCardPendingSignature="")}if(this.embeddedCardPendingSignature===o)return;return this.embeddedCardPendingSignature=o,void this.getCardHelpers().then(t=>t.createCardElement(i)).catch(()=>window.customElements.get(t)?this.createFallbackEmbeddedCardElement(i):void 0).then(t=>this.installEmbeddedCard(e,t,i,o))}this.embeddedCard.hass=this.hass,this.syncEmbeddedPresentation()}syncEmbeddedPresentation(){const t=this.embeddedCard;(t?.updateComplete??Promise.resolve()).catch(()=>{}).then(()=>window.requestAnimationFrame(()=>this.applyEmbeddedPresentation()))}applyEmbeddedPresentation(){const t=this.renderRoot.querySelector(".embedded-card-host"),e=this.renderRoot.querySelector(".group-selector"),i=this.embeddedCard;t&&i&&(t.style.removeProperty("--st-group-cropped-header-height"),i.style.setProperty("--st-group-embedded-header-min-height",this.getEmbeddedHeaderReserve(i,e)),this.fadeInAfterSync&&(this.fadeInAfterSync=!1,window.requestAnimationFrame(()=>{this.cardFading=!1})))}getEmbeddedHeaderReserve(t,e){const i="calc(var(--st-group-header-control-height, 34px) + var(--st-group-header-top-buffer, 2px) + calc(var(--st-spacing, var(--st-default-spacing, 4px)) * 6))",o=this.getEmbeddedHeaderReserveMinimum();if(!e)return i;const a=t.getBoundingClientRect(),r=e.getBoundingClientRect(),n=Math.ceil(r.bottom-a.top+8),s=Math.max(n,o);return Number.isFinite(s)&&s>24?`${s}px`:i}getEmbeddedHeaderReserveMinimum(){const t=getComputedStyle(this),e=parseFloat(t.getPropertyValue("--st-group-header-control-height"))||34,i=parseFloat(t.getPropertyValue("--st-group-header-top-buffer"))||2,o=parseFloat(t.getPropertyValue("--st-spacing"))||parseFloat(t.getPropertyValue("--st-default-spacing"))||4;return Math.ceil(e+i+4*o)}selectEntity(t,e=!0){if(this.menuOpen=!1,t===this.selectedEntity)return;e&&this.pauseAutoSelectAfterManualSelection();const i=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;if(!this.embeddedCard||i)return this.fadeInAfterSync=!1,this.cardFading=!1,this.selectedEntity=t,void(e&&this.writeStoredSelection(t));this.cardFading=!0,this.fadeInAfterSync=!0,this.selectedEntity=t,e&&this.writeStoredSelection(t)}selectOffset(t){if(this.targets.length<2)return;const e=(this.getSelectedIndex()+t+this.targets.length)%this.targets.length;this.selectEntity(this.targets[e].entity)}toggleHeaderEntity(t,e){t.stopPropagation();const i=Boolean(t.target.checked);this.hass?.callService?.("homeassistant","turn_"+(i?"on":"off"),{entity_id:e})}renderHeaderToggles(t){const e=this.getHeaderToggleConfigs(t);return e.length?B`
${e.map(t=>{const e=this.hass?.states?.[t.entity],i=!0===t.name?e?.attributes?.friendly_name:"string"==typeof t.name?t.name:e?.attributes?.friendly_name,o=t.icon||e?.attributes?.icon;return B`
@@ -2502,7 +2870,7 @@ ha-card.standard-visuals .thermostat-trigger:active { `})}
- `:q}renderHeaderIcon(t){const e=this.hass?.states?.[t.entity],i=this.getTargetHeaderData(t);if(!e||!i||!i.icon)return q;const o=ue(e)||String(e.state),a="object"==typeof i.icon?i.icon?.[o]??!1:i.icon;if(!a)return q;const r=o&&o!==e.state?` ${Te(o)}`:"",n=Te(e.state);return B` + `:q}renderHeaderIcon(t){const e=this.hass?.states?.[t.entity],i=this.getTargetHeaderData(t);if(!e||!i||!i.icon)return q;const o=fe(e)||String(e.state),a="object"==typeof i.icon?i.icon?.[o]??!1:i.icon;if(!a)return q;const r=o&&o!==e.state?` ${Me(o)}`:"",n=Me(e.state);return B` @@ -2511,7 +2879,32 @@ ha-card.standard-visuals .thermostat-trigger:active { .icon=${a} > - `}renderSelector(){const t=this.getSelectedTarget(),e=this.getTargetLabel(t);return B` + `}getTargetStateLabel(t){const e=this.hass?.states?.[t.entity];return e?"function"==typeof this.hass?.formatEntityState?this.hass.formatEntityState(e):String(e.state):""}renderTabSelector(){const t=this.config?.selector??Oe;return B` +
+
+ ${this.targets.map(e=>{const i=this.getTargetLabel(e),o=this.getTargetIcon(e),a=e.entity===this.selectedEntity,r=t.states?this.getTargetStateLabel(e):"";return B` + + `})} +
+
+ `}renderSelector(){if("tabs"===this.config?.selector?.style)return this.renderTabSelector();const t=this.getSelectedTarget(),e=this.getTargetLabel(t);return B`
- `:B``}}var Me;i([pt({attribute:!1})],Ne.prototype,"hass",void 0),i([gt()],Ne.prototype,"config",void 0),i([gt()],Ne.prototype,"targets",void 0),i([gt()],Ne.prototype,"selectedEntity",void 0),i([gt()],Ne.prototype,"menuOpen",void 0),i([gt()],Ne.prototype,"cardFading",void 0),function(t){t.OFF="off",t.HEAT="heat",t.COOL="cool",t.HEAT_COOL="heat_cool",t.AUTO="auto",t.DRY="dry",t.FAN_ONLY="fan_only"}(Me||(Me={}));const Re=["auto","silent","quiet","low","mid","medium","high","max","turbo","full"];const je=["mdi:fan-speed-1","mdi:fan-speed-2","mdi:fan-speed-3","st:fan-speed-4","st:fan-speed-5"],Pe=t=>String(t).toLowerCase().replace(/\s+/g,"_"),He={low:1,medlow:2,medium_low:2,mid:2,medium:2,medium_high:3,medhigh:3,max:5,turbo:5,full:5};function Ie(t,e){const i=Pe(t),o=function(t){if(!/^\d+$/.test(t))return;const e=Number(t);return e>=1&&e<=je.length?e:void 0}(i);if(o)return je[o-1];const a=function(t,e){if("high"===t){const t=new Set(e.map(Pe));return t.has("medium_high")||t.has("medhigh")||t.has("max")||t.has("turbo")||t.has("full")?4:3}return He[t]}(i,e);return a?je[a-1]:void 0}function Ve(t,{decimals:e=1,fallback:i="N/A",locale:o}={}){if(null===t||""===t||["boolean","undefined"].includes(typeof t))return i;const a=Number(t);return Number.isNaN(a)?i:o?"decimal_comma"===o.number_format||"space_comma"===o.number_format?a.toFixed(e).replace(".",","):"comma_decimal"===o.number_format||"none"===o.number_format?a.toFixed(e):new Intl.NumberFormat("system"===o.number_format?void 0:o.language,{minimumFractionDigits:e,maximumFractionDigits:e}).format(a):a.toFixed(e)}const Fe=[["heat",/\b(heat|heater|furnace|radiator|boiler|water[_ -]?heater)\b/],["cool",/\b(cool|cooling|ac|a\/c|air[_ -]?conditioner|snowflake)\b/],["dry",/\b(dry|drying|dehumidifier|dehumidify)\b/],["water-percent",/\b(humidifier|humidify|humidity)\b/],["fan",/\b(fan|blower)\b/],["lightbulb",/\b(light|lamp|bulb)\b/]],Le={heat:["component.climate.state._.heat","state_attributes.climate.hvac_action.heating"],cool:["component.climate.state._.cool","state_attributes.climate.hvac_action.cooling"],dry:["component.climate.state._.dry","state_attributes.humidifier.action.drying"],fan:["component.fan.entity_component._.name"],lightbulb:["component.light.entity_component._.name"],"water-percent":["component.humidifier.entity_component._.name","state_attributes.humidifier.action.humidifying"]};function De(t,e){const i=t.toLowerCase().replace(/[.:]/g," "),o=function(t){return"function"!=typeof t?.localize?[]:Object.entries(Le).flatMap(([e,i])=>i.map(e=>t.localize(e)).filter(t=>t&&!i.includes(t)).map(t=>{return[e,(i=String(t),i.toLowerCase().replace(/[.:]/g," "))];var i}))}(e).find(([,t])=>!!t&&(i===t||i.includes(t)));if(o)return o[0];const a=Fe.find(([,t])=>t.test(i));return a?.[0]??""}function Ue(t){if("string"!=typeof t||!t)return"";const e=(i=t.replace(/^[a-z]+:/,""),String(i??"").replace(/[^a-z0-9_-]/gi,""));var i;const o=De(e.replace(/-/g," "));return o||(["fire","radiator","heat-wave","heating-coil","water-boiler","water-boiler-auto","water-boiler-off"].includes(e)?"heat":["snowflake","air-conditioner"].includes(e)?"cool":"fan"===e?"fan":e.includes("light")?"lightbulb":["water-percent","air-humidifier"].includes(e)||["air-humidifier-off"].includes(e)?"water-percent":e)}function We({icon:t,label:e,entity:i,hass:o}){const a=Ue(t);if(a)return a;const r=function(t){const e=t?.entity_id,i="string"==typeof e?e.split(".")[0]:"",o=t?.attributes?.device_class;return"light"===i?"lightbulb":"fan"===i?"fan":"humidifier"===i?"dehumidifier"===o?"dry":"water-percent":"heat"===o||"heater"===o?"heat":"cold"===o||"cooling"===o?"cool":"moisture"===o||"humidity"===o?"water-percent":""}(i);if(r)return r;return De([e,i?.entity_id,i?.attributes?.friendly_name].filter(Boolean).join(" "),o)}function Be(t){return t?`toggle-${t}`:""}function Ge({header:t,toggleEntityChanged:e,entity:i,hass:o,openEntityPopover:a}){if(!1===t)return q;const r=ue(i)||i.state;let n=t.icon;"object"==typeof t.icon&&(n=n?.[r]??!1);const s=Boolean(t.slashOffIcon),c=t?.name??!1;return B` + `:B``}}var Fe;i([pt({attribute:!1})],Pe.prototype,"hass",void 0),i([mt()],Pe.prototype,"config",void 0),i([mt()],Pe.prototype,"targets",void 0),i([mt()],Pe.prototype,"selectedEntity",void 0),i([mt()],Pe.prototype,"menuOpen",void 0),i([mt()],Pe.prototype,"cardFading",void 0),function(t){t.OFF="off",t.HEAT="heat",t.COOL="cool",t.HEAT_COOL="heat_cool",t.AUTO="auto",t.DRY="dry",t.FAN_ONLY="fan_only"}(Fe||(Fe={}));const He=["auto","silent","quiet","low","mid","medium","high","max","turbo","full"];const Ie=["mdi:fan-speed-1","mdi:fan-speed-2","mdi:fan-speed-3","st:fan-speed-4","st:fan-speed-5"],Ve=t=>String(t).toLowerCase().replace(/\s+/g,"_"),Le={low:1,medlow:2,medium_low:2,mid:2,medium:2,medium_high:3,medhigh:3,max:5,turbo:5,full:5};function De(t,e){const i=Ve(t),o=function(t){if(!/^\d+$/.test(t))return;const e=Number(t);return e>=1&&e<=Ie.length?e:void 0}(i);if(o)return Ie[o-1];const a=function(t,e){if("high"===t){const t=new Set(e.map(Ve));return t.has("medium_high")||t.has("medhigh")||t.has("max")||t.has("turbo")||t.has("full")?4:3}return Le[t]}(i,e);return a?Ie[a-1]:void 0}function Ue(t,{decimals:e=1,fallback:i="N/A",locale:o}={}){if(null===t||""===t||["boolean","undefined"].includes(typeof t))return i;const a=Number(t);return Number.isNaN(a)?i:o?"decimal_comma"===o.number_format||"space_comma"===o.number_format?a.toFixed(e).replace(".",","):"comma_decimal"===o.number_format||"none"===o.number_format?a.toFixed(e):new Intl.NumberFormat("system"===o.number_format?void 0:o.language,{minimumFractionDigits:e,maximumFractionDigits:e}).format(a):a.toFixed(e)}const We=[["heat",/\b(heat|heater|furnace|radiator|boiler|water[_ -]?heater)\b/],["cool",/\b(cool|cooling|ac|a\/c|air[_ -]?conditioner|snowflake)\b/],["dry",/\b(dry|drying|dehumidifier|dehumidify)\b/],["water-percent",/\b(humidifier|humidify|humidity)\b/],["fan",/\b(fan|blower)\b/],["lightbulb",/\b(light|lamp|bulb)\b/]],Be={heat:["component.climate.state._.heat","state_attributes.climate.hvac_action.heating"],cool:["component.climate.state._.cool","state_attributes.climate.hvac_action.cooling"],dry:["component.climate.state._.dry","state_attributes.humidifier.action.drying"],fan:["component.fan.entity_component._.name"],lightbulb:["component.light.entity_component._.name"],"water-percent":["component.humidifier.entity_component._.name","state_attributes.humidifier.action.humidifying"]};function Ge(t,e){const i=t.toLowerCase().replace(/[.:]/g," "),o=function(t){return"function"!=typeof t?.localize?[]:Object.entries(Be).flatMap(([e,i])=>i.map(e=>t.localize(e)).filter(t=>t&&!i.includes(t)).map(t=>{return[e,(i=String(t),i.toLowerCase().replace(/[.:]/g," "))];var i}))}(e).find(([,t])=>!!t&&(i===t||i.includes(t)));if(o)return o[0];const a=We.find(([,t])=>t.test(i));return a?.[0]??""}function qe(t){if("string"!=typeof t||!t)return"";const e=(i=t.replace(/^[a-z]+:/,""),String(i??"").replace(/[^a-z0-9_-]/gi,""));var i;const o=Ge(e.replace(/-/g," "));return o||(["fire","radiator","heat-wave","heating-coil","water-boiler","water-boiler-auto","water-boiler-off"].includes(e)?"heat":["snowflake","air-conditioner"].includes(e)?"cool":"fan"===e?"fan":e.includes("light")?"lightbulb":["water-percent","air-humidifier"].includes(e)||["air-humidifier-off"].includes(e)?"water-percent":e)}function Ke({icon:t,label:e,entity:i,hass:o}){const a=qe(t);if(a)return a;const r=function(t){const e=t?.entity_id,i="string"==typeof e?e.split(".")[0]:"",o=t?.attributes?.device_class;return"light"===i?"lightbulb":"fan"===i?"fan":"humidifier"===i?"dehumidifier"===o?"dry":"water-percent":"heat"===o||"heater"===o?"heat":"cold"===o||"cooling"===o?"cool":"moisture"===o||"humidity"===o?"water-percent":""}(i);if(r)return r;return Ge([e,i?.entity_id,i?.attributes?.friendly_name].filter(Boolean).join(" "),o)}function Ze(t){return t?`toggle-${t}`:""}function Je({header:t,toggleEntityChanged:e,entity:i,hass:o,openEntityPopover:a}){if(!1===t)return q;const r=fe(i)||i.state;let n=t.icon;"object"==typeof t.icon&&(n=n?.[r]??!1);const s=Boolean(t.slashOffIcon),c=t?.name??!1;return B`
a()}> ${function(t,e,i,o=!1){const a=i&&i!==e?` ${i}`:"";return t?B` @@ -2591,7 +2984,7 @@ ha-card.standard-visuals .thermostat-trigger:active { >`:q);return B`
${i}
`}(t.faults,a)} ${function(t,e,i,o,a){return t?.length?B`
- ${t.map(t=>{if(!0===t.hide_when_off&&"off"===a?.state)return q;const r=t.entity?.entity_id,n=t.entity?.state,s="string"==typeof r?r.split(".")[0]:"",c=Be(We({icon:"string"==typeof t.icon?t.icon:t.entity?.attributes?.icon,label:t.label,entity:t.entity,hass:o}));return B` + ${t.map(t=>{if(!0===t.hide_when_off&&"off"===a?.state)return q;const r=t.entity?.entity_id,n=t.entity?.state,s="string"==typeof r?r.split(".")[0]:"",c=Ze(Ke({icon:"string"==typeof t.icon?t.icon:t.entity?.attributes?.icon,label:t.label,entity:t.entity,hass:o}));return B`
@@ -2610,84 +3003,126 @@ ha-card.standard-visuals .thermostat-trigger:active {
`:q}(t.toggles,a,e,o,i)}
- `}class qe extends Yt{constructor(t){if(super(t),this.it=q,t.type!==Zt)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===q||null==t)return this._t=void 0,this.it=t;if(t===G)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}}qe.directiveName="unsafeHTML",qe.resultType=1;const Ke=Jt(qe);function Ze(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Je(t,e,i){if(!e||"string"!=typeof e)return String(t);const o=String(t);return new RegExp(`${Ze(e)}$`).test(o)?o:`${o}${function(t,e){if(e){const i=e.match(new RegExp(`(\\s*)${Ze(t)}$`));if(i)return i[1]??""}return"%"===t?"":" "}(e,i)}${e}`}var Ye,Xe={exports:{}};function Qe(){return Ye||(Ye=1,function(t){function e(t){var i,o,a=new Error(t);return i=a,o=e.prototype,Object.setPrototypeOf?Object.setPrototypeOf(i,o):i.__proto__=o,a}function i(t,i,o){var a=i.slice(0,o).split(/\n/),r=a.length,n=a[r-1].length+1;throw e(t+=" at line "+r+" col "+n+":\n\n "+i.split(/\n/)[r-1]+"\n "+Array(n).join(" ")+"^")}e.prototype=Object.create(Error.prototype,{name:{value:"Squirrelly Error",enumerable:!1}});var o=new Function("return this")().Promise,a=!1;try{a=new Function("return (async function(){}).constructor")()}catch(t){if(!(t instanceof SyntaxError))throw t}function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function n(t,e,i){for(var o in e)r(e,o)&&(null==e[o]||"object"!=typeof e[o]||"storage"!==o&&"prefixes"!==o||i?t[o]=e[o]:t[o]=n({},e[o]));return t}var s=/^async +/,c=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,l=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,d=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g,h=/[.*+\-?^${}()|[\]\\]/g;function u(t){return h.test(t)?t.replace(h,"\\$&"):t}function p(t,o){o.rmWhitespace&&(t=t.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),c.lastIndex=0,l.lastIndex=0,d.lastIndex=0;var a=o.prefixes,r=[a.h,a.b,a.i,a.r,a.c,a.e].reduce(function(t,e){return t&&e?t+"|"+u(e):e?u(e):t},""),n=new RegExp("([|()]|=>)|('|\"|`|\\/\\*)|\\s*((\\/)?(-|_)?"+u(o.tags[1])+")","g"),h=new RegExp("([^]*?)"+u(o.tags[0])+"(-|_)?\\s*("+r+")?\\s*","g"),p=0,g=!1;function m(e,a){var r,u={f:[]},m=0,f="c";function v(e){var a=t.slice(p,e),r=a.trim();if("f"===f)"safe"===r?u.raw=!0:o.async&&s.test(r)?(r=r.replace(s,""),u.f.push([r,"",!0])):u.f.push([r,""]);else if("fp"===f)u.f[u.f.length-1][1]+=r;else if("err"===f){if(r){var n=a.search(/\S/);i("invalid syntax",t,p+n)}}else u[f]=r;p=e+1}for("h"===a||"b"===a||"c"===a?f="n":"r"===a&&(u.raw=!0,a="i"),n.lastIndex=p;null!==(r=n.exec(t));){var y=r[1],_=r[2],b=r[3],w=r[4],x=r[5],$=r.index;if(y)"("===y?(0===m&&("n"===f?(v($),f="p"):"f"===f&&(v($),f="fp")),m++):")"===y?0===--m&&"c"!==f&&(v($),f="err"):0===m&&"|"===y?(v($),f="f"):"=>"===y&&(v($),p+=1,f="res");else if(_)if("/*"===_){var S=t.indexOf("*/",n.lastIndex);-1===S&&i("unclosed comment",t,r.index),n.lastIndex=S+2}else"'"===_?(l.lastIndex=r.index,l.exec(t)?n.lastIndex=l.lastIndex:i("unclosed string",t,r.index)):'"'===_?(d.lastIndex=r.index,d.exec(t)?n.lastIndex=d.lastIndex:i("unclosed string",t,r.index)):"`"===_&&(c.lastIndex=r.index,c.exec(t)?n.lastIndex=c.lastIndex:i("unclosed string",t,r.index));else if(b)return v($),p=$+r[0].length,h.lastIndex=p,g=x,w&&"h"===a&&(a="s"),u.t=a,u}return i("unclosed tag",t,e),u}var f=function r(n,c){n.b=[],n.d=[];var l,d=!1,u=[];function f(t,e){t&&(t=function(t,e,i,o){var a,r;return"string"==typeof e.autoTrim?a=r=e.autoTrim:Array.isArray(e.autoTrim)&&(a=e.autoTrim[1],r=e.autoTrim[0]),(i||!1===i)&&(a=i),(o||!1===o)&&(r=o),"slurp"===a&&"slurp"===r?t.trim():("_"===a||"slurp"===a?t=String.prototype.trimLeft?t.trimLeft():t.replace(/^[\s\uFEFF\xA0]+/,""):"-"!==a&&"nl"!==a||(t=t.replace(/^(?:\n|\r|\r\n)/,"")),"_"===r||"slurp"===r?t=String.prototype.trimRight?t.trimRight():t.replace(/[\s\uFEFF\xA0]+$/,""):"-"!==r&&"nl"!==r||(t=t.replace(/(?:\n|\r|\r\n)$/,"")),t)}(t,o,g,e),t&&(t=t.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),u.push(t)))}for(;null!==(l=h.exec(t));){var v,y=l[1],_=l[2],b=l[3]||"";for(var w in a)if(a[w]===b){v=w;break}f(y,_),p=l.index+l[0].length,v||i("unrecognized tag type: "+b,t,p);var x=m(l.index,v),$=x.t;if("h"===$){var S=x.n||"";o.async&&s.test(S)&&(x.a=!0,x.n=S.replace(s,"")),x=r(x),u.push(x)}else if("c"===$){if(n.n===x.n)return d?(d.d=u,n.b.push(d)):n.d=u,n;i("Helper start and end don't match",t,l.index+l[0].length)}else if("b"===$){d?(d.d=u,n.b.push(d)):n.d=u;var A=x.n||"";o.async&&s.test(A)&&(x.a=!0,x.n=A.replace(s,"")),d=x,u=[]}else if("s"===$){var k=x.n||"";o.async&&s.test(k)&&(x.a=!0,x.n=k.replace(s,"")),u.push(x)}else u.push(x)}if(!c)throw e('unclosed helper "'+n.n+'"');return f(t.slice(p,t.length),!1),n.d=u,n}({f:[]},!0);if(o.plugins)for(var v=0;v0)throw e((a?"Native":"")+"Helper '"+t+"' doesn't accept blocks");if(o&&o.length>0)throw e((a?"Native":"")+"Helper '"+t+"' doesn't accept filters")}function x(t,e,i,o,a){i(t[e],e).then(function(r){o+=r,e===t.length-1?a(o):x(t,e+1,i,o,a)})}function $(t,e,i,o,a,r){o(e[i],t[e[i]]).then(function(n){a+=n,i===e.length-1?r(a):$(t,e,i+1,o,a,r)})}var S={"&":"&","<":"<",">":">",'"':""","'":"'"};function A(t){return S[t]}var k=new b({}),C=new b({each:function(t,e){var i="",o=t.params[0];if(w("each",e,!1),t.async)return new Promise(function(e){x(o,0,t.exec,i,e)});for(var a=0;a"']/.test(e)?e.replace(/[&<>"']/g,A):e}}),T={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,defaultFilter:!1,tags:["{{","}}"],l:function(t,i){if("H"===t){var o=this.storage.helpers.get(i);if(o)return o;throw e("Can't find helper '"+i+"'")}if("F"===t){var a=this.storage.filters.get(i);if(a)return a;throw e("Can't find filter '"+i+"'")}},async:!1,storage:{helpers:C,nativeHelpers:E,filters:z,templates:k},prefixes:{h:"@",b:"#",i:"",r:"*",c:"/",e:"!"},cache:!1,plugins:[],useWith:!1};function O(t,e){var i={};return n(i,T),e&&n(i,e),t&&n(i,t),i.l.bind(i),i}function N(t,i){var o,r=O(i||{}),n=Function;if(r.async){if(!a)throw e("This environment doesn't support async/await");n=a}if(r.varName&&!1===(o=r.varName,/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(o)))throw e("options.varName must be a valid JS identifier");try{return new n(r.varName,"c","cb",g(t,r))}catch(i){throw i instanceof SyntaxError?e("Bad template syntax\n\n"+i.message+"\n"+Array(i.message.length+1).join("=")+"\n"+g(t,r)):i}}function M(t,e){var i;return e.cache&&e.name&&e.storage.templates.get(e.name)?e.storage.templates.get(e.name):(i="function"==typeof t?t:N(t,e),e.cache&&e.name&&e.storage.templates.define(e.name,i),i)}T.l.bind(T),t.compile=N,t.compileScope=_,t.compileScopeIntoFunction=y,t.compileToString=g,t.defaultConfig=T,t.filters=z,t.getConfig=O,t.helpers=C,t.nativeHelpers=E,t.parse=p,t.render=function(t,i,a,r){var n=O(a||{});if(!n.async)return M(t,n)(i,n);if(!r){if("function"==typeof o)return new o(function(e,o){try{e(M(t,n)(i,n))}catch(t){o(t)}});throw e("Please provide a callback function, this env doesn't support Promises")}try{M(t,n)(i,n,r)}catch(t){return r(t)}},t.templates=k,Object.defineProperty(t,"__esModule",{value:!0})}(Xe.exports)),Xe.exports}var ti=Qe();function ei(t){return String(t??"").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function ii(t){return ei(t)}function oi(t){return"string"==typeof t?t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"):Array.isArray(t)?t.map(oi):t&&"object"==typeof t?Object.fromEntries(Object.entries(t).map(([t,e])=>[t,oi(e)])):t}function ai({template:t,stateObj:e,attribute:i,hass:o,config:a={},variables:r={},localize:n=t=>t}){const[s]=String(e?.entity_id??"").split("."),c=e?.attributes??{},l=i&&Object.prototype.hasOwnProperty.call(c,i)?c[i]:e?.state,d=i&&"function"==typeof o.formatEntityAttributeValue?o.formatEntityAttributeValue(e,i):"function"==typeof o.formatEntityState?o.formatEntityState(e):n(String(l),`component.${s}.state._.`),h=o.selectedLanguage||o.language,u="ui.card.climate.",p=Object.entries(o.resources?.[h]??{}).reduce((t,[e,i])=>(String(e).startsWith(u)&&(t[String(e).replace(u,"")]=i),t),{});return ti.filters.define("formatNumber",(t,e={decimals:a.decimals})=>String(Ve(t,{...e,locale:o.locale}))),ti.filters.define("relativetime",t=>``),ti.filters.define("translate",(t,i="")=>!i&&"function"==typeof o.formatEntityAttributeValue&&"string"==typeof t&&t in c?o.formatEntityAttributeValue(e,t):n(t,i||"climate"!==s&&"humidifier"!==s?i:`state_attributes.${s}.${t}`)),ti.render(t,{...oi(c),state:{raw:oi(l),text:oi(d)},state_attr:(t,e)=>oi(o.states?.[t]?.attributes?.[e]),ui:p,v:r},{useWith:!0})}ti.defaultConfig.autoEscape=!1,ti.filters.define("icon",t=>``),ti.filters.define("join",(t,e=", ")=>t.join(e)),ti.filters.define("css",(t,e)=>`"'`;{}]/g,"")}(i)};`:t},""))}">${ei(t)}`),ti.filters.define("debug",t=>{try{return JSON.stringify(t)}catch{return`Not able to read valid JSON object from: ${t}`}});const ri="simple-thermostat-timer-remaining";function ni(t){return String(t).padStart(2,"0")}class si extends lt{createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.syncTicker()}disconnectedCallback(){this.clearTicker(),super.disconnectedCallback()}updated(){this.syncTicker()}clearTicker(){this.tick&&(window.clearInterval(this.tick),this.tick=void 0)}syncTicker(){const t="active"===this.stateObj?.state,e=this.stateObj?.attributes?.finishes_at,i=e?Date.parse(e):NaN,o=!Number.isNaN(i)&&i>Date.now();t&&o&&!this.tick?this.tick=window.setInterval(()=>{i<=Date.now()&&this.clearTicker(),this.requestUpdate()},1e3):t&&o||!this.tick||this.clearTicker()}getValue(){const t=this.stateObj;if(!t)return"";if("active"===t.state&&t.attributes?.finishes_at){const e=Date.parse(t.attributes.finishes_at);if(!Number.isNaN(e))return function(t){const e=Math.max(0,Math.ceil(t)),i=Math.floor(e/3600),o=Math.floor(e%3600/60),a=e%60;return i>0?`${i}:${ni(o)}:${ni(a)}`:`${o}:${ni(a)}`}((e-Date.now())/1e3)}return"paused"===t.state&&t.attributes?.remaining?t.attributes.remaining:"function"==typeof this.hass?.formatEntityState?this.hass.formatEntityState(t):t.state}render(){return B`${this.getValue()}`}}i([pt({attribute:!1})],si.prototype,"stateObj",void 0),i([pt({attribute:!1})],si.prototype,"hass",void 0),customElements.get(ri)||customElements.define(ri,si);const ci=["automation","fan","humidifier","input_boolean","light","switch"];function li(t){return String(t??"").replace(/[^a-z0-9_-]/gi,"")}function di({hide:t=!1,hass:e,state:i,details:o,localize:a,openEntityPopover:r}){if(t||void 0===i)return;const{type:n,heading:s,icon:c,unit:l,decimals:d,tooltip:h,entity:u,template:p,attribute:g,variables:m,config:f,separator:v=!0}=o,y=function({icon:t,state:e,attribute:i,hass:o,config:a,variables:r,localize:n}){return"string"==typeof t&&t.includes("{{")&&"object"==typeof e&&null!==e?ai({template:t,stateObj:e,attribute:i,hass:o,config:a,variables:r,localize:n}).trim():t}({icon:c,state:i,attribute:g,hass:e,config:f,variables:m,localize:a}),_=function({heading:t,state:e,attribute:i,hass:o,config:a,variables:r,localize:n}){if("string"==typeof t&&t.includes("{{")&&"object"==typeof e&&null!==e)return ai({template:t,stateObj:e,attribute:i,hass:o,config:a,variables:r,localize:n}).trim()}({heading:s,state:i,attribute:g,hass:e,config:f,variables:m,localize:a}),b="string"==typeof l&&l.length>0,w="object"==typeof i?i.entity_id:u,x=w&&"function"==typeof r,$=h||("object"==typeof i?i?.attributes?.friendly_name||i?.entity_id:u?e.states?.[u]?.attributes?.friendly_name||u:void 0);let S,A="",k="",C=!1;if(p&&"object"==typeof i){const t=ai({template:p,stateObj:i,attribute:g,hass:e,config:f,variables:m,localize:a});S=B`
)|('|\"|`|\\/\\*)|\\s*((\\/)?(-|_)?"+u(o.tags[1])+")","g"),h=new RegExp("([^]*?)"+u(o.tags[0])+"(-|_)?\\s*("+r+")?\\s*","g"),p=0,m=!1;function g(e,a){var r,u={f:[]},g=0,f="c";function v(e){var a=t.slice(p,e),r=a.trim();if("f"===f)"safe"===r?u.raw=!0:o.async&&s.test(r)?(r=r.replace(s,""),u.f.push([r,"",!0])):u.f.push([r,""]);else if("fp"===f)u.f[u.f.length-1][1]+=r;else if("err"===f){if(r){var n=a.search(/\S/);i("invalid syntax",t,p+n)}}else u[f]=r;p=e+1}for("h"===a||"b"===a||"c"===a?f="n":"r"===a&&(u.raw=!0,a="i"),n.lastIndex=p;null!==(r=n.exec(t));){var y=r[1],b=r[2],_=r[3],w=r[4],x=r[5],$=r.index;if(y)"("===y?(0===g&&("n"===f?(v($),f="p"):"f"===f&&(v($),f="fp")),g++):")"===y?0===--g&&"c"!==f&&(v($),f="err"):0===g&&"|"===y?(v($),f="f"):"=>"===y&&(v($),p+=1,f="res");else if(b)if("/*"===b){var S=t.indexOf("*/",n.lastIndex);-1===S&&i("unclosed comment",t,r.index),n.lastIndex=S+2}else"'"===b?(l.lastIndex=r.index,l.exec(t)?n.lastIndex=l.lastIndex:i("unclosed string",t,r.index)):'"'===b?(d.lastIndex=r.index,d.exec(t)?n.lastIndex=d.lastIndex:i("unclosed string",t,r.index)):"`"===b&&(c.lastIndex=r.index,c.exec(t)?n.lastIndex=c.lastIndex:i("unclosed string",t,r.index));else if(_)return v($),p=$+r[0].length,h.lastIndex=p,m=x,w&&"h"===a&&(a="s"),u.t=a,u}return i("unclosed tag",t,e),u}var f=function r(n,c){n.b=[],n.d=[];var l,d=!1,u=[];function f(t,e){t&&(t=function(t,e,i,o){var a,r;return"string"==typeof e.autoTrim?a=r=e.autoTrim:Array.isArray(e.autoTrim)&&(a=e.autoTrim[1],r=e.autoTrim[0]),(i||!1===i)&&(a=i),(o||!1===o)&&(r=o),"slurp"===a&&"slurp"===r?t.trim():("_"===a||"slurp"===a?t=String.prototype.trimLeft?t.trimLeft():t.replace(/^[\s\uFEFF\xA0]+/,""):"-"!==a&&"nl"!==a||(t=t.replace(/^(?:\n|\r|\r\n)/,"")),"_"===r||"slurp"===r?t=String.prototype.trimRight?t.trimRight():t.replace(/[\s\uFEFF\xA0]+$/,""):"-"!==r&&"nl"!==r||(t=t.replace(/(?:\n|\r|\r\n)$/,"")),t)}(t,o,m,e),t&&(t=t.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),u.push(t)))}for(;null!==(l=h.exec(t));){var v,y=l[1],b=l[2],_=l[3]||"";for(var w in a)if(a[w]===_){v=w;break}f(y,b),p=l.index+l[0].length,v||i("unrecognized tag type: "+_,t,p);var x=g(l.index,v),$=x.t;if("h"===$){var S=x.n||"";o.async&&s.test(S)&&(x.a=!0,x.n=S.replace(s,"")),x=r(x),u.push(x)}else if("c"===$){if(n.n===x.n)return d?(d.d=u,n.b.push(d)):n.d=u,n;i("Helper start and end don't match",t,l.index+l[0].length)}else if("b"===$){d?(d.d=u,n.b.push(d)):n.d=u;var A=x.n||"";o.async&&s.test(A)&&(x.a=!0,x.n=A.replace(s,"")),d=x,u=[]}else if("s"===$){var k=x.n||"";o.async&&s.test(k)&&(x.a=!0,x.n=k.replace(s,"")),u.push(x)}else u.push(x)}if(!c)throw e('unclosed helper "'+n.n+'"');return f(t.slice(p,t.length),!1),n.d=u,n}({f:[]},!0);if(o.plugins)for(var v=0;v0)throw e((a?"Native":"")+"Helper '"+t+"' doesn't accept blocks");if(o&&o.length>0)throw e((a?"Native":"")+"Helper '"+t+"' doesn't accept filters")}function x(t,e,i,o,a){i(t[e],e).then(function(r){o+=r,e===t.length-1?a(o):x(t,e+1,i,o,a)})}function $(t,e,i,o,a,r){o(e[i],t[e[i]]).then(function(n){a+=n,i===e.length-1?r(a):$(t,e,i+1,o,a,r)})}var S={"&":"&","<":"<",">":">",'"':""","'":"'"};function A(t){return S[t]}var k=new _({}),C=new _({each:function(t,e){var i="",o=t.params[0];if(w("each",e,!1),t.async)return new Promise(function(e){x(o,0,t.exec,i,e)});for(var a=0;a"']/.test(e)?e.replace(/[&<>"']/g,A):e}}),T={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,defaultFilter:!1,tags:["{{","}}"],l:function(t,i){if("H"===t){var o=this.storage.helpers.get(i);if(o)return o;throw e("Can't find helper '"+i+"'")}if("F"===t){var a=this.storage.filters.get(i);if(a)return a;throw e("Can't find filter '"+i+"'")}},async:!1,storage:{helpers:C,nativeHelpers:E,filters:z,templates:k},prefixes:{h:"@",b:"#",i:"",r:"*",c:"/",e:"!"},cache:!1,plugins:[],useWith:!1};function O(t,e){var i={};return n(i,T),e&&n(i,e),t&&n(i,t),i.l.bind(i),i}function R(t,i){var o,r=O(i||{}),n=Function;if(r.async){if(!a)throw e("This environment doesn't support async/await");n=a}if(r.varName&&!1===(o=r.varName,/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(o)))throw e("options.varName must be a valid JS identifier");try{return new n(r.varName,"c","cb",m(t,r))}catch(i){throw i instanceof SyntaxError?e("Bad template syntax\n\n"+i.message+"\n"+Array(i.message.length+1).join("=")+"\n"+m(t,r)):i}}function N(t,e){var i;return e.cache&&e.name&&e.storage.templates.get(e.name)?e.storage.templates.get(e.name):(i="function"==typeof t?t:R(t,e),e.cache&&e.name&&e.storage.templates.define(e.name,i),i)}T.l.bind(T),t.compile=R,t.compileScope=b,t.compileScopeIntoFunction=y,t.compileToString=m,t.defaultConfig=T,t.filters=z,t.getConfig=O,t.helpers=C,t.nativeHelpers=E,t.parse=p,t.render=function(t,i,a,r){var n=O(a||{});if(!n.async)return N(t,n)(i,n);if(!r){if("function"==typeof o)return new o(function(e,o){try{e(N(t,n)(i,n))}catch(t){o(t)}});throw e("Please provide a callback function, this env doesn't support Promises")}try{N(t,n)(i,n,r)}catch(t){return r(t)}},t.templates=k,Object.defineProperty(t,"__esModule",{value:!0})}(ii.exports)),ii.exports}var ai=oi();function ri(t){return String(t??"").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function ni(t){return ri(t)}function si(t){return"string"==typeof t?t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"):Array.isArray(t)?t.map(si):t&&"object"==typeof t?Object.fromEntries(Object.entries(t).map(([t,e])=>[t,si(e)])):t}function ci({template:t,stateObj:e,attribute:i,hass:o,config:a={},variables:r={},localize:n=t=>t}){const[s]=String(e?.entity_id??"").split("."),c=e?.attributes??{},l=i&&Object.prototype.hasOwnProperty.call(c,i)?c[i]:e?.state,d=i&&"function"==typeof o.formatEntityAttributeValue?o.formatEntityAttributeValue(e,i):"function"==typeof o.formatEntityState?o.formatEntityState(e):n(String(l),`component.${s}.state._.`),h=o.selectedLanguage||o.language,u="ui.card.climate.",p=Object.entries(o.resources?.[h]??{}).reduce((t,[e,i])=>(String(e).startsWith(u)&&(t[String(e).replace(u,"")]=i),t),{});return ai.filters.define("formatNumber",(t,e={decimals:a.decimals})=>String(Ue(t,{...e,locale:o.locale}))),ai.filters.define("relativetime",t=>``),ai.filters.define("translate",(t,i="")=>!i&&"function"==typeof o.formatEntityAttributeValue&&"string"==typeof t&&t in c?o.formatEntityAttributeValue(e,t):n(t,i||"climate"!==s&&"humidifier"!==s?i:`state_attributes.${s}.${t}`)),ai.render(t,{...si(c),state:{raw:si(l),text:si(d)},state_attr:(t,e)=>si(o.states?.[t]?.attributes?.[e]),ui:p,v:r},{useWith:!0})}ai.defaultConfig.autoEscape=!1,ai.filters.define("icon",t=>``),ai.filters.define("join",(t,e=", ")=>t.join(e)),ai.filters.define("css",(t,e)=>`"'`;{}]/g,"")}(i)};`:t},""))}">${ri(t)}`),ai.filters.define("debug",t=>{try{return JSON.stringify(t)}catch{return`Not able to read valid JSON object from: ${t}`}});const li="simple-thermostat-timer-remaining";function di(t){return String(t).padStart(2,"0")}class hi extends lt{createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.syncTicker()}disconnectedCallback(){this.clearTicker(),super.disconnectedCallback()}updated(){this.syncTicker()}clearTicker(){this.tick&&(window.clearInterval(this.tick),this.tick=void 0)}syncTicker(){const t="active"===this.stateObj?.state,e=this.stateObj?.attributes?.finishes_at,i=e?Date.parse(e):NaN,o=!Number.isNaN(i)&&i>Date.now();t&&o&&!this.tick?this.tick=window.setInterval(()=>{i<=Date.now()&&this.clearTicker(),this.requestUpdate()},1e3):t&&o||!this.tick||this.clearTicker()}getValue(){const t=this.stateObj;if(!t)return"";if("active"===t.state&&t.attributes?.finishes_at){const e=Date.parse(t.attributes.finishes_at);if(!Number.isNaN(e))return function(t){const e=Math.max(0,Math.ceil(t)),i=Math.floor(e/3600),o=Math.floor(e%3600/60),a=e%60;return i>0?`${i}:${di(o)}:${di(a)}`:`${o}:${di(a)}`}((e-Date.now())/1e3)}return"paused"===t.state&&t.attributes?.remaining?t.attributes.remaining:"function"==typeof this.hass?.formatEntityState?this.hass.formatEntityState(t):t.state}render(){return B`${this.getValue()}`}}i([pt({attribute:!1})],hi.prototype,"stateObj",void 0),i([pt({attribute:!1})],hi.prototype,"hass",void 0),customElements.get(li)||customElements.define(li,hi);const ui=["automation","fan","humidifier","input_boolean","light","switch"],pi=["button","input_button","script","scene"],mi=["row","auto","button","toggle","chip"];function gi(t,e,i){const o="turn_"+(i?"on":"off");"function"==typeof t.performAction?t.performAction({action:`homeassistant.${o}`,data:{entity_id:e}}):t.callService("homeassistant",o,{entity_id:e})}function fi(t){return String(t??"").replace(/[^a-z0-9_-]/gi,"")}function vi({hide:t=!1,hass:e,state:i,details:o,localize:a,openEntityPopover:r}){if(t||void 0===i)return;const{type:n,heading:s,icon:c,unit:l,decimals:d,tooltip:h,entity:u,template:p,attribute:m,variables:g,config:f,separator:v=!0,display:y}=o,b=function({icon:t,state:e,attribute:i,hass:o,config:a,variables:r,localize:n}){return"string"==typeof t&&t.includes("{{")&&"object"==typeof e&&null!==e?ci({template:t,stateObj:e,attribute:i,hass:o,config:a,variables:r,localize:n}).trim():t}({icon:c,state:i,attribute:m,hass:e,config:f,variables:g,localize:a}),_=function({heading:t,state:e,attribute:i,hass:o,config:a,variables:r,localize:n}){if("string"==typeof t&&t.includes("{{")&&"object"==typeof e&&null!==e)return ci({template:t,stateObj:e,attribute:i,hass:o,config:a,variables:r,localize:n}).trim()}({heading:s,state:i,attribute:m,hass:e,config:f,variables:g,localize:a}),w="string"==typeof l&&l.length>0,x="object"==typeof i?i.entity_id:u,$=x&&"function"==typeof r,S=h||("object"==typeof i?i?.attributes?.friendly_name||i?.entity_id:u?e.states?.[u]?.attributes?.friendly_name||u:void 0);let A,k="",C="",E=!1,z=!1;if(p&&"object"==typeof i){const t=ci({template:p,stateObj:i,attribute:m,hass:e,config:f,variables:g,localize:a});A=B`
- ${Ke(Je(t,!!b&&l))} -
`}else if("relativetime"===n)S=B` + ${Xe(ti(t,!!w&&l))} +
`}else if("relativetime"===n)A=B`
- `;else if("object"==typeof i){const[t]=i.entity_id.split(".");A=t,k=i.state,C=ci.includes(t);const o=[C&&"toggle-entity",A&&`domain-${li(A)}`,k&&`state-${li(k)}`,C&&Be(We({icon:y||i.attributes?.icon,label:s||i.attributes?.friendly_name,entity:i,hass:e}))].filter(Boolean).join(" ");if("timer"===t)S=B` + `;else if("object"==typeof i){const[t]=i.entity_id.split(".");k=t,C=i.state,E=ui.includes(t);const o=function(t,e){return"string"==typeof t&&mi.includes(t)?"auto"!==t?t:ui.includes(e)?"toggle":pi.includes(e)?"button":"chip":"row"}(y,t),n=[E&&"toggle-entity",k&&`domain-${fi(k)}`,C&&`state-${fi(C)}`,"row"!==o&&`display-${o}`,E&&Ze(Ke({icon:b||i.attributes?.icon,label:s||i.attributes?.friendly_name,entity:i,hass:e}))].filter(Boolean).join(" ");if("row"!==o){z=!0;const c=E||pi.includes(t),l="on"===i.state,d="string"==typeof s?s:i.attributes?.friendly_name||i.entity_id,h=b||i.attributes?.icon||(E?"mdi:toggle-switch":pi.includes(t)?"mdi:gesture-tap-button":void 0),u=function({state:t,domain:e,hass:i,localize:o}){return"timer"===e?B``:"function"==typeof i.formatEntityState?i.formatEntityState(t):o?o(t.state,`component.${e}.state._.`):String(t.state)}({state:i,domain:t,hass:e,localize:a});A=B` + + `}else if("timer"===t)A=B`
- `;else if(C)S=B` -
+ `;else if(E)A=B` +
function(t,e,i){const o="turn_"+(i?"on":"off");"function"==typeof t.performAction?t.performAction({action:`homeassistant.${o}`,data:{entity_id:e}}):t.callService("homeassistant",o,{entity_id:e})}(e,i.entity_id,t.target.checked)} + @change=${t=>gi(e,i.entity_id,t.target.checked)} >
- `;else{const o=["component",t,"state",i.attributes?.device_class??"_",""].join(".");let n="function"==typeof e.formatEntityState?e.formatEntityState(i):a(i.state,o);"number"==typeof d&&(n=Ve(i.state,{decimals:d,locale:e.locale}));const s=i.attributes.unit_of_measurement??"",h="humidity"===i.attributes?.device_class||i.entity_id?.includes("humidity")||"mdi:water-percent"===c?"%":"";S=B` + `;else{const o=["component",t,"state",i.attributes?.device_class??"_",""].join(".");let n="function"==typeof e.formatEntityState?e.formatEntityState(i):a(i.state,o);"number"==typeof d&&(n=Ue(i.state,{decimals:d,locale:e.locale}));const s=i.attributes.unit_of_measurement??"",h="humidity"===i.attributes?.device_class||i.entity_id?.includes("humidity")||"mdi:water-percent"===c?"%":"";A=B`
- ${Je(n,b?l:s||h,n)} + ${ti(n,w?l:s||h,n)}
- `}}else{let t="number"==typeof d?Ve(i,{decimals:d,locale:e.locale}):i;S=B`
r(w):null} + `}}else{let t="number"==typeof d?Ue(i,{decimals:d,locale:e.locale}):i;A=B`
r(x):null} > - ${Je(t,!!b&&l)} -
`}if(!1===s)return S;const E=s||$,z=["entity-heading",x&&"clickable",C&&"toggle-entity",A&&`domain-${li(A)}`,k&&`state-${li(k)}`,C&&Be(We({icon:y||i?.attributes?.icon,label:"string"==typeof s?s:i?.attributes?.friendly_name,entity:i,hass:e}))].filter(Boolean).join(" "),T=y?B` + ${ti(t,!!w&&l)} +
`}if(z)return A;if(!1===s)return A;const T=s||S,O=["entity-heading",$&&"clickable",E&&"toggle-entity",k&&`domain-${fi(k)}`,C&&`state-${fi(C)}`,E&&Ze(Ke({icon:b||i?.attributes?.icon,label:"string"==typeof s?s:i?.attributes?.friendly_name,entity:i,hass:e}))].filter(Boolean).join(" "),R=b?B` r(w):null} + icon="${b}" + title=${T} + @click=${$?()=>r(x):null} > - `:"string"==typeof _?B`${Ke(_)}`:` ${s}${!1===v?"":":"} `;return[B`
r(w):null} + `:"string"==typeof _?B`${Xe(_)}`:` ${s}${!1===v?"":":"} `;return[B`
r(x):null} > - ${T} -
`,S]}function hi({_hide:t,entity:e,unit:i,hass:o,entities:a,config:r,localize:n,openEntityPopover:s,adapter:c}){const l=r.current_value_entity,d=l?o.states[l]:e,h=l?d?.state:c.getCurrentValue(e.attributes),u=l?d?.attributes?.unit_of_measurement??i:c.getCurrentValueUnit?.(e.attributes,o.config)??i,p=r?.layout?.entities?.labels??!0,g=!1!==r?.layout?.entities?.separator,m=r?.state_labels?.[e.state]??pe(e,o,n),f=(!0===r?.hide_current_value_when_off||!0===r?.hide?.current_value_when_off||!0===r?.hide?.temperature_when_off)&&e.state===Me.OFF,v=[di({hide:t.temperature||f||null==h,state:Je(Ve(h,{...r,locale:o.locale}),u),hass:o,openEntityPopover:s,details:{heading:!!p&&(r?.label?.temperature??n("ui.card.climate.currently")),tooltip:d?.attributes?.friendly_name??l,entity:l??r.entity,separator:g}}),di({hide:t.state,state:m,hass:o,openEntityPopover:s,details:{heading:!!p&&(r?.label?.state??n("ui.panel.lovelace.editor.card.generic.state")),entity:r.entity,separator:g}}),...(a??[]).map(({name:t,state:i,show:a,_hide_when_off:c,hide_when_off:l,...d})=>di({hide:!1===a||(!0===c||!0===l)&&e.state===Me.OFF,state:i,hass:o,localize:n,openEntityPopover:s,details:{...d,heading:p&&t,tooltip:t,config:r,variables:r.variables,separator:g}}))||null].filter(t=>null!==t);return function(t,e){const{type:i="table",labels:o=!0,alignment:a}=t?.layout?.entities??{},r=[o?"with-labels":"without-labels","list"===i?"as-list":"as-table","left"===a?"align-left":"",1===e.filter(t=>null!=t).length?"single-row":""];return B`
${e}
`}(r,v)}const ui={"st:fan-speed-4":{path:"M16 15V21H19V23H21V15H19V19H18V15H16Z"},"st:fan-speed-5":{path:"M16 15H21V17H18V18H19C20.11 18 21 18.89 21 20V21C21 22.11 20.11 23 19 23H16V21H19V20H16V15Z"}};function pi({state:t,entity:e,hass:i,mode:o,adapter:a,modeOptions:r,localize:n,setMode:s}){const{type:c,hide_when_off:l,mode:d="none",list:h,name:u,heading:p,icons:g}=o;if(0===h.length||l&&t===Me.OFF)return null;const m="hvac"===c?null:a.getModePayloadKey(c);let f=m?`state_attributes.${a.getLocalizationDomain()}.${m}.`:"";"hvac"===c?f="component.climate.state._.":"vane_horizontal"===c||"vane_vertical"===c?f="":"direction"!==c&&"oscillating"!==c&&"mode"!==c||(f="");const v=(t,e=!1)=>t?!1===r?.icons||!1===g||["swing","swing_horizontal","swing_vertical","vane_horizontal","vane_vertical"].includes(c)&&!0!==g&&!e?null:function(t){return t?B` `:null}(t):null,y=(t,e)=>{const i=n(t);return i&&i!==t?i:e},_="hvac"==c?"operation":`${c}_mode`;let b;b="vane_horizontal"===c?"Vane Horizontal":"vane_vertical"===c?"Vane Vertical":"swing_horizontal"===c?y("ui.card.climate.swing_horizontal_mode","Swing Horizontal"):"swing_vertical"===c?y("ui.card.climate.swing_vertical_mode","Swing Vertical"):"direction"===c?"Direction":"oscillating"===c?"Oscillating":"mode"===c?"Mode":"preset"===c?!0===p&&y(`ui.card.${a.getLocalizationDomain()}.${_}`,"Preset"):"state"===c?!0===p&&"State":y(`ui.card.${a.getLocalizationDomain()}.${_}`,"hvac"===c?"Operation":"Mode");const w=!1!==u&&(u||b),x="fan"===c||"preset"===c&&"fan"===a.getLocalizationDomain()?"Fan speed":"swing"===c?"Swing mode":"swing_horizontal"===c?y("ui.card.climate.swing_horizontal_mode","Horizontal swing"):"swing_vertical"===c?y("ui.card.climate.swing_vertical_mode","Vertical swing"):"vane_horizontal"===c?"Horizontal vane":"vane_vertical"===c?"Vertical vane":"",$=(!0===r?.headings||!0===p)&&!1!==w,S="preset"===c&&"fan"===a.getLocalizationDomain(),A=("hvac"===c||"state"===c||"fan"===c)&&h.length<=4,k="preset"===c&&h.length<=4||["swing","swing_horizontal","swing_vertical","vane_horizontal","vane_vertical"].includes(c),C=h.length>4||"hvac"===c&&h.length>4||"fan"===c&&h.length>4;return B` + ${R} +
`,A]}function yi({_hide:t,entity:e,unit:i,hass:o,entities:a,config:r,localize:n,openEntityPopover:s,adapter:c}){const l=r.current_value_entity,d=l?o.states[l]:e,h=l?d?.state:c.getCurrentValue(e.attributes),u=l?d?.attributes?.unit_of_measurement??i:c.getCurrentValueUnit?.(e.attributes,o.config)??i,p=r?.layout?.entities?.labels??!0,m=!1!==r?.layout?.entities?.separator,g=r?.state_labels?.[e.state]??ve(e,o,n),f=(!0===r?.hide_current_value_when_off||!0===r?.hide?.current_value_when_off||!0===r?.hide?.temperature_when_off)&&e.state===Fe.OFF,v=[vi({hide:t.temperature||f||null==h,state:ti(Ue(h,{...r,locale:o.locale}),u),hass:o,openEntityPopover:s,details:{heading:!!p&&(r?.label?.temperature??n("ui.card.climate.currently")),tooltip:d?.attributes?.friendly_name??l,entity:l??r.entity,separator:m}}),vi({hide:t.state,state:g,hass:o,openEntityPopover:s,details:{heading:!!p&&(r?.label?.state??n("ui.panel.lovelace.editor.card.generic.state")),entity:r.entity,separator:m}}),...(a??[]).map(({name:t,state:i,show:a,display:c,_hide_when_off:l,hide_when_off:d,...h})=>vi({hide:!1===a||(!0===l||!0===d)&&e.state===Fe.OFF,state:i,hass:o,localize:n,openEntityPopover:s,details:{...h,heading:p&&t,tooltip:t,config:r,variables:r.variables,separator:m,display:c??r?.layout?.entities?.display}}))||null].filter(t=>null!==t);return function(t,e){const{type:i="table",labels:o=!0,alignment:a}=t?.layout?.entities??{},r=[o?"with-labels":"without-labels","list"===i?"as-list":"as-table","left"===a?"align-left":"",1===e.filter(t=>null!=t).length?"single-row":""];return B`
${e}
`}(r,v)}const bi=new Set(["heat_cool","fan_only"]);function _i(t,e,i){if(!e||!i)return{layout:"inline",lines:e?[e]:[]};const o=e.trim();if(!o)return{layout:"inline",lines:[]};if("heat_cool"===t){const t=o.split(/\s*\/\s*/).filter(Boolean);if(2===t.length&&t.every(t=>t.length>0&&t.length<=12))return{layout:"stacked",lines:t}}if("fan_only"===t){const t=o.split(/\s+/).filter(Boolean);if(2===t.length&&t.every(t=>t.length>0&&t.length<=10))return{layout:"stacked",lines:t}}return bi.has(t)&&o.length>10?{layout:"column",lines:[o]}:{layout:"inline",lines:[o]}}const wi={"st:fan-speed-4":{path:"M16 15V21H19V23H21V15H19V19H18V15H16Z"},"st:fan-speed-5":{path:"M16 15H21V17H18V18H19C20.11 18 21 18.89 21 20V21C21 22.11 20.11 23 19 23H16V21H19V20H16V15Z"}};function xi(t){return t?B` `:null}function $i({state:t,entity:e,hass:i,mode:o,adapter:a,modeOptions:r,localize:n,setMode:s}){const{type:c,hide_when_off:l,mode:d="none",list:h,name:u,heading:p,icons:m}=o;if(0===h.length||l&&t===Fe.OFF)return null;const g="hvac"===c?null:a.getModePayloadKey(c);let f=g?`state_attributes.${a.getLocalizationDomain()}.${g}.`:"";"hvac"===c?f="component.climate.state._.":"vane_horizontal"===c||"vane_vertical"===c?f="":"direction"!==c&&"oscillating"!==c&&"mode"!==c||(f="");const v=(t,e)=>{const i=n(t);return i&&i!==t?i:e},y="hvac"==c?"operation":`${c}_mode`;let b;b="vane_horizontal"===c?"Vane Horizontal":"vane_vertical"===c?"Vane Vertical":"swing_horizontal"===c?v("ui.card.climate.swing_horizontal_mode","Swing Horizontal"):"swing_vertical"===c?v("ui.card.climate.swing_vertical_mode","Swing Vertical"):"direction"===c?"Direction":"oscillating"===c?"Oscillating":"mode"===c?"Mode":"preset"===c?!0===p&&v(`ui.card.${a.getLocalizationDomain()}.${y}`,"Preset"):"state"===c?!0===p&&"State":v(`ui.card.${a.getLocalizationDomain()}.${y}`,"hvac"===c?"Operation":"Mode");const _=!1!==u&&(u||b),w="fan"===c||"preset"===c&&"fan"===a.getLocalizationDomain()?"Fan speed":"swing"===c?"Swing mode":"swing_horizontal"===c?v("ui.card.climate.swing_horizontal_mode","Horizontal swing"):"swing_vertical"===c?v("ui.card.climate.swing_vertical_mode","Vertical swing"):"vane_horizontal"===c?"Horizontal vane":"vane_vertical"===c?"Vertical vane":"",x=(!0===r?.headings||!0===p)&&!1!==_,$="preset"===c&&"fan"===a.getLocalizationDomain(),S=("hvac"===c||"state"===c||"fan"===c)&&h.length<=4,A="preset"===c&&h.length<=4||["swing","swing_horizontal","swing_vertical","vane_horizontal","vane_vertical"].includes(c),k=h.length>4||"hvac"===c&&h.length>4||"fan"===c&&h.length>4;return B`
- ${$?B`
${w}
`:""} - ${h.map(({value:o,icon:a,iconConfigured:l,name:h,hide_when_off:u})=>{if(!0===u&&t===Me.OFF)return q;const p=(t=>String(t).replace(/[^a-z0-9_-]/gi,""))(o),g=((t,o)=>!1===t||!1===r?.names?null:t!==o?f?n(t,f):t:"hvac"!==c&&"state"!==c||"function"!=typeof i?.formatEntityState?m&&e&&"function"==typeof i?.formatEntityAttributeValue?i.formatEntityAttributeValue(e,m,o):f?n(t,f):t:i.formatEntityState({...e,state:o}))(h,o);return B` + ${x?B`
${_}
`:""} + ${h.map(({value:o,icon:a,iconConfigured:l,name:h,hide_when_off:u})=>{if(!0===u&&t===Fe.OFF)return q;const p=(t=>String(t).replace(/[^a-z0-9_-]/gi,""))(o),v=((t,o)=>!1===t||!1===r?.names?null:t!==o?f?n(t,f):t:"hvac"!==c&&"state"!==c||"function"!=typeof i?.formatEntityState?g&&e&&"function"==typeof i?.formatEntityAttributeValue?i.formatEntityAttributeValue(e,g,o):f?n(t,f):t:i.formatEntityState({...e,state:o}))(h,o),y=_i(String(o),v,S),b="stacked"===y.layout?"label-stacked":"column"===y.layout?"label-column":"";return B`
s(c,o)} @keydown=${t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),s(c,o))}} > - ${v(a,l)} - ${g?B`${g}`:null} + ${((t,e=!1)=>t?!1===r?.icons||!1===m||["swing","swing_horizontal","swing_vertical","vane_horizontal","vane_vertical"].includes(c)&&!0!==m&&!e?null:xi(t):null)(a,l)} + ${((t,e)=>{if(!e)return null;const i=_i(t,e,S);return"stacked"===i.layout?B` + ${i.lines.map(t=>B`${t}`)} + `:B`${i.lines[0]??e}`})(String(o),v)}
`})}
- `}window.customIconsets=window.customIconsets||{},window.customIconsets.st||(window.customIconsets.st=async t=>{const e=ui[`st:${t}`];return e?{path:`M13 19C13 17.59 13.5 16.3 14.3 15.28C14.17 14.97 14.03 14.65 13.86 14.34C14.26 14 14.57 13.59 14.77 13.11C15.26 13.21 15.78 13.39 16.25 13.67C17.07 13.25 18 13 19 13C20.05 13 21.03 13.27 21.89 13.74C21.95 13.37 22 12.96 22 12.5C22 8.92 18.03 8.13 14.33 10.13C14 9.73 13.59 9.42 13.11 9.22C13.3 8.29 13.74 7.24 14.73 6.75C17.09 5.57 17 2 12.5 2C8.93 2 8.14 5.96 10.13 9.65C9.72 9.97 9.4 10.39 9.21 10.87C8.28 10.68 7.23 10.25 6.73 9.26C5.56 6.89 2 7 2 11.5C2 15.07 5.95 15.85 9.64 13.87C9.96 14.27 10.39 14.59 10.88 14.79C10.68 15.71 10.24 16.75 9.26 17.24C6.9 18.42 7 22 11.5 22C12.31 22 13 21.78 13.5 21.41C13.19 20.67 13 19.86 13 19M12 13C11.43 13 11 12.55 11 12S11.43 11 12 11C12.54 11 13 11.45 13 12S12.54 13 12 13${e.path}`}:{path:""}});const gi=Object.values(mt),mi="hass:chevron-up",fi="hass:chevron-down",vi="mdi:plus",yi="mdi:minus",_i={temperature:!1,state:!1},bi=[mt.PRESET,mt.FAN,mt.HVAC,mt.SWING,mt.SWING_HORIZONTAL,mt.SWING_VERTICAL,mt.VANE_HORIZONTAL,mt.VANE_VERTICAL,mt.DIRECTION,mt.OSCILLATING,mt.STATE],wi=["entity","hide_when_off","hide_off_when_off"];function xi(t,e,i){const o=Si(String(e),i);if(Ai(o))return!1!==o.include;const a=Object.keys(i).some(t=>!t.startsWith("_")),r=t===mt.PRESET;return o??!(r&&a)}function $i(t){return t.toLowerCase().replace(/\s+/g,"_")}function Si(t,e){const i=$i(t),o=e[t];if(void 0!==o)return o;if(void 0!==e[i])return e[i];const a=Object.entries(e).find(([t])=>!t.startsWith("_")&&!wi.includes(t)&&$i(t)===i);return a?.[1]}function Ai(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function ki(t,e){const i=Array.isArray(e._order)?e._order.map(String):Object.keys(e).filter(t=>!t.startsWith("_")&&!wi.includes(t));if(0===i.length)return t;const o=new Map;t.forEach(t=>{o.set($i(String(t)),t)});const a=new Set,r=[];return i.forEach(t=>{const e=$i(t);o.has(e)&&!a.has(e)&&(r.push(o.get(e)),a.add(e))}),t.forEach(t=>{const e=$i(String(t));a.has(e)||(r.push(t),a.add(e))}),r}function Ci(t,e,i,o={}){let a=e[i.getModeAttribute(t)];return t===mt.STATE?a=["off","on"]:t===mt.DIRECTION&&e.direction?a=["forward","reverse"]:t===mt.OSCILLATING&&"boolean"==typeof e.oscillating&&(a=[!1,!0]),Array.isArray(a)?ki(a,o).filter(e=>xi(t,e,o)).map(e=>{const i=String(e),r=Si(i,o),n=Ai(r)?r:{},{name:s,...c}=n,l=!0===n.hide_when_off||!0===o.hide_off_when_off&&"off"===$i(i),d=!1!==s&&("string"==typeof s?s:be(i));return{...c,hide_when_off:l||void 0,icon:n.icon??(t===mt.FAN?Ie(i,a):void 0)??_e(i),iconConfigured:void 0!==n.icon,value:i,name:d}}):[]}function Ei(t){return"string"==typeof t?.entity_id&&t.entity_id.startsWith("select.")&&Array.isArray(t.attributes?.options)}function zi(t,e={}){return ki(t.attributes.options,e).filter(t=>xi("select",t,e)).map(t=>{const i=String(t),o=Si(i,e),a=Ai(o)?o:{},{name:r,...n}=a,s=!0===a.hide_when_off||!0===e.hide_off_when_off&&"off"===$i(i),c=!1!==r&&("string"==typeof r?r:be(i));return{...n,hide_when_off:s||void 0,icon:a.icon??_e(i),iconConfigured:void 0!==a.icon,value:i,name:c}})}function Ti(t,e){if("fan"!==t)return"";const i=Number(e?.percentage);if(Number.isNaN(i))return"";const o=Math.min(Math.max(i,0),100);return`--st-fan-spin-duration: ${Math.max(.9,3.2-o/100*2.1).toFixed(2)}s;`}function Oi(t){const e=t?.style;if("object"==typeof e&&e){const t=e["ha-card"];if("string"==typeof t)return t.trim();const i=e["."];if("string"==typeof i){const t=i.match(/ha-card\s*\{([\s\S]*?)\}/);return(t?.[1]??"").trim()}}if("string"!=typeof e)return"";const i=e.match(/ha-card\s*\{([\s\S]*?)\}/);return(i?.[1]??"").trim()}function Ni(t,e,i,o){return gi.includes(t)&&(t===mt.STATE?"fan"===e||"humidifier"===e:void 0!==i[o.getModeAttribute(t)])}function Mi(t,e,i,o){return t.filter(t=>Ni(t,e,i,o)).map(t=>({type:t,hide_when_off:!1,list:Ci(t,i,o)}))}class Ri extends lt{constructor(){super(...arguments),this.modes=[],this._hass={},this.entities=[],this.showEntities=!0,this.name="",this.stepSize=.5,this._values={},this._updatingValues=!1,this._hide=_i,this._updatingValuesTimeout=null,this._holdTimer=null,this._holdFired=!1,this._clickCount=0,this._clickTimer=null,this._setpointUpdateTimer=null,this._pendingSetpointValues=null,this._setpointDebounce=500,this.localize=(t,e="")=>{const i=`${e}${t}`;return this._hass.localize?.(i)||t},this.toggleEntityChanged=(t,e)=>{if(!this.header||!e)return;const i=t.target;this._callAction("homeassistant.turn_"+(i.checked?"on":"off"),{entity_id:e})},this.setMode=(t,e)=>{if(t&&e){const i=$t(this.config.entity);if(t===mt.STATE)return this._callAction(`${i.getLocalizationDomain()}.turn_${e}`,{entity_id:this.config.entity}),void vt(this,"haptic","light");const o=this.modes.find(e=>e.type===t);if(o?.entity)return this._callAction("select.select_option",{entity_id:o.entity,option:e}),void vt(this,"haptic","light");const a=i.transformModePayloadValue?.(t,e)??e;this._callAction(`${i.getLocalizationDomain()}.${i.getModeService(t)}`,{entity_id:this.config.entity,[i.getModePayloadKey(t)]:a}),vt(this,"haptic","light")}else vt(this,"haptic","failure")},this.openEntityPopover=(t=null)=>{vt(this,"hass-more-info",{entityId:t||this.config.entity})},this._onActionPointerDown=t=>{0!==t.button&&"mouse"===t.pointerType||(this._holdFired=!1,this._holdTimer&&clearTimeout(this._holdTimer),this._holdTimer=setTimeout(()=>{this._holdFired=!0,this._holdTimer=null,this._dispatchAction("hold")},Ri.HOLD_MS))},this._onActionPointerUp=()=>{this._holdTimer&&(clearTimeout(this._holdTimer),this._holdTimer=null)},this._onActionClick=t=>{t.preventDefault(),this._holdFired?this._holdFired=!1:(this._clickCount+=1,1===this._clickCount?(this._clickTimer&&clearTimeout(this._clickTimer),this._clickTimer=setTimeout(()=>{this._clickCount=0,this._clickTimer=null,this._dispatchSetpointTap()},Ri.DOUBLE_TAP_MS)):(this._clickTimer&&clearTimeout(this._clickTimer),this._clickTimer=null,this._clickCount=0,this._dispatchAction("double_tap")))},this._onSetpointKeyDown=t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this._dispatchSetpointTap())}}static get styles(){return ft}_sendSetpointValues(t){const{domain:e,service:i,data:o={}}=this.service;this._callAction(`${e}.${i}`,{entity_id:this.config.entity,...o,...t})}_scheduleSetpointValues(t){const e=this._setpointDebounce;e<=0?this._sendSetpointValues(t):(this._pendingSetpointValues={...t},this._setpointUpdateTimer&&clearTimeout(this._setpointUpdateTimer),this._setpointUpdateTimer=setTimeout(()=>{const t=this._pendingSetpointValues;this._setpointUpdateTimer=null,this._pendingSetpointValues=null,t&&this._sendSetpointValues(t)},e))}_getSetpointDebounce(t){const e=Number(t?.setpoint_debounce_ms??500);return Number.isFinite(e)&&e>=0?e:500}_callAction(t,e){if("function"==typeof this._hass.callService){const[i,o]=t.split(".");this._hass.callService(i,o,e)}else"function"==typeof this._hass.performAction&&this._hass.performAction({action:t,data:e})}static getConfigElement(){return window.document.createElement(`${t}-editor`)}static getStubConfig(t){return{entity:Object.keys(t.states??{}).find(t=>t.startsWith("climate.")||t.startsWith("fan.")||t.startsWith("humidifier."))??""}}setConfig(t){this.config=_t({decimals:1,...t});const e=this._getSetpointDebounce(this.config);e!==this._setpointDebounce&&(this._setpointDebounce=e),this.entities=[],this.showEntities=!0,this.toggleAttribute("embedded",!0===this.config.embedded),this._hass?.states&&this.updateFromHass(this._hass)}set hass(t){if(t?.states&&(this._hass=t),!this.config?.entity)return;if(!t?.states)return;t.states[this.config.entity]&&this.updateFromHass(t)}disconnectedCallback(){this._updatingValuesTimeout&&(clearTimeout(this._updatingValuesTimeout),this._updatingValuesTimeout=null),this._holdTimer&&(clearTimeout(this._holdTimer),this._holdTimer=null),this._clickTimer&&(clearTimeout(this._clickTimer),this._clickTimer=null),this._setpointUpdateTimer&&(clearTimeout(this._setpointUpdateTimer),this._setpointUpdateTimer=null),this._pendingSetpointValues=null,super.disconnectedCallback()}updateFromHass(t){const e=t.states[this.config.entity];this.entity!==e&&(this.entity=e);const i=$t(this.config.entity);this.header=we(this.config.header,e,t,!1!==this.config.enhanced_visuals),this.service=function(t,e=wt){return t||e.getSetpointService()}(this.config?.service??!1,i);const o=e.attributes;let a=function(t,e,i=wt,o){return!1===t?{}:t?Object.entries(t).reduce((t,[i,a])=>{if(a?.hide)return t;const r=Array.isArray(a?.hide_when)?a.hide_when:a?.hide_when?[a.hide_when]:[];return o&&r.includes(o)||(t[i]=e?.[i]),t},{}):i.getSetpoints(e)}(this.config?.setpoints??null,o,i,e.state);this._updatingValues&&function(t,e){const i=Object.keys(t);return i.length===Object.keys(e).length&&!i.some(i=>t?.[i]!==e?.[i])}(a,this._values)?(this._updatingValues=!1,this._updatingValuesTimeout&&(clearTimeout(this._updatingValuesTimeout),this._updatingValuesTimeout=null)):this._updatingValues||(this._values=a);const r=this.config.entity.split(".")[0],n=function(t){return t.some(({type:t})=>t===mt.STATE)?t.map(t=>t.type&&t.type!==mt.STATE?{...t,list:t.list?.filter(({value:t})=>"off"!==t)??[]}:t):t}(function(t,e,i,o,a){if(!1===t.control)return[];if(Array.isArray(t.control))return Mi(t.control,e,i,o);if(t.control&&"object"==typeof t.control){const r=t.control,n=Object.entries(t.control).filter(([t])=>!t.startsWith("_")),s=Array.isArray(r._order)?r._order.map(String):void 0,c=(s?[...s.filter(t=>n.some(([e])=>e===t)),...n.map(([t])=>t).filter(t=>!s.includes(t))]:n.map(([t])=>t)).map(t=>[t,r[t]]);if(c.length>0)return c.filter(([,t])=>!1!==t).filter(([t,r])=>{const n=!0===r||!1===r?void 0:r.entity;return Ei(n?a?.states?.[n]:void 0)||Ni(t,e,i,o)}).map(([t,e])=>{const{_name:r,_hide_when_off:n,hide_when_off:s,hide_off_when_off:c,_icons:l,_heading:d,entity:h,...u}=!0===e?{}:e,p=h?a?.states?.[h]:void 0,g=Ei(p),m={...u,...!0===c?{hide_off_when_off:c}:{}};return{type:t,entity:g?h:void 0,hide_when_off:s??n,icons:l,heading:d,name:r,preserve_option_order:Object.keys(u).length>0,list:g?zi(p,m):Ci(t,i,o,m)}})}return Mi(o.getDefaultControl(),e,i,o)}(this.config,r,o,i,t)),s=(c=this.config.control,Array.isArray(c)||c&&"object"==typeof c&&Array.isArray(c._order)?n:function(t,e){if("fan"!==e&&"climate"!==e)return t;const i=t=>{const e=bi.indexOf(t);return-1===e?bi.length:e};return[...t].sort((t,e)=>i(t.type)-i(e.type))}(n,r));var c;this.modes=s.map(a=>{const r=a.preserve_option_order?a.list:a.type===mt.HVAC?function(t){const e=Object.values(Me),i=[],o=[];return t.forEach(t=>{const a=e.indexOf(t.value);a>=0?i[a]=t:o.push(t)}),[...i.filter(Boolean),...o]}(a.list):a.type===mt.FAN?function(t){const e=[],i=[];return t.forEach(t=>{const o=Re.indexOf(t.value.toLowerCase());o>=0?e[o]=t:i.push(t)}),[...e.filter(Boolean),...i]}(a.list):a.list,n=a.entity&&t.states?.[a.entity]?t.states[a.entity].state:a.type===mt.HVAC||a.type===mt.STATE?e.state:o[i.getModePayloadKey(a.type)];return{...a,list:r,mode:n}});const{step:l}=i.getRange(o);this.stepSize=Number(this.config.step_size??l??.5),this._hide={..._i,...this.config.hide??{}};const d=this.config.entities??[];!1===d?(this.showEntities=!1,this.entities=[]):d?(this.showEntities=!0,this.entities=d.map(({name:e,entity:i,attribute:o,template:a,unit:r="",...n})=>{let s;const c=[e];return i?(s=t.states[i],c.push(s?.attributes?.friendly_name),o&&!a&&(s=s?.attributes?.[o])):o&&o in(this.entity.attributes??{})&&(s=a?this.entity:this.entity.attributes[o],c.push(o)),c.push(i),{...n,name:c.find(t=>!!t),state:s,entity:i,attribute:o,template:a,unit:r}})):(this.showEntities=!0,this.entities=[])}render({_hide:t,_values:e,_updatingValues:i,config:o,entity:a}=this){if(!o)return B``;const r=[];if(this.stepSize<1&&0===this.config.decimals&&r.push(B` + `}window.customIconsets=window.customIconsets||{},window.customIconsets.st||(window.customIconsets.st=async t=>{const e=wi[`st:${t}`];return e?{path:`M13 19C13 17.59 13.5 16.3 14.3 15.28C14.17 14.97 14.03 14.65 13.86 14.34C14.26 14 14.57 13.59 14.77 13.11C15.26 13.21 15.78 13.39 16.25 13.67C17.07 13.25 18 13 19 13C20.05 13 21.03 13.27 21.89 13.74C21.95 13.37 22 12.96 22 12.5C22 8.92 18.03 8.13 14.33 10.13C14 9.73 13.59 9.42 13.11 9.22C13.3 8.29 13.74 7.24 14.73 6.75C17.09 5.57 17 2 12.5 2C8.93 2 8.14 5.96 10.13 9.65C9.72 9.97 9.4 10.39 9.21 10.87C8.28 10.68 7.23 10.25 6.73 9.26C5.56 6.89 2 7 2 11.5C2 15.07 5.95 15.85 9.64 13.87C9.96 14.27 10.39 14.59 10.88 14.79C10.68 15.71 10.24 16.75 9.26 17.24C6.9 18.42 7 22 11.5 22C12.31 22 13 21.78 13.5 21.41C13.19 20.67 13 19.86 13 19M12 13C11.43 13 11 12.55 11 12S11.43 11 12 11C12.54 11 13 11.45 13 12S12.54 13 12 13${e.path}`}:{path:""}});const Si=t=>String(t).replace(/[^a-z0-9_-]/gi,"");function Ai({toggles:t,mainState:e,toggleFooterEntity:i,openEntityPopover:o}){const a=t.filter(t=>!(!0===t.hide_when_off&&e===Fe.OFF));return a.length?B` + + `:q}const ki=Object.values(gt),Ci="hass:chevron-up",Ei="hass:chevron-down",zi="mdi:plus",Ti="mdi:minus",Oi={temperature:!1,state:!1},Ri=[gt.PRESET,gt.FAN,gt.HVAC,gt.SWING,gt.SWING_HORIZONTAL,gt.SWING_VERTICAL,gt.VANE_HORIZONTAL,gt.VANE_VERTICAL,gt.DIRECTION,gt.OSCILLATING,gt.STATE],Ni=["entity","hide_when_off","hide_off_when_off"];function Mi(t,e,i){const o=Pi(String(e),i);if(Fi(o))return!1!==o.include;const a=Object.keys(i).some(t=>!t.startsWith("_")),r=t===gt.PRESET;return o??!(r&&a)}function ji(t){return t.toLowerCase().replace(/\s+/g,"_")}function Pi(t,e){const i=ji(t),o=e[t];if(void 0!==o)return o;if(void 0!==e[i])return e[i];const a=Object.entries(e).find(([t])=>!t.startsWith("_")&&!Ni.includes(t)&&ji(t)===i);return a?.[1]}function Fi(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Hi(t,e){const i=Array.isArray(e._order)?e._order.map(String):Object.keys(e).filter(t=>!t.startsWith("_")&&!Ni.includes(t));if(0===i.length)return t;const o=new Map;t.forEach(t=>{o.set(ji(String(t)),t)});const a=new Set,r=[];return i.forEach(t=>{const e=ji(t);o.has(e)&&!a.has(e)&&(r.push(o.get(e)),a.add(e))}),t.forEach(t=>{const e=ji(String(t));a.has(e)||(r.push(t),a.add(e))}),r}function Ii(t,e,i,o={}){let a=e[i.getModeAttribute(t)];return t===gt.STATE?a=["off","on"]:t===gt.DIRECTION&&e.direction?a=["forward","reverse"]:t===gt.OSCILLATING&&"boolean"==typeof e.oscillating&&(a=[!1,!0]),Array.isArray(a)?Hi(a,o).filter(e=>Mi(t,e,o)).map(e=>{const i=String(e),r=Pi(i,o),n=Fi(r)?r:{},{name:s,...c}=n,l=!0===n.hide_when_off||!0===o.hide_off_when_off&&"off"===ji(i),d=!1!==s&&("string"==typeof s?s:Se(i));return{...c,hide_when_off:l||void 0,icon:n.icon??(t===gt.FAN?De(i,a):void 0)??$e(i),iconConfigured:void 0!==n.icon,value:i,name:d}}):[]}function Vi(t){return"string"==typeof t?.entity_id&&t.entity_id.startsWith("select.")&&Array.isArray(t.attributes?.options)}function Li(t,e={}){return Hi(t.attributes.options,e).filter(t=>Mi("select",t,e)).map(t=>{const i=String(t),o=Pi(i,e),a=Fi(o)?o:{},{name:r,...n}=a,s=!0===a.hide_when_off||!0===e.hide_off_when_off&&"off"===ji(i),c=!1!==r&&("string"==typeof r?r:Se(i));return{...n,hide_when_off:s||void 0,icon:a.icon??$e(i),iconConfigured:void 0!==a.icon,value:i,name:c}})}function Di(t,e){if("fan"!==t)return"";const i=Number(e?.percentage);if(Number.isNaN(i))return"";const o=Math.min(Math.max(i,0),100);return`--st-fan-spin-duration: ${Math.max(.9,3.2-o/100*2.1).toFixed(2)}s;`}function Ui(t){const e=t?.style;if("object"==typeof e&&e){const t=e["ha-card"];if("string"==typeof t)return t.trim();const i=e["."];if("string"==typeof i){const t=i.match(/ha-card\s*\{([\s\S]*?)\}/);return(t?.[1]??"").trim()}}if("string"!=typeof e)return"";const i=e.match(/ha-card\s*\{([\s\S]*?)\}/);return(i?.[1]??"").trim()}function Wi(t,e,i,o){return ki.includes(t)&&(t===gt.STATE?"fan"===e||"humidifier"===e:void 0!==i[o.getModeAttribute(t)])}function Bi(t,e,i,o){return t.filter(t=>Wi(t,e,i,o)).map(t=>({type:t,hide_when_off:!1,list:Ii(t,i,o)}))}class Gi extends lt{constructor(){super(...arguments),this.modes=[],this._hass={},this.entities=[],this.footer=[],this.showEntities=!0,this.name="",this.stepSize=.5,this._values={},this._updatingValues=!1,this._hide=Oi,this._updatingValuesTimeout=null,this._holdTimer=null,this._holdFired=!1,this._clickCount=0,this._clickTimer=null,this._setpointUpdateTimer=null,this._pendingSetpointValues=null,this._setpointDebounce=500,this.localize=(t,e="")=>{const i=`${e}${t}`;return this._hass.localize?.(i)||t},this.toggleEntityChanged=(t,e)=>{if(!this.header||!e)return;const i=t.target;this._callAction("homeassistant.turn_"+(i.checked?"on":"off"),{entity_id:e})},this.toggleFooterEntity=(t,e)=>{this._callAction("homeassistant.turn_"+(e?"on":"off"),{entity_id:t}),vt(this,"haptic","light")},this.setMode=(t,e)=>{if(t&&e){const i=$t(this.config.entity);if(t===gt.STATE)return this._callAction(`${i.getLocalizationDomain()}.turn_${e}`,{entity_id:this.config.entity}),void vt(this,"haptic","light");const o=this.modes.find(e=>e.type===t);if(o?.entity)return this._callAction("select.select_option",{entity_id:o.entity,option:e}),void vt(this,"haptic","light");const a=i.transformModePayloadValue?.(t,e)??e;this._callAction(`${i.getLocalizationDomain()}.${i.getModeService(t)}`,{entity_id:this.config.entity,[i.getModePayloadKey(t)]:a}),vt(this,"haptic","light")}else vt(this,"haptic","failure")},this.openEntityPopover=(t=null)=>{vt(this,"hass-more-info",{entityId:t||this.config.entity})},this._onActionPointerDown=t=>{0!==t.button&&"mouse"===t.pointerType||(this._holdFired=!1,this._holdTimer&&clearTimeout(this._holdTimer),this._holdTimer=setTimeout(()=>{this._holdFired=!0,this._holdTimer=null,this._dispatchAction("hold")},Gi.HOLD_MS))},this._onActionPointerUp=()=>{this._holdTimer&&(clearTimeout(this._holdTimer),this._holdTimer=null)},this._onActionClick=t=>{t.preventDefault(),this._holdFired?this._holdFired=!1:(this._clickCount+=1,1===this._clickCount?(this._clickTimer&&clearTimeout(this._clickTimer),this._clickTimer=setTimeout(()=>{this._clickCount=0,this._clickTimer=null,this._dispatchSetpointTap()},Gi.DOUBLE_TAP_MS)):(this._clickTimer&&clearTimeout(this._clickTimer),this._clickTimer=null,this._clickCount=0,this._dispatchAction("double_tap")))},this._onSetpointKeyDown=t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this._dispatchSetpointTap())}}static get styles(){return ft}_sendSetpointValues(t){const{domain:e,service:i,data:o={}}=this.service;this._callAction(`${e}.${i}`,{entity_id:this.config.entity,...o,...t})}_scheduleSetpointValues(t){const e=this._setpointDebounce;e<=0?this._sendSetpointValues(t):(this._pendingSetpointValues={...t},this._setpointUpdateTimer&&clearTimeout(this._setpointUpdateTimer),this._setpointUpdateTimer=setTimeout(()=>{const t=this._pendingSetpointValues;this._setpointUpdateTimer=null,this._pendingSetpointValues=null,t&&this._sendSetpointValues(t)},e))}_getSetpointDebounce(t){const e=Number(t?.setpoint_debounce_ms??500);return Number.isFinite(e)&&e>=0?e:500}_callAction(t,e){if("function"==typeof this._hass.callService){const[i,o]=t.split(".");this._hass.callService(i,o,e)}else"function"==typeof this._hass.performAction&&this._hass.performAction({action:t,data:e})}static getConfigElement(){return window.document.createElement(`${t}-editor`)}static getStubConfig(t){return{entity:Object.keys(t.states??{}).find(t=>t.startsWith("climate.")||t.startsWith("fan.")||t.startsWith("humidifier."))??""}}setConfig(t){this.config=bt({decimals:1,...t});const e=this._getSetpointDebounce(this.config);e!==this._setpointDebounce&&(this._setpointDebounce=e),this.entities=[],this.footer=[],this.showEntities=!0,this.toggleAttribute("embedded",!0===this.config.embedded),this._hass?.states&&this.updateFromHass(this._hass)}set hass(t){if(t?.states&&(this._hass=t),!this.config?.entity)return;if(!t?.states)return;t.states[this.config.entity]&&this.updateFromHass(t)}disconnectedCallback(){this._updatingValuesTimeout&&(clearTimeout(this._updatingValuesTimeout),this._updatingValuesTimeout=null),this._holdTimer&&(clearTimeout(this._holdTimer),this._holdTimer=null),this._clickTimer&&(clearTimeout(this._clickTimer),this._clickTimer=null),this._setpointUpdateTimer&&(clearTimeout(this._setpointUpdateTimer),this._setpointUpdateTimer=null),this._pendingSetpointValues=null,super.disconnectedCallback()}updateFromHass(t){const e=t.states[this.config.entity];this.entity!==e&&(this.entity=e);const i=$t(this.config.entity);this.header=Ae(this.config.header,e,t,!1!==this.config.enhanced_visuals),this.service=function(t,e=wt){return t||e.getSetpointService()}(this.config?.service??!1,i);const o=e.attributes;let a=function(t,e,i=wt,o){return!1===t?{}:t?Object.entries(t).reduce((t,[i,a])=>{if(a?.hide)return t;const r=Array.isArray(a?.hide_when)?a.hide_when:a?.hide_when?[a.hide_when]:[];return o&&r.includes(o)||(t[i]=e?.[i]),t},{}):i.getSetpoints(e)}(this.config?.setpoints??null,o,i,e.state);this._updatingValues&&function(t,e){const i=Object.keys(t);return i.length===Object.keys(e).length&&!i.some(i=>t?.[i]!==e?.[i])}(a,this._values)?(this._updatingValues=!1,this._updatingValuesTimeout&&(clearTimeout(this._updatingValuesTimeout),this._updatingValuesTimeout=null)):this._updatingValues||(this._values=a);const r=this.config.entity.split(".")[0],n=function(t){return t.some(({type:t})=>t===gt.STATE)?t.map(t=>t.type&&t.type!==gt.STATE?{...t,list:t.list?.filter(({value:t})=>"off"!==t)??[]}:t):t}(function(t,e,i,o,a){if(!1===t.control)return[];if(Array.isArray(t.control))return Bi(t.control,e,i,o);if(t.control&&"object"==typeof t.control){const r=t.control,n=Object.entries(t.control).filter(([t])=>!t.startsWith("_")),s=Array.isArray(r._order)?r._order.map(String):void 0,c=(s?[...s.filter(t=>n.some(([e])=>e===t)),...n.map(([t])=>t).filter(t=>!s.includes(t))]:n.map(([t])=>t)).map(t=>[t,r[t]]);if(c.length>0)return c.filter(([,t])=>!1!==t).filter(([t,r])=>{const n=!0===r||!1===r?void 0:r.entity;return Vi(n?a?.states?.[n]:void 0)||Wi(t,e,i,o)}).map(([t,e])=>{const{_name:r,_hide_when_off:n,hide_when_off:s,hide_off_when_off:c,_icons:l,_heading:d,entity:h,...u}=!0===e?{}:e,p=h?a?.states?.[h]:void 0,m=Vi(p),g={...u,...!0===c?{hide_off_when_off:c}:{}};return{type:t,entity:m?h:void 0,hide_when_off:s??n,icons:l,heading:d,name:r,preserve_option_order:Object.keys(u).length>0,list:m?Li(p,g):Ii(t,i,o,g)}})}return Bi(o.getDefaultControl(),e,i,o)}(this.config,r,o,i,t)),s=(c=this.config.control,Array.isArray(c)||c&&"object"==typeof c&&Array.isArray(c._order)?n:function(t,e){if("fan"!==e&&"climate"!==e)return t;const i=t=>{const e=Ri.indexOf(t);return-1===e?Ri.length:e};return[...t].sort((t,e)=>i(t.type)-i(e.type))}(n,r));var c;this.modes=s.map(a=>{const r=a.preserve_option_order?a.list:a.type===gt.HVAC?function(t){const e=Object.values(Fe),i=[],o=[];return t.forEach(t=>{const a=e.indexOf(t.value);a>=0?i[a]=t:o.push(t)}),[...i.filter(Boolean),...o]}(a.list):a.type===gt.FAN?function(t){const e=[],i=[];return t.forEach(t=>{const o=He.indexOf(t.value.toLowerCase());o>=0?e[o]=t:i.push(t)}),[...e.filter(Boolean),...i]}(a.list):a.list,n=a.entity&&t.states?.[a.entity]?t.states[a.entity].state:a.type===gt.HVAC||a.type===gt.STATE?e.state:o[i.getModePayloadKey(a.type)];return{...a,list:r,mode:n}});const{step:l}=i.getRange(o);this.stepSize=Number(this.config.step_size??l??.5),this._hide={...Oi,...this.config.hide??{}};const d=this.config.entities??[];!1===d?(this.showEntities=!1,this.entities=[]):d?(this.showEntities=!0,this.entities=d.map(({name:e,entity:i,attribute:o,template:a,unit:r="",...n})=>{let s;const c=[e];return i?(s=t.states[i],c.push(s?.attributes?.friendly_name),o&&!a&&(s=s?.attributes?.[o])):o&&o in(this.entity.attributes??{})&&(s=a?this.entity:this.entity.attributes[o],c.push(o)),c.push(i),{...n,name:c.find(t=>!!t),state:s,entity:i,attribute:o,template:a,unit:r}})):(this.showEntities=!0,this.entities=[]),this.footer=function(t){return Array.isArray(t.footer)?t.footer:[]}(this.config).map(({entity:e,name:i,icon:o,hide_when_off:a})=>{const r=t.states?.[e];return r?{entity:e,name:i,icon:o,hide_when_off:a,state:r}:null}).filter(t=>!!t)}render({_hide:t,_values:e,_updatingValues:i,config:o,entity:a}=this){if(!o)return B``;const r=[];if(this.stepSize<1&&0===this.config.decimals&&r.push(B` Decimals is set to 0 and step_size is lower than 1. Decrementing a setpoint will likely not work. Change one of the settings to clear @@ -2703,23 +3138,24 @@ ha-card.standard-visuals .thermostat-trigger:active { Entity not available: ${o.entity} - `;const n=$t(o.entity),s=ue(a),{min:c,max:l}=n.getRange(a.attributes),d=this.getUnit(),h=o.entity.split(".")[0],u=Object.keys(e).length,p=!1===this.config.enhanced_visuals?this.config?.layout?.step??"column":this.config?.layout?.step??"row",g="row"===p,m=["unavailable","unknown"].includes(a.state),f=t=>"string"==typeof t?t.replace(/[^a-z0-9_-]/gi,""):"",v=[!this.header&&"no-header",`domain-${f(h)}`,`state-${f(a.state)}`,!1===this.config.enhanced_visuals&&"standard-visuals",!0===this.config.embedded&&"embedded",f(s),m&&f(a.state)].filter(t=>!!t),y=["body",this.showEntities&&"has-entities",`step-${p}`,`setpoint-count-${u}`].filter(t=>!!t),_=!0===o.embedded,b=_?function(t,e,i){return[Oi(t.card_mod),Ti(e,i)].filter(t=>!!t).join("; ")}(o,h,a.attributes):Ti(h,a.attributes),w=this.showEntities?hi({_hide:t,unit:d,hass:this._hass,entity:this.entity,entities:this.entities,config:this.config,adapter:n,localize:this.localize,openEntityPopover:this.openEntityPopover}):"",x=_?B``:Ge({header:this.header,hass:this._hass,toggleEntityChanged:this.toggleEntityChanged,entity:this.entity,openEntityPopover:this.openEntityPopover});return B` - + `;const n=$t(o.entity),s=fe(a),{min:c,max:l}=n.getRange(a.attributes),d=this.getUnit(),h=o.entity.split(".")[0],u=Object.keys(e).length,p=this.config?.layout?.step,m=!p&&this.showEntities&&u>1,g=p??(!1===this.config.enhanced_visuals||m?"column":"row"),f="row"===g,v=["unavailable","unknown"].includes(a.state),y=t=>"string"==typeof t?t.replace(/[^a-z0-9_-]/gi,""):"",b=[!this.header&&"no-header",`domain-${y(h)}`,`state-${y(a.state)}`,!1===this.config.enhanced_visuals&&"standard-visuals",!0===this.config.embedded&&"embedded",y(s),v&&y(a.state)].filter(t=>!!t),_=["body",this.showEntities&&"has-entities",`step-${g}`,`setpoint-count-${u}`].filter(t=>!!t),w=!0===o.embedded,x=w?function(t,e,i){return[Ui(t.card_mod),Di(e,i)].filter(t=>!!t).join("; ")}(o,h,a.attributes):Di(h,a.attributes),$=this.showEntities?yi({_hide:t,unit:d,hass:this._hass,entity:this.entity,entities:this.entities,config:this.config,adapter:n,localize:this.localize,openEntityPopover:this.openEntityPopover}):"",S=w?B``:Je({header:this.header,hass:this._hass,toggleEntityChanged:this.toggleEntityChanged,entity:this.entity,openEntityPopover:this.openEntityPopover});return B` + ${o.styles?B``:q} ${r} - ${x} -
- ${w} - ${this.renderSetpoints({values:e,minValue:c,maxValue:l,unit:d,row:g,stepLayout:p,isOff:a.state===Me.OFF,disableSteppers:"climate"===h&&a.state===Me.OFF&&!0===this.config.disable_setpoint_change_when_off})} + ${S} +
+ ${$} + ${this.renderSetpoints({values:e,minValue:c,maxValue:l,unit:d,row:f,stepLayout:g,isOff:a.state===Fe.OFF,disableSteppers:"climate"===h&&a.state===Fe.OFF&&!0===this.config.disable_setpoint_change_when_off})}
${this.modes.length?B`
- ${this.modes.map(t=>pi({state:a.state,entity:a,hass:this._hass,mode:t,adapter:n,localize:this.localize,modeOptions:this.config?.layout?.mode??{},setMode:this.setMode}))} + ${this.modes.map(t=>$i({state:a.state,entity:a,hass:this._hass,mode:t,adapter:n,localize:this.localize,modeOptions:this.config?.layout?.mode??{},setMode:this.setMode}))}
`:q} + ${Ai({toggles:this.footer,mainState:a.state,toggleFooterEntity:this.toggleFooterEntity,openEntityPopover:this.openEntityPopover})} `}renderSetpoints({values:t,minValue:e,maxValue:i,unit:o,row:a,stepLayout:r,isOff:n,disableSteppers:s}){return!0===this.config.hide_setpoint||!0===this.config.hide_setpoint_when_off&&n||!0===this.config.hide?.setpoint_when_off&&n?q:Object.entries(t).map(([t,c])=>this.renderSetpointControl({field:t,value:c,minValue:e,maxValue:i,unit:o,row:a,stepLayout:r,isOff:n,disableSteppers:s}))}renderSetpointControl(t){const{row:e,stepLayout:i}=t,o=this.renderSetpointStepper(t,"decrease"),a=this.renderSetpointValue(t),r=this.renderSetpointStepper(t,"increase"),n=this.renderSetpointLabel(t);return B`
@@ -2734,9 +3170,9 @@ ha-card.standard-visuals .thermostat-trigger:active { aria-label=${`${l?"Decrease":"Increase"} ${t}`} @click="${()=>l?this.setTemperature(-this.stepSize,t):null===e&&null!==i?this.setTemperature(0,t,i):this.setTemperature(this.stepSize,t)}" > - + - `}renderSetpointValue({field:t,value:e,unit:i,isOff:o}){const a=["string","number"].includes(typeof e)&&""!==e&&null!==e,r=!1!==i&&a,n=o&&!a,s=n?"OFF":Ve(e,{...this.config,locale:this._hass.locale}),c=r&&"string"==typeof i?i:"",l="%"===c?"":" ",d=c&&s.endsWith(c)?s.slice(0,-c.length).trimEnd():s,h=c?`${d}${l}${c}`:s;return B` + `}renderSetpointValue({field:t,value:e,unit:i,isOff:o}){const a=["string","number"].includes(typeof e)&&""!==e&&null!==e,r=!1!==i&&a,n=o&&!a,s=n?"OFF":Ue(e,{...this.config,locale:this._hass.locale}),c=r&&"string"==typeof i?i:"",l="%"===c?"":" ",d=c&&s.endsWith(c)?s.slice(0,-c.length).trimEnd():s,h=c?`${d}${l}${c}`:s;return B`

${d}${c?B`${l}${c}`:q}

- `}setTemperature(t,e,i){this._updatingValues=!0,this._updatingValuesTimeout&&clearTimeout(this._updatingValuesTimeout),this._updatingValuesTimeout=setTimeout(()=>{this._updatingValues=!1,this._updatingValuesTimeout=null},1e4);const o=i??this._values[e],a=Number(o)+t,{decimals:r}=this.config;this._values={...this._values,[e]:+Ve(a,{decimals:r})},this._scheduleSetpointValues(this._values)}_dispatchSetpointTap(){this.config?.tap_action?this._dispatchAction("tap"):this.openEntityPopover(this.config.entity)}_dispatchAction(t){const e="tap"===t?"tap_action":"hold"===t?"hold_action":"double_tap_action",i=this.config?.[e]??("tap"===t?{action:"more-info"}:{action:"none"});vt(this,"hass-action",{config:this.config,action:i})}getCardSize(){if(!this.config)return 1;const t=!0===this.config.embedded||this.header?1:0,e=this.showEntities&&this.entities?.length?Math.max(1,Math.ceil(this.entities.length/2)):0,i=!0===this.config.hide_setpoint||!0===this.config.hide_setpoint_when_off&&this.entity?.state===Me.OFF||!0===this.config.hide?.setpoint_when_off&&this.entity?.state===Me.OFF?0:1,o=this.modes?.filter(t=>(!0!==t.hide_when_off||this.entity?.state!==Me.OFF)&&(t.list??[]).some(({hide_when_off:t})=>!(!0===t&&this.entity?.state===Me.OFF))).length??0,a=this.stepSize<1&&0===this.config.decimals?1:0;return Math.max(1,t+e+i+o+a)}getUnit(){if(["boolean","string"].includes(typeof this.config.unit))return this.config?.unit;const t=this.config.entity.split(".")[0];return"fan"===t||"humidifier"===t?"%":this._hass.config?.unit_system?.temperature??!1}}Ri.HOLD_MS=500,Ri.DOUBLE_TAP_MS=250,i([pt()],Ri.prototype,"config",void 0),i([pt()],Ri.prototype,"header",void 0),i([pt()],Ri.prototype,"service",void 0),i([pt()],Ri.prototype,"modes",void 0),i([pt()],Ri.prototype,"entity",void 0),i([pt()],Ri.prototype,"entities",void 0),i([pt()],Ri.prototype,"showEntities",void 0),i([pt()],Ri.prototype,"name",void 0),i([pt({type:Object})],Ri.prototype,"_values",void 0),i([pt()],Ri.prototype,"_updatingValues",void 0),i([pt()],Ri.prototype,"_hide",void 0),customElements.get(t)||customElements.define(t,Ri),customElements.get(`${t}-editor`)||customElements.define(`${t}-editor`,Kt),customElements.get(`${t}-group`)||customElements.define(`${t}-group`,Ne),customElements.get(`${t}-group-editor`)||customElements.define(`${t}-group-editor`,de),console.info(`%c SIMPLE-THERMOSTAT %c v${e} `,"color: var(--text-primary-color); background: var(--primary-color); font-weight: 700; padding: 2px 6px; border-radius: 3px 0 0 3px;","color: var(--primary-color); background: var(--card-background-color); font-weight: 700; padding: 2px 6px; border-radius: 0 3px 3px 0;");const ji=window;ji.customCards=ji.customCards||[],ji.customCards.find(e=>e.type===t)||ji.customCards.push({type:t,name:"Simple Thermostat",preview:!0,description:"A different take on the thermostat card",documentationURL:"https://github.com/Wheemer/simple-thermostat"}),ji.customCards.find(e=>e.type===`${t}-group`)||ji.customCards.push({type:`${t}-group`,name:"Simple Thermostat Group",preview:!0,description:"Switch between multiple thermostat cards in one footprint",documentationURL:"https://github.com/Wheemer/simple-thermostat"}); + `}setTemperature(t,e,i){this._updatingValues=!0,this._updatingValuesTimeout&&clearTimeout(this._updatingValuesTimeout),this._updatingValuesTimeout=setTimeout(()=>{this._updatingValues=!1,this._updatingValuesTimeout=null},1e4);const o=i??this._values[e],a=Number(o)+t,{decimals:r}=this.config;this._values={...this._values,[e]:+Ue(a,{decimals:r})},this._scheduleSetpointValues(this._values)}_dispatchSetpointTap(){this.config?.tap_action?this._dispatchAction("tap"):this.openEntityPopover(this.config.entity)}_dispatchAction(t){const e="tap"===t?"tap_action":"hold"===t?"hold_action":"double_tap_action",i=this.config?.[e]??("tap"===t?{action:"more-info"}:{action:"none"});vt(this,"hass-action",{config:this.config,action:i})}getCardSize(){if(!this.config)return 1;const t=!0===this.config.embedded||this.header?1:0,e=this.showEntities&&this.entities?.length?Math.max(1,Math.ceil(this.entities.length/2)):0,i=!0===this.config.hide_setpoint||!0===this.config.hide_setpoint_when_off&&this.entity?.state===Fe.OFF||!0===this.config.hide?.setpoint_when_off&&this.entity?.state===Fe.OFF?0:1,o=this.modes?.filter(t=>(!0!==t.hide_when_off||this.entity?.state!==Fe.OFF)&&(t.list??[]).some(({hide_when_off:t})=>!(!0===t&&this.entity?.state===Fe.OFF))).length??0,a=this.footer?.some(({hide_when_off:t})=>!(!0===t&&this.entity?.state===Fe.OFF))?1:0,r=this.stepSize<1&&0===this.config.decimals?1:0;return Math.max(1,t+e+i+o+a+r)}getUnit(){if(["boolean","string"].includes(typeof this.config.unit))return this.config?.unit;const t=this.config.entity.split(".")[0];return"fan"===t||"humidifier"===t?"%":this._hass.config?.unit_system?.temperature??!1}}Gi.HOLD_MS=500,Gi.DOUBLE_TAP_MS=250,i([pt()],Gi.prototype,"config",void 0),i([pt()],Gi.prototype,"header",void 0),i([pt()],Gi.prototype,"service",void 0),i([pt()],Gi.prototype,"modes",void 0),i([pt()],Gi.prototype,"entity",void 0),i([pt()],Gi.prototype,"entities",void 0),i([pt()],Gi.prototype,"footer",void 0),i([pt()],Gi.prototype,"showEntities",void 0),i([pt()],Gi.prototype,"name",void 0),i([pt({type:Object})],Gi.prototype,"_values",void 0),i([pt()],Gi.prototype,"_updatingValues",void 0),i([pt()],Gi.prototype,"_hide",void 0),customElements.get(t)||customElements.define(t,Gi),customElements.get(`${t}-editor`)||customElements.define(`${t}-editor`,Xt),customElements.get(`${t}-group`)||customElements.define(`${t}-group`,Pe),customElements.get(`${t}-group-editor`)||customElements.define(`${t}-group-editor`,me),console.info(`%c SIMPLE-THERMOSTAT %c v${e} `,"color: var(--text-primary-color); background: var(--primary-color); font-weight: 700; padding: 2px 6px; border-radius: 3px 0 0 3px;","color: var(--primary-color); background: var(--card-background-color); font-weight: 700; padding: 2px 6px; border-radius: 0 3px 3px 0;");const qi=window;qi.customCards=qi.customCards||[],qi.customCards.find(e=>e.type===t)||qi.customCards.push({type:t,name:"Simple Thermostat",preview:!0,description:"A different take on the thermostat card",documentationURL:"https://github.com/Wheemer/simple-thermostat"}),qi.customCards.find(e=>e.type===`${t}-group`)||qi.customCards.push({type:`${t}-group`,name:"Simple Thermostat Group",preview:!0,description:"Switch between multiple thermostat cards in one footprint",documentationURL:"https://github.com/Wheemer/simple-thermostat"}); diff --git a/www/community/simple-thermostat/simple-thermostat.js.gz b/www/community/simple-thermostat/simple-thermostat.js.gz index f8c32d7f..160f220d 100644 Binary files a/www/community/simple-thermostat/simple-thermostat.js.gz and b/www/community/simple-thermostat/simple-thermostat.js.gz differ diff --git a/zigbee2mqtt/state.json b/zigbee2mqtt/state.json index 862c5a69..49a89b69 100644 --- a/zigbee2mqtt/state.json +++ b/zigbee2mqtt/state.json @@ -4,7 +4,7 @@ "state": "ON", "led_brightness": 100, "countdown_to_turn_off": 0, - "voltage": 122, + "voltage": 121, "countdown_to_turn_on": 0, "ac_frequency": 60, "power_factor": 0.14, @@ -22,15 +22,15 @@ }, "0xffffb40e0607af27": { "state": "ON", - "voltage": 121.6, + "voltage": 121, "ac_frequency": 60, "led_brightness": 100, "countdown_to_turn_off": 0, "countdown_to_turn_on": 0, - "power": 2, - "current": 0.09, + "power": 2.1, + "current": 0.1, "energy": 32.46, - "power_factor": 0.17, + "power_factor": 0.18, "update": { "state": "idle", "installed_version": 268513381, @@ -45,9 +45,9 @@ "state": "ON", "led_brightness": 100, "countdown_to_turn_off": 0, - "voltage": 121.5, + "voltage": 120.5, "countdown_to_turn_on": 0, - "energy": 64.55, + "energy": 64.57, "power_factor": 0.2, "ac_frequency": 60, "update": { @@ -58,7 +58,7 @@ "latest_release_notes": null }, "linkquality": 138, - "power": 0.2, + "power": 0.3, "current": 0.01, "power_on_behavior": "on" }, @@ -74,13 +74,13 @@ "led_brightness": 100, "countdown_to_turn_off": 0, "countdown_to_turn_on": 0, - "voltage": 120.7, + "voltage": 120.8, "state": "ON", "ac_frequency": 60, - "energy": 130.73, - "power": 98.2, - "current": 0.86, - "power_factor": 0.94, + "energy": 130.77, + "power": 0.7, + "current": 0.05, + "power_factor": 0.41, "update": { "state": "idle", "installed_version": 268513381, @@ -95,13 +95,13 @@ "led_brightness": 100, "countdown_to_turn_off": 0, "countdown_to_turn_on": 0, - "voltage": 121.9, - "energy": 61.83, + "voltage": 121, + "energy": 61.86, "state": "ON", - "power": 41.6, - "current": 0.45, + "power": 43.8, + "current": 0.49, "ac_frequency": 60, - "power_factor": 0.75, + "power_factor": 0.74, "update": { "state": "idle", "installed_version": 268513381, @@ -114,7 +114,7 @@ }, "0xffffb40e060895b3": { "state": "ON", - "voltage": 121, + "voltage": 120.8, "ac_frequency": 60, "energy": 8.78, "current": 0.01, @@ -136,14 +136,14 @@ "0xffffb40e0608864e": { "led_brightness": 100, "countdown_to_turn_off": 0, - "voltage": 122, + "voltage": 121.9, "energy": 20.08, "countdown_to_turn_on": 0, "state": "ON", "current": 0.02, "ac_frequency": 60, "power": 0.3, - "power_factor": 0.14, + "power_factor": 0.18, "update": { "state": "idle", "installed_version": 268513381, @@ -172,7 +172,7 @@ "0xffffb40e060893d8": { "state": "ON", "led_brightness": 100, - "voltage": 121.9, + "voltage": 120.8, "countdown_to_turn_off": 0, "countdown_to_turn_on": 0, "energy": 3.49, @@ -192,7 +192,7 @@ }, "0xa4c1380d0679ffff": { "battery": 100, - "temperature": 27.1, + "temperature": 26.9, "temperature_units": "celsius", "temperature_calibration": 0, "update": {