
      var $parcel$global = globalThis;
    
function $parcel$export(e, n, v, s) {
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
var parcelRequire = $parcel$global["parcelRequire42d2"];
var parcelRegister = parcelRequire.register;
parcelRegister("4DjsS", function(module, exports) {

$parcel$export(module.exports, "FirebaseError", () => $35f9e736408d85d1$export$dd24e9cd51226c56);
$parcel$export(module.exports, "_DEFAULT_ENTRY_NAME", () => $35f9e736408d85d1$export$9f30fa0c10967f7f);
$parcel$export(module.exports, "_apps", () => $35f9e736408d85d1$export$b4e3c36c855b14b5);
$parcel$export(module.exports, "_components", () => $35f9e736408d85d1$export$9566bce3835c0f28);
$parcel$export(module.exports, "_addComponent", () => $35f9e736408d85d1$export$fa5244b94c62d36a);
$parcel$export(module.exports, "_addOrOverwriteComponent", () => $35f9e736408d85d1$export$4393112b42e2b41d);
$parcel$export(module.exports, "_registerComponent", () => $35f9e736408d85d1$export$c930050e7bb63965);
$parcel$export(module.exports, "_getProvider", () => $35f9e736408d85d1$export$fa0d6da0f5838f50);
$parcel$export(module.exports, "_removeServiceInstance", () => $35f9e736408d85d1$export$48d18de2ff1c45a5);
$parcel$export(module.exports, "_clearComponents", () => $35f9e736408d85d1$export$3685d89b9c3cdfaf);
$parcel$export(module.exports, "SDK_VERSION", () => $35f9e736408d85d1$export$31499a9cd224b78c);
$parcel$export(module.exports, "initializeApp", () => $35f9e736408d85d1$export$c55cfd413944906d);
$parcel$export(module.exports, "getApp", () => $35f9e736408d85d1$export$f9962582c9e66d99);
$parcel$export(module.exports, "getApps", () => $35f9e736408d85d1$export$68ddedf7d44b3bdf);
$parcel$export(module.exports, "deleteApp", () => $35f9e736408d85d1$export$6eec44aa53d5ea34);
$parcel$export(module.exports, "registerVersion", () => $35f9e736408d85d1$export$d29d5299a7137abc);
$parcel$export(module.exports, "onLog", () => $35f9e736408d85d1$export$a82ad227dc8163dc);
$parcel$export(module.exports, "setLogLevel", () => $35f9e736408d85d1$export$c622e99c0ce7b1c9);
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ /**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ 
var $6B0v2 = parcelRequire("6B0v2");
const $35f9e736408d85d1$var$stringToByteArray$1 = function(str) {
    // TODO(user): Use native implementations if/when available
    const out = [];
    let p = 0;
    for(let i = 0; i < str.length; i++){
        let c = str.charCodeAt(i);
        if (c < 128) out[p++] = c;
        else if (c < 2048) {
            out[p++] = c >> 6 | 192;
            out[p++] = c & 63 | 128;
        } else if ((c & 0xfc00) === 0xd800 && i + 1 < str.length && (str.charCodeAt(i + 1) & 0xfc00) === 0xdc00) {
            // Surrogate Pair
            c = 0x10000 + ((c & 0x03ff) << 10) + (str.charCodeAt(++i) & 0x03ff);
            out[p++] = c >> 18 | 240;
            out[p++] = c >> 12 & 63 | 128;
            out[p++] = c >> 6 & 63 | 128;
            out[p++] = c & 63 | 128;
        } else {
            out[p++] = c >> 12 | 224;
            out[p++] = c >> 6 & 63 | 128;
            out[p++] = c & 63 | 128;
        }
    }
    return out;
};
/**
 * Turns an array of numbers into the string given by the concatenation of the
 * characters to which the numbers correspond.
 * @param bytes Array of numbers representing characters.
 * @return Stringification of the array.
 */ const $35f9e736408d85d1$var$byteArrayToString = function(bytes) {
    // TODO(user): Use native implementations if/when available
    const out = [];
    let pos = 0, c = 0;
    while(pos < bytes.length){
        const c1 = bytes[pos++];
        if (c1 < 128) out[c++] = String.fromCharCode(c1);
        else if (c1 > 191 && c1 < 224) {
            const c2 = bytes[pos++];
            out[c++] = String.fromCharCode((c1 & 31) << 6 | c2 & 63);
        } else if (c1 > 239 && c1 < 365) {
            // Surrogate Pair
            const c2 = bytes[pos++];
            const c3 = bytes[pos++];
            const c4 = bytes[pos++];
            const u = ((c1 & 7) << 18 | (c2 & 63) << 12 | (c3 & 63) << 6 | c4 & 63) - 0x10000;
            out[c++] = String.fromCharCode(0xd800 + (u >> 10));
            out[c++] = String.fromCharCode(0xdc00 + (u & 1023));
        } else {
            const c2 = bytes[pos++];
            const c3 = bytes[pos++];
            out[c++] = String.fromCharCode((c1 & 15) << 12 | (c2 & 63) << 6 | c3 & 63);
        }
    }
    return out.join("");
};
// We define it as an object literal instead of a class because a class compiled down to es5 can't
// be treeshaked. https://github.com/rollup/rollup/issues/1691
// Static lookup maps, lazily populated by init_()
const $35f9e736408d85d1$var$base64 = {
    /**
     * Maps bytes to characters.
     */ byteToCharMap_: null,
    /**
     * Maps characters to bytes.
     */ charToByteMap_: null,
    /**
     * Maps bytes to websafe characters.
     * @private
     */ byteToCharMapWebSafe_: null,
    /**
     * Maps websafe characters to bytes.
     * @private
     */ charToByteMapWebSafe_: null,
    /**
     * Our default alphabet, shared between
     * ENCODED_VALS and ENCODED_VALS_WEBSAFE
     */ ENCODED_VALS_BASE: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
    /**
     * Our default alphabet. Value 64 (=) is special; it means "nothing."
     */ get ENCODED_VALS () {
        return this.ENCODED_VALS_BASE + "+/=";
    },
    /**
     * Our websafe alphabet.
     */ get ENCODED_VALS_WEBSAFE () {
        return this.ENCODED_VALS_BASE + "-_.";
    },
    /**
     * Whether this browser supports the atob and btoa functions. This extension
     * started at Mozilla but is now implemented by many browsers. We use the
     * ASSUME_* variables to avoid pulling in the full useragent detection library
     * but still allowing the standard per-browser compilations.
     *
     */ HAS_NATIVE_SUPPORT: typeof atob === "function",
    /**
     * Base64-encode an array of bytes.
     *
     * @param input An array of bytes (numbers with
     *     value in [0, 255]) to encode.
     * @param webSafe Boolean indicating we should use the
     *     alternative alphabet.
     * @return The base64 encoded string.
     */ encodeByteArray (input, webSafe) {
        if (!Array.isArray(input)) throw Error("encodeByteArray takes an array as a parameter");
        this.init_();
        const byteToCharMap = webSafe ? this.byteToCharMapWebSafe_ : this.byteToCharMap_;
        const output = [];
        for(let i = 0; i < input.length; i += 3){
            const byte1 = input[i];
            const haveByte2 = i + 1 < input.length;
            const byte2 = haveByte2 ? input[i + 1] : 0;
            const haveByte3 = i + 2 < input.length;
            const byte3 = haveByte3 ? input[i + 2] : 0;
            const outByte1 = byte1 >> 2;
            const outByte2 = (byte1 & 0x03) << 4 | byte2 >> 4;
            let outByte3 = (byte2 & 0x0f) << 2 | byte3 >> 6;
            let outByte4 = byte3 & 0x3f;
            if (!haveByte3) {
                outByte4 = 64;
                if (!haveByte2) outByte3 = 64;
            }
            output.push(byteToCharMap[outByte1], byteToCharMap[outByte2], byteToCharMap[outByte3], byteToCharMap[outByte4]);
        }
        return output.join("");
    },
    /**
     * Base64-encode a string.
     *
     * @param input A string to encode.
     * @param webSafe If true, we should use the
     *     alternative alphabet.
     * @return The base64 encoded string.
     */ encodeString (input, webSafe) {
        // Shortcut for Mozilla browsers that implement
        // a native base64 encoder in the form of "btoa/atob"
        if (this.HAS_NATIVE_SUPPORT && !webSafe) return btoa(input);
        return this.encodeByteArray($35f9e736408d85d1$var$stringToByteArray$1(input), webSafe);
    },
    /**
     * Base64-decode a string.
     *
     * @param input to decode.
     * @param webSafe True if we should use the
     *     alternative alphabet.
     * @return string representing the decoded value.
     */ decodeString (input, webSafe) {
        // Shortcut for Mozilla browsers that implement
        // a native base64 encoder in the form of "btoa/atob"
        if (this.HAS_NATIVE_SUPPORT && !webSafe) return atob(input);
        return $35f9e736408d85d1$var$byteArrayToString(this.decodeStringToByteArray(input, webSafe));
    },
    /**
     * Base64-decode a string.
     *
     * In base-64 decoding, groups of four characters are converted into three
     * bytes.  If the encoder did not apply padding, the input length may not
     * be a multiple of 4.
     *
     * In this case, the last group will have fewer than 4 characters, and
     * padding will be inferred.  If the group has one or two characters, it decodes
     * to one byte.  If the group has three characters, it decodes to two bytes.
     *
     * @param input Input to decode.
     * @param webSafe True if we should use the web-safe alphabet.
     * @return bytes representing the decoded value.
     */ decodeStringToByteArray (input, webSafe) {
        this.init_();
        const charToByteMap = webSafe ? this.charToByteMapWebSafe_ : this.charToByteMap_;
        const output = [];
        for(let i = 0; i < input.length;){
            const byte1 = charToByteMap[input.charAt(i++)];
            const haveByte2 = i < input.length;
            const byte2 = haveByte2 ? charToByteMap[input.charAt(i)] : 0;
            ++i;
            const haveByte3 = i < input.length;
            const byte3 = haveByte3 ? charToByteMap[input.charAt(i)] : 64;
            ++i;
            const haveByte4 = i < input.length;
            const byte4 = haveByte4 ? charToByteMap[input.charAt(i)] : 64;
            ++i;
            if (byte1 == null || byte2 == null || byte3 == null || byte4 == null) throw new $35f9e736408d85d1$var$DecodeBase64StringError();
            const outByte1 = byte1 << 2 | byte2 >> 4;
            output.push(outByte1);
            if (byte3 !== 64) {
                const outByte2 = byte2 << 4 & 0xf0 | byte3 >> 2;
                output.push(outByte2);
                if (byte4 !== 64) {
                    const outByte3 = byte3 << 6 & 0xc0 | byte4;
                    output.push(outByte3);
                }
            }
        }
        return output;
    },
    /**
     * Lazy static initialization function. Called before
     * accessing any of the static map variables.
     * @private
     */ init_ () {
        if (!this.byteToCharMap_) {
            this.byteToCharMap_ = {};
            this.charToByteMap_ = {};
            this.byteToCharMapWebSafe_ = {};
            this.charToByteMapWebSafe_ = {};
            // We want quick mappings back and forth, so we precompute two maps.
            for(let i = 0; i < this.ENCODED_VALS.length; i++){
                this.byteToCharMap_[i] = this.ENCODED_VALS.charAt(i);
                this.charToByteMap_[this.byteToCharMap_[i]] = i;
                this.byteToCharMapWebSafe_[i] = this.ENCODED_VALS_WEBSAFE.charAt(i);
                this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[i]] = i;
                // Be forgiving when decoding and correctly decode both encodings.
                if (i >= this.ENCODED_VALS_BASE.length) {
                    this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(i)] = i;
                    this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(i)] = i;
                }
            }
        }
    }
};
/**
 * An error encountered while decoding base64 string.
 */ class $35f9e736408d85d1$var$DecodeBase64StringError extends Error {
    constructor(){
        super(...arguments);
        this.name = "DecodeBase64StringError";
    }
}
/**
 * URL-safe base64 encoding
 */ const $35f9e736408d85d1$var$base64Encode = function(str) {
    const utf8Bytes = $35f9e736408d85d1$var$stringToByteArray$1(str);
    return $35f9e736408d85d1$var$base64.encodeByteArray(utf8Bytes, true);
};
/**
 * URL-safe base64 encoding (without "." padding in the end).
 * e.g. Used in JSON Web Token (JWT) parts.
 */ const $35f9e736408d85d1$var$base64urlEncodeWithoutPadding = function(str) {
    // Use base64url encoding and remove padding in the end (dot characters).
    return $35f9e736408d85d1$var$base64Encode(str).replace(/\./g, "");
};
/**
 * URL-safe base64 decoding
 *
 * NOTE: DO NOT use the global atob() function - it does NOT support the
 * base64Url variant encoding.
 *
 * @param str To be decoded
 * @return Decoded result, if possible
 */ const $35f9e736408d85d1$var$base64Decode = function(str) {
    try {
        return $35f9e736408d85d1$var$base64.decodeString(str, true);
    } catch (e) {
        console.error("base64Decode failed: ", e);
    }
    return null;
};
/**
 * @license
 * Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ /**
 * Polyfill for `globalThis` object.
 * @returns the `globalThis` object for the given environment.
 * @public
 */ function $35f9e736408d85d1$var$getGlobal() {
    if (typeof self !== "undefined") return self;
    if (typeof window !== "undefined") return window;
    if (typeof $parcel$global !== "undefined") return $parcel$global;
    throw new Error("Unable to locate global object.");
}
/**
 * @license
 * Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ const $35f9e736408d85d1$var$getDefaultsFromGlobal = ()=>$35f9e736408d85d1$var$getGlobal().__FIREBASE_DEFAULTS__;
/**
 * Attempt to read defaults from a JSON string provided to
 * process(.)env(.)__FIREBASE_DEFAULTS__ or a JSON file whose path is in
 * process(.)env(.)__FIREBASE_DEFAULTS_PATH__
 * The dots are in parens because certain compilers (Vite?) cannot
 * handle seeing that variable in comments.
 * See https://github.com/firebase/firebase-js-sdk/issues/6838
 */ const $35f9e736408d85d1$var$getDefaultsFromEnvVariable = ()=>{
    if (typeof $6B0v2 === "undefined" || typeof $6B0v2.env === "undefined") return;
    const defaultsJsonString = undefined;
    if (defaultsJsonString) return JSON.parse(defaultsJsonString);
};
const $35f9e736408d85d1$var$getDefaultsFromCookie = ()=>{
    if (typeof document === "undefined") return;
    let match;
    try {
        match = document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/);
    } catch (e) {
        // Some environments such as Angular Universal SSR have a
        // `document` object but error on accessing `document.cookie`.
        return;
    }
    const decoded = match && $35f9e736408d85d1$var$base64Decode(match[1]);
    return decoded && JSON.parse(decoded);
};
/**
 * Get the __FIREBASE_DEFAULTS__ object. It checks in order:
 * (1) if such an object exists as a property of `globalThis`
 * (2) if such an object was provided on a shell environment variable
 * (3) if such an object exists in a cookie
 * @public
 */ const $35f9e736408d85d1$var$getDefaults = ()=>{
    try {
        return $35f9e736408d85d1$var$getDefaultsFromGlobal() || $35f9e736408d85d1$var$getDefaultsFromEnvVariable() || $35f9e736408d85d1$var$getDefaultsFromCookie();
    } catch (e) {
        /**
         * Catch-all for being unable to get __FIREBASE_DEFAULTS__ due
         * to any environment case we have not accounted for. Log to
         * info instead of swallowing so we can find these unknown cases
         * and add paths for them if needed.
         */ console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`);
        return;
    }
};
/**
 * Returns Firebase app config stored in the __FIREBASE_DEFAULTS__ object.
 * @public
 */ const $35f9e736408d85d1$var$getDefaultAppConfig = ()=>{
    var _a;
    return (_a = $35f9e736408d85d1$var$getDefaults()) === null || _a === void 0 ? void 0 : _a.config;
};
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ class $35f9e736408d85d1$var$Deferred {
    constructor(){
        this.reject = ()=>{};
        this.resolve = ()=>{};
        this.promise = new Promise((resolve, reject)=>{
            this.resolve = resolve;
            this.reject = reject;
        });
    }
    /**
     * Our API internals are not promiseified and cannot because our callback APIs have subtle expectations around
     * invoking promises inline, which Promises are forbidden to do. This method accepts an optional node-style callback
     * and returns a node-style callback which will resolve or reject the Deferred's promise.
     */ wrapCallback(callback) {
        return (error, value)=>{
            if (error) this.reject(error);
            else this.resolve(value);
            if (typeof callback === "function") {
                // Attaching noop handler just in case developer wasn't expecting
                // promises
                this.promise.catch(()=>{});
                // Some of our callbacks don't expect a value and our own tests
                // assert that the parameter length is 1
                if (callback.length === 1) callback(error);
                else callback(error, value);
            }
        };
    }
}
/**
 * This method checks if indexedDB is supported by current browser/service worker context
 * @return true if indexedDB is supported by current browser/service worker context
 */ function $35f9e736408d85d1$var$isIndexedDBAvailable() {
    try {
        return typeof indexedDB === "object";
    } catch (e) {
        return false;
    }
}
/**
 * This method validates browser/sw context for indexedDB by opening a dummy indexedDB database and reject
 * if errors occur during the database open operation.
 *
 * @throws exception if current browser/sw context can't run idb.open (ex: Safari iframe, Firefox
 * private browsing)
 */ function $35f9e736408d85d1$var$validateIndexedDBOpenable() {
    return new Promise((resolve, reject)=>{
        try {
            let preExist = true;
            const DB_CHECK_NAME = "validate-browser-context-for-indexeddb-analytics-module";
            const request = self.indexedDB.open(DB_CHECK_NAME);
            request.onsuccess = ()=>{
                request.result.close();
                // delete database only when it doesn't pre-exist
                if (!preExist) self.indexedDB.deleteDatabase(DB_CHECK_NAME);
                resolve(true);
            };
            request.onupgradeneeded = ()=>{
                preExist = false;
            };
            request.onerror = ()=>{
                var _a;
                reject(((_a = request.error) === null || _a === void 0 ? void 0 : _a.message) || "");
            };
        } catch (error) {
            reject(error);
        }
    });
}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ /**
 * @fileoverview Standardized Firebase Error.
 *
 * Usage:
 *
 *   // Typescript string literals for type-safe codes
 *   type Err =
 *     'unknown' |
 *     'object-not-found'
 *     ;
 *
 *   // Closure enum for type-safe error codes
 *   // at-enum {string}
 *   var Err = {
 *     UNKNOWN: 'unknown',
 *     OBJECT_NOT_FOUND: 'object-not-found',
 *   }
 *
 *   let errors: Map<Err, string> = {
 *     'generic-error': "Unknown error",
 *     'file-not-found': "Could not find file: {$file}",
 *   };
 *
 *   // Type-safe function - must pass a valid error code as param.
 *   let error = new ErrorFactory<Err>('service', 'Service', errors);
 *
 *   ...
 *   throw error.create(Err.GENERIC);
 *   ...
 *   throw error.create(Err.FILE_NOT_FOUND, {'file': fileName});
 *   ...
 *   // Service: Could not file file: foo.txt (service/file-not-found).
 *
 *   catch (e) {
 *     assert(e.message === "Could not find file: foo.txt.");
 *     if ((e as FirebaseError)?.code === 'service/file-not-found') {
 *       console.log("Could not read file: " + e['file']);
 *     }
 *   }
 */ const $35f9e736408d85d1$var$ERROR_NAME = "FirebaseError";
// Based on code from:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Custom_Error_Types
class $35f9e736408d85d1$export$dd24e9cd51226c56 extends Error {
    constructor(/** The error code for this error. */ code, message, /** Custom data for this error. */ customData){
        super(message);
        this.code = code;
        this.customData = customData;
        /** The custom name for all FirebaseErrors. */ this.name = $35f9e736408d85d1$var$ERROR_NAME;
        // Fix For ES5
        // https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
        Object.setPrototypeOf(this, $35f9e736408d85d1$export$dd24e9cd51226c56.prototype);
        // Maintains proper stack trace for where our error was thrown.
        // Only available on V8.
        if (Error.captureStackTrace) Error.captureStackTrace(this, $35f9e736408d85d1$var$ErrorFactory.prototype.create);
    }
}
class $35f9e736408d85d1$var$ErrorFactory {
    constructor(service, serviceName, errors){
        this.service = service;
        this.serviceName = serviceName;
        this.errors = errors;
    }
    create(code, ...data) {
        const customData = data[0] || {};
        const fullCode = `${this.service}/${code}`;
        const template = this.errors[code];
        const message = template ? $35f9e736408d85d1$var$replaceTemplate(template, customData) : "Error";
        // Service Name: Error message (service/code).
        const fullMessage = `${this.serviceName}: ${message} (${fullCode}).`;
        const error = new $35f9e736408d85d1$export$dd24e9cd51226c56(fullCode, fullMessage, customData);
        return error;
    }
}
function $35f9e736408d85d1$var$replaceTemplate(template, data) {
    return template.replace($35f9e736408d85d1$var$PATTERN, (_, key)=>{
        const value = data[key];
        return value != null ? String(value) : `<${key}?>`;
    });
}
const $35f9e736408d85d1$var$PATTERN = /\{\$([^}]+)}/g;
/**
 * Deep equal two objects. Support Arrays and Objects.
 */ function $35f9e736408d85d1$var$deepEqual(a, b) {
    if (a === b) return true;
    const aKeys = Object.keys(a);
    const bKeys = Object.keys(b);
    for (const k of aKeys){
        if (!bKeys.includes(k)) return false;
        const aProp = a[k];
        const bProp = b[k];
        if ($35f9e736408d85d1$var$isObject(aProp) && $35f9e736408d85d1$var$isObject(bProp)) {
            if (!$35f9e736408d85d1$var$deepEqual(aProp, bProp)) return false;
        } else if (aProp !== bProp) return false;
    }
    for (const k of bKeys){
        if (!aKeys.includes(k)) return false;
    }
    return true;
}
function $35f9e736408d85d1$var$isObject(thing) {
    return thing !== null && typeof thing === "object";
}
/**
 * Component for service name T, e.g. `auth`, `auth-internal`
 */ class $35f9e736408d85d1$var$Component {
    /**
     *
     * @param name The public service name, e.g. app, auth, firestore, database
     * @param instanceFactory Service factory responsible for creating the public interface
     * @param type whether the service provided by the component is public or private
     */ constructor(name, instanceFactory, type){
        this.name = name;
        this.instanceFactory = instanceFactory;
        this.type = type;
        this.multipleInstances = false;
        /**
         * Properties to be added to the service namespace
         */ this.serviceProps = {};
        this.instantiationMode = "LAZY" /* InstantiationMode.LAZY */ ;
        this.onInstanceCreated = null;
    }
    setInstantiationMode(mode) {
        this.instantiationMode = mode;
        return this;
    }
    setMultipleInstances(multipleInstances) {
        this.multipleInstances = multipleInstances;
        return this;
    }
    setServiceProps(props) {
        this.serviceProps = props;
        return this;
    }
    setInstanceCreatedCallback(callback) {
        this.onInstanceCreated = callback;
        return this;
    }
}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ const $35f9e736408d85d1$var$DEFAULT_ENTRY_NAME$1 = "[DEFAULT]";
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ /**
 * Provider for instance for service name T, e.g. 'auth', 'auth-internal'
 * NameServiceMapping[T] is an alias for the type of the instance
 */ class $35f9e736408d85d1$var$Provider {
    constructor(name, container){
        this.name = name;
        this.container = container;
        this.component = null;
        this.instances = new Map();
        this.instancesDeferred = new Map();
        this.instancesOptions = new Map();
        this.onInitCallbacks = new Map();
    }
    /**
     * @param identifier A provider can provide mulitple instances of a service
     * if this.component.multipleInstances is true.
     */ get(identifier) {
        // if multipleInstances is not supported, use the default name
        const normalizedIdentifier = this.normalizeInstanceIdentifier(identifier);
        if (!this.instancesDeferred.has(normalizedIdentifier)) {
            const deferred = new $35f9e736408d85d1$var$Deferred();
            this.instancesDeferred.set(normalizedIdentifier, deferred);
            if (this.isInitialized(normalizedIdentifier) || this.shouldAutoInitialize()) // initialize the service if it can be auto-initialized
            try {
                const instance = this.getOrInitializeService({
                    instanceIdentifier: normalizedIdentifier
                });
                if (instance) deferred.resolve(instance);
            } catch (e) {
            // when the instance factory throws an exception during get(), it should not cause
            // a fatal error. We just return the unresolved promise in this case.
            }
        }
        return this.instancesDeferred.get(normalizedIdentifier).promise;
    }
    getImmediate(options) {
        var _a;
        // if multipleInstances is not supported, use the default name
        const normalizedIdentifier = this.normalizeInstanceIdentifier(options === null || options === void 0 ? void 0 : options.identifier);
        const optional = (_a = options === null || options === void 0 ? void 0 : options.optional) !== null && _a !== void 0 ? _a : false;
        if (this.isInitialized(normalizedIdentifier) || this.shouldAutoInitialize()) try {
            return this.getOrInitializeService({
                instanceIdentifier: normalizedIdentifier
            });
        } catch (e) {
            if (optional) return null;
            else throw e;
        }
        else {
            // In case a component is not initialized and should/can not be auto-initialized at the moment, return null if the optional flag is set, or throw
            if (optional) return null;
            else throw Error(`Service ${this.name} is not available`);
        }
    }
    getComponent() {
        return this.component;
    }
    setComponent(component) {
        if (component.name !== this.name) throw Error(`Mismatching Component ${component.name} for Provider ${this.name}.`);
        if (this.component) throw Error(`Component for ${this.name} has already been provided`);
        this.component = component;
        // return early without attempting to initialize the component if the component requires explicit initialization (calling `Provider.initialize()`)
        if (!this.shouldAutoInitialize()) return;
        // if the service is eager, initialize the default instance
        if ($35f9e736408d85d1$var$isComponentEager(component)) try {
            this.getOrInitializeService({
                instanceIdentifier: $35f9e736408d85d1$var$DEFAULT_ENTRY_NAME$1
            });
        } catch (e) {
        // when the instance factory for an eager Component throws an exception during the eager
        // initialization, it should not cause a fatal error.
        // TODO: Investigate if we need to make it configurable, because some component may want to cause
        // a fatal error in this case?
        }
        // Create service instances for the pending promises and resolve them
        // NOTE: if this.multipleInstances is false, only the default instance will be created
        // and all promises with resolve with it regardless of the identifier.
        for (const [instanceIdentifier, instanceDeferred] of this.instancesDeferred.entries()){
            const normalizedIdentifier = this.normalizeInstanceIdentifier(instanceIdentifier);
            try {
                // `getOrInitializeService()` should always return a valid instance since a component is guaranteed. use ! to make typescript happy.
                const instance = this.getOrInitializeService({
                    instanceIdentifier: normalizedIdentifier
                });
                instanceDeferred.resolve(instance);
            } catch (e) {
            // when the instance factory throws an exception, it should not cause
            // a fatal error. We just leave the promise unresolved.
            }
        }
    }
    clearInstance(identifier = $35f9e736408d85d1$var$DEFAULT_ENTRY_NAME$1) {
        this.instancesDeferred.delete(identifier);
        this.instancesOptions.delete(identifier);
        this.instances.delete(identifier);
    }
    // app.delete() will call this method on every provider to delete the services
    // TODO: should we mark the provider as deleted?
    async delete() {
        const services = Array.from(this.instances.values());
        await Promise.all([
            ...services.filter((service)=>"INTERNAL" in service) // legacy services
            // eslint-disable-next-line @typescript-eslint/no-explicit-any
            .map((service)=>service.INTERNAL.delete()),
            ...services.filter((service)=>"_delete" in service) // modularized services
            // eslint-disable-next-line @typescript-eslint/no-explicit-any
            .map((service)=>service._delete())
        ]);
    }
    isComponentSet() {
        return this.component != null;
    }
    isInitialized(identifier = $35f9e736408d85d1$var$DEFAULT_ENTRY_NAME$1) {
        return this.instances.has(identifier);
    }
    getOptions(identifier = $35f9e736408d85d1$var$DEFAULT_ENTRY_NAME$1) {
        return this.instancesOptions.get(identifier) || {};
    }
    initialize(opts = {}) {
        const { options: options = {} } = opts;
        const normalizedIdentifier = this.normalizeInstanceIdentifier(opts.instanceIdentifier);
        if (this.isInitialized(normalizedIdentifier)) throw Error(`${this.name}(${normalizedIdentifier}) has already been initialized`);
        if (!this.isComponentSet()) throw Error(`Component ${this.name} has not been registered yet`);
        const instance = this.getOrInitializeService({
            instanceIdentifier: normalizedIdentifier,
            options: options
        });
        // resolve any pending promise waiting for the service instance
        for (const [instanceIdentifier, instanceDeferred] of this.instancesDeferred.entries()){
            const normalizedDeferredIdentifier = this.normalizeInstanceIdentifier(instanceIdentifier);
            if (normalizedIdentifier === normalizedDeferredIdentifier) instanceDeferred.resolve(instance);
        }
        return instance;
    }
    /**
     *
     * @param callback - a function that will be invoked  after the provider has been initialized by calling provider.initialize().
     * The function is invoked SYNCHRONOUSLY, so it should not execute any longrunning tasks in order to not block the program.
     *
     * @param identifier An optional instance identifier
     * @returns a function to unregister the callback
     */ onInit(callback, identifier) {
        var _a;
        const normalizedIdentifier = this.normalizeInstanceIdentifier(identifier);
        const existingCallbacks = (_a = this.onInitCallbacks.get(normalizedIdentifier)) !== null && _a !== void 0 ? _a : new Set();
        existingCallbacks.add(callback);
        this.onInitCallbacks.set(normalizedIdentifier, existingCallbacks);
        const existingInstance = this.instances.get(normalizedIdentifier);
        if (existingInstance) callback(existingInstance, normalizedIdentifier);
        return ()=>{
            existingCallbacks.delete(callback);
        };
    }
    /**
     * Invoke onInit callbacks synchronously
     * @param instance the service instance`
     */ invokeOnInitCallbacks(instance, identifier) {
        const callbacks = this.onInitCallbacks.get(identifier);
        if (!callbacks) return;
        for (const callback of callbacks)try {
            callback(instance, identifier);
        } catch (_a) {
        // ignore errors in the onInit callback
        }
    }
    getOrInitializeService({ instanceIdentifier: instanceIdentifier, options: options = {} }) {
        let instance = this.instances.get(instanceIdentifier);
        if (!instance && this.component) {
            instance = this.component.instanceFactory(this.container, {
                instanceIdentifier: $35f9e736408d85d1$var$normalizeIdentifierForFactory(instanceIdentifier),
                options: options
            });
            this.instances.set(instanceIdentifier, instance);
            this.instancesOptions.set(instanceIdentifier, options);
            /**
             * Invoke onInit listeners.
             * Note this.component.onInstanceCreated is different, which is used by the component creator,
             * while onInit listeners are registered by consumers of the provider.
             */ this.invokeOnInitCallbacks(instance, instanceIdentifier);
            /**
             * Order is important
             * onInstanceCreated() should be called after this.instances.set(instanceIdentifier, instance); which
             * makes `isInitialized()` return true.
             */ if (this.component.onInstanceCreated) try {
                this.component.onInstanceCreated(this.container, instanceIdentifier, instance);
            } catch (_a) {
            // ignore errors in the onInstanceCreatedCallback
            }
        }
        return instance || null;
    }
    normalizeInstanceIdentifier(identifier = $35f9e736408d85d1$var$DEFAULT_ENTRY_NAME$1) {
        if (this.component) return this.component.multipleInstances ? identifier : $35f9e736408d85d1$var$DEFAULT_ENTRY_NAME$1;
        else return identifier; // assume multiple instances are supported before the component is provided.
    }
    shouldAutoInitialize() {
        return !!this.component && this.component.instantiationMode !== "EXPLICIT" /* InstantiationMode.EXPLICIT */ ;
    }
}
// undefined should be passed to the service factory for the default instance
function $35f9e736408d85d1$var$normalizeIdentifierForFactory(identifier) {
    return identifier === $35f9e736408d85d1$var$DEFAULT_ENTRY_NAME$1 ? undefined : identifier;
}
function $35f9e736408d85d1$var$isComponentEager(component) {
    return component.instantiationMode === "EAGER" /* InstantiationMode.EAGER */ ;
}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ /**
 * ComponentContainer that provides Providers for service name T, e.g. `auth`, `auth-internal`
 */ class $35f9e736408d85d1$var$ComponentContainer {
    constructor(name){
        this.name = name;
        this.providers = new Map();
    }
    /**
     *
     * @param component Component being added
     * @param overwrite When a component with the same name has already been registered,
     * if overwrite is true: overwrite the existing component with the new component and create a new
     * provider with the new component. It can be useful in tests where you want to use different mocks
     * for different tests.
     * if overwrite is false: throw an exception
     */ addComponent(component) {
        const provider = this.getProvider(component.name);
        if (provider.isComponentSet()) throw new Error(`Component ${component.name} has already been registered with ${this.name}`);
        provider.setComponent(component);
    }
    addOrOverwriteComponent(component) {
        const provider = this.getProvider(component.name);
        if (provider.isComponentSet()) // delete the existing provider from the container, so we can register the new component
        this.providers.delete(component.name);
        this.addComponent(component);
    }
    /**
     * getProvider provides a type safe interface where it can only be called with a field name
     * present in NameServiceMapping interface.
     *
     * Firebase SDKs providing services should extend NameServiceMapping interface to register
     * themselves.
     */ getProvider(name) {
        if (this.providers.has(name)) return this.providers.get(name);
        // create a Provider for a service that hasn't registered with Firebase
        const provider = new $35f9e736408d85d1$var$Provider(name, this);
        this.providers.set(name, provider);
        return provider;
    }
    getProviders() {
        return Array.from(this.providers.values());
    }
}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ /**
 * A container for all of the Logger instances
 */ const $35f9e736408d85d1$var$instances = [];
/**
 * The JS SDK supports 5 log levels and also allows a user the ability to
 * silence the logs altogether.
 *
 * The order is a follows:
 * DEBUG < VERBOSE < INFO < WARN < ERROR
 *
 * All of the log types above the current log level will be captured (i.e. if
 * you set the log level to `INFO`, errors will still be logged, but `DEBUG` and
 * `VERBOSE` logs will not)
 */ var $35f9e736408d85d1$var$LogLevel;
(function(LogLevel) {
    LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
    LogLevel[LogLevel["VERBOSE"] = 1] = "VERBOSE";
    LogLevel[LogLevel["INFO"] = 2] = "INFO";
    LogLevel[LogLevel["WARN"] = 3] = "WARN";
    LogLevel[LogLevel["ERROR"] = 4] = "ERROR";
    LogLevel[LogLevel["SILENT"] = 5] = "SILENT";
})($35f9e736408d85d1$var$LogLevel || ($35f9e736408d85d1$var$LogLevel = {}));
const $35f9e736408d85d1$var$levelStringToEnum = {
    "debug": $35f9e736408d85d1$var$LogLevel.DEBUG,
    "verbose": $35f9e736408d85d1$var$LogLevel.VERBOSE,
    "info": $35f9e736408d85d1$var$LogLevel.INFO,
    "warn": $35f9e736408d85d1$var$LogLevel.WARN,
    "error": $35f9e736408d85d1$var$LogLevel.ERROR,
    "silent": $35f9e736408d85d1$var$LogLevel.SILENT
};
/**
 * The default log level
 */ const $35f9e736408d85d1$var$defaultLogLevel = $35f9e736408d85d1$var$LogLevel.INFO;
/**
 * By default, `console.debug` is not displayed in the developer console (in
 * chrome). To avoid forcing users to have to opt-in to these logs twice
 * (i.e. once for firebase, and once in the console), we are sending `DEBUG`
 * logs to the `console.log` function.
 */ const $35f9e736408d85d1$var$ConsoleMethod = {
    [$35f9e736408d85d1$var$LogLevel.DEBUG]: "log",
    [$35f9e736408d85d1$var$LogLevel.VERBOSE]: "log",
    [$35f9e736408d85d1$var$LogLevel.INFO]: "info",
    [$35f9e736408d85d1$var$LogLevel.WARN]: "warn",
    [$35f9e736408d85d1$var$LogLevel.ERROR]: "error"
};
/**
 * The default log handler will forward DEBUG, VERBOSE, INFO, WARN, and ERROR
 * messages on to their corresponding console counterparts (if the log method
 * is supported by the current log level)
 */ const $35f9e736408d85d1$var$defaultLogHandler = (instance, logType, ...args)=>{
    if (logType < instance.logLevel) return;
    const now = new Date().toISOString();
    const method = $35f9e736408d85d1$var$ConsoleMethod[logType];
    if (method) console[method](`[${now}]  ${instance.name}:`, ...args);
    else throw new Error(`Attempted to log a message with an invalid logType (value: ${logType})`);
};
class $35f9e736408d85d1$var$Logger {
    /**
     * Gives you an instance of a Logger to capture messages according to
     * Firebase's logging scheme.
     *
     * @param name The name that the logs will be associated with
     */ constructor(name){
        this.name = name;
        /**
         * The log level of the given Logger instance.
         */ this._logLevel = $35f9e736408d85d1$var$defaultLogLevel;
        /**
         * The main (internal) log handler for the Logger instance.
         * Can be set to a new function in internal package code but not by user.
         */ this._logHandler = $35f9e736408d85d1$var$defaultLogHandler;
        /**
         * The optional, additional, user-defined log handler for the Logger instance.
         */ this._userLogHandler = null;
        /**
         * Capture the current instance for later use
         */ $35f9e736408d85d1$var$instances.push(this);
    }
    get logLevel() {
        return this._logLevel;
    }
    set logLevel(val) {
        if (!(val in $35f9e736408d85d1$var$LogLevel)) throw new TypeError(`Invalid value "${val}" assigned to \`logLevel\``);
        this._logLevel = val;
    }
    // Workaround for setter/getter having to be the same type.
    setLogLevel(val) {
        this._logLevel = typeof val === "string" ? $35f9e736408d85d1$var$levelStringToEnum[val] : val;
    }
    get logHandler() {
        return this._logHandler;
    }
    set logHandler(val) {
        if (typeof val !== "function") throw new TypeError("Value assigned to `logHandler` must be a function");
        this._logHandler = val;
    }
    get userLogHandler() {
        return this._userLogHandler;
    }
    set userLogHandler(val) {
        this._userLogHandler = val;
    }
    /**
     * The functions below are all based on the `console` interface
     */ debug(...args) {
        this._userLogHandler && this._userLogHandler(this, $35f9e736408d85d1$var$LogLevel.DEBUG, ...args);
        this._logHandler(this, $35f9e736408d85d1$var$LogLevel.DEBUG, ...args);
    }
    log(...args) {
        this._userLogHandler && this._userLogHandler(this, $35f9e736408d85d1$var$LogLevel.VERBOSE, ...args);
        this._logHandler(this, $35f9e736408d85d1$var$LogLevel.VERBOSE, ...args);
    }
    info(...args) {
        this._userLogHandler && this._userLogHandler(this, $35f9e736408d85d1$var$LogLevel.INFO, ...args);
        this._logHandler(this, $35f9e736408d85d1$var$LogLevel.INFO, ...args);
    }
    warn(...args) {
        this._userLogHandler && this._userLogHandler(this, $35f9e736408d85d1$var$LogLevel.WARN, ...args);
        this._logHandler(this, $35f9e736408d85d1$var$LogLevel.WARN, ...args);
    }
    error(...args) {
        this._userLogHandler && this._userLogHandler(this, $35f9e736408d85d1$var$LogLevel.ERROR, ...args);
        this._logHandler(this, $35f9e736408d85d1$var$LogLevel.ERROR, ...args);
    }
}
function $35f9e736408d85d1$var$setLogLevel$1(level) {
    $35f9e736408d85d1$var$instances.forEach((inst)=>{
        inst.setLogLevel(level);
    });
}
function $35f9e736408d85d1$var$setUserLogHandler(logCallback, options) {
    for (const instance of $35f9e736408d85d1$var$instances){
        let customLogLevel = null;
        if (options && options.level) customLogLevel = $35f9e736408d85d1$var$levelStringToEnum[options.level];
        if (logCallback === null) instance.userLogHandler = null;
        else instance.userLogHandler = (instance, level, ...args)=>{
            const message = args.map((arg)=>{
                if (arg == null) return null;
                else if (typeof arg === "string") return arg;
                else if (typeof arg === "number" || typeof arg === "boolean") return arg.toString();
                else if (arg instanceof Error) return arg.message;
                else try {
                    return JSON.stringify(arg);
                } catch (ignored) {
                    return null;
                }
            }).filter((arg)=>arg).join(" ");
            if (level >= (customLogLevel !== null && customLogLevel !== void 0 ? customLogLevel : instance.logLevel)) logCallback({
                level: $35f9e736408d85d1$var$LogLevel[level].toLowerCase(),
                message: message,
                args: args,
                type: instance.name
            });
        };
    }
}
const $35f9e736408d85d1$var$instanceOfAny = (object, constructors)=>constructors.some((c)=>object instanceof c);
let $35f9e736408d85d1$var$idbProxyableTypes;
let $35f9e736408d85d1$var$cursorAdvanceMethods;
// This is a function to prevent it throwing up in node environments.
function $35f9e736408d85d1$var$getIdbProxyableTypes() {
    return $35f9e736408d85d1$var$idbProxyableTypes || ($35f9e736408d85d1$var$idbProxyableTypes = [
        IDBDatabase,
        IDBObjectStore,
        IDBIndex,
        IDBCursor,
        IDBTransaction
    ]);
}
// This is a function to prevent it throwing up in node environments.
function $35f9e736408d85d1$var$getCursorAdvanceMethods() {
    return $35f9e736408d85d1$var$cursorAdvanceMethods || ($35f9e736408d85d1$var$cursorAdvanceMethods = [
        IDBCursor.prototype.advance,
        IDBCursor.prototype.continue,
        IDBCursor.prototype.continuePrimaryKey
    ]);
}
const $35f9e736408d85d1$var$cursorRequestMap = new WeakMap();
const $35f9e736408d85d1$var$transactionDoneMap = new WeakMap();
const $35f9e736408d85d1$var$transactionStoreNamesMap = new WeakMap();
const $35f9e736408d85d1$var$transformCache = new WeakMap();
const $35f9e736408d85d1$var$reverseTransformCache = new WeakMap();
function $35f9e736408d85d1$var$promisifyRequest(request) {
    const promise = new Promise((resolve, reject)=>{
        const unlisten = ()=>{
            request.removeEventListener("success", success);
            request.removeEventListener("error", error);
        };
        const success = ()=>{
            resolve($35f9e736408d85d1$var$wrap(request.result));
            unlisten();
        };
        const error = ()=>{
            reject(request.error);
            unlisten();
        };
        request.addEventListener("success", success);
        request.addEventListener("error", error);
    });
    promise.then((value)=>{
        // Since cursoring reuses the IDBRequest (*sigh*), we cache it for later retrieval
        // (see wrapFunction).
        if (value instanceof IDBCursor) $35f9e736408d85d1$var$cursorRequestMap.set(value, request);
    // Catching to avoid "Uncaught Promise exceptions"
    }).catch(()=>{});
    // This mapping exists in reverseTransformCache but doesn't doesn't exist in transformCache. This
    // is because we create many promises from a single IDBRequest.
    $35f9e736408d85d1$var$reverseTransformCache.set(promise, request);
    return promise;
}
function $35f9e736408d85d1$var$cacheDonePromiseForTransaction(tx) {
    // Early bail if we've already created a done promise for this transaction.
    if ($35f9e736408d85d1$var$transactionDoneMap.has(tx)) return;
    const done = new Promise((resolve, reject)=>{
        const unlisten = ()=>{
            tx.removeEventListener("complete", complete);
            tx.removeEventListener("error", error);
            tx.removeEventListener("abort", error);
        };
        const complete = ()=>{
            resolve();
            unlisten();
        };
        const error = ()=>{
            reject(tx.error || new DOMException("AbortError", "AbortError"));
            unlisten();
        };
        tx.addEventListener("complete", complete);
        tx.addEventListener("error", error);
        tx.addEventListener("abort", error);
    });
    // Cache it for later retrieval.
    $35f9e736408d85d1$var$transactionDoneMap.set(tx, done);
}
let $35f9e736408d85d1$var$idbProxyTraps = {
    get (target, prop, receiver) {
        if (target instanceof IDBTransaction) {
            // Special handling for transaction.done.
            if (prop === "done") return $35f9e736408d85d1$var$transactionDoneMap.get(target);
            // Polyfill for objectStoreNames because of Edge.
            if (prop === "objectStoreNames") return target.objectStoreNames || $35f9e736408d85d1$var$transactionStoreNamesMap.get(target);
            // Make tx.store return the only store in the transaction, or undefined if there are many.
            if (prop === "store") return receiver.objectStoreNames[1] ? undefined : receiver.objectStore(receiver.objectStoreNames[0]);
        }
        // Else transform whatever we get back.
        return $35f9e736408d85d1$var$wrap(target[prop]);
    },
    set (target, prop, value) {
        target[prop] = value;
        return true;
    },
    has (target, prop) {
        if (target instanceof IDBTransaction && (prop === "done" || prop === "store")) return true;
        return prop in target;
    }
};
function $35f9e736408d85d1$var$replaceTraps(callback) {
    $35f9e736408d85d1$var$idbProxyTraps = callback($35f9e736408d85d1$var$idbProxyTraps);
}
function $35f9e736408d85d1$var$wrapFunction(func) {
    // Due to expected object equality (which is enforced by the caching in `wrap`), we
    // only create one new func per func.
    // Edge doesn't support objectStoreNames (booo), so we polyfill it here.
    if (func === IDBDatabase.prototype.transaction && !("objectStoreNames" in IDBTransaction.prototype)) return function(storeNames, ...args) {
        const tx = func.call($35f9e736408d85d1$var$unwrap(this), storeNames, ...args);
        $35f9e736408d85d1$var$transactionStoreNamesMap.set(tx, storeNames.sort ? storeNames.sort() : [
            storeNames
        ]);
        return $35f9e736408d85d1$var$wrap(tx);
    };
    // Cursor methods are special, as the behaviour is a little more different to standard IDB. In
    // IDB, you advance the cursor and wait for a new 'success' on the IDBRequest that gave you the
    // cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense
    // with real promises, so each advance methods returns a new promise for the cursor object, or
    // undefined if the end of the cursor has been reached.
    if ($35f9e736408d85d1$var$getCursorAdvanceMethods().includes(func)) return function(...args) {
        // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
        // the original object.
        func.apply($35f9e736408d85d1$var$unwrap(this), args);
        return $35f9e736408d85d1$var$wrap($35f9e736408d85d1$var$cursorRequestMap.get(this));
    };
    return function(...args) {
        // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
        // the original object.
        return $35f9e736408d85d1$var$wrap(func.apply($35f9e736408d85d1$var$unwrap(this), args));
    };
}
function $35f9e736408d85d1$var$transformCachableValue(value) {
    if (typeof value === "function") return $35f9e736408d85d1$var$wrapFunction(value);
    // This doesn't return, it just creates a 'done' promise for the transaction,
    // which is later returned for transaction.done (see idbObjectHandler).
    if (value instanceof IDBTransaction) $35f9e736408d85d1$var$cacheDonePromiseForTransaction(value);
    if ($35f9e736408d85d1$var$instanceOfAny(value, $35f9e736408d85d1$var$getIdbProxyableTypes())) return new Proxy(value, $35f9e736408d85d1$var$idbProxyTraps);
    // Return the same value back if we're not going to transform it.
    return value;
}
function $35f9e736408d85d1$var$wrap(value) {
    // We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because
    // IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.
    if (value instanceof IDBRequest) return $35f9e736408d85d1$var$promisifyRequest(value);
    // If we've already transformed this value before, reuse the transformed value.
    // This is faster, but it also provides object equality.
    if ($35f9e736408d85d1$var$transformCache.has(value)) return $35f9e736408d85d1$var$transformCache.get(value);
    const newValue = $35f9e736408d85d1$var$transformCachableValue(value);
    // Not all types are transformed.
    // These may be primitive types, so they can't be WeakMap keys.
    if (newValue !== value) {
        $35f9e736408d85d1$var$transformCache.set(value, newValue);
        $35f9e736408d85d1$var$reverseTransformCache.set(newValue, value);
    }
    return newValue;
}
const $35f9e736408d85d1$var$unwrap = (value)=>$35f9e736408d85d1$var$reverseTransformCache.get(value);
/**
 * Open a database.
 *
 * @param name Name of the database.
 * @param version Schema version.
 * @param callbacks Additional callbacks.
 */ function $35f9e736408d85d1$var$openDB(name, version, { blocked: blocked, upgrade: upgrade, blocking: blocking, terminated: terminated } = {}) {
    const request = indexedDB.open(name, version);
    const openPromise = $35f9e736408d85d1$var$wrap(request);
    if (upgrade) request.addEventListener("upgradeneeded", (event)=>{
        upgrade($35f9e736408d85d1$var$wrap(request.result), event.oldVersion, event.newVersion, $35f9e736408d85d1$var$wrap(request.transaction), event);
    });
    if (blocked) request.addEventListener("blocked", (event)=>blocked(// Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
        event.oldVersion, event.newVersion, event));
    openPromise.then((db)=>{
        if (terminated) db.addEventListener("close", ()=>terminated());
        if (blocking) db.addEventListener("versionchange", (event)=>blocking(event.oldVersion, event.newVersion, event));
    }).catch(()=>{});
    return openPromise;
}
const $35f9e736408d85d1$var$readMethods = [
    "get",
    "getKey",
    "getAll",
    "getAllKeys",
    "count"
];
const $35f9e736408d85d1$var$writeMethods = [
    "put",
    "add",
    "delete",
    "clear"
];
const $35f9e736408d85d1$var$cachedMethods = new Map();
function $35f9e736408d85d1$var$getMethod(target, prop) {
    if (!(target instanceof IDBDatabase && !(prop in target) && typeof prop === "string")) return;
    if ($35f9e736408d85d1$var$cachedMethods.get(prop)) return $35f9e736408d85d1$var$cachedMethods.get(prop);
    const targetFuncName = prop.replace(/FromIndex$/, "");
    const useIndex = prop !== targetFuncName;
    const isWrite = $35f9e736408d85d1$var$writeMethods.includes(targetFuncName);
    if (// Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.
    !(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) || !(isWrite || $35f9e736408d85d1$var$readMethods.includes(targetFuncName))) return;
    const method = async function(storeName, ...args) {
        // isWrite ? 'readwrite' : undefined gzipps better, but fails in Edge :(
        const tx = this.transaction(storeName, isWrite ? "readwrite" : "readonly");
        let target = tx.store;
        if (useIndex) target = target.index(args.shift());
        // Must reject if op rejects.
        // If it's a write operation, must reject if tx.done rejects.
        // Must reject with op rejection first.
        // Must resolve with op value.
        // Must handle both promises (no unhandled rejections)
        return (await Promise.all([
            target[targetFuncName](...args),
            isWrite && tx.done
        ]))[0];
    };
    $35f9e736408d85d1$var$cachedMethods.set(prop, method);
    return method;
}
$35f9e736408d85d1$var$replaceTraps((oldTraps)=>({
        ...oldTraps,
        get: (target, prop, receiver)=>$35f9e736408d85d1$var$getMethod(target, prop) || oldTraps.get(target, prop, receiver),
        has: (target, prop)=>!!$35f9e736408d85d1$var$getMethod(target, prop) || oldTraps.has(target, prop)
    }));
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ class $35f9e736408d85d1$var$PlatformLoggerServiceImpl {
    constructor(container){
        this.container = container;
    }
    // In initial implementation, this will be called by installations on
    // auth token refresh, and installations will send this string.
    getPlatformInfoString() {
        const providers = this.container.getProviders();
        // Loop through providers and get library/version pairs from any that are
        // version components.
        return providers.map((provider)=>{
            if ($35f9e736408d85d1$var$isVersionServiceProvider(provider)) {
                const service = provider.getImmediate();
                return `${service.library}/${service.version}`;
            } else return null;
        }).filter((logString)=>logString).join(" ");
    }
}
/**
 *
 * @param provider check if this provider provides a VersionService
 *
 * NOTE: Using Provider<'app-version'> is a hack to indicate that the provider
 * provides VersionService. The provider is not necessarily a 'app-version'
 * provider.
 */ function $35f9e736408d85d1$var$isVersionServiceProvider(provider) {
    const component = provider.getComponent();
    return (component === null || component === void 0 ? void 0 : component.type) === "VERSION" /* ComponentType.VERSION */ ;
}
const $35f9e736408d85d1$var$name$o = "https://www.gstatic.com/firebasejs/10.8.0/firebase-app.js";
const $35f9e736408d85d1$var$version$1 = "0.9.27";
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ const $35f9e736408d85d1$var$logger = new $35f9e736408d85d1$var$Logger("https://www.gstatic.com/firebasejs/10.8.0/firebase-app.js");
const $35f9e736408d85d1$var$name$n = "@firebase/app-compat";
const $35f9e736408d85d1$var$name$m = "@firebase/analytics-compat";
const $35f9e736408d85d1$var$name$l = "@firebase/analytics";
const $35f9e736408d85d1$var$name$k = "@firebase/app-check-compat";
const $35f9e736408d85d1$var$name$j = "@firebase/app-check";
const $35f9e736408d85d1$var$name$i = "@firebase/auth";
const $35f9e736408d85d1$var$name$h = "@firebase/auth-compat";
const $35f9e736408d85d1$var$name$g = "@firebase/database";
const $35f9e736408d85d1$var$name$f = "@firebase/database-compat";
const $35f9e736408d85d1$var$name$e = "@firebase/functions";
const $35f9e736408d85d1$var$name$d = "@firebase/functions-compat";
const $35f9e736408d85d1$var$name$c = "@firebase/installations";
const $35f9e736408d85d1$var$name$b = "@firebase/installations-compat";
const $35f9e736408d85d1$var$name$a = "@firebase/messaging";
const $35f9e736408d85d1$var$name$9 = "@firebase/messaging-compat";
const $35f9e736408d85d1$var$name$8 = "@firebase/performance";
const $35f9e736408d85d1$var$name$7 = "@firebase/performance-compat";
const $35f9e736408d85d1$var$name$6 = "@firebase/remote-config";
const $35f9e736408d85d1$var$name$5 = "@firebase/remote-config-compat";
const $35f9e736408d85d1$var$name$4 = "@firebase/storage";
const $35f9e736408d85d1$var$name$3 = "@firebase/storage-compat";
const $35f9e736408d85d1$var$name$2 = "@firebase/firestore";
const $35f9e736408d85d1$var$name$1 = "@firebase/firestore-compat";
const $35f9e736408d85d1$var$name$p = "firebase";
const $35f9e736408d85d1$var$version$2 = "10.8.0";
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ /**
 * The default app name
 *
 * @internal
 */ const $35f9e736408d85d1$export$9f30fa0c10967f7f = "[DEFAULT]";
const $35f9e736408d85d1$var$PLATFORM_LOG_STRING = {
    [$35f9e736408d85d1$var$name$o]: "fire-core",
    [$35f9e736408d85d1$var$name$n]: "fire-core-compat",
    [$35f9e736408d85d1$var$name$l]: "fire-analytics",
    [$35f9e736408d85d1$var$name$m]: "fire-analytics-compat",
    [$35f9e736408d85d1$var$name$j]: "fire-app-check",
    [$35f9e736408d85d1$var$name$k]: "fire-app-check-compat",
    [$35f9e736408d85d1$var$name$i]: "fire-auth",
    [$35f9e736408d85d1$var$name$h]: "fire-auth-compat",
    [$35f9e736408d85d1$var$name$g]: "fire-rtdb",
    [$35f9e736408d85d1$var$name$f]: "fire-rtdb-compat",
    [$35f9e736408d85d1$var$name$e]: "fire-fn",
    [$35f9e736408d85d1$var$name$d]: "fire-fn-compat",
    [$35f9e736408d85d1$var$name$c]: "fire-iid",
    [$35f9e736408d85d1$var$name$b]: "fire-iid-compat",
    [$35f9e736408d85d1$var$name$a]: "fire-fcm",
    [$35f9e736408d85d1$var$name$9]: "fire-fcm-compat",
    [$35f9e736408d85d1$var$name$8]: "fire-perf",
    [$35f9e736408d85d1$var$name$7]: "fire-perf-compat",
    [$35f9e736408d85d1$var$name$6]: "fire-rc",
    [$35f9e736408d85d1$var$name$5]: "fire-rc-compat",
    [$35f9e736408d85d1$var$name$4]: "fire-gcs",
    [$35f9e736408d85d1$var$name$3]: "fire-gcs-compat",
    [$35f9e736408d85d1$var$name$2]: "fire-fst",
    [$35f9e736408d85d1$var$name$1]: "fire-fst-compat",
    "fire-js": "fire-js",
    [$35f9e736408d85d1$var$name$p]: "fire-js-all"
};
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ /**
 * @internal
 */ const $35f9e736408d85d1$export$b4e3c36c855b14b5 = new Map();
/**
 * Registered components.
 *
 * @internal
 */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
const $35f9e736408d85d1$export$9566bce3835c0f28 = new Map();
/**
 * @param component - the component being added to this app's container
 *
 * @internal
 */ function $35f9e736408d85d1$export$fa5244b94c62d36a(app, component) {
    try {
        app.container.addComponent(component);
    } catch (e) {
        $35f9e736408d85d1$var$logger.debug(`Component ${component.name} failed to register with FirebaseApp ${app.name}`, e);
    }
}
/**
 *
 * @internal
 */ function $35f9e736408d85d1$export$4393112b42e2b41d(app, component) {
    app.container.addOrOverwriteComponent(component);
}
/**
 *
 * @param component - the component to register
 * @returns whether or not the component is registered successfully
 *
 * @internal
 */ function $35f9e736408d85d1$export$c930050e7bb63965(component) {
    const componentName = component.name;
    if ($35f9e736408d85d1$export$9566bce3835c0f28.has(componentName)) {
        $35f9e736408d85d1$var$logger.debug(`There were multiple attempts to register component ${componentName}.`);
        return false;
    }
    $35f9e736408d85d1$export$9566bce3835c0f28.set(componentName, component);
    // add the component to existing app instances
    for (const app of $35f9e736408d85d1$export$b4e3c36c855b14b5.values())$35f9e736408d85d1$export$fa5244b94c62d36a(app, component);
    return true;
}
/**
 *
 * @param app - FirebaseApp instance
 * @param name - service name
 *
 * @returns the provider for the service with the matching name
 *
 * @internal
 */ function $35f9e736408d85d1$export$fa0d6da0f5838f50(app, name) {
    const heartbeatController = app.container.getProvider("heartbeat").getImmediate({
        optional: true
    });
    if (heartbeatController) heartbeatController.triggerHeartbeat();
    return app.container.getProvider(name);
}
/**
 *
 * @param app - FirebaseApp instance
 * @param name - service name
 * @param instanceIdentifier - service instance identifier in case the service supports multiple instances
 *
 * @internal
 */ function $35f9e736408d85d1$export$48d18de2ff1c45a5(app, name, instanceIdentifier = $35f9e736408d85d1$export$9f30fa0c10967f7f) {
    $35f9e736408d85d1$export$fa0d6da0f5838f50(app, name).clearInstance(instanceIdentifier);
}
/**
 * Test only
 *
 * @internal
 */ function $35f9e736408d85d1$export$3685d89b9c3cdfaf() {
    $35f9e736408d85d1$export$9566bce3835c0f28.clear();
}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ const $35f9e736408d85d1$var$ERRORS = {
    ["no-app" /* AppError.NO_APP */ ]: "No Firebase App '{$appName}' has been created - call initializeApp() first",
    ["bad-app-name" /* AppError.BAD_APP_NAME */ ]: "Illegal App name: '{$appName}",
    ["duplicate-app" /* AppError.DUPLICATE_APP */ ]: "Firebase App named '{$appName}' already exists with different options or config",
    ["app-deleted" /* AppError.APP_DELETED */ ]: "Firebase App named '{$appName}' already deleted",
    ["no-options" /* AppError.NO_OPTIONS */ ]: "Need to provide options, when not being deployed to hosting via source.",
    ["invalid-app-argument" /* AppError.INVALID_APP_ARGUMENT */ ]: "firebase.{$appName}() takes either no argument or a Firebase App instance.",
    ["invalid-log-argument" /* AppError.INVALID_LOG_ARGUMENT */ ]: "First argument to `onLog` must be null or a function.",
    ["idb-open" /* AppError.IDB_OPEN */ ]: "Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.",
    ["idb-get" /* AppError.IDB_GET */ ]: "Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.",
    ["idb-set" /* AppError.IDB_WRITE */ ]: "Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.",
    ["idb-delete" /* AppError.IDB_DELETE */ ]: "Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}."
};
const $35f9e736408d85d1$var$ERROR_FACTORY = new $35f9e736408d85d1$var$ErrorFactory("app", "Firebase", $35f9e736408d85d1$var$ERRORS);
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ class $35f9e736408d85d1$var$FirebaseAppImpl {
    constructor(options, config, container){
        this._isDeleted = false;
        this._options = Object.assign({}, options);
        this._config = Object.assign({}, config);
        this._name = config.name;
        this._automaticDataCollectionEnabled = config.automaticDataCollectionEnabled;
        this._container = container;
        this.container.addComponent(new $35f9e736408d85d1$var$Component("app", ()=>this, "PUBLIC" /* ComponentType.PUBLIC */ ));
    }
    get automaticDataCollectionEnabled() {
        this.checkDestroyed();
        return this._automaticDataCollectionEnabled;
    }
    set automaticDataCollectionEnabled(val) {
        this.checkDestroyed();
        this._automaticDataCollectionEnabled = val;
    }
    get name() {
        this.checkDestroyed();
        return this._name;
    }
    get options() {
        this.checkDestroyed();
        return this._options;
    }
    get config() {
        this.checkDestroyed();
        return this._config;
    }
    get container() {
        return this._container;
    }
    get isDeleted() {
        return this._isDeleted;
    }
    set isDeleted(val) {
        this._isDeleted = val;
    }
    /**
     * This function will throw an Error if the App has already been deleted -
     * use before performing API actions on the App.
     */ checkDestroyed() {
        if (this.isDeleted) throw $35f9e736408d85d1$var$ERROR_FACTORY.create("app-deleted" /* AppError.APP_DELETED */ , {
            appName: this._name
        });
    }
}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ /**
 * The current SDK version.
 *
 * @public
 */ const $35f9e736408d85d1$export$31499a9cd224b78c = $35f9e736408d85d1$var$version$2;
function $35f9e736408d85d1$export$c55cfd413944906d(_options, rawConfig = {}) {
    let options = _options;
    if (typeof rawConfig !== "object") {
        const name = rawConfig;
        rawConfig = {
            name: name
        };
    }
    const config = Object.assign({
        name: $35f9e736408d85d1$export$9f30fa0c10967f7f,
        automaticDataCollectionEnabled: false
    }, rawConfig);
    const name = config.name;
    if (typeof name !== "string" || !name) throw $35f9e736408d85d1$var$ERROR_FACTORY.create("bad-app-name" /* AppError.BAD_APP_NAME */ , {
        appName: String(name)
    });
    options || (options = $35f9e736408d85d1$var$getDefaultAppConfig());
    if (!options) throw $35f9e736408d85d1$var$ERROR_FACTORY.create("no-options" /* AppError.NO_OPTIONS */ );
    const existingApp = $35f9e736408d85d1$export$b4e3c36c855b14b5.get(name);
    if (existingApp) {
        // return the existing app if options and config deep equal the ones in the existing app.
        if ($35f9e736408d85d1$var$deepEqual(options, existingApp.options) && $35f9e736408d85d1$var$deepEqual(config, existingApp.config)) return existingApp;
        else throw $35f9e736408d85d1$var$ERROR_FACTORY.create("duplicate-app" /* AppError.DUPLICATE_APP */ , {
            appName: name
        });
    }
    const container = new $35f9e736408d85d1$var$ComponentContainer(name);
    for (const component of $35f9e736408d85d1$export$9566bce3835c0f28.values())container.addComponent(component);
    const newApp = new $35f9e736408d85d1$var$FirebaseAppImpl(options, config, container);
    $35f9e736408d85d1$export$b4e3c36c855b14b5.set(name, newApp);
    return newApp;
}
/**
 * Retrieves a {@link @firebase/app#FirebaseApp} instance.
 *
 * When called with no arguments, the default app is returned. When an app name
 * is provided, the app corresponding to that name is returned.
 *
 * An exception is thrown if the app being retrieved has not yet been
 * initialized.
 *
 * @example
 * ```javascript
 * // Return the default app
 * const app = getApp();
 * ```
 *
 * @example
 * ```javascript
 * // Return a named app
 * const otherApp = getApp("otherApp");
 * ```
 *
 * @param name - Optional name of the app to return. If no name is
 *   provided, the default is `"[DEFAULT]"`.
 *
 * @returns The app corresponding to the provided app name.
 *   If no app name is provided, the default app is returned.
 *
 * @public
 */ function $35f9e736408d85d1$export$f9962582c9e66d99(name = $35f9e736408d85d1$export$9f30fa0c10967f7f) {
    const app = $35f9e736408d85d1$export$b4e3c36c855b14b5.get(name);
    if (!app && name === $35f9e736408d85d1$export$9f30fa0c10967f7f && $35f9e736408d85d1$var$getDefaultAppConfig()) return $35f9e736408d85d1$export$c55cfd413944906d();
    if (!app) throw $35f9e736408d85d1$var$ERROR_FACTORY.create("no-app" /* AppError.NO_APP */ , {
        appName: name
    });
    return app;
}
/**
 * A (read-only) array of all initialized apps.
 * @public
 */ function $35f9e736408d85d1$export$68ddedf7d44b3bdf() {
    return Array.from($35f9e736408d85d1$export$b4e3c36c855b14b5.values());
}
/**
 * Renders this app unusable and frees the resources of all associated
 * services.
 *
 * @example
 * ```javascript
 * deleteApp(app)
 *   .then(function() {
 *     console.log("App deleted successfully");
 *   })
 *   .catch(function(error) {
 *     console.log("Error deleting app:", error);
 *   });
 * ```
 *
 * @public
 */ async function $35f9e736408d85d1$export$6eec44aa53d5ea34(app) {
    const name = app.name;
    if ($35f9e736408d85d1$export$b4e3c36c855b14b5.has(name)) {
        $35f9e736408d85d1$export$b4e3c36c855b14b5.delete(name);
        await Promise.all(app.container.getProviders().map((provider)=>provider.delete()));
        app.isDeleted = true;
    }
}
/**
 * Registers a library's name and version for platform logging purposes.
 * @param library - Name of 1p or 3p library (e.g. firestore, angularfire)
 * @param version - Current version of that library.
 * @param variant - Bundle variant, e.g., node, rn, etc.
 *
 * @public
 */ function $35f9e736408d85d1$export$d29d5299a7137abc(libraryKeyOrName, version, variant) {
    var _a;
    // TODO: We can use this check to whitelist strings when/if we set up
    // a good whitelist system.
    let library = (_a = $35f9e736408d85d1$var$PLATFORM_LOG_STRING[libraryKeyOrName]) !== null && _a !== void 0 ? _a : libraryKeyOrName;
    if (variant) library += `-${variant}`;
    const libraryMismatch = library.match(/\s|\//);
    const versionMismatch = version.match(/\s|\//);
    if (libraryMismatch || versionMismatch) {
        const warning = [
            `Unable to register library "${library}" with version "${version}":`
        ];
        if (libraryMismatch) warning.push(`library name "${library}" contains illegal characters (whitespace or "/")`);
        if (libraryMismatch && versionMismatch) warning.push("and");
        if (versionMismatch) warning.push(`version name "${version}" contains illegal characters (whitespace or "/")`);
        $35f9e736408d85d1$var$logger.warn(warning.join(" "));
        return;
    }
    $35f9e736408d85d1$export$c930050e7bb63965(new $35f9e736408d85d1$var$Component(`${library}-version`, ()=>({
            library: library,
            version: version
        }), "VERSION" /* ComponentType.VERSION */ ));
}
/**
 * Sets log handler for all Firebase SDKs.
 * @param logCallback - An optional custom log handler that executes user code whenever
 * the Firebase SDK makes a logging call.
 *
 * @public
 */ function $35f9e736408d85d1$export$a82ad227dc8163dc(logCallback, options) {
    if (logCallback !== null && typeof logCallback !== "function") throw $35f9e736408d85d1$var$ERROR_FACTORY.create("invalid-log-argument" /* AppError.INVALID_LOG_ARGUMENT */ );
    $35f9e736408d85d1$var$setUserLogHandler(logCallback, options);
}
/**
 * Sets log level for all Firebase SDKs.
 *
 * All of the log types above the current log level are captured (i.e. if
 * you set the log level to `info`, errors are logged, but `debug` and
 * `verbose` logs are not).
 *
 * @public
 */ function $35f9e736408d85d1$export$c622e99c0ce7b1c9(logLevel) {
    $35f9e736408d85d1$var$setLogLevel$1(logLevel);
}
/**
 * @license
 * Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ const $35f9e736408d85d1$var$DB_NAME = "firebase-heartbeat-database";
const $35f9e736408d85d1$var$DB_VERSION = 1;
const $35f9e736408d85d1$var$STORE_NAME = "firebase-heartbeat-store";
let $35f9e736408d85d1$var$dbPromise = null;
function $35f9e736408d85d1$var$getDbPromise() {
    if (!$35f9e736408d85d1$var$dbPromise) $35f9e736408d85d1$var$dbPromise = $35f9e736408d85d1$var$openDB($35f9e736408d85d1$var$DB_NAME, $35f9e736408d85d1$var$DB_VERSION, {
        upgrade: (db, oldVersion)=>{
            // We don't use 'break' in this switch statement, the fall-through
            // behavior is what we want, because if there are multiple versions between
            // the old version and the current version, we want ALL the migrations
            // that correspond to those versions to run, not only the last one.
            // eslint-disable-next-line default-case
            switch(oldVersion){
                case 0:
                    try {
                        db.createObjectStore($35f9e736408d85d1$var$STORE_NAME);
                    } catch (e) {
                        // Safari/iOS browsers throw occasional exceptions on
                        // db.createObjectStore() that may be a bug. Avoid blocking
                        // the rest of the app functionality.
                        console.warn(e);
                    }
            }
        }
    }).catch((e)=>{
        throw $35f9e736408d85d1$var$ERROR_FACTORY.create("idb-open" /* AppError.IDB_OPEN */ , {
            originalErrorMessage: e.message
        });
    });
    return $35f9e736408d85d1$var$dbPromise;
}
async function $35f9e736408d85d1$var$readHeartbeatsFromIndexedDB(app) {
    try {
        const db = await $35f9e736408d85d1$var$getDbPromise();
        const tx = db.transaction($35f9e736408d85d1$var$STORE_NAME);
        const result = await tx.objectStore($35f9e736408d85d1$var$STORE_NAME).get($35f9e736408d85d1$var$computeKey(app));
        // We already have the value but tx.done can throw,
        // so we need to await it here to catch errors
        await tx.done;
        return result;
    } catch (e) {
        if (e instanceof $35f9e736408d85d1$export$dd24e9cd51226c56) $35f9e736408d85d1$var$logger.warn(e.message);
        else {
            const idbGetError = $35f9e736408d85d1$var$ERROR_FACTORY.create("idb-get" /* AppError.IDB_GET */ , {
                originalErrorMessage: e === null || e === void 0 ? void 0 : e.message
            });
            $35f9e736408d85d1$var$logger.warn(idbGetError.message);
        }
    }
}
async function $35f9e736408d85d1$var$writeHeartbeatsToIndexedDB(app, heartbeatObject) {
    try {
        const db = await $35f9e736408d85d1$var$getDbPromise();
        const tx = db.transaction($35f9e736408d85d1$var$STORE_NAME, "readwrite");
        const objectStore = tx.objectStore($35f9e736408d85d1$var$STORE_NAME);
        await objectStore.put(heartbeatObject, $35f9e736408d85d1$var$computeKey(app));
        await tx.done;
    } catch (e) {
        if (e instanceof $35f9e736408d85d1$export$dd24e9cd51226c56) $35f9e736408d85d1$var$logger.warn(e.message);
        else {
            const idbGetError = $35f9e736408d85d1$var$ERROR_FACTORY.create("idb-set" /* AppError.IDB_WRITE */ , {
                originalErrorMessage: e === null || e === void 0 ? void 0 : e.message
            });
            $35f9e736408d85d1$var$logger.warn(idbGetError.message);
        }
    }
}
function $35f9e736408d85d1$var$computeKey(app) {
    return `${app.name}!${app.options.appId}`;
}
/**
 * @license
 * Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ const $35f9e736408d85d1$var$MAX_HEADER_BYTES = 1024;
// 30 days
const $35f9e736408d85d1$var$STORED_HEARTBEAT_RETENTION_MAX_MILLIS = 2592000000;
class $35f9e736408d85d1$var$HeartbeatServiceImpl {
    constructor(container){
        this.container = container;
        /**
         * In-memory cache for heartbeats, used by getHeartbeatsHeader() to generate
         * the header string.
         * Stores one record per date. This will be consolidated into the standard
         * format of one record per user agent string before being sent as a header.
         * Populated from indexedDB when the controller is instantiated and should
         * be kept in sync with indexedDB.
         * Leave public for easier testing.
         */ this._heartbeatsCache = null;
        const app = this.container.getProvider("app").getImmediate();
        this._storage = new $35f9e736408d85d1$var$HeartbeatStorageImpl(app);
        this._heartbeatsCachePromise = this._storage.read().then((result)=>{
            this._heartbeatsCache = result;
            return result;
        });
    }
    /**
     * Called to report a heartbeat. The function will generate
     * a HeartbeatsByUserAgent object, update heartbeatsCache, and persist it
     * to IndexedDB.
     * Note that we only store one heartbeat per day. So if a heartbeat for today is
     * already logged, subsequent calls to this function in the same day will be ignored.
     */ async triggerHeartbeat() {
        var _a, _b;
        const platformLogger = this.container.getProvider("platform-logger").getImmediate();
        // This is the "Firebase user agent" string from the platform logger
        // service, not the browser user agent.
        const agent = platformLogger.getPlatformInfoString();
        const date = $35f9e736408d85d1$var$getUTCDateString();
        if (((_a = this._heartbeatsCache) === null || _a === void 0 ? void 0 : _a.heartbeats) == null) {
            this._heartbeatsCache = await this._heartbeatsCachePromise;
            // If we failed to construct a heartbeats cache, then return immediately.
            if (((_b = this._heartbeatsCache) === null || _b === void 0 ? void 0 : _b.heartbeats) == null) return;
        }
        // Do not store a heartbeat if one is already stored for this day
        // or if a header has already been sent today.
        if (this._heartbeatsCache.lastSentHeartbeatDate === date || this._heartbeatsCache.heartbeats.some((singleDateHeartbeat)=>singleDateHeartbeat.date === date)) return;
        else // There is no entry for this date. Create one.
        this._heartbeatsCache.heartbeats.push({
            date: date,
            agent: agent
        });
        // Remove entries older than 30 days.
        this._heartbeatsCache.heartbeats = this._heartbeatsCache.heartbeats.filter((singleDateHeartbeat)=>{
            const hbTimestamp = new Date(singleDateHeartbeat.date).valueOf();
            const now = Date.now();
            return now - hbTimestamp <= $35f9e736408d85d1$var$STORED_HEARTBEAT_RETENTION_MAX_MILLIS;
        });
        return this._storage.overwrite(this._heartbeatsCache);
    }
    /**
     * Returns a base64 encoded string which can be attached to the heartbeat-specific header directly.
     * It also clears all heartbeats from memory as well as in IndexedDB.
     *
     * NOTE: Consuming product SDKs should not send the header if this method
     * returns an empty string.
     */ async getHeartbeatsHeader() {
        var _a;
        if (this._heartbeatsCache === null) await this._heartbeatsCachePromise;
        // If it's still null or the array is empty, there is no data to send.
        if (((_a = this._heartbeatsCache) === null || _a === void 0 ? void 0 : _a.heartbeats) == null || this._heartbeatsCache.heartbeats.length === 0) return "";
        const date = $35f9e736408d85d1$var$getUTCDateString();
        // Extract as many heartbeats from the cache as will fit under the size limit.
        const { heartbeatsToSend: heartbeatsToSend, unsentEntries: unsentEntries } = $35f9e736408d85d1$var$extractHeartbeatsForHeader(this._heartbeatsCache.heartbeats);
        const headerString = $35f9e736408d85d1$var$base64urlEncodeWithoutPadding(JSON.stringify({
            version: 2,
            heartbeats: heartbeatsToSend
        }));
        // Store last sent date to prevent another being logged/sent for the same day.
        this._heartbeatsCache.lastSentHeartbeatDate = date;
        if (unsentEntries.length > 0) {
            // Store any unsent entries if they exist.
            this._heartbeatsCache.heartbeats = unsentEntries;
            // This seems more likely than emptying the array (below) to lead to some odd state
            // since the cache isn't empty and this will be called again on the next request,
            // and is probably safest if we await it.
            await this._storage.overwrite(this._heartbeatsCache);
        } else {
            this._heartbeatsCache.heartbeats = [];
            // Do not wait for this, to reduce latency.
            this._storage.overwrite(this._heartbeatsCache);
        }
        return headerString;
    }
}
function $35f9e736408d85d1$var$getUTCDateString() {
    const today = new Date();
    // Returns date format 'YYYY-MM-DD'
    return today.toISOString().substring(0, 10);
}
function $35f9e736408d85d1$var$extractHeartbeatsForHeader(heartbeatsCache, maxSize = $35f9e736408d85d1$var$MAX_HEADER_BYTES) {
    // Heartbeats grouped by user agent in the standard format to be sent in
    // the header.
    const heartbeatsToSend = [];
    // Single date format heartbeats that are not sent.
    let unsentEntries = heartbeatsCache.slice();
    for (const singleDateHeartbeat of heartbeatsCache){
        // Look for an existing entry with the same user agent.
        const heartbeatEntry = heartbeatsToSend.find((hb)=>hb.agent === singleDateHeartbeat.agent);
        if (!heartbeatEntry) {
            // If no entry for this user agent exists, create one.
            heartbeatsToSend.push({
                agent: singleDateHeartbeat.agent,
                dates: [
                    singleDateHeartbeat.date
                ]
            });
            if ($35f9e736408d85d1$var$countBytes(heartbeatsToSend) > maxSize) {
                // If the header would exceed max size, remove the added heartbeat
                // entry and stop adding to the header.
                heartbeatsToSend.pop();
                break;
            }
        } else {
            heartbeatEntry.dates.push(singleDateHeartbeat.date);
            // If the header would exceed max size, remove the added date
            // and stop adding to the header.
            if ($35f9e736408d85d1$var$countBytes(heartbeatsToSend) > maxSize) {
                heartbeatEntry.dates.pop();
                break;
            }
        }
        // Pop unsent entry from queue. (Skipped if adding the entry exceeded
        // quota and the loop breaks early.)
        unsentEntries = unsentEntries.slice(1);
    }
    return {
        heartbeatsToSend: heartbeatsToSend,
        unsentEntries: unsentEntries
    };
}
class $35f9e736408d85d1$var$HeartbeatStorageImpl {
    constructor(app){
        this.app = app;
        this._canUseIndexedDBPromise = this.runIndexedDBEnvironmentCheck();
    }
    async runIndexedDBEnvironmentCheck() {
        if (!$35f9e736408d85d1$var$isIndexedDBAvailable()) return false;
        else return $35f9e736408d85d1$var$validateIndexedDBOpenable().then(()=>true).catch(()=>false);
    }
    /**
     * Read all heartbeats.
     */ async read() {
        const canUseIndexedDB = await this._canUseIndexedDBPromise;
        if (!canUseIndexedDB) return {
            heartbeats: []
        };
        else {
            const idbHeartbeatObject = await $35f9e736408d85d1$var$readHeartbeatsFromIndexedDB(this.app);
            if (idbHeartbeatObject === null || idbHeartbeatObject === void 0 ? void 0 : idbHeartbeatObject.heartbeats) return idbHeartbeatObject;
            else return {
                heartbeats: []
            };
        }
    }
    // overwrite the storage with the provided heartbeats
    async overwrite(heartbeatsObject) {
        var _a;
        const canUseIndexedDB = await this._canUseIndexedDBPromise;
        if (!canUseIndexedDB) return;
        else {
            const existingHeartbeatsObject = await this.read();
            return $35f9e736408d85d1$var$writeHeartbeatsToIndexedDB(this.app, {
                lastSentHeartbeatDate: (_a = heartbeatsObject.lastSentHeartbeatDate) !== null && _a !== void 0 ? _a : existingHeartbeatsObject.lastSentHeartbeatDate,
                heartbeats: heartbeatsObject.heartbeats
            });
        }
    }
    // add heartbeats
    async add(heartbeatsObject) {
        var _a;
        const canUseIndexedDB = await this._canUseIndexedDBPromise;
        if (!canUseIndexedDB) return;
        else {
            const existingHeartbeatsObject = await this.read();
            return $35f9e736408d85d1$var$writeHeartbeatsToIndexedDB(this.app, {
                lastSentHeartbeatDate: (_a = heartbeatsObject.lastSentHeartbeatDate) !== null && _a !== void 0 ? _a : existingHeartbeatsObject.lastSentHeartbeatDate,
                heartbeats: [
                    ...existingHeartbeatsObject.heartbeats,
                    ...heartbeatsObject.heartbeats
                ]
            });
        }
    }
}
/**
 * Calculate bytes of a HeartbeatsByUserAgent array after being wrapped
 * in a platform logging header JSON object, stringified, and converted
 * to base 64.
 */ function $35f9e736408d85d1$var$countBytes(heartbeatsCache) {
    // base64 has a restricted set of characters, all of which should be 1 byte.
    return $35f9e736408d85d1$var$base64urlEncodeWithoutPadding(// heartbeatsCache wrapper properties
    JSON.stringify({
        version: 2,
        heartbeats: heartbeatsCache
    })).length;
}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ function $35f9e736408d85d1$var$registerCoreComponents(variant) {
    $35f9e736408d85d1$export$c930050e7bb63965(new $35f9e736408d85d1$var$Component("platform-logger", (container)=>new $35f9e736408d85d1$var$PlatformLoggerServiceImpl(container), "PRIVATE" /* ComponentType.PRIVATE */ ));
    $35f9e736408d85d1$export$c930050e7bb63965(new $35f9e736408d85d1$var$Component("heartbeat", (container)=>new $35f9e736408d85d1$var$HeartbeatServiceImpl(container), "PRIVATE" /* ComponentType.PRIVATE */ ));
    // Register `app` package.
    $35f9e736408d85d1$export$d29d5299a7137abc($35f9e736408d85d1$var$name$o, $35f9e736408d85d1$var$version$1, variant);
    // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
    $35f9e736408d85d1$export$d29d5299a7137abc($35f9e736408d85d1$var$name$o, $35f9e736408d85d1$var$version$1, "esm2017");
    // Register platform SDK identifier (no version).
    $35f9e736408d85d1$export$d29d5299a7137abc("fire-js", "");
}
/**
 * Firebase App
 *
 * @remarks This package coordinates the communication between the different Firebase components
 * @packageDocumentation
 */ $35f9e736408d85d1$var$registerCoreComponents("");
var $35f9e736408d85d1$var$name = "firebase";
var $35f9e736408d85d1$var$version = "10.8.0";
/**
 * @license
 * Copyright 2020 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ $35f9e736408d85d1$export$d29d5299a7137abc($35f9e736408d85d1$var$name, $35f9e736408d85d1$var$version, "cdn");
 //# sourceMappingURL=firebase-app.js.map

});


