"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[65620],{20873:function(t,n,a){a(50349);var e=!1;a.d(n,{Oc:function(){return"urn:x-cast:com.nabucasa.hast"},gk:function(){return"A078F6B0"},oS:function(){return e}})},50349:function(t,n,a){a.d(n,{I:function(){return"http://192.168.1.234:8123"},_:function(){return"5FE44367"}})},27480:function(t,n,a){a(26099),a(3362);var e=a(20873),i=a(50349),s=function(t,n){return t.sendMessage({type:"connect",refreshToken:n.data.refresh_token,clientId:n.data.clientId,hassUrl:e.oS?i.I:n.data.hassUrl})},o=function(t,n,a,s){return t.sendMessage({type:"show_lovelace_view",viewPath:a,urlPath:s||null,hassUrl:e.oS?i.I:n})},r=function(t,n){if(!t.castConnectedToOurHass)return new Promise(function(a){var e=t.addEventListener("connection-changed",function(){t.castConnectedToOurHass&&(e(),a())});s(t,n)})};a.d(n,{oK:function(){return s},tb:function(){return o},xV:function(){return r}})},95263:function(t,n,a){a.a(t,async function(t,e){try{a.r(n);var i,s,o,r,c,u,h=a(36854),l=a(98117),d=a(28430),f=a(97058),g=a(57567),v=a(25979),p=a(12463),_=a(16472),y=a(92297),A=(a(28706),a(26099),a(3362),a(15697)),m=a(57527),w=a(51209),M=a(48612),k=a(27480),x=a(98747),C=(a(34159),t([x]));x=(C.then?(await C)():C)[0];var b=function(t){function n(){var t;(0,g.A)(this,n);for(var a=arguments.length,e=new Array(a),i=0;i<a;i++)e[i]=arguments[i];return(t=(0,_.A)(this,n,[].concat(e)))._noHTTPS=!1,t}return(0,p.A)(n,t),(0,v.A)(n,[{key:"setConfig",value:function(t){this._config=(0,f.A)({icon:"mdi:television",name:"Home Assistant Cast",view:0},t)}},{key:"shouldUpdate",value:function(t){return!(1===t.size&&t.has("hass"))}},{key:"render",value:function(){if(!this._config)return m.s6;var t=this._castManager&&this._castManager.status&&this._config.view===this._castManager.status.lovelacePath&&this._config.dashboard===this._castManager.status.urlPath;return(0,m.qy)(i||(i=(0,d.A)([" <ha-icon .icon=",'></ha-icon> <div class="flex"> <div class="name">',"</div> "," </div> "])),this._config.icon,this._config.name,this._noHTTPS?(0,m.qy)(s||(s=(0,d.A)([" Cast requires HTTPS "]))):void 0===this._castManager?m.s6:null===this._castManager?(0,m.qy)(o||(o=(0,d.A)([" Cast API unavailable "]))):"NO_DEVICES_AVAILABLE"===this._castManager.castState?(0,m.qy)(r||(r=(0,d.A)([" No devices found "]))):(0,m.qy)(c||(c=(0,d.A)([' <div class="controls"> <google-cast-launcher></google-cast-launcher> <ha-button @click='," class=",' appearance="plain" size="s" .disabled=',"> SHOW </ha-button> </div> "])),this._sendLovelace,(0,M.H)({inactive:!t}),!this._castManager.status))}},{key:"firstUpdated",value:function(t){var e=this;(0,y.A)(n,"firstUpdated",this,3)([t]),"http:"===location.protocol&&"localhost"!==location.hostname&&(this._noHTTPS=!0),a.e(10081).then(a.bind(a,68216)).then(function(t){return(0,t.getCastManager)(e.hass.auth).then(function(t){e._castManager=t,t.addEventListener("connection-changed",function(){e.requestUpdate()}),t.addEventListener("state-changed",function(){e.requestUpdate()})},function(){e._castManager=null})})}},{key:"updated",value:function(t){(0,y.A)(n,"updated",this,3)([t]),this._config&&this._config.hide_if_unavailable&&(this.style.display=this._castManager&&"NO_DEVICES_AVAILABLE"!==this._castManager.castState?"":"none")}},{key:"_sendLovelace",value:(e=(0,l.A)((0,h.A)().m(function t(){return(0,h.A)().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,(0,k.xV)(this._castManager,this.hass.auth);case 1:(0,k.tb)(this._castManager,this.hass.auth.data.hassUrl,this._config.view,this._config.dashboard);case 2:return t.a(2)}},t,this)})),function(){return e.apply(this,arguments)})}]);var e}(m.WF);b.styles=(0,m.AH)(u||(u=(0,d.A)([":host{align-items:center;display:flex}ha-icon{color:var(--state-icon-color);padding:8px}.flex{margin-left:16px;flex:1;justify-content:space-between;align-items:center;margin-inline-start:16px;margin-inline-end:initial;display:flex}.name{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.controls{align-items:center;display:flex}google-cast-launcher{margin-right:.57em;cursor:pointer;width:24px;height:24px;margin-inline-start:initial;margin-inline-end:-.57em;display:inline-block}.inactive{padding:0 4px}"]))),(0,A.Cg)([(0,w.MZ)({attribute:!1})],b.prototype,"hass",void 0),(0,A.Cg)([(0,w.wk)()],b.prototype,"_config",void 0),(0,A.Cg)([(0,w.wk)()],b.prototype,"_castManager",void 0),(0,A.Cg)([(0,w.wk)()],b.prototype,"_noHTTPS",void 0),b=(0,A.Cg)([(0,w.EM)("hui-cast-row")],b),e()}catch(S){e(S)}})}}]);
//# sourceMappingURL=65620.5b6f3abe748ddd14.js.map