@firebase/auth-compat 0.5.19 → 0.5.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- ((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(Hn,Wn){try{!function(){function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var F=t(Hn);let V=()=>{},x={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray(i,e){if(!Array.isArray(i))throw Error("encodeByteArray takes an array as a parameter");this.init_();var n=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,s=[];for(let r=0;r<i.length;r+=3){var a=i[r],o=r+1<i.length,l=o?i[r+1]:0,c=r+2<i.length,d=c?i[r+2]:0;let e=(15&l)<<2|d>>6,t=63&d;c||(t=64,o)||(e=64),s.push(n[a>>2],n[(3&a)<<4|l>>4],n[e],n[t])}return s.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray((r=>{var i=[];let n=0;for(let t=0;t<r.length;t++){let e=r.charCodeAt(t);e<128?i[n++]=e:(e<2048?i[n++]=e>>6|192:(55296==(64512&e)&&t+1<r.length&&56320==(64512&r.charCodeAt(t+1))?(e=65536+((1023&e)<<10)+(1023&r.charCodeAt(++t)),i[n++]=e>>18|240,i[n++]=e>>12&63|128):i[n++]=e>>12|224,i[n++]=e>>6&63|128),i[n++]=63&e|128)}return i})(e),t)},decodeString(r,i){if(this.HAS_NATIVE_SUPPORT&&!i)return atob(r);{var n=this.decodeStringToByteArray(r,i);var s=[];let e=0,t=0;for(;e<n.length;){var a,o,l,c=n[e++];c<128?s[t++]=String.fromCharCode(c):191<c&&c<224?(a=n[e++],s[t++]=String.fromCharCode((31&c)<<6|63&a)):239<c&&c<365?(a=((7&c)<<18|(63&n[e++])<<12|(63&n[e++])<<6|63&n[e++])-65536,s[t++]=String.fromCharCode(55296+(a>>10)),s[t++]=String.fromCharCode(56320+(1023&a))):(o=n[e++],l=n[e++],s[t++]=String.fromCharCode((15&c)<<12|(63&o)<<6|63&l))}return s.join("");return}},decodeStringToByteArray(t,e){this.init_();var r=e?this.charToByteMapWebSafe_:this.charToByteMap_,i=[];for(let e=0;e<t.length;){var n=r[t.charAt(e++)],s=e<t.length?r[t.charAt(e)]:0,a=++e<t.length?r[t.charAt(e)]:64,o=++e<t.length?r[t.charAt(e)]:64;if(++e,null==n||null==s||null==a||null==o)throw new j;i.push(n<<2|s>>4),64!==a&&(i.push(s<<4&240|a>>2),64!==o)&&i.push(a<<6&192|o)}return i},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),(this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e)>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class j extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}let H=function(e){try{return x.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};let W=()=>(()=>{if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("Unable to locate global object.")})().__FIREBASE_DEFAULTS__,q=()=>{var e;return"undefined"!=typeof process&&void 0!==process.env&&(e=process.env.__FIREBASE_DEFAULTS__)?JSON.parse(e):void 0},B=()=>{if("undefined"!=typeof document){let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}var t=e&&H(e[1]);return t&&JSON.parse(t)}},z=()=>{try{return V()||W()||q()||B()}catch(e){console.info("Unable to get __FIREBASE_DEFAULTS__ due to: "+e)}};var i;function l(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function G(){var e=null==(e=z())?void 0:e.forceEnvironment;if("node"===e)return!0;if("browser"===e)return!1;try{return"[object process]"===Object.prototype.toString.call(global.process)}catch(e){return!1}}function K(){var e="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof e&&void 0!==e.id}function J(){return"object"==typeof navigator&&"ReactNative"===navigator.product}function Y(){var e=l();return 0<=e.indexOf("MSIE ")||0<=e.indexOf("Trident/")}function $(){try{return"object"==typeof indexedDB}catch(e){return!1}}class c extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name="FirebaseError",Object.setPrototypeOf(this,c.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,X.prototype.create)}}class X{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){var i,t=t[0]||{},r=this.service+"/"+e,e=this.errors[e],e=e?(i=t,e.replace(Q,(e,t)=>{var r=i[t];return null!=r?String(r):`<${t}?>`})):"Error",e=this.serviceName+`: ${e} (${r}).`;return new c(r,e,t)}}let Q=/\{\$([^}]+)}/g;function Z(e,t){if(e!==t){var r,i,n=Object.keys(e),s=Object.keys(t);for(r of n){if(!s.includes(r))return!1;var a=e[r],o=t[r];if(ee(a)&&ee(o)){if(!Z(a,o))return!1}else if(a!==o)return!1}for(i of s)if(!n.includes(i))return!1}return!0}function ee(e){return null!==e&&"object"==typeof e}function te(r){let i=[];for(let[t,e]of Object.entries(r))Array.isArray(e)?e.forEach(e=>{i.push(encodeURIComponent(t)+"="+encodeURIComponent(e))}):i.push(encodeURIComponent(t)+"="+encodeURIComponent(e));return i.length?"&"+i.join("&"):""}function re(e){let r={};return e.replace(/^\?/,"").split("&").forEach(e=>{var t;e&&([e,t]=e.split("="),r[decodeURIComponent(e)]=decodeURIComponent(t))}),r}function ie(e){var t,r=e.indexOf("?");return r?(t=e.indexOf("#",r),e.substring(r,0<t?t:void 0)):""}class ne{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(t){this.forEachObserver(e=>{e.next(t)})}error(t){this.forEachObserver(e=>{e.error(t)}),this.close(t)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let i;if(void 0===e&&void 0===t&&void 0===r)throw new Error("Missing Observer.");void 0===(i=((e,t)=>{if("object"==typeof e&&null!==e)for(var r of t)if(r in e&&"function"==typeof e[r])return 1})(e,["next","error","complete"])?e:{next:e,error:t,complete:r}).next&&(i.next=se),void 0===i.error&&(i.error=se),void 0===i.complete&&(i.complete=se);e=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?i.error(this.finalError):i.complete()}catch(e){}}),this.observers.push(i),e}unsubscribeOne(e){void 0!==this.observers&&void 0!==this.observers[e]&&(delete this.observers[e],--this.observerCount,0===this.observerCount)&&void 0!==this.onNoObservers&&this.onNoObservers(this)}forEachObserver(t){if(!this.finalized)for(let e=0;e<this.observers.length;e++)this.sendOne(e,t)}sendOne(e,t){this.task.then(()=>{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 se(){}function s(e){return e&&e._delegate?e._delegate:e}(e=i=i||{})[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";let ae={debug:i.DEBUG,verbose:i.VERBOSE,info:i.INFO,warn:i.WARN,error:i.ERROR,silent:i.SILENT},oe=i.INFO,le={[i.DEBUG]:"log",[i.VERBOSE]:"log",[i.INFO]:"info",[i.WARN]:"warn",[i.ERROR]:"error"},ce=(e,t,...r)=>{if(!(t<e.logLevel)){var i=(new Date).toISOString(),n=le[t];if(!n)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[n](`[${i}] ${e.name}:`,...r)}};function de(e,t){var r={};for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r}class ue{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}}let he={FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PASSWORD:"password",PHONE:"phone",TWITTER:"twitter.com"},pe={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"};function me(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}function ge(){return{"admin-restricted-operation":"This operation is restricted to administrators only.","argument-error":"","app-not-authorized":"This app, identified by the domain where it's hosted, is not authorized to use Firebase Authentication with the provided API key. Review your key configuration in the Google API console.","app-not-installed":"The requested mobile application corresponding to the identifier (Android package name or iOS bundle ID) provided is not installed on this device.","captcha-check-failed":"The reCAPTCHA response token provided is either invalid, expired, already used or the domain associated with it does not match the list of whitelisted domains.","code-expired":"The SMS code has expired. Please re-send the verification code to try again.","cordova-not-ready":"Cordova framework is not ready.","cors-unsupported":"This browser is not supported.","credential-already-in-use":"This credential is already associated with a different user account.","custom-token-mismatch":"The custom token corresponds to a different audience.","requires-recent-login":"This operation is sensitive and requires recent authentication. Log in again before retrying this request.","dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK.","dynamic-link-not-activated":"Please activate Dynamic Links in the Firebase Console and agree to the terms and conditions.","email-change-needs-verification":"Multi-factor users must always have a verified email.","email-already-in-use":"The email address is already in use by another account.","emulator-config-failed":'Auth instance has already been used to make a network call. Auth can no longer be configured to use the emulator. Try calling "connectAuthEmulator()" sooner.',"expired-action-code":"The action code has expired.","cancelled-popup-request":"This operation has been cancelled due to another conflicting popup being opened.","internal-error":"An internal AuthError has occurred.","invalid-app-credential":"The phone verification request contains an invalid application verifier. The reCAPTCHA token response is either invalid or expired.","invalid-app-id":"The mobile app identifier is not registered for the current project.","invalid-user-token":"This user's credential isn't valid for this project. This can happen if the user's token has been tampered with, or if the user isn't for the project associated with this API key.","invalid-auth-event":"An internal AuthError has occurred.","invalid-verification-code":"The SMS verification code used to create the phone auth credential is invalid. Please resend the verification code sms and be sure to use the verification code provided by the user.","invalid-continue-uri":"The continue URL provided in the request is invalid.","invalid-cordova-configuration":"The following Cordova plugins must be installed to enable OAuth sign-in: cordova-plugin-buildinfo, cordova-universal-links-plugin, cordova-plugin-browsertab, cordova-plugin-inappbrowser and cordova-plugin-customurlscheme.","invalid-custom-token":"The custom token format is incorrect. Please check the documentation.","invalid-dynamic-link-domain":"The provided dynamic link domain is not configured or authorized for the current project.","invalid-email":"The email address is badly formatted.","invalid-emulator-scheme":"Emulator URL must start with a valid scheme (http:// or https://).","invalid-api-key":"Your API key is invalid, please check you have copied it correctly.","invalid-cert-hash":"The SHA-1 certificate hash provided is invalid.","invalid-credential":"The supplied auth credential is incorrect, malformed or has expired.","invalid-message-payload":"The email template corresponding to this action contains invalid characters in its message. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-multi-factor-session":"The request does not contain a valid proof of first factor successful sign-in.","invalid-oauth-provider":"EmailAuthProvider is not supported for this operation. This operation only supports OAuth providers.","invalid-oauth-client-id":"The OAuth client ID provided is either invalid or does not match the specified API key.","unauthorized-domain":"This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.","invalid-action-code":"The action code is invalid. This can happen if the code is malformed, expired, or has already been used.","wrong-password":"The password is invalid or the user does not have a password.","invalid-persistence-type":"The specified persistence type is invalid. It can only be local, session or none.","invalid-phone-number":"The format of the phone number provided is incorrect. Please enter the phone number in a format that can be parsed into E.164 format. E.164 phone numbers are written in the format [+][country code][subscriber number including area code].","invalid-provider-id":"The specified provider ID is invalid.","invalid-recipient-email":"The email corresponding to this action failed to send as the provided recipient email address is invalid.","invalid-sender":"The email template corresponding to this action contains an invalid sender email or name. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-verification-id":"The verification ID used to create the phone auth credential is invalid.","invalid-tenant-id":"The Auth instance's tenant ID is invalid.","login-blocked":"Login blocked by user-provided method: {$originalMessage}","missing-android-pkg-name":"An Android Package Name must be provided if the Android App is required to be installed.","auth-domain-config-required":"Be sure to include authDomain when calling firebase.initializeApp(), by following the instructions in the Firebase console.","missing-app-credential":"The phone verification request is missing an application verifier assertion. A reCAPTCHA response token needs to be provided.","missing-verification-code":"The phone auth credential was created with an empty SMS verification code.","missing-continue-uri":"A continue URL must be provided in the request.","missing-iframe-start":"An internal AuthError has occurred.","missing-ios-bundle-id":"An iOS Bundle ID must be provided if an App Store ID is provided.","missing-or-invalid-nonce":"The request does not contain a valid nonce. This can occur if the SHA-256 hash of the provided raw nonce does not match the hashed nonce in the ID token payload.","missing-password":"A non-empty password must be provided","missing-multi-factor-info":"No second factor identifier is provided.","missing-multi-factor-session":"The request is missing proof of first factor successful sign-in.","missing-phone-number":"To send verification codes, provide a phone number for the recipient.","missing-verification-id":"The phone auth credential was created with an empty verification ID.","app-deleted":"This instance of FirebaseApp has been deleted.","multi-factor-info-not-found":"The user does not have a second factor matching the identifier provided.","multi-factor-auth-required":"Proof of ownership of a second factor is required to complete sign-in.","account-exists-with-different-credential":"An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.","network-request-failed":"A network AuthError (such as timeout, interrupted connection or unreachable host) has occurred.","no-auth-event":"An internal AuthError has occurred.","no-such-provider":"User was not linked to an account with the given provider.","null-user":"A null user object was provided as the argument for an operation which requires a non-null user object.","operation-not-allowed":"The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section.","operation-not-supported-in-this-environment":'This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.',"popup-blocked":"Unable to establish a connection with the popup. It may have been blocked by the browser.","popup-closed-by-user":"The popup has been closed by the user before finalizing the operation.","provider-already-linked":"User can only be linked to one identity for the given provider.","quota-exceeded":"The project's quota for this operation has been exceeded.","redirect-cancelled-by-user":"The redirect operation has been cancelled by the user before finalizing.","redirect-operation-pending":"A redirect sign-in operation is already pending.","rejected-credential":"The request contains malformed or mismatching credentials.","second-factor-already-in-use":"The second factor is already enrolled on this account.","maximum-second-factor-count-exceeded":"The maximum allowed number of second factors on a user has been exceeded.","tenant-id-mismatch":"The provided tenant ID does not match the Auth instance's tenant ID",timeout:"The operation has timed out.","user-token-expired":"The user's credential is no longer valid. The user must sign in again.","too-many-requests":"We have blocked all requests from this device due to unusual activity. Try again later.","unauthorized-continue-uri":"The domain of the continue URL is not whitelisted. Please whitelist the domain in the Firebase console.","unsupported-first-factor":"Enrolling a second factor or signing in with a multi-factor account requires sign-in with a supported first factor.","unsupported-persistence-type":"The current environment does not support the specified persistence type.","unsupported-tenant-operation":"This operation is not supported in a multi-tenant context.","unverified-email":"The operation requires a verified email.","user-cancelled":"The user did not grant your application the permissions it requested.","user-not-found":"There is no user record corresponding to this identifier. The user may have been deleted.","user-disabled":"The user account has been disabled by an administrator.","user-mismatch":"The supplied credentials do not correspond to the previously signed in user.","user-signed-out":"","weak-password":"The password must be 6 characters long or more.","web-storage-unsupported":"This browser is not supported or 3rd party cookies and data may be disabled.","already-initialized":"initializeAuth() has already been called with different options. To avoid this error, call initializeAuth() with the same options as when it was originally called, or call getAuth() to return the already initialized instance.","missing-recaptcha-token":"The reCAPTCHA token is missing when sending request to the backend.","invalid-recaptcha-token":"The reCAPTCHA token is invalid when sending request to the backend.","invalid-recaptcha-action":"The reCAPTCHA action is invalid when sending request to the backend.","recaptcha-not-enabled":"reCAPTCHA Enterprise integration is not enabled for this project.","missing-client-type":"The reCAPTCHA client type is missing when sending request to the backend.","missing-recaptcha-version":"The reCAPTCHA version is missing when sending request to the backend.","invalid-req-type":"Invalid request parameters.","invalid-recaptcha-version":"The reCAPTCHA version is invalid when sending request to the backend.","unsupported-password-policy-schema-version":"The password policy received from the backend uses a schema version that is not supported by this version of the Firebase SDK.","password-does-not-meet-requirements":"The password does not meet the requirements.","invalid-hosting-link-domain":"The provided Hosting link domain is not configured in Firebase Hosting or is not owned by the current project. This cannot be a default Hosting domain (`web.app` or `firebaseapp.com`)."}}let fe=me,ve=new X("auth","Firebase",me()),_e=new class{constructor(e){this.name=e,this._logLevel=oe,this._logHandler=ce,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in i))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?ae[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,i.DEBUG,...e),this._logHandler(this,i.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,i.VERBOSE,...e),this._logHandler(this,i.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,i.INFO,...e),this._logHandler(this,i.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,i.WARN,...e),this._logHandler(this,i.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,i.ERROR,...e),this._logHandler(this,i.ERROR,...e)}}("@firebase/auth");function ye(e,...t){_e.logLevel<=i.ERROR&&_e.error(`Auth (${Wn.SDK_VERSION}): `+e,...t)}function d(e,...t){throw Te(e,...t)}function u(e,...t){return Te(e,...t)}function Ie(e,t,r){r=Object.assign(Object.assign({},fe()),{[t]:r});return new X("auth","Firebase",r).create(t,{appName:e.name})}function h(e){return Ie(e,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function we(e,t,r){if(!(t instanceof r))throw r.name!==t.constructor.name&&d(e,"argument-error"),Ie(e,"argument-error",`Type of ${t.constructor.name} does not match expected instance.`+"Did you pass a reference from a different Auth SDK?")}function Te(e,...t){var r,i;return"string"!=typeof e?(r=t[0],(i=[...t.slice(1)])[0]&&(i[0].appName=e.name),e._errorFactory.create(r,...i)):ve.create(e,...t)}function m(e,t,...r){if(!e)throw Te(t,...r)}function n(e){e="INTERNAL ASSERTION FAILED: "+e;throw ye(e),new Error(e)}function a(e,t){e||n(t)}function Ee(){var e;return"undefined"!=typeof self&&(null==(e=self.location)?void 0:e.href)||""}function be(){return"http:"===ke()||"https:"===ke()}function ke(){var e;return"undefined"!=typeof self&&(null==(e=self.location)?void 0:e.protocol)||null}class Se{constructor(e,t){a((this.shortDelay=e)<(this.longDelay=t),"Short delay should be less than long delay!"),this.isMobile="undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(l())||J()}get(){return"undefined"!=typeof navigator&&navigator&&"onLine"in navigator&&"boolean"==typeof navigator.onLine&&(be()||K()||"connection"in navigator)&&!navigator.onLine?Math.min(5e3,this.shortDelay):this.isMobile?this.longDelay:this.shortDelay}}function Re(e,t){a(e.emulator,"Emulator should always be set here");e=e.emulator.url;return t?""+e+(t.startsWith("/")?t.slice(1):t):e}class Ae{static initialize(e,t,r){this.fetchImpl=e,t&&(this.headersImpl=t),r&&(this.responseImpl=r)}static fetch(){return this.fetchImpl||("undefined"!=typeof self&&"fetch"in self?self.fetch:"undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch:"undefined"!=typeof fetch?fetch:void n("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill"))}static headers(){return this.headersImpl||("undefined"!=typeof self&&"Headers"in self?self.Headers:"undefined"!=typeof globalThis&&globalThis.Headers?globalThis.Headers:"undefined"!=typeof Headers?Headers:void n("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill"))}static response(){return this.responseImpl||("undefined"!=typeof self&&"Response"in self?self.Response:"undefined"!=typeof globalThis&&globalThis.Response?globalThis.Response:"undefined"!=typeof Response?Response:void n("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill"))}}let Pe={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"},Ce=new Se(3e4,6e4);function o(e,t){return e.tenantId&&!t.tenantId?Object.assign(Object.assign({},t),{tenantId:e.tenantId}):t}async function p(n,s,a,o,e={}){return Oe(n,e,async()=>{let e={},t={};o&&("GET"===s?t=o:e={body:JSON.stringify(o)});var r=te(Object.assign({key:n.config.apiKey},t)).slice(1),i=await n._getAdditionalHeaders(),i=(i["Content-Type"]="application/json",n.languageCode&&(i["X-Firebase-Locale"]=n.languageCode),Object.assign({method:s,headers:i},e));return"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||(i.referrerPolicy="no-referrer"),Ae.fetch()(Ne(n,n.config.apiHost,a,r),i)})}async function Oe(t,e,r){t._canInitEmulator=!1;e=Object.assign(Object.assign({},Pe),e);try{var i=new Le(t),n=await Promise.race([r(),i.promise]),s=(i.clearNetworkTimeout(),await n.json());if("needConfirmation"in s)throw De(t,"account-exists-with-different-credential",s);if(n.ok&&!("errorMessage"in s))return s;var[a,o]=(n.ok?s.errorMessage:s.error.message).split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===a)throw De(t,"credential-already-in-use",s);if("EMAIL_EXISTS"===a)throw De(t,"email-already-in-use",s);if("USER_DISABLED"===a)throw De(t,"user-disabled",s);var l=e[a]||a.toLowerCase().replace(/[_\s]+/g,"-");if(o)throw Ie(t,l,o);d(t,l)}catch(e){if(e instanceof c)throw e;d(t,"network-request-failed",{message:String(e)})}}async function r(e,t,r,i,n={}){t=await p(e,t,r,i,n);return"mfaPendingCredential"in t&&d(e,"multi-factor-auth-required",{_serverResponse:t}),t}function Ne(e,t,r,i){t=""+t+r+"?"+i;return e.config.emulator?Re(e.config,t):e.config.apiScheme+"://"+t}class Le{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((e,t)=>{this.timer=setTimeout(()=>t(u(this.auth,"network-request-failed")),Ce.get())})}}function De(e,t,r){var i={appName:e.name},e=(r.email&&(i.email=r.email),r.phoneNumber&&(i.phoneNumber=r.phoneNumber),u(e,t,i));return e.customData._tokenResponse=r,e}function Ue(e){return void 0!==e&&void 0!==e.getResponse}function Me(e){return void 0!==e&&void 0!==e.enterprise}class Fe{constructor(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}getProviderEnforcementState(t){if(this.recaptchaEnforcementState&&0!==this.recaptchaEnforcementState.length)for(let e of this.recaptchaEnforcementState)if(e.provider&&e.provider===t){switch(e.enforcementState){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}return}return null}isProviderEnabled(e){return"ENFORCE"===this.getProviderEnforcementState(e)||"AUDIT"===this.getProviderEnforcementState(e)}isAnyProviderEnabled(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}async function Ve(e,t){return p(e,"GET","/v2/recaptchaConfig",o(e,t))}async function xe(e,t){return p(e,"POST","/v1/accounts:lookup",t)}function je(e){if(e)try{var t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch(e){}}function He(e){return 1e3*Number(e)}function We(e){var[e,t,r]=e.split(".");if(void 0===e||void 0===t||void 0===r)return ye("JWT malformed, contained fewer than 3 sections"),null;try{var i=H(t);return i?JSON.parse(i):(ye("Failed to decode base64 JWT payload"),null)}catch(e){return ye("Caught error parsing JWT payload as JSON",null==e?void 0:e.toString()),null}}function qe(e){e=We(e);return m(e,"internal-error"),m(void 0!==e.exp,"internal-error"),m(void 0!==e.iat,"internal-error"),Number(e.exp)-Number(e.iat)}async function g(t,e,r=!1){if(r)return e;try{return await e}catch(e){throw e instanceof c&&(r=[e.code][0],"auth/user-disabled"===r||"auth/user-token-expired"===r)&&(t.auth.currentUser===t&&await t.auth.signOut()),e}}class Be{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){return e?(e=this.errorBackoff,this.errorBackoff=Math.min(2*this.errorBackoff,96e4),e):(this.errorBackoff=3e4,e=(null!=(e=this.user.stsTokenManager.expirationTime)?e:0)-Date.now()-3e5,Math.max(0,e))}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"===(null==e?void 0:e.code)&&this.schedule(!0))}this.schedule()}}class ze{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=je(this.lastLoginAt),this.creationTime=je(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function Ge(e){var t=e.auth,r=await e.getIdToken(),r=await g(e,xe(t,{idToken:r})),t=(m(null==r?void 0:r.users.length,t,"internal-error"),r.users[0]),r=(e._notifyReloadListener(t),null!=(r=t.providerUserInfo)&&r.length?Ke(t.providerUserInfo):[]),r=((e,r)=>[...e=e.filter(t=>!r.some(e=>e.providerId===t.providerId)),...r])(e.providerData,r),i=!(e.email&&t.passwordHash||null!=r&&r.length),i=!!e.isAnonymous&&i,r={uid:t.localId,displayName:t.displayName||null,photoURL:t.photoUrl||null,email:t.email||null,emailVerified:t.emailVerified||!1,phoneNumber:t.phoneNumber||null,tenantId:t.tenantId||null,providerData:r,metadata:new ze(t.createdAt,t.lastLoginAt),isAnonymous:i};Object.assign(e,r)}function Ke(e){return e.map(e=>{var t=e.providerId,e=de(e,["providerId"]);return{providerId:t,uid:e.rawId||"",displayName:e.displayName||null,email:e.email||null,phoneNumber:e.phoneNumber||null,photoURL:e.photoUrl||null}})}class Je{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){m(e.idToken,"internal-error"),m(void 0!==e.idToken,"internal-error"),m(void 0!==e.refreshToken,"internal-error");var t="expiresIn"in e&&void 0!==e.expiresIn?Number(e.expiresIn):qe(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){m(0!==e.length,"internal-error");var t=qe(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return t||!this.accessToken||this.isExpired?(m(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null):this.accessToken}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){n=t;var i,n,{accessToken:e,refreshToken:t,expiresIn:r}=await{accessToken:(t=await Oe(i=e,{},async()=>{var e=te({grant_type:"refresh_token",refresh_token:n}).slice(1),{tokenApiHost:t,apiKey:r}=i.config,t=Ne(i,t,"/v1/token","key="+r),r=await i._getAdditionalHeaders();return r["Content-Type"]="application/x-www-form-urlencoded",Ae.fetch()(t,{method:"POST",headers:r,body:e})})).access_token,expiresIn:t.expires_in,refreshToken:t.refresh_token};this.updateTokensAndExpiration(e,t,Number(r))}updateTokensAndExpiration(e,t,r){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+1e3*r}static fromJSON(e,t){var{refreshToken:t,accessToken:r,expirationTime:i}=t,n=new Je;return t&&(m("string"==typeof t,"internal-error",{appName:e}),n.refreshToken=t),r&&(m("string"==typeof r,"internal-error",{appName:e}),n.accessToken=r),i&&(m("number"==typeof i,"internal-error",{appName:e}),n.expirationTime=i),n}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 Je,this.toJSON())}_performRefresh(){return n("not implemented")}}function f(e,t){m("string"==typeof e||void 0===e,"internal-error",{appName:t})}class v{constructor(e){var{uid:t,auth:r,stsTokenManager:i}=e,e=de(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new Be(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,this.auth=r,this.stsTokenManager=i,this.accessToken=i.accessToken,this.displayName=e.displayName||null,this.email=e.email||null,this.emailVerified=e.emailVerified||!1,this.phoneNumber=e.phoneNumber||null,this.photoURL=e.photoURL||null,this.isAnonymous=e.isAnonymous||!1,this.tenantId=e.tenantId||null,this.providerData=e.providerData?[...e.providerData]:[],this.metadata=new ze(e.createdAt||void 0,e.lastLoginAt||void 0)}async getIdToken(e){e=await g(this,this.stsTokenManager.getToken(this.auth,e));return m(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(e,t=!1)=>{var e=s(e),r=We(t=await e.getIdToken(t)),i=(m(r&&r.exp&&r.auth_time&&r.iat,e.auth,"internal-error"),null==(e="object"==typeof r.firebase?r.firebase:void 0)?void 0:e.sign_in_provider);return{claims:r,token:t,authTime:je(He(r.auth_time)),issuedAtTime:je(He(r.iat)),expirationTime:je(He(r.exp)),signInProvider:i||null,signInSecondFactor:(null==e?void 0:e.sign_in_second_factor)||null}})(this,e)}reload(){return(async e=>{await Ge(e=s(e)),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)})(this)}_assign(e){this!==e&&(m(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){e=new v(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}));return e.metadata._copy(this.metadata),e}_onReload(e){m(!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 r=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),r=!0),t&&await Ge(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){var e;return Wn._isFirebaseServerApp(this.auth.app)?Promise.reject(h(this.auth)):(e=await this.getIdToken(),await g(this,(async(e,t)=>p(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 r=null!=(r=t.displayName)?r:void 0,i=null!=(i=t.email)?i:void 0,n=null!=(n=t.phoneNumber)?n:void 0,s=null!=(s=t.photoURL)?s:void 0,a=null!=(a=t.tenantId)?a:void 0,o=null!=(o=t._redirectEventId)?o:void 0,l=null!=(l=t.createdAt)?l:void 0,c=null!=(c=t.lastLoginAt)?c:void 0,{uid:t,emailVerified:d,isAnonymous:u,providerData:h,stsTokenManager:p}=t,p=(m(t&&p,e,"internal-error"),Je.fromJSON(this.name,p)),t=(m("string"==typeof t,e,"internal-error"),f(r,e.name),f(i,e.name),m("boolean"==typeof d,e,"internal-error"),m("boolean"==typeof u,e,"internal-error"),f(n,e.name),f(s,e.name),f(a,e.name),f(o,e.name),f(l,e.name),f(c,e.name),new v({uid:t,auth:e,email:i,emailVerified:d,displayName:r,isAnonymous:u,photoURL:s,phoneNumber:n,tenantId:a,stsTokenManager:p,createdAt:l,lastLoginAt:c}));return h&&Array.isArray(h)&&(t.providerData=h.map(e=>Object.assign({},e))),o&&(t._redirectEventId=o),t}static async _fromIdTokenResponse(e,t,r=!1){var i=new Je,t=(i.updateFromServerResponse(t),new v({uid:t.localId,auth:e,stsTokenManager:i,isAnonymous:r}));return await Ge(t),t}static async _fromGetAccountInfoResponse(e,t,r){var t=t.users[0],i=(m(void 0!==t.localId,"internal-error"),void 0!==t.providerUserInfo?Ke(t.providerUserInfo):[]),n=!(t.email&&t.passwordHash||null!=i&&i.length),s=new Je,r=(s.updateFromIdToken(r),new v({uid:t.localId,auth:e,stsTokenManager:s,isAnonymous:n})),e={uid:t.localId,displayName:t.displayName||null,photoURL:t.photoUrl||null,email:t.email||null,emailVerified:t.emailVerified||!1,phoneNumber:t.phoneNumber||null,tenantId:t.tenantId||null,providerData:i,metadata:new ze(t.createdAt,t.lastLoginAt),isAnonymous:!(t.email&&t.passwordHash||null!=i&&i.length)};return Object.assign(r,e),r}}let Ye=new Map;function _(e){a(e instanceof Function,"Expected a class definition");var t=Ye.get(e);return t?a(t instanceof e,"Instance stored in cache mismatched with class"):(t=new e,Ye.set(e,t)),t}class $e{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){}}$e.type="NONE";let Xe=$e;function y(e,t,r){return`firebase:${e}:${t}:`+r}class Qe{constructor(e,t,r){this.persistence=e,this.auth=t,this.userKey=r;var{config:e,name:r}=this.auth;this.fullUserKey=y(this.userKey,e.apiKey,r),this.fullPersistenceKey=y("persistence",e.apiKey,r),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?v._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){var t;if(this.persistence!==e)return t=await this.getCurrentUser(),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,r="authUser"){if(!t.length)return new Qe(_(Xe),e,r);var i,n=(await Promise.all(t.map(async e=>{if(await e._isAvailable())return e}))).filter(e=>e);let s=n[0]||_(Xe),a=y(r,e.config.apiKey,e.name),o=null;for(i of t)try{var l=await i._get(a);if(l){var c=v._fromJSON(e,l);i!==s&&(o=c),s=i;break}}catch(e){}n=n.filter(e=>e._shouldAllowMigration);return s._shouldAllowMigration&&n.length&&(s=n[0],o&&await s._set(a,o.toJSON()),await Promise.all(t.map(async e=>{if(e!==s)try{await e._remove(a)}catch(e){}}))),new Qe(s,e,r)}}function Ze(e){var t=e.toLowerCase();return t.includes("opera/")||t.includes("opr/")||t.includes("opios/")?"Opera":it(t)?"IEMobile":t.includes("msie")||t.includes("trident/")?"IE":t.includes("edge/")?"Edge":et(t)?"Firefox":t.includes("silk/")?"Silk":st(t)?"Blackberry":at(t)?"Webos":tt(t)?"Safari":!t.includes("chrome/")&&!rt(t)||t.includes("edge/")?nt(t)?"Android":2===(null==(t=e.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/))?void 0:t.length)?t[1]:"Other":"Chrome"}function et(e=l()){return/firefox\//i.test(e)}function tt(e=l()){e=e.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function rt(e=l()){return/crios\//i.test(e)}function it(e=l()){return/iemobile/i.test(e)}function nt(e=l()){return/android/i.test(e)}function st(e=l()){return/blackberry/i.test(e)}function at(e=l()){return/webos/i.test(e)}function ot(e=l()){return/iphone|ipad|ipod/i.test(e)||/macintosh/i.test(e)&&/mobile/i.test(e)}function lt(e=l()){return ot(e)||nt(e)||at(e)||st(e)||/windows phone/i.test(e)||it(e)}function ct(e,t=[]){let r;switch(e){case"Browser":r=Ze(l());break;case"Worker":r=Ze(l())+"-"+e;break;default:r=e}t=t.length?t.join(","):"FirebaseCore-web";return`${r}/JsCore/${Wn.SDK_VERSION}/`+t}class dt{constructor(e){this.auth=e,this.queue=[]}pushCallback(i,e){var t=r=>new Promise((e,t)=>{try{e(i(r))}catch(e){t(e)}});t.onAbort=e,this.queue.push(t);let r=this.queue.length-1;return()=>{this.queue[r]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser!==e){var t=[];try{for(var r of this.queue)await r(e),r.onAbort&&t.push(r.onAbort)}catch(e){t.reverse();for(var i of t)try{i()}catch(e){}throw this.auth._errorFactory.create("login-blocked",{originalMessage:null==e?void 0:e.message})}}}}class ut{constructor(e){var t,r=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=null!=(t=r.minPasswordLength)?t:6,r.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=r.maxPasswordLength),void 0!==r.containsLowercaseCharacter&&(this.customStrengthOptions.containsLowercaseLetter=r.containsLowercaseCharacter),void 0!==r.containsUppercaseCharacter&&(this.customStrengthOptions.containsUppercaseLetter=r.containsUppercaseCharacter),void 0!==r.containsNumericCharacter&&(this.customStrengthOptions.containsNumericCharacter=r.containsNumericCharacter),void 0!==r.containsNonAlphanumericCharacter&&(this.customStrengthOptions.containsNonAlphanumericCharacter=r.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,"ENFORCEMENT_STATE_UNSPECIFIED"===this.enforcementState&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=null!=(r=null==(t=e.allowedNonAlphanumericCharacters)?void 0:t.join(""))?r:"",this.forceUpgradeOnSignin=null!=(t=e.forceUpgradeOnSignin)&&t,this.schemaVersion=e.schemaVersion}validatePassword(e){var t={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,t),this.validatePasswordCharacterOptions(e,t),t.isValid&&(t.isValid=null==(e=t.meetsMinPasswordLength)||e),t.isValid&&(t.isValid=null==(e=t.meetsMaxPasswordLength)||e),t.isValid&&(t.isValid=null==(e=t.containsLowercaseLetter)||e),t.isValid&&(t.isValid=null==(e=t.containsUppercaseLetter)||e),t.isValid&&(t.isValid=null==(e=t.containsNumericCharacter)||e),t.isValid&&(t.isValid=null==(e=t.containsNonAlphanumericCharacter)||e),t}validatePasswordLengthOptions(e,t){var r=this.customStrengthOptions.minPasswordLength,i=this.customStrengthOptions.maxPasswordLength;r&&(t.meetsMinPasswordLength=e.length>=r),i&&(t.meetsMaxPasswordLength=e.length<=i)}validatePasswordCharacterOptions(t,r){var i;this.updatePasswordCharacterOptionsStatuses(r,!1,!1,!1,!1);for(let e=0;e<t.length;e++)i=t.charAt(e),this.updatePasswordCharacterOptionsStatuses(r,"a"<=i&&i<="z","A"<=i&&i<="Z","0"<=i&&i<="9",this.allowedNonAlphanumericCharacters.includes(i))}updatePasswordCharacterOptionsStatuses(e,t,r,i,n){this.customStrengthOptions.containsLowercaseLetter&&!e.containsLowercaseLetter&&(e.containsLowercaseLetter=t),this.customStrengthOptions.containsUppercaseLetter&&!e.containsUppercaseLetter&&(e.containsUppercaseLetter=r),this.customStrengthOptions.containsNumericCharacter&&!e.containsNumericCharacter&&(e.containsNumericCharacter=i),this.customStrengthOptions.containsNonAlphanumericCharacter&&!e.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter=n)}}class ht{constructor(e,t,r,i){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=r,this.config=i,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new pt(this),this.idTokenSubscription=new pt(this),this.beforeStateQueue=new dt(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=ve,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=i.sdkClientVersion}_initializeWithPersistence(t,r){return r&&(this._popupRedirectResolver=_(r)),this._initializationPromise=this.queue(async()=>{var e;if(!this._deleted&&(this.persistenceManager=await Qe.create(this,t),!this._deleted)){if(null!=(e=this._popupRedirectResolver)&&e._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch(e){}await this.initializeCurrentUser(r),this.lastNotifiedUid=(null==(e=this.currentUser)?void 0:e.uid)||null,this._deleted||(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){var e;!this._deleted&&(e=await this.assertedPersistence.getCurrentUser(),this.currentUser||e)&&(this.currentUser&&e&&this.currentUser.uid===e.uid?(this._currentUser._assign(e),await this.currentUser.getIdToken()):await this._updateCurrentUser(e,!0))}async initializeCurrentUserFromIdToken(e){try{var t=await xe(this,{idToken:e}),r=await v._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(r)}catch(e){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",e),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){if(Wn._isFirebaseServerApp(this.app)){let t=this.app.settings.authIdToken;return t?new Promise(e=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(t).then(e,e))}):this.directlySetCurrentUser(null)}var t,r,i=await this.assertedPersistence.getCurrentUser();let n=i,s=!1;if(e&&this.config.authDomain&&(await this.getOrInitRedirectPersistenceManager(),t=null==(t=this.redirectUser)?void 0:t._redirectEventId,r=null==n?void 0:n._redirectEventId,e=await this.tryRedirectSignIn(e),t&&t!==r||null==e||!e.user||(n=e.user,s=!0)),!n)return this.directlySetCurrentUser(null);if(n._redirectEventId)return m(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===n._redirectEventId?this.directlySetCurrentUser(n):this.reloadAndSetCurrentUserOrClear(n);if(s)try{await this.beforeStateQueue.runMiddleware(n)}catch(e){n=i,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(e))}return n?this.reloadAndSetCurrentUserOrClear(n):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 Ge(e)}catch(e){if("auth/network-request-failed"!==(null==e?void 0:e.code))return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){var e;this.languageCode="undefined"!=typeof navigator&&((e=navigator).languages&&e.languages[0]||e.language)||null}async _delete(){this._deleted=!0}async updateCurrentUser(e){return Wn._isFirebaseServerApp(this.app)?Promise.reject(h(this)):((e=e?s(e):null)&&m(e.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(e&&e._clone(this)))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&m(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return Wn._isFirebaseServerApp(this.app)?Promise.reject(h(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return Wn._isFirebaseServerApp(this.app)?Promise.reject(h(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(_(e))})}_getRecaptchaConfig(){return null==this.tenantId?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();var t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return null===this.tenantId?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){var e=await p(e=this,"GET","/v2/passwordPolicy",o(e,{})),e=new ut(e);null===this.tenantId?this._projectPasswordPolicy=e:this._tenantPasswordPolicies[this.tenantId]=e}_getPersistence(){return this.assertedPersistence.persistence.type}_updateErrorMap(e){this._errorFactory=new X("auth","Firebase",e())}onAuthStateChanged(e,t,r){return this.registerStateListener(this.authStateSubscription,e,t,r)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,r){return this.registerStateListener(this.idTokenSubscription,e,t,r)}authStateReady(){return new Promise((t,r)=>{if(this.currentUser)t();else{let e=this.onAuthStateChanged(()=>{e(),t()},r)}})}async revokeAccessToken(e){var t;this.currentUser&&(e={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:await this.currentUser.getIdToken()},null!=this.tenantId&&(e.tenantId=this.tenantId),await p(t=this,"POST","/v2/accounts:revokeToken",o(t,e)))}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:null==(e=this._currentUser)?void 0:e.toJSON()}}async _setRedirectUser(e,t){t=await this.getOrInitRedirectPersistenceManager(t);return null===e?t.removeCurrentUser():t.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){return this.redirectPersistenceManager||(m(e=e&&_(e)||this._popupRedirectResolver,this,"argument-error"),this.redirectPersistenceManager=await Qe.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._redirectEventId)===e?this._currentUser:(null==(t=this.redirectUser)?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.uid)?e:null,this.lastNotifiedUid!==e)&&(this.lastNotifiedUid=e,this.authStateSubscription.next(this.currentUser))}registerStateListener(t,r,i,n){if(this._deleted)return()=>{};let e="function"==typeof r?r:r.next.bind(r),s=!1;var a=this._isInitialized?Promise.resolve():this._initializationPromise;if(m(a,this,"internal-error"),a.then(()=>{s||e(this.currentUser)}),"function"==typeof r){let e=t.addObserver(r,i,n);return()=>{s=!0,e()}}{let e=t.addObserver(r);return()=>{s=!0,e()}}}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 m(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){e&&!this.frameworks.includes(e)&&(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=ct(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var e={"X-Client-Version":this.clientVersion},t=(this.app.options.appId&&(e["X-Firebase-gmpid"]=this.app.options.appId),await(null==(t=this.heartbeatServiceProvider.getImmediate({optional:!0}))?void 0:t.getHeartbeatsHeader())),t=(t&&(e["X-Firebase-Client"]=t),await this._getAppCheckToken());return t&&(e["X-Firebase-AppCheck"]=t),e}async _getAppCheckToken(){var e,t,r;return Wn._isFirebaseServerApp(this.app)&&this.app.settings.appCheckToken?this.app.settings.appCheckToken:(null!=(e=await(null==(e=this.appCheckServiceProvider.getImmediate({optional:!0}))?void 0:e.getToken()))&&e.error&&(t="Error while retrieving App Check token: "+e.error,r=[],_e.logLevel<=i.WARN)&&_e.warn(`Auth (${Wn.SDK_VERSION}): `+t,...r),null==e?void 0:e.token)}}function I(e){return s(e)}class pt{constructor(e){var t;this.auth=e,this.observer=null,this.addObserver=(e=e=>this.observer=e,(e=new ne(e,t)).subscribe.bind(e))}get next(){return m(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}let mt={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function gt(e){return mt.loadJS(e)}function ft(e){return"__"+e+Math.floor(1e6*Math.random())}class vt{constructor(e){this.auth=e,this.counter=1e12,this._widgets=new Map}render(e,t){var r=this.counter;return this._widgets.set(r,new It(e,this.auth.name,t||{})),this.counter++,r}reset(e){var t,e=e||1e12;null!=(t=this._widgets.get(e))&&t.delete(),this._widgets.delete(e)}getResponse(e){return(null==(e=this._widgets.get(e||1e12))?void 0:e.getResponse())||""}async execute(e){return null!=(e=this._widgets.get(e||1e12))&&e.execute(),""}}class _t{constructor(){this.enterprise=new yt}ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class yt{ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class It{constructor(e,t,r){this.params=r,this.timerId=null,this.deleted=!1,this.responseToken=null,this.clickHandler=()=>{this.execute()};r="string"==typeof e?document.getElementById(e):e;m(r,"argument-error",{appName:t}),this.container=r,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=(t=>{var r=[],i="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let e=0;e<t;e++)r.push(i.charAt(Math.floor(Math.random()*i.length)));return r.join("")})(50);let{callback:e,"expired-callback":t}=this.params;if(e)try{e(this.responseToken)}catch(e){}this.timerId=window.setTimeout(()=>{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!")}}let wt="NO_RECAPTCHA";class Tt{constructor(e){this.type="recaptcha-enterprise",this.auth=I(e)}async verify(n="verify",e=!1){function s(e,t,r){let i=window.grecaptcha;Me(i)?i.enterprise.ready(()=>{i.enterprise.execute(e,{action:n}).then(e=>{t(e)}).catch(()=>{t(wt)})}):r(Error("No reCAPTCHA enterprise script loaded."))}return this.auth.settings.appVerificationDisabledForTesting?(new _t).execute("siteKey",{action:"verify"}):new Promise((r,i)=>{(async i=>{if(!e){if(null==i.tenantId&&null!=i._agentRecaptchaConfig)return i._agentRecaptchaConfig.siteKey;if(null!=i.tenantId&&void 0!==i._tenantRecaptchaConfigs[i.tenantId])return i._tenantRecaptchaConfigs[i.tenantId].siteKey}return new Promise(async(t,r)=>{Ve(i,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(e=>{if(void 0!==e.recaptchaKey)return e=new Fe(e),null==i.tenantId?i._agentRecaptchaConfig=e:i._tenantRecaptchaConfigs[i.tenantId]=e,t(e.siteKey);r(new Error("recaptcha Enterprise site key undefined"))}).catch(e=>{r(e)})})})(this.auth).then(t=>{if(!e&&Me(window.grecaptcha))s(t,r,i);else if("undefined"==typeof window)i(new Error("RecaptchaVerifier is only supported in browser"));else{let e=mt.recaptchaEnterpriseScript;0!==e.length&&(e+=t),gt(e).then(()=>{s(t,r,i)}).catch(e=>{i(e)})}}).catch(e=>{i(e)})})}}async function Et(t,e,r,i=!1,n=!1){t=new Tt(t);let s;if(n)s=wt;else try{s=await t.verify(r)}catch(e){s=await t.verify(r,!0)}n=Object.assign({},e);return"mfaSmsEnrollment"===r||"mfaSmsSignIn"===r?"phoneEnrollmentInfo"in n?(t=n.phoneEnrollmentInfo.phoneNumber,e=n.phoneEnrollmentInfo.recaptchaToken,Object.assign(n,{phoneEnrollmentInfo:{phoneNumber:t,recaptchaToken:e,captchaResponse:s,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})):"phoneSignInInfo"in n&&(r=n.phoneSignInInfo.recaptchaToken,Object.assign(n,{phoneSignInInfo:{recaptchaToken:r,captchaResponse:s,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})):(i?Object.assign(n,{captchaResp:s}):Object.assign(n,{captchaResponse:s}),Object.assign(n,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(n,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"})),n}async function w(r,i,n,s,e){var t;return"EMAIL_PASSWORD_PROVIDER"===e?null!=(t=r._getRecaptchaConfig())&&t.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")?(t=await Et(r,i,n,"getOobCode"===n),s(r,t)):s(r,i).catch(async e=>{var t;return"auth/missing-recaptcha-token"===e.code?(console.log(n+" is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow."),t=await Et(r,i,n,"getOobCode"===n),s(r,t)):Promise.reject(e)}):"PHONE_PROVIDER"===e?null!=(t=r._getRecaptchaConfig())&&t.isProviderEnabled("PHONE_PROVIDER")?(t=await Et(r,i,n),s(r,t).catch(async e=>{var t;if("AUDIT"===(null==(t=r._getRecaptchaConfig())?void 0:t.getProviderEnforcementState("PHONE_PROVIDER"))&&("auth/missing-recaptcha-token"===e.code||"auth/invalid-app-credential"===e.code))return console.log(`Failed to verify with reCAPTCHA Enterprise. Automatically triggering the reCAPTCHA v2 flow to complete the ${n} flow.`),t=await Et(r,i,n,!1,!0),s(r,t);return Promise.reject(e)})):(t=await Et(r,i,n,!1,!0),s(r,t)):Promise.reject(e+" provider is not supported.")}function bt(e,t,r){var e=I(e),r=(m(/^https?:\/\//.test(t),e,"invalid-emulator-scheme"),!(null==r||!r.disableWarnings)),i=kt(t),{host:t,port:n}=(e=>{var t=kt(e);return(e=/(\/\/)?([^?#/]+)/.exec(e.substr(t.length)))?(t=e[2].split("@").pop()||"",(e=/^(\[[^\]]+\])(:|$)/.exec(t))?{host:e=e[1],port:St(t.substr(e.length+1))}:([e,t]=t.split(":"),{host:e,port:St(t)})):{host:"",port:null}})(t),s={url:i+`//${t}${null===n?"":":"+n}/`},t=Object.freeze({host:t,port:n,protocol:i.replace(":",""),options:Object.freeze({disableWarnings:r})});function a(){var 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)}e._canInitEmulator?(e.config.emulator=s,e.emulatorConfig=t,e.settings.appVerificationDisabledForTesting=!0,r||("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&&("loading"===document.readyState?window.addEventListener("DOMContentLoaded",a):a()))):(m(e.config.emulator&&e.emulatorConfig,e,"emulator-config-failed"),m(Z(s,e.config.emulator)&&Z(t,e.emulatorConfig),e,"emulator-config-failed"))}function kt(e){var t=e.indexOf(":");return t<0?"":e.substr(0,t+1)}function St(e){return!e||(e=Number(e),isNaN(e))?null:e}class Rt{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return n("not implemented")}_getIdTokenResponse(e){return n("not implemented")}_linkToIdToken(e,t){return n("not implemented")}_getReauthenticationResolver(e){return n("not implemented")}}async function At(e,t){return p(e,"POST","/v1/accounts:resetPassword",o(e,t))}async function Pt(e,t){return p(e,"POST","/v1/accounts:signUp",t)}async function Ct(e,t){return r(e,"POST","/v1/accounts:signInWithPassword",o(e,t))}async function Ot(e,t){return p(e,"POST","/v1/accounts:sendOobCode",o(e,t))}async function Nt(e,t){return Ot(e,t)}async function Lt(e,t){return Ot(e,t)}class Dt extends Rt{constructor(e,t,r,i=null){super("password",r),this._email=e,this._password=t,this._tenantId=i}static _fromEmailAndPassword(e,t){return new Dt(e,t,"password")}static _fromEmailAndCode(e,t,r=null){return new Dt(e,t,"emailLink",r)}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 w(e,{returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signInWithPassword",Ct,"EMAIL_PASSWORD_PROVIDER");case"emailLink":return(async(e,t)=>r(e,"POST","/v1/accounts:signInWithEmailLink",o(e,t)))(e,{email:this._email,oobCode:this._password});default:d(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":return w(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",Pt,"EMAIL_PASSWORD_PROVIDER");case"emailLink":return(async(e,t)=>r(e,"POST","/v1/accounts:signInWithEmailLink",o(e,t)))(e,{idToken:t,email:this._email,oobCode:this._password});default:d(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function T(e,t){return r(e,"POST","/v1/accounts:signInWithIdp",o(e,t))}class E extends Rt{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){var t=new E(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):d("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 e="string"==typeof e?JSON.parse(e):e,{providerId:t,signInMethod:r}=e,e=de(e,["providerId","signInMethod"]);return t&&r?((t=new E(t,r)).idToken=e.idToken||void 0,t.accessToken=e.accessToken||void 0,t.secret=e.secret,t.nonce=e.nonce,t.pendingToken=e.pendingToken||null,t):null}_getIdTokenResponse(e){return T(e,this.buildRequest())}_linkToIdToken(e,t){var r=this.buildRequest();return r.idToken=t,T(e,r)}_getReauthenticationResolver(e){var t=this.buildRequest();return t.autoCreate=!1,T(e,t)}buildRequest(){var e,t={requestUri:"http://localhost",returnSecureToken:!0};return this.pendingToken?t.pendingToken=this.pendingToken:(e={},this.idToken&&(e.id_token=this.idToken),this.accessToken&&(e.access_token=this.accessToken),this.secret&&(e.oauth_token_secret=this.secret),e.providerId=this.providerId,this.nonce&&!this.pendingToken&&(e.nonce=this.nonce),t.postBody=te(e)),t}}async function Ut(e,t){return p(e,"POST","/v1/accounts:sendVerificationCode",o(e,t))}let Mt={USER_NOT_FOUND:"user-not-found"};class Ft extends Rt{constructor(e){super("phone","phone"),this.params=e}static _fromVerification(e,t){return new Ft({verificationId:e,verificationCode:t})}static _fromTokenResponse(e,t){return new Ft({phoneNumber:e,temporaryProof:t})}_getIdTokenResponse(e){return(async(e,t)=>r(e,"POST","/v1/accounts:signInWithPhoneNumber",o(e,t)))(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return(async(e,t)=>{if((t=await r(e,"POST","/v1/accounts:signInWithPhoneNumber",o(e,t))).temporaryProof)throw De(e,"account-exists-with-different-credential",t);return t})(e,Object.assign({idToken:t},this._makeVerificationRequest()))}_getReauthenticationResolver(e){return(async(e,t)=>r(e,"POST","/v1/accounts:signInWithPhoneNumber",o(e,Object.assign(Object.assign({},t),{operation:"REAUTH"})),Mt))(e,this._makeVerificationRequest())}_makeVerificationRequest(){var{temporaryProof:e,phoneNumber:t,verificationId:r,verificationCode:i}=this.params;return e&&t?{temporaryProof:e,phoneNumber:t}:{sessionInfo:r,code:i}}toJSON(){var 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:e,verificationCode:t,phoneNumber:r,temporaryProof:i}=e="string"==typeof e?JSON.parse(e):e;return t||e||r||i?new Ft({verificationId:e,verificationCode:t,phoneNumber:r,temporaryProof:i}):null}}class Vt{constructor(e){var e=re(ie(e)),t=null!=(t=e.apiKey)?t:null,r=null!=(r=e.oobCode)?r:null,i=(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!=(i=e.mode)?i:null);m(t&&r&&i,"argument-error"),this.apiKey=t,this.operation=i,this.code=r,this.continueUrl=null!=(t=e.continueUrl)?t:null,this.languageCode=null!=(i=e.languageCode)?i:null,this.tenantId=null!=(r=e.tenantId)?r:null}static parseLink(e){t=re(ie(e=e)).link,r=t?re(ie(t)).deep_link_id:null;var t,r,i=((i=re(ie(e)).deep_link_id)?re(ie(i)).link:null)||i||r||t||e;try{return new Vt(i)}catch(e){return null}}}class xt{constructor(){this.providerId=xt.PROVIDER_ID}static credential(e,t){return Dt._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){t=Vt.parseLink(t);return m(t,"argument-error"),Dt._fromEmailAndCode(e,t.code,t.tenantId)}}xt.PROVIDER_ID="password",xt.EMAIL_PASSWORD_SIGN_IN_METHOD="password",xt.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class b{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 jt extends b{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class Ht extends jt{static credentialFromJSON(e){e="string"==typeof e?JSON.parse(e):e;return m("providerId"in e&&"signInMethod"in e,"argument-error"),E._fromParams(e)}credential(e){return this._credential(Object.assign(Object.assign({},e),{nonce:e.rawNonce}))}_credential(e){return m(e.idToken||e.accessToken,"argument-error"),E._fromParams(Object.assign(Object.assign({},e),{providerId:this.providerId,signInMethod:this.providerId}))}static credentialFromResult(e){return Ht.oauthCredentialFromTaggedObject(e)}static credentialFromError(e){return Ht.oauthCredentialFromTaggedObject(e.customData||{})}static oauthCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthIdToken:e,oauthAccessToken:t,oauthTokenSecret:r,pendingToken:i,nonce:n,providerId:s}=e;if(!(t||r||e||i))return null;if(!s)return null;try{return new Ht(s)._credential({idToken:e,accessToken:t,nonce:n,pendingToken:i})}catch(e){return null}}}class k extends jt{constructor(){super("facebook.com")}static credential(e){return E._fromParams({providerId:k.PROVIDER_ID,signInMethod:k.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return k.credentialFromTaggedObject(e)}static credentialFromError(e){return k.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!(e&&"oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return k.credential(e.oauthAccessToken)}catch(e){return null}}}k.FACEBOOK_SIGN_IN_METHOD="facebook.com",k.PROVIDER_ID="facebook.com";class S extends jt{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return E._fromParams({providerId:S.PROVIDER_ID,signInMethod:S.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return S.credentialFromTaggedObject(e)}static credentialFromError(e){return S.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthIdToken:e,oauthAccessToken:t}=e;if(!e&&!t)return null;try{return S.credential(e,t)}catch(e){return null}}}S.GOOGLE_SIGN_IN_METHOD="google.com",S.PROVIDER_ID="google.com";class R extends jt{constructor(){super("github.com")}static credential(e){return E._fromParams({providerId:R.PROVIDER_ID,signInMethod:R.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return R.credentialFromTaggedObject(e)}static credentialFromError(e){return R.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!(e&&"oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return R.credential(e.oauthAccessToken)}catch(e){return null}}}R.GITHUB_SIGN_IN_METHOD="github.com",R.PROVIDER_ID="github.com";class Wt extends Rt{constructor(e,t){super(e,e),this.pendingToken=t}_getIdTokenResponse(e){return T(e,this.buildRequest())}_linkToIdToken(e,t){var r=this.buildRequest();return r.idToken=t,T(e,r)}_getReauthenticationResolver(e){var t=this.buildRequest();return t.autoCreate=!1,T(e,t)}toJSON(){return{signInMethod:this.signInMethod,providerId:this.providerId,pendingToken:this.pendingToken}}static fromJSON(e){var{providerId:e,signInMethod:t,pendingToken:r}="string"==typeof e?JSON.parse(e):e;return e&&t&&r&&e===t?new Wt(e,r):null}static _create(e,t){return new Wt(e,t)}buildRequest(){return{requestUri:"http://localhost",returnSecureToken:!0,pendingToken:this.pendingToken}}}class qt extends b{constructor(e){m(e.startsWith("saml."),"argument-error"),super(e)}static credentialFromResult(e){return qt.samlCredentialFromTaggedObject(e)}static credentialFromError(e){return qt.samlCredentialFromTaggedObject(e.customData||{})}static credentialFromJSON(e){e=Wt.fromJSON(e);return m(e,"argument-error"),e}static samlCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{pendingToken:e,providerId:t}=e;if(!e||!t)return null;try{return Wt._create(t,e)}catch(e){return null}}}class A extends jt{constructor(){super("twitter.com")}static credential(e,t){return E._fromParams({providerId:A.PROVIDER_ID,signInMethod:A.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return A.credentialFromTaggedObject(e)}static credentialFromError(e){return A.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthAccessToken:e,oauthTokenSecret:t}=e;if(!e||!t)return null;try{return A.credential(e,t)}catch(e){return null}}}async function Bt(e,t){return r(e,"POST","/v1/accounts:signUp",o(e,t))}A.TWITTER_SIGN_IN_METHOD="twitter.com",A.PROVIDER_ID="twitter.com";class P{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,r,i=!1){e=await v._fromIdTokenResponse(e,r,i),i=zt(r);return new P({user:e,providerId:i,_tokenResponse:r,operationType:t})}static async _forOperation(e,t,r){await e._updateTokensIfNecessary(r,!0);var i=zt(r);return new P({user:e,providerId:i,_tokenResponse:r,operationType:t})}}function zt(e){return e.providerId||("phoneNumber"in e?"phone":null)}class Gt extends c{constructor(e,t,r,i){super(t.code,t.message),this.operationType=r,this.user=i,Object.setPrototypeOf(this,Gt.prototype),this.customData={appName:e.name,tenantId:null!=(i=e.tenantId)?i:void 0,_serverResponse:t.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(e,t,r,i){return new Gt(e,t,r,i)}}function Kt(t,r,e,i){return("reauthenticate"===r?e._getReauthenticationResolver(t):e._getIdTokenResponse(t)).catch(e=>{if("auth/multi-factor-auth-required"===e.code)throw Gt._fromErrorAndOperation(t,e,r,i);throw e})}function Jt(e){return new Set(e.map(({providerId:e})=>e).filter(e=>!!e))}async function Yt(e,t){var e=s(e),r=(await Xt(!0,e,t),r=e.auth,t={idToken:await e.getIdToken(),deleteProvider:[t]},await p(r,"POST","/v1/accounts:update",t)).providerUserInfo;let i=Jt(r||[]);return e.providerData=e.providerData.filter(e=>i.has(e.providerId)),i.has("phone")||(e.phoneNumber=null),await e.auth._persistUserIfCurrent(e),e}async function $t(e,t,r=!1){t=await g(e,t._linkToIdToken(e.auth,await e.getIdToken()),r);return P._forOperation(e,"link",t)}async function Xt(e,t,r){await Ge(t);var i=!1===e?"provider-already-linked":"no-such-provider";m(Jt(t.providerData).has(r)===e,t.auth,i)}async function Qt(e,t,r=!1){var i=e.auth;if(Wn._isFirebaseServerApp(i.app))return Promise.reject(h(i));var n="reauthenticate";try{var s=await g(e,Kt(i,n,t,e),r),a=(m(s.idToken,i,"internal-error"),We(s.idToken)),o=(m(a,i,"internal-error"),a).sub;return m(e.uid===o,i,"user-mismatch"),P._forOperation(e,n,s)}catch(e){throw"auth/user-not-found"===(null==e?void 0:e.code)&&d(i,"user-mismatch"),e}}async function Zt(e,t,r=!1){return Wn._isFirebaseServerApp(e.app)?Promise.reject(h(e)):(t=await Kt(e,"signIn",t),t=await P._fromIdTokenResponse(e,"signIn",t),r||await e._updateCurrentUser(t.user),t)}async function er(e,t){return Zt(I(e),t)}async function tr(e,t){e=s(e);return await Xt(!1,e,t.providerId),$t(e,t)}async function rr(e,t){return Qt(s(e),t)}async function ir(e,t){return Wn._isFirebaseServerApp(e.app)?Promise.reject(h(e)):(t=await r(e=I(e),"POST","/v1/accounts:signInWithCustomToken",o(e,{token:t,returnSecureToken:!0})),t=await P._fromIdTokenResponse(e,"signIn",t),await e._updateCurrentUser(t.user),t)}class nr{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?sr._fromServerResponse(e,t):"totpInfo"in t?ar._fromServerResponse(e,t):d(e,"internal-error")}}class sr extends nr{constructor(e){super("phone",e),this.phoneNumber=e.phoneInfo}static _fromServerResponse(e,t){return new sr(t)}}class ar extends nr{constructor(e){super("totp",e)}static _fromServerResponse(e,t){return new ar(t)}}function or(e,t,r){var i;m(0<(null==(i=r.url)?void 0:i.length),e,"invalid-continue-uri"),m(void 0===r.dynamicLinkDomain||0<r.dynamicLinkDomain.length,e,"invalid-dynamic-link-domain"),m(void 0===r.linkDomain||0<r.linkDomain.length,e,"invalid-hosting-link-domain"),t.continueUrl=r.url,t.dynamicLinkDomain=r.dynamicLinkDomain,t.linkDomain=r.linkDomain,t.canHandleCodeInApp=r.handleCodeInApp,r.iOS&&(m(0<r.iOS.bundleId.length,e,"missing-ios-bundle-id"),t.iOSBundleId=r.iOS.bundleId),r.android&&(m(0<r.android.packageName.length,e,"missing-android-pkg-name"),t.androidInstallApp=r.android.installApp,t.androidMinimumVersionCode=r.android.minimumVersion,t.androidPackageName=r.android.packageName)}async function lr(e){e=I(e);e._getPasswordPolicyInternal()&&await e._updatePasswordPolicy()}async function cr(e,t){await p(e=s(e),"POST","/v1/accounts:update",o(e,{oobCode:t}))}async function dr(e,t){var r=s(e),i=await At(r,{oobCode:t}),e=i.requestType;switch(m(e,r,"internal-error"),e){case"EMAIL_SIGNIN":break;case"VERIFY_AND_CHANGE_EMAIL":m(i.newEmail,r,"internal-error");break;case"REVERT_SECOND_FACTOR_ADDITION":m(i.mfaInfo,r,"internal-error");default:m(i.email,r,"internal-error")}let n=null;return i.mfaInfo&&(n=nr._fromServerResponse(I(r),i.mfaInfo)),{data:{email:("VERIFY_AND_CHANGE_EMAIL"===i.requestType?i.newEmail:i.email)||null,previousEmail:("VERIFY_AND_CHANGE_EMAIL"===i.requestType?i.email:i.newEmail)||null,multiFactorInfo:n},operation:e}}async function ur(e,t){var r=be()?Ee():"http://localhost",e=(await p(e=s(e),"POST","/v1/accounts:createAuthUri",o(e,{identifier:t,continueUri:r}))).signinMethods;return e||[]}async function hr(e,t){var r=s(e),i={requestType:"VERIFY_EMAIL",idToken:await e.getIdToken()},t=(t&&or(r.auth,i,t),await Ot(r.auth,i)).email;t!==e.email&&await e.reload()}async function pr(e,t,r){var i=s(e),t={requestType:"VERIFY_AND_CHANGE_EMAIL",idToken:await e.getIdToken(),newEmail:t},r=(r&&or(i.auth,t,r),await Ot(i.auth,t)).email;r!==e.email&&await e.reload()}async function mr(e,{displayName:t,photoURL:r}){var i;void 0===t&&void 0===r||(i=await(e=s(e)).getIdToken(),i=await g(e,(async(e,t)=>p(e,"POST","/v1/accounts:update",t))(e.auth,{idToken:i,displayName:t,photoUrl:r,returnSecureToken:!0})),e.displayName=i.displayName||null,e.photoURL=i.photoUrl||null,(t=e.providerData.find(({providerId:e})=>"password"===e))&&(t.displayName=e.displayName,t.photoURL=e.photoURL),await e._updateTokensIfNecessary(i))}async function gr(e,t,r){var i=e.auth,n={idToken:await e.getIdToken(),returnSecureToken:!0},t=(t&&(n.email=t),r&&(n.password=r),await g(e,(async(e,t)=>p(e,"POST","/v1/accounts:update",t))(i,n)));await e._updateTokensIfNecessary(t,!0)}class fr{constructor(e,t,r={}){this.isNewUser=e,this.providerId=t,this.profile=r}}class vr extends fr{constructor(e,t,r,i){super(e,t,r),this.username=i}}class _r extends fr{constructor(e,t){super(e,"facebook.com",t)}}class yr extends vr{constructor(e,t){super(e,"github.com",t,"string"==typeof(null==t?void 0:t.login)?null==t?void 0:t.login:null)}}class Ir extends fr{constructor(e,t){super(e,"google.com",t)}}class wr extends vr{constructor(e,t,r){super(e,"twitter.com",t,r)}}function Tr(e){var{user:e,_tokenResponse:t}=e;if(e.isAnonymous&&!t)return{providerId:null,isNewUser:!1,profile:null};var r=t;if(!r)return null;var i=r.providerId,n=r.rawUserInfo?JSON.parse(r.rawUserInfo):{},s=r.isNewUser||"identitytoolkit#SignupNewUserResponse"===r.kind;if(!i&&null!=r&&r.idToken){e=null==(e=null==(e=We(r.idToken))?void 0:e.firebase)?void 0:e.sign_in_provider;if(e)return e="anonymous"!==e&&"custom"!==e?e:null,new fr(s,e)}if(!i)return null;switch(i){case"facebook.com":return new _r(s,n);case"github.com":return new yr(s,n);case"google.com":return new Ir(s,n);case"twitter.com":return new wr(s,n,r.screenName||null);case"custom":case"anonymous":return new fr(s,null);default:return new fr(s,i,n)}}class Er{constructor(e,t,r){this.type=e,this.credential=t,this.user=r}static _fromIdtoken(e,t){return new Er("enroll",e,t)}static _fromMfaPendingCredential(e){return new Er("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)&&t.pendingCredential)return Er._fromMfaPendingCredential(e.multiFactorSession.pendingCredential);if(null!=(t=e.multiFactorSession)&&t.idToken)return Er._fromIdtoken(e.multiFactorSession.idToken)}return null}}class br{constructor(e,t,r){this.session=e,this.hints=t,this.signInResolver=r}static _fromError(e,i){let n=I(e),s=i.customData._serverResponse;e=(s.mfaInfo||[]).map(e=>nr._fromServerResponse(n,e));m(s.mfaPendingCredential,n,"internal-error");let a=Er._fromMfaPendingCredential(s.mfaPendingCredential);return new br(a,e,async e=>{var e=await e._process(n,a),t=(delete s.mfaInfo,delete s.mfaPendingCredential,Object.assign(Object.assign({},s),{idToken:e.idToken,refreshToken:e.refreshToken}));switch(i.operationType){case"signIn":var r=await P._fromIdTokenResponse(n,i.operationType,t);return await n._updateCurrentUser(r.user),r;case"reauthenticate":return m(i.user,n,"internal-error"),P._forOperation(i.user,i.operationType,t);default:d(n,"internal-error")}})}async resolveSignIn(e){return this.signInResolver(e)}}function kr(e,t){return p(e,"POST","/v2/accounts/mfaEnrollment:start",o(e,t))}class Sr{constructor(t){this.user=t,this.enrolledFactors=[],t._onReload(e=>{e.mfaInfo&&(this.enrolledFactors=e.mfaInfo.map(e=>nr._fromServerResponse(t.auth,e)))})}static _fromUser(e){return new Sr(e)}async getSession(){return Er._fromIdtoken(await this.user.getIdToken(),this.user)}async enroll(e,t){var r=await this.getSession(),e=await g(this.user,e._process(this.user.auth,r,t));return await this.user._updateTokensIfNecessary(e),this.user.reload()}async unenroll(e){let t="string"==typeof e?e:e.uid;var r,i,e=await this.user.getIdToken();try{var n=await g(this.user,(r=this.user.auth,i={idToken:e,mfaEnrollmentId:t},p(r,"POST","/v2/accounts/mfaEnrollment:withdraw",o(r,i))));this.enrolledFactors=this.enrolledFactors.filter(({uid:e})=>e!==t),await this.user._updateTokensIfNecessary(n),await this.user.reload()}catch(e){throw e}}}let Rr=new WeakMap;let Ar="__sak";class Pr{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Ar,"1"),this.storage.removeItem(Ar),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()}get storage(){return this.storageRetriever()}}class Cr extends Pr{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=lt(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(var t of Object.keys(this.listeners)){var r=this.storage.getItem(t),i=this.localCache[t];r!==i&&e(t,i,r)}}onStorageEvent(e,r=!1){if(e.key){let t=e.key;r?this.detachListener():this.stopPolling();var i=()=>{var e=this.storage.getItem(t);!r&&this.localCache[t]===e||this.notifyListeners(t,e)},n=this.storage.getItem(t);Y()&&10===document.documentMode&&n!==e.newValue&&e.newValue!==e.oldValue?setTimeout(i,10):i()}else this.forAllChangedKeys((e,t,r)=>{this.notifyListeners(e,r)})}notifyListeners(e,t){this.localCache[e]=t;e=this.listeners[e];if(e)for(var r of Array.from(e))r(t&&JSON.parse(t))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,r)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:r}),!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]}}Cr.type="LOCAL";let Or=Cr;class Nr extends Pr{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}Nr.type="SESSION";let Lr=Nr;class Dr{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));return e||(e=new Dr(t),this.receivers.push(e),e)}isListeningto(e){return this.eventTarget===e}async handleEvent(e){let t=e,{eventId:r,eventType:i,data:n}=t.data;var e=this.handlersMap[i];null!=e&&e.size&&(t.ports[0].postMessage({status:"ack",eventId:r,eventType:i}),e=Array.from(e).map(async e=>e(t.origin,n)),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:r,eventType:i,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 Ur(e="",t=10){let r="";for(let e=0;e<t;e++)r+=Math.floor(10*Math.random());return e+r}Dr.receivers=[];class Mr{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,a=50){let o="undefined"!=typeof MessageChannel?new MessageChannel:null;if(!o)throw new Error("connection_unavailable");let l,c;return new Promise((r,i)=>{let n=Ur("",20),s=(o.port1.start(),setTimeout(()=>{i(new Error("unsupported_event"))},a));c={messageChannel:o,onMessage(e){var t=e;if(t.data.eventId===n)switch(t.data.status){case"ack":clearTimeout(s),l=setTimeout(()=>{i(new Error("timeout"))},3e3);break;case"done":clearTimeout(l),r(t.data.response);break;default:clearTimeout(s),clearTimeout(l),i(new Error("invalid_response"))}}},this.handlers.add(c),o.port1.addEventListener("message",c.onMessage),this.target.postMessage({eventType:e,eventId:n,data:t},[o.port2])}).finally(()=>{c&&this.removeMessageHandler(c)})}}function C(){return window}function Fr(){return void 0!==C().WorkerGlobalScope&&"function"==typeof C().importScripts}let Vr="firebaseLocalStorageDb",xr="firebaseLocalStorage",jr="fbase_key";class Hr{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 Wr(e,t){return e.transaction([xr],t?"readwrite":"readonly").objectStore(xr)}function qr(){let i=indexedDB.open(Vr,1);return new Promise((t,r)=>{i.addEventListener("error",()=>{r(i.error)}),i.addEventListener("upgradeneeded",()=>{var e=i.result;try{e.createObjectStore(xr,{keyPath:jr})}catch(e){r(e)}}),i.addEventListener("success",async()=>{var e=i.result;e.objectStoreNames.contains(xr)?t(e):(e.close(),e=indexedDB.deleteDatabase(Vr),await new Hr(e).toPromise(),t(await qr()))})})}async function Br(e,t,r){e=Wr(e,!0).put({fbase_key:t,value:r});return new Hr(e).toPromise()}function zr(e,t){e=Wr(e,!0).delete(t);return new Hr(e).toPromise()}class Gr{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 qr()),this.db}async _withRetries(e){let t=0;for(;;)try{return await e(await this._openDb())}catch(e){if(3<t++)throw e;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return Fr()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Dr._getInstance(Fr()?self:null),this.receiver._subscribe("keyChanged",async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){var e,t;this.activeServiceWorker=await(async()=>{if(null==navigator||!navigator.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch(e){return null}})(),this.activeServiceWorker&&(this.sender=new Mr(this.activeServiceWorker),t=await this.sender._send("ping",{},800))&&null!=(e=t[0])&&e.fulfilled&&null!=(e=t[0])&&e.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){var t;if(this.sender&&this.activeServiceWorker&&((null==(t=null==navigator?void 0:navigator.serviceWorker)?void 0:t.controller)||null)===this.activeServiceWorker)try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch(e){}}async _isAvailable(){try{var e;return indexedDB?(await Br(e=await qr(),Ar,"1"),await zr(e,Ar),!0):!1}catch(e){}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(t,r){return this._withPendingWrite(async()=>(await this._withRetries(e=>Br(e,t,r)),this.localCache[t]=r,this.notifyServiceWorker(t)))}async _get(t){var e=await this._withRetries(e=>(async(e,t)=>(e=Wr(e,!1).get(t),void 0===(t=await new Hr(e).toPromise())?null:t.value))(e,t));return this.localCache[t]=e}async _remove(t){return this._withPendingWrite(async()=>(await this._withRetries(e=>zr(e,t)),delete this.localCache[t],this.notifyServiceWorker(t)))}async _poll(){var e=await this._withRetries(e=>{e=Wr(e,!1).getAll();return new Hr(e).toPromise()});if(!e)return[];if(0!==this.pendingWrites)return[];var t,r=[],i=new Set;if(0!==e.length)for(var{fbase_key:n,value:s}of e)i.add(n),JSON.stringify(this.localCache[n])!==JSON.stringify(s)&&(this.notifyListeners(n,s),r.push(n));for(t of Object.keys(this.localCache))this.localCache[t]&&!i.has(t)&&(this.notifyListeners(t,null),r.push(t));return r}notifyListeners(e,t){this.localCache[e]=t;e=this.listeners[e];if(e)for(var r of Array.from(e))r(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()}}Gr.type="LOCAL";let Kr=Gr;function Jr(e,t){return p(e,"POST","/v2/accounts/mfaSignIn:start",o(e,t))}let Yr=ft("rcb"),$r=new Se(3e4,6e4);class Xr{constructor(){var e;this.hostLanguage="",this.counter=0,this.librarySeparatelyLoaded=!(null==(e=C().grecaptcha)||!e.render)}load(n,s=""){var e;return m((e=s).length<=6&&/^\s*[a-zA-Z0-9\-]*\s*$/.test(e),n,"argument-error"),this.shouldResolveImmediately(s)&&Ue(C().grecaptcha)?Promise.resolve(C().grecaptcha):new Promise((t,r)=>{let i=C().setTimeout(()=>{r(u(n,"network-request-failed"))},$r.get());C()[Yr]=()=>{C().clearTimeout(i),delete C()[Yr];var e=C().grecaptcha;if(e&&Ue(e)){let r=e.render;e.render=(e,t)=>{e=r(e,t);return this.counter++,e},this.hostLanguage=s,t(e)}else r(u(n,"internal-error"))},gt(mt.recaptchaV2Script+"?"+te({onload:Yr,render:"explicit",hl:s})).catch(()=>{clearTimeout(i),r(u(n,"internal-error"))})})}clearedOneInstance(){this.counter--}shouldResolveImmediately(e){var t;return!(null==(t=C().grecaptcha)||!t.render)&&(e===this.hostLanguage||0<this.counter||this.librarySeparatelyLoaded)}}class Qr{async load(e){return new vt(e)}clearedOneInstance(){}}let Zr="recaptcha",ei={theme:"light",type:"image"};class ti{constructor(e,t,r=Object.assign({},ei)){this.parameters=r,this.type=Zr,this.destroyed=!1,this.widgetId=null,this.tokenChangeListeners=new Set,this.renderPromise=null,this.recaptcha=null,this.auth=I(e),this.isInvisible="invisible"===this.parameters.size,m("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment");r="string"==typeof t?document.getElementById(t):t;m(r,this.auth,"argument-error"),this.container=r,this.parameters.callback=this.makeTokenCallback(this.parameters.callback),this._recaptchaLoader=new(this.auth.settings.appVerificationDisabledForTesting?Qr:Xr),this.validateStartingState()}async verify(){this.assertNotDestroyed();let e=await this.render(),i=this.getAssertedRecaptcha();var t=i.getResponse(e);return t||new Promise(t=>{let r=e=>{e&&(this.tokenChangeListeners.delete(r),t(e))};this.tokenChangeListeners.add(r),this.isInvisible&&i.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(){m(!this.parameters.sitekey,this.auth,"argument-error"),m(this.isInvisible||!this.container.hasChildNodes(),this.auth,"argument-error"),m("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment")}makeTokenCallback(r){return t=>{var e;this.tokenChangeListeners.forEach(e=>e(t)),"function"==typeof r?r(t):"string"==typeof r&&"function"==typeof(e=C()[r])&&e(t)}}assertNotDestroyed(){m(!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(){m(be()&&!Fr(),this.auth,"internal-error"),await(()=>{let t=null;return new Promise(e=>{"complete"===document.readyState?e():(t=()=>e(),window.addEventListener("load",t))}).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 p(this.auth,"GET","/v1/recaptchaParams")).recaptchaSiteKey||"");m(e,this.auth,"internal-error"),this.parameters.sitekey=e}getAssertedRecaptcha(){return m(this.recaptcha,this.auth,"internal-error"),this.recaptcha}}class ri{constructor(e,t){this.verificationId=e,this.onConfirmation=t}confirm(e){e=Ft._fromVerification(this.verificationId,e);return this.onConfirmation(e)}}async function ii(t,r,i){var n,e,s,a,o,l,c,d;if(!t._getRecaptchaConfig())try{s=await Ve(e=I(e=t),{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}),s=new Fe(s),null==e.tenantId?e._agentRecaptchaConfig=s:e._tenantRecaptchaConfigs[e.tenantId]=s,await(!s.isAnyProviderEnabled()||!new Tt(e).verify())}catch(e){console.log("Failed to initialize reCAPTCHA Enterprise config. Triggering the reCAPTCHA v2 verification.")}try{let e;return("session"in(e="string"==typeof r?{phoneNumber:r}:r)?(a=e.session,"phoneNumber"in e?(m("enroll"===a.type,t,"internal-error"),o={idToken:a.credential,phoneEnrollmentInfo:{phoneNumber:e.phoneNumber,clientType:"CLIENT_TYPE_WEB"}},(await w(t,o,"mfaSmsEnrollment",async(e,t)=>t.phoneEnrollmentInfo.captchaResponse===wt?(m((null==i?void 0:i.type)===Zr,e,"argument-error"),kr(e,await ni(e,t,i))):kr(e,t),"PHONE_PROVIDER").catch(e=>Promise.reject(e))).phoneSessionInfo):(m("signin"===a.type,t,"internal-error"),m(l=(null==(n=e.multiFactorHint)?void 0:n.uid)||e.multiFactorUid,t,"missing-multi-factor-info"),c={mfaPendingCredential:a.credential,mfaEnrollmentId:l,phoneSignInInfo:{clientType:"CLIENT_TYPE_WEB"}},(await w(t,c,"mfaSmsSignIn",async(e,t)=>t.phoneSignInInfo.captchaResponse===wt?(m((null==i?void 0:i.type)===Zr,e,"argument-error"),Jr(e,await ni(e,t,i))):Jr(e,t),"PHONE_PROVIDER").catch(e=>Promise.reject(e))).phoneResponseInfo)):(d={phoneNumber:e.phoneNumber,clientType:"CLIENT_TYPE_WEB"},await w(t,d,"sendVerificationCode",async(e,t)=>t.captchaResponse===wt?(m((null==i?void 0:i.type)===Zr,e,"argument-error"),Ut(e,await ni(e,t,i))):Ut(e,t),"PHONE_PROVIDER").catch(e=>Promise.reject(e)))).sessionInfo}finally{null!=i&&i._reset()}}async function ni(e,t,r){m(r.type===Zr,e,"argument-error");var i,n,s,r=await r.verify(),e=(m("string"==typeof r,e,"argument-error"),Object.assign({},t));return"phoneEnrollmentInfo"in e?(t=e.phoneEnrollmentInfo.phoneNumber,n=e.phoneEnrollmentInfo.captchaResponse,s=e.phoneEnrollmentInfo.clientType,i=e.phoneEnrollmentInfo.recaptchaVersion,Object.assign(e,{phoneEnrollmentInfo:{phoneNumber:t,recaptchaToken:r,captchaResponse:n,clientType:s,recaptchaVersion:i}})):"phoneSignInInfo"in e?(t=e.phoneSignInInfo.captchaResponse,n=e.phoneSignInInfo.clientType,s=e.phoneSignInInfo.recaptchaVersion,Object.assign(e,{phoneSignInInfo:{recaptchaToken:r,captchaResponse:t,clientType:n,recaptchaVersion:s}})):Object.assign(e,{recaptchaToken:r}),e}class O{constructor(e){this.providerId=O.PROVIDER_ID,this.auth=I(e)}verifyPhoneNumber(e,t){return ii(this.auth,e,s(t))}static credential(e,t){return Ft._fromVerification(e,t)}static credentialFromResult(e){return O.credentialFromTaggedObject(e)}static credentialFromError(e){return O.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){var t;return e&&({phoneNumber:e,temporaryProof:t}=e,e)&&t?Ft._fromTokenResponse(e,t):null}}function si(e,t){return t?_(t):(m(e._popupRedirectResolver,e,"argument-error"),e._popupRedirectResolver)}O.PROVIDER_ID="phone",O.PHONE_SIGN_IN_METHOD="phone";class ai extends Rt{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return T(e,this._buildIdpRequest())}_linkToIdToken(e,t){return T(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return T(e,this._buildIdpRequest())}_buildIdpRequest(e){var 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 oi(e){return Zt(e.auth,new ai(e),e.bypassAuthState)}function li(e){var{auth:t,user:r}=e;return m(r,t,"internal-error"),Qt(r,new ai(e),e.bypassAuthState)}async function ci(e){var{auth:t,user:r}=e;return m(r,t,"internal-error"),$t(r,new ai(e),e.bypassAuthState)}class di{constructor(e,t,r,i,n=!1){this.auth=e,this.resolver=r,this.user=i,this.bypassAuthState=n,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:e,sessionId:t,postBody:r,tenantId:i,error:n,type:s}=e;if(n)this.reject(n);else{n={auth:this.auth,requestUri:e,sessionId:t,tenantId:i||void 0,postBody:r||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(s)(n))}catch(e){this.reject(e)}}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return oi;case"linkViaPopup":case"linkViaRedirect":return ci;case"reauthViaPopup":case"reauthViaRedirect":return li;default:d(this.auth,"internal-error")}}resolve(e){a(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){a(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()}}let ui=new Se(2e3,1e4);class N extends di{constructor(e,t,r,i,n){super(e,t,i,n),this.provider=r,this.authWindow=null,this.pollId=null,N.currentPopupAction&&N.currentPopupAction.cancel(),N.currentPopupAction=this}async executeNotNull(){var e=await this.execute();return m(e,this.auth,"internal-error"),e}async onExecution(){a(1===this.filter.length,"Popup operations only handle one event");var e=Ur();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(u(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return(null==(e=this.authWindow)?void 0:e.associatedEvent)||null}cancel(){this.reject(u(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,N.currentPopupAction=null}pollUserCancellation(){let t=()=>{var e;null!=(e=null==(e=this.authWindow)?void 0:e.window)&&e.closed?this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(u(this.auth,"popup-closed-by-user"))},8e3):this.pollId=window.setTimeout(t,ui.get())};t()}}N.currentPopupAction=null;let hi="pendingRedirect",pi=new Map;class mi extends di{constructor(e,t,r=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,r),this.eventId=null}async execute(){let t=pi.get(this.auth._key());if(!t){try{let e=await(async(e,t)=>{var r;return t=_i(t),!!await(e=vi(e))._isAvailable()&&(r="true"===await e._get(t),await e._remove(t),r)})(this.resolver,this.auth)?await super.execute():null;t=()=>Promise.resolve(e)}catch(e){t=()=>Promise.reject(e)}pi.set(this.auth._key(),t)}return this.bypassAuthState||pi.set(this.auth._key(),()=>Promise.resolve(null)),t()}async onAuthEvent(e){if("signInViaRedirect"===e.type)return super.onAuthEvent(e);if("unknown"===e.type)this.resolve(null);else if(e.eventId){var t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function gi(e,t){return vi(e)._set(_i(t),"true")}function fi(e,t){pi.set(e._key(),t)}function vi(e){return _(e._redirectPersistence)}function _i(e){return y(hi,e.config.apiKey,e.name)}function yi(e,t,r){return(async(e,t,r)=>{var i;return Wn._isFirebaseServerApp(e.app)?Promise.reject(h(e)):(i=I(e),we(e,t,b),await i._initializationPromise,await gi(e=si(i,r),i),e._openRedirect(i,t,"signInViaRedirect"))})(e,t,r)}function Ii(e,t,r){return(async(e,t,r)=>{if(we((e=s(e)).auth,t,b),Wn._isFirebaseServerApp(e.auth.app))return Promise.reject(h(e.auth));await e.auth._initializationPromise;await gi(r=si(e.auth,r),e.auth);var i=await Ei(e);return r._openRedirect(e.auth,t,"reauthViaRedirect",i)})(e,t,r)}function wi(e,t,r){return(async(e,t,r)=>{we((e=s(e)).auth,t,b),await e.auth._initializationPromise;var r=si(e.auth,r),i=(await Xt(!1,e,t.providerId),await gi(r,e.auth),await Ei(e));return r._openRedirect(e.auth,t,"linkViaRedirect",i)})(e,t,r)}async function Ti(e,t,r=!1){var i;return Wn._isFirebaseServerApp(e.app)?Promise.reject(h(e)):(i=si(e=I(e),t),(i=await new mi(e,i,r).execute())&&!r&&(delete i.user._redirectEventId,await e._persistUserIfCurrent(i.user),await e._setRedirectUser(null,t)),i)}async function Ei(e){var t=Ur(e.uid+":::");return e._redirectEventId=t,await e.auth._setRedirectUser(e),await e.auth._persistUserIfCurrent(e),t}class bi{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 r=!1;return this.consumers.forEach(e=>{this.isEventForConsumer(t,e)&&(r=!0,this.sendToConsumer(t,e),this.saveEventToCache(t))}),this.hasHandledPotentialRedirect||!(e=>{switch(e.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return 1;case"unknown":return Si(e);default:return}})(t)||(this.hasHandledPotentialRedirect=!0,r)||(this.queuedRedirectEvent=t,r=!0),r}sendToConsumer(e,t){var r;e.error&&!Si(e)?(r=(null==(r=e.error.code)?void 0:r.split("auth/")[1])||"internal-error",t.onError(u(this.auth,r))):t.onAuthEvent(e)}isEventForConsumer(e,t){var r=null===t.eventId||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&r}hasEventBeenHandled(e){return 6e5<=Date.now()-this.lastProcessedEventTime&&this.cachedEventUids.clear(),this.cachedEventUids.has(ki(e))}saveEventToCache(e){this.cachedEventUids.add(ki(e)),this.lastProcessedEventTime=Date.now()}}function ki(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(e=>e).join("-")}function Si({type:e,error:t}){return"unknown"===e&&"auth/no-auth-event"===(null==t?void 0:t.code)}async function Ri(e,t={}){return p(e,"GET","/v1/projects",t)}let Ai=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,Pi=/^https?/;async function Ci(e){if(!e.config.emulator){var t,r=(await Ri(e)).authorizedDomains;for(t of r)try{if((e=>{var t,r=Ee(),{protocol:i,hostname:n}=new URL(r);return e.startsWith("chrome-extension://")?""===(t=new URL(e)).hostname&&""===n?"chrome-extension:"===i&&e.replace("chrome-extension://","")===r.replace("chrome-extension://",""):"chrome-extension:"===i&&t.hostname===n:Pi.test(i)&&(Ai.test(e)?n===e:(r=e.replace(/\./g,"\\."),(t=new RegExp("^(.+\\."+r+"|"+r+")$","i")).test(n)))})(t))return}catch(e){}d(e,"unauthorized-domain")}}let Oi=new Se(3e4,6e4);function Ni(){var t=C().___jsl;if(null!=t&&t.H)for(var 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<t.CP.length;e++)t.CP[e]=null}function Li(n){return new Promise((e,t)=>{var r;function i(){Ni(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{Ni(),t(u(n,"network-request-failed"))},timeout:Oi.get()})}if(null!=(r=null==(r=C().gapi)?void 0:r.iframes)&&r.Iframe)e(gapi.iframes.getContext());else{if(null==(r=C().gapi)||!r.load)return r=ft("iframefcb"),C()[r]=()=>{gapi.load?i():t(u(n,"network-request-failed"))},gt(mt.gapiScript+"?onload="+r).catch(e=>t(e));i()}}).catch(e=>{throw Di=null,e})}let Di=null;let Ui=new Se(5e3,15e3),Mi="__/auth/iframe",Fi="emulator/auth/iframe",Vi={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},xi=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);async function ji(a){i=a;var e,t,r,i=await(Di=Di||Li(i)),n=C().gapi;return m(n,a,"internal-error"),i.open({where:document.body,url:(m((t=(i=a).config).authDomain,i,"auth-domain-config-required"),e=t.emulator?Re(t,Fi):`https://${i.config.authDomain}/`+Mi,t={apiKey:t.apiKey,appName:i.name,v:Wn.SDK_VERSION},(r=xi.get(i.config.apiHost))&&(t.eid=r),(r=i._getFrameworks()).length&&(t.fw=r.join(",")),e+"?"+te(t).slice(1)),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:Vi,dontclear:!0},s=>new Promise(async(e,t)=>{await s.restyle({setHideOnLeave:!1});let r=u(a,"network-request-failed"),i=C().setTimeout(()=>{t(r)},Ui.get());function n(){C().clearTimeout(i),e(s)}s.ping(n).then(n,()=>{t(r)})}))}let Hi={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class Wi{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(e){}}}function qi(e,t,r,i=500,n=600){var s=Math.max((window.screen.availHeight-n)/2,0).toString(),a=Math.max((window.screen.availWidth-i)/2,0).toString();let o="";var i=Object.assign(Object.assign({},Hi),{width:i.toString(),height:n.toString(),top:s,left:a}),n=l().toLowerCase(),s=(r&&(o=rt(n)?"_blank":r),et(n)&&(t=t||"http://localhost",i.scrollbars="yes"),Object.entries(i).reduce((e,[t,r])=>""+e+t+`=${r},`,""));if([a=l()]=[n],ot(a)&&null!=(a=window.navigator)&&a.standalone&&"_self"!==o)return r=t||"",i=o,(n=document.createElement("a")).href=r,n.target=i,(r=document.createEvent("MouseEvent")).initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(r),new Wi(null);a=window.open(t||"",o,s);m(a,e,"popup-blocked");try{a.focus()}catch(e){}return new Wi(a)}let Bi="__/auth/handler",zi="emulator/auth/handler",Gi=encodeURIComponent("fac");async function Ki(e,t,r,i,n,s){m(e.config.authDomain,e,"auth-domain-config-required"),m(e.config.apiKey,e,"invalid-api-key");var a={apiKey:e.config.apiKey,appName:e.name,authType:r,redirectUrl:i,v:Wn.SDK_VERSION,eventId:n};if(t instanceof b){t.setDefaultLanguage(e.languageCode),a.providerId=t.providerId||"",(e=>{for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return;return 1})(t.getCustomParameters())||(a.customParameters=JSON.stringify(t.getCustomParameters()));for(var[o,l]of Object.entries(s||{}))a[o]=l}t instanceof jt&&0<(r=t.getScopes().filter(e=>""!==e)).length&&(a.scopes=r.join(",")),e.tenantId&&(a.tid=e.tenantId);var c,d=a;for(c of Object.keys(d))void 0===d[c]&&delete d[c];i=await e._getAppCheckToken(),n=i?`#${Gi}=`+encodeURIComponent(i):"";return`${s=[e.config][0],s.emulator?Re(s,zi):`https://${s.authDomain}/`+Bi}?`+te(d).slice(1)+n}let Ji="webStorageSupport";class Yi{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Lr,this._completeRedirectFn=Ti,this._overrideRedirectResult=fi}async _openPopup(e,t,r,i){a(null==(n=this.eventManagers[e._key()])?void 0:n.manager,"_initialize() not called before _openPopup()");var n=await Ki(e,t,r,Ee(),i);return qi(e,n,Ur())}async _openRedirect(e,t,r,i){await this._originValidation(e);e=await Ki(e,t,r,Ee(),i);return C().location.href=e,new Promise(()=>{})}_initialize(e){let r=e._key();if(this.eventManagers[r]){let{manager:e,promise:t}=this.eventManagers[r];return e?Promise.resolve(e):(a(t,"If manager is not set, promise should be"),t)}let t=this.initAndGetManager(e);return this.eventManagers[r]={promise:t},t.catch(()=>{delete this.eventManagers[r]}),t}async initAndGetManager(t){var e=await ji(t);let r=new bi(t);return e.register("authEvent",e=>(m(null==e?void 0:e.authEvent,t,"invalid-auth-event"),{status:r.onEvent(e.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[t._key()]={manager:r},this.iframes[t._key()]=e,r}_isIframeWebStorageSupported(t,r){this.iframes[t._key()].send(Ji,{type:Ji},e=>{e=null==(e=null==e?void 0:e[0])?void 0:e[Ji];void 0!==e&&r(!!e),d(t,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){var t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=Ci(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return lt()||tt()||ot()}}let $i=Yi;class Xi extends class{constructor(e){this.factorId=e}_process(e,t,r){switch(t.type){case"enroll":return this._finalizeEnroll(e,t.credential,r);case"signin":return this._finalizeSignIn(e,t.credential);default:return n("unexpected MultiFactorSessionType")}}}{constructor(e){super("phone"),this.credential=e}static _fromCredential(e){return new Xi(e)}_finalizeEnroll(e,t,r){return e=e,t={idToken:t,displayName:r,phoneVerificationInfo:this.credential._makeVerificationRequest()},p(e,"POST","/v2/accounts/mfaEnrollment:finalize",o(e,t))}_finalizeSignIn(e,t){return e=e,t={mfaPendingCredential:t,phoneVerificationInfo:this.credential._makeVerificationRequest()},p(e,"POST","/v2/accounts/mfaSignIn:finalize",o(e,t))}}class Qi{constructor(){}static assertion(e){return Xi._fromCredential(e)}}Qi.FACTOR_ID="phone";var e="@firebase/auth";class Zi{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),(null==(e=this.auth.currentUser)?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.stsTokenManager.accessToken)||null)}),this.internalListeners.set(t,e),this.updateProactiveRefresh())}removeAuthTokenListener(e){this.assertAuthConfigured();var t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){m(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){0<this.internalListeners.size?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}var en,tn;function rn(){return window}en="authIdTokenMaxAge",null!=(vn=z())&&vn["_"+en],mt={loadJS(i){return new Promise((e,r)=>{var t=document.createElement("script");t.setAttribute("src",i),t.onload=e,t.onerror=e=>{var t=u("internal-error");t.customData=e,r(t)},t.type="text/javascript",t.charset="UTF-8",(null!=(e=null==(e=document.getElementsByTagName("head"))?void 0:e[0])?e:document).appendChild(t)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="},tn="Browser",Wn._registerComponent(new ue("auth",(e,{options:t})=>{var r=e.getProvider("app").getImmediate(),i=e.getProvider("heartbeat"),e=e.getProvider("app-check-internal"),{apiKey:n,authDomain:s}=r.options,n=(m(n&&!n.includes(":"),"invalid-api-key",{appName:r.name}),{apiKey:n,authDomain:s,clientPlatform:tn,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:ct(tn)}),s=new ht(r,i,e,n);return r=s,e=(null==(i=t)?void 0:i.persistence)||[],e=(Array.isArray(e)?e:[e]).map(_),null!=i&&i.errorMap&&r._updateErrorMap(i.errorMap),r._initializeWithPersistence(e,null==i?void 0:i.popupRedirectResolver),s},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,r)=>{e.getProvider("auth-internal").initialize()})),Wn._registerComponent(new ue("auth-internal",e=>{var e=I(e.getProvider("auth").getImmediate());return e=e,new Zi(e)},"PRIVATE").setInstantiationMode("EXPLICIT")),Wn.registerVersion(e,"1.9.1",(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}})(tn)),Wn.registerVersion(e,"1.9.1","esm2017");async function nn(e,t,r){var i=rn().BuildInfo,n=(a(t.sessionId,"AuthEvent did not contain a session ID"),await(async e=>(e=(t=>{if(a(/[0-9a-zA-Z]+/.test(t),"Can only convert alpha-numeric strings"),"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);var e=new ArrayBuffer(t.length),r=new Uint8Array(e);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r})(e),e=await crypto.subtle.digest("SHA-256",e),(e=Array.from(new Uint8Array(e))).map(e=>e.toString(16).padStart(2,"0")).join("")))(t.sessionId)),s={};return ot()?s.ibi=i.packageName:nt()?s.apn=i.packageName:d(e,"operation-not-supported-in-this-environment"),i.displayName&&(s.appDisplayName=i.displayName),s.sessionId=n,Ki(e,r,t.type,void 0,null!=(i=t.eventId)?i:void 0,s)}function sn(i){let n=rn().cordova;return new Promise(r=>{n.plugins.browsertab.isAvailable(e=>{let t=null;e?n.plugins.browsertab.openUrl(i):t=n.InAppBrowser.open(i,(e=l(),/(iPad|iPhone|iPod).*OS 7_\d/i.test(e)||/(iPad|iPhone|iPod).*OS 8_\d/i.test(e)?"_blank":"_system"),"location=yes"),r(t)})})}let an=20;class on extends bi{constructor(){super(...arguments),this.passiveListeners=new Set,this.initPromise=new Promise(e=>{this.resolveInitialized=e})}addPassiveListener(e){this.passiveListeners.add(e)}removePassiveListener(e){this.passiveListeners.delete(e)}resetRedirect(){this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1}onEvent(t){return this.resolveInitialized(),this.passiveListeners.forEach(e=>e(t)),super.onEvent(t)}async initialized(){await this.initPromise}}function ln(e,t,r=null){return{type:t,eventId:r,urlResponse:null,sessionId:(()=>{var t=[],r="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let e=0;e<an;e++){var i=Math.floor(Math.random()*r.length);t.push(r.charAt(i))}return t.join("")})(),postBody:null,tenantId:e.tenantId,error:u(e,"no-auth-event")}}async function cn(e){var t=await un()._get(hn(e));return t&&await un()._remove(hn(e)),t}function dn(e,t){n=pn(t=t),i=n.link?decodeURIComponent(n.link):void 0,r=pn(i).link,n=n.deep_link_id?decodeURIComponent(n.deep_link_id):void 0;var r,i,n=pn(n).link||n||r||i||t;return n.includes("/__/auth/callback")?(t=(i=null==(r=null==(t=null==(i=(r=pn(n)).firebaseError?(e=>{try{return JSON.parse(e)}catch(e){return null}})(decodeURIComponent(r.firebaseError)):null)?void 0:i.code)?void 0:t.split("auth/"))?void 0:r[1])?u(i):null)?{type:e.type,eventId:e.eventId,tenantId:e.tenantId,error:t,urlResponse:null,sessionId:null,postBody:null}:{type:e.type,eventId:e.eventId,tenantId:e.tenantId,sessionId:e.sessionId,urlResponse:n,postBody:null}:null}function un(){return _(Or)}function hn(e){return y("authEvent",e.config.apiKey,e.name)}function pn(e){var t;return null!=e&&e.includes("?")?([t,...e]=e.split("?"),re(e.join("?"))):{}}class mn{constructor(){this._redirectPersistence=Lr,this._shouldInitProactively=!0,this.eventManagers=new Map,this.originValidationPromises={},this._completeRedirectFn=Ti,this._overrideRedirectResult=fi}async _initialize(e){var t=e._key();let r=this.eventManagers.get(t);return r||(r=new on(e),this.eventManagers.set(t,r),this.attachCallbackListeners(e,r)),r}_openPopup(e){d(e,"operation-not-supported-in-this-environment")}async _openRedirect(e,t,r,i){n=e,a=rn(),m("function"==typeof(null==(s=null==a?void 0:a.universalLinks)?void 0:s.subscribe),n,"invalid-cordova-configuration",{missingPlugin:"cordova-universal-links-plugin-fix"}),m(void 0!==(null==(s=null==a?void 0:a.BuildInfo)?void 0:s.packageName),n,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-buildInfo"}),m("function"==typeof(null==(s=null==(s=null==(s=null==a?void 0:a.cordova)?void 0:s.plugins)?void 0:s.browsertab)?void 0:s.openUrl),n,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-browsertab"}),m("function"==typeof(null==(s=null==(s=null==(s=null==a?void 0:a.cordova)?void 0:s.plugins)?void 0:s.browsertab)?void 0:s.isAvailable),n,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-browsertab"}),m("function"==typeof(null==(a=null==(s=null==a?void 0:a.cordova)?void 0:s.InAppBrowser)?void 0:a.open),n,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-inappbrowser"});var n,s=await this._initialize(e),a=(await s.initialized(),s.resetRedirect(),pi.clear(),await this._originValidation(e),ln(e,r,i)),i=(n=e,r=a,await un()._set(hn(n),r),await nn(e,a,t));return(async(a,o,l)=>{let c=rn().cordova,d=()=>{};try{await new Promise((t,e)=>{let r=null;function i(){t();var e=null==(e=c.plugins.browsertab)?void 0:e.close;"function"==typeof e&&e(),"function"==typeof(null==l?void 0:l.close)&&l.close()}function n(){r=r||window.setTimeout(()=>{e(u(a,"redirect-cancelled-by-user"))},2e3)}function s(){"visible"===(null==document?void 0:document.visibilityState)&&n()}o.addPassiveListener(i),document.addEventListener("resume",n,!1),nt()&&document.addEventListener("visibilitychange",s,!1),d=()=>{o.removePassiveListener(i),document.removeEventListener("resume",n,!1),document.removeEventListener("visibilitychange",s,!1),r&&window.clearTimeout(r)}})}finally{d()}})(e,s,await sn(i))}_isIframeWebStorageSupported(e,t){throw new Error("Method not implemented.")}_originValidation(e){var t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=(async e=>{var t=rn().BuildInfo,r={};ot()?r.iosBundleId=t.packageName:nt()?r.androidPackageName=t.packageName:d(e,"operation-not-supported-in-this-environment"),await Ri(e,r)})(e)),this.originValidationPromises[t]}attachCallbackListeners(i,n){var{universalLinks:e,handleOpenURL:t,BuildInfo:r}=rn();let s=setTimeout(async()=>{await cn(i),n.onEvent(fn())},500),a=async e=>{clearTimeout(s);var t=await cn(i);let r=null;t&&null!=e&&e.url&&(r=dn(t,e.url)),n.onEvent(r||fn())},o=(void 0!==e&&"function"==typeof e.subscribe&&e.subscribe(null,a),t),l=r.packageName.toLowerCase()+"://";rn().handleOpenURL=async e=>{if(e.toLowerCase().startsWith(l)&&a({url:e}),"function"==typeof o)try{o(e)}catch(e){console.error(e)}}}}let gn=mn;function fn(){return{type:"unknown",eventId:null,sessionId:null,urlResponse:null,postBody:null,tenantId:null,error:u("no-auth-event")}}var vn;function _n(){var e;return(null==(e=null==self?void 0:self.location)?void 0:e.protocol)||null}function yn(e=l()){return!("file:"!==_n()&&"ionic:"!==_n()&&"capacitor:"!==_n()||!e.toLowerCase().match(/iphone|ipad|ipod|android/))}function In(e=l()){return Y()&&11===(null==document?void 0:document.documentMode)||([e=l()]=[e],/Edge\/\d+/.test(e))}function wn(){try{var e=self.localStorage,t=Ur();if(e)return e.setItem(t,"1"),e.removeItem(t),!In()||$()}catch(e){return Tn()&&$()}return!1}function Tn(){return"undefined"!=typeof global&&"WorkerGlobalScope"in global&&"importScripts"in global}function En(){return("http:"===_n()||"https:"===_n()||K()||yn())&&!(J()||G())&&wn()&&!Tn()}function bn(){return yn()&&"undefined"!=typeof document}let L={LOCAL:"local",NONE:"none",SESSION:"session"},kn=m,Sn="persistence";async function Rn(e){await e._initializationPromise;var t=An(),r=y(Sn,e.config.apiKey,e.name);t&&t.setItem(r,e._getPersistence())}function An(){var e;try{return(null===(e="undefined"!=typeof window?window:null)?void 0:e.sessionStorage)||null}catch(e){return null}}let Pn=m;class D{constructor(){this.browserResolver=_($i),this.cordovaResolver=_(gn),this.underlyingResolver=null,this._redirectPersistence=Lr,this._completeRedirectFn=Ti,this._overrideRedirectResult=fi}async _initialize(e){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._initialize(e)}async _openPopup(e,t,r,i){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._openPopup(e,t,r,i)}async _openRedirect(e,t,r,i){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._openRedirect(e,t,r,i)}_isIframeWebStorageSupported(e,t){this.assertedUnderlyingResolver._isIframeWebStorageSupported(e,t)}_originValidation(e){return this.assertedUnderlyingResolver._originValidation(e)}get _shouldInitProactively(){return bn()||this.browserResolver._shouldInitProactively}get assertedUnderlyingResolver(){return Pn(this.underlyingResolver,"internal-error"),this.underlyingResolver}async selectUnderlyingResolver(){var e;this.underlyingResolver||(e=await(!!bn()&&new Promise(e=>{let t=setTimeout(()=>{e(!1)},1e3);document.addEventListener("deviceready",()=>{clearTimeout(t),e(!0)})})),this.underlyingResolver=e?this.cordovaResolver:this.browserResolver)}}function Cn(e){return e.unwrap()}function On(e,t){var r,i,n=null==(n=t.customData)?void 0:n._tokenResponse;"auth/multi-factor-auth-required"===(null==t?void 0:t.code)?t.resolver=new Dn(e,(r=t,e=s(e=e),m((i=r).customData.operationType,e,"argument-error"),m(null==(r=i.customData._serverResponse)?void 0:r.mfaPendingCredential,e,"argument-error"),br._fromError(e,i))):n&&(e=Nn(r=t))&&(r.credential=e,r.tenantId=n.tenantId||void 0,r.email=n.email||void 0,r.phoneNumber=n.phoneNumber||void 0)}function Nn(e){var t=(e instanceof c?e.customData:e)._tokenResponse;if(!t)return null;if(!(e instanceof c)&&"temporaryProof"in t&&"phoneNumber"in t)return O.credentialFromResult(e);var r=t.providerId;if(!r||r===he.PASSWORD)return null;let i;switch(r){case he.GOOGLE:i=S;break;case he.FACEBOOK:i=k;break;case he.GITHUB:i=R;break;case he.TWITTER:i=A;break;default:var{oauthIdToken:n,oauthAccessToken:s,oauthTokenSecret:a,pendingToken:o,nonce:l}=t;return s||a||n||o?o?r.startsWith("saml.")?Wt._create(r,o):E._fromParams({providerId:r,signInMethod:r,pendingToken:o,idToken:n,accessToken:s}):new Ht(r).credential({idToken:n,accessToken:s,rawNonce:l}):null}return e instanceof c?i.credentialFromError(e):i.credentialFromResult(e)}function U(t,e){return e.catch(e=>{throw e instanceof c&&On(t,e),e}).then(e=>{var t=e.operationType,r=e.user;return{operationType:t,credential:Nn(e),additionalUserInfo:Tr(e),user:M.getOrCreate(r)}})}async function Ln(t,e){let r=await e;return{verificationId:r.verificationId,confirm:e=>U(t,r.confirm(e))}}class Dn{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 U(Cn(this.auth),this.resolver.resolveSignIn(e))}}class M{constructor(e){this._delegate=e,this.multiFactor=(e=s(e=e),Rr.has(e)||Rr.set(e,Sr._fromUser(e)),Rr.get(e))}static getOrCreate(e){return M.USER_MAP.has(e)||M.USER_MAP.set(e,new M(e)),M.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 U(this.auth,tr(this._delegate,e))}async linkWithPhoneNumber(e,t){return Ln(this.auth,(async(e,t,r)=>{let i=s(e);return await Xt(!1,i,"phone"),e=await ii(i.auth,t,s(r)),new ri(e,e=>tr(i,e))})(this._delegate,e,t))}async linkWithPopup(e){return U(this.auth,(async(e,t,r)=>(we((e=s(e)).auth,t,b),r=si(e.auth,r),new N(e.auth,"linkViaPopup",t,r,e).executeNotNull()))(this._delegate,e,D))}async linkWithRedirect(e){return await Rn(I(this.auth)),wi(this._delegate,e,D)}reauthenticateAndRetrieveDataWithCredential(e){return this.reauthenticateWithCredential(e)}async reauthenticateWithCredential(e){return U(this.auth,rr(this._delegate,e))}reauthenticateWithPhoneNumber(e,t){return Ln(this.auth,(async(e,t,r)=>{let i=s(e);return Wn._isFirebaseServerApp(i.auth.app)?Promise.reject(h(i.auth)):(e=await ii(i.auth,t,s(r)),new ri(e,e=>rr(i,e)))})(this._delegate,e,t))}reauthenticateWithPopup(e){return U(this.auth,(async(e,t,r)=>(e=s(e),Wn._isFirebaseServerApp(e.auth.app)?Promise.reject(u(e.auth,"operation-not-supported-in-this-environment")):(we(e.auth,t,b),r=si(e.auth,r),new N(e.auth,"reauthViaPopup",t,r,e).executeNotNull())))(this._delegate,e,D))}async reauthenticateWithRedirect(e){return await Rn(I(this.auth)),Ii(this._delegate,e,D)}sendEmailVerification(e){return hr(this._delegate,e)}async unlink(e){return await Yt(this._delegate,e),this}updateEmail(e){return t=this._delegate,e=e,t=s(t),Wn._isFirebaseServerApp(t.auth.app)?Promise.reject(h(t.auth)):gr(t,e,null);var t}updatePassword(e){return gr(s(this._delegate),null,e)}updatePhoneNumber(e){return(async(e,t)=>{if(e=s(e),Wn._isFirebaseServerApp(e.auth.app))return Promise.reject(h(e.auth));await $t(e,t)})(this._delegate,e)}updateProfile(e){return mr(this._delegate,e)}verifyBeforeUpdateEmail(e,t){return pr(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}}M.USER_MAP=new WeakMap;let Un=m;class Mn{constructor(e,t){var r,i;this.app=e,t.isInitialized()?this._delegate=t.getImmediate():(r=e.options.apiKey,Un(r,"invalid-api-key",{appName:e.name}),Un(r,"invalid-api-key",{appName:e.name}),i="undefined"!=typeof window?D:void 0,this._delegate=t.initialize({options:{persistence:((e,t)=>{var r=((e,t)=>{var r=An();if(!r)return[];switch(e=y(Sn,e,t),r.getItem(e)){case L.NONE:return[Xe];case L.LOCAL:return[Kr,Lr];case L.SESSION:return[Lr];default:return[]}})(e,t);if("undefined"==typeof self||r.includes(Kr)||r.push(Kr),"undefined"!=typeof window)for(var i of[Or,Lr])r.includes(i)||r.push(i);return r.includes(Xe)||r.push(Xe),r})(r,e.name),popupRedirectResolver:i}}),this._delegate._updateErrorMap(ge)),this.linkUnderlyingAuth()}get emulatorConfig(){return this._delegate.emulatorConfig}get currentUser(){return this._delegate.currentUser?M.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){bt(this._delegate,e,t)}applyActionCode(e){return cr(this._delegate,e)}checkActionCode(e){return dr(this._delegate,e)}confirmPasswordReset(e,t){return(async(t,e,r)=>{await At(s(t),{oobCode:e,newPassword:r}).catch(async e=>{throw"auth/password-does-not-meet-requirements"===e.code&&lr(t),e})})(this._delegate,e,t)}async createUserWithEmailAndPassword(e,t){return U(this._delegate,(async(t,e,r)=>{var i;return Wn._isFirebaseServerApp(t.app)?Promise.reject(h(t)):(e=await w(i=I(t),{returnSecureToken:!0,email:e,password:r,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",Bt,"EMAIL_PASSWORD_PROVIDER").catch(e=>{throw"auth/password-does-not-meet-requirements"===e.code&&lr(t),e}),r=await P._fromIdTokenResponse(i,"signIn",e),await i._updateCurrentUser(r.user),r)})(this._delegate,e,t))}fetchProvidersForEmail(e){return this.fetchSignInMethodsForEmail(e)}fetchSignInMethodsForEmail(e){return ur(this._delegate,e)}isSignInWithEmailLink(e){return this._delegate,e=e,"EMAIL_SIGNIN"===(null==(e=Vt.parseLink(e))?void 0:e.operation)}async getRedirectResult(){Un(En(),this._delegate,"operation-not-supported-in-this-environment");t=this._delegate,e=D,await I(t)._initializationPromise;var e,t=await Ti(t,e,!1);return t?U(this._delegate,Promise.resolve(t)):{credential:null,user:null}}addFrameworkForLogging(e){I(this._delegate)._logFramework(e)}onAuthStateChanged(e,t,r){var{next:e,error:t,complete:r}=Fn(e,t,r);return this._delegate.onAuthStateChanged(e,t,r)}onIdTokenChanged(e,t,r){var{next:e,error:t,complete:r}=Fn(e,t,r);return this._delegate.onIdTokenChanged(e,t,r)}sendSignInLinkToEmail(e,t){return(async(e,t,r)=>{let i=I(e);t=e={requestType:"EMAIL_SIGNIN",email:t,clientType:"CLIENT_TYPE_WEB"},m((r=r).handleCodeInApp,i,"argument-error"),r&&or(i,t,r),await w(i,e,"getOobCode",Lt,"EMAIL_PASSWORD_PROVIDER")})(this._delegate,e,t)}sendPasswordResetEmail(e,t){return(async(e,t,r)=>{e=I(e),t={requestType:"PASSWORD_RESET",email:t,clientType:"CLIENT_TYPE_WEB"},r&&or(e,t,r),await w(e,t,"getOobCode",Nt,"EMAIL_PASSWORD_PROVIDER")})(this._delegate,e,t||void 0)}async setPersistence(e){var t,r;t=this._delegate,r=e,kn(Object.values(L).includes(r),t,"invalid-persistence-type"),J()?kn(r!==L.SESSION,t,"unsupported-persistence-type"):G()?kn(r===L.NONE,t,"unsupported-persistence-type"):Tn()?kn(r===L.NONE||r===L.LOCAL&&$(),t,"unsupported-persistence-type"):kn(r===L.NONE||wn(),t,"unsupported-persistence-type");let i;switch(e){case L.SESSION:i=Lr;break;case L.LOCAL:var n=await _(Kr)._isAvailable();i=n?Kr:Or;break;case L.NONE:i=Xe;break;default:return d("argument-error",{appName:this._delegate.name})}return this._delegate.setPersistence(i)}signInAndRetrieveDataWithCredential(e){return this.signInWithCredential(e)}signInAnonymously(){return U(this._delegate,(async e=>{var t;return Wn._isFirebaseServerApp(e.app)?Promise.reject(h(e)):(await(e=I(e))._initializationPromise,null!=(t=e.currentUser)&&t.isAnonymous?new P({user:e.currentUser,providerId:null,operationType:"signIn"}):(t=await Bt(e,{returnSecureToken:!0}),t=await P._fromIdTokenResponse(e,"signIn",t,!0),await e._updateCurrentUser(t.user),t))})(this._delegate))}signInWithCredential(e){return U(this._delegate,er(this._delegate,e))}signInWithCustomToken(e){return U(this._delegate,ir(this._delegate,e))}signInWithEmailAndPassword(e,t){return U(this._delegate,(r=this._delegate,e=e,t=t,Wn._isFirebaseServerApp(r.app)?Promise.reject(h(r)):er(s(r),xt.credential(e,t)).catch(async e=>{throw"auth/password-does-not-meet-requirements"===e.code&&lr(r),e})));var r}signInWithEmailLink(e,t){return U(this._delegate,(async(e,t,r)=>Wn._isFirebaseServerApp(e.app)?Promise.reject(h(e)):(e=s(e),m((t=xt.credentialWithLink(t,r||Ee()))._tenantId===(e.tenantId||null),e,"tenant-id-mismatch"),er(e,t)))(this._delegate,e,t))}signInWithPhoneNumber(e,t){return Ln(this._delegate,(async(e,t,r)=>{if(Wn._isFirebaseServerApp(e.app))return Promise.reject(h(e));let i=I(e);return e=await ii(i,t,s(r)),new ri(e,e=>er(i,e))})(this._delegate,e,t))}async signInWithPopup(e){return Un(En(),this._delegate,"operation-not-supported-in-this-environment"),U(this._delegate,(async(e,t,r)=>{var i;return Wn._isFirebaseServerApp(e.app)?Promise.reject(u(e,"operation-not-supported-in-this-environment")):(i=I(e),we(e,t,b),e=si(i,r),new N(i,"signInViaPopup",t,e).executeNotNull())})(this._delegate,e,D))}async signInWithRedirect(e){return Un(En(),this._delegate,"operation-not-supported-in-this-environment"),await Rn(this._delegate),yi(this._delegate,e,D)}updateCurrentUser(e){return this._delegate.updateCurrentUser(e)}verifyPasswordResetCode(e){return(async(e,t)=>(e=(await dr(s(e),t)).data).email)(this._delegate,e)}unwrap(){return this._delegate}_delete(){return this._delegate._delete()}linkUnderlyingAuth(){this._delegate.wrapped=()=>this}}function Fn(e,t,r){let i=e,n=("function"!=typeof e&&({next:i,error:t,complete:r}=e),i);return{next:e=>n(e&&M.getOrCreate(e)),error:t,complete:r}}Mn.Persistence=L;class Vn{static credential(e,t){return O.credential(e,t)}constructor(){this.providerId="phone",this._delegate=new O(Cn(F.default.auth()))}verifyPhoneNumber(e,t){return this._delegate.verifyPhoneNumber(e,t)}unwrap(){return this._delegate}}Vn.PHONE_SIGN_IN_METHOD=O.PHONE_SIGN_IN_METHOD,Vn.PROVIDER_ID=O.PROVIDER_ID;let xn=m;class jn{constructor(e,t,r=F.default.app()){var i;xn(null==(i=r.options)?void 0:i.apiKey,"invalid-api-key",{appName:r.name}),this._delegate=new ti(r.auth(),e,t),this.type=this._delegate.type}clear(){this._delegate.clear()}render(){return this._delegate.render()}verify(){return this._delegate.verify()}}(vn=F.default).INTERNAL.registerComponent(new ue("auth-compat",e=>{var t=e.getProvider("app-compat").getImmediate(),e=e.getProvider("auth");return new Mn(t,e)},"PUBLIC").setServiceProps({ActionCodeInfo:{Operation:{EMAIL_SIGNIN:pe.EMAIL_SIGNIN,PASSWORD_RESET:pe.PASSWORD_RESET,RECOVER_EMAIL:pe.RECOVER_EMAIL,REVERT_SECOND_FACTOR_ADDITION:pe.REVERT_SECOND_FACTOR_ADDITION,VERIFY_AND_CHANGE_EMAIL:pe.VERIFY_AND_CHANGE_EMAIL,VERIFY_EMAIL:pe.VERIFY_EMAIL}},EmailAuthProvider:xt,FacebookAuthProvider:k,GithubAuthProvider:R,GoogleAuthProvider:S,OAuthProvider:Ht,SAMLAuthProvider:qt,PhoneAuthProvider:Vn,PhoneMultiFactorGenerator:Qi,RecaptchaVerifier:jn,TwitterAuthProvider:A,Auth:Mn,AuthCredential:Rt,Error:c}).setInstantiationMode("LAZY").setMultipleInstances(!1)),vn.registerVersion("@firebase/auth-compat","0.5.19")}.apply(this,arguments)}catch(e){throw console.error(e),new Error("Cannot instantiate firebase-auth.js - be sure to load firebase-app.js first.")}});//# sourceMappingURL=firebase-auth.js.map
1
+ ((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(Wn,qn){try{!function(){function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var F=t(Wn);let V=()=>{},x={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray(i,e){if(!Array.isArray(i))throw Error("encodeByteArray takes an array as a parameter");this.init_();var n=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,s=[];for(let r=0;r<i.length;r+=3){var a=i[r],o=r+1<i.length,l=o?i[r+1]:0,c=r+2<i.length,u=c?i[r+2]:0;let e=(15&l)<<2|u>>6,t=63&u;c||(t=64,o)||(e=64),s.push(n[a>>2],n[(3&a)<<4|l>>4],n[e],n[t])}return s.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray((r=>{var i=[];let n=0;for(let t=0;t<r.length;t++){let e=r.charCodeAt(t);e<128?i[n++]=e:(e<2048?i[n++]=e>>6|192:(55296==(64512&e)&&t+1<r.length&&56320==(64512&r.charCodeAt(t+1))?(e=65536+((1023&e)<<10)+(1023&r.charCodeAt(++t)),i[n++]=e>>18|240,i[n++]=e>>12&63|128):i[n++]=e>>12|224,i[n++]=e>>6&63|128),i[n++]=63&e|128)}return i})(e),t)},decodeString(r,i){if(this.HAS_NATIVE_SUPPORT&&!i)return atob(r);{var n=this.decodeStringToByteArray(r,i);var s=[];let e=0,t=0;for(;e<n.length;){var a,o,l,c=n[e++];c<128?s[t++]=String.fromCharCode(c):191<c&&c<224?(a=n[e++],s[t++]=String.fromCharCode((31&c)<<6|63&a)):239<c&&c<365?(a=((7&c)<<18|(63&n[e++])<<12|(63&n[e++])<<6|63&n[e++])-65536,s[t++]=String.fromCharCode(55296+(a>>10)),s[t++]=String.fromCharCode(56320+(1023&a))):(o=n[e++],l=n[e++],s[t++]=String.fromCharCode((15&c)<<12|(63&o)<<6|63&l))}return s.join("");return}},decodeStringToByteArray(t,e){this.init_();var r=e?this.charToByteMapWebSafe_:this.charToByteMap_,i=[];for(let e=0;e<t.length;){var n=r[t.charAt(e++)],s=e<t.length?r[t.charAt(e)]:0,a=++e<t.length?r[t.charAt(e)]:64,o=++e<t.length?r[t.charAt(e)]:64;if(++e,null==n||null==s||null==a||null==o)throw new j;i.push(n<<2|s>>4),64!==a&&(i.push(s<<4&240|a>>2),64!==o)&&i.push(a<<6&192|o)}return i},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),(this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e)>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class j extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}let H=function(e){try{return x.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};let W=()=>(()=>{if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("Unable to locate global object.")})().__FIREBASE_DEFAULTS__,q=()=>{var e;return"undefined"!=typeof process&&void 0!==process.env&&(e=process.env.__FIREBASE_DEFAULTS__)?JSON.parse(e):void 0},B=()=>{if("undefined"!=typeof document){let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}var t=e&&H(e[1]);return t&&JSON.parse(t)}},z=()=>{try{return V()||W()||q()||B()}catch(e){console.info("Unable to get __FIREBASE_DEFAULTS__ due to: "+e)}};var i;function l(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function G(){var e=null==(e=z())?void 0:e.forceEnvironment;if("node"===e)return!0;if("browser"===e)return!1;try{return"[object process]"===Object.prototype.toString.call(global.process)}catch(e){return!1}}function K(){var e="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof e&&void 0!==e.id}function J(){return"object"==typeof navigator&&"ReactNative"===navigator.product}function Y(){var e=l();return 0<=e.indexOf("MSIE ")||0<=e.indexOf("Trident/")}function $(){try{return"object"==typeof indexedDB}catch(e){return!1}}class c extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name="FirebaseError",Object.setPrototypeOf(this,c.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,X.prototype.create)}}class X{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){var i,t=t[0]||{},r=this.service+"/"+e,e=this.errors[e],e=e?(i=t,e.replace(Q,(e,t)=>{var r=i[t];return null!=r?String(r):`<${t}?>`})):"Error",e=this.serviceName+`: ${e} (${r}).`;return new c(r,e,t)}}let Q=/\{\$([^}]+)}/g;function Z(e,t){if(e!==t){var r,i,n=Object.keys(e),s=Object.keys(t);for(r of n){if(!s.includes(r))return!1;var a=e[r],o=t[r];if(ee(a)&&ee(o)){if(!Z(a,o))return!1}else if(a!==o)return!1}for(i of s)if(!n.includes(i))return!1}return!0}function ee(e){return null!==e&&"object"==typeof e}function te(r){let i=[];for(let[t,e]of Object.entries(r))Array.isArray(e)?e.forEach(e=>{i.push(encodeURIComponent(t)+"="+encodeURIComponent(e))}):i.push(encodeURIComponent(t)+"="+encodeURIComponent(e));return i.length?"&"+i.join("&"):""}function re(e){let r={};return e.replace(/^\?/,"").split("&").forEach(e=>{var t;e&&([e,t]=e.split("="),r[decodeURIComponent(e)]=decodeURIComponent(t))}),r}function ie(e){var t,r=e.indexOf("?");return r?(t=e.indexOf("#",r),e.substring(r,0<t?t:void 0)):""}class ne{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(t){this.forEachObserver(e=>{e.next(t)})}error(t){this.forEachObserver(e=>{e.error(t)}),this.close(t)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let i;if(void 0===e&&void 0===t&&void 0===r)throw new Error("Missing Observer.");void 0===(i=((e,t)=>{if("object"==typeof e&&null!==e)for(var r of t)if(r in e&&"function"==typeof e[r])return 1})(e,["next","error","complete"])?e:{next:e,error:t,complete:r}).next&&(i.next=se),void 0===i.error&&(i.error=se),void 0===i.complete&&(i.complete=se);e=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?i.error(this.finalError):i.complete()}catch(e){}}),this.observers.push(i),e}unsubscribeOne(e){void 0!==this.observers&&void 0!==this.observers[e]&&(delete this.observers[e],--this.observerCount,0===this.observerCount)&&void 0!==this.onNoObservers&&this.onNoObservers(this)}forEachObserver(t){if(!this.finalized)for(let e=0;e<this.observers.length;e++)this.sendOne(e,t)}sendOne(e,t){this.task.then(()=>{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 se(){}function s(e){return e&&e._delegate?e._delegate:e}(e=i=i||{})[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";let ae={debug:i.DEBUG,verbose:i.VERBOSE,info:i.INFO,warn:i.WARN,error:i.ERROR,silent:i.SILENT},oe=i.INFO,le={[i.DEBUG]:"log",[i.VERBOSE]:"log",[i.INFO]:"info",[i.WARN]:"warn",[i.ERROR]:"error"},ce=(e,t,...r)=>{if(!(t<e.logLevel)){var i=(new Date).toISOString(),n=le[t];if(!n)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[n](`[${i}] ${e.name}:`,...r)}};function ue(e,t){var r={};for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r}class de{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}}let he={FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PASSWORD:"password",PHONE:"phone",TWITTER:"twitter.com"},pe={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"};function me(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}function ge(){return{"admin-restricted-operation":"This operation is restricted to administrators only.","argument-error":"","app-not-authorized":"This app, identified by the domain where it's hosted, is not authorized to use Firebase Authentication with the provided API key. Review your key configuration in the Google API console.","app-not-installed":"The requested mobile application corresponding to the identifier (Android package name or iOS bundle ID) provided is not installed on this device.","captcha-check-failed":"The reCAPTCHA response token provided is either invalid, expired, already used or the domain associated with it does not match the list of whitelisted domains.","code-expired":"The SMS code has expired. Please re-send the verification code to try again.","cordova-not-ready":"Cordova framework is not ready.","cors-unsupported":"This browser is not supported.","credential-already-in-use":"This credential is already associated with a different user account.","custom-token-mismatch":"The custom token corresponds to a different audience.","requires-recent-login":"This operation is sensitive and requires recent authentication. Log in again before retrying this request.","dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK.","dynamic-link-not-activated":"Please activate Dynamic Links in the Firebase Console and agree to the terms and conditions.","email-change-needs-verification":"Multi-factor users must always have a verified email.","email-already-in-use":"The email address is already in use by another account.","emulator-config-failed":'Auth instance has already been used to make a network call. Auth can no longer be configured to use the emulator. Try calling "connectAuthEmulator()" sooner.',"expired-action-code":"The action code has expired.","cancelled-popup-request":"This operation has been cancelled due to another conflicting popup being opened.","internal-error":"An internal AuthError has occurred.","invalid-app-credential":"The phone verification request contains an invalid application verifier. The reCAPTCHA token response is either invalid or expired.","invalid-app-id":"The mobile app identifier is not registered for the current project.","invalid-user-token":"This user's credential isn't valid for this project. This can happen if the user's token has been tampered with, or if the user isn't for the project associated with this API key.","invalid-auth-event":"An internal AuthError has occurred.","invalid-verification-code":"The SMS verification code used to create the phone auth credential is invalid. Please resend the verification code sms and be sure to use the verification code provided by the user.","invalid-continue-uri":"The continue URL provided in the request is invalid.","invalid-cordova-configuration":"The following Cordova plugins must be installed to enable OAuth sign-in: cordova-plugin-buildinfo, cordova-universal-links-plugin, cordova-plugin-browsertab, cordova-plugin-inappbrowser and cordova-plugin-customurlscheme.","invalid-custom-token":"The custom token format is incorrect. Please check the documentation.","invalid-dynamic-link-domain":"The provided dynamic link domain is not configured or authorized for the current project.","invalid-email":"The email address is badly formatted.","invalid-emulator-scheme":"Emulator URL must start with a valid scheme (http:// or https://).","invalid-api-key":"Your API key is invalid, please check you have copied it correctly.","invalid-cert-hash":"The SHA-1 certificate hash provided is invalid.","invalid-credential":"The supplied auth credential is incorrect, malformed or has expired.","invalid-message-payload":"The email template corresponding to this action contains invalid characters in its message. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-multi-factor-session":"The request does not contain a valid proof of first factor successful sign-in.","invalid-oauth-provider":"EmailAuthProvider is not supported for this operation. This operation only supports OAuth providers.","invalid-oauth-client-id":"The OAuth client ID provided is either invalid or does not match the specified API key.","unauthorized-domain":"This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.","invalid-action-code":"The action code is invalid. This can happen if the code is malformed, expired, or has already been used.","wrong-password":"The password is invalid or the user does not have a password.","invalid-persistence-type":"The specified persistence type is invalid. It can only be local, session or none.","invalid-phone-number":"The format of the phone number provided is incorrect. Please enter the phone number in a format that can be parsed into E.164 format. E.164 phone numbers are written in the format [+][country code][subscriber number including area code].","invalid-provider-id":"The specified provider ID is invalid.","invalid-recipient-email":"The email corresponding to this action failed to send as the provided recipient email address is invalid.","invalid-sender":"The email template corresponding to this action contains an invalid sender email or name. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-verification-id":"The verification ID used to create the phone auth credential is invalid.","invalid-tenant-id":"The Auth instance's tenant ID is invalid.","login-blocked":"Login blocked by user-provided method: {$originalMessage}","missing-android-pkg-name":"An Android Package Name must be provided if the Android App is required to be installed.","auth-domain-config-required":"Be sure to include authDomain when calling firebase.initializeApp(), by following the instructions in the Firebase console.","missing-app-credential":"The phone verification request is missing an application verifier assertion. A reCAPTCHA response token needs to be provided.","missing-verification-code":"The phone auth credential was created with an empty SMS verification code.","missing-continue-uri":"A continue URL must be provided in the request.","missing-iframe-start":"An internal AuthError has occurred.","missing-ios-bundle-id":"An iOS Bundle ID must be provided if an App Store ID is provided.","missing-or-invalid-nonce":"The request does not contain a valid nonce. This can occur if the SHA-256 hash of the provided raw nonce does not match the hashed nonce in the ID token payload.","missing-password":"A non-empty password must be provided","missing-multi-factor-info":"No second factor identifier is provided.","missing-multi-factor-session":"The request is missing proof of first factor successful sign-in.","missing-phone-number":"To send verification codes, provide a phone number for the recipient.","missing-verification-id":"The phone auth credential was created with an empty verification ID.","app-deleted":"This instance of FirebaseApp has been deleted.","multi-factor-info-not-found":"The user does not have a second factor matching the identifier provided.","multi-factor-auth-required":"Proof of ownership of a second factor is required to complete sign-in.","account-exists-with-different-credential":"An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.","network-request-failed":"A network AuthError (such as timeout, interrupted connection or unreachable host) has occurred.","no-auth-event":"An internal AuthError has occurred.","no-such-provider":"User was not linked to an account with the given provider.","null-user":"A null user object was provided as the argument for an operation which requires a non-null user object.","operation-not-allowed":"The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section.","operation-not-supported-in-this-environment":'This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.',"popup-blocked":"Unable to establish a connection with the popup. It may have been blocked by the browser.","popup-closed-by-user":"The popup has been closed by the user before finalizing the operation.","provider-already-linked":"User can only be linked to one identity for the given provider.","quota-exceeded":"The project's quota for this operation has been exceeded.","redirect-cancelled-by-user":"The redirect operation has been cancelled by the user before finalizing.","redirect-operation-pending":"A redirect sign-in operation is already pending.","rejected-credential":"The request contains malformed or mismatching credentials.","second-factor-already-in-use":"The second factor is already enrolled on this account.","maximum-second-factor-count-exceeded":"The maximum allowed number of second factors on a user has been exceeded.","tenant-id-mismatch":"The provided tenant ID does not match the Auth instance's tenant ID",timeout:"The operation has timed out.","user-token-expired":"The user's credential is no longer valid. The user must sign in again.","too-many-requests":"We have blocked all requests from this device due to unusual activity. Try again later.","unauthorized-continue-uri":"The domain of the continue URL is not whitelisted. Please whitelist the domain in the Firebase console.","unsupported-first-factor":"Enrolling a second factor or signing in with a multi-factor account requires sign-in with a supported first factor.","unsupported-persistence-type":"The current environment does not support the specified persistence type.","unsupported-tenant-operation":"This operation is not supported in a multi-tenant context.","unverified-email":"The operation requires a verified email.","user-cancelled":"The user did not grant your application the permissions it requested.","user-not-found":"There is no user record corresponding to this identifier. The user may have been deleted.","user-disabled":"The user account has been disabled by an administrator.","user-mismatch":"The supplied credentials do not correspond to the previously signed in user.","user-signed-out":"","weak-password":"The password must be 6 characters long or more.","web-storage-unsupported":"This browser is not supported or 3rd party cookies and data may be disabled.","already-initialized":"initializeAuth() has already been called with different options. To avoid this error, call initializeAuth() with the same options as when it was originally called, or call getAuth() to return the already initialized instance.","missing-recaptcha-token":"The reCAPTCHA token is missing when sending request to the backend.","invalid-recaptcha-token":"The reCAPTCHA token is invalid when sending request to the backend.","invalid-recaptcha-action":"The reCAPTCHA action is invalid when sending request to the backend.","recaptcha-not-enabled":"reCAPTCHA Enterprise integration is not enabled for this project.","missing-client-type":"The reCAPTCHA client type is missing when sending request to the backend.","missing-recaptcha-version":"The reCAPTCHA version is missing when sending request to the backend.","invalid-req-type":"Invalid request parameters.","invalid-recaptcha-version":"The reCAPTCHA version is invalid when sending request to the backend.","unsupported-password-policy-schema-version":"The password policy received from the backend uses a schema version that is not supported by this version of the Firebase SDK.","password-does-not-meet-requirements":"The password does not meet the requirements.","invalid-hosting-link-domain":"The provided Hosting link domain is not configured in Firebase Hosting or is not owned by the current project. This cannot be a default Hosting domain (`web.app` or `firebaseapp.com`)."}}let fe=me,ve=new X("auth","Firebase",me()),_e=new class{constructor(e){this.name=e,this._logLevel=oe,this._logHandler=ce,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in i))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?ae[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,i.DEBUG,...e),this._logHandler(this,i.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,i.VERBOSE,...e),this._logHandler(this,i.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,i.INFO,...e),this._logHandler(this,i.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,i.WARN,...e),this._logHandler(this,i.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,i.ERROR,...e),this._logHandler(this,i.ERROR,...e)}}("@firebase/auth");function ye(e,...t){_e.logLevel<=i.ERROR&&_e.error(`Auth (${qn.SDK_VERSION}): `+e,...t)}function u(e,...t){throw Te(e,...t)}function d(e,...t){return Te(e,...t)}function Ie(e,t,r){r=Object.assign(Object.assign({},fe()),{[t]:r});return new X("auth","Firebase",r).create(t,{appName:e.name})}function h(e){return Ie(e,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function we(e,t,r){if(!(t instanceof r))throw r.name!==t.constructor.name&&u(e,"argument-error"),Ie(e,"argument-error",`Type of ${t.constructor.name} does not match expected instance.`+"Did you pass a reference from a different Auth SDK?")}function Te(e,...t){var r,i;return"string"!=typeof e?(r=t[0],(i=[...t.slice(1)])[0]&&(i[0].appName=e.name),e._errorFactory.create(r,...i)):ve.create(e,...t)}function m(e,t,...r){if(!e)throw Te(t,...r)}function n(e){e="INTERNAL ASSERTION FAILED: "+e;throw ye(e),new Error(e)}function a(e,t){e||n(t)}function Ee(){var e;return"undefined"!=typeof self&&(null==(e=self.location)?void 0:e.href)||""}function be(){return"http:"===ke()||"https:"===ke()}function ke(){var e;return"undefined"!=typeof self&&(null==(e=self.location)?void 0:e.protocol)||null}class Se{constructor(e,t){a((this.shortDelay=e)<(this.longDelay=t),"Short delay should be less than long delay!"),this.isMobile="undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(l())||J()}get(){return"undefined"!=typeof navigator&&navigator&&"onLine"in navigator&&"boolean"==typeof navigator.onLine&&(be()||K()||"connection"in navigator)&&!navigator.onLine?Math.min(5e3,this.shortDelay):this.isMobile?this.longDelay:this.shortDelay}}function Re(e,t){a(e.emulator,"Emulator should always be set here");e=e.emulator.url;return t?""+e+(t.startsWith("/")?t.slice(1):t):e}class Ae{static initialize(e,t,r){this.fetchImpl=e,t&&(this.headersImpl=t),r&&(this.responseImpl=r)}static fetch(){return this.fetchImpl||("undefined"!=typeof self&&"fetch"in self?self.fetch:"undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch:"undefined"!=typeof fetch?fetch:void n("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill"))}static headers(){return this.headersImpl||("undefined"!=typeof self&&"Headers"in self?self.Headers:"undefined"!=typeof globalThis&&globalThis.Headers?globalThis.Headers:"undefined"!=typeof Headers?Headers:void n("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill"))}static response(){return this.responseImpl||("undefined"!=typeof self&&"Response"in self?self.Response:"undefined"!=typeof globalThis&&globalThis.Response?globalThis.Response:"undefined"!=typeof Response?Response:void n("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill"))}}let Pe={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"},Ce=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],Oe=new Se(3e4,6e4);function o(e,t){return e.tenantId&&!t.tenantId?Object.assign(Object.assign({},t),{tenantId:e.tenantId}):t}async function p(n,s,a,o,e={}){return Ne(n,e,async()=>{let e={},t={};o&&("GET"===s?t=o:e={body:JSON.stringify(o)});var r=te(Object.assign({key:n.config.apiKey},t)).slice(1),i=await n._getAdditionalHeaders(),i=(i["Content-Type"]="application/json",n.languageCode&&(i["X-Firebase-Locale"]=n.languageCode),Object.assign({method:s,headers:i},e));return"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||(i.referrerPolicy="no-referrer"),Ae.fetch()(await Le(n,n.config.apiHost,a,r),i)})}async function Ne(t,e,r){t._canInitEmulator=!1;e=Object.assign(Object.assign({},Pe),e);try{var i=new De(t),n=await Promise.race([r(),i.promise]),s=(i.clearNetworkTimeout(),await n.json());if("needConfirmation"in s)throw Me(t,"account-exists-with-different-credential",s);if(n.ok&&!("errorMessage"in s))return s;var[a,o]=(n.ok?s.errorMessage:s.error.message).split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===a)throw Me(t,"credential-already-in-use",s);if("EMAIL_EXISTS"===a)throw Me(t,"email-already-in-use",s);if("USER_DISABLED"===a)throw Me(t,"user-disabled",s);var l=e[a]||a.toLowerCase().replace(/[_\s]+/g,"-");if(o)throw Ie(t,l,o);u(t,l)}catch(e){if(e instanceof c)throw e;u(t,"network-request-failed",{message:String(e)})}}async function r(e,t,r,i,n={}){t=await p(e,t,r,i,n);return"mfaPendingCredential"in t&&u(e,"multi-factor-auth-required",{_serverResponse:t}),t}async function Le(e,t,r,i){t=""+t+r+"?"+i,i=e,e=i.config.emulator?Re(e.config,t):e.config.apiScheme+"://"+t;if(Ce.includes(r)&&(await i._persistenceManagerAvailable,"COOKIE"===i._getPersistenceType()))return i._getPersistence()._getFinalTarget(e).toString();return e}class De{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((e,t)=>{this.timer=setTimeout(()=>t(d(this.auth,"network-request-failed")),Oe.get())})}}function Me(e,t,r){var i={appName:e.name},e=(r.email&&(i.email=r.email),r.phoneNumber&&(i.phoneNumber=r.phoneNumber),d(e,t,i));return e.customData._tokenResponse=r,e}function Ue(e){return void 0!==e&&void 0!==e.getResponse}function Fe(e){return void 0!==e&&void 0!==e.enterprise}class Ve{constructor(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}getProviderEnforcementState(t){if(this.recaptchaEnforcementState&&0!==this.recaptchaEnforcementState.length)for(let e of this.recaptchaEnforcementState)if(e.provider&&e.provider===t){switch(e.enforcementState){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}return}return null}isProviderEnabled(e){return"ENFORCE"===this.getProviderEnforcementState(e)||"AUDIT"===this.getProviderEnforcementState(e)}isAnyProviderEnabled(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}async function xe(e,t){return p(e,"GET","/v2/recaptchaConfig",o(e,t))}async function je(e,t){return p(e,"POST","/v1/accounts:lookup",t)}function He(e){if(e)try{var t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch(e){}}function We(e){return 1e3*Number(e)}function qe(e){var[e,t,r]=e.split(".");if(void 0===e||void 0===t||void 0===r)return ye("JWT malformed, contained fewer than 3 sections"),null;try{var i=H(t);return i?JSON.parse(i):(ye("Failed to decode base64 JWT payload"),null)}catch(e){return ye("Caught error parsing JWT payload as JSON",null==e?void 0:e.toString()),null}}function Be(e){e=qe(e);return m(e,"internal-error"),m(void 0!==e.exp,"internal-error"),m(void 0!==e.iat,"internal-error"),Number(e.exp)-Number(e.iat)}async function g(t,e,r=!1){if(r)return e;try{return await e}catch(e){throw e instanceof c&&(r=[e.code][0],"auth/user-disabled"===r||"auth/user-token-expired"===r)&&(t.auth.currentUser===t&&await t.auth.signOut()),e}}class ze{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){return e?(e=this.errorBackoff,this.errorBackoff=Math.min(2*this.errorBackoff,96e4),e):(this.errorBackoff=3e4,e=(null!=(e=this.user.stsTokenManager.expirationTime)?e:0)-Date.now()-3e5,Math.max(0,e))}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"===(null==e?void 0:e.code)&&this.schedule(!0))}this.schedule()}}class Ge{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=He(this.lastLoginAt),this.creationTime=He(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function Ke(e){var t=e.auth,r=await e.getIdToken(),r=await g(e,je(t,{idToken:r})),t=(m(null==r?void 0:r.users.length,t,"internal-error"),r.users[0]),r=(e._notifyReloadListener(t),null!=(r=t.providerUserInfo)&&r.length?Je(t.providerUserInfo):[]),r=((e,r)=>[...e=e.filter(t=>!r.some(e=>e.providerId===t.providerId)),...r])(e.providerData,r),i=!(e.email&&t.passwordHash||null!=r&&r.length),i=!!e.isAnonymous&&i,r={uid:t.localId,displayName:t.displayName||null,photoURL:t.photoUrl||null,email:t.email||null,emailVerified:t.emailVerified||!1,phoneNumber:t.phoneNumber||null,tenantId:t.tenantId||null,providerData:r,metadata:new Ge(t.createdAt,t.lastLoginAt),isAnonymous:i};Object.assign(e,r)}function Je(e){return e.map(e=>{var t=e.providerId,e=ue(e,["providerId"]);return{providerId:t,uid:e.rawId||"",displayName:e.displayName||null,email:e.email||null,phoneNumber:e.phoneNumber||null,photoURL:e.photoUrl||null}})}class Ye{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){m(e.idToken,"internal-error"),m(void 0!==e.idToken,"internal-error"),m(void 0!==e.refreshToken,"internal-error");var t="expiresIn"in e&&void 0!==e.expiresIn?Number(e.expiresIn):Be(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){m(0!==e.length,"internal-error");var t=Be(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return t||!this.accessToken||this.isExpired?(m(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null):this.accessToken}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){n=t;var i,n,{accessToken:e,refreshToken:t,expiresIn:r}=await{accessToken:(t=await Ne(i=e,{},async()=>{var e=te({grant_type:"refresh_token",refresh_token:n}).slice(1),{tokenApiHost:t,apiKey:r}=i.config,t=await Le(i,t,"/v1/token","key="+r),r=await i._getAdditionalHeaders();return r["Content-Type"]="application/x-www-form-urlencoded",Ae.fetch()(t,{method:"POST",headers:r,body:e})})).access_token,expiresIn:t.expires_in,refreshToken:t.refresh_token};this.updateTokensAndExpiration(e,t,Number(r))}updateTokensAndExpiration(e,t,r){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+1e3*r}static fromJSON(e,t){var{refreshToken:t,accessToken:r,expirationTime:i}=t,n=new Ye;return t&&(m("string"==typeof t,"internal-error",{appName:e}),n.refreshToken=t),r&&(m("string"==typeof r,"internal-error",{appName:e}),n.accessToken=r),i&&(m("number"==typeof i,"internal-error",{appName:e}),n.expirationTime=i),n}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 n("not implemented")}}function f(e,t){m("string"==typeof e||void 0===e,"internal-error",{appName:t})}class v{constructor(e){var{uid:t,auth:r,stsTokenManager:i}=e,e=ue(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new ze(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,this.auth=r,this.stsTokenManager=i,this.accessToken=i.accessToken,this.displayName=e.displayName||null,this.email=e.email||null,this.emailVerified=e.emailVerified||!1,this.phoneNumber=e.phoneNumber||null,this.photoURL=e.photoURL||null,this.isAnonymous=e.isAnonymous||!1,this.tenantId=e.tenantId||null,this.providerData=e.providerData?[...e.providerData]:[],this.metadata=new Ge(e.createdAt||void 0,e.lastLoginAt||void 0)}async getIdToken(e){e=await g(this,this.stsTokenManager.getToken(this.auth,e));return m(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(e,t=!1)=>{var e=s(e),r=qe(t=await e.getIdToken(t)),i=(m(r&&r.exp&&r.auth_time&&r.iat,e.auth,"internal-error"),null==(e="object"==typeof r.firebase?r.firebase:void 0)?void 0:e.sign_in_provider);return{claims:r,token:t,authTime:He(We(r.auth_time)),issuedAtTime:He(We(r.iat)),expirationTime:He(We(r.exp)),signInProvider:i||null,signInSecondFactor:(null==e?void 0:e.sign_in_second_factor)||null}})(this,e)}reload(){return(async e=>{await Ke(e=s(e)),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)})(this)}_assign(e){this!==e&&(m(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){e=new v(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}));return e.metadata._copy(this.metadata),e}_onReload(e){m(!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 r=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),r=!0),t&&await Ke(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){var e;return qn._isFirebaseServerApp(this.auth.app)?Promise.reject(h(this.auth)):(e=await this.getIdToken(),await g(this,(async(e,t)=>p(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 r=null!=(r=t.displayName)?r:void 0,i=null!=(i=t.email)?i:void 0,n=null!=(n=t.phoneNumber)?n:void 0,s=null!=(s=t.photoURL)?s:void 0,a=null!=(a=t.tenantId)?a:void 0,o=null!=(o=t._redirectEventId)?o:void 0,l=null!=(l=t.createdAt)?l:void 0,c=null!=(c=t.lastLoginAt)?c:void 0,{uid:t,emailVerified:u,isAnonymous:d,providerData:h,stsTokenManager:p}=t,p=(m(t&&p,e,"internal-error"),Ye.fromJSON(this.name,p)),t=(m("string"==typeof t,e,"internal-error"),f(r,e.name),f(i,e.name),m("boolean"==typeof u,e,"internal-error"),m("boolean"==typeof d,e,"internal-error"),f(n,e.name),f(s,e.name),f(a,e.name),f(o,e.name),f(l,e.name),f(c,e.name),new v({uid:t,auth:e,email:i,emailVerified:u,displayName:r,isAnonymous:d,photoURL:s,phoneNumber:n,tenantId:a,stsTokenManager:p,createdAt:l,lastLoginAt:c}));return h&&Array.isArray(h)&&(t.providerData=h.map(e=>Object.assign({},e))),o&&(t._redirectEventId=o),t}static async _fromIdTokenResponse(e,t,r=!1){var i=new Ye,t=(i.updateFromServerResponse(t),new v({uid:t.localId,auth:e,stsTokenManager:i,isAnonymous:r}));return await Ke(t),t}static async _fromGetAccountInfoResponse(e,t,r){var t=t.users[0],i=(m(void 0!==t.localId,"internal-error"),void 0!==t.providerUserInfo?Je(t.providerUserInfo):[]),n=!(t.email&&t.passwordHash||null!=i&&i.length),s=new Ye,r=(s.updateFromIdToken(r),new v({uid:t.localId,auth:e,stsTokenManager:s,isAnonymous:n})),e={uid:t.localId,displayName:t.displayName||null,photoURL:t.photoUrl||null,email:t.email||null,emailVerified:t.emailVerified||!1,phoneNumber:t.phoneNumber||null,tenantId:t.tenantId||null,providerData:i,metadata:new Ge(t.createdAt,t.lastLoginAt),isAnonymous:!(t.email&&t.passwordHash||null!=i&&i.length)};return Object.assign(r,e),r}}let $e=new Map;function _(e){a(e instanceof Function,"Expected a class definition");var t=$e.get(e);return t?a(t instanceof e,"Instance stored in cache mismatched with class"):(t=new e,$e.set(e,t)),t}class Xe{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){}}Xe.type="NONE";let Qe=Xe;function y(e,t,r){return`firebase:${e}:${t}:`+r}class Ze{constructor(e,t,r){this.persistence=e,this.auth=t,this.userKey=r;var{config:e,name:r}=this.auth;this.fullUserKey=y(this.userKey,e.apiKey,r),this.fullPersistenceKey=y("persistence",e.apiKey,r),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,t=await this.persistence._get(this.fullUserKey);return t?"string"==typeof t?(e=await je(this.auth,{idToken:t}).catch(()=>{}))?v._fromGetAccountInfoResponse(this.auth,e,t):null:v._fromJSON(this.auth,t):null}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){var t;if(this.persistence!==e)return t=await this.getCurrentUser(),await this.removeCurrentUser(),this.persistence=e,t?this.setCurrentUser(t):void 0}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(t,e,r="authUser"){if(!e.length)return new Ze(_(Qe),t,r);var i,n=(await Promise.all(e.map(async e=>{if(await e._isAvailable())return e}))).filter(e=>e);let s=n[0]||_(Qe),a=y(r,t.config.apiKey,t.name),o=null;for(i of e)try{var l=await i._get(a);if(l){let e;if("string"==typeof l){var c=await je(t,{idToken:l}).catch(()=>{});if(!c)break;e=await v._fromGetAccountInfoResponse(t,c,l)}else e=v._fromJSON(t,l);i!==s&&(o=e),s=i;break}}catch(e){}n=n.filter(e=>e._shouldAllowMigration);return s._shouldAllowMigration&&n.length&&(s=n[0],o&&await s._set(a,o.toJSON()),await Promise.all(e.map(async e=>{if(e!==s)try{await e._remove(a)}catch(e){}}))),new Ze(s,t,r)}}function et(e){var t=e.toLowerCase();return t.includes("opera/")||t.includes("opr/")||t.includes("opios/")?"Opera":nt(t)?"IEMobile":t.includes("msie")||t.includes("trident/")?"IE":t.includes("edge/")?"Edge":tt(t)?"Firefox":t.includes("silk/")?"Silk":at(t)?"Blackberry":ot(t)?"Webos":rt(t)?"Safari":!t.includes("chrome/")&&!it(t)||t.includes("edge/")?st(t)?"Android":2===(null==(t=e.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/))?void 0:t.length)?t[1]:"Other":"Chrome"}function tt(e=l()){return/firefox\//i.test(e)}function rt(e=l()){e=e.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function it(e=l()){return/crios\//i.test(e)}function nt(e=l()){return/iemobile/i.test(e)}function st(e=l()){return/android/i.test(e)}function at(e=l()){return/blackberry/i.test(e)}function ot(e=l()){return/webos/i.test(e)}function lt(e=l()){return/iphone|ipad|ipod/i.test(e)||/macintosh/i.test(e)&&/mobile/i.test(e)}function ct(e=l()){return lt(e)||st(e)||ot(e)||at(e)||/windows phone/i.test(e)||nt(e)}function ut(e,t=[]){let r;switch(e){case"Browser":r=et(l());break;case"Worker":r=et(l())+"-"+e;break;default:r=e}t=t.length?t.join(","):"FirebaseCore-web";return`${r}/JsCore/${qn.SDK_VERSION}/`+t}class dt{constructor(e){this.auth=e,this.queue=[]}pushCallback(i,e){var t=r=>new Promise((e,t)=>{try{e(i(r))}catch(e){t(e)}});t.onAbort=e,this.queue.push(t);let r=this.queue.length-1;return()=>{this.queue[r]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser!==e){var t=[];try{for(var r of this.queue)await r(e),r.onAbort&&t.push(r.onAbort)}catch(e){t.reverse();for(var i of t)try{i()}catch(e){}throw this.auth._errorFactory.create("login-blocked",{originalMessage:null==e?void 0:e.message})}}}}class ht{constructor(e){var t,r=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=null!=(t=r.minPasswordLength)?t:6,r.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=r.maxPasswordLength),void 0!==r.containsLowercaseCharacter&&(this.customStrengthOptions.containsLowercaseLetter=r.containsLowercaseCharacter),void 0!==r.containsUppercaseCharacter&&(this.customStrengthOptions.containsUppercaseLetter=r.containsUppercaseCharacter),void 0!==r.containsNumericCharacter&&(this.customStrengthOptions.containsNumericCharacter=r.containsNumericCharacter),void 0!==r.containsNonAlphanumericCharacter&&(this.customStrengthOptions.containsNonAlphanumericCharacter=r.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,"ENFORCEMENT_STATE_UNSPECIFIED"===this.enforcementState&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=null!=(r=null==(t=e.allowedNonAlphanumericCharacters)?void 0:t.join(""))?r:"",this.forceUpgradeOnSignin=null!=(t=e.forceUpgradeOnSignin)&&t,this.schemaVersion=e.schemaVersion}validatePassword(e){var t={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,t),this.validatePasswordCharacterOptions(e,t),t.isValid&&(t.isValid=null==(e=t.meetsMinPasswordLength)||e),t.isValid&&(t.isValid=null==(e=t.meetsMaxPasswordLength)||e),t.isValid&&(t.isValid=null==(e=t.containsLowercaseLetter)||e),t.isValid&&(t.isValid=null==(e=t.containsUppercaseLetter)||e),t.isValid&&(t.isValid=null==(e=t.containsNumericCharacter)||e),t.isValid&&(t.isValid=null==(e=t.containsNonAlphanumericCharacter)||e),t}validatePasswordLengthOptions(e,t){var r=this.customStrengthOptions.minPasswordLength,i=this.customStrengthOptions.maxPasswordLength;r&&(t.meetsMinPasswordLength=e.length>=r),i&&(t.meetsMaxPasswordLength=e.length<=i)}validatePasswordCharacterOptions(t,r){var i;this.updatePasswordCharacterOptionsStatuses(r,!1,!1,!1,!1);for(let e=0;e<t.length;e++)i=t.charAt(e),this.updatePasswordCharacterOptionsStatuses(r,"a"<=i&&i<="z","A"<=i&&i<="Z","0"<=i&&i<="9",this.allowedNonAlphanumericCharacters.includes(i))}updatePasswordCharacterOptionsStatuses(e,t,r,i,n){this.customStrengthOptions.containsLowercaseLetter&&!e.containsLowercaseLetter&&(e.containsLowercaseLetter=t),this.customStrengthOptions.containsUppercaseLetter&&!e.containsUppercaseLetter&&(e.containsUppercaseLetter=r),this.customStrengthOptions.containsNumericCharacter&&!e.containsNumericCharacter&&(e.containsNumericCharacter=i),this.customStrengthOptions.containsNonAlphanumericCharacter&&!e.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter=n)}}class pt{constructor(e,t,r,i){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=r,this.config=i,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new mt(this),this.idTokenSubscription=new mt(this),this.beforeStateQueue=new dt(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=ve,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this._resolvePersistenceManagerAvailable=void 0,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=i.sdkClientVersion,this._persistenceManagerAvailable=new Promise(e=>this._resolvePersistenceManagerAvailable=e)}_initializeWithPersistence(t,r){return r&&(this._popupRedirectResolver=_(r)),this._initializationPromise=this.queue(async()=>{var e;if(!this._deleted&&(this.persistenceManager=await Ze.create(this,t),null!=(e=this._resolvePersistenceManagerAvailable)&&e.call(this),!this._deleted)){if(null!=(e=this._popupRedirectResolver)&&e._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch(e){}await this.initializeCurrentUser(r),this.lastNotifiedUid=(null==(e=this.currentUser)?void 0:e.uid)||null,this._deleted||(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){var e;!this._deleted&&(e=await this.assertedPersistence.getCurrentUser(),this.currentUser||e)&&(this.currentUser&&e&&this.currentUser.uid===e.uid?(this._currentUser._assign(e),await this.currentUser.getIdToken()):await this._updateCurrentUser(e,!0))}async initializeCurrentUserFromIdToken(e){try{var t=await je(this,{idToken:e}),r=await v._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(r)}catch(e){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",e),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){if(qn._isFirebaseServerApp(this.app)){let t=this.app.settings.authIdToken;return t?new Promise(e=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(t).then(e,e))}):this.directlySetCurrentUser(null)}var t,r,i=await this.assertedPersistence.getCurrentUser();let n=i,s=!1;if(e&&this.config.authDomain&&(await this.getOrInitRedirectPersistenceManager(),t=null==(t=this.redirectUser)?void 0:t._redirectEventId,r=null==n?void 0:n._redirectEventId,e=await this.tryRedirectSignIn(e),t&&t!==r||null==e||!e.user||(n=e.user,s=!0)),!n)return this.directlySetCurrentUser(null);if(n._redirectEventId)return m(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===n._redirectEventId?this.directlySetCurrentUser(n):this.reloadAndSetCurrentUserOrClear(n);if(s)try{await this.beforeStateQueue.runMiddleware(n)}catch(e){n=i,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(e))}return n?this.reloadAndSetCurrentUserOrClear(n):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 Ke(e)}catch(e){if("auth/network-request-failed"!==(null==e?void 0:e.code))return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){var e;this.languageCode="undefined"!=typeof navigator&&((e=navigator).languages&&e.languages[0]||e.language)||null}async _delete(){this._deleted=!0}async updateCurrentUser(e){return qn._isFirebaseServerApp(this.app)?Promise.reject(h(this)):((e=e?s(e):null)&&m(e.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(e&&e._clone(this)))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&m(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return qn._isFirebaseServerApp(this.app)?Promise.reject(h(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return qn._isFirebaseServerApp(this.app)?Promise.reject(h(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(_(e))})}_getRecaptchaConfig(){return null==this.tenantId?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();var t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return null===this.tenantId?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){var e=await p(e=this,"GET","/v2/passwordPolicy",o(e,{})),e=new ht(e);null===this.tenantId?this._projectPasswordPolicy=e:this._tenantPasswordPolicies[this.tenantId]=e}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new X("auth","Firebase",e())}onAuthStateChanged(e,t,r){return this.registerStateListener(this.authStateSubscription,e,t,r)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,r){return this.registerStateListener(this.idTokenSubscription,e,t,r)}authStateReady(){return new Promise((t,r)=>{if(this.currentUser)t();else{let e=this.onAuthStateChanged(()=>{e(),t()},r)}})}async revokeAccessToken(e){var t;this.currentUser&&(e={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:await this.currentUser.getIdToken()},null!=this.tenantId&&(e.tenantId=this.tenantId),await p(t=this,"POST","/v2/accounts:revokeToken",o(t,e)))}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:null==(e=this._currentUser)?void 0:e.toJSON()}}async _setRedirectUser(e,t){t=await this.getOrInitRedirectPersistenceManager(t);return null===e?t.removeCurrentUser():t.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){return this.redirectPersistenceManager||(m(e=e&&_(e)||this._popupRedirectResolver,this,"argument-error"),this.redirectPersistenceManager=await Ze.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._redirectEventId)===e?this._currentUser:(null==(t=this.redirectUser)?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.uid)?e:null,this.lastNotifiedUid!==e)&&(this.lastNotifiedUid=e,this.authStateSubscription.next(this.currentUser))}registerStateListener(t,r,i,n){if(this._deleted)return()=>{};let e="function"==typeof r?r:r.next.bind(r),s=!1;var a=this._isInitialized?Promise.resolve():this._initializationPromise;if(m(a,this,"internal-error"),a.then(()=>{s||e(this.currentUser)}),"function"==typeof r){let e=t.addObserver(r,i,n);return()=>{s=!0,e()}}{let e=t.addObserver(r);return()=>{s=!0,e()}}}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 m(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){e&&!this.frameworks.includes(e)&&(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=ut(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var e={"X-Client-Version":this.clientVersion},t=(this.app.options.appId&&(e["X-Firebase-gmpid"]=this.app.options.appId),await(null==(t=this.heartbeatServiceProvider.getImmediate({optional:!0}))?void 0:t.getHeartbeatsHeader())),t=(t&&(e["X-Firebase-Client"]=t),await this._getAppCheckToken());return t&&(e["X-Firebase-AppCheck"]=t),e}async _getAppCheckToken(){var e,t,r;return qn._isFirebaseServerApp(this.app)&&this.app.settings.appCheckToken?this.app.settings.appCheckToken:(null!=(e=await(null==(e=this.appCheckServiceProvider.getImmediate({optional:!0}))?void 0:e.getToken()))&&e.error&&(t="Error while retrieving App Check token: "+e.error,r=[],_e.logLevel<=i.WARN)&&_e.warn(`Auth (${qn.SDK_VERSION}): `+t,...r),null==e?void 0:e.token)}}function I(e){return s(e)}class mt{constructor(e){var t;this.auth=e,this.observer=null,this.addObserver=(e=e=>this.observer=e,(e=new ne(e,t)).subscribe.bind(e))}get next(){return m(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}let gt={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function ft(e){return gt.loadJS(e)}function vt(e){return"__"+e+Math.floor(1e6*Math.random())}class _t{constructor(e){this.auth=e,this.counter=1e12,this._widgets=new Map}render(e,t){var r=this.counter;return this._widgets.set(r,new wt(e,this.auth.name,t||{})),this.counter++,r}reset(e){var t,e=e||1e12;null!=(t=this._widgets.get(e))&&t.delete(),this._widgets.delete(e)}getResponse(e){return(null==(e=this._widgets.get(e||1e12))?void 0:e.getResponse())||""}async execute(e){return null!=(e=this._widgets.get(e||1e12))&&e.execute(),""}}class yt{constructor(){this.enterprise=new It}ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class It{ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class wt{constructor(e,t,r){this.params=r,this.timerId=null,this.deleted=!1,this.responseToken=null,this.clickHandler=()=>{this.execute()};r="string"==typeof e?document.getElementById(e):e;m(r,"argument-error",{appName:t}),this.container=r,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=(t=>{var r=[],i="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let e=0;e<t;e++)r.push(i.charAt(Math.floor(Math.random()*i.length)));return r.join("")})(50);let{callback:e,"expired-callback":t}=this.params;if(e)try{e(this.responseToken)}catch(e){}this.timerId=window.setTimeout(()=>{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!")}}let Tt="NO_RECAPTCHA";class Et{constructor(e){this.type="recaptcha-enterprise",this.auth=I(e)}async verify(n="verify",e=!1){function s(e,t,r){let i=window.grecaptcha;Fe(i)?i.enterprise.ready(()=>{i.enterprise.execute(e,{action:n}).then(e=>{t(e)}).catch(()=>{t(Tt)})}):r(Error("No reCAPTCHA enterprise script loaded."))}return this.auth.settings.appVerificationDisabledForTesting?(new yt).execute("siteKey",{action:"verify"}):new Promise((r,i)=>{(async i=>{if(!e){if(null==i.tenantId&&null!=i._agentRecaptchaConfig)return i._agentRecaptchaConfig.siteKey;if(null!=i.tenantId&&void 0!==i._tenantRecaptchaConfigs[i.tenantId])return i._tenantRecaptchaConfigs[i.tenantId].siteKey}return new Promise(async(t,r)=>{xe(i,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(e=>{if(void 0!==e.recaptchaKey)return e=new Ve(e),null==i.tenantId?i._agentRecaptchaConfig=e:i._tenantRecaptchaConfigs[i.tenantId]=e,t(e.siteKey);r(new Error("recaptcha Enterprise site key undefined"))}).catch(e=>{r(e)})})})(this.auth).then(t=>{if(!e&&Fe(window.grecaptcha))s(t,r,i);else if("undefined"==typeof window)i(new Error("RecaptchaVerifier is only supported in browser"));else{let e=gt.recaptchaEnterpriseScript;0!==e.length&&(e+=t),ft(e).then(()=>{s(t,r,i)}).catch(e=>{i(e)})}}).catch(e=>{i(e)})})}}async function bt(t,e,r,i=!1,n=!1){t=new Et(t);let s;if(n)s=Tt;else try{s=await t.verify(r)}catch(e){s=await t.verify(r,!0)}n=Object.assign({},e);return"mfaSmsEnrollment"===r||"mfaSmsSignIn"===r?"phoneEnrollmentInfo"in n?(t=n.phoneEnrollmentInfo.phoneNumber,e=n.phoneEnrollmentInfo.recaptchaToken,Object.assign(n,{phoneEnrollmentInfo:{phoneNumber:t,recaptchaToken:e,captchaResponse:s,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})):"phoneSignInInfo"in n&&(r=n.phoneSignInInfo.recaptchaToken,Object.assign(n,{phoneSignInInfo:{recaptchaToken:r,captchaResponse:s,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})):(i?Object.assign(n,{captchaResp:s}):Object.assign(n,{captchaResponse:s}),Object.assign(n,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(n,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"})),n}async function w(r,i,n,s,e){var t;return"EMAIL_PASSWORD_PROVIDER"===e?null!=(t=r._getRecaptchaConfig())&&t.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")?(t=await bt(r,i,n,"getOobCode"===n),s(r,t)):s(r,i).catch(async e=>{var t;return"auth/missing-recaptcha-token"===e.code?(console.log(n+" is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow."),t=await bt(r,i,n,"getOobCode"===n),s(r,t)):Promise.reject(e)}):"PHONE_PROVIDER"===e?null!=(t=r._getRecaptchaConfig())&&t.isProviderEnabled("PHONE_PROVIDER")?(t=await bt(r,i,n),s(r,t).catch(async e=>{var t;if("AUDIT"===(null==(t=r._getRecaptchaConfig())?void 0:t.getProviderEnforcementState("PHONE_PROVIDER"))&&("auth/missing-recaptcha-token"===e.code||"auth/invalid-app-credential"===e.code))return console.log(`Failed to verify with reCAPTCHA Enterprise. Automatically triggering the reCAPTCHA v2 flow to complete the ${n} flow.`),t=await bt(r,i,n,!1,!0),s(r,t);return Promise.reject(e)})):(t=await bt(r,i,n,!1,!0),s(r,t)):Promise.reject(e+" provider is not supported.")}function kt(e,t,r){var e=I(e),r=(m(/^https?:\/\//.test(t),e,"invalid-emulator-scheme"),!(null==r||!r.disableWarnings)),i=St(t),{host:t,port:n}=(e=>{var t=St(e);return(e=/(\/\/)?([^?#/]+)/.exec(e.substr(t.length)))?(t=e[2].split("@").pop()||"",(e=/^(\[[^\]]+\])(:|$)/.exec(t))?{host:e=e[1],port:Rt(t.substr(e.length+1))}:([e,t]=t.split(":"),{host:e,port:Rt(t)})):{host:"",port:null}})(t),s={url:i+`//${t}${null===n?"":":"+n}/`},t=Object.freeze({host:t,port:n,protocol:i.replace(":",""),options:Object.freeze({disableWarnings:r})});function a(){var 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)}e._canInitEmulator?(e.config.emulator=s,e.emulatorConfig=t,e.settings.appVerificationDisabledForTesting=!0,r||("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&&("loading"===document.readyState?window.addEventListener("DOMContentLoaded",a):a()))):(m(e.config.emulator&&e.emulatorConfig,e,"emulator-config-failed"),m(Z(s,e.config.emulator)&&Z(t,e.emulatorConfig),e,"emulator-config-failed"))}function St(e){var t=e.indexOf(":");return t<0?"":e.substr(0,t+1)}function Rt(e){return!e||(e=Number(e),isNaN(e))?null:e}class At{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return n("not implemented")}_getIdTokenResponse(e){return n("not implemented")}_linkToIdToken(e,t){return n("not implemented")}_getReauthenticationResolver(e){return n("not implemented")}}async function Pt(e,t){return p(e,"POST","/v1/accounts:resetPassword",o(e,t))}async function Ct(e,t){return p(e,"POST","/v1/accounts:signUp",t)}async function Ot(e,t){return r(e,"POST","/v1/accounts:signInWithPassword",o(e,t))}async function Nt(e,t){return p(e,"POST","/v1/accounts:sendOobCode",o(e,t))}async function Lt(e,t){return Nt(e,t)}async function Dt(e,t){return Nt(e,t)}class Mt extends At{constructor(e,t,r,i=null){super("password",r),this._email=e,this._password=t,this._tenantId=i}static _fromEmailAndPassword(e,t){return new Mt(e,t,"password")}static _fromEmailAndCode(e,t,r=null){return new Mt(e,t,"emailLink",r)}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 w(e,{returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signInWithPassword",Ot,"EMAIL_PASSWORD_PROVIDER");case"emailLink":return(async(e,t)=>r(e,"POST","/v1/accounts:signInWithEmailLink",o(e,t)))(e,{email:this._email,oobCode:this._password});default:u(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":return w(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",Ct,"EMAIL_PASSWORD_PROVIDER");case"emailLink":return(async(e,t)=>r(e,"POST","/v1/accounts:signInWithEmailLink",o(e,t)))(e,{idToken:t,email:this._email,oobCode:this._password});default:u(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function T(e,t){return r(e,"POST","/v1/accounts:signInWithIdp",o(e,t))}class E extends At{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){var t=new E(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):u("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 e="string"==typeof e?JSON.parse(e):e,{providerId:t,signInMethod:r}=e,e=ue(e,["providerId","signInMethod"]);return t&&r?((t=new E(t,r)).idToken=e.idToken||void 0,t.accessToken=e.accessToken||void 0,t.secret=e.secret,t.nonce=e.nonce,t.pendingToken=e.pendingToken||null,t):null}_getIdTokenResponse(e){return T(e,this.buildRequest())}_linkToIdToken(e,t){var r=this.buildRequest();return r.idToken=t,T(e,r)}_getReauthenticationResolver(e){var t=this.buildRequest();return t.autoCreate=!1,T(e,t)}buildRequest(){var e,t={requestUri:"http://localhost",returnSecureToken:!0};return this.pendingToken?t.pendingToken=this.pendingToken:(e={},this.idToken&&(e.id_token=this.idToken),this.accessToken&&(e.access_token=this.accessToken),this.secret&&(e.oauth_token_secret=this.secret),e.providerId=this.providerId,this.nonce&&!this.pendingToken&&(e.nonce=this.nonce),t.postBody=te(e)),t}}async function Ut(e,t){return p(e,"POST","/v1/accounts:sendVerificationCode",o(e,t))}let Ft={USER_NOT_FOUND:"user-not-found"};class Vt extends At{constructor(e){super("phone","phone"),this.params=e}static _fromVerification(e,t){return new Vt({verificationId:e,verificationCode:t})}static _fromTokenResponse(e,t){return new Vt({phoneNumber:e,temporaryProof:t})}_getIdTokenResponse(e){return(async(e,t)=>r(e,"POST","/v1/accounts:signInWithPhoneNumber",o(e,t)))(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return(async(e,t)=>{if((t=await r(e,"POST","/v1/accounts:signInWithPhoneNumber",o(e,t))).temporaryProof)throw Me(e,"account-exists-with-different-credential",t);return t})(e,Object.assign({idToken:t},this._makeVerificationRequest()))}_getReauthenticationResolver(e){return(async(e,t)=>r(e,"POST","/v1/accounts:signInWithPhoneNumber",o(e,Object.assign(Object.assign({},t),{operation:"REAUTH"})),Ft))(e,this._makeVerificationRequest())}_makeVerificationRequest(){var{temporaryProof:e,phoneNumber:t,verificationId:r,verificationCode:i}=this.params;return e&&t?{temporaryProof:e,phoneNumber:t}:{sessionInfo:r,code:i}}toJSON(){var 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:e,verificationCode:t,phoneNumber:r,temporaryProof:i}=e="string"==typeof e?JSON.parse(e):e;return t||e||r||i?new Vt({verificationId:e,verificationCode:t,phoneNumber:r,temporaryProof:i}):null}}class xt{constructor(e){var e=re(ie(e)),t=null!=(t=e.apiKey)?t:null,r=null!=(r=e.oobCode)?r:null,i=(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!=(i=e.mode)?i:null);m(t&&r&&i,"argument-error"),this.apiKey=t,this.operation=i,this.code=r,this.continueUrl=null!=(t=e.continueUrl)?t:null,this.languageCode=null!=(i=e.languageCode)?i:null,this.tenantId=null!=(r=e.tenantId)?r:null}static parseLink(e){t=re(ie(e=e)).link,r=t?re(ie(t)).deep_link_id:null;var t,r,i=((i=re(ie(e)).deep_link_id)?re(ie(i)).link:null)||i||r||t||e;try{return new xt(i)}catch(e){return null}}}class jt{constructor(){this.providerId=jt.PROVIDER_ID}static credential(e,t){return Mt._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){t=xt.parseLink(t);return m(t,"argument-error"),Mt._fromEmailAndCode(e,t.code,t.tenantId)}}jt.PROVIDER_ID="password",jt.EMAIL_PASSWORD_SIGN_IN_METHOD="password",jt.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class b{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 Ht extends b{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class Wt extends Ht{static credentialFromJSON(e){e="string"==typeof e?JSON.parse(e):e;return m("providerId"in e&&"signInMethod"in e,"argument-error"),E._fromParams(e)}credential(e){return this._credential(Object.assign(Object.assign({},e),{nonce:e.rawNonce}))}_credential(e){return m(e.idToken||e.accessToken,"argument-error"),E._fromParams(Object.assign(Object.assign({},e),{providerId:this.providerId,signInMethod:this.providerId}))}static credentialFromResult(e){return Wt.oauthCredentialFromTaggedObject(e)}static credentialFromError(e){return Wt.oauthCredentialFromTaggedObject(e.customData||{})}static oauthCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthIdToken:e,oauthAccessToken:t,oauthTokenSecret:r,pendingToken:i,nonce:n,providerId:s}=e;if(!(t||r||e||i))return null;if(!s)return null;try{return new Wt(s)._credential({idToken:e,accessToken:t,nonce:n,pendingToken:i})}catch(e){return null}}}class k extends Ht{constructor(){super("facebook.com")}static credential(e){return E._fromParams({providerId:k.PROVIDER_ID,signInMethod:k.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return k.credentialFromTaggedObject(e)}static credentialFromError(e){return k.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!(e&&"oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return k.credential(e.oauthAccessToken)}catch(e){return null}}}k.FACEBOOK_SIGN_IN_METHOD="facebook.com",k.PROVIDER_ID="facebook.com";class S extends Ht{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return E._fromParams({providerId:S.PROVIDER_ID,signInMethod:S.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return S.credentialFromTaggedObject(e)}static credentialFromError(e){return S.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthIdToken:e,oauthAccessToken:t}=e;if(!e&&!t)return null;try{return S.credential(e,t)}catch(e){return null}}}S.GOOGLE_SIGN_IN_METHOD="google.com",S.PROVIDER_ID="google.com";class R extends Ht{constructor(){super("github.com")}static credential(e){return E._fromParams({providerId:R.PROVIDER_ID,signInMethod:R.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return R.credentialFromTaggedObject(e)}static credentialFromError(e){return R.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!(e&&"oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return R.credential(e.oauthAccessToken)}catch(e){return null}}}R.GITHUB_SIGN_IN_METHOD="github.com",R.PROVIDER_ID="github.com";class qt extends At{constructor(e,t){super(e,e),this.pendingToken=t}_getIdTokenResponse(e){return T(e,this.buildRequest())}_linkToIdToken(e,t){var r=this.buildRequest();return r.idToken=t,T(e,r)}_getReauthenticationResolver(e){var t=this.buildRequest();return t.autoCreate=!1,T(e,t)}toJSON(){return{signInMethod:this.signInMethod,providerId:this.providerId,pendingToken:this.pendingToken}}static fromJSON(e){var{providerId:e,signInMethod:t,pendingToken:r}="string"==typeof e?JSON.parse(e):e;return e&&t&&r&&e===t?new qt(e,r):null}static _create(e,t){return new qt(e,t)}buildRequest(){return{requestUri:"http://localhost",returnSecureToken:!0,pendingToken:this.pendingToken}}}class Bt extends b{constructor(e){m(e.startsWith("saml."),"argument-error"),super(e)}static credentialFromResult(e){return Bt.samlCredentialFromTaggedObject(e)}static credentialFromError(e){return Bt.samlCredentialFromTaggedObject(e.customData||{})}static credentialFromJSON(e){e=qt.fromJSON(e);return m(e,"argument-error"),e}static samlCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{pendingToken:e,providerId:t}=e;if(!e||!t)return null;try{return qt._create(t,e)}catch(e){return null}}}class A extends Ht{constructor(){super("twitter.com")}static credential(e,t){return E._fromParams({providerId:A.PROVIDER_ID,signInMethod:A.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return A.credentialFromTaggedObject(e)}static credentialFromError(e){return A.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthAccessToken:e,oauthTokenSecret:t}=e;if(!e||!t)return null;try{return A.credential(e,t)}catch(e){return null}}}async function zt(e,t){return r(e,"POST","/v1/accounts:signUp",o(e,t))}A.TWITTER_SIGN_IN_METHOD="twitter.com",A.PROVIDER_ID="twitter.com";class P{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,r,i=!1){e=await v._fromIdTokenResponse(e,r,i),i=Gt(r);return new P({user:e,providerId:i,_tokenResponse:r,operationType:t})}static async _forOperation(e,t,r){await e._updateTokensIfNecessary(r,!0);var i=Gt(r);return new P({user:e,providerId:i,_tokenResponse:r,operationType:t})}}function Gt(e){return e.providerId||("phoneNumber"in e?"phone":null)}class Kt extends c{constructor(e,t,r,i){super(t.code,t.message),this.operationType=r,this.user=i,Object.setPrototypeOf(this,Kt.prototype),this.customData={appName:e.name,tenantId:null!=(i=e.tenantId)?i:void 0,_serverResponse:t.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(e,t,r,i){return new Kt(e,t,r,i)}}function Jt(t,r,e,i){return("reauthenticate"===r?e._getReauthenticationResolver(t):e._getIdTokenResponse(t)).catch(e=>{if("auth/multi-factor-auth-required"===e.code)throw Kt._fromErrorAndOperation(t,e,r,i);throw e})}function Yt(e){return new Set(e.map(({providerId:e})=>e).filter(e=>!!e))}async function $t(e,t){var e=s(e),r=(await Qt(!0,e,t),r=e.auth,t={idToken:await e.getIdToken(),deleteProvider:[t]},await p(r,"POST","/v1/accounts:update",t)).providerUserInfo;let i=Yt(r||[]);return e.providerData=e.providerData.filter(e=>i.has(e.providerId)),i.has("phone")||(e.phoneNumber=null),await e.auth._persistUserIfCurrent(e),e}async function Xt(e,t,r=!1){t=await g(e,t._linkToIdToken(e.auth,await e.getIdToken()),r);return P._forOperation(e,"link",t)}async function Qt(e,t,r){await Ke(t);var i=!1===e?"provider-already-linked":"no-such-provider";m(Yt(t.providerData).has(r)===e,t.auth,i)}async function Zt(e,t,r=!1){var i=e.auth;if(qn._isFirebaseServerApp(i.app))return Promise.reject(h(i));var n="reauthenticate";try{var s=await g(e,Jt(i,n,t,e),r),a=(m(s.idToken,i,"internal-error"),qe(s.idToken)),o=(m(a,i,"internal-error"),a).sub;return m(e.uid===o,i,"user-mismatch"),P._forOperation(e,n,s)}catch(e){throw"auth/user-not-found"===(null==e?void 0:e.code)&&u(i,"user-mismatch"),e}}async function er(e,t,r=!1){return qn._isFirebaseServerApp(e.app)?Promise.reject(h(e)):(t=await Jt(e,"signIn",t),t=await P._fromIdTokenResponse(e,"signIn",t),r||await e._updateCurrentUser(t.user),t)}async function tr(e,t){return er(I(e),t)}async function rr(e,t){e=s(e);return await Qt(!1,e,t.providerId),Xt(e,t)}async function ir(e,t){return Zt(s(e),t)}async function nr(e,t){return qn._isFirebaseServerApp(e.app)?Promise.reject(h(e)):(t=await r(e=I(e),"POST","/v1/accounts:signInWithCustomToken",o(e,{token:t,returnSecureToken:!0})),t=await P._fromIdTokenResponse(e,"signIn",t),await e._updateCurrentUser(t.user),t)}class sr{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?ar._fromServerResponse(e,t):"totpInfo"in t?or._fromServerResponse(e,t):u(e,"internal-error")}}class ar extends sr{constructor(e){super("phone",e),this.phoneNumber=e.phoneInfo}static _fromServerResponse(e,t){return new ar(t)}}class or extends sr{constructor(e){super("totp",e)}static _fromServerResponse(e,t){return new or(t)}}function lr(e,t,r){var i;m(0<(null==(i=r.url)?void 0:i.length),e,"invalid-continue-uri"),m(void 0===r.dynamicLinkDomain||0<r.dynamicLinkDomain.length,e,"invalid-dynamic-link-domain"),m(void 0===r.linkDomain||0<r.linkDomain.length,e,"invalid-hosting-link-domain"),t.continueUrl=r.url,t.dynamicLinkDomain=r.dynamicLinkDomain,t.linkDomain=r.linkDomain,t.canHandleCodeInApp=r.handleCodeInApp,r.iOS&&(m(0<r.iOS.bundleId.length,e,"missing-ios-bundle-id"),t.iOSBundleId=r.iOS.bundleId),r.android&&(m(0<r.android.packageName.length,e,"missing-android-pkg-name"),t.androidInstallApp=r.android.installApp,t.androidMinimumVersionCode=r.android.minimumVersion,t.androidPackageName=r.android.packageName)}async function cr(e){e=I(e);e._getPasswordPolicyInternal()&&await e._updatePasswordPolicy()}async function ur(e,t){await p(e=s(e),"POST","/v1/accounts:update",o(e,{oobCode:t}))}async function dr(e,t){var r=s(e),i=await Pt(r,{oobCode:t}),e=i.requestType;switch(m(e,r,"internal-error"),e){case"EMAIL_SIGNIN":break;case"VERIFY_AND_CHANGE_EMAIL":m(i.newEmail,r,"internal-error");break;case"REVERT_SECOND_FACTOR_ADDITION":m(i.mfaInfo,r,"internal-error");default:m(i.email,r,"internal-error")}let n=null;return i.mfaInfo&&(n=sr._fromServerResponse(I(r),i.mfaInfo)),{data:{email:("VERIFY_AND_CHANGE_EMAIL"===i.requestType?i.newEmail:i.email)||null,previousEmail:("VERIFY_AND_CHANGE_EMAIL"===i.requestType?i.email:i.newEmail)||null,multiFactorInfo:n},operation:e}}async function hr(e,t){var r=be()?Ee():"http://localhost",e=(await p(e=s(e),"POST","/v1/accounts:createAuthUri",o(e,{identifier:t,continueUri:r}))).signinMethods;return e||[]}async function pr(e,t){var r=s(e),i={requestType:"VERIFY_EMAIL",idToken:await e.getIdToken()},t=(t&&lr(r.auth,i,t),await Nt(r.auth,i)).email;t!==e.email&&await e.reload()}async function mr(e,t,r){var i=s(e),t={requestType:"VERIFY_AND_CHANGE_EMAIL",idToken:await e.getIdToken(),newEmail:t},r=(r&&lr(i.auth,t,r),await Nt(i.auth,t)).email;r!==e.email&&await e.reload()}async function gr(e,{displayName:t,photoURL:r}){var i;void 0===t&&void 0===r||(i=await(e=s(e)).getIdToken(),i=await g(e,(async(e,t)=>p(e,"POST","/v1/accounts:update",t))(e.auth,{idToken:i,displayName:t,photoUrl:r,returnSecureToken:!0})),e.displayName=i.displayName||null,e.photoURL=i.photoUrl||null,(t=e.providerData.find(({providerId:e})=>"password"===e))&&(t.displayName=e.displayName,t.photoURL=e.photoURL),await e._updateTokensIfNecessary(i))}async function fr(e,t,r){var i=e.auth,n={idToken:await e.getIdToken(),returnSecureToken:!0},t=(t&&(n.email=t),r&&(n.password=r),await g(e,(async(e,t)=>p(e,"POST","/v1/accounts:update",t))(i,n)));await e._updateTokensIfNecessary(t,!0)}class vr{constructor(e,t,r={}){this.isNewUser=e,this.providerId=t,this.profile=r}}class _r extends vr{constructor(e,t,r,i){super(e,t,r),this.username=i}}class yr extends vr{constructor(e,t){super(e,"facebook.com",t)}}class Ir extends _r{constructor(e,t){super(e,"github.com",t,"string"==typeof(null==t?void 0:t.login)?null==t?void 0:t.login:null)}}class wr extends vr{constructor(e,t){super(e,"google.com",t)}}class Tr extends _r{constructor(e,t,r){super(e,"twitter.com",t,r)}}function Er(e){var{user:e,_tokenResponse:t}=e;if(e.isAnonymous&&!t)return{providerId:null,isNewUser:!1,profile:null};var r=t;if(!r)return null;var i=r.providerId,n=r.rawUserInfo?JSON.parse(r.rawUserInfo):{},s=r.isNewUser||"identitytoolkit#SignupNewUserResponse"===r.kind;if(!i&&null!=r&&r.idToken){e=null==(e=null==(e=qe(r.idToken))?void 0:e.firebase)?void 0:e.sign_in_provider;if(e)return e="anonymous"!==e&&"custom"!==e?e:null,new vr(s,e)}if(!i)return null;switch(i){case"facebook.com":return new yr(s,n);case"github.com":return new Ir(s,n);case"google.com":return new wr(s,n);case"twitter.com":return new Tr(s,n,r.screenName||null);case"custom":case"anonymous":return new vr(s,null);default:return new vr(s,i,n)}}class br{constructor(e,t,r){this.type=e,this.credential=t,this.user=r}static _fromIdtoken(e,t){return new br("enroll",e,t)}static _fromMfaPendingCredential(e){return new br("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)&&t.pendingCredential)return br._fromMfaPendingCredential(e.multiFactorSession.pendingCredential);if(null!=(t=e.multiFactorSession)&&t.idToken)return br._fromIdtoken(e.multiFactorSession.idToken)}return null}}class kr{constructor(e,t,r){this.session=e,this.hints=t,this.signInResolver=r}static _fromError(e,i){let n=I(e),s=i.customData._serverResponse;e=(s.mfaInfo||[]).map(e=>sr._fromServerResponse(n,e));m(s.mfaPendingCredential,n,"internal-error");let a=br._fromMfaPendingCredential(s.mfaPendingCredential);return new kr(a,e,async e=>{var e=await e._process(n,a),t=(delete s.mfaInfo,delete s.mfaPendingCredential,Object.assign(Object.assign({},s),{idToken:e.idToken,refreshToken:e.refreshToken}));switch(i.operationType){case"signIn":var r=await P._fromIdTokenResponse(n,i.operationType,t);return await n._updateCurrentUser(r.user),r;case"reauthenticate":return m(i.user,n,"internal-error"),P._forOperation(i.user,i.operationType,t);default:u(n,"internal-error")}})}async resolveSignIn(e){return this.signInResolver(e)}}function Sr(e,t){return p(e,"POST","/v2/accounts/mfaEnrollment:start",o(e,t))}class Rr{constructor(t){this.user=t,this.enrolledFactors=[],t._onReload(e=>{e.mfaInfo&&(this.enrolledFactors=e.mfaInfo.map(e=>sr._fromServerResponse(t.auth,e)))})}static _fromUser(e){return new Rr(e)}async getSession(){return br._fromIdtoken(await this.user.getIdToken(),this.user)}async enroll(e,t){var r=await this.getSession(),e=await g(this.user,e._process(this.user.auth,r,t));return await this.user._updateTokensIfNecessary(e),this.user.reload()}async unenroll(e){let t="string"==typeof e?e:e.uid;var r,i,e=await this.user.getIdToken();try{var n=await g(this.user,(r=this.user.auth,i={idToken:e,mfaEnrollmentId:t},p(r,"POST","/v2/accounts/mfaEnrollment:withdraw",o(r,i))));this.enrolledFactors=this.enrolledFactors.filter(({uid:e})=>e!==t),await this.user._updateTokensIfNecessary(n),await this.user.reload()}catch(e){throw e}}}let Ar=new WeakMap;let Pr="__sak";class Cr{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Pr,"1"),this.storage.removeItem(Pr),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()}get storage(){return this.storageRetriever()}}class Or extends Cr{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=ct(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(var t of Object.keys(this.listeners)){var r=this.storage.getItem(t),i=this.localCache[t];r!==i&&e(t,i,r)}}onStorageEvent(e,r=!1){if(e.key){let t=e.key;r?this.detachListener():this.stopPolling();var i=()=>{var e=this.storage.getItem(t);!r&&this.localCache[t]===e||this.notifyListeners(t,e)},n=this.storage.getItem(t);Y()&&10===document.documentMode&&n!==e.newValue&&e.newValue!==e.oldValue?setTimeout(i,10):i()}else this.forAllChangedKeys((e,t,r)=>{this.notifyListeners(e,r)})}notifyListeners(e,t){this.localCache[e]=t;e=this.listeners[e];if(e)for(var r of Array.from(e))r(t&&JSON.parse(t))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,r)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:r}),!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]}}Or.type="LOCAL";let Nr=Or;class Lr extends Cr{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}Lr.type="SESSION";let Dr=Lr;class Mr{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));return e||(e=new Mr(t),this.receivers.push(e),e)}isListeningto(e){return this.eventTarget===e}async handleEvent(e){let t=e,{eventId:r,eventType:i,data:n}=t.data;var e=this.handlersMap[i];null!=e&&e.size&&(t.ports[0].postMessage({status:"ack",eventId:r,eventType:i}),e=Array.from(e).map(async e=>e(t.origin,n)),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:r,eventType:i,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 Ur(e="",t=10){let r="";for(let e=0;e<t;e++)r+=Math.floor(10*Math.random());return e+r}Mr.receivers=[];class Fr{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,a=50){let o="undefined"!=typeof MessageChannel?new MessageChannel:null;if(!o)throw new Error("connection_unavailable");let l,c;return new Promise((r,i)=>{let n=Ur("",20),s=(o.port1.start(),setTimeout(()=>{i(new Error("unsupported_event"))},a));c={messageChannel:o,onMessage(e){var t=e;if(t.data.eventId===n)switch(t.data.status){case"ack":clearTimeout(s),l=setTimeout(()=>{i(new Error("timeout"))},3e3);break;case"done":clearTimeout(l),r(t.data.response);break;default:clearTimeout(s),clearTimeout(l),i(new Error("invalid_response"))}}},this.handlers.add(c),o.port1.addEventListener("message",c.onMessage),this.target.postMessage({eventType:e,eventId:n,data:t},[o.port2])}).finally(()=>{c&&this.removeMessageHandler(c)})}}function C(){return window}function Vr(){return void 0!==C().WorkerGlobalScope&&"function"==typeof C().importScripts}let xr="firebaseLocalStorageDb",jr="firebaseLocalStorage",Hr="fbase_key";class Wr{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 qr(e,t){return e.transaction([jr],t?"readwrite":"readonly").objectStore(jr)}function Br(){let i=indexedDB.open(xr,1);return new Promise((t,r)=>{i.addEventListener("error",()=>{r(i.error)}),i.addEventListener("upgradeneeded",()=>{var e=i.result;try{e.createObjectStore(jr,{keyPath:Hr})}catch(e){r(e)}}),i.addEventListener("success",async()=>{var e=i.result;e.objectStoreNames.contains(jr)?t(e):(e.close(),e=indexedDB.deleteDatabase(xr),await new Wr(e).toPromise(),t(await Br()))})})}async function zr(e,t,r){e=qr(e,!0).put({fbase_key:t,value:r});return new Wr(e).toPromise()}function Gr(e,t){e=qr(e,!0).delete(t);return new Wr(e).toPromise()}class Kr{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 Br()),this.db}async _withRetries(e){let t=0;for(;;)try{return await e(await this._openDb())}catch(e){if(3<t++)throw e;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return Vr()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Mr._getInstance(Vr()?self:null),this.receiver._subscribe("keyChanged",async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){var e,t;this.activeServiceWorker=await(async()=>{if(null==navigator||!navigator.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch(e){return null}})(),this.activeServiceWorker&&(this.sender=new Fr(this.activeServiceWorker),t=await this.sender._send("ping",{},800))&&null!=(e=t[0])&&e.fulfilled&&null!=(e=t[0])&&e.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){var t;if(this.sender&&this.activeServiceWorker&&((null==(t=null==navigator?void 0:navigator.serviceWorker)?void 0:t.controller)||null)===this.activeServiceWorker)try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch(e){}}async _isAvailable(){try{var e;return indexedDB?(await zr(e=await Br(),Pr,"1"),await Gr(e,Pr),!0):!1}catch(e){}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(t,r){return this._withPendingWrite(async()=>(await this._withRetries(e=>zr(e,t,r)),this.localCache[t]=r,this.notifyServiceWorker(t)))}async _get(t){var e=await this._withRetries(e=>(async(e,t)=>(e=qr(e,!1).get(t),void 0===(t=await new Wr(e).toPromise())?null:t.value))(e,t));return this.localCache[t]=e}async _remove(t){return this._withPendingWrite(async()=>(await this._withRetries(e=>Gr(e,t)),delete this.localCache[t],this.notifyServiceWorker(t)))}async _poll(){var e=await this._withRetries(e=>{e=qr(e,!1).getAll();return new Wr(e).toPromise()});if(!e)return[];if(0!==this.pendingWrites)return[];var t,r=[],i=new Set;if(0!==e.length)for(var{fbase_key:n,value:s}of e)i.add(n),JSON.stringify(this.localCache[n])!==JSON.stringify(s)&&(this.notifyListeners(n,s),r.push(n));for(t of Object.keys(this.localCache))this.localCache[t]&&!i.has(t)&&(this.notifyListeners(t,null),r.push(t));return r}notifyListeners(e,t){this.localCache[e]=t;e=this.listeners[e];if(e)for(var r of Array.from(e))r(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()}}Kr.type="LOCAL";let Jr=Kr;function Yr(e,t){return p(e,"POST","/v2/accounts/mfaSignIn:start",o(e,t))}let $r=vt("rcb"),Xr=new Se(3e4,6e4);class Qr{constructor(){var e;this.hostLanguage="",this.counter=0,this.librarySeparatelyLoaded=!(null==(e=C().grecaptcha)||!e.render)}load(n,s=""){var e;return m((e=s).length<=6&&/^\s*[a-zA-Z0-9\-]*\s*$/.test(e),n,"argument-error"),this.shouldResolveImmediately(s)&&Ue(C().grecaptcha)?Promise.resolve(C().grecaptcha):new Promise((t,r)=>{let i=C().setTimeout(()=>{r(d(n,"network-request-failed"))},Xr.get());C()[$r]=()=>{C().clearTimeout(i),delete C()[$r];var e=C().grecaptcha;if(e&&Ue(e)){let r=e.render;e.render=(e,t)=>{e=r(e,t);return this.counter++,e},this.hostLanguage=s,t(e)}else r(d(n,"internal-error"))},ft(gt.recaptchaV2Script+"?"+te({onload:$r,render:"explicit",hl:s})).catch(()=>{clearTimeout(i),r(d(n,"internal-error"))})})}clearedOneInstance(){this.counter--}shouldResolveImmediately(e){var t;return!(null==(t=C().grecaptcha)||!t.render)&&(e===this.hostLanguage||0<this.counter||this.librarySeparatelyLoaded)}}class Zr{async load(e){return new _t(e)}clearedOneInstance(){}}let ei="recaptcha",ti={theme:"light",type:"image"};class ri{constructor(e,t,r=Object.assign({},ti)){this.parameters=r,this.type=ei,this.destroyed=!1,this.widgetId=null,this.tokenChangeListeners=new Set,this.renderPromise=null,this.recaptcha=null,this.auth=I(e),this.isInvisible="invisible"===this.parameters.size,m("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment");r="string"==typeof t?document.getElementById(t):t;m(r,this.auth,"argument-error"),this.container=r,this.parameters.callback=this.makeTokenCallback(this.parameters.callback),this._recaptchaLoader=new(this.auth.settings.appVerificationDisabledForTesting?Zr:Qr),this.validateStartingState()}async verify(){this.assertNotDestroyed();let e=await this.render(),i=this.getAssertedRecaptcha();var t=i.getResponse(e);return t||new Promise(t=>{let r=e=>{e&&(this.tokenChangeListeners.delete(r),t(e))};this.tokenChangeListeners.add(r),this.isInvisible&&i.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(){m(!this.parameters.sitekey,this.auth,"argument-error"),m(this.isInvisible||!this.container.hasChildNodes(),this.auth,"argument-error"),m("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment")}makeTokenCallback(r){return t=>{var e;this.tokenChangeListeners.forEach(e=>e(t)),"function"==typeof r?r(t):"string"==typeof r&&"function"==typeof(e=C()[r])&&e(t)}}assertNotDestroyed(){m(!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(){m(be()&&!Vr(),this.auth,"internal-error"),await(()=>{let t=null;return new Promise(e=>{"complete"===document.readyState?e():(t=()=>e(),window.addEventListener("load",t))}).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 p(this.auth,"GET","/v1/recaptchaParams")).recaptchaSiteKey||"");m(e,this.auth,"internal-error"),this.parameters.sitekey=e}getAssertedRecaptcha(){return m(this.recaptcha,this.auth,"internal-error"),this.recaptcha}}class ii{constructor(e,t){this.verificationId=e,this.onConfirmation=t}confirm(e){e=Vt._fromVerification(this.verificationId,e);return this.onConfirmation(e)}}async function ni(t,r,i){var n,e,s,a,o,l,c,u;if(!t._getRecaptchaConfig())try{s=await xe(e=I(e=t),{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}),s=new Ve(s),null==e.tenantId?e._agentRecaptchaConfig=s:e._tenantRecaptchaConfigs[e.tenantId]=s,await(!s.isAnyProviderEnabled()||!new Et(e).verify())}catch(e){console.log("Failed to initialize reCAPTCHA Enterprise config. Triggering the reCAPTCHA v2 verification.")}try{let e;return("session"in(e="string"==typeof r?{phoneNumber:r}:r)?(a=e.session,"phoneNumber"in e?(m("enroll"===a.type,t,"internal-error"),o={idToken:a.credential,phoneEnrollmentInfo:{phoneNumber:e.phoneNumber,clientType:"CLIENT_TYPE_WEB"}},(await w(t,o,"mfaSmsEnrollment",async(e,t)=>t.phoneEnrollmentInfo.captchaResponse===Tt?(m((null==i?void 0:i.type)===ei,e,"argument-error"),Sr(e,await si(e,t,i))):Sr(e,t),"PHONE_PROVIDER").catch(e=>Promise.reject(e))).phoneSessionInfo):(m("signin"===a.type,t,"internal-error"),m(l=(null==(n=e.multiFactorHint)?void 0:n.uid)||e.multiFactorUid,t,"missing-multi-factor-info"),c={mfaPendingCredential:a.credential,mfaEnrollmentId:l,phoneSignInInfo:{clientType:"CLIENT_TYPE_WEB"}},(await w(t,c,"mfaSmsSignIn",async(e,t)=>t.phoneSignInInfo.captchaResponse===Tt?(m((null==i?void 0:i.type)===ei,e,"argument-error"),Yr(e,await si(e,t,i))):Yr(e,t),"PHONE_PROVIDER").catch(e=>Promise.reject(e))).phoneResponseInfo)):(u={phoneNumber:e.phoneNumber,clientType:"CLIENT_TYPE_WEB"},await w(t,u,"sendVerificationCode",async(e,t)=>t.captchaResponse===Tt?(m((null==i?void 0:i.type)===ei,e,"argument-error"),Ut(e,await si(e,t,i))):Ut(e,t),"PHONE_PROVIDER").catch(e=>Promise.reject(e)))).sessionInfo}finally{null!=i&&i._reset()}}async function si(e,t,r){m(r.type===ei,e,"argument-error");var i,n,s,r=await r.verify(),e=(m("string"==typeof r,e,"argument-error"),Object.assign({},t));return"phoneEnrollmentInfo"in e?(t=e.phoneEnrollmentInfo.phoneNumber,n=e.phoneEnrollmentInfo.captchaResponse,s=e.phoneEnrollmentInfo.clientType,i=e.phoneEnrollmentInfo.recaptchaVersion,Object.assign(e,{phoneEnrollmentInfo:{phoneNumber:t,recaptchaToken:r,captchaResponse:n,clientType:s,recaptchaVersion:i}})):"phoneSignInInfo"in e?(t=e.phoneSignInInfo.captchaResponse,n=e.phoneSignInInfo.clientType,s=e.phoneSignInInfo.recaptchaVersion,Object.assign(e,{phoneSignInInfo:{recaptchaToken:r,captchaResponse:t,clientType:n,recaptchaVersion:s}})):Object.assign(e,{recaptchaToken:r}),e}class O{constructor(e){this.providerId=O.PROVIDER_ID,this.auth=I(e)}verifyPhoneNumber(e,t){return ni(this.auth,e,s(t))}static credential(e,t){return Vt._fromVerification(e,t)}static credentialFromResult(e){return O.credentialFromTaggedObject(e)}static credentialFromError(e){return O.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){var t;return e&&({phoneNumber:e,temporaryProof:t}=e,e)&&t?Vt._fromTokenResponse(e,t):null}}function ai(e,t){return t?_(t):(m(e._popupRedirectResolver,e,"argument-error"),e._popupRedirectResolver)}O.PROVIDER_ID="phone",O.PHONE_SIGN_IN_METHOD="phone";class oi extends At{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return T(e,this._buildIdpRequest())}_linkToIdToken(e,t){return T(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return T(e,this._buildIdpRequest())}_buildIdpRequest(e){var 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 li(e){return er(e.auth,new oi(e),e.bypassAuthState)}function ci(e){var{auth:t,user:r}=e;return m(r,t,"internal-error"),Zt(r,new oi(e),e.bypassAuthState)}async function ui(e){var{auth:t,user:r}=e;return m(r,t,"internal-error"),Xt(r,new oi(e),e.bypassAuthState)}class di{constructor(e,t,r,i,n=!1){this.auth=e,this.resolver=r,this.user=i,this.bypassAuthState=n,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:e,sessionId:t,postBody:r,tenantId:i,error:n,type:s}=e;if(n)this.reject(n);else{n={auth:this.auth,requestUri:e,sessionId:t,tenantId:i||void 0,postBody:r||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(s)(n))}catch(e){this.reject(e)}}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return li;case"linkViaPopup":case"linkViaRedirect":return ui;case"reauthViaPopup":case"reauthViaRedirect":return ci;default:u(this.auth,"internal-error")}}resolve(e){a(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){a(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()}}let hi=new Se(2e3,1e4);class N extends di{constructor(e,t,r,i,n){super(e,t,i,n),this.provider=r,this.authWindow=null,this.pollId=null,N.currentPopupAction&&N.currentPopupAction.cancel(),N.currentPopupAction=this}async executeNotNull(){var e=await this.execute();return m(e,this.auth,"internal-error"),e}async onExecution(){a(1===this.filter.length,"Popup operations only handle one event");var e=Ur();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(d(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return(null==(e=this.authWindow)?void 0:e.associatedEvent)||null}cancel(){this.reject(d(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,N.currentPopupAction=null}pollUserCancellation(){let t=()=>{var e;null!=(e=null==(e=this.authWindow)?void 0:e.window)&&e.closed?this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(d(this.auth,"popup-closed-by-user"))},8e3):this.pollId=window.setTimeout(t,hi.get())};t()}}N.currentPopupAction=null;let pi="pendingRedirect",mi=new Map;class gi extends di{constructor(e,t,r=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,r),this.eventId=null}async execute(){let t=mi.get(this.auth._key());if(!t){try{let e=await(async(e,t)=>{var r;return t=yi(t),!!await(e=_i(e))._isAvailable()&&(r="true"===await e._get(t),await e._remove(t),r)})(this.resolver,this.auth)?await super.execute():null;t=()=>Promise.resolve(e)}catch(e){t=()=>Promise.reject(e)}mi.set(this.auth._key(),t)}return this.bypassAuthState||mi.set(this.auth._key(),()=>Promise.resolve(null)),t()}async onAuthEvent(e){if("signInViaRedirect"===e.type)return super.onAuthEvent(e);if("unknown"===e.type)this.resolve(null);else if(e.eventId){var t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function fi(e,t){return _i(e)._set(yi(t),"true")}function vi(e,t){mi.set(e._key(),t)}function _i(e){return _(e._redirectPersistence)}function yi(e){return y(pi,e.config.apiKey,e.name)}function Ii(e,t,r){return(async(e,t,r)=>{var i;return qn._isFirebaseServerApp(e.app)?Promise.reject(h(e)):(i=I(e),we(e,t,b),await i._initializationPromise,await fi(e=ai(i,r),i),e._openRedirect(i,t,"signInViaRedirect"))})(e,t,r)}function wi(e,t,r){return(async(e,t,r)=>{if(we((e=s(e)).auth,t,b),qn._isFirebaseServerApp(e.auth.app))return Promise.reject(h(e.auth));await e.auth._initializationPromise;await fi(r=ai(e.auth,r),e.auth);var i=await bi(e);return r._openRedirect(e.auth,t,"reauthViaRedirect",i)})(e,t,r)}function Ti(e,t,r){return(async(e,t,r)=>{we((e=s(e)).auth,t,b),await e.auth._initializationPromise;var r=ai(e.auth,r),i=(await Qt(!1,e,t.providerId),await fi(r,e.auth),await bi(e));return r._openRedirect(e.auth,t,"linkViaRedirect",i)})(e,t,r)}async function Ei(e,t,r=!1){var i;return qn._isFirebaseServerApp(e.app)?Promise.reject(h(e)):(i=ai(e=I(e),t),(i=await new gi(e,i,r).execute())&&!r&&(delete i.user._redirectEventId,await e._persistUserIfCurrent(i.user),await e._setRedirectUser(null,t)),i)}async function bi(e){var t=Ur(e.uid+":::");return e._redirectEventId=t,await e.auth._setRedirectUser(e),await e.auth._persistUserIfCurrent(e),t}class ki{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 r=!1;return this.consumers.forEach(e=>{this.isEventForConsumer(t,e)&&(r=!0,this.sendToConsumer(t,e),this.saveEventToCache(t))}),this.hasHandledPotentialRedirect||!(e=>{switch(e.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return 1;case"unknown":return Ri(e);default:return}})(t)||(this.hasHandledPotentialRedirect=!0,r)||(this.queuedRedirectEvent=t,r=!0),r}sendToConsumer(e,t){var r;e.error&&!Ri(e)?(r=(null==(r=e.error.code)?void 0:r.split("auth/")[1])||"internal-error",t.onError(d(this.auth,r))):t.onAuthEvent(e)}isEventForConsumer(e,t){var r=null===t.eventId||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&r}hasEventBeenHandled(e){return 6e5<=Date.now()-this.lastProcessedEventTime&&this.cachedEventUids.clear(),this.cachedEventUids.has(Si(e))}saveEventToCache(e){this.cachedEventUids.add(Si(e)),this.lastProcessedEventTime=Date.now()}}function Si(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(e=>e).join("-")}function Ri({type:e,error:t}){return"unknown"===e&&"auth/no-auth-event"===(null==t?void 0:t.code)}async function Ai(e,t={}){return p(e,"GET","/v1/projects",t)}let Pi=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,Ci=/^https?/;async function Oi(e){if(!e.config.emulator){var t,r=(await Ai(e)).authorizedDomains;for(t of r)try{if((e=>{var t,r=Ee(),{protocol:i,hostname:n}=new URL(r);return e.startsWith("chrome-extension://")?""===(t=new URL(e)).hostname&&""===n?"chrome-extension:"===i&&e.replace("chrome-extension://","")===r.replace("chrome-extension://",""):"chrome-extension:"===i&&t.hostname===n:Ci.test(i)&&(Pi.test(e)?n===e:(r=e.replace(/\./g,"\\."),(t=new RegExp("^(.+\\."+r+"|"+r+")$","i")).test(n)))})(t))return}catch(e){}u(e,"unauthorized-domain")}}let Ni=new Se(3e4,6e4);function Li(){var t=C().___jsl;if(null!=t&&t.H)for(var 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<t.CP.length;e++)t.CP[e]=null}function Di(n){return new Promise((e,t)=>{var r;function i(){Li(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{Li(),t(d(n,"network-request-failed"))},timeout:Ni.get()})}if(null!=(r=null==(r=C().gapi)?void 0:r.iframes)&&r.Iframe)e(gapi.iframes.getContext());else{if(null==(r=C().gapi)||!r.load)return r=vt("iframefcb"),C()[r]=()=>{gapi.load?i():t(d(n,"network-request-failed"))},ft(gt.gapiScript+"?onload="+r).catch(e=>t(e));i()}}).catch(e=>{throw Mi=null,e})}let Mi=null;let Ui=new Se(5e3,15e3),Fi="__/auth/iframe",Vi="emulator/auth/iframe",xi={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},ji=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);async function Hi(a){i=a;var e,t,r,i=await(Mi=Mi||Di(i)),n=C().gapi;return m(n,a,"internal-error"),i.open({where:document.body,url:(m((t=(i=a).config).authDomain,i,"auth-domain-config-required"),e=t.emulator?Re(t,Vi):`https://${i.config.authDomain}/`+Fi,t={apiKey:t.apiKey,appName:i.name,v:qn.SDK_VERSION},(r=ji.get(i.config.apiHost))&&(t.eid=r),(r=i._getFrameworks()).length&&(t.fw=r.join(",")),e+"?"+te(t).slice(1)),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:xi,dontclear:!0},s=>new Promise(async(e,t)=>{await s.restyle({setHideOnLeave:!1});let r=d(a,"network-request-failed"),i=C().setTimeout(()=>{t(r)},Ui.get());function n(){C().clearTimeout(i),e(s)}s.ping(n).then(n,()=>{t(r)})}))}let Wi={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class qi{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(e){}}}function Bi(e,t,r,i=500,n=600){var s=Math.max((window.screen.availHeight-n)/2,0).toString(),a=Math.max((window.screen.availWidth-i)/2,0).toString();let o="";var i=Object.assign(Object.assign({},Wi),{width:i.toString(),height:n.toString(),top:s,left:a}),n=l().toLowerCase(),s=(r&&(o=it(n)?"_blank":r),tt(n)&&(t=t||"http://localhost",i.scrollbars="yes"),Object.entries(i).reduce((e,[t,r])=>""+e+t+`=${r},`,""));if([a=l()]=[n],lt(a)&&null!=(a=window.navigator)&&a.standalone&&"_self"!==o)return r=t||"",i=o,(n=document.createElement("a")).href=r,n.target=i,(r=document.createEvent("MouseEvent")).initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(r),new qi(null);a=window.open(t||"",o,s);m(a,e,"popup-blocked");try{a.focus()}catch(e){}return new qi(a)}let zi="__/auth/handler",Gi="emulator/auth/handler",Ki=encodeURIComponent("fac");async function Ji(e,t,r,i,n,s){m(e.config.authDomain,e,"auth-domain-config-required"),m(e.config.apiKey,e,"invalid-api-key");var a={apiKey:e.config.apiKey,appName:e.name,authType:r,redirectUrl:i,v:qn.SDK_VERSION,eventId:n};if(t instanceof b){t.setDefaultLanguage(e.languageCode),a.providerId=t.providerId||"",(e=>{for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return;return 1})(t.getCustomParameters())||(a.customParameters=JSON.stringify(t.getCustomParameters()));for(var[o,l]of Object.entries(s||{}))a[o]=l}t instanceof Ht&&0<(r=t.getScopes().filter(e=>""!==e)).length&&(a.scopes=r.join(",")),e.tenantId&&(a.tid=e.tenantId);var c,u=a;for(c of Object.keys(u))void 0===u[c]&&delete u[c];i=await e._getAppCheckToken(),n=i?`#${Ki}=`+encodeURIComponent(i):"";return`${s=[e.config][0],s.emulator?Re(s,Gi):`https://${s.authDomain}/`+zi}?`+te(u).slice(1)+n}let Yi="webStorageSupport";class $i{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Dr,this._completeRedirectFn=Ei,this._overrideRedirectResult=vi}async _openPopup(e,t,r,i){a(null==(n=this.eventManagers[e._key()])?void 0:n.manager,"_initialize() not called before _openPopup()");var n=await Ji(e,t,r,Ee(),i);return Bi(e,n,Ur())}async _openRedirect(e,t,r,i){await this._originValidation(e);e=await Ji(e,t,r,Ee(),i);return C().location.href=e,new Promise(()=>{})}_initialize(e){let r=e._key();if(this.eventManagers[r]){let{manager:e,promise:t}=this.eventManagers[r];return e?Promise.resolve(e):(a(t,"If manager is not set, promise should be"),t)}let t=this.initAndGetManager(e);return this.eventManagers[r]={promise:t},t.catch(()=>{delete this.eventManagers[r]}),t}async initAndGetManager(t){var e=await Hi(t);let r=new ki(t);return e.register("authEvent",e=>(m(null==e?void 0:e.authEvent,t,"invalid-auth-event"),{status:r.onEvent(e.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[t._key()]={manager:r},this.iframes[t._key()]=e,r}_isIframeWebStorageSupported(t,r){this.iframes[t._key()].send(Yi,{type:Yi},e=>{e=null==(e=null==e?void 0:e[0])?void 0:e[Yi];void 0!==e&&r(!!e),u(t,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){var t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=Oi(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return ct()||rt()||lt()}}let Xi=$i;class Qi extends class{constructor(e){this.factorId=e}_process(e,t,r){switch(t.type){case"enroll":return this._finalizeEnroll(e,t.credential,r);case"signin":return this._finalizeSignIn(e,t.credential);default:return n("unexpected MultiFactorSessionType")}}}{constructor(e){super("phone"),this.credential=e}static _fromCredential(e){return new Qi(e)}_finalizeEnroll(e,t,r){return e=e,t={idToken:t,displayName:r,phoneVerificationInfo:this.credential._makeVerificationRequest()},p(e,"POST","/v2/accounts/mfaEnrollment:finalize",o(e,t))}_finalizeSignIn(e,t){return e=e,t={mfaPendingCredential:t,phoneVerificationInfo:this.credential._makeVerificationRequest()},p(e,"POST","/v2/accounts/mfaSignIn:finalize",o(e,t))}}class Zi{constructor(){}static assertion(e){return Qi._fromCredential(e)}}Zi.FACTOR_ID="phone";var e="@firebase/auth";class en{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),(null==(e=this.auth.currentUser)?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.stsTokenManager.accessToken)||null)}),this.internalListeners.set(t,e),this.updateProactiveRefresh())}removeAuthTokenListener(e){this.assertAuthConfigured();var t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){m(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){0<this.internalListeners.size?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}var tn,rn;function nn(){return window}tn="authIdTokenMaxAge",null!=(_n=z())&&_n["_"+tn],gt={loadJS(i){return new Promise((e,r)=>{var t=document.createElement("script");t.setAttribute("src",i),t.onload=e,t.onerror=e=>{var t=d("internal-error");t.customData=e,r(t)},t.type="text/javascript",t.charset="UTF-8",(null!=(e=null==(e=document.getElementsByTagName("head"))?void 0:e[0])?e:document).appendChild(t)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="},rn="Browser",qn._registerComponent(new de("auth",(e,{options:t})=>{var r=e.getProvider("app").getImmediate(),i=e.getProvider("heartbeat"),e=e.getProvider("app-check-internal"),{apiKey:n,authDomain:s}=r.options,n=(m(n&&!n.includes(":"),"invalid-api-key",{appName:r.name}),{apiKey:n,authDomain:s,clientPlatform:rn,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:ut(rn)}),s=new pt(r,i,e,n);return r=s,e=(null==(i=t)?void 0:i.persistence)||[],e=(Array.isArray(e)?e:[e]).map(_),null!=i&&i.errorMap&&r._updateErrorMap(i.errorMap),r._initializeWithPersistence(e,null==i?void 0:i.popupRedirectResolver),s},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,r)=>{e.getProvider("auth-internal").initialize()})),qn._registerComponent(new de("auth-internal",e=>{var e=I(e.getProvider("auth").getImmediate());return e=e,new en(e)},"PRIVATE").setInstantiationMode("EXPLICIT")),qn.registerVersion(e,"1.10.0",(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}})(rn)),qn.registerVersion(e,"1.10.0","esm2017");async function sn(e,t,r){var i=nn().BuildInfo,n=(a(t.sessionId,"AuthEvent did not contain a session ID"),await(async e=>(e=(t=>{if(a(/[0-9a-zA-Z]+/.test(t),"Can only convert alpha-numeric strings"),"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);var e=new ArrayBuffer(t.length),r=new Uint8Array(e);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r})(e),e=await crypto.subtle.digest("SHA-256",e),(e=Array.from(new Uint8Array(e))).map(e=>e.toString(16).padStart(2,"0")).join("")))(t.sessionId)),s={};return lt()?s.ibi=i.packageName:st()?s.apn=i.packageName:u(e,"operation-not-supported-in-this-environment"),i.displayName&&(s.appDisplayName=i.displayName),s.sessionId=n,Ji(e,r,t.type,void 0,null!=(i=t.eventId)?i:void 0,s)}function an(i){let n=nn().cordova;return new Promise(r=>{n.plugins.browsertab.isAvailable(e=>{let t=null;e?n.plugins.browsertab.openUrl(i):t=n.InAppBrowser.open(i,(e=l(),/(iPad|iPhone|iPod).*OS 7_\d/i.test(e)||/(iPad|iPhone|iPod).*OS 8_\d/i.test(e)?"_blank":"_system"),"location=yes"),r(t)})})}let on=20;class ln extends ki{constructor(){super(...arguments),this.passiveListeners=new Set,this.initPromise=new Promise(e=>{this.resolveInitialized=e})}addPassiveListener(e){this.passiveListeners.add(e)}removePassiveListener(e){this.passiveListeners.delete(e)}resetRedirect(){this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1}onEvent(t){return this.resolveInitialized(),this.passiveListeners.forEach(e=>e(t)),super.onEvent(t)}async initialized(){await this.initPromise}}function cn(e,t,r=null){return{type:t,eventId:r,urlResponse:null,sessionId:(()=>{var t=[],r="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let e=0;e<on;e++){var i=Math.floor(Math.random()*r.length);t.push(r.charAt(i))}return t.join("")})(),postBody:null,tenantId:e.tenantId,error:d(e,"no-auth-event")}}async function un(e){var t=await hn()._get(pn(e));return t&&await hn()._remove(pn(e)),t}function dn(e,t){n=mn(t=t),i=n.link?decodeURIComponent(n.link):void 0,r=mn(i).link,n=n.deep_link_id?decodeURIComponent(n.deep_link_id):void 0;var r,i,n=mn(n).link||n||r||i||t;return n.includes("/__/auth/callback")?(t=(i=null==(r=null==(t=null==(i=(r=mn(n)).firebaseError?(e=>{try{return JSON.parse(e)}catch(e){return null}})(decodeURIComponent(r.firebaseError)):null)?void 0:i.code)?void 0:t.split("auth/"))?void 0:r[1])?d(i):null)?{type:e.type,eventId:e.eventId,tenantId:e.tenantId,error:t,urlResponse:null,sessionId:null,postBody:null}:{type:e.type,eventId:e.eventId,tenantId:e.tenantId,sessionId:e.sessionId,urlResponse:n,postBody:null}:null}function hn(){return _(Nr)}function pn(e){return y("authEvent",e.config.apiKey,e.name)}function mn(e){var t;return null!=e&&e.includes("?")?([t,...e]=e.split("?"),re(e.join("?"))):{}}class gn{constructor(){this._redirectPersistence=Dr,this._shouldInitProactively=!0,this.eventManagers=new Map,this.originValidationPromises={},this._completeRedirectFn=Ei,this._overrideRedirectResult=vi}async _initialize(e){var t=e._key();let r=this.eventManagers.get(t);return r||(r=new ln(e),this.eventManagers.set(t,r),this.attachCallbackListeners(e,r)),r}_openPopup(e){u(e,"operation-not-supported-in-this-environment")}async _openRedirect(e,t,r,i){n=e,a=nn(),m("function"==typeof(null==(s=null==a?void 0:a.universalLinks)?void 0:s.subscribe),n,"invalid-cordova-configuration",{missingPlugin:"cordova-universal-links-plugin-fix"}),m(void 0!==(null==(s=null==a?void 0:a.BuildInfo)?void 0:s.packageName),n,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-buildInfo"}),m("function"==typeof(null==(s=null==(s=null==(s=null==a?void 0:a.cordova)?void 0:s.plugins)?void 0:s.browsertab)?void 0:s.openUrl),n,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-browsertab"}),m("function"==typeof(null==(s=null==(s=null==(s=null==a?void 0:a.cordova)?void 0:s.plugins)?void 0:s.browsertab)?void 0:s.isAvailable),n,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-browsertab"}),m("function"==typeof(null==(a=null==(s=null==a?void 0:a.cordova)?void 0:s.InAppBrowser)?void 0:a.open),n,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-inappbrowser"});var n,s=await this._initialize(e),a=(await s.initialized(),s.resetRedirect(),mi.clear(),await this._originValidation(e),cn(e,r,i)),i=(n=e,r=a,await hn()._set(pn(n),r),await sn(e,a,t));return(async(a,o,l)=>{let c=nn().cordova,u=()=>{};try{await new Promise((t,e)=>{let r=null;function i(){t();var e=null==(e=c.plugins.browsertab)?void 0:e.close;"function"==typeof e&&e(),"function"==typeof(null==l?void 0:l.close)&&l.close()}function n(){r=r||window.setTimeout(()=>{e(d(a,"redirect-cancelled-by-user"))},2e3)}function s(){"visible"===(null==document?void 0:document.visibilityState)&&n()}o.addPassiveListener(i),document.addEventListener("resume",n,!1),st()&&document.addEventListener("visibilitychange",s,!1),u=()=>{o.removePassiveListener(i),document.removeEventListener("resume",n,!1),document.removeEventListener("visibilitychange",s,!1),r&&window.clearTimeout(r)}})}finally{u()}})(e,s,await an(i))}_isIframeWebStorageSupported(e,t){throw new Error("Method not implemented.")}_originValidation(e){var t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=(async e=>{var t=nn().BuildInfo,r={};lt()?r.iosBundleId=t.packageName:st()?r.androidPackageName=t.packageName:u(e,"operation-not-supported-in-this-environment"),await Ai(e,r)})(e)),this.originValidationPromises[t]}attachCallbackListeners(i,n){var{universalLinks:e,handleOpenURL:t,BuildInfo:r}=nn();let s=setTimeout(async()=>{await un(i),n.onEvent(vn())},500),a=async e=>{clearTimeout(s);var t=await un(i);let r=null;t&&null!=e&&e.url&&(r=dn(t,e.url)),n.onEvent(r||vn())},o=(void 0!==e&&"function"==typeof e.subscribe&&e.subscribe(null,a),t),l=r.packageName.toLowerCase()+"://";nn().handleOpenURL=async e=>{if(e.toLowerCase().startsWith(l)&&a({url:e}),"function"==typeof o)try{o(e)}catch(e){console.error(e)}}}}let fn=gn;function vn(){return{type:"unknown",eventId:null,sessionId:null,urlResponse:null,postBody:null,tenantId:null,error:d("no-auth-event")}}var _n;function yn(){var e;return(null==(e=null==self?void 0:self.location)?void 0:e.protocol)||null}function In(e=l()){return!("file:"!==yn()&&"ionic:"!==yn()&&"capacitor:"!==yn()||!e.toLowerCase().match(/iphone|ipad|ipod|android/))}function wn(e=l()){return Y()&&11===(null==document?void 0:document.documentMode)||([e=l()]=[e],/Edge\/\d+/.test(e))}function Tn(){try{var e=self.localStorage,t=Ur();if(e)return e.setItem(t,"1"),e.removeItem(t),!wn()||$()}catch(e){return En()&&$()}return!1}function En(){return"undefined"!=typeof global&&"WorkerGlobalScope"in global&&"importScripts"in global}function bn(){return("http:"===yn()||"https:"===yn()||K()||In())&&!(J()||G())&&Tn()&&!En()}function kn(){return In()&&"undefined"!=typeof document}let L={LOCAL:"local",NONE:"none",SESSION:"session"},Sn=m,Rn="persistence";async function An(e){await e._initializationPromise;var t=Pn(),r=y(Rn,e.config.apiKey,e.name);t&&t.setItem(r,e._getPersistenceType())}function Pn(){var e;try{return(null===(e="undefined"!=typeof window?window:null)?void 0:e.sessionStorage)||null}catch(e){return null}}let Cn=m;class D{constructor(){this.browserResolver=_(Xi),this.cordovaResolver=_(fn),this.underlyingResolver=null,this._redirectPersistence=Dr,this._completeRedirectFn=Ei,this._overrideRedirectResult=vi}async _initialize(e){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._initialize(e)}async _openPopup(e,t,r,i){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._openPopup(e,t,r,i)}async _openRedirect(e,t,r,i){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._openRedirect(e,t,r,i)}_isIframeWebStorageSupported(e,t){this.assertedUnderlyingResolver._isIframeWebStorageSupported(e,t)}_originValidation(e){return this.assertedUnderlyingResolver._originValidation(e)}get _shouldInitProactively(){return kn()||this.browserResolver._shouldInitProactively}get assertedUnderlyingResolver(){return Cn(this.underlyingResolver,"internal-error"),this.underlyingResolver}async selectUnderlyingResolver(){var e;this.underlyingResolver||(e=await(!!kn()&&new Promise(e=>{let t=setTimeout(()=>{e(!1)},1e3);document.addEventListener("deviceready",()=>{clearTimeout(t),e(!0)})})),this.underlyingResolver=e?this.cordovaResolver:this.browserResolver)}}function On(e){return e.unwrap()}function Nn(e,t){var r,i,n=null==(n=t.customData)?void 0:n._tokenResponse;"auth/multi-factor-auth-required"===(null==t?void 0:t.code)?t.resolver=new Mn(e,(r=t,e=s(e=e),m((i=r).customData.operationType,e,"argument-error"),m(null==(r=i.customData._serverResponse)?void 0:r.mfaPendingCredential,e,"argument-error"),kr._fromError(e,i))):n&&(e=Ln(r=t))&&(r.credential=e,r.tenantId=n.tenantId||void 0,r.email=n.email||void 0,r.phoneNumber=n.phoneNumber||void 0)}function Ln(e){var t=(e instanceof c?e.customData:e)._tokenResponse;if(!t)return null;if(!(e instanceof c)&&"temporaryProof"in t&&"phoneNumber"in t)return O.credentialFromResult(e);var r=t.providerId;if(!r||r===he.PASSWORD)return null;let i;switch(r){case he.GOOGLE:i=S;break;case he.FACEBOOK:i=k;break;case he.GITHUB:i=R;break;case he.TWITTER:i=A;break;default:var{oauthIdToken:n,oauthAccessToken:s,oauthTokenSecret:a,pendingToken:o,nonce:l}=t;return s||a||n||o?o?r.startsWith("saml.")?qt._create(r,o):E._fromParams({providerId:r,signInMethod:r,pendingToken:o,idToken:n,accessToken:s}):new Wt(r).credential({idToken:n,accessToken:s,rawNonce:l}):null}return e instanceof c?i.credentialFromError(e):i.credentialFromResult(e)}function M(t,e){return e.catch(e=>{throw e instanceof c&&Nn(t,e),e}).then(e=>{var t=e.operationType,r=e.user;return{operationType:t,credential:Ln(e),additionalUserInfo:Er(e),user:U.getOrCreate(r)}})}async function Dn(t,e){let r=await e;return{verificationId:r.verificationId,confirm:e=>M(t,r.confirm(e))}}class Mn{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 M(On(this.auth),this.resolver.resolveSignIn(e))}}class U{constructor(e){this._delegate=e,this.multiFactor=(e=s(e=e),Ar.has(e)||Ar.set(e,Rr._fromUser(e)),Ar.get(e))}static getOrCreate(e){return U.USER_MAP.has(e)||U.USER_MAP.set(e,new U(e)),U.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 M(this.auth,rr(this._delegate,e))}async linkWithPhoneNumber(e,t){return Dn(this.auth,(async(e,t,r)=>{let i=s(e);return await Qt(!1,i,"phone"),e=await ni(i.auth,t,s(r)),new ii(e,e=>rr(i,e))})(this._delegate,e,t))}async linkWithPopup(e){return M(this.auth,(async(e,t,r)=>(we((e=s(e)).auth,t,b),r=ai(e.auth,r),new N(e.auth,"linkViaPopup",t,r,e).executeNotNull()))(this._delegate,e,D))}async linkWithRedirect(e){return await An(I(this.auth)),Ti(this._delegate,e,D)}reauthenticateAndRetrieveDataWithCredential(e){return this.reauthenticateWithCredential(e)}async reauthenticateWithCredential(e){return M(this.auth,ir(this._delegate,e))}reauthenticateWithPhoneNumber(e,t){return Dn(this.auth,(async(e,t,r)=>{let i=s(e);return qn._isFirebaseServerApp(i.auth.app)?Promise.reject(h(i.auth)):(e=await ni(i.auth,t,s(r)),new ii(e,e=>ir(i,e)))})(this._delegate,e,t))}reauthenticateWithPopup(e){return M(this.auth,(async(e,t,r)=>(e=s(e),qn._isFirebaseServerApp(e.auth.app)?Promise.reject(d(e.auth,"operation-not-supported-in-this-environment")):(we(e.auth,t,b),r=ai(e.auth,r),new N(e.auth,"reauthViaPopup",t,r,e).executeNotNull())))(this._delegate,e,D))}async reauthenticateWithRedirect(e){return await An(I(this.auth)),wi(this._delegate,e,D)}sendEmailVerification(e){return pr(this._delegate,e)}async unlink(e){return await $t(this._delegate,e),this}updateEmail(e){return t=this._delegate,e=e,t=s(t),qn._isFirebaseServerApp(t.auth.app)?Promise.reject(h(t.auth)):fr(t,e,null);var t}updatePassword(e){return fr(s(this._delegate),null,e)}updatePhoneNumber(e){return(async(e,t)=>{if(e=s(e),qn._isFirebaseServerApp(e.auth.app))return Promise.reject(h(e.auth));await Xt(e,t)})(this._delegate,e)}updateProfile(e){return gr(this._delegate,e)}verifyBeforeUpdateEmail(e,t){return mr(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}}U.USER_MAP=new WeakMap;let Un=m;class Fn{constructor(e,t){var r,i;this.app=e,t.isInitialized()?this._delegate=t.getImmediate():(r=e.options.apiKey,Un(r,"invalid-api-key",{appName:e.name}),Un(r,"invalid-api-key",{appName:e.name}),i="undefined"!=typeof window?D:void 0,this._delegate=t.initialize({options:{persistence:((e,t)=>{var r=((e,t)=>{var r=Pn();if(!r)return[];switch(e=y(Rn,e,t),r.getItem(e)){case L.NONE:return[Qe];case L.LOCAL:return[Jr,Dr];case L.SESSION:return[Dr];default:return[]}})(e,t);if("undefined"==typeof self||r.includes(Jr)||r.push(Jr),"undefined"!=typeof window)for(var i of[Nr,Dr])r.includes(i)||r.push(i);return r.includes(Qe)||r.push(Qe),r})(r,e.name),popupRedirectResolver:i}}),this._delegate._updateErrorMap(ge)),this.linkUnderlyingAuth()}get emulatorConfig(){return this._delegate.emulatorConfig}get currentUser(){return this._delegate.currentUser?U.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){kt(this._delegate,e,t)}applyActionCode(e){return ur(this._delegate,e)}checkActionCode(e){return dr(this._delegate,e)}confirmPasswordReset(e,t){return(async(t,e,r)=>{await Pt(s(t),{oobCode:e,newPassword:r}).catch(async e=>{throw"auth/password-does-not-meet-requirements"===e.code&&cr(t),e})})(this._delegate,e,t)}async createUserWithEmailAndPassword(e,t){return M(this._delegate,(async(t,e,r)=>{var i;return qn._isFirebaseServerApp(t.app)?Promise.reject(h(t)):(e=await w(i=I(t),{returnSecureToken:!0,email:e,password:r,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",zt,"EMAIL_PASSWORD_PROVIDER").catch(e=>{throw"auth/password-does-not-meet-requirements"===e.code&&cr(t),e}),r=await P._fromIdTokenResponse(i,"signIn",e),await i._updateCurrentUser(r.user),r)})(this._delegate,e,t))}fetchProvidersForEmail(e){return this.fetchSignInMethodsForEmail(e)}fetchSignInMethodsForEmail(e){return hr(this._delegate,e)}isSignInWithEmailLink(e){return this._delegate,e=e,"EMAIL_SIGNIN"===(null==(e=xt.parseLink(e))?void 0:e.operation)}async getRedirectResult(){Un(bn(),this._delegate,"operation-not-supported-in-this-environment");t=this._delegate,e=D,await I(t)._initializationPromise;var e,t=await Ei(t,e,!1);return t?M(this._delegate,Promise.resolve(t)):{credential:null,user:null}}addFrameworkForLogging(e){I(this._delegate)._logFramework(e)}onAuthStateChanged(e,t,r){var{next:e,error:t,complete:r}=Vn(e,t,r);return this._delegate.onAuthStateChanged(e,t,r)}onIdTokenChanged(e,t,r){var{next:e,error:t,complete:r}=Vn(e,t,r);return this._delegate.onIdTokenChanged(e,t,r)}sendSignInLinkToEmail(e,t){return(async(e,t,r)=>{let i=I(e);t=e={requestType:"EMAIL_SIGNIN",email:t,clientType:"CLIENT_TYPE_WEB"},m((r=r).handleCodeInApp,i,"argument-error"),r&&lr(i,t,r),await w(i,e,"getOobCode",Dt,"EMAIL_PASSWORD_PROVIDER")})(this._delegate,e,t)}sendPasswordResetEmail(e,t){return(async(e,t,r)=>{e=I(e),t={requestType:"PASSWORD_RESET",email:t,clientType:"CLIENT_TYPE_WEB"},r&&lr(e,t,r),await w(e,t,"getOobCode",Lt,"EMAIL_PASSWORD_PROVIDER")})(this._delegate,e,t||void 0)}async setPersistence(e){var t,r;t=this._delegate,r=e,Sn(Object.values(L).includes(r),t,"invalid-persistence-type"),J()?Sn(r!==L.SESSION,t,"unsupported-persistence-type"):G()?Sn(r===L.NONE,t,"unsupported-persistence-type"):En()?Sn(r===L.NONE||r===L.LOCAL&&$(),t,"unsupported-persistence-type"):Sn(r===L.NONE||Tn(),t,"unsupported-persistence-type");let i;switch(e){case L.SESSION:i=Dr;break;case L.LOCAL:var n=await _(Jr)._isAvailable();i=n?Jr:Nr;break;case L.NONE:i=Qe;break;default:return u("argument-error",{appName:this._delegate.name})}return this._delegate.setPersistence(i)}signInAndRetrieveDataWithCredential(e){return this.signInWithCredential(e)}signInAnonymously(){return M(this._delegate,(async e=>{var t;return qn._isFirebaseServerApp(e.app)?Promise.reject(h(e)):(await(e=I(e))._initializationPromise,null!=(t=e.currentUser)&&t.isAnonymous?new P({user:e.currentUser,providerId:null,operationType:"signIn"}):(t=await zt(e,{returnSecureToken:!0}),t=await P._fromIdTokenResponse(e,"signIn",t,!0),await e._updateCurrentUser(t.user),t))})(this._delegate))}signInWithCredential(e){return M(this._delegate,tr(this._delegate,e))}signInWithCustomToken(e){return M(this._delegate,nr(this._delegate,e))}signInWithEmailAndPassword(e,t){return M(this._delegate,(r=this._delegate,e=e,t=t,qn._isFirebaseServerApp(r.app)?Promise.reject(h(r)):tr(s(r),jt.credential(e,t)).catch(async e=>{throw"auth/password-does-not-meet-requirements"===e.code&&cr(r),e})));var r}signInWithEmailLink(e,t){return M(this._delegate,(async(e,t,r)=>qn._isFirebaseServerApp(e.app)?Promise.reject(h(e)):(e=s(e),m((t=jt.credentialWithLink(t,r||Ee()))._tenantId===(e.tenantId||null),e,"tenant-id-mismatch"),tr(e,t)))(this._delegate,e,t))}signInWithPhoneNumber(e,t){return Dn(this._delegate,(async(e,t,r)=>{if(qn._isFirebaseServerApp(e.app))return Promise.reject(h(e));let i=I(e);return e=await ni(i,t,s(r)),new ii(e,e=>tr(i,e))})(this._delegate,e,t))}async signInWithPopup(e){return Un(bn(),this._delegate,"operation-not-supported-in-this-environment"),M(this._delegate,(async(e,t,r)=>{var i;return qn._isFirebaseServerApp(e.app)?Promise.reject(d(e,"operation-not-supported-in-this-environment")):(i=I(e),we(e,t,b),e=ai(i,r),new N(i,"signInViaPopup",t,e).executeNotNull())})(this._delegate,e,D))}async signInWithRedirect(e){return Un(bn(),this._delegate,"operation-not-supported-in-this-environment"),await An(this._delegate),Ii(this._delegate,e,D)}updateCurrentUser(e){return this._delegate.updateCurrentUser(e)}verifyPasswordResetCode(e){return(async(e,t)=>(e=(await dr(s(e),t)).data).email)(this._delegate,e)}unwrap(){return this._delegate}_delete(){return this._delegate._delete()}linkUnderlyingAuth(){this._delegate.wrapped=()=>this}}function Vn(e,t,r){let i=e,n=("function"!=typeof e&&({next:i,error:t,complete:r}=e),i);return{next:e=>n(e&&U.getOrCreate(e)),error:t,complete:r}}Fn.Persistence=L;class xn{static credential(e,t){return O.credential(e,t)}constructor(){this.providerId="phone",this._delegate=new O(On(F.default.auth()))}verifyPhoneNumber(e,t){return this._delegate.verifyPhoneNumber(e,t)}unwrap(){return this._delegate}}xn.PHONE_SIGN_IN_METHOD=O.PHONE_SIGN_IN_METHOD,xn.PROVIDER_ID=O.PROVIDER_ID;let jn=m;class Hn{constructor(e,t,r=F.default.app()){var i;jn(null==(i=r.options)?void 0:i.apiKey,"invalid-api-key",{appName:r.name}),this._delegate=new ri(r.auth(),e,t),this.type=this._delegate.type}clear(){this._delegate.clear()}render(){return this._delegate.render()}verify(){return this._delegate.verify()}}(_n=F.default).INTERNAL.registerComponent(new de("auth-compat",e=>{var t=e.getProvider("app-compat").getImmediate(),e=e.getProvider("auth");return new Fn(t,e)},"PUBLIC").setServiceProps({ActionCodeInfo:{Operation:{EMAIL_SIGNIN:pe.EMAIL_SIGNIN,PASSWORD_RESET:pe.PASSWORD_RESET,RECOVER_EMAIL:pe.RECOVER_EMAIL,REVERT_SECOND_FACTOR_ADDITION:pe.REVERT_SECOND_FACTOR_ADDITION,VERIFY_AND_CHANGE_EMAIL:pe.VERIFY_AND_CHANGE_EMAIL,VERIFY_EMAIL:pe.VERIFY_EMAIL}},EmailAuthProvider:jt,FacebookAuthProvider:k,GithubAuthProvider:R,GoogleAuthProvider:S,OAuthProvider:Wt,SAMLAuthProvider:Bt,PhoneAuthProvider:xn,PhoneMultiFactorGenerator:Zi,RecaptchaVerifier:Hn,TwitterAuthProvider:A,Auth:Fn,AuthCredential:At,Error:c}).setInstantiationMode("LAZY").setMultipleInstances(!1)),_n.registerVersion("@firebase/auth-compat","0.5.20")}.apply(this,arguments)}catch(e){throw console.error(e),new Error("Cannot instantiate firebase-auth.js - be sure to load firebase-app.js first.")}});//# sourceMappingURL=firebase-auth.js.map