iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
275 lines (270 loc) • 87.1 kB
JavaScript
function e(e,t,i,s){var o,a=arguments.length,n=a<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,s);else for(var r=e.length-1;r>=0;r--)(o=e[r])&&(n=(a<3?o(n):a>3?o(t,i,n):o(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n}"function"==typeof SuppressedError&&SuppressedError;const t=globalThis,i=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),o=new WeakMap;let a=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(i&&void 0===e){const i=void 0!==t&&1===t.length;i&&(e=o.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&o.set(t,e))}return e}toString(){return this.cssText}};const n=(e,...t)=>{const i=1===e.length?e[0]:t.reduce((t,i,s)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[s+1],e[0]);return new a(i,e,s)},r=i?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return(e=>new a("string"==typeof e?e:e+"",void 0,s))(t)})(e):e,{is:l,defineProperty:d,getOwnPropertyDescriptor:c,getOwnPropertyNames:h,getOwnPropertySymbols:u,getPrototypeOf:p}=Object,b=globalThis,g=b.trustedTypes,m=g?g.emptyScript:"",_=b.reactiveElementPolyfillSupport,w=(e,t)=>e,v={toAttribute(e,t){switch(t){case Boolean:e=e?m:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=null!==e;break;case Number:i=null===e?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch(e){i=null}}return i}},f=(e,t)=>!l(e,t),y={attribute:!0,type:String,converter:v,reflect:!1,useDefault:!1,hasChanged:f};Symbol.metadata??=Symbol("metadata"),b.litPropertyMetadata??=new WeakMap;let $=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=y){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(e,i,t);void 0!==s&&d(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){const{get:s,set:o}=c(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:s,set(t){const a=s?.call(this);o?.call(this,t),this.requestUpdate(e,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??y}static _$Ei(){if(this.hasOwnProperty(w("elementProperties")))return;const e=p(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(w("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(w("properties"))){const e=this.properties,t=[...h(e),...u(e)];for(const i of t)this.createProperty(i,e[i])}const e=this[Symbol.metadata];if(null!==e){const t=litPropertyMetadata.get(e);if(void 0!==t)for(const[e,i]of t)this.elementProperties.set(e,i)}this._$Eh=new Map;for(const[e,t]of this.elementProperties){const i=this._$Eu(e,t);void 0!==i&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const e of i)t.unshift(r(e))}else void 0!==e&&t.push(r(e));return t}static _$Eu(e,t){const i=t.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof e?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),void 0!==this.renderRoot&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((e,s)=>{if(i)e.adoptedStyleSheets=s.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const i of s){const s=document.createElement("style"),o=t.litNonce;void 0!==o&&s.setAttribute("nonce",o),s.textContent=i.cssText,e.appendChild(s)}})(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$ET(e,t){const i=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,i);if(void 0!==s&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:v).toAttribute(t,i.type);this._$Em=e,null==o?this.removeAttribute(s):this.setAttribute(s,o),this._$Em=null}}_$AK(e,t){const i=this.constructor,s=i._$Eh.get(e);if(void 0!==s&&this._$Em!==s){const e=i.getPropertyOptions(s),o="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==e.converter?.fromAttribute?e.converter:v;this._$Em=s;const a=o.fromAttribute(t,e.type);this[s]=a??this._$Ej?.get(s)??a,this._$Em=null}}requestUpdate(e,t,i){if(void 0!==e){const s=this.constructor,o=this[e];if(i??=s.getPropertyOptions(e),!((i.hasChanged??f)(o,t)||i.useDefault&&i.reflect&&o===this._$Ej?.get(e)&&!this.hasAttribute(s._$Eu(e,i))))return;this.C(e,t,i)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:s,wrapped:o},a){i&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,a??t??this[e]),!0!==o||void 0!==a)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),!0===s&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}const e=this.constructor.elementProperties;if(e.size>0)for(const[t,i]of e){const{wrapped:e}=i,s=this[t];!0!==e||this._$AL.has(t)||void 0===s||this.C(t,void 0,i,s)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(e=>e.hostUpdate?.()),this.update(t)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(e){}firstUpdated(e){}};$.elementStyles=[],$.shadowRootOptions={mode:"open"},$[w("elementProperties")]=new Map,$[w("finalized")]=new Map,_?.({ReactiveElement:$}),(b.reactiveElementVersions??=[]).push("2.1.1");const S=globalThis,x=S.trustedTypes,A=x?x.createPolicy("lit-html",{createHTML:e=>e}):void 0,E="$lit$",C=`lit$${Math.random().toFixed(9).slice(2)}$`,k="?"+C,P=`<${k}>`,O=document,U=()=>O.createComment(""),D=e=>null===e||"object"!=typeof e&&"function"!=typeof e,T=Array.isArray,R="[ \t\n\f\r]",H=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,M=/-->/g,I=/>/g,j=RegExp(`>|${R}(?:([^\\s"'>=/]+)(${R}*=${R}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),B=/'/g,N=/"/g,L=/^(?:script|style|textarea|title)$/i,K=(e=>(t,...i)=>({_$litType$:e,strings:t,values:i}))(1),z=Symbol.for("lit-noChange"),F=Symbol.for("lit-nothing"),q=new WeakMap,W=O.createTreeWalker(O,129);function J(e,t){if(!T(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==A?A.createHTML(t):t}const V=(e,t)=>{const i=e.length-1,s=[];let o,a=2===t?"<svg>":3===t?"<math>":"",n=H;for(let t=0;t<i;t++){const i=e[t];let r,l,d=-1,c=0;for(;c<i.length&&(n.lastIndex=c,l=n.exec(i),null!==l);)c=n.lastIndex,n===H?"!--"===l[1]?n=M:void 0!==l[1]?n=I:void 0!==l[2]?(L.test(l[2])&&(o=RegExp("</"+l[2],"g")),n=j):void 0!==l[3]&&(n=j):n===j?">"===l[0]?(n=o??H,d=-1):void 0===l[1]?d=-2:(d=n.lastIndex-l[2].length,r=l[1],n=void 0===l[3]?j:'"'===l[3]?N:B):n===N||n===B?n=j:n===M||n===I?n=H:(n=j,o=void 0);const h=n===j&&e[t+1].startsWith("/>")?" ":"";a+=n===H?i+P:d>=0?(s.push(r),i.slice(0,d)+E+i.slice(d)+C+h):i+C+(-2===d?t:h)}return[J(e,a+(e[i]||"<?>")+(2===t?"</svg>":3===t?"</math>":"")),s]};class G{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let o=0,a=0;const n=e.length-1,r=this.parts,[l,d]=V(e,t);if(this.el=G.createElement(l,i),W.currentNode=this.el.content,2===t||3===t){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(s=W.nextNode())&&r.length<n;){if(1===s.nodeType){if(s.hasAttributes())for(const e of s.getAttributeNames())if(e.endsWith(E)){const t=d[a++],i=s.getAttribute(e).split(C),n=/([.?@])?(.*)/.exec(t);r.push({type:1,index:o,name:n[2],strings:i,ctor:"."===n[1]?ee:"?"===n[1]?te:"@"===n[1]?ie:Q}),s.removeAttribute(e)}else e.startsWith(C)&&(r.push({type:6,index:o}),s.removeAttribute(e));if(L.test(s.tagName)){const e=s.textContent.split(C),t=e.length-1;if(t>0){s.textContent=x?x.emptyScript:"";for(let i=0;i<t;i++)s.append(e[i],U()),W.nextNode(),r.push({type:2,index:++o});s.append(e[t],U())}}}else if(8===s.nodeType)if(s.data===k)r.push({type:2,index:o});else{let e=-1;for(;-1!==(e=s.data.indexOf(C,e+1));)r.push({type:7,index:o}),e+=C.length-1}o++}}static createElement(e,t){const i=O.createElement("template");return i.innerHTML=e,i}}function Y(e,t,i=e,s){if(t===z)return t;let o=void 0!==s?i._$Co?.[s]:i._$Cl;const a=D(t)?void 0:t._$litDirective$;return o?.constructor!==a&&(o?._$AO?.(!1),void 0===a?o=void 0:(o=new a(e),o._$AT(e,i,s)),void 0!==s?(i._$Co??=[])[s]=o:i._$Cl=o),void 0!==o&&(t=Y(e,o._$AS(e,t.values),o,s)),t}class Z{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:i}=this._$AD,s=(e?.creationScope??O).importNode(t,!0);W.currentNode=s;let o=W.nextNode(),a=0,n=0,r=i[0];for(;void 0!==r;){if(a===r.index){let t;2===r.type?t=new X(o,o.nextSibling,this,e):1===r.type?t=new r.ctor(o,r.name,r.strings,this,e):6===r.type&&(t=new se(o,this,e)),this._$AV.push(t),r=i[++n]}a!==r?.index&&(o=W.nextNode(),a++)}return W.currentNode=O,s}p(e){let t=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class X{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=F,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=s?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e?.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=Y(this,e,t),D(e)?e===F||null==e||""===e?(this._$AH!==F&&this._$AR(),this._$AH=F):e!==this._$AH&&e!==z&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>T(e)||"function"==typeof e?.[Symbol.iterator])(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==F&&D(this._$AH)?this._$AA.nextSibling.data=e:this.T(O.createTextNode(e)),this._$AH=e}$(e){const{values:t,_$litType$:i}=e,s="number"==typeof i?this._$AC(e):(void 0===i.el&&(i.el=G.createElement(J(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(t);else{const e=new Z(s,this),i=e.u(this.options);e.p(t),this.T(i),this._$AH=e}}_$AC(e){let t=q.get(e.strings);return void 0===t&&q.set(e.strings,t=new G(e)),t}k(e){T(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const o of e)s===t.length?t.push(i=new X(this.O(U()),this.O(U()),this,this.options)):i=t[s],i._$AI(o),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){void 0===this._$AM&&(this._$Cv=e,this._$AP?.(e))}}class Q{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,o){this.type=1,this._$AH=F,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=o,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=F}_$AI(e,t=this,i,s){const o=this.strings;let a=!1;if(void 0===o)e=Y(this,e,t,0),a=!D(e)||e!==this._$AH&&e!==z,a&&(this._$AH=e);else{const s=e;let n,r;for(e=o[0],n=0;n<o.length-1;n++)r=Y(this,s[i+n],t,n),r===z&&(r=this._$AH[n]),a||=!D(r)||r!==this._$AH[n],r===F?e=F:e!==F&&(e+=(r??"")+o[n+1]),this._$AH[n]=r}a&&!s&&this.j(e)}j(e){e===F?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class ee extends Q{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===F?void 0:e}}class te extends Q{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==F)}}class ie extends Q{constructor(e,t,i,s,o){super(e,t,i,s,o),this.type=5}_$AI(e,t=this){if((e=Y(this,e,t,0)??F)===z)return;const i=this._$AH,s=e===F&&i!==F||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,o=e!==F&&(i===F||s);s&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}}class se{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){Y(this,e)}}const oe=S.litHtmlPolyfillSupport;oe?.(G,X),(S.litHtmlVersions??=[]).push("3.3.1");const ae=globalThis;let ne=class extends ${constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=((e,t,i)=>{const s=i?.renderBefore??t;let o=s._$litPart$;if(void 0===o){const e=i?.renderBefore??null;s._$litPart$=o=new X(t.insertBefore(U(),e),e,void 0,i??{})}return o._$AI(e),o})(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return z}};ne._$litElement$=!0,ne.finalized=!0,ae.litElementHydrateSupport?.({LitElement:ne});const re=ae.litElementPolyfillSupport;re?.({LitElement:ne}),(ae.litElementVersions??=[]).push("4.2.1");const le={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:f},de=(e=le,t,i)=>{const{kind:s,metadata:o}=i;let a=globalThis.litPropertyMetadata.get(o);if(void 0===a&&globalThis.litPropertyMetadata.set(o,a=new Map),"setter"===s&&((e=Object.create(e)).wrapped=!0),a.set(i.name,e),"accessor"===s){const{name:s}=i;return{set(i){const o=t.get.call(this);t.set.call(this,i),this.requestUpdate(s,o,e)},init(t){return void 0!==t&&this.C(s,void 0,e,t),t}}}if("setter"===s){const{name:s}=i;return function(i){const o=this[s];t.call(this,i),this.requestUpdate(s,o,e)}}throw Error("Unsupported decorator location: "+s)};function ce(e){return(t,i)=>"object"==typeof i?de(e,t,i):((e,t,i)=>{const s=t.hasOwnProperty(i);return t.constructor.createProperty(i,e),s?Object.getOwnPropertyDescriptor(t,i):void 0})(e,t,i)}function he(e){return ce({...e,state:!0,attribute:!1})}var ue;const pe=new WeakMap,be=()=>{};ue=Symbol.toStringTag;let ge=class e{constructor(e){this.subscribers=[],this.settlement=null,this[ue]="Unpromise",this.promise="function"==typeof e?new Promise(e):e;const t=this.promise.then(e=>{const{subscribers:t}=this;this.subscribers=null,this.settlement={status:"fulfilled",value:e},null==t||t.forEach(({resolve:t})=>{t(e)})});"catch"in t&&t.catch(e=>{const{subscribers:t}=this;this.subscribers=null,this.settlement={status:"rejected",reason:e},null==t||t.forEach(({reject:t})=>{t(e)})})}subscribe(){let e,t;const{settlement:i}=this;if(null===i){if(null===this.subscribers)throw new Error("Unpromise settled but still has subscribers");const i=function(){let e,t;return{promise:new Promise((i,s)=>{e=i,t=s}),resolve:e,reject:t}}();this.subscribers=function(e,t){return[...e,t]}(this.subscribers,i),e=i.promise,t=()=>{null!==this.subscribers&&(this.subscribers=function(e,t){const i=e.indexOf(t);return-1!==i?function(e,t){return[...e.slice(0,t),...e.slice(t+1)]}(e,i):e}(this.subscribers,i))}}else{const{status:s}=i;e="fulfilled"===s?Promise.resolve(i.value):Promise.reject(i.reason),t=be}return Object.assign(e,{unsubscribe:t})}then(e,t){const i=this.subscribe(),{unsubscribe:s}=i;return Object.assign(i.then(e,t),{unsubscribe:s})}catch(e){const t=this.subscribe(),{unsubscribe:i}=t;return Object.assign(t.catch(e),{unsubscribe:i})}finally(e){const t=this.subscribe(),{unsubscribe:i}=t;return Object.assign(t.finally(e),{unsubscribe:i})}static proxy(t){const i=e.getSubscribablePromise(t);return typeof i<"u"?i:e.createSubscribablePromise(t)}static createSubscribablePromise(t){const i=new e(t);return pe.set(t,i),pe.set(i,i),i}static getSubscribablePromise(e){return pe.get(e)}static resolve(t){const i="object"==typeof t&&null!==t&&"then"in t&&"function"==typeof t.then?t:Promise.resolve(t);return e.proxy(i).subscribe()}static async any(t){const i=(Array.isArray(t)?t:[...t]).map(e.resolve);try{return await Promise.any(i)}finally{i.forEach(({unsubscribe:e})=>{e()})}}static async race(t){const i=(Array.isArray(t)?t:[...t]).map(e.resolve);try{return await Promise.race(i)}finally{i.forEach(({unsubscribe:e})=>{e()})}}static async raceReferences(e){const t=e.map(me);try{return await Promise.race(t)}finally{for(const e of t)e.unsubscribe()}}};function me(e){return ge.proxy(e).then(()=>[e])}const _e="SELECTTREE-TIMEOUT";async function we(e,t=!1){var i;if((null===(i=e.localName)||void 0===i?void 0:i.includes("-"))&&await customElements.whenDefined(e.localName),e.updateComplete&&await e.updateComplete,t&&(e.pageRendered&&await e.pageRendered,e._panelState)){let t=0;for(;"loaded"!==e._panelState&&t++<5;)await new Promise(e=>setTimeout(e,100))}}async function ve(e,t,i=!1){let s=[e];for("string"==typeof t&&(t=t.split(/(\$| )/));""===t[t.length-1];)t.pop();for(const[e,i]of t.entries()){const e=s[0];if(!e)return null;i.trim().length&&(we(e),s="$"===i?[e.shadowRoot]:e.querySelectorAll(i))}return i?s:s[0]}async function fe(e,t,i=!1,s=1e4){return ge.race([ve(e,t,i),new Promise((e,t)=>setTimeout(()=>t(new Error(_e)),s))]).catch(e=>{if(!e.message||e.message!==_e)throw e;return null})}async function ye(){var e;void 0===(null!==(e=customElements.get("home-assistant"))&&void 0!==e?e:customElements.get("hc-main"))&&await ge.race([customElements.whenDefined("home-assistant"),customElements.whenDefined("hc-main")]);const t=customElements.get("home-assistant")?"home-assistant":"hc-main";for(;!document.querySelector(t);)await new Promise(e=>window.setTimeout(e,100));return document.querySelector(t)}function $e(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(!(e instanceof Object&&t instanceof Object))return!1;for(const i in e)if(e.hasOwnProperty(i)){if(!t.hasOwnProperty(i))return!1;if(e[i]!==t[i]){if("object"!=typeof e[i])return!1;if(!$e(e[i],t[i]))return!1}}for(const i in t)if(t.hasOwnProperty(i)&&!e.hasOwnProperty(i))return!1;return!0}const Se="ha-adaptive-dialog {\n --ha-bottom-sheet-height: calc(\n 100vh - max(var(--safe-area-inset-top), 100vh / 3)\n );\n --ha-bottom-sheet-height: calc(\n 100dvh - max(var(--safe-area-inset-top), 100dvh / 3)\n );\n --ha-bottom-sheet-max-height: var(--ha-bottom-sheet-height);\n }";let xe=class extends ne{constructor(){super(...arguments),this.dirty=!1,this.narrow=!1}toggleRegister(){var e;(null===(e=window.browser_mod)||void 0===e?void 0:e.ready)&&(window.browser_mod.registered=!window.browser_mod.registered,this.dirty=!0)}toggleCameraEnabled(){window.browser_mod.cameraEnabled=!window.browser_mod.cameraEnabled,this.dirty=!0}toggleGo2rtcEnabled(){window.browser_mod.go2rtcEnabled=!window.browser_mod.go2rtcEnabled,this.dirty=!0}toggleSyncSession(){window.browser_mod.syncSession=!window.browser_mod.syncSession,this.requestUpdate()}firstUpdated(){window.browser_mod.addEventListener("browser-mod-config-update",()=>this.requestUpdate())}render(){var e,t,i,s,o,a,n,r,l,d,c,h,u,p,b,g,m,_,w,v;return K`
<ha-card outlined>
<h1 class="card-header">
<div class="name">This Browser</div>
${(null===(e=window.browser_mod)||void 0===e?void 0:e.ready)?K`
<ha-icon
class="icon"
.icon=${"mdi:check-circle-outline"}
style="color: var(--success-color, green);"
></ha-icon>
`:K`
<ha-icon
class="icon"
.icon=${"mdi:circle-outline"}
style="color: var(--error-color, red);"
></ha-icon>
`}
</h1>
<div class="card-content">
${this.dirty?K`
<ha-alert alert-type="warning">
It is strongly recommended to refresh your browser window
after changing any of the settings in this box.
</ha-alert>
`:""}
</div>
<div class="card-content">
${(null===(t=this.hass.user)||void 0===t?void 0:t.is_admin)?"":K`
<ha-alert alert-type="info" title="Login as admin to edit">
Login as admin to change the settings of this Browser.
<br /><br />
You can set auto-register as admin on another Browser
to register this Browser automatically. You can then either
use <i>browser_mod.change_browser_id</i> service or login
as admin on this Browser to change the Browser ID.
</ha-alert>
`}
</div>
<div class="card-content">
<ha-md-list-item>
<span slot="headline">Register</span>
<span slot="supporting-text"
>Enable this browser as a Device in Home Assistant</span
>
<ha-switch
slot="end"
.checked=${null===(i=window.browser_mod)||void 0===i?void 0:i.registered}
@change=${this.toggleRegister}
.disabled=${(null===(s=window.browser_mod)||void 0===s?void 0:s.browser_locked)||(null===(o=window.browser_mod)||void 0===o?void 0:o.global_settings.autoRegister)||(null===(a=window.browser_mod)||void 0===a?void 0:a.global_settings.lockRegister)||!(null===(n=this.hass.user)||void 0===n?void 0:n.is_admin)}
></ha-switch>
</ha-md-list-item>
<ha-md-list-item ?narrow=${this.narrow}>
<span slot="headline">Browser ID</span>
<span slot="supporting-text"
>A unique identifier for this browser-device combination.</span
>
<ha-form
slot="end"
.hass=${this.hass}
.schema=${[{name:"browser_id",label:"Browser ID",helper:"Select an existing known Browser ID or enter new",required:!0,selector:{select:{sort:!0,custom_value:!0,mode:"dropdown",options:Object.keys(null===(r=window.browser_mod)||void 0===r?void 0:r.browsers)||[]}}}]}
.computeLabel=${e=>{var t;return null!==(t=e.label)&&void 0!==t?t:e.name}}
.computeHelper=${e=>{var t;return null!==(t=e.helper)&&void 0!==t?t:""}}
.data=${{browser_id:null===(l=window.browser_mod)||void 0===l?void 0:l.browserID}}
.disabled=${(null===(d=window.browser_mod)||void 0===d?void 0:d.browser_locked)||!(null===(c=this.hass.user)||void 0===c?void 0:c.is_admin)}
@value-changed=${e=>{var t;const i=e.detail.value.browser_id;i&&i!==(null===(t=window.browser_mod)||void 0===t?void 0:t.browserID)&&(window.browser_mod.browserID=i,this.dirty=!0)}}
>
</ha-form>
</ha-md-list-item>
<ha-md-list-item>
<span slot="headline">Sync Browser ID to login session</span>
<span slot="supporting-text"
>Store this Browser ID against your current login session.
Allows the Browser ID to be recalled if local storage is
cleared.</span
>
<ha-switch
slot="end"
.checked=${null===(h=window.browser_mod)||void 0===h?void 0:h.syncSession}
@change=${this.toggleSyncSession}
.disabled=${null===(u=window.browser_mod)||void 0===u?void 0:u.browser_locked}
></ha-switch>
</ha-md-list-item>
${(null===(p=window.browser_mod)||void 0===p?void 0:p.registered)?K`
${this._renderSuspensionAlert()}
<ha-md-list-item>
<span slot="headline">Enable camera entity</span>
<span slot="supporting-text"
>Expose this browser camera as a Home Assistant camera
entity</span
>
<ha-switch
slot="end"
.checked=${null===(b=window.browser_mod)||void 0===b?void 0:b.cameraEnabled}
@change=${this.toggleCameraEnabled}
.disabled=${null===(g=window.browser_mod)||void 0===g?void 0:g.browser_locked}
></ha-switch>
</ha-md-list-item>
<ha-md-list-item>
<span slot="headline">Enable go2rtc publishing</span>
<span slot="supporting-text"
>Publish this browser camera to go2rtc using WHIP</span
>
<ha-switch
slot="end"
.checked=${null===(m=window.browser_mod)||void 0===m?void 0:m.go2rtcEnabled}
@change=${this.toggleGo2rtcEnabled}
.disabled=${null===(_=window.browser_mod)||void 0===_?void 0:_.browser_locked}
></ha-switch>
</ha-md-list-item>
${(null===(w=window.browser_mod)||void 0===w?void 0:w.cameraError)?K`
<ha-alert alert-type="error">
Setting up the device camera failed. Make sure you are browsing
in a secure (https://) context and have
allowed use of the camera in your browser.
</ha-alert>
`:""}
${(null===(v=window.browser_mod)||void 0===v?void 0:v.go2rtcError)?K`
<ha-alert alert-type="error">
Setting up go2rtc publishing failed. Make sure go2rtc
is reachable, you are browsing in a secure (https://)
context, and camera access is allowed.
</ha-alert>
`:""}
${this._renderInteractionAlert()}
${this._renderFKBSettingsInfo()}
`:""}
</div>
</ha-card>
`}_renderSuspensionAlert(){return this.hass.suspendWhenHidden?K`
<ha-alert alert-type="warning" title="Auto closing connection">
Home Assistant will close the websocket connection to the server
automatically after 5 minutes of inactivity.<br /><br />
While decreasing network traffic and memory usage, this may cause
problems for browser_mod operation.
<br /><br />
If you find that some things stop working for this Browser after a time,
try going to your
<a
href="/profile"
style="text-decoration: underline; color: var(--primary-color);"
>Profile Settings</a
>
and disabling the option
"${this.hass.localize("ui.panel.profile.suspend.header")||"Automatically close connection"}".
</ha-alert>
`:K``}_renderInteractionAlert(){return K`
<ha-alert title="Interaction requirement">
For privacy reasons many browsers require the user to interact with a
webpage before allowing audio playback or video capture. This may affect
the
<code>media_player</code>, <code>camera</code>, and go2rtc publishing
features of Browser Mod. <br /><br />
If you ever see a
<ha-icon
icon="mdi:gesture-tap"
style="color: var(--warning-color);"
></ha-icon>
symbol at the bottom right corner of the screen, please tap or click
anywhere on the page. This should allow Browser Mod to work again.
</ha-alert>
`}_renderFKBSettingsInfo(){var e,t;return(null===(e=window.browser_mod)||void 0===e?void 0:e.fully)&&this.getFullySettings()?K`
${(null===(t=window.browser_mod)||void 0===t?void 0:t.fully)&&this.getFullySettings()?K` <ha-alert title="FullyKiosk Browser">
You are using FullyKiosk Browser. It is recommended to enable the
following settings:
<ul>
${this.getFullySettings()}
</ul>
</ha-alert>`:""}
`:K``}getFullySettings(){if(!window.browser_mod.fully)return null;const e=[],t=[];"true"!==window.fully.getBooleanSetting("autoplayVideos")&&t.push(K`<li>Autoplay Videos</li>`),"true"!==window.fully.getBooleanSetting("autoplayAudio")&&t.push(K`<li>Autoplay Audio</li>`),"true"!==window.fully.getBooleanSetting("webcamAccess")&&t.push(K`<li>Enable Webcam Access (PLUS)</li>`),0!==t.length&&e.push(K`<li>Web Content Settings</li>
<ul>
${t}
</ul>`),"true"!==window.fully.getBooleanSetting("websiteIntegration")&&e.push(K`<li>Advanced Web Settings</li>
<ul>
<li>Enable JavaScript Interface (PLUS)</li>
</ul>`),"true"!==window.fully.getBooleanSetting("keepScreenOn")&&e.push(K`<li>Device Management</li>
<ul>
<li>Keep Screen On</li>
</ul>`),"true"!==window.fully.getBooleanSetting("preventSleepWhileScreenOff")&&e.push(K`<li>Power Settings</li>
<ul>
<li>Prevent from Sleep while Screen Off</li>
</ul>`);const i=[];return"true"!==window.fully.getBooleanSetting("motionDetection")&&i.push(K`<li>Enable Visual Motion Detection</li>`),"true"!==window.fully.getBooleanSetting("screenOnOnMotion")&&i.push(K`<li>Turn Screen On on Motion</li>`),"true"!==window.fully.getBooleanSetting("stopScreensaverOnMotion")&&i.push(K`<li>Exit Screensaver on Motion</li>`),0!==i.length&&e.push(K`<li>Motion Detection (PLUS)</li>
<ul>
${i}
</ul>`),"true"!==window.fully.getBooleanSetting("remoteAdmin")&&e.push(K`<li>Remote Administration (PLUS)</li>
<ul>
<li>Enable Remote Administration</li>
</ul>`),e.length?e:null}static get styles(){return n`
.card-header {
display: flex;
justify-content: space-between;
}
ha-md-list-item[narrow] > ha-form {
flex: 2;
}
`}};e([ce()],xe.prototype,"hass",void 0),e([ce({type:Boolean})],xe.prototype,"dirty",void 0),e([ce({type:Boolean})],xe.prototype,"narrow",void 0),customElements.define("browser-mod-browser-settings-card",xe);class Ae extends ne{firstUpdated(){window.browser_mod.addEventListener("browser-mod-config-update",()=>this.requestUpdate()),this._fetch_entity_registry()}async _fetch_entity_registry(){this._entity_registry||(this._entity_registry=await this.hass.callWS({type:"config/device_registry/list"}))}_find_entity(e){if(this._entity_registry)return this._entity_registry.find(t=>{var i;return JSON.stringify(null===(i=null==t?void 0:t.identifiers)||void 0===i?void 0:i[0])===JSON.stringify(["browser_mod",e])})}unregister_browser(e){const t=e.currentTarget.browserID;window.browser_mod.showPopup({title:"Unregister browser",adaptive:!0,content:`Are you sure you want to unregister Browser ${t}?`,right_button:"Unregister",right_button_variant:"danger",right_button_appearance:"accent",right_button_action:()=>{t===window.browser_mod.browserID?window.browser_mod.registered=!1:window.browser_mod.connection.sendMessage({type:"browser_mod/unregister",browserID:t})},left_button:"Cancel",left_button_variant:"neutral",left_button_appearance:"plain",popup_styles:[{style:"all",styles:Se}]})}toggle_lock_browser(e){const t=e.currentTarget.browserID,i=window.browser_mod.browsers[t];window.browser_mod.connection.sendMessage({type:"browser_mod/register",browserID:t,data:Object.assign(Object.assign({},i),{locked:!i.locked})})}toggle_auto_register(e){var t;(null===(t=window.browser_mod)||void 0===t?void 0:t.global_settings.autoRegister)?window.browser_mod.setSetting("global",null,{autoRegister:void 0}):window.browser_mod.setSetting("global",null,{autoRegister:!0})}toggle_lock_register(e){var t;(null===(t=window.browser_mod)||void 0===t?void 0:t.global_settings.lockRegister)?window.browser_mod.setSetting("global",null,{lockRegister:void 0}):window.browser_mod.setSetting("global",null,{lockRegister:!0,autoRegister:void 0})}register_cast(){window.browser_mod.connection.sendMessage({type:"browser_mod/register",browserID:"CAST"})}render(){var e,t;return K`
<ha-card header="Registered Browsers" outlined>
<div class="card-content">
<ha-md-list-item>
<span slot="headline">Auto-register</span>
<span slot="supporting-text">
Automatically register all new Browsers
</span>
<ha-switch
slot="end"
.checked=${!0===(null===(e=window.browser_mod)||void 0===e?void 0:e.global_settings.autoRegister)}
@change=${this.toggle_auto_register}
></ha-switch>
</ha-md-list-item>
<ha-md-list-item>
<span slot="headline">Lock register</span>
<span slot="supporting-text">
Disable registering or unregistering of all Browsers
</span>
<ha-switch
slot="end"
.checked=${!0===(null===(t=window.browser_mod)||void 0===t?void 0:t.global_settings.lockRegister)}
@change=${this.toggle_lock_register}
></ha-switch>
</ha-md-list-item>
${Object.keys(window.browser_mod.browsers).map(e=>{const t=window.browser_mod.browsers[e],i=this._find_entity(e);return K` <ha-md-list-item>
<span slot="headline">
${e} ${(null==i?void 0:i.name_by_user)?`(${i.name_by_user})`:""}
</span>
<span slot="supporting-text">
Last connected:
<ha-relative-time
.hass=${this.hass}
.datetime=${t.last_seen}
></ha-relative-time>
</span>
${i?K`
<a href="config/devices/device/${i.id}" slot="end">
<ha-icon-button>
<ha-icon .icon=${"mdi:devices"}></ha-icon>
</ha-icon-button>
</a>
`:""}
<ha-icon-button slot="end"
.browserID=${e}
@click=${this.toggle_lock_browser}
>
<ha-icon
.icon=${t.locked?"mdi:lock":"mdi:lock-open-variant"}
></ha-icon>
</ha-icon-button>
<ha-icon-button slot="end" .browserID=${e} @click=${this.unregister_browser}>
<ha-icon .icon=${"mdi:delete"}></ha-icon>
</ha-icon-button>
</ha-md-list-item>`})}
</div>
${void 0===window.browser_mod.browsers.CAST?K`
<div class="card-actions">
<ha-button
appearance="plain"
@click=${this.register_cast}
>
Register CAST Browser
</ha-button>
</div>
`:""}
</ha-card>
`}static get styles(){return n`
ha-icon-button > * {
display: flex;
color: var(--primary-text-color);
}
ha-card .card-content {
--ha-md-list-item-gap: var(--ha-space-2);
}
`}}e([ce()],Ae.prototype,"hass",void 0),e([he()],Ae.prototype,"_entity_registry",void 0),customElements.define("browser-mod-registered-browsers-card",Ae);class Ee{constructor(e){this._element=e,customElements.get("dialog-edit-sidebar")?this._dialogAvailable=!0:(this._dialogAvailable=!1,fe(document.body,"home-assistant $ home-assistant-main $ ha-drawer ha-sidebar").then(e=>{if(e&&void 0===e.editMode){const t=e.shadowRoot.querySelector("div.menu");t&&(e.addEventListener("show-dialog",e=>{var t,i,s;"dialog-edit-sidebar"===(null===(t=e.detail)||void 0===t?void 0:t.dialogTag)&&(e.stopPropagation(),null===(s=null===(i=e.detail)||void 0===i?void 0:i.dialogImport)||void 0===s||s.call(i))},{once:!0}),t.dispatchEvent(new CustomEvent("action",{detail:{action:"hold"}})))}}),customElements.whenDefined("dialog-edit-sidebar").then(async()=>{this._dialogAvailable=!0,await this._element.updateComplete.then(()=>this._element.requestUpdate())}))}get dialogAvailable(){return this._dialogAvailable}get order(){var e,t;const i=null===(t=null===(e=window.browser_mod)||void 0===e?void 0:e.getSetting)||void 0===t?void 0:t.call(e,"sidebarPanelOrder");return"global"===this._type?i.global||"[]":i[this._type][this._target]||"[]"}get hidden(){var e,t;const i=null===(t=null===(e=window.browser_mod)||void 0===e?void 0:e.getSetting)||void 0===t?void 0:t.call(e,"sidebarHiddenPanels");return"global"===this._type?i.global||"[]":i[this._type][this._target]||"[]"}async setupDialog(){var e;if(!this._dialogAvailable)return;this._dialogEditSidebar=document.createElement("dialog-edit-sidebar");const t=await ye();t&&this._dialogEditSidebar&&(await async function(e){(await ye()).provideHass(e)}(this._dialogEditSidebar),this._dialogEditSidebar._order=JSON.parse(this.order),this._dialogEditSidebar._hidden=JSON.parse(this.hidden),t.shadowRoot.appendChild(this._dialogEditSidebar),this._dialogEditSidebar._open=!0,this._dialogEditSidebar.focus(),window.addEventListener("popstate",async e=>{var t,i;const s=null===(t=e.state)||void 0===t?void 0:t.sidebarSettingsCustomSelector;s&&(s.open||(null===(i=this._dialogEditSidebar)||void 0===i?void 0:i._open)&&await this._dialogEditSidebar.closeDialog())}),void 0===(null===(e=history.state)||void 0===e?void 0:e.sidebarSettingsCustomSelector)&&history.replaceState({sidebarSettingsCustomSelector:{open:!1}},""),history.pushState({sidebarSettingsCustomSelector:{open:!0}},""),this._dialogEditSidebar.addEventListener("dialog-closed",e=>{var t;"dialog-edit-sidebar"==(null===(t=e.detail)||void 0===t?void 0:t.dialog)&&this._dialogEditSidebar&&(this._dialogEditSidebar.remove(),this._dialogEditSidebar=void 0)}))}async customiseDialog(){var e;if(!this._dialogEditSidebar)return;let t,i=0;for(;!t&&i++<5;)t=this._dialogEditSidebar.shadowRoot.querySelector("ha-dialog"),t||await new Promise(e=>setTimeout(e,500));await(null==t?void 0:t.updateComplete);const s=await fe(this._dialogEditSidebar.shadowRoot,"ha-dialog $ ha-dialog-header");if(s){const t=document.createElement("style");s.append(t);const i="global"===this._type?"Global":this._type.charAt(0).toUpperCase()+this._type.slice(1)+" - ";let o="";if("user"===this._type){for(const e of this._allUsers)if(e.id===this._target){o=e.name;break}}else o=null!==(e=this._target)&&void 0!==e?e:"";t.innerHTML=`\n slot[name="headerActionItems"] {\n display: none;\n }\n span[slot="subtitle"] {\n display: none;\n }\n .title::after {\n content: "- ${i}${o}";\n }\n `}}async setupSaveHandler(){if(!this._dialogEditSidebar)return;let e,t=0;for(;!e&&t++<5;)e=this._dialogEditSidebar.shadowRoot.querySelector("ha-dialog"),e||await new Promise(e=>setTimeout(e,500));await(null==e?void 0:e.updateComplete);const i=this._dialogEditSidebar.shadowRoot.querySelector('ha-dialog > ha-dialog-footer > ha-button[slot="primaryAction"]');if(i){const e=i.shadowRoot.querySelector("button");e&&e.addEventListener("click",e=>{e.stopImmediatePropagation(),e.stopPropagation(),e.preventDefault(),this._dialogEditSidebar.dispatchEvent(new CustomEvent("sidebar-settings-save"))})}}async saveSettings(){if(!this._dialogEditSidebar)return;const e=this._dialogEditSidebar._order,t=this._dialogEditSidebar._hidden;window.browser_mod.setSetting(this._type,this._target,{sidebarHiddenPanels:JSON.stringify(t),sidebarPanelOrder:JSON.stringify(e)}),this._dialogEditSidebar.closeDialog()}async changeSetting(e,t,i){var s,o;this.dialogAvailable?(this._type=e,this._target=t,this._allUsers=i,await this.setupDialog(),await this.customiseDialog(),await this.setupSaveHandler(),this._dialogEditSidebar.addEventListener("sidebar-settings-save",async()=>{this.saveSettings()})):null===(o=null===(s=window.browser_mod)||void 0===s?void 0:s.showPopup)||void 0===o||o.call(s,{title:"ERROR!",adaptive:!0,content:"Sidebar settings dialog unavailable.",right_button:"OK",popup_styles:[{style:"all",styles:Se}]})}}const Ce=1,ke=2,Pe=e=>(...t)=>({_$litDirective$:e,values:t});let Oe=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};const Ue=(e,t)=>{const i=e._$AN;if(void 0===i)return!1;for(const e of i)e._$AO?.(t,!1),Ue(e,t);return!0},De=e=>{let t,i;do{if(void 0===(t=e._$AM))break;i=t._$AN,i.delete(e),e=t}while(0===i?.size)},Te=e=>{for(let t;t=e._$AM;e=t){let i=t._$AN;if(void 0===i)t._$AN=i=new Set;else if(i.has(e))break;i.add(e),Me(t)}};function Re(e){void 0!==this._$AN?(De(this),this._$AM=e,Te(this)):this._$AM=e}function He(e,t=!1,i=0){const s=this._$AH,o=this._$AN;if(void 0!==o&&0!==o.size)if(t)if(Array.isArray(s))for(let e=i;e<s.length;e++)Ue(s[e],!1),De(s[e]);else null!=s&&(Ue(s,!1),De(s));else Ue(this,e)}const Me=e=>{e.type==ke&&(e._$AP??=He,e._$AQ??=Re)};class Ie extends Oe{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,i){super._$AT(e,t,i),Te(this),this.isConnected=e._$AU}_$AO(e,t=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),t&&(Ue(this,e),De(this))}setValue(e){if((e=>void 0===e.strings)(this._$Ct))this._$Ct._$AI(e,this);else{const t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}}class je{constructor(e){this.G=e}disconnect(){this.G=void 0}reconnect(e){this.G=e}deref(){return this.G}}class Be{constructor(){this.Y=void 0,this.Z=void 0}get(){return this.Y}pause(){this.Y??=new Promise(e=>this.Z=e)}resume(){this.Z?.(),this.Y=this.Z=void 0}}const Ne=e=>!(e=>null===e||"object"!=typeof e&&"function"!=typeof e)(e)&&"function"==typeof e.then,Le=1073741823;const Ke=Pe(class extends Ie{constructor(){super(...arguments),this._$Cwt=Le,this._$Cbt=[],this._$CK=new je(this),this._$CX=new Be}render(...e){return e.find(e=>!Ne(e))??z}update(e,t){const i=this._$Cbt;let s=i.length;this._$Cbt=t;const o=this._$CK,a=this._$CX;this.isConnected||this.disconnected();for(let e=0;e<t.length&&!(e>this._$Cwt);e++){const n=t[e];if(!Ne(n))return this._$Cwt=e,n;e<s&&n===i[e]||(this._$Cwt=Le,s=0,Promise.resolve(n).then(async e=>{for(;a.get();)await a.get();const t=o.deref();if(void 0!==t){const i=t._$Cbt.indexOf(n);i>-1&&i<t._$Cwt&&(t._$Cwt=i,t.setValue(e))}}))}return z}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}}),ze=Pe(class extends Oe{constructor(e){if(super(e),e.type!==Ce||"class"!==e.name||e.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return" "+Object.keys(e).filter(t=>e[t]).join(" ")+" "}update(e,[t]){if(void 0===this.st){this.st=new Set,void 0!==e.strings&&(this.nt=new Set(e.strings.join(" ").split(/\s/).filter(e=>""!==e)));for(const e in t)t[e]&&!this.nt?.has(e)&&this.st.add(e);return this.render(t)}const i=e.element.classList;for(const e of this.st)e in t||(i.remove(e),this.st.delete(e));for(const e in t){const s=!!t[e];s===this.st.has(e)||this.nt?.has(e)||(s?(i.add(e),this.st.add(e)):(i.remove(e),this.st.delete(e)))}return z}});let Fe;class qe extends ne{constructor(){super(...arguments),this.settingSelector={template:{}},this.tableData=[],this._tableFirstUpdate=null,this._tableUpdate=new Promise(e=>{this._tableFirstUpdate=e}),this._tableFirstDisplay=null,this._tableDisplay=new Promise(e=>{this._tableFirstDisplay=e}),this.updateTableDebounced=((e,t,i=!1)=>{let s;const o=(...o)=>{const a=i&&!s;clearTimeout(s),s=window.setTimeout(()=>{s=void 0,e(...o)},t),a&&e(...o)};return o.cancel=()=>{clearTimeout(s)},o})(()=>this.updateTable(),1e3)}showTable(){var e;null===(e=this._tableFirstDisplay)||void 0===e||e.call(this),this._tableFirstDisplay=null}firstUpdated(){window.browser_mod.addEventListener("browser-mod-config-update",()=>{this.updateTableDebounced()})}shouldUpdate(e){if(e.has("settingKey"))return!0;if(e.has("tableData")){const t=e.get("tableData");if(void 0===t&&void 0!==this.tableData&&this.tableData.length>0)return!0;if(Array.isArray(t)&&Array.isArray(this.tableData)&&!$e(t,this.tableData))return!0}return!1}updated(e){(e.has("settingKey")||e.has("hass")&&void 0===e.get("hass"))&&this.updateTableDebounced()}async fetchUsers(){return void 0===Fe&&(Fe=this.hass.callWS({type:"config/auth/list"})),Fe}clearSetting(e,t){var i;null===(i=window.browser_mod)||void 0===i||i.showPopup({title:"Are you sure",adaptive:!0,content:"Do you wish to clear this setting?",right_button:"Clear",right_button_variant:"danger",right_button_appearance:"accent",right_button_action:async()=>{if("sidebarPanelOrder"===this.settingKey)return await fe(document.body,"home-assistant $ home-assistant-main $ ha-drawer ha-sidebar"),window.browser_mod.setSetting(e,t,{sidebarHiddenPanels:"[]",sidebarPanelOrder:"[]"}),void window.browser_mod.setSetting(e,t,{sidebarHiddenPanels:void 0,sidebarPanelOrder:void 0});this.default&&window.browser_mod.setSetting(e,t,{[this.settingKey]:this.default}),window.browser_mod.setSetting(e,t,{[this.settingKey]:void 0})},left_button:"Cancel",left_button_variant:"neutral",left_button_appearance:"plain",popup_styles:[{style:"all",styles:Se}]})}async changeSetting(e,t){var i;if(this.settingSelector.custom){const s=await this.fetchUsers();null===(i=this.settingSelector.custom)||void 0===i||i.changeSetting(e,t,s)}else this.changeSettingForm(e,t)}changeSettingForm(e,t){var i,s,o,a,n,r,l;const d=null===(s=null===(i=window.browser_mod)||void 0===i?void 0:i.getSetting)||void 0===s?void 0:s.call(i,this.settingKey),c=null!==(o="global"===e?d.global:d[e][t])&&void 0!==o?o:this.default,h=null!==(n=null!==(a=this.settingSelector.plaintext)&&void 0!==a?a:this.settingSelector.schema)&&void 0!==n?n:[{name:"value",label:null!==(r=this.settingSelector.label)&&void 0!==r?r:"",default:c,selector:this.settingSelector}];if(this.settingSelector.schema&&void 0!==c){function u(e,t){for(const i of e)i.schema?u(i.schema,t):void 0!==t[i.name]&&(i.default=t[i.name])}u(h,c)}null===(l=window.browser_mod)||void 0===l||l.showPopup({title:"Change setting",adaptive:!0,tag:"change-setting",content:h,right_button:"Save",right_button_variant:"brand",right_button_appearance:"accent",right_button_action:async i=>{var s;if("sidebarPanelOrder"===this.settingKey){const i=await fe(document.body,"home-assistant $ home-assistant-main $ ha-drawer ha-sidebar");return void window.browser_mod.setSetting(e,t,{sidebarHiddenPanels:JSON.stringify(i._hiddenPanels),sidebarPanelOrder:JSON.stringify(i._panelOrder)})}let o=null!==(s=i.value)&&void 0!==s?s:i;window.browser_mod.setSetting(e,t,{[this.settingKey]:o})},left_button:"Cancel",left_button_variant:"neutral",left_button_appearance:"plain",popup_styles:[{style:"all",styles:Se}]})}addBrowserSetting(){var e,t;const i=null===(t=null===(e=window.browser_mod)||void 0===e?void 0:e.getSetting)||void 0===t?void 0:t.call(e,this.settingKey),s=window.browser_mod._data.browsers,o=[];for(const e of Object.keys(s))null==i.browser[e]&&o.push(e);0!==o.length?window.browser_mod.showPopup({title:"Select browser to configure",adaptive:!0,tag:"select-browser",content:[{name:"browser",label:"",selector:{select:{options:o}}}],right_button:"Next",right_button_action:e=>this.changeSetting("browser",e.browser),right_button_variant:"brand",right_button_appearance:"filled",left_button:"Cancel",left_button_variant:"neutral",left_button_appearance:"plain",popup_styles:[{style:"all",styles:Se}]}):window.browser_mod.showPopup({title:"No browsers to configure",adaptive:!0,content:"All registered browsers have already been configured.",right_button:"OK",popup_styles:[{style:"all",styles:Se}]})}async addUserSetting(){var e,t;const i=null===(t=null===(e=window.browser_mod)||void 0===e?void 0:e.getSetting)||void 0===t?void 0:t.call(e,this.settingKey),s=await this.fetchUsers(),o=[];for(const e of s)e.system_generated||null!=i.user[e.id]||o.push({label:e.name,value:e.id});0!==o.length?window.browser_mod.showPopup({title:"Select user to configure",adaptive:!0,tag:"select-user",content:[{name:"user",label:"",selector:{select:{options:o}}}],right_button:"Next",right_button_variant:"brand",right_button_appearance:"filled",rig