codexui-android 0.1.72

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.
@@ -0,0 +1,376 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */const pe=()=>{};var U={};/**
17
+ * @license
18
+ * Copyright 2017 Google LLC
19
+ *
20
+ * Licensed under the Apache License, Version 2.0 (the "License");
21
+ * you may not use this file except in compliance with the License.
22
+ * You may obtain a copy of the License at
23
+ *
24
+ * http://www.apache.org/licenses/LICENSE-2.0
25
+ *
26
+ * Unless required by applicable law or agreed to in writing, software
27
+ * distributed under the License is distributed on an "AS IS" BASIS,
28
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29
+ * See the License for the specific language governing permissions and
30
+ * limitations under the License.
31
+ */const Q=function(t){const e=[];let n=0;for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);s<128?e[n++]=s:s<2048?(e[n++]=s>>6|192,e[n++]=s&63|128):(s&64512)===55296&&r+1<t.length&&(t.charCodeAt(r+1)&64512)===56320?(s=65536+((s&1023)<<10)+(t.charCodeAt(++r)&1023),e[n++]=s>>18|240,e[n++]=s>>12&63|128,e[n++]=s>>6&63|128,e[n++]=s&63|128):(e[n++]=s>>12|224,e[n++]=s>>6&63|128,e[n++]=s&63|128)}return e},me=function(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n++];if(s<128)e[r++]=String.fromCharCode(s);else if(s>191&&s<224){const i=t[n++];e[r++]=String.fromCharCode((s&31)<<6|i&63)}else if(s>239&&s<365){const i=t[n++],o=t[n++],c=t[n++],a=((s&7)<<18|(i&63)<<12|(o&63)<<6|c&63)-65536;e[r++]=String.fromCharCode(55296+(a>>10)),e[r++]=String.fromCharCode(56320+(a&1023))}else{const i=t[n++],o=t[n++];e[r++]=String.fromCharCode((s&15)<<12|(i&63)<<6|o&63)}}return e.join("")},Z={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(t,e){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let s=0;s<t.length;s+=3){const i=t[s],o=s+1<t.length,c=o?t[s+1]:0,a=s+2<t.length,h=a?t[s+2]:0,b=i>>2,p=(i&3)<<4|c>>4;let y=(c&15)<<2|h>>6,D=h&63;a||(D=64,o||(y=64)),r.push(n[b],n[p],n[y],n[D])}return r.join("")},encodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(Q(t),e)},decodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):me(this.decodeStringToByteArray(t,e))},decodeStringToByteArray(t,e){this.init_();const n=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let s=0;s<t.length;){const i=n[t.charAt(s++)],c=s<t.length?n[t.charAt(s)]:0;++s;const h=s<t.length?n[t.charAt(s)]:64;++s;const p=s<t.length?n[t.charAt(s)]:64;if(++s,i==null||c==null||h==null||p==null)throw new ge;const y=i<<2|c>>4;if(r.push(y),h!==64){const D=c<<4&240|h>>2;if(r.push(D),p!==64){const ue=h<<6&192|p;r.push(ue)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let t=0;t<this.ENCODED_VALS.length;t++)this.byteToCharMap_[t]=this.ENCODED_VALS.charAt(t),this.charToByteMap_[this.byteToCharMap_[t]]=t,this.byteToCharMapWebSafe_[t]=this.ENCODED_VALS_WEBSAFE.charAt(t),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]]=t,t>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}};class ge extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const be=function(t){const e=Q(t);return Z.encodeByteArray(e,!0)},ee=function(t){return be(t).replace(/\./g,"")},te=function(t){try{return Z.decodeString(t,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};/**
32
+ * @license
33
+ * Copyright 2022 Google LLC
34
+ *
35
+ * Licensed under the Apache License, Version 2.0 (the "License");
36
+ * you may not use this file except in compliance with the License.
37
+ * You may obtain a copy of the License at
38
+ *
39
+ * http://www.apache.org/licenses/LICENSE-2.0
40
+ *
41
+ * Unless required by applicable law or agreed to in writing, software
42
+ * distributed under the License is distributed on an "AS IS" BASIS,
43
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44
+ * See the License for the specific language governing permissions and
45
+ * limitations under the License.
46
+ */function ye(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}/**
47
+ * @license
48
+ * Copyright 2022 Google LLC
49
+ *
50
+ * Licensed under the Apache License, Version 2.0 (the "License");
51
+ * you may not use this file except in compliance with the License.
52
+ * You may obtain a copy of the License at
53
+ *
54
+ * http://www.apache.org/licenses/LICENSE-2.0
55
+ *
56
+ * Unless required by applicable law or agreed to in writing, software
57
+ * distributed under the License is distributed on an "AS IS" BASIS,
58
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
59
+ * See the License for the specific language governing permissions and
60
+ * limitations under the License.
61
+ */const Ee=()=>ye().__FIREBASE_DEFAULTS__,ve=()=>{if(typeof process>"u"||typeof U>"u")return;const t=U.__FIREBASE_DEFAULTS__;if(t)return JSON.parse(t)},_e=()=>{if(typeof document>"u")return;let t;try{t=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=t&&te(t[1]);return e&&JSON.parse(e)},k=()=>{try{return pe()||Ee()||ve()||_e()}catch(t){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${t}`);return}},Vt=t=>{var e,n;return(n=(e=k())==null?void 0:e.emulatorHosts)==null?void 0:n[t]},F=()=>{var t;return(t=k())==null?void 0:t.config},Wt=t=>{var e;return(e=k())==null?void 0:e[`_${t}`]};/**
62
+ * @license
63
+ * Copyright 2017 Google LLC
64
+ *
65
+ * Licensed under the Apache License, Version 2.0 (the "License");
66
+ * you may not use this file except in compliance with the License.
67
+ * You may obtain a copy of the License at
68
+ *
69
+ * http://www.apache.org/licenses/LICENSE-2.0
70
+ *
71
+ * Unless required by applicable law or agreed to in writing, software
72
+ * distributed under the License is distributed on an "AS IS" BASIS,
73
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
74
+ * See the License for the specific language governing permissions and
75
+ * limitations under the License.
76
+ */class Ce{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,n)=>{this.resolve=e,this.reject=n})}wrapCallback(e){return(n,r)=>{n?this.reject(n):this.resolve(r),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(n):e(n,r))}}}/**
77
+ * @license
78
+ * Copyright 2017 Google LLC
79
+ *
80
+ * Licensed under the Apache License, Version 2.0 (the "License");
81
+ * you may not use this file except in compliance with the License.
82
+ * You may obtain a copy of the License at
83
+ *
84
+ * http://www.apache.org/licenses/LICENSE-2.0
85
+ *
86
+ * Unless required by applicable law or agreed to in writing, software
87
+ * distributed under the License is distributed on an "AS IS" BASIS,
88
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
89
+ * See the License for the specific language governing permissions and
90
+ * limitations under the License.
91
+ */function ne(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function jt(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(ne())}function De(){return typeof window<"u"||re()}function re(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}function Gt(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function Jt(){const t=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof t=="object"&&t.id!==void 0}function Kt(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function Yt(){const t=ne();return t.indexOf("MSIE ")>=0||t.indexOf("Trident/")>=0}function we(){try{return typeof indexedDB=="object"}catch{return!1}}function Ie(){return new Promise((t,e)=>{try{let n=!0;const r="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(r);s.onsuccess=()=>{s.result.close(),n||self.indexedDB.deleteDatabase(r),t(!0)},s.onupgradeneeded=()=>{n=!1},s.onerror=()=>{var i;e(((i=s.error)==null?void 0:i.message)||"")}}catch(n){e(n)}})}/**
92
+ * @license
93
+ * Copyright 2017 Google LLC
94
+ *
95
+ * Licensed under the Apache License, Version 2.0 (the "License");
96
+ * you may not use this file except in compliance with the License.
97
+ * You may obtain a copy of the License at
98
+ *
99
+ * http://www.apache.org/licenses/LICENSE-2.0
100
+ *
101
+ * Unless required by applicable law or agreed to in writing, software
102
+ * distributed under the License is distributed on an "AS IS" BASIS,
103
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
104
+ * See the License for the specific language governing permissions and
105
+ * limitations under the License.
106
+ */const Se="FirebaseError";class C extends Error{constructor(e,n,r){super(n),this.code=e,this.customData=r,this.name=Se,Object.setPrototypeOf(this,C.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,se.prototype.create)}}class se{constructor(e,n,r){this.service=e,this.serviceName=n,this.errors=r}create(e,...n){const r=n[0]||{},s=`${this.service}/${e}`,i=this.errors[e],o=i?Ae(i,r):"Error",c=`${this.serviceName}: ${o} (${s}).`;return new C(s,c,r)}}function Ae(t,e){return t.replace(Oe,(n,r)=>{const s=e[r];return s!=null?String(s):`<${r}?>`})}const Oe=/\{\$([^}]+)}/g;function qt(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function N(t,e){if(t===e)return!0;const n=Object.keys(t),r=Object.keys(e);for(const s of n){if(!r.includes(s))return!1;const i=t[s],o=e[s];if(V(i)&&V(o)){if(!N(i,o))return!1}else if(i!==o)return!1}for(const s of r)if(!n.includes(s))return!1;return!0}function V(t){return t!==null&&typeof t=="object"}/**
107
+ * @license
108
+ * Copyright 2017 Google LLC
109
+ *
110
+ * Licensed under the Apache License, Version 2.0 (the "License");
111
+ * you may not use this file except in compliance with the License.
112
+ * You may obtain a copy of the License at
113
+ *
114
+ * http://www.apache.org/licenses/LICENSE-2.0
115
+ *
116
+ * Unless required by applicable law or agreed to in writing, software
117
+ * distributed under the License is distributed on an "AS IS" BASIS,
118
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
119
+ * See the License for the specific language governing permissions and
120
+ * limitations under the License.
121
+ */function Xt(t){const e=[];for(const[n,r]of Object.entries(t))Array.isArray(r)?r.forEach(s=>{e.push(encodeURIComponent(n)+"="+encodeURIComponent(s))}):e.push(encodeURIComponent(n)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function Qt(t){const e={};return t.replace(/^\?/,"").split("&").forEach(r=>{if(r){const[s,i]=r.split("=");e[decodeURIComponent(s)]=decodeURIComponent(i)}}),e}function Zt(t){const e=t.indexOf("?");if(!e)return"";const n=t.indexOf("#",e);return t.substring(e,n>0?n:void 0)}function en(t,e){const n=new Be(t,e);return n.subscribe.bind(n)}class Be{constructor(e,n){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=n,this.task.then(()=>{e(this)}).catch(r=>{this.error(r)})}next(e){this.forEachObserver(n=>{n.next(e)})}error(e){this.forEachObserver(n=>{n.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,n,r){let s;if(e===void 0&&n===void 0&&r===void 0)throw new Error("Missing Observer.");Te(e,["next","error","complete"])?s=e:s={next:e,error:n,complete:r},s.next===void 0&&(s.next=O),s.error===void 0&&(s.error=O),s.complete===void 0&&(s.complete=O);const i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?s.error(this.finalError):s.complete()}catch{}}),this.observers.push(s),i}unsubscribeOne(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let n=0;n<this.observers.length;n++)this.sendOne(n,e)}sendOne(e,n){this.task.then(()=>{if(this.observers!==void 0&&this.observers[e]!==void 0)try{n(this.observers[e])}catch(r){typeof console<"u"&&console.error&&console.error(r)}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function Te(t,e){if(typeof t!="object"||t===null)return!1;for(const n of e)if(n in t&&typeof t[n]=="function")return!0;return!1}function O(){}/**
122
+ * @license
123
+ * Copyright 2021 Google LLC
124
+ *
125
+ * Licensed under the Apache License, Version 2.0 (the "License");
126
+ * you may not use this file except in compliance with the License.
127
+ * You may obtain a copy of the License at
128
+ *
129
+ * http://www.apache.org/licenses/LICENSE-2.0
130
+ *
131
+ * Unless required by applicable law or agreed to in writing, software
132
+ * distributed under the License is distributed on an "AS IS" BASIS,
133
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
134
+ * See the License for the specific language governing permissions and
135
+ * limitations under the License.
136
+ */function tn(t){return t&&t._delegate?t._delegate:t}/**
137
+ * @license
138
+ * Copyright 2025 Google LLC
139
+ *
140
+ * Licensed under the Apache License, Version 2.0 (the "License");
141
+ * you may not use this file except in compliance with the License.
142
+ * You may obtain a copy of the License at
143
+ *
144
+ * http://www.apache.org/licenses/LICENSE-2.0
145
+ *
146
+ * Unless required by applicable law or agreed to in writing, software
147
+ * distributed under the License is distributed on an "AS IS" BASIS,
148
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
149
+ * See the License for the specific language governing permissions and
150
+ * limitations under the License.
151
+ */function nn(t){try{return(t.startsWith("http://")||t.startsWith("https://")?new URL(t).hostname:t).endsWith(".cloudworkstations.dev")}catch{return!1}}async function rn(t){return(await fetch(t,{credentials:"include"})).ok}class I{constructor(e,n,r){this.name=e,this.instanceFactory=n,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}/**
152
+ * @license
153
+ * Copyright 2019 Google LLC
154
+ *
155
+ * Licensed under the Apache License, Version 2.0 (the "License");
156
+ * you may not use this file except in compliance with the License.
157
+ * You may obtain a copy of the License at
158
+ *
159
+ * http://www.apache.org/licenses/LICENSE-2.0
160
+ *
161
+ * Unless required by applicable law or agreed to in writing, software
162
+ * distributed under the License is distributed on an "AS IS" BASIS,
163
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
164
+ * See the License for the specific language governing permissions and
165
+ * limitations under the License.
166
+ */const m="[DEFAULT]";/**
167
+ * @license
168
+ * Copyright 2019 Google LLC
169
+ *
170
+ * Licensed under the Apache License, Version 2.0 (the "License");
171
+ * you may not use this file except in compliance with the License.
172
+ * You may obtain a copy of the License at
173
+ *
174
+ * http://www.apache.org/licenses/LICENSE-2.0
175
+ *
176
+ * Unless required by applicable law or agreed to in writing, software
177
+ * distributed under the License is distributed on an "AS IS" BASIS,
178
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
179
+ * See the License for the specific language governing permissions and
180
+ * limitations under the License.
181
+ */class Re{constructor(e,n){this.name=e,this.container=n,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const n=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(n)){const r=new Ce;if(this.instancesDeferred.set(n,r),this.isInitialized(n)||this.shouldAutoInitialize())try{const s=this.getOrInitializeService({instanceIdentifier:n});s&&r.resolve(s)}catch{}}return this.instancesDeferred.get(n).promise}getImmediate(e){const n=this.normalizeInstanceIdentifier(e==null?void 0:e.identifier),r=(e==null?void 0:e.optional)??!1;if(this.isInitialized(n)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:n})}catch(s){if(r)return null;throw s}else{if(r)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,!!this.shouldAutoInitialize()){if(Ne(e))try{this.getOrInitializeService({instanceIdentifier:m})}catch{}for(const[n,r]of this.instancesDeferred.entries()){const s=this.normalizeInstanceIdentifier(n);try{const i=this.getOrInitializeService({instanceIdentifier:s});r.resolve(i)}catch{}}}}clearInstance(e=m){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(n=>"INTERNAL"in n).map(n=>n.INTERNAL.delete()),...e.filter(n=>"_delete"in n).map(n=>n._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=m){return this.instances.has(e)}getOptions(e=m){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:n={}}=e,r=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const s=this.getOrInitializeService({instanceIdentifier:r,options:n});for(const[i,o]of this.instancesDeferred.entries()){const c=this.normalizeInstanceIdentifier(i);r===c&&o.resolve(s)}return s}onInit(e,n){const r=this.normalizeInstanceIdentifier(n),s=this.onInitCallbacks.get(r)??new Set;s.add(e),this.onInitCallbacks.set(r,s);const i=this.instances.get(r);return i&&e(i,r),()=>{s.delete(e)}}invokeOnInitCallbacks(e,n){const r=this.onInitCallbacks.get(n);if(r)for(const s of r)try{s(e,n)}catch{}}getOrInitializeService({instanceIdentifier:e,options:n={}}){let r=this.instances.get(e);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:Me(e),options:n}),this.instances.set(e,r),this.instancesOptions.set(e,n),this.invokeOnInitCallbacks(r,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,r)}catch{}return r||null}normalizeInstanceIdentifier(e=m){return this.component?this.component.multipleInstances?e:m:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function Me(t){return t===m?void 0:t}function Ne(t){return t.instantiationMode==="EAGER"}/**
182
+ * @license
183
+ * Copyright 2019 Google LLC
184
+ *
185
+ * Licensed under the Apache License, Version 2.0 (the "License");
186
+ * you may not use this file except in compliance with the License.
187
+ * You may obtain a copy of the License at
188
+ *
189
+ * http://www.apache.org/licenses/LICENSE-2.0
190
+ *
191
+ * Unless required by applicable law or agreed to in writing, software
192
+ * distributed under the License is distributed on an "AS IS" BASIS,
193
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
194
+ * See the License for the specific language governing permissions and
195
+ * limitations under the License.
196
+ */class ie{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const n=this.getProvider(e.name);if(n.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);n.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const n=new Re(e,this);return this.providers.set(e,n),n}getProviders(){return Array.from(this.providers.values())}}/**
197
+ * @license
198
+ * Copyright 2017 Google LLC
199
+ *
200
+ * Licensed under the Apache License, Version 2.0 (the "License");
201
+ * you may not use this file except in compliance with the License.
202
+ * You may obtain a copy of the License at
203
+ *
204
+ * http://www.apache.org/licenses/LICENSE-2.0
205
+ *
206
+ * Unless required by applicable law or agreed to in writing, software
207
+ * distributed under the License is distributed on an "AS IS" BASIS,
208
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
209
+ * See the License for the specific language governing permissions and
210
+ * limitations under the License.
211
+ */const H=[];var l;(function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"})(l||(l={}));const oe={debug:l.DEBUG,verbose:l.VERBOSE,info:l.INFO,warn:l.WARN,error:l.ERROR,silent:l.SILENT},$e=l.INFO,Le={[l.DEBUG]:"log",[l.VERBOSE]:"log",[l.INFO]:"info",[l.WARN]:"warn",[l.ERROR]:"error"},xe=(t,e,...n)=>{if(e<t.logLevel)return;const r=new Date().toISOString(),s=Le[e];if(s)console[s](`[${r}] ${t.name}:`,...n);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class Pe{constructor(e){this.name=e,this._logLevel=$e,this._logHandler=xe,this._userLogHandler=null,H.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in l))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?oe[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,l.DEBUG,...e),this._logHandler(this,l.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,l.VERBOSE,...e),this._logHandler(this,l.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,l.INFO,...e),this._logHandler(this,l.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,l.WARN,...e),this._logHandler(this,l.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,l.ERROR,...e),this._logHandler(this,l.ERROR,...e)}}function ke(t){H.forEach(e=>{e.setLogLevel(t)})}function Fe(t,e){for(const n of H){let r=null;e&&e.level&&(r=oe[e.level]),t===null?n.userLogHandler=null:n.userLogHandler=(s,i,...o)=>{const c=o.map(a=>{if(a==null)return null;if(typeof a=="string")return a;if(typeof a=="number"||typeof a=="boolean")return a.toString();if(a instanceof Error)return a.message;try{return JSON.stringify(a)}catch{return null}}).filter(a=>a).join(" ");i>=(r??s.logLevel)&&t({level:l[i].toLowerCase(),message:c,args:o,type:s.name})}}}const He=(t,e)=>e.some(n=>t instanceof n);let W,j;function ze(){return W||(W=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Ue(){return j||(j=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const ae=new WeakMap,$=new WeakMap,ce=new WeakMap,B=new WeakMap,z=new WeakMap;function Ve(t){const e=new Promise((n,r)=>{const s=()=>{t.removeEventListener("success",i),t.removeEventListener("error",o)},i=()=>{n(u(t.result)),s()},o=()=>{r(t.error),s()};t.addEventListener("success",i),t.addEventListener("error",o)});return e.then(n=>{n instanceof IDBCursor&&ae.set(n,t)}).catch(()=>{}),z.set(e,t),e}function We(t){if($.has(t))return;const e=new Promise((n,r)=>{const s=()=>{t.removeEventListener("complete",i),t.removeEventListener("error",o),t.removeEventListener("abort",o)},i=()=>{n(),s()},o=()=>{r(t.error||new DOMException("AbortError","AbortError")),s()};t.addEventListener("complete",i),t.addEventListener("error",o),t.addEventListener("abort",o)});$.set(t,e)}let L={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return $.get(t);if(e==="objectStoreNames")return t.objectStoreNames||ce.get(t);if(e==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return u(t[e])},set(t,e,n){return t[e]=n,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function je(t){L=t(L)}function Ge(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...n){const r=t.call(T(this),e,...n);return ce.set(r,e.sort?e.sort():[e]),u(r)}:Ue().includes(t)?function(...e){return t.apply(T(this),e),u(ae.get(this))}:function(...e){return u(t.apply(T(this),e))}}function Je(t){return typeof t=="function"?Ge(t):(t instanceof IDBTransaction&&We(t),He(t,ze())?new Proxy(t,L):t)}function u(t){if(t instanceof IDBRequest)return Ve(t);if(B.has(t))return B.get(t);const e=Je(t);return e!==t&&(B.set(t,e),z.set(e,t)),e}const T=t=>z.get(t);function Ke(t,e,{blocked:n,upgrade:r,blocking:s,terminated:i}={}){const o=indexedDB.open(t,e),c=u(o);return r&&o.addEventListener("upgradeneeded",a=>{r(u(o.result),a.oldVersion,a.newVersion,u(o.transaction),a)}),n&&o.addEventListener("blocked",a=>n(a.oldVersion,a.newVersion,a)),c.then(a=>{i&&a.addEventListener("close",()=>i()),s&&a.addEventListener("versionchange",h=>s(h.oldVersion,h.newVersion,h))}).catch(()=>{}),c}const Ye=["get","getKey","getAll","getAllKeys","count"],qe=["put","add","delete","clear"],R=new Map;function G(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(R.get(e))return R.get(e);const n=e.replace(/FromIndex$/,""),r=e!==n,s=qe.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(s||Ye.includes(n)))return;const i=async function(o,...c){const a=this.transaction(o,s?"readwrite":"readonly");let h=a.store;return r&&(h=h.index(c.shift())),(await Promise.all([h[n](...c),s&&a.done]))[0]};return R.set(e,i),i}je(t=>({...t,get:(e,n,r)=>G(e,n)||t.get(e,n,r),has:(e,n)=>!!G(e,n)||t.has(e,n)}));/**
212
+ * @license
213
+ * Copyright 2019 Google LLC
214
+ *
215
+ * Licensed under the Apache License, Version 2.0 (the "License");
216
+ * you may not use this file except in compliance with the License.
217
+ * You may obtain a copy of the License at
218
+ *
219
+ * http://www.apache.org/licenses/LICENSE-2.0
220
+ *
221
+ * Unless required by applicable law or agreed to in writing, software
222
+ * distributed under the License is distributed on an "AS IS" BASIS,
223
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
224
+ * See the License for the specific language governing permissions and
225
+ * limitations under the License.
226
+ */class Xe{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(n=>{if(Qe(n)){const r=n.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(n=>n).join(" ")}}function Qe(t){const e=t.getComponent();return(e==null?void 0:e.type)==="VERSION"}const S="@firebase/app",x="0.14.10";/**
227
+ * @license
228
+ * Copyright 2019 Google LLC
229
+ *
230
+ * Licensed under the Apache License, Version 2.0 (the "License");
231
+ * you may not use this file except in compliance with the License.
232
+ * You may obtain a copy of the License at
233
+ *
234
+ * http://www.apache.org/licenses/LICENSE-2.0
235
+ *
236
+ * Unless required by applicable law or agreed to in writing, software
237
+ * distributed under the License is distributed on an "AS IS" BASIS,
238
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
239
+ * See the License for the specific language governing permissions and
240
+ * limitations under the License.
241
+ */const d=new Pe("@firebase/app"),Ze="@firebase/app-compat",et="@firebase/analytics-compat",tt="@firebase/analytics",nt="@firebase/app-check-compat",rt="@firebase/app-check",st="@firebase/auth",it="@firebase/auth-compat",ot="@firebase/database",at="@firebase/data-connect",ct="@firebase/database-compat",lt="@firebase/functions",ht="@firebase/functions-compat",ft="@firebase/installations",dt="@firebase/installations-compat",ut="@firebase/messaging",pt="@firebase/messaging-compat",mt="@firebase/performance",gt="@firebase/performance-compat",bt="@firebase/remote-config",yt="@firebase/remote-config-compat",Et="@firebase/storage",vt="@firebase/storage-compat",_t="@firebase/firestore",Ct="@firebase/ai",Dt="@firebase/firestore-compat",wt="firebase",It="12.11.0";/**
242
+ * @license
243
+ * Copyright 2019 Google LLC
244
+ *
245
+ * Licensed under the Apache License, Version 2.0 (the "License");
246
+ * you may not use this file except in compliance with the License.
247
+ * You may obtain a copy of the License at
248
+ *
249
+ * http://www.apache.org/licenses/LICENSE-2.0
250
+ *
251
+ * Unless required by applicable law or agreed to in writing, software
252
+ * distributed under the License is distributed on an "AS IS" BASIS,
253
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
254
+ * See the License for the specific language governing permissions and
255
+ * limitations under the License.
256
+ */const A="[DEFAULT]",St={[S]:"fire-core",[Ze]:"fire-core-compat",[tt]:"fire-analytics",[et]:"fire-analytics-compat",[rt]:"fire-app-check",[nt]:"fire-app-check-compat",[st]:"fire-auth",[it]:"fire-auth-compat",[ot]:"fire-rtdb",[at]:"fire-data-connect",[ct]:"fire-rtdb-compat",[lt]:"fire-fn",[ht]:"fire-fn-compat",[ft]:"fire-iid",[dt]:"fire-iid-compat",[ut]:"fire-fcm",[pt]:"fire-fcm-compat",[mt]:"fire-perf",[gt]:"fire-perf-compat",[bt]:"fire-rc",[yt]:"fire-rc-compat",[Et]:"fire-gcs",[vt]:"fire-gcs-compat",[_t]:"fire-fst",[Dt]:"fire-fst-compat",[Ct]:"fire-vertex","fire-js":"fire-js",[wt]:"fire-js-all"};/**
257
+ * @license
258
+ * Copyright 2019 Google LLC
259
+ *
260
+ * Licensed under the Apache License, Version 2.0 (the "License");
261
+ * you may not use this file except in compliance with the License.
262
+ * You may obtain a copy of the License at
263
+ *
264
+ * http://www.apache.org/licenses/LICENSE-2.0
265
+ *
266
+ * Unless required by applicable law or agreed to in writing, software
267
+ * distributed under the License is distributed on an "AS IS" BASIS,
268
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
269
+ * See the License for the specific language governing permissions and
270
+ * limitations under the License.
271
+ */const g=new Map,E=new Map,v=new Map;function J(t,e){try{t.container.addComponent(e)}catch(n){d.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`,n)}}function sn(t,e){t.container.addOrOverwriteComponent(e)}function P(t){const e=t.name;if(v.has(e))return d.debug(`There were multiple attempts to register component ${e}.`),!1;v.set(e,t);for(const n of g.values())J(n,t);for(const n of E.values())J(n,t);return!0}function At(t,e){const n=t.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),t.container.getProvider(e)}function on(t,e,n=A){At(t,e).clearInstance(n)}function le(t){return t.options!==void 0}function Ot(t){return le(t)?!1:"authIdToken"in t||"appCheckToken"in t||"releaseOnDeref"in t||"automaticDataCollectionEnabled"in t}function an(t){return t==null?!1:t.settings!==void 0}function cn(){v.clear()}/**
272
+ * @license
273
+ * Copyright 2019 Google LLC
274
+ *
275
+ * Licensed under the Apache License, Version 2.0 (the "License");
276
+ * you may not use this file except in compliance with the License.
277
+ * You may obtain a copy of the License at
278
+ *
279
+ * http://www.apache.org/licenses/LICENSE-2.0
280
+ *
281
+ * Unless required by applicable law or agreed to in writing, software
282
+ * distributed under the License is distributed on an "AS IS" BASIS,
283
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
284
+ * See the License for the specific language governing permissions and
285
+ * limitations under the License.
286
+ */const Bt={"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."},f=new se("app","Firebase",Bt);/**
287
+ * @license
288
+ * Copyright 2019 Google LLC
289
+ *
290
+ * Licensed under the Apache License, Version 2.0 (the "License");
291
+ * you may not use this file except in compliance with the License.
292
+ * You may obtain a copy of the License at
293
+ *
294
+ * http://www.apache.org/licenses/LICENSE-2.0
295
+ *
296
+ * Unless required by applicable law or agreed to in writing, software
297
+ * distributed under the License is distributed on an "AS IS" BASIS,
298
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
299
+ * See the License for the specific language governing permissions and
300
+ * limitations under the License.
301
+ */class he{constructor(e,n,r){this._isDeleted=!1,this._options={...e},this._config={...n},this._name=n.name,this._automaticDataCollectionEnabled=n.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new I("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw f.create("app-deleted",{appName:this._name})}}/**
302
+ * @license
303
+ * Copyright 2023 Google LLC
304
+ *
305
+ * Licensed under the Apache License, Version 2.0 (the "License");
306
+ * you may not use this file except in compliance with the License.
307
+ * You may obtain a copy of the License at
308
+ *
309
+ * http://www.apache.org/licenses/LICENSE-2.0
310
+ *
311
+ * Unless required by applicable law or agreed to in writing, software
312
+ * distributed under the License is distributed on an "AS IS" BASIS,
313
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
314
+ * See the License for the specific language governing permissions and
315
+ * limitations under the License.
316
+ */function K(t,e){const n=te(t.split(".")[1]);if(n===null){console.error(`FirebaseServerApp ${e} is invalid: second part could not be parsed.`);return}if(JSON.parse(n).exp===void 0){console.error(`FirebaseServerApp ${e} is invalid: expiration claim could not be parsed`);return}const s=JSON.parse(n).exp*1e3,i=new Date().getTime();s-i<=0&&console.error(`FirebaseServerApp ${e} is invalid: the token has expired.`)}class Tt extends he{constructor(e,n,r,s){const i=n.automaticDataCollectionEnabled!==void 0?n.automaticDataCollectionEnabled:!0,o={name:r,automaticDataCollectionEnabled:i};if(e.apiKey!==void 0)super(e,o,s);else{const c=e;super(c.options,o,s)}this._serverConfig={automaticDataCollectionEnabled:i,...n},this._serverConfig.authIdToken&&K(this._serverConfig.authIdToken,"authIdToken"),this._serverConfig.appCheckToken&&K(this._serverConfig.appCheckToken,"appCheckToken"),this._finalizationRegistry=null,typeof FinalizationRegistry<"u"&&(this._finalizationRegistry=new FinalizationRegistry(()=>{this.automaticCleanup()})),this._refCount=0,this.incRefCount(this._serverConfig.releaseOnDeref),this._serverConfig.releaseOnDeref=void 0,n.releaseOnDeref=void 0,w(S,x,"serverapp")}toJSON(){}get refCount(){return this._refCount}incRefCount(e){this.isDeleted||(this._refCount++,e!==void 0&&this._finalizationRegistry!==null&&this._finalizationRegistry.register(e,this))}decRefCount(){return this.isDeleted?0:--this._refCount}automaticCleanup(){Mt(this)}get settings(){return this.checkDestroyed(),this._serverConfig}checkDestroyed(){if(this.isDeleted)throw f.create("server-app-deleted")}}/**
317
+ * @license
318
+ * Copyright 2019 Google LLC
319
+ *
320
+ * Licensed under the Apache License, Version 2.0 (the "License");
321
+ * you may not use this file except in compliance with the License.
322
+ * You may obtain a copy of the License at
323
+ *
324
+ * http://www.apache.org/licenses/LICENSE-2.0
325
+ *
326
+ * Unless required by applicable law or agreed to in writing, software
327
+ * distributed under the License is distributed on an "AS IS" BASIS,
328
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
329
+ * See the License for the specific language governing permissions and
330
+ * limitations under the License.
331
+ */const ln=It;function Rt(t,e={}){let n=t;typeof e!="object"&&(e={name:e});const r={name:A,automaticDataCollectionEnabled:!0,...e},s=r.name;if(typeof s!="string"||!s)throw f.create("bad-app-name",{appName:String(s)});if(n||(n=F()),!n)throw f.create("no-options");const i=g.get(s);if(i){if(N(n,i.options)&&N(r,i.config))return i;throw f.create("duplicate-app",{appName:s})}const o=new ie(s);for(const a of v.values())o.addComponent(a);const c=new he(n,r,o);return g.set(s,c),c}function hn(t,e={}){if(De()&&!re())throw f.create("invalid-server-app-environment");let n,r=e||{};if(t&&(le(t)?n=t.options:Ot(t)?r=t:n=t),r.automaticDataCollectionEnabled===void 0&&(r.automaticDataCollectionEnabled=!0),n||(n=F()),!n)throw f.create("no-options");const s={...r,...n};s.releaseOnDeref!==void 0&&delete s.releaseOnDeref;const i=b=>[...b].reduce((p,y)=>Math.imul(31,p)+y.charCodeAt(0)|0,0);if(r.releaseOnDeref!==void 0&&typeof FinalizationRegistry>"u")throw f.create("finalization-registry-not-supported",{});const o=""+i(JSON.stringify(s)),c=E.get(o);if(c)return c.incRefCount(r.releaseOnDeref),c;const a=new ie(o);for(const b of v.values())a.addComponent(b);const h=new Tt(n,r,o,a);return E.set(o,h),h}function fn(t=A){const e=g.get(t);if(!e&&t===A&&F())return Rt();if(!e)throw f.create("no-app",{appName:t});return e}function dn(){return Array.from(g.values())}async function Mt(t){let e=!1;const n=t.name;g.has(n)?(e=!0,g.delete(n)):E.has(n)&&t.decRefCount()<=0&&(E.delete(n),e=!0),e&&(await Promise.all(t.container.getProviders().map(r=>r.delete())),t.isDeleted=!0)}function w(t,e,n){let r=St[t]??t;n&&(r+=`-${n}`);const s=r.match(/\s|\//),i=e.match(/\s|\//);if(s||i){const o=[`Unable to register library "${r}" with version "${e}":`];s&&o.push(`library name "${r}" contains illegal characters (whitespace or "/")`),s&&i&&o.push("and"),i&&o.push(`version name "${e}" contains illegal characters (whitespace or "/")`),d.warn(o.join(" "));return}P(new I(`${r}-version`,()=>({library:r,version:e}),"VERSION"))}function un(t,e){if(t!==null&&typeof t!="function")throw f.create("invalid-log-argument");Fe(t,e)}function pn(t){ke(t)}/**
332
+ * @license
333
+ * Copyright 2021 Google LLC
334
+ *
335
+ * Licensed under the Apache License, Version 2.0 (the "License");
336
+ * you may not use this file except in compliance with the License.
337
+ * You may obtain a copy of the License at
338
+ *
339
+ * http://www.apache.org/licenses/LICENSE-2.0
340
+ *
341
+ * Unless required by applicable law or agreed to in writing, software
342
+ * distributed under the License is distributed on an "AS IS" BASIS,
343
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
344
+ * See the License for the specific language governing permissions and
345
+ * limitations under the License.
346
+ */const Nt="firebase-heartbeat-database",$t=1,_="firebase-heartbeat-store";let M=null;function fe(){return M||(M=Ke(Nt,$t,{upgrade:(t,e)=>{switch(e){case 0:try{t.createObjectStore(_)}catch(n){console.warn(n)}}}}).catch(t=>{throw f.create("idb-open",{originalErrorMessage:t.message})})),M}async function Lt(t){try{const n=(await fe()).transaction(_),r=await n.objectStore(_).get(de(t));return await n.done,r}catch(e){if(e instanceof C)d.warn(e.message);else{const n=f.create("idb-get",{originalErrorMessage:e==null?void 0:e.message});d.warn(n.message)}}}async function Y(t,e){try{const r=(await fe()).transaction(_,"readwrite");await r.objectStore(_).put(e,de(t)),await r.done}catch(n){if(n instanceof C)d.warn(n.message);else{const r=f.create("idb-set",{originalErrorMessage:n==null?void 0:n.message});d.warn(r.message)}}}function de(t){return`${t.name}!${t.options.appId}`}/**
347
+ * @license
348
+ * Copyright 2021 Google LLC
349
+ *
350
+ * Licensed under the Apache License, Version 2.0 (the "License");
351
+ * you may not use this file except in compliance with the License.
352
+ * You may obtain a copy of the License at
353
+ *
354
+ * http://www.apache.org/licenses/LICENSE-2.0
355
+ *
356
+ * Unless required by applicable law or agreed to in writing, software
357
+ * distributed under the License is distributed on an "AS IS" BASIS,
358
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
359
+ * See the License for the specific language governing permissions and
360
+ * limitations under the License.
361
+ */const xt=1024,Pt=30;class kt{constructor(e){this.container=e,this._heartbeatsCache=null;const n=this.container.getProvider("app").getImmediate();this._storage=new Ht(n),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){var e,n;try{const s=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),i=q();if(((e=this._heartbeatsCache)==null?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((n=this._heartbeatsCache)==null?void 0:n.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===i||this._heartbeatsCache.heartbeats.some(o=>o.date===i))return;if(this._heartbeatsCache.heartbeats.push({date:i,agent:s}),this._heartbeatsCache.heartbeats.length>Pt){const o=zt(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(o,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(r){d.warn(r)}}async getHeartbeatsHeader(){var e;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((e=this._heartbeatsCache)==null?void 0:e.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";const n=q(),{heartbeatsToSend:r,unsentEntries:s}=Ft(this._heartbeatsCache.heartbeats),i=ee(JSON.stringify({version:2,heartbeats:r}));return this._heartbeatsCache.lastSentHeartbeatDate=n,s.length>0?(this._heartbeatsCache.heartbeats=s,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),i}catch(n){return d.warn(n),""}}}function q(){return new Date().toISOString().substring(0,10)}function Ft(t,e=xt){const n=[];let r=t.slice();for(const s of t){const i=n.find(o=>o.agent===s.agent);if(i){if(i.dates.push(s.date),X(n)>e){i.dates.pop();break}}else if(n.push({agent:s.agent,dates:[s.date]}),X(n)>e){n.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}class Ht{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return we()?Ie().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const n=await Lt(this.app);return n!=null&&n.heartbeats?n:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){const r=await this.read();return Y(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){if(await this._canUseIndexedDBPromise){const r=await this.read();return Y(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...e.heartbeats]})}else return}}function X(t){return ee(JSON.stringify({version:2,heartbeats:t})).length}function zt(t){if(t.length===0)return-1;let e=0,n=t[0].date;for(let r=1;r<t.length;r++)t[r].date<n&&(n=t[r].date,e=r);return e}/**
362
+ * @license
363
+ * Copyright 2019 Google LLC
364
+ *
365
+ * Licensed under the Apache License, Version 2.0 (the "License");
366
+ * you may not use this file except in compliance with the License.
367
+ * You may obtain a copy of the License at
368
+ *
369
+ * http://www.apache.org/licenses/LICENSE-2.0
370
+ *
371
+ * Unless required by applicable law or agreed to in writing, software
372
+ * distributed under the License is distributed on an "AS IS" BASIS,
373
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
374
+ * See the License for the specific language governing permissions and
375
+ * limitations under the License.
376
+ */function Ut(t){P(new I("platform-logger",e=>new Xe(e),"PRIVATE")),P(new I("heartbeat",e=>new kt(e),"PRIVATE")),w(S,x,t),w(S,x,"esm2020"),w("fire-js","")}Ut("");export{Wt as A,Vt as B,ne as C,A as D,Yt as E,C as F,qt as G,te as H,se as I,l as J,jt as K,Pe as L,Kt as M,Jt as N,Gt as O,I as P,en as Q,ln as S,J as _,sn as a,g as b,cn as c,v as d,At as e,le as f,an as g,Ot as h,P as i,on as j,E as k,Mt as l,fn as m,dn as n,Rt as o,hn as p,un as q,w as r,pn as s,Qt as t,Zt as u,Xt as v,tn as w,N as x,nn as y,rn as z};