"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[50998],{48030:function(e,t,n){n(26099),n(3362);var r=function(e,t,n){return new Promise(function(r,a){var o=document.createElement(e),i="src",s="body";switch(o.onload=function(){return r(t)},o.onerror=function(){return a(t)},e){case"script":o.async=!0,n&&(o.type=n);break;case"link":o.type="text/css",o.rel="stylesheet",i="href",s="head"}o[i]=t,document[s].appendChild(o)})},a=function(e){return r("link",e)},o=function(e){return r("script",e)},i=function(e){return r("script",e,"module")};n.d(t,{Vw:function(){return i},kG:function(){return o},y6:function(){return a}})},40885:function(e,t,n){n.r(t),n.d(t,{HaPanelCustom:function(){return _}});var r=n(61051),a=n(57567),o=n(25979),i=n(12463),s=n(16472),l=n(92297),c=(n(28706),n(74423),n(23792),n(26099),n(47764),n(42762),n(62953),n(15697)),u=n(57527),h=n(51209),d=n(56245),p=n(73286),f=(n(3362),n(48030)),m={},y=function(e){return e.html_url?{type:"html",url:e.html_url}:e.module_url&&e.js_url?{type:"js",url:e.js_url}:e.module_url?{type:"module",url:e.module_url}:{type:"js",url:e.js_url}},v=(n(18111),n(7588),n(79432),n(23500),function(e,t){"setProperties"in e?e.setProperties(t):Object.keys(t).forEach(function(n){e[n]=t[n]})}),_=function(e){function t(){var e;(0,a.A)(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return(e=(0,s.A)(this,t,[].concat(r))).narrow=!1,e._wasDisconnected=!1,e.navigate=function(e,t){return(0,d.oo)(e,t)},e}return(0,i.A)(t,e),(0,o.A)(t,[{key:"createRenderRoot",value:function(){return this}},{key:"registerIframe",value:function(e,t){var n;e(this.panel,{hass:this.hass,narrow:this.narrow,route:this.route}),this._setProperties=t,null===(n=this.querySelector("iframe"))||void 0===n||n.classList.add("loaded")}},{key:"connectedCallback",value:function(){(0,l.A)(t,"connectedCallback",this,3)([]),this._wasDisconnected&&this.panel&&(this._wasDisconnected=!1,this._createPanel(this.panel))}},{key:"disconnectedCallback",value:function(){(0,l.A)(t,"disconnectedCallback",this,3)([]),this._wasDisconnected=!0,this._cleanupPanel()}},{key:"update",value:function(e){if((0,l.A)(t,"update",this,3)([e]),e.has("panel")){var n=e.get("panel");if(!(0,p.b)(n,this.panel))return n&&this._cleanupPanel(),void this._createPanel(this.panel)}if(this._setProperties){var a,o={},i=(0,r.A)(e.keys());try{for(i.s();!(a=i.n()).done;){var s=a.value;o[s]=this[s]}}catch(c){i.e(c)}finally{i.f()}this._setProperties(o)}}},{key:"_cleanupPanel",value:function(){for(delete window.customPanel,this._setProperties=void 0;this.lastChild;)this.removeChild(this.lastChild)}},{key:"_createPanel",value:function(e){var t=this;this.style.backgroundColor="var(--primary-background-color)";var n=e.config._panel_custom,r=y(n),a=document.createElement("a");if(a.href=r.url,n.trust_external||["localhost","127.0.0.1",location.hostname].includes(a.hostname)||confirm("".concat(this.hass.localize("ui.panel.custom.external_panel.question_trust",{name:n.name,link:a.href}),"\n\n           ").concat(this.hass.localize("ui.panel.custom.external_panel.complete_access"),"\n\n           (").concat(this.hass.localize("ui.panel.custom.external_panel.hide_message"),")")))if(n.embed_iframe){var o,i;window.customPanel=this;var s=this.panel.title?'title="'.concat(this.panel.title,'"'):"";this.innerHTML="\n      <style>\n        iframe {\n          border: none;\n          width: 100%;\n          height: 100vh;\n          height: 100dvh;\n          display: block;\n          background-color: var(--primary-background-color);\n          opacity: 0;\n          transition: opacity var(--ha-animation-duration-normal) ease;\n        }\n        iframe.loaded {\n          opacity: 1;\n        }\n      </style>\n      <iframe ".concat(s,"></iframe>").trim();var l=this.querySelector("iframe").contentWindow.document;l.open(),l.write("<!doctype html><script src='".concat(window.customPanelJS,"'><\/script>")),l.close()}else(o=n,i=y(o),"js"===i.type?(i.url in m||(m[i.url]=(0,f.kG)(i.url)),m[i.url]):"module"===i.type?(0,f.Vw)(i.url):Promise.reject("No valid url found in panel config.")).then(function(){if(t.isConnected&&!t._setProperties){var r=function(e){var t="html_url"in e?"ha-panel-".concat(e.name):e.name;return document.createElement(t)}(n);t._setProperties=function(e){return v(r,e)},v(r,{panel:e,hass:t.hass,narrow:t.narrow,route:t.route}),t.appendChild(r)}},function(){alert("Unable to load custom panel from ".concat(a.href))})}}])}(u.mN);(0,c.Cg)([(0,h.MZ)({attribute:!1})],_.prototype,"hass",void 0),(0,c.Cg)([(0,h.MZ)({type:Boolean})],_.prototype,"narrow",void 0),(0,c.Cg)([(0,h.MZ)({attribute:!1})],_.prototype,"route",void 0),(0,c.Cg)([(0,h.MZ)({attribute:!1})],_.prototype,"panel",void 0),_=(0,c.Cg)([(0,h.EM)("ha-panel-custom")],_)}}]);
//# sourceMappingURL=50998.0809a7936f5c3317.js.map