prompt-api-polyfill 1.16.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1322 +1,9 @@
1
1
  import { n as e, t } from "../chunks/defaults-B5W7MP9T.js";
2
2
  import { initializeApp as n } from "firebase/app";
3
- import { GoogleAIBackend as r, InferenceMode as i, Schema as a, VertexAIBackend as o, getAI as s, getGenerativeModel as c } from "firebase/ai";
4
- //#region node_modules/@firebase/util/dist/postinstall.mjs
5
- var l = () => void 0, u = function(e) {
6
- let t = [], n = 0;
7
- for (let r = 0; r < e.length; r++) {
8
- let i = e.charCodeAt(r);
9
- i < 128 ? t[n++] = i : i < 2048 ? (t[n++] = i >> 6 | 192, t[n++] = i & 63 | 128) : (i & 64512) == 55296 && r + 1 < e.length && (e.charCodeAt(r + 1) & 64512) == 56320 ? (i = 65536 + ((i & 1023) << 10) + (e.charCodeAt(++r) & 1023), t[n++] = i >> 18 | 240, t[n++] = i >> 12 & 63 | 128, t[n++] = i >> 6 & 63 | 128, t[n++] = i & 63 | 128) : (t[n++] = i >> 12 | 224, t[n++] = i >> 6 & 63 | 128, t[n++] = i & 63 | 128);
10
- }
11
- return t;
12
- }, d = function(e) {
13
- let t = [], n = 0, r = 0;
14
- for (; n < e.length;) {
15
- let i = e[n++];
16
- if (i < 128) t[r++] = String.fromCharCode(i);
17
- else if (i > 191 && i < 224) {
18
- let a = e[n++];
19
- t[r++] = String.fromCharCode((i & 31) << 6 | a & 63);
20
- } else if (i > 239 && i < 365) {
21
- let a = e[n++], o = e[n++], s = e[n++], c = ((i & 7) << 18 | (a & 63) << 12 | (o & 63) << 6 | s & 63) - 65536;
22
- t[r++] = String.fromCharCode(55296 + (c >> 10)), t[r++] = String.fromCharCode(56320 + (c & 1023));
23
- } else {
24
- let a = e[n++], o = e[n++];
25
- t[r++] = String.fromCharCode((i & 15) << 12 | (a & 63) << 6 | o & 63);
26
- }
27
- }
28
- return t.join("");
29
- }, f = {
30
- byteToCharMap_: null,
31
- charToByteMap_: null,
32
- byteToCharMapWebSafe_: null,
33
- charToByteMapWebSafe_: null,
34
- ENCODED_VALS_BASE: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
35
- get ENCODED_VALS() {
36
- return this.ENCODED_VALS_BASE + "+/=";
37
- },
38
- get ENCODED_VALS_WEBSAFE() {
39
- return this.ENCODED_VALS_BASE + "-_.";
40
- },
41
- HAS_NATIVE_SUPPORT: typeof atob == "function",
42
- encodeByteArray(e, t) {
43
- if (!Array.isArray(e)) throw Error("encodeByteArray takes an array as a parameter");
44
- this.init_();
45
- let n = t ? this.byteToCharMapWebSafe_ : this.byteToCharMap_, r = [];
46
- for (let t = 0; t < e.length; t += 3) {
47
- let i = e[t], a = t + 1 < e.length, o = a ? e[t + 1] : 0, s = t + 2 < e.length, c = s ? e[t + 2] : 0, l = i >> 2, u = (i & 3) << 4 | o >> 4, d = (o & 15) << 2 | c >> 6, f = c & 63;
48
- s || (f = 64, a || (d = 64)), r.push(n[l], n[u], n[d], n[f]);
49
- }
50
- return r.join("");
51
- },
52
- encodeString(e, t) {
53
- return this.HAS_NATIVE_SUPPORT && !t ? btoa(e) : this.encodeByteArray(u(e), t);
54
- },
55
- decodeString(e, t) {
56
- return this.HAS_NATIVE_SUPPORT && !t ? atob(e) : d(this.decodeStringToByteArray(e, t));
57
- },
58
- decodeStringToByteArray(e, t) {
59
- this.init_();
60
- let n = t ? this.charToByteMapWebSafe_ : this.charToByteMap_, r = [];
61
- for (let t = 0; t < e.length;) {
62
- let i = n[e.charAt(t++)], a = t < e.length ? n[e.charAt(t)] : 0;
63
- ++t;
64
- let o = t < e.length ? n[e.charAt(t)] : 64;
65
- ++t;
66
- let s = t < e.length ? n[e.charAt(t)] : 64;
67
- if (++t, i == null || a == null || o == null || s == null) throw new ee();
68
- let c = i << 2 | a >> 4;
69
- if (r.push(c), o !== 64) {
70
- let e = a << 4 & 240 | o >> 2;
71
- if (r.push(e), s !== 64) {
72
- let e = o << 6 & 192 | s;
73
- r.push(e);
74
- }
75
- }
76
- }
77
- return r;
78
- },
79
- init_() {
80
- if (!this.byteToCharMap_) {
81
- this.byteToCharMap_ = {}, this.charToByteMap_ = {}, this.byteToCharMapWebSafe_ = {}, this.charToByteMapWebSafe_ = {};
82
- 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);
83
- }
84
- }
85
- }, ee = class extends Error {
86
- constructor() {
87
- super(...arguments), this.name = "DecodeBase64StringError";
88
- }
89
- }, te = function(e) {
90
- let t = u(e);
91
- return f.encodeByteArray(t, !0);
92
- }, ne = function(e) {
93
- return te(e).replace(/\./g, "");
94
- }, re = function(e) {
95
- try {
96
- return f.decodeString(e, !0);
97
- } catch (e) {
98
- console.error("base64Decode failed: ", e);
99
- }
100
- return null;
101
- };
102
- function ie() {
103
- if (typeof self < "u") return self;
104
- if (typeof window < "u") return window;
105
- if (typeof global < "u") return global;
106
- throw Error("Unable to locate global object.");
107
- }
108
- var ae = () => ie().__FIREBASE_DEFAULTS__, oe = () => {
109
- if (typeof process > "u" || process.env === void 0) return;
110
- let e = process.env.__FIREBASE_DEFAULTS__;
111
- if (e) return JSON.parse(e);
112
- }, se = () => {
113
- if (typeof document > "u") return;
114
- let e;
115
- try {
116
- e = document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/);
117
- } catch {
118
- return;
119
- }
120
- let t = e && re(e[1]);
121
- return t && JSON.parse(t);
122
- }, ce = () => {
123
- try {
124
- return l() || ae() || oe() || se();
125
- } catch (e) {
126
- console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`);
127
- return;
128
- }
129
- }, le = () => ce()?.config, p = class {
130
- constructor() {
131
- this.reject = () => {}, this.resolve = () => {}, this.promise = new Promise((e, t) => {
132
- this.resolve = e, this.reject = t;
133
- });
134
- }
135
- wrapCallback(e) {
136
- return (t, n) => {
137
- t ? this.reject(t) : this.resolve(n), typeof e == "function" && (this.promise.catch(() => {}), e.length === 1 ? e(t) : e(t, n));
138
- };
139
- }
140
- };
141
- function m() {
142
- try {
143
- return typeof indexedDB == "object";
144
- } catch {
145
- return !1;
146
- }
147
- }
148
- function ue() {
149
- return new Promise((e, t) => {
150
- try {
151
- let n = !0, r = "validate-browser-context-for-indexeddb-analytics-module", i = self.indexedDB.open(r);
152
- i.onsuccess = () => {
153
- i.result.close(), n || self.indexedDB.deleteDatabase(r), e(!0);
154
- }, i.onupgradeneeded = () => {
155
- n = !1;
156
- }, i.onerror = () => {
157
- t(i.error?.message || "");
158
- };
159
- } catch (e) {
160
- t(e);
161
- }
162
- });
163
- }
164
- var de = "FirebaseError", h = class e extends Error {
165
- constructor(t, n, r) {
166
- super(n), this.code = t, this.customData = r, this.name = de, Object.setPrototypeOf(this, e.prototype), Error.captureStackTrace && Error.captureStackTrace(this, g.prototype.create);
167
- }
168
- }, g = class {
169
- constructor(e, t, n) {
170
- this.service = e, this.serviceName = t, this.errors = n;
171
- }
172
- create(e, ...t) {
173
- let n = t[0] || {}, r = `${this.service}/${e}`, i = this.errors[e], a = i ? fe(i, n) : "Error";
174
- return new h(r, `${this.serviceName}: ${a} (${r}).`, n);
175
- }
176
- };
177
- function fe(e, t) {
178
- return e.replace(pe, (e, n) => {
179
- let r = t[n];
180
- return r == null ? `<${n}?>` : String(r);
181
- });
182
- }
183
- var pe = /\{\$([^}]+)}/g;
184
- function _(e, t) {
185
- if (e === t) return !0;
186
- let n = Object.keys(e), r = Object.keys(t);
187
- for (let i of n) {
188
- if (!r.includes(i)) return !1;
189
- let n = e[i], a = t[i];
190
- if (me(n) && me(a)) {
191
- if (!_(n, a)) return !1;
192
- } else if (n !== a) return !1;
193
- }
194
- for (let e of r) if (!n.includes(e)) return !1;
195
- return !0;
196
- }
197
- function me(e) {
198
- return typeof e == "object" && !!e;
199
- }
200
- var he = 1e3, ge = 2, _e = 14400 * 1e3, ve = .5;
201
- function ye(e, t = he, n = ge) {
202
- let r = t * n ** +e, i = Math.round(ve * r * (Math.random() - .5) * 2);
203
- return Math.min(_e, r + i);
204
- }
205
- function be(e) {
206
- return e && e._delegate ? e._delegate : e;
207
- }
208
- //#endregion
209
- //#region node_modules/@firebase/component/dist/esm/index.esm.js
210
- var v = class {
211
- constructor(e, t, n) {
212
- this.name = e, this.instanceFactory = t, this.type = n, this.multipleInstances = !1, this.serviceProps = {}, this.instantiationMode = "LAZY", this.onInstanceCreated = null;
213
- }
214
- setInstantiationMode(e) {
215
- return this.instantiationMode = e, this;
216
- }
217
- setMultipleInstances(e) {
218
- return this.multipleInstances = e, this;
219
- }
220
- setServiceProps(e) {
221
- return this.serviceProps = e, this;
222
- }
223
- setInstanceCreatedCallback(e) {
224
- return this.onInstanceCreated = e, this;
225
- }
226
- }, y = "[DEFAULT]", xe = class {
227
- constructor(e, t) {
228
- this.name = e, this.container = t, this.component = null, this.instances = /* @__PURE__ */ new Map(), this.instancesDeferred = /* @__PURE__ */ new Map(), this.instancesOptions = /* @__PURE__ */ new Map(), this.onInitCallbacks = /* @__PURE__ */ new Map();
229
- }
230
- get(e) {
231
- let t = this.normalizeInstanceIdentifier(e);
232
- if (!this.instancesDeferred.has(t)) {
233
- let e = new p();
234
- if (this.instancesDeferred.set(t, e), this.isInitialized(t) || this.shouldAutoInitialize()) try {
235
- let n = this.getOrInitializeService({ instanceIdentifier: t });
236
- n && e.resolve(n);
237
- } catch {}
238
- }
239
- return this.instancesDeferred.get(t).promise;
240
- }
241
- getImmediate(e) {
242
- let t = this.normalizeInstanceIdentifier(e?.identifier), n = e?.optional ?? !1;
243
- if (this.isInitialized(t) || this.shouldAutoInitialize()) try {
244
- return this.getOrInitializeService({ instanceIdentifier: t });
245
- } catch (e) {
246
- if (n) return null;
247
- throw e;
248
- }
249
- else if (n) return null;
250
- else throw Error(`Service ${this.name} is not available`);
251
- }
252
- getComponent() {
253
- return this.component;
254
- }
255
- setComponent(e) {
256
- if (e.name !== this.name) throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);
257
- if (this.component) throw Error(`Component for ${this.name} has already been provided`);
258
- if (this.component = e, this.shouldAutoInitialize()) {
259
- if (Ce(e)) try {
260
- this.getOrInitializeService({ instanceIdentifier: y });
261
- } catch {}
262
- for (let [e, t] of this.instancesDeferred.entries()) {
263
- let n = this.normalizeInstanceIdentifier(e);
264
- try {
265
- let e = this.getOrInitializeService({ instanceIdentifier: n });
266
- t.resolve(e);
267
- } catch {}
268
- }
269
- }
270
- }
271
- clearInstance(e = y) {
272
- this.instancesDeferred.delete(e), this.instancesOptions.delete(e), this.instances.delete(e);
273
- }
274
- async delete() {
275
- let e = Array.from(this.instances.values());
276
- await Promise.all([...e.filter((e) => "INTERNAL" in e).map((e) => e.INTERNAL.delete()), ...e.filter((e) => "_delete" in e).map((e) => e._delete())]);
277
- }
278
- isComponentSet() {
279
- return this.component != null;
280
- }
281
- isInitialized(e = y) {
282
- return this.instances.has(e);
283
- }
284
- getOptions(e = y) {
285
- return this.instancesOptions.get(e) || {};
286
- }
287
- initialize(e = {}) {
288
- let { options: t = {} } = e, n = this.normalizeInstanceIdentifier(e.instanceIdentifier);
289
- if (this.isInitialized(n)) throw Error(`${this.name}(${n}) has already been initialized`);
290
- if (!this.isComponentSet()) throw Error(`Component ${this.name} has not been registered yet`);
291
- let r = this.getOrInitializeService({
292
- instanceIdentifier: n,
293
- options: t
294
- });
295
- for (let [e, t] of this.instancesDeferred.entries()) n === this.normalizeInstanceIdentifier(e) && t.resolve(r);
296
- return r;
297
- }
298
- onInit(e, t) {
299
- let n = this.normalizeInstanceIdentifier(t), r = this.onInitCallbacks.get(n) ?? /* @__PURE__ */ new Set();
300
- r.add(e), this.onInitCallbacks.set(n, r);
301
- let i = this.instances.get(n);
302
- return i && e(i, n), () => {
303
- r.delete(e);
304
- };
305
- }
306
- invokeOnInitCallbacks(e, t) {
307
- let n = this.onInitCallbacks.get(t);
308
- if (n) for (let r of n) try {
309
- r(e, t);
310
- } catch {}
311
- }
312
- getOrInitializeService({ instanceIdentifier: e, options: t = {} }) {
313
- let n = this.instances.get(e);
314
- if (!n && this.component && (n = this.component.instanceFactory(this.container, {
315
- instanceIdentifier: Se(e),
316
- options: t
317
- }), this.instances.set(e, n), this.instancesOptions.set(e, t), this.invokeOnInitCallbacks(n, e), this.component.onInstanceCreated)) try {
318
- this.component.onInstanceCreated(this.container, e, n);
319
- } catch {}
320
- return n || null;
321
- }
322
- normalizeInstanceIdentifier(e = y) {
323
- return this.component ? this.component.multipleInstances ? e : y : e;
324
- }
325
- shouldAutoInitialize() {
326
- return !!this.component && this.component.instantiationMode !== "EXPLICIT";
327
- }
328
- };
329
- function Se(e) {
330
- return e === y ? void 0 : e;
331
- }
332
- function Ce(e) {
333
- return e.instantiationMode === "EAGER";
334
- }
335
- var we = class {
336
- constructor(e) {
337
- this.name = e, this.providers = /* @__PURE__ */ new Map();
338
- }
339
- addComponent(e) {
340
- let t = this.getProvider(e.name);
341
- if (t.isComponentSet()) throw Error(`Component ${e.name} has already been registered with ${this.name}`);
342
- t.setComponent(e);
343
- }
344
- addOrOverwriteComponent(e) {
345
- this.getProvider(e.name).isComponentSet() && this.providers.delete(e.name), this.addComponent(e);
346
- }
347
- getProvider(e) {
348
- if (this.providers.has(e)) return this.providers.get(e);
349
- let t = new xe(e, this);
350
- return this.providers.set(e, t), t;
351
- }
352
- getProviders() {
353
- return Array.from(this.providers.values());
354
- }
355
- }, Te = [], b;
356
- (function(e) {
357
- 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";
358
- })(b ||= {});
359
- var Ee = {
360
- debug: b.DEBUG,
361
- verbose: b.VERBOSE,
362
- info: b.INFO,
363
- warn: b.WARN,
364
- error: b.ERROR,
365
- silent: b.SILENT
366
- }, De = b.INFO, Oe = {
367
- [b.DEBUG]: "log",
368
- [b.VERBOSE]: "log",
369
- [b.INFO]: "info",
370
- [b.WARN]: "warn",
371
- [b.ERROR]: "error"
372
- }, ke = (e, t, ...n) => {
373
- if (t < e.logLevel) return;
374
- let r = (/* @__PURE__ */ new Date()).toISOString(), i = Oe[t];
375
- if (i) console[i](`[${r}] ${e.name}:`, ...n);
376
- else throw Error(`Attempted to log a message with an invalid logType (value: ${t})`);
377
- }, Ae = class {
378
- constructor(e) {
379
- this.name = e, this._logLevel = De, this._logHandler = ke, this._userLogHandler = null, Te.push(this);
380
- }
381
- get logLevel() {
382
- return this._logLevel;
383
- }
384
- set logLevel(e) {
385
- if (!(e in b)) throw TypeError(`Invalid value "${e}" assigned to \`logLevel\``);
386
- this._logLevel = e;
387
- }
388
- setLogLevel(e) {
389
- this._logLevel = typeof e == "string" ? Ee[e] : e;
390
- }
391
- get logHandler() {
392
- return this._logHandler;
393
- }
394
- set logHandler(e) {
395
- if (typeof e != "function") throw TypeError("Value assigned to `logHandler` must be a function");
396
- this._logHandler = e;
397
- }
398
- get userLogHandler() {
399
- return this._userLogHandler;
400
- }
401
- set userLogHandler(e) {
402
- this._userLogHandler = e;
403
- }
404
- debug(...e) {
405
- this._userLogHandler && this._userLogHandler(this, b.DEBUG, ...e), this._logHandler(this, b.DEBUG, ...e);
406
- }
407
- log(...e) {
408
- this._userLogHandler && this._userLogHandler(this, b.VERBOSE, ...e), this._logHandler(this, b.VERBOSE, ...e);
409
- }
410
- info(...e) {
411
- this._userLogHandler && this._userLogHandler(this, b.INFO, ...e), this._logHandler(this, b.INFO, ...e);
412
- }
413
- warn(...e) {
414
- this._userLogHandler && this._userLogHandler(this, b.WARN, ...e), this._logHandler(this, b.WARN, ...e);
415
- }
416
- error(...e) {
417
- this._userLogHandler && this._userLogHandler(this, b.ERROR, ...e), this._logHandler(this, b.ERROR, ...e);
418
- }
419
- }, je = (e, t) => t.some((t) => e instanceof t), Me, Ne;
420
- function Pe() {
421
- return Me ||= [
422
- IDBDatabase,
423
- IDBObjectStore,
424
- IDBIndex,
425
- IDBCursor,
426
- IDBTransaction
427
- ];
428
- }
429
- function Fe() {
430
- return Ne ||= [
431
- IDBCursor.prototype.advance,
432
- IDBCursor.prototype.continue,
433
- IDBCursor.prototype.continuePrimaryKey
434
- ];
435
- }
436
- var Ie = /* @__PURE__ */ new WeakMap(), x = /* @__PURE__ */ new WeakMap(), Le = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new WeakMap();
437
- function Re(e) {
438
- let t = new Promise((t, n) => {
439
- let r = () => {
440
- e.removeEventListener("success", i), e.removeEventListener("error", a);
441
- }, i = () => {
442
- t(T(e.result)), r();
443
- }, a = () => {
444
- n(e.error), r();
445
- };
446
- e.addEventListener("success", i), e.addEventListener("error", a);
447
- });
448
- return t.then((t) => {
449
- t instanceof IDBCursor && Ie.set(t, e);
450
- }).catch(() => {}), C.set(t, e), t;
451
- }
452
- function ze(e) {
453
- if (x.has(e)) return;
454
- let t = new Promise((t, n) => {
455
- let r = () => {
456
- e.removeEventListener("complete", i), e.removeEventListener("error", a), e.removeEventListener("abort", a);
457
- }, i = () => {
458
- t(), r();
459
- }, a = () => {
460
- n(e.error || new DOMException("AbortError", "AbortError")), r();
461
- };
462
- e.addEventListener("complete", i), e.addEventListener("error", a), e.addEventListener("abort", a);
463
- });
464
- x.set(e, t);
465
- }
466
- var w = {
467
- get(e, t, n) {
468
- if (e instanceof IDBTransaction) {
469
- if (t === "done") return x.get(e);
470
- if (t === "objectStoreNames") return e.objectStoreNames || Le.get(e);
471
- if (t === "store") return n.objectStoreNames[1] ? void 0 : n.objectStore(n.objectStoreNames[0]);
472
- }
473
- return T(e[t]);
474
- },
475
- set(e, t, n) {
476
- return e[t] = n, !0;
477
- },
478
- has(e, t) {
479
- return e instanceof IDBTransaction && (t === "done" || t === "store") ? !0 : t in e;
480
- }
481
- };
482
- function Be(e) {
483
- w = e(w);
484
- }
485
- function Ve(e) {
486
- return e === IDBDatabase.prototype.transaction && !("objectStoreNames" in IDBTransaction.prototype) ? function(t, ...n) {
487
- let r = e.call(E(this), t, ...n);
488
- return Le.set(r, t.sort ? t.sort() : [t]), T(r);
489
- } : Fe().includes(e) ? function(...t) {
490
- return e.apply(E(this), t), T(Ie.get(this));
491
- } : function(...t) {
492
- return T(e.apply(E(this), t));
493
- };
494
- }
495
- function He(e) {
496
- return typeof e == "function" ? Ve(e) : (e instanceof IDBTransaction && ze(e), je(e, Pe()) ? new Proxy(e, w) : e);
497
- }
498
- function T(e) {
499
- if (e instanceof IDBRequest) return Re(e);
500
- if (S.has(e)) return S.get(e);
501
- let t = He(e);
502
- return t !== e && (S.set(e, t), C.set(t, e)), t;
503
- }
504
- var E = (e) => C.get(e);
505
- //#endregion
506
- //#region node_modules/idb/build/index.js
507
- function Ue(e, t, { blocked: n, upgrade: r, blocking: i, terminated: a } = {}) {
508
- let o = indexedDB.open(e, t), s = T(o);
509
- return r && o.addEventListener("upgradeneeded", (e) => {
510
- r(T(o.result), e.oldVersion, e.newVersion, T(o.transaction), e);
511
- }), n && o.addEventListener("blocked", (e) => n(e.oldVersion, e.newVersion, e)), s.then((e) => {
512
- a && e.addEventListener("close", () => a()), i && e.addEventListener("versionchange", (e) => i(e.oldVersion, e.newVersion, e));
513
- }).catch(() => {}), s;
514
- }
515
- var We = [
516
- "get",
517
- "getKey",
518
- "getAll",
519
- "getAllKeys",
520
- "count"
521
- ], Ge = [
522
- "put",
523
- "add",
524
- "delete",
525
- "clear"
526
- ], D = /* @__PURE__ */ new Map();
527
- function Ke(e, t) {
528
- if (!(e instanceof IDBDatabase && !(t in e) && typeof t == "string")) return;
529
- if (D.get(t)) return D.get(t);
530
- let n = t.replace(/FromIndex$/, ""), r = t !== n, i = Ge.includes(n);
531
- if (!(n in (r ? IDBIndex : IDBObjectStore).prototype) || !(i || We.includes(n))) return;
532
- let a = async function(e, ...t) {
533
- let a = this.transaction(e, i ? "readwrite" : "readonly"), o = a.store;
534
- return r && (o = o.index(t.shift())), (await Promise.all([o[n](...t), i && a.done]))[0];
535
- };
536
- return D.set(t, a), a;
537
- }
538
- Be((e) => ({
539
- ...e,
540
- get: (t, n, r) => Ke(t, n) || e.get(t, n, r),
541
- has: (t, n) => !!Ke(t, n) || e.has(t, n)
542
- }));
543
- //#endregion
544
- //#region node_modules/@firebase/app/dist/esm/index.esm.js
545
- var qe = class {
546
- constructor(e) {
547
- this.container = e;
548
- }
549
- getPlatformInfoString() {
550
- return this.container.getProviders().map((e) => {
551
- if (Je(e)) {
552
- let t = e.getImmediate();
553
- return `${t.library}/${t.version}`;
554
- } else return null;
555
- }).filter((e) => e).join(" ");
556
- }
557
- };
558
- function Je(e) {
559
- return e.getComponent()?.type === "VERSION";
560
- }
561
- var O = "@firebase/app", Ye = "0.14.11", k = new Ae("@firebase/app"), Xe = "@firebase/app-compat", Ze = "@firebase/analytics-compat", Qe = "@firebase/analytics", $e = "@firebase/app-check-compat", et = "@firebase/app-check", tt = "@firebase/auth", nt = "@firebase/auth-compat", rt = "@firebase/database", it = "@firebase/data-connect", at = "@firebase/database-compat", ot = "@firebase/functions", st = "@firebase/functions-compat", ct = "@firebase/installations", lt = "@firebase/installations-compat", ut = "@firebase/messaging", dt = "@firebase/messaging-compat", ft = "@firebase/performance", pt = "@firebase/performance-compat", mt = "@firebase/remote-config", ht = "@firebase/remote-config-compat", gt = "@firebase/storage", _t = "@firebase/storage-compat", vt = "@firebase/firestore", yt = "@firebase/ai", bt = "@firebase/firestore-compat", xt = "firebase", St = "[DEFAULT]", Ct = {
562
- [O]: "fire-core",
563
- [Xe]: "fire-core-compat",
564
- [Qe]: "fire-analytics",
565
- [Ze]: "fire-analytics-compat",
566
- [et]: "fire-app-check",
567
- [$e]: "fire-app-check-compat",
568
- [tt]: "fire-auth",
569
- [nt]: "fire-auth-compat",
570
- [rt]: "fire-rtdb",
571
- [it]: "fire-data-connect",
572
- [at]: "fire-rtdb-compat",
573
- [ot]: "fire-fn",
574
- [st]: "fire-fn-compat",
575
- [ct]: "fire-iid",
576
- [lt]: "fire-iid-compat",
577
- [ut]: "fire-fcm",
578
- [dt]: "fire-fcm-compat",
579
- [ft]: "fire-perf",
580
- [pt]: "fire-perf-compat",
581
- [mt]: "fire-rc",
582
- [ht]: "fire-rc-compat",
583
- [gt]: "fire-gcs",
584
- [_t]: "fire-gcs-compat",
585
- [vt]: "fire-fst",
586
- [bt]: "fire-fst-compat",
587
- [yt]: "fire-vertex",
588
- "fire-js": "fire-js",
589
- [xt]: "fire-js-all"
590
- }, A = /* @__PURE__ */ new Map(), wt = /* @__PURE__ */ new Map(), j = /* @__PURE__ */ new Map();
591
- function Tt(e, t) {
592
- try {
593
- e.container.addComponent(t);
594
- } catch (n) {
595
- k.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`, n);
596
- }
597
- }
598
- function M(e) {
599
- let t = e.name;
600
- if (j.has(t)) return k.debug(`There were multiple attempts to register component ${t}.`), !1;
601
- j.set(t, e);
602
- for (let t of A.values()) Tt(t, e);
603
- for (let t of wt.values()) Tt(t, e);
604
- return !0;
605
- }
606
- function Et(e, t) {
607
- let n = e.container.getProvider("heartbeat").getImmediate({ optional: !0 });
608
- return n && n.triggerHeartbeat(), e.container.getProvider(t);
609
- }
610
- var N = new g("app", "Firebase", {
611
- "no-app": "No Firebase App '{$appName}' has been created - call initializeApp() first",
612
- "bad-app-name": "Illegal App name: '{$appName}'",
613
- "duplicate-app": "Firebase App named '{$appName}' already exists with different options or config",
614
- "app-deleted": "Firebase App named '{$appName}' already deleted",
615
- "server-app-deleted": "Firebase Server App has been deleted",
616
- "no-options": "Need to provide options, when not being deployed to hosting via source.",
617
- "invalid-app-argument": "firebase.{$appName}() takes either no argument or a Firebase App instance.",
618
- "invalid-log-argument": "First argument to `onLog` must be null or a function.",
619
- "idb-open": "Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.",
620
- "idb-get": "Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.",
621
- "idb-set": "Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.",
622
- "idb-delete": "Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.",
623
- "finalization-registry-not-supported": "FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.",
624
- "invalid-server-app-environment": "FirebaseServerApp is not for use in browser environments."
625
- }), Dt = class {
626
- constructor(e, t, n) {
627
- this._isDeleted = !1, this._options = { ...e }, this._config = { ...t }, this._name = t.name, this._automaticDataCollectionEnabled = t.automaticDataCollectionEnabled, this._container = n, this.container.addComponent(new v("app", () => this, "PUBLIC"));
628
- }
629
- get automaticDataCollectionEnabled() {
630
- return this.checkDestroyed(), this._automaticDataCollectionEnabled;
631
- }
632
- set automaticDataCollectionEnabled(e) {
633
- this.checkDestroyed(), this._automaticDataCollectionEnabled = e;
634
- }
635
- get name() {
636
- return this.checkDestroyed(), this._name;
637
- }
638
- get options() {
639
- return this.checkDestroyed(), this._options;
640
- }
641
- get config() {
642
- return this.checkDestroyed(), this._config;
643
- }
644
- get container() {
645
- return this._container;
646
- }
647
- get isDeleted() {
648
- return this._isDeleted;
649
- }
650
- set isDeleted(e) {
651
- this._isDeleted = e;
652
- }
653
- checkDestroyed() {
654
- if (this.isDeleted) throw N.create("app-deleted", { appName: this._name });
655
- }
656
- };
657
- function Ot(e, t = {}) {
658
- let n = e;
659
- typeof t != "object" && (t = { name: t });
660
- let r = {
661
- name: St,
662
- automaticDataCollectionEnabled: !0,
663
- ...t
664
- }, i = r.name;
665
- if (typeof i != "string" || !i) throw N.create("bad-app-name", { appName: String(i) });
666
- if (n ||= le(), !n) throw N.create("no-options");
667
- let a = A.get(i);
668
- if (a) {
669
- if (_(n, a.options) && _(r, a.config)) return a;
670
- throw N.create("duplicate-app", { appName: i });
671
- }
672
- let o = new we(i);
673
- for (let e of j.values()) o.addComponent(e);
674
- let s = new Dt(n, r, o);
675
- return A.set(i, s), s;
676
- }
677
- function kt(e = St) {
678
- let t = A.get(e);
679
- if (!t && e === "[DEFAULT]" && le()) return Ot();
680
- if (!t) throw N.create("no-app", { appName: e });
681
- return t;
682
- }
683
- function P(e, t, n) {
684
- let r = Ct[e] ?? e;
685
- n && (r += `-${n}`);
686
- let i = r.match(/\s|\//), a = t.match(/\s|\//);
687
- if (i || a) {
688
- let e = [`Unable to register library "${r}" with version "${t}":`];
689
- i && e.push(`library name "${r}" contains illegal characters (whitespace or "/")`), i && a && e.push("and"), a && e.push(`version name "${t}" contains illegal characters (whitespace or "/")`), k.warn(e.join(" "));
690
- return;
691
- }
692
- M(new v(`${r}-version`, () => ({
693
- library: r,
694
- version: t
695
- }), "VERSION"));
696
- }
697
- var At = "firebase-heartbeat-database", jt = 1, F = "firebase-heartbeat-store", Mt = null;
698
- function Nt() {
699
- return Mt ||= Ue(At, jt, { upgrade: (e, t) => {
700
- switch (t) {
701
- case 0: try {
702
- e.createObjectStore(F);
703
- } catch (e) {
704
- console.warn(e);
705
- }
706
- }
707
- } }).catch((e) => {
708
- throw N.create("idb-open", { originalErrorMessage: e.message });
709
- }), Mt;
710
- }
711
- async function Pt(e) {
712
- try {
713
- let t = (await Nt()).transaction(F), n = await t.objectStore(F).get(It(e));
714
- return await t.done, n;
715
- } catch (e) {
716
- if (e instanceof h) k.warn(e.message);
717
- else {
718
- let t = N.create("idb-get", { originalErrorMessage: e?.message });
719
- k.warn(t.message);
720
- }
721
- }
722
- }
723
- async function Ft(e, t) {
724
- try {
725
- let n = (await Nt()).transaction(F, "readwrite");
726
- await n.objectStore(F).put(t, It(e)), await n.done;
727
- } catch (e) {
728
- if (e instanceof h) k.warn(e.message);
729
- else {
730
- let t = N.create("idb-set", { originalErrorMessage: e?.message });
731
- k.warn(t.message);
732
- }
733
- }
734
- }
735
- function It(e) {
736
- return `${e.name}!${e.options.appId}`;
737
- }
738
- var Lt = 1024, Rt = 30, zt = class {
739
- constructor(e) {
740
- this.container = e, this._heartbeatsCache = null, this._storage = new Ht(this.container.getProvider("app").getImmediate()), this._heartbeatsCachePromise = this._storage.read().then((e) => (this._heartbeatsCache = e, e));
741
- }
742
- async triggerHeartbeat() {
743
- try {
744
- let e = this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(), t = Bt();
745
- if (this._heartbeatsCache?.heartbeats == null && (this._heartbeatsCache = await this._heartbeatsCachePromise, this._heartbeatsCache?.heartbeats == null) || this._heartbeatsCache.lastSentHeartbeatDate === t || this._heartbeatsCache.heartbeats.some((e) => e.date === t)) return;
746
- if (this._heartbeatsCache.heartbeats.push({
747
- date: t,
748
- agent: e
749
- }), this._heartbeatsCache.heartbeats.length > Rt) {
750
- let e = Wt(this._heartbeatsCache.heartbeats);
751
- this._heartbeatsCache.heartbeats.splice(e, 1);
752
- }
753
- return this._storage.overwrite(this._heartbeatsCache);
754
- } catch (e) {
755
- k.warn(e);
756
- }
757
- }
758
- async getHeartbeatsHeader() {
759
- try {
760
- if (this._heartbeatsCache === null && await this._heartbeatsCachePromise, this._heartbeatsCache?.heartbeats == null || this._heartbeatsCache.heartbeats.length === 0) return "";
761
- let e = Bt(), { heartbeatsToSend: t, unsentEntries: n } = Vt(this._heartbeatsCache.heartbeats), r = ne(JSON.stringify({
762
- version: 2,
763
- heartbeats: t
764
- }));
765
- return this._heartbeatsCache.lastSentHeartbeatDate = e, n.length > 0 ? (this._heartbeatsCache.heartbeats = n, await this._storage.overwrite(this._heartbeatsCache)) : (this._heartbeatsCache.heartbeats = [], this._storage.overwrite(this._heartbeatsCache)), r;
766
- } catch (e) {
767
- return k.warn(e), "";
768
- }
769
- }
770
- };
771
- function Bt() {
772
- return (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
773
- }
774
- function Vt(e, t = Lt) {
775
- let n = [], r = e.slice();
776
- for (let i of e) {
777
- let e = n.find((e) => e.agent === i.agent);
778
- if (!e) {
779
- if (n.push({
780
- agent: i.agent,
781
- dates: [i.date]
782
- }), Ut(n) > t) {
783
- n.pop();
784
- break;
785
- }
786
- } else if (e.dates.push(i.date), Ut(n) > t) {
787
- e.dates.pop();
788
- break;
789
- }
790
- r = r.slice(1);
791
- }
792
- return {
793
- heartbeatsToSend: n,
794
- unsentEntries: r
795
- };
796
- }
797
- var Ht = class {
798
- constructor(e) {
799
- this.app = e, this._canUseIndexedDBPromise = this.runIndexedDBEnvironmentCheck();
800
- }
801
- async runIndexedDBEnvironmentCheck() {
802
- return m() ? ue().then(() => !0).catch(() => !1) : !1;
803
- }
804
- async read() {
805
- if (await this._canUseIndexedDBPromise) {
806
- let e = await Pt(this.app);
807
- return e?.heartbeats ? e : { heartbeats: [] };
808
- } else return { heartbeats: [] };
809
- }
810
- async overwrite(e) {
811
- if (await this._canUseIndexedDBPromise) {
812
- let t = await this.read();
813
- return Ft(this.app, {
814
- lastSentHeartbeatDate: e.lastSentHeartbeatDate ?? t.lastSentHeartbeatDate,
815
- heartbeats: e.heartbeats
816
- });
817
- } else return;
818
- }
819
- async add(e) {
820
- if (await this._canUseIndexedDBPromise) {
821
- let t = await this.read();
822
- return Ft(this.app, {
823
- lastSentHeartbeatDate: e.lastSentHeartbeatDate ?? t.lastSentHeartbeatDate,
824
- heartbeats: [...t.heartbeats, ...e.heartbeats]
825
- });
826
- } else return;
827
- }
828
- };
829
- function Ut(e) {
830
- return ne(JSON.stringify({
831
- version: 2,
832
- heartbeats: e
833
- })).length;
834
- }
835
- function Wt(e) {
836
- if (e.length === 0) return -1;
837
- let t = 0, n = e[0].date;
838
- for (let r = 1; r < e.length; r++) e[r].date < n && (n = e[r].date, t = r);
839
- return t;
840
- }
841
- function Gt(e) {
842
- M(new v("platform-logger", (e) => new qe(e), "PRIVATE")), M(new v("heartbeat", (e) => new zt(e), "PRIVATE")), P(O, Ye, e), P(O, Ye, "esm2020"), P("fire-js", "");
843
- }
844
- Gt("");
845
- //#endregion
846
- //#region node_modules/@firebase/app-check/dist/esm/index.esm.js
847
- var I = /* @__PURE__ */ new Map(), Kt = {
848
- activated: !1,
849
- tokenObservers: []
850
- }, qt = {
851
- initialized: !1,
852
- enabled: !1
853
- };
854
- function L(e) {
855
- return I.get(e) || { ...Kt };
856
- }
857
- function Jt(e, t) {
858
- return I.set(e, t), I.get(e);
859
- }
860
- function R() {
861
- return qt;
862
- }
863
- var Yt = "https://content-firebaseappcheck.googleapis.com/v1", Xt = "exchangeRecaptchaEnterpriseToken", Zt = "exchangeDebugToken", Qt = {
864
- OFFSET_DURATION: 300 * 1e3,
865
- RETRIAL_MIN_WAIT: 30 * 1e3,
866
- RETRIAL_MAX_WAIT: 960 * 1e3
867
- }, $t = 1440 * 60 * 1e3, en = class {
868
- constructor(e, t, n, r, i) {
869
- if (this.operation = e, this.retryPolicy = t, this.getWaitDuration = n, this.lowerBound = r, this.upperBound = i, this.pending = null, this.nextErrorWaitInterval = r, r > i) throw Error("Proactive refresh lower bound greater than upper bound!");
870
- }
871
- start() {
872
- this.nextErrorWaitInterval = this.lowerBound, this.process(!0).catch(() => {});
873
- }
874
- stop() {
875
- this.pending &&= (this.pending.reject("cancelled"), null);
876
- }
877
- isRunning() {
878
- return !!this.pending;
879
- }
880
- async process(e) {
881
- this.stop();
882
- try {
883
- this.pending = new p(), this.pending.promise.catch((e) => {}), await tn(this.getNextRun(e)), this.pending.resolve(), await this.pending.promise, this.pending = new p(), this.pending.promise.catch((e) => {}), await this.operation(), this.pending.resolve(), await this.pending.promise, this.process(!0).catch(() => {});
884
- } catch (e) {
885
- this.retryPolicy(e) ? this.process(!1).catch(() => {}) : this.stop();
886
- }
887
- }
888
- getNextRun(e) {
889
- if (e) return this.nextErrorWaitInterval = this.lowerBound, this.getWaitDuration();
890
- {
891
- let e = this.nextErrorWaitInterval;
892
- return this.nextErrorWaitInterval *= 2, this.nextErrorWaitInterval > this.upperBound && (this.nextErrorWaitInterval = this.upperBound), e;
893
- }
894
- }
895
- };
896
- function tn(e) {
897
- return new Promise((t) => {
898
- setTimeout(t, e);
899
- });
900
- }
901
- var z = new g("appCheck", "AppCheck", {
902
- "already-initialized": "You have already called initializeAppCheck() for FirebaseApp {$appName} with different options. To avoid this error, call initializeAppCheck() with the same options as when it was originally called. This will return the already initialized instance.",
903
- "use-before-activation": "App Check is being used before initializeAppCheck() is called for FirebaseApp {$appName}. Call initializeAppCheck() before instantiating other Firebase services.",
904
- "fetch-network-error": "Fetch failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.",
905
- "fetch-parse-error": "Fetch client could not parse response. Original error: {$originalErrorMessage}.",
906
- "fetch-status-error": "Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.",
907
- "storage-open": "Error thrown when opening storage. Original error: {$originalErrorMessage}.",
908
- "storage-get": "Error thrown when reading from storage. Original error: {$originalErrorMessage}.",
909
- "storage-set": "Error thrown when writing to storage. Original error: {$originalErrorMessage}.",
910
- "recaptcha-error": "ReCAPTCHA error.",
911
- "initial-throttle": "{$httpStatus} error. Attempts allowed again after {$time}",
912
- throttled: "Requests throttled due to previous {$httpStatus} error. Attempts allowed again after {$time}"
913
- });
914
- function nn(e = !1) {
915
- return e ? self.grecaptcha?.enterprise : self.grecaptcha;
916
- }
917
- function B(e) {
918
- if (!L(e).activated) throw z.create("use-before-activation", { appName: e.name });
919
- }
920
- function rn(e) {
921
- let t = Math.round(e / 1e3), n = Math.floor(t / (3600 * 24)), r = Math.floor((t - n * 3600 * 24) / 3600), i = Math.floor((t - n * 3600 * 24 - r * 3600) / 60), a = t - n * 3600 * 24 - r * 3600 - i * 60, o = "";
922
- return n && (o += V(n) + "d:"), r && (o += V(r) + "h:"), o += V(i) + "m:" + V(a) + "s", o;
923
- }
924
- function V(e) {
925
- return e === 0 ? "00" : e >= 10 ? e.toString() : "0" + e;
926
- }
927
- async function H({ url: e, body: t }, n) {
928
- let r = { "Content-Type": "application/json" }, i = n.getImmediate({ optional: !0 });
929
- if (i) {
930
- let e = await i.getHeartbeatsHeader();
931
- e && (r["X-Firebase-Client"] = e);
932
- }
933
- let a = {
934
- method: "POST",
935
- body: JSON.stringify(t),
936
- headers: r
937
- }, o;
938
- try {
939
- o = await fetch(e, a);
940
- } catch (e) {
941
- throw z.create("fetch-network-error", { originalErrorMessage: e?.message });
942
- }
943
- if (o.status !== 200) throw z.create("fetch-status-error", { httpStatus: o.status });
944
- let s;
945
- try {
946
- s = await o.json();
947
- } catch (e) {
948
- throw z.create("fetch-parse-error", { originalErrorMessage: e?.message });
949
- }
950
- let c = s.ttl.match(/^([\d.]+)(s)$/);
951
- if (!c || !c[2] || isNaN(Number(c[1]))) throw z.create("fetch-parse-error", { originalErrorMessage: `ttl field (timeToLive) is not in standard Protobuf Duration format: ${s.ttl}` });
952
- let l = Number(c[1]) * 1e3, u = Date.now();
953
- return {
954
- token: s.token,
955
- expireTimeMillis: u + l,
956
- issuedAtTimeMillis: u
957
- };
958
- }
959
- function an(e, t) {
960
- let { projectId: n, appId: r, apiKey: i } = e.options;
961
- return {
962
- url: `${Yt}/projects/${n}/apps/${r}:${Xt}?key=${i}`,
963
- body: { recaptcha_enterprise_token: t }
964
- };
965
- }
966
- function on(e, t) {
967
- let { projectId: n, appId: r, apiKey: i } = e.options;
968
- return {
969
- url: `${Yt}/projects/${n}/apps/${r}:${Zt}?key=${i}`,
970
- body: { debug_token: t }
971
- };
972
- }
973
- var sn = "firebase-app-check-database", cn = 1, U = "firebase-app-check-store", ln = "debug-token", W = null;
974
- function un() {
975
- return W || (W = new Promise((e, t) => {
976
- try {
977
- let n = indexedDB.open(sn, cn);
978
- n.onsuccess = (t) => {
979
- e(t.target.result);
980
- }, n.onerror = (e) => {
981
- t(z.create("storage-open", { originalErrorMessage: e.target.error?.message }));
982
- }, n.onupgradeneeded = (e) => {
983
- let t = e.target.result;
984
- switch (e.oldVersion) {
985
- case 0: t.createObjectStore(U, { keyPath: "compositeKey" });
986
- }
987
- };
988
- } catch (e) {
989
- t(z.create("storage-open", { originalErrorMessage: e?.message }));
990
- }
991
- }), W);
992
- }
993
- function dn(e) {
994
- return gn(_n(e));
995
- }
996
- function fn(e, t) {
997
- return hn(_n(e), t);
998
- }
999
- function pn(e) {
1000
- return hn(ln, e);
1001
- }
1002
- function mn() {
1003
- return gn(ln);
1004
- }
1005
- async function hn(e, t) {
1006
- let n = (await un()).transaction(U, "readwrite"), r = n.objectStore(U).put({
1007
- compositeKey: e,
1008
- value: t
1009
- });
1010
- return new Promise((e, t) => {
1011
- r.onsuccess = (t) => {
1012
- e();
1013
- }, n.onerror = (e) => {
1014
- t(z.create("storage-set", { originalErrorMessage: e.target.error?.message }));
1015
- };
1016
- });
1017
- }
1018
- async function gn(e) {
1019
- let t = (await un()).transaction(U, "readonly"), n = t.objectStore(U).get(e);
1020
- return new Promise((e, r) => {
1021
- n.onsuccess = (t) => {
1022
- let n = t.target.result;
1023
- e(n ? n.value : void 0);
1024
- }, t.onerror = (e) => {
1025
- r(z.create("storage-get", { originalErrorMessage: e.target.error?.message }));
1026
- };
1027
- });
1028
- }
1029
- function _n(e) {
1030
- return `${e.options.appId}-${e.name}`;
1031
- }
1032
- var G = new Ae("@firebase/app-check");
1033
- async function vn(e) {
1034
- if (m()) {
1035
- let t;
1036
- try {
1037
- t = await dn(e);
1038
- } catch (e) {
1039
- G.warn(`Failed to read token from IndexedDB. Error: ${e}`);
1040
- }
1041
- return t;
1042
- }
1043
- }
1044
- function K(e, t) {
1045
- return m() ? fn(e, t).catch((e) => {
1046
- G.warn(`Failed to write token to IndexedDB. Error: ${e}`);
1047
- }) : Promise.resolve();
1048
- }
1049
- async function yn() {
1050
- let e;
1051
- try {
1052
- e = await mn();
1053
- } catch {}
1054
- if (e) return e;
1055
- {
1056
- let e = crypto.randomUUID();
1057
- return pn(e).catch((e) => G.warn(`Failed to persist debug token to IndexedDB. Error: ${e}`)), e;
1058
- }
1059
- }
1060
- function q() {
1061
- return R().enabled;
1062
- }
1063
- async function J() {
1064
- let e = R();
1065
- if (e.enabled && e.token) return e.token.promise;
1066
- throw Error("\n Can't get debug token in production mode.\n ");
1067
- }
1068
- function bn() {
1069
- let e = ie(), t = R();
1070
- if (t.initialized = !0, typeof e.FIREBASE_APPCHECK_DEBUG_TOKEN != "string" && e.FIREBASE_APPCHECK_DEBUG_TOKEN !== !0) return;
1071
- t.enabled = !0;
1072
- let n = new p();
1073
- t.token = n, typeof e.FIREBASE_APPCHECK_DEBUG_TOKEN == "string" ? n.resolve(e.FIREBASE_APPCHECK_DEBUG_TOKEN) : n.resolve(yn());
1074
- }
1075
- var xn = { error: "UNKNOWN_ERROR" };
1076
- function Sn(e) {
1077
- return f.encodeString(JSON.stringify(e), !1);
1078
- }
1079
- async function Y(e, t = !1, n = !1) {
1080
- let r = e.app;
1081
- B(r);
1082
- let i = L(r), a = i.token, o;
1083
- if (a && !X(a) && (i.token = void 0, a = void 0), !a) {
1084
- let e = await i.cachedTokenPromise;
1085
- e && (X(e) ? a = e : await K(r, void 0));
1086
- }
1087
- if (!t && a && X(a)) return { token: a.token };
1088
- let s = !1;
1089
- if (q()) try {
1090
- let t = await J();
1091
- i.exchangeTokenPromise || (i.exchangeTokenPromise = H(on(r, t), e.heartbeatServiceProvider).finally(() => {
1092
- i.exchangeTokenPromise = void 0;
1093
- }), s = !0);
1094
- let n = await i.exchangeTokenPromise;
1095
- return await K(r, n), i.token = n, { token: n.token };
1096
- } catch (e) {
1097
- return e.code === "appCheck/throttled" || e.code === "appCheck/initial-throttle" ? G.warn(e.message) : n && G.error(e), Z(e);
1098
- }
1099
- try {
1100
- i.exchangeTokenPromise || (i.exchangeTokenPromise = i.provider.getToken().finally(() => {
1101
- i.exchangeTokenPromise = void 0;
1102
- }), s = !0), a = await L(r).exchangeTokenPromise;
1103
- } catch (e) {
1104
- e.code === "appCheck/throttled" || e.code === "appCheck/initial-throttle" ? G.warn(e.message) : n && G.error(e), o = e;
1105
- }
1106
- let c;
1107
- return a ? o ? c = X(a) ? {
1108
- token: a.token,
1109
- internalError: o
1110
- } : Z(o) : (c = { token: a.token }, i.token = a, await K(r, a)) : c = Z(o), s && On(r, c), c;
1111
- }
1112
- async function Cn(e) {
1113
- let t = e.app;
1114
- B(t);
1115
- let { provider: n } = L(t);
1116
- if (q()) {
1117
- let { token: n } = await H(on(t, await J()), e.heartbeatServiceProvider);
1118
- return { token: n };
1119
- } else {
1120
- let { token: e } = await n.getToken();
1121
- return { token: e };
1122
- }
1123
- }
1124
- function wn(e, t, n, r) {
1125
- let { app: i } = e, a = L(i), o = {
1126
- next: n,
1127
- error: r,
1128
- type: t
1129
- };
1130
- if (a.tokenObservers = [...a.tokenObservers, o], a.token && X(a.token)) {
1131
- let t = a.token;
1132
- Promise.resolve().then(() => {
1133
- n({ token: t.token }), En(e);
1134
- }).catch(() => {});
1135
- }
1136
- a.cachedTokenPromise.then(() => En(e));
1137
- }
1138
- function Tn(e, t) {
1139
- let n = L(e), r = n.tokenObservers.filter((e) => e.next !== t);
1140
- r.length === 0 && n.tokenRefresher && n.tokenRefresher.isRunning() && n.tokenRefresher.stop(), n.tokenObservers = r;
1141
- }
1142
- function En(e) {
1143
- let { app: t } = e, n = L(t), r = n.tokenRefresher;
1144
- r || (r = Dn(e), n.tokenRefresher = r), !r.isRunning() && n.isTokenAutoRefreshEnabled && r.start();
1145
- }
1146
- function Dn(e) {
1147
- let { app: t } = e;
1148
- return new en(async () => {
1149
- let n = L(t), r;
1150
- if (r = n.token ? await Y(e, !0) : await Y(e), r.error) throw r.error;
1151
- if (r.internalError) throw r.internalError;
1152
- }, () => !0, () => {
1153
- let e = L(t);
1154
- if (e.token) {
1155
- let t = e.token.issuedAtTimeMillis + (e.token.expireTimeMillis - e.token.issuedAtTimeMillis) * .5 + 300 * 1e3, n = e.token.expireTimeMillis - 300 * 1e3;
1156
- return t = Math.min(t, n), Math.max(0, t - Date.now());
1157
- } else return 0;
1158
- }, Qt.RETRIAL_MIN_WAIT, Qt.RETRIAL_MAX_WAIT);
1159
- }
1160
- function On(e, t) {
1161
- let n = L(e).tokenObservers;
1162
- for (let e of n) try {
1163
- e.type === "EXTERNAL" && t.error != null ? e.error(t.error) : e.next(t);
1164
- } catch {}
1165
- }
1166
- function X(e) {
1167
- return e.expireTimeMillis - Date.now() > 0;
1168
- }
1169
- function Z(e) {
1170
- return {
1171
- token: Sn(xn),
1172
- error: e
1173
- };
1174
- }
1175
- var kn = class {
1176
- constructor(e, t) {
1177
- this.app = e, this.heartbeatServiceProvider = t;
1178
- }
1179
- _delete() {
1180
- let { tokenObservers: e } = L(this.app);
1181
- for (let t of e) Tn(this.app, t.next);
1182
- return Promise.resolve();
1183
- }
1184
- };
1185
- function An(e, t) {
1186
- return new kn(e, t);
1187
- }
1188
- function jn(e) {
1189
- return {
1190
- getToken: (t) => Y(e, t),
1191
- getLimitedUseToken: () => Cn(e),
1192
- addTokenListener: (t) => wn(e, "INTERNAL", t),
1193
- removeTokenListener: (t) => Tn(e.app, t)
1194
- };
1195
- }
1196
- var Mn = "@firebase/app-check", Nn = "0.11.2", Pn = "https://www.google.com/recaptcha/enterprise.js";
1197
- function Fn(e, t) {
1198
- let n = new p(), r = L(e);
1199
- r.reCAPTCHAState = { initialized: n };
1200
- let i = In(e), a = nn(!0);
1201
- return a ? Q(e, t, a, i, n) : zn(() => {
1202
- let r = nn(!0);
1203
- if (!r) throw Error("no recaptcha");
1204
- Q(e, t, r, i, n);
1205
- }), n.promise;
1206
- }
1207
- function Q(e, t, n, r, i) {
1208
- n.ready(() => {
1209
- Rn(e, t, n, r), i.resolve(n);
1210
- });
1211
- }
1212
- function In(e) {
1213
- let t = `fire_app_check_${e.name}`, n = document.createElement("div");
1214
- return n.id = t, n.style.display = "none", document.body.appendChild(n), t;
1215
- }
1216
- async function Ln(e) {
1217
- B(e);
1218
- let t = await L(e).reCAPTCHAState.initialized.promise;
1219
- return new Promise((n, r) => {
1220
- let i = L(e).reCAPTCHAState;
1221
- t.ready(() => {
1222
- n(t.execute(i.widgetId, { action: "fire_app_check" }));
1223
- });
1224
- });
1225
- }
1226
- function Rn(e, t, n, r) {
1227
- let i = n.render(r, {
1228
- sitekey: t,
1229
- size: "invisible",
1230
- callback: () => {
1231
- L(e).reCAPTCHAState.succeeded = !0;
1232
- },
1233
- "error-callback": () => {
1234
- L(e).reCAPTCHAState.succeeded = !1;
1235
- }
1236
- }), a = L(e);
1237
- a.reCAPTCHAState = {
1238
- ...a.reCAPTCHAState,
1239
- widgetId: i
1240
- };
1241
- }
1242
- function zn(e) {
1243
- let t = document.createElement("script");
1244
- t.src = Pn, t.onload = e, document.head.appendChild(t);
1245
- }
1246
- var Bn = class e {
1247
- constructor(e) {
1248
- this._siteKey = e, this._throttleData = null;
1249
- }
1250
- async getToken() {
1251
- Hn(this._throttleData);
1252
- let e = await Ln(this._app).catch((e) => {
1253
- throw z.create("recaptcha-error");
1254
- });
1255
- if (!L(this._app).reCAPTCHAState?.succeeded) throw z.create("recaptcha-error");
1256
- let t;
1257
- try {
1258
- t = await H(an(this._app, e), this._heartbeatServiceProvider);
1259
- } catch (e) {
1260
- throw e.code?.includes("fetch-status-error") ? (this._throttleData = Vn(Number(e.customData?.httpStatus), this._throttleData), z.create("initial-throttle", {
1261
- time: rn(this._throttleData.allowRequestsAfter - Date.now()),
1262
- httpStatus: this._throttleData.httpStatus
1263
- })) : e;
1264
- }
1265
- return this._throttleData = null, t;
1266
- }
1267
- initialize(e) {
1268
- this._app = e, this._heartbeatServiceProvider = Et(e, "heartbeat"), Fn(e, this._siteKey).catch(() => {});
1269
- }
1270
- isEqual(t) {
1271
- return t instanceof e ? this._siteKey === t._siteKey : !1;
1272
- }
1273
- };
1274
- function Vn(e, t) {
1275
- if (e === 404 || e === 403) return {
1276
- backoffCount: 1,
1277
- allowRequestsAfter: Date.now() + $t,
1278
- httpStatus: e
1279
- };
1280
- {
1281
- let n = t ? t.backoffCount : 0, r = ye(n, 1e3, 2);
1282
- return {
1283
- backoffCount: n + 1,
1284
- allowRequestsAfter: Date.now() + r,
1285
- httpStatus: e
1286
- };
1287
- }
1288
- }
1289
- function Hn(e) {
1290
- if (e && Date.now() - e.allowRequestsAfter <= 0) throw z.create("throttled", {
1291
- time: rn(e.allowRequestsAfter - Date.now()),
1292
- httpStatus: e.httpStatus
1293
- });
1294
- }
1295
- function Un(e = kt(), t) {
1296
- e = be(e);
1297
- let n = Et(e, "app-check");
1298
- if (R().initialized || bn(), q() && J().then((e) => console.log(`App Check debug token: ${e}. You will need to add it to your app's App Check settings in the Firebase console for it to work.`)), n.isInitialized()) {
1299
- let r = n.getImmediate(), i = n.getOptions();
1300
- if (i.isTokenAutoRefreshEnabled === t.isTokenAutoRefreshEnabled && i.provider.isEqual(t.provider)) return r;
1301
- throw z.create("already-initialized", { appName: e.name });
1302
- }
1303
- let r = n.initialize({ options: t });
1304
- return Wn(e, t.provider, t.isTokenAutoRefreshEnabled), L(e).isTokenAutoRefreshEnabled && wn(r, "INTERNAL", () => {}), r;
1305
- }
1306
- function Wn(e, t, n = !1) {
1307
- let r = Jt(e, { ...Kt });
1308
- r.activated = !0, r.provider = t, r.cachedTokenPromise = vn(e).then((t) => (t && X(t) && (r.token = t, On(e, { token: t.token })), t)), r.isTokenAutoRefreshEnabled = n && e.automaticDataCollectionEnabled, !e.automaticDataCollectionEnabled && n && G.warn("`isTokenAutoRefreshEnabled` is true but `automaticDataCollectionEnabled` was set to false during `initializeApp()`. This blocks automatic token refresh."), r.provider.initialize(e);
1309
- }
1310
- var Gn = "app-check", Kn = "app-check-internal";
1311
- function qn() {
1312
- M(new v(Gn, (e) => An(e.getProvider("app").getImmediate(), e.getProvider("heartbeat")), "PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e, t, n) => {
1313
- e.getProvider(Kn).initialize();
1314
- })), M(new v(Kn, (e) => jn(e.getProvider("app-check").getImmediate()), "PUBLIC").setInstantiationMode("EXPLICIT")), P(Mn, Nn);
1315
- }
1316
- qn();
1317
- //#endregion
3
+ import { ReCaptchaEnterpriseProvider as r, initializeAppCheck as i } from "firebase/app-check";
4
+ import { GoogleAIBackend as a, InferenceMode as o, Schema as s, VertexAIBackend as c, getAI as l, getGenerativeModel as u } from "firebase/ai";
1318
5
  //#region backends/firebase.js
