!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("@firebase/app-compat"),require("@firebase/app")):"function"==typeof define&&define.amd?define(["@firebase/app-compat","@firebase/app"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).firebase,e.firebase.INTERNAL.modularAPIs)}(this,function(ui,li){"use strict";try{!function(){function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=e(ui),r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function s(e,t){var n={};for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,i=Object.getOwnPropertySymbols(e);r>6,u=63&u;c||(u=64,o||(l=64)),r.push(n[s>>2],n[(3&s)<<4|a>>4],n[l],n[u])}return r.join("")},encodeString:function(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(function(e){for(var t=[],n=0,r=0;r>6|192:(55296==(64512&i)&&r+1>18|240,t[n++]=i>>12&63|128):t[n++]=i>>12|224,t[n++]=i>>6&63|128),t[n++]=63&i|128)}return t}(e),t)},decodeString:function(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){for(var t=[],n=0,r=0;n>10)),t[r++]=String.fromCharCode(56320+(1023&i))):(s=e[n++],o=e[n++],t[r++]=String.fromCharCode((15&a)<<12|(63&s)<<6|63&o))}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray:function(e,t){this.init_();for(var n=t?this.charToByteMapWebSafe_:this.charToByteMap_,r=[],i=0;i>4),64!==a&&(r.push(o<<4&240|a>>2),64!==c&&r.push(a<<6&192|c))}return r},init_:function(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(var 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)}}},a=function(e){try{return t.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function d(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function c(){try{return"[object process]"===Object.prototype.toString.call(global.process)}catch(e){return!1}}function n(){var e="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof e&&void 0!==e.id}function u(){return"object"==typeof navigator&&"ReactNative"===navigator.product}function l(){var e=d();return 0<=e.indexOf("MSIE ")||0<=e.indexOf("Trident/")}function h(){return"indexedDB"in self&&null!=indexedDB}var p,f="FirebaseError",m=(function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(g,p=Error),g);function g(e,t,n){t=p.call(this,t)||this;return t.code=e,t.customData=n,t.name=f,Object.setPrototypeOf(t,g.prototype),Error.captureStackTrace&&Error.captureStackTrace(t,v.prototype.create),t}var v=(y.prototype.create=function(e){for(var t=[],n=1;n"})):"Error",e=this.serviceName+": "+e+" ("+s+").";return new m(s,e,i)},y);function y(e,t,n){this.service=e,this.serviceName=t,this.errors=n}var _=/\{\$([^}]+)}/g;function I(e){for(var n=[],t=0,r=Object.entries(e);t{let e={},t={};a&&("GET"===s?t=a:e={body:JSON.stringify(a)});var n=I(Object.assign({key:i.config.apiKey},t)).slice(1);const r=new(te.headers());return r.set("Content-Type","application/json"),r.set("X-Client-Version",i._getSdkClientVersion()),i.languageCode&&r.set("X-Firebase-Locale",i.languageCode),te.fetch()(ce(i,i.config.apiHost,o,n),Object.assign({method:s,headers:r,referrerPolicy:"no-referrer"},e))})}async function oe(t,e,n){t._canInitEmulator=!1;e=Object.assign(Object.assign({},ne),e);try{const i=new ue(t),s=await Promise.race([n(),i.promise]);i.clearNetworkTimeout();var r=await s.json();if("needConfirmation"in r)throw le(t,"account-exists-with-different-credential",r);if(s.ok&&!("errorMessage"in r))return r;{const o=s.ok?r.errorMessage:r.error.message,a=o.split(" : ")[0];if("FEDERATED_USER_ID_ALREADY_LINKED"===a)throw le(t,"credential-already-in-use",r);if("EMAIL_EXISTS"===a)throw le(t,"email-already-in-use",r);H(t,e[a]||a.toLowerCase().replace(/[_\s]+/g,"-"))}}catch(e){if(e instanceof m)throw e;H(t,"network-request-failed")}}async function ae(e,t,n,r,i={}){i=await se(e,t,n,r,i);return"mfaPendingCredential"in i&&H(e,"multi-factor-auth-required",{serverResponse:i}),i}function ce(e,t,n,r){r=`${t}${n}?${r}`;return e.config.emulator?ee(e.config,r):`${e.config.apiScheme}://${r}`}class ue{constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((e,t)=>{this.timer=setTimeout(()=>t(z(this.auth,"timeout")),re.get())})}clearNetworkTimeout(){clearTimeout(this.timer)}}function le(e,t,n){const r={appName:e.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const i=z(e,t,r);return i.customData._tokenResponse=n,i}function de(e){if(e)try{const t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch(e){}}function he(e){return 1e3*Number(e)}function pe(e){var[t,n,e]=e.split(".");if(void 0===t||void 0===n||void 0===e)return W("JWT malformed, contained fewer than 3 sections"),null;try{var r=a(n);return r?JSON.parse(r):(W("Failed to decode base64 JWT payload"),null)}catch(e){return W("Caught error parsing JWT payload as JSON",e),null}}async function fe(t,n,e=!1){if(e)return n;try{return await n}catch(e){throw e instanceof m&&([{code:n}]=[e],"auth/user-disabled"===n||"auth/user-token-expired"===n)&&t.auth.currentUser===t&&await t.auth.signOut(),e}}class me{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,null!==this.timerId&&clearTimeout(this.timerId))}getInterval(e){if(e){var t=this.errorBackoff;return this.errorBackoff=Math.min(2*this.errorBackoff,96e4),t}this.errorBackoff=3e4;t=(null!==(t=this.user.stsTokenManager.expirationTime)&&void 0!==t?t:0)-Date.now()-3e5;return Math.max(0,t)}schedule(e=!1){this.isRunning&&(e=this.getInterval(e),this.timerId=setTimeout(async()=>{await this.iteration()},e))}async iteration(){try{await this.user.getIdToken(!0)}catch(e){return void("auth/network-request-failed"===e.code&&this.schedule(!0))}this.schedule()}}class ge{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=de(this.lastLoginAt),this.creationTime=de(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function ve(e){var t=e.auth,n=await e.getIdToken(),r=await fe(e,async function(e,t){return se(e,"POST","/v1/accounts:lookup",t)}(t,{idToken:n}));B(null==r?void 0:r.users.length,t,"internal-error");var i=r.users[0];e._notifyReloadListener(i);t=null!==(n=i.providerUserInfo)&&void 0!==n&&n.length?i.providerUserInfo.map(e=>{var{providerId:t}=e,e=s(e,["providerId"]);return{providerId:t,uid:e.rawId||"",displayName:e.displayName||null,email:e.email||null,phoneNumber:e.phoneNumber||null,photoURL:e.photoUrl||null}}):[],r=function(e,n){e=e.filter(t=>!n.some(e=>e.providerId===t.providerId));return[...e,...n]}(e.providerData,t),n=e.isAnonymous,t=!(e.email&&i.passwordHash||null!=r&&r.length),t=!!n&&t,t={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:r,metadata:new ge(i.createdAt,i.lastLoginAt),isAnonymous:t};Object.assign(e,t)}class ye{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){B(e.idToken,"internal-error"),B(void 0!==e.idToken,"internal-error"),B(void 0!==e.refreshToken,"internal-error");var t,t="expiresIn"in e&&void 0!==e.expiresIn?Number(e.expiresIn):(B(t=pe(t=e.idToken),"internal-error"),B(void 0!==t.exp,"internal-error"),B(void 0!==t.iat,"internal-error"),Number(t.exp)-Number(t.iat));this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}async getToken(e,t=!1){return B(!this.accessToken||this.refreshToken,e,"user-token-expired"),t||!this.accessToken||this.isExpired?this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null:this.accessToken}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){var r,i,{accessToken:t,refreshToken:e,expiresIn:n}=(i=t,await{accessToken:(n=await oe(r=e,{},()=>{var e=I({grant_type:"refresh_token",refresh_token:i}).slice(1),{tokenApiHost:t,apiKey:n}=r.config,n=ce(r,t,"/v1/token",`key=${n}`);return te.fetch()(n,{method:"POST",headers:{"X-Client-Version":r._getSdkClientVersion(),"Content-Type":"application/x-www-form-urlencoded"},body:e})})).access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token});this.updateTokensAndExpiration(t,e,Number(n))}updateTokensAndExpiration(e,t,n){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+1e3*n}static fromJSON(e,t){var{refreshToken:n,accessToken:r,expirationTime:t}=t;const i=new ye;return n&&(B("string"==typeof n,"internal-error",{appName:e}),i.refreshToken=n),r&&(B("string"==typeof r,"internal-error",{appName:e}),i.accessToken=r),t&&(B("number"==typeof t,"internal-error",{appName:e}),i.expirationTime=t),i}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new ye,this.toJSON())}_performRefresh(){return G("not implemented")}}function _e(e,t){B("string"==typeof e||void 0===e,"internal-error",{appName:t})}class Ie{constructor(e){var{uid:t,auth:n,stsTokenManager:r}=e,e=s(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.emailVerified=!1,this.isAnonymous=!1,this.tenantId=null,this.providerData=[],this.proactiveRefresh=new me(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,this.auth=n,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=e.displayName||null,this.email=e.email||null,this.phoneNumber=e.phoneNumber||null,this.photoURL=e.photoURL||null,this.isAnonymous=e.isAnonymous||!1,this.metadata=new ge(e.createdAt||void 0,e.lastLoginAt||void 0)}async getIdToken(e){e=await fe(this,this.stsTokenManager.getToken(this.auth,e));return B(e,this.auth,"internal-error"),this.accessToken!==e&&(this.accessToken=e,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),e}getIdTokenResult(e){return async function(e,t=!1){const n=S(e);var r=await n.getIdToken(t),i=pe(r);return B(i&&i.exp&&i.auth_time&&i.iat,n.auth,"internal-error"),e="object"==typeof i.firebase?i.firebase:void 0,t=null==e?void 0:e.sign_in_provider,{claims:i,token:r,authTime:de(he(i.auth_time)),issuedAtTime:de(he(i.iat)),expirationTime:de(he(i.exp)),signInProvider:t||null,signInSecondFactor:(null==e?void 0:e.sign_in_second_factor)||null}}(this,e)}reload(){return async function(e){const t=S(e);await ve(t),await t.auth._persistUserIfCurrent(t),t.auth._notifyListenersIfCurrent(t)}(this)}_assign(e){this!==e&&(B(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(e=>Object.assign({},e)),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){return new Ie(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}))}_onReload(e){B(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let n=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),n=!0),t&&await ve(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){var e=await this.getIdToken();return await fe(this,async function(e,t){return se(e,"POST","/v1/accounts:delete",t)}(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return Object.assign(Object.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(e=>Object.assign({},e)),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){var n=null!==(u=t.displayName)&&void 0!==u?u:void 0,r=null!==(o=t.email)&&void 0!==o?o:void 0,i=null!==(c=t.phoneNumber)&&void 0!==c?c:void 0,s=null!==(a=t.photoURL)&&void 0!==a?a:void 0,o=null!==(u=t.tenantId)&&void 0!==u?u:void 0,a=null!==(c=t._redirectEventId)&&void 0!==c?c:void 0,c=null!==(u=t.createdAt)&&void 0!==u?u:void 0,u=null!==(u=t.lastLoginAt)&&void 0!==u?u:void 0;const{uid:l,emailVerified:d,isAnonymous:h,providerData:p,stsTokenManager:f}=t;B(l&&f,e,"internal-error");t=ye.fromJSON(this.name,f);B("string"==typeof l,e,"internal-error"),_e(n,e.name),_e(r,e.name),B("boolean"==typeof d,e,"internal-error"),B("boolean"==typeof h,e,"internal-error"),_e(i,e.name),_e(s,e.name),_e(o,e.name),_e(a,e.name),_e(c,e.name),_e(u,e.name);const m=new Ie({uid:l,auth:e,email:r,emailVerified:d,displayName:n,isAnonymous:h,photoURL:s,phoneNumber:i,tenantId:o,stsTokenManager:t,createdAt:c,lastLoginAt:u});return p&&Array.isArray(p)&&(m.providerData=p.map(e=>Object.assign({},e))),a&&(m._redirectEventId=a),m}static async _fromIdTokenResponse(e,t,n=!1){const r=new ye;r.updateFromServerResponse(t);n=new Ie({uid:t.localId,auth:e,stsTokenManager:r,isAnonymous:n});return await ve(n),n}}class we{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){e=this.storage[e];return void 0===e?null:e}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}we.type="NONE";const Te=we;function be(e,t,n){return`firebase:${e}:${t}:${n}`}class ke{constructor(e,t,n){this.persistence=e,this.auth=t,this.userKey=n;var{config:e,name:n}=this.auth;this.fullUserKey=be(this.userKey,e.apiKey,n),this.fullPersistenceKey=be("persistence",e.apiKey,n),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){var e=await this.persistence._get(this.fullUserKey);return e?Ie._fromJSON(this.auth,e):null}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence!==e){var t=await this.getCurrentUser();return await this.removeCurrentUser(),this.persistence=e,t?this.setCurrentUser(t):void 0}}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,n="authUser"){if(!t.length)return new ke($(Te),e,n);const r=(await Promise.all(t.map(async e=>{if(await e._isAvailable())return e}))).filter(e=>e);let i=r[0]||$(Te);const s=be(n,e.config.apiKey,e.name);let o=null;for(const l of t)try{var a=await l._get(s);if(a){var c=Ie._fromJSON(e,a);l!==i&&(o=c),i=l;break}}catch(e){}var u=r.filter(e=>e._shouldAllowMigration);return i._shouldAllowMigration&&u.length&&(i=u[0],o&&await i._set(s,o.toJSON()),await Promise.all(t.map(async e=>{if(e!==i)try{await e._remove(s)}catch(e){}}))),new ke(i,e,n)}}function Ee(e){const t=e.toLowerCase();if(t.includes("opera/")||t.includes("opr/")||t.includes("opios/"))return"Opera";if(Oe(t))return"IEMobile";if(t.includes("msie")||t.includes("trident/"))return"IE";if(t.includes("edge/"))return"Edge";if(Re(t))return"Firefox";if(t.includes("silk/"))return"Silk";if(Pe(t))return"Blackberry";if(Ce(t))return"Webos";if(Se(t))return"Safari";if((t.includes("chrome/")||Ae(t))&&!t.includes("edge/"))return"Chrome";if(Ne(t))return"Android";e=e.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/);return 2===(null==e?void 0:e.length)?e[1]:"Other"}function Re(e=d()){return/firefox\//i.test(e)}function Se(e=d()){const t=e.toLowerCase();return t.includes("safari/")&&!t.includes("chrome/")&&!t.includes("crios/")&&!t.includes("android")}function Ae(e=d()){return/crios\//i.test(e)}function Oe(e=d()){return/iemobile/i.test(e)}function Ne(e=d()){return/android/i.test(e)}function Pe(e=d()){return/blackberry/i.test(e)}function Ce(e=d()){return/webos/i.test(e)}function Le(e=d()){return/iphone|ipad|ipod/i.test(e)}function De(e=d()){return Le(e)||Ne(e)||Ce(e)||Pe(e)||/windows phone/i.test(e)||Oe(e)}function Me(e,t=[]){let n;switch(e){case"Browser":n=Ee(d());break;case"Worker":n=`${Ee(d())}-${e}`;break;default:n=e}t=t.length?t.join(","):"FirebaseCore-web";return`${n}/JsCore/${li.SDK_VERSION}/${t}`}class Ue{constructor(e,t){this.app=e,this.config=t,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new xe(this),this.idTokenSubscription=new xe(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=V,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=t.sdkClientVersion}_initializeWithPersistence(t,n){return n&&(this._popupRedirectResolver=$(n)),this._initializationPromise=this.queue(async()=>{var e;this._deleted||(this.persistenceManager=await ke.create(this,t),this._deleted||(null!==(e=this._popupRedirectResolver)&&void 0!==e&&e._shouldInitProactively&&await this._popupRedirectResolver._initialize(this),await this.initializeCurrentUser(n),this._deleted||(this._isInitialized=!0)))}),this._initializationPromise}async _onStorageEvent(){if(!this._deleted){var e=await this.assertedPersistence.getCurrentUser();if(this.currentUser||e)return this.currentUser&&e&&this.currentUser.uid===e.uid?(this._currentUser._assign(e),void await this.currentUser.getIdToken()):void await this._updateCurrentUser(e)}}async initializeCurrentUser(e){var t,n;let r=await this.assertedPersistence.getCurrentUser();return e&&this.config.authDomain&&(await this.getOrInitRedirectPersistenceManager(),t=null===(n=this.redirectUser)||void 0===n?void 0:n._redirectEventId,n=null===r||void 0===r?void 0:r._redirectEventId,e=await this.tryRedirectSignIn(e),t&&t!==n||null==e||!e.user||(r=e.user)),r?r._redirectEventId?(B(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===r._redirectEventId?this.directlySetCurrentUser(r):this.reloadAndSetCurrentUserOrClear(r)):this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch(e){await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await ve(e)}catch(e){if("auth/network-request-failed"!==e.code)return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=function(){if("undefined"==typeof navigator)return null;var e=navigator;return e.languages&&e.languages[0]||e.language||null}()}async _delete(){this._deleted=!0}async updateCurrentUser(e){const t=e?S(e):null;return t&&B(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e){if(!this._deleted)return e&&B(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null)}setPersistence(e){return this.queue(async()=>{await this.assertedPersistence.setPersistence($(e))})}_getPersistence(){return this.assertedPersistence.persistence.type}_updateErrorMap(e){this._errorFactory=new v("auth","Firebase",e())}onAuthStateChanged(e,t,n){return this.registerStateListener(this.authStateSubscription,e,t,n)}onIdTokenChanged(e,t,n){return this.registerStateListener(this.idTokenSubscription,e,t,n)}toJSON(){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()}}async _setRedirectUser(e,t){const n=await this.getOrInitRedirectPersistenceManager(t);return null===e?n.removeCurrentUser():n.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){return this.redirectPersistenceManager||(B(e=e&&$(e)||this._popupRedirectResolver,this,"argument-error"),this.redirectPersistenceManager=await ke.create(this,[$(e._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()),this.redirectPersistenceManager}async _redirectUserForId(e){var t;return this._isInitialized&&await this.queue(async()=>{}),(null===(t=this._currentUser)||void 0===t?void 0:t._redirectEventId)===e?this._currentUser:(null===(t=this.redirectUser)||void 0===t?void 0:t._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var e;this._isInitialized&&(this.idTokenSubscription.next(this.currentUser),e=null!==(e=null===(e=this.currentUser)||void 0===e?void 0:e.uid)&&void 0!==e?e:null,this.lastNotifiedUid!==e&&(this.lastNotifiedUid=e,this.authStateSubscription.next(this.currentUser)))}registerStateListener(e,t,n,r){if(this._deleted)return()=>{};const i="function"==typeof t?t:t.next.bind(t),s=this._isInitialized?Promise.resolve():this._initializationPromise;return B(s,this,"internal-error"),s.then(()=>i(this.currentUser)),"function"==typeof t?e.addObserver(t,n,r):e.addObserver(t)}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&(this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh()),(this.currentUser=e)?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return B(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){e&&!this.frameworks.includes(e)&&(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=Me(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}_getSdkClientVersion(){return this.clientVersion}}function Fe(e){return S(e)}class xe{constructor(e){var t;this.auth=e,this.observer=null,this.addObserver=(t=new k(e=>this.observer=e,t)).subscribe.bind(t)}get next(){return B(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}function Ve(e,t,n){const r=Fe(e);B(r._canInitEmulator,r,"emulator-config-failed"),B(/^https?:\/\//.test(t),r,"invalid-emulator-scheme");e=!(null==n||!n.disableWarnings);const i=je(t);var{host:n,port:t}=function(e){const t=je(e),n=/(\/\/)?([^?#/]+)/.exec(e.substr(t.length));if(!n)return{host:"",port:null};const r=n[2].split("@").pop()||"",i=/^(\[[^\]]+\])(:|$)/.exec(r);{if(i){var s=i[1];return{host:s,port:We(r.substr(s.length+1))}}var[e,s]=r.split(":");return{host:e,port:We(s)}}}(t);r.config.emulator={url:`${i}//${n}${null===t?"":`:${t}`}/`},r.settings.appVerificationDisabledForTesting=!0,r.emulatorConfig=Object.freeze({host:n,port:t,protocol:i.replace(":",""),options:Object.freeze({disableWarnings:e})}),function(e){function t(){const e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}"undefined"!=typeof console&&"function"==typeof console.info&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials.");"undefined"==typeof window||"undefined"==typeof document||e||("loading"===document.readyState?window.addEventListener("DOMContentLoaded",t):t())}(e)}function je(e){var t=e.indexOf(":");return t<0?"":e.substr(0,t+1)}function We(e){if(!e)return null;e=Number(e);return isNaN(e)?null:e}class He{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return G("not implemented")}_getIdTokenResponse(e){return G("not implemented")}_linkToIdToken(e,t){return G("not implemented")}_getReauthenticationResolver(e){return G("not implemented")}}async function ze(e,t){return se(e,"POST","/v1/accounts:resetPassword",ie(e,t))}async function qe(e,t){return se(e,"POST","/v1/accounts:update",t)}async function Be(e,t){return se(e,"POST","/v1/accounts:sendOobCode",ie(e,t))}class Ge extends He{constructor(e,t,n,r=null){super("password",n),this._email=e,this._password=t,this._tenantId=r}static _fromEmailAndPassword(e,t){return new Ge(e,t,"password")}static _fromEmailAndCode(e,t,n=null){return new Ge(e,t,"emailLink",n)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){e="string"==typeof e?JSON.parse(e):e;if(null!=e&&e.email&&null!=e&&e.password){if("password"===e.signInMethod)return this._fromEmailAndPassword(e.email,e.password);if("emailLink"===e.signInMethod)return this._fromEmailAndCode(e.email,e.password,e.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case"password":return async function(e,t){return ae(e,"POST","/v1/accounts:signInWithPassword",ie(e,t))}(e,{returnSecureToken:!0,email:this._email,password:this._password});case"emailLink":return async function(e,t){return ae(e,"POST","/v1/accounts:signInWithEmailLink",ie(e,t))}(e,{email:this._email,oobCode:this._password});default:H(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":return qe(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password});case"emailLink":return async function(e,t){return ae(e,"POST","/v1/accounts:signInWithEmailLink",ie(e,t))}(e,{idToken:t,email:this._email,oobCode:this._password});default:H(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function Ke(e,t){return ae(e,"POST","/v1/accounts:signInWithIdp",ie(e,t))}class Je extends He{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new Je(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):H("argument-error"),t}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){var t="string"==typeof e?JSON.parse(e):e,{providerId:n,signInMethod:e}=t,t=s(t,["providerId","signInMethod"]);if(!n||!e)return null;e=new Je(n,e);return Object.assign(e,t),e}_getIdTokenResponse(e){return Ke(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,Ke(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,Ke(e,t)}buildRequest(){const e={requestUri:"http://localhost",returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=I(t)}return e}}const $e={USER_NOT_FOUND:"user-not-found"};class Ye extends He{constructor(e){super("phone","phone"),this.params=e}static _fromVerification(e,t){return new Ye({verificationId:e,verificationCode:t})}static _fromTokenResponse(e,t){return new Ye({phoneNumber:e,temporaryProof:t})}_getIdTokenResponse(e){return async function(e,t){return ae(e,"POST","/v1/accounts:signInWithPhoneNumber",ie(e,t))}(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return async function(e,t){if((t=await ae(e,"POST","/v1/accounts:signInWithPhoneNumber",ie(e,t))).temporaryProof)throw le(e,"account-exists-with-different-credential",t);return t}(e,Object.assign({idToken:t},this._makeVerificationRequest()))}_getReauthenticationResolver(e){return async function(e,t){return ae(e,"POST","/v1/accounts:signInWithPhoneNumber",ie(e,Object.assign(Object.assign({},t),{operation:"REAUTH"})),$e)}(e,this._makeVerificationRequest())}_makeVerificationRequest(){var{temporaryProof:e,phoneNumber:t,verificationId:n,verificationCode:r}=this.params;return e&&t?{temporaryProof:e,phoneNumber:t}:{sessionInfo:n,code:r}}toJSON(){const e={providerId:this.providerId};return this.params.phoneNumber&&(e.phoneNumber=this.params.phoneNumber),this.params.temporaryProof&&(e.temporaryProof=this.params.temporaryProof),this.params.verificationCode&&(e.verificationCode=this.params.verificationCode),this.params.verificationId&&(e.verificationId=this.params.verificationId),e}static fromJSON(e){var{verificationId:t,verificationCode:n,phoneNumber:r,temporaryProof:e}=e="string"==typeof e?JSON.parse(e):e;return n||t||r||e?new Ye({verificationId:t,verificationCode:n,phoneNumber:r,temporaryProof:e}):null}}class Xe{constructor(e){var t=w(T(e)),n=null!==(r=t.apiKey)&&void 0!==r?r:null,r=null!==(e=t.oobCode)&&void 0!==e?e:null,e=function(e){switch(e){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}(null!==(e=t.mode)&&void 0!==e?e:null);B(n&&r&&e,"argument-error"),this.apiKey=n,this.operation=e,this.code=r,this.continueUrl=null!==(r=t.continueUrl)&&void 0!==r?r:null,this.languageCode=null!==(r=t.languageCode)&&void 0!==r?r:null,this.tenantId=null!==(t=t.tenantId)&&void 0!==t?t:null}static parseLink(e){var t,n,r,t=(n=w(T(t=e)).link,r=n?w(T(n)).deep_link_id:null,((e=w(T(t)).deep_link_id)?w(T(e)).link:null)||e||r||n||t);try{return new Xe(t)}catch(e){return null}}}class Ze{constructor(){this.providerId=Ze.PROVIDER_ID}static credential(e,t){return Ge._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){t=Xe.parseLink(t);return B(t,"argument-error"),Ge._fromEmailAndCode(e,t.code,t.tenantId)}}Ze.PROVIDER_ID="password",Ze.EMAIL_PASSWORD_SIGN_IN_METHOD="password",Ze.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class Qe{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}class et extends Qe{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class tt extends et{static credentialFromJSON(e){e="string"==typeof e?JSON.parse(e):e;return B("providerId"in e&&"signInMethod"in e,"argument-error"),Je._fromParams(e)}credential(e){return this._credential(e)}_credential(e){return B(e.idToken||e.accessToken,"argument-error"),Je._fromParams(Object.assign(Object.assign({},e),{providerId:this.providerId,signInMethod:this.providerId}))}static credentialFromResult(e){return tt.oauthCredentialFromTaggedObject(e)}static credentialFromError(e){return tt.oauthCredentialFromTaggedObject(e.customData||{})}static oauthCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthIdToken:t,oauthAccessToken:n,oauthTokenSecret:r,pendingToken:i,nonce:s,providerId:e}=e;if(!(n||r||t||i))return null;if(!e)return null;try{return new tt(e)._credential({idToken:t,accessToken:n,rawNonce:s,pendingToken:i})}catch(e){return null}}}class nt extends et{constructor(){super("facebook.com")}static credential(e){return Je._fromParams({providerId:nt.PROVIDER_ID,signInMethod:nt.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return nt.credentialFromTaggedObject(e)}static credentialFromError(e){return nt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!(e&&"oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return nt.credential(e.oauthAccessToken)}catch(e){return null}}}nt.FACEBOOK_SIGN_IN_METHOD="facebook.com",nt.PROVIDER_ID="facebook.com";class rt extends et{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return Je._fromParams({providerId:rt.PROVIDER_ID,signInMethod:rt.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return rt.credentialFromTaggedObject(e)}static credentialFromError(e){return rt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthIdToken:t,oauthAccessToken:e}=e;if(!t&&!e)return null;try{return rt.credential(t,e)}catch(e){return null}}}rt.GOOGLE_SIGN_IN_METHOD="google.com",rt.PROVIDER_ID="google.com";class it extends et{constructor(){super("github.com")}static credential(e){return Je._fromParams({providerId:it.PROVIDER_ID,signInMethod:it.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return it.credentialFromTaggedObject(e)}static credentialFromError(e){return it.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!(e&&"oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return it.credential(e.oauthAccessToken)}catch(e){return null}}}it.GITHUB_SIGN_IN_METHOD="github.com",it.PROVIDER_ID="github.com";class st extends He{constructor(e,t){super(e,e),this.pendingToken=t}_getIdTokenResponse(e){return Ke(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,Ke(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,Ke(e,t)}toJSON(){return{signInMethod:this.signInMethod,providerId:this.providerId,pendingToken:this.pendingToken}}static fromJSON(e){var{providerId:t,signInMethod:n,pendingToken:e}="string"==typeof e?JSON.parse(e):e;return t&&n&&e&&t===n?new st(t,e):null}static _create(e,t){return new st(e,t)}buildRequest(){return{requestUri:"http://localhost",returnSecureToken:!0,pendingToken:this.pendingToken}}}class ot extends et{constructor(){super("twitter.com")}static credential(e,t){return Je._fromParams({providerId:ot.PROVIDER_ID,signInMethod:ot.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return ot.credentialFromTaggedObject(e)}static credentialFromError(e){return ot.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthAccessToken:t,oauthTokenSecret:e}=e;if(!t||!e)return null;try{return ot.credential(t,e)}catch(e){return null}}}ot.TWITTER_SIGN_IN_METHOD="twitter.com",ot.PROVIDER_ID="twitter.com";async function at(e,t){return ae(e,"POST","/v1/accounts:signUp",ie(e,t))}class ct{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,n,r=!1){e=await Ie._fromIdTokenResponse(e,n,r),r=ut(n);return new ct({user:e,providerId:r,_tokenResponse:n,operationType:t})}static async _forOperation(e,t,n){await e._updateTokensIfNecessary(n,!0);var r=ut(n);return new ct({user:e,providerId:r,_tokenResponse:n,operationType:t})}}function ut(e){return e.providerId||("phoneNumber"in e?"phone":null)}class lt extends m{constructor(e,t,n,r){super(t.code,t.message),this.operationType=n,this.user=r,this.name="FirebaseError",Object.setPrototypeOf(this,lt.prototype),this.appName=e.name,this.code=t.code,this.tenantId=null!==(e=e.tenantId)&&void 0!==e?e:void 0,this.serverResponse=t.customData.serverResponse}static _fromErrorAndOperation(e,t,n,r){return new lt(e,t,n,r)}}function dt(t,n,e,r){const i="reauthenticate"===n?e._getReauthenticationResolver(t):e._getIdTokenResponse(t);return i.catch(e=>{if("auth/multi-factor-auth-required"===e.code)throw lt._fromErrorAndOperation(t,e,n,r);throw e})}function ht(e){return new Set(e.map(({providerId:e})=>e).filter(e=>!!e))}async function pt(e,t){const n=S(e);await mt(!0,n,t);var{providerUserInfo:t}=(e=n.auth,t={idToken:await n.getIdToken(),deleteProvider:[t]},await se(e,"POST","/v1/accounts:update",t));const r=ht(t||[]);return n.providerData=n.providerData.filter(e=>r.has(e.providerId)),r.has("phone")||(n.phoneNumber=null),await n.auth._persistUserIfCurrent(n),n}async function ft(e,t,n=!1){n=await fe(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return ct._forOperation(e,"link",n)}async function mt(e,t,n){await ve(t);const r=ht(t.providerData);var i=!1===e?"provider-already-linked":"no-such-provider";B(r.has(n)===e,t.auth,i)}async function gt(e,t,n=!1){var{auth:r}=e,i="reauthenticate";try{var s=await fe(e,dt(r,i,t,e),n);B(s.idToken,r,"internal-error");var o=pe(s.idToken);B(o,r,"internal-error");var{sub:a}=o;return B(e.uid===a,r,"user-mismatch"),ct._forOperation(e,i,s)}catch(e){throw"auth/user-not-found"===(null==e?void 0:e.code)&&H(r,"user-mismatch"),e}}async function vt(e,t,n=!1){t=await dt(e,"signIn",t),t=await ct._fromIdTokenResponse(e,"signIn",t);return n||await e._updateCurrentUser(t.user),t}async function yt(e,t){return vt(Fe(e),t)}async function _t(e,t){e=S(e);return await mt(!1,e,t.providerId),ft(e,t)}async function It(e,t){return gt(S(e),t)}async function wt(e,t){const n=Fe(e);t=await ae(n,"POST","/v1/accounts:signInWithCustomToken",ie(n,{token:t,returnSecureToken:!0})),t=await ct._fromIdTokenResponse(n,"signIn",t);return await n._updateCurrentUser(t.user),t}class Tt{constructor(e,t){this.factorId=e,this.uid=t.mfaEnrollmentId,this.enrollmentTime=new Date(t.enrolledAt).toUTCString(),this.displayName=t.displayName}static _fromServerResponse(e,t){return"phoneInfo"in t?bt._fromServerResponse(e,t):H(e,"internal-error")}}class bt extends Tt{constructor(e){super("phone",e),this.phoneNumber=e.phoneInfo}static _fromServerResponse(e,t){return new bt(t)}}function kt(e,t,n){var r;B(0<(null===(r=n.url)||void 0===r?void 0:r.length),e,"invalid-continue-uri"),B(void 0===n.dynamicLinkDomain||0"password"===e);i&&(i.displayName=r.displayName,i.photoURL=r.photoURL),await r._updateTokensIfNecessary(n)}}async function Lt(e,t,n){var{auth:r}=e;const i={idToken:await e.getIdToken(),returnSecureToken:!0};t&&(i.email=t),n&&(i.password=n);r=await fe(e,qe(r,i));await e._updateTokensIfNecessary(r,!0)}class Dt{constructor(e,t,n={}){this.isNewUser=e,this.providerId=t,this.profile=n}}class Mt extends Dt{constructor(e,t,n,r){super(e,t,n),this.username=r}}class Ut extends Dt{constructor(e,t){super(e,"facebook.com",t)}}class Ft extends Mt{constructor(e,t){super(e,"github.com",t,"string"==typeof(null==t?void 0:t.login)?null==t?void 0:t.login:null)}}class xt extends Dt{constructor(e,t){super(e,"google.com",t)}}class Vt extends Mt{constructor(e,t,n){super(e,"twitter.com",t,n)}}function jt(e){var{user:t,_tokenResponse:e}=e;return t.isAnonymous&&!e?{providerId:null,isNewUser:!1,profile:null}:function(e){if(!e)return null;var{providerId:t}=e,n=e.rawUserInfo?JSON.parse(e.rawUserInfo):{},r=e.isNewUser||"identitytoolkit#SignupNewUserResponse"===e.kind;if(!t&&null!=e&&e.idToken){var i=null===(i=null===(i=pe(e.idToken))||void 0===i?void 0:i.firebase)||void 0===i?void 0:i.sign_in_provider;if(i){i="anonymous"!==i&&"custom"!==i?i:null;return new Dt(r,i)}}if(!t)return null;switch(t){case"facebook.com":return new Ut(r,n);case"github.com":return new Ft(r,n);case"google.com":return new xt(r,n);case"twitter.com":return new Vt(r,n,e.screenName||null);case"custom":case"anonymous":return new Dt(r,null);default:return new Dt(r,t,n)}}(e)}class Wt{constructor(e,t){this.type=e,this.credential=t}static _fromIdtoken(e){return new Wt("enroll",e)}static _fromMfaPendingCredential(e){return new Wt("signin",e)}toJSON(){return{multiFactorSession:{["enroll"===this.type?"idToken":"pendingCredential"]:this.credential}}}static fromJSON(e){var t;if(null!=e&&e.multiFactorSession){if(null!==(t=e.multiFactorSession)&&void 0!==t&&t.pendingCredential)return Wt._fromMfaPendingCredential(e.multiFactorSession.pendingCredential);if(null!==(t=e.multiFactorSession)&&void 0!==t&&t.idToken)return Wt._fromIdtoken(e.multiFactorSession.idToken)}return null}}class Ht{constructor(e,t,n){this.session=e,this.hints=t,this.signInResolver=n}static _fromError(e,r){const i=Fe(e);e=(r.serverResponse.mfaInfo||[]).map(e=>Tt._fromServerResponse(i,e));B(r.serverResponse.mfaPendingCredential,i,"internal-error");const s=Wt._fromMfaPendingCredential(r.serverResponse.mfaPendingCredential);return new Ht(s,e,async e=>{e=await e._process(i,s);delete r.serverResponse.mfaInfo,delete r.serverResponse.mfaPendingCredential;var t=Object.assign(Object.assign({},r.serverResponse),{idToken:e.idToken,refreshToken:e.refreshToken});switch(r.operationType){case"signIn":var n=await ct._fromIdTokenResponse(i,r.operationType,t);return await i._updateCurrentUser(n.user),n;case"reauthenticate":return B(r.user,i,"internal-error"),ct._forOperation(r.user,r.operationType,t);default:H(i,"internal-error")}})}async resolveSignIn(e){return this.signInResolver(e)}}class zt{constructor(t){this.user=t,this.enrolledFactors=[],t._onReload(e=>{e.mfaInfo&&(this.enrolledFactors=e.mfaInfo.map(e=>Tt._fromServerResponse(t.auth,e)))})}static _fromUser(e){return new zt(e)}async getSession(){return Wt._fromIdtoken(await this.user.getIdToken())}async enroll(e,t){const n=e;e=await this.getSession(),t=await fe(this.user,n._process(this.user.auth,e,t));return await this.user._updateTokensIfNecessary(t),this.user.reload()}async unenroll(e){const t="string"==typeof e?e:e.uid;var n=await this.user.getIdToken(),n=await fe(this.user,(e=this.user.auth,n={idToken:n,mfaEnrollmentId:t},se(e,"POST","/v2/accounts/mfaEnrollment:withdraw",Object.assign({tenantId:e.tenantId},n))));this.enrolledFactors=this.enrolledFactors.filter(({uid:e})=>e!==t),await this.user._updateTokensIfNecessary(n);try{await this.user.reload()}catch(e){if("auth/user-token-expired"!==e.code)throw e}}}const qt=new WeakMap;const Bt="__sak";class Gt{constructor(e,t){this.storage=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Bt,"1"),this.storage.removeItem(Bt),Promise.resolve(!0)):Promise.resolve(!1)}catch(e){return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){e=this.storage.getItem(e);return Promise.resolve(e?JSON.parse(e):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}}class Kt extends Gt{constructor(){var e;super(window.localStorage,"LOCAL"),this.listeners={},this.localCache={},this.pollTimer=null,this.safariLocalStorageNotSynced=(Se(e=d())||Le(e))&&function(){try{return!(!window||window===window.top)}catch(e){return!1}}(),this.fallbackToPolling=De(),this._shouldAllowMigration=!0,this.boundEventHandler=this.onStorageEvent.bind(this)}forAllChangedKeys(e){for(const r of Object.keys(this.listeners)){var t=this.storage.getItem(r),n=this.localCache[r];t!==n&&e(r,n,t)}}onStorageEvent(e,t=!1){if(e.key){const r=e.key;if(t?this.detachListener():this.stopPolling(),this.safariLocalStorageNotSynced){const i=this.storage.getItem(r);if(e.newValue!==i)null!==e.newValue?this.storage.setItem(r,e.newValue):this.storage.removeItem(r);else if(this.localCache[r]===e.newValue&&!t)return}var n=()=>{var e=this.storage.getItem(r);!t&&this.localCache[r]===e||this.notifyListeners(r,e)};const i=this.storage.getItem(r);l()&&10===document.documentMode&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(n,10):n()}else this.forAllChangedKeys((e,t,n)=>{this.notifyListeners(e,n)})}notifyListeners(e,t){this.localCache[e]=t;e=this.listeners[e];if(e)for(const n of Array.from(e))n(t&&JSON.parse(t))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,n)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:n}),!0)})},1e3)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){0===Object.keys(this.listeners).length&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){var t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}Kt.type="LOCAL";const Jt=Kt;class $t extends Gt{constructor(){super(window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}$t.type="SESSION";const Yt=$t;class Xt{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(t){var e=this.receivers.find(e=>e.isListeningto(t));if(e)return e;e=new Xt(t);return this.receivers.push(e),e}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:n,eventType:r,data:i}=t.data;e=this.handlersMap[r];null!=e&&e.size&&(t.ports[0].postMessage({status:"ack",eventId:n,eventType:r}),e=Array.from(e).map(async e=>e(t.origin,i)),e=await Promise.all(e.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(e){return{fulfilled:!1,reason:e}}})),t.ports[0].postMessage({status:"done",eventId:n,eventType:r,response:e}))}_subscribe(e,t){0===Object.keys(this.handlersMap).length&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}_unsubscribe(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),t&&0!==this.handlersMap[e].size||delete this.handlersMap[e],0===Object.keys(this.handlersMap).length&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}function Zt(e="",t=10){let n="";for(let e=0;e{const i=Zt("",20);a.port1.start();const s=setTimeout(()=>{r(new Error("unsupported_event"))},o);u={messageChannel:a,onMessage(e){var t=e;if(t.data.eventId===i)switch(t.data.status){case"ack":clearTimeout(s),c=setTimeout(()=>{r(new Error("timeout"))},3e3);break;case"done":clearTimeout(c),n(t.data.response);break;default:clearTimeout(s),clearTimeout(c),r(new Error("invalid_response"))}}},this.handlers.add(u),a.port1.addEventListener("message",u.onMessage),this.target.postMessage({eventType:e,eventId:i,data:t},[a.port2])}).finally(()=>{u&&this.removeMessageHandler(u)})}}function en(){return window}function tn(){return void 0!==en().WorkerGlobalScope&&"function"==typeof en().importScripts}const nn="firebaseLocalStorageDb",rn=1,sn="firebaseLocalStorage",on="fbase_key";class an{constructor(e){this.request=e}toPromise(){return new Promise((e,t)=>{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{t(this.request.error)})})}}function cn(e,t){return e.transaction([sn],t?"readwrite":"readonly").objectStore(sn)}function un(){const r=indexedDB.open(nn,rn);return new Promise((n,t)=>{r.addEventListener("error",()=>{t(r.error)}),r.addEventListener("upgradeneeded",()=>{const e=r.result;try{e.createObjectStore(sn,{keyPath:on})}catch(e){t(e)}}),r.addEventListener("success",async()=>{const e=r.result;var t;e.objectStoreNames.contains(sn)?n(e):(e.close(),t=indexedDB.deleteDatabase(nn),await new an(t).toPromise(),n(await un()))})})}async function ln(e,t,n){n=cn(e,!0).put({[on]:t,value:n});return new an(n).toPromise()}function dn(e,t){t=cn(e,!0).delete(t);return new an(t).toPromise()}class hn{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db||(this.db=await un(),this.db)}async _withRetries(e){let t=0;for(;;)try{return await e(await this._openDb())}catch(e){if(3{const n=await this._poll();return{keyProcessed:n.includes(t.key)}}),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){var e,t,n;this.activeServiceWorker=await async function(){if(null===navigator||void 0===navigator||!navigator.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch(e){return null}}(),this.activeServiceWorker&&(this.sender=new Qt(this.activeServiceWorker),(n=await this.sender._send("ping",{},800))&&null!==(e=n[0])&&void 0!==e&&e.fulfilled&&null!==(t=n[0])&&void 0!==t&&t.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0))}async notifyServiceWorker(e){var t;if(this.sender&&this.activeServiceWorker&&((null===(t=null===navigator||void 0===navigator?void 0:navigator.serviceWorker)||void 0===t?void 0:t.controller)||null)===this.activeServiceWorker)try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch(e){}}async _isAvailable(){try{if(!indexedDB)return!1;var e=await un();return await ln(e,Bt,"1"),await dn(e,Bt),!0}catch(e){}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(t,n){return this._withPendingWrite(async()=>(await this._withRetries(e=>ln(e,t,n)),this.localCache[t]=n,this.notifyServiceWorker(t)))}async _get(t){var e=await this._withRetries(e=>async function(e,t){return t=cn(e,!1).get(t),void 0===(t=await new an(t).toPromise())?null:t.value}(e,t));return this.localCache[t]=e}async _remove(t){return this._withPendingWrite(async()=>(await this._withRetries(e=>dn(e,t)),delete this.localCache[t],this.notifyServiceWorker(t)))}async _poll(){var e,t,n=await this._withRetries(e=>{e=cn(e,!1).getAll();return new an(e).toPromise()});if(!n)return[];if(0!==this.pendingWrites)return[];const r=[],i=new Set;for({fbase_key:e,value:t}of n)i.add(e),JSON.stringify(this.localCache[e])!==JSON.stringify(t)&&(this.notifyListeners(e,t),r.push(e));for(const s of Object.keys(this.localCache))this.localCache[s]&&!i.has(s)&&(this.notifyListeners(s,null),r.push(s));return r}notifyListeners(e,t){this.localCache[e]=t;e=this.listeners[e];if(e)for(const n of Array.from(e))n(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),800)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){0===Object.keys(this.listeners).length&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&this.stopPolling()}}hn.type="LOCAL";const pn=hn;function fn(r){return new Promise((e,n)=>{const t=document.createElement("script");t.setAttribute("src",r),t.onload=e,t.onerror=e=>{const t=z("internal-error");t.customData=e,n(t)},t.type="text/javascript",t.charset="UTF-8",(null!==(e=null===(e=document.getElementsByTagName("head"))||void 0===e?void 0:e[0])&&void 0!==e?e:document).appendChild(t)})}function mn(e){return`__${e}${Math.floor(1e6*Math.random())}`}class gn{constructor(e){this.auth=e,this.counter=1e12,this._widgets=new Map}render(e,t){var n=this.counter;return this._widgets.set(n,new vn(e,this.auth.name,t||{})),this.counter++,n}reset(e){var t=e||1e12;null===(e=this._widgets.get(t))||void 0===e||e.delete(),this._widgets.delete(t)}getResponse(e){return(null===(e=this._widgets.get(e||1e12))||void 0===e?void 0:e.getResponse())||""}async execute(e){return null===(e=this._widgets.get(e||1e12))||void 0===e||e.execute(),""}}class vn{constructor(e,t,n){this.params=n,this.timerId=null,this.deleted=!1,this.responseToken=null,this.clickHandler=()=>{this.execute()};e="string"==typeof e?document.getElementById(e):e;B(e,"argument-error",{appName:t}),this.container=e,this.isVisible="invisible"!==this.params.size,this.isVisible?this.execute():this.container.addEventListener("click",this.clickHandler)}getResponse(){return this.checkIfDeleted(),this.responseToken}delete(){this.checkIfDeleted(),this.deleted=!0,this.timerId&&(clearTimeout(this.timerId),this.timerId=null),this.container.removeEventListener("click",this.clickHandler)}execute(){this.checkIfDeleted(),this.timerId||(this.timerId=window.setTimeout(()=>{this.responseToken=function(t){const n=[],r="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let e=0;e{if(this.timerId=null,this.responseToken=null,t)try{t()}catch(e){}this.isVisible&&this.execute()},6e4)},500))}checkIfDeleted(){if(this.deleted)throw new Error("reCAPTCHA mock was already deleted!")}}const yn=mn("rcb"),_n=new Q(3e4,6e4);class In{constructor(){this.hostLanguage="",this.counter=0,this.librarySeparatelyLoaded=!!en().grecaptcha}load(s,o=""){var e;return B((e=o).length<=6&&/^\s*[a-zA-Z0-9\-]*\s*$/.test(e),s,"argument-error"),this.shouldResolveImmediately(o)?Promise.resolve(en().grecaptcha):new Promise((t,r)=>{const i=en().setTimeout(()=>{r(z(s,"network-request-failed"))},_n.get());en()[yn]=()=>{en().clearTimeout(i),delete en()[yn];const e=en().grecaptcha;if(e){const n=e.render;e.render=(e,t)=>{t=n(e,t);return this.counter++,t},this.hostLanguage=o,t(e)}else r(z(s,"internal-error"))},fn(`https://www.google.com/recaptcha/api.js??${I({onload:yn,render:"explicit",hl:o})}`).catch(()=>{clearTimeout(i),r(z(s,"internal-error"))})})}clearedOneInstance(){this.counter--}shouldResolveImmediately(e){return!!en().grecaptcha&&(e===this.hostLanguage||0{const n=e=>{e&&(this.tokenChangeListeners.delete(n),t(e))};this.tokenChangeListeners.add(n),this.isInvisible&&r.execute(e)})}render(){try{this.assertNotDestroyed()}catch(e){return Promise.reject(e)}return this.renderPromise||(this.renderPromise=this.makeRenderPromise().catch(e=>{throw this.renderPromise=null,e}),this.renderPromise)}_reset(){this.assertNotDestroyed(),null!==this.widgetId&&this.getAssertedRecaptcha().reset(this.widgetId)}clear(){this.assertNotDestroyed(),this.destroyed=!0,this._recaptchaLoader.clearedOneInstance(),this.isInvisible||this.container.childNodes.forEach(e=>{this.container.removeChild(e)})}validateStartingState(){B(!this.parameters.sitekey,this.auth,"argument-error"),B(this.isInvisible||!this.container.hasChildNodes(),this.auth,"argument-error"),B("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment")}makeTokenCallback(n){return t=>{if(this.tokenChangeListeners.forEach(e=>e(t)),"function"==typeof n)n(t);else if("string"==typeof n){const e=en()[n];"function"==typeof e&&e(t)}}}assertNotDestroyed(){B(!this.destroyed,this.auth,"internal-error")}async makeRenderPromise(){if(await this.init(),!this.widgetId){let e=this.container;var t;this.isInvisible||(t=document.createElement("div"),e.appendChild(t),e=t),this.widgetId=this.getAssertedRecaptcha().render(e,this.parameters)}return this.widgetId}async init(){B(X()&&!tn(),this.auth,"internal-error"),await function(){let t=null;return new Promise(e=>{"complete"!==document.readyState?(t=()=>e(),window.addEventListener("load",t)):e()}).catch(e=>{throw t&&window.removeEventListener("load",t),e})}(),this.recaptcha=await this._recaptchaLoader.load(this.auth,this.auth.languageCode||void 0);var e=await((await se(this.auth,"GET","/v1/recaptchaParams")).recaptchaSiteKey||"");B(e,this.auth,"internal-error"),this.parameters.sitekey=e}getAssertedRecaptcha(){return B(this.recaptcha,this.auth,"internal-error"),this.recaptcha}}class En{constructor(e,t){this.verificationId=e,this.onConfirmation=t}confirm(e){e=Ye._fromVerification(this.verificationId,e);return this.onConfirmation(e)}}async function Rn(t,n,r){var i,s,o,a,c,u,l=await r.verify();try{B("string"==typeof l,t,"argument-error"),B(r.type===Tn,t,"argument-error");let e;if(e="string"==typeof n?{phoneNumber:n}:n,"session"in e){var d=e.session;if("phoneNumber"in e)return B("enroll"===d.type,t,"internal-error"),(c=t,u={idToken:d.credential,phoneEnrollmentInfo:{phoneNumber:e.phoneNumber,recaptchaToken:l}},await se(c,"POST","/v2/accounts/mfaEnrollment:start",Object.assign({tenantId:c.tenantId},u))).phoneSessionInfo.sessionInfo;B("signin"===d.type,t,"internal-error");var h=(null===(i=e.multiFactorHint)||void 0===i?void 0:i.uid)||e.multiFactorUid;return B(h,t,"missing-multi-factor-info"),(a={mfaPendingCredential:d.credential,mfaEnrollmentId:h,phoneSignInInfo:{recaptchaToken:l}},await se(t,"POST","/v2/accounts/mfaSignIn:start",Object.assign({tenantId:t.tenantId},a))).phoneResponseInfo.sessionInfo}var{sessionInfo:p}=(s=t,o={phoneNumber:e.phoneNumber,recaptchaToken:l},await se(s,"POST","/v1/accounts:sendVerificationCode",ie(s,o)));return p}finally{r._reset()}}class Sn{constructor(e){this.providerId=Sn.PROVIDER_ID,this.auth=Fe(e)}verifyPhoneNumber(e,t){return Rn(this.auth,e,S(t))}static credential(e,t){return Ye._fromVerification(e,t)}static credentialFromResult(e){return Sn.credentialFromTaggedObject(e)}static credentialFromError(e){return Sn.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{phoneNumber:t,temporaryProof:e}=e;return t&&e?Ye._fromTokenResponse(t,e):null}}function An(e,t){return t?$(t):(B(e._popupRedirectResolver,e,"argument-error"),e._popupRedirectResolver)}Sn.PROVIDER_ID="phone",Sn.PHONE_SIGN_IN_METHOD="phone";class On extends He{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return Ke(e,this._buildIdpRequest())}_linkToIdToken(e,t){return Ke(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return Ke(e,this._buildIdpRequest())}_buildIdpRequest(e){const t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function Nn(e){return vt(e.auth,new On(e),e.bypassAuthState)}function Pn(e){var{auth:t,user:n}=e;return B(n,t,"internal-error"),gt(n,new On(e),e.bypassAuthState)}async function Cn(e){var{auth:t,user:n}=e;return B(n,t,"internal-error"),ft(n,new On(e),e.bypassAuthState)}class Ln{constructor(e,t,n,r,i=!1){this.auth=e,this.resolver=n,this.user=r,this.bypassAuthState=i,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(e){this.reject(e)}})}async onAuthEvent(e){var{urlResponse:t,sessionId:n,postBody:r,tenantId:i,error:s,type:e}=e;if(s)this.reject(s);else{r={auth:this.auth,requestUri:t,sessionId:n,tenantId:i||void 0,postBody:r||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(e)(r))}catch(e){this.reject(e)}}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return Nn;case"linkViaPopup":case"linkViaRedirect":return Cn;case"reauthViaPopup":case"reauthViaRedirect":return Pn;default:H(this.auth,"internal-error")}}resolve(e){K(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){K(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}const Dn=new Q(2e3,1e4);class Mn extends Ln{constructor(e,t,n,r,i){super(e,t,r,i),this.provider=n,this.authWindow=null,this.pollId=null,Mn.currentPopupAction&&Mn.currentPopupAction.cancel(),Mn.currentPopupAction=this}async executeNotNull(){var e=await this.execute();return B(e,this.auth,"internal-error"),e}async onExecution(){K(1===this.filter.length,"Popup operations only handle one event");var e=Zt();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(e=>{this.reject(e)}),this.resolver._isIframeWebStorageSupported(this.auth,e=>{e||this.reject(z(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return(null===(e=this.authWindow)||void 0===e?void 0:e.associatedEvent)||null}cancel(){this.reject(z(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,Mn.currentPopupAction=null}pollUserCancellation(){const t=()=>{var e;null!==(e=null===(e=this.authWindow)||void 0===e?void 0:e.window)&&void 0!==e&&e.closed?this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(z(this.auth,"popup-closed-by-user"))},2e3):this.pollId=window.setTimeout(t,Dn.get())};t()}}Mn.currentPopupAction=null;const Un="pendingRedirect",Fn=new Map;class xn extends Ln{constructor(e,t,n=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,n),this.eventId=null}async execute(){let t=Fn.get(this.auth._key());if(!t){try{const i=(e=this.resolver,n=this.auth,r=Wn(n),n="true"===await jn(e)._get(r),await jn(e)._remove(r),await n)?await super.execute():null;t=()=>Promise.resolve(i)}catch(e){t=()=>Promise.reject(e)}Fn.set(this.auth._key(),t)}var e,n,r;return t()}async onAuthEvent(e){if("signInViaRedirect"===e.type)return super.onAuthEvent(e);if("unknown"!==e.type){if(e.eventId){var t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}else this.resolve(null)}async onExecution(){}cleanUp(){}}async function Vn(e,t){return jn(e)._set(Wn(t),"true")}function jn(e){return $(e._redirectPersistence)}function Wn(e){return be(Un,e.config.apiKey,e.name)}function Hn(e,t,n){return async function(e,t,n){var r=Fe(e);B(t instanceof Qe,e,"argument-error");const i=An(r,n);return await Vn(i,r),i._openRedirect(r,t,"signInViaRedirect")}(e,t,n)}function zn(e,t,n){return async function(e,t,n){e=S(e);B(t instanceof Qe,e.auth,"argument-error");const r=An(e.auth,n);await Vn(r,e.auth);n=await Gn(e);return r._openRedirect(e.auth,t,"reauthViaRedirect",n)}(e,t,n)}function qn(e,t,n){return async function(e,t,n){e=S(e);B(t instanceof Qe,e.auth,"argument-error");const r=An(e.auth,n);await mt(!1,e,t.providerId),await Vn(r,e.auth);n=await Gn(e);return r._openRedirect(e.auth,t,"linkViaRedirect",n)}(e,t,n)}async function Bn(e,t,n=!1){const r=Fe(e);e=An(r,t);const i=new xn(r,e,n),s=await i.execute();return s&&!n&&(delete s.user._redirectEventId,await r._persistUserIfCurrent(s.user),await r._setRedirectUser(null,t)),s}async function Gn(e){var t=Zt(`${e.uid}:::`);return e._redirectEventId=t,await e.auth._setRedirectUser(e),await e.auth._persistUserIfCurrent(e),t}class Kn{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(t){if(this.hasEventBeenHandled(t))return!1;let n=!1;return this.consumers.forEach(e=>{this.isEventForConsumer(t,e)&&(n=!0,this.sendToConsumer(t,e),this.saveEventToCache(t))}),this.hasHandledPotentialRedirect||!function(e){switch(e.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return $n(e);default:return!1}}(t)||(this.hasHandledPotentialRedirect=!0,n||(this.queuedRedirectEvent=t,n=!0)),n}sendToConsumer(e,t){var n;e.error&&!$n(e)?(n=(null===(n=e.error.code)||void 0===n?void 0:n.split("auth/")[1])||"internal-error",t.onError(z(this.auth,n))):t.onAuthEvent(e)}isEventForConsumer(e,t){var n=null===t.eventId||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&n}hasEventBeenHandled(e){return 6e5<=Date.now()-this.lastProcessedEventTime&&this.cachedEventUids.clear(),this.cachedEventUids.has(Jn(e))}saveEventToCache(e){this.cachedEventUids.add(Jn(e)),this.lastProcessedEventTime=Date.now()}}function Jn(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(e=>e).join("-")}function $n({type:e,error:t}){return"unknown"===e&&"auth/no-auth-event"===(null==t?void 0:t.code)}async function Yn(e,t={}){return se(e,"GET","/v1/projects",t)}const Xn=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,Zn=/^https?/;async function Qn(e){if(!e.config.emulator){var{authorizedDomains:t}=await Yn(e);for(const n of t)try{if(function(e){const t=Y(),{protocol:n,hostname:r}=new URL(t);if(e.startsWith("chrome-extension://")){var i=new URL(e);return""===i.hostname&&""===r?"chrome-extension:"===n&&e.replace("chrome-extension://","")===t.replace("chrome-extension://",""):"chrome-extension:"===n&&i.hostname===r}if(!Zn.test(n))return!1;if(Xn.test(e))return r===e;const s=e.replace(/\./g,"\\."),o=new RegExp("^(.+\\."+s+"|"+s+")$","i");return o.test(r)}(n))return}catch(e){}H(e,"unauthorized-domain")}}const er=new Q(3e4,6e4);function tr(){const t=en().___jsl;if(null!==t&&void 0!==t&&t.H)for(const e of Object.keys(t.H))if(t.H[e].r=t.H[e].r||[],t.H[e].L=t.H[e].L||[],t.H[e].r=[...t.H[e].L],t.CP)for(let e=0;e{function n(){tr(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{tr(),t(z(i,"network-request-failed"))},timeout:er.get()})}if(null!==(r=null===(r=en().gapi)||void 0===r?void 0:r.iframes)&&void 0!==r&&r.Iframe)e(gapi.iframes.getContext());else{if(null===(r=en().gapi)||void 0===r||!r.load){var r=mn("iframefcb");return en()[r]=()=>{gapi.load?n():t(z(i,"network-request-failed"))},fn(`https://apis.google.com/js/api.js?onload=${r}`)}n()}}).catch(e=>{throw nr=null,e})),nr}const ir=new Q(5e3,15e3),sr="__/auth/iframe",or="emulator/auth/iframe",ar={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"}},cr=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);async function ur(o){const e=await rr(o);var t=en().gapi;return B(t,o,"internal-error"),e.open({where:document.body,url:function(e){var t=e.config;B(t.authDomain,e,"auth-domain-config-required");var n=t.emulator?ee(t,or):`https://${e.config.authDomain}/${sr}`;const r={apiKey:t.apiKey,appName:e.name,v:li.SDK_VERSION};(t=cr.get(e.config.apiHost))&&(r.eid=t);const i=e._getFrameworks();return i.length&&(r.fw=i.join(",")),`${n}?${I(r).slice(1)}`}(o),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:ar,dontclear:!0},s=>new Promise(async(e,t)=>{await s.restyle({setHideOnLeave:!1});const n=z(o,"network-request-failed"),r=en().setTimeout(()=>{t(n)},ir.get());function i(){en().clearTimeout(r),e(s)}s.ping(i).then(i,()=>{t(n)})}))}const lr={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class dr{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(e){}}}function hr(e,t,n,r=500,i=600){var s=Math.max((window.screen.availHeight-i)/2,0).toString(),o=Math.max((window.screen.availWidth-r)/2,0).toString();let a="";const c=Object.assign(Object.assign({},lr),{width:r.toString(),height:i.toString(),top:s,left:o});o=d().toLowerCase();n&&(a=Ae(o)?"_blank":n),Re(o)&&(t=t||"http://localhost",c.scrollbars="yes");var u,n=Object.entries(c).reduce((e,[t,n])=>`${e}${t}=${n},`,"");if([o=d()]=[o],Le(o)&&null!==(u=window.navigator)&&void 0!==u&&u.standalone&&"_self"!==a)return function(e,t){const n=document.createElement("a");n.href=e,n.target=t;const r=document.createEvent("MouseEvent");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(r)}(t||"",a),new dr(null);const l=window.open(t||"",a,n);B(l,e,"popup-blocked");try{l.focus()}catch(e){}return new dr(l)}const pr="__/auth/handler",fr="emulator/auth/handler";function mr(e,t,n,r,i,s){B(e.config.authDomain,e,"auth-domain-config-required"),B(e.config.apiKey,e,"invalid-api-key");const o={apiKey:e.config.apiKey,appName:e.name,authType:n,redirectUrl:r,v:li.SDK_VERSION,eventId:i};if(t instanceof Qe){t.setDefaultLanguage(e.languageCode),o.providerId=t.providerId||"",function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return;return 1}(t.getCustomParameters())||(o.customParameters=JSON.stringify(t.getCustomParameters()));for(var[a,c]of Object.entries(s||{}))o[a]=c}if(t instanceof et){const l=t.getScopes().filter(e=>""!==e);0{})}_initialize(e){var t=e._key();if(this.eventManagers[t]){const{manager:r,promise:n}=this.eventManagers[t];return r?Promise.resolve(r):(K(n,"If manager is not set, promise should be"),n)}const n=this.initAndGetManager(e);return this.eventManagers[t]={promise:n},n}async initAndGetManager(t){const e=await ur(t),n=new Kn(t);return e.register("authEvent",e=>{return B(null==e?void 0:e.authEvent,t,"invalid-auth-event"),{status:n.onEvent(e.authEvent)?"ACK":"ERROR"}},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[t._key()]={manager:n},this.iframes[t._key()]=e,n}_isIframeWebStorageSupported(t,n){const e=this.iframes[t._key()];e.send(gr,{type:gr},e=>{e=null===(e=null==e?void 0:e[0])||void 0===e?void 0:e[gr];void 0!==e&&n(!!e),H(t,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){var t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=Qn(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return De()||Se()||Le()}};class yr extends class{constructor(e){this.factorId=e}_process(e,t,n){switch(t.type){case"enroll":return this._finalizeEnroll(e,t.credential,n);case"signin":return this._finalizeSignIn(e,t.credential);default:return G("unexpected MultiFactorSessionType")}}}{constructor(e){super("phone"),this.credential=e}static _fromCredential(e){return new yr(e)}_finalizeEnroll(e,t,n){return e=e,n={idToken:t,displayName:n,phoneVerificationInfo:this.credential._makeVerificationRequest()},se(e,"POST","/v2/accounts/mfaEnrollment:finalize",Object.assign({tenantId:e.tenantId},n))}_finalizeSignIn(e,t){return e=e,t={mfaPendingCredential:t,phoneVerificationInfo:this.credential._makeVerificationRequest()},se(e,"POST","/v2/accounts/mfaSignIn:finalize",Object.assign({tenantId:e.tenantId},t))}}class _r{constructor(){}static assertion(e){return yr._fromCredential(e)}}var Ir;class wr{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),(null===(e=this.auth.currentUser)||void 0===e?void 0:e.uid)||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(t){var e;this.assertAuthConfigured(),this.internalListeners.has(t)||(e=this.auth.onIdTokenChanged(e=>{t((null===e||void 0===e?void 0:e.stsTokenManager.accessToken)||null)}),this.internalListeners.set(t,e),this.updateProactiveRefresh())}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){B(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){0{e=e.getProvider("app").getImmediate();const{apiKey:r,authDomain:i}=e.options;return(e=>{B(r&&!r.includes(":"),"invalid-api-key",{appName:e.name}),B(!(null!==i&&void 0!==i&&i.includes(":")),"argument-error",{appName:e.name});var t={apiKey:r,authDomain:i,clientPlatform:Ir,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:Me(Ir)},t=new Ue(e,t);return function(e,t){const n=(null==t?void 0:t.persistence)||[];var r=(Array.isArray(n)?n:[n]).map($);null!=t&&t.errorMap&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(r,null==t?void 0:t.popupRedirectResolver)}(t,n),t})(e)},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,n)=>{const r=e.getProvider("auth-internal");r.initialize()})),li._registerComponent(new D("auth-internal",e=>{e=Fe(e.getProvider("auth").getImmediate());return e=e,new wr(e)},"PRIVATE").setInstantiationMode("EXPLICIT")),li.registerVersion("@firebase/auth","0.17.0",function(e){switch(e){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";default:return}}(Ir));async function br(e,t,n){var{BuildInfo:r}=Tr();K(t.sessionId,"AuthEvent did not contain a session ID");var i=await async function(e){const t=function(t){if(K(/[0-9a-zA-Z]+/.test(t),"Can only convert alpha-numeric strings"),"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);const e=new ArrayBuffer(t.length),n=new Uint8Array(e);for(let e=0;ee.toString(16).padStart(2,"0")).join("")}(t.sessionId);const s={};return Le()?s.ibi=r.packageName:Ne()?s.apn=r.packageName:H(e,"operation-not-supported-in-this-environment"),r.displayName&&(s.appDisplayName=r.displayName),s.sessionId=i,mr(e,n,t.type,void 0,null!==(t=t.eventId)&&void 0!==t?t:void 0,s)}function kr(r){const{cordova:i}=Tr();return new Promise(n=>{i.plugins.browsertab.isAvailable(e=>{let t=null;e?i.plugins.browsertab.openUrl(r):t=i.InAppBrowser.open(r,(e=d(),/(iPad|iPhone|iPod).*OS 7_\d/i.test(e)||/(iPad|iPhone|iPod).*OS 8_\d/i.test(e)?"_blank":"_system"),"location=yes"),n(t)})})}const Er=20;class Rr extends Kn{constructor(){super(...arguments),this.passiveListeners=new Set,this.initPromise=new Promise(e=>{this.resolveInialized=e})}addPassiveListener(e){this.passiveListeners.add(e)}removePassiveListener(e){this.passiveListeners.delete(e)}resetRedirect(){this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1}onEvent(t){return this.resolveInialized(),this.passiveListeners.forEach(e=>e(t)),super.onEvent(t)}async initialized(){await this.initPromise}}function Sr(e,t,n=null){return{type:t,eventId:n,urlResponse:null,sessionId:function(){const t=[],n="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let e=0;e{};try{await new Promise((n,e)=>{let t=null;function r(){var e;n();const t=null===(e=u.plugins.browsertab)||void 0===e?void 0:e.close;"function"==typeof t&&t(),"function"==typeof(null==c?void 0:c.close)&&c.close()}function i(){t=t||window.setTimeout(()=>{e(z(o,"redirect-cancelled-by-user"))},2e3)}function s(){"visible"===(null===document||void 0===document?void 0:document.visibilityState)&&i()}a.addPassiveListener(r),document.addEventListener("resume",i,!1),Ne()&&document.addEventListener("visibilitychange",s,!1),l=()=>{a.removePassiveListener(r),document.removeEventListener("resume",i,!1),document.removeEventListener("visibilitychange",s,!1),t&&window.clearTimeout(t)}})}finally{l()}}(e,o,t)}_isIframeWebStorageSupported(e,t){throw new Error("Method not implemented.")}_originValidation(e){var t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=async function(e){var{BuildInfo:t}=Tr();const n={};Le()?n.iosBundleId=t.packageName:Ne()?n.androidPackageName=t.packageName:H(e,"operation-not-supported-in-this-environment"),await Yn(e,n)}(e)),this.originValidationPromises[t]}attachCallbackListeners(r,i){const{universalLinks:e,handleOpenURL:t,BuildInfo:n}=Tr(),s=setTimeout(async()=>{await Ar(r),i.onEvent(Dr())},500),o=async e=>{clearTimeout(s);var t=await Ar(r);let n=null;t&&null!=e&&e.url&&(n=Or(t,e.url)),i.onEvent(n||Dr())};void 0!==e&&"function"==typeof e.subscribe&&e.subscribe(null,o);const a=t,c=`${n.packageName.toLowerCase()}://`;Tr().handleOpenURL=async e=>{if(e.toLowerCase().startsWith(c)&&o({url:e}),"function"==typeof a)try{a(e)}catch(e){console.error(e)}}}};function Dr(){return{type:"unknown",eventId:null,sessionId:null,urlResponse:null,postBody:null,tenantId:null,error:z("no-auth-event")}}var Mr;function Ur(){var e;return(null===(e=null===self||void 0===self?void 0:self.location)||void 0===e?void 0:e.protocol)||null}function Fr(e=d()){return!("file:"!==Ur()&&"ionic:"!==Ur()||!e.toLowerCase().match(/iphone|ipad|ipod|android/))}function xr(e=d()){return l()&&11===(null===document||void 0===document?void 0:document.documentMode)||([e=d()]=[e],/Edge\/\d+/.test(e))}function Vr(){try{const t=self.localStorage;var e=Zt();if(t)return t.setItem(e,"1"),t.removeItem(e),!xr()||h()}catch(e){return jr()&&h()}return!1}function jr(){return"undefined"!=typeof global&&"WorkerGlobalScope"in global&&"importScripts"in global}function Wr(){return("http:"===Ur()||"https:"===Ur()||n()||Fr())&&!(u()||c())&&Vr()&&!jr()}function Hr(){return Fr()&&"undefined"!=typeof document}const zr={LOCAL:"local",NONE:"none",SESSION:"session"},qr=B,Br="persistence";async function Gr(e){await e._initializationPromise;const t=Kr();var n=be(Br,e.config.apiKey,e.name);null!==t&&void 0!==t&&t.sessionStorage&&t.sessionStorage.setItem(n,e._getPersistence())}function Kr(){return"undefined"!=typeof window?window:null}const Jr=B;class $r{constructor(){this.browserResolver=$(vr),this.cordovaResolver=$(Lr),this.underlyingResolver=null,this._redirectPersistence=Yt,this._completeRedirectFn=Bn}async _initialize(e){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._initialize(e)}async _openPopup(e,t,n,r){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._openPopup(e,t,n,r)}async _openRedirect(e,t,n,r){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._openRedirect(e,t,n,r)}_isIframeWebStorageSupported(e,t){this.assertedUnderlyingResolver._isIframeWebStorageSupported(e,t)}_originValidation(e){return this.assertedUnderlyingResolver._originValidation(e)}get _shouldInitProactively(){return Hr()||this.browserResolver._shouldInitProactively}get assertedUnderlyingResolver(){return Jr(this.underlyingResolver,"internal-error"),this.underlyingResolver}async selectUnderlyingResolver(){var e;this.underlyingResolver||(e=await(!!Hr()&&new Promise(e=>{const t=setTimeout(()=>{e(!1)},1e3);document.addEventListener("deviceready",()=>{clearTimeout(t),e(!0)})})),this.underlyingResolver=e?this.cordovaResolver:this.browserResolver)}}function Yr(e){return e.unwrap()}function Xr(e,t){var n,r=null===(n=t.customData)||void 0===n?void 0:n._tokenResponse;if("auth/multi-factor-auth-required"===t.code){const s=t;s.resolver=new ti(e,(n=t,e=S(i=e),B((i=n).operationType,e,"argument-error"),B(null===(n=i.serverResponse)||void 0===n?void 0:n.mfaPendingCredential,e,"argument-error"),Ht._fromError(e,i)))}else if(r){var i=Zr(t);const o=t;i&&(o.credential=i,o.tenantId=r.tenantId||void 0,o.email=r.email||void 0,o.phoneNumber=r.phoneNumber||void 0)}}function Zr(e){var{_tokenResponse:t}=e instanceof m?e.customData:e;if(!t)return null;if(!(e instanceof m)&&"temporaryProof"in t&&"phoneNumber"in t)return Sn.credentialFromResult(e);const n=t.providerId;if(!n||n===U.PASSWORD)return null;let r;switch(n){case U.GOOGLE:r=rt;break;case U.FACEBOOK:r=nt;break;case U.GITHUB:r=it;break;case U.TWITTER:r=ot;break;default:var{oauthIdToken:i,oauthAccessToken:s,oauthTokenSecret:o,pendingToken:a,nonce:c}=t;return s||o||i||a?a?n.startsWith("saml.")?st._create(n,a):Je._fromParams({providerId:n,signInMethod:n,pendingToken:a,idToken:i,accessToken:s}):new tt(n).credential({idToken:i,accessToken:s,rawNonce:c}):null}return e instanceof m?r.credentialFromError(e):r.credentialFromResult(e)}async function Qr(t,e){let n;try{n=await e}catch(e){throw e instanceof m&&Xr(t,e),e}var{operationType:e,user:t}=n;return{operationType:e,credential:Zr(n),additionalUserInfo:jt(n),user:ni.getOrCreate(t)}}async function ei(t,e){const n=await e;return{verificationId:n.verificationId,confirm:e=>Qr(t,n.confirm(e))}}class ti{constructor(e,t){this.resolver=t,this.auth=e.wrapped()}get session(){return this.resolver.session}get hints(){return this.resolver.hints}resolveSignIn(e){return Qr(Yr(this.auth),this.resolver.resolveSignIn(e))}}class ni{constructor(e){this._delegate=e,this.multiFactor=(e=S(e=e),qt.has(e)||qt.set(e,zt._fromUser(e)),qt.get(e))}static getOrCreate(e){return ni.USER_MAP.has(e)||ni.USER_MAP.set(e,new ni(e)),ni.USER_MAP.get(e)}delete(){return this._delegate.delete()}reload(){return this._delegate.reload()}toJSON(){return this._delegate.toJSON()}getIdTokenResult(e){return this._delegate.getIdTokenResult(e)}getIdToken(e){return this._delegate.getIdToken(e)}linkAndRetrieveDataWithCredential(e){return this.linkWithCredential(e)}async linkWithCredential(e){return Qr(this.auth,_t(this._delegate,e))}async linkWithPhoneNumber(e,t){return ei(this.auth,async function(e,t,n){const r=S(e);return await mt(!1,r,"phone"),n=await Rn(r.auth,t,S(n)),new En(n,e=>_t(r,e))}(this._delegate,e,t))}async linkWithPopup(e){return Qr(this.auth,async function(e,t,n){e=S(e),B(t instanceof Qe,e.auth,"argument-error"),n=An(e.auth,n);const r=new Mn(e.auth,"linkViaPopup",t,n,e);return r.executeNotNull()}(this._delegate,e,$r))}async linkWithRedirect(e){return await Gr(Fe(this.auth)),qn(this._delegate,e,$r)}reauthenticateAndRetrieveDataWithCredential(e){return this.reauthenticateWithCredential(e)}async reauthenticateWithCredential(e){return Qr(this.auth,It(this._delegate,e))}reauthenticateWithPhoneNumber(e,t){return ei(this.auth,async function(e,t,n){const r=S(e);return n=await Rn(r.auth,t,S(n)),new En(n,e=>It(r,e))}(this._delegate,e,t))}reauthenticateWithPopup(e){return Qr(this.auth,async function(e,t,n){e=S(e),B(t instanceof Qe,e.auth,"argument-error"),n=An(e.auth,n);const r=new Mn(e.auth,"reauthViaPopup",t,n,e);return r.executeNotNull()}(this._delegate,e,$r))}async reauthenticateWithRedirect(e){return await Gr(Fe(this.auth)),zn(this._delegate,e,$r)}sendEmailVerification(e){return Nt(this._delegate,e)}async unlink(e){return await pt(this._delegate,e),this}updateEmail(e){return Lt(S(this._delegate),e,null)}updatePassword(e){return Lt(S(this._delegate),null,e)}updatePhoneNumber(e){return async function(e,t){await ft(S(e),t)}(this._delegate,e)}updateProfile(e){return Ct(this._delegate,e)}verifyBeforeUpdateEmail(e,t){return Pt(this._delegate,e,t)}get emailVerified(){return this._delegate.emailVerified}get isAnonymous(){return this._delegate.isAnonymous}get metadata(){return this._delegate.metadata}get phoneNumber(){return this._delegate.phoneNumber}get providerData(){return this._delegate.providerData}get refreshToken(){return this._delegate.refreshToken}get tenantId(){return this._delegate.tenantId}get displayName(){return this._delegate.displayName}get email(){return this._delegate.email}get photoURL(){return this._delegate.photoURL}get providerId(){return this._delegate.providerId}get uid(){return this._delegate.uid}get auth(){return this._delegate.auth}}ni.USER_MAP=new WeakMap;const ri=B;class ii{constructor(e,t){if(this.app=e,t.isInitialized())return this._delegate=t.getImmediate(),void this.linkUnderlyingAuth();var{apiKey:n}=e.options;ri(n,"invalid-api-key",{appName:e.name});let r=[Te];if("undefined"!=typeof window){r=function(e,t){const n=Kr();if(null===n||void 0===n||!n.sessionStorage)return[];switch(t=be(Br,e,t),n.sessionStorage.getItem(t)){case zr.NONE:return[Te];case zr.LOCAL:return[pn,Yt];case zr.SESSION:return[Yt];default:return[]}}(n,e.name);for(const i of[pn,Jt,Yt])r.includes(i)||r.push(i)}ri(n,"invalid-api-key",{appName:e.name});e="undefined"!=typeof window?$r:void 0;this._delegate=t.initialize({options:{persistence:r,popupRedirectResolver:e}}),this._delegate._updateErrorMap(x),this.linkUnderlyingAuth()}get emulatorConfig(){return this._delegate.emulatorConfig}get currentUser(){return this._delegate.currentUser?ni.getOrCreate(this._delegate.currentUser):null}get languageCode(){return this._delegate.languageCode}set languageCode(e){this._delegate.languageCode=e}get settings(){return this._delegate.settings}get tenantId(){return this._delegate.tenantId}set tenantId(e){this._delegate.tenantId=e}useDeviceLanguage(){this._delegate.useDeviceLanguage()}signOut(){return this._delegate.signOut()}useEmulator(e,t){Ve(this._delegate,e,t)}applyActionCode(e){return Rt(this._delegate,e)}checkActionCode(e){return St(this._delegate,e)}confirmPasswordReset(e,t){return async function(e,t,n){await ze(S(e),{oobCode:t,newPassword:n})}(this._delegate,e,t)}async createUserWithEmailAndPassword(e,t){return Qr(this._delegate,async function(e,t,n){const r=Fe(e);return n=await at(r,{returnSecureToken:!0,email:t,password:n}),n=await ct._fromIdTokenResponse(r,"signIn",n),await r._updateCurrentUser(n.user),n}(this._delegate,e,t))}fetchProvidersForEmail(e){return this.fetchSignInMethodsForEmail(e)}fetchSignInMethodsForEmail(e){return Ot(this._delegate,e)}isSignInWithEmailLink(e){return this._delegate,e=e,"EMAIL_SIGNIN"===(null==(e=Xe.parseLink(e))?void 0:e.operation)}async getRedirectResult(){ri(Wr(),this._delegate,"operation-not-supported-in-this-environment");var e,t,t=(e=this._delegate,t=$r,await Fe(e)._initializationPromise,await Bn(e,t,!1));return t?Qr(this._delegate,Promise.resolve(t)):{credential:null,user:null}}addFrameworkForLogging(e){Fe(this._delegate)._logFramework(e)}onAuthStateChanged(e,t,n){var{next:e,error:t,complete:n}=si(e,t,n);return this._delegate.onAuthStateChanged(e,t,n)}onIdTokenChanged(e,t,n){var{next:e,error:t,complete:n}=si(e,t,n);return this._delegate.onIdTokenChanged(e,t,n)}sendSignInLinkToEmail(e,t){return At(this._delegate,e,t)}sendPasswordResetEmail(e,t){return Et(this._delegate,e,t||void 0)}async setPersistence(e){var t,n;t=this._delegate,n=e,qr(Object.values(zr).includes(n),t,"invalid-persistence-type"),u()?qr(n!==zr.SESSION,t,"unsupported-persistence-type"):c()?qr(n===zr.NONE,t,"unsupported-persistence-type"):jr()?qr(n===zr.NONE||n===zr.LOCAL&&h(),t,"unsupported-persistence-type"):qr(n===zr.NONE||Vr(),t,"unsupported-persistence-type");let r;switch(e){case zr.SESSION:r=Yt;break;case zr.LOCAL:var i=await $(pn)._isAvailable();r=i?pn:Jt;break;case zr.NONE:r=Te;break;default:return H("argument-error",{appName:this._delegate.name})}return this._delegate.setPersistence(r)}signInAndRetrieveDataWithCredential(e){return this.signInWithCredential(e)}signInAnonymously(){return Qr(this._delegate,async function(e){const t=Fe(e);return await t._initializationPromise,null!==(e=t.currentUser)&&void 0!==e&&e.isAnonymous?new ct({user:t.currentUser,providerId:null,operationType:"signIn"}):(e=await at(t,{returnSecureToken:!0}),e=await ct._fromIdTokenResponse(t,"signIn",e,!0),await t._updateCurrentUser(e.user),e)}(this._delegate))}signInWithCredential(e){return Qr(this._delegate,yt(this._delegate,e))}signInWithCustomToken(e){return Qr(this._delegate,wt(this._delegate,e))}signInWithEmailAndPassword(e,t){return Qr(this._delegate,(n=this._delegate,e=e,t=t,yt(S(n),Ze.credential(e,t))));var n}signInWithEmailLink(e,t){return Qr(this._delegate,async function(e,t,n){return e=S(e),B((n=Ze.credentialWithLink(t,n||Y()))._tenantId===(e.tenantId||null),e,"tenant-id-mismatch"),yt(e,n)}(this._delegate,e,t))}signInWithPhoneNumber(e,t){return ei(this._delegate,async function(e,t,n){const r=Fe(e);return n=await Rn(r,t,S(n)),new En(n,e=>yt(r,e))}(this._delegate,e,t))}async signInWithPopup(e){return ri(Wr(),this._delegate,"operation-not-supported-in-this-environment"),Qr(this._delegate,async function(e,t,n){var r=Fe(e);B(t instanceof Qe,e,"argument-error"),n=An(r,n);const i=new Mn(r,"signInViaPopup",t,n);return i.executeNotNull()}(this._delegate,e,$r))}async signInWithRedirect(e){return ri(Wr(),this._delegate,"operation-not-supported-in-this-environment"),await Gr(this._delegate),Hn(this._delegate,e,$r)}updateCurrentUser(e){return this._delegate.updateCurrentUser(e)}verifyPasswordResetCode(e){return async function(e,t){var{data:t}=await St(S(e),t);return t.email}(this._delegate,e)}unwrap(){return this._delegate}_delete(){return this._delegate._delete()}linkUnderlyingAuth(){this._delegate.wrapped=()=>this}}function si(e,t,n){let r=e;"function"!=typeof e&&({next:r,error:t,complete:n}=e);const i=r;return{next:e=>i(e&&ni.getOrCreate(e)),error:t,complete:n}}ii.Persistence=zr;class oi{constructor(){this.providerId="phone",this._delegate=new Sn(Yr(i.default.auth()))}static credential(e,t){return Sn.credential(e,t)}verifyPhoneNumber(e,t){return this._delegate.verifyPhoneNumber(e,t)}unwrap(){return this._delegate}}oi.PHONE_SIGN_IN_METHOD=Sn.PHONE_SIGN_IN_METHOD,oi.PROVIDER_ID=Sn.PROVIDER_ID;const ai=B;class ci{constructor(e,t,n=i.default.app()){var r;ai(null===(r=n.options)||void 0===r?void 0:r.apiKey,"invalid-api-key",{appName:n.name}),this._delegate=new kn(e,t,n.auth()),this.type=this._delegate.type}clear(){this._delegate.clear()}render(){return this._delegate.render()}verify(){return this._delegate.verify()}}(Mr=i.default).INTERNAL.registerComponent(new D("auth-compat",e=>{var t=e.getProvider("app-compat").getImmediate(),e=e.getProvider("auth");return new ii(t,e)},"PUBLIC").setServiceProps({ActionCodeInfo:{Operation:{EMAIL_SIGNIN:F.EMAIL_SIGNIN,PASSWORD_RESET:F.PASSWORD_RESET,RECOVER_EMAIL:F.RECOVER_EMAIL,REVERT_SECOND_FACTOR_ADDITION:F.REVERT_SECOND_FACTOR_ADDITION,VERIFY_AND_CHANGE_EMAIL:F.VERIFY_AND_CHANGE_EMAIL,VERIFY_EMAIL:F.VERIFY_EMAIL}},EmailAuthProvider:Ze,FacebookAuthProvider:nt,GithubAuthProvider:it,GoogleAuthProvider:rt,OAuthProvider:tt,PhoneAuthProvider:oi,PhoneMultiFactorGenerator:_r,RecaptchaVerifier:ci,TwitterAuthProvider:ot,Auth:ii,AuthCredential:He,Error:m}).setInstantiationMode("LAZY").setMultipleInstances(!1)),Mr.registerVersion("@firebase/auth-compat","0.1.0")}.apply(this,arguments)}catch(e){throw console.error(e),new Error("Cannot instantiate firebase-auth-compat.js - be sure to load firebase-app.js first.")}}); //# sourceMappingURL=firebase-auth-compat.js.map