"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["80444"],{51671:function(t,e,n){n.d(e,{getCastManager:function(){return v}});var s,i,a=n(31432),r=n(44734),o=n(43080),c=(n(16280),n(25276),n(44114),n(54554),n(79432),n(58335),n(26099),n(3362),n(25995)),u=n(44688),h=n(50816),f=n(40461),d=function(){return(0,o.A)(function t(e){var n=this;(0,r.A)(this,t),this._eventListeners={},this._sessionStateChanged=function(t){"SESSION_STARTED"===t.sessionState||"SESSION_RESUMED"===t.sessionState?(n.auth?(0,f.oK)(n,n.auth):n.sendMessage({type:"get_status"}),n._attachMessageListener()):"SESSION_ENDED"===t.sessionState&&(n.status=void 0,n._fireEvent("connection-changed"))},this._castStateChanged=function(t){n._fireEvent("state-changed")},this.auth=e;var s=this.castContext;s.setOptions({receiverApplicationId:u.gk,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),s.addEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED,this._sessionStateChanged),s.addEventListener(cast.framework.CastContextEventType.CAST_STATE_CHANGED,this._castStateChanged)},[{key:"addEventListener",value:function(t,e){var n=this;return t in this._eventListeners||(this._eventListeners[t]=[]),this._eventListeners[t].push(e),function(){n._eventListeners[t].splice(n._eventListeners[t].indexOf(e))}}},{key:"castConnectedToOurHass",get:function(){return void 0!==this.status&&void 0!==this.auth&&this.status.connected&&(this.status.hassUrl===this.auth.data.hassUrl||u.oS&&this.status.hassUrl===h.I)}},{key:"sendMessage",value:function(t){this.castSession.sendMessage(u.Oc,t)}},{key:"castState",get:function(){return this.castContext.getCastState()}},{key:"castContext",get:function(){return cast.framework.CastContext.getInstance()}},{key:"castSession",get:function(){return this.castContext.getCurrentSession()}},{key:"requestSession",value:function(){return this.castContext.requestSession()}},{key:"_fireEvent",value:function(t){var e,n=(0,a.A)(this._eventListeners[t]||[]);try{for(n.s();!(e=n.n()).done;){(0,e.value)()}}catch(s){n.e(s)}finally{n.f()}}},{key:"_receiveMessage",value:function(t){"receiver_status"===t.type&&(this.status=t,this._fireEvent("connection-changed"))}},{key:"_attachMessageListener",value:function(){var t=this;this.castSession.addMessageListener(u.Oc,function(e,n){return t._receiveMessage(JSON.parse(n))})}}])}(),v=function(t){return i||(i=function(){if(s)return s;s=new Promise(function(t){window.__onGCastApiAvailable=t});var t=document.createElement("div");return t.id="cast",document.body.append(t),(0,c.kG)("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"),s}().then(function(e){if(!e)throw new Error("No Cast API available");return new d(t)})),i}},25995:function(t,e,n){n.d(e,{Vw:function(){return r},kG:function(){return a},y6:function(){return i}});n(26099),n(3362);var s=function(t,e,n){return new Promise(function(s,i){var a=document.createElement(t),r="src",o="body";switch(a.onload=function(){return s(e)},a.onerror=function(){return i(e)},t){case"script":a.async=!0,n&&(a.type=n);break;case"link":a.type="text/css",a.rel="stylesheet",r="href",o="head"}a[r]=e,document[o].appendChild(a)})},i=function(t){return s("link",t)},a=function(t){return s("script",t)},r=function(t){return s("script",t,"module")}}}]);
//# sourceMappingURL=80444.50172773ff35404e.js.map