PageSourceSearch

https://public.getgreenspark.com/assets/firebase-CJnrmy_C.js

js getgreenspark.com collected 2026-09-26 05:06:11 UTC 689,709 bytes, 5,041 lines download raw bytes

1import{o as rf}from"./idb-BU8SpEdM.js";import{_ as yl}from"./tslib-DNNf6dQ6.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="d82ee8dd-eeb3-4239-8d2a-1dcbe9f1f652",n._sentryDebugIdIdentifier="sentry-dbid-d82ee8dd-eeb3-4239-8d2a-1dcbe9f1f652")}catch{}})();var Yu={};/**
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 of={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 N=function(n,e){if(!n)throw gs(e)},gs=function(n){return new Error("Firebase Database ("+of.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 af=function(n){const e=[];let t=0;for(let s=0;s<n.length;s++){let i=n.charCodeAt(s);i<128?e[t++]=i:i<2048?(e[t++]=i>>6|192,e[t++]=i&63|128):(i&64512)===55296&&s+1<n.length&&(n.charCodeAt(s+1)&64512)===56320?(i=65536+((i&1023)<<10)+(n.charCodeAt(++s)&1023),e[t++]=i>>18|240,e[t++]=i>>12&63|128,e[t++]=i>>6&63|128,e[t++]=i&63|128):(e[t++]=i>>12|224,e[t++]=i>>6&63|128,e[t++]=i&63|128)}return e},sy=function(n){const e=[];let t=0,s=0;for(;t<n.length;){const i=n[t++];if(i<128)e[s++]=String.fromCharCode(i);else if(i>191&&i<224){const r=n[t++];e[s++]=String.fromCharCode((i&31)<<6|r&63)}else if(i>239&&i<365){const r=n[t++],o=n[t++],l=n[t++],c=((i&7)<<18|(r&63)<<12|(o&63)<<6|l&63)-65536;e[s++]=String.fromCharCode(55296+(c>>10)),e[s++]=String.fromCharCode(56320+(c&1023))}else{const r=n[t++],o=n[t++];e[s++]=String.fromCharCode((i&15)<<12|(r&63)<<6|o&63)}}return e.join("")},co={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_,s=[];for(let i=0;i<n.length;i+=3){const r=n[i],o=i+1<n.length,l=o?n[i+1]:0,c=i+2<n.length,h=c?n[i+2]:0,f=r>>2,p=(r&3)<<4|l>>4;let g=(l&15)<<2|h>>6,I=h&63;c||(I=64,o||(g=64)),s.push(t[f],t[p],t[g],t[I])}return s.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray(af(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):sy(this.decodeStringToByteArray(n,e))},decodeStringToByteArray(n,e){this.init_();const t=e?this.charToByteMapWebSafe_:this.charToByteMap_,s=[];for(let i=0;i<n.length;){const r=t[n.charAt(i++)],l=i<n.length?t[n.charAt(i)]:0;++i;const h=i<n.length?t[n.charAt(i)]:64;++i;const p=i<n.length?t[n.charAt(i)]:64;if(++i,r==null||l==null||h==null||p==null)throw new iy;const g=r<<2|l>>4;if(s.push(g),h!==64){const I=l<<4&240|h>>2;if(s.push(I),p!==64){const S=h<<6&192|p;s.push(S)}}}return s},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 iy extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const lf=function(n){const e=af(n);return co.encodeByteArray(e,!0)},Nr=function(n){return lf(n).replace(/\./g,"")},Dr=function(n){try{return co.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 ry(n){return cf(void 0,n)}function cf(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)||!oy(t)||(n[t]=cf(n[t],e[t]));return n}function oy(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 uf(){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 ay=()=>uf().__FIREBASE_DEFAULTS__,ly=()=>{if(typeof process>"u"||typeof Yu>"u")return;const n=Yu.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},cy=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=n&&Dr(n[1]);return e&&JSON.parse(e)},uo=()=>{try{return ay()||ly()||cy()}catch(n){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},hf=n=>{var e,t;return(t=(e=uo())===null||e===void 0?void 0:e.emulatorHosts)===null||t===void 0?void 0:t[n]},vl=n=>{const e=hf(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 s=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),s]:[e.substring(0,t),s]},df=()=>{var n;return(n=uo())===null||n===void 0?void 0:n.config},ff=n=>{var e;return(e=uo())===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 ts{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>
106{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,s)=>{t?this.reject(t):this.resolve(s),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,s))}}}/**
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 El(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"},s=e||"demo-project",i=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/${s}`,aud:s,iat:i,exp:i+3600,auth_time:i,sub:r,user_id:r,firebase:{sign_in_provider:"custom",identities:{}}},n);return[Nr(JSON.stringify(t)),Nr(JSON.stringify(o)),""].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 Fe(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function Tl(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(Fe())}function uy(){var n;const e=(n=uo())===null||n===void 0?void 0:n.forceEnvironment;if(e==="node")return!0;if(e==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function hy(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function pf(){const n=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof n=="object"&&n.id!==void 0}function _f(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function dy(){const n=Fe();return n.indexOf("MSIE ")>=0||n.indexOf("Trident/")>=0}function fy(){return of.NODE_ADMIN===!0}function py(){return!uy()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function ho(){try{return typeof indexedDB=="object"}catch{return!1}}function gf(){return new Promise((n,e)=>{try{let t=!0;const s="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(s);i.onsuccess=()=>{i.result.close(),t||self.indexedDB.deleteDatabase(s),n(!0)},i.onupgradeneeded=()=>{t=!1},i.onerror=()=>{var r;e(((r=i.error)===null||r===void 0?void 0:r.message)||"")}}catch(t){e(t)}})}function _y(){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 gy="FirebaseError";
151class tt extends Error{constructor(e,t,s){super(t),this.code=e,this.customData=s,this.name=gy,Object.setPrototypeOf(this,tt.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,an.prototype.create)}}class an{constructor(e,t,s){this.service=e,this.serviceName=t,this.errors=s}create(e,...t){const s=t[0]||{},i=`${this.service}/${e}`,r=this.errors[e],o=r?my(r,s):"Error",l=`${this.serviceName}: ${o} (${i}).`;return new tt(i,l,s)}}function my(n,e){return n.replace(yy,(t,s)=>{const i=e[s];return i!=null?String(i):`<${s}?>`})}const yy=/\{\$([^}]+)}/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 hi(n){return JSON.parse(n)}function ye(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 mf=function(n){let e={},t={},s={},i="";try{const r=n.split(".");e=hi(Dr(r[0])||""),t=hi(Dr(r[1])||""),i=r[2],s=t.d||{},delete t.d}catch{}return{header:e,claims:t,data:s,signature:i}},vy=function(n){const e=mf(n),t=e.claims;return!!t&&typeof t=="object"&&t.hasOwnProperty("iat")},Ey=function(n){const e=mf(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 Lt(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function ns(n,e){if(Object.prototype.hasOwnProperty.call(n,e))return n[e]}function Oa(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function Or(n,e,t){const s={};for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[i]=e.call(t,n[i],i,n));return s}function di(n,e){if(n===e)return!0;const t=Object.keys(n),s=Object.keys(e);for(const i of t){if(!s.includes(i))return!1;const r=n[i],o=e[i];if(Xu(r)&&Xu(o)){if(!di(r,o))return!1}else if(r!==o)return!1}for(const i of s)if(!t.includes(i))return!1;return!0}function Xu(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 ms(n){const e=[];
211for(const[t,s]of Object.entries(n))Array.isArray(s)?s.forEach(i=>{e.push(encodeURIComponent(t)+"="+encodeURIComponent(i))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(s));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 Ty{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 s=this.W_;if(typeof e=="string")for(let p=0;p<16;p++)s[p]=e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3),t+=4;else for(let p=0;p<16;p++)s[p]=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3],t+=4;for(let p=16;p<80;p++){const g=s[p-3]^s[p-8]^s[p-14]^s[p-16];s[p]=(g<<1|g>>>31)&4294967295}let i=this.chain_[0],r=this.chain_[1],o=this.chain_[2],l=this.chain_[3],c=this.chain_[4],h,f;for(let p=0;p<80;p++){p<40?p<20?(h=l^r&(o^l),f=1518500249):(h=r^o^l,f=1859775393):p<60?(h=r&o|l&(r|o),f=2400959708):(h=r^o^l,f=3395469782);const g=(i<<5|i>>>27)+h+c+f+s[p]&4294967295;c=l,l=o,o=(r<<30|r>>>2)&4294967295,r=i,i=g}this.chain_[0]=this.chain_[0]+i&4294967295,this.chain_[1]=this.chain_[1]+r&4294967295,this.chain_[2]=this.chain_[2]+o&4294967295,this.chain_[3]=this.chain_[3]+l&4294967295,this.chain_[4]=this.chain_[4]+c&4294967295}update(e,t){if(e==null)return;t===void 0&&(t=e.length);const s=t-this.blockSize;let i=0;const r=this.buf_;let o=this.inbuf_;for(;i<t;){if(o===0)for(;i<=s;)this.compress_(e,i),i+=this.blockSize;if(typeof e=="string"){for(;i<t;)if(r[o]=e.charCodeAt(i),++o,++i,o===this.blockSize){this.compress_(r),o=0;break}}else for(;i<t;)if(r[o]=e[i],++o,++i,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 i=this.blockSize-1;i>=56;i--)this.buf_[i]=t&255,t/=256;this.compress_(this.buf_);let s=0;for(let i=0;i<5;i++)for(let r=24;r>=0;r-=8)e[s]=this.chain_[i]>>r&255,++s;return e}}function Iy(n,e){const t=new wy(n,e);return t.subscribe.bind(t)}class wy{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(s=>{this.error(s)})}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,s){let i;if(e===void 0&&t===void 0&&s===void 0)throw new Error("Missing Observer.");Cy(e,["next","error","complete"])?i=e:i={next:e,error:t,complete:s},i.next===void 0&&(i.next=ua),i.error===void 0&&(i.error=ua),i.complete===void 0&&(i.complete=ua);const r=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?i.error(this.finalError):i.complete()}catch{}}),this.observers.push(i),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(s){typeof console<"u"&&console.error&&console.error(s)}})}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 Cy(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 ua(){}function yf(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 Ay=function(n){const e=[];let t=0;for(let s=0;s<n.length;s++){let i=n.charCodeAt(s);if(i>=55296&&i<=56319){const r=i-55296;s++,N(s<n.length,"Surrogate pair missing trail surrogate.");const o=n.charCodeAt(s)-56320;i=65536+(r<<10)+o}i<128?e[t++]=i:i<2048?(e[t++]=i>>6|192,e[t++]=i&63|128):i<65536?(e[t++]=i>>12|224,e[t++]=i>>6&63|128,e[t++]=i&63|128):(e[t++]=i>>18|240,e[t++]=i>>12&63|128,e[t++]=i>>6&63|128,e[t++]=i&63|128)}return e},fo=function(n){let e=0;for(let t=0;t<n.length;t++){const s=n.charCodeAt(t);s<128?e++:s<2048?e+=2:s>=55296&&s<=56319?(e+=4,t++):e+=3}return e};/**
242 * @license
243 * Copyright 2022 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 Ry=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)})};/**
257 * @license
258 * Copyright 2019 Google LLC
259 *
260 * Licensed under the Apache License, Version 2.0 (the "License");
261 * you may not use this file except in compliance with the License.
262 * You may obtain a copy of the License at
263 *
264 *   http://www.apache.org/licenses/LICENSE-2.0
265 *
266 * Unless required by applicable law or agreed to in writing, software
267 * distributed under the License is distributed on an "AS IS" BASIS,
268 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
269 * See the License for the specific language governing permissions and
270 * limitations under the License.
271 */const Sy=1e3,by=2,Py=4*60*60*1e3,ky=.5;function Ju(n,e=Sy,t=by){const s=e*Math.pow(t,n),i=Math.round(ky*s*(Math.random()-.5)*2);return Math.min(Py,s+i)}/**
272 * @license
273 * Copyright 2021 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 */function le(n){return n&&n._delegate?n._delegate:n}class He{constructor(e,t,s){this.name=e,this.instanceFactory=t,this.type=s,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}}/**
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 */const pn="[DEFAULT]";/**
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 Ny{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 s=new ts;if(this.instancesDeferred.set(t,s),this.isInitialized(t)||this.shouldAutoInitialize())try{const i=this.getOrInitializeService({instanceIdentifier:t});i&&s.resolve(i)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;const s=this.normalizeInstanceIdentifier(e==null?void 0:e.identifier),i=(t=e==null?void 0:e.optional)!==null&&t!==void 0?t:!1;if(this.isInitialized(s)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:s})}catch(r){if(i)return null;throw r}else{if(i)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(Oy(e))try{this.getOrInitializeService({instanceIdentifier:pn})}catch{}for(const[t,s]of this.instancesDeferred.entries()){const i=this.normalizeInstanceIdentifier(t);try{const r=this.getOrInitializeService({instanceIdentifier:i});s.resolve(r)}catch{}}}}clearInstance(e=pn){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=pn){return this.instances.has(e)}getOptions(e=pn){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,s=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(s))throw Error(`${this.name}(${s}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const i=this.getOrInitializeService({instanceIdentifier:s,options:t});for(const[r,o]of this.instancesDeferred.entries()){const l=this.normalizeInstanceIdentifier(r);s===l&&o.resolve(i)}return i}onInit(e,t){var s;const i=this.normalizeInstanceIdentifier(t),r=(s=this.onInitCallbacks.get(i))!==null&&s!==void 0?s:new Set;r.add(e),this.onInitCallbacks.set(i,r);const o=this.instances.get(i);return o&&e(o,i),()=>{r.delete(e)}}invokeOnInitCallbacks(e,t){const s=this.onInitCallbacks.get(t);if(s)for(const i of s)try{i(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let s=this.instances.get(e);if(!s&&this.component&&(s=this.component.instanceFactory(this.container,{instanceIdentifier:Dy(e),options:t}),this.instances.set(e,s),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(s,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,s)}catch{}return s||null}normalizeInstanceIdentifier(e=pn){return this.component?this.component.multipleInstances?e:pn:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function Dy(n){return n===pn?void 0:n}function Oy(n){return n.instantiationMode==="EAGER"}/**
317 * @license
318 * Copyright 2019 Google LLC
319 *
320 * Licensed under the Apache License, Version 2.0 (the "License");
321 * you may not use this file except in compliance with the License.
322 * You may obtain a copy of the License at
323 *
324 *   http://www.apache.org/licenses/LICENSE-2.0
325 *
326 * Unless required by applicable law or agreed to in writing, softw
326are
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 */class xy{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 Ny(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}/**
332 * @license
333 * Copyright 2017 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 */var K;(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"})(K||(K={}));const My={debug:K.DEBUG,verbose:K.VERBOSE,info:K.INFO,warn:K.WARN,error:K.ERROR,silent:K.SILENT},Ly=K.INFO,Vy={[K.DEBUG]:"log",[K.VERBOSE]:"log",[K.INFO]:"info",[K.WARN]:"warn",[K.ERROR]:"error"},Fy=(n,e,...t)=>{if(e<n.logLevel)return;const s=new Date().toISOString(),i=Vy[e];if(i)console[i](`[${s}]  ${n.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class ys{constructor(e){this.name=e,this._logLevel=Ly,this._logHandler=Fy,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in K))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?My[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,K.DEBUG,...e),this._logHandler(this,K.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,K.VERBOSE,...e),this._logHandler(this,K.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,K.INFO,...e),this._logHandler(this,K.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,K.WARN,...e),this._logHandler(this,K.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,K.ERROR,...e),this._logHandler(this,K.ERROR,...e)}}/**
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 */class Uy{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(By(t)){const s=t.getImmediate();return`${s.library}/${s.version}`}else return null}).filter(t=>t).join(" ")}}function By(n){const e=n.getComponent();return(e==null?void 0:e.type)==="VERSION"}const xa="@firebase/app",Zu="0.10.13";/**
362 * @license
363 * Copyright 2019 Google LLC
364 *
365 * Licensed under the Apache License, Version 2.0 (the "License");
366 * you may not use this file except in compliance with the License.
367 * You may obtain a copy of the License at
368 *
369 *   http://www.apache.org/licenses/LICENSE-2.0
370 *
371 * Unless required by applicable law or agreed to in writing, software
372 * distributed under the License is distributed on an "AS IS" BASIS,
373 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
374 * See the License for the specific language governing permissions and
375 * limitations under the License.
376 */const Nt=new ys("@firebase/app"),qy="@firebase/app-compat",$y="@firebase/analytics-compat",jy="@firebase/analytics",Hy="@firebase/app-check-compat",Wy="@firebase/app-check",zy="@firebase/auth",Gy="@firebase/auth-compat",Ky="@firebase/database",Qy="@firebase/data-connect",Yy="@firebase/database-compat",Xy="@firebase/functions",Jy="@firebase/functions-compat",Zy="@firebase/installations",ev="@firebase/installations-compat",tv="@firebase/messaging",nv="@firebase/messaging-compat",sv="@firebase/performance",iv="@firebase/performance-compat",rv="@firebase/remote-config",ov="@firebase/remote-config-compat",av="@firebase/storage",lv="@firebase/storage-compat",cv="@firebase/firestore",uv="@firebase/vertexai-preview",hv="@firebase/firestore-compat",dv="firebase",fv="10.14.1";/**
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 Ma="[DEFAULT]",pv={[xa]:"fire-core",[qy]:"fire-core-compat",[jy]:"fire-analytics",[$y]:"fire-analytics-compat",[Wy]:"fire-app-check",[Hy]:"fire-app-check-compat",[zy]:"fire-auth",[Gy]:"fire-auth-compat",[Ky]:"fire-rtdb",[Qy]:"fire-data-connect",[Yy]:"fire-rtdb-compat",[Xy]:"fire-fn",[Jy]:"fire-fn-compat",[Zy]:"fire-iid",[ev]:"fire-iid-compat",[tv]:"fire-fcm",[nv]:"fire-fcm-compat",[sv]:"fire-perf",[iv]:"fire-perf-compat",[rv]:"fire-rc",[ov]:"fire-rc-compat",[av]:"fire-gcs",[lv]:"fire-gcs-compat",[cv]:"fire-fst",[hv]:"fire-fst-compat",[uv]:"fire-vertex","fire-js":"fire-js",[dv]:"fire-js-all"};/**
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 fi=new Map,_v=new Map,La=new Map;function eh(n,e){try{n.container.addComponent(e)}catch(t){Nt.debug(`Component ${e.name} failed to register with FirebaseApp ${n.name}`,t)}}function Ge(n){const e=n.name;if(La.has(e))return Nt.debug(`There were multiple attempts to register component ${e}.`),!1;La.set(e,n);for(const t of fi.values())eh(t,n);for(const t of _v.values())eh(t,n);return!0}function gt(n,e){const t=n.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),n.container.getProvider(e)}function Ht(n){return n.settings!==void 0}/**
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 */const gv={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invali
421d-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},Gt=new an("app","Firebase",gv);/**
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 */class mv{constructor(e,t,s){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=s,this.container.addComponent(new He("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 Gt.create("app-deleted",{appName:this._name})}}/**
437 * @license
438 * Copyright 2019 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 ln=fv;function yv(n,e={}){let t=n;typeof e!="object"&&(e={name:e});const s=Object.assign({name:Ma,automaticDataCollectionEnabled:!1},e),i=s.name;if(typeof i!="string"||!i)throw Gt.create("bad-app-name",{appName:String(i)});if(t||(t=df()),!t)throw Gt.create("no-options");const r=fi.get(i);if(r){if(di(t,r.options)&&di(s,r.config))return r;throw Gt.create("duplicate-app",{appName:i})}const o=new xy(i);for(const c of La.values())o.addComponent(c);const l=new mv(t,s,o);return fi.set(i,l),l}function vs(n=Ma){const e=fi.get(n);if(!e&&n===Ma&&df())return yv();if(!e)throw Gt.create("no-app",{appName:n});return e}function hP(){return Array.from(fi.values())}function Re(n,e,t){var s;let i=(s=pv[n])!==null&&s!==void 0?s:n;t&&(i+=`-${t}`);const r=i.match(/\s|\//),o=e.match(/\s|\//);if(r||o){const l=[`Unable to register library "${i}" with version "${e}":`];r&&l.push(`library name "${i}" contains illegal characters (whitespace or "/")`),r&&o&&l.push("and"),o&&l.push(`version name "${e}" contains illegal characters (whitespace or "/")`),Nt.warn(l.join(" "));return}Ge(new He(`${i}-version`,()=>({library:i,version:e}),"VERSION"))}/**
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 vv="firebase-heartbeat-database",Ev=1,pi="firebase-heartbeat-store";let ha=null;function vf(){return ha||(ha=rf(vv,Ev,{upgrade:(n,e)=>{switch(e){case 0:try{n.createObjectStore(pi)}catch(t){console.warn(t)}}}}).catch(n=>{throw Gt.create("idb-open",{originalErrorMessage:n.message})})),ha}async function Tv(n){try{const t=(await vf()).transaction(pi),s=await t.objectStore(pi).get(Ef(n));return await t.done,s}catch(e){if(e instanceof tt)Nt.warn(e.message);else{const t=Gt.create("idb-get",{originalErrorMessage:e==null?void 0:e.message});Nt.warn(t.message)}}}async function th(n,e){try{const s=(await vf()).transaction(pi,"readwrite");await s.objectStore(pi).put(e,Ef(n)),await s.done}catch(t){if(t instanceof tt)Nt.warn(t.message);else{const s=Gt.create("idb-set",{originalErrorMessage:t==null?void 0:t.message});Nt.warn(s.message)}}}function Ef(n){return`${n.name}!${n.options.appId}`}/**
467 * @license
468 * Copyright 2021 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, software
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 */const Iv=1024,wv=30*24*60*60*1e3;class Cv{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new Rv(t),this._heartbeatsCachePromise=this._storage.read().then(s=>(this._heartbeatsCache=s,s))}async triggerHeartbeat(){var e,t;try{const i=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),r=nh();return((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((t=this._heartbeatsCache)===null||t===void 0?void 0:t.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===r||this._heartbeatsCache.heartbeats.some(o=>o.date===r)?void 0:(this._heartbeatsCache.heartbeats.push({date:r,agent:i}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter(o=>{const l=new Date(o.date).valueOf();return Date.now()-l<=wv}),this._storage.overwrite(this._heartbeatsCache))}catch(s){Nt.warn(s)}}async getHeartbeatsHeader(){var e;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";const t=nh(),{heartbeatsToSend:s,unsentEntries:i}=Av(this._heartbeatsCache.heartbeats),r=Nr(JSON.stringify({version:2,heartbeats:s}));return this._heartbeatsCache.lastSentHeartbeatDate=t,i.length>0?(this._heartbeatsCache.heartbeats=i,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),r}catch(t){return Nt.warn(t),""}}}function nh(){return new Date().toISOString().substring(0,10)}function Av(n,e=Iv){const t=[];let s=n.slice();for(const i of n){const r=t.find(o=>o.agent===i.agent);if(r){if(r.dates.push(i.date),sh(t)>e){r.dates.pop();break}}else if(t.push({agent:i.agent,dates:[i.date]}),sh(t)>e){t.pop();break}s=s.slice(1)}return{heartbeatsToSend:t,unsentEntries:s}}class Rv{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return ho()?gf().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const t=await Tv(this.app);return t!=null&&t.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){const i=await this.read();return th(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:i.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){var t;if(await this._canUseIndexedDBPromise){const i=await this.read();return th(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:i.lastSentHeartbeatDate,heartbeats:[...i.heartbeats,...e.heartbeats]})}else return}}function sh(n){return Nr(JSON.stringify({version:2,heartbeats:n})).length}/**
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 */function Sv(n){Ge(new He("platform-logger",e=>new Uy(e),"PRIVATE")),Ge(new He("heartbeat",e=>new Cv(e),"PRIVATE")),Re(xa,Zu,n),Re(xa,Zu,"esm2017"),Re("fire-js","")}Sv("");var bv="firebase",Pv="10.14.1";/**
497 * @license
498 * Copyright 2020 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 */Re(bv,Pv,"app");const Tf="@firebase/installations",Il="0.6.9";/**
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 */const If=1e4,wf=`w:${Il}`,Cf="FIS_v2",kv="https://firebaseinstallations.googleapis.com/v1",Nv=60*60*1e3,Dv="installations",Ov="Installations";/**
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 */const xv={"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."},wn=new an(Dv,Ov,xv);function Af(n){return n instanceof tt&&n.code.includes("request-failed")}/**
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 Rf({projectId:n}){return`${kv}/projects/${n}/installations`}function Sf(n){return{token:n.token,requestStatus:2,expiresIn:Lv(n.expiresIn),creationTime:Date.now()}}async function bf(n,e){const s=(await e.json()).error;return wn.create("request-failed",{requestName:n,serverCode:s.code,serverMessage:s.message,serverStatus:s.status})}function Pf({apiKey:n}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":n})}function Mv(n,{refreshToken:e}){const t=Pf(n);return t.append("Authorization",Vv(e)),t}async function kf(n){const e=await n();return e.status>=500&&e.status<600?n():e}function Lv(n){return Number(n.replace("s","000"))}function Vv(n){return`${Cf} ${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 */async function Fv({appConfig:n,heartbeatServiceProvider:e},{fid:t}){const s=Rf(n),i=Pf(n),r=e.getImmediate({optional:!0});if(r){const h=await r.getHeartbeatsHeader();h&&i.append("x-firebase-client",h)}const o={fid:t,authVersion:Cf,appId:n.appId,sdkVersion:wf},l={method:"POST",headers:i,body:JSON.stringify(o)},c=await kf(()=>fetch(s,l));if(c.ok){const h=await c.json();return{fid:h.fid||t,registrationStatus:2,refreshToken:h.refreshToken,authToken:Sf(h.authToken)}}else throw await bf("Create Installation",c)}/**
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 */function Nf(n){return new Promise(e=>{setTimeout(e,n)})}/**
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 Uv(n){return btoa(String.fromCharCode(...n)).replace(/\+/g,"-").replace(/\//g,"_")}/**
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 Bv=/^[cdef][\w-]{21}$/,Va="";function qv(){try{const n=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(n),n[0]=112+n[0]%16;const t=$v(n);return Bv.test(t)?t:Va}catch{return Va}}function $v(n){return Uv(n).substr(0,22)}/**
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 */function po(n){return`${n.appName}!${n.appId}`}/**
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, softw
641are
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 */const Df=new Map;function Of(n,e){const t=po(n);xf(t,e),jv(t,e)}function xf(n,e){const t=Df.get(n);if(t)for(const s of t)s(e)}function jv(n,e){const t=Hv();t&&t.postMessage({key:n,fid:e}),Wv()}let gn=null;function Hv(){return!gn&&"BroadcastChannel"in self&&(gn=new BroadcastChannel("[Firebase] FID Change"),gn.onmessage=n=>{xf(n.data.key,n.data.fid)}),gn}function Wv(){Df.size===0&&gn&&(gn.close(),gn=null)}/**
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 */const zv="firebase-installations-database",Gv=1,Cn="firebase-installations-store";let da=null;function wl(){return da||(da=rf(zv,Gv,{upgrade:(n,e)=>{switch(e){case 0:n.createObjectStore(Cn)}}})),da}async function xr(n,e){const t=po(n),i=(await wl()).transaction(Cn,"readwrite"),r=i.objectStore(Cn),o=await r.get(t);return await r.put(e,t),await i.done,(!o||o.fid!==e.fid)&&Of(n,e.fid),e}async function Mf(n){const e=po(n),s=(await wl()).transaction(Cn,"readwrite");await s.objectStore(Cn).delete(e),await s.done}async function _o(n,e){const t=po(n),i=(await wl()).transaction(Cn,"readwrite"),r=i.objectStore(Cn),o=await r.get(t),l=e(o);return l===void 0?await r.delete(t):await r.put(l,t),await i.done,l&&(!o||o.fid!==l.fid)&&Of(n,l.fid),l}/**
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 Cl(n){let e;const t=await _o(n.appConfig,s=>{const i=Kv(s),r=Qv(n,i);return e=r.registrationPromise,r.installationEntry});return t.fid===Va?{installationEntry:await e}:{installationEntry:t,registrationPromise:e}}function Kv(n){const e=n||{fid:qv(),registrationStatus:0};return Lf(e)}function Qv(n,e){if(e.registrationStatus===0){if(!navigator.onLine){const i=Promise.reject(wn.create("app-offline"));return{installationEntry:e,registrationPromise:i}}const t={fid:e.fid,registrationStatus:1,registrationTime:Date.now()},s=Yv(n,t);return{installationEntry:t,registrationPromise:s}}else return e.registrationStatus===1?{installationEntry:e,registrationPromise:Xv(n)}:{installationEntry:e}}async function Yv(n,e){try{const t=await Fv(n,e);return xr(n.appConfig,t)}catch(t){throw Af(t)&&t.customData.serverCode===409?await Mf(n.appConfig):await xr(n.appConfig,{fid:e.fid,registrationStatus:0}),t}}async function Xv(n){let e=await ih(n.appConfig);for(;e.registrationStatus===1;)await Nf(100),e=await ih(n.appConfig);if(e.registrationStatus===0){const{installationEntry:t,registrationPromise:s}=await Cl(n);return s||t}return e}function ih(n){return _o(n,e=>{if(!e)throw wn.create("installation-not-found");return Lf(e)})}function Lf(n){return Jv(n)?{fid:n.fid,registrationStatus:0}:n}function Jv(n){return n.registrationStatus===1&&n.registrationTime+If<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 Zv({appConfig:n,heartbeatServiceProvider:e},t){const s=eE(n,t),i=Mv(n,t),r=e.getImmediate({optional:!0});if(r){const h=await r.getHeartbeatsHeader();h&&i.append("x-firebase-client",h)}const o={installation:{sdkVersion:wf,appId:n.appId}},l={method:"POST",headers:i,body:JSON.stringify(o)},c=await kf(()=>fetch(s,l));if(c.ok){const h=await c.json();return Sf(h)}else throw await bf("Generate Auth Token",c)}function eE(n,{fid:e}){return`${Rf(n)}/${e}/authTokens:generate`}/**
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 Al(n,e=!1){let t;const s=await _o(n.appConfig,r=>{if(!Vf(r))throw wn.create("not-registered");const o=r.authToken;if(!e&&sE(o))return r;if(o.requestStatus===1)return t=tE(n,e),r;{if(!navigator.onLine)throw wn.create("app-offline");const l=rE(r);return t=nE(n,l),l}});return t?await t:s.authToken}async function tE(n,e){let t=await rh(n.appConfig);for(;t.authToken.requestStatus===1;)await Nf(100),t=await rh(n.appConfig);const s=t.authToken;return s.requestStatus===0?Al(n,e):s}function rh(n){return _o(n,e=>{if(!Vf(e))throw wn.create("not-registered");const t=e.authToken;return oE(t)?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e})}async function nE(n,e){try{const t=await Zv(n,e),s=Object.assign(Object.assign({},e),{authToken:t});return await xr(n.appConfig,s),t}catch(t){if(Af(t)&&(t.customData.serverCode===401||t.customData.serverCode===404))await Mf(n.appConfig);else{const s=Object.assign(Object.assign({},e),{authToken:{requestStatus:0}});await xr(n.appConfig,s)}throw t}}function Vf(n){return n!==void 0&&n.registrationStatus===2}function sE(n){return n.requestStatus===2&&!iE(n)}function iE(n){const e=Date.now();return e<n.creationTime||n.creationTime+n.expiresIn<e+Nv}function rE(n){const e={requestStatus:1,requestTime:Date.now()};return Object.assign(Object.assign({},n),{authToken:e})}function oE(n){return n.requestStatus===1&&n.requestTime+If<Date.now()}/**
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 */async function aE(n){const e=n,{installationEntry:t,registrationPromise:s}=await Cl(e);return s?s.catch(console.error):Al(e).catch(console.error),t.fid}/**
722 * @license
723 * Copyright 2019 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 */async function lE(n,e=!1){const t=n;return await cE(t),(await Al(t,e)).token}async function cE(n){const{registrationPromise:e}=await Cl(n);e&&await e}/**
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 */function uE(n){if(!n||!n.options)throw fa("App Configuration");if(!n.name)throw fa("App Name");const e=["projectId","apiKey","appId"];for(const t of e)if(!n.options[t])throw fa(t);return{appName:n.name,projectId:n.options.projectId,apiKey:n.options.apiKey,appId:n.options.appId}}function fa(n){return wn.create("missing-app-config-values",{valueName:n})}/**
752 * @license
753 * Copyright 2020 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 Ff="installations",hE="installations-internal",dE=n=>{const e=n.getProvider("app").getImmediate(),t=uE(e),s=gt(e,"heartbeat");return{app:e,appConfig:t,heartbeatServiceProvider:s,_delete:()=>Promise.resolve()}},fE=n=>{const e=n.getProvider("app").getImmediate(),t=gt(e,Ff).getImmediate();return{getId:()=>aE(t),getToken:i=>lE(t,i)}};function pE(){Ge(new He(Ff,dE,"PUBLIC")),Ge(new He(hE,fE,"PRIVATE"))}pE();Re(Tf,Il);Re(Tf,Il,"esm2017");/**
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 Mr="analytics",_E="firebase_id",gE="origin",mE=60*1e3,yE="https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig",Rl="https://www.googletagmanager.com/gtag/js";/**
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 */const Se=new ys("@firebase/analytics");/**
797 * @license
798 * Copyright 2019 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 vE={"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-initialized 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}
811","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}."},Xe=new an("analytics","Analytics",vE);/**
812 * @license
813 * Copyright 2019 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 */function EE(n){if(!n.startsWith(Rl)){const e=Xe.create("invalid-gtag-resource",{gtagURL:n});return Se.warn(e.message),""}return n}function Uf(n){return Promise.all(n.map(e=>e.catch(t=>t)))}function TE(n,e){let t;return window.trustedTypes&&(t=window.trustedTypes.createPolicy(n,e)),t}function IE(n,e){const t=TE("firebase-js-sdk-policy",{createScriptURL:EE}),s=document.createElement("script"),i=`${Rl}?l=${n}&id=${e}`;s.src=t?t==null?void 0:t.createScriptURL(i):i,s.async=!0,document.head.appendChild(s)}function wE(n){let e=[];return Array.isArray(window[n])?e=window[n]:window[n]=e,e}async function CE(n,e,t,s,i,r){const o=s[i];try{if(o)await e[o];else{const c=(await Uf(t)).find(h=>h.measurementId===i);c&&await e[c.appId]}}catch(l){Se.error(l)}n("config",i,r)}async function AE(n,e,t,s,i){try{let r=[];if(i&&i.send_to){let o=i.send_to;Array.isArray(o)||(o=[o]);const l=await Uf(t);for(const c of o){const h=l.find(p=>p.measurementId===c),f=h&&e[h.appId];if(f)r.push(f);else{r=[];break}}}r.length===0&&(r=Object.values(e)),await Promise.all(r),n("event",s,i||{})}catch(r){Se.error(r)}}function RE(n,e,t,s){async function i(r,...o){try{if(r==="event"){const[l,c]=o;await AE(n,e,t,l,c)}else if(r==="config"){const[l,c]=o;await CE(n,e,t,s,l,c)}else if(r==="consent"){const[l,c]=o;n("consent",l,c)}else if(r==="get"){const[l,c,h]=o;n("get",l,c,h)}else if(r==="set"){const[l]=o;n("set",l)}else n(r,...o)}catch(l){Se.error(l)}}return i}function SE(n,e,t,s,i){let r=function(...o){window[s].push(arguments)};return window[i]&&typeof window[i]=="function"&&(r=window[i]),window[i]=RE(r,n,e,t),{gtagCore:r,wrappedGtag:window[i]}}function bE(n){const e=window.document.getElementsByTagName("script");for(const t of Object.values(e))if(t.src&&t.src.includes(Rl)&&t.src.includes(n))return t;return null}/**
827 * @license
828 * Copyright 2020 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 */const PE=30,kE=1e3;class NE{constructor(e={},t=kE){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 Bf=new NE;function DE(n){return new Headers({Accept:"application/json","x-goog-api-key":n})}async function OE(n){var e;const{appId:t,apiKey:s}=n,i={method:"GET",headers:DE(s)},r=yE.replace("{app-id}",t),o=await fetch(r,i);if(o.status!==200&&o.status!==304){let l="";try{const c=await o.json();!((e=c.error)===null||e===void 0)&&e.message&&(l=c.error.message)}catch{}throw Xe.create("config-fetch-failed",{httpStatus:o.status,responseMessage:l})}return o.json()}async function xE(n,e=Bf,t){const{appId:s,apiKey:i,measurementId:r}=n.options;if(!s)throw Xe.create("no-app-id");
841if(!i){if(r)return{measurementId:r,appId:s};throw Xe.create("no-api-key")}const o=e.getThrottleMetadata(s)||{backoffCount:0,throttleEndTimeMillis:Date.now()},l=new VE;return setTimeout(async()=>{l.abort()},mE),qf({appId:s,apiKey:i,measurementId:r},o,l,e)}async function qf(n,{throttleEndTimeMillis:e,backoffCount:t},s,i=Bf){var r;const{appId:o,measurementId:l}=n;try{await ME(s,e)}catch(c){if(l)return Se.warn(`Timed out fetching this Firebase app's measurement ID from the server. Falling back to the measurement ID ${l} provided in the "measurementId" field in the local Firebase config. [${c==null?void 0:c.message}]`),{appId:o,measurementId:l};throw c}try{const c=await OE(n);return i.deleteThrottleMetadata(o),c}catch(c){const h=c;if(!LE(h)){if(i.deleteThrottleMetadata(o),l)return Se.warn(`Failed to fetch this Firebase app's measurement ID from the server. Falling back to the measurement ID ${l} provided in the "measurementId" field in the local Firebase config. [${h==null?void 0:h.message}]`),{appId:o,measurementId:l};throw c}const f=Number((r=h==null?void 0:h.customData)===null||r===void 0?void 0:r.httpStatus)===503?Ju(t,i.intervalMillis,PE):Ju(t,i.intervalMillis),p={throttleEndTimeMillis:Date.now()+f,backoffCount:t+1};return i.setThrottleMetadata(o,p),Se.debug(`Calling attemptFetch again in ${f} millis`),qf(n,p,s,i)}}function ME(n,e){return new Promise((t,s)=>{const i=Math.max(e-Date.now(),0),r=setTimeout(t,i);n.addEventListener(()=>{clearTimeout(r),s(Xe.create("fetch-throttle",{throttleEndTimeMillis:e}))})})}function LE(n){if(!(n instanceof tt)||!n.customData)return!1;const e=Number(n.customData.httpStatus);return e===429||e===500||e===503||e===504}class VE{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}async function FE(n,e,t,s,i){if(i&&i.global){n("event",t,s);return}else{const r=await e,o=Object.assign(Object.assign({},s),{send_to:r});n("event",t,o)}}async function UE(n,e,t,s){if(s&&s.global)return n("set",{user_id:t}),Promise.resolve();{const i=await e;n("config",i,{update:!0,user_id:t})}}async function BE(n,e,t,s){if(s&&s.global){const i={};for(const r of Object.keys(t))i[`user_properties.${r}`]=t[r];return n("set",i),Promise.resolve()}else{const i=await e;n("config",i,{update:!0,user_properties:t})}}async function qE(n,e){const t=await n;window[`ga-disable-${t}`]=!1}let Fa;function $f(n){Fa=n}/**
842 * @license
843 * Copyright 2020 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 */async function $E(){if(ho())try{await gf()}catch(n){return Se.warn(Xe.create("indexeddb-unavailable",{errorInfo:n==null?void 0:n.toString()}).message),!1}else return Se.warn(Xe.create("indexeddb-unavailable",{errorInfo:"IndexedDB is not available in this environment."}).message),!1;return!0}async function jE(n,e,t,s,i,r,o){var l;const c=xE(n);c.then(I=>{t[I.measurementId]=I.appId,n.options.measurementId&&I.measurementId!==n.options.measurementId&&Se.warn(`The measurement ID in the local Firebase config (${n.options.measurementId}) does not match the measurement ID fetched from the server (${I.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(I=>Se.error(I)),e.push(c);const h=$E().then(I=>{if(I)return s.getId()}),[f,p]=await Promise.all([c,h]);bE(r)||IE(r,f.measurementId),Fa&&(i("consent","default",Fa),$f(void 0)),i("js",new Date);const g=(l=o==null?void 0:o.config)!==null&&l!==void 0?l:{};return g[gE]="firebase",g.update=!0,p!=null&&(g[_E]=p),i("config",f.measurementId,g),f.measurementId}/**
857 * @license
858 * Copyright 2019 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 HE{constructor(e){this.app=e}_delete(){return delete Kt[this.app.options.appId],Promise.resolve()}}let Kt={},oh=[];const ah={};let pa="dataLayer",WE="gtag",lh,ss,ch=!1;function zE(){const n=[];if(pf()&&n.push("This is a browser extension environment."),_y()||n.push("Cookies are not available."),n.length>0){const e=n.map((s,i)=>`(${i+1}) ${s}`).join(" "),t=Xe.create("invalid-analytics-context",{errorInfo:e});Se.warn(t.message)}}function GE(n,e,t){zE();const s=n.options.appId;if(!s)throw Xe.create("no-app-id");if(!n.options.apiKey)if(n.options.measurementId)Se.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 Xe.create("no-api-key");if(Kt[s]!=null)throw Xe.create("already-exists",{id:s});if(!ch){wE(pa);const{wrappedGtag:r,gtagCore:o}=SE(Kt,oh,ah,pa,WE);ss=r,lh=o,ch=!0}return Kt[s]=jE(n,oh,ah,e,lh,pa,t),new HE(n)}function dP(n=vs()){n=le(n);const e=gt(n,Mr);return e.isInitialized()?e.getImmediate():KE(n)}function KE(n,e={}){const t=gt(n,Mr);if(t.isInitialized()){const i=t.getImmediate();if(di(e,t.getOptions()))return i;throw Xe.create("already-initialized")}return t.initialize({options:e})}function fP(n,e,t){n=le(n),UE(ss,Kt[n.app.options.appId],e,t).catch(s=>Se.error(s))}function pP(n,e,t){n=le(n),BE(ss,Kt[n.app.options.appId],e,t).catch(s=>Se.error(s))}function _P(n,e){n=le(n),qE(Kt[n.app.options.appId]).catch(t=>Se.error(t))}function QE(n,e,t,s){n=le(n),FE(ss,Kt[n.app.options.appId],e,t,s).catch(i=>Se.error(i))}function gP(n){ss?ss("consent","update",n):$f(n)}const uh="@firebase/analytics",hh="0.10.8";function YE(){Ge(new He(Mr,(e,{options:t})=>{const s=e.getProvider("app").getImmediate(),i=e.getProvider("installations-internal").getImmediate();return GE(s,i,t)},"PUBLIC")),Ge(new He("analytics-internal",n,"PRIVATE")),Re(uh,hh),Re(uh,hh,"esm2017");function n(e){try{const t=e.getProvider(Mr).getImmediate();return{logEvent:(s,i,r)=>QE(t,s,i,r)}}catch(t){throw Xe.create("interop-component-reg-failed",{reason:t})}}}YE();function jf(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}const Hf=jf,Wf=new an("auth","Firebase",jf());/**
872 * @license
873 * Copyright 2020 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 */const Lr=new ys("@firebase/auth");function XE(n,...e){Lr.logLevel<=K.WARN&&Lr.warn(`Auth (${ln}): ${n}`,...e)}function Tr(n,...e){Lr.logLevel<=K.ERROR&&Lr.error(`Auth (${ln}): ${n}`,...e)}/**
887 * @license
888 * Copyright 2020 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, softw
896are
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 */function Dt(n,...e){throw Sl(n,...e)}function ht(n,...e){return Sl(n,...e)}function zf(n,e,t){const s=Object.assign(Object.assign({},Hf()),{[e]:t});return new an("auth","Firebase",s).create(e,{appName:n.name})}function vn(n){return zf(n,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function Sl(n,...e){if(typeof n!="string"){const t=e[0],s=[...e.slice(1)];return s[0]&&(s[0].appName=n.name),n._errorFactory.create(t,...s)}return Wf.create(n,...e)}function U(n,e,...t){if(!n)throw Sl(e,...t)}function At(n){const e="INTERNAL ASSERTION FAILED: "+n;throw Tr(e),new Error(e)}function Ot(n,e){n||At(e)}/**
902 * @license
903 * Copyright 2020 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 */function Ua(){var n;return typeof self<"u"&&((n=self.location)===null||n===void 0?void 0:n.href)||""}function JE(){return dh()==="http:"||dh()==="https:"}function dh(){var n;return typeof self<"u"&&((n=self.location)===null||n===void 0?void 0:n.protocol)||null}/**
917 * @license
918 * Copyright 2020 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 */function ZE(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(JE()||pf()||"connection"in navigator)?navigator.onLine:!0}function eT(){if(typeof navigator>"u")return null;const n=navigator;return n.languages&&n.languages[0]||n.language||null}/**
932 * @license
933 * Copyright 2020 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 Pi{constructor(e,t){this.shortDelay=e,this.longDelay=t,Ot(t>e,"Short delay should be less than long delay!"),this.isMobile=Tl()||_f()}get(){return ZE()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}/**
947 * @license
948 * Copyright 2020 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 */function bl(n,e){Ot(n.emulator,"Emulator should always be set here");const{url:t}=n.emulator;return e?`${t}${e.startsWith("/")?e.slice(1):e}`:t}/**
962 * @license
963 * Copyright 2020 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 Gf{static initialize(e,t,s){this.fetchImpl=e,t&&(this.headersImpl=t),s&&(this.responseImpl=s)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<"u"&&"fetch"in self)return self.fetch;if(typeof globalThis<"u"&&globalThis.fetch)return globalThis.fetch;if(typeof fetch<"u")return fetch;At("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){if(this.headersImpl)return this.headersImpl;if(typeof self<"u"&&"Headers"in self)return self.Headers;if(typeof globalThis<"u"&&globalThis.Headers)return globalThis.Headers;if(typeof Headers<"u")return Headers;At("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<"u"&&"Response"in self)return self.Response;if(typeof globalThis<"u"&&globalThis.Response)return globalThis.Response;if(typeof Response<"u")return Response;At("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}/**
977 * @license
978 * Copyright 2020 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 */const tT={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-rec
991aptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"};/**
992 * @license
993 * Copyright 2020 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 nT=new Pi(3e4,6e4);function Pl(n,e){return n.tenantId&&!e.tenantId?Object.assign(Object.assign({},e),{tenantId:n.tenantId}):e}async function Nn(n,e,t,s,i={}){return Kf(n,i,async()=>{let r={},o={};s&&(e==="GET"?o=s:r={body:JSON.stringify(s)});const l=ms(Object.assign({key:n.config.apiKey},o)).slice(1),c=await n._getAdditionalHeaders();c["Content-Type"]="application/json",n.languageCode&&(c["X-Firebase-Locale"]=n.languageCode);const h=Object.assign({method:e,headers:c},r);return hy()||(h.referrerPolicy="no-referrer"),Gf.fetch()(Qf(n,n.config.apiHost,t,l),h)})}async function Kf(n,e,t){n._canInitEmulator=!1;const s=Object.assign(Object.assign({},tT),e);try{const i=new iT(n),r=await Promise.race([t(),i.promise]);i.clearNetworkTimeout();const o=await r.json();if("needConfirmation"in o)throw hr(n,"account-exists-with-different-credential",o);if(r.ok&&!("errorMessage"in o))return o;{const l=r.ok?o.errorMessage:o.error.message,[c,h]=l.split(" : ");if(c==="FEDERATED_USER_ID_ALREADY_LINKED")throw hr(n,"credential-already-in-use",o);if(c==="EMAIL_EXISTS")throw hr(n,"email-already-in-use",o);if(c==="USER_DISABLED")throw hr(n,"user-disabled",o);const f=s[c]||c.toLowerCase().replace(/[_\s]+/g,"-");if(h)throw zf(n,f,h);Dt(n,f)}}catch(i){if(i instanceof tt)throw i;Dt(n,"network-request-failed",{message:String(i)})}}async function sT(n,e,t,s,i={}){const r=await Nn(n,e,t,s,i);return"mfaPendingCredential"in r&&Dt(n,"multi-factor-auth-required",{_serverResponse:r}),r}function Qf(n,e,t,s){const i=`${e}${t}?${s}`;return n.config.emulator?bl(n.config,i):`${n.config.apiScheme}://${i}`}class iT{constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((t,s)=>{this.timer=setTimeout(()=>s(ht(this.auth,"network-request-failed")),nT.get())})}clearNetworkTimeout(){clearTimeout(this.timer)}}function hr(n,e,t){const s={appName:n.name};t.email&&(s.email=t.email),t.phoneNumber&&(s.phoneNumber=t.phoneNumber);const i=ht(n,e,s);return i.customData._tokenResponse=t,i}/**
1007 * @license
1008 * Copyright 2020 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 */async function rT(n,e){return Nn(n,"POST","/v1/accounts:delete",e)}async function Yf(n,e){return Nn(n,"POST","/v1/accounts:lookup",e)}/**
1022 * @license
1023 * Copyright 2020 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 */function ei(n){if(n)try{const e=new Date(Number(n));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function Xf(n,e=!1){const t=le(n),s=await t.getIdToken(e),i=kl(s);U(i&&i.exp&&i.auth_time&&i.iat,t.auth,"internal-error");const r=typeof i.firebase=="object"?i.firebase:void 0,o=r==null?void 0:r.sign_in_provider;return{claims:i,token:s,authTime:ei(_a(i.auth_time)),issuedAtTime:ei(_a(i.iat)),expirationTime:ei(_a(i.exp
1036)),signInProvider:o||null,signInSecondFactor:(r==null?void 0:r.sign_in_second_factor)||null}}function _a(n){return Number(n)*1e3}function kl(n){const[e,t,s]=n.split(".");if(e===void 0||t===void 0||s===void 0)return Tr("JWT malformed, contained fewer than 3 sections"),null;try{const i=Dr(t);return i?JSON.parse(i):(Tr("Failed to decode base64 JWT payload"),null)}catch(i){return Tr("Caught error parsing JWT payload as JSON",i==null?void 0:i.toString()),null}}function fh(n){const e=kl(n);return U(e,"internal-error"),U(typeof e.exp<"u","internal-error"),U(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}/**
1037 * @license
1038 * Copyright 2020 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 */async function is(n,e,t=!1){if(t)return e;try{return await e}catch(s){throw s instanceof tt&&oT(s)&&n.auth.currentUser===n&&await n.auth.signOut(),s}}function oT({code:n}){return n==="auth/user-disabled"||n==="auth/user-token-expired"}/**
1052 * @license
1053 * Copyright 2020 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 aT{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,this.timerId!==null&&clearTimeout(this.timerId))}getInterval(e){var t;if(e){const s=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),s}else{this.errorBackoff=3e4;const i=((t=this.user.stsTokenManager.expirationTime)!==null&&t!==void 0?t:0)-Date.now()-3e5;return Math.max(0,i)}}schedule(e=!1){if(!this.isRunning)return;const t=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){(e==null?void 0:e.code)==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}/**
1067 * @license
1068 * Copyright 2020 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 */class Ba{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=ei(this.lastLoginAt),this.creationTime=ei(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}/**
1082 * @license
1083 * Copyright 2019 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 */async function Vr(n){var e;const t=n.auth,s=await n.getIdToken(),i=await is(n,Yf(t,{idToken:s}));U(i==null?void 0:i.users.length,t,"internal-error");const r=i.users[0];n._notifyReloadListener(r);const o=!((e=r.providerUserInfo)===null||e===void 0)&&e.length?Zf(r.providerUserInfo):[],l=lT(n.providerData,o),c=n.isAnonymous,h=!(n.email&&r.passwordHash)&&!(l!=null&&l.length),f=c?h:!1,p={uid:r.localId,displayName:r.displayName||null,photoURL:r.photoUrl||null,email:r.email||null,emailVerified:r.emailVerified||!1,phoneNumber:r.phoneNumber||null,tenantId:r.tenantId||null,providerData:l,metadata:new Ba(r.createdAt,r.lastLoginAt),isAnonymous:f};Object.assign(n,p)}async function Jf(n){const e=le(n);await Vr(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function lT(n,e){return[...n.filter(s=>!e.some(i=>i.providerId===s.providerId)),...e]}function Zf(n){return n.map(e=>{var{providerId:t}=e,s=yl(e,["providerId"]);return{providerId:t,uid:s.rawId||"",displayName:s.displayName||null,email:s.email||null,phoneNumber:s.phoneNumber||null,photoURL:s.photoUrl||null}})}/**
1097 * @license
1098 * Copyright 2020 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 */async function cT(n,e){const t=await Kf(n,{},async()=>{const s=ms({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:i,apiKey:r}=n.config,o=Qf(n,i,"/v1/token",`key=${r}`),l=await n._getAdditionalHeaders();return l["Content-Type"]="application/x-www-form-urlencoded",Gf.fetch()(o,{method:"POST",headers:l,body:s})});return{accessToken:t.access_token,expiresIn:t.expires_in,refreshToken:t.refresh_token}}async function uT(n,e){return Nn(n,"POST","/v2/accounts:revokeToken",Pl(n,e))}/**
1112 * @license
1113 * Copyright 2020 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 Kn{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){U(e.idToken,"internal-error"),U(typeof e.idToken<"u","internal-error"),U(typeof e.refreshToken<"u","internal-error");const t="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):fh(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){U(e.length!==0,"internal-error");const t=fh(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(U(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:s,refreshToken:i,expiresIn:r}=await cT(e,t);this.updateTokensAndExpiration(s,i,Number(r))}updateTokensAndExpiration(e,t,s){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+s*1e3}static fromJSON(e,t){const{refreshToken:s,accessToken:i,expirationTime:r}=t,o=new Kn;return s&&(U(typeof s=="string","internal-error",{appName:e}),o.refreshToken=s),i&&(U(typeof i=="string","internal-error",{appName:e}),o.accessToken=i),r&&(U(typeof r=="number","internal-error",{appName:e}),o.expirationTime=r),o}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new Kn,this.toJSON())}_performRefresh(){return At("not implemented")}}/**
1127 * @license
1128 * Copyright 2020 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 */function qt(n,e){U(typeof n=="string"||typeof n>"u","internal-error",{appName:e})}class Rt{constructor(e){var{uid:t,auth:s,stsTokenManager:i}=e,r=yl(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new aT(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,this.auth=s,this.stsTokenManager=i,this.accessToken=i.accessToken,this.displayName=r.displayName||null,this.email=r.email||null,this.emailVerified=r.emailVerified||!1,this.phoneNumber=r.phoneNumber||null,this.photoURL=r.photoURL||null,this.isAnonymous=r.isAnonymous||!1,this.tenantId=r.tenantId||null,this.providerData=r.providerData?[...r.providerData]:[],this.metadata=new Ba(r.createdAt||void 0,r.lastLoginAt||void 0)}async getIdToken(e){const t=await is(this,this.stsTokenManager.getToken(this.auth,e));return U(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return Xf(this,e)}reload(){return Jf(this)}_assign(e){this!==e&&(U(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(t=>Object.assign({},t)),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new Rt(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}));return t.metadata._copy(this.metadata),t}_onReload(e){U(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let s=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),s=!0),t&&await Vr(this),await this.auth._persistUserIfCurrent(this),s&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(Ht(this.auth.app))return Promise.reject(vn(this.auth));const e=await this.getIdToken();return await is(this,rT(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>Object.assign({},e)),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){var s,i,r,o,l,c,h,f;const p=(s=t.displayName)!==null&&s!==void 0?s:void 0,g=(i=t.email)!==null&&i!==void 0?i:void 0,I=(r=t.phoneNumber)!==null&&r!==void 0?r:void 0,S=(o=t.photoURL)!==null&&o!==void 0?o:void 0,k=(l=t.tenantId)!==null&&l!==void 0?l:void 0,b=(c=t._redirectEventId)!==null&&c!==void 0?c:void 0,B=(h=t.createdAt)!==null&&h!==void 0?h:void 0,H=(f=t.lastLoginAt)!==null&&f!==void 0?f:void 0,{uid:V,emailVerified:$,isAnonymous:me,providerData:te,stsTokenManager:T}=t;U(V&&T,e,"internal-error");const m=Kn.fromJSON(this.name,T);U(typeof V=="string",e,"internal-error"),qt(p,e.name),qt(g,e.name),U(typeof $=="boolean",e,"internal-error"),U(typeof me=="boolean",e,"internal-error"),qt(I,e.name),qt(S,e.name),qt(k,e.name),qt(b,e.name),qt(B,e.name),qt(H,e.name);const y=new Rt({uid:V,auth:e,email:g,emailVerified:$,displayName:p,isAnonymous:me,photoURL:S,phoneNumber:I,tenantId:k,stsTokenManager:m,createdAt:B,lastLoginAt:H});return te&&Array.isArray(te)&&(y.providerData=te.map(E=>Object.assign({},E))),b&&(y._redirectEventId=b),y}static async _fromIdTokenResponse(e,t,s=!1){const i=new Kn;i.updateFromServerResponse(t);const r=new Rt({uid:t.localId,auth:e,stsTokenManager:i,isAnonymous:s});return await Vr(r),r}static async _fromGetAccountInfoResponse(e,t,s){const i=t.users[0];U(i.localId!==void 0,"internal-error");const r=i.providerUserInfo!==void 0?Zf(i.providerUserInfo):[],o=!(i.email&&i.passwordHash)&&!(r!=null&&r.length),l=new Kn;l.updateFromIdToken(s);const c=new Rt({uid:i.localId,auth:e,stsTokenManager:l,isAnonymous:o}),h={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:r,metadata:new Ba(i.createdAt,i.lastLoginAt),isAnonymous:!(i.email&&i.passwordHash)&&!(r!=null&&r.length)};return Object.assign(c,h),c}}/**
1142 * @license
1143 * Copyright 2020 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 */const ph=new Map;function St(n){Ot(n instanceof Function,"Expected a class definition");let e=ph.get(n);return e?(Ot(e instanceof n,"Instance stored in cache mismatched with class"),e):(e=new n,ph.set(n,e),e)}/**
1157 * @license
1158 * Copyright 2019 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 */class ep{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){const t=this.storage[e];return t===void 0?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}ep.type="NONE";const qa=ep;/**
1172 * @license
1173 * Copyright 2019 Google LLC
1174 *
1175 * Licensed under the Apache License, Version 2.0 (the "License");
1176 * you may not use this file except in compliance with the License.
1177 * You may obtain a copy of the License at
1178 *
1179 *   http://www.apache.org/licenses/LICENSE-2.0
1180 *
1181 * Unless required by applicable law or agreed to in writing, software
1182 * distributed under the License is distributed on an "AS IS" BASIS,
1183 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1184 * See the License for the specific language governing permissions and
1185 * limitations under the License.
1186 */function Ir(n,e,t){return`firebase:${n}:${e}:${t}`}class Qn{constructor(e,t,s){this.persistence=e,this.auth=t,this.userKey=s;const{config:i,name:r}=this.auth;this.fullUserKey=Ir(this.userKey,i.apiKey,r),this.fullPersistenceKey=Ir("persistence",i.apiKey,r),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);return e?Rt._fromJSON(this.auth,e):null}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;const t=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=e,t)return this.setCurrentUser(t)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,s="authUser"){if(!t.length)return new Qn(St(qa),e,s);const i=(await Promise.all(t.map(async h=>{if(await h._isAvailable())return h}))).filter(h=>h);let r=i[0]||St(qa);const o=Ir(s,e.config.apiKey,e.name);let l=null;for(const h of t)try{const f=await h._get(o);if(f){const p=Rt._fromJSON(e,f);h!==r&&(l=p),r=h;break}}catch{}const c=i.filter(h=>h._shouldAllowMigration);return!r._shouldAllowMigration||!c.length?new Qn(r,e,s):(r=c[0],l&&await r._set(o,l.toJSON()),await Promise.all(t.map(async h=>{if(h!==r)try{await h._remove(o)}catch{}})),new Qn(r,e,s))}}/**
1187 * @license
1188 * Copyright 2020 Google LLC
1189 *
1190 * Licensed under the Apache License, Version 2.0 (the "License");
1191 * you may not use this file except in compliance with the License.
1192 * You may obtain a copy of the License at
1193 *
1194 *   http://www.apache.org/licenses/LICENSE-2.0
1195 *
1196 * Unless required by applicable law or agreed to in writing, softw
1196are
1197 * distributed under the License is distributed on an "AS IS" BASIS,
1198 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1199 * See the License for the specific language governing permissions and
1200 * limitations under the License.
1201 */function _h(n){const e=n.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(ip(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(tp(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(op(e))return"Blackberry";if(ap(e))return"Webos";if(np(e))return"Safari";if((e.includes("chrome/")||sp(e))&&!e.includes("edge/"))return"Chrome";if(rp(e))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,s=n.match(t);if((s==null?void 0:s.length)===2)return s[1]}return"Other"}function tp(n=Fe()){return/firefox\//i.test(n)}function np(n=Fe()){const e=n.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function sp(n=Fe()){return/crios\//i.test(n)}function ip(n=Fe()){return/iemobile/i.test(n)}function rp(n=Fe()){return/android/i.test(n)}function op(n=Fe()){return/blackberry/i.test(n)}function ap(n=Fe()){return/webos/i.test(n)}function Nl(n=Fe()){return/iphone|ipad|ipod/i.test(n)||/macintosh/i.test(n)&&/mobile/i.test(n)}function hT(n=Fe()){var e;return Nl(n)&&!!(!((e=window.navigator)===null||e===void 0)&&e.standalone)}function dT(){return dy()&&document.documentMode===10}function lp(n=Fe()){return Nl(n)||rp(n)||ap(n)||op(n)||/windows phone/i.test(n)||ip(n)}/**
1202 * @license
1203 * Copyright 2020 Google LLC
1204 *
1205 * Licensed under the Apache License, Version 2.0 (the "License");
1206 * you may not use this file except in compliance with the License.
1207 * You may obtain a copy of the License at
1208 *
1209 *   http://www.apache.org/licenses/LICENSE-2.0
1210 *
1211 * Unless required by applicable law or agreed to in writing, software
1212 * distributed under the License is distributed on an "AS IS" BASIS,
1213 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1214 * See the License for the specific language governing permissions and
1215 * limitations under the License.
1216 */function cp(n,e=[]){let t;switch(n){case"Browser":t=_h(Fe());break;case"Worker":t=`${_h(Fe())}-${n}`;break;default:t=n}const s=e.length?e.join(","):"FirebaseCore-web";return`${t}/JsCore/${ln}/${s}`}/**
1217 * @license
1218 * Copyright 2022 Google LLC
1219 *
1220 * Licensed under the Apache License, Version 2.0 (the "License");
1221 * you may not use this file except in compliance with the License.
1222 * You may obtain a copy of the License at
1223 *
1224 *   http://www.apache.org/licenses/LICENSE-2.0
1225 *
1226 * Unless required by applicable law or agreed to in writing, software
1227 * distributed under the License is distributed on an "AS IS" BASIS,
1228 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1229 * See the License for the specific language governing permissions and
1230 * limitations under the License.
1231 */class fT{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const s=r=>new Promise((o,l)=>{try{const c=e(r);o(c)}catch(c){l(c)}});s.onAbort=t,this.queue.push(s);const i=this.queue.length-1;return()=>{this.queue[i]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const t=[];try{for(const s of this.queue)await s(e),s.onAbort&&t.push(s.onAbort)}catch(s){t.reverse();for(const i of t)try{i()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:s==null?void 0:s.message})}}}/**
1232 * @license
1233 * Copyright 2023 Google LLC
1234 *
1235 * Licensed under the Apache License, Version 2.0 (the "License");
1236 * you may not use this file except in compliance with the License.
1237 * You may obtain a copy of the License at
1238 *
1239 *   http://www.apache.org/licenses/LICENSE-2.0
1240 *
1241 * Unless required by applicable law or agreed to in writing, software
1242 * distributed under the License is distributed on an "AS IS" BASIS,
1243 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1244 * See the License for the specific language governing permissions and
1245 * limitations under the License.
1246 */async function pT(n,e={}){return Nn(n,"GET","/v2/passwordPolicy",Pl(n,e))}/**
1247 * @license
1248 * Copyright 2023 Google LLC
1249 *
1250 * Licensed under the Apache License, Version 2.0 (the "License");
1251 * you may not use this file except in compliance with the License.
1252 * You may obtain a copy of the License at
1253 *
1254 *   http://www.apache.org/licenses/LICENSE-2.0
1255 *
1256 * Unless required by applicable law or agreed to in writing, software
1257 * distributed under the License is distributed on an "AS IS" BASIS,
1258 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1259 * See the License for the specific language governing permissions and
1260 * limitations under the License.
1261 */const _T=6;class gT{constructor(e){var t,s,i,r;const o=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=(t=o.minPasswordLength)!==null&&t!==void 0?t:_T,o.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=o.maxPasswordLength),o.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=o.containsLowercaseCharacter),o.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=o.containsUppercaseCharacter),o.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=o.containsNumericCharacter),o.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=o.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=(i=(s=e.allowedNonAlphanumericCharacters)===null||s===void 0?void 0:s.join(""))!==null&&i!==void 0?i:"",this.forceUpgradeOnSignin=(r=e.forceUpgradeOnSignin)!==null&&r!==void 0?r:!1,this.schemaVersion=e.schemaVersion}validatePassword(e){var t,s,i,r,o,l;const c={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,c),this.validatePasswordCharacterOptions(e,c),c.isValid&&
1261(c.isValid=(t=c.meetsMinPasswordLength)!==null&&t!==void 0?t:!0),c.isValid&&(c.isValid=(s=c.meetsMaxPasswordLength)!==null&&s!==void 0?s:!0),c.isValid&&(c.isValid=(i=c.containsLowercaseLetter)!==null&&i!==void 0?i:!0),c.isValid&&(c.isValid=(r=c.containsUppercaseLetter)!==null&&r!==void 0?r:!0),c.isValid&&(c.isValid=(o=c.containsNumericCharacter)!==null&&o!==void 0?o:!0),c.isValid&&(c.isValid=(l=c.containsNonAlphanumericCharacter)!==null&&l!==void 0?l:!0),c}validatePasswordLengthOptions(e,t){const s=this.customStrengthOptions.minPasswordLength,i=this.customStrengthOptions.maxPasswordLength;s&&(t.meetsMinPasswordLength=e.length>=s),i&&(t.meetsMaxPasswordLength=e.length<=i)}validatePasswordCharacterOptions(e,t){this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);let s;for(let i=0;i<e.length;i++)s=e.charAt(i),this.updatePasswordCharacterOptionsStatuses(t,s>="a"&&s<="z",s>="A"&&s<="Z",s>="0"&&s<="9",this.allowedNonAlphanumericCharacters.includes(s))}updatePasswordCharacterOptionsStatuses(e,t,s,i,r){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=s)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=i)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=r))}}/**
1262 * @license
1263 * Copyright 2020 Google LLC
1264 *
1265 * Licensed under the Apache License, Version 2.0 (the "License");
1266 * you may not use this file except in compliance with the License.
1267 * You may obtain a copy of the License at
1268 *
1269 *   http://www.apache.org/licenses/LICENSE-2.0
1270 *
1271 * Unless required by applicable law or agreed to in writing, software
1272 * distributed under the License is distributed on an "AS IS" BASIS,
1273 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1274 * See the License for the specific language governing permissions and
1275 * limitations under the License.
1276 */class mT{constructor(e,t,s,i){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=s,this.config=i,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new gh(this),this.idTokenSubscription=new gh(this),this.beforeStateQueue=new fT(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=Wf,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=i.sdkClientVersion}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=St(t)),this._initializationPromise=this.queue(async()=>{var s,i;if(!this._deleted&&(this.persistenceManager=await Qn.create(this,e),!this._deleted)){if(!((s=this._popupRedirectResolver)===null||s===void 0)&&s._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(t),this.lastNotifiedUid=((i=this.currentUser)===null||i===void 0?void 0:i.uid)||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{const t=await Yf(this,{idToken:e}),s=await Rt._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(s)}catch(t){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",t),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){var t;if(Ht(this.app)){const o=this.app.settings.authIdToken;return o?new Promise(l=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(o).then(l,l))}):this.directlySetCurrentUser(null)}const s=await this.assertedPersistence.getCurrentUser();let i=s,r=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const o=(t=this.redirectUser)===null||t===void 0?void 0:t._redirectEventId,l=i==null?void 0:i._redirectEventId,c=await this.tryRedirectSignIn(e);(!o||o===l)&&(c!=null&&c.user)&&(i=c.user,r=!0)}if(!i)return this.directlySetCurrentUser(null);
1276if(!i._redirectEventId){if(r)try{await this.beforeStateQueue.runMiddleware(i)}catch(o){i=s,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(o))}return i?this.reloadAndSetCurrentUserOrClear(i):this.directlySetCurrentUser(null)}return U(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===i._redirectEventId?this.directlySetCurrentUser(i):this.reloadAndSetCurrentUserOrClear(i)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await Vr(e)}catch(t){if((t==null?void 0:t.code)!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=eT()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(Ht(this.app))return Promise.reject(vn(this));const t=e?le(e):null;return t&&U(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&U(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return Ht(this.app)?Promise.reject(vn(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return Ht(this.app)?Promise.reject(vn(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(St(e))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await pT(this),t=new gT(e);this.tenantId===null?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t}_getPersistence(){return this.assertedPersistence.persistence.type}_updateErrorMap(e){this._errorFactory=new an("auth","Firebase",e())}onAuthStateChanged(e,t,s){return this.registerStateListener(this.authStateSubscription,e,t,s)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,s){return this.registerStateListener(this.idTokenSubscription,e,t,s)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{const s=this.onAuthStateChanged(()=>{s(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){const t=await this.currentUser.getIdToken(),s={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:t};this.tenantId!=null&&(s.tenantId=this.tenantId),await uT(this,s)}}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:(e=this._currentUser)===null||e===void 0?void 0:e.toJSON()}}async _setRedirectUser(e,t){const s=await this.getOrInitRedirectPersistenceManager(t);return e===null?s.removeCurrentUser():s.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&St(e)||this._popupRedirectResolver;U(t,this,"argument-error"),this.redirectPersistenceManager=await Qn.create(this,[St(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var t,s;return this._isInitialized&&await this.queue(async()=>{}),((t=this._currentUser)===null||t===void 0?void 0:t._redirectEventId)===e?this._currentUser:((s=this.redirectUser)===null||s===void 0?void 0:s._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var e,t;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const s=(t=(e=this.currentUser)===null||e===void 0?void 0:e.uid)!==null&&t!==void 0?t:null;this.lastNotifiedUid!==s&&(this.lastNotifiedUid=s,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,s,i){if(this._deleted)return()=>{};const r=typeof t=="function"?t:t.next.bind(t);let o=!1;const l=this._isInitialized?Promise.resolve():this._initializationPromise;if(U(l,this,"internal-error"),l.then(()=>{o||r(this.currentUser)}),typeof t=="function"){const c=e.addObserver(t,s,i);return()=>{o=!0,c()}}else{const c=e.addObserver(t);return()=>{o=!0,c()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return U(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=cp(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var e;const t={"X-Client-Version":this.clientVersion};this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId);const s=await((e=this.heartbeatServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getHeartbeatsHeader());s&&(t["X-Firebase-Client"]=s);const i=await this._getAppCheckToken();return i&&(t["X-Firebase-AppCheck"]=i),t}async _getAppCheckToken(){var e;const t=await((e=this.appCheckServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getToken());return t!=null&&t.error&&XE(`Error while retrieving App Check token: ${t.error}`),t==null?void 0:t.token}}function Dl(n){return le(n)}class gh{constructor(e){this.auth=e,this.observer=null,this.addObserver=Iy(t=>this.observer=t)}get next(){return U(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}/**
1277 * @license
1278 * Copyright 2020 Google LLC
1279 *
1280 * Licensed under the Apache License, Version 2.0 (the "License");
1281 * you may not use this file except in compliance with the License.
1282 * You may obtain a copy of the License at
1283 *
1284 *   http://www.apache.org/licenses/LICENSE-2.0
1285 *
1286 * Unless required by applicable law or agreed to in writing, software
1287 * distributed under the License is distributed on an "AS IS" BASIS,
1288 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1289 * See the License for the specific language governing permissions and
1290 * limitations under the License.
1291 */let Ol={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function yT(n){Ol=n}function vT(n){return Ol.loadJS(n)}function ET(){return Ol.gapiScript}function TT(n){return`__${n}${Math.floor(Math.random()*1e6)}`}/**
1292 * @license
1293 * Copyright 2020 Google LLC
1294 *
1295 * Licensed under the Apache License, Version 2.0 (the "License");
1296 * you may not use this file except in compliance with the License.
1297 * You may obtain a copy of the License at
1298 *
1299 *   http://www.apache.org/licenses/LICENSE-2.0
1300 *
1301 * Unless required by applicable law or agreed to in writing, software
1302 * distributed under the License is distributed on an "AS IS" BASIS,
1303 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1304 * See the License for the specific language governing permissions and
1305 * limitations under the License.
1306 */function up(n,e){const t=gt(n,"auth");if(t.isInitialized()){const i=t.getImmediate(),r=t.getOptions();if(di(r,e??{}))return i;Dt(i,"already-initialized")}return t.initialize({options:e})}function IT(n,e){const t=(e==null?void 0:e.persistence)||[],s=(Array.isArray(t)?t:[t]).map(St);e!=null&&e.errorMap&&n._updateErrorMap(e.errorMap),n._initializeWithPersistence(s,e==null?void 0:e.popupRedirectResolver)}function hp(n,e,t){const s=Dl(n);U(s._canInitEmulator,s,"emulator-config-failed"),U(/^https?:\/\//.test(e),s,"invalid-emulator-scheme");const i=!1,r=dp(e),{host:o,port:l}=wT(e),c=l===null?"":`:${l}`;s.config.emulator={url:`${r}//${o}${c}/`},s.settings.appVerificationDisabledForTesting=!0,s.emulatorConfig=Object.freeze({host:o,port:l,protocol:r.replace(":",""),options:Object.freeze({disableWarnings:i})}),CT()}function dp(n){const e=n.indexOf(":");return e<0?"":n.substr(0,e+1)}function wT(n){const e=dp(n),t=/(\/\/)?([^?#/]+)/.exec(n.substr(e.length));if(!t)return{host:"",port:null};const s=t[2].split("@").pop()||"",i=/^(\[[^\]]+\])(:|$)/.exec(s);if(i){const r=i[1];return{host:r,port:mh(s.substr(r.length+1))}}else{const[r,o]=s.split(":");return{host:r,port:mh(o)}}}function mh(n){if(!n)return null;const e=Number(n);return isNaN(e)?null:e}function CT(){function n(){const e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}typeof console<"u"&&typeof console.info=="function"&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only.  Do not use with production credentials."),typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?window.addEventListener("DOMContentLoaded",n):n())}/**
1307 * @license
1308 * Copyright 2020 Google LLC
1309 *
1310 * Licensed under the Apache License, Version 2.0 (the "License");
1311 * you may not use this file except in compliance with the License.
1312 * You may obtain a copy of the License at
1313 *
1314 *   http://www.apache.org/licenses/LICENSE-2.0
1315 *
1316 * Unless required by applicable law or agreed to in writing, software
1317 * distributed under the License is distributed on an "AS IS" BASIS,
1318 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1319 * See the License for the specific language governing permissions and
1320 * limitations under the License.
1321 */class xl{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return At("not implemented")}_getIdTokenResponse(e){return At("not implemented")}_linkToIdToken(e,t){return At("not implemented")}_getReauthenticationResolver(e){return At("not implemented")}}/**
1322 * @license
1323 * Copyright 2020 Google LLC
1324 *
1325 * Licensed under the Apache License, Version 2.0 (the "License");
1326 * you may not use this file except in compliance with the License.
1327 * You may obtain a copy of the License at
1328 *
1329 *   http://www.apache.org/licenses/LICENSE-2.0
1330 *
1331 * Unless required by applicable law or agreed to in writing, software
1332 * distributed under the License is distributed on an "AS IS" BASIS,
1333 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1334 * See the License for the specific language governing permissions and
1335 * limitations under the License.
1336 */async function Yn(n,e){return sT(n,"POST","/v1/accounts:signInWithIdp",Pl(n,e))}/**
1337 * @license
1338 * Copyright 2020 Google LLC
1339 *
1340 * Licensed under the Apache License, Version 2.0 (the "License");
1341 * you may not use this file except in compliance with the License.
1342 * You may obtain a copy of the License at
1343 *
1344 *   http://www.apache.org/licenses/LICENSE-2.0
1345 *
1346 * Unless required by applicable law or agreed to in writing, software
1347 * distributed under the License is distributed on an "AS IS" BASIS,
1348 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1349 * See the License for the specific language governing permissions and
1350 * limitations under the License.
1351 */const AT="http://localhost";class Zt extends xl{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new Zt(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):Dt("argument-error"),t}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,n
1351once:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e,{providerId:s,signInMethod:i}=t,r=yl(t,["providerId","signInMethod"]);if(!s||!i)return null;const o=new Zt(s,i);return o.idToken=r.idToken||void 0,o.accessToken=r.accessToken||void 0,o.secret=r.secret,o.nonce=r.nonce,o.pendingToken=r.pendingToken||null,o}_getIdTokenResponse(e){const t=this.buildRequest();return Yn(e,t)}_linkToIdToken(e,t){const s=this.buildRequest();return s.idToken=t,Yn(e,s)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,Yn(e,t)}buildRequest(){const e={requestUri:AT,returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=ms(t)}return e}}/**
1352 * @license
1353 * Copyright 2020 Google LLC
1354 *
1355 * Licensed under the Apache License, Version 2.0 (the "License");
1356 * you may not use this file except in compliance with the License.
1357 * You may obtain a copy of the License at
1358 *
1359 *   http://www.apache.org/licenses/LICENSE-2.0
1360 *
1361 * Unless required by applicable law or agreed to in writing, software
1362 * distributed under the License is distributed on an "AS IS" BASIS,
1363 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1364 * See the License for the specific language governing permissions and
1365 * limitations under the License.
1366 */class fp{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}/**
1367 * @license
1368 * Copyright 2019 Google LLC
1369 *
1370 * Licensed under the Apache License, Version 2.0 (the "License");
1371 * you may not use this file except in compliance with the License.
1372 * You may obtain a copy of the License at
1373 *
1374 *   http://www.apache.org/licenses/LICENSE-2.0
1375 *
1376 * Unless required by applicable law or agreed to in writing, software
1377 * distributed under the License is distributed on an "AS IS" BASIS,
1378 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1379 * See the License for the specific language governing permissions and
1380 * limitations under the License.
1381 */class ki extends fp{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}/**
1382 * @license
1383 * Copyright 2020 Google LLC
1384 *
1385 * Licensed under the Apache License, Version 2.0 (the "License");
1386 * you may not use this file except in compliance with the License.
1387 * You may obtain a copy of the License at
1388 *
1389 *   http://www.apache.org/licenses/LICENSE-2.0
1390 *
1391 * Unless required by applicable law or agreed to in writing, software
1392 * distributed under the License is distributed on an "AS IS" BASIS,
1393 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1394 * See the License for the specific language governing permissions and
1395 * limitations under the License.
1396 */class Tt extends ki{constructor(){super("facebook.com")}static credential(e){return Zt._fromParams({providerId:Tt.PROVIDER_ID,signInMethod:Tt.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Tt.credentialFromTaggedObject(e)}static credentialFromError(e){return Tt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Tt.credential(e.oauthAccessToken)}catch{return null}}}Tt.FACEBOOK_SIGN_IN_METHOD="facebook.com";Tt.PROVIDER_ID="facebook.com";/**
1397 * @license
1398 * Copyright 2020 Google LLC
1399 *
1400 * Licensed under the Apache License, Version 2.0 (the "License");
1401 * you may not use this file except in compliance with the License.
1402 * You may obtain a copy of the License at
1403 *
1404 *   http://www.apache.org/licenses/LICENSE-2.0
1405 *
1406 * Unless required by applicable law or agreed to in writing, softw
1406are
1407 * distributed under the License is distributed on an "AS IS" BASIS,
1408 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1409 * See the License for the specific language governing permissions and
1410 * limitations under the License.
1411 */class It extends ki{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return Zt._fromParams({providerId:It.PROVIDER_ID,signInMethod:It.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return It.credentialFromTaggedObject(e)}static credentialFromError(e){return It.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:s}=e;if(!t&&!s)return null;try{return It.credential(t,s)}catch{return null}}}It.GOOGLE_SIGN_IN_METHOD="google.com";It.PROVIDER_ID="google.com";/**
1412 * @license
1413 * Copyright 2020 Google LLC
1414 *
1415 * Licensed under the Apache License, Version 2.0 (the "License");
1416 * you may not use this file except in compliance with the License.
1417 * You may obtain a copy of the License at
1418 *
1419 *   http://www.apache.org/licenses/LICENSE-2.0
1420 *
1421 * Unless required by applicable law or agreed to in writing, software
1422 * distributed under the License is distributed on an "AS IS" BASIS,
1423 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1424 * See the License for the specific language governing permissions and
1425 * limitations under the License.
1426 */class wt extends ki{constructor(){super("github.com")}static credential(e){return Zt._fromParams({providerId:wt.PROVIDER_ID,signInMethod:wt.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return wt.credentialFromTaggedObject(e)}static credentialFromError(e){return wt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return wt.credential(e.oauthAccessToken)}catch{return null}}}wt.GITHUB_SIGN_IN_METHOD="github.com";wt.PROVIDER_ID="github.com";/**
1427 * @license
1428 * Copyright 2020 Google LLC
1429 *
1430 * Licensed under the Apache License, Version 2.0 (the "License");
1431 * you may not use this file except in compliance with the License.
1432 * You may obtain a copy of the License at
1433 *
1434 *   http://www.apache.org/licenses/LICENSE-2.0
1435 *
1436 * Unless required by applicable law or agreed to in writing, software
1437 * distributed under the License is distributed on an "AS IS" BASIS,
1438 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1439 * See the License for the specific language governing permissions and
1440 * limitations under the License.
1441 */class Ct extends ki{constructor(){super("twitter.com")}static credential(e,t){return Zt._fromParams({providerId:Ct.PROVIDER_ID,signInMethod:Ct.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return Ct.credentialFromTaggedObject(e)}static credentialFromError(e){return Ct.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:s}=e;if(!t||!s)return null;try{return Ct.credential(t,s)}catch{return null}}}Ct.TWITTER_SIGN_IN_METHOD="twitter.com";Ct.PROVIDER_ID="twitter.com";/**
1442 * @license
1443 * Copyright 2020 Google LLC
1444 *
1445 * Licensed under the Apache License, Version 2.0 (the "License");
1446 * you may not use this file except in compliance with the License.
1447 * You may obtain a copy of the License at
1448 *
1449 *   http://www.apache.org/licenses/LICENSE-2.0
1450 *
1451 * Unless required by applicable law or agreed to in writing, software
1452 * distributed under the License is distributed on an "AS IS" BASIS,
1453 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1454 * See the License for the specific language governing permissions and
1455 * limitations under the License.
1456 */class rs{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,s,i=!1){const r=await Rt._fromIdTokenResponse(e,s,i),o=yh(s);return new rs({user:r,providerId:o,_tokenResponse:s,operationType:t})}static async _forOperation(e,t,s){await e._updateTokensIfNecessary(s,!0);const i=yh(s);return new rs({user:e,providerId:i,_tokenResponse:s,operationType:t})}}function yh(n){return n.providerId?n.providerId:"phoneNumber"in n?"phone":null}/**
1457 * @license
1458 * Copyright 2020 Google LLC
1459 *
1460 * Licensed under the Apache License, Version 2.0 (the "License");
1461 * you may not use this file except in compliance with the License.
1462 * You may obtain a copy of the License at
1463 *
1464 *   http://www.apache.org/licenses/LICENSE-2.0
1465 *
1466 * Unless required by applicable law or agreed to in writing, software
1467 * distributed under the License is distributed on an "AS IS" BASIS,
1468 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1469 * See the License for the specific language governing permissions and
1470 * limitations under the License.
1471 */class Fr extends tt{constructor(e,t,s,i){var r;super(t.code,t.message),this.operationType=s,this.user=i,Object.setPrototypeOf(this,Fr.prototype),this.customData={appName:e.name,tenantId:(r=e.tenantId)!==null&&r!==void 0?r:void 0,_serverResponse:t.customData._serverResponse,operationType:s}}static _fromErrorAndOperation(e,t,s,i){return new Fr(e,t,s,i)}}function pp(n,e,t,s){return(e==="reauthenticate"?t._getReauthenticationResolver(n):t._getIdTokenResponse(n)).catch(r=>{throw r.code==="auth/multi-factor-auth-required"?Fr._fromErrorAndOperation(n,r,e,s):r})}async function RT(n,e,t=!1){const s=await is(n,e._linkToIdToken(n.auth,await n.getIdToken()),t);return rs._forOperation(n,"link",s)}/**
1472 * @license
1473 * Copyright 2019 Google LLC
1474 *
1475 * Licensed under the Apache License, Version 2.0 (the "License");
1476 * you may not use this file except in compliance with the License.
1477 * You may obtain a copy of the License at
1478 *
1479 *   http://www.apache.org/licenses/LICENSE-2.0
1480 *
1481 * Unless required by applicable law or agreed to in writing, software
1482 * distributed under the License is distributed on an "AS IS" BASIS,
1483 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1484 * See the License for the specific language governing permissions and
1485 * limitations under the License.
1486 */async function ST(n,e,t=!1){const{auth:s}=n;if(Ht(s.app))return Promise.reject(vn(s));const i="reauthenticate";try{const r=await is(n,pp(s,i,e,n),t);U(r.idToken,s,"internal-error");const o=kl(r.idToken);U(o,s,"internal-error");const{sub:l}=o;return U(n.uid===l,s,"user-mismatch"),rs._forOperation(n,i,r)}catch(r){throw(r==null?void 0:r.code)==="auth/user-not-found"&&Dt(s,"user-mismatch"),r}}/**
1487 * @license
1488 * Copyright 2020 Google LLC
1489 *
1490 * Licensed under the Apache License, Version 2.0 (the "License");
1491 * you may not use this file except in compliance with the License.
1492 * You may obtain a copy of the License at
1493 *
1494 *   http://www.apache.org/licenses/LICENSE-2.0
1495 *
1496 * Unless required by applicable law or agreed to in writing, software
1497 * distributed under the License is distributed on an "AS IS" BASIS,
1498 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1499 * See the License for the specific language governing permissions and
1500 * limitations under the License.
1501 */async function bT(n,e,t=!1){if(Ht(n.app))return Promise.reject(vn(n));const s="signIn",i=await pp(n,s,e),r=await rs._fromIdTokenResponse(n,s,i);return t||await n._updateCurrentUser(r.user),r}/**
1502 * @license
1503 * Copyright 2020 Google LLC
1504 *
1505 * Licensed under the Apache License, Version 2.0 (the "License");
1506 * you may not use this file except in compliance with the License.
1507 * You may obtain a copy of the License at
1508 *
1509 *   http://www.apache.org/licenses/LICENSE-2.0
1510 *
1511 * Unless required by applicable law or agreed to in writing, software
1512 * distributed under the License is distributed on an "AS IS" BASIS,
1513 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1514 * See the License for the specific language governing permissions and
1515 * limitations under the License.
1516 */async function PT(n,e){return Nn(n,"POST","/v1/accounts:update",e)}/**
1517 * @license
1518 * Copyright 2020 Google LLC
1519 *
1520 * Licensed under the Apache License, Version 2.0 (the "License");
1521 * you may not use this file except in compliance with the License.
1522 * You may obtain a copy of the License at
1523 *
1524 *   http://www.apache.org/licenses/LICENSE-2.0
1525 *
1526 * Unless required by applicable law or agreed to in writing, software
1527 * distributed under the License is distributed on an "AS IS" BASIS,
1528 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1529 * See the License for the specific language governing permissions and
1530 * limitations under the License.
1531 */async function kT(n,{displayName:e,photoURL:t}){if(e===void 0&&t===void 0)return;
1531const s=le(n),r={idToken:await s.getIdToken(),displayName:e,photoUrl:t,returnSecureToken:!0},o=await is(s,PT(s.auth,r));s.displayName=o.displayName||null,s.photoURL=o.photoUrl||null;const l=s.providerData.find(({providerId:c})=>c==="password");l&&(l.displayName=s.displayName,l.photoURL=s.photoURL),await s._updateTokensIfNecessary(o)}function _p(n,e,t,s){return le(n).onIdTokenChanged(e,t,s)}function gp(n,e,t){return le(n).beforeAuthStateChanged(e,t)}function NT(n,e,t,s){return le(n).onAuthStateChanged(e,t,s)}const Ur="__sak";/**
1532 * @license
1533 * Copyright 2019 Google LLC
1534 *
1535 * Licensed under the Apache License, Version 2.0 (the "License");
1536 * you may not use this file except in compliance with the License.
1537 * You may obtain a copy of the License at
1538 *
1539 *   http://www.apache.org/licenses/LICENSE-2.0
1540 *
1541 * Unless required by applicable law or agreed to in writing, software
1542 * distributed under the License is distributed on an "AS IS" BASIS,
1543 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1544 * See the License for the specific language governing permissions and
1545 * limitations under the License.
1546 */class mp{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Ur,"1"),this.storage.removeItem(Ur),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){const t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}/**
1547 * @license
1548 * Copyright 2020 Google LLC
1549 *
1550 * Licensed under the Apache License, Version 2.0 (the "License");
1551 * you may not use this file except in compliance with the License.
1552 * You may obtain a copy of the License at
1553 *
1554 *   http://www.apache.org/licenses/LICENSE-2.0
1555 *
1556 * Unless required by applicable law or agreed to in writing, software
1557 * distributed under the License is distributed on an "AS IS" BASIS,
1558 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1559 * See the License for the specific language governing permissions and
1560 * limitations under the License.
1561 */const DT=1e3,OT=10;class yp extends mp{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=lp(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const s=this.storage.getItem(t),i=this.localCache[t];s!==i&&e(t,i,s)}}onStorageEvent(e,t=!1){if(!e.key){this.forAllChangedKeys((o,l,c)=>{this.notifyListeners(o,c)});return}const s=e.key;t?this.detachListener():this.stopPolling();const i=()=>{const o=this.storage.getItem(s);!t&&this.localCache[s]===o||this.notifyListeners(s,o)},r=this.storage.getItem(s);dT()&&r!==e.newValue&&e.newValue!==e.oldValue?setTimeout(i,OT):i()}notifyListeners(e,t){this.localCache[e]=t;const s=this.listeners[e];if(s)for(const i of Array.from(s))i(t&&JSON.parse(t))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,s)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:s}),!0)})},DT)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Ob
1561ject.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){const t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}yp.type="LOCAL";const vp=yp;/**
1562 * @license
1563 * Copyright 2020 Google LLC
1564 *
1565 * Licensed under the Apache License, Version 2.0 (the "License");
1566 * you may not use this file except in compliance with the License.
1567 * You may obtain a copy of the License at
1568 *
1569 *   http://www.apache.org/licenses/LICENSE-2.0
1570 *
1571 * Unless required by applicable law or agreed to in writing, software
1572 * distributed under the License is distributed on an "AS IS" BASIS,
1573 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1574 * See the License for the specific language governing permissions and
1575 * limitations under the License.
1576 */class Ep extends mp{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}Ep.type="SESSION";const Ml=Ep;/**
1577 * @license
1578 * Copyright 2019 Google LLC
1579 *
1580 * Licensed under the Apache License, Version 2.0 (the "License");
1581 * you may not use this file except in compliance with the License.
1582 * You may obtain a copy of the License at
1583 *
1584 *   http://www.apache.org/licenses/LICENSE-2.0
1585 *
1586 * Unless required by applicable law or agreed to in writing, software
1587 * distributed under the License is distributed on an "AS IS" BASIS,
1588 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1589 * See the License for the specific language governing permissions and
1590 * limitations under the License.
1591 */function xT(n){return Promise.all(n.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(t){return{fulfilled:!1,reason:t}}}))}/**
1592 * @license
1593 * Copyright 2019 Google LLC
1594 *
1595 * Licensed under the Apache License, Version 2.0 (the "License");
1596 * you may not use this file except in compliance with the License.
1597 * You may obtain a copy of the License at
1598 *
1599 *   http://www.apache.org/licenses/LICENSE-2.0
1600 *
1601 * Unless required by applicable law or agreed to in writing, software
1602 * distributed under the License is distributed on an "AS IS" BASIS,
1603 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1604 * See the License for the specific language governing permissions and
1605 * limitations under the License.
1606 */class go{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const t=this.receivers.find(i=>i.isListeningto(e));if(t)return t;const s=new go(e);return this.receivers.push(s),s}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:s,eventType:i,data:r}=t.data,o=this.handlersMap[i];if(!(o!=null&&o.size))return;t.ports[0].postMessage({status:"ack",eventId:s,eventType:i});const l=Array.from(o).map(async h=>h(t.origin,r)),c=await xT(l);t.ports[0].postMessage({status:"done",eventId:s,eventType:i,response:c})}_subscribe(e,t){Object.keys(this.handlersMap).length===0&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}_unsubscribe(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),(!t||this.handlersMap[e].size===0)&&delete this.handlersMap[e],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}go.receivers=[];/**
1607 * @license
1608 * Copyright 2020 Google LLC
1609 *
1610 * Licensed under the Apache License, Version 2.0 (the "License");
1611 * you may not use this file except in compliance with the License.
1612 * You may obtain a copy of the License at
1613 *
1614 *   http://www.apache.org/licenses/LICENSE-2.0
1615 *
1616 * Unless required by applicable law or agreed to in writing, software
1617 * distributed under the License is distributed on an "AS IS" BASIS,
1618 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1619 * See the License for the specific language governing permissions and
1620 * limitations under the License.
1621 */function Ll(n="",e=10){let t="";for(let s=0;s<e;s++)t+=Math.floor(Math.random()*10);return n+t}/**
1622 * @license
1623 * Copyright 2019 Google LLC
1624 *
1625 * Licensed under the Apache License, Version 2.0 (the "License");
1626 * you may not use this file except in compliance with the License.
1627 * You may obtain a copy of the License at
1628 *
1629 *   http://www.apache.org/licenses/LICENSE-2.0
1630 *
1631 * Unless required by applicable law or agreed to in writing, software
1632 * distributed under the License is distributed on an "AS IS" BASIS,
1633 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1634 * See the License for the specific language governing permissions and
1635 * limitations under the License.
1636 */class MT{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,s=50){const i=typeof MessageChannel<"u"?new MessageChannel:null;if(!i)throw new Error("connection_unavailable");let r,o;return new Promise((l,c)=>{const h=Ll("",20);i.port1.start();const f=setTimeout(()=>{c(new Error("unsupported_event"))},s);o={messageChannel:i,onMessage(p){const g=p;if(g.data.eventId===h)switch(g.data.status){case"ack":clearTimeout(f),r=setTimeout(()=>{c(new Error("timeout"))},3e3);break;case"done":clearTimeout(r),l(g.data.response);break;default:clearTimeout(f),clearTimeout(r),c(new Error("invalid_response"));break}}},this.handlers.add(o),i.port1.addEventListener("message",o.onMessage),this.target.postMessage({eventType:e,eventId:h,data:t},[i.port2])}).finally(()=>{o&&this.removeMessageHandler(o)})}}/**
1637 * @license
1638 * Copyright 2020 Google LLC
1639 *
1640 * Licensed under the Apache License, Version 2.0 (the "License");
1641 * you may not use this file except in compliance with the License.
1642 * You may obtain a copy of the License at
1643 *
1644 *   http://www.apache.org/licenses/LICENSE-2.0
1645 *
1646 * Unless required by applicable law or agreed to in writing, software
1647 * distributed under the License is distributed on an "AS IS" BASIS,
1648 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1649 * See the License for the specific language governing permissions and
1650 * limitations under the License.
1651 */function dt(){return window}function LT(n){dt().location.href=n}/**
1652 * @license
1653 * Copyright 2020 Google LLC.
1654 *
1655 * Licensed under the Apache License, Version 2.0 (the "License");
1656 * you may not use this file except in compliance with the License.
1657 * You may obtain a copy of the License at
1658 *
1659 *   http://www.apache.org/licenses/LICENSE-2.0
1660 *
1661 * Unless required by applicable law or agreed to in writing, software
1662 * distributed under the License is distributed on an "AS IS" BASIS,
1663 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1664 * See the License for the specific language governing permissions and
1665 * limitations under the License.
1666 */function Tp(){return typeof dt().WorkerGlobalScope<"u"&&typeof dt().importScripts=="function"}async function VT(){if(!(navigator!=null&&navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function FT(){var n;return((n=navigator==null?void 0:navigator.serviceWorker)===null||n===void 0?void 0:n.controller)||null}function UT(){return Tp()?self:null}/**
1667 * @license
1668 * Copyright 2019 Google LLC
1669 *
1670 * Licensed under the Apache License, Version 2.0 (the "License");
1671 * you may not use this file except in compliance with the License.
1672 * You may obtain a copy of the License at
1673 *
1674 *   http://www.apache.org/licenses/LICENSE-2.0
1675 *
1676 * Unless required by applicable law or agreed to in writing, software
1677 * distributed under the License is distributed on an "AS IS" BASIS,
1678 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1679 * See the License for the specific language governing permissions and
1680 * limitations under the License.
1681 */const Ip="firebaseLocalStorageDb",BT=1,Br="firebaseLocalStorage",wp="fbase_key";class Ni{constructor(e){this.request=e}toPromise(){return new Promise((e,t)=>{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{t(this.request.error)})})}}function mo(n,e){return n.transaction([Br],e?"readwrite":"readonly").objectStore(Br)}function qT(){const n=indexedDB.deleteDatabase(Ip);return new Ni(n).toPromise()}function $a(){const n=indexedDB.open(Ip,BT);return new Promise((e,t)=>
1681{n.addEventListener("error",()=>{t(n.error)}),n.addEventListener("upgradeneeded",()=>{const s=n.result;try{s.createObjectStore(Br,{keyPath:wp})}catch(i){t(i)}}),n.addEventListener("success",async()=>{const s=n.result;s.objectStoreNames.contains(Br)?e(s):(s.close(),await qT(),e(await $a()))})})}async function vh(n,e,t){const s=mo(n,!0).put({[wp]:e,value:t});return new Ni(s).toPromise()}async function $T(n,e){const t=mo(n,!1).get(e),s=await new Ni(t).toPromise();return s===void 0?null:s.value}function Eh(n,e){const t=mo(n,!0).delete(e);return new Ni(t).toPromise()}const jT=800,HT=3;class Cp{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db?this.db:(this.db=await $a(),this.db)}async _withRetries(e){let t=0;for(;;)try{const s=await this._openDb();return await e(s)}catch(s){if(t++>HT)throw s;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return Tp()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=go._getInstance(UT()),this.receiver._subscribe("keyChanged",async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){var e,t;if(this.activeServiceWorker=await VT(),!this.activeServiceWorker)return;this.sender=new MT(this.activeServiceWorker);const s=await this.sender._send("ping",{},800);s&&!((e=s[0])===null||e===void 0)&&e.fulfilled&&!((t=s[0])===null||t===void 0)&&t.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||FT()!==this.activeServiceWorker))try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{if(!indexedDB)return!1;const e=await $a();return await vh(e,Ur,"1"),await Eh(e,Ur),!0}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(s=>vh(s,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){const t=await this._withRetries(s=>$T(s,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>Eh(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(i=>{const r=mo(i,!1).getAll();return new Ni(r).toPromise()});if(!e)return[];if(this.pendingWrites!==0)return[];const t=[],s=new Set;if(e.length!==0)for(const{fbase_key:i,value:r}of e)s.add(i),JSON.stringify(this.localCache[i])!==JSON.stringify(r)&&(this.notifyListeners(i,r),t.push(i));for(const i of Object.keys(this.localCache))this.localCache[i]&&!s.has(i)&&(this.notifyListeners(i,null),t.push(i));return t}notifyListeners(e,t){this.localCache[e]=t;const s=this.listeners[e];if(s)for(const i of Array.from(s))i(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),jT)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){Object.keys(this.listeners).length===0&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Ob
1681ject.keys(this.listeners).length===0&&this.stopPolling()}}Cp.type="LOCAL";const Ap=Cp;new Pi(3e4,6e4);/**
1682 * @license
1683 * Copyright 2021 Google LLC
1684 *
1685 * Licensed under the Apache License, Version 2.0 (the "License");
1686 * you may not use this file except in compliance with the License.
1687 * You may obtain a copy of the License at
1688 *
1689 *   http://www.apache.org/licenses/LICENSE-2.0
1690 *
1691 * Unless required by applicable law or agreed to in writing, software
1692 * distributed under the License is distributed on an "AS IS" BASIS,
1693 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1694 * See the License for the specific language governing permissions and
1695 * limitations under the License.
1696 */function WT(n,e){return e?St(e):(U(n._popupRedirectResolver,n,"argument-error"),n._popupRedirectResolver)}/**
1697 * @license
1698 * Copyright 2019 Google LLC
1699 *
1700 * Licensed under the Apache License, Version 2.0 (the "License");
1701 * you may not use this file except in compliance with the License.
1702 * You may obtain a copy of the License at
1703 *
1704 *   http://www.apache.org/licenses/LICENSE-2.0
1705 *
1706 * Unless required by applicable law or agreed to in writing, software
1707 * distributed under the License is distributed on an "AS IS" BASIS,
1708 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1709 * See the License for the specific language governing permissions and
1710 * limitations under the License.
1711 */class Vl extends xl{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return Yn(e,this._buildIdpRequest())}_linkToIdToken(e,t){return Yn(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return Yn(e,this._buildIdpRequest())}_buildIdpRequest(e){const t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function zT(n){return bT(n.auth,new Vl(n),n.bypassAuthState)}function GT(n){const{auth:e,user:t}=n;return U(t,e,"internal-error"),ST(t,new Vl(n),n.bypassAuthState)}async function KT(n){const{auth:e,user:t}=n;return U(t,e,"internal-error"),RT(t,new Vl(n),n.bypassAuthState)}/**
1712 * @license
1713 * Copyright 2020 Google LLC
1714 *
1715 * Licensed under the Apache License, Version 2.0 (the "License");
1716 * you may not use this file except in compliance with the License.
1717 * You may obtain a copy of the License at
1718 *
1719 *   http://www.apache.org/licenses/LICENSE-2.0
1720 *
1721 * Unless required by applicable law or agreed to in writing, software
1722 * distributed under the License is distributed on an "AS IS" BASIS,
1723 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1724 * See the License for the specific language governing permissions and
1725 * limitations under the License.
1726 */class Rp{constructor(e,t,s,i,r=!1){this.auth=e,this.resolver=s,this.user=i,this.bypassAuthState=r,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(s){this.reject(s)}})}async onAuthEvent(e){const{urlResponse:t,sessionId:s,postBody:i,tenantId:r,error:o,type:l}=e;if(o){this.reject(o);return}const c={auth:this.auth,requestUri:t,sessionId:s,tenantId:r||void 0,postBody:i||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(l)(c))}catch(h){this.reject(h)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return zT;case"linkViaPopup":case"linkViaRedirect":return KT;case"reauthViaPopup":case"reauthViaRedirect":return GT;default:Dt(this.auth,"internal-error")}}resolve(e){Ot(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){Ot(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}/**
1727 * @license
1728 * Copyright 2020 Google LLC
1729 *
1730 * Licensed under the Apache License, Version 2.0 (the "License");
1731 * you may not use this file except in compliance with the License.
1732 * You may obtain a copy of the License at
1733 *
1734 *   http://www.apache.org/licenses/LICENSE-2.0
1735 *
1736 * Unless required by applicable law or agreed to in writing, software
1737 * distributed under the License is distributed on an "AS IS" BASIS,
1738 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1739 * See the License for the specific language governing permissions and
1740 * limitations under the License.
1741 */const QT=new Pi(2e3,1e4);class Hn extends Rp{constructor(e,t,s,i,r){super(e,t,i,r),this.provider=s,this.authWindow=null,this.pollId=null,Hn.currentPopupAction&&Hn.currentPopupAction.cancel(),Hn.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return U(e,this.auth,"internal-error"),e}async onExecution(){Ot(this.filter.length===1,"Popup operations only handle one event");const e=Ll();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(t=>{this.reject(t)}),this.resolver._isIframeWebStorageSupported(this.auth,t=>{t||this.reject(ht(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return((e=this.authWindow)===null||e===void 0?void 0:e.associatedEvent)||null}cancel(){this.reject(ht(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,Hn.currentPopupAction=null}pollUserCancellation(){const e=()=>{var t,s;if(!((s=(t=this.authWindow)===null||t===void 0?void 0:t.window)===null||s===void 0)&&s.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(ht(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,QT.get())};e()}}Hn.currentPopupAction=null;/**
1742 * @license
1743 * Copyright 2020 Google LLC
1744 *
1745 * Licensed under the Apache License, Version 2.0 (the "License");
1746 * you may not use this file except in compliance with the License.
1747 * You may obtain a copy of the License at
1748 *
1749 *   http://www.apache.org/licenses/LICENSE-2.0
1750 *
1751 * Unless required by applicable law or agreed to in writing, software
1752 * distributed under the License is distributed on an "AS IS" BASIS,
1753 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1754 * See the License for the specific language governing permissions and
1755 * limitations under the License.
1756 */const YT="pendingRedirect",wr=new Map;class XT extends Rp{constructor(e,t,s=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,s),this.eventId=null}async execute(){let e=wr.get(this.auth._key());if(!e){try{const s=await JT(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(s)}catch(t){e=()=>Promise.reject(t)}wr.set(this.auth._key(),e)}return this.bypassAuthState||wr.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if(e.type==="signInViaRedirect")return super.onAuthEvent(e);if(e.type==="unknown"){this.resolve(null);return}if(e.eventId){const t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function JT(n,e){const t=tI(e),s=eI(n);if(!await s._isAvailable())return!1;const i=await s._get(t)==="true";return await s._remove(t),i}function ZT(n,e){wr.set(n._key(),e)}function eI(n){return St(n._redirectPersistence)}function tI(n){return Ir(YT,n.config.apiKey,n.name)}async function nI(n,e,t=!1){if(Ht(n.app))return Promise.reject(vn(n));const s=Dl(n),i=WT(s,e),o=await new XT(s,i,t).execute();return o&&!t&&(delete o.user._redirectEventId,await s._persistUserIfCurrent(o.user),await s._setRedirectUser(null,e)),o}/**
1757 * @license
1758 * Copyright 2020 Google LLC
1759 *
1760 * Licensed under the Apache License, Version 2.0 (the "License");
1761 * you may not use this file except in compliance with the License.
1762 * You may obtain a copy of the License at
1763 *
1764 *   http://www.apache.org/licenses/LICENSE-2.0
1765 *
1766 * Unless required by applicable law or agreed to in writing, softw
1766are
1767 * distributed under the License is distributed on an "AS IS" BASIS,
1768 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1769 * See the License for the specific language governing permissions and
1770 * limitations under the License.
1771 */const sI=10*60*1e3;class iI{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach(s=>{this.isEventForConsumer(e,s)&&(t=!0,this.sendToConsumer(e,s),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!rI(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){var s;if(e.error&&!Sp(e)){const i=((s=e.error.code)===null||s===void 0?void 0:s.split("auth/")[1])||"internal-error";t.onError(ht(this.auth,i))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const s=t.eventId===null||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&s}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=sI&&this.cachedEventUids.clear(),this.cachedEventUids.has(Th(e))}saveEventToCache(e){this.cachedEventUids.add(Th(e)),this.lastProcessedEventTime=Date.now()}}function Th(n){return[n.type,n.eventId,n.sessionId,n.tenantId].filter(e=>e).join("-")}function Sp({type:n,error:e}){return n==="unknown"&&(e==null?void 0:e.code)==="auth/no-auth-event"}function rI(n){switch(n.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return Sp(n);default:return!1}}/**
1772 * @license
1773 * Copyright 2020 Google LLC
1774 *
1775 * Licensed under the Apache License, Version 2.0 (the "License");
1776 * you may not use this file except in compliance with the License.
1777 * You may obtain a copy of the License at
1778 *
1779 *   http://www.apache.org/licenses/LICENSE-2.0
1780 *
1781 * Unless required by applicable law or agreed to in writing, software
1782 * distributed under the License is distributed on an "AS IS" BASIS,
1783 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1784 * See the License for the specific language governing permissions and
1785 * limitations under the License.
1786 */async function oI(n,e={}){return Nn(n,"GET","/v1/projects",e)}/**
1787 * @license
1788 * Copyright 2020 Google LLC
1789 *
1790 * Licensed under the Apache License, Version 2.0 (the "License");
1791 * you may not use this file except in compliance with the License.
1792 * You may obtain a copy of the License at
1793 *
1794 *   http://www.apache.org/licenses/LICENSE-2.0
1795 *
1796 * Unless required by applicable law or agreed to in writing, software
1797 * distributed under the License is distributed on an "AS IS" BASIS,
1798 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1799 * See the License for the specific language governing permissions and
1800 * limitations under the License.
1801 */const aI=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,lI=/^https?/;async function cI(n){if(n.config.emulator)return;const{authorizedDomains:e}=await oI(n);for(const t of e)try{if(uI(t))return}catch{}Dt(n,"unauthorized-domain")}function uI(n){const e=Ua(),{protocol:t,hostname:s}=new URL(e);if(n.startsWith("chrome-extension://")){const o=new URL(n);return o.hostname===""&&s===""?t==="chrome-extension:"&&n.replace("chrome-extension://","")===e.replace("chrome-extension://",""):t==="chrome-extension:"&&o.hostname===s}if(!lI.test(t))return!1;if(aI.test(n))return s===n;const i=n.replace(/\./g,"\\.");return new RegExp("^(.+\\."+i+"|"+i+")$","i").test(s)}/**
1802 * @license
1803 * Copyright 2020 Google LLC.
1804 *
1805 * Licensed under the Apache License, Version 2.0 (the "License");
1806 * you may not use this file except in compliance with the License.
1807 * You may obtain a copy of the License at
1808 *
1809 *   http://www.apache.org/licenses/LICENSE-2.0
1810 *
1811 * Unless required by applicable law or agreed to in writing, softw
1811are
1812 * distributed under the License is distributed on an "AS IS" BASIS,
1813 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1814 * See the License for the specific language governing permissions and
1815 * limitations under the License.
1816 */const hI=new Pi(3e4,6e4);function Ih(){const n=dt().___jsl;if(n!=null&&n.H){for(const e of Object.keys(n.H))if(n.H[e].r=n.H[e].r||[],n.H[e].L=n.H[e].L||[],n.H[e].r=[...n.H[e].L],n.CP)for(let t=0;t<n.CP.length;t++)n.CP[t]=null}}function dI(n){return new Promise((e,t)=>{var s,i,r;function o(){Ih(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{Ih(),t(ht(n,"network-request-failed"))},timeout:hI.get()})}if(!((i=(s=dt().gapi)===null||s===void 0?void 0:s.iframes)===null||i===void 0)&&i.Iframe)e(gapi.iframes.getContext());else if(!((r=dt().gapi)===null||r===void 0)&&r.load)o();else{const l=TT("iframefcb");return dt()[l]=()=>{gapi.load?o():t(ht(n,"network-request-failed"))},vT(`${ET()}?onload=${l}`).catch(c=>t(c))}}).catch(e=>{throw Cr=null,e})}let Cr=null;function fI(n){return Cr=Cr||dI(n),Cr}/**
1817 * @license
1818 * Copyright 2020 Google LLC.
1819 *
1820 * Licensed under the Apache License, Version 2.0 (the "License");
1821 * you may not use this file except in compliance with the License.
1822 * You may obtain a copy of the License at
1823 *
1824 *   http://www.apache.org/licenses/LICENSE-2.0
1825 *
1826 * Unless required by applicable law or agreed to in writing, software
1827 * distributed under the License is distributed on an "AS IS" BASIS,
1828 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1829 * See the License for the specific language governing permissions and
1830 * limitations under the License.
1831 */const pI=new Pi(5e3,15e3),_I="__/auth/iframe",gI="emulator/auth/iframe",mI={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},yI=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function vI(n){const e=n.config;U(e.authDomain,n,"auth-domain-config-required");const t=e.emulator?bl(e,gI):`https://${n.config.authDomain}/${_I}`,s={apiKey:e.apiKey,appName:n.name,v:ln},i=yI.get(n.config.apiHost);i&&(s.eid=i);const r=n._getFrameworks();return r.length&&(s.fw=r.join(",")),`${t}?${ms(s).slice(1)}`}async function EI(n){const e=await fI(n),t=dt().gapi;return U(t,n,"internal-error"),e.open({where:document.body,url:vI(n),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:mI,dontclear:!0},s=>new Promise(async(i,r)=>{await s.restyle({setHideOnLeave:!1});const o=ht(n,"network-request-failed"),l=dt().setTimeout(()=>{r(o)},pI.get());function c(){dt().clearTimeout(l),i(s)}s.ping(c).then(c,()=>{r(o)})}))}/**
1832 * @license
1833 * Copyright 2020 Google LLC.
1834 *
1835 * Licensed under the Apache License, Version 2.0 (the "License");
1836 * you may not use this file except in compliance with the License.
1837 * You may obtain a copy of the License at
1838 *
1839 *   http://www.apache.org/licenses/LICENSE-2.0
1840 *
1841 * Unless required by applicable law or agreed to in writing, software
1842 * distributed under the License is distributed on an "AS IS" BASIS,
1843 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1844 * See the License for the specific language governing permissions and
1845 * limitations under the License.
1846 */const TI={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},II=500,wI=600,CI="_blank",AI="http://localhost";class wh{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function RI(n,e,t,s=II,i=wI){const r=Math.max((window.screen.availHeight-i)/2,0).toString(),o=Math.max((window.screen.availWidth-s)/2,0).toString();let l="";const c=Object.assign(Object.assign({},TI),{width:s.toString(),height:i.toString(),top:r,left:o}),h=Fe().toLowerCase();t&&(l=sp(h)?CI:t),tp(h)&&(e=e||AI,c.scrollbars="yes");const f=Object.entries(c).reduce((g,[I,S])=>`${g}${I}=${S},`,"");if(hT(h)&&l!=="_self")return SI(e||"",l),new wh(null);const p=window.open(e||"",l,f);U(p,n,"popup-blocked");try{p.focus()}catch{}return new wh(p)}function SI(n,e){const t=document.createElement("a");t.href=n,t.target=e;const s=document.createEvent("MouseEvent");
1846s.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),t.dispatchEvent(s)}/**
1847 * @license
1848 * Copyright 2021 Google LLC
1849 *
1850 * Licensed under the Apache License, Version 2.0 (the "License");
1851 * you may not use this file except in compliance with the License.
1852 * You may obtain a copy of the License at
1853 *
1854 *   http://www.apache.org/licenses/LICENSE-2.0
1855 *
1856 * Unless required by applicable law or agreed to in writing, software
1857 * distributed under the License is distributed on an "AS IS" BASIS,
1858 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1859 * See the License for the specific language governing permissions and
1860 * limitations under the License.
1861 */const bI="__/auth/handler",PI="emulator/auth/handler",kI=encodeURIComponent("fac");async function Ch(n,e,t,s,i,r){U(n.config.authDomain,n,"auth-domain-config-required"),U(n.config.apiKey,n,"invalid-api-key");const o={apiKey:n.config.apiKey,appName:n.name,authType:t,redirectUrl:s,v:ln,eventId:i};if(e instanceof fp){e.setDefaultLanguage(n.languageCode),o.providerId=e.providerId||"",Oa(e.getCustomParameters())||(o.customParameters=JSON.stringify(e.getCustomParameters()));for(const[f,p]of Object.entries({}))o[f]=p}if(e instanceof ki){const f=e.getScopes().filter(p=>p!=="");f.length>0&&(o.scopes=f.join(","))}n.tenantId&&(o.tid=n.tenantId);const l=o;for(const f of Object.keys(l))l[f]===void 0&&delete l[f];const c=await n._getAppCheckToken(),h=c?`#${kI}=${encodeURIComponent(c)}`:"";return`${NI(n)}?${ms(l).slice(1)}${h}`}function NI({config:n}){return n.emulator?bl(n,PI):`https://${n.authDomain}/${bI}`}/**
1862 * @license
1863 * Copyright 2020 Google LLC
1864 *
1865 * Licensed under the Apache License, Version 2.0 (the "License");
1866 * you may not use this file except in compliance with the License.
1867 * You may obtain a copy of the License at
1868 *
1869 *   http://www.apache.org/licenses/LICENSE-2.0
1870 *
1871 * Unless required by applicable law or agreed to in writing, software
1872 * distributed under the License is distributed on an "AS IS" BASIS,
1873 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1874 * See the License for the specific language governing permissions and
1875 * limitations under the License.
1876 */const ga="webStorageSupport";class DI{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Ml,this._completeRedirectFn=nI,this._overrideRedirectResult=ZT}async _openPopup(e,t,s,i){var r;Ot((r=this.eventManagers[e._key()])===null||r===void 0?void 0:r.manager,"_initialize() not called before _openPopup()");const o=await Ch(e,t,s,Ua(),i);return RI(e,o,Ll())}async _openRedirect(e,t,s,i){await this._originValidation(e);const r=await Ch(e,t,s,Ua(),i);return LT(r),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:i,promise:r}=this.eventManagers[t];return i?Promise.resolve(i):(Ot(r,"If manager is not set, promise should be"),r)}const s=this.initAndGetManager(e);return this.eventManagers[t]={promise:s},s.catch(()=>{delete this.eventManagers[t]}),s}async initAndGetManager(e){const t=await EI(e),s=new iI(e);return t.register("authEvent",i=>(U(i==null?void 0:i.authEvent,e,"invalid-auth-event"),{status:s.onEvent(i.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:s},this.iframes[e._key()]=t,s}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(ga,{type:ga},i=>{var r;const o=(r=i==null?void 0:i[0])===null||r===void 0?void 0:r[ga];o!==void 0&&t(!!o),Dt(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=cI(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return lp()||np()||Nl()}}const bp=DI;var Ah="@firebase/auth",Rh="1.7.9";/**
1877 * @license
1878 * Copyright 2020 Google LLC
1879 *
1880 * Licensed under the Apache License, Version 2.0 (the "License");
1881 * you may not use this file except in compliance with the License.
1882 * You may obtain a copy of the License at
1883 *
1884 *   http://www.apache.org/licenses/LICENSE-2.0
1885 *
1886 * Unless required by applicable law or agreed to in writing, softw
1886are
1887 * distributed under the License is distributed on an "AS IS" BASIS,
1888 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1889 * See the License for the specific language governing permissions and
1890 * limitations under the License.
1891 */class OI{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),((e=this.auth.currentUser)===null||e===void 0?void 0:e.uid)||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged(s=>{e((s==null?void 0:s.stsTokenManager.accessToken)||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){U(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}/**
1892 * @license
1893 * Copyright 2020 Google LLC
1894 *
1895 * Licensed under the Apache License, Version 2.0 (the "License");
1896 * you may not use this file except in compliance with the License.
1897 * You may obtain a copy of the License at
1898 *
1899 *   http://www.apache.org/licenses/LICENSE-2.0
1900 *
1901 * Unless required by applicable law or agreed to in writing, software
1902 * distributed under the License is distributed on an "AS IS" BASIS,
1903 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1904 * See the License for the specific language governing permissions and
1905 * limitations under the License.
1906 */function xI(n){switch(n){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function MI(n){Ge(new He("auth",(e,{options:t})=>{const s=e.getProvider("app").getImmediate(),i=e.getProvider("heartbeat"),r=e.getProvider("app-check-internal"),{apiKey:o,authDomain:l}=s.options;U(o&&!o.includes(":"),"invalid-api-key",{appName:s.name});const c={apiKey:o,authDomain:l,clientPlatform:n,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:cp(n)},h=new mT(s,i,r,c);return IT(h,t),h},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,s)=>{e.getProvider("auth-internal").initialize()})),Ge(new He("auth-internal",e=>{const t=Dl(e.getProvider("auth").getImmediate());return(s=>new OI(s))(t)},"PRIVATE").setInstantiationMode("EXPLICIT")),Re(Ah,Rh,xI(n)),Re(Ah,Rh,"esm2017")}/**
1907 * @license
1908 * Copyright 2021 Google LLC
1909 *
1910 * Licensed under the Apache License, Version 2.0 (the "License");
1911 * you may not use this file except in compliance with the License.
1912 * You may obtain a copy of the License at
1913 *
1914 *   http://www.apache.org/licenses/LICENSE-2.0
1915 *
1916 * Unless required by applicable law or agreed to in writing, software
1917 * distributed under the License is distributed on an "AS IS" BASIS,
1918 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1919 * See the License for the specific language governing permissions and
1920 * limitations under the License.
1921 */const LI=5*60,VI=ff("authIdTokenMaxAge")||LI;let Sh=null;const FI=n=>async e=>{const t=e&&await e.getIdTokenResult(),s=t&&(new Date().getTime()-Date.parse(t.issuedAtTime))/1e3;if(s&&s>VI)return;const i=t==null?void 0:t.token;Sh!==i&&(Sh=i,await fetch(n,{method:i?"POST":"DELETE",headers:i?{Authorization:`Bearer ${i}`}:{}}))};function UI(n=vs()){const e=gt(n,"auth");if(e.isInitialized())return e.getImmediate();const t=up(n,{popupRedirectResolver:bp,persistence:[Ap,vp,Ml]}),s=ff("authTokenSyncURL");if(s&&typeof isSecureContext=="boolean"&&isSecureContext){const r=new URL(s,location.origin);if(location.origin===r.origin){const o=FI(r.toString());gp(t,o,()=>o(t.currentUser)),_p(t,l=>o(l))}}const i=hf("auth");return i&&hp(t,`http://${i}`),t}function BI(){var n,e;return(e=(n=document.getElementsByTagName("head"))===null||n===void 0?void 0:n[0])!==null&&e!==void 0?e:document}yT({loadJS(n){return new Promise((e,t)=>
1921{const s=document.createElement("script");s.setAttribute("src",n),s.onload=e,s.onerror=i=>{const r=ht("internal-error");r.customData=i,t(r)},s.type="text/javascript",s.charset="UTF-8",BI().appendChild(s)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});MI("Browser");const mP=Object.freeze(Object.defineProperty({__proto__:null,AuthCredential:xl,FacebookAuthProvider:Tt,GithubAuthProvider:wt,GoogleAuthProvider:It,OAuthCredential:Zt,TwitterAuthProvider:Ct,beforeAuthStateChanged:gp,browserLocalPersistence:vp,browserPopupRedirectResolver:bp,browserSessionPersistence:Ml,connectAuthEmulator:hp,getAuth:UI,getIdTokenResult:Xf,inMemoryPersistence:qa,indexedDBLocalPersistence:Ap,initializeAuth:up,onAuthStateChanged:NT,onIdTokenChanged:_p,prodErrorMap:Hf,reload:Jf,updateProfile:kT},Symbol.toStringTag,{value:"Module"}));/**
1922 * @license
1923 * Copyright 2020 Google LLC
1924 *
1925 * Licensed under the Apache License, Version 2.0 (the "License");
1926 * you may not use this file except in compliance with the License.
1927 * You may obtain a copy of the License at
1928 *
1929 *   http://www.apache.org/licenses/LICENSE-2.0
1930 *
1931 * Unless required by applicable law or agreed to in writing, software
1932 * distributed under the License is distributed on an "AS IS" BASIS,
1933 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1934 * See the License for the specific language governing permissions and
1935 * limitations under the License.
1936 */const ja=new Map,Pp={activated:!1,tokenObservers:[]},qI={initialized:!1,enabled:!1};function et(n){return ja.get(n)||Object.assign({},Pp)}function $I(n,e){return ja.set(n,e),ja.get(n)}function yo(){return qI}/**
1937 * @license
1938 * Copyright 2020 Google LLC
1939 *
1940 * Licensed under the Apache License, Version 2.0 (the "License");
1941 * you may not use this file except in compliance with the License.
1942 * You may obtain a copy of the License at
1943 *
1944 *   http://www.apache.org/licenses/LICENSE-2.0
1945 *
1946 * Unless required by applicable law or agreed to in writing, software
1947 * distributed under the License is distributed on an "AS IS" BASIS,
1948 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1949 * See the License for the specific language governing permissions and
1950 * limitations under the License.
1951 */const jI="https://content-firebaseappcheck.googleapis.com/v1",HI="exchangeDebugToken",bh={RETRIAL_MIN_WAIT:30*1e3,RETRIAL_MAX_WAIT:16*60*1e3};/**
1952 * @license
1953 * Copyright 2020 Google LLC
1954 *
1955 * Licensed under the Apache License, Version 2.0 (the "License");
1956 * you may not use this file except in compliance with the License.
1957 * You may obtain a copy of the License at
1958 *
1959 *   http://www.apache.org/licenses/LICENSE-2.0
1960 *
1961 * Unless required by applicable law or agreed to in writing, software
1962 * distributed under the License is distributed on an "AS IS" BASIS,
1963 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1964 * See the License for the specific language governing permissions and
1965 * limitations under the License.
1966 */class WI{constructor(e,t,s,i,r){if(this.operation=e,this.retryPolicy=t,this.getWaitDuration=s,this.lowerBound=i,this.upperBound=r,this.pending=null,this.nextErrorWaitInterval=i,i>r)throw new Error("Proactive refresh lower bound greater than upper bound!")}start(){this.nextErrorWaitInterval=this.lowerBound,this.process(!0).catch(()=>{})}stop(){this.pending&&(this.pending.reject("cancelled"),this.pending=null)}isRunning(){return!!this.pending}async process(e){this.stop();try{this.pending=new ts,this.pending.promise.catch(t=>{}),await zI(this.getNextRun(e)),this.pending.resolve(),await this.pending.promise,this.pending=new ts,this.pending.promise.catch(t=>{}),await this.operation(),this.pending.resolve(),await this.pending.promise,this.process(!0).catch(()=>{})}catch(t){this.retryPolicy(t)?this.process(!1).catch(()=>{}):this.stop()}}getNextRun(e){if(e)return this.nextErrorWaitInterval=this.lowerBound,this.getWaitDuration();{const t=this.nextErrorWaitInterval;return this.nextErrorWaitInterval*=2,this.nextErrorWaitInterval>this.upperBound&&(this.nextErrorWaitInterval=this.upperBound),t}}}function zI(n){return new Promise(e=>{setTimeout(e,n)})}/**
1967 * @license
1968 * Copyright 2020 Google LLC
1969 *
1970 * Licensed under the Apache License, Version 2.0 (the "License");
1971 * you may not use this file except in compliance with the License.
1972 * You may obtain a copy of the License at
1973 *
1974 *   http://www.apache.org/licenses/LICENSE-2.0
1975 *
1976 * Unless required by applicable law or agreed to in writing, software
1977 * distributed under the License is distributed on an "AS IS" BASIS,
1978 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1979 * See the License for the specific language governing permissions and
1980 * limitations under the License.
1981 */const GI={"already-initialized":"You have already called initializeAppCheck() for FirebaseApp {$appName} with different options. To avoid this error, call initializeAppCheck() with the same options as when it was originally called. This will return the already initialized instance.","use-before-activation":"App Check is being used before initializeAppCheck() is called for FirebaseApp {$appName}. Call initializeAppCheck() before instantiating other Firebase services.","fetch-network-error":"Fetch failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.","fetch-parse-error":"Fetch client could not parse response. Original error: {$originalErrorMessage}.","fetch-status-error":"Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.","storage-open":"Error thrown when opening storage. Original error: {$originalErrorMessage}.","storage-get":"Error thrown when reading from storage. Original error: {$originalErrorMessage}.","storage-set":"Error thrown when writing to storage. Original error: {$originalErrorMessage}.","recaptcha-error":"ReCAPTCHA error.",throttled:"Requests throttled due to {$httpStatus} error. Attempts allowed again after {$time}"},lt=new an("appCheck","AppCheck",GI);function kp(n){if(!et(n).activated)throw lt.create("use-before-activation",{appName:n.name})}/**
1982 * @license
1983 * Copyright 2020 Google LLC
1984 *
1985 * Licensed under the Apache License, Version 2.0 (the "License");
1986 * you may not use this file except in compliance with the License.
1987 * You may obtain a copy of the License at
1988 *
1989 *   http://www.apache.org/licenses/LICENSE-2.0
1990 *
1991 * Unless required by applicable law or agreed to in writing, software
1992 * distributed under the License is distributed on an "AS IS" BASIS,
1993 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1994 * See the License for the specific language governing permissions and
1995 * limitations under the License.
1996 */async function Np({url:n,body:e},t){const s={"Content-Type":"application/json"},i=t.getImmediate({optional:!0});if(i){const p=await i.getHeartbeatsHeader();p&&(s["X-Firebase-Client"]=p)}const r={method:"POST",body:JSON.stringify(e),headers:s};let o;try{o=await fetch(n,r)}catch(p){throw lt.create("fetch-network-error",{originalErrorMessage:p==null?void 0:p.message})}if(o.status!==200)throw lt.create("fetch-status-error",{httpStatus:o.status});let l;try{l=await o.json()}catch(p){throw lt.create("fetch-parse-error",{originalErrorMessage:p==null?void 0:p.message})}const c=l.ttl.match(/^([\d.]+)(s)$/);if(!c||!c[2]||isNaN(Number(c[1])))throw lt.create("fetch-parse-error",{originalErrorMessage:`ttl field (timeToLive) is not in standard Protobuf Duration format: ${l.ttl}`});const h=Number(c[1])*1e3,f=Date.now();return{token:l.token,expireTimeMillis:f+h,issuedAtTimeMillis:f}}function Dp(n,e){const{projectId:t,appId:s,apiKey:i}=n.options;return{url:`${jI}/projects/${t}/apps/${s}:${HI}?key=${i}`,body:{debug_token:e}}}/**
1997 * @license
1998 * Copyright 2020 Google LLC
1999 *
2000 * Licensed under the Apache License, Version 2.0 (the "License");
2001 * you may not use this file except in compliance with the License.
2002 * You may obtain a copy of the License at
2003 *
2004 *   http://www.apache.org/licenses/LICENSE-2.0
2005 *
2006 * Unless required by applicable law or agreed to in writing, software
2007 * distributed under the License is distributed on an "AS IS" BASIS,
2008 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2009 * See the License for the specific language governing permissions and
2010 * limitations under the License.
2011 */const KI="firebase-app-check-database",QI=1,_i="firebase-app-check-store",Op="debug-token";let dr=null;function xp(){return dr||(dr=new Promise((n,e)=>{try{const t=indexedDB.open(KI,QI);t.onsuccess=s=>{n(s.target.result)},t.onerror=s=>{var i;e(lt.create("storage-open",{originalErrorMessage:(i=s.target.error)===null||i===void 0?void 0:i.message}))},t.onupgradeneeded=s=>{const i=s.target.result;switch(s.oldVersion){case 0:i.createObjectStore(_i,{keyPath:"compositeKey"})}}}catch(t){e(lt.create("storage-open",{originalErrorMessage:t==null?void 0:t.message}))}}),dr)}function YI(n){return Lp(Vp(n))}function XI(n,e){return Mp(Vp(n),e)}function JI(n){return Mp(Op,n)}function ZI(){return Lp(Op)}async function Mp(n,e){const s=(await xp()).transaction(_i,"readwrite"),r=s.objectStore(_i).put({compositeKey:n,value:e});return new Promise((o,l)=>{r.onsuccess=c=>{o()},s.onerror=c=>{var h;l(lt.create("storage-set",{originalErrorMessage:(h=c.target.error)===null||h===void 0?void 0:h.message}))}})}async function Lp(n){const t=(await xp()).transaction(_i,"readonly"),i=t.objectStore(_i).get(n);return new Promise((r,o)=>{i.onsuccess=l=>{const c=l.target.result;r(c?c.value:void 0)},t.onerror=l=>{var c;o(lt.create("storage-get",{originalErrorMessage:(c=l.target.error)===null||c===void 0?void 0:c.message}))}})}function Vp(n){return`${n.options.appId}-${n.name}`}/**
2012 * @license
2013 * Copyright 2020 Google LLC
2014 *
2015 * Licensed under the Apache License, Version 2.0 (the "License");
2016 * you may not use this file except in compliance with the License.
2017 * You may obtain a copy of the License at
2018 *
2019 *   http://www.apache.org/licenses/LICENSE-2.0
2020 *
2021 * Unless required by applicable law or agreed to in writing, software
2022 * distributed under the License is distributed on an "AS IS" BASIS,
2023 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2024 * See the License for the specific language governing permissions and
2025 * limitations under the License.
2026 */const gi=new ys("@firebase/app-check");/**
2027 * @license
2028 * Copyright 2020 Google LLC
2029 *
2030 * Licensed under the Apache License, Version 2.0 (the "License");
2031 * you may not use this file except in compliance with the License.
2032 * You may obtain a copy of the License at
2033 *
2034 *   http://www.apache.org/licenses/LICENSE-2.0
2035 *
2036 * Unless required by applicable law or agreed to in writing, software
2037 * distributed under the License is distributed on an "AS IS" BASIS,
2038 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2039 * See the License for the specific language governing permissions and
2040 * limitations under the License.
2041 */async function ew(n){if(ho()){let e;try{e=await YI(n)}catch(t){gi.warn(`Failed to read token from IndexedDB. Error: ${t}`)}return e}}function ma(n,e){return ho()?XI(n,e).catch(t=>{gi.warn(`Failed to write token to IndexedDB. Error: ${t}`)}):Promise.resolve()}async function tw(){let n;try{n=await ZI()}catch{}if(n)return n;{const e=Ry();return JI(e).catch(t=>gi.warn(`Failed to persist debug token to IndexedDB. Error: ${t}`)),e}}/**
2042 * @license
2043 * Copyright 2020 Google LLC
2044 *
2045 * Licensed under the Apache License, Version 2.0 (the "License");
2046 * you may not use this file except in compliance with the License.
2047 * You may obtain a copy of the License at
2048 *
2049 *   http://www.apache.org/licenses/LICENSE-2.0
2050 *
2051 * Unless required by applicable law or agreed to in writing, software
2052 * distributed under the License is distributed on an "AS IS" BASIS,
2053 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2054 * See the License for the specific language governing permissions and
2055 * limitations under the License.
2056 */function Fl(){return yo().enabled}async function Ul(){const n=yo();if(n.enabled&&n.token)return n.token.promise;throw Error(`
2057            Can't get debug token in production mode.
2058        `)}function nw(){const n=uf(),e=yo();if(e.initialized=!0,typeof n.FIREBASE_APPCHECK_DEBUG_TOKEN!="string"&&n.FIREBASE_APPCHECK_DEBUG_TOKEN!==!0)return;e.enabled=!0;const t=new ts;e.token=t,typeof n.FIREBASE_APPCHECK_DEBUG_TOKEN=="string"?t.resolve(n.FIREBASE_APPCHECK_DEBUG_TOKEN):t.resolve(tw())}/**
2059 * @license
2060 * Copyright 2020 Google LLC
2061 *
2062 * Licensed under the Apache License, Version 2.0 (the "License");
2063 * you may not use this file except in compliance with the License.
2064 * You may obtain a copy of the License at
2065 *
2066 *   http://www.apache.org/licenses/LICENSE-2.0
2067 *
2068 * Unless required by applicable law or agreed to in writing, software
2069 * distributed under the License is distributed on an "AS IS" BASIS,
2070 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2071 * See the License for the specific language governing permissions and
2072 * limitations under the License.
2073 */const sw={error:"UNKNOWN_ERROR"};function iw(n){return co.encodeString(JSON.stringify(n),!1)}async function Ha(n,e=!1){const t=n.app;kp(t);const s=et(t);let i=s.token,r;if(i&&!Wn(i)&&(s.token=void 0,i=void 0),!i){const c=await s.cachedTokenPromise;c&&(Wn(c)?i=c:await ma(t,void 0))}if(!e&&i&&Wn(i))return{token:i.token};let o=!1;if(Fl()){s.exchangeTokenPromise||(s.exchangeTokenPromise=Np(Dp(t,await Ul()),n.heartbeatServiceProvider).finally(()=>{s.exchangeTokenPromise=void 0}),o=!0);const c=await s.exchangeTokenPromise;return await ma(t,c),s.token=c,{token:c.token}}try{s.exchangeTokenPromise||(s.exchangeTokenPromise=s.provider.getToken().finally(()=>{s.exchangeTokenPromise=void 0}),o=!0),i=await et(t).exchangeTokenPromise}catch(c){c.code==="appCheck/throttled"?gi.warn(c.message):gi.error(c),r=c}let l;return i?r?Wn(i)?l={token:i.token,internalError:r}:l=kh(r):(l={token:i.token},s.token=i,await ma(t,i)):l=kh(r),o&&Fp(t,l),l}async function rw(n){const e=n.app;kp(e);const{provider:t}=et(e);if(Fl()){const s=await Ul(),{token:i}=await Np(Dp(e,s),n.heartbeatServiceProvider);return{token:i}}else{const{token:s}=await t.getToken();return{token:s}}}function Bl(n,e,t,s){const{app:i}=n,r=et(i),o={next:t,error:s,type:e};if(r.tokenObservers=[...r.tokenObservers,o],r.token&&Wn(r.token)){const l=r.token;Promise.resolve().then(()=>{t({token:l.token}),Ph(n)}).catch(()=>{})}r.cachedTokenPromise.then(()=>Ph(n))}function ql(n,e){const t=et(n),s=t.tokenObservers.filter(i=>i.next!==e);s.length===0&&t.tokenRefresher&&t.tokenRefresher.isRunning()&&t.tokenRefresher.stop(),t.tokenObservers=s}function Ph(n){const{app:e}=n,t=et(e);let s=t.tokenRefresher;s||(s=ow(n),t.tokenRefresher=s),!s.isRunning()&&t.isTokenAutoRefreshEnabled&&s.start()}function ow(n){const{app:e}=n;return new WI(async()=>{const t=et(e);let s;
2073if(t.token?s=await Ha(n,!0):s=await Ha(n),s.error)throw s.error;if(s.internalError)throw s.internalError},()=>!0,()=>{const t=et(e);if(t.token){let s=t.token.issuedAtTimeMillis+(t.token.expireTimeMillis-t.token.issuedAtTimeMillis)*.5+3e5;const i=t.token.expireTimeMillis-5*60*1e3;return s=Math.min(s,i),Math.max(0,s-Date.now())}else return 0},bh.RETRIAL_MIN_WAIT,bh.RETRIAL_MAX_WAIT)}function Fp(n,e){const t=et(n).tokenObservers;for(const s of t)try{s.type==="EXTERNAL"&&e.error!=null?s.error(e.error):s.next(e)}catch{}}function Wn(n){return n.expireTimeMillis-Date.now()>0}function kh(n){return{token:iw(sw),error:n}}/**
2074 * @license
2075 * Copyright 2020 Google LLC
2076 *
2077 * Licensed under the Apache License, Version 2.0 (the "License");
2078 * you may not use this file except in compliance with the License.
2079 * You may obtain a copy of the License at
2080 *
2081 *   http://www.apache.org/licenses/LICENSE-2.0
2082 *
2083 * Unless required by applicable law or agreed to in writing, software
2084 * distributed under the License is distributed on an "AS IS" BASIS,
2085 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2086 * See the License for the specific language governing permissions and
2087 * limitations under the License.
2088 */class aw{constructor(e,t){this.app=e,this.heartbeatServiceProvider=t}_delete(){const{tokenObservers:e}=et(this.app);for(const t of e)ql(this.app,t.next);return Promise.resolve()}}function lw(n,e){return new aw(n,e)}function cw(n){return{getToken:e=>Ha(n,e),getLimitedUseToken:()=>rw(n),addTokenListener:e=>Bl(n,"INTERNAL",e),removeTokenListener:e=>ql(n.app,e)}}const uw="@firebase/app-check",hw="0.8.8";/**
2089 * @license
2090 * Copyright 2020 Google LLC
2091 *
2092 * Licensed under the Apache License, Version 2.0 (the "License");
2093 * you may not use this file except in compliance with the License.
2094 * You may obtain a copy of the License at
2095 *
2096 *   http://www.apache.org/licenses/LICENSE-2.0
2097 *
2098 * Unless required by applicable law or agreed to in writing, software
2099 * distributed under the License is distributed on an "AS IS" BASIS,
2100 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2101 * See the License for the specific language governing permissions and
2102 * limitations under the License.
2103 */function yP(n=vs(),e){n=le(n);const t=gt(n,"app-check");if(yo().initialized||nw(),Fl()&&Ul().then(i=>console.log(`App Check debug token: ${i}. You will need to add it to your app's App Check settings in the Firebase console for it to work.`)),t.isInitialized()){const i=t.getImmediate(),r=t.getOptions();if(r.isTokenAutoRefreshEnabled===e.isTokenAutoRefreshEnabled&&r.provider.isEqual(e.provider))return i;throw lt.create("already-initialized",{appName:n.name})}const s=t.initialize({options:e});return dw(n,e.provider,e.isTokenAutoRefreshEnabled),et(n).isTokenAutoRefreshEnabled&&Bl(s,"INTERNAL",()=>{}),s}function dw(n,e,t){const s=$I(n,Object.assign({},Pp));s.activated=!0,s.provider=e,s.cachedTokenPromise=ew(n).then(i=>(i&&Wn(i)&&(s.token=i,Fp(n,{token:i.token})),i)),s.isTokenAutoRefreshEnabled=t===void 0?n.automaticDataCollectionEnabled:t,s.provider.initialize(n)}function vP(n,e,t,s){let i=()=>{},r=()=>{};return e.next!=null?i=e.next.bind(e):i=e,e.error!=null&&(r=e.error.bind(e)),Bl(n,"EXTERNAL",i,r),()=>ql(n.app,i)}const fw="app-check",Nh="app-check-internal";function pw(){Ge(new He(fw,n=>{const e=n.getProvider("app").getImmediate(),t=n.getProvider("heartbeat");return lw(e,t)},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((n,e,t)=>{n.getProvider(Nh).initialize()})),Ge(new He(Nh,n=>{const e=n.getProvider("app-check").getImmediate();return cw(e)},"PUBLIC").setInstantiationMode("EXPLICIT")),Re(uw,hw)}pw();var Dh={};const Oh="@firebase/database",xh="1.0.8";/**
2104 * @license
2105 * Copyright 2019 Google LLC
2106 *
2107 * Licensed under the Apache License, Version 2.0 (the "License");
2108 * you may not use this file except in compliance with the License.
2109 * You may obtain a copy of the License at
2110 *
2111 *   http://www.apache.org/licenses/LICENSE-2.0
2112 *
2113 * Unless required by applicable law or agreed to in writing, software
2114 * distributed under the License is distributed on an "AS IS" BASIS,
2115 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2116 * See the License for the specific language governing permissions and
2117 * limitations under the License.
2118 */let Up="";function _w(n){Up=n}/**
2119 * @license
2120 * Copyright 2017 Google LLC
2121 *
2122 * Licensed under the Apache License, Version 2.0 (the "License");
2123 * you may not use this file except in compliance with the License.
2124 * You may obtain a copy of the License at
2125 *
2126 *   http://www.apache.org/licenses/LICENSE-2.0
2127 *
2128 * Unless required by applicable law or agreed to in writing, software
2129 * distributed under the License is distributed on an "AS IS" BASIS,
2130 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2131 * See the License for the specific language governing permissions and
2132 * limitations under the License.
2133 */class gw{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),ye(t))}get(e){const t=this.domStorage_.getItem(this.prefixedName_(e));return t==null?null:hi(t)}remove(e){this.domStorage_.removeItem(this.prefixedName_(e))}prefixedName_(e){return this.prefix_+e}toString(){return this.domStorage_.toString()}}/**
2134 * @license
2135 * Copyright 2017 Google LLC
2136 *
2137 * Licensed under the Apache License, Version 2.0 (the "License");
2138 * you may not use this file except in compliance with the License.
2139 * You may obtain a copy of the License at
2140 *
2141 *   http://www.apache.org/licenses/LICENSE-2.0
2142 *
2143 * Unless required by applicable law or agreed to in writing, software
2144 * distributed under the License is distributed on an "AS IS" BASIS,
2145 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2146 * See the License for the specific language governing permissions and
2147 * limitations under the License.
2148 */class mw{constructor(){this.cache_={},this.isInMemoryStorage=!0}set(e,t){t==null?delete this.cache_[e]:this.cache_[e]=t}get(e){return Lt(this.cache_,e)?this.cache_[e]:null}remove(e){delete this.cache_[e]}}/**
2149 * @license
2150 * Copyright 2017 Google LLC
2151 *
2152 * Licensed under the Apache License, Version 2.0 (the "License");
2153 * you may not use this file except in compliance with the License.
2154 * You may obtain a copy of the License at
2155 *
2156 *   http://www.apache.org/licenses/LICENSE-2.0
2157 *
2158 * Unless required by applicable law or agreed to in writing, software
2159 * distributed under the License is distributed on an "AS IS" BASIS,
2160 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2161 * See the License for the specific language governing permissions and
2162 * limitations under the License.
2163 */const Bp=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 gw(e)}}catch{}return new mw},mn=Bp("localStorage"),yw=Bp("sessionStorage");/**
2164 * @license
2165 * Copyright 2017 Google LLC
2166 *
2167 * Licensed under the Apache License, Version 2.0 (the "License");
2168 * you may not use this file except in compliance with the License.
2169 * You may obtain a copy of the License at
2170 *
2171 *   http://www.apache.org/licenses/LICENSE-2.0
2172 *
2173 * Unless required by applicable law or agreed to in writing, software
2174 * distributed under the License is distributed on an "AS IS" BASIS,
2175 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2176 * See the License for the specific language governing permissions and
2177 * limitations under the License.
2178 */const Xn=new ys("@firebase/database"),vw=function(){let n=1;return function(){return n++}}(),qp=function(n){const e=Ay(n),t=new Ty;t.update(e);const s=t.digest();return co.encodeByteArray(s)},Di=function(...n){let e="";for(let t=0;t<n.length;t++){const s=n[t];Array.isArray(s)||s&&typeof s=="object"&&typeof s.length=="number"?e+=Di.apply(null,s):typeof s=="object"?e+=ye(s):e+=s,e+=" "}return e};let ti=null,Mh=!0;const Ew=function(n,e){N(!0,"Can't turn on custom loggers persistently."),Xn.logLevel=K.VERBOSE,ti=Xn.log.bind(Xn)},Le=function(...n){if(Mh===!0&&(Mh=!1,ti===null&&yw.get("logging_enabled")===!0&&Ew()),ti){const e=Di.apply(null,n);ti(e)}},Oi=function(n){return function(...e){Le(n,...e)}},Wa=function(...n){const e="FIREBASE INTERNAL ERROR: "+Di(...n);Xn.error(e)},xt=function(...n){const e=`FIREBASE FATAL ERROR: ${Di(...n)}`;throw Xn.error(e),new Error(e)},Je=function(...n){const e="FIREBASE WARNING: "+Di(...n);Xn.warn(e)},Tw=function(){typeof window<"u"&&window.location&&window.location.protocol&&window.location.protocol.indexOf("https:")!==-1&&Je("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().")},$p=function(n){return typeof n=="number"&&(n!==n||n===Number.POSITIVE_INFINITY||n===Number.NEGATIVE_INFINITY)},Iw=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))}},os="[MIN_NAME]",An="[MAX_NAME]",Es=function(n,e){if(n===e)return 0;if(n===os||e===An)return-1;if(e===os||n===An)return 1;{const t=Lh(n),s=Lh(e);return t!==null?s!==null?t-s===0?n.length-e.length:t-s:-1:s!==null?1:n<e?-1:1}},ww=function(n,e){return n===e?0:n<e?-1:1},js=function(n,e){if(e&&n in e)return e[n];throw new Error("Missing required key ("+n+") in object: "+ye(e))},$l=function(n){if(typeof n!="object"||n===null)return ye(n);const e=[];for(const s in n)e.push(s);e.sort();let t="{";for(let s=0;s<e.length;s++)s!==0&&(t+=","),t+=ye(e[s]),t+=":",t+=$l(n[e[s]]);return t+="}",t},jp=function(n,e){const t=n.length;if(t<=e)return[n];const s=[];for(let i=0;i<t;i+=e)i+e>t?s.push(n.substring(i,t)):s.push(n.substring(i,i+e));return s};function Ke(n,e){for(const t in n)n.hasOwnProperty(t)&&e(t,n[t])}const Hp=function(n){N(!$p(n),"Invalid JSON number");const e=11,t=52,s=(1<<e-1)-1;let i,r,o,l,c;n===0?(r=0,o=0,i=1/n===-1/0?1:0):(i=n<0,n=Math.abs(n),n>=Math.pow(2,1-s)?(l=Math.min(Math.floor(Math.log(n)/Math.LN2),s),r
2178=l+s,o=Math.round(n*Math.pow(2,t-l)-Math.pow(2,t))):(r=0,o=Math.round(n/Math.pow(2,1-s-t))));const h=[];for(c=t;c;c-=1)h.push(o%2?1:0),o=Math.floor(o/2);for(c=e;c;c-=1)h.push(r%2?1:0),r=Math.floor(r/2);h.push(i?1:0),h.reverse();const f=h.join("");let p="";for(c=0;c<64;c+=8){let g=parseInt(f.substr(c,8),2).toString(16);g.length===1&&(g="0"+g),p=p+g}return p.toLowerCase()},Cw=function(){return!!(typeof window=="object"&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href))},Aw=function(){return typeof Windows=="object"&&typeof Windows.UI=="object"};function Rw(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 s=new Error(n+" at "+e._path.toString()+": "+t);return s.code=n.toUpperCase(),s}const Sw=new RegExp("^-?(0*)\\d{1,10}$"),bw=-2147483648,Pw=2147483647,Lh=function(n){if(Sw.test(n)){const e=Number(n);if(e>=bw&&e<=Pw)return e}return null},xi=function(n){try{n()}catch(e){setTimeout(()=>{const t=e.stack||"";throw Je("Exception was thrown by user callback.",t),e},Math.floor(0))}},kw=function(){return(typeof window=="object"&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)>=0},ni=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};/**
2179 * @license
2180 * Copyright 2021 Google LLC
2181 *
2182 * Licensed under the Apache License, Version 2.0 (the "License");
2183 * you may not use this file except in compliance with the License.
2184 * You may obtain a copy of the License at
2185 *
2186 *   http://www.apache.org/licenses/LICENSE-2.0
2187 *
2188 * Unless required by applicable law or agreed to in writing, software
2189 * distributed under the License is distributed on an "AS IS" BASIS,
2190 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2191 * See the License for the specific language governing permissions and
2192 * limitations under the License.
2193 */class Nw{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(s=>this.appCheck=s)}getToken(e){return this.appCheck?this.appCheck.getToken(e):new Promise((t,s)=>{setTimeout(()=>{this.appCheck?this.getToken(e).then(t,s):t(null)},0)})}addTokenChangeListener(e){var t;(t=this.appCheckProvider)===null||t===void 0||t.get().then(s=>s.addTokenListener(e))}notifyForInvalidToken(){Je(`Provided AppCheck credentials for the app named "${this.appName_}" are invalid. This usually indicates your app was not initialized correctly.`)}}/**
2194 * @license
2195 * Copyright 2017 Google LLC
2196 *
2197 * Licensed under the Apache License, Version 2.0 (the "License");
2198 * you may not use this file except in compliance with the License.
2199 * You may obtain a copy of the License at
2200 *
2201 *   http://www.apache.org/licenses/LICENSE-2.0
2202 *
2203 * Unless required by applicable law or agreed to in writing, software
2204 * distributed under the License is distributed on an "AS IS" BASIS,
2205 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2206 * See the License for the specific language governing permissions and
2207 * limitations under the License.
2208 */class Dw{constructor(e,t,s){this.appName_=e,this.firebaseOptions_=t,this.authProvider_=s,this.auth_=null,this.auth_=s.getImmediate({optional:!0}),this.auth_||s.onInit(i=>this.auth_=i)}getToken(e){return this.auth_?this.auth_.getToken(e).catch(t=>t&&t.code==="auth/token-not-initialized"?(Le("Got auth/token-not-initialized error.  Treating as null token."),null):Promise.reject(t)):new Promise((t,s)=>{setTimeout(()=>{this.auth_?this.getToken(e).then(t,s):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/.',Je(e)}}class Ar{constructor(e){this.accessToken=e}getToken(e){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(e){e(this.accessToken)}removeTokenChangeListener(e){}notifyForInvalidToken(){}}Ar.OWNER="owner";/**
2209 * @license
2210 * Copyright 2017 Google LLC
2211 *
2212 * Licensed under the Apache License, Version 2.0 (the "License");
2213 * you may not use this file except in compliance with the License.
2214 * You may obtain a copy of the License at
2215 *
2216 *   http://www.apache.org/licenses/LICENSE-2.0
2217 *
2218 * Unless required by applicable law or agreed to in writing, software
2219 * distributed under the License is distributed on an "AS IS" BASIS,
2220 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2221 * See the License for the specific language governing permissions and
2222 * limitations under the License.
2223 */const jl="5",Wp="v",zp="s",Gp="r",Kp="f",Qp=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,Yp="ls",Xp="p",za="ac",Jp="websocket",Zp="long_polling";/**
2224 * @license
2225 * Copyright 2017 Google LLC
2226 *
2227 * Licensed under the Apache License, Version 2.0 (the "License");
2228 * you may not use this file except in compliance with the License.
2229 * You may obtain a copy of the License at
2230 *
2231 *   http://www.apache.org/licenses/LICENSE-2.0
2232 *
2233 * Unless required by applicable law or agreed to in writing, software
2234 * distributed under the License is distributed on an "AS IS" BASIS,
2235 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2236 * See the License for the specific language governing permissions and
2237 * limitations under the License.
2238 */class e_{constructor(e,t,s,i,r=!1,o="",l=!1,c=!1){this.secure=t,this.namespace=s,this.webSocketOnly=i,this.nodeAdmin=r,this.persistenceKey=o,this.includeNamespaceInQueryParams=l,this.isUsingEmulator=c,this._host=e.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=mn.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()&&mn.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 Ow(n){return n.host!==n.internalHost||n.isCustomHost()||n.includeNamespaceInQueryParams}function t_(n,e,t){N(typeof e=="string","typeof type must == string"),N(typeof t=="object","typeof params must == object");let s;if(e===Jp)s=(n.secure?"wss://":"ws://")+n.internalHost+"/.ws?";else if(e===Zp)s=(n.secure?"https://":"http://")+n.internalHost+"/.lp?";else throw new Error("Unknown connection type: "+e);Ow(n)&&(t.ns=n.namespace);const i=[];return Ke(t,(r,o)=>{i.push(r+"="+o)}),s+i.join("&")}/**
2239 * @license
2240 * Copyright 2017 Google LLC
2241 *
2242 * Licensed under the Apache License, Version 2.0 (the "License");
2243 * you may not use this file except in compliance with the License.
2244 * You may obtain a copy of the License at
2245 *
2246 *   http://www.apache.org/licenses/LICENSE-2.0
2247 *
2248 * Unless required by applicable law or agreed to in writing, software
2249 * distributed under the License is distributed on an "AS IS" BASIS,
2250 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2251 * See the License for the specific language governing permissions and
2252 * limitations under the License.
2253 */class xw{constructor(){this.counters_={}}incrementCounter(e,t=1){Lt(this.counters_,e)||(this.counters_[e]=0),this.counters_[e]+=t}get(){return ry(this.counters_)}}/**
2254 * @license
2255 * Copyright 2017 Google LLC
2256 *
2257 * Licensed under the Apache License, Version 2.0 (the "License");
2258 * you may not use this file except in compliance with the License.
2259 * You may obtain a copy of the License at
2260 *
2261 *   http://www.apache.org/licenses/LICENSE-2.0
2262 *
2263 * Unless required by applicable law or agreed to in writing, software
2264 * distributed under the License is distributed on an "AS IS" BASIS,
2265 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2266 * See the License for the specific language governing permissions and
2267 * limitations under the License.
2268 */const ya={},va={};function Hl(n){const e=n.toString();return ya[e]||(ya[e]=new xw),ya[e]}function Mw(n,e){const t=n.toString();return va[t]||(va[t]=e()),va[t]}/**
2269 * @license
2270 * Copyright 2017 Google LLC
2271 *
2272 * Licensed under the Apache License, Version 2.0 (the "License");
2273 * you may not use this file except in compliance with the License.
2274 * You may obtain a copy of the License at
2275 *
2276 *   http://www.apache.org/licenses/LICENSE-2.0
2277 *
2278 * Unless required by applicable law or agreed to in writing, software
2279 * distributed under the License is distributed on an "AS IS" BASIS,
2280 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2281 * See the License for the specific language governing permissions and
2282 * limitations under the License.
2283 */class Lw{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 s=this.pendingResponses[this.currentResponseNum];delete this.pendingResponses[this.currentResponseNum];for(let i=0;i<s.length;++i)s[i]&&xi(()=>{this.onMessage_(s[i])});if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}}/**
2284 * @license
2285 * Copyright 2017 Google LLC
2286 *
2287 * Licensed under the Apache License, Version 2.0 (the "License");
2288 * you may not use this file except in compliance with the License.
2289 * You may obtain a copy of the License at
2290 *
2291 *   http://www.apache.org/licenses/LICENSE-2.0
2292 *
2293 * Unless required by applicable law or agreed to in writing, software
2294 * distributed under the License is distributed on an "AS IS" BASIS,
2295 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2296 * See the License for the specific language governing permissions and
2297 * limitations under the License.
2298 */const Vh="start",Vw="close",Fw="pLPCommand",Uw="pRTLPCB",n_="id",s_="pw",i_="ser",Bw="cb",qw="seg",$w="ts",jw="d",Hw="dframe",r_=1870,o_=30,Ww=r_-o_,zw=25e3,Gw=3e4;class zn{constructor(e,t,s,i,r,o,l){this.connId=e,this.repoInfo=t,this.applicationId=s,this.appCheckToken=i,this.authToken=r,this.transportSessionId=o,this.lastSessionId=l,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=Oi(e),this.stats_=Hl(t),this.urlFn=c=>(this.appCheckToken&&(c[za]=this.appCheckToken),t_(t,Zp,c))}open(e,t){this.curSegmentNum=0,this.onDisconnect_=t,this.myPacketOrderer=new Lw(e),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null},Math.floor(Gw)),Iw(()=>{if(this.isClosed_)return;this.scriptTagHolder=new Wl((...r)=>{const[o,l,c,h,f]=r;if(this.incrementIncomingBytes_(r),!!this.scriptTagHolder)if(this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,o===Vh)this.id=l,this.password=c;else if(o===Vw)l?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(l,()=>{this.onClosed_()})):this.onClosed_();else throw new Error("Unrecognized command received: "+o)},(...r)=>{const[o,l]=r;this.incrementIncomingBytes_(r),this.myPacketOrderer.handleResponse(o,l)},()=>{this.onClosed_()},this.urlFn);const s={};s[Vh]="t",s[i_]=Math.floor(Math.random()*1e8),this.scriptTagHolder.uniqueCallbackIdentifier&&(s[Bw]=this.scriptTagHolder.uniqueCallbackIdentifier),s[Wp]=jl,this.transportSessionId&&(s[zp]=this.transportSessionId),this.lastSessionId&&(s[Yp]=this.lastSessionId),this.applicationId&&(s[Xp]=this.applicationId),this.appCheckToken&&(s[za]=this.appCheckToken),typeof location<"u"&&location.hostname&&Qp.test(location.hostname)&&(s[Gp]=Kp);const i=this.urlFn(s);this.log_("Connecting via long-poll to "+i),this.scriptTagHolder.addTag(i,()=>{})})}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){zn.forceAllow_=!0}static forceDisallow(){zn.forceDisallow_=!0}static isAvailable(){return zn.forceAllow_?!0:!zn.forceDisallow_&&typeof document<"u"&&document.createElement!=null&&!Cw()&&!Aw()}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=ye(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const s=lf(t),i=jp(s,Ww);for(let r=0;r<i.length;r++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,i.length,i[r]),this.curSegmentNum++}addDisconnectPingFrame(e,t){this.myDisconnFrame=document.createElement("iframe");const s={};s[Hw]="t",s[n_]=e,s[s_]=t,this.myDisconnFrame.src=this.urlFn(s),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}incrementIncomingBytes_(e){const t=ye(e).length;this.bytesReceived+=t,this.stats_.incrementCounter("bytes_received",t)}}class Wl{constructor(e,t,s,i){this.onDisconnect=s,this.urlFn=i,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(Math.random()*1e8),this.sendNewPolls=!0;{this.uniqueCallbackIdentifier=vw(),window[Fw+this.uniqueCallbackIdentifier]=e,window[Uw+this.uniqueCallbackIdentifier]=t,this.myIFrame=Wl.createI
2298Frame_();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>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(o),this.myIFrame.doc.close()}catch(l){Le("frame writing exception"),l.stack&&Le(l.stack),Le(l)}}}static createIFrame_(){const e=document.createElement("iframe");if(e.style.display="none",document.body){document.body.appendChild(e);try{e.contentWindow.document||Le("No IE domain setting required")}catch{const s=document.domain;e.src="javascript:void((function(){document.open();document.domain='"+s+"';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[n_]=this.myID,e[s_]=this.myPW,e[i_]=this.currentSerial;let t=this.urlFn(e),s="",i=0;for(;this.pendingSegs.length>0&&this.pendingSegs[0].d.length+o_+s.length<=r_;){const o=this.pendingSegs.shift();s=s+"&"+qw+i+"="+o.seg+"&"+$w+i+"="+o.ts+"&"+jw+i+"="+o.d,i++}return t=t+s,this.addLongPollTag_(t,this.currentSerial),!0}else return!1}enqueueSegment(e,t,s){this.pendingSegs.push({seg:e,ts:t,d:s}),this.alive&&this.newRequest_()}addLongPollTag_(e,t){this.outstandingRequests.add(t);const s=()=>{this.outstandingRequests.delete(t),this.newRequest_()},i=setTimeout(s,Math.floor(zw)),r=()=>{clearTimeout(i),s()};this.addTag(e,r)}addTag(e,t){setTimeout(()=>{try{if(!this.sendNewPolls)return;const s=this.myIFrame.doc.createElement("script");s.type="text/javascript",s.async=!0,s.src=e,s.onload=s.onreadystatechange=function(){const i=s.readyState;(!i||i==="loaded"||i==="complete")&&(s.onload=s.onreadystatechange=null,s.parentNode&&s.parentNode.removeChild(s),t())},s.onerror=()=>{Le("Long-poll script failed to load: "+e),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(s)}catch{}},Math.floor(1))}}/**
2299 * @license
2300 * Copyright 2017 Google LLC
2301 *
2302 * Licensed under the Apache License, Version 2.0 (the "License");
2303 * you may not use this file except in compliance with the License.
2304 * You may obtain a copy of the License at
2305 *
2306 *   http://www.apache.org/licenses/LICENSE-2.0
2307 *
2308 * Unless required by applicable law or agreed to in writing, software
2309 * distributed under the License is distributed on an "AS IS" BASIS,
2310 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2311 * See the License for the specific language governing permissions and
2312 * limitations under the License.
2313 */const Kw=16384,Qw=45e3;let qr=null;typeof MozWebSocket<"u"?qr=MozWebSocket:typeof WebSocket<"u"&&(qr=WebSocket);class st{constructor(e,t,s,i,r,o,l){this.connId=e,this.applicationId=s,this.appCheckToken=i,this.authToken=r,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=Oi(this.connId),this.stats_=Hl(t),this.connURL=st.connectionURL_(t,o,l,i,s),this.nodeAdmin=t.nodeAdmin}static connectionURL_(e,t,s,i,r){const o={};return o[Wp]=jl,typeof location<"u"&&location.hostname&&Qp.test(location.hostname)&&(o[Gp]=Kp),t&&(o[zp]=t),s&&(o[Yp]=s),i&&(o[za]=i),r&&(o[Xp]=r),t_(e,Jp,o)}open(e,t){this.onDisconnect=t,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,mn.set("previous_websocket_failure",!0);try{let s;fy(),this.mySock=new qr(this.connURL,[],s)}catch(s){this.log_("Error instantiating WebSocket.");const i=s.message||s.data;i&&this.log_(i),this.onClosed_();return}this.mySock.onopen=()=>{this.log_("Websocket connected."),this.everConnected_=!0}
2313,this.mySock.onclose=()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=s=>{this.handleIncomingFrame(s)},this.mySock.onerror=s=>{this.log_("WebSocket error.  Closing connection.");const i=s.message||s.data;i&&this.log_(i),this.onClosed_()}}start(){}static forceDisallow(){st.forceDisallow_=!0}static isAvailable(){let e=!1;if(typeof navigator<"u"&&navigator.userAgent){const t=/Android ([0-9]{0,}\.[0-9]{0,})/,s=navigator.userAgent.match(t);s&&s.length>1&&parseFloat(s[1])<4.4&&(e=!0)}return!e&&qr!==null&&!st.forceDisallow_}static previouslyFailed(){return mn.isInMemoryStorage||mn.get("previous_websocket_failure")===!0}markConnectionHealthy(){mn.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 s=hi(t);this.onMessage(s)}}handleNewFrameCount_(e){this.totalFrames=e,this.frames=[]}extractFrameCount_(e){if(N(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 s=this.extractFrameCount_(t);s!==null&&this.appendFrame_(s)}}send(e){this.resetKeepAlive();const t=ye(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const s=jp(t,Kw);s.length>1&&this.sendString_(String(s.length));for(let i=0;i<s.length;i++)this.sendString_(s[i])}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(Qw))}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)}}}st.responsesRequiredToBeHealthy=2;st.healthyTimeout=3e4;/**
2314 * @license
2315 * Copyright 2017 Google LLC
2316 *
2317 * Licensed under the Apache License, Version 2.0 (the "License");
2318 * you may not use this file except in compliance with the License.
2319 * You may obtain a copy of the License at
2320 *
2321 *   http://www.apache.org/licenses/LICENSE-2.0
2322 *
2323 * Unless required by applicable law or agreed to in writing, software
2324 * distributed under the License is distributed on an "AS IS" BASIS,
2325 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2326 * See the License for the specific language governing permissions and
2327 * limitations under the License.
2328 */class mi{constructor(e){this.initTransports_(e)}static get ALL_TRANSPORTS(){return[zn,st]}static get IS_TRANSPORT_INITIALIZED(){return this.globalTransportInitialized_}initTransports_(e){const t=st&&st.isAvailable();let s=t&&!st.previouslyFailed();if(e.webSocketOnly&&(t||Je("wss:// URL used, but browser isn't known to support websockets.  Trying anyway."),s=!0),s)this.transports_=[st];else{const i=this.transports_=[];for(const r of mi.ALL_TRANSPORTS)r&&r.isAvailable()&&i.push(r);mi.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}}mi.globalTransportInitialized_=!1;/**
2329 * @license
2330 * Copyright 2017 Google LLC
2331 *
2332 * Licensed under the Apache License, Version 2.0 (the "License");
2333 * you may not use this file except in compliance with the License.
2334 * You may obtain a copy of the License at
2335 *
2336 *   http://www.apache.org/licenses/LICENSE-2.0
2337 *
2338 * Unless required by applicable law or agreed to in writing, softw
2338are
2339 * distributed under the License is distributed on an "AS IS" BASIS,
2340 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2341 * See the License for the specific language governing permissions and
2342 * limitations under the License.
2343 */const Yw=6e4,Xw=5e3,Jw=10*1024,Zw=100*1024,Ea="t",Fh="d",eC="s",Uh="r",tC="e",Bh="o",qh="a",$h="n",jh="p",nC="h";class sC{constructor(e,t,s,i,r,o,l,c,h,f){this.id=e,this.repoInfo_=t,this.applicationId_=s,this.appCheckToken_=i,this.authToken_=r,this.onMessage_=o,this.onReady_=l,this.onDisconnect_=c,this.onKill_=h,this.lastSessionId=f,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=Oi("c:"+this.id+":"),this.transportManager_=new mi(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_),s=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,s)},Math.floor(0));const i=e.healthyTimeout||0;i>0&&(this.healthyTimeout_=ni(()=>{this.healthyTimeout_=null,this.isHealthy_||(this.conn_&&this.conn_.bytesReceived>Zw?(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>Jw?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(i)))}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(Ea in e){const t=e[Ea];t===qh?this.upgradeIfSecondaryHealthy_():t===Uh?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),(this.tx_===this.secondaryConn_||this.rx_===this.secondaryConn_)&&this.close()):t===Bh&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}}onSecondaryMessageReceived_(e){const t=js("t",e),s=js("d",e);if(t==="c")this.onSecondaryControl_(s);else if(t==="d")this.pendingDataMessages.push(s);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:"c",d:{t:jh,d:{}}}))}proceedWithUpgrade_(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:qh,d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:$h,d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()}onPrimaryMessageReceived_(e){const t=js("t",e),s=js("d",e);t==="c"?this.onControl_(s):t==="d"&&this.onDataMessage_(s)}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=js(Ea,e);if(Fh in e){const s=e[Fh];if(t===nC){const i=Object.assign({},s);this.repoInfo_.isUsingEmulator&&(i.h=this.repoInfo_.host),this.onHandshake_(i)}else if(t===$h){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(let i=0;i<this.pendingDataMessages.length;++i)this.onDataMessage_(this.pendingDataMessages[i]);this.pendingDataMessages=[],this.tryCleanupConnection()}else t===eC?this.onConnectionShutdown_(s):t===Uh?this.onReset_(s):t===tC?Wa("Server Error: "+s):t===Bh?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):Wa("Unknown control packet command: "+t)}}onHandshake_(e){const t=e.ts,s=e.v,i=e.h;this.sessionId=e.s,this.repoInfo_.host=i,this.state_===0&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,t),jl!==s&&Je("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_),s=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(t,s),ni(()=>{this.secondaryConn_&&(this.log_("Timed out trying to upgrade."),this.secondaryConn_.close())},Math.floor(Yw))}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):ni(()=>{this.sendPingOnPrimaryIfNecessary_()},Math.floor(Xw))}sendPingOnPrimaryIfNecessary_(){!this.isHealthy_&&this.state_===1&&(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:jh,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()&&(mn.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)}}/**
2344 * @license
2345 * Copyright 2017 Google LLC
2346 *
2347 * Licensed under the Apache License, Version 2.0 (the "License");
2348 * you may not use this file except in compliance with the License.
2349 * You may obtain a copy of the License at
2350 *
2351 *   http://www.apache.org/licenses/LICENSE-2.0
2352 *
2353 * Unless required by applicable law or agreed to in writing, software
2354 * distributed under the License is distributed on an "AS IS" BASIS,
2355 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2356 * See the License for the specific language governing permissions and
2357 * limitations under the License.
2358 */class a_{put(e,t,s,i){}merge(e,t,s,i){}refreshAuthToken(e){}refreshAppCheckToken(e){}onDisconnectPut(e,t,s){}onDisconnectMerge(e,t,s){}onDisconnectCancel(e,t){}reportStats(e){}}/**
2359 * @license
2360 * Copyright 2017 Google LLC
2361 *
2362 * Licensed under the Apache License, Version 2.0 (the "License");
2363 * you may not use this file except in compliance with the License.
2364 * You may obtain a copy of the License at
2365 *
2366 *   http://www.apache.org/licenses/LICENSE-2.0
2367 *
2368 * Unless required by applicable law or agreed to in writing, software
2369 * distributed under the License is distributed on an "AS IS" BASIS,
2370 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2371 * See the License for the specific language governing permissions and
2372 * limitations under the License.
2373 */class l_{constructor(e){this.allowedEvents_=e,this.listeners_={},N(Array.isArray(e)&&e.length>0,"Requires a non-empty array")}trigger(e,...t){if(Array.isArray(this.listeners_[e])){const s=[...this.listeners_[e]];for(let i=0;i<s.length;i++)s[i].callback.apply(s[i].context,t)}}on(e,t,s){this.validateEventType_(e),this.listeners_[e]=this.listeners_[e]||[],this.listeners_[e].push({callback:t,context:s});const i=this.getInitialEvent(e);i&&t.apply(s,i)}off(e,t,s){this.validateEventType_(e);const i=this.listeners_[e]||[];for(let r=0;r<i.length;r++)if(i[r].callback===t&&(!s||s===i[r].context)){i.splice(r,1);return}}validateEventType_(e){N(this.allowedEvents_.find(t=>t===e),"Unknown event: "+e)}}/**
2374 * @license
2375 * Copyright 2017 Google LLC
2376 *
2377 * Licensed under the Apache License, Version 2.0 (the "License");
2378 * you may not use this file except in compliance with the License.
2379 * You may obtain a copy of the License at
2380 *
2381 *   http://www.apache.org/licenses/LICENSE-2.0
2382 *
2383 * Unless required by applicable law or agreed to in writing, software
2384 * distributed under the License is distributed on an "AS IS" BASIS,
2385 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2386 * See the License for the specific language governing permissions and
2387 * limitations under the License.
2388 */class $r extends l_{constructor(){super(["online"]),this.online_=!0,typeof window<"u"&&typeof window.addEventListener<"u"&&!Tl()&&(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 $r}getInitialEvent(e){return N(e==="online","Unknown event type: "+e),[this.online_]}currentlyOnline(){return this.online_}}/**
2389 * @license
2390 * Copyright 2017 Google LLC
2391 *
2392 * Licensed under the Apache License, Version 2.0 (the "License");
2393 * you may not use this file except in compliance with the License.
2394 * You may obtain a copy of the License at
2395 *
2396 *   http://www.apache.org/licenses/LICENSE-2.0
2397 *
2398 * Unless required by applicable law or agreed to in writing, software
2399 * distributed under the License is distributed on an "AS IS" BASIS,
2400 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2401 * See the License for the specific language governing permissions and
2402 * limitations under the License.
2403 */const Hh=32,Wh=768;class se{constructor(e,t){if(t===void 0){this.pieces_=e.split("/");let s=0;for(let i=0;i<this.pieces_.length;i++)this.pieces_[i].length>0&&(this.pieces_[s]=this.pieces_[i],s++);this.pieces_.length=s,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 Z(){return new se("")}function z(n){return n.pieceNum_>=n.pieces_.length?null:n.pieces_[n.pieceNum_]}function en(n){return n.pieces_.length-n.pieceNum_}function ie(n){let e=n.pieceNum_;return e<n.pieces_.length&&e++,new se(n.pieces_,e)}function c_(n){return n.pieceNum_<n.pieces_.length?n.pieces_[n.pieces_.length-1]:null}function iC(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 u_(n,e=0){return n.pieces_.slice(n.pieceNum_+e)}function h_(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 se(e,0)}function ve(n,e){const t=[];for(let s=n.pieceNum_;s<n.pieces_.length;s++)t.push(n.pieces_[s]);if(e instanceof se)for(let s=e.pieceNum_;s<e.pieces_.length;s++)t.push(e.pieces_[s]);else{const s=e.split("/");for(let i=0;i<s.length;i++)s[i].length>0&&t.push(s[i])}return new se(t,0)}function G(n){return n.pieceNum_>=n.pieces_.length}function je(n,e){const t=z(n),s=z(e);if(t===null)return e;if(t===s)return je(ie(n),ie(e));
vendor: 11,896 bytes, lines 2403-2434
2403throw new Error("INTERNAL ERROR: innerPath ("+e+") is not within outerPath ("+n+")")}function zl(n,e){if(en(n)!==en(e))return!1;for(let t=n.pieceNum_,s=e.pieceNum_;t<=n.pieces_.length;t++,s++)if(n.pieces_[t]!==e.pieces_[s])return!1;return!0}function it(n,e){let t=n.pieceNum_,s=e.pieceNum_;if(en(n)>en(e))return!1;for(;t<n.pieces_.length;){if(n.pieces_[t]!==e.pieces_[s])return!1;++t,++s}return!0}class rC{constructor(e,t){this.errorPrefix_=t,this.parts_=u_(e,0),this.byteLength_=Math.max(1,this.parts_.length);for(let s=0;s<this.parts_.length;s++)this.byteLength_+=fo(this.parts_[s]);d_(this)}}function oC(n,e){n.parts_.length>0&&(n.byteLength_+=1),n.parts_.push(e),n.byteLength_+=fo(e),d_(n)}function aC(n){const e=n.parts_.pop();n.byteLength_-=fo(e),n.parts_.length>0&&(n.byteLength_-=1)}function d_(n){if(n.byteLength_>Wh)throw new Error(n.errorPrefix_+"has a key path longer than "+Wh+" bytes ("+n.byteLength_+").");if(n.parts_.length>Hh)throw new Error(n.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+Hh+") or object contains a cycle "+_n(n))}function _n(n){return n.parts_.length===0?"":"in property '"+n.parts_.join(".")+"'"}/**
2404 * @license
2405 * Copyright 2017 Google LLC
2406 *
2407 * Licensed under the Apache License, Version 2.0 (the "License");
2408 * you may not use this file except in compliance with the License.
2409 * You may obtain a copy of the License at
2410 *
2411 *   http://www.apache.org/licenses/LICENSE-2.0
2412 *
2413 * Unless required by applicable law or agreed to in writing, software
2414 * distributed under the License is distributed on an "AS IS" BASIS,
2415 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2416 * See the License for the specific language governing permissions and
2417 * limitations under the License.
2418 */class Gl extends l_{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 s=!document[e];s!==this.visible_&&(this.visible_=s,this.trigger("visible",s))},!1)}static getInstance(){return new Gl}getInitialEvent(e){return N(e==="visible","Unknown event type: "+e),[this.visible_]}}/**
2419 * @license
2420 * Copyright 2017 Google LLC
2421 *
2422 * Licensed under the Apache License, Version 2.0 (the "License");
2423 * you may not use this file except in compliance with the License.
2424 * You may obtain a copy of the License at
2425 *
2426 *   http://www.apache.org/licenses/LICENSE-2.0
2427 *
2428 * Unless required by applicable law or agreed to in writing, software
2429 * distributed under the License is distributed on an "AS IS" BASIS,
2430 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2431 * See the License for the specific language governing permissions and
2432 * limitations under the License.
2433 */const Hs=1e3,lC=60*5*1e3,zh=30*1e3,cC=1.3,uC=3e4,hC="server_kill",Gh=3;class Pt extends a_{constructor(e,t,s,i,r,o,l,c){if(super(),this.repoInfo_=e,this.applicationId_=t,this.onDataUpdate_=s,this.onConnectStatus_=i,this.onServerInfoUpdate_=r,this.authTokenProvider_=o,this.appCheckTokenProvider_=l,this.authOverride_=c,this.id=Pt.nextPersistentConnectionId_++,this.log_=Oi("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_=Hs,this.maxReconnectDelay_=lC,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,c)throw new Error("Auth override specified in options, but not supported on non Node.js platforms");Gl.getInstance().on("visible",this.onVisible_,this),e.host.indexOf("fblocal")===-1&&$r.getInstance().on("online",this.onOnline_,this)}sendRequest(e,t,s){const i=++this.requestNumber_,r={r:i,a:e,b:t};this.log_(ye(r)),N(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(r),s&&(this.requestCBHash_[i]=s)}get(e){this.initConnection_();const t=new ts,i={action:"g",request:{p:e._path.toString(),q:e._queryObject},onComplete:o=>{const l=o.d;o.s==="ok"?t.resolve(l):t.reject(l)}};this.outstandingGets_.push(i),this.outstandingGetCount_++;const r=this.outstandingGets_.length-1;return this.connected_&&this.sendGet_(r),t.promise}listen(e,t,s,i){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),N(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),N(!this.listens.get(o).has(r),"listen() called twice for same path/queryId.");const l={onComplete:i,hashFn:t,query:e,tag:s};this.listens.get(o).set(r,l),this.connected_&&this.sendListen_(l)}sendGet_(e){const t=this.outstandingGets_[e];this.sendRequest("g",t.request,s=>{delete this.outstandingGets_[e],this.outstandingGetCount_--,this.outstandingGetCount_===0&&(this.outstandingGets_=[]),t.onComplete&&t.onComplete(s)})}sendListen_(e){const t=e.query,s=t._path.toString(),i=t._queryIdentifier;this.log_("Listen on "+s+" for "+i);const r={p:s},o="q";e.tag&&(r.q=t._queryObject,r.t=e.tag),r.h=e.hashFn(),this.sendRequest(o,r,l=>{const c=l.d,h=l.s;Pt.warnOnListenWarnings_(c,t),(this.listens.get(s)&&this.listens.get(s).get(i))===e&&(this.log_("listen response",l),h!=="ok"&&this.removeListen_(s,i),e.onComplete&&e.onComplete(h,c))})}static warnOnListenWarnings_(e,t){if(e&&typeof e=="object"&&Lt(e,"w")){const s=ns(e,"w");if(Array.isArray(s)&&~s.indexOf("no_index")){const i='".indexOn": "'+t._queryParams.getIndex().toString()+'"',r=t._path.toString();Je(`Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ${i} 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||Ey(e))&&(this.log_("Admin auth credential detected.  Reducing max reconnect time."),this.maxReconnectDelay_=zh)}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=vy(e)?"auth":"gauth",s={cred:e};this.authOverride_===null?s.noauth=!0:typeof this.authOverride_=="object"&&(s.authvar=this.authOverride_),this.sendRequest(t,s,i=>{const r=i.s,o=i.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,s=e.d||"error";t==="ok"?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(t,s)})}unlisten(e,t){const s=e._path.toString(),i=e._queryIdentifier;this.log_("Unlisten called for "+s+" "+i),N(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(s,i)&&this.connected_&&this.sendUnlisten_(s,i,e._queryObject,t)}sendUnlisten_(e,t,s,i){this.log_("Unlisten on "+e+" for "+t);const r={p:e},o="n";i&&(r.q=s,r.t=i),this.sendRequest(o,r)}onDisconnectPut(e,t,s){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",e,t,s):this.onDisconnectRequestQueue_.push({pathString:e,action:"o",data:t,onComplete:s})}onDisconnectMerge(e,t,s){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",e,t,s):this.onDisconnectRequestQueue_.push({pathString:e,action:"om",data:t,onComplete:s})}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,s,i){const r={p:t,d:s};this.log_("onDisconnect "+e,r),this.sendRequest(e,r,o=>{i&&setTimeout(()=>{i(o.s,o.d)},Math.floor(0))})}put(e,t,s,i){this.putInternal("p",e,t,s,i)}merge(e,t,s,i){this.putInternal("m",e,t,s,i)}putInternal(e,t,s,i,r){this.initConnection_();const o={p:t,d:s};r!==void 0&&(o.h=r),this.outstandingPuts_.push({action:e,request:o,onComplete:i}),this.outstandingPutCount_++;const l=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(l):this.log_("Buffering put: "+t)}sendPut_(e){const t=this.outstandingPuts_[e].action,s=this.outstandingPuts_[e].request,i=this.outstandingPuts_[e].onComplete;this.outstandingPuts_[e].queued=this.connected_,this.sendRequest(t,s,r=>{this.log_(t+" response",r),delete this.outstandingPuts_[e],this.outstandingPutCount_--,this.outstandingPutCount_===0&&(this.outstandingPuts_=[]),i&&i(r.s,r.d)})}reportStats(e){if(this.connected_){const t={c:e};this.log_("reportStats",t),this.sendRequest("s",t,s=>{if(s.s!=="ok"){const r=s.d;this.log_("reportStats","Error sending stats: "+r)}})}}onDataMessage_(e){if("r"in e){this.log_("from server: "+ye(e));const t=e.r,s=this.requestCBHash_[t];s&&(delete this.requestCBHash_[t],s(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):Wa("Unrecognized action received from server: "+ye(e)+`
2434Are 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){N(!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_=Hs,this.realtime_||this.scheduleConnect_(0)),this.visible_=e}onOnline_(e){e?(this.log_("Browser went online."),this.reconnectDelay_=Hs,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_>uC&&(this.reconnectDelay_=Hs),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);
2434t=Math.random()*t,this.log_("Trying to reconnect in "+t+"ms"),this.scheduleConnect_(t),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,this.reconnectDelay_*cC)}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),s=this.onRealtimeDisconnect_.bind(this),i=this.id+":"+Pt.nextConnectionId_++,r=this.lastSessionId;let o=!1,l=null;const c=function(){l?l.close():(o=!0,s())},h=function(p){N(l,"sendRequest call when we're not connected not allowed."),l.sendRequest(p)};this.realtime_={close:c,sendRequest:h};const f=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{const[p,g]=await Promise.all([this.authTokenProvider_.getToken(f),this.appCheckTokenProvider_.getToken(f)]);o?Le("getToken() completed but was canceled"):(Le("getToken() completed. Creating connection."),this.authToken_=p&&p.accessToken,this.appCheckToken_=g&&g.token,l=new sC(i,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,t,s,I=>{Je(I+" ("+this.repoInfo_.toString()+")"),this.interrupt(hC)},r))}catch(p){this.log_("Failed to get token: "+p),o||(this.repoInfo_.nodeAdmin&&Je(p),c())}}}interrupt(e){Le("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){Le("Resuming connection for reason: "+e),delete this.interruptReasons_[e],Oa(this.interruptReasons_)&&(this.reconnectDelay_=Hs,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 s;t?s=t.map(r=>$l(r)).join("$"):s="default";const i=this.removeListen_(e,s);i&&i.onComplete&&i.onComplete("permission_denied")}removeListen_(e,t){const s=new se(e).toString();let i;if(this.listens.has(s)){const r=this.listens.get(s);i=r.get(t),r.delete(t),r.size===0&&this.listens.delete(s)}else i=void 0;return i}onAuthRevoked_(e,t){Le("Auth token revoked: "+e+"/"+t),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),(e==="invalid_token"||e==="permission_denied")&&(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=Gh&&(this.reconnectDelay_=zh,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(e,t){Le("App check token revoked: "+e+"/"+t),this.appCheckToken_=null,this.forceTokenRefresh_=!0,(e==="invalid_token"||e==="permission_denied")&&(this.invalidAppCheckTokenCount_++,this.invalidAppCheckTokenCount_>=Gh&&this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&&console.log("FIREBASE: "+e.msg.replace(`
2435`,`
2436FIREBASE: `))}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+"."+Up.replace(/\./g,"-")]=1,Tl()?e["framework.cordova"]=1:_f()&&(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){const e=$r.getInstance().currentlyOnline();return Oa(this.interruptReasons_)&&e}}Pt.nextPersistentConnectionId_=0;Pt.nextConnectionId_=0;/**
2437 * @license
2438 * Copyright 2017 Google LLC
2439 *
2440 * Licensed under the Apache License, Version 2.0 (the "License");
2441 * you may not use this file except in compliance with the License.
2442 * You may obtain a copy of the License at
2443 *
2444 *   http://www.apache.org/licenses/LICENSE-2.0
2445 *
2446 * Unless required by applicable law or agreed to in writing, software
2447 * distributed under the License is distributed on an "AS IS" BASIS,
2448 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2449 * See the License for the specific language governing permissions and
2450 * limitations under the License.
2451 */class W{constructor(e,t){this.name=e,this.node=t}static Wrap(e,t){return new W(e,t)}}/**
2452 * @license
2453 * Copyright 2017 Google LLC
2454 *
2455 * Licensed under the Apache License, Version 2.0 (the "License");
2456 * you may not use this file except in compliance with the License.
2457 * You may obtain a copy of the License at
2458 *
2459 *   http://www.apache.org/licenses/LICENSE-2.0
2460 *
2461 * Unless required by applicable law or agreed to in writing, software
2462 * distributed under the License is distributed on an "AS IS" BASIS,
2463 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2464 * See the License for the specific language governing permissions and
2465 * limitations under the License.
2466 */class vo{getCompare(){return this.compare.bind(this)}indexedValueChanged(e,t){const s=new W(os,e),i=new W(os,t);return this.compare(s,i)!==0}minPost(){return W.MIN}}/**
2467 * @license
2468 * Copyright 2017 Google LLC
2469 *
2470 * Licensed under the Apache License, Version 2.0 (the "License");
2471 * you may not use this file except in compliance with the License.
2472 * You may obtain a copy of the License at
2473 *
2474 *   http://www.apache.org/licenses/LICENSE-2.0
2475 *
2476 * Unless required by applicable law or agreed to in writing, software
2477 * distributed under the License is distributed on an "AS IS" BASIS,
2478 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2479 * See the License for the specific language governing permissions and
2480 * limitations under the License.
2481 */let fr;class f_ extends vo{static get __EMPTY_NODE(){return fr}static set __EMPTY_NODE(e){fr=e}compare(e,t){return Es(e.name,t.name)}isDefinedOn(e){throw gs("KeyIndex.isDefinedOn not expected to be called.")}indexedValueChanged(e,t){return!1}minPost(){return W.MIN}maxPost(){return new W(An,fr)}makePost(e,t){return N(typeof e=="string","KeyIndex indexValue must always be a string."),new W(e,fr)}toString(){return".key"}}const Jn=new f_;/**
2482 * @license
2483 * Copyright 2017 Google LLC
2484 *
2485 * Licensed under the Apache License, Version 2.0 (the "License");
2486 * you may not use this file except in compliance with the License.
2487 * You may obtain a copy of the License at
2488 *
2489 *   http://www.apache.org/licenses/LICENSE-2.0
2490 *
2491 * Unless required by applicable law or agreed to in writing, software
2492 * distributed under the License is distributed on an "AS IS" BASIS,
2493 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2494 * See the License for the specific language governing permissions and
2495 * limitations under the License.
2496 */let pr=class{constructor(e,t,s,i,r=null){this.isReverse_=i,this.resultGenerator_=r,this.nodeStack_=[];let o=1;for(;!e.isEmpty();)if(e=e,o=t?s(e.key,t):1,i&&(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}}},Ye=class Qs{constructor(e,t,s,i,r){this.key=e,this.value=t,this.color=s??Qs.RED,this.left=i??ct.EMPTY_NODE,this.right=r??ct.EMPTY_NODE}copy(e,t,s,i,r){return new Qs(e??this.key,t??this.value,s??this.color,i??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,s){let i=this;const r=s(e,i.key);return r<0?i=i.copy(null,null,null,i.left.insert(e,t,s),null):r===0?i=i.copy(null,t,null,null,null):i=i.copy(null,null,null,null,i.right.insert(e,t,s)),i.fixUp_()}removeMin_(){if(this.left.isEmpty())return ct.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 s,i;if(s=this,t(e,s.key)<0)!s.left.isEmpty()&&!s.left.isRed_()&&!s.left.left.isRed_()&&(s=s.moveRedLeft_()),s=s.copy(null,null,null,s.left.remove(e,t),null);else{if(s.left.isRed_()&&(s=s.rotateRight_()),!s.right.isEmpty()&&!s.right.isRed_()&&!s.right.left.isRed_()&&(s=s.moveRedRight_()),t(e,s.
vendor: 1,302 bytes, line 2496
2496key)===0){if(s.right.isEmpty())return ct.EMPTY_NODE;i=s.right.min_(),s=s.copy(i.key,i.value,null,null,s.right.removeMin_())}s=s.copy(null,null,null,null,s.right.remove(e,t))}return s.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,Qs.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight_(){const e=this.copy(null,null,Qs.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+")");
2496if(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)}};Ye.RED=!0;Ye.BLACK=!1;class dC{copy(e,t,s,i,r){return this}insert(e,t,s){return new Ye(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}}let ct=class Rr{constructor(e,t=Rr.EMPTY_NODE){this.comparator_=e,this.root_=t}insert(e,t){return new Rr(this.comparator_,this.root_.insert(e,t,this.comparator_).copy(null,null,Ye.BLACK,null,null))}remove(e){return new Rr(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,Ye.BLACK,null,null))}get(e){let t,s=this.root_;for(;!s.isEmpty();){if(t=this.comparator_(e,s.key),t===0)return s.value;t<0?s=s.left:t>0&&(s=s.right)}return null}getPredecessorKey(e){let t,s=this.root_,i=null;for(;!s.isEmpty();)if(t=this.comparator_(e,s.key),t===0){if(s.left.isEmpty())return i?i.key:null;for(s=s.left;!s.right.isEmpty();)s=s.right;return s.key}else t<0?s=s.left:t>0&&(i=s,s=s.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 pr(this.root_,null,this.comparator_,!1,e)}getIteratorFrom(e,t){return new pr(this.root_,e,this.comparator_,!1,t)}getReverseIteratorFrom(e,t){return new pr(this.root_,e,this.comparator_,!0,t)}getReverseIterator(e){return new pr(this.root_,null,this.comparator_,!0,e)}};ct.EMPTY_NODE=new dC;/**
2497 * @license
2498 * Copyright 2017 Google LLC
2499 *
2500 * Licensed under the Apache License, Version 2.0 (the "License");
2501 * you may not use this file except in compliance with the License.
2502 * You may obtain a copy of the License at
2503 *
2504 *   http://www.apache.org/licenses/LICENSE-2.0
2505 *
2506 * Unless required by applicable law or agreed to in writing, software
2507 * distributed under the License is distributed on an "AS IS" BASIS,
2508 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2509 * See the License for the specific language governing permissions and
2510 * limitations under the License.
2511 */function fC(n,e){return Es(n.name,e.name)}function Kl(n,e){return Es(n,e)}/**
2512 * @license
2513 * Copyright 2017 Google LLC
2514 *
2515 * Licensed under the Apache License, Version 2.0 (the "License");
2516 * you may not use this file except in compliance with the License.
2517 * You may obtain a copy of the License at
2518 *
2519 *   http://www.apache.org/licenses/LICENSE-2.0
2520 *
2521 * Unless required by applicable law or agreed to in writing, software
2522 * distributed under the License is distributed on an "AS IS" BASIS,
2523 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2524 * See the License for the specific language governing permissions and
2525 * limitations under the License.
2526 */let Ga;function pC(n){Ga=n}const p_=function(n){return typeof n=="number"?"number:"+Hp(n):"string:"+n},__=function(n){if(n.isLeafNode()){const e=n.val();N(typeof e=="string"||typeof e=="number"||typeof e=="object"&&Lt(e,".sv"),"Priority must be a string or number.")}else N(n===Ga||n.isEmpty(),"priority of unexpected type.");N(n===Ga||n.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")};/**
2527 * @license
2528 * Copyright 2017 Google LLC
2529 *
2530 * Licensed under the Apache License, Version 2.0 (the "License");
2531 * you may not use this file except in compliance with the License.
2532 * You may obtain a copy of the License at
2533 *
2534 *   http://www.apache.org/licenses/LICENSE-2.0
2535 *
2536 * Unless required by applicable law or agreed to in writing, software
2537 * distributed under the License is distributed on an "AS IS" BASIS,
2538 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2539 * See the License for the specific language governing permissions and
2540 * limitations under the License.
2541 */let Kh;class Te{constructor(e,t=Te.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=t,this.lazyHash_=null,N(this.value_!==void 0&&this.value_!==null,"LeafNode shouldn't be created with null/undefined value."),__(this.priorityNode_)}static set __childrenNodeConstructor(e){Kh=e}static get __childrenNodeConstructor(){return Kh}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new Te(this.value_,e)}getImmediateChild(e){return e===".priority"?this.priorityNode_:Te.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return G(e)?this:z(e)===".priority"?this.priorityNode_:Te.__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:Te.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,t).updatePriority(this.priorityNode_)}updateChild(e,t){const s=z(e);return s===null?t:t.isEmpty()&&s!==".priority"?this:(N(s!==".priority"||en(e)===1,".priority must be the last token in a path"),this.updateImmediateChild(s,Te.__childrenNodeConstructor.EMPTY_NODE.updateChild(ie(e),t)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(e,t){return!1}
2541val(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:"+p_(this.priorityNode_.val())+":");const t=typeof this.value_;e+=t+":",t==="number"?e+=Hp(this.value_):e+=this.value_,this.lazyHash_=qp(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===Te.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof Te.__childrenNodeConstructor?-1:(N(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){const t=typeof e.value_,s=typeof this.value_,i=Te.VALUE_TYPE_ORDER.indexOf(t),r=Te.VALUE_TYPE_ORDER.indexOf(s);return N(i>=0,"Unknown leaf type: "+t),N(r>=0,"Unknown leaf type: "+s),i===r?s==="object"?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:r-i}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}}Te.VALUE_TYPE_ORDER=["object","boolean","number","string"];/**
2542 * @license
2543 * Copyright 2017 Google LLC
2544 *
2545 * Licensed under the Apache License, Version 2.0 (the "License");
2546 * you may not use this file except in compliance with the License.
2547 * You may obtain a copy of the License at
2548 *
2549 *   http://www.apache.org/licenses/LICENSE-2.0
2550 *
2551 * Unless required by applicable law or agreed to in writing, software
2552 * distributed under the License is distributed on an "AS IS" BASIS,
2553 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2554 * See the License for the specific language governing permissions and
2555 * limitations under the License.
2556 */let g_,m_;function _C(n){g_=n}function gC(n){m_=n}class mC extends vo{compare(e,t){const s=e.node.getPriority(),i=t.node.getPriority(),r=s.compareTo(i);return r===0?Es(e.name,t.name):r}isDefinedOn(e){return!e.getPriority().isEmpty()}indexedValueChanged(e,t){return!e.getPriority().equals(t.getPriority())}minPost(){return W.MIN}maxPost(){return new W(An,new Te("[PRIORITY-POST]",m_))}makePost(e,t){const s=g_(e);return new W(t,new Te("[PRIORITY-POST]",s))}toString(){return".priority"}}const ue=new mC;/**
2557 * @license
2558 * Copyright 2017 Google LLC
2559 *
2560 * Licensed under the Apache License, Version 2.0 (the "License");
2561 * you may not use this file except in compliance with the License.
2562 * You may obtain a copy of the License at
2563 *
2564 *   http://www.apache.org/licenses/LICENSE-2.0
2565 *
2566 * Unless required by applicable law or agreed to in writing, software
2567 * distributed under the License is distributed on an "AS IS" BASIS,
2568 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2569 * See the License for the specific language governing permissions and
2570 * limitations under the License.
2571 */const yC=Math.log(2);class vC{constructor(e){const t=r=>parseInt(Math.log(r)/yC,10),s=r=>parseInt(Array(r+1).join("1"),2);this.count=t(e+1),this.current_=this.count-1;const i=s(this.count);this.bits_=e+1&i}nextBitIsOne(){const e=!(this.bits_&1<<this.current_);return this.current_--,e}}const jr=function(n,e,t,s){n.sort(e);const i=function(c,h){const f=h-c;let p,g;if(f===0)return null;if(f===1)return p=n[c],g=t?t(p):p,new Ye(g,p.node,Ye.BLACK,null,null);{const I=parseInt(f/2,10)+c,S=i(c,I),k=i(I+1,h);return p=n[I],g=t?t(p):p,new Ye(g,p.node,Ye.BLACK,S,k)}},r=function(c){let h=null,f=null,p=n.length;const g=function(S,k){const b=p-S,B=p;p-=S;const H=i(b+1,B),V=n[b],$=t?t(V):V;I(new Ye($,V.node,k,null,H))},I=function(S){h?(h.left=S,h=S):(f=S,h=S)};for(let S=0;S<c.count;++S){const k=c.nextBitIsOne(),b=Math.pow(2,c.count-(S+1));k?g(b,Ye.BLACK):(g(b,Ye.BLACK),g(b,Ye.RED))}return f},o=new vC(n.length),l=r(o);return new ct(s||e,l)};/**
2572 * @license
2573 * Copyright 2017 Google LLC
2574 *
2575 * Licensed under the Apache License, Version 2.0 (the "License");
2576 * you may not use this file except in compliance with the License.
2577 * You may obtain a copy of the License at
2578 *
2579 *   http://www.apache.org/licenses/LICENSE-2.0
2580 *
2581 * Unless required by applicable law or agreed to in writing, softw
2581are
2582 * distributed under the License is distributed on an "AS IS" BASIS,
2583 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2584 * See the License for the specific language governing permissions and
2585 * limitations under the License.
2586 */let Ta;const Un={};class bt{constructor(e,t){this.indexes_=e,this.indexSet_=t}static get Default(){return N(Un&&ue,"ChildrenNode.ts has not been loaded"),Ta=Ta||new bt({".priority":Un},{".priority":ue}),Ta}get(e){const t=ns(this.indexes_,e);if(!t)throw new Error("No index defined for "+e);return t instanceof ct?t:null}hasIndex(e){return Lt(this.indexSet_,e.toString())}addIndex(e,t){N(e!==Jn,"KeyIndex always exists and isn't meant to be added to the IndexMap.");const s=[];let i=!1;const r=t.getIterator(W.Wrap);let o=r.getNext();for(;o;)i=i||e.isDefinedOn(o.node),s.push(o),o=r.getNext();let l;i?l=jr(s,e.getCompare()):l=Un;const c=e.toString(),h=Object.assign({},this.indexSet_);h[c]=e;const f=Object.assign({},this.indexes_);return f[c]=l,new bt(f,h)}addToIndexes(e,t){const s=Or(this.indexes_,(i,r)=>{const o=ns(this.indexSet_,r);if(N(o,"Missing index implementation for "+r),i===Un)if(o.isDefinedOn(e.node)){const l=[],c=t.getIterator(W.Wrap);let h=c.getNext();for(;h;)h.name!==e.name&&l.push(h),h=c.getNext();return l.push(e),jr(l,o.getCompare())}else return Un;else{const l=t.get(e.name);let c=i;return l&&(c=c.remove(new W(e.name,l))),c.insert(e,e.node)}});return new bt(s,this.indexSet_)}removeFromIndexes(e,t){const s=Or(this.indexes_,i=>{if(i===Un)return i;{const r=t.get(e.name);return r?i.remove(new W(e.name,r)):i}});return new bt(s,this.indexSet_)}}/**
2587 * @license
2588 * Copyright 2017 Google LLC
2589 *
2590 * Licensed under the Apache License, Version 2.0 (the "License");
2591 * you may not use this file except in compliance with the License.
2592 * You may obtain a copy of the License at
2593 *
2594 *   http://www.apache.org/licenses/LICENSE-2.0
2595 *
2596 * Unless required by applicable law or agreed to in writing, software
2597 * distributed under the License is distributed on an "AS IS" BASIS,
2598 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2599 * See the License for the specific language governing permissions and
2600 * limitations under the License.
2601 */let Ws;class L{constructor(e,t,s){this.children_=e,this.priorityNode_=t,this.indexMap_=s,this.lazyHash_=null,this.priorityNode_&&__(this.priorityNode_),this.children_.isEmpty()&&N(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}static get EMPTY_NODE(){return Ws||(Ws=new L(new ct(Kl),null,bt.Default))}isLeafNode(){return!1}getPriority(){return this.priorityNode_||Ws}updatePriority(e){return this.children_.isEmpty()?this:new L(this.children_,e,this.indexMap_)}getImmediateChild(e){if(e===".priority")return this.getPriority();{const t=this.children_.get(e);return t===null?Ws:t}}getChild(e){const t=z(e);return t===null?this:this.getImmediateChild(t).getChild(ie(e))}hasChild(e){return this.children_.get(e)!==null}updateImmediateChild(e,t){if(N(t,"We should always be passing snapshot nodes"),e===".priority")return this.updatePriority(t);{const s=new W(e,t);let i,r;t.isEmpty()?(i=this.children_.remove(e),r=this.indexMap_.removeFromIndexes(s,this.children_)):(i=this.children_.insert(e,t),r=this.indexMap_.addToIndexes(s,this.children_));const o=i.isEmpty()?Ws:this.priorityNode_;return new L(i,o,r)}}updateChild(e,t){const s=z(e);if(s===null)return t;{N(z(e)!==".priority"||en(e)===1,".priority must be the last token in a path");const i=this.getImmediateChild(s).updateChild(ie(e),t);return this.updateImmediateChild(s,i)}}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(e){if(this.isEmpty())return null;const t={};let s=0,i=0,r=!0;if(this.forEachChild(ue,(o,l)=>{t[o]=l.val(e),s++,r&&L.INTEGER_REGEXP_.test(o)?i=Math.max(i,Number(o)):r=!1}),!e&&r&&i<2*s){const o=[];for(const l in t)o[l]=t[l];return o}else return e&&!this.getPriority().isEmpty()&&(t[".priority"]=this.getPriority().val()),t}hash(){if(this.lazyHash_===null){let e="";
2601this.getPriority().isEmpty()||(e+="priority:"+p_(this.getPriority().val())+":"),this.forEachChild(ue,(t,s)=>{const i=s.hash();i!==""&&(e+=":"+t+":"+i)}),this.lazyHash_=e===""?"":qp(e)}return this.lazyHash_}getPredecessorChildName(e,t,s){const i=this.resolveIndex_(s);if(i){const r=i.getPredecessorKey(new W(e,t));return r?r.name:null}else return this.children_.getPredecessorKey(e)}getFirstChildName(e){const t=this.resolveIndex_(e);if(t){const s=t.minKey();return s&&s.name}else return this.children_.minKey()}getFirstChild(e){const t=this.getFirstChildName(e);return t?new W(t,this.children_.get(t)):null}getLastChildName(e){const t=this.resolveIndex_(e);if(t){const s=t.maxKey();return s&&s.name}else return this.children_.maxKey()}getLastChild(e){const t=this.getLastChildName(e);return t?new W(t,this.children_.get(t)):null}forEachChild(e,t){const s=this.resolveIndex_(e);return s?s.inorderTraversal(i=>t(i.name,i.node)):this.children_.inorderTraversal(t)}getIterator(e){return this.getIteratorFrom(e.minPost(),e)}getIteratorFrom(e,t){const s=this.resolveIndex_(t);if(s)return s.getIteratorFrom(e,i=>i);{const i=this.children_.getIteratorFrom(e.name,W.Wrap);let r=i.peek();for(;r!=null&&t.compare(r,e)<0;)i.getNext(),r=i.peek();return i}}getReverseIterator(e){return this.getReverseIteratorFrom(e.maxPost(),e)}getReverseIteratorFrom(e,t){const s=this.resolveIndex_(t);if(s)return s.getReverseIteratorFrom(e,i=>i);{const i=this.children_.getReverseIteratorFrom(e.name,W.Wrap);let r=i.peek();for(;r!=null&&t.compare(r,e)>0;)i.getNext(),r=i.peek();return i}}compareTo(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===Mi?-1:0}withIndex(e){if(e===Jn||this.indexMap_.hasIndex(e))return this;{const t=this.indexMap_.addIndex(e,this.children_);return new L(this.children_,this.priorityNode_,t)}}isIndexed(e){return e===Jn||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 s=this.getIterator(ue),i=t.getIterator(ue);let r=s.getNext(),o=i.getNext();for(;r&&o;){if(r.name!==o.name||!r.node.equals(o.node))return!1;r=s.getNext(),o=i.getNext()}return r===null&&o===null}else return!1;else return!1}}resolveIndex_(e){return e===Jn?null:this.indexMap_.get(e.toString())}}L.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;class EC extends L{constructor(){super(new ct(Kl),L.EMPTY_NODE,bt.Default)}compareTo(e){return e===this?0:1}equals(e){return e===this}getPriority(){return this}getImmediateChild(e){return L.EMPTY_NODE}isEmpty(){return!1}}const Mi=new EC;Object.defineProperties(W,{MIN:{value:new W(os,L.EMPTY_NODE)},MAX:{value:new W(An,Mi)}});f_.__EMPTY_NODE=L.EMPTY_NODE;Te.__childrenNodeConstructor=L;pC(Mi);gC(Mi);/**
2602 * @license
2603 * Copyright 2017 Google LLC
2604 *
2605 * Licensed under the Apache License, Version 2.0 (the "License");
2606 * you may not use this file except in compliance with the License.
2607 * You may obtain a copy of the License at
2608 *
2609 *   http://www.apache.org/licenses/LICENSE-2.0
2610 *
2611 * Unless required by applicable law or agreed to in writing, software
2612 * distributed under the License is distributed on an "AS IS" BASIS,
2613 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2614 * See the License for the specific language governing permissions and
2615 * limitations under the License.
2616 */const TC=!0;function Ae(n,e=null){if(n===null)return L.EMPTY_NODE;if(typeof n=="object"&&".priority"in n&&(e=n[".priority"]),N(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 Te(t,Ae(e))}if(!(n instanceof Array)&&TC){const t=[];let s=!1;if(Ke(n,(o,l)=>{if(o.substring(0,1)!=="."){const c=Ae(l);c.isEmpty()||(s=s||!c.getPriority().isEmpty(),t.push(new W(o,c)))}}),t.length===0)return L.EMPTY_NODE;const r=jr(t,fC,o=>o.name,Kl);if(s){const o=jr(t,ue.getCompare());return new L(r,Ae(e),new bt({".priority":o},{".priority":ue}))}else return new L(r,Ae(e),bt.Default)}else{let t=L.EMPTY_NODE;return Ke(n,(s,i)=>{if(Lt(n,s)&&s.substring(0,1)!=="."){const r=Ae(i);(r.isLeafNode()||!r.isEmpty())&&(t=t.updateImmediateChild(s,r))}}),t.updatePriority(Ae(e))}}_C(Ae);/**
2617 * @license
2618 * Copyright 2017 Google LLC
2619 *
2620 * Licensed under the Apache License, Version 2.0 (the "License");
2621 * you may not use this file except in compliance with the License.
2622 * You may obtain a copy of the License at
2623 *
2624 *   http://www.apache.org/licenses/LICENSE-2.0
2625 *
2626 * Unless required by applicable law or agreed to in writing, software
2627 * distributed under the License is distributed on an "AS IS" BASIS,
2628 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2629 * See the License for the specific language governing permissions and
2630 * limitations under the License.
2631 */class IC extends vo{constructor(e){super(),this.indexPath_=e,N(!G(e)&&z(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 s=this.extractChild(e.node),i=this.extractChild(t.node),r=s.compareTo(i);return r===0?Es(e.name,t.name):r}makePost(e,t){const s=Ae(e),i=L.EMPTY_NODE.updateChild(this.indexPath_,s);return new W(t,i)}maxPost(){const e=L.EMPTY_NODE.updateChild(this.indexPath_,Mi);return new W(An,e)}toString(){return u_(this.indexPath_,0).join("/")}}/**
2632 * @license
2633 * Copyright 2017 Google LLC
2634 *
2635 * Licensed under the Apache License, Version 2.0 (the "License");
2636 * you may not use this file except in compliance with the License.
2637 * You may obtain a copy of the License at
2638 *
2639 *   http://www.apache.org/licenses/LICENSE-2.0
2640 *
2641 * Unless required by applicable law or agreed to in writing, software
2642 * distributed under the License is distributed on an "AS IS" BASIS,
2643 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2644 * See the License for the specific language governing permissions and
2645 * limitations under the License.
2646 */class wC extends vo{compare(e,t){const s=e.node.compareTo(t.node);return s===0?Es(e.name,t.name):s}isDefinedOn(e){return!0}indexedValueChanged(e,t){return!e.equals(t)}minPost(){return W.MIN}maxPost(){return W.MAX}makePost(e,t){const s=Ae(e);return new W(t,s)}toString(){return".value"}}const CC=new wC;/**
2647 * @license
2648 * Copyright 2017 Google LLC
2649 *
2650 * Licensed under the Apache License, Version 2.0 (the "License");
2651 * you may not use this file except in compliance with the License.
2652 * You may obtain a copy of the License at
2653 *
2654 *   http://www.apache.org/licenses/LICENSE-2.0
2655 *
2656 * Unless required by applicable law or agreed to in writing, software
2657 * distributed under the License is distributed on an "AS IS" BASIS,
2658 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2659 * See the License for the specific language governing permissions and
2660 * limitations under the License.
2661 */function y_(n){return{type:"value",snapshotNode:n}}function as(n,e){return{type:"child_added",snapshotNode:e,childName:n}}function yi(n,e){return{type:"child_removed",snapshotNode:e,childName:n}}function vi(n,e,t){return{type:"child_changed",snapshotNode:e,childName:n,oldSnap:t}}function AC(n,e){return{type:"child_moved",snapshotNode:e,childName:n}}/**
2662 * @license
2663 * Copyright 2017 Google LLC
2664 *
2665 * Licensed under the Apache License, Version 2.0 (the "License");
2666 * you may not use this file except in compliance with the License.
2667 * You may obtain a copy of the License at
2668 *
2669 *   http://www.apache.org/licenses/LICENSE-2.0
2670 *
2671 * Unless required by applicable law or agreed to in writing, software
2672 * distributed under the License is distributed on an "AS IS" BASIS,
2673 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2674 * See the License for the specific language governing permissions and
2675 * limitations under the License.
2676 */class Ql{constructor(e){this.index_=e}updateChild(e,t,s,i,r,o){N(e.isIndexed(this.index_),"A node must be indexed if only a child is updated");const l=e.getImmediateChild(t);return l.getChild(i).equals(s.getChild(i))&&l.isEmpty()===s.isEmpty()||(o!=null&&(s.isEmpty()?e.hasChild(t)?o.trackChildChange(yi(t,l)):N(e.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):l.isEmpty()?o.trackChildChange(as(t,s)):o.trackChildChange(vi(t,s,l))),e.isLeafNode()&&s.isEmpty())?e:e.updateImmediateChild(t,s).withIndex(this.index_)}updateFullNode(e,t,s){return s!=null&&(e.isLeafNode()||e.forEachChild(ue,(i,r)=>{t.hasChild(i)||s.trackChildChange(yi(i,r))}),t.isLeafNode()||t.forEachChild(ue,(i,r)=>{if(e.hasChild(i)){const o=e.getImmediateChild(i);o.equals(r)||s.trackChildChange(vi(i,r,o))}else s.trackChildChange(as(i,r))})),t.withIndex(this.index_)}updatePriority(e,t){return e.isEmpty()?L.EMPTY_NODE:e.updatePriority(t)}filtersNodes(){return!1}getIndexedFilter(){return this}getIndex(){return this.index_}}/**
2677 * @license
2678 * Copyright 2017 Google LLC
2679 *
2680 * Licensed under the Apache License, Version 2.0 (the "License");
2681 * you may not use this file except in compliance with the License.
2682 * You may obtain a copy of the License at
2683 *
2684 *   http://www.apache.org/licenses/LICENSE-2.0
2685 *
2686 * Unless required by applicable law or agreed to in writing, software
2687 * distributed under the License is distributed on an "AS IS" BASIS,
2688 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2689 * See the License for the specific language governing permissions and
2690 * limitations under the License.
2691 */class Ei{constructor(e){this.indexedFilter_=new Ql(e.getIndex()),this.index_=e.getIndex(),this.startPost_=Ei.getStartPost_(e),this.endPost_=Ei.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,s=this.endIsInclusive_?this.index_.compare(e,this.getEndPost())<=0:this.index_.compare(e,this.getEndPost())<0;return t&&s}updateChild(e,t,s,i,r,o){return this.matches(new W(t,s))||(s=L.EMPTY_NODE),this.indexedFilter_.updateChild(e,t,s,i,r,o)}updateFullNode(e,t,s){t.isLeafNode()&&(t=L.EMPTY_NODE);let i=t.withIndex(this.index_);i=i.updatePriority(L.EMPTY_NODE);const r=this;return t.forEachChild(ue,(o,l)=>{r.matches(new W(o,l))||(i=i.updateImmediateChild(o,L.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(e,i,s)}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()}}/**
2692 * @license
2693 * Copyright 2017 Google LLC
2694 *
2695 * Licensed under the Apache License, Version 2.0 (the "License");
2696 * you may not use this file except in compliance with the License.
2697 * You may obtain a copy of the License at
2698 *
2699 *   http://www.apache.org/licenses/LICENSE-2.0
2700 *
2701 * Unless required by applicable law or agreed to in writing, software
2702 * distributed under the License is distributed on an "AS IS" BASIS,
2703 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2704 * See the License for the specific language governing permissions and
2705 * limitations under the License.
2706 */class RC{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 s=this.index_.compare(this.rangedFilter_.getStartPost(),t);return this.startIsInclusive_?s<=0:s<0},this.withinEndPost=t=>{const s=this.index_.compare(t,this.rangedFilter_.getEndPost());return this.endIsInclusive_?s<=0:s<0},this.rangedFilter_=new Ei(e),this.index_=e.getIndex(),this.limit_=e.getLimit(),this.reverse_=!e.isViewFromLeft(),this.startIsInclusive_=!e.startAfterSet_,this.endIsInclusive_=!e.endBeforeSet_}updateChild(e,t,s,i,r,o){return this.rangedFilter_.matches(new W(t,s))||(s=L.EMPTY_NODE),e.getImmediateChild(t).equals(s)?e:e.numChildren()<this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(e,t,s,i,r,o):this.fullLimitUpdateChild_(e,t,s,r,o)}updateFullNode(e,t,s){let i;if(t.isLeafNode()||t.isEmpty())i=L.EMPTY_NODE.withIndex(this.index_);else if(this.limit_*2<t.numChildren()&&t.isIndexed(this.index_)){i=L.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 l=r.getNext();if(this.withinDirectionalStart(l))if(this.withinDirectionalEnd(l))i=i.updateImmediateChild(l.name,l.node),o++;else break;else continue}}else{i=t.withIndex(this.index_),i=i.updatePriority(L.EMPTY_NODE);let r;this.reverse_?r=i.getReverseIterator(this.index_):r=i.getIterator(this.index_);let o=0;for(;r.hasNext();){const l=r.getNext();o<this.limit_&&this.withinDirectionalStart(l)&&this.withinDirectionalEnd(l)?o++:i=i.updateImmediateChild(l.name,L.EMPTY_NODE)}}return this.rangedFilter_.getIndexedFilter().updateFullNode(e,i,s)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.rangedFilter_.getIndexedFilter()}getIndex(){return this.index_}
2706fullLimitUpdateChild_(e,t,s,i,r){let o;if(this.reverse_){const p=this.index_.getCompare();o=(g,I)=>p(I,g)}else o=this.index_.getCompare();const l=e;N(l.numChildren()===this.limit_,"");const c=new W(t,s),h=this.reverse_?l.getFirstChild(this.index_):l.getLastChild(this.index_),f=this.rangedFilter_.matches(c);if(l.hasChild(t)){const p=l.getImmediateChild(t);let g=i.getChildAfterChild(this.index_,h,this.reverse_);for(;g!=null&&(g.name===t||l.hasChild(g.name));)g=i.getChildAfterChild(this.index_,g,this.reverse_);const I=g==null?1:o(g,c);if(f&&!s.isEmpty()&&I>=0)return r!=null&&r.trackChildChange(vi(t,s,p)),l.updateImmediateChild(t,s);{r!=null&&r.trackChildChange(yi(t,p));const k=l.updateImmediateChild(t,L.EMPTY_NODE);return g!=null&&this.rangedFilter_.matches(g)?(r!=null&&r.trackChildChange(as(g.name,g.node)),k.updateImmediateChild(g.name,g.node)):k}}else return s.isEmpty()?e:f&&o(h,c)>=0?(r!=null&&(r.trackChildChange(yi(h.name,h.node)),r.trackChildChange(as(t,s))),l.updateImmediateChild(t,s).updateImmediateChild(h.name,L.EMPTY_NODE)):e}}/**
2707 * @license
2708 * Copyright 2017 Google LLC
2709 *
2710 * Licensed under the Apache License, Version 2.0 (the "License");
2711 * you may not use this file except in compliance with the License.
2712 * You may obtain a copy of the License at
2713 *
2714 *   http://www.apache.org/licenses/LICENSE-2.0
2715 *
2716 * Unless required by applicable law or agreed to in writing, software
2717 * distributed under the License is distributed on an "AS IS" BASIS,
2718 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2719 * See the License for the specific language governing permissions and
2720 * limitations under the License.
2721 */class Yl{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_=ue}hasStart(){return this.startSet_}isViewFromLeft(){return this.viewFrom_===""?this.startSet_:this.viewFrom_==="l"}getIndexStartValue(){return N(this.startSet_,"Only valid if start has been set"),this.indexStartValue_}getIndexStartName(){return N(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:os}hasEnd(){return this.endSet_}getIndexEndValue(){return N(this.endSet_,"Only valid if end has been set"),this.indexEndValue_}getIndexEndName(){return N(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:An}hasLimit(){return this.limitSet_}hasAnchoredLimit(){return this.limitSet_&&this.viewFrom_!==""}getLimit(){return N(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_===ue}copy(){const e=new Yl;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 SC(n){return n.loadsAllData()?new Ql(n.getIndex()):n.hasLimit()?new RC(n):new Ei(n)}function Qh(n){const e={};if(n.isDefault())return e;let t;if(n.index_===ue?t="$priority":n.index_===CC?t="$value":n.index_===Jn?t="$key":(N(n.index_ instanceof IC,"Unrecognized index type!"),t=n.index_.toString()),e.orderBy=ye(t),n.startSet_){const s=n.startAfterSet_?"startAfter":"startAt";e[s]=ye(n.indexStartValue_),n.startNameSet_&&(e[s]+=","+ye(n.indexStartName_))}if(n.endSet_){const s=n.endBeforeSet_?"endBefore":"endAt";e[s]=ye(n.indexEndValue_),n.endNameSet_&&(e[s]+=","+ye(n.indexEndName_))}return n.limitSet_&&(n.isViewFromLeft()?e.limitToFirst=n.limit_:e.limitToLast=n.limit_),e}function Yh(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_!==ue&&(e.i=n.index_.toString()),e}/**
2722 * @license
2723 * Copyright 2017 Google LLC
2724 *
2725 * Licensed under the Apache License, Version 2.0 (the "License");
2726 * you may not use this file except in compliance with the License.
2727 * You may obtain a copy of the License at
2728 *
2729 *   http://www.apache.org/licenses/LICENSE-2.0
2730 *
2731 * Unless required by applicable law or agreed to in writing, software
2732 * distributed under the License is distributed on an "AS IS" BASIS,
2733 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2734 * See the License for the specific language governing permissions and
2735 * limitations under the License.
2736 */class Hr extends a_{constructor(e,t,s,i){super(),this.repoInfo_=e,this.onDataUpdate_=t,this.authTokenProvider_=s,this.appCheckTokenProvider_=i,this.log_=Oi("p:rest:"),this.listens_={}}reportStats(e){throw new Error("Method not implemented.")}static getListenId_(e,t){return t!==void 0?"tag$"+t:(N(e._queryParams.isDefault(),"should have a tag if it's not a default query."),e._path.toString())}listen(e,t,s,i){const r=e._path.toString();this.log_("Listen called for "+r+" "+e._queryIdentifier);const o=Hr.getListenId_(e,s),l={};this.listens_[o]=l;const c=Qh(e._queryParams);this.restRequest_(r+".json",c,(h,f)=>{let p=f;if(h===404&&(p=null,h=null),h===null&&this.onDataUpdate_(r,p,!1,s),ns(this.listens_,o)===l){let g;h?h===401?g="permission_denied":g="rest_error:"+h:g="ok",i(g,null)}})}unlisten(e,t){const s=Hr.getListenId_(e,t);delete this.listens_[s]}get(e){const t=Qh(e._queryParams),s=e._path.toString(),i=new ts;return this.restRequest_(s+".json",t,(r,o)=>{let l=o;r===404&&(l=null,r=null),r===null?(this.onDataUpdate_(s,l,!1,null),i.resolve(l)):i.reject(new Error(l))}),i.promise}refreshAuthToken(e){}restRequest_(e,t={},s){return t.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then(([i,r])=>{i&&i.accessToken&&(t.auth=i.accessToken),r&&r.token&&(t.ac=r.token);const o=(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host+e+"?ns="+this.repoInfo_.namespace+ms(t);this.log_("Sending REST request for "+o);const l=new XMLHttpRequest;l.onreadystatechange=()=>{if(s&&l.readyState===4){this.log_("REST Response for "+o+" received. status:",l.status,"response:",l.responseText);let c=null;if(l.status>=200&&l.status<300){try{c=hi(l.responseText)}catch{Je("Failed to parse JSON response for "+o+": "+l.responseText)}s(null,c)}else l.status!==401&&l.status!==404&&Je("Got unsuccessful REST response for "+o+" Status: "+l.status),s(l.status);s=null}},l.open("GET",o,!0),l.send()})}}/**
2737 * @license
2738 * Copyright 2017 Google LLC
2739 *
2740 * Licensed under the Apache License, Version 2.0 (the "License");
2741 * you may not use this file except in compliance with the License.
2742 * You may obtain a copy of the License at
2743 *
2744 *   http://www.apache.org/licenses/LICENSE-2.0
2745 *
2746 * Unless required by applicable law or agreed to in writing, software
2747 * distributed under the License is distributed on an "AS IS" BASIS,
2748 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2749 * See the License for the specific language governing permissions and
2750 * limitations under the License.
2751 */class bC{constructor(){this.rootNode_=L.EMPTY_NODE}getNode(e){return this.rootNode_.getChild(e)}updateSnapshot(e,t){this.rootNode_=this.rootNode_.updateChild(e,t)}}/**
2752 * @license
2753 * Copyright 2017 Google LLC
2754 *
2755 * Licensed under the Apache License, Version 2.0 (the "License");
2756 * you may not use this file except in compliance with the License.
2757 * You may obtain a copy of the License at
2758 *
2759 *   http://www.apache.org/licenses/LICENSE-2.0
2760 *
2761 * Unless required by applicable law or agreed to in writing, software
2762 * distributed under the License is distributed on an "AS IS" BASIS,
2763 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2764 * See the License for the specific language governing permissions and
2765 * limitations under the License.
2766 */function Wr(){return{value:null,children:new Map}}function v_(n,e,t){if(G(e))n.value=t,n.children.clear();else if(n.value!==null)n.value=n.value.updateChild(e,t);else{const s=z(e);n.children.has(s)||n.children.set(s,Wr());const i=n.children.get(s);e=ie(e),v_(i,e,t)}}function Ka(n,e,t){n.value!==null?t(e,n.value):PC(n,(s,i)=>{const r=new se(e.toString()+"/"+s);Ka(i,r,t)})}
2766function PC(n,e){n.children.forEach((t,s)=>{e(s,t)})}/**
2767 * @license
2768 * Copyright 2017 Google LLC
2769 *
2770 * Licensed under the Apache License, Version 2.0 (the "License");
2771 * you may not use this file except in compliance with the License.
2772 * You may obtain a copy of the License at
2773 *
2774 *   http://www.apache.org/licenses/LICENSE-2.0
2775 *
2776 * Unless required by applicable law or agreed to in writing, software
2777 * distributed under the License is distributed on an "AS IS" BASIS,
2778 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2779 * See the License for the specific language governing permissions and
2780 * limitations under the License.
2781 */class kC{constructor(e){this.collection_=e,this.last_=null}get(){const e=this.collection_.get(),t=Object.assign({},e);return this.last_&&Ke(this.last_,(s,i)=>{t[s]=t[s]-i}),this.last_=e,t}}/**
2782 * @license
2783 * Copyright 2017 Google LLC
2784 *
2785 * Licensed under the Apache License, Version 2.0 (the "License");
2786 * you may not use this file except in compliance with the License.
2787 * You may obtain a copy of the License at
2788 *
2789 *   http://www.apache.org/licenses/LICENSE-2.0
2790 *
2791 * Unless required by applicable law or agreed to in writing, software
2792 * distributed under the License is distributed on an "AS IS" BASIS,
2793 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2794 * See the License for the specific language governing permissions and
2795 * limitations under the License.
2796 */const Xh=10*1e3,NC=30*1e3,DC=5*60*1e3;class OC{constructor(e,t){this.server_=t,this.statsToReport_={},this.statsListener_=new kC(e);const s=Xh+(NC-Xh)*Math.random();ni(this.reportStats_.bind(this),Math.floor(s))}reportStats_(){const e=this.statsListener_.get(),t={};let s=!1;Ke(e,(i,r)=>{r>0&&Lt(this.statsToReport_,i)&&(t[i]=r,s=!0)}),s&&this.server_.reportStats(t),ni(this.reportStats_.bind(this),Math.floor(Math.random()*2*DC))}}/**
2797 * @license
2798 * Copyright 2017 Google LLC
2799 *
2800 * Licensed under the Apache License, Version 2.0 (the "License");
2801 * you may not use this file except in compliance with the License.
2802 * You may obtain a copy of the License at
2803 *
2804 *   http://www.apache.org/licenses/LICENSE-2.0
2805 *
2806 * Unless required by applicable law or agreed to in writing, software
2807 * distributed under the License is distributed on an "AS IS" BASIS,
2808 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2809 * See the License for the specific language governing permissions and
2810 * limitations under the License.
2811 */var rt;(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"})(rt||(rt={}));function E_(){return{fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}function Xl(){return{fromUser:!1,fromServer:!0,queryId:null,tagged:!1}}function Jl(n){return{fromUser:!1,fromServer:!0,queryId:n,tagged:!0}}/**
2812 * @license
2813 * Copyright 2017 Google LLC
2814 *
2815 * Licensed under the Apache License, Version 2.0 (the "License");
2816 * you may not use this file except in compliance with the License.
2817 * You may obtain a copy of the License at
2818 *
2819 *   http://www.apache.org/licenses/LICENSE-2.0
2820 *
2821 * Unless required by applicable law or agreed to in writing, software
2822 * distributed under the License is distributed on an "AS IS" BASIS,
2823 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2824 * See the License for the specific language governing permissions and
2825 * limitations under the License.
2826 */class zr{constructor(e,t,s){this.path=e,this.affectedTree=t,this.revert=s,this.type=rt.ACK_USER_WRITE,this.source=E_()}operationForChild(e){if(G(this.path)){if(this.affectedTree.value!=null)return N(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{const t=this.affectedTree.subtree(new se(e));return new zr(Z(),t,this.revert)}}else return N(z(this.path)===e,"operationForChild called for unrelated child."),new zr(ie(this.path),this.affectedTree,this.revert)}}/**
2827 * @license
2828 * Copyright 2017 Google LLC
2829 *
2830 * Licensed under the Apache License, Version 2.0 (the "License");
2831 * you may not use this file except in compliance with the License.
2832 * You may obtain a copy of the License at
2833 *
2834 *   http://www.apache.org/licenses/LICENSE-2.0
2835 *
2836 * Unless required by applicable law or agreed to in writing, software
2837 * distributed under the License is distributed on an "AS IS" BASIS,
2838 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2839 * See the License for the specific language governing permissions and
2840 * limitations under the License.
2841 */class Ti{constructor(e,t){this.source=e,this.path=t,this.type=rt.LISTEN_COMPLETE}operationForChild(e){return G(this.path)?new Ti(this.source,Z()):new Ti(this.source,ie(this.path))}}/**
2842 * @license
2843 * Copyright 2017 Google LLC
2844 *
2845 * Licensed under the Apache License, Version 2.0 (the "License");
2846 * you may not use this file except in compliance with the License.
2847 * You may obtain a copy of the License at
2848 *
2849 *   http://www.apache.org/licenses/LICENSE-2.0
2850 *
2851 * Unless required by applicable law or agreed to in writing, software
2852 * distributed under the License is distributed on an "AS IS" BASIS,
2853 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2854 * See the License for the specific language governing permissions and
2855 * limitations under the License.
2856 */class Rn{constructor(e,t,s){this.source=e,this.path=t,this.snap=s,this.type=rt.OVERWRITE}operationForChild(e){return G(this.path)?new Rn(this.source,Z(),this.snap.getImmediateChild(e)):new Rn(this.source,ie(this.path),this.snap)}}/**
2857 * @license
2858 * Copyright 2017 Google LLC
2859 *
2860 * Licensed under the Apache License, Version 2.0 (the "License");
2861 * you may not use this file except in compliance with the License.
2862 * You may obtain a copy of the License at
2863 *
2864 *   http://www.apache.org/licenses/LICENSE-2.0
2865 *
2866 * Unless required by applicable law or agreed to in writing, software
2867 * distributed under the License is distributed on an "AS IS" BASIS,
2868 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2869 * See the License for the specific language governing permissions and
2870 * limitations under the License.
2871 */class Ii{constructor(e,t,s){this.source=e,this.path=t,this.children=s,this.type=rt.MERGE}operationForChild(e){if(G(this.path)){const t=this.children.subtree(new se(e));return t.isEmpty()?null:t.value?new Rn(this.source,Z(),t.value):new Ii(this.source,Z(),t)}else return N(z(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new Ii(this.source,ie(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}/**
2872 * @license
2873 * Copyright 2017 Google LLC
2874 *
2875 * Licensed under the Apache License, Version 2.0 (the "License");
2876 * you may not use this file except in compliance with the License.
2877 * You may obtain a copy of the License at
2878 *
2879 *   http://www.apache.org/licenses/LICENSE-2.0
2880 *
2881 * Unless required by applicable law or agreed to in writing, software
2882 * distributed under the License is distributed on an "AS IS" BASIS,
2883 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2884 * See the License for the specific language governing permissions and
2885 * limitations under the License.
2886 */class tn{constructor(e,t,s){this.node_=e,this.fullyInitialized_=t,this.filtered_=s}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(e){if(G(e))return this.isFullyInitialized()&&!this.filtered_;const t=z(e);return this.isCompleteForChild(t)}isCompleteForChild(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)}getNode(){return this.node_}}/**
2887 * @license
2888 * Copyright 2017 Google LLC
2889 *
2890 * Licensed under the Apache License, Version 2.0 (the "License");
2891 * you may not use this file except in compliance with the License.
2892 * You may obtain a copy of the License at
2893 *
2894 *   http://www.apache.org/licenses/LICENSE-2.0
2895 *
2896 * Unless required by applicable law or agreed to in writing, software
2897 * distributed under the License is distributed on an "AS IS" BASIS,
2898 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2899 * See the License for the specific language governing permissions and
2900 * limitations under the License.
2901 */class xC{constructor(e){this.query_=e,this.index_=this.query_._queryParams.getIndex()}}function MC(n,e,t,s){const i=[],r=[];return e.forEach(o=>{o.type==="child_changed"&&n.index_.indexedValueChanged(o.oldSnap,o.snapshotNode)&&r.push(AC(o.childName,o.snapshotNode))}),zs(n,i,"child_removed",e,s,t),zs(n,i,"child_added",e,s,t),zs(n,i,"child_moved",r,s,t),zs(n,i,"child_changed",e,s,t),zs(n,i,"value",e,s,t),i}function zs(n,e,t,s,i,r){const o=s.filter(l=>l.type===t);o.sort((l,c)=>VC(n,l,c)),o.forEach(l=>{const c=LC(n,l,r);
2901i.forEach(h=>{h.respondsTo(l.type)&&e.push(h.createEvent(c,n.query_))})})}function LC(n,e,t){return e.type==="value"||e.type==="child_removed"||(e.prevName=t.getPredecessorChildName(e.childName,e.snapshotNode,n.index_)),e}function VC(n,e,t){if(e.childName==null||t.childName==null)throw gs("Should only compare child_ events.");const s=new W(e.childName,e.snapshotNode),i=new W(t.childName,t.snapshotNode);return n.index_.compare(s,i)}/**
2902 * @license
2903 * Copyright 2017 Google LLC
2904 *
2905 * Licensed under the Apache License, Version 2.0 (the "License");
2906 * you may not use this file except in compliance with the License.
2907 * You may obtain a copy of the License at
2908 *
2909 *   http://www.apache.org/licenses/LICENSE-2.0
2910 *
2911 * Unless required by applicable law or agreed to in writing, software
2912 * distributed under the License is distributed on an "AS IS" BASIS,
2913 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2914 * See the License for the specific language governing permissions and
2915 * limitations under the License.
2916 */function Eo(n,e){return{eventCache:n,serverCache:e}}function si(n,e,t,s){return Eo(new tn(e,t,s),n.serverCache)}function T_(n,e,t,s){return Eo(n.eventCache,new tn(e,t,s))}function Gr(n){return n.eventCache.isFullyInitialized()?n.eventCache.getNode():null}function Sn(n){return n.serverCache.isFullyInitialized()?n.serverCache.getNode():null}/**
2917 * @license
2918 * Copyright 2017 Google LLC
2919 *
2920 * Licensed under the Apache License, Version 2.0 (the "License");
2921 * you may not use this file except in compliance with the License.
2922 * You may obtain a copy of the License at
2923 *
2924 *   http://www.apache.org/licenses/LICENSE-2.0
2925 *
2926 * Unless required by applicable law or agreed to in writing, software
2927 * distributed under the License is distributed on an "AS IS" BASIS,
2928 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2929 * See the License for the specific language governing permissions and
2930 * limitations under the License.
2931 */let Ia;const FC=()=>(Ia||(Ia=new ct(ww)),Ia);class oe{constructor(e,t=FC()){this.value=e,this.children=t}static fromObject(e){let t=new oe(null);return Ke(e,(s,i)=>{t=t.set(new se(s),i)}),t}isEmpty(){return this.value===null&&this.children.isEmpty()}findRootMostMatchingPathAndValue(e,t){if(this.value!=null&&t(this.value))return{path:Z(),value:this.value};if(G(e))return null;{const s=z(e),i=this.children.get(s);if(i!==null){const r=i.findRootMostMatchingPathAndValue(ie(e),t);return r!=null?{path:ve(new se(s),r.path),value:r.value}:null}else return null}}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,()=>!0)}subtree(e){if(G(e))return this;{const t=z(e),s=this.children.get(t);return s!==null?s.subtree(ie(e)):new oe(null)}}set(e,t){if(G(e))return new oe(t,this.children);{const s=z(e),r=(this.children.get(s)||new oe(null)).set(ie(e),t),o=this.children.insert(s,r);return new oe(this.value,o)}}remove(e){if(G(e))return this.children.isEmpty()?new oe(null):new oe(null,this.children);{const t=z(e),s=this.children.get(t);if(s){const i=s.remove(ie(e));let r;return i.isEmpty()?r=this.children.remove(t):r=this.children.insert(t,i),this.value===null&&r.isEmpty()?new oe(null):new oe(this.value,r)}else return this}}get(e){if(G(e))return this.value;{const t=z(e),s=this.children.get(t);return s?s.get(ie(e)):null}}setTree(e,t){if(G(e))return t;{const s=z(e),r=(this.children.get(s)||new oe(null)).setTree(ie(e),t);let o;return r.isEmpty()?o=this.children.remove(s):o=this.children.insert(s,r),new oe(this.value,o)}}fold(e){return this.fold_(Z(),e)}fold_(e,t){const s={};return this.children.inorderTraversal((i,r)=>{s[i]=r.fold_(ve(e,i),t)}),t(e,this.value,s)}findOnPath(e,t){return this.findOnPath_(e,Z(),t)}findOnPath_(e,t,s){const i=this.value?s(t,this.value):!1;if(i)return i;if(G(e))return null;{const r=z(e),o=this.children.get(r);return o?o.findOnPath_(ie(e),ve(t,r),s):null}}foreachOnPath(e,t){return this.foreachOnPath_(e,Z(),t)}foreachOnPath_(e,t,s){if(G(e))return this;{this.value&&s(t,this.value);const i=z(e),r=this.children.get(i);return r?r.foreachOnPath_(ie(e),ve(t,i),s):new oe(null)}}foreach(e){this.foreach_(Z(),e)}foreach_(e,t){this.children.inorderTraversal((s,i)=>{i.foreach_(ve(e,s),t)}),this.value&&t(e,this.value)}foreachChild(e){this.children.inorderTraversal((t,s)=>{s.value&&e(t,s.value)})}}/**
2932 * @license
2933 * Copyright 2017 Google LLC
2934 *
2935 * Licensed under the Apache License, Version 2.0 (the "License");
2936 * you may not use this file except in compliance with the License.
2937 * You may obtain a copy of the License at
2938 *
2939 *   http://www.apache.org/licenses/LICENSE-2.0
2940 *
2941 * Unless required by applicable law or agreed to in writing, software
2942 * distributed under the License is distributed on an "AS IS" BASIS,
2943 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2944 * See the License for the specific language governing permissions and
2945 * limitations under the License.
2946 */class ot{constructor(e){this.writeTree_=e}static empty(){return new ot(new oe(null))}}function ii(n,e,t){if(G(e))return new ot(new oe(t));{const s=n.writeTree_.findRootMostValueAndPath(e);if(s!=null){const i=s.path;let r=s.value;const o=je(i,e);return r=r.updateChild(o,t),new ot(n.writeTree_.set(i,r))}else{const i=new oe(t),r=n.writeTree_.setTree(e,i);return new ot(r)}}}function Jh(n,e,t){let s=n;return Ke(t,(i,r)=>{s=ii(s,ve(e,i),r)}),s}function Zh(n,e){if(G(e))return ot.empty();{const t=n.writeTree_.setTree(e,new oe(null));return new ot(t)}}function Qa(n,e){return Dn(n,e)!=null}function Dn(n,e){const t=n.writeTree_.findRootMostValueAndPath(e);return t!=null?n.writeTree_.get(t.path).getChild(je(t.path,e)):null}function ed(n){const e=[],t=n.writeTree_.value;return t!=null?t.isLeafNode()||t.forEachChild(ue,(s,i)=>{e.push(new W(s,i))}):n.writeTree_.children.inorderTraversal((s,i)=>{i.value!=null&&e.push(new W(s,i.value))}),e}function Qt(n,e){if(G(e))return n;{const t=Dn(n,e);return t!=null?new ot(new oe(t)):new ot(n.writeTree_.subtree(e))}}function Ya(n){return n.writeTree_.isEmpty()}function ls(n,e){return I_(Z(),n.writeTree_,e)}function I_(n,e,t){if(e.value!=null)return t.updateChild(n,e.value);{let s=null;return e.children.inorderTraversal((i,r)=>{i===".priority"?(N(r.value!==null,"Priority writes must always be leaf nodes"),s=r.value):t=I_(ve(n,i),r,t)}),!t.getChild(n).isEmpty()&&s!==null&&(t=t.updateChild(ve(n,".priority"),s)),t}}/**
2947 * @license
2948 * Copyright 2017 Google LLC
2949 *
2950 * Licensed under the Apache License, Version 2.0 (the "License");
2951 * you may not use this file except in compliance with the License.
2952 * You may obtain a copy of the License at
2953 *
2954 *   http://www.apache.org/licenses/LICENSE-2.0
2955 *
2956 * Unless required by applicable law or agreed to in writing, software
2957 * distributed under the License is distributed on an "AS IS" BASIS,
2958 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2959 * See the License for the specific language governing permissions and
2960 * limitations under the License.
2961 */function To(n,e){return R_(e,n)}function UC(n,e,t,s,i){N(s>n.lastWriteId,"Stacking an older write on top of newer ones"),i===void 0&&(i=!0),n.allWrites.push({path:e,snap:t,writeId:s,visible:i}),i&&(n.visibleWrites=ii(n.visibleWrites,e,t)),n.lastWriteId=s}function BC(n,e){for(let t=0;t<n.allWrites.length;t++){const s=n.allWrites[t];if(s.writeId===e)return s}return null}function qC(n,e){const t=n.allWrites.findIndex(l=>l.writeId===e);N(t>=0,"removeWrite called with nonexistent writeId.");const s=n.allWrites[t];n.allWrites.splice(t,1);let i=s.visible,r=!1,o=n.allWrites.length-1;for(;i&&o>=0;){const l=n.allWrites[o];l.visible&&(o>=t&&$C(l,s.path)?i=!1:it(s.path,l.path)&&(r=!0)),o--}if(i){if(r)return jC(n),!0;if(s.snap)n.visibleWrites=Zh(n.visibleWrites,s.path);else{const l=s.children;Ke(l,c=>{n.visibleWrites=Zh(n.visibleWrites,ve(s.path,c))})}return!0}else return!1}function $C(n,e){if(n.snap)return it(n.path,e);for(const t in n.children)if(n.children.hasOwnProperty(t)&&it(ve(n.path,t),e))return!0;return!1}function jC(n){n.visibleWrites=w_(n.allWrites,HC,Z()),n.allWrites.length>0?n.lastWriteId=n.allWrites[n.allWrites.length-1].writeId:n.lastWriteId=-1}function HC(n){return n.visible}function w_(n,e,t){let s=ot.empty();for(let i=0;i<n.length;++i){const r=n[i];if(e(r)){const o=r.path;let l;if(r.snap)it(t,o)?(l=je(t,o),s=ii(s,l,r.snap)):it(o,t)&&(l=je(o,t),s=ii(s,Z(),r.snap.getChild(l)));else if(r.children){if(it(t,o))l=je(t,o),s=Jh(s,l,r.children);else if(it(o,t))if(l=je(o,t),G(l))s=Jh(s,Z(),r.children);else{const c=ns(r.children,z(l));if(c){const h=c.getChild(ie(l));s=ii(s,Z(),h)}}}else throw gs("WriteRecord should have .snap or .children")}}return s}function C_(n,e,t,s,i){if(!s&&!i){const r=Dn(n.visibleWrites,e);if(r!=null)return r;{const o=Qt(n.visibleWrites,e);if(Ya(o))return t;if(t==null&&!Qa(o,Z()))return null;{const l=t||L.EMPTY_NODE;return ls(o,l)}}}
2961else{const r=Qt(n.visibleWrites,e);if(!i&&Ya(r))return t;if(!i&&t==null&&!Qa(r,Z()))return null;{const o=function(h){return(h.visible||i)&&(!s||!~s.indexOf(h.writeId))&&(it(h.path,e)||it(e,h.path))},l=w_(n.allWrites,o,e),c=t||L.EMPTY_NODE;return ls(l,c)}}}function WC(n,e,t){let s=L.EMPTY_NODE;const i=Dn(n.visibleWrites,e);if(i)return i.isLeafNode()||i.forEachChild(ue,(r,o)=>{s=s.updateImmediateChild(r,o)}),s;if(t){const r=Qt(n.visibleWrites,e);return t.forEachChild(ue,(o,l)=>{const c=ls(Qt(r,new se(o)),l);s=s.updateImmediateChild(o,c)}),ed(r).forEach(o=>{s=s.updateImmediateChild(o.name,o.node)}),s}else{const r=Qt(n.visibleWrites,e);return ed(r).forEach(o=>{s=s.updateImmediateChild(o.name,o.node)}),s}}function zC(n,e,t,s,i){N(s||i,"Either existingEventSnap or existingServerSnap must exist");const r=ve(e,t);if(Qa(n.visibleWrites,r))return null;{const o=Qt(n.visibleWrites,r);return Ya(o)?i.getChild(t):ls(o,i.getChild(t))}}function GC(n,e,t,s){const i=ve(e,t),r=Dn(n.visibleWrites,i);if(r!=null)return r;if(s.isCompleteForChild(t)){const o=Qt(n.visibleWrites,i);return ls(o,s.getNode().getImmediateChild(t))}else return null}function KC(n,e){return Dn(n.visibleWrites,e)}function QC(n,e,t,s,i,r,o){let l;const c=Qt(n.visibleWrites,e),h=Dn(c,Z());if(h!=null)l=h;else if(t!=null)l=ls(c,t);else return[];if(l=l.withIndex(o),!l.isEmpty()&&!l.isLeafNode()){const f=[],p=o.getCompare(),g=r?l.getReverseIteratorFrom(s,o):l.getIteratorFrom(s,o);let I=g.getNext();for(;I&&f.length<i;)p(I,s)!==0&&f.push(I),I=g.getNext();return f}else return[]}function YC(){return{visibleWrites:ot.empty(),allWrites:[],lastWriteId:-1}}function Kr(n,e,t,s){return C_(n.writeTree,n.treePath,e,t,s)}function Zl(n,e){return WC(n.writeTree,n.treePath,e)}function td(n,e,t,s){return zC(n.writeTree,n.treePath,e,t,s)}function Qr(n,e){return KC(n.writeTree,ve(n.treePath,e))}function XC(n,e,t,s,i,r){return QC(n.writeTree,n.treePath,e,t,s,i,r)}function ec(n,e,t){return GC(n.writeTree,n.treePath,e,t)}function A_(n,e){return R_(ve(n.treePath,e),n.writeTree)}function R_(n,e){return{treePath:n,writeTree:e}}/**
2962 * @license
2963 * Copyright 2017 Google LLC
2964 *
2965 * Licensed under the Apache License, Version 2.0 (the "License");
2966 * you may not use this file except in compliance with the License.
2967 * You may obtain a copy of the License at
2968 *
2969 *   http://www.apache.org/licenses/LICENSE-2.0
2970 *
2971 * Unless required by applicable law or agreed to in writing, software
2972 * distributed under the License is distributed on an "AS IS" BASIS,
2973 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2974 * See the License for the specific language governing permissions and
2975 * limitations under the License.
2976 */class JC{constructor(){this.changeMap=new Map}trackChildChange(e){const t=e.type,s=e.childName;N(t==="child_added"||t==="child_changed"||t==="child_removed","Only child changes supported for tracking"),N(s!==".priority","Only non-priority child changes can be tracked.");const i=this.changeMap.get(s);if(i){const r=i.type;if(t==="child_added"&&r==="child_removed")this.changeMap.set(s,vi(s,e.snapshotNode,i.snapshotNode));else if(t==="child_removed"&&r==="child_added")this.changeMap.delete(s);else if(t==="child_removed"&&r==="child_changed")this.changeMap.set(s,yi(s,i.oldSnap));else if(t==="child_changed"&&r==="child_added")this.changeMap.set(s,as(s,e.snapshotNode));else if(t==="child_changed"&&r==="child_changed")this.changeMap.set(s,vi(s,e.snapshotNode,i.oldSnap));else throw gs("Illegal combination of changes: "+e+" occurred after "+i)}else this.changeMap.set(s,e)}getChanges(){return Array.from(this.changeMap.values())}}/**
2977 * @license
2978 * Copyright 2017 Google LLC
2979 *
2980 * Licensed under the Apache License, Version 2.0 (the "License");
2981 * you may not use this file except in compliance with the License.
2982 * You may obtain a copy of the License at
2983 *
2984 *   http://www.apache.org/licenses/LICENSE-2.0
2985 *
2986 * Unless required by applicable law or agreed to in writing, software
2987 * distributed under the License is distributed on an "AS IS" BASIS,
2988 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2989 * See the License for the specific language governing permissions and
2990 * limitations under the License.
2991 */class ZC{getCompleteChild(e){return null}getChildAfterChild(e,t,s){return null}}const S_=new ZC;class tc{constructor(e,t,s=null){this.writes_=e,this.viewCache_=t,this.optCompleteServerCache_=s}getCompleteChild(e){const t=this.viewCache_.eventCache;if(t.isCompleteForChild(e))return t.getNode().getImmediateChild(e);{const s=this.optCompleteServerCache_!=null?new tn(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return ec(this.writes_,e,s)}}getChildAfterChild(e,t,s){const i=this.optCompleteServerCache_!=null?this.optCompleteServerCache_:Sn(this.viewCache_),r=XC(this.writes_,i,t,1,s,e);return r.length===0?null:r[0]}}/**
2992 * @license
2993 * Copyright 2017 Google LLC
2994 *
2995 * Licensed under the Apache License, Version 2.0 (the "License");
2996 * you may not use this file except in compliance with the License.
2997 * You may obtain a copy of the License at
2998 *
2999 *   http://www.apache.org/licenses/LICENSE-2.0
3000 *
3001 * Unless required by applicable law or agreed to in writing, software
3002 * distributed under the License is distributed on an "AS IS" BASIS,
3003 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3004 * See the License for the specific language governing permissions and
3005 * limitations under the License.
3006 */function eA(n){return{filter:n}}function tA(n,e){N(e.eventCache.getNode().isIndexed(n.filter.getIndex()),"Event snap not indexed"),N(e.serverCache.getNode().isIndexed(n.filter.getIndex()),"Server snap not indexed")}function nA(n,e,t,s,i){const r=new JC;let o,l;if(t.type===rt.OVERWRITE){const h=t;h.source.fromUser?o=Xa(n,e,h.path,h.snap,s,i,r):(N(h.source.fromServer,"Unknown source."),l=h.source.tagged||e.serverCache.isFiltered()&&!G(h.path),o=Yr(n,e,h.path,h.snap,s,i,l,r))}else if(t.type===rt.MERGE){const h=t;h.source.fromUser?o=iA(n,e,h.path,h.children,s,i,r):(N(h.source.fromServer,"Unknown source."),l=h.source.tagged||e.serverCache.isFiltered(),o=Ja(n,e,h.path,h.children,s,i,l,r))}else if(t.type===rt.ACK_USER_WRITE){const h=t;h.revert?o=aA(n,e,h.path,s,i,r):o=rA(n,e,h.path,h.affectedTree,s,i,r)}else if(t.type===rt.LISTEN_COMPLETE)o=oA(n,e,t.path,s,r);else throw gs("Unknown operation type: "+t.type);const c=r.getChanges();return sA(e,o,c),{viewCache:o,changes:c}}function sA(n,e,t){const s=e.eventCache;if(s.isFullyInitialized()){const i=s.getNode().isLeafNode()||s.getNode().isEmpty(),r=Gr(n);(t.length>0||!n.eventCache.isFullyInitialized()||i&&!s.getNode().equals(r)||!s.getNode().getPriority().equals(r.getPriority()))&&t.push(y_(Gr(e)))}}function b_(n,e,t,s,i,r){const o=e.eventCache;if(Qr(s,t)!=null)return e;{let l,c;if(G(t))if(N(e.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),e.serverCache.isFiltered()){const h=Sn(e),f=h instanceof L?h:L.EMPTY_NODE,p=Zl(s,f);l=n.filter.updateFullNode(e.eventCache.getNode(),p,r)}else{const h=Kr(s,Sn(e));l=n.filter.updateFullNode(e.eventCache.getNode(),h,r)}else{const h=z(t);if(h===".priority"){N(en(t)===1,"Can't have a priority with additional path components");const f=o.getNode();c=e.serverCache.getNode();const p=td(s,t,f,c);p!=null?l=n.filter.updatePriority(f,p):l=o.getNode()}else{const f=ie(t);let p;if(o.isCompleteForChild(h)){c=e.serverCache.getNode();const g=td(s,t,o.getNode(),c);g!=null?p=o.getNode().getImmediateChild(h).updateChild(f,g):p=o.getNode().getImmediateChild(h)}else p=ec(s,h,e.serverCache);p!=null?l=n.filter.updateChild(o.getNode(),h,p,f,i,r):l=o.getNode()}}return si(e,l,o.isFullyInitialized()||G(t),n.filter.filtersNodes())}}function Yr(n,e,t,s,i,r,o,l){const c=e.serverCache;let h;const f=o?n.filter:n.filter.getIndexedFilter();if(G(t))h=f.updateFullNode(c.getNode(),s,null);else if(f.filtersNodes()&&!c.isFiltered()){const I=c.getNode().updateChild(t,s);h=f.updateFullNode(c.getNode(),I,null)}else{const I=z(t);if(!c.isCompleteForPath(t)&&en(t)>1)return e;const S=ie(t),b=c.getNode().getImmediateChild(I).updateChild(S,s);I===".priority"?h=f.updatePriority(c.getNode(),b):h=f.updateChild(c.getNode(),I,b,S,S_,null)}const p=T_(e,h,c.isFullyInitialized()||G(t),f.filtersNodes()),g=new tc(i,p,r);return b_(n,p,t,i,g,l)}function Xa(n,e,t,s,i,r,o){const l=e.eventCache;let c,h;const f=new tc(i,e,r);if(G(t))h=n.filter.updateFullNode(e.eventCache.getNode(),s,o),c=si(e,h,!0,n.filter.filtersNodes());else{const p=z(t);if(p===".priority")h=n.filter.updatePriority(e.eventCache.getNode(),s),c=si(e,h,l.isFullyInitialized(),l.isFiltered());else{const g=ie(t),I=l.getNode().getImmediateChild(p);let S;if(G(g))S=s;
3006else{const k=f.getCompleteChild(p);k!=null?c_(g)===".priority"&&k.getChild(h_(g)).isEmpty()?S=k:S=k.updateChild(g,s):S=L.EMPTY_NODE}if(I.equals(S))c=e;else{const k=n.filter.updateChild(l.getNode(),p,S,g,f,o);c=si(e,k,l.isFullyInitialized(),n.filter.filtersNodes())}}}return c}function nd(n,e){return n.eventCache.isCompleteForChild(e)}function iA(n,e,t,s,i,r,o){let l=e;return s.foreach((c,h)=>{const f=ve(t,c);nd(e,z(f))&&(l=Xa(n,l,f,h,i,r,o))}),s.foreach((c,h)=>{const f=ve(t,c);nd(e,z(f))||(l=Xa(n,l,f,h,i,r,o))}),l}function sd(n,e,t){return t.foreach((s,i)=>{e=e.updateChild(s,i)}),e}function Ja(n,e,t,s,i,r,o,l){if(e.serverCache.getNode().isEmpty()&&!e.serverCache.isFullyInitialized())return e;let c=e,h;G(t)?h=s:h=new oe(null).setTree(t,s);const f=e.serverCache.getNode();return h.children.inorderTraversal((p,g)=>{if(f.hasChild(p)){const I=e.serverCache.getNode().getImmediateChild(p),S=sd(n,I,g);c=Yr(n,c,new se(p),S,i,r,o,l)}}),h.children.inorderTraversal((p,g)=>{const I=!e.serverCache.isCompleteForChild(p)&&g.value===null;if(!f.hasChild(p)&&!I){const S=e.serverCache.getNode().getImmediateChild(p),k=sd(n,S,g);c=Yr(n,c,new se(p),k,i,r,o,l)}}),c}function rA(n,e,t,s,i,r,o){if(Qr(i,t)!=null)return e;const l=e.serverCache.isFiltered(),c=e.serverCache;if(s.value!=null){if(G(t)&&c.isFullyInitialized()||c.isCompleteForPath(t))return Yr(n,e,t,c.getNode().getChild(t),i,r,l,o);if(G(t)){let h=new oe(null);return c.getNode().forEachChild(Jn,(f,p)=>{h=h.set(new se(f),p)}),Ja(n,e,t,h,i,r,l,o)}else return e}else{let h=new oe(null);return s.foreach((f,p)=>{const g=ve(t,f);c.isCompleteForPath(g)&&(h=h.set(f,c.getNode().getChild(g)))}),Ja(n,e,t,h,i,r,l,o)}}function oA(n,e,t,s,i){const r=e.serverCache,o=T_(e,r.getNode(),r.isFullyInitialized()||G(t),r.isFiltered());return b_(n,o,t,s,S_,i)}function aA(n,e,t,s,i,r){let o;if(Qr(s,t)!=null)return e;{const l=new tc(s,e,i),c=e.eventCache.getNode();let h;if(G(t)||z(t)===".priority"){let f;if(e.serverCache.isFullyInitialized())f=Kr(s,Sn(e));else{const p=e.serverCache.getNode();N(p instanceof L,"serverChildren would be complete if leaf node"),f=Zl(s,p)}f=f,h=n.filter.updateFullNode(c,f,r)}else{const f=z(t);let p=ec(s,f,e.serverCache);p==null&&e.serverCache.isCompleteForChild(f)&&(p=c.getImmediateChild(f)),p!=null?h=n.filter.updateChild(c,f,p,ie(t),l,r):e.eventCache.getNode().hasChild(f)?h=n.filter.updateChild(c,f,L.EMPTY_NODE,ie(t),l,r):h=c,h.isEmpty()&&e.serverCache.isFullyInitialized()&&(o=Kr(s,Sn(e)),o.isLeafNode()&&(h=n.filter.updateFullNode(h,o,r)))}return o=e.serverCache.isFullyInitialized()||Qr(s,Z())!=null,si(e,h,o,n.filter.filtersNodes())}}/**
3007 * @license
3008 * Copyright 2017 Google LLC
3009 *
3010 * Licensed under the Apache License, Version 2.0 (the "License");
3011 * you may not use this file except in compliance with the License.
3012 * You may obtain a copy of the License at
3013 *
3014 *   http://www.apache.org/licenses/LICENSE-2.0
3015 *
3016 * Unless required by applicable law or agreed to in writing, software
3017 * distributed under the License is distributed on an "AS IS" BASIS,
3018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3019 * See the License for the specific language governing permissions and
3020 * limitations under the License.
3021 */class lA{constructor(e,t){this.query_=e,this.eventRegistrations_=[];const s=this.query_._queryParams,i=new Ql(s.getIndex()),r=SC(s);this.processor_=eA(r);const o=t.serverCache,l=t.eventCache,c=i.updateFullNode(L.EMPTY_NODE,o.getNode(),null),h=r.updateFullNode(L.EMPTY_NODE,l.getNode(),null),f=new tn(c,o.isFullyInitialized(),i.filtersNodes()),p=new tn(h,l.isFullyInitialized(),r.filtersNodes());this.viewCache_=Eo(p,f),this.eventGenerator_=new xC(this.query_)}get query(){return this.query_}}function cA(n){return n.viewCache_.serverCache.getNode()}function uA(n){return Gr(n.viewCache_)}function hA(n,e){const t=Sn(n.viewCache_);return t&&(n.query._queryParams.loadsAllData()||!G(e)&&!t.getImmediateChild(z(e)).isEmpty())?t.getChild(e):null}function id(n){return n.eventRegistrations_.length===0}function dA(n,e){n.eventRegistrations_.push(e)}function rd(n,e,t){const s=[];if(t){N(e==null,"A cancel should cancel all event registrations.");const i=n.query._path;n.eventRegistrations_.forEach(r=>{const o=r.createCancelEvent(t,i);o&&s.push(o)})}if(e){let i=[];for(let r=0;r<n.eventRegistrations_.length;++r){const o=n.eventRegistrations_[r];if(!o.matches(e))i.push(o);else if(e.hasAnyCallback()){i=i.concat(n.eventRegistrations_.slice(r+1));break}}n.eventRegistrations_=i}else n.eventRegistrations_=[];return s}function od(n,e,t,s){e.type===rt.MERGE&&e.source.queryId!==null&&(N(Sn(n.viewCache_),"We should always have a full c
3021ache before handling merges"),N(Gr(n.viewCache_),"Missing event cache, even though we have a server cache"));const i=n.viewCache_,r=nA(n.processor_,i,e,t,s);return tA(n.processor_,r.viewCache),N(r.viewCache.serverCache.isFullyInitialized()||!i.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),n.viewCache_=r.viewCache,P_(n,r.changes,r.viewCache.eventCache.getNode(),null)}function fA(n,e){const t=n.viewCache_.eventCache,s=[];return t.getNode().isLeafNode()||t.getNode().forEachChild(ue,(r,o)=>{s.push(as(r,o))}),t.isFullyInitialized()&&s.push(y_(t.getNode())),P_(n,s,t.getNode(),e)}function P_(n,e,t,s){const i=s?[s]:n.eventRegistrations_;return MC(n.eventGenerator_,e,t,i)}/**
3022 * @license
3023 * Copyright 2017 Google LLC
3024 *
3025 * Licensed under the Apache License, Version 2.0 (the "License");
3026 * you may not use this file except in compliance with the License.
3027 * You may obtain a copy of the License at
3028 *
3029 *   http://www.apache.org/licenses/LICENSE-2.0
3030 *
3031 * Unless required by applicable law or agreed to in writing, software
3032 * distributed under the License is distributed on an "AS IS" BASIS,
3033 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3034 * See the License for the specific language governing permissions and
3035 * limitations under the License.
3036 */let Xr;class k_{constructor(){this.views=new Map}}function pA(n){N(!Xr,"__referenceConstructor has already been defined"),Xr=n}function _A(){return N(Xr,"Reference.ts has not been loaded"),Xr}function gA(n){return n.views.size===0}function nc(n,e,t,s){const i=e.source.queryId;if(i!==null){const r=n.views.get(i);return N(r!=null,"SyncTree gave us an op for an invalid query."),od(r,e,t,s)}else{let r=[];for(const o of n.views.values())r=r.concat(od(o,e,t,s));return r}}function N_(n,e,t,s,i){const r=e._queryIdentifier,o=n.views.get(r);if(!o){let l=Kr(t,i?s:null),c=!1;l?c=!0:s instanceof L?(l=Zl(t,s),c=!1):(l=L.EMPTY_NODE,c=!1);const h=Eo(new tn(l,c,!1),new tn(s,i,!1));return new lA(e,h)}return o}function mA(n,e,t,s,i,r){const o=N_(n,e,s,i,r);return n.views.has(e._queryIdentifier)||n.views.set(e._queryIdentifier,o),dA(o,t),fA(o,t)}function yA(n,e,t,s){const i=e._queryIdentifier,r=[];let o=[];const l=nn(n);if(i==="default")for(const[c,h]of n.views.entries())o=o.concat(rd(h,t,s)),id(h)&&(n.views.delete(c),h.query._queryParams.loadsAllData()||r.push(h.query));else{const c=n.views.get(i);c&&(o=o.concat(rd(c,t,s)),id(c)&&(n.views.delete(i),c.query._queryParams.loadsAllData()||r.push(c.query)))}return l&&!nn(n)&&r.push(new(_A())(e._repo,e._path)),{removed:r,events:o}}function D_(n){const e=[];for(const t of n.views.values())t.query._queryParams.loadsAllData()||e.push(t);return e}function Yt(n,e){let t=null;for(const s of n.views.values())t=t||hA(s,e);return t}function O_(n,e){if(e._queryParams.loadsAllData())return Io(n);{const s=e._queryIdentifier;return n.views.get(s)}}function x_(n,e){return O_(n,e)!=null}function nn(n){return Io(n)!=null}function Io(n){for(const e of n.views.values())if(e.query._queryParams.loadsAllData())return e;return null}/**
3037 * @license
3038 * Copyright 2017 Google LLC
3039 *
3040 * Licensed under the Apache License, Version 2.0 (the "License");
3041 * you may not use this file except in compliance with the License.
3042 * You may obtain a copy of the License at
3043 *
3044 *   http://www.apache.org/licenses/LICENSE-2.0
3045 *
3046 * Unless required by applicable law or agreed to in writing, software
3047 * distributed under the License is distributed on an "AS IS" BASIS,
3048 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3049 * See the License for the specific language governing permissions and
3050 * limitations under the License.
3051 */let Jr;function vA(n){N(!Jr,"__referenceConstructor has already been defined"),Jr=n}function EA(){return N(Jr,"Reference.ts has not been loaded"),Jr}let TA=1;class ad{constructor(e){this.listenProvider_=e,this.syncPointTree_=new oe(null),this.pendingWriteTree_=YC(),this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function IA(n,e,t,s,i){return UC(n.pendingWriteTree_,e,t,s,i),i?Vi(n,new Rn(E_(),e,t)):[]}function Gn(n,e,t=!1){const s=BC(n.pendingWriteTree_,e);if(qC(n.pendingWriteTree_,e)){let r=new oe(null);return s.snap!=null?r=r.set(Z(),!0):Ke(s.children,o=>{r=r.set(new se(o),!0)}),Vi(n,new zr(s.path,r,t))}else return[]}function Li(n,e,t){return Vi(n,new Rn(Xl(),e,t))}function wA(n,e,t){const s=oe.fromObject(t);return Vi(n,new Ii(Xl(),e,s))}function CA(n,e){return Vi(n,new Ti(Xl(),e))}function AA(n,e,t){const s=sc(n,t);if(s){const i=ic(s),r=i.path,o=i.queryId,l=je(r,e),c=new Ti(Jl(o),l);return rc(n,r,c)}else return[]}function Zr(n,e,t,s,i=!1){const r=e._path,o=n.syncPointTree_.get(r);let l=[];
3051if(o&&(e._queryIdentifier==="default"||x_(o,e))){const c=yA(o,e,t,s);gA(o)&&(n.syncPointTree_=n.syncPointTree_.remove(r));const h=c.removed;if(l=c.events,!i){const f=h.findIndex(g=>g._queryParams.loadsAllData())!==-1,p=n.syncPointTree_.findOnPath(r,(g,I)=>nn(I));if(f&&!p){const g=n.syncPointTree_.subtree(r);if(!g.isEmpty()){const I=bA(g);for(let S=0;S<I.length;++S){const k=I[S],b=k.query,B=U_(n,k);n.listenProvider_.startListening(ri(b),wi(n,b),B.hashFn,B.onComplete)}}}!p&&h.length>0&&!s&&(f?n.listenProvider_.stopListening(ri(e),null):h.forEach(g=>{const I=n.queryToTagMap.get(wo(g));n.listenProvider_.stopListening(ri(g),I)}))}PA(n,h)}return l}function M_(n,e,t,s){const i=sc(n,s);if(i!=null){const r=ic(i),o=r.path,l=r.queryId,c=je(o,e),h=new Rn(Jl(l),c,t);return rc(n,o,h)}else return[]}function RA(n,e,t,s){const i=sc(n,s);if(i){const r=ic(i),o=r.path,l=r.queryId,c=je(o,e),h=oe.fromObject(t),f=new Ii(Jl(l),c,h);return rc(n,o,f)}else return[]}function Za(n,e,t,s=!1){const i=e._path;let r=null,o=!1;n.syncPointTree_.foreachOnPath(i,(g,I)=>{const S=je(g,i);r=r||Yt(I,S),o=o||nn(I)});let l=n.syncPointTree_.get(i);l?(o=o||nn(l),r=r||Yt(l,Z())):(l=new k_,n.syncPointTree_=n.syncPointTree_.set(i,l));let c;r!=null?c=!0:(c=!1,r=L.EMPTY_NODE,n.syncPointTree_.subtree(i).foreachChild((I,S)=>{const k=Yt(S,Z());k&&(r=r.updateImmediateChild(I,k))}));const h=x_(l,e);if(!h&&!e._queryParams.loadsAllData()){const g=wo(e);N(!n.queryToTagMap.has(g),"View does not exist, but we have a tag");const I=kA();n.queryToTagMap.set(g,I),n.tagToQueryMap.set(I,g)}const f=To(n.pendingWriteTree_,i);let p=mA(l,e,t,f,r,c);if(!h&&!o&&!s){const g=O_(l,e);p=p.concat(NA(n,e,g))}return p}function L_(n,e,t){const i=n.pendingWriteTree_,r=n.syncPointTree_.findOnPath(e,(o,l)=>{const c=je(o,e),h=Yt(l,c);if(h)return h});return C_(i,e,r,t,!0)}function SA(n,e){const t=e._path;let s=null;n.syncPointTree_.foreachOnPath(t,(h,f)=>{const p=je(h,t);s=s||Yt(f,p)});let i=n.syncPointTree_.get(t);i?s=s||Yt(i,Z()):(i=new k_,n.syncPointTree_=n.syncPointTree_.set(t,i));const r=s!=null,o=r?new tn(s,!0,!1):null,l=To(n.pendingWriteTree_,e._path),c=N_(i,e,l,r?o.getNode():L.EMPTY_NODE,r);return uA(c)}function Vi(n,e){return V_(e,n.syncPointTree_,null,To(n.pendingWriteTree_,Z()))}function V_(n,e,t,s){if(G(n.path))return F_(n,e,t,s);{const i=e.get(Z());t==null&&i!=null&&(t=Yt(i,Z()));let r=[];const o=z(n.path),l=n.operationForChild(o),c=e.children.get(o);if(c&&l){const h=t?t.getImmediateChild(o):null,f=A_(s,o);r=r.concat(V_(l,c,h,f))}return i&&(r=r.concat(nc(i,n,s,t))),r}}function F_(n,e,t,s){const i=e.get(Z());t==null&&i!=null&&(t=Yt(i,Z()));let r=[];return e.children.inorderTraversal((o,l)=>{const c=t?t.getImmediateChild(o):null,h=A_(s,o),f=n.operationForChild(o);f&&(r=r.concat(F_(f,l,c,h)))}),i&&(r=r.concat(nc(i,n,s,t))),r}function U_(n,e){const t=e.query,s=wi(n,t);return{hashFn:()=>(cA(e)||L.EMPTY_NODE).hash(),onComplete:i=>{if(i==="ok")return s?AA(n,t._path,s):CA(n,t._path);{const r=Rw(i,t);return Zr(n,t,null,r)}}}}function wi(n,e){const t=wo(e);return n.queryToTagMap.get(t)}function wo(n){return n._path.toString()+"$"+n._queryIdentifier}function sc(n,e){return n.tagToQueryMap.get(e)}function ic(n){const e=n.indexOf("$");return N(e!==-1&&e<n.length-1,"Bad queryKey."),{queryId:n.substr(e+1),path:new se(n.substr(0,e))}}function rc(n,e,t){const s=n.syncPointTree_.get(e);N(s,"Missing sync point for query tag that we're tracking");const i=To(n.pendingWriteTree_,e);return nc(s,t,i,null)}function bA(n){return n.fold((e,t,s)=>{if(t&&nn(t))return[Io(t)];{let i=[];return t&&(i=D_(t)),Ke(s,(r,o)=>{i=i.concat(o)}),i}})}
3051function ri(n){return n._queryParams.loadsAllData()&&!n._queryParams.isDefault()?new(EA())(n._repo,n._path):n}function PA(n,e){for(let t=0;t<e.length;++t){const s=e[t];if(!s._queryParams.loadsAllData()){const i=wo(s),r=n.queryToTagMap.get(i);n.queryToTagMap.delete(i),n.tagToQueryMap.delete(r)}}}function kA(){return TA++}function NA(n,e,t){const s=e._path,i=wi(n,e),r=U_(n,t),o=n.listenProvider_.startListening(ri(e),i,r.hashFn,r.onComplete),l=n.syncPointTree_.subtree(s);if(i)N(!nn(l.value),"If we're adding a query, it shouldn't be shadowed");else{const c=l.fold((h,f,p)=>{if(!G(h)&&f&&nn(f))return[Io(f).query];{let g=[];return f&&(g=g.concat(D_(f).map(I=>I.query))),Ke(p,(I,S)=>{g=g.concat(S)}),g}});for(let h=0;h<c.length;++h){const f=c[h];n.listenProvider_.stopListening(ri(f),wi(n,f))}}return o}/**
3052 * @license
3053 * Copyright 2017 Google LLC
3054 *
3055 * Licensed under the Apache License, Version 2.0 (the "License");
3056 * you may not use this file except in compliance with the License.
3057 * You may obtain a copy of the License at
3058 *
3059 *   http://www.apache.org/licenses/LICENSE-2.0
3060 *
3061 * Unless required by applicable law or agreed to in writing, software
3062 * distributed under the License is distributed on an "AS IS" BASIS,
3063 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3064 * See the License for the specific language governing permissions and
3065 * limitations under the License.
3066 */class oc{constructor(e){this.node_=e}getImmediateChild(e){const t=this.node_.getImmediateChild(e);return new oc(t)}node(){return this.node_}}class ac{constructor(e,t){this.syncTree_=e,this.path_=t}getImmediateChild(e){const t=ve(this.path_,e);return new ac(this.syncTree_,t)}node(){return L_(this.syncTree_,this.path_)}}const DA=function(n){return n=n||{},n.timestamp=n.timestamp||new Date().getTime(),n},ld=function(n,e,t){if(!n||typeof n!="object")return n;if(N(".sv"in n,"Unexpected leaf node or priority contents"),typeof n[".sv"]=="string")return OA(n[".sv"],e,t);if(typeof n[".sv"]=="object")return xA(n[".sv"],e);N(!1,"Unexpected server value: "+JSON.stringify(n,null,2))},OA=function(n,e,t){switch(n){case"timestamp":return t.timestamp;default:N(!1,"Unexpected server value: "+n)}},xA=function(n,e,t){n.hasOwnProperty("increment")||N(!1,"Unexpected server value: "+JSON.stringify(n,null,2));const s=n.increment;typeof s!="number"&&N(!1,"Unexpected increment value: "+s);const i=e.node();if(N(i!==null&&typeof i<"u","Expected ChildrenNode.EMPTY_NODE for nulls"),!i.isLeafNode())return s;const o=i.getValue();return typeof o!="number"?s:o+s},MA=function(n,e,t,s){return lc(e,new ac(t,n),s)},LA=function(n,e,t){return lc(n,new oc(e),t)};function lc(n,e,t){const s=n.getPriority().val(),i=ld(s,e.getImmediateChild(".priority"),t);let r;if(n.isLeafNode()){const o=n,l=ld(o.getValue(),e,t);return l!==o.getValue()||i!==o.getPriority().val()?new Te(l,Ae(i)):n}else{const o=n;return r=o,i!==o.getPriority().val()&&(r=r.updatePriority(new Te(i))),o.forEachChild(ue,(l,c)=>{const h=lc(c,e.getImmediateChild(l),t);h!==c&&(r=r.updateImmediateChild(l,h))}),r}}/**
3067 * @license
3068 * Copyright 2017 Google LLC
3069 *
3070 * Licensed under the Apache License, Version 2.0 (the "License");
3071 * you may not use this file except in compliance with the License.
3072 * You may obtain a copy of the License at
3073 *
3074 *   http://www.apache.org/licenses/LICENSE-2.0
3075 *
3076 * Unless required by applicable law or agreed to in writing, software
3077 * distributed under the License is distributed on an "AS IS" BASIS,
3078 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3079 * See the License for the specific language governing permissions and
3080 * limitations under the License.
3081 */class cc{constructor(e="",t=null,s={children:{},childCount:0}){this.name=e,this.parent=t,this.node=s}}function uc(n,e){let t=e instanceof se?e:new se(e),s=n,i=z(t);for(;i!==null;){const r=ns(s.node.children,i)||{children:{},childCount:0};s=new cc(i,s,r),t=ie(t),i=z(t)}return s}function Ts(n){return n.node.value}function B_(n,e){n.node.value=e,el(n)}function q_(n){return n.node.childCount>0}function VA(n){return Ts(n)===void 0&&!q_(n)}function Co(n,e){Ke(n.node.children,(t,s)=>{e(new cc(t,n,s))})}function $_(n,e,t,s){t&&e(n),Co(n,i=>{$_(i,e,!0)})}function FA(n,e,t){let s=n.parent;for(;s!==null;){if(e(s))return!0;s=s.parent}return!1}function Fi(n){return new se(n.parent===null?n.name:Fi(n.parent)+"/"+n.name)}function el(n){n.parent!==null&&UA(n.parent,n.name,n)}function UA(n,e,t){const s=VA(t),i=Lt(n.node.children,e);s&&i?(delete n.node.children[e],n.node.childCount--,el(n)):!s&&!i&&(n.node.children[e]=t.node,n.node.childCount++,el(n))}/**
3082 * @license
3083 * Copyright 2017 Google LLC
3084 *
3085 * Licensed under the Apache License, Version 2.0 (the "License");
3086 * you may not use this file except in compliance with the License.
3087 * You may obtain a copy of the License at
3088 *
3089 *   http://www.apache.org/licenses/LICENSE-2.0
3090 *
3091 * Unless required by applicable law or agreed to in writing, software
3092 * distributed under the License is distributed on an "AS IS" BASIS,
3093 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3094 * See the License for the specific language governing permissions and
3095 * limitations under the License.
3096 */const BA=/[\[\].#$\/\u0000-\u001F\u007F]/,qA=/[\[\].#$\u0000-\u001F\u007F]/,wa=10*1024*1024,j_=function(n){return typeof n=="string"&&n.length!==0&&!BA.test(n)},H_=function(n){return typeof n=="string"&&n.length!==0&&!qA.test(n)},$A=function(n){return n&&(n=n.replace(/^\/*\.info(\/|$)/,"/")),H_(n)},W_=function(n,e,t){const s=t instanceof se?new rC(t,n):t;if(e===void 0)throw new Error(n+"contains undefined "+_n(s));if(typeof e=="function")throw new Error(n+"contains a function "+_n(s)+" with contents = "+e.toString());if($p(e))throw new Error(n+"contains "+e.toString()+" "+_n(s));if(typeof e=="string"&&e.length>wa/3&&fo(e)>wa)throw new Error(n+"contains a string greater than "+wa+" utf8 bytes "+_n(s)+" ('"+e.substring(0,50)+"...')");if(e&&typeof e=="object"){let i=!1,r=!1;if(Ke(e,(o,l)=>{if(o===".value")i=!0;else if(o!==".priority"&&o!==".sv"&&(r=!0,!j_(o)))throw new Error(n+" contains an invalid key ("+o+") "+_n(s)+`.  Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"`);oC(s,o),W_(n,l,s),aC(s)}),i&&r)throw new Error(n+' contains ".value" child '+_n(s)+" in addition to actual children.")}},z_=function(n,e,t,s){if(!H_(t))throw new Error(yf(n,e)+'was an invalid path = "'+t+`". Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"`)},jA=function(n,e,t,s){t&&(t=t.replace(/^\/*\.info(\/|$)/,"/")),z_(n,e,t)},HA=function(n,e){const t=e.path.toString();if(typeof e.repoInfo.host!="string"||e.repoInfo.host.length===0||!j_(e.repoInfo.namespace)&&e.repoInfo.host.split(":")[0]!=="localhost"||t.length!==0&&!$A(t))throw new Error(yf(n,"url")+`must be a valid firebase URL and the path can't contain ".", "#", "$", "[", or "]".`)};/**
3097 * @license
3098 * Copyright 2017 Google LLC
3099 *
3100 * Licensed under the Apache License, Version 2.0 (the "License");
3101 * you may not use this file except in compliance with the License.
3102 * You may obtain a copy of the License at
3103 *
3104 *   http://www.apache.org/licenses/LICENSE-2.0
3105 *
3106 * Unless required by applicable law or agreed to in writing, software
3107 * distributed under the License is distributed on an "AS IS" BASIS,
3108 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3109 * See the License for the specific language governing permissions and
3110 * limitations under the License.
3111 */class WA{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function G_(n,e){let t=null;for(let s=0;s<e.length;s++){const i=e[s],r=i.getPath();t!==null&&!zl(r,t.path)&&(n.eventLists_.push(t),t=null),t===null&&(t={events:[],path:r}),t.events.push(i)}t&&n.eventLists_.push(t)}function K_(n,e,t){G_(n,t),Q_(n,s=>zl(s,e))}function cn(n,e,t){G_(n,t),Q_(n,s=>it(s,e)||it(e,s))}function Q_(n,e){n.recursionDepth_++;let t=!0;for(let s=0;s<n.eventLists_.length;s++){const i=n.eventLists_[s];if(i){const r=i.path;e(r)?(zA(n.eventLists_[s]),n.eventLists_[s]=null):t=!1}}t&&(n.eventLists_=[]),n.recursionDepth_--}function zA(n){for(let e=0;e<n.events.length;e++){const t=n.events[e];if(t!==null){n.events[e]=null;const s=t.getEventRunner();ti&&Le("event: "+t.toString()),xi(s)}}}/**
3112 * @license
3113 * Copyright 2017 Google LLC
3114 *
3115 * Licensed under the Apache License, Version 2.0 (the "License");
3116 * you may not use this file except in compliance with the License.
3117 * You may obtain a copy of the License at
3118 *
3119 *   http://www.apache.org/licenses/LICENSE-2.0
3120 *
3121 * Unless required by applicable law or agreed to in writing, software
3122 * distributed under the License is distributed on an "AS IS" BASIS,
3123 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3124 * See the License for the specific language governing permissions and
3125 * limitations under the License.
3126 */const GA="repo_interrupt",KA=25;class QA{constructor(e,t,s,i){this.repoInfo_=e,this.forceRestClient_=t,this.authTokenProvider_=s,this.appCheckProvider_=i,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new WA,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=Wr(),this.transactionQueueTree_=new cc,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function YA(n,e,t){if(n.stats_=Hl(n.repoInfo_),n.forceRestClient_||kw())n.server_=new Hr(n.repoInfo_,(s,i,r,o)=>{cd(n,s,i,r,o)},n.authTokenProvider_,n.appCheckProvider_),setTimeout(()=>ud(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{ye(t)}catch(s){throw new Error("Invalid authOverride provided: "+s)}}n.persistentConnection_=new Pt(n.repoInfo_,e,(s,i,r,o)=>{cd(n,s,i,r,o)},s=>{ud(n,s)},s=>{JA(n,s)},n.authTokenProvider_,n.appCheckProvider_,t),n.server_=n.persistentConnection_}n.authTokenProvider_.addTokenChangeListener(s=>{n.server_.refreshAuthToken(s)}),n.appCheckProvider_.addTokenChangeListener(s=>{n.server_.refreshAppCheckToken(s.token)}),n.statsReporter_=Mw(n.repoInfo_,()=>new OC(n.stats_,n.server_)),n.infoData_=new bC,n.infoSyncTree_=new ad({startListening:(s,i,r,o)=>{let l=[];const c=n.infoData_.getNode(s._path);return c.isEmpty()||(l=Li(n.infoSyncTree_,s._path,c),setTimeout(()=>{o("ok")},0)),l},stopListening:()=>{}}),hc(n,"connected",!1),n.serverSyncTree_=new ad({startListening:(s,i,r,o)=>(n.server_.listen(s,r,i,(l,c)=>{const h=o(l,c);cn(n.eventQueue_,s._path,h)}),[]),stopListening:(s,i)=>{n.server_.unlisten(s,i)}})}function XA(n){const t=n.infoData_.getNode(new se(".info/serverTimeOffset")).val()||0;return new Date().getTime()+t}function Y_(n){return DA({timestamp:XA(n)})}function cd(n,e,t,s,i){n.dataUpdateCount++;const r=new se(e);t=n.interceptServerDataCallback_?n.interceptServerDataCallback_(e,t):t;let o=[];if(i)if(s){const c=Or(t,h=>Ae(h));o=RA(n.serverSyncTree_,r,c,i)}else{const c=Ae(t);o=M_(n.serverSyncTree_,r,c,i)}else if(s){const c=Or(t,h=>Ae(h));o=wA(n.serverSyncTree_,r,c)}else{const c=Ae(t);o=Li(n.serverSyncTree_,r,c)}let l=r;o.length>0&&(l=pc(n,r)),cn(n.eventQueue_,l,o)}function ud(n,e){hc(n,"connected",e),e===!1&&tR(n)}function JA(n,e){Ke(e,(t,s)=>{hc(n,t,s)})}function hc(n,e,t){const s=new se("/.info/"+e),i=Ae(t);n.infoData_.updateSnapshot(s,i);const r=Li(n.infoSyncTree_,s,i);cn(n.eventQueue_,s,r)}function ZA(n){return n.nextWriteId_++}function eR(n,e,t){const s=SA(n.serverSyncTree_,e);return s!=null?Promise.resolve(s):n.server_.get(e).then(i=>{const r=Ae(i).withIndex(e._queryParams.getIndex());Za(n.serverSyncTree_,e,t,!0);let o;if(e._queryParams.loadsAllData())o=Li(n.serverSyncTree_,e._path,r);else{const l=wi(n.serverSyncTree_,e);o=M_(n.serverSyncTree_,e._path,r,l)}return cn(n.eventQueue_,e._path,o),Zr(n.serverSyncTree_,e,t,null,!0),r},i=>(dc(n,"get for query "+ye(e)+" failed: "+i),Promise.reject(new Error(i))))}function tR(n){dc(n,"onDisconnectEvents");const e=Y_(n),t=Wr();Ka(n.onDisconnect_,Z(),(i,r)=>{const o=MA(i,r,n.serverSyncTree_,e);v_(t,i,o)});let s=[];Ka(t,Z(),(i,r)=>
3126{s=s.concat(Li(n.serverSyncTree_,i,r));const o=oR(n,i);pc(n,o)}),n.onDisconnect_=Wr(),cn(n.eventQueue_,Z(),s)}function nR(n,e,t){let s;z(e._path)===".info"?s=Za(n.infoSyncTree_,e,t):s=Za(n.serverSyncTree_,e,t),K_(n.eventQueue_,e._path,s)}function hd(n,e,t){let s;z(e._path)===".info"?s=Zr(n.infoSyncTree_,e,t):s=Zr(n.serverSyncTree_,e,t),K_(n.eventQueue_,e._path,s)}function sR(n){n.persistentConnection_&&n.persistentConnection_.interrupt(GA)}function dc(n,...e){let t="";n.persistentConnection_&&(t=n.persistentConnection_.id+":"),Le(t,...e)}function X_(n,e,t){return L_(n.serverSyncTree_,e,t)||L.EMPTY_NODE}function fc(n,e=n.transactionQueueTree_){if(e||Ao(n,e),Ts(e)){const t=Z_(n,e);N(t.length>0,"Sending zero length transaction queue"),t.every(i=>i.status===0)&&iR(n,Fi(e),t)}else q_(e)&&Co(e,t=>{fc(n,t)})}function iR(n,e,t){const s=t.map(h=>h.currentWriteId),i=X_(n,e,s);let r=i;const o=i.hash();for(let h=0;h<t.length;h++){const f=t[h];N(f.status===0,"tryToSendTransactionQueue_: items in queue should all be run."),f.status=1,f.retryCount++;const p=je(e,f.path);r=r.updateChild(p,f.currentOutputSnapshotRaw)}const l=r.val(!0),c=e;n.server_.put(c.toString(),l,h=>{dc(n,"transaction put response",{path:c.toString(),status:h});let f=[];if(h==="ok"){const p=[];for(let g=0;g<t.length;g++)t[g].status=2,f=f.concat(Gn(n.serverSyncTree_,t[g].currentWriteId)),t[g].onComplete&&p.push(()=>t[g].onComplete(null,!0,t[g].currentOutputSnapshotResolved)),t[g].unwatcher();Ao(n,uc(n.transactionQueueTree_,e)),fc(n,n.transactionQueueTree_),cn(n.eventQueue_,e,f);for(let g=0;g<p.length;g++)xi(p[g])}else{if(h==="datastale")for(let p=0;p<t.length;p++)t[p].status===3?t[p].status=4:t[p].status=0;else{Je("transaction at "+c.toString()+" failed: "+h);for(let p=0;p<t.length;p++)t[p].status=4,t[p].abortReason=h}pc(n,e)}},o)}function pc(n,e){const t=J_(n,e),s=Fi(t),i=Z_(n,t);return rR(n,i,s),s}function rR(n,e,t){if(e.length===0)return;const s=[];let i=[];const o=e.filter(l=>l.status===0).map(l=>l.currentWriteId);for(let l=0;l<e.length;l++){const c=e[l],h=je(t,c.path);let f=!1,p;if(N(h!==null,"rerunTransactionsUnderNode_: relativePath should not be null."),c.status===4)f=!0,p=c.abortReason,i=i.concat(Gn(n.serverSyncTree_,c.currentWriteId,!0));else if(c.status===0)if(c.retryCount>=KA)f=!0,p="maxretry",i=i.concat(Gn(n.serverSyncTree_,c.currentWriteId,!0));else{const g=X_(n,c.path,o);c.currentInputSnapshot=g;const I=e[l].update(g.val());if(I!==void 0){W_("transaction failed: Data returned ",I,c.path);let S=Ae(I);typeof I=="object"&&I!=null&&Lt(I,".priority")||(S=S.updatePriority(g.getPriority()));const b=c.currentWriteId,B=Y_(n),H=LA(S,g,B);c.currentOutputSnapshotRaw=S,c.currentOutputSnapshotResolved=H,c.currentWriteId=ZA(n),o.splice(o.indexOf(b),1),i=i.concat(IA(n.serverSyncTree_,c.path,H,c.currentWriteId,c.applyLocally)),i=i.concat(Gn(n.serverSyncTree_,b,!0))}else f=!0,p="nodata",i=i.concat(Gn(n.serverSyncTree_,c.currentWriteId,!0))}cn(n.eventQueue_,t,i),i=[],f&&(e[l].status=2,function(g){setTimeout(g,Math.floor(0))}(e[l].unwatcher),e[l].onComplete&&(p==="nodata"?s.push(()=>e[l].onComplete(null,!1,e[l].currentInputSnapshot)):s.push(()=>e[l].onComplete(new Error(p),!1,null))))}Ao(n,n.transactionQueueTree_);for(let l=0;l<s.length;l++)xi(s[l]);fc(n,n.transactionQueueTree_)}function J_(n,e){let t,s=n.transactionQueueTree_;for(t=z(e);t!==null&&Ts(s)===void 0;)s=uc(s,t),e=ie(e),t=z(e);return s}function Z_(n,e){const t=[];return eg(n,e,t),t.sort((s,i)=>s.order-i.order),t}function eg(n,e,t){const s=Ts(e);if(s)for(let i=0;i<s.length;i++)t.push(s[i]);Co(e,i=>{eg(n,i,t)})}function Ao(n,e){const t=Ts(e);if(t){let s=0;for(let i=0;i<t.length;i++)t[i].status!==2&&(t[s]=t[i],s++);t.length=s,B_(e,t.length>0?t:void 0)}Co(e,s=>{Ao(n,s)})}function oR(n,e){const t=Fi(J_(n,e)),s=uc(n.transactionQueueTree_,e);return FA(s,i=>{Ca(n,i)}),Ca(n,s),$_(s,i=>{Ca(n,i)}),t}function Ca(n,e){const t=Ts(e);if(t){const s=[];let i=[],r=-1;for(let o=0;o<t.length;o++)t[o].status===3||(t[o].status===1?(N(r===o-1,"All SENT items should be at beginning of queue."),r=o,t[o].status=3,t[o].abortReason="set"):(N(t[o].status===0,"Unexpected transaction status in abort"),t[o].unwatcher(),i=i.
3126concat(Gn(n.serverSyncTree_,t[o].currentWriteId,!0)),t[o].onComplete&&s.push(t[o].onComplete.bind(null,new Error("set"),!1,null))));r===-1?B_(e,void 0):t.length=r+1,cn(n.eventQueue_,Fi(e),i);for(let o=0;o<s.length;o++)xi(s[o])}}/**
3127 * @license
3128 * Copyright 2017 Google LLC
3129 *
3130 * Licensed under the Apache License, Version 2.0 (the "License");
3131 * you may not use this file except in compliance with the License.
3132 * You may obtain a copy of the License at
3133 *
3134 *   http://www.apache.org/licenses/LICENSE-2.0
3135 *
3136 * Unless required by applicable law or agreed to in writing, software
3137 * distributed under the License is distributed on an "AS IS" BASIS,
3138 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3139 * See the License for the specific language governing permissions and
3140 * limitations under the License.
3141 */function aR(n){let e="";const t=n.split("/");for(let s=0;s<t.length;s++)if(t[s].length>0){let i=t[s];try{i=decodeURIComponent(i.replace(/\+/g," "))}catch{}e+="/"+i}return e}function lR(n){const e={};n.charAt(0)==="?"&&(n=n.substring(1));for(const t of n.split("&")){if(t.length===0)continue;const s=t.split("=");s.length===2?e[decodeURIComponent(s[0])]=decodeURIComponent(s[1]):Je(`Invalid query segment '${t}' in query '${n}'`)}return e}const dd=function(n,e){const t=cR(n),s=t.namespace;t.domain==="firebase.com"&&xt(t.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),(!s||s==="undefined")&&t.domain!=="localhost"&&xt("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),t.secure||Tw();const i=t.scheme==="ws"||t.scheme==="wss";return{repoInfo:new e_(t.host,t.secure,s,i,e,"",s!==t.subdomain),path:new se(t.pathString)}},cR=function(n){let e="",t="",s="",i="",r="",o=!0,l="https",c=443;if(typeof n=="string"){let h=n.indexOf("//");h>=0&&(l=n.substring(0,h-1),n=n.substring(h+2));let f=n.indexOf("/");f===-1&&(f=n.length);let p=n.indexOf("?");p===-1&&(p=n.length),e=n.substring(0,Math.min(f,p)),f<p&&(i=aR(n.substring(f,p)));const g=lR(n.substring(Math.min(n.length,p)));h=e.indexOf(":"),h>=0?(o=l==="https"||l==="wss",c=parseInt(e.substring(h+1),10)):h=e.length;const I=e.slice(0,h);if(I.toLowerCase()==="localhost")t="localhost";else if(I.split(".").length<=2)t=I;else{const S=e.indexOf(".");s=e.substring(0,S).toLowerCase(),t=e.substring(S+1),r=s}"ns"in g&&(r=g.ns)}return{host:e,port:c,domain:t,subdomain:s,secure:o,scheme:l,pathString:i,namespace:r}};/**
3142 * @license
3143 * Copyright 2017 Google LLC
3144 *
3145 * Licensed under the Apache License, Version 2.0 (the "License");
3146 * you may not use this file except in compliance with the License.
3147 * You may obtain a copy of the License at
3148 *
3149 *   http://www.apache.org/licenses/LICENSE-2.0
3150 *
3151 * Unless required by applicable law or agreed to in writing, software
3152 * distributed under the License is distributed on an "AS IS" BASIS,
3153 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3154 * See the License for the specific language governing permissions and
3155 * limitations under the License.
3156 */class tg{constructor(e,t,s,i){this.eventType=e,this.eventRegistration=t,this.snapshot=s,this.prevName=i}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+":"+ye(this.snapshot.exportVal())}}class ng{constructor(e,t,s){this.eventRegistration=e,this.error=t,this.path=s}getPath(){return this.path}getEventType(){return"cancel"}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.path.toString()+":cancel"}}/**
3157 * @license
3158 * Copyright 2017 Google LLC
3159 *
3160 * Licensed under the Apache License, Version 2.0 (the "License");
3161 * you may not use this file except in compliance with the License.
3162 * You may obtain a copy of the License at
3163 *
3164 *   http://www.apache.org/licenses/LICENSE-2.0
3165 *
3166 * Unless required by applicable law or agreed to in writing, software
3167 * distributed under the License is distributed on an "AS IS" BASIS,
3168 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3169 * See the License for the specific language governing permissions and
3170 * limitations under the License.
3171 */class sg{constructor(e,t){this.snapshotCallback=e,this.cancelCallback=t}onValue(e,t){this.snapshotCallback.call(null,e,t)}onCancel(e){return N(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}}/**
3172 * @license
3173 * Copyright 2020 Google LLC
3174 *
3175 * Licensed under the Apache License, Version 2.0 (the "License");
3176 * you may not use this file except in compliance with the License.
3177 * You may obtain a copy of the License at
3178 *
3179 *   http://www.apache.org/licenses/LICENSE-2.0
3180 *
3181 * Unless required by applicable law or agreed to in writing, software
3182 * distributed under the License is distributed on an "AS IS" BASIS,
3183 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3184 * See the License for the specific language governing permissions and
3185 * limitations under the License.
3186 */class _c{constructor(e,t,s,i){this._repo=e,this._path=t,this._queryParams=s,this._orderByCalled=i}get key(){return G(this._path)?null:c_(this._path)}get ref(){return new mt(this._repo,this._path)}get _queryIdentifier(){const e=Yh(this._queryParams),t=$l(e);return t==="{}"?"default":t}get _queryObject(){return Yh(this._queryParams)}isEqual(e){if(e=le(e),!(e instanceof _c))return!1;const t=this._repo===e._repo,s=zl(this._path,e._path),i=this._queryIdentifier===e._queryIdentifier;return t&&s&&i}toJSON(){return this.toString()}toString(){return this._repo.toString()+iC(this._path)}}class mt extends _c{constructor(e,t){super(e,t,new Yl,!1)}get parent(){const e=h_(this._path);return e===null?null:new mt(this._repo,e)}get root(){let e=this;for(;e.parent!==null;)e=e.parent;return e}}class cs{constructor(e,t,s){this._node=e,this.ref=t,this._index=s}get priority(){return this._node.getPriority().val()}get key(){return this.ref.key}get size(){return this._node.numChildren()}child(e){const t=new se(e),s=tl(this.ref,e);return new cs(this._node.getChild(t),s,ue)}exists(){return!this._node.isEmpty()}exportVal(){return this._node.val(!0)}forEach(e){return this._node.isLeafNode()?!1:!!this._node.forEachChild(this._index,(s,i)=>e(new cs(i,tl(this.ref,s),ue)))}hasChild(e){const t=new se(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 tl(n,e){return n=le(n),z(n._path)===null?jA("child","path",e):z_("child","path",e),new mt(n._repo,ve(n._path,e))}function TP(n){n=le(n);const e=new sg(()=>{}),t=new Ro(e);return eR(n._repo,n,t).then(s=>new cs(s,new mt(n._repo,n._path),n._queryParams.getIndex()))}class Ro{constructor(e){this.callbackContext=e}respondsTo(e){return e==="value"}createEvent(e,t){const s=t._queryParams.getIndex();return new tg("value",this,new cs(e.snapshotNode,new mt(t._repo,t._path),s))}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 ng(this,e,t):null}matches(e){return e instanceof Ro?!e.callbackContext||!this.callbackContext?!0:e.callbackContext.matches(this.callbackContext):!1}hasAnyCallback(){return this.callbackContext!==null}}class gc{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 ng(this,e,t):null}createEvent(e,t){N(e.childName!=null,"Child events should have a childName.");const s=tl(new mt(t._repo,t._path),e.childName),i=t._queryParams.getIndex();return new tg(e.type,this,new cs(e.snapshotNode,s,i),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 gc?this.eventType===e.eventType&&(!this.callbackContext||!e.callbackContext||this.callbackContext.matches(e.callbackContext)):!1}hasAnyCallback(){return!!this.callbackContext}}function Ui(n,e,t,s,i){let r;if(typeof s=="object"&&(r=void 0,i=s),typeof s=="function"&&(r=s),i&&i.onlyOnce){const c=t,h=(f,p)=>{hd(n._repo,n,l),c(f,p)};h.userCallback=t.userCallback,h.context=t.context,t=h}const o=new sg(t,r||void 0),l=e==="value"?new Ro(o):new gc(e,o);return nR(n._repo,n,l),()=>hd(n._repo,n,l)}function IP(n,e,t,s){return Ui(n,"value",e,t,s)}function wP(n,e,t,s){return Ui(n,"child_added",e,t,s)}function CP(n,e,t,s){return Ui(n,"child_changed",e,t,s)}function AP(n,e,t,s){return Ui(n,"child_moved",e,t,s)}function RP(n,e,t,s){return Ui(n,"child_removed",e,t,s)}pA(mt);vA(mt);/**
3187 * @license
3188 * Copyright 2020 Google LLC
3189 *
3190 * Licensed under the Apache License, Version 2.0 (the "License");
3191 * you may not use this file except in compliance with the License.
3192 * You may obtain a copy of the License at
3193 *
3194 *   http://www.apache.org/licenses/LICENSE-2.0
3195 *
3196 * Unless required by applicable law or agreed to in writing, software
3197 * distributed under the License is distributed on an "AS IS" BASIS,
3198 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3199 * See the License for the specific language governing permissions and
3200 * limitations under the License.
3201 */const uR="FIREBASE_DATABASE_EMULATOR_HOST",nl={};let hR=!1;function dR(n,e,t,s){n.repoInfo_=new e_(`${e}:${t}`,!1,n.repoInfo_.namespace,n.repoInfo_.webSocketOnly,n.repoInfo_.nodeAdmin,n.repoInfo_.persistenceKey,n.repoInfo_.includeNamespaceInQueryParams,!0),s&&(n.authTokenProvider_=s)}function fR(n,e,t,s,i){let r=s||n.options.databaseURL;r===void 0&&(n.options.projectId||xt("Can't determine Firebase Database URL. Be sure to include  a Project ID when calling firebase.initializeApp()."),Le("Using default host for project ",n.options.projectId),r=`${n.options.projectId}-default-rtdb.firebaseio.com`);let o=dd(r,i),l=o.repoInfo,c;typeof process<"u"&&Dh&&(c=Dh[uR]),c?(r=`http://${c}?ns=${l.namespace}`,o=dd(r,i),l=o.repoInfo):o.repoInfo.secure;const h=new Dw(n.name,n.options,e);HA("Invalid Firebase Database URL",o),G(o.path)||xt("Database URL must point to the root of a Firebase Database (not including a child path).");const f=_R(l,n,h,new Nw(n.name,t));return new gR(f,n)}function pR(n,e){const t=nl[e];(!t||t[n.key]!==n)&&xt(`Database ${e}(${n.repoInfo_}) has already been deleted.`),sR(n),delete t[n.key]}function _R(n,e,t,s){let i=nl[e.name];i||(i={},nl[e.name]=i);let r=i[n.toURLString()];return r&&xt("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),r=new QA(n,hR,t,s),i[n.toURLString()]=r,r}class gR{constructor(e,t){this._repoInternal=e,this.app=t,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(YA(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new mt(this._repo,Z())),this._rootInternal}_delete(){return this._rootInternal!==null&&(pR(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(e){this._rootInternal===null&&xt("Cannot call "+e+" on a deleted database.")}}function SP(n=vs(),e){const t=gt(n,"database").getImmediate({identifier:e});if(!t._instanceStarted){const s=vl("database");s&&mR(t,...s)}return t}function mR(n,e,t,s={}){n=le(n),n._checkNotDeleted("useEmulator"),n._instanceStarted&&xt("Cannot call useEmulator() after instance has already been initialized.");const i=n._repoInternal;let r;if(i.repoInfo_.nodeAdmin)s.mockUserToken&&xt('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 Ar(Ar.OWNER);else if(s.mockUserToken){const o=typeof s.mockUserToken=="string"?s.mockUserToken:El(s.mockUserToken,n.app.options.projectId);r=new Ar(o)}dR(i,e,t,r)}/**
3202 * @license
3203 * Copyright 2021 Google LLC
3204 *
3205 * Licensed under the Apache License, Version 2.0 (the "License");
3206 * you may not use this file except in compliance with the License.
3207 * You may obtain a copy of the License at
3208 *
3209 *   http://www.apache.org/licenses/LICENSE-2.0
3210 *
3211 * Unless required by applicable law or agreed to in writing, software
3212 * distributed under the License is distributed on an "AS IS" BASIS,
3213 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3214 * See the License for the specific language governing permissions and
3215 * limitations under the License.
3216 */function yR(n){_w(ln),Ge(new He("database",(e,{instanceIdentifier:t})=>{const s=e.getProvider("app").getImmediate(),i=e.getProvider("auth-internal"),r=e.getProvider("app-check-internal");return fR(s,i,r,t)},"PUBLIC").setMultipleInstances(!0)),Re(Oh,xh,n),Re(Oh,xh,"esm2017")}Pt.prototype.simpleListen=function(n,e){this.sendRequest("q",{p:n},e)};Pt.prototype.echo=function(n,e){this.sendRequest("echo",{d:n},e)};
vendor: 53,514 bytes, lines 3216-3257
3216yR();var fd=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
3217Copyright The Closure Library Authors.
3218SPDX-License-Identifier: Apache-2.0
3219*/var En,ig;(function(){var n;/** @license
3220
3221 Copyright The Closure Library Authors.
3222 SPDX-License-Identifier: Apache-2.0
3223*/function e(T,m){function y(){}y.prototype=m.prototype,T.D=m.prototype,T.prototype=new y,T.prototype.constructor=T,T.C=function(E,w,A){for(var v=Array(arguments.length-2),yt=2;yt<arguments.length;yt++)v[yt-2]=arguments[yt];return m.prototype[w].apply(E,v)}}function t(){this.blockSize=-1}function s(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.B=Array(this.blockSize),this.o=this.h=0,this.s()}e(s,t),s.prototype.s=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function i(T,m,y){y||(y=0);var E=Array(16);if(typeof m=="string")for(var w=0;16>w;++w)E[w]=m.charCodeAt(y++)|m.charCodeAt(y++)<<8|m.charCodeAt(y++)<<16|m.charCodeAt(y++)<<24;else for(w=0;16>w;++w)E[w]=m[y++]|m[y++]<<8|m[y++]<<16|m[y++]<<24;m=T.g[0],y=T.g[1],w=T.g[2];var A=T.g[3],v=m+(A^y&(w^A))+E[0]+3614090360&4294967295;m=y+(v<<7&4294967295|v>>>25),v=A+(w^m&(y^w))+E[1]+3905402710&4294967295,A=m+(v<<12&4294967295|v>>>20),v=w+(y^A&(m^y))+E[2]+606105819&4294967295,w=A+(v<<17&4294967295|v>>>15),v=y+(m^w&(A^m))+E[3]+3250441966&4294967295,y=w+(v<<22&4294967295|v>>>10),v=m+(A^y&(w^A))+E[4]+4118548399&4294967295,m=y+(v<<7&4294967295|v>>>25),v=A+(w^m&(y^w))+E[5]+1200080426&4294967295,A=m+(v<<12&4294967295|v>>>20),v=w+(y^A&(m^y))+E[6]+2821735955&4294967295,w=A+(v<<17&4294967295|v>>>15),v=y+(m^w&(A^m))+E[7]+4249261313&4294967295,y=w+(v<<22&4294967295|v>>>10),v=m+(A^y&(w^A))+E[8]+1770035416&4294967295,m=y+(v<<7&4294967295|v>>>25),v=A+(w^m&(y^w))+E[9]+2336552879&4294967295,A=m+(v<<12&4294967295|v>>>20),v=w+(y^A&(m^y))+E[10]+4294925233&4294967295,w=A+(v<<17&4294967295|v>>>15),v=y+(m^w&(A^m))+E[11]+2304563134&4294967295,y=w+(v<<22&4294967295|v>>>10),v=m+(A^y&(w^A))+E[12]+1804603682&4294967295,m=y+(v<<7&4294967295|v>>>25),v=A+(w^m&(y^w))+E[13]+4254626195&4294967295,A=m+(v<<12&4294967295|v>>>20),v=w+(y^A&(m^y))+E[14]+2792965006&4294967295,w=A+(v<<17&4294967295|v>>>15),v=y+(m^w&(A^m))+E[15]+1236535329&4294967295,y=w+(v<<22&4294967295|v>>>10),v=m+(w^A&(y^w))+E[1]+4129170786&4294967295,m=y+(v<<5&4294967295|v>>>27),v=A+(y^w&(m^y))+E[6]+3225465664&4294967295,A=m+(v<<9&4294967295|v>>>23),v=w+(m^y&(A^m))+E[11]+643717713&4294967295,w=A+(v<<14&4294967295|v>>>18),v=y+(A^m&(w^A))+E[0]+3921069994&4294967295,y=w+(v<<20&4294967295|v>>>12),v=m+(w^A&(y^w))+E[5]+3593408605&4294967295,m=y+(v<<5&4294967295|v>>>27),v=A+(y^w&(m^y))+E[10]+38016083&4294967295,A=m+(v<<9&4294967295|v>>>23),v=w+(m^y&(A^m))+E[15]+3634488961&4294967295,w=A+(v<<14&4294967295|v>>>18),v=y+(A^m&(w^A))+E[4]+3889429448&4294967295,y=w+(v<<20&4294967295|v>>>12),v=m+(w^A&(y^w))+E[9]+568446438&4294967295,m=y+(v<<5&4294967295|v>>>27),v=A+(y^w&(m^y))+E[14]+3275163606&4294967295,A=m+(v<<9&4294967295|v>>>23),v=w+(m^y&(A^m))+E[3]+4107603335&4294967295,w=A+(v<<14&4294967295|v>>>18),v=y+(A^m&(w^A))+E[8]+1163531501&4294967295,y=w+(v<<20&4294967295|v>>>12),v=m+(w^A&(y^w))+E[13]+2850285829&4294967295,m=y+(v<<5&4294967295|v>>>27),v=A+(y^w&(m^y))+E[2]+4243563512&4294967295,A=m+(v<<9&4294967295|v>>>23),v=w+(m^y&(A^m))+E[7]+1735328473&4294967295,w=A+(v<<14&4294967295|v>>>18),v=y+(A^m&(w^A))+E[12]+2368359562&4294967295,y=w+(v<<20&4294967295|v>>>12),v=m+(y^w^A)+E[5]+4294588738&4294967295,m=y+(v<<4&4294967295|v>>>28),v=A+(m^y^w)+E[8]+2272392833&4294967295,A=m+(v<<11&4294967295|v>>>21),v=w+(A^m^y)+E[11]+1839030562&4294967295,w=A+(v<<16&4294967295|v>>>16),v=y+(w^A^m)+E[14]+4259657740&4294967295,y=w+(v<<23&4294967295|v>>>9),v=m+(y^w^A)+E[1]+2763975236&4294967295,m=y+(v<<4&4294967295|v>>>28),v=A+(m^y^w)+E[4]+1272893353&4294967295,A=m+(v<<11&4294967295|v>>>21),v=w+(A^m^y)+E[7]+4139469664&4294967295,w=A+(v<<16&4294967295|v>>>16),v=y+(w^A^m)+E[10]+3200236656&4294967295,y=w+(v<<23&4294967295|v>>>9),v=m+(y^w^A)+E[13]+681279174&4294967295,m=y+(v<<4&4294967295|v>>>28),v=A+(m^y^w)+E[0]+3936430074&4294967295,A=m+(v<<11&4294967295|v>>>21),v=w+(A^m^y)+E[3]+3572445317&4294967295,w=A+(v<<16&4294967295|v>>>16),v=y+(w^A^m)+E[6]+76029189&4294967295,y=w+(v<<23&4294967295|v>>>9),v=m+(y^w^A)+E[9]+3654602809&4294967295,m=y+(v<<4&4294967295|v>>>28),v=A+(m^y^w)+E[12]+3873151461&4294967295,A=m+(v<<11&4294967295|v>>>21),v=w+(A^m^y)+E[15]+530742520&4294967295,w=A+(v<<16&4294967295|v>>>16),v=y+(w^A^m)+E[2]+3299628645&4294967295,y=w+(v<<23&4294967295|v>>>9),v=m+(w^(y|~A))+E[0]+4096336452&4294967295,m=y+(v<<6&4294967295|v>>>26),v=A+(y^(m|~w))+E[7]+1126891415&4294967295,A=m+(v<<10&4294967295|v>>>22),v=w+(m^(A|~y))+E[14]+2878612391&4294967295,w=A+(v<<15&4294967295|v>>>17),v=y+(A^(w|~m))+E[5]+4237533241&4294967295,y=w+(v<<21&4294967295|v>>>11),v=m+(w^(y|~A))+E[12]+1700485571&4294967295,m=y+(v<<6&4294967295|v>>>26),v=A+(y^(m|~w))+E[3]+2399980690&4294967295,A=m+(v<<10&4294967295|v>>>22),v=w+(m^(A|~y))+E[10]+4293915773&4294967295,w=A+(v<<15&4294967295|v>>>17),v=y+(A^(w|~m))+E[1]+2240044497&4294967295,y=w+(v<<21&4294967295|v>>>11),v=m+(w^(y|~A))+E[8]+1873313359&4294967295,m=y+(v<<6&4294967295|v>>>26),v=A+(y^(m|~w))+E[15]+4264355552&4294967295,A=m+(v<<10&4294967295|v>>>22),v=w+(m^(A|~y))+E[6]+2734768916&4294967295,w=A+(v<<15&4294967295|v>>>17),v=y+(A^(w|~m))+E[13]+1309151649&4294967295,y=w+(v<<21&4294967295|v>>>11),v=m+(w^(y|~A))+E[4]+4149444226&4294967295,m=y+(v<<6&4294967295|v>>>26),v=A+(y^(m|~w))+E[11]+3174756917&4294967295,A=m+(v<<10&4294967295|v>>>22),v=w+(m^(A|~y))+E[2]+718787259&4294967295,w=A+(v<<15&4294967295|v>>>17),v=y+(A^(w|~m))+E[9]+3951481745&4294967295,T.g[0]=T.g[0]+m&4294967295,T.g[1]=T.g[1]+(w+(v<<21&4294967295|v>>>11))&4294967295,T.g[2]=T.g[2]+w&4294967295,T.g[3]=T.g[3]+A&4294967295}s.prototype.u=function(T,m){m===void 0&&(m=T.length);for(var y=m-this.blockSize,E=this.B,w=this.h,A=0;A<m;){if(w==0)for(;A<=y;)i(this,T,A),A+=this.blockSize;if(typeof T=="string"){for(;A<m;)if(E[w++]=T.charCodeAt(A++),w==this.blockSize){i(this,E),w=0;break}}else for(;A<m;)if(E[w++]=T[A++],w==this.blockSize){i(this,E),w=0;break}}this.h=w,this.o+=m},s.prototype.v=function(){var T=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);T[0]=128;for(var m=1;m<T.length-8;++m)T[m]=0;var y=8*this.o;for(m=T.length-8;m<T.length;++m)T[m]=y&255,y/=256;for(this.u(T),T=Array(16),m=y=0;4>m;++m)for(var E=0;32>E;E+=8)T[y++]=this.g[m]>>>E&255;return T};function r(T,m){var y=l;return Object.prototype.hasOwnProperty.call(y,T)?y[T]:y[T]=m(T)}function o(T,m){this.h=m;for(var y=[],E=!0,w=T.length-1;0<=w;w--){var A=T[w]|0;E&&A==m||(y[w]=A,E=!1)}this.g=y}var l={};function c(T){return-128<=T&&128>T?r(T,function(m){return new o([m|0],0>m?-1:0)}):new o([T|0],0>T?-1:0)}function h(T){if(isNaN(T)||!isFinite(T))return p;if(0>T)return b(h(-T));for(var m=[],y=1,E=0;T>=y;E++)m[E]=T/y|0,y*=4294967296;return new o(m,0)}function f(T,m){if(T.length==0)throw Error("number format error: empty string");if(m=m||10,2>m||36<m)throw Error("radix out of range: "+m);if(T.charAt(0)=="-")return b(f(T.substring(1),m));if(0<=T.indexOf("-"))throw Error('number format error: interior "-" character');for(var y=h(Math.pow(m,8)),E=p,w=0;w<T.length;w+=8){var A=Math.min(8,T.length-w),v=parseInt(T.substring(w,w+A),m);8>A?(A=h(Math.pow(m,A)),E=E.j(A).add(h(v))):(E=E.j(y),E=E.add(h(v)))}return E}var p=c(0),g=c(1),I=c(16777216);n=o.prototype,n.m=function(){if(k(this))return-b(this).m();for(var T=0,m=1,y=0;y<this.g.length;y++){var E=this.i(y);T+=(0<=E?E:4294967296+E)*m,m*=4294967296}return T},n.toString=function(T){if(T=T||10,2>T||36<T)throw Error("radix out of range: "+T);if(S(this))return"0";if(k(this))return"-"+b(this).toString(T);for(var m=h(Math.pow(T,6)),y=this,E="";;){var w=$(y,m).g;y=B(y,w.j(m));var A=((0<y.g.length?y.g[0]:y.h)>>>0).toString(T);if(y=w,S(y))return A+E;for(;6>A.length;)A="0"+A;E=A+E}},n.i=function(T){return 0>T?0:T<this.g.length?this.g[T]:this.h};function S(T){if(T.h!=0)return!1;for(var m=0;m<T.g.length;m++)if(T.g[m]!=0)return!1;return!0}function k(T){return T.h==-1}n.l=function(T){return T=B(this,T),k(T)?-1:S(T)?0:1};function b(T){for(var m=T.g.length,y=[],E=0;E<m;E++)y[E]=~T.g[E];return new o(y,~T.h).add(g)}n.abs=function(){return k(this)?b(this):this},n.add=function(T){for(var m=Math.max(this.g.length,T.g.length),y=[],E=0,w=0;w<=m;w++){var A=E+(this.i(w)&65535)+(T.i(w)&65535),v=(A>>>16)+(this.i(w)>>>16)+(T.i(w)>>>16);E=v>>>16,A&=65535,v&=65535,y[w]=v<<16|A}return new o(y,y[y.length-1]&-2147483648?-1:0)};function B(T,m){return T.add(b(m))}n.j=function(T){if(S(this)||S(T))return p;if(k(this))return k(T)?b(this).j(b(T)):b(b(this).j(T));if(k(T))return b(this.j(b(T)));if(0>this.l(I)&&0>T.l(I))return h(this.m()*T.m());for(var m=this.g.length+T.g.length,y=[],E=0;E<2*m;E++)y[E]=0;for(E=0;E<this.g.length;E++)for(var w=0;w<T.g.length;w++){var A=this.i(E)>>>16,v=this.i(E)&65535,yt=T.i(w)>>>16,Rs=T.i(w)&65535;y[2*E+2*w]+=v*Rs,H(y,2*E+2*w),y[2*E+2*w+1]+=A*Rs,H(y,2*E+2*w+1),y[2*E+2*w+1]+=v*yt,H(y,2*E+2*w+1),y[2*E+2*w+2]+=A*yt,H(y,2*E+2*w+2)}for(E=0;E<m;E++)y[E]=y[2*E+1]<<16|y[2*E];for(E=m;E<2*m;E++)y[E]=0;return new o(y,0)};function H(T,m){for(;(T[m]&65535)!=T[m];)T[m+1]+=T[m]>>>16,T[m]&=65535,m++}function V(T,m){this.g=T,this.h=m}function $(T,m){if(S(m))throw Error("division by zero");if(S(T))return new V(p,p);if(k(T))return m=$(b(T),m),new V(b(m.g),b(m.h));if(k(m))return m=$(T,b(m)),new V(b(m.g),m.h);if(30<T.g.length){if(k(T)||k(m))throw Error("slowDivide_ only works with positive integers.");for(var y=g,E=m;0>=E.l(T);)y=me(y),E=me(E);var w=te(y,1),A=te(E,1);for(E=te(E,2),y=te(y,2);!S(E);){var v=A.add(E);0>=v.l(T)&&(w=w.add(y),A=v),E=te(E,1),y=te(y,1)}return m=B(T,w.j(m)),new V(w,m)}for(w=p;0<=T.l(m);){for(y=Math.max(1,Math.floor(T.m()/m.m())),E=Math.ceil(Math.log(y)/Math.LN2),E=48>=E?1:Math.pow(2,E-48),A=h(y),v=A.j(m);k(v)||0<v.l(T);)y-=E,A=h(y),v=A.j(m);S(A)&&(A=g),w=w.add(A),T=B(T,v)}return new V(w,T)}n.A=function(T){return $(this,T).h},n.and=function(T){for(var m=Math.max(this.g.length,T.g.length),y=[],E=0;E<m;E++)y[E]=this.i(E)&T.i(E);return new o(y,this.h&T.h)},n.or=function(T){for(var m=Math.max(this.g.length,T.g.length),y=[],E=0;E<m;E++)y[E]=this.i(E)|T.i(E);return new o(y,this.h|T.h)},n.xor=function(T){for(var m=Math.max(this.g.length,T.g.length),y=[],E=0;E<m;E++)y[E]=this.i(E)^T.i(E);return new o(y,this.h^T.h)};function me(T){for(var m=T.g.length+1,y=[],E=0;E<m;E++)y[E]=T.i(E)<<1|T.i(E-1)>>>31;return new o(y,T.h)}function te(T,m){var y=m>>5;m%=32;for(var E=T.g.length-y,w=[],A=0;A<E;A++)w[A]=0<m?T.i(A+y)>>>m|T.i(A+y+1)<<32-m:T.i(A+y);return new o(w,T.h)}s.prototype.digest=s.prototype.v,s.prototype.reset=s.prototype.s,s.prototype.update=s.prototype.u,ig=s,o.prototype.add=o.prototype.add,o.prototype.multiply=o.prototype.j,o.prototype.modulo=o.prototype.A,o.prototype.compare=o.prototype.l,o.prototype.toNumber=o.prototype.m,o.prototype.toString=o.prototype.toString,o.prototype.getBits=o.prototype.i,o.fromNumber=h,o.fromString=f,En=o}).apply(typeof fd<"u"?fd:typeof self<"u"?self:typeof window<"u"?window:{});var _r=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
3224Copyright The Closure Library Authors.
3225SPDX-License-Identifier: Apache-2.0
3226*/var rg,Ys,og,Sr,sl,ag,lg,cg;(function(){var n,e=typeof Object.defineProperties=="function"?Object.defineProperty:function(a,u,d){return a==Array.prototype||a==Object.prototype||(a[u]=d.value),a};function t(a){a=[typeof globalThis=="object"&&globalThis,a,typeof window=="object"&&window,typeof self=="object"&&self,typeof _r=="object"&&_r];for(var u=0;u<a.length;++u){var d=a[u];if(d&&d.Math==Math)return d}throw Error("Cannot find global object")}var s=t(this);function i(a,u){if(u)e:{var d=s;a=a.split(".");for(var _=0;_<a.length-1;_++){var C=a[_];if(!(C in d))break e;d=d[C]}a=a[a.length-1],_=d[a],u=u(_),u!=_&&u!=null&&e(d,a,{configurable:!0,writable:!0,value:u})}}function r(a,u){a instanceof String&&(a+="");var d=0,_=!1,C={next:function(){if(!_&&d<a.length){var R=d++;return{value:u(R,a[R]),done:!1}}return _=!0,{done:!0,value:void 0}}};return C[Symbol.iterator]=function(){return C},C}i("Array.prototype.values",function(a){return a||function(){return r(this,function(u,d){return d})}});/** @license
3227
3228 Copyright The Closure Library Authors.
3229 SPDX-License-Identifier: Apache-2.0
3230*/var o=o||{},l=this||self;function c(a){var u=typeof a;return u=u!="object"?u:a?Array.isArray(a)?"array":u:"null",u=="array"||u=="object"&&typeof a.length=="number"}function h(a){var u=typeof a;return u=="object"&&a!=null||u=="function"}function f(a,u,d){return a.call.apply(a.bind,arguments)}function p(a,u,d){if(!a)throw Error();if(2<arguments.length){var _=Array.prototype.slice.call(arguments,2);return function(){var C=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(C,_),a.apply(u,C)}}return function(){return a.apply(u,arguments)}}function g(a,u,d){return g=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?f:p,g.apply(null,arguments)}function I(a,u){var d=Array.prototype.slice.call(arguments,1);return function(){var _=d.slice();return _.push.apply(_,arguments),a.apply(this,_)}}function S(a,u){function d(){}d.prototype=u.prototype,a.aa=u.prototype,a.prototype=new d,a.prototype.constructor=a,a.Qb=function(_,C,R){for(var D=Array(arguments.length-2),ne=2;ne<arguments.length;ne++)D[ne-2]=arguments[ne];return u.prototype[C].apply(_,D)}}function k(a){const u=a.length;if(0<u){const d=Array(u);for(let _=0;_<u;_++)d[_]=a[_];return d}return[]}function b(a,u){for(let d=1;d<arguments.length;d++){const _=arguments[d];if(c(_)){const C=a.length||0,R=_.length||0;a.length=C+R;for(let D=0;D<R;D++)a[C+D]=_[D]}else a.push(_)}}class B{constructor(u,d){this.i=u,this.j=d,this.h=0,this.g=null}get(){let u;return 0<this.h?(this.h--,u=this.g,this.g=u.next,u.next=null):u=this.i(),u}}function H(a){return/^[\s\xa0]*$/.test(a)}function V(){var a=l.navigator;return a&&(a=a.userAgent)?a:""}function $(a){return $[" "](a),a}$[" "]=function(){};var me=V().indexOf("Gecko")!=-1&&!(V().toLowerCase().indexOf("webkit")!=-1&&V().indexOf("Edge")==-1)&&!(V().indexOf("Trident")!=-1||V().indexOf("MSIE")!=-1)&&V().indexOf("Edge")==-1;function te(a,u,d){for(const _ in a)u.call(d,a[_],_,a)}function T(a,u){for(const d in a)u.call(void 0,a[d],d,a)}function m(a){const u={};for(const d in a)u[d]=a[d];return u}const y="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function E(a,u){let d,_;for(let C=1;C<arguments.length;C++){_=arguments[C];for(d in _)a[d]=_[d];for(let R=0;R<y.length;R++)d=y[R],Object.prototype.hasOwnProperty.call(_,d)&&(a[d]=_[d])}}function w(a){var u=1;a=a.split(":");const d=[];for(;0<u&&a.length;)d.push(a.shift()),u--;return a.length&&d.push(a.join(":")),d}function A(a){l.setTimeout(()=>{throw a},0)}function v(){var a=Bo;let u=null;return a.g&&(u=a.g,a.g=a.g.next,a.g||(a.h=null),u.next=null),u}class yt{constructor(){this.h=this.g=null}add(u,d){const _=Rs.get();_.set(u,d),this.h?this.h.next=_:this.g=_,this.h=_}}var Rs=new B(()=>new Im,a=>a.reset());class Im{constructor(){this.next=this.g=this.h=null}set(u,d){this.h=u,this.g=d,this.next=null}reset(){this.next=this.g=this.h=null}}let Ss,bs=!1,Bo=new yt,Yc=()=>{const a=l.Promise.resolve(void 0);Ss=()=>{a.then(wm)}};var wm=()=>{for(var a;a=v();){try{a.h.call(a.g)}catch(d){A(d)}var u=Rs;u.j(a),100>u.h&&(u.h++,a.next=u.g,u.g=a)}bs=!1};function Vt(){this.s=this.s,this.C=this.C}Vt.prototype.s=!1,Vt.prototype.ma=function(){this.s||(this.s=!0,this.N())},Vt.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function ke(a,u){this.type=a,this.g=this.target=u,this.defaultPrevented=!1}ke.prototype.h=function(){this.defaultPrevented=!0};var Cm=function(){if(!l.addEventListener||!Object.defineProperty)return!1;var a=!1,u=Object.defineProperty({},"passive",{get:function(){a=!0}});try{const d=()=>{};l.addEventListener("test",d,u),l.removeEventListener("test",d,u)}catch{}return a}();function Ps(a,u){if(ke.call(this,a?a.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,a){var d=this.type=a.type,_=a.changedTouches&&a.changedTouches.length?a.changedTouches[0]:null;if(this.target=a.target||a.srcElement,this.g=u,u=a.relatedTarget){if(me){e:{try{$(u.nodeName);var C=!0;break e}catch{}C=!1}C||(u=null)}}else d=="mouseover"?u=a.fromElement:d=="mouseout"&&(u=a.toElement);this.relatedTarget=u,_?(this.clientX=_.clientX!==void 0?_.clientX:_.pageX,this.clientY=_.clientY!==void 0?_.clientY:_.pageY,this.screenX=_.screenX||0,this.screenY=_.screenY||0):(this.clientX=a.clientX!==void 0?a.clientX:a.pageX,this.clientY=a.clientY!==void 0?a.clientY:a.pageY,this.screenX=a.screenX||0,this.screenY=a.screenY||0),this.button=a.button,this.key=a.key||"",this.ctrlKey=a.ctrlKey,this.altKey=a.altKey,this.shiftKey=a.shiftKey,this.metaKey=a.metaKey,this.pointerId=a.pointerId||0,this.pointerType=typeof a.pointerType=="string"?a.pointerType:Am[a.pointerType]||"",this.state=a.state,this.i=a,a.defaultPrevented&&Ps.aa.h.call(this)}}S(Ps,ke);var Am={2:"touch",3:"pen",4:"mouse"};Ps.prototype.h=function(){Ps.aa.h.call(this);var a=this.i;a.preventDefault?a.preventDefault():a.returnValue=!1};var zi="closure_listenable_"+(1e6*Math.random()|0),Rm=0;function Sm(a,u,d,_,C){this.listener=a,this.proxy=null,this.src=u,this.type=d,this.capture=!!_,this.ha=C,this.key=++Rm,this.da=this.fa=!1}function Gi(a){a.da=!0,a.listener=null,a.proxy=null,a.src=null,a.ha=null}function Ki(a){this.src=a,this.g={},this.h=0}Ki.prototype.add=function(a,u,d,_,C){var R=a.toString();a=this.g[R],a||(a=this.g[R]=[],this.h++);var D=$o(a,u,_,C);return-1<D?(u=a[D],d||(u.fa=!1)):(u=new Sm(u,this.src,R,!!_,C),u.fa=d,a.push(u)),u};function qo(a,u){var d=u.type;if(d in a.g){var _=a.g[d],C=Array.prototype.indexOf.call(_,u,void 0),R;(R=0<=C)&&Array.prototype.splice.call(_,C,1),R&&(Gi(u),a.g[d].length==0&&(delete a.g[d],a.h--))}}function $o(a,u,d,_){for(var C=0;C<a.length;++C){var R=a[C];if(!R.da&&R.listener==u&&R.capture==!!d&&R.ha==_)return C}return-1}var jo="closure_lm_"+(1e6*Math.random()|0),Ho={};function Xc(a,u,d,_,C){if(Array.isArray(u)){for(var R=0;R<u.length;R++)Xc(a,u[R],d,_,C);return null}return d=eu(d),a&&a[zi]?a.K(u,d,h(_)?!!_.capture:!1,C):bm(a,u,d,!1,_,C)}function bm(a,u,d,_,C,R){if(!u)throw Error("Invalid event type");var D=h(C)?!!C.capture:!!C,ne=zo(a);if(ne||(a[jo]=ne=new Ki(a)),d=ne.add(u,d,_,D,R),d.proxy)return d;if(_=Pm(),d.proxy=_,_.src=a,_.listener=d,a.addEventListener)Cm||(C=D),C===void 0&&(C=!1),a.addEventListener(u.toString(),_,C);else if(a.attachEvent)a.attachEvent(Zc(u.toString()),_);else if(a.addListener&&a.removeListener)a.addListener(_);else throw Error("addEventListener and attachEvent are unavailable.");return d}function Pm(){function a(d){return u.call(a.src,a.listener,d)}const u=km;return a}function Jc(a,u,d,_,C){if(Array.isArray(u))for(var R=0;R<u.length;R++)Jc(a,u[R],d,_,C);else _=h(_)?!!_.capture:!!_,d=eu(d),a&&a[zi]?(a=a.i,u=String(u).toString(),u in a.g&&(R=a.g[u],d=$o(R,d,_,C),-1<d&&(Gi(R[d]),Array.prototype.splice.call(R,d,1),R.length==0&&(delete a.g[u],a.h--)))):a&&(a=zo(a))&&(u=a.g[u.toString()],a=-1,u&&(a=$o(u,d,_,C)),(d=-1<a?u[a]:null)&&Wo(d))}function Wo(a){if(typeof a!="number"&&a&&!a.da){var u=a.src;if(u&&u[zi])qo(u.i,a);else{var d=a.type,_=a.proxy;u.removeEventListener?u.removeEventListener(d,_,a.capture):u.detachEvent?u.detachEvent(Zc(d),_):u.addListener&&u.removeListener&&u.removeListener(_),(d=zo(u))?(qo(d,a),d.h==0&&(d.src=null,u[jo]=null)):Gi(a)}}}function Zc(a){return a in Ho?Ho[a]:Ho[a]="on"+a}function km(a,u){if(a.da)a=!0;else{u=new Ps(u,this);var d=a.listener,_=a.ha||a.src;a.fa&&Wo(a),a=d.call(_,u)}return a}function zo(a){return a=a[jo],a instanceof Ki?a:null}var Go="__closure_events_fn_"+(1e9*Math.random()>>>0);function eu(a){return typeof a=="function"?a:(a[Go]||(a[Go]=function(u){return a.handleEvent(u)}),a[Go])}function Ne(){Vt.call(this),this.i=new Ki(this),this.M=this,this.F=null}S(Ne,Vt),Ne.prototype[zi]=!0,Ne.prototype.removeEventListener=function(a,u,d,_){Jc(this,a,u,d,_)};function Ue(a,u){var d,_=a.F;if(_)for(d=[];_;_=_.F)d.push(_);if(a=a.M,_=u.type||u,typeof u=="string")u=new ke(u,a);else if(u instanceof ke)u.target=u.target||a;else{var C=u;u=new ke(_,a),E(u,C)}if(C=!0,d)for(var R=d.length-1;0<=R;R--){var D=u.g=d[R];C=Qi(D,_,!0,u)&&C}if(D=u.g=a,C=Qi(D,_,!0,u)&&C,C=Qi(D,_,!1,u)&&C,d)for(R=0;R<d.length;R++)D=u.g=d[R],C=Qi(D,_,!1,u)&&C}Ne.prototype.N=function(){if(Ne.aa.N.call(this),this.i){var a=this.i,u;for(u in a.g){for(var d=a.g[u],_=0;_<d.length;_++)Gi(d[_]);delete a.g[u],a.h--}}this.F=null},Ne.prototype.K=function(a,u,d,_){return this.i.add(String(a),u,!1,d,_)},Ne.prototype.L=function(a,u,d,_){return this.i.add(String(a),u,!0,d,_)};function Qi(a,u,d,_){if(u=a.i.g[String(u)],!u)return!0;u=u.concat();for(var C=!0,R=0;R<u.length;++R){var D=u[R];if(D&&!D.da&&D.capture==d){var ne=D.listener,we=D.ha||D.src;D.fa&&qo(a.i,D),C=ne.call(we,_)!==!1&&C}}return C&&!_.defaultPrevented}function tu(a,u,d){if(typeof a=="function")d&&(a=g(a,d));else if(a&&typeof a.handleEvent=="function")a=g(a.handleEvent,a);else throw Error("Invalid listener argument");return 2147483647<Number(u)?-1:l.setTimeout(a,u||0)}function nu(a){a.g=tu(()=>{a.g=null,a.i&&(a.i=!1,nu(a))},a.l);const u=a.h;a.h=null,a.m.apply(null,u)}class Nm extends Vt{constructor(u,d){super(),this.m=u,this.l=d,this.h=null,this.i=!1,this.g=null}j(u){this.h=arguments,this.g?this.i=!0:nu(this)}N(){super.N(),this.g&&(l.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function ks(a){Vt.call(this),this.h=a,this.g={}}S(ks,Vt);var su=[];function iu(a){te(a.g,function(u,d){this.g.hasOwnProperty(d)&&Wo(u)},a),a.g={}}ks.prototype.N=function(){ks.aa.N.call(this),iu(this)},ks.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var Ko=l.JSON.stringify,Dm=l.JSON.parse,Om=class{stringify(a){return l.JSON.stringify(a,void 0)}parse(a){return l.JSON.parse(a,void 0)}};function Qo(){}Qo.prototype.h=null;function ru(a){return a.h||(a.h=a.i())}function ou(){}var Ns={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function Yo(){ke.call(this,"d")}S(Yo,ke);function Xo(){ke.call(this,"c")}S(Xo,ke);var un={},au=null;function Yi(){return au=au||new Ne}un.La="serverreachability";function lu(a){ke.call(this,un.La,a)}S(lu,ke);function Ds(a){const u=Yi();Ue(u,new lu(u))}un.STAT_EVENT="statevent";function cu(a,u){ke.call(this,un.STAT_EVENT,a),this.stat=u}S(cu,ke);function Be(a){const u=Yi();Ue(u,new cu(u,a))}un.Ma="timingevent";function uu(a,u){ke.call(this,un.Ma,a),this.size=u}S(uu,ke);function Os(a,u){if(typeof a!="function")throw Error("Fn must not be null and must be a function");return l.setTimeout(function(){a()},u)}function xs(){this.g=!0}xs.prototype.xa=function(){this.g=!1};function xm(a,u,d,_,C,R){a.info(function(){if(a.g)if(R)for(var D="",ne=R.split("&"),we=0;we<ne.length;we++){var J=ne[we].split("=");if(1<J.length){var De=J[0];J=J[1];var Oe=De.split("_");D=2<=Oe.length&&Oe[1]=="type"?D+(De+"="+J+"&"):D+(De+"=redacted&")}}else D=null;else D=R;return"XMLHTTP REQ ("+_+") [attempt "+C+"]: "+u+`
3231`+d+`
3232`+D})}function Mm(a,u,d,_,C,R,D){a.info(function(){return"XMLHTTP RESP ("+_+") [ attempt "+C+"]: "+u+`
3233`+d+`
3234`+R+" "+D})}function Mn(a,u,d,_){a.info(function(){return"XMLHTTP TEXT ("+u+"): "+Vm(a,d)+(_?" "+_:"")})}function Lm(a,u){a.info(function(){return"TIMEOUT: "+u})}xs.prototype.info=function(){};function Vm(a,u){if(!a.g)return u;if(!u)return null;try{var d=JSON.parse(u);if(d){for(a=0;a<d.length;a++)if(Array.isArray(d[a])){var _=d[a];if(!(2>_.length)){var C=_[1];if(Array.isArray(C)&&!(1>C.length)){var R=C[0];if(R!="noop"&&R!="stop"&&R!="close")for(var D=1;D<C.length;D++)C[D]=""}}}}return Ko(d)}catch{return u}}var Xi={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},hu={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"},Jo;function Ji(){}S(Ji,Qo),Ji.prototype.g=function(){return new XMLHttpRequest},Ji.prototype.i=function(){return{}},Jo=new Ji;function Ft(a,u,d,_){this.j=a,this.i=u,this.l=d,this.R=_||1,this.U=new ks(this),this.I=45e3,this.H=null,this.o=!1,this.m=this.A=this.v=this.L=this.F=this.S=this.B=null,this.D=[],this.g=null,this.C=0,this.s=this.u=null,this.X=-1,this.J=!1,this.O=0,this.M=null,this.W=this.K=this.T=this.P=!1,this.h=new du}function du(){this.i=null,this.g="",this.h=!1}var fu={},Zo={};function ea(a,u,d){a.L=1,a.v=nr(vt(u)),a.m=d,a.P=!0,pu(a,null)}function pu(a,u){a.F=Date.now(),Zi(a),a.A=vt(a.v);var d=a.A,_=a.R;Array.isArray(_)||(_=[String(_)]),bu(d.i,"t",_),a.C=0,d=a.j.J,a.h=new du,a.g=zu(a.j,d?u:null,!a.m),0<a.O&&(a.M=new Nm(g(a.Y,a,a.g),a.O)),u=a.U,d=a.g,_=a.ca;var C="readystatechange";Array.isArray(C)||(C&&(su[0]=C.toString()),C=su);for(var R=0;R<C.length;R++){var D=Xc(d,C[R],_||u.handleEvent,!1,u.h||u);if(!D)break;u.g[D.key]=D}u=a.H?m(a.H):{},a.m?(a.u||(a.u="POST"),u["Content-Type"]="application/x-www-form-urlencoded",a.g.ea(a.A,a.u,a.m,u)):(a.u="GET",a.g.ea(a.A,a.u,null,u)),Ds(),xm(a.i,a.u,a.A,a.l,a.R,a.m)}Ft.prototype.ca=function(a){a=a.target;const u=this.M;u&&Et(a)==3?u.j():this.Y(a)},Ft.prototype.Y=function(a){try{if(a==this.g)e:{const Oe=Et(this.g);var u=this.g.Ba();const Fn=this.g.Z();if(!(3>Oe)&&(Oe!=3||this.g&&(this.h.h||this.g.oa()||Mu(this.g)))){this.J||Oe!=4||u==7||(u==8||0>=Fn?Ds(3):Ds(2)),ta(this);var d=this.g.Z();this.X=d;t:if(_u(this)){var _=Mu(this.g);a="";var C=_.length,R=Et(this.g)==4;if(!this.h.i){if(typeof TextDecoder>"u"){hn(this),Ms(this);var D="";break t}this.h.i=new l.TextDecoder}for(u=0;u<C;u++)this.h.h=!0,a+=this.h.i.decode(_[u],{stream:!(R&&u==C-1)});_.length=0,this.h.g+=a,this.C=0,D=this.h.g}else D=this.g.oa();if(this.o=d==200,Mm(this.i,this.u,this.A,this.l,this.R,Oe,d),this.o){if(this.T&&!this.K){t:{if(this.g){var ne,we=this.g;if((ne=we.g?we.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!H(ne)){var J=ne;break t}}J=null}if(d=J)Mn(this.i,this.l,d,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,na(this,d);else{this.o=!1,this.s=3,Be(12),hn(this),Ms(this);break e}}if(this.P){d=!0;let nt;for(;!this.J&&this.C<D.length;)if(nt=Fm(this,D),nt==Zo){Oe==4&&(this.s=4,Be(14),d=!1),Mn(this.i,this.l,null,"[Incomplete Response]");break}else if(nt==fu){this.s=4,Be(15),Mn(this.i,this.l,D,"[Invalid Chunk]"),d=!1;break}else Mn(this.i,this.l,nt,null),na(this,nt);if(_u(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),Oe!=4||D.length!=0||this.h.h||(this.s=1,Be(16),d=!1),this.o=this.o&&d,!d)Mn(this.i,this.l,D,"[Invalid Chunked Response]"),hn(this),Ms(this);else if(0<D.length&&!this.W){this.W=!0;var De=this.j;De.g==this&&De.ba&&!De.M&&(De.j.info("Great, no buffering proxy detected. Bytes received: "+D.length),la(De),De.M=!0,Be(11))}}else Mn(this.i,this.l,D,null),na(this,D);Oe==4&&hn(this),this.o&&!this.J&&(Oe==4?$u(this.j,this):(this.o=!1,Zi(this)))}else ty(this.g),d==400&&0<D.indexOf("Unknown SID")?(this.s=3,Be(12)):(this.s=0,Be(13)),hn(this),Ms(this)}}}catch{}finally{}};function _u(a){return a.g?a.u=="GET"&&a.L!=2&&a.j.Ca:!1}function Fm(a,u){var d=a.C,_=u.indexOf(`
3235`,d);return _==-1?Zo:(d=Number(u.substring(d,_)),isNaN(d)?fu:(_+=1,_+d>u.length?Zo:(u=u.slice(_,_+d),a.C=_+d,u)))}Ft.prototype.cancel=function(){this.J=!0,hn(this)};function Zi(a){a.S=Date.now()+a.I,gu(a,a.I)}function gu(a,u){if(a.B!=null)throw Error("WatchDog timer not null");a.B=Os(g(a.ba,a),u)}function ta(a){a.B&&(l.clearTimeout(a.B),a.B=null)}Ft.prototype.ba=function(){this.B=null;const a=Date.now();0<=a-this.S?(Lm(this.i,this.A),this.L!=2&&(Ds(),Be(17)),hn(this),this.s=2,Ms(this)):gu(this,this.S-a)};function Ms(a){a.j.G==0||a.J||$u(a.j,a)}function hn(a){ta(a);var u=a.M;u&&typeof u.ma=="function"&&u.ma(),a.M=null,iu(a.U),a.g&&(u=a.g,a.g=null,u.abort(),u.ma())}function na(a,u){try{var d=a.j;if(d.G!=0&&(d.g==a||sa(d.h,a))){if(!a.K&&sa(d.h,a)&&d.G==3){try{var _=d.Da.g.parse(u)}catch{_=null}if(Array.isArray(_)&&_.length==3){var C=_;if(C[0]==0){e:if(!d.u){if(d.g)if(d.g.F+3e3<a.F)lr(d),or(d);else break e;aa(d),Be(18)}}else d.za=C[1],0<d.za-d.T&&37500>C[2]&&d.F&&d.v==0&&!d.C&&(d.C=Os(g(d.Za,d),6e3));if(1>=vu(d.h)&&d.ca){try{d.ca()}catch{}d.ca=void 0}}else fn(d,11)}else if((a.K||d.g==a)&&lr(d),!H(u))for(C=d.Da.g.parse(u),u=0;u<C.length;u++){let J=C[u];if(d.T=J[0],J=J[1],d.G==2)if(J[0]=="c"){d.K=J[1],d.ia=J[2];const De=J[3];De!=null&&(d.la=De,d.j.info("VER="+d.la));const Oe=J[4];Oe!=null&&(d.Aa=Oe,d.j.info("SVER="+d.Aa));const Fn=J[5];Fn!=null&&typeof Fn=="number"&&0<Fn&&(_=1.5*Fn,d.L=_,d.j.info("backChannelRequestTimeoutMs_="+_)),_=d;const nt=a.g;if(nt){const ur=nt.g?nt.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(ur){var R=_.h;R.g||ur.indexOf("spdy")==-1&&ur.indexOf("quic")==-1&&ur.indexOf("h2")==-1||(R.j=R.l,R.g=new Set,R.h&&(ia(R,R.h),R.h=null))}if(_.D){const ca=nt.g?nt.g.getResponseHeader("X-HTTP-Session-Id"):null;ca&&(_.ya=ca,re(_.I,_.D,ca))}}d.G=3,d.l&&d.l.ua(),d.ba&&(d.R=Date.now()-a.F,d.j.info("Handshake RTT: "+d.R+"ms")),_=d;var D=a;if(_.qa=Wu(_,_.J?_.ia:null,_.W),D.K){Eu(_.h,D);var ne=D,we=_.L;we&&(ne.I=we),ne.B&&(ta(ne),Zi(ne)),_.g=D}else Bu(_);0<d.i.length&&ar(d)}else J[0]!="stop"&&J[0]!="close"||fn(d,7);else d.G==3&&(J[0]=="stop"||J[0]=="close"?J[0]=="stop"?fn(d,7):oa(d):J[0]!="noop"&&d.l&&d.l.ta(J),d.v=0)}}Ds(4)}catch{}}var Um=class{constructor(a,u){this.g=a,this.map=u}};function mu(a){this.l=a||10,l.PerformanceNavigationTiming?(a=l.performance.getEntriesByType("navigation"),a=0<a.length&&(a[0].nextHopProtocol=="hq"||a[0].nextHopProtocol=="h2")):a=!!(l.chrome&&l.chrome.loadTimes&&l.chrome.loadTimes()&&l.chrome.loadTimes().wasFetchedViaSpdy),this.j=a?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function yu(a){return a.h?!0:a.g?a.g.size>=a.j:!1}function vu(a){return a.h?1:a.g?a.g.size:0}function sa(a,u){return a.h?a.h==u:a.g?a.g.has(u):!1}function ia(a,u){a.g?a.g.add(u):a.h=u}function Eu(a,u){a.h&&a.h==u?a.h=null:a.g&&a.g.has(u)&&a.g.delete(u)}mu.prototype.cancel=function(){if(this.i=Tu(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const a of this.g.values())a.cancel();this.g.clear()}};function Tu(a){if(a.h!=null)return a.i.concat(a.h.D);if(a.g!=null&&a.g.size!==0){let u=a.i;for(const d of a.g.values())u=u.concat(d.D);return u}return k(a.i)}function Bm(a){if(a.V&&typeof a.V=="function")return a.V();if(typeof Map<"u"&&a instanceof Map||typeof Set<"u"&&a instanceof Set)return Array.from(a.values());if(typeof a=="string")return a.split("");if(c(a)){for(var u=[],d=a.length,_=0;_<d;_++)u.push(a[_]);return u}u=[],d=0;for(_ in a)u[d++]=a[_];return u}function qm(a){if(a.na&&typeof a.na=="function")return a.na();if(!a.V||typeof a.V!="function"){if(typeof Map<"u"&&a instanceof Map)return Array.from(a.keys());if(!(typeof Set<"u"&&a instanceof Set)){if(c(a)||typeof a=="string"){var u=[];a=a.length;for(var d=0;d<a;d++)u.push(d);return u}u=[],d=0;for(const _ in a)u[d++]=_;return u}}}function Iu(a,u){if(a.forEach&&typeof a.forEach=="function")a.forEach(u,void 0);else if(c(a)||typeof a=="string")Array.prototype.forEach.call(a,u,void 0);else for(var d=qm(a),_=Bm(a),C=_.length,R=0;R<C;R++)u.call(void 0,_[R],d&&d[R],a)}var wu=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function $m(a,u){if(a){a=a.split("&");for(var d=0;d<a.length;d++){var _=a[d].indexOf("="),C=null;if(0<=_){var R=a[d].substring(0,_);C=a[d].substring(_+1)}else R=a[d];u(R,C?decodeURIComponent(C.replace(/\+/g," ")):"")}}}function dn(a){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,a instanceof dn){this.h=a.h,er(this,a.j),this.o=a.o,this.g=a.g,tr(this,a.s),this.l=a.l;var u=a.i,d=new Fs;d.i=u.i,u.g&&(d.g=new Map(u.g),d.h=u.h),Cu(this,d),this.m=a.m}else a&&(u=String(a).match(wu))?(this.h=!1,er(this,u[1]||"",!0),this.o=Ls(u[2]||""),this.g=Ls(u[3]||"",!0),tr(this,u[4]),this.l=Ls(u[5]||"",!0),Cu(this,u[6]||"",!0),this.m=Ls(u[7]||"")):(this.h=!1,this.i=new Fs(null,this.h))}dn.prototype.toString=function(){var a=[],u=this.j;u&&a.push(Vs(u,Au,!0),":");var d=this.g;return(d||u=="file")&&(a.push("//"),(u=this.o)&&a.push(Vs(u,Au,!0),"@"),a.push(encodeURIComponent(String(d)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),d=this.s,d!=null&&a.push(":",String(d))),(d=this.l)&&(this.g&&d.charAt(0)!="/"&&a.push("/"),a.push(Vs(d,d.charAt(0)=="/"?Wm:Hm,!0))),(d=this.i.toString())&&a.push("?",d),(d=this.m)&&a.push("#",Vs(d,Gm)),a.join("")};function vt(a){return new dn(a)}function er(a,u,d){a.j=d?Ls(u,!0):u,a.j&&(a.j=a.j.replace(/:$/,""))}function tr(a,u){if(u){if(u=Number(u),isNaN(u)||0>u)throw Error("Bad port number "+u);a.s=u}else a.s=null}function Cu(a,u,d){u instanceof Fs?(a.i=u,Km(a.i,a.h)):(d||(u=Vs(u,zm)),a.i=new Fs(u,a.h))}function re(a,u,d){a.i.set(u,d)}function nr(a){return re(a,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),a}function Ls(a,u){return a?u?decodeURI(a.replace(/%25/g,"%2525")):decodeURIComponent(a):""}function Vs(a,u,d){return typeof a=="string"?(a=encodeURI(a).replace(u,jm),d&&(a=a.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),a):null}function jm(a){return a=a.charCodeAt(0),"%"+(a>>4&15).toString(16)+(a&15).toString(16)}var Au=/[#\/\?@]/g,Hm=/[#\?:]/g,Wm=/[#\?]/g,zm=/[#\?@]/g,Gm=/#/g;function Fs(a,u){this.h=this.g=null,this.i=a||null,this.j=!!u}function Ut(a){a.g||(a.g=new Map,a.h=0,a.i&&$m(a.i,function(u,d){a.add(decodeURIComponent(u.replace(/\+/g," ")),d)}))}n=Fs.prototype,n.add=function(a,u){Ut(this),this.i=null,a=Ln(this,a);var d=this.g.get(a);return d||this.g.set(a,d=[]),d.push(u),this.h+=1,this};function Ru(a,u){Ut(a),u=Ln(a,u),a.g.has(u)&&(a.i=null,a.h-=a.g.get(u).length,a.g.delete(u))}function Su(a,u){return Ut(a),u=Ln(a,u),a.g.has(u)}n.forEach=function(a,u){Ut(this),this.g.forEach(function(d,_){d.forEach(function(C){a.call(u,C,_,this)},this)},this)},n.na=function(){Ut(this);const a=Array.from(this.g.values()),u=Array.from(this.g.keys()),d=[];for(let _=0;_<u.length;_++){const C=a[_];for(let R=0;R<C.length;R++)d.push(u[_])}return d},n.V=function(a){Ut(this);let u=[];if(typeof a=="string")Su(this,a)&&(u=u.concat(this.g.get(Ln(this,a))));else{a=Array.from(this.g.values());for(let d=0;d<a.length;d++)u=u.concat(a[d])}return u},n.set=function(a,u){return Ut(this),this.i=null,a=Ln(this,a),Su(this,a)&&(this.h-=this.g.get(a).length),this.g.set(a,[u]),this.h+=1,this},n.get=function(a,u){return a?(a=this.V(a),0<a.length?String(a[0]):u):u};function bu(a,u,d){Ru(a,u),0<d.length&&(a.i=null,a.g.set(Ln(a,u),k(d)),a.h+=d.length)}n.toString=function(){if(this.i)return this.i;if(!this.g)return"";const a=[],u=Array.from(this.g.keys());for(var d=0;d<u.length;d++){var _=u[d];const R=encodeURIComponent(String(_)),D=this.V(_);for(_=0;_<D.length;_++){var C=R;D[_]!==""&&(C+="="+encodeURIComponent(String(D[_]))),a.push(C)}}return this.i=a.join("&")};function Ln(a,u){return u=String(u),a.j&&(u=u.toLowerCase()),u}function Km(a,u){u&&!a.j&&(Ut(a),a.i=null,a.g.forEach(function(d,_){var C=_.toLowerCase();_!=C&&(Ru(this,_),bu(this,C,d))},a)),a.j=u}function Qm(a,u){const d=new xs;if(l.Image){const _=new Image;_.onload=I(Bt,d,"TestLoadImage: loaded",!0,u,_),_.onerror=I(Bt,d,"TestLoadImage: error",!1,u,_),_.onabort=I(Bt,d,"TestLoadImage: abort",!1,u,_),_.ontimeout=I(Bt,d,"TestLoadImage: timeout",!1,u,_),l.setTimeout(function(){_.ontimeout&&_.ontimeout()},1e4),_.src=a}else u(!1)}function Ym(a,u){const d=new xs,_=new AbortController,C=setTimeout(()=>{_.abort(),Bt(d,"TestPingServer: timeout",!1,u)},1e4);fetch(a,{signal:_.signal}).then(R=>{clearTimeout(C),R.ok?Bt(d,"TestPingServer: ok",!0,u):Bt(d,"TestPingServer: server error",!1,u)}).catch(()=>{clearTimeout(C),Bt(d,"TestPingServer: error",!1,u)})}function Bt(a,u,d,_,C){try{C&&(C.onload=null,C.onerror=null,C.onabort=null,C.ontimeout=null),_(d)}catch{}}function Xm(){this.g=new Om}function Jm(a,u,d){const _=d||"";try{Iu(a,function(C,R){let D=C;h(C)&&(D=Ko(C)),u.push(_+R+"="+encodeURIComponent(D))})}catch(C){throw u.push(_+"type="+encodeURIComponent("_badmap")),C}}function sr(a){this.l=a.Ub||null,this.j=a.eb||!1}S(sr,Qo),sr.prototype.g=function(){return new ir(this.l,this.j)},sr.prototype.i=function(a){return function(){return a}}({});function ir(a,u){Ne.call(this),this.D=a,this.o=u,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}S(ir,Ne),n=ir.prototype,n.open=function(a,u){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.B=a,this.A=u,this.readyState=1,Bs(this)},n.send=function(a){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");this.g=!0;const u={headers:this.u,method:this.B,credentials:this.m,cache:void 0};a&&(u.body=a),(this.D||l).fetch(new Request(this.A,u)).then(this.Sa.bind(this),this.ga.bind(this))},n.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&this.readyState!=4&&(this.g=!1,Us(this)),this.readyState=0},n.Sa=function(a){if(this.g&&(this.l=a,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=a.headers,this.readyState=2,Bs(this)),this.g&&(this.readyState=3,Bs(this),this.g)))if(this.responseType==="arraybuffer")a.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(typeof l.ReadableStream<"u"&&"body"in a){if(this.j=a.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;Pu(this)}else a.text().then(this.Ra.bind(this),this.ga.bind(this))};function Pu(a){a.j.read().then(a.Pa.bind(a)).catch(a.ga.bind(a))}n.Pa=function(a){if(this.g){if(this.o&&a.value)this.response.push(a.value);else if(!this.o){var u=a.value?a.value:new Uint8Array(0);(u=this.v.decode(u,{stream:!a.done}))&&(this.response=this.responseText+=u)}a.done?Us(this):Bs(this),this.readyState==3&&Pu(this)}},n.Ra=function(a){this.g&&(this.response=this.responseText=a,Us(this))},n.Qa=function(a){this.g&&(this.response=a,Us(this))},n.ga=function(){this.g&&Us(this)};function Us(a){a.readyState=4,a.l=null,a.j=null,a.v=null,Bs(a)}n.setRequestHeader=function(a,u){this.u.append(a,u)},n.getResponseHeader=function(a){return this.h&&this.h.get(a.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";const a=[],u=this.h.entries();for(var d=u.next();!d.done;)d=d.value,a.push(d[0]+": "+d[1]),d=u.next();return a.join(`\r
3236`)};function Bs(a){a.onreadystatechange&&a.onreadystatechange.call(a)}Object.defineProperty(ir.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(a){this.m=a?"include":"same-origin"}});function ku(a){let u="";return te(a,function(d,_){u+=_,u+=":",u+=d,u+=`\r
3237`}),u}function ra(a,u,d){e:{for(_ in d){var _=!1;break e}_=!0}_||(d=ku(d),typeof a=="string"?d!=null&&encodeURIComponent(String(d)):re(a,u,d))}function ce(a){Ne.call(this),this.headers=new Map,this.o=a||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}S(ce,Ne);var Zm=/^https?$/i,ey=["POST","PUT"];n=ce.prototype,n.Ha=function(a){this.J=a},n.ea=function(a,u,d,_){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+a);u=u?u.toUpperCase():"GET",this.D=a,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():Jo.g(),this.v=this.o?ru(this.o):ru(Jo),this.g.onreadystatechange=g(this.Ea,this);try{this.B=!0,this.g.open(u,String(a),!0),this.B=!1}catch(R){Nu(this,R);return}if(a=d||"",d=new Map(this.headers),_)if(Object.getPrototypeOf(_)===Object.prototype)for(var C in _)d.set(C,_[C]);else if(typeof _.keys=="function"&&typeof _.get=="function")for(const R of _.keys())d.set(R,_.get(R));else throw Error("Unknown input type for opt_headers: "+String(_));_=Array.from(d.keys()).find(R=>R.toLowerCase()=="content-type"),C=l.FormData&&a instanceof l.FormData,!(0<=Array.prototype.indexOf.call(ey,u,void 0))||_||C||d.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[R,D]of d)this.g.setRequestHeader(R,D);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{xu(this),this.u=!0,this.g.send(a),this.u=!1}catch(R){Nu(this,R)}};function Nu(a,u){a.h=!1,a.g&&(a.j=!0,a.g.abort(),a.j=!1),a.l=u,a.m=5,Du(a),rr(a)}function Du(a){a.A||(a.A=!0,Ue(a,"complete"),Ue(a,"error"))}n.abort=function(a){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=a||7,Ue(this,"complete"),Ue(this,"abort"),rr(this))},n.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),rr(this,!0)),ce.aa.N.call(this)},n.Ea=function(){this.s||(this.B||this.u||this.j?Ou(this):this.bb())},n.bb=function(){Ou(this)};function Ou(a){if(a.h&&typeof o<"u"&&(!a.v[1]||Et(a)!=4||a.Z()!=2)){if(a.u&&Et(a)==4)tu(a.Ea,0,a);else if(Ue(a,"readystatechange"),Et(a)==4){a.h=!1;try{const D=a.Z();e:switch(D){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var u=!0;break e;default:u=!1}var d;if(!(d=u)){var _;if(_=D===0){var C=String(a.D).match(wu)[1]||null;!C&&l.self&&l.self.location&&(C=l.self.location.protocol.slice(0,-1)),_=!Zm.test(C?C.toLowerCase():"")}d=_}if(d)Ue(a,"complete"),Ue(a,"success");else{a.m=6;try{var R=2<Et(a)?a.g.statusText:""}catch{R=""}a.l=R+" ["+a.Z()+"]",Du(a)}}finally{rr(a)}}}}function rr(a,u){if(a.g){xu(a);const d=a.g,_=a.v[0]?()=>{}:null;a.g=null,a.v=null,u||Ue(a,"ready");try{d.onreadystatechange=_}catch{}}}function xu(a){a.I&&(l.clearTimeout(a.I),a.I=null)}n.isActive=function(){return!!this.g};function Et(a){return a.g?a.g.readyState:0}n.Z=function(){try{return 2<Et(this)?this.g.status:-1}catch{return-1}},n.oa=function(){try{return this.g?this.g.responseText:""}catch{return""}},n.Oa=function(a){if(this.g){var u=this.g.responseText;return a&&u.indexOf(a)==0&&(u=u.substring(a.length)),Dm(u)}};function Mu(a){try{if(!a.g)return null;if("response"in a.g)return a.g.response;switch(a.H){case"":case"text":return a.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in a.g)return a.g.mozResponseArrayBuffer}return null}catch{return null}}function ty(a){const u={};a=(a.g&&2<=Et(a)&&a.g.getAllResponseHeaders()||"").split(`\r
3238`);for(let _=0;_<a.length;_++){if(H(a[_]))continue;var d=w(a[_]);const C=d[0];if(d=d[1],typeof d!="string")continue;d=d.trim();const R=u[C]||[];u[C]=R,R.push(d)}T(u,function(_){return _.join(", ")})}n.Ba=function(){return this.m},n.Ka=function(){return typeof this.l=="string"?this.l:String(this.l)};function qs(a,u,d){return d&&d.internalChannelParams&&d.internalChannelParams[a]||u}function Lu(a){this.Aa=0,this.i=[],this.j=new xs,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=qs("failFast",!1,a),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=qs("baseRetryDelayMs",5e3,a),this.cb=qs("retryDelaySeedMs",1e4,a),this.Wa=qs("forwardChannelMaxRetries",2,a),this.wa=qs("forwardChannelRequestTimeoutMs",2e4,a),this.pa=a&&a.xmlHttpFactory||void 0,this.Xa=a&&a.Tb||void 0,this.Ca=a&&a.useFetchStreams||!1,this.L=void 0,this.J=a&&a.supportsCrossDomainXhr||!1,this.K="",this.h=new mu(a&&a.concurrentRequestLimit),this.Da=new Xm,this.P=a&&a.fastHandshake||!1,this.O=a&&a.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=a&&a.Rb||!1,a&&a.xa&&this.j.xa(),a&&a.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&a&&a.detectBufferingProxy||!1,this.ja=void 0,a&&a.longPollingTimeout&&0<a.longPollingTimeout&&(this.ja=a.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}n=Lu.prototype,n.la=8,n.G=1,n.connect=function(a,u,d,_){Be(0),this.W=a,this.H=u||{},d&&_!==void 0&&(this.H.OSID=d,this.H.OAID=_),this.F=this.X,this.I=Wu(this,null,this.W),ar(this)};function oa(a){if(Vu(a),a.G==3){var u=a.U++,d=vt(a.I);if(re(d,"SID",a.K),re(d,"RID",u),re(d,"TYPE","terminate"),$s(a,d),u=new Ft(a,a.j,u),u.L=2,u.v=nr(vt(d)),d=!1,l.navigator&&l.navigator.sendBeacon)try{d=l.navigator.sendBeacon(u.v.toString(),"")}catch{}!d&&l.Image&&(new Image().src=u.v,d=!0),d||(u.g=zu(u.j,null),u.g.ea(u.v)),u.F=Date.now(),Zi(u)}Hu(a)}function or(a){a.g&&(la(a),a.g.cancel(),a.g=null)}function Vu(a){or(a),a.u&&(l.clearTimeout(a.u),a.u=null),lr(a),a.h.cancel(),a.s&&(typeof a.s=="number"&&l.clearTimeout(a.s),a.s=null)}function ar(a){if(!yu(a.h)&&!a.s){a.s=!0;var u=a.Ga;Ss||Yc(),bs||(Ss(),bs=!0),Bo.add(u,a),a.B=0}}function ny(a,u){return vu(a.h)>=a.h.j-(a.s?1:0)?!1:a.s?(a.i=u.D.concat(a.i),!0):a.G==1||a.G==2||a.B>=(a.Va?0:a.Wa)?!1:(a.s=Os(g(a.Ga,a,u),ju(a,a.B)),a.B++,!0)}n.Ga=function(a){if(this.s)if(this.s=null,this.G==1){if(!a){this.U=Math.floor(1e5*Math.random()),a=this.U++;const C=new Ft(this,this.j,a);let R=this.o;if(this.S&&(R?(R=m(R),E(R,this.S)):R=this.S),this.m!==null||this.O||(C.H=R,R=null),this.P)e:{for(var u=0,d=0;d<this.i.length;d++){t:{var _=this.i[d];if("__data__"in _.map&&(_=_.map.__data__,typeof _=="string")){_=_.length;break t}_=void 0}if(_===void 0)break;if(u+=_,4096<u){u=d;break e}if(u===4096||d===this.i.length-1){u=d+1;break e}}u=1e3}else u=1e3;u=Uu(this,C,u),d=vt(this.I),re(d,"RID",a),re(d,"CVER",22),this.D&&re(d,"X-HTTP-Session-Id",this.D),$s(this,d),R&&(this.O?u="headers="+encodeURIComponent(String(ku(R)))+"&"+u:this.m&&ra(d,this.m,R)),ia(this.h,C),this.Ua&&re(d,"TYPE","init"),this.P?(re(d,"$req",u),re(d,"SID","null"),C.T=!0,ea(C,d,null)):ea(C,d,u),this.G=2}}else this.G==3&&(a?Fu(this,a):this.i.length==0||yu(this.h)||Fu(this))};function Fu(a,u){var d;u?d=u.l:d=a.U++;const _=vt(a.I);re(_,"SID",a.K),re(_,"RID",d),re(_,"AID",a.T),$s(a,_),a.m&&a.o&&ra(_,a.m,a.o),d=new Ft(a,a.j,d,a.B+1),a.m===null&&(d.H=a.o),u&&(a.i=u.D.concat(a.i)),u=Uu(a,d,1e3),d.I=Math.round(.5*a.wa)+Math.round(.5*a.wa*Math.random()),ia(a.h,d),ea(d,_,u)}function $s(a,u){a.H&&te(a.H,function(d,_){re(u,_,d)}),a.l&&Iu({},function(d,_){re(u,_,d)})}function Uu(a,u,d){d=Math.min(a.i.length,d);var _=a.l?g(a.l.Na,a.l,a):null;e:{var C=a.i;let R=-1;for(;;){const D=["count="+d];R==-1?0<d?(R=C[0].g,D.push("ofs="+R)):R=0:D.push("ofs="+R);let ne=!0;for(let we=0;we<d;we++){let J=C[we].g;const De=C[we].map;if(J-=R,0>J)R=Math.max(0,C[we].g-100),ne=!1;else try{Jm(De,D,"req"+J+"_")}catch{_&&_(De)}}if(ne){_=D.join("&");break e}}}return a=a.i.splice(0,d),u.D=a,_}function Bu(a){if(!a.g&&!a.u){a.Y=1;var u=a.Fa;Ss||Yc(),bs||(Ss(),bs=!0),Bo.add(u,a),a.v=0}}function aa(a){return a.g||a.u||3<=a.v?!1:(a.Y++,a.u=Os(g(a.Fa,a),ju(a,a.v)),a.v++,!0)}n.Fa=function(){if(this.u=null,qu(this),this.ba&&!(this.M||this.g==null||0>=this.R)){var a=2*this.R;this.j.info("BP detection timer enabled: "+a),this.A=Os(g(this.ab,this),a)}},n.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,Be(10),or(this),qu(this))};function la(a){a.A!=null&&(l.clearTimeout(a.A),a.A=null)}function qu(a){a.g=new Ft(a,a.j,"rpc",a.Y),a.m===null&&(a.g.H=a.o),a.g.O=0;var u=vt(a.qa);re(u,"RID","rpc"),re(u,"SID",a.K),re(u,"AID",a.T),re(u,"CI",a.F?"0":"1"),!a.F&&a.ja&&re(u,"TO",a.ja),re(u,"TYPE","xmlhttp"),$s(a,u),a.m&&a.o&&ra(u,a.m,a.o),a.L&&(a.g.I=a.L);var d=a.g;a=a.ia,d.L=1,d.v=nr(vt(u)),d.m=null,d.P=!0,pu(d,a)}n.Za=function(){this.C!=null&&(this.C=null,or(this),aa(this),Be(19))};function lr(a){a.C!=null&&(l.clearTimeout(a.C),a.C=null)}function $u(a,u){var d=null;if(a.g==u){lr(a),la(a),a.g=null;var _=2}else if(sa(a.h,u))d=u.D,Eu(a.h,u),_=1;else return;if(a.G!=0){if(u.o)if(_==1){d=u.m?u.m.length:0,u=Date.now()-u.F;var C=a.B;_=Yi(),Ue(_,new uu(_,d)),ar(a)}else Bu(a);else if(C=u.s,C==3||C==0&&0<u.X||!(_==1&&ny(a,u)||_==2&&aa(a)))switch(d&&0<d.length&&(u=a.h,u.i=u.i.concat(d)),C){case 1:fn(a,5);break;case 4:fn(a,10);break;case 3:fn(a,6);break;default:fn(a,2)}}}function ju(a,u){let d=a.Ta+Math.floor(Math.random()*a.cb);return a.isActive()||(d*=2),d*u}function fn(a,u){if(a.j.info("Error code "+u),u==2){var d=g(a.fb,a),_=a.Xa;const C=!_;_=new dn(_||"//www.google.com/images/cleardot.gif"),l.location&&l.location.protocol=="http"||er(_,"https"),nr(_),C?Qm(_.toString(),d):Ym(_.toString(),d)}else Be(2);a.G=0,a.l&&a.l.sa(u),Hu(a),Vu(a)}n.fb=function(a){a?(this.j.info("Successfully pinged google.com"),Be(2)):(this.j.info("Failed to ping google.com"),Be(1))};function Hu(a){if(a.G=0,a.ka=[],a.l){const u=Tu(a.h);(u.length!=0||a.i.length!=0)&&(b(a.ka,u),b(a.ka,a.i),a.h.i.length=0,k(a.i),a.i.length=0),a.l.ra()}}function Wu(a,u,d){var _=d instanceof dn?vt(d):new dn(d);if(_.g!="")u&&(_.g=u+"."+_.g),tr(_,_.s);else{var C=l.location;_=C.protocol,u=u?u+"."+C.hostname:C.hostname,C=+C.port;var R=new dn(null);_&&er(R,_),u&&(R.g=u),C&&tr(R,C),d&&(R.l=d),_=R}return d=a.D,u=a.ya,d&&u&&re(_,d,u),re(_,"VER",a.la),$s(a,_),_}function zu(a,u,d){if(u&&!a.J)throw Error("Can't create secondary domain capable XhrIo object.");return u=a.Ca&&!a.pa?new ce(new sr({eb:d})):new ce(a.pa),u.Ha(a.J),u}n.isActive=function(){return!!this.l&&this.l.isActive(this)};function Gu(){}n=Gu.prototype,n.ua=function(){},n.ta=function(){},n.sa=function(){},n.ra=function(){},n.isActive=function(){return!0},n.Na=function(){};function cr(){}cr.prototype.g=function(a,u){return new Qe(a,u)};function Qe(a,u){Ne.call(this),this.g=new Lu(u),this.l=a,this.h=u&&u.messageUrlParams||null,a=u&&u.messageHeaders||null,u&&u.clientProtocolHeaderRequired&&(a?a["X-Client-Protocol"]="webchannel":a={"X-Client-Protocol":"webchannel"}),this.g.o=a,a=u&&u.initMessageHeaders||null,u&&u.messageContentType&&(a?a["X-WebChannel-Content-Type"]=u.messageContentType:a={"X-WebChannel-Content-Type":u.messageContentType}),u&&u.va&&(a?a["X-WebChannel-Client-Profile"]=u.va:a={"X-WebChannel-Client-Profile":u.va}),this.g.S=a,(a=u&&u.Sb)&&!H(a)&&(this.g.m=a),this.v=u&&u.supportsCrossDomainXhr||!1,this.u=u&&u.sendRawJson||!1,(u=u&&u.httpSessionIdParam)&&!H(u)&&(this.g.D=u,a=this.h,a!==null&&u in a&&(a=this.h,u in a&&delete a[u])),this.j=new Vn(this)}S(Qe,Ne),Qe.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},Qe.prototype.close=function(){oa(this.g)},Qe.prototype.o=function(a){var u=this.g;if(typeof a=="string"){var d={};d.__data__=a,a=d}else this.u&&(d={},d.__data__=Ko(a),a=d);u.i.push(new Um(u.Ya++,a)),u.G==3&&ar(u)},Qe.prototype.N=function(){this.g.l=null,delete this.j,oa(this.g),delete this.g,Qe.aa.N.call(this)};function Ku(a){Yo.call(this),a.__headers__&&(this.headers=a.__headers__,this.statusCode=a.__status__,delete a.__headers__,delete a.__status__);var u=a.__sm__;if(u){e:{for(const d in u){a=d;break e}a=void 0}(this.i=a)&&(a=this.i,u=u!==null&&a in u?u[a]:void 0),this.data=u}else this.data=a}S(Ku,Yo);function Qu(){Xo.call(this),this.status=1}S(Qu,Xo);function Vn(a){this.g=a}S(Vn,Gu),Vn.prototype.ua=function(){Ue(this.g,"a")},Vn.prototype.ta=function(a){Ue(this.g,new Ku(a))},Vn.prototype.sa=function(a){Ue(this.g,new Qu)},Vn.prototype.ra=function(){Ue(this.g,"b")},cr.prototype.createWebChannel=cr.prototype.g,Qe.prototype.send=Qe.prototype.o,Qe.prototype.open=Qe.prototype.m,Qe.prototype.close=Qe.prototype.close,cg=function(){return new cr},lg=function(){return Yi()},ag=un,sl={mb:0,pb:1,qb:2,Jb:3,Ob:4,Lb:5,Mb:6,Kb:7,Ib:8,Nb:9,PROXY:10,NOPROXY:11,Gb:12,Cb:13,Db:14,Bb:15,Eb:16,Fb:17,ib:18,hb:19,jb:20},Xi.NO_ERROR=0,Xi.TIMEOUT=8,Xi.HTTP_ERROR=6,Sr=Xi,hu.COMPLETE="complete",og=hu,ou.EventType=Ns,Ns.OPEN="a",Ns.CLOSE="b",Ns.ERROR="c",Ns.MESSAGE="d",Ne.prototype.listen=Ne.prototype.K,Ys=ou,ce.prototype.listenOnce=ce.prototype.L,ce.prototype.getLastError=ce.prototype.Ka,ce.prototype.getLastErrorCode=ce.prototype.Ba,ce.prototype.getStatus=ce.prototype.Z,ce.prototype.getResponseJson=ce.prototype.Oa,ce.prototype.getResponseText=ce.prototype.oa,ce.prototype.send=ce.prototype.ea,ce.prototype.setWithCredentials=ce.prototype.Ha,rg=ce}).apply(typeof _r<"u"?_r:typeof self<"u"?self:typeof window<"u"?window:{});const pd="@firebase/firestore";/**
3239 * @license
3240 * Copyright 2017 Google LLC
3241 *
3242 * Licensed under the Apache License, Version 2.0 (the "License");
3243 * you may not use this file except in compliance with the License.
3244 * You may obtain a copy of the License at
3245 *
3246 *   http://www.apache.org/licenses/LICENSE-2.0
3247 *
3248 * Unless required by applicable law or agreed to in writing, software
3249 * distributed under the License is distributed on an "AS IS" BASIS,
3250 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3251 * See the License for the specific language governing permissions and
3252 * limitations under the License.
3253 */class Me{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}Me.UNAUTHENTICATED=new Me(null),Me.GOOGLE_CREDENTIALS=new Me("google-credentials-uid"),Me.FIRST_PARTY=new Me("first-party-uid"),Me.MOCK_USER=new Me("mock-user");/**
3254 * @license
3255 * Copyright 2017 Google LLC
3256 *
3257 * Licensed under the Apache License, Version 2.0 (the "License");
3258 * you may not use this file except in compliance with the License.
3259 * You may obtain a copy of the License at
3260 *
3261 *   http://www.apache.org/licenses/LICENSE-2.0
3262 *
3263 * Unless required by applicable law or agreed to in writing, software
3264 * distributed under the License is distributed on an "AS IS" BASIS,
3265 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3266 * See the License for the specific language governing permissions and
3267 * limitations under the License.
3268 */let Is="10.14.0";/**
3269 * @license
3270 * Copyright 2017 Google LLC
3271 *
3272 * Licensed under the Apache License, Version 2.0 (the "License");
3273 * you may not use this file except in compliance with the License.
3274 * You may obtain a copy of the License at
3275 *
3276 *   http://www.apache.org/licenses/LICENSE-2.0
3277 *
3278 * Unless required by applicable law or agreed to in writing, software
3279 * distributed under the License is distributed on an "AS IS" BASIS,
3280 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3281 * See the License for the specific language governing permissions and
3282 * limitations under the License.
3283 */const bn=new ys("@firebase/firestore");function Gs(){return bn.logLevel}function x(n,...e){if(bn.logLevel<=K.DEBUG){const t=e.map(mc);bn.debug(`Firestore (${Is}): ${n}`,...t)}}function Mt(n,...e){if(bn.logLevel<=K.ERROR){const t=e.map(mc);bn.error(`Firestore (${Is}): ${n}`,...t)}}function us(n,...e){if(bn.logLevel<=K.WARN){const t=e.map(mc);bn.warn(`Firestore (${Is}): ${n}`,...t)}}function mc(n){if(typeof n=="string")return n;try{/**
3284* @license
3285* Copyright 2020 Google LLC
3286*
3287* Licensed under the Apache License, Version 2.0 (the "License");
3288* you may not use this file except in compliance with the License.
3289* You may obtain a copy of the License at
3290*
3291*   http://www.apache.org/licenses/LICENSE-2.0
3292*
3293* Unless required by applicable law or agreed to in writing, software
3294* distributed under the License is distributed on an "AS IS" BASIS,
3295* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3296* See the License for the specific language governing permissions and
3297* limitations under the License.
3298*/return function(t){return JSON.stringify(t)}(n)}catch{return n}}/**
3299 * @license
3300 * Copyright 2017 Google LLC
3301 *
3302 * Licensed under the Apache License, Version 2.0 (the "License");
3303 * you may not use this file except in compliance with the License.
3304 * You may obtain a copy of the License at
3305 *
3306 *   http://www.apache.org/licenses/LICENSE-2.0
3307 *
3308 * Unless required by applicable law or agreed to in writing, software
3309 * distributed under the License is distributed on an "AS IS" BASIS,
3310 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3311 * See the License for the specific language governing permissions and
3312 * limitations under the License.
3313 */function j(n="Unexpected state"){const e=`FIRESTORE (${Is}) INTERNAL ASSERTION FAILED: `+n;throw Mt(e),new Error(e)}function he(n,e){n||j()}function Y(n,e){return n}/**
3314 * @license
3315 * Copyright 2017 Google LLC
3316 *
3317 * Licensed under the Apache License, Version 2.0 (the "License");
3318 * you may not use this file except in compliance with the License.
3319 * You may obtain a copy of the License at
3320 *
3321 *   http://www.apache.org/licenses/LICENSE-2.0
3322 *
3323 * Unless required by applicable law or agreed to in writing, software
3324 * distributed under the License is distributed on an "AS IS" BASIS,
3325 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3326 * See the License for the specific language governing permissions and
3327 * limitations under the License.
3328 */const O={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class M extends tt{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/**
3329 * @license
3330 * Copyright 2017 Google LLC
3331 *
3332 * Licensed under the Apache License, Version 2.0 (the "License");
3333 * you may not use this file except in compliance with the License.
3334 * You may obtain a copy of the License at
3335 *
3336 *   http://www.apache.org/licenses/LICENSE-2.0
3337 *
3338 * Unless required by applicable law or agreed to in writing, software
3339 * distributed under the License is distributed on an "AS IS" BASIS,
3340 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3341 * See the License for the specific language governing permissions and
3342 * limitations under the License.
3343 */class Xt{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}/**
3344 * @license
3345 * Copyright 2017 Google LLC
3346 *
3347 * Licensed under the Apache License, Version 2.0 (the "License");
3348 * you may not use this file except in compliance with the License.
3349 * You may obtain a copy of the License at
3350 *
3351 *   http://www.apache.org/licenses/LICENSE-2.0
3352 *
3353 * Unless required by applicable law or agreed to in writing, software
3354 * distributed under the License is distributed on an "AS IS" BASIS,
3355 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3356 * See the License for the specific language governing permissions and
3357 * limitations under the License.
3358 */class ug{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class vR{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(Me.UNAUTHENTICATED))}shutdown(){}}class ER{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable(()=>t(this.token.user))}shutdown(){this.changeListener=null}}class TR{constructor(e){this.t=e,this.currentUser=Me.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){he(this.o===void 0);let s=this.i;const i=c=>this.i!==s?(s=this.i,t(c)):Promise.resolve();let r=new Xt;this.o=()=>{this.i++,this.currentUser=this.u(),r.resolve(),r=new Xt,e.enqueueRetryable(()=>i(this.currentUser))};const o=()=>{const c=r;e.enqueueRetryable(async()=>{await c.promise,await i(this.currentUser)})},l=c=>{x("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=c,this.o&&(this.auth.addAuthTokenListener(this.o),o())};this.t.onInit(c=>l(c)),setTimeout(()=>{if(!this.auth){const c=this.t.getImmediate({optional:!0});c?l(c):(x("FirebaseAuthCredentialsProvider","Auth not yet detected"),r.resolve(),r=new Xt)}},0),o()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(s=>this.i!==e?(x("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):s?(he(typeof s.accessToken=="string"),new ug(s.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){const e=this.auth&&this.auth.getUid();return he(e===null||typeof e=="string"),new Me(e)}}class IR{constructor(e,t,s){this.l=e,this.h=t,this.P=s,this.type="FirstParty",this.user=Me.FIRST_PARTY,this.I=new Map}T(){return this.P?this.P():null}get headers(){this.I.set("X-Goog-AuthUser",this.l);const e=this.T();return e&&this.I.set("Authorization",e),this.h&&this.I.set("X-Goog-Iam-Authorization-Token",this.h),this.I}}class wR{constructor(e,t,s){this.l=e,this.h=t,this.P=s}getToken(){return Promise.resolve(new IR(this.l,this.h,this.P))}start(e,t){e.enqueueRetryable(()=>t(Me.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class CR{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class AR{constructor(e){this.A=e,this.forceRefresh=!1,this.appCheck=null,this.R=null}start(e,t){he(this.o===void 0);const s=r=>{r.error!=null&&x("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${r.error.message}`);const o=r.token!==this.R;return this.R=r.token,x("FirebaseAppCheckTokenProvider",`Received ${o?"new":"existing"} token.`),o?t(r.token):Promise.resolve()};this.o=r=>{e.enqueueRetryable(()=>s(r))};const i=r=>{x("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=r,this.o&&this.appCheck.addTokenListener(this.o)};this.A.onInit(r=>i(r)),setTimeout(()=>{if(!this.appCheck){const r=this.A.getImmediate({optional:!0});r?i(r):x("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(t=>t?(he(typeof t.token=="string"),this.R=t.token,new CR(t.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}/**
3359 * @license
3360 * Copyright 2020 Google LLC
3361 *
3362 * Licensed under the Apache License, Version 2.0 (the "License");
3363 * you may not use this file except in compliance with the License.
3364 * You may obtain a copy of the License at
3365 *
3366 *   http://www.apache.org/licenses/LICENSE-2.0
3367 *
3368 * Unless required by applicable law or agreed to in writing, software
3369 * distributed under the License is distributed on an "AS IS" BASIS,
3370 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3371 * See the License for the specific language governing permissions and
3372 * limitations under the License.
3373 */function RR(n){const e=typeof self<"u"&&(self.crypto||self.msCrypto),t=new Uint8Array(n);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let s=0;s<n;s++)t[s]=Math.floor(256*Math.random());return t}/**
3374 * @license
3375 * Copyright 2017 Google LLC
3376 *
3377 * Licensed under the Apache License, Version 2.0 (the "License");
3378 * you may not use this file except in compliance with the License.
3379 * You may obtain a copy of the License at
3380 *
3381 *   http://www.apache.org/licenses/LICENSE-2.0
3382 *
3383 * Unless required by applicable law or agreed to in writing, software
3384 * distributed under the License is distributed on an "AS IS" BASIS,
3385 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3386 * See the License for the specific language governing permissions and
3387 * limitations under the License.
3388 */class SR{static newId(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=Math.floor(256/e.length)*e.length;let s="";for(;s.length<20;){const i=RR(40);for(let r=0;r<i.length;++r)s.length<20&&i[r]<t&&(s+=e.charAt(i[r]%e.length))}return s}}function ee(n,e){return n<e?-1:n>e?1:0}function hs(n,e,t){return n.length===e.length&&n.every((s,i)=>t(s,e[i]))}/**
3389 * @license
3390 * Copyright 2017 Google LLC
3391 *
3392 * Licensed under the Apache License, Version 2.0 (the "License");
3393 * you may not use this file except in compliance with the License.
3394 * You may obtain a copy of the License at
3395 *
3396 *   http://www.apache.org/licenses/LICENSE-2.0
3397 *
3398 * Unless required by applicable law or agreed to in writing, software
3399 * distributed under the License is distributed on an "AS IS" BASIS,
3400 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3401 * See the License for the specific language governing permissions and
3402 * limitations under the License.
3403 */class ze{constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new M(O.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new M(O.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<-62135596800)throw new M(O.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new M(O.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}static now(){return ze.fromMillis(Date.now())}static fromDate(e){return ze.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),s=Math.floor(1e6*(e-1e3*t));return new ze(t,s)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?ee(this.nanoseconds,e.nanoseconds):ee(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){const e=this.seconds- -62135596800;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}/**
3404 * @license
3405 * Copyright 2017 Google LLC
3406 *
3407 * Licensed under the Apache License, Version 2.0 (the "License");
3408 * you may not use this file except in compliance with the License.
3409 * You may obtain a copy of the License at
3410 *
3411 *   http://www.apache.org/licenses/LICENSE-2.0
3412 *
3413 * Unless required by applicable law or agreed to in writing, software
3414 * distributed under the License is distributed on an "AS IS" BASIS,
3415 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3416 * See the License for the specific language governing permissions and
3417 * limitations under the License.
3418 */class q{constructor(e){this.timestamp=e}static fromTimestamp(e){return new q(e)}static min(){return new q(new ze(0,0))}static max(){return new q(new ze(253402300799,999999999))}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}/**
3419 * @license
3420 * Copyright 2017 Google LLC
3421 *
3422 * Licensed under the Apache License, Version 2.0 (the "License");
3423 * you may not use this file except in compliance with the License.
3424 * You may obtain a copy of the License at
3425 *
3426 *   http://www.apache.org/licenses/LICENSE-2.0
3427 *
3428 * Unless required by applicable law or agreed to in writing, software
3429 * distributed under the License is distributed on an "AS IS" BASIS,
3430 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3431 * See the License for the specific language governing permissions and
3432 * limitations under the License.
3433 */class Ci{constructor(e,t,s){t===void 0?t=0:t>e.length&&j(),s===void 0?s=e.length-t:s>e.length-t&&j(),this.segments=e,this.offset=t,this.len=s}get length(){return this.len}isEqual(e){return Ci.comparator(this,e)===0}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof Ci?e.forEach(s=>{t.push(s)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,s=this.limit();t<s;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const s=Math.min(e.length,t.length);for(let i=0;i<s;i++){const r=e.get(i),o=t.get(i);if(r<o)return-1;if(r>o)return 1}return e.length<t.length?-1:e.length>t.length?1:0}}class ge extends Ci{construct(e,t,s){return new ge(e,t,s)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const s of e){if(s.indexOf("//")>=0)throw new M(O.INVALID_ARGUMENT,`Invalid segment (${s}). Paths must not contain // in them.`);t.push(...s.split("/").filter(i=>i.length>0))}return new ge(t)}static emptyPath(){return new ge([])}}const bR=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class $e extends Ci{construct(e,t,s){return new $e(e,t,s)}static isValidIdentifier(e){return bR.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),$e.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)==="__name__"}static keyField(){return new $e(["__name__"])}static fromServerFormat(e){const t=[];let s="",i=0;const r=()=>{if(s.length===0)throw new M(O.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(s),s=""};let o=!1;for(;i<e.length;){const l=e[i];if(l==="\\"){if(i+1===e.length)throw new M(O.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const c=e[i+1];if(c!=="\\"&&c!=="."&&c!=="`")throw new M(O.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);s+=c,i+=2}else l==="`"?(o=!o,i++):l!=="."||o?(s+=l,i++):(r(),i++)}if(r(),o)throw new M(O.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new $e(t)}static emptyPath(){return new $e([])}}/**
3434 * @license
3435 * Copyright 2017 Google LLC
3436 *
3437 * Licensed under the Apache License, Version 2.0 (the "License");
3438 * you may not use this file except in compliance with the License.
3439 * You may obtain a copy of the License at
3440 *
3441 *   http://www.apache.org/licenses/LICENSE-2.0
3442 *
3443 * Unless required by applicable law or agreed to in writing, software
3444 * distributed under the License is distributed on an "AS IS" BASIS,
3445 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3446 * See the License for the specific language governing permissions and
3447 * limitations under the License.
3448 */class F{constructor(e){this.path=e}static fromPath(e){return new F(ge.fromString(e))}static fromName(e){return new F(ge.fromString(e).popFirst(5))}static empty(){return new F(ge.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&ge.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return ge.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new F(new ge(e.slice()))}}function PR(n,e){const t=n.toTimestamp().seconds,s=n.toTimestamp().nanoseconds+1,i=q.fromTimestamp(s===1e9?new ze(t+1,0):new ze(t,s));return new sn(i,F.empty(),e)}function kR(n){return new sn(n.readTime,n.key,-1)}class sn{constructor(e,t,s){this.readTime=e,this.documentKey=t,this.largestBatchId=s}static min(){return new sn(q.min(),F.empty(),-1)}static max(){return new sn(q.max(),F.empty(),-1)}}function NR(n,e){let t=n.readTime.compareTo(e.readTime);
3448return t!==0?t:(t=F.comparator(n.documentKey,e.documentKey),t!==0?t:ee(n.largestBatchId,e.largestBatchId))}/**
3449 * @license
3450 * Copyright 2020 Google LLC
3451 *
3452 * Licensed under the Apache License, Version 2.0 (the "License");
3453 * you may not use this file except in compliance with the License.
3454 * You may obtain a copy of the License at
3455 *
3456 *   http://www.apache.org/licenses/LICENSE-2.0
3457 *
3458 * Unless required by applicable law or agreed to in writing, software
3459 * distributed under the License is distributed on an "AS IS" BASIS,
3460 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3461 * See the License for the specific language governing permissions and
3462 * limitations under the License.
3463 */const DR="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class OR{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}/**
3464 * @license
3465 * Copyright 2017 Google LLC
3466 *
3467 * Licensed under the Apache License, Version 2.0 (the "License");
3468 * you may not use this file except in compliance with the License.
3469 * You may obtain a copy of the License at
3470 *
3471 *   http://www.apache.org/licenses/LICENSE-2.0
3472 *
3473 * Unless required by applicable law or agreed to in writing, software
3474 * distributed under the License is distributed on an "AS IS" BASIS,
3475 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3476 * See the License for the specific language governing permissions and
3477 * limitations under the License.
3478 */async function yc(n){if(n.code!==O.FAILED_PRECONDITION||n.message!==DR)throw n;x("LocalStore","Unexpectedly lost primary lease")}/**
3479 * @license
3480 * Copyright 2017 Google LLC
3481 *
3482 * Licensed under the Apache License, Version 2.0 (the "License");
3483 * you may not use this file except in compliance with the License.
3484 * You may obtain a copy of the License at
3485 *
3486 *   http://www.apache.org/licenses/LICENSE-2.0
3487 *
3488 * Unless required by applicable law or agreed to in writing, software
3489 * distributed under the License is distributed on an "AS IS" BASIS,
3490 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3491 * See the License for the specific language governing permissions and
3492 * limitations under the License.
3493 */class P{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)},t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)})}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&j(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new P((s,i)=>{this.nextCallback=r=>{this.wrapSuccess(e,r).next(s,i)},this.catchCallback=r=>{this.wrapFailure(t,r).next(s,i)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{const t=e();return t instanceof P?t:P.resolve(t)}catch(t){return P.reject(t)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):P.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):P.reject(t)}static resolve(e){return new P((t,s)=>{t(e)})}static reject(e){return new P((t,s)=>{s(e)})}static waitFor(e){return new P((t,s)=>{let i=0,r=0,o=!1;e.forEach(l=>{++i,l.next(()=>{++r,o&&r===i&&t()},c=>s(c))}),o=!0,r===i&&t()})}static or(e){let t=P.resolve(!1);for(const s of e)t=t.next(i=>i?P.resolve(i):s());return t}static forEach(e,t){const s=[];return e.forEach((i,r)=>{s.push(t.call(this,i,r))}),this.waitFor(s)}static mapArray(e,t){return new P((s,i)=>{const r=e.length,o=new Array(r);let l=0;for(let c=0;c<r;c++){const h=c;t(e[h]).next(f=>{o[h]=f,++l,l===r&&s(o)},f=>i(f))}})}static doWhile(e,t){return new P((s,i)=>{const r=()=>{e()===!0?t().next(()=>{r()},i):s()};r()})}}function xR(n){const e=n.match(/Android ([\d.]+)/i),t=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(t)}function Bi(n){return n.name==="IndexedDbTransactionError"}/**
3494 * @license
3495 * Copyright 2018 Google LLC
3496 *
3497 * Licensed under the Apache License, Version 2.0 (the "License");
3498 * you may not use this file except in compliance with the License.
3499 * You may obtain a copy of the License at
3500 *
3501 *   http://www.apache.org/licenses/LICENSE-2.0
3502 *
3503 * Unless required by applicable law or agreed to in writing, software
3504 * distributed under the License is distributed on an "AS IS" BASIS,
3505 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3506 * See the License for the specific language governing permissions and
3507 * limitations under the License.
3508 */class vc{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=s=>this.ie(s),this.se=s=>t.writeSequenceNumber(s))}ie(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.se&&this.se(e),e}}vc.oe=-1;function So(n){return n==null}function il(n){return n===0&&1/n==-1/0}/**
3509 * @license
3510 * Copyright 2017 Google LLC
3511 *
3512 * Licensed under the Apache License, Version 2.0 (the "License");
3513 * you may not use this file except in compliance with the License.
3514 * You may obtain a copy of the License at
3515 *
3516 *   http://www.apache.org/licenses/LICENSE-2.0
3517 *
3518 * Unless required by applicable law or agreed to in writing, software
3519 * distributed under the License is distributed on an "AS IS" BASIS,
3520 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3521 * See the License for the specific language governing permissions and
3522 * limitations under the License.
3523 */function _d(n){let e=0;for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e++;return e}function bo(n,e){for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e(t,n[t])}function MR(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}/**
3524 * @license
3525 * Copyright 2017 Google LLC
3526 *
3527 * Licensed under the Apache License, Version 2.0 (the "License");
3528 * you may not use this file except in compliance with the License.
3529 * You may obtain a copy of the License at
3530 *
3531 *   http://www.apache.org/licenses/LICENSE-2.0
3532 *
3533 * Unless required by applicable law or agreed to in writing, software
3534 * distributed under the License is distributed on an "AS IS" BASIS,
3535 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3536 * See the License for the specific language governing permissions and
3537 * limitations under the License.
3538 */class pe{constructor(e,t){this.comparator=e,this.root=t||Ce.EMPTY}insert(e,t){return new pe(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,Ce.BLACK,null,null))}remove(e){return new pe(this.comparator,this.root.remove(e,this.comparator).copy(null,null,Ce.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){const s=this.comparator(e,t.key);if(s===0)return t.value;s<0?t=t.left:s>0&&(t=t.right)}return null}indexOf(e){let t=0,s=this.root;for(;!s.isEmpty();){const i=this.comparator(e,s.key);if(i===0)return t+s.left.size;i<0?s=s.left:(t+=s.left.size+1,s=s.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((t,s)=>(e(t,s),!1))}toString(){const e=[];return this.inorderTraversal((t,s)=>(e.push(`${t}:${s}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new gr(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new gr(this.root,e,this.comparator,!1)}getReverseIterator(){return new gr(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new gr(this.root,e,this.comparator,!0)}}class gr{constructor(e,t,s,i){this.isReverse=i,this.nodeStack=[];let r=1;for(;!e.isEmpty();)if(r=t?s(e.key,t):1,t&&i&&(r*=-1),r<0)e=this.isReverse?e.left:e.right;else{if(r===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const t={key:e.key,value:e.value};if(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{key:e.key,value:e.value}}}class Ce{constructor(e,t,s,i,r){this.key=e,this.value=t,this.color=s??Ce.RED,this.left=i??Ce.EMPTY,this.right=r??Ce.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,s,i,r){return new Ce(e??this.key,t??this.value,s??this.color,i??this.left,r??this.right)}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,s){let i=this;const r=s(e,i.key);return i=r<0?i.copy(null,null,null,i.left.insert(e,t,s),null):r===0?i.copy(null,t,null,null,null):i.copy(null,null,null,null,i.right.insert(e,t,s)),i.fixUp()}removeMin(){if(this.left.isEmpty())return Ce.EMPTY;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 s,i=this;if(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 Ce.EMPTY;s=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,Ce.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,Ce.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.size+1}check(){if(this.isRed()&&this.left.isRed()||this.right.isRed())throw j();const e=this.left.check();if(e!==this.right.check())throw j();return e+(this.isRed()?0:1)}}Ce.EMPTY=null,Ce.RED=!0,Ce.BLACK=!1;
3538Ce.EMPTY=new class{constructor(){this.size=0}get key(){throw j()}get value(){throw j()}get color(){throw j()}get left(){throw j()}get right(){throw j()}copy(e,t,s,i,r){return this}insert(e,t,s){return new Ce(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};/**
3539 * @license
3540 * Copyright 2017 Google LLC
3541 *
3542 * Licensed under the Apache License, Version 2.0 (the "License");
3543 * you may not use this file except in compliance with the License.
3544 * You may obtain a copy of the License at
3545 *
3546 *   http://www.apache.org/licenses/LICENSE-2.0
3547 *
3548 * Unless required by applicable law or agreed to in writing, software
3549 * distributed under the License is distributed on an "AS IS" BASIS,
3550 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3551 * See the License for the specific language governing permissions and
3552 * limitations under the License.
3553 */class be{constructor(e){this.comparator=e,this.data=new pe(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((t,s)=>(e(t),!1))}forEachInRange(e,t){const s=this.data.getIteratorFrom(e[0]);for(;s.hasNext();){const i=s.getNext();if(this.comparator(i.key,e[1])>=0)return;t(i.key)}}forEachWhile(e,t){let s;for(s=t!==void 0?this.data.getIteratorFrom(t):this.data.getIterator();s.hasNext();)if(!e(s.getNext().key))return}firstAfterOrEqual(e){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new gd(this.data.getIterator())}getIteratorFrom(e){return new gd(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach(s=>{t=t.add(s)}),t}isEqual(e){if(!(e instanceof be)||this.size!==e.size)return!1;const t=this.data.getIterator(),s=e.data.getIterator();for(;t.hasNext();){const i=t.getNext().key,r=s.getNext().key;if(this.comparator(i,r)!==0)return!1}return!0}toArray(){const e=[];return this.forEach(t=>{e.push(t)}),e}toString(){const e=[];return this.forEach(t=>e.push(t)),"SortedSet("+e.toString()+")"}copy(e){const t=new be(this.comparator);return t.data=e,t}}class gd{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}/**
3554 * @license
3555 * Copyright 2020 Google LLC
3556 *
3557 * Licensed under the Apache License, Version 2.0 (the "License");
3558 * you may not use this file except in compliance with the License.
3559 * You may obtain a copy of the License at
3560 *
3561 *   http://www.apache.org/licenses/LICENSE-2.0
3562 *
3563 * Unless required by applicable law or agreed to in writing, software
3564 * distributed under the License is distributed on an "AS IS" BASIS,
3565 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3566 * See the License for the specific language governing permissions and
3567 * limitations under the License.
3568 */class Wt{constructor(e){this.fields=e,e.sort($e.comparator)}static empty(){return new Wt([])}unionWith(e){let t=new be($e.comparator);for(const s of this.fields)t=t.add(s);for(const s of e)t=t.add(s);return new Wt(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return hs(this.fields,e.fields,(t,s)=>t.isEqual(s))}}/**
3569 * @license
3570 * Copyright 2023 Google LLC
3571 *
3572 * Licensed under the Apache License, Version 2.0 (the "License");
3573 * you may not use this file except in compliance with the License.
3574 * You may obtain a copy of the License at
3575 *
3576 *   http://www.apache.org/licenses/LICENSE-2.0
3577 *
3578 * Unless required by applicable law or agreed to in writing, software
3579 * distributed under the License is distributed on an "AS IS" BASIS,
3580 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3581 * See the License for the specific language governing permissions and
3582 * limitations under the License.
3583 */class hg extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}/**
3584 * @license
3585 * Copyright 2020 Google LLC
3586 *
3587 * Licensed under the Apache License, Version 2.0 (the "License");
3588 * you may not use this file except in compliance with the License.
3589 * You may obtain a copy of the License at
3590 *
3591 *   http://www.apache.org/licenses/LICENSE-2.0
3592 *
3593 * Unless required by applicable law or agreed to in writing, software
3594 * distributed under the License is distributed on an "AS IS" BASIS,
3595 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3596 * See the License for the specific language governing permissions and
3597 * limitations under the License.
3598 */class Pe{constructor(e){this.binaryString=e}static fromBase64String(e){const t=function(i){try{return atob(i)}catch(r){throw typeof DOMException<"u"&&r instanceof DOMException?new hg("Invalid base64 string: "+r):r}}(e);return new Pe(t)}static fromUint8Array(e){const t=function(i){let r="";for(let o=0;o<i.length;++o)r+=String.fromCharCode(i[o]);return r}(e);return new Pe(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return function(t){return btoa(t)}(this.binaryString)}toUint8Array(){return function(t){const s=new Uint8Array(t.length);for(let i=0;i<t.length;i++)s[i]=t.charCodeAt(i);return s}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return ee(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}Pe.EMPTY_BYTE_STRING=new Pe("");const LR=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function rn(n){if(he(!!n),typeof n=="string"){let e=0;const t=LR.exec(n);if(he(!!t),t[1]){let i=t[1];i=(i+"000000000").substr(0,9),e=Number(i)}const s=new Date(n);return{seconds:Math.floor(s.getTime()/1e3),nanos:e}}return{seconds:fe(n.seconds),nanos:fe(n.nanos)}}function fe(n){return typeof n=="number"?n:typeof n=="string"?Number(n):0}function Pn(n){return typeof n=="string"?Pe.fromBase64String(n):Pe.fromUint8Array(n)}/**
3599 * @license
3600 * Copyright 2020 Google LLC
3601 *
3602 * Licensed under the Apache License, Version 2.0 (the "License");
3603 * you may not use this file except in compliance with the License.
3604 * You may obtain a copy of the License at
3605 *
3606 *   http://www.apache.org/licenses/LICENSE-2.0
3607 *
3608 * Unless required by applicable law or agreed to in writing, software
3609 * distributed under the License is distributed on an "AS IS" BASIS,
3610 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3611 * See the License for the specific language governing permissions and
3612 * limitations under the License.
3613 */function Ec(n){var e,t;return((t=(((e=n==null?void 0:n.mapValue)===null||e===void 0?void 0:e.fields)||{}).__type__)===null||t===void 0?void 0:t.stringValue)==="server_timestamp"}function Tc(n){const e=n.mapValue.fields.__previous_value__;
3613return Ec(e)?Tc(e):e}function Ai(n){const e=rn(n.mapValue.fields.__local_write_time__.timestampValue);return new ze(e.seconds,e.nanos)}/**
3614 * @license
3615 * Copyright 2017 Google LLC
3616 *
3617 * Licensed under the Apache License, Version 2.0 (the "License");
3618 * you may not use this file except in compliance with the License.
3619 * You may obtain a copy of the License at
3620 *
3621 *   http://www.apache.org/licenses/LICENSE-2.0
3622 *
3623 * Unless required by applicable law or agreed to in writing, software
3624 * distributed under the License is distributed on an "AS IS" BASIS,
3625 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3626 * See the License for the specific language governing permissions and
3627 * limitations under the License.
3628 */class VR{constructor(e,t,s,i,r,o,l,c,h){this.databaseId=e,this.appId=t,this.persistenceKey=s,this.host=i,this.ssl=r,this.forceLongPolling=o,this.autoDetectLongPolling=l,this.longPollingOptions=c,this.useFetchStreams=h}}class Ri{constructor(e,t){this.projectId=e,this.database=t||"(default)"}static empty(){return new Ri("","")}get isDefaultDatabase(){return this.database==="(default)"}isEqual(e){return e instanceof Ri&&e.projectId===this.projectId&&e.database===this.database}}/**
3629 * @license
3630 * Copyright 2020 Google LLC
3631 *
3632 * Licensed under the Apache License, Version 2.0 (the "License");
3633 * you may not use this file except in compliance with the License.
3634 * You may obtain a copy of the License at
3635 *
3636 *   http://www.apache.org/licenses/LICENSE-2.0
3637 *
3638 * Unless required by applicable law or agreed to in writing, software
3639 * distributed under the License is distributed on an "AS IS" BASIS,
3640 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3641 * See the License for the specific language governing permissions and
3642 * limitations under the License.
3643 */const mr={mapValue:{}};function kn(n){return"nullValue"in n?0:"booleanValue"in n?1:"integerValue"in n||"doubleValue"in n?2:"timestampValue"in n?3:"stringValue"in n?5:"bytesValue"in n?6:"referenceValue"in n?7:"geoPointValue"in n?8:"arrayValue"in n?9:"mapValue"in n?Ec(n)?4:UR(n)?9007199254740991:FR(n)?10:11:j()}function pt(n,e){if(n===e)return!0;const t=kn(n);if(t!==kn(e))return!1;switch(t){case 0:case 9007199254740991:return!0;case 1:return n.booleanValue===e.booleanValue;case 4:return Ai(n).isEqual(Ai(e));case 3:return function(i,r){if(typeof i.timestampValue=="string"&&typeof r.timestampValue=="string"&&i.timestampValue.length===r.timestampValue.length)return i.timestampValue===r.timestampValue;const o=rn(i.timestampValue),l=rn(r.timestampValue);return o.seconds===l.seconds&&o.nanos===l.nanos}(n,e);case 5:return n.stringValue===e.stringValue;case 6:return function(i,r){return Pn(i.bytesValue).isEqual(Pn(r.bytesValue))}(n,e);case 7:return n.referenceValue===e.referenceValue;case 8:return function(i,r){return fe(i.geoPointValue.latitude)===fe(r.geoPointValue.latitude)&&fe(i.geoPointValue.longitude)===fe(r.geoPointValue.longitude)}(n,e);case 2:return function(i,r){if("integerValue"in i&&"integerValue"in r)return fe(i.integerValue)===fe(r.integerValue);if("doubleValue"in i&&"doubleValue"in r){const o=fe(i.doubleValue),l=fe(r.doubleValue);return o===l?il(o)===il(l):isNaN(o)&&isNaN(l)}return!1}(n,e);case 9:return hs(n.arrayValue.values||[],e.arrayValue.values||[],pt);case 10:case 11:return function(i,r){const o=i.mapValue.fields||{},l=r.mapValue.fields||{};if(_d(o)!==_d(l))return!1;for(const c in o)if(o.hasOwnProperty(c)&&(l[c]===void 0||!pt(o[c],l[c])))return!1;return!0}(n,e);default:return j()}}function Si(n,e){return(n.values||[]).find(t=>pt(t,e))!==void 0}function ds(n,e){if(n===e)return 0;const t=kn(n),s=kn(e);if(t!==s)return ee(t,s);switch(t){case 0:case 9007199254740991:return 0;case 1:return ee(n.booleanValue,e.booleanValue);case 2:return function(r,o){const l=fe(r.integerValue||r.doubleValue),c=fe(o.integerValue||o.doubleValue);return l<c?-1:l>c?1:l===c?0:isNaN(l)?isNaN(c)?0:-1:1}(n,e);case 3:return md(n.timestampValue,e.timestampValue);case 4:return md(Ai(n),Ai(e));case 5:return ee(n.stringValue,e.stringValue);case 6:return function(r,o){const l=Pn(r),c=Pn(o);return l.compareTo(c)}(n.bytesValue,e.bytesValue);case 7:return function(r,o){const l=r.split("/"),c=o.split("/");for(let h=0;h<l.length&&h<c.length;h++){const f=ee(l[h],c[h]);if(f!==0)return f}return ee(l.length,c.length)}(n.referenceValue,e.referenceValue);case 8:return function(r,o){const l=ee(fe(r.latitude),fe(o.latitude));return l!==0?l:ee(fe(r.longitude),fe(o.longitude))}(n.geoPointValue,e.geoPointValue);case 9:return yd(n.arrayValue,e.arrayValue);case 10:return function(r,o){var l,c,h,f;
3643const p=r.fields||{},g=o.fields||{},I=(l=p.value)===null||l===void 0?void 0:l.arrayValue,S=(c=g.value)===null||c===void 0?void 0:c.arrayValue,k=ee(((h=I==null?void 0:I.values)===null||h===void 0?void 0:h.length)||0,((f=S==null?void 0:S.values)===null||f===void 0?void 0:f.length)||0);return k!==0?k:yd(I,S)}(n.mapValue,e.mapValue);case 11:return function(r,o){if(r===mr.mapValue&&o===mr.mapValue)return 0;if(r===mr.mapValue)return 1;if(o===mr.mapValue)return-1;const l=r.fields||{},c=Object.keys(l),h=o.fields||{},f=Object.keys(h);c.sort(),f.sort();for(let p=0;p<c.length&&p<f.length;++p){const g=ee(c[p],f[p]);if(g!==0)return g;const I=ds(l[c[p]],h[f[p]]);if(I!==0)return I}return ee(c.length,f.length)}(n.mapValue,e.mapValue);default:throw j()}}function md(n,e){if(typeof n=="string"&&typeof e=="string"&&n.length===e.length)return ee(n,e);const t=rn(n),s=rn(e),i=ee(t.seconds,s.seconds);return i!==0?i:ee(t.nanos,s.nanos)}function yd(n,e){const t=n.values||[],s=e.values||[];for(let i=0;i<t.length&&i<s.length;++i){const r=ds(t[i],s[i]);if(r)return r}return ee(t.length,s.length)}function fs(n){return rl(n)}function rl(n){return"nullValue"in n?"null":"booleanValue"in n?""+n.booleanValue:"integerValue"in n?""+n.integerValue:"doubleValue"in n?""+n.doubleValue:"timestampValue"in n?function(t){const s=rn(t);return`time(${s.seconds},${s.nanos})`}(n.timestampValue):"stringValue"in n?n.stringValue:"bytesValue"in n?function(t){return Pn(t).toBase64()}(n.bytesValue):"referenceValue"in n?function(t){return F.fromName(t).toString()}(n.referenceValue):"geoPointValue"in n?function(t){return`geo(${t.latitude},${t.longitude})`}(n.geoPointValue):"arrayValue"in n?function(t){let s="[",i=!0;for(const r of t.values||[])i?i=!1:s+=",",s+=rl(r);return s+"]"}(n.arrayValue):"mapValue"in n?function(t){const s=Object.keys(t.fields||{}).sort();let i="{",r=!0;for(const o of s)r?r=!1:i+=",",i+=`${o}:${rl(t.fields[o])}`;return i+"}"}(n.mapValue):j()}function ol(n){return!!n&&"integerValue"in n}function Ic(n){return!!n&&"arrayValue"in n}function vd(n){return!!n&&"nullValue"in n}function Ed(n){return!!n&&"doubleValue"in n&&isNaN(Number(n.doubleValue))}function Aa(n){return!!n&&"mapValue"in n}function FR(n){var e,t;return((t=(((e=n==null?void 0:n.mapValue)===null||e===void 0?void 0:e.fields)||{}).__type__)===null||t===void 0?void 0:t.stringValue)==="__vector__"}function oi(n){if(n.geoPointValue)return{geoPointValue:Object.assign({},n.geoPointValue)};if(n.timestampValue&&typeof n.timestampValue=="object")return{timestampValue:Object.assign({},n.timestampValue)};if(n.mapValue){const e={mapValue:{fields:{}}};return bo(n.mapValue.fields,(t,s)=>e.mapValue.fields[t]=oi(s)),e}if(n.arrayValue){const e={arrayValue:{values:[]}};for(let t=0;t<(n.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=oi(n.arrayValue.values[t]);return e}return Object.assign({},n)}function UR(n){return(((n.mapValue||{}).fields||{}).__type__||{}).stringValue==="__max__"}/**
3644 * @license
3645 * Copyright 2017 Google LLC
3646 *
3647 * Licensed under the Apache License, Version 2.0 (the "License");
3648 * you may not use this file except in compliance with the License.
3649 * You may obtain a copy of the License at
3650 *
3651 *   http://www.apache.org/licenses/LICENSE-2.0
3652 *
3653 * Unless required by applicable law or agreed to in writing, software
3654 * distributed under the License is distributed on an "AS IS" BASIS,
3655 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3656 * See the License for the specific language governing permissions and
3657 * limitations under the License.
3658 */class at{constructor(e){this.value=e}static empty(){return new at({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let s=0;s<e.length-1;++s)if(t=(t.mapValue.fields||{})[e.get(s)],!Aa(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=oi(t)}setAll(e){let t=$e.emptyPath(),s={},i=[];e.forEach((o,l)=>{if(!t.isImmediateParentOf(l)){const c=this.getFieldsMap(t);this.applyChanges(c,s,i),s={},i=[],t=l.popLast()}o?s[l.lastSegment()]=oi(o):i.push(l.lastSegment())});const r=this.getFieldsMap(t);this.applyChanges(r,s,i)}delete(e){const t=this.field(e.popLast());Aa(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return pt(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let s=0;s<e.length;++s){let i=t.mapValue.fields[e.get(s)];Aa(i)&&i.mapValue.fields||(i={mapValue:{fields:{}}},t.mapValue.fields[e.get(s)]=i),t=i}return t.mapValue.fields}
vendor: 4,182 bytes, lines 3658-3698
3658applyChanges(e,t,s){bo(t,(i,r)=>e[i]=r);for(const i of s)delete e[i]}clone(){return new at(oi(this.value))}}/**
3659 * @license
3660 * Copyright 2017 Google LLC
3661 *
3662 * Licensed under the Apache License, Version 2.0 (the "License");
3663 * you may not use this file except in compliance with the License.
3664 * You may obtain a copy of the License at
3665 *
3666 *   http://www.apache.org/licenses/LICENSE-2.0
3667 *
3668 * Unless required by applicable law or agreed to in writing, software
3669 * distributed under the License is distributed on an "AS IS" BASIS,
3670 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3671 * See the License for the specific language governing permissions and
3672 * limitations under the License.
3673 */class Ve{constructor(e,t,s,i,r,o,l){this.key=e,this.documentType=t,this.version=s,this.readTime=i,this.createTime=r,this.data=o,this.documentState=l}static newInvalidDocument(e){return new Ve(e,0,q.min(),q.min(),q.min(),at.empty(),0)}static newFoundDocument(e,t,s,i){return new Ve(e,1,t,q.min(),s,i,0)}static newNoDocument(e,t){return new Ve(e,2,t,q.min(),q.min(),at.empty(),0)}static newUnknownDocument(e,t){return new Ve(e,3,t,q.min(),q.min(),at.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(q.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=at.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=at.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=q.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(e){return e instanceof Ve&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new Ve(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}/**
3674 * @license
3675 * Copyright 2022 Google LLC
3676 *
3677 * Licensed under the Apache License, Version 2.0 (the "License");
3678 * you may not use this file except in compliance with the License.
3679 * You may obtain a copy of the License at
3680 *
3681 *   http://www.apache.org/licenses/LICENSE-2.0
3682 *
3683 * Unless required by applicable law or agreed to in writing, software
3684 * distributed under the License is distributed on an "AS IS" BASIS,
3685 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3686 * See the License for the specific language governing permissions and
3687 * limitations under the License.
3688 */class eo{constructor(e,t){this.position=e,this.inclusive=t}}function Td(n,e,t){let s=0;for(let i=0;i<n.position.length;i++){const r=e[i],o=n.position[i];if(r.field.isKeyField()?s=F.comparator(F.fromName(o.referenceValue),t.key):s=ds(o,t.data.field(r.field)),r.dir==="desc"&&(s*=-1),s!==0)break}return s}function Id(n,e){if(n===null)return e===null;if(e===null||n.inclusive!==e.inclusive||n.position.length!==e.position.length)return!1;for(let t=0;t<n.position.length;t++)if(!pt(n.position[t],e.position[t]))return!1;return!0}/**
3689 * @license
3690 * Copyright 2022 Google LLC
3691 *
3692 * Licensed under the Apache License, Version 2.0 (the "License");
3693 * you may not use this file except in compliance with the License.
3694 * You may obtain a copy of the License at
3695 *
3696 *   http://www.apache.org/licenses/LICENSE-2.0
3697 *
3698 * Unless required by applicable law or agreed to in writing, softw
3698are
3699 * distributed under the License is distributed on an "AS IS" BASIS,
3700 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3701 * See the License for the specific language governing permissions and
3702 * limitations under the License.
3703 */class to{constructor(e,t="asc"){this.field=e,this.dir=t}}function BR(n,e){return n.dir===e.dir&&n.field.isEqual(e.field)}/**
3704 * @license
3705 * Copyright 2022 Google LLC
3706 *
3707 * Licensed under the Apache License, Version 2.0 (the "License");
3708 * you may not use this file except in compliance with the License.
3709 * You may obtain a copy of the License at
3710 *
3711 *   http://www.apache.org/licenses/LICENSE-2.0
3712 *
3713 * Unless required by applicable law or agreed to in writing, software
3714 * distributed under the License is distributed on an "AS IS" BASIS,
3715 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3716 * See the License for the specific language governing permissions and
3717 * limitations under the License.
3718 */class dg{}class Ee extends dg{constructor(e,t,s){super(),this.field=e,this.op=t,this.value=s}static create(e,t,s){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,s):new $R(e,t,s):t==="array-contains"?new WR(e,s):t==="in"?new zR(e,s):t==="not-in"?new GR(e,s):t==="array-contains-any"?new KR(e,s):new Ee(e,t,s)}static createKeyFieldInFilter(e,t,s){return t==="in"?new jR(e,s):new HR(e,s)}matches(e){const t=e.data.field(this.field);return this.op==="!="?t!==null&&this.matchesComparison(ds(t,this.value)):t!==null&&kn(this.value)===kn(t)&&this.matchesComparison(ds(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return j()}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class _t extends dg{constructor(e,t){super(),this.filters=e,this.op=t,this.ae=null}static create(e,t){return new _t(e,t)}matches(e){return fg(this)?this.filters.find(t=>!t.matches(e))===void 0:this.filters.find(t=>t.matches(e))!==void 0}getFlattenedFilters(){return this.ae!==null||(this.ae=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.ae}getFilters(){return Object.assign([],this.filters)}}function fg(n){return n.op==="and"}function pg(n){return qR(n)&&fg(n)}function qR(n){for(const e of n.filters)if(e instanceof _t)return!1;return!0}function al(n){if(n instanceof Ee)return n.field.canonicalString()+n.op.toString()+fs(n.value);if(pg(n))return n.filters.map(e=>al(e)).join(",");{const e=n.filters.map(t=>al(t)).join(",");return`${n.op}(${e})`}}function _g(n,e){return n instanceof Ee?function(s,i){return i instanceof Ee&&s.op===i.op&&s.field.isEqual(i.field)&&pt(s.value,i.value)}(n,e):n instanceof _t?function(s,i){return i instanceof _t&&s.op===i.op&&s.filters.length===i.filters.length?s.filters.reduce((r,o,l)=>r&&_g(o,i.filters[l]),!0):!1}(n,e):void j()}function gg(n){return n instanceof Ee?function(t){return`${t.field.canonicalString()} ${t.op} ${fs(t.value)}`}(n):n instanceof _t?function(t){return t.op.toString()+" {"+t.getFilters().map(gg).join(" ,")+"}"}(n):"Filter"}class $R extends Ee{constructor(e,t,s){super(e,t,s),this.key=F.fromName(s.referenceValue)}matches(e){const t=F.comparator(e.key,this.key);return this.matchesComparison(t)}}class jR extends Ee{constructor(e,t){super(e,"in",t),this.keys=mg("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}}class HR extends Ee{constructor(e,t){super(e,"not-in",t),this.keys=mg("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}}function mg(n,e){var t;return(((t=e.arrayValue)===null||t===void 0?void 0:t.values)||[]).map(s=>F.fromName(s.referenceValue))}class WR extends Ee{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return Ic(t)&&Si(t.arrayValue,this.value)}}class zR extends Ee{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return t!==null&&Si(this.value.arrayValue,t)}}class GR extends Ee{constructor(e,t){super(e,"not-in",t)}matches(e){if(Si(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return t!==null&&!Si(this.value.arrayValue,t)}}
3718class KR extends Ee{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!Ic(t)||!t.arrayValue.values)&&t.arrayValue.values.some(s=>Si(this.value.arrayValue,s))}}/**
3719 * @license
3720 * Copyright 2019 Google LLC
3721 *
3722 * Licensed under the Apache License, Version 2.0 (the "License");
3723 * you may not use this file except in compliance with the License.
3724 * You may obtain a copy of the License at
3725 *
3726 *   http://www.apache.org/licenses/LICENSE-2.0
3727 *
3728 * Unless required by applicable law or agreed to in writing, software
3729 * distributed under the License is distributed on an "AS IS" BASIS,
3730 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3731 * See the License for the specific language governing permissions and
3732 * limitations under the License.
3733 */class QR{constructor(e,t=null,s=[],i=[],r=null,o=null,l=null){this.path=e,this.collectionGroup=t,this.orderBy=s,this.filters=i,this.limit=r,this.startAt=o,this.endAt=l,this.ue=null}}function wd(n,e=null,t=[],s=[],i=null,r=null,o=null){return new QR(n,e,t,s,i,r,o)}function wc(n){const e=Y(n);if(e.ue===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(s=>al(s)).join(","),t+="|ob:",t+=e.orderBy.map(s=>function(r){return r.field.canonicalString()+r.dir}(s)).join(","),So(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(s=>fs(s)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(s=>fs(s)).join(",")),e.ue=t}return e.ue}function Cc(n,e){if(n.limit!==e.limit||n.orderBy.length!==e.orderBy.length)return!1;for(let t=0;t<n.orderBy.length;t++)if(!BR(n.orderBy[t],e.orderBy[t]))return!1;if(n.filters.length!==e.filters.length)return!1;for(let t=0;t<n.filters.length;t++)if(!_g(n.filters[t],e.filters[t]))return!1;return n.collectionGroup===e.collectionGroup&&!!n.path.isEqual(e.path)&&!!Id(n.startAt,e.startAt)&&Id(n.endAt,e.endAt)}function ll(n){return F.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}/**
3734 * @license
3735 * Copyright 2017 Google LLC
3736 *
3737 * Licensed under the Apache License, Version 2.0 (the "License");
3738 * you may not use this file except in compliance with the License.
3739 * You may obtain a copy of the License at
3740 *
3741 *   http://www.apache.org/licenses/LICENSE-2.0
3742 *
3743 * Unless required by applicable law or agreed to in writing, software
3744 * distributed under the License is distributed on an "AS IS" BASIS,
3745 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3746 * See the License for the specific language governing permissions and
3747 * limitations under the License.
3748 */class Po{constructor(e,t=null,s=[],i=[],r=null,o="F",l=null,c=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=s,this.filters=i,this.limit=r,this.limitType=o,this.startAt=l,this.endAt=c,this.ce=null,this.le=null,this.he=null,this.startAt,this.endAt}}function YR(n,e,t,s,i,r,o,l){return new Po(n,e,t,s,i,r,o,l)}function ko(n){return new Po(n)}function Cd(n){return n.filters.length===0&&n.limit===null&&n.startAt==null&&n.endAt==null&&(n.explicitOrderBy.length===0||n.explicitOrderBy.length===1&&n.explicitOrderBy[0].field.isKeyField())}function XR(n){return n.collectionGroup!==null}function ai(n){const e=Y(n);if(e.ce===null){e.ce=[];const t=new Set;for(const r of e.explicitOrderBy)e.ce.push(r),t.add(r.field.canonicalString());const s=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(o){let l=new be($e.comparator);return o.filters.forEach(c=>{c.getFlattenedFilters().forEach(h=>{h.isInequality()&&(l=l.add(h.field))})}),l})(e).forEach(r=>{t.has(r.canonicalString())||r.isKeyField()||e.ce.push(new to(r,s))}),t.has($e.keyField().canonicalString())||e.ce.push(new to($e.keyField(),s))}return e.ce}function ft(n){const e=Y(n);return e.le||(e.le=JR(e,ai(n))),e.le}function JR(n,e){if(n.limitType==="F")return wd(n.path,n.collectionGroup,e,n.filters,n.limit,n.startAt,n.endAt);{e=e.map(i=>{const r=i.dir==="desc"?"asc":"desc";return new to(i.field,r)});const t=n.endAt?new eo(n.endAt.position,n.endAt.inclusive):null,s=n.startAt?new eo(n.startAt.position,n.startAt.inclusive):null;return wd(n.path,n.collectionGroup,e,n.filters,n.limit,t,s)}}function cl(n,e,t){return new Po(n.path,n.collectionGroup,n.explicitOrderBy.slice(),n.filters.slice(),e,t,n.startAt,n.endAt)}function No(n,e){return Cc(ft(n),ft(e))&&n.limitType===e.limitType}function yg(n){return`${wc(ft(n))}|lt:${n.limitType}`}function qn(n){return`Query(target=${function(t){let s=t.path.canonicalString();return t.collectionGroup!==null&&(s+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(s+=`, filters: [${t.filters.map(i=>gg(i)).join(", ")}]`),So(t.limit)||(s+=", limit: "+t.limit),t.orderBy.length>0&&(s+=`, orderBy: [${t.orderBy.map(i=>function(o){return`${o.field.canonicalString()} (${o.dir})`}(i)).join(", ")}]`),t.startAt&&(s+=", startAt: ",s+=t.startAt.inclusive?"b:":"a:",s+=t.startAt.position.map(i=>fs(i)).join(",")),t.endAt&&(s+=", endAt: ",s+=t.endAt.inclusive?"a:":"b:",s+=t.endAt.position.map(i=>fs(i)).join(",")),`Target(${s})`}(ft(n))}; limitType=${n.limitType})`}function Do(n,e){return e.isFoundDocument()&&function(s,i){const r=i.key.path;return s.collectionGroup!==null?i.key.hasCollectionId(s.collectionGroup)&&s.path.isPrefixOf(r):F.isDocumentKey(s.path)?s.path.isEqual(r):s.path.isImmediateParentOf(r)}(n,e)&&function(s,i){for(const r of ai(s))if(!r.field.isKeyField()&&i.data.field(r.field)===null)return!1;return!0}(n,e)&&function(s,i){for(const r of s.filters)if(!r.matches(i))return!1;return!0}(n,e)&&function(s,i){return!(s.startAt&&!function(o,l,c){const h=Td(o,l,c);return o.inclusive?h<=0:h<0}(s.startAt,ai(s),i)||s.endAt&&!function(o,l,c){const h=Td(o,l,c);return o.inclusive?h>=0:h>0}(s.endAt,ai(s),i))}(n,e)}function ZR(n){return n.collectionGroup||(n.path.length%2==1?n.path.lastSegment():n.path.get(n.path.length-2))}function vg(n){return(e,t)=>{let s=!1;for(const i of ai(n)){const r=eS(i,e,t);if(r!==0)return r;s=s||i.field.isKeyField()}return 0}}function eS(n,e,t){const s=n.field.isKeyField()?F.comparator(e.key,t.key):function(r,o,l){const c=o.data.field(r),h=l.data.field(r);return c!==null&&h!==null?ds(c,h):j()}(n.field,e,t);switch(n.dir){case"asc":return s;
3748case"desc":return-1*s;default:return j()}}/**
3749 * @license
3750 * Copyright 2017 Google LLC
3751 *
3752 * Licensed under the Apache License, Version 2.0 (the "License");
3753 * you may not use this file except in compliance with the License.
3754 * You may obtain a copy of the License at
3755 *
3756 *   http://www.apache.org/licenses/LICENSE-2.0
3757 *
3758 * Unless required by applicable law or agreed to in writing, software
3759 * distributed under the License is distributed on an "AS IS" BASIS,
3760 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3761 * See the License for the specific language governing permissions and
3762 * limitations under the License.
3763 */class ws{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){const t=this.mapKeyFn(e),s=this.inner[t];if(s!==void 0){for(const[i,r]of s)if(this.equalsFn(i,e))return r}}has(e){return this.get(e)!==void 0}set(e,t){const s=this.mapKeyFn(e),i=this.inner[s];if(i===void 0)return this.inner[s]=[[e,t]],void this.innerSize++;for(let r=0;r<i.length;r++)if(this.equalsFn(i[r][0],e))return void(i[r]=[e,t]);i.push([e,t]),this.innerSize++}delete(e){const t=this.mapKeyFn(e),s=this.inner[t];if(s===void 0)return!1;for(let i=0;i<s.length;i++)if(this.equalsFn(s[i][0],e))return s.length===1?delete this.inner[t]:s.splice(i,1),this.innerSize--,!0;return!1}forEach(e){bo(this.inner,(t,s)=>{for(const[i,r]of s)e(i,r)})}isEmpty(){return MR(this.inner)}size(){return this.innerSize}}/**
3764 * @license
3765 * Copyright 2017 Google LLC
3766 *
3767 * Licensed under the Apache License, Version 2.0 (the "License");
3768 * you may not use this file except in compliance with the License.
3769 * You may obtain a copy of the License at
3770 *
3771 *   http://www.apache.org/licenses/LICENSE-2.0
3772 *
3773 * Unless required by applicable law or agreed to in writing, software
3774 * distributed under the License is distributed on an "AS IS" BASIS,
3775 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3776 * See the License for the specific language governing permissions and
3777 * limitations under the License.
3778 */const tS=new pe(F.comparator);function on(){return tS}const Eg=new pe(F.comparator);function Xs(...n){let e=Eg;for(const t of n)e=e.insert(t.key,t);return e}function nS(n){let e=Eg;return n.forEach((t,s)=>e=e.insert(t,s.overlayedDocument)),e}function yn(){return li()}function Tg(){return li()}function li(){return new ws(n=>n.toString(),(n,e)=>n.isEqual(e))}const sS=new be(F.comparator);function X(...n){let e=sS;for(const t of n)e=e.add(t);return e}const iS=new be(ee);function rS(){return iS}/**
3779 * @license
3780 * Copyright 2020 Google LLC
3781 *
3782 * Licensed under the Apache License, Version 2.0 (the "License");
3783 * you may not use this file except in compliance with the License.
3784 * You may obtain a copy of the License at
3785 *
3786 *   http://www.apache.org/licenses/LICENSE-2.0
3787 *
3788 * Unless required by applicable law or agreed to in writing, software
3789 * distributed under the License is distributed on an "AS IS" BASIS,
3790 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3791 * See the License for the specific language governing permissions and
3792 * limitations under the License.
3793 */function oS(n,e){if(n.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:il(e)?"-0":e}}function aS(n){return{integerValue:""+n}}/**
3794 * @license
3795 * Copyright 2018 Google LLC
3796 *
3797 * Licensed under the Apache License, Version 2.0 (the "License");
3798 * you may not use this file except in compliance with the License.
3799 * You may obtain a copy of the License at
3800 *
3801 *   http://www.apache.org/licenses/LICENSE-2.0
3802 *
3803 * Unless required by applicable law or agreed to in writing, software
3804 * distributed under the License is distributed on an "AS IS" BASIS,
3805 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3806 * See the License for the specific language governing permissions and
3807 * limitations under the License.
3808 */class Oo{constructor(){this._=void 0}}function lS(n,e,t){return n instanceof ul?function(i,r){const o={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:i.seconds,nanos:i.nanoseconds}}}};return r&&Ec(r)&&(r=Tc(r)),r&&(o.fields.__previous_value__=r),{mapValue:o}}(t,e):n instanceof no?Ig(n,e):n instanceof so?wg(n,e):function(i,r){const o=uS(i,r),l=Ad(o)+Ad(i.Pe);return ol(o)&&ol(i.Pe)?aS(l):oS(i.serializer,l)}(n,e)}function cS(n,e,t){return n instanceof no?Ig(n,e):n instanceof so?wg(n,e):t}function uS(n,e){return n instanceof hl?function(s){return ol(s)||function(r){return!!r&&"doubleValue"in r}(s)}(e)?e:{integerValue:0}:null}class ul extends Oo{}class no extends Oo{constructor(e){super(),this.elements=e}}function Ig(n,e){const t=Cg(e);for(const s of n.elements)t.some(i=>
3808pt(i,s))||t.push(s);return{arrayValue:{values:t}}}class so extends Oo{constructor(e){super(),this.elements=e}}function wg(n,e){let t=Cg(e);for(const s of n.elements)t=t.filter(i=>!pt(i,s));return{arrayValue:{values:t}}}class hl extends Oo{constructor(e,t){super(),this.serializer=e,this.Pe=t}}function Ad(n){return fe(n.integerValue||n.doubleValue)}function Cg(n){return Ic(n)&&n.arrayValue.values?n.arrayValue.values.slice():[]}function hS(n,e){return n.field.isEqual(e.field)&&function(s,i){return s instanceof no&&i instanceof no||s instanceof so&&i instanceof so?hs(s.elements,i.elements,pt):s instanceof hl&&i instanceof hl?pt(s.Pe,i.Pe):s instanceof ul&&i instanceof ul}(n.transform,e.transform)}class Tn{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new Tn}static exists(e){return new Tn(void 0,e)}static updateTime(e){return new Tn(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function br(n,e){return n.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(n.updateTime):n.exists===void 0||n.exists===e.isFoundDocument()}class Ac{}function Ag(n,e){if(!n.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return n.isNoDocument()?new fS(n.key,Tn.none()):new Rc(n.key,n.data,Tn.none());{const t=n.data,s=at.empty();let i=new be($e.comparator);for(let r of e.fields)if(!i.has(r)){let o=t.field(r);o===null&&r.length>1&&(r=r.popLast(),o=t.field(r)),o===null?s.delete(r):s.set(r,o),i=i.add(r)}return new xo(n.key,s,new Wt(i.toArray()),Tn.none())}}function dS(n,e,t){n instanceof Rc?function(i,r,o){const l=i.value.clone(),c=Sd(i.fieldTransforms,r,o.transformResults);l.setAll(c),r.convertToFoundDocument(o.version,l).setHasCommittedMutations()}(n,e,t):n instanceof xo?function(i,r,o){if(!br(i.precondition,r))return void r.convertToUnknownDocument(o.version);const l=Sd(i.fieldTransforms,r,o.transformResults),c=r.data;c.setAll(Rg(i)),c.setAll(l),r.convertToFoundDocument(o.version,c).setHasCommittedMutations()}(n,e,t):function(i,r,o){r.convertToNoDocument(o.version).setHasCommittedMutations()}(0,e,t)}function ci(n,e,t,s){return n instanceof Rc?function(r,o,l,c){if(!br(r.precondition,o))return l;const h=r.value.clone(),f=bd(r.fieldTransforms,c,o);return h.setAll(f),o.convertToFoundDocument(o.version,h).setHasLocalMutations(),null}(n,e,t,s):n instanceof xo?function(r,o,l,c){if(!br(r.precondition,o))return l;const h=bd(r.fieldTransforms,c,o),f=o.data;return f.setAll(Rg(r)),f.setAll(h),o.convertToFoundDocument(o.version,f).setHasLocalMutations(),l===null?null:l.unionWith(r.fieldMask.fields).unionWith(r.fieldTransforms.map(p=>p.field))}(n,e,t,s):function(r,o,l){return br(r.precondition,o)?(o.convertToNoDocument(o.version).setHasLocalMutations(),null):l}(n,e,t)}function Rd(n,e){return n.type===e.type&&!!n.key.isEqual(e.key)&&!!n.precondition.isEqual(e.precondition)&&!!function(s,i){return s===void 0&&i===void 0||!(!s||!i)&&hs(s,i,(r,o)=>hS(r,o))}(n.fieldTransforms,e.fieldTransforms)&&(n.type===0?n.value.isEqual(e.value):n.type!==1||n.data.isEqual(e.data)&&n.fieldMask.isEqual(e.fieldMask))}class Rc extends Ac{constructor(e,t,s,i=[]){super(),this.key=e,this.value=t,this.precondition=s,this.fieldTransforms=i,this.type=0}getFieldMask(){return null}}class xo extends Ac{constructor(e,t,s,i,r=[]){super(),this.key=e,this.data=t,this.fieldMask=s,this.precondition=i,this.fieldTransforms=r,this.type=1}getFieldMask(){return this.fieldMask}}function Rg(n){const e=new Map;return n.fieldMask.fields.forEach(t=>{if(!t.isEmpty()){const s=n.data.field(t);e.set(t,s)}}),e}function Sd(n,e,t){const s=new Map;he(n.length===t.length);for(let i=0;i<t.length;i++){const r=n[i],o=r.transform,l=e.data.field(r.field);s.set(r.field,cS(o,l,t[i]))}return s}function bd(n,e,t){const s=new Map;for(const i of n){const r=i.transform,o=t.data.field(i.field);s.set(i.field,lS(r,o,e))}return s}class fS extends Ac{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}/**
3809 * @license
3810 * Copyright 2017 Google LLC
3811 *
3812 * Licensed under the Apache License, Version 2.0 (the "License");
3813 * you may not use this file except in compliance with the License.
3814 * You may obtain a copy of the License at
3815 *
3816 *   http://www.apache.org/licenses/LICENSE-2.0
3817 *
3818 * Unless required by applicable law or agreed to in writing, software
3819 * distributed under the License is distributed on an "AS IS" BASIS,
3820 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3821 * See the License for the specific language governing permissions and
3822 * limitations under the License.
3823 */class pS{constructor(e,t,s,i){this.batchId=e,this.localWriteTime=t,this.baseMutations=s,this.mutations=i}applyToRemoteDocument(e,t){const s=t.mutationResults;for(let i=0;i<this.mutations.length;i++){const r=this.mutations[i];r.key.isEqual(e.key)&&dS(r,e,s[i])}}applyToLocalView(e,t){for(const s of this.baseMutations)s.key.isEqual(e.key)&&(t=ci(s,e,t,this.localWriteTime));for(const s of this.mutations)s.key.isEqual(e.key)&&(t=ci(s,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const s=Tg();return this.mutations.forEach(i=>{const r=e.get(i.key),o=r.overlayedDocument;let l=this.applyToLocalView(o,r.mutatedFields);l=t.has(i.key)?null:l;const c=Ag(o,l);c!==null&&s.set(i.key,c),o.isValidDocument()||o.convertToNoDocument(q.min())}),s}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),X())}isEqual(e){return this.batchId===e.batchId&&hs(this.mutations,e.mutations,(t,s)=>Rd(t,s))&&hs(this.baseMutations,e.baseMutations,(t,s)=>Rd(t,s))}}/**
3824 * @license
3825 * Copyright 2022 Google LLC
3826 *
3827 * Licensed under the Apache License, Version 2.0 (the "License");
3828 * you may not use this file except in compliance with the License.
3829 * You may obtain a copy of the License at
3830 *
3831 *   http://www.apache.org/licenses/LICENSE-2.0
3832 *
3833 * Unless required by applicable law or agreed to in writing, software
3834 * distributed under the License is distributed on an "AS IS" BASIS,
3835 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3836 * See the License for the specific language governing permissions and
3837 * limitations under the License.
3838 */class _S{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{
3839      largestBatchId: ${this.largestBatchId},
3840      mutation: ${this.mutation.toString()}
3841    }`}}/**
3842 * @license
3843 * Copyright 2017 Google LLC
3844 *
3845 * Licensed under the Apache License, Version 2.0 (the "License");
3846 * you may not use this file except in compliance with the License.
3847 * You may obtain a copy of the License at
3848 *
3849 *   http://www.apache.org/licenses/LICENSE-2.0
3850 *
3851 * Unless required by applicable law or agreed to in writing, software
3852 * distributed under the License is distributed on an "AS IS" BASIS,
3853 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3854 * See the License for the specific language governing permissions and
3855 * limitations under the License.
3856 */class gS{constructor(e,t){this.count=e,this.unchangedNames=t}}/**
3857 * @license
3858 * Copyright 2017 Google LLC
3859 *
3860 * Licensed under the Apache License, Version 2.0 (the "License");
3861 * you may not use this file except in compliance with the License.
3862 * You may obtain a copy of the License at
3863 *
3864 *   http://www.apache.org/licenses/LICENSE-2.0
3865 *
3866 * Unless required by applicable law or agreed to in writing, software
3867 * distributed under the License is distributed on an "AS IS" BASIS,
3868 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3869 * See the License for the specific language governing permissions and
3870 * limitations under the License.
3871 */var _e,Q;function Sg(n){if(n===void 0)return Mt("GRPC error has no .code"),O.UNKNOWN;switch(n){case _e.OK:return O.OK;case _e.CANCELLED:return O.CANCELLED;case _e.UNKNOWN:return O.UNKNOWN;case _e.DEADLINE_EXCEEDED:return O.DEADLINE_EXCEEDED;case _e.RESOURCE_EXHAUSTED:return O.RESOURCE_EXHAUSTED;case _e.INTERNAL:return O.INTERNAL;case _e.UNAVAILABLE:return O.UNAVAILABLE;case _e.UNAUTHENTICATED:return O.UNAUTHENTICATED;case _e.INVALID_ARGUMENT:return O.INVALID_ARGUMENT;case _e.NOT_FOUND:return O.NOT_FOUND;case _e.ALREADY_EXISTS:return O.ALREADY_EXISTS;case _e.PERMISSION_DENIED:return O.PERMISSION_DENIED;case _e.FAILED_PRECONDITION:return O.FAILED_PRECONDITION;case _e.ABORTED:return O.ABORTED;case _e.OUT_OF_RANGE:return O.OUT_OF_RANGE;
3871case _e.UNIMPLEMENTED:return O.UNIMPLEMENTED;case _e.DATA_LOSS:return O.DATA_LOSS;default:return j()}}(Q=_e||(_e={}))[Q.OK=0]="OK",Q[Q.CANCELLED=1]="CANCELLED",Q[Q.UNKNOWN=2]="UNKNOWN",Q[Q.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Q[Q.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Q[Q.NOT_FOUND=5]="NOT_FOUND",Q[Q.ALREADY_EXISTS=6]="ALREADY_EXISTS",Q[Q.PERMISSION_DENIED=7]="PERMISSION_DENIED",Q[Q.UNAUTHENTICATED=16]="UNAUTHENTICATED",Q[Q.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Q[Q.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Q[Q.ABORTED=10]="ABORTED",Q[Q.OUT_OF_RANGE=11]="OUT_OF_RANGE",Q[Q.UNIMPLEMENTED=12]="UNIMPLEMENTED",Q[Q.INTERNAL=13]="INTERNAL",Q[Q.UNAVAILABLE=14]="UNAVAILABLE",Q[Q.DATA_LOSS=15]="DATA_LOSS";/**
3872 * @license
3873 * Copyright 2023 Google LLC
3874 *
3875 * Licensed under the Apache License, Version 2.0 (the "License");
3876 * you may not use this file except in compliance with the License.
3877 * You may obtain a copy of the License at
3878 *
3879 *   http://www.apache.org/licenses/LICENSE-2.0
3880 *
3881 * Unless required by applicable law or agreed to in writing, software
3882 * distributed under the License is distributed on an "AS IS" BASIS,
3883 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3884 * See the License for the specific language governing permissions and
3885 * limitations under the License.
3886 */function mS(){return new TextEncoder}/**
3887 * @license
3888 * Copyright 2022 Google LLC
3889 *
3890 * Licensed under the Apache License, Version 2.0 (the "License");
3891 * you may not use this file except in compliance with the License.
3892 * You may obtain a copy of the License at
3893 *
3894 *   http://www.apache.org/licenses/LICENSE-2.0
3895 *
3896 * Unless required by applicable law or agreed to in writing, software
3897 * distributed under the License is distributed on an "AS IS" BASIS,
3898 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3899 * See the License for the specific language governing permissions and
3900 * limitations under the License.
3901 */const yS=new En([4294967295,4294967295],0);function Pd(n){const e=mS().encode(n),t=new ig;return t.update(e),new Uint8Array(t.digest())}function kd(n){const e=new DataView(n.buffer),t=e.getUint32(0,!0),s=e.getUint32(4,!0),i=e.getUint32(8,!0),r=e.getUint32(12,!0);return[new En([t,s],0),new En([i,r],0)]}class Sc{constructor(e,t,s){if(this.bitmap=e,this.padding=t,this.hashCount=s,t<0||t>=8)throw new Js(`Invalid padding: ${t}`);if(s<0)throw new Js(`Invalid hash count: ${s}`);if(e.length>0&&this.hashCount===0)throw new Js(`Invalid hash count: ${s}`);if(e.length===0&&t!==0)throw new Js(`Invalid padding when bitmap length is 0: ${t}`);this.Ie=8*e.length-t,this.Te=En.fromNumber(this.Ie)}Ee(e,t,s){let i=e.add(t.multiply(En.fromNumber(s)));return i.compare(yS)===1&&(i=new En([i.getBits(0),i.getBits(1)],0)),i.modulo(this.Te).toNumber()}de(e){return(this.bitmap[Math.floor(e/8)]&1<<e%8)!=0}mightContain(e){if(this.Ie===0)return!1;const t=Pd(e),[s,i]=kd(t);for(let r=0;r<this.hashCount;r++){const o=this.Ee(s,i,r);if(!this.de(o))return!1}return!0}static create(e,t,s){const i=e%8==0?0:8-e%8,r=new Uint8Array(Math.ceil(e/8)),o=new Sc(r,i,t);return s.forEach(l=>o.insert(l)),o}insert(e){if(this.Ie===0)return;const t=Pd(e),[s,i]=kd(t);for(let r=0;r<this.hashCount;r++){const o=this.Ee(s,i,r);this.Ae(o)}}Ae(e){const t=Math.floor(e/8),s=e%8;this.bitmap[t]|=1<<s}}class Js extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}/**
3902 * @license
3903 * Copyright 2017 Google LLC
3904 *
3905 * Licensed under the Apache License, Version 2.0 (the "License");
3906 * you may not use this file except in compliance with the License.
3907 * You may obtain a copy of the License at
3908 *
3909 *   http://www.apache.org/licenses/LICENSE-2.0
3910 *
3911 * Unless required by applicable law or agreed to in writing, software
3912 * distributed under the License is distributed on an "AS IS" BASIS,
3913 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3914 * See the License for the specific language governing permissions and
3915 * limitations under the License.
3916 */class Mo{constructor(e,t,s,i,r){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=s,this.documentUpdates=i,this.resolvedLimboDocuments=r}
3916static createSynthesizedRemoteEventForCurrentChange(e,t,s){const i=new Map;return i.set(e,qi.createSynthesizedTargetChangeForCurrentChange(e,t,s)),new Mo(q.min(),i,new pe(ee),on(),X())}}class qi{constructor(e,t,s,i,r){this.resumeToken=e,this.current=t,this.addedDocuments=s,this.modifiedDocuments=i,this.removedDocuments=r}static createSynthesizedTargetChangeForCurrentChange(e,t,s){return new qi(s,t,X(),X(),X())}}/**
3917 * @license
3918 * Copyright 2017 Google LLC
3919 *
3920 * Licensed under the Apache License, Version 2.0 (the "License");
3921 * you may not use this file except in compliance with the License.
3922 * You may obtain a copy of the License at
3923 *
3924 *   http://www.apache.org/licenses/LICENSE-2.0
3925 *
3926 * Unless required by applicable law or agreed to in writing, software
3927 * distributed under the License is distributed on an "AS IS" BASIS,
3928 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3929 * See the License for the specific language governing permissions and
3930 * limitations under the License.
3931 */class Pr{constructor(e,t,s,i){this.Re=e,this.removedTargetIds=t,this.key=s,this.Ve=i}}class bg{constructor(e,t){this.targetId=e,this.me=t}}class Pg{constructor(e,t,s=Pe.EMPTY_BYTE_STRING,i=null){this.state=e,this.targetIds=t,this.resumeToken=s,this.cause=i}}
3931class Nd{constructor(){this.fe=0,this.ge=Od(),this.pe=Pe.EMPTY_BYTE_STRING,this.ye=!1,this.we=!0}get current(){return this.ye}get resumeToken(){return this.pe}get Se(){return this.fe!==0}get be(){return this.we}De(e){e.approximateByteSize()>0&&(this.we=!0,this.pe=e)}ve(){let e=X(),t=X(),s=X();return this.ge.forEach((i,r)=>{switch(r){case 0:e=e.add(i);break;case 2:t=t.add(i);break;case 1:s=s.add(i);break;default:j()}}),new qi(this.pe,this.ye,e,t,s)}Ce(){this.we=!1,this.ge=Od()}Fe(e,t){this.we=!0,this.ge=this.ge.insert(e,t)}Me(e){this.we=!0,this.ge=this.ge.remove(e)}xe(){this.fe+=1}Oe(){this.fe-=1,he(this.fe>=0)}Ne(){this.we=!0,this.ye=!0}}class vS{constructor(e){this.Le=e,this.Be=new Map,this.ke=on(),this.qe=Dd(),this.Qe=new pe(ee)}Ke(e){for(const t of e.Re)e.Ve&&e.Ve.isFoundDocument()?this.$e(t,e.Ve):this.Ue(t,e.key,e.Ve);for(const t of e.removedTargetIds)this.Ue(t,e.key,e.Ve)}We(e){this.forEachTarget(e,t=>{const s=this.Ge(t);switch(e.state){case 0:this.ze(t)&&s.De(e.resumeToken);break;case 1:s.Oe(),s.Se||s.Ce(),s.De(e.resumeToken);break;case 2:s.Oe(),s.Se||this.removeTarget(t);break;case 3:this.ze(t)&&(s.Ne(),s.De(e.resumeToken));break;case 4:this.ze(t)&&(this.je(t),s.De(e.resumeToken));break;default:j()}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.Be.forEach((s,i)=>{this.ze(i)&&t(i)})}He(e){const t=e.targetId,s=e.me.count,i=this.Je(t);if(i){const r=i.target;if(ll(r))if(s===0){const o=new F(r.path);this.Ue(t,o,Ve.newNoDocument(o,q.min()))}else he(s===1);else{const o=this.Ye(t);if(o!==s){const l=this.Ze(e),c=l?this.Xe(l,e,o):1;if(c!==0){this.je(t);const h=c===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Qe=this.Qe.insert(t,h)}}}}}Ze(e){const t=e.me.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:s="",padding:i=0},hashCount:r=0}=t;let o,l;try{o=Pn(s).toUint8Array()}catch(c){if(c instanceof hg)return us("Decoding the base64 bloom filter in existence filter failed ("+c.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw c}try{l=new Sc(o,i,r)}catch(c){return us(c instanceof Js?"BloomFilter error: ":"Applying bloom filter failed: ",c),null}return l.Ie===0?null:l}Xe(e,t,s){return t.me.count===s-this.nt(e,t.targetId)?0:2}nt(e,t){const s=this.Le.getRemoteKeysForTarget(t);let i=0;return s.forEach(r=>{const o=this.Le.tt(),l=`projects/${o.projectId}/databases/${o.database}/documents/${r.path.canonicalString()}`;e.mightContain(l)||(this.Ue(t,r,null),i++)}),i}rt(e){const t=new Map;this.Be.forEach((r,o)=>{const l=this.Je(o);if(l){if(r.current&&ll(l.target)){const c=new F(l.target.path);this.ke.get(c)!==null||this.it(o,c)||this.Ue(o,c,Ve.newNoDocument(c,e))}r.be&&(t.set(o,r.ve()),r.Ce())}});let s=X();this.qe.forEach((r,o)=>{let l=!0;o.forEachWhile(c=>{const h=this.Je(c);return!h||h.purpose==="TargetPurposeLimboResolution"||(l=!1,!1)}),l&&(s=s.add(r))}),this.ke.forEach((r,o)=>o.setReadTime(e));const i=new Mo(e,t,this.Qe,this.ke,s);return this.ke=on(),this.qe=Dd(),this.Qe=new pe(ee),i}$e(e,t){if(!this.ze(e))return;const s=this.it(e,t.key)?2:0;this.Ge(e).Fe(t.key,s),this.ke=this.ke.insert(t.key,t),this.qe=this.qe.insert(t.key,this.st(t.key).add(e))}Ue(e,t,s){if(!this.ze(e))return;const i=this.Ge(e);this.it(e,t)?i.Fe(t,1):i.Me(t),this.qe=this.qe.insert(t,this.st(t).delete(e)),s&&(this.ke=this.ke.insert(t,s))}removeTarget(e){this.Be.delete(e)}Ye(e){const t=this.Ge(e).ve();return this.Le.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}xe(e){this.Ge(e).xe()}Ge(e){let t=this.Be.get(e);return t||(t=new Nd,this.Be.set(e,t)),t}st(e){let t=this.qe.get(e);return t||(t=new be(ee),this.qe=this.qe.insert(e,t)),t}ze(e){const t=this.Je(e)!==null;return t||x("WatchChangeAggregator","Detected inactive target",e),t}Je(e){const t=this.Be.get(e);return t&&t.Se?null:this.Le.ot(e)}je(e){this.Be.set(e,new Nd),this.Le.getRemoteKeysForTarget(e).forEach(t=>{this.Ue(e,t,null)})}it(e,t){return this.Le.getRemoteKeysForTarget(e).has(t)}}function Dd(){return new pe(F.comparator)}function Od(){return new pe(F.comparator)}const ES={asc:"ASCENDING",desc:"DESCENDING"},TS={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},IS={and:"AND",or:"OR"};class wS{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function dl(n,e){return n.useProto3Json||So(e)?e:{value:e}}function CS(n,e){return n.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function AS(n,e){return n.useProto3Json?e.toBase64():e.toUint8Array()}function Zn(n){return he(!!n),q.fromTimestamp(function(t){const s=rn(t);return new ze(s.seconds,s.nanos)}(n))}function RS(n,e){return fl(n,e).canonicalString()}function fl(n,e){const t=function(i){return new ge(["projects",i.projectId,"databases",i.database])}(n).child("documents");return e===void 0?t:t.child(e)}function kg(n){const e=ge.fromString(n);return he(Mg(e)),e}function Ra(n,e){const t=kg(e);if(t.get(1)!==n.databaseId.projectId)throw new M(O.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+n.databaseId.projectId);if(t.get(3)!==n.databaseId.database)throw new M(O.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+n.databaseId.database);return new F(Dg(t))}function Ng(n,e){return RS(n.databaseId,e)}function SS(n){const e=kg(n);return e.length===4?ge.emptyPath():Dg(e)}function xd(n){return new ge(["projects",n.databaseId.projectId,"databases",n.databaseId.database]).canonicalString()}function Dg(n){return he(n.length>4&&n.get(4)==="documents"),n.popFirst(5)}function bS(n,e){let t;if("targetChange"in e){e.targetChange;const s=function(h){return h==="NO_CHANGE"?0:h==="ADD"?1:h==="REMOVE"?2:h==="CURRENT"?3:h==="RESET"?4:j()}(e.targetChange.targetChangeType||"NO_CHANGE"),i=e.targetChange.targetIds||[],r=function(h,f){return h.useProto3Json?(he(f===void 0||typeof f=="string"),Pe.fromBase64String(f||"")):(he(f===void 0||f instanceof Buffer||f instanceof Uint8Array),Pe.fromUint8Array(f||new Uint8Array))}(n,e.targetChange.resumeToken),o=e.targetChange.cause,l=o&&function(h){const f=h.code===void 0?O.UNKNOWN:Sg(h.code);return new M(f,h.message||"")}(o);t=new Pg(s,i,r,l||null)}else if("documentChange"in e){e.documentChange;const s=e.documentChange;s.document,s.document.name,s.document.updateTime;const i=Ra(n,s.document.name),r=Zn(s.document.updateTime),o=s.document.createTime?Zn(s.document.createTime):q.min(),l=new at({mapValue:{fields:s.document.fields}}),c=Ve.newFoundDocument(i,r,o,l),h=s.targetIds||[],f=s.removedTargetIds||[];t=new Pr(h,f,c.key,c)}else if("documentDelete"in e){e.documentDelete;const s=e.documentDelete;s.document;const i=Ra(n,s.document),r=s.readTime?Zn(s.readTime):q.min(),o=Ve.newNoDocument(i,r),l=s.removedTargetIds||[];t=new Pr([],l,o.key,o)}else if("documentRemove"in e){e.documentRemove;const s=e.documentRemove;s.document;const i=Ra(n,s.document),r=s.removedTargetIds||[];t=new Pr([],r,i,null)}else{if(!("filter"in e))return j();{e.filter;const s=e.filter;s.targetId;const{count:i=0,unchangedNames:r}=s,o=new gS(i,r),l=s.targetId;t=new bg(l,o)}}return t}function PS(n,e){return{documents:[Ng(n,e.path)]}}function kS(n,e){const t={structuredQuery:{}},s=e.path;let i;e.collectionGroup!==null?(i=s,t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(i=s.popLast(),t.structuredQuery.from=[{collectionId:s.lastSegment()}]),t.parent=Ng(n,i);const r=function(h){if(h.length!==0)return xg(_t.create(h,"and"))}(e.filters);r&&(t.structuredQuery.where=r);const o=function(h){if(h.length!==0)return h.map(f=>function(g){return{field:$n(g.field),direction:OS(g.dir)}}(f))}(e.orderBy);o&&(t.structuredQuery.orderBy=o);const l=dl(n,e.limit);return l!==null&&(t.structuredQuery.limit=l),e.startAt&&(t.structuredQuery.startAt=function(h){return{before:h.inclusive,values:h.position}}(e.startAt)),e.endAt&&(t.structuredQuery.endAt=function(h){return{before:!h.inclusive,values:h.position}}(e.endAt)),{_t:t,parent:i}}function NS(n){let e=SS(n.parent);const t=n.structuredQuery,s=t.from?t.from.length:0;let i=null;if(s>0){he(s===1);const f=t.from[0];f.allDescendants?i=f.collectionId:e=e.child(f.collectionId)}let r=[];t.where&&(r=function(p){const g=Og(p);return g instanceof _t&&pg(g)?g.getFilters():[g]}(t.where));let o=[];t.orderBy&&(o=function(p){return p.map(g=>function(S){return new to(jn(S.field),function(b){switch(b){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(S.direction))}(g))}(t.orderBy));let l=null;t.limit&&(l=function(p){let g;return g=typeof p=="object"?p.value:p,So(g)?null:g}(t.limit));let c=null;t.startAt&&(c=function(p){const g=!!p.before,I=p.values||[];return new eo(I,g)}(t.startAt));let h=null;return t.endAt&&(h=function(p){const g=!p.before,I=p.values||[];return new eo(I,g)}(t.endAt)),YR(e,i,o,r,l,"F",c,h)}function DS(n,e){const t=function(i){switch(i){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return j()}}(e.purpose);return t==null?null:{"goog-listen-tags":t}}function Og(n){return n.unaryFilter!==void 0?function(t){switch(t.unaryFilter.op){case"IS_NAN":const s=jn(t.unaryFilter.field);return Ee.create(s,"==",{doubleValue:NaN});case"IS_NULL":const i=jn(t.unaryFilter.field);return Ee.create(i,"==",{nullValue:"NULL_VALUE"});
3931case"IS_NOT_NAN":const r=jn(t.unaryFilter.field);return Ee.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const o=jn(t.unaryFilter.field);return Ee.create(o,"!=",{nullValue:"NULL_VALUE"});default:return j()}}(n):n.fieldFilter!==void 0?function(t){return Ee.create(jn(t.fieldFilter.field),function(i){switch(i){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return j()}}(t.fieldFilter.op),t.fieldFilter.value)}(n):n.compositeFilter!==void 0?function(t){return _t.create(t.compositeFilter.filters.map(s=>Og(s)),function(i){switch(i){case"AND":return"and";case"OR":return"or";default:return j()}}(t.compositeFilter.op))}(n):j()}function OS(n){return ES[n]}function xS(n){return TS[n]}function MS(n){return IS[n]}function $n(n){return{fieldPath:n.canonicalString()}}function jn(n){return $e.fromServerFormat(n.fieldPath)}function xg(n){return n instanceof Ee?function(t){if(t.op==="=="){if(Ed(t.value))return{unaryFilter:{field:$n(t.field),op:"IS_NAN"}};if(vd(t.value))return{unaryFilter:{field:$n(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(Ed(t.value))return{unaryFilter:{field:$n(t.field),op:"IS_NOT_NAN"}};if(vd(t.value))return{unaryFilter:{field:$n(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:$n(t.field),op:xS(t.op),value:t.value}}}(n):n instanceof _t?function(t){const s=t.getFilters().map(i=>xg(i));return s.length===1?s[0]:{compositeFilter:{op:MS(t.op),filters:s}}}(n):j()}function Mg(n){return n.length>=4&&n.get(0)==="projects"&&n.get(2)==="databases"}/**
3932 * @license
3933 * Copyright 2017 Google LLC
3934 *
3935 * Licensed under the Apache License, Version 2.0 (the "License");
3936 * you may not use this file except in compliance with the License.
3937 * You may obtain a copy of the License at
3938 *
3939 *   http://www.apache.org/licenses/LICENSE-2.0
3940 *
3941 * Unless required by applicable law or agreed to in writing, software
3942 * distributed under the License is distributed on an "AS IS" BASIS,
3943 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3944 * See the License for the specific language governing permissions and
3945 * limitations under the License.
3946 */class zt{constructor(e,t,s,i,r=q.min(),o=q.min(),l=Pe.EMPTY_BYTE_STRING,c=null){this.target=e,this.targetId=t,this.purpose=s,this.sequenceNumber=i,this.snapshotVersion=r,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=l,this.expectedCount=c}withSequenceNumber(e){return new zt(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new zt(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new zt(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new zt(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}/**
3947 * @license
3948 * Copyright 2017 Google LLC
3949 *
3950 * Licensed under the Apache License, Version 2.0 (the "License");
3951 * you may not use this file except in compliance with the License.
3952 * You may obtain a copy of the License at
3953 *
3954 *   http://www.apache.org/licenses/LICENSE-2.0
3955 *
3956 * Unless required by applicable law or agreed to in writing, software
3957 * distributed under the License is distributed on an "AS IS" BASIS,
3958 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3959 * See the License for the specific language governing permissions and
3960 * limitations under the License.
3961 */class LS{constructor(e){this.ct=e}}function VS(n){const e=NS({parent:n.parent,structuredQuery:n.structuredQuery});return n.limitType==="LAST"?cl(e,e.limit,"L"):e}/**
3962 * @license
3963 * Copyright 2019 Google LLC
3964 *
3965 * Licensed under the Apache License, Version 2.0 (the "License");
3966 * you may not use this file except in compliance with the License.
3967 * You may obtain a copy of the License at
3968 *
3969 *   http://www.apache.org/licenses/LICENSE-2.0
3970 *
3971 * Unless required by applicable law or agreed to in writing, software
3972 * distributed under the License is distributed on an "AS IS" BASIS,
3973 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3974 * See the License for the specific language governing permissions and
3975 * limitations under the License.
3976 */class FS{constructor(){this.un=new US}addToCollectionParentIndex(e,t){return this.un.add(t),P.resolve()}getCollectionParents(e,t){return P.resolve(this.un.getEntries(t))}addFieldIndex(e,t){return P.resolve()}deleteFieldIndex(e,t){return P.resolve()}deleteAllFieldIndexes(e){return P.resolve()}createTargetIndexes(e,t){return P.resolve()}getDocumentsMatchingTarget(e,t){return P.resolve(null)}getIndexType(e,t){return P.resolve(0)}getFieldIndexes(e,t){return P.resolve([])}getNextCollectionGroupToUpdate(e){return P.resolve(null)}getMinOffset(e,t){return P.resolve(sn.min())}getMinOffsetFromCollectionGroup(e,t){return P.resolve(sn.min())}updateCollectionGroup(e,t,s){return P.resolve()}updateIndexEntries(e,t){return P.resolve()}}class US{constructor(){this.index={}}add(e){const t=e.lastSegment(),s=e.popLast(),i=this.index[t]||new be(ge.comparator),r=!i.has(s);return this.index[t]=i.add(s),r}has(e){const t=e.lastSegment(),s=e.popLast(),i=this.index[t];return i&&i.has(s)}getEntries(e){return(this.index[e]||new be(ge.comparator)).toArray()}}/**
3977 * @license
3978 * Copyright 2017 Google LLC
3979 *
3980 * Licensed under the Apache License, Version 2.0 (the "License");
3981 * you may not use this file except in compliance with the License.
3982 * You may obtain a copy of the License at
3983 *
3984 *   http://www.apache.org/licenses/LICENSE-2.0
3985 *
3986 * Unless required by applicable law or agreed to in writing, software
3987 * distributed under the License is distributed on an "AS IS" BASIS,
3988 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3989 * See the License for the specific language governing permissions and
3990 * limitations under the License.
3991 */class ps{constructor(e){this.Ln=e}next(){return this.Ln+=2,this.Ln}static Bn(){return new ps(0)}static kn(){return new ps(-1)}}/**
3992 * @license
3993 * Copyright 2017 Google LLC
3994 *
3995 * Licensed under the Apache License, Version 2.0 (the "License");
3996 * you may not use this file except in compliance with the License.
3997 * You may obtain a copy of the License at
3998 *
3999 *   http://www.apache.org/licenses/LICENSE-2.0
4000 *
4001 * Unless required by applicable law or agreed to in writing, software
4002 * distributed under the License is distributed on an "AS IS" BASIS,
4003 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4004 * See the License for the specific language governing permissions and
4005 * limitations under the License.
4006 */class BS{constructor(){this.changes=new ws(e=>e.toString(),(e,t)=>e.isEqual(t)),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,Ve.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const s=this.changes.get(t);return s!==void 0?P.resolve(s):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}/**
4007 * @license
4008 * Copyright 2017 Google LLC
4009 *
4010 * Licensed under the Apache License, Version 2.0 (the "License");
4011 * you may not use this file except in compliance with the License.
4012 * You may obtain a copy of the License at
4013 *
4014 *   http://www.apache.org/licenses/LICENSE-2.0
4015 *
4016 * Unless required by applicable law or agreed to in writing, software
4017 * distributed under the License is distributed on an "AS IS" BASIS,
4018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4019 * See the License for the specific language governing permissions and
4020 * limitations under the License.
4021 *//**
4022 * @license
4023 * Copyright 2022 Google LLC
4024 *
4025 * Licensed under the Apache License, Version 2.0 (the "License");
4026 * you may not use this file except in compliance with the License.
4027 * You may obtain a copy of the License at
4028 *
4029 *   http://www.apache.org/licenses/LICENSE-2.0
4030 *
4031 * Unless required by applicable law or agreed to in writing, software
4032 * distributed under the License is distributed on an "AS IS" BASIS,
4033 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4034 * See the License for the specific language governing permissions and
4035 * limitations under the License.
4036 */class qS{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}/**
4037 * @license
4038 * Copyright 2017 Google LLC
4039 *
4040 * Licensed under the Apache License, Version 2.0 (the "License");
4041 * you may not use this file except in compliance with the License.
4042 * You may obtain a copy of the License at
4043 *
4044 *   http://www.apache.org/licenses/LICENSE-2.0
4045 *
4046 * Unless required by applicable law or agreed to in writing, software
4047 * distributed under the License is distributed on an "AS IS" BASIS,
4048 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4049 * See the License for the specific language governing permissions and
4050 * limitations under the License.
4051 */class $S{constructor(e,t,s,i){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=s,this.indexManager=i}getDocument(e,t){let s=null;return this.documentOverlayCache.getOverlay(e,t).next(i=>(s=i,this.remoteDocumentCache.getEntry(e,t))).next(i=>(s!==null&&ci(s.mutation,i,Wt.empty(),ze.now()),i))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(s=>this.getLocalViewOfDocuments(e,s,X()).next(()=>s))}getLocalViewOfDocuments(e,t,s=X()){const i=yn();return this.populateOverlays(e,i,t).next(()=>this.computeViews(e,t,i,s).next(r=>{let o=Xs();return r.forEach((l,c)=>{o=o.insert(l,c.overlayedDocument)}),o}))}getOverlayedDocuments(e,t){const s=yn();return this.populateOverlays(e,s,t).next(()=>this.computeViews(e,t,s,X()))}populateOverlays(e,t,s){const i=[];return s.forEach(r=>{t.has(r)||i.push(r)}),this.documentOverlayCache.getOverlays(e,i).next(r=>{r.forEach((o,l)=>{t.set(o,l)})})}computeViews(e,t,s,i){let r=on();const o=li(),l=function(){return li()}();return t.forEach((c,h)=>{const f=s.get(h.key);i.has(h.key)&&(f===void 0||f.mutation instanceof xo)?r=r.insert(h.key,h):f!==void 0?(o.set(h.key,f.mutation.getFieldMask()),ci(f.mutation,h,f.mutation.getFieldMask(),ze.now())):o.set(h.key,Wt.empty())}),this.recalculateAndSaveOverlays(e,r).next(c=>(c.forEach((h,f)=>o.set(h,f)),t.forEach((h,f)=>{var p;return l.set(h,new qS(f,(p=o.get(h))!==null&&p!==void 0?p:null))}),l))}recalculateAndSaveOverlays(e,t){const s=li();let i=new pe((o,l)=>o-l),r=X();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(o=>{for(const l of o)l.keys().forEach(c=>{const h=t.get(c);if(h===null)return;let f=s.get(c)||Wt.empty();f=l.applyToLocalView(h,f),s.set(c,f);const p=(i.get(l.batchId)||X()).add(c);i=i.insert(l.batchId,p)})}).next(()=>{const o=[],l=i.getReverseIterator();for(;l.hasNext();){const c=l.getNext(),h=c.key,f=c.value,p=Tg();f.forEach(g=>{if(!r.has(g)){const I=Ag(t.get(g),s.get(g));I!==null&&p.set(g,I),r=r.add(g)}}),o.push(this.documentOverlayCache.saveOverlays(e,h,p))}return P.waitFor(o)}).next(()=>s)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(s=>this.recalculateAndSaveOverlays(e,s))}getDocumentsMatchingQuery(e,t,s,i){return function(o){return F.isDocumentKey(o.path)&&o.collectionGroup===null&&o.filters.length===0}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):XR(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,s,i):this.getDocumentsMatchingCollectionQuery(e,t,s,i)}getNextDocuments(e,t,s,i){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,s,i).next(r=>{const o=i-r.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,s.largestBatchId,i-r.size):P.resolve(yn());let l=-1,c=r;return o.next(h=>P.forEach(h,(f,p)=>(l<p.largestBatchId&&(l=p.largestBatchId),r.get(f)?P.resolve():this.remoteDocumentCache.getEntry(e,f).next(g=>{c=c.insert(f,g)}))).next(()=>this.populateOverlays(e,h,r)).next(()=>this.computeViews(e,c,h,X())).next(f=>({batchId:l,changes:nS(f)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new F(t)).next(s=>{let i=Xs();
4051return s.isFoundDocument()&&(i=i.insert(s.key,s)),i})}getDocumentsMatchingCollectionGroupQuery(e,t,s,i){const r=t.collectionGroup;let o=Xs();return this.indexManager.getCollectionParents(e,r).next(l=>P.forEach(l,c=>{const h=function(p,g){return new Po(g,null,p.explicitOrderBy.slice(),p.filters.slice(),p.limit,p.limitType,p.startAt,p.endAt)}(t,c.child(r));return this.getDocumentsMatchingCollectionQuery(e,h,s,i).next(f=>{f.forEach((p,g)=>{o=o.insert(p,g)})})}).next(()=>o))}getDocumentsMatchingCollectionQuery(e,t,s,i){let r;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,s.largestBatchId).next(o=>(r=o,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,s,r,i))).next(o=>{r.forEach((c,h)=>{const f=h.getKey();o.get(f)===null&&(o=o.insert(f,Ve.newInvalidDocument(f)))});let l=Xs();return o.forEach((c,h)=>{const f=r.get(c);f!==void 0&&ci(f.mutation,h,Wt.empty(),ze.now()),Do(t,h)&&(l=l.insert(c,h))}),l})}}/**
4052 * @license
4053 * Copyright 2020 Google LLC
4054 *
4055 * Licensed under the Apache License, Version 2.0 (the "License");
4056 * you may not use this file except in compliance with the License.
4057 * You may obtain a copy of the License at
4058 *
4059 *   http://www.apache.org/licenses/LICENSE-2.0
4060 *
4061 * Unless required by applicable law or agreed to in writing, software
4062 * distributed under the License is distributed on an "AS IS" BASIS,
4063 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4064 * See the License for the specific language governing permissions and
4065 * limitations under the License.
4066 */class jS{constructor(e){this.serializer=e,this.hr=new Map,this.Pr=new Map}getBundleMetadata(e,t){return P.resolve(this.hr.get(t))}saveBundleMetadata(e,t){return this.hr.set(t.id,function(i){return{id:i.id,version:i.version,createTime:Zn(i.createTime)}}(t)),P.resolve()}getNamedQuery(e,t){return P.resolve(this.Pr.get(t))}saveNamedQuery(e,t){return this.Pr.set(t.name,function(i){return{name:i.name,query:VS(i.bundledQuery),readTime:Zn(i.readTime)}}(t)),P.resolve()}}/**
4067 * @license
4068 * Copyright 2022 Google LLC
4069 *
4070 * Licensed under the Apache License, Version 2.0 (the "License");
4071 * you may not use this file except in compliance with the License.
4072 * You may obtain a copy of the License at
4073 *
4074 *   http://www.apache.org/licenses/LICENSE-2.0
4075 *
4076 * Unless required by applicable law or agreed to in writing, software
4077 * distributed under the License is distributed on an "AS IS" BASIS,
4078 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4079 * See the License for the specific language governing permissions and
4080 * limitations under the License.
4081 */class HS{constructor(){this.overlays=new pe(F.comparator),this.Ir=new Map}getOverlay(e,t){return P.resolve(this.overlays.get(t))}getOverlays(e,t){const s=yn();return P.forEach(t,i=>this.getOverlay(e,i).next(r=>{r!==null&&s.set(i,r)})).next(()=>s)}saveOverlays(e,t,s){return s.forEach((i,r)=>{this.ht(e,t,r)}),P.resolve()}removeOverlaysForBatchId(e,t,s){const i=this.Ir.get(s);return i!==void 0&&(i.forEach(r=>this.overlays=this.overlays.remove(r)),this.Ir.delete(s)),P.resolve()}getOverlaysForCollection(e,t,s){const i=yn(),r=t.length+1,o=new F(t.child("")),l=this.overlays.getIteratorFrom(o);for(;l.hasNext();){const c=l.getNext().value,h=c.getKey();if(!t.isPrefixOf(h.path))break;h.path.length===r&&c.largestBatchId>s&&i.set(c.getKey(),c)}return P.resolve(i)}getOverlaysForCollectionGroup(e,t,s,i){let r=new pe((h,f)=>h-f);const o=this.overlays.getIterator();for(;o.hasNext();){const h=o.getNext().value;if(h.getKey().getCollectionGroup()===t&&h.largestBatchId>s){let f=r.get(h.largestBatchId);f===null&&(f=yn(),r=r.insert(h.largestBatchId,f)),f.set(h.getKey(),h)}}const l=yn(),c=r.getIterator();for(;c.hasNext()&&(c.getNext().value.forEach((h,f)=>l.set(h,f)),!(l.size()>=i)););return P.resolve(l)}ht(e,t,s){const i=this.overlays.get(s.key);if(i!==null){const o=this.Ir.get(i.largestBatchId).delete(s.key);this.Ir.set(i.largestBatchId,o)}this.overlays=this.overlays.insert(s.key,new _S(t,s));let r=this.Ir.get(t);r===void 0&&(r=X(),this.Ir.set(t,r)),this.Ir.set(t,r.add(s.key))}}/**
4082 * @license
4083 * Copyright 2024 Google LLC
4084 *
4085 * Licensed under the Apache License, Version 2.0 (the "License");
4086 * you may not use this file except in compliance with the License.
4087 * You may obtain a copy of the License at
4088 *
4089 *   http://www.apache.org/licenses/LICENSE-2.0
4090 *
4091 * Unless required by applicable law or agreed to in writing, software
4092 * distributed under the License is distributed on an "AS IS" BASIS,
4093 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4094 * See the License for the specific language governing permissions and
4095 * limitations under the License.
4096 */class WS{constructor(){this.sessionToken=Pe.EMPTY_BYTE_STRING}getSessionToken(e){return P.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,P.resolve()}}/**
4097 * @license
4098 * Copyright 2017 Google LLC
4099 *
4100 * Licensed under the Apache License, Version 2.0 (the "License");
4101 * you may not use this file except in compliance with the License.
4102 * You may obtain a copy of the License at
4103 *
4104 *   http://www.apache.org/licenses/LICENSE-2.0
4105 *
4106 * Unless required by applicable law or agreed to in writing, software
4107 * distributed under the License is distributed on an "AS IS" BASIS,
4108 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4109 * See the License for the specific language governing permissions and
4110 * limitations under the License.
4111 */class bc{constructor(){this.Tr=new be(Ie.Er),this.dr=new be(Ie.Ar)}isEmpty(){return this.Tr.isEmpty()}addReference(e,t){const s=new Ie(e,t);this.Tr=this.Tr.add(s),this.dr=this.dr.add(s)}Rr(e,t){e.forEach(s=>this.addReference(s,t))}removeReference(e,t){this.Vr(new Ie(e,t))}mr(e,t){e.forEach(s=>this.removeReference(s,t))}gr(e){const t=new F(new ge([])),s=new Ie(t,e),i=new Ie(t,e+1),r=[];return this.dr.forEachInRange([s,i],o=>{this.Vr(o),r.push(o.key)}),r}pr(){this.Tr.forEach(e=>this.Vr(e))}Vr(e){this.Tr=this.Tr.delete(e),this.dr=this.dr.delete(e)}yr(e){const t=new F(new ge([])),s=new Ie(t,e),i=new Ie(t,e+1);let r=X();return this.dr.forEachInRange([s,i],o=>{r=r.add(o.key)}),r}containsKey(e){const t=new Ie(e,0),s=this.Tr.firstAfterOrEqual(t);return s!==null&&e.isEqual(s.key)}}class Ie{constructor(e,t){this.key=e,this.wr=t}static Er(e,t){return F.comparator(e.key,t.key)||ee(e.wr,t.wr)}static Ar(e,t){return ee(e.wr,t.wr)||F.comparator(e.key,t.key)}}/**
4112 * @license
4113 * Copyright 2017 Google LLC
4114 *
4115 * Licensed under the Apache License, Version 2.0 (the "License");
4116 * you may not use this file except in compliance with the License.
4117 * You may obtain a copy of the License at
4118 *
4119 *   http://www.apache.org/licenses/LICENSE-2.0
4120 *
4121 * Unless required by applicable law or agreed to in writing, software
4122 * distributed under the License is distributed on an "AS IS" BASIS,
4123 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4124 * See the License for the specific language governing permissions and
4125 * limitations under the License.
4126 */class zS{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Sr=1,this.br=new be(Ie.Er)}checkEmpty(e){return P.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,s,i){const r=this.Sr;this.Sr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const o=new pS(r,t,s,i);this.mutationQueue.push(o);for(const l of i)this.br=this.br.add(new Ie(l.key,r)),this.indexManager.addToCollectionParentIndex(e,l.key.path.popLast());return P.resolve(o)}lookupMutationBatch(e,t){return P.resolve(this.Dr(t))}getNextMutationBatchAfterBatchId(e,t){const s=t+1,i=this.vr(s),r=i<0?0:i;return P.resolve(this.mutationQueue.length>r?this.mutationQueue[r]:null)}getHighestUnacknowledgedBatchId(){return P.resolve(this.mutationQueue.length===0?-1:this.Sr-1)}getAllMutationBatches(e){return P.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const s=new Ie(t,0),i=new Ie(t,Number.POSITIVE_INFINITY),r=[];return this.br.forEachInRange([s,i],o=>{const l=this.Dr(o.wr);r.push(l)}),P.resolve(r)}getAllMutationBatchesAffectingDocumentKeys(e,t){let s=new be(ee);return t.forEach(i=>{const r=new Ie(i,0),o=new Ie(i,Number.POSITIVE_INFINITY);this.br.forEachInRange([r,o],l=>{s=s.add(l.wr)})}),P.resolve(this.Cr(s))}getAllMutationBatchesAffectingQuery(e,t){const s=t.path,i=s.length+1;let r=s;F.isDocumentKey(r)||(r=r.child(""));const o=new Ie(new F(r),0);let l=new be(ee);return this.br.forEachWhile(c=>{const h=c.key.path;return!!s.isPrefixOf(h)&&(h.length===i&&(l=l.add(c.wr)),!0)},o),P.resolve(this.Cr(l))}Cr(e){const t=[];return e.forEach(s=>{const i=this.Dr(s);i!==null&&t.push(i)}),t}removeMutationBatch(e,t){he(this.Fr(t.batchId,"removed")===0),this.mutation
4126Queue.shift();let s=this.br;return P.forEach(t.mutations,i=>{const r=new Ie(i.key,t.batchId);return s=s.delete(r),this.referenceDelegate.markPotentiallyOrphaned(e,i.key)}).next(()=>{this.br=s})}On(e){}containsKey(e,t){const s=new Ie(t,0),i=this.br.firstAfterOrEqual(s);return P.resolve(t.isEqual(i&&i.key))}performConsistencyCheck(e){return this.mutationQueue.length,P.resolve()}Fr(e,t){return this.vr(e)}vr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Dr(e){const t=this.vr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}/**
4127 * @license
4128 * Copyright 2017 Google LLC
4129 *
4130 * Licensed under the Apache License, Version 2.0 (the "License");
4131 * you may not use this file except in compliance with the License.
4132 * You may obtain a copy of the License at
4133 *
4134 *   http://www.apache.org/licenses/LICENSE-2.0
4135 *
4136 * Unless required by applicable law or agreed to in writing, software
4137 * distributed under the License is distributed on an "AS IS" BASIS,
4138 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4139 * See the License for the specific language governing permissions and
4140 * limitations under the License.
4141 */class GS{constructor(e){this.Mr=e,this.docs=function(){return new pe(F.comparator)}(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const s=t.key,i=this.docs.get(s),r=i?i.size:0,o=this.Mr(t);return this.docs=this.docs.insert(s,{document:t.mutableCopy(),size:o}),this.size+=o-r,this.indexManager.addToCollectionParentIndex(e,s.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const s=this.docs.get(t);return P.resolve(s?s.document.mutableCopy():Ve.newInvalidDocument(t))}getEntries(e,t){let s=on();return t.forEach(i=>{const r=this.docs.get(i);s=s.insert(i,r?r.document.mutableCopy():Ve.newInvalidDocument(i))}),P.resolve(s)}getDocumentsMatchingQuery(e,t,s,i){let r=on();const o=t.path,l=new F(o.child("")),c=this.docs.getIteratorFrom(l);for(;c.hasNext();){const{key:h,value:{document:f}}=c.getNext();if(!o.isPrefixOf(h.path))break;h.path.length>o.length+1||NR(kR(f),s)<=0||(i.has(f.key)||Do(t,f))&&(r=r.insert(f.key,f.mutableCopy()))}return P.resolve(r)}getAllFromCollectionGroup(e,t,s,i){j()}Or(e,t){return P.forEach(this.docs,s=>t(s))}newChangeBuffer(e){return new KS(this)}getSize(e){return P.resolve(this.size)}}class KS extends BS{constructor(e){super(),this.cr=e}applyChanges(e){const t=[];
4141return this.changes.forEach((s,i)=>{i.isValidDocument()?t.push(this.cr.addEntry(e,i)):this.cr.removeEntry(s)}),P.waitFor(t)}getFromCache(e,t){return this.cr.getEntry(e,t)}getAllFromCache(e,t){return this.cr.getEntries(e,t)}}/**
4142 * @license
4143 * Copyright 2017 Google LLC
4144 *
4145 * Licensed under the Apache License, Version 2.0 (the "License");
4146 * you may not use this file except in compliance with the License.
4147 * You may obtain a copy of the License at
4148 *
4149 *   http://www.apache.org/licenses/LICENSE-2.0
4150 *
4151 * Unless required by applicable law or agreed to in writing, software
4152 * distributed under the License is distributed on an "AS IS" BASIS,
4153 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4154 * See the License for the specific language governing permissions and
4155 * limitations under the License.
4156 */class QS{constructor(e){this.persistence=e,this.Nr=new ws(t=>wc(t),Cc),this.lastRemoteSnapshotVersion=q.min(),this.highestTargetId=0,this.Lr=0,this.Br=new bc,this.targetCount=0,this.kr=ps.Bn()}forEachTarget(e,t){return this.Nr.forEach((s,i)=>t(i)),P.resolve()}getLastRemoteSnapshotVersion(e){return P.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return P.resolve(this.Lr)}allocateTargetId(e){return this.highestTargetId=this.kr.next(),P.resolve(this.highestTargetId)}setTargetsMetadata(e,t,s){return s&&(this.lastRemoteSnapshotVersion=s),t>this.Lr&&(this.Lr=t),P.resolve()}Kn(e){this.Nr.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this.kr=new ps(t),this.highestTargetId=t),e.sequenceNumber>this.Lr&&(this.Lr=e.sequenceNumber)}addTargetData(e,t){return this.Kn(t),this.targetCount+=1,P.resolve()}updateTargetData(e,t){return this.Kn(t),P.resolve()}removeTargetData(e,t){return this.Nr.delete(t.target),this.Br.gr(t.targetId),this.targetCount-=1,P.resolve()}removeTargets(e,t,s){let i=0;const r=[];return this.Nr.forEach((o,l)=>{l.sequenceNumber<=t&&s.get(l.targetId)===null&&(this.Nr.delete(o),r.push(this.removeMatchingKeysForTargetId(e,l.targetId)),i++)}),P.waitFor(r).next(()=>i)}getTargetCount(e){return P.resolve(this.targetCount)}getTargetData(e,t){const s=this.Nr.get(t)||null;return P.resolve(s)}addMatchingKeys(e,t,s){return this.Br.Rr(t,s),P.resolve()}removeMatchingKeys(e,t,s){this.Br.mr(t,s);const i=this.persistence.referenceDelegate,r=[];return i&&t.forEach(o=>{r.push(i.markPotentiallyOrphaned(e,o))}),P.waitFor(r)}removeMatchingKeysForTargetId(e,t){return this.Br.gr(t),P.resolve()}getMatchingKeysForTargetId(e,t){const s=this.Br.yr(t);return P.resolve(s)}containsKey(e,t){return P.resolve(this.Br.containsKey(t))}}/**
4157 * @license
4158 * Copyright 2017 Google LLC
4159 *
4160 * Licensed under the Apache License, Version 2.0 (the "License");
4161 * you may not use this file except in compliance with the License.
4162 * You may obtain a copy of the License at
4163 *
4164 *   http://www.apache.org/licenses/LICENSE-2.0
4165 *
4166 * Unless required by applicable law or agreed to in writing, software
4167 * distributed under the License is distributed on an "AS IS" BASIS,
4168 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4169 * See the License for the specific language governing permissions and
4170 * limitations under the License.
4171 */class YS{constructor(e,t){this.qr={},this.overlays={},this.Qr=new vc(0),this.Kr=!1,this.Kr=!0,this.$r=new WS,this.referenceDelegate=e(this),this.Ur=new QS(this),this.indexManager=new FS,this.remoteDocumentCache=function(i){return new GS(i)}(s=>this.referenceDelegate.Wr(s)),this.serializer=new LS(t),this.Gr=new jS(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.Kr=!1,Promise.resolve()}get started(){return this.Kr}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new HS,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let s=this.qr[e.toKey()];return s||(s=new zS(t,this.referenceDelegate),this.qr[e.toKey()]=s),s}getGlobalsCache(){return this.$r}getTargetCache(){return this.Ur}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Gr}runTransaction(e,t,s){x("MemoryPersistence","Starting transaction:",e);const i=new XS(this.Qr.next());return this.referenceDelegate.zr(),s(i).next(r=>this.referenceDelegate.jr(i).next(()=>r)).toPromise().then(r=>(i.raiseOnCommittedEvent(),r))}
4171Hr(e,t){return P.or(Object.values(this.qr).map(s=>()=>s.containsKey(e,t)))}}class XS extends OR{constructor(e){super(),this.currentSequenceNumber=e}}class Pc{constructor(e){this.persistence=e,this.Jr=new bc,this.Yr=null}static Zr(e){return new Pc(e)}get Xr(){if(this.Yr)return this.Yr;throw j()}addReference(e,t,s){return this.Jr.addReference(s,t),this.Xr.delete(s.toString()),P.resolve()}removeReference(e,t,s){return this.Jr.removeReference(s,t),this.Xr.add(s.toString()),P.resolve()}markPotentiallyOrphaned(e,t){return this.Xr.add(t.toString()),P.resolve()}removeTarget(e,t){this.Jr.gr(t.targetId).forEach(i=>this.Xr.add(i.toString()));const s=this.persistence.getTargetCache();return s.getMatchingKeysForTargetId(e,t.targetId).next(i=>{i.forEach(r=>this.Xr.add(r.toString()))}).next(()=>s.removeTargetData(e,t))}zr(){this.Yr=new Set}jr(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return P.forEach(this.Xr,s=>{const i=F.fromPath(s);return this.ei(e,i).next(r=>{r||t.removeEntry(i,q.min())})}).next(()=>(this.Yr=null,t.apply(e)))}updateLimboDocument(e,t){return this.ei(e,t).next(s=>{s?this.Xr.delete(t.toString()):this.Xr.add(t.toString())})}Wr(e){return 0}ei(e,t){return P.or([()=>P.resolve(this.Jr.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Hr(e,t)])}}/**
4172 * @license
4173 * Copyright 2017 Google LLC
4174 *
4175 * Licensed under the Apache License, Version 2.0 (the "License");
4176 * you may not use this file except in compliance with the License.
4177 * You may obtain a copy of the License at
4178 *
4179 *   http://www.apache.org/licenses/LICENSE-2.0
4180 *
4181 * Unless required by applicable law or agreed to in writing, software
4182 * distributed under the License is distributed on an "AS IS" BASIS,
4183 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4184 * See the License for the specific language governing permissions and
4185 * limitations under the License.
4186 */class kc{constructor(e,t,s,i){this.targetId=e,this.fromCache=t,this.$i=s,this.Ui=i}static Wi(e,t){let s=X(),i=X();for(const r of t.docChanges)switch(r.type){case 0:s=s.add(r.doc.key);break;case 1:i=i.add(r.doc.key)}return new kc(e,t.fromCache,s,i)}}/**
4187 * @license
4188 * Copyright 2023 Google LLC
4189 *
4190 * Licensed under the Apache License, Version 2.0 (the "License");
4191 * you may not use this file except in compliance with the License.
4192 * You may obtain a copy of the License at
4193 *
4194 *   http://www.apache.org/licenses/LICENSE-2.0
4195 *
4196 * Unless required by applicable law or agreed to in writing, software
4197 * distributed under the License is distributed on an "AS IS" BASIS,
4198 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4199 * See the License for the specific language governing permissions and
4200 * limitations under the License.
4201 */class JS{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}/**
4202 * @license
4203 * Copyright 2019 Google LLC
4204 *
4205 * Licensed under the Apache License, Version 2.0 (the "License");
4206 * you may not use this file except in compliance with the License.
4207 * You may obtain a copy of the License at
4208 *
4209 *   http://www.apache.org/licenses/LICENSE-2.0
4210 *
4211 * Unless required by applicable law or agreed to in writing, software
4212 * distributed under the License is distributed on an "AS IS" BASIS,
4213 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4214 * See the License for the specific language governing permissions and
4215 * limitations under the License.
4216 */class ZS{constructor(){this.Gi=!1,this.zi=!1,this.ji=100,this.Hi=function(){return py()?8:xR(Fe())>0?6:4}()}initialize(e,t){this.Ji=e,this.indexManager=t,this.Gi=!0}getDocumentsMatchingQuery(e,t,s,i){const r={result:null};return this.Yi(e,t).next(o=>{r.result=o}).next(()=>{if(!r.result)return this.Zi(e,t,i,s).next(o=>{r.result=o})}).next(()=>{if(r.result)return;const o=new JS;return this.Xi(e,t,o).next(l=>{if(r.result=l,this.zi)return this.es(e,t,o,l.size)})}).next(()=>r.result)}es(e,t,s,i){return s.documentReadCount<this.ji?(Gs()<=K.DEBUG&&x("QueryEngine","SDK will not create cache indexes for query:",qn(t),"since it only creates cache indexes for collection contains","more than or equal to",this.ji,"documents"),P.resolve()):(Gs()<=K.DEBUG&&x("QueryEngine","Query:",qn(t),"scans",s.documentReadCount,"local documents and returns",i,"documents as results."),s.documentReadCount>this.Hi*i?(Gs()<=K.DEBUG&&x("QueryEngine","The SDK decides to create cache indexes for query:",qn(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,ft(t))):P.resolve())}Yi(e,t){if(Cd(t))return P.resolve(null);let s=ft(t);return this.indexManager.getIndexType(e,s).next(i=>i===0?null:(t.limit!==null&&i===1&&(t=cl(t,null,"F"),s=ft(t)),this.indexManager.getDocumentsMatchingTarget(e,s).next(r=>{const o=X(...r);return this.Ji.getDocuments(e,o).next(l=>this.indexManager.getMinOffset(e,s).next(c=>{const h=this.ts(t,l);return this.ns(t,h,o,c.readTime)?this.Yi(e,cl(t,null,"F")):this.rs(e,h,t,c)}))})))}Zi(e,t,s,i){return Cd(t)||i.isEqual(q.min())?P.resolve(null):this.Ji.getDocuments(e,s).next(r=>{const o=this.ts(t,r);return this.ns(t,o,s,i)?P.resolve(null):(Gs()<=K.DEBUG&&x("QueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),qn(t)),this.rs(e,o,t,PR(i,-1)).next(l=>l))})}ts(e,t){let s=new be(vg(e));return t.forEach((i,r)=>{Do(e,r)&&(s=s.add(r))}),s}ns(e,t,s,i){if(e.limit===null)return!1;if(s.size!==t.size)return!0;const r=e.limitType==="F"?t.last():t.first();return!!r&&(r.hasPendingWrites||r.version.compareTo(i)>0)}Xi(e,t,s){return Gs()<=K.DEBUG&&x("QueryEngine","Using full collection scan to execute query:",qn(t)),this.Ji.getDocumentsMatchingQuery(e,t,sn.min(),s)}rs(e,t,s,i){return this.Ji.getDocumentsMatchingQuery(e,s,i).next(r=>(t.forEach(o=>{r=r.insert(o.key,o)}),r))}}/**
4217 * @license
4218 * Copyright 2020 Google LLC
4219 *
4220 * Licensed under the Apache License, Version 2.0 (the "License");
4221 * you may not use this file except in compliance with the License.
4222 * You may obtain a copy of the License at
4223 *
4224 *   http://www.apache.org/licenses/LICENSE-2.0
4225 *
4226 * Unless required by applicable law or agreed to in writing, software
4227 * distributed under the License is distributed on an "AS IS" BASIS,
4228 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4229 * See the License for the specific language governing permissions and
4230 * limitations under the License.
4231 */class eb{constructor(e,t,s,i){this.persistence=e,this.ss=t,this.serializer=i,this.os=new pe(ee),this._s=new ws(r=>wc(r),Cc),this.us=new Map,this.cs=e.getRemoteDocumentCache(),this.Ur=e.getTargetCache(),this.Gr=e.getBundleCache(),this.ls(s)}ls(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new $S(this.cs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.cs.setIndexManager(this.indexManager),this.ss.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.os))}}function tb(n,e,t,s){return new eb(n,e,t,s)}async function Lg(n,e){const t=Y(n);return await t.persistence.runTransaction("Handle user change","readonly",s=>{let i;return t.mutationQueue.getAllMutationBatches(s).next(r=>(i=r,t.ls(e),t.mutationQueue.getAllMutationBatches(s))).next(r=>{const o=[],l=[];let c=X();for(const h of i){o.push(h.batchId);for(const f of h.mutations)c=c.add(f.key)}for(const h of r){l.push(h.batchId);for(const f of h.mutations)c=c.add(f.key)}return t.localDocuments.getDocuments(s,c).next(h=>({hs:h,removedBatchIds:o,addedBatchIds:l}))})})}function Vg(n){const e=Y(n);return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.Ur.getLastRemoteSnapshotVersion(t))}function nb(n,e){const t=Y(n),s=e.snapshotVersion;let i=t.os;return t.persistence.runTransaction("Apply remote event","readwrite-primary",r=>{const o=t.cs.newChangeBuffer({trackRemovals:!0});i=t.os;const l=[];
4231e.targetChanges.forEach((f,p)=>{const g=i.get(p);if(!g)return;l.push(t.Ur.removeMatchingKeys(r,f.removedDocuments,p).next(()=>t.Ur.addMatchingKeys(r,f.addedDocuments,p)));let I=g.withSequenceNumber(r.currentSequenceNumber);e.targetMismatches.get(p)!==null?I=I.withResumeToken(Pe.EMPTY_BYTE_STRING,q.min()).withLastLimboFreeSnapshotVersion(q.min()):f.resumeToken.approximateByteSize()>0&&(I=I.withResumeToken(f.resumeToken,s)),i=i.insert(p,I),function(k,b,B){return k.resumeToken.approximateByteSize()===0||b.snapshotVersion.toMicroseconds()-k.snapshotVersion.toMicroseconds()>=3e8?!0:B.addedDocuments.size+B.modifiedDocuments.size+B.removedDocuments.size>0}(g,I,f)&&l.push(t.Ur.updateTargetData(r,I))});let c=on(),h=X();if(e.documentUpdates.forEach(f=>{e.resolvedLimboDocuments.has(f)&&l.push(t.persistence.referenceDelegate.updateLimboDocument(r,f))}),l.push(sb(r,o,e.documentUpdates).next(f=>{c=f.Ps,h=f.Is})),!s.isEqual(q.min())){const f=t.Ur.getLastRemoteSnapshotVersion(r).next(p=>t.Ur.setTargetsMetadata(r,r.currentSequenceNumber,s));l.push(f)}return P.waitFor(l).next(()=>o.apply(r)).next(()=>t.localDocuments.getLocalViewOfDocuments(r,c,h)).next(()=>c)}).then(r=>(t.os=i,r))}function sb(n,e,t){let s=X(),i=X();return t.forEach(r=>s=s.add(r)),e.getEntries(n,s).next(r=>{let o=on();return t.forEach((l,c)=>{const h=r.get(l);c.isFoundDocument()!==h.isFoundDocument()&&(i=i.add(l)),c.isNoDocument()&&c.version.isEqual(q.min())?(e.removeEntry(l,c.readTime),o=o.insert(l,c)):!h.isValidDocument()||c.version.compareTo(h.version)>0||c.version.compareTo(h.version)===0&&h.hasPendingWrites?(e.addEntry(c),o=o.insert(l,c)):x("LocalStore","Ignoring outdated watch update for ",l,". Current version:",h.version," Watch version:",c.version)}),{Ps:o,Is:i}})}function ib(n,e){const t=Y(n);return t.persistence.runTransaction("Allocate target","readwrite",s=>{let i;return t.Ur.getTargetData(s,e).next(r=>r?(i=r,P.resolve(i)):t.Ur.allocateTargetId(s).next(o=>(i=new zt(e,o,"TargetPurposeListen",s.currentSequenceNumber),t.Ur.addTargetData(s,i).next(()=>i))))}).then(s=>{const i=t.os.get(s.targetId);return(i===null||s.snapshotVersion.compareTo(i.snapshotVersion)>0)&&(t.os=t.os.insert(s.targetId,s),t._s.set(e,s.targetId)),s})}async function pl(n,e,t){const s=Y(n),i=s.os.get(e),r=t?"readwrite":"readwrite-primary";try{t||await s.persistence.runTransaction("Release target",r,o=>s.persistence.referenceDelegate.removeTarget(o,i))}catch(o){if(!Bi(o))throw o;x("LocalStore",`Failed to update sequence numbers for target ${e}: ${o}`)}s.os=s.os.remove(e),s._s.delete(i.target)}function Md(n,e,t){const s=Y(n);let i=q.min(),r=X();return s.persistence.runTransaction("Execute query","readwrite",o=>function(c,h,f){const p=Y(c),g=p._s.get(f);return g!==void 0?P.resolve(p.os.get(g)):p.Ur.getTargetData(h,f)}(s,o,ft(e)).next(l=>{if(l)return i=l.lastLimboFreeSnapshotVersion,s.Ur.getMatchingKeysForTargetId(o,l.targetId).next(c=>{r=c})}).next(()=>s.ss.getDocumentsMatchingQuery(o,e,t?i:q.min(),t?r:X())).next(l=>(rb(s,ZR(e),l),{documents:l,Ts:r})))}function rb(n,e,t){let s=n.us.get(e)||q.min();t.forEach((i,r)=>{r.readTime.compareTo(s)>0&&(s=r.readTime)}),n.us.set(e,s)}class Ld{constructor(){this.activeTargetIds=rS()}fs(e){this.activeTargetIds=this.activeTargetIds.add(e)}gs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Vs(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class ob{constructor(){this.so=new Ld,this.oo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}
4231updateMutationState(e,t,s){}addLocalQueryTarget(e,t=!0){return t&&this.so.fs(e),this.oo[e]||"not-current"}updateQueryState(e,t,s){this.oo[e]=t}removeLocalQueryTarget(e){this.so.gs(e)}isLocalQueryTarget(e){return this.so.activeTargetIds.has(e)}clearQueryState(e){delete this.oo[e]}getAllActiveQueryTargets(){return this.so.activeTargetIds}isActiveQueryTarget(e){return this.so.activeTargetIds.has(e)}start(){return this.so=new Ld,Promise.resolve()}handleUserChange(e,t,s){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}/**
4232 * @license
4233 * Copyright 2019 Google LLC
4234 *
4235 * Licensed under the Apache License, Version 2.0 (the "License");
4236 * you may not use this file except in compliance with the License.
4237 * You may obtain a copy of the License at
4238 *
4239 *   http://www.apache.org/licenses/LICENSE-2.0
4240 *
4241 * Unless required by applicable law or agreed to in writing, software
4242 * distributed under the License is distributed on an "AS IS" BASIS,
4243 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4244 * See the License for the specific language governing permissions and
4245 * limitations under the License.
4246 */class ab{_o(e){}shutdown(){}}/**
4247 * @license
4248 * Copyright 2019 Google LLC
4249 *
4250 * Licensed under the Apache License, Version 2.0 (the "License");
4251 * you may not use this file except in compliance with the License.
4252 * You may obtain a copy of the License at
4253 *
4254 *   http://www.apache.org/licenses/LICENSE-2.0
4255 *
4256 * Unless required by applicable law or agreed to in writing, software
4257 * distributed under the License is distributed on an "AS IS" BASIS,
4258 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4259 * See the License for the specific language governing permissions and
4260 * limitations under the License.
4261 */class Vd{constructor(){this.ao=()=>this.uo(),this.co=()=>this.lo(),this.ho=[],this.Po()}_o(e){this.ho.push(e)}shutdown(){window.removeEventListener("online",this.ao),window.removeEventListener("offline",this.co)}Po(){window.addEventListener("online",this.ao),window.addEventListener("offline",this.co)}uo(){x("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(const e of this.ho)e(0)}lo(){x("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(const e of this.ho)e(1)}static D(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/**
4262 * @license
4263 * Copyright 2023 Google LLC
4264 *
4265 * Licensed under the Apache License, Version 2.0 (the "License");
4266 * you may not use this file except in compliance with the License.
4267 * You may obtain a copy of the License at
4268 *
4269 *   http://www.apache.org/licenses/LICENSE-2.0
4270 *
4271 * Unless required by applicable law or agreed to in writing, software
4272 * distributed under the License is distributed on an "AS IS" BASIS,
4273 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4274 * See the License for the specific language governing permissions and
4275 * limitations under the License.
4276 */let yr=null;function Sa(){return yr===null?yr=function(){return 268435456+Math.round(2147483648*Math.random())}():yr++,"0x"+yr.toString(16)}/**
4277 * @license
4278 * Copyright 2020 Google LLC
4279 *
4280 * Licensed under the Apache License, Version 2.0 (the "License");
4281 * you may not use this file except in compliance with the License.
4282 * You may obtain a copy of the License at
4283 *
4284 *   http://www.apache.org/licenses/LICENSE-2.0
4285 *
4286 * Unless required by applicable law or agreed to in writing, software
4287 * distributed under the License is distributed on an "AS IS" BASIS,
4288 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4289 * See the License for the specific language governing permissions and
4290 * limitations under the License.
4291 */const lb={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};/**
4292 * @license
4293 * Copyright 2017 Google LLC
4294 *
4295 * Licensed under the Apache License, Version 2.0 (the "License");
4296 * you may not use this file except in compliance with the License.
4297 * You may obtain a copy of the License at
4298 *
4299 *   http://www.apache.org/licenses/LICENSE-2.0
4300 *
4301 * Unless required by applicable law or agreed to in writing, softw
4301are
4302 * distributed under the License is distributed on an "AS IS" BASIS,
4303 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4304 * See the License for the specific language governing permissions and
4305 * limitations under the License.
4306 */class cb{constructor(e){this.Io=e.Io,this.To=e.To}Eo(e){this.Ao=e}Ro(e){this.Vo=e}mo(e){this.fo=e}onMessage(e){this.po=e}close(){this.To()}send(e){this.Io(e)}yo(){this.Ao()}wo(){this.Vo()}So(e){this.fo(e)}bo(e){this.po(e)}}/**
4307 * @license
4308 * Copyright 2017 Google LLC
4309 *
4310 * Licensed under the Apache License, Version 2.0 (the "License");
4311 * you may not use this file except in compliance with the License.
4312 * You may obtain a copy of the License at
4313 *
4314 *   http://www.apache.org/licenses/LICENSE-2.0
4315 *
4316 * Unless required by applicable law or agreed to in writing, software
4317 * distributed under the License is distributed on an "AS IS" BASIS,
4318 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4319 * See the License for the specific language governing permissions and
4320 * limitations under the License.
4321 */const xe="WebChannelConnection";class ub extends class{constructor(t){this.databaseInfo=t,this.databaseId=t.databaseId;const s=t.ssl?"https":"http",i=encodeURIComponent(this.databaseId.projectId),r=encodeURIComponent(this.databaseId.database);this.Do=s+"://"+t.host,this.vo=`projects/${i}/databases/${r}`,this.Co=this.databaseId.database==="(default)"?`project_id=${i}`:`project_id=${i}&database_id=${r}`}get Fo(){return!1}Mo(t,s,i,r,o){const l=Sa(),c=this.xo(t,s.toUriEncodedString());x("RestConnection",`Sending RPC '${t}' ${l}:`,c,i);const h={"google-cloud-resource-prefix":this.vo,"x-goog-request-params":this.Co};return this.Oo(h,r,o),this.No(t,c,h,i).then(f=>(x("RestConnection",`Received RPC '${t}' ${l}: `,f),f),f=>{throw us("RestConnection",`RPC '${t}' ${l} failed with error: `,f,"url: ",c,"request:",i),f})}Lo(t,s,i,r,o,l){return this.Mo(t,s,i,r,o)}Oo(t,s,i){t["X-Goog-Api-Client"]=function(){return"gl-js/ fire/"+Is}(),t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),s&&s.headers.forEach((r,o)=>t[o]=r),i&&i.headers.forEach((r,o)=>t[o]=r)}xo(t,s){const i=lb[t];return`${this.Do}/v1/${s}:${i}`}terminate(){}}{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}No(e,t,s,i){const r=Sa();return new Promise((o,l)=>{const c=new rg;c.setWithCredentials(!0),c.listenOnce(og.COMPLETE,()=>{try{switch(c.getLastErrorCode()){case Sr.NO_ERROR:const f=c.getResponseJson();x(xe,`XHR for RPC '${e}' ${r} received:`,JSON.stringify(f)),o(f);break;case Sr.TIMEOUT:x(xe,`RPC '${e}' ${r} timed out`),l(new M(O.DEADLINE_EXCEEDED,"Request time out"));break;case Sr.HTTP_ERROR:const p=c.getStatus();if(x(xe,`RPC '${e}' ${r} failed with status:`,p,"response text:",c.getResponseText()),p>0){let g=c.getResponseJson();Array.isArray(g)&&(g=g[0]);const I=g==null?void 0:g.error;if(I&&I.status&&I.message){const S=function(b){const B=b.toLowerCase().replace(/_/g,"-");return Object.values(O).indexOf(B)>=0?B:O.UNKNOWN}(I.status);l(new M(S,I.message))}else l(new M(O.UNKNOWN,"Server responded with status "+c.getStatus()))}else l(new M(O.UNAVAILABLE,"Connection failed."));break;default:j()}}finally{x(xe,`RPC '${e}' ${r} completed.`)}});const h=JSON.stringify(i);x(xe,`RPC '${e}' ${r} sending request:`,i),c.send(t,"POST",h,s,15)})}Bo(e,t,s){const i=Sa(),r=[this.Do,"/","google.firestore.v1.Firestore","/",e,"/channel"],o=cg(),l=lg(),c={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},h=this.longPollingOptions.timeoutSeconds;h!==void 0&&(c.longPollingTimeout=Math.round(1e3*h)),this.useFetchStreams&&(c.useFetchStreams=!0),this.Oo(c.initMessageHeaders,t,s),c.encodeInitMessageHeaders=!0;const f=r.join("");x(xe,`Creating RPC '${e}' stream ${i}: ${f}`,c);const p=o.createWebChannel(f,c);let g=!1,I=!1;const S=new cb({Io:b=>{I?x(xe,`Not sending because RPC '${e}' stream ${i} is closed:`,b):(g||(x(xe,`Opening RPC '${e}' stream ${i} transport.`),p.open(),g=!0),x(xe,`RPC '${e}' stream ${i} sending:`,b),p.send(b))},To:()=>p.close()}),k=(b,B,H)=>{b.listen(B,V=>{try{H(V)}catch($){setTimeout(()=>{throw $},0)}})};return k(p,Ys.EventType.OPEN,()=>{I||(x(xe,`RPC '${e}' stream ${i} transport opened.`),S.yo())}),k(p,Ys.EventType.CLOSE,()=>{I||(I=!0,x(xe,`RPC '${e}' stream ${i} transport closed`),S.So())}
4321),k(p,Ys.EventType.ERROR,b=>{I||(I=!0,us(xe,`RPC '${e}' stream ${i} transport errored:`,b),S.So(new M(O.UNAVAILABLE,"The operation could not be completed")))}),k(p,Ys.EventType.MESSAGE,b=>{var B;if(!I){const H=b.data[0];he(!!H);const V=H,$=V.error||((B=V[0])===null||B===void 0?void 0:B.error);if($){x(xe,`RPC '${e}' stream ${i} received error:`,$);const me=$.status;let te=function(y){const E=_e[y];if(E!==void 0)return Sg(E)}(me),T=$.message;te===void 0&&(te=O.INTERNAL,T="Unknown error status: "+me+" with message "+$.message),I=!0,S.So(new M(te,T)),p.close()}else x(xe,`RPC '${e}' stream ${i} received:`,H),S.bo(H)}}),k(l,ag.STAT_EVENT,b=>{b.stat===sl.PROXY?x(xe,`RPC '${e}' stream ${i} detected buffering proxy`):b.stat===sl.NOPROXY&&x(xe,`RPC '${e}' stream ${i} detected no buffering proxy`)}),setTimeout(()=>{S.wo()},0),S}}function ba(){return typeof document<"u"?document:null}/**
4322 * @license
4323 * Copyright 2020 Google LLC
4324 *
4325 * Licensed under the Apache License, Version 2.0 (the "License");
4326 * you may not use this file except in compliance with the License.
4327 * You may obtain a copy of the License at
4328 *
4329 *   http://www.apache.org/licenses/LICENSE-2.0
4330 *
4331 * Unless required by applicable law or agreed to in writing, software
4332 * distributed under the License is distributed on an "AS IS" BASIS,
4333 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4334 * See the License for the specific language governing permissions and
4335 * limitations under the License.
4336 */function Fg(n){return new wS(n,!0)}/**
4337 * @license
4338 * Copyright 2017 Google LLC
4339 *
4340 * Licensed under the Apache License, Version 2.0 (the "License");
4341 * you may not use this file except in compliance with the License.
4342 * You may obtain a copy of the License at
4343 *
4344 *   http://www.apache.org/licenses/LICENSE-2.0
4345 *
4346 * Unless required by applicable law or agreed to in writing, software
4347 * distributed under the License is distributed on an "AS IS" BASIS,
4348 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4349 * See the License for the specific language governing permissions and
4350 * limitations under the License.
4351 */class Ug{constructor(e,t,s=1e3,i=1.5,r=6e4){this.ui=e,this.timerId=t,this.ko=s,this.qo=i,this.Qo=r,this.Ko=0,this.$o=null,this.Uo=Date.now(),this.reset()}reset(){this.Ko=0}Wo(){this.Ko=this.Qo}Go(e){this.cancel();const t=Math.floor(this.Ko+this.zo()),s=Math.max(0,Date.now()-this.Uo),i=Math.max(0,t-s);i>0&&x("ExponentialBackoff",`Backing off for ${i} ms (base delay: ${this.Ko} ms, delay with jitter: ${t} ms, last attempt: ${s} ms ago)`),this.$o=this.ui.enqueueAfterDelay(this.timerId,i,()=>(this.Uo=Date.now(),e())),this.Ko*=this.qo,this.Ko<this.ko&&(this.Ko=this.ko),this.Ko>this.Qo&&(this.Ko=this.Qo)}jo(){this.$o!==null&&(this.$o.skipDelay(),this.$o=null)}cancel(){this.$o!==null&&(this.$o.cancel(),this.$o=null)}zo(){return(Math.random()-.5)*this.Ko}}/**
4352 * @license
4353 * Copyright 2017 Google LLC
4354 *
4355 * Licensed under the Apache License, Version 2.0 (the "License");
4356 * you may not use this file except in compliance with the License.
4357 * You may obtain a copy of the License at
4358 *
4359 *   http://www.apache.org/licenses/LICENSE-2.0
4360 *
4361 * Unless required by applicable law or agreed to in writing, software
4362 * distributed under the License is distributed on an "AS IS" BASIS,
4363 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4364 * See the License for the specific language governing permissions and
4365 * limitations under the License.
4366 */class hb{constructor(e,t,s,i,r,o,l,c){this.ui=e,this.Ho=s,this.Jo=i,this.connection=r,this.authCredentialsProvider=o,this.appCheckCredentialsProvider=l,this.listener=c,this.state=0,this.Yo=0,this.Zo=null,this.Xo=null,this.stream=null,this.e_=0,this.t_=new Ug(e,t)}n_(){return this.state===1||this.state===5||this.r_()}r_(){return this.state===2||this.state===3}start(){this.e_=0,this.state!==4?this.auth():this.i_()}async stop(){this.n_()&&await this.close(0)}s_(){this.state=0,this.t_.reset()}o_(){this.r_()&&this.Zo===null&&(this.Zo=this.ui.enqueueAfterDelay(this.Ho,6e4,()=>this.__()))}a_(e){this.u_(),this.stream.send(e)}async __(){if(this.r_())return this.close(0)}u_(){this.Zo&&(this.Zo.cancel(),this.Zo=null)}
4366c_(){this.Xo&&(this.Xo.cancel(),this.Xo=null)}async close(e,t){this.u_(),this.c_(),this.t_.cancel(),this.Yo++,e!==4?this.t_.reset():t&&t.code===O.RESOURCE_EXHAUSTED?(Mt(t.toString()),Mt("Using maximum backoff delay to prevent overloading the backend."),this.t_.Wo()):t&&t.code===O.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.l_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.mo(t)}l_(){}auth(){this.state=1;const e=this.h_(this.Yo),t=this.Yo;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([s,i])=>{this.Yo===t&&this.P_(s,i)},s=>{e(()=>{const i=new M(O.UNKNOWN,"Fetching auth token failed: "+s.message);return this.I_(i)})})}P_(e,t){const s=this.h_(this.Yo);this.stream=this.T_(e,t),this.stream.Eo(()=>{s(()=>this.listener.Eo())}),this.stream.Ro(()=>{s(()=>(this.state=2,this.Xo=this.ui.enqueueAfterDelay(this.Jo,1e4,()=>(this.r_()&&(this.state=3),Promise.resolve())),this.listener.Ro()))}),this.stream.mo(i=>{s(()=>this.I_(i))}),this.stream.onMessage(i=>{s(()=>++this.e_==1?this.E_(i):this.onNext(i))})}i_(){this.state=5,this.t_.Go(async()=>{this.state=0,this.start()})}I_(e){return x("PersistentStream",`close with error: ${e}`),this.stream=null,this.close(4,e)}h_(e){return t=>{this.ui.enqueueAndForget(()=>this.Yo===e?t():(x("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class db extends hb{constructor(e,t,s,i,r,o){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,s,i,o),this.serializer=r}T_(e,t){return this.connection.Bo("Listen",e,t)}E_(e){return this.onNext(e)}onNext(e){this.t_.reset();const t=bS(this.serializer,e),s=function(r){if(!("targetChange"in r))return q.min();const o=r.targetChange;return o.targetIds&&o.targetIds.length?q.min():o.readTime?Zn(o.readTime):q.min()}(e);return this.listener.d_(t,s)}A_(e){const t={};t.database=xd(this.serializer),t.addTarget=function(r,o){let l;const c=o.target;if(l=ll(c)?{documents:PS(r,c)}:{query:kS(r,c)._t},l.targetId=o.targetId,o.resumeToken.approximateByteSize()>0){l.resumeToken=AS(r,o.resumeToken);const h=dl(r,o.expectedCount);h!==null&&(l.expectedCount=h)}else if(o.snapshotVersion.compareTo(q.min())>0){l.readTime=CS(r,o.snapshotVersion.toTimestamp());const h=dl(r,o.expectedCount);h!==null&&(l.expectedCount=h)}return l}(this.serializer,e);const s=DS(this.serializer,e);s&&(t.labels=s),this.a_(t)}R_(e){const t={};t.database=xd(this.serializer),t.removeTarget=e,this.a_(t)}}/**
4367 * @license
4368 * Copyright 2017 Google LLC
4369 *
4370 * Licensed under the Apache License, Version 2.0 (the "License");
4371 * you may not use this file except in compliance with the License.
4372 * You may obtain a copy of the License at
4373 *
4374 *   http://www.apache.org/licenses/LICENSE-2.0
4375 *
4376 * Unless required by applicable law or agreed to in writing, software
4377 * distributed under the License is distributed on an "AS IS" BASIS,
4378 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4379 * See the License for the specific language governing permissions and
4380 * limitations under the License.
4381 */class fb extends class{}{constructor(e,t,s,i){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=s,this.serializer=i,this.y_=!1}w_(){if(this.y_)throw new M(O.FAILED_PRECONDITION,"The client has already been terminated.")}Mo(e,t,s,i){return this.w_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([r,o])=>this.connection.Mo(e,fl(t,s),i,r,o)).catch(r=>{throw r.name==="FirebaseError"?(r.code===O.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),r):new M(O.UNKNOWN,r.toString())})}Lo(e,t,s,i,r){return this.w_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([o,l])=>this.connection.Lo(e,fl(t,s),i,o,l,r)).catch(o=>{throw o.name==="FirebaseError"?(o.code===O.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),o):new M(O.UNKNOWN,o.toString())})}terminate(){this.y_=!0,this.connection.terminate()}}
4381class pb{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.S_=0,this.b_=null,this.D_=!0}v_(){this.S_===0&&(this.C_("Unknown"),this.b_=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.b_=null,this.F_("Backend didn't respond within 10 seconds."),this.C_("Offline"),Promise.resolve())))}M_(e){this.state==="Online"?this.C_("Unknown"):(this.S_++,this.S_>=1&&(this.x_(),this.F_(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.C_("Offline")))}set(e){this.x_(),this.S_=0,e==="Online"&&(this.D_=!1),this.C_(e)}C_(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}F_(e){const t=`Could not reach Cloud Firestore backend. ${e}
4382This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.D_?(Mt(t),this.D_=!1):x("OnlineStateTracker",t)}x_(){this.b_!==null&&(this.b_.cancel(),this.b_=null)}}/**
4383 * @license
4384 * Copyright 2017 Google LLC
4385 *
4386 * Licensed under the Apache License, Version 2.0 (the "License");
4387 * you may not use this file except in compliance with the License.
4388 * You may obtain a copy of the License at
4389 *
4390 *   http://www.apache.org/licenses/LICENSE-2.0
4391 *
4392 * Unless required by applicable law or agreed to in writing, software
4393 * distributed under the License is distributed on an "AS IS" BASIS,
4394 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4395 * See the License for the specific language governing permissions and
4396 * limitations under the License.
4397 */class _b{constructor(e,t,s,i,r){this.localStore=e,this.datastore=t,this.asyncQueue=s,this.remoteSyncer={},this.O_=[],this.N_=new Map,this.L_=new Set,this.B_=[],this.k_=r,this.k_._o(o=>{s.enqueueAndForget(async()=>{ji(this)&&(x("RemoteStore","Restarting streams for network reachability change."),await async function(c){const h=Y(c);h.L_.add(4),await $i(h),h.q_.set("Unknown"),h.L_.delete(4),await Lo(h)}(this))})}),this.q_=new pb(s,i)}}async function Lo(n){if(ji(n))for(const e of n.B_)await e(!0)}async function $i(n){for(const e of n.B_)await e(!1)}function Bg(n,e){const t=Y(n);t.N_.has(e.targetId)||(t.N_.set(e.targetId,e),xc(t)?Oc(t):Cs(t).r_()&&Dc(t,e))}function Nc(n,e){const t=Y(n),s=Cs(t);t.N_.delete(e),s.r_()&&qg(t,e),t.N_.size===0&&(s.r_()?s.o_():ji(t)&&t.q_.set("Unknown"))}function Dc(n,e){if(n.Q_.xe(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo(q.min())>0){const t=n.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;e=e.withExpectedCount(t)}Cs(n).A_(e)}function qg(n,e){n.Q_.xe(e),Cs(n).R_(e)}function Oc(n){n.Q_=new vS({getRemoteKeysForTarget:e=>n.remoteSyncer.getRemoteKeysForTarget(e),ot:e=>n.N_.get(e)||null,tt:()=>n.datastore.serializer.databaseId}),Cs(n).start(),n.q_.v_()}function xc(n){return ji(n)&&!Cs(n).n_()&&n.N_.size>0}function ji(n){return Y(n).L_.size===0}function $g(n){n.Q_=void 0}async function gb(n){n.q_.set("Online")}async function mb(n){n.N_.forEach((e,t)=>{Dc(n,e)})}async function yb(n,e){$g(n),xc(n)?(n.q_.M_(e),Oc(n)):n.q_.set("Unknown")}async function vb(n,e,t){if(n.q_.set("Online"),e instanceof Pg&&e.state===2&&e.cause)try{await async function(i,r){const o=r.cause;for(const l of r.targetIds)i.N_.has(l)&&(await i.remoteSyncer.rejectListen(l,o),i.N_.delete(l),i.Q_.removeTarget(l))}(n,e)}catch(s){x("RemoteStore","Failed to remove targets %s: %s ",e.targetIds.join(","),s),await Fd(n,s)}else if(e instanceof Pr?n.Q_.Ke(e):e instanceof bg?n.Q_.He(e):n.Q_.We(e),!t.isEqual(q.min()))try{const s=await Vg(n.localStore);t.compareTo(s)>=0&&await function(r,o){const l=r.Q_.rt(o);
4397return l.targetChanges.forEach((c,h)=>{if(c.resumeToken.approximateByteSize()>0){const f=r.N_.get(h);f&&r.N_.set(h,f.withResumeToken(c.resumeToken,o))}}),l.targetMismatches.forEach((c,h)=>{const f=r.N_.get(c);if(!f)return;r.N_.set(c,f.withResumeToken(Pe.EMPTY_BYTE_STRING,f.snapshotVersion)),qg(r,c);const p=new zt(f.target,c,h,f.sequenceNumber);Dc(r,p)}),r.remoteSyncer.applyRemoteEvent(l)}(n,t)}catch(s){x("RemoteStore","Failed to raise snapshot:",s),await Fd(n,s)}}async function Fd(n,e,t){if(!Bi(e))throw e;n.L_.add(1),await $i(n),n.q_.set("Offline"),t||(t=()=>Vg(n.localStore)),n.asyncQueue.enqueueRetryable(async()=>{x("RemoteStore","Retrying IndexedDB access"),await t(),n.L_.delete(1),await Lo(n)})}async function Ud(n,e){const t=Y(n);t.asyncQueue.verifyOperationInProgress(),x("RemoteStore","RemoteStore received new credentials");const s=ji(t);t.L_.add(3),await $i(t),s&&t.q_.set("Unknown"),await t.remoteSyncer.handleCredentialChange(e),t.L_.delete(3),await Lo(t)}async function Eb(n,e){const t=Y(n);e?(t.L_.delete(2),await Lo(t)):e||(t.L_.add(2),await $i(t),t.q_.set("Unknown"))}function Cs(n){return n.K_||(n.K_=function(t,s,i){const r=Y(t);return r.w_(),new db(s,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,i)}(n.datastore,n.asyncQueue,{Eo:gb.bind(null,n),Ro:mb.bind(null,n),mo:yb.bind(null,n),d_:vb.bind(null,n)}),n.B_.push(async e=>{e?(n.K_.s_(),xc(n)?Oc(n):n.q_.set("Unknown")):(await n.K_.stop(),$g(n))})),n.K_}/**
4398 * @license
4399 * Copyright 2017 Google LLC
4400 *
4401 * Licensed under the Apache License, Version 2.0 (the "License");
4402 * you may not use this file except in compliance with the License.
4403 * You may obtain a copy of the License at
4404 *
4405 *   http://www.apache.org/licenses/LICENSE-2.0
4406 *
4407 * Unless required by applicable law or agreed to in writing, software
4408 * distributed under the License is distributed on an "AS IS" BASIS,
4409 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4410 * See the License for the specific language governing permissions and
4411 * limitations under the License.
4412 */class Mc{constructor(e,t,s,i,r){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=s,this.op=i,this.removalCallback=r,this.deferred=new Xt,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(o=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,t,s,i,r){const o=Date.now()+s,l=new Mc(e,t,o,i,r);return l.start(s),l}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new M(O.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then(e=>this.deferred.resolve(e))):Promise.resolve())}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function jg(n,e){if(Mt("AsyncQueue",`${e}: ${n}`),Bi(n))return new M(O.UNAVAILABLE,`${e}: ${n}`);throw n}/**
4413 * @license
4414 * Copyright 2017 Google LLC
4415 *
4416 * Licensed under the Apache License, Version 2.0 (the "License");
4417 * you may not use this file except in compliance with the License.
4418 * You may obtain a copy of the License at
4419 *
4420 *   http://www.apache.org/licenses/LICENSE-2.0
4421 *
4422 * Unless required by applicable law or agreed to in writing, software
4423 * distributed under the License is distributed on an "AS IS" BASIS,
4424 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4425 * See the License for the specific language governing permissions and
4426 * limitations under the License.
4427 */class es{constructor(e){this.comparator=e?(t,s)=>e(t,s)||F.comparator(t.key,s.key):(t,s)=>F.comparator(t.key,s.key),this.keyedMap=Xs(),this.sortedSet=new pe(this.comparator)}static emptySet(e){return new es(e.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((t,s)=>(e(t),!1))}add(e){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){const t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof es)||this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),s=e.sortedSet.getIterator();for(;t.hasNext();){const i=t.getNext().key,r=s.getNext().key;if(!i.isEqual(r))return!1}return!0}toString(){const e=[];return this.forEach(t=>{e.push(t.toString())}),e.length===0?"DocumentSet ()":`DocumentSet (
4428  `+e.join(`  
4429`)+`
4430)`}copy(e,t){const s=new es;return s.comparator=this.comparator,s.keyedMap=e,s.sortedSet=t,s}}/**
4431 * @license
4432 * Copyright 2017 Google LLC
4433 *
4434 * Licensed under the Apache License, Version 2.0 (the "License");
4435 * you may not use this file except in compliance with the License.
4436 * You may obtain a copy of the License at
4437 *
4438 *   http://www.apache.org/licenses/LICENSE-2.0
4439 *
4440 * Unless required by applicable law or agreed to in writing, software
4441 * distributed under the License is distributed on an "AS IS" BASIS,
4442 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4443 * See the License for the specific language governing permissions and
4444 * limitations under the License.
4445 */class Bd{constructor(){this.W_=new pe(F.comparator)}track(e){const t=e.doc.key,s=this.W_.get(t);s?e.type!==0&&s.type===3?this.W_=this.W_.insert(t,e):e.type===3&&s.type!==1?this.W_=this.W_.insert(t,{type:s.type,doc:e.doc}):e.type===2&&s.type===2?this.W_=this.W_.insert(t,{type:2,doc:e.doc}):e.type===2&&s.type===0?this.W_=this.W_.insert(t,{type:0,doc:e.doc}):e.type===1&&s.type===0?this.W_=this.W_.remove(t):e.type===1&&s.type===2?this.W_=this.W_.insert(t,{type:1,doc:s.doc}):e.type===0&&s.type===1?this.W_=this.W_.insert(t,{type:2,doc:e.doc}):j():this.W_=this.W_.insert(t,e)}G_(){const e=[];return this.W_.inorderTraversal((t,s)=>{e.push(s)}),e}}class _s{constructor(e,t,s,i,r,o,l,c,h){this.query=e,this.docs=t,this.oldDocs=s,this.docChanges=i,this.mutatedKeys=r,this.fromCache=o,this.syncStateChanged=l,this.excludesMetadataChanges=c,this.hasCachedResults=h}static fromInitialDocuments(e,t,s,i,r){const o=[];return t.forEach(l=>{o.push({type:0,doc:l})}),new _s(e,t,es.emptySet(t),o,s,i,!0,!1,r)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&No(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,s=e.docChanges;if(t.length!==s.length)return!1;for(let i=0;i<t.length;i++)if(t[i].type!==s[i].type||!t[i].doc.isEqual(s[i].doc))return!1;return!0}}/**
4446 * @license
4447 * Copyright 2017 Google LLC
4448 *
4449 * Licensed under the Apache License, Version 2.0 (the "License");
4450 * you may not use this file except in compliance with the License.
4451 * You may obtain a copy of the License at
4452 *
4453 *   http://www.apache.org/licenses/LICENSE-2.0
4454 *
4455 * Unless required by applicable law or agreed to in writing, software
4456 * distributed under the License is distributed on an "AS IS" BASIS,
4457 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4458 * See the License for the specific language governing permissions and
4459 * limitations under the License.
4460 */class Tb{constructor(){this.z_=void 0,this.j_=[]}H_(){return this.j_.some(e=>e.J_())}}class Ib{constructor(){this.queries=qd(),this.onlineState="Unknown",this.Y_=new Set}terminate(){(function(t,s){const i=Y(t),r=i.queries;i.queries=qd(),r.forEach((o,l)=>{for(const c of l.j_)c.onError(s)})})(this,new M(O.ABORTED,"Firestore shutting down"))}}function qd(){return new ws(n=>yg(n),No)}async function Lc(n,e){const t=Y(n);let s=3;const i=e.query;let r=t.queries.get(i);r?!r.H_()&&e.J_()&&(s=2):(r=new Tb,s=e.J_()?0:1);try{switch(s){case 0:r.z_=await t.onListen(i,!0);break;case 1:r.z_=await t.onListen(i,!1);break;case 2:await t.onFirstRemoteStoreListen(i)}}catch(o){const l=jg(o,`Initialization of query '${qn(e.query)}' failed`);return void e.onError(l)}t.queries.set(i,r),r.j_.push(e),e.Z_(t.onlineState),r.z_&&e.X_(r.z_)&&Fc(t)}async function Vc(n,e){const t=Y(n),s=e.query;let i=3;const r=t.queries.get(s);if(r){const o=r.j_.indexOf(e);o>=0&&(r.j_.splice(o,1),r.j_.length===0?i=e.J_()?0:1:!r.H_()&&e.J_()&&(i=2))}switch(i){case 0:return t.queries.delete(s),t.onUnlisten(s,!0);case 1:return t.queries.delete(s),t.onUnlisten(s,!1);case 2:return t.onLastRemoteStoreUnlisten(s);default:return}}function wb(n,e){const t=Y(n);let s=!1;for(const i of e){const r=i.query,o=t.queries.get(r);if(o){for(const l of o.j_)l.X_(i)&&(s=!0);o.z_=i}}s&&Fc(t)}function Cb(n,e,t){const s=Y(n),i=s.queries.get(e);if(i)for(const r of i.j_)r.onError(t);s.queries.delete(e)}function Fc(n){n.Y_.forEach(e=>{e.next()})}var _l,$d;($d=_l||(_l={})).ea="default",$d.Cache="cache";class Uc{constructor(e,t,s){this.query=e,this.ta=t,this.na=!1,this.ra=null,this.onlineState="Unknown",this.options=s||{}}X_(e){if(!this.options.includeMetadataChanges){const s=[];for(const i of e.docChanges)i.type!==3&&s.push(i);e=new _s(e.query,e.docs,e.oldDocs,s,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.na?this.ia(e)&&(this.ta.next(e),t=!0):this.sa(e,this.onlineState)&&(this.oa(e),t=!0),this.ra=e,t}onError(e){this.ta.error(e)}Z_(e){this.onlineState=e;let t=!1;return this.ra&&!this.na&&this.sa(this.ra,e)&&(this.oa(this.ra),t=!0),t}sa(e,t){if(!e.fromCache||!this.J_())return!0;const s=t!=="Offline";return(!this.options._a||!s)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}ia(e){if(e.docChanges.length>0)return!0;const t=this.ra&&this.ra.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}oa(e){e=_s.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.na=!0,this.ta.next(e)}J_(){return this.options.source!==_l.Cache}}/**
4461 * @license
4462 * Copyright 2017 Google LLC
4463 *
4464 * Licensed under the Apache License, Version 2.0 (the "License");
4465 * you may not use this file except in compliance with the License.
4466 * You may obtain a copy of the License at
4467 *
4468 *   http://www.apache.org/licenses/LICENSE-2.0
4469 *
4470 * Unless required by applicable law or agreed to in writing, software
4471 * distributed under the License is distributed on an "AS IS" BASIS,
4472 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4473 * See the License for the specific language governing permissions and
4474 * limitations under the License.
4475 */class Hg{constructor(e){this.key=e}}class Wg{constructor(e){this.key=e}}class Ab{constructor(e,t){this.query=e,this.Ta=t,this.Ea=null,this.hasCachedResults=!1,this.current=!1,this.da=X(),this.mutatedKeys=X(),this.Aa=vg(e),this.Ra=new es(this.Aa)}get Va(){return this.Ta}ma(e,t){const s=t?t.fa:new Bd,i=t?t.Ra:this.Ra;let r=t?t.mutatedKeys:this.mutatedKeys,o=i,l=!1;const c=this.query.limitType==="F"&&i.size===this.query.limit?i.last():null,h=this.query.limitType==="L"&&i.size===this.query.limit?i.first():null;if(e.inorderTraversal((f,p)=>{const g=i.get(f),I=Do(this.query,p)?p:null,S=!!g&&this.mutatedKeys.has(g.key),k=!!I&&(I.hasLocalMutations||this.mutatedKeys.has(I.key)&&I.hasCommittedMutations);let b=!1;g&&I?g.data.isEqual(I.data)?S!==k&&(s.track({type:3,doc:I}),b=!0):this.ga(g,I)||(s.track({type:2,doc:I}),b=!0,(c&&this.Aa(I,c)>0||h&&this.Aa(I,h)<0)&&(l=!0)):!g&&I?(s.track({type:0,doc:I}),b=!0):g&&!I&&(s.track({type:1,doc:g}),b=!0,(c||h)&&(l=!0)),b&&(I?(o=o.add(I),r=k?r.add(f):r.delete(f)):(o=o.delete(f),r=r.delete(f)))}),this.query.limit!==null)for(;o.size>this.query.limit;){const f=this.query.limitType==="F"?o.last():o.first();o=o.delete(f.key),r=r.delete(f.key),s.track({type:1,doc:f})}return{Ra:o,fa:s,ns:l,mutatedKeys:r}}ga(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,s,i){const r=this.Ra;this.Ra=e.Ra,this.mutatedKeys=e.mutatedKeys;const o=e.fa.G_();o.sort((f,p)=>function(I,S){const k=b=>{switch(b){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return j()}};return k(I)-k(S)}(f.type,p.type)||this.Aa(f.doc,p.doc)),this.pa(s),i=i!=null&&i;const l=t&&!i?this.ya():[],c=this.da.size===0&&this.current&&!i?1:0,h=c!==this.Ea;return this.Ea=c,o.length!==0||h?{snapshot:new _s(this.query,e.Ra,r,o,e.mutatedKeys,c===0,h,!1,!!s&&s.resumeToken.approximateByteSize()>0),wa:l}:{wa:l}}Z_(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({Ra:this.Ra,fa:new Bd,mutatedKeys:this.mutatedKeys,ns:!1},!1)):{wa:[]}}Sa(e){return!this.Ta.has(e)&&!!this.Ra.has(e)&&!this.Ra.get(e).hasLocalMutations}pa(e){e&&(e.addedDocuments.forEach(t=>this.Ta=this.Ta.add(t)),e.modifiedDocuments.forEach(t=>{}),e.removedDocuments.forEach(t=>this.Ta=this.Ta.delete(t)),this.current=e.current)}ya(){if(!this.current)return[];const e=this.da;this.da=X(),this.Ra.forEach(s=>{this.Sa(s.key)&&(this.da=this.da.add(s.key))});const t=[];return e.forEach(s=>{this.da.has(s)||t.push(new Wg(s))}),this.da.forEach(s=>{e.has(s)||t.push(new Hg(s))}),t}ba(e){this.Ta=e.Ts,this.da=X();const t=this.ma(e.documents);return this.applyChanges(t,!0)}Da(){return _s.fromInitialDocuments(this.query,this.Ra,this.mutatedKeys,this.Ea===0,this.hasCachedResults)}}class Rb{constructor(e,t,s){this.query=e,this.targetId=t,this.view=s}}class Sb{constructor(e){this.key=e,this.va=!1}}class bb{constructor(e,t,s,i,r,o){this.localStore=e,this.remoteStore=t,this.eventManager=s,this.sharedClientState=i,this.currentUser=r,this.maxConcurrentLimboResolutions=o,this.Ca={},this.Fa=new ws(l=>yg(l),No),this.Ma=new Map,this.xa=new Set,this.Oa=new pe(F.comparator),this.Na=new Map,this.La=new bc,this.Ba={},this.ka=new Map,this.qa=ps.kn(),this.onlineState="Unknown",this.Qa=void 0}get isPrimaryClient(){return this.Qa===!0}}async function Pb(n,e,t=!0){const s=Yg(n);let i;const r=s.Fa.get(e);return r?(s.sharedClientState.addLocalQueryTarget(r.targetId),i=r.view.Da()):i=await zg(s,e,t,!0),i}async function kb(n,e){const t=Yg(n);await zg(t,e,!0,!1)}async function zg(n,e,t,s){const i=await ib(n.localStore,ft(e)),r=i.targetId,o=n.sharedClientState.addLocalQueryTarget(r,t);let l;return s&&(l=await Nb(n,e,r,o==="current",i.resumeToken)),n.isPrimaryClient&&t&&Bg(n.remoteStore,i),l}async function Nb(n,e,t,s,i){n.Ka=(p,g,I)=>async function(k,b,B,H){let V=b.view.ma(B);V.ns&&(V=await Md(k.localStore,b.query,!1).then(({documents:T})=>b.view.ma(T,V)));const $=H&&H.targetChanges.get(b.targetId),me=H&&H.targetMismatches.get(b.targetId)!=null,te=b.view.applyChanges(V,k.isPrimaryClient,$,me);return Hd(k,b.targetId,te.wa),te.snapshot}(n,p,g,I);const r=await Md(n.localStore,e,!0),o=new Ab(e,r.Ts),l=o.ma(r.documents),c=qi.createSynthesizedTargetChangeForCurrentChange(t,s&&n.onlineState!=="Offline",i),h=o.applyChanges(l,n.isPrimaryClient,c);Hd(n,t,h.wa);const f=new Rb(e,t,o);return n.Fa.set(e,f),n.Ma.has(t)?n.Ma.get(t).push(e):n.Ma.set(t,[e]),h.snapshot}async function Db(n,e,t){const s=Y(n),i=s.Fa.get(e),r=s.Ma.get(i.targetId);if(r.length>1)return s.Ma.set(i.targetId,r.filter(o=>!No(o,e))),void s.Fa.delete(e);
4475s.isPrimaryClient?(s.sharedClientState.removeLocalQueryTarget(i.targetId),s.sharedClientState.isActiveQueryTarget(i.targetId)||await pl(s.localStore,i.targetId,!1).then(()=>{s.sharedClientState.clearQueryState(i.targetId),t&&Nc(s.remoteStore,i.targetId),gl(s,i.targetId)}).catch(yc)):(gl(s,i.targetId),await pl(s.localStore,i.targetId,!0))}async function Ob(n,e){const t=Y(n),s=t.Fa.get(e),i=t.Ma.get(s.targetId);t.isPrimaryClient&&i.length===1&&(t.sharedClientState.removeLocalQueryTarget(s.targetId),Nc(t.remoteStore,s.targetId))}async function Gg(n,e){const t=Y(n);try{const s=await nb(t.localStore,e);e.targetChanges.forEach((i,r)=>{const o=t.Na.get(r);o&&(he(i.addedDocuments.size+i.modifiedDocuments.size+i.removedDocuments.size<=1),i.addedDocuments.size>0?o.va=!0:i.modifiedDocuments.size>0?he(o.va):i.removedDocuments.size>0&&(he(o.va),o.va=!1))}),await Qg(t,s,e)}catch(s){await yc(s)}}function jd(n,e,t){const s=Y(n);if(s.isPrimaryClient&&t===0||!s.isPrimaryClient&&t===1){const i=[];s.Fa.forEach((r,o)=>{const l=o.view.Z_(e);l.snapshot&&i.push(l.snapshot)}),function(o,l){const c=Y(o);c.onlineState=l;let h=!1;c.queries.forEach((f,p)=>{for(const g of p.j_)g.Z_(l)&&(h=!0)}),h&&Fc(c)}(s.eventManager,e),i.length&&s.Ca.d_(i),s.onlineState=e,s.isPrimaryClient&&s.sharedClientState.setOnlineState(e)}}async function xb(n,e,t){const s=Y(n);s.sharedClientState.updateQueryState(e,"rejected",t);const i=s.Na.get(e),r=i&&i.key;if(r){let o=new pe(F.comparator);o=o.insert(r,Ve.newNoDocument(r,q.min()));const l=X().add(r),c=new Mo(q.min(),new Map,new pe(ee),o,l);await Gg(s,c),s.Oa=s.Oa.remove(r),s.Na.delete(e),Bc(s)}else await pl(s.localStore,e,!1).then(()=>gl(s,e,t)).catch(yc)}function gl(n,e,t=null){n.sharedClientState.removeLocalQueryTarget(e);for(const s of n.Ma.get(e))n.Fa.delete(s),t&&n.Ca.$a(s,t);n.Ma.delete(e),n.isPrimaryClient&&n.La.gr(e).forEach(s=>{n.La.containsKey(s)||Kg(n,s)})}function Kg(n,e){n.xa.delete(e.path.canonicalString());const t=n.Oa.get(e);t!==null&&(Nc(n.remoteStore,t),n.Oa=n.Oa.remove(e),n.Na.delete(t),Bc(n))}function Hd(n,e,t){for(const s of t)s instanceof Hg?(n.La.addReference(s.key,e),Mb(n,s)):s instanceof Wg?(x("SyncEngine","Document no longer in limbo: "+s.key),n.La.removeReference(s.key,e),n.La.containsKey(s.key)||Kg(n,s.key)):j()}function Mb(n,e){const t=e.key,s=t.path.canonicalString();n.Oa.get(t)||n.xa.has(s)||(x("SyncEngine","New document in limbo: "+t),n.xa.add(s),Bc(n))}function Bc(n){for(;n.xa.size>0&&n.Oa.size<n.maxConcurrentLimboResolutions;){const e=n.xa.values().next().value;n.xa.delete(e);const t=new F(ge.fromString(e)),s=n.qa.next();n.Na.set(s,new Sb(t)),n.Oa=n.Oa.insert(t,s),Bg(n.remoteStore,new zt(ft(ko(t.path)),s,"TargetPurposeLimboResolution",vc.oe))}}async function Qg(n,e,t){const s=Y(n),i=[],r=[],o=[];s.Fa.isEmpty()||(s.Fa.forEach((l,c)=>{o.push(s.Ka(c,e,t).then(h=>{var f;if((h||t)&&s.isPrimaryClient){const p=h?!h.fromCache:(f=t==null?void 0:t.targetChanges.get(c.targetId))===null||f===void 0?void 0:f.current;s.sharedClientState.updateQueryState(c.targetId,p?"current":"not-current")}if(h){i.push(h);const p=kc.Wi(c.targetId,h);r.push(p)}}))}),await Promise.all(o),s.Ca.d_(i),await async function(c,h){const f=Y(c);try{await f.persistence.runTransaction("notifyLocalViewChanges","readwrite",p=>P.forEach(h,g=>P.forEach(g.$i,I=>f.persistence.referenceDelegate.addReference(p,g.targetId,I)).next(()=>P.forEach(g.Ui,I=>f.persistence.referenceDelegate.removeReference(p,g.targetId,I)))))}catch(p){if(!Bi(p))throw p;x("LocalStore","Failed to update sequence numbers: "+p)}for(const p of h){const g=p.targetId;if(!p.fromCache){const I=f.os.get(g),S=I.snapshotVersion,k=I.withLastLimboFreeSnapshotVersion(S);f.os=f.os.insert(g,k)}}}(s.localStore,r))}
4475async function Lb(n,e){const t=Y(n);if(!t.currentUser.isEqual(e)){x("SyncEngine","User change. New user:",e.toKey());const s=await Lg(t.localStore,e);t.currentUser=e,function(r,o){r.ka.forEach(l=>{l.forEach(c=>{c.reject(new M(O.CANCELLED,o))})}),r.ka.clear()}(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,s.removedBatchIds,s.addedBatchIds),await Qg(t,s.hs)}}function Vb(n,e){const t=Y(n),s=t.Na.get(e);if(s&&s.va)return X().add(s.key);{let i=X();const r=t.Ma.get(e);if(!r)return i;for(const o of r){const l=t.Fa.get(o);i=i.unionWith(l.view.Va)}return i}}function Yg(n){const e=Y(n);return e.remoteStore.remoteSyncer.applyRemoteEvent=Gg.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=Vb.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=xb.bind(null,e),e.Ca.d_=wb.bind(null,e.eventManager),e.Ca.$a=Cb.bind(null,e.eventManager),e}class io{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=Fg(e.databaseInfo.databaseId),this.sharedClientState=this.Wa(e),this.persistence=this.Ga(e),await this.persistence.start(),this.localStore=this.za(e),this.gcScheduler=this.ja(e,this.localStore),this.indexBackfillerScheduler=this.Ha(e,this.localStore)}ja(e,t){return null}Ha(e,t){return null}za(e){return tb(this.persistence,new ZS,e.initialUser,this.serializer)}Ga(e){return new YS(Pc.Zr,this.serializer)}Wa(e){return new ob}async terminate(){var e,t;(e=this.gcScheduler)===null||e===void 0||e.stop(),(t=this.indexBackfillerScheduler)===null||t===void 0||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}io.provider={build:()=>new io};
4475class ml{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=s=>jd(this.syncEngine,s,1),this.remoteStore.remoteSyncer.handleCredentialChange=Lb.bind(null,this.syncEngine),await Eb(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return function(){return new Ib}()}createDatastore(e){const t=Fg(e.databaseInfo.databaseId),s=function(r){return new ub(r)}(e.databaseInfo);return function(r,o,l,c){return new fb(r,o,l,c)}(e.authCredentials,e.appCheckCredentials,s,t)}createRemoteStore(e){return function(s,i,r,o,l){return new _b(s,i,r,o,l)}(this.localStore,this.datastore,e.asyncQueue,t=>jd(this.syncEngine,t,0),function(){return Vd.D()?new Vd:new ab}())}createSyncEngine(e,t){return function(i,r,o,l,c,h,f){const p=new bb(i,r,o,l,c,h);return f&&(p.Qa=!0),p}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){var e,t;await async function(i){const r=Y(i);x("RemoteStore","RemoteStore shutting down."),r.L_.add(5),await $i(r),r.k_.shutdown(),r.q_.set("Unknown")}(this.remoteStore),(e=this.datastore)===null||e===void 0||e.terminate(),(t=this.eventManager)===null||t===void 0||t.terminate()}}ml.provider={build:()=>new ml};/**
4476 * @license
4477 * Copyright 2020 Google LLC
4478 *
4479 * Licensed under the Apache License, Version 2.0 (the "License");
4480 * you may not use this file except in compliance with the License.
4481 * You may obtain a copy of the License at
4482 *
4483 *   http://www.apache.org/licenses/LICENSE-2.0
4484 *
4485 * Unless required by applicable law or agreed to in writing, software
4486 * distributed under the License is distributed on an "AS IS" BASIS,
4487 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4488 * See the License for the specific language governing permissions and
4489 * limitations under the License.
4490 *//**
4491 * @license
4492 * Copyright 2017 Google LLC
4493 *
4494 * Licensed under the Apache License, Version 2.0 (the "License");
4495 * you may not use this file except in compliance with the License.
4496 * You may obtain a copy of the License at
4497 *
4498 *   http://www.apache.org/licenses/LICENSE-2.0
4499 *
4500 * Unless required by applicable law or agreed to in writing, software
4501 * distributed under the License is distributed on an "AS IS" BASIS,
4502 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4503 * See the License for the specific language governing permissions and
4504 * limitations under the License.
4505 */class qc{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ya(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ya(this.observer.error,e):Mt("Uncaught Error in snapshot listener:",e.toString()))}Za(){this.muted=!0}Ya(e,t){setTimeout(()=>{this.muted||e(t)},0)}}/**
4506 * @license
4507 * Copyright 2017 Google LLC
4508 *
4509 * Licensed under the Apache License, Version 2.0 (the "License");
4510 * you may not use this file except in compliance with the License.
4511 * You may obtain a copy of the License at
4512 *
4513 *   http://www.apache.org/licenses/LICENSE-2.0
4514 *
4515 * Unless required by applicable law or agreed to in writing, software
4516 * distributed under the License is distributed on an "AS IS" BASIS,
4517 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4518 * See the License for the specific language governing permissions and
4519 * limitations under the License.
4520 */class Fb{constructor(e,t,s,i,r){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=s,this.databaseInfo=i,this.user=Me.UNAUTHENTICATED,this.clientId=SR.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=r,this.authCredentials.start(s,async o=>{x("FirestoreClient","Received user=",o.uid),await this.authCredentialListener(o),this.user=o}),this.appCheckCredentials.start(s,o=>(x("FirestoreClient","Received new app check token=",o),this.appCheckCredentialListener(o,this.user)))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();const e=new Xt;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){const s=jg(t,"Failed to shutdown persistence");e.reject(s)}}),e.promise}}async function Pa(n,e){n.asyncQueue.verifyOperationInProgress(),x("FirestoreClient","Initializing OfflineComponentProvider");const t=n.configuration;await e.initialize(t);let s=t.initialUser;n.setCredentialChangeListener(async i=>{s.isEqual(i)||(await Lg(e.localStore,i),s=i)}),e.persistence.setDatabaseDeletedListener(()=>n.terminate()),n._offlineComponents=e}async function Wd(n,e){n.asyncQueue.verifyOperationInProgress();const t=await Ub(n);x("FirestoreClient","Initializing OnlineComponentProvider"),await e.initialize(t,n.configuration),n.setCredentialChangeListener(s=>Ud(e.remoteStore,s)),n.setAppCheckTokenChangeListener((s,i)=>Ud(e.remoteStore,i)),n._onlineComponents=e}async function Ub(n){if(!n._offlineComponents)if(n._uninitializedComponentsProvider){x("FirestoreClient","Using user provided OfflineComponentProvider");try{await Pa(n,n._uninitializedComponentsProvider._offline)}catch(e){const t=e;if(!function(i){return i.name==="FirebaseError"?i.code===O.FAILED_PRECONDITION||i.code===O.UNIMPLEMENT
4520ED:!(typeof DOMException<"u"&&i instanceof DOMException)||i.code===22||i.code===20||i.code===11}(t))throw t;us("Error using user provided cache. Falling back to memory cache: "+t),await Pa(n,new io)}}else x("FirestoreClient","Using default OfflineComponentProvider"),await Pa(n,new io);return n._offlineComponents}async function Bb(n){return n._onlineComponents||(n._uninitializedComponentsProvider?(x("FirestoreClient","Using user provided OnlineComponentProvider"),await Wd(n,n._uninitializedComponentsProvider._online)):(x("FirestoreClient","Using default OnlineComponentProvider"),await Wd(n,new ml))),n._onlineComponents}async function ro(n){const e=await Bb(n),t=e.eventManager;return t.onListen=Pb.bind(null,e.syncEngine),t.onUnlisten=Db.bind(null,e.syncEngine),t.onFirstRemoteStoreListen=kb.bind(null,e.syncEngine),t.onLastRemoteStoreUnlisten=Ob.bind(null,e.syncEngine),t}function qb(n,e,t={}){const s=new Xt;return n.asyncQueue.enqueueAndForget(async()=>function(r,o,l,c,h){const f=new qc({next:g=>{f.Za(),o.enqueueAndForget(()=>Vc(r,p));const I=g.docs.has(l);!I&&g.fromCache?h.reject(new M(O.UNAVAILABLE,"Failed to get document because the client is offline.")):I&&g.fromCache&&c&&c.source==="server"?h.reject(new M(O.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):h.resolve(g)},error:g=>h.reject(g)}),p=new Uc(ko(l.path),f,{includeMetadataChanges:!0,_a:!0});return Lc(r,p)}(await ro(n),n.asyncQueue,e,t,s)),s.promise}function $b(n,e,t={}){const s=new Xt;return n.asyncQueue.enqueueAndForget(async()=>function(r,o,l,c,h){const f=new qc({next:g=>{f.Za(),o.enqueueAndForget(()=>Vc(r,p)),g.fromCache&&c.source==="server"?h.reject(new M(O.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):h.resolve(g)},error:g=>h.reject(g)}),p=new Uc(l,f,{includeMetadataChanges:!0,_a:!0});return Lc(r,p)}(await ro(n),n.asyncQueue,e,t,s)),s.promise}/**
4521 * @license
4522 * Copyright 2023 Google LLC
4523 *
4524 * Licensed under the Apache License, Version 2.0 (the "License");
4525 * you may not use this file except in compliance with the License.
4526 * You may obtain a copy of the License at
4527 *
4528 *   http://www.apache.org/licenses/LICENSE-2.0
4529 *
4530 * Unless required by applicable law or agreed to in writing, software
4531 * distributed under the License is distributed on an "AS IS" BASIS,
4532 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4533 * See the License for the specific language governing permissions and
4534 * limitations under the License.
4535 */function Xg(n){const e={};return n.timeoutSeconds!==void 0&&(e.timeoutSeconds=n.timeoutSeconds),e}/**
4536 * @license
4537 * Copyright 2020 Google LLC
4538 *
4539 * Licensed under the Apache License, Version 2.0 (the "License");
4540 * you may not use this file except in compliance with the License.
4541 * You may obtain a copy of the License at
4542 *
4543 *   http://www.apache.org/licenses/LICENSE-2.0
4544 *
4545 * Unless required by applicable law or agreed to in writing, software
4546 * distributed under the License is distributed on an "AS IS" BASIS,
4547 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4548 * See the License for the specific language governing permissions and
4549 * limitations under the License.
4550 */const zd=new Map;function jb(n,e,t,s){if(e===!0&&s===!0)throw new M(O.INVALID_ARGUMENT,`${n} and ${t} cannot be used together.`)}function Hb(n){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n.length>20&&(n=`${n.substring(0,20)}...`),JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return""+n;if(typeof n=="object"){if(n instanceof Array)return"an array";{const e=function(s){return s.constructor?s.constructor.name:null}(n);return e?`a custom ${e} object`:"an object"}}return typeof n=="function"?"a function":j()}function Jt(n,e){if("_delegate"in n&&(n=n._delegate),!(n instanceof e)){if(e.name===n.constructor.name)throw new M(O.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const t=Hb(n);throw new M(O.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return n}/**
4551 * @license
4552 * Copyright 2020 Google LLC
4553 *
4554 * Licensed under the Apache License, Version 2.0 (the "License");
4555 * you may not use this file except in compliance with the License.
4556 * You may obtain a copy of the License at
4557 *
4558 *   http://www.apache.org/licenses/LICENSE-2.0
4559 *
4560 * Unless required by applicable law or agreed to in writing, software
4561 * distributed under the License is distributed on an "AS IS" BASIS,
4562 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4563 * See the License for the specific language governing permissions and
4564 * limitations under the License.
4565 */class Gd{constructor(e){var t,s;if(e.host===void 0){if(e.ssl!==void 0)throw new M(O.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=e.host,this.ssl=(t=e.ssl)===null||t===void 0||t;if(this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=41943040;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<1048576)throw new M(O.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}jb("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=Xg((s=e.experimentalLongPollingOptions)!==null&&s!==void 0?s:{}),function(r){if(r.timeoutSeconds!==void 0){if(isNaN(r.timeoutSeconds))throw new M(O.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (must not be NaN)`);if(r.timeoutSeconds<5)throw new M(O.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (minimum allowed value is 5)`);if(r.timeoutSeconds>30)throw new M(O.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&function(s,i){return s.timeoutSeconds===i.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class Jg{constructor(e,t,s,i){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=s,this._app=i,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Gd({}),this._settingsFrozen=!1,this._terminateTask="notTerminated"}get app(){if(!this._app)throw new M(O.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!=="notTerminated"}_setSettings(e){if(this._settingsFrozen)throw new M(O.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new Gd(e),e.credentials!==void 0&&(this._authCredentials=function(s){if(!s)return new vR;switch(s.type){case"firstParty":return new wR(s.sessionIndex||"0",s.iamToken||null,s.authTokenFactory||null);case"provider":return s.client;default:throw new M(O.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(t){const s=zd.get(t);s&&(x("ComponentProvider","Removing Datastore"),zd.delete(t),s.terminate())}(this),Promise.resolve()}}function Wb(n,e,t,s={}){var i;const r=(n=Jt(n,Jg))._getSettings(),o=`${e}:${t}`;if(r.host!=="firestore.googleapis.com"&&r.host!==o&&us("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used."),n._setSettings(Object.assign(Object.assign({},r),{host:o,ssl:!1})),s.mockUserToken){let l,c;if(typeof s.mockUserToken=="string")l=s.mockUserToken,c=Me.MOCK_USER;else{l=El(s.mockUserToken,(i=n._app)===null||i===void 0?void 0:i.options.projectId);const h=s.mockUserToken.sub||s.mockUserToken.user_id;if(!h)throw new M(O.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");c=new Me(h)}n._authCredentials=new ER(new ug(l,c))}}/**
4566 * @license
4567 * Copyright 2020 Google LLC
4568 *
4569 * Licensed under the Apache License, Version 2.0 (the "License");
4570 * you may not use this file except in compliance with the License.
4571 * You may obtain a copy of the License at
4572 *
4573 *   http://www.apache.org/licenses/LICENSE-2.0
4574 *
4575 * Unless required by applicable law or agreed to in writing, software
4576 * distributed under the License is distributed on an "AS IS" BASIS,
4577 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4578 * See the License for the specific language governing permissions and
4579 * limitations under the License.
4580 */class Hi{constructor(e,t,s){this.converter=t,this._query=s,this.type="query",this.firestore=e}withConverter(e){return new Hi(this.firestore,e,this._query)}}class On{constructor(e,t,s){this.converter=t,this._key=s,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new $c(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new On(this.firestore,e,this._key)}}class $c extends Hi{constructor(e,t,s){super(e,t,ko(s)),this._path=s,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new On(this.firestore,null,new F(e))}withConverter(e){return new $c(this.firestore,e,this._path)}}/**
4581 * @license
4582 * Copyright 2020 Google LLC
4583 *
4584 * Licensed under the Apache License, Version 2.0 (the "License");
4585 * you may not use this file except in compliance with the License.
4586 * You may obtain a copy of the License at
4587 *
4588 *   http://www.apache.org/licenses/LICENSE-2.0
4589 *
4590 * Unless required by applicable law or agreed to in writing, software
4591 * distributed under the License is distributed on an "AS IS" BASIS,
4592 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4593 * See the License for the specific language governing permissions and
4594 * limitations under the License.
4595 */class Kd{constructor(e=Promise.resolve()){this.Pu=[],this.Iu=!1,this.Tu=[],this.Eu=null,this.du=!1,this.Au=!1,this.Ru=[],this.t_=new Ug(this,"async_queue_retry"),this.Vu=()=>{const s=ba();s&&x("AsyncQueue","Visibility state changed to "+s.visibilityState),this.t_.jo()},this.mu=e;const t=ba();t&&typeof t.addEventListener=="function"&&t.addEventListener("visibilitychange",this.Vu)}get isShuttingDown(){return this.Iu}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.fu(),this.gu(e)}enterRestrictedMode(e){if(!this.Iu){this.Iu=!0,this.Au=e||!1;const t=ba();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this.Vu)}}enqueue(e){if(this.fu(),this.Iu)return new Promise(()=>{});const t=new Xt;return this.gu(()=>this.Iu&&this.Au?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Pu.push(e),this.pu()))}async pu(){if(this.Pu.length!==0){try{await this.Pu[0](),this.Pu.shift(),this.t_.reset()}catch(e){if(!Bi(e))throw e;x("AsyncQueue","Operation failed with retryable error: "+e)}this.Pu.length>0&&this.t_.Go(()=>this.pu())}}gu(e){const t=this.mu.then(()=>(this.du=!0,e().catch(s=>{this.Eu=s,this.du=!1;const i=function(o){let l=o.message||"";return o.stack&&(l=o.stack.includes(o.message)?o.stack:o.message+`
4596`+o.stack),l}(s);throw Mt("INTERNAL UNHANDLED ERROR: ",i),s}).then(s=>(this.du=!1,s))));return this.mu=t,t}enqueueAfterDelay(e,t,s){this.fu(),this.Ru.indexOf(e)>-1&&(t=0);const i=Mc.createAndSchedule(this,e,t,s,r=>this.yu(r));return this.Tu.push(i),i}fu(){this.Eu&&j()}verifyOperationInProgress(){}async wu(){let e;do e=this.mu,await e;while(e!==this.mu)}Su(e){for(const t of this.Tu)if(t.timerId===e)return!0;return!1}bu(e){return this.wu().then(()=>{this.Tu.sort((t,s)=>t.targetTimeMs-s.targetTimeMs);for(const t of this.Tu)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.wu()})}Du(e){this.Ru.push(e)}yu(e){const t=this.Tu.indexOf(e);this.Tu.splice(t,1)}}function Qd(n){return function(t,s){if(typeof t!="object"||t===null)return!1;const i=t;for(const r of s)if(r in i&&typeof i[r]=="function")return!0;return!1}(n,["next","error","complete"])}class bi extends Jg{constructor(e,t,s,i){super(e,t,s,i),this.type="firestore",this._queue=new Kd,this._persistenceKey=(i==null?void 0:i.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new Kd(e),this._firestoreClient=void 0,await e}}}function NP(n,e){const t=typeof n=="object"?n:vs(),s=typeof n=="string"?n:"(default)",i=gt(t,"firestore").getImmediate({identifier:s});if(!i._initialized){const r=vl("firestore");r&&Wb(i,...r)}return i}function jc(n){if(n._terminated)throw new M(O.FAILED_PRECONDITION,"The client has already been terminated.");return n._firestoreClient||zb(n),n._firestoreClient}function zb(n){var e,t,s;const i=n._freezeSettings(),r=function(l,c,h,f){return new VR(l,c,h,f.host,f.ssl,f.experimentalForceLongPolling,f.experimentalAutoDetectLongPolling,Xg(f.experimentalLongPollingOptions),f.useFetchStreams)}(n._databaseId,((e=n._app)===null||e===void 0?void 0:e.options.appId)||"",n._persistenceKey,i);n._componentsProvider||!((t=i.localCache)===null||t===void 0)&&t._offlineComponentProvider&&(!((s=i.localCache)===null||s===void 0)&&s._onlineComponentProvider)&&(n._componentsProvider={_offline:i.localCache._offlineComponentProvider,_online:i.localCache._onlineComponentProvider}),n._firestoreClient=new Fb(n._authCredentials,n._appCheckCredentials,n._queue,r,n._componentsProvider&&function(l){const c=l==null?void 0:l._online.build();return{_offline:l==null?void 0:l._offline.build(c),_online:c}}(n._componentsProvider))}/**
4597 * @license
4598 * Copyright 2020 Google LLC
4599 *
4600 * Licensed under the Apache License, Version 2.0 (the "License");
4601 * you may not use this file except in compliance with the License.
4602 * You may obtain a copy of the License at
4603 *
4604 *   http://www.apache.org/licenses/LICENSE-2.0
4605 *
4606 * Unless required by applicable law or agreed to in writing, software
4607 * distributed under the License is distributed on an "AS IS" BASIS,
4608 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4609 * See the License for the specific language governing permissions and
4610 * limitations under the License.
4611 */class oo{constructor(e){this._byteString=e}static fromBase64String(e){try{return new oo(Pe.fromBase64String(e))}catch(t){throw new M(O.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new oo(Pe.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}}/**
4612 * @license
4613 * Copyright 2020 Google LLC
4614 *
4615 * Licensed under the Apache License, Version 2.0 (the "License");
4616 * you may not use this file except in compliance with the License.
4617 * You may obtain a copy of the License at
4618 *
4619 *   http://www.apache.org/licenses/LICENSE-2.0
4620 *
4621 * Unless required by applicable law or agreed to in writing, software
4622 * distributed under the License is distributed on an "AS IS" BASIS,
4623 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4624 * See the License for the specific language governing permissions and
4625 * limitations under the License.
4626 */class Zg{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new M(O.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new $e(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}/**
4627 * @license
4628 * Copyright 2017 Google LLC
4629 *
4630 * Licensed under the Apache License, Version 2.0 (the "License");
4631 * you may not use this file except in compliance with the License.
4632 * You may obtain a copy of the License at
4633 *
4634 *   http://www.apache.org/licenses/LICENSE-2.0
4635 *
4636 * Unless required by applicable law or agreed to in writing, software
4637 * distributed under the License is distributed on an "AS IS" BASIS,
4638 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4639 * See the License for the specific language governing permissions and
4640 * limitations under the License.
4641 */class Gb{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new M(O.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new M(O.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(e){return ee(this._lat,e._lat)||ee(this._long,e._long)}}/**
4642 * @license
4643 * Copyright 2024 Google LLC
4644 *
4645 * Licensed under the Apache License, Version 2.0 (the "License");
4646 * you may not use this file except in compliance with the License.
4647 * You may obtain a copy of the License at
4648 *
4649 *   http://www.apache.org/licenses/LICENSE-2.0
4650 *
4651 * Unless required by applicable law or agreed to in writing, software
4652 * distributed under the License is distributed on an "AS IS" BASIS,
4653 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4654 * See the License for the specific language governing permissions and
4655 * limitations under the License.
4656 */class Kb{constructor(e){this._values=(e||[]).map(t=>t)}toArray(){return this._values.map(e=>e)}isEqual(e){return function(s,i){if(s.length!==i.length)return!1;for(let r=0;r<s.length;++r)if(s[r]!==i[r])return!1;return!0}(this._values,e._values)}}const Qb=new RegExp("[~\\*/\\[\\]]");function Yb(n,e,t){if(e.search(Qb)>=0)throw Yd(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,n);try{return new Zg(...e.split("."))._internalPath}catch{throw Yd(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,n)}}function Yd(n,e,t,s,i){let r=`Function ${e}
4656() called with invalid data`;r+=". ";let o="";return new M(O.INVALID_ARGUMENT,r+n+o)}/**
4657 * @license
4658 * Copyright 2020 Google LLC
4659 *
4660 * Licensed under the Apache License, Version 2.0 (the "License");
4661 * you may not use this file except in compliance with the License.
4662 * You may obtain a copy of the License at
4663 *
4664 *   http://www.apache.org/licenses/LICENSE-2.0
4665 *
4666 * Unless required by applicable law or agreed to in writing, software
4667 * distributed under the License is distributed on an "AS IS" BASIS,
4668 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4669 * See the License for the specific language governing permissions and
4670 * limitations under the License.
4671 */class em{constructor(e,t,s,i,r){this._firestore=e,this._userDataWriter=t,this._key=s,this._document=i,this._converter=r}get id(){return this._key.path.lastSegment()}get ref(){return new On(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new Xb(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){const t=this._document.data.field(tm("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}}class Xb extends em{data(){return super.data()}}function tm(n,e){return typeof e=="string"?Yb(n,e):e instanceof Zg?e._internalPath:e._delegate._internalPath}/**
4672 * @license
4673 * Copyright 2020 Google LLC
4674 *
4675 * Licensed under the Apache License, Version 2.0 (the "License");
4676 * you may not use this file except in compliance with the License.
4677 * You may obtain a copy of the License at
4678 *
4679 *   http://www.apache.org/licenses/LICENSE-2.0
4680 *
4681 * Unless required by applicable law or agreed to in writing, software
4682 * distributed under the License is distributed on an "AS IS" BASIS,
4683 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4684 * See the License for the specific language governing permissions and
4685 * limitations under the License.
4686 */function nm(n){if(n.limitType==="L"&&n.explicitOrderBy.length===0)throw new M(O.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Jb{convertValue(e,t="none"){switch(kn(e)){case 0:return null;case 1:return e.booleanValue;case 2:return fe(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(Pn(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw j()}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const s={};return bo(e,(i,r)=>{s[i]=this.convertValue(r,t)}),s}convertVectorValue(e){var t,s,i;const r=(i=(s=(t=e.fields)===null||t===void 0?void 0:t.value.arrayValue)===null||s===void 0?void 0:s.values)===null||i===void 0?void 0:i.map(o=>fe(o.doubleValue));return new Kb(r)}convertGeoPoint(e){return new Gb(fe(e.latitude),fe(e.longitude))}convertArray(e,t){return(e.values||[]).map(s=>this.convertValue(s,t))}convertServerTimestamp(e,t){switch(t){case"previous":const s=Tc(e);return s==null?null:this.convertValue(s,t);case"estimate":return this.convertTimestamp(Ai(e));default:return null}}convertTimestamp(e){const t=rn(e);return new ze(t.seconds,t.nanos)}convertDocumentKey(e,t){const s=ge.fromString(e);he(Mg(s));const i=new Ri(s.get(1),s.get(3)),r=new F(s.popFirst(5));return i.isEqual(t)||Mt(`Document ${r} contains a document reference within a different database (${i.projectId}/${i.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),r}}/**
4687 * @license
4688 * Copyright 2020 Google LLC
4689 *
4690 * Licensed under the Apache License, Version 2.0 (the "License");
4691 * you may not use this file except in compliance with the License.
4692 * You may obtain a copy of the License at
4693 *
4694 *   http://www.apache.org/licenses/LICENSE-2.0
4695 *
4696 * Unless required by applicable law or agreed to in writing, software
4697 * distributed under the License is distributed on an "AS IS" BASIS,
4698 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4699 * See the License for the specific language governing permissions and
4700 * limitations under the License.
4701 */class Zs{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class sm extends em{constructor(e,t,s,i,r,o){super(e,t,s,i,o),this._firestore=e,this._firestoreImpl=e,this.metadata=r}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new kr(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){const s=this._document.data.field(tm("DocumentSnapshot.get",e));if(s!==null)return this._userDataWriter.convertValue(s,t.serverTimestamps)}}}class kr extends sm{data(e={}){return super.data(e)}}class im{constructor(e,t,s,i){this._firestore=e,this._userDataWriter=t,this._snapshot=i,this.metadata=new Zs(i.hasPendingWrites,i.fromCache),this.query=s}get docs(){const e=[];return this.forEach(t=>e.push(t)),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach(s=>{e.call(t,new kr(this._firestore,this._userDataWriter,s.key,s,new Zs(this._snapshot.mutatedKeys.has(s.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new M(O.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(i,r){if(i._snapshot.oldDocs.isEmpty()){let o=0;return i._snapshot.docChanges.map(l=>{const c=new kr(i._firestore,i._userDataWriter,l.doc.key,l.doc,new Zs(i._snapshot.mutatedKeys.has(l.doc.key),i._snapshot.fromCache),i.query.converter);return l.doc,{type:"added",doc:c,oldIndex:-1,newIndex:o++}})}{let o=i._snapshot.oldDocs;return i._snapshot.docChanges.filter(l=>r||l.type!==3).map(l=>{const c=new kr(i._firestore,i._userDataWriter,l.doc.key,l.doc,new Zs(i._snapshot.mutatedKeys.has(l.doc.key),i._snapshot.fromCache),i.query.converter);let h=-1,f=-1;return l.type!==0&&(h=o.indexOf(l.doc.key),o=o.delete(l.doc.key)),l.type!==1&&(o=o.add(l.doc),f=o.indexOf(l.doc.key)),{type:Zb(l.type),doc:c,oldIndex:h,newIndex:f}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}}function Zb(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return j()}}/**
4702 * @license
4703 * Copyright 2020 Google LLC
4704 *
4705 * Licensed under the Apache License, Version 2.0 (the "License");
4706 * you may not use this file except in compliance with the License.
4707 * You may obtain a copy of the License at
4708 *
4709 *   http://www.apache.org/licenses/LICENSE-2.0
4710 *
4711 * Unless required by applicable law or agreed to in writing, software
4712 * distributed under the License is distributed on an "AS IS" BASIS,
4713 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4714 * See the License for the specific language governing permissions and
4715 * limitations under the License.
4716 */function DP(n){n=Jt(n,On);const e=Jt(n.firestore,bi);return qb(jc(e),n._key).then(t=>rm(e,n,t))}class Hc extends Jb{constructor(e){super(),this.firestore=e}convertBytes(e){return new oo(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new On(this.firestore,null,t)}}function OP(n){n=Jt(n,Hi);const e=Jt(n.firestore,bi),t=jc(e),s=new Hc(e);return nm(n._query),$b(t,n._query).then(i=>new im(e,s,n,i))}function xP(n,...e){var t,s,i;n=le(n);let r={includeMetadataChanges:!1,source:"default"},o=0;typeof e[o]!="object"||Qd(e[o])||(r=e[o],o++);const l={includeMetadataChanges:r.includeMetadataChanges,source:r.source};if(Qd(e[o])){const p=e[o];e[o]=(t=p.next)===null||t===void 0?void 0:t.bind(p),e[o+1]=(s=p.error)===null||s===void 0?void 0:s.bind(p),e[o+2]=(i=p.complete)===null||i===void 0?void 0:i.bind(p)}let c,h,f;if(n instanceof On)h=Jt(n.firestore,bi),f=ko(n._key.path),c={next:p=>{e[o]&&e[o](rm(h,n,p))},error:e[o+1],complete:e[o+2]};else{const p=Jt(n,Hi);h=Jt(p.firestore,bi),f=p._query;const g=new Hc(h);c={next:I=>{e[o]&&e[o](new im(h,g,p,I))},error:e[o+1],complete:e[o+2]},nm(n._query)}return function(g,I,S,k){const b=new qc(k),B=new Uc(I,b,S);return g.asyncQueue.enqueueAndForget(async()=>Lc(await ro(g),B)),()=>{b.Za(),g.asyncQueue.enqueueAndForget(async()=>Vc(await ro(g),B))}}(jc(h),f,l,c)}function rm(n,e,t){const s=t.docs.get(e._key),i=new Hc(n);return new sm(n,i,e._key,s,new Zs(t.hasPendingWrites,t.fromCache),e.converter)}(function(e,t=!0){(function(i){Is=i})(ln),Ge(new He("firestore",(s,{instanceIdentifier:i,options:r})=>{const o=s.getProvider("app").getImmediate(),l=new bi(new TR(s.getProvider("auth-internal")),new AR(s.getProvider("app-check-internal")),function(h,f){if(!Object.prototype.hasOwnProperty.apply(h.options,["projectId"]))throw new M(O.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new Ri(h.options.projectId,f)}(o,i),o);return r=Object.assign({useFetchStreams:t},r),l._setSettings(r),l},"PUBLIC").setMultipleInstances(!0)),Re(pd,"4.7.3",e),Re(pd,"4.7.3","esm2017")})();/**
4717 * @license
4718 * Copyright 2017 Google LLC
4719 *
4720 * Licensed under the Apache License, Version 2.0 (the "License");
4721 * you may not use this file except in compliance with the License.
4722 * You may obtain a copy of the License at
4723 *
4724 *   http://www.apache.org/licenses/LICENSE-2.0
4725 *
4726 * Unless required by applicable law or agreed to in writing, software
4727 * distributed under the License is distributed on an "AS IS" BASIS,
4728 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4729 * See the License for the specific language governing permissions and
4730 * limitations under the License.
4731 */const om="firebasestorage.googleapis.com",e0="storageBucket",t0=2*60*1e3,n0=10*60*1e3,s0=1e3;/**
4732 * @license
4733 * Copyright 2017 Google LLC
4734 *
4735 * Licensed under the Apache License, Version 2.0 (the "License");
4736 * you may not use this file except in compliance with the License.
4737 * You may obtain a copy of the License at
4738 *
4739 *   http://www.apache.org/licenses/LICENSE-2.0
4740 *
4741 * Unless required by applicable law or agreed to in writing, software
4742 * distributed under the License is distributed on an "AS IS" BASIS,
4743 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4744 * See the License for the specific language governing permissions and
4745 * limitations under the License.
4746 */class de extends tt{constructor(e,t,s=0){super(ka(e),`Firebase Storage: ${t} (${ka(e)})`),this.status_=s,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,de.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return ka(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}
4747${this.customData.serverResponse}`:this.message=this._baseMessage}}var ae;(function(n){n.UNKNOWN="unknown",n.OBJECT_NOT_FOUND="object-not-found",n.BUCKET_NOT_FOUND="bucket-not-found",n.PROJECT_NOT_FOUND="project-not-found",n.QUOTA_EXCEEDED="quota-exceeded",n.UNAUTHENTICATED="unauthenticated",n.UNAUTHORIZED="unauthorized",n.UNAUTHORIZED_APP="unauthorized-app",n.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",n.INVALID_CHECKSUM="invalid-checksum",n.CANCELED="canceled",n.INVALID_EVENT_NAME="invalid-event-name",n.INVALID_URL="invalid-url",n.INVALID_DEFAULT_BUCKET="invalid-default-bucket",n.NO_DEFAULT_BUCKET="no-default-bucket",n.CANNOT_SLICE_BLOB="cannot-slice-blob",n.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",n.NO_DOWNLOAD_URL="no-download-url",n.INVALID_ARGUMENT="invalid-argument",n.INVALID_ARGUMENT_COUNT="invalid-argument-count",n.APP_DELETED="app-deleted",n.INVALID_ROOT_OPERATION="invalid-root-operation",n.INVALID_FORMAT="invalid-format",n.INTERNAL_ERROR="internal-error",n.UNSUPPORTED_ENVIRONMENT="unsupported-environment"})(ae||(ae={}));function ka(n){return"storage/"+n}function Wc(){const n="An unknown error occurred, please check the error payload for server response.";return new de(ae.UNKNOWN,n)}function i0(n){return new de(ae.OBJECT_NOT_FOUND,"Object '"+n+"' does not exist.")}function r0(n){return new de(ae.QUOTA_EXCEEDED,"Quota for bucket '"+n+"' exceeded, please view quota on https://firebase.google.com/pricing/.")}function o0(){const n="User is not authenticated, please authenticate using Firebase Authentication and try again.";return new de(ae.UNAUTHENTICATED,n)}function a0(){return new de(ae.UNAUTHORIZED_APP,"This app does not have permission to access Firebase Storage on this project.")}function l0(n){return new de(ae.UNAUTHORIZED,"User does not have permission to access '"+n+"'.")}function am(){return new de(ae.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function lm(){return new de(ae.CANCELED,"User canceled the upload/download.")}function c0(n){return new de(ae.INVALID_URL,"Invalid URL '"+n+"'.")}function u0(n){return new de(ae.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+n+"'.")}function cm(){return new de(ae.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function h0(){return new de(ae.SERVER_FILE_WRONG_SIZE,"Server recorded incorrect upload file size, please retry the upload.")}function d0(){return new de(ae.NO_DOWNLOAD_URL,"The given file does not have any download URLs.")}function f0(n){return new de(ae.UNSUPPORTED_ENVIRONMENT,`${n} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`)}function Xd(n){return new de(ae.INVALID_ARGUMENT,n)}function um(){return new de(ae.APP_DELETED,"The Firebase app was deleted.")}function p0(n){return new de(ae.INVALID_ROOT_OPERATION,"The operation '"+n+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}function ui(n,e){return new de(ae.INVALID_FORMAT,"String does not match format '"+n+"': "+e)}function Ks(n){throw new de(ae.INTERNAL_ERROR,"Internal error: "+n)}/**
4748 * @license
4749 * Copyright 2017 Google LLC
4750 *
4751 * Licensed under the Apache License, Version 2.0 (the "License");
4752 * you may not use this file except in compliance with the License.
4753 * You may obtain a copy of the License at
4754 *
4755 *   http://www.apache.org/licenses/LICENSE-2.0
4756 *
4757 * Unless required by applicable law or agreed to in writing, software
4758 * distributed under the License is distributed on an "AS IS" BASIS,
4759 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4760 * See the License for the specific language governing permissions and
4761 * limitations under the License.
4762 */class Ze{constructor(e,t){this.bucket=e,this.path_=t}get path(){return this.path_}get isRoot(){return this.path.length===0}fullServerUrl(){const e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(e,t){let s;try{s=Ze.makeFromUrl(e,t)}catch{return new Ze(e,"")}if(s.path==="")return s;throw u0(e)}static makeFromUrl(e,t){let s=null;const i="([A-Za-z0-9.\\-_]+)";function r($){$.path.charAt($.path.length-1)==="/"&&($.path_=$.path_.slice(0,-1))}const o="(/(.*))?$",l=new RegExp("^gs://"+i+o,"i"),c={bucket:1,path:3};function h($){$.path_=decodeURIComponent($.path)}const f="v[A-Za-z0-9_]+",p=t.replace(/[.]/g,"\\."),g="(/([^?#]*).*)?$",I=new RegExp(`^https?://${p}/${f}/b/${i}/o${g}`,"i"),S={bucket:1,path:3},k=t===om?"(?:storage.googleapis.com|storage.cloud.google.com)":t,b="([^?#]*)",B=new RegExp(`^https?://${k}/${i}/${b}`,"i"),V=[{regex:l,indices:c,postModify:r},{regex:I,indices:S,postModify:h},{regex:B,indices:{bucket:1,path:2},postModify:h}];for(let $=0;$<V.length;$++){const me=V[$],te=me.regex.exec(e);if(te){const T=te[me.indices.bucket];let m=te[me.indices.path];m||(m=""),s=new Ze(T,m),me.postModify(s);break}}if(s==null)throw c0(e);return s}}class _0{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}}/**
4763 * @license
4764 * Copyright 2017 Google LLC
4765 *
4766 * Licensed under the Apache License, Version 2.0 (the "License");
4767 * you may not use this file except in compliance with the License.
4768 * You may obtain a copy of the License at
4769 *
4770 *   http://www.apache.org/licenses/LICENSE-2.0
4771 *
4772 * Unless required by applicable law or agreed to in writing, software
4773 * distributed under the License is distributed on an "AS IS" BASIS,
4774 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4775 * See the License for the specific language governing permissions and
4776 * limitations under the License.
4777 */function g0(n,e,t){let s=1,i=null,r=null,o=!1,l=0;function c(){return l===2}let h=!1;function f(...b){h||(h=!0,e.apply(null,b))}function p(b){i=setTimeout(()=>{i=null,n(I,c())},b)}function g(){r&&clearTimeout(r)}function I(b,...B){if(h){g();return}if(b){g(),f.call(null,b,...B);return}if(c()||o){g(),f.call(null,b,...B);return}s<64&&(s*=2);let V;l===1?(l=2,V=0):V=(s+Math.random())*1e3,p(V)}let S=!1;function k(b){S||(S=!0,g(),!h&&(i!==null?(b||(l=2),clearTimeout(i),p(0)):b||(l=1)))}return p(0),r=setTimeout(()=>{o=!0,k(!0)},t),k}function m0(n){n(!1)}/**
4778 * @license
4779 * Copyright 2017 Google LLC
4780 *
4781 * Licensed under the Apache License, Version 2.0 (the "License");
4782 * you may not use this file except in compliance with the License.
4783 * You may obtain a copy of the License at
4784 *
4785 *   http://www.apache.org/licenses/LICENSE-2.0
4786 *
4787 * Unless required by applicable law or agreed to in writing, software
4788 * distributed under the License is distributed on an "AS IS" BASIS,
4789 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4790 * See the License for the specific language governing permissions and
4791 * limitations under the License.
4792 */function y0(n){return n!==void 0}function v0(n){return typeof n=="function"}function E0(n){return typeof n=="object"&&!Array.isArray(n)}function Vo(n){return typeof n=="string"||n instanceof String}function Jd(n){return zc()&&n instanceof Blob}function zc(){return typeof Blob<"u"}function Zd(n,e,t,s){if(s<e)throw Xd(`Invalid value for '${n}'. Expected ${e} or greater.`);if(s>t)throw Xd(`Invalid value for '${n}'. Expected ${t} or less.`)}/**
4793 * @license
4794 * Copyright 2017 Google LLC
4795 *
4796 * Licensed under the Apache License, Version 2.0 (the "License");
4797 * you may not use this file except in compliance with the License.
4798 * You may obtain a copy of the License at
4799 *
4800 *   http://www.apache.org/licenses/LICENSE-2.0
4801 *
4802 * Unless required by applicable law or agreed to in writing, software
4803 * distributed under the License is distributed on an "AS IS" BASIS,
4804 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4805 * See the License for the specific language governing permissions and
4806 * limitations under the License.
4807 */function As(n,e,t){let s=e;return t==null&&(s=`https://${e}`),`${t}://${s}/v0${n}`}function hm(n){const e=encodeURIComponent;let t="?";for(const s in n)if(n.hasOwnProperty(s)){const i=e(s)+"="+e(n[s]);t=t+i+"&"}return t=t.slice(0,-1),t}var In;(function(n){n[n.NO_ERROR=0]="NO_ERROR",n[n.NETWORK_ERROR=1]="NETWORK_ERROR",n[n.ABORT=2]="ABORT"})(In||(In={}));/**
4808 * @license
4809 * Copyright 2022 Google LLC
4810 *
4811 * Licensed under the Apache License, Version 2.0 (the "License");
4812 * you may not use this file except in compliance with the License.
4813 * You may obtain a copy of the License at
4814 *
4815 *   http://www.apache.org/licenses/LICENSE-2.0
4816 *
4817 * Unless required by applicable law or agreed to in writing, software
4818 * distributed under the License is distributed on an "AS IS" BASIS,
4819 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4820 * See the License for the specific language governing permissions and
4821 * limitations under the License.
4822 */function dm(n,e){const t=n>=500&&n<600,i=[408,429].indexOf(n)!==-1,r=e.indexOf(n)!==-1;return t||i||r}/**
4823 * @license
4824 * Copyright 2017 Google LLC
4825 *
4826 * Licensed under the Apache License, Version 2.0 (the "License");
4827 * you may not use this file except in compliance with the License.
4828 * You may obtain a copy of the License at
4829 *
4830 *   http://www.apache.org/licenses/LICENSE-2.0
4831 *
4832 * Unless required by applicable law or agreed to in writing, software
4833 * distributed under the License is distributed on an "AS IS" BASIS,
4834 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4835 * See the License for the specific language governing permissions and
4836 * limitations under the License.
4837 */class T0{constructor(e,t,s,i,r,o,l,c,h,f,p,g=!0){this.url_=e,this.method_=t,this.headers_=s,this.body_=i,this.successCodes_=r,this.additionalRetryCodes_=o,this.callback_=l,this.errorCallback_=c,this.timeout_=h,this.progressCallback_=f,this.connectionFactory_=p,this.retry=g,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((I,S)=>{this.resolve_=I,this.reject_=S,this.start_()})}start_(){const e=(s,i)=>{if(i){s(!1,new vr(!1,null,!0));return}const r=this.connectionFactory_();this.pendingConnection_=r;const o=l=>{const c=l.loaded,h=l.lengthComputable?l.total:-1;this.progressCallback_!==null&&this.progressCallback_(c,h)};this.progressCallback_!==null&&r.addUploadProgressListener(o),r.send(this.url_,this.method_,this.body_,this.headers_).then(()=>{this.progressCallback_!==null&&r.removeUploadProgressListener(o),this.pendingConnection_=null;const l=r.getErrorCode()===In.NO_ERROR,c=r.getStatus();if(!l||dm(c,this.additionalRetryCodes_)&&this.retry){const f=r.getErrorCode()===In.ABORT;s(!1,new vr(!1,null,f));return}const h=this.successCodes_.indexOf(c)!==-1;s(!0,new vr(h,r))})},t=(s,i)=>{const r=this.resolve_,o=this.reject_,l=i.connection;if(i.wasSuccessCode)try{const c=this.callback_(l,l.getResponse());y0(c)?r(c):r()}catch(c){o(c)}else if(l!==null){const c=Wc();c.serverResponse=l.getErrorText(),this.errorCallback_?o(this.errorCallback_(l,c)):o(c)}else if(i.canceled){const c=this.appDelete_?um():lm();o(c)}else{const c=am();o(c)}};this.canceled_?t(!1,new vr(!1,null,!0)):this.backoffId_=g0(e,t,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&m0(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}}class vr{constructor(e,t,s){this.wasSuccessCode=e,this.connection=t,this.canceled=!!s}}function I0(n,e){e!==null&&e.length>0&&(n.Authorization="Firebase "+e)}function w0(n,e){n["X-Firebase-Storage-Version"]="webjs/"+(e??"AppManager")}function C0(n,e){e&&(n["X-Firebase-GMPID"]=e)}function A0(n,e){e!==null&&(n["X-Firebase-AppCheck"]=e)}
4837function R0(n,e,t,s,i,r,o=!0){const l=hm(n.urlParams),c=n.url+l,h=Object.assign({},n.headers);return C0(h,e),I0(h,t),w0(h,r),A0(h,s),new T0(c,n.method,h,n.body,n.successCodes,n.additionalRetryCodes,n.handler,n.errorHandler,n.timeout,n.progressCallback,i,o)}/**
4838 * @license
4839 * Copyright 2017 Google LLC
4840 *
4841 * Licensed under the Apache License, Version 2.0 (the "License");
4842 * you may not use this file except in compliance with the License.
4843 * You may obtain a copy of the License at
4844 *
4845 *   http://www.apache.org/licenses/LICENSE-2.0
4846 *
4847 * Unless required by applicable law or agreed to in writing, software
4848 * distributed under the License is distributed on an "AS IS" BASIS,
4849 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4850 * See the License for the specific language governing permissions and
4851 * limitations under the License.
4852 */function S0(){return typeof BlobBuilder<"u"?BlobBuilder:typeof WebKitBlobBuilder<"u"?WebKitBlobBuilder:void 0}function b0(...n){const e=S0();if(e!==void 0){const t=new e;for(let s=0;s<n.length;s++)t.append(n[s]);return t.getBlob()}else{if(zc())return new Blob(n);throw new de(ae.UNSUPPORTED_ENVIRONMENT,"This browser doesn't seem to support creating Blobs")}}function P0(n,e,t){return n.webkitSlice?n.webkitSlice(e,t):n.mozSlice?n.mozSlice(e,t):n.slice?n.slice(e,t):null}/**
4853 * @license
4854 * Copyright 2021 Google LLC
4855 *
4856 * Licensed under the Apache License, Version 2.0 (the "License");
4857 * you may not use this file except in compliance with the License.
4858 * You may obtain a copy of the License at
4859 *
4860 *   http://www.apache.org/licenses/LICENSE-2.0
4861 *
4862 * Unless required by applicable law or agreed to in writing, software
4863 * distributed under the License is distributed on an "AS IS" BASIS,
4864 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4865 * See the License for the specific language governing permissions and
4866 * limitations under the License.
4867 */function k0(n){if(typeof atob>"u")throw f0("base-64");return atob(n)}/**
4868 * @license
4869 * Copyright 2017 Google LLC
4870 *
4871 * Licensed under the Apache License, Version 2.0 (the "License");
4872 * you may not use this file except in compliance with the License.
4873 * You may obtain a copy of the License at
4874 *
4875 *   http://www.apache.org/licenses/LICENSE-2.0
4876 *
4877 * Unless required by applicable law or agreed to in writing, software
4878 * distributed under the License is distributed on an "AS IS" BASIS,
4879 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4880 * See the License for the specific language governing permissions and
4881 * limitations under the License.
4882 */const ut={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};class Na{constructor(e,t){this.data=e,this.contentType=t||null}}function N0(n,e){switch(n){case ut.RAW:return new Na(fm(e));case ut.BASE64:case ut.BASE64URL:return new Na(pm(n,e));case ut.DATA_URL:return new Na(O0(e),x0(e))}throw Wc()}function fm(n){const e=[];for(let t=0;t<n.length;t++){let s=n.charCodeAt(t);if(s<=127)e.push(s);else if(s<=2047)e.push(192|s>>6,128|s&63);else if((s&64512)===55296)if(!(t<n.length-1&&(n.charCodeAt(t+1)&64512)===56320))e.push(239,191,189);else{const r=s,o=n.charCodeAt(++t);s=65536|(r&1023)<<10|o&1023,e.push(240|s>>18,128|s>>12&63,128|s>>6&63,128|s&63)}else(s&64512)===56320?e.push(239,191,189):e.push(224|s>>12,128|s>>6&63,128|s&63)}return new Uint8Array(e)}function D0(n){let e;try{e=decodeURIComponent(n)}catch{throw ui(ut.DATA_URL,"Malformed data URL.")}return fm(e)}function pm(n,e){switch(n){case ut.BASE64:{const i=e.indexOf("-")!==-1,r=e.indexOf("_")!==-1;if(i||r)throw ui(n,"Invalid character '"+(i?"-":"_")+"' found: is it base64url encoded?");break}case ut.BASE64URL:{const i=e.indexOf("+")!==-1,r=e.indexOf("/")!==-1;if(i||r)throw ui(n,"Invalid character '"+(i?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/");break}}let t;try{t=k0(e)}catch(i){throw i.message.includes("polyfill")?i:ui(n,"Invalid character found")}const s=new Uint8Array(t.length);for(let i=0;i<t.length;i++)s[i]=t.charCodeAt(i);return s}class _m{constructor(e){this.base64=!1,this.contentType=null;const t=e.match(/^data:([^,]+)?,/);if(t===null)throw ui(ut.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");const s=t[1]||null;s!=null&&(this.base64=M0(s,";base64"),this.contentType=this.base64?s.substring(0,s.length-7):s),this.rest=e.substring(e.indexOf(",")+1)}}function O0(n){const e=new _m(n);return e.base64?pm(ut.BASE64,e.rest):D0(e.rest)}function x0(n){return new _m(n).contentType}function M0(n,e){return n.length>=e.length?n.substring(n.length-e.length)===e:!1}/**
4883 * @license
4884 * Copyright 2017 Google LLC
4885 *
4886 * Licensed under the Apache License, Version 2.0 (the "License");
4887 * you may not use this file except in compliance with the License.
4888 * You may obtain a copy of the License at
4889 *
4890 *   http://www.apache.org/licenses/LICENSE-2.0
4891 *
4892 * Unless required by applicable law or agreed to in writing, software
4893 * distributed under the License is distributed on an "AS IS" BASIS,
4894 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4895 * See the License for the specific language governing permissions and
4896 * limitations under the License.
4897 */class $t{constructor(e,t){let s=0,i="";Jd(e)?(this.data_=e,s=e.size,i=e.type):e instanceof ArrayBuffer?(t?this.data_=new Uint8Array(e):(this.data_=new Uint8Array(e.byteLength),this.data_.set(new Uint8Array(e))),s=this.data_.length):e instanceof Uint8Array&&(t?this.data_=e:(this.data_=new Uint8Array(e.length),this.data_.set(e)),s=e.length),this.size_=s,this.type_=i}size(){return this.size_}type(){return this.type_}slice(e,t){if(Jd(this.data_)){const s=this.data_,i=P0(s,e,t);return i===null?null:new $t(i)}else{const s=new Uint8Array(this.data_.buffer,e,t-e);return new $t(s,!0)}}static getBlob(...e){if(zc()){const t=e.map(s=>s instanceof $t?s.data_:s);return new $t(b0.apply(null,t))}else{const t=e.map(o=>Vo(o)?N0(ut.RAW,o).data:o.data_);let s=0;t.forEach(o=>{s+=o.byteLength});const i=new Uint8Array(s);let r=0;return t.forEach(o=>{for(let l=0;l<o.length;l++)i[r++]=o[l]}),new $t(i,!0)}}uploadData(){return this.data_}}/**
4898 * @license
4899 * Copyright 2017 Google LLC
4900 *
4901 * Licensed under the Apache License, Version 2.0 (the "License");
4902 * you may not use this file except in compliance with the License.
4903 * You may obtain a copy of the License at
4904 *
4905 *   http://www.apache.org/licenses/LICENSE-2.0
4906 *
4907 * Unless required by applicable law or agreed to in writing, software
4908 * distributed under the License is distributed on an "AS IS" BASIS,
4909 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4910 * See the License for the specific language governing permissions and
4911 * limitations under the License.
4912 */function gm(n){let e;try{e=JSON.parse(n)}catch{return null}return E0(e)?e:null}/**
4913 * @license
4914 * Copyright 2017 Google LLC
4915 *
4916 * Licensed under the Apache License, Version 2.0 (the "License");
4917 * you may not use this file except in compliance with the License.
4918 * You may obtain a copy of the License at
4919 *
4920 *   http://www.apache.org/licenses/LICENSE-2.0
4921 *
4922 * Unless required by applicable law or agreed to in writing, software
4923 * distributed under the License is distributed on an "AS IS" BASIS,
4924 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4925 * See the License for the specific language governing permissions and
4926 * limitations under the License.
4927 */function L0(n){if(n.length===0)return null;const e=n.lastIndexOf("/");return e===-1?"":n.slice(0,e)}function mm(n){const e=n.lastIndexOf("/",n.length-2);return e===-1?n:n.slice(e+1)}/**
4928 * @license
4929 * Copyright 2017 Google LLC
4930 *
4931 * Licensed under the Apache License, Version 2.0 (the "License");
4932 * you may not use this file except in compliance with the License.
4933 * You may obtain a copy of the License at
4934 *
4935 *   http://www.apache.org/licenses/LICENSE-2.0
4936 *
4937 * Unless required by applicable law or agreed to in writing, software
4938 * distributed under the License is distributed on an "AS IS" BASIS,
4939 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4940 * See the License for the specific language governing permissions and
4941 * limitations under the License.
4942 */function V0(n,e){return e}class qe{constructor(e,t,s,i){this.server=e,this.local=t||e,this.writable=!!s,this.xform=i||V0}}let Er=null;function F0(n){return!Vo(n)||n.length<2?n:mm(n)}function Fo(){if(Er)return Er;const n=[];n.push(new qe("bucket")),n.push(new qe("generation")),n.push(new qe("metageneration")),n.push(new qe("name","fullPath",!0));function e(r,o){return F0(o)}const t=new qe("name");t.xform=e,n.push(t);function s(r,o){return o!==void 0?Number(o):o}const i=new qe("size");return i.xform=s,n.push(i),n.push(new qe("timeCreated")),n.push(new qe("updated")),n.push(new qe("md5Hash",null,!0)),n.push(new qe("cacheControl",null,!0)),n.push(new qe("contentDisposition",null,!0)),n.push(new qe("contentEncoding",null,!0)),n.push(new qe("contentLanguage",null,!0)),n.push(new qe("contentType",null,!0)),n.push(new qe("metadata","customMetadata",!0)),Er=n,Er}function U0(n,e){function t(){const s=n.bucket,i=n.fullPath,r=new Ze(s,i);return e._makeStorageReference(r)}Object.defineProperty(n,"ref",{get:t})}function B0(n,e,t){const s={};s.type="file";const i=t.length;for(let r=0;r<i;r++){const o=t[r];s[o.local]=o.xform(s,e[o.server])}return U0(s,n),s}function ym(n,e,t){const s=gm(e);return s===null?null:B0(n,s,t)}function q0(n,e,t,s){const i=gm(e);if(i===null||!Vo(i.downloadTokens))return null;const r=i.downloadTokens;if(r.length===0)return null;const o=encodeURIComponent;return r.split(",").map(h=>{const f=n.bucket,p=n.fullPath,g="/b/"+o(f)+"/o/"+o(p),I=As(g,t,s),S=hm({alt:"media",token:h});return I+S})[0]}function Gc(n,e){const t={},s=e.length;for(let i=0;i<s;i++){const r=e[i];r.writable&&(t[r.server]=n[r.local])}return JSON.stringify(t)}class xn{constructor(e,t,s,i){this.url=e,this.method=t,this.handler=s,this.timeout=i,this.urlParam
vendor: 1,504 bytes, lines 4942-4957
4942s={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}}/**
4943 * @license
4944 * Copyright 2017 Google LLC
4945 *
4946 * Licensed under the Apache License, Version 2.0 (the "License");
4947 * you may not use this file except in compliance with the License.
4948 * You may obtain a copy of the License at
4949 *
4950 *   http://www.apache.org/licenses/LICENSE-2.0
4951 *
4952 * Unless required by applicable law or agreed to in writing, software
4953 * distributed under the License is distributed on an "AS IS" BASIS,
4954 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4955 * See the License for the specific language governing permissions and
4956 * limitations under the License.
4957 */function kt(n){if(!n)throw Wc()}function Uo(n,e){function t(s,i){const r=ym(n,i,e);return kt(r!==null),r}return t}function $0(n,e){function t(s,i){const r=ym(n,i,e);return kt(r!==null),q0(r,i,n.host,n._protocol)}return t}function Wi(n){function e(t,s){let i;return t.getStatus()===401?t.getErrorText().includes("Firebase App Check token is invalid")?i=a0():i=o0():t.getStatus()===402?i=r0(n.bucket):t.getStatus()===403?i=l0(n.path):i=s,i.status=t.getStatus(),i.serverResponse=s.serverResponse,i}return e}function Kc(n){const e=Wi(n);function t(s,i){let r=e(s,i);return s.getStatus()===404&&(r=i0(n.path)),r.serverResponse=i.serverResponse,r}return t}function vm(n,e,t){const s=e.fullServerUrl(),i=As(s,n.host,n._protocol),r="GET",o=n.maxOperationRetryTime,l=ne
4957w xn(i,r,Uo(n,t),o);return l.errorHandler=Kc(e),l}function j0(n,e,t){const s=e.fullServerUrl(),i=As(s,n.host,n._protocol),r="GET",o=n.maxOperationRetryTime,l=new xn(i,r,$0(n,t),o);return l.errorHandler=Kc(e),l}function H0(n,e,t,s){const i=e.fullServerUrl(),r=As(i,n.host,n._protocol),o="PATCH",l=Gc(t,s),c={"Content-Type":"application/json; charset=utf-8"},h=n.maxOperationRetryTime,f=new xn(r,o,Uo(n,s),h);return f.headers=c,f.body=l,f.errorHandler=Kc(e),f}function W0(n,e){return n&&n.contentType||e&&e.type()||"application/octet-stream"}function Em(n,e,t){const s=Object.assign({},t);return s.fullPath=n.path,s.size=e.size(),s.contentType||(s.contentType=W0(null,e)),s}function z0(n,e,t,s,i){const r=e.bucketOnlyServerUrl(),o={"X-Goog-Upload-Protocol":"multipart"};function l(){let V="";for(let $=0;$<2;$++)V=V+Math.random().toString().slice(2);return V}const c=l();o["Content-Type"]="multipart/related; boundary="+c;const h=Em(e,s,i),f=Gc(h,t),p="--"+c+`\r
4958Content-Type: application/json; charset=utf-8\r
4959\r
4960`+f+`\r
4961--`+c+`\r
4962Content-Type: `+h.contentType+`\r
4963\r
4964`,g=`\r
4965--`+c+"--",I=$t.getBlob(p,s,g);if(I===null)throw cm();const S={name:h.fullPath},k=As(r,n.host,n._protocol),b="POST",B=n.maxUploadRetryTime,H=new xn(k,b,Uo(n,t),B);return H.urlParams=S,H.headers=o,H.body=I.uploadData(),H.errorHandler=Wi(e),H}class ao{constructor(e,t,s,i){this.current=e,this.total=t,this.finalized=!!s,this.metadata=i||null}}function Qc(n,e){let t=null;try{t=n.getResponseHeader("X-Goog-Upload-Status")}catch{kt(!1)}return kt(!!t&&(e||["active"]).indexOf(t)!==-1),t}function G0(n,e,t,s,i){const r=e.bucketOnlyServerUrl(),o=Em(e,s,i),l={name:o.fullPath},c=As(r,n.host,n._protocol),h="POST",f={"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${s.size()}`,"X-Goog-Upload-Header-Content-Type":o.contentType,"Content-Type":"application/json; charset=utf-8"},p=Gc(o,t),g=n.maxUploadRetryTime;function I(k){Qc(k);let b;try{b=k.getResponseHeader("X-Goog-Upload-URL")}catch{kt(!1)}return kt(Vo(b)),b}const S=new xn(c,h,I,g);return S.urlParams=l,S.headers=f,S.body=p,S.errorHandler=Wi(e),S}function K0(n,e,t,s){const i={"X-Goog-Upload-Command":"query"};function r(h){const f=Qc(h,["active","final"]);let p=null;try{p=h.getResponseHeader("X-Goog-Upload-Size-Received")}catch{kt(!1)}p||kt(!1);const g=Number(p);return kt(!isNaN(g)),new ao(g,s.size(),f==="final")}const o="POST",l=n.maxUploadRetryTime,c=new xn(t,o,r,l);return c.headers=i,c.errorHandler=Wi(e),c}const ef=256*1024;function Q0(n,e,t,s,i,r,o,l){const c=new ao(0,0);if(o?(c.current=o.current,c.total=o.total):(c.current=0,c.total=s.size()),s.size()!==c.total)throw h0();const h=c.total-c.current;let f=h;i>0&&(f=Math.min(f,i));const p=c.current,g=p+f;let I="";f===0?I="finalize":h===f?I="upload, finalize":I="upload";const S={"X-Goog-Upload-Command":I,"X-Goog-Upload-Offset":`${c.current}`},k=s.slice(p,g);if(k===null)throw cm();function b($,me){const te=Qc($,["active","final"]),T=c.current+f,m=s.size();let y;return te==="final"?y=Uo(e,r)($,me):y=null,new ao(T,m,te==="final",y)}const B="POST",H=e.maxUploadRetryTime,V=new xn(t,B,b,H);return V.headers=S,V.body=k.uploadData(),V.progressCallback=l||null,V.errorHandler=Wi(n),V}const We={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function Da(n){switch(n){case"running":case"pausing":case"canceling":return We.RUNNING;case"paused":return We.PAUSED;case"success":return We.SUCCESS;case"canceled":return We.CANCELED;case"error":return We.ERROR;default:return We.ERROR}}/**
4966 * @license
4967 * Copyright 2017 Google LLC
4968 *
4969 * Licensed under the Apache License, Version 2.0 (the "License");
4970 * you may not use this file except in compliance with the License.
4971 * You may obtain a copy of the License at
4972 *
4973 *   http://www.apache.org/licenses/LICENSE-2.0
4974 *
4975 * Unless required by applicable law or agreed to in writing, software
4976 * distributed under the License is distributed on an "AS IS" BASIS,
4977 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4978 * See the License for the specific language governing permissions and
4979 * limitations under the License.
4980 */class Y0{constructor(e,t,s){if(v0(e)||t!=null||s!=null)this.next=e,this.error=t??void 0,this.complete=s??void 0;else{const r=e;this.next=r.next,this.error=r.error,this.complete=r.complete}}}/**
4981 * @license
4982 * Copyright 2017 Google LLC
4983 *
4984 * Licensed under the Apache License, Version 2.0 (the "License");
4985 * you may not use this file except in compliance with the License.
4986 * You may obtain a copy of the License at
4987 *
4988 *   http://www.apache.org/licenses/LICENSE-2.0
4989 *
4990 * Unless required by applicable law or agreed to in writing, software
4991 * distributed under the License is distributed on an "AS IS" BASIS,
4992 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4993 * See the License for the specific language governing permissions and
4994 * limitations under the License.
4995 */function Bn(n){return(...e)=>{Promise.resolve().then(()=>n(...e))}}class X0{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=In.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=In.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=In.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,t,s,i){if(this.sent_)throw Ks("cannot .send() more than once");if(this.sent_=!0,this.xhr_.open(t,e,!0),i!==void 0)for(const r in i)i.hasOwnProperty(r)&&this.xhr_.setRequestHeader(r,i[r].toString());return s!==void 0?this.xhr_.send(s):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw Ks("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw Ks("cannot .getStatus() before sending");try{return this.xhr_.status}catch{return-1}}getResponse(){if(!this.sent_)throw Ks("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw Ks("cannot .getErrorText() before sending");return this.xhr_.statusText}abort(){this.xhr_.abort()}getResponseHeader(e){return this.xhr_.getResponseHeader(e)}addUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.addEventListener("progress",e)}removeUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.removeEventListener("progress",e)}}class J0 extends X0{initXhr(){this.xhr_.responseType="text"}}function jt(){return new J0}/**
4996 * @license
4997 * Copyright 2017 Google LLC
4998 *
4999 * Licensed under the Apache License, Version 2.0 (the "License");
5000 * you may not use this file except in compliance with the License.
5001 * You may obtain a copy of the License at
5002 *
5003 *   http://www.apache.org/licenses/LICENSE-2.0
5004 *
5005 * Unless required by applicable law or agreed to in writing, software
5006 * distributed under the License is distributed on an "AS IS" BASIS,
5007 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5008 * See the License for the specific language governing permissions and
5009 * limitations under the License.
5010 */class Z0{constructor(e,t,s=null){this._transferred=0,this._needToFetchStatus=!1,this._needToFetchMetadata=!1,this._observers=[],this._error=void 0,this._uploadUrl=void 0,this._request=void 0,this._chunkMultiplier=1,this._resolve=void 0,this._reject=void 0,this._ref=e,this._blob=t,this._metadata=s,this._mappings=Fo(),this._resumable=this._shouldDoResumable(this._blob),this._state="running",this._errorHandler=i=>{if(this._request=void 0,this._chunkMultiplier=1,i._codeEquals(ae.CANCELED))this._needToFetchStatus=!0,this.completeTransitions_();else{const r=this.isExponentialBackoffExpired();if(dm(i.status,[]))if(r)i=am();else{this.sleepTime=Math.max(this.sleepTime*2,s0),this._needToFetchStatus=!0,this.completeTransitions_();return}this._error=i,this._transition("error")}},this._metadataErrorHandler=i=>{this._request=void 0,i._codeEquals(ae.CANCELED)?this.completeTransitions_():(this._error=i,this._transition("error"))},this.sleepTime=0,this.maxSleepTime=this._ref.storage.maxUploadRetryTime,this._promise=new Promise((i,r)=>{this._resolve=i,this._reject=r,this._start()}),this._promise.then(null,()=>{})}isExponentialBackoffExpired(){return this.sleepTime>this.maxSleepTime}_makeProgressCallback(){const e=this._transferred;return t=>this._updateProgress(e+t)}_shouldDoResumable(e){return e.size()>256*1024}_start(){this._state==="running"&&this._request===void 0&&(this._resumable?this._uploadUrl===void 0?this._createResumable():this._needToFetchStatus?this._fetchStatus():this._needToFetchMetadata?this._fetchMetadata():this.pendingTimeout=setTimeout(()=>{this.pendingTimeout=void 0,this._continueUpload()},this.sleepTime):this._oneShotUpload())}_resolveToken(e){Promise.all([this._ref.storage._getAuthToken(),this._ref.storage._getAppCheckToken()]).then(([t,s])=>{switch(this._state){case"running":e(t,s);break;case"canceling":this._transition("canceled");break;case"pausing":this._transition("paused");break}})}_createResumable(){this._resolveToken((e,t)=>{const s=G0(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),i=this._ref.storage._makeRequest
vendor: 4,422 bytes, lines 5010-5014
5010(s,jt,e,t);this._request=i,i.getPromise().then(r=>{this._request=void 0,this._uploadUrl=r,this._needToFetchStatus=!1,this.completeTransitions_()},this._errorHandler)})}_fetchStatus(){const e=this._uploadUrl;this._resolveToken((t,s)=>{const i=K0(this._ref.storage,this._ref._location,e,this._blob),r=this._ref.storage._makeRequest(i,jt,t,s);this._request=r,r.getPromise().then(o=>{o=o,this._request=void 0,this._updateProgress(o.current),this._needToFetchStatus=!1,o.finalized&&(this._needToFetchMetadata=!0),this.completeTransitions_()},this._errorHandler)})}_continueUpload(){const e=ef*this._chunkMultiplier,t=new ao(this._transferred,this._blob.size()),s=this._uploadUrl;this._resolveToken((i,r)=>{let o;try{o=Q0(this._ref._location,this._ref.storage,s,this._blob,e,this._mappings,t,this._makeProgressCallback())}catch(c){this._error=c,this._transition("error");return}const l=this._ref.storage._makeRequest(o,jt,i,r,!1);this._request=l,l.getPromise().then(c=>{this._increaseMultiplier(),this._request=void 0,this._updateProgress(c.current),c.finalized?(this._metadata=c.metadata,this._transition("success")):this.completeTransitions_()},this._errorHandler)})}_increaseMultiplier(){ef*this._chunkMultiplier*2<32*1024*1024&&(this._chunkMultiplier*=2)}_fetchMetadata(){this._resolveToken((e,t)=>{const s=vm(this._ref.storage,this._ref._location,this._mappings),i=this._ref.storage._makeRequest(s,jt,e,t);this._request=i,i.getPromise().then(r=>{this._request=void 0,this._metadata=r,this._transition("success")},this._metadataErrorHandler)})}_oneShotUpload(){this._resolveToken((e,t)=>{const s=z0(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),i=this._ref.storage._makeRequest(s,jt,e,t);this._request=i,i.getPromise().then(r=>{this._request=void 0,this._metadata=r,this._updateProgress(this._blob.size()),this._transition("success")},this._errorHandler)})}_updateProgress(e){const t=this._transferred;this._transferred=e,this._transferred!==t&&this._notifyObservers()}_transition(e){if(this._state!==e)switch(e){case"canceling":case"pausing":this._state=e,this._request!==void 0?this._request.cancel():this.pendingTimeout&&(clearTimeout(this.pendingTimeout),this.pendingTimeout=void 0,this.completeTransitions_());break;case"running":const t=this._state==="paused";this._state=e,t&&(this._notifyObservers(),this._start());break;case"paused":this._state=e,this._notifyObservers();break;case"canceled":this._error=lm(),this._state=e,this._notifyObservers();break;case"error":this._state=e,this._notifyObservers();break;case"success":this._state=e,this._notifyObservers();break}}completeTransitions_(){switch(this._state){case"pausing":this._transition("paused");break;case"canceling":this._transition("canceled");break;case"running":this._start();break}}get snapshot(){const e=Da(this._state);return{bytesTransferred:this._transferred,totalBytes:this._blob.size(),state:e,metadata:this._metadata,task:this,ref:this._ref}}on(e,t,s,i){const r=new Y0(t||void 0,s||void 0,i||void 0);return this._addObserver(r),()=>{this._removeObserver(r)}}then(e,t){return this._promise.then(e,t)}catch(e){return this.then(null,e)}_addObserver(e){this._observers.push(e),this._notifyObserver(e)}_removeObserver(e){const t=this._observers.indexOf(e);t!==-1&&this._observers.splice(t,1)}_notifyObservers(){this._finishPromise(),this._observers.slice().forEach(t=>{this._notifyObserver(t)})}_finishPromise(){if(this._resolve!==void 0){let e=!0;switch(Da(this._state)){case We.SUCCESS:Bn(this._resolve.bind(null,this.snapshot))();break;case We.CANCELED:case We.ERROR:const t=this._reject;Bn(t.bind(null,this._error))();break;default:e=!1;break}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(Da(this._state)){case We.RUNNING:case We.PAUSED:e.next&&Bn(e.next.bind(e,this.snapshot))();break;case We.SUCCESS:e.complete&&Bn(e.complete.bind(e))();break;case We.CANCELED:case We.ERROR:e.error&&Bn(e.error.bind(e,this._error))();break;default:e.error&&Bn(e.error.bind(e,this._error))()}}resume(){const e=this._state==="paused"||this._state==="pausing";return e&&this._transition("running"),e}pause(){const e=this._state==="running";return e&&this._transition("pausing"),e}cancel(){const e=this._state==="running"||this._state==="pausing";return e&&this._transition("canceling"),e}}/**
5011 * @license
5012 * Copyright 2019 Google LLC
5013 *
5014 * Licensed under the Apache License, Version 2.0 (the "License");
5015 * you may not use this file except in compliance with the License.
5016 * You may obtain a copy of the License at
5017 *
5018 *   http://www.apache.org/licenses/LICENSE-2.0
5019 *
5020 * Unless required by applicable law or agreed to in writing, software
5021 * distributed under the License is distributed on an "AS IS" BASIS,
5022 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5023 * See the License for the specific language governing permissions and
5024 * limitations under the License.
5025 */class lo{constructor(e,t){this._service=e,t instanceof Ze?this._location=t:this._location=Ze.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new lo(e,t)}get root(){const e=new Ze(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return mm(this._location.path)}get storage(){return this._service}get parent(){const e=L0(this._location.path);if(e===null)return null;const t=new Ze(this._location.bucket,e);return new lo(this._service,t)}_throwIfRoot(e){if(this._location.path==="")throw p0(e)}}function eP(n,e,t){return n._throwIfRoot("uploadBytesResumable"),new Z0(n,new $t(e),t)}function tP(n){n._throwIfRoot("getMetadata");const e=vm(n.storage,n._location,Fo());return n.storage.makeRequestWithTokens(e,jt)}function nP(n,e){n._throwIfRoot("updateMetadata");const t=H0(n.storage,n._location,e,Fo());return n.storage.makeRequestWithTokens(t,jt)}function sP(n){n._throwIfRoot("getDownloadURL");const e=j0(n.storage,n._location,Fo());return n.storage.makeRequestWithTokens(e,jt).then(t=>{if(t===null)throw d0();return t})}function tf(n,e){const t=e==null?void 0:e[e0];return t==null?null:Ze.makeFromBucketSpec(t,n)}function iP(n,e,t,s={}){n.host=`${e}:${t}`,n._protocol="http";const{mockUserToken:i}=s;i&&(n._overrideAuthToken=typeof i=="string"?i:El(i,n.app.options.projectId))}class rP{constructor(e,t,s,i,r){this.app=e,this._authProvider=t,this._appCheckProvider=s,this._url=i,this._firebaseVersion=r,this._bucket=null,this._host=om,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=t0,this._maxUploadRetryTime=n0,this._requests=new Set,i!=null?this._bucket=Ze.makeFromBucketSpec(i,this._host):this._bucket=tf(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,this._url!=null?this._bucket=Ze.makeFromBucketSpec(this._url,e):this._bucket=tf(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){Zd("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){Zd("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;const e=this._authProvider.getImmediate({optional:!0});if(e){const t=await e.getToken();if(t!==null)return t.accessToken}return null}async _getAppCheckToken(){const e=this._appCheckProvider.getImmediate({optional:!0});return e?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new lo(this,e)}_makeRequest(e,t,s,i,r=!0){if(this._deleted)return new _0(um());{const o=R0(e,this._appId,s,i,t,this._firebaseVersion,r);return this._requests.add(o),o.getPromise().then(()=>this._requests.delete(o),()=>this._requests.delete(o)),o}}async makeRequestWithTokens(e,t){const[s,i]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,s,i).getPromise()}}const nf="@firebase/storage",sf="0.13.2";/**
5026 * @license
5027 * Copyright 2020 Google LLC
5028 *
5029 * Licensed under the Apache License, Version 2.0 (the "License");
5030 * you may not use this file except in compliance with the License.
5031 * You may obtain a copy of the License at
5032 *
5033 *   http://www.apache.org/licenses/LICENSE-2.0
5034 *
5035 * Unless required by applicable law or agreed to in writing, softw
5035are
5036 * distributed under the License is distributed on an "AS IS" BASIS,
5037 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5038 * See the License for the specific language governing permissions and
5039 * limitations under the License.
5040 */const Tm="storage";function MP(n,e,t){return n=le(n),eP(n,e,t)}function LP(n){return n=le(n),tP(n)}function VP(n,e){return n=le(n),nP(n,e)}function FP(n){return n=le(n),sP(n)}function UP(n=vs(),e){n=le(n);const s=gt(n,Tm).getImmediate({identifier:e}),i=vl("storage");return i&&oP(s,...i),s}function oP(n,e,t,s={}){iP(n,e,t,s)}function aP(n,{instanceIdentifier:e}){const t=n.getProvider("app").getImmediate(),s=n.getProvider("auth-internal"),i=n.getProvider("app-check-internal");return new rP(t,s,i,e,ln)}function lP(){Ge(new He(Tm,aP,"PUBLIC").setMultipleInstances(!0)),Re(nf,sf,""),Re(nf,sf,"esm2017")}lP();export{hP as A,yv as B,dP as C,_P as D,fP as E,pP as F,Gb as G,gP as H,mP as I,ze as T,_p as a,up as b,SP as c,UP as d,NP as e,MP as f,vs as g,LP as h,yP as i,VP as j,FP as k,TP as l,wP as m,RP as n,vP as o,CP as p,AP as q,IP as r,DP as s,xP as t,kT as u,OP as v,Ap as w,vp as x,Ml as y,bp as z};
5041//# sourceMappingURL=firebase-CJnrmy_C.js.map

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.