"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["44619"],{84334:function(t,e,i){i.d(e,{H:function(){return s},R:function(){return n}});const n=(t,e,i)=>t.subscribeMessage(t=>e(t),Object.assign({type:"render_template"},i)),s=(t,e,i,n,s)=>t.connection.subscribeMessage(s,{type:"template/start_preview",flow_id:e,flow_type:i,user_input:n})},67334:function(t,e,i){i.a(t,async function(t,n){try{i.r(e),i.d(e,{HuiMarkdownCard:function(){return b}});i(49255),i(16280),i(3362),i(62953);var s=i(40445),r=i(96196),o=i(77845),a=i(94333),h=i(30015),c=i.n(h),l=i(42372),d=i(1087),_=i(38962),u=(i(76776),i(3587),i(84334)),p=i(996),g=t([_]);_=(g.then?(await g)():g)[0];let m,f,v,y=t=>t;const w=new p.G(1e3);class b extends r.WF{static async getConfigElement(){return await i.e("90742").then(i.bind(i,4757)),document.createElement("hui-markdown-card-editor")}static getStubConfig(){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)."}}getCardSize(){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}setConfig(t){var e;if(!t.content)throw new Error("Content required");(null===(e=this._config)||void 0===e?void 0:e.content)!==t.content&&this._tryDisconnect(),this._config=t}connectedCallback(){super.connectedCallback(),this._tryConnect()}_computeCacheKey(){return c()(this._config)}disconnectedCallback(){if(super.disconnectedCallback(),this._tryDisconnect(),this._config&&this._templateResult){const t=this._computeCacheKey();w.set(t,this._templateResult)}}willUpdate(t){if(super.willUpdate(t),this._config&&!this._templateResult){const t=this._computeCacheKey();w.has(t)&&(this._templateResult=w.get(t))}}render(){var t,e,i;return this._config?(0,r.qy)(m||(m=y` ${0} <ha-card .header="${0}" class="${0}"> <ha-markdown cache breaks .content="${0}"></ha-markdown> </ha-card> `),this._error?(0,r.qy)(f||(f=y` <ha-alert .alertType="${0}"> ${0} </ha-alert> `),(null===(t=this._errorLevel)||void 0===t?void 0:t.toLowerCase())||"error",this._error):r.s6,this._config.text_only?void 0:this._config.title,(0,a.H)({"with-header":!!this._config.title,"text-only":null!==(e=this._config.text_only)&&void 0!==e&&e}),null===(i=this._templateResult)||void 0===i?void 0:i.result):r.s6}updated(t){if(super.updated(t),!this._config||!this.hass)return;t.has("_config")&&this._tryConnect();const e=!!this._templateResult&&!1===this._config.show_empty&&0===this._templateResult.result.length;e!==this.hidden&&(this.style.display=e?"none":"",this.toggleAttribute("hidden",e),(0,d.r)(this,"card-visibility-changed",{value:!e}));const i=t.get("hass"),n=t.get("_config");i&&n&&i.themes===this.hass.themes&&n.theme===this._config.theme||(0,l.Q)(this,this.hass.themes,this._config.theme)}async _tryConnect(){if(void 0===this._unsubRenderTemplate&&this.hass&&this._config){this._error=void 0,this._errorLevel=void 0;try{this._unsubRenderTemplate=(0,u.R)(this.hass.connection,t=>{"error"in t?"ERROR"!==t.level&&"ERROR"===this._errorLevel||(this._error=t.error,this._errorLevel=t.level):this._templateResult=t},{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(t){this.preview&&(this._error=t.message,this._errorLevel=void 0),this._templateResult={result:this._config.content,listeners:{all:!1,domains:[],entities:[],time:!1}},this._unsubRenderTemplate=void 0}}}async _tryDisconnect(){this._unsubRenderTemplate&&(this._unsubRenderTemplate.then(t=>t()).catch(),this._unsubRenderTemplate=void 0,this._error=void 0,this._errorLevel=void 0)}constructor(...t){super(...t),this.preview=!1}}b.styles=(0,r.AH)(v||(v=y`ha-card{height:100%;overflow-y:auto}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}`)),(0,s.Cg)([(0,o.MZ)({attribute:!1})],b.prototype,"hass",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],b.prototype,"preview",void 0),(0,s.Cg)([(0,o.wk)()],b.prototype,"_config",void 0),(0,s.Cg)([(0,o.wk)()],b.prototype,"_error",void 0),(0,s.Cg)([(0,o.wk)()],b.prototype,"_errorLevel",void 0),(0,s.Cg)([(0,o.wk)()],b.prototype,"_templateResult",void 0),b=(0,s.Cg)([(0,o.EM)("hui-markdown-card")],b),n()}catch(m){n(m)}})}}]);
//# sourceMappingURL=44619.c8ccba5fbd8ffd82.js.map