(self.webpackJsonp=self.webpackJsonp||[]).push([[37],{175:function(e,t,n){"use strict";n.r(t);var r=n(0),s=n(13),i=function(){function e(){this.commands={},this.cache={},this.msgId=0}return e.prototype.attach=function(){var e,t=this;e=this,window.addEventListener("connection-status",function(t){return e.fireMessage({type:"connection-status",payload:{event:t.detail}})}),function(e){window.addEventListener("haptic",function(t){return e.fireMessage({type:"haptic",payload:{hapticType:t.detail}})})}(this),window.externalBus=function(e){return t.receiveMessage(e)}},e.prototype.sendMessage=function(e){var t=this,n=++this.msgId;return e.id=n,this.fireMessage(e),new Promise(function(e,r){t.commands[n]={resolve:e,reject:r}})},e.prototype.fireMessage=function(e){e.id||(e.id=++this.msgId),this._sendExternal(e)},e.prototype.receiveMessage=function(e){var t=this.commands[e.id];t?"result"===e.type&&(e.success?t.resolve(e.result):t.reject(e.error)):console.warn("Received unknown msg ID",e.id)},e.prototype._sendExternal=function(e){window.externalApp?window.externalApp.externalBus(JSON.stringify(e)):window.webkit.messageHandlers.externalBus.postMessage(e)},e}();n.d(t,"createExternalAuth",function(){return a});if(!window.externalApp&&!window.webkit)throw new Error("External auth requires either externalApp or webkit defined on Window object.");var o=function(e){function t(t){return e.call(this,{hassUrl:t,clientId:"",refresh_token:"",access_token:"",expires_in:0,expires:0})||this}return Object(r.d)(t,e),t.prototype.refreshAccessToken=function(){return Object(r.b)(this,void 0,void 0,function(){var e,t,n;return Object(r.e)(this,function(r){switch(r.label){case 0:return e={callback:"externalAuthSetToken"},t=new Promise(function(e,t){window.externalAuthSetToken=function(n,r){return n?e(r):t(r)}}),[4,0];case 1:return r.sent(),window.externalApp?window.externalApp.getExternalAuth(JSON.stringify(e)):window.webkit.messageHandlers.getExternalAuth.postMessage(e),[4,t];case 2:return n=r.sent(),this.data.access_token=n.access_token,this.data.expires=1e3*n.expires_in+Date.now(),[2]}})})},t.prototype.revoke=function(){return Object(r.b)(this,void 0,void 0,function(){var e,t;return Object(r.e)(this,function(n){switch(n.label){case 0:return e={callback:"externalAuthRevokeToken"},t=new Promise(function(e,t){window.externalAuthRevokeToken=function(n,r){return n?e(r):t(r)}}),[4,0];case 1:return n.sent(),window.externalApp?window.externalApp.revokeExternalAuth(JSON.stringify(e)):window.webkit.messageHandlers.revokeExternalAuth.postMessage(e),[4,t];case 2:return n.sent(),[2]}})})},t}(s.a),a=function(e){var t=new o(e);return(window.externalApp&&window.externalApp.externalBus||window.webkit&&window.webkit.messageHandlers.externalBus)&&(t.external=new i,t.external.attach()),t}}}]);
//# sourceMappingURL=chunk.5c5f7a546bf7382bc014.js.map