iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
3 lines • 17.3 kB
JavaScript
/*! For license information please see 30575.cac7c7df748fbccf.js.LICENSE.txt */
(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["30575"],{53013:function(e,t,n){"use strict";var o=n(61701),i=n(72621),r=n(91179),a=(n(19083),n(71695),n(52805),n(9359),n(56475),n(70104),n(48136),n(40251),n(19134),n(61006),n(47021),n(57243)),s=n(50778),c=n(94886),l=n.n(c),d=n(36522),h=(n(72700),n(8038),n(71513),n(75656),n(50100),n(18084),n(75351));let u;const f=new(n(80262).L)(1e3),p={reType:(0,r.Z)(/((\[!(caution|important|note|tip|warning)\])(?:\s|\\n)?)/i,{input:1,type:3}),typeToHaAlert:{caution:"error",important:"info",note:"info",tip:"success",warning:"warning"}};(0,o.Z)([(0,s.Mo)("ha-markdown-element")],(function(e,t){class o extends t{constructor(...t){super(...t),e(this)}}return{F:o,d:[{kind:"field",decorators:[(0,s.Cb)()],key:"content",value:void 0},{kind:"field",decorators:[(0,s.Cb)({attribute:"allow-svg",type:Boolean})],key:"allowSvg",value(){return!1}},{kind:"field",decorators:[(0,s.Cb)({type:Boolean})],key:"breaks",value(){return!1}},{kind:"field",decorators:[(0,s.Cb)({type:Boolean,attribute:"lazy-images"})],key:"lazyImages",value(){return!1}},{kind:"field",decorators:[(0,s.Cb)({type:Boolean})],key:"cache",value(){return!1}},{kind:"method",key:"disconnectedCallback",value:function(){if((0,i.Z)(o,"disconnectedCallback",this,3)([]),this.cache){const e=this._computeCacheKey();f.set(e,this.innerHTML)}}},{kind:"method",key:"createRenderRoot",value:function(){return this}},{kind:"method",key:"update",value:function(e){(0,i.Z)(o,"update",this,3)([e]),void 0!==this.content&&this._render()}},{kind:"method",key:"willUpdate",value:function(e){if(!this.innerHTML&&this.cache){const e=this._computeCacheKey();f.has(e)&&(this.innerHTML=f.get(e),this._resize())}}},{kind:"method",key:"_computeCacheKey",value:function(){return l()({content:this.content,allowSvg:this.allowSvg,breaks:this.breaks})}},{kind:"method",key:"_render",value:async function(){this.innerHTML=await(async(e,t,o)=>(u||(u=(0,h.Ud)(new Worker(new URL(n.p+n.u("45845"),n.b)))),u.renderMarkdown(e,t,o)))(String(this.content),{breaks:this.breaks,gfm:!0},{allowSvg:this.allowSvg}),this._resize();const e=document.createTreeWalker(this,NodeFilter.SHOW_ELEMENT,null);for(;e.nextNode();){const o=e.currentNode;if(o instanceof HTMLAnchorElement&&o.host!==document.location.host)o.target="_blank",o.rel="noreferrer noopener";else if(o instanceof HTMLImageElement)this.lazyImages&&(o.loading="lazy"),o.addEventListener("load",this._resize);else if(o instanceof HTMLQuoteElement){var t;const n=(null===(t=o.firstElementChild)||void 0===t||null===(t=t.firstChild)||void 0===t?void 0:t.textContent)&&p.reType.exec(o.firstElementChild.firstChild.textContent);if(n){const{type:t}=n.groups,i=document.createElement("ha-alert");i.alertType=p.typeToHaAlert[t.toLowerCase()],i.append(...Array.from(o.childNodes).map((e=>{const t=Array.from(e.childNodes);if(!this.breaks&&t.length){var o;const e=t[0];e.nodeType===Node.TEXT_NODE&&e.textContent===n.input&&null!==(o=e.textContent)&&void 0!==o&&o.includes("\n")&&(e.textContent=e.textContent.split("\n").slice(1).join("\n"))}return t})).reduce(((e,t)=>e.concat(t)),[]).filter((e=>e.textContent&&e.textContent!==n.input))),e.parentNode().replaceChild(i,o)}}else o instanceof HTMLElement&&["ha-alert","ha-qr-code","ha-icon","ha-svg-icon"].includes(o.localName)&&n(23265)(`./${o.localName}`)}}},{kind:"field",key:"_resize",value(){return()=>(0,d.B)(this,"content-resize")}}]}}),a.fl)},99254:function(e,t,n){"use strict";var o=n(61701),i=(n(71695),n(47021),n(57243)),r=n(50778);n(53013);let a,s,c=e=>e;(0,o.Z)([(0,r.Mo)("ha-markdown")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,r.Cb)()],key:"content",value:void 0},{kind:"field",decorators:[(0,r.Cb)({attribute:"allow-svg",type:Boolean})],key:"allowSvg",value(){return!1}},{kind:"field",decorators:[(0,r.Cb)({type:Boolean})],key:"breaks",value(){return!1}},{kind:"field",decorators:[(0,r.Cb)({type:Boolean,attribute:"lazy-images"})],key:"lazyImages",value(){return!1}},{kind:"field",decorators:[(0,r.Cb)({type:Boolean})],key:"cache",value(){return!1}},{kind:"method",key:"render",value:function(){return this.content?(0,i.dy)(a||(a=c`<ha-markdown-element .content="${0}" .allowSvg="${0}" .breaks="${0}" .lazyImages="${0}" .cache="${0}"></ha-markdown-element>`),this.content,this.allowSvg,this.breaks,this.lazyImages,this.cache):i.Ld}},{kind:"field",static:!0,key:"styles",value(){return(0,i.iv)(s||(s=c`:host{display:block}ha-markdown-element{-ms-user-select:text;-webkit-user-select:text;-moz-user-select:text}ha-markdown-element>:first-child{margin-top:0}ha-markdown-element>:last-child{margin-bottom:0}ha-alert{display:block;margin:4px 0}a{color:var(--primary-color)}img{max-width:100%}code,pre{background-color:var(--markdown-code-background-color,none);border-radius:3px}svg{background-color:var(--markdown-svg-background-color,none);color:var(--markdown-svg-color,none)}code{font-size:85%;padding:.2em .4em}pre code{padding:0}pre{padding:16px;overflow:auto;line-height:1.45;font-family:var(--code-font-family, monospace)}h1,h2,h3,h4,h5,h6{line-height:initial}h2{font-size:1.5em;font-weight:700}hr{border-color:var(--divider-color);border-bottom:none;margin:16px 0}`))}}]}}),i.oi)},23575:function(e,t,n){"use strict";n.d(t,{N:()=>o,Z:()=>i});n(19423);const o=(e,t,n)=>e.subscribeMessage((e=>t(e)),Object.assign({type:"render_template"},n)),i=(e,t,n,o,i)=>e.connection.subscribeMessage(i,{type:"template/start_preview",flow_id:t,flow_type:n,user_input:o})},91713:function(e,t,n){"use strict";n.r(t),n.d(t,{HuiMarkdownCard:()=>y});var o=n(61701),i=n(72621),r=(n(22152),n(52247),n(71695),n(40251),n(47021),n(57243)),a=n(50778),s=n(35359),c=n(94886),l=n.n(c),d=n(82393),h=n(36522),u=(n(99426),n(54977),n(99254),n(23575)),f=n(80262);let p,m,g,v=e=>e;const k=new f.L(1e3);let y=(0,o.Z)([(0,a.Mo)("hui-markdown-card")],(function(e,t){class o extends t{constructor(...t){super(...t),e(this)}}return{F:o,d:[{kind:"method",static:!0,key:"getConfigElement",value:async function(){return await n.e("17497").then(n.bind(n,23006)),document.createElement("hui-markdown-card-editor")}},{kind:"method",static:!0,key:"getStubConfig",value:function(){return{type:"markdown",content:"The **Markdown** card allows you to write any text. You can style it **bold**, *italicized*, ~strikethrough~ etc. You can do images, links, and more.\n\nFor more information see the [Markdown Cheatsheet](https://commonmark.org/help)."}}},{kind:"field",decorators:[(0,a.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,a.Cb)({type:Boolean})],key:"preview",value(){return!1}},{kind:"field",decorators:[(0,a.SB)()],key:"_config",value:void 0},{kind:"field",decorators:[(0,a.SB)()],key:"_error",value:void 0},{kind:"field",decorators:[(0,a.SB)()],key:"_errorLevel",value:void 0},{kind:"field",decorators:[(0,a.SB)()],key:"_templateResult",value:void 0},{kind:"field",key:"_unsubRenderTemplate",value:void 0},{kind:"method",key:"getCardSize",value:function(){return void 0===this._config?3:void 0===this._config.card_size?Math.round(this._config.content.split("\n").length/2)+(this._config.title?1:0):this._config.card_size}},{kind:"method",key:"setConfig",value:function(e){var t;if(!e.content)throw new Error("Content required");(null===(t=this._config)||void 0===t?void 0:t.content)!==e.content&&this._tryDisconnect(),this._config=e}},{kind:"method",key:"connectedCallback",value:function(){(0,i.Z)(o,"connectedCallback",this,3)([]),this._tryConnect()}},{kind:"method",key:"_computeCacheKey",value:function(){return l()(this._config)}},{kind:"method",key:"disconnectedCallback",value:function(){if((0,i.Z)(o,"disconnectedCallback",this,3)([]),this._tryDisconnect(),this._config&&this._templateResult){const e=this._computeCacheKey();k.set(e,this._templateResult)}}},{kind:"method",key:"willUpdate",value:function(e){if((0,i.Z)(o,"willUpdate",this,3)([e]),this._config&&!this._templateResult){const e=this._computeCacheKey();k.has(e)&&(this._templateResult=k.get(e))}}},{kind:"method",key:"render",value:function(){var e,t,n;return this._config?(0,r.dy)(p||(p=v` ${0} <ha-card .header="${0}" class="${0}"> <ha-markdown cache breaks .content="${0}"></ha-markdown> </ha-card> `),this._error?(0,r.dy)(m||(m=v` <ha-alert .alertType="${0}"> ${0} </ha-alert> `),(null===(e=this._errorLevel)||void 0===e?void 0:e.toLowerCase())||"error",this._error):r.Ld,this._config.text_only?void 0:this._config.title,(0,s.$)({"with-header":!!this._config.title,"text-only":null!==(t=this._config.text_only)&&void 0!==t&&t}),null===(n=this._templateResult)||void 0===n?void 0:n.result):r.Ld}},{kind:"method",key:"updated",value:function(e){if((0,i.Z)(o,"updated",this,3)([e]),!this._config||!this.hass)return;e.has("_config")&&this._tryConnect();const t=!!this._templateResult&&!1===this._config.show_empty&&0===this._templateResult.result.length;t!==this.hidden&&(this.style.display=t?"none":"",this.toggleAttribute("hidden",t),(0,h.B)(this,"card-visibility-changed",{value:!t}));const n=e.get("hass"),r=e.get("_config");n&&r&&n.themes===this.hass.themes&&r.theme===this._config.theme||(0,d.R)(this,this.hass.themes,this._config.theme)}},{kind:"method",key:"_tryConnect",value:async function(){if(void 0===this._unsubRenderTemplate&&this.hass&&this._config){this._error=void 0,this._errorLevel=void 0;try{this._unsubRenderTemplate=(0,u.N)(this.hass.connection,(e=>{"error"in e?"ERROR"!==e.level&&"ERROR"===this._errorLevel||(this._error=e.error,this._errorLevel=e.level):this._templateResult=e}),{template:this._config.content,entity_ids:this._config.entity_id,variables:{config:this._config,user:this.hass.user.name},strict:!0,report_errors:this.preview}),await this._unsubRenderTemplate}catch(e){this.preview&&(this._error=e.message,this._errorLevel=void 0),this._templateResult={result:this._config.content,listeners:{all:!1,domains:[],entities:[],time:!1}},this._unsubRenderTemplate=void 0}}}},{kind:"method",key:"_tryDisconnect",value:async function(){this._unsubRenderTemplate&&(this._unsubRenderTemplate.then((e=>e())).catch(),this._unsubRenderTemplate=void 0,this._error=void 0,this._errorLevel=void 0)}},{kind:"field",static:!0,key:"styles",value(){return(0,r.iv)(g||(g=v`ha-card{height:100%}ha-alert{margin-bottom:8px}ha-markdown{padding:16px;word-wrap:break-word;text-align:var(--card-text-align,inherit)}.with-header ha-markdown{padding:0 16px 16px}.text-only{background:0 0;box-shadow:none;border:none}.text-only ha-markdown{padding:2px 4px}`))}}]}}),r.oi)},80262:function(e,t,n){"use strict";n.d(t,{L:()=>o});n(71695),n(47021);class o{constructor(e){this._expiration=void 0,this._cache=new Map,this._expiration=e}get(e){return this._cache.get(e)}set(e,t){this._cache.set(e,t),this._expiration&&window.setTimeout((()=>this._cache.delete(e)),this._expiration)}has(e){return this._cache.has(e)}}},23265:function(e,t,n){var o={"./ha-icon":["65981","97406"],"./ha-icon-button-toggle":["79505","80175"],"./ha-svg-icon":["37583"],"./ha-icon-button-group":["45747","97792"],"./ha-svg-icon.ts":["37583"],"./ha-icon.ts":["65981","97406"],"./ha-icon-overflow-menu":["59959","91552","78456","56898","99287","14932"],"./ha-icon-next":["13928","99172"],"./ha-icon-picker":["21393","46379","66031","24199","78943","45760"],"./ha-qr-code.ts":["50634","53750","70472"],"./ha-icon-button-arrow-prev.ts":["54202","41069"],"./ha-icon-button-arrow-prev":["54202","41069"],"./ha-icon-overflow-menu.ts":["59959","91552","78456","56898","99287","14932"],"./ha-alert":["99426","4809"],"./ha-icon-button-next":["4635","51577"],"./ha-icon-button":["23334"],"./ha-icon-button-next.ts":["4635","51577"],"./ha-icon-picker.ts":["21393","46379","66031","24199","78943","45760"],"./ha-icon-button-group.ts":["45747","97792"],"./ha-icon-button-toggle.ts":["79505","80175"],"./ha-icon-button-arrow-next.ts":["54237","21559"],"./ha-icon-button-prev.ts":["5828","43537"],"./ha-icon-prev":["95499","87557"],"./ha-icon-prev.ts":["95499","87557"],"./ha-icon-button.ts":["23334"],"./ha-alert.ts":["99426","4809"],"./ha-icon-button-prev":["5828","43537"],"./ha-qr-code":["50634","53750","70472"],"./ha-icon-next.ts":["13928","99172"],"./ha-icon-button-arrow-next":["54237","21559"]};function i(e){if(!n.o(o,e))return Promise.resolve().then((function(){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}));var t=o[e],i=t[0];return Promise.all(t.slice(1).map(n.e)).then((function(){return n(i)}))}i.keys=()=>Object.keys(o),i.id=23265,e.exports=i},68289:function(e,t,n){"use strict";var o=n(40810),i=n(1569),r=n(27803),a=n(85779),s=TypeError,c=Object.defineProperty,l=i.self!==i;try{if(a){var d=Object.getOwnPropertyDescriptor(i,"self");!l&&d&&d.get&&d.enumerable||r(i,"self",{get:function(){return i},set:function(e){if(this!==i)throw new s("Illegal invocation");c(i,"self",{value:e,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}else o({global:!0,simple:!0,forced:l},{self:i})}catch(h){}},75351:function(e,t,n){"use strict";n.d(t,{Ud:()=>u});n(63721),n(52247),n(71695),n(52805),n(43451),n(9359),n(70104),n(48136),n(19423),n(40251),n(69235),n(12385),n(19134),n(5740),n(11740),n(46692),n(47021);const o=Symbol("Comlink.proxy"),i=Symbol("Comlink.endpoint"),r=Symbol("Comlink.releaseProxy"),a=Symbol("Comlink.finalizer"),s=Symbol("Comlink.thrown"),c=e=>"object"==typeof e&&null!==e||"function"==typeof e,l=new Map([["proxy",{canHandle:e=>c(e)&&e[o],serialize(e){const{port1:t,port2:n}=new MessageChannel;return d(e,t),[n,[n]]},deserialize(e){return e.start(),u(e)}}],["throw",{canHandle:e=>c(e)&&s in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function d(e,t=globalThis,n=["*"]){t.addEventListener("message",(function i(r){if(!r||!r.data)return;if(!function(e,t){for(const n of e){if(t===n||"*"===n)return!0;if(n instanceof RegExp&&n.test(t))return!0}return!1}(n,r.origin))return void console.warn(`Invalid origin '${r.origin}' for comlink proxy`);const{id:c,type:l,path:u}=Object.assign({path:[]},r.data),f=(r.data.argumentList||[]).map(_);let p;try{const t=u.slice(0,-1).reduce(((e,t)=>e[t]),e),n=u.reduce(((e,t)=>e[t]),e);switch(l){case"GET":p=n;break;case"SET":t[u.slice(-1)[0]]=_(r.data.value),p=!0;break;case"APPLY":p=n.apply(t,f);break;case"CONSTRUCT":p=function(e){return Object.assign(e,{[o]:!0})}(new n(...f));break;case"ENDPOINT":{const{port1:t,port2:n}=new MessageChannel;d(e,n),p=function(e,t){return y.set(e,t),e}(t,[t])}break;case"RELEASE":p=void 0;break;default:return}}catch(m){p={value:m,[s]:0}}Promise.resolve(p).catch((e=>({value:e,[s]:0}))).then((n=>{const[o,r]=b(n);t.postMessage(Object.assign(Object.assign({},o),{id:c}),r),"RELEASE"===l&&(t.removeEventListener("message",i),h(t),a in e&&"function"==typeof e[a]&&e[a]())})).catch((e=>{const[n,o]=b({value:new TypeError("Unserializable return value"),[s]:0});t.postMessage(Object.assign(Object.assign({},n),{id:c}),o)}))})),t.start&&t.start()}function h(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function u(e,t){const n=new Map;return e.addEventListener("message",(function(e){const{data:t}=e;if(!t||!t.id)return;const o=n.get(t.id);if(o)try{o(t)}finally{n.delete(t.id)}})),v(e,n,[],t)}function f(e){if(e)throw new Error("Proxy has been released and is not useable")}function p(e){return w(e,new Map,{type:"RELEASE"}).then((()=>{h(e)}))}const m=new WeakMap,g="FinalizationRegistry"in globalThis&&new FinalizationRegistry((e=>{const t=(m.get(e)||0)-1;m.set(e,t),0===t&&p(e)}));function v(e,t,n=[],o=function(){}){let a=!1;const s=new Proxy(o,{get(o,i){if(f(a),i===r)return()=>{!function(e){g&&g.unregister(e)}(s),p(e),t.clear(),a=!0};if("then"===i){if(0===n.length)return{then:()=>s};const o=w(e,t,{type:"GET",path:n.map((e=>e.toString()))}).then(_);return o.then.bind(o)}return v(e,t,[...n,i])},set(o,i,r){f(a);const[s,c]=b(r);return w(e,t,{type:"SET",path:[...n,i].map((e=>e.toString())),value:s},c).then(_)},apply(o,r,s){f(a);const c=n[n.length-1];if(c===i)return w(e,t,{type:"ENDPOINT"}).then(_);if("bind"===c)return v(e,t,n.slice(0,-1));const[l,d]=k(s);return w(e,t,{type:"APPLY",path:n.map((e=>e.toString())),argumentList:l},d).then(_)},construct(o,i){f(a);const[r,s]=k(i);return w(e,t,{type:"CONSTRUCT",path:n.map((e=>e.toString())),argumentList:r},s).then(_)}});return function(e,t){const n=(m.get(t)||0)+1;m.set(t,n),g&&g.register(e,t,e)}(s,e),s}function k(e){const t=e.map(b);return[t.map((e=>e[0])),(n=t.map((e=>e[1])),Array.prototype.concat.apply([],n))];var n}const y=new WeakMap;function b(e){for(const[t,n]of l)if(n.canHandle(e)){const[o,i]=n.serialize(e);return[{type:"HANDLER",name:t,value:o},i]}return[{type:"RAW",value:e},y.get(e)||[]]}function _(e){switch(e.type){case"HANDLER":return l.get(e.name).deserialize(e.value);case"RAW":return e.value}}function w(e,t,n,o){return new Promise((i=>{const r=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.set(r,i),e.start&&e.start(),e.postMessage(Object.assign({id:r},n),o)}))}}}]);
//# sourceMappingURL=30575.cac7c7df748fbccf.js.map