UNPKG

@logback4js/google-analytics

Version:

Google Analytics Appenders for Logback4js.

1,535 lines 74.2 kB
import { JsonAppender as _e } from "@logback4js/core"; class Gr extends _e { constructor(t) { super(), this.eventName = t; } get name() { return `ga@${this.eventName}`; } doAppend(t) { t.level.priority && gtag("event", this.eventName, this.getMessage(t)); } } var d = {}, b, y; function K() { throw new Error("setTimeout has not been defined"); } function z() { throw new Error("clearTimeout has not been defined"); } (function() { try { typeof setTimeout == "function" ? b = setTimeout : b = K; } catch { b = K; } try { typeof clearTimeout == "function" ? y = clearTimeout : y = z; } catch { y = z; } })(); function Se(e) { if (b === setTimeout) return setTimeout(e, 0); if ((b === K || !b) && setTimeout) return b = setTimeout, setTimeout(e, 0); try { return b(e, 0); } catch { try { return b.call(null, e, 0); } catch { return b.call(this, e, 0); } } } function ut(e) { if (y === clearTimeout) return clearTimeout(e); if ((y === z || !y) && clearTimeout) return y = clearTimeout, clearTimeout(e); try { return y(e); } catch { try { return y.call(null, e); } catch { return y.call(this, e); } } } var I = [], O = !1, A, P = -1; function dt() { !O || !A || (O = !1, A.length ? I = A.concat(I) : P = -1, I.length && Ce()); } function Ce() { if (!O) { var e = Se(dt); O = !0; for (var t = I.length; t; ) { for (A = I, I = []; ++P < t; ) A && A[P].run(); P = -1, t = I.length; } A = null, O = !1, ut(e); } } d.nextTick = function(e) { var t = new Array(arguments.length - 1); if (arguments.length > 1) for (var n = 1; n < arguments.length; n++) t[n - 1] = arguments[n]; I.push(new De(e, t)), I.length === 1 && !O && Se(Ce); }; function De(e, t) { this.fun = e, this.array = t; } De.prototype.run = function() { this.fun.apply(null, this.array); }; d.title = "browser"; d.browser = !0; d.env = {}; d.argv = []; d.version = ""; d.versions = {}; function v() { } d.on = v; d.addListener = v; d.once = v; d.off = v; d.removeListener = v; d.removeAllListeners = v; d.emit = v; d.prependListener = v; d.prependOnceListener = v; d.listeners = function(e) { return []; }; d.binding = function(e) { throw new Error("process.binding is not supported"); }; d.cwd = function() { return "/"; }; d.chdir = function(e) { throw new Error("process.chdir is not supported"); }; d.umask = function() { return 0; }; /** * @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. */ const Re = function(e) { const t = []; let n = 0; for (let r = 0; r < e.length; r++) { let a = e.charCodeAt(r); a < 128 ? t[n++] = a : a < 2048 ? (t[n++] = a >> 6 | 192, t[n++] = a & 63 | 128) : (a & 64512) === 55296 && r + 1 < e.length && (e.charCodeAt(r + 1) & 64512) === 56320 ? (a = 65536 + ((a & 1023) << 10) + (e.charCodeAt(++r) & 1023), t[n++] = a >> 18 | 240, t[n++] = a >> 12 & 63 | 128, t[n++] = a >> 6 & 63 | 128, t[n++] = a & 63 | 128) : (t[n++] = a >> 12 | 224, t[n++] = a >> 6 & 63 | 128, t[n++] = a & 63 | 128); } return t; }, ft = function(e) { const t = []; let n = 0, r = 0; for (; n < e.length; ) { const a = e[n++]; if (a < 128) t[r++] = String.fromCharCode(a); else if (a > 191 && a < 224) { const s = e[n++]; t[r++] = String.fromCharCode((a & 31) << 6 | s & 63); } else if (a > 239 && a < 365) { const s = e[n++], i = e[n++], o = e[n++], c = ((a & 7) << 18 | (s & 63) << 12 | (i & 63) << 6 | o & 63) - 65536; t[r++] = String.fromCharCode(55296 + (c >> 10)), t[r++] = String.fromCharCode(56320 + (c & 1023)); } else { const s = e[n++], i = e[n++]; t[r++] = String.fromCharCode((a & 15) << 12 | (s & 63) << 6 | i & 63); } } return t.join(""); }, ht = { /** * 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(e, t) { if (!Array.isArray(e)) throw Error("encodeByteArray takes an array as a parameter"); this.init_(); const n = t ? this.byteToCharMapWebSafe_ : this.byteToCharMap_, r = []; for (let a = 0; a < e.length; a += 3) { const s = e[a], i = a + 1 < e.length, o = i ? e[a + 1] : 0, c = a + 2 < e.length, l = c ? e[a + 2] : 0, f = s >> 2, p = (s & 3) << 4 | o >> 4; let w = (o & 15) << 2 | l >> 6, g = l & 63; c || (g = 64, i || (w = 64)), r.push(n[f], n[p], n[w], n[g]); } return r.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(e, t) { return this.HAS_NATIVE_SUPPORT && !t ? btoa(e) : this.encodeByteArray(Re(e), t); }, /** * 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(e, t) { return this.HAS_NATIVE_SUPPORT && !t ? atob(e) : ft(this.decodeStringToByteArray(e, t)); }, /** * 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(e, t) { this.init_(); const n = t ? this.charToByteMapWebSafe_ : this.charToByteMap_, r = []; for (let a = 0; a < e.length; ) { const s = n[e.charAt(a++)], o = a < e.length ? n[e.charAt(a)] : 0; ++a; const l = a < e.length ? n[e.charAt(a)] : 64; ++a; const p = a < e.length ? n[e.charAt(a)] : 64; if (++a, s == null || o == null || l == null || p == null) throw new pt(); const w = s << 2 | o >> 4; if (r.push(w), l !== 64) { const g = o << 4 & 240 | l >> 2; if (r.push(g), p !== 64) { const lt = l << 6 & 192 | p; r.push(lt); } } } return r; }, /** * 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_ = {}; for (let e = 0; e < this.ENCODED_VALS.length; e++) this.byteToCharMap_[e] = this.ENCODED_VALS.charAt(e), this.charToByteMap_[this.byteToCharMap_[e]] = e, this.byteToCharMapWebSafe_[e] = this.ENCODED_VALS_WEBSAFE.charAt(e), this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]] = e, e >= this.ENCODED_VALS_BASE.length && (this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)] = e, this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)] = e); } } }; class pt extends Error { constructor() { super(...arguments), this.name = "DecodeBase64StringError"; } } const gt = function(e) { const t = Re(e); return ht.encodeByteArray(t, !0); }, Be = function(e) { return gt(e).replace(/\./g, ""); }; function mt() { const e = typeof chrome == "object" ? chrome.runtime : typeof browser == "object" ? browser.runtime : void 0; return typeof e == "object" && e.id !== void 0; } function Me() { try { return typeof indexedDB == "object"; } catch { return !1; } } function Oe() { return new Promise((e, t) => { try { let n = !0; const r = "validate-browser-context-for-indexeddb-analytics-module", a = self.indexedDB.open(r); a.onsuccess = () => { a.result.close(), n || self.indexedDB.deleteDatabase(r), e(!0); }, a.onupgradeneeded = () => { n = !1; }, a.onerror = () => { var s; t(((s = a.error) === null || s === void 0 ? void 0 : s.message) || ""); }; } catch (n) { t(n); } }); } function bt() { return !(typeof navigator > "u" || !navigator.cookieEnabled); } /** * @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. */ const yt = "FirebaseError"; class M extends Error { constructor(t, n, r) { super(n), this.code = t, this.customData = r, this.name = yt, Object.setPrototypeOf(this, M.prototype), Error.captureStackTrace && Error.captureStackTrace(this, L.prototype.create); } } class L { constructor(t, n, r) { this.service = t, this.serviceName = n, this.errors = r; } create(t, ...n) { const r = n[0] || {}, a = `${this.service}/${t}`, s = this.errors[t], i = s ? wt(s, r) : "Error", o = `${this.serviceName}: ${i} (${a}).`; return new M(a, o, r); } } function wt(e, t) { return e.replace(It, (n, r) => { const a = t[r]; return a != null ? String(a) : `<${r}?>`; }); } const It = /\{\$([^}]+)}/g; /** * @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 Tt = 1e3, vt = 2, Et = 14400 * 1e3, At = 0.5; function ie(e, t = Tt, n = vt) { const r = t * Math.pow(n, e), a = Math.round( // A fraction of the backoff value to add/subtract. // Deviation: changes multiplication order to improve readability. At * r * // A random float (rounded to int by Math.round above) in the range [-1, 1]. Determines // if we add or subtract. (Math.random() - 0.5) * 2 ); return Math.min(Et, r + a); } /** * @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 _t(e) { return e && e._delegate ? e._delegate : e; } class C { /** * * @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(t, n, r) { this.name = t, this.instanceFactory = n, this.type = r, this.multipleInstances = !1, this.serviceProps = {}, this.instantiationMode = "LAZY", this.onInstanceCreated = null; } setInstantiationMode(t) { return this.instantiationMode = t, this; } setMultipleInstances(t) { return this.multipleInstances = t, this; } setServiceProps(t) { return this.serviceProps = t, this; } setInstanceCreatedCallback(t) { return this.onInstanceCreated = t, this; } } /** * @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 u; (function(e) { e[e.DEBUG = 0] = "DEBUG", e[e.VERBOSE = 1] = "VERBOSE", e[e.INFO = 2] = "INFO", e[e.WARN = 3] = "WARN", e[e.ERROR = 4] = "ERROR", e[e.SILENT = 5] = "SILENT"; })(u || (u = {})); const St = { debug: u.DEBUG, verbose: u.VERBOSE, info: u.INFO, warn: u.WARN, error: u.ERROR, silent: u.SILENT }, Ct = u.INFO, Dt = { [u.DEBUG]: "log", [u.VERBOSE]: "log", [u.INFO]: "info", [u.WARN]: "warn", [u.ERROR]: "error" }, Rt = (e, t, ...n) => { if (t < e.logLevel) return; const r = (/* @__PURE__ */ new Date()).toISOString(), a = Dt[t]; if (a) console[a](`[${r}] ${e.name}:`, ...n); else throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`); }; class $e { /** * 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(t) { this.name = t, this._logLevel = Ct, this._logHandler = Rt, this._userLogHandler = null; } get logLevel() { return this._logLevel; } set logLevel(t) { if (!(t in u)) throw new TypeError(`Invalid value "${t}" assigned to \`logLevel\``); this._logLevel = t; } // Workaround for setter/getter having to be the same type. setLogLevel(t) { this._logLevel = typeof t == "string" ? St[t] : t; } get logHandler() { return this._logHandler; } set logHandler(t) { if (typeof t != "function") throw new TypeError("Value assigned to `logHandler` must be a function"); this._logHandler = t; } get userLogHandler() { return this._userLogHandler; } set userLogHandler(t) { this._userLogHandler = t; } /** * The functions below are all based on the `console` interface */ debug(...t) { this._userLogHandler && this._userLogHandler(this, u.DEBUG, ...t), this._logHandler(this, u.DEBUG, ...t); } log(...t) { this._userLogHandler && this._userLogHandler(this, u.VERBOSE, ...t), this._logHandler(this, u.VERBOSE, ...t); } info(...t) { this._userLogHandler && this._userLogHandler(this, u.INFO, ...t), this._logHandler(this, u.INFO, ...t); } warn(...t) { this._userLogHandler && this._userLogHandler(this, u.WARN, ...t), this._logHandler(this, u.WARN, ...t); } error(...t) { this._userLogHandler && this._userLogHandler(this, u.ERROR, ...t), this._logHandler(this, u.ERROR, ...t); } } const Bt = (e, t) => t.some((n) => e instanceof n); let oe, ce; function Mt() { return oe || (oe = [ IDBDatabase, IDBObjectStore, IDBIndex, IDBCursor, IDBTransaction ]); } function Ot() { return ce || (ce = [ IDBCursor.prototype.advance, IDBCursor.prototype.continue, IDBCursor.prototype.continuePrimaryKey ]); } const Ne = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new WeakMap(), Pe = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new WeakMap(); function $t(e) { const t = new Promise((n, r) => { const a = () => { e.removeEventListener("success", s), e.removeEventListener("error", i); }, s = () => { n(E(e.result)), a(); }, i = () => { r(e.error), a(); }; e.addEventListener("success", s), e.addEventListener("error", i); }); return t.then((n) => { n instanceof IDBCursor && Ne.set(n, e); }).catch(() => { }), Z.set(t, e), t; } function Nt(e) { if (Y.has(e)) return; const t = new Promise((n, r) => { const a = () => { e.removeEventListener("complete", s), e.removeEventListener("error", i), e.removeEventListener("abort", i); }, s = () => { n(), a(); }, i = () => { r(e.error || new DOMException("AbortError", "AbortError")), a(); }; e.addEventListener("complete", s), e.addEventListener("error", i), e.addEventListener("abort", i); }); Y.set(e, t); } let J = { get(e, t, n) { if (e instanceof IDBTransaction) { if (t === "done") return Y.get(e); if (t === "objectStoreNames") return e.objectStoreNames || Pe.get(e); if (t === "store") return n.objectStoreNames[1] ? void 0 : n.objectStore(n.objectStoreNames[0]); } return E(e[t]); }, set(e, t, n) { return e[t] = n, !0; }, has(e, t) { return e instanceof IDBTransaction && (t === "done" || t === "store") ? !0 : t in e; } }; function Pt(e) { J = e(J); } function xt(e) { return e === IDBDatabase.prototype.transaction && !("objectStoreNames" in IDBTransaction.prototype) ? function(t, ...n) { const r = e.call(j(this), t, ...n); return Pe.set(r, t.sort ? t.sort() : [t]), E(r); } : Ot().includes(e) ? function(...t) { return e.apply(j(this), t), E(Ne.get(this)); } : function(...t) { return E(e.apply(j(this), t)); }; } function Lt(e) { return typeof e == "function" ? xt(e) : (e instanceof IDBTransaction && Nt(e), Bt(e, Mt()) ? new Proxy(e, J) : e); } function E(e) { if (e instanceof IDBRequest) return $t(e); if (H.has(e)) return H.get(e); const t = Lt(e); return t !== e && (H.set(e, t), Z.set(t, e)), t; } const j = (e) => Z.get(e); function xe(e, t, { blocked: n, upgrade: r, blocking: a, terminated: s } = {}) { const i = indexedDB.open(e, t), o = E(i); return r && i.addEventListener("upgradeneeded", (c) => { r(E(i.result), c.oldVersion, c.newVersion, E(i.transaction), c); }), n && i.addEventListener("blocked", (c) => n( // Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405 c.oldVersion, c.newVersion, c )), o.then((c) => { s && c.addEventListener("close", () => s()), a && c.addEventListener("versionchange", (l) => a(l.oldVersion, l.newVersion, l)); }).catch(() => { }), o; } const kt = ["get", "getKey", "getAll", "getAllKeys", "count"], Ft = ["put", "add", "delete", "clear"], V = /* @__PURE__ */ new Map(); function le(e, t) { if (!(e instanceof IDBDatabase && !(t in e) && typeof t == "string")) return; if (V.get(t)) return V.get(t); const n = t.replace(/FromIndex$/, ""), r = t !== n, a = Ft.includes(n); if ( // Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge. !(n in (r ? IDBIndex : IDBObjectStore).prototype) || !(a || kt.includes(n)) ) return; const s = async function(i, ...o) { const c = this.transaction(i, a ? "readwrite" : "readonly"); let l = c.store; return r && (l = l.index(o.shift())), (await Promise.all([ l[n](...o), a && c.done ]))[0]; }; return V.set(t, s), s; } Pt((e) => ({ ...e, get: (t, n, r) => le(t, n) || e.get(t, n, r), has: (t, n) => !!le(t, n) || e.has(t, n) })); /** * @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 Ht { constructor(t) { this.container = t; } // In initial implementation, this will be called by installations on // auth token refresh, and installations will send this string. getPlatformInfoString() { return this.container.getProviders().map((n) => { if (jt(n)) { const r = n.getImmediate(); return `${r.library}/${r.version}`; } else return null; }).filter((n) => n).join(" "); } } function jt(e) { const t = e.getComponent(); return t?.type === "VERSION"; } const X = "@firebase/app", ue = "0.13.2"; /** * @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 T = new $e("@firebase/app"), Vt = "@firebase/app-compat", Ut = "@firebase/analytics-compat", Wt = "@firebase/analytics", qt = "@firebase/app-check-compat", Gt = "@firebase/app-check", Kt = "@firebase/auth", zt = "@firebase/auth-compat", Yt = "@firebase/database", Jt = "@firebase/data-connect", Xt = "@firebase/database-compat", Qt = "@firebase/functions", Zt = "@firebase/functions-compat", en = "@firebase/installations", tn = "@firebase/installations-compat", nn = "@firebase/messaging", rn = "@firebase/messaging-compat", an = "@firebase/performance", sn = "@firebase/performance-compat", on = "@firebase/remote-config", cn = "@firebase/remote-config-compat", ln = "@firebase/storage", un = "@firebase/storage-compat", dn = "@firebase/firestore", fn = "@firebase/ai", hn = "@firebase/firestore-compat", pn = "firebase", gn = { [X]: "fire-core", [Vt]: "fire-core-compat", [Wt]: "fire-analytics", [Ut]: "fire-analytics-compat", [Gt]: "fire-app-check", [qt]: "fire-app-check-compat", [Kt]: "fire-auth", [zt]: "fire-auth-compat", [Yt]: "fire-rtdb", [Jt]: "fire-data-connect", [Xt]: "fire-rtdb-compat", [Qt]: "fire-fn", [Zt]: "fire-fn-compat", [en]: "fire-iid", [tn]: "fire-iid-compat", [nn]: "fire-fcm", [rn]: "fire-fcm-compat", [an]: "fire-perf", [sn]: "fire-perf-compat", [on]: "fire-rc", [cn]: "fire-rc-compat", [ln]: "fire-gcs", [un]: "fire-gcs-compat", [dn]: "fire-fst", [hn]: "fire-fst-compat", [fn]: "fire-vertex", "fire-js": "fire-js", // Platform identifier for JS SDK. [pn]: "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. */ const mn = /* @__PURE__ */ new Map(), bn = /* @__PURE__ */ new Map(), de = /* @__PURE__ */ new Map(); function fe(e, t) { try { e.container.addComponent(t); } catch (n) { T.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`, n); } } function D(e) { const t = e.name; if (de.has(t)) return T.debug(`There were multiple attempts to register component ${t}.`), !1; de.set(t, e); for (const n of mn.values()) fe(n, e); for (const n of bn.values()) fe(n, e); return !0; } function Le(e, t) { const n = e.container.getProvider("heartbeat").getImmediate({ optional: !0 }); return n && n.triggerHeartbeat(), e.container.getProvider(t); } /** * @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 yn = { "no-app": "No Firebase App '{$appName}' has been created - call initializeApp() first", "bad-app-name": "Illegal App name: '{$appName}'", "duplicate-app": "Firebase App named '{$appName}' already exists with different options or config", "app-deleted": "Firebase App named '{$appName}' already deleted", "server-app-deleted": "Firebase Server App has been deleted", "no-options": "Need to provide options, when not being deployed to hosting via source.", "invalid-app-argument": "firebase.{$appName}() takes either no argument or a Firebase App instance.", "invalid-log-argument": "First argument to `onLog` must be null or a function.", "idb-open": "Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.", "idb-get": "Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.", "idb-set": "Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.", "idb-delete": "Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.", "finalization-registry-not-supported": "FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.", "invalid-server-app-environment": "FirebaseServerApp is not for use in browser environments." }, ee = new L("app", "Firebase", yn); function S(e, t, n) { var r; let a = (r = gn[e]) !== null && r !== void 0 ? r : e; n && (a += `-${n}`); const s = a.match(/\s|\//), i = t.match(/\s|\//); if (s || i) { const o = [ `Unable to register library "${a}" with version "${t}":` ]; s && o.push(`library name "${a}" contains illegal characters (whitespace or "/")`), s && i && o.push("and"), i && o.push(`version name "${t}" contains illegal characters (whitespace or "/")`), T.warn(o.join(" ")); return; } D(new C( `${a}-version`, () => ({ library: a, version: t }), "VERSION" /* ComponentType.VERSION */ )); } /** * @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 wn = "firebase-heartbeat-database", In = 1, N = "firebase-heartbeat-store"; let U = null; function ke() { return U || (U = xe(wn, In, { upgrade: (e, t) => { switch (t) { case 0: try { e.createObjectStore(N); } catch (n) { console.warn(n); } } } }).catch((e) => { throw ee.create("idb-open", { originalErrorMessage: e.message }); })), U; } async function Tn(e) { try { const n = (await ke()).transaction(N), r = await n.objectStore(N).get(Fe(e)); return await n.done, r; } catch (t) { if (t instanceof M) T.warn(t.message); else { const n = ee.create("idb-get", { originalErrorMessage: t?.message }); T.warn(n.message); } } } async function he(e, t) { try { const r = (await ke()).transaction(N, "readwrite"); await r.objectStore(N).put(t, Fe(e)), await r.done; } catch (n) { if (n instanceof M) T.warn(n.message); else { const r = ee.create("idb-set", { originalErrorMessage: n?.message }); T.warn(r.message); } } } function Fe(e) { return `${e.name}!${e.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 vn = 1024, En = 30; class An { constructor(t) { this.container = t, this._heartbeatsCache = null; const n = this.container.getProvider("app").getImmediate(); this._storage = new Sn(n), this._heartbeatsCachePromise = this._storage.read().then((r) => (this._heartbeatsCache = r, r)); } /** * 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 t, n; try { const a = this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(), s = pe(); if (((t = this._heartbeatsCache) === null || t === void 0 ? void 0 : t.heartbeats) == null && (this._heartbeatsCache = await this._heartbeatsCachePromise, ((n = this._heartbeatsCache) === null || n === void 0 ? void 0 : n.heartbeats) == null) || this._heartbeatsCache.lastSentHeartbeatDate === s || this._heartbeatsCache.heartbeats.some((i) => i.date === s)) return; if (this._heartbeatsCache.heartbeats.push({ date: s, agent: a }), this._heartbeatsCache.heartbeats.length > En) { const i = Cn(this._heartbeatsCache.heartbeats); this._heartbeatsCache.heartbeats.splice(i, 1); } return this._storage.overwrite(this._heartbeatsCache); } catch (r) { T.warn(r); } } /** * 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 t; try { if (this._heartbeatsCache === null && await this._heartbeatsCachePromise, ((t = this._heartbeatsCache) === null || t === void 0 ? void 0 : t.heartbeats) == null || this._heartbeatsCache.heartbeats.length === 0) return ""; const n = pe(), { heartbeatsToSend: r, unsentEntries: a } = _n(this._heartbeatsCache.heartbeats), s = Be(JSON.stringify({ version: 2, heartbeats: r })); return this._heartbeatsCache.lastSentHeartbeatDate = n, a.length > 0 ? (this._heartbeatsCache.heartbeats = a, await this._storage.overwrite(this._heartbeatsCache)) : (this._heartbeatsCache.heartbeats = [], this._storage.overwrite(this._heartbeatsCache)), s; } catch (n) { return T.warn(n), ""; } } } function pe() { return (/* @__PURE__ */ new Date()).toISOString().substring(0, 10); } function _n(e, t = vn) { const n = []; let r = e.slice(); for (const a of e) { const s = n.find((i) => i.agent === a.agent); if (s) { if (s.dates.push(a.date), ge(n) > t) { s.dates.pop(); break; } } else if (n.push({ agent: a.agent, dates: [a.date] }), ge(n) > t) { n.pop(); break; } r = r.slice(1); } return { heartbeatsToSend: n, unsentEntries: r }; } class Sn { constructor(t) { this.app = t, this._canUseIndexedDBPromise = this.runIndexedDBEnvironmentCheck(); } async runIndexedDBEnvironmentCheck() { return Me() ? Oe().then(() => !0).catch(() => !1) : !1; } /** * Read all heartbeats. */ async read() { if (await this._canUseIndexedDBPromise) { const n = await Tn(this.app); return n?.heartbeats ? n : { heartbeats: [] }; } else return { heartbeats: [] }; } // overwrite the storage with the provided heartbeats async overwrite(t) { var n; if (await this._canUseIndexedDBPromise) { const a = await this.read(); return he(this.app, { lastSentHeartbeatDate: (n = t.lastSentHeartbeatDate) !== null && n !== void 0 ? n : a.lastSentHeartbeatDate, heartbeats: t.heartbeats }); } else return; } // add heartbeats async add(t) { var n; if (await this._canUseIndexedDBPromise) { const a = await this.read(); return he(this.app, { lastSentHeartbeatDate: (n = t.lastSentHeartbeatDate) !== null && n !== void 0 ? n : a.lastSentHeartbeatDate, heartbeats: [ ...a.heartbeats, ...t.heartbeats ] }); } else return; } } function ge(e) { return Be( // heartbeatsCache wrapper properties JSON.stringify({ version: 2, heartbeats: e }) ).length; } function Cn(e) { if (e.length === 0) return -1; let t = 0, n = e[0].date; for (let r = 1; r < e.length; r++) e[r].date < n && (n = e[r].date, t = r); return t; } /** * @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 Dn(e) { D(new C( "platform-logger", (t) => new Ht(t), "PRIVATE" /* ComponentType.PRIVATE */ )), D(new C( "heartbeat", (t) => new An(t), "PRIVATE" /* ComponentType.PRIVATE */ )), S(X, ue, e), S(X, ue, "esm2017"), S("fire-js", ""); } Dn(""); const He = "@firebase/installations", te = "0.6.18"; /** * @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 je = 1e4, Ve = `w:${te}`, Ue = "FIS_v2", Rn = "https://firebaseinstallations.googleapis.com/v1", Bn = 3600 * 1e3, Mn = "installations", On = "Installations"; /** * @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 $n = { "missing-app-config-values": 'Missing App configuration value: "{$valueName}"', "not-registered": "Firebase Installation is not registered.", "installation-not-found": "Firebase Installation not found.", "request-failed": '{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"', "app-offline": "Could not process request. Application offline.", "delete-pending-registration": "Can't delete installation while there is a pending registration request." }, R = new L(Mn, On, $n); function We(e) { return e instanceof M && e.code.includes( "request-failed" /* ErrorCode.REQUEST_FAILED */ ); } /** * @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 qe({ projectId: e }) { return `${Rn}/projects/${e}/installations`; } function Ge(e) { return { token: e.token, requestStatus: 2, expiresIn: Pn(e.expiresIn), creationTime: Date.now() }; } async function Ke(e, t) { const r = (await t.json()).error; return R.create("request-failed", { requestName: e, serverCode: r.code, serverMessage: r.message, serverStatus: r.status }); } function ze({ apiKey: e }) { return new Headers({ "Content-Type": "application/json", Accept: "application/json", "x-goog-api-key": e }); } function Nn(e, { refreshToken: t }) { const n = ze(e); return n.append("Authorization", xn(t)), n; } async function Ye(e) { const t = await e(); return t.status >= 500 && t.status < 600 ? e() : t; } function Pn(e) { return Number(e.replace("s", "000")); } function xn(e) { return `${Ue} ${e}`; } /** * @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. */ async function Ln({ appConfig: e, heartbeatServiceProvider: t }, { fid: n }) { const r = qe(e), a = ze(e), s = t.getImmediate({ optional: !0 }); if (s) { const l = await s.getHeartbeatsHeader(); l && a.append("x-firebase-client", l); } const i = { fid: n, authVersion: Ue, appId: e.appId, sdkVersion: Ve }, o = { method: "POST", headers: a, body: JSON.stringify(i) }, c = await Ye(() => fetch(r, o)); if (c.ok) { const l = await c.json(); return { fid: l.fid || n, registrationStatus: 2, refreshToken: l.refreshToken, authToken: Ge(l.authToken) }; } else throw await Ke("Create Installation", c); } /** * @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 Je(e) { return new Promise((t) => { setTimeout(t, e); }); } /** * @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 kn(e) { return btoa(String.fromCharCode(...e)).replace(/\+/g, "-").replace(/\//g, "_"); } /** * @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 Fn = /^[cdef][\w-]{21}$/, Q = ""; function Hn() { try { const e = new Uint8Array(17); (self.crypto || self.msCrypto).getRandomValues(e), e[0] = 112 + e[0] % 16; const n = jn(e); return Fn.test(n) ? n : Q; } catch { return Q; } } function jn(e) { return kn(e).substr(0, 22); } /** * @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 k(e) { return `${e.appName}!${e.appId}`; } /** * @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 Xe = /* @__PURE__ */ new Map(); function Qe(e, t) { const n = k(e); Ze(n, t), Vn(n, t); } function Ze(e, t) { const n = Xe.get(e); if (n) for (const r of n) r(t); } function Vn(e, t) { const n = Un(); n && n.postMessage({ key: e, fid: t }), Wn(); } let _ = null; function Un() { return !_ && "BroadcastChannel" in self && (_ = new BroadcastChannel("[Firebase] FID Change"), _.onmessage = (e) => { Ze(e.data.key, e.data.fid); }), _; } function Wn() { Xe.size === 0 && _ && (_.close(), _ = null); } /** * @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 qn = "firebase-installations-database", Gn = 1, B = "firebase-installations-store"; let W = null; function ne() { return W || (W = xe(qn, Gn, { upgrade: (e, t) => { switch (t) { case 0: e.createObjectStore(B); } } })), W; } async function x(e, t) { const n = k(e), a = (await ne()).transaction(B, "readwrite"), s = a.objectStore(B), i = await s.get(n); return await s.put(t, n), await a.done, (!i || i.fid !== t.fid) && Qe(e, t.fid), t; } async function et(e) { const t = k(e), r = (await ne()).transaction(B, "readwrite"); await r.objectStore(B).delete(t), await r.done; } async function F(e, t) { const n = k(e), a = (await ne()).transaction(B, "readwrite"), s = a.objectStore(B), i = await s.get(n), o = t(i); return o === void 0 ? await s.delete(n) : await s.put(o, n), await a.done, o && (!i || i.fid !== o.fid) && Qe(e, o.fid), o; } /** * @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. */ async function re(e) { let t; const n = await F(e.appConfig, (r) => { const a = Kn(r), s = zn(e, a); return t = s.registrationPromise, s.installationEntry; }); return n.fid === Q ? { installationEntry: await t } : { installationEntry: n, registrationPromise: t }; } function Kn(e) { const t = e || { fid: Hn(), registrationStatus: 0 /* RequestStatus.NOT_STARTED */ }; return tt(t); } function zn(e, t) { if (t.registrationStatus === 0) { if (!navigator.onLine) { const a = Promise.reject(R.create( "app-offline" /* ErrorCode.APP_OFFLINE */ )); return { installationEntry: t, registrationPromise: a }; } const n = { fid: t.fid, registrationStatus: 1, registrationTime: Date.now() }, r = Yn(e, n); return { installationEntry: n, registrationPromise: r }; } else return t.registrationStatus === 1 ? { installationEntry: t, registrationPromise: Jn(e) } : { installationEntry: t }; } async function Yn(e, t) { try { const n = await Ln(e, t); return x(e.appConfig, n); } catch (n) { throw We(n) && n.customData.serverCode === 409 ? await et(e.appConfig) : await x(e.appConfig, { fid: t.fid, registrationStatus: 0 /* RequestStatus.NOT_STARTED */ }), n; } } async function Jn(e) { let t = await me(e.appConfig); for (; t.registrationStatus === 1; ) await Je(100), t = await me(e.appConfig); if (t.registrationStatus === 0) { const { installationEntry: n, registrationPromise: r } = await re(e); return r || n; } return t; } function me(e) { return F(e, (t) => { if (!t) throw R.create( "installation-not-found" /* ErrorCode.INSTALLATION_NOT_FOUND */ ); return tt(t); }); } function tt(e) { return Xn(e) ? { fid: e.fid, registrationStatus: 0 /* RequestStatus.NOT_STARTED */ } : e; } function Xn(e) { return e.registrationStatus === 1 && e.registrationTime + je < Date.now(); } /** * @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/LICEN