import{SDK_VERSION as e,_getProvider,_registerComponent as t,registerVersion as r,getApp as n}from"https://www.gstatic.com/firebasejs/10.8.0/firebase-app.js";var extendStatics=function(e,t){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},extendStatics(e,t)};function __extends(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}var __assign=function(){return __assign=Object.assign||function __assign(e){for(var t,r=1,n=arguments.length;r0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]>2,d=(3&i)<<4|s>>4;let l=(15&s)<<2|u>>6,h=63&u;a||(h=64,o||(l=64)),n.push(r[c],r[d],r[l],r[h])}return n.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(function(e){const t=[];let r=0;for(let n=0;n>6|192,t[r++]=63&i|128):55296==(64512&i)&&n+1>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128)}return t}(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){const t=[];let r=0,n=0;for(;r191&&i<224){const o=e[r++];t[n++]=String.fromCharCode((31&i)<<6|63&o)}else if(i>239&&i<365){const o=((7&i)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536;t[n++]=String.fromCharCode(55296+(o>>10)),t[n++]=String.fromCharCode(56320+(1023&o))}else{const o=e[r++],s=e[r++];t[n++]=String.fromCharCode((15&i)<<12|(63&o)<<6|63&s)}}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();const r=t?this.charToByteMapWebSafe_:this.charToByteMap_,n=[];for(let t=0;t>4;if(n.push(u),64!==s){const e=o<<4&240|s>>2;if(n.push(e),64!==a){const e=s<<6&192|a;n.push(e)}}}return n},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class DecodeBase64StringError extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}function getUA(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}class FirebaseError extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name="FirebaseError",Object.setPrototypeOf(this,FirebaseError.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,ErrorFactory.prototype.create)}}class ErrorFactory{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){const r=t[0]||{},n=`${this.service}/${e}`,i=this.errors[e],s=i?function replaceTemplate(e,t){return e.replace(o,((e,r)=>{const n=t[r];return null!=n?String(n):`<${r}?>`}))}(i,r):"Error",a=`${this.serviceName}: ${s} (${n}).`;return new FirebaseError(n,a,r)}}const o=/\{\$([^}]+)}/g;function deepEqual(e,t){if(e===t)return!0;const r=Object.keys(e),n=Object.keys(t);for(const i of r){if(!n.includes(i))return!1;const r=e[i],o=t[i];if(isObject(r)&&isObject(o)){if(!deepEqual(r,o))return!1}else if(r!==o)return!1}for(const e of n)if(!r.includes(e))return!1;return!0}function isObject(e){return null!==e&&"object"==typeof e}function querystring(e){const t=[];for(const[r,n]of Object.entries(e))Array.isArray(n)?n.forEach((e=>{t.push(encodeURIComponent(r)+"="+encodeURIComponent(e))})):t.push(encodeURIComponent(r)+"="+encodeURIComponent(n));return t.length?"&"+t.join("&"):""}function querystringDecode(e){const t={};return e.replace(/^\?/,"").split("&").forEach((e=>{if(e){const[r,n]=e.split("=");t[decodeURIComponent(r)]=decodeURIComponent(n)}})),t}function extractQuerystring(e){const t=e.indexOf("?");if(!t)return"";const r=e.indexOf("#",t);return e.substring(t,r>0?r:void 0)}class ObserverProxy{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then((()=>{e(this)})).catch((e=>{this.error(e)}))}next(e){this.forEachObserver((t=>{t.next(e)}))}error(e){this.forEachObserver((t=>{t.error(e)})),this.close(e)}complete(){this.forEachObserver((e=>{e.complete()})),this.close()}subscribe(e,t,r){let n;if(void 0===e&&void 0===t&&void 0===r)throw new Error("Missing Observer.");n=function implementsAnyMethods(e,t){if("object"!=typeof e||null===e)return!1;for(const r of t)if(r in e&&"function"==typeof e[r])return!0;return!1}(e,["next","error","complete"])?e:{next:e,error:t,complete:r},void 0===n.next&&(n.next=noop),void 0===n.error&&(n.error=noop),void 0===n.complete&&(n.complete=noop);const i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then((()=>{try{this.finalError?n.error(this.finalError):n.complete()}catch(e){}})),this.observers.push(n),i}unsubscribeOne(e){void 0!==this.observers&&void 0!==this.observers[e]&&(delete this.observers[e],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t{if(void 0!==this.observers&&void 0!==this.observers[e])try{t(this.observers[e])}catch(e){"undefined"!=typeof console&&console.error&&console.error(e)}}))}close(e){this.finalized||(this.finalized=!0,void 0!==e&&(this.finalError=e),this.task.then((()=>{this.observers=void 0,this.onNoObservers=void 0})))}}function noop(){}function getModularInstance(e){return e&&e._delegate?e._delegate:e}class Component{constructor(e,t,r){this.name=e,this.instanceFactory=t,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}var s;!function(e){e[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.SILENT=5]="SILENT"}(s||(s={}));const a={debug:s.DEBUG,verbose:s.VERBOSE,info:s.INFO,warn:s.WARN,error:s.ERROR,silent:s.SILENT},u=s.INFO,c={[s.DEBUG]:"log",[s.VERBOSE]:"log",[s.INFO]:"info",[s.WARN]:"warn",[s.ERROR]:"error"},defaultLogHandler=(e,t,...r)=>{if(t3)throw n;return this.db&&(this.db.close(),this.db=void 0),[3,6];case 6:return[3,1];case 7:return[2]}}))}))},IndexedDBLocalPersistence.prototype.initializeServiceWorkerMessaging=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,_isWorker()?this.initializeReceiver():this.initializeSender()]}))}))},IndexedDBLocalPersistence.prototype.initializeReceiver=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){return this.receiver=d._getInstance(function _getWorkerGlobalScope(){return _isWorker()?self:null}()),this.receiver._subscribe("keyChanged",(function(t,r){return __awaiter(e,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:return[4,this._poll()];case 1:return[2,{keyProcessed:e.sent().includes(r.key)}]}}))}))})),this.receiver._subscribe("ping",(function(t,r){return __awaiter(e,void 0,void 0,(function(){return __generator(this,(function(e){return[2,["keyChanged"]]}))}))})),[2]}))}))},IndexedDBLocalPersistence.prototype.initializeSender=function(){var e,t;return __awaiter(this,void 0,void 0,(function(){var r,n;return __generator(this,(function(i){switch(i.label){case 0:return r=this,[4,_getActiveServiceWorker()];case 1:return r.activeServiceWorker=i.sent(),this.activeServiceWorker?(this.sender=new l(this.activeServiceWorker),[4,this.sender._send("ping",{},800)]):[2];case 2:return(n=i.sent())?((null===(e=n[0])||void 0===e?void 0:e.fulfilled)&&(null===(t=n[0])||void 0===t?void 0:t.value.includes("keyChanged"))&&(this.serviceWorkerReceiverAvailable=!0),[2]):[2]}}))}))},IndexedDBLocalPersistence.prototype.notifyServiceWorker=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:if(!this.sender||!this.activeServiceWorker||function _getServiceWorkerController(){var e;return(null===(e=null===navigator||void 0===navigator?void 0:navigator.serviceWorker)||void 0===e?void 0:e.controller)||null}()!==this.activeServiceWorker)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}}))}))},IndexedDBLocalPersistence.prototype._isAvailable=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:return t.trys.push([0,4,,5]),indexedDB?[4,_openDatabase()]:[2,!1];case 1:return[4,_putObject(e=t.sent(),"__sak","1")];case 2:return t.sent(),[4,_deleteObject(e,"__sak")];case 3:return t.sent(),[2,!0];case 4:return t.sent(),[3,5];case 5:return[2,!1]}}))}))},IndexedDBLocalPersistence.prototype._withPendingWrite=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:this.pendingWrites++,t.label=1;case 1:return t.trys.push([1,,3,4]),[4,e()];case 2:return t.sent(),[3,4];case 3:return this.pendingWrites--,[7];case 4:return[2]}}))}))},IndexedDBLocalPersistence.prototype._set=function(e,t){return __awaiter(this,void 0,void 0,(function(){var r=this;return __generator(this,(function(n){return[2,this._withPendingWrite((function(){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(r){switch(r.label){case 0:return[4,this._withRetries((function(r){return _putObject(r,e,t)}))];case 1:return r.sent(),this.localCache[e]=t,[2,this.notifyServiceWorker(e)]}}))}))}))]}))}))},IndexedDBLocalPersistence.prototype._get=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){switch(r.label){case 0:return[4,this._withRetries((function(t){return function getObject(e,t){return __awaiter(this,void 0,void 0,(function(){var r,n;return __generator(this,(function(i){switch(i.label){case 0:return r=getObjectStore(e,!1).get(t),[4,new p(r).toPromise()];case 1:return[2,void 0===(n=i.sent())?null:n.value]}}))}))}(t,e)}))];case 1:return t=r.sent(),this.localCache[e]=t,[2,t]}}))}))},IndexedDBLocalPersistence.prototype._remove=function(e){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(r){return[2,this._withPendingWrite((function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:return[4,this._withRetries((function(t){return _deleteObject(t,e)}))];case 1:return t.sent(),delete this.localCache[e],[2,this.notifyServiceWorker(e)]}}))}))}))]}))}))},IndexedDBLocalPersistence.prototype._poll=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,r,n,i,o,s,a,u,c,d;return __generator(this,(function(l){switch(l.label){case 0:return[4,this._withRetries((function(e){var t=getObjectStore(e,!1).getAll();return new p(t).toPromise()}))];case 1:if(!(e=l.sent()))return[2,[]];if(0!==this.pendingWrites)return[2,[]];if(t=[],r=new Set,0!==e.length)for(n=0,i=e;ne,"Short delay should be less than long delay!"),this.isMobile=function isMobileCordova(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(getUA())}()||function isReactNative(){return"object"==typeof navigator&&"ReactNative"===navigator.product}()}return Delay.prototype.get=function(){return _isOnline()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)},Delay}();function _emulatorUrl(e,t){debugAssert(e.emulator,"Emulator should always be set here");var r=e.emulator.url;return t?"".concat(r).concat(t.startsWith("/")?t.slice(1):t):r}var E,w=function(){function FetchProvider(){}return FetchProvider.initialize=function(e,t,r){this.fetchImpl=e,t&&(this.headersImpl=t),r&&(this.responseImpl=r)},FetchProvider.fetch=function(){return this.fetchImpl?this.fetchImpl:"undefined"!=typeof self&&"fetch"in self?self.fetch:"undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch:"undefined"!=typeof fetch?fetch:void debugFail("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")},FetchProvider.headers=function(){return this.headersImpl?this.headersImpl:"undefined"!=typeof self&&"Headers"in self?self.Headers:"undefined"!=typeof globalThis&&globalThis.Headers?globalThis.Headers:"undefined"!=typeof Headers?Headers:void debugFail("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")},FetchProvider.response=function(){return this.responseImpl?this.responseImpl:"undefined"!=typeof self&&"Response"in self?self.Response:"undefined"!=typeof globalThis&&globalThis.Response?globalThis.Response:"undefined"!=typeof Response?Response:void debugFail("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")},FetchProvider}(),T=((E={}).CREDENTIAL_MISMATCH="custom-token-mismatch",E.MISSING_CUSTOM_TOKEN="internal-error",E.INVALID_IDENTIFIER="invalid-email",E.MISSING_CONTINUE_URI="internal-error",E.INVALID_PASSWORD="wrong-password",E.MISSING_PASSWORD="missing-password",E.INVALID_LOGIN_CREDENTIALS="invalid-credential",E.EMAIL_EXISTS="email-already-in-use",E.PASSWORD_LOGIN_DISABLED="operation-not-allowed",E.INVALID_IDP_RESPONSE="invalid-credential",E.INVALID_PENDING_TOKEN="invalid-credential",E.FEDERATED_USER_ID_ALREADY_LINKED="credential-already-in-use",E.MISSING_REQ_TYPE="internal-error",E.EMAIL_NOT_FOUND="user-not-found",E.RESET_PASSWORD_EXCEED_LIMIT="too-many-requests",E.EXPIRED_OOB_CODE="expired-action-code",E.INVALID_OOB_CODE="invalid-action-code",E.MISSING_OOB_CODE="internal-error",E.CREDENTIAL_TOO_OLD_LOGIN_AGAIN="requires-recent-login",E.INVALID_ID_TOKEN="invalid-user-token",E.TOKEN_EXPIRED="user-token-expired",E.USER_NOT_FOUND="user-token-expired",E.TOO_MANY_ATTEMPTS_TRY_LATER="too-many-requests",E.PASSWORD_DOES_NOT_MEET_REQUIREMENTS="password-does-not-meet-requirements",E.INVALID_CODE="invalid-verification-code",E.INVALID_SESSION_INFO="invalid-verification-id",E.INVALID_TEMPORARY_PROOF="invalid-credential",E.MISSING_SESSION_INFO="missing-verification-id",E.SESSION_EXPIRED="code-expired",E.MISSING_ANDROID_PACKAGE_NAME="missing-android-pkg-name",E.UNAUTHORIZED_DOMAIN="unauthorized-continue-uri",E.INVALID_OAUTH_CLIENT_ID="invalid-oauth-client-id",E.ADMIN_ONLY_OPERATION="admin-restricted-operation",E.INVALID_MFA_PENDING_CREDENTIAL="invalid-multi-factor-session",E.MFA_ENROLLMENT_NOT_FOUND="multi-factor-info-not-found",E.MISSING_MFA_ENROLLMENT_ID="missing-multi-factor-info",E.MISSING_MFA_PENDING_CREDENTIAL="missing-multi-factor-session",E.SECOND_FACTOR_EXISTS="second-factor-already-in-use",E.SECOND_FACTOR_LIMIT_EXCEEDED="maximum-second-factor-count-exceeded",E.BLOCKING_FUNCTION_ERROR_RESPONSE="internal-error",E.RECAPTCHA_NOT_ENABLED="recaptcha-not-enabled",E.MISSING_RECAPTCHA_TOKEN="missing-recaptcha-token",E.INVALID_RECAPTCHA_TOKEN="invalid-recaptcha-token",E.INVALID_RECAPTCHA_ACTION="invalid-recaptcha-action",E.MISSING_CLIENT_TYPE="missing-client-type",E.MISSING_RECAPTCHA_VERSION="missing-recaptcha-version",E.INVALID_RECAPTCHA_VERSION="invalid-recaptcha-version",E.INVALID_REQ_TYPE="invalid-req-type",E),b=new y(3e4,6e4);function _addTidIfNecessary(e,t){return e.tenantId&&!t.tenantId?__assign(__assign({},t),{tenantId:e.tenantId}):t}function _performApiRequest(e,t,r,n,i){return void 0===i&&(i={}),__awaiter(this,void 0,void 0,(function(){var o=this;return __generator(this,(function(s){return[2,_performFetchWithErrorHandling(e,i,(function(){return __awaiter(o,void 0,void 0,(function(){var i,o,s,a;return __generator(this,(function(u){switch(u.label){case 0:return i={},o={},n&&("GET"===t?o=n:i={body:JSON.stringify(n)}),s=querystring(__assign({key:e.config.apiKey},o)).slice(1),[4,e._getAdditionalHeaders()];case 1:return(a=u.sent())["Content-Type"]="application/json",e.languageCode&&(a["X-Firebase-Locale"]=e.languageCode),[2,w.fetch()(_getFinalTarget(e,e.config.apiHost,r,s),__assign({method:t,headers:a,referrerPolicy:"no-referrer"},i))]}}))}))}))]}))}))}function _performFetchWithErrorHandling(e,t,r){return __awaiter(this,void 0,void 0,(function(){var n,i,o,s,a,u,c,d,l,h;return __generator(this,(function(p){switch(p.label){case 0:e._canInitEmulator=!1,n=__assign(__assign({},T),t),p.label=1;case 1:return p.trys.push([1,4,,5]),i=new P(e),[4,Promise.race([r(),i.promise])];case 2:return o=p.sent(),i.clearNetworkTimeout(),[4,o.json()];case 3:if("needConfirmation"in(s=p.sent()))throw _makeTaggedError(e,"account-exists-with-different-credential",s);if(o.ok&&!("errorMessage"in s))return[2,s];if(a=o.ok?s.errorMessage:s.error.message,u=a.split(" : "),c=u[0],d=u[1],"FEDERATED_USER_ID_ALREADY_LINKED"===c)throw _makeTaggedError(e,"credential-already-in-use",s);if("EMAIL_EXISTS"===c)throw _makeTaggedError(e,"email-already-in-use",s);if("USER_DISABLED"===c)throw _makeTaggedError(e,"user-disabled",s);if(l=n[c]||c.toLowerCase().replace(/[_\s]+/g,"-"),d)throw _errorWithCustomMessage(e,l,d);return _fail(e,l),[3,5];case 4:if((h=p.sent())instanceof FirebaseError)throw h;return _fail(e,"network-request-failed",{message:String(h)}),[3,5];case 5:return[2]}}))}))}function _performSignInRequest(e,t,r,n,i){return void 0===i&&(i={}),__awaiter(this,void 0,void 0,(function(){var o;return __generator(this,(function(s){switch(s.label){case 0:return[4,_performApiRequest(e,t,r,n,i)];case 1:return"mfaPendingCredential"in(o=s.sent())&&_fail(e,"multi-factor-auth-required",{_serverResponse:o}),[2,o]}}))}))}function _getFinalTarget(e,t,r,n){var i="".concat(t).concat(r,"?").concat(n);return e.config.emulator?_emulatorUrl(e.config,i):"".concat(e.config.apiScheme,"://").concat(i)}function _parseEnforcementState(e){switch(e){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}var P=function(){function NetworkTimeout(e){var t=this;this.auth=e,this.timer=null,this.promise=new Promise((function(e,r){t.timer=setTimeout((function(){return r(_createError(t.auth,"network-request-failed"))}),b.get())}))}return NetworkTimeout.prototype.clearNetworkTimeout=function(){clearTimeout(this.timer)},NetworkTimeout}();function _makeTaggedError(e,t,r){var n={appName:e.name};r.email&&(n.email=r.email),r.phoneNumber&&(n.phoneNumber=r.phoneNumber);var i=_createError(e,t,n);return i.customData._tokenResponse=r,i}function isEnterprise(e){return void 0!==e&&void 0!==e.enterprise}var S=function(){function RecaptchaConfig(e){if(this.siteKey="",this.recaptchaEnforcementState=[],void 0===e.recaptchaKey)throw new Error("recaptchaKey undefined");this.siteKey=e.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}return RecaptchaConfig.prototype.getProviderEnforcementState=function(e){if(!this.recaptchaEnforcementState||0===this.recaptchaEnforcementState.length)return null;for(var t=0,r=this.recaptchaEnforcementState;tthis.expirationTime-3e4},enumerable:!1,configurable:!0}),StsTokenManager.prototype.updateFromServerResponse=function(e){_assert(e.idToken,"internal-error"),_assert(void 0!==e.idToken,"internal-error"),_assert(void 0!==e.refreshToken,"internal-error");var t="expiresIn"in e&&void 0!==e.expiresIn?Number(e.expiresIn):function _tokenExpiresIn(e){var t=_parseToken(e);return _assert(t,"internal-error"),_assert(void 0!==t.exp,"internal-error"),_assert(void 0!==t.iat,"internal-error"),Number(t.exp)-Number(t.iat)}(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)},StsTokenManager.prototype.getToken=function(e,t){return void 0===t&&(t=!1),__awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){switch(r.label){case 0:return _assert(!this.accessToken||this.refreshToken,e,"user-token-expired"),t||!this.accessToken||this.isExpired?this.refreshToken?[4,this.refresh(e,this.refreshToken)]:[3,2]:[2,this.accessToken];case 1:return r.sent(),[2,this.accessToken];case 2:return[2,null]}}))}))},StsTokenManager.prototype.clearRefreshToken=function(){this.refreshToken=null},StsTokenManager.prototype.refresh=function(e,t){return __awaiter(this,void 0,void 0,(function(){var r,n,i,o;return __generator(this,(function(s){switch(s.label){case 0:return[4,requestStsToken(e,t)];case 1:return r=s.sent(),n=r.accessToken,i=r.refreshToken,o=r.expiresIn,this.updateTokensAndExpiration(n,i,Number(o)),[2]}}))}))},StsTokenManager.prototype.updateTokensAndExpiration=function(e,t,r){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+1e3*r},StsTokenManager.fromJSON=function(e,t){var r=t.refreshToken,n=t.accessToken,i=t.expirationTime,o=new StsTokenManager;return r&&(_assert("string"==typeof r,"internal-error",{appName:e}),o.refreshToken=r),n&&(_assert("string"==typeof n,"internal-error",{appName:e}),o.accessToken=n),i&&(_assert("number"==typeof i,"internal-error",{appName:e}),o.expirationTime=i),o},StsTokenManager.prototype.toJSON=function(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}},StsTokenManager.prototype._assign=function(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime},StsTokenManager.prototype._clone=function(){return Object.assign(new StsTokenManager,this.toJSON())},StsTokenManager.prototype._performRefresh=function(){return debugFail("not implemented")},StsTokenManager}();function assertStringOrUndefined(e,t){_assert("string"==typeof e||void 0===e,"internal-error",{appName:t})}var O=function(){function UserImpl(e){var t=e.uid,r=e.auth,n=e.stsTokenManager,i=__rest(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new R(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,this.auth=r,this.stsTokenManager=n,this.accessToken=n.accessToken,this.displayName=i.displayName||null,this.email=i.email||null,this.emailVerified=i.emailVerified||!1,this.phoneNumber=i.phoneNumber||null,this.photoURL=i.photoURL||null,this.isAnonymous=i.isAnonymous||!1,this.tenantId=i.tenantId||null,this.providerData=i.providerData?__spreadArray([],i.providerData,!0):[],this.metadata=new k(i.createdAt||void 0,i.lastLoginAt||void 0)}return UserImpl.prototype.getIdToken=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){switch(r.label){case 0:return[4,_logoutIfInvalidated(this,this.stsTokenManager.getToken(this.auth,e))];case 1:return _assert(t=r.sent(),this.auth,"internal-error"),this.accessToken===t?[3,3]:(this.accessToken=t,[4,this.auth._persistUserIfCurrent(this)]);case 2:r.sent(),this.auth._notifyListenersIfCurrent(this),r.label=3;case 3:return[2,t]}}))}))},UserImpl.prototype.getIdTokenResult=function(e){return getIdTokenResult(this,e)},UserImpl.prototype.reload=function(){return reload(this)},UserImpl.prototype._assign=function(e){this!==e&&(_assert(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map((function(e){return __assign({},e)})),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))},UserImpl.prototype._clone=function(e){var t=new UserImpl(__assign(__assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}));return t.metadata._copy(this.metadata),t},UserImpl.prototype._onReload=function(e){_assert(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)},UserImpl.prototype._notifyReloadListener=function(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e},UserImpl.prototype._startProactiveRefresh=function(){this.proactiveRefresh._start()},UserImpl.prototype._stopProactiveRefresh=function(){this.proactiveRefresh._stop()},UserImpl.prototype._updateTokensIfNecessary=function(e,t){return void 0===t&&(t=!1),__awaiter(this,void 0,void 0,(function(){var r;return __generator(this,(function(n){switch(n.label){case 0:return r=!1,e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),r=!0),t?[4,_reloadWithoutSaving(this)]:[3,2];case 1:n.sent(),n.label=2;case 2:return[4,this.auth._persistUserIfCurrent(this)];case 3:return n.sent(),r&&this.auth._notifyListenersIfCurrent(this),[2]}}))}))},UserImpl.prototype.delete=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:return[4,this.getIdToken()];case 1:return e=t.sent(),[4,_logoutIfInvalidated(this,deleteAccount(this.auth,{idToken:e}))];case 2:return t.sent(),this.stsTokenManager.clearRefreshToken(),[2,this.auth.signOut()]}}))}))},UserImpl.prototype.toJSON=function(){return __assign(__assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map((function(e){return __assign({},e)})),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})},Object.defineProperty(UserImpl.prototype,"refreshToken",{get:function(){return this.stsTokenManager.refreshToken||""},enumerable:!1,configurable:!0}),UserImpl._fromJSON=function(e,t){var r,n,i,o,s,a,u,c,d=null!==(r=t.displayName)&&void 0!==r?r:void 0,l=null!==(n=t.email)&&void 0!==n?n:void 0,h=null!==(i=t.phoneNumber)&&void 0!==i?i:void 0,p=null!==(o=t.photoURL)&&void 0!==o?o:void 0,f=null!==(s=t.tenantId)&&void 0!==s?s:void 0,_=null!==(a=t._redirectEventId)&&void 0!==a?a:void 0,v=null!==(u=t.createdAt)&&void 0!==u?u:void 0,g=null!==(c=t.lastLoginAt)&&void 0!==c?c:void 0,m=t.uid,I=t.emailVerified,A=t.isAnonymous,y=t.providerData,E=t.stsTokenManager;_assert(m&&E,e,"internal-error");var w=C.fromJSON(this.name,E);_assert("string"==typeof m,e,"internal-error"),assertStringOrUndefined(d,e.name),assertStringOrUndefined(l,e.name),_assert("boolean"==typeof I,e,"internal-error"),_assert("boolean"==typeof A,e,"internal-error"),assertStringOrUndefined(h,e.name),assertStringOrUndefined(p,e.name),assertStringOrUndefined(f,e.name),assertStringOrUndefined(_,e.name),assertStringOrUndefined(v,e.name),assertStringOrUndefined(g,e.name);var T=new UserImpl({uid:m,auth:e,email:l,emailVerified:I,displayName:d,isAnonymous:A,photoURL:p,phoneNumber:h,tenantId:f,stsTokenManager:w,createdAt:v,lastLoginAt:g});return y&&Array.isArray(y)&&(T.providerData=y.map((function(e){return __assign({},e)}))),_&&(T._redirectEventId=_),T},UserImpl._fromIdTokenResponse=function(e,t,r){return void 0===r&&(r=!1),__awaiter(this,void 0,void 0,(function(){var n,i;return __generator(this,(function(o){switch(o.label){case 0:return(n=new C).updateFromServerResponse(t),[4,_reloadWithoutSaving(i=new UserImpl({uid:t.localId,auth:e,stsTokenManager:n,isAnonymous:r}))];case 1:return o.sent(),[2,i]}}))}))},UserImpl}(),N=new Map;function _getInstance(e){debugAssert(e instanceof Function,"Expected a class definition");var t=N.get(e);return t?(debugAssert(t instanceof e,"Instance stored in cache mismatched with class"),t):(t=new e,N.set(e,t),t)}var L=function(){function InMemoryPersistence(){this.type="NONE",this.storage={}}return InMemoryPersistence.prototype._isAvailable=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,!0]}))}))},InMemoryPersistence.prototype._set=function(e,t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){return this.storage[e]=t,[2]}))}))},InMemoryPersistence.prototype._get=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){return[2,void 0===(t=this.storage[e])?null:t]}))}))},InMemoryPersistence.prototype._remove=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return delete this.storage[e],[2]}))}))},InMemoryPersistence.prototype._addListener=function(e,t){},InMemoryPersistence.prototype._removeListener=function(e,t){},InMemoryPersistence.type="NONE",InMemoryPersistence}();function _persistenceKeyName(e,t,r){return"".concat("firebase",":").concat(e,":").concat(t,":").concat(r)}var M=function(){function PersistenceUserManager(e,t,r){this.persistence=e,this.auth=t,this.userKey=r;var n=this.auth,i=n.config,o=n.name;this.fullUserKey=_persistenceKeyName(this.userKey,i.apiKey,o),this.fullPersistenceKey=_persistenceKeyName("persistence",i.apiKey,o),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}return PersistenceUserManager.prototype.setCurrentUser=function(e){return this.persistence._set(this.fullUserKey,e.toJSON())},PersistenceUserManager.prototype.getCurrentUser=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:return[4,this.persistence._get(this.fullUserKey)];case 1:return[2,(e=t.sent())?O._fromJSON(this.auth,e):null]}}))}))},PersistenceUserManager.prototype.removeCurrentUser=function(){return this.persistence._remove(this.fullUserKey)},PersistenceUserManager.prototype.savePersistenceForRedirect=function(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)},PersistenceUserManager.prototype.setPersistence=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){switch(r.label){case 0:return this.persistence===e?[2]:[4,this.getCurrentUser()];case 1:return t=r.sent(),[4,this.removeCurrentUser()];case 2:return r.sent(),this.persistence=e,t?[2,this.setCurrentUser(t)]:[2]}}))}))},PersistenceUserManager.prototype.delete=function(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)},PersistenceUserManager.create=function(e,t,r){return void 0===r&&(r="authUser"),__awaiter(this,void 0,void 0,(function(){var n,i,o,s,a,u,c,d,l,h,p=this;return __generator(this,(function(f){switch(f.label){case 0:return t.length?[4,Promise.all(t.map((function(e){return __awaiter(p,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:return[4,e._isAvailable()];case 1:return t.sent()?[2,e]:[2,void 0]}}))}))})))]:[2,new PersistenceUserManager(_getInstance(L),e,r)];case 1:n=f.sent().filter((function(e){return e})),i=n[0]||_getInstance(L),o=_persistenceKeyName(r,e.config.apiKey,e.name),s=null,a=0,u=t,f.label=2;case 2:if(!(a=0||e.indexOf("Trident/")>=0}()&&10===document.documentMode}function _getClientVersion(t,r){var n;switch(void 0===r&&(r=[]),t){case"Browser":n=_getBrowserName(getUA());break;case"Worker":n="".concat(_getBrowserName(getUA()),"-").concat(t);break;default:n=t}var i=r.length?r.join(","):"FirebaseCore-web";return"".concat(n,"/").concat("JsCore","/").concat(e,"/").concat(i)}var D=function(){function AuthMiddlewareQueue(e){this.auth=e,this.queue=[]}return AuthMiddlewareQueue.prototype.pushCallback=function(e,t){var r=this,wrappedCallback=function(t){return new Promise((function(r,n){try{r(e(t))}catch(e){n(e)}}))};wrappedCallback.onAbort=t,this.queue.push(wrappedCallback);var n=this.queue.length-1;return function(){r.queue[n]=function(){return Promise.resolve()}}},AuthMiddlewareQueue.prototype.runMiddleware=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,n,i,o,s,a,u;return __generator(this,(function(c){switch(c.label){case 0:if(this.auth.currentUser===e)return[2];t=[],c.label=1;case 1:c.trys.push([1,6,,7]),r=0,n=this.queue,c.label=2;case 2:return r=r),n&&(t.meetsMaxPasswordLength=e.length<=n)},PasswordPolicyImpl.prototype.validatePasswordCharacterOptions=function(e,t){var r;this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);for(var n=0;n="a"&&r<="z",r>="A"&&r<="Z",r>="0"&&r<="9",this.allowedNonAlphanumericCharacters.includes(r))},PasswordPolicyImpl.prototype.updatePasswordCharacterOptionsStatuses=function(e,t,r,n,i){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=r)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=n)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=i))},PasswordPolicyImpl}(),F=function(){function AuthImpl(e,t,r,n){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=r,this.config=n,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new V(this),this.idTokenSubscription=new V(this),this.beforeStateQueue=new D(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=m,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=n.sdkClientVersion}return AuthImpl.prototype._initializeWithPersistence=function(e,t){var r=this;return t&&(this._popupRedirectResolver=_getInstance(t)),this._initializationPromise=this.queue((function(){return __awaiter(r,void 0,void 0,(function(){var r,n,i;return __generator(this,(function(o){switch(o.label){case 0:return this._deleted?[2]:(r=this,[4,M.create(this,e)]);case 1:if(r.persistenceManager=o.sent(),this._deleted)return[2];if(!(null===(n=this._popupRedirectResolver)||void 0===n?void 0:n._shouldInitProactively))return[3,5];o.label=2;case 2:return o.trys.push([2,4,,5]),[4,this._popupRedirectResolver._initialize(this)];case 3:case 4:return o.sent(),[3,5];case 5:return[4,this.initializeCurrentUser(t)];case 6:return o.sent(),this.lastNotifiedUid=(null===(i=this.currentUser)||void 0===i?void 0:i.uid)||null,this._deleted?[2]:(this._isInitialized=!0,[2])}}))}))})),this._initializationPromise},AuthImpl.prototype._onStorageEvent=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:return this._deleted?[2]:[4,this.assertedPersistence.getCurrentUser()];case 1:return e=t.sent(),this.currentUser||e?this.currentUser&&e&&this.currentUser.uid===e.uid?(this._currentUser._assign(e),[4,this.currentUser.getIdToken()]):[3,3]:[2];case 2:case 4:return t.sent(),[2];case 3:return[4,this._updateCurrentUser(e,!0)]}}))}))},AuthImpl.prototype.initializeCurrentUser=function(e){var t;return __awaiter(this,void 0,void 0,(function(){var r,n,i,o,s,a,u;return __generator(this,(function(c){switch(c.label){case 0:return[4,this.assertedPersistence.getCurrentUser()];case 1:return r=c.sent(),n=r,i=!1,e&&this.config.authDomain?[4,this.getOrInitRedirectPersistenceManager()]:[3,4];case 2:return c.sent(),o=null===(t=this.redirectUser)||void 0===t?void 0:t._redirectEventId,s=null==n?void 0:n._redirectEventId,[4,this.tryRedirectSignIn(e)];case 3:a=c.sent(),o&&o!==s||!(null==a?void 0:a.user)||(n=a.user,i=!0),c.label=4;case 4:if(!n)return[2,this.directlySetCurrentUser(null)];if(n._redirectEventId)return[3,9];if(!i)return[3,8];c.label=5;case 5:return c.trys.push([5,7,,8]),[4,this.beforeStateQueue.runMiddleware(n)];case 6:return c.sent(),[3,8];case 7:return u=c.sent(),n=r,this._popupRedirectResolver._overrideRedirectResult(this,(function(){return Promise.reject(u)})),[3,8];case 8:return n?[2,this.reloadAndSetCurrentUserOrClear(n)]:[2,this.directlySetCurrentUser(null)];case 9:return _assert(this._popupRedirectResolver,this,"argument-error"),[4,this.getOrInitRedirectPersistenceManager()];case 10:return c.sent(),this.redirectUser&&this.redirectUser._redirectEventId===n._redirectEventId?[2,this.directlySetCurrentUser(n)]:[2,this.reloadAndSetCurrentUserOrClear(n)]}}))}))},AuthImpl.prototype.tryRedirectSignIn=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){switch(r.label){case 0:t=null,r.label=1;case 1:return r.trys.push([1,3,,5]),[4,this._popupRedirectResolver._completeRedirectFn(this,e,!0)];case 2:return t=r.sent(),[3,5];case 3:return r.sent(),[4,this._setRedirectUser(null)];case 4:return r.sent(),[3,5];case 5:return[2,t]}}))}))},AuthImpl.prototype.reloadAndSetCurrentUserOrClear=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,_reloadWithoutSaving(e)];case 1:return r.sent(),[3,3];case 2:return(null==(t=r.sent())?void 0:t.code)!=="auth/".concat("network-request-failed")?[2,this.directlySetCurrentUser(null)]:[3,3];case 3:return[2,this.directlySetCurrentUser(e)]}}))}))},AuthImpl.prototype.useDeviceLanguage=function(){this.languageCode=function _getUserLanguage(){if("undefined"==typeof navigator)return null;var e=navigator;return e.languages&&e.languages[0]||e.language||null}()},AuthImpl.prototype._delete=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return this._deleted=!0,[2]}))}))},AuthImpl.prototype.updateCurrentUser=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){return(t=e?getModularInstance(e):null)&&_assert(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),[2,this._updateCurrentUser(t&&t._clone(this))]}))}))},AuthImpl.prototype._updateCurrentUser=function(e,t){return void 0===t&&(t=!1),__awaiter(this,void 0,void 0,(function(){var r=this;return __generator(this,(function(n){switch(n.label){case 0:return this._deleted?[2]:(e&&_assert(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t?[3,2]:[4,this.beforeStateQueue.runMiddleware(e)]);case 1:n.sent(),n.label=2;case 2:return[2,this.queue((function(){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:return[4,this.directlySetCurrentUser(e)];case 1:return t.sent(),this.notifyAuthListeners(),[2]}}))}))}))]}}))}))},AuthImpl.prototype.signOut=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:return[4,this.beforeStateQueue.runMiddleware(null)];case 1:return e.sent(),this.redirectPersistenceManager||this._popupRedirectResolver?[4,this._setRedirectUser(null)]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2,this._updateCurrentUser(null,!0)]}}))}))},AuthImpl.prototype.setPersistence=function(e){var t=this;return this.queue((function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:return[4,this.assertedPersistence.setPersistence(_getInstance(e))];case 1:return t.sent(),[2]}}))}))}))},AuthImpl.prototype._getRecaptchaConfig=function(){return null==this.tenantId?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]},AuthImpl.prototype.validatePassword=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){switch(r.label){case 0:return this._getPasswordPolicyInternal()?[3,2]:[4,this._updatePasswordPolicy()];case 1:r.sent(),r.label=2;case 2:return(t=this._getPasswordPolicyInternal()).schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?[2,Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{}))]:[2,t.validatePassword(e)]}}))}))},AuthImpl.prototype._getPasswordPolicyInternal=function(){return null===this.tenantId?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]},AuthImpl.prototype._updatePasswordPolicy=function(){return __awaiter(this,void 0,void 0,(function(){var e,t;return __generator(this,(function(r){switch(r.label){case 0:return[4,_getPasswordPolicy(this)];case 1:return e=r.sent(),t=new U(e),null===this.tenantId?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t,[2]}}))}))},AuthImpl.prototype._getPersistence=function(){return this.assertedPersistence.persistence.type},AuthImpl.prototype._updateErrorMap=function(e){this._errorFactory=new ErrorFactory("auth","Firebase",e())},AuthImpl.prototype.onAuthStateChanged=function(e,t,r){return this.registerStateListener(this.authStateSubscription,e,t,r)},AuthImpl.prototype.beforeAuthStateChanged=function(e,t){return this.beforeStateQueue.pushCallback(e,t)},AuthImpl.prototype.onIdTokenChanged=function(e,t,r){return this.registerStateListener(this.idTokenSubscription,e,t,r)},AuthImpl.prototype.authStateReady=function(){var e=this;return new Promise((function(t,r){if(e.currentUser)t();else var n=e.onAuthStateChanged((function(){n(),t()}),r)}))},AuthImpl.prototype.revokeAccessToken=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r;return __generator(this,(function(n){switch(n.label){case 0:return this.currentUser?[4,this.currentUser.getIdToken()]:[3,3];case 1:return t=n.sent(),r={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:t},null!=this.tenantId&&(r.tenantId=this.tenantId),[4,revokeToken(this,r)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},AuthImpl.prototype.toJSON=function(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:null===(e=this._currentUser)||void 0===e?void 0:e.toJSON()}},AuthImpl.prototype._setRedirectUser=function(e,t){return __awaiter(this,void 0,void 0,(function(){var r;return __generator(this,(function(n){switch(n.label){case 0:return[4,this.getOrInitRedirectPersistenceManager(t)];case 1:return r=n.sent(),[2,null===e?r.removeCurrentUser():r.setCurrentUser(e)]}}))}))},AuthImpl.prototype.getOrInitRedirectPersistenceManager=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,n;return __generator(this,(function(i){switch(i.label){case 0:return this.redirectPersistenceManager?[3,3]:(_assert(t=e&&_getInstance(e)||this._popupRedirectResolver,this,"argument-error"),r=this,[4,M.create(this,[_getInstance(t._redirectPersistence)],"redirectUser")]);case 1:return r.redirectPersistenceManager=i.sent(),n=this,[4,this.redirectPersistenceManager.getCurrentUser()];case 2:n.redirectUser=i.sent(),i.label=3;case 3:return[2,this.redirectPersistenceManager]}}))}))},AuthImpl.prototype._redirectUserForId=function(e){var t,r;return __awaiter(this,void 0,void 0,(function(){var n=this;return __generator(this,(function(i){switch(i.label){case 0:return this._isInitialized?[4,this.queue((function(){return __awaiter(n,void 0,void 0,(function(){return __generator(this,(function(e){return[2]}))}))}))]:[3,2];case 1:i.sent(),i.label=2;case 2:return(null===(t=this._currentUser)||void 0===t?void 0:t._redirectEventId)===e?[2,this._currentUser]:(null===(r=this.redirectUser)||void 0===r?void 0:r._redirectEventId)===e?[2,this.redirectUser]:[2,null]}}))}))},AuthImpl.prototype._persistUserIfCurrent=function(e){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(r){return e===this.currentUser?[2,this.queue((function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(t){return[2,this.directlySetCurrentUser(e)]}))}))}))]:[2]}))}))},AuthImpl.prototype._notifyListenersIfCurrent=function(e){e===this.currentUser&&this.notifyAuthListeners()},AuthImpl.prototype._key=function(){return"".concat(this.config.authDomain,":").concat(this.config.apiKey,":").concat(this.name)},AuthImpl.prototype._startProactiveRefresh=function(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()},AuthImpl.prototype._stopProactiveRefresh=function(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()},Object.defineProperty(AuthImpl.prototype,"_currentUser",{get:function(){return this.currentUser},enumerable:!1,configurable:!0}),AuthImpl.prototype.notifyAuthListeners=function(){var e,t;if(this._isInitialized){this.idTokenSubscription.next(this.currentUser);var r=null!==(t=null===(e=this.currentUser)||void 0===e?void 0:e.uid)&&void 0!==t?t:null;this.lastNotifiedUid!==r&&(this.lastNotifiedUid=r,this.authStateSubscription.next(this.currentUser))}},AuthImpl.prototype.registerStateListener=function(e,t,r,n){var i=this;if(this._deleted)return function(){};var o="function"==typeof t?t:t.next.bind(t),s=!1,a=this._isInitialized?Promise.resolve():this._initializationPromise;if(_assert(a,this,"internal-error"),a.then((function(){s||o(i.currentUser)})),"function"==typeof t){var u=e.addObserver(t,r,n);return function(){s=!0,u()}}var c=e.addObserver(t);return function(){s=!0,c()}},AuthImpl.prototype.directlySetCurrentUser=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:return this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?[4,this.assertedPersistence.setCurrentUser(e)]:[3,2];case 1:return t.sent(),[3,4];case 2:return[4,this.assertedPersistence.removeCurrentUser()];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},AuthImpl.prototype.queue=function(e){return this.operations=this.operations.then(e,e),this.operations},Object.defineProperty(AuthImpl.prototype,"assertedPersistence",{get:function(){return _assert(this.persistenceManager,this,"internal-error"),this.persistenceManager},enumerable:!1,configurable:!0}),AuthImpl.prototype._logFramework=function(e){e&&!this.frameworks.includes(e)&&(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=_getClientVersion(this.config.clientPlatform,this._getFrameworks()))},AuthImpl.prototype._getFrameworks=function(){return this.frameworks},AuthImpl.prototype._getAdditionalHeaders=function(){var e;return __awaiter(this,void 0,void 0,(function(){var t,r,n,i;return __generator(this,(function(o){switch(o.label){case 0:return(i={})["X-Client-Version"]=this.clientVersion,t=i,this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId),[4,null===(e=this.heartbeatServiceProvider.getImmediate({optional:!0}))||void 0===e?void 0:e.getHeartbeatsHeader()];case 1:return(r=o.sent())&&(t["X-Firebase-Client"]=r),[4,this._getAppCheckToken()];case 2:return(n=o.sent())&&(t["X-Firebase-AppCheck"]=n),[2,t]}}))}))},AuthImpl.prototype._getAppCheckToken=function(){var t;return __awaiter(this,void 0,void 0,(function(){var r;return __generator(this,(function(n){switch(n.label){case 0:return[4,null===(t=this.appCheckServiceProvider.getImmediate({optional:!0}))||void 0===t?void 0:t.getToken()];case 1:return(null==(r=n.sent())?void 0:r.error)&&function _logWarn(t){for(var r=[],n=1;n0,e,"invalid-continue-uri"),_assert(void 0===r.dynamicLinkDomain||r.dynamicLinkDomain.length>0,e,"invalid-dynamic-link-domain"),t.continueUrl=r.url,t.dynamicLinkDomain=r.dynamicLinkDomain,t.canHandleCodeInApp=r.handleCodeInApp,r.iOS&&(_assert(r.iOS.bundleId.length>0,e,"missing-ios-bundle-id"),t.iOSBundleId=r.iOS.bundleId),r.android&&(_assert(r.android.packageName.length>0,e,"missing-android-pkg-name"),t.androidInstallApp=r.android.installApp,t.androidMinimumVersionCode=r.android.minimumVersion,t.androidPackageName=r.android.packageName)}function recachePasswordPolicy(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){switch(r.label){case 0:return(t=_castAuth(e))._getPasswordPolicyInternal()?[4,t._updatePasswordPolicy()]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}}))}))}function sendPasswordResetEmail(e,t,r){return __awaiter(this,void 0,void 0,(function(){var n,i;return __generator(this,(function(o){switch(o.label){case 0:return n=_castAuth(e),i={requestType:"PASSWORD_RESET",email:t,clientType:"CLIENT_TYPE_WEB"},r&&_setActionCodeSettingsOnRequest(n,i,r),[4,handleRecaptchaFlow(n,i,"getOobCode",sendPasswordResetEmail$1)];case 1:return o.sent(),[2]}}))}))}function confirmPasswordReset(e,t,r){return __awaiter(this,void 0,void 0,(function(){var n=this;return __generator(this,(function(i){switch(i.label){case 0:return[4,resetPassword(getModularInstance(e),{oobCode:t,newPassword:r}).catch((function(t){return __awaiter(n,void 0,void 0,(function(){return __generator(this,(function(r){throw t.code==="auth/".concat("password-does-not-meet-requirements")&&recachePasswordPolicy(e),t}))}))}))];case 1:return i.sent(),[2]}}))}))}function applyActionCode(e,t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){switch(r.label){case 0:return[4,applyActionCode$1(getModularInstance(e),{oobCode:t})];case 1:return r.sent(),[2]}}))}))}function checkActionCode(e,t){return __awaiter(this,void 0,void 0,(function(){var r,n,i,o;return __generator(this,(function(s){switch(s.label){case 0:return[4,resetPassword(r=getModularInstance(e),{oobCode:t})];case 1:switch(n=s.sent(),_assert(i=n.requestType,r,"internal-error"),i){case"EMAIL_SIGNIN":break;case"VERIFY_AND_CHANGE_EMAIL":_assert(n.newEmail,r,"internal-error");break;case"REVERT_SECOND_FACTOR_ADDITION":_assert(n.mfaInfo,r,"internal-error");default:_assert(n.email,r,"internal-error")}return o=null,n.mfaInfo&&(o=se._fromServerResponse(_castAuth(r),n.mfaInfo)),[2,{data:{email:("VERIFY_AND_CHANGE_EMAIL"===n.requestType?n.newEmail:n.email)||null,previousEmail:("VERIFY_AND_CHANGE_EMAIL"===n.requestType?n.email:n.newEmail)||null,multiFactorInfo:o},operation:i}]}}))}))}function verifyPasswordResetCode(e,t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){switch(r.label){case 0:return[4,checkActionCode(getModularInstance(e),t)];case 1:return[2,r.sent().data.email]}}))}))}function createUserWithEmailAndPassword(e,t,r){return __awaiter(this,void 0,void 0,(function(){var n,i,o;return __generator(this,(function(s){switch(s.label){case 0:return n=_castAuth(e),[4,handleRecaptchaFlow(n,{returnSecureToken:!0,email:t,password:r,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",signUp).catch((function(t){throw t.code==="auth/".concat("password-does-not-meet-requirements")&&recachePasswordPolicy(e),t}))];case 1:return i=s.sent(),[4,ie._fromIdTokenResponse(n,"signIn",i)];case 2:return o=s.sent(),[4,n._updateCurrentUser(o.user)];case 3:return s.sent(),[2,o]}}))}))}function signInWithEmailAndPassword(e,t,r){var n=this;return signInWithCredential(getModularInstance(e),J.credential(t,r)).catch((function(t){return __awaiter(n,void 0,void 0,(function(){return __generator(this,(function(r){throw t.code==="auth/".concat("password-does-not-meet-requirements")&&recachePasswordPolicy(e),t}))}))}))}function sendSignInLinkToEmail(e,t,r){return __awaiter(this,void 0,void 0,(function(){var n,i;return __generator(this,(function(o){switch(o.label){case 0:return n=_castAuth(e),function setActionCodeSettings(e,t){_assert(t.handleCodeInApp,n,"argument-error"),t&&_setActionCodeSettingsOnRequest(n,e,t)}(i={requestType:"EMAIL_SIGNIN",email:t,clientType:"CLIENT_TYPE_WEB"},r),[4,handleRecaptchaFlow(n,i,"getOobCode",sendSignInLinkToEmail$1)];case 1:return o.sent(),[2]}}))}))}function isSignInWithEmailLink(e,t){var r=K.parseLink(t);return"EMAIL_SIGNIN"===(null==r?void 0:r.operation)}function signInWithEmailLink(e,t,r){return __awaiter(this,void 0,void 0,(function(){var n,i;return __generator(this,(function(o){return n=getModularInstance(e),_assert((i=J.credentialWithLink(t,r||_getCurrentUrl()))._tenantId===(n.tenantId||null),n,"tenant-id-mismatch"),[2,signInWithCredential(n,i)]}))}))}function createAuthUri(e,t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){return[2,_performApiRequest(e,"POST","/v1/accounts:createAuthUri",_addTidIfNecessary(e,t))]}))}))}function fetchSignInMethodsForEmail(e,t){return __awaiter(this,void 0,void 0,(function(){var r,n;return __generator(this,(function(i){switch(i.label){case 0:return r=_isHttpOrHttps()?_getCurrentUrl():"http://localhost",n={identifier:t,continueUri:r},[4,createAuthUri(getModularInstance(e),n)];case 1:return[2,i.sent().signinMethods||[]]}}))}))}function sendEmailVerification(e,t){return __awaiter(this,void 0,void 0,(function(){var r,n,i;return __generator(this,(function(o){switch(o.label){case 0:return r=getModularInstance(e),[4,e.getIdToken()];case 1:return n=o.sent(),i={requestType:"VERIFY_EMAIL",idToken:n},t&&_setActionCodeSettingsOnRequest(r.auth,i,t),[4,sendEmailVerification$1(r.auth,i)];case 2:return o.sent().email===e.email?[3,4]:[4,e.reload()];case 3:o.sent(),o.label=4;case 4:return[2]}}))}))}function verifyBeforeUpdateEmail(e,t,r){return __awaiter(this,void 0,void 0,(function(){var n,i,o;return __generator(this,(function(s){switch(s.label){case 0:return n=getModularInstance(e),[4,e.getIdToken()];case 1:return i=s.sent(),o={requestType:"VERIFY_AND_CHANGE_EMAIL",idToken:i,newEmail:t},r&&_setActionCodeSettingsOnRequest(n.auth,o,r),[4,verifyAndChangeEmail(n.auth,o)];case 2:return s.sent().email===e.email?[3,4]:[4,e.reload()];case 3:s.sent(),s.label=4;case 4:return[2]}}))}))}function updateProfile$1(e,t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){return[2,_performApiRequest(e,"POST","/v1/accounts:update",t)]}))}))}function updateProfile(e,t){var r=t.displayName,n=t.photoURL;return __awaiter(this,void 0,void 0,(function(){var t,i,o,s,a;return __generator(this,(function(u){switch(u.label){case 0:return void 0===r&&void 0===n?[2]:[4,(t=getModularInstance(e)).getIdToken()];case 1:return i=u.sent(),o={idToken:i,displayName:r,photoUrl:n,returnSecureToken:!0},[4,_logoutIfInvalidated(t,updateProfile$1(t.auth,o))];case 2:return s=u.sent(),t.displayName=s.displayName||null,t.photoURL=s.photoUrl||null,a=t.providerData.find((function(e){return"password"===e.providerId})),a&&(a.displayName=t.displayName,a.photoURL=t.photoURL),[4,t._updateTokensIfNecessary(s)];case 3:return u.sent(),[2]}}))}))}function updateEmail(e,t){return updateEmailOrPassword(getModularInstance(e),t,null)}function updatePassword(e,t){return updateEmailOrPassword(getModularInstance(e),null,t)}function updateEmailOrPassword(e,t,r){return __awaiter(this,void 0,void 0,(function(){var n,i,o,s;return __generator(this,(function(a){switch(a.label){case 0:return n=e.auth,[4,e.getIdToken()];case 1:return i=a.sent(),o={idToken:i,returnSecureToken:!0},t&&(o.email=t),r&&(o.password=r),[4,_logoutIfInvalidated(e,updateEmailPassword(n,o))];case 2:return s=a.sent(),[4,e._updateTokensIfNecessary(s,!0)];case 3:return a.sent(),[2]}}))}))}var ce=function ce(e,t,r){void 0===r&&(r={}),this.isNewUser=e,this.providerId=t,this.profile=r},de=function(e){function FederatedAdditionalUserInfoWithUsername(t,r,n,i){var o=e.call(this,t,r,n)||this;return o.username=i,o}return __extends(FederatedAdditionalUserInfoWithUsername,e),FederatedAdditionalUserInfoWithUsername}(ce),le=function(e){function FacebookAdditionalUserInfo(t,r){return e.call(this,t,"facebook.com",r)||this}return __extends(FacebookAdditionalUserInfo,e),FacebookAdditionalUserInfo}(ce),he=function(e){function GithubAdditionalUserInfo(t,r){return e.call(this,t,"github.com",r,"string"==typeof(null==r?void 0:r.login)?null==r?void 0:r.login:null)||this}return __extends(GithubAdditionalUserInfo,e),GithubAdditionalUserInfo}(de),pe=function(e){function GoogleAdditionalUserInfo(t,r){return e.call(this,t,"google.com",r)||this}return __extends(GoogleAdditionalUserInfo,e),GoogleAdditionalUserInfo}(ce),fe=function(e){function TwitterAdditionalUserInfo(t,r,n){return e.call(this,t,"twitter.com",r,n)||this}return __extends(TwitterAdditionalUserInfo,e),TwitterAdditionalUserInfo}(de);function getAdditionalUserInfo(e){var t=e,r=t.user,n=t._tokenResponse;return r.isAnonymous&&!n?{providerId:null,isNewUser:!1,profile:null}:function _fromIdTokenResponse(e){var t,r;if(!e)return null;var n=e.providerId,i=e.rawUserInfo?JSON.parse(e.rawUserInfo):{},o=e.isNewUser||"identitytoolkit#SignupNewUserResponse"===e.kind;if(!n&&(null==e?void 0:e.idToken)){var s=null===(r=null===(t=_parseToken(e.idToken))||void 0===t?void 0:t.firebase)||void 0===r?void 0:r.sign_in_provider;if(s)return new ce(o,"anonymous"!==s&&"custom"!==s?s:null)}if(!n)return null;switch(n){case"facebook.com":return new le(o,i);case"github.com":return new he(o,i);case"google.com":return new pe(o,i);case"twitter.com":return new fe(o,i,e.screenName||null);case"custom":case"anonymous":return new ce(o,null);default:return new ce(o,n,i)}}(n)}function setPersistence(e,t){return getModularInstance(e).setPersistence(t)}function initializeRecaptchaConfig(e){return function _initializeRecaptchaConfig(e){return __awaiter(this,void 0,void 0,(function(){var t,r,n;return __generator(this,(function(i){switch(i.label){case 0:return[4,getRecaptchaConfig(t=_castAuth(e),{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"})];case 1:return r=i.sent(),n=new S(r),null==t.tenantId?t._agentRecaptchaConfig=n:t._tenantRecaptchaConfigs[t.tenantId]=n,n.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")&&new W(t).verify(),[2]}}))}))}(e)}function validatePassword(e,t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){return[2,_castAuth(e).validatePassword(t)]}))}))}function onIdTokenChanged(e,t,r,n){return getModularInstance(e).onIdTokenChanged(t,r,n)}function beforeAuthStateChanged(e,t,r){return getModularInstance(e).beforeAuthStateChanged(t,r)}function onAuthStateChanged(e,t,r,n){return getModularInstance(e).onAuthStateChanged(t,r,n)}function useDeviceLanguage(e){getModularInstance(e).useDeviceLanguage()}function updateCurrentUser(e,t){return getModularInstance(e).updateCurrentUser(t)}function signOut(e){return getModularInstance(e).signOut()}function revokeAccessToken(e,t){return _castAuth(e).revokeAccessToken(t)}function deleteUser(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,getModularInstance(e).delete()]}))}))}var _e=function(){function MultiFactorSessionImpl(e,t,r){this.type=e,this.credential=t,this.user=r}return MultiFactorSessionImpl._fromIdtoken=function(e,t){return new MultiFactorSessionImpl("enroll",e,t)},MultiFactorSessionImpl._fromMfaPendingCredential=function(e){return new MultiFactorSessionImpl("signin",e)},MultiFactorSessionImpl.prototype.toJSON=function(){var e;return{multiFactorSession:(e={},e["enroll"===this.type?"idToken":"pendingCredential"]=this.credential,e)}},MultiFactorSessionImpl.fromJSON=function(e){var t,r;if(null==e?void 0:e.multiFactorSession){if(null===(t=e.multiFactorSession)||void 0===t?void 0:t.pendingCredential)return MultiFactorSessionImpl._fromMfaPendingCredential(e.multiFactorSession.pendingCredential);if(null===(r=e.multiFactorSession)||void 0===r?void 0:r.idToken)return MultiFactorSessionImpl._fromIdtoken(e.multiFactorSession.idToken)}return null},MultiFactorSessionImpl}(),ve=function(){function MultiFactorResolverImpl(e,t,r){this.session=e,this.hints=t,this.signInResolver=r}return MultiFactorResolverImpl._fromError=function(e,t){var r=this,n=_castAuth(e),i=t.customData._serverResponse,o=(i.mfaInfo||[]).map((function(e){return se._fromServerResponse(n,e)}));_assert(i.mfaPendingCredential,n,"internal-error");var s=_e._fromMfaPendingCredential(i.mfaPendingCredential);return new MultiFactorResolverImpl(s,o,(function(e){return __awaiter(r,void 0,void 0,(function(){var r,o,a;return __generator(this,(function(u){switch(u.label){case 0:return[4,e._process(n,s)];case 1:switch(r=u.sent(),delete i.mfaInfo,delete i.mfaPendingCredential,o=__assign(__assign({},i),{idToken:r.idToken,refreshToken:r.refreshToken}),t.operationType){case"signIn":return[3,2];case"reauthenticate":return[3,5]}return[3,6];case 2:return[4,ie._fromIdTokenResponse(n,t.operationType,o)];case 3:return a=u.sent(),[4,n._updateCurrentUser(a.user)];case 4:return u.sent(),[2,a];case 5:return _assert(t.user,n,"internal-error"),[2,ie._forOperation(t.user,t.operationType,o)];case 6:_fail(n,"internal-error"),u.label=7;case 7:return[2]}}))}))}))},MultiFactorResolverImpl.prototype.resolveSignIn=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){return t=e,[2,this.signInResolver(t)]}))}))},MultiFactorResolverImpl}();function getMultiFactorResolver(e,t){var r,n=getModularInstance(e),i=t;return _assert(t.customData.operationType,n,"argument-error"),_assert(null===(r=i.customData._serverResponse)||void 0===r?void 0:r.mfaPendingCredential,n,"argument-error"),ve._fromError(n,i)}var ge=function(){function MultiFactorUserImpl(e){var t=this;this.user=e,this.enrolledFactors=[],e._onReload((function(r){r.mfaInfo&&(t.enrolledFactors=r.mfaInfo.map((function(t){return se._fromServerResponse(e.auth,t)})))}))}return MultiFactorUserImpl._fromUser=function(e){return new MultiFactorUserImpl(e)},MultiFactorUserImpl.prototype.getSession=function(){return __awaiter(this,void 0,void 0,(function(){var e,t;return __generator(this,(function(r){switch(r.label){case 0:return t=(e=_e)._fromIdtoken,[4,this.user.getIdToken()];case 1:return[2,t.apply(e,[r.sent(),this.user])]}}))}))},MultiFactorUserImpl.prototype.enroll=function(e,t){return __awaiter(this,void 0,void 0,(function(){var r,n,i;return __generator(this,(function(o){switch(o.label){case 0:return r=e,[4,this.getSession()];case 1:return n=o.sent(),[4,_logoutIfInvalidated(this.user,r._process(this.user.auth,n,t))];case 2:return i=o.sent(),[4,this.user._updateTokensIfNecessary(i)];case 3:return o.sent(),[2,this.user.reload()]}}))}))},MultiFactorUserImpl.prototype.unenroll=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,n;return __generator(this,(function(i){switch(i.label){case 0:return t="string"==typeof e?e:e.uid,[4,this.user.getIdToken()];case 1:r=i.sent(),i.label=2;case 2:return i.trys.push([2,6,,7]),[4,_logoutIfInvalidated(this.user,(o=this.user.auth,s={idToken:r,mfaEnrollmentId:t},_performApiRequest(o,"POST","/v2/accounts/mfaEnrollment:withdraw",_addTidIfNecessary(o,s))))];case 3:return n=i.sent(),this.enrolledFactors=this.enrolledFactors.filter((function(e){return e.uid!==t})),[4,this.user._updateTokensIfNecessary(n)];case 4:return i.sent(),[4,this.user.reload()];case 5:return i.sent(),[3,7];case 6:throw i.sent();case 7:return[2]}var o,s}))}))},MultiFactorUserImpl}(),me=new WeakMap;function multiFactor(e){var t=getModularInstance(e);return me.has(t)||me.set(t,ge._fromUser(t)),me.get(t)}var Ie="@firebase/auth",Ae=function(){function AuthInterop(e){this.auth=e,this.internalListeners=new Map}return AuthInterop.prototype.getUid=function(){var e;return this.assertAuthConfigured(),(null===(e=this.auth.currentUser)||void 0===e?void 0:e.uid)||null},AuthInterop.prototype.getToken=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:return this.assertAuthConfigured(),[4,this.auth._initializationPromise];case 1:return t.sent(),this.auth.currentUser?[4,this.auth.currentUser.getIdToken(e)]:[2,null];case 2:return[2,{accessToken:t.sent()}]}}))}))},AuthInterop.prototype.addAuthTokenListener=function(e){if(this.assertAuthConfigured(),!this.internalListeners.has(e)){var t=this.auth.onIdTokenChanged((function(t){e((null==t?void 0:t.stsTokenManager.accessToken)||null)}));this.internalListeners.set(e,t),this.updateProactiveRefresh()}},AuthInterop.prototype.removeAuthTokenListener=function(e){this.assertAuthConfigured();var t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())},AuthInterop.prototype.assertAuthConfigured=function(){_assert(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")},AuthInterop.prototype.updateProactiveRefresh=function(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()},AuthInterop}();var ye={PHONE:"phone",TOTP:"totp"},Ee={FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PASSWORD:"password",PHONE:"phone",TWITTER:"twitter.com"},we={EMAIL_LINK:"emailLink",EMAIL_PASSWORD:"password",FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PHONE:"phone",TWITTER:"twitter.com"},Te={LINK:"link",REAUTHENTICATE:"reauthenticate",SIGN_IN:"signIn"},be={EMAIL_SIGNIN:"EMAIL_SIGNIN",PASSWORD_RESET:"PASSWORD_RESET",RECOVER_EMAIL:"RECOVER_EMAIL",REVERT_SECOND_FACTOR_ADDITION:"REVERT_SECOND_FACTOR_ADDITION",VERIFY_AND_CHANGE_EMAIL:"VERIFY_AND_CHANGE_EMAIL",VERIFY_EMAIL:"VERIFY_EMAIL"},Pe=function(){function BrowserPersistenceClass(e,t){this.storageRetriever=e,this.type=t}return BrowserPersistenceClass.prototype._isAvailable=function(){try{return this.storage?(this.storage.setItem("__sak","1"),this.storage.removeItem("__sak"),Promise.resolve(!0)):Promise.resolve(!1)}catch(e){return Promise.resolve(!1)}},BrowserPersistenceClass.prototype._set=function(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()},BrowserPersistenceClass.prototype._get=function(e){var t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)},BrowserPersistenceClass.prototype._remove=function(e){return this.storage.removeItem(e),Promise.resolve()},Object.defineProperty(BrowserPersistenceClass.prototype,"storage",{get:function(){return this.storageRetriever()},enumerable:!1,configurable:!0}),BrowserPersistenceClass}();var Se=function(e){function BrowserLocalPersistence(){var t=e.call(this,(function(){return window.localStorage}),"LOCAL")||this;return t.boundEventHandler=function(e,r){return t.onStorageEvent(e,r)},t.listeners={},t.localCache={},t.pollTimer=null,t.safariLocalStorageNotSynced=function _iframeCannotSyncWebStorage(){var e=getUA();return _isSafari(e)||_isIOS(e)}()&&function _isIframe(){try{return!(!window||window===window.top)}catch(e){return!1}}(),t.fallbackToPolling=function _isMobileBrowser(e){return void 0===e&&(e=getUA()),_isIOS(e)||_isAndroid(e)||_isWebOS(e)||_isBlackBerry(e)||/windows phone/i.test(e)||_isIEMobile(e)}(),t._shouldAllowMigration=!0,t}return __extends(BrowserLocalPersistence,e),BrowserLocalPersistence.prototype.forAllChangedKeys=function(e){for(var t=0,r=Object.keys(this.listeners);t0&&(a.scopes=h.join(",")),t.tenantId&&(a.tid=t.tenantId),p=a,f=0,_=Object.keys(p);f<_.length;f++)v=_[f],void 0===p[v]&&delete p[v];return[4,t._getAppCheckToken()];case 1:return g=I.sent(),m=g?"#".concat(Me,"=").concat(encodeURIComponent(g)):"",[2,"".concat(getHandlerBase(t),"?").concat(querystring(p).slice(1)).concat(m)]}}))}))}function getHandlerBase(e){var t=e.config;return t.emulator?_emulatorUrl(t,"emulator/auth/handler"):"https://".concat(t.authDomain,"/").concat("__/auth/handler")}function _cordovaWindow(){return window}function _getProjectConfig(e,t){return void 0===t&&(t={}),__awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){return[2,_performApiRequest(e,"GET","/v1/projects",t)]}))}))}function _generateHandlerUrl(e,t,r){var n;return __awaiter(this,void 0,void 0,(function(){var i,o,s;return __generator(this,(function(a){switch(a.label){case 0:return i=_cordovaWindow().BuildInfo,debugAssert(t.sessionId,"AuthEvent did not contain a session ID"),[4,computeSha256(t.sessionId)];case 1:return o=a.sent(),s={},_isIOS()?s.ibi=i.packageName:_isAndroid()?s.apn=i.packageName:_fail(e,"operation-not-supported-in-this-environment"),i.displayName&&(s.appDisplayName=i.displayName),s.sessionId=o,[2,_getRedirectUrl(e,r,t.type,void 0,null!==(n=t.eventId)&&void 0!==n?n:void 0,s)]}}))}))}function _performRedirect(e){var t=_cordovaWindow().cordova;return new Promise((function(r){t.plugins.browsertab.isAvailable((function(n){var i=null;n?t.plugins.browsertab.openUrl(e):i=t.InAppBrowser.open(e,function _isIOS7Or8(e){return void 0===e&&(e=getUA()),/(iPad|iPhone|iPod).*OS 7_\d/i.test(e)||/(iPad|iPhone|iPod).*OS 8_\d/i.test(e)}()?"_blank":"_system","location=yes"),r(i)}))}))}function _waitForAppResume(e,t,r){return __awaiter(this,void 0,void 0,(function(){var n,i;return __generator(this,(function(o){switch(o.label){case 0:n=_cordovaWindow().cordova,i=function(){},o.label=1;case 1:return o.trys.push([1,,3,4]),[4,new Promise((function(o,s){var a=null;function authEventSeen(){var e;o();var t=null===(e=n.plugins.browsertab)||void 0===e?void 0:e.close;"function"==typeof t&&t(),"function"==typeof(null==r?void 0:r.close)&&r.close()}function resumed(){a||(a=window.setTimeout((function(){s(_createError(e,"redirect-cancelled-by-user"))}),2e3))}function visibilityChanged(){"visible"===(null===document||void 0===document?void 0:document.visibilityState)&&resumed()}t.addPassiveListener(authEventSeen),document.addEventListener("resume",resumed,!1),_isAndroid()&&document.addEventListener("visibilitychange",visibilityChanged,!1),i=function(){t.removePassiveListener(authEventSeen),document.removeEventListener("resume",resumed,!1),document.removeEventListener("visibilitychange",visibilityChanged,!1),a&&window.clearTimeout(a)}}))];case 2:return o.sent(),[3,4];case 3:return i(),[7];case 4:return[2]}}))}))}function computeSha256(e){return __awaiter(this,void 0,void 0,(function(){var t,r;return __generator(this,(function(n){switch(n.label){case 0:return t=function stringToArrayBuffer(e){if(debugAssert(/[0-9a-zA-Z]+/.test(e),"Can only convert alpha-numeric strings"),"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0;n=6e5&&this.cachedEventUids.clear(),this.cachedEventUids.has(eventUid(e))},AuthEventManager.prototype.saveEventToCache=function(e){this.cachedEventUids.add(eventUid(e)),this.lastProcessedEventTime=Date.now()},AuthEventManager}();function eventUid(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter((function(e){return e})).join("-")}function isNullRedirectEvent(e){var t=e.type,r=e.error;return"unknown"===t&&(null==r?void 0:r.code)==="auth/".concat("no-auth-event")}var Ue=function(e){function CordovaAuthEventManager(){var t=null!==e&&e.apply(this,arguments)||this;return t.passiveListeners=new Set,t.initPromise=new Promise((function(e){t.resolveInialized=e})),t}return __extends(CordovaAuthEventManager,e),CordovaAuthEventManager.prototype.addPassiveListener=function(e){this.passiveListeners.add(e)},CordovaAuthEventManager.prototype.removePassiveListener=function(e){this.passiveListeners.delete(e)},CordovaAuthEventManager.prototype.resetRedirect=function(){this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1},CordovaAuthEventManager.prototype.onEvent=function(t){return this.resolveInialized(),this.passiveListeners.forEach((function(e){return e(t)})),e.prototype.onEvent.call(this,t)},CordovaAuthEventManager.prototype.initialized=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:return[4,this.initPromise];case 1:return e.sent(),[2]}}))}))},CordovaAuthEventManager}(De);function _savePartialEvent(e,t){return storage()._set(persistenceKey(e),t)}function _getAndRemoveEvent(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){switch(r.label){case 0:return[4,storage()._get(persistenceKey(e))];case 1:return(t=r.sent())?[4,storage()._remove(persistenceKey(e))]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2,t]}}))}))}function _eventFromPartialAndUrl(e,t){var r,n,i=function _getDeepLinkFromCallback(e){var t=searchParamsOrEmpty(e),r=t.link?decodeURIComponent(t.link):void 0,n=searchParamsOrEmpty(r).link,i=t.deep_link_id?decodeURIComponent(t.deep_link_id):void 0;return searchParamsOrEmpty(i).link||i||n||r||e}(t);if(i.includes("/__/auth/callback")){var o=searchParamsOrEmpty(i),s=o.firebaseError?function parseJsonOrNull(e){try{return JSON.parse(e)}catch(e){return null}}(decodeURIComponent(o.firebaseError)):null,a=null===(n=null===(r=null==s?void 0:s.code)||void 0===r?void 0:r.split("auth/"))||void 0===n?void 0:n[1],u=a?_createError(a):null;return u?{type:e.type,eventId:e.eventId,tenantId:e.tenantId,error:u,urlResponse:null,sessionId:null,postBody:null}:{type:e.type,eventId:e.eventId,tenantId:e.tenantId,sessionId:e.sessionId,urlResponse:i,postBody:null}}return null}function generateSessionId(){for(var e=[],t="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",r=0;r<20;r++){var n=Math.floor(Math.random()*t.length);e.push(t.charAt(n))}return e.join("")}function storage(){return _getInstance(Re)}function persistenceKey(e){return _persistenceKeyName("authEvent",e.config.apiKey,e.name)}function searchParamsOrEmpty(e){if(!(null==e?void 0:e.includes("?")))return{};var t=e.split("?");return t[0],querystringDecode(t.slice(1).join("?"))}var Fe=function(){function CordovaPopupRedirectResolver(){this._redirectPersistence=ke,this._shouldInitProactively=!0,this.eventManagers=new Map,this.originValidationPromises={},this._completeRedirectFn=_getRedirectResult,this._overrideRedirectResult=_overrideRedirectResult}return CordovaPopupRedirectResolver.prototype._initialize=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r;return __generator(this,(function(n){return t=e._key(),(r=this.eventManagers.get(t))||(r=new Ue(e),this.eventManagers.set(t,r),this.attachCallbackListeners(e,r)),[2,r]}))}))},CordovaPopupRedirectResolver.prototype._openPopup=function(e){_fail(e,"operation-not-supported-in-this-environment")},CordovaPopupRedirectResolver.prototype._openRedirect=function(e,t,r,n){return __awaiter(this,void 0,void 0,(function(){var i,o,s;return __generator(this,(function(a){switch(a.label){case 0:return function _checkCordovaConfiguration(e){var t,r,n,i,o,s,a,u,c,d,l=_cordovaWindow();_assert("function"==typeof(null===(t=null==l?void 0:l.universalLinks)||void 0===t?void 0:t.subscribe),e,"invalid-cordova-configuration",{missingPlugin:"cordova-universal-links-plugin-fix"}),_assert(void 0!==(null===(r=null==l?void 0:l.BuildInfo)||void 0===r?void 0:r.packageName),e,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-buildInfo"}),_assert("function"==typeof(null===(o=null===(i=null===(n=null==l?void 0:l.cordova)||void 0===n?void 0:n.plugins)||void 0===i?void 0:i.browsertab)||void 0===o?void 0:o.openUrl),e,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-browsertab"}),_assert("function"==typeof(null===(u=null===(a=null===(s=null==l?void 0:l.cordova)||void 0===s?void 0:s.plugins)||void 0===a?void 0:a.browsertab)||void 0===u?void 0:u.isAvailable),e,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-browsertab"}),_assert("function"==typeof(null===(d=null===(c=null==l?void 0:l.cordova)||void 0===c?void 0:c.InAppBrowser)||void 0===d?void 0:d.open),e,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-inappbrowser"})}(e),[4,this._initialize(e)];case 1:return[4,(i=a.sent()).initialized()];case 2:return a.sent(),i.resetRedirect(),function _clearRedirectOutcomes(){Ne.clear()}(),[4,this._originValidation(e)];case 3:return a.sent(),o=function _generateNewEvent(e,t,r){return void 0===r&&(r=null),{type:t,eventId:r,urlResponse:null,sessionId:generateSessionId(),postBody:null,tenantId:e.tenantId,error:_createError(e,"no-auth-event")}}(e,r,n),[4,_savePartialEvent(e,o)];case 4:return a.sent(),[4,_generateHandlerUrl(e,o,t)];case 5:return[4,_performRedirect(a.sent())];case 6:return s=a.sent(),[2,_waitForAppResume(e,i,s)]}}))}))},CordovaPopupRedirectResolver.prototype._isIframeWebStorageSupported=function(e,t){throw new Error("Method not implemented.")},CordovaPopupRedirectResolver.prototype._originValidation=function(e){var t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=function _validateOrigin(e){return __awaiter(this,void 0,void 0,(function(){var t,r;return __generator(this,(function(n){switch(n.label){case 0:return t=_cordovaWindow().BuildInfo,r={},_isIOS()?r.iosBundleId=t.packageName:_isAndroid()?r.androidPackageName=t.packageName:_fail(e,"operation-not-supported-in-this-environment"),[4,_getProjectConfig(e,r)];case 1:return n.sent(),[2]}}))}))}(e)),this.originValidationPromises[t]},CordovaPopupRedirectResolver.prototype.attachCallbackListeners=function(e,t){var r=this,n=_cordovaWindow(),i=n.universalLinks,o=n.handleOpenURL,s=n.BuildInfo,a=setTimeout((function(){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(r){switch(r.label){case 0:return[4,_getAndRemoveEvent(e)];case 1:return r.sent(),t.onEvent(generateNoEvent()),[2]}}))}))}),500),universalLinksCb=function(n){return __awaiter(r,void 0,void 0,(function(){var r,i;return __generator(this,(function(o){switch(o.label){case 0:return clearTimeout(a),[4,_getAndRemoveEvent(e)];case 1:return r=o.sent(),i=null,r&&(null==n?void 0:n.url)&&(i=_eventFromPartialAndUrl(r,n.url)),t.onEvent(i||generateNoEvent()),[2]}}))}))};void 0!==i&&"function"==typeof i.subscribe&&i.subscribe(null,universalLinksCb);var u=o,c="".concat(s.packageName.toLowerCase(),"://");_cordovaWindow().handleOpenURL=function(e){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(t){if(e.toLowerCase().startsWith(c)&&universalLinksCb({url:e}),"function"==typeof u)try{u(e)}catch(e){console.error(e)}return[2]}))}))}},CordovaPopupRedirectResolver}(),Ve=Fe;function generateNoEvent(){return{type:"unknown",eventId:null,sessionId:null,urlResponse:null,postBody:null,tenantId:null,error:_createError("no-auth-event")}}function signInWithRedirect(e,t,r){return function _signInWithRedirect(e,t,r){return __awaiter(this,void 0,void 0,(function(){var n,i;return __generator(this,(function(o){switch(o.label){case 0:return n=_castAuth(e),_assertInstanceOf(e,t,Y),[4,n._initializationPromise];case 1:return o.sent(),[4,_setPendingRedirectStatus(i=_withDefaultResolver(n,r),n)];case 2:return o.sent(),[2,i._openRedirect(n,t,"signInViaRedirect")]}}))}))}(e,t,r)}function reauthenticateWithRedirect(e,t,r){return function _reauthenticateWithRedirect(e,t,r){return __awaiter(this,void 0,void 0,(function(){var n,i,o;return __generator(this,(function(s){switch(s.label){case 0:return _assertInstanceOf((n=getModularInstance(e)).auth,t,Y),[4,n.auth._initializationPromise];case 1:return s.sent(),[4,_setPendingRedirectStatus(i=_withDefaultResolver(n.auth,r),n.auth)];case 2:return s.sent(),[4,prepareUserForRedirect(n)];case 3:return o=s.sent(),[2,i._openRedirect(n.auth,t,"reauthViaRedirect",o)]}}))}))}(e,t,r)}function linkWithRedirect(e,t,r){return function _linkWithRedirect(e,t,r){return __awaiter(this,void 0,void 0,(function(){var n,i,o;return __generator(this,(function(s){switch(s.label){case 0:return _assertInstanceOf((n=getModularInstance(e)).auth,t,Y),[4,n.auth._initializationPromise];case 1:return s.sent(),i=_withDefaultResolver(n.auth,r),[4,_assertLinkedStatus(!1,n,t.providerId)];case 2:return s.sent(),[4,_setPendingRedirectStatus(i,n.auth)];case 3:return s.sent(),[4,prepareUserForRedirect(n)];case 4:return o=s.sent(),[2,i._openRedirect(n.auth,t,"linkViaRedirect",o)]}}))}))}(e,t,r)}function getAuth(e){void 0===e&&(e=n());var t=_getProvider(e,"auth");return t.isInitialized()?t.getImmediate():initializeAuth(e,{persistence:_,popupRedirectResolver:Ve})}!function registerAuth(e){t(new Component("auth",(function(t,r){var n=r.options,i=t.getProvider("app").getImmediate(),o=t.getProvider("heartbeat"),s=t.getProvider("app-check-internal"),a=i.options,u=a.apiKey,c=a.authDomain;_assert(u&&!u.includes(":"),"invalid-api-key",{appName:i.name});var d={apiKey:u,authDomain:c,clientPlatform:e,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:_getClientVersion(e)},l=new F(i,o,s,d);return function _initializeAuthInstance(e,t){var r=(null==t?void 0:t.persistence)||[],n=(Array.isArray(r)?r:[r]).map(_getInstance);(null==t?void 0:t.errorMap)&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(n,null==t?void 0:t.popupRedirectResolver)}(l,n),l}),"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((function(e,t,r){e.getProvider("auth-internal").initialize()}))),t(new Component("auth-internal",(function(e){return function(e){return new Ae(e)}(_castAuth(e.getProvider("auth").getImmediate()))}),"PRIVATE").setInstantiationMode("EXPLICIT")),r(Ie,"1.6.0",function getVersionForPlatform(e){switch(e){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}(e)),r(Ie,"1.6.0","esm5")}("Cordova");export{be as ActionCodeOperation,K as ActionCodeURL,B as AuthCredential,I as AuthErrorCodes,H as EmailAuthCredential,J as EmailAuthProvider,Q as FacebookAuthProvider,ye as FactorId,ee as GithubAuthProvider,Z as GoogleAuthProvider,G as OAuthCredential,X as OAuthProvider,Te as OperationType,z as PhoneAuthCredential,Ee as ProviderId,re as SAMLAuthProvider,we as SignInMethod,ne as TwitterAuthProvider,applyActionCode,beforeAuthStateChanged,Re as browserLocalPersistence,ke as browserSessionPersistence,checkActionCode,confirmPasswordReset,connectAuthEmulator,Ve as cordovaPopupRedirectResolver,createUserWithEmailAndPassword,v as debugErrorMap,deleteUser,fetchSignInMethodsForEmail,getAdditionalUserInfo,getAuth,getIdToken,getIdTokenResult,getMultiFactorResolver,getRedirectResult,L as inMemoryPersistence,_ as indexedDBLocalPersistence,initializeAuth,initializeRecaptchaConfig,isSignInWithEmailLink,linkWithCredential,linkWithRedirect,multiFactor,onAuthStateChanged,onIdTokenChanged,parseActionCodeURL,g as prodErrorMap,reauthenticateWithCredential,reauthenticateWithRedirect,reload,revokeAccessToken,sendEmailVerification,sendPasswordResetEmail,sendSignInLinkToEmail,setPersistence,signInAnonymously,signInWithCredential,signInWithCustomToken,signInWithEmailAndPassword,signInWithEmailLink,signInWithRedirect,signOut,unlink,updateCurrentUser,updateEmail,updatePassword,updateProfile,useDeviceLanguage,validatePassword,verifyBeforeUpdateEmail,verifyPasswordResetCode}; //# sourceMappingURL=firebase-auth-cordova.js.map