!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(Q)return X;Q=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($)return J;$=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 a=e("Symbol");return t(a)&&n(a.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(ae)return ie;ae=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 oe;se=1;var e=_(),t=ve(),n=ye(),r=TypeError;return oe=function(i,a){var o,s;if("string"===a&&t(o=i.toString)&&!n(s=e(o,i)))return s;if(t(o=i.valueOf)&&!n(s=e(o,i)))return s;if("string"!==a&&t(o=i.toString)&&!n(s=e(o,i)))return s;throw new r("Can't convert object to primitive value")}}var Pe,ke,Me,Le,Oe,Be,De,Ue,Fe,Ne,je,We,ze,He,Ge,qe,Ye,Ve,Xe,Qe,Je,$e,Ze,Ke,et={exports:{}};function tt(){return ke?Pe:(ke=1,Pe=!1)}function nt(){if(Le)return Me;Le=1;var e=s(),t=Object.defineProperty;return Me=function(n,r){try{t(e,n,{value:r,configurable:!0,writable:!0})}catch(t){e[n]=r}return r}}function rt(){if(Oe)return et.exports;Oe=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 at(){if(Fe)return Ue;Fe=1;var e=pe(),t=Object;return Ue=function(n){return t(e(n))}}function ot(){if(je)return Ne;je=1;var e=he(),t=at(),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=ot(),r=st(),i=Ee(),a=xe(),o=e.Symbol,c=t("wks"),u=a?o.for||o:o&&o.withoutSetter||r;return He=function(e){return n(c,e)||(c[e]=i&&n(o,e)?o[e]:u("Symbol."+e)),c[e]}}function ut(){if(Ye)return qe;Ye=1;var e=_(),t=ye(),n=Se(),r=Te(),i=Re(),a=ct(),o=TypeError,s=a("toPrimitive");return qe=function(a,c){if(!t(a)||n(a))return a;var u,l=r(a,s);if(l){if(void 0===c&&(c="default"),u=e(l,a,c),!t(u)||n(u))return u;throw new o("Can't convert object to primitive value")}return void 0===c&&(c="number"),i(a,c)}}function lt(){if(Xe)return Ve;Xe=1;var e=ut(),t=Se();return Ve=function(n){var r=e(n,"string");return t(r)?r:r+""}}function ht(){if(Je)return Qe;Je=1;var e=s(),t=ye(),n=e.document,r=t(n)&&t(n.createElement);return Qe=function(e){return r?n.createElement(e):{}}}function dt(){if(Ze)return $e;Ze=1;var e=y(),t=v(),n=ht();return $e=!e&&!t(function(){return 7!==Object.defineProperty(n("div"),"a",{get:function(){return 7}}).a})}function ft(){if(Ke)return g;Ke=1;var e=y(),t=_(),n=ue(),r=le(),i=ge(),a=lt(),o=ot(),s=dt(),c=Object.getOwnPropertyDescriptor;return g.f=e?c:function(e,u){if(e=i(e),u=a(u),s)try{return c(e,u)}catch(e){}if(o(e,u))return r(!t(n.f,e,u),e[u])},g}var mt,pt,gt,vt,yt,At,_t,bt={};function wt(){if(pt)return mt;pt=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 gt;vt=1;var e=ye(),t=String,n=TypeError;return gt=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=lt(),a=TypeError,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,c="enumerable",u="configurable",l="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&&l in n&&!n[l]){var a=s(e,t);a&&a[l]&&(e[t]=n.value,n={configurable:u in n?n[u]:a[u],enumerable:c in n?n[c]:a[c],writable:!1})}return o(e,t,n)}:o:function(e,n,s){if(r(e),n=i(n),r(s),t)try{return o(e,n,s)}catch(e){}if("get"in s||"set"in s)throw new a("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=le();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,Pt,kt,Mt,Lt,Ot,Bt,Dt,Ut,Ft,Nt,jt,Wt={exports:{}};function zt(){if(It)return Ct;It=1;var e=y(),t=ot(),n=Function.prototype,r=e&&Object.getOwnPropertyDescriptor,i=t(n,"name"),a=i&&"something"===function(){}.name,o=i&&(!e||e&&r(n,"name").configurable);return Ct={EXISTS:i,PROPER:a,CONFIGURABLE:o}}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(Lt)return Mt;Lt=1;var e=it(),t=st(),n=e("keys");return Mt=function(e){return n[e]||(n[e]=t(e))}}function qt(){return Bt?Ot:(Bt=1,Ot={})}function Yt(){if(Ut)return Dt;Ut=1;var e,t,n,r=function(){if(kt)return Pt;kt=1;var e=s(),t=ve(),n=e.WeakMap;return Pt=t(n)&&/native code/.test(String(n))}(),i=s(),a=ye(),o=St(),c=ot(),u=rt(),l=Gt(),h=qt(),d="Object already initialized",f=i.TypeError,m=i.WeakMap;if(r||u.state){var p=u.state||(u.state=new m);p.get=p.get,p.has=p.has,p.set=p.set,e=function(e,t){if(p.has(e))throw new f(d);return t.facade=e,p.set(e,t),t},t=function(e){return p.get(e)||{}},n=function(e){return p.has(e)}}else{var g=l("state");h[g]=!0,e=function(e,t){if(c(e,g))throw new f(d);return t.facade=e,o(e,g,t),t},t=function(e){return c(e,g)?e[g]:{}},n=function(e){return c(e,g)}}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(!a(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=ot(),i=y(),a=zt().CONFIGURABLE,o=Ht(),s=Yt(),c=s.enforce,u=s.get,l=String,h=Object.defineProperty,d=e("".slice),f=e("".replace),m=e([].join),p=i&&!t(function(){return 8!==h(function(){},"length",{value:8}).length}),g=String(String).split("String"),A=Wt.exports=function(e,t,n){"Symbol("===d(l(t),0,7)&&(t="["+f(l(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!r(e,"name")||a&&e.name!==t)&&(i?h(e,"name",{value:t,configurable:!0}):e.name=t),p&&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 o=c(e);return r(o,"source")||(o.source=m(g,"string"==typeof t?t:"")),e};return Function.prototype.toString=A(function(){return n(this)&&u(this).source||o(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,a,o,s){s||(s={});var c=s.enumerable,u=void 0!==s.name?s.name:a;if(e(o)&&n(o,u,s),s.global)c?i[a]=o:r(a,o);else{try{s.unsafe?i[a]&&(c=!0):delete i[a]}catch(e){}c?i[a]=o:t.f(i,a,{value:o,enumerable:!1,configurable:!s.nonConfigurable,writable:!s.nonWritable})}return i}}var Qt,Jt,$t,Zt,Kt,en,tn,nn,rn,an,on,sn,cn,un,ln,hn,dn,fn={};function mn(){if(Zt)return $t;Zt=1;var e=function(){if(Jt)return Qt;Jt=1;var e=Math.ceil,t=Math.floor;return Qt=Math.trunc||function(n){var r=+n;return(r>0?t:e)(r)}}();return $t=function(t){var n=+t;return n!=n||0===n?0:e(n)}}function pn(){if(en)return Kt;en=1;var e=mn(),t=Math.max,n=Math.min;return Kt=function(r,i){var a=e(r);return a<0?t(a+i,0):n(a,i)}}function gn(){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(an)return rn;an=1;var e=gn();return rn=function(t){return e(t.length)}}function yn(){if(un)return cn;un=1;var e=he(),t=ot(),n=ge(),r=function(){if(sn)return on;sn=1;var e=ge(),t=pn(),n=vn(),r=function(r){return function(i,a,o){var s=e(i),c=n(s);if(0===c)return!r&&-1;var u,l=t(o,c);if(r&&a!=a){for(;c>l;)if((u=s[l++])!=u)return!0}else for(;c>l;l++)if((r||l in s)&&s[l]===a)return r||l||0;return!r&&-1}};return on={includes:r(!0),indexOf:r(!1)}}().indexOf,i=qt(),a=e([].push);return cn=function(e,o){var s,c=n(e),u=0,l=[];for(s in c)!t(i,s)&&t(c,s)&&a(l,s);for(;o.length>u;)t(c,s=o[u++])&&(~r(l,s)||a(l,s));return l}}function An(){return hn?ln:(hn=1,ln=["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,Pn,kn,Mn,Ln,On,Bn,Dn,Un,Fn,Nn,jn,Wn,zn,Hn,Gn,qn,Yn,Vn,Xn,Qn,Jn,$n,Zn,Kn,er,tr,nr,rr,ir,ar,or,sr,cr,ur={};function lr(){return bn||(bn=1,ur.f=Object.getOwnPropertySymbols),ur}function hr(){if(En)return wn;En=1;var e=Ae(),t=he(),n=_n(),r=lr(),i=Et(),a=t([].concat);return wn=e("Reflect","ownKeys")||function(e){var t=n.f(i(e)),o=r.f;return o?a(t,o(e)):t}}function dr(){if(Sn)return xn;Sn=1;var e=ot(),t=hr(),n=ft(),r=xt();return xn=function(i,a,o){for(var s=t(a),c=r.f,u=n.f,l=0;ly&&u(a,arguments[y]),a});if(x.prototype=w,"Error"!==_?i?i(x,E):a(x,E,{name:!0}):h&&v in b&&(o(x,b,v),o(x,b,"prepareStackTrace")),a(x,b),!d)try{w.name!==_&&n(w,"name",_),w.constructor=x}catch(e){}return x}},or}!function(){if(cr)return o;cr=1;var e=mr(),t=s(),n=pr(),r=Tr(),i="WebAssembly",a=t[i],c=7!==new Error("e",{cause:7}).cause,u=function(t,n){var i={};i[t]=r(t,n,c),e({global:!0,constructor:!0,arity:1,forced:c},i)},l=function(t,n){if(a&&a[t]){var o={};o[t]=r(i+"."+t,n,c),e({target:i,stat:!0,constructor:!0,arity:1,forced:c},o)}};u("Error",function(e){return function(t){return n(e,this,arguments)}}),u("EvalError",function(e){return function(t){return n(e,this,arguments)}}),u("RangeError",function(e){return function(t){return n(e,this,arguments)}}),u("ReferenceError",function(e){return function(t){return n(e,this,arguments)}}),u("SyntaxError",function(e){return function(t){return n(e,this,arguments)}}),u("TypeError",function(e){return function(t){return n(e,this,arguments)}}),u("URIError",function(e){return function(t){return n(e,this,arguments)}}),l("CompileError",function(e){return function(t){return n(e,this,arguments)}}),l("LinkError",function(e){return function(t){return n(e,this,arguments)}}),l("RuntimeError",function(e){return function(t){return n(e,this,arguments)}})}();var Rr,Pr,kr,Mr,Lr,Or,Br,Dr,Ur,Fr,Nr,jr,Wr,zr,Hr,Gr,qr,Yr={};function Vr(){if(Pr)return Rr;Pr=1;var e=de();return Rr=Array.isArray||function(t){return"Array"===e(t)}}function Xr(){if(Mr)return kr;Mr=1;var e=TypeError;return kr=function(t){if(t>9007199254740991)throw e("Maximum allowed index exceeded");return t}}function Qr(){if(Or)return Lr;Or=1;var e=de(),t=he();return Lr=function(n){if("Function"===e(n))return t(n)}}function Jr(){if(Dr)return Br;Dr=1;var e=Qr(),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 $r(){if(Fr)return Ur;Fr=1;var e=Vr(),t=vn(),n=Xr(),r=Jr(),i=function(a,o,s,c,u,l,h,d){for(var f,m,p=u,g=0,v=!!h&&r(h,d);g0&&e(f)?(m=t(f),p=i(a,o,f,m,p,l-1)-1):(n(p+1),a[p]=f),p++),g++;return p};return Ur=i}function Zr(){if(jr)return Nr;jr=1;var e=he(),t=v(),n=ve(),r=wr(),i=Ae(),a=Ht(),o=function(){},s=i("Reflect","construct"),c=/^\s*(?:class|function)\b/,u=e(c.exec),l=!c.test(o),h=function(e){if(!n(e))return!1;try{return s(o,[],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 l||!!u(c,a(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 Kr(){if(zr)return Wr;zr=1;var e=Vr(),t=Zr(),n=ye(),r=ct()("species"),i=Array;return Wr=function(a){var o;return e(a)&&(o=a.constructor,(t(o)&&(o===i||e(o.prototype))||n(o)&&null===(o=o[r]))&&(o=void 0)),void 0===o?i:o}}function ei(){if(Gr)return Hr;Gr=1;var e=Kr();return Hr=function(t,n){return new(e(t))(0===n?0:n)}}!function(){if(qr)return Yr;qr=1;var e=mr(),t=$r(),n=at(),r=vn(),i=mn(),a=ei();e({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,o=n(this),s=r(o),c=a(o,0);return c.length=t(c,o,o,s,0,void 0===e?1:i(e)),c}})}();var ti,ni={};!function(){if(ti)return ni;ti=1;var e=mr(),t=$r(),n=Ie(),r=at(),i=vn(),a=ei();e({target:"Array",proto:!0},{flatMap:function(e){var o,s=r(this),c=i(s);return n(e),(o=a(s,0)).length=t(o,s,s,c,0,1,e,arguments.length>1?arguments[1]:void 0),o}})}();var ri,ii,ai,oi={};!function(){if(ai)return oi;ai=1;var e=mr(),t=at(),n=vn(),r=function(){if(ii)return ri;ii=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 ri=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 a=t(this),o=n(a),s=arguments.length;i(o+s);for(var c=0;c0;)r[s]=r[--s];s!==c++&&(r[s]=o)}else for(var u=t(a/2),l=n(e(r,0,u),i),h=n(e(r,u),i),d=l.length,f=h.length,m=0,p=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;ro(n)?1:-1}}(e)),s=i(l),u=0;ul;)n.f(e,o=c[l++],s[o]);return e},ji}(),r=An(),i=qt(),a=zi(),o=ht(),s=Gt(),c="prototype",u="script",l=s("IE_PROTO"),h=function(){},d=function(e){return"<"+u+">"+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=o("iframe"),i="java"+u+":",n.style.display="none",a.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[l]=!0,Bi=Object.create||function(e,r){var i;return null!==e?(h[c]=t(e),i=new h,h[c]=null,i[l]=e):i=m(),void 0===r?i:n.f(i,r)}}function Gi(){if(Fi)return Ui;Fi=1;var e=ct(),t=Hi(),n=xt().f,r=e("unscopables"),i=Array.prototype;return void 0===i[r]&&n(i,r,{configurable:!0,value:t(null)}),Ui=function(e){i[r][e]=!0}}Ni||(Ni=1,Gi()("flat"));var qi;qi||(qi=1,Gi()("flatMap"));var Yi,Vi,Xi,Qi,Ji,$i,Zi,Ki,ea,ta,na,ra,ia,aa,oa,sa,ca,ua,la,ha,da,fa,ma,pa,ga,va,ya,Aa,_a,ba,wa,Ea,xa,Sa={};function Ca(){return Vi?Yi:(Vi=1,Yi="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView)}function Ia(){if(Qi)return Xi;Qi=1;var e=Vt(),t=xt();return Xi=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 Ta(){if($i)return Ji;$i=1;var e=Xt();return Ji=function(t,n,r){for(var i in n)e(t,i,n[i],r);return t}}function Ra(){if(Ki)return Zi;Ki=1;var e=_e(),t=TypeError;return Zi=function(n,r){if(e(r,n))return n;throw new t("Incorrect invocation")}}function Pa(){if(ta)return ea;ta=1;var e=mn(),t=gn(),n=RangeError;return ea=function(r){if(void 0===r)return 0;var i=e(r),a=t(i);if(i!==a)throw new n("Wrong length or index");return a}}function ka(){if(sa)return oa;sa=1;var e=ra?na:(ra=1,na=Math.sign||function(e){var t=+e;return 0===t||t!=t?t:t<0?-1:1}),t=function(){if(aa)return ia;aa=1;var e=4503599627370496;return ia=function(t){return t+e-e}}(),n=Math.abs;return oa=function(r,i,a,o){var s=+r,c=n(s),u=e(s);if(ca||h!=h?u*(1/0):u*h}}function Ma(){if(ha)return la;ha=1;var e=Array,t=Math.abs,n=Math.pow,r=Math.floor,i=Math.log,a=Math.LN2;return la={pack:function(o,s,c){var u,l,h,d=e(c),f=8*c-s-1,m=(1<>1,g=23===s?n(2,-24)-n(2,-77):0,v=o<0||0===o&&1/o<0?1:0,y=0;for((o=t(o))!=o||o===1/0?(l=o!=o?1:0,u=m):(u=r(i(o)/a),o*(h=n(2,-u))<1&&(u--,h*=2),(o+=u+p>=1?g/h:g*n(2,1-p))*h>=2&&(u++,h/=2),u+p>=m?(l=0,u=m):u+p>=1?(l=(o*h-1)*n(2,s),u+=p):(l=o*n(2,p-1)*n(2,s),u=0));s>=8;)d[y++]=255&l,l/=256,s-=8;for(u=u<0;)d[y++]=255&u,u/=256,f-=8;return d[y-1]|=128*v,d},unpack:function(e,t){var r,i=e.length,a=8*i-t-1,o=(1<>1,c=a-7,u=i-1,l=e[u--],h=127&l;for(l>>=7;c>0;)h=256*h+e[u--],c-=8;for(r=h&(1<<-c)-1,h>>=-c,c+=t;c>0;)r=256*r+e[u--],c-=8;if(0===h)h=1-s;else{if(h===o)return r?NaN:l?-1/0:1/0;r+=n(2,t),h-=s}return(l?-1:1)*r*n(2,h-t)}}}function La(){if(pa)return ma;pa=1;var e=ot(),t=ve(),n=at(),r=Gt(),i=function(){if(fa)return da;fa=1;var e=v();return da=!e(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})}(),a=r("IE_PROTO"),o=Object,s=o.prototype;return ma=i?o.getPrototypeOf:function(r){var i=n(r);if(e(i,a))return i[a];var c=i.constructor;return t(c)&&i instanceof c?c.prototype:i instanceof o?s:null}}function Oa(){if(va)return ga;va=1;var e=at(),t=pn(),n=vn();return ga=function(r){for(var i=e(this),a=n(i),o=arguments.length,s=t(o>1?arguments[1]:void 0,a),c=o>2?arguments[2]:void 0,u=void 0===c?a:t(c,a);u>s;)i[s++]=r;return i},ga}function Ba(){if(Aa)return ya;Aa=1;var e=xt().f,t=ot(),n=ct()("toStringTag");return ya=function(r,i,a){r&&!a&&(r=r.prototype),r&&!t(r,n)&&e(r,n,{configurable:!0,value:i})}}function Da(){if(ba)return _a;ba=1;var e=s(),t=he(),n=y(),r=Ca(),i=zt(),a=St(),o=Ia(),c=Ta(),u=v(),l=Ra(),h=mn(),d=gn(),f=Pa(),m=function(){if(ua)return ca;ua=1;var e=ka();return ca=Math.fround||function(t){return e(t,1.1920928955078125e-7,34028234663852886e22,11754943508222875e-54)}}(),p=Ma(),g=La(),A=Ar(),_=Oa(),b=xi(),w=br(),E=dr(),x=Ba(),S=Yt(),C=i.PROPER,I=i.CONFIGURABLE,T="ArrayBuffer",R="DataView",P="prototype",k="Wrong index",M=S.getterFor(T),L=S.getterFor(R),O=S.set,B=e[T],D=B,U=D&&D[P],F=e[R],N=F&&F[P],j=Object.prototype,W=e.Array,z=e.RangeError,H=t(_),G=t([].reverse),q=p.pack,Y=p.unpack,V=function(e){return[255&e]},X=function(e){return[255&e,e>>8&255]},Q=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]},$=function(e){return q(m(e),23,4)},Z=function(e){return q(e,52,8)},K=function(e,t,n){o(e[P],t,{configurable:!0,get:function(){return n(this)[t]}})},ee=function(e,t,n,r){var i=L(e),a=f(n),o=!!r;if(a+t>i.byteLength)throw new z(k);var s=i.bytes,c=a+i.byteOffset,u=b(s,c,c+t);return o?u:G(u)},te=function(e,t,n,r,i,a){var o=L(e),s=f(n),c=r(+i),u=!!a;if(s+t>o.byteLength)throw new z(k);for(var l=o.bytes,h=s+o.byteOffset,d=0;d>24)},setUint8:function(e,t){ie(this,e,t<<24>>24)}},{unsafe:!0})}else U=(D=function(e){l(this,U);var t=f(e);O(this,{type:T,bytes:H(W(t),0),byteLength:t}),n||(this.byteLength=t,this.detached=!1)})[P],N=(F=function(e,t,r){l(this,N),l(e,U);var i=M(e),a=i.byteLength,o=h(t);if(o<0||o>a)throw new z("Wrong offset");if(o+(r=void 0===r?a-o:d(r))>a)throw new z("Wrong length");O(this,{type:R,buffer:e,byteLength:r,byteOffset:o,bytes:i.bytes}),n||(this.buffer=e,this.byteLength=r,this.byteOffset=o)})[P],n&&(K(D,"byteLength",M),K(F,"buffer",L),K(F,"byteLength",L),K(F,"byteOffset",L)),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,Q,t,arguments.length>2&&arguments[2])},setUint32:function(e,t){te(this,4,e,Q,t,arguments.length>2&&arguments[2])},setFloat32:function(e,t){te(this,4,e,$,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),_a={ArrayBuffer:D,DataView:F}}function Ua(){if(Ea)return wa;Ea=1;var e=Ae(),t=Ia(),n=ct(),r=y(),i=n("species");return wa=function(n){var a=e(n);r&&a&&!a[i]&&t(a,i,{configurable:!0,get:function(){return this}})}}!function(){if(xa)return Sa;xa=1;var e=mr(),t=s(),n=Da(),r=Ua(),i="ArrayBuffer",a=n[i];e({global:!0,constructor:!0,forced:t[i]!==a},{ArrayBuffer:a}),r(i)}();var Fa,Na={};!function(){if(Fa)return Na;Fa=1;var e=mr(),t=Qr(),n=v(),r=Da(),i=Et(),a=pn(),o=gn(),s=r.ArrayBuffer,c=r.DataView,u=c.prototype,l=t(s.prototype.slice),h=t(u.getUint8),d=t(u.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(l&&void 0===t)return l(i(this),e);for(var n=i(this).byteLength,r=a(e,n),u=a(void 0===t?n:t,n),f=new s(o(u-r)),m=new c(this),p=new c(f),g=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 mo(){if(ao)return io;ao=1;var e,t,n,r,i=s(),a=ho(),o=fo(),c=i.structuredClone,u=i.ArrayBuffer,l=i.MessageChannel,h=!1;if(o)h=function(e){c(e,{transfer:[e]})};else if(u)try{l||(e=a("worker_threads"))&&(l=e.MessageChannel),l&&(t=new l,n=new u(2),r=function(e){t.port1.postMessage(null,[e])},2===n.byteLength&&(r(n),0===n.byteLength&&(h=r)))}catch(e){}return io=h}function po(){if(so)return oo;so=1;var e=s(),t=he(),n=gr(),r=Pa(),i=function(){if(Qa)return Xa;Qa=1;var e=Va(),t=TypeError;return Xa=function(n){if(e(n))throw new t("ArrayBuffer is detached");return n}}(),a=Ya(),o=mo(),c=fo(),u=e.structuredClone,l=e.ArrayBuffer,h=e.DataView,d=Math.min,f=l.prototype,m=h.prototype,p=t(f.slice),g=n(f,"resizable","get"),v=n(f,"maxByteLength","get"),y=t(m.getInt8),A=t(m.setInt8);return oo=(c||o)&&function(e,t,n){var s,f=a(e),m=void 0===t?f:r(t),_=!g||!g(e);if(i(e),c&&(e=u(e,{transfer:[e]}),f===m&&(n||_)))return e;if(f>=m&&(!n||_))s=p(e,0,m);else{var b=n&&!_&&v?{maxByteLength:v(e)}:void 0;s=new l(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 Xo(){if(Bo)return Oo;Bo=1;var e=_(),t=Hi(),n=St(),r=Ta(),i=ct(),a=Yt(),o=Te(),s=So().IteratorPrototype,c=qo(),u=Yo(),l=Vo(),h=i("toStringTag"),d="IteratorHelper",f="WrapForValidIterator",m="normal",p="throw",g=a.set,v=function(n){var i=a.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 a=o(r,"return");return a?e(a,r):c(void 0,!0)}if(t.inner)try{u(t.inner.iterator,m)}catch(e){return u(r,p,e)}if(t.openIters)try{l(t.openIters,m)}catch(e){return u(r,p,e)}return r&&u(r,m),c(void 0,!0)}})},y=v(!0),A=v(!1);return n(A,h,"Iterator Helper"),Oo=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,g(this,i)};return r.prototype=t?y:A,r}}function Qo(){if(Uo)return Do;Uo=1;var e=Et(),t=Yo();return Do=function(n,r,i,a){try{return a?r(e(i)[0],i[1]):r(i)}catch(e){t(n,"throw",e)}}}function Jo(){return No?Fo:(No=1,Fo=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 $o(){if(Wo)return jo;Wo=1;var e=s();return jo=function(t,n){var r=e.Iterator,i=r&&r.prototype,a=i&&i[t],o=!1;if(a)try{a.call({next:function(){return{done:!0}},return:function(){o=!0}},-1)}catch(e){e instanceof n||(o=!1)}if(!o)return a}}!function(){if(zo)return Ho;zo=1;var e=mr(),t=_(),n=Ie(),r=Et(),i=Go(),a=Xo(),o=Qo(),s=tt(),c=Yo(),u=Jo(),l=$o(),h=!s&&!u("filter",function(){}),d=!s&&!h&&l("filter",TypeError),f=s||h||d,m=a(function(){for(var e,n,i=this.iterator,a=this.predicate,s=this.next;;){if(e=r(t(s,i)),this.done=!!e.done)return;if(n=e.value,o(i,a,[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 Zo,Ko,es,ts,ns,rs,is,as,os,ss,cs,us={};function ls(){return Ko?Zo:(Ko=1,Zo={})}function hs(){if(ts)return es;ts=1;var e=ct(),t=ls(),n=e("iterator"),r=Array.prototype;return es=function(e){return void 0!==e&&(t.Array===e||r[n]===e)}}function ds(){if(rs)return ns;rs=1;var e=wr(),t=Te(),n=me(),r=ls(),i=ct()("iterator");return ns=function(a){if(!n(a))return t(a,i)||t(a,"@@iterator")||r[e(a)]}}function fs(){if(as)return is;as=1;var e=_(),t=Ie(),n=Et(),r=Ce(),i=ds(),a=TypeError;return is=function(o,s){var c=arguments.length<2?i(o):s;if(t(c))return n(e(c,o));throw new a(r(o)+" is not iterable")},is}function ms(){if(ss)return os;ss=1;var e=Jr(),t=_(),n=Et(),r=Ce(),i=hs(),a=vn(),o=_e(),s=fs(),c=ds(),u=Yo(),l=TypeError,h=function(e,t){this.stopped=e,this.result=t},d=h.prototype;return os=function(f,m,p){var g,v,y,A,_,b,w,E=p&&p.that,x=!(!p||!p.AS_ENTRIES),S=!(!p||!p.IS_RECORD),C=!(!p||!p.IS_ITERATOR),I=!(!p||!p.INTERRUPTED),T=e(m,E),R=function(e){return g&&u(g,"normal"),new h(!0,e)},P=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)g=f.iterator;else if(C)g=f;else{if(!(v=c(f)))throw new l(r(f)+" is not iterable");if(i(v)){for(y=0,A=a(f);A>y;y++)if((_=P(f[y]))&&o(d,_))return _;return new h(!1)}g=s(f,v)}for(b=S?f.next:g.next;!(w=t(b,g)).done;){try{_=P(w.value)}catch(e){u(g,"throw",e)}if("object"==typeof _&&_&&o(d,_))return _}return new h(!1)}}!function(){if(cs)return us;cs=1;var e=mr(),t=_(),n=ms(),r=Ie(),i=Et(),a=Go(),o=Yo(),s=$o()("find",TypeError);e({target:"Iterator",proto:!0,real:!0,forced:s},{find:function(e){i(this);try{r(e)}catch(e){o(this,"throw",e)}if(s)return t(s,this,e);var c=a(this),u=0;return n(c,function(t,n){if(e(t,u++))return n(t)},{IS_RECORD:!0,INTERRUPTED:!0}).result}})}();var ps,gs,vs,ys={};function As(){if(gs)return ps;gs=1;var e=_(),t=Et(),n=Go(),r=ds();return ps=function(i,a){a&&"string"==typeof i||t(i);var o=r(i);return n(t(void 0!==o?e(o,i):i))}}!function(){if(vs)return ys;vs=1;var e=mr(),t=_(),n=Ie(),r=Et(),i=Go(),a=As(),o=Xo(),s=Yo(),c=tt(),u=Jo(),l=$o(),h=!c&&!u("flatMap",function(){}),d=!c&&!h&&l("flatMap",TypeError),f=c||h||d,m=o(function(){for(var e,n,i=this.iterator,o=this.mapper;;){if(n=this.inner)try{if(!(e=r(t(n.next,n.iterator))).done)return e.value;this.inner=null}catch(e){s(i,"throw",e)}if(e=r(t(this.next,i)),this.done=!!e.done)return;try{this.inner=a(o(e.value,this.counter++),!1)}catch(e){s(i,"throw",e)}}});e({target:"Iterator",proto:!0,real:!0,forced:f},{flatMap: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,inner:null})}})}();var _s,bs={};!function(){if(_s)return bs;_s=1;var e=mr(),t=_(),n=ms(),r=Ie(),i=Et(),a=Go(),o=Yo(),s=$o()("forEach",TypeError);e({target:"Iterator",proto:!0,real:!0,forced:s},{forEach:function(e){i(this);try{r(e)}catch(e){o(this,"throw",e)}if(s)return t(s,this,e);var c=a(this),u=0;n(c,function(t){e(t,u++)},{IS_RECORD:!0})}})}();var ws,Es={};!function(){if(ws)return Es;ws=1;var e=mr(),t=_(),n=Ie(),r=Et(),i=Go(),a=Xo(),o=Qo(),s=Yo(),c=Jo(),u=$o(),l=tt(),h=!l&&!c("map",function(){}),d=!l&&!h&&u("map",TypeError),f=l||h||d,m=a(function(){var e=this.iterator,n=r(t(this.next,e));if(!(this.done=!!n.done))return o(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 xs,Ss,Cs,Is={};!function(){if(Cs)return Is;Cs=1;var e=mr(),t=Ae(),n=pr(),r=_(),i=he(),a=v(),o=ve(),s=Se(),c=xi(),u=function(){if(Ss)return xs;Ss=1;var e=he(),t=Vr(),n=ve(),r=de(),i=Er(),a=e([].push);return xs=function(e){if(n(e))return e;if(t(e)){for(var o=e.length,s=[],c=0;cb)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$c")})}!function(){if(Gs)return qs;Gs=1;var e=y(),t=s(),n=he(),r=fr(),i=br(),a=St(),o=Hi(),c=_n().f,u=_e(),l=function(){if(ks)return Ps;ks=1;var e=ye(),t=de(),n=ct()("match");return Ps=function(r){var i;return e(r)&&(void 0!==(i=r[n])?!!i:"RegExp"===t(r))}}(),h=Er(),d=Vs(),f=Xs(),m=_r(),p=Xt(),g=v(),A=ot(),_=Yt().enforce,b=Ua(),w=ct(),E=Qs(),x=Js(),S=w("match"),C=t.RegExp,I=C.prototype,T=t.SyntaxError,R=n(I.exec),P=n("".charAt),k=n("".replace),M=n("".indexOf),L=n("".slice),O=/^\?<[^\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||g(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,p=u(I,this),g=l(e),v=void 0===t,y=[],b=e;if(!p&&g&&v&&e.constructor===W)return e;if((g||u(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&&M(t,"s")>-1)&&(t=k(t,/s/g,"")),n=t,F&&"sticky"in B&&(s=!!t&&M(t,"y")>-1)&&N&&(t=k(t,/y/g,"")),x&&(c=function(e){for(var t,n=e.length,r=0,i="",a=[],s=o(null),c=!1,u=!1,l=0,h="";r<=n;r++){if("\\"===(t=P(e,r)))t+=P(e,++r);else if("]"===t)c=!1;else if(!c)switch(!0){case"["===t:c=!0;break;case"("===t:if(i+=t,"?:"===L(e,r+1,r+3))continue;R(O,L(e,r+1))&&(r+=2,u=!0),l++;continue;case">"===t&&u:if(""===h||A(s,h))throw new T("Invalid capture group name");s[h]=!0,a[a.length]=[h,l],u=!1,h="";continue}u?h+=t:i+=t}return[i,a]}(e),e=c[0],y=c[1]),f=i(C(e,t),p?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="",a=!1;r<=n;r++)"\\"!==(t=P(e,r))?a||"."!==t?("["===t?a=!0:"]"===t&&(a=!1),i+=t):i+="[\\s\\S]":i+=t+P(e,++r);return i}(e),n)),s&&(m.sticky=!0),y.length&&(m.groups=y)),e!==b)try{a(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,p(t,"RegExp",W,{constructor:!0})}b("RegExp")}();var $s,Zs={};!function(){if($s)return Zs;$s=1;var e=y(),t=Qs(),n=de(),r=Ia(),i=Yt().get,a=RegExp.prototype,o=TypeError;e&&t&&r(a,"dotAll",{configurable:!0,get:function(){if(this!==a){if("RegExp"===n(this))return!!i(this).dotAll;throw new o("Incompatible receiver, RegExp required")}}})}();var Ks,ec,tc,nc={};function rc(){if(ec)return Ks;ec=1;var e,t,n=_(),r=he(),i=Er(),a=Ys(),o=Xs(),s=it(),c=Hi(),u=Yt().get,l=Qs(),h=Js(),d=s("native-string-replace",String.prototype.replace),f=RegExp.prototype.exec,m=f,p=r("".charAt),g=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=o.BROKEN_CARET,w=void 0!==/()??/.exec("")[1];return(A||w||b||l||h)&&(m=function(e){var t,r,o,s,l,h,_,E=this,x=u(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(a,E),P=E.source,k=0,M=S;if(T&&(R=v(R,"y",""),-1===g(R,"g")&&(R+="g"),M=y(S,E.lastIndex),E.lastIndex>0&&(!E.multiline||E.multiline&&"\n"!==p(S,E.lastIndex-1))&&(P="(?: "+P+")",M=" "+M,k++),r=new RegExp("^(?:"+P+")",R)),w&&(r=new RegExp("^"+P+"$(?!\\s)",R)),A&&(o=E.lastIndex),s=n(f,T?r:E,M),T?s?(s.input=y(s.input,k),s[0]=y(s[0],k),s.index=E.lastIndex,E.lastIndex+=s[0].length):E.lastIndex=0:A&&s&&(E.lastIndex=E.global?s.index+s[0].length:o),w&&s&&s.length>1&&n(d,s[0],r,function(){for(l=1;l=f?e?"":void 0:(u=a(h,d))<55296||u>56319||d+1===f||(l=a(h,d+1))<56320||l>57343?e?i(h,d):u:e?o(h,d,d+2):l-56320+(u-55296<<10)+65536}};return sc={codeAt:s(!1),charAt:s(!0)}}function yc(){if(lc)return uc;lc=1;var e=vc().charAt;return uc=function(t,n,r){return n+(r?e(t,n).length:1)}}function Ac(){if(dc)return hc;dc=1;var e=he(),t=at(),n=Math.floor,r=e("".charAt),i=e("".replace),a=e("".slice),o=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,s=/\$([$&'`]|\d{1,2})/g;return hc=function(e,c,u,l,h,d){var f=u+e.length,m=l.length,p=s;return void 0!==h&&(h=t(h),p=o),i(d,p,function(t,i){var o;switch(r(i,0)){case"$":return"$";case"&":return e;case"`":return a(c,0,u);case"'":return a(c,f);case"<":o=h[a(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===l[d-1]?r(i,1):l[d-1]+r(i,1):t}o=l[s-1]}return void 0===o?"":o})}}!function(){if(pc)return gc;pc=1;var e=pr(),t=_(),n=he(),r=function(){if(oc)return ac;oc=1,ic();var e=_(),t=Xt(),n=rc(),r=v(),i=ct(),a=St(),o=i("species"),s=RegExp.prototype;return ac=function(c,u,l,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[o]=function(){return t},t.flags="",t[d]=/./[d]),t.exec=function(){return e=!0,null},t[d](""),!e});if(!f||!m||l){var p=/./[d],g=u(d,""[c],function(t,r,i,a,o){var c=r.exec;return c===n||c===s.exec?f&&!o?{done:!0,value:e(p,r,i,a)}:{done:!0,value:e(t,i,r,a)}:{done:!1}});t(String.prototype,c,g[0]),t(s,d,g[1])}h&&a(s[d],"sham",!0)}}(),i=v(),a=Et(),o=ve(),s=ye(),c=mn(),u=gn(),l=Er(),h=pe(),d=yc(),f=Te(),m=Ac(),p=Vs(),g=function(){if(mc)return fc;mc=1;var e=_(),t=Et(),n=ve(),r=de(),i=rc(),a=TypeError;return fc=function(o,s){var c=o.exec;if(n(c)){var u=e(c,o,s);return null!==u&&t(u),u}if("RegExp"===r(o))return e(i,o,s);throw new a("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),a=s(e)?f(e,y):void 0;return a?t(a,e,i,n):t(r,l(i),e,n)},function(t,n){var s=a(this),h=l(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=o(n);y||(n=l(n));var _,I=l(p(s)),T=-1!==x(I,"g");T&&(_=-1!==x(I,"u"),s.lastIndex=0);for(var R,P=[];null!==(R=g(s,h))&&(E(P,R),T);){""===l(R[0])&&(s.lastIndex=d(h,u(s.lastIndex),_))}for(var k="",M=0,L=0;L=M&&(k+=S(h,M,D)+O,M=D+B.length)}return k+S(h,M)}]},!!i(function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$")})||!I||T)}();var _c,bc,wc,Ec,xc,Sc,Cc,Ic={};function Tc(){return bc?_c:(bc=1,_c="\t\n\v\f\r                 \u2028\u2029\ufeff")}!function(){if(Cc)return Ic;Cc=1;var e=mr(),t=function(){if(Ec)return wc;Ec=1;var e=he(),t=pe(),n=Er(),r=Tc(),i=e("".replace),a=RegExp("^["+r+"]+"),o=RegExp("(^|[^"+r+"])["+r+"]+$"),s=function(e){return function(r){var s=n(t(r));return 1&e&&(s=i(s,a,"")),2&e&&(s=i(s,o,"$1")),s}};return wc={start:s(1),end:s(2),trim:s(3)}}().trim,n=function(){if(Sc)return xc;Sc=1;var e=zt().PROPER,t=v(),n=Tc();return xc=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 Rc,Pc,kc,Mc,Lc,Oc,Bc,Dc,Uc,Fc,Nc,jc,Wc,zc,Hc,Gc,qc,Yc,Vc,Xc,Qc,Jc,$c,Zc,Kc,eu,tu,nu,ru={exports:{}};function iu(){if(Pc)return Rc;Pc=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 Rc=function(n,r){try{if(!r&&!t)return!1}catch(e){return!1}var i=!1;try{var a={};a[e]=function(){return{next:function(){return{done:i=!0}}}},n(a)}catch(e){}return i}}function au(){if(Mc)return kc;Mc=1;var e,t,n,r=Ca(),i=y(),a=s(),o=ve(),c=ye(),u=ot(),l=wr(),h=Ce(),d=St(),f=Xt(),m=Ia(),p=_e(),g=La(),v=Ar(),A=ct(),_=st(),b=Yt(),w=b.enforce,E=b.get,x=a.Int8Array,S=x&&x.prototype,C=a.Uint8ClampedArray,I=C&&C.prototype,T=x&&g(x),R=S&&g(S),P=Object.prototype,k=a.TypeError,M=A("toStringTag"),L=_("TYPED_ARRAY_TAG"),O="TypedArrayConstructor",B=r&&!!v&&"Opera"!==l(a.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=g(e);if(c(t)){var n=E(t);return n&&u(n,O)?n[O]:N(t)}},j=function(e){if(!c(e))return!1;var t=l(e);return u(U,t)||u(F,t)};for(e in U)(n=(t=a[e])&&t.prototype)?w(n)[O]=t:B=!1;for(e in F)(n=(t=a[e])&&t.prototype)&&(w(n)[O]=t);if((!B||!o(T)||T===Function.prototype)&&(T=function(){throw new k("Incorrect invocation")},B))for(e in U)a[e]&&v(a[e],T);if((!B||!R||R===P)&&(R=T.prototype,B))for(e in U)a[e]&&v(a[e].prototype,R);if(B&&g(I)!==R&&v(I,R),i&&!u(R,M))for(e in D=!0,m(R,M,{configurable:!0,get:function(){return c(this)?this[L]:void 0}}),U)a[e]&&d(a[e],L,e);return kc={NATIVE_ARRAY_BUFFER_VIEWS:B,TYPED_ARRAY_TAG:D&&L,aTypedArray:function(e){if(j(e))return e;throw new k("Target is not a typed array")},aTypedArrayConstructor:function(e){if(o(e)&&(!v||p(T,e)))return e;throw new k(h(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,r){if(i){if(n)for(var o in U){var s=a[o];if(s&&u(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,o;if(i){if(v){if(n)for(r in U)if((o=a[r])&&u(o,e))try{delete o[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)!(o=a[r])||o[e]&&!n||f(o,e,t)}},getTypedArrayConstructor:N,isView:function(e){if(!c(e))return!1;var t=l(e);return"DataView"===t||u(U,t)||u(F,t)},isTypedArray:j,TypedArray:T,TypedArrayPrototype:R}}function ou(){if(Dc)return Bc;Dc=1;var e=ye(),t=Math.floor;return Bc=Number.isInteger||function(n){return!e(n)&&isFinite(n)&&t(n)===n}}function su(){if(Fc)return Uc;Fc=1;var e=mn(),t=RangeError;return Uc=function(n){var r=e(n);if(r<0)throw new t("The argument can't be less than 0");return r}}function cu(){if(jc)return Nc;jc=1;var e=su(),t=RangeError;return Nc=function(n,r){var i=e(n);if(i%r)throw new t("Wrong offset");return i}}function uu(){if(zc)return Wc;zc=1;var e=Math.round;return Wc=function(t){var n=e(t);return n<0?0:n>255?255:255&n}}function lu(){if(Gc)return Hc;Gc=1;var e=Zr(),t=Ce(),n=TypeError;return Hc=function(r){if(e(r))return r;throw new n(t(r)+" is not a constructor")}}function hu(){if(Yc)return qc;Yc=1;var e=wr();return qc=function(t){var n=e(t);return"BigInt64Array"===n||"BigUint64Array"===n}}function du(){if(Xc)return Vc;Xc=1;var e=ut(),t=TypeError;return Vc=function(n){var r=e(n,"number");if("number"==typeof r)throw new t("Can't convert number to bigint");return BigInt(r)}}function fu(){if(Jc)return Qc;Jc=1;var e=Jr(),t=_(),n=lu(),r=at(),i=vn(),a=fs(),o=ds(),s=hs(),c=hu(),u=au().aTypedArrayConstructor,l=du();return Qc=function(h){var d,f,m,p,g,v,y,A,_=n(this),b=r(h),w=arguments.length,E=w>1?arguments[1]:void 0,x=void 0!==E,S=o(b);if(S&&!s(S))for(A=(y=a(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(u(_))(f),p=c(m),d=0;f>d;d++)g=x?E(b[d],d):b[d],m[d]=p?l(g):+g;return m},Qc}function mu(){if(eu)return Kc;eu=1;var e=vn();return Kc=function(t,n,r){for(var i=0,a=arguments.length>2?r:e(n),o=new t(a);a>i;)o[i]=n[i++];return o},Kc}function pu(){if(tu)return ru.exports;tu=1;var e=mr(),t=s(),n=_(),r=y(),i=function(){if(Oc)return Lc;Oc=1;var e=s(),t=v(),n=iu(),r=au().NATIVE_ARRAY_BUFFER_VIEWS,i=e.ArrayBuffer,a=e.Int8Array;return Lc=!r||!t(function(){a(1)})||!t(function(){new a(-1)})||!n(function(e){new a,new a(null),new a(1.5),new a(e)},!0)||t(function(){return 1!==new a(new i(2),1,void 0).length})}(),a=au(),o=Da(),c=Ra(),u=le(),l=St(),h=ou(),d=gn(),f=Pa(),m=cu(),p=uu(),g=lt(),A=ot(),b=wr(),w=ye(),E=Se(),x=Hi(),S=_e(),C=Ar(),I=_n().f,T=fu(),R=function(){if(Zc)return $c;Zc=1;var e=Jr(),t=he(),n=fe(),r=at(),i=vn(),a=ei(),o=t([].push),s=function(t){var s=1===t,c=2===t,u=3===t,l=4===t,h=6===t,d=7===t,f=5===t||h;return function(m,p,g,v){for(var y,A,_=r(m),b=n(_),w=i(b),E=e(p,g),x=0,S=v||a,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:o(C,y)}else switch(t){case 4:return!1;case 7:o(C,y)}return h?-1:u||l?l:C}};return $c={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,P=Ua(),k=Ia(),M=xt(),L=ft(),O=mu(),B=Yt(),D=br(),U=B.get,F=B.set,N=B.enforce,j=M.f,W=L.f,z=t.RangeError,H=o.ArrayBuffer,G=H.prototype,q=o.DataView,Y=a.NATIVE_ARRAY_BUFFER_VIEWS,V=a.TYPED_ARRAY_TAG,X=a.TypedArray,Q=a.TypedArrayPrototype,J=a.isTypedArray,$="BYTES_PER_ELEMENT",Z="Wrong length",K=function(e,t){k(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=g(t),te(e,t)?u(2,e[t]):W(e,t)},re=function(e,t,n){return t=g(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||(L.f=ne,M.f=re,K(Q,"buffer"),K(Q,"byteOffset"),K(Q,"byteLength"),K(Q,"length")),e({target:"Object",stat:!0,forced:!Y},{getOwnPropertyDescriptor:ne,defineProperty:re}),ru.exports=function(r,a,o){var s=r.match(/\d+/)[0]/8,u=r+(o?"Clamped":"")+"Array",h="get"+r,g="set"+r,v=t[u],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[g](t*s+r.byteOffset,o?p(n):n,!0)}(this,t,e)},enumerable:!0})};Y?i&&(y=a(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)?O(y,t):n(T,y,t):new v(f(t)),e,y)}),C&&C(y,X),R(I(v),function(e){e in y||l(y,e,v[e])}),y.prototype=A):(y=a(function(e,t,r,i){c(e,A);var a,o,u,l=0,h=0;if(w(t)){if(!ee(t))return J(t)?O(y,t):n(T,y,t);a=t,h=m(r,s);var p=t.byteLength;if(void 0===i){if(p%s)throw new z(Z);if((o=p-h)<0)throw new z(Z)}else if((o=d(i)*s)+h>p)throw new z(Z);u=o/s}else u=f(t),a=new H(o=u*s);for(F(e,{buffer:a,byteOffset:h,byteLength:o,length:u,view:new q(a)});l=0?o:a+o;return s<0||s>=a?void 0:i[s]})}();var yu,Au={};!function(){if(yu)return Au;yu=1;var e=au(),t=Oa(),n=du(),r=wr(),i=_(),a=he(),o=v(),s=e.aTypedArray,c=e.exportTypedArrayMethod,u=a("".slice);c("fill",function(e){var a=arguments.length;s(this);var o="Big"===u(r(this),0,3)?n(e):+e;return i(t,this,o,a>1?arguments[1]:void 0,a>2?arguments[2]:void 0)},o(function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e}))}();var _u,bu,wu,Eu={};function xu(){if(bu)return _u;bu=1;var e=Jr(),t=fe(),n=at(),r=vn(),i=function(i){var a=1===i;return function(o,s,c){for(var u,l=n(o),h=t(l),d=r(h),f=e(s,c);d-- >0;)if(f(u=h[d],d,l))switch(i){case 0:return u;case 1:return d}return a?-1:void 0}};return _u={findLast:i(0),findLastIndex:i(1)}}!function(){if(wu)return Eu;wu=1;var e=au(),t=xu().findLast,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("findLast",function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)})}();var Su,Cu={};!function(){if(Su)return Cu;Su=1;var e=au(),t=xu().findLastIndex,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("findLastIndex",function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)})}();var Iu,Tu={};!function(){if(Iu)return Tu;Iu=1;var e=s(),t=_(),n=au(),r=vn(),i=cu(),a=at(),o=v(),c=e.RangeError,u=e.Int8Array,l=u&&u.prototype,h=l&&l.set,d=n.aTypedArray,f=n.exportTypedArrayMethod,m=!o(function(){var e=new Uint8ClampedArray(2);return t(h,e,{length:1,0:3},1),3!==e[1]}),p=m&&n.NATIVE_ARRAY_BUFFER_VIEWS&&o(function(){var e=new u(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),o=a(e);if(m)return t(h,this,o,n);var s=this.length,u=r(o),l=0;if(u+n>s)throw new c("Wrong length");for(;l0&&1/n<0?1:-1:t>n}}(e))},!g||p)}();var ku,Mu,Lu,Ou={};function Bu(){if(Mu)return ku;Mu=1;var e=vn();return ku=function(t,n){for(var r=e(t),i=new n(r),a=0;a=s||u<0)throw new n("Incorrect index");for(var l=new i(s),h=0;h=t.length)return e.target=null,o(void 0,!0);switch(e.kind){case"keys":return o(n,!1);case"values":return o(t[n],!1)}return o([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 $u}!function(){if(Ku)return el;Ku=1;var e=s(),t=Gu?Hu:(Gu=1,Hu={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(Yu)return qu;Yu=1;var e=ht()("span").classList,t=e&&e.constructor&&e.constructor.prototype;return qu=t===Object.prototype?void 0:t}(),r=rl(),i=St(),a=Ba(),o=ct()("iterator"),c=r.values,u=function(e,n){if(e){if(e[o]!==c)try{i(e,o,c)}catch(t){e[o]=c}if(a(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 l in t)u(e[l]&&e[l].prototype,l);u(n,"DOMTokenList")}();var il,al,ol,sl,cl,ul={};function ll(){if(al)return il;al=1;var e=y(),t=v(),n=Et(),r=xr(),i=Error.prototype.toString,a=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 il=a?function(){var e=n(this),t=r(e.name,"Error"),i=r(e.message);return t?i?t+": "+i:t:i}:i}function hl(){return sl?ol:(sl=1,ol={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(cl)return ul;cl=1;var e=mr(),t=Ae(),n=ho(),r=v(),i=Hi(),a=le(),o=xt().f,s=Xt(),c=Ia(),u=ot(),l=Ra(),h=Et(),d=ll(),f=xr(),m=hl(),p=Cr(),g=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=g.set,T=g.getterFor(b),R="stack"in new E(b),P=function(e){return u(m,e)&&m[e].m?m[e].c:0},k=function(){l(this,M);var e=arguments.length,t=f(e<1?void 0:arguments[0]),n=f(e<2?void 0:arguments[1],"Error"),r=P(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,o(this,"stack",a(1,p(i.stack,1)))}},M=k.prototype=i(C),L=function(e){return{enumerable:!0,configurable:!0,get:e}},O=function(e){return L(function(){return T(this)[e]})};A&&(c(M,"code",O("code")),c(M,"message",O("message")),c(M,"name",O("name"))),o(M,"constructor",a(1,k));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?k: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",L(function(){return P(h(this).name)})),m)if(u(m,z)){var H=m[z],G=H.s,q=a(6,H.c);u(j,G)||o(j,G,q),u(W,G)||o(W,G,q)}}();var dl,fl={};!function(){if(dl)return fl;dl=1;var e=mr(),t=s(),n=Ae(),r=le(),i=xt().f,a=ot(),o=Ra(),c=br(),u=xr(),l=hl(),h=Cr(),d=y(),f=tt(),m="DOMException",p=n("Error"),g=n(m),v=function(){o(this,A);var e=arguments.length,t=u(e<1?void 0:arguments[0]),n=u(e<2?void 0:arguments[1],"Error"),a=new g(t,n),s=new p(t);return s.name=m,i(a,"stack",r(1,h(s.stack,1))),c(a,this,v),a},A=v.prototype=g.prototype,_="stack"in new p(m),b="stack"in new g(1,2),w=g&&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:g});var S=n(m),C=S.prototype;if(C.constructor!==S)for(var I in f||i(C,"constructor",r(1,S)),l)if(a(l,I)){var T=l[I],R=T.s;a(S,R)||i(S,R,r(6,T.c))}}();var ml,pl={};!function(){if(ml)return pl;ml=1;var e=Ae(),t="DOMException";Ba()(e(t),t)}();var gl,vl={};!function(){if(gl)return vl;gl=1;var e=mr(),t=s(),n=Ia(),r=y(),i=TypeError,a=Object.defineProperty,o=t.self!==t;try{if(r){var c=Object.getOwnPropertyDescriptor(t,"self");!o&&c&&c.get&&c.enumerable||n(t,"self",{get:function(){return t},set:function(e){if(this!==t)throw new i("Illegal invocation");a(t,"self",{value:e,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}else e({global:!0,simple:!0,forced:o},{self:t})}catch(e){}}();var yl,Al,_l,bl,wl,El,xl,Sl,Cl,Il,Tl,Rl={},Pl={};function kl(){if(_l)return Al;_l=1;var e=v(),t=ct(),n=y(),r=tt(),i=t("iterator");return Al=!e(function(){var e=new URL("b?a=1&b=2&c=3","https://a"),t=e.searchParams,a=new URLSearchParams("a=1&a=2&b=3"),o="";return e.pathname="c%20d",t.forEach(function(e,n){t.delete("b"),o+=n+e}),a.delete("a",2),a.delete("b",void 0),r&&(!e.toJSON||!a.has("a",1)||a.has("a",2)||!a.has("a",void 0)||a.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"!==o||"x"!==new URL("https://x",void 0).host})}function Ml(){if(xl)return El;xl=1;var e=Jr(),t=_(),n=at(),r=Qo(),i=hs(),a=Zr(),o=vn(),s=xo(),c=fs(),u=ds(),l=Array;return El=function(h){var d=n(h),f=a(this),m=arguments.length,p=m>1?arguments[1]:void 0,g=void 0!==p;g&&(p=e(p,m>2?arguments[2]:void 0));var v,y,A,_,b,w,E=u(d),x=0;if(!E||this===l&&i(E))for(v=o(d),y=f?new this(v):l(v);v>x;x++)w=g?p(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=g?r(_,p,[A.value,x],!0):A.value,s(y,x,w);return y.length=x,y},El}function Ll(){if(Cl)return Sl;Cl=1;var e=he(),t=2147483647,n=/[^\0-\u007E]/,r=/[.\u3002\uFF0E\uFF61]/g,i="Overflow: input needs wider integers to process",a=RangeError,o=e(r.exec),s=Math.floor,c=String.fromCharCode,u=e("".charCodeAt),l=e([].join),h=e([].push),d=e("".replace),f=e("".split),m=e("".toLowerCase),p=function(e){return e+22+75*(e<26)},g=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&&o<_&&(_=o);var b=A+1;if(_-f>s((t-m)/b))throw new a(i);for(m+=(_-f)*b,f=_,r=0;rt)throw new a(i);if(o===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");a[c]=t<65536?i(t):i(55296+((t-=65536)>>10),t%1024+56320)}return o(a,"")}})}();var e=mr(),t=s(),n=Hl(),r=Ae(),i=_(),a=he(),o=y(),c=kl(),u=Xt(),l=Ia(),h=Ta(),d=Ba(),f=tl(),m=Yt(),p=Ra(),g=ve(),v=ot(),A=Jr(),b=wr(),w=Et(),E=ye(),x=Er(),S=Hi(),C=le(),I=fs(),T=ds(),R=qo(),P=Ol(),k=ct(),M=Si(),L=k("iterator"),O="URLSearchParams",B=O+"Iterator",D=m.set,U=m.getterFor(O),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,Q=a("".charAt),J=a([].join),$=a([].push),Z=a("".replace),K=a([].shift),ee=a([].splice),te=a("".split),ne=a("".slice),re=a(/./.exec),ie=/\+/g,ae=/^[0-9a-f]+$/i,oe=function(e,t){var n=ne(e,t,t+2);return re(ae,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},ue=function(e){for(var t=(e=Z(e,ie," ")).length,n="",r=0;rt){n+="%",r++;continue}var a=oe(e,r+1);if(a!=a){n+=i,r++;continue}r+=2;var o=se(a);if(0===o)i=Y(a);else{if(1===o||o>4){n+="�",r++;continue}for(var s=[a],c=1;ct||"%"!==Q(e,r));){var u=oe(e,r+1);if(u!=u){r+=3;break}if(u>191||u<128)break;$(s,u),r+=2,c++}if(s.length!==o){n+="�";continue}var l=ce(s);null===l?n+="�":i=V(l)}}n+=i,r++}return n},de=/[!'()~]|%20/g,fe={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},me=function(e){return fe[e]},pe=function(e){return Z(q(e),de,me)},ge=f(function(e,t){D(this,{type:B,target:U(e).entries,index:0,kind:t})},O,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?"?"===Q(e,0)?ne(e,1):e:x(e)))};_e.prototype={type:O,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,r,a,o,s,c,u=this.entries,l=T(e);if(l)for(n=(t=I(e,l)).next;!(r=i(n,t)).done;){if(o=(a=I(w(r.value))).next,(s=i(o,a)).done||(c=i(o,a)).done||!i(o,a).done)throw new G("Expected sequence with length 2");$(u,{key:x(s.value),value:x(c.value)})}else for(var h in e)v(e,h)&&$(u,{key:h,value:x(e[h])})},parseQuery:function(e){if(e)for(var t,n,r=this.entries,i=te(e,"&"),a=0;a0?arguments[0]:void 0));o||(this.size=e.entries.length)},we=be.prototype;if(h(we,{append:function(e,t){var n=U(this);P(arguments.length,2),$(n.entries,{key:x(e),value:x(t)}),o||this.length++,n.updateURL()},delete:function(e){for(var t=U(this),n=P(arguments.length,1),r=t.entries,i=x(e),a=n<2?void 0:arguments[1],s=void 0===a?a:x(a),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]):{})}}),g(j)){var Ce=function(e){return p(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 Fl={URLSearchParams:be,getState:U}}function ql(){if(jl)return Rl;jl=1,function(){if(yl)return Pl;yl=1;var e=vc().charAt,t=Er(),n=Yt(),r=nl(),i=qo(),a="String Iterator",o=n.set,s=n.getterFor(a);r(String,"String",function(e){o(this,{type:a,string:t(e),index:0})},function(){var t,n=s(this),r=n.string,a=n.index;return a>=r.length?i(void 0,!0):(t=e(r,a),n.index+=t.length,i(t,!1))})}();var e,t=mr(),n=y(),r=kl(),i=s(),a=Jr(),o=he(),c=Xt(),u=Ia(),l=Ra(),h=ot(),d=function(){if(wl)return bl;wl=1;var e=y(),t=he(),n=_(),r=v(),i=Wi(),a=lr(),o=ue(),s=at(),c=fe(),u=Object.assign,l=Object.defineProperty,h=t([].concat);return bl=!u||r(function(){if(e&&1!==u({b:1},u(l({},"a",{enumerable:!0,get:function(){l(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var t={},n={},r=Symbol("assign detection"),a="abcdefghijklmnopqrst";return t[r]=7,a.split("").forEach(function(e){n[e]=e}),7!==u({},t)[r]||i(u({},n)).join("")!==a})?function(t,r){for(var u=s(t),l=arguments.length,d=1,f=a.f,m=o.f;l>d;)for(var p,g=c(arguments[d++]),v=f?h(i(g),f(g)):i(g),y=v.length,A=0;y>A;)p=v[A++],e&&!n(m,g,p)||(u[p]=g[p]);return u}:u,bl}(),f=Ml(),m=xi(),p=vc().codeAt,g=Ll(),A=Er(),b=Ba(),w=Ol(),E=Gl(),x=Yt(),S=x.set,C=x.getterFor("URL"),I=E.URLSearchParams,T=E.getState,R=i.URL,P=i.TypeError,k=i.parseInt,M=Math.floor,L=Math.pow,O=o("".charAt),B=o(/./.exec),D=o([].join),U=o(1.1.toString),F=o([].pop),N=o([].push),j=o("".replace),W=o([].shift),z=o("".split),H=o("".slice),G=o("".toLowerCase),q=o([].unshift),Y="Invalid scheme",V="Invalid host",X="Invalid port",Q=/[a-z]/i,J=/[\d+-.a-z]/i,$=/\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]+/,ae=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,oe=/[\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=M(e/256);return D(t,".")}if("object"==typeof e){for(t="",r=function(e){for(var t=null,n=1,r=null,i=0,a=0;a<8;a++)0!==e[a]?(i>n&&(t=r,n=i),r=null,i=0):(null===r&&(r=a),++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={},le=d({},ce,{" ":1,'"':1,"<":1,">":1,"`":1}),de=d({},le,{"#":1,"?":1,"{":1,"}":1}),me=d({},de,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),pe=function(e,t){var n=p(e,0);return n>32&&n<127&&!h(t,e)?e:encodeURIComponent(e)},ge={ftp:21,file:null,http:80,https:443,ws:80,wss:443},ve=function(e,t){var n;return 2===e.length&&B(Q,O(e,0))&&(":"===(n=O(e,1))||!t&&"|"===n)},ye=function(e){var t;return e.length>1&&ve(H(e,0,2))&&(2===e.length||"/"===(t=O(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={},Pe={},ke={},Me={},Le={},Oe={},Be={},De={},Ue={},Fe={},Ne={},je={},We={},ze=function(e,t,n){var r,i,a,o=A(e);if(t){if(i=this.parse(o))throw new P(i);this.searchParams=null}else{if(void 0!==n&&(r=new ze(n,!0)),i=this.parse(o,null,r))throw new P(i);(a=T(new I)).bindURL(this),this.searchParams=a}};ze.prototype={type:"URL",parse:function(t,n,r){var i,a,o,s,c=this,u=n||be,l=0,d="",p=!1,g=!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,ae,"$1")),t=j(t,oe,""),i=f(t);l<=i.length;){switch(a=i[l],u){case be:if(!a||!B(Q,a)){if(n)return Y;u=Ee;continue}d+=G(a),u=we;break;case we:if(a&&(B(J,a)||"+"===a||"-"===a||"."===a))d+=G(a);else{if(":"!==a){if(n)return Y;d="",u=Ee,l=0;continue}if(n&&(c.isSpecial()!==h(ge,d)||"file"===d&&(c.includesCredentials()||null!==c.port)||"file"===c.scheme&&!c.host))return;if(c.scheme=d,n)return void(c.isSpecial()&&ge[c.scheme]===c.port&&(c.port=null));d="","file"===c.scheme?u=Oe:c.isSpecial()&&r&&r.scheme===c.scheme?u=xe:c.isSpecial()?u=Te:"/"===i[l+1]?(u=Se,l++):(c.cannotBeABaseURL=!0,N(c.path,""),u=Ne)}break;case Ee:if(!r||r.cannotBeABaseURL&&"#"!==a)return Y;if(r.cannotBeABaseURL&&"#"===a){c.scheme=r.scheme,c.path=m(r.path),c.query=r.query,c.fragment="",c.cannotBeABaseURL=!0,u=We;break}u="file"===r.scheme?Oe:Ce;continue;case xe:if("/"!==a||"/"!==i[l+1]){u=Ce;continue}u=Re,l++;break;case Se:if("/"===a){u=Pe;break}u=Fe;continue;case Ce:if(c.scheme=r.scheme,a===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("/"===a||"\\"===a&&c.isSpecial())u=Ie;else if("?"===a)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=m(r.path),c.query="",u=je;else{if("#"!==a){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=m(r.path),c.path.length--,u=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="",u=We}break;case Ie:if(!c.isSpecial()||"/"!==a&&"\\"!==a){if("/"!==a){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,u=Fe;continue}u=Pe}else u=Re;break;case Te:if(u=Re,"/"!==a||"/"!==O(d,l+1))continue;l++;break;case Re:if("/"!==a&&"\\"!==a){u=Pe;continue}break;case Pe:if("@"===a){p&&(d="%40"+d),p=!0,o=f(d);for(var y=0;y65535)return X;c.port=c.isSpecial()&&w===ge[c.scheme]?null:w,d=""}if(n)return;u=Ue;continue}return X}d+=a;break;case Oe:if(c.scheme="file","/"===a||"\\"===a)u=Be;else{if(!r||"file"!==r.scheme){u=Fe;continue}switch(a){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="",u=je;break;case"#":c.host=r.host,c.path=m(r.path),c.query=r.query,c.fragment="",u=We;break;default:ye(D(m(i,l),""))||(c.host=r.host,c.path=m(r.path),c.shortenPath()),u=Fe;continue}}break;case Be:if("/"===a||"\\"===a){u=De;break}r&&"file"===r.scheme&&!ye(D(m(i,l),""))&&(ve(r.path[0],!0)?N(c.path,r.path[0]):c.host=r.host),u=Fe;continue;case De:if(a===e||"/"===a||"\\"===a||"?"===a||"#"===a){if(!n&&ve(d))u=Fe;else if(""===d){if(c.host="",n)return;u=Ue}else{if(s=c.parseHost(d))return s;if("localhost"===c.host&&(c.host=""),n)return;d="",u=Ue}continue}d+=a;break;case Ue:if(c.isSpecial()){if(u=Fe,"/"!==a&&"\\"!==a)continue}else if(n||"?"!==a)if(n||"#"!==a){if(a!==e&&(u=Fe,"/"!==a))continue}else c.fragment="",u=We;else c.query="",u=je;break;case Fe:if(a===e||"/"===a||"\\"===a&&c.isSpecial()||!n&&("?"===a||"#"===a)){if(_e(d)?(c.shortenPath(),"/"===a||"\\"===a&&c.isSpecial()||N(c.path,"")):Ae(d)?"/"===a||"\\"===a&&c.isSpecial()||N(c.path,""):("file"===c.scheme&&!c.path.length&&ve(d)&&(c.host&&(c.host=""),d=O(d,0)+":"),N(c.path,d)),d="","file"===c.scheme&&(a===e||"?"===a||"#"===a))for(;c.path.length>1&&""===c.path[0];)W(c.path);"?"===a?(c.query="",u=je):"#"===a&&(c.fragment="",u=We)}else d+=pe(a,de);break;case Ne:"?"===a?(c.query="",u=je):"#"===a?(c.fragment="",u=We):a!==e&&(c.path[0]+=pe(a,ce));break;case je:n||"#"!==a?a!==e&&("'"===a&&c.isSpecial()?c.query+="%27":c.query+="#"===a?"%23":pe(a,ce)):(c.fragment="",u=We);break;case We:a!==e&&(c.fragment+=pe(a,le))}l++}},parseHost:function(e){var t,n,r;if("["===O(e,0)){if("]"!==O(e,e.length-1))return V;if(t=function(e){var t,n,r,i,a,o,s,c=[0,0,0,0,0,0,0,0],u=0,l=null,h=0,d=function(){return O(e,h)};if(":"===d()){if(":"!==O(e,1))return;h+=2,l=++u}for(;d();){if(8===u)return;if(":"!==d()){for(t=n=0;n<4&&B(te,d());)t=16*t+k(d(),16),h++,n++;if("."===d()){if(0===n)return;if(h-=n,u>6)return;for(r=0;d();){if(i=null,r>0){if(!("."===d()&&r<4))return;h++}if(!B($,d()))return;for(;B($,d());){if(a=k(d(),10),null===i)i=a;else{if(0===i)return;i=10*i+a}if(i>255)return;h++}c[u]=256*c[u]+i,2!==++r&&4!==r||u++}if(4!==r)return;break}if(":"===d()){if(h++,!d())return}else if(d())return;c[u++]=t}else{if(null!==l)return;h++,l=++u}}if(null!==l)for(o=u-l,u=7;0!==u&&o>0;)s=c[u],c[u--]=c[l+o-1],c[l+--o]=s;else if(8!==u)return;return c}(H(e,1,-1)),!t)return V;this.host=t}else if(this.isSpecial()){if(e=g(e),B(ne,e))return V;if(t=function(e){var t,n,r,i,a,o,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"===O(i,0)&&(a=B(Z,i)?16:8,i=H(i,8===a?1:2)),""===i)o=0;else{if(!B(10===a?ee:8===a?K:te,i))return e;o=k(i,a)}N(n,o)}for(r=0;r=L(256,5-t))return null}else if(o>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&&(u(Ge,"href",qe("serialize","setHref")),u(Ge,"origin",qe("getOrigin")),u(Ge,"protocol",qe("getProtocol","setProtocol")),u(Ge,"username",qe("getUsername","setUsername")),u(Ge,"password",qe("getPassword","setPassword")),u(Ge,"host",qe("getHost","setHost")),u(Ge,"hostname",qe("getHostname","setHostname")),u(Ge,"port",qe("getPort","setPort")),u(Ge,"pathname",qe("getPathname","setPathname")),u(Ge,"search",qe("getSearch","setSearch")),u(Ge,"searchParams",qe("getSearchParams")),u(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",a(Ye,R)),Ve&&c(He,"revokeObjectURL",a(Ve,R))}return b(He,"URL"),t({global:!0,constructor:!0,forced:!r,sham:!n},{URL:He}),Rl}Wl||(Wl=1,ql());var Yl,Vl={};!function(){if(Yl)return Vl;Yl=1;var e=mr(),t=_();e({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return t(URL.prototype.toString,this)}})}();var Xl;Xl||(Xl=1,Gl());var Ql,Jl={};!function(){if(Ql)return Jl;Ql=1;var e=Xt(),t=he(),n=Er(),r=Ol(),i=URLSearchParams,a=i.prototype,o=t(a.append),s=t(a.delete),c=t(a.forEach),u=t([].push),l=new i("a=1&a=2&b=3");l.delete("a",1),l.delete("b",void 0),l+""!="a=2"&&e(a,"delete",function(e){var t=arguments.length,i=t<2?void 0:arguments[1];if(t&&void 0===i)return s(this,e);var a=[];c(this,function(e,t){u(a,{key:t,value:e})}),r(t,1);for(var l,h=n(e),d=n(i),f=0,m=0,p=!1,g=a.length;f=n;){const e=fh.keys().next().value;fh.delete(e)}fh.set(e,t)}}const ph={};let gh=null,vh=null,yh=null,Ah=null,_h=null,bh=null,wh=null;function Eh(e){return e&&"object"==typeof e&&!Array.isArray(e)}function xh(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)}if(n instanceof Error||"undefined"!=typeof DOMException&&n instanceof DOMException){const e={name:n.name,message:n.message,stack:n.stack};return"cause"in n&&(e.cause=n.cause),Object.keys(n).forEach(t=>{e[t]=n[t]}),e}return n})}let Sh=null,Ch=null;const Ih=[];function Th(){let e="";for(const t in dh)if(t.startsWith("wallpanel-message")){e+=".".concat(t," {\n");for(const n in dh[t])e+="".concat(n,": ").concat(dh[t][n],";\n");e+="}\n"}return e}function Rh(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5e3;const i=Sh&&Sh.isConnected?Sh:document.body?(Ch=document.createElement("style"),Ch.innerHTML=Th(),Sh=document.createElement("div"),Sh.id="wallpanel-message-container",Sh.appendChild(Ch),Object.assign(Sh.style,{position:"fixed",top:"1rem",left:"1rem",bottom:"1rem",right:"1rem",display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"0.5rem",zIndex:"100000",pointerEvents:"none"}),document.body.appendChild(Sh),Sh):null;if(!i)return Ih.length||document.addEventListener("DOMContentLoaded",Mh,{once:!0}),void Ih.push([e,t,n,r]);const a=document.createElement("div");a.className="wallpanel-message ".concat(e),a.style.pointerEvents="auto";const o=document.createElement("div");o.className="wallpanel-message-title",o.textContent=t,a.appendChild(o);const s=document.createElement("div");s.className="wallpanel-message-text",s.textContent=n,a.appendChild(s),a.addEventListener("click",()=>Ph(a)),i.appendChild(a),requestAnimationFrame(()=>a.classList.add("show")),setTimeout(()=>Ph(a),r)}function Ph(e){e.classList.remove("show"),e.addEventListener("transitionend",()=>e.remove())}function kh(){if(!Sh)return!1;const e=Sh.querySelectorAll(".wallpanel-message");return!!e.length&&(e.forEach(e=>Ph(e)),!0)}function Mh(){Ih.splice(0,Ih.length).forEach(e=>Rh.apply(null,e))}const Lh={messages:[],logLevelConsole:"warning",logLevelSystem:"error",systemTargetLogLevel:"",addMessage:function(e,t){if(!ah.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&&Lh.messages.shift()},systemLog(e,t){vh&&vh.hass&&vh.hass.callService("system_log","write",{logger:"frontend.wallpanel".concat(Ah?"."+Ah:""),message:t,level:Lh.systemTargetLogLevel||e},void 0,!1).catch(()=>{})},downloadMessages:function(){const e=new Blob([xh(Lh.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(){Lh.messages=[]},debug:function(){["debug"].includes(Lh.logLevelConsole)&&console.debug.apply(this,arguments),["debug"].includes(Lh.logLevelSystem)&&Lh.systemLog("debug",xh(arguments)),Lh.addMessage("debug",arguments)},info:function(){["debug","info"].includes(Lh.logLevelConsole)&&console.info.apply(this,arguments),["debug","info"].includes(Lh.logLevelSystem)&&Lh.systemLog("info",xh(arguments)),Lh.addMessage("info",arguments)},log:function(){Lh.info.apply(this,arguments)},warning:function(){["debug","info","warning"].includes(Lh.logLevelConsole)&&console.warn.apply(this,arguments),["debug","info","warning"].includes(Lh.logLevelSystem)&&Lh.systemLog("warning",xh(arguments)),Lh.addMessage("warning",arguments)},warn:function(){Lh.warning.apply(this,arguments)},error:function(){["debug","info","warning","error"].includes(Lh.logLevelConsole)&&console.error.apply(this,arguments),["debug","info","warning","error"].includes(Lh.logLevelSystem)&&Lh.systemLog("error",xh(arguments)),Lh.addMessage("error",arguments),ah.alert_errors&&Rh("error","Error","Wallpanel error: ".concat(xh(arguments)),1e4)},err:function(){Lh.error.apply(this,arguments)}};class Oh{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=()=>{Lh.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",()=>{Lh.debug("Video ended"),this.enabled&&this.enable()}),this._player.addEventListener("playing",()=>{Lh.debug("Video playing"),this._isPlaying=!0}),this._player.addEventListener("pause",()=>{Lh.debug("Video pause"),this._isPlaying=!1})}}enable(){if(this.nativeWakeLockSupported){if(Lh.debug("Requesting native screen wakelock"),this._lock)return void Lh.debug("Screen wakelock already active");navigator.wakeLock.request("screen").then(e=>{Lh.debug("Request screen wakelock successful"),this._lock=e,this._onWakeLockRelease=()=>{Lh.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,Lh.warning("Failed to request screen wakeLock: ".concat(e))})}else{Lh.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,Lh.debug("Video play successful")}).catch(e=>{this.enabled=!1,this.error=e,Lh.warning("Failed to play video: ".concat(e))})}}disable(){this.nativeWakeLockSupported?(Lh.debug("Releasing native screen wakelock"),this._lock&&(this._onWakeLockRelease&&(this._lock.removeEventListener("release",this._onWakeLockRelease),this._onWakeLockRelease=null),this._lock.release()),this._lock=null):(Lh.debug("Stopping video player"),!this._player.paused&&this._isPlaying&&this._player.pause()),this.enabled=!1}}class Bh{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),a=this.previousChangeRatios.length>=this.maxRatioHistorySize&&this.hasRequiredRatioBelowThreshold(this.previousChangeRatios,this.roomSettledRequiredRatio);i?(this.motionActive||(Lh.debug("Motion started"),this.motionActive=!0,lh.motionDetected()),this.motionStopTimeout&&(clearTimeout(this.motionStopTimeout),this.motionStopTimeout=null)):this.motionActive&&!this.motionStopTimeout&&(this.motionStopTimeout=setTimeout(()=>{Lh.debug("Motion stopped"),this.motionActive=!1,this.motionStopTimeout=null,lh.motionStopped()},this.motionStopDelay)),a&&(Lh.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 Lh.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=ah.camera_motion_detection_capture_width,this.height=ah.camera_motion_detection_capture_height,this.thresholdRatio=.01*ah.camera_motion_detection_threshold,this.threshold=this.width*this.height*this.thresholdRatio,this.captureInterval=1e3*ah.camera_motion_detection_capture_interval,this.motionStartDelay=1e3*ah.camera_motion_detection_motion_start_delay,this.motionStopDelay=1e3*ah.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,ah.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:ah.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=>{Lh.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,Lh.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 Dh=1592614637;function Uh(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 Fh(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 Nh(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 jh(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;rc(e)):Eh(t)&&(t=Object.fromEntries(Object.entries(t).map(e=>{let[t,n]=e;return[t,c(n)]}))),"boolean"==typeof e[a]&&(t=null!=t&&["true","on","yes","1"].includes(String(t).toLowerCase())),t}o=c(o),Array.isArray(e[a])&&"string"==typeof o&&(o=o.split(",").map(e=>e.trim())),Object.assign(e,{[a]:o})}}return jh(e,...n)}function Wh(){const e=new URLSearchParams(window.location.search),t=ah;ah={},jh(ah,nh),0===Object.keys(ih).length&&(ih=Vh(),0===Object.keys(ih).length&&Lh.debug("No wallpanel config found in dashboard config")),jh(ah,ih);const n={};for(let[t,r]of e)if(t.startsWith("wp_")&&(t=t.substring(3),rh[t]&&(Lh.warn("The configuration option '".concat(t,"' has been renamed to '").concat(rh[t],"'. Please update your wallpanel configuration accordingly.")),t=rh[t]),t in nh&&r)){try{r=JSON.parse(r)}catch(e){}const e=nh[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:Lh.warn("Invalid numeric wp_ param '".concat(t,"': ").concat(r))}else n[t]=r}ah=jh(ah,n);const r=ah.profile;if(ah.profiles&&r&&ah.profiles[r]&&(ah=jh(ah,ah.profiles[r]),Lh.debug("Profile set from config: ".concat(r))),ah.profiles&&Ah&&ah.profiles["device.".concat(Ah)]){const e="device.".concat(Ah);ah=jh(ah,ah.profiles[e]),Lh.debug("Profile set from device: ".concat(e))}if(ah.profiles){const e=[_h,bh,wh];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 Hh(){const e=zh();return e&&0!=e.length?e[0]:null}function Gh(){if("1"==new URLSearchParams(window.location.search).get("edit"))return Lh.debug("Edit mode active"),!1;if(!ah.enabled)return Lh.debug("Wallpanel not enabled in config"),!1;if(ah.enabled_on_views&&ah.enabled_on_views.length>0&&ch&&!ah.enabled_on_views.includes(ch))return Lh.debug("Wallpanel not enabled on current tab ".concat(ch)),!1;if(ah.disable_screensaver_when_assist_active){const e=vh.shadowRoot.querySelector("ha-voice-command-dialog");if(e&&e.shadowRoot&&e.shadowRoot.querySelector("ha-dialog"))return Lh.debug("Assist is active, wallpanel disabled"),!1}return lh&&lh.disable_screensaver_on_browser_mod_popup_function&&Hh()&&lh.disable_screensaver_on_browser_mod_popup_function(Hh())?(Lh.debug("Browser mod popup function returned true, wallpanel disabled"),!1):!ah.disable_screensaver_on_browser_mod_popup||!Hh()||(Lh.debug("Browser mod popup active, wallpanel disabled"),!1)}function qh(){return ah.show_images&&ah.image_url?ah.image_url.startsWith("media-entity-video://")?"media-entity-video":ah.image_url.startsWith("media-entity-image://")?"media-entity-image":ah.image_url.startsWith("media-source://")?"media-source":ah.image_url.startsWith("https://api.unsplash")?"unsplash-api":ah.image_url.startsWith("immich+")?"immich-api":ah.image_url.startsWith("iframe+")?"iframe":ah.image_url.startsWith("embed+")?"embed":"url":""}function Yh(){try{return yh.shadowRoot.querySelector("ha-panel-lovelace")}catch(e){Lh.error("Failed to get ha-panel-lovelace:",e)}}function Vh(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const t=Yh(),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 nh||e in rh)&&(n[e]=r[e])}))}return n}function Xh(e){Lh.debug("setSidebarVisibility: hidden=".concat(e));try{const t=yh.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){Lh.warn(e)}try{const t=yh.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",yh.style.setProperty(r,"env(safe-area-inset-left)")):(n.style.opacity=1,n.style.maxWidth="",yh.style.removeProperty(r)),window.dispatchEvent(new Event("resize")))}}catch(e){Lh.warn(e)}}function Qh(e,t){Lh.debug("setToolbarVisibility: hideToolbar=".concat(e,", hideActionItems=").concat(t));try{const n=yh.shadowRoot.querySelector("ha-panel-lovelace");if(!n)return;let r=n.shadowRoot.querySelector("hui-root");if(!r)return;r=r.shadowRoot;let i=r.querySelector("app-toolbar");i||(i=r.querySelector("div.toolbar"));const a="wallpanel-toolbar-visibility";let o=r.querySelector("#".concat(a));if(e)o||(o=document.createElement("style"),o.id=a,r.appendChild(o)),o.textContent=".header, app-toolbar, div.toolbar { display: none !important; }".concat(ah.keep_toolbar_space?"":"hui-view-container, #view { min-height: 100vh !important; margin-top: 0 !important; padding-top: 0 !important; }");else{o&&o.remove();const e=i.querySelector("div.action-items");t?e.style.setProperty("display","none"):e.style.setProperty("display","flex")}window.dispatchEvent(new Event("resize"))}catch(e){Lh.warn(e)}}function Jh(){return void 0!==document.fullscreenElement?Boolean(document.fullscreenElement):void 0!==document.webkitCurrentFullScreenElement&&Boolean(document.webkitCurrentFullScreenElement)}function $h(){Lh.debug("Enter fullscreen");const e=document.documentElement;e.requestFullscreen?e.requestFullscreen().then(()=>{Lh.debug("Successfully requested fullscreen")},e=>{Lh.debug("Failed to enter fullscreen:",e)}):e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen?e.msRequestFullscreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen()}function Zh(){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.mediaPathLists=[],this.mediaPathQueue=[],this.currentMediaPath=null,this.lastMediaListUpdate,this.updatingMediaList=!1,this.mediaListRetryAt=0,this.mediaListRetryTimer=null,this.updatingMedia=!1,this.mediaLoadRetryAt=0,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=ah.profile,this.lastMove=null,this.lastCorner=0,this.translateTimeout=null,this.afterFadeoutTimer=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 Oh,this.cameraMotionDetection=new Bh,this.lovelace=null,this.__hass=vh.hass||vh.__hass,this.__cards=[],this.__badges=[],this.__views=[],vh.provideHass(this),this.timerInterval=setInterval(this.timer.bind(this),1e3),uh.hass=this.__hass}set hass(e){Lh.debug("Update hass"),this.__hass=e;let t=!1;for(const e in ph){const n=this.__hass.states[e];n&&n.state!=ph[e]&&(ph[e]=n.state,t=!0)}if(!this.updateProfile()&&t&&Wh(),!Gh())return;const n=ah.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(ah.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"==qh()&&this.switchActiveMedia("entity_update"))}get hass(){return this.__hass}setScreensaverEntityState(){const e=ah.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";Lh.debug("Updating screensaver_entity",e,t),this.__hass.callService("input_boolean",t,{entity_id:e}).then(e=>{Lh.debug(e)},e=>{Lh.error("Failed to set screensaver entity state:",e)})}setImageURLEntityState(){const e=ah.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&&(Lh.debug("Updating image_url_entity",e,n),this.__hass.callService("input_text","set_value",{entity_id:e,value:n}).then(e=>{Lh.debug(e),this.lastImageUrlEntityValue=n},e=>{Lh.error("Failed to set image url entity state:",e)}))}updateProfile(){const e=ah.profile_entity;if(e&&this.__hass.states[e]){const t=this.__hass.states[e].state;if(t&&t!=this.lastProfileSet||!t&&this.lastProfileSet)return Lh.debug("Set profile to ".concat(t)),this.lastProfileSet=t,Wh(),!0}return!1}timer(){ah.enabled&&sh&&(this.screensaverRunning()?ah.disable_screensaver_on_browser_mod_popup&&Hh()?this.stopScreensaver(ah.fade_out_time_browser_mod_popup):this.updateScreensaver():Gh()&&ah.idle_time>0&&Date.now()-this.idleSince>=1e3*ah.idle_time&&(ah.camera_motion_detection_stop_screensaver&&this.cameraMotionDetection&&this.cameraMotionDetection.motionActive||this.startScreensaver()))}setDefaultStyle(){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=ah.debug?"visible":"hidden",this.debugBox.style.pointerEvents=ah.debug?"auto":"none",this.style.transition=ah.fade_in_time>0?"opacity ".concat(Math.round(1e3*ah.fade_in_time),"ms ease-in-out"):"",this.imageOneContainer.style.transition=ah.crossfade_time>0?"opacity ".concat(Math.round(1e3*ah.crossfade_time),"ms ease-in-out"):"",this.imageTwoContainer.style.transition=ah.crossfade_time>0?"opacity ".concat(Math.round(1e3*ah.crossfade_time),"ms ease-in-out"):"",this.screensaverImageOverlay.style.pointerEvents=ah.content_interaction?"none":"auto";const e=ah.show_image_info&&Boolean(ah.image_info_template);if(this.imageOneInfoContainer.style.display=e?"block":"none",this.imageTwoInfoContainer.style.display=e?"block":"none",ah.info_animation_duration_x?this.infoBoxPosX.style.animation="moveX ".concat(ah.info_animation_duration_x,"s ").concat(ah.info_animation_timing_function_x," infinite alternate"):this.infoBoxPosX.style.animation="",ah.info_animation_duration_y?this.infoBoxPosY.style.animation="moveY ".concat(ah.info_animation_duration_y,"s ").concat(ah.info_animation_timing_function_y," infinite alternate"):this.infoBoxPosY.style.animation="",ah.style)for(const e in ah.style)if(e.startsWith("wallpanel-")&&"wallpanel-shadow-host"!=e&&"wallpanel-screensaver-info-box-badges"!=e&&"wallpanel-screensaver-info-box-views"!=e&&!dh[e]){const t=this.shadowRoot.getElementById(e);if(t){Lh.debug("Setting style attributes for element #".concat(e));for(const n in ah.style[e])Lh.debug("Setting style attribute ".concat(n," to ").concat(ah.style[e][n])),t.style.setProperty(n,ah.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 Lh.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(ah.style){if(ah.style["wallpanel-shadow-host"])for(const e in ah.style["wallpanel-shadow-host"])r+="".concat(e,": ").concat(ah.style["wallpanel-shadow-host"][e],";\n");for(const e in dh)ah.style[e]&&jh(dh[e],ah.style[e])}Ch&&(Ch.innerHTML=Th());let i="";for(const e in dh){i+=".".concat(e," {\n");for(const t in dh[e])i+="".concat(t,": ").concat(dh[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(ah.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=ah.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 Lh.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(){Lh.debug("Creating info box content");const e=Yh();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)}),ah.badges&&ah.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)",ah.style[e.id])for(const t in ah.style[e.id])Lh.debug("Setting style attribute ".concat(t," to ").concat(ah.style[e.id][t])),e.style.setProperty(t,ah.style[e.id][t]);ah.badges.forEach(t=>{const n=JSON.parse(JSON.stringify(t));Lh.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(ah.views&&ah.views.length>0){const e=document.createElement("div");if(e.id="wallpanel-screensaver-info-box-views",e.classList.add("wp-views"),ah.style[e.id])for(const t in ah.style[e.id])Lh.debug("Setting style attribute ".concat(t," to ").concat(ah.style[e.id][t])),e.style.setProperty(t,ah.style[e.id][t]);const t=this.lovelace.config.views;ah.views.forEach(n=>{let r=-1;const i=JSON.parse(JSON.stringify(n));for(var a=0;a0&&ah.cards.forEach(e=>{const t=JSON.parse(JSON.stringify(e));Lh.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 a=document.createElement("div");a.classList.add("wp-card"),a.style.width="var(--wp-card-width)",a.style.padding="var(--wp-card-padding)",a.style.margin="var(--wp-card-margin)",a.style.backdropFilter="var(--wp-card-backdrop-filter)",ah.content_interaction?a.style.pointerEvents="auto":a.style.pointerEvents="none";for(const e in n)if("parent"==e){const t=this.shadowRoot.getElementById(n[e]);t&&(i=t)}else a.style.setProperty(e,n[e]);a.append(r),i.appendChild(a)}),setTimeout(this.updateShadowStyle.bind(this),500)}}setDisplayTime(){const e=ah.display_time,t=this.getActiveMediaElement(!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",!ah.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(!ah.image_animation_ken_burns||!ah.image_animation_ken_burns_animations.length)return;const e=this.getActiveMediaElement();e.style.animation="none",e.style.setProperty("--ken-burns-zoom",ah.image_animation_ken_burns_zoom);let t=Math.floor(1e3*ah.image_animation_ken_burns_delay);t<50&&(t=50);const n=Math.ceil(ah.image_animation_ken_burns_duration||1.2*(this.getDisplayTime()+2*ah.crossfade_time)),r=ah.image_animation_ken_burns_animations[Math.floor(Math.random()*ah.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=Nh(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)}releaseMediaElement(e){if(!e)return;e.style.animation="none";const t=e===this.imageOne?this.imageOneBackground:e===this.imageTwo?this.imageTwoBackground:null;t&&(t.style.backgroundImage="");const n=e.tagName.toLowerCase();if("ha-camera-stream"===n)try{const[t,n]=Nh(e);n&&n.pause(),t&&"function"==typeof t.stop&&t.stop()}catch(e){Lh.debug(e)}else{if("function"==typeof e.pause)try{e.pause()}catch(e){Lh.debug(e)}const t=e.getAttribute("src")||"";t.startsWith("blob:")&&URL.revokeObjectURL(t),e.removeAttribute("src"),"video"===n&&"function"==typeof e.load&&e.load()}e.mediaUrl=null,e.infoCacheUrl=null}releaseAllMedia(){this.releaseMediaElement(this.imageOne),this.releaseMediaElement(this.imageTwo)}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]=Nh(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:ah.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=Nh(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,Lh.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=ah.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.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),ah.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.debugBox);const t=this,n=["click","touchstart","touchend","wheel"];ah.stop_screensaver_on_key_down&&n.push("keydown"),ah.stop_screensaver_on_mouse_move&&n.push("mousemove");const r=e=>{try{t.handleInteractionEvent(e)}catch(e){Lh.error(e.stack)}};n.forEach(function(e){window.addEventListener(e,r,!0),t.windowEventHandlers.push({eventName:e,handler:r,options:!0})});const i=e=>{ah.disable_context_menu&&t.screensaverRunning()&&e.preventDefault()};window.addEventListener("contextmenu",i),this.windowEventHandlers.push({eventName:"contextmenu",handler:i});const a=()=>{try{const e=this.screensaverContainer.clientWidth,n=this.screensaverContainer.clientHeight;!t.screensaverRunning()||t.currentWidth==e&&t.currentHeight==n||(Lh.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){Lh.error(e.stack)}};window.addEventListener("resize",a),this.windowEventHandlers.push({eventName:"resize",handler:a});const o=()=>{try{t.screensaverRunning()&&t.moreInfoDialogToForeground()}catch(e){Lh.error(e.stack)}};window.addEventListener("hass-more-info",o),this.windowEventHandlers.push({eventName:"hass-more-info",handler:o}),this.infoBoxResizeObserver=new ResizeObserver(()=>{"corners"===ah.info_move_pattern&&this.moveAroundCorners(!0)}),this.infoBoxResizeObserver.observe(this.infoBoxContent),this.setScreensaverEntityState()}disconnectedCallback(){this.afterFadeoutTimer&&(clearTimeout(this.afterFadeoutTimer),this.afterFadeoutTimer=null),this.releaseAllMedia(),this.clearMediaListRetry(),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==ah.hide_toolbar&&e.hide_toolbar_action_icons==ah.hide_toolbar_action_icons&&e.hide_toolbar_on_subviews==ah.hide_toolbar_on_subviews&&e.hide_sidebar==ah.hide_sidebar&&e.fullscreen==ah.fullscreen||Kh(),ah.theme&&(Lh.info("Apply theme",ah.theme),uh.theme=ah.theme,uh._applyTheme()),this.updateStyle(),this.screensaverRunning()&&this.createInfoBoxContent(),!ah.info_move_interval&&t&&e.info_move_interval&&lh.moveInfoBox(0,0);const n=e.image_url!=ah.image_url||e.media_order!=ah.media_order||e.media_list_max_size!=ah.media_list_max_size||JSON.stringify(e.exclude_filenames)!=JSON.stringify(ah.exclude_filenames)||JSON.stringify(e.exclude_media_types)!=JSON.stringify(ah.exclude_media_types)||"immich-api"==qh()&&(ah.immich_shared_albums!=e.immich_shared_albums||ah.immich_memories!=e.immich_memories||ah.immich_favorites!=e.immich_favorites||JSON.stringify(ah.immich_album_names)!=JSON.stringify(e.immich_album_names)||JSON.stringify(ah.immich_tag_names)!=JSON.stringify(e.immich_tag_names)||JSON.stringify(ah.immich_persons)!=JSON.stringify(e.immich_persons));if(ah.show_images&&(!this.mediaList||!this.mediaList.length||!t||!e.show_images||n)){const e=this,r=this.screensaverRunning()&&t;n&&(this.clearMediaListRetry(),this.resetMediaPathLists(),this.mediaList=[],this.mediaIndex=-1),this.updateMediaList(function(){r&&e.switchActiveMedia("reconfigure")},n)}if(ah.disable_screensaver_on_browser_mod_popup_func)try{this.disable_screensaver_on_browser_mod_popup_function=new Function("bmp",ah.disable_screensaver_on_browser_mod_popup_func)}catch(e){this.disable_screensaver_on_browser_mod_popup_function=null,Lh.error("Invalid disable_screensaver_on_browser_mod_popup_func:",e)}Gh()&&ah.camera_motion_detection_enabled?this.cameraMotionDetection.start():this.cameraMotionDetection.stop()}getMoreInfoDialog(){const e=vh.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(fh.get(e.infoCacheUrl))return;const n=document.createElement("img");n.src=e.src,n.mediaUrl=e.mediaUrl,n.infoCacheUrl=e.infoCacheUrl,dd(n,function(){Lh.debug("EXIF data:",n.exifdata),mh(n.infoCacheUrl,n.exifdata),t.setMediaDataInfo(n);const e=n.exifdata.GPSLongitude,r=n.exifdata.GPSLatitude;if(ah.fetch_address_data&&e&&!isNaN(e[0])&&r&&!isNaN(r[0])){let i="S"==n.exifdata.GPSLatitudeRef?-1:1;const a=r[0]*i+(r[1]*i*60+r[2]*i)/3600;i="W"==n.exifdata.GPSLongitudeRef?-1:1;const o=e[0]*i+(e[1]*i*60+e[2]*i)/3600;Lh.debug("Fetching nominatim data for lat=".concat(a," lon=").concat(o));const s=new XMLHttpRequest;s.onload=function(){if(200==this.status||0===this.status){const e=JSON.parse(s.responseText);if(Lh.debug("nominatim data:",e),e&&e.address){const r=fh.get(n.infoCacheUrl);r?(r.address=e.address,t.setMediaDataInfo(n)):Lh.warn("URL not in cache:",n.infoCacheUrl)}}else Lh.error("nominatim error:",this.status,s.status,s.responseText)},s.onerror=function(e){Lh.error("nominatim error:",e)},s.ontimeout=function(e){Lh.error("nominatim timeout:",e)},s.open("GET","https://nominatim.openstreetmap.org/reverse?lat=".concat(a,"&lon=").concat(o,"&format=json")),s.timeout=15e3,s.send()}})}setMediaDataInfo(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;const t=ah.show_image_info&&Boolean(ah.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 Lh.debug("infoCacheUrl missing:",e);if(!r)return void Lh.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 a=fh.get(n);a||(a={}),a.image||(a.image={}),void 0===a.image.url&&(a.image.url=r);const o=r.replace(/\?[^?]*$/,"").replace(/\/+$/,"");if(void 0===a.image.path&&(a.image.path=o.replace(/^[^:]+:\/\/[^/]+/,"")),void 0===a.image.relativePath){const c="media-source"===qh()?n.replace(/\?[^?]*$/,"").replace(/\/+$/,""):o;a.image.relativePath=c.replace(ah.image_url,"").replace(/^\/+/,"")}if(void 0===a.image.filename&&(a.image.filename=o.replace(/^.*[\\/]/,"")),void 0===a.image.folderName){a.image.folderName="";const u=o.split("/");u.length>=2&&(a.image.folderName=u[u.length-2])}a.mediaPosition=this.mediaIndex+1,a.mediaCount=this.mediaList.length,Lh.debug("Media info:",a);let s=ah.image_info_template||"";if("analyze"==s){function l(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?l(r,n+"."):s+="".concat(t).concat(n,": ").concat(xh(r),"
")})}s="",l(a),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]&&(o[t[0].replace(/\s/g,"")]=t[1].replace(/\s/g,""))}))}}let s="";const c=t.split("|");let u="";for(let e=0;e{s&&(s=s[e])}),s)break}if(s){if(/DateTime/i.test(u)){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;o||(o={year:"numeric",month:"2-digit",day:"2-digit"}),s=e.toLocaleDateString((vh.hass||vh.__hass).locale.language,o)}return"object"==typeof s&&(s=JSON.stringify(s)),r+s+i}}return""});i.forEach(e=>{e.innerHTML=s,e.style.display="block"})}clearMediaListRetry(){this.mediaListRetryTimer&&(clearTimeout(this.mediaListRetryTimer),this.mediaListRetryTimer=null),this.mediaListRetryAt=0}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(!ah.image_url)return;if(this.updatingMediaList)return;if(this.mediaListRetryAt>Date.now())return;if(!t&&(new Date).getTime()-this.lastMediaListUpdate<1e3*ah.media_list_update_interval)return;this.clearMediaListRetry();const r=this;let i=null;const a=qh();if("unsplash-api"==a)i=r.updateMediaListFromUnsplashAPI;else if("immich-api"==a)i=r.updateMediaListFromImmichAPI;else{if("media-source"!=a){let t=ah.image_url;return"iframe"==a?t=t.replace(/^iframe\+/,""):"embed"==a&&(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)(),this.clearMediaListRetry(),Lh.debug("Media list from ".concat(a," is now:"),r.mediaList),e&&e()}catch(t){const i=3;let o=3e3;if(429===t.httpStatus&&(o=Number.isFinite(t.retryAfterDelay)?Math.max(t.retryAfterDelay,3e3):Math.min(6e4*2**n,36e5)),Lh.warn("Failed to update media list from ".concat(a,":"),t),n{r.mediaListRetryTimer=null,r.mediaListRetryAt=0,r.updateMediaList(e,!0,n+1)},o);else{const e="Failed to update media list from ".concat(ah.image_url," after ").concat(i," retries: ").concat(t.message||xh(t));Lh.error(e)}}this.updatingMediaList=!1}resetMediaPathLists(){this.mediaPathLists=[],this.mediaPathQueue=[],this.currentMediaPath=null}limitMediaList(e){return e.length>ah.media_list_max_size?(Lh.info("Using only ".concat(ah.media_list_max_size," of ").concat(e.length," media items")),e.slice(0,ah.media_list_max_size)):e}async findMediaPathLists(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const n=this;if(Lh.debug("findMediaPathLists: ".concat(e)),!t&&(t=[],ah.exclude_filenames))for(const e of ah.exclude_filenames)t.push(new RegExp(e));try{const r=await n.hass.callWS({type:"media_source/browse_media",media_content_id:e});Lh.debug("Found media entry",r);const i=[],a=[];for(const e of r.children){const r=e.media_content_id.replace(/^media-source:\/\/[^/]+/,"");let o=!1;for(const e of t)if(e.lastIndex=0,e.test(r)){o=!0;break}if(!o)if(["image","video"].includes(e.media_class)){if(ah.exclude_media_types&&ah.exclude_media_types.includes(e.media_class))continue;i.push(e.media_content_id)}else"directory"==e.media_class&&a.push(n.findMediaPathLists(e.media_content_id,t))}const o=(await Promise.all(a)).flat();return(i.length?[{path:e,medias:i}]:[]).concat(o)}catch(t){throw Lh.warn("Error browsing media ".concat(e,":"),t),t}}updateMediaPathQueue(){const e=this.mediaPathLists.map(e=>e.path);this.mediaPathQueue=this.mediaPathQueue.filter((t,n,r)=>t!=this.currentMediaPath&&e.includes(t)&&r.indexOf(t)==n)}selectNextMediaPath(){if(!this.mediaPathLists.length)return this.mediaList=[],this.mediaIndex=-1,this.currentMediaPath=null,!1;this.mediaPathQueue.length||(this.mediaPathQueue=Fh(this.mediaPathLists.map(e=>e.path)),this.mediaPathQueue.length>1&&this.mediaPathQueue[0]==this.currentMediaPath&&([this.mediaPathQueue[0],this.mediaPathQueue[1]]=[this.mediaPathQueue[1],this.mediaPathQueue[0]]));const e=this.mediaPathQueue.shift(),t=this.mediaPathLists.find(t=>t.path==e);return t?(this.currentMediaPath=e,this.mediaList=this.limitMediaList(t.medias.slice().sort()),this.mediaIndex=-1,Lh.debug("Selected media path ".concat(e,":"),this.mediaList),this.mediaList.length>0):(this.updateMediaPathQueue(),this.selectNextMediaPath())}updateRandomPathMediaLists(e){const t=this.mediaList[this.mediaIndex],n=this.mediaIndex;this.mediaPathLists=e,this.updateMediaPathQueue();const r=this.mediaPathLists.find(e=>e.path==this.currentMediaPath);if(!r)return this.currentMediaPath=null,this.mediaPathQueue=[],void this.selectNextMediaPath();this.mediaList=this.limitMediaList(r.medias.slice().sort()),t&&this.mediaList.includes(t)?this.mediaIndex=this.mediaList.indexOf(t):this.mediaIndex=n>=0?Math.min(n-1,this.mediaList.length-1):-1}async updateMediaListFromMediaSource(){const e=ah.image_url,t=this;try{const n=await t.findMediaPathLists(e);if("random_path"==ah.media_order)return void t.updateRandomPathMediaLists(n);t.resetMediaPathLists();let r=n.flatMap(e=>e.medias);r="random"==ah.media_order?Fh(r):"random_but_synced"==ah.media_order?Fh(r.slice().sort(),Uh(Dh)):r.sort(),t.mediaList=t.limitMediaList(r)}catch(e){throw new Error("Failed to update image list from ".concat(ah.image_url,": ").concat(e.message||xh(e)))}}async updateMediaListFromUnsplashAPI(){const e=[],t="".concat(ah.image_url,"&count=30");Lh.debug("Unsplash API request: ".concat(t));try{const n={method:"GET",headers:{Accept:"application/json"}};"undefined"!=typeof AbortSignal&&void 0!==AbortSignal.timeout&&(Lh.debug("Using AbortSignal"),n.signal=AbortSignal.timeout(1e3*ah.immich_api_request_timeout));const r=await fetch(t,n);if(!r.ok){const e=await r.text(),t=new Error("Unsplash API request failed: ".concat(r.status," ").concat(r.statusText," - ").concat(e));throw t.httpStatus=r.status,429===r.status&&(t.retryAfterDelay=function(e){const t=e.headers.get("Retry-After");if(t){const e=Number(t);if(Number.isFinite(e)&&e>=0)return Math.round(1e3*e);const n=Date.parse(t);if(Number.isFinite(n))return Math.max(0,n-Date.now())}const n=Number(e.headers.get("X-Ratelimit-Reset"));if(Number.isFinite(n)&&n>0){const e=n>1e12?n:1e3*n;return Math.max(0,e-Date.now())}return null}(r)),t}const i=await r.json();Lh.debug("Got Unsplash API response"),i.forEach(t=>{Lh.debug(t);const n="".concat(t.urls.raw,"&w=${width}&h=${height}&auto=format");e.push(n),mh(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"}},a=n(n({},i),r);a.headers=n(n({},i.headers),r.headers),"undefined"!=typeof AbortSignal&&void 0!==AbortSignal.timeout&&(Lh.debug("Using AbortSignal"),a.signal=AbortSignal.timeout(1e4)),Lh.debug("Immich API request: ".concat(e));try{const t=await fetch(e,a);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(!ah.immich_api_keys||!ah.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=ah.exclude_media_orientation;"auto"==n&&(n="landscape"==t?"portrait":"landscape"),Lh.debug("config.exclude_media_orientation=".concat(ah.exclude_media_orientation,", screenOrientation=").concat(t,", exclude_media_orientation=").concat(n));let r=[];const i={},a=ah.image_url.replace(/^immich\+/,""),o=[];if(ah.exclude_filenames)for(const e of ah.exclude_filenames)o.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 u(t,s){let u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;await async function(t,r){const i=ah.immich_exclude_tag_names&&ah.immich_exclude_tag_names.length,o=!!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),u=s&&o&&(null==t.width||null==t.height);if(!t.exifInfo||i&&!t.tags||u||c){Lh.debug("Fetching asset info for ".concat(t.id));const n=await e._immichFetch("".concat(a,"/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){Lh.debug("Processing immich asset",e);const t=e.type.toLowerCase();if(!["image","video"].includes(t)){Lh.debug("Neither image nor video, skipping");continue}if(ah.exclude_media_types&&ah.exclude_media_types.includes(t)){Lh.debug('Media type "'.concat(t,'" excluded'));continue}let l=!1;for(const t of o)t.test(e.originalFileName)&&(Lh.debug('Media item excluded by regex "'.concat(t,'"')),l=!0);if(l)continue;if(ah.immich_exclude_tag_names&&ah.immich_exclude_tag_names.length){const t=e.tags.filter(e=>ah.immich_exclude_tag_names.includes(e));if(t.length>0){Lh.debug("Media item excluded due to tag(s): ".concat(t.join(", ")));continue}}if(n){const t=c(e);if(t===n){Lh.debug('Media item with orientation "'.concat(t,'" excluded'));continue}}let h="original";"preview"==ah.immich_resolution&&(h="video"==t?"video/playback":"thumbnail?size=preview");let d="".concat(a,"/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:u},i[d]=f}}try{for(const t of ah.immich_api_keys)if(Lh.debug("Using immich API key ".concat(t)),ah.immich_persons&&ah.immich_persons.length){Lh.debug("Searching for assets based on persons");const n=ah.immich_persons.map(e=>(Array.isArray(e)?e:[e]).map(e=>e.toLowerCase())),r={};let i=[],o=1,s=!0;for(;s;){const n=await e._immichFetch("".concat(a,"/people?size=1000&page=").concat(o),t);i=i.concat(n.people),s=n.hasNextPage,o++}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):Lh.error("Person not found in immich: ".concat(e))}),n.length>0){Lh.debug("Searching asset metadata for persons: ",n);let r=1;for(;;){Lh.debug("Fetching asset metadata page ".concat(r));const o=await e._immichFetch("".concat(a,"/search/metadata"),t,{method:"POST",body:JSON.stringify({personIds:n,withExif:!0,page:r,size:1e3})});if(Lh.debug("Got immich API response",o),!o.assets.count){if(1==r){const e="No media items found in immich that contain all these people: ".concat(i);Lh.error(e)}break}if(await u(o.assets.items,t),!o.assets.nextPage)break;r=parseInt(o.assets.nextPage,10)}}}}else if(ah.immich_memories){Lh.debug("Fetching immich memories (on_this_day)");const n=await e._immichFetch("".concat(a,"/memories?type=on_this_day"),t);Lh.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});Lh.debug("Found ".concat(i.length," visible memories")),await Promise.all(i.map(async e=>{Lh.debug("Processing memory:",e),await u(e.assets,t)}))}else if(ah.immich_favorites){Lh.debug("Search for favorites in asset metadata");let n=1;for(;;){Lh.debug("Fetching asset metadata page ".concat(n));const r=await e._immichFetch("".concat(a,"/search/metadata"),t,{method:"POST",body:JSON.stringify({isFavorite:!0,withExif:!0,page:n,size:1e3})});if(Lh.debug("Got immich API response",r),!r.assets.count){if(1==n){const e="No favorite media items found in immich";Lh.error(e)}break}if(await u(r.assets.items,t),!r.assets.nextPage)break;n=parseInt(r.assets.nextPage,10)}}else if(ah.immich_tag_names&&ah.immich_tag_names.length){Lh.debug("Searching for assets based on tag names");const n=ah.immich_tag_names.map(e=>e.toLowerCase());Lh.debug("Fetching immich tags");const r=await e._immichFetch("".concat(a,"/tags"),t);Lh.debug("Got immich API response",r);const i=r.filter(e=>{const t=n.includes(e.name.toLowerCase());return Lh.debug("".concat(t?"Adding":"Skipping"," tag: ").concat(e.name)),t}).map(e=>e.id);if(i.length>0){Lh.debug("Searching asset metadata for tags: ",i);let r=1;for(;;){Lh.debug("Fetching asset metadata page ".concat(r));const o=await e._immichFetch("".concat(a,"/search/metadata"),t,{method:"POST",body:JSON.stringify({tagIds:i,withExif:!0,page:r,size:1e3})});if(Lh.debug("Got immich API response",o),!o.assets.count){if(1==r){const e="No media items found in immich that contain these tags: ".concat(n);Lh.error(e)}break}if(await u(o.assets.items,t),!o.assets.nextPage)break;r=parseInt(o.assets.nextPage,10)}}else{const e="No matching immich tags found or selected.";Lh.error(e)}}else{Lh.debug("Searching for assets based on albums");const n=(ah.immich_album_names||[]).map(e=>e.toLowerCase());Lh.debug("Fetching immich albums (shared=".concat(ah.immich_shared_albums,")"));const r=await e._immichFetch("".concat(a,"/server/version"),t);Lh.debug("Immich server version:",r);const i=r.major<3?"shared":"isShared",o=await e._immichFetch("".concat(a,"/albums?").concat(i,"=").concat(ah.immich_shared_albums),t);Lh.debug("Got immich API response",o);const s=o.filter(e=>{const t=!n.length||n.includes(e.albumName.toLowerCase());return Lh.debug("".concat(t?"Adding":"Skipping"," album: ").concat(e.albumName)),t});if(s.length>0)for(const n of s){Lh.debug("Fetching assets for album: ",n.albumName);let r=1;for(;;){const i=await e._immichFetch("".concat(a,"/search/metadata"),t,{method:"POST",body:JSON.stringify({albumIds:[n.id],withExif:!0,page:r})});if(Lh.debug("Got immich album assets (page ".concat(r,")"),i),await u(i.assets.items,t,n.albumName),!i.assets.nextPage)break;r=parseInt(i.assets.nextPage,10)}}else Lh.debug("No matching immich albums found or selected.")}!function(){if(0==r.length){const e="No matching media assets found";Lh.error(e)}r="random"==ah.media_order?Fh(r):"random_but_synced"==ah.media_order?Fh(r.slice().sort(),Uh(Dh)):r.sort(),r.length>ah.media_list_max_size&&(Lh.info("Using only ".concat(ah.media_list_max_size," of ").concat(r.length," media items")),r=r.slice(0,ah.media_list_max_size)),r.forEach(e=>{mh(e,i[e])}),e.mediaList=r}()}catch(e){throw Lh.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,a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];ah.force_load_media_with_fetch&&(a=!0);const o=(e,n)=>{const r=new Error("Failed to load ".concat(e.tagName,' "').concat(t,'": HTTP ').concat(n.status," ").concat(n.statusText).trim());return r.response={url:n.url,status:n.status,statusText:n.statusText,type:n.type},r},s=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 s=new Promise((i,a)=>{const o=()=>{e.onerror=null,e.removeEventListener(r,s)},s=async()=>{if(o(),"img"===n&&"function"==typeof e.decode)try{await e.decode()}catch(e){Lh.debug('Failed to pre-decode loaded image "'.concat(t,'":'),e)}i()};e.addEventListener(r,s),e.onerror=()=>{o();const n=new Error("Failed to load ".concat(e.tagName,' "').concat(t,'"'));n.mediaElement={tagName:e.tagName,currentSrc:e.currentSrc||e.src||"",complete:e.complete,naturalWidth:e.naturalWidth,naturalHeight:e.naturalHeight,readyState:e.readyState,networkState:e.networkState},e.error&&(n.mediaElement.error={code:e.error.code,message:e.error.message}),a(n)}});if(a)if(i=i||{},ah.stream_load_media){const n=await fetch(t,{headers:i});if(!n.ok)throw o(e,n);if(!n.body)throw new Error("Failed to load ".concat(e.tagName,' "').concat(t,'": empty body'));const r=n.body.getReader(),a=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()})}()}),s=await new Response(a).blob();"string"==typeof e.src&&e.src.startsWith("blob:")&&URL.revokeObjectURL(e.src),e.src=URL.createObjectURL(s)}else{const n=await fetch(t,{headers:i});if(Lh.debug("Got respone",n),!n.ok)throw o(e,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 s},c=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 s(i),i}catch(e){throw r||e}},u=async(e,t)=>{try{return await s(e),e}catch(n){if(t)return await c(e,null,n);throw n}};return r?r===e.tagName.toLowerCase()?await u(e,!1):await c(e,r):await u(e,!0)}getNextMediaURL(){let e,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.mediaList.length?("random_but_synced"==ah.media_order?e=Math.floor(Date.now()/(1e3*ah.display_time))%this.mediaList.length:(e=this.mediaIndex,"forwards"==this.mediaListDirection?e++:e--,e>=this.mediaList.length?("random_path"==ah.media_order&&t&&this.selectNextMediaPath(),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 a=n.url;return a.startsWith("http://")||a.startsWith("https://")||(a="".concat(document.location.origin).concat(a)),Lh.debug("Setting image src: ".concat(a)),e.mediaUrl=a,await this.updateMediaFromUrl(e,e.mediaUrl,i)}async updateMediaFromImmichAPI(e){const t=fh.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 a(){"media_exif"in i.attributes?mh(e.infoCacheUrl,i.attributes.media_exif):mh(e.infoCacheUrl,i.attributes)}if(gh=i.state,"video"==n)return e.infoCacheUrl=e.mediaUrl,a(),(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 a=i.currentTarget;a.removeEventListener("load",e),await a.updateComplete;const[o,s]=Nh(a);if(!o||!s)return r++,r<=20?void setTimeout(()=>e(i),100):void n(new Error("Failed to initialize camera stream player"));if(o.style.height="100%",s.autoplay=!1,s.muted=!1,s.volume=ah.video_volume,s.style.maxHeight="100%",s.style.height="100%",s.readyState>=s.HAVE_ENOUGH_DATA)t(a);else{const e=()=>{s.removeEventListener("canplay",e),t(a)};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,a(),await this.updateMediaFromUrl(e,e.mediaUrl,"img",null,!0)}}async updateMediaFromUnsplashAPI(e){const t=fh.get(e.mediaUrl);return e.mediaUrl=this.fillPlaceholders(e.mediaUrl),t&&mh(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(ah.show_images){this.updatingMedia=!0,e.style.visibility="hidden";try{if(e==this.getActiveMediaElement()){const e=this.getInactiveMediaElement();if("video"===e.tagName.toLowerCase())try{e.pause()}catch(e){Lh.debug(e)}else if("ha-camera-stream"===e.tagName.toLowerCase())try{const[t,n]=Nh(e);n&&n.pause(),t&&"function"==typeof t.stop&&t.stop()}catch(e){Lh.debug(e)}}if(e.mediaUrl=this.getNextMediaURL(),!e.mediaUrl)return;if(e.infoCacheUrl=e.mediaUrl,e="media-source"==qh()?await this.updateMediaFromMediaSource(e):"unsplash-api"==qh()?await this.updateMediaFromUnsplashAPI(e):"immich-api"==qh()?await this.updateMediaFromImmichAPI(e):qh().startsWith("media-entity")?await this.updateMediaFromMediaEntity(e):"iframe"==qh()?await this.updateMediaFromMediaIframe(e):"embed"==qh()?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"===ah.image_background&&this.loadBackgroundImage(e),!t&&ah.show_image_info&&/.*\.jpe?g$/i.test(e.mediaUrl.split("?")[0].replace(/\/*$/,""))&&this.fetchEXIFInfo(e)}}catch(t){return Lh.error("Failed to update media from ".concat(e.mediaUrl,":"),t),null}finally{this.updatingMedia=!1}return e}}setMediaDimensions(){if(!ah.calculate_media_size)return;const e=this.getActiveMediaElement(),t=this.getActiveMediaElement(!0);if(Lh.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 a=!r||!i||r>=i?ah.image_fit_landscape:ah.image_fit_portrait;e.style.position="absolute",e.style.left="0px",e.style.top="0px",e.style.objectFit=a;const o=this.screensaverContainer.clientWidth,s=this.screensaverContainer.clientHeight;let c=s,u=o,l=0,h=0,d=0,f=0;if(Lh.debug("Available size is ".concat(o,"x").concat(s,", media size is ").concat(r,"x").concat(i)),r&&i){const e=o/r,t=s/i,n=o-r*t,m=s-i*e;Lh.debug("Diff is ".concat(n,"x").concat(m)),"contain"==a&&n=m?(Lh.debug("Using available width"),u=o,c=Math.floor(i*e),d="top"==ah.media_vertical_align?0:"bottom"==ah.media_vertical_align?s-c:Math.floor((c-s)/-2),l=Math.max(c-s,0)):(Lh.debug("Using available height"),c=s,u=Math.floor(r*t),f="left"==ah.media_horizontal_align?0:"right"==ah.media_horizontal_align?o-u:Math.floor((u-o)/-2),h=Math.max(u-o,0))}else"iframe"!==n&&"embed"!==n&&Lh.warn("Size not available for media element",t);Lh.debug("Setting dimensions: size=".concat(u,"x").concat(c," - position=").concat(f,"x").concat(d," - hidden=").concat(h,"x").concat(l)),e.style.width="".concat(u,"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",l)}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=ah.video_loop&&t.duration{if(this.getActiveMediaElement()===t){if(t.currentTime>ah.crossfade_time){t.duration-t.currentTime<=ah.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()&&Lh.error('Failed to play media "'.concat(e.mediaUrl,'" (src=').concat(t.src,"):"),r)})}async switchActiveMedia(e){if(this.updatingMedia)return void Lh.debug("Already switching media");this.afterFadeoutTimer&&(clearTimeout(this.afterFadeoutTimer),this.afterFadeoutTimer=null);const t=qh();if(t.startsWith("media-entity")){const t=ah.image_url.replace(/^media-entity-(image|video):\/\//,""),n=this.hass.states[t];if(!n)return void Lh.error('Media entity "'.concat(t,'" not available'));if(gh!=n.state)Lh.debug("Media entity ".concat(t," state has changed"));else{if("entity_update"==e)return;if("start"==e||"user_action"==e)Lh.debug("Media entity ".concat(t," state unchanged, but eventType = ").concat(e));else{if(!ah.media_entity_load_unchanged)return this.lastMediaUpdate=Date.now(),this.isPaused&&(this.mediaTimeElapsedBeforePause=0),void this.restartProgressBarAnimation();Lh.debug("Media entity ".concat(t," state unchanged, but media_entity_load_unchanged = true"))}}gh=n.state}this.lastMediaUpdate=Date.now(),this.isPaused&&(this.mediaTimeElapsedBeforePause=0);const n=this.getActiveMediaElement();if(("iframe"===t||"embed"===t)&&!ah.iframe_load_unchanged&&this.getNextMediaURL(!1)==n.mediaUrl)return;let r=0;"start"!=e&&(ah.crossfade_time>0&&(r=Math.round(1e3*ah.crossfade_time)),"user_action"==e&&r>250&&(r=250));const i=this.getInactiveMediaElement(),a=await this.updateMedia(i);a?(this.mediaLoadRetryAt=0,this._switchActiveMedia(a,r)):this.mediaLoadRetryAt=Date.now()+1e3}_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,a=this.imageTwo;e==this.imageOne&&(n=this.imageTwoContainer,r=this.imageOneContainer,i=this.imageTwo,a=this.imageOne),Lh.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"==a.tagName.toLowerCase()&&ah.iframe_interaction?a.style.pointerEvents="auto":a.style.pointerEvents="none",this.setMediaDataInfo(),this.setMediaDimensions(),this.setImageURLEntityState(),this.startPlayingActiveMedia(),this.restartProgressBarAnimation(),this.restartKenBurnsEffect();const o=this;this.afterFadeoutTimer=setTimeout(function(){o.afterFadeoutTimer=null,i===o.getInactiveMediaElement()&&o.releaseMediaElement(i)},t)}setupScreensaver(){Lh.debug("Setup screensaver"),ah.keep_screen_on_time>0&&!this.screenWakeLock.enabled&&this.screenWakeLock.enable(),ah.fullscreen&&!Jh()&&$h()}async startScreensaver(){if(Lh.debug("Start screensaver"),this.afterFadeoutTimer&&(clearTimeout(this.afterFadeoutTimer),this.afterFadeoutTimer=null),this.mediaLoadRetryAt=0,this.screensaverStartedAt=Date.now(),this.screensaverStoppedAt=null,this.currentWidth=this.screensaverContainer.clientWidth,this.currentHeight=this.screensaverContainer.clientHeight,this.setDefaultStyle(),Wh(),!Gh())return Lh.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(),ah.keep_screen_on_time>0){const e=this;setTimeout(function(){e.screensaverRunning()&&!e.screenWakeLock.enabled&&(Lh.warning("Keep screen on will not work because the user didn't interact with the document first. https://goo.gl/xX8pDD"),Rh("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(),(ah.screensaver_start_navigation_path||ah.screensaver_stop_close_browser_mod_popup)&&(this.screensaverStopNavigationPathTimeout=setTimeout(()=>{ah.screensaver_start_navigation_path&&(hh=!0,function(e){(!(arguments.length>1&&void 0!==arguments[1])||arguments[1])&&!e.includes("?")&&(e+=window.location.search),history.pushState(null,"",e),vh.dispatchEvent(new Event("location-changed",{bubbles:!0,cancelable:!1,composed:!0}))}(ah.screensaver_start_navigation_path),setTimeout(()=>{hh=!1},5e3)),ah.screensaver_stop_close_browser_mod_popup&&zh().forEach(e=>{e.closeDialog()})},1e3*(ah.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;Lh.debug("Stop screensaver"),this.afterFadeoutTimer&&(clearTimeout(this.afterFadeoutTimer),this.afterFadeoutTimer=null),this.mediaLoadRetryAt=0,this.screensaverStartedAt=null,this.screensaverStoppedAt=Date.now(),document.documentElement.style.removeProperty("overflow"),this.screensaverStopNavigationPathTimeout&&clearTimeout(this.screensaverStopNavigationPathTimeout),kh(),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();const t=this;this.afterFadeoutTimer=setTimeout(function(){t.afterFadeoutTimer=null,t.screensaverRunning()||t.releaseAllMedia()},Math.round(1e3*e)),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(),ah.info_move_interval>0&&t-this.lastMove>=1e3*ah.info_move_interval&&("random"===ah.info_move_pattern?this.randomMove():"corners"===ah.info_move_pattern?this.moveAroundCorners():Lh.error("Unknown info move type ".concat(ah.info_move_pattern))),ah.black_screen_after_time>0&&t-this.screensaverStartedAt>=1e3*ah.black_screen_after_time)Lh.debug("Setting screen to black"),this.screensaverOverlay.style.background="#000000";else if(ah.show_images){let e;e="random_but_synced"==ah.media_order?Math.floor(t/(1e3*ah.display_time))!=Math.floor(this.lastMediaUpdate/(1e3*ah.display_time)):t-this.lastMediaUpdate>=1e3*this.getDisplayTime();const n=this.mediaLoadRetryAt>0?t>=this.mediaLoadRetryAt:e;this.isPaused||this.updatingMedia||!n||this.switchActiveMedia("display_time_elapsed"),t-this.lastMediaListUpdate>=1e3*ah.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(ah.close_more_info_dialog_time>0){const e=this.getMoreInfoDialog();if(e){const t=new Date;this.moreInfoDialogOpenedAt?t-this.moreInfoDialogOpenedAt>=1e3*ah.close_more_info_dialog_time&&e.close():this.moreInfoDialogOpenedAt=t}else this.moreInfoDialogOpenedAt=0}if(ah.debug){let e="";const t={};for(const e in ah)["profiles"].includes(e)?t[e]="...":t[e]=ah[e];if(e+='
Download log
',e+="Version: ".concat(th,"
"),e+="User-Agent: ".concat(navigator.userAgent,"
"),e+="Config: ".concat(JSON.stringify(t),"
"),e+="Fullscreen: ".concat(Jh(),"
"),e+="Screensaver started at: ".concat(lh.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=fh.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){Lh.downloadMessages(),e.preventDefault()})),this.debugBox.scrollTop=this.debugBox.scrollHeight}this.screenWakeLock.enabled&&ah.keep_screen_on_time>0&&t-this.screensaverStartedAt>=1e3*ah.keep_screen_on_time&&(Lh.info("Disable wake lock after ".concat(ah.keep_screen_on_time," seconds")),this.screenWakeLock.disable())}switchMediaDirection(e){this.mediaListDirection=e,this.switchActiveMedia("user_action")}async nextImage(){if(this.updatingMedia)return void Lh.debug("Already switching media");Lh.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 Lh.debug("Already switching media");Lh.debug("Previous image");const e=this.mediaListDirection;this.mediaListDirection="backwards";try{await this.switchActiveMedia("user_action")}finally{this.mediaListDirection=e}}togglePlayPause(){if(Lh.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=ah.camera_motion_detection_set_entity;t&&this.__hass.states[t]&&(Lh.debug("Updating camera motion detection entity",t,e),this.__hass.callService("input_boolean",e?"turn_on":"turn_off",{entity_id:t}).then(e=>{Lh.debug(e)},e=>{Lh.error("Failed to set camera motion detection entity state:",e)}))}motionDetected(){ah.camera_motion_detection_stop_screensaver&&this.screensaverRunning()&&this.stopScreensaver(ah.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&&kh())return void(this.blockEventsUntil=n+1e3);let i=e.clientX,a=e.clientY;if(!i&&e.changedTouches&&e.changedTouches[0]&&(i=e.changedTouches[0].clientX),!a&&e.changedTouches&&e.changedTouches[0]&&(a=e.changedTouches[0].clientY),ah.debug&&i&&i<100&&a&&a<100)return;const o=Hh();if(o){const e=[o.shadowRoot.querySelector(".content"),o.shadowRoot.querySelector("ha-dialog-header")];for(let t=0;t=n.left&&i<=n.right&&a>=n.top&&a<=n.bottom)return void Lh.debug("Event on browser mod popup:",e[t])}}if(ah.iframe_interaction&&"iframe"==qh())return;if(ah.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"==ah.image_info_template&&(e.push(this.imageOneInfo),e.push(this.imageTwoInfo));for(let t=0;t=n.left&&i<=n.right&&a>=n.top&&a<=n.bottom)return void Lh.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 o=this.screensaverContainer.getBoundingClientRect();if(i&&(n=(o.right-i)/this.screensaverContainer.clientWidth),a&&(r=(o.bottom-a)/this.screensaverContainer.clientHeight),Lh.debug("Event position screensaver:",i,a,o.left,o.right,o.top,o.bottom),r>1||r<0||n>1||n<0)return;if(t&&e.preventDefault(),e.stopImmediatePropagation(),ah.touch_zone_size_next_image>0&&n<=ah.touch_zone_size_next_image/100){if(!t)return;s="forwards"}else if(ah.touch_zone_size_previous_image>0&&n>=(100-ah.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&&(Lh.purgeMessages(),ah.debug=!ah.debug,this.debugBox.style.visibility=ah.debug?"visible":"hidden",this.debugBox.style.pointerEvents=ah.debug?"auto":"none")):this.clickCount=1,void(this.lastClickTime=e)}}s?this.updatingMedia?Lh.debug("Already switching media"):(Lh.debug("Switching media, direction ".concat(s)),this.mediaListDirection!=s?this.switchMediaDirection(s):this.switchActiveMedia("user_action")):t&&!ah.stop_screensaver_on_mouse_click||(this.blockEventsUntil=n+1e3*ah.control_reactivation_time,this.stopScreensaver(ah.fade_out_time_interaction))}}customElements.get("wallpanel-view-container")||customElements.define("wallpanel-view-container",r),customElements.get("wallpanel-view")||customElements.define("wallpanel-view",i),uh=document.createElement("wallpanel-view-container"),lh=document.createElement("wallpanel-view"),uh.appendChild(lh),yh.shadowRoot.appendChild(uh)}function Kh(){Lh.debug("activateWallpanel");let e=ah.hide_toolbar,t=ah.hide_toolbar_action_icons;if(e&&!ah.hide_toolbar_on_subviews&&ch){const n=Yh();if(n&&n.lovelace&&n.lovelace.rawConfig&&n.lovelace.rawConfig.views)for(let r=0;r{Lh.debug("Successfully exited fullscreen")},e=>{Lh.debug("Failed to exit fullscreen:",e)}):document.mozCancelFullScreen?document.mozCancelFullScreen():document.msRequestFullscreen?document.msRequestFullscreen():document.webkitExitFullscreen&&document.webkitExitFullscreen())}function td(){sh&&ch?(Wh(),Gh()?Kh():ed()):ed()}function nd(){if(Lh.debug("Location changed from '".concat(oh,"' to '").concat(window.location.href,"'")),window.location.href==oh)return;oh=window.location.href,lh&&lh.screensaverRunning&&lh.screensaverRunning()&&ah.stop_screensaver_on_location_change&&(hh?(hh=!1,lh.screensaverStopNavigationPathTimeout&&clearTimeout(lh.screensaverStopNavigationPathTimeout)):lh.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=sh&&e!=sh;sh=e,ch=t,r?(Lh.debug("Reset dashboard config"),ih={},rd(td)):td()}function rd(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(vh=document.querySelector("body > home-assistant"),vh&&vh.shadowRoot&&(yh=vh.shadowRoot.querySelector("home-assistant-main")),!vh||!vh.shadowRoot||!yh)return r>=5?void Lh.error("Wallpanel startup failed after ".concat(r," seconds, element home-assistant / home-assistant-main not found.")):void setTimeout(rd,100,e,t);const i=Yh();if(!(i&&i.lovelace&&i.lovelace.config&&i.lovelace.config))return r>=5?void Lh.info("No lovelace config found after ".concat(r," seconds")):void setTimeout(rd,100,e,t);if(!customElements.get("hui-view"))return r>=5?void Lh.error("Wallpanel startup failed after ".concat(r," seconds, hui-view not found.")):void setTimeout(rd,100,e,t);if(!window.browser_mod){let n=Vh(["wait_for_browser_mod_time"]).wait_for_browser_mod_time;if(void 0===n&&(n=nh.wait_for_browser_mod_time),r{let t=null;try{t=e.target.location.href}catch(e){Lh.debug(e)}Lh.debug("location-changed",t,e),setTimeout(nd,20)}),window.navigation&&window.navigation.addEventListener("navigate",e=>{let t=null;try{t=e.destination.url}catch(e){Lh.debug(e)}Lh.debug("navigate",t,e),setTimeout(nd,30)}),(vh.hass||vh.__hass).connection.subscribeEvents(function(e){Lh.debug("lovelace_updated",e),(e.data.url_path?e.data.url_path:"lovelace")==sh&&(vh.hass||vh.__hass).connection.sendMessagePromise({type:"lovelace/config",url_path:e.data.url_path}).then(e=>{if(ih={},e.wallpanel)for(const t in e.wallpanel)(t in nh||t in rh)&&(ih[t]=e.wallpanel[t]);td()})},"lovelace_updated"),setTimeout(nd,0)})}catch(e){Lh.error(e.stack)}var id=!1,ad=function(e){return e instanceof ad?e:this instanceof ad?void(this.EXIFwrapped=e):new ad(e)},od=ad.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"},sd=ad.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"},cd=ad.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"},ud=ad.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"},ld=ad.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 hd(e){return!!e.exifdata}function dd(e,t){function n(n){var r=fd(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,u=(s=s.substring(s.indexOf("4?f:t+8,o=[],c=0;c4?f:t+8,d-1);case 3:if(1==d)return e.getUint16(t+8,!i);for(a=d>2?f:t+8,o=[],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:a=e[n++],t+=String.fromCharCode((31&i)<<6|63&a);break;case 14:a=e[n++],o=e[n++],t+=String.fromCharCode((15&i)<<12|(63&a)<<6|63&o)}return t}(r)}function Ad(e,t){if("Exif"!=yd(e,t,4))return!1;var n,r,i,a,o,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=gd(e,s,s+c,sd,n)).ExifIFDPointer)for(i in a=gd(e,s,s+r.ExifIFDPointer,od,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":a[i]=ld[i][a[i]];break;case"ExifVersion":case"FlashpixVersion":a[i]=String.fromCharCode(a[i][0],a[i][1],a[i][2],a[i][3]);break;case"ComponentsConfiguration":a[i]=ld.Components[a[i][0]]+ld.Components[a[i][1]]+ld.Components[a[i][2]]+ld.Components[a[i][3]]}r[i]=a[i]}if(r.GPSInfoIFDPointer)for(i in o=gd(e,s,s+r.GPSInfoIFDPointer,cd,n)){if("GPSVersionID"==i)try{o[i]=o[i][0]+"."+o[i][1]+"."+o[i][2]+"."+o[i][3]}catch(e){}r[i]=o[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 a=gd(e,t,t+i,ud,r);if(a.Compression)switch(a.Compression){case 6:if(a.JpegIFOffset&&a.JpegIFByteCount){var o=t+a.JpegIFOffset,s=a.JpegIFByteCount;a.blob=new Blob([new Uint8Array(e.buffer,o,s)],{type:"image/jpeg"})}break;case 1:Lh.log("Thumbnail image format is TIFF, which is not implemented.");break;default:Lh.log("Unknown thumbnail image format '%s'",a.Compression)}else 2==a.PhotometricInterpretation&&Lh.log("Thumbnail image format is RGB, which is not implemented.");return a}(e,s,c,n),r}function _d(e){var t={};if(1==e.nodeType){if(e.attributes.length>0){t["@attributes"]={};for(var n=0;n0)for(var n=0;n