UNPKG

firebase

Version:

Firebase JavaScript library for web and Node.js

1,235 lines (1,213 loc) • 793 kB
import { _getProvider, getApp, _removeServiceInstance, SDK_VERSION, _registerComponent, registerVersion } from 'https://www.gstatic.com/firebasejs/9.0.0/firebase-app.js'; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics$1 = function(d, b) { extendStatics$1 = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics$1(d, b); }; function __extends$1(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics$1(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __spreadArray(to, from) { for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) to[j] = from[i]; return to; } /** * @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 stringToByteArray$1 = function (str) { // TODO(user): Use native implementations if/when available var out = []; var p = 0; for (var i = 0; i < str.length; i++) { var 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. */ var byteArrayToString = function (bytes) { // TODO(user): Use native implementations if/when available var out = []; var pos = 0, c = 0; while (pos < bytes.length) { var c1 = bytes[pos++]; if (c1 < 128) { out[c++] = String.fromCharCode(c1); } else if (c1 > 191 && c1 < 224) { var c2 = bytes[pos++]; out[c++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63)); } else if (c1 > 239 && c1 < 365) { // Surrogate Pair var c2 = bytes[pos++]; var c3 = bytes[pos++]; var c4 = bytes[pos++]; var 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 { var c2 = bytes[pos++]; var 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_() 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: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + 'abcdefghijklmnopqrstuvwxyz' + '0123456789', /** * 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: function (input, webSafe) { if (!Array.isArray(input)) { throw Error('encodeByteArray takes an array as a parameter'); } this.init_(); var byteToCharMap = webSafe ? this.byteToCharMapWebSafe_ : this.byteToCharMap_; var output = []; for (var i = 0; i < input.length; i += 3) { var byte1 = input[i]; var haveByte2 = i + 1 < input.length; var byte2 = haveByte2 ? input[i + 1] : 0; var haveByte3 = i + 2 < input.length; var byte3 = haveByte3 ? input[i + 2] : 0; var outByte1 = byte1 >> 2; var outByte2 = ((byte1 & 0x03) << 4) | (byte2 >> 4); var outByte3 = ((byte2 & 0x0f) << 2) | (byte3 >> 6); var 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: function (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(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: function (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 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: function (input, webSafe) { this.init_(); var charToByteMap = webSafe ? this.charToByteMapWebSafe_ : this.charToByteMap_; var output = []; for (var i = 0; i < input.length;) { var byte1 = charToByteMap[input.charAt(i++)]; var haveByte2 = i < input.length; var byte2 = haveByte2 ? charToByteMap[input.charAt(i)] : 0; ++i; var haveByte3 = i < input.length; var byte3 = haveByte3 ? charToByteMap[input.charAt(i)] : 64; ++i; var haveByte4 = i < input.length; var byte4 = haveByte4 ? charToByteMap[input.charAt(i)] : 64; ++i; if (byte1 == null || byte2 == null || byte3 == null || byte4 == null) { throw Error(); } var outByte1 = (byte1 << 2) | (byte2 >> 4); output.push(outByte1); if (byte3 !== 64) { var outByte2 = ((byte2 << 4) & 0xf0) | (byte3 >> 2); output.push(outByte2); if (byte4 !== 64) { var 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_: function () { if (!this.byteToCharMap_) { this.byteToCharMap_ = {}; this.charToByteMap_ = {}; this.byteToCharMapWebSafe_ = {}; this.charToByteMapWebSafe_ = {}; // We want quick mappings back and forth, so we precompute two maps. for (var 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; } } } } }; /** * URL-safe base64 encoding */ var base64Encode = function (str) { var utf8Bytes = stringToByteArray$1(str); return base64.encodeByteArray(utf8Bytes, true); }; /** * URL-safe base64 encoding (without "." padding in the end). * e.g. Used in JSON Web Token (JWT) parts. */ var base64urlEncodeWithoutPadding = function (str) { // Use base64url encoding and remove padding in the end (dot characters). return base64Encode(str).replace(/\./g, ''); }; /** * @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. */ function createMockUserToken(token, projectId) { if (token.uid) { throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.'); } // Unsecured JWTs use "none" as the algorithm. var header = { alg: 'none', type: 'JWT' }; var project = projectId || 'demo-project'; var iat = token.iat || 0; var sub = token.sub || token.user_id; if (!sub) { throw new Error("mockUserToken must contain 'sub' or 'user_id' field!"); } var payload = __assign({ // Set all required fields to decent defaults iss: "https://securetoken.google.com/" + project, aud: project, iat: iat, exp: iat + 3600, auth_time: iat, sub: sub, user_id: sub, firebase: { sign_in_provider: 'custom', identities: {} } }, token); // Unsecured JWTs use the empty string as a signature. var signature = ''; return [ base64urlEncodeWithoutPadding(JSON.stringify(header)), base64urlEncodeWithoutPadding(JSON.stringify(payload)), signature ].join('.'); } /** * @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. */ /** * Returns navigator.userAgent string or '' if it's not defined. * @return user agent string */ function getUA() { if (typeof navigator !== 'undefined' && typeof navigator['userAgent'] === 'string') { return navigator['userAgent']; } else { return ''; } } /** * Detect Cordova / PhoneGap / Ionic frameworks on a mobile device. * * Deliberately does not rely on checking `file://` URLs (as this fails PhoneGap * in the Ripple emulator) nor Cordova `onDeviceReady`, which would normally * wait for a callback. */ function isMobileCordova() { return (typeof window !== 'undefined' && // @ts-ignore Setting up an broadly applicable index signature for Window // just to deal with this case would probably be a bad idea. !!(window['cordova'] || window['phonegap'] || window['PhoneGap']) && /ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(getUA())); } /** * Detect Node.js. * * @return true if Node.js environment is detected. */ // Node detection logic from: https://github.com/iliakan/detect-node/ function isNode() { try { return (Object.prototype.toString.call(global.process) === '[object process]'); } catch (e) { return false; } } function isBrowserExtension() { var runtime = typeof chrome === 'object' ? chrome.runtime : typeof browser === 'object' ? browser.runtime : undefined; return typeof runtime === 'object' && runtime.id !== undefined; } /** * Detect React Native. * * @return true if ReactNative environment is detected. */ function isReactNative() { return (typeof navigator === 'object' && navigator['product'] === 'ReactNative'); } /** Detects Electron apps. */ function isElectron() { return getUA().indexOf('Electron/') >= 0; } /** Detects Internet Explorer. */ function isIE() { var ua = getUA(); return ua.indexOf('MSIE ') >= 0 || ua.indexOf('Trident/') >= 0; } /** Detects Universal Windows Platform apps. */ function isUWP() { return getUA().indexOf('MSAppHost/') >= 0; } /** Returns true if we are running in Safari. */ function isSafari() { return (!isNode() && navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrome')); } /** * @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 ERROR_NAME = 'FirebaseError'; // Based on code from: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Custom_Error_Types var FirebaseError = /** @class */ (function (_super) { __extends$1(FirebaseError, _super); function FirebaseError(code, message, customData) { var _this = _super.call(this, message) || this; _this.code = code; _this.customData = customData; _this.name = 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, FirebaseError.prototype); // Maintains proper stack trace for where our error was thrown. // Only available on V8. if (Error.captureStackTrace) { Error.captureStackTrace(_this, ErrorFactory.prototype.create); } return _this; } return FirebaseError; }(Error)); var ErrorFactory = /** @class */ (function () { function ErrorFactory(service, serviceName, errors) { this.service = service; this.serviceName = serviceName; this.errors = errors; } ErrorFactory.prototype.create = function (code) { var data = []; for (var _i = 1; _i < arguments.length; _i++) { data[_i - 1] = arguments[_i]; } var customData = data[0] || {}; var fullCode = this.service + "/" + code; var template = this.errors[code]; var message = template ? replaceTemplate(template, customData) : 'Error'; // Service Name: Error message (service/code). var fullMessage = this.serviceName + ": " + message + " (" + fullCode + ")."; var error = new FirebaseError(fullCode, fullMessage, customData); return error; }; return ErrorFactory; }()); function replaceTemplate(template, data) { return template.replace(PATTERN, function (_, key) { var value = data[key]; return value != null ? String(value) : "<" + key + "?>"; }); } var PATTERN = /\{\$([^}]+)}/g; /** * Deep equal two objects. Support Arrays and Objects. */ function deepEqual(a, b) { if (a === b) { return true; } var aKeys = Object.keys(a); var bKeys = Object.keys(b); for (var _i = 0, aKeys_1 = aKeys; _i < aKeys_1.length; _i++) { var k = aKeys_1[_i]; if (!bKeys.includes(k)) { return false; } var aProp = a[k]; var bProp = b[k]; if (isObject(aProp) && isObject(bProp)) { if (!deepEqual(aProp, bProp)) { return false; } } else if (aProp !== bProp) { return false; } } for (var _a = 0, bKeys_1 = bKeys; _a < bKeys_1.length; _a++) { var k = bKeys_1[_a]; if (!aKeys.includes(k)) { return false; } } return true; } function isObject(thing) { return thing !== null && typeof thing === 'object'; } /** * @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. */ function getModularInstance(service) { if (service && service._delegate) { return service._delegate; } else { return service; } } /** * Component for service name T, e.g. `auth`, `auth-internal` */ var Component = /** @class */ (function () { /** * * @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 */ function Component(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" /* LAZY */; this.onInstanceCreated = null; } Component.prototype.setInstantiationMode = function (mode) { this.instantiationMode = mode; return this; }; Component.prototype.setMultipleInstances = function (multipleInstances) { this.multipleInstances = multipleInstances; return this; }; Component.prototype.setServiceProps = function (props) { this.serviceProps = props; return this; }; Component.prototype.setInstanceCreatedCallback = function (callback) { this.onInstanceCreated = callback; return this; }; return Component; }()); /** * @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 _a$1; /** * 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 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"; })(LogLevel || (LogLevel = {})); var levelStringToEnum = { 'debug': LogLevel.DEBUG, 'verbose': LogLevel.VERBOSE, 'info': LogLevel.INFO, 'warn': LogLevel.WARN, 'error': LogLevel.ERROR, 'silent': LogLevel.SILENT }; /** * The default log level */ var defaultLogLevel = 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. */ var ConsoleMethod = (_a$1 = {}, _a$1[LogLevel.DEBUG] = 'log', _a$1[LogLevel.VERBOSE] = 'log', _a$1[LogLevel.INFO] = 'info', _a$1[LogLevel.WARN] = 'warn', _a$1[LogLevel.ERROR] = 'error', _a$1); /** * 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) */ var defaultLogHandler = function (instance, logType) { var args = []; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } if (logType < instance.logLevel) { return; } var now = new Date().toISOString(); var method = ConsoleMethod[logType]; if (method) { console[method].apply(console, __spreadArray(["[" + now + "] " + instance.name + ":"], args)); } else { throw new Error("Attempted to log a message with an invalid logType (value: " + logType + ")"); } }; var Logger = /** @class */ (function () { /** * 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 */ function Logger(name) { this.name = name; /** * The log level of the given Logger instance. */ this._logLevel = 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 = defaultLogHandler; /** * The optional, additional, user-defined log handler for the Logger instance. */ this._userLogHandler = null; } Object.defineProperty(Logger.prototype, "logLevel", { get: function () { return this._logLevel; }, set: function (val) { if (!(val in LogLevel)) { throw new TypeError("Invalid value \"" + val + "\" assigned to `logLevel`"); } this._logLevel = val; }, enumerable: false, configurable: true }); // Workaround for setter/getter having to be the same type. Logger.prototype.setLogLevel = function (val) { this._logLevel = typeof val === 'string' ? levelStringToEnum[val] : val; }; Object.defineProperty(Logger.prototype, "logHandler", { get: function () { return this._logHandler; }, set: function (val) { if (typeof val !== 'function') { throw new TypeError('Value assigned to `logHandler` must be a function'); } this._logHandler = val; }, enumerable: false, configurable: true }); Object.defineProperty(Logger.prototype, "userLogHandler", { get: function () { return this._userLogHandler; }, set: function (val) { this._userLogHandler = val; }, enumerable: false, configurable: true }); /** * The functions below are all based on the `console` interface */ Logger.prototype.debug = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } this._userLogHandler && this._userLogHandler.apply(this, __spreadArray([this, LogLevel.DEBUG], args)); this._logHandler.apply(this, __spreadArray([this, LogLevel.DEBUG], args)); }; Logger.prototype.log = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } this._userLogHandler && this._userLogHandler.apply(this, __spreadArray([this, LogLevel.VERBOSE], args)); this._logHandler.apply(this, __spreadArray([this, LogLevel.VERBOSE], args)); }; Logger.prototype.info = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } this._userLogHandler && this._userLogHandler.apply(this, __spreadArray([this, LogLevel.INFO], args)); this._logHandler.apply(this, __spreadArray([this, LogLevel.INFO], args)); }; Logger.prototype.warn = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } this._userLogHandler && this._userLogHandler.apply(this, __spreadArray([this, LogLevel.WARN], args)); this._logHandler.apply(this, __spreadArray([this, LogLevel.WARN], args)); }; Logger.prototype.error = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } this._userLogHandler && this._userLogHandler.apply(this, __spreadArray([this, LogLevel.ERROR], args)); this._logHandler.apply(this, __spreadArray([this, LogLevel.ERROR], args)); }; return Logger; }()); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } function __values(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); } var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; var k$1, goog = goog || {}, l = commonjsGlobal || self; function aa$1() { } function ba$1(a) { var b = typeof a; b = "object" != b ? b : a ? Array.isArray(a) ? "array" : b : "null"; return "array" == b || "object" == b && "number" == typeof a.length; } function p(a) { var b = typeof a; return "object" == b && null != a || "function" == b; } function da$1(a) { return Object.prototype.hasOwnProperty.call(a, ea$1) && a[ea$1] || (a[ea$1] = ++fa$1); } var ea$1 = "closure_uid_" + (1E9 * Math.random() >>> 0), fa$1 = 0; function ha$1(a, b, c) { return a.call.apply(a.bind, arguments); } function ia$1(a, b, c) { if (!a) throw Error(); if (2 < arguments.length) { var d = Array.prototype.slice.call(arguments, 2); return function () { var e = Array.prototype.slice.call(arguments); Array.prototype.unshift.apply(e, d); return a.apply(b, e); }; } return function () { return a.apply(b, arguments); }; } function q$1(a, b, c) { Function.prototype.bind && -1 != Function.prototype.bind.toString().indexOf("native code") ? q$1 = ha$1 : q$1 = ia$1; return q$1.apply(null, arguments); } function ja$1(a, b) { var c = Array.prototype.slice.call(arguments, 1); return function () { var d = c.slice(); d.push.apply(d, arguments); return a.apply(this, d); }; } function t(a, b) { function c() { } c.prototype = b.prototype; a.Z = b.prototype; a.prototype = new c; a.prototype.constructor = a; a.Vb = function (d, e, f) { for (var h = Array(arguments.length - 2), n = 2; n < arguments.length; n++) h[n - 2] = arguments[n]; return b.prototype[e].apply(d, h); }; } function v() { this.s = this.s; this.o = this.o; } var ka$1 = 0, la$1 = {}; v.prototype.s = !1; v.prototype.na = function () { if (!this.s && (this.s = !0, this.M(), 0 != ka$1)) { var a = da$1(this); delete la$1[a]; } }; v.prototype.M = function () { if (this.o) for (; this.o.length;) this.o.shift()(); }; var ma$1 = Array.prototype.indexOf ? function (a, b) { return Array.prototype.indexOf.call(a, b, void 0); } : function (a, b) { if ("string" === typeof a) return "string" !== typeof b || 1 != b.length ? -1 : a.indexOf(b, 0); for (var c = 0; c < a.length; c++) if (c in a && a[c] === b) return c; return -1; }, na$1 = Array.prototype.forEach ? function (a, b, c) { Array.prototype.forEach.call(a, b, c); } : function (a, b, c) { var d = a.length, e = "string" === typeof a ? a.split("") : a; for (var f = 0; f < d; f++) f in e && b.call(c, e[f], f, a); }; function oa$1(a) { a: { var b = pa$1; var c = a.length, d = "string" === typeof a ? a.split("") : a; for (var e = 0; e < c; e++) if (e in d && b.call(void 0, d[e], e, a)) { b = e; break a; } b = -1; } return 0 > b ? null : "string" === typeof a ? a.charAt(b) : a[b]; } function qa$1(a) { return Array.prototype.concat.apply([], arguments); } function ra$1(a) { var b = a.length; if (0 < b) { var c = Array(b); for (var d = 0; d < b; d++) c[d] = a[d]; return c; } return []; } function sa$1(a) { return /^[\s\xa0]*$/.test(a); } var ta$1 = String.prototype.trim ? function (a) { return a.trim(); } : function (a) { return /^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(a)[1]; }; function w(a, b) { return -1 != a.indexOf(b); } function ua$1(a, b) { return a < b ? -1 : a > b ? 1 : 0; } var x$1; a: { var va$1 = l.navigator; if (va$1) { var wa$1 = va$1.userAgent; if (wa$1) { x$1 = wa$1; break a; } } x$1 = ""; } function xa$1(a, b, c) { for (var d in a) b.call(c, a[d], d, a); } function ya$1(a) { var b = {}; for (var c in a) b[c] = a[c]; return b; } var za$1 = "constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "); function Aa$1(a, b) { var c, d; for (var e = 1; e < arguments.length; e++) { d = arguments[e]; for (c in d) a[c] = d[c]; for (var f = 0; f < za$1.length; f++) c = za$1[f], Object.prototype.hasOwnProperty.call(d, c) && (a[c] = d[c]); } } function Ca$1(a) { Ca$1[" "](a); return a; } Ca$1[" "] = aa$1; function Fa$1(a) { var b = Ga$1; return Object.prototype.hasOwnProperty.call(b, 9) ? b[9] : b[9] = a(9); } var Ha$1 = w(x$1, "Opera"), y = w(x$1, "Trident") || w(x$1, "MSIE"), Ia$1 = w(x$1, "Edge"), Ja$1 = Ia$1 || y, Ka$1 = w(x$1, "Gecko") && !(w(x$1.toLowerCase(), "webkit") && !w(x$1, "Edge")) && !(w(x$1, "Trident") || w(x$1, "MSIE")) && !w(x$1, "Edge"), La$1 = w(x$1.toLowerCase(), "webkit") && !w(x$1, "Edge"); function Ma$1() { var a = l.document; return a ? a.documentMode : void 0; } var Na$1; a: { var Oa$1 = "", Pa$1 = function () { var a = x$1; if (Ka$1) return /rv:([^\);]+)(\)|;)/.exec(a); if (Ia$1) return /Edge\/([\d\.]+)/.exec(a); if (y) return /\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(a); if (La$1) return /WebKit\/(\S+)/.exec(a); if (Ha$1) return /(?:Version)[ \/]?(\S+)/.exec(a); }(); Pa$1 && (Oa$1 = Pa$1 ? Pa$1[1] : ""); if (y) { var Qa$1 = Ma$1(); if (null != Qa$1 && Qa$1 > parseFloat(Oa$1)) { Na$1 = String(Qa$1); break a; } } Na$1 = Oa$1; } var Ga$1 = {}; function Ra$1() { return Fa$1(function () { var a = 0; var b = ta$1(String(Na$1)).split("."), c = ta$1("9").split("."), d = Math.max(b.length, c.length); for (var h = 0; 0 == a && h < d; h++) { var e = b[h] || "", f = c[h] || ""; do { e = /(\d*)(\D*)(.*)/.exec(e) || ["", "", "", ""]; f = /(\d*)(\D*)(.*)/.exec(f) || ["", "", "", ""]; if (0 == e[0].length && 0 == f[0].length) break; a = ua$1(0 == e[1].length ? 0 : parseInt(e[1], 10), 0 == f[1].length ? 0 : parseInt(f[1], 10)) || ua$1(0 == e[2].length, 0 == f[2].length) || ua$1(e[2], f[2]); e = e[3]; f = f[3]; } while (0 == a); } return 0 <= a; }); } var Sa$1; if (l.document && y) { var Ta$1 = Ma$1(); Sa$1 = Ta$1 ? Ta$1 : parseInt(Na$1, 10) || void 0; } else Sa$1 = void 0; var Ua$1 = Sa$1; var Va$1 = function () { if (!l.addEventListener || !Object.defineProperty) return !1; var a = !1, b = Object.defineProperty({}, "passive", { get: function () { a = !0; } }); try { l.addEventListener("test", aa$1, b), l.removeEventListener("test", aa$1, b); } catch (c) { } return a; }(); function z$1(a, b) { this.type = a; this.g = this.target = b; this.defaultPrevented = !1; } z$1.prototype.h = function () { this.defaultPrevented = !0; }; function A(a, b) { z$1.call(this, a ? a.type : ""); this.relatedTarget = this.g = this.target = null; this.button = this.screenY = this.screenX = this.clientY = this.clientX = 0; this.key = ""; this.metaKey = this.shiftKey = this.altKey = this.ctrlKey = !1; this.state = null; this.pointerId = 0; this.pointerType = ""; this.i = null; if (a) { var c = this.type = a.type, d = a.changedTouches && a.changedTouches.length ? a.changedTouches[0] : null; this.target = a.target || a.srcElement; this.g = b; if (b = a.relatedTarget) { if (Ka$1) { a: { try { Ca$1(b.nodeName); var e = !0; break a; } catch (f) { } e = !1; } e || (b = null); } } else "mouseover" == c ? b = a.fromElement : "mouseout" == c && (b = a.toElement); this.relatedTarget = b; d ? (this.clientX = void 0 !== d.clientX ? d.clientX : d.pageX, this.clientY = void 0 !== d.clientY ? d.clientY : d.pageY, this.screenX = d.screenX || 0, this.screenY = d.screenY || 0) : (this.clientX = void 0 !== a.clientX ? a.clientX : a.pageX, this.clientY = void 0 !== a.clientY ? a.clientY : a.pageY, this.screenX = a.screenX || 0, this.screenY = a.screenY || 0); this.button = a.button; this.key = a.key || ""; this.ctrlKey = a.ctrlKey; this.altKey = a.altKey; this.shiftKey = a.shiftKey; this.metaKey = a.metaKey; this.pointerId = a.pointerId || 0; this.pointerType = "string" === typeof a.pointerType ? a.pointerType : Wa$1[a.pointerType] || ""; this.state = a.state; this.i = a; a.defaultPrevented && A.Z.h.call(this); } } t(A, z$1); var Wa$1 = { 2: "touch", 3: "pen", 4: "mouse" }; A.prototype.h = function () { A.Z.h.call(this); var a = this.i; a.preventDefault ? a.preventDefault() : a.returnValue = !1; }; var B$1 = "closure_listenable_" + (1E6 * Math.random() | 0); var Xa$1 = 0; function Ya$1(a, b, c, d, e) { this.listener = a; this.proxy = null; this.src = b; this.type = c; this.capture = !!d; this.ia = e; this.key = ++Xa$1; this.ca = this.fa = !1; } function Za$1(a) { a.ca = !0; a.listener = null; a.proxy = null; a.src = null; a.ia = null; } function $a$1(a) { this.src = a; this.g = {}; this.h = 0; } $a$1.prototype.add = function (a, b, c, d, e) { var f = a.toString(); a = this.g[f]; a || (a = this.g[f] = [], this.h++); var h = ab(a, b, d, e); -1 < h ? (b = a[h], c || (b.fa = !1)) : (b = new Ya$1(b, this.src, f, !!d, e), b.fa = c, a.push(b)); return b; }; function bb(a, b) { var c = b.type; if (c in a.g) { var d = a.g[c], e = ma$1(d, b), f; (f = 0 <= e) && Array.prototype.splice.call(d, e, 1); f && (Za$1(b), 0 == a.g[c].length && (delete a.g[c], a.h--)); } } function ab(a, b, c, d) { for (var e = 0; e < a.length; ++e) { var f = a[e]; if (!f.ca && f.listener == b && f.capture == !!c && f.ia == d) return e; } return -1; } var cb = "closure_lm_" + (1E6 * Math.random() | 0), db = {}; function fb(a, b, c, d, e) { if (d && d.once) return gb(a, b, c, d, e); if (Array.isArray(b)) { for (var f = 0; f < b.length; f++) fb(a, b[f], c, d, e); return null; } c = hb(c); return a && a[B$1] ? a.N(b, c, p(d) ? !!d.capture : !!d, e) : ib(a, b, c, !1, d, e); } function ib(a, b, c, d, e, f) { if (!b) throw Error("Invalid event type"); var h = p(e) ? !!e.capture : !!e, n = jb(a); n || (a[cb] = n = new $a$1(a)); c = n.add(b, c, d, h, f); if (c.proxy) return c; d = kb(); c.proxy = d; d.src = a; d.listener = c; if (a.addEventListener) Va$1 || (e = h), void 0 === e && (e = !1), a.addEventListener(b.toString(), d, e); else if (a.attachEvent) a.attachEvent(lb(b.toString()), d); else if (a.addListener && a.removeListener) a.addListener(d); else throw Error("addEventListener and attachEvent are unavailable."); return c; } function kb() { function a(c) { return b.call(a.src, a.listener, c); } var b = mb; return a; } function gb(a, b, c, d, e) { if (Array.isArray(b)) { for (var f = 0; f < b.length; f++) gb(a, b[f], c, d, e); return null; } c = hb(c); return a && a[B$1] ? a.O(b, c, p(d) ? !!d.capture : !!d, e) : ib(a, b, c, !0, d, e); } function nb(a, b, c, d, e) { if (Array.isArray(b)) for (var f = 0; f < b.length; f++) nb(a, b[f], c, d, e); else (d = p(d) ? !!d.capture : !!d, c = hb(c), a && a[B$1]) ? (a = a.i, b = String(b).toString(), b in a.g && (f = a.g[b], c = ab(f, c, d, e), -1 < c && (Za$1(f[c]), Array.prototype.splice.call(f, c, 1), 0 == f.length && (delete a.g[b], a.h--)))) : a && (a = jb(a)) && (b = a.g[b.toString()], a = -1, b && (a = ab(b, c, d, e)), (c = -1 < a ? b[a] : null) && ob(c)); } function ob(a) { if ("number" !== typeof a && a && !a.ca) { var b = a.src; if (b && b[B$1]) bb(b.i, a); else { var c = a.type, d = a.proxy; b.removeEventListener ? b.removeEventListener(c, d, a.capture) : b.detachEvent ? b.detachEvent(lb(c), d) : b.addListener && b.removeListener && b.removeListener(d); (c = jb(b)) ? (bb(c, a), 0 == c.h && (c.src = null, b[cb] = null)) : Za$1(a); } } } function lb(a) { return a in db ? db[a] : db[a] = "on" + a; } function mb(a, b) { if (a.ca) a = !0; else { b = new A(b, this); var c = a.listener, d = a.ia || a.src; a.fa && ob(a); a = c.call(d, b); } return a; } function jb(a) { a = a[cb]; return a instanceof $a$1 ? a : null; } var pb = "__closure_events_fn_" + (1E9 * Math.random() >>> 0); function hb(a) { if ("function" === typeof a) return a; a[pb] || (a[pb] = function (b) { return a.handleEvent(b); }); return a[pb]; } function C$1() { v.call(this); this.i = new $a$1(this); this.P = this; this.I = null; } t(C$1, v); C$1.prototype[B$1] = !0; C$1.prototype.removeEventListener = function (a, b, c, d) { nb(this, a, b, c, d); }; function D$1(a, b) { var c, d = a.I; if (d) for (c = []; d; d = d.I) c.push(d); a = a.P; d = b.type || b; if ("string" === typeof b) b = new z$1(b, a); else if (b instanceof z$1) b.target = b.target || a; else { var e = b; b = new z$1(d, a); Aa$1(b, e); } e = !0; if (c) for (var f = c.length - 1; 0 <= f; f--) { var h = b.g = c[f]; e = qb(h, d, !0, b) && e; } h = b.g = a; e = qb(h, d, !0, b) && e; e = qb(h, d, !1, b) && e; if (c) for (f = 0; f < c.length; f++) h = b.g = c[f], e = qb(h, d, !1, b) && e; } C$1.prototype.M = function () { C$1.Z.M.call(this); if (this.i) { var a = this.i, c; for (c in a.g) { for (var d = a.g[c], e = 0; e < d.length; e++) Za$1(d[e]); delete a.g[c]; a.h--; } } this.I = null; }; C$1.prototype.N = function (a, b, c, d) { return this.i.add(String(a), b, !1, c, d); }; C$1.prototype.O = function (a, b, c, d) { return this.i.add(String(a), b, !0, c, d); }; function qb(a, b, c, d) { b = a.i.g[String(b)]; if (!b) return !0; b = b.concat(); for (var e = !0, f = 0; f < b.length; ++f) { var h = b[f]; if (h && !h.ca && h.capture == c) { var n = h.listener, u = h.ia || h.src; h.fa && bb(a.i, h); e = !1 !== n.call(u, d) && e; } } return e && !d.defaultPrevented; } var rb = l.JSON.stringify; function sb() { var a = tb; var b = null; a.g && (b = a.g, a.g = a.g.next, a.g || (a.h = null), b.next = null); return b; } var ub = /** @class */ (function () { function ub() { this.h = this.g = null; } ub.prototype.add = function (a, b) { var c = vb.get(); c.set(a, b); this.h ? this.h.next = c : this.g = c; this.h = c; }; return ub; }()); var vb = new /** @class */ (function () { function class_2(a, b) { this.i = a; this.j = b; this.h = 0; this.g = null; } class_2.prototype.get = function () { var a; 0 < this.h ? (this.h--, a = this.g, this.g = a.next, a.next = null) : a = this.i(); return a; }; return class_2; }())(function () { return new wb; }, function (a) { return a.reset(); }); var wb = /** @class */ (function () { function wb() { this.next = this.g = this.h = null; } wb.prototype.set = function (a, b) { this.h = a; this.g = b; this.next = null; }; wb.prototype.reset = function () { this.next = this.g = this.h = null; }; return wb; }()); function yb(a) { l.setTimeout(function () { throw a; }, 0); } function zb(a, b) { Ab || Bb(); Cb || (Ab(), Cb = !0); tb.add(a, b); } var Ab; function Bb() { var a = l.Promise.resolve(void 0); Ab = function () { a.then(Db); }; } var Cb = !1, tb = new ub; function Db() { for (var a; a = sb();) { try { a.h.call(a.g); } catch (c) { yb(c); } var b = vb; b.j(a); 100 > b.h && (b.h++, a.next = b.g, b.g = a); } Cb = !1; } function Eb(a, b) { C$1.call(this); this.h = a || 1; this.g = b || l; this.j = q$1(this.kb, this); this.l = Date.now(); } t(Eb, C$1); k$1 = Eb.prototype; k$1.da = !1; k$1.S = null; k$1.kb = function () { if (this.da) { var a = Date.now() - this.l; 0 < a && a < .8 * this.h ? this.S = this.g.setTimeout(this.j, this.h - a) : (this.S && (this.g.clearTimeout(this.S), this.S = null), D$1(this, "tick"), this.da && (Fb(this), this.start())); } }; k$1.start = function () { this.da = !0; this.S || (this.S = this.g.setTimeout(this.j, this.h), this.l = Date.now()); }; function Fb(a) { a.da = !1; a.S && (a.g.clearTimeout(a.S), a.S = null); } k$1.M = function () { Eb.Z.M.call(this); Fb(this); delete this.g; }; function Gb(a, b, c) { if ("function" === typeof a) c && (a = q$1(a, c)); else if (a && "function" == typeof a.handleEvent) a = q$1(a.handleEvent, a); else throw Error("Invalid listener argument"); return 2147483647 < Number(b) ? -1 : l.setTimeout(a, b || 0); } function Hb(a) { a.g = Gb(function () { a