@purr-core/services.firebase 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";const Qr=require("@purr-core/utils.helpers");/**
1
+ "use strict";const Ee=require("@purr-core/utils.helpers");/**
2
2
  * @license
3
3
  * Copyright 2017 Google LLC
4
4
  *
@@ -118,7 +118,7 @@
118
118
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
119
119
  * See the License for the specific language governing permissions and
120
120
  * limitations under the License.
121
- */const nm="FirebaseError";class un extends Error{constructor(t,e,n){super(e),this.code=t,this.customData=n,this.name=nm,Object.setPrototypeOf(this,un.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,fl.prototype.create)}}class fl{constructor(t,e,n){this.service=t,this.serviceName=e,this.errors=n}create(t,...e){const n=e[0]||{},i=`${this.service}/${t}`,s=this.errors[t],a=s?rm(s,n):"Error",u=`${this.serviceName}: ${a} (${i}).`;return new un(i,u,n)}}function rm(r,t){return r.replace(im,(e,n)=>{const i=t[n];return i!=null?String(i):`<${n}?>`})}const im=/\{\$([^}]+)}/g;function Ye(r,t){if(r===t)return!0;const e=Object.keys(r),n=Object.keys(t);for(const i of e){if(!n.includes(i))return!1;const s=r[i],a=t[i];if(Bu(s)&&Bu(a)){if(!Ye(s,a))return!1}else if(s!==a)return!1}for(const i of n)if(!e.includes(i))return!1;return!0}function Bu(r){return r!==null&&typeof r=="object"}/**
121
+ */const nm="FirebaseError";class cn extends Error{constructor(t,e,n){super(e),this.code=t,this.customData=n,this.name=nm,Object.setPrototypeOf(this,cn.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,fl.prototype.create)}}class fl{constructor(t,e,n){this.service=t,this.serviceName=e,this.errors=n}create(t,...e){const n=e[0]||{},i=`${this.service}/${t}`,s=this.errors[t],a=s?rm(s,n):"Error",u=`${this.serviceName}: ${a} (${i}).`;return new cn(i,u,n)}}function rm(r,t){return r.replace(im,(e,n)=>{const i=t[n];return i!=null?String(i):`<${n}?>`})}const im=/\{\$([^}]+)}/g;function Xe(r,t){if(r===t)return!0;const e=Object.keys(r),n=Object.keys(t);for(const i of e){if(!n.includes(i))return!1;const s=r[i],a=t[i];if(Bu(s)&&Bu(a)){if(!Xe(s,a))return!1}else if(s!==a)return!1}for(const i of n)if(!e.includes(i))return!1;return!0}function Bu(r){return r!==null&&typeof r=="object"}/**
122
122
  * @license
123
123
  * Copyright 2021 Google LLC
124
124
  *
@@ -133,7 +133,7 @@
133
133
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
134
134
  * See the License for the specific language governing permissions and
135
135
  * limitations under the License.
136
- */function yt(r){return r&&r._delegate?r._delegate:r}class bn{constructor(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(t){return this.instantiationMode=t,this}setMultipleInstances(t){return this.multipleInstances=t,this}setServiceProps(t){return this.serviceProps=t,this}setInstanceCreatedCallback(t){return this.onInstanceCreated=t,this}}/**
136
+ */function yt(r){return r&&r._delegate?r._delegate:r}class Pn{constructor(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(t){return this.instantiationMode=t,this}setMultipleInstances(t){return this.multipleInstances=t,this}setServiceProps(t){return this.serviceProps=t,this}setInstanceCreatedCallback(t){return this.onInstanceCreated=t,this}}/**
137
137
  * @license
138
138
  * Copyright 2019 Google LLC
139
139
  *
@@ -148,7 +148,7 @@
148
148
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
149
149
  * See the License for the specific language governing permissions and
150
150
  * limitations under the License.
151
- */const ze="[DEFAULT]";/**
151
+ */const je="[DEFAULT]";/**
152
152
  * @license
153
153
  * Copyright 2019 Google LLC
154
154
  *
@@ -163,7 +163,7 @@
163
163
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
164
164
  * See the License for the specific language governing permissions and
165
165
  * limitations under the License.
166
- */class sm{constructor(t,e){this.name=t,this.container=e,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(t){const e=this.normalizeInstanceIdentifier(t);if(!this.instancesDeferred.has(e)){const n=new Xf;if(this.instancesDeferred.set(e,n),this.isInitialized(e)||this.shouldAutoInitialize())try{const i=this.getOrInitializeService({instanceIdentifier:e});i&&n.resolve(i)}catch{}}return this.instancesDeferred.get(e).promise}getImmediate(t){var e;const n=this.normalizeInstanceIdentifier(t==null?void 0:t.identifier),i=(e=t==null?void 0:t.optional)!==null&&e!==void 0?e:!1;if(this.isInitialized(n)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:n})}catch(s){if(i)return null;throw s}else{if(i)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(t){if(t.name!==this.name)throw Error(`Mismatching Component ${t.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=t,!!this.shouldAutoInitialize()){if(am(t))try{this.getOrInitializeService({instanceIdentifier:ze})}catch{}for(const[e,n]of this.instancesDeferred.entries()){const i=this.normalizeInstanceIdentifier(e);try{const s=this.getOrInitializeService({instanceIdentifier:i});n.resolve(s)}catch{}}}}clearInstance(t=ze){this.instancesDeferred.delete(t),this.instancesOptions.delete(t),this.instances.delete(t)}async delete(){const t=Array.from(this.instances.values());await Promise.all([...t.filter(e=>"INTERNAL"in e).map(e=>e.INTERNAL.delete()),...t.filter(e=>"_delete"in e).map(e=>e._delete())])}isComponentSet(){return this.component!=null}isInitialized(t=ze){return this.instances.has(t)}getOptions(t=ze){return this.instancesOptions.get(t)||{}}initialize(t={}){const{options:e={}}=t,n=this.normalizeInstanceIdentifier(t.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const i=this.getOrInitializeService({instanceIdentifier:n,options:e});for(const[s,a]of this.instancesDeferred.entries()){const u=this.normalizeInstanceIdentifier(s);n===u&&a.resolve(i)}return i}onInit(t,e){var n;const i=this.normalizeInstanceIdentifier(e),s=(n=this.onInitCallbacks.get(i))!==null&&n!==void 0?n:new Set;s.add(t),this.onInitCallbacks.set(i,s);const a=this.instances.get(i);return a&&t(a,i),()=>{s.delete(t)}}invokeOnInitCallbacks(t,e){const n=this.onInitCallbacks.get(e);if(n)for(const i of n)try{i(t,e)}catch{}}getOrInitializeService({instanceIdentifier:t,options:e={}}){let n=this.instances.get(t);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:om(t),options:e}),this.instances.set(t,n),this.instancesOptions.set(t,e),this.invokeOnInitCallbacks(n,t),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,t,n)}catch{}return n||null}normalizeInstanceIdentifier(t=ze){return this.component?this.component.multipleInstances?t:ze:t}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function om(r){return r===ze?void 0:r}function am(r){return r.instantiationMode==="EAGER"}/**
166
+ */class sm{constructor(t,e){this.name=t,this.container=e,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(t){const e=this.normalizeInstanceIdentifier(t);if(!this.instancesDeferred.has(e)){const n=new Xf;if(this.instancesDeferred.set(e,n),this.isInitialized(e)||this.shouldAutoInitialize())try{const i=this.getOrInitializeService({instanceIdentifier:e});i&&n.resolve(i)}catch{}}return this.instancesDeferred.get(e).promise}getImmediate(t){var e;const n=this.normalizeInstanceIdentifier(t==null?void 0:t.identifier),i=(e=t==null?void 0:t.optional)!==null&&e!==void 0?e:!1;if(this.isInitialized(n)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:n})}catch(s){if(i)return null;throw s}else{if(i)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(t){if(t.name!==this.name)throw Error(`Mismatching Component ${t.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=t,!!this.shouldAutoInitialize()){if(am(t))try{this.getOrInitializeService({instanceIdentifier:je})}catch{}for(const[e,n]of this.instancesDeferred.entries()){const i=this.normalizeInstanceIdentifier(e);try{const s=this.getOrInitializeService({instanceIdentifier:i});n.resolve(s)}catch{}}}}clearInstance(t=je){this.instancesDeferred.delete(t),this.instancesOptions.delete(t),this.instances.delete(t)}async delete(){const t=Array.from(this.instances.values());await Promise.all([...t.filter(e=>"INTERNAL"in e).map(e=>e.INTERNAL.delete()),...t.filter(e=>"_delete"in e).map(e=>e._delete())])}isComponentSet(){return this.component!=null}isInitialized(t=je){return this.instances.has(t)}getOptions(t=je){return this.instancesOptions.get(t)||{}}initialize(t={}){const{options:e={}}=t,n=this.normalizeInstanceIdentifier(t.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const i=this.getOrInitializeService({instanceIdentifier:n,options:e});for(const[s,a]of this.instancesDeferred.entries()){const u=this.normalizeInstanceIdentifier(s);n===u&&a.resolve(i)}return i}onInit(t,e){var n;const i=this.normalizeInstanceIdentifier(e),s=(n=this.onInitCallbacks.get(i))!==null&&n!==void 0?n:new Set;s.add(t),this.onInitCallbacks.set(i,s);const a=this.instances.get(i);return a&&t(a,i),()=>{s.delete(t)}}invokeOnInitCallbacks(t,e){const n=this.onInitCallbacks.get(e);if(n)for(const i of n)try{i(t,e)}catch{}}getOrInitializeService({instanceIdentifier:t,options:e={}}){let n=this.instances.get(t);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:om(t),options:e}),this.instances.set(t,n),this.instancesOptions.set(t,e),this.invokeOnInitCallbacks(n,t),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,t,n)}catch{}return n||null}normalizeInstanceIdentifier(t=je){return this.component?this.component.multipleInstances?t:je:t}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function om(r){return r===je?void 0:r}function am(r){return r.instantiationMode==="EAGER"}/**
167
167
  * @license
168
168
  * Copyright 2019 Google LLC
169
169
  *
@@ -238,7 +238,7 @@
238
238
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
239
239
  * See the License for the specific language governing permissions and
240
240
  * limitations under the License.
241
- */const kr="[DEFAULT]",Zm={[$i]:"fire-core",[bm]:"fire-core-compat",[Sm]:"fire-analytics",[Pm]:"fire-analytics-compat",[Cm]:"fire-app-check",[Vm]:"fire-app-check-compat",[Dm]:"fire-auth",[xm]:"fire-auth-compat",[Nm]:"fire-rtdb",[km]:"fire-data-connect",[Fm]:"fire-rtdb-compat",[Mm]:"fire-fn",[Om]:"fire-fn-compat",[Lm]:"fire-iid",[Bm]:"fire-iid-compat",[Um]:"fire-fcm",[qm]:"fire-fcm-compat",[zm]:"fire-perf",[jm]:"fire-perf-compat",[Gm]:"fire-rc",[Km]:"fire-rc-compat",[$m]:"fire-gcs",[Qm]:"fire-gcs-compat",[Wm]:"fire-fst",[Jm]:"fire-fst-compat",[Hm]:"fire-vertex","fire-js":"fire-js",[Ym]:"fire-js-all"};/**
241
+ */const Fr="[DEFAULT]",Zm={[$i]:"fire-core",[bm]:"fire-core-compat",[Sm]:"fire-analytics",[Pm]:"fire-analytics-compat",[Cm]:"fire-app-check",[Vm]:"fire-app-check-compat",[Dm]:"fire-auth",[xm]:"fire-auth-compat",[Nm]:"fire-rtdb",[km]:"fire-data-connect",[Fm]:"fire-rtdb-compat",[Mm]:"fire-fn",[Om]:"fire-fn-compat",[Lm]:"fire-iid",[Bm]:"fire-iid-compat",[Um]:"fire-fcm",[qm]:"fire-fcm-compat",[zm]:"fire-perf",[jm]:"fire-perf-compat",[Gm]:"fire-rc",[Km]:"fire-rc-compat",[$m]:"fire-gcs",[Qm]:"fire-gcs-compat",[Wm]:"fire-fst",[Jm]:"fire-fst-compat",[Hm]:"fire-vertex","fire-js":"fire-js",[Ym]:"fire-js-all"};/**
242
242
  * @license
243
243
  * Copyright 2019 Google LLC
244
244
  *
@@ -253,7 +253,7 @@
253
253
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
254
254
  * See the License for the specific language governing permissions and
255
255
  * limitations under the License.
256
- */const Ee=new Map,Pn=new Map,Sn=new Map;function fo(r,t){try{r.container.addComponent(t)}catch(e){ee.debug(`Component ${t.name} failed to register with FirebaseApp ${r.name}`,e)}}function tg(r,t){r.container.addOrOverwriteComponent(t)}function Fr(r){const t=r.name;if(Sn.has(t))return ee.debug(`There were multiple attempts to register component ${t}.`),!1;Sn.set(t,r);for(const e of Ee.values())fo(e,r);for(const e of Pn.values())fo(e,r);return!0}function os(r,t){const e=r.container.getProvider("heartbeat").getImmediate({optional:!0});return e&&e.triggerHeartbeat(),r.container.getProvider(t)}function Il(r,t,e=kr){os(r,t).clearInstance(e)}function El(r){return r.options!==void 0}function eg(r){return r.settings!==void 0}function ng(){Sn.clear()}/**
256
+ */const Te=new Map,Sn=new Map,Vn=new Map;function fo(r,t){try{r.container.addComponent(t)}catch(e){ee.debug(`Component ${t.name} failed to register with FirebaseApp ${r.name}`,e)}}function tg(r,t){r.container.addOrOverwriteComponent(t)}function Mr(r){const t=r.name;if(Vn.has(t))return ee.debug(`There were multiple attempts to register component ${t}.`),!1;Vn.set(t,r);for(const e of Te.values())fo(e,r);for(const e of Sn.values())fo(e,r);return!0}function os(r,t){const e=r.container.getProvider("heartbeat").getImmediate({optional:!0});return e&&e.triggerHeartbeat(),r.container.getProvider(t)}function Il(r,t,e=Fr){os(r,t).clearInstance(e)}function El(r){return r.options!==void 0}function eg(r){return r.settings!==void 0}function ng(){Vn.clear()}/**
257
257
  * @license
258
258
  * Copyright 2019 Google LLC
259
259
  *
@@ -283,7 +283,7 @@
283
283
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
284
284
  * See the License for the specific language governing permissions and
285
285
  * limitations under the License.
286
- */class Tl{constructor(t,e,n){this._isDeleted=!1,this._options=Object.assign({},t),this._config=Object.assign({},e),this._name=e.name,this._automaticDataCollectionEnabled=e.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new bn("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(t){this.checkDestroyed(),this._automaticDataCollectionEnabled=t}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(t){this._isDeleted=t}checkDestroyed(){if(this.isDeleted)throw jt.create("app-deleted",{appName:this._name})}}/**
286
+ */class Tl{constructor(t,e,n){this._isDeleted=!1,this._options=Object.assign({},t),this._config=Object.assign({},e),this._name=e.name,this._automaticDataCollectionEnabled=e.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new Pn("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(t){this.checkDestroyed(),this._automaticDataCollectionEnabled=t}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(t){this._isDeleted=t}checkDestroyed(){if(this.isDeleted)throw jt.create("app-deleted",{appName:this._name})}}/**
287
287
  * @license
288
288
  * Copyright 2023 Google LLC
289
289
  *
@@ -298,7 +298,7 @@
298
298
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
299
299
  * See the License for the specific language governing permissions and
300
300
  * limitations under the License.
301
- */class ig extends Tl{constructor(t,e,n,i){const s=e.automaticDataCollectionEnabled!==void 0?e.automaticDataCollectionEnabled:!1,a={name:n,automaticDataCollectionEnabled:s};if(t.apiKey!==void 0)super(t,a,i);else{const u=t;super(u.options,a,i)}this._serverConfig=Object.assign({automaticDataCollectionEnabled:s},e),this._finalizationRegistry=null,typeof FinalizationRegistry<"u"&&(this._finalizationRegistry=new FinalizationRegistry(()=>{this.automaticCleanup()})),this._refCount=0,this.incRefCount(this._serverConfig.releaseOnDeref),this._serverConfig.releaseOnDeref=void 0,e.releaseOnDeref=void 0,We($i,ho,"serverapp")}toJSON(){}get refCount(){return this._refCount}incRefCount(t){this.isDeleted||(this._refCount++,t!==void 0&&this._finalizationRegistry!==null&&this._finalizationRegistry.register(t,this))}decRefCount(){return this.isDeleted?0:--this._refCount}automaticCleanup(){Rl(this)}get settings(){return this.checkDestroyed(),this._serverConfig}checkDestroyed(){if(this.isDeleted)throw jt.create("server-app-deleted")}}/**
301
+ */class ig extends Tl{constructor(t,e,n,i){const s=e.automaticDataCollectionEnabled!==void 0?e.automaticDataCollectionEnabled:!1,a={name:n,automaticDataCollectionEnabled:s};if(t.apiKey!==void 0)super(t,a,i);else{const u=t;super(u.options,a,i)}this._serverConfig=Object.assign({automaticDataCollectionEnabled:s},e),this._finalizationRegistry=null,typeof FinalizationRegistry<"u"&&(this._finalizationRegistry=new FinalizationRegistry(()=>{this.automaticCleanup()})),this._refCount=0,this.incRefCount(this._serverConfig.releaseOnDeref),this._serverConfig.releaseOnDeref=void 0,e.releaseOnDeref=void 0,He($i,ho,"serverapp")}toJSON(){}get refCount(){return this._refCount}incRefCount(t){this.isDeleted||(this._refCount++,t!==void 0&&this._finalizationRegistry!==null&&this._finalizationRegistry.register(t,this))}decRefCount(){return this.isDeleted?0:--this._refCount}automaticCleanup(){Rl(this)}get settings(){return this.checkDestroyed(),this._serverConfig}checkDestroyed(){if(this.isDeleted)throw jt.create("server-app-deleted")}}/**
302
302
  * @license
303
303
  * Copyright 2019 Google LLC
304
304
  *
@@ -313,7 +313,7 @@
313
313
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
314
314
  * See the License for the specific language governing permissions and
315
315
  * limitations under the License.
316
- */const vl=Xm;function wl(r,t={}){let e=r;typeof t!="object"&&(t={name:t});const n=Object.assign({name:kr,automaticDataCollectionEnabled:!1},t),i=n.name;if(typeof i!="string"||!i)throw jt.create("bad-app-name",{appName:String(i)});if(e||(e=ul()),!e)throw jt.create("no-options");const s=Ee.get(i);if(s){if(Ye(e,s.options)&&Ye(n,s.config))return s;throw jt.create("duplicate-app",{appName:i})}const a=new ml(i);for(const c of Sn.values())a.addComponent(c);const u=new Tl(e,n,a);return Ee.set(i,u),u}function sg(r,t){if(tm()&&!ll())throw jt.create("invalid-server-app-environment");t.automaticDataCollectionEnabled===void 0&&(t.automaticDataCollectionEnabled=!1);let e;El(r)?e=r.options:e=r;const n=Object.assign(Object.assign({},t),e);n.releaseOnDeref!==void 0&&delete n.releaseOnDeref;const i=h=>[...h].reduce((f,g)=>Math.imul(31,f)+g.charCodeAt(0)|0,0);if(t.releaseOnDeref!==void 0&&typeof FinalizationRegistry>"u")throw jt.create("finalization-registry-not-supported",{});const s=""+i(JSON.stringify(n)),a=Pn.get(s);if(a)return a.incRefCount(t.releaseOnDeref),a;const u=new ml(s);for(const h of Sn.values())u.addComponent(h);const c=new ig(e,t,s,u);return Pn.set(s,c),c}function Al(r=kr){const t=Ee.get(r);if(!t&&r===kr&&ul())return wl();if(!t)throw jt.create("no-app",{appName:r});return t}function og(){return Array.from(Ee.values())}async function Rl(r){let t=!1;const e=r.name;Ee.has(e)?(t=!0,Ee.delete(e)):Pn.has(e)&&r.decRefCount()<=0&&(Pn.delete(e),t=!0),t&&(await Promise.all(r.container.getProviders().map(n=>n.delete())),r.isDeleted=!0)}function We(r,t,e){var n;let i=(n=Zm[r])!==null&&n!==void 0?n:r;e&&(i+=`-${e}`);const s=i.match(/\s|\//),a=t.match(/\s|\//);if(s||a){const u=[`Unable to register library "${i}" with version "${t}":`];s&&u.push(`library name "${i}" contains illegal characters (whitespace or "/")`),s&&a&&u.push("and"),a&&u.push(`version name "${t}" contains illegal characters (whitespace or "/")`),ee.warn(u.join(" "));return}Fr(new bn(`${i}-version`,()=>({library:i,version:t}),"VERSION"))}function ag(r,t){if(r!==null&&typeof r!="function")throw jt.create("invalid-log-argument");dm(r,t)}function ug(r){hm(r)}/**
316
+ */const vl=Xm;function wl(r,t={}){let e=r;typeof t!="object"&&(t={name:t});const n=Object.assign({name:Fr,automaticDataCollectionEnabled:!1},t),i=n.name;if(typeof i!="string"||!i)throw jt.create("bad-app-name",{appName:String(i)});if(e||(e=ul()),!e)throw jt.create("no-options");const s=Te.get(i);if(s){if(Xe(e,s.options)&&Xe(n,s.config))return s;throw jt.create("duplicate-app",{appName:i})}const a=new ml(i);for(const c of Vn.values())a.addComponent(c);const u=new Tl(e,n,a);return Te.set(i,u),u}function sg(r,t){if(tm()&&!ll())throw jt.create("invalid-server-app-environment");t.automaticDataCollectionEnabled===void 0&&(t.automaticDataCollectionEnabled=!1);let e;El(r)?e=r.options:e=r;const n=Object.assign(Object.assign({},t),e);n.releaseOnDeref!==void 0&&delete n.releaseOnDeref;const i=h=>[...h].reduce((f,g)=>Math.imul(31,f)+g.charCodeAt(0)|0,0);if(t.releaseOnDeref!==void 0&&typeof FinalizationRegistry>"u")throw jt.create("finalization-registry-not-supported",{});const s=""+i(JSON.stringify(n)),a=Sn.get(s);if(a)return a.incRefCount(t.releaseOnDeref),a;const u=new ml(s);for(const h of Vn.values())u.addComponent(h);const c=new ig(e,t,s,u);return Sn.set(s,c),c}function Al(r=Fr){const t=Te.get(r);if(!t&&r===Fr&&ul())return wl();if(!t)throw jt.create("no-app",{appName:r});return t}function og(){return Array.from(Te.values())}async function Rl(r){let t=!1;const e=r.name;Te.has(e)?(t=!0,Te.delete(e)):Sn.has(e)&&r.decRefCount()<=0&&(Sn.delete(e),t=!0),t&&(await Promise.all(r.container.getProviders().map(n=>n.delete())),r.isDeleted=!0)}function He(r,t,e){var n;let i=(n=Zm[r])!==null&&n!==void 0?n:r;e&&(i+=`-${e}`);const s=i.match(/\s|\//),a=t.match(/\s|\//);if(s||a){const u=[`Unable to register library "${i}" with version "${t}":`];s&&u.push(`library name "${i}" contains illegal characters (whitespace or "/")`),s&&a&&u.push("and"),a&&u.push(`version name "${t}" contains illegal characters (whitespace or "/")`),ee.warn(u.join(" "));return}Mr(new Pn(`${i}-version`,()=>({library:i,version:t}),"VERSION"))}function ag(r,t){if(r!==null&&typeof r!="function")throw jt.create("invalid-log-argument");dm(r,t)}function ug(r){hm(r)}/**
317
317
  * @license
318
318
  * Copyright 2021 Google LLC
319
319
  *
@@ -328,7 +328,7 @@
328
328
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
329
329
  * See the License for the specific language governing permissions and
330
330
  * limitations under the License.
331
- */const cg="firebase-heartbeat-database",lg=1,Mr="firebase-heartbeat-store";let no=null;function bl(){return no||(no=Tm(cg,lg,{upgrade:(r,t)=>{switch(t){case 0:try{r.createObjectStore(Mr)}catch(e){console.warn(e)}}}}).catch(r=>{throw jt.create("idb-open",{originalErrorMessage:r.message})})),no}async function hg(r){try{const e=(await bl()).transaction(Mr),n=await e.objectStore(Mr).get(Pl(r));return await e.done,n}catch(t){if(t instanceof un)ee.warn(t.message);else{const e=jt.create("idb-get",{originalErrorMessage:t==null?void 0:t.message});ee.warn(e.message)}}}async function ju(r,t){try{const n=(await bl()).transaction(Mr,"readwrite");await n.objectStore(Mr).put(t,Pl(r)),await n.done}catch(e){if(e instanceof un)ee.warn(e.message);else{const n=jt.create("idb-set",{originalErrorMessage:e==null?void 0:e.message});ee.warn(n.message)}}}function Pl(r){return`${r.name}!${r.options.appId}`}/**
331
+ */const cg="firebase-heartbeat-database",lg=1,Or="firebase-heartbeat-store";let no=null;function bl(){return no||(no=Tm(cg,lg,{upgrade:(r,t)=>{switch(t){case 0:try{r.createObjectStore(Or)}catch(e){console.warn(e)}}}}).catch(r=>{throw jt.create("idb-open",{originalErrorMessage:r.message})})),no}async function hg(r){try{const e=(await bl()).transaction(Or),n=await e.objectStore(Or).get(Pl(r));return await e.done,n}catch(t){if(t instanceof cn)ee.warn(t.message);else{const e=jt.create("idb-get",{originalErrorMessage:t==null?void 0:t.message});ee.warn(e.message)}}}async function ju(r,t){try{const n=(await bl()).transaction(Or,"readwrite");await n.objectStore(Or).put(t,Pl(r)),await n.done}catch(e){if(e instanceof cn)ee.warn(e.message);else{const n=jt.create("idb-set",{originalErrorMessage:e==null?void 0:e.message});ee.warn(n.message)}}}function Pl(r){return`${r.name}!${r.options.appId}`}/**
332
332
  * @license
333
333
  * Copyright 2021 Google LLC
334
334
  *
@@ -358,29 +358,29 @@
358
358
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
359
359
  * See the License for the specific language governing permissions and
360
360
  * limitations under the License.
361
- */function _g(r){Fr(new bn("platform-logger",t=>new Am(t),"PRIVATE")),Fr(new bn("heartbeat",t=>new mg(t),"PRIVATE")),We($i,ho,r),We($i,ho,"esm2017"),We("fire-js","")}_g("");var $u=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
361
+ */function _g(r){Mr(new Pn("platform-logger",t=>new Am(t),"PRIVATE")),Mr(new Pn("heartbeat",t=>new mg(t),"PRIVATE")),He($i,ho,r),He($i,ho,"esm2017"),He("fire-js","")}_g("");var $u=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
362
362
  Copyright The Closure Library Authors.
363
363
  SPDX-License-Identifier: Apache-2.0
364
- */var He,Sl;(function(){var r;/** @license
364
+ */var Je,Sl;(function(){var r;/** @license
365
365
 
366
366
  Copyright The Closure Library Authors.
367
367
  SPDX-License-Identifier: Apache-2.0
368
- */function t(E,p){function I(){}I.prototype=p.prototype,E.D=p.prototype,E.prototype=new I,E.prototype.constructor=E,E.C=function(T,v,b){for(var y=Array(arguments.length-2),Yt=2;Yt<arguments.length;Yt++)y[Yt-2]=arguments[Yt];return p.prototype[v].apply(T,y)}}function e(){this.blockSize=-1}function n(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.B=Array(this.blockSize),this.o=this.h=0,this.s()}t(n,e),n.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(E,p,I){I||(I=0);var T=Array(16);if(typeof p=="string")for(var v=0;16>v;++v)T[v]=p.charCodeAt(I++)|p.charCodeAt(I++)<<8|p.charCodeAt(I++)<<16|p.charCodeAt(I++)<<24;else for(v=0;16>v;++v)T[v]=p[I++]|p[I++]<<8|p[I++]<<16|p[I++]<<24;p=E.g[0],I=E.g[1],v=E.g[2];var b=E.g[3],y=p+(b^I&(v^b))+T[0]+3614090360&4294967295;p=I+(y<<7&4294967295|y>>>25),y=b+(v^p&(I^v))+T[1]+3905402710&4294967295,b=p+(y<<12&4294967295|y>>>20),y=v+(I^b&(p^I))+T[2]+606105819&4294967295,v=b+(y<<17&4294967295|y>>>15),y=I+(p^v&(b^p))+T[3]+3250441966&4294967295,I=v+(y<<22&4294967295|y>>>10),y=p+(b^I&(v^b))+T[4]+4118548399&4294967295,p=I+(y<<7&4294967295|y>>>25),y=b+(v^p&(I^v))+T[5]+1200080426&4294967295,b=p+(y<<12&4294967295|y>>>20),y=v+(I^b&(p^I))+T[6]+2821735955&4294967295,v=b+(y<<17&4294967295|y>>>15),y=I+(p^v&(b^p))+T[7]+4249261313&4294967295,I=v+(y<<22&4294967295|y>>>10),y=p+(b^I&(v^b))+T[8]+1770035416&4294967295,p=I+(y<<7&4294967295|y>>>25),y=b+(v^p&(I^v))+T[9]+2336552879&4294967295,b=p+(y<<12&4294967295|y>>>20),y=v+(I^b&(p^I))+T[10]+4294925233&4294967295,v=b+(y<<17&4294967295|y>>>15),y=I+(p^v&(b^p))+T[11]+2304563134&4294967295,I=v+(y<<22&4294967295|y>>>10),y=p+(b^I&(v^b))+T[12]+1804603682&4294967295,p=I+(y<<7&4294967295|y>>>25),y=b+(v^p&(I^v))+T[13]+4254626195&4294967295,b=p+(y<<12&4294967295|y>>>20),y=v+(I^b&(p^I))+T[14]+2792965006&4294967295,v=b+(y<<17&4294967295|y>>>15),y=I+(p^v&(b^p))+T[15]+1236535329&4294967295,I=v+(y<<22&4294967295|y>>>10),y=p+(v^b&(I^v))+T[1]+4129170786&4294967295,p=I+(y<<5&4294967295|y>>>27),y=b+(I^v&(p^I))+T[6]+3225465664&4294967295,b=p+(y<<9&4294967295|y>>>23),y=v+(p^I&(b^p))+T[11]+643717713&4294967295,v=b+(y<<14&4294967295|y>>>18),y=I+(b^p&(v^b))+T[0]+3921069994&4294967295,I=v+(y<<20&4294967295|y>>>12),y=p+(v^b&(I^v))+T[5]+3593408605&4294967295,p=I+(y<<5&4294967295|y>>>27),y=b+(I^v&(p^I))+T[10]+38016083&4294967295,b=p+(y<<9&4294967295|y>>>23),y=v+(p^I&(b^p))+T[15]+3634488961&4294967295,v=b+(y<<14&4294967295|y>>>18),y=I+(b^p&(v^b))+T[4]+3889429448&4294967295,I=v+(y<<20&4294967295|y>>>12),y=p+(v^b&(I^v))+T[9]+568446438&4294967295,p=I+(y<<5&4294967295|y>>>27),y=b+(I^v&(p^I))+T[14]+3275163606&4294967295,b=p+(y<<9&4294967295|y>>>23),y=v+(p^I&(b^p))+T[3]+4107603335&4294967295,v=b+(y<<14&4294967295|y>>>18),y=I+(b^p&(v^b))+T[8]+1163531501&4294967295,I=v+(y<<20&4294967295|y>>>12),y=p+(v^b&(I^v))+T[13]+2850285829&4294967295,p=I+(y<<5&4294967295|y>>>27),y=b+(I^v&(p^I))+T[2]+4243563512&4294967295,b=p+(y<<9&4294967295|y>>>23),y=v+(p^I&(b^p))+T[7]+1735328473&4294967295,v=b+(y<<14&4294967295|y>>>18),y=I+(b^p&(v^b))+T[12]+2368359562&4294967295,I=v+(y<<20&4294967295|y>>>12),y=p+(I^v^b)+T[5]+4294588738&4294967295,p=I+(y<<4&4294967295|y>>>28),y=b+(p^I^v)+T[8]+2272392833&4294967295,b=p+(y<<11&4294967295|y>>>21),y=v+(b^p^I)+T[11]+1839030562&4294967295,v=b+(y<<16&4294967295|y>>>16),y=I+(v^b^p)+T[14]+4259657740&4294967295,I=v+(y<<23&4294967295|y>>>9),y=p+(I^v^b)+T[1]+2763975236&4294967295,p=I+(y<<4&4294967295|y>>>28),y=b+(p^I^v)+T[4]+1272893353&4294967295,b=p+(y<<11&4294967295|y>>>21),y=v+(b^p^I)+T[7]+4139469664&4294967295,v=b+(y<<16&4294967295|y>>>16),y=I+(v^b^p)+T[10]+3200236656&4294967295,I=v+(y<<23&4294967295|y>>>9),y=p+(I^v^b)+T[13]+681279174&4294967295,p=I+(y<<4&4294967295|y>>>28),y=b+(p^I^v)+T[0]+3936430074&4294967295,b=p+(y<<11&4294967295|y>>>21),y=v+(b^p^I)+T[3]+3572445317&4294967295,v=b+(y<<16&4294967295|y>>>16),y=I+(v^b^p)+T[6]+76029189&4294967295,I=v+(y<<23&4294967295|y>>>9),y=p+(I^v^b)+T[9]+3654602809&4294967295,p=I+(y<<4&4294967295|y>>>28),y=b+(p^I^v)+T[12]+3873151461&4294967295,b=p+(y<<11&4294967295|y>>>21),y=v+(b^p^I)+T[15]+530742520&4294967295,v=b+(y<<16&4294967295|y>>>16),y=I+(v^b^p)+T[2]+3299628645&4294967295,I=v+(y<<23&4294967295|y>>>9),y=p+(v^(I|~b))+T[0]+4096336452&4294967295,p=I+(y<<6&4294967295|y>>>26),y=b+(I^(p|~v))+T[7]+1126891415&4294967295,b=p+(y<<10&4294967295|y>>>22),y=v+(p^(b|~I))+T[14]+2878612391&4294967295,v=b+(y<<15&4294967295|y>>>17),y=I+(b^(v|~p))+T[5]+4237533241&4294967295,I=v+(y<<21&4294967295|y>>>11),y=p+(v^(I|~b))+T[12]+1700485571&4294967295,p=I+(y<<6&4294967295|y>>>26),y=b+(I^(p|~v))+T[3]+2399980690&4294967295,b=p+(y<<10&4294967295|y>>>22),y=v+(p^(b|~I))+T[10]+4293915773&4294967295,v=b+(y<<15&4294967295|y>>>17),y=I+(b^(v|~p))+T[1]+2240044497&4294967295,I=v+(y<<21&4294967295|y>>>11),y=p+(v^(I|~b))+T[8]+1873313359&4294967295,p=I+(y<<6&4294967295|y>>>26),y=b+(I^(p|~v))+T[15]+4264355552&4294967295,b=p+(y<<10&4294967295|y>>>22),y=v+(p^(b|~I))+T[6]+2734768916&4294967295,v=b+(y<<15&4294967295|y>>>17),y=I+(b^(v|~p))+T[13]+1309151649&4294967295,I=v+(y<<21&4294967295|y>>>11),y=p+(v^(I|~b))+T[4]+4149444226&4294967295,p=I+(y<<6&4294967295|y>>>26),y=b+(I^(p|~v))+T[11]+3174756917&4294967295,b=p+(y<<10&4294967295|y>>>22),y=v+(p^(b|~I))+T[2]+718787259&4294967295,v=b+(y<<15&4294967295|y>>>17),y=I+(b^(v|~p))+T[9]+3951481745&4294967295,E.g[0]=E.g[0]+p&4294967295,E.g[1]=E.g[1]+(v+(y<<21&4294967295|y>>>11))&4294967295,E.g[2]=E.g[2]+v&4294967295,E.g[3]=E.g[3]+b&4294967295}n.prototype.u=function(E,p){p===void 0&&(p=E.length);for(var I=p-this.blockSize,T=this.B,v=this.h,b=0;b<p;){if(v==0)for(;b<=I;)i(this,E,b),b+=this.blockSize;if(typeof E=="string"){for(;b<p;)if(T[v++]=E.charCodeAt(b++),v==this.blockSize){i(this,T),v=0;break}}else for(;b<p;)if(T[v++]=E[b++],v==this.blockSize){i(this,T),v=0;break}}this.h=v,this.o+=p},n.prototype.v=function(){var E=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);E[0]=128;for(var p=1;p<E.length-8;++p)E[p]=0;var I=8*this.o;for(p=E.length-8;p<E.length;++p)E[p]=I&255,I/=256;for(this.u(E),E=Array(16),p=I=0;4>p;++p)for(var T=0;32>T;T+=8)E[I++]=this.g[p]>>>T&255;return E};function s(E,p){var I=u;return Object.prototype.hasOwnProperty.call(I,E)?I[E]:I[E]=p(E)}function a(E,p){this.h=p;for(var I=[],T=!0,v=E.length-1;0<=v;v--){var b=E[v]|0;T&&b==p||(I[v]=b,T=!1)}this.g=I}var u={};function c(E){return-128<=E&&128>E?s(E,function(p){return new a([p|0],0>p?-1:0)}):new a([E|0],0>E?-1:0)}function h(E){if(isNaN(E)||!isFinite(E))return g;if(0>E)return V(h(-E));for(var p=[],I=1,T=0;E>=I;T++)p[T]=E/I|0,I*=4294967296;return new a(p,0)}function f(E,p){if(E.length==0)throw Error("number format error: empty string");if(p=p||10,2>p||36<p)throw Error("radix out of range: "+p);if(E.charAt(0)=="-")return V(f(E.substring(1),p));if(0<=E.indexOf("-"))throw Error('number format error: interior "-" character');for(var I=h(Math.pow(p,8)),T=g,v=0;v<E.length;v+=8){var b=Math.min(8,E.length-v),y=parseInt(E.substring(v,v+b),p);8>b?(b=h(Math.pow(p,b)),T=T.j(b).add(h(y))):(T=T.j(I),T=T.add(h(y)))}return T}var g=c(0),_=c(1),R=c(16777216);r=a.prototype,r.m=function(){if(N(this))return-V(this).m();for(var E=0,p=1,I=0;I<this.g.length;I++){var T=this.i(I);E+=(0<=T?T:4294967296+T)*p,p*=4294967296}return E},r.toString=function(E){if(E=E||10,2>E||36<E)throw Error("radix out of range: "+E);if(C(this))return"0";if(N(this))return"-"+V(this).toString(E);for(var p=h(Math.pow(E,6)),I=this,T="";;){var v=$(I,p).g;I=q(I,v.j(p));var b=((0<I.g.length?I.g[0]:I.h)>>>0).toString(E);if(I=v,C(I))return b+T;for(;6>b.length;)b="0"+b;T=b+T}},r.i=function(E){return 0>E?0:E<this.g.length?this.g[E]:this.h};function C(E){if(E.h!=0)return!1;for(var p=0;p<E.g.length;p++)if(E.g[p]!=0)return!1;return!0}function N(E){return E.h==-1}r.l=function(E){return E=q(this,E),N(E)?-1:C(E)?0:1};function V(E){for(var p=E.g.length,I=[],T=0;T<p;T++)I[T]=~E.g[T];return new a(I,~E.h).add(_)}r.abs=function(){return N(this)?V(this):this},r.add=function(E){for(var p=Math.max(this.g.length,E.g.length),I=[],T=0,v=0;v<=p;v++){var b=T+(this.i(v)&65535)+(E.i(v)&65535),y=(b>>>16)+(this.i(v)>>>16)+(E.i(v)>>>16);T=y>>>16,b&=65535,y&=65535,I[v]=y<<16|b}return new a(I,I[I.length-1]&-2147483648?-1:0)};function q(E,p){return E.add(V(p))}r.j=function(E){if(C(this)||C(E))return g;if(N(this))return N(E)?V(this).j(V(E)):V(V(this).j(E));if(N(E))return V(this.j(V(E)));if(0>this.l(R)&&0>E.l(R))return h(this.m()*E.m());for(var p=this.g.length+E.g.length,I=[],T=0;T<2*p;T++)I[T]=0;for(T=0;T<this.g.length;T++)for(var v=0;v<E.g.length;v++){var b=this.i(T)>>>16,y=this.i(T)&65535,Yt=E.i(v)>>>16,nr=E.i(v)&65535;I[2*T+2*v]+=y*nr,z(I,2*T+2*v),I[2*T+2*v+1]+=b*nr,z(I,2*T+2*v+1),I[2*T+2*v+1]+=y*Yt,z(I,2*T+2*v+1),I[2*T+2*v+2]+=b*Yt,z(I,2*T+2*v+2)}for(T=0;T<p;T++)I[T]=I[2*T+1]<<16|I[2*T];for(T=p;T<2*p;T++)I[T]=0;return new a(I,0)};function z(E,p){for(;(E[p]&65535)!=E[p];)E[p+1]+=E[p]>>>16,E[p]&=65535,p++}function B(E,p){this.g=E,this.h=p}function $(E,p){if(C(p))throw Error("division by zero");if(C(E))return new B(g,g);if(N(E))return p=$(V(E),p),new B(V(p.g),V(p.h));if(N(p))return p=$(E,V(p)),new B(V(p.g),p.h);if(30<E.g.length){if(N(E)||N(p))throw Error("slowDivide_ only works with positive integers.");for(var I=_,T=p;0>=T.l(E);)I=Z(I),T=Z(T);var v=K(I,1),b=K(T,1);for(T=K(T,2),I=K(I,2);!C(T);){var y=b.add(T);0>=y.l(E)&&(v=v.add(I),b=y),T=K(T,1),I=K(I,1)}return p=q(E,v.j(p)),new B(v,p)}for(v=g;0<=E.l(p);){for(I=Math.max(1,Math.floor(E.m()/p.m())),T=Math.ceil(Math.log(I)/Math.LN2),T=48>=T?1:Math.pow(2,T-48),b=h(I),y=b.j(p);N(y)||0<y.l(E);)I-=T,b=h(I),y=b.j(p);C(b)&&(b=_),v=v.add(b),E=q(E,y)}return new B(v,E)}r.A=function(E){return $(this,E).h},r.and=function(E){for(var p=Math.max(this.g.length,E.g.length),I=[],T=0;T<p;T++)I[T]=this.i(T)&E.i(T);return new a(I,this.h&E.h)},r.or=function(E){for(var p=Math.max(this.g.length,E.g.length),I=[],T=0;T<p;T++)I[T]=this.i(T)|E.i(T);return new a(I,this.h|E.h)},r.xor=function(E){for(var p=Math.max(this.g.length,E.g.length),I=[],T=0;T<p;T++)I[T]=this.i(T)^E.i(T);return new a(I,this.h^E.h)};function Z(E){for(var p=E.g.length+1,I=[],T=0;T<p;T++)I[T]=E.i(T)<<1|E.i(T-1)>>>31;return new a(I,E.h)}function K(E,p){var I=p>>5;p%=32;for(var T=E.g.length-I,v=[],b=0;b<T;b++)v[b]=0<p?E.i(b+I)>>>p|E.i(b+I+1)<<32-p:E.i(b+I);return new a(v,E.h)}n.prototype.digest=n.prototype.v,n.prototype.reset=n.prototype.s,n.prototype.update=n.prototype.u,Sl=n,a.prototype.add=a.prototype.add,a.prototype.multiply=a.prototype.j,a.prototype.modulo=a.prototype.A,a.prototype.compare=a.prototype.l,a.prototype.toNumber=a.prototype.m,a.prototype.toString=a.prototype.toString,a.prototype.getBits=a.prototype.i,a.fromNumber=h,a.fromString=f,He=a}).apply(typeof $u<"u"?$u:typeof self<"u"?self:typeof window<"u"?window:{});var Vi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
368
+ */function t(E,p){function I(){}I.prototype=p.prototype,E.D=p.prototype,E.prototype=new I,E.prototype.constructor=E,E.C=function(T,v,b){for(var y=Array(arguments.length-2),Yt=2;Yt<arguments.length;Yt++)y[Yt-2]=arguments[Yt];return p.prototype[v].apply(T,y)}}function e(){this.blockSize=-1}function n(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.B=Array(this.blockSize),this.o=this.h=0,this.s()}t(n,e),n.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(E,p,I){I||(I=0);var T=Array(16);if(typeof p=="string")for(var v=0;16>v;++v)T[v]=p.charCodeAt(I++)|p.charCodeAt(I++)<<8|p.charCodeAt(I++)<<16|p.charCodeAt(I++)<<24;else for(v=0;16>v;++v)T[v]=p[I++]|p[I++]<<8|p[I++]<<16|p[I++]<<24;p=E.g[0],I=E.g[1],v=E.g[2];var b=E.g[3],y=p+(b^I&(v^b))+T[0]+3614090360&4294967295;p=I+(y<<7&4294967295|y>>>25),y=b+(v^p&(I^v))+T[1]+3905402710&4294967295,b=p+(y<<12&4294967295|y>>>20),y=v+(I^b&(p^I))+T[2]+606105819&4294967295,v=b+(y<<17&4294967295|y>>>15),y=I+(p^v&(b^p))+T[3]+3250441966&4294967295,I=v+(y<<22&4294967295|y>>>10),y=p+(b^I&(v^b))+T[4]+4118548399&4294967295,p=I+(y<<7&4294967295|y>>>25),y=b+(v^p&(I^v))+T[5]+1200080426&4294967295,b=p+(y<<12&4294967295|y>>>20),y=v+(I^b&(p^I))+T[6]+2821735955&4294967295,v=b+(y<<17&4294967295|y>>>15),y=I+(p^v&(b^p))+T[7]+4249261313&4294967295,I=v+(y<<22&4294967295|y>>>10),y=p+(b^I&(v^b))+T[8]+1770035416&4294967295,p=I+(y<<7&4294967295|y>>>25),y=b+(v^p&(I^v))+T[9]+2336552879&4294967295,b=p+(y<<12&4294967295|y>>>20),y=v+(I^b&(p^I))+T[10]+4294925233&4294967295,v=b+(y<<17&4294967295|y>>>15),y=I+(p^v&(b^p))+T[11]+2304563134&4294967295,I=v+(y<<22&4294967295|y>>>10),y=p+(b^I&(v^b))+T[12]+1804603682&4294967295,p=I+(y<<7&4294967295|y>>>25),y=b+(v^p&(I^v))+T[13]+4254626195&4294967295,b=p+(y<<12&4294967295|y>>>20),y=v+(I^b&(p^I))+T[14]+2792965006&4294967295,v=b+(y<<17&4294967295|y>>>15),y=I+(p^v&(b^p))+T[15]+1236535329&4294967295,I=v+(y<<22&4294967295|y>>>10),y=p+(v^b&(I^v))+T[1]+4129170786&4294967295,p=I+(y<<5&4294967295|y>>>27),y=b+(I^v&(p^I))+T[6]+3225465664&4294967295,b=p+(y<<9&4294967295|y>>>23),y=v+(p^I&(b^p))+T[11]+643717713&4294967295,v=b+(y<<14&4294967295|y>>>18),y=I+(b^p&(v^b))+T[0]+3921069994&4294967295,I=v+(y<<20&4294967295|y>>>12),y=p+(v^b&(I^v))+T[5]+3593408605&4294967295,p=I+(y<<5&4294967295|y>>>27),y=b+(I^v&(p^I))+T[10]+38016083&4294967295,b=p+(y<<9&4294967295|y>>>23),y=v+(p^I&(b^p))+T[15]+3634488961&4294967295,v=b+(y<<14&4294967295|y>>>18),y=I+(b^p&(v^b))+T[4]+3889429448&4294967295,I=v+(y<<20&4294967295|y>>>12),y=p+(v^b&(I^v))+T[9]+568446438&4294967295,p=I+(y<<5&4294967295|y>>>27),y=b+(I^v&(p^I))+T[14]+3275163606&4294967295,b=p+(y<<9&4294967295|y>>>23),y=v+(p^I&(b^p))+T[3]+4107603335&4294967295,v=b+(y<<14&4294967295|y>>>18),y=I+(b^p&(v^b))+T[8]+1163531501&4294967295,I=v+(y<<20&4294967295|y>>>12),y=p+(v^b&(I^v))+T[13]+2850285829&4294967295,p=I+(y<<5&4294967295|y>>>27),y=b+(I^v&(p^I))+T[2]+4243563512&4294967295,b=p+(y<<9&4294967295|y>>>23),y=v+(p^I&(b^p))+T[7]+1735328473&4294967295,v=b+(y<<14&4294967295|y>>>18),y=I+(b^p&(v^b))+T[12]+2368359562&4294967295,I=v+(y<<20&4294967295|y>>>12),y=p+(I^v^b)+T[5]+4294588738&4294967295,p=I+(y<<4&4294967295|y>>>28),y=b+(p^I^v)+T[8]+2272392833&4294967295,b=p+(y<<11&4294967295|y>>>21),y=v+(b^p^I)+T[11]+1839030562&4294967295,v=b+(y<<16&4294967295|y>>>16),y=I+(v^b^p)+T[14]+4259657740&4294967295,I=v+(y<<23&4294967295|y>>>9),y=p+(I^v^b)+T[1]+2763975236&4294967295,p=I+(y<<4&4294967295|y>>>28),y=b+(p^I^v)+T[4]+1272893353&4294967295,b=p+(y<<11&4294967295|y>>>21),y=v+(b^p^I)+T[7]+4139469664&4294967295,v=b+(y<<16&4294967295|y>>>16),y=I+(v^b^p)+T[10]+3200236656&4294967295,I=v+(y<<23&4294967295|y>>>9),y=p+(I^v^b)+T[13]+681279174&4294967295,p=I+(y<<4&4294967295|y>>>28),y=b+(p^I^v)+T[0]+3936430074&4294967295,b=p+(y<<11&4294967295|y>>>21),y=v+(b^p^I)+T[3]+3572445317&4294967295,v=b+(y<<16&4294967295|y>>>16),y=I+(v^b^p)+T[6]+76029189&4294967295,I=v+(y<<23&4294967295|y>>>9),y=p+(I^v^b)+T[9]+3654602809&4294967295,p=I+(y<<4&4294967295|y>>>28),y=b+(p^I^v)+T[12]+3873151461&4294967295,b=p+(y<<11&4294967295|y>>>21),y=v+(b^p^I)+T[15]+530742520&4294967295,v=b+(y<<16&4294967295|y>>>16),y=I+(v^b^p)+T[2]+3299628645&4294967295,I=v+(y<<23&4294967295|y>>>9),y=p+(v^(I|~b))+T[0]+4096336452&4294967295,p=I+(y<<6&4294967295|y>>>26),y=b+(I^(p|~v))+T[7]+1126891415&4294967295,b=p+(y<<10&4294967295|y>>>22),y=v+(p^(b|~I))+T[14]+2878612391&4294967295,v=b+(y<<15&4294967295|y>>>17),y=I+(b^(v|~p))+T[5]+4237533241&4294967295,I=v+(y<<21&4294967295|y>>>11),y=p+(v^(I|~b))+T[12]+1700485571&4294967295,p=I+(y<<6&4294967295|y>>>26),y=b+(I^(p|~v))+T[3]+2399980690&4294967295,b=p+(y<<10&4294967295|y>>>22),y=v+(p^(b|~I))+T[10]+4293915773&4294967295,v=b+(y<<15&4294967295|y>>>17),y=I+(b^(v|~p))+T[1]+2240044497&4294967295,I=v+(y<<21&4294967295|y>>>11),y=p+(v^(I|~b))+T[8]+1873313359&4294967295,p=I+(y<<6&4294967295|y>>>26),y=b+(I^(p|~v))+T[15]+4264355552&4294967295,b=p+(y<<10&4294967295|y>>>22),y=v+(p^(b|~I))+T[6]+2734768916&4294967295,v=b+(y<<15&4294967295|y>>>17),y=I+(b^(v|~p))+T[13]+1309151649&4294967295,I=v+(y<<21&4294967295|y>>>11),y=p+(v^(I|~b))+T[4]+4149444226&4294967295,p=I+(y<<6&4294967295|y>>>26),y=b+(I^(p|~v))+T[11]+3174756917&4294967295,b=p+(y<<10&4294967295|y>>>22),y=v+(p^(b|~I))+T[2]+718787259&4294967295,v=b+(y<<15&4294967295|y>>>17),y=I+(b^(v|~p))+T[9]+3951481745&4294967295,E.g[0]=E.g[0]+p&4294967295,E.g[1]=E.g[1]+(v+(y<<21&4294967295|y>>>11))&4294967295,E.g[2]=E.g[2]+v&4294967295,E.g[3]=E.g[3]+b&4294967295}n.prototype.u=function(E,p){p===void 0&&(p=E.length);for(var I=p-this.blockSize,T=this.B,v=this.h,b=0;b<p;){if(v==0)for(;b<=I;)i(this,E,b),b+=this.blockSize;if(typeof E=="string"){for(;b<p;)if(T[v++]=E.charCodeAt(b++),v==this.blockSize){i(this,T),v=0;break}}else for(;b<p;)if(T[v++]=E[b++],v==this.blockSize){i(this,T),v=0;break}}this.h=v,this.o+=p},n.prototype.v=function(){var E=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);E[0]=128;for(var p=1;p<E.length-8;++p)E[p]=0;var I=8*this.o;for(p=E.length-8;p<E.length;++p)E[p]=I&255,I/=256;for(this.u(E),E=Array(16),p=I=0;4>p;++p)for(var T=0;32>T;T+=8)E[I++]=this.g[p]>>>T&255;return E};function s(E,p){var I=u;return Object.prototype.hasOwnProperty.call(I,E)?I[E]:I[E]=p(E)}function a(E,p){this.h=p;for(var I=[],T=!0,v=E.length-1;0<=v;v--){var b=E[v]|0;T&&b==p||(I[v]=b,T=!1)}this.g=I}var u={};function c(E){return-128<=E&&128>E?s(E,function(p){return new a([p|0],0>p?-1:0)}):new a([E|0],0>E?-1:0)}function h(E){if(isNaN(E)||!isFinite(E))return g;if(0>E)return V(h(-E));for(var p=[],I=1,T=0;E>=I;T++)p[T]=E/I|0,I*=4294967296;return new a(p,0)}function f(E,p){if(E.length==0)throw Error("number format error: empty string");if(p=p||10,2>p||36<p)throw Error("radix out of range: "+p);if(E.charAt(0)=="-")return V(f(E.substring(1),p));if(0<=E.indexOf("-"))throw Error('number format error: interior "-" character');for(var I=h(Math.pow(p,8)),T=g,v=0;v<E.length;v+=8){var b=Math.min(8,E.length-v),y=parseInt(E.substring(v,v+b),p);8>b?(b=h(Math.pow(p,b)),T=T.j(b).add(h(y))):(T=T.j(I),T=T.add(h(y)))}return T}var g=c(0),_=c(1),R=c(16777216);r=a.prototype,r.m=function(){if(N(this))return-V(this).m();for(var E=0,p=1,I=0;I<this.g.length;I++){var T=this.i(I);E+=(0<=T?T:4294967296+T)*p,p*=4294967296}return E},r.toString=function(E){if(E=E||10,2>E||36<E)throw Error("radix out of range: "+E);if(C(this))return"0";if(N(this))return"-"+V(this).toString(E);for(var p=h(Math.pow(E,6)),I=this,T="";;){var v=$(I,p).g;I=q(I,v.j(p));var b=((0<I.g.length?I.g[0]:I.h)>>>0).toString(E);if(I=v,C(I))return b+T;for(;6>b.length;)b="0"+b;T=b+T}},r.i=function(E){return 0>E?0:E<this.g.length?this.g[E]:this.h};function C(E){if(E.h!=0)return!1;for(var p=0;p<E.g.length;p++)if(E.g[p]!=0)return!1;return!0}function N(E){return E.h==-1}r.l=function(E){return E=q(this,E),N(E)?-1:C(E)?0:1};function V(E){for(var p=E.g.length,I=[],T=0;T<p;T++)I[T]=~E.g[T];return new a(I,~E.h).add(_)}r.abs=function(){return N(this)?V(this):this},r.add=function(E){for(var p=Math.max(this.g.length,E.g.length),I=[],T=0,v=0;v<=p;v++){var b=T+(this.i(v)&65535)+(E.i(v)&65535),y=(b>>>16)+(this.i(v)>>>16)+(E.i(v)>>>16);T=y>>>16,b&=65535,y&=65535,I[v]=y<<16|b}return new a(I,I[I.length-1]&-2147483648?-1:0)};function q(E,p){return E.add(V(p))}r.j=function(E){if(C(this)||C(E))return g;if(N(this))return N(E)?V(this).j(V(E)):V(V(this).j(E));if(N(E))return V(this.j(V(E)));if(0>this.l(R)&&0>E.l(R))return h(this.m()*E.m());for(var p=this.g.length+E.g.length,I=[],T=0;T<2*p;T++)I[T]=0;for(T=0;T<this.g.length;T++)for(var v=0;v<E.g.length;v++){var b=this.i(T)>>>16,y=this.i(T)&65535,Yt=E.i(v)>>>16,rr=E.i(v)&65535;I[2*T+2*v]+=y*rr,z(I,2*T+2*v),I[2*T+2*v+1]+=b*rr,z(I,2*T+2*v+1),I[2*T+2*v+1]+=y*Yt,z(I,2*T+2*v+1),I[2*T+2*v+2]+=b*Yt,z(I,2*T+2*v+2)}for(T=0;T<p;T++)I[T]=I[2*T+1]<<16|I[2*T];for(T=p;T<2*p;T++)I[T]=0;return new a(I,0)};function z(E,p){for(;(E[p]&65535)!=E[p];)E[p+1]+=E[p]>>>16,E[p]&=65535,p++}function B(E,p){this.g=E,this.h=p}function $(E,p){if(C(p))throw Error("division by zero");if(C(E))return new B(g,g);if(N(E))return p=$(V(E),p),new B(V(p.g),V(p.h));if(N(p))return p=$(E,V(p)),new B(V(p.g),p.h);if(30<E.g.length){if(N(E)||N(p))throw Error("slowDivide_ only works with positive integers.");for(var I=_,T=p;0>=T.l(E);)I=Z(I),T=Z(T);var v=K(I,1),b=K(T,1);for(T=K(T,2),I=K(I,2);!C(T);){var y=b.add(T);0>=y.l(E)&&(v=v.add(I),b=y),T=K(T,1),I=K(I,1)}return p=q(E,v.j(p)),new B(v,p)}for(v=g;0<=E.l(p);){for(I=Math.max(1,Math.floor(E.m()/p.m())),T=Math.ceil(Math.log(I)/Math.LN2),T=48>=T?1:Math.pow(2,T-48),b=h(I),y=b.j(p);N(y)||0<y.l(E);)I-=T,b=h(I),y=b.j(p);C(b)&&(b=_),v=v.add(b),E=q(E,y)}return new B(v,E)}r.A=function(E){return $(this,E).h},r.and=function(E){for(var p=Math.max(this.g.length,E.g.length),I=[],T=0;T<p;T++)I[T]=this.i(T)&E.i(T);return new a(I,this.h&E.h)},r.or=function(E){for(var p=Math.max(this.g.length,E.g.length),I=[],T=0;T<p;T++)I[T]=this.i(T)|E.i(T);return new a(I,this.h|E.h)},r.xor=function(E){for(var p=Math.max(this.g.length,E.g.length),I=[],T=0;T<p;T++)I[T]=this.i(T)^E.i(T);return new a(I,this.h^E.h)};function Z(E){for(var p=E.g.length+1,I=[],T=0;T<p;T++)I[T]=E.i(T)<<1|E.i(T-1)>>>31;return new a(I,E.h)}function K(E,p){var I=p>>5;p%=32;for(var T=E.g.length-I,v=[],b=0;b<T;b++)v[b]=0<p?E.i(b+I)>>>p|E.i(b+I+1)<<32-p:E.i(b+I);return new a(v,E.h)}n.prototype.digest=n.prototype.v,n.prototype.reset=n.prototype.s,n.prototype.update=n.prototype.u,Sl=n,a.prototype.add=a.prototype.add,a.prototype.multiply=a.prototype.j,a.prototype.modulo=a.prototype.A,a.prototype.compare=a.prototype.l,a.prototype.toNumber=a.prototype.m,a.prototype.toString=a.prototype.toString,a.prototype.getBits=a.prototype.i,a.fromNumber=h,a.fromString=f,Je=a}).apply(typeof $u<"u"?$u:typeof self<"u"?self:typeof window<"u"?window:{});var Vi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
369
369
  Copyright The Closure Library Authors.
370
370
  SPDX-License-Identifier: Apache-2.0
371
- */var Vl,Ar,Cl,Mi,mo,Dl,xl,Nl;(function(){var r,t=typeof Object.defineProperties=="function"?Object.defineProperty:function(o,l,d){return o==Array.prototype||o==Object.prototype||(o[l]=d.value),o};function e(o){o=[typeof globalThis=="object"&&globalThis,o,typeof window=="object"&&window,typeof self=="object"&&self,typeof Vi=="object"&&Vi];for(var l=0;l<o.length;++l){var d=o[l];if(d&&d.Math==Math)return d}throw Error("Cannot find global object")}var n=e(this);function i(o,l){if(l)t:{var d=n;o=o.split(".");for(var m=0;m<o.length-1;m++){var A=o[m];if(!(A in d))break t;d=d[A]}o=o[o.length-1],m=d[o],l=l(m),l!=m&&l!=null&&t(d,o,{configurable:!0,writable:!0,value:l})}}function s(o,l){o instanceof String&&(o+="");var d=0,m=!1,A={next:function(){if(!m&&d<o.length){var S=d++;return{value:l(S,o[S]),done:!1}}return m=!0,{done:!0,value:void 0}}};return A[Symbol.iterator]=function(){return A},A}i("Array.prototype.values",function(o){return o||function(){return s(this,function(l,d){return d})}});/** @license
371
+ */var Vl,Rr,Cl,Mi,mo,Dl,xl,Nl;(function(){var r,t=typeof Object.defineProperties=="function"?Object.defineProperty:function(o,l,d){return o==Array.prototype||o==Object.prototype||(o[l]=d.value),o};function e(o){o=[typeof globalThis=="object"&&globalThis,o,typeof window=="object"&&window,typeof self=="object"&&self,typeof Vi=="object"&&Vi];for(var l=0;l<o.length;++l){var d=o[l];if(d&&d.Math==Math)return d}throw Error("Cannot find global object")}var n=e(this);function i(o,l){if(l)t:{var d=n;o=o.split(".");for(var m=0;m<o.length-1;m++){var A=o[m];if(!(A in d))break t;d=d[A]}o=o[o.length-1],m=d[o],l=l(m),l!=m&&l!=null&&t(d,o,{configurable:!0,writable:!0,value:l})}}function s(o,l){o instanceof String&&(o+="");var d=0,m=!1,A={next:function(){if(!m&&d<o.length){var S=d++;return{value:l(S,o[S]),done:!1}}return m=!0,{done:!0,value:void 0}}};return A[Symbol.iterator]=function(){return A},A}i("Array.prototype.values",function(o){return o||function(){return s(this,function(l,d){return d})}});/** @license
372
372
 
373
373
  Copyright The Closure Library Authors.
374
374
  SPDX-License-Identifier: Apache-2.0
375
- */var a=a||{},u=this||self;function c(o){var l=typeof o;return l=l!="object"?l:o?Array.isArray(o)?"array":l:"null",l=="array"||l=="object"&&typeof o.length=="number"}function h(o){var l=typeof o;return l=="object"&&o!=null||l=="function"}function f(o,l,d){return o.call.apply(o.bind,arguments)}function g(o,l,d){if(!o)throw Error();if(2<arguments.length){var m=Array.prototype.slice.call(arguments,2);return function(){var A=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(A,m),o.apply(l,A)}}return function(){return o.apply(l,arguments)}}function _(o,l,d){return _=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?f:g,_.apply(null,arguments)}function R(o,l){var d=Array.prototype.slice.call(arguments,1);return function(){var m=d.slice();return m.push.apply(m,arguments),o.apply(this,m)}}function C(o,l){function d(){}d.prototype=l.prototype,o.aa=l.prototype,o.prototype=new d,o.prototype.constructor=o,o.Qb=function(m,A,S){for(var F=Array(arguments.length-2),rt=2;rt<arguments.length;rt++)F[rt-2]=arguments[rt];return l.prototype[A].apply(m,F)}}function N(o){const l=o.length;if(0<l){const d=Array(l);for(let m=0;m<l;m++)d[m]=o[m];return d}return[]}function V(o,l){for(let d=1;d<arguments.length;d++){const m=arguments[d];if(c(m)){const A=o.length||0,S=m.length||0;o.length=A+S;for(let F=0;F<S;F++)o[A+F]=m[F]}else o.push(m)}}class q{constructor(l,d){this.i=l,this.j=d,this.h=0,this.g=null}get(){let l;return 0<this.h?(this.h--,l=this.g,this.g=l.next,l.next=null):l=this.i(),l}}function z(o){return/^[\s\xa0]*$/.test(o)}function B(){var o=u.navigator;return o&&(o=o.userAgent)?o:""}function $(o){return $[" "](o),o}$[" "]=function(){};var Z=B().indexOf("Gecko")!=-1&&!(B().toLowerCase().indexOf("webkit")!=-1&&B().indexOf("Edge")==-1)&&!(B().indexOf("Trident")!=-1||B().indexOf("MSIE")!=-1)&&B().indexOf("Edge")==-1;function K(o,l,d){for(const m in o)l.call(d,o[m],m,o)}function E(o,l){for(const d in o)l.call(void 0,o[d],d,o)}function p(o){const l={};for(const d in o)l[d]=o[d];return l}const I="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function T(o,l){let d,m;for(let A=1;A<arguments.length;A++){m=arguments[A];for(d in m)o[d]=m[d];for(let S=0;S<I.length;S++)d=I[S],Object.prototype.hasOwnProperty.call(m,d)&&(o[d]=m[d])}}function v(o){var l=1;o=o.split(":");const d=[];for(;0<l&&o.length;)d.push(o.shift()),l--;return o.length&&d.push(o.join(":")),d}function b(o){u.setTimeout(()=>{throw o},0)}function y(){var o=Vs;let l=null;return o.g&&(l=o.g,o.g=o.g.next,o.g||(o.h=null),l.next=null),l}class Yt{constructor(){this.h=this.g=null}add(l,d){const m=nr.get();m.set(l,d),this.h?this.h.next=m:this.g=m,this.h=m}}var nr=new q(()=>new uf,o=>o.reset());class uf{constructor(){this.next=this.g=this.h=null}set(l,d){this.h=l,this.g=d,this.next=null}reset(){this.next=this.g=this.h=null}}let rr,ir=!1,Vs=new Yt,Ba=()=>{const o=u.Promise.resolve(void 0);rr=()=>{o.then(cf)}};var cf=()=>{for(var o;o=y();){try{o.h.call(o.g)}catch(d){b(d)}var l=nr;l.j(o),100>l.h&&(l.h++,o.next=l.g,l.g=o)}ir=!1};function ue(){this.s=this.s,this.C=this.C}ue.prototype.s=!1,ue.prototype.ma=function(){this.s||(this.s=!0,this.N())},ue.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function Pt(o,l){this.type=o,this.g=this.target=l,this.defaultPrevented=!1}Pt.prototype.h=function(){this.defaultPrevented=!0};var lf=function(){if(!u.addEventListener||!Object.defineProperty)return!1;var o=!1,l=Object.defineProperty({},"passive",{get:function(){o=!0}});try{const d=()=>{};u.addEventListener("test",d,l),u.removeEventListener("test",d,l)}catch{}return o}();function sr(o,l){if(Pt.call(this,o?o.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,o){var d=this.type=o.type,m=o.changedTouches&&o.changedTouches.length?o.changedTouches[0]:null;if(this.target=o.target||o.srcElement,this.g=l,l=o.relatedTarget){if(Z){t:{try{$(l.nodeName);var A=!0;break t}catch{}A=!1}A||(l=null)}}else d=="mouseover"?l=o.fromElement:d=="mouseout"&&(l=o.toElement);this.relatedTarget=l,m?(this.clientX=m.clientX!==void 0?m.clientX:m.pageX,this.clientY=m.clientY!==void 0?m.clientY:m.pageY,this.screenX=m.screenX||0,this.screenY=m.screenY||0):(this.clientX=o.clientX!==void 0?o.clientX:o.pageX,this.clientY=o.clientY!==void 0?o.clientY:o.pageY,this.screenX=o.screenX||0,this.screenY=o.screenY||0),this.button=o.button,this.key=o.key||"",this.ctrlKey=o.ctrlKey,this.altKey=o.altKey,this.shiftKey=o.shiftKey,this.metaKey=o.metaKey,this.pointerId=o.pointerId||0,this.pointerType=typeof o.pointerType=="string"?o.pointerType:hf[o.pointerType]||"",this.state=o.state,this.i=o,o.defaultPrevented&&sr.aa.h.call(this)}}C(sr,Pt);var hf={2:"touch",3:"pen",4:"mouse"};sr.prototype.h=function(){sr.aa.h.call(this);var o=this.i;o.preventDefault?o.preventDefault():o.returnValue=!1};var li="closure_listenable_"+(1e6*Math.random()|0),df=0;function ff(o,l,d,m,A){this.listener=o,this.proxy=null,this.src=l,this.type=d,this.capture=!!m,this.ha=A,this.key=++df,this.da=this.fa=!1}function hi(o){o.da=!0,o.listener=null,o.proxy=null,o.src=null,o.ha=null}function di(o){this.src=o,this.g={},this.h=0}di.prototype.add=function(o,l,d,m,A){var S=o.toString();o=this.g[S],o||(o=this.g[S]=[],this.h++);var F=Ds(o,l,m,A);return-1<F?(l=o[F],d||(l.fa=!1)):(l=new ff(l,this.src,S,!!m,A),l.fa=d,o.push(l)),l};function Cs(o,l){var d=l.type;if(d in o.g){var m=o.g[d],A=Array.prototype.indexOf.call(m,l,void 0),S;(S=0<=A)&&Array.prototype.splice.call(m,A,1),S&&(hi(l),o.g[d].length==0&&(delete o.g[d],o.h--))}}function Ds(o,l,d,m){for(var A=0;A<o.length;++A){var S=o[A];if(!S.da&&S.listener==l&&S.capture==!!d&&S.ha==m)return A}return-1}var xs="closure_lm_"+(1e6*Math.random()|0),Ns={};function Ua(o,l,d,m,A){if(Array.isArray(l)){for(var S=0;S<l.length;S++)Ua(o,l[S],d,m,A);return null}return d=ja(d),o&&o[li]?o.K(l,d,h(m)?!!m.capture:!!m,A):mf(o,l,d,!1,m,A)}function mf(o,l,d,m,A,S){if(!l)throw Error("Invalid event type");var F=h(A)?!!A.capture:!!A,rt=Fs(o);if(rt||(o[xs]=rt=new di(o)),d=rt.add(l,d,m,F,S),d.proxy)return d;if(m=gf(),d.proxy=m,m.src=o,m.listener=d,o.addEventListener)lf||(A=F),A===void 0&&(A=!1),o.addEventListener(l.toString(),m,A);else if(o.attachEvent)o.attachEvent(za(l.toString()),m);else if(o.addListener&&o.removeListener)o.addListener(m);else throw Error("addEventListener and attachEvent are unavailable.");return d}function gf(){function o(d){return l.call(o.src,o.listener,d)}const l=pf;return o}function qa(o,l,d,m,A){if(Array.isArray(l))for(var S=0;S<l.length;S++)qa(o,l[S],d,m,A);else m=h(m)?!!m.capture:!!m,d=ja(d),o&&o[li]?(o=o.i,l=String(l).toString(),l in o.g&&(S=o.g[l],d=Ds(S,d,m,A),-1<d&&(hi(S[d]),Array.prototype.splice.call(S,d,1),S.length==0&&(delete o.g[l],o.h--)))):o&&(o=Fs(o))&&(l=o.g[l.toString()],o=-1,l&&(o=Ds(l,d,m,A)),(d=-1<o?l[o]:null)&&ks(d))}function ks(o){if(typeof o!="number"&&o&&!o.da){var l=o.src;if(l&&l[li])Cs(l.i,o);else{var d=o.type,m=o.proxy;l.removeEventListener?l.removeEventListener(d,m,o.capture):l.detachEvent?l.detachEvent(za(d),m):l.addListener&&l.removeListener&&l.removeListener(m),(d=Fs(l))?(Cs(d,o),d.h==0&&(d.src=null,l[xs]=null)):hi(o)}}}function za(o){return o in Ns?Ns[o]:Ns[o]="on"+o}function pf(o,l){if(o.da)o=!0;else{l=new sr(l,this);var d=o.listener,m=o.ha||o.src;o.fa&&ks(o),o=d.call(m,l)}return o}function Fs(o){return o=o[xs],o instanceof di?o:null}var Ms="__closure_events_fn_"+(1e9*Math.random()>>>0);function ja(o){return typeof o=="function"?o:(o[Ms]||(o[Ms]=function(l){return o.handleEvent(l)}),o[Ms])}function St(){ue.call(this),this.i=new di(this),this.M=this,this.F=null}C(St,ue),St.prototype[li]=!0,St.prototype.removeEventListener=function(o,l,d,m){qa(this,o,l,d,m)};function Ft(o,l){var d,m=o.F;if(m)for(d=[];m;m=m.F)d.push(m);if(o=o.M,m=l.type||l,typeof l=="string")l=new Pt(l,o);else if(l instanceof Pt)l.target=l.target||o;else{var A=l;l=new Pt(m,o),T(l,A)}if(A=!0,d)for(var S=d.length-1;0<=S;S--){var F=l.g=d[S];A=fi(F,m,!0,l)&&A}if(F=l.g=o,A=fi(F,m,!0,l)&&A,A=fi(F,m,!1,l)&&A,d)for(S=0;S<d.length;S++)F=l.g=d[S],A=fi(F,m,!1,l)&&A}St.prototype.N=function(){if(St.aa.N.call(this),this.i){var o=this.i,l;for(l in o.g){for(var d=o.g[l],m=0;m<d.length;m++)hi(d[m]);delete o.g[l],o.h--}}this.F=null},St.prototype.K=function(o,l,d,m){return this.i.add(String(o),l,!1,d,m)},St.prototype.L=function(o,l,d,m){return this.i.add(String(o),l,!0,d,m)};function fi(o,l,d,m){if(l=o.i.g[String(l)],!l)return!0;l=l.concat();for(var A=!0,S=0;S<l.length;++S){var F=l[S];if(F&&!F.da&&F.capture==d){var rt=F.listener,At=F.ha||F.src;F.fa&&Cs(o.i,F),A=rt.call(At,m)!==!1&&A}}return A&&!m.defaultPrevented}function Ga(o,l,d){if(typeof o=="function")d&&(o=_(o,d));else if(o&&typeof o.handleEvent=="function")o=_(o.handleEvent,o);else throw Error("Invalid listener argument");return 2147483647<Number(l)?-1:u.setTimeout(o,l||0)}function Ka(o){o.g=Ga(()=>{o.g=null,o.i&&(o.i=!1,Ka(o))},o.l);const l=o.h;o.h=null,o.m.apply(null,l)}class _f extends ue{constructor(l,d){super(),this.m=l,this.l=d,this.h=null,this.i=!1,this.g=null}j(l){this.h=arguments,this.g?this.i=!0:Ka(this)}N(){super.N(),this.g&&(u.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function or(o){ue.call(this),this.h=o,this.g={}}C(or,ue);var $a=[];function Qa(o){K(o.g,function(l,d){this.g.hasOwnProperty(d)&&ks(l)},o),o.g={}}or.prototype.N=function(){or.aa.N.call(this),Qa(this)},or.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var Os=u.JSON.stringify,yf=u.JSON.parse,If=class{stringify(o){return u.JSON.stringify(o,void 0)}parse(o){return u.JSON.parse(o,void 0)}};function Ls(){}Ls.prototype.h=null;function Wa(o){return o.h||(o.h=o.i())}function Ha(){}var ar={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function Bs(){Pt.call(this,"d")}C(Bs,Pt);function Us(){Pt.call(this,"c")}C(Us,Pt);var Oe={},Ja=null;function mi(){return Ja=Ja||new St}Oe.La="serverreachability";function Ya(o){Pt.call(this,Oe.La,o)}C(Ya,Pt);function ur(o){const l=mi();Ft(l,new Ya(l))}Oe.STAT_EVENT="statevent";function Xa(o,l){Pt.call(this,Oe.STAT_EVENT,o),this.stat=l}C(Xa,Pt);function Mt(o){const l=mi();Ft(l,new Xa(l,o))}Oe.Ma="timingevent";function Za(o,l){Pt.call(this,Oe.Ma,o),this.size=l}C(Za,Pt);function cr(o,l){if(typeof o!="function")throw Error("Fn must not be null and must be a function");return u.setTimeout(function(){o()},l)}function lr(){this.g=!0}lr.prototype.xa=function(){this.g=!1};function Ef(o,l,d,m,A,S){o.info(function(){if(o.g)if(S)for(var F="",rt=S.split("&"),At=0;At<rt.length;At++){var X=rt[At].split("=");if(1<X.length){var Vt=X[0];X=X[1];var Ct=Vt.split("_");F=2<=Ct.length&&Ct[1]=="type"?F+(Vt+"="+X+"&"):F+(Vt+"=redacted&")}}else F=null;else F=S;return"XMLHTTP REQ ("+m+") [attempt "+A+"]: "+l+`
375
+ */var a=a||{},u=this||self;function c(o){var l=typeof o;return l=l!="object"?l:o?Array.isArray(o)?"array":l:"null",l=="array"||l=="object"&&typeof o.length=="number"}function h(o){var l=typeof o;return l=="object"&&o!=null||l=="function"}function f(o,l,d){return o.call.apply(o.bind,arguments)}function g(o,l,d){if(!o)throw Error();if(2<arguments.length){var m=Array.prototype.slice.call(arguments,2);return function(){var A=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(A,m),o.apply(l,A)}}return function(){return o.apply(l,arguments)}}function _(o,l,d){return _=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?f:g,_.apply(null,arguments)}function R(o,l){var d=Array.prototype.slice.call(arguments,1);return function(){var m=d.slice();return m.push.apply(m,arguments),o.apply(this,m)}}function C(o,l){function d(){}d.prototype=l.prototype,o.aa=l.prototype,o.prototype=new d,o.prototype.constructor=o,o.Qb=function(m,A,S){for(var F=Array(arguments.length-2),rt=2;rt<arguments.length;rt++)F[rt-2]=arguments[rt];return l.prototype[A].apply(m,F)}}function N(o){const l=o.length;if(0<l){const d=Array(l);for(let m=0;m<l;m++)d[m]=o[m];return d}return[]}function V(o,l){for(let d=1;d<arguments.length;d++){const m=arguments[d];if(c(m)){const A=o.length||0,S=m.length||0;o.length=A+S;for(let F=0;F<S;F++)o[A+F]=m[F]}else o.push(m)}}class q{constructor(l,d){this.i=l,this.j=d,this.h=0,this.g=null}get(){let l;return 0<this.h?(this.h--,l=this.g,this.g=l.next,l.next=null):l=this.i(),l}}function z(o){return/^[\s\xa0]*$/.test(o)}function B(){var o=u.navigator;return o&&(o=o.userAgent)?o:""}function $(o){return $[" "](o),o}$[" "]=function(){};var Z=B().indexOf("Gecko")!=-1&&!(B().toLowerCase().indexOf("webkit")!=-1&&B().indexOf("Edge")==-1)&&!(B().indexOf("Trident")!=-1||B().indexOf("MSIE")!=-1)&&B().indexOf("Edge")==-1;function K(o,l,d){for(const m in o)l.call(d,o[m],m,o)}function E(o,l){for(const d in o)l.call(void 0,o[d],d,o)}function p(o){const l={};for(const d in o)l[d]=o[d];return l}const I="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function T(o,l){let d,m;for(let A=1;A<arguments.length;A++){m=arguments[A];for(d in m)o[d]=m[d];for(let S=0;S<I.length;S++)d=I[S],Object.prototype.hasOwnProperty.call(m,d)&&(o[d]=m[d])}}function v(o){var l=1;o=o.split(":");const d=[];for(;0<l&&o.length;)d.push(o.shift()),l--;return o.length&&d.push(o.join(":")),d}function b(o){u.setTimeout(()=>{throw o},0)}function y(){var o=Vs;let l=null;return o.g&&(l=o.g,o.g=o.g.next,o.g||(o.h=null),l.next=null),l}class Yt{constructor(){this.h=this.g=null}add(l,d){const m=rr.get();m.set(l,d),this.h?this.h.next=m:this.g=m,this.h=m}}var rr=new q(()=>new uf,o=>o.reset());class uf{constructor(){this.next=this.g=this.h=null}set(l,d){this.h=l,this.g=d,this.next=null}reset(){this.next=this.g=this.h=null}}let ir,sr=!1,Vs=new Yt,Ba=()=>{const o=u.Promise.resolve(void 0);ir=()=>{o.then(cf)}};var cf=()=>{for(var o;o=y();){try{o.h.call(o.g)}catch(d){b(d)}var l=rr;l.j(o),100>l.h&&(l.h++,o.next=l.g,l.g=o)}sr=!1};function ue(){this.s=this.s,this.C=this.C}ue.prototype.s=!1,ue.prototype.ma=function(){this.s||(this.s=!0,this.N())},ue.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function Pt(o,l){this.type=o,this.g=this.target=l,this.defaultPrevented=!1}Pt.prototype.h=function(){this.defaultPrevented=!0};var lf=function(){if(!u.addEventListener||!Object.defineProperty)return!1;var o=!1,l=Object.defineProperty({},"passive",{get:function(){o=!0}});try{const d=()=>{};u.addEventListener("test",d,l),u.removeEventListener("test",d,l)}catch{}return o}();function or(o,l){if(Pt.call(this,o?o.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,o){var d=this.type=o.type,m=o.changedTouches&&o.changedTouches.length?o.changedTouches[0]:null;if(this.target=o.target||o.srcElement,this.g=l,l=o.relatedTarget){if(Z){t:{try{$(l.nodeName);var A=!0;break t}catch{}A=!1}A||(l=null)}}else d=="mouseover"?l=o.fromElement:d=="mouseout"&&(l=o.toElement);this.relatedTarget=l,m?(this.clientX=m.clientX!==void 0?m.clientX:m.pageX,this.clientY=m.clientY!==void 0?m.clientY:m.pageY,this.screenX=m.screenX||0,this.screenY=m.screenY||0):(this.clientX=o.clientX!==void 0?o.clientX:o.pageX,this.clientY=o.clientY!==void 0?o.clientY:o.pageY,this.screenX=o.screenX||0,this.screenY=o.screenY||0),this.button=o.button,this.key=o.key||"",this.ctrlKey=o.ctrlKey,this.altKey=o.altKey,this.shiftKey=o.shiftKey,this.metaKey=o.metaKey,this.pointerId=o.pointerId||0,this.pointerType=typeof o.pointerType=="string"?o.pointerType:hf[o.pointerType]||"",this.state=o.state,this.i=o,o.defaultPrevented&&or.aa.h.call(this)}}C(or,Pt);var hf={2:"touch",3:"pen",4:"mouse"};or.prototype.h=function(){or.aa.h.call(this);var o=this.i;o.preventDefault?o.preventDefault():o.returnValue=!1};var li="closure_listenable_"+(1e6*Math.random()|0),df=0;function ff(o,l,d,m,A){this.listener=o,this.proxy=null,this.src=l,this.type=d,this.capture=!!m,this.ha=A,this.key=++df,this.da=this.fa=!1}function hi(o){o.da=!0,o.listener=null,o.proxy=null,o.src=null,o.ha=null}function di(o){this.src=o,this.g={},this.h=0}di.prototype.add=function(o,l,d,m,A){var S=o.toString();o=this.g[S],o||(o=this.g[S]=[],this.h++);var F=Ds(o,l,m,A);return-1<F?(l=o[F],d||(l.fa=!1)):(l=new ff(l,this.src,S,!!m,A),l.fa=d,o.push(l)),l};function Cs(o,l){var d=l.type;if(d in o.g){var m=o.g[d],A=Array.prototype.indexOf.call(m,l,void 0),S;(S=0<=A)&&Array.prototype.splice.call(m,A,1),S&&(hi(l),o.g[d].length==0&&(delete o.g[d],o.h--))}}function Ds(o,l,d,m){for(var A=0;A<o.length;++A){var S=o[A];if(!S.da&&S.listener==l&&S.capture==!!d&&S.ha==m)return A}return-1}var xs="closure_lm_"+(1e6*Math.random()|0),Ns={};function Ua(o,l,d,m,A){if(Array.isArray(l)){for(var S=0;S<l.length;S++)Ua(o,l[S],d,m,A);return null}return d=ja(d),o&&o[li]?o.K(l,d,h(m)?!!m.capture:!!m,A):mf(o,l,d,!1,m,A)}function mf(o,l,d,m,A,S){if(!l)throw Error("Invalid event type");var F=h(A)?!!A.capture:!!A,rt=Fs(o);if(rt||(o[xs]=rt=new di(o)),d=rt.add(l,d,m,F,S),d.proxy)return d;if(m=gf(),d.proxy=m,m.src=o,m.listener=d,o.addEventListener)lf||(A=F),A===void 0&&(A=!1),o.addEventListener(l.toString(),m,A);else if(o.attachEvent)o.attachEvent(za(l.toString()),m);else if(o.addListener&&o.removeListener)o.addListener(m);else throw Error("addEventListener and attachEvent are unavailable.");return d}function gf(){function o(d){return l.call(o.src,o.listener,d)}const l=pf;return o}function qa(o,l,d,m,A){if(Array.isArray(l))for(var S=0;S<l.length;S++)qa(o,l[S],d,m,A);else m=h(m)?!!m.capture:!!m,d=ja(d),o&&o[li]?(o=o.i,l=String(l).toString(),l in o.g&&(S=o.g[l],d=Ds(S,d,m,A),-1<d&&(hi(S[d]),Array.prototype.splice.call(S,d,1),S.length==0&&(delete o.g[l],o.h--)))):o&&(o=Fs(o))&&(l=o.g[l.toString()],o=-1,l&&(o=Ds(l,d,m,A)),(d=-1<o?l[o]:null)&&ks(d))}function ks(o){if(typeof o!="number"&&o&&!o.da){var l=o.src;if(l&&l[li])Cs(l.i,o);else{var d=o.type,m=o.proxy;l.removeEventListener?l.removeEventListener(d,m,o.capture):l.detachEvent?l.detachEvent(za(d),m):l.addListener&&l.removeListener&&l.removeListener(m),(d=Fs(l))?(Cs(d,o),d.h==0&&(d.src=null,l[xs]=null)):hi(o)}}}function za(o){return o in Ns?Ns[o]:Ns[o]="on"+o}function pf(o,l){if(o.da)o=!0;else{l=new or(l,this);var d=o.listener,m=o.ha||o.src;o.fa&&ks(o),o=d.call(m,l)}return o}function Fs(o){return o=o[xs],o instanceof di?o:null}var Ms="__closure_events_fn_"+(1e9*Math.random()>>>0);function ja(o){return typeof o=="function"?o:(o[Ms]||(o[Ms]=function(l){return o.handleEvent(l)}),o[Ms])}function St(){ue.call(this),this.i=new di(this),this.M=this,this.F=null}C(St,ue),St.prototype[li]=!0,St.prototype.removeEventListener=function(o,l,d,m){qa(this,o,l,d,m)};function Ft(o,l){var d,m=o.F;if(m)for(d=[];m;m=m.F)d.push(m);if(o=o.M,m=l.type||l,typeof l=="string")l=new Pt(l,o);else if(l instanceof Pt)l.target=l.target||o;else{var A=l;l=new Pt(m,o),T(l,A)}if(A=!0,d)for(var S=d.length-1;0<=S;S--){var F=l.g=d[S];A=fi(F,m,!0,l)&&A}if(F=l.g=o,A=fi(F,m,!0,l)&&A,A=fi(F,m,!1,l)&&A,d)for(S=0;S<d.length;S++)F=l.g=d[S],A=fi(F,m,!1,l)&&A}St.prototype.N=function(){if(St.aa.N.call(this),this.i){var o=this.i,l;for(l in o.g){for(var d=o.g[l],m=0;m<d.length;m++)hi(d[m]);delete o.g[l],o.h--}}this.F=null},St.prototype.K=function(o,l,d,m){return this.i.add(String(o),l,!1,d,m)},St.prototype.L=function(o,l,d,m){return this.i.add(String(o),l,!0,d,m)};function fi(o,l,d,m){if(l=o.i.g[String(l)],!l)return!0;l=l.concat();for(var A=!0,S=0;S<l.length;++S){var F=l[S];if(F&&!F.da&&F.capture==d){var rt=F.listener,At=F.ha||F.src;F.fa&&Cs(o.i,F),A=rt.call(At,m)!==!1&&A}}return A&&!m.defaultPrevented}function Ga(o,l,d){if(typeof o=="function")d&&(o=_(o,d));else if(o&&typeof o.handleEvent=="function")o=_(o.handleEvent,o);else throw Error("Invalid listener argument");return 2147483647<Number(l)?-1:u.setTimeout(o,l||0)}function Ka(o){o.g=Ga(()=>{o.g=null,o.i&&(o.i=!1,Ka(o))},o.l);const l=o.h;o.h=null,o.m.apply(null,l)}class _f extends ue{constructor(l,d){super(),this.m=l,this.l=d,this.h=null,this.i=!1,this.g=null}j(l){this.h=arguments,this.g?this.i=!0:Ka(this)}N(){super.N(),this.g&&(u.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function ar(o){ue.call(this),this.h=o,this.g={}}C(ar,ue);var $a=[];function Qa(o){K(o.g,function(l,d){this.g.hasOwnProperty(d)&&ks(l)},o),o.g={}}ar.prototype.N=function(){ar.aa.N.call(this),Qa(this)},ar.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var Os=u.JSON.stringify,yf=u.JSON.parse,If=class{stringify(o){return u.JSON.stringify(o,void 0)}parse(o){return u.JSON.parse(o,void 0)}};function Ls(){}Ls.prototype.h=null;function Wa(o){return o.h||(o.h=o.i())}function Ha(){}var ur={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function Bs(){Pt.call(this,"d")}C(Bs,Pt);function Us(){Pt.call(this,"c")}C(Us,Pt);var Le={},Ja=null;function mi(){return Ja=Ja||new St}Le.La="serverreachability";function Ya(o){Pt.call(this,Le.La,o)}C(Ya,Pt);function cr(o){const l=mi();Ft(l,new Ya(l))}Le.STAT_EVENT="statevent";function Xa(o,l){Pt.call(this,Le.STAT_EVENT,o),this.stat=l}C(Xa,Pt);function Mt(o){const l=mi();Ft(l,new Xa(l,o))}Le.Ma="timingevent";function Za(o,l){Pt.call(this,Le.Ma,o),this.size=l}C(Za,Pt);function lr(o,l){if(typeof o!="function")throw Error("Fn must not be null and must be a function");return u.setTimeout(function(){o()},l)}function hr(){this.g=!0}hr.prototype.xa=function(){this.g=!1};function Ef(o,l,d,m,A,S){o.info(function(){if(o.g)if(S)for(var F="",rt=S.split("&"),At=0;At<rt.length;At++){var X=rt[At].split("=");if(1<X.length){var Vt=X[0];X=X[1];var Ct=Vt.split("_");F=2<=Ct.length&&Ct[1]=="type"?F+(Vt+"="+X+"&"):F+(Vt+"=redacted&")}}else F=null;else F=S;return"XMLHTTP REQ ("+m+") [attempt "+A+"]: "+l+`
376
376
  `+d+`
377
377
  `+F})}function Tf(o,l,d,m,A,S,F){o.info(function(){return"XMLHTTP RESP ("+m+") [ attempt "+A+"]: "+l+`
378
378
  `+d+`
379
- `+S+" "+F})}function dn(o,l,d,m){o.info(function(){return"XMLHTTP TEXT ("+l+"): "+wf(o,d)+(m?" "+m:"")})}function vf(o,l){o.info(function(){return"TIMEOUT: "+l})}lr.prototype.info=function(){};function wf(o,l){if(!o.g)return l;if(!l)return null;try{var d=JSON.parse(l);if(d){for(o=0;o<d.length;o++)if(Array.isArray(d[o])){var m=d[o];if(!(2>m.length)){var A=m[1];if(Array.isArray(A)&&!(1>A.length)){var S=A[0];if(S!="noop"&&S!="stop"&&S!="close")for(var F=1;F<A.length;F++)A[F]=""}}}}return Os(d)}catch{return l}}var gi={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},tu={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"},qs;function pi(){}C(pi,Ls),pi.prototype.g=function(){return new XMLHttpRequest},pi.prototype.i=function(){return{}},qs=new pi;function ce(o,l,d,m){this.j=o,this.i=l,this.l=d,this.R=m||1,this.U=new or(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 eu}function eu(){this.i=null,this.g="",this.h=!1}var nu={},zs={};function js(o,l,d){o.L=1,o.v=Ei(Xt(l)),o.m=d,o.P=!0,ru(o,null)}function ru(o,l){o.F=Date.now(),_i(o),o.A=Xt(o.v);var d=o.A,m=o.R;Array.isArray(m)||(m=[String(m)]),_u(d.i,"t",m),o.C=0,d=o.j.J,o.h=new eu,o.g=Fu(o.j,d?l:null,!o.m),0<o.O&&(o.M=new _f(_(o.Y,o,o.g),o.O)),l=o.U,d=o.g,m=o.ca;var A="readystatechange";Array.isArray(A)||(A&&($a[0]=A.toString()),A=$a);for(var S=0;S<A.length;S++){var F=Ua(d,A[S],m||l.handleEvent,!1,l.h||l);if(!F)break;l.g[F.key]=F}l=o.H?p(o.H):{},o.m?(o.u||(o.u="POST"),l["Content-Type"]="application/x-www-form-urlencoded",o.g.ea(o.A,o.u,o.m,l)):(o.u="GET",o.g.ea(o.A,o.u,null,l)),ur(),Ef(o.i,o.u,o.A,o.l,o.R,o.m)}ce.prototype.ca=function(o){o=o.target;const l=this.M;l&&Zt(o)==3?l.j():this.Y(o)},ce.prototype.Y=function(o){try{if(o==this.g)t:{const Ct=Zt(this.g);var l=this.g.Ba();const gn=this.g.Z();if(!(3>Ct)&&(Ct!=3||this.g&&(this.h.h||this.g.oa()||Au(this.g)))){this.J||Ct!=4||l==7||(l==8||0>=gn?ur(3):ur(2)),Gs(this);var d=this.g.Z();this.X=d;e:if(iu(this)){var m=Au(this.g);o="";var A=m.length,S=Zt(this.g)==4;if(!this.h.i){if(typeof TextDecoder>"u"){Le(this),hr(this);var F="";break e}this.h.i=new u.TextDecoder}for(l=0;l<A;l++)this.h.h=!0,o+=this.h.i.decode(m[l],{stream:!(S&&l==A-1)});m.length=0,this.h.g+=o,this.C=0,F=this.h.g}else F=this.g.oa();if(this.o=d==200,Tf(this.i,this.u,this.A,this.l,this.R,Ct,d),this.o){if(this.T&&!this.K){e:{if(this.g){var rt,At=this.g;if((rt=At.g?At.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!z(rt)){var X=rt;break e}}X=null}if(d=X)dn(this.i,this.l,d,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,Ks(this,d);else{this.o=!1,this.s=3,Mt(12),Le(this),hr(this);break t}}if(this.P){d=!0;let Gt;for(;!this.J&&this.C<F.length;)if(Gt=Af(this,F),Gt==zs){Ct==4&&(this.s=4,Mt(14),d=!1),dn(this.i,this.l,null,"[Incomplete Response]");break}else if(Gt==nu){this.s=4,Mt(15),dn(this.i,this.l,F,"[Invalid Chunk]"),d=!1;break}else dn(this.i,this.l,Gt,null),Ks(this,Gt);if(iu(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),Ct!=4||F.length!=0||this.h.h||(this.s=1,Mt(16),d=!1),this.o=this.o&&d,!d)dn(this.i,this.l,F,"[Invalid Chunked Response]"),Le(this),hr(this);else if(0<F.length&&!this.W){this.W=!0;var Vt=this.j;Vt.g==this&&Vt.ba&&!Vt.M&&(Vt.j.info("Great, no buffering proxy detected. Bytes received: "+F.length),Ys(Vt),Vt.M=!0,Mt(11))}}else dn(this.i,this.l,F,null),Ks(this,F);Ct==4&&Le(this),this.o&&!this.J&&(Ct==4?Du(this.j,this):(this.o=!1,_i(this)))}else qf(this.g),d==400&&0<F.indexOf("Unknown SID")?(this.s=3,Mt(12)):(this.s=0,Mt(13)),Le(this),hr(this)}}}catch{}finally{}};function iu(o){return o.g?o.u=="GET"&&o.L!=2&&o.j.Ca:!1}function Af(o,l){var d=o.C,m=l.indexOf(`
380
- `,d);return m==-1?zs:(d=Number(l.substring(d,m)),isNaN(d)?nu:(m+=1,m+d>l.length?zs:(l=l.slice(m,m+d),o.C=m+d,l)))}ce.prototype.cancel=function(){this.J=!0,Le(this)};function _i(o){o.S=Date.now()+o.I,su(o,o.I)}function su(o,l){if(o.B!=null)throw Error("WatchDog timer not null");o.B=cr(_(o.ba,o),l)}function Gs(o){o.B&&(u.clearTimeout(o.B),o.B=null)}ce.prototype.ba=function(){this.B=null;const o=Date.now();0<=o-this.S?(vf(this.i,this.A),this.L!=2&&(ur(),Mt(17)),Le(this),this.s=2,hr(this)):su(this,this.S-o)};function hr(o){o.j.G==0||o.J||Du(o.j,o)}function Le(o){Gs(o);var l=o.M;l&&typeof l.ma=="function"&&l.ma(),o.M=null,Qa(o.U),o.g&&(l=o.g,o.g=null,l.abort(),l.ma())}function Ks(o,l){try{var d=o.j;if(d.G!=0&&(d.g==o||$s(d.h,o))){if(!o.K&&$s(d.h,o)&&d.G==3){try{var m=d.Da.g.parse(l)}catch{m=null}if(Array.isArray(m)&&m.length==3){var A=m;if(A[0]==0){t:if(!d.u){if(d.g)if(d.g.F+3e3<o.F)bi(d),Ai(d);else break t;Js(d),Mt(18)}}else d.za=A[1],0<d.za-d.T&&37500>A[2]&&d.F&&d.v==0&&!d.C&&(d.C=cr(_(d.Za,d),6e3));if(1>=uu(d.h)&&d.ca){try{d.ca()}catch{}d.ca=void 0}}else Ue(d,11)}else if((o.K||d.g==o)&&bi(d),!z(l))for(A=d.Da.g.parse(l),l=0;l<A.length;l++){let X=A[l];if(d.T=X[0],X=X[1],d.G==2)if(X[0]=="c"){d.K=X[1],d.ia=X[2];const Vt=X[3];Vt!=null&&(d.la=Vt,d.j.info("VER="+d.la));const Ct=X[4];Ct!=null&&(d.Aa=Ct,d.j.info("SVER="+d.Aa));const gn=X[5];gn!=null&&typeof gn=="number"&&0<gn&&(m=1.5*gn,d.L=m,d.j.info("backChannelRequestTimeoutMs_="+m)),m=d;const Gt=o.g;if(Gt){const Si=Gt.g?Gt.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(Si){var S=m.h;S.g||Si.indexOf("spdy")==-1&&Si.indexOf("quic")==-1&&Si.indexOf("h2")==-1||(S.j=S.l,S.g=new Set,S.h&&(Qs(S,S.h),S.h=null))}if(m.D){const Xs=Gt.g?Gt.g.getResponseHeader("X-HTTP-Session-Id"):null;Xs&&(m.ya=Xs,st(m.I,m.D,Xs))}}d.G=3,d.l&&d.l.ua(),d.ba&&(d.R=Date.now()-o.F,d.j.info("Handshake RTT: "+d.R+"ms")),m=d;var F=o;if(m.qa=ku(m,m.J?m.ia:null,m.W),F.K){cu(m.h,F);var rt=F,At=m.L;At&&(rt.I=At),rt.B&&(Gs(rt),_i(rt)),m.g=F}else Vu(m);0<d.i.length&&Ri(d)}else X[0]!="stop"&&X[0]!="close"||Ue(d,7);else d.G==3&&(X[0]=="stop"||X[0]=="close"?X[0]=="stop"?Ue(d,7):Hs(d):X[0]!="noop"&&d.l&&d.l.ta(X),d.v=0)}}ur(4)}catch{}}var Rf=class{constructor(o,l){this.g=o,this.map=l}};function ou(o){this.l=o||10,u.PerformanceNavigationTiming?(o=u.performance.getEntriesByType("navigation"),o=0<o.length&&(o[0].nextHopProtocol=="hq"||o[0].nextHopProtocol=="h2")):o=!!(u.chrome&&u.chrome.loadTimes&&u.chrome.loadTimes()&&u.chrome.loadTimes().wasFetchedViaSpdy),this.j=o?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function au(o){return o.h?!0:o.g?o.g.size>=o.j:!1}function uu(o){return o.h?1:o.g?o.g.size:0}function $s(o,l){return o.h?o.h==l:o.g?o.g.has(l):!1}function Qs(o,l){o.g?o.g.add(l):o.h=l}function cu(o,l){o.h&&o.h==l?o.h=null:o.g&&o.g.has(l)&&o.g.delete(l)}ou.prototype.cancel=function(){if(this.i=lu(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const o of this.g.values())o.cancel();this.g.clear()}};function lu(o){if(o.h!=null)return o.i.concat(o.h.D);if(o.g!=null&&o.g.size!==0){let l=o.i;for(const d of o.g.values())l=l.concat(d.D);return l}return N(o.i)}function bf(o){if(o.V&&typeof o.V=="function")return o.V();if(typeof Map<"u"&&o instanceof Map||typeof Set<"u"&&o instanceof Set)return Array.from(o.values());if(typeof o=="string")return o.split("");if(c(o)){for(var l=[],d=o.length,m=0;m<d;m++)l.push(o[m]);return l}l=[],d=0;for(m in o)l[d++]=o[m];return l}function Pf(o){if(o.na&&typeof o.na=="function")return o.na();if(!o.V||typeof o.V!="function"){if(typeof Map<"u"&&o instanceof Map)return Array.from(o.keys());if(!(typeof Set<"u"&&o instanceof Set)){if(c(o)||typeof o=="string"){var l=[];o=o.length;for(var d=0;d<o;d++)l.push(d);return l}l=[],d=0;for(const m in o)l[d++]=m;return l}}}function hu(o,l){if(o.forEach&&typeof o.forEach=="function")o.forEach(l,void 0);else if(c(o)||typeof o=="string")Array.prototype.forEach.call(o,l,void 0);else for(var d=Pf(o),m=bf(o),A=m.length,S=0;S<A;S++)l.call(void 0,m[S],d&&d[S],o)}var du=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function Sf(o,l){if(o){o=o.split("&");for(var d=0;d<o.length;d++){var m=o[d].indexOf("="),A=null;if(0<=m){var S=o[d].substring(0,m);A=o[d].substring(m+1)}else S=o[d];l(S,A?decodeURIComponent(A.replace(/\+/g," ")):"")}}}function Be(o){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,o instanceof Be){this.h=o.h,yi(this,o.j),this.o=o.o,this.g=o.g,Ii(this,o.s),this.l=o.l;var l=o.i,d=new mr;d.i=l.i,l.g&&(d.g=new Map(l.g),d.h=l.h),fu(this,d),this.m=o.m}else o&&(l=String(o).match(du))?(this.h=!1,yi(this,l[1]||"",!0),this.o=dr(l[2]||""),this.g=dr(l[3]||"",!0),Ii(this,l[4]),this.l=dr(l[5]||"",!0),fu(this,l[6]||"",!0),this.m=dr(l[7]||"")):(this.h=!1,this.i=new mr(null,this.h))}Be.prototype.toString=function(){var o=[],l=this.j;l&&o.push(fr(l,mu,!0),":");var d=this.g;return(d||l=="file")&&(o.push("//"),(l=this.o)&&o.push(fr(l,mu,!0),"@"),o.push(encodeURIComponent(String(d)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),d=this.s,d!=null&&o.push(":",String(d))),(d=this.l)&&(this.g&&d.charAt(0)!="/"&&o.push("/"),o.push(fr(d,d.charAt(0)=="/"?Df:Cf,!0))),(d=this.i.toString())&&o.push("?",d),(d=this.m)&&o.push("#",fr(d,Nf)),o.join("")};function Xt(o){return new Be(o)}function yi(o,l,d){o.j=d?dr(l,!0):l,o.j&&(o.j=o.j.replace(/:$/,""))}function Ii(o,l){if(l){if(l=Number(l),isNaN(l)||0>l)throw Error("Bad port number "+l);o.s=l}else o.s=null}function fu(o,l,d){l instanceof mr?(o.i=l,kf(o.i,o.h)):(d||(l=fr(l,xf)),o.i=new mr(l,o.h))}function st(o,l,d){o.i.set(l,d)}function Ei(o){return st(o,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),o}function dr(o,l){return o?l?decodeURI(o.replace(/%25/g,"%2525")):decodeURIComponent(o):""}function fr(o,l,d){return typeof o=="string"?(o=encodeURI(o).replace(l,Vf),d&&(o=o.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),o):null}function Vf(o){return o=o.charCodeAt(0),"%"+(o>>4&15).toString(16)+(o&15).toString(16)}var mu=/[#\/\?@]/g,Cf=/[#\?:]/g,Df=/[#\?]/g,xf=/[#\?@]/g,Nf=/#/g;function mr(o,l){this.h=this.g=null,this.i=o||null,this.j=!!l}function le(o){o.g||(o.g=new Map,o.h=0,o.i&&Sf(o.i,function(l,d){o.add(decodeURIComponent(l.replace(/\+/g," ")),d)}))}r=mr.prototype,r.add=function(o,l){le(this),this.i=null,o=fn(this,o);var d=this.g.get(o);return d||this.g.set(o,d=[]),d.push(l),this.h+=1,this};function gu(o,l){le(o),l=fn(o,l),o.g.has(l)&&(o.i=null,o.h-=o.g.get(l).length,o.g.delete(l))}function pu(o,l){return le(o),l=fn(o,l),o.g.has(l)}r.forEach=function(o,l){le(this),this.g.forEach(function(d,m){d.forEach(function(A){o.call(l,A,m,this)},this)},this)},r.na=function(){le(this);const o=Array.from(this.g.values()),l=Array.from(this.g.keys()),d=[];for(let m=0;m<l.length;m++){const A=o[m];for(let S=0;S<A.length;S++)d.push(l[m])}return d},r.V=function(o){le(this);let l=[];if(typeof o=="string")pu(this,o)&&(l=l.concat(this.g.get(fn(this,o))));else{o=Array.from(this.g.values());for(let d=0;d<o.length;d++)l=l.concat(o[d])}return l},r.set=function(o,l){return le(this),this.i=null,o=fn(this,o),pu(this,o)&&(this.h-=this.g.get(o).length),this.g.set(o,[l]),this.h+=1,this},r.get=function(o,l){return o?(o=this.V(o),0<o.length?String(o[0]):l):l};function _u(o,l,d){gu(o,l),0<d.length&&(o.i=null,o.g.set(fn(o,l),N(d)),o.h+=d.length)}r.toString=function(){if(this.i)return this.i;if(!this.g)return"";const o=[],l=Array.from(this.g.keys());for(var d=0;d<l.length;d++){var m=l[d];const S=encodeURIComponent(String(m)),F=this.V(m);for(m=0;m<F.length;m++){var A=S;F[m]!==""&&(A+="="+encodeURIComponent(String(F[m]))),o.push(A)}}return this.i=o.join("&")};function fn(o,l){return l=String(l),o.j&&(l=l.toLowerCase()),l}function kf(o,l){l&&!o.j&&(le(o),o.i=null,o.g.forEach(function(d,m){var A=m.toLowerCase();m!=A&&(gu(this,m),_u(this,A,d))},o)),o.j=l}function Ff(o,l){const d=new lr;if(u.Image){const m=new Image;m.onload=R(he,d,"TestLoadImage: loaded",!0,l,m),m.onerror=R(he,d,"TestLoadImage: error",!1,l,m),m.onabort=R(he,d,"TestLoadImage: abort",!1,l,m),m.ontimeout=R(he,d,"TestLoadImage: timeout",!1,l,m),u.setTimeout(function(){m.ontimeout&&m.ontimeout()},1e4),m.src=o}else l(!1)}function Mf(o,l){const d=new lr,m=new AbortController,A=setTimeout(()=>{m.abort(),he(d,"TestPingServer: timeout",!1,l)},1e4);fetch(o,{signal:m.signal}).then(S=>{clearTimeout(A),S.ok?he(d,"TestPingServer: ok",!0,l):he(d,"TestPingServer: server error",!1,l)}).catch(()=>{clearTimeout(A),he(d,"TestPingServer: error",!1,l)})}function he(o,l,d,m,A){try{A&&(A.onload=null,A.onerror=null,A.onabort=null,A.ontimeout=null),m(d)}catch{}}function Of(){this.g=new If}function Lf(o,l,d){const m=d||"";try{hu(o,function(A,S){let F=A;h(A)&&(F=Os(A)),l.push(m+S+"="+encodeURIComponent(F))})}catch(A){throw l.push(m+"type="+encodeURIComponent("_badmap")),A}}function Ti(o){this.l=o.Ub||null,this.j=o.eb||!1}C(Ti,Ls),Ti.prototype.g=function(){return new vi(this.l,this.j)},Ti.prototype.i=function(o){return function(){return o}}({});function vi(o,l){St.call(this),this.D=o,this.o=l,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}C(vi,St),r=vi.prototype,r.open=function(o,l){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.B=o,this.A=l,this.readyState=1,pr(this)},r.send=function(o){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");this.g=!0;const l={headers:this.u,method:this.B,credentials:this.m,cache:void 0};o&&(l.body=o),(this.D||u).fetch(new Request(this.A,l)).then(this.Sa.bind(this),this.ga.bind(this))},r.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,gr(this)),this.readyState=0},r.Sa=function(o){if(this.g&&(this.l=o,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=o.headers,this.readyState=2,pr(this)),this.g&&(this.readyState=3,pr(this),this.g)))if(this.responseType==="arraybuffer")o.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(typeof u.ReadableStream<"u"&&"body"in o){if(this.j=o.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;yu(this)}else o.text().then(this.Ra.bind(this),this.ga.bind(this))};function yu(o){o.j.read().then(o.Pa.bind(o)).catch(o.ga.bind(o))}r.Pa=function(o){if(this.g){if(this.o&&o.value)this.response.push(o.value);else if(!this.o){var l=o.value?o.value:new Uint8Array(0);(l=this.v.decode(l,{stream:!o.done}))&&(this.response=this.responseText+=l)}o.done?gr(this):pr(this),this.readyState==3&&yu(this)}},r.Ra=function(o){this.g&&(this.response=this.responseText=o,gr(this))},r.Qa=function(o){this.g&&(this.response=o,gr(this))},r.ga=function(){this.g&&gr(this)};function gr(o){o.readyState=4,o.l=null,o.j=null,o.v=null,pr(o)}r.setRequestHeader=function(o,l){this.u.append(o,l)},r.getResponseHeader=function(o){return this.h&&this.h.get(o.toLowerCase())||""},r.getAllResponseHeaders=function(){if(!this.h)return"";const o=[],l=this.h.entries();for(var d=l.next();!d.done;)d=d.value,o.push(d[0]+": "+d[1]),d=l.next();return o.join(`\r
381
- `)};function pr(o){o.onreadystatechange&&o.onreadystatechange.call(o)}Object.defineProperty(vi.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(o){this.m=o?"include":"same-origin"}});function Iu(o){let l="";return K(o,function(d,m){l+=m,l+=":",l+=d,l+=`\r
379
+ `+S+" "+F})}function fn(o,l,d,m){o.info(function(){return"XMLHTTP TEXT ("+l+"): "+wf(o,d)+(m?" "+m:"")})}function vf(o,l){o.info(function(){return"TIMEOUT: "+l})}hr.prototype.info=function(){};function wf(o,l){if(!o.g)return l;if(!l)return null;try{var d=JSON.parse(l);if(d){for(o=0;o<d.length;o++)if(Array.isArray(d[o])){var m=d[o];if(!(2>m.length)){var A=m[1];if(Array.isArray(A)&&!(1>A.length)){var S=A[0];if(S!="noop"&&S!="stop"&&S!="close")for(var F=1;F<A.length;F++)A[F]=""}}}}return Os(d)}catch{return l}}var gi={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},tu={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"},qs;function pi(){}C(pi,Ls),pi.prototype.g=function(){return new XMLHttpRequest},pi.prototype.i=function(){return{}},qs=new pi;function ce(o,l,d,m){this.j=o,this.i=l,this.l=d,this.R=m||1,this.U=new ar(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 eu}function eu(){this.i=null,this.g="",this.h=!1}var nu={},zs={};function js(o,l,d){o.L=1,o.v=Ei(Xt(l)),o.m=d,o.P=!0,ru(o,null)}function ru(o,l){o.F=Date.now(),_i(o),o.A=Xt(o.v);var d=o.A,m=o.R;Array.isArray(m)||(m=[String(m)]),_u(d.i,"t",m),o.C=0,d=o.j.J,o.h=new eu,o.g=Fu(o.j,d?l:null,!o.m),0<o.O&&(o.M=new _f(_(o.Y,o,o.g),o.O)),l=o.U,d=o.g,m=o.ca;var A="readystatechange";Array.isArray(A)||(A&&($a[0]=A.toString()),A=$a);for(var S=0;S<A.length;S++){var F=Ua(d,A[S],m||l.handleEvent,!1,l.h||l);if(!F)break;l.g[F.key]=F}l=o.H?p(o.H):{},o.m?(o.u||(o.u="POST"),l["Content-Type"]="application/x-www-form-urlencoded",o.g.ea(o.A,o.u,o.m,l)):(o.u="GET",o.g.ea(o.A,o.u,null,l)),cr(),Ef(o.i,o.u,o.A,o.l,o.R,o.m)}ce.prototype.ca=function(o){o=o.target;const l=this.M;l&&Zt(o)==3?l.j():this.Y(o)},ce.prototype.Y=function(o){try{if(o==this.g)t:{const Ct=Zt(this.g);var l=this.g.Ba();const pn=this.g.Z();if(!(3>Ct)&&(Ct!=3||this.g&&(this.h.h||this.g.oa()||Au(this.g)))){this.J||Ct!=4||l==7||(l==8||0>=pn?cr(3):cr(2)),Gs(this);var d=this.g.Z();this.X=d;e:if(iu(this)){var m=Au(this.g);o="";var A=m.length,S=Zt(this.g)==4;if(!this.h.i){if(typeof TextDecoder>"u"){Be(this),dr(this);var F="";break e}this.h.i=new u.TextDecoder}for(l=0;l<A;l++)this.h.h=!0,o+=this.h.i.decode(m[l],{stream:!(S&&l==A-1)});m.length=0,this.h.g+=o,this.C=0,F=this.h.g}else F=this.g.oa();if(this.o=d==200,Tf(this.i,this.u,this.A,this.l,this.R,Ct,d),this.o){if(this.T&&!this.K){e:{if(this.g){var rt,At=this.g;if((rt=At.g?At.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!z(rt)){var X=rt;break e}}X=null}if(d=X)fn(this.i,this.l,d,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,Ks(this,d);else{this.o=!1,this.s=3,Mt(12),Be(this),dr(this);break t}}if(this.P){d=!0;let Gt;for(;!this.J&&this.C<F.length;)if(Gt=Af(this,F),Gt==zs){Ct==4&&(this.s=4,Mt(14),d=!1),fn(this.i,this.l,null,"[Incomplete Response]");break}else if(Gt==nu){this.s=4,Mt(15),fn(this.i,this.l,F,"[Invalid Chunk]"),d=!1;break}else fn(this.i,this.l,Gt,null),Ks(this,Gt);if(iu(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),Ct!=4||F.length!=0||this.h.h||(this.s=1,Mt(16),d=!1),this.o=this.o&&d,!d)fn(this.i,this.l,F,"[Invalid Chunked Response]"),Be(this),dr(this);else if(0<F.length&&!this.W){this.W=!0;var Vt=this.j;Vt.g==this&&Vt.ba&&!Vt.M&&(Vt.j.info("Great, no buffering proxy detected. Bytes received: "+F.length),Ys(Vt),Vt.M=!0,Mt(11))}}else fn(this.i,this.l,F,null),Ks(this,F);Ct==4&&Be(this),this.o&&!this.J&&(Ct==4?Du(this.j,this):(this.o=!1,_i(this)))}else qf(this.g),d==400&&0<F.indexOf("Unknown SID")?(this.s=3,Mt(12)):(this.s=0,Mt(13)),Be(this),dr(this)}}}catch{}finally{}};function iu(o){return o.g?o.u=="GET"&&o.L!=2&&o.j.Ca:!1}function Af(o,l){var d=o.C,m=l.indexOf(`
380
+ `,d);return m==-1?zs:(d=Number(l.substring(d,m)),isNaN(d)?nu:(m+=1,m+d>l.length?zs:(l=l.slice(m,m+d),o.C=m+d,l)))}ce.prototype.cancel=function(){this.J=!0,Be(this)};function _i(o){o.S=Date.now()+o.I,su(o,o.I)}function su(o,l){if(o.B!=null)throw Error("WatchDog timer not null");o.B=lr(_(o.ba,o),l)}function Gs(o){o.B&&(u.clearTimeout(o.B),o.B=null)}ce.prototype.ba=function(){this.B=null;const o=Date.now();0<=o-this.S?(vf(this.i,this.A),this.L!=2&&(cr(),Mt(17)),Be(this),this.s=2,dr(this)):su(this,this.S-o)};function dr(o){o.j.G==0||o.J||Du(o.j,o)}function Be(o){Gs(o);var l=o.M;l&&typeof l.ma=="function"&&l.ma(),o.M=null,Qa(o.U),o.g&&(l=o.g,o.g=null,l.abort(),l.ma())}function Ks(o,l){try{var d=o.j;if(d.G!=0&&(d.g==o||$s(d.h,o))){if(!o.K&&$s(d.h,o)&&d.G==3){try{var m=d.Da.g.parse(l)}catch{m=null}if(Array.isArray(m)&&m.length==3){var A=m;if(A[0]==0){t:if(!d.u){if(d.g)if(d.g.F+3e3<o.F)bi(d),Ai(d);else break t;Js(d),Mt(18)}}else d.za=A[1],0<d.za-d.T&&37500>A[2]&&d.F&&d.v==0&&!d.C&&(d.C=lr(_(d.Za,d),6e3));if(1>=uu(d.h)&&d.ca){try{d.ca()}catch{}d.ca=void 0}}else qe(d,11)}else if((o.K||d.g==o)&&bi(d),!z(l))for(A=d.Da.g.parse(l),l=0;l<A.length;l++){let X=A[l];if(d.T=X[0],X=X[1],d.G==2)if(X[0]=="c"){d.K=X[1],d.ia=X[2];const Vt=X[3];Vt!=null&&(d.la=Vt,d.j.info("VER="+d.la));const Ct=X[4];Ct!=null&&(d.Aa=Ct,d.j.info("SVER="+d.Aa));const pn=X[5];pn!=null&&typeof pn=="number"&&0<pn&&(m=1.5*pn,d.L=m,d.j.info("backChannelRequestTimeoutMs_="+m)),m=d;const Gt=o.g;if(Gt){const Si=Gt.g?Gt.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(Si){var S=m.h;S.g||Si.indexOf("spdy")==-1&&Si.indexOf("quic")==-1&&Si.indexOf("h2")==-1||(S.j=S.l,S.g=new Set,S.h&&(Qs(S,S.h),S.h=null))}if(m.D){const Xs=Gt.g?Gt.g.getResponseHeader("X-HTTP-Session-Id"):null;Xs&&(m.ya=Xs,st(m.I,m.D,Xs))}}d.G=3,d.l&&d.l.ua(),d.ba&&(d.R=Date.now()-o.F,d.j.info("Handshake RTT: "+d.R+"ms")),m=d;var F=o;if(m.qa=ku(m,m.J?m.ia:null,m.W),F.K){cu(m.h,F);var rt=F,At=m.L;At&&(rt.I=At),rt.B&&(Gs(rt),_i(rt)),m.g=F}else Vu(m);0<d.i.length&&Ri(d)}else X[0]!="stop"&&X[0]!="close"||qe(d,7);else d.G==3&&(X[0]=="stop"||X[0]=="close"?X[0]=="stop"?qe(d,7):Hs(d):X[0]!="noop"&&d.l&&d.l.ta(X),d.v=0)}}cr(4)}catch{}}var Rf=class{constructor(o,l){this.g=o,this.map=l}};function ou(o){this.l=o||10,u.PerformanceNavigationTiming?(o=u.performance.getEntriesByType("navigation"),o=0<o.length&&(o[0].nextHopProtocol=="hq"||o[0].nextHopProtocol=="h2")):o=!!(u.chrome&&u.chrome.loadTimes&&u.chrome.loadTimes()&&u.chrome.loadTimes().wasFetchedViaSpdy),this.j=o?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function au(o){return o.h?!0:o.g?o.g.size>=o.j:!1}function uu(o){return o.h?1:o.g?o.g.size:0}function $s(o,l){return o.h?o.h==l:o.g?o.g.has(l):!1}function Qs(o,l){o.g?o.g.add(l):o.h=l}function cu(o,l){o.h&&o.h==l?o.h=null:o.g&&o.g.has(l)&&o.g.delete(l)}ou.prototype.cancel=function(){if(this.i=lu(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const o of this.g.values())o.cancel();this.g.clear()}};function lu(o){if(o.h!=null)return o.i.concat(o.h.D);if(o.g!=null&&o.g.size!==0){let l=o.i;for(const d of o.g.values())l=l.concat(d.D);return l}return N(o.i)}function bf(o){if(o.V&&typeof o.V=="function")return o.V();if(typeof Map<"u"&&o instanceof Map||typeof Set<"u"&&o instanceof Set)return Array.from(o.values());if(typeof o=="string")return o.split("");if(c(o)){for(var l=[],d=o.length,m=0;m<d;m++)l.push(o[m]);return l}l=[],d=0;for(m in o)l[d++]=o[m];return l}function Pf(o){if(o.na&&typeof o.na=="function")return o.na();if(!o.V||typeof o.V!="function"){if(typeof Map<"u"&&o instanceof Map)return Array.from(o.keys());if(!(typeof Set<"u"&&o instanceof Set)){if(c(o)||typeof o=="string"){var l=[];o=o.length;for(var d=0;d<o;d++)l.push(d);return l}l=[],d=0;for(const m in o)l[d++]=m;return l}}}function hu(o,l){if(o.forEach&&typeof o.forEach=="function")o.forEach(l,void 0);else if(c(o)||typeof o=="string")Array.prototype.forEach.call(o,l,void 0);else for(var d=Pf(o),m=bf(o),A=m.length,S=0;S<A;S++)l.call(void 0,m[S],d&&d[S],o)}var du=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function Sf(o,l){if(o){o=o.split("&");for(var d=0;d<o.length;d++){var m=o[d].indexOf("="),A=null;if(0<=m){var S=o[d].substring(0,m);A=o[d].substring(m+1)}else S=o[d];l(S,A?decodeURIComponent(A.replace(/\+/g," ")):"")}}}function Ue(o){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,o instanceof Ue){this.h=o.h,yi(this,o.j),this.o=o.o,this.g=o.g,Ii(this,o.s),this.l=o.l;var l=o.i,d=new gr;d.i=l.i,l.g&&(d.g=new Map(l.g),d.h=l.h),fu(this,d),this.m=o.m}else o&&(l=String(o).match(du))?(this.h=!1,yi(this,l[1]||"",!0),this.o=fr(l[2]||""),this.g=fr(l[3]||"",!0),Ii(this,l[4]),this.l=fr(l[5]||"",!0),fu(this,l[6]||"",!0),this.m=fr(l[7]||"")):(this.h=!1,this.i=new gr(null,this.h))}Ue.prototype.toString=function(){var o=[],l=this.j;l&&o.push(mr(l,mu,!0),":");var d=this.g;return(d||l=="file")&&(o.push("//"),(l=this.o)&&o.push(mr(l,mu,!0),"@"),o.push(encodeURIComponent(String(d)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),d=this.s,d!=null&&o.push(":",String(d))),(d=this.l)&&(this.g&&d.charAt(0)!="/"&&o.push("/"),o.push(mr(d,d.charAt(0)=="/"?Df:Cf,!0))),(d=this.i.toString())&&o.push("?",d),(d=this.m)&&o.push("#",mr(d,Nf)),o.join("")};function Xt(o){return new Ue(o)}function yi(o,l,d){o.j=d?fr(l,!0):l,o.j&&(o.j=o.j.replace(/:$/,""))}function Ii(o,l){if(l){if(l=Number(l),isNaN(l)||0>l)throw Error("Bad port number "+l);o.s=l}else o.s=null}function fu(o,l,d){l instanceof gr?(o.i=l,kf(o.i,o.h)):(d||(l=mr(l,xf)),o.i=new gr(l,o.h))}function st(o,l,d){o.i.set(l,d)}function Ei(o){return st(o,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),o}function fr(o,l){return o?l?decodeURI(o.replace(/%25/g,"%2525")):decodeURIComponent(o):""}function mr(o,l,d){return typeof o=="string"?(o=encodeURI(o).replace(l,Vf),d&&(o=o.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),o):null}function Vf(o){return o=o.charCodeAt(0),"%"+(o>>4&15).toString(16)+(o&15).toString(16)}var mu=/[#\/\?@]/g,Cf=/[#\?:]/g,Df=/[#\?]/g,xf=/[#\?@]/g,Nf=/#/g;function gr(o,l){this.h=this.g=null,this.i=o||null,this.j=!!l}function le(o){o.g||(o.g=new Map,o.h=0,o.i&&Sf(o.i,function(l,d){o.add(decodeURIComponent(l.replace(/\+/g," ")),d)}))}r=gr.prototype,r.add=function(o,l){le(this),this.i=null,o=mn(this,o);var d=this.g.get(o);return d||this.g.set(o,d=[]),d.push(l),this.h+=1,this};function gu(o,l){le(o),l=mn(o,l),o.g.has(l)&&(o.i=null,o.h-=o.g.get(l).length,o.g.delete(l))}function pu(o,l){return le(o),l=mn(o,l),o.g.has(l)}r.forEach=function(o,l){le(this),this.g.forEach(function(d,m){d.forEach(function(A){o.call(l,A,m,this)},this)},this)},r.na=function(){le(this);const o=Array.from(this.g.values()),l=Array.from(this.g.keys()),d=[];for(let m=0;m<l.length;m++){const A=o[m];for(let S=0;S<A.length;S++)d.push(l[m])}return d},r.V=function(o){le(this);let l=[];if(typeof o=="string")pu(this,o)&&(l=l.concat(this.g.get(mn(this,o))));else{o=Array.from(this.g.values());for(let d=0;d<o.length;d++)l=l.concat(o[d])}return l},r.set=function(o,l){return le(this),this.i=null,o=mn(this,o),pu(this,o)&&(this.h-=this.g.get(o).length),this.g.set(o,[l]),this.h+=1,this},r.get=function(o,l){return o?(o=this.V(o),0<o.length?String(o[0]):l):l};function _u(o,l,d){gu(o,l),0<d.length&&(o.i=null,o.g.set(mn(o,l),N(d)),o.h+=d.length)}r.toString=function(){if(this.i)return this.i;if(!this.g)return"";const o=[],l=Array.from(this.g.keys());for(var d=0;d<l.length;d++){var m=l[d];const S=encodeURIComponent(String(m)),F=this.V(m);for(m=0;m<F.length;m++){var A=S;F[m]!==""&&(A+="="+encodeURIComponent(String(F[m]))),o.push(A)}}return this.i=o.join("&")};function mn(o,l){return l=String(l),o.j&&(l=l.toLowerCase()),l}function kf(o,l){l&&!o.j&&(le(o),o.i=null,o.g.forEach(function(d,m){var A=m.toLowerCase();m!=A&&(gu(this,m),_u(this,A,d))},o)),o.j=l}function Ff(o,l){const d=new hr;if(u.Image){const m=new Image;m.onload=R(he,d,"TestLoadImage: loaded",!0,l,m),m.onerror=R(he,d,"TestLoadImage: error",!1,l,m),m.onabort=R(he,d,"TestLoadImage: abort",!1,l,m),m.ontimeout=R(he,d,"TestLoadImage: timeout",!1,l,m),u.setTimeout(function(){m.ontimeout&&m.ontimeout()},1e4),m.src=o}else l(!1)}function Mf(o,l){const d=new hr,m=new AbortController,A=setTimeout(()=>{m.abort(),he(d,"TestPingServer: timeout",!1,l)},1e4);fetch(o,{signal:m.signal}).then(S=>{clearTimeout(A),S.ok?he(d,"TestPingServer: ok",!0,l):he(d,"TestPingServer: server error",!1,l)}).catch(()=>{clearTimeout(A),he(d,"TestPingServer: error",!1,l)})}function he(o,l,d,m,A){try{A&&(A.onload=null,A.onerror=null,A.onabort=null,A.ontimeout=null),m(d)}catch{}}function Of(){this.g=new If}function Lf(o,l,d){const m=d||"";try{hu(o,function(A,S){let F=A;h(A)&&(F=Os(A)),l.push(m+S+"="+encodeURIComponent(F))})}catch(A){throw l.push(m+"type="+encodeURIComponent("_badmap")),A}}function Ti(o){this.l=o.Ub||null,this.j=o.eb||!1}C(Ti,Ls),Ti.prototype.g=function(){return new vi(this.l,this.j)},Ti.prototype.i=function(o){return function(){return o}}({});function vi(o,l){St.call(this),this.D=o,this.o=l,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}C(vi,St),r=vi.prototype,r.open=function(o,l){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.B=o,this.A=l,this.readyState=1,_r(this)},r.send=function(o){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");this.g=!0;const l={headers:this.u,method:this.B,credentials:this.m,cache:void 0};o&&(l.body=o),(this.D||u).fetch(new Request(this.A,l)).then(this.Sa.bind(this),this.ga.bind(this))},r.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,pr(this)),this.readyState=0},r.Sa=function(o){if(this.g&&(this.l=o,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=o.headers,this.readyState=2,_r(this)),this.g&&(this.readyState=3,_r(this),this.g)))if(this.responseType==="arraybuffer")o.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(typeof u.ReadableStream<"u"&&"body"in o){if(this.j=o.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;yu(this)}else o.text().then(this.Ra.bind(this),this.ga.bind(this))};function yu(o){o.j.read().then(o.Pa.bind(o)).catch(o.ga.bind(o))}r.Pa=function(o){if(this.g){if(this.o&&o.value)this.response.push(o.value);else if(!this.o){var l=o.value?o.value:new Uint8Array(0);(l=this.v.decode(l,{stream:!o.done}))&&(this.response=this.responseText+=l)}o.done?pr(this):_r(this),this.readyState==3&&yu(this)}},r.Ra=function(o){this.g&&(this.response=this.responseText=o,pr(this))},r.Qa=function(o){this.g&&(this.response=o,pr(this))},r.ga=function(){this.g&&pr(this)};function pr(o){o.readyState=4,o.l=null,o.j=null,o.v=null,_r(o)}r.setRequestHeader=function(o,l){this.u.append(o,l)},r.getResponseHeader=function(o){return this.h&&this.h.get(o.toLowerCase())||""},r.getAllResponseHeaders=function(){if(!this.h)return"";const o=[],l=this.h.entries();for(var d=l.next();!d.done;)d=d.value,o.push(d[0]+": "+d[1]),d=l.next();return o.join(`\r
381
+ `)};function _r(o){o.onreadystatechange&&o.onreadystatechange.call(o)}Object.defineProperty(vi.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(o){this.m=o?"include":"same-origin"}});function Iu(o){let l="";return K(o,function(d,m){l+=m,l+=":",l+=d,l+=`\r
382
382
  `}),l}function Ws(o,l,d){t:{for(m in d){var m=!1;break t}m=!0}m||(d=Iu(d),typeof o=="string"?d!=null&&encodeURIComponent(String(d)):st(o,l,d))}function ft(o){St.call(this),this.headers=new Map,this.o=o||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}C(ft,St);var Bf=/^https?$/i,Uf=["POST","PUT"];r=ft.prototype,r.Ha=function(o){this.J=o},r.ea=function(o,l,d,m){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+o);l=l?l.toUpperCase():"GET",this.D=o,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():qs.g(),this.v=this.o?Wa(this.o):Wa(qs),this.g.onreadystatechange=_(this.Ea,this);try{this.B=!0,this.g.open(l,String(o),!0),this.B=!1}catch(S){Eu(this,S);return}if(o=d||"",d=new Map(this.headers),m)if(Object.getPrototypeOf(m)===Object.prototype)for(var A in m)d.set(A,m[A]);else if(typeof m.keys=="function"&&typeof m.get=="function")for(const S of m.keys())d.set(S,m.get(S));else throw Error("Unknown input type for opt_headers: "+String(m));m=Array.from(d.keys()).find(S=>S.toLowerCase()=="content-type"),A=u.FormData&&o instanceof u.FormData,!(0<=Array.prototype.indexOf.call(Uf,l,void 0))||m||A||d.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[S,F]of d)this.g.setRequestHeader(S,F);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{wu(this),this.u=!0,this.g.send(o),this.u=!1}catch(S){Eu(this,S)}};function Eu(o,l){o.h=!1,o.g&&(o.j=!0,o.g.abort(),o.j=!1),o.l=l,o.m=5,Tu(o),wi(o)}function Tu(o){o.A||(o.A=!0,Ft(o,"complete"),Ft(o,"error"))}r.abort=function(o){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=o||7,Ft(this,"complete"),Ft(this,"abort"),wi(this))},r.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),wi(this,!0)),ft.aa.N.call(this)},r.Ea=function(){this.s||(this.B||this.u||this.j?vu(this):this.bb())},r.bb=function(){vu(this)};function vu(o){if(o.h&&typeof a<"u"&&(!o.v[1]||Zt(o)!=4||o.Z()!=2)){if(o.u&&Zt(o)==4)Ga(o.Ea,0,o);else if(Ft(o,"readystatechange"),Zt(o)==4){o.h=!1;try{const F=o.Z();t:switch(F){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var l=!0;break t;default:l=!1}var d;if(!(d=l)){var m;if(m=F===0){var A=String(o.D).match(du)[1]||null;!A&&u.self&&u.self.location&&(A=u.self.location.protocol.slice(0,-1)),m=!Bf.test(A?A.toLowerCase():"")}d=m}if(d)Ft(o,"complete"),Ft(o,"success");else{o.m=6;try{var S=2<Zt(o)?o.g.statusText:""}catch{S=""}o.l=S+" ["+o.Z()+"]",Tu(o)}}finally{wi(o)}}}}function wi(o,l){if(o.g){wu(o);const d=o.g,m=o.v[0]?()=>{}:null;o.g=null,o.v=null,l||Ft(o,"ready");try{d.onreadystatechange=m}catch{}}}function wu(o){o.I&&(u.clearTimeout(o.I),o.I=null)}r.isActive=function(){return!!this.g};function Zt(o){return o.g?o.g.readyState:0}r.Z=function(){try{return 2<Zt(this)?this.g.status:-1}catch{return-1}},r.oa=function(){try{return this.g?this.g.responseText:""}catch{return""}},r.Oa=function(o){if(this.g){var l=this.g.responseText;return o&&l.indexOf(o)==0&&(l=l.substring(o.length)),yf(l)}};function Au(o){try{if(!o.g)return null;if("response"in o.g)return o.g.response;switch(o.H){case"":case"text":return o.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in o.g)return o.g.mozResponseArrayBuffer}return null}catch{return null}}function qf(o){const l={};o=(o.g&&2<=Zt(o)&&o.g.getAllResponseHeaders()||"").split(`\r
383
- `);for(let m=0;m<o.length;m++){if(z(o[m]))continue;var d=v(o[m]);const A=d[0];if(d=d[1],typeof d!="string")continue;d=d.trim();const S=l[A]||[];l[A]=S,S.push(d)}E(l,function(m){return m.join(", ")})}r.Ba=function(){return this.m},r.Ka=function(){return typeof this.l=="string"?this.l:String(this.l)};function _r(o,l,d){return d&&d.internalChannelParams&&d.internalChannelParams[o]||l}function Ru(o){this.Aa=0,this.i=[],this.j=new lr,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=_r("failFast",!1,o),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=_r("baseRetryDelayMs",5e3,o),this.cb=_r("retryDelaySeedMs",1e4,o),this.Wa=_r("forwardChannelMaxRetries",2,o),this.wa=_r("forwardChannelRequestTimeoutMs",2e4,o),this.pa=o&&o.xmlHttpFactory||void 0,this.Xa=o&&o.Tb||void 0,this.Ca=o&&o.useFetchStreams||!1,this.L=void 0,this.J=o&&o.supportsCrossDomainXhr||!1,this.K="",this.h=new ou(o&&o.concurrentRequestLimit),this.Da=new Of,this.P=o&&o.fastHandshake||!1,this.O=o&&o.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=o&&o.Rb||!1,o&&o.xa&&this.j.xa(),o&&o.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&o&&o.detectBufferingProxy||!1,this.ja=void 0,o&&o.longPollingTimeout&&0<o.longPollingTimeout&&(this.ja=o.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}r=Ru.prototype,r.la=8,r.G=1,r.connect=function(o,l,d,m){Mt(0),this.W=o,this.H=l||{},d&&m!==void 0&&(this.H.OSID=d,this.H.OAID=m),this.F=this.X,this.I=ku(this,null,this.W),Ri(this)};function Hs(o){if(bu(o),o.G==3){var l=o.U++,d=Xt(o.I);if(st(d,"SID",o.K),st(d,"RID",l),st(d,"TYPE","terminate"),yr(o,d),l=new ce(o,o.j,l),l.L=2,l.v=Ei(Xt(d)),d=!1,u.navigator&&u.navigator.sendBeacon)try{d=u.navigator.sendBeacon(l.v.toString(),"")}catch{}!d&&u.Image&&(new Image().src=l.v,d=!0),d||(l.g=Fu(l.j,null),l.g.ea(l.v)),l.F=Date.now(),_i(l)}Nu(o)}function Ai(o){o.g&&(Ys(o),o.g.cancel(),o.g=null)}function bu(o){Ai(o),o.u&&(u.clearTimeout(o.u),o.u=null),bi(o),o.h.cancel(),o.s&&(typeof o.s=="number"&&u.clearTimeout(o.s),o.s=null)}function Ri(o){if(!au(o.h)&&!o.s){o.s=!0;var l=o.Ga;rr||Ba(),ir||(rr(),ir=!0),Vs.add(l,o),o.B=0}}function zf(o,l){return uu(o.h)>=o.h.j-(o.s?1:0)?!1:o.s?(o.i=l.D.concat(o.i),!0):o.G==1||o.G==2||o.B>=(o.Va?0:o.Wa)?!1:(o.s=cr(_(o.Ga,o,l),xu(o,o.B)),o.B++,!0)}r.Ga=function(o){if(this.s)if(this.s=null,this.G==1){if(!o){this.U=Math.floor(1e5*Math.random()),o=this.U++;const A=new ce(this,this.j,o);let S=this.o;if(this.S&&(S?(S=p(S),T(S,this.S)):S=this.S),this.m!==null||this.O||(A.H=S,S=null),this.P)t:{for(var l=0,d=0;d<this.i.length;d++){e:{var m=this.i[d];if("__data__"in m.map&&(m=m.map.__data__,typeof m=="string")){m=m.length;break e}m=void 0}if(m===void 0)break;if(l+=m,4096<l){l=d;break t}if(l===4096||d===this.i.length-1){l=d+1;break t}}l=1e3}else l=1e3;l=Su(this,A,l),d=Xt(this.I),st(d,"RID",o),st(d,"CVER",22),this.D&&st(d,"X-HTTP-Session-Id",this.D),yr(this,d),S&&(this.O?l="headers="+encodeURIComponent(String(Iu(S)))+"&"+l:this.m&&Ws(d,this.m,S)),Qs(this.h,A),this.Ua&&st(d,"TYPE","init"),this.P?(st(d,"$req",l),st(d,"SID","null"),A.T=!0,js(A,d,null)):js(A,d,l),this.G=2}}else this.G==3&&(o?Pu(this,o):this.i.length==0||au(this.h)||Pu(this))};function Pu(o,l){var d;l?d=l.l:d=o.U++;const m=Xt(o.I);st(m,"SID",o.K),st(m,"RID",d),st(m,"AID",o.T),yr(o,m),o.m&&o.o&&Ws(m,o.m,o.o),d=new ce(o,o.j,d,o.B+1),o.m===null&&(d.H=o.o),l&&(o.i=l.D.concat(o.i)),l=Su(o,d,1e3),d.I=Math.round(.5*o.wa)+Math.round(.5*o.wa*Math.random()),Qs(o.h,d),js(d,m,l)}function yr(o,l){o.H&&K(o.H,function(d,m){st(l,m,d)}),o.l&&hu({},function(d,m){st(l,m,d)})}function Su(o,l,d){d=Math.min(o.i.length,d);var m=o.l?_(o.l.Na,o.l,o):null;t:{var A=o.i;let S=-1;for(;;){const F=["count="+d];S==-1?0<d?(S=A[0].g,F.push("ofs="+S)):S=0:F.push("ofs="+S);let rt=!0;for(let At=0;At<d;At++){let X=A[At].g;const Vt=A[At].map;if(X-=S,0>X)S=Math.max(0,A[At].g-100),rt=!1;else try{Lf(Vt,F,"req"+X+"_")}catch{m&&m(Vt)}}if(rt){m=F.join("&");break t}}}return o=o.i.splice(0,d),l.D=o,m}function Vu(o){if(!o.g&&!o.u){o.Y=1;var l=o.Fa;rr||Ba(),ir||(rr(),ir=!0),Vs.add(l,o),o.v=0}}function Js(o){return o.g||o.u||3<=o.v?!1:(o.Y++,o.u=cr(_(o.Fa,o),xu(o,o.v)),o.v++,!0)}r.Fa=function(){if(this.u=null,Cu(this),this.ba&&!(this.M||this.g==null||0>=this.R)){var o=2*this.R;this.j.info("BP detection timer enabled: "+o),this.A=cr(_(this.ab,this),o)}},r.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,Mt(10),Ai(this),Cu(this))};function Ys(o){o.A!=null&&(u.clearTimeout(o.A),o.A=null)}function Cu(o){o.g=new ce(o,o.j,"rpc",o.Y),o.m===null&&(o.g.H=o.o),o.g.O=0;var l=Xt(o.qa);st(l,"RID","rpc"),st(l,"SID",o.K),st(l,"AID",o.T),st(l,"CI",o.F?"0":"1"),!o.F&&o.ja&&st(l,"TO",o.ja),st(l,"TYPE","xmlhttp"),yr(o,l),o.m&&o.o&&Ws(l,o.m,o.o),o.L&&(o.g.I=o.L);var d=o.g;o=o.ia,d.L=1,d.v=Ei(Xt(l)),d.m=null,d.P=!0,ru(d,o)}r.Za=function(){this.C!=null&&(this.C=null,Ai(this),Js(this),Mt(19))};function bi(o){o.C!=null&&(u.clearTimeout(o.C),o.C=null)}function Du(o,l){var d=null;if(o.g==l){bi(o),Ys(o),o.g=null;var m=2}else if($s(o.h,l))d=l.D,cu(o.h,l),m=1;else return;if(o.G!=0){if(l.o)if(m==1){d=l.m?l.m.length:0,l=Date.now()-l.F;var A=o.B;m=mi(),Ft(m,new Za(m,d)),Ri(o)}else Vu(o);else if(A=l.s,A==3||A==0&&0<l.X||!(m==1&&zf(o,l)||m==2&&Js(o)))switch(d&&0<d.length&&(l=o.h,l.i=l.i.concat(d)),A){case 1:Ue(o,5);break;case 4:Ue(o,10);break;case 3:Ue(o,6);break;default:Ue(o,2)}}}function xu(o,l){let d=o.Ta+Math.floor(Math.random()*o.cb);return o.isActive()||(d*=2),d*l}function Ue(o,l){if(o.j.info("Error code "+l),l==2){var d=_(o.fb,o),m=o.Xa;const A=!m;m=new Be(m||"//www.google.com/images/cleardot.gif"),u.location&&u.location.protocol=="http"||yi(m,"https"),Ei(m),A?Ff(m.toString(),d):Mf(m.toString(),d)}else Mt(2);o.G=0,o.l&&o.l.sa(l),Nu(o),bu(o)}r.fb=function(o){o?(this.j.info("Successfully pinged google.com"),Mt(2)):(this.j.info("Failed to ping google.com"),Mt(1))};function Nu(o){if(o.G=0,o.ka=[],o.l){const l=lu(o.h);(l.length!=0||o.i.length!=0)&&(V(o.ka,l),V(o.ka,o.i),o.h.i.length=0,N(o.i),o.i.length=0),o.l.ra()}}function ku(o,l,d){var m=d instanceof Be?Xt(d):new Be(d);if(m.g!="")l&&(m.g=l+"."+m.g),Ii(m,m.s);else{var A=u.location;m=A.protocol,l=l?l+"."+A.hostname:A.hostname,A=+A.port;var S=new Be(null);m&&yi(S,m),l&&(S.g=l),A&&Ii(S,A),d&&(S.l=d),m=S}return d=o.D,l=o.ya,d&&l&&st(m,d,l),st(m,"VER",o.la),yr(o,m),m}function Fu(o,l,d){if(l&&!o.J)throw Error("Can't create secondary domain capable XhrIo object.");return l=o.Ca&&!o.pa?new ft(new Ti({eb:d})):new ft(o.pa),l.Ha(o.J),l}r.isActive=function(){return!!this.l&&this.l.isActive(this)};function Mu(){}r=Mu.prototype,r.ua=function(){},r.ta=function(){},r.sa=function(){},r.ra=function(){},r.isActive=function(){return!0},r.Na=function(){};function Pi(){}Pi.prototype.g=function(o,l){return new Ut(o,l)};function Ut(o,l){St.call(this),this.g=new Ru(l),this.l=o,this.h=l&&l.messageUrlParams||null,o=l&&l.messageHeaders||null,l&&l.clientProtocolHeaderRequired&&(o?o["X-Client-Protocol"]="webchannel":o={"X-Client-Protocol":"webchannel"}),this.g.o=o,o=l&&l.initMessageHeaders||null,l&&l.messageContentType&&(o?o["X-WebChannel-Content-Type"]=l.messageContentType:o={"X-WebChannel-Content-Type":l.messageContentType}),l&&l.va&&(o?o["X-WebChannel-Client-Profile"]=l.va:o={"X-WebChannel-Client-Profile":l.va}),this.g.S=o,(o=l&&l.Sb)&&!z(o)&&(this.g.m=o),this.v=l&&l.supportsCrossDomainXhr||!1,this.u=l&&l.sendRawJson||!1,(l=l&&l.httpSessionIdParam)&&!z(l)&&(this.g.D=l,o=this.h,o!==null&&l in o&&(o=this.h,l in o&&delete o[l])),this.j=new mn(this)}C(Ut,St),Ut.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},Ut.prototype.close=function(){Hs(this.g)},Ut.prototype.o=function(o){var l=this.g;if(typeof o=="string"){var d={};d.__data__=o,o=d}else this.u&&(d={},d.__data__=Os(o),o=d);l.i.push(new Rf(l.Ya++,o)),l.G==3&&Ri(l)},Ut.prototype.N=function(){this.g.l=null,delete this.j,Hs(this.g),delete this.g,Ut.aa.N.call(this)};function Ou(o){Bs.call(this),o.__headers__&&(this.headers=o.__headers__,this.statusCode=o.__status__,delete o.__headers__,delete o.__status__);var l=o.__sm__;if(l){t:{for(const d in l){o=d;break t}o=void 0}(this.i=o)&&(o=this.i,l=l!==null&&o in l?l[o]:void 0),this.data=l}else this.data=o}C(Ou,Bs);function Lu(){Us.call(this),this.status=1}C(Lu,Us);function mn(o){this.g=o}C(mn,Mu),mn.prototype.ua=function(){Ft(this.g,"a")},mn.prototype.ta=function(o){Ft(this.g,new Ou(o))},mn.prototype.sa=function(o){Ft(this.g,new Lu)},mn.prototype.ra=function(){Ft(this.g,"b")},Pi.prototype.createWebChannel=Pi.prototype.g,Ut.prototype.send=Ut.prototype.o,Ut.prototype.open=Ut.prototype.m,Ut.prototype.close=Ut.prototype.close,Nl=function(){return new Pi},xl=function(){return mi()},Dl=Oe,mo={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},gi.NO_ERROR=0,gi.TIMEOUT=8,gi.HTTP_ERROR=6,Mi=gi,tu.COMPLETE="complete",Cl=tu,Ha.EventType=ar,ar.OPEN="a",ar.CLOSE="b",ar.ERROR="c",ar.MESSAGE="d",St.prototype.listen=St.prototype.K,Ar=Ha,ft.prototype.listenOnce=ft.prototype.L,ft.prototype.getLastError=ft.prototype.Ka,ft.prototype.getLastErrorCode=ft.prototype.Ba,ft.prototype.getStatus=ft.prototype.Z,ft.prototype.getResponseJson=ft.prototype.Oa,ft.prototype.getResponseText=ft.prototype.oa,ft.prototype.send=ft.prototype.ea,ft.prototype.setWithCredentials=ft.prototype.Ha,Vl=ft}).apply(typeof Vi<"u"?Vi:typeof self<"u"?self:typeof window<"u"?window:{});const Qu="@firebase/firestore";/**
383
+ `);for(let m=0;m<o.length;m++){if(z(o[m]))continue;var d=v(o[m]);const A=d[0];if(d=d[1],typeof d!="string")continue;d=d.trim();const S=l[A]||[];l[A]=S,S.push(d)}E(l,function(m){return m.join(", ")})}r.Ba=function(){return this.m},r.Ka=function(){return typeof this.l=="string"?this.l:String(this.l)};function yr(o,l,d){return d&&d.internalChannelParams&&d.internalChannelParams[o]||l}function Ru(o){this.Aa=0,this.i=[],this.j=new hr,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=yr("failFast",!1,o),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=yr("baseRetryDelayMs",5e3,o),this.cb=yr("retryDelaySeedMs",1e4,o),this.Wa=yr("forwardChannelMaxRetries",2,o),this.wa=yr("forwardChannelRequestTimeoutMs",2e4,o),this.pa=o&&o.xmlHttpFactory||void 0,this.Xa=o&&o.Tb||void 0,this.Ca=o&&o.useFetchStreams||!1,this.L=void 0,this.J=o&&o.supportsCrossDomainXhr||!1,this.K="",this.h=new ou(o&&o.concurrentRequestLimit),this.Da=new Of,this.P=o&&o.fastHandshake||!1,this.O=o&&o.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=o&&o.Rb||!1,o&&o.xa&&this.j.xa(),o&&o.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&o&&o.detectBufferingProxy||!1,this.ja=void 0,o&&o.longPollingTimeout&&0<o.longPollingTimeout&&(this.ja=o.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}r=Ru.prototype,r.la=8,r.G=1,r.connect=function(o,l,d,m){Mt(0),this.W=o,this.H=l||{},d&&m!==void 0&&(this.H.OSID=d,this.H.OAID=m),this.F=this.X,this.I=ku(this,null,this.W),Ri(this)};function Hs(o){if(bu(o),o.G==3){var l=o.U++,d=Xt(o.I);if(st(d,"SID",o.K),st(d,"RID",l),st(d,"TYPE","terminate"),Ir(o,d),l=new ce(o,o.j,l),l.L=2,l.v=Ei(Xt(d)),d=!1,u.navigator&&u.navigator.sendBeacon)try{d=u.navigator.sendBeacon(l.v.toString(),"")}catch{}!d&&u.Image&&(new Image().src=l.v,d=!0),d||(l.g=Fu(l.j,null),l.g.ea(l.v)),l.F=Date.now(),_i(l)}Nu(o)}function Ai(o){o.g&&(Ys(o),o.g.cancel(),o.g=null)}function bu(o){Ai(o),o.u&&(u.clearTimeout(o.u),o.u=null),bi(o),o.h.cancel(),o.s&&(typeof o.s=="number"&&u.clearTimeout(o.s),o.s=null)}function Ri(o){if(!au(o.h)&&!o.s){o.s=!0;var l=o.Ga;ir||Ba(),sr||(ir(),sr=!0),Vs.add(l,o),o.B=0}}function zf(o,l){return uu(o.h)>=o.h.j-(o.s?1:0)?!1:o.s?(o.i=l.D.concat(o.i),!0):o.G==1||o.G==2||o.B>=(o.Va?0:o.Wa)?!1:(o.s=lr(_(o.Ga,o,l),xu(o,o.B)),o.B++,!0)}r.Ga=function(o){if(this.s)if(this.s=null,this.G==1){if(!o){this.U=Math.floor(1e5*Math.random()),o=this.U++;const A=new ce(this,this.j,o);let S=this.o;if(this.S&&(S?(S=p(S),T(S,this.S)):S=this.S),this.m!==null||this.O||(A.H=S,S=null),this.P)t:{for(var l=0,d=0;d<this.i.length;d++){e:{var m=this.i[d];if("__data__"in m.map&&(m=m.map.__data__,typeof m=="string")){m=m.length;break e}m=void 0}if(m===void 0)break;if(l+=m,4096<l){l=d;break t}if(l===4096||d===this.i.length-1){l=d+1;break t}}l=1e3}else l=1e3;l=Su(this,A,l),d=Xt(this.I),st(d,"RID",o),st(d,"CVER",22),this.D&&st(d,"X-HTTP-Session-Id",this.D),Ir(this,d),S&&(this.O?l="headers="+encodeURIComponent(String(Iu(S)))+"&"+l:this.m&&Ws(d,this.m,S)),Qs(this.h,A),this.Ua&&st(d,"TYPE","init"),this.P?(st(d,"$req",l),st(d,"SID","null"),A.T=!0,js(A,d,null)):js(A,d,l),this.G=2}}else this.G==3&&(o?Pu(this,o):this.i.length==0||au(this.h)||Pu(this))};function Pu(o,l){var d;l?d=l.l:d=o.U++;const m=Xt(o.I);st(m,"SID",o.K),st(m,"RID",d),st(m,"AID",o.T),Ir(o,m),o.m&&o.o&&Ws(m,o.m,o.o),d=new ce(o,o.j,d,o.B+1),o.m===null&&(d.H=o.o),l&&(o.i=l.D.concat(o.i)),l=Su(o,d,1e3),d.I=Math.round(.5*o.wa)+Math.round(.5*o.wa*Math.random()),Qs(o.h,d),js(d,m,l)}function Ir(o,l){o.H&&K(o.H,function(d,m){st(l,m,d)}),o.l&&hu({},function(d,m){st(l,m,d)})}function Su(o,l,d){d=Math.min(o.i.length,d);var m=o.l?_(o.l.Na,o.l,o):null;t:{var A=o.i;let S=-1;for(;;){const F=["count="+d];S==-1?0<d?(S=A[0].g,F.push("ofs="+S)):S=0:F.push("ofs="+S);let rt=!0;for(let At=0;At<d;At++){let X=A[At].g;const Vt=A[At].map;if(X-=S,0>X)S=Math.max(0,A[At].g-100),rt=!1;else try{Lf(Vt,F,"req"+X+"_")}catch{m&&m(Vt)}}if(rt){m=F.join("&");break t}}}return o=o.i.splice(0,d),l.D=o,m}function Vu(o){if(!o.g&&!o.u){o.Y=1;var l=o.Fa;ir||Ba(),sr||(ir(),sr=!0),Vs.add(l,o),o.v=0}}function Js(o){return o.g||o.u||3<=o.v?!1:(o.Y++,o.u=lr(_(o.Fa,o),xu(o,o.v)),o.v++,!0)}r.Fa=function(){if(this.u=null,Cu(this),this.ba&&!(this.M||this.g==null||0>=this.R)){var o=2*this.R;this.j.info("BP detection timer enabled: "+o),this.A=lr(_(this.ab,this),o)}},r.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,Mt(10),Ai(this),Cu(this))};function Ys(o){o.A!=null&&(u.clearTimeout(o.A),o.A=null)}function Cu(o){o.g=new ce(o,o.j,"rpc",o.Y),o.m===null&&(o.g.H=o.o),o.g.O=0;var l=Xt(o.qa);st(l,"RID","rpc"),st(l,"SID",o.K),st(l,"AID",o.T),st(l,"CI",o.F?"0":"1"),!o.F&&o.ja&&st(l,"TO",o.ja),st(l,"TYPE","xmlhttp"),Ir(o,l),o.m&&o.o&&Ws(l,o.m,o.o),o.L&&(o.g.I=o.L);var d=o.g;o=o.ia,d.L=1,d.v=Ei(Xt(l)),d.m=null,d.P=!0,ru(d,o)}r.Za=function(){this.C!=null&&(this.C=null,Ai(this),Js(this),Mt(19))};function bi(o){o.C!=null&&(u.clearTimeout(o.C),o.C=null)}function Du(o,l){var d=null;if(o.g==l){bi(o),Ys(o),o.g=null;var m=2}else if($s(o.h,l))d=l.D,cu(o.h,l),m=1;else return;if(o.G!=0){if(l.o)if(m==1){d=l.m?l.m.length:0,l=Date.now()-l.F;var A=o.B;m=mi(),Ft(m,new Za(m,d)),Ri(o)}else Vu(o);else if(A=l.s,A==3||A==0&&0<l.X||!(m==1&&zf(o,l)||m==2&&Js(o)))switch(d&&0<d.length&&(l=o.h,l.i=l.i.concat(d)),A){case 1:qe(o,5);break;case 4:qe(o,10);break;case 3:qe(o,6);break;default:qe(o,2)}}}function xu(o,l){let d=o.Ta+Math.floor(Math.random()*o.cb);return o.isActive()||(d*=2),d*l}function qe(o,l){if(o.j.info("Error code "+l),l==2){var d=_(o.fb,o),m=o.Xa;const A=!m;m=new Ue(m||"//www.google.com/images/cleardot.gif"),u.location&&u.location.protocol=="http"||yi(m,"https"),Ei(m),A?Ff(m.toString(),d):Mf(m.toString(),d)}else Mt(2);o.G=0,o.l&&o.l.sa(l),Nu(o),bu(o)}r.fb=function(o){o?(this.j.info("Successfully pinged google.com"),Mt(2)):(this.j.info("Failed to ping google.com"),Mt(1))};function Nu(o){if(o.G=0,o.ka=[],o.l){const l=lu(o.h);(l.length!=0||o.i.length!=0)&&(V(o.ka,l),V(o.ka,o.i),o.h.i.length=0,N(o.i),o.i.length=0),o.l.ra()}}function ku(o,l,d){var m=d instanceof Ue?Xt(d):new Ue(d);if(m.g!="")l&&(m.g=l+"."+m.g),Ii(m,m.s);else{var A=u.location;m=A.protocol,l=l?l+"."+A.hostname:A.hostname,A=+A.port;var S=new Ue(null);m&&yi(S,m),l&&(S.g=l),A&&Ii(S,A),d&&(S.l=d),m=S}return d=o.D,l=o.ya,d&&l&&st(m,d,l),st(m,"VER",o.la),Ir(o,m),m}function Fu(o,l,d){if(l&&!o.J)throw Error("Can't create secondary domain capable XhrIo object.");return l=o.Ca&&!o.pa?new ft(new Ti({eb:d})):new ft(o.pa),l.Ha(o.J),l}r.isActive=function(){return!!this.l&&this.l.isActive(this)};function Mu(){}r=Mu.prototype,r.ua=function(){},r.ta=function(){},r.sa=function(){},r.ra=function(){},r.isActive=function(){return!0},r.Na=function(){};function Pi(){}Pi.prototype.g=function(o,l){return new Ut(o,l)};function Ut(o,l){St.call(this),this.g=new Ru(l),this.l=o,this.h=l&&l.messageUrlParams||null,o=l&&l.messageHeaders||null,l&&l.clientProtocolHeaderRequired&&(o?o["X-Client-Protocol"]="webchannel":o={"X-Client-Protocol":"webchannel"}),this.g.o=o,o=l&&l.initMessageHeaders||null,l&&l.messageContentType&&(o?o["X-WebChannel-Content-Type"]=l.messageContentType:o={"X-WebChannel-Content-Type":l.messageContentType}),l&&l.va&&(o?o["X-WebChannel-Client-Profile"]=l.va:o={"X-WebChannel-Client-Profile":l.va}),this.g.S=o,(o=l&&l.Sb)&&!z(o)&&(this.g.m=o),this.v=l&&l.supportsCrossDomainXhr||!1,this.u=l&&l.sendRawJson||!1,(l=l&&l.httpSessionIdParam)&&!z(l)&&(this.g.D=l,o=this.h,o!==null&&l in o&&(o=this.h,l in o&&delete o[l])),this.j=new gn(this)}C(Ut,St),Ut.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},Ut.prototype.close=function(){Hs(this.g)},Ut.prototype.o=function(o){var l=this.g;if(typeof o=="string"){var d={};d.__data__=o,o=d}else this.u&&(d={},d.__data__=Os(o),o=d);l.i.push(new Rf(l.Ya++,o)),l.G==3&&Ri(l)},Ut.prototype.N=function(){this.g.l=null,delete this.j,Hs(this.g),delete this.g,Ut.aa.N.call(this)};function Ou(o){Bs.call(this),o.__headers__&&(this.headers=o.__headers__,this.statusCode=o.__status__,delete o.__headers__,delete o.__status__);var l=o.__sm__;if(l){t:{for(const d in l){o=d;break t}o=void 0}(this.i=o)&&(o=this.i,l=l!==null&&o in l?l[o]:void 0),this.data=l}else this.data=o}C(Ou,Bs);function Lu(){Us.call(this),this.status=1}C(Lu,Us);function gn(o){this.g=o}C(gn,Mu),gn.prototype.ua=function(){Ft(this.g,"a")},gn.prototype.ta=function(o){Ft(this.g,new Ou(o))},gn.prototype.sa=function(o){Ft(this.g,new Lu)},gn.prototype.ra=function(){Ft(this.g,"b")},Pi.prototype.createWebChannel=Pi.prototype.g,Ut.prototype.send=Ut.prototype.o,Ut.prototype.open=Ut.prototype.m,Ut.prototype.close=Ut.prototype.close,Nl=function(){return new Pi},xl=function(){return mi()},Dl=Le,mo={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},gi.NO_ERROR=0,gi.TIMEOUT=8,gi.HTTP_ERROR=6,Mi=gi,tu.COMPLETE="complete",Cl=tu,Ha.EventType=ur,ur.OPEN="a",ur.CLOSE="b",ur.ERROR="c",ur.MESSAGE="d",St.prototype.listen=St.prototype.K,Rr=Ha,ft.prototype.listenOnce=ft.prototype.L,ft.prototype.getLastError=ft.prototype.Ka,ft.prototype.getLastErrorCode=ft.prototype.Ba,ft.prototype.getStatus=ft.prototype.Z,ft.prototype.getResponseJson=ft.prototype.Oa,ft.prototype.getResponseText=ft.prototype.oa,ft.prototype.send=ft.prototype.ea,ft.prototype.setWithCredentials=ft.prototype.Ha,Vl=ft}).apply(typeof Vi<"u"?Vi:typeof self<"u"?self:typeof window<"u"?window:{});const Qu="@firebase/firestore";/**
384
384
  * @license
385
385
  * Copyright 2017 Google LLC
386
386
  *
@@ -410,7 +410,7 @@ SPDX-License-Identifier: Apache-2.0
410
410
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
411
411
  * See the License for the specific language governing permissions and
412
412
  * limitations under the License.
413
- */let Gn="10.14.0";/**
413
+ */let Kn="10.14.0";/**
414
414
  * @license
415
415
  * Copyright 2017 Google LLC
416
416
  *
@@ -425,7 +425,7 @@ SPDX-License-Identifier: Apache-2.0
425
425
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
426
426
  * See the License for the specific language governing permissions and
427
427
  * limitations under the License.
428
- */const Te=new pl("@firebase/firestore");function En(){return Te.logLevel}function yg(r){Te.setLogLevel(r)}function x(r,...t){if(Te.logLevel<=J.DEBUG){const e=t.map(Lo);Te.debug(`Firestore (${Gn}): ${r}`,...e)}}function gt(r,...t){if(Te.logLevel<=J.ERROR){const e=t.map(Lo);Te.error(`Firestore (${Gn}): ${r}`,...e)}}function qt(r,...t){if(Te.logLevel<=J.WARN){const e=t.map(Lo);Te.warn(`Firestore (${Gn}): ${r}`,...e)}}function Lo(r){if(typeof r=="string")return r;try{/**
428
+ */const ve=new pl("@firebase/firestore");function Tn(){return ve.logLevel}function yg(r){ve.setLogLevel(r)}function x(r,...t){if(ve.logLevel<=J.DEBUG){const e=t.map(Lo);ve.debug(`Firestore (${Kn}): ${r}`,...e)}}function gt(r,...t){if(ve.logLevel<=J.ERROR){const e=t.map(Lo);ve.error(`Firestore (${Kn}): ${r}`,...e)}}function qt(r,...t){if(ve.logLevel<=J.WARN){const e=t.map(Lo);ve.warn(`Firestore (${Kn}): ${r}`,...e)}}function Lo(r){if(typeof r=="string")return r;try{/**
429
429
  * @license
430
430
  * Copyright 2020 Google LLC
431
431
  *
@@ -455,7 +455,7 @@ SPDX-License-Identifier: Apache-2.0
455
455
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
456
456
  * See the License for the specific language governing permissions and
457
457
  * limitations under the License.
458
- */function O(r="Unexpected state"){const t=`FIRESTORE (${Gn}) INTERNAL ASSERTION FAILED: `+r;throw gt(t),new Error(t)}function L(r,t){r||O()}function Ig(r,t){r||O()}function k(r,t){return r}/**
458
+ */function O(r="Unexpected state"){const t=`FIRESTORE (${Kn}) INTERNAL ASSERTION FAILED: `+r;throw gt(t),new Error(t)}function L(r,t){r||O()}function Ig(r,t){r||O()}function k(r,t){return r}/**
459
459
  * @license
460
460
  * Copyright 2017 Google LLC
461
461
  *
@@ -470,7 +470,7 @@ SPDX-License-Identifier: Apache-2.0
470
470
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
471
471
  * See the License for the specific language governing permissions and
472
472
  * limitations under the License.
473
- */const P={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 D extends un{constructor(t,e){super(t,e),this.code=t,this.message=e,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/**
473
+ */const P={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 D extends cn{constructor(t,e){super(t,e),this.code=t,this.message=e,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/**
474
474
  * @license
475
475
  * Copyright 2017 Google LLC
476
476
  *
@@ -530,7 +530,7 @@ SPDX-License-Identifier: Apache-2.0
530
530
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
531
531
  * See the License for the specific language governing permissions and
532
532
  * limitations under the License.
533
- */class Bo{static newId(){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=Math.floor(256/t.length)*t.length;let n="";for(;n.length<20;){const i=bg(40);for(let s=0;s<i.length;++s)n.length<20&&i[s]<e&&(n+=t.charAt(i[s]%t.length))}return n}}function j(r,t){return r<t?-1:r>t?1:0}function Vn(r,t,e){return r.length===t.length&&r.every((n,i)=>e(n,t[i]))}function Ol(r){return r+"\0"}/**
533
+ */class Bo{static newId(){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=Math.floor(256/t.length)*t.length;let n="";for(;n.length<20;){const i=bg(40);for(let s=0;s<i.length;++s)n.length<20&&i[s]<e&&(n+=t.charAt(i[s]%t.length))}return n}}function j(r,t){return r<t?-1:r>t?1:0}function Cn(r,t,e){return r.length===t.length&&r.every((n,i)=>e(n,t[i]))}function Ol(r){return r+"\0"}/**
534
534
  * @license
535
535
  * Copyright 2017 Google LLC
536
536
  *
@@ -575,7 +575,7 @@ SPDX-License-Identifier: Apache-2.0
575
575
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
576
576
  * See the License for the specific language governing permissions and
577
577
  * limitations under the License.
578
- */class Or{constructor(t,e,n){e===void 0?e=0:e>t.length&&O(),n===void 0?n=t.length-e:n>t.length-e&&O(),this.segments=t,this.offset=e,this.len=n}get length(){return this.len}isEqual(t){return Or.comparator(this,t)===0}child(t){const e=this.segments.slice(this.offset,this.limit());return t instanceof Or?t.forEach(n=>{e.push(n)}):e.push(t),this.construct(e)}limit(){return this.offset+this.length}popFirst(t){return t=t===void 0?1:t,this.construct(this.segments,this.offset+t,this.length-t)}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(t){return this.segments[this.offset+t]}isEmpty(){return this.length===0}isPrefixOf(t){if(t.length<this.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}isImmediateParentOf(t){if(this.length+1!==t.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}forEach(t){for(let e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(t,e){const n=Math.min(t.length,e.length);for(let i=0;i<n;i++){const s=t.get(i),a=e.get(i);if(s<a)return-1;if(s>a)return 1}return t.length<e.length?-1:t.length>e.length?1:0}}class W extends Or{construct(t,e,n){return new W(t,e,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...t){const e=[];for(const n of t){if(n.indexOf("//")>=0)throw new D(P.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);e.push(...n.split("/").filter(i=>i.length>0))}return new W(e)}static emptyPath(){return new W([])}}const Pg=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class at extends Or{construct(t,e,n){return new at(t,e,n)}static isValidIdentifier(t){return Pg.test(t)}canonicalString(){return this.toArray().map(t=>(t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),at.isValidIdentifier(t)||(t="`"+t+"`"),t)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)==="__name__"}static keyField(){return new at(["__name__"])}static fromServerFormat(t){const e=[];let n="",i=0;const s=()=>{if(n.length===0)throw new D(P.INVALID_ARGUMENT,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);e.push(n),n=""};let a=!1;for(;i<t.length;){const u=t[i];if(u==="\\"){if(i+1===t.length)throw new D(P.INVALID_ARGUMENT,"Path has trailing escape character: "+t);const c=t[i+1];if(c!=="\\"&&c!=="."&&c!=="`")throw new D(P.INVALID_ARGUMENT,"Path has invalid escape sequence: "+t);n+=c,i+=2}else u==="`"?(a=!a,i++):u!=="."||a?(n+=u,i++):(s(),i++)}if(s(),a)throw new D(P.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new at(e)}static emptyPath(){return new at([])}}/**
578
+ */class Lr{constructor(t,e,n){e===void 0?e=0:e>t.length&&O(),n===void 0?n=t.length-e:n>t.length-e&&O(),this.segments=t,this.offset=e,this.len=n}get length(){return this.len}isEqual(t){return Lr.comparator(this,t)===0}child(t){const e=this.segments.slice(this.offset,this.limit());return t instanceof Lr?t.forEach(n=>{e.push(n)}):e.push(t),this.construct(e)}limit(){return this.offset+this.length}popFirst(t){return t=t===void 0?1:t,this.construct(this.segments,this.offset+t,this.length-t)}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(t){return this.segments[this.offset+t]}isEmpty(){return this.length===0}isPrefixOf(t){if(t.length<this.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}isImmediateParentOf(t){if(this.length+1!==t.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}forEach(t){for(let e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(t,e){const n=Math.min(t.length,e.length);for(let i=0;i<n;i++){const s=t.get(i),a=e.get(i);if(s<a)return-1;if(s>a)return 1}return t.length<e.length?-1:t.length>e.length?1:0}}class W extends Lr{construct(t,e,n){return new W(t,e,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...t){const e=[];for(const n of t){if(n.indexOf("//")>=0)throw new D(P.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);e.push(...n.split("/").filter(i=>i.length>0))}return new W(e)}static emptyPath(){return new W([])}}const Pg=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class at extends Lr{construct(t,e,n){return new at(t,e,n)}static isValidIdentifier(t){return Pg.test(t)}canonicalString(){return this.toArray().map(t=>(t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),at.isValidIdentifier(t)||(t="`"+t+"`"),t)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)==="__name__"}static keyField(){return new at(["__name__"])}static fromServerFormat(t){const e=[];let n="",i=0;const s=()=>{if(n.length===0)throw new D(P.INVALID_ARGUMENT,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);e.push(n),n=""};let a=!1;for(;i<t.length;){const u=t[i];if(u==="\\"){if(i+1===t.length)throw new D(P.INVALID_ARGUMENT,"Path has trailing escape character: "+t);const c=t[i+1];if(c!=="\\"&&c!=="."&&c!=="`")throw new D(P.INVALID_ARGUMENT,"Path has invalid escape sequence: "+t);n+=c,i+=2}else u==="`"?(a=!a,i++):u!=="."||a?(n+=u,i++):(s(),i++)}if(s(),a)throw new D(P.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new at(e)}static emptyPath(){return new at([])}}/**
579
579
  * @license
580
580
  * Copyright 2017 Google LLC
581
581
  *
@@ -605,7 +605,7 @@ SPDX-License-Identifier: Apache-2.0
605
605
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
606
606
  * See the License for the specific language governing permissions and
607
607
  * limitations under the License.
608
- */class Cn{constructor(t,e,n,i){this.indexId=t,this.collectionGroup=e,this.fields=n,this.indexState=i}}function go(r){return r.fields.find(t=>t.kind===2)}function je(r){return r.fields.filter(t=>t.kind!==2)}function Sg(r,t){let e=j(r.collectionGroup,t.collectionGroup);if(e!==0)return e;for(let n=0;n<Math.min(r.fields.length,t.fields.length);++n)if(e=Vg(r.fields[n],t.fields[n]),e!==0)return e;return j(r.fields.length,t.fields.length)}Cn.UNKNOWN_ID=-1;class Je{constructor(t,e){this.fieldPath=t,this.kind=e}}function Vg(r,t){const e=at.comparator(r.fieldPath,t.fieldPath);return e!==0?e:j(r.kind,t.kind)}class Dn{constructor(t,e){this.sequenceNumber=t,this.offset=e}static empty(){return new Dn(0,zt.min())}}function Ll(r,t){const e=r.toTimestamp().seconds,n=r.toTimestamp().nanoseconds+1,i=U.fromTimestamp(n===1e9?new lt(e+1,0):new lt(e,n));return new zt(i,M.empty(),t)}function Bl(r){return new zt(r.readTime,r.key,-1)}class zt{constructor(t,e,n){this.readTime=t,this.documentKey=e,this.largestBatchId=n}static min(){return new zt(U.min(),M.empty(),-1)}static max(){return new zt(U.max(),M.empty(),-1)}}function Uo(r,t){let e=r.readTime.compareTo(t.readTime);return e!==0?e:(e=M.comparator(r.documentKey,t.documentKey),e!==0?e:j(r.largestBatchId,t.largestBatchId))}/**
608
+ */class Dn{constructor(t,e,n,i){this.indexId=t,this.collectionGroup=e,this.fields=n,this.indexState=i}}function go(r){return r.fields.find(t=>t.kind===2)}function Ge(r){return r.fields.filter(t=>t.kind!==2)}function Sg(r,t){let e=j(r.collectionGroup,t.collectionGroup);if(e!==0)return e;for(let n=0;n<Math.min(r.fields.length,t.fields.length);++n)if(e=Vg(r.fields[n],t.fields[n]),e!==0)return e;return j(r.fields.length,t.fields.length)}Dn.UNKNOWN_ID=-1;class Ye{constructor(t,e){this.fieldPath=t,this.kind=e}}function Vg(r,t){const e=at.comparator(r.fieldPath,t.fieldPath);return e!==0?e:j(r.kind,t.kind)}class xn{constructor(t,e){this.sequenceNumber=t,this.offset=e}static empty(){return new xn(0,zt.min())}}function Ll(r,t){const e=r.toTimestamp().seconds,n=r.toTimestamp().nanoseconds+1,i=U.fromTimestamp(n===1e9?new lt(e+1,0):new lt(e,n));return new zt(i,M.empty(),t)}function Bl(r){return new zt(r.readTime,r.key,-1)}class zt{constructor(t,e,n){this.readTime=t,this.documentKey=e,this.largestBatchId=n}static min(){return new zt(U.min(),M.empty(),-1)}static max(){return new zt(U.max(),M.empty(),-1)}}function Uo(r,t){let e=r.readTime.compareTo(t.readTime);return e!==0?e:(e=M.comparator(r.documentKey,t.documentKey),e!==0?e:j(r.largestBatchId,t.largestBatchId))}/**
609
609
  * @license
610
610
  * Copyright 2020 Google LLC
611
611
  *
@@ -635,7 +635,7 @@ SPDX-License-Identifier: Apache-2.0
635
635
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
636
636
  * See the License for the specific language governing permissions and
637
637
  * limitations under the License.
638
- */async function Ce(r){if(r.code!==P.FAILED_PRECONDITION||r.message!==Ul)throw r;x("LocalStore","Unexpectedly lost primary lease")}/**
638
+ */async function De(r){if(r.code!==P.FAILED_PRECONDITION||r.message!==Ul)throw r;x("LocalStore","Unexpectedly lost primary lease")}/**
639
639
  * @license
640
640
  * Copyright 2017 Google LLC
641
641
  *
@@ -665,7 +665,7 @@ SPDX-License-Identifier: Apache-2.0
665
665
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
666
666
  * See the License for the specific language governing permissions and
667
667
  * limitations under the License.
668
- */class as{constructor(t,e){this.action=t,this.transaction=e,this.aborted=!1,this.V=new vt,this.transaction.oncomplete=()=>{this.V.resolve()},this.transaction.onabort=()=>{e.error?this.V.reject(new Sr(t,e.error)):this.V.resolve()},this.transaction.onerror=n=>{const i=qo(n.target.error);this.V.reject(new Sr(t,i))}}static open(t,e,n,i){try{return new as(e,t.transaction(i,n))}catch(s){throw new Sr(e,s)}}get m(){return this.V.promise}abort(t){t&&this.V.reject(t),this.aborted||(x("SimpleDb","Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}g(){const t=this.transaction;this.aborted||typeof t.commit!="function"||t.commit()}store(t){const e=this.transaction.objectStore(t);return new Dg(e)}}class Wt{constructor(t,e,n){this.name=t,this.version=e,this.p=n,Wt.S(Ki())===12.2&&gt("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}static delete(t){return x("SimpleDb","Removing database:",t),Ge(window.indexedDB.deleteDatabase(t)).toPromise()}static D(){if(!dl())return!1;if(Wt.v())return!0;const t=Ki(),e=Wt.S(t),n=0<e&&e<10,i=zl(t),s=0<i&&i<4.5;return!(t.indexOf("MSIE ")>0||t.indexOf("Trident/")>0||t.indexOf("Edge/")>0||n||s)}static v(){var t;return typeof process<"u"&&((t=process.__PRIVATE_env)===null||t===void 0?void 0:t.C)==="YES"}static F(t,e){return t.store(e)}static S(t){const e=t.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=e?e[1].split("_").slice(0,2).join("."):"-1";return Number(n)}async M(t){return this.db||(x("SimpleDb","Opening database:",this.name),this.db=await new Promise((e,n)=>{const i=indexedDB.open(this.name,this.version);i.onsuccess=s=>{const a=s.target.result;e(a)},i.onblocked=()=>{n(new Sr(t,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},i.onerror=s=>{const a=s.target.error;a.name==="VersionError"?n(new D(P.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):a.name==="InvalidStateError"?n(new D(P.FAILED_PRECONDITION,"Unable to open an IndexedDB connection. This could be due to running in a private browsing session on a browser whose private browsing sessions do not support IndexedDB: "+a)):n(new Sr(t,a))},i.onupgradeneeded=s=>{x("SimpleDb",'Database "'+this.name+'" requires upgrade from version:',s.oldVersion);const a=s.target.result;this.p.O(a,i.transaction,s.oldVersion,this.version).next(()=>{x("SimpleDb","Database upgrade to version "+this.version+" complete")})}})),this.N&&(this.db.onversionchange=e=>this.N(e)),this.db}L(t){this.N=t,this.db&&(this.db.onversionchange=e=>t(e))}async runTransaction(t,e,n,i){const s=e==="readonly";let a=0;for(;;){++a;try{this.db=await this.M(t);const u=as.open(this.db,t,s?"readonly":"readwrite",n),c=i(u).next(h=>(u.g(),h)).catch(h=>(u.abort(h),w.reject(h))).toPromise();return c.catch(()=>{}),await u.m,c}catch(u){const c=u,h=c.name!=="FirebaseError"&&a<3;if(x("SimpleDb","Transaction failed with error:",c.message,"Retrying:",h),this.close(),!h)return Promise.reject(c)}}}close(){this.db&&this.db.close(),this.db=void 0}}function zl(r){const t=r.match(/Android ([\d.]+)/i),e=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(e)}class Cg{constructor(t){this.B=t,this.k=!1,this.q=null}get isDone(){return this.k}get K(){return this.q}set cursor(t){this.B=t}done(){this.k=!0}$(t){this.q=t}delete(){return Ge(this.B.delete())}}class Sr extends D{constructor(t,e){super(P.UNAVAILABLE,`IndexedDB transaction '${t}' failed: ${e}`),this.name="IndexedDbTransactionError"}}function De(r){return r.name==="IndexedDbTransactionError"}class Dg{constructor(t){this.store=t}put(t,e){let n;return e!==void 0?(x("SimpleDb","PUT",this.store.name,t,e),n=this.store.put(e,t)):(x("SimpleDb","PUT",this.store.name,"<auto-key>",t),n=this.store.put(t)),Ge(n)}add(t){return x("SimpleDb","ADD",this.store.name,t,t),Ge(this.store.add(t))}get(t){return Ge(this.store.get(t)).next(e=>(e===void 0&&(e=null),x("SimpleDb","GET",this.store.name,t,e),e))}delete(t){return x("SimpleDb","DELETE",this.store.name,t),Ge(this.store.delete(t))}count(){return x("SimpleDb","COUNT",this.store.name),Ge(this.store.count())}U(t,e){const n=this.options(t,e),i=n.index?this.store.index(n.index):this.store;if(typeof i.getAll=="function"){const s=i.getAll(n.range);return new w((a,u)=>{s.onerror=c=>{u(c.target.error)},s.onsuccess=c=>{a(c.target.result)}})}{const s=this.cursor(n),a=[];return this.W(s,(u,c)=>{a.push(c)}).next(()=>a)}}G(t,e){const n=this.store.getAll(t,e===null?void 0:e);return new w((i,s)=>{n.onerror=a=>{s(a.target.error)},n.onsuccess=a=>{i(a.target.result)}})}j(t,e){x("SimpleDb","DELETE ALL",this.store.name);const n=this.options(t,e);n.H=!1;const i=this.cursor(n);return this.W(i,(s,a,u)=>u.delete())}J(t,e){let n;e?n=t:(n={},e=t);const i=this.cursor(n);return this.W(i,e)}Y(t){const e=this.cursor({});return new w((n,i)=>{e.onerror=s=>{const a=qo(s.target.error);i(a)},e.onsuccess=s=>{const a=s.target.result;a?t(a.primaryKey,a.value).next(u=>{u?a.continue():n()}):n()}})}W(t,e){const n=[];return new w((i,s)=>{t.onerror=a=>{s(a.target.error)},t.onsuccess=a=>{const u=a.target.result;if(!u)return void i();const c=new Cg(u),h=e(u.primaryKey,u.value,c);if(h instanceof w){const f=h.catch(g=>(c.done(),w.reject(g)));n.push(f)}c.isDone?i():c.K===null?u.continue():u.continue(c.K)}}).next(()=>w.waitFor(n))}options(t,e){let n;return t!==void 0&&(typeof t=="string"?n=t:e=t),{index:n,range:e}}cursor(t){let e="next";if(t.reverse&&(e="prev"),t.index){const n=this.store.index(t.index);return t.H?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)}}function Ge(r){return new w((t,e)=>{r.onsuccess=n=>{const i=n.target.result;t(i)},r.onerror=n=>{const i=qo(n.target.error);e(i)}})}let Wu=!1;function qo(r){const t=Wt.S(Ki());if(t>=12.2&&t<13){const e="An internal error was encountered in the Indexed Database server";if(r.message.indexOf(e)>=0){const n=new D("internal",`IOS_INDEXEDDB_BUG1: IndexedDb has thrown '${e}'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`);return Wu||(Wu=!0,setTimeout(()=>{throw n},0)),n}}return r}class xg{constructor(t,e){this.asyncQueue=t,this.Z=e,this.task=null}start(){this.X(15e3)}stop(){this.task&&(this.task.cancel(),this.task=null)}get started(){return this.task!==null}X(t){x("IndexBackfiller",`Scheduled in ${t}ms`),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",t,async()=>{this.task=null;try{x("IndexBackfiller",`Documents written: ${await this.Z.ee()}`)}catch(e){De(e)?x("IndexBackfiller","Ignoring IndexedDB error during index backfill: ",e):await Ce(e)}await this.X(6e4)})}}class Ng{constructor(t,e){this.localStore=t,this.persistence=e}async ee(t=50){return this.persistence.runTransaction("Backfill Indexes","readwrite-primary",e=>this.te(e,t))}te(t,e){const n=new Set;let i=e,s=!0;return w.doWhile(()=>s===!0&&i>0,()=>this.localStore.indexManager.getNextCollectionGroupToUpdate(t).next(a=>{if(a!==null&&!n.has(a))return x("IndexBackfiller",`Processing collection: ${a}`),this.ne(t,a,i).next(u=>{i-=u,n.add(a)});s=!1})).next(()=>e-i)}ne(t,e,n){return this.localStore.indexManager.getMinOffsetFromCollectionGroup(t,e).next(i=>this.localStore.localDocuments.getNextDocuments(t,e,i,n).next(s=>{const a=s.changes;return this.localStore.indexManager.updateIndexEntries(t,a).next(()=>this.re(i,s)).next(u=>(x("IndexBackfiller",`Updating offset: ${u}`),this.localStore.indexManager.updateCollectionGroup(t,e,u))).next(()=>a.size)}))}re(t,e){let n=t;return e.changes.forEach((i,s)=>{const a=Bl(s);Uo(a,n)>0&&(n=a)}),new zt(n.readTime,n.documentKey,Math.max(e.batchId,t.largestBatchId))}}/**
668
+ */class as{constructor(t,e){this.action=t,this.transaction=e,this.aborted=!1,this.V=new vt,this.transaction.oncomplete=()=>{this.V.resolve()},this.transaction.onabort=()=>{e.error?this.V.reject(new Vr(t,e.error)):this.V.resolve()},this.transaction.onerror=n=>{const i=qo(n.target.error);this.V.reject(new Vr(t,i))}}static open(t,e,n,i){try{return new as(e,t.transaction(i,n))}catch(s){throw new Vr(e,s)}}get m(){return this.V.promise}abort(t){t&&this.V.reject(t),this.aborted||(x("SimpleDb","Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}g(){const t=this.transaction;this.aborted||typeof t.commit!="function"||t.commit()}store(t){const e=this.transaction.objectStore(t);return new Dg(e)}}class Wt{constructor(t,e,n){this.name=t,this.version=e,this.p=n,Wt.S(Ki())===12.2&&gt("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}static delete(t){return x("SimpleDb","Removing database:",t),Ke(window.indexedDB.deleteDatabase(t)).toPromise()}static D(){if(!dl())return!1;if(Wt.v())return!0;const t=Ki(),e=Wt.S(t),n=0<e&&e<10,i=zl(t),s=0<i&&i<4.5;return!(t.indexOf("MSIE ")>0||t.indexOf("Trident/")>0||t.indexOf("Edge/")>0||n||s)}static v(){var t;return typeof process<"u"&&((t=process.__PRIVATE_env)===null||t===void 0?void 0:t.C)==="YES"}static F(t,e){return t.store(e)}static S(t){const e=t.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=e?e[1].split("_").slice(0,2).join("."):"-1";return Number(n)}async M(t){return this.db||(x("SimpleDb","Opening database:",this.name),this.db=await new Promise((e,n)=>{const i=indexedDB.open(this.name,this.version);i.onsuccess=s=>{const a=s.target.result;e(a)},i.onblocked=()=>{n(new Vr(t,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},i.onerror=s=>{const a=s.target.error;a.name==="VersionError"?n(new D(P.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):a.name==="InvalidStateError"?n(new D(P.FAILED_PRECONDITION,"Unable to open an IndexedDB connection. This could be due to running in a private browsing session on a browser whose private browsing sessions do not support IndexedDB: "+a)):n(new Vr(t,a))},i.onupgradeneeded=s=>{x("SimpleDb",'Database "'+this.name+'" requires upgrade from version:',s.oldVersion);const a=s.target.result;this.p.O(a,i.transaction,s.oldVersion,this.version).next(()=>{x("SimpleDb","Database upgrade to version "+this.version+" complete")})}})),this.N&&(this.db.onversionchange=e=>this.N(e)),this.db}L(t){this.N=t,this.db&&(this.db.onversionchange=e=>t(e))}async runTransaction(t,e,n,i){const s=e==="readonly";let a=0;for(;;){++a;try{this.db=await this.M(t);const u=as.open(this.db,t,s?"readonly":"readwrite",n),c=i(u).next(h=>(u.g(),h)).catch(h=>(u.abort(h),w.reject(h))).toPromise();return c.catch(()=>{}),await u.m,c}catch(u){const c=u,h=c.name!=="FirebaseError"&&a<3;if(x("SimpleDb","Transaction failed with error:",c.message,"Retrying:",h),this.close(),!h)return Promise.reject(c)}}}close(){this.db&&this.db.close(),this.db=void 0}}function zl(r){const t=r.match(/Android ([\d.]+)/i),e=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(e)}class Cg{constructor(t){this.B=t,this.k=!1,this.q=null}get isDone(){return this.k}get K(){return this.q}set cursor(t){this.B=t}done(){this.k=!0}$(t){this.q=t}delete(){return Ke(this.B.delete())}}class Vr extends D{constructor(t,e){super(P.UNAVAILABLE,`IndexedDB transaction '${t}' failed: ${e}`),this.name="IndexedDbTransactionError"}}function xe(r){return r.name==="IndexedDbTransactionError"}class Dg{constructor(t){this.store=t}put(t,e){let n;return e!==void 0?(x("SimpleDb","PUT",this.store.name,t,e),n=this.store.put(e,t)):(x("SimpleDb","PUT",this.store.name,"<auto-key>",t),n=this.store.put(t)),Ke(n)}add(t){return x("SimpleDb","ADD",this.store.name,t,t),Ke(this.store.add(t))}get(t){return Ke(this.store.get(t)).next(e=>(e===void 0&&(e=null),x("SimpleDb","GET",this.store.name,t,e),e))}delete(t){return x("SimpleDb","DELETE",this.store.name,t),Ke(this.store.delete(t))}count(){return x("SimpleDb","COUNT",this.store.name),Ke(this.store.count())}U(t,e){const n=this.options(t,e),i=n.index?this.store.index(n.index):this.store;if(typeof i.getAll=="function"){const s=i.getAll(n.range);return new w((a,u)=>{s.onerror=c=>{u(c.target.error)},s.onsuccess=c=>{a(c.target.result)}})}{const s=this.cursor(n),a=[];return this.W(s,(u,c)=>{a.push(c)}).next(()=>a)}}G(t,e){const n=this.store.getAll(t,e===null?void 0:e);return new w((i,s)=>{n.onerror=a=>{s(a.target.error)},n.onsuccess=a=>{i(a.target.result)}})}j(t,e){x("SimpleDb","DELETE ALL",this.store.name);const n=this.options(t,e);n.H=!1;const i=this.cursor(n);return this.W(i,(s,a,u)=>u.delete())}J(t,e){let n;e?n=t:(n={},e=t);const i=this.cursor(n);return this.W(i,e)}Y(t){const e=this.cursor({});return new w((n,i)=>{e.onerror=s=>{const a=qo(s.target.error);i(a)},e.onsuccess=s=>{const a=s.target.result;a?t(a.primaryKey,a.value).next(u=>{u?a.continue():n()}):n()}})}W(t,e){const n=[];return new w((i,s)=>{t.onerror=a=>{s(a.target.error)},t.onsuccess=a=>{const u=a.target.result;if(!u)return void i();const c=new Cg(u),h=e(u.primaryKey,u.value,c);if(h instanceof w){const f=h.catch(g=>(c.done(),w.reject(g)));n.push(f)}c.isDone?i():c.K===null?u.continue():u.continue(c.K)}}).next(()=>w.waitFor(n))}options(t,e){let n;return t!==void 0&&(typeof t=="string"?n=t:e=t),{index:n,range:e}}cursor(t){let e="next";if(t.reverse&&(e="prev"),t.index){const n=this.store.index(t.index);return t.H?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)}}function Ke(r){return new w((t,e)=>{r.onsuccess=n=>{const i=n.target.result;t(i)},r.onerror=n=>{const i=qo(n.target.error);e(i)}})}let Wu=!1;function qo(r){const t=Wt.S(Ki());if(t>=12.2&&t<13){const e="An internal error was encountered in the Indexed Database server";if(r.message.indexOf(e)>=0){const n=new D("internal",`IOS_INDEXEDDB_BUG1: IndexedDb has thrown '${e}'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`);return Wu||(Wu=!0,setTimeout(()=>{throw n},0)),n}}return r}class xg{constructor(t,e){this.asyncQueue=t,this.Z=e,this.task=null}start(){this.X(15e3)}stop(){this.task&&(this.task.cancel(),this.task=null)}get started(){return this.task!==null}X(t){x("IndexBackfiller",`Scheduled in ${t}ms`),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",t,async()=>{this.task=null;try{x("IndexBackfiller",`Documents written: ${await this.Z.ee()}`)}catch(e){xe(e)?x("IndexBackfiller","Ignoring IndexedDB error during index backfill: ",e):await De(e)}await this.X(6e4)})}}class Ng{constructor(t,e){this.localStore=t,this.persistence=e}async ee(t=50){return this.persistence.runTransaction("Backfill Indexes","readwrite-primary",e=>this.te(e,t))}te(t,e){const n=new Set;let i=e,s=!0;return w.doWhile(()=>s===!0&&i>0,()=>this.localStore.indexManager.getNextCollectionGroupToUpdate(t).next(a=>{if(a!==null&&!n.has(a))return x("IndexBackfiller",`Processing collection: ${a}`),this.ne(t,a,i).next(u=>{i-=u,n.add(a)});s=!1})).next(()=>e-i)}ne(t,e,n){return this.localStore.indexManager.getMinOffsetFromCollectionGroup(t,e).next(i=>this.localStore.localDocuments.getNextDocuments(t,e,i,n).next(s=>{const a=s.changes;return this.localStore.indexManager.updateIndexEntries(t,a).next(()=>this.re(i,s)).next(u=>(x("IndexBackfiller",`Updating offset: ${u}`),this.localStore.indexManager.updateCollectionGroup(t,e,u))).next(()=>a.size)}))}re(t,e){let n=t;return e.changes.forEach((i,s)=>{const a=Bl(s);Uo(a,n)>0&&(n=a)}),new zt(n.readTime,n.documentKey,Math.max(e.batchId,t.largestBatchId))}}/**
669
669
  * @license
670
670
  * Copyright 2018 Google LLC
671
671
  *
@@ -680,7 +680,7 @@ SPDX-License-Identifier: Apache-2.0
680
680
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
681
681
  * See the License for the specific language governing permissions and
682
682
  * limitations under the License.
683
- */class Ot{constructor(t,e){this.previousValue=t,e&&(e.sequenceNumberHandler=n=>this.ie(n),this.se=n=>e.writeSequenceNumber(n))}ie(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue}next(){const t=++this.previousValue;return this.se&&this.se(t),t}}Ot.oe=-1;function Wr(r){return r==null}function Lr(r){return r===0&&1/r==-1/0}function jl(r){return typeof r=="number"&&Number.isInteger(r)&&!Lr(r)&&r<=Number.MAX_SAFE_INTEGER&&r>=Number.MIN_SAFE_INTEGER}/**
683
+ */class Ot{constructor(t,e){this.previousValue=t,e&&(e.sequenceNumberHandler=n=>this.ie(n),this.se=n=>e.writeSequenceNumber(n))}ie(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue}next(){const t=++this.previousValue;return this.se&&this.se(t),t}}Ot.oe=-1;function Wr(r){return r==null}function Br(r){return r===0&&1/r==-1/0}function jl(r){return typeof r=="number"&&Number.isInteger(r)&&!Br(r)&&r<=Number.MAX_SAFE_INTEGER&&r>=Number.MIN_SAFE_INTEGER}/**
684
684
  * @license
685
685
  * Copyright 2017 Google LLC
686
686
  *
@@ -755,7 +755,7 @@ SPDX-License-Identifier: Apache-2.0
755
755
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
756
756
  * See the License for the specific language governing permissions and
757
757
  * limitations under the License.
758
- */function Yu(r){let t=0;for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&t++;return t}function xe(r,t){for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&t(e,r[e])}function Wl(r,t){const e=[];for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.push(t(r[n],n,r));return e}function Hl(r){for(const t in r)if(Object.prototype.hasOwnProperty.call(r,t))return!1;return!0}/**
758
+ */function Yu(r){let t=0;for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&t++;return t}function Ne(r,t){for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&t(e,r[e])}function Wl(r,t){const e=[];for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.push(t(r[n],n,r));return e}function Hl(r){for(const t in r)if(Object.prototype.hasOwnProperty.call(r,t))return!1;return!0}/**
759
759
  * @license
760
760
  * Copyright 2017 Google LLC
761
761
  *
@@ -785,7 +785,7 @@ SPDX-License-Identifier: Apache-2.0
785
785
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
786
786
  * See the License for the specific language governing permissions and
787
787
  * limitations under the License.
788
- */class et{constructor(t){this.comparator=t,this.data=new it(this.comparator)}has(t){return this.data.get(t)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(t){return this.data.indexOf(t)}forEach(t){this.data.inorderTraversal((e,n)=>(t(e),!1))}forEachInRange(t,e){const n=this.data.getIteratorFrom(t[0]);for(;n.hasNext();){const i=n.getNext();if(this.comparator(i.key,t[1])>=0)return;e(i.key)}}forEachWhile(t,e){let n;for(n=e!==void 0?this.data.getIteratorFrom(e):this.data.getIterator();n.hasNext();)if(!t(n.getNext().key))return}firstAfterOrEqual(t){const e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null}getIterator(){return new Xu(this.data.getIterator())}getIteratorFrom(t){return new Xu(this.data.getIteratorFrom(t))}add(t){return this.copy(this.data.remove(t).insert(t,!0))}delete(t){return this.has(t)?this.copy(this.data.remove(t)):this}isEmpty(){return this.data.isEmpty()}unionWith(t){let e=this;return e.size<t.size&&(e=t,t=this),t.forEach(n=>{e=e.add(n)}),e}isEqual(t){if(!(t instanceof et)||this.size!==t.size)return!1;const e=this.data.getIterator(),n=t.data.getIterator();for(;e.hasNext();){const i=e.getNext().key,s=n.getNext().key;if(this.comparator(i,s)!==0)return!1}return!0}toArray(){const t=[];return this.forEach(e=>{t.push(e)}),t}toString(){const t=[];return this.forEach(e=>t.push(e)),"SortedSet("+t.toString()+")"}copy(t){const e=new et(this.comparator);return e.data=t,e}}class Xu{constructor(t){this.iter=t}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}function pn(r){return r.hasNext()?r.getNext():void 0}/**
788
+ */class et{constructor(t){this.comparator=t,this.data=new it(this.comparator)}has(t){return this.data.get(t)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(t){return this.data.indexOf(t)}forEach(t){this.data.inorderTraversal((e,n)=>(t(e),!1))}forEachInRange(t,e){const n=this.data.getIteratorFrom(t[0]);for(;n.hasNext();){const i=n.getNext();if(this.comparator(i.key,t[1])>=0)return;e(i.key)}}forEachWhile(t,e){let n;for(n=e!==void 0?this.data.getIteratorFrom(e):this.data.getIterator();n.hasNext();)if(!t(n.getNext().key))return}firstAfterOrEqual(t){const e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null}getIterator(){return new Xu(this.data.getIterator())}getIteratorFrom(t){return new Xu(this.data.getIteratorFrom(t))}add(t){return this.copy(this.data.remove(t).insert(t,!0))}delete(t){return this.has(t)?this.copy(this.data.remove(t)):this}isEmpty(){return this.data.isEmpty()}unionWith(t){let e=this;return e.size<t.size&&(e=t,t=this),t.forEach(n=>{e=e.add(n)}),e}isEqual(t){if(!(t instanceof et)||this.size!==t.size)return!1;const e=this.data.getIterator(),n=t.data.getIterator();for(;e.hasNext();){const i=e.getNext().key,s=n.getNext().key;if(this.comparator(i,s)!==0)return!1}return!0}toArray(){const t=[];return this.forEach(e=>{t.push(e)}),t}toString(){const t=[];return this.forEach(e=>t.push(e)),"SortedSet("+t.toString()+")"}copy(t){const e=new et(this.comparator);return e.data=t,e}}class Xu{constructor(t){this.iter=t}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}function _n(r){return r.hasNext()?r.getNext():void 0}/**
789
789
  * @license
790
790
  * Copyright 2020 Google LLC
791
791
  *
@@ -800,7 +800,7 @@ SPDX-License-Identifier: Apache-2.0
800
800
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
801
801
  * See the License for the specific language governing permissions and
802
802
  * limitations under the License.
803
- */class Lt{constructor(t){this.fields=t,t.sort(at.comparator)}static empty(){return new Lt([])}unionWith(t){let e=new et(at.comparator);for(const n of this.fields)e=e.add(n);for(const n of t)e=e.add(n);return new Lt(e.toArray())}covers(t){for(const e of this.fields)if(e.isPrefixOf(t))return!0;return!1}isEqual(t){return Vn(this.fields,t.fields,(e,n)=>e.isEqual(n))}}/**
803
+ */class Lt{constructor(t){this.fields=t,t.sort(at.comparator)}static empty(){return new Lt([])}unionWith(t){let e=new et(at.comparator);for(const n of this.fields)e=e.add(n);for(const n of t)e=e.add(n);return new Lt(e.toArray())}covers(t){for(const e of this.fields)if(e.isPrefixOf(t))return!0;return!1}isEqual(t){return Cn(this.fields,t.fields,(e,n)=>e.isEqual(n))}}/**
804
804
  * @license
805
805
  * Copyright 2023 Google LLC
806
806
  *
@@ -860,7 +860,7 @@ SPDX-License-Identifier: Apache-2.0
860
860
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
861
861
  * See the License for the specific language governing permissions and
862
862
  * limitations under the License.
863
- */function us(r){var t,e;return((e=(((t=r==null?void 0:r.mapValue)===null||t===void 0?void 0:t.fields)||{}).__type__)===null||e===void 0?void 0:e.stringValue)==="server_timestamp"}function cs(r){const t=r.mapValue.fields.__previous_value__;return us(t)?cs(t):t}function Br(r){const t=ne(r.mapValue.fields.__local_write_time__.timestampValue);return new lt(t.seconds,t.nanos)}/**
863
+ */function us(r){var t,e;return((e=(((t=r==null?void 0:r.mapValue)===null||t===void 0?void 0:t.fields)||{}).__type__)===null||e===void 0?void 0:e.stringValue)==="server_timestamp"}function cs(r){const t=r.mapValue.fields.__previous_value__;return us(t)?cs(t):t}function Ur(r){const t=ne(r.mapValue.fields.__local_write_time__.timestampValue);return new lt(t.seconds,t.nanos)}/**
864
864
  * @license
865
865
  * Copyright 2017 Google LLC
866
866
  *
@@ -875,7 +875,7 @@ SPDX-License-Identifier: Apache-2.0
875
875
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
876
876
  * See the License for the specific language governing permissions and
877
877
  * limitations under the License.
878
- */class ep{constructor(t,e,n,i,s,a,u,c,h){this.databaseId=t,this.appId=e,this.persistenceKey=n,this.host=i,this.ssl=s,this.forceLongPolling=a,this.autoDetectLongPolling=u,this.longPollingOptions=c,this.useFetchStreams=h}}class ve{constructor(t,e){this.projectId=t,this.database=e||"(default)"}static empty(){return new ve("","")}get isDefaultDatabase(){return this.database==="(default)"}isEqual(t){return t instanceof ve&&t.projectId===this.projectId&&t.database===this.database}}/**
878
+ */class ep{constructor(t,e,n,i,s,a,u,c,h){this.databaseId=t,this.appId=e,this.persistenceKey=n,this.host=i,this.ssl=s,this.forceLongPolling=a,this.autoDetectLongPolling=u,this.longPollingOptions=c,this.useFetchStreams=h}}class we{constructor(t,e){this.projectId=t,this.database=e||"(default)"}static empty(){return new we("","")}get isDefaultDatabase(){return this.database==="(default)"}isEqual(t){return t instanceof we&&t.projectId===this.projectId&&t.database===this.database}}/**
879
879
  * @license
880
880
  * Copyright 2020 Google LLC
881
881
  *
@@ -890,7 +890,7 @@ SPDX-License-Identifier: Apache-2.0
890
890
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
891
891
  * See the License for the specific language governing permissions and
892
892
  * limitations under the License.
893
- */const _e={mapValue:{fields:{__type__:{stringValue:"__max__"}}}},Li={nullValue:"NULL_VALUE"};function we(r){return"nullValue"in r?0:"booleanValue"in r?1:"integerValue"in r||"doubleValue"in r?2:"timestampValue"in r?3:"stringValue"in r?5:"bytesValue"in r?6:"referenceValue"in r?7:"geoPointValue"in r?8:"arrayValue"in r?9:"mapValue"in r?us(r)?4:Yl(r)?9007199254740991:ls(r)?10:11:O()}function Jt(r,t){if(r===t)return!0;const e=we(r);if(e!==we(t))return!1;switch(e){case 0:case 9007199254740991:return!0;case 1:return r.booleanValue===t.booleanValue;case 4:return Br(r).isEqual(Br(t));case 3:return function(i,s){if(typeof i.timestampValue=="string"&&typeof s.timestampValue=="string"&&i.timestampValue.length===s.timestampValue.length)return i.timestampValue===s.timestampValue;const a=ne(i.timestampValue),u=ne(s.timestampValue);return a.seconds===u.seconds&&a.nanos===u.nanos}(r,t);case 5:return r.stringValue===t.stringValue;case 6:return function(i,s){return re(i.bytesValue).isEqual(re(s.bytesValue))}(r,t);case 7:return r.referenceValue===t.referenceValue;case 8:return function(i,s){return ut(i.geoPointValue.latitude)===ut(s.geoPointValue.latitude)&&ut(i.geoPointValue.longitude)===ut(s.geoPointValue.longitude)}(r,t);case 2:return function(i,s){if("integerValue"in i&&"integerValue"in s)return ut(i.integerValue)===ut(s.integerValue);if("doubleValue"in i&&"doubleValue"in s){const a=ut(i.doubleValue),u=ut(s.doubleValue);return a===u?Lr(a)===Lr(u):isNaN(a)&&isNaN(u)}return!1}(r,t);case 9:return Vn(r.arrayValue.values||[],t.arrayValue.values||[],Jt);case 10:case 11:return function(i,s){const a=i.mapValue.fields||{},u=s.mapValue.fields||{};if(Yu(a)!==Yu(u))return!1;for(const c in a)if(a.hasOwnProperty(c)&&(u[c]===void 0||!Jt(a[c],u[c])))return!1;return!0}(r,t);default:return O()}}function Ur(r,t){return(r.values||[]).find(e=>Jt(e,t))!==void 0}function Ae(r,t){if(r===t)return 0;const e=we(r),n=we(t);if(e!==n)return j(e,n);switch(e){case 0:case 9007199254740991:return 0;case 1:return j(r.booleanValue,t.booleanValue);case 2:return function(s,a){const u=ut(s.integerValue||s.doubleValue),c=ut(a.integerValue||a.doubleValue);return u<c?-1:u>c?1:u===c?0:isNaN(u)?isNaN(c)?0:-1:1}(r,t);case 3:return Zu(r.timestampValue,t.timestampValue);case 4:return Zu(Br(r),Br(t));case 5:return j(r.stringValue,t.stringValue);case 6:return function(s,a){const u=re(s),c=re(a);return u.compareTo(c)}(r.bytesValue,t.bytesValue);case 7:return function(s,a){const u=s.split("/"),c=a.split("/");for(let h=0;h<u.length&&h<c.length;h++){const f=j(u[h],c[h]);if(f!==0)return f}return j(u.length,c.length)}(r.referenceValue,t.referenceValue);case 8:return function(s,a){const u=j(ut(s.latitude),ut(a.latitude));return u!==0?u:j(ut(s.longitude),ut(a.longitude))}(r.geoPointValue,t.geoPointValue);case 9:return tc(r.arrayValue,t.arrayValue);case 10:return function(s,a){var u,c,h,f;const g=s.fields||{},_=a.fields||{},R=(u=g.value)===null||u===void 0?void 0:u.arrayValue,C=(c=_.value)===null||c===void 0?void 0:c.arrayValue,N=j(((h=R==null?void 0:R.values)===null||h===void 0?void 0:h.length)||0,((f=C==null?void 0:C.values)===null||f===void 0?void 0:f.length)||0);return N!==0?N:tc(R,C)}(r.mapValue,t.mapValue);case 11:return function(s,a){if(s===_e.mapValue&&a===_e.mapValue)return 0;if(s===_e.mapValue)return 1;if(a===_e.mapValue)return-1;const u=s.fields||{},c=Object.keys(u),h=a.fields||{},f=Object.keys(h);c.sort(),f.sort();for(let g=0;g<c.length&&g<f.length;++g){const _=j(c[g],f[g]);if(_!==0)return _;const R=Ae(u[c[g]],h[f[g]]);if(R!==0)return R}return j(c.length,f.length)}(r.mapValue,t.mapValue);default:throw O()}}function Zu(r,t){if(typeof r=="string"&&typeof t=="string"&&r.length===t.length)return j(r,t);const e=ne(r),n=ne(t),i=j(e.seconds,n.seconds);return i!==0?i:j(e.nanos,n.nanos)}function tc(r,t){const e=r.values||[],n=t.values||[];for(let i=0;i<e.length&&i<n.length;++i){const s=Ae(e[i],n[i]);if(s)return s}return j(e.length,n.length)}function xn(r){return _o(r)}function _o(r){return"nullValue"in r?"null":"booleanValue"in r?""+r.booleanValue:"integerValue"in r?""+r.integerValue:"doubleValue"in r?""+r.doubleValue:"timestampValue"in r?function(e){const n=ne(e);return`time(${n.seconds},${n.nanos})`}(r.timestampValue):"stringValue"in r?r.stringValue:"bytesValue"in r?function(e){return re(e).toBase64()}(r.bytesValue):"referenceValue"in r?function(e){return M.fromName(e).toString()}(r.referenceValue):"geoPointValue"in r?function(e){return`geo(${e.latitude},${e.longitude})`}(r.geoPointValue):"arrayValue"in r?function(e){let n="[",i=!0;for(const s of e.values||[])i?i=!1:n+=",",n+=_o(s);return n+"]"}(r.arrayValue):"mapValue"in r?function(e){const n=Object.keys(e.fields||{}).sort();let i="{",s=!0;for(const a of n)s?s=!1:i+=",",i+=`${a}:${_o(e.fields[a])}`;return i+"}"}(r.mapValue):O()}function Bi(r){switch(we(r)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const t=cs(r);return t?16+Bi(t):16;case 5:return 2*r.stringValue.length;case 6:return re(r.bytesValue).approximateByteSize();case 7:return r.referenceValue.length;case 9:return function(n){return(n.values||[]).reduce((i,s)=>i+Bi(s),0)}(r.arrayValue);case 10:case 11:return function(n){let i=0;return xe(n.fields,(s,a)=>{i+=s.length+Bi(a)}),i}(r.mapValue);default:throw O()}}function Xe(r,t){return{referenceValue:`projects/${r.projectId}/databases/${r.database}/documents/${t.path.canonicalString()}`}}function yo(r){return!!r&&"integerValue"in r}function qr(r){return!!r&&"arrayValue"in r}function ec(r){return!!r&&"nullValue"in r}function nc(r){return!!r&&"doubleValue"in r&&isNaN(Number(r.doubleValue))}function Ui(r){return!!r&&"mapValue"in r}function ls(r){var t,e;return((e=(((t=r==null?void 0:r.mapValue)===null||t===void 0?void 0:t.fields)||{}).__type__)===null||e===void 0?void 0:e.stringValue)==="__vector__"}function Vr(r){if(r.geoPointValue)return{geoPointValue:Object.assign({},r.geoPointValue)};if(r.timestampValue&&typeof r.timestampValue=="object")return{timestampValue:Object.assign({},r.timestampValue)};if(r.mapValue){const t={mapValue:{fields:{}}};return xe(r.mapValue.fields,(e,n)=>t.mapValue.fields[e]=Vr(n)),t}if(r.arrayValue){const t={arrayValue:{values:[]}};for(let e=0;e<(r.arrayValue.values||[]).length;++e)t.arrayValue.values[e]=Vr(r.arrayValue.values[e]);return t}return Object.assign({},r)}function Yl(r){return(((r.mapValue||{}).fields||{}).__type__||{}).stringValue==="__max__"}const Xl={mapValue:{fields:{__type__:{stringValue:"__vector__"},value:{arrayValue:{}}}}};function np(r){return"nullValue"in r?Li:"booleanValue"in r?{booleanValue:!1}:"integerValue"in r||"doubleValue"in r?{doubleValue:NaN}:"timestampValue"in r?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"stringValue"in r?{stringValue:""}:"bytesValue"in r?{bytesValue:""}:"referenceValue"in r?Xe(ve.empty(),M.empty()):"geoPointValue"in r?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in r?{arrayValue:{}}:"mapValue"in r?ls(r)?Xl:{mapValue:{}}:O()}function rp(r){return"nullValue"in r?{booleanValue:!1}:"booleanValue"in r?{doubleValue:NaN}:"integerValue"in r||"doubleValue"in r?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"timestampValue"in r?{stringValue:""}:"stringValue"in r?{bytesValue:""}:"bytesValue"in r?Xe(ve.empty(),M.empty()):"referenceValue"in r?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in r?{arrayValue:{}}:"arrayValue"in r?Xl:"mapValue"in r?ls(r)?{mapValue:{}}:_e:O()}function rc(r,t){const e=Ae(r.value,t.value);return e!==0?e:r.inclusive&&!t.inclusive?-1:!r.inclusive&&t.inclusive?1:0}function ic(r,t){const e=Ae(r.value,t.value);return e!==0?e:r.inclusive&&!t.inclusive?1:!r.inclusive&&t.inclusive?-1:0}/**
893
+ */const _e={mapValue:{fields:{__type__:{stringValue:"__max__"}}}},Li={nullValue:"NULL_VALUE"};function Ae(r){return"nullValue"in r?0:"booleanValue"in r?1:"integerValue"in r||"doubleValue"in r?2:"timestampValue"in r?3:"stringValue"in r?5:"bytesValue"in r?6:"referenceValue"in r?7:"geoPointValue"in r?8:"arrayValue"in r?9:"mapValue"in r?us(r)?4:Yl(r)?9007199254740991:ls(r)?10:11:O()}function Jt(r,t){if(r===t)return!0;const e=Ae(r);if(e!==Ae(t))return!1;switch(e){case 0:case 9007199254740991:return!0;case 1:return r.booleanValue===t.booleanValue;case 4:return Ur(r).isEqual(Ur(t));case 3:return function(i,s){if(typeof i.timestampValue=="string"&&typeof s.timestampValue=="string"&&i.timestampValue.length===s.timestampValue.length)return i.timestampValue===s.timestampValue;const a=ne(i.timestampValue),u=ne(s.timestampValue);return a.seconds===u.seconds&&a.nanos===u.nanos}(r,t);case 5:return r.stringValue===t.stringValue;case 6:return function(i,s){return re(i.bytesValue).isEqual(re(s.bytesValue))}(r,t);case 7:return r.referenceValue===t.referenceValue;case 8:return function(i,s){return ut(i.geoPointValue.latitude)===ut(s.geoPointValue.latitude)&&ut(i.geoPointValue.longitude)===ut(s.geoPointValue.longitude)}(r,t);case 2:return function(i,s){if("integerValue"in i&&"integerValue"in s)return ut(i.integerValue)===ut(s.integerValue);if("doubleValue"in i&&"doubleValue"in s){const a=ut(i.doubleValue),u=ut(s.doubleValue);return a===u?Br(a)===Br(u):isNaN(a)&&isNaN(u)}return!1}(r,t);case 9:return Cn(r.arrayValue.values||[],t.arrayValue.values||[],Jt);case 10:case 11:return function(i,s){const a=i.mapValue.fields||{},u=s.mapValue.fields||{};if(Yu(a)!==Yu(u))return!1;for(const c in a)if(a.hasOwnProperty(c)&&(u[c]===void 0||!Jt(a[c],u[c])))return!1;return!0}(r,t);default:return O()}}function qr(r,t){return(r.values||[]).find(e=>Jt(e,t))!==void 0}function Re(r,t){if(r===t)return 0;const e=Ae(r),n=Ae(t);if(e!==n)return j(e,n);switch(e){case 0:case 9007199254740991:return 0;case 1:return j(r.booleanValue,t.booleanValue);case 2:return function(s,a){const u=ut(s.integerValue||s.doubleValue),c=ut(a.integerValue||a.doubleValue);return u<c?-1:u>c?1:u===c?0:isNaN(u)?isNaN(c)?0:-1:1}(r,t);case 3:return Zu(r.timestampValue,t.timestampValue);case 4:return Zu(Ur(r),Ur(t));case 5:return j(r.stringValue,t.stringValue);case 6:return function(s,a){const u=re(s),c=re(a);return u.compareTo(c)}(r.bytesValue,t.bytesValue);case 7:return function(s,a){const u=s.split("/"),c=a.split("/");for(let h=0;h<u.length&&h<c.length;h++){const f=j(u[h],c[h]);if(f!==0)return f}return j(u.length,c.length)}(r.referenceValue,t.referenceValue);case 8:return function(s,a){const u=j(ut(s.latitude),ut(a.latitude));return u!==0?u:j(ut(s.longitude),ut(a.longitude))}(r.geoPointValue,t.geoPointValue);case 9:return tc(r.arrayValue,t.arrayValue);case 10:return function(s,a){var u,c,h,f;const g=s.fields||{},_=a.fields||{},R=(u=g.value)===null||u===void 0?void 0:u.arrayValue,C=(c=_.value)===null||c===void 0?void 0:c.arrayValue,N=j(((h=R==null?void 0:R.values)===null||h===void 0?void 0:h.length)||0,((f=C==null?void 0:C.values)===null||f===void 0?void 0:f.length)||0);return N!==0?N:tc(R,C)}(r.mapValue,t.mapValue);case 11:return function(s,a){if(s===_e.mapValue&&a===_e.mapValue)return 0;if(s===_e.mapValue)return 1;if(a===_e.mapValue)return-1;const u=s.fields||{},c=Object.keys(u),h=a.fields||{},f=Object.keys(h);c.sort(),f.sort();for(let g=0;g<c.length&&g<f.length;++g){const _=j(c[g],f[g]);if(_!==0)return _;const R=Re(u[c[g]],h[f[g]]);if(R!==0)return R}return j(c.length,f.length)}(r.mapValue,t.mapValue);default:throw O()}}function Zu(r,t){if(typeof r=="string"&&typeof t=="string"&&r.length===t.length)return j(r,t);const e=ne(r),n=ne(t),i=j(e.seconds,n.seconds);return i!==0?i:j(e.nanos,n.nanos)}function tc(r,t){const e=r.values||[],n=t.values||[];for(let i=0;i<e.length&&i<n.length;++i){const s=Re(e[i],n[i]);if(s)return s}return j(e.length,n.length)}function Nn(r){return _o(r)}function _o(r){return"nullValue"in r?"null":"booleanValue"in r?""+r.booleanValue:"integerValue"in r?""+r.integerValue:"doubleValue"in r?""+r.doubleValue:"timestampValue"in r?function(e){const n=ne(e);return`time(${n.seconds},${n.nanos})`}(r.timestampValue):"stringValue"in r?r.stringValue:"bytesValue"in r?function(e){return re(e).toBase64()}(r.bytesValue):"referenceValue"in r?function(e){return M.fromName(e).toString()}(r.referenceValue):"geoPointValue"in r?function(e){return`geo(${e.latitude},${e.longitude})`}(r.geoPointValue):"arrayValue"in r?function(e){let n="[",i=!0;for(const s of e.values||[])i?i=!1:n+=",",n+=_o(s);return n+"]"}(r.arrayValue):"mapValue"in r?function(e){const n=Object.keys(e.fields||{}).sort();let i="{",s=!0;for(const a of n)s?s=!1:i+=",",i+=`${a}:${_o(e.fields[a])}`;return i+"}"}(r.mapValue):O()}function Bi(r){switch(Ae(r)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const t=cs(r);return t?16+Bi(t):16;case 5:return 2*r.stringValue.length;case 6:return re(r.bytesValue).approximateByteSize();case 7:return r.referenceValue.length;case 9:return function(n){return(n.values||[]).reduce((i,s)=>i+Bi(s),0)}(r.arrayValue);case 10:case 11:return function(n){let i=0;return Ne(n.fields,(s,a)=>{i+=s.length+Bi(a)}),i}(r.mapValue);default:throw O()}}function Ze(r,t){return{referenceValue:`projects/${r.projectId}/databases/${r.database}/documents/${t.path.canonicalString()}`}}function yo(r){return!!r&&"integerValue"in r}function zr(r){return!!r&&"arrayValue"in r}function ec(r){return!!r&&"nullValue"in r}function nc(r){return!!r&&"doubleValue"in r&&isNaN(Number(r.doubleValue))}function Ui(r){return!!r&&"mapValue"in r}function ls(r){var t,e;return((e=(((t=r==null?void 0:r.mapValue)===null||t===void 0?void 0:t.fields)||{}).__type__)===null||e===void 0?void 0:e.stringValue)==="__vector__"}function Cr(r){if(r.geoPointValue)return{geoPointValue:Object.assign({},r.geoPointValue)};if(r.timestampValue&&typeof r.timestampValue=="object")return{timestampValue:Object.assign({},r.timestampValue)};if(r.mapValue){const t={mapValue:{fields:{}}};return Ne(r.mapValue.fields,(e,n)=>t.mapValue.fields[e]=Cr(n)),t}if(r.arrayValue){const t={arrayValue:{values:[]}};for(let e=0;e<(r.arrayValue.values||[]).length;++e)t.arrayValue.values[e]=Cr(r.arrayValue.values[e]);return t}return Object.assign({},r)}function Yl(r){return(((r.mapValue||{}).fields||{}).__type__||{}).stringValue==="__max__"}const Xl={mapValue:{fields:{__type__:{stringValue:"__vector__"},value:{arrayValue:{}}}}};function np(r){return"nullValue"in r?Li:"booleanValue"in r?{booleanValue:!1}:"integerValue"in r||"doubleValue"in r?{doubleValue:NaN}:"timestampValue"in r?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"stringValue"in r?{stringValue:""}:"bytesValue"in r?{bytesValue:""}:"referenceValue"in r?Ze(we.empty(),M.empty()):"geoPointValue"in r?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in r?{arrayValue:{}}:"mapValue"in r?ls(r)?Xl:{mapValue:{}}:O()}function rp(r){return"nullValue"in r?{booleanValue:!1}:"booleanValue"in r?{doubleValue:NaN}:"integerValue"in r||"doubleValue"in r?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"timestampValue"in r?{stringValue:""}:"stringValue"in r?{bytesValue:""}:"bytesValue"in r?Ze(we.empty(),M.empty()):"referenceValue"in r?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in r?{arrayValue:{}}:"arrayValue"in r?Xl:"mapValue"in r?ls(r)?{mapValue:{}}:_e:O()}function rc(r,t){const e=Re(r.value,t.value);return e!==0?e:r.inclusive&&!t.inclusive?-1:!r.inclusive&&t.inclusive?1:0}function ic(r,t){const e=Re(r.value,t.value);return e!==0?e:r.inclusive&&!t.inclusive?1:!r.inclusive&&t.inclusive?-1:0}/**
894
894
  * @license
895
895
  * Copyright 2017 Google LLC
896
896
  *
@@ -905,7 +905,7 @@ SPDX-License-Identifier: Apache-2.0
905
905
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
906
906
  * See the License for the specific language governing permissions and
907
907
  * limitations under the License.
908
- */class bt{constructor(t){this.value=t}static empty(){return new bt({mapValue:{}})}field(t){if(t.isEmpty())return this.value;{let e=this.value;for(let n=0;n<t.length-1;++n)if(e=(e.mapValue.fields||{})[t.get(n)],!Ui(e))return null;return e=(e.mapValue.fields||{})[t.lastSegment()],e||null}}set(t,e){this.getFieldsMap(t.popLast())[t.lastSegment()]=Vr(e)}setAll(t){let e=at.emptyPath(),n={},i=[];t.forEach((a,u)=>{if(!e.isImmediateParentOf(u)){const c=this.getFieldsMap(e);this.applyChanges(c,n,i),n={},i=[],e=u.popLast()}a?n[u.lastSegment()]=Vr(a):i.push(u.lastSegment())});const s=this.getFieldsMap(e);this.applyChanges(s,n,i)}delete(t){const e=this.field(t.popLast());Ui(e)&&e.mapValue.fields&&delete e.mapValue.fields[t.lastSegment()]}isEqual(t){return Jt(this.value,t.value)}getFieldsMap(t){let e=this.value;e.mapValue.fields||(e.mapValue={fields:{}});for(let n=0;n<t.length;++n){let i=e.mapValue.fields[t.get(n)];Ui(i)&&i.mapValue.fields||(i={mapValue:{fields:{}}},e.mapValue.fields[t.get(n)]=i),e=i}return e.mapValue.fields}applyChanges(t,e,n){xe(e,(i,s)=>t[i]=s);for(const i of n)delete t[i]}clone(){return new bt(Vr(this.value))}}function Zl(r){const t=[];return xe(r.fields,(e,n)=>{const i=new at([e]);if(Ui(n)){const s=Zl(n.mapValue).fields;if(s.length===0)t.push(i);else for(const a of s)t.push(i.child(a))}else t.push(i)}),new Lt(t)}/**
908
+ */class bt{constructor(t){this.value=t}static empty(){return new bt({mapValue:{}})}field(t){if(t.isEmpty())return this.value;{let e=this.value;for(let n=0;n<t.length-1;++n)if(e=(e.mapValue.fields||{})[t.get(n)],!Ui(e))return null;return e=(e.mapValue.fields||{})[t.lastSegment()],e||null}}set(t,e){this.getFieldsMap(t.popLast())[t.lastSegment()]=Cr(e)}setAll(t){let e=at.emptyPath(),n={},i=[];t.forEach((a,u)=>{if(!e.isImmediateParentOf(u)){const c=this.getFieldsMap(e);this.applyChanges(c,n,i),n={},i=[],e=u.popLast()}a?n[u.lastSegment()]=Cr(a):i.push(u.lastSegment())});const s=this.getFieldsMap(e);this.applyChanges(s,n,i)}delete(t){const e=this.field(t.popLast());Ui(e)&&e.mapValue.fields&&delete e.mapValue.fields[t.lastSegment()]}isEqual(t){return Jt(this.value,t.value)}getFieldsMap(t){let e=this.value;e.mapValue.fields||(e.mapValue={fields:{}});for(let n=0;n<t.length;++n){let i=e.mapValue.fields[t.get(n)];Ui(i)&&i.mapValue.fields||(i={mapValue:{fields:{}}},e.mapValue.fields[t.get(n)]=i),e=i}return e.mapValue.fields}applyChanges(t,e,n){Ne(e,(i,s)=>t[i]=s);for(const i of n)delete t[i]}clone(){return new bt(Cr(this.value))}}function Zl(r){const t=[];return Ne(r.fields,(e,n)=>{const i=new at([e]);if(Ui(n)){const s=Zl(n.mapValue).fields;if(s.length===0)t.push(i);else for(const a of s)t.push(i.child(a))}else t.push(i)}),new Lt(t)}/**
909
909
  * @license
910
910
  * Copyright 2017 Google LLC
911
911
  *
@@ -935,7 +935,7 @@ SPDX-License-Identifier: Apache-2.0
935
935
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
936
936
  * See the License for the specific language governing permissions and
937
937
  * limitations under the License.
938
- */class Re{constructor(t,e){this.position=t,this.inclusive=e}}function sc(r,t,e){let n=0;for(let i=0;i<r.position.length;i++){const s=t[i],a=r.position[i];if(s.field.isKeyField()?n=M.comparator(M.fromName(a.referenceValue),e.key):n=Ae(a,e.data.field(s.field)),s.dir==="desc"&&(n*=-1),n!==0)break}return n}function oc(r,t){if(r===null)return t===null;if(t===null||r.inclusive!==t.inclusive||r.position.length!==t.position.length)return!1;for(let e=0;e<r.position.length;e++)if(!Jt(r.position[e],t.position[e]))return!1;return!0}/**
938
+ */class be{constructor(t,e){this.position=t,this.inclusive=e}}function sc(r,t,e){let n=0;for(let i=0;i<r.position.length;i++){const s=t[i],a=r.position[i];if(s.field.isKeyField()?n=M.comparator(M.fromName(a.referenceValue),e.key):n=Re(a,e.data.field(s.field)),s.dir==="desc"&&(n*=-1),n!==0)break}return n}function oc(r,t){if(r===null)return t===null;if(t===null||r.inclusive!==t.inclusive||r.position.length!==t.position.length)return!1;for(let e=0;e<r.position.length;e++)if(!Jt(r.position[e],t.position[e]))return!1;return!0}/**
939
939
  * @license
940
940
  * Copyright 2022 Google LLC
941
941
  *
@@ -950,7 +950,7 @@ SPDX-License-Identifier: Apache-2.0
950
950
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
951
951
  * See the License for the specific language governing permissions and
952
952
  * limitations under the License.
953
- */class zr{constructor(t,e="asc"){this.field=t,this.dir=e}}function ip(r,t){return r.dir===t.dir&&r.field.isEqual(t.field)}/**
953
+ */class jr{constructor(t,e="asc"){this.field=t,this.dir=e}}function ip(r,t){return r.dir===t.dir&&r.field.isEqual(t.field)}/**
954
954
  * @license
955
955
  * Copyright 2022 Google LLC
956
956
  *
@@ -965,7 +965,7 @@ SPDX-License-Identifier: Apache-2.0
965
965
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
966
966
  * See the License for the specific language governing permissions and
967
967
  * limitations under the License.
968
- */class th{}class H extends th{constructor(t,e,n){super(),this.field=t,this.op=e,this.value=n}static create(t,e,n){return t.isKeyField()?e==="in"||e==="not-in"?this.createKeyFieldInFilter(t,e,n):new sp(t,e,n):e==="array-contains"?new up(t,n):e==="in"?new oh(t,n):e==="not-in"?new cp(t,n):e==="array-contains-any"?new lp(t,n):new H(t,e,n)}static createKeyFieldInFilter(t,e,n){return e==="in"?new op(t,n):new ap(t,n)}matches(t){const e=t.data.field(this.field);return this.op==="!="?e!==null&&this.matchesComparison(Ae(e,this.value)):e!==null&&we(this.value)===we(e)&&this.matchesComparison(Ae(e,this.value))}matchesComparison(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return t===0;case"!=":return t!==0;case">":return t>0;case">=":return t>=0;default:return O()}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class tt extends th{constructor(t,e){super(),this.filters=t,this.op=e,this.ae=null}static create(t,e){return new tt(t,e)}matches(t){return Nn(this)?this.filters.find(e=>!e.matches(t))===void 0:this.filters.find(e=>e.matches(t))!==void 0}getFlattenedFilters(){return this.ae!==null||(this.ae=this.filters.reduce((t,e)=>t.concat(e.getFlattenedFilters()),[])),this.ae}getFilters(){return Object.assign([],this.filters)}}function Nn(r){return r.op==="and"}function Io(r){return r.op==="or"}function jo(r){return eh(r)&&Nn(r)}function eh(r){for(const t of r.filters)if(t instanceof tt)return!1;return!0}function Eo(r){if(r instanceof H)return r.field.canonicalString()+r.op.toString()+xn(r.value);if(jo(r))return r.filters.map(t=>Eo(t)).join(",");{const t=r.filters.map(e=>Eo(e)).join(",");return`${r.op}(${t})`}}function nh(r,t){return r instanceof H?function(n,i){return i instanceof H&&n.op===i.op&&n.field.isEqual(i.field)&&Jt(n.value,i.value)}(r,t):r instanceof tt?function(n,i){return i instanceof tt&&n.op===i.op&&n.filters.length===i.filters.length?n.filters.reduce((s,a,u)=>s&&nh(a,i.filters[u]),!0):!1}(r,t):void O()}function rh(r,t){const e=r.filters.concat(t);return tt.create(e,r.op)}function ih(r){return r instanceof H?function(e){return`${e.field.canonicalString()} ${e.op} ${xn(e.value)}`}(r):r instanceof tt?function(e){return e.op.toString()+" {"+e.getFilters().map(ih).join(" ,")+"}"}(r):"Filter"}class sp extends H{constructor(t,e,n){super(t,e,n),this.key=M.fromName(n.referenceValue)}matches(t){const e=M.comparator(t.key,this.key);return this.matchesComparison(e)}}class op extends H{constructor(t,e){super(t,"in",e),this.keys=sh("in",e)}matches(t){return this.keys.some(e=>e.isEqual(t.key))}}class ap extends H{constructor(t,e){super(t,"not-in",e),this.keys=sh("not-in",e)}matches(t){return!this.keys.some(e=>e.isEqual(t.key))}}function sh(r,t){var e;return(((e=t.arrayValue)===null||e===void 0?void 0:e.values)||[]).map(n=>M.fromName(n.referenceValue))}class up extends H{constructor(t,e){super(t,"array-contains",e)}matches(t){const e=t.data.field(this.field);return qr(e)&&Ur(e.arrayValue,this.value)}}class oh extends H{constructor(t,e){super(t,"in",e)}matches(t){const e=t.data.field(this.field);return e!==null&&Ur(this.value.arrayValue,e)}}class cp extends H{constructor(t,e){super(t,"not-in",e)}matches(t){if(Ur(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const e=t.data.field(this.field);return e!==null&&!Ur(this.value.arrayValue,e)}}class lp extends H{constructor(t,e){super(t,"array-contains-any",e)}matches(t){const e=t.data.field(this.field);return!(!qr(e)||!e.arrayValue.values)&&e.arrayValue.values.some(n=>Ur(this.value.arrayValue,n))}}/**
968
+ */class th{}class H extends th{constructor(t,e,n){super(),this.field=t,this.op=e,this.value=n}static create(t,e,n){return t.isKeyField()?e==="in"||e==="not-in"?this.createKeyFieldInFilter(t,e,n):new sp(t,e,n):e==="array-contains"?new up(t,n):e==="in"?new oh(t,n):e==="not-in"?new cp(t,n):e==="array-contains-any"?new lp(t,n):new H(t,e,n)}static createKeyFieldInFilter(t,e,n){return e==="in"?new op(t,n):new ap(t,n)}matches(t){const e=t.data.field(this.field);return this.op==="!="?e!==null&&this.matchesComparison(Re(e,this.value)):e!==null&&Ae(this.value)===Ae(e)&&this.matchesComparison(Re(e,this.value))}matchesComparison(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return t===0;case"!=":return t!==0;case">":return t>0;case">=":return t>=0;default:return O()}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class tt extends th{constructor(t,e){super(),this.filters=t,this.op=e,this.ae=null}static create(t,e){return new tt(t,e)}matches(t){return kn(this)?this.filters.find(e=>!e.matches(t))===void 0:this.filters.find(e=>e.matches(t))!==void 0}getFlattenedFilters(){return this.ae!==null||(this.ae=this.filters.reduce((t,e)=>t.concat(e.getFlattenedFilters()),[])),this.ae}getFilters(){return Object.assign([],this.filters)}}function kn(r){return r.op==="and"}function Io(r){return r.op==="or"}function jo(r){return eh(r)&&kn(r)}function eh(r){for(const t of r.filters)if(t instanceof tt)return!1;return!0}function Eo(r){if(r instanceof H)return r.field.canonicalString()+r.op.toString()+Nn(r.value);if(jo(r))return r.filters.map(t=>Eo(t)).join(",");{const t=r.filters.map(e=>Eo(e)).join(",");return`${r.op}(${t})`}}function nh(r,t){return r instanceof H?function(n,i){return i instanceof H&&n.op===i.op&&n.field.isEqual(i.field)&&Jt(n.value,i.value)}(r,t):r instanceof tt?function(n,i){return i instanceof tt&&n.op===i.op&&n.filters.length===i.filters.length?n.filters.reduce((s,a,u)=>s&&nh(a,i.filters[u]),!0):!1}(r,t):void O()}function rh(r,t){const e=r.filters.concat(t);return tt.create(e,r.op)}function ih(r){return r instanceof H?function(e){return`${e.field.canonicalString()} ${e.op} ${Nn(e.value)}`}(r):r instanceof tt?function(e){return e.op.toString()+" {"+e.getFilters().map(ih).join(" ,")+"}"}(r):"Filter"}class sp extends H{constructor(t,e,n){super(t,e,n),this.key=M.fromName(n.referenceValue)}matches(t){const e=M.comparator(t.key,this.key);return this.matchesComparison(e)}}class op extends H{constructor(t,e){super(t,"in",e),this.keys=sh("in",e)}matches(t){return this.keys.some(e=>e.isEqual(t.key))}}class ap extends H{constructor(t,e){super(t,"not-in",e),this.keys=sh("not-in",e)}matches(t){return!this.keys.some(e=>e.isEqual(t.key))}}function sh(r,t){var e;return(((e=t.arrayValue)===null||e===void 0?void 0:e.values)||[]).map(n=>M.fromName(n.referenceValue))}class up extends H{constructor(t,e){super(t,"array-contains",e)}matches(t){const e=t.data.field(this.field);return zr(e)&&qr(e.arrayValue,this.value)}}class oh extends H{constructor(t,e){super(t,"in",e)}matches(t){const e=t.data.field(this.field);return e!==null&&qr(this.value.arrayValue,e)}}class cp extends H{constructor(t,e){super(t,"not-in",e)}matches(t){if(qr(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const e=t.data.field(this.field);return e!==null&&!qr(this.value.arrayValue,e)}}class lp extends H{constructor(t,e){super(t,"array-contains-any",e)}matches(t){const e=t.data.field(this.field);return!(!zr(e)||!e.arrayValue.values)&&e.arrayValue.values.some(n=>qr(this.value.arrayValue,n))}}/**
969
969
  * @license
970
970
  * Copyright 2019 Google LLC
971
971
  *
@@ -980,7 +980,7 @@ SPDX-License-Identifier: Apache-2.0
980
980
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
981
981
  * See the License for the specific language governing permissions and
982
982
  * limitations under the License.
983
- */class hp{constructor(t,e=null,n=[],i=[],s=null,a=null,u=null){this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=i,this.limit=s,this.startAt=a,this.endAt=u,this.ue=null}}function To(r,t=null,e=[],n=[],i=null,s=null,a=null){return new hp(r,t,e,n,i,s,a)}function Ze(r){const t=k(r);if(t.ue===null){let e=t.path.canonicalString();t.collectionGroup!==null&&(e+="|cg:"+t.collectionGroup),e+="|f:",e+=t.filters.map(n=>Eo(n)).join(","),e+="|ob:",e+=t.orderBy.map(n=>function(s){return s.field.canonicalString()+s.dir}(n)).join(","),Wr(t.limit)||(e+="|l:",e+=t.limit),t.startAt&&(e+="|lb:",e+=t.startAt.inclusive?"b:":"a:",e+=t.startAt.position.map(n=>xn(n)).join(",")),t.endAt&&(e+="|ub:",e+=t.endAt.inclusive?"a:":"b:",e+=t.endAt.position.map(n=>xn(n)).join(",")),t.ue=e}return t.ue}function Hr(r,t){if(r.limit!==t.limit||r.orderBy.length!==t.orderBy.length)return!1;for(let e=0;e<r.orderBy.length;e++)if(!ip(r.orderBy[e],t.orderBy[e]))return!1;if(r.filters.length!==t.filters.length)return!1;for(let e=0;e<r.filters.length;e++)if(!nh(r.filters[e],t.filters[e]))return!1;return r.collectionGroup===t.collectionGroup&&!!r.path.isEqual(t.path)&&!!oc(r.startAt,t.startAt)&&oc(r.endAt,t.endAt)}function Qi(r){return M.isDocumentKey(r.path)&&r.collectionGroup===null&&r.filters.length===0}function Wi(r,t){return r.filters.filter(e=>e instanceof H&&e.field.isEqual(t))}function ac(r,t,e){let n=Li,i=!0;for(const s of Wi(r,t)){let a=Li,u=!0;switch(s.op){case"<":case"<=":a=np(s.value);break;case"==":case"in":case">=":a=s.value;break;case">":a=s.value,u=!1;break;case"!=":case"not-in":a=Li}rc({value:n,inclusive:i},{value:a,inclusive:u})<0&&(n=a,i=u)}if(e!==null){for(let s=0;s<r.orderBy.length;++s)if(r.orderBy[s].field.isEqual(t)){const a=e.position[s];rc({value:n,inclusive:i},{value:a,inclusive:e.inclusive})<0&&(n=a,i=e.inclusive);break}}return{value:n,inclusive:i}}function uc(r,t,e){let n=_e,i=!0;for(const s of Wi(r,t)){let a=_e,u=!0;switch(s.op){case">=":case">":a=rp(s.value),u=!1;break;case"==":case"in":case"<=":a=s.value;break;case"<":a=s.value,u=!1;break;case"!=":case"not-in":a=_e}ic({value:n,inclusive:i},{value:a,inclusive:u})>0&&(n=a,i=u)}if(e!==null){for(let s=0;s<r.orderBy.length;++s)if(r.orderBy[s].field.isEqual(t)){const a=e.position[s];ic({value:n,inclusive:i},{value:a,inclusive:e.inclusive})>0&&(n=a,i=e.inclusive);break}}return{value:n,inclusive:i}}/**
983
+ */class hp{constructor(t,e=null,n=[],i=[],s=null,a=null,u=null){this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=i,this.limit=s,this.startAt=a,this.endAt=u,this.ue=null}}function To(r,t=null,e=[],n=[],i=null,s=null,a=null){return new hp(r,t,e,n,i,s,a)}function tn(r){const t=k(r);if(t.ue===null){let e=t.path.canonicalString();t.collectionGroup!==null&&(e+="|cg:"+t.collectionGroup),e+="|f:",e+=t.filters.map(n=>Eo(n)).join(","),e+="|ob:",e+=t.orderBy.map(n=>function(s){return s.field.canonicalString()+s.dir}(n)).join(","),Wr(t.limit)||(e+="|l:",e+=t.limit),t.startAt&&(e+="|lb:",e+=t.startAt.inclusive?"b:":"a:",e+=t.startAt.position.map(n=>Nn(n)).join(",")),t.endAt&&(e+="|ub:",e+=t.endAt.inclusive?"a:":"b:",e+=t.endAt.position.map(n=>Nn(n)).join(",")),t.ue=e}return t.ue}function Hr(r,t){if(r.limit!==t.limit||r.orderBy.length!==t.orderBy.length)return!1;for(let e=0;e<r.orderBy.length;e++)if(!ip(r.orderBy[e],t.orderBy[e]))return!1;if(r.filters.length!==t.filters.length)return!1;for(let e=0;e<r.filters.length;e++)if(!nh(r.filters[e],t.filters[e]))return!1;return r.collectionGroup===t.collectionGroup&&!!r.path.isEqual(t.path)&&!!oc(r.startAt,t.startAt)&&oc(r.endAt,t.endAt)}function Qi(r){return M.isDocumentKey(r.path)&&r.collectionGroup===null&&r.filters.length===0}function Wi(r,t){return r.filters.filter(e=>e instanceof H&&e.field.isEqual(t))}function ac(r,t,e){let n=Li,i=!0;for(const s of Wi(r,t)){let a=Li,u=!0;switch(s.op){case"<":case"<=":a=np(s.value);break;case"==":case"in":case">=":a=s.value;break;case">":a=s.value,u=!1;break;case"!=":case"not-in":a=Li}rc({value:n,inclusive:i},{value:a,inclusive:u})<0&&(n=a,i=u)}if(e!==null){for(let s=0;s<r.orderBy.length;++s)if(r.orderBy[s].field.isEqual(t)){const a=e.position[s];rc({value:n,inclusive:i},{value:a,inclusive:e.inclusive})<0&&(n=a,i=e.inclusive);break}}return{value:n,inclusive:i}}function uc(r,t,e){let n=_e,i=!0;for(const s of Wi(r,t)){let a=_e,u=!0;switch(s.op){case">=":case">":a=rp(s.value),u=!1;break;case"==":case"in":case"<=":a=s.value;break;case"<":a=s.value,u=!1;break;case"!=":case"not-in":a=_e}ic({value:n,inclusive:i},{value:a,inclusive:u})>0&&(n=a,i=u)}if(e!==null){for(let s=0;s<r.orderBy.length;++s)if(r.orderBy[s].field.isEqual(t)){const a=e.position[s];ic({value:n,inclusive:i},{value:a,inclusive:e.inclusive})>0&&(n=a,i=e.inclusive);break}}return{value:n,inclusive:i}}/**
984
984
  * @license
985
985
  * Copyright 2017 Google LLC
986
986
  *
@@ -995,7 +995,7 @@ SPDX-License-Identifier: Apache-2.0
995
995
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
996
996
  * See the License for the specific language governing permissions and
997
997
  * limitations under the License.
998
- */class ie{constructor(t,e=null,n=[],i=[],s=null,a="F",u=null,c=null){this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=i,this.limit=s,this.limitType=a,this.startAt=u,this.endAt=c,this.ce=null,this.le=null,this.he=null,this.startAt,this.endAt}}function ah(r,t,e,n,i,s,a,u){return new ie(r,t,e,n,i,s,a,u)}function Kn(r){return new ie(r)}function cc(r){return r.filters.length===0&&r.limit===null&&r.startAt==null&&r.endAt==null&&(r.explicitOrderBy.length===0||r.explicitOrderBy.length===1&&r.explicitOrderBy[0].field.isKeyField())}function Go(r){return r.collectionGroup!==null}function An(r){const t=k(r);if(t.ce===null){t.ce=[];const e=new Set;for(const s of t.explicitOrderBy)t.ce.push(s),e.add(s.field.canonicalString());const n=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc";(function(a){let u=new et(at.comparator);return a.filters.forEach(c=>{c.getFlattenedFilters().forEach(h=>{h.isInequality()&&(u=u.add(h.field))})}),u})(t).forEach(s=>{e.has(s.canonicalString())||s.isKeyField()||t.ce.push(new zr(s,n))}),e.has(at.keyField().canonicalString())||t.ce.push(new zr(at.keyField(),n))}return t.ce}function kt(r){const t=k(r);return t.le||(t.le=ch(t,An(r))),t.le}function uh(r){const t=k(r);return t.he||(t.he=ch(t,r.explicitOrderBy)),t.he}function ch(r,t){if(r.limitType==="F")return To(r.path,r.collectionGroup,t,r.filters,r.limit,r.startAt,r.endAt);{t=t.map(i=>{const s=i.dir==="desc"?"asc":"desc";return new zr(i.field,s)});const e=r.endAt?new Re(r.endAt.position,r.endAt.inclusive):null,n=r.startAt?new Re(r.startAt.position,r.startAt.inclusive):null;return To(r.path,r.collectionGroup,t,r.filters,r.limit,e,n)}}function vo(r,t){const e=r.filters.concat([t]);return new ie(r.path,r.collectionGroup,r.explicitOrderBy.slice(),e,r.limit,r.limitType,r.startAt,r.endAt)}function Hi(r,t,e){return new ie(r.path,r.collectionGroup,r.explicitOrderBy.slice(),r.filters.slice(),t,e,r.startAt,r.endAt)}function Jr(r,t){return Hr(kt(r),kt(t))&&r.limitType===t.limitType}function lh(r){return`${Ze(kt(r))}|lt:${r.limitType}`}function Tn(r){return`Query(target=${function(e){let n=e.path.canonicalString();return e.collectionGroup!==null&&(n+=" collectionGroup="+e.collectionGroup),e.filters.length>0&&(n+=`, filters: [${e.filters.map(i=>ih(i)).join(", ")}]`),Wr(e.limit)||(n+=", limit: "+e.limit),e.orderBy.length>0&&(n+=`, orderBy: [${e.orderBy.map(i=>function(a){return`${a.field.canonicalString()} (${a.dir})`}(i)).join(", ")}]`),e.startAt&&(n+=", startAt: ",n+=e.startAt.inclusive?"b:":"a:",n+=e.startAt.position.map(i=>xn(i)).join(",")),e.endAt&&(n+=", endAt: ",n+=e.endAt.inclusive?"a:":"b:",n+=e.endAt.position.map(i=>xn(i)).join(",")),`Target(${n})`}(kt(r))}; limitType=${r.limitType})`}function Yr(r,t){return t.isFoundDocument()&&function(n,i){const s=i.key.path;return n.collectionGroup!==null?i.key.hasCollectionId(n.collectionGroup)&&n.path.isPrefixOf(s):M.isDocumentKey(n.path)?n.path.isEqual(s):n.path.isImmediateParentOf(s)}(r,t)&&function(n,i){for(const s of An(n))if(!s.field.isKeyField()&&i.data.field(s.field)===null)return!1;return!0}(r,t)&&function(n,i){for(const s of n.filters)if(!s.matches(i))return!1;return!0}(r,t)&&function(n,i){return!(n.startAt&&!function(a,u,c){const h=sc(a,u,c);return a.inclusive?h<=0:h<0}(n.startAt,An(n),i)||n.endAt&&!function(a,u,c){const h=sc(a,u,c);return a.inclusive?h>=0:h>0}(n.endAt,An(n),i))}(r,t)}function hh(r){return r.collectionGroup||(r.path.length%2==1?r.path.lastSegment():r.path.get(r.path.length-2))}function dh(r){return(t,e)=>{let n=!1;for(const i of An(r)){const s=dp(i,t,e);if(s!==0)return s;n=n||i.field.isKeyField()}return 0}}function dp(r,t,e){const n=r.field.isKeyField()?M.comparator(t.key,e.key):function(s,a,u){const c=a.data.field(s),h=u.data.field(s);return c!==null&&h!==null?Ae(c,h):O()}(r.field,t,e);switch(r.dir){case"asc":return n;case"desc":return-1*n;default:return O()}}/**
998
+ */class ie{constructor(t,e=null,n=[],i=[],s=null,a="F",u=null,c=null){this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=i,this.limit=s,this.limitType=a,this.startAt=u,this.endAt=c,this.ce=null,this.le=null,this.he=null,this.startAt,this.endAt}}function ah(r,t,e,n,i,s,a,u){return new ie(r,t,e,n,i,s,a,u)}function $n(r){return new ie(r)}function cc(r){return r.filters.length===0&&r.limit===null&&r.startAt==null&&r.endAt==null&&(r.explicitOrderBy.length===0||r.explicitOrderBy.length===1&&r.explicitOrderBy[0].field.isKeyField())}function Go(r){return r.collectionGroup!==null}function Rn(r){const t=k(r);if(t.ce===null){t.ce=[];const e=new Set;for(const s of t.explicitOrderBy)t.ce.push(s),e.add(s.field.canonicalString());const n=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc";(function(a){let u=new et(at.comparator);return a.filters.forEach(c=>{c.getFlattenedFilters().forEach(h=>{h.isInequality()&&(u=u.add(h.field))})}),u})(t).forEach(s=>{e.has(s.canonicalString())||s.isKeyField()||t.ce.push(new jr(s,n))}),e.has(at.keyField().canonicalString())||t.ce.push(new jr(at.keyField(),n))}return t.ce}function kt(r){const t=k(r);return t.le||(t.le=ch(t,Rn(r))),t.le}function uh(r){const t=k(r);return t.he||(t.he=ch(t,r.explicitOrderBy)),t.he}function ch(r,t){if(r.limitType==="F")return To(r.path,r.collectionGroup,t,r.filters,r.limit,r.startAt,r.endAt);{t=t.map(i=>{const s=i.dir==="desc"?"asc":"desc";return new jr(i.field,s)});const e=r.endAt?new be(r.endAt.position,r.endAt.inclusive):null,n=r.startAt?new be(r.startAt.position,r.startAt.inclusive):null;return To(r.path,r.collectionGroup,t,r.filters,r.limit,e,n)}}function vo(r,t){const e=r.filters.concat([t]);return new ie(r.path,r.collectionGroup,r.explicitOrderBy.slice(),e,r.limit,r.limitType,r.startAt,r.endAt)}function Hi(r,t,e){return new ie(r.path,r.collectionGroup,r.explicitOrderBy.slice(),r.filters.slice(),t,e,r.startAt,r.endAt)}function Jr(r,t){return Hr(kt(r),kt(t))&&r.limitType===t.limitType}function lh(r){return`${tn(kt(r))}|lt:${r.limitType}`}function vn(r){return`Query(target=${function(e){let n=e.path.canonicalString();return e.collectionGroup!==null&&(n+=" collectionGroup="+e.collectionGroup),e.filters.length>0&&(n+=`, filters: [${e.filters.map(i=>ih(i)).join(", ")}]`),Wr(e.limit)||(n+=", limit: "+e.limit),e.orderBy.length>0&&(n+=`, orderBy: [${e.orderBy.map(i=>function(a){return`${a.field.canonicalString()} (${a.dir})`}(i)).join(", ")}]`),e.startAt&&(n+=", startAt: ",n+=e.startAt.inclusive?"b:":"a:",n+=e.startAt.position.map(i=>Nn(i)).join(",")),e.endAt&&(n+=", endAt: ",n+=e.endAt.inclusive?"a:":"b:",n+=e.endAt.position.map(i=>Nn(i)).join(",")),`Target(${n})`}(kt(r))}; limitType=${r.limitType})`}function Yr(r,t){return t.isFoundDocument()&&function(n,i){const s=i.key.path;return n.collectionGroup!==null?i.key.hasCollectionId(n.collectionGroup)&&n.path.isPrefixOf(s):M.isDocumentKey(n.path)?n.path.isEqual(s):n.path.isImmediateParentOf(s)}(r,t)&&function(n,i){for(const s of Rn(n))if(!s.field.isKeyField()&&i.data.field(s.field)===null)return!1;return!0}(r,t)&&function(n,i){for(const s of n.filters)if(!s.matches(i))return!1;return!0}(r,t)&&function(n,i){return!(n.startAt&&!function(a,u,c){const h=sc(a,u,c);return a.inclusive?h<=0:h<0}(n.startAt,Rn(n),i)||n.endAt&&!function(a,u,c){const h=sc(a,u,c);return a.inclusive?h>=0:h>0}(n.endAt,Rn(n),i))}(r,t)}function hh(r){return r.collectionGroup||(r.path.length%2==1?r.path.lastSegment():r.path.get(r.path.length-2))}function dh(r){return(t,e)=>{let n=!1;for(const i of Rn(r)){const s=dp(i,t,e);if(s!==0)return s;n=n||i.field.isKeyField()}return 0}}function dp(r,t,e){const n=r.field.isKeyField()?M.comparator(t.key,e.key):function(s,a,u){const c=a.data.field(s),h=u.data.field(s);return c!==null&&h!==null?Re(c,h):O()}(r.field,t,e);switch(r.dir){case"asc":return n;case"desc":return-1*n;default:return O()}}/**
999
999
  * @license
1000
1000
  * Copyright 2017 Google LLC
1001
1001
  *
@@ -1010,7 +1010,7 @@ SPDX-License-Identifier: Apache-2.0
1010
1010
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1011
1011
  * See the License for the specific language governing permissions and
1012
1012
  * limitations under the License.
1013
- */class se{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.innerSize=0}get(t){const e=this.mapKeyFn(t),n=this.inner[e];if(n!==void 0){for(const[i,s]of n)if(this.equalsFn(i,t))return s}}has(t){return this.get(t)!==void 0}set(t,e){const n=this.mapKeyFn(t),i=this.inner[n];if(i===void 0)return this.inner[n]=[[t,e]],void this.innerSize++;for(let s=0;s<i.length;s++)if(this.equalsFn(i[s][0],t))return void(i[s]=[t,e]);i.push([t,e]),this.innerSize++}delete(t){const e=this.mapKeyFn(t),n=this.inner[e];if(n===void 0)return!1;for(let i=0;i<n.length;i++)if(this.equalsFn(n[i][0],t))return n.length===1?delete this.inner[e]:n.splice(i,1),this.innerSize--,!0;return!1}forEach(t){xe(this.inner,(e,n)=>{for(const[i,s]of n)t(i,s)})}isEmpty(){return Hl(this.inner)}size(){return this.innerSize}}/**
1013
+ */class se{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.innerSize=0}get(t){const e=this.mapKeyFn(t),n=this.inner[e];if(n!==void 0){for(const[i,s]of n)if(this.equalsFn(i,t))return s}}has(t){return this.get(t)!==void 0}set(t,e){const n=this.mapKeyFn(t),i=this.inner[n];if(i===void 0)return this.inner[n]=[[t,e]],void this.innerSize++;for(let s=0;s<i.length;s++)if(this.equalsFn(i[s][0],t))return void(i[s]=[t,e]);i.push([t,e]),this.innerSize++}delete(t){const e=this.mapKeyFn(t),n=this.inner[e];if(n===void 0)return!1;for(let i=0;i<n.length;i++)if(this.equalsFn(n[i][0],t))return n.length===1?delete this.inner[e]:n.splice(i,1),this.innerSize--,!0;return!1}forEach(t){Ne(this.inner,(e,n)=>{for(const[i,s]of n)t(i,s)})}isEmpty(){return Hl(this.inner)}size(){return this.innerSize}}/**
1014
1014
  * @license
1015
1015
  * Copyright 2017 Google LLC
1016
1016
  *
@@ -1025,7 +1025,7 @@ SPDX-License-Identifier: Apache-2.0
1025
1025
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1026
1026
  * See the License for the specific language governing permissions and
1027
1027
  * limitations under the License.
1028
- */const fp=new it(M.comparator);function Bt(){return fp}const fh=new it(M.comparator);function Rr(...r){let t=fh;for(const e of r)t=t.insert(e.key,e);return t}function mh(r){let t=fh;return r.forEach((e,n)=>t=t.insert(e,n.overlayedDocument)),t}function Qt(){return Cr()}function gh(){return Cr()}function Cr(){return new se(r=>r.toString(),(r,t)=>r.isEqual(t))}const mp=new it(M.comparator),gp=new et(M.comparator);function G(...r){let t=gp;for(const e of r)t=t.add(e);return t}const pp=new et(j);function Ko(){return pp}/**
1028
+ */const fp=new it(M.comparator);function Bt(){return fp}const fh=new it(M.comparator);function br(...r){let t=fh;for(const e of r)t=t.insert(e.key,e);return t}function mh(r){let t=fh;return r.forEach((e,n)=>t=t.insert(e,n.overlayedDocument)),t}function Qt(){return Dr()}function gh(){return Dr()}function Dr(){return new se(r=>r.toString(),(r,t)=>r.isEqual(t))}const mp=new it(M.comparator),gp=new et(M.comparator);function G(...r){let t=gp;for(const e of r)t=t.add(e);return t}const pp=new et(j);function Ko(){return pp}/**
1029
1029
  * @license
1030
1030
  * Copyright 2020 Google LLC
1031
1031
  *
@@ -1040,7 +1040,7 @@ SPDX-License-Identifier: Apache-2.0
1040
1040
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1041
1041
  * See the License for the specific language governing permissions and
1042
1042
  * limitations under the License.
1043
- */function $o(r,t){if(r.useProto3Json){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:Lr(t)?"-0":t}}function ph(r){return{integerValue:""+r}}function _h(r,t){return jl(t)?ph(t):$o(r,t)}/**
1043
+ */function $o(r,t){if(r.useProto3Json){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:Br(t)?"-0":t}}function ph(r){return{integerValue:""+r}}function _h(r,t){return jl(t)?ph(t):$o(r,t)}/**
1044
1044
  * @license
1045
1045
  * Copyright 2018 Google LLC
1046
1046
  *
@@ -1055,7 +1055,7 @@ SPDX-License-Identifier: Apache-2.0
1055
1055
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1056
1056
  * See the License for the specific language governing permissions and
1057
1057
  * limitations under the License.
1058
- */class hs{constructor(){this._=void 0}}function _p(r,t,e){return r instanceof kn?function(i,s){const a={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:i.seconds,nanos:i.nanoseconds}}}};return s&&us(s)&&(s=cs(s)),s&&(a.fields.__previous_value__=s),{mapValue:a}}(e,t):r instanceof tn?Ih(r,t):r instanceof en?Eh(r,t):function(i,s){const a=yh(i,s),u=lc(a)+lc(i.Pe);return yo(a)&&yo(i.Pe)?ph(u):$o(i.serializer,u)}(r,t)}function yp(r,t,e){return r instanceof tn?Ih(r,t):r instanceof en?Eh(r,t):e}function yh(r,t){return r instanceof Fn?function(n){return yo(n)||function(s){return!!s&&"doubleValue"in s}(n)}(t)?t:{integerValue:0}:null}class kn extends hs{}class tn extends hs{constructor(t){super(),this.elements=t}}function Ih(r,t){const e=Th(t);for(const n of r.elements)e.some(i=>Jt(i,n))||e.push(n);return{arrayValue:{values:e}}}class en extends hs{constructor(t){super(),this.elements=t}}function Eh(r,t){let e=Th(t);for(const n of r.elements)e=e.filter(i=>!Jt(i,n));return{arrayValue:{values:e}}}class Fn extends hs{constructor(t,e){super(),this.serializer=t,this.Pe=e}}function lc(r){return ut(r.integerValue||r.doubleValue)}function Th(r){return qr(r)&&r.arrayValue.values?r.arrayValue.values.slice():[]}/**
1058
+ */class hs{constructor(){this._=void 0}}function _p(r,t,e){return r instanceof Fn?function(i,s){const a={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:i.seconds,nanos:i.nanoseconds}}}};return s&&us(s)&&(s=cs(s)),s&&(a.fields.__previous_value__=s),{mapValue:a}}(e,t):r instanceof en?Ih(r,t):r instanceof nn?Eh(r,t):function(i,s){const a=yh(i,s),u=lc(a)+lc(i.Pe);return yo(a)&&yo(i.Pe)?ph(u):$o(i.serializer,u)}(r,t)}function yp(r,t,e){return r instanceof en?Ih(r,t):r instanceof nn?Eh(r,t):e}function yh(r,t){return r instanceof Mn?function(n){return yo(n)||function(s){return!!s&&"doubleValue"in s}(n)}(t)?t:{integerValue:0}:null}class Fn extends hs{}class en extends hs{constructor(t){super(),this.elements=t}}function Ih(r,t){const e=Th(t);for(const n of r.elements)e.some(i=>Jt(i,n))||e.push(n);return{arrayValue:{values:e}}}class nn extends hs{constructor(t){super(),this.elements=t}}function Eh(r,t){let e=Th(t);for(const n of r.elements)e=e.filter(i=>!Jt(i,n));return{arrayValue:{values:e}}}class Mn extends hs{constructor(t,e){super(),this.serializer=t,this.Pe=e}}function lc(r){return ut(r.integerValue||r.doubleValue)}function Th(r){return zr(r)&&r.arrayValue.values?r.arrayValue.values.slice():[]}/**
1059
1059
  * @license
1060
1060
  * Copyright 2017 Google LLC
1061
1061
  *
@@ -1070,7 +1070,7 @@ SPDX-License-Identifier: Apache-2.0
1070
1070
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1071
1071
  * See the License for the specific language governing permissions and
1072
1072
  * limitations under the License.
1073
- */class Xr{constructor(t,e){this.field=t,this.transform=e}}function Ip(r,t){return r.field.isEqual(t.field)&&function(n,i){return n instanceof tn&&i instanceof tn||n instanceof en&&i instanceof en?Vn(n.elements,i.elements,Jt):n instanceof Fn&&i instanceof Fn?Jt(n.Pe,i.Pe):n instanceof kn&&i instanceof kn}(r.transform,t.transform)}class Ep{constructor(t,e){this.version=t,this.transformResults=e}}class ct{constructor(t,e){this.updateTime=t,this.exists=e}static none(){return new ct}static exists(t){return new ct(void 0,t)}static updateTime(t){return new ct(t)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)}}function qi(r,t){return r.updateTime!==void 0?t.isFoundDocument()&&t.version.isEqual(r.updateTime):r.exists===void 0||r.exists===t.isFoundDocument()}class ds{}function vh(r,t){if(!r.hasLocalMutations||t&&t.fields.length===0)return null;if(t===null)return r.isNoDocument()?new Qn(r.key,ct.none()):new $n(r.key,r.data,ct.none());{const e=r.data,n=bt.empty();let i=new et(at.comparator);for(let s of t.fields)if(!i.has(s)){let a=e.field(s);a===null&&s.length>1&&(s=s.popLast(),a=e.field(s)),a===null?n.delete(s):n.set(s,a),i=i.add(s)}return new oe(r.key,n,new Lt(i.toArray()),ct.none())}}function Tp(r,t,e){r instanceof $n?function(i,s,a){const u=i.value.clone(),c=dc(i.fieldTransforms,s,a.transformResults);u.setAll(c),s.convertToFoundDocument(a.version,u).setHasCommittedMutations()}(r,t,e):r instanceof oe?function(i,s,a){if(!qi(i.precondition,s))return void s.convertToUnknownDocument(a.version);const u=dc(i.fieldTransforms,s,a.transformResults),c=s.data;c.setAll(wh(i)),c.setAll(u),s.convertToFoundDocument(a.version,c).setHasCommittedMutations()}(r,t,e):function(i,s,a){s.convertToNoDocument(a.version).setHasCommittedMutations()}(0,t,e)}function Dr(r,t,e,n){return r instanceof $n?function(s,a,u,c){if(!qi(s.precondition,a))return u;const h=s.value.clone(),f=fc(s.fieldTransforms,c,a);return h.setAll(f),a.convertToFoundDocument(a.version,h).setHasLocalMutations(),null}(r,t,e,n):r instanceof oe?function(s,a,u,c){if(!qi(s.precondition,a))return u;const h=fc(s.fieldTransforms,c,a),f=a.data;return f.setAll(wh(s)),f.setAll(h),a.convertToFoundDocument(a.version,f).setHasLocalMutations(),u===null?null:u.unionWith(s.fieldMask.fields).unionWith(s.fieldTransforms.map(g=>g.field))}(r,t,e,n):function(s,a,u){return qi(s.precondition,a)?(a.convertToNoDocument(a.version).setHasLocalMutations(),null):u}(r,t,e)}function vp(r,t){let e=null;for(const n of r.fieldTransforms){const i=t.data.field(n.field),s=yh(n.transform,i||null);s!=null&&(e===null&&(e=bt.empty()),e.set(n.field,s))}return e||null}function hc(r,t){return r.type===t.type&&!!r.key.isEqual(t.key)&&!!r.precondition.isEqual(t.precondition)&&!!function(n,i){return n===void 0&&i===void 0||!(!n||!i)&&Vn(n,i,(s,a)=>Ip(s,a))}(r.fieldTransforms,t.fieldTransforms)&&(r.type===0?r.value.isEqual(t.value):r.type!==1||r.data.isEqual(t.data)&&r.fieldMask.isEqual(t.fieldMask))}class $n extends ds{constructor(t,e,n,i=[]){super(),this.key=t,this.value=e,this.precondition=n,this.fieldTransforms=i,this.type=0}getFieldMask(){return null}}class oe extends ds{constructor(t,e,n,i,s=[]){super(),this.key=t,this.data=e,this.fieldMask=n,this.precondition=i,this.fieldTransforms=s,this.type=1}getFieldMask(){return this.fieldMask}}function wh(r){const t=new Map;return r.fieldMask.fields.forEach(e=>{if(!e.isEmpty()){const n=r.data.field(e);t.set(e,n)}}),t}function dc(r,t,e){const n=new Map;L(r.length===e.length);for(let i=0;i<e.length;i++){const s=r[i],a=s.transform,u=t.data.field(s.field);n.set(s.field,yp(a,u,e[i]))}return n}function fc(r,t,e){const n=new Map;for(const i of r){const s=i.transform,a=e.data.field(i.field);n.set(i.field,_p(s,a,t))}return n}class Qn extends ds{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class Qo extends ds{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}/**
1073
+ */class Xr{constructor(t,e){this.field=t,this.transform=e}}function Ip(r,t){return r.field.isEqual(t.field)&&function(n,i){return n instanceof en&&i instanceof en||n instanceof nn&&i instanceof nn?Cn(n.elements,i.elements,Jt):n instanceof Mn&&i instanceof Mn?Jt(n.Pe,i.Pe):n instanceof Fn&&i instanceof Fn}(r.transform,t.transform)}class Ep{constructor(t,e){this.version=t,this.transformResults=e}}class ct{constructor(t,e){this.updateTime=t,this.exists=e}static none(){return new ct}static exists(t){return new ct(void 0,t)}static updateTime(t){return new ct(t)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)}}function qi(r,t){return r.updateTime!==void 0?t.isFoundDocument()&&t.version.isEqual(r.updateTime):r.exists===void 0||r.exists===t.isFoundDocument()}class ds{}function vh(r,t){if(!r.hasLocalMutations||t&&t.fields.length===0)return null;if(t===null)return r.isNoDocument()?new Wn(r.key,ct.none()):new Qn(r.key,r.data,ct.none());{const e=r.data,n=bt.empty();let i=new et(at.comparator);for(let s of t.fields)if(!i.has(s)){let a=e.field(s);a===null&&s.length>1&&(s=s.popLast(),a=e.field(s)),a===null?n.delete(s):n.set(s,a),i=i.add(s)}return new oe(r.key,n,new Lt(i.toArray()),ct.none())}}function Tp(r,t,e){r instanceof Qn?function(i,s,a){const u=i.value.clone(),c=dc(i.fieldTransforms,s,a.transformResults);u.setAll(c),s.convertToFoundDocument(a.version,u).setHasCommittedMutations()}(r,t,e):r instanceof oe?function(i,s,a){if(!qi(i.precondition,s))return void s.convertToUnknownDocument(a.version);const u=dc(i.fieldTransforms,s,a.transformResults),c=s.data;c.setAll(wh(i)),c.setAll(u),s.convertToFoundDocument(a.version,c).setHasCommittedMutations()}(r,t,e):function(i,s,a){s.convertToNoDocument(a.version).setHasCommittedMutations()}(0,t,e)}function xr(r,t,e,n){return r instanceof Qn?function(s,a,u,c){if(!qi(s.precondition,a))return u;const h=s.value.clone(),f=fc(s.fieldTransforms,c,a);return h.setAll(f),a.convertToFoundDocument(a.version,h).setHasLocalMutations(),null}(r,t,e,n):r instanceof oe?function(s,a,u,c){if(!qi(s.precondition,a))return u;const h=fc(s.fieldTransforms,c,a),f=a.data;return f.setAll(wh(s)),f.setAll(h),a.convertToFoundDocument(a.version,f).setHasLocalMutations(),u===null?null:u.unionWith(s.fieldMask.fields).unionWith(s.fieldTransforms.map(g=>g.field))}(r,t,e,n):function(s,a,u){return qi(s.precondition,a)?(a.convertToNoDocument(a.version).setHasLocalMutations(),null):u}(r,t,e)}function vp(r,t){let e=null;for(const n of r.fieldTransforms){const i=t.data.field(n.field),s=yh(n.transform,i||null);s!=null&&(e===null&&(e=bt.empty()),e.set(n.field,s))}return e||null}function hc(r,t){return r.type===t.type&&!!r.key.isEqual(t.key)&&!!r.precondition.isEqual(t.precondition)&&!!function(n,i){return n===void 0&&i===void 0||!(!n||!i)&&Cn(n,i,(s,a)=>Ip(s,a))}(r.fieldTransforms,t.fieldTransforms)&&(r.type===0?r.value.isEqual(t.value):r.type!==1||r.data.isEqual(t.data)&&r.fieldMask.isEqual(t.fieldMask))}class Qn extends ds{constructor(t,e,n,i=[]){super(),this.key=t,this.value=e,this.precondition=n,this.fieldTransforms=i,this.type=0}getFieldMask(){return null}}class oe extends ds{constructor(t,e,n,i,s=[]){super(),this.key=t,this.data=e,this.fieldMask=n,this.precondition=i,this.fieldTransforms=s,this.type=1}getFieldMask(){return this.fieldMask}}function wh(r){const t=new Map;return r.fieldMask.fields.forEach(e=>{if(!e.isEmpty()){const n=r.data.field(e);t.set(e,n)}}),t}function dc(r,t,e){const n=new Map;L(r.length===e.length);for(let i=0;i<e.length;i++){const s=r[i],a=s.transform,u=t.data.field(s.field);n.set(s.field,yp(a,u,e[i]))}return n}function fc(r,t,e){const n=new Map;for(const i of r){const s=i.transform,a=e.data.field(i.field);n.set(i.field,_p(s,a,t))}return n}class Wn extends ds{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class Qo extends ds{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}/**
1074
1074
  * @license
1075
1075
  * Copyright 2017 Google LLC
1076
1076
  *
@@ -1085,7 +1085,7 @@ SPDX-License-Identifier: Apache-2.0
1085
1085
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1086
1086
  * See the License for the specific language governing permissions and
1087
1087
  * limitations under the License.
1088
- */class Wo{constructor(t,e,n,i){this.batchId=t,this.localWriteTime=e,this.baseMutations=n,this.mutations=i}applyToRemoteDocument(t,e){const n=e.mutationResults;for(let i=0;i<this.mutations.length;i++){const s=this.mutations[i];s.key.isEqual(t.key)&&Tp(s,t,n[i])}}applyToLocalView(t,e){for(const n of this.baseMutations)n.key.isEqual(t.key)&&(e=Dr(n,t,e,this.localWriteTime));for(const n of this.mutations)n.key.isEqual(t.key)&&(e=Dr(n,t,e,this.localWriteTime));return e}applyToLocalDocumentSet(t,e){const n=gh();return this.mutations.forEach(i=>{const s=t.get(i.key),a=s.overlayedDocument;let u=this.applyToLocalView(a,s.mutatedFields);u=e.has(i.key)?null:u;const c=vh(a,u);c!==null&&n.set(i.key,c),a.isValidDocument()||a.convertToNoDocument(U.min())}),n}keys(){return this.mutations.reduce((t,e)=>t.add(e.key),G())}isEqual(t){return this.batchId===t.batchId&&Vn(this.mutations,t.mutations,(e,n)=>hc(e,n))&&Vn(this.baseMutations,t.baseMutations,(e,n)=>hc(e,n))}}class Ho{constructor(t,e,n,i){this.batch=t,this.commitVersion=e,this.mutationResults=n,this.docVersions=i}static from(t,e,n){L(t.mutations.length===n.length);let i=function(){return mp}();const s=t.mutations;for(let a=0;a<s.length;a++)i=i.insert(s[a].key,n[a].version);return new Ho(t,e,n,i)}}/**
1088
+ */class Wo{constructor(t,e,n,i){this.batchId=t,this.localWriteTime=e,this.baseMutations=n,this.mutations=i}applyToRemoteDocument(t,e){const n=e.mutationResults;for(let i=0;i<this.mutations.length;i++){const s=this.mutations[i];s.key.isEqual(t.key)&&Tp(s,t,n[i])}}applyToLocalView(t,e){for(const n of this.baseMutations)n.key.isEqual(t.key)&&(e=xr(n,t,e,this.localWriteTime));for(const n of this.mutations)n.key.isEqual(t.key)&&(e=xr(n,t,e,this.localWriteTime));return e}applyToLocalDocumentSet(t,e){const n=gh();return this.mutations.forEach(i=>{const s=t.get(i.key),a=s.overlayedDocument;let u=this.applyToLocalView(a,s.mutatedFields);u=e.has(i.key)?null:u;const c=vh(a,u);c!==null&&n.set(i.key,c),a.isValidDocument()||a.convertToNoDocument(U.min())}),n}keys(){return this.mutations.reduce((t,e)=>t.add(e.key),G())}isEqual(t){return this.batchId===t.batchId&&Cn(this.mutations,t.mutations,(e,n)=>hc(e,n))&&Cn(this.baseMutations,t.baseMutations,(e,n)=>hc(e,n))}}class Ho{constructor(t,e,n,i){this.batch=t,this.commitVersion=e,this.mutationResults=n,this.docVersions=i}static from(t,e,n){L(t.mutations.length===n.length);let i=function(){return mp}();const s=t.mutations;for(let a=0;a<s.length;a++)i=i.insert(s[a].key,n[a].version);return new Ho(t,e,n,i)}}/**
1089
1089
  * @license
1090
1090
  * Copyright 2022 Google LLC
1091
1091
  *
@@ -1193,7 +1193,7 @@ SPDX-License-Identifier: Apache-2.0
1193
1193
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1194
1194
  * See the License for the specific language governing permissions and
1195
1195
  * limitations under the License.
1196
- */const Ap=new He([4294967295,4294967295],0);function mc(r){const t=Ph().encode(r),e=new Sl;return e.update(t),new Uint8Array(e.digest())}function gc(r){const t=new DataView(r.buffer),e=t.getUint32(0,!0),n=t.getUint32(4,!0),i=t.getUint32(8,!0),s=t.getUint32(12,!0);return[new He([e,n],0),new He([i,s],0)]}class Yo{constructor(t,e,n){if(this.bitmap=t,this.padding=e,this.hashCount=n,e<0||e>=8)throw new br(`Invalid padding: ${e}`);if(n<0)throw new br(`Invalid hash count: ${n}`);if(t.length>0&&this.hashCount===0)throw new br(`Invalid hash count: ${n}`);if(t.length===0&&e!==0)throw new br(`Invalid padding when bitmap length is 0: ${e}`);this.Ie=8*t.length-e,this.Te=He.fromNumber(this.Ie)}Ee(t,e,n){let i=t.add(e.multiply(He.fromNumber(n)));return i.compare(Ap)===1&&(i=new He([i.getBits(0),i.getBits(1)],0)),i.modulo(this.Te).toNumber()}de(t){return(this.bitmap[Math.floor(t/8)]&1<<t%8)!=0}mightContain(t){if(this.Ie===0)return!1;const e=mc(t),[n,i]=gc(e);for(let s=0;s<this.hashCount;s++){const a=this.Ee(n,i,s);if(!this.de(a))return!1}return!0}static create(t,e,n){const i=t%8==0?0:8-t%8,s=new Uint8Array(Math.ceil(t/8)),a=new Yo(s,i,e);return n.forEach(u=>a.insert(u)),a}insert(t){if(this.Ie===0)return;const e=mc(t),[n,i]=gc(e);for(let s=0;s<this.hashCount;s++){const a=this.Ee(n,i,s);this.Ae(a)}}Ae(t){const e=Math.floor(t/8),n=t%8;this.bitmap[e]|=1<<n}}class br extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}/**
1196
+ */const Ap=new Je([4294967295,4294967295],0);function mc(r){const t=Ph().encode(r),e=new Sl;return e.update(t),new Uint8Array(e.digest())}function gc(r){const t=new DataView(r.buffer),e=t.getUint32(0,!0),n=t.getUint32(4,!0),i=t.getUint32(8,!0),s=t.getUint32(12,!0);return[new Je([e,n],0),new Je([i,s],0)]}class Yo{constructor(t,e,n){if(this.bitmap=t,this.padding=e,this.hashCount=n,e<0||e>=8)throw new Pr(`Invalid padding: ${e}`);if(n<0)throw new Pr(`Invalid hash count: ${n}`);if(t.length>0&&this.hashCount===0)throw new Pr(`Invalid hash count: ${n}`);if(t.length===0&&e!==0)throw new Pr(`Invalid padding when bitmap length is 0: ${e}`);this.Ie=8*t.length-e,this.Te=Je.fromNumber(this.Ie)}Ee(t,e,n){let i=t.add(e.multiply(Je.fromNumber(n)));return i.compare(Ap)===1&&(i=new Je([i.getBits(0),i.getBits(1)],0)),i.modulo(this.Te).toNumber()}de(t){return(this.bitmap[Math.floor(t/8)]&1<<t%8)!=0}mightContain(t){if(this.Ie===0)return!1;const e=mc(t),[n,i]=gc(e);for(let s=0;s<this.hashCount;s++){const a=this.Ee(n,i,s);if(!this.de(a))return!1}return!0}static create(t,e,n){const i=t%8==0?0:8-t%8,s=new Uint8Array(Math.ceil(t/8)),a=new Yo(s,i,e);return n.forEach(u=>a.insert(u)),a}insert(t){if(this.Ie===0)return;const e=mc(t),[n,i]=gc(e);for(let s=0;s<this.hashCount;s++){const a=this.Ee(n,i,s);this.Ae(a)}}Ae(t){const e=Math.floor(t/8),n=t%8;this.bitmap[e]|=1<<n}}class Pr extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}/**
1197
1197
  * @license
1198
1198
  * Copyright 2017 Google LLC
1199
1199
  *
@@ -1223,7 +1223,7 @@ SPDX-License-Identifier: Apache-2.0
1223
1223
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1224
1224
  * See the License for the specific language governing permissions and
1225
1225
  * limitations under the License.
1226
- */class zi{constructor(t,e,n,i){this.Re=t,this.removedTargetIds=e,this.key=n,this.Ve=i}}class Sh{constructor(t,e){this.targetId=t,this.me=e}}class Vh{constructor(t,e,n=dt.EMPTY_BYTE_STRING,i=null){this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=i}}class pc{constructor(){this.fe=0,this.ge=yc(),this.pe=dt.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(t){t.approximateByteSize()>0&&(this.we=!0,this.pe=t)}ve(){let t=G(),e=G(),n=G();return this.ge.forEach((i,s)=>{switch(s){case 0:t=t.add(i);break;case 2:e=e.add(i);break;case 1:n=n.add(i);break;default:O()}}),new ti(this.pe,this.ye,t,e,n)}Ce(){this.we=!1,this.ge=yc()}Fe(t,e){this.we=!0,this.ge=this.ge.insert(t,e)}Me(t){this.we=!0,this.ge=this.ge.remove(t)}xe(){this.fe+=1}Oe(){this.fe-=1,L(this.fe>=0)}Ne(){this.we=!0,this.ye=!0}}class Rp{constructor(t){this.Le=t,this.Be=new Map,this.ke=Bt(),this.qe=_c(),this.Qe=new it(j)}Ke(t){for(const e of t.Re)t.Ve&&t.Ve.isFoundDocument()?this.$e(e,t.Ve):this.Ue(e,t.key,t.Ve);for(const e of t.removedTargetIds)this.Ue(e,t.key,t.Ve)}We(t){this.forEachTarget(t,e=>{const n=this.Ge(e);switch(t.state){case 0:this.ze(e)&&n.De(t.resumeToken);break;case 1:n.Oe(),n.Se||n.Ce(),n.De(t.resumeToken);break;case 2:n.Oe(),n.Se||this.removeTarget(e);break;case 3:this.ze(e)&&(n.Ne(),n.De(t.resumeToken));break;case 4:this.ze(e)&&(this.je(e),n.De(t.resumeToken));break;default:O()}})}forEachTarget(t,e){t.targetIds.length>0?t.targetIds.forEach(e):this.Be.forEach((n,i)=>{this.ze(i)&&e(i)})}He(t){const e=t.targetId,n=t.me.count,i=this.Je(e);if(i){const s=i.target;if(Qi(s))if(n===0){const a=new M(s.path);this.Ue(e,a,ot.newNoDocument(a,U.min()))}else L(n===1);else{const a=this.Ye(e);if(a!==n){const u=this.Ze(t),c=u?this.Xe(u,t,a):1;if(c!==0){this.je(e);const h=c===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Qe=this.Qe.insert(e,h)}Ji==null||Ji.et(function(f,g,_,R,C){var N,V,q,z,B,$;const Z={localCacheCount:f,existenceFilterCount:g.count,databaseId:_.database,projectId:_.projectId},K=g.unchangedNames;return K&&(Z.bloomFilter={applied:C===0,hashCount:(N=K==null?void 0:K.hashCount)!==null&&N!==void 0?N:0,bitmapLength:(z=(q=(V=K==null?void 0:K.bits)===null||V===void 0?void 0:V.bitmap)===null||q===void 0?void 0:q.length)!==null&&z!==void 0?z:0,padding:($=(B=K==null?void 0:K.bits)===null||B===void 0?void 0:B.padding)!==null&&$!==void 0?$:0,mightContain:E=>{var p;return(p=R==null?void 0:R.mightContain(E))!==null&&p!==void 0&&p}}),Z}(a,t.me,this.Le.tt(),u,c))}}}}Ze(t){const e=t.me.unchangedNames;if(!e||!e.bits)return null;const{bits:{bitmap:n="",padding:i=0},hashCount:s=0}=e;let a,u;try{a=re(n).toUint8Array()}catch(c){if(c instanceof Jl)return qt("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{u=new Yo(a,i,s)}catch(c){return qt(c instanceof br?"BloomFilter error: ":"Applying bloom filter failed: ",c),null}return u.Ie===0?null:u}Xe(t,e,n){return e.me.count===n-this.nt(t,e.targetId)?0:2}nt(t,e){const n=this.Le.getRemoteKeysForTarget(e);let i=0;return n.forEach(s=>{const a=this.Le.tt(),u=`projects/${a.projectId}/databases/${a.database}/documents/${s.path.canonicalString()}`;t.mightContain(u)||(this.Ue(e,s,null),i++)}),i}rt(t){const e=new Map;this.Be.forEach((s,a)=>{const u=this.Je(a);if(u){if(s.current&&Qi(u.target)){const c=new M(u.target.path);this.ke.get(c)!==null||this.it(a,c)||this.Ue(a,c,ot.newNoDocument(c,t))}s.be&&(e.set(a,s.ve()),s.Ce())}});let n=G();this.qe.forEach((s,a)=>{let u=!0;a.forEachWhile(c=>{const h=this.Je(c);return!h||h.purpose==="TargetPurposeLimboResolution"||(u=!1,!1)}),u&&(n=n.add(s))}),this.ke.forEach((s,a)=>a.setReadTime(t));const i=new Zr(t,e,this.Qe,this.ke,n);return this.ke=Bt(),this.qe=_c(),this.Qe=new it(j),i}$e(t,e){if(!this.ze(t))return;const n=this.it(t,e.key)?2:0;this.Ge(t).Fe(e.key,n),this.ke=this.ke.insert(e.key,e),this.qe=this.qe.insert(e.key,this.st(e.key).add(t))}Ue(t,e,n){if(!this.ze(t))return;const i=this.Ge(t);this.it(t,e)?i.Fe(e,1):i.Me(e),this.qe=this.qe.insert(e,this.st(e).delete(t)),n&&(this.ke=this.ke.insert(e,n))}removeTarget(t){this.Be.delete(t)}Ye(t){const e=this.Ge(t).ve();return this.Le.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size}xe(t){this.Ge(t).xe()}Ge(t){let e=this.Be.get(t);return e||(e=new pc,this.Be.set(t,e)),e}st(t){let e=this.qe.get(t);return e||(e=new et(j),this.qe=this.qe.insert(t,e)),e}ze(t){const e=this.Je(t)!==null;return e||x("WatchChangeAggregator","Detected inactive target",t),e}Je(t){const e=this.Be.get(t);return e&&e.Se?null:this.Le.ot(t)}je(t){this.Be.set(t,new pc),this.Le.getRemoteKeysForTarget(t).forEach(e=>{this.Ue(t,e,null)})}it(t,e){return this.Le.getRemoteKeysForTarget(t).has(e)}}function _c(){return new it(M.comparator)}function yc(){return new it(M.comparator)}const bp={asc:"ASCENDING",desc:"DESCENDING"},Pp={"<":"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"},Sp={and:"AND",or:"OR"};class Vp{constructor(t,e){this.databaseId=t,this.useProto3Json=e}}function wo(r,t){return r.useProto3Json||Wr(t)?t:{value:t}}function Mn(r,t){return r.useProto3Json?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function Ch(r,t){return r.useProto3Json?t.toBase64():t.toUint8Array()}function Cp(r,t){return Mn(r,t.toTimestamp())}function pt(r){return L(!!r),U.fromTimestamp(function(e){const n=ne(e);return new lt(n.seconds,n.nanos)}(r))}function Xo(r,t){return Ao(r,t).canonicalString()}function Ao(r,t){const e=function(i){return new W(["projects",i.projectId,"databases",i.database])}(r).child("documents");return t===void 0?e:e.child(t)}function Dh(r){const t=W.fromString(r);return L(qh(t)),t}function jr(r,t){return Xo(r.databaseId,t.path)}function Ht(r,t){const e=Dh(t);if(e.get(1)!==r.databaseId.projectId)throw new D(P.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+e.get(1)+" vs "+r.databaseId.projectId);if(e.get(3)!==r.databaseId.database)throw new D(P.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+e.get(3)+" vs "+r.databaseId.database);return new M(kh(e))}function xh(r,t){return Xo(r.databaseId,t)}function Nh(r){const t=Dh(r);return t.length===4?W.emptyPath():kh(t)}function Ro(r){return new W(["projects",r.databaseId.projectId,"databases",r.databaseId.database]).canonicalString()}function kh(r){return L(r.length>4&&r.get(4)==="documents"),r.popFirst(5)}function Ic(r,t,e){return{name:jr(r,t),fields:e.value.mapValue.fields}}function Fh(r,t,e){const n=Ht(r,t.name),i=pt(t.updateTime),s=t.createTime?pt(t.createTime):U.min(),a=new bt({mapValue:{fields:t.fields}}),u=ot.newFoundDocument(n,i,s,a);return e&&u.setHasCommittedMutations(),e?u.setHasCommittedMutations():u}function Dp(r,t){return"found"in t?function(n,i){L(!!i.found),i.found.name,i.found.updateTime;const s=Ht(n,i.found.name),a=pt(i.found.updateTime),u=i.found.createTime?pt(i.found.createTime):U.min(),c=new bt({mapValue:{fields:i.found.fields}});return ot.newFoundDocument(s,a,u,c)}(r,t):"missing"in t?function(n,i){L(!!i.missing),L(!!i.readTime);const s=Ht(n,i.missing),a=pt(i.readTime);return ot.newNoDocument(s,a)}(r,t):O()}function xp(r,t){let e;if("targetChange"in t){t.targetChange;const n=function(h){return h==="NO_CHANGE"?0:h==="ADD"?1:h==="REMOVE"?2:h==="CURRENT"?3:h==="RESET"?4:O()}(t.targetChange.targetChangeType||"NO_CHANGE"),i=t.targetChange.targetIds||[],s=function(h,f){return h.useProto3Json?(L(f===void 0||typeof f=="string"),dt.fromBase64String(f||"")):(L(f===void 0||f instanceof Buffer||f instanceof Uint8Array),dt.fromUint8Array(f||new Uint8Array))}(r,t.targetChange.resumeToken),a=t.targetChange.cause,u=a&&function(h){const f=h.code===void 0?P.UNKNOWN:bh(h.code);return new D(f,h.message||"")}(a);e=new Vh(n,i,s,u||null)}else if("documentChange"in t){t.documentChange;const n=t.documentChange;n.document,n.document.name,n.document.updateTime;const i=Ht(r,n.document.name),s=pt(n.document.updateTime),a=n.document.createTime?pt(n.document.createTime):U.min(),u=new bt({mapValue:{fields:n.document.fields}}),c=ot.newFoundDocument(i,s,a,u),h=n.targetIds||[],f=n.removedTargetIds||[];e=new zi(h,f,c.key,c)}else if("documentDelete"in t){t.documentDelete;const n=t.documentDelete;n.document;const i=Ht(r,n.document),s=n.readTime?pt(n.readTime):U.min(),a=ot.newNoDocument(i,s),u=n.removedTargetIds||[];e=new zi([],u,a.key,a)}else if("documentRemove"in t){t.documentRemove;const n=t.documentRemove;n.document;const i=Ht(r,n.document),s=n.removedTargetIds||[];e=new zi([],s,i,null)}else{if(!("filter"in t))return O();{t.filter;const n=t.filter;n.targetId;const{count:i=0,unchangedNames:s}=n,a=new wp(i,s),u=n.targetId;e=new Sh(u,a)}}return e}function Gr(r,t){let e;if(t instanceof $n)e={update:Ic(r,t.key,t.value)};else if(t instanceof Qn)e={delete:jr(r,t.key)};else if(t instanceof oe)e={update:Ic(r,t.key,t.data),updateMask:Lp(t.fieldMask)};else{if(!(t instanceof Qo))return O();e={verify:jr(r,t.key)}}return t.fieldTransforms.length>0&&(e.updateTransforms=t.fieldTransforms.map(n=>function(s,a){const u=a.transform;if(u instanceof kn)return{fieldPath:a.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(u instanceof tn)return{fieldPath:a.field.canonicalString(),appendMissingElements:{values:u.elements}};if(u instanceof en)return{fieldPath:a.field.canonicalString(),removeAllFromArray:{values:u.elements}};if(u instanceof Fn)return{fieldPath:a.field.canonicalString(),increment:u.Pe};throw O()}(0,n))),t.precondition.isNone||(e.currentDocument=function(i,s){return s.updateTime!==void 0?{updateTime:Cp(i,s.updateTime)}:s.exists!==void 0?{exists:s.exists}:O()}(r,t.precondition)),e}function bo(r,t){const e=t.currentDocument?function(s){return s.updateTime!==void 0?ct.updateTime(pt(s.updateTime)):s.exists!==void 0?ct.exists(s.exists):ct.none()}(t.currentDocument):ct.none(),n=t.updateTransforms?t.updateTransforms.map(i=>function(a,u){let c=null;if("setToServerValue"in u)L(u.setToServerValue==="REQUEST_TIME"),c=new kn;else if("appendMissingElements"in u){const f=u.appendMissingElements.values||[];c=new tn(f)}else if("removeAllFromArray"in u){const f=u.removeAllFromArray.values||[];c=new en(f)}else"increment"in u?c=new Fn(a,u.increment):O();const h=at.fromServerFormat(u.fieldPath);return new Xr(h,c)}(r,i)):[];if(t.update){t.update.name;const i=Ht(r,t.update.name),s=new bt({mapValue:{fields:t.update.fields}});if(t.updateMask){const a=function(c){const h=c.fieldPaths||[];return new Lt(h.map(f=>at.fromServerFormat(f)))}(t.updateMask);return new oe(i,s,a,e,n)}return new $n(i,s,e,n)}if(t.delete){const i=Ht(r,t.delete);return new Qn(i,e)}if(t.verify){const i=Ht(r,t.verify);return new Qo(i,e)}return O()}function Np(r,t){return r&&r.length>0?(L(t!==void 0),r.map(e=>function(i,s){let a=i.updateTime?pt(i.updateTime):pt(s);return a.isEqual(U.min())&&(a=pt(s)),new Ep(a,i.transformResults||[])}(e,t))):[]}function Mh(r,t){return{documents:[xh(r,t.path)]}}function fs(r,t){const e={structuredQuery:{}},n=t.path;let i;t.collectionGroup!==null?(i=n,e.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(i=n.popLast(),e.structuredQuery.from=[{collectionId:n.lastSegment()}]),e.parent=xh(r,i);const s=function(h){if(h.length!==0)return Uh(tt.create(h,"and"))}(t.filters);s&&(e.structuredQuery.where=s);const a=function(h){if(h.length!==0)return h.map(f=>function(_){return{field:me(_.field),direction:Fp(_.dir)}}(f))}(t.orderBy);a&&(e.structuredQuery.orderBy=a);const u=wo(r,t.limit);return u!==null&&(e.structuredQuery.limit=u),t.startAt&&(e.structuredQuery.startAt=function(h){return{before:h.inclusive,values:h.position}}(t.startAt)),t.endAt&&(e.structuredQuery.endAt=function(h){return{before:!h.inclusive,values:h.position}}(t.endAt)),{_t:e,parent:i}}function Oh(r,t,e,n){const{_t:i,parent:s}=fs(r,t),a={},u=[];let c=0;return e.forEach(h=>{const f=n?h.alias:"aggregate_"+c++;a[f]=h.alias,h.aggregateType==="count"?u.push({alias:f,count:{}}):h.aggregateType==="avg"?u.push({alias:f,avg:{field:me(h.fieldPath)}}):h.aggregateType==="sum"&&u.push({alias:f,sum:{field:me(h.fieldPath)}})}),{request:{structuredAggregationQuery:{aggregations:u,structuredQuery:i.structuredQuery},parent:i.parent},ut:a,parent:s}}function Lh(r){let t=Nh(r.parent);const e=r.structuredQuery,n=e.from?e.from.length:0;let i=null;if(n>0){L(n===1);const f=e.from[0];f.allDescendants?i=f.collectionId:t=t.child(f.collectionId)}let s=[];e.where&&(s=function(g){const _=Bh(g);return _ instanceof tt&&jo(_)?_.getFilters():[_]}(e.where));let a=[];e.orderBy&&(a=function(g){return g.map(_=>function(C){return new zr(vn(C.field),function(V){switch(V){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(C.direction))}(_))}(e.orderBy));let u=null;e.limit&&(u=function(g){let _;return _=typeof g=="object"?g.value:g,Wr(_)?null:_}(e.limit));let c=null;e.startAt&&(c=function(g){const _=!!g.before,R=g.values||[];return new Re(R,_)}(e.startAt));let h=null;return e.endAt&&(h=function(g){const _=!g.before,R=g.values||[];return new Re(R,_)}(e.endAt)),ah(t,i,a,s,u,"F",c,h)}function kp(r,t){const e=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 O()}}(t.purpose);return e==null?null:{"goog-listen-tags":e}}function Bh(r){return r.unaryFilter!==void 0?function(e){switch(e.unaryFilter.op){case"IS_NAN":const n=vn(e.unaryFilter.field);return H.create(n,"==",{doubleValue:NaN});case"IS_NULL":const i=vn(e.unaryFilter.field);return H.create(i,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const s=vn(e.unaryFilter.field);return H.create(s,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const a=vn(e.unaryFilter.field);return H.create(a,"!=",{nullValue:"NULL_VALUE"});default:return O()}}(r):r.fieldFilter!==void 0?function(e){return H.create(vn(e.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 O()}}(e.fieldFilter.op),e.fieldFilter.value)}(r):r.compositeFilter!==void 0?function(e){return tt.create(e.compositeFilter.filters.map(n=>Bh(n)),function(i){switch(i){case"AND":return"and";case"OR":return"or";default:return O()}}(e.compositeFilter.op))}(r):O()}function Fp(r){return bp[r]}function Mp(r){return Pp[r]}function Op(r){return Sp[r]}function me(r){return{fieldPath:r.canonicalString()}}function vn(r){return at.fromServerFormat(r.fieldPath)}function Uh(r){return r instanceof H?function(e){if(e.op==="=="){if(nc(e.value))return{unaryFilter:{field:me(e.field),op:"IS_NAN"}};if(ec(e.value))return{unaryFilter:{field:me(e.field),op:"IS_NULL"}}}else if(e.op==="!="){if(nc(e.value))return{unaryFilter:{field:me(e.field),op:"IS_NOT_NAN"}};if(ec(e.value))return{unaryFilter:{field:me(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:me(e.field),op:Mp(e.op),value:e.value}}}(r):r instanceof tt?function(e){const n=e.getFilters().map(i=>Uh(i));return n.length===1?n[0]:{compositeFilter:{op:Op(e.op),filters:n}}}(r):O()}function Lp(r){const t=[];return r.fields.forEach(e=>t.push(e.canonicalString())),{fieldPaths:t}}function qh(r){return r.length>=4&&r.get(0)==="projects"&&r.get(2)==="databases"}/**
1226
+ */class zi{constructor(t,e,n,i){this.Re=t,this.removedTargetIds=e,this.key=n,this.Ve=i}}class Sh{constructor(t,e){this.targetId=t,this.me=e}}class Vh{constructor(t,e,n=dt.EMPTY_BYTE_STRING,i=null){this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=i}}class pc{constructor(){this.fe=0,this.ge=yc(),this.pe=dt.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(t){t.approximateByteSize()>0&&(this.we=!0,this.pe=t)}ve(){let t=G(),e=G(),n=G();return this.ge.forEach((i,s)=>{switch(s){case 0:t=t.add(i);break;case 2:e=e.add(i);break;case 1:n=n.add(i);break;default:O()}}),new ti(this.pe,this.ye,t,e,n)}Ce(){this.we=!1,this.ge=yc()}Fe(t,e){this.we=!0,this.ge=this.ge.insert(t,e)}Me(t){this.we=!0,this.ge=this.ge.remove(t)}xe(){this.fe+=1}Oe(){this.fe-=1,L(this.fe>=0)}Ne(){this.we=!0,this.ye=!0}}class Rp{constructor(t){this.Le=t,this.Be=new Map,this.ke=Bt(),this.qe=_c(),this.Qe=new it(j)}Ke(t){for(const e of t.Re)t.Ve&&t.Ve.isFoundDocument()?this.$e(e,t.Ve):this.Ue(e,t.key,t.Ve);for(const e of t.removedTargetIds)this.Ue(e,t.key,t.Ve)}We(t){this.forEachTarget(t,e=>{const n=this.Ge(e);switch(t.state){case 0:this.ze(e)&&n.De(t.resumeToken);break;case 1:n.Oe(),n.Se||n.Ce(),n.De(t.resumeToken);break;case 2:n.Oe(),n.Se||this.removeTarget(e);break;case 3:this.ze(e)&&(n.Ne(),n.De(t.resumeToken));break;case 4:this.ze(e)&&(this.je(e),n.De(t.resumeToken));break;default:O()}})}forEachTarget(t,e){t.targetIds.length>0?t.targetIds.forEach(e):this.Be.forEach((n,i)=>{this.ze(i)&&e(i)})}He(t){const e=t.targetId,n=t.me.count,i=this.Je(e);if(i){const s=i.target;if(Qi(s))if(n===0){const a=new M(s.path);this.Ue(e,a,ot.newNoDocument(a,U.min()))}else L(n===1);else{const a=this.Ye(e);if(a!==n){const u=this.Ze(t),c=u?this.Xe(u,t,a):1;if(c!==0){this.je(e);const h=c===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Qe=this.Qe.insert(e,h)}Ji==null||Ji.et(function(f,g,_,R,C){var N,V,q,z,B,$;const Z={localCacheCount:f,existenceFilterCount:g.count,databaseId:_.database,projectId:_.projectId},K=g.unchangedNames;return K&&(Z.bloomFilter={applied:C===0,hashCount:(N=K==null?void 0:K.hashCount)!==null&&N!==void 0?N:0,bitmapLength:(z=(q=(V=K==null?void 0:K.bits)===null||V===void 0?void 0:V.bitmap)===null||q===void 0?void 0:q.length)!==null&&z!==void 0?z:0,padding:($=(B=K==null?void 0:K.bits)===null||B===void 0?void 0:B.padding)!==null&&$!==void 0?$:0,mightContain:E=>{var p;return(p=R==null?void 0:R.mightContain(E))!==null&&p!==void 0&&p}}),Z}(a,t.me,this.Le.tt(),u,c))}}}}Ze(t){const e=t.me.unchangedNames;if(!e||!e.bits)return null;const{bits:{bitmap:n="",padding:i=0},hashCount:s=0}=e;let a,u;try{a=re(n).toUint8Array()}catch(c){if(c instanceof Jl)return qt("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{u=new Yo(a,i,s)}catch(c){return qt(c instanceof Pr?"BloomFilter error: ":"Applying bloom filter failed: ",c),null}return u.Ie===0?null:u}Xe(t,e,n){return e.me.count===n-this.nt(t,e.targetId)?0:2}nt(t,e){const n=this.Le.getRemoteKeysForTarget(e);let i=0;return n.forEach(s=>{const a=this.Le.tt(),u=`projects/${a.projectId}/databases/${a.database}/documents/${s.path.canonicalString()}`;t.mightContain(u)||(this.Ue(e,s,null),i++)}),i}rt(t){const e=new Map;this.Be.forEach((s,a)=>{const u=this.Je(a);if(u){if(s.current&&Qi(u.target)){const c=new M(u.target.path);this.ke.get(c)!==null||this.it(a,c)||this.Ue(a,c,ot.newNoDocument(c,t))}s.be&&(e.set(a,s.ve()),s.Ce())}});let n=G();this.qe.forEach((s,a)=>{let u=!0;a.forEachWhile(c=>{const h=this.Je(c);return!h||h.purpose==="TargetPurposeLimboResolution"||(u=!1,!1)}),u&&(n=n.add(s))}),this.ke.forEach((s,a)=>a.setReadTime(t));const i=new Zr(t,e,this.Qe,this.ke,n);return this.ke=Bt(),this.qe=_c(),this.Qe=new it(j),i}$e(t,e){if(!this.ze(t))return;const n=this.it(t,e.key)?2:0;this.Ge(t).Fe(e.key,n),this.ke=this.ke.insert(e.key,e),this.qe=this.qe.insert(e.key,this.st(e.key).add(t))}Ue(t,e,n){if(!this.ze(t))return;const i=this.Ge(t);this.it(t,e)?i.Fe(e,1):i.Me(e),this.qe=this.qe.insert(e,this.st(e).delete(t)),n&&(this.ke=this.ke.insert(e,n))}removeTarget(t){this.Be.delete(t)}Ye(t){const e=this.Ge(t).ve();return this.Le.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size}xe(t){this.Ge(t).xe()}Ge(t){let e=this.Be.get(t);return e||(e=new pc,this.Be.set(t,e)),e}st(t){let e=this.qe.get(t);return e||(e=new et(j),this.qe=this.qe.insert(t,e)),e}ze(t){const e=this.Je(t)!==null;return e||x("WatchChangeAggregator","Detected inactive target",t),e}Je(t){const e=this.Be.get(t);return e&&e.Se?null:this.Le.ot(t)}je(t){this.Be.set(t,new pc),this.Le.getRemoteKeysForTarget(t).forEach(e=>{this.Ue(t,e,null)})}it(t,e){return this.Le.getRemoteKeysForTarget(t).has(e)}}function _c(){return new it(M.comparator)}function yc(){return new it(M.comparator)}const bp={asc:"ASCENDING",desc:"DESCENDING"},Pp={"<":"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"},Sp={and:"AND",or:"OR"};class Vp{constructor(t,e){this.databaseId=t,this.useProto3Json=e}}function wo(r,t){return r.useProto3Json||Wr(t)?t:{value:t}}function On(r,t){return r.useProto3Json?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function Ch(r,t){return r.useProto3Json?t.toBase64():t.toUint8Array()}function Cp(r,t){return On(r,t.toTimestamp())}function pt(r){return L(!!r),U.fromTimestamp(function(e){const n=ne(e);return new lt(n.seconds,n.nanos)}(r))}function Xo(r,t){return Ao(r,t).canonicalString()}function Ao(r,t){const e=function(i){return new W(["projects",i.projectId,"databases",i.database])}(r).child("documents");return t===void 0?e:e.child(t)}function Dh(r){const t=W.fromString(r);return L(qh(t)),t}function Gr(r,t){return Xo(r.databaseId,t.path)}function Ht(r,t){const e=Dh(t);if(e.get(1)!==r.databaseId.projectId)throw new D(P.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+e.get(1)+" vs "+r.databaseId.projectId);if(e.get(3)!==r.databaseId.database)throw new D(P.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+e.get(3)+" vs "+r.databaseId.database);return new M(kh(e))}function xh(r,t){return Xo(r.databaseId,t)}function Nh(r){const t=Dh(r);return t.length===4?W.emptyPath():kh(t)}function Ro(r){return new W(["projects",r.databaseId.projectId,"databases",r.databaseId.database]).canonicalString()}function kh(r){return L(r.length>4&&r.get(4)==="documents"),r.popFirst(5)}function Ic(r,t,e){return{name:Gr(r,t),fields:e.value.mapValue.fields}}function Fh(r,t,e){const n=Ht(r,t.name),i=pt(t.updateTime),s=t.createTime?pt(t.createTime):U.min(),a=new bt({mapValue:{fields:t.fields}}),u=ot.newFoundDocument(n,i,s,a);return e&&u.setHasCommittedMutations(),e?u.setHasCommittedMutations():u}function Dp(r,t){return"found"in t?function(n,i){L(!!i.found),i.found.name,i.found.updateTime;const s=Ht(n,i.found.name),a=pt(i.found.updateTime),u=i.found.createTime?pt(i.found.createTime):U.min(),c=new bt({mapValue:{fields:i.found.fields}});return ot.newFoundDocument(s,a,u,c)}(r,t):"missing"in t?function(n,i){L(!!i.missing),L(!!i.readTime);const s=Ht(n,i.missing),a=pt(i.readTime);return ot.newNoDocument(s,a)}(r,t):O()}function xp(r,t){let e;if("targetChange"in t){t.targetChange;const n=function(h){return h==="NO_CHANGE"?0:h==="ADD"?1:h==="REMOVE"?2:h==="CURRENT"?3:h==="RESET"?4:O()}(t.targetChange.targetChangeType||"NO_CHANGE"),i=t.targetChange.targetIds||[],s=function(h,f){return h.useProto3Json?(L(f===void 0||typeof f=="string"),dt.fromBase64String(f||"")):(L(f===void 0||f instanceof Buffer||f instanceof Uint8Array),dt.fromUint8Array(f||new Uint8Array))}(r,t.targetChange.resumeToken),a=t.targetChange.cause,u=a&&function(h){const f=h.code===void 0?P.UNKNOWN:bh(h.code);return new D(f,h.message||"")}(a);e=new Vh(n,i,s,u||null)}else if("documentChange"in t){t.documentChange;const n=t.documentChange;n.document,n.document.name,n.document.updateTime;const i=Ht(r,n.document.name),s=pt(n.document.updateTime),a=n.document.createTime?pt(n.document.createTime):U.min(),u=new bt({mapValue:{fields:n.document.fields}}),c=ot.newFoundDocument(i,s,a,u),h=n.targetIds||[],f=n.removedTargetIds||[];e=new zi(h,f,c.key,c)}else if("documentDelete"in t){t.documentDelete;const n=t.documentDelete;n.document;const i=Ht(r,n.document),s=n.readTime?pt(n.readTime):U.min(),a=ot.newNoDocument(i,s),u=n.removedTargetIds||[];e=new zi([],u,a.key,a)}else if("documentRemove"in t){t.documentRemove;const n=t.documentRemove;n.document;const i=Ht(r,n.document),s=n.removedTargetIds||[];e=new zi([],s,i,null)}else{if(!("filter"in t))return O();{t.filter;const n=t.filter;n.targetId;const{count:i=0,unchangedNames:s}=n,a=new wp(i,s),u=n.targetId;e=new Sh(u,a)}}return e}function Kr(r,t){let e;if(t instanceof Qn)e={update:Ic(r,t.key,t.value)};else if(t instanceof Wn)e={delete:Gr(r,t.key)};else if(t instanceof oe)e={update:Ic(r,t.key,t.data),updateMask:Lp(t.fieldMask)};else{if(!(t instanceof Qo))return O();e={verify:Gr(r,t.key)}}return t.fieldTransforms.length>0&&(e.updateTransforms=t.fieldTransforms.map(n=>function(s,a){const u=a.transform;if(u instanceof Fn)return{fieldPath:a.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(u instanceof en)return{fieldPath:a.field.canonicalString(),appendMissingElements:{values:u.elements}};if(u instanceof nn)return{fieldPath:a.field.canonicalString(),removeAllFromArray:{values:u.elements}};if(u instanceof Mn)return{fieldPath:a.field.canonicalString(),increment:u.Pe};throw O()}(0,n))),t.precondition.isNone||(e.currentDocument=function(i,s){return s.updateTime!==void 0?{updateTime:Cp(i,s.updateTime)}:s.exists!==void 0?{exists:s.exists}:O()}(r,t.precondition)),e}function bo(r,t){const e=t.currentDocument?function(s){return s.updateTime!==void 0?ct.updateTime(pt(s.updateTime)):s.exists!==void 0?ct.exists(s.exists):ct.none()}(t.currentDocument):ct.none(),n=t.updateTransforms?t.updateTransforms.map(i=>function(a,u){let c=null;if("setToServerValue"in u)L(u.setToServerValue==="REQUEST_TIME"),c=new Fn;else if("appendMissingElements"in u){const f=u.appendMissingElements.values||[];c=new en(f)}else if("removeAllFromArray"in u){const f=u.removeAllFromArray.values||[];c=new nn(f)}else"increment"in u?c=new Mn(a,u.increment):O();const h=at.fromServerFormat(u.fieldPath);return new Xr(h,c)}(r,i)):[];if(t.update){t.update.name;const i=Ht(r,t.update.name),s=new bt({mapValue:{fields:t.update.fields}});if(t.updateMask){const a=function(c){const h=c.fieldPaths||[];return new Lt(h.map(f=>at.fromServerFormat(f)))}(t.updateMask);return new oe(i,s,a,e,n)}return new Qn(i,s,e,n)}if(t.delete){const i=Ht(r,t.delete);return new Wn(i,e)}if(t.verify){const i=Ht(r,t.verify);return new Qo(i,e)}return O()}function Np(r,t){return r&&r.length>0?(L(t!==void 0),r.map(e=>function(i,s){let a=i.updateTime?pt(i.updateTime):pt(s);return a.isEqual(U.min())&&(a=pt(s)),new Ep(a,i.transformResults||[])}(e,t))):[]}function Mh(r,t){return{documents:[xh(r,t.path)]}}function fs(r,t){const e={structuredQuery:{}},n=t.path;let i;t.collectionGroup!==null?(i=n,e.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(i=n.popLast(),e.structuredQuery.from=[{collectionId:n.lastSegment()}]),e.parent=xh(r,i);const s=function(h){if(h.length!==0)return Uh(tt.create(h,"and"))}(t.filters);s&&(e.structuredQuery.where=s);const a=function(h){if(h.length!==0)return h.map(f=>function(_){return{field:me(_.field),direction:Fp(_.dir)}}(f))}(t.orderBy);a&&(e.structuredQuery.orderBy=a);const u=wo(r,t.limit);return u!==null&&(e.structuredQuery.limit=u),t.startAt&&(e.structuredQuery.startAt=function(h){return{before:h.inclusive,values:h.position}}(t.startAt)),t.endAt&&(e.structuredQuery.endAt=function(h){return{before:!h.inclusive,values:h.position}}(t.endAt)),{_t:e,parent:i}}function Oh(r,t,e,n){const{_t:i,parent:s}=fs(r,t),a={},u=[];let c=0;return e.forEach(h=>{const f=n?h.alias:"aggregate_"+c++;a[f]=h.alias,h.aggregateType==="count"?u.push({alias:f,count:{}}):h.aggregateType==="avg"?u.push({alias:f,avg:{field:me(h.fieldPath)}}):h.aggregateType==="sum"&&u.push({alias:f,sum:{field:me(h.fieldPath)}})}),{request:{structuredAggregationQuery:{aggregations:u,structuredQuery:i.structuredQuery},parent:i.parent},ut:a,parent:s}}function Lh(r){let t=Nh(r.parent);const e=r.structuredQuery,n=e.from?e.from.length:0;let i=null;if(n>0){L(n===1);const f=e.from[0];f.allDescendants?i=f.collectionId:t=t.child(f.collectionId)}let s=[];e.where&&(s=function(g){const _=Bh(g);return _ instanceof tt&&jo(_)?_.getFilters():[_]}(e.where));let a=[];e.orderBy&&(a=function(g){return g.map(_=>function(C){return new jr(wn(C.field),function(V){switch(V){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(C.direction))}(_))}(e.orderBy));let u=null;e.limit&&(u=function(g){let _;return _=typeof g=="object"?g.value:g,Wr(_)?null:_}(e.limit));let c=null;e.startAt&&(c=function(g){const _=!!g.before,R=g.values||[];return new be(R,_)}(e.startAt));let h=null;return e.endAt&&(h=function(g){const _=!g.before,R=g.values||[];return new be(R,_)}(e.endAt)),ah(t,i,a,s,u,"F",c,h)}function kp(r,t){const e=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 O()}}(t.purpose);return e==null?null:{"goog-listen-tags":e}}function Bh(r){return r.unaryFilter!==void 0?function(e){switch(e.unaryFilter.op){case"IS_NAN":const n=wn(e.unaryFilter.field);return H.create(n,"==",{doubleValue:NaN});case"IS_NULL":const i=wn(e.unaryFilter.field);return H.create(i,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const s=wn(e.unaryFilter.field);return H.create(s,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const a=wn(e.unaryFilter.field);return H.create(a,"!=",{nullValue:"NULL_VALUE"});default:return O()}}(r):r.fieldFilter!==void 0?function(e){return H.create(wn(e.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 O()}}(e.fieldFilter.op),e.fieldFilter.value)}(r):r.compositeFilter!==void 0?function(e){return tt.create(e.compositeFilter.filters.map(n=>Bh(n)),function(i){switch(i){case"AND":return"and";case"OR":return"or";default:return O()}}(e.compositeFilter.op))}(r):O()}function Fp(r){return bp[r]}function Mp(r){return Pp[r]}function Op(r){return Sp[r]}function me(r){return{fieldPath:r.canonicalString()}}function wn(r){return at.fromServerFormat(r.fieldPath)}function Uh(r){return r instanceof H?function(e){if(e.op==="=="){if(nc(e.value))return{unaryFilter:{field:me(e.field),op:"IS_NAN"}};if(ec(e.value))return{unaryFilter:{field:me(e.field),op:"IS_NULL"}}}else if(e.op==="!="){if(nc(e.value))return{unaryFilter:{field:me(e.field),op:"IS_NOT_NAN"}};if(ec(e.value))return{unaryFilter:{field:me(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:me(e.field),op:Mp(e.op),value:e.value}}}(r):r instanceof tt?function(e){const n=e.getFilters().map(i=>Uh(i));return n.length===1?n[0]:{compositeFilter:{op:Op(e.op),filters:n}}}(r):O()}function Lp(r){const t=[];return r.fields.forEach(e=>t.push(e.canonicalString())),{fieldPaths:t}}function qh(r){return r.length>=4&&r.get(0)==="projects"&&r.get(2)==="databases"}/**
1227
1227
  * @license
1228
1228
  * Copyright 2017 Google LLC
1229
1229
  *
@@ -1253,7 +1253,7 @@ SPDX-License-Identifier: Apache-2.0
1253
1253
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1254
1254
  * See the License for the specific language governing permissions and
1255
1255
  * limitations under the License.
1256
- */class zh{constructor(t){this.ct=t}}function Bp(r,t){let e;if(t.document)e=Fh(r.ct,t.document,!!t.hasCommittedMutations);else if(t.noDocument){const n=M.fromSegments(t.noDocument.path),i=rn(t.noDocument.readTime);e=ot.newNoDocument(n,i),t.hasCommittedMutations&&e.setHasCommittedMutations()}else{if(!t.unknownDocument)return O();{const n=M.fromSegments(t.unknownDocument.path),i=rn(t.unknownDocument.version);e=ot.newUnknownDocument(n,i)}}return t.readTime&&e.setReadTime(function(i){const s=new lt(i[0],i[1]);return U.fromTimestamp(s)}(t.readTime)),e}function Ec(r,t){const e=t.key,n={prefixPath:e.getCollectionPath().popLast().toArray(),collectionGroup:e.collectionGroup,documentId:e.path.lastSegment(),readTime:Yi(t.readTime),hasCommittedMutations:t.hasCommittedMutations};if(t.isFoundDocument())n.document=function(s,a){return{name:jr(s,a.key),fields:a.data.value.mapValue.fields,updateTime:Mn(s,a.version.toTimestamp()),createTime:Mn(s,a.createTime.toTimestamp())}}(r.ct,t);else if(t.isNoDocument())n.noDocument={path:e.path.toArray(),readTime:nn(t.version)};else{if(!t.isUnknownDocument())return O();n.unknownDocument={path:e.path.toArray(),version:nn(t.version)}}return n}function Yi(r){const t=r.toTimestamp();return[t.seconds,t.nanoseconds]}function nn(r){const t=r.toTimestamp();return{seconds:t.seconds,nanoseconds:t.nanoseconds}}function rn(r){const t=new lt(r.seconds,r.nanoseconds);return U.fromTimestamp(t)}function Ke(r,t){const e=(t.baseMutations||[]).map(s=>bo(r.ct,s));for(let s=0;s<t.mutations.length-1;++s){const a=t.mutations[s];if(s+1<t.mutations.length&&t.mutations[s+1].transform!==void 0){const u=t.mutations[s+1];a.updateTransforms=u.transform.fieldTransforms,t.mutations.splice(s+1,1),++s}}const n=t.mutations.map(s=>bo(r.ct,s)),i=lt.fromMillis(t.localWriteTimeMs);return new Wo(t.batchId,i,e,n)}function Pr(r){const t=rn(r.readTime),e=r.lastLimboFreeSnapshotVersion!==void 0?rn(r.lastLimboFreeSnapshotVersion):U.min();let n;return n=function(s){return s.documents!==void 0}(r.query)?function(s){return L(s.documents.length===1),kt(Kn(Nh(s.documents[0])))}(r.query):function(s){return kt(Lh(s))}(r.query),new te(n,r.targetId,"TargetPurposeListen",r.lastListenSequenceNumber,t,e,dt.fromBase64String(r.resumeToken))}function jh(r,t){const e=nn(t.snapshotVersion),n=nn(t.lastLimboFreeSnapshotVersion);let i;i=Qi(t.target)?Mh(r.ct,t.target):fs(r.ct,t.target)._t;const s=t.resumeToken.toBase64();return{targetId:t.targetId,canonicalId:Ze(t.target),readTime:e,resumeToken:s,lastListenSequenceNumber:t.sequenceNumber,lastLimboFreeSnapshotVersion:n,query:i}}function Zo(r){const t=Lh({parent:r.parent,structuredQuery:r.structuredQuery});return r.limitType==="LAST"?Hi(t,t.limit,"L"):t}function ro(r,t){return new Jo(t.largestBatchId,bo(r.ct,t.overlayMutation))}function Tc(r,t){const e=t.path.lastSegment();return[r,Nt(t.path.popLast()),e]}function vc(r,t,e,n){return{indexId:r,uid:t,sequenceNumber:e,readTime:nn(n.readTime),documentKey:Nt(n.documentKey.path),largestBatchId:n.largestBatchId}}/**
1256
+ */class zh{constructor(t){this.ct=t}}function Bp(r,t){let e;if(t.document)e=Fh(r.ct,t.document,!!t.hasCommittedMutations);else if(t.noDocument){const n=M.fromSegments(t.noDocument.path),i=sn(t.noDocument.readTime);e=ot.newNoDocument(n,i),t.hasCommittedMutations&&e.setHasCommittedMutations()}else{if(!t.unknownDocument)return O();{const n=M.fromSegments(t.unknownDocument.path),i=sn(t.unknownDocument.version);e=ot.newUnknownDocument(n,i)}}return t.readTime&&e.setReadTime(function(i){const s=new lt(i[0],i[1]);return U.fromTimestamp(s)}(t.readTime)),e}function Ec(r,t){const e=t.key,n={prefixPath:e.getCollectionPath().popLast().toArray(),collectionGroup:e.collectionGroup,documentId:e.path.lastSegment(),readTime:Yi(t.readTime),hasCommittedMutations:t.hasCommittedMutations};if(t.isFoundDocument())n.document=function(s,a){return{name:Gr(s,a.key),fields:a.data.value.mapValue.fields,updateTime:On(s,a.version.toTimestamp()),createTime:On(s,a.createTime.toTimestamp())}}(r.ct,t);else if(t.isNoDocument())n.noDocument={path:e.path.toArray(),readTime:rn(t.version)};else{if(!t.isUnknownDocument())return O();n.unknownDocument={path:e.path.toArray(),version:rn(t.version)}}return n}function Yi(r){const t=r.toTimestamp();return[t.seconds,t.nanoseconds]}function rn(r){const t=r.toTimestamp();return{seconds:t.seconds,nanoseconds:t.nanoseconds}}function sn(r){const t=new lt(r.seconds,r.nanoseconds);return U.fromTimestamp(t)}function $e(r,t){const e=(t.baseMutations||[]).map(s=>bo(r.ct,s));for(let s=0;s<t.mutations.length-1;++s){const a=t.mutations[s];if(s+1<t.mutations.length&&t.mutations[s+1].transform!==void 0){const u=t.mutations[s+1];a.updateTransforms=u.transform.fieldTransforms,t.mutations.splice(s+1,1),++s}}const n=t.mutations.map(s=>bo(r.ct,s)),i=lt.fromMillis(t.localWriteTimeMs);return new Wo(t.batchId,i,e,n)}function Sr(r){const t=sn(r.readTime),e=r.lastLimboFreeSnapshotVersion!==void 0?sn(r.lastLimboFreeSnapshotVersion):U.min();let n;return n=function(s){return s.documents!==void 0}(r.query)?function(s){return L(s.documents.length===1),kt($n(Nh(s.documents[0])))}(r.query):function(s){return kt(Lh(s))}(r.query),new te(n,r.targetId,"TargetPurposeListen",r.lastListenSequenceNumber,t,e,dt.fromBase64String(r.resumeToken))}function jh(r,t){const e=rn(t.snapshotVersion),n=rn(t.lastLimboFreeSnapshotVersion);let i;i=Qi(t.target)?Mh(r.ct,t.target):fs(r.ct,t.target)._t;const s=t.resumeToken.toBase64();return{targetId:t.targetId,canonicalId:tn(t.target),readTime:e,resumeToken:s,lastListenSequenceNumber:t.sequenceNumber,lastLimboFreeSnapshotVersion:n,query:i}}function Zo(r){const t=Lh({parent:r.parent,structuredQuery:r.structuredQuery});return r.limitType==="LAST"?Hi(t,t.limit,"L"):t}function ro(r,t){return new Jo(t.largestBatchId,bo(r.ct,t.overlayMutation))}function Tc(r,t){const e=t.path.lastSegment();return[r,Nt(t.path.popLast()),e]}function vc(r,t,e,n){return{indexId:r,uid:t,sequenceNumber:e,readTime:rn(n.readTime),documentKey:Nt(n.documentKey.path),largestBatchId:n.largestBatchId}}/**
1257
1257
  * @license
1258
1258
  * Copyright 2020 Google LLC
1259
1259
  *
@@ -1268,7 +1268,7 @@ SPDX-License-Identifier: Apache-2.0
1268
1268
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1269
1269
  * See the License for the specific language governing permissions and
1270
1270
  * limitations under the License.
1271
- */class Up{getBundleMetadata(t,e){return wc(t).get(e).next(n=>{if(n)return function(s){return{id:s.bundleId,createTime:rn(s.createTime),version:s.version}}(n)})}saveBundleMetadata(t,e){return wc(t).put(function(i){return{bundleId:i.id,createTime:nn(pt(i.createTime)),version:i.version}}(e))}getNamedQuery(t,e){return Ac(t).get(e).next(n=>{if(n)return function(s){return{name:s.name,query:Zo(s.bundledQuery),readTime:rn(s.readTime)}}(n)})}saveNamedQuery(t,e){return Ac(t).put(function(i){return{name:i.name,readTime:nn(pt(i.readTime)),bundledQuery:i.bundledQuery}}(e))}}function wc(r){return It(r,"bundles")}function Ac(r){return It(r,"namedQueries")}/**
1271
+ */class Up{getBundleMetadata(t,e){return wc(t).get(e).next(n=>{if(n)return function(s){return{id:s.bundleId,createTime:sn(s.createTime),version:s.version}}(n)})}saveBundleMetadata(t,e){return wc(t).put(function(i){return{bundleId:i.id,createTime:rn(pt(i.createTime)),version:i.version}}(e))}getNamedQuery(t,e){return Ac(t).get(e).next(n=>{if(n)return function(s){return{name:s.name,query:Zo(s.bundledQuery),readTime:sn(s.readTime)}}(n)})}saveNamedQuery(t,e){return Ac(t).put(function(i){return{name:i.name,readTime:rn(pt(i.readTime)),bundledQuery:i.bundledQuery}}(e))}}function wc(r){return It(r,"bundles")}function Ac(r){return It(r,"namedQueries")}/**
1272
1272
  * @license
1273
1273
  * Copyright 2022 Google LLC
1274
1274
  *
@@ -1283,7 +1283,7 @@ SPDX-License-Identifier: Apache-2.0
1283
1283
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1284
1284
  * See the License for the specific language governing permissions and
1285
1285
  * limitations under the License.
1286
- */class ms{constructor(t,e){this.serializer=t,this.userId=e}static lt(t,e){const n=e.uid||"";return new ms(t,n)}getOverlay(t,e){return Ir(t).get(Tc(this.userId,e)).next(n=>n?ro(this.serializer,n):null)}getOverlays(t,e){const n=Qt();return w.forEach(e,i=>this.getOverlay(t,i).next(s=>{s!==null&&n.set(i,s)})).next(()=>n)}saveOverlays(t,e,n){const i=[];return n.forEach((s,a)=>{const u=new Jo(e,a);i.push(this.ht(t,u))}),w.waitFor(i)}removeOverlaysForBatchId(t,e,n){const i=new Set;e.forEach(a=>i.add(Nt(a.getCollectionPath())));const s=[];return i.forEach(a=>{const u=IDBKeyRange.bound([this.userId,a,n],[this.userId,a,n+1],!1,!0);s.push(Ir(t).j("collectionPathOverlayIndex",u))}),w.waitFor(s)}getOverlaysForCollection(t,e,n){const i=Qt(),s=Nt(e),a=IDBKeyRange.bound([this.userId,s,n],[this.userId,s,Number.POSITIVE_INFINITY],!0);return Ir(t).U("collectionPathOverlayIndex",a).next(u=>{for(const c of u){const h=ro(this.serializer,c);i.set(h.getKey(),h)}return i})}getOverlaysForCollectionGroup(t,e,n,i){const s=Qt();let a;const u=IDBKeyRange.bound([this.userId,e,n],[this.userId,e,Number.POSITIVE_INFINITY],!0);return Ir(t).J({index:"collectionGroupOverlayIndex",range:u},(c,h,f)=>{const g=ro(this.serializer,h);s.size()<i||g.largestBatchId===a?(s.set(g.getKey(),g),a=g.largestBatchId):f.done()}).next(()=>s)}ht(t,e){return Ir(t).put(function(i,s,a){const[u,c,h]=Tc(s,a.mutation.key);return{userId:s,collectionPath:c,documentId:h,collectionGroup:a.mutation.key.getCollectionGroup(),largestBatchId:a.largestBatchId,overlayMutation:Gr(i.ct,a.mutation)}}(this.serializer,this.userId,e))}}function Ir(r){return It(r,"documentOverlays")}/**
1286
+ */class ms{constructor(t,e){this.serializer=t,this.userId=e}static lt(t,e){const n=e.uid||"";return new ms(t,n)}getOverlay(t,e){return Er(t).get(Tc(this.userId,e)).next(n=>n?ro(this.serializer,n):null)}getOverlays(t,e){const n=Qt();return w.forEach(e,i=>this.getOverlay(t,i).next(s=>{s!==null&&n.set(i,s)})).next(()=>n)}saveOverlays(t,e,n){const i=[];return n.forEach((s,a)=>{const u=new Jo(e,a);i.push(this.ht(t,u))}),w.waitFor(i)}removeOverlaysForBatchId(t,e,n){const i=new Set;e.forEach(a=>i.add(Nt(a.getCollectionPath())));const s=[];return i.forEach(a=>{const u=IDBKeyRange.bound([this.userId,a,n],[this.userId,a,n+1],!1,!0);s.push(Er(t).j("collectionPathOverlayIndex",u))}),w.waitFor(s)}getOverlaysForCollection(t,e,n){const i=Qt(),s=Nt(e),a=IDBKeyRange.bound([this.userId,s,n],[this.userId,s,Number.POSITIVE_INFINITY],!0);return Er(t).U("collectionPathOverlayIndex",a).next(u=>{for(const c of u){const h=ro(this.serializer,c);i.set(h.getKey(),h)}return i})}getOverlaysForCollectionGroup(t,e,n,i){const s=Qt();let a;const u=IDBKeyRange.bound([this.userId,e,n],[this.userId,e,Number.POSITIVE_INFINITY],!0);return Er(t).J({index:"collectionGroupOverlayIndex",range:u},(c,h,f)=>{const g=ro(this.serializer,h);s.size()<i||g.largestBatchId===a?(s.set(g.getKey(),g),a=g.largestBatchId):f.done()}).next(()=>s)}ht(t,e){return Er(t).put(function(i,s,a){const[u,c,h]=Tc(s,a.mutation.key);return{userId:s,collectionPath:c,documentId:h,collectionGroup:a.mutation.key.getCollectionGroup(),largestBatchId:a.largestBatchId,overlayMutation:Kr(i.ct,a.mutation)}}(this.serializer,this.userId,e))}}function Er(r){return It(r,"documentOverlays")}/**
1287
1287
  * @license
1288
1288
  * Copyright 2024 Google LLC
1289
1289
  *
@@ -1313,7 +1313,7 @@ SPDX-License-Identifier: Apache-2.0
1313
1313
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1314
1314
  * See the License for the specific language governing permissions and
1315
1315
  * limitations under the License.
1316
- */class $e{constructor(){}It(t,e){this.Tt(t,e),e.Et()}Tt(t,e){if("nullValue"in t)this.dt(e,5);else if("booleanValue"in t)this.dt(e,10),e.At(t.booleanValue?1:0);else if("integerValue"in t)this.dt(e,15),e.At(ut(t.integerValue));else if("doubleValue"in t){const n=ut(t.doubleValue);isNaN(n)?this.dt(e,13):(this.dt(e,15),Lr(n)?e.At(0):e.At(n))}else if("timestampValue"in t){let n=t.timestampValue;this.dt(e,20),typeof n=="string"&&(n=ne(n)),e.Rt(`${n.seconds||""}`),e.At(n.nanos||0)}else if("stringValue"in t)this.Vt(t.stringValue,e),this.ft(e);else if("bytesValue"in t)this.dt(e,30),e.gt(re(t.bytesValue)),this.ft(e);else if("referenceValue"in t)this.yt(t.referenceValue,e);else if("geoPointValue"in t){const n=t.geoPointValue;this.dt(e,45),e.At(n.latitude||0),e.At(n.longitude||0)}else"mapValue"in t?Yl(t)?this.dt(e,Number.MAX_SAFE_INTEGER):ls(t)?this.wt(t.mapValue,e):(this.St(t.mapValue,e),this.ft(e)):"arrayValue"in t?(this.bt(t.arrayValue,e),this.ft(e)):O()}Vt(t,e){this.dt(e,25),this.Dt(t,e)}Dt(t,e){e.Rt(t)}St(t,e){const n=t.fields||{};this.dt(e,55);for(const i of Object.keys(n))this.Vt(i,e),this.Tt(n[i],e)}wt(t,e){var n,i;const s=t.fields||{};this.dt(e,53);const a="value",u=((i=(n=s[a].arrayValue)===null||n===void 0?void 0:n.values)===null||i===void 0?void 0:i.length)||0;this.dt(e,15),e.At(ut(u)),this.Vt(a,e),this.Tt(s[a],e)}bt(t,e){const n=t.values||[];this.dt(e,50);for(const i of n)this.Tt(i,e)}yt(t,e){this.dt(e,37),M.fromName(t).path.forEach(n=>{this.dt(e,60),this.Dt(n,e)})}dt(t,e){t.At(e)}ft(t){t.At(2)}}$e.vt=new $e;function zp(r){if(r===0)return 8;let t=0;return!(r>>4)&&(t+=4,r<<=4),!(r>>6)&&(t+=2,r<<=2),!(r>>7)&&(t+=1),t}function Rc(r){const t=64-function(n){let i=0;for(let s=0;s<8;++s){const a=zp(255&n[s]);if(i+=a,a!==8)break}return i}(r);return Math.ceil(t/8)}class jp{constructor(){this.buffer=new Uint8Array(1024),this.position=0}Ct(t){const e=t[Symbol.iterator]();let n=e.next();for(;!n.done;)this.Ft(n.value),n=e.next();this.Mt()}xt(t){const e=t[Symbol.iterator]();let n=e.next();for(;!n.done;)this.Ot(n.value),n=e.next();this.Nt()}Lt(t){for(const e of t){const n=e.charCodeAt(0);if(n<128)this.Ft(n);else if(n<2048)this.Ft(960|n>>>6),this.Ft(128|63&n);else if(e<"\uD800"||"\uDBFF"<e)this.Ft(480|n>>>12),this.Ft(128|63&n>>>6),this.Ft(128|63&n);else{const i=e.codePointAt(0);this.Ft(240|i>>>18),this.Ft(128|63&i>>>12),this.Ft(128|63&i>>>6),this.Ft(128|63&i)}}this.Mt()}Bt(t){for(const e of t){const n=e.charCodeAt(0);if(n<128)this.Ot(n);else if(n<2048)this.Ot(960|n>>>6),this.Ot(128|63&n);else if(e<"\uD800"||"\uDBFF"<e)this.Ot(480|n>>>12),this.Ot(128|63&n>>>6),this.Ot(128|63&n);else{const i=e.codePointAt(0);this.Ot(240|i>>>18),this.Ot(128|63&i>>>12),this.Ot(128|63&i>>>6),this.Ot(128|63&i)}}this.Nt()}kt(t){const e=this.qt(t),n=Rc(e);this.Qt(1+n),this.buffer[this.position++]=255&n;for(let i=e.length-n;i<e.length;++i)this.buffer[this.position++]=255&e[i]}Kt(t){const e=this.qt(t),n=Rc(e);this.Qt(1+n),this.buffer[this.position++]=~(255&n);for(let i=e.length-n;i<e.length;++i)this.buffer[this.position++]=~(255&e[i])}$t(){this.Ut(255),this.Ut(255)}Wt(){this.Gt(255),this.Gt(255)}reset(){this.position=0}seed(t){this.Qt(t.length),this.buffer.set(t,this.position),this.position+=t.length}zt(){return this.buffer.slice(0,this.position)}qt(t){const e=function(s){const a=new DataView(new ArrayBuffer(8));return a.setFloat64(0,s,!1),new Uint8Array(a.buffer)}(t),n=(128&e[0])!=0;e[0]^=n?255:128;for(let i=1;i<e.length;++i)e[i]^=n?255:0;return e}Ft(t){const e=255&t;e===0?(this.Ut(0),this.Ut(255)):e===255?(this.Ut(255),this.Ut(0)):this.Ut(e)}Ot(t){const e=255&t;e===0?(this.Gt(0),this.Gt(255)):e===255?(this.Gt(255),this.Gt(0)):this.Gt(t)}Mt(){this.Ut(0),this.Ut(1)}Nt(){this.Gt(0),this.Gt(1)}Ut(t){this.Qt(1),this.buffer[this.position++]=t}Gt(t){this.Qt(1),this.buffer[this.position++]=~t}Qt(t){const e=t+this.position;if(e<=this.buffer.length)return;let n=2*this.buffer.length;n<e&&(n=e);const i=new Uint8Array(n);i.set(this.buffer),this.buffer=i}}class Gp{constructor(t){this.jt=t}gt(t){this.jt.Ct(t)}Rt(t){this.jt.Lt(t)}At(t){this.jt.kt(t)}Et(){this.jt.$t()}}class Kp{constructor(t){this.jt=t}gt(t){this.jt.xt(t)}Rt(t){this.jt.Bt(t)}At(t){this.jt.Kt(t)}Et(){this.jt.Wt()}}class Er{constructor(){this.jt=new jp,this.Ht=new Gp(this.jt),this.Jt=new Kp(this.jt)}seed(t){this.jt.seed(t)}Yt(t){return t===0?this.Ht:this.Jt}zt(){return this.jt.zt()}reset(){this.jt.reset()}}/**
1316
+ */class Qe{constructor(){}It(t,e){this.Tt(t,e),e.Et()}Tt(t,e){if("nullValue"in t)this.dt(e,5);else if("booleanValue"in t)this.dt(e,10),e.At(t.booleanValue?1:0);else if("integerValue"in t)this.dt(e,15),e.At(ut(t.integerValue));else if("doubleValue"in t){const n=ut(t.doubleValue);isNaN(n)?this.dt(e,13):(this.dt(e,15),Br(n)?e.At(0):e.At(n))}else if("timestampValue"in t){let n=t.timestampValue;this.dt(e,20),typeof n=="string"&&(n=ne(n)),e.Rt(`${n.seconds||""}`),e.At(n.nanos||0)}else if("stringValue"in t)this.Vt(t.stringValue,e),this.ft(e);else if("bytesValue"in t)this.dt(e,30),e.gt(re(t.bytesValue)),this.ft(e);else if("referenceValue"in t)this.yt(t.referenceValue,e);else if("geoPointValue"in t){const n=t.geoPointValue;this.dt(e,45),e.At(n.latitude||0),e.At(n.longitude||0)}else"mapValue"in t?Yl(t)?this.dt(e,Number.MAX_SAFE_INTEGER):ls(t)?this.wt(t.mapValue,e):(this.St(t.mapValue,e),this.ft(e)):"arrayValue"in t?(this.bt(t.arrayValue,e),this.ft(e)):O()}Vt(t,e){this.dt(e,25),this.Dt(t,e)}Dt(t,e){e.Rt(t)}St(t,e){const n=t.fields||{};this.dt(e,55);for(const i of Object.keys(n))this.Vt(i,e),this.Tt(n[i],e)}wt(t,e){var n,i;const s=t.fields||{};this.dt(e,53);const a="value",u=((i=(n=s[a].arrayValue)===null||n===void 0?void 0:n.values)===null||i===void 0?void 0:i.length)||0;this.dt(e,15),e.At(ut(u)),this.Vt(a,e),this.Tt(s[a],e)}bt(t,e){const n=t.values||[];this.dt(e,50);for(const i of n)this.Tt(i,e)}yt(t,e){this.dt(e,37),M.fromName(t).path.forEach(n=>{this.dt(e,60),this.Dt(n,e)})}dt(t,e){t.At(e)}ft(t){t.At(2)}}Qe.vt=new Qe;function zp(r){if(r===0)return 8;let t=0;return!(r>>4)&&(t+=4,r<<=4),!(r>>6)&&(t+=2,r<<=2),!(r>>7)&&(t+=1),t}function Rc(r){const t=64-function(n){let i=0;for(let s=0;s<8;++s){const a=zp(255&n[s]);if(i+=a,a!==8)break}return i}(r);return Math.ceil(t/8)}class jp{constructor(){this.buffer=new Uint8Array(1024),this.position=0}Ct(t){const e=t[Symbol.iterator]();let n=e.next();for(;!n.done;)this.Ft(n.value),n=e.next();this.Mt()}xt(t){const e=t[Symbol.iterator]();let n=e.next();for(;!n.done;)this.Ot(n.value),n=e.next();this.Nt()}Lt(t){for(const e of t){const n=e.charCodeAt(0);if(n<128)this.Ft(n);else if(n<2048)this.Ft(960|n>>>6),this.Ft(128|63&n);else if(e<"\uD800"||"\uDBFF"<e)this.Ft(480|n>>>12),this.Ft(128|63&n>>>6),this.Ft(128|63&n);else{const i=e.codePointAt(0);this.Ft(240|i>>>18),this.Ft(128|63&i>>>12),this.Ft(128|63&i>>>6),this.Ft(128|63&i)}}this.Mt()}Bt(t){for(const e of t){const n=e.charCodeAt(0);if(n<128)this.Ot(n);else if(n<2048)this.Ot(960|n>>>6),this.Ot(128|63&n);else if(e<"\uD800"||"\uDBFF"<e)this.Ot(480|n>>>12),this.Ot(128|63&n>>>6),this.Ot(128|63&n);else{const i=e.codePointAt(0);this.Ot(240|i>>>18),this.Ot(128|63&i>>>12),this.Ot(128|63&i>>>6),this.Ot(128|63&i)}}this.Nt()}kt(t){const e=this.qt(t),n=Rc(e);this.Qt(1+n),this.buffer[this.position++]=255&n;for(let i=e.length-n;i<e.length;++i)this.buffer[this.position++]=255&e[i]}Kt(t){const e=this.qt(t),n=Rc(e);this.Qt(1+n),this.buffer[this.position++]=~(255&n);for(let i=e.length-n;i<e.length;++i)this.buffer[this.position++]=~(255&e[i])}$t(){this.Ut(255),this.Ut(255)}Wt(){this.Gt(255),this.Gt(255)}reset(){this.position=0}seed(t){this.Qt(t.length),this.buffer.set(t,this.position),this.position+=t.length}zt(){return this.buffer.slice(0,this.position)}qt(t){const e=function(s){const a=new DataView(new ArrayBuffer(8));return a.setFloat64(0,s,!1),new Uint8Array(a.buffer)}(t),n=(128&e[0])!=0;e[0]^=n?255:128;for(let i=1;i<e.length;++i)e[i]^=n?255:0;return e}Ft(t){const e=255&t;e===0?(this.Ut(0),this.Ut(255)):e===255?(this.Ut(255),this.Ut(0)):this.Ut(e)}Ot(t){const e=255&t;e===0?(this.Gt(0),this.Gt(255)):e===255?(this.Gt(255),this.Gt(0)):this.Gt(t)}Mt(){this.Ut(0),this.Ut(1)}Nt(){this.Gt(0),this.Gt(1)}Ut(t){this.Qt(1),this.buffer[this.position++]=t}Gt(t){this.Qt(1),this.buffer[this.position++]=~t}Qt(t){const e=t+this.position;if(e<=this.buffer.length)return;let n=2*this.buffer.length;n<e&&(n=e);const i=new Uint8Array(n);i.set(this.buffer),this.buffer=i}}class Gp{constructor(t){this.jt=t}gt(t){this.jt.Ct(t)}Rt(t){this.jt.Lt(t)}At(t){this.jt.kt(t)}Et(){this.jt.$t()}}class Kp{constructor(t){this.jt=t}gt(t){this.jt.xt(t)}Rt(t){this.jt.Bt(t)}At(t){this.jt.Kt(t)}Et(){this.jt.Wt()}}class Tr{constructor(){this.jt=new jp,this.Ht=new Gp(this.jt),this.Jt=new Kp(this.jt)}seed(t){this.jt.seed(t)}Yt(t){return t===0?this.Ht:this.Jt}zt(){return this.jt.zt()}reset(){this.jt.reset()}}/**
1317
1317
  * @license
1318
1318
  * Copyright 2022 Google LLC
1319
1319
  *
@@ -1328,7 +1328,7 @@ SPDX-License-Identifier: Apache-2.0
1328
1328
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1329
1329
  * See the License for the specific language governing permissions and
1330
1330
  * limitations under the License.
1331
- */class Qe{constructor(t,e,n,i){this.indexId=t,this.documentKey=e,this.arrayValue=n,this.directionalValue=i}Zt(){const t=this.directionalValue.length,e=t===0||this.directionalValue[t-1]===255?t+1:t,n=new Uint8Array(e);return n.set(this.directionalValue,0),e!==t?n.set([0],this.directionalValue.length):++n[n.length-1],new Qe(this.indexId,this.documentKey,this.arrayValue,n)}}function de(r,t){let e=r.indexId-t.indexId;return e!==0?e:(e=bc(r.arrayValue,t.arrayValue),e!==0?e:(e=bc(r.directionalValue,t.directionalValue),e!==0?e:M.comparator(r.documentKey,t.documentKey)))}function bc(r,t){for(let e=0;e<r.length&&e<t.length;++e){const n=r[e]-t[e];if(n!==0)return n}return r.length-t.length}/**
1331
+ */class We{constructor(t,e,n,i){this.indexId=t,this.documentKey=e,this.arrayValue=n,this.directionalValue=i}Zt(){const t=this.directionalValue.length,e=t===0||this.directionalValue[t-1]===255?t+1:t,n=new Uint8Array(e);return n.set(this.directionalValue,0),e!==t?n.set([0],this.directionalValue.length):++n[n.length-1],new We(this.indexId,this.documentKey,this.arrayValue,n)}}function de(r,t){let e=r.indexId-t.indexId;return e!==0?e:(e=bc(r.arrayValue,t.arrayValue),e!==0?e:(e=bc(r.directionalValue,t.directionalValue),e!==0?e:M.comparator(r.documentKey,t.documentKey)))}function bc(r,t){for(let e=0;e<r.length&&e<t.length;++e){const n=r[e]-t[e];if(n!==0)return n}return r.length-t.length}/**
1332
1332
  * @license
1333
1333
  * Copyright 2022 Google LLC
1334
1334
  *
@@ -1343,7 +1343,7 @@ SPDX-License-Identifier: Apache-2.0
1343
1343
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1344
1344
  * See the License for the specific language governing permissions and
1345
1345
  * limitations under the License.
1346
- */class Pc{constructor(t){this.Xt=new et((e,n)=>at.comparator(e.field,n.field)),this.collectionId=t.collectionGroup!=null?t.collectionGroup:t.path.lastSegment(),this.en=t.orderBy,this.tn=[];for(const e of t.filters){const n=e;n.isInequality()?this.Xt=this.Xt.add(n):this.tn.push(n)}}get nn(){return this.Xt.size>1}rn(t){if(L(t.collectionGroup===this.collectionId),this.nn)return!1;const e=go(t);if(e!==void 0&&!this.sn(e))return!1;const n=je(t);let i=new Set,s=0,a=0;for(;s<n.length&&this.sn(n[s]);++s)i=i.add(n[s].fieldPath.canonicalString());if(s===n.length)return!0;if(this.Xt.size>0){const u=this.Xt.getIterator().getNext();if(!i.has(u.field.canonicalString())){const c=n[s];if(!this.on(u,c)||!this._n(this.en[a++],c))return!1}++s}for(;s<n.length;++s){const u=n[s];if(a>=this.en.length||!this._n(this.en[a++],u))return!1}return!0}an(){if(this.nn)return null;let t=new et(at.comparator);const e=[];for(const n of this.tn)if(!n.field.isKeyField())if(n.op==="array-contains"||n.op==="array-contains-any")e.push(new Je(n.field,2));else{if(t.has(n.field))continue;t=t.add(n.field),e.push(new Je(n.field,0))}for(const n of this.en)n.field.isKeyField()||t.has(n.field)||(t=t.add(n.field),e.push(new Je(n.field,n.dir==="asc"?0:1)));return new Cn(Cn.UNKNOWN_ID,this.collectionId,e,Dn.empty())}sn(t){for(const e of this.tn)if(this.on(e,t))return!0;return!1}on(t,e){if(t===void 0||!t.field.isEqual(e.fieldPath))return!1;const n=t.op==="array-contains"||t.op==="array-contains-any";return e.kind===2===n}_n(t,e){return!!t.field.isEqual(e.fieldPath)&&(e.kind===0&&t.dir==="asc"||e.kind===1&&t.dir==="desc")}}/**
1346
+ */class Pc{constructor(t){this.Xt=new et((e,n)=>at.comparator(e.field,n.field)),this.collectionId=t.collectionGroup!=null?t.collectionGroup:t.path.lastSegment(),this.en=t.orderBy,this.tn=[];for(const e of t.filters){const n=e;n.isInequality()?this.Xt=this.Xt.add(n):this.tn.push(n)}}get nn(){return this.Xt.size>1}rn(t){if(L(t.collectionGroup===this.collectionId),this.nn)return!1;const e=go(t);if(e!==void 0&&!this.sn(e))return!1;const n=Ge(t);let i=new Set,s=0,a=0;for(;s<n.length&&this.sn(n[s]);++s)i=i.add(n[s].fieldPath.canonicalString());if(s===n.length)return!0;if(this.Xt.size>0){const u=this.Xt.getIterator().getNext();if(!i.has(u.field.canonicalString())){const c=n[s];if(!this.on(u,c)||!this._n(this.en[a++],c))return!1}++s}for(;s<n.length;++s){const u=n[s];if(a>=this.en.length||!this._n(this.en[a++],u))return!1}return!0}an(){if(this.nn)return null;let t=new et(at.comparator);const e=[];for(const n of this.tn)if(!n.field.isKeyField())if(n.op==="array-contains"||n.op==="array-contains-any")e.push(new Ye(n.field,2));else{if(t.has(n.field))continue;t=t.add(n.field),e.push(new Ye(n.field,0))}for(const n of this.en)n.field.isKeyField()||t.has(n.field)||(t=t.add(n.field),e.push(new Ye(n.field,n.dir==="asc"?0:1)));return new Dn(Dn.UNKNOWN_ID,this.collectionId,e,xn.empty())}sn(t){for(const e of this.tn)if(this.on(e,t))return!0;return!1}on(t,e){if(t===void 0||!t.field.isEqual(e.fieldPath))return!1;const n=t.op==="array-contains"||t.op==="array-contains-any";return e.kind===2===n}_n(t,e){return!!t.field.isEqual(e.fieldPath)&&(e.kind===0&&t.dir==="asc"||e.kind===1&&t.dir==="desc")}}/**
1347
1347
  * @license
1348
1348
  * Copyright 2022 Google LLC
1349
1349
  *
@@ -1358,7 +1358,7 @@ SPDX-License-Identifier: Apache-2.0
1358
1358
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1359
1359
  * See the License for the specific language governing permissions and
1360
1360
  * limitations under the License.
1361
- */function Gh(r){var t,e;if(L(r instanceof H||r instanceof tt),r instanceof H){if(r instanceof oh){const i=((e=(t=r.value.arrayValue)===null||t===void 0?void 0:t.values)===null||e===void 0?void 0:e.map(s=>H.create(r.field,"==",s)))||[];return tt.create(i,"or")}return r}const n=r.filters.map(i=>Gh(i));return tt.create(n,r.op)}function $p(r){if(r.getFilters().length===0)return[];const t=Vo(Gh(r));return L(Kh(t)),Po(t)||So(t)?[t]:t.getFilters()}function Po(r){return r instanceof H}function So(r){return r instanceof tt&&jo(r)}function Kh(r){return Po(r)||So(r)||function(e){if(e instanceof tt&&Io(e)){for(const n of e.getFilters())if(!Po(n)&&!So(n))return!1;return!0}return!1}(r)}function Vo(r){if(L(r instanceof H||r instanceof tt),r instanceof H)return r;if(r.filters.length===1)return Vo(r.filters[0]);const t=r.filters.map(n=>Vo(n));let e=tt.create(t,r.op);return e=Xi(e),Kh(e)?e:(L(e instanceof tt),L(Nn(e)),L(e.filters.length>1),e.filters.reduce((n,i)=>ta(n,i)))}function ta(r,t){let e;return L(r instanceof H||r instanceof tt),L(t instanceof H||t instanceof tt),e=r instanceof H?t instanceof H?function(i,s){return tt.create([i,s],"and")}(r,t):Sc(r,t):t instanceof H?Sc(t,r):function(i,s){if(L(i.filters.length>0&&s.filters.length>0),Nn(i)&&Nn(s))return rh(i,s.getFilters());const a=Io(i)?i:s,u=Io(i)?s:i,c=a.filters.map(h=>ta(h,u));return tt.create(c,"or")}(r,t),Xi(e)}function Sc(r,t){if(Nn(t))return rh(t,r.getFilters());{const e=t.filters.map(n=>ta(r,n));return tt.create(e,"or")}}function Xi(r){if(L(r instanceof H||r instanceof tt),r instanceof H)return r;const t=r.getFilters();if(t.length===1)return Xi(t[0]);if(eh(r))return r;const e=t.map(i=>Xi(i)),n=[];return e.forEach(i=>{i instanceof H?n.push(i):i instanceof tt&&(i.op===r.op?n.push(...i.filters):n.push(i))}),n.length===1?n[0]:tt.create(n,r.op)}/**
1361
+ */function Gh(r){var t,e;if(L(r instanceof H||r instanceof tt),r instanceof H){if(r instanceof oh){const i=((e=(t=r.value.arrayValue)===null||t===void 0?void 0:t.values)===null||e===void 0?void 0:e.map(s=>H.create(r.field,"==",s)))||[];return tt.create(i,"or")}return r}const n=r.filters.map(i=>Gh(i));return tt.create(n,r.op)}function $p(r){if(r.getFilters().length===0)return[];const t=Vo(Gh(r));return L(Kh(t)),Po(t)||So(t)?[t]:t.getFilters()}function Po(r){return r instanceof H}function So(r){return r instanceof tt&&jo(r)}function Kh(r){return Po(r)||So(r)||function(e){if(e instanceof tt&&Io(e)){for(const n of e.getFilters())if(!Po(n)&&!So(n))return!1;return!0}return!1}(r)}function Vo(r){if(L(r instanceof H||r instanceof tt),r instanceof H)return r;if(r.filters.length===1)return Vo(r.filters[0]);const t=r.filters.map(n=>Vo(n));let e=tt.create(t,r.op);return e=Xi(e),Kh(e)?e:(L(e instanceof tt),L(kn(e)),L(e.filters.length>1),e.filters.reduce((n,i)=>ta(n,i)))}function ta(r,t){let e;return L(r instanceof H||r instanceof tt),L(t instanceof H||t instanceof tt),e=r instanceof H?t instanceof H?function(i,s){return tt.create([i,s],"and")}(r,t):Sc(r,t):t instanceof H?Sc(t,r):function(i,s){if(L(i.filters.length>0&&s.filters.length>0),kn(i)&&kn(s))return rh(i,s.getFilters());const a=Io(i)?i:s,u=Io(i)?s:i,c=a.filters.map(h=>ta(h,u));return tt.create(c,"or")}(r,t),Xi(e)}function Sc(r,t){if(kn(t))return rh(t,r.getFilters());{const e=t.filters.map(n=>ta(r,n));return tt.create(e,"or")}}function Xi(r){if(L(r instanceof H||r instanceof tt),r instanceof H)return r;const t=r.getFilters();if(t.length===1)return Xi(t[0]);if(eh(r))return r;const e=t.map(i=>Xi(i)),n=[];return e.forEach(i=>{i instanceof H?n.push(i):i instanceof tt&&(i.op===r.op?n.push(...i.filters):n.push(i))}),n.length===1?n[0]:tt.create(n,r.op)}/**
1362
1362
  * @license
1363
1363
  * Copyright 2019 Google LLC
1364
1364
  *
@@ -1388,7 +1388,7 @@ SPDX-License-Identifier: Apache-2.0
1388
1388
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1389
1389
  * See the License for the specific language governing permissions and
1390
1390
  * limitations under the License.
1391
- */const Di=new Uint8Array(0);class Wp{constructor(t,e){this.databaseId=e,this.cn=new ea,this.ln=new se(n=>Ze(n),(n,i)=>Hr(n,i)),this.uid=t.uid||""}addToCollectionParentIndex(t,e){if(!this.cn.has(e)){const n=e.lastSegment(),i=e.popLast();t.addOnCommittedListener(()=>{this.cn.add(e)});const s={collectionId:n,parent:Nt(i)};return Vc(t).put(s)}return w.resolve()}getCollectionParents(t,e){const n=[],i=IDBKeyRange.bound([e,""],[Ol(e),""],!1,!0);return Vc(t).U(i).next(s=>{for(const a of s){if(a.collectionId!==e)break;n.push($t(a.parent))}return n})}addFieldIndex(t,e){const n=Tr(t),i=function(u){return{indexId:u.indexId,collectionGroup:u.collectionGroup,fields:u.fields.map(c=>[c.fieldPath.canonicalString(),c.kind])}}(e);delete i.indexId;const s=n.add(i);if(e.indexState){const a=yn(t);return s.next(u=>{a.put(vc(u,this.uid,e.indexState.sequenceNumber,e.indexState.offset))})}return s.next()}deleteFieldIndex(t,e){const n=Tr(t),i=yn(t),s=_n(t);return n.delete(e.indexId).next(()=>i.delete(IDBKeyRange.bound([e.indexId],[e.indexId+1],!1,!0))).next(()=>s.delete(IDBKeyRange.bound([e.indexId],[e.indexId+1],!1,!0)))}deleteAllFieldIndexes(t){const e=Tr(t),n=_n(t),i=yn(t);return e.j().next(()=>n.j()).next(()=>i.j())}createTargetIndexes(t,e){return w.forEach(this.hn(e),n=>this.getIndexType(t,n).next(i=>{if(i===0||i===1){const s=new Pc(n).an();if(s!=null)return this.addFieldIndex(t,s)}}))}getDocumentsMatchingTarget(t,e){const n=_n(t);let i=!0;const s=new Map;return w.forEach(this.hn(e),a=>this.Pn(t,a).next(u=>{i&&(i=!!u),s.set(a,u)})).next(()=>{if(i){let a=G();const u=[];return w.forEach(s,(c,h)=>{x("IndexedDbIndexManager",`Using index ${function(B){return`id=${B.indexId}|cg=${B.collectionGroup}|f=${B.fields.map($=>`${$.fieldPath}:${$.kind}`).join(",")}`}(c)} to execute ${Ze(e)}`);const f=function(B,$){const Z=go($);if(Z===void 0)return null;for(const K of Wi(B,Z.fieldPath))switch(K.op){case"array-contains-any":return K.value.arrayValue.values||[];case"array-contains":return[K.value]}return null}(h,c),g=function(B,$){const Z=new Map;for(const K of je($))for(const E of Wi(B,K.fieldPath))switch(E.op){case"==":case"in":Z.set(K.fieldPath.canonicalString(),E.value);break;case"not-in":case"!=":return Z.set(K.fieldPath.canonicalString(),E.value),Array.from(Z.values())}return null}(h,c),_=function(B,$){const Z=[];let K=!0;for(const E of je($)){const p=E.kind===0?ac(B,E.fieldPath,B.startAt):uc(B,E.fieldPath,B.startAt);Z.push(p.value),K&&(K=p.inclusive)}return new Re(Z,K)}(h,c),R=function(B,$){const Z=[];let K=!0;for(const E of je($)){const p=E.kind===0?uc(B,E.fieldPath,B.endAt):ac(B,E.fieldPath,B.endAt);Z.push(p.value),K&&(K=p.inclusive)}return new Re(Z,K)}(h,c),C=this.In(c,h,_),N=this.In(c,h,R),V=this.Tn(c,h,g),q=this.En(c.indexId,f,C,_.inclusive,N,R.inclusive,V);return w.forEach(q,z=>n.G(z,e.limit).next(B=>{B.forEach($=>{const Z=M.fromSegments($.documentKey);a.has(Z)||(a=a.add(Z),u.push(Z))})}))}).next(()=>u)}return w.resolve(null)})}hn(t){let e=this.ln.get(t);return e||(t.filters.length===0?e=[t]:e=$p(tt.create(t.filters,"and")).map(n=>To(t.path,t.collectionGroup,t.orderBy,n.getFilters(),t.limit,t.startAt,t.endAt)),this.ln.set(t,e),e)}En(t,e,n,i,s,a,u){const c=(e!=null?e.length:1)*Math.max(n.length,s.length),h=c/(e!=null?e.length:1),f=[];for(let g=0;g<c;++g){const _=e?this.dn(e[g/h]):Di,R=this.An(t,_,n[g%h],i),C=this.Rn(t,_,s[g%h],a),N=u.map(V=>this.An(t,_,V,!0));f.push(...this.createRange(R,C,N))}return f}An(t,e,n,i){const s=new Qe(t,M.empty(),e,n);return i?s:s.Zt()}Rn(t,e,n,i){const s=new Qe(t,M.empty(),e,n);return i?s.Zt():s}Pn(t,e){const n=new Pc(e),i=e.collectionGroup!=null?e.collectionGroup:e.path.lastSegment();return this.getFieldIndexes(t,i).next(s=>{let a=null;for(const u of s)n.rn(u)&&(!a||u.fields.length>a.fields.length)&&(a=u);return a})}getIndexType(t,e){let n=2;const i=this.hn(e);return w.forEach(i,s=>this.Pn(t,s).next(a=>{a?n!==0&&a.fields.length<function(c){let h=new et(at.comparator),f=!1;for(const g of c.filters)for(const _ of g.getFlattenedFilters())_.field.isKeyField()||(_.op==="array-contains"||_.op==="array-contains-any"?f=!0:h=h.add(_.field));for(const g of c.orderBy)g.field.isKeyField()||(h=h.add(g.field));return h.size+(f?1:0)}(s)&&(n=1):n=0})).next(()=>function(a){return a.limit!==null}(e)&&i.length>1&&n===2?1:n)}Vn(t,e){const n=new Er;for(const i of je(t)){const s=e.data.field(i.fieldPath);if(s==null)return null;const a=n.Yt(i.kind);$e.vt.It(s,a)}return n.zt()}dn(t){const e=new Er;return $e.vt.It(t,e.Yt(0)),e.zt()}mn(t,e){const n=new Er;return $e.vt.It(Xe(this.databaseId,e),n.Yt(function(s){const a=je(s);return a.length===0?0:a[a.length-1].kind}(t))),n.zt()}Tn(t,e,n){if(n===null)return[];let i=[];i.push(new Er);let s=0;for(const a of je(t)){const u=n[s++];for(const c of i)if(this.fn(e,a.fieldPath)&&qr(u))i=this.gn(i,a,u);else{const h=c.Yt(a.kind);$e.vt.It(u,h)}}return this.pn(i)}In(t,e,n){return this.Tn(t,e,n.position)}pn(t){const e=[];for(let n=0;n<t.length;++n)e[n]=t[n].zt();return e}gn(t,e,n){const i=[...t],s=[];for(const a of n.arrayValue.values||[])for(const u of i){const c=new Er;c.seed(u.zt()),$e.vt.It(a,c.Yt(e.kind)),s.push(c)}return s}fn(t,e){return!!t.filters.find(n=>n instanceof H&&n.field.isEqual(e)&&(n.op==="in"||n.op==="not-in"))}getFieldIndexes(t,e){const n=Tr(t),i=yn(t);return(e?n.U("collectionGroupIndex",IDBKeyRange.bound(e,e)):n.U()).next(s=>{const a=[];return w.forEach(s,u=>i.get([u.indexId,this.uid]).next(c=>{a.push(function(f,g){const _=g?new Dn(g.sequenceNumber,new zt(rn(g.readTime),new M($t(g.documentKey)),g.largestBatchId)):Dn.empty(),R=f.fields.map(([C,N])=>new Je(at.fromServerFormat(C),N));return new Cn(f.indexId,f.collectionGroup,R,_)}(u,c))})).next(()=>a)})}getNextCollectionGroupToUpdate(t){return this.getFieldIndexes(t).next(e=>e.length===0?null:(e.sort((n,i)=>{const s=n.indexState.sequenceNumber-i.indexState.sequenceNumber;return s!==0?s:j(n.collectionGroup,i.collectionGroup)}),e[0].collectionGroup))}updateCollectionGroup(t,e,n){const i=Tr(t),s=yn(t);return this.yn(t).next(a=>i.U("collectionGroupIndex",IDBKeyRange.bound(e,e)).next(u=>w.forEach(u,c=>s.put(vc(c.indexId,this.uid,a,n)))))}updateIndexEntries(t,e){const n=new Map;return w.forEach(e,(i,s)=>{const a=n.get(i.collectionGroup);return(a?w.resolve(a):this.getFieldIndexes(t,i.collectionGroup)).next(u=>(n.set(i.collectionGroup,u),w.forEach(u,c=>this.wn(t,i,c).next(h=>{const f=this.Sn(s,c);return h.isEqual(f)?w.resolve():this.bn(t,s,c,h,f)}))))})}Dn(t,e,n,i){return _n(t).put({indexId:i.indexId,uid:this.uid,arrayValue:i.arrayValue,directionalValue:i.directionalValue,orderedDocumentKey:this.mn(n,e.key),documentKey:e.key.path.toArray()})}vn(t,e,n,i){return _n(t).delete([i.indexId,this.uid,i.arrayValue,i.directionalValue,this.mn(n,e.key),e.key.path.toArray()])}wn(t,e,n){const i=_n(t);let s=new et(de);return i.J({index:"documentKeyIndex",range:IDBKeyRange.only([n.indexId,this.uid,this.mn(n,e)])},(a,u)=>{s=s.add(new Qe(n.indexId,e,u.arrayValue,u.directionalValue))}).next(()=>s)}Sn(t,e){let n=new et(de);const i=this.Vn(e,t);if(i==null)return n;const s=go(e);if(s!=null){const a=t.data.field(s.fieldPath);if(qr(a))for(const u of a.arrayValue.values||[])n=n.add(new Qe(e.indexId,t.key,this.dn(u),i))}else n=n.add(new Qe(e.indexId,t.key,Di,i));return n}bn(t,e,n,i,s){x("IndexedDbIndexManager","Updating index entries for document '%s'",e.key);const a=[];return function(c,h,f,g,_){const R=c.getIterator(),C=h.getIterator();let N=pn(R),V=pn(C);for(;N||V;){let q=!1,z=!1;if(N&&V){const B=f(N,V);B<0?z=!0:B>0&&(q=!0)}else N!=null?z=!0:q=!0;q?(g(V),V=pn(C)):z?(_(N),N=pn(R)):(N=pn(R),V=pn(C))}}(i,s,de,u=>{a.push(this.Dn(t,e,n,u))},u=>{a.push(this.vn(t,e,n,u))}),w.waitFor(a)}yn(t){let e=1;return yn(t).J({index:"sequenceNumberIndex",reverse:!0,range:IDBKeyRange.upperBound([this.uid,Number.MAX_SAFE_INTEGER])},(n,i,s)=>{s.done(),e=i.sequenceNumber+1}).next(()=>e)}createRange(t,e,n){n=n.sort((a,u)=>de(a,u)).filter((a,u,c)=>!u||de(a,c[u-1])!==0);const i=[];i.push(t);for(const a of n){const u=de(a,t),c=de(a,e);if(u===0)i[0]=t.Zt();else if(u>0&&c<0)i.push(a),i.push(a.Zt());else if(c>0)break}i.push(e);const s=[];for(let a=0;a<i.length;a+=2){if(this.Cn(i[a],i[a+1]))return[];const u=[i[a].indexId,this.uid,i[a].arrayValue,i[a].directionalValue,Di,[]],c=[i[a+1].indexId,this.uid,i[a+1].arrayValue,i[a+1].directionalValue,Di,[]];s.push(IDBKeyRange.bound(u,c))}return s}Cn(t,e){return de(t,e)>0}getMinOffsetFromCollectionGroup(t,e){return this.getFieldIndexes(t,e).next(Cc)}getMinOffset(t,e){return w.mapArray(this.hn(e),n=>this.Pn(t,n).next(i=>i||O())).next(Cc)}}function Vc(r){return It(r,"collectionParents")}function _n(r){return It(r,"indexEntries")}function Tr(r){return It(r,"indexConfiguration")}function yn(r){return It(r,"indexState")}function Cc(r){L(r.length!==0);let t=r[0].indexState.offset,e=t.largestBatchId;for(let n=1;n<r.length;n++){const i=r[n].indexState.offset;Uo(i,t)<0&&(t=i),e<i.largestBatchId&&(e=i.largestBatchId)}return new zt(t.readTime,t.documentKey,e)}/**
1391
+ */const Di=new Uint8Array(0);class Wp{constructor(t,e){this.databaseId=e,this.cn=new ea,this.ln=new se(n=>tn(n),(n,i)=>Hr(n,i)),this.uid=t.uid||""}addToCollectionParentIndex(t,e){if(!this.cn.has(e)){const n=e.lastSegment(),i=e.popLast();t.addOnCommittedListener(()=>{this.cn.add(e)});const s={collectionId:n,parent:Nt(i)};return Vc(t).put(s)}return w.resolve()}getCollectionParents(t,e){const n=[],i=IDBKeyRange.bound([e,""],[Ol(e),""],!1,!0);return Vc(t).U(i).next(s=>{for(const a of s){if(a.collectionId!==e)break;n.push($t(a.parent))}return n})}addFieldIndex(t,e){const n=vr(t),i=function(u){return{indexId:u.indexId,collectionGroup:u.collectionGroup,fields:u.fields.map(c=>[c.fieldPath.canonicalString(),c.kind])}}(e);delete i.indexId;const s=n.add(i);if(e.indexState){const a=In(t);return s.next(u=>{a.put(vc(u,this.uid,e.indexState.sequenceNumber,e.indexState.offset))})}return s.next()}deleteFieldIndex(t,e){const n=vr(t),i=In(t),s=yn(t);return n.delete(e.indexId).next(()=>i.delete(IDBKeyRange.bound([e.indexId],[e.indexId+1],!1,!0))).next(()=>s.delete(IDBKeyRange.bound([e.indexId],[e.indexId+1],!1,!0)))}deleteAllFieldIndexes(t){const e=vr(t),n=yn(t),i=In(t);return e.j().next(()=>n.j()).next(()=>i.j())}createTargetIndexes(t,e){return w.forEach(this.hn(e),n=>this.getIndexType(t,n).next(i=>{if(i===0||i===1){const s=new Pc(n).an();if(s!=null)return this.addFieldIndex(t,s)}}))}getDocumentsMatchingTarget(t,e){const n=yn(t);let i=!0;const s=new Map;return w.forEach(this.hn(e),a=>this.Pn(t,a).next(u=>{i&&(i=!!u),s.set(a,u)})).next(()=>{if(i){let a=G();const u=[];return w.forEach(s,(c,h)=>{x("IndexedDbIndexManager",`Using index ${function(B){return`id=${B.indexId}|cg=${B.collectionGroup}|f=${B.fields.map($=>`${$.fieldPath}:${$.kind}`).join(",")}`}(c)} to execute ${tn(e)}`);const f=function(B,$){const Z=go($);if(Z===void 0)return null;for(const K of Wi(B,Z.fieldPath))switch(K.op){case"array-contains-any":return K.value.arrayValue.values||[];case"array-contains":return[K.value]}return null}(h,c),g=function(B,$){const Z=new Map;for(const K of Ge($))for(const E of Wi(B,K.fieldPath))switch(E.op){case"==":case"in":Z.set(K.fieldPath.canonicalString(),E.value);break;case"not-in":case"!=":return Z.set(K.fieldPath.canonicalString(),E.value),Array.from(Z.values())}return null}(h,c),_=function(B,$){const Z=[];let K=!0;for(const E of Ge($)){const p=E.kind===0?ac(B,E.fieldPath,B.startAt):uc(B,E.fieldPath,B.startAt);Z.push(p.value),K&&(K=p.inclusive)}return new be(Z,K)}(h,c),R=function(B,$){const Z=[];let K=!0;for(const E of Ge($)){const p=E.kind===0?uc(B,E.fieldPath,B.endAt):ac(B,E.fieldPath,B.endAt);Z.push(p.value),K&&(K=p.inclusive)}return new be(Z,K)}(h,c),C=this.In(c,h,_),N=this.In(c,h,R),V=this.Tn(c,h,g),q=this.En(c.indexId,f,C,_.inclusive,N,R.inclusive,V);return w.forEach(q,z=>n.G(z,e.limit).next(B=>{B.forEach($=>{const Z=M.fromSegments($.documentKey);a.has(Z)||(a=a.add(Z),u.push(Z))})}))}).next(()=>u)}return w.resolve(null)})}hn(t){let e=this.ln.get(t);return e||(t.filters.length===0?e=[t]:e=$p(tt.create(t.filters,"and")).map(n=>To(t.path,t.collectionGroup,t.orderBy,n.getFilters(),t.limit,t.startAt,t.endAt)),this.ln.set(t,e),e)}En(t,e,n,i,s,a,u){const c=(e!=null?e.length:1)*Math.max(n.length,s.length),h=c/(e!=null?e.length:1),f=[];for(let g=0;g<c;++g){const _=e?this.dn(e[g/h]):Di,R=this.An(t,_,n[g%h],i),C=this.Rn(t,_,s[g%h],a),N=u.map(V=>this.An(t,_,V,!0));f.push(...this.createRange(R,C,N))}return f}An(t,e,n,i){const s=new We(t,M.empty(),e,n);return i?s:s.Zt()}Rn(t,e,n,i){const s=new We(t,M.empty(),e,n);return i?s.Zt():s}Pn(t,e){const n=new Pc(e),i=e.collectionGroup!=null?e.collectionGroup:e.path.lastSegment();return this.getFieldIndexes(t,i).next(s=>{let a=null;for(const u of s)n.rn(u)&&(!a||u.fields.length>a.fields.length)&&(a=u);return a})}getIndexType(t,e){let n=2;const i=this.hn(e);return w.forEach(i,s=>this.Pn(t,s).next(a=>{a?n!==0&&a.fields.length<function(c){let h=new et(at.comparator),f=!1;for(const g of c.filters)for(const _ of g.getFlattenedFilters())_.field.isKeyField()||(_.op==="array-contains"||_.op==="array-contains-any"?f=!0:h=h.add(_.field));for(const g of c.orderBy)g.field.isKeyField()||(h=h.add(g.field));return h.size+(f?1:0)}(s)&&(n=1):n=0})).next(()=>function(a){return a.limit!==null}(e)&&i.length>1&&n===2?1:n)}Vn(t,e){const n=new Tr;for(const i of Ge(t)){const s=e.data.field(i.fieldPath);if(s==null)return null;const a=n.Yt(i.kind);Qe.vt.It(s,a)}return n.zt()}dn(t){const e=new Tr;return Qe.vt.It(t,e.Yt(0)),e.zt()}mn(t,e){const n=new Tr;return Qe.vt.It(Ze(this.databaseId,e),n.Yt(function(s){const a=Ge(s);return a.length===0?0:a[a.length-1].kind}(t))),n.zt()}Tn(t,e,n){if(n===null)return[];let i=[];i.push(new Tr);let s=0;for(const a of Ge(t)){const u=n[s++];for(const c of i)if(this.fn(e,a.fieldPath)&&zr(u))i=this.gn(i,a,u);else{const h=c.Yt(a.kind);Qe.vt.It(u,h)}}return this.pn(i)}In(t,e,n){return this.Tn(t,e,n.position)}pn(t){const e=[];for(let n=0;n<t.length;++n)e[n]=t[n].zt();return e}gn(t,e,n){const i=[...t],s=[];for(const a of n.arrayValue.values||[])for(const u of i){const c=new Tr;c.seed(u.zt()),Qe.vt.It(a,c.Yt(e.kind)),s.push(c)}return s}fn(t,e){return!!t.filters.find(n=>n instanceof H&&n.field.isEqual(e)&&(n.op==="in"||n.op==="not-in"))}getFieldIndexes(t,e){const n=vr(t),i=In(t);return(e?n.U("collectionGroupIndex",IDBKeyRange.bound(e,e)):n.U()).next(s=>{const a=[];return w.forEach(s,u=>i.get([u.indexId,this.uid]).next(c=>{a.push(function(f,g){const _=g?new xn(g.sequenceNumber,new zt(sn(g.readTime),new M($t(g.documentKey)),g.largestBatchId)):xn.empty(),R=f.fields.map(([C,N])=>new Ye(at.fromServerFormat(C),N));return new Dn(f.indexId,f.collectionGroup,R,_)}(u,c))})).next(()=>a)})}getNextCollectionGroupToUpdate(t){return this.getFieldIndexes(t).next(e=>e.length===0?null:(e.sort((n,i)=>{const s=n.indexState.sequenceNumber-i.indexState.sequenceNumber;return s!==0?s:j(n.collectionGroup,i.collectionGroup)}),e[0].collectionGroup))}updateCollectionGroup(t,e,n){const i=vr(t),s=In(t);return this.yn(t).next(a=>i.U("collectionGroupIndex",IDBKeyRange.bound(e,e)).next(u=>w.forEach(u,c=>s.put(vc(c.indexId,this.uid,a,n)))))}updateIndexEntries(t,e){const n=new Map;return w.forEach(e,(i,s)=>{const a=n.get(i.collectionGroup);return(a?w.resolve(a):this.getFieldIndexes(t,i.collectionGroup)).next(u=>(n.set(i.collectionGroup,u),w.forEach(u,c=>this.wn(t,i,c).next(h=>{const f=this.Sn(s,c);return h.isEqual(f)?w.resolve():this.bn(t,s,c,h,f)}))))})}Dn(t,e,n,i){return yn(t).put({indexId:i.indexId,uid:this.uid,arrayValue:i.arrayValue,directionalValue:i.directionalValue,orderedDocumentKey:this.mn(n,e.key),documentKey:e.key.path.toArray()})}vn(t,e,n,i){return yn(t).delete([i.indexId,this.uid,i.arrayValue,i.directionalValue,this.mn(n,e.key),e.key.path.toArray()])}wn(t,e,n){const i=yn(t);let s=new et(de);return i.J({index:"documentKeyIndex",range:IDBKeyRange.only([n.indexId,this.uid,this.mn(n,e)])},(a,u)=>{s=s.add(new We(n.indexId,e,u.arrayValue,u.directionalValue))}).next(()=>s)}Sn(t,e){let n=new et(de);const i=this.Vn(e,t);if(i==null)return n;const s=go(e);if(s!=null){const a=t.data.field(s.fieldPath);if(zr(a))for(const u of a.arrayValue.values||[])n=n.add(new We(e.indexId,t.key,this.dn(u),i))}else n=n.add(new We(e.indexId,t.key,Di,i));return n}bn(t,e,n,i,s){x("IndexedDbIndexManager","Updating index entries for document '%s'",e.key);const a=[];return function(c,h,f,g,_){const R=c.getIterator(),C=h.getIterator();let N=_n(R),V=_n(C);for(;N||V;){let q=!1,z=!1;if(N&&V){const B=f(N,V);B<0?z=!0:B>0&&(q=!0)}else N!=null?z=!0:q=!0;q?(g(V),V=_n(C)):z?(_(N),N=_n(R)):(N=_n(R),V=_n(C))}}(i,s,de,u=>{a.push(this.Dn(t,e,n,u))},u=>{a.push(this.vn(t,e,n,u))}),w.waitFor(a)}yn(t){let e=1;return In(t).J({index:"sequenceNumberIndex",reverse:!0,range:IDBKeyRange.upperBound([this.uid,Number.MAX_SAFE_INTEGER])},(n,i,s)=>{s.done(),e=i.sequenceNumber+1}).next(()=>e)}createRange(t,e,n){n=n.sort((a,u)=>de(a,u)).filter((a,u,c)=>!u||de(a,c[u-1])!==0);const i=[];i.push(t);for(const a of n){const u=de(a,t),c=de(a,e);if(u===0)i[0]=t.Zt();else if(u>0&&c<0)i.push(a),i.push(a.Zt());else if(c>0)break}i.push(e);const s=[];for(let a=0;a<i.length;a+=2){if(this.Cn(i[a],i[a+1]))return[];const u=[i[a].indexId,this.uid,i[a].arrayValue,i[a].directionalValue,Di,[]],c=[i[a+1].indexId,this.uid,i[a+1].arrayValue,i[a+1].directionalValue,Di,[]];s.push(IDBKeyRange.bound(u,c))}return s}Cn(t,e){return de(t,e)>0}getMinOffsetFromCollectionGroup(t,e){return this.getFieldIndexes(t,e).next(Cc)}getMinOffset(t,e){return w.mapArray(this.hn(e),n=>this.Pn(t,n).next(i=>i||O())).next(Cc)}}function Vc(r){return It(r,"collectionParents")}function yn(r){return It(r,"indexEntries")}function vr(r){return It(r,"indexConfiguration")}function In(r){return It(r,"indexState")}function Cc(r){L(r.length!==0);let t=r[0].indexState.offset,e=t.largestBatchId;for(let n=1;n<r.length;n++){const i=r[n].indexState.offset;Uo(i,t)<0&&(t=i),e<i.largestBatchId&&(e=i.largestBatchId)}return new zt(t.readTime,t.documentKey,e)}/**
1392
1392
  * @license
1393
1393
  * Copyright 2018 Google LLC
1394
1394
  *
@@ -1433,7 +1433,7 @@ SPDX-License-Identifier: Apache-2.0
1433
1433
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1434
1434
  * See the License for the specific language governing permissions and
1435
1435
  * limitations under the License.
1436
- */xt.DEFAULT_COLLECTION_PERCENTILE=10,xt.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,xt.DEFAULT=new xt(41943040,xt.DEFAULT_COLLECTION_PERCENTILE,xt.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),xt.DISABLED=new xt(-1,0,0);class gs{constructor(t,e,n,i){this.userId=t,this.serializer=e,this.indexManager=n,this.referenceDelegate=i,this.Fn={}}static lt(t,e,n,i){L(t.uid!=="");const s=t.isAuthenticated()?t.uid:"";return new gs(s,e,n,i)}checkEmpty(t){let e=!0;const n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return fe(t).J({index:"userMutationsIndex",range:n},(i,s,a)=>{e=!1,a.done()}).next(()=>e)}addMutationBatch(t,e,n,i){const s=wn(t),a=fe(t);return a.add({}).next(u=>{L(typeof u=="number");const c=new Wo(u,e,n,i),h=function(R,C,N){const V=N.baseMutations.map(z=>Gr(R.ct,z)),q=N.mutations.map(z=>Gr(R.ct,z));return{userId:C,batchId:N.batchId,localWriteTimeMs:N.localWriteTime.toMillis(),baseMutations:V,mutations:q}}(this.serializer,this.userId,c),f=[];let g=new et((_,R)=>j(_.canonicalString(),R.canonicalString()));for(const _ of i){const R=Gl(this.userId,_.key.path,u);g=g.add(_.key.path.popLast()),f.push(a.put(h)),f.push(s.put(R,Fg))}return g.forEach(_=>{f.push(this.indexManager.addToCollectionParentIndex(t,_))}),t.addOnCommittedListener(()=>{this.Fn[u]=c.keys()}),w.waitFor(f).next(()=>c)})}lookupMutationBatch(t,e){return fe(t).get(e).next(n=>n?(L(n.userId===this.userId),Ke(this.serializer,n)):null)}Mn(t,e){return this.Fn[e]?w.resolve(this.Fn[e]):this.lookupMutationBatch(t,e).next(n=>{if(n){const i=n.keys();return this.Fn[e]=i,i}return null})}getNextMutationBatchAfterBatchId(t,e){const n=e+1,i=IDBKeyRange.lowerBound([this.userId,n]);let s=null;return fe(t).J({index:"userMutationsIndex",range:i},(a,u,c)=>{u.userId===this.userId&&(L(u.batchId>=n),s=Ke(this.serializer,u)),c.done()}).next(()=>s)}getHighestUnacknowledgedBatchId(t){const e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let n=-1;return fe(t).J({index:"userMutationsIndex",range:e,reverse:!0},(i,s,a)=>{n=s.batchId,a.done()}).next(()=>n)}getAllMutationBatches(t){const e=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return fe(t).U("userMutationsIndex",e).next(n=>n.map(i=>Ke(this.serializer,i)))}getAllMutationBatchesAffectingDocumentKey(t,e){const n=Oi(this.userId,e.path),i=IDBKeyRange.lowerBound(n),s=[];return wn(t).J({range:i},(a,u,c)=>{const[h,f,g]=a,_=$t(f);if(h===this.userId&&e.path.isEqual(_))return fe(t).get(g).next(R=>{if(!R)throw O();L(R.userId===this.userId),s.push(Ke(this.serializer,R))});c.done()}).next(()=>s)}getAllMutationBatchesAffectingDocumentKeys(t,e){let n=new et(j);const i=[];return e.forEach(s=>{const a=Oi(this.userId,s.path),u=IDBKeyRange.lowerBound(a),c=wn(t).J({range:u},(h,f,g)=>{const[_,R,C]=h,N=$t(R);_===this.userId&&s.path.isEqual(N)?n=n.add(C):g.done()});i.push(c)}),w.waitFor(i).next(()=>this.xn(t,n))}getAllMutationBatchesAffectingQuery(t,e){const n=e.path,i=n.length+1,s=Oi(this.userId,n),a=IDBKeyRange.lowerBound(s);let u=new et(j);return wn(t).J({range:a},(c,h,f)=>{const[g,_,R]=c,C=$t(_);g===this.userId&&n.isPrefixOf(C)?C.length===i&&(u=u.add(R)):f.done()}).next(()=>this.xn(t,u))}xn(t,e){const n=[],i=[];return e.forEach(s=>{i.push(fe(t).get(s).next(a=>{if(a===null)throw O();L(a.userId===this.userId),n.push(Ke(this.serializer,a))}))}),w.waitFor(i).next(()=>n)}removeMutationBatch(t,e){return $h(t._e,this.userId,e).next(n=>(t.addOnCommittedListener(()=>{this.On(e.batchId)}),w.forEach(n,i=>this.referenceDelegate.markPotentiallyOrphaned(t,i))))}On(t){delete this.Fn[t]}performConsistencyCheck(t){return this.checkEmpty(t).next(e=>{if(!e)return w.resolve();const n=IDBKeyRange.lowerBound(function(a){return[a]}(this.userId)),i=[];return wn(t).J({range:n},(s,a,u)=>{if(s[0]===this.userId){const c=$t(s[1]);i.push(c)}else u.done()}).next(()=>{L(i.length===0)})})}containsKey(t,e){return Qh(t,this.userId,e)}Nn(t){return Wh(t).get(this.userId).next(e=>e||{userId:this.userId,lastAcknowledgedBatchId:-1,lastStreamToken:""})}}function Qh(r,t,e){const n=Oi(t,e.path),i=n[1],s=IDBKeyRange.lowerBound(n);let a=!1;return wn(r).J({range:s,H:!0},(u,c,h)=>{const[f,g,_]=u;f===t&&g===i&&(a=!0),h.done()}).next(()=>a)}function fe(r){return It(r,"mutations")}function wn(r){return It(r,"documentMutations")}function Wh(r){return It(r,"mutationQueues")}/**
1436
+ */xt.DEFAULT_COLLECTION_PERCENTILE=10,xt.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,xt.DEFAULT=new xt(41943040,xt.DEFAULT_COLLECTION_PERCENTILE,xt.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),xt.DISABLED=new xt(-1,0,0);class gs{constructor(t,e,n,i){this.userId=t,this.serializer=e,this.indexManager=n,this.referenceDelegate=i,this.Fn={}}static lt(t,e,n,i){L(t.uid!=="");const s=t.isAuthenticated()?t.uid:"";return new gs(s,e,n,i)}checkEmpty(t){let e=!0;const n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return fe(t).J({index:"userMutationsIndex",range:n},(i,s,a)=>{e=!1,a.done()}).next(()=>e)}addMutationBatch(t,e,n,i){const s=An(t),a=fe(t);return a.add({}).next(u=>{L(typeof u=="number");const c=new Wo(u,e,n,i),h=function(R,C,N){const V=N.baseMutations.map(z=>Kr(R.ct,z)),q=N.mutations.map(z=>Kr(R.ct,z));return{userId:C,batchId:N.batchId,localWriteTimeMs:N.localWriteTime.toMillis(),baseMutations:V,mutations:q}}(this.serializer,this.userId,c),f=[];let g=new et((_,R)=>j(_.canonicalString(),R.canonicalString()));for(const _ of i){const R=Gl(this.userId,_.key.path,u);g=g.add(_.key.path.popLast()),f.push(a.put(h)),f.push(s.put(R,Fg))}return g.forEach(_=>{f.push(this.indexManager.addToCollectionParentIndex(t,_))}),t.addOnCommittedListener(()=>{this.Fn[u]=c.keys()}),w.waitFor(f).next(()=>c)})}lookupMutationBatch(t,e){return fe(t).get(e).next(n=>n?(L(n.userId===this.userId),$e(this.serializer,n)):null)}Mn(t,e){return this.Fn[e]?w.resolve(this.Fn[e]):this.lookupMutationBatch(t,e).next(n=>{if(n){const i=n.keys();return this.Fn[e]=i,i}return null})}getNextMutationBatchAfterBatchId(t,e){const n=e+1,i=IDBKeyRange.lowerBound([this.userId,n]);let s=null;return fe(t).J({index:"userMutationsIndex",range:i},(a,u,c)=>{u.userId===this.userId&&(L(u.batchId>=n),s=$e(this.serializer,u)),c.done()}).next(()=>s)}getHighestUnacknowledgedBatchId(t){const e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let n=-1;return fe(t).J({index:"userMutationsIndex",range:e,reverse:!0},(i,s,a)=>{n=s.batchId,a.done()}).next(()=>n)}getAllMutationBatches(t){const e=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return fe(t).U("userMutationsIndex",e).next(n=>n.map(i=>$e(this.serializer,i)))}getAllMutationBatchesAffectingDocumentKey(t,e){const n=Oi(this.userId,e.path),i=IDBKeyRange.lowerBound(n),s=[];return An(t).J({range:i},(a,u,c)=>{const[h,f,g]=a,_=$t(f);if(h===this.userId&&e.path.isEqual(_))return fe(t).get(g).next(R=>{if(!R)throw O();L(R.userId===this.userId),s.push($e(this.serializer,R))});c.done()}).next(()=>s)}getAllMutationBatchesAffectingDocumentKeys(t,e){let n=new et(j);const i=[];return e.forEach(s=>{const a=Oi(this.userId,s.path),u=IDBKeyRange.lowerBound(a),c=An(t).J({range:u},(h,f,g)=>{const[_,R,C]=h,N=$t(R);_===this.userId&&s.path.isEqual(N)?n=n.add(C):g.done()});i.push(c)}),w.waitFor(i).next(()=>this.xn(t,n))}getAllMutationBatchesAffectingQuery(t,e){const n=e.path,i=n.length+1,s=Oi(this.userId,n),a=IDBKeyRange.lowerBound(s);let u=new et(j);return An(t).J({range:a},(c,h,f)=>{const[g,_,R]=c,C=$t(_);g===this.userId&&n.isPrefixOf(C)?C.length===i&&(u=u.add(R)):f.done()}).next(()=>this.xn(t,u))}xn(t,e){const n=[],i=[];return e.forEach(s=>{i.push(fe(t).get(s).next(a=>{if(a===null)throw O();L(a.userId===this.userId),n.push($e(this.serializer,a))}))}),w.waitFor(i).next(()=>n)}removeMutationBatch(t,e){return $h(t._e,this.userId,e).next(n=>(t.addOnCommittedListener(()=>{this.On(e.batchId)}),w.forEach(n,i=>this.referenceDelegate.markPotentiallyOrphaned(t,i))))}On(t){delete this.Fn[t]}performConsistencyCheck(t){return this.checkEmpty(t).next(e=>{if(!e)return w.resolve();const n=IDBKeyRange.lowerBound(function(a){return[a]}(this.userId)),i=[];return An(t).J({range:n},(s,a,u)=>{if(s[0]===this.userId){const c=$t(s[1]);i.push(c)}else u.done()}).next(()=>{L(i.length===0)})})}containsKey(t,e){return Qh(t,this.userId,e)}Nn(t){return Wh(t).get(this.userId).next(e=>e||{userId:this.userId,lastAcknowledgedBatchId:-1,lastStreamToken:""})}}function Qh(r,t,e){const n=Oi(t,e.path),i=n[1],s=IDBKeyRange.lowerBound(n);let a=!1;return An(r).J({range:s,H:!0},(u,c,h)=>{const[f,g,_]=u;f===t&&g===i&&(a=!0),h.done()}).next(()=>a)}function fe(r){return It(r,"mutations")}function An(r){return It(r,"documentMutations")}function Wh(r){return It(r,"mutationQueues")}/**
1437
1437
  * @license
1438
1438
  * Copyright 2017 Google LLC
1439
1439
  *
@@ -1448,7 +1448,7 @@ SPDX-License-Identifier: Apache-2.0
1448
1448
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1449
1449
  * See the License for the specific language governing permissions and
1450
1450
  * limitations under the License.
1451
- */class sn{constructor(t){this.Ln=t}next(){return this.Ln+=2,this.Ln}static Bn(){return new sn(0)}static kn(){return new sn(-1)}}/**
1451
+ */class on{constructor(t){this.Ln=t}next(){return this.Ln+=2,this.Ln}static Bn(){return new on(0)}static kn(){return new on(-1)}}/**
1452
1452
  * @license
1453
1453
  * Copyright 2017 Google LLC
1454
1454
  *
@@ -1463,7 +1463,7 @@ SPDX-License-Identifier: Apache-2.0
1463
1463
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1464
1464
  * See the License for the specific language governing permissions and
1465
1465
  * limitations under the License.
1466
- */class Hp{constructor(t,e){this.referenceDelegate=t,this.serializer=e}allocateTargetId(t){return this.qn(t).next(e=>{const n=new sn(e.highestTargetId);return e.highestTargetId=n.next(),this.Qn(t,e).next(()=>e.highestTargetId)})}getLastRemoteSnapshotVersion(t){return this.qn(t).next(e=>U.fromTimestamp(new lt(e.lastRemoteSnapshotVersion.seconds,e.lastRemoteSnapshotVersion.nanoseconds)))}getHighestSequenceNumber(t){return this.qn(t).next(e=>e.highestListenSequenceNumber)}setTargetsMetadata(t,e,n){return this.qn(t).next(i=>(i.highestListenSequenceNumber=e,n&&(i.lastRemoteSnapshotVersion=n.toTimestamp()),e>i.highestListenSequenceNumber&&(i.highestListenSequenceNumber=e),this.Qn(t,i)))}addTargetData(t,e){return this.Kn(t,e).next(()=>this.qn(t).next(n=>(n.targetCount+=1,this.$n(e,n),this.Qn(t,n))))}updateTargetData(t,e){return this.Kn(t,e)}removeTargetData(t,e){return this.removeMatchingKeysForTargetId(t,e.targetId).next(()=>In(t).delete(e.targetId)).next(()=>this.qn(t)).next(n=>(L(n.targetCount>0),n.targetCount-=1,this.Qn(t,n)))}removeTargets(t,e,n){let i=0;const s=[];return In(t).J((a,u)=>{const c=Pr(u);c.sequenceNumber<=e&&n.get(c.targetId)===null&&(i++,s.push(this.removeTargetData(t,c)))}).next(()=>w.waitFor(s)).next(()=>i)}forEachTarget(t,e){return In(t).J((n,i)=>{const s=Pr(i);e(s)})}qn(t){return xc(t).get("targetGlobalKey").next(e=>(L(e!==null),e))}Qn(t,e){return xc(t).put("targetGlobalKey",e)}Kn(t,e){return In(t).put(jh(this.serializer,e))}$n(t,e){let n=!1;return t.targetId>e.highestTargetId&&(e.highestTargetId=t.targetId,n=!0),t.sequenceNumber>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=t.sequenceNumber,n=!0),n}getTargetCount(t){return this.qn(t).next(e=>e.targetCount)}getTargetData(t,e){const n=Ze(e),i=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]);let s=null;return In(t).J({range:i,index:"queryTargetsIndex"},(a,u,c)=>{const h=Pr(u);Hr(e,h.target)&&(s=h,c.done())}).next(()=>s)}addMatchingKeys(t,e,n){const i=[],s=ge(t);return e.forEach(a=>{const u=Nt(a.path);i.push(s.put({targetId:n,path:u})),i.push(this.referenceDelegate.addReference(t,n,a))}),w.waitFor(i)}removeMatchingKeys(t,e,n){const i=ge(t);return w.forEach(e,s=>{const a=Nt(s.path);return w.waitFor([i.delete([n,a]),this.referenceDelegate.removeReference(t,n,s)])})}removeMatchingKeysForTargetId(t,e){const n=ge(t),i=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(i)}getMatchingKeysForTargetId(t,e){const n=IDBKeyRange.bound([e],[e+1],!1,!0),i=ge(t);let s=G();return i.J({range:n,H:!0},(a,u,c)=>{const h=$t(a[1]),f=new M(h);s=s.add(f)}).next(()=>s)}containsKey(t,e){const n=Nt(e.path),i=IDBKeyRange.bound([n],[Ol(n)],!1,!0);let s=0;return ge(t).J({index:"documentTargetsIndex",H:!0,range:i},([a,u],c,h)=>{a!==0&&(s++,h.done())}).next(()=>s>0)}ot(t,e){return In(t).get(e).next(n=>n?Pr(n):null)}}function In(r){return It(r,"targets")}function xc(r){return It(r,"targetGlobal")}function ge(r){return It(r,"targetDocuments")}/**
1466
+ */class Hp{constructor(t,e){this.referenceDelegate=t,this.serializer=e}allocateTargetId(t){return this.qn(t).next(e=>{const n=new on(e.highestTargetId);return e.highestTargetId=n.next(),this.Qn(t,e).next(()=>e.highestTargetId)})}getLastRemoteSnapshotVersion(t){return this.qn(t).next(e=>U.fromTimestamp(new lt(e.lastRemoteSnapshotVersion.seconds,e.lastRemoteSnapshotVersion.nanoseconds)))}getHighestSequenceNumber(t){return this.qn(t).next(e=>e.highestListenSequenceNumber)}setTargetsMetadata(t,e,n){return this.qn(t).next(i=>(i.highestListenSequenceNumber=e,n&&(i.lastRemoteSnapshotVersion=n.toTimestamp()),e>i.highestListenSequenceNumber&&(i.highestListenSequenceNumber=e),this.Qn(t,i)))}addTargetData(t,e){return this.Kn(t,e).next(()=>this.qn(t).next(n=>(n.targetCount+=1,this.$n(e,n),this.Qn(t,n))))}updateTargetData(t,e){return this.Kn(t,e)}removeTargetData(t,e){return this.removeMatchingKeysForTargetId(t,e.targetId).next(()=>En(t).delete(e.targetId)).next(()=>this.qn(t)).next(n=>(L(n.targetCount>0),n.targetCount-=1,this.Qn(t,n)))}removeTargets(t,e,n){let i=0;const s=[];return En(t).J((a,u)=>{const c=Sr(u);c.sequenceNumber<=e&&n.get(c.targetId)===null&&(i++,s.push(this.removeTargetData(t,c)))}).next(()=>w.waitFor(s)).next(()=>i)}forEachTarget(t,e){return En(t).J((n,i)=>{const s=Sr(i);e(s)})}qn(t){return xc(t).get("targetGlobalKey").next(e=>(L(e!==null),e))}Qn(t,e){return xc(t).put("targetGlobalKey",e)}Kn(t,e){return En(t).put(jh(this.serializer,e))}$n(t,e){let n=!1;return t.targetId>e.highestTargetId&&(e.highestTargetId=t.targetId,n=!0),t.sequenceNumber>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=t.sequenceNumber,n=!0),n}getTargetCount(t){return this.qn(t).next(e=>e.targetCount)}getTargetData(t,e){const n=tn(e),i=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]);let s=null;return En(t).J({range:i,index:"queryTargetsIndex"},(a,u,c)=>{const h=Sr(u);Hr(e,h.target)&&(s=h,c.done())}).next(()=>s)}addMatchingKeys(t,e,n){const i=[],s=ge(t);return e.forEach(a=>{const u=Nt(a.path);i.push(s.put({targetId:n,path:u})),i.push(this.referenceDelegate.addReference(t,n,a))}),w.waitFor(i)}removeMatchingKeys(t,e,n){const i=ge(t);return w.forEach(e,s=>{const a=Nt(s.path);return w.waitFor([i.delete([n,a]),this.referenceDelegate.removeReference(t,n,s)])})}removeMatchingKeysForTargetId(t,e){const n=ge(t),i=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(i)}getMatchingKeysForTargetId(t,e){const n=IDBKeyRange.bound([e],[e+1],!1,!0),i=ge(t);let s=G();return i.J({range:n,H:!0},(a,u,c)=>{const h=$t(a[1]),f=new M(h);s=s.add(f)}).next(()=>s)}containsKey(t,e){const n=Nt(e.path),i=IDBKeyRange.bound([n],[Ol(n)],!1,!0);let s=0;return ge(t).J({index:"documentTargetsIndex",H:!0,range:i},([a,u],c,h)=>{a!==0&&(s++,h.done())}).next(()=>s>0)}ot(t,e){return En(t).get(e).next(n=>n?Sr(n):null)}}function En(r){return It(r,"targets")}function xc(r){return It(r,"targetGlobal")}function ge(r){return It(r,"targetDocuments")}/**
1467
1467
  * @license
1468
1468
  * Copyright 2020 Google LLC
1469
1469
  *
@@ -1478,7 +1478,7 @@ SPDX-License-Identifier: Apache-2.0
1478
1478
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1479
1479
  * See the License for the specific language governing permissions and
1480
1480
  * limitations under the License.
1481
- */function Nc([r,t],[e,n]){const i=j(r,e);return i===0?j(t,n):i}class Jp{constructor(t){this.Un=t,this.buffer=new et(Nc),this.Wn=0}Gn(){return++this.Wn}zn(t){const e=[t,this.Gn()];if(this.buffer.size<this.Un)this.buffer=this.buffer.add(e);else{const n=this.buffer.last();Nc(e,n)<0&&(this.buffer=this.buffer.delete(n).add(e))}}get maxValue(){return this.buffer.last()[0]}}class Hh{constructor(t,e,n){this.garbageCollector=t,this.asyncQueue=e,this.localStore=n,this.jn=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.Hn(6e4)}stop(){this.jn&&(this.jn.cancel(),this.jn=null)}get started(){return this.jn!==null}Hn(t){x("LruGarbageCollector",`Garbage collection scheduled in ${t}ms`),this.jn=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",t,async()=>{this.jn=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){De(e)?x("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e):await Ce(e)}await this.Hn(3e5)})}}class Yp{constructor(t,e){this.Jn=t,this.params=e}calculateTargetCount(t,e){return this.Jn.Yn(t).next(n=>Math.floor(e/100*n))}nthSequenceNumber(t,e){if(e===0)return w.resolve(Ot.oe);const n=new Jp(e);return this.Jn.forEachTarget(t,i=>n.zn(i.sequenceNumber)).next(()=>this.Jn.Zn(t,i=>n.zn(i))).next(()=>n.maxValue)}removeTargets(t,e,n){return this.Jn.removeTargets(t,e,n)}removeOrphanedDocuments(t,e){return this.Jn.removeOrphanedDocuments(t,e)}collect(t,e){return this.params.cacheSizeCollectionThreshold===-1?(x("LruGarbageCollector","Garbage collection skipped; disabled"),w.resolve(Dc)):this.getCacheSize(t).next(n=>n<this.params.cacheSizeCollectionThreshold?(x("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Dc):this.Xn(t,e))}getCacheSize(t){return this.Jn.getCacheSize(t)}Xn(t,e){let n,i,s,a,u,c,h;const f=Date.now();return this.calculateTargetCount(t,this.params.percentileToCollect).next(g=>(g>this.params.maximumSequenceNumbersToCollect?(x("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${g}`),i=this.params.maximumSequenceNumbersToCollect):i=g,a=Date.now(),this.nthSequenceNumber(t,i))).next(g=>(n=g,u=Date.now(),this.removeTargets(t,n,e))).next(g=>(s=g,c=Date.now(),this.removeOrphanedDocuments(t,n))).next(g=>(h=Date.now(),En()<=J.DEBUG&&x("LruGarbageCollector",`LRU Garbage Collection
1481
+ */function Nc([r,t],[e,n]){const i=j(r,e);return i===0?j(t,n):i}class Jp{constructor(t){this.Un=t,this.buffer=new et(Nc),this.Wn=0}Gn(){return++this.Wn}zn(t){const e=[t,this.Gn()];if(this.buffer.size<this.Un)this.buffer=this.buffer.add(e);else{const n=this.buffer.last();Nc(e,n)<0&&(this.buffer=this.buffer.delete(n).add(e))}}get maxValue(){return this.buffer.last()[0]}}class Hh{constructor(t,e,n){this.garbageCollector=t,this.asyncQueue=e,this.localStore=n,this.jn=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.Hn(6e4)}stop(){this.jn&&(this.jn.cancel(),this.jn=null)}get started(){return this.jn!==null}Hn(t){x("LruGarbageCollector",`Garbage collection scheduled in ${t}ms`),this.jn=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",t,async()=>{this.jn=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){xe(e)?x("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e):await De(e)}await this.Hn(3e5)})}}class Yp{constructor(t,e){this.Jn=t,this.params=e}calculateTargetCount(t,e){return this.Jn.Yn(t).next(n=>Math.floor(e/100*n))}nthSequenceNumber(t,e){if(e===0)return w.resolve(Ot.oe);const n=new Jp(e);return this.Jn.forEachTarget(t,i=>n.zn(i.sequenceNumber)).next(()=>this.Jn.Zn(t,i=>n.zn(i))).next(()=>n.maxValue)}removeTargets(t,e,n){return this.Jn.removeTargets(t,e,n)}removeOrphanedDocuments(t,e){return this.Jn.removeOrphanedDocuments(t,e)}collect(t,e){return this.params.cacheSizeCollectionThreshold===-1?(x("LruGarbageCollector","Garbage collection skipped; disabled"),w.resolve(Dc)):this.getCacheSize(t).next(n=>n<this.params.cacheSizeCollectionThreshold?(x("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Dc):this.Xn(t,e))}getCacheSize(t){return this.Jn.getCacheSize(t)}Xn(t,e){let n,i,s,a,u,c,h;const f=Date.now();return this.calculateTargetCount(t,this.params.percentileToCollect).next(g=>(g>this.params.maximumSequenceNumbersToCollect?(x("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${g}`),i=this.params.maximumSequenceNumbersToCollect):i=g,a=Date.now(),this.nthSequenceNumber(t,i))).next(g=>(n=g,u=Date.now(),this.removeTargets(t,n,e))).next(g=>(s=g,c=Date.now(),this.removeOrphanedDocuments(t,n))).next(g=>(h=Date.now(),Tn()<=J.DEBUG&&x("LruGarbageCollector",`LRU Garbage Collection
1482
1482
  Counted targets in ${a-f}ms
1483
1483
  Determined least recently used ${i} in `+(u-a)+`ms
1484
1484
  Removed ${s} targets in `+(c-u)+`ms
@@ -1528,7 +1528,7 @@ Total Duration: ${h-f}ms`),w.resolve({didRun:!0,sequenceNumbersCollected:i,targe
1528
1528
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1529
1529
  * See the License for the specific language governing permissions and
1530
1530
  * limitations under the License.
1531
- */class Zp{constructor(t){this.serializer=t}setIndexManager(t){this.indexManager=t}addEntry(t,e,n){return qe(t).put(n)}removeEntry(t,e,n){return qe(t).delete(function(s,a){const u=s.path.toArray();return[u.slice(0,u.length-2),u[u.length-2],Yi(a),u[u.length-1]]}(e,n))}updateMetadata(t,e){return this.getMetadata(t).next(n=>(n.byteSize+=e,this.rr(t,n)))}getEntry(t,e){let n=ot.newInvalidDocument(e);return qe(t).J({index:"documentKeyIndex",range:IDBKeyRange.only(vr(e))},(i,s)=>{n=this.ir(e,s)}).next(()=>n)}sr(t,e){let n={size:0,document:ot.newInvalidDocument(e)};return qe(t).J({index:"documentKeyIndex",range:IDBKeyRange.only(vr(e))},(i,s)=>{n={document:this.ir(e,s),size:Zi(s)}}).next(()=>n)}getEntries(t,e){let n=Bt();return this._r(t,e,(i,s)=>{const a=this.ir(i,s);n=n.insert(i,a)}).next(()=>n)}ar(t,e){let n=Bt(),i=new it(M.comparator);return this._r(t,e,(s,a)=>{const u=this.ir(s,a);n=n.insert(s,u),i=i.insert(s,Zi(a))}).next(()=>({documents:n,ur:i}))}_r(t,e,n){if(e.isEmpty())return w.resolve();let i=new et(Mc);e.forEach(c=>i=i.add(c));const s=IDBKeyRange.bound(vr(i.first()),vr(i.last())),a=i.getIterator();let u=a.getNext();return qe(t).J({index:"documentKeyIndex",range:s},(c,h,f)=>{const g=M.fromSegments([...h.prefixPath,h.collectionGroup,h.documentId]);for(;u&&Mc(u,g)<0;)n(u,null),u=a.getNext();u&&u.isEqual(g)&&(n(u,h),u=a.hasNext()?a.getNext():null),u?f.$(vr(u)):f.done()}).next(()=>{for(;u;)n(u,null),u=a.hasNext()?a.getNext():null})}getDocumentsMatchingQuery(t,e,n,i,s){const a=e.path,u=[a.popLast().toArray(),a.lastSegment(),Yi(n.readTime),n.documentKey.path.isEmpty()?"":n.documentKey.path.lastSegment()],c=[a.popLast().toArray(),a.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];return qe(t).U(IDBKeyRange.bound(u,c,!0)).next(h=>{s==null||s.incrementDocumentReadCount(h.length);let f=Bt();for(const g of h){const _=this.ir(M.fromSegments(g.prefixPath.concat(g.collectionGroup,g.documentId)),g);_.isFoundDocument()&&(Yr(e,_)||i.has(_.key))&&(f=f.insert(_.key,_))}return f})}getAllFromCollectionGroup(t,e,n,i){let s=Bt();const a=Fc(e,n),u=Fc(e,zt.max());return qe(t).J({index:"collectionGroupIndex",range:IDBKeyRange.bound(a,u,!0)},(c,h,f)=>{const g=this.ir(M.fromSegments(h.prefixPath.concat(h.collectionGroup,h.documentId)),h);s=s.insert(g.key,g),s.size===i&&f.done()}).next(()=>s)}newChangeBuffer(t){return new t_(this,!!t&&t.trackRemovals)}getSize(t){return this.getMetadata(t).next(e=>e.byteSize)}getMetadata(t){return kc(t).get("remoteDocumentGlobalKey").next(e=>(L(!!e),e))}rr(t,e){return kc(t).put("remoteDocumentGlobalKey",e)}ir(t,e){if(e){const n=Bp(this.serializer,e);if(!(n.isNoDocument()&&n.version.isEqual(U.min())))return n}return ot.newInvalidDocument(t)}}function Xh(r){return new Zp(r)}class t_ extends Yh{constructor(t,e){super(),this.cr=t,this.trackRemovals=e,this.lr=new se(n=>n.toString(),(n,i)=>n.isEqual(i))}applyChanges(t){const e=[];let n=0,i=new et((s,a)=>j(s.canonicalString(),a.canonicalString()));return this.changes.forEach((s,a)=>{const u=this.lr.get(s);if(e.push(this.cr.removeEntry(t,s,u.readTime)),a.isValidDocument()){const c=Ec(this.cr.serializer,a);i=i.add(s.path.popLast());const h=Zi(c);n+=h-u.size,e.push(this.cr.addEntry(t,s,c))}else if(n-=u.size,this.trackRemovals){const c=Ec(this.cr.serializer,a.convertToNoDocument(U.min()));e.push(this.cr.addEntry(t,s,c))}}),i.forEach(s=>{e.push(this.cr.indexManager.addToCollectionParentIndex(t,s))}),e.push(this.cr.updateMetadata(t,n)),w.waitFor(e)}getFromCache(t,e){return this.cr.sr(t,e).next(n=>(this.lr.set(e,{size:n.size,readTime:n.document.readTime}),n.document))}getAllFromCache(t,e){return this.cr.ar(t,e).next(({documents:n,ur:i})=>(i.forEach((s,a)=>{this.lr.set(s,{size:a,readTime:n.get(s).readTime})}),n))}}function kc(r){return It(r,"remoteDocumentGlobal")}function qe(r){return It(r,"remoteDocumentsV14")}function vr(r){const t=r.path.toArray();return[t.slice(0,t.length-2),t[t.length-2],t[t.length-1]]}function Fc(r,t){const e=t.documentKey.path.toArray();return[r,Yi(t.readTime),e.slice(0,e.length-2),e.length>0?e[e.length-1]:""]}function Mc(r,t){const e=r.path.toArray(),n=t.path.toArray();let i=0;for(let s=0;s<e.length-2&&s<n.length-2;++s)if(i=j(e[s],n[s]),i)return i;return i=j(e.length,n.length),i||(i=j(e[e.length-2],n[n.length-2]),i||j(e[e.length-1],n[n.length-1]))}/**
1531
+ */class Zp{constructor(t){this.serializer=t}setIndexManager(t){this.indexManager=t}addEntry(t,e,n){return ze(t).put(n)}removeEntry(t,e,n){return ze(t).delete(function(s,a){const u=s.path.toArray();return[u.slice(0,u.length-2),u[u.length-2],Yi(a),u[u.length-1]]}(e,n))}updateMetadata(t,e){return this.getMetadata(t).next(n=>(n.byteSize+=e,this.rr(t,n)))}getEntry(t,e){let n=ot.newInvalidDocument(e);return ze(t).J({index:"documentKeyIndex",range:IDBKeyRange.only(wr(e))},(i,s)=>{n=this.ir(e,s)}).next(()=>n)}sr(t,e){let n={size:0,document:ot.newInvalidDocument(e)};return ze(t).J({index:"documentKeyIndex",range:IDBKeyRange.only(wr(e))},(i,s)=>{n={document:this.ir(e,s),size:Zi(s)}}).next(()=>n)}getEntries(t,e){let n=Bt();return this._r(t,e,(i,s)=>{const a=this.ir(i,s);n=n.insert(i,a)}).next(()=>n)}ar(t,e){let n=Bt(),i=new it(M.comparator);return this._r(t,e,(s,a)=>{const u=this.ir(s,a);n=n.insert(s,u),i=i.insert(s,Zi(a))}).next(()=>({documents:n,ur:i}))}_r(t,e,n){if(e.isEmpty())return w.resolve();let i=new et(Mc);e.forEach(c=>i=i.add(c));const s=IDBKeyRange.bound(wr(i.first()),wr(i.last())),a=i.getIterator();let u=a.getNext();return ze(t).J({index:"documentKeyIndex",range:s},(c,h,f)=>{const g=M.fromSegments([...h.prefixPath,h.collectionGroup,h.documentId]);for(;u&&Mc(u,g)<0;)n(u,null),u=a.getNext();u&&u.isEqual(g)&&(n(u,h),u=a.hasNext()?a.getNext():null),u?f.$(wr(u)):f.done()}).next(()=>{for(;u;)n(u,null),u=a.hasNext()?a.getNext():null})}getDocumentsMatchingQuery(t,e,n,i,s){const a=e.path,u=[a.popLast().toArray(),a.lastSegment(),Yi(n.readTime),n.documentKey.path.isEmpty()?"":n.documentKey.path.lastSegment()],c=[a.popLast().toArray(),a.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];return ze(t).U(IDBKeyRange.bound(u,c,!0)).next(h=>{s==null||s.incrementDocumentReadCount(h.length);let f=Bt();for(const g of h){const _=this.ir(M.fromSegments(g.prefixPath.concat(g.collectionGroup,g.documentId)),g);_.isFoundDocument()&&(Yr(e,_)||i.has(_.key))&&(f=f.insert(_.key,_))}return f})}getAllFromCollectionGroup(t,e,n,i){let s=Bt();const a=Fc(e,n),u=Fc(e,zt.max());return ze(t).J({index:"collectionGroupIndex",range:IDBKeyRange.bound(a,u,!0)},(c,h,f)=>{const g=this.ir(M.fromSegments(h.prefixPath.concat(h.collectionGroup,h.documentId)),h);s=s.insert(g.key,g),s.size===i&&f.done()}).next(()=>s)}newChangeBuffer(t){return new t_(this,!!t&&t.trackRemovals)}getSize(t){return this.getMetadata(t).next(e=>e.byteSize)}getMetadata(t){return kc(t).get("remoteDocumentGlobalKey").next(e=>(L(!!e),e))}rr(t,e){return kc(t).put("remoteDocumentGlobalKey",e)}ir(t,e){if(e){const n=Bp(this.serializer,e);if(!(n.isNoDocument()&&n.version.isEqual(U.min())))return n}return ot.newInvalidDocument(t)}}function Xh(r){return new Zp(r)}class t_ extends Yh{constructor(t,e){super(),this.cr=t,this.trackRemovals=e,this.lr=new se(n=>n.toString(),(n,i)=>n.isEqual(i))}applyChanges(t){const e=[];let n=0,i=new et((s,a)=>j(s.canonicalString(),a.canonicalString()));return this.changes.forEach((s,a)=>{const u=this.lr.get(s);if(e.push(this.cr.removeEntry(t,s,u.readTime)),a.isValidDocument()){const c=Ec(this.cr.serializer,a);i=i.add(s.path.popLast());const h=Zi(c);n+=h-u.size,e.push(this.cr.addEntry(t,s,c))}else if(n-=u.size,this.trackRemovals){const c=Ec(this.cr.serializer,a.convertToNoDocument(U.min()));e.push(this.cr.addEntry(t,s,c))}}),i.forEach(s=>{e.push(this.cr.indexManager.addToCollectionParentIndex(t,s))}),e.push(this.cr.updateMetadata(t,n)),w.waitFor(e)}getFromCache(t,e){return this.cr.sr(t,e).next(n=>(this.lr.set(e,{size:n.size,readTime:n.document.readTime}),n.document))}getAllFromCache(t,e){return this.cr.ar(t,e).next(({documents:n,ur:i})=>(i.forEach((s,a)=>{this.lr.set(s,{size:a,readTime:n.get(s).readTime})}),n))}}function kc(r){return It(r,"remoteDocumentGlobal")}function ze(r){return It(r,"remoteDocumentsV14")}function wr(r){const t=r.path.toArray();return[t.slice(0,t.length-2),t[t.length-2],t[t.length-1]]}function Fc(r,t){const e=t.documentKey.path.toArray();return[r,Yi(t.readTime),e.slice(0,e.length-2),e.length>0?e[e.length-1]:""]}function Mc(r,t){const e=r.path.toArray(),n=t.path.toArray();let i=0;for(let s=0;s<e.length-2&&s<n.length-2;++s)if(i=j(e[s],n[s]),i)return i;return i=j(e.length,n.length),i||(i=j(e[e.length-2],n[n.length-2]),i||j(e[e.length-1],n[n.length-1]))}/**
1532
1532
  * @license
1533
1533
  * Copyright 2017 Google LLC
1534
1534
  *
@@ -1573,7 +1573,7 @@ Total Duration: ${h-f}ms`),w.resolve({didRun:!0,sequenceNumbersCollected:i,targe
1573
1573
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1574
1574
  * See the License for the specific language governing permissions and
1575
1575
  * limitations under the License.
1576
- */class Zh{constructor(t,e,n,i){this.remoteDocumentCache=t,this.mutationQueue=e,this.documentOverlayCache=n,this.indexManager=i}getDocument(t,e){let n=null;return this.documentOverlayCache.getOverlay(t,e).next(i=>(n=i,this.remoteDocumentCache.getEntry(t,e))).next(i=>(n!==null&&Dr(n.mutation,i,Lt.empty(),lt.now()),i))}getDocuments(t,e){return this.remoteDocumentCache.getEntries(t,e).next(n=>this.getLocalViewOfDocuments(t,n,G()).next(()=>n))}getLocalViewOfDocuments(t,e,n=G()){const i=Qt();return this.populateOverlays(t,i,e).next(()=>this.computeViews(t,e,i,n).next(s=>{let a=Rr();return s.forEach((u,c)=>{a=a.insert(u,c.overlayedDocument)}),a}))}getOverlayedDocuments(t,e){const n=Qt();return this.populateOverlays(t,n,e).next(()=>this.computeViews(t,e,n,G()))}populateOverlays(t,e,n){const i=[];return n.forEach(s=>{e.has(s)||i.push(s)}),this.documentOverlayCache.getOverlays(t,i).next(s=>{s.forEach((a,u)=>{e.set(a,u)})})}computeViews(t,e,n,i){let s=Bt();const a=Cr(),u=function(){return Cr()}();return e.forEach((c,h)=>{const f=n.get(h.key);i.has(h.key)&&(f===void 0||f.mutation instanceof oe)?s=s.insert(h.key,h):f!==void 0?(a.set(h.key,f.mutation.getFieldMask()),Dr(f.mutation,h,f.mutation.getFieldMask(),lt.now())):a.set(h.key,Lt.empty())}),this.recalculateAndSaveOverlays(t,s).next(c=>(c.forEach((h,f)=>a.set(h,f)),e.forEach((h,f)=>{var g;return u.set(h,new e_(f,(g=a.get(h))!==null&&g!==void 0?g:null))}),u))}recalculateAndSaveOverlays(t,e){const n=Cr();let i=new it((a,u)=>a-u),s=G();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(t,e).next(a=>{for(const u of a)u.keys().forEach(c=>{const h=e.get(c);if(h===null)return;let f=n.get(c)||Lt.empty();f=u.applyToLocalView(h,f),n.set(c,f);const g=(i.get(u.batchId)||G()).add(c);i=i.insert(u.batchId,g)})}).next(()=>{const a=[],u=i.getReverseIterator();for(;u.hasNext();){const c=u.getNext(),h=c.key,f=c.value,g=gh();f.forEach(_=>{if(!s.has(_)){const R=vh(e.get(_),n.get(_));R!==null&&g.set(_,R),s=s.add(_)}}),a.push(this.documentOverlayCache.saveOverlays(t,h,g))}return w.waitFor(a)}).next(()=>n)}recalculateAndSaveOverlaysForDocumentKeys(t,e){return this.remoteDocumentCache.getEntries(t,e).next(n=>this.recalculateAndSaveOverlays(t,n))}getDocumentsMatchingQuery(t,e,n,i){return function(a){return M.isDocumentKey(a.path)&&a.collectionGroup===null&&a.filters.length===0}(e)?this.getDocumentsMatchingDocumentQuery(t,e.path):Go(e)?this.getDocumentsMatchingCollectionGroupQuery(t,e,n,i):this.getDocumentsMatchingCollectionQuery(t,e,n,i)}getNextDocuments(t,e,n,i){return this.remoteDocumentCache.getAllFromCollectionGroup(t,e,n,i).next(s=>{const a=i-s.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(t,e,n.largestBatchId,i-s.size):w.resolve(Qt());let u=-1,c=s;return a.next(h=>w.forEach(h,(f,g)=>(u<g.largestBatchId&&(u=g.largestBatchId),s.get(f)?w.resolve():this.remoteDocumentCache.getEntry(t,f).next(_=>{c=c.insert(f,_)}))).next(()=>this.populateOverlays(t,h,s)).next(()=>this.computeViews(t,c,h,G())).next(f=>({batchId:u,changes:mh(f)})))})}getDocumentsMatchingDocumentQuery(t,e){return this.getDocument(t,new M(e)).next(n=>{let i=Rr();return n.isFoundDocument()&&(i=i.insert(n.key,n)),i})}getDocumentsMatchingCollectionGroupQuery(t,e,n,i){const s=e.collectionGroup;let a=Rr();return this.indexManager.getCollectionParents(t,s).next(u=>w.forEach(u,c=>{const h=function(g,_){return new ie(_,null,g.explicitOrderBy.slice(),g.filters.slice(),g.limit,g.limitType,g.startAt,g.endAt)}(e,c.child(s));return this.getDocumentsMatchingCollectionQuery(t,h,n,i).next(f=>{f.forEach((g,_)=>{a=a.insert(g,_)})})}).next(()=>a))}getDocumentsMatchingCollectionQuery(t,e,n,i){let s;return this.documentOverlayCache.getOverlaysForCollection(t,e.path,n.largestBatchId).next(a=>(s=a,this.remoteDocumentCache.getDocumentsMatchingQuery(t,e,n,s,i))).next(a=>{s.forEach((c,h)=>{const f=h.getKey();a.get(f)===null&&(a=a.insert(f,ot.newInvalidDocument(f)))});let u=Rr();return a.forEach((c,h)=>{const f=s.get(c);f!==void 0&&Dr(f.mutation,h,Lt.empty(),lt.now()),Yr(e,h)&&(u=u.insert(c,h))}),u})}}/**
1576
+ */class Zh{constructor(t,e,n,i){this.remoteDocumentCache=t,this.mutationQueue=e,this.documentOverlayCache=n,this.indexManager=i}getDocument(t,e){let n=null;return this.documentOverlayCache.getOverlay(t,e).next(i=>(n=i,this.remoteDocumentCache.getEntry(t,e))).next(i=>(n!==null&&xr(n.mutation,i,Lt.empty(),lt.now()),i))}getDocuments(t,e){return this.remoteDocumentCache.getEntries(t,e).next(n=>this.getLocalViewOfDocuments(t,n,G()).next(()=>n))}getLocalViewOfDocuments(t,e,n=G()){const i=Qt();return this.populateOverlays(t,i,e).next(()=>this.computeViews(t,e,i,n).next(s=>{let a=br();return s.forEach((u,c)=>{a=a.insert(u,c.overlayedDocument)}),a}))}getOverlayedDocuments(t,e){const n=Qt();return this.populateOverlays(t,n,e).next(()=>this.computeViews(t,e,n,G()))}populateOverlays(t,e,n){const i=[];return n.forEach(s=>{e.has(s)||i.push(s)}),this.documentOverlayCache.getOverlays(t,i).next(s=>{s.forEach((a,u)=>{e.set(a,u)})})}computeViews(t,e,n,i){let s=Bt();const a=Dr(),u=function(){return Dr()}();return e.forEach((c,h)=>{const f=n.get(h.key);i.has(h.key)&&(f===void 0||f.mutation instanceof oe)?s=s.insert(h.key,h):f!==void 0?(a.set(h.key,f.mutation.getFieldMask()),xr(f.mutation,h,f.mutation.getFieldMask(),lt.now())):a.set(h.key,Lt.empty())}),this.recalculateAndSaveOverlays(t,s).next(c=>(c.forEach((h,f)=>a.set(h,f)),e.forEach((h,f)=>{var g;return u.set(h,new e_(f,(g=a.get(h))!==null&&g!==void 0?g:null))}),u))}recalculateAndSaveOverlays(t,e){const n=Dr();let i=new it((a,u)=>a-u),s=G();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(t,e).next(a=>{for(const u of a)u.keys().forEach(c=>{const h=e.get(c);if(h===null)return;let f=n.get(c)||Lt.empty();f=u.applyToLocalView(h,f),n.set(c,f);const g=(i.get(u.batchId)||G()).add(c);i=i.insert(u.batchId,g)})}).next(()=>{const a=[],u=i.getReverseIterator();for(;u.hasNext();){const c=u.getNext(),h=c.key,f=c.value,g=gh();f.forEach(_=>{if(!s.has(_)){const R=vh(e.get(_),n.get(_));R!==null&&g.set(_,R),s=s.add(_)}}),a.push(this.documentOverlayCache.saveOverlays(t,h,g))}return w.waitFor(a)}).next(()=>n)}recalculateAndSaveOverlaysForDocumentKeys(t,e){return this.remoteDocumentCache.getEntries(t,e).next(n=>this.recalculateAndSaveOverlays(t,n))}getDocumentsMatchingQuery(t,e,n,i){return function(a){return M.isDocumentKey(a.path)&&a.collectionGroup===null&&a.filters.length===0}(e)?this.getDocumentsMatchingDocumentQuery(t,e.path):Go(e)?this.getDocumentsMatchingCollectionGroupQuery(t,e,n,i):this.getDocumentsMatchingCollectionQuery(t,e,n,i)}getNextDocuments(t,e,n,i){return this.remoteDocumentCache.getAllFromCollectionGroup(t,e,n,i).next(s=>{const a=i-s.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(t,e,n.largestBatchId,i-s.size):w.resolve(Qt());let u=-1,c=s;return a.next(h=>w.forEach(h,(f,g)=>(u<g.largestBatchId&&(u=g.largestBatchId),s.get(f)?w.resolve():this.remoteDocumentCache.getEntry(t,f).next(_=>{c=c.insert(f,_)}))).next(()=>this.populateOverlays(t,h,s)).next(()=>this.computeViews(t,c,h,G())).next(f=>({batchId:u,changes:mh(f)})))})}getDocumentsMatchingDocumentQuery(t,e){return this.getDocument(t,new M(e)).next(n=>{let i=br();return n.isFoundDocument()&&(i=i.insert(n.key,n)),i})}getDocumentsMatchingCollectionGroupQuery(t,e,n,i){const s=e.collectionGroup;let a=br();return this.indexManager.getCollectionParents(t,s).next(u=>w.forEach(u,c=>{const h=function(g,_){return new ie(_,null,g.explicitOrderBy.slice(),g.filters.slice(),g.limit,g.limitType,g.startAt,g.endAt)}(e,c.child(s));return this.getDocumentsMatchingCollectionQuery(t,h,n,i).next(f=>{f.forEach((g,_)=>{a=a.insert(g,_)})})}).next(()=>a))}getDocumentsMatchingCollectionQuery(t,e,n,i){let s;return this.documentOverlayCache.getOverlaysForCollection(t,e.path,n.largestBatchId).next(a=>(s=a,this.remoteDocumentCache.getDocumentsMatchingQuery(t,e,n,s,i))).next(a=>{s.forEach((c,h)=>{const f=h.getKey();a.get(f)===null&&(a=a.insert(f,ot.newInvalidDocument(f)))});let u=br();return a.forEach((c,h)=>{const f=s.get(c);f!==void 0&&xr(f.mutation,h,Lt.empty(),lt.now()),Yr(e,h)&&(u=u.insert(c,h))}),u})}}/**
1577
1577
  * @license
1578
1578
  * Copyright 2020 Google LLC
1579
1579
  *
@@ -1678,7 +1678,7 @@ Total Duration: ${h-f}ms`),w.resolve({didRun:!0,sequenceNumbersCollected:i,targe
1678
1678
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1679
1679
  * See the License for the specific language governing permissions and
1680
1680
  * limitations under the License.
1681
- */class u_{constructor(t){this.persistence=t,this.Nr=new se(e=>Ze(e),Hr),this.lastRemoteSnapshotVersion=U.min(),this.highestTargetId=0,this.Lr=0,this.Br=new na,this.targetCount=0,this.kr=sn.Bn()}forEachTarget(t,e){return this.Nr.forEach((n,i)=>e(i)),w.resolve()}getLastRemoteSnapshotVersion(t){return w.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(t){return w.resolve(this.Lr)}allocateTargetId(t){return this.highestTargetId=this.kr.next(),w.resolve(this.highestTargetId)}setTargetsMetadata(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.Lr&&(this.Lr=e),w.resolve()}Kn(t){this.Nr.set(t.target,t);const e=t.targetId;e>this.highestTargetId&&(this.kr=new sn(e),this.highestTargetId=e),t.sequenceNumber>this.Lr&&(this.Lr=t.sequenceNumber)}addTargetData(t,e){return this.Kn(e),this.targetCount+=1,w.resolve()}updateTargetData(t,e){return this.Kn(e),w.resolve()}removeTargetData(t,e){return this.Nr.delete(e.target),this.Br.gr(e.targetId),this.targetCount-=1,w.resolve()}removeTargets(t,e,n){let i=0;const s=[];return this.Nr.forEach((a,u)=>{u.sequenceNumber<=e&&n.get(u.targetId)===null&&(this.Nr.delete(a),s.push(this.removeMatchingKeysForTargetId(t,u.targetId)),i++)}),w.waitFor(s).next(()=>i)}getTargetCount(t){return w.resolve(this.targetCount)}getTargetData(t,e){const n=this.Nr.get(e)||null;return w.resolve(n)}addMatchingKeys(t,e,n){return this.Br.Rr(e,n),w.resolve()}removeMatchingKeys(t,e,n){this.Br.mr(e,n);const i=this.persistence.referenceDelegate,s=[];return i&&e.forEach(a=>{s.push(i.markPotentiallyOrphaned(t,a))}),w.waitFor(s)}removeMatchingKeysForTargetId(t,e){return this.Br.gr(e),w.resolve()}getMatchingKeysForTargetId(t,e){const n=this.Br.yr(e);return w.resolve(n)}containsKey(t,e){return w.resolve(this.Br.containsKey(e))}}/**
1681
+ */class u_{constructor(t){this.persistence=t,this.Nr=new se(e=>tn(e),Hr),this.lastRemoteSnapshotVersion=U.min(),this.highestTargetId=0,this.Lr=0,this.Br=new na,this.targetCount=0,this.kr=on.Bn()}forEachTarget(t,e){return this.Nr.forEach((n,i)=>e(i)),w.resolve()}getLastRemoteSnapshotVersion(t){return w.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(t){return w.resolve(this.Lr)}allocateTargetId(t){return this.highestTargetId=this.kr.next(),w.resolve(this.highestTargetId)}setTargetsMetadata(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.Lr&&(this.Lr=e),w.resolve()}Kn(t){this.Nr.set(t.target,t);const e=t.targetId;e>this.highestTargetId&&(this.kr=new on(e),this.highestTargetId=e),t.sequenceNumber>this.Lr&&(this.Lr=t.sequenceNumber)}addTargetData(t,e){return this.Kn(e),this.targetCount+=1,w.resolve()}updateTargetData(t,e){return this.Kn(e),w.resolve()}removeTargetData(t,e){return this.Nr.delete(e.target),this.Br.gr(e.targetId),this.targetCount-=1,w.resolve()}removeTargets(t,e,n){let i=0;const s=[];return this.Nr.forEach((a,u)=>{u.sequenceNumber<=e&&n.get(u.targetId)===null&&(this.Nr.delete(a),s.push(this.removeMatchingKeysForTargetId(t,u.targetId)),i++)}),w.waitFor(s).next(()=>i)}getTargetCount(t){return w.resolve(this.targetCount)}getTargetData(t,e){const n=this.Nr.get(e)||null;return w.resolve(n)}addMatchingKeys(t,e,n){return this.Br.Rr(e,n),w.resolve()}removeMatchingKeys(t,e,n){this.Br.mr(e,n);const i=this.persistence.referenceDelegate,s=[];return i&&e.forEach(a=>{s.push(i.markPotentiallyOrphaned(t,a))}),w.waitFor(s)}removeMatchingKeysForTargetId(t,e){return this.Br.gr(e),w.resolve()}getMatchingKeysForTargetId(t,e){const n=this.Br.yr(e);return w.resolve(n)}containsKey(t,e){return w.resolve(this.Br.containsKey(e))}}/**
1682
1682
  * @license
1683
1683
  * Copyright 2017 Google LLC
1684
1684
  *
@@ -1708,7 +1708,7 @@ Total Duration: ${h-f}ms`),w.resolve({didRun:!0,sequenceNumbersCollected:i,targe
1708
1708
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1709
1709
  * See the License for the specific language governing permissions and
1710
1710
  * limitations under the License.
1711
- */class l_{constructor(t){this.serializer=t}O(t,e,n,i){const s=new as("createOrUpgrade",e);n<1&&i>=1&&(function(c){c.createObjectStore("owner")}(t),function(c){c.createObjectStore("mutationQueues",{keyPath:"userId"}),c.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",Ju,{unique:!0}),c.createObjectStore("documentMutations")}(t),Oc(t),function(c){c.createObjectStore("remoteDocuments")}(t));let a=w.resolve();return n<3&&i>=3&&(n!==0&&(function(c){c.deleteObjectStore("targetDocuments"),c.deleteObjectStore("targets"),c.deleteObjectStore("targetGlobal")}(t),Oc(t)),a=a.next(()=>function(c){const h=c.store("targetGlobal"),f={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:U.min().toTimestamp(),targetCount:0};return h.put("targetGlobalKey",f)}(s))),n<4&&i>=4&&(n!==0&&(a=a.next(()=>function(c,h){return h.store("mutations").U().next(f=>{c.deleteObjectStore("mutations"),c.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",Ju,{unique:!0});const g=h.store("mutations"),_=f.map(R=>g.put(R));return w.waitFor(_)})}(t,s))),a=a.next(()=>{(function(c){c.createObjectStore("clientMetadata",{keyPath:"clientId"})})(t)})),n<5&&i>=5&&(a=a.next(()=>this.ni(s))),n<6&&i>=6&&(a=a.next(()=>(function(c){c.createObjectStore("remoteDocumentGlobal")}(t),this.ri(s)))),n<7&&i>=7&&(a=a.next(()=>this.ii(s))),n<8&&i>=8&&(a=a.next(()=>this.si(t,s))),n<9&&i>=9&&(a=a.next(()=>{(function(c){c.objectStoreNames.contains("remoteDocumentChanges")&&c.deleteObjectStore("remoteDocumentChanges")})(t)})),n<10&&i>=10&&(a=a.next(()=>this.oi(s))),n<11&&i>=11&&(a=a.next(()=>{(function(c){c.createObjectStore("bundles",{keyPath:"bundleId"})})(t),function(c){c.createObjectStore("namedQueries",{keyPath:"name"})}(t)})),n<12&&i>=12&&(a=a.next(()=>{(function(c){const h=c.createObjectStore("documentOverlays",{keyPath:Qg});h.createIndex("collectionPathOverlayIndex",Wg,{unique:!1}),h.createIndex("collectionGroupOverlayIndex",Hg,{unique:!1})})(t)})),n<13&&i>=13&&(a=a.next(()=>function(c){const h=c.createObjectStore("remoteDocumentsV14",{keyPath:Mg});h.createIndex("documentKeyIndex",Og),h.createIndex("collectionGroupIndex",Lg)}(t)).next(()=>this._i(t,s)).next(()=>t.deleteObjectStore("remoteDocuments"))),n<14&&i>=14&&(a=a.next(()=>this.ai(t,s))),n<15&&i>=15&&(a=a.next(()=>function(c){c.createObjectStore("indexConfiguration",{keyPath:"indexId",autoIncrement:!0}).createIndex("collectionGroupIndex","collectionGroup",{unique:!1}),c.createObjectStore("indexState",{keyPath:jg}).createIndex("sequenceNumberIndex",Gg,{unique:!1}),c.createObjectStore("indexEntries",{keyPath:Kg}).createIndex("documentKeyIndex",$g,{unique:!1})}(t))),n<16&&i>=16&&(a=a.next(()=>{e.objectStore("indexState").clear()}).next(()=>{e.objectStore("indexEntries").clear()})),n<17&&i>=17&&(a=a.next(()=>{(function(c){c.createObjectStore("globals",{keyPath:"name"})})(t)})),a}ri(t){let e=0;return t.store("remoteDocuments").J((n,i)=>{e+=Zi(i)}).next(()=>{const n={byteSize:e};return t.store("remoteDocumentGlobal").put("remoteDocumentGlobalKey",n)})}ni(t){const e=t.store("mutationQueues"),n=t.store("mutations");return e.U().next(i=>w.forEach(i,s=>{const a=IDBKeyRange.bound([s.userId,-1],[s.userId,s.lastAcknowledgedBatchId]);return n.U("userMutationsIndex",a).next(u=>w.forEach(u,c=>{L(c.userId===s.userId);const h=Ke(this.serializer,c);return $h(t,s.userId,h).next(()=>{})}))}))}ii(t){const e=t.store("targetDocuments"),n=t.store("remoteDocuments");return t.store("targetGlobal").get("targetGlobalKey").next(i=>{const s=[];return n.J((a,u)=>{const c=new W(a),h=function(g){return[0,Nt(g)]}(c);s.push(e.get(h).next(f=>f?w.resolve():(g=>e.put({targetId:0,path:Nt(g),sequenceNumber:i.highestListenSequenceNumber}))(c)))}).next(()=>w.waitFor(s))})}si(t,e){t.createObjectStore("collectionParents",{keyPath:zg});const n=e.store("collectionParents"),i=new ea,s=a=>{if(i.add(a)){const u=a.lastSegment(),c=a.popLast();return n.put({collectionId:u,parent:Nt(c)})}};return e.store("remoteDocuments").J({H:!0},(a,u)=>{const c=new W(a);return s(c.popLast())}).next(()=>e.store("documentMutations").J({H:!0},([a,u,c],h)=>{const f=$t(u);return s(f.popLast())}))}oi(t){const e=t.store("targets");return e.J((n,i)=>{const s=Pr(i),a=jh(this.serializer,s);return e.put(a)})}_i(t,e){const n=e.store("remoteDocuments"),i=[];return n.J((s,a)=>{const u=e.store("remoteDocumentsV14"),c=function(g){return g.document?new M(W.fromString(g.document.name).popFirst(5)):g.noDocument?M.fromSegments(g.noDocument.path):g.unknownDocument?M.fromSegments(g.unknownDocument.path):O()}(a).path.toArray(),h={prefixPath:c.slice(0,c.length-2),collectionGroup:c[c.length-2],documentId:c[c.length-1],readTime:a.readTime||[0,0],unknownDocument:a.unknownDocument,noDocument:a.noDocument,document:a.document,hasCommittedMutations:!!a.hasCommittedMutations};i.push(u.put(h))}).next(()=>w.waitFor(i))}ai(t,e){const n=e.store("mutations"),i=Xh(this.serializer),s=new ra(ps.Zr,this.serializer.ct);return n.U().next(a=>{const u=new Map;return a.forEach(c=>{var h;let f=(h=u.get(c.userId))!==null&&h!==void 0?h:G();Ke(this.serializer,c).keys().forEach(g=>f=f.add(g)),u.set(c.userId,f)}),w.forEach(u,(c,h)=>{const f=new Tt(h),g=ms.lt(this.serializer,f),_=s.getIndexManager(f),R=gs.lt(f,this.serializer,_,s.referenceDelegate);return new Zh(i,R,g,_).recalculateAndSaveOverlaysForDocumentKeys(new po(e,Ot.oe),c).next()})})}}function Oc(r){r.createObjectStore("targetDocuments",{keyPath:Ug}).createIndex("documentTargetsIndex",qg,{unique:!0}),r.createObjectStore("targets",{keyPath:"targetId"}).createIndex("queryTargetsIndex",Bg,{unique:!0}),r.createObjectStore("targetGlobal")}const io="Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.";class ia{constructor(t,e,n,i,s,a,u,c,h,f,g=17){if(this.allowTabSynchronization=t,this.persistenceKey=e,this.clientId=n,this.ui=s,this.window=a,this.document=u,this.ci=h,this.li=f,this.hi=g,this.Qr=null,this.Kr=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Pi=null,this.inForeground=!1,this.Ii=null,this.Ti=null,this.Ei=Number.NEGATIVE_INFINITY,this.di=_=>Promise.resolve(),!ia.D())throw new D(P.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new Xp(this,i),this.Ai=e+"main",this.serializer=new zh(c),this.Ri=new Wt(this.Ai,this.hi,new l_(this.serializer)),this.$r=new qp,this.Ur=new Hp(this.referenceDelegate,this.serializer),this.remoteDocumentCache=Xh(this.serializer),this.Gr=new Up,this.window&&this.window.localStorage?this.Vi=this.window.localStorage:(this.Vi=null,f===!1&&gt("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.mi().then(()=>{if(!this.isPrimary&&!this.allowTabSynchronization)throw new D(P.FAILED_PRECONDITION,io);return this.fi(),this.gi(),this.pi(),this.runTransaction("getHighestListenSequenceNumber","readonly",t=>this.Ur.getHighestSequenceNumber(t))}).then(t=>{this.Qr=new Ot(t,this.ci)}).then(()=>{this.Kr=!0}).catch(t=>(this.Ri&&this.Ri.close(),Promise.reject(t)))}yi(t){return this.di=async e=>{if(this.started)return t(e)},t(this.isPrimary)}setDatabaseDeletedListener(t){this.Ri.L(async e=>{e.newVersion===null&&await t()})}setNetworkEnabled(t){this.networkEnabled!==t&&(this.networkEnabled=t,this.ui.enqueueAndForget(async()=>{this.started&&await this.mi()}))}mi(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",t=>Ni(t).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next(()=>{if(this.isPrimary)return this.wi(t).next(e=>{e||(this.isPrimary=!1,this.ui.enqueueRetryable(()=>this.di(!1)))})}).next(()=>this.Si(t)).next(e=>this.isPrimary&&!e?this.bi(t).next(()=>!1):!!e&&this.Di(t).next(()=>!0))).catch(t=>{if(De(t))return x("IndexedDbPersistence","Failed to extend owner lease: ",t),this.isPrimary;if(!this.allowTabSynchronization)throw t;return x("IndexedDbPersistence","Releasing owner lease after error during lease refresh",t),!1}).then(t=>{this.isPrimary!==t&&this.ui.enqueueRetryable(()=>this.di(t)),this.isPrimary=t})}wi(t){return wr(t).get("owner").next(e=>w.resolve(this.vi(e)))}Ci(t){return Ni(t).delete(this.clientId)}async Fi(){if(this.isPrimary&&!this.Mi(this.Ei,18e5)){this.Ei=Date.now();const t=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",e=>{const n=It(e,"clientMetadata");return n.U().next(i=>{const s=this.xi(i,18e5),a=i.filter(u=>s.indexOf(u)===-1);return w.forEach(a,u=>n.delete(u.clientId)).next(()=>a)})}).catch(()=>[]);if(this.Vi)for(const e of t)this.Vi.removeItem(this.Oi(e.clientId))}}pi(){this.Ti=this.ui.enqueueAfterDelay("client_metadata_refresh",4e3,()=>this.mi().then(()=>this.Fi()).then(()=>this.pi()))}vi(t){return!!t&&t.ownerId===this.clientId}Si(t){return this.li?w.resolve(!0):wr(t).get("owner").next(e=>{if(e!==null&&this.Mi(e.leaseTimestampMs,5e3)&&!this.Ni(e.ownerId)){if(this.vi(e)&&this.networkEnabled)return!0;if(!this.vi(e)){if(!e.allowTabSynchronization)throw new D(P.FAILED_PRECONDITION,io);return!1}}return!(!this.networkEnabled||!this.inForeground)||Ni(t).U().next(n=>this.xi(n,5e3).find(i=>{if(this.clientId!==i.clientId){const s=!this.networkEnabled&&i.networkEnabled,a=!this.inForeground&&i.inForeground,u=this.networkEnabled===i.networkEnabled;if(s||a&&u)return!0}return!1})===void 0)}).next(e=>(this.isPrimary!==e&&x("IndexedDbPersistence",`Client ${e?"is":"is not"} eligible for a primary lease.`),e))}async shutdown(){this.Kr=!1,this.Li(),this.Ti&&(this.Ti.cancel(),this.Ti=null),this.Bi(),this.ki(),await this.Ri.runTransaction("shutdown","readwrite",["owner","clientMetadata"],t=>{const e=new po(t,Ot.oe);return this.bi(e).next(()=>this.Ci(e))}),this.Ri.close(),this.qi()}xi(t,e){return t.filter(n=>this.Mi(n.updateTimeMs,e)&&!this.Ni(n.clientId))}Qi(){return this.runTransaction("getActiveClients","readonly",t=>Ni(t).U().next(e=>this.xi(e,18e5).map(n=>n.clientId)))}get started(){return this.Kr}getGlobalsCache(){return this.$r}getMutationQueue(t,e){return gs.lt(t,this.serializer,e,this.referenceDelegate)}getTargetCache(){return this.Ur}getRemoteDocumentCache(){return this.remoteDocumentCache}getIndexManager(t){return new Wp(t,this.serializer.ct.databaseId)}getDocumentOverlayCache(t){return ms.lt(this.serializer,t)}getBundleCache(){return this.Gr}runTransaction(t,e,n){x("IndexedDbPersistence","Starting transaction:",t);const i=e==="readonly"?"readonly":"readwrite",s=function(c){return c===17?Xg:c===16?Yg:c===15?zo:c===14?Ql:c===13?$l:c===12?Jg:c===11?Kl:void O()}(this.hi);let a;return this.Ri.runTransaction(t,i,s,u=>(a=new po(u,this.Qr?this.Qr.next():Ot.oe),e==="readwrite-primary"?this.wi(a).next(c=>!!c||this.Si(a)).next(c=>{if(!c)throw gt(`Failed to obtain primary lease for action '${t}'.`),this.isPrimary=!1,this.ui.enqueueRetryable(()=>this.di(!1)),new D(P.FAILED_PRECONDITION,Ul);return n(a)}).next(c=>this.Di(a).next(()=>c)):this.Ki(a).next(()=>n(a)))).then(u=>(a.raiseOnCommittedEvent(),u))}Ki(t){return wr(t).get("owner").next(e=>{if(e!==null&&this.Mi(e.leaseTimestampMs,5e3)&&!this.Ni(e.ownerId)&&!this.vi(e)&&!(this.li||this.allowTabSynchronization&&e.allowTabSynchronization))throw new D(P.FAILED_PRECONDITION,io)})}Di(t){const e={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return wr(t).put("owner",e)}static D(){return Wt.D()}bi(t){const e=wr(t);return e.get("owner").next(n=>this.vi(n)?(x("IndexedDbPersistence","Releasing primary lease."),e.delete("owner")):w.resolve())}Mi(t,e){const n=Date.now();return!(t<n-e)&&(!(t>n)||(gt(`Detected an update time that is in the future: ${t} > ${n}`),!1))}fi(){this.document!==null&&typeof this.document.addEventListener=="function"&&(this.Ii=()=>{this.ui.enqueueAndForget(()=>(this.inForeground=this.document.visibilityState==="visible",this.mi()))},this.document.addEventListener("visibilitychange",this.Ii),this.inForeground=this.document.visibilityState==="visible")}Bi(){this.Ii&&(this.document.removeEventListener("visibilitychange",this.Ii),this.Ii=null)}gi(){var t;typeof((t=this.window)===null||t===void 0?void 0:t.addEventListener)=="function"&&(this.Pi=()=>{this.Li();const e=/(?:Version|Mobile)\/1[456]/;hl()&&(navigator.appVersion.match(e)||navigator.userAgent.match(e))&&this.ui.enterRestrictedMode(!0),this.ui.enqueueAndForget(()=>this.shutdown())},this.window.addEventListener("pagehide",this.Pi))}ki(){this.Pi&&(this.window.removeEventListener("pagehide",this.Pi),this.Pi=null)}Ni(t){var e;try{const n=((e=this.Vi)===null||e===void 0?void 0:e.getItem(this.Oi(t)))!==null;return x("IndexedDbPersistence",`Client '${t}' ${n?"is":"is not"} zombied in LocalStorage`),n}catch(n){return gt("IndexedDbPersistence","Failed to get zombied client id.",n),!1}}Li(){if(this.Vi)try{this.Vi.setItem(this.Oi(this.clientId),String(Date.now()))}catch(t){gt("Failed to set zombie client id.",t)}}qi(){if(this.Vi)try{this.Vi.removeItem(this.Oi(this.clientId))}catch{}}Oi(t){return`firestore_zombie_${this.persistenceKey}_${t}`}}function wr(r){return It(r,"owner")}function Ni(r){return It(r,"clientMetadata")}function sa(r,t){let e=r.projectId;return r.isDefaultDatabase||(e+="."+r.database),"firestore/"+t+"/"+e+"/"}/**
1711
+ */class l_{constructor(t){this.serializer=t}O(t,e,n,i){const s=new as("createOrUpgrade",e);n<1&&i>=1&&(function(c){c.createObjectStore("owner")}(t),function(c){c.createObjectStore("mutationQueues",{keyPath:"userId"}),c.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",Ju,{unique:!0}),c.createObjectStore("documentMutations")}(t),Oc(t),function(c){c.createObjectStore("remoteDocuments")}(t));let a=w.resolve();return n<3&&i>=3&&(n!==0&&(function(c){c.deleteObjectStore("targetDocuments"),c.deleteObjectStore("targets"),c.deleteObjectStore("targetGlobal")}(t),Oc(t)),a=a.next(()=>function(c){const h=c.store("targetGlobal"),f={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:U.min().toTimestamp(),targetCount:0};return h.put("targetGlobalKey",f)}(s))),n<4&&i>=4&&(n!==0&&(a=a.next(()=>function(c,h){return h.store("mutations").U().next(f=>{c.deleteObjectStore("mutations"),c.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",Ju,{unique:!0});const g=h.store("mutations"),_=f.map(R=>g.put(R));return w.waitFor(_)})}(t,s))),a=a.next(()=>{(function(c){c.createObjectStore("clientMetadata",{keyPath:"clientId"})})(t)})),n<5&&i>=5&&(a=a.next(()=>this.ni(s))),n<6&&i>=6&&(a=a.next(()=>(function(c){c.createObjectStore("remoteDocumentGlobal")}(t),this.ri(s)))),n<7&&i>=7&&(a=a.next(()=>this.ii(s))),n<8&&i>=8&&(a=a.next(()=>this.si(t,s))),n<9&&i>=9&&(a=a.next(()=>{(function(c){c.objectStoreNames.contains("remoteDocumentChanges")&&c.deleteObjectStore("remoteDocumentChanges")})(t)})),n<10&&i>=10&&(a=a.next(()=>this.oi(s))),n<11&&i>=11&&(a=a.next(()=>{(function(c){c.createObjectStore("bundles",{keyPath:"bundleId"})})(t),function(c){c.createObjectStore("namedQueries",{keyPath:"name"})}(t)})),n<12&&i>=12&&(a=a.next(()=>{(function(c){const h=c.createObjectStore("documentOverlays",{keyPath:Qg});h.createIndex("collectionPathOverlayIndex",Wg,{unique:!1}),h.createIndex("collectionGroupOverlayIndex",Hg,{unique:!1})})(t)})),n<13&&i>=13&&(a=a.next(()=>function(c){const h=c.createObjectStore("remoteDocumentsV14",{keyPath:Mg});h.createIndex("documentKeyIndex",Og),h.createIndex("collectionGroupIndex",Lg)}(t)).next(()=>this._i(t,s)).next(()=>t.deleteObjectStore("remoteDocuments"))),n<14&&i>=14&&(a=a.next(()=>this.ai(t,s))),n<15&&i>=15&&(a=a.next(()=>function(c){c.createObjectStore("indexConfiguration",{keyPath:"indexId",autoIncrement:!0}).createIndex("collectionGroupIndex","collectionGroup",{unique:!1}),c.createObjectStore("indexState",{keyPath:jg}).createIndex("sequenceNumberIndex",Gg,{unique:!1}),c.createObjectStore("indexEntries",{keyPath:Kg}).createIndex("documentKeyIndex",$g,{unique:!1})}(t))),n<16&&i>=16&&(a=a.next(()=>{e.objectStore("indexState").clear()}).next(()=>{e.objectStore("indexEntries").clear()})),n<17&&i>=17&&(a=a.next(()=>{(function(c){c.createObjectStore("globals",{keyPath:"name"})})(t)})),a}ri(t){let e=0;return t.store("remoteDocuments").J((n,i)=>{e+=Zi(i)}).next(()=>{const n={byteSize:e};return t.store("remoteDocumentGlobal").put("remoteDocumentGlobalKey",n)})}ni(t){const e=t.store("mutationQueues"),n=t.store("mutations");return e.U().next(i=>w.forEach(i,s=>{const a=IDBKeyRange.bound([s.userId,-1],[s.userId,s.lastAcknowledgedBatchId]);return n.U("userMutationsIndex",a).next(u=>w.forEach(u,c=>{L(c.userId===s.userId);const h=$e(this.serializer,c);return $h(t,s.userId,h).next(()=>{})}))}))}ii(t){const e=t.store("targetDocuments"),n=t.store("remoteDocuments");return t.store("targetGlobal").get("targetGlobalKey").next(i=>{const s=[];return n.J((a,u)=>{const c=new W(a),h=function(g){return[0,Nt(g)]}(c);s.push(e.get(h).next(f=>f?w.resolve():(g=>e.put({targetId:0,path:Nt(g),sequenceNumber:i.highestListenSequenceNumber}))(c)))}).next(()=>w.waitFor(s))})}si(t,e){t.createObjectStore("collectionParents",{keyPath:zg});const n=e.store("collectionParents"),i=new ea,s=a=>{if(i.add(a)){const u=a.lastSegment(),c=a.popLast();return n.put({collectionId:u,parent:Nt(c)})}};return e.store("remoteDocuments").J({H:!0},(a,u)=>{const c=new W(a);return s(c.popLast())}).next(()=>e.store("documentMutations").J({H:!0},([a,u,c],h)=>{const f=$t(u);return s(f.popLast())}))}oi(t){const e=t.store("targets");return e.J((n,i)=>{const s=Sr(i),a=jh(this.serializer,s);return e.put(a)})}_i(t,e){const n=e.store("remoteDocuments"),i=[];return n.J((s,a)=>{const u=e.store("remoteDocumentsV14"),c=function(g){return g.document?new M(W.fromString(g.document.name).popFirst(5)):g.noDocument?M.fromSegments(g.noDocument.path):g.unknownDocument?M.fromSegments(g.unknownDocument.path):O()}(a).path.toArray(),h={prefixPath:c.slice(0,c.length-2),collectionGroup:c[c.length-2],documentId:c[c.length-1],readTime:a.readTime||[0,0],unknownDocument:a.unknownDocument,noDocument:a.noDocument,document:a.document,hasCommittedMutations:!!a.hasCommittedMutations};i.push(u.put(h))}).next(()=>w.waitFor(i))}ai(t,e){const n=e.store("mutations"),i=Xh(this.serializer),s=new ra(ps.Zr,this.serializer.ct);return n.U().next(a=>{const u=new Map;return a.forEach(c=>{var h;let f=(h=u.get(c.userId))!==null&&h!==void 0?h:G();$e(this.serializer,c).keys().forEach(g=>f=f.add(g)),u.set(c.userId,f)}),w.forEach(u,(c,h)=>{const f=new Tt(h),g=ms.lt(this.serializer,f),_=s.getIndexManager(f),R=gs.lt(f,this.serializer,_,s.referenceDelegate);return new Zh(i,R,g,_).recalculateAndSaveOverlaysForDocumentKeys(new po(e,Ot.oe),c).next()})})}}function Oc(r){r.createObjectStore("targetDocuments",{keyPath:Ug}).createIndex("documentTargetsIndex",qg,{unique:!0}),r.createObjectStore("targets",{keyPath:"targetId"}).createIndex("queryTargetsIndex",Bg,{unique:!0}),r.createObjectStore("targetGlobal")}const io="Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.";class ia{constructor(t,e,n,i,s,a,u,c,h,f,g=17){if(this.allowTabSynchronization=t,this.persistenceKey=e,this.clientId=n,this.ui=s,this.window=a,this.document=u,this.ci=h,this.li=f,this.hi=g,this.Qr=null,this.Kr=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Pi=null,this.inForeground=!1,this.Ii=null,this.Ti=null,this.Ei=Number.NEGATIVE_INFINITY,this.di=_=>Promise.resolve(),!ia.D())throw new D(P.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new Xp(this,i),this.Ai=e+"main",this.serializer=new zh(c),this.Ri=new Wt(this.Ai,this.hi,new l_(this.serializer)),this.$r=new qp,this.Ur=new Hp(this.referenceDelegate,this.serializer),this.remoteDocumentCache=Xh(this.serializer),this.Gr=new Up,this.window&&this.window.localStorage?this.Vi=this.window.localStorage:(this.Vi=null,f===!1&&gt("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.mi().then(()=>{if(!this.isPrimary&&!this.allowTabSynchronization)throw new D(P.FAILED_PRECONDITION,io);return this.fi(),this.gi(),this.pi(),this.runTransaction("getHighestListenSequenceNumber","readonly",t=>this.Ur.getHighestSequenceNumber(t))}).then(t=>{this.Qr=new Ot(t,this.ci)}).then(()=>{this.Kr=!0}).catch(t=>(this.Ri&&this.Ri.close(),Promise.reject(t)))}yi(t){return this.di=async e=>{if(this.started)return t(e)},t(this.isPrimary)}setDatabaseDeletedListener(t){this.Ri.L(async e=>{e.newVersion===null&&await t()})}setNetworkEnabled(t){this.networkEnabled!==t&&(this.networkEnabled=t,this.ui.enqueueAndForget(async()=>{this.started&&await this.mi()}))}mi(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",t=>Ni(t).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next(()=>{if(this.isPrimary)return this.wi(t).next(e=>{e||(this.isPrimary=!1,this.ui.enqueueRetryable(()=>this.di(!1)))})}).next(()=>this.Si(t)).next(e=>this.isPrimary&&!e?this.bi(t).next(()=>!1):!!e&&this.Di(t).next(()=>!0))).catch(t=>{if(xe(t))return x("IndexedDbPersistence","Failed to extend owner lease: ",t),this.isPrimary;if(!this.allowTabSynchronization)throw t;return x("IndexedDbPersistence","Releasing owner lease after error during lease refresh",t),!1}).then(t=>{this.isPrimary!==t&&this.ui.enqueueRetryable(()=>this.di(t)),this.isPrimary=t})}wi(t){return Ar(t).get("owner").next(e=>w.resolve(this.vi(e)))}Ci(t){return Ni(t).delete(this.clientId)}async Fi(){if(this.isPrimary&&!this.Mi(this.Ei,18e5)){this.Ei=Date.now();const t=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",e=>{const n=It(e,"clientMetadata");return n.U().next(i=>{const s=this.xi(i,18e5),a=i.filter(u=>s.indexOf(u)===-1);return w.forEach(a,u=>n.delete(u.clientId)).next(()=>a)})}).catch(()=>[]);if(this.Vi)for(const e of t)this.Vi.removeItem(this.Oi(e.clientId))}}pi(){this.Ti=this.ui.enqueueAfterDelay("client_metadata_refresh",4e3,()=>this.mi().then(()=>this.Fi()).then(()=>this.pi()))}vi(t){return!!t&&t.ownerId===this.clientId}Si(t){return this.li?w.resolve(!0):Ar(t).get("owner").next(e=>{if(e!==null&&this.Mi(e.leaseTimestampMs,5e3)&&!this.Ni(e.ownerId)){if(this.vi(e)&&this.networkEnabled)return!0;if(!this.vi(e)){if(!e.allowTabSynchronization)throw new D(P.FAILED_PRECONDITION,io);return!1}}return!(!this.networkEnabled||!this.inForeground)||Ni(t).U().next(n=>this.xi(n,5e3).find(i=>{if(this.clientId!==i.clientId){const s=!this.networkEnabled&&i.networkEnabled,a=!this.inForeground&&i.inForeground,u=this.networkEnabled===i.networkEnabled;if(s||a&&u)return!0}return!1})===void 0)}).next(e=>(this.isPrimary!==e&&x("IndexedDbPersistence",`Client ${e?"is":"is not"} eligible for a primary lease.`),e))}async shutdown(){this.Kr=!1,this.Li(),this.Ti&&(this.Ti.cancel(),this.Ti=null),this.Bi(),this.ki(),await this.Ri.runTransaction("shutdown","readwrite",["owner","clientMetadata"],t=>{const e=new po(t,Ot.oe);return this.bi(e).next(()=>this.Ci(e))}),this.Ri.close(),this.qi()}xi(t,e){return t.filter(n=>this.Mi(n.updateTimeMs,e)&&!this.Ni(n.clientId))}Qi(){return this.runTransaction("getActiveClients","readonly",t=>Ni(t).U().next(e=>this.xi(e,18e5).map(n=>n.clientId)))}get started(){return this.Kr}getGlobalsCache(){return this.$r}getMutationQueue(t,e){return gs.lt(t,this.serializer,e,this.referenceDelegate)}getTargetCache(){return this.Ur}getRemoteDocumentCache(){return this.remoteDocumentCache}getIndexManager(t){return new Wp(t,this.serializer.ct.databaseId)}getDocumentOverlayCache(t){return ms.lt(this.serializer,t)}getBundleCache(){return this.Gr}runTransaction(t,e,n){x("IndexedDbPersistence","Starting transaction:",t);const i=e==="readonly"?"readonly":"readwrite",s=function(c){return c===17?Xg:c===16?Yg:c===15?zo:c===14?Ql:c===13?$l:c===12?Jg:c===11?Kl:void O()}(this.hi);let a;return this.Ri.runTransaction(t,i,s,u=>(a=new po(u,this.Qr?this.Qr.next():Ot.oe),e==="readwrite-primary"?this.wi(a).next(c=>!!c||this.Si(a)).next(c=>{if(!c)throw gt(`Failed to obtain primary lease for action '${t}'.`),this.isPrimary=!1,this.ui.enqueueRetryable(()=>this.di(!1)),new D(P.FAILED_PRECONDITION,Ul);return n(a)}).next(c=>this.Di(a).next(()=>c)):this.Ki(a).next(()=>n(a)))).then(u=>(a.raiseOnCommittedEvent(),u))}Ki(t){return Ar(t).get("owner").next(e=>{if(e!==null&&this.Mi(e.leaseTimestampMs,5e3)&&!this.Ni(e.ownerId)&&!this.vi(e)&&!(this.li||this.allowTabSynchronization&&e.allowTabSynchronization))throw new D(P.FAILED_PRECONDITION,io)})}Di(t){const e={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return Ar(t).put("owner",e)}static D(){return Wt.D()}bi(t){const e=Ar(t);return e.get("owner").next(n=>this.vi(n)?(x("IndexedDbPersistence","Releasing primary lease."),e.delete("owner")):w.resolve())}Mi(t,e){const n=Date.now();return!(t<n-e)&&(!(t>n)||(gt(`Detected an update time that is in the future: ${t} > ${n}`),!1))}fi(){this.document!==null&&typeof this.document.addEventListener=="function"&&(this.Ii=()=>{this.ui.enqueueAndForget(()=>(this.inForeground=this.document.visibilityState==="visible",this.mi()))},this.document.addEventListener("visibilitychange",this.Ii),this.inForeground=this.document.visibilityState==="visible")}Bi(){this.Ii&&(this.document.removeEventListener("visibilitychange",this.Ii),this.Ii=null)}gi(){var t;typeof((t=this.window)===null||t===void 0?void 0:t.addEventListener)=="function"&&(this.Pi=()=>{this.Li();const e=/(?:Version|Mobile)\/1[456]/;hl()&&(navigator.appVersion.match(e)||navigator.userAgent.match(e))&&this.ui.enterRestrictedMode(!0),this.ui.enqueueAndForget(()=>this.shutdown())},this.window.addEventListener("pagehide",this.Pi))}ki(){this.Pi&&(this.window.removeEventListener("pagehide",this.Pi),this.Pi=null)}Ni(t){var e;try{const n=((e=this.Vi)===null||e===void 0?void 0:e.getItem(this.Oi(t)))!==null;return x("IndexedDbPersistence",`Client '${t}' ${n?"is":"is not"} zombied in LocalStorage`),n}catch(n){return gt("IndexedDbPersistence","Failed to get zombied client id.",n),!1}}Li(){if(this.Vi)try{this.Vi.setItem(this.Oi(this.clientId),String(Date.now()))}catch(t){gt("Failed to set zombie client id.",t)}}qi(){if(this.Vi)try{this.Vi.removeItem(this.Oi(this.clientId))}catch{}}Oi(t){return`firestore_zombie_${this.persistenceKey}_${t}`}}function Ar(r){return It(r,"owner")}function Ni(r){return It(r,"clientMetadata")}function sa(r,t){let e=r.projectId;return r.isDefaultDatabase||(e+="."+r.database),"firestore/"+t+"/"+e+"/"}/**
1712
1712
  * @license
1713
1713
  * Copyright 2017 Google LLC
1714
1714
  *
@@ -1753,7 +1753,7 @@ Total Duration: ${h-f}ms`),w.resolve({didRun:!0,sequenceNumbersCollected:i,targe
1753
1753
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1754
1754
  * See the License for the specific language governing permissions and
1755
1755
  * limitations under the License.
1756
- */class td{constructor(){this.Gi=!1,this.zi=!1,this.ji=100,this.Hi=function(){return hl()?8:zl(Ki())>0?6:4}()}initialize(t,e){this.Ji=t,this.indexManager=e,this.Gi=!0}getDocumentsMatchingQuery(t,e,n,i){const s={result:null};return this.Yi(t,e).next(a=>{s.result=a}).next(()=>{if(!s.result)return this.Zi(t,e,i,n).next(a=>{s.result=a})}).next(()=>{if(s.result)return;const a=new h_;return this.Xi(t,e,a).next(u=>{if(s.result=u,this.zi)return this.es(t,e,a,u.size)})}).next(()=>s.result)}es(t,e,n,i){return n.documentReadCount<this.ji?(En()<=J.DEBUG&&x("QueryEngine","SDK will not create cache indexes for query:",Tn(e),"since it only creates cache indexes for collection contains","more than or equal to",this.ji,"documents"),w.resolve()):(En()<=J.DEBUG&&x("QueryEngine","Query:",Tn(e),"scans",n.documentReadCount,"local documents and returns",i,"documents as results."),n.documentReadCount>this.Hi*i?(En()<=J.DEBUG&&x("QueryEngine","The SDK decides to create cache indexes for query:",Tn(e),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(t,kt(e))):w.resolve())}Yi(t,e){if(cc(e))return w.resolve(null);let n=kt(e);return this.indexManager.getIndexType(t,n).next(i=>i===0?null:(e.limit!==null&&i===1&&(e=Hi(e,null,"F"),n=kt(e)),this.indexManager.getDocumentsMatchingTarget(t,n).next(s=>{const a=G(...s);return this.Ji.getDocuments(t,a).next(u=>this.indexManager.getMinOffset(t,n).next(c=>{const h=this.ts(e,u);return this.ns(e,h,a,c.readTime)?this.Yi(t,Hi(e,null,"F")):this.rs(t,h,e,c)}))})))}Zi(t,e,n,i){return cc(e)||i.isEqual(U.min())?w.resolve(null):this.Ji.getDocuments(t,n).next(s=>{const a=this.ts(e,s);return this.ns(e,a,n,i)?w.resolve(null):(En()<=J.DEBUG&&x("QueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),Tn(e)),this.rs(t,a,e,Ll(i,-1)).next(u=>u))})}ts(t,e){let n=new et(dh(t));return e.forEach((i,s)=>{Yr(t,s)&&(n=n.add(s))}),n}ns(t,e,n,i){if(t.limit===null)return!1;if(n.size!==e.size)return!0;const s=t.limitType==="F"?e.last():e.first();return!!s&&(s.hasPendingWrites||s.version.compareTo(i)>0)}Xi(t,e,n){return En()<=J.DEBUG&&x("QueryEngine","Using full collection scan to execute query:",Tn(e)),this.Ji.getDocumentsMatchingQuery(t,e,zt.min(),n)}rs(t,e,n,i){return this.Ji.getDocumentsMatchingQuery(t,n,i).next(s=>(e.forEach(a=>{s=s.insert(a.key,a)}),s))}}/**
1756
+ */class td{constructor(){this.Gi=!1,this.zi=!1,this.ji=100,this.Hi=function(){return hl()?8:zl(Ki())>0?6:4}()}initialize(t,e){this.Ji=t,this.indexManager=e,this.Gi=!0}getDocumentsMatchingQuery(t,e,n,i){const s={result:null};return this.Yi(t,e).next(a=>{s.result=a}).next(()=>{if(!s.result)return this.Zi(t,e,i,n).next(a=>{s.result=a})}).next(()=>{if(s.result)return;const a=new h_;return this.Xi(t,e,a).next(u=>{if(s.result=u,this.zi)return this.es(t,e,a,u.size)})}).next(()=>s.result)}es(t,e,n,i){return n.documentReadCount<this.ji?(Tn()<=J.DEBUG&&x("QueryEngine","SDK will not create cache indexes for query:",vn(e),"since it only creates cache indexes for collection contains","more than or equal to",this.ji,"documents"),w.resolve()):(Tn()<=J.DEBUG&&x("QueryEngine","Query:",vn(e),"scans",n.documentReadCount,"local documents and returns",i,"documents as results."),n.documentReadCount>this.Hi*i?(Tn()<=J.DEBUG&&x("QueryEngine","The SDK decides to create cache indexes for query:",vn(e),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(t,kt(e))):w.resolve())}Yi(t,e){if(cc(e))return w.resolve(null);let n=kt(e);return this.indexManager.getIndexType(t,n).next(i=>i===0?null:(e.limit!==null&&i===1&&(e=Hi(e,null,"F"),n=kt(e)),this.indexManager.getDocumentsMatchingTarget(t,n).next(s=>{const a=G(...s);return this.Ji.getDocuments(t,a).next(u=>this.indexManager.getMinOffset(t,n).next(c=>{const h=this.ts(e,u);return this.ns(e,h,a,c.readTime)?this.Yi(t,Hi(e,null,"F")):this.rs(t,h,e,c)}))})))}Zi(t,e,n,i){return cc(e)||i.isEqual(U.min())?w.resolve(null):this.Ji.getDocuments(t,n).next(s=>{const a=this.ts(e,s);return this.ns(e,a,n,i)?w.resolve(null):(Tn()<=J.DEBUG&&x("QueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),vn(e)),this.rs(t,a,e,Ll(i,-1)).next(u=>u))})}ts(t,e){let n=new et(dh(t));return e.forEach((i,s)=>{Yr(t,s)&&(n=n.add(s))}),n}ns(t,e,n,i){if(t.limit===null)return!1;if(n.size!==e.size)return!0;const s=t.limitType==="F"?e.last():e.first();return!!s&&(s.hasPendingWrites||s.version.compareTo(i)>0)}Xi(t,e,n){return Tn()<=J.DEBUG&&x("QueryEngine","Using full collection scan to execute query:",vn(e)),this.Ji.getDocumentsMatchingQuery(t,e,zt.min(),n)}rs(t,e,n,i){return this.Ji.getDocumentsMatchingQuery(t,n,i).next(s=>(e.forEach(a=>{s=s.insert(a.key,a)}),s))}}/**
1757
1757
  * @license
1758
1758
  * Copyright 2020 Google LLC
1759
1759
  *
@@ -1768,7 +1768,7 @@ Total Duration: ${h-f}ms`),w.resolve({didRun:!0,sequenceNumbersCollected:i,targe
1768
1768
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1769
1769
  * See the License for the specific language governing permissions and
1770
1770
  * limitations under the License.
1771
- */class d_{constructor(t,e,n,i){this.persistence=t,this.ss=e,this.serializer=i,this.os=new it(j),this._s=new se(s=>Ze(s),Hr),this.us=new Map,this.cs=t.getRemoteDocumentCache(),this.Ur=t.getTargetCache(),this.Gr=t.getBundleCache(),this.ls(n)}ls(t){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(t),this.indexManager=this.persistence.getIndexManager(t),this.mutationQueue=this.persistence.getMutationQueue(t,this.indexManager),this.localDocuments=new Zh(this.cs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.cs.setIndexManager(this.indexManager),this.ss.initialize(this.localDocuments,this.indexManager)}collectGarbage(t){return this.persistence.runTransaction("Collect garbage","readwrite-primary",e=>t.collect(e,this.os))}}function ed(r,t,e,n){return new d_(r,t,e,n)}async function nd(r,t){const e=k(r);return await e.persistence.runTransaction("Handle user change","readonly",n=>{let i;return e.mutationQueue.getAllMutationBatches(n).next(s=>(i=s,e.ls(t),e.mutationQueue.getAllMutationBatches(n))).next(s=>{const a=[],u=[];let c=G();for(const h of i){a.push(h.batchId);for(const f of h.mutations)c=c.add(f.key)}for(const h of s){u.push(h.batchId);for(const f of h.mutations)c=c.add(f.key)}return e.localDocuments.getDocuments(n,c).next(h=>({hs:h,removedBatchIds:a,addedBatchIds:u}))})})}function f_(r,t){const e=k(r);return e.persistence.runTransaction("Acknowledge batch","readwrite-primary",n=>{const i=t.batch.keys(),s=e.cs.newChangeBuffer({trackRemovals:!0});return function(u,c,h,f){const g=h.batch,_=g.keys();let R=w.resolve();return _.forEach(C=>{R=R.next(()=>f.getEntry(c,C)).next(N=>{const V=h.docVersions.get(C);L(V!==null),N.version.compareTo(V)<0&&(g.applyToRemoteDocument(N,h),N.isValidDocument()&&(N.setReadTime(h.commitVersion),f.addEntry(N)))})}),R.next(()=>u.mutationQueue.removeMutationBatch(c,g))}(e,n,t,s).next(()=>s.apply(n)).next(()=>e.mutationQueue.performConsistencyCheck(n)).next(()=>e.documentOverlayCache.removeOverlaysForBatchId(n,i,t.batch.batchId)).next(()=>e.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(n,function(u){let c=G();for(let h=0;h<u.mutationResults.length;++h)u.mutationResults[h].transformResults.length>0&&(c=c.add(u.batch.mutations[h].key));return c}(t))).next(()=>e.localDocuments.getDocuments(n,i))})}function rd(r){const t=k(r);return t.persistence.runTransaction("Get last remote snapshot version","readonly",e=>t.Ur.getLastRemoteSnapshotVersion(e))}function m_(r,t){const e=k(r),n=t.snapshotVersion;let i=e.os;return e.persistence.runTransaction("Apply remote event","readwrite-primary",s=>{const a=e.cs.newChangeBuffer({trackRemovals:!0});i=e.os;const u=[];t.targetChanges.forEach((f,g)=>{const _=i.get(g);if(!_)return;u.push(e.Ur.removeMatchingKeys(s,f.removedDocuments,g).next(()=>e.Ur.addMatchingKeys(s,f.addedDocuments,g)));let R=_.withSequenceNumber(s.currentSequenceNumber);t.targetMismatches.get(g)!==null?R=R.withResumeToken(dt.EMPTY_BYTE_STRING,U.min()).withLastLimboFreeSnapshotVersion(U.min()):f.resumeToken.approximateByteSize()>0&&(R=R.withResumeToken(f.resumeToken,n)),i=i.insert(g,R),function(N,V,q){return N.resumeToken.approximateByteSize()===0||V.snapshotVersion.toMicroseconds()-N.snapshotVersion.toMicroseconds()>=3e8?!0:q.addedDocuments.size+q.modifiedDocuments.size+q.removedDocuments.size>0}(_,R,f)&&u.push(e.Ur.updateTargetData(s,R))});let c=Bt(),h=G();if(t.documentUpdates.forEach(f=>{t.resolvedLimboDocuments.has(f)&&u.push(e.persistence.referenceDelegate.updateLimboDocument(s,f))}),u.push(id(s,a,t.documentUpdates).next(f=>{c=f.Ps,h=f.Is})),!n.isEqual(U.min())){const f=e.Ur.getLastRemoteSnapshotVersion(s).next(g=>e.Ur.setTargetsMetadata(s,s.currentSequenceNumber,n));u.push(f)}return w.waitFor(u).next(()=>a.apply(s)).next(()=>e.localDocuments.getLocalViewOfDocuments(s,c,h)).next(()=>c)}).then(s=>(e.os=i,s))}function id(r,t,e){let n=G(),i=G();return e.forEach(s=>n=n.add(s)),t.getEntries(r,n).next(s=>{let a=Bt();return e.forEach((u,c)=>{const h=s.get(u);c.isFoundDocument()!==h.isFoundDocument()&&(i=i.add(u)),c.isNoDocument()&&c.version.isEqual(U.min())?(t.removeEntry(u,c.readTime),a=a.insert(u,c)):!h.isValidDocument()||c.version.compareTo(h.version)>0||c.version.compareTo(h.version)===0&&h.hasPendingWrites?(t.addEntry(c),a=a.insert(u,c)):x("LocalStore","Ignoring outdated watch update for ",u,". Current version:",h.version," Watch version:",c.version)}),{Ps:a,Is:i}})}function g_(r,t){const e=k(r);return e.persistence.runTransaction("Get next mutation batch","readonly",n=>(t===void 0&&(t=-1),e.mutationQueue.getNextMutationBatchAfterBatchId(n,t)))}function On(r,t){const e=k(r);return e.persistence.runTransaction("Allocate target","readwrite",n=>{let i;return e.Ur.getTargetData(n,t).next(s=>s?(i=s,w.resolve(i)):e.Ur.allocateTargetId(n).next(a=>(i=new te(t,a,"TargetPurposeListen",n.currentSequenceNumber),e.Ur.addTargetData(n,i).next(()=>i))))}).then(n=>{const i=e.os.get(n.targetId);return(i===null||n.snapshotVersion.compareTo(i.snapshotVersion)>0)&&(e.os=e.os.insert(n.targetId,n),e._s.set(t,n.targetId)),n})}async function Ln(r,t,e){const n=k(r),i=n.os.get(t),s=e?"readwrite":"readwrite-primary";try{e||await n.persistence.runTransaction("Release target",s,a=>n.persistence.referenceDelegate.removeTarget(a,i))}catch(a){if(!De(a))throw a;x("LocalStore",`Failed to update sequence numbers for target ${t}: ${a}`)}n.os=n.os.remove(t),n._s.delete(i.target)}function es(r,t,e){const n=k(r);let i=U.min(),s=G();return n.persistence.runTransaction("Execute query","readwrite",a=>function(c,h,f){const g=k(c),_=g._s.get(f);return _!==void 0?w.resolve(g.os.get(_)):g.Ur.getTargetData(h,f)}(n,a,kt(t)).next(u=>{if(u)return i=u.lastLimboFreeSnapshotVersion,n.Ur.getMatchingKeysForTargetId(a,u.targetId).next(c=>{s=c})}).next(()=>n.ss.getDocumentsMatchingQuery(a,t,e?i:U.min(),e?s:G())).next(u=>(ad(n,hh(t),u),{documents:u,Ts:s})))}function sd(r,t){const e=k(r),n=k(e.Ur),i=e.os.get(t);return i?Promise.resolve(i.target):e.persistence.runTransaction("Get target data","readonly",s=>n.ot(s,t).next(a=>a?a.target:null))}function od(r,t){const e=k(r),n=e.us.get(t)||U.min();return e.persistence.runTransaction("Get new document changes","readonly",i=>e.cs.getAllFromCollectionGroup(i,t,Ll(n,-1),Number.MAX_SAFE_INTEGER)).then(i=>(ad(e,t,i),i))}function ad(r,t,e){let n=r.us.get(t)||U.min();e.forEach((i,s)=>{s.readTime.compareTo(n)>0&&(n=s.readTime)}),r.us.set(t,n)}async function p_(r,t,e,n){const i=k(r);let s=G(),a=Bt();for(const h of e){const f=t.Es(h.metadata.name);h.document&&(s=s.add(f));const g=t.ds(h);g.setReadTime(t.As(h.metadata.readTime)),a=a.insert(f,g)}const u=i.cs.newChangeBuffer({trackRemovals:!0}),c=await On(i,function(f){return kt(Kn(W.fromString(`__bundle__/docs/${f}`)))}(n));return i.persistence.runTransaction("Apply bundle documents","readwrite",h=>id(h,u,a).next(f=>(u.apply(h),f)).next(f=>i.Ur.removeMatchingKeysForTargetId(h,c.targetId).next(()=>i.Ur.addMatchingKeys(h,s,c.targetId)).next(()=>i.localDocuments.getLocalViewOfDocuments(h,f.Ps,f.Is)).next(()=>f.Ps)))}async function __(r,t,e=G()){const n=await On(r,kt(Zo(t.bundledQuery))),i=k(r);return i.persistence.runTransaction("Save named query","readwrite",s=>{const a=pt(t.readTime);if(n.snapshotVersion.compareTo(a)>=0)return i.Gr.saveNamedQuery(s,t);const u=n.withResumeToken(dt.EMPTY_BYTE_STRING,a);return i.os=i.os.insert(u.targetId,u),i.Ur.updateTargetData(s,u).next(()=>i.Ur.removeMatchingKeysForTargetId(s,n.targetId)).next(()=>i.Ur.addMatchingKeys(s,e,n.targetId)).next(()=>i.Gr.saveNamedQuery(s,t))})}function Lc(r,t){return`firestore_clients_${r}_${t}`}function Bc(r,t,e){let n=`firestore_mutations_${r}_${e}`;return t.isAuthenticated()&&(n+=`_${t.uid}`),n}function so(r,t){return`firestore_targets_${r}_${t}`}class ns{constructor(t,e,n,i){this.user=t,this.batchId=e,this.state=n,this.error=i}static Rs(t,e,n){const i=JSON.parse(n);let s,a=typeof i=="object"&&["pending","acknowledged","rejected"].indexOf(i.state)!==-1&&(i.error===void 0||typeof i.error=="object");return a&&i.error&&(a=typeof i.error.message=="string"&&typeof i.error.code=="string",a&&(s=new D(i.error.code,i.error.message))),a?new ns(t,e,i.state,s):(gt("SharedClientState",`Failed to parse mutation state for ID '${e}': ${n}`),null)}Vs(){const t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)}}class xr{constructor(t,e,n){this.targetId=t,this.state=e,this.error=n}static Rs(t,e){const n=JSON.parse(e);let i,s=typeof n=="object"&&["not-current","current","rejected"].indexOf(n.state)!==-1&&(n.error===void 0||typeof n.error=="object");return s&&n.error&&(s=typeof n.error.message=="string"&&typeof n.error.code=="string",s&&(i=new D(n.error.code,n.error.message))),s?new xr(t,n.state,i):(gt("SharedClientState",`Failed to parse target state for ID '${t}': ${e}`),null)}Vs(){const t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)}}class rs{constructor(t,e){this.clientId=t,this.activeTargetIds=e}static Rs(t,e){const n=JSON.parse(e);let i=typeof n=="object"&&n.activeTargetIds instanceof Array,s=Ko();for(let a=0;i&&a<n.activeTargetIds.length;++a)i=jl(n.activeTargetIds[a]),s=s.add(n.activeTargetIds[a]);return i?new rs(t,s):(gt("SharedClientState",`Failed to parse client data for instance '${t}': ${e}`),null)}}class aa{constructor(t,e){this.clientId=t,this.onlineState=e}static Rs(t){const e=JSON.parse(t);return typeof e=="object"&&["Unknown","Online","Offline"].indexOf(e.onlineState)!==-1&&typeof e.clientId=="string"?new aa(e.clientId,e.onlineState):(gt("SharedClientState",`Failed to parse online state: ${t}`),null)}}class Co{constructor(){this.activeTargetIds=Ko()}fs(t){this.activeTargetIds=this.activeTargetIds.add(t)}gs(t){this.activeTargetIds=this.activeTargetIds.delete(t)}Vs(){const t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)}}class oo{constructor(t,e,n,i,s){this.window=t,this.ui=e,this.persistenceKey=n,this.ps=i,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.ys=this.ws.bind(this),this.Ss=new it(j),this.started=!1,this.bs=[];const a=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=s,this.Ds=Lc(this.persistenceKey,this.ps),this.vs=function(c){return`firestore_sequence_number_${c}`}(this.persistenceKey),this.Ss=this.Ss.insert(this.ps,new Co),this.Cs=new RegExp(`^firestore_clients_${a}_([^_]*)$`),this.Fs=new RegExp(`^firestore_mutations_${a}_(\\d+)(?:_(.*))?$`),this.Ms=new RegExp(`^firestore_targets_${a}_(\\d+)$`),this.xs=function(c){return`firestore_online_state_${c}`}(this.persistenceKey),this.Os=function(c){return`firestore_bundle_loaded_v2_${c}`}(this.persistenceKey),this.window.addEventListener("storage",this.ys)}static D(t){return!(!t||!t.localStorage)}async start(){const t=await this.syncEngine.Qi();for(const n of t){if(n===this.ps)continue;const i=this.getItem(Lc(this.persistenceKey,n));if(i){const s=rs.Rs(n,i);s&&(this.Ss=this.Ss.insert(s.clientId,s))}}this.Ns();const e=this.storage.getItem(this.xs);if(e){const n=this.Ls(e);n&&this.Bs(n)}for(const n of this.bs)this.ws(n);this.bs=[],this.window.addEventListener("pagehide",()=>this.shutdown()),this.started=!0}writeSequenceNumber(t){this.setItem(this.vs,JSON.stringify(t))}getAllActiveQueryTargets(){return this.ks(this.Ss)}isActiveQueryTarget(t){let e=!1;return this.Ss.forEach((n,i)=>{i.activeTargetIds.has(t)&&(e=!0)}),e}addPendingMutation(t){this.qs(t,"pending")}updateMutationState(t,e,n){this.qs(t,e,n),this.Qs(t)}addLocalQueryTarget(t,e=!0){let n="not-current";if(this.isActiveQueryTarget(t)){const i=this.storage.getItem(so(this.persistenceKey,t));if(i){const s=xr.Rs(t,i);s&&(n=s.state)}}return e&&this.Ks.fs(t),this.Ns(),n}removeLocalQueryTarget(t){this.Ks.gs(t),this.Ns()}isLocalQueryTarget(t){return this.Ks.activeTargetIds.has(t)}clearQueryState(t){this.removeItem(so(this.persistenceKey,t))}updateQueryState(t,e,n){this.$s(t,e,n)}handleUserChange(t,e,n){e.forEach(i=>{this.Qs(i)}),this.currentUser=t,n.forEach(i=>{this.addPendingMutation(i)})}setOnlineState(t){this.Us(t)}notifyBundleLoaded(t){this.Ws(t)}shutdown(){this.started&&(this.window.removeEventListener("storage",this.ys),this.removeItem(this.Ds),this.started=!1)}getItem(t){const e=this.storage.getItem(t);return x("SharedClientState","READ",t,e),e}setItem(t,e){x("SharedClientState","SET",t,e),this.storage.setItem(t,e)}removeItem(t){x("SharedClientState","REMOVE",t),this.storage.removeItem(t)}ws(t){const e=t;if(e.storageArea===this.storage){if(x("SharedClientState","EVENT",e.key,e.newValue),e.key===this.Ds)return void gt("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.ui.enqueueRetryable(async()=>{if(this.started){if(e.key!==null){if(this.Cs.test(e.key)){if(e.newValue==null){const n=this.Gs(e.key);return this.zs(n,null)}{const n=this.js(e.key,e.newValue);if(n)return this.zs(n.clientId,n)}}else if(this.Fs.test(e.key)){if(e.newValue!==null){const n=this.Hs(e.key,e.newValue);if(n)return this.Js(n)}}else if(this.Ms.test(e.key)){if(e.newValue!==null){const n=this.Ys(e.key,e.newValue);if(n)return this.Zs(n)}}else if(e.key===this.xs){if(e.newValue!==null){const n=this.Ls(e.newValue);if(n)return this.Bs(n)}}else if(e.key===this.vs){const n=function(s){let a=Ot.oe;if(s!=null)try{const u=JSON.parse(s);L(typeof u=="number"),a=u}catch(u){gt("SharedClientState","Failed to read sequence number from WebStorage",u)}return a}(e.newValue);n!==Ot.oe&&this.sequenceNumberHandler(n)}else if(e.key===this.Os){const n=this.Xs(e.newValue);await Promise.all(n.map(i=>this.syncEngine.eo(i)))}}}else this.bs.push(e)})}}get Ks(){return this.Ss.get(this.ps)}Ns(){this.setItem(this.Ds,this.Ks.Vs())}qs(t,e,n){const i=new ns(this.currentUser,t,e,n),s=Bc(this.persistenceKey,this.currentUser,t);this.setItem(s,i.Vs())}Qs(t){const e=Bc(this.persistenceKey,this.currentUser,t);this.removeItem(e)}Us(t){const e={clientId:this.ps,onlineState:t};this.storage.setItem(this.xs,JSON.stringify(e))}$s(t,e,n){const i=so(this.persistenceKey,t),s=new xr(t,e,n);this.setItem(i,s.Vs())}Ws(t){const e=JSON.stringify(Array.from(t));this.setItem(this.Os,e)}Gs(t){const e=this.Cs.exec(t);return e?e[1]:null}js(t,e){const n=this.Gs(t);return rs.Rs(n,e)}Hs(t,e){const n=this.Fs.exec(t),i=Number(n[1]),s=n[2]!==void 0?n[2]:null;return ns.Rs(new Tt(s),i,e)}Ys(t,e){const n=this.Ms.exec(t),i=Number(n[1]);return xr.Rs(i,e)}Ls(t){return aa.Rs(t)}Xs(t){return JSON.parse(t)}async Js(t){if(t.user.uid===this.currentUser.uid)return this.syncEngine.no(t.batchId,t.state,t.error);x("SharedClientState",`Ignoring mutation for non-active user ${t.user.uid}`)}Zs(t){return this.syncEngine.ro(t.targetId,t.state,t.error)}zs(t,e){const n=e?this.Ss.insert(t,e):this.Ss.remove(t),i=this.ks(this.Ss),s=this.ks(n),a=[],u=[];return s.forEach(c=>{i.has(c)||a.push(c)}),i.forEach(c=>{s.has(c)||u.push(c)}),this.syncEngine.io(a,u).then(()=>{this.Ss=n})}Bs(t){this.Ss.get(t.clientId)&&this.onlineStateHandler(t.onlineState)}ks(t){let e=Ko();return t.forEach((n,i)=>{e=e.unionWith(i.activeTargetIds)}),e}}class ud{constructor(){this.so=new Co,this.oo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(t){}updateMutationState(t,e,n){}addLocalQueryTarget(t,e=!0){return e&&this.so.fs(t),this.oo[t]||"not-current"}updateQueryState(t,e,n){this.oo[t]=e}removeLocalQueryTarget(t){this.so.gs(t)}isLocalQueryTarget(t){return this.so.activeTargetIds.has(t)}clearQueryState(t){delete this.oo[t]}getAllActiveQueryTargets(){return this.so.activeTargetIds}isActiveQueryTarget(t){return this.so.activeTargetIds.has(t)}start(){return this.so=new Co,Promise.resolve()}handleUserChange(t,e,n){}setOnlineState(t){}shutdown(){}writeSequenceNumber(t){}notifyBundleLoaded(t){}}/**
1771
+ */class d_{constructor(t,e,n,i){this.persistence=t,this.ss=e,this.serializer=i,this.os=new it(j),this._s=new se(s=>tn(s),Hr),this.us=new Map,this.cs=t.getRemoteDocumentCache(),this.Ur=t.getTargetCache(),this.Gr=t.getBundleCache(),this.ls(n)}ls(t){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(t),this.indexManager=this.persistence.getIndexManager(t),this.mutationQueue=this.persistence.getMutationQueue(t,this.indexManager),this.localDocuments=new Zh(this.cs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.cs.setIndexManager(this.indexManager),this.ss.initialize(this.localDocuments,this.indexManager)}collectGarbage(t){return this.persistence.runTransaction("Collect garbage","readwrite-primary",e=>t.collect(e,this.os))}}function ed(r,t,e,n){return new d_(r,t,e,n)}async function nd(r,t){const e=k(r);return await e.persistence.runTransaction("Handle user change","readonly",n=>{let i;return e.mutationQueue.getAllMutationBatches(n).next(s=>(i=s,e.ls(t),e.mutationQueue.getAllMutationBatches(n))).next(s=>{const a=[],u=[];let c=G();for(const h of i){a.push(h.batchId);for(const f of h.mutations)c=c.add(f.key)}for(const h of s){u.push(h.batchId);for(const f of h.mutations)c=c.add(f.key)}return e.localDocuments.getDocuments(n,c).next(h=>({hs:h,removedBatchIds:a,addedBatchIds:u}))})})}function f_(r,t){const e=k(r);return e.persistence.runTransaction("Acknowledge batch","readwrite-primary",n=>{const i=t.batch.keys(),s=e.cs.newChangeBuffer({trackRemovals:!0});return function(u,c,h,f){const g=h.batch,_=g.keys();let R=w.resolve();return _.forEach(C=>{R=R.next(()=>f.getEntry(c,C)).next(N=>{const V=h.docVersions.get(C);L(V!==null),N.version.compareTo(V)<0&&(g.applyToRemoteDocument(N,h),N.isValidDocument()&&(N.setReadTime(h.commitVersion),f.addEntry(N)))})}),R.next(()=>u.mutationQueue.removeMutationBatch(c,g))}(e,n,t,s).next(()=>s.apply(n)).next(()=>e.mutationQueue.performConsistencyCheck(n)).next(()=>e.documentOverlayCache.removeOverlaysForBatchId(n,i,t.batch.batchId)).next(()=>e.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(n,function(u){let c=G();for(let h=0;h<u.mutationResults.length;++h)u.mutationResults[h].transformResults.length>0&&(c=c.add(u.batch.mutations[h].key));return c}(t))).next(()=>e.localDocuments.getDocuments(n,i))})}function rd(r){const t=k(r);return t.persistence.runTransaction("Get last remote snapshot version","readonly",e=>t.Ur.getLastRemoteSnapshotVersion(e))}function m_(r,t){const e=k(r),n=t.snapshotVersion;let i=e.os;return e.persistence.runTransaction("Apply remote event","readwrite-primary",s=>{const a=e.cs.newChangeBuffer({trackRemovals:!0});i=e.os;const u=[];t.targetChanges.forEach((f,g)=>{const _=i.get(g);if(!_)return;u.push(e.Ur.removeMatchingKeys(s,f.removedDocuments,g).next(()=>e.Ur.addMatchingKeys(s,f.addedDocuments,g)));let R=_.withSequenceNumber(s.currentSequenceNumber);t.targetMismatches.get(g)!==null?R=R.withResumeToken(dt.EMPTY_BYTE_STRING,U.min()).withLastLimboFreeSnapshotVersion(U.min()):f.resumeToken.approximateByteSize()>0&&(R=R.withResumeToken(f.resumeToken,n)),i=i.insert(g,R),function(N,V,q){return N.resumeToken.approximateByteSize()===0||V.snapshotVersion.toMicroseconds()-N.snapshotVersion.toMicroseconds()>=3e8?!0:q.addedDocuments.size+q.modifiedDocuments.size+q.removedDocuments.size>0}(_,R,f)&&u.push(e.Ur.updateTargetData(s,R))});let c=Bt(),h=G();if(t.documentUpdates.forEach(f=>{t.resolvedLimboDocuments.has(f)&&u.push(e.persistence.referenceDelegate.updateLimboDocument(s,f))}),u.push(id(s,a,t.documentUpdates).next(f=>{c=f.Ps,h=f.Is})),!n.isEqual(U.min())){const f=e.Ur.getLastRemoteSnapshotVersion(s).next(g=>e.Ur.setTargetsMetadata(s,s.currentSequenceNumber,n));u.push(f)}return w.waitFor(u).next(()=>a.apply(s)).next(()=>e.localDocuments.getLocalViewOfDocuments(s,c,h)).next(()=>c)}).then(s=>(e.os=i,s))}function id(r,t,e){let n=G(),i=G();return e.forEach(s=>n=n.add(s)),t.getEntries(r,n).next(s=>{let a=Bt();return e.forEach((u,c)=>{const h=s.get(u);c.isFoundDocument()!==h.isFoundDocument()&&(i=i.add(u)),c.isNoDocument()&&c.version.isEqual(U.min())?(t.removeEntry(u,c.readTime),a=a.insert(u,c)):!h.isValidDocument()||c.version.compareTo(h.version)>0||c.version.compareTo(h.version)===0&&h.hasPendingWrites?(t.addEntry(c),a=a.insert(u,c)):x("LocalStore","Ignoring outdated watch update for ",u,". Current version:",h.version," Watch version:",c.version)}),{Ps:a,Is:i}})}function g_(r,t){const e=k(r);return e.persistence.runTransaction("Get next mutation batch","readonly",n=>(t===void 0&&(t=-1),e.mutationQueue.getNextMutationBatchAfterBatchId(n,t)))}function Ln(r,t){const e=k(r);return e.persistence.runTransaction("Allocate target","readwrite",n=>{let i;return e.Ur.getTargetData(n,t).next(s=>s?(i=s,w.resolve(i)):e.Ur.allocateTargetId(n).next(a=>(i=new te(t,a,"TargetPurposeListen",n.currentSequenceNumber),e.Ur.addTargetData(n,i).next(()=>i))))}).then(n=>{const i=e.os.get(n.targetId);return(i===null||n.snapshotVersion.compareTo(i.snapshotVersion)>0)&&(e.os=e.os.insert(n.targetId,n),e._s.set(t,n.targetId)),n})}async function Bn(r,t,e){const n=k(r),i=n.os.get(t),s=e?"readwrite":"readwrite-primary";try{e||await n.persistence.runTransaction("Release target",s,a=>n.persistence.referenceDelegate.removeTarget(a,i))}catch(a){if(!xe(a))throw a;x("LocalStore",`Failed to update sequence numbers for target ${t}: ${a}`)}n.os=n.os.remove(t),n._s.delete(i.target)}function es(r,t,e){const n=k(r);let i=U.min(),s=G();return n.persistence.runTransaction("Execute query","readwrite",a=>function(c,h,f){const g=k(c),_=g._s.get(f);return _!==void 0?w.resolve(g.os.get(_)):g.Ur.getTargetData(h,f)}(n,a,kt(t)).next(u=>{if(u)return i=u.lastLimboFreeSnapshotVersion,n.Ur.getMatchingKeysForTargetId(a,u.targetId).next(c=>{s=c})}).next(()=>n.ss.getDocumentsMatchingQuery(a,t,e?i:U.min(),e?s:G())).next(u=>(ad(n,hh(t),u),{documents:u,Ts:s})))}function sd(r,t){const e=k(r),n=k(e.Ur),i=e.os.get(t);return i?Promise.resolve(i.target):e.persistence.runTransaction("Get target data","readonly",s=>n.ot(s,t).next(a=>a?a.target:null))}function od(r,t){const e=k(r),n=e.us.get(t)||U.min();return e.persistence.runTransaction("Get new document changes","readonly",i=>e.cs.getAllFromCollectionGroup(i,t,Ll(n,-1),Number.MAX_SAFE_INTEGER)).then(i=>(ad(e,t,i),i))}function ad(r,t,e){let n=r.us.get(t)||U.min();e.forEach((i,s)=>{s.readTime.compareTo(n)>0&&(n=s.readTime)}),r.us.set(t,n)}async function p_(r,t,e,n){const i=k(r);let s=G(),a=Bt();for(const h of e){const f=t.Es(h.metadata.name);h.document&&(s=s.add(f));const g=t.ds(h);g.setReadTime(t.As(h.metadata.readTime)),a=a.insert(f,g)}const u=i.cs.newChangeBuffer({trackRemovals:!0}),c=await Ln(i,function(f){return kt($n(W.fromString(`__bundle__/docs/${f}`)))}(n));return i.persistence.runTransaction("Apply bundle documents","readwrite",h=>id(h,u,a).next(f=>(u.apply(h),f)).next(f=>i.Ur.removeMatchingKeysForTargetId(h,c.targetId).next(()=>i.Ur.addMatchingKeys(h,s,c.targetId)).next(()=>i.localDocuments.getLocalViewOfDocuments(h,f.Ps,f.Is)).next(()=>f.Ps)))}async function __(r,t,e=G()){const n=await Ln(r,kt(Zo(t.bundledQuery))),i=k(r);return i.persistence.runTransaction("Save named query","readwrite",s=>{const a=pt(t.readTime);if(n.snapshotVersion.compareTo(a)>=0)return i.Gr.saveNamedQuery(s,t);const u=n.withResumeToken(dt.EMPTY_BYTE_STRING,a);return i.os=i.os.insert(u.targetId,u),i.Ur.updateTargetData(s,u).next(()=>i.Ur.removeMatchingKeysForTargetId(s,n.targetId)).next(()=>i.Ur.addMatchingKeys(s,e,n.targetId)).next(()=>i.Gr.saveNamedQuery(s,t))})}function Lc(r,t){return`firestore_clients_${r}_${t}`}function Bc(r,t,e){let n=`firestore_mutations_${r}_${e}`;return t.isAuthenticated()&&(n+=`_${t.uid}`),n}function so(r,t){return`firestore_targets_${r}_${t}`}class ns{constructor(t,e,n,i){this.user=t,this.batchId=e,this.state=n,this.error=i}static Rs(t,e,n){const i=JSON.parse(n);let s,a=typeof i=="object"&&["pending","acknowledged","rejected"].indexOf(i.state)!==-1&&(i.error===void 0||typeof i.error=="object");return a&&i.error&&(a=typeof i.error.message=="string"&&typeof i.error.code=="string",a&&(s=new D(i.error.code,i.error.message))),a?new ns(t,e,i.state,s):(gt("SharedClientState",`Failed to parse mutation state for ID '${e}': ${n}`),null)}Vs(){const t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)}}class Nr{constructor(t,e,n){this.targetId=t,this.state=e,this.error=n}static Rs(t,e){const n=JSON.parse(e);let i,s=typeof n=="object"&&["not-current","current","rejected"].indexOf(n.state)!==-1&&(n.error===void 0||typeof n.error=="object");return s&&n.error&&(s=typeof n.error.message=="string"&&typeof n.error.code=="string",s&&(i=new D(n.error.code,n.error.message))),s?new Nr(t,n.state,i):(gt("SharedClientState",`Failed to parse target state for ID '${t}': ${e}`),null)}Vs(){const t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)}}class rs{constructor(t,e){this.clientId=t,this.activeTargetIds=e}static Rs(t,e){const n=JSON.parse(e);let i=typeof n=="object"&&n.activeTargetIds instanceof Array,s=Ko();for(let a=0;i&&a<n.activeTargetIds.length;++a)i=jl(n.activeTargetIds[a]),s=s.add(n.activeTargetIds[a]);return i?new rs(t,s):(gt("SharedClientState",`Failed to parse client data for instance '${t}': ${e}`),null)}}class aa{constructor(t,e){this.clientId=t,this.onlineState=e}static Rs(t){const e=JSON.parse(t);return typeof e=="object"&&["Unknown","Online","Offline"].indexOf(e.onlineState)!==-1&&typeof e.clientId=="string"?new aa(e.clientId,e.onlineState):(gt("SharedClientState",`Failed to parse online state: ${t}`),null)}}class Co{constructor(){this.activeTargetIds=Ko()}fs(t){this.activeTargetIds=this.activeTargetIds.add(t)}gs(t){this.activeTargetIds=this.activeTargetIds.delete(t)}Vs(){const t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)}}class oo{constructor(t,e,n,i,s){this.window=t,this.ui=e,this.persistenceKey=n,this.ps=i,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.ys=this.ws.bind(this),this.Ss=new it(j),this.started=!1,this.bs=[];const a=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=s,this.Ds=Lc(this.persistenceKey,this.ps),this.vs=function(c){return`firestore_sequence_number_${c}`}(this.persistenceKey),this.Ss=this.Ss.insert(this.ps,new Co),this.Cs=new RegExp(`^firestore_clients_${a}_([^_]*)$`),this.Fs=new RegExp(`^firestore_mutations_${a}_(\\d+)(?:_(.*))?$`),this.Ms=new RegExp(`^firestore_targets_${a}_(\\d+)$`),this.xs=function(c){return`firestore_online_state_${c}`}(this.persistenceKey),this.Os=function(c){return`firestore_bundle_loaded_v2_${c}`}(this.persistenceKey),this.window.addEventListener("storage",this.ys)}static D(t){return!(!t||!t.localStorage)}async start(){const t=await this.syncEngine.Qi();for(const n of t){if(n===this.ps)continue;const i=this.getItem(Lc(this.persistenceKey,n));if(i){const s=rs.Rs(n,i);s&&(this.Ss=this.Ss.insert(s.clientId,s))}}this.Ns();const e=this.storage.getItem(this.xs);if(e){const n=this.Ls(e);n&&this.Bs(n)}for(const n of this.bs)this.ws(n);this.bs=[],this.window.addEventListener("pagehide",()=>this.shutdown()),this.started=!0}writeSequenceNumber(t){this.setItem(this.vs,JSON.stringify(t))}getAllActiveQueryTargets(){return this.ks(this.Ss)}isActiveQueryTarget(t){let e=!1;return this.Ss.forEach((n,i)=>{i.activeTargetIds.has(t)&&(e=!0)}),e}addPendingMutation(t){this.qs(t,"pending")}updateMutationState(t,e,n){this.qs(t,e,n),this.Qs(t)}addLocalQueryTarget(t,e=!0){let n="not-current";if(this.isActiveQueryTarget(t)){const i=this.storage.getItem(so(this.persistenceKey,t));if(i){const s=Nr.Rs(t,i);s&&(n=s.state)}}return e&&this.Ks.fs(t),this.Ns(),n}removeLocalQueryTarget(t){this.Ks.gs(t),this.Ns()}isLocalQueryTarget(t){return this.Ks.activeTargetIds.has(t)}clearQueryState(t){this.removeItem(so(this.persistenceKey,t))}updateQueryState(t,e,n){this.$s(t,e,n)}handleUserChange(t,e,n){e.forEach(i=>{this.Qs(i)}),this.currentUser=t,n.forEach(i=>{this.addPendingMutation(i)})}setOnlineState(t){this.Us(t)}notifyBundleLoaded(t){this.Ws(t)}shutdown(){this.started&&(this.window.removeEventListener("storage",this.ys),this.removeItem(this.Ds),this.started=!1)}getItem(t){const e=this.storage.getItem(t);return x("SharedClientState","READ",t,e),e}setItem(t,e){x("SharedClientState","SET",t,e),this.storage.setItem(t,e)}removeItem(t){x("SharedClientState","REMOVE",t),this.storage.removeItem(t)}ws(t){const e=t;if(e.storageArea===this.storage){if(x("SharedClientState","EVENT",e.key,e.newValue),e.key===this.Ds)return void gt("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.ui.enqueueRetryable(async()=>{if(this.started){if(e.key!==null){if(this.Cs.test(e.key)){if(e.newValue==null){const n=this.Gs(e.key);return this.zs(n,null)}{const n=this.js(e.key,e.newValue);if(n)return this.zs(n.clientId,n)}}else if(this.Fs.test(e.key)){if(e.newValue!==null){const n=this.Hs(e.key,e.newValue);if(n)return this.Js(n)}}else if(this.Ms.test(e.key)){if(e.newValue!==null){const n=this.Ys(e.key,e.newValue);if(n)return this.Zs(n)}}else if(e.key===this.xs){if(e.newValue!==null){const n=this.Ls(e.newValue);if(n)return this.Bs(n)}}else if(e.key===this.vs){const n=function(s){let a=Ot.oe;if(s!=null)try{const u=JSON.parse(s);L(typeof u=="number"),a=u}catch(u){gt("SharedClientState","Failed to read sequence number from WebStorage",u)}return a}(e.newValue);n!==Ot.oe&&this.sequenceNumberHandler(n)}else if(e.key===this.Os){const n=this.Xs(e.newValue);await Promise.all(n.map(i=>this.syncEngine.eo(i)))}}}else this.bs.push(e)})}}get Ks(){return this.Ss.get(this.ps)}Ns(){this.setItem(this.Ds,this.Ks.Vs())}qs(t,e,n){const i=new ns(this.currentUser,t,e,n),s=Bc(this.persistenceKey,this.currentUser,t);this.setItem(s,i.Vs())}Qs(t){const e=Bc(this.persistenceKey,this.currentUser,t);this.removeItem(e)}Us(t){const e={clientId:this.ps,onlineState:t};this.storage.setItem(this.xs,JSON.stringify(e))}$s(t,e,n){const i=so(this.persistenceKey,t),s=new Nr(t,e,n);this.setItem(i,s.Vs())}Ws(t){const e=JSON.stringify(Array.from(t));this.setItem(this.Os,e)}Gs(t){const e=this.Cs.exec(t);return e?e[1]:null}js(t,e){const n=this.Gs(t);return rs.Rs(n,e)}Hs(t,e){const n=this.Fs.exec(t),i=Number(n[1]),s=n[2]!==void 0?n[2]:null;return ns.Rs(new Tt(s),i,e)}Ys(t,e){const n=this.Ms.exec(t),i=Number(n[1]);return Nr.Rs(i,e)}Ls(t){return aa.Rs(t)}Xs(t){return JSON.parse(t)}async Js(t){if(t.user.uid===this.currentUser.uid)return this.syncEngine.no(t.batchId,t.state,t.error);x("SharedClientState",`Ignoring mutation for non-active user ${t.user.uid}`)}Zs(t){return this.syncEngine.ro(t.targetId,t.state,t.error)}zs(t,e){const n=e?this.Ss.insert(t,e):this.Ss.remove(t),i=this.ks(this.Ss),s=this.ks(n),a=[],u=[];return s.forEach(c=>{i.has(c)||a.push(c)}),i.forEach(c=>{s.has(c)||u.push(c)}),this.syncEngine.io(a,u).then(()=>{this.Ss=n})}Bs(t){this.Ss.get(t.clientId)&&this.onlineStateHandler(t.onlineState)}ks(t){let e=Ko();return t.forEach((n,i)=>{e=e.unionWith(i.activeTargetIds)}),e}}class ud{constructor(){this.so=new Co,this.oo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(t){}updateMutationState(t,e,n){}addLocalQueryTarget(t,e=!0){return e&&this.so.fs(t),this.oo[t]||"not-current"}updateQueryState(t,e,n){this.oo[t]=e}removeLocalQueryTarget(t){this.so.gs(t)}isLocalQueryTarget(t){return this.so.activeTargetIds.has(t)}clearQueryState(t){delete this.oo[t]}getAllActiveQueryTargets(){return this.so.activeTargetIds}isActiveQueryTarget(t){return this.so.activeTargetIds.has(t)}start(){return this.so=new Co,Promise.resolve()}handleUserChange(t,e,n){}setOnlineState(t){}shutdown(){}writeSequenceNumber(t){}notifyBundleLoaded(t){}}/**
1772
1772
  * @license
1773
1773
  * Copyright 2019 Google LLC
1774
1774
  *
@@ -1858,7 +1858,7 @@ Total Duration: ${h-f}ms`),w.resolve({didRun:!0,sequenceNumbersCollected:i,targe
1858
1858
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1859
1859
  * See the License for the specific language governing permissions and
1860
1860
  * limitations under the License.
1861
- */const Dt="WebChannelConnection";class T_ extends class{constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const n=e.ssl?"https":"http",i=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.Do=n+"://"+e.host,this.vo=`projects/${i}/databases/${s}`,this.Co=this.databaseId.database==="(default)"?`project_id=${i}`:`project_id=${i}&database_id=${s}`}get Fo(){return!1}Mo(e,n,i,s,a){const u=ao(),c=this.xo(e,n.toUriEncodedString());x("RestConnection",`Sending RPC '${e}' ${u}:`,c,i);const h={"google-cloud-resource-prefix":this.vo,"x-goog-request-params":this.Co};return this.Oo(h,s,a),this.No(e,c,h,i).then(f=>(x("RestConnection",`Received RPC '${e}' ${u}: `,f),f),f=>{throw qt("RestConnection",`RPC '${e}' ${u} failed with error: `,f,"url: ",c,"request:",i),f})}Lo(e,n,i,s,a,u){return this.Mo(e,n,i,s,a)}Oo(e,n,i){e["X-Goog-Api-Client"]=function(){return"gl-js/ fire/"+Gn}(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),n&&n.headers.forEach((s,a)=>e[a]=s),i&&i.headers.forEach((s,a)=>e[a]=s)}xo(e,n){const i=I_[e];return`${this.Do}/v1/${n}:${i}`}terminate(){}}{constructor(t){super(t),this.forceLongPolling=t.forceLongPolling,this.autoDetectLongPolling=t.autoDetectLongPolling,this.useFetchStreams=t.useFetchStreams,this.longPollingOptions=t.longPollingOptions}No(t,e,n,i){const s=ao();return new Promise((a,u)=>{const c=new Vl;c.setWithCredentials(!0),c.listenOnce(Cl.COMPLETE,()=>{try{switch(c.getLastErrorCode()){case Mi.NO_ERROR:const f=c.getResponseJson();x(Dt,`XHR for RPC '${t}' ${s} received:`,JSON.stringify(f)),a(f);break;case Mi.TIMEOUT:x(Dt,`RPC '${t}' ${s} timed out`),u(new D(P.DEADLINE_EXCEEDED,"Request time out"));break;case Mi.HTTP_ERROR:const g=c.getStatus();if(x(Dt,`RPC '${t}' ${s} failed with status:`,g,"response text:",c.getResponseText()),g>0){let _=c.getResponseJson();Array.isArray(_)&&(_=_[0]);const R=_==null?void 0:_.error;if(R&&R.status&&R.message){const C=function(V){const q=V.toLowerCase().replace(/_/g,"-");return Object.values(P).indexOf(q)>=0?q:P.UNKNOWN}(R.status);u(new D(C,R.message))}else u(new D(P.UNKNOWN,"Server responded with status "+c.getStatus()))}else u(new D(P.UNAVAILABLE,"Connection failed."));break;default:O()}}finally{x(Dt,`RPC '${t}' ${s} completed.`)}});const h=JSON.stringify(i);x(Dt,`RPC '${t}' ${s} sending request:`,i),c.send(e,"POST",h,n,15)})}Bo(t,e,n){const i=ao(),s=[this.Do,"/","google.firestore.v1.Firestore","/",t,"/channel"],a=Nl(),u=xl(),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,e,n),c.encodeInitMessageHeaders=!0;const f=s.join("");x(Dt,`Creating RPC '${t}' stream ${i}: ${f}`,c);const g=a.createWebChannel(f,c);let _=!1,R=!1;const C=new E_({Io:V=>{R?x(Dt,`Not sending because RPC '${t}' stream ${i} is closed:`,V):(_||(x(Dt,`Opening RPC '${t}' stream ${i} transport.`),g.open(),_=!0),x(Dt,`RPC '${t}' stream ${i} sending:`,V),g.send(V))},To:()=>g.close()}),N=(V,q,z)=>{V.listen(q,B=>{try{z(B)}catch($){setTimeout(()=>{throw $},0)}})};return N(g,Ar.EventType.OPEN,()=>{R||(x(Dt,`RPC '${t}' stream ${i} transport opened.`),C.yo())}),N(g,Ar.EventType.CLOSE,()=>{R||(R=!0,x(Dt,`RPC '${t}' stream ${i} transport closed`),C.So())}),N(g,Ar.EventType.ERROR,V=>{R||(R=!0,qt(Dt,`RPC '${t}' stream ${i} transport errored:`,V),C.So(new D(P.UNAVAILABLE,"The operation could not be completed")))}),N(g,Ar.EventType.MESSAGE,V=>{var q;if(!R){const z=V.data[0];L(!!z);const B=z,$=B.error||((q=B[0])===null||q===void 0?void 0:q.error);if($){x(Dt,`RPC '${t}' stream ${i} received error:`,$);const Z=$.status;let K=function(I){const T=_t[I];if(T!==void 0)return bh(T)}(Z),E=$.message;K===void 0&&(K=P.INTERNAL,E="Unknown error status: "+Z+" with message "+$.message),R=!0,C.So(new D(K,E)),g.close()}else x(Dt,`RPC '${t}' stream ${i} received:`,z),C.bo(z)}}),N(u,Dl.STAT_EVENT,V=>{V.stat===mo.PROXY?x(Dt,`RPC '${t}' stream ${i} detected buffering proxy`):V.stat===mo.NOPROXY&&x(Dt,`RPC '${t}' stream ${i} detected no buffering proxy`)}),setTimeout(()=>{C.wo()},0),C}}/**
1861
+ */const Dt="WebChannelConnection";class T_ extends class{constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const n=e.ssl?"https":"http",i=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.Do=n+"://"+e.host,this.vo=`projects/${i}/databases/${s}`,this.Co=this.databaseId.database==="(default)"?`project_id=${i}`:`project_id=${i}&database_id=${s}`}get Fo(){return!1}Mo(e,n,i,s,a){const u=ao(),c=this.xo(e,n.toUriEncodedString());x("RestConnection",`Sending RPC '${e}' ${u}:`,c,i);const h={"google-cloud-resource-prefix":this.vo,"x-goog-request-params":this.Co};return this.Oo(h,s,a),this.No(e,c,h,i).then(f=>(x("RestConnection",`Received RPC '${e}' ${u}: `,f),f),f=>{throw qt("RestConnection",`RPC '${e}' ${u} failed with error: `,f,"url: ",c,"request:",i),f})}Lo(e,n,i,s,a,u){return this.Mo(e,n,i,s,a)}Oo(e,n,i){e["X-Goog-Api-Client"]=function(){return"gl-js/ fire/"+Kn}(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),n&&n.headers.forEach((s,a)=>e[a]=s),i&&i.headers.forEach((s,a)=>e[a]=s)}xo(e,n){const i=I_[e];return`${this.Do}/v1/${n}:${i}`}terminate(){}}{constructor(t){super(t),this.forceLongPolling=t.forceLongPolling,this.autoDetectLongPolling=t.autoDetectLongPolling,this.useFetchStreams=t.useFetchStreams,this.longPollingOptions=t.longPollingOptions}No(t,e,n,i){const s=ao();return new Promise((a,u)=>{const c=new Vl;c.setWithCredentials(!0),c.listenOnce(Cl.COMPLETE,()=>{try{switch(c.getLastErrorCode()){case Mi.NO_ERROR:const f=c.getResponseJson();x(Dt,`XHR for RPC '${t}' ${s} received:`,JSON.stringify(f)),a(f);break;case Mi.TIMEOUT:x(Dt,`RPC '${t}' ${s} timed out`),u(new D(P.DEADLINE_EXCEEDED,"Request time out"));break;case Mi.HTTP_ERROR:const g=c.getStatus();if(x(Dt,`RPC '${t}' ${s} failed with status:`,g,"response text:",c.getResponseText()),g>0){let _=c.getResponseJson();Array.isArray(_)&&(_=_[0]);const R=_==null?void 0:_.error;if(R&&R.status&&R.message){const C=function(V){const q=V.toLowerCase().replace(/_/g,"-");return Object.values(P).indexOf(q)>=0?q:P.UNKNOWN}(R.status);u(new D(C,R.message))}else u(new D(P.UNKNOWN,"Server responded with status "+c.getStatus()))}else u(new D(P.UNAVAILABLE,"Connection failed."));break;default:O()}}finally{x(Dt,`RPC '${t}' ${s} completed.`)}});const h=JSON.stringify(i);x(Dt,`RPC '${t}' ${s} sending request:`,i),c.send(e,"POST",h,n,15)})}Bo(t,e,n){const i=ao(),s=[this.Do,"/","google.firestore.v1.Firestore","/",t,"/channel"],a=Nl(),u=xl(),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,e,n),c.encodeInitMessageHeaders=!0;const f=s.join("");x(Dt,`Creating RPC '${t}' stream ${i}: ${f}`,c);const g=a.createWebChannel(f,c);let _=!1,R=!1;const C=new E_({Io:V=>{R?x(Dt,`Not sending because RPC '${t}' stream ${i} is closed:`,V):(_||(x(Dt,`Opening RPC '${t}' stream ${i} transport.`),g.open(),_=!0),x(Dt,`RPC '${t}' stream ${i} sending:`,V),g.send(V))},To:()=>g.close()}),N=(V,q,z)=>{V.listen(q,B=>{try{z(B)}catch($){setTimeout(()=>{throw $},0)}})};return N(g,Rr.EventType.OPEN,()=>{R||(x(Dt,`RPC '${t}' stream ${i} transport opened.`),C.yo())}),N(g,Rr.EventType.CLOSE,()=>{R||(R=!0,x(Dt,`RPC '${t}' stream ${i} transport closed`),C.So())}),N(g,Rr.EventType.ERROR,V=>{R||(R=!0,qt(Dt,`RPC '${t}' stream ${i} transport errored:`,V),C.So(new D(P.UNAVAILABLE,"The operation could not be completed")))}),N(g,Rr.EventType.MESSAGE,V=>{var q;if(!R){const z=V.data[0];L(!!z);const B=z,$=B.error||((q=B[0])===null||q===void 0?void 0:q.error);if($){x(Dt,`RPC '${t}' stream ${i} received error:`,$);const Z=$.status;let K=function(I){const T=_t[I];if(T!==void 0)return bh(T)}(Z),E=$.message;K===void 0&&(K=P.INTERNAL,E="Unknown error status: "+Z+" with message "+$.message),R=!0,C.So(new D(K,E)),g.close()}else x(Dt,`RPC '${t}' stream ${i} received:`,z),C.bo(z)}}),N(u,Dl.STAT_EVENT,V=>{V.stat===mo.PROXY?x(Dt,`RPC '${t}' stream ${i} detected buffering proxy`):V.stat===mo.NOPROXY&&x(Dt,`RPC '${t}' stream ${i} detected no buffering proxy`)}),setTimeout(()=>{C.wo()},0),C}}/**
1862
1862
  * @license
1863
1863
  * Copyright 2020 Google LLC
1864
1864
  *
@@ -1933,7 +1933,7 @@ Total Duration: ${h-f}ms`),w.resolve({didRun:!0,sequenceNumbersCollected:i,targe
1933
1933
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1934
1934
  * See the License for the specific language governing permissions and
1935
1935
  * limitations under the License.
1936
- */class ld{constructor(t,e,n,i,s,a,u,c){this.ui=t,this.Ho=n,this.Jo=i,this.connection=s,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=u,this.listener=c,this.state=0,this.Yo=0,this.Zo=null,this.Xo=null,this.stream=null,this.e_=0,this.t_=new ua(t,e)}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_(t){this.u_(),this.stream.send(t)}async __(){if(this.r_())return this.close(0)}u_(){this.Zo&&(this.Zo.cancel(),this.Zo=null)}c_(){this.Xo&&(this.Xo.cancel(),this.Xo=null)}async close(t,e){this.u_(),this.c_(),this.t_.cancel(),this.Yo++,t!==4?this.t_.reset():e&&e.code===P.RESOURCE_EXHAUSTED?(gt(e.toString()),gt("Using maximum backoff delay to prevent overloading the backend."),this.t_.Wo()):e&&e.code===P.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.l_(),this.stream.close(),this.stream=null),this.state=t,await this.listener.mo(e)}l_(){}auth(){this.state=1;const t=this.h_(this.Yo),e=this.Yo;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([n,i])=>{this.Yo===e&&this.P_(n,i)},n=>{t(()=>{const i=new D(P.UNKNOWN,"Fetching auth token failed: "+n.message);return this.I_(i)})})}P_(t,e){const n=this.h_(this.Yo);this.stream=this.T_(t,e),this.stream.Eo(()=>{n(()=>this.listener.Eo())}),this.stream.Ro(()=>{n(()=>(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=>{n(()=>this.I_(i))}),this.stream.onMessage(i=>{n(()=>++this.e_==1?this.E_(i):this.onNext(i))})}i_(){this.state=5,this.t_.Go(async()=>{this.state=0,this.start()})}I_(t){return x("PersistentStream",`close with error: ${t}`),this.stream=null,this.close(4,t)}h_(t){return e=>{this.ui.enqueueAndForget(()=>this.Yo===t?e():(x("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class v_ extends ld{constructor(t,e,n,i,s,a){super(t,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",e,n,i,a),this.serializer=s}T_(t,e){return this.connection.Bo("Listen",t,e)}E_(t){return this.onNext(t)}onNext(t){this.t_.reset();const e=xp(this.serializer,t),n=function(s){if(!("targetChange"in s))return U.min();const a=s.targetChange;return a.targetIds&&a.targetIds.length?U.min():a.readTime?pt(a.readTime):U.min()}(t);return this.listener.d_(e,n)}A_(t){const e={};e.database=Ro(this.serializer),e.addTarget=function(s,a){let u;const c=a.target;if(u=Qi(c)?{documents:Mh(s,c)}:{query:fs(s,c)._t},u.targetId=a.targetId,a.resumeToken.approximateByteSize()>0){u.resumeToken=Ch(s,a.resumeToken);const h=wo(s,a.expectedCount);h!==null&&(u.expectedCount=h)}else if(a.snapshotVersion.compareTo(U.min())>0){u.readTime=Mn(s,a.snapshotVersion.toTimestamp());const h=wo(s,a.expectedCount);h!==null&&(u.expectedCount=h)}return u}(this.serializer,t);const n=kp(this.serializer,t);n&&(e.labels=n),this.a_(e)}R_(t){const e={};e.database=Ro(this.serializer),e.removeTarget=t,this.a_(e)}}class w_ extends ld{constructor(t,e,n,i,s,a){super(t,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",e,n,i,a),this.serializer=s}get V_(){return this.e_>0}start(){this.lastStreamToken=void 0,super.start()}l_(){this.V_&&this.m_([])}T_(t,e){return this.connection.Bo("Write",t,e)}E_(t){return L(!!t.streamToken),this.lastStreamToken=t.streamToken,L(!t.writeResults||t.writeResults.length===0),this.listener.f_()}onNext(t){L(!!t.streamToken),this.lastStreamToken=t.streamToken,this.t_.reset();const e=Np(t.writeResults,t.commitTime),n=pt(t.commitTime);return this.listener.g_(n,e)}p_(){const t={};t.database=Ro(this.serializer),this.a_(t)}m_(t){const e={streamToken:this.lastStreamToken,writes:t.map(n=>Gr(this.serializer,n))};this.a_(e)}}/**
1936
+ */class ld{constructor(t,e,n,i,s,a,u,c){this.ui=t,this.Ho=n,this.Jo=i,this.connection=s,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=u,this.listener=c,this.state=0,this.Yo=0,this.Zo=null,this.Xo=null,this.stream=null,this.e_=0,this.t_=new ua(t,e)}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_(t){this.u_(),this.stream.send(t)}async __(){if(this.r_())return this.close(0)}u_(){this.Zo&&(this.Zo.cancel(),this.Zo=null)}c_(){this.Xo&&(this.Xo.cancel(),this.Xo=null)}async close(t,e){this.u_(),this.c_(),this.t_.cancel(),this.Yo++,t!==4?this.t_.reset():e&&e.code===P.RESOURCE_EXHAUSTED?(gt(e.toString()),gt("Using maximum backoff delay to prevent overloading the backend."),this.t_.Wo()):e&&e.code===P.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.l_(),this.stream.close(),this.stream=null),this.state=t,await this.listener.mo(e)}l_(){}auth(){this.state=1;const t=this.h_(this.Yo),e=this.Yo;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([n,i])=>{this.Yo===e&&this.P_(n,i)},n=>{t(()=>{const i=new D(P.UNKNOWN,"Fetching auth token failed: "+n.message);return this.I_(i)})})}P_(t,e){const n=this.h_(this.Yo);this.stream=this.T_(t,e),this.stream.Eo(()=>{n(()=>this.listener.Eo())}),this.stream.Ro(()=>{n(()=>(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=>{n(()=>this.I_(i))}),this.stream.onMessage(i=>{n(()=>++this.e_==1?this.E_(i):this.onNext(i))})}i_(){this.state=5,this.t_.Go(async()=>{this.state=0,this.start()})}I_(t){return x("PersistentStream",`close with error: ${t}`),this.stream=null,this.close(4,t)}h_(t){return e=>{this.ui.enqueueAndForget(()=>this.Yo===t?e():(x("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class v_ extends ld{constructor(t,e,n,i,s,a){super(t,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",e,n,i,a),this.serializer=s}T_(t,e){return this.connection.Bo("Listen",t,e)}E_(t){return this.onNext(t)}onNext(t){this.t_.reset();const e=xp(this.serializer,t),n=function(s){if(!("targetChange"in s))return U.min();const a=s.targetChange;return a.targetIds&&a.targetIds.length?U.min():a.readTime?pt(a.readTime):U.min()}(t);return this.listener.d_(e,n)}A_(t){const e={};e.database=Ro(this.serializer),e.addTarget=function(s,a){let u;const c=a.target;if(u=Qi(c)?{documents:Mh(s,c)}:{query:fs(s,c)._t},u.targetId=a.targetId,a.resumeToken.approximateByteSize()>0){u.resumeToken=Ch(s,a.resumeToken);const h=wo(s,a.expectedCount);h!==null&&(u.expectedCount=h)}else if(a.snapshotVersion.compareTo(U.min())>0){u.readTime=On(s,a.snapshotVersion.toTimestamp());const h=wo(s,a.expectedCount);h!==null&&(u.expectedCount=h)}return u}(this.serializer,t);const n=kp(this.serializer,t);n&&(e.labels=n),this.a_(e)}R_(t){const e={};e.database=Ro(this.serializer),e.removeTarget=t,this.a_(e)}}class w_ extends ld{constructor(t,e,n,i,s,a){super(t,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",e,n,i,a),this.serializer=s}get V_(){return this.e_>0}start(){this.lastStreamToken=void 0,super.start()}l_(){this.V_&&this.m_([])}T_(t,e){return this.connection.Bo("Write",t,e)}E_(t){return L(!!t.streamToken),this.lastStreamToken=t.streamToken,L(!t.writeResults||t.writeResults.length===0),this.listener.f_()}onNext(t){L(!!t.streamToken),this.lastStreamToken=t.streamToken,this.t_.reset();const e=Np(t.writeResults,t.commitTime),n=pt(t.commitTime);return this.listener.g_(n,e)}p_(){const t={};t.database=Ro(this.serializer),this.a_(t)}m_(t){const e={streamToken:this.lastStreamToken,writes:t.map(n=>Kr(this.serializer,n))};this.a_(e)}}/**
1937
1937
  * @license
1938
1938
  * Copyright 2017 Google LLC
1939
1939
  *
@@ -1964,7 +1964,7 @@ This typically indicates that your device does not have a healthy Internet conne
1964
1964
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1965
1965
  * See the License for the specific language governing permissions and
1966
1966
  * limitations under the License.
1967
- */class b_{constructor(t,e,n,i,s){this.localStore=t,this.datastore=e,this.asyncQueue=n,this.remoteSyncer={},this.O_=[],this.N_=new Map,this.L_=new Set,this.B_=[],this.k_=s,this.k_._o(a=>{n.enqueueAndForget(async()=>{Ne(this)&&(x("RemoteStore","Restarting streams for network reachability change."),await async function(c){const h=k(c);h.L_.add(4),await Wn(h),h.q_.set("Unknown"),h.L_.delete(4),await ni(h)}(this))})}),this.q_=new R_(n,i)}}async function ni(r){if(Ne(r))for(const t of r.B_)await t(!0)}async function Wn(r){for(const t of r.B_)await t(!1)}function _s(r,t){const e=k(r);e.N_.has(t.targetId)||(e.N_.set(t.targetId,t),ha(e)?la(e):Jn(e).r_()&&ca(e,t))}function Bn(r,t){const e=k(r),n=Jn(e);e.N_.delete(t),n.r_()&&hd(e,t),e.N_.size===0&&(n.r_()?n.o_():Ne(e)&&e.q_.set("Unknown"))}function ca(r,t){if(r.Q_.xe(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(U.min())>0){const e=r.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(e)}Jn(r).A_(t)}function hd(r,t){r.Q_.xe(t),Jn(r).R_(t)}function la(r){r.Q_=new Rp({getRemoteKeysForTarget:t=>r.remoteSyncer.getRemoteKeysForTarget(t),ot:t=>r.N_.get(t)||null,tt:()=>r.datastore.serializer.databaseId}),Jn(r).start(),r.q_.v_()}function ha(r){return Ne(r)&&!Jn(r).n_()&&r.N_.size>0}function Ne(r){return k(r).L_.size===0}function dd(r){r.Q_=void 0}async function P_(r){r.q_.set("Online")}async function S_(r){r.N_.forEach((t,e)=>{ca(r,t)})}async function V_(r,t){dd(r),ha(r)?(r.q_.M_(t),la(r)):r.q_.set("Unknown")}async function C_(r,t,e){if(r.q_.set("Online"),t instanceof Vh&&t.state===2&&t.cause)try{await async function(i,s){const a=s.cause;for(const u of s.targetIds)i.N_.has(u)&&(await i.remoteSyncer.rejectListen(u,a),i.N_.delete(u),i.Q_.removeTarget(u))}(r,t)}catch(n){x("RemoteStore","Failed to remove targets %s: %s ",t.targetIds.join(","),n),await is(r,n)}else if(t instanceof zi?r.Q_.Ke(t):t instanceof Sh?r.Q_.He(t):r.Q_.We(t),!e.isEqual(U.min()))try{const n=await rd(r.localStore);e.compareTo(n)>=0&&await function(s,a){const u=s.Q_.rt(a);return u.targetChanges.forEach((c,h)=>{if(c.resumeToken.approximateByteSize()>0){const f=s.N_.get(h);f&&s.N_.set(h,f.withResumeToken(c.resumeToken,a))}}),u.targetMismatches.forEach((c,h)=>{const f=s.N_.get(c);if(!f)return;s.N_.set(c,f.withResumeToken(dt.EMPTY_BYTE_STRING,f.snapshotVersion)),hd(s,c);const g=new te(f.target,c,h,f.sequenceNumber);ca(s,g)}),s.remoteSyncer.applyRemoteEvent(u)}(r,e)}catch(n){x("RemoteStore","Failed to raise snapshot:",n),await is(r,n)}}async function is(r,t,e){if(!De(t))throw t;r.L_.add(1),await Wn(r),r.q_.set("Offline"),e||(e=()=>rd(r.localStore)),r.asyncQueue.enqueueRetryable(async()=>{x("RemoteStore","Retrying IndexedDB access"),await e(),r.L_.delete(1),await ni(r)})}function fd(r,t){return t().catch(e=>is(r,e,t))}async function Hn(r){const t=k(r),e=be(t);let n=t.O_.length>0?t.O_[t.O_.length-1].batchId:-1;for(;D_(t);)try{const i=await g_(t.localStore,n);if(i===null){t.O_.length===0&&e.o_();break}n=i.batchId,x_(t,i)}catch(i){await is(t,i)}md(t)&&gd(t)}function D_(r){return Ne(r)&&r.O_.length<10}function x_(r,t){r.O_.push(t);const e=be(r);e.r_()&&e.V_&&e.m_(t.mutations)}function md(r){return Ne(r)&&!be(r).n_()&&r.O_.length>0}function gd(r){be(r).start()}async function N_(r){be(r).p_()}async function k_(r){const t=be(r);for(const e of r.O_)t.m_(e.mutations)}async function F_(r,t,e){const n=r.O_.shift(),i=Ho.from(n,t,e);await fd(r,()=>r.remoteSyncer.applySuccessfulWrite(i)),await Hn(r)}async function M_(r,t){t&&be(r).V_&&await async function(n,i){if(function(a){return Rh(a)&&a!==P.ABORTED}(i.code)){const s=n.O_.shift();be(n).s_(),await fd(n,()=>n.remoteSyncer.rejectFailedWrite(s.batchId,i)),await Hn(n)}}(r,t),md(r)&&gd(r)}async function qc(r,t){const e=k(r);e.asyncQueue.verifyOperationInProgress(),x("RemoteStore","RemoteStore received new credentials");const n=Ne(e);e.L_.add(3),await Wn(e),n&&e.q_.set("Unknown"),await e.remoteSyncer.handleCredentialChange(t),e.L_.delete(3),await ni(e)}async function Do(r,t){const e=k(r);t?(e.L_.delete(2),await ni(e)):t||(e.L_.add(2),await Wn(e),e.q_.set("Unknown"))}function Jn(r){return r.K_||(r.K_=function(e,n,i){const s=k(e);return s.w_(),new v_(n,s.connection,s.authCredentials,s.appCheckCredentials,s.serializer,i)}(r.datastore,r.asyncQueue,{Eo:P_.bind(null,r),Ro:S_.bind(null,r),mo:V_.bind(null,r),d_:C_.bind(null,r)}),r.B_.push(async t=>{t?(r.K_.s_(),ha(r)?la(r):r.q_.set("Unknown")):(await r.K_.stop(),dd(r))})),r.K_}function be(r){return r.U_||(r.U_=function(e,n,i){const s=k(e);return s.w_(),new w_(n,s.connection,s.authCredentials,s.appCheckCredentials,s.serializer,i)}(r.datastore,r.asyncQueue,{Eo:()=>Promise.resolve(),Ro:N_.bind(null,r),mo:M_.bind(null,r),f_:k_.bind(null,r),g_:F_.bind(null,r)}),r.B_.push(async t=>{t?(r.U_.s_(),await Hn(r)):(await r.U_.stop(),r.O_.length>0&&(x("RemoteStore",`Stopping write stream with ${r.O_.length} pending writes`),r.O_=[]))})),r.U_}/**
1967
+ */class b_{constructor(t,e,n,i,s){this.localStore=t,this.datastore=e,this.asyncQueue=n,this.remoteSyncer={},this.O_=[],this.N_=new Map,this.L_=new Set,this.B_=[],this.k_=s,this.k_._o(a=>{n.enqueueAndForget(async()=>{ke(this)&&(x("RemoteStore","Restarting streams for network reachability change."),await async function(c){const h=k(c);h.L_.add(4),await Hn(h),h.q_.set("Unknown"),h.L_.delete(4),await ni(h)}(this))})}),this.q_=new R_(n,i)}}async function ni(r){if(ke(r))for(const t of r.B_)await t(!0)}async function Hn(r){for(const t of r.B_)await t(!1)}function _s(r,t){const e=k(r);e.N_.has(t.targetId)||(e.N_.set(t.targetId,t),ha(e)?la(e):Yn(e).r_()&&ca(e,t))}function Un(r,t){const e=k(r),n=Yn(e);e.N_.delete(t),n.r_()&&hd(e,t),e.N_.size===0&&(n.r_()?n.o_():ke(e)&&e.q_.set("Unknown"))}function ca(r,t){if(r.Q_.xe(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(U.min())>0){const e=r.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(e)}Yn(r).A_(t)}function hd(r,t){r.Q_.xe(t),Yn(r).R_(t)}function la(r){r.Q_=new Rp({getRemoteKeysForTarget:t=>r.remoteSyncer.getRemoteKeysForTarget(t),ot:t=>r.N_.get(t)||null,tt:()=>r.datastore.serializer.databaseId}),Yn(r).start(),r.q_.v_()}function ha(r){return ke(r)&&!Yn(r).n_()&&r.N_.size>0}function ke(r){return k(r).L_.size===0}function dd(r){r.Q_=void 0}async function P_(r){r.q_.set("Online")}async function S_(r){r.N_.forEach((t,e)=>{ca(r,t)})}async function V_(r,t){dd(r),ha(r)?(r.q_.M_(t),la(r)):r.q_.set("Unknown")}async function C_(r,t,e){if(r.q_.set("Online"),t instanceof Vh&&t.state===2&&t.cause)try{await async function(i,s){const a=s.cause;for(const u of s.targetIds)i.N_.has(u)&&(await i.remoteSyncer.rejectListen(u,a),i.N_.delete(u),i.Q_.removeTarget(u))}(r,t)}catch(n){x("RemoteStore","Failed to remove targets %s: %s ",t.targetIds.join(","),n),await is(r,n)}else if(t instanceof zi?r.Q_.Ke(t):t instanceof Sh?r.Q_.He(t):r.Q_.We(t),!e.isEqual(U.min()))try{const n=await rd(r.localStore);e.compareTo(n)>=0&&await function(s,a){const u=s.Q_.rt(a);return u.targetChanges.forEach((c,h)=>{if(c.resumeToken.approximateByteSize()>0){const f=s.N_.get(h);f&&s.N_.set(h,f.withResumeToken(c.resumeToken,a))}}),u.targetMismatches.forEach((c,h)=>{const f=s.N_.get(c);if(!f)return;s.N_.set(c,f.withResumeToken(dt.EMPTY_BYTE_STRING,f.snapshotVersion)),hd(s,c);const g=new te(f.target,c,h,f.sequenceNumber);ca(s,g)}),s.remoteSyncer.applyRemoteEvent(u)}(r,e)}catch(n){x("RemoteStore","Failed to raise snapshot:",n),await is(r,n)}}async function is(r,t,e){if(!xe(t))throw t;r.L_.add(1),await Hn(r),r.q_.set("Offline"),e||(e=()=>rd(r.localStore)),r.asyncQueue.enqueueRetryable(async()=>{x("RemoteStore","Retrying IndexedDB access"),await e(),r.L_.delete(1),await ni(r)})}function fd(r,t){return t().catch(e=>is(r,e,t))}async function Jn(r){const t=k(r),e=Pe(t);let n=t.O_.length>0?t.O_[t.O_.length-1].batchId:-1;for(;D_(t);)try{const i=await g_(t.localStore,n);if(i===null){t.O_.length===0&&e.o_();break}n=i.batchId,x_(t,i)}catch(i){await is(t,i)}md(t)&&gd(t)}function D_(r){return ke(r)&&r.O_.length<10}function x_(r,t){r.O_.push(t);const e=Pe(r);e.r_()&&e.V_&&e.m_(t.mutations)}function md(r){return ke(r)&&!Pe(r).n_()&&r.O_.length>0}function gd(r){Pe(r).start()}async function N_(r){Pe(r).p_()}async function k_(r){const t=Pe(r);for(const e of r.O_)t.m_(e.mutations)}async function F_(r,t,e){const n=r.O_.shift(),i=Ho.from(n,t,e);await fd(r,()=>r.remoteSyncer.applySuccessfulWrite(i)),await Jn(r)}async function M_(r,t){t&&Pe(r).V_&&await async function(n,i){if(function(a){return Rh(a)&&a!==P.ABORTED}(i.code)){const s=n.O_.shift();Pe(n).s_(),await fd(n,()=>n.remoteSyncer.rejectFailedWrite(s.batchId,i)),await Jn(n)}}(r,t),md(r)&&gd(r)}async function qc(r,t){const e=k(r);e.asyncQueue.verifyOperationInProgress(),x("RemoteStore","RemoteStore received new credentials");const n=ke(e);e.L_.add(3),await Hn(e),n&&e.q_.set("Unknown"),await e.remoteSyncer.handleCredentialChange(t),e.L_.delete(3),await ni(e)}async function Do(r,t){const e=k(r);t?(e.L_.delete(2),await ni(e)):t||(e.L_.add(2),await Hn(e),e.q_.set("Unknown"))}function Yn(r){return r.K_||(r.K_=function(e,n,i){const s=k(e);return s.w_(),new v_(n,s.connection,s.authCredentials,s.appCheckCredentials,s.serializer,i)}(r.datastore,r.asyncQueue,{Eo:P_.bind(null,r),Ro:S_.bind(null,r),mo:V_.bind(null,r),d_:C_.bind(null,r)}),r.B_.push(async t=>{t?(r.K_.s_(),ha(r)?la(r):r.q_.set("Unknown")):(await r.K_.stop(),dd(r))})),r.K_}function Pe(r){return r.U_||(r.U_=function(e,n,i){const s=k(e);return s.w_(),new w_(n,s.connection,s.authCredentials,s.appCheckCredentials,s.serializer,i)}(r.datastore,r.asyncQueue,{Eo:()=>Promise.resolve(),Ro:N_.bind(null,r),mo:M_.bind(null,r),f_:k_.bind(null,r),g_:F_.bind(null,r)}),r.B_.push(async t=>{t?(r.U_.s_(),await Jn(r)):(await r.U_.stop(),r.O_.length>0&&(x("RemoteStore",`Stopping write stream with ${r.O_.length} pending writes`),r.O_=[]))})),r.U_}/**
1968
1968
  * @license
1969
1969
  * Copyright 2017 Google LLC
1970
1970
  *
@@ -1979,7 +1979,7 @@ This typically indicates that your device does not have a healthy Internet conne
1979
1979
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1980
1980
  * See the License for the specific language governing permissions and
1981
1981
  * limitations under the License.
1982
- */class da{constructor(t,e,n,i,s){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=i,this.removalCallback=s,this.deferred=new vt,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(a=>{})}get promise(){return this.deferred.promise}static createAndSchedule(t,e,n,i,s){const a=Date.now()+n,u=new da(t,e,a,i,s);return u.start(n),u}start(t){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),t)}skipDelay(){return this.handleDelayElapsed()}cancel(t){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new D(P.CANCELLED,"Operation cancelled"+(t?": "+t:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then(t=>this.deferred.resolve(t))):Promise.resolve())}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function Yn(r,t){if(gt("AsyncQueue",`${t}: ${r}`),De(r))return new D(P.UNAVAILABLE,`${t}: ${r}`);throw r}/**
1982
+ */class da{constructor(t,e,n,i,s){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=i,this.removalCallback=s,this.deferred=new vt,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(a=>{})}get promise(){return this.deferred.promise}static createAndSchedule(t,e,n,i,s){const a=Date.now()+n,u=new da(t,e,a,i,s);return u.start(n),u}start(t){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),t)}skipDelay(){return this.handleDelayElapsed()}cancel(t){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new D(P.CANCELLED,"Operation cancelled"+(t?": "+t:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then(t=>this.deferred.resolve(t))):Promise.resolve())}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function Xn(r,t){if(gt("AsyncQueue",`${t}: ${r}`),xe(r))return new D(P.UNAVAILABLE,`${t}: ${r}`);throw r}/**
1983
1983
  * @license
1984
1984
  * Copyright 2017 Google LLC
1985
1985
  *
@@ -1994,10 +1994,10 @@ This typically indicates that your device does not have a healthy Internet conne
1994
1994
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1995
1995
  * See the License for the specific language governing permissions and
1996
1996
  * limitations under the License.
1997
- */class Rn{constructor(t){this.comparator=t?(e,n)=>t(e,n)||M.comparator(e.key,n.key):(e,n)=>M.comparator(e.key,n.key),this.keyedMap=Rr(),this.sortedSet=new it(this.comparator)}static emptySet(t){return new Rn(t.comparator)}has(t){return this.keyedMap.get(t)!=null}get(t){return this.keyedMap.get(t)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(t){const e=this.keyedMap.get(t);return e?this.sortedSet.indexOf(e):-1}get size(){return this.sortedSet.size}forEach(t){this.sortedSet.inorderTraversal((e,n)=>(t(e),!1))}add(t){const e=this.delete(t.key);return e.copy(e.keyedMap.insert(t.key,t),e.sortedSet.insert(t,null))}delete(t){const e=this.get(t);return e?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(e)):this}isEqual(t){if(!(t instanceof Rn)||this.size!==t.size)return!1;const e=this.sortedSet.getIterator(),n=t.sortedSet.getIterator();for(;e.hasNext();){const i=e.getNext().key,s=n.getNext().key;if(!i.isEqual(s))return!1}return!0}toString(){const t=[];return this.forEach(e=>{t.push(e.toString())}),t.length===0?"DocumentSet ()":`DocumentSet (
1997
+ */class bn{constructor(t){this.comparator=t?(e,n)=>t(e,n)||M.comparator(e.key,n.key):(e,n)=>M.comparator(e.key,n.key),this.keyedMap=br(),this.sortedSet=new it(this.comparator)}static emptySet(t){return new bn(t.comparator)}has(t){return this.keyedMap.get(t)!=null}get(t){return this.keyedMap.get(t)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(t){const e=this.keyedMap.get(t);return e?this.sortedSet.indexOf(e):-1}get size(){return this.sortedSet.size}forEach(t){this.sortedSet.inorderTraversal((e,n)=>(t(e),!1))}add(t){const e=this.delete(t.key);return e.copy(e.keyedMap.insert(t.key,t),e.sortedSet.insert(t,null))}delete(t){const e=this.get(t);return e?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(e)):this}isEqual(t){if(!(t instanceof bn)||this.size!==t.size)return!1;const e=this.sortedSet.getIterator(),n=t.sortedSet.getIterator();for(;e.hasNext();){const i=e.getNext().key,s=n.getNext().key;if(!i.isEqual(s))return!1}return!0}toString(){const t=[];return this.forEach(e=>{t.push(e.toString())}),t.length===0?"DocumentSet ()":`DocumentSet (
1998
1998
  `+t.join(`
1999
1999
  `)+`
2000
- )`}copy(t,e){const n=new Rn;return n.comparator=this.comparator,n.keyedMap=t,n.sortedSet=e,n}}/**
2000
+ )`}copy(t,e){const n=new bn;return n.comparator=this.comparator,n.keyedMap=t,n.sortedSet=e,n}}/**
2001
2001
  * @license
2002
2002
  * Copyright 2017 Google LLC
2003
2003
  *
@@ -2012,7 +2012,7 @@ This typically indicates that your device does not have a healthy Internet conne
2012
2012
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2013
2013
  * See the License for the specific language governing permissions and
2014
2014
  * limitations under the License.
2015
- */class zc{constructor(){this.W_=new it(M.comparator)}track(t){const e=t.doc.key,n=this.W_.get(e);n?t.type!==0&&n.type===3?this.W_=this.W_.insert(e,t):t.type===3&&n.type!==1?this.W_=this.W_.insert(e,{type:n.type,doc:t.doc}):t.type===2&&n.type===2?this.W_=this.W_.insert(e,{type:2,doc:t.doc}):t.type===2&&n.type===0?this.W_=this.W_.insert(e,{type:0,doc:t.doc}):t.type===1&&n.type===0?this.W_=this.W_.remove(e):t.type===1&&n.type===2?this.W_=this.W_.insert(e,{type:1,doc:n.doc}):t.type===0&&n.type===1?this.W_=this.W_.insert(e,{type:2,doc:t.doc}):O():this.W_=this.W_.insert(e,t)}G_(){const t=[];return this.W_.inorderTraversal((e,n)=>{t.push(n)}),t}}class Un{constructor(t,e,n,i,s,a,u,c,h){this.query=t,this.docs=e,this.oldDocs=n,this.docChanges=i,this.mutatedKeys=s,this.fromCache=a,this.syncStateChanged=u,this.excludesMetadataChanges=c,this.hasCachedResults=h}static fromInitialDocuments(t,e,n,i,s){const a=[];return e.forEach(u=>{a.push({type:0,doc:u})}),new Un(t,e,Rn.emptySet(e),a,n,i,!0,!1,s)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(t){if(!(this.fromCache===t.fromCache&&this.hasCachedResults===t.hasCachedResults&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&Jr(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))return!1;const e=this.docChanges,n=t.docChanges;if(e.length!==n.length)return!1;for(let i=0;i<e.length;i++)if(e[i].type!==n[i].type||!e[i].doc.isEqual(n[i].doc))return!1;return!0}}/**
2015
+ */class zc{constructor(){this.W_=new it(M.comparator)}track(t){const e=t.doc.key,n=this.W_.get(e);n?t.type!==0&&n.type===3?this.W_=this.W_.insert(e,t):t.type===3&&n.type!==1?this.W_=this.W_.insert(e,{type:n.type,doc:t.doc}):t.type===2&&n.type===2?this.W_=this.W_.insert(e,{type:2,doc:t.doc}):t.type===2&&n.type===0?this.W_=this.W_.insert(e,{type:0,doc:t.doc}):t.type===1&&n.type===0?this.W_=this.W_.remove(e):t.type===1&&n.type===2?this.W_=this.W_.insert(e,{type:1,doc:n.doc}):t.type===0&&n.type===1?this.W_=this.W_.insert(e,{type:2,doc:t.doc}):O():this.W_=this.W_.insert(e,t)}G_(){const t=[];return this.W_.inorderTraversal((e,n)=>{t.push(n)}),t}}class qn{constructor(t,e,n,i,s,a,u,c,h){this.query=t,this.docs=e,this.oldDocs=n,this.docChanges=i,this.mutatedKeys=s,this.fromCache=a,this.syncStateChanged=u,this.excludesMetadataChanges=c,this.hasCachedResults=h}static fromInitialDocuments(t,e,n,i,s){const a=[];return e.forEach(u=>{a.push({type:0,doc:u})}),new qn(t,e,bn.emptySet(e),a,n,i,!0,!1,s)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(t){if(!(this.fromCache===t.fromCache&&this.hasCachedResults===t.hasCachedResults&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&Jr(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))return!1;const e=this.docChanges,n=t.docChanges;if(e.length!==n.length)return!1;for(let i=0;i<e.length;i++)if(e[i].type!==n[i].type||!e[i].doc.isEqual(n[i].doc))return!1;return!0}}/**
2016
2016
  * @license
2017
2017
  * Copyright 2017 Google LLC
2018
2018
  *
@@ -2027,7 +2027,7 @@ This typically indicates that your device does not have a healthy Internet conne
2027
2027
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2028
2028
  * See the License for the specific language governing permissions and
2029
2029
  * limitations under the License.
2030
- */class O_{constructor(){this.z_=void 0,this.j_=[]}H_(){return this.j_.some(t=>t.J_())}}class L_{constructor(){this.queries=jc(),this.onlineState="Unknown",this.Y_=new Set}terminate(){(function(e,n){const i=k(e),s=i.queries;i.queries=jc(),s.forEach((a,u)=>{for(const c of u.j_)c.onError(n)})})(this,new D(P.ABORTED,"Firestore shutting down"))}}function jc(){return new se(r=>lh(r),Jr)}async function fa(r,t){const e=k(r);let n=3;const i=t.query;let s=e.queries.get(i);s?!s.H_()&&t.J_()&&(n=2):(s=new O_,n=t.J_()?0:1);try{switch(n){case 0:s.z_=await e.onListen(i,!0);break;case 1:s.z_=await e.onListen(i,!1);break;case 2:await e.onFirstRemoteStoreListen(i)}}catch(a){const u=Yn(a,`Initialization of query '${Tn(t.query)}' failed`);return void t.onError(u)}e.queries.set(i,s),s.j_.push(t),t.Z_(e.onlineState),s.z_&&t.X_(s.z_)&&ga(e)}async function ma(r,t){const e=k(r),n=t.query;let i=3;const s=e.queries.get(n);if(s){const a=s.j_.indexOf(t);a>=0&&(s.j_.splice(a,1),s.j_.length===0?i=t.J_()?0:1:!s.H_()&&t.J_()&&(i=2))}switch(i){case 0:return e.queries.delete(n),e.onUnlisten(n,!0);case 1:return e.queries.delete(n),e.onUnlisten(n,!1);case 2:return e.onLastRemoteStoreUnlisten(n);default:return}}function B_(r,t){const e=k(r);let n=!1;for(const i of t){const s=i.query,a=e.queries.get(s);if(a){for(const u of a.j_)u.X_(i)&&(n=!0);a.z_=i}}n&&ga(e)}function U_(r,t,e){const n=k(r),i=n.queries.get(t);if(i)for(const s of i.j_)s.onError(e);n.queries.delete(t)}function ga(r){r.Y_.forEach(t=>{t.next()})}var xo,Gc;(Gc=xo||(xo={})).ea="default",Gc.Cache="cache";class pa{constructor(t,e,n){this.query=t,this.ta=e,this.na=!1,this.ra=null,this.onlineState="Unknown",this.options=n||{}}X_(t){if(!this.options.includeMetadataChanges){const n=[];for(const i of t.docChanges)i.type!==3&&n.push(i);t=new Un(t.query,t.docs,t.oldDocs,n,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0,t.hasCachedResults)}let e=!1;return this.na?this.ia(t)&&(this.ta.next(t),e=!0):this.sa(t,this.onlineState)&&(this.oa(t),e=!0),this.ra=t,e}onError(t){this.ta.error(t)}Z_(t){this.onlineState=t;let e=!1;return this.ra&&!this.na&&this.sa(this.ra,t)&&(this.oa(this.ra),e=!0),e}sa(t,e){if(!t.fromCache||!this.J_())return!0;const n=e!=="Offline";return(!this.options._a||!n)&&(!t.docs.isEmpty()||t.hasCachedResults||e==="Offline")}ia(t){if(t.docChanges.length>0)return!0;const e=this.ra&&this.ra.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!e)&&this.options.includeMetadataChanges===!0}oa(t){t=Un.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache,t.hasCachedResults),this.na=!0,this.ta.next(t)}J_(){return this.options.source!==xo.Cache}}/**
2030
+ */class O_{constructor(){this.z_=void 0,this.j_=[]}H_(){return this.j_.some(t=>t.J_())}}class L_{constructor(){this.queries=jc(),this.onlineState="Unknown",this.Y_=new Set}terminate(){(function(e,n){const i=k(e),s=i.queries;i.queries=jc(),s.forEach((a,u)=>{for(const c of u.j_)c.onError(n)})})(this,new D(P.ABORTED,"Firestore shutting down"))}}function jc(){return new se(r=>lh(r),Jr)}async function fa(r,t){const e=k(r);let n=3;const i=t.query;let s=e.queries.get(i);s?!s.H_()&&t.J_()&&(n=2):(s=new O_,n=t.J_()?0:1);try{switch(n){case 0:s.z_=await e.onListen(i,!0);break;case 1:s.z_=await e.onListen(i,!1);break;case 2:await e.onFirstRemoteStoreListen(i)}}catch(a){const u=Xn(a,`Initialization of query '${vn(t.query)}' failed`);return void t.onError(u)}e.queries.set(i,s),s.j_.push(t),t.Z_(e.onlineState),s.z_&&t.X_(s.z_)&&ga(e)}async function ma(r,t){const e=k(r),n=t.query;let i=3;const s=e.queries.get(n);if(s){const a=s.j_.indexOf(t);a>=0&&(s.j_.splice(a,1),s.j_.length===0?i=t.J_()?0:1:!s.H_()&&t.J_()&&(i=2))}switch(i){case 0:return e.queries.delete(n),e.onUnlisten(n,!0);case 1:return e.queries.delete(n),e.onUnlisten(n,!1);case 2:return e.onLastRemoteStoreUnlisten(n);default:return}}function B_(r,t){const e=k(r);let n=!1;for(const i of t){const s=i.query,a=e.queries.get(s);if(a){for(const u of a.j_)u.X_(i)&&(n=!0);a.z_=i}}n&&ga(e)}function U_(r,t,e){const n=k(r),i=n.queries.get(t);if(i)for(const s of i.j_)s.onError(e);n.queries.delete(t)}function ga(r){r.Y_.forEach(t=>{t.next()})}var xo,Gc;(Gc=xo||(xo={})).ea="default",Gc.Cache="cache";class pa{constructor(t,e,n){this.query=t,this.ta=e,this.na=!1,this.ra=null,this.onlineState="Unknown",this.options=n||{}}X_(t){if(!this.options.includeMetadataChanges){const n=[];for(const i of t.docChanges)i.type!==3&&n.push(i);t=new qn(t.query,t.docs,t.oldDocs,n,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0,t.hasCachedResults)}let e=!1;return this.na?this.ia(t)&&(this.ta.next(t),e=!0):this.sa(t,this.onlineState)&&(this.oa(t),e=!0),this.ra=t,e}onError(t){this.ta.error(t)}Z_(t){this.onlineState=t;let e=!1;return this.ra&&!this.na&&this.sa(this.ra,t)&&(this.oa(this.ra),e=!0),e}sa(t,e){if(!t.fromCache||!this.J_())return!0;const n=e!=="Offline";return(!this.options._a||!n)&&(!t.docs.isEmpty()||t.hasCachedResults||e==="Offline")}ia(t){if(t.docChanges.length>0)return!0;const e=this.ra&&this.ra.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!e)&&this.options.includeMetadataChanges===!0}oa(t){t=qn.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache,t.hasCachedResults),this.na=!0,this.ta.next(t)}J_(){return this.options.source!==xo.Cache}}/**
2031
2031
  * @license
2032
2032
  * Copyright 2020 Google LLC
2033
2033
  *
@@ -2072,7 +2072,7 @@ This typically indicates that your device does not have a healthy Internet conne
2072
2072
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2073
2073
  * See the License for the specific language governing permissions and
2074
2074
  * limitations under the License.
2075
- */class _d{constructor(t){this.key=t}}class yd{constructor(t){this.key=t}}class Id{constructor(t,e){this.query=t,this.Ta=e,this.Ea=null,this.hasCachedResults=!1,this.current=!1,this.da=G(),this.mutatedKeys=G(),this.Aa=dh(t),this.Ra=new Rn(this.Aa)}get Va(){return this.Ta}ma(t,e){const n=e?e.fa:new zc,i=e?e.Ra:this.Ra;let s=e?e.mutatedKeys:this.mutatedKeys,a=i,u=!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(t.inorderTraversal((f,g)=>{const _=i.get(f),R=Yr(this.query,g)?g:null,C=!!_&&this.mutatedKeys.has(_.key),N=!!R&&(R.hasLocalMutations||this.mutatedKeys.has(R.key)&&R.hasCommittedMutations);let V=!1;_&&R?_.data.isEqual(R.data)?C!==N&&(n.track({type:3,doc:R}),V=!0):this.ga(_,R)||(n.track({type:2,doc:R}),V=!0,(c&&this.Aa(R,c)>0||h&&this.Aa(R,h)<0)&&(u=!0)):!_&&R?(n.track({type:0,doc:R}),V=!0):_&&!R&&(n.track({type:1,doc:_}),V=!0,(c||h)&&(u=!0)),V&&(R?(a=a.add(R),s=N?s.add(f):s.delete(f)):(a=a.delete(f),s=s.delete(f)))}),this.query.limit!==null)for(;a.size>this.query.limit;){const f=this.query.limitType==="F"?a.last():a.first();a=a.delete(f.key),s=s.delete(f.key),n.track({type:1,doc:f})}return{Ra:a,fa:n,ns:u,mutatedKeys:s}}ga(t,e){return t.hasLocalMutations&&e.hasCommittedMutations&&!e.hasLocalMutations}applyChanges(t,e,n,i){const s=this.Ra;this.Ra=t.Ra,this.mutatedKeys=t.mutatedKeys;const a=t.fa.G_();a.sort((f,g)=>function(R,C){const N=V=>{switch(V){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return O()}};return N(R)-N(C)}(f.type,g.type)||this.Aa(f.doc,g.doc)),this.pa(n),i=i!=null&&i;const u=e&&!i?this.ya():[],c=this.da.size===0&&this.current&&!i?1:0,h=c!==this.Ea;return this.Ea=c,a.length!==0||h?{snapshot:new Un(this.query,t.Ra,s,a,t.mutatedKeys,c===0,h,!1,!!n&&n.resumeToken.approximateByteSize()>0),wa:u}:{wa:u}}Z_(t){return this.current&&t==="Offline"?(this.current=!1,this.applyChanges({Ra:this.Ra,fa:new zc,mutatedKeys:this.mutatedKeys,ns:!1},!1)):{wa:[]}}Sa(t){return!this.Ta.has(t)&&!!this.Ra.has(t)&&!this.Ra.get(t).hasLocalMutations}pa(t){t&&(t.addedDocuments.forEach(e=>this.Ta=this.Ta.add(e)),t.modifiedDocuments.forEach(e=>{}),t.removedDocuments.forEach(e=>this.Ta=this.Ta.delete(e)),this.current=t.current)}ya(){if(!this.current)return[];const t=this.da;this.da=G(),this.Ra.forEach(n=>{this.Sa(n.key)&&(this.da=this.da.add(n.key))});const e=[];return t.forEach(n=>{this.da.has(n)||e.push(new yd(n))}),this.da.forEach(n=>{t.has(n)||e.push(new _d(n))}),e}ba(t){this.Ta=t.Ts,this.da=G();const e=this.ma(t.documents);return this.applyChanges(e,!0)}Da(){return Un.fromInitialDocuments(this.query,this.Ra,this.mutatedKeys,this.Ea===0,this.hasCachedResults)}}class j_{constructor(t,e,n){this.query=t,this.targetId=e,this.view=n}}class G_{constructor(t){this.key=t,this.va=!1}}class K_{constructor(t,e,n,i,s,a){this.localStore=t,this.remoteStore=e,this.eventManager=n,this.sharedClientState=i,this.currentUser=s,this.maxConcurrentLimboResolutions=a,this.Ca={},this.Fa=new se(u=>lh(u),Jr),this.Ma=new Map,this.xa=new Set,this.Oa=new it(M.comparator),this.Na=new Map,this.La=new na,this.Ba={},this.ka=new Map,this.qa=sn.kn(),this.onlineState="Unknown",this.Qa=void 0}get isPrimaryClient(){return this.Qa===!0}}async function $_(r,t,e=!0){const n=ys(r);let i;const s=n.Fa.get(t);return s?(n.sharedClientState.addLocalQueryTarget(s.targetId),i=s.view.Da()):i=await Ed(n,t,e,!0),i}async function Q_(r,t){const e=ys(r);await Ed(e,t,!0,!1)}async function Ed(r,t,e,n){const i=await On(r.localStore,kt(t)),s=i.targetId,a=r.sharedClientState.addLocalQueryTarget(s,e);let u;return n&&(u=await _a(r,t,s,a==="current",i.resumeToken)),r.isPrimaryClient&&e&&_s(r.remoteStore,i),u}async function _a(r,t,e,n,i){r.Ka=(g,_,R)=>async function(N,V,q,z){let B=V.view.ma(q);B.ns&&(B=await es(N.localStore,V.query,!1).then(({documents:E})=>V.view.ma(E,B)));const $=z&&z.targetChanges.get(V.targetId),Z=z&&z.targetMismatches.get(V.targetId)!=null,K=V.view.applyChanges(B,N.isPrimaryClient,$,Z);return No(N,V.targetId,K.wa),K.snapshot}(r,g,_,R);const s=await es(r.localStore,t,!0),a=new Id(t,s.Ts),u=a.ma(s.documents),c=ti.createSynthesizedTargetChangeForCurrentChange(e,n&&r.onlineState!=="Offline",i),h=a.applyChanges(u,r.isPrimaryClient,c);No(r,e,h.wa);const f=new j_(t,e,a);return r.Fa.set(t,f),r.Ma.has(e)?r.Ma.get(e).push(t):r.Ma.set(e,[t]),h.snapshot}async function W_(r,t,e){const n=k(r),i=n.Fa.get(t),s=n.Ma.get(i.targetId);if(s.length>1)return n.Ma.set(i.targetId,s.filter(a=>!Jr(a,t))),void n.Fa.delete(t);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(i.targetId),n.sharedClientState.isActiveQueryTarget(i.targetId)||await Ln(n.localStore,i.targetId,!1).then(()=>{n.sharedClientState.clearQueryState(i.targetId),e&&Bn(n.remoteStore,i.targetId),qn(n,i.targetId)}).catch(Ce)):(qn(n,i.targetId),await Ln(n.localStore,i.targetId,!0))}async function H_(r,t){const e=k(r),n=e.Fa.get(t),i=e.Ma.get(n.targetId);e.isPrimaryClient&&i.length===1&&(e.sharedClientState.removeLocalQueryTarget(n.targetId),Bn(e.remoteStore,n.targetId))}async function J_(r,t,e){const n=Ta(r);try{const i=await function(a,u){const c=k(a),h=lt.now(),f=u.reduce((R,C)=>R.add(C.key),G());let g,_;return c.persistence.runTransaction("Locally write mutations","readwrite",R=>{let C=Bt(),N=G();return c.cs.getEntries(R,f).next(V=>{C=V,C.forEach((q,z)=>{z.isValidDocument()||(N=N.add(q))})}).next(()=>c.localDocuments.getOverlayedDocuments(R,C)).next(V=>{g=V;const q=[];for(const z of u){const B=vp(z,g.get(z.key).overlayedDocument);B!=null&&q.push(new oe(z.key,B,Zl(B.value.mapValue),ct.exists(!0)))}return c.mutationQueue.addMutationBatch(R,h,q,u)}).next(V=>{_=V;const q=V.applyToLocalDocumentSet(g,N);return c.documentOverlayCache.saveOverlays(R,V.batchId,q)})}).then(()=>({batchId:_.batchId,changes:mh(g)}))}(n.localStore,t);n.sharedClientState.addPendingMutation(i.batchId),function(a,u,c){let h=a.Ba[a.currentUser.toKey()];h||(h=new it(j)),h=h.insert(u,c),a.Ba[a.currentUser.toKey()]=h}(n,i.batchId,e),await ae(n,i.changes),await Hn(n.remoteStore)}catch(i){const s=Yn(i,"Failed to persist write");e.reject(s)}}async function Td(r,t){const e=k(r);try{const n=await m_(e.localStore,t);t.targetChanges.forEach((i,s)=>{const a=e.Na.get(s);a&&(L(i.addedDocuments.size+i.modifiedDocuments.size+i.removedDocuments.size<=1),i.addedDocuments.size>0?a.va=!0:i.modifiedDocuments.size>0?L(a.va):i.removedDocuments.size>0&&(L(a.va),a.va=!1))}),await ae(e,n,t)}catch(n){await Ce(n)}}function $c(r,t,e){const n=k(r);if(n.isPrimaryClient&&e===0||!n.isPrimaryClient&&e===1){const i=[];n.Fa.forEach((s,a)=>{const u=a.view.Z_(t);u.snapshot&&i.push(u.snapshot)}),function(a,u){const c=k(a);c.onlineState=u;let h=!1;c.queries.forEach((f,g)=>{for(const _ of g.j_)_.Z_(u)&&(h=!0)}),h&&ga(c)}(n.eventManager,t),i.length&&n.Ca.d_(i),n.onlineState=t,n.isPrimaryClient&&n.sharedClientState.setOnlineState(t)}}async function Y_(r,t,e){const n=k(r);n.sharedClientState.updateQueryState(t,"rejected",e);const i=n.Na.get(t),s=i&&i.key;if(s){let a=new it(M.comparator);a=a.insert(s,ot.newNoDocument(s,U.min()));const u=G().add(s),c=new Zr(U.min(),new Map,new it(j),a,u);await Td(n,c),n.Oa=n.Oa.remove(s),n.Na.delete(t),Ea(n)}else await Ln(n.localStore,t,!1).then(()=>qn(n,t,e)).catch(Ce)}async function X_(r,t){const e=k(r),n=t.batch.batchId;try{const i=await f_(e.localStore,t);Ia(e,n,null),ya(e,n),e.sharedClientState.updateMutationState(n,"acknowledged"),await ae(e,i)}catch(i){await Ce(i)}}async function Z_(r,t,e){const n=k(r);try{const i=await function(a,u){const c=k(a);return c.persistence.runTransaction("Reject batch","readwrite-primary",h=>{let f;return c.mutationQueue.lookupMutationBatch(h,u).next(g=>(L(g!==null),f=g.keys(),c.mutationQueue.removeMutationBatch(h,g))).next(()=>c.mutationQueue.performConsistencyCheck(h)).next(()=>c.documentOverlayCache.removeOverlaysForBatchId(h,f,u)).next(()=>c.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(h,f)).next(()=>c.localDocuments.getDocuments(h,f))})}(n.localStore,t);Ia(n,t,e),ya(n,t),n.sharedClientState.updateMutationState(t,"rejected",e),await ae(n,i)}catch(i){await Ce(i)}}async function ty(r,t){const e=k(r);Ne(e.remoteStore)||x("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.");try{const n=await function(a){const u=k(a);return u.persistence.runTransaction("Get highest unacknowledged batch id","readonly",c=>u.mutationQueue.getHighestUnacknowledgedBatchId(c))}(e.localStore);if(n===-1)return void t.resolve();const i=e.ka.get(n)||[];i.push(t),e.ka.set(n,i)}catch(n){const i=Yn(n,"Initialization of waitForPendingWrites() operation failed");t.reject(i)}}function ya(r,t){(r.ka.get(t)||[]).forEach(e=>{e.resolve()}),r.ka.delete(t)}function Ia(r,t,e){const n=k(r);let i=n.Ba[n.currentUser.toKey()];if(i){const s=i.get(t);s&&(e?s.reject(e):s.resolve(),i=i.remove(t)),n.Ba[n.currentUser.toKey()]=i}}function qn(r,t,e=null){r.sharedClientState.removeLocalQueryTarget(t);for(const n of r.Ma.get(t))r.Fa.delete(n),e&&r.Ca.$a(n,e);r.Ma.delete(t),r.isPrimaryClient&&r.La.gr(t).forEach(n=>{r.La.containsKey(n)||vd(r,n)})}function vd(r,t){r.xa.delete(t.path.canonicalString());const e=r.Oa.get(t);e!==null&&(Bn(r.remoteStore,e),r.Oa=r.Oa.remove(t),r.Na.delete(e),Ea(r))}function No(r,t,e){for(const n of e)n instanceof _d?(r.La.addReference(n.key,t),ey(r,n)):n instanceof yd?(x("SyncEngine","Document no longer in limbo: "+n.key),r.La.removeReference(n.key,t),r.La.containsKey(n.key)||vd(r,n.key)):O()}function ey(r,t){const e=t.key,n=e.path.canonicalString();r.Oa.get(e)||r.xa.has(n)||(x("SyncEngine","New document in limbo: "+e),r.xa.add(n),Ea(r))}function Ea(r){for(;r.xa.size>0&&r.Oa.size<r.maxConcurrentLimboResolutions;){const t=r.xa.values().next().value;r.xa.delete(t);const e=new M(W.fromString(t)),n=r.qa.next();r.Na.set(n,new G_(e)),r.Oa=r.Oa.insert(e,n),_s(r.remoteStore,new te(kt(Kn(e.path)),n,"TargetPurposeLimboResolution",Ot.oe))}}async function ae(r,t,e){const n=k(r),i=[],s=[],a=[];n.Fa.isEmpty()||(n.Fa.forEach((u,c)=>{a.push(n.Ka(c,t,e).then(h=>{var f;if((h||e)&&n.isPrimaryClient){const g=h?!h.fromCache:(f=e==null?void 0:e.targetChanges.get(c.targetId))===null||f===void 0?void 0:f.current;n.sharedClientState.updateQueryState(c.targetId,g?"current":"not-current")}if(h){i.push(h);const g=oa.Wi(c.targetId,h);s.push(g)}}))}),await Promise.all(a),n.Ca.d_(i),await async function(c,h){const f=k(c);try{await f.persistence.runTransaction("notifyLocalViewChanges","readwrite",g=>w.forEach(h,_=>w.forEach(_.$i,R=>f.persistence.referenceDelegate.addReference(g,_.targetId,R)).next(()=>w.forEach(_.Ui,R=>f.persistence.referenceDelegate.removeReference(g,_.targetId,R)))))}catch(g){if(!De(g))throw g;x("LocalStore","Failed to update sequence numbers: "+g)}for(const g of h){const _=g.targetId;if(!g.fromCache){const R=f.os.get(_),C=R.snapshotVersion,N=R.withLastLimboFreeSnapshotVersion(C);f.os=f.os.insert(_,N)}}}(n.localStore,s))}async function ny(r,t){const e=k(r);if(!e.currentUser.isEqual(t)){x("SyncEngine","User change. New user:",t.toKey());const n=await nd(e.localStore,t);e.currentUser=t,function(s,a){s.ka.forEach(u=>{u.forEach(c=>{c.reject(new D(P.CANCELLED,a))})}),s.ka.clear()}(e,"'waitForPendingWrites' promise is rejected due to a user change."),e.sharedClientState.handleUserChange(t,n.removedBatchIds,n.addedBatchIds),await ae(e,n.hs)}}function ry(r,t){const e=k(r),n=e.Na.get(t);if(n&&n.va)return G().add(n.key);{let i=G();const s=e.Ma.get(t);if(!s)return i;for(const a of s){const u=e.Fa.get(a);i=i.unionWith(u.view.Va)}return i}}async function iy(r,t){const e=k(r),n=await es(e.localStore,t.query,!0),i=t.view.ba(n);return e.isPrimaryClient&&No(e,t.targetId,i.wa),i}async function sy(r,t){const e=k(r);return od(e.localStore,t).then(n=>ae(e,n))}async function oy(r,t,e,n){const i=k(r),s=await function(u,c){const h=k(u),f=k(h.mutationQueue);return h.persistence.runTransaction("Lookup mutation documents","readonly",g=>f.Mn(g,c).next(_=>_?h.localDocuments.getDocuments(g,_):w.resolve(null)))}(i.localStore,t);s!==null?(e==="pending"?await Hn(i.remoteStore):e==="acknowledged"||e==="rejected"?(Ia(i,t,n||null),ya(i,t),function(u,c){k(k(u).mutationQueue).On(c)}(i.localStore,t)):O(),await ae(i,s)):x("SyncEngine","Cannot apply mutation batch with id: "+t)}async function ay(r,t){const e=k(r);if(ys(e),Ta(e),t===!0&&e.Qa!==!0){const n=e.sharedClientState.getAllActiveQueryTargets(),i=await Qc(e,n.toArray());e.Qa=!0,await Do(e.remoteStore,!0);for(const s of i)_s(e.remoteStore,s)}else if(t===!1&&e.Qa!==!1){const n=[];let i=Promise.resolve();e.Ma.forEach((s,a)=>{e.sharedClientState.isLocalQueryTarget(a)?n.push(a):i=i.then(()=>(qn(e,a),Ln(e.localStore,a,!0))),Bn(e.remoteStore,a)}),await i,await Qc(e,n),function(a){const u=k(a);u.Na.forEach((c,h)=>{Bn(u.remoteStore,h)}),u.La.pr(),u.Na=new Map,u.Oa=new it(M.comparator)}(e),e.Qa=!1,await Do(e.remoteStore,!1)}}async function Qc(r,t,e){const n=k(r),i=[],s=[];for(const a of t){let u;const c=n.Ma.get(a);if(c&&c.length!==0){u=await On(n.localStore,kt(c[0]));for(const h of c){const f=n.Fa.get(h),g=await iy(n,f);g.snapshot&&s.push(g.snapshot)}}else{const h=await sd(n.localStore,a);u=await On(n.localStore,h),await _a(n,wd(h),a,!1,u.resumeToken)}i.push(u)}return n.Ca.d_(s),i}function wd(r){return ah(r.path,r.collectionGroup,r.orderBy,r.filters,r.limit,"F",r.startAt,r.endAt)}function uy(r){return function(e){return k(k(e).persistence).Qi()}(k(r).localStore)}async function cy(r,t,e,n){const i=k(r);if(i.Qa)return void x("SyncEngine","Ignoring unexpected query state notification.");const s=i.Ma.get(t);if(s&&s.length>0)switch(e){case"current":case"not-current":{const a=await od(i.localStore,hh(s[0])),u=Zr.createSynthesizedRemoteEventForCurrentChange(t,e==="current",dt.EMPTY_BYTE_STRING);await ae(i,a,u);break}case"rejected":await Ln(i.localStore,t,!0),qn(i,t,n);break;default:O()}}async function ly(r,t,e){const n=ys(r);if(n.Qa){for(const i of t){if(n.Ma.has(i)&&n.sharedClientState.isActiveQueryTarget(i)){x("SyncEngine","Adding an already active target "+i);continue}const s=await sd(n.localStore,i),a=await On(n.localStore,s);await _a(n,wd(s),a.targetId,!1,a.resumeToken),_s(n.remoteStore,a)}for(const i of e)n.Ma.has(i)&&await Ln(n.localStore,i,!1).then(()=>{Bn(n.remoteStore,i),qn(n,i)}).catch(Ce)}}function ys(r){const t=k(r);return t.remoteStore.remoteSyncer.applyRemoteEvent=Td.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=ry.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=Y_.bind(null,t),t.Ca.d_=B_.bind(null,t.eventManager),t.Ca.$a=U_.bind(null,t.eventManager),t}function Ta(r){const t=k(r);return t.remoteStore.remoteSyncer.applySuccessfulWrite=X_.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=Z_.bind(null,t),t}function hy(r,t,e){const n=k(r);(async function(s,a,u){try{const c=await a.getMetadata();if(await function(R,C){const N=k(R),V=pt(C.createTime);return N.persistence.runTransaction("hasNewerBundle","readonly",q=>N.Gr.getBundleMetadata(q,C.id)).then(q=>!!q&&q.createTime.compareTo(V)>=0)}(s.localStore,c))return await a.close(),u._completeWith(function(R){return{taskState:"Success",documentsLoaded:R.totalDocuments,bytesLoaded:R.totalBytes,totalDocuments:R.totalDocuments,totalBytes:R.totalBytes}}(c)),Promise.resolve(new Set);u._updateProgress(pd(c));const h=new z_(c,s.localStore,a.serializer);let f=await a.Ua();for(;f;){const _=await h.la(f);_&&u._updateProgress(_),f=await a.Ua()}const g=await h.complete();return await ae(s,g.Ia,void 0),await function(R,C){const N=k(R);return N.persistence.runTransaction("Save bundle","readwrite",V=>N.Gr.saveBundleMetadata(V,C))}(s.localStore,c),u._completeWith(g.progress),Promise.resolve(g.Pa)}catch(c){return qt("SyncEngine",`Loading bundle failed with ${c}`),u._failWith(c),Promise.resolve(new Set)}})(n,t,e).then(i=>{n.sharedClientState.notifyBundleLoaded(i)})}class Pe{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(t){this.serializer=ei(t.databaseInfo.databaseId),this.sharedClientState=this.Wa(t),this.persistence=this.Ga(t),await this.persistence.start(),this.localStore=this.za(t),this.gcScheduler=this.ja(t,this.localStore),this.indexBackfillerScheduler=this.Ha(t,this.localStore)}ja(t,e){return null}Ha(t,e){return null}za(t){return ed(this.persistence,new td,t.initialUser,this.serializer)}Ga(t){return new ra(ps.Zr,this.serializer)}Wa(t){return new ud}async terminate(){var t,e;(t=this.gcScheduler)===null||t===void 0||t.stop(),(e=this.indexBackfillerScheduler)===null||e===void 0||e.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}Pe.provider={build:()=>new Pe};class dy extends Pe{constructor(t){super(),this.cacheSizeBytes=t}ja(t,e){L(this.persistence.referenceDelegate instanceof ts);const n=this.persistence.referenceDelegate.garbageCollector;return new Hh(n,t.asyncQueue,e)}Ga(t){const e=this.cacheSizeBytes!==void 0?xt.withCacheSize(this.cacheSizeBytes):xt.DEFAULT;return new ra(n=>ts.Zr(n,e),this.serializer)}}class va extends Pe{constructor(t,e,n){super(),this.Ja=t,this.cacheSizeBytes=e,this.forceOwnership=n,this.kind="persistent",this.synchronizeTabs=!1}async initialize(t){await super.initialize(t),await this.Ja.initialize(this,t),await Ta(this.Ja.syncEngine),await Hn(this.Ja.remoteStore),await this.persistence.yi(()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(),this.indexBackfillerScheduler&&!this.indexBackfillerScheduler.started&&this.indexBackfillerScheduler.start(),Promise.resolve()))}za(t){return ed(this.persistence,new td,t.initialUser,this.serializer)}ja(t,e){const n=this.persistence.referenceDelegate.garbageCollector;return new Hh(n,t.asyncQueue,e)}Ha(t,e){const n=new Ng(e,this.persistence);return new xg(t.asyncQueue,n)}Ga(t){const e=sa(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey),n=this.cacheSizeBytes!==void 0?xt.withCacheSize(this.cacheSizeBytes):xt.DEFAULT;return new ia(this.synchronizeTabs,e,t.clientId,n,t.asyncQueue,cd(),ji(),this.serializer,this.sharedClientState,!!this.forceOwnership)}Wa(t){return new ud}}class Ad extends va{constructor(t,e){super(t,e,!1),this.Ja=t,this.cacheSizeBytes=e,this.synchronizeTabs=!0}async initialize(t){await super.initialize(t);const e=this.Ja.syncEngine;this.sharedClientState instanceof oo&&(this.sharedClientState.syncEngine={no:oy.bind(null,e),ro:cy.bind(null,e),io:ly.bind(null,e),Qi:uy.bind(null,e),eo:sy.bind(null,e)},await this.sharedClientState.start()),await this.persistence.yi(async n=>{await ay(this.Ja.syncEngine,n),this.gcScheduler&&(n&&!this.gcScheduler.started?this.gcScheduler.start():n||this.gcScheduler.stop()),this.indexBackfillerScheduler&&(n&&!this.indexBackfillerScheduler.started?this.indexBackfillerScheduler.start():n||this.indexBackfillerScheduler.stop())})}Wa(t){const e=cd();if(!oo.D(e))throw new D(P.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");const n=sa(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey);return new oo(e,t.asyncQueue,n,t.clientId,t.initialUser)}}class Se{async initialize(t,e){this.localStore||(this.localStore=t.localStore,this.sharedClientState=t.sharedClientState,this.datastore=this.createDatastore(e),this.remoteStore=this.createRemoteStore(e),this.eventManager=this.createEventManager(e),this.syncEngine=this.createSyncEngine(e,!t.synchronizeTabs),this.sharedClientState.onlineStateHandler=n=>$c(this.syncEngine,n,1),this.remoteStore.remoteSyncer.handleCredentialChange=ny.bind(null,this.syncEngine),await Do(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(t){return function(){return new L_}()}createDatastore(t){const e=ei(t.databaseInfo.databaseId),n=function(s){return new T_(s)}(t.databaseInfo);return function(s,a,u,c){return new A_(s,a,u,c)}(t.authCredentials,t.appCheckCredentials,n,e)}createRemoteStore(t){return function(n,i,s,a,u){return new b_(n,i,s,a,u)}(this.localStore,this.datastore,t.asyncQueue,e=>$c(this.syncEngine,e,0),function(){return Uc.D()?new Uc:new y_}())}createSyncEngine(t,e){return function(i,s,a,u,c,h,f){const g=new K_(i,s,a,u,c,h);return f&&(g.Qa=!0),g}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,t.initialUser,t.maxConcurrentLimboResolutions,e)}async terminate(){var t,e;await async function(i){const s=k(i);x("RemoteStore","RemoteStore shutting down."),s.L_.add(5),await Wn(s),s.k_.shutdown(),s.q_.set("Unknown")}(this.remoteStore),(t=this.datastore)===null||t===void 0||t.terminate(),(e=this.eventManager)===null||e===void 0||e.terminate()}}Se.provider={build:()=>new Se};function Wc(r,t=10240){let e=0;return{async read(){if(e<r.byteLength){const n={value:r.slice(e,e+t),done:!1};return e+=t,n}return{done:!0}},async cancel(){},releaseLock(){},closed:Promise.resolve()}}/**
2075
+ */class _d{constructor(t){this.key=t}}class yd{constructor(t){this.key=t}}class Id{constructor(t,e){this.query=t,this.Ta=e,this.Ea=null,this.hasCachedResults=!1,this.current=!1,this.da=G(),this.mutatedKeys=G(),this.Aa=dh(t),this.Ra=new bn(this.Aa)}get Va(){return this.Ta}ma(t,e){const n=e?e.fa:new zc,i=e?e.Ra:this.Ra;let s=e?e.mutatedKeys:this.mutatedKeys,a=i,u=!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(t.inorderTraversal((f,g)=>{const _=i.get(f),R=Yr(this.query,g)?g:null,C=!!_&&this.mutatedKeys.has(_.key),N=!!R&&(R.hasLocalMutations||this.mutatedKeys.has(R.key)&&R.hasCommittedMutations);let V=!1;_&&R?_.data.isEqual(R.data)?C!==N&&(n.track({type:3,doc:R}),V=!0):this.ga(_,R)||(n.track({type:2,doc:R}),V=!0,(c&&this.Aa(R,c)>0||h&&this.Aa(R,h)<0)&&(u=!0)):!_&&R?(n.track({type:0,doc:R}),V=!0):_&&!R&&(n.track({type:1,doc:_}),V=!0,(c||h)&&(u=!0)),V&&(R?(a=a.add(R),s=N?s.add(f):s.delete(f)):(a=a.delete(f),s=s.delete(f)))}),this.query.limit!==null)for(;a.size>this.query.limit;){const f=this.query.limitType==="F"?a.last():a.first();a=a.delete(f.key),s=s.delete(f.key),n.track({type:1,doc:f})}return{Ra:a,fa:n,ns:u,mutatedKeys:s}}ga(t,e){return t.hasLocalMutations&&e.hasCommittedMutations&&!e.hasLocalMutations}applyChanges(t,e,n,i){const s=this.Ra;this.Ra=t.Ra,this.mutatedKeys=t.mutatedKeys;const a=t.fa.G_();a.sort((f,g)=>function(R,C){const N=V=>{switch(V){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return O()}};return N(R)-N(C)}(f.type,g.type)||this.Aa(f.doc,g.doc)),this.pa(n),i=i!=null&&i;const u=e&&!i?this.ya():[],c=this.da.size===0&&this.current&&!i?1:0,h=c!==this.Ea;return this.Ea=c,a.length!==0||h?{snapshot:new qn(this.query,t.Ra,s,a,t.mutatedKeys,c===0,h,!1,!!n&&n.resumeToken.approximateByteSize()>0),wa:u}:{wa:u}}Z_(t){return this.current&&t==="Offline"?(this.current=!1,this.applyChanges({Ra:this.Ra,fa:new zc,mutatedKeys:this.mutatedKeys,ns:!1},!1)):{wa:[]}}Sa(t){return!this.Ta.has(t)&&!!this.Ra.has(t)&&!this.Ra.get(t).hasLocalMutations}pa(t){t&&(t.addedDocuments.forEach(e=>this.Ta=this.Ta.add(e)),t.modifiedDocuments.forEach(e=>{}),t.removedDocuments.forEach(e=>this.Ta=this.Ta.delete(e)),this.current=t.current)}ya(){if(!this.current)return[];const t=this.da;this.da=G(),this.Ra.forEach(n=>{this.Sa(n.key)&&(this.da=this.da.add(n.key))});const e=[];return t.forEach(n=>{this.da.has(n)||e.push(new yd(n))}),this.da.forEach(n=>{t.has(n)||e.push(new _d(n))}),e}ba(t){this.Ta=t.Ts,this.da=G();const e=this.ma(t.documents);return this.applyChanges(e,!0)}Da(){return qn.fromInitialDocuments(this.query,this.Ra,this.mutatedKeys,this.Ea===0,this.hasCachedResults)}}class j_{constructor(t,e,n){this.query=t,this.targetId=e,this.view=n}}class G_{constructor(t){this.key=t,this.va=!1}}class K_{constructor(t,e,n,i,s,a){this.localStore=t,this.remoteStore=e,this.eventManager=n,this.sharedClientState=i,this.currentUser=s,this.maxConcurrentLimboResolutions=a,this.Ca={},this.Fa=new se(u=>lh(u),Jr),this.Ma=new Map,this.xa=new Set,this.Oa=new it(M.comparator),this.Na=new Map,this.La=new na,this.Ba={},this.ka=new Map,this.qa=on.kn(),this.onlineState="Unknown",this.Qa=void 0}get isPrimaryClient(){return this.Qa===!0}}async function $_(r,t,e=!0){const n=ys(r);let i;const s=n.Fa.get(t);return s?(n.sharedClientState.addLocalQueryTarget(s.targetId),i=s.view.Da()):i=await Ed(n,t,e,!0),i}async function Q_(r,t){const e=ys(r);await Ed(e,t,!0,!1)}async function Ed(r,t,e,n){const i=await Ln(r.localStore,kt(t)),s=i.targetId,a=r.sharedClientState.addLocalQueryTarget(s,e);let u;return n&&(u=await _a(r,t,s,a==="current",i.resumeToken)),r.isPrimaryClient&&e&&_s(r.remoteStore,i),u}async function _a(r,t,e,n,i){r.Ka=(g,_,R)=>async function(N,V,q,z){let B=V.view.ma(q);B.ns&&(B=await es(N.localStore,V.query,!1).then(({documents:E})=>V.view.ma(E,B)));const $=z&&z.targetChanges.get(V.targetId),Z=z&&z.targetMismatches.get(V.targetId)!=null,K=V.view.applyChanges(B,N.isPrimaryClient,$,Z);return No(N,V.targetId,K.wa),K.snapshot}(r,g,_,R);const s=await es(r.localStore,t,!0),a=new Id(t,s.Ts),u=a.ma(s.documents),c=ti.createSynthesizedTargetChangeForCurrentChange(e,n&&r.onlineState!=="Offline",i),h=a.applyChanges(u,r.isPrimaryClient,c);No(r,e,h.wa);const f=new j_(t,e,a);return r.Fa.set(t,f),r.Ma.has(e)?r.Ma.get(e).push(t):r.Ma.set(e,[t]),h.snapshot}async function W_(r,t,e){const n=k(r),i=n.Fa.get(t),s=n.Ma.get(i.targetId);if(s.length>1)return n.Ma.set(i.targetId,s.filter(a=>!Jr(a,t))),void n.Fa.delete(t);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(i.targetId),n.sharedClientState.isActiveQueryTarget(i.targetId)||await Bn(n.localStore,i.targetId,!1).then(()=>{n.sharedClientState.clearQueryState(i.targetId),e&&Un(n.remoteStore,i.targetId),zn(n,i.targetId)}).catch(De)):(zn(n,i.targetId),await Bn(n.localStore,i.targetId,!0))}async function H_(r,t){const e=k(r),n=e.Fa.get(t),i=e.Ma.get(n.targetId);e.isPrimaryClient&&i.length===1&&(e.sharedClientState.removeLocalQueryTarget(n.targetId),Un(e.remoteStore,n.targetId))}async function J_(r,t,e){const n=Ta(r);try{const i=await function(a,u){const c=k(a),h=lt.now(),f=u.reduce((R,C)=>R.add(C.key),G());let g,_;return c.persistence.runTransaction("Locally write mutations","readwrite",R=>{let C=Bt(),N=G();return c.cs.getEntries(R,f).next(V=>{C=V,C.forEach((q,z)=>{z.isValidDocument()||(N=N.add(q))})}).next(()=>c.localDocuments.getOverlayedDocuments(R,C)).next(V=>{g=V;const q=[];for(const z of u){const B=vp(z,g.get(z.key).overlayedDocument);B!=null&&q.push(new oe(z.key,B,Zl(B.value.mapValue),ct.exists(!0)))}return c.mutationQueue.addMutationBatch(R,h,q,u)}).next(V=>{_=V;const q=V.applyToLocalDocumentSet(g,N);return c.documentOverlayCache.saveOverlays(R,V.batchId,q)})}).then(()=>({batchId:_.batchId,changes:mh(g)}))}(n.localStore,t);n.sharedClientState.addPendingMutation(i.batchId),function(a,u,c){let h=a.Ba[a.currentUser.toKey()];h||(h=new it(j)),h=h.insert(u,c),a.Ba[a.currentUser.toKey()]=h}(n,i.batchId,e),await ae(n,i.changes),await Jn(n.remoteStore)}catch(i){const s=Xn(i,"Failed to persist write");e.reject(s)}}async function Td(r,t){const e=k(r);try{const n=await m_(e.localStore,t);t.targetChanges.forEach((i,s)=>{const a=e.Na.get(s);a&&(L(i.addedDocuments.size+i.modifiedDocuments.size+i.removedDocuments.size<=1),i.addedDocuments.size>0?a.va=!0:i.modifiedDocuments.size>0?L(a.va):i.removedDocuments.size>0&&(L(a.va),a.va=!1))}),await ae(e,n,t)}catch(n){await De(n)}}function $c(r,t,e){const n=k(r);if(n.isPrimaryClient&&e===0||!n.isPrimaryClient&&e===1){const i=[];n.Fa.forEach((s,a)=>{const u=a.view.Z_(t);u.snapshot&&i.push(u.snapshot)}),function(a,u){const c=k(a);c.onlineState=u;let h=!1;c.queries.forEach((f,g)=>{for(const _ of g.j_)_.Z_(u)&&(h=!0)}),h&&ga(c)}(n.eventManager,t),i.length&&n.Ca.d_(i),n.onlineState=t,n.isPrimaryClient&&n.sharedClientState.setOnlineState(t)}}async function Y_(r,t,e){const n=k(r);n.sharedClientState.updateQueryState(t,"rejected",e);const i=n.Na.get(t),s=i&&i.key;if(s){let a=new it(M.comparator);a=a.insert(s,ot.newNoDocument(s,U.min()));const u=G().add(s),c=new Zr(U.min(),new Map,new it(j),a,u);await Td(n,c),n.Oa=n.Oa.remove(s),n.Na.delete(t),Ea(n)}else await Bn(n.localStore,t,!1).then(()=>zn(n,t,e)).catch(De)}async function X_(r,t){const e=k(r),n=t.batch.batchId;try{const i=await f_(e.localStore,t);Ia(e,n,null),ya(e,n),e.sharedClientState.updateMutationState(n,"acknowledged"),await ae(e,i)}catch(i){await De(i)}}async function Z_(r,t,e){const n=k(r);try{const i=await function(a,u){const c=k(a);return c.persistence.runTransaction("Reject batch","readwrite-primary",h=>{let f;return c.mutationQueue.lookupMutationBatch(h,u).next(g=>(L(g!==null),f=g.keys(),c.mutationQueue.removeMutationBatch(h,g))).next(()=>c.mutationQueue.performConsistencyCheck(h)).next(()=>c.documentOverlayCache.removeOverlaysForBatchId(h,f,u)).next(()=>c.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(h,f)).next(()=>c.localDocuments.getDocuments(h,f))})}(n.localStore,t);Ia(n,t,e),ya(n,t),n.sharedClientState.updateMutationState(t,"rejected",e),await ae(n,i)}catch(i){await De(i)}}async function ty(r,t){const e=k(r);ke(e.remoteStore)||x("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.");try{const n=await function(a){const u=k(a);return u.persistence.runTransaction("Get highest unacknowledged batch id","readonly",c=>u.mutationQueue.getHighestUnacknowledgedBatchId(c))}(e.localStore);if(n===-1)return void t.resolve();const i=e.ka.get(n)||[];i.push(t),e.ka.set(n,i)}catch(n){const i=Xn(n,"Initialization of waitForPendingWrites() operation failed");t.reject(i)}}function ya(r,t){(r.ka.get(t)||[]).forEach(e=>{e.resolve()}),r.ka.delete(t)}function Ia(r,t,e){const n=k(r);let i=n.Ba[n.currentUser.toKey()];if(i){const s=i.get(t);s&&(e?s.reject(e):s.resolve(),i=i.remove(t)),n.Ba[n.currentUser.toKey()]=i}}function zn(r,t,e=null){r.sharedClientState.removeLocalQueryTarget(t);for(const n of r.Ma.get(t))r.Fa.delete(n),e&&r.Ca.$a(n,e);r.Ma.delete(t),r.isPrimaryClient&&r.La.gr(t).forEach(n=>{r.La.containsKey(n)||vd(r,n)})}function vd(r,t){r.xa.delete(t.path.canonicalString());const e=r.Oa.get(t);e!==null&&(Un(r.remoteStore,e),r.Oa=r.Oa.remove(t),r.Na.delete(e),Ea(r))}function No(r,t,e){for(const n of e)n instanceof _d?(r.La.addReference(n.key,t),ey(r,n)):n instanceof yd?(x("SyncEngine","Document no longer in limbo: "+n.key),r.La.removeReference(n.key,t),r.La.containsKey(n.key)||vd(r,n.key)):O()}function ey(r,t){const e=t.key,n=e.path.canonicalString();r.Oa.get(e)||r.xa.has(n)||(x("SyncEngine","New document in limbo: "+e),r.xa.add(n),Ea(r))}function Ea(r){for(;r.xa.size>0&&r.Oa.size<r.maxConcurrentLimboResolutions;){const t=r.xa.values().next().value;r.xa.delete(t);const e=new M(W.fromString(t)),n=r.qa.next();r.Na.set(n,new G_(e)),r.Oa=r.Oa.insert(e,n),_s(r.remoteStore,new te(kt($n(e.path)),n,"TargetPurposeLimboResolution",Ot.oe))}}async function ae(r,t,e){const n=k(r),i=[],s=[],a=[];n.Fa.isEmpty()||(n.Fa.forEach((u,c)=>{a.push(n.Ka(c,t,e).then(h=>{var f;if((h||e)&&n.isPrimaryClient){const g=h?!h.fromCache:(f=e==null?void 0:e.targetChanges.get(c.targetId))===null||f===void 0?void 0:f.current;n.sharedClientState.updateQueryState(c.targetId,g?"current":"not-current")}if(h){i.push(h);const g=oa.Wi(c.targetId,h);s.push(g)}}))}),await Promise.all(a),n.Ca.d_(i),await async function(c,h){const f=k(c);try{await f.persistence.runTransaction("notifyLocalViewChanges","readwrite",g=>w.forEach(h,_=>w.forEach(_.$i,R=>f.persistence.referenceDelegate.addReference(g,_.targetId,R)).next(()=>w.forEach(_.Ui,R=>f.persistence.referenceDelegate.removeReference(g,_.targetId,R)))))}catch(g){if(!xe(g))throw g;x("LocalStore","Failed to update sequence numbers: "+g)}for(const g of h){const _=g.targetId;if(!g.fromCache){const R=f.os.get(_),C=R.snapshotVersion,N=R.withLastLimboFreeSnapshotVersion(C);f.os=f.os.insert(_,N)}}}(n.localStore,s))}async function ny(r,t){const e=k(r);if(!e.currentUser.isEqual(t)){x("SyncEngine","User change. New user:",t.toKey());const n=await nd(e.localStore,t);e.currentUser=t,function(s,a){s.ka.forEach(u=>{u.forEach(c=>{c.reject(new D(P.CANCELLED,a))})}),s.ka.clear()}(e,"'waitForPendingWrites' promise is rejected due to a user change."),e.sharedClientState.handleUserChange(t,n.removedBatchIds,n.addedBatchIds),await ae(e,n.hs)}}function ry(r,t){const e=k(r),n=e.Na.get(t);if(n&&n.va)return G().add(n.key);{let i=G();const s=e.Ma.get(t);if(!s)return i;for(const a of s){const u=e.Fa.get(a);i=i.unionWith(u.view.Va)}return i}}async function iy(r,t){const e=k(r),n=await es(e.localStore,t.query,!0),i=t.view.ba(n);return e.isPrimaryClient&&No(e,t.targetId,i.wa),i}async function sy(r,t){const e=k(r);return od(e.localStore,t).then(n=>ae(e,n))}async function oy(r,t,e,n){const i=k(r),s=await function(u,c){const h=k(u),f=k(h.mutationQueue);return h.persistence.runTransaction("Lookup mutation documents","readonly",g=>f.Mn(g,c).next(_=>_?h.localDocuments.getDocuments(g,_):w.resolve(null)))}(i.localStore,t);s!==null?(e==="pending"?await Jn(i.remoteStore):e==="acknowledged"||e==="rejected"?(Ia(i,t,n||null),ya(i,t),function(u,c){k(k(u).mutationQueue).On(c)}(i.localStore,t)):O(),await ae(i,s)):x("SyncEngine","Cannot apply mutation batch with id: "+t)}async function ay(r,t){const e=k(r);if(ys(e),Ta(e),t===!0&&e.Qa!==!0){const n=e.sharedClientState.getAllActiveQueryTargets(),i=await Qc(e,n.toArray());e.Qa=!0,await Do(e.remoteStore,!0);for(const s of i)_s(e.remoteStore,s)}else if(t===!1&&e.Qa!==!1){const n=[];let i=Promise.resolve();e.Ma.forEach((s,a)=>{e.sharedClientState.isLocalQueryTarget(a)?n.push(a):i=i.then(()=>(zn(e,a),Bn(e.localStore,a,!0))),Un(e.remoteStore,a)}),await i,await Qc(e,n),function(a){const u=k(a);u.Na.forEach((c,h)=>{Un(u.remoteStore,h)}),u.La.pr(),u.Na=new Map,u.Oa=new it(M.comparator)}(e),e.Qa=!1,await Do(e.remoteStore,!1)}}async function Qc(r,t,e){const n=k(r),i=[],s=[];for(const a of t){let u;const c=n.Ma.get(a);if(c&&c.length!==0){u=await Ln(n.localStore,kt(c[0]));for(const h of c){const f=n.Fa.get(h),g=await iy(n,f);g.snapshot&&s.push(g.snapshot)}}else{const h=await sd(n.localStore,a);u=await Ln(n.localStore,h),await _a(n,wd(h),a,!1,u.resumeToken)}i.push(u)}return n.Ca.d_(s),i}function wd(r){return ah(r.path,r.collectionGroup,r.orderBy,r.filters,r.limit,"F",r.startAt,r.endAt)}function uy(r){return function(e){return k(k(e).persistence).Qi()}(k(r).localStore)}async function cy(r,t,e,n){const i=k(r);if(i.Qa)return void x("SyncEngine","Ignoring unexpected query state notification.");const s=i.Ma.get(t);if(s&&s.length>0)switch(e){case"current":case"not-current":{const a=await od(i.localStore,hh(s[0])),u=Zr.createSynthesizedRemoteEventForCurrentChange(t,e==="current",dt.EMPTY_BYTE_STRING);await ae(i,a,u);break}case"rejected":await Bn(i.localStore,t,!0),zn(i,t,n);break;default:O()}}async function ly(r,t,e){const n=ys(r);if(n.Qa){for(const i of t){if(n.Ma.has(i)&&n.sharedClientState.isActiveQueryTarget(i)){x("SyncEngine","Adding an already active target "+i);continue}const s=await sd(n.localStore,i),a=await Ln(n.localStore,s);await _a(n,wd(s),a.targetId,!1,a.resumeToken),_s(n.remoteStore,a)}for(const i of e)n.Ma.has(i)&&await Bn(n.localStore,i,!1).then(()=>{Un(n.remoteStore,i),zn(n,i)}).catch(De)}}function ys(r){const t=k(r);return t.remoteStore.remoteSyncer.applyRemoteEvent=Td.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=ry.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=Y_.bind(null,t),t.Ca.d_=B_.bind(null,t.eventManager),t.Ca.$a=U_.bind(null,t.eventManager),t}function Ta(r){const t=k(r);return t.remoteStore.remoteSyncer.applySuccessfulWrite=X_.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=Z_.bind(null,t),t}function hy(r,t,e){const n=k(r);(async function(s,a,u){try{const c=await a.getMetadata();if(await function(R,C){const N=k(R),V=pt(C.createTime);return N.persistence.runTransaction("hasNewerBundle","readonly",q=>N.Gr.getBundleMetadata(q,C.id)).then(q=>!!q&&q.createTime.compareTo(V)>=0)}(s.localStore,c))return await a.close(),u._completeWith(function(R){return{taskState:"Success",documentsLoaded:R.totalDocuments,bytesLoaded:R.totalBytes,totalDocuments:R.totalDocuments,totalBytes:R.totalBytes}}(c)),Promise.resolve(new Set);u._updateProgress(pd(c));const h=new z_(c,s.localStore,a.serializer);let f=await a.Ua();for(;f;){const _=await h.la(f);_&&u._updateProgress(_),f=await a.Ua()}const g=await h.complete();return await ae(s,g.Ia,void 0),await function(R,C){const N=k(R);return N.persistence.runTransaction("Save bundle","readwrite",V=>N.Gr.saveBundleMetadata(V,C))}(s.localStore,c),u._completeWith(g.progress),Promise.resolve(g.Pa)}catch(c){return qt("SyncEngine",`Loading bundle failed with ${c}`),u._failWith(c),Promise.resolve(new Set)}})(n,t,e).then(i=>{n.sharedClientState.notifyBundleLoaded(i)})}class Se{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(t){this.serializer=ei(t.databaseInfo.databaseId),this.sharedClientState=this.Wa(t),this.persistence=this.Ga(t),await this.persistence.start(),this.localStore=this.za(t),this.gcScheduler=this.ja(t,this.localStore),this.indexBackfillerScheduler=this.Ha(t,this.localStore)}ja(t,e){return null}Ha(t,e){return null}za(t){return ed(this.persistence,new td,t.initialUser,this.serializer)}Ga(t){return new ra(ps.Zr,this.serializer)}Wa(t){return new ud}async terminate(){var t,e;(t=this.gcScheduler)===null||t===void 0||t.stop(),(e=this.indexBackfillerScheduler)===null||e===void 0||e.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}Se.provider={build:()=>new Se};class dy extends Se{constructor(t){super(),this.cacheSizeBytes=t}ja(t,e){L(this.persistence.referenceDelegate instanceof ts);const n=this.persistence.referenceDelegate.garbageCollector;return new Hh(n,t.asyncQueue,e)}Ga(t){const e=this.cacheSizeBytes!==void 0?xt.withCacheSize(this.cacheSizeBytes):xt.DEFAULT;return new ra(n=>ts.Zr(n,e),this.serializer)}}class va extends Se{constructor(t,e,n){super(),this.Ja=t,this.cacheSizeBytes=e,this.forceOwnership=n,this.kind="persistent",this.synchronizeTabs=!1}async initialize(t){await super.initialize(t),await this.Ja.initialize(this,t),await Ta(this.Ja.syncEngine),await Jn(this.Ja.remoteStore),await this.persistence.yi(()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(),this.indexBackfillerScheduler&&!this.indexBackfillerScheduler.started&&this.indexBackfillerScheduler.start(),Promise.resolve()))}za(t){return ed(this.persistence,new td,t.initialUser,this.serializer)}ja(t,e){const n=this.persistence.referenceDelegate.garbageCollector;return new Hh(n,t.asyncQueue,e)}Ha(t,e){const n=new Ng(e,this.persistence);return new xg(t.asyncQueue,n)}Ga(t){const e=sa(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey),n=this.cacheSizeBytes!==void 0?xt.withCacheSize(this.cacheSizeBytes):xt.DEFAULT;return new ia(this.synchronizeTabs,e,t.clientId,n,t.asyncQueue,cd(),ji(),this.serializer,this.sharedClientState,!!this.forceOwnership)}Wa(t){return new ud}}class Ad extends va{constructor(t,e){super(t,e,!1),this.Ja=t,this.cacheSizeBytes=e,this.synchronizeTabs=!0}async initialize(t){await super.initialize(t);const e=this.Ja.syncEngine;this.sharedClientState instanceof oo&&(this.sharedClientState.syncEngine={no:oy.bind(null,e),ro:cy.bind(null,e),io:ly.bind(null,e),Qi:uy.bind(null,e),eo:sy.bind(null,e)},await this.sharedClientState.start()),await this.persistence.yi(async n=>{await ay(this.Ja.syncEngine,n),this.gcScheduler&&(n&&!this.gcScheduler.started?this.gcScheduler.start():n||this.gcScheduler.stop()),this.indexBackfillerScheduler&&(n&&!this.indexBackfillerScheduler.started?this.indexBackfillerScheduler.start():n||this.indexBackfillerScheduler.stop())})}Wa(t){const e=cd();if(!oo.D(e))throw new D(P.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");const n=sa(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey);return new oo(e,t.asyncQueue,n,t.clientId,t.initialUser)}}class Ve{async initialize(t,e){this.localStore||(this.localStore=t.localStore,this.sharedClientState=t.sharedClientState,this.datastore=this.createDatastore(e),this.remoteStore=this.createRemoteStore(e),this.eventManager=this.createEventManager(e),this.syncEngine=this.createSyncEngine(e,!t.synchronizeTabs),this.sharedClientState.onlineStateHandler=n=>$c(this.syncEngine,n,1),this.remoteStore.remoteSyncer.handleCredentialChange=ny.bind(null,this.syncEngine),await Do(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(t){return function(){return new L_}()}createDatastore(t){const e=ei(t.databaseInfo.databaseId),n=function(s){return new T_(s)}(t.databaseInfo);return function(s,a,u,c){return new A_(s,a,u,c)}(t.authCredentials,t.appCheckCredentials,n,e)}createRemoteStore(t){return function(n,i,s,a,u){return new b_(n,i,s,a,u)}(this.localStore,this.datastore,t.asyncQueue,e=>$c(this.syncEngine,e,0),function(){return Uc.D()?new Uc:new y_}())}createSyncEngine(t,e){return function(i,s,a,u,c,h,f){const g=new K_(i,s,a,u,c,h);return f&&(g.Qa=!0),g}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,t.initialUser,t.maxConcurrentLimboResolutions,e)}async terminate(){var t,e;await async function(i){const s=k(i);x("RemoteStore","RemoteStore shutting down."),s.L_.add(5),await Hn(s),s.k_.shutdown(),s.q_.set("Unknown")}(this.remoteStore),(t=this.datastore)===null||t===void 0||t.terminate(),(e=this.eventManager)===null||e===void 0||e.terminate()}}Ve.provider={build:()=>new Ve};function Wc(r,t=10240){let e=0;return{async read(){if(e<r.byteLength){const n={value:r.slice(e,e+t),done:!1};return e+=t,n}return{done:!0}},async cancel(){},releaseLock(){},closed:Promise.resolve()}}/**
2076
2076
  * @license
2077
2077
  * Copyright 2020 Google LLC
2078
2078
  *
@@ -2133,7 +2133,7 @@ This typically indicates that your device does not have a healthy Internet conne
2133
2133
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2134
2134
  * See the License for the specific language governing permissions and
2135
2135
  * limitations under the License.
2136
- */class my{constructor(t){this.datastore=t,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastTransactionError=null,this.writtenDocs=new Set}async lookup(t){if(this.ensureCommitNotCalled(),this.mutations.length>0)throw this.lastTransactionError=new D(P.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes."),this.lastTransactionError;const e=await async function(i,s){const a=k(i),u={documents:s.map(g=>jr(a.serializer,g))},c=await a.Lo("BatchGetDocuments",a.serializer.databaseId,W.emptyPath(),u,s.length),h=new Map;c.forEach(g=>{const _=Dp(a.serializer,g);h.set(_.key.toString(),_)});const f=[];return s.forEach(g=>{const _=h.get(g.toString());L(!!_),f.push(_)}),f}(this.datastore,t);return e.forEach(n=>this.recordVersion(n)),e}set(t,e){this.write(e.toMutation(t,this.precondition(t))),this.writtenDocs.add(t.toString())}update(t,e){try{this.write(e.toMutation(t,this.preconditionForUpdate(t)))}catch(n){this.lastTransactionError=n}this.writtenDocs.add(t.toString())}delete(t){this.write(new Qn(t,this.precondition(t))),this.writtenDocs.add(t.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastTransactionError)throw this.lastTransactionError;const t=this.readVersions;this.mutations.forEach(e=>{t.delete(e.key.toString())}),t.forEach((e,n)=>{const i=M.fromPath(n);this.mutations.push(new Qo(i,this.precondition(i)))}),await async function(n,i){const s=k(n),a={writes:i.map(u=>Gr(s.serializer,u))};await s.Mo("Commit",s.serializer.databaseId,W.emptyPath(),a)}(this.datastore,this.mutations),this.committed=!0}recordVersion(t){let e;if(t.isFoundDocument())e=t.version;else{if(!t.isNoDocument())throw O();e=U.min()}const n=this.readVersions.get(t.key.toString());if(n){if(!e.isEqual(n))throw new D(P.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(t.key.toString(),e)}precondition(t){const e=this.readVersions.get(t.toString());return!this.writtenDocs.has(t.toString())&&e?e.isEqual(U.min())?ct.exists(!1):ct.updateTime(e):ct.none()}preconditionForUpdate(t){const e=this.readVersions.get(t.toString());if(!this.writtenDocs.has(t.toString())&&e){if(e.isEqual(U.min()))throw new D(P.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return ct.updateTime(e)}return ct.exists(!0)}write(t){this.ensureCommitNotCalled(),this.mutations.push(t)}ensureCommitNotCalled(){}}/**
2136
+ */class my{constructor(t){this.datastore=t,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastTransactionError=null,this.writtenDocs=new Set}async lookup(t){if(this.ensureCommitNotCalled(),this.mutations.length>0)throw this.lastTransactionError=new D(P.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes."),this.lastTransactionError;const e=await async function(i,s){const a=k(i),u={documents:s.map(g=>Gr(a.serializer,g))},c=await a.Lo("BatchGetDocuments",a.serializer.databaseId,W.emptyPath(),u,s.length),h=new Map;c.forEach(g=>{const _=Dp(a.serializer,g);h.set(_.key.toString(),_)});const f=[];return s.forEach(g=>{const _=h.get(g.toString());L(!!_),f.push(_)}),f}(this.datastore,t);return e.forEach(n=>this.recordVersion(n)),e}set(t,e){this.write(e.toMutation(t,this.precondition(t))),this.writtenDocs.add(t.toString())}update(t,e){try{this.write(e.toMutation(t,this.preconditionForUpdate(t)))}catch(n){this.lastTransactionError=n}this.writtenDocs.add(t.toString())}delete(t){this.write(new Wn(t,this.precondition(t))),this.writtenDocs.add(t.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastTransactionError)throw this.lastTransactionError;const t=this.readVersions;this.mutations.forEach(e=>{t.delete(e.key.toString())}),t.forEach((e,n)=>{const i=M.fromPath(n);this.mutations.push(new Qo(i,this.precondition(i)))}),await async function(n,i){const s=k(n),a={writes:i.map(u=>Kr(s.serializer,u))};await s.Mo("Commit",s.serializer.databaseId,W.emptyPath(),a)}(this.datastore,this.mutations),this.committed=!0}recordVersion(t){let e;if(t.isFoundDocument())e=t.version;else{if(!t.isNoDocument())throw O();e=U.min()}const n=this.readVersions.get(t.key.toString());if(n){if(!e.isEqual(n))throw new D(P.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(t.key.toString(),e)}precondition(t){const e=this.readVersions.get(t.toString());return!this.writtenDocs.has(t.toString())&&e?e.isEqual(U.min())?ct.exists(!1):ct.updateTime(e):ct.none()}preconditionForUpdate(t){const e=this.readVersions.get(t.toString());if(!this.writtenDocs.has(t.toString())&&e){if(e.isEqual(U.min()))throw new D(P.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return ct.updateTime(e)}return ct.exists(!0)}write(t){this.ensureCommitNotCalled(),this.mutations.push(t)}ensureCommitNotCalled(){}}/**
2137
2137
  * @license
2138
2138
  * Copyright 2019 Google LLC
2139
2139
  *
@@ -2163,7 +2163,7 @@ This typically indicates that your device does not have a healthy Internet conne
2163
2163
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2164
2164
  * See the License for the specific language governing permissions and
2165
2165
  * limitations under the License.
2166
- */class py{constructor(t,e,n,i,s){this.authCredentials=t,this.appCheckCredentials=e,this.asyncQueue=n,this.databaseInfo=i,this.user=Tt.UNAUTHENTICATED,this.clientId=Bo.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=s,this.authCredentials.start(n,async a=>{x("FirestoreClient","Received user=",a.uid),await this.authCredentialListener(a),this.user=a}),this.appCheckCredentials.start(n,a=>(x("FirestoreClient","Received new app check token=",a),this.appCheckCredentialListener(a,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(t){this.authCredentialListener=t}setAppCheckTokenChangeListener(t){this.appCheckCredentialListener=t}terminate(){this.asyncQueue.enterRestrictedMode();const t=new vt;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),t.resolve()}catch(e){const n=Yn(e,"Failed to shutdown persistence");t.reject(n)}}),t.promise}}async function uo(r,t){r.asyncQueue.verifyOperationInProgress(),x("FirestoreClient","Initializing OfflineComponentProvider");const e=r.configuration;await t.initialize(e);let n=e.initialUser;r.setCredentialChangeListener(async i=>{n.isEqual(i)||(await nd(t.localStore,i),n=i)}),t.persistence.setDatabaseDeletedListener(()=>r.terminate()),r._offlineComponents=t}async function Hc(r,t){r.asyncQueue.verifyOperationInProgress();const e=await wa(r);x("FirestoreClient","Initializing OnlineComponentProvider"),await t.initialize(e,r.configuration),r.setCredentialChangeListener(n=>qc(t.remoteStore,n)),r.setAppCheckTokenChangeListener((n,i)=>qc(t.remoteStore,i)),r._onlineComponents=t}async function wa(r){if(!r._offlineComponents)if(r._uninitializedComponentsProvider){x("FirestoreClient","Using user provided OfflineComponentProvider");try{await uo(r,r._uninitializedComponentsProvider._offline)}catch(t){const e=t;if(!function(i){return i.name==="FirebaseError"?i.code===P.FAILED_PRECONDITION||i.code===P.UNIMPLEMENTED:!(typeof DOMException<"u"&&i instanceof DOMException)||i.code===22||i.code===20||i.code===11}(e))throw e;qt("Error using user provided cache. Falling back to memory cache: "+e),await uo(r,new Pe)}}else x("FirestoreClient","Using default OfflineComponentProvider"),await uo(r,new Pe);return r._offlineComponents}async function Es(r){return r._onlineComponents||(r._uninitializedComponentsProvider?(x("FirestoreClient","Using user provided OnlineComponentProvider"),await Hc(r,r._uninitializedComponentsProvider._online)):(x("FirestoreClient","Using default OnlineComponentProvider"),await Hc(r,new Se))),r._onlineComponents}function Rd(r){return wa(r).then(t=>t.persistence)}function Xn(r){return wa(r).then(t=>t.localStore)}function bd(r){return Es(r).then(t=>t.remoteStore)}function Aa(r){return Es(r).then(t=>t.syncEngine)}function Pd(r){return Es(r).then(t=>t.datastore)}async function zn(r){const t=await Es(r),e=t.eventManager;return e.onListen=$_.bind(null,t.syncEngine),e.onUnlisten=W_.bind(null,t.syncEngine),e.onFirstRemoteStoreListen=Q_.bind(null,t.syncEngine),e.onLastRemoteStoreUnlisten=H_.bind(null,t.syncEngine),e}function _y(r){return r.asyncQueue.enqueue(async()=>{const t=await Rd(r),e=await bd(r);return t.setNetworkEnabled(!0),function(i){const s=k(i);return s.L_.delete(0),ni(s)}(e)})}function yy(r){return r.asyncQueue.enqueue(async()=>{const t=await Rd(r),e=await bd(r);return t.setNetworkEnabled(!1),async function(i){const s=k(i);s.L_.add(0),await Wn(s),s.q_.set("Offline")}(e)})}function Iy(r,t){const e=new vt;return r.asyncQueue.enqueueAndForget(async()=>async function(i,s,a){try{const u=await function(h,f){const g=k(h);return g.persistence.runTransaction("read document","readonly",_=>g.localDocuments.getDocument(_,f))}(i,s);u.isFoundDocument()?a.resolve(u):u.isNoDocument()?a.resolve(null):a.reject(new D(P.UNAVAILABLE,"Failed to get document from cache. (However, this document may exist on the server. Run again without setting 'source' in the GetOptions to attempt to retrieve the document from the server.)"))}catch(u){const c=Yn(u,`Failed to get document '${s} from cache`);a.reject(c)}}(await Xn(r),t,e)),e.promise}function Sd(r,t,e={}){const n=new vt;return r.asyncQueue.enqueueAndForget(async()=>function(s,a,u,c,h){const f=new Is({next:_=>{f.Za(),a.enqueueAndForget(()=>ma(s,g));const R=_.docs.has(u);!R&&_.fromCache?h.reject(new D(P.UNAVAILABLE,"Failed to get document because the client is offline.")):R&&_.fromCache&&c&&c.source==="server"?h.reject(new D(P.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(_)},error:_=>h.reject(_)}),g=new pa(Kn(u.path),f,{includeMetadataChanges:!0,_a:!0});return fa(s,g)}(await zn(r),r.asyncQueue,t,e,n)),n.promise}function Ey(r,t){const e=new vt;return r.asyncQueue.enqueueAndForget(async()=>async function(i,s,a){try{const u=await es(i,s,!0),c=new Id(s,u.Ts),h=c.ma(u.documents),f=c.applyChanges(h,!1);a.resolve(f.snapshot)}catch(u){const c=Yn(u,`Failed to execute query '${s} against cache`);a.reject(c)}}(await Xn(r),t,e)),e.promise}function Vd(r,t,e={}){const n=new vt;return r.asyncQueue.enqueueAndForget(async()=>function(s,a,u,c,h){const f=new Is({next:_=>{f.Za(),a.enqueueAndForget(()=>ma(s,g)),_.fromCache&&c.source==="server"?h.reject(new D(P.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(_)},error:_=>h.reject(_)}),g=new pa(u,f,{includeMetadataChanges:!0,_a:!0});return fa(s,g)}(await zn(r),r.asyncQueue,t,e,n)),n.promise}function Ty(r,t,e){const n=new vt;return r.asyncQueue.enqueueAndForget(async()=>{try{const i=await Pd(r);n.resolve(async function(a,u,c){var h;const f=k(a),{request:g,ut:_,parent:R}=Oh(f.serializer,uh(u),c);f.connection.Fo||delete g.parent;const C=(await f.Lo("RunAggregationQuery",f.serializer.databaseId,R,g,1)).filter(V=>!!V.result);L(C.length===1);const N=(h=C[0].result)===null||h===void 0?void 0:h.aggregateFields;return Object.keys(N).reduce((V,q)=>(V[_[q]]=N[q],V),{})}(i,t,e))}catch(i){n.reject(i)}}),n.promise}function vy(r,t){const e=new Is(t);return r.asyncQueue.enqueueAndForget(async()=>function(i,s){k(i).Y_.add(s),s.next()}(await zn(r),e)),()=>{e.Za(),r.asyncQueue.enqueueAndForget(async()=>function(i,s){k(i).Y_.delete(s)}(await zn(r),e))}}function wy(r,t,e,n){const i=function(a,u){let c;return c=typeof a=="string"?Ph().encode(a):a,function(f,g){return new fy(f,g)}(function(f,g){if(f instanceof Uint8Array)return Wc(f,g);if(f instanceof ArrayBuffer)return Wc(new Uint8Array(f),g);if(f instanceof ReadableStream)return f.getReader();throw new Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}(c),u)}(e,ei(t));r.asyncQueue.enqueueAndForget(async()=>{hy(await Aa(r),i,n)})}function Ay(r,t){return r.asyncQueue.enqueue(async()=>function(n,i){const s=k(n);return s.persistence.runTransaction("Get named query","readonly",a=>s.Gr.getNamedQuery(a,i))}(await Xn(r),t))}function Ry(r,t){return r.asyncQueue.enqueue(async()=>async function(n,i){const s=k(n),a=s.indexManager,u=[];return s.persistence.runTransaction("Configure indexes","readwrite",c=>a.getFieldIndexes(c).next(h=>function(g,_,R,C,N){g=[...g],_=[..._],g.sort(R),_.sort(R);const V=g.length,q=_.length;let z=0,B=0;for(;z<q&&B<V;){const $=R(g[B],_[z]);$<0?N(g[B++]):$>0?C(_[z++]):(z++,B++)}for(;z<q;)C(_[z++]);for(;B<V;)N(g[B++])}(h,i,Sg,f=>{u.push(a.addFieldIndex(c,f))},f=>{u.push(a.deleteFieldIndex(c,f))})).next(()=>w.waitFor(u)))}(await Xn(r),t))}function by(r,t){return r.asyncQueue.enqueue(async()=>function(n,i){k(n).ss.zi=i}(await Xn(r),t))}function Py(r){return r.asyncQueue.enqueue(async()=>function(e){const n=k(e),i=n.indexManager;return n.persistence.runTransaction("Delete All Indexes","readwrite",s=>i.deleteAllFieldIndexes(s))}(await Xn(r)))}/**
2166
+ */class py{constructor(t,e,n,i,s){this.authCredentials=t,this.appCheckCredentials=e,this.asyncQueue=n,this.databaseInfo=i,this.user=Tt.UNAUTHENTICATED,this.clientId=Bo.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=s,this.authCredentials.start(n,async a=>{x("FirestoreClient","Received user=",a.uid),await this.authCredentialListener(a),this.user=a}),this.appCheckCredentials.start(n,a=>(x("FirestoreClient","Received new app check token=",a),this.appCheckCredentialListener(a,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(t){this.authCredentialListener=t}setAppCheckTokenChangeListener(t){this.appCheckCredentialListener=t}terminate(){this.asyncQueue.enterRestrictedMode();const t=new vt;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),t.resolve()}catch(e){const n=Xn(e,"Failed to shutdown persistence");t.reject(n)}}),t.promise}}async function uo(r,t){r.asyncQueue.verifyOperationInProgress(),x("FirestoreClient","Initializing OfflineComponentProvider");const e=r.configuration;await t.initialize(e);let n=e.initialUser;r.setCredentialChangeListener(async i=>{n.isEqual(i)||(await nd(t.localStore,i),n=i)}),t.persistence.setDatabaseDeletedListener(()=>r.terminate()),r._offlineComponents=t}async function Hc(r,t){r.asyncQueue.verifyOperationInProgress();const e=await wa(r);x("FirestoreClient","Initializing OnlineComponentProvider"),await t.initialize(e,r.configuration),r.setCredentialChangeListener(n=>qc(t.remoteStore,n)),r.setAppCheckTokenChangeListener((n,i)=>qc(t.remoteStore,i)),r._onlineComponents=t}async function wa(r){if(!r._offlineComponents)if(r._uninitializedComponentsProvider){x("FirestoreClient","Using user provided OfflineComponentProvider");try{await uo(r,r._uninitializedComponentsProvider._offline)}catch(t){const e=t;if(!function(i){return i.name==="FirebaseError"?i.code===P.FAILED_PRECONDITION||i.code===P.UNIMPLEMENTED:!(typeof DOMException<"u"&&i instanceof DOMException)||i.code===22||i.code===20||i.code===11}(e))throw e;qt("Error using user provided cache. Falling back to memory cache: "+e),await uo(r,new Se)}}else x("FirestoreClient","Using default OfflineComponentProvider"),await uo(r,new Se);return r._offlineComponents}async function Es(r){return r._onlineComponents||(r._uninitializedComponentsProvider?(x("FirestoreClient","Using user provided OnlineComponentProvider"),await Hc(r,r._uninitializedComponentsProvider._online)):(x("FirestoreClient","Using default OnlineComponentProvider"),await Hc(r,new Ve))),r._onlineComponents}function Rd(r){return wa(r).then(t=>t.persistence)}function Zn(r){return wa(r).then(t=>t.localStore)}function bd(r){return Es(r).then(t=>t.remoteStore)}function Aa(r){return Es(r).then(t=>t.syncEngine)}function Pd(r){return Es(r).then(t=>t.datastore)}async function jn(r){const t=await Es(r),e=t.eventManager;return e.onListen=$_.bind(null,t.syncEngine),e.onUnlisten=W_.bind(null,t.syncEngine),e.onFirstRemoteStoreListen=Q_.bind(null,t.syncEngine),e.onLastRemoteStoreUnlisten=H_.bind(null,t.syncEngine),e}function _y(r){return r.asyncQueue.enqueue(async()=>{const t=await Rd(r),e=await bd(r);return t.setNetworkEnabled(!0),function(i){const s=k(i);return s.L_.delete(0),ni(s)}(e)})}function yy(r){return r.asyncQueue.enqueue(async()=>{const t=await Rd(r),e=await bd(r);return t.setNetworkEnabled(!1),async function(i){const s=k(i);s.L_.add(0),await Hn(s),s.q_.set("Offline")}(e)})}function Iy(r,t){const e=new vt;return r.asyncQueue.enqueueAndForget(async()=>async function(i,s,a){try{const u=await function(h,f){const g=k(h);return g.persistence.runTransaction("read document","readonly",_=>g.localDocuments.getDocument(_,f))}(i,s);u.isFoundDocument()?a.resolve(u):u.isNoDocument()?a.resolve(null):a.reject(new D(P.UNAVAILABLE,"Failed to get document from cache. (However, this document may exist on the server. Run again without setting 'source' in the GetOptions to attempt to retrieve the document from the server.)"))}catch(u){const c=Xn(u,`Failed to get document '${s} from cache`);a.reject(c)}}(await Zn(r),t,e)),e.promise}function Sd(r,t,e={}){const n=new vt;return r.asyncQueue.enqueueAndForget(async()=>function(s,a,u,c,h){const f=new Is({next:_=>{f.Za(),a.enqueueAndForget(()=>ma(s,g));const R=_.docs.has(u);!R&&_.fromCache?h.reject(new D(P.UNAVAILABLE,"Failed to get document because the client is offline.")):R&&_.fromCache&&c&&c.source==="server"?h.reject(new D(P.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(_)},error:_=>h.reject(_)}),g=new pa($n(u.path),f,{includeMetadataChanges:!0,_a:!0});return fa(s,g)}(await jn(r),r.asyncQueue,t,e,n)),n.promise}function Ey(r,t){const e=new vt;return r.asyncQueue.enqueueAndForget(async()=>async function(i,s,a){try{const u=await es(i,s,!0),c=new Id(s,u.Ts),h=c.ma(u.documents),f=c.applyChanges(h,!1);a.resolve(f.snapshot)}catch(u){const c=Xn(u,`Failed to execute query '${s} against cache`);a.reject(c)}}(await Zn(r),t,e)),e.promise}function Vd(r,t,e={}){const n=new vt;return r.asyncQueue.enqueueAndForget(async()=>function(s,a,u,c,h){const f=new Is({next:_=>{f.Za(),a.enqueueAndForget(()=>ma(s,g)),_.fromCache&&c.source==="server"?h.reject(new D(P.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(_)},error:_=>h.reject(_)}),g=new pa(u,f,{includeMetadataChanges:!0,_a:!0});return fa(s,g)}(await jn(r),r.asyncQueue,t,e,n)),n.promise}function Ty(r,t,e){const n=new vt;return r.asyncQueue.enqueueAndForget(async()=>{try{const i=await Pd(r);n.resolve(async function(a,u,c){var h;const f=k(a),{request:g,ut:_,parent:R}=Oh(f.serializer,uh(u),c);f.connection.Fo||delete g.parent;const C=(await f.Lo("RunAggregationQuery",f.serializer.databaseId,R,g,1)).filter(V=>!!V.result);L(C.length===1);const N=(h=C[0].result)===null||h===void 0?void 0:h.aggregateFields;return Object.keys(N).reduce((V,q)=>(V[_[q]]=N[q],V),{})}(i,t,e))}catch(i){n.reject(i)}}),n.promise}function vy(r,t){const e=new Is(t);return r.asyncQueue.enqueueAndForget(async()=>function(i,s){k(i).Y_.add(s),s.next()}(await jn(r),e)),()=>{e.Za(),r.asyncQueue.enqueueAndForget(async()=>function(i,s){k(i).Y_.delete(s)}(await jn(r),e))}}function wy(r,t,e,n){const i=function(a,u){let c;return c=typeof a=="string"?Ph().encode(a):a,function(f,g){return new fy(f,g)}(function(f,g){if(f instanceof Uint8Array)return Wc(f,g);if(f instanceof ArrayBuffer)return Wc(new Uint8Array(f),g);if(f instanceof ReadableStream)return f.getReader();throw new Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}(c),u)}(e,ei(t));r.asyncQueue.enqueueAndForget(async()=>{hy(await Aa(r),i,n)})}function Ay(r,t){return r.asyncQueue.enqueue(async()=>function(n,i){const s=k(n);return s.persistence.runTransaction("Get named query","readonly",a=>s.Gr.getNamedQuery(a,i))}(await Zn(r),t))}function Ry(r,t){return r.asyncQueue.enqueue(async()=>async function(n,i){const s=k(n),a=s.indexManager,u=[];return s.persistence.runTransaction("Configure indexes","readwrite",c=>a.getFieldIndexes(c).next(h=>function(g,_,R,C,N){g=[...g],_=[..._],g.sort(R),_.sort(R);const V=g.length,q=_.length;let z=0,B=0;for(;z<q&&B<V;){const $=R(g[B],_[z]);$<0?N(g[B++]):$>0?C(_[z++]):(z++,B++)}for(;z<q;)C(_[z++]);for(;B<V;)N(g[B++])}(h,i,Sg,f=>{u.push(a.addFieldIndex(c,f))},f=>{u.push(a.deleteFieldIndex(c,f))})).next(()=>w.waitFor(u)))}(await Zn(r),t))}function by(r,t){return r.asyncQueue.enqueue(async()=>function(n,i){k(n).ss.zi=i}(await Zn(r),t))}function Py(r){return r.asyncQueue.enqueue(async()=>function(e){const n=k(e),i=n.indexManager;return n.persistence.runTransaction("Delete All Indexes","readwrite",s=>i.deleteAllFieldIndexes(s))}(await Zn(r)))}/**
2167
2167
  * @license
2168
2168
  * Copyright 2023 Google LLC
2169
2169
  *
@@ -2238,7 +2238,7 @@ This typically indicates that your device does not have a healthy Internet conne
2238
2238
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2239
2239
  * See the License for the specific language governing permissions and
2240
2240
  * limitations under the License.
2241
- */class wt{constructor(t,e,n){this.converter=e,this._query=n,this.type="query",this.firestore=t}withConverter(t){return new wt(this.firestore,t,this._query)}}class mt{constructor(t,e,n){this.converter=e,this._key=n,this.type="document",this.firestore=t}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new Kt(this.firestore,this.converter,this._key.path.popLast())}withConverter(t){return new mt(this.firestore,t,this._key)}}class Kt extends wt{constructor(t,e,n){super(t,e,Kn(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const t=this._path.popLast();return t.isEmpty()?null:new mt(this.firestore,null,new M(t))}withConverter(t){return new Kt(this.firestore,t,this._path)}}function ba(r,t,...e){if(r=yt(r),Ra("collection","path",t),r instanceof ri){const n=W.fromString(t,...e);return Xc(n),new Kt(r,null,n)}{if(!(r instanceof mt||r instanceof Kt))throw new D(P.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const n=r._path.child(W.fromString(t,...e));return Xc(n),new Kt(r.firestore,null,n)}}function Sy(r,t){if(r=Q(r,ri),Ra("collectionGroup","collection id",t),t.indexOf("/")>=0)throw new D(P.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new wt(r,null,function(n){return new ie(W.emptyPath(),n)}(t))}function ii(r,t,...e){if(r=yt(r),arguments.length===1&&(t=Bo.newId()),Ra("doc","path",t),r instanceof ri){const n=W.fromString(t,...e);return Yc(n),new mt(r,null,new M(n))}{if(!(r instanceof mt||r instanceof Kt))throw new D(P.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const n=r._path.child(W.fromString(t,...e));return Yc(n),new mt(r.firestore,r instanceof Kt?r.converter:null,new M(n))}}function Vy(r,t){return r=yt(r),t=yt(t),(r instanceof mt||r instanceof Kt)&&(t instanceof mt||t instanceof Kt)&&r.firestore===t.firestore&&r.path===t.path&&r.converter===t.converter}function Pa(r,t){return r=yt(r),t=yt(t),r instanceof wt&&t instanceof wt&&r.firestore===t.firestore&&Jr(r._query,t._query)&&r.converter===t.converter}/**
2241
+ */class wt{constructor(t,e,n){this.converter=e,this._query=n,this.type="query",this.firestore=t}withConverter(t){return new wt(this.firestore,t,this._query)}}class mt{constructor(t,e,n){this.converter=e,this._key=n,this.type="document",this.firestore=t}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new Kt(this.firestore,this.converter,this._key.path.popLast())}withConverter(t){return new mt(this.firestore,t,this._key)}}class Kt extends wt{constructor(t,e,n){super(t,e,$n(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const t=this._path.popLast();return t.isEmpty()?null:new mt(this.firestore,null,new M(t))}withConverter(t){return new Kt(this.firestore,t,this._path)}}function ba(r,t,...e){if(r=yt(r),Ra("collection","path",t),r instanceof ri){const n=W.fromString(t,...e);return Xc(n),new Kt(r,null,n)}{if(!(r instanceof mt||r instanceof Kt))throw new D(P.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const n=r._path.child(W.fromString(t,...e));return Xc(n),new Kt(r.firestore,null,n)}}function Sy(r,t){if(r=Q(r,ri),Ra("collectionGroup","collection id",t),t.indexOf("/")>=0)throw new D(P.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new wt(r,null,function(n){return new ie(W.emptyPath(),n)}(t))}function ii(r,t,...e){if(r=yt(r),arguments.length===1&&(t=Bo.newId()),Ra("doc","path",t),r instanceof ri){const n=W.fromString(t,...e);return Yc(n),new mt(r,null,new M(n))}{if(!(r instanceof mt||r instanceof Kt))throw new D(P.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const n=r._path.child(W.fromString(t,...e));return Yc(n),new mt(r.firestore,r instanceof Kt?r.converter:null,new M(n))}}function Vy(r,t){return r=yt(r),t=yt(t),(r instanceof mt||r instanceof Kt)&&(t instanceof mt||t instanceof Kt)&&r.firestore===t.firestore&&r.path===t.path&&r.converter===t.converter}function Pa(r,t){return r=yt(r),t=yt(t),r instanceof wt&&t instanceof wt&&r.firestore===t.firestore&&Jr(r._query,t._query)&&r.converter===t.converter}/**
2242
2242
  * @license
2243
2243
  * Copyright 2020 Google LLC
2244
2244
  *
@@ -2253,7 +2253,7 @@ This typically indicates that your device does not have a healthy Internet conne
2253
2253
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2254
2254
  * See the License for the specific language governing permissions and
2255
2255
  * limitations under the License.
2256
- */class tl{constructor(t=Promise.resolve()){this.Pu=[],this.Iu=!1,this.Tu=[],this.Eu=null,this.du=!1,this.Au=!1,this.Ru=[],this.t_=new ua(this,"async_queue_retry"),this.Vu=()=>{const n=ji();n&&x("AsyncQueue","Visibility state changed to "+n.visibilityState),this.t_.jo()},this.mu=t;const e=ji();e&&typeof e.addEventListener=="function"&&e.addEventListener("visibilitychange",this.Vu)}get isShuttingDown(){return this.Iu}enqueueAndForget(t){this.enqueue(t)}enqueueAndForgetEvenWhileRestricted(t){this.fu(),this.gu(t)}enterRestrictedMode(t){if(!this.Iu){this.Iu=!0,this.Au=t||!1;const e=ji();e&&typeof e.removeEventListener=="function"&&e.removeEventListener("visibilitychange",this.Vu)}}enqueue(t){if(this.fu(),this.Iu)return new Promise(()=>{});const e=new vt;return this.gu(()=>this.Iu&&this.Au?Promise.resolve():(t().then(e.resolve,e.reject),e.promise)).then(()=>e.promise)}enqueueRetryable(t){this.enqueueAndForget(()=>(this.Pu.push(t),this.pu()))}async pu(){if(this.Pu.length!==0){try{await this.Pu[0](),this.Pu.shift(),this.t_.reset()}catch(t){if(!De(t))throw t;x("AsyncQueue","Operation failed with retryable error: "+t)}this.Pu.length>0&&this.t_.Go(()=>this.pu())}}gu(t){const e=this.mu.then(()=>(this.du=!0,t().catch(n=>{this.Eu=n,this.du=!1;const i=function(a){let u=a.message||"";return a.stack&&(u=a.stack.includes(a.message)?a.stack:a.message+`
2256
+ */class tl{constructor(t=Promise.resolve()){this.Pu=[],this.Iu=!1,this.Tu=[],this.Eu=null,this.du=!1,this.Au=!1,this.Ru=[],this.t_=new ua(this,"async_queue_retry"),this.Vu=()=>{const n=ji();n&&x("AsyncQueue","Visibility state changed to "+n.visibilityState),this.t_.jo()},this.mu=t;const e=ji();e&&typeof e.addEventListener=="function"&&e.addEventListener("visibilitychange",this.Vu)}get isShuttingDown(){return this.Iu}enqueueAndForget(t){this.enqueue(t)}enqueueAndForgetEvenWhileRestricted(t){this.fu(),this.gu(t)}enterRestrictedMode(t){if(!this.Iu){this.Iu=!0,this.Au=t||!1;const e=ji();e&&typeof e.removeEventListener=="function"&&e.removeEventListener("visibilitychange",this.Vu)}}enqueue(t){if(this.fu(),this.Iu)return new Promise(()=>{});const e=new vt;return this.gu(()=>this.Iu&&this.Au?Promise.resolve():(t().then(e.resolve,e.reject),e.promise)).then(()=>e.promise)}enqueueRetryable(t){this.enqueueAndForget(()=>(this.Pu.push(t),this.pu()))}async pu(){if(this.Pu.length!==0){try{await this.Pu[0](),this.Pu.shift(),this.t_.reset()}catch(t){if(!xe(t))throw t;x("AsyncQueue","Operation failed with retryable error: "+t)}this.Pu.length>0&&this.t_.Go(()=>this.pu())}}gu(t){const e=this.mu.then(()=>(this.du=!0,t().catch(n=>{this.Eu=n,this.du=!1;const i=function(a){let u=a.message||"";return a.stack&&(u=a.stack.includes(a.message)?a.stack:a.message+`
2257
2257
  `+a.stack),u}(n);throw gt("INTERNAL UNHANDLED ERROR: ",i),n}).then(n=>(this.du=!1,n))));return this.mu=e,e}enqueueAfterDelay(t,e,n){this.fu(),this.Ru.indexOf(t)>-1&&(e=0);const i=da.createAndSchedule(this,t,e,n,s=>this.yu(s));return this.Tu.push(i),i}fu(){this.Eu&&O()}verifyOperationInProgress(){}async wu(){let t;do t=this.mu,await t;while(t!==this.mu)}Su(t){for(const e of this.Tu)if(e.timerId===t)return!0;return!1}bu(t){return this.wu().then(()=>{this.Tu.sort((e,n)=>e.targetTimeMs-n.targetTimeMs);for(const e of this.Tu)if(e.skipDelay(),t!=="all"&&e.timerId===t)break;return this.wu()})}Du(t){this.Ru.push(t)}yu(t){const e=this.Tu.indexOf(t);this.Tu.splice(e,1)}}function ko(r){return function(e,n){if(typeof e!="object"||e===null)return!1;const i=e;for(const s of n)if(s in i&&typeof i[s]=="function")return!0;return!1}(r,["next","error","complete"])}class kd{constructor(){this._progressObserver={},this._taskCompletionResolver=new vt,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}onProgress(t,e,n){this._progressObserver={next:t,error:e,complete:n}}catch(t){return this._taskCompletionResolver.promise.catch(t)}then(t,e){return this._taskCompletionResolver.promise.then(t,e)}_completeWith(t){this._updateProgress(t),this._progressObserver.complete&&this._progressObserver.complete(),this._taskCompletionResolver.resolve(t)}_failWith(t){this._lastProgress.taskState="Error",this._progressObserver.next&&this._progressObserver.next(this._lastProgress),this._progressObserver.error&&this._progressObserver.error(t),this._taskCompletionResolver.reject(t)}_updateProgress(t){this._lastProgress=t,this._progressObserver.next&&this._progressObserver.next(t)}}/**
2258
2258
  * @license
2259
2259
  * Copyright 2020 Google LLC
@@ -2269,7 +2269,7 @@ This typically indicates that your device does not have a healthy Internet conne
2269
2269
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2270
2270
  * See the License for the specific language governing permissions and
2271
2271
  * limitations under the License.
2272
- */const Cy=-1;class nt extends ri{constructor(t,e,n,i){super(t,e,n,i),this.type="firestore",this._queue=new tl,this._persistenceKey=(i==null?void 0:i.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const t=this._firestoreClient.terminate();this._queue=new tl(t),this._firestoreClient=void 0,await t}}}function Dy(r,t,e){e||(e="(default)");const n=os(r,"firestore");if(n.isInitialized(e)){const i=n.getImmediate({identifier:e}),s=n.getOptions(e);if(Ye(s,t))return i;throw new D(P.FAILED_PRECONDITION,"initializeFirestore() has already been called with different options. To avoid this error, call initializeFirestore() with the same options as when it was originally called, or call getFirestore() to return the already initialized instance.")}if(t.cacheSizeBytes!==void 0&&t.localCache!==void 0)throw new D(P.INVALID_ARGUMENT,"cache and cacheSizeBytes cannot be specified at the same time as cacheSizeBytes willbe deprecated. Instead, specify the cache size in the cache object");if(t.cacheSizeBytes!==void 0&&t.cacheSizeBytes!==-1&&t.cacheSizeBytes<1048576)throw new D(P.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return n.initialize({options:t,instanceIdentifier:e})}function xy(r,t){const e=typeof r=="object"?r:Al(),n=typeof r=="string"?r:t||"(default)",i=os(e,"firestore").getImmediate({identifier:n});if(!i._initialized){const s=al("firestore");s&&Nd(i,...s)}return i}function ht(r){if(r._terminated)throw new D(P.FAILED_PRECONDITION,"The client has already been terminated.");return r._firestoreClient||Fd(r),r._firestoreClient}function Fd(r){var t,e,n;const i=r._freezeSettings(),s=function(u,c,h,f){return new ep(u,c,h,f.host,f.ssl,f.experimentalForceLongPolling,f.experimentalAutoDetectLongPolling,Cd(f.experimentalLongPollingOptions),f.useFetchStreams)}(r._databaseId,((t=r._app)===null||t===void 0?void 0:t.options.appId)||"",r._persistenceKey,i);r._componentsProvider||!((e=i.localCache)===null||e===void 0)&&e._offlineComponentProvider&&(!((n=i.localCache)===null||n===void 0)&&n._onlineComponentProvider)&&(r._componentsProvider={_offline:i.localCache._offlineComponentProvider,_online:i.localCache._onlineComponentProvider}),r._firestoreClient=new py(r._authCredentials,r._appCheckCredentials,r._queue,s,r._componentsProvider&&function(u){const c=u==null?void 0:u._online.build();return{_offline:u==null?void 0:u._offline.build(c),_online:c}}(r._componentsProvider))}function Ny(r,t){qt("enableIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");const e=r._freezeSettings();return Md(r,Se.provider,{build:n=>new va(n,e.cacheSizeBytes,t==null?void 0:t.forceOwnership)}),Promise.resolve()}async function ky(r){qt("enableMultiTabIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");const t=r._freezeSettings();Md(r,Se.provider,{build:e=>new Ad(e,t.cacheSizeBytes)})}function Md(r,t,e){if((r=Q(r,nt))._firestoreClient||r._terminated)throw new D(P.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.");if(r._componentsProvider||r._getSettings().localCache)throw new D(P.FAILED_PRECONDITION,"SDK cache is already specified.");r._componentsProvider={_online:t,_offline:e},Fd(r)}function Fy(r){if(r._initialized&&!r._terminated)throw new D(P.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");const t=new vt;return r._queue.enqueueAndForgetEvenWhileRestricted(async()=>{try{await async function(n){if(!Wt.D())return Promise.resolve();const i=n+"main";await Wt.delete(i)}(sa(r._databaseId,r._persistenceKey)),t.resolve()}catch(e){t.reject(e)}}),t.promise}function My(r){return function(e){const n=new vt;return e.asyncQueue.enqueueAndForget(async()=>ty(await Aa(e),n)),n.promise}(ht(r=Q(r,nt)))}function Oy(r){return _y(ht(r=Q(r,nt)))}function Ly(r){return yy(ht(r=Q(r,nt)))}function By(r){return Il(r.app,"firestore",r._databaseId.database),r._delete()}function Uy(r,t){const e=ht(r=Q(r,nt)),n=new kd;return wy(e,r._databaseId,t,n),n}function qy(r,t){return Ay(ht(r=Q(r,nt)),t).then(e=>e?new wt(r,null,e.query):null)}/**
2272
+ */const Cy=-1;class nt extends ri{constructor(t,e,n,i){super(t,e,n,i),this.type="firestore",this._queue=new tl,this._persistenceKey=(i==null?void 0:i.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const t=this._firestoreClient.terminate();this._queue=new tl(t),this._firestoreClient=void 0,await t}}}function Dy(r,t,e){e||(e="(default)");const n=os(r,"firestore");if(n.isInitialized(e)){const i=n.getImmediate({identifier:e}),s=n.getOptions(e);if(Xe(s,t))return i;throw new D(P.FAILED_PRECONDITION,"initializeFirestore() has already been called with different options. To avoid this error, call initializeFirestore() with the same options as when it was originally called, or call getFirestore() to return the already initialized instance.")}if(t.cacheSizeBytes!==void 0&&t.localCache!==void 0)throw new D(P.INVALID_ARGUMENT,"cache and cacheSizeBytes cannot be specified at the same time as cacheSizeBytes willbe deprecated. Instead, specify the cache size in the cache object");if(t.cacheSizeBytes!==void 0&&t.cacheSizeBytes!==-1&&t.cacheSizeBytes<1048576)throw new D(P.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return n.initialize({options:t,instanceIdentifier:e})}function xy(r,t){const e=typeof r=="object"?r:Al(),n=typeof r=="string"?r:t||"(default)",i=os(e,"firestore").getImmediate({identifier:n});if(!i._initialized){const s=al("firestore");s&&Nd(i,...s)}return i}function ht(r){if(r._terminated)throw new D(P.FAILED_PRECONDITION,"The client has already been terminated.");return r._firestoreClient||Fd(r),r._firestoreClient}function Fd(r){var t,e,n;const i=r._freezeSettings(),s=function(u,c,h,f){return new ep(u,c,h,f.host,f.ssl,f.experimentalForceLongPolling,f.experimentalAutoDetectLongPolling,Cd(f.experimentalLongPollingOptions),f.useFetchStreams)}(r._databaseId,((t=r._app)===null||t===void 0?void 0:t.options.appId)||"",r._persistenceKey,i);r._componentsProvider||!((e=i.localCache)===null||e===void 0)&&e._offlineComponentProvider&&(!((n=i.localCache)===null||n===void 0)&&n._onlineComponentProvider)&&(r._componentsProvider={_offline:i.localCache._offlineComponentProvider,_online:i.localCache._onlineComponentProvider}),r._firestoreClient=new py(r._authCredentials,r._appCheckCredentials,r._queue,s,r._componentsProvider&&function(u){const c=u==null?void 0:u._online.build();return{_offline:u==null?void 0:u._offline.build(c),_online:c}}(r._componentsProvider))}function Ny(r,t){qt("enableIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");const e=r._freezeSettings();return Md(r,Ve.provider,{build:n=>new va(n,e.cacheSizeBytes,t==null?void 0:t.forceOwnership)}),Promise.resolve()}async function ky(r){qt("enableMultiTabIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");const t=r._freezeSettings();Md(r,Ve.provider,{build:e=>new Ad(e,t.cacheSizeBytes)})}function Md(r,t,e){if((r=Q(r,nt))._firestoreClient||r._terminated)throw new D(P.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.");if(r._componentsProvider||r._getSettings().localCache)throw new D(P.FAILED_PRECONDITION,"SDK cache is already specified.");r._componentsProvider={_online:t,_offline:e},Fd(r)}function Fy(r){if(r._initialized&&!r._terminated)throw new D(P.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");const t=new vt;return r._queue.enqueueAndForgetEvenWhileRestricted(async()=>{try{await async function(n){if(!Wt.D())return Promise.resolve();const i=n+"main";await Wt.delete(i)}(sa(r._databaseId,r._persistenceKey)),t.resolve()}catch(e){t.reject(e)}}),t.promise}function My(r){return function(e){const n=new vt;return e.asyncQueue.enqueueAndForget(async()=>ty(await Aa(e),n)),n.promise}(ht(r=Q(r,nt)))}function Oy(r){return _y(ht(r=Q(r,nt)))}function Ly(r){return yy(ht(r=Q(r,nt)))}function By(r){return Il(r.app,"firestore",r._databaseId.database),r._delete()}function Uy(r,t){const e=ht(r=Q(r,nt)),n=new kd;return wy(e,r._databaseId,t,n),n}function qy(r,t){return Ay(ht(r=Q(r,nt)),t).then(e=>e?new wt(r,null,e.query):null)}/**
2273
2273
  * @license
2274
2274
  * Copyright 2020 Google LLC
2275
2275
  *
@@ -2299,7 +2299,7 @@ This typically indicates that your device does not have a healthy Internet conne
2299
2299
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2300
2300
  * See the License for the specific language governing permissions and
2301
2301
  * limitations under the License.
2302
- */class jn{constructor(t="count",e){this._internalFieldPath=e,this.type="AggregateField",this.aggregateType=t}}class Od{constructor(t,e,n){this._userDataWriter=e,this._data=n,this.type="AggregateQuerySnapshot",this.query=t}data(){return this._userDataWriter.convertObjectMap(this._data)}}/**
2302
+ */class Gn{constructor(t="count",e){this._internalFieldPath=e,this.type="AggregateField",this.aggregateType=t}}class Od{constructor(t,e,n){this._userDataWriter=e,this._data=n,this.type="AggregateQuerySnapshot",this.query=t}data(){return this._userDataWriter.convertObjectMap(this._data)}}/**
2303
2303
  * @license
2304
2304
  * Copyright 2020 Google LLC
2305
2305
  *
@@ -2314,7 +2314,7 @@ This typically indicates that your device does not have a healthy Internet conne
2314
2314
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2315
2315
  * See the License for the specific language governing permissions and
2316
2316
  * limitations under the License.
2317
- */class Ve{constructor(t){this._byteString=t}static fromBase64String(t){try{return new Ve(dt.fromBase64String(t))}catch(e){throw new D(P.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(t){return new Ve(dt.fromUint8Array(t))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(t){return this._byteString.isEqual(t._byteString)}}/**
2317
+ */class Ce{constructor(t){this._byteString=t}static fromBase64String(t){try{return new Ce(dt.fromBase64String(t))}catch(e){throw new D(P.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(t){return new Ce(dt.fromUint8Array(t))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(t){return this._byteString.isEqual(t._byteString)}}/**
2318
2318
  * @license
2319
2319
  * Copyright 2020 Google LLC
2320
2320
  *
@@ -2329,7 +2329,7 @@ This typically indicates that your device does not have a healthy Internet conne
2329
2329
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2330
2330
  * See the License for the specific language governing permissions and
2331
2331
  * limitations under the License.
2332
- */class ke{constructor(...t){for(let e=0;e<t.length;++e)if(t[e].length===0)throw new D(P.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new at(t)}isEqual(t){return this._internalPath.isEqual(t._internalPath)}}function zy(){return new ke("__name__")}/**
2332
+ */class Fe{constructor(...t){for(let e=0;e<t.length;++e)if(t[e].length===0)throw new D(P.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new at(t)}isEqual(t){return this._internalPath.isEqual(t._internalPath)}}function zy(){return new Fe("__name__")}/**
2333
2333
  * @license
2334
2334
  * Copyright 2020 Google LLC
2335
2335
  *
@@ -2344,7 +2344,7 @@ This typically indicates that your device does not have a healthy Internet conne
2344
2344
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2345
2345
  * See the License for the specific language governing permissions and
2346
2346
  * limitations under the License.
2347
- */class Fe{constructor(t){this._methodName=t}}/**
2347
+ */class Me{constructor(t){this._methodName=t}}/**
2348
2348
  * @license
2349
2349
  * Copyright 2017 Google LLC
2350
2350
  *
@@ -2389,7 +2389,7 @@ This typically indicates that your device does not have a healthy Internet conne
2389
2389
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2390
2390
  * See the License for the specific language governing permissions and
2391
2391
  * limitations under the License.
2392
- */const jy=/^__.*__$/;class Gy{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return this.fieldMask!==null?new oe(t,this.data,this.fieldMask,e,this.fieldTransforms):new $n(t,this.data,e,this.fieldTransforms)}}class Ld{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return new oe(t,this.data,this.fieldMask,e,this.fieldTransforms)}}function Bd(r){switch(r){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw O()}}class ws{constructor(t,e,n,i,s,a){this.settings=t,this.databaseId=e,this.serializer=n,this.ignoreUndefinedProperties=i,s===void 0&&this.vu(),this.fieldTransforms=s||[],this.fieldMask=a||[]}get path(){return this.settings.path}get Cu(){return this.settings.Cu}Fu(t){return new ws(Object.assign(Object.assign({},this.settings),t),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}Mu(t){var e;const n=(e=this.path)===null||e===void 0?void 0:e.child(t),i=this.Fu({path:n,xu:!1});return i.Ou(t),i}Nu(t){var e;const n=(e=this.path)===null||e===void 0?void 0:e.child(t),i=this.Fu({path:n,xu:!1});return i.vu(),i}Lu(t){return this.Fu({path:void 0,xu:!0})}Bu(t){return ss(t,this.settings.methodName,this.settings.ku||!1,this.path,this.settings.qu)}contains(t){return this.fieldMask.find(e=>t.isPrefixOf(e))!==void 0||this.fieldTransforms.find(e=>t.isPrefixOf(e.field))!==void 0}vu(){if(this.path)for(let t=0;t<this.path.length;t++)this.Ou(this.path.get(t))}Ou(t){if(t.length===0)throw this.Bu("Document fields must not be empty");if(Bd(this.Cu)&&jy.test(t))throw this.Bu('Document fields cannot begin and end with "__"')}}class Ky{constructor(t,e,n){this.databaseId=t,this.ignoreUndefinedProperties=e,this.serializer=n||ei(t)}Qu(t,e,n,i=!1){return new ws({Cu:t,methodName:e,qu:n,path:at.emptyPath(),xu:!1,ku:i},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function cn(r){const t=r._freezeSettings(),e=ei(r._databaseId);return new Ky(r._databaseId,!!t.ignoreUndefinedProperties,e)}function As(r,t,e,n,i,s={}){const a=r.Qu(s.merge||s.mergeFields?2:0,t,e,i);ka("Data must be an object, but it was:",a,n);const u=zd(n,a);let c,h;if(s.merge)c=new Lt(a.fieldMask),h=a.fieldTransforms;else if(s.mergeFields){const f=[];for(const g of s.mergeFields){const _=Kr(t,g,e);if(!a.contains(_))throw new D(P.INVALID_ARGUMENT,`Field '${_}' is specified in your field mask but missing from your input data.`);Gd(f,_)||f.push(_)}c=new Lt(f),h=a.fieldTransforms.filter(g=>c.covers(g.field))}else c=null,h=a.fieldTransforms;return new Gy(new bt(u),c,h)}class oi extends Fe{_toFieldTransform(t){if(t.Cu!==2)throw t.Cu===1?t.Bu(`${this._methodName}() can only appear at the top level of your update data`):t.Bu(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return t.fieldMask.push(t.path),null}isEqual(t){return t instanceof oi}}function Ud(r,t,e){return new ws({Cu:3,qu:t.settings.qu,methodName:r._methodName,xu:e},t.databaseId,t.serializer,t.ignoreUndefinedProperties)}class Sa extends Fe{_toFieldTransform(t){return new Xr(t.path,new kn)}isEqual(t){return t instanceof Sa}}class Va extends Fe{constructor(t,e){super(t),this.Ku=e}_toFieldTransform(t){const e=Ud(this,t,!0),n=this.Ku.map(s=>ln(s,e)),i=new tn(n);return new Xr(t.path,i)}isEqual(t){return t instanceof Va&&Ye(this.Ku,t.Ku)}}class Ca extends Fe{constructor(t,e){super(t),this.Ku=e}_toFieldTransform(t){const e=Ud(this,t,!0),n=this.Ku.map(s=>ln(s,e)),i=new en(n);return new Xr(t.path,i)}isEqual(t){return t instanceof Ca&&Ye(this.Ku,t.Ku)}}class Da extends Fe{constructor(t,e){super(t),this.$u=e}_toFieldTransform(t){const e=new Fn(t.serializer,_h(t.serializer,this.$u));return new Xr(t.path,e)}isEqual(t){return t instanceof Da&&this.$u===t.$u}}function xa(r,t,e,n){const i=r.Qu(1,t,e);ka("Data must be an object, but it was:",i,n);const s=[],a=bt.empty();xe(n,(c,h)=>{const f=Rs(t,c,e);h=yt(h);const g=i.Nu(f);if(h instanceof oi)s.push(f);else{const _=ln(h,g);_!=null&&(s.push(f),a.set(f,_))}});const u=new Lt(s);return new Ld(a,u,i.fieldTransforms)}function Na(r,t,e,n,i,s){const a=r.Qu(1,t,e),u=[Kr(t,n,e)],c=[i];if(s.length%2!=0)throw new D(P.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let _=0;_<s.length;_+=2)u.push(Kr(t,s[_])),c.push(s[_+1]);const h=[],f=bt.empty();for(let _=u.length-1;_>=0;--_)if(!Gd(h,u[_])){const R=u[_];let C=c[_];C=yt(C);const N=a.Nu(R);if(C instanceof oi)h.push(R);else{const V=ln(C,N);V!=null&&(h.push(R),f.set(R,V))}}const g=new Lt(h);return new Ld(f,g,a.fieldTransforms)}function qd(r,t,e,n=!1){return ln(e,r.Qu(n?4:3,t))}function ln(r,t){if(jd(r=yt(r)))return ka("Unsupported field value:",t,r),zd(r,t);if(r instanceof Fe)return function(n,i){if(!Bd(i.Cu))throw i.Bu(`${n._methodName}() can only be used with update() and set()`);if(!i.path)throw i.Bu(`${n._methodName}() is not currently supported inside arrays`);const s=n._toFieldTransform(i);s&&i.fieldTransforms.push(s)}(r,t),null;if(r===void 0&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),r instanceof Array){if(t.settings.xu&&t.Cu!==4)throw t.Bu("Nested arrays are not supported");return function(n,i){const s=[];let a=0;for(const u of n){let c=ln(u,i.Lu(a));c==null&&(c={nullValue:"NULL_VALUE"}),s.push(c),a++}return{arrayValue:{values:s}}}(r,t)}return function(n,i){if((n=yt(n))===null)return{nullValue:"NULL_VALUE"};if(typeof n=="number")return _h(i.serializer,n);if(typeof n=="boolean")return{booleanValue:n};if(typeof n=="string")return{stringValue:n};if(n instanceof Date){const s=lt.fromDate(n);return{timestampValue:Mn(i.serializer,s)}}if(n instanceof lt){const s=new lt(n.seconds,1e3*Math.floor(n.nanoseconds/1e3));return{timestampValue:Mn(i.serializer,s)}}if(n instanceof vs)return{geoPointValue:{latitude:n.latitude,longitude:n.longitude}};if(n instanceof Ve)return{bytesValue:Ch(i.serializer,n._byteString)};if(n instanceof mt){const s=i.databaseId,a=n.firestore._databaseId;if(!a.isEqual(s))throw i.Bu(`Document reference is for database ${a.projectId}/${a.database} but should be for database ${s.projectId}/${s.database}`);return{referenceValue:Xo(n.firestore._databaseId||i.databaseId,n._key.path)}}if(n instanceof si)return function(a,u){return{mapValue:{fields:{__type__:{stringValue:"__vector__"},value:{arrayValue:{values:a.toArray().map(c=>{if(typeof c!="number")throw u.Bu("VectorValues must only contain numeric values.");return $o(u.serializer,c)})}}}}}}(n,i);throw i.Bu(`Unsupported field value: ${Ts(n)}`)}(r,t)}function zd(r,t){const e={};return Hl(r)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):xe(r,(n,i)=>{const s=ln(i,t.Mu(n));s!=null&&(e[n]=s)}),{mapValue:{fields:e}}}function jd(r){return!(typeof r!="object"||r===null||r instanceof Array||r instanceof Date||r instanceof lt||r instanceof vs||r instanceof Ve||r instanceof mt||r instanceof Fe||r instanceof si)}function ka(r,t,e){if(!jd(e)||!function(i){return typeof i=="object"&&i!==null&&(Object.getPrototypeOf(i)===Object.prototype||Object.getPrototypeOf(i)===null)}(e)){const n=Ts(e);throw n==="an object"?t.Bu(r+" a custom object"):t.Bu(r+" "+n)}}function Kr(r,t,e){if((t=yt(t))instanceof ke)return t._internalPath;if(typeof t=="string")return Rs(r,t);throw ss("Field path arguments must be of type string or ",r,!1,void 0,e)}const $y=new RegExp("[~\\*/\\[\\]]");function Rs(r,t,e){if(t.search($y)>=0)throw ss(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,r,!1,void 0,e);try{return new ke(...t.split("."))._internalPath}catch{throw ss(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,r,!1,void 0,e)}}function ss(r,t,e,n,i){const s=n&&!n.isEmpty(),a=i!==void 0;let u=`Function ${t}() called with invalid data`;e&&(u+=" (via `toFirestore()`)"),u+=". ";let c="";return(s||a)&&(c+=" (found",s&&(c+=` in field ${n}`),a&&(c+=` in document ${i}`),c+=")"),new D(P.INVALID_ARGUMENT,u+r+c)}function Gd(r,t){return r.some(e=>e.isEqual(t))}/**
2392
+ */const jy=/^__.*__$/;class Gy{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return this.fieldMask!==null?new oe(t,this.data,this.fieldMask,e,this.fieldTransforms):new Qn(t,this.data,e,this.fieldTransforms)}}class Ld{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return new oe(t,this.data,this.fieldMask,e,this.fieldTransforms)}}function Bd(r){switch(r){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw O()}}class ws{constructor(t,e,n,i,s,a){this.settings=t,this.databaseId=e,this.serializer=n,this.ignoreUndefinedProperties=i,s===void 0&&this.vu(),this.fieldTransforms=s||[],this.fieldMask=a||[]}get path(){return this.settings.path}get Cu(){return this.settings.Cu}Fu(t){return new ws(Object.assign(Object.assign({},this.settings),t),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}Mu(t){var e;const n=(e=this.path)===null||e===void 0?void 0:e.child(t),i=this.Fu({path:n,xu:!1});return i.Ou(t),i}Nu(t){var e;const n=(e=this.path)===null||e===void 0?void 0:e.child(t),i=this.Fu({path:n,xu:!1});return i.vu(),i}Lu(t){return this.Fu({path:void 0,xu:!0})}Bu(t){return ss(t,this.settings.methodName,this.settings.ku||!1,this.path,this.settings.qu)}contains(t){return this.fieldMask.find(e=>t.isPrefixOf(e))!==void 0||this.fieldTransforms.find(e=>t.isPrefixOf(e.field))!==void 0}vu(){if(this.path)for(let t=0;t<this.path.length;t++)this.Ou(this.path.get(t))}Ou(t){if(t.length===0)throw this.Bu("Document fields must not be empty");if(Bd(this.Cu)&&jy.test(t))throw this.Bu('Document fields cannot begin and end with "__"')}}class Ky{constructor(t,e,n){this.databaseId=t,this.ignoreUndefinedProperties=e,this.serializer=n||ei(t)}Qu(t,e,n,i=!1){return new ws({Cu:t,methodName:e,qu:n,path:at.emptyPath(),xu:!1,ku:i},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function ln(r){const t=r._freezeSettings(),e=ei(r._databaseId);return new Ky(r._databaseId,!!t.ignoreUndefinedProperties,e)}function As(r,t,e,n,i,s={}){const a=r.Qu(s.merge||s.mergeFields?2:0,t,e,i);ka("Data must be an object, but it was:",a,n);const u=zd(n,a);let c,h;if(s.merge)c=new Lt(a.fieldMask),h=a.fieldTransforms;else if(s.mergeFields){const f=[];for(const g of s.mergeFields){const _=$r(t,g,e);if(!a.contains(_))throw new D(P.INVALID_ARGUMENT,`Field '${_}' is specified in your field mask but missing from your input data.`);Gd(f,_)||f.push(_)}c=new Lt(f),h=a.fieldTransforms.filter(g=>c.covers(g.field))}else c=null,h=a.fieldTransforms;return new Gy(new bt(u),c,h)}class oi extends Me{_toFieldTransform(t){if(t.Cu!==2)throw t.Cu===1?t.Bu(`${this._methodName}() can only appear at the top level of your update data`):t.Bu(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return t.fieldMask.push(t.path),null}isEqual(t){return t instanceof oi}}function Ud(r,t,e){return new ws({Cu:3,qu:t.settings.qu,methodName:r._methodName,xu:e},t.databaseId,t.serializer,t.ignoreUndefinedProperties)}class Sa extends Me{_toFieldTransform(t){return new Xr(t.path,new Fn)}isEqual(t){return t instanceof Sa}}class Va extends Me{constructor(t,e){super(t),this.Ku=e}_toFieldTransform(t){const e=Ud(this,t,!0),n=this.Ku.map(s=>hn(s,e)),i=new en(n);return new Xr(t.path,i)}isEqual(t){return t instanceof Va&&Xe(this.Ku,t.Ku)}}class Ca extends Me{constructor(t,e){super(t),this.Ku=e}_toFieldTransform(t){const e=Ud(this,t,!0),n=this.Ku.map(s=>hn(s,e)),i=new nn(n);return new Xr(t.path,i)}isEqual(t){return t instanceof Ca&&Xe(this.Ku,t.Ku)}}class Da extends Me{constructor(t,e){super(t),this.$u=e}_toFieldTransform(t){const e=new Mn(t.serializer,_h(t.serializer,this.$u));return new Xr(t.path,e)}isEqual(t){return t instanceof Da&&this.$u===t.$u}}function xa(r,t,e,n){const i=r.Qu(1,t,e);ka("Data must be an object, but it was:",i,n);const s=[],a=bt.empty();Ne(n,(c,h)=>{const f=Rs(t,c,e);h=yt(h);const g=i.Nu(f);if(h instanceof oi)s.push(f);else{const _=hn(h,g);_!=null&&(s.push(f),a.set(f,_))}});const u=new Lt(s);return new Ld(a,u,i.fieldTransforms)}function Na(r,t,e,n,i,s){const a=r.Qu(1,t,e),u=[$r(t,n,e)],c=[i];if(s.length%2!=0)throw new D(P.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let _=0;_<s.length;_+=2)u.push($r(t,s[_])),c.push(s[_+1]);const h=[],f=bt.empty();for(let _=u.length-1;_>=0;--_)if(!Gd(h,u[_])){const R=u[_];let C=c[_];C=yt(C);const N=a.Nu(R);if(C instanceof oi)h.push(R);else{const V=hn(C,N);V!=null&&(h.push(R),f.set(R,V))}}const g=new Lt(h);return new Ld(f,g,a.fieldTransforms)}function qd(r,t,e,n=!1){return hn(e,r.Qu(n?4:3,t))}function hn(r,t){if(jd(r=yt(r)))return ka("Unsupported field value:",t,r),zd(r,t);if(r instanceof Me)return function(n,i){if(!Bd(i.Cu))throw i.Bu(`${n._methodName}() can only be used with update() and set()`);if(!i.path)throw i.Bu(`${n._methodName}() is not currently supported inside arrays`);const s=n._toFieldTransform(i);s&&i.fieldTransforms.push(s)}(r,t),null;if(r===void 0&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),r instanceof Array){if(t.settings.xu&&t.Cu!==4)throw t.Bu("Nested arrays are not supported");return function(n,i){const s=[];let a=0;for(const u of n){let c=hn(u,i.Lu(a));c==null&&(c={nullValue:"NULL_VALUE"}),s.push(c),a++}return{arrayValue:{values:s}}}(r,t)}return function(n,i){if((n=yt(n))===null)return{nullValue:"NULL_VALUE"};if(typeof n=="number")return _h(i.serializer,n);if(typeof n=="boolean")return{booleanValue:n};if(typeof n=="string")return{stringValue:n};if(n instanceof Date){const s=lt.fromDate(n);return{timestampValue:On(i.serializer,s)}}if(n instanceof lt){const s=new lt(n.seconds,1e3*Math.floor(n.nanoseconds/1e3));return{timestampValue:On(i.serializer,s)}}if(n instanceof vs)return{geoPointValue:{latitude:n.latitude,longitude:n.longitude}};if(n instanceof Ce)return{bytesValue:Ch(i.serializer,n._byteString)};if(n instanceof mt){const s=i.databaseId,a=n.firestore._databaseId;if(!a.isEqual(s))throw i.Bu(`Document reference is for database ${a.projectId}/${a.database} but should be for database ${s.projectId}/${s.database}`);return{referenceValue:Xo(n.firestore._databaseId||i.databaseId,n._key.path)}}if(n instanceof si)return function(a,u){return{mapValue:{fields:{__type__:{stringValue:"__vector__"},value:{arrayValue:{values:a.toArray().map(c=>{if(typeof c!="number")throw u.Bu("VectorValues must only contain numeric values.");return $o(u.serializer,c)})}}}}}}(n,i);throw i.Bu(`Unsupported field value: ${Ts(n)}`)}(r,t)}function zd(r,t){const e={};return Hl(r)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):Ne(r,(n,i)=>{const s=hn(i,t.Mu(n));s!=null&&(e[n]=s)}),{mapValue:{fields:e}}}function jd(r){return!(typeof r!="object"||r===null||r instanceof Array||r instanceof Date||r instanceof lt||r instanceof vs||r instanceof Ce||r instanceof mt||r instanceof Me||r instanceof si)}function ka(r,t,e){if(!jd(e)||!function(i){return typeof i=="object"&&i!==null&&(Object.getPrototypeOf(i)===Object.prototype||Object.getPrototypeOf(i)===null)}(e)){const n=Ts(e);throw n==="an object"?t.Bu(r+" a custom object"):t.Bu(r+" "+n)}}function $r(r,t,e){if((t=yt(t))instanceof Fe)return t._internalPath;if(typeof t=="string")return Rs(r,t);throw ss("Field path arguments must be of type string or ",r,!1,void 0,e)}const $y=new RegExp("[~\\*/\\[\\]]");function Rs(r,t,e){if(t.search($y)>=0)throw ss(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,r,!1,void 0,e);try{return new Fe(...t.split("."))._internalPath}catch{throw ss(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,r,!1,void 0,e)}}function ss(r,t,e,n,i){const s=n&&!n.isEmpty(),a=i!==void 0;let u=`Function ${t}() called with invalid data`;e&&(u+=" (via `toFirestore()`)"),u+=". ";let c="";return(s||a)&&(c+=" (found",s&&(c+=` in field ${n}`),a&&(c+=` in document ${i}`),c+=")"),new D(P.INVALID_ARGUMENT,u+r+c)}function Gd(r,t){return r.some(e=>e.isEqual(t))}/**
2393
2393
  * @license
2394
2394
  * Copyright 2020 Google LLC
2395
2395
  *
@@ -2404,7 +2404,7 @@ This typically indicates that your device does not have a healthy Internet conne
2404
2404
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2405
2405
  * See the License for the specific language governing permissions and
2406
2406
  * limitations under the License.
2407
- */class $r{constructor(t,e,n,i,s){this._firestore=t,this._userDataWriter=e,this._key=n,this._document=i,this._converter=s}get id(){return this._key.path.lastSegment()}get ref(){return new mt(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const t=new Qy(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.value)}}get(t){if(this._document){const e=this._document.data.field(bs("DocumentSnapshot.get",t));if(e!==null)return this._userDataWriter.convertValue(e)}}}class Qy extends $r{data(){return super.data()}}function bs(r,t){return typeof t=="string"?Rs(r,t):t instanceof ke?t._internalPath:t._delegate._internalPath}/**
2407
+ */class Qr{constructor(t,e,n,i,s){this._firestore=t,this._userDataWriter=e,this._key=n,this._document=i,this._converter=s}get id(){return this._key.path.lastSegment()}get ref(){return new mt(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const t=new Qy(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.value)}}get(t){if(this._document){const e=this._document.data.field(bs("DocumentSnapshot.get",t));if(e!==null)return this._userDataWriter.convertValue(e)}}}class Qy extends Qr{data(){return super.data()}}function bs(r,t){return typeof t=="string"?Rs(r,t):t instanceof Fe?t._internalPath:t._delegate._internalPath}/**
2408
2408
  * @license
2409
2409
  * Copyright 2020 Google LLC
2410
2410
  *
@@ -2419,7 +2419,7 @@ This typically indicates that your device does not have a healthy Internet conne
2419
2419
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2420
2420
  * See the License for the specific language governing permissions and
2421
2421
  * limitations under the License.
2422
- */function Kd(r){if(r.limitType==="L"&&r.explicitOrderBy.length===0)throw new D(P.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Fa{}class Zn extends Fa{}function Wy(r,t,...e){let n=[];t instanceof Fa&&n.push(t),n=n.concat(e),function(s){const a=s.filter(c=>c instanceof hn).length,u=s.filter(c=>c instanceof tr).length;if(a>1||a>0&&u>0)throw new D(P.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}(n);for(const i of n)r=i._apply(r);return r}class tr extends Zn{constructor(t,e,n){super(),this._field=t,this._op=e,this._value=n,this.type="where"}static _create(t,e,n){return new tr(t,e,n)}_apply(t){const e=this._parse(t);return Qd(t._query,e),new wt(t.firestore,t.converter,vo(t._query,e))}_parse(t){const e=cn(t.firestore);return function(s,a,u,c,h,f,g){let _;if(h.isKeyField()){if(f==="array-contains"||f==="array-contains-any")throw new D(P.INVALID_ARGUMENT,`Invalid Query. You can't perform '${f}' queries on documentId().`);if(f==="in"||f==="not-in"){nl(g,f);const R=[];for(const C of g)R.push(el(c,s,C));_={arrayValue:{values:R}}}else _=el(c,s,g)}else f!=="in"&&f!=="not-in"&&f!=="array-contains-any"||nl(g,f),_=qd(u,a,g,f==="in"||f==="not-in");return H.create(h,f,_)}(t._query,"where",e,t.firestore._databaseId,this._field,this._op,this._value)}}function Hy(r,t,e){const n=t,i=bs("where",r);return tr._create(i,n,e)}class hn extends Fa{constructor(t,e){super(),this.type=t,this._queryConstraints=e}static _create(t,e){return new hn(t,e)}_parse(t){const e=this._queryConstraints.map(n=>n._parse(t)).filter(n=>n.getFilters().length>0);return e.length===1?e[0]:tt.create(e,this._getOperator())}_apply(t){const e=this._parse(t);return e.getFilters().length===0?t:(function(i,s){let a=i;const u=s.getFlattenedFilters();for(const c of u)Qd(a,c),a=vo(a,c)}(t._query,e),new wt(t.firestore,t.converter,vo(t._query,e)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}function Jy(...r){return r.forEach(t=>Wd("or",t)),hn._create("or",r)}function Yy(...r){return r.forEach(t=>Wd("and",t)),hn._create("and",r)}class Ps extends Zn{constructor(t,e){super(),this._field=t,this._direction=e,this.type="orderBy"}static _create(t,e){return new Ps(t,e)}_apply(t){const e=function(i,s,a){if(i.startAt!==null)throw new D(P.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(i.endAt!==null)throw new D(P.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new zr(s,a)}(t._query,this._field,this._direction);return new wt(t.firestore,t.converter,function(i,s){const a=i.explicitOrderBy.concat([s]);return new ie(i.path,i.collectionGroup,a,i.filters.slice(),i.limit,i.limitType,i.startAt,i.endAt)}(t._query,e))}}function Xy(r,t="asc"){const e=t,n=bs("orderBy",r);return Ps._create(n,e)}class ai extends Zn{constructor(t,e,n){super(),this.type=t,this._limit=e,this._limitType=n}static _create(t,e,n){return new ai(t,e,n)}_apply(t){return new wt(t.firestore,t.converter,Hi(t._query,this._limit,this._limitType))}}function Zy(r){return xd("limit",r),ai._create("limit",r,"F")}function tI(r){return xd("limitToLast",r),ai._create("limitToLast",r,"L")}class ui extends Zn{constructor(t,e,n){super(),this.type=t,this._docOrFields=e,this._inclusive=n}static _create(t,e,n){return new ui(t,e,n)}_apply(t){const e=$d(t,this.type,this._docOrFields,this._inclusive);return new wt(t.firestore,t.converter,function(i,s){return new ie(i.path,i.collectionGroup,i.explicitOrderBy.slice(),i.filters.slice(),i.limit,i.limitType,s,i.endAt)}(t._query,e))}}function eI(...r){return ui._create("startAt",r,!0)}function nI(...r){return ui._create("startAfter",r,!1)}class ci extends Zn{constructor(t,e,n){super(),this.type=t,this._docOrFields=e,this._inclusive=n}static _create(t,e,n){return new ci(t,e,n)}_apply(t){const e=$d(t,this.type,this._docOrFields,this._inclusive);return new wt(t.firestore,t.converter,function(i,s){return new ie(i.path,i.collectionGroup,i.explicitOrderBy.slice(),i.filters.slice(),i.limit,i.limitType,i.startAt,s)}(t._query,e))}}function rI(...r){return ci._create("endBefore",r,!1)}function iI(...r){return ci._create("endAt",r,!0)}function $d(r,t,e,n){if(e[0]=yt(e[0]),e[0]instanceof $r)return function(s,a,u,c,h){if(!c)throw new D(P.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${u}().`);const f=[];for(const g of An(s))if(g.field.isKeyField())f.push(Xe(a,c.key));else{const _=c.data.field(g.field);if(us(_))throw new D(P.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+g.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(_===null){const R=g.field.canonicalString();throw new D(P.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field '${R}' (used as the orderBy) does not exist.`)}f.push(_)}return new Re(f,h)}(r._query,r.firestore._databaseId,t,e[0]._document,n);{const i=cn(r.firestore);return function(a,u,c,h,f,g){const _=a.explicitOrderBy;if(f.length>_.length)throw new D(P.INVALID_ARGUMENT,`Too many arguments provided to ${h}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);const R=[];for(let C=0;C<f.length;C++){const N=f[C];if(_[C].field.isKeyField()){if(typeof N!="string")throw new D(P.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${h}(), but got a ${typeof N}`);if(!Go(a)&&N.indexOf("/")!==-1)throw new D(P.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${h}() must be a plain document ID, but '${N}' contains a slash.`);const V=a.path.child(W.fromString(N));if(!M.isDocumentKey(V))throw new D(P.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${h}() must result in a valid document path, but '${V}' is not because it contains an odd number of segments.`);const q=new M(V);R.push(Xe(u,q))}else{const V=qd(c,h,N);R.push(V)}}return new Re(R,g)}(r._query,r.firestore._databaseId,i,t,e,n)}}function el(r,t,e){if(typeof(e=yt(e))=="string"){if(e==="")throw new D(P.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Go(t)&&e.indexOf("/")!==-1)throw new D(P.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${e}' contains a '/' character.`);const n=t.path.child(W.fromString(e));if(!M.isDocumentKey(n))throw new D(P.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${n}' is not because it has an odd number of segments (${n.length}).`);return Xe(r,new M(n))}if(e instanceof mt)return Xe(r,e._key);throw new D(P.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Ts(e)}.`)}function nl(r,t){if(!Array.isArray(r)||r.length===0)throw new D(P.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function Qd(r,t){const e=function(i,s){for(const a of i)for(const u of a.getFlattenedFilters())if(s.indexOf(u.op)>=0)return u.op;return null}(r.filters,function(i){switch(i){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}}(t.op));if(e!==null)throw e===t.op?new D(P.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new D(P.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${e.toString()}' filters.`)}function Wd(r,t){if(!(t instanceof tr||t instanceof hn))throw new D(P.INVALID_ARGUMENT,`Function ${r}() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.`)}class Ma{convertValue(t,e="none"){switch(we(t)){case 0:return null;case 1:return t.booleanValue;case 2:return ut(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(re(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 11:return this.convertObject(t.mapValue,e);case 10:return this.convertVectorValue(t.mapValue);default:throw O()}}convertObject(t,e){return this.convertObjectMap(t.fields,e)}convertObjectMap(t,e="none"){const n={};return xe(t,(i,s)=>{n[i]=this.convertValue(s,e)}),n}convertVectorValue(t){var e,n,i;const s=(i=(n=(e=t.fields)===null||e===void 0?void 0:e.value.arrayValue)===null||n===void 0?void 0:n.values)===null||i===void 0?void 0:i.map(a=>ut(a.doubleValue));return new si(s)}convertGeoPoint(t){return new vs(ut(t.latitude),ut(t.longitude))}convertArray(t,e){return(t.values||[]).map(n=>this.convertValue(n,e))}convertServerTimestamp(t,e){switch(e){case"previous":const n=cs(t);return n==null?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(Br(t));default:return null}}convertTimestamp(t){const e=ne(t);return new lt(e.seconds,e.nanos)}convertDocumentKey(t,e){const n=W.fromString(t);L(qh(n));const i=new ve(n.get(1),n.get(3)),s=new M(n.popFirst(5));return i.isEqual(e)||gt(`Document ${s} 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 (${e.projectId}/${e.database}) instead.`),s}}/**
2422
+ */function Kd(r){if(r.limitType==="L"&&r.explicitOrderBy.length===0)throw new D(P.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Fa{}class tr extends Fa{}function Wy(r,t,...e){let n=[];t instanceof Fa&&n.push(t),n=n.concat(e),function(s){const a=s.filter(c=>c instanceof dn).length,u=s.filter(c=>c instanceof er).length;if(a>1||a>0&&u>0)throw new D(P.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}(n);for(const i of n)r=i._apply(r);return r}class er extends tr{constructor(t,e,n){super(),this._field=t,this._op=e,this._value=n,this.type="where"}static _create(t,e,n){return new er(t,e,n)}_apply(t){const e=this._parse(t);return Qd(t._query,e),new wt(t.firestore,t.converter,vo(t._query,e))}_parse(t){const e=ln(t.firestore);return function(s,a,u,c,h,f,g){let _;if(h.isKeyField()){if(f==="array-contains"||f==="array-contains-any")throw new D(P.INVALID_ARGUMENT,`Invalid Query. You can't perform '${f}' queries on documentId().`);if(f==="in"||f==="not-in"){nl(g,f);const R=[];for(const C of g)R.push(el(c,s,C));_={arrayValue:{values:R}}}else _=el(c,s,g)}else f!=="in"&&f!=="not-in"&&f!=="array-contains-any"||nl(g,f),_=qd(u,a,g,f==="in"||f==="not-in");return H.create(h,f,_)}(t._query,"where",e,t.firestore._databaseId,this._field,this._op,this._value)}}function Hy(r,t,e){const n=t,i=bs("where",r);return er._create(i,n,e)}class dn extends Fa{constructor(t,e){super(),this.type=t,this._queryConstraints=e}static _create(t,e){return new dn(t,e)}_parse(t){const e=this._queryConstraints.map(n=>n._parse(t)).filter(n=>n.getFilters().length>0);return e.length===1?e[0]:tt.create(e,this._getOperator())}_apply(t){const e=this._parse(t);return e.getFilters().length===0?t:(function(i,s){let a=i;const u=s.getFlattenedFilters();for(const c of u)Qd(a,c),a=vo(a,c)}(t._query,e),new wt(t.firestore,t.converter,vo(t._query,e)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}function Jy(...r){return r.forEach(t=>Wd("or",t)),dn._create("or",r)}function Yy(...r){return r.forEach(t=>Wd("and",t)),dn._create("and",r)}class Ps extends tr{constructor(t,e){super(),this._field=t,this._direction=e,this.type="orderBy"}static _create(t,e){return new Ps(t,e)}_apply(t){const e=function(i,s,a){if(i.startAt!==null)throw new D(P.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(i.endAt!==null)throw new D(P.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new jr(s,a)}(t._query,this._field,this._direction);return new wt(t.firestore,t.converter,function(i,s){const a=i.explicitOrderBy.concat([s]);return new ie(i.path,i.collectionGroup,a,i.filters.slice(),i.limit,i.limitType,i.startAt,i.endAt)}(t._query,e))}}function Xy(r,t="asc"){const e=t,n=bs("orderBy",r);return Ps._create(n,e)}class ai extends tr{constructor(t,e,n){super(),this.type=t,this._limit=e,this._limitType=n}static _create(t,e,n){return new ai(t,e,n)}_apply(t){return new wt(t.firestore,t.converter,Hi(t._query,this._limit,this._limitType))}}function Zy(r){return xd("limit",r),ai._create("limit",r,"F")}function tI(r){return xd("limitToLast",r),ai._create("limitToLast",r,"L")}class ui extends tr{constructor(t,e,n){super(),this.type=t,this._docOrFields=e,this._inclusive=n}static _create(t,e,n){return new ui(t,e,n)}_apply(t){const e=$d(t,this.type,this._docOrFields,this._inclusive);return new wt(t.firestore,t.converter,function(i,s){return new ie(i.path,i.collectionGroup,i.explicitOrderBy.slice(),i.filters.slice(),i.limit,i.limitType,s,i.endAt)}(t._query,e))}}function eI(...r){return ui._create("startAt",r,!0)}function nI(...r){return ui._create("startAfter",r,!1)}class ci extends tr{constructor(t,e,n){super(),this.type=t,this._docOrFields=e,this._inclusive=n}static _create(t,e,n){return new ci(t,e,n)}_apply(t){const e=$d(t,this.type,this._docOrFields,this._inclusive);return new wt(t.firestore,t.converter,function(i,s){return new ie(i.path,i.collectionGroup,i.explicitOrderBy.slice(),i.filters.slice(),i.limit,i.limitType,i.startAt,s)}(t._query,e))}}function rI(...r){return ci._create("endBefore",r,!1)}function iI(...r){return ci._create("endAt",r,!0)}function $d(r,t,e,n){if(e[0]=yt(e[0]),e[0]instanceof Qr)return function(s,a,u,c,h){if(!c)throw new D(P.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${u}().`);const f=[];for(const g of Rn(s))if(g.field.isKeyField())f.push(Ze(a,c.key));else{const _=c.data.field(g.field);if(us(_))throw new D(P.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+g.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(_===null){const R=g.field.canonicalString();throw new D(P.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field '${R}' (used as the orderBy) does not exist.`)}f.push(_)}return new be(f,h)}(r._query,r.firestore._databaseId,t,e[0]._document,n);{const i=ln(r.firestore);return function(a,u,c,h,f,g){const _=a.explicitOrderBy;if(f.length>_.length)throw new D(P.INVALID_ARGUMENT,`Too many arguments provided to ${h}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);const R=[];for(let C=0;C<f.length;C++){const N=f[C];if(_[C].field.isKeyField()){if(typeof N!="string")throw new D(P.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${h}(), but got a ${typeof N}`);if(!Go(a)&&N.indexOf("/")!==-1)throw new D(P.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${h}() must be a plain document ID, but '${N}' contains a slash.`);const V=a.path.child(W.fromString(N));if(!M.isDocumentKey(V))throw new D(P.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${h}() must result in a valid document path, but '${V}' is not because it contains an odd number of segments.`);const q=new M(V);R.push(Ze(u,q))}else{const V=qd(c,h,N);R.push(V)}}return new be(R,g)}(r._query,r.firestore._databaseId,i,t,e,n)}}function el(r,t,e){if(typeof(e=yt(e))=="string"){if(e==="")throw new D(P.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Go(t)&&e.indexOf("/")!==-1)throw new D(P.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${e}' contains a '/' character.`);const n=t.path.child(W.fromString(e));if(!M.isDocumentKey(n))throw new D(P.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${n}' is not because it has an odd number of segments (${n.length}).`);return Ze(r,new M(n))}if(e instanceof mt)return Ze(r,e._key);throw new D(P.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Ts(e)}.`)}function nl(r,t){if(!Array.isArray(r)||r.length===0)throw new D(P.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function Qd(r,t){const e=function(i,s){for(const a of i)for(const u of a.getFlattenedFilters())if(s.indexOf(u.op)>=0)return u.op;return null}(r.filters,function(i){switch(i){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}}(t.op));if(e!==null)throw e===t.op?new D(P.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new D(P.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${e.toString()}' filters.`)}function Wd(r,t){if(!(t instanceof er||t instanceof dn))throw new D(P.INVALID_ARGUMENT,`Function ${r}() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.`)}class Ma{convertValue(t,e="none"){switch(Ae(t)){case 0:return null;case 1:return t.booleanValue;case 2:return ut(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(re(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 11:return this.convertObject(t.mapValue,e);case 10:return this.convertVectorValue(t.mapValue);default:throw O()}}convertObject(t,e){return this.convertObjectMap(t.fields,e)}convertObjectMap(t,e="none"){const n={};return Ne(t,(i,s)=>{n[i]=this.convertValue(s,e)}),n}convertVectorValue(t){var e,n,i;const s=(i=(n=(e=t.fields)===null||e===void 0?void 0:e.value.arrayValue)===null||n===void 0?void 0:n.values)===null||i===void 0?void 0:i.map(a=>ut(a.doubleValue));return new si(s)}convertGeoPoint(t){return new vs(ut(t.latitude),ut(t.longitude))}convertArray(t,e){return(t.values||[]).map(n=>this.convertValue(n,e))}convertServerTimestamp(t,e){switch(e){case"previous":const n=cs(t);return n==null?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(Ur(t));default:return null}}convertTimestamp(t){const e=ne(t);return new lt(e.seconds,e.nanos)}convertDocumentKey(t,e){const n=W.fromString(t);L(qh(n));const i=new we(n.get(1),n.get(3)),s=new M(n.popFirst(5));return i.isEqual(e)||gt(`Document ${s} 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 (${e.projectId}/${e.database}) instead.`),s}}/**
2423
2423
  * @license
2424
2424
  * Copyright 2020 Google LLC
2425
2425
  *
@@ -2434,7 +2434,7 @@ This typically indicates that your device does not have a healthy Internet conne
2434
2434
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2435
2435
  * See the License for the specific language governing permissions and
2436
2436
  * limitations under the License.
2437
- */function Ss(r,t,e){let n;return n=r?e&&(e.merge||e.mergeFields)?r.toFirestore(t,e):r.toFirestore(t):t,n}class sI extends Ma{constructor(t){super(),this.firestore=t}convertBytes(t){return new Ve(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new mt(this.firestore,null,e)}}/**
2437
+ */function Ss(r,t,e){let n;return n=r?e&&(e.merge||e.mergeFields)?r.toFirestore(t,e):r.toFirestore(t):t,n}class sI extends Ma{constructor(t){super(),this.firestore=t}convertBytes(t){return new Ce(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new mt(this.firestore,null,e)}}/**
2438
2438
  * @license
2439
2439
  * Copyright 2022 Google LLC
2440
2440
  *
@@ -2449,7 +2449,7 @@ This typically indicates that your device does not have a healthy Internet conne
2449
2449
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2450
2450
  * See the License for the specific language governing permissions and
2451
2451
  * limitations under the License.
2452
- */function oI(r){return new jn("sum",Kr("sum",r))}function aI(r){return new jn("avg",Kr("average",r))}function Hd(){return new jn("count")}function uI(r,t){var e,n;return r instanceof jn&&t instanceof jn&&r.aggregateType===t.aggregateType&&((e=r._internalFieldPath)===null||e===void 0?void 0:e.canonicalString())===((n=t._internalFieldPath)===null||n===void 0?void 0:n.canonicalString())}function cI(r,t){return Pa(r.query,t.query)&&Ye(r.data(),t.data())}/**
2452
+ */function oI(r){return new Gn("sum",$r("sum",r))}function aI(r){return new Gn("avg",$r("average",r))}function Hd(){return new Gn("count")}function uI(r,t){var e,n;return r instanceof Gn&&t instanceof Gn&&r.aggregateType===t.aggregateType&&((e=r._internalFieldPath)===null||e===void 0?void 0:e.canonicalString())===((n=t._internalFieldPath)===null||n===void 0?void 0:n.canonicalString())}function cI(r,t){return Pa(r.query,t.query)&&Xe(r.data(),t.data())}/**
2453
2453
  * @license
2454
2454
  * Copyright 2020 Google LLC
2455
2455
  *
@@ -2464,7 +2464,7 @@ This typically indicates that your device does not have a healthy Internet conne
2464
2464
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2465
2465
  * See the License for the specific language governing permissions and
2466
2466
  * limitations under the License.
2467
- */class ye{constructor(t,e){this.hasPendingWrites=t,this.fromCache=e}isEqual(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache}}class on extends $r{constructor(t,e,n,i,s,a){super(t,e,n,i,a),this._firestore=t,this._firestoreImpl=t,this.metadata=s}exists(){return super.exists()}data(t={}){if(this._document){if(this._converter){const e=new Nr(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(e,t)}return this._userDataWriter.convertValue(this._document.data.value,t.serverTimestamps)}}get(t,e={}){if(this._document){const n=this._document.data.field(bs("DocumentSnapshot.get",t));if(n!==null)return this._userDataWriter.convertValue(n,e.serverTimestamps)}}}class Nr extends on{data(t={}){return super.data(t)}}class an{constructor(t,e,n,i){this._firestore=t,this._userDataWriter=e,this._snapshot=i,this.metadata=new ye(i.hasPendingWrites,i.fromCache),this.query=n}get docs(){const t=[];return this.forEach(e=>t.push(e)),t}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(t,e){this._snapshot.docs.forEach(n=>{t.call(e,new Nr(this._firestore,this._userDataWriter,n.key,n,new ye(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))})}docChanges(t={}){const e=!!t.includeMetadataChanges;if(e&&this._snapshot.excludesMetadataChanges)throw new D(P.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===e||(this._cachedChanges=function(i,s){if(i._snapshot.oldDocs.isEmpty()){let a=0;return i._snapshot.docChanges.map(u=>{const c=new Nr(i._firestore,i._userDataWriter,u.doc.key,u.doc,new ye(i._snapshot.mutatedKeys.has(u.doc.key),i._snapshot.fromCache),i.query.converter);return u.doc,{type:"added",doc:c,oldIndex:-1,newIndex:a++}})}{let a=i._snapshot.oldDocs;return i._snapshot.docChanges.filter(u=>s||u.type!==3).map(u=>{const c=new Nr(i._firestore,i._userDataWriter,u.doc.key,u.doc,new ye(i._snapshot.mutatedKeys.has(u.doc.key),i._snapshot.fromCache),i.query.converter);let h=-1,f=-1;return u.type!==0&&(h=a.indexOf(u.doc.key),a=a.delete(u.doc.key)),u.type!==1&&(a=a.add(u.doc),f=a.indexOf(u.doc.key)),{type:lI(u.type),doc:c,oldIndex:h,newIndex:f}})}}(this,e),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges}}function lI(r){switch(r){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return O()}}function hI(r,t){return r instanceof on&&t instanceof on?r._firestore===t._firestore&&r._key.isEqual(t._key)&&(r._document===null?t._document===null:r._document.isEqual(t._document))&&r._converter===t._converter:r instanceof an&&t instanceof an&&r._firestore===t._firestore&&Pa(r.query,t.query)&&r.metadata.isEqual(t.metadata)&&r._snapshot.isEqual(t._snapshot)}/**
2467
+ */class ye{constructor(t,e){this.hasPendingWrites=t,this.fromCache=e}isEqual(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache}}class an extends Qr{constructor(t,e,n,i,s,a){super(t,e,n,i,a),this._firestore=t,this._firestoreImpl=t,this.metadata=s}exists(){return super.exists()}data(t={}){if(this._document){if(this._converter){const e=new kr(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(e,t)}return this._userDataWriter.convertValue(this._document.data.value,t.serverTimestamps)}}get(t,e={}){if(this._document){const n=this._document.data.field(bs("DocumentSnapshot.get",t));if(n!==null)return this._userDataWriter.convertValue(n,e.serverTimestamps)}}}class kr extends an{data(t={}){return super.data(t)}}class un{constructor(t,e,n,i){this._firestore=t,this._userDataWriter=e,this._snapshot=i,this.metadata=new ye(i.hasPendingWrites,i.fromCache),this.query=n}get docs(){const t=[];return this.forEach(e=>t.push(e)),t}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(t,e){this._snapshot.docs.forEach(n=>{t.call(e,new kr(this._firestore,this._userDataWriter,n.key,n,new ye(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))})}docChanges(t={}){const e=!!t.includeMetadataChanges;if(e&&this._snapshot.excludesMetadataChanges)throw new D(P.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===e||(this._cachedChanges=function(i,s){if(i._snapshot.oldDocs.isEmpty()){let a=0;return i._snapshot.docChanges.map(u=>{const c=new kr(i._firestore,i._userDataWriter,u.doc.key,u.doc,new ye(i._snapshot.mutatedKeys.has(u.doc.key),i._snapshot.fromCache),i.query.converter);return u.doc,{type:"added",doc:c,oldIndex:-1,newIndex:a++}})}{let a=i._snapshot.oldDocs;return i._snapshot.docChanges.filter(u=>s||u.type!==3).map(u=>{const c=new kr(i._firestore,i._userDataWriter,u.doc.key,u.doc,new ye(i._snapshot.mutatedKeys.has(u.doc.key),i._snapshot.fromCache),i.query.converter);let h=-1,f=-1;return u.type!==0&&(h=a.indexOf(u.doc.key),a=a.delete(u.doc.key)),u.type!==1&&(a=a.add(u.doc),f=a.indexOf(u.doc.key)),{type:lI(u.type),doc:c,oldIndex:h,newIndex:f}})}}(this,e),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges}}function lI(r){switch(r){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return O()}}function hI(r,t){return r instanceof an&&t instanceof an?r._firestore===t._firestore&&r._key.isEqual(t._key)&&(r._document===null?t._document===null:r._document.isEqual(t._document))&&r._converter===t._converter:r instanceof un&&t instanceof un&&r._firestore===t._firestore&&Pa(r.query,t.query)&&r.metadata.isEqual(t.metadata)&&r._snapshot.isEqual(t._snapshot)}/**
2468
2468
  * @license
2469
2469
  * Copyright 2020 Google LLC
2470
2470
  *
@@ -2479,7 +2479,7 @@ This typically indicates that your device does not have a healthy Internet conne
2479
2479
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2480
2480
  * See the License for the specific language governing permissions and
2481
2481
  * limitations under the License.
2482
- */function Jd(r){r=Q(r,mt);const t=Q(r.firestore,nt);return Sd(ht(t),r._key).then(e=>Oa(t,r,e))}class Me extends Ma{constructor(t){super(),this.firestore=t}convertBytes(t){return new Ve(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new mt(this.firestore,null,e)}}function dI(r){r=Q(r,mt);const t=Q(r.firestore,nt),e=ht(t),n=new Me(t);return Iy(e,r._key).then(i=>new on(t,n,r._key,i,new ye(i!==null&&i.hasLocalMutations,!0),r.converter))}function fI(r){r=Q(r,mt);const t=Q(r.firestore,nt);return Sd(ht(t),r._key,{source:"server"}).then(e=>Oa(t,r,e))}function Yd(r){r=Q(r,wt);const t=Q(r.firestore,nt),e=ht(t),n=new Me(t);return Kd(r._query),Vd(e,r._query).then(i=>new an(t,n,r,i))}function mI(r){r=Q(r,wt);const t=Q(r.firestore,nt),e=ht(t),n=new Me(t);return Ey(e,r._query).then(i=>new an(t,n,r,i))}function gI(r){r=Q(r,wt);const t=Q(r.firestore,nt),e=ht(t),n=new Me(t);return Vd(e,r._query,{source:"server"}).then(i=>new an(t,n,r,i))}function Xd(r,t,e){r=Q(r,mt);const n=Q(r.firestore,nt),i=Ss(r.converter,t,e);return er(n,[As(cn(n),"setDoc",r._key,i,r.converter!==null,e).toMutation(r._key,ct.none())])}function pI(r,t,e,...n){r=Q(r,mt);const i=Q(r.firestore,nt),s=cn(i);let a;return a=typeof(t=yt(t))=="string"||t instanceof ke?Na(s,"updateDoc",r._key,t,e,n):xa(s,"updateDoc",r._key,t),er(i,[a.toMutation(r._key,ct.exists(!0))])}function Zd(r){return er(Q(r.firestore,nt),[new Qn(r._key,ct.none())])}function tf(r,t){const e=Q(r.firestore,nt),n=ii(r),i=Ss(r.converter,t);return er(e,[As(cn(r.firestore),"addDoc",n._key,i,r.converter!==null,{}).toMutation(n._key,ct.exists(!1))]).then(()=>n)}function _I(r,...t){var e,n,i;r=yt(r);let s={includeMetadataChanges:!1,source:"default"},a=0;typeof t[a]!="object"||ko(t[a])||(s=t[a],a++);const u={includeMetadataChanges:s.includeMetadataChanges,source:s.source};if(ko(t[a])){const g=t[a];t[a]=(e=g.next)===null||e===void 0?void 0:e.bind(g),t[a+1]=(n=g.error)===null||n===void 0?void 0:n.bind(g),t[a+2]=(i=g.complete)===null||i===void 0?void 0:i.bind(g)}let c,h,f;if(r instanceof mt)h=Q(r.firestore,nt),f=Kn(r._key.path),c={next:g=>{t[a]&&t[a](Oa(h,r,g))},error:t[a+1],complete:t[a+2]};else{const g=Q(r,wt);h=Q(g.firestore,nt),f=g._query;const _=new Me(h);c={next:R=>{t[a]&&t[a](new an(h,_,g,R))},error:t[a+1],complete:t[a+2]},Kd(r._query)}return function(_,R,C,N){const V=new Is(N),q=new pa(R,V,C);return _.asyncQueue.enqueueAndForget(async()=>fa(await zn(_),q)),()=>{V.Za(),_.asyncQueue.enqueueAndForget(async()=>ma(await zn(_),q))}}(ht(h),f,u,c)}function yI(r,t){return vy(ht(r=Q(r,nt)),ko(t)?t:{next:t})}function er(r,t){return function(n,i){const s=new vt;return n.asyncQueue.enqueueAndForget(async()=>J_(await Aa(n),i,s)),s.promise}(ht(r),t)}function Oa(r,t,e){const n=e.docs.get(t._key),i=new Me(r);return new on(r,i,t._key,n,new ye(e.hasPendingWrites,e.fromCache),t.converter)}/**
2482
+ */function Jd(r){r=Q(r,mt);const t=Q(r.firestore,nt);return Sd(ht(t),r._key).then(e=>Oa(t,r,e))}class Oe extends Ma{constructor(t){super(),this.firestore=t}convertBytes(t){return new Ce(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new mt(this.firestore,null,e)}}function dI(r){r=Q(r,mt);const t=Q(r.firestore,nt),e=ht(t),n=new Oe(t);return Iy(e,r._key).then(i=>new an(t,n,r._key,i,new ye(i!==null&&i.hasLocalMutations,!0),r.converter))}function fI(r){r=Q(r,mt);const t=Q(r.firestore,nt);return Sd(ht(t),r._key,{source:"server"}).then(e=>Oa(t,r,e))}function Yd(r){r=Q(r,wt);const t=Q(r.firestore,nt),e=ht(t),n=new Oe(t);return Kd(r._query),Vd(e,r._query).then(i=>new un(t,n,r,i))}function mI(r){r=Q(r,wt);const t=Q(r.firestore,nt),e=ht(t),n=new Oe(t);return Ey(e,r._query).then(i=>new un(t,n,r,i))}function gI(r){r=Q(r,wt);const t=Q(r.firestore,nt),e=ht(t),n=new Oe(t);return Vd(e,r._query,{source:"server"}).then(i=>new un(t,n,r,i))}function Xd(r,t,e){r=Q(r,mt);const n=Q(r.firestore,nt),i=Ss(r.converter,t,e);return nr(n,[As(ln(n),"setDoc",r._key,i,r.converter!==null,e).toMutation(r._key,ct.none())])}function pI(r,t,e,...n){r=Q(r,mt);const i=Q(r.firestore,nt),s=ln(i);let a;return a=typeof(t=yt(t))=="string"||t instanceof Fe?Na(s,"updateDoc",r._key,t,e,n):xa(s,"updateDoc",r._key,t),nr(i,[a.toMutation(r._key,ct.exists(!0))])}function Zd(r){return nr(Q(r.firestore,nt),[new Wn(r._key,ct.none())])}function tf(r,t){const e=Q(r.firestore,nt),n=ii(r),i=Ss(r.converter,t);return nr(e,[As(ln(r.firestore),"addDoc",n._key,i,r.converter!==null,{}).toMutation(n._key,ct.exists(!1))]).then(()=>n)}function _I(r,...t){var e,n,i;r=yt(r);let s={includeMetadataChanges:!1,source:"default"},a=0;typeof t[a]!="object"||ko(t[a])||(s=t[a],a++);const u={includeMetadataChanges:s.includeMetadataChanges,source:s.source};if(ko(t[a])){const g=t[a];t[a]=(e=g.next)===null||e===void 0?void 0:e.bind(g),t[a+1]=(n=g.error)===null||n===void 0?void 0:n.bind(g),t[a+2]=(i=g.complete)===null||i===void 0?void 0:i.bind(g)}let c,h,f;if(r instanceof mt)h=Q(r.firestore,nt),f=$n(r._key.path),c={next:g=>{t[a]&&t[a](Oa(h,r,g))},error:t[a+1],complete:t[a+2]};else{const g=Q(r,wt);h=Q(g.firestore,nt),f=g._query;const _=new Oe(h);c={next:R=>{t[a]&&t[a](new un(h,_,g,R))},error:t[a+1],complete:t[a+2]},Kd(r._query)}return function(_,R,C,N){const V=new Is(N),q=new pa(R,V,C);return _.asyncQueue.enqueueAndForget(async()=>fa(await jn(_),q)),()=>{V.Za(),_.asyncQueue.enqueueAndForget(async()=>ma(await jn(_),q))}}(ht(h),f,u,c)}function yI(r,t){return vy(ht(r=Q(r,nt)),ko(t)?t:{next:t})}function nr(r,t){return function(n,i){const s=new vt;return n.asyncQueue.enqueueAndForget(async()=>J_(await Aa(n),i,s)),s.promise}(ht(r),t)}function Oa(r,t,e){const n=e.docs.get(t._key),i=new Oe(r);return new an(r,i,t._key,n,new ye(e.hasPendingWrites,e.fromCache),t.converter)}/**
2483
2483
  * @license
2484
2484
  * Copyright 2022 Google LLC
2485
2485
  *
@@ -2494,7 +2494,7 @@ This typically indicates that your device does not have a healthy Internet conne
2494
2494
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2495
2495
  * See the License for the specific language governing permissions and
2496
2496
  * limitations under the License.
2497
- */function II(r){return ef(r,{count:Hd()})}function ef(r,t){const e=Q(r.firestore,nt),n=ht(e),i=Wl(t,(s,a)=>new Ah(a,s.aggregateType,s._internalFieldPath));return Ty(n,r._query,i).then(s=>function(u,c,h){const f=new Me(u);return new Od(c,f,h)}(e,r,s))}class EI{constructor(t){this.kind="memory",this._onlineComponentProvider=Se.provider,t!=null&&t.garbageCollector?this._offlineComponentProvider=t.garbageCollector._offlineComponentProvider:this._offlineComponentProvider=Pe.provider}toJSON(){return{kind:this.kind}}}class TI{constructor(t){let e;this.kind="persistent",t!=null&&t.tabManager?(t.tabManager._initialize(t),e=t.tabManager):(e=nf(void 0),e._initialize(t)),this._onlineComponentProvider=e._onlineComponentProvider,this._offlineComponentProvider=e._offlineComponentProvider}toJSON(){return{kind:this.kind}}}class vI{constructor(){this.kind="memoryEager",this._offlineComponentProvider=Pe.provider}toJSON(){return{kind:this.kind}}}class wI{constructor(t){this.kind="memoryLru",this._offlineComponentProvider={build:()=>new dy(t)}}toJSON(){return{kind:this.kind}}}function AI(){return new vI}function RI(r){return new wI(r==null?void 0:r.cacheSizeBytes)}function bI(r){return new EI(r)}function PI(r){return new TI(r)}class SI{constructor(t){this.forceOwnership=t,this.kind="persistentSingleTab"}toJSON(){return{kind:this.kind}}_initialize(t){this._onlineComponentProvider=Se.provider,this._offlineComponentProvider={build:e=>new va(e,t==null?void 0:t.cacheSizeBytes,this.forceOwnership)}}}class VI{constructor(){this.kind="PersistentMultipleTab"}toJSON(){return{kind:this.kind}}_initialize(t){this._onlineComponentProvider=Se.provider,this._offlineComponentProvider={build:e=>new Ad(e,t==null?void 0:t.cacheSizeBytes)}}}function nf(r){return new SI(r==null?void 0:r.forceOwnership)}function CI(){return new VI}/**
2497
+ */function II(r){return ef(r,{count:Hd()})}function ef(r,t){const e=Q(r.firestore,nt),n=ht(e),i=Wl(t,(s,a)=>new Ah(a,s.aggregateType,s._internalFieldPath));return Ty(n,r._query,i).then(s=>function(u,c,h){const f=new Oe(u);return new Od(c,f,h)}(e,r,s))}class EI{constructor(t){this.kind="memory",this._onlineComponentProvider=Ve.provider,t!=null&&t.garbageCollector?this._offlineComponentProvider=t.garbageCollector._offlineComponentProvider:this._offlineComponentProvider=Se.provider}toJSON(){return{kind:this.kind}}}class TI{constructor(t){let e;this.kind="persistent",t!=null&&t.tabManager?(t.tabManager._initialize(t),e=t.tabManager):(e=nf(void 0),e._initialize(t)),this._onlineComponentProvider=e._onlineComponentProvider,this._offlineComponentProvider=e._offlineComponentProvider}toJSON(){return{kind:this.kind}}}class vI{constructor(){this.kind="memoryEager",this._offlineComponentProvider=Se.provider}toJSON(){return{kind:this.kind}}}class wI{constructor(t){this.kind="memoryLru",this._offlineComponentProvider={build:()=>new dy(t)}}toJSON(){return{kind:this.kind}}}function AI(){return new vI}function RI(r){return new wI(r==null?void 0:r.cacheSizeBytes)}function bI(r){return new EI(r)}function PI(r){return new TI(r)}class SI{constructor(t){this.forceOwnership=t,this.kind="persistentSingleTab"}toJSON(){return{kind:this.kind}}_initialize(t){this._onlineComponentProvider=Ve.provider,this._offlineComponentProvider={build:e=>new va(e,t==null?void 0:t.cacheSizeBytes,this.forceOwnership)}}}class VI{constructor(){this.kind="PersistentMultipleTab"}toJSON(){return{kind:this.kind}}_initialize(t){this._onlineComponentProvider=Ve.provider,this._offlineComponentProvider={build:e=>new Ad(e,t==null?void 0:t.cacheSizeBytes)}}}function nf(r){return new SI(r==null?void 0:r.forceOwnership)}function CI(){return new VI}/**
2498
2498
  * @license
2499
2499
  * Copyright 2022 Google LLC
2500
2500
  *
@@ -2524,7 +2524,7 @@ This typically indicates that your device does not have a healthy Internet conne
2524
2524
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2525
2525
  * See the License for the specific language governing permissions and
2526
2526
  * limitations under the License.
2527
- */class rf{constructor(t,e){this._firestore=t,this._commitHandler=e,this._mutations=[],this._committed=!1,this._dataReader=cn(t)}set(t,e,n){this._verifyNotCommitted();const i=pe(t,this._firestore),s=Ss(i.converter,e,n),a=As(this._dataReader,"WriteBatch.set",i._key,s,i.converter!==null,n);return this._mutations.push(a.toMutation(i._key,ct.none())),this}update(t,e,n,...i){this._verifyNotCommitted();const s=pe(t,this._firestore);let a;return a=typeof(e=yt(e))=="string"||e instanceof ke?Na(this._dataReader,"WriteBatch.update",s._key,e,n,i):xa(this._dataReader,"WriteBatch.update",s._key,e),this._mutations.push(a.toMutation(s._key,ct.exists(!0))),this}delete(t){this._verifyNotCommitted();const e=pe(t,this._firestore);return this._mutations=this._mutations.concat(new Qn(e._key,ct.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new D(P.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function pe(r,t){if((r=yt(r)).firestore!==t)throw new D(P.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return r}/**
2527
+ */class rf{constructor(t,e){this._firestore=t,this._commitHandler=e,this._mutations=[],this._committed=!1,this._dataReader=ln(t)}set(t,e,n){this._verifyNotCommitted();const i=pe(t,this._firestore),s=Ss(i.converter,e,n),a=As(this._dataReader,"WriteBatch.set",i._key,s,i.converter!==null,n);return this._mutations.push(a.toMutation(i._key,ct.none())),this}update(t,e,n,...i){this._verifyNotCommitted();const s=pe(t,this._firestore);let a;return a=typeof(e=yt(e))=="string"||e instanceof Fe?Na(this._dataReader,"WriteBatch.update",s._key,e,n,i):xa(this._dataReader,"WriteBatch.update",s._key,e),this._mutations.push(a.toMutation(s._key,ct.exists(!0))),this}delete(t){this._verifyNotCommitted();const e=pe(t,this._firestore);return this._mutations=this._mutations.concat(new Wn(e._key,ct.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new D(P.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function pe(r,t){if((r=yt(r)).firestore!==t)throw new D(P.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return r}/**
2528
2528
  * @license
2529
2529
  * Copyright 2020 Google LLC
2530
2530
  *
@@ -2554,7 +2554,7 @@ This typically indicates that your device does not have a healthy Internet conne
2554
2554
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2555
2555
  * See the License for the specific language governing permissions and
2556
2556
  * limitations under the License.
2557
- */class sf extends class{constructor(e,n){this._firestore=e,this._transaction=n,this._dataReader=cn(e)}get(e){const n=pe(e,this._firestore),i=new sI(this._firestore);return this._transaction.lookup([n._key]).then(s=>{if(!s||s.length!==1)return O();const a=s[0];if(a.isFoundDocument())return new $r(this._firestore,i,a.key,a,n.converter);if(a.isNoDocument())return new $r(this._firestore,i,n._key,null,n.converter);throw O()})}set(e,n,i){const s=pe(e,this._firestore),a=Ss(s.converter,n,i),u=As(this._dataReader,"Transaction.set",s._key,a,s.converter!==null,i);return this._transaction.set(s._key,u),this}update(e,n,i,...s){const a=pe(e,this._firestore);let u;return u=typeof(n=yt(n))=="string"||n instanceof ke?Na(this._dataReader,"Transaction.update",a._key,n,i,s):xa(this._dataReader,"Transaction.update",a._key,n),this._transaction.update(a._key,u),this}delete(e){const n=pe(e,this._firestore);return this._transaction.delete(n._key),this}}{constructor(t,e){super(t,e),this._firestore=t}get(t){const e=pe(t,this._firestore),n=new Me(this._firestore);return super.get(t).then(i=>new on(this._firestore,n,e._key,i._document,new ye(!1,!1),e.converter))}}function xI(r,t,e){r=Q(r,nt);const n=Object.assign(Object.assign({},DI),e);return function(s){if(s.maxAttempts<1)throw new D(P.INVALID_ARGUMENT,"Max attempts must be at least 1")}(n),function(s,a,u){const c=new vt;return s.asyncQueue.enqueueAndForget(async()=>{const h=await Pd(s);new gy(s.asyncQueue,h,u,a,c).au()}),c.promise}(ht(r),i=>t(new sf(r,i)),n)}/**
2557
+ */class sf extends class{constructor(e,n){this._firestore=e,this._transaction=n,this._dataReader=ln(e)}get(e){const n=pe(e,this._firestore),i=new sI(this._firestore);return this._transaction.lookup([n._key]).then(s=>{if(!s||s.length!==1)return O();const a=s[0];if(a.isFoundDocument())return new Qr(this._firestore,i,a.key,a,n.converter);if(a.isNoDocument())return new Qr(this._firestore,i,n._key,null,n.converter);throw O()})}set(e,n,i){const s=pe(e,this._firestore),a=Ss(s.converter,n,i),u=As(this._dataReader,"Transaction.set",s._key,a,s.converter!==null,i);return this._transaction.set(s._key,u),this}update(e,n,i,...s){const a=pe(e,this._firestore);let u;return u=typeof(n=yt(n))=="string"||n instanceof Fe?Na(this._dataReader,"Transaction.update",a._key,n,i,s):xa(this._dataReader,"Transaction.update",a._key,n),this._transaction.update(a._key,u),this}delete(e){const n=pe(e,this._firestore);return this._transaction.delete(n._key),this}}{constructor(t,e){super(t,e),this._firestore=t}get(t){const e=pe(t,this._firestore),n=new Oe(this._firestore);return super.get(t).then(i=>new an(this._firestore,n,e._key,i._document,new ye(!1,!1),e.converter))}}function xI(r,t,e){r=Q(r,nt);const n=Object.assign(Object.assign({},DI),e);return function(s){if(s.maxAttempts<1)throw new D(P.INVALID_ARGUMENT,"Max attempts must be at least 1")}(n),function(s,a,u){const c=new vt;return s.asyncQueue.enqueueAndForget(async()=>{const h=await Pd(s);new gy(s.asyncQueue,h,u,a,c).au()}),c.promise}(ht(r),i=>t(new sf(r,i)),n)}/**
2558
2558
  * @license
2559
2559
  * Copyright 2020 Google LLC
2560
2560
  *
@@ -2584,7 +2584,7 @@ This typically indicates that your device does not have a healthy Internet conne
2584
2584
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2585
2585
  * See the License for the specific language governing permissions and
2586
2586
  * limitations under the License.
2587
- */function BI(r){return ht(r=Q(r,nt)),new rf(r,t=>er(r,t))}/**
2587
+ */function BI(r){return ht(r=Q(r,nt)),new rf(r,t=>nr(r,t))}/**
2588
2588
  * @license
2589
2589
  * Copyright 2021 Google LLC
2590
2590
  *
@@ -2599,7 +2599,7 @@ This typically indicates that your device does not have a healthy Internet conne
2599
2599
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2600
2600
  * See the License for the specific language governing permissions and
2601
2601
  * limitations under the License.
2602
- */function UI(r,t){const e=ht(r=Q(r,nt));if(!e._uninitializedComponentsProvider||e._uninitializedComponentsProvider._offline.kind==="memory")return qt("Cannot enable indexes when persistence is disabled"),Promise.resolve();const n=function(s){const a=typeof s=="string"?function(h){try{return JSON.parse(h)}catch(f){throw new D(P.INVALID_ARGUMENT,"Failed to parse JSON: "+(f==null?void 0:f.message))}}(s):s,u=[];if(Array.isArray(a.indexes))for(const c of a.indexes){const h=rl(c,"collectionGroup"),f=[];if(Array.isArray(c.fields))for(const g of c.fields){const _=Rs("setIndexConfiguration",rl(g,"fieldPath"));g.arrayConfig==="CONTAINS"?f.push(new Je(_,2)):g.order==="ASCENDING"?f.push(new Je(_,0)):g.order==="DESCENDING"&&f.push(new Je(_,1))}u.push(new Cn(Cn.UNKNOWN_ID,h,f,Dn.empty()))}return u}(t);return Ry(e,n)}function rl(r,t){if(typeof r[t]!="string")throw new D(P.INVALID_ARGUMENT,"Missing string value for: "+t);return r[t]}/**
2602
+ */function UI(r,t){const e=ht(r=Q(r,nt));if(!e._uninitializedComponentsProvider||e._uninitializedComponentsProvider._offline.kind==="memory")return qt("Cannot enable indexes when persistence is disabled"),Promise.resolve();const n=function(s){const a=typeof s=="string"?function(h){try{return JSON.parse(h)}catch(f){throw new D(P.INVALID_ARGUMENT,"Failed to parse JSON: "+(f==null?void 0:f.message))}}(s):s,u=[];if(Array.isArray(a.indexes))for(const c of a.indexes){const h=rl(c,"collectionGroup"),f=[];if(Array.isArray(c.fields))for(const g of c.fields){const _=Rs("setIndexConfiguration",rl(g,"fieldPath"));g.arrayConfig==="CONTAINS"?f.push(new Ye(_,2)):g.order==="ASCENDING"?f.push(new Ye(_,0)):g.order==="DESCENDING"&&f.push(new Ye(_,1))}u.push(new Dn(Dn.UNKNOWN_ID,h,f,xn.empty()))}return u}(t);return Ry(e,n)}function rl(r,t){if(typeof r[t]!="string")throw new D(P.INVALID_ARGUMENT,"Missing string value for: "+t);return r[t]}/**
2603
2603
  * @license
2604
2604
  * Copyright 2023 Google LLC
2605
2605
  *
@@ -2644,4 +2644,4 @@ This typically indicates that your device does not have a healthy Internet conne
2644
2644
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2645
2645
  * See the License for the specific language governing permissions and
2646
2646
  * limitations under the License.
2647
- */class QI{constructor(){throw new Error("instances of this class should not be created")}static onExistenceFilterMismatch(t){return La.instance.onExistenceFilterMismatch(t)}}class La{constructor(){this.Uu=new Map}static get instance(){return Fi||(Fi=new La,function(e){if(Ji)throw new Error("a TestingHooksSpi instance is already set");Ji=e}(Fi)),Fi}et(t){this.Uu.forEach(e=>e(t))}onExistenceFilterMismatch(t){const e=Symbol(),n=this.Uu;return n.set(e,t),()=>n.delete(e)}}let Fi=null;(function(t,e=!0){(function(i){Gn=i})(vl),Fr(new bn("firestore",(n,{instanceIdentifier:i,options:s})=>{const a=n.getProvider("app").getImmediate(),u=new nt(new Tg(n.getProvider("auth-internal")),new Ag(n.getProvider("app-check-internal")),function(h,f){if(!Object.prototype.hasOwnProperty.apply(h.options,["projectId"]))throw new D(P.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new ve(h.options.projectId,f)}(a,i),a);return s=Object.assign({useFetchStreams:e},s),u._setSettings(s),u},"PUBLIC").setMultipleInstances(!0)),We(Qu,"4.7.3",t),We(Qu,"4.7.3","esm2017")})();const WI=async(r,t)=>{var a,u;const e=ba(r,t),{error:n,result:i}=await Qr.tryDo(Yd(e)),s=(u=(a=i==null?void 0:i.docs)==null?void 0:a.map)==null?void 0:u.call(a,c=>({...c.data(),id:c.id}));return n&&console.error(n),{error:n,result:s}},HI=async(r,t,e)=>{const n=ii(r,t,e),{error:i,result:s}=await Qr.tryDo(Jd(n));return i&&console.error(i),{error:i,result:s==null?void 0:s.data()}},JI=async(r,t,e)=>{const n=ba(r,t),{error:i,result:s}=await Qr.tryDo(tf(n,e));return i&&console.error(i),{error:i,result:s}},YI=async(r,t,e)=>{const n=ii(r,t,e.id),{error:i,result:s}=await Qr.tryDo(Xd(n,e,{merge:!0}));return i&&console.error(i),{error:i,result:s}},XI=async(r,t,e)=>{const n=ii(r,t,e),{error:i,result:s}=await Qr.tryDo(Zd(n));return i&&console.error(i),{error:i,result:s}},ZI=async r=>(await Promise.resolve().then(()=>require("./index.esm-Bng7WOuv.cjs")).then(e=>e.default.initializeApp))(r),tE=async r=>(await Promise.resolve().then(()=>require("./index.esm-DS_RlbEp.cjs")).then(e=>e.default.getFirestore))(r),eE=async r=>(await Promise.resolve().then(()=>require("./index.esm-CASCXGKx.cjs")).then(e=>e.default.getStorage))(r);exports.AbstractUserDataWriter=Ma;exports.AggregateField=jn;exports.AggregateQuerySnapshot=Od;exports.ByteString=dt;exports.Bytes=Ve;exports.CollectionReference=Kt;exports.Component=bn;exports.DEFAULT_ENTRY_NAME=kr;exports.DatabaseId=ve;exports.DocumentKey=M;exports.DocumentReference=mt;exports.DocumentSnapshot=on;exports.FieldPath=ke;exports.FieldPath$1=at;exports.FieldValue=Fe;exports.FirebaseError=un;exports.Firestore=nt;exports.FirestoreError=D;exports.GeoPoint=vs;exports.LoadBundleTask=kd;exports.PersistentCacheIndexManager=of;exports.Query=wt;exports.QueryCompositeFilterConstraint=hn;exports.QueryConstraint=Zn;exports.QueryDocumentSnapshot=Nr;exports.QueryEndAtConstraint=ci;exports.QueryFieldFilterConstraint=tr;exports.QueryLimitConstraint=ai;exports.QueryOrderByConstraint=Ps;exports.QuerySnapshot=an;exports.QueryStartAtConstraint=ui;exports.SDK_VERSION=vl;exports.Se=Cy;exports.SnapshotMetadata=ye;exports.TestingHooks=QI;exports.Timestamp=lt;exports.Transaction=sf;exports.VectorValue=si;exports.WriteBatch=rf;exports.__PRIVATE_AutoId=Bo;exports.__PRIVATE_EmptyAppCheckTokenProvider=Rg;exports.__PRIVATE_EmptyAuthCredentialsProvider=Fl;exports.__PRIVATE_cast=Q;exports.__PRIVATE_debugAssert=Ig;exports.__PRIVATE_isBase64Available=Zg;exports.__PRIVATE_logWarn=qt;exports.__PRIVATE_validateIsNotUsedTogether=Dd;exports._addComponent=fo;exports._addOrOverwriteComponent=tg;exports._apps=Ee;exports._clearComponents=ng;exports._components=Sn;exports._getProvider=os;exports._internalAggregationQueryToProtoRunAggregationQueryRequest=$I;exports._internalQueryToProtoQueryTarget=KI;exports._isFirebaseApp=El;exports._isFirebaseServerApp=eg;exports._registerComponent=Fr;exports._removeServiceInstance=Il;exports._serverApps=Pn;exports.addDoc=tf;exports.addDocument=JI;exports.aggregateFieldEqual=uI;exports.aggregateQuerySnapshotEqual=cI;exports.and=Yy;exports.arrayRemove=MI;exports.arrayUnion=FI;exports.average=aI;exports.clearIndexedDbPersistence=Fy;exports.collection=ba;exports.collectionGroup=Sy;exports.connectFirestoreEmulator=Nd;exports.count=Hd;exports.createMockUserToken=cl;exports.deleteAllPersistentCacheIndexes=GI;exports.deleteApp=Rl;exports.deleteDoc=Zd;exports.deleteDocument=XI;exports.deleteField=NI;exports.disableNetwork=Ly;exports.disablePersistentCacheIndexAutoCreation=jI;exports.doc=ii;exports.documentId=zy;exports.enableIndexedDbPersistence=Ny;exports.enableMultiTabIndexedDbPersistence=ky;exports.enableNetwork=Oy;exports.enablePersistentCacheIndexAutoCreation=zI;exports.endAt=iI;exports.endBefore=rI;exports.ensureFirestoreConfigured=ht;exports.executeWrite=er;exports.getAggregateFromServer=ef;exports.getAllDocuments=WI;exports.getApp=Al;exports.getApps=og;exports.getCountFromServer=II;exports.getDefaultEmulatorHostnameAndPort=al;exports.getDoc=Jd;exports.getDocFromCache=dI;exports.getDocFromServer=fI;exports.getDocs=Yd;exports.getDocsFromCache=mI;exports.getDocsFromServer=gI;exports.getDocumentById=HI;exports.getFireStorage=eE;exports.getFireStore=tE;exports.getFirestore=xy;exports.getModularInstance=yt;exports.getPersistentCacheIndexManager=qI;exports.increment=OI;exports.initFirebaseApp=ZI;exports.initializeApp=wl;exports.initializeFirestore=Dy;exports.initializeServerApp=sg;exports.limit=Zy;exports.limitToLast=tI;exports.loadBundle=Uy;exports.memoryEagerGarbageCollector=AI;exports.memoryLocalCache=bI;exports.memoryLruGarbageCollector=RI;exports.namedQuery=qy;exports.onLog=ag;exports.onSnapshot=_I;exports.onSnapshotsInSync=yI;exports.or=Jy;exports.orderBy=Xy;exports.persistentLocalCache=PI;exports.persistentMultipleTabManager=CI;exports.persistentSingleTabManager=nf;exports.query=Wy;exports.queryEqual=Pa;exports.refEqual=Vy;exports.registerVersion=We;exports.runTransaction=xI;exports.serverTimestamp=kI;exports.setDoc=Xd;exports.setDocument=YI;exports.setIndexConfiguration=UI;exports.setLogLevel=yg;exports.setLogLevel$1=ug;exports.snapshotEqual=hI;exports.startAfter=nI;exports.startAt=eI;exports.sum=oI;exports.terminate=By;exports.updateDoc=pI;exports.vector=LI;exports.waitForPendingWrites=My;exports.where=Hy;exports.writeBatch=BI;
2647
+ */class QI{constructor(){throw new Error("instances of this class should not be created")}static onExistenceFilterMismatch(t){return La.instance.onExistenceFilterMismatch(t)}}class La{constructor(){this.Uu=new Map}static get instance(){return Fi||(Fi=new La,function(e){if(Ji)throw new Error("a TestingHooksSpi instance is already set");Ji=e}(Fi)),Fi}et(t){this.Uu.forEach(e=>e(t))}onExistenceFilterMismatch(t){const e=Symbol(),n=this.Uu;return n.set(e,t),()=>n.delete(e)}}let Fi=null;(function(t,e=!0){(function(i){Kn=i})(vl),Mr(new Pn("firestore",(n,{instanceIdentifier:i,options:s})=>{const a=n.getProvider("app").getImmediate(),u=new nt(new Tg(n.getProvider("auth-internal")),new Ag(n.getProvider("app-check-internal")),function(h,f){if(!Object.prototype.hasOwnProperty.apply(h.options,["projectId"]))throw new D(P.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new we(h.options.projectId,f)}(a,i),a);return s=Object.assign({useFetchStreams:e},s),u._setSettings(s),u},"PUBLIC").setMultipleInstances(!0)),He(Qu,"4.7.3",t),He(Qu,"4.7.3","esm2017")})();const WI=async(r,t)=>{var a,u;const e=ba(r,t),{error:n,result:i}=await Ee.tryDo(Yd(e));if(n)return{error:n,result:null};const s=(u=(a=i==null?void 0:i.docs)==null?void 0:a.map)==null?void 0:u.call(a,c=>({...c.data(),id:c.id}));return{error:null,result:Ee.cast(s)}},HI=async(r,t,e)=>{const n=ii(r,t,e),{error:i,result:s}=await Ee.tryDo(Jd(n));return i?{error:i,result:null}:{error:null,result:Ee.cast(s==null?void 0:s.data())}},JI=async(r,t,e)=>{const n=ba(r,t),{error:i,result:s}=await Ee.tryDo(tf(n,e));return i?{error:i,result:null}:{error:null,result:Ee.cast(s)}},YI=async(r,t,e)=>{const n=ii(r,t,e.id),{error:i,result:s}=await Ee.tryDo(Xd(n,e,{merge:!0}));return i?{error:i,result:null}:{error:null,result:s}},XI=async(r,t,e)=>{const n=ii(r,t,e),{error:i,result:s}=await Ee.tryDo(Zd(n));return i?{error:i,result:null}:{error:null,result:s}},ZI=async r=>(await Promise.resolve().then(()=>require("./index.esm-_CWU_suT.cjs")).then(e=>e.default.initializeApp))(r),tE=async r=>(await Promise.resolve().then(()=>require("./index.esm-RieK0f97.cjs")).then(e=>e.default.getFirestore))(r),eE=async r=>(await Promise.resolve().then(()=>require("./index.esm-B0E-kI9K.cjs")).then(e=>e.default.getStorage))(r);exports.AbstractUserDataWriter=Ma;exports.AggregateField=Gn;exports.AggregateQuerySnapshot=Od;exports.ByteString=dt;exports.Bytes=Ce;exports.CollectionReference=Kt;exports.Component=Pn;exports.DEFAULT_ENTRY_NAME=Fr;exports.DatabaseId=we;exports.DocumentKey=M;exports.DocumentReference=mt;exports.DocumentSnapshot=an;exports.FieldPath=Fe;exports.FieldPath$1=at;exports.FieldValue=Me;exports.FirebaseError=cn;exports.Firestore=nt;exports.FirestoreError=D;exports.GeoPoint=vs;exports.LoadBundleTask=kd;exports.PersistentCacheIndexManager=of;exports.Query=wt;exports.QueryCompositeFilterConstraint=dn;exports.QueryConstraint=tr;exports.QueryDocumentSnapshot=kr;exports.QueryEndAtConstraint=ci;exports.QueryFieldFilterConstraint=er;exports.QueryLimitConstraint=ai;exports.QueryOrderByConstraint=Ps;exports.QuerySnapshot=un;exports.QueryStartAtConstraint=ui;exports.SDK_VERSION=vl;exports.Se=Cy;exports.SnapshotMetadata=ye;exports.TestingHooks=QI;exports.Timestamp=lt;exports.Transaction=sf;exports.VectorValue=si;exports.WriteBatch=rf;exports.__PRIVATE_AutoId=Bo;exports.__PRIVATE_EmptyAppCheckTokenProvider=Rg;exports.__PRIVATE_EmptyAuthCredentialsProvider=Fl;exports.__PRIVATE_cast=Q;exports.__PRIVATE_debugAssert=Ig;exports.__PRIVATE_isBase64Available=Zg;exports.__PRIVATE_logWarn=qt;exports.__PRIVATE_validateIsNotUsedTogether=Dd;exports._addComponent=fo;exports._addOrOverwriteComponent=tg;exports._apps=Te;exports._clearComponents=ng;exports._components=Vn;exports._getProvider=os;exports._internalAggregationQueryToProtoRunAggregationQueryRequest=$I;exports._internalQueryToProtoQueryTarget=KI;exports._isFirebaseApp=El;exports._isFirebaseServerApp=eg;exports._registerComponent=Mr;exports._removeServiceInstance=Il;exports._serverApps=Sn;exports.addDoc=tf;exports.addDocument=JI;exports.aggregateFieldEqual=uI;exports.aggregateQuerySnapshotEqual=cI;exports.and=Yy;exports.arrayRemove=MI;exports.arrayUnion=FI;exports.average=aI;exports.clearIndexedDbPersistence=Fy;exports.collection=ba;exports.collectionGroup=Sy;exports.connectFirestoreEmulator=Nd;exports.count=Hd;exports.createMockUserToken=cl;exports.deleteAllPersistentCacheIndexes=GI;exports.deleteApp=Rl;exports.deleteDoc=Zd;exports.deleteDocument=XI;exports.deleteField=NI;exports.disableNetwork=Ly;exports.disablePersistentCacheIndexAutoCreation=jI;exports.doc=ii;exports.documentId=zy;exports.enableIndexedDbPersistence=Ny;exports.enableMultiTabIndexedDbPersistence=ky;exports.enableNetwork=Oy;exports.enablePersistentCacheIndexAutoCreation=zI;exports.endAt=iI;exports.endBefore=rI;exports.ensureFirestoreConfigured=ht;exports.executeWrite=nr;exports.getAggregateFromServer=ef;exports.getAllDocuments=WI;exports.getApp=Al;exports.getApps=og;exports.getCountFromServer=II;exports.getDefaultEmulatorHostnameAndPort=al;exports.getDoc=Jd;exports.getDocFromCache=dI;exports.getDocFromServer=fI;exports.getDocs=Yd;exports.getDocsFromCache=mI;exports.getDocsFromServer=gI;exports.getDocumentById=HI;exports.getFireStorage=eE;exports.getFireStore=tE;exports.getFirestore=xy;exports.getModularInstance=yt;exports.getPersistentCacheIndexManager=qI;exports.increment=OI;exports.initFirebaseApp=ZI;exports.initializeApp=wl;exports.initializeFirestore=Dy;exports.initializeServerApp=sg;exports.limit=Zy;exports.limitToLast=tI;exports.loadBundle=Uy;exports.memoryEagerGarbageCollector=AI;exports.memoryLocalCache=bI;exports.memoryLruGarbageCollector=RI;exports.namedQuery=qy;exports.onLog=ag;exports.onSnapshot=_I;exports.onSnapshotsInSync=yI;exports.or=Jy;exports.orderBy=Xy;exports.persistentLocalCache=PI;exports.persistentMultipleTabManager=CI;exports.persistentSingleTabManager=nf;exports.query=Wy;exports.queryEqual=Pa;exports.refEqual=Vy;exports.registerVersion=He;exports.runTransaction=xI;exports.serverTimestamp=kI;exports.setDoc=Xd;exports.setDocument=YI;exports.setIndexConfiguration=UI;exports.setLogLevel=yg;exports.setLogLevel$1=ug;exports.snapshotEqual=hI;exports.startAfter=nI;exports.startAt=eI;exports.sum=oI;exports.terminate=By;exports.updateDoc=pI;exports.vector=LI;exports.waitForPendingWrites=My;exports.where=Hy;exports.writeBatch=BI;