export const __rspack_esm_id="33495";export const __rspack_esm_ids=["33495"];export const __webpack_modules__={25995(e,t,r){r.d(t,{Vw:()=>o,kG:()=>n,y6:()=>s});const a=(e,t,r)=>new Promise((a,s)=>{const n=document.createElement(e);let o="src",i="body";switch(n.onload=()=>a(t),n.onerror=()=>s(t),e){case"script":n.async=!0,r&&(n.type=r);break;case"link":n.type="text/css",n.rel="stylesheet",o="href",i="head"}n[o]=t,document[i].appendChild(n)}),s=e=>a("link",e),n=e=>a("script",e),o=e=>a("script",e,"module")},6378(e,t,r){r.r(t),r.d(t,{HaPanelCustom:()=>u});var a=r(62826),s=r(96196),n=r(44457),o=r(91926),i=r(19459);var l=r(25995);const c={},p=e=>e.html_url?{type:"html",url:e.html_url}:e.module_url&&e.js_url||e.module_url?{type:"module",url:e.module_url}:{type:"js",url:e.js_url};r(18111),r(7588);const h=(e,t)=>{"setProperties"in e?e.setProperties(t):Object.keys(t).forEach(r=>{e[r]=t[r]})};class u extends s.mN{createRenderRoot(){return this}registerIframe(e,t){e(this.panel,{hass:this.hass,narrow:this.narrow,route:this.route}),this._setProperties=t}disconnectedCallback(){super.disconnectedCallback(),this._cleanupPanel()}update(e){if(super.update(e),e.has("panel")){const t=e.get("panel");if(!(0,i.b)(t,this.panel))return t&&this._cleanupPanel(),void this._createPanel(this.panel)}if(!this._setProperties)return;const t={};for(const r of e.keys())t[r]=this[r];this._setProperties(t)}_cleanupPanel(){for(delete window.customPanel,this._setProperties=void 0;this.lastChild;)this.removeChild(this.lastChild)}_createPanel(e){const t=e.config._panel_custom,r=p(t),a=document.createElement("a");if(a.href=r.url,!t.trust_external&&!["localhost","127.0.0.1",location.hostname].includes(a.hostname)&&!confirm(`${this.hass.localize("ui.panel.custom.external_panel.question_trust",{name:t.name,link:a.href})}\n\n           ${this.hass.localize("ui.panel.custom.external_panel.complete_access")}\n\n           (${this.hass.localize("ui.panel.custom.external_panel.hide_message")})`))return;if(!t.embed_iframe)return void(e=>{const t=p(e);return"js"===t.type?(t.url in c||(c[t.url]=(0,l.kG)(t.url)),c[t.url]):"module"===t.type?(0,l.Vw)(t.url):Promise.reject("No valid url found in panel config.")})(t).then(()=>{const r=(e=>{const t="html_url"in e?`ha-panel-${e.name}`:e.name;return document.createElement(t)})(t);this._setProperties=e=>h(r,e),h(r,{panel:e,hass:this.hass,narrow:this.narrow,route:this.route}),this.appendChild(r)},()=>{alert(`Unable to load custom panel from ${a.href}`)});window.customPanel=this;const s=this.panel.title?`title="${this.panel.title}"`:"";this.innerHTML=`\n      <style>\n        iframe {\n          border: 0;\n          width: calc(100% - var(--safe-area-inset-right, 0px));\n          height: calc(100% - var(--safe-area-inset-top, 0px) - var(--safe-area-inset-bottom, 0px));\n          display: block;\n          background-color: var(--primary-background-color);\n          margin-top: var(--safe-area-inset-top);\n          margin-bottom: var(--safe-area-inset-bottom);\n          margin-right: var(--safe-area-inset-right);\n        }\n        @media (max-width: 870px) {\n          iframe {\n            width: calc(100% - var(--safe-area-inset-left, 0px) - var(--safe-area-inset-right, 0px));\n            margin-left: var(--safe-area-inset-left);\n          }\n        }\n      </style>\n      <iframe ${s}></iframe>`.trim();const n=this.querySelector("iframe").contentWindow.document;n.open(),n.write(`<!doctype html><script src='${window.customPanelJS}'><\/script>`),n.close()}constructor(...e){super(...e),this.narrow=!1,this.navigate=(e,t)=>(0,o.o)(e,t)}}(0,a.Cg)([(0,n.MZ)({attribute:!1})],u.prototype,"hass",void 0),(0,a.Cg)([(0,n.MZ)({type:Boolean})],u.prototype,"narrow",void 0),(0,a.Cg)([(0,n.MZ)({attribute:!1})],u.prototype,"route",void 0),(0,a.Cg)([(0,n.MZ)({attribute:!1})],u.prototype,"panel",void 0),u=(0,a.Cg)([(0,n.EM)("ha-panel-custom")],u)}};
//# sourceMappingURL=33495.2d6f3bf0e74fec86.js.map