1319
- function $(e) {
6
+ function d(e) {
1320
7
  if (!e) return;
1321
8
  let t = {
1322
9
  description: e.description,
@@ -1324,53 +11,55 @@ function $(e) {
1324
11
  format: e.format
1325
12
  };
1326
13
  switch (Array.isArray(e.type) && e.type.includes("null") && (t.nullable = !0, e.type = e.type.find((e) => e !== "null")), e.type) {
1327
- case "string": return e.enum && Array.isArray(e.enum) ? a.enumString({
14
+ case "string": return e.enum && Array.isArray(e.enum) ? s.enumString({
1328
15
  ...t,
1329
16
  enum: e.enum
1330
- }) : a.string(t);
1331
- case "number": return a.number(t);
1332
- case "integer": return a.integer(t);
1333
- case "boolean": return a.boolean(t);
1334
- case "array": return a.array({
17
+ }) : s.string(t);
18
+ case "number": return s.number(t);
19
+ case "integer": return s.integer(t);
20
+ case "boolean": return s.boolean(t);
21
+ case "array": return s.array({
1335
22
  ...t,
1336
- items: $(e.items)
23
+ items: d(e.items)
1337
24
  });
1338
25
  case "object": {
1339
26
  let n = {}, r = e.properties ? Object.keys(e.properties) : [];
1340
27
  r.forEach((t) => {
1341
- n[t] = $(e.properties[t]);
28
+ n[t] = d(e.properties[t]);
1342
29
  });
1343
- let i = e.required || [], o = r.filter((e) => !i.includes(e));
1344
- return a.object({
30
+ let i = e.required || [], a = r.filter((e) => !i.includes(e));
31
+ return s.object({
1345
32
  ...t,
1346
33
  properties: n,
1347
- optionalProperties: o
34
+ optionalProperties: a
1348
35
  });
1349
36
  }
1350
- default: return console.warn(`Unsupported type: ${e.type}, defaulting to string.`), a.string(t);
37
+ default: return console.warn(`Unsupported type: ${e.type}, defaulting to string.`), s.string(t);
1351
38
  }
1352
39
  }
1353
- var Jn = class extends e {
40
+ var f = class extends e {
1354
41
  #e;
1355
42
  #t;
1356
43
  constructor(e) {
1357
- let { geminiApiProvider: i, modelName: a, useAppCheck: c, reCaptchaSiteKey: l, useLimitedUseAppCheckTokens: u, ...d } = e;
1358
- super(a || t.firebase.modelName);
1359
- let f = n(d);
1360
- c && l && Un(f, {
1361
- provider: new Bn(l),
44
+ let { geminiApiProvider: o, modelName: s, useAppCheck: u, reCaptchaSiteKey: d, useLimitedUseAppCheckTokens: f, ...p } = e;
45
+ super(s || t.firebase.modelName);
46
+ let m = n(p);
47
+ u && d && i(m, {
48
+ provider: new r(d),
1362
49
  isTokenAutoRefreshEnabled: !0
1363
- }), this.#t = s(f, {
1364
- backend: i === "vertex" ? new o() : new r(),
1365
- useLimitedUseAppCheckTokens: u || !0
50
+ });
51
+ let h = o === "vertex" ? new c() : new a();
52
+ this.#t = l(m, {
53
+ backend: h,
54
+ useLimitedUseAppCheckTokens: f || !0
1366
55
  });
1367
56
  }
1368
57
  convertSchema(e) {
1369
- return $(e);
58
+ return d(e);
1370
59
  }
1371
60
  createSession(e, t) {
1372
- return this.#e = c(this.#t, {
1373
- mode: i.ONLY_IN_CLOUD,
61
+ return this.#e = u(this.#t, {
62
+ mode: o.ONLY_IN_CLOUD,
1374
63
  inCloudParams: t
1375
64
  }), this.#e;
1376
65
  }
@@ -1390,4 +79,4 @@ var Jn = class extends e {
1390
79
  }
1391
80
  };
1392
81
  //#endregion
1393
- export { Jn as default };
82
+ export { f as default };