diff --git a/custom_components/switch_manager/assets/switch_manager_panel.js b/custom_components/switch_manager/assets/switch_manager_panel.js index 1194b456..d87d9b7f 100644 --- a/custom_components/switch_manager/assets/switch_manager_panel.js +++ b/custom_components/switch_manager/assets/switch_manager_panel.js @@ -1,4 +1,10 @@ -function t(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(r=(n<3?o(r):n>3?o(e,i,r):o(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}const e=t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:i,elements:s}=e;return{kind:i,elements:s,finisher(e){customElements.define(t,e)}}})(t,e),i=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(i){i.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};function s(t){return(e,s)=>void 0!==s?((t,e,i)=>{e.constructor.createProperty(i,t)})(t,e,s):i(t,e)}function o(t){return s({...t,state:!0})}function n(t,e){return(({finisher:t,descriptor:e})=>(i,s)=>{var o;if(void 0===s){const s=null!==(o=i.originalKey)&&void 0!==o?o:i.key,n=null!=e?{kind:"method",placement:"prototype",key:s,descriptor:e(i.key)}:{...i,key:s};return null!=t&&(n.finisher=function(e){t(e,s)}),n}{const o=i.constructor;void 0!==e&&Object.defineProperty(i,s,e(s)),null==t||t(o,s)}})({descriptor:i=>{const s={get(){var e,i;return null!==(i=null===(e=this.renderRoot)||void 0===e?void 0:e.querySelector(t))&&void 0!==i?i:null},enumerable:!0,configurable:!0};if(e){const e="symbol"==typeof i?Symbol():"__"+i;s.get=function(){var i,s;return void 0===this[e]&&(this[e]=null!==(s=null===(i=this.renderRoot)||void 0===i?void 0:i.querySelector(t))&&void 0!==s?s:null),this[e]}}return s}})}var r;null===(r=window.HTMLSlotElement)||void 0===r||r.prototype.assignedElements;const a=window,l=a.ShadowRoot&&(void 0===a.ShadyCSS||a.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,h=Symbol(),d=new WeakMap;class c{constructor(t,e,i){if(this._$cssResult$=!0,i!==h)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(l&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=d.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&d.set(e,t))}return t}toString(){return this.cssText}}const p=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,s)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[s+1]),t[0]);return new c(i,t,h)},u=l?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new c("string"==typeof t?t:t+"",void 0,h))(e)})(t):t;var v;const g=window,m=g.trustedTypes,_=m?m.emptyScript:"",f=g.reactiveElementPolyfillSupport,b={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},$=(t,e)=>e!==t&&(e==e||t==t),y={attribute:!0,type:String,converter:b,reflect:!1,hasChanged:$};class w extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var e;this.finalize(),(null!==(e=this.h)&&void 0!==e?e:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const s=this._$Ep(i,e);void 0!==s&&(this._$Ev.set(s,i),t.push(s))})),t}static createProperty(t,e=y){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,s=this.getPropertyDescriptor(t,i,e);void 0!==s&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(s){const o=this[t];this[e]=s,this.requestUpdate(t,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||y}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),void 0!==t.h&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(u(t))}else void 0!==t&&e.push(u(t));return e}static _$Ep(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{l?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const i=document.createElement("style"),s=a.litNonce;void 0!==s&&i.setAttribute("nonce",s),i.textContent=e.cssText,t.appendChild(i)}))})(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e,i=y){var s;const o=this.constructor._$Ep(t,i);if(void 0!==o&&!0===i.reflect){const n=(void 0!==(null===(s=i.converter)||void 0===s?void 0:s.toAttribute)?i.converter:b).toAttribute(e,i.type);this._$El=t,null==n?this.removeAttribute(o):this.setAttribute(o,n),this._$El=null}}_$AK(t,e){var i;const s=this.constructor,o=s._$Ev.get(t);if(void 0!==o&&this._$El!==o){const t=s.getPropertyOptions(o),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(i=t.converter)||void 0===i?void 0:i.fromAttribute)?t.converter:b;this._$El=o,this[o]=n.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,i){let s=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||$)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$Ek()}catch(t){throw e=!1,this._$Ek(),t}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}var A;w.finalized=!0,w.elementProperties=new Map,w.elementStyles=[],w.shadowRootOptions={mode:"open"},null==f||f({ReactiveElement:w}),(null!==(v=g.reactiveElementVersions)&&void 0!==v?v:g.reactiveElementVersions=[]).push("1.4.2");const x=window,S=x.trustedTypes,C=S?S.createPolicy("lit-html",{createHTML:t=>t}):void 0,E=`lit$${(Math.random()+"").slice(9)}$`,k="?"+E,H=`<${k}>`,N=document,P=(t="")=>N.createComment(t),M=t=>null===t||"object"!=typeof t&&"function"!=typeof t,U=Array.isArray,O=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,T=/-->/g,L=/>/g,R=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),D=/'/g,z=/"/g,j=/^(?:script|style|textarea|title)$/i,V=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),q=Symbol.for("lit-noChange"),B=Symbol.for("lit-nothing"),I=new WeakMap,W=N.createTreeWalker(N,129,null,!1);class Z{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let o=0,n=0;const r=t.length-1,a=this.parts,[l,h]=((t,e)=>{const i=t.length-1,s=[];let o,n=2===e?"":"",r=O;for(let e=0;e"===l[0]?(r=null!=o?o:O,h=-1):void 0===l[1]?h=-2:(h=r.lastIndex-l[2].length,a=l[1],r=void 0===l[3]?R:'"'===l[3]?z:D):r===z||r===D?r=R:r===T||r===L?r=O:(r=R,o=void 0);const c=r===R&&t[e+1].startsWith("/>")?" ":"";n+=r===O?i+H:h>=0?(s.push(a),i.slice(0,h)+"$lit$"+i.slice(h)+E+c):i+E+(-2===h?(s.push(void 0),e):c)}const a=n+(t[i]||"")+(2===e?"":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==C?C.createHTML(a):a,s]})(t,e);if(this.el=Z.createElement(l,i),W.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(s=W.nextNode())&&a.length0){s.textContent=S?S.emptyScript:"";for(let i=0;iU(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.k(t):this.g(t)}O(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}g(t){this._$AH!==B&&M(this._$AH)?this._$AA.nextSibling.data=t:this.T(N.createTextNode(t)),this._$AH=t}$(t){var e;const{values:i,_$litType$:s}=t,o="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=Z.createElement(s.h,this.options)),s);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===o)this._$AH.p(i);else{const t=new F(o,this),e=t.v(this.options);t.p(i),this.T(e),this._$AH=t}}_$AC(t){let e=I.get(t.strings);return void 0===e&&I.set(t.strings,e=new Z(t)),e}k(t){U(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const o of t)s===e.length?e.push(i=new J(this.O(P()),this.O(P()),this,this.options)):i=e[s],i._$AI(o),s++;s2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=B}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,s){const o=this.strings;let n=!1;if(void 0===o)t=K(this,t,e,0),n=!M(t)||t!==this._$AH&&t!==q,n&&(this._$AH=t);else{const s=t;let r,a;for(t=o[0],r=0;r{var s,o;const n=null!==(s=null==i?void 0:i.renderBefore)&&void 0!==s?s:e;let r=n._$litPart$;if(void 0===r){const t=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:null;n._$litPart$=r=new J(e.insertBefore(P(),t),t,void 0,null!=i?i:{})}return r._$AI(t),r})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return q}}nt.finalized=!0,nt._$litElement$=!0,null===(st=globalThis.litElementHydrateSupport)||void 0===st||st.call(globalThis,{LitElement:nt});const rt=globalThis.litElementPolyfillSupport;null==rt||rt({LitElement:nt}),(null!==(ot=globalThis.litElementVersions)&&void 0!==ot?ot:globalThis.litElementVersions=[]).push("3.2.2");var at=Number.isNaN||function(t){return"number"==typeof t&&t!=t};function lt(t,e){if(t.length!==e.length)return!1;for(var i=0;i{s=s||{},i=null==i?{}:i;const o=new Event(e,{bubbles:void 0===s.bubbles||s.bubbles,cancelable:Boolean(s.cancelable),composed:void 0===s.composed||s.composed});return o.detail=i,t.dispatchEvent(o),o},mt="switch_manager";function _t(t){return t?`/${mt}/${t}`:`/${mt}`}function ft(t){return`/assets/${mt}/${t}`}function bt(t){return`${mt}/${t}`}function $t(t){if("string"==typeof t)return window.history.pushState({},null,t),window.dispatchEvent(new PopStateEvent("popstate")),!1;var e=t.target;return"a"!==e.localName&&(e=e.closest("a")),"a"===e.localName&&e.href&&(window.history.pushState({},null,e.href),window.dispatchEvent(new PopStateEvent("popstate"))),!1}const yt=(t,e)=>gt(t,"hass-notification",e),wt=(t,e)=>new Promise((i=>{const s=e.cancel,o=e.confirm;gt(t,"show-dialog",{dialogTag:"switch-manager-dialog-confirm",dialogImport:()=>Promise.resolve().then((function(){return Te})),dialogParams:Object.assign(Object.assign({},e),{cancel:()=>{i(!!(null==e?void 0:e.prompt)&&null),s&&s()},confirm:()=>{i(!(null==e?void 0:e.prompt)||null),o&&o()}})})})),At=window,xt=At.ShadowRoot&&(void 0===At.ShadyCSS||At.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,St=Symbol(),Ct=new WeakMap;class Et{constructor(t,e,i){if(this._$cssResult$=!0,i!==St)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(xt&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=Ct.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Ct.set(e,t))}return t}toString(){return this.cssText}}const kt=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,s)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[s+1]),t[0]);return new Et(i,t,St)},Ht=xt?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new Et("string"==typeof t?t:t+"",void 0,St))(e)})(t):t;var Nt;const Pt=window,Mt=Pt.trustedTypes,Ut=Mt?Mt.emptyScript:"",Ot=Pt.reactiveElementPolyfillSupport,Tt={toAttribute(t,e){switch(e){case Boolean:t=t?Ut:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},Lt=(t,e)=>e!==t&&(e==e||t==t),Rt={attribute:!0,type:String,converter:Tt,reflect:!1,hasChanged:Lt};class Dt extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var e;this.finalize(),(null!==(e=this.h)&&void 0!==e?e:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const s=this._$Ep(i,e);void 0!==s&&(this._$Ev.set(s,i),t.push(s))})),t}static createProperty(t,e=Rt){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,s=this.getPropertyDescriptor(t,i,e);void 0!==s&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(s){const o=this[t];this[e]=s,this.requestUpdate(t,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||Rt}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),void 0!==t.h&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(Ht(t))}else void 0!==t&&e.push(Ht(t));return e}static _$Ep(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{xt?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const i=document.createElement("style"),s=At.litNonce;void 0!==s&&i.setAttribute("nonce",s),i.textContent=e.cssText,t.appendChild(i)}))})(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e,i=Rt){var s;const o=this.constructor._$Ep(t,i);if(void 0!==o&&!0===i.reflect){const n=(void 0!==(null===(s=i.converter)||void 0===s?void 0:s.toAttribute)?i.converter:Tt).toAttribute(e,i.type);this._$El=t,null==n?this.removeAttribute(o):this.setAttribute(o,n),this._$El=null}}_$AK(t,e){var i;const s=this.constructor,o=s._$Ev.get(t);if(void 0!==o&&this._$El!==o){const t=s.getPropertyOptions(o),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(i=t.converter)||void 0===i?void 0:i.fromAttribute)?t.converter:Tt;this._$El=o,this[o]=n.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,i){let s=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||Lt)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$Ek()}catch(t){throw e=!1,this._$Ek(),t}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}var zt;Dt.finalized=!0,Dt.elementProperties=new Map,Dt.elementStyles=[],Dt.shadowRootOptions={mode:"open"},null==Ot||Ot({ReactiveElement:Dt}),(null!==(Nt=Pt.reactiveElementVersions)&&void 0!==Nt?Nt:Pt.reactiveElementVersions=[]).push("1.4.2");const jt=window,Vt=jt.trustedTypes,qt=Vt?Vt.createPolicy("lit-html",{createHTML:t=>t}):void 0,Bt=`lit$${(Math.random()+"").slice(9)}$`,It="?"+Bt,Wt=`<${It}>`,Zt=document,Kt=(t="")=>Zt.createComment(t),Ft=t=>null===t||"object"!=typeof t&&"function"!=typeof t,Jt=Array.isArray,Gt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Qt=/-->/g,Xt=/>/g,Yt=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),te=/'/g,ee=/"/g,ie=/^(?:script|style|textarea|title)$/i,se=Symbol.for("lit-noChange"),oe=Symbol.for("lit-nothing"),ne=new WeakMap,re=Zt.createTreeWalker(Zt,129,null,!1),ae=(t,e)=>{const i=t.length-1,s=[];let o,n=2===e?"":"",r=Gt;for(let e=0;e"===l[0]?(r=null!=o?o:Gt,h=-1):void 0===l[1]?h=-2:(h=r.lastIndex-l[2].length,a=l[1],r=void 0===l[3]?Yt:'"'===l[3]?ee:te):r===ee||r===te?r=Yt:r===Qt||r===Xt?r=Gt:(r=Yt,o=void 0);const c=r===Yt&&t[e+1].startsWith("/>")?" ":"";n+=r===Gt?i+Wt:h>=0?(s.push(a),i.slice(0,h)+"$lit$"+i.slice(h)+Bt+c):i+Bt+(-2===h?(s.push(void 0),e):c)}const a=n+(t[i]||"")+(2===e?"":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==qt?qt.createHTML(a):a,s]};class le{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let o=0,n=0;const r=t.length-1,a=this.parts,[l,h]=ae(t,e);if(this.el=le.createElement(l,i),re.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(s=re.nextNode())&&a.length0){s.textContent=Vt?Vt.emptyScript:"";for(let i=0;iJt(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.k(t):this.g(t)}O(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}g(t){this._$AH!==oe&&Ft(this._$AH)?this._$AA.nextSibling.data=t:this.T(Zt.createTextNode(t)),this._$AH=t}$(t){var e;const{values:i,_$litType$:s}=t,o="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=le.createElement(s.h,this.options)),s);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===o)this._$AH.p(i);else{const t=new de(o,this),e=t.v(this.options);t.p(i),this.T(e),this._$AH=t}}_$AC(t){let e=ne.get(t.strings);return void 0===e&&ne.set(t.strings,e=new le(t)),e}k(t){Jt(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const o of t)s===e.length?e.push(i=new ce(this.O(Kt()),this.O(Kt()),this,this.options)):i=e[s],i._$AI(o),s++;s2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=oe}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,s){const o=this.strings;let n=!1;if(void 0===o)t=he(this,t,e,0),n=!Ft(t)||t!==this._$AH&&t!==se,n&&(this._$AH=t);else{const s=t;let r,a;for(t=o[0],r=0;r{var s,o;const n=null!==(s=null==i?void 0:i.renderBefore)&&void 0!==s?s:e;let r=n._$litPart$;if(void 0===r){const t=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:null;n._$litPart$=r=new ce(e.insertBefore(Kt(),t),t,void 0,null!=i?i:{})}return r._$AI(t),r})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return se}}ye.finalized=!0,ye._$litElement$=!0,null===(be=globalThis.litElementHydrateSupport)||void 0===be||be.call(globalThis,{LitElement:ye});const we=globalThis.litElementPolyfillSupport;null==we||we({LitElement:ye}),(null!==($e=globalThis.litElementVersions)&&void 0!==$e?$e:globalThis.litElementVersions=[]).push("3.2.2");const Ae=kt` +function t(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(r=(n<3?o(r):n>3?o(e,i,r):o(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}const e=t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:i,elements:s}=e;return{kind:i,elements:s,finisher(e){customElements.define(t,e)}}})(t,e),i=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(i){i.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};function s(t){return(e,s)=>void 0!==s?((t,e,i)=>{e.constructor.createProperty(i,t)})(t,e,s):i(t,e)}function o(t){return s({...t,state:!0})}function n(t,e){return(({finisher:t,descriptor:e})=>(i,s)=>{var o;if(void 0===s){const s=null!==(o=i.originalKey)&&void 0!==o?o:i.key,n=null!=e?{kind:"method",placement:"prototype",key:s,descriptor:e(i.key)}:{...i,key:s};return null!=t&&(n.finisher=function(e){t(e,s)}),n}{const o=i.constructor;void 0!==e&&Object.defineProperty(i,s,e(s)),null==t||t(o,s)}})({descriptor:i=>{const s={get(){var e,i;return null!==(i=null===(e=this.renderRoot)||void 0===e?void 0:e.querySelector(t))&&void 0!==i?i:null},enumerable:!0,configurable:!0};if(e){const e="symbol"==typeof i?Symbol():"__"+i;s.get=function(){var i,s;return void 0===this[e]&&(this[e]=null!==(s=null===(i=this.renderRoot)||void 0===i?void 0:i.querySelector(t))&&void 0!==s?s:null),this[e]}}return s}})}var r;null===(r=window.HTMLSlotElement)||void 0===r||r.prototype.assignedElements;const a=window,l=a.ShadowRoot&&(void 0===a.ShadyCSS||a.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,h=Symbol(),d=new WeakMap;class c{constructor(t,e,i){if(this._$cssResult$=!0,i!==h)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(l&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=d.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&d.set(e,t))}return t}toString(){return this.cssText}}const p=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,s)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[s+1]),t[0]);return new c(i,t,h)},u=l?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new c("string"==typeof t?t:t+"",void 0,h))(e)})(t):t;var v;const g=window,m=g.trustedTypes,_=m?m.emptyScript:"",f=g.reactiveElementPolyfillSupport,b={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},$=(t,e)=>e!==t&&(e==e||t==t),y={attribute:!0,type:String,converter:b,reflect:!1,hasChanged:$};class w extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var e;this.finalize(),(null!==(e=this.h)&&void 0!==e?e:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const s=this._$Ep(i,e);void 0!==s&&(this._$Ev.set(s,i),t.push(s))})),t}static createProperty(t,e=y){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,s=this.getPropertyDescriptor(t,i,e);void 0!==s&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(s){const o=this[t];this[e]=s,this.requestUpdate(t,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||y}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),void 0!==t.h&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(u(t))}else void 0!==t&&e.push(u(t));return e}static _$Ep(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{l?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const i=document.createElement("style"),s=a.litNonce;void 0!==s&&i.setAttribute("nonce",s),i.textContent=e.cssText,t.appendChild(i)}))})(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e,i=y){var s;const o=this.constructor._$Ep(t,i);if(void 0!==o&&!0===i.reflect){const n=(void 0!==(null===(s=i.converter)||void 0===s?void 0:s.toAttribute)?i.converter:b).toAttribute(e,i.type);this._$El=t,null==n?this.removeAttribute(o):this.setAttribute(o,n),this._$El=null}}_$AK(t,e){var i;const s=this.constructor,o=s._$Ev.get(t);if(void 0!==o&&this._$El!==o){const t=s.getPropertyOptions(o),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(i=t.converter)||void 0===i?void 0:i.fromAttribute)?t.converter:b;this._$El=o,this[o]=n.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,i){let s=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||$)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$Ek()}catch(t){throw e=!1,this._$Ek(),t}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}var A;w.finalized=!0,w.elementProperties=new Map,w.elementStyles=[],w.shadowRootOptions={mode:"open"},null==f||f({ReactiveElement:w}),(null!==(v=g.reactiveElementVersions)&&void 0!==v?v:g.reactiveElementVersions=[]).push("1.4.2");const x=window,S=x.trustedTypes,C=S?S.createPolicy("lit-html",{createHTML:t=>t}):void 0,E=`lit$${(Math.random()+"").slice(9)}$`,k="?"+E,H=`<${k}>`,N=document,P=(t="")=>N.createComment(t),M=t=>null===t||"object"!=typeof t&&"function"!=typeof t,U=Array.isArray,O=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,T=/-->/g,L=/>/g,R=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),D=/'/g,z=/"/g,j=/^(?:script|style|textarea|title)$/i,V=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),q=Symbol.for("lit-noChange"),B=Symbol.for("lit-nothing"),I=new WeakMap,W=N.createTreeWalker(N,129,null,!1);class Z{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let o=0,n=0;const r=t.length-1,a=this.parts,[l,h]=((t,e)=>{const i=t.length-1,s=[];let o,n=2===e?"":"",r=O;for(let e=0;e"===l[0]?(r=null!=o?o:O,h=-1):void 0===l[1]?h=-2:(h=r.lastIndex-l[2].length,a=l[1],r=void 0===l[3]?R:'"'===l[3]?z:D):r===z||r===D?r=R:r===T||r===L?r=O:(r=R,o=void 0);const c=r===R&&t[e+1].startsWith("/>")?" ":"";n+=r===O?i+H:h>=0?(s.push(a),i.slice(0,h)+"$lit$"+i.slice(h)+E+c):i+E+(-2===h?(s.push(void 0),e):c)}const a=n+(t[i]||"")+(2===e?"":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==C?C.createHTML(a):a,s]})(t,e);if(this.el=Z.createElement(l,i),W.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(s=W.nextNode())&&a.length0){s.textContent=S?S.emptyScript:"";for(let i=0;iU(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.k(t):this.g(t)}O(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}g(t){this._$AH!==B&&M(this._$AH)?this._$AA.nextSibling.data=t:this.T(N.createTextNode(t)),this._$AH=t}$(t){var e;const{values:i,_$litType$:s}=t,o="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=Z.createElement(s.h,this.options)),s);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===o)this._$AH.p(i);else{const t=new F(o,this),e=t.v(this.options);t.p(i),this.T(e),this._$AH=t}}_$AC(t){let e=I.get(t.strings);return void 0===e&&I.set(t.strings,e=new Z(t)),e}k(t){U(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const o of t)s===e.length?e.push(i=new J(this.O(P()),this.O(P()),this,this.options)):i=e[s],i._$AI(o),s++;s2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=B}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,s){const o=this.strings;let n=!1;if(void 0===o)t=K(this,t,e,0),n=!M(t)||t!==this._$AH&&t!==q,n&&(this._$AH=t);else{const s=t;let r,a;for(t=o[0],r=0;r{var s,o;const n=null!==(s=null==i?void 0:i.renderBefore)&&void 0!==s?s:e;let r=n._$litPart$;if(void 0===r){const t=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:null;n._$litPart$=r=new J(e.insertBefore(P(),t),t,void 0,null!=i?i:{})}return r._$AI(t),r})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return q}}nt.finalized=!0,nt._$litElement$=!0,null===(st=globalThis.litElementHydrateSupport)||void 0===st||st.call(globalThis,{LitElement:nt});const rt=globalThis.litElementPolyfillSupport;null==rt||rt({LitElement:nt}),(null!==(ot=globalThis.litElementVersions)&&void 0!==ot?ot:globalThis.litElementVersions=[]).push("3.2.2");var at=Number.isNaN||function(t){return"number"==typeof t&&t!=t};function lt(t,e){if(t.length!==e.length)return!1;for(var i=0;i{s=s||{},i=null==i?{}:i;const o=new Event(e,{bubbles:void 0===s.bubbles||s.bubbles,cancelable:Boolean(s.cancelable),composed:void 0===s.composed||s.composed});return o.detail=i,t.dispatchEvent(o),o},gt="switch_manager";function mt(t){return t?`/${gt}/${t}`:`/${gt}`}function _t(t){return`/assets/${gt}/${t}`}function ft(t){return`${gt}/${t}`}function bt(t){if("string"==typeof t)return window.history.pushState({},null,t),window.dispatchEvent(new PopStateEvent("popstate")),!1;var e=t.target;return"a"!==e.localName&&(e=e.closest("a")),"a"===e.localName&&e.href&&(window.history.pushState({},null,e.href),window.dispatchEvent(new PopStateEvent("popstate"))),!1}const $t=t=>V` +
${t}
+ `,yt=(t,e)=>vt(t,"hass-notification",e),wt=(t,e)=>new Promise((i=>{const s=e.cancel,o=e.confirm;vt(t,"show-dialog",{dialogTag:"switch-manager-dialog-confirm",dialogImport:()=>Promise.resolve().then((function(){return Te})),dialogParams:Object.assign(Object.assign({},e),{cancel:()=>{i(!!(null==e?void 0:e.prompt)&&null),s&&s()},confirm:()=>{i(!(null==e?void 0:e.prompt)||null),o&&o()}})})})),At=window,xt=At.ShadowRoot&&(void 0===At.ShadyCSS||At.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,St=Symbol(),Ct=new WeakMap;class Et{constructor(t,e,i){if(this._$cssResult$=!0,i!==St)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(xt&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=Ct.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Ct.set(e,t))}return t}toString(){return this.cssText}}const kt=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,s)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[s+1]),t[0]);return new Et(i,t,St)},Ht=xt?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new Et("string"==typeof t?t:t+"",void 0,St))(e)})(t):t;var Nt;const Pt=window,Mt=Pt.trustedTypes,Ut=Mt?Mt.emptyScript:"",Ot=Pt.reactiveElementPolyfillSupport,Tt={toAttribute(t,e){switch(e){case Boolean:t=t?Ut:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},Lt=(t,e)=>e!==t&&(e==e||t==t),Rt={attribute:!0,type:String,converter:Tt,reflect:!1,hasChanged:Lt};class Dt extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var e;this.finalize(),(null!==(e=this.h)&&void 0!==e?e:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const s=this._$Ep(i,e);void 0!==s&&(this._$Ev.set(s,i),t.push(s))})),t}static createProperty(t,e=Rt){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,s=this.getPropertyDescriptor(t,i,e);void 0!==s&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(s){const o=this[t];this[e]=s,this.requestUpdate(t,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||Rt}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),void 0!==t.h&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(Ht(t))}else void 0!==t&&e.push(Ht(t));return e}static _$Ep(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{xt?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const i=document.createElement("style"),s=At.litNonce;void 0!==s&&i.setAttribute("nonce",s),i.textContent=e.cssText,t.appendChild(i)}))})(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e,i=Rt){var s;const o=this.constructor._$Ep(t,i);if(void 0!==o&&!0===i.reflect){const n=(void 0!==(null===(s=i.converter)||void 0===s?void 0:s.toAttribute)?i.converter:Tt).toAttribute(e,i.type);this._$El=t,null==n?this.removeAttribute(o):this.setAttribute(o,n),this._$El=null}}_$AK(t,e){var i;const s=this.constructor,o=s._$Ev.get(t);if(void 0!==o&&this._$El!==o){const t=s.getPropertyOptions(o),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(i=t.converter)||void 0===i?void 0:i.fromAttribute)?t.converter:Tt;this._$El=o,this[o]=n.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,i){let s=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||Lt)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$Ek()}catch(t){throw e=!1,this._$Ek(),t}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}var zt;Dt.finalized=!0,Dt.elementProperties=new Map,Dt.elementStyles=[],Dt.shadowRootOptions={mode:"open"},null==Ot||Ot({ReactiveElement:Dt}),(null!==(Nt=Pt.reactiveElementVersions)&&void 0!==Nt?Nt:Pt.reactiveElementVersions=[]).push("1.4.2");const jt=window,Vt=jt.trustedTypes,qt=Vt?Vt.createPolicy("lit-html",{createHTML:t=>t}):void 0,Bt=`lit$${(Math.random()+"").slice(9)}$`,It="?"+Bt,Wt=`<${It}>`,Zt=document,Kt=(t="")=>Zt.createComment(t),Ft=t=>null===t||"object"!=typeof t&&"function"!=typeof t,Jt=Array.isArray,Gt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Qt=/-->/g,Xt=/>/g,Yt=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),te=/'/g,ee=/"/g,ie=/^(?:script|style|textarea|title)$/i,se=Symbol.for("lit-noChange"),oe=Symbol.for("lit-nothing"),ne=new WeakMap,re=Zt.createTreeWalker(Zt,129,null,!1),ae=(t,e)=>{const i=t.length-1,s=[];let o,n=2===e?"":"",r=Gt;for(let e=0;e"===l[0]?(r=null!=o?o:Gt,h=-1):void 0===l[1]?h=-2:(h=r.lastIndex-l[2].length,a=l[1],r=void 0===l[3]?Yt:'"'===l[3]?ee:te):r===ee||r===te?r=Yt:r===Qt||r===Xt?r=Gt:(r=Yt,o=void 0);const c=r===Yt&&t[e+1].startsWith("/>")?" ":"";n+=r===Gt?i+Wt:h>=0?(s.push(a),i.slice(0,h)+"$lit$"+i.slice(h)+Bt+c):i+Bt+(-2===h?(s.push(void 0),e):c)}const a=n+(t[i]||"")+(2===e?"":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==qt?qt.createHTML(a):a,s]};class le{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let o=0,n=0;const r=t.length-1,a=this.parts,[l,h]=ae(t,e);if(this.el=le.createElement(l,i),re.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(s=re.nextNode())&&a.length0){s.textContent=Vt?Vt.emptyScript:"";for(let i=0;iJt(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.k(t):this.g(t)}O(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}g(t){this._$AH!==oe&&Ft(this._$AH)?this._$AA.nextSibling.data=t:this.T(Zt.createTextNode(t)),this._$AH=t}$(t){var e;const{values:i,_$litType$:s}=t,o="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=le.createElement(s.h,this.options)),s);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===o)this._$AH.p(i);else{const t=new de(o,this),e=t.v(this.options);t.p(i),this.T(e),this._$AH=t}}_$AC(t){let e=ne.get(t.strings);return void 0===e&&ne.set(t.strings,e=new le(t)),e}k(t){Jt(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const o of t)s===e.length?e.push(i=new ce(this.O(Kt()),this.O(Kt()),this,this.options)):i=e[s],i._$AI(o),s++;s2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=oe}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,s){const o=this.strings;let n=!1;if(void 0===o)t=he(this,t,e,0),n=!Ft(t)||t!==this._$AH&&t!==se,n&&(this._$AH=t);else{const s=t;let r,a;for(t=o[0],r=0;r{var s,o;const n=null!==(s=null==i?void 0:i.renderBefore)&&void 0!==s?s:e;let r=n._$litPart$;if(void 0===r){const t=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:null;n._$litPart$=r=new ce(e.insertBefore(Kt(),t),t,void 0,null!=i?i:{})}return r._$AI(t),r})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return se}}ye.finalized=!0,ye._$litElement$=!0,null===(be=globalThis.litElementHydrateSupport)||void 0===be||be.call(globalThis,{LitElement:ye});const we=globalThis.litElementPolyfillSupport;null==we||we({LitElement:ye}),(null!==($e=globalThis.litElementVersions)&&void 0!==$e?$e:globalThis.litElementVersions=[]).push("3.2.2");const Ae=kt` :host { font-family: var(--paper-font-body1_-_font-family); -webkit-font-smoothing: var(--paper-font-body1_-_-webkit-font-smoothing); @@ -235,15 +241,15 @@ function t(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPro ha-fab.blocked { bottom: calc(-80px - env(safe-area-inset-bottom)); } -`;let Ee=class extends nt{constructor(){super(...arguments),this._data=[],this._columns=function(t,e){void 0===e&&(e=lt);var i=null;function s(){for(var s=[],o=0;o({image:{title:"",sortable:!1,filterable:!1,grows:!1,width:"90px",template:(t,e)=>e.switch.valid_blueprint?e.switch.blueprint.has_image?V``:V``:""},name:{title:"Name",main:!0,direction:"asc",sortable:!0,filterable:!0,grows:!0,template:(t,e)=>e.error?V`${t} (${e.error})`:t},enabled:{title:"",width:"10%",template:t=>t?"":V` +`;let Ee=class extends nt{constructor(){super(...arguments),this._data=[],this._columns=function(t,e){void 0===e&&(e=lt);var i=null;function s(){for(var s=[],o=0;o({image:{title:"",sortable:!1,filterable:!1,grows:!1,width:"90px",template:(t,e)=>e.switch.valid_blueprint?e.switch.blueprint.has_image?V``:V``:""},name:{title:"Name",main:!0,direction:"asc",sortable:!0,filterable:!0,grows:!0,template:(t,e)=>e.error?V`${t} (${e.error})`:t},enabled:{title:"",width:"10%",template:t=>t?"":V` Disabled `},service:{title:"Service",sortable:!0,filterable:!0,width:"15%"},type:{title:"Type",sortable:!0,filterable:!0,grows:!1,width:"15%"},actions:{title:"",width:this.narrow?void 0:"10%",type:"overflow-menu",template:(t,e)=>V` this._toggleEnabled(e.switch_id,e.enabled)},{label:"Delete",path:dt,action:()=>this._deleteConfirm(e),warning:!0}]}> + .items=${[{path:e.enabled?pt:ct,label:e.enabled?"Disable":"Enable",disabled:e.error,action:()=>this._toggleEnabled(e.switch_id,e.enabled)},{label:"Delete",path:ht,action:()=>this._deleteConfirm(e),warning:!0}]}> `}})))}render(){return V` @@ -289,7 +295,7 @@ function t(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPro height: calc(100vh - var(--header-height)); overflow-y: auto; } - `]}connectedCallback(){super.connectedCallback(),this._populateSwitches()}_populateSwitches(){const t=[];this.hass.callWS({type:bt("configs")}).then((e=>{Object.values(e.configs).forEach((e=>{let i;i=e.valid_blueprint?e.blueprint:{id:e.blueprint},t.push({switch:e,image:i.id,switch_id:e.id,error:e._error,enabled:e.enabled,name:e.name,service:i.service,type:i.name,actions:e.id})})),this._data=t}))}_rowClicked(t){$t(_t(`edit/${t.detail.id}`))}async _toggleEnabled(t,e){this.hass.callWS({type:bt("config/enabled"),enabled:!e,config_id:t}).then((t=>{this._populateSwitches(),yt(this,{message:"Switch "+(t.enabled?"Enabled":"Disabled")})})).catch((t=>yt(this,{message:t.message})))}async _deleteConfirm(t){wt(this,{title:"Delete switch?",text:`${t.name} will be permanently deleted.`,confirmText:"Delete",dismissText:"Cancel",confirm:()=>this._delete(t.switch_id),confirmation:!0,destructive:!0})}async _delete(t){this.hass.callWS({type:bt("config/delete"),config_id:t.toString()}).then((t=>{this._populateSwitches(),yt(this,{message:"Switch Deleted"})})).catch((t=>yt(this,{message:t.message})))}_showBlueprintDialog(){gt(this,"show-dialog",{dialogTag:"switch-manager-dialog-blueprint-selector",dialogImport:()=>Promise.resolve().then((function(){return Re})),dialogParams:{}})}};t([s()],Ee.prototype,"hass",void 0),t([s()],Ee.prototype,"narrow",void 0),t([s()],Ee.prototype,"panel",void 0),t([s()],Ee.prototype,"route",void 0),t([o()],Ee.prototype,"_data",void 0),Ee=t([e("switch-manager-index")],Ee);const ke=1;class He{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}const Ne=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends He{constructor(t){var e;if(super(t),t.type!==ke||"class"!==t.name||(null===(e=t.strings)||void 0===e?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter((e=>t[e])).join(" ")+" "}update(t,[e]){var i,s;if(void 0===this.nt){this.nt=new Set,void 0!==t.strings&&(this.st=new Set(t.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in e)e[t]&&!(null===(i=this.st)||void 0===i?void 0:i.has(t))&&this.nt.add(t);return this.render(e)}const o=t.element.classList;this.nt.forEach((t=>{t in e||(o.remove(t),this.nt.delete(t))}));for(const t in e){const i=!!e[t];i===this.nt.has(t)||(null===(s=this.st)||void 0===s?void 0:s.has(t))||(i?(o.add(t),this.nt.add(t)):(o.remove(t),this.nt.delete(t)))}return q}});let Pe=class extends nt{constructor(){super(...arguments),this.index=0}render(){if(this.actions&&1!=this.actions.length)return V` + `]}connectedCallback(){super.connectedCallback(),this._populateSwitches()}_populateSwitches(){const t=[];this.hass.callWS({type:ft("configs")}).then((e=>{Object.values(e.configs).forEach((e=>{let i;i=e.valid_blueprint?e.blueprint:{id:e.blueprint},t.push({switch:e,image:i.id,switch_id:e.id,error:e._error,enabled:e.enabled,name:e.name,service:i.service,type:i.name,actions:e.id})})),this._data=t}))}_rowClicked(t){bt(mt(`edit/${t.detail.id}`))}async _toggleEnabled(t,e){this.hass.callWS({type:ft("config/enabled"),enabled:!e,config_id:t}).then((t=>{this._populateSwitches(),yt(this,{message:"Switch "+(t.enabled?"Enabled":"Disabled")})})).catch((t=>yt(this,{message:t.message})))}async _deleteConfirm(t){wt(this,{title:"Delete switch?",text:`${t.name} will be permanently deleted.`,confirmText:"Delete",dismissText:"Cancel",confirm:()=>this._delete(t.switch_id),confirmation:!0,destructive:!0})}async _delete(t){this.hass.callWS({type:ft("config/delete"),config_id:t.toString()}).then((t=>{this._populateSwitches(),yt(this,{message:"Switch Deleted"})})).catch((t=>yt(this,{message:t.message})))}_showBlueprintDialog(){vt(this,"show-dialog",{dialogTag:"switch-manager-dialog-blueprint-selector",dialogImport:()=>Promise.resolve().then((function(){return Re})),dialogParams:{}})}};t([s()],Ee.prototype,"hass",void 0),t([s()],Ee.prototype,"narrow",void 0),t([s()],Ee.prototype,"panel",void 0),t([s()],Ee.prototype,"route",void 0),t([o()],Ee.prototype,"_data",void 0),Ee=t([e("switch-manager-index")],Ee);const ke=1;class He{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}const Ne=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends He{constructor(t){var e;if(super(t),t.type!==ke||"class"!==t.name||(null===(e=t.strings)||void 0===e?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter((e=>t[e])).join(" ")+" "}update(t,[e]){var i,s;if(void 0===this.nt){this.nt=new Set,void 0!==t.strings&&(this.st=new Set(t.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in e)e[t]&&!(null===(i=this.st)||void 0===i?void 0:i.has(t))&&this.nt.add(t);return this.render(e)}const o=t.element.classList;this.nt.forEach((t=>{t in e||(o.remove(t),this.nt.delete(t))}));for(const t in e){const i=!!e[t];i===this.nt.has(t)||(null===(s=this.st)||void 0===s?void 0:s.has(t))||(i?(o.add(t),this.nt.add(t)):(o.remove(t),this.nt.delete(t)))}return q}});let Pe=class extends nt{constructor(){super(...arguments),this.index=0}render(){if(this.actions&&1!=this.actions.length)return V`
${this.actions.map((t=>V`${t.title}`))} @@ -326,7 +332,7 @@ function t(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPro $t(_t())}> + @click=${()=>bt(mt())}>
Switch Manager - ${null===(t=this.config)||void 0===t?void 0:t.name} @@ -355,7 +361,7 @@ function t(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPro ${(null===(s=this.config)||void 0===s?void 0:s.enabled)?"Disable":"Enable"} + .path=${(null===(o=this.config)||void 0===o?void 0:o.enabled)?pt:ct}> @@ -370,7 +376,7 @@ function t(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPro + .path=${ht}> @@ -404,7 +410,7 @@ function t(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPro
- ${this.blueprint&&!(null===(d=this.blueprint)||void 0===d?void 0:d.has_image)?V``:V``} + ${this.blueprint&&!(null===(d=this.blueprint)||void 0===d?void 0:d.has_image)?V``:V``}
${(null===(c=this.config)||void 0===c?void 0:c.valid_blueprint)?V` @@ -439,7 +445,7 @@ function t(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPro .hass=${this.hass} .value=${null===(m=null===(g=this.config)||void 0===g?void 0:g.buttons[this.button_index])||void 0===m?void 0:m.actions[this.action_index].mode} label="Mode" - .selector=${{select:{mode:"dropdown",options:vt.map((t=>({label:t.charAt(0).toUpperCase()+t.slice(1),value:t})))}}} + .selector=${{select:{mode:"dropdown",options:ut.map((t=>({label:t.charAt(0).toUpperCase()+t.slice(1),value:t})))}}} @value-changed=${this._modeValueChanged}> @@ -488,20 +494,22 @@ function t(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPro } h3, #identifier { padding-left: 25px; + position: relative; } #identifier-input { width: 300px; } #identifier ha-icon-button { vertical-align: middle; - background: var(--material-secondary-text-color); + background: var(--mdc-text-field-fill-color); border-radius: 50%; - color: var(--primary-background-color); + color: var(--mdc-text-field-ink-color); margn-top: -10px; margin-top: -14px; margin-left: -34px; position: relative; --mdc-icon-button-size: 54px; + box-shadow: -5px 1px 8px -6px; } #identifier ha-icon-button[listening] { animation: 1s infinite alternate pulse; @@ -561,6 +569,9 @@ function t(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPro width: 260px; height: 260px; } + #switch-image svg image { + filter: drop-shadow(0px 0px 8px #00000033); + } #switch-image svg .button { fill: #00000000; stroke: #00adff3d; @@ -576,11 +587,11 @@ function t(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPro font-weight: bold; color: var(--error-color); } - `]}connectedCallback(){super.connectedCallback(),this._loadConfig()}disconnectedCallback(){super.disconnectedCallback(),this._subscribed&&(this._subscribed(),this._subscribed=null)}_loadConfig(){"id"in this.params?(this.is_new=!1,this.hass.callWS({type:bt("configs"),config_id:this.params.id}).then((t=>{this._setConfig(t.config)}))):(this.is_new=!0,this._dirty=!0,"blueprint"in this.params&&this._loadBlueprint(this.params.blueprint).then((t=>{this._setConfig(function(t){let e={id:null,name:"New Switch",enabled:!0,identifier:"",blueprint:t,valid_blueprint:!0,buttons:[]};return t.buttons.forEach(((t,i)=>{e.buttons[i]={actions:[]},t.actions.forEach(((t,s)=>{e.buttons[i].actions[s]={mode:vt[0],sequence:[]}}))})),e}(t.blueprint)),this._showRenameDialog()})))}_loadBlueprint(t){return this.hass.callWS({type:bt("blueprints"),blueprint_id:t})}_setConfig(t){if(this.config=t,t._error)return this._errors=t._error,void(this._block_save=!0);this._setBlueprint(t.blueprint),this._updateSequence()}_setBlueprint(t){this.blueprint=t,this.requestUpdate(),this._drawSVG()}async _drawSVG(){if(this.blueprint.has_image){await this.updateComplete;var t=new Image;t.src=ft(`${this.blueprint.id}.png`),t.onload=()=>{this.svg.setAttributeNS(null,"viewBox",`0 0 ${t.width.toString()} ${t.height.toString()}`);var e=document.createElementNS("http://www.w3.org/2000/svg","image");e.setAttributeNS(null,"x","0"),e.setAttributeNS(null,"y","0"),e.setAttributeNS(null,"width",t.width.toString()),e.setAttributeNS(null,"height",t.height.toString()),e.setAttributeNS("http://www.w3.org/1999/xlink","href",t.src),e.setAttributeNS(null,"visibility","visible"),this.svg.prepend(e)},this.blueprint.buttons.length>1&&this.blueprint.buttons.forEach(((t,e)=>{let i;"circle"==t.shape?(i=document.createElementNS("http://www.w3.org/2000/svg","circle"),i.setAttributeNS(null,"cx",t.x.toString()),i.setAttributeNS(null,"cy",t.y.toString()),i.setAttributeNS(null,"r",t.width.toString())):"path"==t.shape?(i=document.createElementNS("http://www.w3.org/2000/svg","path"),i.setAttributeNS(null,"d",t.d.toString())):(i=document.createElementNS("http://www.w3.org/2000/svg","rect"),i.setAttributeNS(null,"x",t.x.toString()),i.setAttributeNS(null,"y",t.y.toString()),i.setAttributeNS(null,"width",t.width.toString()),i.setAttributeNS(null,"height",t.height.toString())),i.setAttribute("class","button"),i.setAttribute("index",e.toString()),this.button_index==e&&i.setAttribute("selected",""),i.addEventListener("click",(t=>{t.preventDefault(),t.stopPropagation(),this._setButtonIndex(parseInt(t.target.getAttribute("index")))})),this.svg.append(i)}))}}_validate(){return this._errors=null,this.identifier_input.invalid=!1,!!this.config.identifier||(this._errors="Identifier must not be empty",this.identifier_input.invalid=!0,this.identifier_input.errorMessage="Identifier required",!1)}_save(){!this._block_save&&this._validate()&&(this._block_save=!0,this._dirty=!1,this.hass.callWS({type:bt("config/save"),config:Object.assign(Object.assign({},this.config),{blueprint:this.config.blueprint.id})}).then((t=>{this.is_new&&(this.is_new=!1,this.config.id=t.config_id,$t(_t(`edit/${t.config_id}`))),yt(this,{message:"Switch Saved"})})).catch((t=>{yt(this,{message:t.message}),this._errors=t.message,this._dirty=!0})).finally((()=>this._block_save=!1)))}_actionChanged(t){this._setActionIndex(t.detail.index)}_setButtonIndex(t){t!=this.button_index&&(this.svg.querySelector("[selected]").removeAttribute("selected"),this.svg.querySelector(`[index="${t}"]`).setAttribute("selected",""),this.button_index=t,this._setActionIndex(0))}_setActionIndex(t){this.action_index=t,this._updateSequence()}_configSequenceChanged(t){this._updateSequence(t.detail.value),this._errors=void 0,this._dirty=!0}async _listenForEvent(){if(this._subscribed)return this._subscribed(),void(this._subscribed=void 0);this._subscribed=await this.hass.connection.subscribeEvents((t=>{this.blueprint.identifier_key in t.data&&(this.identifier_input.value=t.data[this.blueprint.identifier_key],this._identifierChanged(),this._subscribed(),this._subscribed=void 0)}),this.blueprint.event_type)}_identifierChanged(t){this.config.identifier=function(t,e,i=!0){return i?t.renderRoot.querySelector(`#${e}`).value.toString().trim():t.querySelector(`#${e}`).value.toString().trim()}(this,"identifier-input"),this._dirty=!0}_modeValueChanged(t){var e;(null===(e=this.config)||void 0===e?void 0:e.buttons[this.button_index].actions[this.action_index].mode)!=t.detail.value&&(this.config.buttons[this.button_index].actions[this.action_index].mode=t.detail.value,this.requestUpdate("config"),this._dirty=!0)}async _showRenameDialog(){gt(this,"show-dialog",{dialogTag:"switch-manager-dialog-rename-switch",dialogImport:()=>Promise.resolve().then((function(){return ze})),dialogParams:{config:this.config,update:t=>{this.config.name=t.name,this._dirty=!0,this.requestUpdate()},onClose:()=>{}}})}_updateSequence(t){t&&(this.config.buttons[this.button_index].actions[this.action_index].sequence=t),this.sequence=this.config.buttons[this.button_index].actions[this.action_index].sequence,this.requestUpdate("config")}_toggleEnabled(){this.hass.callWS({type:bt("config/enabled"),enabled:!this.config.enabled,config_id:this.config.id}).then((t=>{this.config.enabled=t.enabled,this.requestUpdate("config"),yt(this,{message:"Switch "+(t.enabled?"Enabled":"Disabled")})})).catch((t=>yt(this,{message:t.message})))}async _deleteConfirm(){wt(this,{title:"Delete switch?",text:`${this.config.name} will be permanently deleted.`,confirmText:"Delete",dismissText:"Cancel",confirm:()=>this._delete(),confirmation:!0,destructive:!0})}async _delete(){this.hass.callWS({type:bt("config/delete"),config_id:this.config.id.toString()}).then((t=>{yt(this,{message:"Switch Deleted"}),$t(_t())}))}}t([s()],Me.prototype,"hass",void 0),t([s()],Me.prototype,"narrow",void 0),t([s()],Me.prototype,"panel",void 0),t([s()],Me.prototype,"route",void 0),t([s()],Me.prototype,"params",void 0),t([s()],Me.prototype,"blueprint",void 0),t([s()],Me.prototype,"config",void 0),t([s()],Me.prototype,"disabled",void 0),t([o()],Me.prototype,"_subscribed",void 0),t([o()],Me.prototype,"sequence",void 0),t([o()],Me.prototype,"button_index",void 0),t([o()],Me.prototype,"action_index",void 0),t([o()],Me.prototype,"is_new",void 0),t([o()],Me.prototype,"_dirty",void 0),t([o()],Me.prototype,"_block_save",void 0),t([o()],Me.prototype,"_errors",void 0),t([n("#switch-svg")],Me.prototype,"svg",void 0),t([n("#identifier-input")],Me.prototype,"identifier_input",void 0),customElements.define("switch-manager-switch-editor",Me);let Ue=class extends nt{get route(){return this._route}set route(t){this._route=t;let e=t.path.split("/");"new"==e[1]?this.params={action:"new",blueprint:e[2]}:"edit"==e[1]?this.params={action:"edit",id:e[2]}:this.params={}}constructor(){super(),this.params={},(async()=>{var t,e,i,s,o,n,r;if(customElements.get("ha-automation-action")&&customElements.get("ha-data-table"))return;await customElements.whenDefined("partial-panel-resolver");const a=document.createElement("partial-panel-resolver").getRoutes([{component_name:"config",url_path:"a"}]);await(null===(i=null===(e=null===(t=null==a?void 0:a.routes)||void 0===t?void 0:t.a)||void 0===e?void 0:e.load)||void 0===i?void 0:i.call(e)),await customElements.whenDefined("ha-panel-config");const l=document.createElement("ha-panel-config");await(null===(r=null===(n=null===(o=null===(s=null==l?void 0:l.routerOptions)||void 0===s?void 0:s.routes)||void 0===o?void 0:o.script)||void 0===n?void 0:n.load)||void 0===r?void 0:r.call(n)),await customElements.whenDefined("ha-config-dashboard")})()}render(){return"action"in this.params?V` + `]}connectedCallback(){super.connectedCallback(),this._loadConfig()}disconnectedCallback(){super.disconnectedCallback(),this._subscribed&&(this._subscribed(),this._subscribed=null)}_loadConfig(){"id"in this.params?(this.is_new=!1,this.hass.callWS({type:ft("configs"),config_id:this.params.id}).then((t=>{this._setConfig(t.config)}))):(this.is_new=!0,this._dirty=!0,"blueprint"in this.params&&this._loadBlueprint(this.params.blueprint).then((t=>{this._setConfig(function(t){let e={id:null,name:"New Switch",enabled:!0,identifier:"",blueprint:t,valid_blueprint:!0,buttons:[]};return t.buttons.forEach(((t,i)=>{e.buttons[i]={actions:[]},t.actions.forEach(((t,s)=>{e.buttons[i].actions[s]={mode:ut[0],sequence:[]}}))})),e}(t.blueprint)),this._showRenameDialog()})))}_loadBlueprint(t){return this.hass.callWS({type:ft("blueprints"),blueprint_id:t})}_setConfig(t){if(this.config=t,t._error)return this._errors=t._error,void(this._block_save=!0);this._setBlueprint(t.blueprint),this._updateSequence()}_setBlueprint(t){this.blueprint=t,this.requestUpdate(),this._drawSVG()}async _drawSVG(){if(this.blueprint.has_image){await this.updateComplete;var t=new Image;t.src=_t(`${this.blueprint.id}.png`),t.onload=()=>{this.svg.setAttributeNS(null,"viewBox",`0 0 ${t.width.toString()} ${t.height.toString()}`);var e=document.createElementNS("http://www.w3.org/2000/svg","image");e.setAttributeNS(null,"x","0"),e.setAttributeNS(null,"y","0"),e.setAttributeNS(null,"width",t.width.toString()),e.setAttributeNS(null,"height",t.height.toString()),e.setAttributeNS("http://www.w3.org/1999/xlink","href",t.src),e.setAttributeNS(null,"visibility","visible"),this.svg.prepend(e)},this.blueprint.buttons.length>1&&this.blueprint.buttons.forEach(((t,e)=>{let i;"circle"==t.shape?(i=document.createElementNS("http://www.w3.org/2000/svg","circle"),i.setAttributeNS(null,"cx",t.x.toString()),i.setAttributeNS(null,"cy",t.y.toString()),i.setAttributeNS(null,"r",t.width.toString())):"path"==t.shape?(i=document.createElementNS("http://www.w3.org/2000/svg","path"),i.setAttributeNS(null,"d",t.d.toString())):(i=document.createElementNS("http://www.w3.org/2000/svg","rect"),i.setAttributeNS(null,"x",t.x.toString()),i.setAttributeNS(null,"y",t.y.toString()),i.setAttributeNS(null,"width",t.width.toString()),i.setAttributeNS(null,"height",t.height.toString())),i.setAttribute("class","button"),i.setAttribute("index",e.toString()),this.button_index==e&&i.setAttribute("selected",""),i.addEventListener("click",(t=>{t.preventDefault(),t.stopPropagation(),this._setButtonIndex(parseInt(t.target.getAttribute("index")))})),this.svg.append(i)}))}}_validate(){return this._errors=null,this.identifier_input.invalid=!1,!!this.config.identifier||(this._errors="Identifier must not be empty",this.identifier_input.invalid=!0,this.identifier_input.errorMessage="Identifier required",!1)}_save(){!this._block_save&&this._validate()&&(this._block_save=!0,this._dirty=!1,this.hass.callWS({type:ft("config/save"),config:Object.assign(Object.assign({},this.config),{blueprint:this.config.blueprint.id})}).then((t=>{this.is_new&&(this.is_new=!1,this.config.id=t.config_id,bt(mt(`edit/${t.config_id}`))),yt(this,{message:"Switch Saved"})})).catch((t=>{yt(this,{message:t.message}),this._errors=t.message,this._dirty=!0})).finally((()=>this._block_save=!1)))}_actionChanged(t){this._setActionIndex(t.detail.index)}_setButtonIndex(t){t!=this.button_index&&(this.svg.querySelector("[selected]").removeAttribute("selected"),this.svg.querySelector(`[index="${t}"]`).setAttribute("selected",""),this.button_index=t,this._setActionIndex(0))}_setActionIndex(t){this.action_index=t,this._updateSequence()}_configSequenceChanged(t){this._updateSequence(t.detail.value),this._errors=void 0,this._dirty=!0}async _listenForEvent(){if(this._subscribed)return this._subscribed(),void(this._subscribed=void 0);this._subscribed=await this.hass.connection.subscribeEvents((t=>{this.blueprint.identifier_key in t.data&&(this.identifier_input.value=t.data[this.blueprint.identifier_key],this._identifierChanged(),this._subscribed(),this._subscribed=void 0)}),this.blueprint.event_type)}_identifierChanged(t){this.config.identifier=function(t,e,i=!0){return i?t.renderRoot.querySelector(`#${e}`).value.toString().trim():t.querySelector(`#${e}`).value.toString().trim()}(this,"identifier-input"),this._dirty=!0}_modeValueChanged(t){var e;(null===(e=this.config)||void 0===e?void 0:e.buttons[this.button_index].actions[this.action_index].mode)!=t.detail.value&&(this.config.buttons[this.button_index].actions[this.action_index].mode=t.detail.value,this.requestUpdate("config"),this._dirty=!0)}async _showRenameDialog(){vt(this,"show-dialog",{dialogTag:"switch-manager-dialog-rename-switch",dialogImport:()=>Promise.resolve().then((function(){return ze})),dialogParams:{config:this.config,update:t=>{this.config.name=t.name,this._dirty=!0,this.requestUpdate()},onClose:()=>{}}})}_updateSequence(t){t&&(this.config.buttons[this.button_index].actions[this.action_index].sequence=t),this.sequence=this.config.buttons[this.button_index].actions[this.action_index].sequence,this.requestUpdate("config")}_toggleEnabled(){this.hass.callWS({type:ft("config/enabled"),enabled:!this.config.enabled,config_id:this.config.id}).then((t=>{this.config.enabled=t.enabled,this.requestUpdate("config"),yt(this,{message:"Switch "+(t.enabled?"Enabled":"Disabled")})})).catch((t=>yt(this,{message:t.message})))}async _deleteConfirm(){wt(this,{title:"Delete switch?",text:`${this.config.name} will be permanently deleted.`,confirmText:"Delete",dismissText:"Cancel",confirm:()=>this._delete(),confirmation:!0,destructive:!0})}async _delete(){this.hass.callWS({type:ft("config/delete"),config_id:this.config.id.toString()}).then((t=>{yt(this,{message:"Switch Deleted"}),bt(mt())}))}}t([s()],Me.prototype,"hass",void 0),t([s()],Me.prototype,"narrow",void 0),t([s()],Me.prototype,"panel",void 0),t([s()],Me.prototype,"route",void 0),t([s()],Me.prototype,"params",void 0),t([s()],Me.prototype,"blueprint",void 0),t([s()],Me.prototype,"config",void 0),t([s()],Me.prototype,"disabled",void 0),t([o()],Me.prototype,"_subscribed",void 0),t([o()],Me.prototype,"sequence",void 0),t([o()],Me.prototype,"button_index",void 0),t([o()],Me.prototype,"action_index",void 0),t([o()],Me.prototype,"is_new",void 0),t([o()],Me.prototype,"_dirty",void 0),t([o()],Me.prototype,"_block_save",void 0),t([o()],Me.prototype,"_errors",void 0),t([n("#switch-svg")],Me.prototype,"svg",void 0),t([n("#identifier-input")],Me.prototype,"identifier_input",void 0),customElements.define("switch-manager-switch-editor",Me);let Ue=class extends nt{get route(){return this._route}set route(t){this._route=t;let e=t.path.split("/");"new"==e[1]?this.params={action:"new",blueprint:e[2]}:"edit"==e[1]?this.params={action:"edit",id:e[2]}:this.params={}}constructor(){super(),this.params={},this.component_name="custom",(async()=>{var t,e,i,s,o,n,r;if(customElements.get("ha-automation-action")&&customElements.get("ha-data-table"))return;await customElements.whenDefined("partial-panel-resolver");const a=document.createElement("partial-panel-resolver").getRoutes([{component_name:"config",url_path:"a"}]);await(null===(i=null===(e=null===(t=null==a?void 0:a.routes)||void 0===t?void 0:t.a)||void 0===e?void 0:e.load)||void 0===i?void 0:i.call(e)),await customElements.whenDefined("ha-panel-config");const l=document.createElement("ha-panel-config");await(null===(r=null===(n=null===(o=null===(s=null==l?void 0:l.routerOptions)||void 0===s?void 0:s.routes)||void 0===o?void 0:o.script)||void 0===n?void 0:n.load)||void 0===r?void 0:r.call(n)),await customElements.whenDefined("ha-config-dashboard")})()}render(){return"action"in this.params?V` `:V` - `}firstUpdated(t){super.firstUpdated(t),this.hass.loadFragmentTranslation("config")}};t([s({attribute:!1})],Ue.prototype,"hass",void 0),t([s()],Ue.prototype,"narrow",void 0),t([s()],Ue.prototype,"panel",void 0),t([o()],Ue.prototype,"params",void 0),t([s()],Ue.prototype,"route",null),Ue=t([e("switch-manager-panel")],Ue);let Oe=class extends nt{async showDialog(t){this._params=t}closeDialog(){var t,e;return!(null===(t=this._params)||void 0===t?void 0:t.confirmation)&&!(null===(e=this._params)||void 0===e?void 0:e.prompt)&&(!this._params||(this._dismiss(),!0))}render(){if(!this._params)return V``;const t=this._params.confirmation||this._params.prompt;return V` + `}firstUpdated(t){super.firstUpdated(t),this.hass.loadFragmentTranslation("config")}};t([s()],Ue.prototype,"hass",void 0),t([s()],Ue.prototype,"narrow",void 0),t([s()],Ue.prototype,"panel",void 0),t([o()],Ue.prototype,"params",void 0),t([o()],Ue.prototype,"component_name",void 0),t([s()],Ue.prototype,"route",null),Ue=t([e("switch-manager-panel")],Ue);let Oe=class extends nt{async showDialog(t){this._params=t}closeDialog(){var t,e;return!(null===(t=this._params)||void 0===t?void 0:t.confirmation)&&!(null===(e=this._params)||void 0===e?void 0:e.prompt)&&(!this._params||(this._dismiss(),!0))}render(){if(!this._params)return V``;const t=this._params.confirmation||this._params.prompt;return V` - `}_dismiss(){var t;(null===(t=this._params)||void 0===t?void 0:t.cancel)&&this._params.cancel(),this._close()}_confirm(){this._params.confirm&&this._params.confirm(),this._close()}_dialogClosed(t){"ignore"!==t.detail.action&&this._dismiss()}_close(){this._params&&(this._params=void 0,gt(this,"dialog-closed",{dialog:this.localName}))}static get styles(){return p` + `}_dismiss(){var t;(null===(t=this._params)||void 0===t?void 0:t.cancel)&&this._params.cancel(),this._close()}_confirm(){this._params.confirm&&this._params.confirm(),this._close()}_dialogClosed(t){"ignore"!==t.detail.action&&this._dismiss()}_close(){this._params&&(this._params=void 0,vt(this,"dialog-closed",{dialog:this.localName}))}static get styles(){return p` :host([inert]) { pointer-events: initial !important; cursor: initial !important; @@ -646,95 +657,94 @@ function t(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPro ha-textfield { width: 100%; } - `}};t([s({attribute:!1})],Oe.prototype,"hass",void 0),t([o()],Oe.prototype,"_params",void 0),Oe=t([e("switch-manager-dialog-confirm")],Oe);var Te=Object.freeze({__proto__:null});let Le=class extends nt{constructor(){super(...arguments),this._opened=!1}showDialog(){this._opened=!0}closeDialog(){this._opened&>(this,"dialog-closed",{dialog:this.localName}),this._opened=!1}render(){return this._opened?V` + `}};t([s({attribute:!1})],Oe.prototype,"hass",void 0),t([o()],Oe.prototype,"_params",void 0),Oe=t([e("switch-manager-dialog-confirm")],Oe);var Te=Object.freeze({__proto__:null});let Le=class extends nt{constructor(){super(...arguments),this._opened=!1}showDialog(){this._opened=!0}closeDialog(){this._opened&&vt(this,"dialog-closed",{dialog:this.localName}),this._opened=!1}render(){return this._opened?V` Select Blueprint
`}> - + .heading="${$t("Select Blueprint")}"> +

Can't find a blueprint for your switch? create your own. + window.open("https://github.com/Sian-Lee-SA/Home-Assistant-Switch-Manager#blueprints","_blank").focus()}> +

${this._listBlueprints()} - - - `:V``}static get styles(){return p` - :host { - --mdc-dialog-min-width: 500px; - } - - mwc-list-item { - height: 90px; - padding: 0px 20px; - align-items: center; - } - - h2 { - padding: 0px 0px 12px; - margin: 0px; - font-weight: normal; - font-size: 1.3em; - border-bottom: 1px solid #DDD; - margin-bottom: 5px; - } - - .row { - - display: flex; - align-items: center; - } - a.blueprint-item { - display: flex; - padding: 0px 20px; - align-items: center; - -webkit-font-smoothing: antialiased; - font-family: var(--mdc-typography-subtitle1-font-family, var(--mdc-typography-font-family, Roboto, sans-serif)); - font-size: var(--mdc-typography-subtitle1-font-size, 1rem); - font-weight: var(--mdc-typography-subtitle1-font-weight, 400); - letter-spacing: var(--mdc-typography-subtitle1-letter-spacing, 0.009375em); - color: var(--mdc-theme-text-primary-on-background, rgba(0, 0, 0, 0.87)); - text-decoration: none; - } - .image { - height: 90px; - width: 90px; - text-align: center; - } - .image img { - max-width: 100%; - max-height: 100%; - } - .image ha-svg-icon { - fill: var(--primary-color); - margin-top: 5px; - width: 85%; - height: 85%; - } - .name { - padding-left: 1em; - } - `}_itemClicked(t){$t(_t(`new/${t}`)),this.closeDialog()}connectedCallback(){super.connectedCallback(),this._updateBlueprints()}_updateBlueprints(){this.hass.callWS({type:bt("blueprints")}).then((t=>{this.blueprints=t.blueprints})).catch((t=>yt(this,{message:t.message})))}_listBlueprints(){if(!this.blueprints)return;let t={};for(let e of Object.values(this.blueprints))t[e.service]||(t[e.service]=[]),t[e.service].push(e);let e=[];for(let i in t){e.push(V`

${i}

`);for(let s of t[i])e.push(V` + + `:V``}static get styles(){return[xe,Se,p` + + mwc-list-item { + min-width: 470px; + height: 90px; + padding: 0px 20px; + align-items: center; + } + h2 { + padding: 0px 0px 12px; + margin: 15px 0px 0px; + font-weight: normal; + font-size: 1.3em; + border-bottom: 1px solid #DDD; + } + h2:first-child { + margin: 0; + } + p { + margin: -35px 0 0 0; + font-size: 0.8em; + } + ha-icon-button { + vertical-align: middle; + } + .row { + display: flex; + align-items: center; + } + a.blueprint-item { + display: flex; + padding: 0px 20px; + align-items: center; + -webkit-font-smoothing: antialiased; + font-family: var(--mdc-typography-subtitle1-font-family, var(--mdc-typography-font-family, Roboto, sans-serif)); + font-size: var(--mdc-typography-subtitle1-font-size, 1rem); + font-weight: var(--mdc-typography-subtitle1-font-weight, 400); + letter-spacing: var(--mdc-typography-subtitle1-letter-spacing, 0.009375em); + color: var(--mdc-theme-text-primary-on-background, rgba(0, 0, 0, 0.87)); + text-decoration: none; + } + .image { + height: 90px; + width: 90px; + text-align: center; + padding: 4px; + box-sizing: border-box; + } + .image img { + max-width: 100%; + max-height: 100%; + } + .image ha-svg-icon { + fill: var(--primary-color); + margin-top: 5px; + width: 85%; + height: 85%; + } + .name { + padding-left: 1em; + } + `]}_itemClicked(t){bt(mt(`new/${t}`)),this.closeDialog()}connectedCallback(){super.connectedCallback(),this._updateBlueprints()}_updateBlueprints(){this.hass.callWS({type:ft("blueprints")}).then((t=>{this.blueprints=t.blueprints})).catch((t=>yt(this,{message:t.message})))}_listBlueprints(){if(!this.blueprints)return;let t={};for(let e of Object.values(this.blueprints))t[e.service]||(t[e.service]=[]),t[e.service].push(e);let e=[];for(let i in t){e.push(V`

${i}

`);for(let s of t[i])e.push(V` this._itemClicked(s.id)} data-item-id="${s.id}">
- ${s.has_image?V``:V``} + ${s.has_image?V``:V``}
${s.name}
-
`)}return e}};t([s({attribute:!1})],Le.prototype,"hass",void 0),t([s({attribute:!1})],Le.prototype,"blueprints",void 0),t([o()],Le.prototype,"_opened",void 0),Le=t([e("switch-manager-dialog-blueprint-selector")],Le);var Re=Object.freeze({__proto__:null});let De=class extends nt{constructor(){super(...arguments),this._opened=!1}showDialog(t){this._opened=!0,this._error=null,this._params=t,this._newName=t.config.name}closeDialog(){this._params.onClose(),this._opened&>(this,"dialog-closed",{dialog:this.localName}),this._opened=!1}render(){return this._opened?V` + `)}return e}};t([s({attribute:!1})],Le.prototype,"hass",void 0),t([s({attribute:!1})],Le.prototype,"blueprints",void 0),t([o()],Le.prototype,"_opened",void 0),Le=t([e("switch-manager-dialog-blueprint-selector")],Le);var Re=Object.freeze({__proto__:null});let De=class extends nt{constructor(){super(...arguments),this._opened=!1}showDialog(t){this._opened=!0,this._error=null,this._params=t,this._newName=t.config.name}closeDialog(){this._params.onClose(),this._opened&&vt(this,"dialog-closed",{dialog:this.localName}),this._opened=!1}render(){return this._opened?V` ${t}
- `}"> + .heading="${$t("Rename")}"> ${this._error?V`Missing Name`:""} - `:V``;var t}static get styles(){return[Ae,xe,p` + `:V``}static get styles(){return[Ae,xe,p` ha-textfield, ha-textarea { display: block; diff --git a/custom_components/switch_manager/manifest.json b/custom_components/switch_manager/manifest.json index 9262db7b..95e10156 100644 --- a/custom_components/switch_manager/manifest.json +++ b/custom_components/switch_manager/manifest.json @@ -1,7 +1,7 @@ { "domain": "switch_manager", "name": "Switch Manager", - "version": "0.0.5", + "version": "0.0.6", "documentation": "https://github.com/Sian-Lee-SA/switch_manager", "dependencies": ["panel_custom", "websocket_api", "http", "frontend", "script", "mqtt"], "requirements": [], diff --git a/custom_components/switch_manager/models.py b/custom_components/switch_manager/models.py index d01a2c5f..0577ac1e 100644 --- a/custom_components/switch_manager/models.py +++ b/custom_components/switch_manager/models.py @@ -1,6 +1,6 @@ from .const import DOMAIN, LOGGER from .helpers import format_mqtt_message -from homeassistant.core import HomeAssistant, Context +from homeassistant.core import HomeAssistant, Context, callback from homeassistant.helpers.script import Script from homeassistant.components.mqtt.client import async_subscribe as mqtt_subscribe from homeassistant.components.mqtt.models import ReceiveMessage @@ -183,13 +183,34 @@ async def start(self): if self._event_listener or not self.valid_blueprint or not self.enabled: return + @callback + def _handleMQTT( message: ReceiveMessage ): + data = format_mqtt_message(message) + __processIncoming( data, Context() ) + + @callback + def _handleEvent( event ): + __processIncoming( event.data, event.context ) + + def __processIncoming( data, context ): + if not self.enabled or not self._check_conditons( data ): + return + + for button in self.buttons: + if not button._check_conditions( data ): + continue + for action in button.actions: + if not action._check_conditions( data ): + continue + self._hass.async_create_task( action.run( context=context ) ) + if self.blueprint.event_type == 'mqtt': try: - self._event_listener = await mqtt_subscribe(self._hass, self.identifier, self._handleMQTT) + self._event_listener = await mqtt_subscribe(self._hass, self.identifier, _handleMQTT) except HomeAssistantError: LOGGER.error(f"Unable to handle switch: {self.name} as MQTT is not loaded") else: - self._event_listener = self._hass.bus.async_listen(self.blueprint.event_type, self._handleEvent) + self._event_listener = self._hass.bus.async_listen(self.blueprint.event_type, _handleEvent) def stop(self): self.stop_running_scripts(); @@ -199,25 +220,8 @@ def stop(self): def setEnabled( self, value: bool ): self.enabled = value + - async def _handleMQTT( self, message: ReceiveMessage ): - data = format_mqtt_message(message) - await self.__processIncoming( data, Context() ) - - async def _handleEvent( self, event ): - await self.__processIncoming( event.data, event.context ) - - async def __processIncoming( self, data, context ): - if not self.enabled or not self._check_conditons( data ): - return - - for button in self.buttons: - if not button._check_conditions( data ): - continue - for action in button.actions: - if not action._check_conditions( data ): - continue - await action.run( context=context ) def _check_conditons( self, data ) -> bool: diff --git a/js/dialogs/dialog-blueprint-selector.ts b/js/dialogs/dialog-blueprint-selector.ts index 0373b2b4..11eec0d0 100644 --- a/js/dialogs/dialog-blueprint-selector.ts +++ b/js/dialogs/dialog-blueprint-selector.ts @@ -3,17 +3,19 @@ import { customElement, property, state } from "lit/decorators.js"; import { SwitchManagerBlueprint } from "../types"; import { mdiGestureTapButton, - mdiClose + mdiClose, + mdiHelpCircle } from "@mdi/js"; import { buildAssetUrl, buildUrl, buildWSPath, + createCloseHeading, navigate, showToast } from "../helpers"; import { fireEvent } from "@hass/common/dom/fire_event"; - +import { haStyleDialog, haStyleScrollbar } from "@hass/resources/styles" @customElement('switch-manager-dialog-blueprint-selector') class SwitchManagerBlueprintSelector extends LitElement @@ -46,77 +48,82 @@ class SwitchManagerBlueprintSelector extends LitElement open hideActions @closed=${this.closeDialog} - .heading=${html`
Select Blueprint
`}> - + .heading="${createCloseHeading('Select Blueprint')}"> +

Can't find a blueprint for your switch? create your own. + window.open('https://github.com/Sian-Lee-SA/Home-Assistant-Switch-Manager#blueprints', '_blank').focus()}> +

${this._listBlueprints()} - - + `; } static get styles() { - return css` - :host { - --mdc-dialog-min-width: 500px; - } - - mwc-list-item { - height: 90px; - padding: 0px 20px; - align-items: center; - } - - h2 { - padding: 0px 0px 12px; - margin: 0px; - font-weight: normal; - font-size: 1.3em; - border-bottom: 1px solid #DDD; - margin-bottom: 5px; - } + return [haStyleDialog, haStyleScrollbar, css` - .row { - - display: flex; - align-items: center; - } - a.blueprint-item { - display: flex; - padding: 0px 20px; - align-items: center; - -webkit-font-smoothing: antialiased; - font-family: var(--mdc-typography-subtitle1-font-family, var(--mdc-typography-font-family, Roboto, sans-serif)); - font-size: var(--mdc-typography-subtitle1-font-size, 1rem); - font-weight: var(--mdc-typography-subtitle1-font-weight, 400); - letter-spacing: var(--mdc-typography-subtitle1-letter-spacing, 0.009375em); - color: var(--mdc-theme-text-primary-on-background, rgba(0, 0, 0, 0.87)); - text-decoration: none; - } - .image { - height: 90px; - width: 90px; - text-align: center; - } - .image img { - max-width: 100%; - max-height: 100%; - } - .image ha-svg-icon { - fill: var(--primary-color); - margin-top: 5px; - width: 85%; - height: 85%; - } - .name { - padding-left: 1em; - } - `; + mwc-list-item { + min-width: 470px; + height: 90px; + padding: 0px 20px; + align-items: center; + } + h2 { + padding: 0px 0px 12px; + margin: 15px 0px 0px; + font-weight: normal; + font-size: 1.3em; + border-bottom: 1px solid #DDD; + } + h2:first-child { + margin: 0; + } + p { + margin: -35px 0 0 0; + font-size: 0.8em; + } + ha-icon-button { + vertical-align: middle; + } + .row { + display: flex; + align-items: center; + } + a.blueprint-item { + display: flex; + padding: 0px 20px; + align-items: center; + -webkit-font-smoothing: antialiased; + font-family: var(--mdc-typography-subtitle1-font-family, var(--mdc-typography-font-family, Roboto, sans-serif)); + font-size: var(--mdc-typography-subtitle1-font-size, 1rem); + font-weight: var(--mdc-typography-subtitle1-font-weight, 400); + letter-spacing: var(--mdc-typography-subtitle1-letter-spacing, 0.009375em); + color: var(--mdc-theme-text-primary-on-background, rgba(0, 0, 0, 0.87)); + text-decoration: none; + } + .image { + height: 90px; + width: 90px; + text-align: center; + padding: 4px; + box-sizing: border-box; + } + .image img { + max-width: 100%; + max-height: 100%; + } + .image ha-svg-icon { + fill: var(--primary-color); + margin-top: 5px; + width: 85%; + height: 85%; + } + .name { + padding-left: 1em; + } + `]; } diff --git a/js/main.ts b/js/main.ts index 09ddc4e7..69d5e45b 100644 --- a/js/main.ts +++ b/js/main.ts @@ -8,11 +8,13 @@ import { loadComponents } from "./helpers"; @customElement('switch-manager-panel') class SwitchManagerPanel extends LitElement { - @property({ attribute: false }) hass!: any; + @property() hass!: any; @property() narrow; @property() panel; @state() params = {}; + @state() component_name = "custom"; + private _route; get route() { return this._route }; @property() set route( route ) { diff --git a/js/switch-editor.ts b/js/switch-editor.ts index f37300e6..2f99f021 100644 --- a/js/switch-editor.ts +++ b/js/switch-editor.ts @@ -13,7 +13,7 @@ import { mdiEarHearing } from "@mdi/js"; import { MODES, SwitchManagerBlueprint, SwitchManagerConfig } from "./types" -import { haStyle, haStyleScrollbar } from "@hass/resources/styles" +import { haStyle } from "@hass/resources/styles" import { buildAssetUrl, buildUrl, @@ -254,20 +254,22 @@ class SwitchManagerSwitchEditor extends LitElement } h3, #identifier { padding-left: 25px; + position: relative; } #identifier-input { width: 300px; } #identifier ha-icon-button { vertical-align: middle; - background: var(--material-secondary-text-color); + background: var(--mdc-text-field-fill-color); border-radius: 50%; - color: var(--primary-background-color); + color: var(--mdc-text-field-ink-color); margn-top: -10px; margin-top: -14px; margin-left: -34px; position: relative; --mdc-icon-button-size: 54px; + box-shadow: -5px 1px 8px -6px; } #identifier ha-icon-button[listening] { animation: 1s infinite alternate pulse; @@ -327,6 +329,9 @@ class SwitchManagerSwitchEditor extends LitElement width: 260px; height: 260px; } + #switch-image svg image { + filter: drop-shadow(0px 0px 8px #00000033); + } #switch-image svg .button { fill: #00000000; stroke: #00adff3d; diff --git a/package.json b/package.json index d3590bc3..caf7fc57 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "switch_manager", "private": true, - "version": "0.0.5", + "version": "0.0.6", "description": "Home Assistant Frontend for Switch Manager", "scripts": { "build": "rollup -c",