PageSourceSearch

https://treasure-debris.vercel.app/_app/immutable/chunks/2.3818ca5c.js

js treasure-debris.vercel.app collected 2026-10-03 05:50:01 UTC 260,490 bytes, 1,969 lines download raw bytes

1import{S as Oo,i as Mo,s as Lo}from"./index.544f46ea.js";/**
2 * @license
3 * Copyright 2017 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 xs={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"};/**
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 f=function(n,e){if(!n)throw Le(e)},Le=function(n){return new Error("Firebase Database ("+xs.SDK_VERSION+") INTERNAL ASSERT FAILED: "+n)};/**
32 * @license
33 * Copyright 2017 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 */const Ps=function(n){const e=[];let t=0;for(let i=0;i<n.length;i++){let s=n.charCodeAt(i);s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&i+1<n.length&&(n.charCodeAt(i+1)&64512)===56320?(s=65536+((s&1023)<<10)+(n.charCodeAt(++i)&1023),e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128)}return e},Fo=function(n){const e=[];let t=0,i=0;for(;t<n.length;){const s=n[t++];if(s<128)e[i++]=String.fromCharCode(s);else if(s>191&&s<224){const r=n[t++];e[i++]=String.fromCharCode((s&31)<<6|r&63)}else if(s>239&&s<365){const r=n[t++],o=n[t++],a=n[t++],l=((s&7)<<18|(r&63)<<12|(o&63)<<6|a&63)-65536;e[i++]=String.fromCharCode(55296+(l>>10)),e[i++]=String.fromCharCode(56320+(l&1023))}else{const r=n[t++],o=n[t++];e[i++]=String.fromCharCode((s&15)<<12|(r&63)<<6|o&63)}}return e.join("")},$n={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(n,e){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();const t=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,i=[];for(let s=0;s<n.length;s+=3){const r=n[s],o=s+1<n.length,a=o?n[s+1]:0,l=s+2<n.length,c=l?n[s+2]:0,u=r>>2,h=(r&3)<<4|a>>4;let d=(a&15)<<2|c>>6,_=c&63;l||(_=64,o||(d=64)),i.push(t[u],t[h],t[d],t[_])}return i.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray(Ps(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):Fo(this.decodeStringToByteArray(n,e))},decodeStringToByteArray(n,e){this.init_();const t=e?this.charToByteMapWebSafe_:this.charToByteMap_,i=[];for(let s=0;s<n.length;){const r=t[n.charAt(s++)],a=s<n.length?t[n.charAt(s)]:0;++s;const c=s<n.length?t[n.charAt(s)]:64;++s;const h=s<n.length?t[n.charAt(s)]:64;if(++s,r==null||a==null||c==null||h==null)throw new Bo;const d=r<<2|a>>4;if(i.push(d),c!==64){const _=a<<4&240|c>>2;if(i.push(_),h!==64){const p=c<<6&192|h;i.push(p)}}}return i},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let n=0;n<this.ENCODED_VALS.length;n++)this.byteToCharMap_[n]=this.ENCODED_VALS.charAt(n),this.charToByteMap_[this.byteToCharMap_[n]]=n,this.byteToCharMapWebSafe_[n]=this.ENCODED_VALS_WEBSAFE.charAt(n),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[n]]=n,n>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(n)]=n,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(n)]=n)}}};
46class Bo extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const Os=function(n){const e=Ps(n);return $n.encodeByteArray(e,!0)},pt=function(n){return Os(n).replace(/\./g,"")},mn=function(n){try{return $n.decodeString(n,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};/**
47 * @license
48 * Copyright 2017 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 */function Wo(n){return Ms(void 0,n)}function Ms(n,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:const t=e;return new Date(t.getTime());case Object:n===void 0&&(n={});break;case Array:n=[];break;default:return e}for(const t in e)!e.hasOwnProperty(t)||!$o(t)||(n[t]=Ms(n[t],e[t]));return n}function $o(n){return n!=="__proto__"}/**
62 * @license
63 * Copyright 2022 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 */function Uo(){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.")}/**
77 * @license
78 * Copyright 2022 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 */const Vo=()=>Uo().__FIREBASE_DEFAULTS__,Ho=()=>{if(typeof process>"u"||typeof process.env>"u")return;const n={}.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},jo=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=n&&mn(n[1]);return e&&JSON.parse(e)},Un=()=>{try{return Vo()||Ho()||jo()}catch(n){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},Go=n=>{var e,t;return(t=(e=Un())===null||e===void 0?void 0:e.emulatorHosts)===null||t===void 0?void 0:t[n]},zo=n=>{const e=Go(n);if(!e)return;const t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const i=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),i]:[e.substring(0,t),i]},Ls=()=>{var n;return(n=Un())===null||n===void 0?void 0:n.config},lf=n=>{var e;return(e=Un())===null||e===void 0?void 0: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 */class st{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>
106{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,i)=>{t?this.reject(t):this.resolve(i),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,i))}}}/**
107 * @license
108 * Copyright 2021 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 qo(n,e){if(n.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const t={alg:"none",type:"JWT"},i=e||"demo-project",s=n.iat||0,r=n.sub||n.user_id;if(!r)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o=Object.assign({iss:`https://securetoken.google.com/${i}`,aud:i,iat:s,exp:s+3600,auth_time:s,sub:r,user_id:r,firebase:{sign_in_provider:"custom",identities:{}}},n),a="";return[pt(JSON.stringify(t)),pt(JSON.stringify(o)),a].join(".")}/**
122 * @license
123 * Copyright 2017 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 Fs(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function Bs(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(Fs())}function Ws(){const n=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof n=="object"&&n.id!==void 0}function Ko(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function cf(){const n=Fs();return n.indexOf("MSIE ")>=0||n.indexOf("Trident/")>=0}function $s(){return xs.NODE_ADMIN===!0}function Vn(){try{return typeof indexedDB=="object"}catch{return!1}}function Hn(){return new Promise((n,e)=>{try{let t=!0;const i="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(i);s.onsuccess=()=>{s.result.close(),t||self.indexedDB.deleteDatabase(i),n(!0)},s.onupgradeneeded=()=>{t=!1},s.onerror=()=>{var r;e(((r=s.error)===null||r===void 0?void 0:r.message)||"")}}catch(t){e(t)}})}function Us(){return!(typeof navigator>"u"||!navigator.cookieEnabled)}/**
137 * @license
138 * Copyright 2017 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 */const Yo="FirebaseError";class Ce extends Error{constructor(e,t,i){super(t),this.code=e,this.customData=i,this.name=Yo,Object.setPrototypeOf(this,Ce.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,Mt.prototype.create)}}class Mt{constructor(e,t,i){this.service=e,this.serviceName=t,this.errors=i}create(e,...t){const i=t[0]||{},s=`${this.service}/${e}`,r=this.errors[e],o=r?Qo(r,i):"Error",a=`${this.serviceName}: ${o} (${s}).`;return new Ce(s,a,i)}}function Qo(n,e){return n.replace(Xo,(t,i)=>{const s=e[i];return s!=null?String(s):`<${i}?>`})}const Xo=/\{\$([^}]+)}/g;/**
152 * @license
153 * Copyright 2017 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 */function Ye(n){return JSON.parse(n)}function A(n){return JSON.stringify(n)}/**
167 * @license
168 * Copyright 2017 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 */const Vs=function(n){let e={},t={},i={},s="";try{const r=n.split(".");e=Ye(mn(r[0])||""),t=Ye(mn(r[1])||""),s=r[2],i=t.d||{},delete t.d}catch{}return{header:e,claims:t,data:i,signature:s}},Jo=function(n){const e=Vs(n),t=e.claims;return!!t&&typeof t=="object"&&t.hasOwnProperty("iat")},Zo=function(n){const e=Vs(n).claims;return typeof e=="object"&&e.admin===!0};/**
182 * @license
183 * Copyright 2017 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 */function z(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function Ae(n,e){if(Object.prototype.hasOwnProperty.call(n,e))return n[e]}function xi(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function gt(n,e,t){const i={};for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=e.call(t,n[s],s,n));return i}function mt(n,e){if(n===e)return!0;const t=Object.keys(n),i=Object.keys(e);for(const s of t){if(!i.includes(s))return!1;const r=n[s],o=e[s];if(Pi(r)&&Pi(o)){if(!mt(r,o))return!1}else if(r!==o)return!1}for(const s of i)if(!t.includes(s))return!1;return!0}function Pi(n){return n!==null&&typeof n=="object"}/**
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 */function ea(n){const e=[];for(const[t,i]of Object.entries(n))Array.isArray(i)?i.forEach(s=>{e.push(encodeURIComponent(t)+"="+encodeURIComponent(s))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(i));return e.length?"&"+e.join("&"):""}/**
212 * @license
213 * Copyright 2017 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 ta{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=512/8,this.pad_[0]=128;for(let e=1;e<this.blockSize;++e)this.pad_[e]=0;this.reset()}reset(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0}compress_(e,t){t||(t=0);const i=this.W_;if(typeof e=="string")for(let h=0;h<16;h++)i[h]=e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3),t+=4;else for(let h=0;h<16;h++)i[h]=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3],t+=4;for(let h=16;h<80;h++){const d=i[h-3]^i[h-8]^i[h-14]^i[h-16];i[h]=(d<<1|d>>>31)&4294967295}let s=this.chain_[0],r=this.chain_[1],o=this.chain_[2],a=this.chain_[3],l=this.chain_[4],c,u;for(let h=0;h<80;h++){h<40?h<20?(c=a^r&(o^a),u=1518500249):(c=r^o^a,u=1859775393):h<60?(c=r&o|a&(r|o),u=2400959708):(c=r^o^a,u=3395469782);const d=(s<<5|s>>>27)+c+l+u+i[h]&4294967295;l=a,a=o,o=(r<<30|r>>>2)&4294967295,r=s,s=d}this.chain_[0]=this.chain_[0]+s&4294967295,this.chain_[1]=this.chain_[1]+r&4294967295,this.chain_[2]=this.chain_[2]+o&4294967295,this.chain_[3]=this.chain_[3]+a&4294967295,this.chain_[4]=this.chain_[4]+l&4294967295}update(e,t){if(e==null)return;t===void 0&&(t=e.length);const i=t-this.blockSize;let s=0;const r=this.buf_;let o=this.inbuf_;for(;s<t;){if(o===0)for(;s<=i;)this.compress_(e,s),s+=this.blockSize;if(typeof e=="string"){for(;s<t;)if(r[o]=e.charCodeAt(s),++o,++s,o===this.blockSize){this.compress_(r),o=0;break}}else for(;s<t;)if(r[o]=e[s],++o,++s,o===this.blockSize){this.compress_(r),o=0;break}}this.inbuf_=o,this.total_+=t}digest(){const e=[];let t=this.total_*8;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let s=this.blockSize-1;s>=56;s--)this.buf_[s]=t&255,t/=256;this.compress_(this.buf_);let i=0;for(let s=0;s<5;s++)for(let r=24;r>=0;r-=8)e[i]=this.chain_[s]>>r&255,++i;return e}}function hf(n,e){const t=new na(n,e);return t.subscribe.bind(t)}class na{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Prom
226ise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(i=>{this.error(i)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,i){let s;if(e===void 0&&t===void 0&&i===void 0)throw new Error("Missing Observer.");ia(e,["next","error","complete"])?s=e:s={next:e,error:t,complete:i},s.next===void 0&&(s.next=Jt),s.error===void 0&&(s.error=Jt),s.complete===void 0&&(s.complete=Jt);const r=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),r}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 t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(this.observers!==void 0&&this.observers[e]!==void 0)try{t(this.observers[e])}catch(i){typeof console<"u"&&console.error&&console.error(i)}})}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 ia(n,e){if(typeof n!="object"||n===null)return!1;for(const t of e)if(t in n&&typeof n[t]=="function")return!0;return!1}function Jt(){}function Lt(n,e){return`${n} failed: ${e} argument `}/**
227 * @license
228 * Copyright 2017 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 sa=function(n){const e=[];let t=0;for(let i=0;i<n.length;i++){let s=n.charCodeAt(i);if(s>=55296&&s<=56319){const r=s-55296;i++,f(i<n.length,"Surrogate pair missing trail surrogate.");const o=n.charCodeAt(i)-56320;s=65536+(r<<10)+o}s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):s<65536?(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128)}return e},Ft=function(n){let e=0;for(let t=0;t<n.length;t++){const i=n.charCodeAt(t);i<128?e++:i<2048?e+=2:i>=55296&&i<=56319?(e+=4,t++):e+=3}return e};/**
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 ra=1e3,oa=2,aa=4*60*60*1e3,la=.5;function Oi(n,e=ra,t=oa){const i=e*Math.pow(t,n),s=Math.round(la*i*(Math.random()-.5)*2);return Math.min(aa,i+s)}/**
257 * @license
258 * Copyright 2021 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 */function le(n){return n&&n._delegate?n._delegate:n}class Q{constructor(e,t,i){this.name=e,this.instanceFactory=t,this.type=i,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}}/**
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 ce="[DEFAULT]";/**
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 ca{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const i=new st;if(this.instancesDeferred.set(t,i),this.isInitialized(t)||this.shouldAutoInitialize())try{const s=this.getOrInitializeService({instanceIdentifier:t});s&&i.resolve(s)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;const i=this.normalizeInstanceIdentifier(e==null?void 0:e.identifier),s=(t=e==null?void 0:e.optional)!==null&&t!==void 0?t:!1;if(this.isInitialized(i)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:i})}catch(r){if(s)return null;throw r}else{if(s)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(ua(e))try{this.getOrInitializeService({instanceIdentifier:ce})}catch{}for(const[t,i]of this.instancesDeferred.entries()){const s=this.normalizeInstanceIdentifier(t);try{const r=this.getOrInitializeService({instanceIdentifier:s});i.resolve(r)}catch{}}}}clearInstance(e=ce){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(t=>"INTERNAL"in t).map(t=>t.INTERNAL.delete()),...e.filter(t=>"_delete"in t).map(t=>t._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=ce){return this.instances.has(e)}getOptions(e=ce){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,i=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(i))throw Error(`${this.name}(${i}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const s=this.getOrInitializeService({instanceIdentifier:i,options:t});for(const[r,o]of this.instancesDeferred.entries()){const a=this.normalizeInstanceIdentifier(r);i===a&&o.resolve(s)}return s}onInit(e,t){var i;const s=this.normalizeInstanceIdentifier(t),r=(i=this.onInitCallbacks.get(s))!==null&&i!==void 0?i:new Set;r.add(e),this.onInitCallbacks.set(s,r);const o=this.instances.get(s);return o&&e(o,s),()=>{r.delete(e)}}invokeOnInitCallbacks(e,t){const i=this.onInitCallbacks.get(t);if(i)for(const s of i)try{s(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let i=this.instances.get(e);if(!i&&this.component&&(i=this.component.instanceFactory(this.container,{instanceIdentifier:ha(e),options:t}),this.instances.set(e,i),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(i,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,i)}catch{}return i||null}normalizeInstanceIdentifier(e=ce){return this.component?this.component.multipleInstances?e:ce:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function ha(n){return n===ce?void 0:n}function ua(n){return n.instantiationMode==="EAGER"}/**
302 * @license
303 * Copyright 2019 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 */class da{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.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 t=new ca(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}/**
317 * @license
318 * Copyright 2017 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 */var b;(function(n){n[n.DEBUG=0]="DEBUG",n[n.VERBOSE=1]="VERBOSE",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.SILENT=5]="SILENT"})(b||(b={}));const fa={debug:b.DEBUG,verbose:b.VERBOSE,info:b.INFO,warn:b.WARN,error:b.ERROR,silent:b.SILENT},_a=b.INFO,pa={[b.DEBUG]:"log",[b.VERBOSE]:"log",[b.INFO]:"info",[b.WARN]:"warn",[b.ERROR]:"error"},ga=(n,e,...t)=>{if(e<n.logLevel)return;const i=new Date().toISOString(),s=pa[e];if(s)console[s](`[${i}]  ${n.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class jn{constructor(e){this.name=e,this._logLevel=_a,this._logHandler=ga,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in b))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?fa[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,b.DEBUG,...e),this._logHandler(this,b.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,b.VERBOSE,...e),this._logHandler(this,b.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,b.INFO,...e),this._logHandler(this,b.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,b.WARN,...e),this._logHandler(this,b.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,b.ERROR,...e),this._logHandler(this,b.ERROR,...e)}}const ma=(n,e)=>e.some(t=>n instanceof t);let Mi,Li;function ya(){return Mi||(Mi=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function va(){return Li||(Li=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Hs=new WeakMap,yn=new WeakMap,js=new WeakMap,Zt=new WeakMap,Gn=new WeakMap;function Ca(n){const e=new Promise((t,i)=>{const s=()=>{n.removeEventListener("success",r),n.removeEventListener("error",o)},r=()=>{t(Z(n.result)),s()},o=()=>{i(n.error),s()};n.addEventListener("success",r),n.addEventListener("error",o)});return e.then(t=>{t instanceof IDBCursor&&Hs.set(t,n)}).catch(()=>{}),Gn.set(e,n),e}function Ea(n){if(yn.has(n))return;const e=new Promise((t,i)=>{const s=()=>{n.removeEventListener("complete",r),n.removeEventListener("error",o),n.removeEventListener("abort",o)},r=()=>{t(),s()},o=()=>{i(n.error||new DOMException("AbortError","AbortError")),s()};n.addEventListener("complete",r),n.addEventListener("error",o),n.addEventListener("abort",o)});yn.set(n,e)}let vn={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return yn.get(n);if(e==="objectStoreNames")return n.objectStoreNames||js.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return Z(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function wa(n){vn=n(vn)}
331function Ia(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const i=n.call(en(this),e,...t);return js.set(i,e.sort?e.sort():[e]),Z(i)}:va().includes(n)?function(...e){return n.apply(en(this),e),Z(Hs.get(this))}:function(...e){return Z(n.apply(en(this),e))}}function ba(n){return typeof n=="function"?Ia(n):(n instanceof IDBTransaction&&Ea(n),ma(n,ya())?new Proxy(n,vn):n)}function Z(n){if(n instanceof IDBRequest)return Ca(n);if(Zt.has(n))return Zt.get(n);const e=ba(n);return e!==n&&(Zt.set(n,e),Gn.set(e,n)),e}const en=n=>Gn.get(n);function Ta(n,e,{blocked:t,upgrade:i,blocking:s,terminated:r}={}){const o=indexedDB.open(n,e),a=Z(o);return i&&o.addEventListener("upgradeneeded",l=>{i(Z(o.result),l.oldVersion,l.newVersion,Z(o.transaction),l)}),t&&o.addEventListener("blocked",l=>t(l.oldVersion,l.newVersion,l)),a.then(l=>{r&&l.addEventListener("close",()=>r()),s&&l.addEventListener("versionchange",c=>s(c.oldVersion,c.newVersion,c))}).catch(()=>{}),a}const Sa=["get","getKey","getAll","getAllKeys","count"],Na=["put","add","delete","clear"],tn=new Map;function Fi(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(tn.get(e))return tn.get(e);const t=e.replace(/FromIndex$/,""),i=e!==t,s=Na.includes(t);if(!(t in(i?IDBIndex:IDBObjectStore).prototype)||!(s||Sa.includes(t)))return;const r=async function(o,...a){const l=this.transaction(o,s?"readwrite":"readonly");let c=l.store;return i&&(c=c.index(a.shift())),(await Promise.all([c[t](...a),s&&l.done]))[0]};return tn.set(e,r),r}wa(n=>({...n,get:(e,t,i)=>Fi(e,t)||n.get(e,t,i),has:(e,t)=>!!Fi(e,t)||n.has(e,t)}));/**
332 * @license
333 * Copyright 2019 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 */class Ra{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(Aa(t)){const i=t.getImmediate();return`${i.library}/${i.version}`}else return null}).filter(t=>t).join(" ")}}function Aa(n){const e=n.getComponent();return(e==null?void 0:e.type)==="VERSION"}const Cn="@firebase/app",Bi="0.9.13";/**
347 * @license
348 * Copyright 2019 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 _e=new jn("@firebase/app"),ka="@firebase/app-compat",Da="@firebase/analytics-compat",xa="@firebase/analytics",Pa="@firebase/app-check-compat",Oa="@firebase/app-check",Ma="@firebase/auth",La="@firebase/auth-compat",Fa="@firebase/database",Ba="@firebase/database-compat",Wa="@firebase/functions",$a="@firebase/functions-compat",Ua="@firebase/installations",Va="@firebase/installations-compat",Ha="@firebase/messaging",ja="@firebase/messaging-compat",Ga="@firebase/performance",za="@firebase/performance-compat",qa="@firebase/remote-config",Ka="@firebase/remote-config-compat",Ya="@firebase/storage",Qa="@firebase/storage-compat",Xa="@firebase/firestore",Ja="@firebase/firestore-compat",Za="firebase",el="9.23.0";/**
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, softw
371are
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 */const En="[DEFAULT]",tl={[Cn]:"fire-core",[ka]:"fire-core-compat",[xa]:"fire-analytics",[Da]:"fire-analytics-compat",[Oa]:"fire-app-check",[Pa]:"fire-app-check-compat",[Ma]:"fire-auth",[La]:"fire-auth-compat",[Fa]:"fire-rtdb",[Ba]:"fire-rtdb-compat",[Wa]:"fire-fn",[$a]:"fire-fn-compat",[Ua]:"fire-iid",[Va]:"fire-iid-compat",[Ha]:"fire-fcm",[ja]:"fire-fcm-compat",[Ga]:"fire-perf",[za]:"fire-perf-compat",[qa]:"fire-rc",[Ka]:"fire-rc-compat",[Ya]:"fire-gcs",[Qa]:"fire-gcs-compat",[Xa]:"fire-fst",[Ja]:"fire-fst-compat","fire-js":"fire-js",[Za]:"fire-js-all"};/**
377 * @license
378 * Copyright 2019 Google LLC
379 *
380 * Licensed under the Apache License, Version 2.0 (the "License");
381 * you may not use this file except in compliance with the License.
382 * You may obtain a copy of the License at
383 *
384 *   http://www.apache.org/licenses/LICENSE-2.0
385 *
386 * Unless required by applicable law or agreed to in writing, software
387 * distributed under the License is distributed on an "AS IS" BASIS,
388 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
389 * See the License for the specific language governing permissions and
390 * limitations under the License.
391 */const yt=new Map,wn=new Map;function nl(n,e){try{n.container.addComponent(e)}catch(t){_e.debug(`Component ${e.name} failed to register with FirebaseApp ${n.name}`,t)}}function se(n){const e=n.name;if(wn.has(e))return _e.debug(`There were multiple attempts to register component ${e}.`),!1;wn.set(e,n);for(const t of yt.values())nl(t,n);return!0}function rt(n,e){const t=n.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),n.container.getProvider(e)}/**
392 * @license
393 * Copyright 2019 Google LLC
394 *
395 * Licensed under the Apache License, Version 2.0 (the "License");
396 * you may not use this file except in compliance with the License.
397 * You may obtain a copy of the License at
398 *
399 *   http://www.apache.org/licenses/LICENSE-2.0
400 *
401 * Unless required by applicable law or agreed to in writing, software
402 * distributed under the License is distributed on an "AS IS" BASIS,
403 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
404 * See the License for the specific language governing permissions and
405 * limitations under the License.
406 */const il={"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","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.","invali
406d-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}."},ee=new Mt("app","Firebase",il);/**
407 * @license
408 * Copyright 2019 Google LLC
409 *
410 * Licensed under the Apache License, Version 2.0 (the "License");
411 * you may not use this file except in compliance with the License.
412 * You may obtain a copy of the License at
413 *
414 *   http://www.apache.org/licenses/LICENSE-2.0
415 *
416 * Unless required by applicable law or agreed to in writing, software
417 * distributed under the License is distributed on an "AS IS" BASIS,
418 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
419 * See the License for the specific language governing permissions and
420 * limitations under the License.
421 */class sl{constructor(e,t,i){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=i,this.container.addComponent(new Q("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 ee.create("app-deleted",{appName:this._name})}}/**
422 * @license
423 * Copyright 2019 Google LLC
424 *
425 * Licensed under the Apache License, Version 2.0 (the "License");
426 * you may not use this file except in compliance with the License.
427 * You may obtain a copy of the License at
428 *
429 *   http://www.apache.org/licenses/LICENSE-2.0
430 *
431 * Unless required by applicable law or agreed to in writing, software
432 * distributed under the License is distributed on an "AS IS" BASIS,
433 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
434 * See the License for the specific language governing permissions and
435 * limitations under the License.
436 */const rl=el;function Gs(n,e={}){let t=n;typeof e!="object"&&(e={name:e});const i=Object.assign({name:En,automaticDataCollectionEnabled:!1},e),s=i.name;if(typeof s!="string"||!s)throw ee.create("bad-app-name",{appName:String(s)});if(t||(t=Ls()),!t)throw ee.create("no-options");const r=yt.get(s);if(r){if(mt(t,r.options)&&mt(i,r.config))return r;throw ee.create("duplicate-app",{appName:s})}const o=new da(s);for(const l of wn.values())o.addComponent(l);const a=new sl(t,i,o);return yt.set(s,a),a}function zs(n=En){const e=yt.get(n);if(!e&&n===En&&Ls())return Gs();if(!e)throw ee.create("no-app",{appName:n});return e}function G(n,e,t){var i;let s=(i=tl[n])!==null&&i!==void 0?i:n;t&&(s+=`-${t}`);const r=s.match(/\s|\//),o=e.match(/\s|\//);if(r||o){const a=[`Unable to register library "${s}" with version "${e}":`];r&&a.push(`library name "${s}" contains illegal characters (whitespace or "/")`),r&&o&&a.push("and"),o&&a.push(`version name "${e}" contains illegal characters (whitespace or "/")`),_e.warn(a.join(" "));return}se(new Q(`${s}-version`,()=>({library:s,version:e}),"VERSION"))}/**
437 * @license
438 * Copyright 2021 Google LLC
439 *
440 * Licensed under the Apache License, Version 2.0 (the "License");
441 * you may not use this file except in compliance with the License.
442 * You may obtain a copy of the License at
443 *
444 *   http://www.apache.org/licenses/LICENSE-2.0
445 *
446 * Unless required by applicable law or agreed to in writing, software
447 * distributed under the License is distributed on an "AS IS" BASIS,
448 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
449 * See the License for the specific language governing permissions and
450 * limitations under the License.
451 */const ol="firebase-heartbeat-database",al=1,Qe="firebase-heartbeat-store";let nn=null;function qs(){return nn||(nn=Ta(ol,al,{upgrade:(n,e)=>
451{switch(e){case 0:n.createObjectStore(Qe)}}}).catch(n=>{throw ee.create("idb-open",{originalErrorMessage:n.message})})),nn}async function ll(n){try{return await(await qs()).transaction(Qe).objectStore(Qe).get(Ks(n))}catch(e){if(e instanceof Ce)_e.warn(e.message);else{const t=ee.create("idb-get",{originalErrorMessage:e==null?void 0:e.message});_e.warn(t.message)}}}async function Wi(n,e){try{const i=(await qs()).transaction(Qe,"readwrite");await i.objectStore(Qe).put(e,Ks(n)),await i.done}catch(t){if(t instanceof Ce)_e.warn(t.message);else{const i=ee.create("idb-set",{originalErrorMessage:t==null?void 0:t.message});_e.warn(i.message)}}}function Ks(n){return`${n.name}!${n.options.appId}`}/**
452 * @license
453 * Copyright 2021 Google LLC
454 *
455 * Licensed under the Apache License, Version 2.0 (the "License");
456 * you may not use this file except in compliance with the License.
457 * You may obtain a copy of the License at
458 *
459 *   http://www.apache.org/licenses/LICENSE-2.0
460 *
461 * Unless required by applicable law or agreed to in writing, software
462 * distributed under the License is distributed on an "AS IS" BASIS,
463 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
464 * See the License for the specific language governing permissions and
465 * limitations under the License.
466 */const cl=1024,hl=30*24*60*60*1e3;class ul{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new fl(t),this._heartbeatsCachePromise=this._storage.read().then(i=>(this._heartbeatsCache=i,i))}async triggerHeartbeat(){const t=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),i=$i();if(this._heartbeatsCache===null&&(this._heartbeatsCache=await this._heartbeatsCachePromise),!(this._heartbeatsCache.lastSentHeartbeatDate===i||this._heartbeatsCache.heartbeats.some(s=>s.date===i)))return this._heartbeatsCache.heartbeats.push({date:i,agent:t}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter(s=>{const r=new Date(s.date).valueOf();return Date.now()-r<=hl}),this._storage.overwrite(this._heartbeatsCache)}async getHeartbeatsHeader(){if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache===null||this._heartbeatsCache.heartbeats.length===0)return"";const e=$i(),{heartbeatsToSend:t,unsentEntries:i}=dl(this._heartbeatsCache.heartbeats),s=pt(JSON.stringify({version:2,heartbeats:t}));return this._heartbeatsCache.lastSentHeartbeatDate=e,i.length>0?(this._heartbeatsCache.heartbeats=i,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),s}}function $i(){return new Date().toISOString().substring(0,10)}function dl(n,e=cl){const t=[];let i=n.slice();for(const s of n){const r=t.find(o=>o.agent===s.agent);if(r){if(r.dates.push(s.date),Ui(t)>e){r.dates.pop();break}}else if(t.push({agent:s.agent,dates:[s.date]}),Ui(t)>e){t.pop();break}i=i.slice(1)}return{heartbeatsToSend:t,unsentEntries:i}}class fl{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return Vn()?Hn().then(()=>!0).catch(()=>!1):!1}async read(){return await this._canUseIndexedDBPromise?await ll(this.app)||{heartbeats:[]}:{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){const s=await this.read();return Wi(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:s.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){var t;if(await this._canUseIndexedDBPromise){const s=await this.read();return Wi(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:s.lastSentHeartbeatDate,heartbeats:[...s.heartbeats,...e.heartbeats]})}else return}}function Ui(n){return pt(JSON.stringify({version:2,heartbeats:n})).length}/**
467 * @license
468 * Copyright 2019 Google LLC
469 *
470 * Licensed under the Apache License, Version 2.0 (the "License");
471 * you may not use this file except in compliance with the License.
472 * You may obtain a copy of the License at
473 *
474 *   http://www.apache.org/licenses/LICENSE-2.0
475 *
476 * Unless required by applicable law or agreed to in writing, softw
476are
477 * distributed under the License is distributed on an "AS IS" BASIS,
478 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
479 * See the License for the specific language governing permissions and
480 * limitations under the License.
481 */function _l(n){se(new Q("platform-logger",e=>new Ra(e),"PRIVATE")),se(new Q("heartbeat",e=>new ul(e),"PRIVATE")),G(Cn,Bi,n),G(Cn,Bi,"esm2017"),G("fire-js","")}_l("");const pl=(n,e)=>e.some(t=>n instanceof t);let Vi,Hi;function gl(){return Vi||(Vi=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function ml(){return Hi||(Hi=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Ys=new WeakMap,In=new WeakMap,Qs=new WeakMap,sn=new WeakMap,zn=new WeakMap;function yl(n){const e=new Promise((t,i)=>{const s=()=>{n.removeEventListener("success",r),n.removeEventListener("error",o)},r=()=>{t(te(n.result)),s()},o=()=>{i(n.error),s()};n.addEventListener("success",r),n.addEventListener("error",o)});return e.then(t=>{t instanceof IDBCursor&&Ys.set(t,n)}).catch(()=>{}),zn.set(e,n),e}function vl(n){if(In.has(n))return;const e=new Promise((t,i)=>{const s=()=>{n.removeEventListener("complete",r),n.removeEventListener("error",o),n.removeEventListener("abort",o)},r=()=>{t(),s()},o=()=>{i(n.error||new DOMException("AbortError","AbortError")),s()};n.addEventListener("complete",r),n.addEventListener("error",o),n.addEventListener("abort",o)});In.set(n,e)}let bn={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return In.get(n);if(e==="objectStoreNames")return n.objectStoreNames||Qs.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return te(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function Cl(n){bn=n(bn)}function El(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const i=n.call(rn(this),e,...t);return Qs.set(i,e.sort?e.sort():[e]),te(i)}:ml().includes(n)?function(...e){return n.apply(rn(this),e),te(Ys.get(this))}:function(...e){return te(n.apply(rn(this),e))}}function wl(n){return typeof n=="function"?El(n):(n instanceof IDBTransaction&&vl(n),pl(n,gl())?new Proxy(n,bn):n)}function te(n){if(n instanceof IDBRequest)return yl(n);if(sn.has(n))return sn.get(n);const e=wl(n);return e!==n&&(sn.set(n,e),zn.set(e,n)),e}const rn=n=>zn.get(n);function Il(n,e,{blocked:t,upgrade:i,blocking:s,terminated:r}={}){const o=indexedDB.open(n,e),a=te(o);return i&&o.addEventListener("upgradeneeded",l=>{i(te(o.result),l.oldVersion,l.newVersion,te(o.transaction))}),t&&o.addEventListener("blocked",()=>t()),a.then(l=>{r&&l.addEventListener("close",()=>r()),s&&l.addEventListener("versionchange",()=>s())}).catch(()=>{}),a}const bl=["get","getKey","getAll","getAllKeys","count"],Tl=["put","add","delete","clear"],on=new Map;function ji(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(on.get(e))return on.get(e);const t=e.replace(/FromIndex$/,""),i=e!==t,s=Tl.includes(t);if(!(t in(i?IDBIndex:IDBObjectStore).prototype)||!(s||bl.includes(t)))return;const r=async function(o,...a){const l=this.transaction(o,s?"readwrite":"readonly");let c=l.store;return i&&(c=c.index(a.shift())),(await Promise.all([c[t](...a),s&&l.done]))[0]};return on.set(e,r),r}Cl(n=>({...n,get:(e,t,i)=>ji(e,t)||n.get(e,t,i),has:(e,t)=>!!ji(e,t)||n.has(e,t)}));const Xs="@firebase/installations",qn="0.6.4";/**
482 * @license
483 * Copyright 2019 Google LLC
484 *
485 * Licensed under the Apache License, Version 2.0 (the "License");
486 * you may not use this file except in compliance with the License.
487 * You may obtain a copy of the License at
488 *
489 *   http://www.apache.org/licenses/LICENSE-2.0
490 *
491 * Unless required by applicable law or agreed to in writing, software
492 * distributed under the License is distributed on an "AS IS" BASIS,
493 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
494 * See the License for the specific language governing permissions and
495 * limitations under the License.
496 */const Js=1e4,Zs=`w:${qn}`,er="FIS_v2",Sl="https://firebaseinstallations.googleapis.com/v1",Nl=60*60*1e3,Rl="installations",Al="Installations";/**
497 * @license
498 * Copyright 2019 Google LLC
499 *
500 * Licensed under the Apache License, Version 2.0 (the "License");
501 * you may not use this file except in compliance with the License.
502 * You may obtain a copy of the License at
503 *
504 *   http://www.apache.org/licenses/LICENSE-2.0
505 *
506 * Unless required by applicable law or agreed to in writing, software
507 * distributed under the License is distributed on an "AS IS" BASIS,
508 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
509 * See the License for the specific language governing permissions and
510 * limitations under the License.
511 */const kl={"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."},pe=new Mt(Rl,Al,kl);function tr(n){return n instanceof Ce&&n.code.includes("request-failed")}/**
512 * @license
513 * Copyright 2019 Google LLC
514 *
515 * Licensed under the Apache License, Version 2.0 (the "License");
516 * you may not use this file except in compliance with the License.
517 * You may obtain a copy of the License at
518 *
519 *   http://www.apache.org/licenses/LICENSE-2.0
520 *
521 * Unless required by applicable law or agreed to in writing, software
522 * distributed under the License is distributed on an "AS IS" BASIS,
523 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
524 * See the License for the specific language governing permissions and
525 * limitations under the License.
526 */function nr({projectId:n}){return`${Sl}/projects/${n}/installations`}function ir(n){return{token:n.token,requestStatus:2,expiresIn:xl(n.expiresIn),creationTime:Date.now()}}async function sr(n,e){const i=(await e.json()).error;return pe.create("request-failed",{requestName:n,serverCode:i.code,serverMessage:i.message,serverStatus:i.status})}function rr({apiKey:n}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":n})}function Dl(n,{refreshToken:e}){const t=rr(n);return t.append("Authorization",Pl(e)),t}async function or(n){const e=await n();return e.status>=500&&e.status<600?n():e}function xl(n){return Number(n.replace("s","000"))}function Pl(n){return`${er} ${n}`}/**
527 * @license
528 * Copyright 2019 Google LLC
529 *
530 * Licensed under the Apache License, Version 2.0 (the "License");
531 * you may not use this file except in compliance with the License.
532 * You may obtain a copy of the License at
533 *
534 *   http://www.apache.org/licenses/LICENSE-2.0
535 *
536 * Unless required by applicable law or agreed to in writing, software
537 * distributed under the License is distributed on an "AS IS" BASIS,
538 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
539 * See the License for the specific language governing permissions and
540 * limitations under the License.
541 */async function Ol({appConfig:n,heartbeatServiceProvider:e},{fid:t}){const i=nr(n),s=rr(n),r=e.getImmediate({optional:!0});if(r){const c=await r.getHeartbeatsHeader();c&&s.append("x-firebase-client",c)}const o={fid:t,authVersion:er,appId:n.appId,sdkVersion:Zs},a={method:"POST",headers:s,body:JSON.stringify(o)},l=await or(()=>fetch(i,a));if(l.ok){const c=await l.json();return{fid:c.fid||t,registrationStatus:2,refreshToken:c.refreshToken,authToken:ir(c.authToken)}}else throw await sr("Create Installation",l)}/**
542 * @license
543 * Copyright 2019 Google LLC
544 *
545 * Licensed under the Apache License, Version 2.0 (the "License");
546 * you may not use this file except in compliance with the License.
547 * You may obtain a copy of the License at
548 *
549 *   http://www.apache.org/licenses/LICENSE-2.0
550 *
551 * Unless required by applicable law or agreed to in writing, software
552 * distributed under the License is distributed on an "AS IS" BASIS,
553 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
554 * See the License for the specific language governing permissions and
555 * limitations under the License.
556 */function ar(n){return new Promise(e=>{setTimeout(e,n)})}/**
557 * @license
558 * Copyright 2019 Google LLC
559 *
560 * Licensed under the Apache License, Version 2.0 (the "License");
561 * you may not use this file except in compliance with the License.
562 * You may obtain a copy of the License at
563 *
564 *   http://www.apache.org/licenses/LICENSE-2.0
565 *
566 * Unless required by applicable law or agreed to in writing, software
567 * distributed under the License is distributed on an "AS IS" BASIS,
568 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
569 * See the License for the specific language governing permissions and
570 * limitations under the License.
571 */function Ml(n){return btoa(String.fromCharCode(...n)).replace(/\+/g,"-").replace(/\//g,"_")}/**
572 * @license
573 * Copyright 2019 Google LLC
574 *
575 * Licensed under the Apache License, Version 2.0 (the "License");
576 * you may not use this file except in compliance with the License.
577 * You may obtain a copy of the License at
578 *
579 *   http://www.apache.org/licenses/LICENSE-2.0
580 *
581 * Unless required by applicable law or agreed to in writing, software
582 * distributed under the License is distributed on an "AS IS" BASIS,
583 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
584 * See the License for the specific language governing permissions and
585 * limitations under the License.
586 */const Ll=/^[cdef][\w-]{21}$/,Tn="";function Fl(){try{const n=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(n),n[0]=112+n[0]%16;const t=Bl(n);return Ll.test(t)?t:Tn}catch{return Tn}}function Bl(n){return Ml(n).substr(0,22)}/**
587 * @license
588 * Copyright 2019 Google LLC
589 *
590 * Licensed under the Apache License, Version 2.0 (the "License");
591 * you may not use this file except in compliance with the License.
592 * You may obtain a copy of the License at
593 *
594 *   http://www.apache.org/licenses/LICENSE-2.0
595 *
596 * Unless required by applicable law or agreed to in writing, software
597 * distributed under the License is distributed on an "AS IS" BASIS,
598 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
599 * See the License for the specific language governing permissions and
600 * limitations under the License.
601 */function Bt(n){return`${n.appName}!${n.appId}`}/**
602 * @license
603 * Copyright 2019 Google LLC
604 *
605 * Licensed under the Apache License, Version 2.0 (the "License");
606 * you may not use this file except in compliance with the License.
607 * You may obtain a copy of the License at
608 *
609 *   http://www.apache.org/licenses/LICENSE-2.0
610 *
611 * Unless required by applicable law or agreed to in writing, software
612 * distributed under the License is distributed on an "AS IS" BASIS,
613 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
614 * See the License for the specific language governing permissions and
615 * limitations under the License.
616 */const lr=new Map;function cr(n,e){const t=Bt(n);hr(t,e),Wl(t,e)}function hr(n,e){const t=lr.get(n);if(t)for(const i of t)i(e)}function Wl(n,e){const t=$l();t&&t.postMessage({key:n,fid:e}),Ul()}let ue=null;function $l(){return!ue&&"BroadcastChannel"in self&&(ue=new BroadcastChannel("[Firebase] FID Change"),ue.onmessage=n=>{hr(n.data.key,n.data.fid)}),ue}function Ul(){lr.size===0&&ue&&(ue.close(),ue=null)}/**
617 * @license
618 * Copyright 2019 Google LLC
619 *
620 * Licensed under the Apache License, Version 2.0 (the "License");
621 * you may not use this file except in compliance with the License.
622 * You may obtain a copy of the License at
623 *
624 *   http://www.apache.org/licenses/LICENSE-2.0
625 *
626 * Unless required by applicable law or agreed to in writing, software
627 * distributed under the License is distributed on an "AS IS" BASIS,
628 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
629 * See the License for the specific language governing permissions and
630 * limitations under the License.
631 */const Vl="firebase-installations-database",Hl=1,ge="firebase-installations-store";let an=null;function Kn(){return an||(an=Il(Vl,Hl,{upgrade:(n,e)=>{switch(e){case 0:n.createObjectStore(ge)}}})),an}async function vt(n,e){const t=Bt(n),s=(await Kn()).transaction(ge,"readwrite"),r=s.objectStore(ge),o=await r.get(t);return await r.put(e,t),await s.done,(!o||o.fid!==e.fid)&&cr(n,e.fid),e}async function ur(n){const e=Bt(n),i=(await Kn()).transaction(ge,"readwrite");await i.objectStore(ge).delete(e),await i.done}async function Wt(n,e){const t=Bt(n),s=(await Kn()).transaction(ge,"readwrite"),r=s.objectStore(ge),o=await r.get(t),a=e(o);return a===void 0?await r.delete(t):await r.put(a,t),await s.done,a&&(!o||o.fid!==a.fid)&&cr(n,a.fid),a}/**
632 * @license
633 * Copyright 2019 Google LLC
634 *
635 * Licensed under the Apache License, Version 2.0 (the "License");
636 * you may not use this file except in compliance with the License.
637 * You may obtain a copy of the License at
638 *
639 *   http://www.apache.org/licenses/LICENSE-2.0
640 *
641 * Unless required by applicable law or agreed to in writing, software
642 * distributed under the License is distributed on an "AS IS" BASIS,
643 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
644 * See the License for the specific language governing permissions and
645 * limitations under the License.
646 */async function Yn(n){let e;const t=await Wt(n.appConfig,i=>{const s=jl(i),r=Gl(n,s);return e=r.registrationPromise,r.installationEntry});return t.fid===Tn?{installationEntry:await e}:{installationEntry:t,registrationPromise:e}}function jl(n){const e=n||{fid:Fl(),registrationStatus:0};return dr(e)}function Gl(n,e){if(e.registrationStatus===0){if(!navigator.onLine){const s=Promise.reject(pe.create("app-offline"));return{installationEntry:e,registrationPromise:s}}const t={fid:e.fid,registrationStatus:1,registrationTime:Date.now()},i=zl(n,t);return{installationEntry:t,registrationPromise:i}}else return e.registrationStatus===1?{installationEntry:e,registrationPromise:ql(n)}:{installationEntry:e}}async function zl(n,e){try{const t=await Ol(n,e);return vt(n.appConfig,t)}catch(t){throw tr(t)&&t.customData.serverCode===409?await ur(n.appConfig):await vt(n.appConfig,{fid:e.fid,registrationStatus:0}),t}}async function ql(n){let e=await Gi(n.appConfig);for(;e.registrationStatus===1;)await ar(100),e=await Gi(n.appConfig);if(e.registrationStatus===0){const{installationEntry:t,registrationPromise:i}=await Yn(n);return i||t}return e}function Gi(n){return Wt(n,e=>{if(!e)throw pe.create("installation-not-found");return dr(e)})}function dr(n){return Kl(n)?{fid:n.fid,registrationStatus:0}:n}function Kl(n){return n.registrationStatus===1&&n.registrationTime+Js<Date.now()}/**
647 * @license
648 * Copyright 2019 Google LLC
649 *
650 * Licensed under the Apache License, Version 2.0 (the "License");
651 * you may not use this file except in compliance with the License.
652 * You may obtain a copy of the License at
653 *
654 *   http://www.apache.org/licenses/LICENSE-2.0
655 *
656 * Unless required by applicable law or agreed to in writing, software
657 * distributed under the License is distributed on an "AS IS" BASIS,
658 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
659 * See the License for the specific language governing permissions and
660 * limitations under the License.
661 */async function Yl({appConfig:n,heartbeatServiceProvider:e},t){const i=Ql(n,t),s=Dl(n,t),r=e.getImmediate({optional:!0});if(r){const c=await r.getHeartbeatsHeader();c&&s.append("x-firebase-client",c)}const o={installation:{sdkVersion:Zs,appId:n.appId}},a={method:"POST",headers:s,body:JSON.stringify(o)},l=await or(()=>fetch(i,a));if(l.ok){const c=await l.json();return ir(c)}else throw await sr("Generate Auth Token",l)}function Ql(n,{fid:e}){return`${nr(n)}/${e}/authTokens:generate`}/**
662 * @license
663 * Copyright 2019 Google LLC
664 *
665 * Licensed under the Apache License, Version 2.0 (the "License");
666 * you may not use this file except in compliance with the License.
667 * You may obtain a copy of the License at
668 *
669 *   http://www.apache.org/licenses/LICENSE-2.0
670 *
671 * Unless required by applicable law or agreed to in writing, software
672 * distributed under the License is distributed on an "AS IS" BASIS,
673 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
674 * See the License for the specific language governing permissions and
675 * limitations under the License.
676 */async function Qn(n,e=!1){let t;const i=await Wt(n.appConfig,r=>{if(!fr(r))throw pe.create("not-registered");const o=r.authToken;if(!e&&Zl(o))return r;if(o.requestStatus===1)return t=Xl(n,e),r;{if(!navigator.onLine)throw pe.create("app-offline");const a=tc(r);return t=Jl(n,a),a}});return t?await t:i.authToken}async function Xl(n,e){let t=await zi(n.appConfig);for(;t.authToken.requestStatus===1;)await ar(100),t=await zi(n.appConfig);const i=t.authToken;return i.requestStatus===0?Qn(n,e):i}function zi(n){return Wt(n,e=>{if(!fr(e))throw pe.create("not-registered");const t=e.authToken;return nc(t)?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e})}async function Jl(n,e){try{const t=await Yl(n,e),i=Object.assign(Object.assign({},e),{authToken:t});return await vt(n.appConfig,i),t}catch(t){if(tr(t)&&(t.customData.serverCode===401||t.customData.serverCode===404))await ur(n.appConfig);else{const i=Object.assign(Object.assign({},e),{authToken:{requestStatus:0}});await vt(n.appConfig,i)}throw t}}function fr(n){return n!==void 0&&n.registrationStatus===2}function Zl(n){return n.requestStatus===2&&!ec(n)}function ec(n){const e=Date.now();return e<n.creationTime||n.creationTime+n.expiresIn<e+Nl}function tc(n){const e={requestStatus:1,requestTime:Date.now()};return Object.assign(Object.assign({},n),{authToken:e})}function nc(n){return n.requestStatus===1&&n.requestTime+Js<Date.now()}/**
677 * @license
678 * Copyright 2019 Google LLC
679 *
680 * Licensed under the Apache License, Version 2.0 (the "License");
681 * you may not use this file except in compliance with the License.
682 * You may obtain a copy of the License at
683 *
684 *   http://www.apache.org/licenses/LICENSE-2.0
685 *
686 * Unless required by applicable law or agreed to in writing, software
687 * distributed under the License is distributed on an "AS IS" BASIS,
688 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
689 * See the License for the specific language governing permissions and
690 * limitations under the License.
691 */async function ic(n){const e=n,{installationEntry:t,registrationPromise:i}=await Yn(e);return i?i.catch(console.error):Qn(e).catch(console.error),t.fid}/**
692 * @license
693 * Copyright 2019 Google LLC
694 *
695 * Licensed under the Apache License, Version 2.0 (the "License");
696 * you may not use this file except in compliance with the License.
697 * You may obtain a copy of the License at
698 *
699 *   http://www.apache.org/licenses/LICENSE-2.0
700 *
701 * Unless required by applicable law or agreed to in writing, software
702 * distributed under the License is distributed on an "AS IS" BASIS,
703 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
704 * See the License for the specific language governing permissions and
705 * limitations under the License.
706 */async function sc(n,e=!1){const t=n;return await rc(t),(await Qn(t,e)).token}async function rc(n){const{registrationPromise:e}=await Yn(n);e&&await e}/**
707 * @license
708 * Copyright 2019 Google LLC
709 *
710 * Licensed under the Apache License, Version 2.0 (the "License");
711 * you may not use this file except in compliance with the License.
712 * You may obtain a copy of the License at
713 *
714 *   http://www.apache.org/licenses/LICENSE-2.0
715 *
716 * Unless required by applicable law or agreed to in writing, software
717 * distributed under the License is distributed on an "AS IS" BASIS,
718 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
719 * See the License for the specific language governing permissions and
720 * limitations under the License.
721 */function oc(n){if(!n||!n.options)throw ln("App Configuration");if(!n.name)throw ln("App Name");const e=["projectId","apiKey","appId"];for(const t of e)if(!n.options[t])throw ln(t);return{appName:n.name,projectId:n.options.projectId,apiKey:n.options.apiKey,appId:n.options.appId}}function ln(n){return pe.create("missing-app-config-values",{valueName:n})}/**
722 * @license
723 * Copyright 2020 Google LLC
724 *
725 * Licensed under the Apache License, Version 2.0 (the "License");
726 * you may not use this file except in compliance with the License.
727 * You may obtain a copy of the License at
728 *
729 *   http://www.apache.org/licenses/LICENSE-2.0
730 *
731 * Unless required by applicable law or agreed to in writing, software
732 * distributed under the License is distributed on an "AS IS" BASIS,
733 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
734 * See the License for the specific language governing permissions and
735 * limitations under the License.
736 */const _r="installations",ac="installations-internal",lc=n=>{const e=n.getProvider("app").getImmediate(),t=oc(e),i=rt(e,"heartbeat");return{app:e,appConfig:t,heartbeatServiceProvider:i,_delete:()=>Promise.resolve()}},cc=n=>{const e=n.getProvider("app").getImmediate(),t=rt(e,_r).getImmediate();return{getId:()=>ic(t),getToken:s=>sc(t,s)}};function hc(){se(new Q(_r,lc,"PUBLIC")),se(new Q(ac,cc,"PRIVATE"))}hc();G(Xs,qn);G(Xs,qn,"esm2017");/**
737 * @license
738 * Copyright 2019 Google LLC
739 *
740 * Licensed under the Apache License, Version 2.0 (the "License");
741 * you may not use this file except in compliance with the License.
742 * You may obtain a copy of the License at
743 *
744 *   http://www.apache.org/licenses/LICENSE-2.0
745 *
746 * Unless required by applicable law or agreed to in writing, software
747 * distributed under the License is distributed on an "AS IS" BASIS,
748 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
749 * See the License for the specific language governing permissions and
750 * limitations under the License.
751 */const Ct="analytics",uc="firebase_id",dc="origin",fc=60*1e3,_c="https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig",Xn="https://www.googletagmanager.com/gtag/js";/**
752 * @license
753 * Copyright 2019 Google LLC
754 *
755 * Licensed under the Apache License, Version 2.0 (the "License");
756 * you may not use this file except in compliance with the License.
757 * You may obtain a copy of the License at
758 *
759 *   http://www.apache.org/licenses/LICENSE-2.0
760 *
761 * Unless required by applicable law or agreed to in writing, software
762 * distributed under the License is distributed on an "AS IS" BASIS,
763 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
764 * See the License for the specific language governing permissions and
765 * limitations under the License.
766 */const B=new jn("@firebase/analytics");/**
767 * @license
768 * Copyright 2019 Google LLC
769 *
770 * Licensed under the Apache License, Version 2.0 (the "License");
771 * you may not use this file except in compliance with the License.
772 * You may obtain a copy of the License at
773 *
774 *   http://www.apache.org/licenses/LICENSE-2.0
775 *
776 * Unless required by applicable law or agreed to in writing, software
777 * distributed under the License is distributed on an "AS IS" BASIS,
778 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
779 * See the License for the specific language governing permissions and
780 * limitations under the License.
781 */const pc={"already-exists":"A Firebase Analytics instance with the appId {$id}  already exists. Only one Firebase Analytics instance can be created for each appId.","already-initialized":"initializeAnalytics() cannot be called again with different options than those it was initially called with. It can be called again with the same options to return the existing instance, or getAnalytics() can be used to get a reference to the already-intialized instance.","already-initialized-settings":"Firebase Analytics has already been initialized.settings() must be called before initializing any Analytics instanceor it will have no effect.","interop-component-reg-failed":"Firebase Analytics Interop Component failed to instantiate: {$reason}","invalid-analytics-context":"Firebase Analytics is not supported in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","indexeddb-unavailable":"IndexedDB unavailable or restricted in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","fetch-throttle":"The config fetch request timed out while in an exponential backoff state. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.","config-fetch-failed":"Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}","no-api-key":'The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid API key.',"no-app-id":'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid app ID.',"no-client-id":'The "client_id" field is empty.',"invalid-gtag-resource":"Trusted Types detected an invalid gtag resource: {$gtagURL}."},W=new Mt("analytics","Analytics",pc);/**
782 * @license
783 * Copyright 2019 Google LLC
784 *
785 * Licensed under the Apache License, Version 2.0 (the "License");
786 * you may not use this file except in compliance with the License.
787 * You may obtain a copy of the License at
788 *
789 *   http://www.apache.org/licenses/LICENSE-2.0
790 *
791 * Unless required by applicable law or agreed to in writing, software
792 * distributed under the License is distributed on an "AS IS" BASIS,
793 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
794 * See the License for the specific language governing permissions and
795 * limitations under the License.
796 */function gc(n){if(!n.startsWith(Xn)){const e=W.create("invalid-gtag-resource",{gtagURL:n});return B.warn(e.message),""}return n}function pr(n){return Promise.all(n.map(e=>e.catch(t=>t)))}function mc(n,e){let t;return window.trustedTypes&&(t=window.trustedTypes.createPolicy(n,e)),t}function yc(n,e){const t=mc("firebase-js-sdk-policy",{createScriptURL:gc}),i=document.createElement("script"),s=`${Xn}?l=${n}&id=${e}`;i.src=t?t==null?void 0:t.createScriptURL(s):s,i.async=!0,document.head.appendChild(i)}function vc(n){let e=[];return Array.isArray(window[n])?e=window[n]:window[n]=e,e}async function Cc(n,e,t,i,s,r){const o=i[s];try{if(o)await e[o];else{const l=(await pr(t)).find(c=>c.measurementId===s);l&&await e[l.appId]}}catch(a){B.error(a)}n("config",s,r)}async function Ec(n,e,t,i,s){try{let r=[];if(s&&s.send_to){let o=s.send_to;Array.isArray(o)||(o=[o]);const a=await pr(t);for(const l of o){const c=a.find(h=>h.measurementId===l),u=c&&e[c.appId];if(u)r.push(u);else{r=[];break}}}r.length===0&&(r=Object.values(e)),await Promise.all(r),n("event",i,s||{})}catch(r){B.error(r)}}function wc(n,e,t,i){async function s(r,...o){try{if(r==="event"){const[a,l]=o;await Ec(n,e,t,a,l)}else if(r==="config"){const[a,l]=o;await Cc(n,e,t,i,a,l)}else if(r==="consent"){const[a]=o;n("consent","update",a)}else if(r==="get"){const[a,l,c]=o;n("get",a,l,c)}else if(r==="set"){const[a]=o;n("set",a)}else n(r,...o)}catch(a){B.error(a)}}return s}function Ic(n,e,t,i,s){let r=function(...o){window[i].push(arguments)};return window[s]&&typeof window[s]=="function"&&(r=window[s]),window[s]=wc(r,n,e,t),{gtagCore:r,wrappedGtag:window[s]}}function bc(n){const e=window.document.getElementsByTagName("script");for(const t of Object.values(e))if(t.src&&t.src.includes(Xn)&&t.src.includes(n))return t;return null}/**
797 * @license
798 * Copyright 2020 Google LLC
799 *
800 * Licensed under the Apache License, Version 2.0 (the "License");
801 * you may not use this file except in compliance with the License.
802 * You may obtain a copy of the License at
803 *
804 *   http://www.apache.org/licenses/LICENSE-2.0
805 *
806 * Unless required by applicable law or agreed to in writing, software
807 * distributed under the License is distributed on an "AS IS" BASIS,
808 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
809 * See the License for the specific language governing permissions and
810 * limitations under the License.
811 */const Tc=30,Sc=1e3;class Nc{constructor(e={},t=Sc){this.throttleMetadata=e,this.intervalMillis=t}getThrottleMetadata(e){return this.throttleMetadata[e]}setThrottleMetadata(e,t){this.throttleMetadata[e]=t}deleteThrottleMetadata(e){delete this.throttleMetadata[e]}}const gr=new Nc;function Rc(n){return new Headers({Accept:"application/json","x-goog-api-key":n})}async function Ac(n){var e;const{appId:t,apiKey:i}=n,s={method:"GET",headers:Rc(i)},r=_c.replace("{app-id}",t),o=await fetch(r,s);if(o.status!==200&&o.status!==304){let a="";try{const l=await o.json();!((e=l.error)===null||e===void 0)&&e.message&&(a=l.error.message)}catch{}throw W.create("config-fetch-failed",{httpStatus:o.status,responseMessage:a})}return o.json()}async function kc(n,e=gr,t){const{appId:i,apiKey:s,measurementId:r}=n.options;if(!i)throw W.create("no-app-id");if(!s){if(r)return{measurementId:r,appId:i};throw W.create("no-api-key")}const o=e.getThrottleMetadata(i)||{backoffCount:0,throttleEndTimeMillis:Date.now()},a=new Pc;return setTimeout(async()=>{a.abort()},t!==void 0?t:fc),mr({appId:i,apiKey:s,measurementId:r},o,a,e)}async function mr(n,{throttleEndTimeMillis:e,backoffCount:t},i,s=gr){var r;const{appId:o,measurementId:a}=n;try{await Dc(i,e)}catch(l){if(a)return B.warn(`Timed out fetching this Firebase app's measurement ID from the server. Falling back to the measurement ID ${a} provided in the "measurementId" field in the local Firebase config. [${l==null?void 0:l.message}]`),{appId:o,measurementId:a};throw l}try{const l=await Ac(n);return s.deleteThrottleMetadata(o),l}catch(l){const c=l;if(!xc(c)){if(s.deleteThrottleMetadata(o),a)return B.warn(`Failed to fetch this Firebase app's measurement ID from the server. Falling back to the measurement ID ${a} provided in the "measurementId" field in the local Firebase config. [${c==null?void 0:c.message}]`),{appId:o,measurementId:a};throw l}const u=Number((r=c==null?void 0:c.customData)===null||r===void 0?void 0:r.httpStatus)===503?Oi(t,s.intervalMillis,Tc):Oi(t,s.intervalMillis),h={throttleEndTimeMillis:Date.now()+u,backoffCount:t+1};return s.setThrottleMetadata(o,h),B.debug(`Calling attemptFetch again in ${u} millis`),mr(n,h,i,s)}}function Dc(n,e){return new Promise((t,i)=>{const s=Math.max(e-Date.now(),0),r=setTimeout(t,s);n.addEventListener(()=>{clearTimeout(r),i(W.create("fetch-throttle",{throttleEndTimeMillis:e}))})})}function xc(n){if(!(n instanceof Ce)||!n.customData)return!1;const e=Number(n.customData.httpStatus);return e===429||e===500||e===503||e===504}class Pc{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}async function Oc(n,e,t,i,s){if(s&&s.global){n("event",t,i);return}else{const r=await e,o=Object.assign(Object.assign({},i),{send_to:r});n("event",t,o)}}/**
812 * @license
813 * Copyright 2020 Google LLC
814 *
815 * Licensed under the Apache License, Version 2.0 (the "License");
816 * you may not use this file except in compliance with the License.
817 * You may obtain a copy of the License at
818 *
819 *   http://www.apache.org/licenses/LICENSE-2.0
820 *
821 * Unless required by applicable law or agreed to in writing, software
822 * distributed under the License is distributed on an "AS IS" BASIS,
823 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
824 * See the License for the specific language governing permissions and
825 * limitations under the License.
826 */async function Mc(){if(Vn())try{await Hn()}catch(n){return B.warn(W.create("indexeddb-unavailable",{errorInfo:n==null?void 0:n.toString()}).message),!1}else return B.warn(W.create("indexeddb-unavailable",{errorInfo:"IndexedDB is not available in this environment."}).message),!1;return!0}async function Lc(n,e,t,i,s,r,o){var a;const l=kc(n);l.then(_=>{t[_.measurementId]=_.appId,n.options.measurementId&&_.measurementId!==n.options.measurementId&&B.warn(`The measurement ID in the local Firebase config (${n.options.measurementId}) does not match the measurement ID fetched from the server (${_.measurementId}). To ensure analytics events are always sent to the correct Analytics property, update the measurement ID field in the local config or remove it from the local config.`)}).catch(_=>B.error(_)),e.push(l);const c=Mc().then(_=>{if(_)return i.getId()}),[u,h]=await Promise.all([l,c]);bc(r)||yc(r,u.measurementId),s("js",new Date);const d=(a=o==null?void 0:o.config)!==null&&a!==void 0?a:{};return d[dc]="firebase",d.update=!0,h!=null&&(d[uc]=h),s("config",u.measurementId,d),u.measurementId}/**
827 * @license
828 * Copyright 2019 Google LLC
829 *
830 * Licensed under the Apache License, Version 2.0 (the "License");
831 * you may not use this file except in compliance with the License.
832 * You may obtain a copy of the License at
833 *
834 *   http://www.apache.org/licenses/LICENSE-2.0
835 *
836 * Unless required by applicable law or agreed to in writing, software
837 * distributed under the License is distributed on an "AS IS" BASIS,
838 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
839 * See the License for the specific language governing permissions and
840 * limitations under the License.
841 */class Fc{constructor(e){this.app=e}_delete(){return delete je[this.app.options.appId],Promise.resolve()}}let je={},qi=[];const Ki={};let cn="dataLayer",Bc="gtag",Yi,yr,Qi=!1;function Wc(){const n=[];if(Ws()&&n.push("This is a browser extension environment."),Us()||n.push("Cookies are not available."),n.length>0){const e=n.map((i,s)=>`(${s+1}) ${i}`).join(" "),t=W.create("invalid-analytics-context",{errorInfo:e});B.warn(t.message)}}function $c(n,e,t){Wc();const i=n.options.appId;if(!i)throw W.create("no-app-id");if(!n.options.apiKey)if(n.options.measurementId)B.warn(`The "apiKey" field is empty in the local Firebase config. This is needed to fetch the latest measurement ID for this Firebase app. Falling back to the measurement ID ${n.options.measurementId} provided in the "measurementId" field in the local Firebase config.`);else throw W.create("no-api-key");if(je[i]!=null)throw W.create("already-exists",{id:i});if(!Qi){vc(cn);const{wrappedGtag:r,gtagCore:o}=Ic(je,qi,Ki,cn,Bc);yr=r,Yi=o,Qi=!0}return je[i]=Lc(n,qi,Ki,e,Yi,cn,t),new Fc(n)}function Uc(n=zs()){n=le(n);const e=rt(n,Ct);return e.isInitialized()?e.getImmediate():Vc(n)}function Vc(n,e={}){const t=rt(n,Ct);if(t.isInitialized()){const s=t.getImmediate();if(mt(e,t.getOptions()))return s;throw W.create("already-initialized")}return t.initialize({options:e})}async function Hc(){if(Ws()||!Us()||!Vn())return!1;try{return await Hn()}catch{return!1}}function jc(n,e,t,i){n=le(n),Oc(yr,je[n.app.options.appId],e,t,i).catch(s=>B.error(s))}const Xi="@firebase/analytics",Ji="0.10.0";function Gc(){se(new Q(Ct,(e,{options:t})=>{const i=e.getProvider("app").getImmediate(),s=e.getProvider("installations-internal").getImmediate();return $c(i,s,t)},"PUBLIC")),se(new Q("analytics-internal",n,"PRIVATE")),G(Xi,Ji),G(Xi,Ji,"esm2017");function n(e){try{const t=e.getProvider(Ct).getImmediate();return{logEvent:(i,s,r)=>jc(t,i,s,r)}}catch(t){throw W.create("interop-component-reg-failed",{reason:t})}}}Gc();const Zi="@firebase/database",es="0.14.4";/**
842 * @license
843 * Copyright 2019 Google LLC
844 *
845 * Licensed under the Apache License, Version 2.0 (the "License");
846 * you may not use this file except in compliance with the License.
847 * You may obtain a copy of the License at
848 *
849 *   http://www.apache.org/licenses/LICENSE-2.0
850 *
851 * Unless required by applicable law or agreed to in writing, software
852 * distributed under the License is distributed on an "AS IS" BASIS,
853 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
854 * See the License for the specific language governing permissions and
855 * limitations under the License.
856 */let vr="";function zc(n){vr=n}/**
857 * @license
858 * Copyright 2017 Google LLC
859 *
860 * Licensed under the Apache License, Version 2.0 (the "License");
861 * you may not use this file except in compliance with the License.
862 * You may obtain a copy of the License at
863 *
864 *   http://www.apache.org/licenses/LICENSE-2.0
865 *
866 * Unless required by applicable law or agreed to in writing, software
867 * distributed under the License is distributed on an "AS IS" BASIS,
868 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
869 * See the License for the specific language governing permissions and
870 * limitations under the License.
871 */class qc{constructor(e){this.domStorage_=e,this.prefix_="firebase:"}set(e,t){t==null?this.domStorage_.removeItem(this.prefixedName_(e)):this.domStorage_.setItem(this.prefixedName_(e),A(t))}get(e){const t=this.domStorage_.getItem(this.prefixedName_(e));return t==null?null:Ye(t)}remove(e){this.domStorage_.removeItem(this.prefixedName_(e))}prefixedName_(e){return this.prefix_+e}toString(){return this.domStorage_.toString()}}/**
872 * @license
873 * Copyright 2017 Google LLC
874 *
875 * Licensed under the Apache License, Version 2.0 (the "License");
876 * you may not use this file except in compliance with the License.
877 * You may obtain a copy of the License at
878 *
879 *   http://www.apache.org/licenses/LICENSE-2.0
880 *
881 * Unless required by applicable law or agreed to in writing, software
882 * distributed under the License is distributed on an "AS IS" BASIS,
883 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
884 * See the License for the specific language governing permissions and
885 * limitations under the License.
886 */class Kc{constructor(){this.cache_={},this.isInMemoryStorage=!0}set(e,t){t==null?delete this.cache_[e]:this.cache_[e]=t}get(e){return z(this.cache_,e)?this.cache_[e]:null}remove(e){delete this.cache_[e]}}/**
887 * @license
888 * Copyright 2017 Google LLC
889 *
890 * Licensed under the Apache License, Version 2.0 (the "License");
891 * you may not use this file except in compliance with the License.
892 * You may obtain a copy of the License at
893 *
894 *   http://www.apache.org/licenses/LICENSE-2.0
895 *
896 * Unless required by applicable law or agreed to in writing, software
897 * distributed under the License is distributed on an "AS IS" BASIS,
898 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
899 * See the License for the specific language governing permissions and
900 * limitations under the License.
901 */const Cr=function(n){try{if(typeof window<"u"&&typeof window[n]<"u"){const e=window[n];return e.setItem("firebase:sentinel","cache"),e.removeItem("firebase:sentinel"),new qc(e)}}catch{}return new Kc},de=Cr("localStorage"),Sn=Cr("sessionStorage");/**
902 * @license
903 * Copyright 2017 Google LLC
904 *
905 * Licensed under the Apache License, Version 2.0 (the "License");
906 * you may not use this file except in compliance with the License.
907 * You may obtain a copy of the License at
908 *
909 *   http://www.apache.org/licenses/LICENSE-2.0
910 *
911 * Unless required by applicable law or agreed to in writing, software
912 * distributed under the License is distributed on an "AS IS" BASIS,
913 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
914 * See the License for the specific language governing permissions and
915 * limitations under the License.
916 */const Se=new jn("@firebase/database"),Yc=function(){let n=1;return function(){return n++}}(),Er=function(n){const e=sa(n),t=new ta;t.update(e);const i=t.digest();return $n.encodeByteArray(i)},ot=function(...n){let e="";for(let t=0;t<n.length;t++){const i=n[t];Array.isArray(i)||i&&typeof i=="object"&&typeof i.length=="number"?e+=ot.apply(null,i):typeof i=="object"?e+=A(i):e+=i,e+=" "}return e};let fe=null,ts=!0;const Qc=function(n,e){f(!e||n===!0||n===!1,"Can't turn on custom loggers persistently."),n===!0?(Se.logLevel=b.VERBOSE,fe=Se.log.bind(Se),e&&Sn.set("logging_enabled",!0)):typeof n=="function"?fe=n:(fe=null,Sn.remove("logging_enabled"))},x=function(...n){if(ts===!0&&(ts=!1,fe===null&&Sn.get("logging_enabled")===!0&&Qc(!0)),fe){const e=ot.apply(null,n);fe(e)}},at=function(n){return function(...e){x(n,...e)}},Nn=function(...n){const e="FIREBASE INTERNAL ERROR: "+ot(...n);Se.error(e)},X=function(...n){const e=`FIREBASE FATAL ERROR: ${ot(...n)}`;throw Se.error(e),new Error(e)},L=function(...n){const e="FIREBASE WARNING: "+ot(...n);Se.warn(e)},Xc=function(){typeof window<"u"&&window.location&&window.location.protocol&&window.location.protocol.indexOf("https:")!==-1&&L("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().")},Jn=function(n){return typeof n=="number"&&(n!==n||n===Number.POSITIVE_INFINITY||n===Number.NEGATIVE_INFINITY)},Jc=function(n){if(document.readyState==="complete")n();else{let e=!1;const t=function(){if(!document.body){setTimeout(t,Math.floor(10));return}e||(e=!0,n())};document.addEventListener?(document.addEventListener("DOMContentLoaded",t,!1),window.addEventListener("load",t,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",()=>{document.readyState==="complete"&&t()}),window.attachEvent("onload",t))}},ke="[MIN_NAME]",me="[MAX_NAME]",Ee=function(n,e){if(n===e)return 0;if(n===ke||e===me)return-1;if(e===ke||n===me)return 1;{const t=ns(n),i=ns(e);return t!==null?i!==null?t-i===0?n.length-e.length:t-i:-1:i!==null?1:n<e?-1:1}},Zc=function(n,e){return n===e?0:n<e?-1:1},$e=function(n,e){if(e&&n in e)return e[n];throw new Error("Missing required key ("+n+") in object: "+A(e))},Zn=function(n){if(typeof n!="object"||n===null)return A(n);const e=[];for(const i in n)e.push(i);e.sort();let t="{";for(let i=0;i<e.length;i++)i!==0&&(t+=","),t+=A(e[i]),t+=":",t+=Zn(n[e[i]]);return t+="}",t},wr=function(n,e){const t=n.length;if(t<=e)return[n];const i=[];for(let s=0;s<t;s+=e)s+e>t?i.push(n.substring(s,t)):i.push(n.substring(s,s+e));return i};function P(n,e){for(const t in n)n.hasOwnProperty(t)&&e(t,n[t])}const Ir=function(n){f(!Jn(n),"Invalid JSON number");const e=11,t=52,i=(1<<e-1)-1;let s,r,o,a,l;n===0?(r=0,o=0,s=1/n===-1/0?1:0):(s=n<0,n=Math.abs(n),n>=Math.pow(2,1-i)?(a=Math.min(Math.floor(Math.log(n)/Math.LN2),i),r=a+i,o=Math.round(n*Math.pow(2,t-a)-Math.pow(2,t))):(r=0,o=Math.round(n/Math.pow(2,1-i-t))));const c=[];for(l=t;l;l-=1)c.push(o%2?1:0),o=Math.floor(o/2);for(l=e;l;l-=1)c.push(r%2?1:0),r=Math.floor(r/2);c.push(s?1:0),c.reverse();const u=c.join("");let h="";for(l=0;l<64;l+=8){let d=parseInt(u.substr(l,8),2).toString(16);d.length===1&&(d="0"+d),h=h+d}return h.toLowerCase()},eh=function(){return!!(typeof window=="object"&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href))},th=function(){return typeof Windows=="object"&&typeof Windows.UI=="object"};function nh(n,e){let t="Unknown Error";n==="too_big"?t="The data requested exceeds the maximum size that can be accessed with a single request.":n==="permission_denied"?t="Client doesn't have permission to access the desired data.":n==="unavailable"&&(t="The service is unavailable");const i=new Error(n+" at "+e._path.toString()+": "+t);return i.code=n.toUpperCase(),i}const ih=new RegExp("^-?(0*)\\d{1,10}$"),sh=-2147483648,rh=2147483647,ns=function(n){if(ih.test(n)){const e=Number(n);if(e>=sh&&e<=rh)return e}return null},Fe=function(n){try{n()}catch(e){setTimeout(()=>{const t=e.stack||"";throw L("Exception was thrown by user callback.",t),e},Math.floor(0))}},oh=function(){return(typeof window=="object"&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)>=0},Ge=function(n,e){const t=setTimeout(n,e);return typeof t=="number"&&typeof Deno<"u"&&Deno.unrefTimer?Deno.unrefTimer(t):typeof t=="object"&&t.unref&&t.unref(),t};/**
917 * @license
918 * Copyright 2021 Google LLC
919 *
920 * Licensed under the Apache License, Version 2.0 (the "License");
921 * you may not use this file except in compliance with the License.
922 * You may obtain a copy of the License at
923 *
924 *   http://www.apache.org/licenses/LICENSE-2.0
925 *
926 * Unless required by applicable law or agreed to in writing, software
927 * distributed under the License is distributed on an "AS IS" BASIS,
928 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
929 * See the License for the specific language governing permissions and
930 * limitations under the License.
931 */class ah{constructor(e,t){this.appName_=e,this.appCheckProvider=t,this.appCheck=t==null?void 0:t.getImmediate({optional:!0}),this.appCheck||t==null||t.get().then(i=>this.appCheck=i)}getToken(e){return this.appCheck?this.appCheck.getToken(e):new Promise((t,i)=>{setTimeout(()=>{this.appCheck?this.getToken(e).then(t,i):t(null)},0)})}addTokenChangeListener(e){var t;(t=this.appCheckProvider)===null||t===void 0||t.get().then(i=>i.addTokenListener(e))}notifyForInvalidToken(){L(`Provided AppCheck credentials for the app named "${this.appName_}" are invalid. This usually indicates your app was not initialized correctly.`)}}/**
932 * @license
933 * Copyright 2017 Google LLC
934 *
935 * Licensed under the Apache License, Version 2.0 (the "License");
936 * you may not use this file except in compliance with the License.
937 * You may obtain a copy of the License at
938 *
939 *   http://www.apache.org/licenses/LICENSE-2.0
940 *
941 * Unless required by applicable law or agreed to in writing, software
942 * distributed under the License is distributed on an "AS IS" BASIS,
943 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
944 * See the License for the specific language governing permissions and
945 * limitations under the License.
946 */class lh{constructor(e,t,i){this.appName_=e,this.firebaseOptions_=t,this.authProvider_=i,this.auth_=null,this.auth_=i.getImmediate({optional:!0}),this.auth_||i.onInit(s=>this.auth_=s)}getToken(e){return this.auth_?this.auth_.getToken(e).catch(t=>t&&t.code==="auth/token-not-initialized"?(x("Got auth/token-not-initialized error.  Treating as null token."),null):Promise.reject(t)):new Promise((t,i)=>{setTimeout(()=>{this.auth_?this.getToken(e).then(t,i):t(null)},0)})}addTokenChangeListener(e){this.auth_?this.auth_.addAuthTokenListener(e):this.authProvider_.get().then(t=>t.addAuthTokenListener(e))}removeTokenChangeListener(e){this.authProvider_.get().then(t=>t.removeAuthTokenListener(e))}notifyForInvalidToken(){let e='Provided authentication credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.firebaseOptions_?e+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.firebaseOptions_?e+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':e+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',L(e)}}class Ne{constructor(e){this.accessToken=e}getToken(e){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(e){e(this.accessToken)}removeTokenChangeListener(e){}notifyForInvalidToken(){}}Ne.OWNER="owner";/**
947 * @license
948 * Copyright 2017 Google LLC
949 *
950 * Licensed under the Apache License, Version 2.0 (the "License");
951 * you may not use this file except in compliance with the License.
952 * You may obtain a copy of the License at
953 *
954 *   http://www.apache.org/licenses/LICENSE-2.0
955 *
956 * Unless required by applicable law or agreed to in writing, software
957 * distributed under the License is distributed on an "AS IS" BASIS,
958 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
959 * See the License for the specific language governing permissions and
960 * limitations under the License.
961 */const ei="5",br="v",Tr="s",Sr="r",Nr="f",Rr=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,Ar="ls",kr="p",Rn="ac",Dr="websocket",xr="long_polling";/**
962 * @license
963 * Copyright 2017 Google LLC
964 *
965 * Licensed under the Apache License, Version 2.0 (the "License");
966 * you may not use this file except in compliance with the License.
967 * You may obtain a copy of the License at
968 *
969 *   http://www.apache.org/licenses/LICENSE-2.0
970 *
971 * Unless required by applicable law or agreed to in writing, software
972 * distributed under the License is distributed on an "AS IS" BASIS,
973 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
974 * See the License for the specific language governing permissions and
975 * limitations under the License.
976 */class Pr{constructor(e,t,i,s,r=!1,o="",a=!1,l=!1){this.secure=t,this.namespace=i,this.webSocketOnly=s,this.nodeAdmin=r,this.persistenceKey=o,this.includeNamespaceInQueryParams=a,this.isUsingEmulator=l,this._host=e.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=de.get("host:"+e)||this._host}isCacheableHost(){return this.internalHost.substr(0,2)==="s-"}isCustomHost(){return this._domain!=="firebaseio.com"&&this._domain!=="firebaseio-demo.com"}get host(){return this._host}set host(e){e!==this.internalHost&&(this.internalHost=e,this.isCacheableHost()&&de.set("host:"+this._host,this.internalHost))}toString(){let e=this.toURLString();return this.persistenceKey&&(e+="<"+this.persistenceKey+">"),e}toURLString(){const e=this.secure?"https://":"http://",t=this.includeNamespaceInQueryParams?`?ns=${this.namespace}`:"";return`${e}${this.host}/${t}`}}function ch(n){return n.host!==n.internalHost||n.isCustomHost()||n.includeNamespaceInQueryParams}function Or(n,e,t){f(typeof e=="string","typeof type must == string"),f(typeof t=="object","typeof params must == object");let i;if(e===Dr)i=(n.secure?"wss://":"ws://")+n.internalHost+"/.ws?";else if(e===xr)i=(n.secure?"https://":"http://")+n.internalHost+"/.lp?";else throw new Error("Unknown connection type: "+e);ch(n)&&(t.ns=n.namespace);const s=[];return P(t,(r,o)=>{s.push(r+"="+o)}),i+s.join("&")}/**
977 * @license
978 * Copyright 2017 Google LLC
979 *
980 * Licensed under the Apache License, Version 2.0 (the "License");
981 * you may not use this file except in compliance with the License.
982 * You may obtain a copy of the License at
983 *
984 *   http://www.apache.org/licenses/LICENSE-2.0
985 *
986 * Unless required by applicable law or agreed to in writing, software
987 * distributed under the License is distributed on an "AS IS" BASIS,
988 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
989 * See the License for the specific language governing permissions and
990 * limitations under the License.
991 */class hh{constructor(){this.counters_={}}incrementCounter(e,t=1){z(this.counters_,e)||(this.counters_[e]=0),this.counters_[e]+=t}get(){return Wo(this.counters_)}}/**
992 * @license
993 * Copyright 2017 Google LLC
994 *
995 * Licensed under the Apache License, Version 2.0 (the "License");
996 * you may not use this file except in compliance with the License.
997 * You may obtain a copy of the License at
998 *
999 *   http://www.apache.org/licenses/LICENSE-2.0
1000 *
1001 * Unless required by applicable law or agreed to in writing, software
1002 * distributed under the License is distributed on an "AS IS" BASIS,
1003 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1004 * See the License for the specific language governing permissions and
1005 * limitations under the License.
1006 */const hn={},un={};function ti(n){const e=n.toString();return hn[e]||(hn[e]=new hh),hn[e]}function uh(n,e){const t=n.toString();return un[t]||(un[t]=e()),un[t]}/**
1007 * @license
1008 * Copyright 2017 Google LLC
1009 *
1010 * Licensed under the Apache License, Version 2.0 (the "License");
1011 * you may not use this file except in compliance with the License.
1012 * You may obtain a copy of the License at
1013 *
1014 *   http://www.apache.org/licenses/LICENSE-2.0
1015 *
1016 * Unless required by applicable law or agreed to in writing, software
1017 * distributed under the License is distributed on an "AS IS" BASIS,
1018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1019 * See the License for the specific language governing permissions and
1020 * limitations under the License.
1021 */class dh{constructor(e){this.onMessage_=e,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}closeAfter(e,t){this.closeAfterResponse=e,this.onClose=t,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)}handleResponse(e,t){for(this.pendingResponses[e]=t;this.pendingResponses[this.currentResponseNum];){const i=this.pendingResponses[this.currentResponseNum];delete this.pendingResponses[this.currentResponseNum];for(let s=0;s<i.length;++s)i[s]&&Fe(()=>{this.onMessage_(i[s])});if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}}/**
1022 * @license
1023 * Copyright 2017 Google LLC
1024 *
1025 * Licensed under the Apache License, Version 2.0 (the "License");
1026 * you may not use this file except in compliance with the License.
1027 * You may obtain a copy of the License at
1028 *
1029 *   http://www.apache.org/licenses/LICENSE-2.0
1030 *
1031 * Unless required by applicable law or agreed to in writing, software
1032 * distributed under the License is distributed on an "AS IS" BASIS,
1033 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1034 * See the License for the specific language governing permissions and
1035 * limitations under the License.
1036 */const is="start",fh="close",_h="pLPCommand",ph="pRTLPCB",Mr="id",Lr="pw",Fr="ser",gh="cb",mh="seg",yh="ts",vh="d",Ch="dframe",Br=1870,Wr=30,Eh=Br-Wr,wh=25e3,Ih=3e4;class Te{constructor(e,t,i,s,r,o,a){this.connId=e,this.repoInfo=t,this.applicationId=i,this.appCheckToken=s,this.authToken=r,this.transportSessionId=o,this.lastSessionId=a,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=at(e),this.stats_=ti(t),this.urlFn=l=>(this.appCheckToken&&(l[Rn]=this.appCheckToken),Or(t,xr,l))}open(e,t){this.curSegmentNum=0,this.onDisconnect_=t,this.myPacketOrderer=new dh(e),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null},Math.floor(Ih)),Jc(()=>{if(this.isClosed_)return;this.scriptTagHolder=new ni((...r)=>{const[o,a,l,c,u]=r;if(this.incrementIncomingBytes_(r),!!this.scriptTagHolder)if(this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,o===is)this.id=a,this.password=l;else if(o===fh)a?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(a,()=>{this.onClosed_()})):this.onClosed_();else throw new Error("Unrecognized command received: "+o)},(...r)=>{const[o,a]=r;this.incrementIncomingBytes_(r),this.myPacketOrderer.handleResponse(o,a)},()=>{this.onClosed_()},this.urlFn);const i={};i[is]="t",i[Fr]=Math.floor(Math.random()*1e8),this.scriptTagHolder.uniqueCallbackIdentifier&&(i[gh]=this.scriptTagHolder.uniqueCallbackIdentifier),i[br]=ei,this.transportSessionId&&(i[Tr]=this.transportSessionId),this.lastSessionId&&(i[Ar]=this.lastSessionId),this.applicationId&&(i[kr]=this.applicationId),this.appCheckToken&&(i[Rn]=this.appCheckToken),typeof location<"u"&&location.hostname&&Rr.test(location.hostname)&&(i[Sr]=Nr);const s=this.urlFn(i);this.log_("Connecting via long-poll to "+s),this.scriptTagHolder.addTag(s,()=>{})})}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){Te.forceAllow_=!0}static forceDisallow(){Te.forceDisallow_=!0}static isAvailable(){return Te.forceAllow_?!0:!Te.forceDisallow_&&typeof document<"u"&&document.createElement!=null&&!eh()&&!th()}markConnectionHealthy(){}shutdown_(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)}onClosed_(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))}close(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())}send(e){const t=A(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const i=Os(t),s=wr(i,Eh);for(let r=0;r<s.length;r++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,s.length,s[r]),this.curSegmentNum++}addDisconnectPingFrame(e,t){this.myDisconnFrame=document.createElement("iframe");const i={};i[Ch]="t",i[Mr]=e,i[Lr]=t,this.myDisconnFrame.src=this.urlFn(i),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}incrementIncomingBytes_(e){const t=A(e).length;this.bytesReceived+=t,this.stats_.incrementCounter("bytes_received",t)}}class ni{constructor(e,t,i,s){this.onDisconnect=i,this.urlFn=s,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(Math.random()*1e8),this.sendNewPolls=!0;{this.uniqueCallbackIdentifier=Yc(),window[_h+this.uniqueCallbackIdentifier]=e,window[ph+this.uniqueCallbackIdentifier]=t,this.myIFrame=ni.createIFrame_();let r="";this.myIFrame.src&&this.myIFrame.src.substr(0,11)==="javascript:"&&(r='<script>document.domain="'+document.domain+'";<\/script>');const o="<html><body>"+r+"</body></html>";
1036try{this.myIFrame.doc.open(),this.myIFrame.doc.write(o),this.myIFrame.doc.close()}catch(a){x("frame writing exception"),a.stack&&x(a.stack),x(a)}}}static createIFrame_(){const e=document.createElement("iframe");if(e.style.display="none",document.body){document.body.appendChild(e);try{e.contentWindow.document||x("No IE domain setting required")}catch{const i=document.domain;e.src="javascript:void((function(){document.open();document.domain='"+i+"';document.close();})())"}}else throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";return e.contentDocument?e.doc=e.contentDocument:e.contentWindow?e.doc=e.contentWindow.document:e.document&&(e.doc=e.document),e}close(){this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.textContent="",setTimeout(()=>{this.myIFrame!==null&&(document.body.removeChild(this.myIFrame),this.myIFrame=null)},Math.floor(0)));const e=this.onDisconnect;e&&(this.onDisconnect=null,e())}startLongPoll(e,t){for(this.myID=e,this.myPW=t,this.alive=!0;this.newRequest_(););}newRequest_(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(this.pendingSegs.length>0?2:1)){this.currentSerial++;const e={};e[Mr]=this.myID,e[Lr]=this.myPW,e[Fr]=this.currentSerial;let t=this.urlFn(e),i="",s=0;for(;this.pendingSegs.length>0&&this.pendingSegs[0].d.length+Wr+i.length<=Br;){const o=this.pendingSegs.shift();i=i+"&"+mh+s+"="+o.seg+"&"+yh+s+"="+o.ts+"&"+vh+s+"="+o.d,s++}return t=t+i,this.addLongPollTag_(t,this.currentSerial),!0}else return!1}enqueueSegment(e,t,i){this.pendingSegs.push({seg:e,ts:t,d:i}),this.alive&&this.newRequest_()}addLongPollTag_(e,t){this.outstandingRequests.add(t);const i=()=>{this.outstandingRequests.delete(t),this.newRequest_()},s=setTimeout(i,Math.floor(wh)),r=()=>{clearTimeout(s),i()};this.addTag(e,r)}addTag(e,t){setTimeout(()=>{try{if(!this.sendNewPolls)return;const i=this.myIFrame.doc.createElement("script");i.type="text/javascript",i.async=!0,i.src=e,i.onload=i.onreadystatechange=function(){const s=i.readyState;(!s||s==="loaded"||s==="complete")&&(i.onload=i.onreadystatechange=null,i.parentNode&&i.parentNode.removeChild(i),t())},i.onerror=()=>{x("Long-poll script failed to load: "+e),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(i)}catch{}},Math.floor(1))}}/**
1037 * @license
1038 * Copyright 2017 Google LLC
1039 *
1040 * Licensed under the Apache License, Version 2.0 (the "License");
1041 * you may not use this file except in compliance with the License.
1042 * You may obtain a copy of the License at
1043 *
1044 *   http://www.apache.org/licenses/LICENSE-2.0
1045 *
1046 * Unless required by applicable law or agreed to in writing, software
1047 * distributed under the License is distributed on an "AS IS" BASIS,
1048 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1049 * See the License for the specific language governing permissions and
1050 * limitations under the License.
1051 */const bh=16384,Th=45e3;let Et=null;typeof MozWebSocket<"u"?Et=MozWebSocket:typeof WebSocket<"u"&&(Et=WebSocket);class V{constructor(e,t,i,s,r,o,a){this.connId=e,this.applicationId=i,this.appCheckToken=s,this.authToken=r,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=at(this.connId),this.stats_=ti(t),this.connURL=V.connectionURL_(t,o,a,s,i),this.nodeAdmin=t.nodeAdmin}static connectionURL_(e,t,i,s,r){const o={};return o[br]=ei,typeof location<"u"&&location.hostname&&Rr.test(location.hostname)&&(o[Sr]=Nr),t&&(o[Tr]=t),i&&(o[Ar]=i),s&&(o[Rn]=s),r&&(o[kr]=r),Or(e,Dr,o)}open(e,t){this.onDisconnect=t,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,de.set("previous_websocket_failure",!0);try{let i;$s(),this.mySock=new Et(this.connURL,[],i)}catch(i){this.log_("Error instantiating WebSocket.");const s=i.message||i.data;s&&this.log_(s),this.onClosed_();return}this.mySock.onopen=()=>{this.log_("Websocket connected."),this.everConnected_=!0},this.mySock.onclose=()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=i=>{this.handleIncomingFrame(i)},this.mySock.onerror=i=>{this.log_("WebSocket error.  Closing connection.");const s=i.message||i.data;s&&this.log_(s),this.onClosed_()}}start(){}static forceDisallow(){V.forceDisallow_=!0}static isAvailable(){let e=!1;if(typeof navigator<"u"&&navigator.userAgent){const t=/Android ([0-9]{0,}\.[0-9]{0,})/,i=navigator.userAgent.match(t);i&&i.length>1&&parseFloat(i[1])<4.4&&(e=!0)}return!e&&Et!==null&&!V.forceDisallow_}static previouslyFailed(){return de.isInMemoryStorage||de.get("previous_websocket_failure")===!0}markConnectionHealthy(){de.remove("previous_websocket_failure")}appendFrame_(e){if(this.frames.push(e),this.frames.length===this.totalFrames){const t=this.frames.join("");this.frames=null;const i=Ye(t);this.onMessage(i)}}handleNewFrameCount_(e){this.totalFrames=e,this.frames=[]}extractFrameCount_(e){if(f(this.frames===null,"We already have a frame buffer"),e.length<=6){const t=Number(e);if(!isNaN(t))return this.handleNewFrameCount_(t),null}return this.handleNewFrameCount_(1),e}handleIncomingFrame(e){if(this.mySock===null)return;const t=e.data;if(this.bytesReceived+=t.length,this.stats_.incrementCounter("bytes_received",t.length),this.resetKeepAlive(),this.frames!==null)this.appendFrame_(t);else{const i=this.extractFrameCount_(t);i!==null&&this.appendFrame_(i)}}send(e){this.resetKeepAlive();const t=A(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const i=wr(t,bh);i.length>1&&this.sendString_(String(i.length));for(let s=0;s<i.length;s++)this.sendString_(i[s])}shutdown_(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)}onClosed_(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))}close(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())}resetKeepAlive(){clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(()=>{this.mySock&&this.sendString_("0"),this.resetKeepAlive()},Math.floor(Th))}sendString_(e){try{this.mySock.send(e)}catch(t){this.log_("Exception thrown from WebSocket.send():",t.message||t.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}}}V.responsesRequiredToBeHealthy=2;V.healthyTimeout=3e4;/**
1052 * @license
1053 * Copyright 2017 Google LLC
1054 *
1055 * Licensed under the Apache License, Version 2.0 (the "License");
1056 * you may not use this file except in compliance with the License.
1057 * You may obtain a copy of the License at
1058 *
1059 *   http://www.apache.org/licenses/LICENSE-2.0
1060 *
1061 * Unless required by applicable law or agreed to in writing, software
1062 * distributed under the License is distributed on an "AS IS" BASIS,
1063 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1064 * See the License for the specific language governing permissions and
1065 * limitations under the License.
1066 */class Xe{constructor(e){this.initTransports_(e)}static get ALL_TRANSPORTS(){return[Te,V]}static get IS_TRANSPORT_INITIALIZED(){return this.globalTransportInitialized_}initTransports_(e){const t=V&&V.isAvailable();let i=t&&!V.previouslyFailed();if(e.webSocketOnly&&(t||L("wss:// URL used, but browser isn't known to support websockets.  Trying anyway."),i=!0),i)this.transports_=[V];else{const s=this.transports_=[];for(const r of Xe.ALL_TRANSPORTS)r&&r.isAvailable()&&s.push(r);Xe.globalTransportInitialized_=!0}}initialTransport(){if(this.transports_.length>0)return this.transports_[0];throw new Error("No transports available")}upgradeTransport(){return this.transports_.length>1?this.transports_[1]:null}}Xe.globalTransportInitialized_=!1;/**
1067 * @license
1068 * Copyright 2017 Google LLC
1069 *
1070 * Licensed under the Apache License, Version 2.0 (the "License");
1071 * you may not use this file except in compliance with the License.
1072 * You may obtain a copy of the License at
1073 *
1074 *   http://www.apache.org/licenses/LICENSE-2.0
1075 *
1076 * Unless required by applicable law or agreed to in writing, software
1077 * distributed under the License is distributed on an "AS IS" BASIS,
1078 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1079 * See the License for the specific language governing permissions and
1080 * limitations under the License.
1081 */const Sh=6e4,Nh=5e3,Rh=10*1024,Ah=100*1024,dn="t",ss="d",kh="s",rs="r",Dh="e",os="o",as="a",ls="n",cs="p",xh="h";class Ph{constructor(e,t,i,s,r,o,a,l,c,u){this.id=e,this.repoInfo_=t,this.applicationId_=i,this.appCheckToken_=s,this.authToken_=r,this.onMessage_=o,this.onReady_=a,this.onDisconnect_=l,this.onKill_=c,this.lastSessionId=u,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=at("c:"+this.id+":"),this.transportManager_=new Xe(t),this.log_("Connection created"),this.start_()}start_(){const e=this.transportManager_.initialTransport();this.conn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,null,this.lastSessionId),this.primaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.conn_),i=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout(()=>{this.conn_&&this.conn_.open(t,i)},Math.floor(0));const s=e.healthyTimeout||0;s>0&&(this.healthyTimeout_=Ge(()=>{this.healthyTimeout_=null,this.isHealthy_||(this.conn_&&this.conn_.bytesReceived>Ah?(this.log_("Connection exceeded healthy timeout but has received "+this.conn_.bytesReceived+" bytes.  Marking connection healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()):this.conn_&&this.conn_.bytesSent>Rh?this.log_("Connection exceeded healthy timeout but has sent "+this.conn_.bytesSent+" bytes.  Leaving connection alive."):(this.log_("Closing unhealthy connection after timeout."),this.close()))},Math.floor(s)))}nextTransportId_(){return"c:"+this.id+":"+this.connectionCount++}disconnReceiver_(e){return t=>{e===this.conn_?this.onConnectionLost_(t):e===this.secondaryConn_?(this.log_("Secondary connection lost."),this.onSecondaryConnectionLost_()):this.log_("closing an old connection")}}connReceiver_(e){return t=>{this.state_!==2&&(e===this.rx_?this.onPrimaryMessageReceived_(t):e===this.secondaryConn_?this.onSecondaryMessageReceived_(t):this.log_("message on old connection"))}}sendRequest(e){const t={t:"d",d:e};this.sendData_(t)}tryCleanupConnection(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)}onSecondaryControl_(e){if(dn in e){const t=e[dn];t===as?this.upgradeIfSecondaryHealthy_():t===rs?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),(this.tx_===this.secondaryConn_||this.rx_===this.secondaryConn_)&&this.close()):t===os&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}}onSecondaryMessageReceived_(e){const t=$e("t",e),i=$e("d",e);if(t==="c")this.onSecondaryControl_(i);else if(t==="d")this.pendingDataMessages.push(i);else throw new Error("Unknown protocol layer: "+t)}upgradeIfSecondaryHealthy_(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t
vendor: 4,261 bytes, lines 1081-1091
1081:"c",d:{t:cs,d:{}}}))}proceedWithUpgrade_(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:as,d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:ls,d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()}onPrimaryMessageReceived_(e){const t=$e("t",e),i=$e("d",e);t==="c"?this.onControl_(i):t==="d"&&this.onDataMessage_(i)}onDataMessage_(e){this.onPrimaryResponse_(),this.onMessage_(e)}onPrimaryResponse_(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))}onControl_(e){const t=$e(dn,e);if(ss in e){const i=e[ss];if(t===xh){const s=Object.assign({},i);this.repoInfo_.isUsingEmulator&&(s.h=this.repoInfo_.host),this.onHandshake_(s)}else if(t===ls){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(let s=0;s<this.pendingDataMessages.length;++s)this.onDataMessage_(this.pendingDataMessages[s]);this.pendingDataMessages=[],this.tryCleanupConnection()}else t===kh?this.onConnectionShutdown_(i):t===rs?this.onReset_(i):t===Dh?Nn("Server Error: "+i):t===os?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):Nn("Unknown control packet command: "+t)}}onHandshake_(e){const t=e.ts,i=e.v,s=e.h;this.sessionId=e.s,this.repoInfo_.host=s,this.state_===0&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,t),ei!==i&&L("Protocol version mismatch detected"),this.tryStartUpgrade_())}tryStartUpgrade_(){const e=this.transportManager_.upgradeTransport();e&&this.startUpgrade_(e)}startUpgrade_(e){this.secondaryConn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,this.sessionId),this.secondaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.secondaryConn_),i=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(t,i),Ge(()=>{this.secondaryConn_&&(this.log_("Timed out trying to upgrade."),this.secondaryConn_.close())},Math.floor(Sh))}onReset_(e){this.log_("Reset packet received.  New host: "+e),this.repoInfo_.host=e,this.state_===1?this.close():(this.closeConnections_(),this.start_())}onConnectionEstablished_(e,t){this.log_("Realtime connection established."),this.conn_=e,this.state_=1,this.onReady_&&(this.onReady_(t,this.sessionId),this.onReady_=null),this.primaryResponsesRequired_===0?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):Ge(()=>{this.sendPingOnPrimaryIfNecessary_()},Math.floor(Nh))}sendPingOnPrimaryIfNecessary_(){!this.isHealthy_&&this.state_===1&&(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:cs,d:{}}}))}onSecondaryConnectionLost_(){const e=this.secondaryConn_;this.secondaryConn_=null,(this.tx_===e||this.rx_===e)&&this.close()}onConnectionLost_(e){this.conn_=null,!e&&this.state_===0?(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(de.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)):this.state_===1&&this.log_("Realtime connection lost."),this.close()}onConnectionShutdown_(e){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(e),this.onKill_=null),this.onDisconnect_=null,this.close()}sendData_(e){if(this.state_!==1)throw"Connection is not connected";this.tx_.send(e)}close(){this.state_!==2&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))}closeConnections_(){this.log_("Shutting down all connections"),this.conn_&&(this.conn_.close(),this.conn_=null),this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)}}/**
1082 * @license
1083 * Copyright 2017 Google LLC
1084 *
1085 * Licensed under the Apache License, Version 2.0 (the "License");
1086 * you may not use this file except in compliance with the License.
1087 * You may obtain a copy of the License at
1088 *
1089 *   http://www.apache.org/licenses/LICENSE-2.0
1090 *
1091 * Unless required by applicable law or agreed to in writing, softw
1091are
1092 * distributed under the License is distributed on an "AS IS" BASIS,
1093 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1094 * See the License for the specific language governing permissions and
1095 * limitations under the License.
1096 */class $r{put(e,t,i,s){}merge(e,t,i,s){}refreshAuthToken(e){}refreshAppCheckToken(e){}onDisconnectPut(e,t,i){}onDisconnectMerge(e,t,i){}onDisconnectCancel(e,t){}reportStats(e){}}/**
1097 * @license
1098 * Copyright 2017 Google LLC
1099 *
1100 * Licensed under the Apache License, Version 2.0 (the "License");
1101 * you may not use this file except in compliance with the License.
1102 * You may obtain a copy of the License at
1103 *
1104 *   http://www.apache.org/licenses/LICENSE-2.0
1105 *
1106 * Unless required by applicable law or agreed to in writing, software
1107 * distributed under the License is distributed on an "AS IS" BASIS,
1108 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1109 * See the License for the specific language governing permissions and
1110 * limitations under the License.
1111 */class Ur{constructor(e){this.allowedEvents_=e,this.listeners_={},f(Array.isArray(e)&&e.length>0,"Requires a non-empty array")}trigger(e,...t){if(Array.isArray(this.listeners_[e])){const i=[...this.listeners_[e]];for(let s=0;s<i.length;s++)i[s].callback.apply(i[s].context,t)}}on(e,t,i){this.validateEventType_(e),this.listeners_[e]=this.listeners_[e]||[],this.listeners_[e].push({callback:t,context:i});const s=this.getInitialEvent(e);s&&t.apply(i,s)}off(e,t,i){this.validateEventType_(e);const s=this.listeners_[e]||[];for(let r=0;r<s.length;r++)if(s[r].callback===t&&(!i||i===s[r].context)){s.splice(r,1);return}}validateEventType_(e){f(this.allowedEvents_.find(t=>t===e),"Unknown event: "+e)}}/**
1112 * @license
1113 * Copyright 2017 Google LLC
1114 *
1115 * Licensed under the Apache License, Version 2.0 (the "License");
1116 * you may not use this file except in compliance with the License.
1117 * You may obtain a copy of the License at
1118 *
1119 *   http://www.apache.org/licenses/LICENSE-2.0
1120 *
1121 * Unless required by applicable law or agreed to in writing, software
1122 * distributed under the License is distributed on an "AS IS" BASIS,
1123 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1124 * See the License for the specific language governing permissions and
1125 * limitations under the License.
1126 */class wt extends Ur{constructor(){super(["online"]),this.online_=!0,typeof window<"u"&&typeof window.addEventListener<"u"&&!Bs()&&(window.addEventListener("online",()=>{this.online_||(this.online_=!0,this.trigger("online",!0))},!1),window.addEventListener("offline",()=>{this.online_&&(this.online_=!1,this.trigger("online",!1))},!1))}static getInstance(){return new wt}getInitialEvent(e){return f(e==="online","Unknown event type: "+e),[this.online_]}currentlyOnline(){return this.online_}}/**
1127 * @license
1128 * Copyright 2017 Google LLC
1129 *
1130 * Licensed under the Apache License, Version 2.0 (the "License");
1131 * you may not use this file except in compliance with the License.
1132 * You may obtain a copy of the License at
1133 *
1134 *   http://www.apache.org/licenses/LICENSE-2.0
1135 *
1136 * Unless required by applicable law or agreed to in writing, software
1137 * distributed under the License is distributed on an "AS IS" BASIS,
1138 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1139 * See the License for the specific language governing permissions and
1140 * limitations under the License.
1141 */const hs=32,us=768;class E{constructor(e,t){if(t===void 0){this.pieces_=e.split("/");let i=0;for(let s=0;s<this.pieces_.length;s++)this.pieces_[s].length>0&&(this.pieces_[i]=this.pieces_[s],i++);this.pieces_.length=i,this.pieceNum_=0}else this.pieces_=e,this.pieceNum_=t}toString(){let e="";for(let t=this.pieceNum_;t<this.pieces_.length;t++)this.pieces_[t]!==""&&(e+="/"+this.pieces_[t]);return e||"/"}}function C(){return new E("")}function m(n){return n.pieceNum_>=n.pieces_.length?null:n.pieces_[n.pieceNum_]}function re(n){return n.pieces_.length-n.pieceNum_}function T(n){let e=n.pieceNum_;return e<n.pieces_.length&&e++,new E(n.pieces_,e)}function ii(n){return n.pieceNum_<n.pieces_.length?n.pieces_[n.pieces_.length-1]:null}function Oh(n){let e="";for(let t=n.pieceNum_;t<n.pieces_.length;t++)n.pieces_[t]!==""&&(e+="/"+encodeURIComponent(String(n.pieces_[t])));return e||"/"}function Je(n,e=0){return n.pieces_.slice(n.pieceNum_+e)}function Vr(n){if(n.pieceNum_>=n.pieces_.length)return null;const e=[];for(let t=n.pieceNum_;t<n.pieces_.length-1;t++)e.push(n.pieces_[t]);return new E(e,0)}function S(n,e){const t=[];for(let i=n.pieceNum_;i<n.pieces_.length;i++)t.push(n.pieces_[i]);if(e instanceof E)for(let i=e.pieceNum_;i<e.pieces_.length;i++)t.push(e.pieces_[i]);else{const i=e.split("/");for(let s=0;s<i.length;s++)i[s].length>0&&t.push(i[s])}return new E(t,0)}function v(n){return n.pieceNum_>=n.pieces_.length}function M(n,e){const t=m(n),i=m(e);if(t===null)return e;if(t===i)return M(T(n),T(e));
vendor: 12,069 bytes, lines 1141-1172
1141throw new Error("INTERNAL ERROR: innerPath ("+e+") is not within outerPath ("+n+")")}function Mh(n,e){const t=Je(n,0),i=Je(e,0);for(let s=0;s<t.length&&s<i.length;s++){const r=Ee(t[s],i[s]);if(r!==0)return r}return t.length===i.length?0:t.length<i.length?-1:1}function si(n,e){if(re(n)!==re(e))return!1;for(let t=n.pieceNum_,i=e.pieceNum_;t<=n.pieces_.length;t++,i++)if(n.pieces_[t]!==e.pieces_[i])return!1;return!0}function $(n,e){let t=n.pieceNum_,i=e.pieceNum_;if(re(n)>re(e))return!1;for(;t<n.pieces_.length;){if(n.pieces_[t]!==e.pieces_[i])return!1;++t,++i}return!0}class Lh{constructor(e,t){this.errorPrefix_=t,this.parts_=Je(e,0),this.byteLength_=Math.max(1,this.parts_.length);for(let i=0;i<this.parts_.length;i++)this.byteLength_+=Ft(this.parts_[i]);Hr(this)}}function Fh(n,e){n.parts_.length>0&&(n.byteLength_+=1),n.parts_.push(e),n.byteLength_+=Ft(e),Hr(n)}function Bh(n){const e=n.parts_.pop();n.byteLength_-=Ft(e),n.parts_.length>0&&(n.byteLength_-=1)}function Hr(n){if(n.byteLength_>us)throw new Error(n.errorPrefix_+"has a key path longer than "+us+" bytes ("+n.byteLength_+").");if(n.parts_.length>hs)throw new Error(n.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+hs+") or object contains a cycle "+he(n))}function he(n){return n.parts_.length===0?"":"in property '"+n.parts_.join(".")+"'"}/**
1142 * @license
1143 * Copyright 2017 Google LLC
1144 *
1145 * Licensed under the Apache License, Version 2.0 (the "License");
1146 * you may not use this file except in compliance with the License.
1147 * You may obtain a copy of the License at
1148 *
1149 *   http://www.apache.org/licenses/LICENSE-2.0
1150 *
1151 * Unless required by applicable law or agreed to in writing, software
1152 * distributed under the License is distributed on an "AS IS" BASIS,
1153 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1154 * See the License for the specific language governing permissions and
1155 * limitations under the License.
1156 */class ri extends Ur{constructor(){super(["visible"]);let e,t;typeof document<"u"&&typeof document.addEventListener<"u"&&(typeof document.hidden<"u"?(t="visibilitychange",e="hidden"):typeof document.mozHidden<"u"?(t="mozvisibilitychange",e="mozHidden"):typeof document.msHidden<"u"?(t="msvisibilitychange",e="msHidden"):typeof document.webkitHidden<"u"&&(t="webkitvisibilitychange",e="webkitHidden")),this.visible_=!0,t&&document.addEventListener(t,()=>{const i=!document[e];i!==this.visible_&&(this.visible_=i,this.trigger("visible",i))},!1)}static getInstance(){return new ri}getInitialEvent(e){return f(e==="visible","Unknown event type: "+e),[this.visible_]}}/**
1157 * @license
1158 * Copyright 2017 Google LLC
1159 *
1160 * Licensed under the Apache License, Version 2.0 (the "License");
1161 * you may not use this file except in compliance with the License.
1162 * You may obtain a copy of the License at
1163 *
1164 *   http://www.apache.org/licenses/LICENSE-2.0
1165 *
1166 * Unless required by applicable law or agreed to in writing, software
1167 * distributed under the License is distributed on an "AS IS" BASIS,
1168 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1169 * See the License for the specific language governing permissions and
1170 * limitations under the License.
1171 */const Ue=1e3,Wh=60*5*1e3,ds=30*1e3,$h=1.3,Uh=3e4,Vh="server_kill",fs=3;class Y extends $r{constructor(e,t,i,s,r,o,a,l){if(super(),this.repoInfo_=e,this.applicationId_=t,this.onDataUpdate_=i,this.onConnectStatus_=s,this.onServerInfoUpdate_=r,this.authTokenProvider_=o,this.appCheckTokenProvider_=a,this.authOverride_=l,this.id=Y.nextPersistentConnectionId_++,this.log_=at("p:"+this.id+":"),this.interruptReasons_={},this.listens=new Map,this.outstandingPuts_=[],this.outstandingGets_=[],this.outstandingPutCount_=0,this.outstandingGetCount_=0,this.onDisconnectRequestQueue_=[],this.connected_=!1,this.reconnectDelay_=Ue,this.maxReconnectDelay_=Wh,this.securityDebugCallback_=null,this.lastSessionId=null,this.establishConnectionTimer_=null,this.visible_=!1,this.requestCBHash_={},this.requestNumber_=0,this.realtime_=null,this.authToken_=null,this.appCheckToken_=null,this.forceTokenRefresh_=!1,this.invalidAuthTokenCount_=0,this.invalidAppCheckTokenCount_=0,this.firstConnection_=!0,this.lastConnectionAttemptTime_=null,this.lastConnectionEstablishedTime_=null,l&&!$s())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");ri.getInstance().on("visible",this.onVisible_,this),e.host.indexOf("fblocal")===-1&&wt.getInstance().on("online",this.onOnline_,this)}sendRequest(e,t,i){const s=++this.requestNumber_,r={r:s,a:e,b:t};this.log_(A(r)),f(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(r),i&&(this.requestCBHash_[s]=i)}get(e){this.initConnection_();const t=new st,s={action:"g",request:{p:e._path.toString(),q:e._queryObject},onComplete:o=>{const a=o.d;o.s==="ok"?t.resolve(a):t.reject(a)}};this.outstandingGets_.push(s),this.outstandingGetCount_++;const r=this.outstandingGets_.length-1;return this.connected_&&this.sendGet_(r),t.promise}listen(e,t,i,s){this.initConnection_();const r=e._queryIdentifier,o=e._path.toString();this.log_("Listen called for "+o+" "+r),this.listens.has(o)||this.listens.set(o,new Map),f(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),f(!this.listens.get(o).has(r),"listen() called twice for same path/queryId.");const a={onComplete:s,hashFn:t,query:e,tag:i};this.listens.get(o).set(r,a),this.connected_&&this.sendListen_(a)}sendGet_(e){const t=this.outstandingGets_[e];this.sendRequest("g",t.request,i=>{delete this.outstandingGets_[e],this.outstandingGetCount_--,this.outstandingGetCount_===0&&(this.outstandingGets_=[]),t.onComplete&&t.onComplete(i)})}sendListen_(e){const t=e.query,i=t._path.toString(),s=t._queryIdentifier;this.log_("Listen on "+i+" for "+s);const r={p:i},o="q";e.tag&&(r.q=t._queryObject,r.t=e.tag),r.h=e.hashFn(),this.sendRequest(o,r,a=>{const l=a.d,c=a.s;Y.warnOnListenWarnings_(l,t),(this.listens.get(i)&&this.listens.get(i).get(s))===e&&(this.log_("listen response",a),c!=="ok"&&this.removeListen_(i,s),e.onComplete&&e.onComplete(c,l))})}static warnOnListenWarnings_(e,t){if(e&&typeof e=="object"&&z(e,"w")){const i=Ae(e,"w");if(Array.isArray(i)&&~i.indexOf("no_index")){const s='".indexOn": "'+t._queryParams.getIndex().toString()+'"',r=t._path.toString();L(`Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ${s} at ${r} to your security rules for better performance.`)}}}refreshAuthToken(e){this.authToken_=e,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},()=>{}),this.reduceReconnectDelayIfAdminCredential_(e)}reduceReconnectDelayIfAdminCredential_(e){(e&&e.length===40||Zo(e))&&(this.log_("Admin auth credential detected.  Reducing max reconnect time."),this.maxReconnectDelay_=ds)}refreshAppCheckToken(e){this.appCheckToken_=e,this.log_("App check token refreshed"),this.appCheckToken_?this.tryAppCheck():this.connected_&&this.sendRequest("unappeck",{},()=>{})}tryAuth(){if(this.connected_&&this.authToken_){const e=this.authToken_,t=Jo(e)?"auth":"gauth",i={cred:e};this.authOverride_===null?i.noauth=!0:typeof this.authOverride_=="object"&&(i.authvar=this.authOverride_),this.sendRequest(t,i,s=>{const r=s.s,o=s.d||"error";this.authToken_===e&&(r==="ok"?this.invalidAuthTokenCount_=0:this.onAuthRevoked_(r,o))})}}tryAppCheck(){this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},e=>{const t=e.s,i=e.d||"error";t==="ok"?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(t,i)})}unlisten(e,t){const i=e._path.toString(),s=e._queryIdentifier;this.log_("Unlisten called for "+i+" "+s),f(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(i,s)&&this.connected_&&this.sendUnlisten_(i,s,e._queryObject,t)}sendUnlisten_(e,t,i,s){this.log_("Unlisten on "+e+" for "+t);const r={p:e},o="n";s&&(r.q=i,r.t=s),this.sendRequest(o,r)}onDisconnectPut(e,t,i){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",e,t,i):this.onDisconnectRequestQueue_.push({pathString:e,action:"o",data:t,onComplete:i})}onDisconnectMerge(e,t,i){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",e,t,i):this.onDisconnectRequestQueue_.push({pathString:e,action:"om",data:t,onComplete:i})}onDisconnectCancel(e,t){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",e,null,t):this.onDisconnectRequestQueue_.push({pathString:e,action:"oc",data:null,onComplete:t})}sendOnDisconnect_(e,t,i,s){const r={p:t,d:i};this.log_("onDisconnect "+e,r),this.sendRequest(e,r,o=>{s&&setTimeout(()=>{s(o.s,o.d)},Math.floor(0))})}put(e,t,i,s){this.putInternal("p",e,t,i,s)}merge(e,t,i,s){this.putInternal("m",e,t,i,s)}putInternal(e,t,i,s,r){this.initConnection_();const o={p:t,d:i};r!==void 0&&(o.h=r),this.outstandingPuts_.push({action:e,request:o,onComplete:s}),this.outstandingPutCount_++;const a=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(a):this.log_("Buffering put: "+t)}sendPut_(e){const t=this.outstandingPuts_[e].action,i=this.outstandingPuts_[e].request,s=this.outstandingPuts_[e].onComplete;this.outstandingPuts_[e].queued=this.connected_,this.sendRequest(t,i,r=>{this.log_(t+" response",r),delete this.outstandingPuts_[e],this.outstandingPutCount_--,this.outstandingPutCount_===0&&(this.outstandingPuts_=[]),s&&s(r.s,r.d)})}reportStats(e){if(this.connected_){const t={c:e};this.log_("reportStats",t),this.sendRequest("s",t,i=>{if(i.s!=="ok"){const r=i.d;this.log_("reportStats","Error sending stats: "+r)}})}}onDataMessage_(e){if("r"in e){this.log_("from server: "+A(e));const t=e.r,i=this.requestCBHash_[t];i&&(delete this.requestCBHash_[t],i(e.b))}else{if("error"in e)throw"A server-side error has occurred: "+e.error;"a"in e&&this.onDataPush_(e.a,e.b)}}onDataPush_(e,t){this.log_("handleServerMessage",e,t),e==="d"?this.onDataUpdate_(t.p,t.d,!1,t.t):e==="m"?this.onDataUpdate_(t.p,t.d,!0,t.t):e==="c"?this.onListenRevoked_(t.p,t.q):e==="ac"?this.onAuthRevoked_(t.s,t.d):e==="apc"?this.onAppCheckRevoked_(t.s,t.d):e==="sd"?this.onSecurityDebugPacket_(t):Nn("Unrecognized action received from server: "+A(e)+`
1172Are you using the latest client?`)}onReady_(e,t){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=new Date().getTime(),this.handleTimestamp_(e),this.lastSessionId=t,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)}scheduleConnect_(e){f(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout(()=>{this.establishConnectionTimer_=null,this.establishConnection_()},Math.floor(e))}initConnection_(){!this.realtime_&&this.firstConnection_&&this.scheduleConnect_(0)}onVisible_(e){e&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible.  Reducing delay."),this.reconnectDelay_=Ue,this.realtime_||this.scheduleConnect_(0)),this.visible_=e}onOnline_(e){e?(this.log_("Browser went online."),this.reconnectDelay_=Ue,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline.  Killing connection."),this.realtime_&&this.realtime_.close())}onRealtimeDisconnect_(){if(this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()){this.visible_?this.lastConnectionEstablishedTime_&&(new Date().getTime()-this.lastConnectionEstablishedTime_>Uh&&(this.reconnectDelay_=Ue),this.lastConnectionEstablishedTime_=null):(this.log_("Window isn't visible.  Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=new Date().getTime());const e=new Date().getTime()-this.lastConnectionAttemptTime_;let t=Math.max(0,this.reconnectDelay_-e);
1172t=Math.random()*t,this.log_("Trying to reconnect in "+t+"ms"),this.scheduleConnect_(t),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,this.reconnectDelay_*$h)}this.onConnectStatus_(!1)}async establishConnection_(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=new Date().getTime(),this.lastConnectionEstablishedTime_=null;const e=this.onDataMessage_.bind(this),t=this.onReady_.bind(this),i=this.onRealtimeDisconnect_.bind(this),s=this.id+":"+Y.nextConnectionId_++,r=this.lastSessionId;let o=!1,a=null;const l=function(){a?a.close():(o=!0,i())},c=function(h){f(a,"sendRequest call when we're not connected not allowed."),a.sendRequest(h)};this.realtime_={close:l,sendRequest:c};const u=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{const[h,d]=await Promise.all([this.authTokenProvider_.getToken(u),this.appCheckTokenProvider_.getToken(u)]);o?x("getToken() completed but was canceled"):(x("getToken() completed. Creating connection."),this.authToken_=h&&h.accessToken,this.appCheckToken_=d&&d.token,a=new Ph(s,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,t,i,_=>{L(_+" ("+this.repoInfo_.toString()+")"),this.interrupt(Vh)},r))}catch(h){this.log_("Failed to get token: "+h),o||(this.repoInfo_.nodeAdmin&&L(h),l())}}}interrupt(e){x("Interrupting connection for reason: "+e),this.interruptReasons_[e]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())}resume(e){x("Resuming connection for reason: "+e),delete this.interruptReasons_[e],xi(this.interruptReasons_)&&(this.reconnectDelay_=Ue,this.realtime_||this.scheduleConnect_(0))}handleTimestamp_(e){const t=e-new Date().getTime();this.onServerInfoUpdate_({serverTimeOffset:t})}cancelSentTransactions_(){for(let e=0;e<this.outstandingPuts_.length;e++){const t=this.outstandingPuts_[e];t&&"h"in t.request&&t.queued&&(t.onComplete&&t.onComplete("disconnect"),delete this.outstandingPuts_[e],this.outstandingPutCount_--)}this.outstandingPutCount_===0&&(this.outstandingPuts_=[])}onListenRevoked_(e,t){let i;t?i=t.map(r=>Zn(r)).join("$"):i="default";const s=this.removeListen_(e,i);s&&s.onComplete&&s.onComplete("permission_denied")}removeListen_(e,t){const i=new E(e).toString();let s;if(this.listens.has(i)){const r=this.listens.get(i);s=r.get(t),r.delete(t),r.size===0&&this.listens.delete(i)}else s=void 0;return s}onAuthRevoked_(e,t){x("Auth token revoked: "+e+"/"+t),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),(e==="invalid_token"||e==="permission_denied")&&(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=fs&&(this.reconnectDelay_=ds,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(e,t){x("App check token revoked: "+e+"/"+t),this.appCheckToken_=null,this.forceTokenRefresh_=!0,(e==="invalid_token"||e==="permission_denied")&&(this.invalidAppCheckTokenCount_++,this.invalidAppCheckTokenCount_>=fs&&this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&&console.log("FIREBASE: "+e.msg.replace(`
1173`,`
1174FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of this.listens.values())for(const t of e.values())this.sendListen_(t);for(let e=0;e<this.outstandingPuts_.length;e++)this.outstandingPuts_[e]&&this.sendPut_(e);for(;this.onDisconnectRequestQueue_.length;){const e=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(e.action,e.pathString,e.data,e.onComplete)}for(let e=0;e<this.outstandingGets_.length;e++)this.outstandingGets_[e]&&this.sendGet_(e)}sendConnectStats_(){const e={};let t="js";e["sdk."+t+"."+vr.replace(/\./g,"-")]=1,Bs()?e["framework.cordova"]=1:Ko()&&(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){const e=wt.getInstance().currentlyOnline();return xi(this.interruptReasons_)&&e}}Y.nextPersistentConnectionId_=0;Y.nextConnectionId_=0;/**
1175 * @license
1176 * Copyright 2017 Google LLC
1177 *
1178 * Licensed under the Apache License, Version 2.0 (the "License");
1179 * you may not use this file except in compliance with the License.
1180 * You may obtain a copy of the License at
1181 *
1182 *   http://www.apache.org/licenses/LICENSE-2.0
1183 *
1184 * Unless required by applicable law or agreed to in writing, software
1185 * distributed under the License is distributed on an "AS IS" BASIS,
1186 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1187 * See the License for the specific language governing permissions and
1188 * limitations under the License.
1189 */class y{constructor(e,t){this.name=e,this.node=t}static Wrap(e,t){return new y(e,t)}}/**
1190 * @license
1191 * Copyright 2017 Google LLC
1192 *
1193 * Licensed under the Apache License, Version 2.0 (the "License");
1194 * you may not use this file except in compliance with the License.
1195 * You may obtain a copy of the License at
1196 *
1197 *   http://www.apache.org/licenses/LICENSE-2.0
1198 *
1199 * Unless required by applicable law or agreed to in writing, software
1200 * distributed under the License is distributed on an "AS IS" BASIS,
1201 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1202 * See the License for the specific language governing permissions and
1203 * limitations under the License.
1204 */class $t{getCompare(){return this.compare.bind(this)}indexedValueChanged(e,t){const i=new y(ke,e),s=new y(ke,t);return this.compare(i,s)!==0}minPost(){return y.MIN}}/**
1205 * @license
1206 * Copyright 2017 Google LLC
1207 *
1208 * Licensed under the Apache License, Version 2.0 (the "License");
1209 * you may not use this file except in compliance with the License.
1210 * You may obtain a copy of the License at
1211 *
1212 *   http://www.apache.org/licenses/LICENSE-2.0
1213 *
1214 * Unless required by applicable law or agreed to in writing, software
1215 * distributed under the License is distributed on an "AS IS" BASIS,
1216 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1217 * See the License for the specific language governing permissions and
1218 * limitations under the License.
1219 */let ft;class jr extends $t{static get __EMPTY_NODE(){return ft}static set __EMPTY_NODE(e){ft=e}compare(e,t){return Ee(e.name,t.name)}isDefinedOn(e){throw Le("KeyIndex.isDefinedOn not expected to be called.")}indexedValueChanged(e,t){return!1}minPost(){return y.MIN}maxPost(){return new y(me,ft)}makePost(e,t){return f(typeof e=="string","KeyIndex indexValue must always be a string."),new y(e,ft)}toString(){return".key"}}const Re=new jr;/**
1220 * @license
1221 * Copyright 2017 Google LLC
1222 *
1223 * Licensed under the Apache License, Version 2.0 (the "License");
1224 * you may not use this file except in compliance with the License.
1225 * You may obtain a copy of the License at
1226 *
1227 *   http://www.apache.org/licenses/LICENSE-2.0
1228 *
1229 * Unless required by applicable law or agreed to in writing, software
1230 * distributed under the License is distributed on an "AS IS" BASIS,
1231 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1232 * See the License for the specific language governing permissions and
1233 * limitations under the License.
1234 */class _t{constructor(e,t,i,s,r=null){this.isReverse_=s,this.resultGenerator_=r,this.nodeStack_=[];let o=1;for(;!e.isEmpty();)if(e=e,o=t?i(e.key,t):1,s&&(o*=-1),o<0)this.isReverse_?e=e.left:e=e.right;else if(o===0){this.nodeStack_.push(e);break}else this.nodeStack_.push(e),this.isReverse_?e=e.right:e=e.left}getNext(){if(this.nodeStack_.length===0)return null;let e=this.nodeStack_.pop(),t;if(this.resultGenerator_?t=this.resultGenerator_(e.key,e.value):t={key:e.key,value:e.value},this.isReverse_)for(e=e.left;!e.isEmpty();)this.nodeStack_.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack_.push(e),e=e.left;return t}hasNext(){return this.nodeStack_.length>0}peek(){if(this.nodeStack_.length===0)return null;const e=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value}}}class D{constructor(e,t,i,s,r){this.key=e,this.value=t,this.color=i??D.RED,this.left=s??F.EMPTY_NODE,this.right=r??F.EMPTY_NODE}copy(e,t,i,s,r){return new D(e??this.key,t??this.value,i??this.color,s??this.left,r??this.right)}count(){return this.left.count()+1+this.right.count()}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||!!e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min_(){return this.left.isEmpty()?this:this.left.min_()}minKey(){return this.min_().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,i){let s=this;const r=i(e,s.key);return r<0?s=s.copy(null,null,null,s.left.insert(e,t,i),null):r===0?s=s.copy(null,t,null,null,null):s=s.copy(null,null,null,null,s.right.insert(e,t,i)),s.fixUp_()}removeMin_(){if(this.left.isEmpty())return F.EMPTY_NODE;let e=this;return!e.left.isRed_()&&!e.left.left.isRed_()&&(e=e.moveRedLeft_()),e=e.copy(null,null,null,e.left.removeMin_(),null),e.fixUp_()}remove(e,t){let i,s;if(i=this,t(e,i.key)<0)!i.left.isEmpty()&&!i.left.isRed_()&&!i.left.left.isRed_()&&(i=i.moveRedLeft_()),i=i.copy(null,null,null,i.left.remove(e,t),null);else{if(i.left.isRed_()&&(i=i.rotateRight_()),!i.right.isEmpty()&&!i.right.isRed_()&&!i.right.left.isRed_()&&(i=i.moveRedRight_()),t(e,i.key)===0){if(i.right.isEmpty())return F.EMPTY_NODE;
vendor: 1,248 bytes, line 1234
1234s=i.right.min_(),i=i.copy(s.key,s.value,null,null,i.right.removeMin_())}i=i.copy(null,null,null,null,i.right.remove(e,t))}return i.fixUp_()}isRed_(){return this.color}fixUp_(){let e=this;return e.right.isRed_()&&!e.left.isRed_()&&(e=e.rotateLeft_()),e.left.isRed_()&&e.left.left.isRed_()&&(e=e.rotateRight_()),e.left.isRed_()&&e.right.isRed_()&&(e=e.colorFlip_()),e}moveRedLeft_(){let e=this.colorFlip_();return e.right.left.isRed_()&&(e=e.copy(null,null,null,null,e.right.rotateRight_()),e=e.rotateLeft_(),e=e.colorFlip_()),e}moveRedRight_(){let e=this.colorFlip_();return e.left.left.isRed_()&&(e=e.rotateRight_(),e=e.colorFlip_()),e}rotateLeft_(){const e=this.copy(null,null,D.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight_(){const e=this.copy(null,null,D.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip_(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth_(){const e=this.check_();return Math.pow(2,e)<=this.count()+1}check_(){if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");
1234if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");const e=this.left.check_();if(e!==this.right.check_())throw new Error("Black depths differ");return e+(this.isRed_()?0:1)}}D.RED=!0;D.BLACK=!1;class Hh{copy(e,t,i,s,r){return this}insert(e,t,i){return new D(e,t,null)}remove(e,t){return this}count(){return 0}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}check_(){return 0}isRed_(){return!1}}class F{constructor(e,t=F.EMPTY_NODE){this.comparator_=e,this.root_=t}insert(e,t){return new F(this.comparator_,this.root_.insert(e,t,this.comparator_).copy(null,null,D.BLACK,null,null))}remove(e){return new F(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,D.BLACK,null,null))}get(e){let t,i=this.root_;for(;!i.isEmpty();){if(t=this.comparator_(e,i.key),t===0)return i.value;t<0?i=i.left:t>0&&(i=i.right)}return null}getPredecessorKey(e){let t,i=this.root_,s=null;for(;!i.isEmpty();)if(t=this.comparator_(e,i.key),t===0){if(i.left.isEmpty())return s?s.key:null;for(i=i.left;!i.right.isEmpty();)i=i.right;return i.key}else t<0?i=i.left:t>0&&(s=i,i=i.right);throw new Error("Attempted to find predecessor key for a nonexistent key.  What gives?")}isEmpty(){return this.root_.isEmpty()}count(){return this.root_.count()}minKey(){return this.root_.minKey()}maxKey(){return this.root_.maxKey()}inorderTraversal(e){return this.root_.inorderTraversal(e)}reverseTraversal(e){return this.root_.reverseTraversal(e)}getIterator(e){return new _t(this.root_,null,this.comparator_,!1,e)}getIteratorFrom(e,t){return new _t(this.root_,e,this.comparator_,!1,t)}getReverseIteratorFrom(e,t){return new _t(this.root_,e,this.comparator_,!0,t)}getReverseIterator(e){return new _t(this.root_,null,this.comparator_,!0,e)}}F.EMPTY_NODE=new Hh;/**
1235 * @license
1236 * Copyright 2017 Google LLC
1237 *
1238 * Licensed under the Apache License, Version 2.0 (the "License");
1239 * you may not use this file except in compliance with the License.
1240 * You may obtain a copy of the License at
1241 *
1242 *   http://www.apache.org/licenses/LICENSE-2.0
1243 *
1244 * Unless required by applicable law or agreed to in writing, software
1245 * distributed under the License is distributed on an "AS IS" BASIS,
1246 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1247 * See the License for the specific language governing permissions and
1248 * limitations under the License.
1249 */function jh(n,e){return Ee(n.name,e.name)}function oi(n,e){return Ee(n,e)}/**
1250 * @license
1251 * Copyright 2017 Google LLC
1252 *
1253 * Licensed under the Apache License, Version 2.0 (the "License");
1254 * you may not use this file except in compliance with the License.
1255 * You may obtain a copy of the License at
1256 *
1257 *   http://www.apache.org/licenses/LICENSE-2.0
1258 *
1259 * Unless required by applicable law or agreed to in writing, software
1260 * distributed under the License is distributed on an "AS IS" BASIS,
1261 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1262 * See the License for the specific language governing permissions and
1263 * limitations under the License.
1264 */let An;function Gh(n){An=n}const Gr=function(n){return typeof n=="number"?"number:"+Ir(n):"string:"+n},zr=function(n){if(n.isLeafNode()){const e=n.val();f(typeof e=="string"||typeof e=="number"||typeof e=="object"&&z(e,".sv"),"Priority must be a string or number.")}else f(n===An||n.isEmpty(),"priority of unexpected type.");f(n===An||n.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")};/**
1265 * @license
1266 * Copyright 2017 Google LLC
1267 *
1268 * Licensed under the Apache License, Version 2.0 (the "License");
1269 * you may not use this file except in compliance with the License.
1270 * You may obtain a copy of the License at
1271 *
1272 *   http://www.apache.org/licenses/LICENSE-2.0
1273 *
1274 * Unless required by applicable law or agreed to in writing, software
1275 * distributed under the License is distributed on an "AS IS" BASIS,
1276 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1277 * See the License for the specific language governing permissions and
1278 * limitations under the License.
1279 */let _s;class k{constructor(e,t=k.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=t,this.lazyHash_=null,f(this.value_!==void 0&&this.value_!==null,"LeafNode shouldn't be created with null/undefined value."),zr(this.priorityNode_)}static set __childrenNodeConstructor(e){_s=e}static get __childrenNodeConstructor(){return _s}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new k(this.value_,e)}getImmediateChild(e){return e===".priority"?this.priorityNode_:k.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return v(e)?this:m(e)===".priority"?this.priorityNode_:k.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(e,t){return null}updateImmediateChild(e,t){return e===".priority"?this.updatePriority(t):t.isEmpty()&&e!==".priority"?this:k.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,t).updatePriority(this.priorityNode_)}updateChild(e,t){const i=m(e);return i===null?t:t.isEmpty()&&i!==".priority"?this:(f(i!==".priority"||re(e)===1,".priority must be the last token in a path"),this.updateImmediateChild(i,k.__childrenNodeConstructor.EMPTY_NODE.updateChild(T(e),t)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(e,t){return!1}
1279val(e){return e&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(this.lazyHash_===null){let e="";this.priorityNode_.isEmpty()||(e+="priority:"+Gr(this.priorityNode_.val())+":");const t=typeof this.value_;e+=t+":",t==="number"?e+=Ir(this.value_):e+=this.value_,this.lazyHash_=Er(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===k.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof k.__childrenNodeConstructor?-1:(f(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){const t=typeof e.value_,i=typeof this.value_,s=k.VALUE_TYPE_ORDER.indexOf(t),r=k.VALUE_TYPE_ORDER.indexOf(i);return f(s>=0,"Unknown leaf type: "+t),f(r>=0,"Unknown leaf type: "+i),s===r?i==="object"?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:r-s}withIndex(){return this}isIndexed(){return!0}equals(e){if(e===this)return!0;if(e.isLeafNode()){const t=e;return this.value_===t.value_&&this.priorityNode_.equals(t.priorityNode_)}else return!1}}k.VALUE_TYPE_ORDER=["object","boolean","number","string"];/**
1280 * @license
1281 * Copyright 2017 Google LLC
1282 *
1283 * Licensed under the Apache License, Version 2.0 (the "License");
1284 * you may not use this file except in compliance with the License.
1285 * You may obtain a copy of the License at
1286 *
1287 *   http://www.apache.org/licenses/LICENSE-2.0
1288 *
1289 * Unless required by applicable law or agreed to in writing, software
1290 * distributed under the License is distributed on an "AS IS" BASIS,
1291 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1292 * See the License for the specific language governing permissions and
1293 * limitations under the License.
1294 */let qr,Kr;function zh(n){qr=n}function qh(n){Kr=n}class Kh extends $t{compare(e,t){const i=e.node.getPriority(),s=t.node.getPriority(),r=i.compareTo(s);return r===0?Ee(e.name,t.name):r}isDefinedOn(e){return!e.getPriority().isEmpty()}indexedValueChanged(e,t){return!e.getPriority().equals(t.getPriority())}minPost(){return y.MIN}maxPost(){return new y(me,new k("[PRIORITY-POST]",Kr))}makePost(e,t){const i=qr(e);return new y(t,new k("[PRIORITY-POST]",i))}toString(){return".priority"}}const N=new Kh;/**
1295 * @license
1296 * Copyright 2017 Google LLC
1297 *
1298 * Licensed under the Apache License, Version 2.0 (the "License");
1299 * you may not use this file except in compliance with the License.
1300 * You may obtain a copy of the License at
1301 *
1302 *   http://www.apache.org/licenses/LICENSE-2.0
1303 *
1304 * Unless required by applicable law or agreed to in writing, software
1305 * distributed under the License is distributed on an "AS IS" BASIS,
1306 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1307 * See the License for the specific language governing permissions and
1308 * limitations under the License.
1309 */const Yh=Math.log(2);class Qh{constructor(e){const t=r=>parseInt(Math.log(r)/Yh,10),i=r=>parseInt(Array(r+1).join("1"),2);this.count=t(e+1),this.current_=this.count-1;const s=i(this.count);this.bits_=e+1&s}nextBitIsOne(){const e=!(this.bits_&1<<this.current_);return this.current_--,e}}const It=function(n,e,t,i){n.sort(e);const s=function(l,c){const u=c-l;let h,d;if(u===0)return null;if(u===1)return h=n[l],d=t?t(h):h,new D(d,h.node,D.BLACK,null,null);{const _=parseInt(u/2,10)+l,p=s(l,_),w=s(_+1,c);return h=n[_],d=t?t(h):h,new D(d,h.node,D.BLACK,p,w)}},r=function(l){let c=null,u=null,h=n.length;const d=function(p,w){const O=h-p,Ie=h;h-=p;const dt=s(O+1,Ie),Xt=n[O],Po=t?t(Xt):Xt;_(new D(Po,Xt.node,w,null,dt))},_=function(p){c?(c.left=p,c=p):(u=p,c=p)};for(let p=0;p<l.count;++p){const w=l.nextBitIsOne(),O=Math.pow(2,l.count-(p+1));w?d(O,D.BLACK):(d(O,D.BLACK),d(O,D.RED))}return u},o=new Qh(n.length),a=r(o);return new F(i||e,a)};/**
1310 * @license
1311 * Copyright 2017 Google LLC
1312 *
1313 * Licensed under the Apache License, Version 2.0 (the "License");
1314 * you may not use this file except in compliance with the License.
1315 * You may obtain a copy of the License at
1316 *
1317 *   http://www.apache.org/licenses/LICENSE-2.0
1318 *
1319 * Unless required by applicable law or agreed to in writing, softw
1319are
1320 * distributed under the License is distributed on an "AS IS" BASIS,
1321 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1322 * See the License for the specific language governing permissions and
1323 * limitations under the License.
1324 */let fn;const be={};class K{constructor(e,t){this.indexes_=e,this.indexSet_=t}static get Default(){return f(be&&N,"ChildrenNode.ts has not been loaded"),fn=fn||new K({".priority":be},{".priority":N}),fn}get(e){const t=Ae(this.indexes_,e);if(!t)throw new Error("No index defined for "+e);return t instanceof F?t:null}hasIndex(e){return z(this.indexSet_,e.toString())}addIndex(e,t){f(e!==Re,"KeyIndex always exists and isn't meant to be added to the IndexMap.");const i=[];let s=!1;const r=t.getIterator(y.Wrap);let o=r.getNext();for(;o;)s=s||e.isDefinedOn(o.node),i.push(o),o=r.getNext();let a;s?a=It(i,e.getCompare()):a=be;const l=e.toString(),c=Object.assign({},this.indexSet_);c[l]=e;const u=Object.assign({},this.indexes_);return u[l]=a,new K(u,c)}addToIndexes(e,t){const i=gt(this.indexes_,(s,r)=>{const o=Ae(this.indexSet_,r);if(f(o,"Missing index implementation for "+r),s===be)if(o.isDefinedOn(e.node)){const a=[],l=t.getIterator(y.Wrap);let c=l.getNext();for(;c;)c.name!==e.name&&a.push(c),c=l.getNext();return a.push(e),It(a,o.getCompare())}else return be;else{const a=t.get(e.name);let l=s;return a&&(l=l.remove(new y(e.name,a))),l.insert(e,e.node)}});return new K(i,this.indexSet_)}removeFromIndexes(e,t){const i=gt(this.indexes_,s=>{if(s===be)return s;{const r=t.get(e.name);return r?s.remove(new y(e.name,r)):s}});return new K(i,this.indexSet_)}}/**
1325 * @license
1326 * Copyright 2017 Google LLC
1327 *
1328 * Licensed under the Apache License, Version 2.0 (the "License");
1329 * you may not use this file except in compliance with the License.
1330 * You may obtain a copy of the License at
1331 *
1332 *   http://www.apache.org/licenses/LICENSE-2.0
1333 *
1334 * Unless required by applicable law or agreed to in writing, software
1335 * distributed under the License is distributed on an "AS IS" BASIS,
1336 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1337 * See the License for the specific language governing permissions and
1338 * limitations under the License.
1339 */let Ve;class g{constructor(e,t,i){this.children_=e,this.priorityNode_=t,this.indexMap_=i,this.lazyHash_=null,this.priorityNode_&&zr(this.priorityNode_),this.children_.isEmpty()&&f(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}static get EMPTY_NODE(){return Ve||(Ve=new g(new F(oi),null,K.Default))}isLeafNode(){return!1}getPriority(){return this.priorityNode_||Ve}updatePriority(e){return this.children_.isEmpty()?this:new g(this.children_,e,this.indexMap_)}getImmediateChild(e){if(e===".priority")return this.getPriority();{const t=this.children_.get(e);return t===null?Ve:t}}getChild(e){const t=m(e);return t===null?this:this.getImmediateChild(t).getChild(T(e))}hasChild(e){return this.children_.get(e)!==null}updateImmediateChild(e,t){if(f(t,"We should always be passing snapshot nodes"),e===".priority")return this.updatePriority(t);{const i=new y(e,t);let s,r;t.isEmpty()?(s=this.children_.remove(e),r=this.indexMap_.removeFromIndexes(i,this.children_)):(s=this.children_.insert(e,t),r=this.indexMap_.addToIndexes(i,this.children_));const o=s.isEmpty()?Ve:this.priorityNode_;return new g(s,o,r)}}updateChild(e,t){const i=m(e);if(i===null)return t;{f(m(e)!==".priority"||re(e)===1,".priority must be the last token in a path");const s=this.getImmediateChild(i).updateChild(T(e),t);return this.updateImmediateChild(i,s)}}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(e){if(this.isEmpty())return null;const t={};let i=0,s=0,r=!0;if(this.forEachChild(N,(o,a)=>{t[o]=a.val(e),i++,r&&g.INTEGER_REGEXP_.test(o)?s=Math.max(s,Number(o)):r=!1}),!e&&r&&s<2*i){const o=[];for(const a in t)o[a]=t[a];return o}else return e&&!this.getPriority().isEmpty()&&(t[".priority"]=this.getPriority().val()),t}hash(){if(this.lazyHash_===null){let e="";
1339this.getPriority().isEmpty()||(e+="priority:"+Gr(this.getPriority().val())+":"),this.forEachChild(N,(t,i)=>{const s=i.hash();s!==""&&(e+=":"+t+":"+s)}),this.lazyHash_=e===""?"":Er(e)}return this.lazyHash_}getPredecessorChildName(e,t,i){const s=this.resolveIndex_(i);if(s){const r=s.getPredecessorKey(new y(e,t));return r?r.name:null}else return this.children_.getPredecessorKey(e)}getFirstChildName(e){const t=this.resolveIndex_(e);if(t){const i=t.minKey();return i&&i.name}else return this.children_.minKey()}getFirstChild(e){const t=this.getFirstChildName(e);return t?new y(t,this.children_.get(t)):null}getLastChildName(e){const t=this.resolveIndex_(e);if(t){const i=t.maxKey();return i&&i.name}else return this.children_.maxKey()}getLastChild(e){const t=this.getLastChildName(e);return t?new y(t,this.children_.get(t)):null}forEachChild(e,t){const i=this.resolveIndex_(e);return i?i.inorderTraversal(s=>t(s.name,s.node)):this.children_.inorderTraversal(t)}getIterator(e){return this.getIteratorFrom(e.minPost(),e)}getIteratorFrom(e,t){const i=this.resolveIndex_(t);if(i)return i.getIteratorFrom(e,s=>s);{const s=this.children_.getIteratorFrom(e.name,y.Wrap);let r=s.peek();for(;r!=null&&t.compare(r,e)<0;)s.getNext(),r=s.peek();return s}}getReverseIterator(e){return this.getReverseIteratorFrom(e.maxPost(),e)}getReverseIteratorFrom(e,t){const i=this.resolveIndex_(t);if(i)return i.getReverseIteratorFrom(e,s=>s);{const s=this.children_.getReverseIteratorFrom(e.name,y.Wrap);let r=s.peek();for(;r!=null&&t.compare(r,e)>0;)s.getNext(),r=s.peek();return s}}compareTo(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===lt?-1:0}withIndex(e){if(e===Re||this.indexMap_.hasIndex(e))return this;{const t=this.indexMap_.addIndex(e,this.children_);return new g(this.children_,this.priorityNode_,t)}}isIndexed(e){return e===Re||this.indexMap_.hasIndex(e)}equals(e){if(e===this)return!0;if(e.isLeafNode())return!1;{const t=e;if(this.getPriority().equals(t.getPriority()))if(this.children_.count()===t.children_.count()){const i=this.getIterator(N),s=t.getIterator(N);let r=i.getNext(),o=s.getNext();for(;r&&o;){if(r.name!==o.name||!r.node.equals(o.node))return!1;r=i.getNext(),o=s.getNext()}return r===null&&o===null}else return!1;else return!1}}resolveIndex_(e){return e===Re?null:this.indexMap_.get(e.toString())}}g.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;class Xh extends g{constructor(){super(new F(oi),g.EMPTY_NODE,K.Default)}compareTo(e){return e===this?0:1}equals(e){return e===this}getPriority(){return this}getImmediateChild(e){return g.EMPTY_NODE}isEmpty(){return!1}}const lt=new Xh;Object.defineProperties(y,{MIN:{value:new y(ke,g.EMPTY_NODE)},MAX:{value:new y(me,lt)}});jr.__EMPTY_NODE=g.EMPTY_NODE;k.__childrenNodeConstructor=g;Gh(lt);qh(lt);/**
1340 * @license
1341 * Copyright 2017 Google LLC
1342 *
1343 * Licensed under the Apache License, Version 2.0 (the "License");
1344 * you may not use this file except in compliance with the License.
1345 * You may obtain a copy of the License at
1346 *
1347 *   http://www.apache.org/licenses/LICENSE-2.0
1348 *
1349 * Unless required by applicable law or agreed to in writing, software
1350 * distributed under the License is distributed on an "AS IS" BASIS,
1351 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1352 * See the License for the specific language governing permissions and
1353 * limitations under the License.
1354 */const Jh=!0;function R(n,e=null){if(n===null)return g.EMPTY_NODE;if(typeof n=="object"&&".priority"in n&&(e=n[".priority"]),f(e===null||typeof e=="string"||typeof e=="number"||typeof e=="object"&&".sv"in e,"Invalid priority type found: "+typeof e),typeof n=="object"&&".value"in n&&n[".value"]!==null&&(n=n[".value"]),typeof n!="object"||".sv"in n){const t=n;return new k(t,R(e))}if(!(n instanceof Array)&&Jh){const t=[];let i=!1;if(P(n,(o,a)=>{if(o.substring(0,1)!=="."){const l=R(a);l.isEmpty()||(i=i||!l.getPriority().isEmpty(),t.push(new y(o,l)))}}),t.length===0)return g.EMPTY_NODE;const r=It(t,jh,o=>o.name,oi);if(i){const o=It(t,N.getCompare());return new g(r,R(e),new K({".priority":o},{".priority":N}))}else return new g(r,R(e),K.Default)}else{let t=g.EMPTY_NODE;return P(n,(i,s)=>{if(z(n,i)&&i.substring(0,1)!=="."){const r=R(s);(r.isLeafNode()||!r.isEmpty())&&(t=t.updateImmediateChild(i,r))}}),t.updatePriority(R(e))}}zh(R);/**
1355 * @license
1356 * Copyright 2017 Google LLC
1357 *
1358 * Licensed under the Apache License, Version 2.0 (the "License");
1359 * you may not use this file except in compliance with the License.
1360 * You may obtain a copy of the License at
1361 *
1362 *   http://www.apache.org/licenses/LICENSE-2.0
1363 *
1364 * Unless required by applicable law or agreed to in writing, software
1365 * distributed under the License is distributed on an "AS IS" BASIS,
1366 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1367 * See the License for the specific language governing permissions and
1368 * limitations under the License.
1369 */class Zh extends $t{constructor(e){super(),this.indexPath_=e,f(!v(e)&&m(e)!==".priority","Can't create PathIndex with empty path or .priority key")}extractChild(e){return e.getChild(this.indexPath_)}isDefinedOn(e){return!e.getChild(this.indexPath_).isEmpty()}compare(e,t){const i=this.extractChild(e.node),s=this.extractChild(t.node),r=i.compareTo(s);return r===0?Ee(e.name,t.name):r}makePost(e,t){const i=R(e),s=g.EMPTY_NODE.updateChild(this.indexPath_,i);return new y(t,s)}maxPost(){const e=g.EMPTY_NODE.updateChild(this.indexPath_,lt);return new y(me,e)}toString(){return Je(this.indexPath_,0).join("/")}}/**
1370 * @license
1371 * Copyright 2017 Google LLC
1372 *
1373 * Licensed under the Apache License, Version 2.0 (the "License");
1374 * you may not use this file except in compliance with the License.
1375 * You may obtain a copy of the License at
1376 *
1377 *   http://www.apache.org/licenses/LICENSE-2.0
1378 *
1379 * Unless required by applicable law or agreed to in writing, software
1380 * distributed under the License is distributed on an "AS IS" BASIS,
1381 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1382 * See the License for the specific language governing permissions and
1383 * limitations under the License.
1384 */class eu extends $t{compare(e,t){const i=e.node.compareTo(t.node);return i===0?Ee(e.name,t.name):i}isDefinedOn(e){return!0}indexedValueChanged(e,t){return!e.equals(t)}minPost(){return y.MIN}maxPost(){return y.MAX}makePost(e,t){const i=R(e);return new y(t,i)}toString(){return".value"}}
vendor: 4,724 bytes, lines 1384-1433
1384const tu=new eu;/**
1385 * @license
1386 * Copyright 2017 Google LLC
1387 *
1388 * Licensed under the Apache License, Version 2.0 (the "License");
1389 * you may not use this file except in compliance with the License.
1390 * You may obtain a copy of the License at
1391 *
1392 *   http://www.apache.org/licenses/LICENSE-2.0
1393 *
1394 * Unless required by applicable law or agreed to in writing, software
1395 * distributed under the License is distributed on an "AS IS" BASIS,
1396 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1397 * See the License for the specific language governing permissions and
1398 * limitations under the License.
1399 */function Yr(n){return{type:"value",snapshotNode:n}}function De(n,e){return{type:"child_added",snapshotNode:e,childName:n}}function Ze(n,e){return{type:"child_removed",snapshotNode:e,childName:n}}function et(n,e,t){return{type:"child_changed",snapshotNode:e,childName:n,oldSnap:t}}function nu(n,e){return{type:"child_moved",snapshotNode:e,childName:n}}/**
1400 * @license
1401 * Copyright 2017 Google LLC
1402 *
1403 * Licensed under the Apache License, Version 2.0 (the "License");
1404 * you may not use this file except in compliance with the License.
1405 * You may obtain a copy of the License at
1406 *
1407 *   http://www.apache.org/licenses/LICENSE-2.0
1408 *
1409 * Unless required by applicable law or agreed to in writing, software
1410 * distributed under the License is distributed on an "AS IS" BASIS,
1411 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1412 * See the License for the specific language governing permissions and
1413 * limitations under the License.
1414 */class ai{constructor(e){this.index_=e}updateChild(e,t,i,s,r,o){f(e.isIndexed(this.index_),"A node must be indexed if only a child is updated");const a=e.getImmediateChild(t);return a.getChild(s).equals(i.getChild(s))&&a.isEmpty()===i.isEmpty()||(o!=null&&(i.isEmpty()?e.hasChild(t)?o.trackChildChange(Ze(t,a)):f(e.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):a.isEmpty()?o.trackChildChange(De(t,i)):o.trackChildChange(et(t,i,a))),e.isLeafNode()&&i.isEmpty())?e:e.updateImmediateChild(t,i).withIndex(this.index_)}updateFullNode(e,t,i){return i!=null&&(e.isLeafNode()||e.forEachChild(N,(s,r)=>{t.hasChild(s)||i.trackChildChange(Ze(s,r))}),t.isLeafNode()||t.forEachChild(N,(s,r)=>{if(e.hasChild(s)){const o=e.getImmediateChild(s);o.equals(r)||i.trackChildChange(et(s,r,o))}else i.trackChildChange(De(s,r))})),t.withIndex(this.index_)}updatePriority(e,t){return e.isEmpty()?g.EMPTY_NODE:e.updatePriority(t)}filtersNodes(){return!1}getIndexedFilter(){return this}getIndex(){return this.index_}}/**
1415 * @license
1416 * Copyright 2017 Google LLC
1417 *
1418 * Licensed under the Apache License, Version 2.0 (the "License");
1419 * you may not use this file except in compliance with the License.
1420 * You may obtain a copy of the License at
1421 *
1422 *   http://www.apache.org/licenses/LICENSE-2.0
1423 *
1424 * Unless required by applicable law or agreed to in writing, software
1425 * distributed under the License is distributed on an "AS IS" BASIS,
1426 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1427 * See the License for the specific language governing permissions and
1428 * limitations under the License.
1429 */class tt{constructor(e){this.indexedFilter_=new ai(e.getIndex()),this.index_=e.getIndex(),this.startPost_=tt.getStartPost_(e),this.endPost_=tt.getEndPost_(e),this.startIsInclusive_=!e.startAfterSet_,this.endIsInclusive_=!e.endBeforeSet_}getStartPost(){return this.startPost_}getEndPost(){return this.endPost_}matches(e){const t=this.startIsInclusive_?this.index_.compare(this.getStartPost(),e)<=0:this.index_.compare(this.getStartPost(),e)<0,i=this.endIsInclusive_?this.index_.compare(e,this.getEndPost())<=0:this.index_.compare(e,this.getEndPost())<0;return t&&i}updateChild(e,t,i,s,r,o){return this.matches(new y(t,i))||(i=g.EMPTY_NODE),this.indexedFilter_.updateChild(e,t,i,s,r,o)}updateFullNode(e,t,i){t.isLeafNode()&&(t=g.EMPTY_NODE);let s=t.withIndex(this.index_);s=s.updatePriority(g.EMPTY_NODE);const r=this;return t.forEachChild(N,(o,a)=>{r.matches(new y(o,a))||(s=s.updateImmediateChild(o,g.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(e,s,i)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.indexedFilter_}getIndex(){return this.index_}static getStartPost_(e){if(e.hasStart()){const t=e.getIndexStartName();return e.getIndex().makePost(e.getIndexStartValue(),t)}else return e.getIndex().minPost()}static getEndPost_(e){if(e.hasEnd()){const t=e.getIndexEndName();return e.getIndex().makePost(e.getIndexEndValue(),t)}else return e.getIndex().maxPost()}}/**
1430 * @license
1431 * Copyright 2017 Google LLC
1432 *
1433 * Licensed under the Apache License, Version 2.0 (the "License");
1434 * you may not use this file except in compliance with the License.
1435 * You may obtain a copy of the License at
1436 *
1437 *   http://www.apache.org/licenses/LICENSE-2.0
1438 *
1439 * Unless required by applicable law or agreed to in writing, software
1440 * distributed under the License is distributed on an "AS IS" BASIS,
1441 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1442 * See the License for the specific language governing permissions and
1443 * limitations under the License.
1444 */class iu{constructor(e){this.withinDirectionalStart=t=>this.reverse_?this.withinEndPost(t):this.withinStartPost(t),this.withinDirectionalEnd=t=>this.reverse_?this.withinStartPost(t):this.withinEndPost(t),this.withinStartPost=t=>{const i=this.index_.compare(this.rangedFilter_.getStartPost(),t);return this.startIsInclusive_?i<=0:i<0},this.withinEndPost=t=>{const i=this.index_.compare(t,this.rangedFilter_.getEndPost());return this.endIsInclusive_?i<=0:i<0},this.rangedFilter_=new tt(e),this.index_=e.getIndex(),this.limit_=e.getLimit(),this.reverse_=!e.isViewFromLeft(),this.startIsInclusive_=!e.startAfterSet_,this.endIsInclusive_=!e.endBeforeSet_}updateChild(e,t,i,s,r,o){return this.rangedFilter_.matches(new y(t,i))||(i=g.EMPTY_NODE),e.getImmediateChild(t).equals(i)?e:e.numChildren()<this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(e,t,i,s,r,o):this.fullLimitUpdateChild_(e,t,i,r,o)}updateFullNode(e,t,i){let s;if(t.isLeafNode()||t.isEmpty())s=g.EMPTY_NODE.withIndex(this.index_);else if(this.limit_*2<t.numChildren()&&t.isIndexed(this.index_)){s=g.EMPTY_NODE.withIndex(this.index_);let r;this.reverse_?r=t.getReverseIteratorFrom(this.rangedFilter_.getEndPost(),this.index_):r=t.getIteratorFrom(this.rangedFilter_.getStartPost(),this.index_);let o=0;for(;r.hasNext()&&o<this.limit_;){const a=r.getNext();if(this.withinDirectionalStart(a))if(this.withinDirectionalEnd(a))s=s.updateImmediateChild(a.name,a.node),o++;else break;else continue}}else{s=t.withIndex(this.index_),s=s.updatePriority(g.EMPTY_NODE);let r;this.reverse_?r=s.getReverseIterator(this.index_):r=s.getIterator(this.index_);let o=0;for(;r.hasNext();){const a=r.getNext();o<this.limit_&&this.withinDirectionalStart(a)&&this.withinDirectionalEnd(a)?o++:s=s.updateImmediateChild(a.name,g.EMPTY_NODE)}}return this.rangedFilter_.getIndexedFilter().updateFullNode(e,s,i)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.rangedFilter_.getIndexedFilter()}getIndex(){return this.index_}fullLimitUpdateChild_(e,t,i,s,r){let o;if(this.reverse_){const h=this.index_.getCompare();o=(d,_)=>h(_,d)}else o=this.index_.getCompare();const a=e;f(a.numChildren()===this.limit_,"");const l=new y(t,i),c=this.reverse_?a.getFirstChild(this.index_):a.getLastChild(this.index_),u=this.rangedFilter_.matches(l);if(a.hasChild(t)){const h=a.getImmediateChild(t);let d=s.getChildAfterChild(this.index_,c,this.reverse_);for(;d!=null&&(d.name===t||a.hasChild(d.name));)d=s.getChildAfterChild(this.index_,d,this.reverse_);const _=d==null?1:o(d,l);if(u&&!i.isEmpty()&&_>=0)return r!=null&&r.trackChildChange(et(t,i,h)),a.updateImmediateChild(t,i);{r!=null&&r.trackChildChange(Ze(t,h));const w=a.updateImmediateChild(t,g.EMPTY_NODE);return d!=null&&this.rangedFilter_.matches(d)?(r!=null&&r.trackChildChange(De(d.name,d.node)),w.updateImmediateChild(d.name,d.node)):w}}else return i.isEmpty()?e:u&&o(c,l)>=0?(r!=null&&(r.trackChildChange(Ze(c.name,c.node)),r.trackChildChange(De(t,i))),a.updateImmediateChild(t,i).updateImmediateChild(c.name,g.EMPTY_NODE)):e}}/**
1445 * @license
1446 * Copyright 2017 Google LLC
1447 *
1448 * Licensed under the Apache License, Version 2.0 (the "License");
1449 * you may not use this file except in compliance with the License.
1450 * You may obtain a copy of the License at
1451 *
1452 *   http://www.apache.org/licenses/LICENSE-2.0
1453 *
1454 * Unless required by applicable law or agreed to in writing, software
1455 * distributed under the License is distributed on an "AS IS" BASIS,
1456 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1457 * See the License for the specific language governing permissions and
1458 * limitations under the License.
1459 */class li{constructor(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.startAfterSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.endBeforeSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=N}hasStart(){return this.startSet_}isViewFromLeft(){return this.viewFrom_===""?this.startSet_:this.viewFrom_==="l"}getIndexStartValue(){return f(this.startSet_,"Only valid if start has been set"),this.indexStartValue_}getIndexStartName(){return f(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:ke}hasEnd(){return this.endSet_}getIndexEndValue(){return f(this.endSet_,"Only valid if end has been set"),this.indexEndValue_}getIndexEndName(){return f(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:me}hasLimit(){return this.limitSet_}hasAnchoredLimit(){return this.limitSet_&&this.viewFrom_!==""}getLimit(){return f(this.limitSet_,"Only valid if limit has been set"),this.limit_}getIndex(){return this.index_}loadsAllData(){return!(this.startSet_||this.endSet_||this.limitSet_)}isDefault(){return this.loadsAllData()&&this.index_===N}copy(){const e=new li;return e.limitSet_=this.limitSet_,e.limit_=this.limit_,e.startSet_=this.startSet_,e.startAfterSet_=this.startAfterSet_,e.indexStartValue_=this.indexStartValue_,e.startNameSet_=this.startNameSet_,e.indexStartName_=this.indexStartName_,e.endSet_=this.endSet_,e.endBeforeSet_=this.endBeforeSet_,e.indexEndValue_=this.indexEndValue_,e.endNameSet_=this.endNameSet_,e.indexEndName_=this.indexEndName_,e.index_=this.index_,e.viewFrom_=this.viewFrom_,e}}function su(n){return n.loadsAllData()?new ai(n.getIndex()):n.hasLimit()?new iu(n):new tt(n)}function ps(n){const e={};if(n.isDefault())return e;let t;if(n.index_===N?t="$priority":n.index_===tu?t="$value":n.index_===Re?t="$key":(f(n.index_ instanceof Zh,"Unrecognized index type!"),t=n.index_.toString()),e.orderBy=A(t),n.startSet_){const i=n.startAfterSet_?"startAfter":"startAt";e[i]=A(n.indexStartValue_),n.startNameSet_&&(e[i]+=","+A(n.indexStartName_))}if(n.endSet_){const i=n.endBeforeSet_?"endBefore":"endAt";e[i]=A(n.indexEndValue_),n.endNameSet_&&(e[i]+=","+A(n.indexEndName_))}return n.limitSet_&&(n.isViewFromLeft()?e.limitToFirst=n.limit_:e.limitToLast=n.limit_),e}function gs(n){const e={};if(n.startSet_&&(e.sp=n.indexStartValue_,n.startNameSet_&&(e.sn=n.indexStartName_),e.sin=!n.startAfterSet_),n.endSet_&&(e.ep=n.indexEndValue_,n.endNameSet_&&(e.en=n.indexEndName_),e.ein=!n.endBeforeSet_),n.limitSet_){e.l=n.limit_;let t=n.viewFrom_;t===""&&(n.isViewFromLeft()?t="l":t="r"),e.vf=t}return n.index_!==N&&(e.i=n.index_.toString()),e}/**
1460 * @license
1461 * Copyright 2017 Google LLC
1462 *
1463 * Licensed under the Apache License, Version 2.0 (the "License");
1464 * you may not use this file except in compliance with the License.
1465 * You may obtain a copy of the License at
1466 *
1467 *   http://www.apache.org/licenses/LICENSE-2.0
1468 *
1469 * Unless required by applicable law or agreed to in writing, software
1470 * distributed under the License is distributed on an "AS IS" BASIS,
1471 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1472 * See the License for the specific language governing permissions and
1473 * limitations under the License.
1474 */class bt extends $r{constructor(e,t,i,s){super(),this.repoInfo_=e,this.onDataUpdate_=t,this.authTokenProvider_=i,this.appCheckTokenProvider_=s,this.log_=at("p:rest:"),this.listens_={}}reportStats(e){throw new Error("Method not implemented.")}static getListenId_(e,t){return t!==void 0?"tag$"+t:(f(e._queryParams.isDefault(),"should have a tag if it's not a default query."),e._path.toString())}listen(e,t,i,s){const r=e._path.toString();this.log_("Listen called for "+r+" "+e._queryIdentifier);const o=bt.getListenId_(e,i),a={};this.listens_[o]=a;const l=ps(e._queryParams);this.restRequest_(r+".json",l,(c,u)=>{let h=u;if(c===404&&(h=null,c=null),c===null&&this.onDataUpdate_(r,h,!1,i),Ae(this.listens_,o)===a){let d;c?c===401?d="permission_denied":d="rest_error:"+c:d="ok",s(d,null)}})}unlisten(e,t){const i=bt.getListenId_(e,t);delete this.listens_[i]}get(e){const t=ps(e._queryParams),i=e._path.toString(),s=new st;return this.restRequest_(i+".json",t,(r,o)=>{let a=o;r===404&&(a=null,r=null),r===null?(this.onDataUpdate_(i,a,!1,null),s.resolve(a)):s.reject(new Error(a))}),s.promise}refreshAuthToken(e){}restRequest_(e,t={},i){return t.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then(([s,r])=>{s&&s.accessToken&&(t.auth=s.accessToken),r&&r.token&&(t.ac=r.token);const o=(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host+e+"?ns="+this.repoInfo_.namespace+ea(t);this.log_("Sending REST request for "+o);const a=new XMLHttpRequest;a.onreadystatechange=()=>{if(i&&a.readyState===4){this.log_("REST Response for "+o+" received. status:",a.status,"response:",a.responseText);let l=null;if(a.status>=200&&a.status<300){try{l=Ye(a.responseText)}catch{L("Failed to parse JSON response for "+o+": "+a.responseText)}i(null,l)}else a.status!==401&&a.status!==404&&L("Got unsuccessful REST response for "+o+" Status: "+a.status),i(a.status);i=null}},a.open("GET",o,!0),a.send()})}}/**
1475 * @license
1476 * Copyright 2017 Google LLC
1477 *
1478 * Licensed under the Apache License, Version 2.0 (the "License");
1479 * you may not use this file except in compliance with the License.
1480 * You may obtain a copy of the License at
1481 *
1482 *   http://www.apache.org/licenses/LICENSE-2.0
1483 *
1484 * Unless required by applicable law or agreed to in writing, software
1485 * distributed under the License is distributed on an "AS IS" BASIS,
1486 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1487 * See the License for the specific language governing permissions and
1488 * limitations under the License.
1489 */class ru{constructor(){this.rootNode_=g.EMPTY_NODE}getNode(e){return this.rootNode_.getChild(e)}updateSnapshot(e,t){this.rootNode_=this.rootNode_.updateChild(e,t)}}/**
1490 * @license
1491 * Copyright 2017 Google LLC
1492 *
1493 * Licensed under the Apache License, Version 2.0 (the "License");
1494 * you may not use this file except in compliance with the License.
1495 * You may obtain a copy of the License at
1496 *
1497 *   http://www.apache.org/licenses/LICENSE-2.0
1498 *
1499 * Unless required by applicable law or agreed to in writing, software
1500 * distributed under the License is distributed on an "AS IS" BASIS,
1501 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1502 * See the License for the specific language governing permissions and
1503 * limitations under the License.
1504 */function Tt(){return{value:null,children:new Map}}function Qr(n,e,t){if(v(e))n.value=t,n.children.clear();else if(n.value!==null)n.value=n.value.updateChild(e,t);else{const i=m(e);n.children.has(i)||n.children.set(i,Tt());const s=n.children.get(i);e=T(e),Qr(s,e,t)}}function kn(n,e,t){n.value!==null?t(e,n.value):ou(n,(i,s)=>{const r=new E(e.toString()+"/"+i);kn(s,r,t)})}
1504function ou(n,e){n.children.forEach((t,i)=>{e(i,t)})}/**
1505 * @license
1506 * Copyright 2017 Google LLC
1507 *
1508 * Licensed under the Apache License, Version 2.0 (the "License");
1509 * you may not use this file except in compliance with the License.
1510 * You may obtain a copy of the License at
1511 *
1512 *   http://www.apache.org/licenses/LICENSE-2.0
1513 *
1514 * Unless required by applicable law or agreed to in writing, software
1515 * distributed under the License is distributed on an "AS IS" BASIS,
1516 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1517 * See the License for the specific language governing permissions and
1518 * limitations under the License.
1519 */class au{constructor(e){this.collection_=e,this.last_=null}get(){const e=this.collection_.get(),t=Object.assign({},e);return this.last_&&P(this.last_,(i,s)=>{t[i]=t[i]-s}),this.last_=e,t}}/**
1520 * @license
1521 * Copyright 2017 Google LLC
1522 *
1523 * Licensed under the Apache License, Version 2.0 (the "License");
1524 * you may not use this file except in compliance with the License.
1525 * You may obtain a copy of the License at
1526 *
1527 *   http://www.apache.org/licenses/LICENSE-2.0
1528 *
1529 * Unless required by applicable law or agreed to in writing, software
1530 * distributed under the License is distributed on an "AS IS" BASIS,
1531 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1532 * See the License for the specific language governing permissions and
1533 * limitations under the License.
1534 */const ms=10*1e3,lu=30*1e3,cu=5*60*1e3;class hu{constructor(e,t){this.server_=t,this.statsToReport_={},this.statsListener_=new au(e);const i=ms+(lu-ms)*Math.random();Ge(this.reportStats_.bind(this),Math.floor(i))}reportStats_(){const e=this.statsListener_.get(),t={};let i=!1;P(e,(s,r)=>{r>0&&z(this.statsToReport_,s)&&(t[s]=r,i=!0)}),i&&this.server_.reportStats(t),Ge(this.reportStats_.bind(this),Math.floor(Math.random()*2*cu))}}/**
1535 * @license
1536 * Copyright 2017 Google LLC
1537 *
1538 * Licensed under the Apache License, Version 2.0 (the "License");
1539 * you may not use this file except in compliance with the License.
1540 * You may obtain a copy of the License at
1541 *
1542 *   http://www.apache.org/licenses/LICENSE-2.0
1543 *
1544 * Unless required by applicable law or agreed to in writing, software
1545 * distributed under the License is distributed on an "AS IS" BASIS,
1546 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1547 * See the License for the specific language governing permissions and
1548 * limitations under the License.
1549 */var H;(function(n){n[n.OVERWRITE=0]="OVERWRITE",n[n.MERGE=1]="MERGE",n[n.ACK_USER_WRITE=2]="ACK_USER_WRITE",n[n.LISTEN_COMPLETE=3]="LISTEN_COMPLETE"})(H||(H={}));function ci(){return{fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}function hi(){return{fromUser:!1,fromServer:!0,queryId:null,tagged:!1}}function ui(n){return{fromUser:!1,fromServer:!0,queryId:n,tagged:!0}}/**
1550 * @license
1551 * Copyright 2017 Google LLC
1552 *
1553 * Licensed under the Apache License, Version 2.0 (the "License");
1554 * you may not use this file except in compliance with the License.
1555 * You may obtain a copy of the License at
1556 *
1557 *   http://www.apache.org/licenses/LICENSE-2.0
1558 *
1559 * Unless required by applicable law or agreed to in writing, software
1560 * distributed under the License is distributed on an "AS IS" BASIS,
1561 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1562 * See the License for the specific language governing permissions and
1563 * limitations under the License.
1564 */class St{constructor(e,t,i){this.path=e,this.affectedTree=t,this.revert=i,this.type=H.ACK_USER_WRITE,this.source=ci()}operationForChild(e){if(v(this.path)){if(this.affectedTree.value!=null)return f(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{const t=this.affectedTree.subtree(new E(e));return new St(C(),t,this.revert)}}else return f(m(this.path)===e,"operationForChild called for unrelated child."),new St(T(this.path),this.affectedTree,this.revert)}}/**
1565 * @license
1566 * Copyright 2017 Google LLC
1567 *
1568 * Licensed under the Apache License, Version 2.0 (the "License");
1569 * you may not use this file except in compliance with the License.
1570 * You may obtain a copy of the License at
1571 *
1572 *   http://www.apache.org/licenses/LICENSE-2.0
1573 *
1574 * Unless required by applicable law or agreed to in writing, software
1575 * distributed under the License is distributed on an "AS IS" BASIS,
1576 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1577 * See the License for the specific language governing permissions and
1578 * limitations under the License.
1579 */class nt{constructor(e,t){this.source=e,this.path=t,this.type=H.LISTEN_COMPLETE}operationForChild(e){return v(this.path)?new nt(this.source,C()):new nt(this.source,T(this.path))}}/**
1580 * @license
1581 * Copyright 2017 Google LLC
1582 *
1583 * Licensed under the Apache License, Version 2.0 (the "License");
1584 * you may not use this file except in compliance with the License.
1585 * You may obtain a copy of the License at
1586 *
1587 *   http://www.apache.org/licenses/LICENSE-2.0
1588 *
1589 * Unless required by applicable law or agreed to in writing, software
1590 * distributed under the License is distributed on an "AS IS" BASIS,
1591 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1592 * See the License for the specific language governing permissions and
1593 * limitations under the License.
1594 */class ye{constructor(e,t,i){this.source=e,this.path=t,this.snap=i,this.type=H.OVERWRITE}operationForChild(e){return v(this.path)?new ye(this.source,C(),this.snap.getImmediateChild(e)):new ye(this.source,T(this.path),this.snap)}}/**
1595 * @license
1596 * Copyright 2017 Google LLC
1597 *
1598 * Licensed under the Apache License, Version 2.0 (the "License");
1599 * you may not use this file except in compliance with the License.
1600 * You may obtain a copy of the License at
1601 *
1602 *   http://www.apache.org/licenses/LICENSE-2.0
1603 *
1604 * Unless required by applicable law or agreed to in writing, software
1605 * distributed under the License is distributed on an "AS IS" BASIS,
1606 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1607 * See the License for the specific language governing permissions and
1608 * limitations under the License.
1609 */class xe{constructor(e,t,i){this.source=e,this.path=t,this.children=i,this.type=H.MERGE}operationForChild(e){if(v(this.path)){const t=this.children.subtree(new E(e));return t.isEmpty()?null:t.value?new ye(this.source,C(),t.value):new xe(this.source,C(),t)}else return f(m(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new xe(this.source,T(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}/**
1610 * @license
1611 * Copyright 2017 Google LLC
1612 *
1613 * Licensed under the Apache License, Version 2.0 (the "License");
1614 * you may not use this file except in compliance with the License.
1615 * You may obtain a copy of the License at
1616 *
1617 *   http://www.apache.org/licenses/LICENSE-2.0
1618 *
1619 * Unless required by applicable law or agreed to in writing, software
1620 * distributed under the License is distributed on an "AS IS" BASIS,
1621 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1622 * See the License for the specific language governing permissions and
1623 * limitations under the License.
1624 */class oe{constructor(e,t,i){this.node_=e,this.fullyInitialized_=t,this.filtered_=i}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(e){if(v(e))return this.isFullyInitialized()&&!this.filtered_;const t=m(e);return this.isCompleteForChild(t)}isCompleteForChild(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)}getNode(){return this.node_}}/**
1625 * @license
1626 * Copyright 2017 Google LLC
1627 *
1628 * Licensed under the Apache License, Version 2.0 (the "License");
1629 * you may not use this file except in compliance with the License.
1630 * You may obtain a copy of the License at
1631 *
1632 *   http://www.apache.org/licenses/LICENSE-2.0
1633 *
1634 * Unless required by applicable law or agreed to in writing, software
1635 * distributed under the License is distributed on an "AS IS" BASIS,
1636 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1637 * See the License for the specific language governing permissions and
1638 * limitations under the License.
1639 */class uu{constructor(e){this.query_=e,this.index_=this.query_._queryParams.getIndex()}}function du(n,e,t,i){const s=[],r=[];return e.forEach(o=>{o.type==="child_changed"&&n.index_.indexedValueChanged(o.oldSnap,o.snapshotNode)&&r.push(nu(o.childName,o.snapshotNode))}
1639),He(n,s,"child_removed",e,i,t),He(n,s,"child_added",e,i,t),He(n,s,"child_moved",r,i,t),He(n,s,"child_changed",e,i,t),He(n,s,"value",e,i,t),s}function He(n,e,t,i,s,r){const o=i.filter(a=>a.type===t);o.sort((a,l)=>_u(n,a,l)),o.forEach(a=>{const l=fu(n,a,r);s.forEach(c=>{c.respondsTo(a.type)&&e.push(c.createEvent(l,n.query_))})})}function fu(n,e,t){return e.type==="value"||e.type==="child_removed"||(e.prevName=t.getPredecessorChildName(e.childName,e.snapshotNode,n.index_)),e}function _u(n,e,t){if(e.childName==null||t.childName==null)throw Le("Should only compare child_ events.");const i=new y(e.childName,e.snapshotNode),s=new y(t.childName,t.snapshotNode);return n.index_.compare(i,s)}/**
1640 * @license
1641 * Copyright 2017 Google LLC
1642 *
1643 * Licensed under the Apache License, Version 2.0 (the "License");
1644 * you may not use this file except in compliance with the License.
1645 * You may obtain a copy of the License at
1646 *
1647 *   http://www.apache.org/licenses/LICENSE-2.0
1648 *
1649 * Unless required by applicable law or agreed to in writing, software
1650 * distributed under the License is distributed on an "AS IS" BASIS,
1651 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1652 * See the License for the specific language governing permissions and
1653 * limitations under the License.
1654 */function Ut(n,e){return{eventCache:n,serverCache:e}}function ze(n,e,t,i){return Ut(new oe(e,t,i),n.serverCache)}function Xr(n,e,t,i){return Ut(n.eventCache,new oe(e,t,i))}function Nt(n){return n.eventCache.isFullyInitialized()?n.eventCache.getNode():null}function ve(n){return n.serverCache.isFullyInitialized()?n.serverCache.getNode():null}/**
1655 * @license
1656 * Copyright 2017 Google LLC
1657 *
1658 * Licensed under the Apache License, Version 2.0 (the "License");
1659 * you may not use this file except in compliance with the License.
1660 * You may obtain a copy of the License at
1661 *
1662 *   http://www.apache.org/licenses/LICENSE-2.0
1663 *
1664 * Unless required by applicable law or agreed to in writing, software
1665 * distributed under the License is distributed on an "AS IS" BASIS,
1666 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1667 * See the License for the specific language governing permissions and
1668 * limitations under the License.
1669 */let _n;const pu=()=>(_n||(_n=new F(Zc)),_n);class I{constructor(e,t=pu()){this.value=e,this.children=t}static fromObject(e){let t=new I(null);return P(e,(i,s)=>{t=t.set(new E(i),s)}),t}isEmpty(){return this.value===null&&this.children.isEmpty()}findRootMostMatchingPathAndValue(e,t){if(this.value!=null&&t(this.value))return{path:C(),value:this.value};if(v(e))return null;{const i=m(e),s=this.children.get(i);if(s!==null){const r=s.findRootMostMatchingPathAndValue(T(e),t);return r!=null?{path:S(new E(i),r.path),value:r.value}:null}else return null}}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,()=>!0)}subtree(e){if(v(e))return this;{const t=m(e),i=this.children.get(t);return i!==null?i.subtree(T(e)):new I(null)}}set(e,t){if(v(e))return new I(t,this.children);{const i=m(e),r=(this.children.get(i)||new I(null)).set(T(e),t),o=this.children.insert(i,r);return new I(this.value,o)}}remove(e){if(v(e))return this.children.isEmpty()?new I(null):new I(null,this.children);{const t=m(e),i=this.children.get(t);if(i){const s=i.remove(T(e));let r;return s.isEmpty()?r=this.children.remove(t):r=this.children.insert(t,s),this.value===null&&r.isEmpty()?new I(null):new I(this.value,r)}else return this}}get(e){if(v(e))return this.value;{const t=m(e),i=this.children.get(t);return i?i.get(T(e)):null}}setTree(e,t){if(v(e))return t;{const i=m(e),r=(this.children.get(i)||new I(null)).setTree(T(e),t);let o;return r.isEmpty()?o=this.children.remove(i):o=this.children.insert(i,r),new I(this.value,o)}}fold(e){return this.fold_(C(),e)}fold_(e,t){const i={};return this.children.inorderTraversal((s,r)=>{i[s]=r.fold_(S(e,s),t)}),t(e,this.value,i)}findOnPath(e,t){return this.findOnPath_(e,C(),t)}findOnPath_(e,t,i){const s=this.value?i(t,this.value):!1;if(s)return s;if(v(e))return null;{const r=m(e),o=this.children.get(r);return o?o.findOnPath_(T(e),S(t,r),i):null}}foreachOnPath(e,t){return this.foreachOnPath_(e,C(),t)}foreachOnPath_(e,t,i){if(v(e))return this;{this.value&&i(t,this.value);const s=m(e),r=this.children.get(s);return r?r.foreachOnPath_(T(e),S(t,s),i):new I(null)}}foreach(e){this.foreach_(C(),e)}foreach_(e,t){this.children.inorderTraversal((i,s)=>{s.foreach_(S(e,i),t)}),this.value&&t(e,this.value)}foreachChild(e){this.children.inorderTraversal((t,i)=>{i.value&&e(t,i.value)})}}/**
1670 * @license
1671 * Copyright 2017 Google LLC
1672 *
1673 * Licensed under the Apache License, Version 2.0 (the "License");
1674 * you may not use this file except in compliance with the License.
1675 * You may obtain a copy of the License at
1676 *
1677 *   http://www.apache.org/licenses/LICENSE-2.0
1678 *
1679 * Unless required by applicable law or agreed to in writing, software
1680 * distributed under the License is distributed on an "AS IS" BASIS,
1681 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1682 * See the License for the specific language governing permissions and
1683 * limitations under the License.
1684 */class j{constructor(e){this.writeTree_=e}static empty(){return new j(new I(null))}}function qe(n,e,t){if(v(e))return new j(new I(t));{const i=n.writeTree_.findRootMostValueAndPath(e);if(i!=null){const s=i.path;let r=i.value;const o=M(s,e);return r=r.updateChild(o,t),new j(n.writeTree_.set(s,r))}else{const s=new I(t),r=n.writeTree_.setTree(e,s);return new j(r)}}}function Dn(n,e,t){let i=n;return P(t,(s,r)=>{i=qe(i,S(e,s),r)}),i}function ys(n,e){if(v(e))return j.empty();{const t=n.writeTree_.setTree(e,new I(null));return new j(t)}}function xn(n,e){return we(n,e)!=null}function we(n,e){const t=n.writeTree_.findRootMostValueAndPath(e);return t!=null?n.writeTree_.get(t.path).getChild(M(t.path,e)):null}function vs(n){const e=[],t=n.writeTree_.value;return t!=null?t.isLeafNode()||t.forEachChild(N,(i,s)=>{e.push(new y(i,s))}):n.writeTree_.children.inorderTraversal((i,s)=>{s.value!=null&&e.push(new y(i,s.value))}),e}function ne(n,e){if(v(e))return n;{const t=we(n,e);return t!=null?new j(new I(t)):new j(n.writeTree_.subtree(e))}}function Pn(n){return n.writeTree_.isEmpty()}function Pe(n,e){return Jr(C(),n.writeTree_,e)}function Jr(n,e,t){if(e.value!=null)return t.updateChild(n,e.value);{let i=null;return e.children.inorderTraversal((s,r)=>{s===".priority"?(f(r.value!==null,"Priority writes must always be leaf nodes"),i=r.value):t=Jr(S(n,s),r,t)}),!t.getChild(n).isEmpty()&&i!==null&&(t=t.updateChild(S(n,".priority"),i)),t}}/**
1685 * @license
1686 * Copyright 2017 Google LLC
1687 *
1688 * Licensed under the Apache License, Version 2.0 (the "License");
1689 * you may not use this file except in compliance with the License.
1690 * You may obtain a copy of the License at
1691 *
1692 *   http://www.apache.org/licenses/LICENSE-2.0
1693 *
1694 * Unless required by applicable law or agreed to in writing, software
1695 * distributed under the License is distributed on an "AS IS" BASIS,
1696 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1697 * See the License for the specific language governing permissions and
1698 * limitations under the License.
1699 */function Vt(n,e){return no(e,n)}function gu(n,e,t,i,s){f(i>n.lastWriteId,"Stacking an older write on top of newer ones"),s===void 0&&(s=!0),n.allWrites.push({path:e,snap:t,writeId:i,visible:s}),s&&(n.visibleWrites=qe(n.visibleWrites,e,t)),n.lastWriteId=i}function mu(n,e,t,i){f(i>n.lastWriteId,"Stacking an older merge on top of newer ones"),n.allWrites.push({path:e,children:t,writeId:i,visible:!0}),n.visibleWrites=Dn(n.visibleWrites,e,t),n.lastWriteId=i}function yu(n,e){for(let t=0;t<n.allWrites.length;t++){const i=n.allWrites[t];if(i.writeId===e)return i}return null}function vu(n,e){const t=n.allWrites.findIndex(a=>a.writeId===e);f(t>=0,"removeWrite called with nonexistent writeId.");const i=n.allWrites[t];n.allWrites.splice(t,1);let s=i.visible,r=!1,o=n.allWrites.length-1;for(;s&&o>=0;){const a=n.allWrites[o];a.visible&&(o>=t&&Cu(a,i.path)?s=!1:$(i.path,a.path)&&(r=!0)),o--}if(s){if(r)return Eu(n),!0;if(i.snap)n.visibleWrites=ys(n.visibleWrites,i.path);else{const a=i.children;P(a,l=>{n.visibleWrites=ys(n.visibleWrites,S(i.path,l))})}return!0}else return!1}function Cu(n,e){if(n.snap)return $(n.path,e);for(const t in n.children)if(n.children.hasOwnProperty(t)&&$(S(n.path,t),e))return!0;return!1}function Eu(n){n.visibleWrites=Zr(n.allWrites,wu,C()),n.allWrites.length>0?n.lastWriteId=n.allWrites[n.allWrites.length-1].writeId:n.lastWriteId=-1}function wu(n){return n.visible}function Zr(n,e,t){let i=j.empty();for(let s=0;s<n.length;++s){const r=n[s];if(e(r)){const o=r.path;let a;if(r.snap)$(t,o)?(a=M(t,o),i=qe(i,a,r.snap)):$(o,t)&&(a=M(o,t),i=qe(i,C(),r.snap.getChild(a)));else if(r.children){if($(t,o))a=M(t,o),i=Dn(i,a,r.children);else if($(o,t))if(a=M(o,t),v(a))i=Dn(i,C(),r.children);else{const l=Ae(r.children,m(a));if(l){const c=l.getChild(T(a));i=qe(i,C(),c)}}}else throw Le("WriteRecord should have .snap or .children")}}return i}function eo(n,e,t,i,s){if(!i&&!s){const r=we(n.visibleWrites,e);if(r!=null)return r;{const o=ne(n.visibleWrites,e);if(Pn(o))return t;if(t==null&&!xn(o,C()))return null;{const a=t||g.EMPTY_NODE;return Pe(o,a)}}}else{const r=ne(n.visibleWrites,e);if(!s&&Pn(r))return t;if(!s&&t==null&&!xn(r,C()))return null;{const o=function(c){return(c.visible||s)&&(!i||!~i.indexOf(c.writeId))&&($(c.path,e)||$(e,c.path))},a=Zr(n.allWrites,o,e),l=t||g.EMPTY_NODE;return Pe(a,l)}}}function Iu(n,e,t){let i=g.EMPTY_NODE;const s=we(n.visibleWrites,e);
1699if(s)return s.isLeafNode()||s.forEachChild(N,(r,o)=>{i=i.updateImmediateChild(r,o)}),i;if(t){const r=ne(n.visibleWrites,e);return t.forEachChild(N,(o,a)=>{const l=Pe(ne(r,new E(o)),a);i=i.updateImmediateChild(o,l)}),vs(r).forEach(o=>{i=i.updateImmediateChild(o.name,o.node)}),i}else{const r=ne(n.visibleWrites,e);return vs(r).forEach(o=>{i=i.updateImmediateChild(o.name,o.node)}),i}}function bu(n,e,t,i,s){f(i||s,"Either existingEventSnap or existingServerSnap must exist");const r=S(e,t);if(xn(n.visibleWrites,r))return null;{const o=ne(n.visibleWrites,r);return Pn(o)?s.getChild(t):Pe(o,s.getChild(t))}}function Tu(n,e,t,i){const s=S(e,t),r=we(n.visibleWrites,s);if(r!=null)return r;if(i.isCompleteForChild(t)){const o=ne(n.visibleWrites,s);return Pe(o,i.getNode().getImmediateChild(t))}else return null}function Su(n,e){return we(n.visibleWrites,e)}function Nu(n,e,t,i,s,r,o){let a;const l=ne(n.visibleWrites,e),c=we(l,C());if(c!=null)a=c;else if(t!=null)a=Pe(l,t);else return[];if(a=a.withIndex(o),!a.isEmpty()&&!a.isLeafNode()){const u=[],h=o.getCompare(),d=r?a.getReverseIteratorFrom(i,o):a.getIteratorFrom(i,o);let _=d.getNext();for(;_&&u.length<s;)h(_,i)!==0&&u.push(_),_=d.getNext();return u}else return[]}function Ru(){return{visibleWrites:j.empty(),allWrites:[],lastWriteId:-1}}function Rt(n,e,t,i){return eo(n.writeTree,n.treePath,e,t,i)}function di(n,e){return Iu(n.writeTree,n.treePath,e)}function Cs(n,e,t,i){return bu(n.writeTree,n.treePath,e,t,i)}function At(n,e){return Su(n.writeTree,S(n.treePath,e))}function Au(n,e,t,i,s,r){return Nu(n.writeTree,n.treePath,e,t,i,s,r)}function fi(n,e,t){return Tu(n.writeTree,n.treePath,e,t)}function to(n,e){return no(S(n.treePath,e),n.writeTree)}function no(n,e){return{treePath:n,writeTree:e}}/**
1700 * @license
1701 * Copyright 2017 Google LLC
1702 *
1703 * Licensed under the Apache License, Version 2.0 (the "License");
1704 * you may not use this file except in compliance with the License.
1705 * You may obtain a copy of the License at
1706 *
1707 *   http://www.apache.org/licenses/LICENSE-2.0
1708 *
1709 * Unless required by applicable law or agreed to in writing, software
1710 * distributed under the License is distributed on an "AS IS" BASIS,
1711 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1712 * See the License for the specific language governing permissions and
1713 * limitations under the License.
1714 */class ku{constructor(){this.changeMap=new Map}trackChildChange(e){const t=e.type,i=e.childName;f(t==="child_added"||t==="child_changed"||t==="child_removed","Only child changes supported for tracking"),f(i!==".priority","Only non-priority child changes can be tracked.");const s=this.changeMap.get(i);if(s){const r=s.type;if(t==="child_added"&&r==="child_removed")this.changeMap.set(i,et(i,e.snapshotNode,s.snapshotNode));else if(t==="child_removed"&&r==="child_added")this.changeMap.delete(i);else if(t==="child_removed"&&r==="child_changed")this.changeMap.set(i,Ze(i,s.oldSnap));else if(t==="child_changed"&&r==="child_added")this.changeMap.set(i,De(i,e.snapshotNode));else if(t==="child_changed"&&r==="child_changed")this.changeMap.set(i,et(i,e.snapshotNode,s.oldSnap));else throw Le("Illegal combination of changes: "+e+" occurred after "+s)}else this.changeMap.set(i,e)}getChanges(){return Array.from(this.changeMap.values())}}/**
1715 * @license
1716 * Copyright 2017 Google LLC
1717 *
1718 * Licensed under the Apache License, Version 2.0 (the "License");
1719 * you may not use this file except in compliance with the License.
1720 * You may obtain a copy of the License at
1721 *
1722 *   http://www.apache.org/licenses/LICENSE-2.0
1723 *
1724 * Unless required by applicable law or agreed to in writing, software
1725 * distributed under the License is distributed on an "AS IS" BASIS,
1726 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1727 * See the License for the specific language governing permissions and
1728 * limitations under the License.
1729 */class Du{getCompleteChild(e){return null}getChildAfterChild(e,t,i){return null}}const io=new Du;class _i{constructor(e,t,i=null){this.writes_=e,this.viewCache_=t,this.optCompleteServerCache_=i}getCompleteChild(e){const t=this.viewCache_.eventCache;if(t.isCompleteForChild(e))return t.getNode().getImmediateChild(e);{const i=this.optCompleteServerCache_!=null?new oe(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return fi(this.writes_,e,i)}}getChildAfterChild(e,t,i){const s=this.optCompleteServerCache_!=null?this.optCompleteServerCache_:ve(this.viewCache_),r=Au(this.writes_,s,t,1,i,e);return r.length===0?null:r[0]}}/**
1730 * @license
1731 * Copyright 2017 Google LLC
1732 *
1733 * Licensed under the Apache License, Version 2.0 (the "License");
1734 * you may not use this file except in compliance with the License.
1735 * You may obtain a copy of the License at
1736 *
1737 *   http://www.apache.org/licenses/LICENSE-2.0
1738 *
1739 * Unless required by applicable law or agreed to in writing, software
1740 * distributed under the License is distributed on an "AS IS" BASIS,
1741 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1742 * See the License for the specific language governing permissions and
1743 * limitations under the License.
1744 */function xu(n){return{filter:n}}function Pu(n,e){f(e.eventCache.getNode().isIndexed(n.filter.getIndex()),"Event snap not indexed"),f(e.serverCache.getNode().isIndexed(n.filter.getIndex()),"Server snap not indexed")}function Ou(n,e,t,i,s){const r=new ku;let o,a;if(t.type===H.OVERWRITE){const c=t;c.source.fromUser?o=On(n,e,c.path,c.snap,i,s,r):(f(c.source.fromServer,"Unknown source."),a=c.source.tagged||e.serverCache.isFiltered()&&!v(c.path),o=kt(n,e,c.path,c.snap,i,s,a,r))}else if(t.type===H.MERGE){const c=t;c.source.fromUser?o=Lu(n,e,c.path,c.children,i,s,r):(f(c.source.fromServer,"Unknown source."),a=c.source.tagged||e.serverCache.isFiltered(),o=Mn(n,e,c.path,c.children,i,s,a,r))}else if(t.type===H.ACK_USER_WRITE){const c=t;c.revert?o=Wu(n,e,c.path,i,s,r):o=Fu(n,e,c.path,c.affectedTree,i,s,r)}else if(t.type===H.LISTEN_COMPLETE)o=Bu(n,e,t.path,i,r);else throw Le("Unknown operation type: "+t.type);const l=r.getChanges();return Mu(e,o,l),{viewCache:o,changes:l}}function Mu(n,e,t){const i=e.eventCache;if(i.isFullyInitialized()){const s=i.getNode().isLeafNode()||i.getNode().isEmpty(),r=Nt(n);(t.length>0||!n.eventCache.isFullyInitialized()||s&&!i.getNode().equals(r)||!i.getNode().getPriority().equals(r.getPriority()))&&t.push(Yr(Nt(e)))}}function so(n,e,t,i,s,r){const o=e.eventCache;if(At(i,t)!=null)return e;{let a,l;if(v(t))if(f(e.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),e.serverCache.isFiltered()){const c=ve(e),u=c instanceof g?c:g.EMPTY_NODE,h=di(i,u);a=n.filter.updateFullNode(e.eventCache.getNode(),h,r)}else{const c=Rt(i,ve(e));a=n.filter.updateFullNode(e.eventCache.getNode(),c,r)}else{const c=m(t);if(c===".priority"){f(re(t)===1,"Can't have a priority with additional path components");const u=o.getNode();l=e.serverCache.getNode();const h=Cs(i,t,u,l);h!=null?a=n.filter.updatePriority(u,h):a=o.getNode()}else{const u=T(t);let h;if(o.isCompleteForChild(c)){l=e.serverCache.getNode();const d=Cs(i,t,o.getNode(),l);d!=null?h=o.getNode().getImmediateChild(c).updateChild(u,d):h=o.getNode().getImmediateChild(c)}else h=fi(i,c,e.serverCache);h!=null?a=n.filter.updateChild(o.getNode(),c,h,u,s,r):a=o.getNode()}}return ze(e,a,o.isFullyInitialized()||v(t),n.filter.filtersNodes())}}function kt(n,e,t,i,s,r,o,a){const l=e.serverCache;let c;const u=o?n.filter:n.filter.getIndexedFilter();if(v(t))c=u.updateFullNode(l.getNode(),i,null);else if(u.filtersNodes()&&!l.isFiltered()){const _=l.getNode().updateChild(t,i);c=u.updateFullNode(l.getNode(),_,null)}else{const _=m(t);if(!l.isCompleteForPath(t)&&re(t)>1)return e;const p=T(t),O=l.getNode().getImmediateChild(_).updateChild(p,i);_===".priority"?c=u.updatePriority(l.getNode(),O):c=u.updateChild(l.getNode(),_,O,p,io,null)}const h=Xr(e,c,l.isFullyInitialized()||v(t),u.filtersNodes()),d=new _i(s,h,r);return so(n,h,t,s,d,a)}function On(n,e,t,i,s,r,o){const a=e.eventCache;let l,c;const u=new _i(s,e,r);if(v(t))c=n.filter.updateFullNode(e.eventCache.getNode(),i,o),l=ze(e,c,!0,n.filter.filtersNodes());else{const h=m(t);if(h===".priority")c=n.filter.updatePriority(e.eventCache.getNode(),i),l=ze(e,c,a.isFullyInitialized(),a.isFiltered());else{const d=T(t),_=a.getNode().getImmediateChild(h);let p;if(v(d))p=i;else{const w=u.getCompleteChild(h);w!=null?ii(d)===".priority"&&w.getChild(Vr(d)).isEmpty()?p=w:p=w.updateChild(d,i):p=g.EMPTY_NODE}if(_.equals(p))l=e;else{const w=n.filter.updateChild(a.getNode(),h,p,d,u,o);l=ze(e,w,a.isFullyInitialized(),n.filter.filtersNodes())}}}return l}function Es(n,e){return n.eventCache.isCompleteForChild(e)}function Lu(n,e,t,i,s,r,o){let a=e;return i.foreach((l,c)=>{const u=S(t,l);Es(e,m(u))&&(a=On(n,a,u,c,s,r,o))}),i.foreach((l,c)=>{const u=S(t,l);Es(e,m(u))||(a=On(n,a,u,c,s,r,o))}),a}function ws(n,e,t){return t.foreach((i,s)=>{e=e.updateChild(i,s)}),e}function Mn(n,e,t,i,s,r,o,a){if(e.serverCache.getNode().isEmpty()&&!e.serverCache.isFullyInitialized())return e;let l=e,c;v(t)?c=i:c=new I(null).setTree(t,i);const u=e.serverCache.getNode();return c.children.inorderTraversal((h,d)=>
1744{if(u.hasChild(h)){const _=e.serverCache.getNode().getImmediateChild(h),p=ws(n,_,d);l=kt(n,l,new E(h),p,s,r,o,a)}}),c.children.inorderTraversal((h,d)=>{const _=!e.serverCache.isCompleteForChild(h)&&d.value===null;if(!u.hasChild(h)&&!_){const p=e.serverCache.getNode().getImmediateChild(h),w=ws(n,p,d);l=kt(n,l,new E(h),w,s,r,o,a)}}),l}function Fu(n,e,t,i,s,r,o){if(At(s,t)!=null)return e;const a=e.serverCache.isFiltered(),l=e.serverCache;if(i.value!=null){if(v(t)&&l.isFullyInitialized()||l.isCompleteForPath(t))return kt(n,e,t,l.getNode().getChild(t),s,r,a,o);if(v(t)){let c=new I(null);return l.getNode().forEachChild(Re,(u,h)=>{c=c.set(new E(u),h)}),Mn(n,e,t,c,s,r,a,o)}else return e}else{let c=new I(null);return i.foreach((u,h)=>{const d=S(t,u);l.isCompleteForPath(d)&&(c=c.set(u,l.getNode().getChild(d)))}),Mn(n,e,t,c,s,r,a,o)}}function Bu(n,e,t,i,s){const r=e.serverCache,o=Xr(e,r.getNode(),r.isFullyInitialized()||v(t),r.isFiltered());return so(n,o,t,i,io,s)}function Wu(n,e,t,i,s,r){let o;if(At(i,t)!=null)return e;{const a=new _i(i,e,s),l=e.eventCache.getNode();let c;if(v(t)||m(t)===".priority"){let u;if(e.serverCache.isFullyInitialized())u=Rt(i,ve(e));else{const h=e.serverCache.getNode();f(h instanceof g,"serverChildren would be complete if leaf node"),u=di(i,h)}u=u,c=n.filter.updateFullNode(l,u,r)}else{const u=m(t);let h=fi(i,u,e.serverCache);h==null&&e.serverCache.isCompleteForChild(u)&&(h=l.getImmediateChild(u)),h!=null?c=n.filter.updateChild(l,u,h,T(t),a,r):e.eventCache.getNode().hasChild(u)?c=n.filter.updateChild(l,u,g.EMPTY_NODE,T(t),a,r):c=l,c.isEmpty()&&e.serverCache.isFullyInitialized()&&(o=Rt(i,ve(e)),o.isLeafNode()&&(c=n.filter.updateFullNode(c,o,r)))}return o=e.serverCache.isFullyInitialized()||At(i,C())!=null,ze(e,c,o,n.filter.filtersNodes())}}/**
1745 * @license
1746 * Copyright 2017 Google LLC
1747 *
1748 * Licensed under the Apache License, Version 2.0 (the "License");
1749 * you may not use this file except in compliance with the License.
1750 * You may obtain a copy of the License at
1751 *
1752 *   http://www.apache.org/licenses/LICENSE-2.0
1753 *
1754 * Unless required by applicable law or agreed to in writing, software
1755 * distributed under the License is distributed on an "AS IS" BASIS,
1756 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1757 * See the License for the specific language governing permissions and
1758 * limitations under the License.
1759 */class $u{constructor(e,t){this.query_=e,this.eventRegistrations_=[];const i=this.query_._queryParams,s=new ai(i.getIndex()),r=su(i);this.processor_=xu(r);const o=t.serverCache,a=t.eventCache,l=s.updateFullNode(g.EMPTY_NODE,o.getNode(),null),c=r.updateFullNode(g.EMPTY_NODE,a.getNode(),null),u=new oe(l,o.isFullyInitialized(),s.filtersNodes()),h=new oe(c,a.isFullyInitialized(),r.filtersNodes());this.viewCache_=Ut(h,u),this.eventGenerator_=new uu(this.query_)}get query(){return this.query_}}function Uu(n){return n.viewCache_.serverCache.getNode()}function Vu(n){return Nt(n.viewCache_)}function Hu(n,e){const t=ve(n.viewCache_);return t&&(n.query._queryParams.loadsAllData()||!v(e)&&!t.getImmediateChild(m(e)).isEmpty())?t.getChild(e):null}function Is(n){return n.eventRegistrations_.length===0}function ju(n,e){n.eventRegistrations_.push(e)}function bs(n,e,t){const i=[];if(t){f(e==null,"A cancel should cancel all event registrations.");const s=n.query._path;n.eventRegistrations_.forEach(r=>{const o=r.createCancelEvent(t,s);o&&i.push(o)})}if(e){let s=[];for(let r=0;r<n.eventRegistrations_.length;++r){const o=n.eventRegistrations_[r];if(!o.matches(e))s.push(o);else if(e.hasAnyCallback()){s=s.concat(n.eventRegistrations_.slice(r+1));break}}n.eventRegistrations_=s}else n.eventRegistrations_=[];return i}function Ts(n,e,t,i){e.type===H.MERGE&&e.source.queryId!==null&&(f(ve(n.viewCache_),"We should always have a full cache before handling merges"),f(Nt(n.viewCache_),"Missing event cache, even though we have a server cache"));const s=n.viewCache_,r=Ou(n.processor_,s,e,t,i);return Pu(n.processor_,r.viewCache),f(r.viewCache.serverCache.isFullyInitialized()||!s.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),n.viewCache_=r.viewCache,ro(n,r.changes,r.viewCache.eventCache.getNode(),null)}function Gu(n,e){const t=n.viewCache_.eventCache,i=[];
1759return t.getNode().isLeafNode()||t.getNode().forEachChild(N,(r,o)=>{i.push(De(r,o))}),t.isFullyInitialized()&&i.push(Yr(t.getNode())),ro(n,i,t.getNode(),e)}function ro(n,e,t,i){const s=i?[i]:n.eventRegistrations_;return du(n.eventGenerator_,e,t,s)}/**
1760 * @license
1761 * Copyright 2017 Google LLC
1762 *
1763 * Licensed under the Apache License, Version 2.0 (the "License");
1764 * you may not use this file except in compliance with the License.
1765 * You may obtain a copy of the License at
1766 *
1767 *   http://www.apache.org/licenses/LICENSE-2.0
1768 *
1769 * Unless required by applicable law or agreed to in writing, software
1770 * distributed under the License is distributed on an "AS IS" BASIS,
1771 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1772 * See the License for the specific language governing permissions and
1773 * limitations under the License.
1774 */let Dt;class oo{constructor(){this.views=new Map}}function zu(n){f(!Dt,"__referenceConstructor has already been defined"),Dt=n}function qu(){return f(Dt,"Reference.ts has not been loaded"),Dt}function Ku(n){return n.views.size===0}function pi(n,e,t,i){const s=e.source.queryId;if(s!==null){const r=n.views.get(s);return f(r!=null,"SyncTree gave us an op for an invalid query."),Ts(r,e,t,i)}else{let r=[];for(const o of n.views.values())r=r.concat(Ts(o,e,t,i));return r}}function ao(n,e,t,i,s){const r=e._queryIdentifier,o=n.views.get(r);if(!o){let a=Rt(t,s?i:null),l=!1;a?l=!0:i instanceof g?(a=di(t,i),l=!1):(a=g.EMPTY_NODE,l=!1);const c=Ut(new oe(a,l,!1),new oe(i,s,!1));return new $u(e,c)}return o}function Yu(n,e,t,i,s,r){const o=ao(n,e,i,s,r);return n.views.has(e._queryIdentifier)||n.views.set(e._queryIdentifier,o),ju(o,t),Gu(o,t)}function Qu(n,e,t,i){const s=e._queryIdentifier,r=[];let o=[];const a=ae(n);if(s==="default")for(const[l,c]of n.views.entries())o=o.concat(bs(c,t,i)),Is(c)&&(n.views.delete(l),c.query._queryParams.loadsAllData()||r.push(c.query));else{const l=n.views.get(s);l&&(o=o.concat(bs(l,t,i)),Is(l)&&(n.views.delete(s),l.query._queryParams.loadsAllData()||r.push(l.query)))}return a&&!ae(n)&&r.push(new(qu())(e._repo,e._path)),{removed:r,events:o}}function lo(n){const e=[];for(const t of n.views.values())t.query._queryParams.loadsAllData()||e.push(t);return e}function ie(n,e){let t=null;for(const i of n.views.values())t=t||Hu(i,e);return t}function co(n,e){if(e._queryParams.loadsAllData())return Ht(n);{const i=e._queryIdentifier;return n.views.get(i)}}function ho(n,e){return co(n,e)!=null}function ae(n){return Ht(n)!=null}function Ht(n){for(const e of n.views.values())if(e.query._queryParams.loadsAllData())return e;return null}/**
1775 * @license
1776 * Copyright 2017 Google LLC
1777 *
1778 * Licensed under the Apache License, Version 2.0 (the "License");
1779 * you may not use this file except in compliance with the License.
1780 * You may obtain a copy of the License at
1781 *
1782 *   http://www.apache.org/licenses/LICENSE-2.0
1783 *
1784 * Unless required by applicable law or agreed to in writing, software
1785 * distributed under the License is distributed on an "AS IS" BASIS,
1786 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1787 * See the License for the specific language governing permissions and
1788 * limitations under the License.
1789 */let xt;function Xu(n){f(!xt,"__referenceConstructor has already been defined"),xt=n}function Ju(){return f(xt,"Reference.ts has not been loaded"),xt}let Zu=1;class Ss{constructor(e){this.listenProvider_=e,this.syncPointTree_=new I(null),this.pendingWriteTree_=Ru(),this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function uo(n,e,t,i,s){return gu(n.pendingWriteTree_,e,t,i,s),s?Be(n,new ye(ci(),e,t)):[]}function ed(n,e,t,i){mu(n.pendingWriteTree_,e,t,i);const s=I.fromObject(t);return Be(n,new xe(ci(),e,s))}function J(n,e,t=!1){const i=yu(n.pendingWriteTree_,e);if(vu(n.pendingWriteTree_,e)){let r=new I(null);return i.snap!=null?r=r.set(C(),!0):P(i.children,o=>{r=r.set(new E(o),!0)}),Be(n,new St(i.path,r,t))}else return[]}function ct(n,e,t){return Be(n,new ye(hi(),e,t))}function td(n,e,t){const i=I.fromObject(t);return Be(n,new xe(hi(),e,i))}function nd(n,e){return Be(n,new nt(hi(),e))}function id(n,e,t){const i=mi(n,t);if(i){const s=yi(i),r=s.path,o=s.queryId,a=M(r,e),l=new nt(ui(o),a);return vi(n,r,l)}else return[]}function Pt(n,e,t,i,s=!1){const r=e._path,o=n.syncPointTree_.get(r);let a=[];if(o&&(e._queryIdentifier==="default"||ho(o,e))){const l=Qu(o,e,t,i);Ku(o)&&(n.syncPointTree_=n.syncPointTree_.remove(r));const c=l.removed;if(a=l.events,!s){const u=c.findIndex(d=>d._queryParams.loadsAllData())!==-1,h=n.syncPointTree_.findOnPath(r,(d,_)=>ae(_));if(u&&!h){const d=n.syncPointTree_.subtree(r);if(!d.isEmpty()){const _=od(d);for(let p=0;p<_.length;++p){const w=_[p],O=w.query,Ie=go(n,w);
1789n.listenProvider_.startListening(Ke(O),it(n,O),Ie.hashFn,Ie.onComplete)}}}!h&&c.length>0&&!i&&(u?n.listenProvider_.stopListening(Ke(e),null):c.forEach(d=>{const _=n.queryToTagMap.get(jt(d));n.listenProvider_.stopListening(Ke(d),_)}))}ad(n,c)}return a}function fo(n,e,t,i){const s=mi(n,i);if(s!=null){const r=yi(s),o=r.path,a=r.queryId,l=M(o,e),c=new ye(ui(a),l,t);return vi(n,o,c)}else return[]}function sd(n,e,t,i){const s=mi(n,i);if(s){const r=yi(s),o=r.path,a=r.queryId,l=M(o,e),c=I.fromObject(t),u=new xe(ui(a),l,c);return vi(n,o,u)}else return[]}function Ln(n,e,t,i=!1){const s=e._path;let r=null,o=!1;n.syncPointTree_.foreachOnPath(s,(d,_)=>{const p=M(d,s);r=r||ie(_,p),o=o||ae(_)});let a=n.syncPointTree_.get(s);a?(o=o||ae(a),r=r||ie(a,C())):(a=new oo,n.syncPointTree_=n.syncPointTree_.set(s,a));let l;r!=null?l=!0:(l=!1,r=g.EMPTY_NODE,n.syncPointTree_.subtree(s).foreachChild((_,p)=>{const w=ie(p,C());w&&(r=r.updateImmediateChild(_,w))}));const c=ho(a,e);if(!c&&!e._queryParams.loadsAllData()){const d=jt(e);f(!n.queryToTagMap.has(d),"View does not exist, but we have a tag");const _=ld();n.queryToTagMap.set(d,_),n.tagToQueryMap.set(_,d)}const u=Vt(n.pendingWriteTree_,s);let h=Yu(a,e,t,u,r,l);if(!c&&!o&&!i){const d=co(a,e);h=h.concat(cd(n,e,d))}return h}function gi(n,e,t){const s=n.pendingWriteTree_,r=n.syncPointTree_.findOnPath(e,(o,a)=>{const l=M(o,e),c=ie(a,l);if(c)return c});return eo(s,e,r,t,!0)}function rd(n,e){const t=e._path;let i=null;n.syncPointTree_.foreachOnPath(t,(c,u)=>{const h=M(c,t);i=i||ie(u,h)});let s=n.syncPointTree_.get(t);s?i=i||ie(s,C()):(s=new oo,n.syncPointTree_=n.syncPointTree_.set(t,s));const r=i!=null,o=r?new oe(i,!0,!1):null,a=Vt(n.pendingWriteTree_,e._path),l=ao(s,e,a,r?o.getNode():g.EMPTY_NODE,r);return Vu(l)}function Be(n,e){return _o(e,n.syncPointTree_,null,Vt(n.pendingWriteTree_,C()))}function _o(n,e,t,i){if(v(n.path))return po(n,e,t,i);{const s=e.get(C());t==null&&s!=null&&(t=ie(s,C()));let r=[];const o=m(n.path),a=n.operationForChild(o),l=e.children.get(o);if(l&&a){const c=t?t.getImmediateChild(o):null,u=to(i,o);r=r.concat(_o(a,l,c,u))}return s&&(r=r.concat(pi(s,n,i,t))),r}}function po(n,e,t,i){const s=e.get(C());t==null&&s!=null&&(t=ie(s,C()));let r=[];return e.children.inorderTraversal((o,a)=>{const l=t?t.getImmediateChild(o):null,c=to(i,o),u=n.operationForChild(o);u&&(r=r.concat(po(u,a,l,c)))}),s&&(r=r.concat(pi(s,n,i,t))),r}function go(n,e){const t=e.query,i=it(n,t);return{hashFn:()=>(Uu(e)||g.EMPTY_NODE).hash(),onComplete:s=>{if(s==="ok")return i?id(n,t._path,i):nd(n,t._path);{const r=nh(s,t);return Pt(n,t,null,r)}}}}function it(n,e){const t=jt(e);return n.queryToTagMap.get(t)}function jt(n){return n._path.toString()+"$"+n._queryIdentifier}function mi(n,e){return n.tagToQueryMap.get(e)}function yi(n){const e=n.indexOf("$");return f(e!==-1&&e<n.length-1,"Bad queryKey."),{queryId:n.substr(e+1),path:new E(n.substr(0,e))}}function vi(n,e,t){const i=n.syncPointTree_.get(e);f(i,"Missing sync point for query tag that we're tracking");const s=Vt(n.pendingWriteTree_,e);return pi(i,t,s,null)}function od(n){return n.fold((e,t,i)=>{if(t&&ae(t))return[Ht(t)];{let s=[];return t&&(s=lo(t)),P(i,(r,o)=>{s=s.concat(o)}),s}})}
1789function Ke(n){return n._queryParams.loadsAllData()&&!n._queryParams.isDefault()?new(Ju())(n._repo,n._path):n}function ad(n,e){for(let t=0;t<e.length;++t){const i=e[t];if(!i._queryParams.loadsAllData()){const s=jt(i),r=n.queryToTagMap.get(s);n.queryToTagMap.delete(s),n.tagToQueryMap.delete(r)}}}function ld(){return Zu++}function cd(n,e,t){const i=e._path,s=it(n,e),r=go(n,t),o=n.listenProvider_.startListening(Ke(e),s,r.hashFn,r.onComplete),a=n.syncPointTree_.subtree(i);if(s)f(!ae(a.value),"If we're adding a query, it shouldn't be shadowed");else{const l=a.fold((c,u,h)=>{if(!v(c)&&u&&ae(u))return[Ht(u).query];{let d=[];return u&&(d=d.concat(lo(u).map(_=>_.query))),P(h,(_,p)=>{d=d.concat(p)}),d}});for(let c=0;c<l.length;++c){const u=l[c];n.listenProvider_.stopListening(Ke(u),it(n,u))}}return o}/**
1790 * @license
1791 * Copyright 2017 Google LLC
1792 *
1793 * Licensed under the Apache License, Version 2.0 (the "License");
1794 * you may not use this file except in compliance with the License.
1795 * You may obtain a copy of the License at
1796 *
1797 *   http://www.apache.org/licenses/LICENSE-2.0
1798 *
1799 * Unless required by applicable law or agreed to in writing, software
1800 * distributed under the License is distributed on an "AS IS" BASIS,
1801 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1802 * See the License for the specific language governing permissions and
1803 * limitations under the License.
1804 */class Ci{constructor(e){this.node_=e}getImmediateChild(e){const t=this.node_.getImmediateChild(e);return new Ci(t)}node(){return this.node_}}class Ei{constructor(e,t){this.syncTree_=e,this.path_=t}getImmediateChild(e){const t=S(this.path_,e);return new Ei(this.syncTree_,t)}node(){return gi(this.syncTree_,this.path_)}}const hd=function(n){return n=n||{},n.timestamp=n.timestamp||new Date().getTime(),n},Ns=function(n,e,t){if(!n||typeof n!="object")return n;if(f(".sv"in n,"Unexpected leaf node or priority contents"),typeof n[".sv"]=="string")return ud(n[".sv"],e,t);if(typeof n[".sv"]=="object")return dd(n[".sv"],e);f(!1,"Unexpected server value: "+JSON.stringify(n,null,2))},ud=function(n,e,t){switch(n){case"timestamp":return t.timestamp;default:f(!1,"Unexpected server value: "+n)}},dd=function(n,e,t){n.hasOwnProperty("increment")||f(!1,"Unexpected server value: "+JSON.stringify(n,null,2));const i=n.increment;typeof i!="number"&&f(!1,"Unexpected increment value: "+i);const s=e.node();if(f(s!==null&&typeof s<"u","Expected ChildrenNode.EMPTY_NODE for nulls"),!s.isLeafNode())return i;const o=s.getValue();return typeof o!="number"?i:o+i},mo=function(n,e,t,i){return wi(e,new Ei(t,n),i)},yo=function(n,e,t){return wi(n,new Ci(e),t)};function wi(n,e,t){const i=n.getPriority().val(),s=Ns(i,e.getImmediateChild(".priority"),t);let r;if(n.isLeafNode()){const o=n,a=Ns(o.getValue(),e,t);return a!==o.getValue()||s!==o.getPriority().val()?new k(a,R(s)):n}else{const o=n;return r=o,s!==o.getPriority().val()&&(r=r.updatePriority(new k(s))),o.forEachChild(N,(a,l)=>{const c=wi(l,e.getImmediateChild(a),t);c!==l&&(r=r.updateImmediateChild(a,c))}),r}}/**
1805 * @license
1806 * Copyright 2017 Google LLC
1807 *
1808 * Licensed under the Apache License, Version 2.0 (the "License");
1809 * you may not use this file except in compliance with the License.
1810 * You may obtain a copy of the License at
1811 *
1812 *   http://www.apache.org/licenses/LICENSE-2.0
1813 *
1814 * Unless required by applicable law or agreed to in writing, software
1815 * distributed under the License is distributed on an "AS IS" BASIS,
1816 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1817 * See the License for the specific language governing permissions and
1818 * limitations under the License.
1819 */class Ii{constructor(e="",t=null,i={children:{},childCount:0}){this.name=e,this.parent=t,this.node=i}}function bi(n,e){let t=e instanceof E?e:new E(e),i=n,s=m(t);for(;s!==null;){const r=Ae(i.node.children,s)||{children:{},childCount:0};i=new Ii(s,i,r),t=T(t),s=m(t)}return i}function We(n){return n.node.value}function vo(n,e){n.node.value=e,Fn(n)}function Co(n){return n.node.childCount>0}function fd(n){return We(n)===void 0&&!Co(n)}function Gt(n,e){P(n.node.children,(t,i)=>{e(new Ii(t,n,i))})}function Eo(n,e,t,i){t&&!i&&e(n),Gt(n,s=>{Eo(s,e,!0,i)}),t&&i&&e(n)}function _d(n,e,t){let i=t?n:n.parent;for(;i!==null;){if(e(i))return!0;
vendor: 4,217 bytes, lines 1819-1844
1819i=i.parent}return!1}function ht(n){return new E(n.parent===null?n.name:ht(n.parent)+"/"+n.name)}function Fn(n){n.parent!==null&&pd(n.parent,n.name,n)}function pd(n,e,t){const i=fd(t),s=z(n.node.children,e);i&&s?(delete n.node.children[e],n.node.childCount--,Fn(n)):!i&&!s&&(n.node.children[e]=t.node,n.node.childCount++,Fn(n))}/**
1820 * @license
1821 * Copyright 2017 Google LLC
1822 *
1823 * Licensed under the Apache License, Version 2.0 (the "License");
1824 * you may not use this file except in compliance with the License.
1825 * You may obtain a copy of the License at
1826 *
1827 *   http://www.apache.org/licenses/LICENSE-2.0
1828 *
1829 * Unless required by applicable law or agreed to in writing, software
1830 * distributed under the License is distributed on an "AS IS" BASIS,
1831 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1832 * See the License for the specific language governing permissions and
1833 * limitations under the License.
1834 */const gd=/[\[\].#$\/\u0000-\u001F\u007F]/,md=/[\[\].#$\u0000-\u001F\u007F]/,pn=10*1024*1024,Ti=function(n){return typeof n=="string"&&n.length!==0&&!gd.test(n)},wo=function(n){return typeof n=="string"&&n.length!==0&&!md.test(n)},yd=function(n){return n&&(n=n.replace(/^\/*\.info(\/|$)/,"/")),wo(n)},vd=function(n){return n===null||typeof n=="string"||typeof n=="number"&&!Jn(n)||n&&typeof n=="object"&&z(n,".sv")},Cd=function(n,e,t,i){i&&e===void 0||zt(Lt(n,"value"),e,t)},zt=function(n,e,t){const i=t instanceof E?new Lh(t,n):t;if(e===void 0)throw new Error(n+"contains undefined "+he(i));if(typeof e=="function")throw new Error(n+"contains a function "+he(i)+" with contents = "+e.toString());if(Jn(e))throw new Error(n+"contains "+e.toString()+" "+he(i));if(typeof e=="string"&&e.length>pn/3&&Ft(e)>pn)throw new Error(n+"contains a string greater than "+pn+" utf8 bytes "+he(i)+" ('"+e.substring(0,50)+"...')");if(e&&typeof e=="object"){let s=!1,r=!1;if(P(e,(o,a)=>{if(o===".value")s=!0;else if(o!==".priority"&&o!==".sv"&&(r=!0,!Ti(o)))throw new Error(n+" contains an invalid key ("+o+") "+he(i)+`.  Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"`);Fh(i,o),zt(n,a,i),Bh(i)}),s&&r)throw new Error(n+' contains ".value" child '+he(i)+" in addition to actual children.")}},Ed=function(n,e){let t,i;for(t=0;t<e.length;t++){i=e[t];const r=Je(i);for(let o=0;o<r.length;o++)if(!(r[o]===".priority"&&o===r.length-1)){if(!Ti(r[o]))throw new Error(n+"contains an invalid key ("+r[o]+") in path "+i.toString()+`. Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"`)}}e.sort(Mh);let s=null;for(t=0;t<e.length;t++){if(i=e[t],s!==null&&$(s,i))throw new Error(n+"contains a path "+s.toString()+" that is ancestor of another path "+i.toString());s=i}},wd=function(n,e,t,i){if(i&&e===void 0)return;const s=Lt(n,"values");if(!(e&&typeof e=="object")||Array.isArray(e))throw new Error(s+" must be an object containing the children to replace.");const r=[];P(e,(o,a)=>{const l=new E(o);if(zt(s,a,S(t,l)),ii(l)===".priority"&&!vd(a))throw new Error(s+"contains an invalid value for '"+l.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");r.push(l)}),Ed(s,r)},Io=function(n,e,t,i){if(!(i&&t===void 0)&&!wo(t))throw new Error(Lt(n,e)+'was an invalid path = "'+t+`". Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"`)},Id=function(n,e,t,i){t&&(t=t.replace(/^\/*\.info(\/|$)/,"/")),Io(n,e,t,i)},bd=function(n,e){if(m(e)===".info")throw new Error(n+" failed = Can't modify data under /.info/")},Td=function(n,e){const t=e.path.toString();if(typeof e.repoInfo.host!="string"||e.repoInfo.host.length===0||!Ti(e.repoInfo.namespace)&&e.repoInfo.host.split(":")[0]!=="localhost"||t.length!==0&&!yd(t))throw new Error(Lt(n,"url")+`must be a valid firebase URL and the path can't contain ".", "#", "$", "[", or "]".`)};/**
1835 * @license
1836 * Copyright 2017 Google LLC
1837 *
1838 * Licensed under the Apache License, Version 2.0 (the "License");
1839 * you may not use this file except in compliance with the License.
1840 * You may obtain a copy of the License at
1841 *
1842 *   http://www.apache.org/licenses/LICENSE-2.0
1843 *
1844 * Unless required by applicable law or agreed to in writing, softw
1844are
1845 * distributed under the License is distributed on an "AS IS" BASIS,
1846 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1847 * See the License for the specific language governing permissions and
1848 * limitations under the License.
1849 */class Sd{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function qt(n,e){let t=null;for(let i=0;i<e.length;i++){const s=e[i],r=s.getPath();t!==null&&!si(r,t.path)&&(n.eventLists_.push(t),t=null),t===null&&(t={events:[],path:r}),t.events.push(s)}t&&n.eventLists_.push(t)}function bo(n,e,t){qt(n,t),To(n,i=>si(i,e))}function U(n,e,t){qt(n,t),To(n,i=>$(i,e)||$(e,i))}function To(n,e){n.recursionDepth_++;let t=!0;for(let i=0;i<n.eventLists_.length;i++){const s=n.eventLists_[i];if(s){const r=s.path;e(r)?(Nd(n.eventLists_[i]),n.eventLists_[i]=null):t=!1}}t&&(n.eventLists_=[]),n.recursionDepth_--}function Nd(n){for(let e=0;e<n.events.length;e++){const t=n.events[e];if(t!==null){n.events[e]=null;const i=t.getEventRunner();fe&&x("event: "+t.toString()),Fe(i)}}}/**
1850 * @license
1851 * Copyright 2017 Google LLC
1852 *
1853 * Licensed under the Apache License, Version 2.0 (the "License");
1854 * you may not use this file except in compliance with the License.
1855 * You may obtain a copy of the License at
1856 *
1857 *   http://www.apache.org/licenses/LICENSE-2.0
1858 *
1859 * Unless required by applicable law or agreed to in writing, software
1860 * distributed under the License is distributed on an "AS IS" BASIS,
1861 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1862 * See the License for the specific language governing permissions and
1863 * limitations under the License.
1864 */const Rd="repo_interrupt",Ad=25;class kd{constructor(e,t,i,s){this.repoInfo_=e,this.forceRestClient_=t,this.authTokenProvider_=i,this.appCheckProvider_=s,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new Sd,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=Tt(),this.transactionQueueTree_=new Ii,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function Dd(n,e,t){if(n.stats_=ti(n.repoInfo_),n.forceRestClient_||oh())n.server_=new bt(n.repoInfo_,(i,s,r,o)=>{Rs(n,i,s,r,o)},n.authTokenProvider_,n.appCheckProvider_),setTimeout(()=>As(n,!0),0);else{if(typeof t<"u"&&t!==null){if(typeof t!="object")throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{A(t)}catch(i){throw new Error("Invalid authOverride provided: "+i)}}n.persistentConnection_=new Y(n.repoInfo_,e,(i,s,r,o)=>{Rs(n,i,s,r,o)},i=>{As(n,i)},i=>{Pd(n,i)},n.authTokenProvider_,n.appCheckProvider_,t),n.server_=n.persistentConnection_}n.authTokenProvider_.addTokenChangeListener(i=>{n.server_.refreshAuthToken(i)}),n.appCheckProvider_.addTokenChangeListener(i=>{n.server_.refreshAppCheckToken(i.token)}),n.statsReporter_=uh(n.repoInfo_,()=>new hu(n.stats_,n.server_)),n.infoData_=new ru,n.infoSyncTree_=new Ss({startListening:(i,s,r,o)=>{let a=[];const l=n.infoData_.getNode(i._path);return l.isEmpty()||(a=ct(n.infoSyncTree_,i._path,l),setTimeout(()=>{o("ok")},0)),a},stopListening:()=>{}}),Si(n,"connected",!1),n.serverSyncTree_=new Ss({startListening:(i,s,r,o)=>(n.server_.listen(i,r,s,(a,l)=>{const c=o(a,l);U(n.eventQueue_,i._path,c)}),[]),stopListening:(i,s)=>{n.server_.unlisten(i,s)}})}function xd(n){const t=n.infoData_.getNode(new E(".info/serverTimeOffset")).val()||0;return new Date().getTime()+t}function Kt(n){return hd({timestamp:xd(n)})}function Rs(n,e,t,i,s){n.dataUpdateCount++;const r=new E(e);t=n.interceptServerDataCallback_?n.interceptServerDataCallback_(e,t):t;let o=[];if(s)if(i){const l=gt(t,c=>R(c));o=sd(n.serverSyncTree_,r,l,s)}else{const l=R(t);o=fo(n.serverSyncTree_,r,l,s)}else if(i){const l=gt(t,c=>R(c));o=td(n.serverSyncTree_,r,l)}else{const l=R(t);o=ct(n.serverSyncTree_,r,l)}let a=r;o.length>0&&(a=Oe(n,r)),U(n.eventQueue_,a,o)}function As(n,e){Si(n,"connected",e),e===!1&&Fd(n)}function Pd(n,e){P(e,(t,i)=>{Si(n,t,i)})}function Si(n,e,t){const i=new E("/.info/"+e),s=R(t);n.infoData_.updateSnapshot(i,s);const r=ct(n.infoSyncTree_,i,s);U(n.eventQueue_,i,r)}function Ni(n){return n.nextWriteId_++}function Od(n,e,t){const i=rd(n.serverSyncTree_,e);return i!=null?Promise.resolve(i):n.server_.get(e).then(s=>{const r=R(s).withIndex(e._queryParams.getIndex());Ln(n.serverSyncTree_,e,t,!0);let o;if(e._queryParams.loadsAllData())o=ct(n.serverSyncTree_,e._path,r);else{const a=it(n.serverSyncTree_,e);o=fo(n.serverSyncTree_,e._path,r,a)}return U(n.eventQueue_,e._path,o),Pt(n.serverSyncTree_,e,t,null,!0),r},s=>(ut(n,"get for query "+A(e)+" failed: "+s),Promise.reject(new Error(s))))}function Md(n,e,t,i,s){ut(n,"set",{path:e.toString(),value:t,priority:i});const r=Kt(n),o=R(t,i),a=gi(n.serverSyncTree_,e),l=yo(o,a,r),c=Ni(n),u=uo(n.serverSyncTree_,e,l,c,!0);qt(n.eventQueue_,u),n.server_.put(e.toString(),o.val(!0),(d,_)=>{const p=d==="ok";p||L("set at "+e+" failed: "+d);const w=J(n.serverSyncTree_,c,!p);U(n.eventQueue_,e,w),Bn(n,s,d,_)});const h=Ai(n,e);Oe(n,h),U(n.eventQueue_,h,[])}function Ld(n,e,t,i){ut(n,"update",{path:e.toString(),value:t});let s=!0;const r=Kt(n),o={};if(P(t,(a,l)=>{s=!1,o[a]=mo(S(e,a),R(l),n.serverSyncTree_,r)}),s)x("update() called with empty data.  Don't do anything."),Bn(n,i,"ok",void 0);else{const a=Ni(n),l=ed(n.serverSyncTree_,e,o,a);qt(n.eventQueue_,l),n.server_.merge(e.toString(),t,(c,u)=>{const h=c==="ok";h||L("update at "+e+" failed: "+c);const d=J(n.serverSyncTree_,a,!h),_=d.length>0?Oe(n,e):e;U(n.eventQueue_,_,d),Bn(n,i,c,u)}),P(t,c=>{const u=Ai(n,S(e,c));Oe(n,u)}),U(n.eventQueue_,e,[])}}function Fd(n){ut(n,"onDisconnectEvents");const e=Kt(n),t=Tt();kn(n.onDisconnect_,C(),(s,r)=>{const o=mo(s,r,n.serverSyncTree_,e);Qr(t,s,o)});let i=[];kn(t,C(),(s,r)=>{i=i.concat(ct(n.serverSyncTree_,s,r));const o=Ai(n,s);Oe(n,o)}),n.onDisconnect_=Tt(),U(n.eventQueue_,C(),i)}function Bd(n,e,t){let i;m(e._path)===".info"?i=Ln(n.infoSyncTree_,e,t):i=Ln(n.serverSyncTree_,e,t),bo(n.eventQueue_,e._path,i)}function ks(n,e,t){let i;m(e._path)===".info"?i=Pt(n.infoSyncTree_,e,t):i=Pt(n.serverSyncTree_,e,t),bo(n.eventQueue_,e._path,i)}function Wd(n){n.persistentConnection_&&n.persistentConnection_.interrupt(Rd)}function ut(n,...e){let t="";n.persistentConnection_&&(t=n.persistentConnection_.id+":"),x(t,...e)}function Bn(n,e,t,i){e&&Fe(()=>{if(t==="ok")e(null);else{const s=(t||"error").toUpperCase();let r=s;i&&(r+=": "+i);const o=new Error(r);o.code=s,e(o)}})}function So(n,e,t){return gi(n.serverSyncTree_,e,t)||g.EMPTY_NODE}function Ri(n,e=n.transactionQueueTree_){if(e||Yt(n,e),We(e)){const t=Ro(n,e);f(t.length>0,"Sending zero length transaction queue"),t.every(s=>s.status===0)&&$d(n,ht(e),t)}else Co(e)&&Gt(e,t=>{Ri(n,t)})}function $d(n,e,t){const i=t.map(c=>c.currentWriteId),s=So(n,e,i);let r=s;const o=s.hash();for(let c=0;c<t.length;c++){const u=t[c];f(u.status===0,"tryToSendTransactionQueue_: items in queue should all be run."),u.status=1,u.retryCount++;const h=M(e,u.path);r=r.updateChild(h,u.currentOutputSnapshotRaw)}const a=r.val(!0),l=e;
1864n.server_.put(l.toString(),a,c=>{ut(n,"transaction put response",{path:l.toString(),status:c});let u=[];if(c==="ok"){const h=[];for(let d=0;d<t.length;d++)t[d].status=2,u=u.concat(J(n.serverSyncTree_,t[d].currentWriteId)),t[d].onComplete&&h.push(()=>t[d].onComplete(null,!0,t[d].currentOutputSnapshotResolved)),t[d].unwatcher();Yt(n,bi(n.transactionQueueTree_,e)),Ri(n,n.transactionQueueTree_),U(n.eventQueue_,e,u);for(let d=0;d<h.length;d++)Fe(h[d])}else{if(c==="datastale")for(let h=0;h<t.length;h++)t[h].status===3?t[h].status=4:t[h].status=0;else{L("transaction at "+l.toString()+" failed: "+c);for(let h=0;h<t.length;h++)t[h].status=4,t[h].abortReason=c}Oe(n,e)}},o)}function Oe(n,e){const t=No(n,e),i=ht(t),s=Ro(n,t);return Ud(n,s,i),i}function Ud(n,e,t){if(e.length===0)return;const i=[];let s=[];const o=e.filter(a=>a.status===0).map(a=>a.currentWriteId);for(let a=0;a<e.length;a++){const l=e[a],c=M(t,l.path);let u=!1,h;if(f(c!==null,"rerunTransactionsUnderNode_: relativePath should not be null."),l.status===4)u=!0,h=l.abortReason,s=s.concat(J(n.serverSyncTree_,l.currentWriteId,!0));else if(l.status===0)if(l.retryCount>=Ad)u=!0,h="maxretry",s=s.concat(J(n.serverSyncTree_,l.currentWriteId,!0));else{const d=So(n,l.path,o);l.currentInputSnapshot=d;const _=e[a].update(d.val());if(_!==void 0){zt("transaction failed: Data returned ",_,l.path);let p=R(_);typeof _=="object"&&_!=null&&z(_,".priority")||(p=p.updatePriority(d.getPriority()));const O=l.currentWriteId,Ie=Kt(n),dt=yo(p,d,Ie);l.currentOutputSnapshotRaw=p,l.currentOutputSnapshotResolved=dt,l.currentWriteId=Ni(n),o.splice(o.indexOf(O),1),s=s.concat(uo(n.serverSyncTree_,l.path,dt,l.currentWriteId,l.applyLocally)),s=s.concat(J(n.serverSyncTree_,O,!0))}else u=!0,h="nodata",s=s.concat(J(n.serverSyncTree_,l.currentWriteId,!0))}U(n.eventQueue_,t,s),s=[],u&&(e[a].status=2,function(d){setTimeout(d,Math.floor(0))}(e[a].unwatcher),e[a].onComplete&&(h==="nodata"?i.push(()=>e[a].onComplete(null,!1,e[a].currentInputSnapshot)):i.push(()=>e[a].onComplete(new Error(h),!1,null))))}Yt(n,n.transactionQueueTree_);for(let a=0;a<i.length;a++)Fe(i[a]);Ri(n,n.transactionQueueTree_)}function No(n,e){let t,i=n.transactionQueueTree_;for(t=m(e);t!==null&&We(i)===void 0;)i=bi(i,t),e=T(e),t=m(e);return i}function Ro(n,e){const t=[];return Ao(n,e,t),t.sort((i,s)=>i.order-s.order),t}function Ao(n,e,t){const i=We(e);if(i)for(let s=0;s<i.length;s++)t.push(i[s]);Gt(e,s=>{Ao(n,s,t)})}function Yt(n,e){const t=We(e);if(t){let i=0;for(let s=0;s<t.length;s++)t[s].status!==2&&(t[i]=t[s],i++);t.length=i,vo(e,t.length>0?t:void 0)}Gt(e,i=>{Yt(n,i)})}function Ai(n,e){const t=ht(No(n,e)),i=bi(n.transactionQueueTree_,e);return _d(i,s=>{gn(n,s)}),gn(n,i),Eo(i,s=>{gn(n,s)}),t}function gn(n,e){const t=We(e);if(t){const i=[];let s=[],r=-1;for(let o=0;o<t.length;o++)t[o].status===3||(t[o].status===1?(f(r===o-1,"All SENT items should be at beginning of queue."),r=o,t[o].status=3,t[o].abortReason="set"):(f(t[o].status===0,"Unexpected transaction status in abort"),t[o].unwatcher(),s=s.concat(J(n.serverSyncTree_,t[o].currentWriteId,!0)),t[o].onComplete&&i.push(t[o].onComplete.bind(null,new Error("set"),!1,null))));r===-1?vo(e,void 0):t.length=r+1,U(n.eventQueue_,ht(e),s);for(let o=0;o<i.length;o++)Fe(i[o])}}/**
1865 * @license
1866 * Copyright 2017 Google LLC
1867 *
1868 * Licensed under the Apache License, Version 2.0 (the "License");
1869 * you may not use this file except in compliance with the License.
1870 * You may obtain a copy of the License at
1871 *
1872 *   http://www.apache.org/licenses/LICENSE-2.0
1873 *
1874 * Unless required by applicable law or agreed to in writing, software
1875 * distributed under the License is distributed on an "AS IS" BASIS,
1876 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1877 * See the License for the specific language governing permissions and
1878 * limitations under the License.
1879 */function Vd(n){let e="";const t=n.split("/");for(let i=0;i<t.length;i++)if(t[i].length>0){let s=t[i];try{s=decodeURIComponent(s.replace(/\+/g," "))}catch{}e+="/"+s}return e}function Hd(n){const e={};n.charAt(0)==="?"&&(n=n.substring(1));for(const t of n.split("&")){if(t.length===0)continue;const i=t.split("=");i.length===2?e[decodeURIComponent(i[0])]=decodeURIComponent(i[1]):L(`Invalid query segment '${t}' in query '${n}'`)}return e}const Ds=function(n,e){const t=jd(n),i=t.namespace;t.domain==="firebase.com"&&X(t.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),(!i||i==="undefined")&&t.domain!=="localhost"&&X("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),t.secure||Xc();const s=t.scheme==="ws"||t.scheme==="wss";return{repoInfo:new Pr(t.host,t.secure,i,s,e,"",i!==t.subdomain),path:new E(t.pathString)}},jd=function(n){let e="",t="",i="",s="",r="",o=!0,a="https",l=443;if(typeof n=="string"){let c=n.indexOf("//");c>=0&&(a=n.substring(0,c-1),n=n.substring(c+2));let u=n.indexOf("/");u===-1&&(u=n.length);let h=n.indexOf("?");h===-1&&(h=n.length),e=n.substring(0,Math.min(u,h)),u<h&&(s=Vd(n.substring(u,h)));const d=Hd(n.substring(Math.min(n.length,h)));c=e.indexOf(":"),c>=0?(o=a==="https"||a==="wss",l=parseInt(e.substring(c+1),10)):c=e.length;const _=e.slice(0,c);if(_.toLowerCase()==="localhost")t="localhost";else if(_.split(".").length<=2)t=_;else{const p=e.indexOf(".");i=e.substring(0,p).toLowerCase(),t=e.substring(p+1),r=i}"ns"in d&&(r=d.ns)}return{host:e,port:l,domain:t,subdomain:i,secure:o,scheme:a,pathString:s,namespace:r}};/**
1880 * @license
1881 * Copyright 2017 Google LLC
1882 *
1883 * Licensed under the Apache License, Version 2.0 (the "License");
1884 * you may not use this file except in compliance with the License.
1885 * You may obtain a copy of the License at
1886 *
1887 *   http://www.apache.org/licenses/LICENSE-2.0
1888 *
1889 * Unless required by applicable law or agreed to in writing, software
1890 * distributed under the License is distributed on an "AS IS" BASIS,
1891 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1892 * See the License for the specific language governing permissions and
1893 * limitations under the License.
1894 */class ko{constructor(e,t,i,s){this.eventType=e,this.eventRegistration=t,this.snapshot=i,this.prevName=s}getPath(){const e=this.snapshot.ref;return this.eventType==="value"?e._path:e.parent._path}getEventType(){return this.eventType}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.getPath().toString()+":"+this.eventType+":"+A(this.snapshot.exportVal())}}class Do{constructor(e,t,i){this.eventRegistration=e,this.error=t,this.path=i}getPath(){return this.path}getEventType(){return"cancel"}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.path.toString()+":cancel"}}/**
1895 * @license
1896 * Copyright 2017 Google LLC
1897 *
1898 * Licensed under the Apache License, Version 2.0 (the "License");
1899 * you may not use this file except in compliance with the License.
1900 * You may obtain a copy of the License at
1901 *
1902 *   http://www.apache.org/licenses/LICENSE-2.0
1903 *
1904 * Unless required by applicable law or agreed to in writing, software
1905 * distributed under the License is distributed on an "AS IS" BASIS,
1906 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1907 * See the License for the specific language governing permissions and
1908 * limitations under the License.
1909 */class xo{constructor(e,t){this.snapshotCallback=e,this.cancelCallback=t}onValue(e,t){this.snapshotCallback.call(null,e,t)}onCancel(e){return f(this.hasCancelCallback,"Raising a cancel event on a listener with no cancel callback"),this.cancelCallback.call(null,e)}get hasCancelCallback(){return!!this.cancelCallback}matches(e){return this.snapshotCallback===e.snapshotCallback||this.snapshotCallback.userCallback!==void 0&&this.snapshotCallback.userCallback===e.snapshotCallback.userCallback&&this.snapshotCallback.context===e.snapshotCallback.context}}/**
1910 * @license
1911 * Copyright 2020 Google LLC
1912 *
1913 * Licensed under the Apache License, Version 2.0 (the "License");
1914 * you may not use this file except in compliance with the License.
1915 * You may obtain a copy of the License at
1916 *
1917 *   http://www.apache.org/licenses/LICENSE-2.0
1918 *
1919 * Unless required by applicable law or agreed to in writing, software
1920 * distributed under the License is distributed on an "AS IS" BASIS,
1921 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1922 * See the License for the specific language governing permissions and
1923 * limitations under the License.
1924 */class ki{constructor(e,t,i,s){this._repo=e,this._path=t,this._queryParams=i,this._orderByCalled=s}get key(){return v(this._path)?null:ii(this._path)}get ref(){return new q(this._repo,this._path)}get _queryIdentifier(){const e=gs(this._queryParams),t=Zn(e);return t==="{}"?"default":t}get _queryObject(){return gs(this._queryParams)}isEqual(e){if(e=le(e),!(e instanceof ki))return!1;const t=this._repo===e._repo,i=si(this._path,e._path),s=this._queryIdentifier===e._queryIdentifier;return t&&i&&s}toJSON(){return this.toString()}toString(){return this._repo.toString()+Oh(this._path)}}class q extends ki{constructor(e,t){super(e,t,new li,!1)}get parent(){const e=Vr(this._path);return e===null?null:new q(this._repo,e)}get root(){let e=this;for(;e.parent!==null;)e=e.parent;return e}}class Me{constructor(e,t,i){this._node=e,this.ref=t,this._index=i}get priority(){return this._node.getPriority().val()}get key(){return this.ref.key}get size(){return this._node.numChildren()}child(e){const t=new E(e),i=Ot(this.ref,e);return new Me(this._node.getChild(t),i,N)}exists(){return!this._node.isEmpty()}exportVal(){return this._node.val(!0)}forEach(e){return this._node.isLeafNode()?!1:!!this._node.forEachChild(this._index,(i,s)=>e(new Me(s,Ot(this.ref,i),N)))}hasChild(e){const t=new E(e);return!this._node.getChild(t).isEmpty()}hasChildren(){return this._node.isLeafNode()?!1:!this._node.isEmpty()}toJSON(){return this.exportVal()}val(){return this._node.val()}}function uf(n,e){return n=le(n),n._checkNotDeleted("ref"),e!==void 0?Ot(n._root,e):n._root}function Ot(n,e){return n=le(n),m(n._path)===null?Id("child","path",e,!1):Io("child","path",e,!1),new q(n._repo,S(n._path,e))}function df(n,e){n=le(n),bd("set",n._path),Cd("set",e,n._path,!1);const t=new st;return Md(n._repo,n._path,e,null,t.wrapCallback(()=>{})),t.promise}function ff(n,e){wd("update",e,n._path,!1);const t=new st;return Ld(n._repo,n._path,e,t.wrapCallback(()=>{})),t.promise}function _f(n){n=le(n);const e=new xo(()=>{}),t=new Qt(e);return Od(n._repo,n,t).then(i=>new Me(i,new q(n._repo,n._path),n._queryParams.getIndex()))}class Qt{constructor(e){this.callbackContext=e}respondsTo(e){return e==="value"}createEvent(e,t){const i=t._queryParams.getIndex();return new ko("value",this,new Me(e.snapshotNode,new q(t._repo,t._path),i))}getEventRunner(e){return e.getEventType()==="cancel"?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,null)}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new Do(this,e,t):null}matches(e){return e instanceof Qt?!e.callbackContext||!this.callbackContext?!0:e.callbackContext.matches(this.callbackContext):!1}hasAnyCallback(){return this.callbackContext!==null}}class Di{constructor(e,t){this.eventType=e,this.callbackContext=t}respondsTo(e){let t=e==="children_added"?"child_added":e;return t=t==="children_removed"?"child_removed":t,this.eventType===t}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new Do(this,e,t):null}createEvent(e,t){f(e.childName!=null,"Child events should have a childName.");const i=Ot(new q(t._repo,t._path),e.childName),s=t._queryParams.getIndex();return new ko(e.type,this,new Me(e.snapshotNode,i,s),e.prevName)}getEventRunner(e){return e.getEventType()==="cancel"?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,e.prevName)}matches(e){return e instanceof Di?this.eventType===e.eventType&&(!this.callbackContext||!e.callbackContext||this.callbackContext.matches(e.callbackContext)):!1}hasAnyCallback(){return!!this.callbackContext}}function Gd(n,e,t,i,s){let r;if(typeof i=="object"&&(r=void 0,s=i),typeof i=="function"&&(r=i),s&&s.onlyOnce){const l=t,c=(u,h)=>{ks(n._repo,n,a),l(u,h)};c.userCallback=t.userCallback,c.context=t.context,t=c}const o=new xo(t,r||void 0),a=e==="value"?new Qt(o):new Di(e,o);return Bd(n._repo,n,a),()=>ks(n._repo,n,a)}function pf(n,e,t,i){return Gd(n,"value",e,t,i)}zu(q);Xu(q);/**
1925 * @license
1926 * Copyright 2020 Google LLC
1927 *
1928 * Licensed under the Apache License, Version 2.0 (the "License");
1929 * you may not use this file except in compliance with the License.
1930 * You may obtain a copy of the License at
1931 *
1932 *   http://www.apache.org/licenses/LICENSE-2.0
1933 *
1934 * Unless required by applicable law or agreed to in writing, software
1935 * distributed under the License is distributed on an "AS IS" BASIS,
1936 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1937 * See the License for the specific language governing permissions and
1938 * limitations under the License.
1939 */const zd="FIREBASE_DATABASE_EMULATOR_HOST",Wn={};let qd=!1;function Kd(n,e,t,i){n.repoInfo_=new Pr(`${e}:${t}`,!1,n.repoInfo_.namespace,n.repoInfo_.webSocketOnly,n.repoInfo_.nodeAdmin,n.repoInfo_.persistenceKey,n.repoInfo_.includeNamespaceInQueryParams,!0),i&&(n.authTokenProvider_=i)}function Yd(n,e,t,i,s){let r=i||n.options.databaseURL;r===void 0&&(n.options.projectId||X("Can't determine Firebase Database URL. Be sure to include  a Project ID when calling firebase.initializeApp()."),x("Using default host for project ",n.options.projectId),r=`${n.options.projectId}-default-rtdb.firebaseio.com`);let o=Ds(r,s),a=o.repoInfo,l,c;typeof process<"u"&&process.env&&(c=process.env[zd]),c?(l=!0,r=`http://${c}?ns=${a.namespace}`,o=Ds(r,s),a=o.repoInfo):l=!o.repoInfo.secure;const u=s&&l?new Ne(Ne.OWNER):new lh(n.name,n.options,e);Td("Invalid Firebase Database URL",o),v(o.path)||X("Database URL must point to the root of a Firebase Database (not including a child path).");const h=Xd(a,n,u,new ah(n.name,t));return new Jd(h,n)}function Qd(n,e){const t=Wn[e];(!t||t[n.key]!==n)&&X(`Database ${e}(${n.repoInfo_}) has already been deleted.`),Wd(n),delete t[n.key]}function Xd(n,e,t,i){let s=Wn[e.name];s||(s={},Wn[e.name]=s);let r=s[n.toURLString()];return r&&X("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),r=new kd(n,qd,t,i),s[n.toURLString()]=r,r}class Jd{constructor(e,t){this._repoInternal=e,this.app=t,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(Dd(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new q(this._repo,C())),this._rootInternal}_delete(){return this._rootInternal!==null&&(Qd(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(e){this._rootInternal===null&&X("Cannot call "+e+" on a deleted database.")}}function Zd(n=zs(),e){const t=rt(n,"database").getImmediate({identifier:e});if(!t._instanceStarted){const i=zo("database");i&&ef(t,...i)}return t}function ef(n,e,t,i={}){n=le(n),n._checkNotDeleted("useEmulator"),n._instanceStarted&&X("Cannot call useEmulator() after instance has already been initialized.");const s=n._repoInternal;let r;if(s.repoInfo_.nodeAdmin)i.mockUserToken&&X('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),r=new Ne(Ne.OWNER);else if(i.mockUserToken){const o=typeof i.mockUserToken=="string"?i.mockUserToken:qo(i.mockUserToken,n.app.options.projectId);r=new Ne(o)}Kd(s,e,t,r)}/**
1940 * @license
1941 * Copyright 2021 Google LLC
1942 *
1943 * Licensed under the Apache License, Version 2.0 (the "License");
1944 * you may not use this file except in compliance with the License.
1945 * You may obtain a copy of the License at
1946 *
1947 *   http://www.apache.org/licenses/LICENSE-2.0
1948 *
1949 * Unless required by applicable law or agreed to in writing, software
1950 * distributed under the License is distributed on an "AS IS" BASIS,
1951 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1952 * See the License for the specific language governing permissions and
1953 * limitations under the License.
1954 */function tf(n){zc(rl),se(new Q("database",(e,{instanceIdentifier:t})=>{const i=e.getProvider("app").getImmediate(),s=e.getProvider("auth-internal"),r=e.getProvider("app-check-internal");return Yd(i,s,r,t)},"PUBLIC").setMultipleInstances(!0)),G(Zi,es,n),G(Zi,es,"esm2017")}Y.prototype.simpleListen=function(n,e){this.sendRequest("q",{p:n},e)};Y.prototype.echo=function(n,e){this.sendRequest("echo",{d:n},e)};tf();var nf="firebase",sf="9.23.0";/**
1955 * @license
1956 * Copyright 2020 Google LLC
1957 *
1958 * Licensed under the Apache License, Version 2.0 (the "License");
1959 * you may not use this file except in compliance with the License.
1960 * You may obtain a copy of the License at
1961 *
1962 *   http://www.apache.org/licenses/LICENSE-2.0
1963 *
1964 * Unless required by applicable law or agreed to in writing, software
1965 * distributed under the License is distributed on an "AS IS" BASIS,
1966 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1967 * See the License for the specific language governing permissions and
1968 * limitations under the License.
1969 */G(nf,sf,"app");const rf={apiKey:"AIzaSyCxpMuSG1brf5HtVJn4asXkylMNkbji5CM",authDomain:"treasure-debris.firebaseapp.com",projectId:"treasure-debris",storageBucket:"treasure-debris.appspot.com",messagingSenderId:"8190677378",databaseURL:"https://treasure-debris-default-rtdb.firebaseio.com",appId:"1:8190677378:web:f96bb2c9cca585607e3f9b",measurementId:"G-CD0LP881NY"},of=Gs(rf),gf=Zd();Hc().then(n=>{n&&Uc(of)});console.log("FirebaseInit / RealtimeDBInit !!!");class mf extends Oo{constructor(e){super(),Mo(this,e,null,null,Lo,{})}}export{Q as C,Mt as E,Ce as F,b as L,mf as P,rl as S,se as _,Ko as a,Ws as b,le as c,hf as d,Fs as e,jn as f,lf as g,mn as h,Bs as i,rt as j,Go as k,zs as l,mt as m,cf as n,xi as o,uf as p,ea as q,G as r,gf as s,_f as t,Ot as u,df as v,pf as w,ff as x};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.