(window.webpackJsonp=window.webpackJsonp||[]).push([[134],{748:function(t,e,n){"use strict";n.r(e);var s,a,i=n(89),r=n(447),o=n(446);function c(t,e){for(var n=0;n<e.length;n++){var s=e[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}n.d(e,"CastManager",function(){return u}),n.d(e,"getCastManager",function(){return h});var u=function(){function t(e){var n=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.auth=void 0,this.status=void 0,this._eventListeners={},this.auth=e;var s=this.castContext;s.setOptions({receiverApplicationId:r.a,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),s.addEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED,function(t){return n._sessionStateChanged(t)}),s.addEventListener(cast.framework.CastContextEventType.CAST_STATE_CHANGED,function(t){return n._castStateChanged(t)})}var e,n,s;return e=t,(n=[{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:"sendMessage",value:function(t){this.castSession.sendMessage(r.d,t)}},{key:"requestSession",value:function(){return this.castContext.requestSession()}},{key:"_fireEvent",value:function(t){var e=!0,n=!1,s=void 0;try{for(var a,i=(this._eventListeners[t]||[])[Symbol.iterator]();!(e=(a=i.next()).done);e=!0){(0,a.value)()}}catch(r){n=!0,s=r}finally{try{e||null==i.return||i.return()}finally{if(n)throw s}}}},{key:"_receiveMessage",value:function(t){"receiver_status"===t.type&&(this.status=t,this._fireEvent("connection-changed"))}},{key:"_sessionStateChanged",value:function(t){"SESSION_STARTED"===t.sessionState||"SESSION_RESUMED"===t.sessionState?(this.auth?Object(o.a)(this,this.auth):this.sendMessage({type:"get_status"}),this._attachMessageListener()):"SESSION_ENDED"===t.sessionState&&(this.status=void 0,this._fireEvent("connection-changed"))}},{key:"_castStateChanged",value:function(t){this._fireEvent("state-changed")}},{key:"_attachMessageListener",value:function(){var t=this;this.castSession.addMessageListener(r.d,function(e,n){return t._receiveMessage(JSON.parse(n))})}},{key:"castConnectedToOurHass",get:function(){return void 0!==this.status&&void 0!==this.auth&&this.status.connected&&(this.status.hassUrl===this.auth.data.hassUrl||r.b&&this.status.hassUrl===r.c)}},{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()}}])&&c(e.prototype,n),s&&c(e,s),t}(),h=function(t){return a||(a=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),Object(i.b)("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 u(t)})),a}}}]);
//# sourceMappingURL=chunk.16e067e8f61b4d5724a2.js.map