"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["10405"],{44688:function(t,a,e){e.d(a,{Oc:function(){return o},gk:function(){return i},oS:function(){return s}});var n=e(50816);const s=!1,i=s?n._:"A078F6B0",o="urn:x-cast:com.nabucasa.hast"},50816:function(t,a,e){e.d(a,{I:function(){return s},_:function(){return n}});const n="5FE44367",s="http://192.168.1.234:8123"},40461:function(t,a,e){e.d(a,{oK:function(){return i},tb:function(){return o},xV:function(){return c}});e(3362);var n=e(44688),s=e(50816);const i=(t,a)=>t.sendMessage({type:"connect",refreshToken:a.data.refresh_token,clientId:a.data.clientId,hassUrl:n.oS?s.I:a.data.hassUrl}),o=(t,a,e,i)=>t.sendMessage({type:"show_lovelace_view",viewPath:e,urlPath:i||null,hassUrl:n.oS?s.I:a}),c=(t,a)=>{if(!t.castConnectedToOurHass)return new Promise(e=>{const n=t.addEventListener("connection-changed",()=>{t.castConnectedToOurHass&&(n(),e())});i(t,a)})}},96612:function(t,a,e){e.a(t,async function(t,n){try{e.r(a);e(3362),e(62953);var s=e(40445),i=e(96196),o=e(77845),c=e(94333),r=e(40461),h=e(18350),l=(e(88945),t([h]));h=(l.then?(await l)():l)[0];let d,u,g,f,p,_,v=t=>t;class m extends i.WF{setConfig(t){this._config=Object.assign({icon:"mdi:television",name:"Home Assistant Cast",view:0},t)}shouldUpdate(t){return!(1===t.size&&t.has("hass"))}render(){if(!this._config)return i.s6;const t=this._castManager&&this._castManager.status&&this._config.view===this._castManager.status.lovelacePath&&this._config.dashboard===this._castManager.status.urlPath;return(0,i.qy)(d||(d=v` <ha-icon .icon="${0}"></ha-icon> <div class="flex"> <div class="name">${0}</div> ${0} </div> `),this._config.icon,this._config.name,this._noHTTPS?(0,i.qy)(u||(u=v` Cast requires HTTPS `)):void 0===this._castManager?i.s6:null===this._castManager?(0,i.qy)(g||(g=v` Cast API unavailable `)):"NO_DEVICES_AVAILABLE"===this._castManager.castState?(0,i.qy)(f||(f=v` No devices found `)):(0,i.qy)(p||(p=v` <div class="controls"> <google-cast-launcher></google-cast-launcher> <ha-button @click="${0}" class="${0}" appearance="plain" size="small" .disabled="${0}"> SHOW </ha-button> </div> `),this._sendLovelace,(0,c.H)({inactive:!t}),!this._castManager.status))}firstUpdated(t){super.firstUpdated(t),"http:"===location.protocol&&"localhost"!==location.hostname&&(this._noHTTPS=!0),e.e("80444").then(e.bind(e,51671)).then(({getCastManager:t})=>t(this.hass.auth).then(t=>{this._castManager=t,t.addEventListener("connection-changed",()=>{this.requestUpdate()}),t.addEventListener("state-changed",()=>{this.requestUpdate()})},()=>{this._castManager=null}))}updated(t){super.updated(t),this._config&&this._config.hide_if_unavailable&&(this.style.display=this._castManager&&"NO_DEVICES_AVAILABLE"!==this._castManager.castState?"":"none")}async _sendLovelace(){await(0,r.xV)(this._castManager,this.hass.auth),(0,r.tb)(this._castManager,this.hass.auth.data.hassUrl,this._config.view,this._config.dashboard)}constructor(...t){super(...t),this._noHTTPS=!1}}m.styles=(0,i.AH)(_||(_=v`:host{display:flex;align-items:center}ha-icon{padding:8px;color:var(--state-icon-color)}.flex{flex:1;margin-left:16px;margin-inline-start:16px;margin-inline-end:initial;display:flex;justify-content:space-between;align-items:center}.name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.controls{display:flex;align-items:center}google-cast-launcher{margin-right:.57em;margin-inline-end:-.57em;margin-inline-start:initial;cursor:pointer;display:inline-block;height:24px;width:24px}.inactive{padding:0 4px}`)),(0,s.Cg)([(0,o.MZ)({attribute:!1})],m.prototype,"hass",void 0),(0,s.Cg)([(0,o.wk)()],m.prototype,"_config",void 0),(0,s.Cg)([(0,o.wk)()],m.prototype,"_castManager",void 0),(0,s.Cg)([(0,o.wk)()],m.prototype,"_noHTTPS",void 0),m=(0,s.Cg)([(0,o.EM)("hui-cast-row")],m),n()}catch(d){n(d)}})}}]);
//# sourceMappingURL=10405.bb2cb4dddc118029.js.map