"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/asyncToGenerator"),r=require("@babel/runtime/helpers/classCallCheck"),t=require("@babel/runtime/helpers/createClass"),n=require("@babel/runtime/helpers/defineProperty"),i=require("@babel/runtime/regenerator"),s=require("./apiCore.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=a(e),u=a(r),l=a(t),h=a(n),f=a(i),c=function(){function e(){u.default(this,e),h.default(this,"refreshPromise",null),h.default(this,"refreshFn",void 0),this.refreshFn=s.refreshToken}var r;return l.default(e,[{key:"tryRefresh",value:(r=o.default(f.default.mark((function e(){var r=this;return f.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.refreshPromise||(this.refreshPromise=this.refreshFn().finally((function(){r.refreshPromise=null}))),e.abrupt("return",this.refreshPromise);case 2:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"isRefreshableAuthError",value:function(e){var r,t;return null!==(r=null===(t=e.isAuthenticationProblem)||void 0===t?void 0:t.call(e))&&void 0!==r&&r&&!e.isTermsProblem()&&!e.isLoginProblem()}},{key:"handleAuthFailure",value:function(e){this.isRefreshableAuthError(e)&&(console.error("Unrecoverable authentication failure detected;"),window.location.pathname.startsWith("/login")||(console.error("Redirecting to /login."),window.location.href="/login"))}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}();h.default(c,"instance",void 0),exports.AuthRecovery=c;
//# sourceMappingURL=AuthRecovery.js.map
