PageSourceSearch

https://www.zemith.com/_next/static/chunks/09a4f7ac-e1c231ccecab2bad.js

js zemith.com collected 2026-10-04 05:40:15 UTC 223,065 bytes, 7 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[82644],{20542:(e,t,r)=>{r.d(t,{C:()=>tw,D:()=>le,F:()=>ty,I:()=>nS,K:()=>nW,N:()=>lr,Q:()=>nN,S:()=>o7,T:()=>Z,U:()=>t$,V:()=>oY,Y:()=>K,_:()=>rW,a:()=>rX,a5:()=>oJ,a6:()=>tj,a7:()=>eP,a8:()=>em,a9:()=>tm,aL:()=>nC,aM:()=>nV,aN:()=>nb,aV:()=>o8,aa:()=>tz,ab:()=>F,ac:()=>J,ad:()=>o1,ae:()=>T,am:()=>p,av:()=>er,b:()=>ev,c:()=>tK,d:()=>o6,e:()=>tY,f:()=>P,g:()=>nz,h:()=>tW,i:()=>tV,j:()=>tQ,k:()=>tH,l:()=>nM,m:()=>o0,n:()=>nF,o:()=>rq,p:()=>nB,q:()=>n$,s:()=>X,t:()=>O,u:()=>o9,v:()=>nA,x:()=>o5});var n,s,i,a,o=r(92625),l=r(28838),u=r(42387),c=r(47034),h=r(10839),d=r(72562),m=r(87480).hp;r(37811);let f="12.18.0";function p(e){f=e}let g=new c.Vy("@firebase/firestore");function y(){return g.logLevel}function w(e,...t){if(g.logLevel<=c.$b.DEBUG){let r=t.map(E);g.debug(`Firestore (${f}): ${e}`,...r)}}function v(e,...t){if(g.logLevel<=c.$b.ERROR){let r=t.map(E);g.error(`Firestore (${f}): ${e}`,...r)}}function _(e,...t){if(g.logLevel<=c.$b.WARN){let r=t.map(E);g.warn(`Firestore (${f}): ${e}`,...r)}}function E(e){if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(t){return e}}function T(e,t,r){let n="Unexpected state";"string"==typeof t?n=t:r=t,x(e,n,r)}function x(e,t,r){let n=`FIRESTORE (${f}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(void 0!==r)try{n+=" CONTEXT: "+JSON.stringify(r)}catch(e){n+=" CONTEXT: "+r}throw v(n),Error(n)}function b(e,t,r,n){let s="Unexpected state";"string"==typeof r?s=r:n=r,e||x(t,s,n)}class N{static newId(){let e=62*Math.floor(256/62),t="";for(;t.length<20;){let r=function(){let e="u">typeof self&&(self.crypto||self.msCrypto),t=new Uint8Array(40);if(e&&"function"==typeof e.getRandomValues)e.getRandomValues(t);else for(let e=0;e<40;e++)t[e]=Math.floor(256*Math.random());return t}();for(let n=0;n<r.length;++n)t.length<20&&r[n]<e&&(t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(r[n]%62))}return t}}function S(e,t){return e<t?-1:+(e>t)}function I(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++){let r=e.charAt(n),s=t.charAt(n);if(r!==s)return C(r)===C(s)?S(r,s):C(r)?1:-1}return S(e.length,t.length)}function C(e){let t=e.charCodeAt(0);return t>=55296&&t<=57343}function V(e,t,r){return e.length===t.length&&e.every((e,n)=>r(e,t[n]))}class A{constructor(e,t){this.comparator=e,this.root=t||k.EMPTY}insert(e,t){return new A(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,k.BLACK,null,null))}remove(e){return new A(this.comparator,this.root.remove(e,this.comparator).copy(null,null,k.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){let r=this.comparator(e,t.key);if(0===r)return t.value;r<0?t=t.left:r>0&&(t=t.right)}return null}indexOf(e){let t=0,r=this.root;for(;!r.isEmpty();){let n=this.comparator(e,r.key);if(0===n)return t+r.left.size;n<0?r=r.left:(t+=r.left.size+1,r=r.right)}return -1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((t,r)=>(e(t,r),!1))}toString(){let e=[];return this.inorderTraversal((t,r)=>(e.push(`${t}:${r}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new D(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new D(this.root,e,this.comparator,!1)}getReverseIterator(){return new D(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new D(this.root,e,this.comparator,!0)}}class D{constructor(e,t,r,n){this.isReverse=n,this.nodeStack=[];let s=1;for(;!e.isEmpty();)if(s=t?r(e.key,t):1,t&&n&&(s*=-1),s<0)e=this.isReverse?e.left:e.right;else{if(0===s){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop(),t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(0===this.nodeStack.length)return null;let e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class k{constructor(e,t,r,n,s){this.key=e,this.value=t,this.color=null!=r?r:k.RED,this.left=null!=n?n:k.EMPTY,this.right=null!=s?s:k.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,r,n,s){return new k(null!=e?e:this.key,null!=t?t:this.value,
1null!=r?r:this.color,null!=n?n:this.left,null!=s?s:this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,r){let n=this,s=r(e,n.key);return(n=s<0?n.copy(null,null,null,n.left.insert(e,t,r),null):0===s?n.copy(null,t,null,null,null):n.copy(null,null,null,null,n.right.insert(e,t,r))).fixUp()}removeMin(){if(this.left.isEmpty())return k.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),(e=e.copy(null,null,null,e.left.removeMin(),null)).fixUp()}remove(e,t){let r,n=this;if(0>t(e,n.key))n.left.isEmpty()||n.left.isRed()||n.left.left.isRed()||(n=n.moveRedLeft()),n=n.copy(null,null,null,n.left.remove(e,t),null);else{if(n.left.isRed()&&(n=n.rotateRight()),n.right.isEmpty()||n.right.isRed()||n.right.left.isRed()||(n=n.moveRedRight()),0===t(e,n.key)){if(n.right.isEmpty())return k.EMPTY;r=n.right.min(),n=n.copy(r.key,r.value,null,null,n.right.removeMin())}n=n.copy(null,null,null,null,n.right.remove(e,t))}return n.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=(e=(e=e.copy(null,null,null,null,e.right.rotateRight())).rotateLeft()).colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=(e=e.rotateRight()).colorFlip()),e}rotateLeft(){let e=this.copy(null,null,k.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){let e=this.copy(null,null,k.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){let e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){return Math.pow(2,this.check())<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw T(43730,{key:this.key,value:this.value});if(this.right.isRed())throw T(14113,{key:this.key,value:this.value});let e=this.left.check();if(e!==this.right.check())throw T(27949);return e+ +!this.isRed()}}
1k.EMPTY=null,k.RED=!0,k.BLACK=!1,k.EMPTY=new class{constructor(){this.size=0}get key(){throw T(57766)}get value(){throw T(16141)}get color(){throw T(16727)}get left(){throw T(29726)}get right(){throw T(36894)}copy(e,t,r,n,s){return this}insert(e,t,r){return new k(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class L{constructor(e){this.comparator=e,this.data=new A(this.comparator)}has(e){return null!==this.data.get(e)}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((t,r)=>(e(t),!1))}forEachInRange(e,t){let r=this.data.getIteratorFrom(e[0]);for(;r.hasNext();){let n=r.getNext();if(this.comparator(n.key,e[1])>=0)return;t(n.key)}}forEachWhile(e,t){let r;for(r=void 0!==t?this.data.getIteratorFrom(t):this.data.getIterator();r.hasNext();)if(!e(r.getNext().key))return}firstAfterOrEqual(e){let t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new R(this.data.getIterator())}getIteratorFrom(e){return new R(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach(e=>{t=t.add(e)}),t}isEqual(e){if(!(e instanceof L)||this.size!==e.size)return!1;let t=this.data.getIterator(),r=e.data.getIterator();for(;t.hasNext();){let e=t.getNext().key,n=r.getNext().key;if(0!==this.comparator(e,n))return!1}return!0}toArray(){let e=[];return this.forEach(t=>{e.push(t)}),e}toString(){let e=[];return this.forEach(t=>e.push(t)),"SortedSet("+e.toString()+")"}copy(e){let t=new L(this.comparator);return t.data=e,t}}class R{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}let O={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class P extends l.g{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}let U="__name__";class M{constructor(e,t,r){void 0===t?t=0:t>e.length&&T(637,{offset:t,range:e.length}),void 0===r?r=e.length-t:r>e.length-t&&T(1746,{length:r,range:e.length-t}),this.segments=e,this.offset=t,this.len=r}get length(){return this.len}isEqual(e){return 0===M.comparator(this,e)}child(e){let t=this.segments.slice(this.offset,this.limit());return e instanceof M?e.forEach(e=>{t.push(e)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=void 0===e?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return 0===this.length}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,r=this.limit();t<r;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++){let r=M.compareSegments(e.get(n),t.get(n));if(0!==r)return r}return S(e.length,t.length)}static compareSegments(e,t){let r=M.isNumericId(e),n=M.isNumericId(t);return r&&!n?-1:!r&&n?1:r&&n?M.extractNumericId(e).compare(M.extractNumericId(t)):I(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return u.jz.fromString(e.substring(4,e.length-2))}}class F extends M{construct(e,t,r){return new F(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toStringWithLeadingSlash(){return`/${this.canonicalString()}`}
1toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){let t=[];for(let r of e){if(r.indexOf("//")>=0)throw new P(O.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);t.push(...r.split("/").filter(e=>e.length>0))}return new F(t)}static emptyPath(){return new F([])}}let q=/^[_a-zA-Z][_a-zA-Z0-9]*$/,$=class e extends M{construct(t,r,n){return new e(t,r,n)}static isValidIdentifier(e){return q.test(e)}canonicalString(){return this.toArray().map(t=>(t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),e.isValidIdentifier(t)||(t="`"+t+"`"),t)).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&this.get(0)===U}static keyField(){return new e([U])}static fromServerFormat(t){let r=[],n="",s=0,i=()=>{if(0===n.length)throw new P(O.INVALID_ARGUMENT,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);r.push(n),n=""},a=!1;for(;s<t.length;){let e=t[s];if("\\"===e){if(s+1===t.length)throw new P(O.INVALID_ARGUMENT,"Path has trailing escape character: "+t);let e=t[s+1];if("\\"!==e&&"."!==e&&"`"!==e)throw new P(O.INVALID_ARGUMENT,"Path has invalid escape sequence: "+t);n+=e,s+=2}else"`"===e?a=!a:"."!==e||a?n+=e:i(),s++}if(i(),a)throw new P(O.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new e(r)}static emptyPath(){return new e([])}};class B{constructor(e){this.fields=e,e.sort($.comparator)}static empty(){return new B([])}unionWith(e){let t=new L($.comparator);for(let e of this.fields)t=t.add(e);for(let r of e)t=t.add(r);return new B(t.toArray())}covers(e){for(let t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return V(this.fields,e.fields,(e,t)=>e.isEqual(t))}}function z(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}function j(e,t){for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t(r,e[r])}function G(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}class K{constructor(e){this.path=e}static fromPath(e){return new K(F.fromString(e))}static fromName(e){return new K(F.fromString(e).popFirst(5))}static empty(){return new K(F.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return null!==e&&0===F.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,t){return F.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new K(new F(e.slice()))}}function Q(e,t,r){if(!r)throw new P(O.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function W(e){if(!K.isDocumentKey(e))throw new P(O.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function H(e){if(K.isDocumentKey(e))throw new P(O.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function Y(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}function J(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return e.length>20&&(e=`${e.substring(0,20)}...`),JSON.stringify(e);if("number"==typeof e||"boolean"==typeof e)return""+e;if("object"==typeof e){if(e instanceof Array)return"an array";{var t;let r=(t=e).constructor?t.constructor.name:null;return r?`a custom ${r} object`:"an object"}}return"function"==typeof e?"a function":T(12329,{type:typeof e})}function X(e,t){if("_delegate"in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new P(O.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{let r=J(e);throw new P(O.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${r}`)}}return e}function Z(e,t){if(t<=0)throw new P(O.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}function ee(e,t){let r={typeString:e};return t&&(r.value=t),r}function et(e,t){let r;if(!Y(e))throw new P(O.INVALID_ARGUMENT,"JSON must be an object");for(let n in t)if(t[n]){let s=t[n].typeString,i="value"in t[n]?{value:t[n].value}:void 0;if(!(n in e)){r=`JSON missing required field: '${n}'`;break}let a=e[n];if(s&&typeof a!==s){r=`JSON field '${n}' must be a ${s}.`;break}if(void 0!==i&&a!==i.value){r=`Expected '${n}' field to equal '${i.value}'`;break}}if(r)throw new P(O.INVALID_ARGUMENT,r);return!0}class er{static now(){return er.fromMillis(Date.now())}static fromDate(e){return er.fromMillis(e.getTime())}static fromMillis(e){let t=Math.floor(e/1e3),r=Math.floor((e-1e3*t)*1e6);return new er(t,r)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0||t>=1e9)throw new P(O.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<-0xe7791f700||e>=0x3afff44180)throw new P(O.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?S(this.nanoseconds,e.nanoseconds):S(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:er._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(et(e,er._jsonSchema))return new er(e.seconds,e.nanoseconds)}valueOf(){return String(this.seconds- -0xe7791f700).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}
1}er._jsonSchemaVersion="firestore/timestamp/1.0",er._jsonSchema={type:ee("string",er._jsonSchemaVersion),seconds:ee("number"),nanoseconds:ee("number")};class en extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class es{constructor(e){this.binaryString=e}static fromBase64String(e){return new es(function(e){try{return atob(e)}catch(e){throw"u">typeof DOMException&&e instanceof DOMException?new en("Invalid base64 string: "+e):e}}(e))}static fromUint8Array(e){return new es(function(e){let t="";for(let r=0;r<e.length;++r)t+=String.fromCharCode(e[r]);return t}(e))}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return btoa(this.binaryString)}toUint8Array(){var e=this.binaryString;let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return S(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}es.EMPTY_BYTE_STRING=new es("");let ei=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function ea(e){if(b(!!e,39018),"string"==typeof e){let t=0,r=ei.exec(e);if(b(!!r,46558,{timestamp:e}),r[1]){let e=r[1];t=Number(e=(e+"000000000").substr(0,9))}return{seconds:Math.floor(new Date(e).getTime()/1e3),nanos:t}}return{seconds:eo(e.seconds),nanos:eo(e.nanos)}}function eo(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function el(e){return"string"==typeof e?es.fromBase64String(e):es.fromUint8Array(e)}let eu="server_timestamp",ec="__type__",eh="__previous_value__",ed="__local_write_time__";function em(e){return(e?.mapValue?.fields||{})[ec]?.stringValue===eu}function ef(e){let t=e.mapValue.fields[eh];return em(t)?ef(t):t}function ep(e){let t=ea(e.mapValue.fields[ed].timestampValue);return new er(t.seconds,t.nanos)}class eg{constructor(e,t,r,n,s,i,a,o,l,u,c,h,d){this.databaseId=e,this.appId=t,this.persistenceKey=r,this.host=n,this.ssl=s,this.forceLongPolling=i,this.autoDetectLongPolling=a,this.longPollingOptions=o,this.useFetchStreams=l,this.isUsingEmulator=u,this.apiKey=c,this._customHeaders=h,this.grpcFlowControlWindow=d}}let ey="(default)";class ew{constructor(e,t){this.projectId=e,this.database=t||ey}static empty(){return new ew("","")}get isDefaultDatabase(){return this.database===ey}isEqual(e){return e instanceof ew&&e.projectId===this.projectId&&e.database===this.database}}function ev(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new P(O.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new ew(e.options.projectId,t)}function e_(e){return 0===e&&1/e==-1/0}let eE="__type__",eT="__max__",ex={fields:{__type__:{stringValue:eT}}},eb="__vector__",eN="value",eS={nullValue:"NULL_VALUE"},eI={booleanValue:!0},eC={booleanValue:!1};function eV(e){return"nullValue"in e?0:"booleanValue"in e?1:"integerValue"in e||"doubleValue"in e?2:"timestampValue"in e?3:"stringValue"in e?5:"bytesValue"in e?6:"referenceValue"in e?7:"geoPointValue"in e?8:"arrayValue"in e?9:"mapValue"in e?em(e)?4:eQ(e)?0x1fffffffffffff:ej(e)?10:11:T(28295,{value:e})}function eA(e,t,r){if(e===t)return!0;let n=eV(e);if(n!==eV(t))return!1;switch(n){case 0:case 0x1fffffffffffff:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return ep(e).isEqual(ep(t));case 3:if("string"==typeof e.timestampValue&&"string"==typeof t.timestampValue&&e.timestampValue.length===t.timestampValue.length)return e.timestampValue===t.timestampValue;let s=ea(e.timestampValue),i=ea(t.timestampValue);return s.seconds===i.seconds&&s.nanos===i.nanos;case 5:return e.stringValue===t.stringValue;case 6:return el(e.bytesValue).isEqual(el(t.bytesValue));case 7:return e.referenceValue===t.referenceValue;case 8:return eo(e.geoPointValue.latitude)===eo(t.geoPointValue.latitude)&&eo(e.geoPointValue.longitude)===eo(t.geoPointValue.longitude);case 2:let a,o;if("integerValue"in e&&"integerValue"in t)return eo(e.integerValue)===eo(t.integerValue);if("doubleValue"in e&&"doubleValue"in t)a=eo(e.doubleValue),o=eo(t.doubleValue);else{if(!r?.t)return!1;a=eo(e.integerValue??e.doubleValue),o=eo(t.integerValue??t.doubleValue)}return a===o?!!r?.i||e_(a)===e_(o):!!(void 0===r||r.o)&&isNaN(a)&&isNaN(o);case 9:return V(e.arrayValue.values||[],t.arrayValue.values||[],(e,t)=>eA(e,t,r));case 10:case 11:let l=e.mapValue.fields||{},u=t.mapValue.fields||{};if(z(l)!==z(u))return!1;for(let e in l)if(l.hasOwnProperty(e)&&(void 0===u[e]||!eA(l[e],u[e],r)))return!1;return!0;default:return T(52216,{left:e})}}function eD(e,t){return void 0!==(e.values||[]).find(e=>eA(e,t))}function ek(e,t){var r,n,s,i,a,o;if(e===t)return 0;let l=eV(e),u=eV(t);if(l!==u)return S(l,u);switch(l){case 0:case 0x1fffffffffffff:return 0;case 1:return S(e.booleanValue,t.booleanValue);case 2:let c,h;return c=eo(e.integerValue||e.doubleValue),c<(h=eo(t.integerValue||t.doubleValue))?-1:c>h?1:c===h?0:isNaN(c)?isNaN(h)?0:-1:1;case 3:return eL(e.timestampValue,t.timestampValue);case 4:return eL(ep(e),ep(t));case 5:return I(e.stringValue,t.stringValue);case 6:let d,m;return r=e.bytesValue,n=t.bytesValue,d=el(r),m=el(n),d.compareTo(m);case 7:return function(e,t){let r=e.split("/"),n=t.split("/");for(let e=0;e<r.length&&e<n.length;e++){let t=S(r[e],n[e]);if(0!==t)return t}return S(r.length,n.length)}(e.referenceValue,t.referenceValue);case 8:let f;return s=e.geoPointValue,i=t.geoPointValue,0!==(f=S(eo(s.latitude),eo(i.latitude)))?f:S(eo(s.longitude),eo(i.longitude));case 9:return eR(e.arrayValue,t.arrayValue);case 10:let p,g,y,w,v;return a=e.mapValue,o=t.mapValue,p=a.fields||{},g=o.fields||{},y=p[eN]?.arrayValue,w=g[eN]?.arrayValue,0!==(v=S(y?.values?.length||0,w?.values?.length||0))?v:eR(y,w);case 11:return function(e,t){if(e===ex&&t===ex)return 0;if(e===ex)return 1;if(t===ex)return -1;let r=e.fields||{},n=Object.keys(r),s=t.fields||{},i=Object.keys(s);n.sort(),i.sort();for(let e=0;e<n.length&&e<i.length;++e){let t=I(n[e],i[e]);if(0!==t)return t;let a=ek(r[n[e]],s[i[e]]);if(0!==a)return a}return S(n.length,i.length)}(e.mapValue,t.mapValue);default:throw T(23264,{u:l})}}function eL(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return S(e,t);let r=ea(e),n=ea(t),s=S(r.seconds,n.seconds);return 0!==s?s:S(r.nanos,n.nanos)}function eR(e,t){let r=e.values||[],n=t.values||[];for(let e=0;e<r.length&&e<n.length;++e){let t=ek(r[e],n[e]);if(void 0!==t&&0!==t)return t}return S(r.length,n.length)}function eO(e){var t,r;let n;return"nullValue"in e?"null":"booleanValue"in e?""+e.booleanValue:"integerValue"in e?""+e.integerValue:"doubleValue"in e?""+e.doubleValue:"timestampValue"in e?(n=ea(e.timestampValue),`time(${n.seconds},${n.nanos}
1)`):"stringValue"in e?e.stringValue:"bytesValue"in e?el(e.bytesValue).toBase64():"referenceValue"in e?(t=e.referenceValue,K.fromName(t).toString()):"geoPointValue"in e?(r=e.geoPointValue,`geo(${r.latitude},${r.longitude})`):"arrayValue"in e?function(e){let t="[",r=!0;for(let n of e.values||[])r?r=!1:t+=",",t+=eO(n);return t+"]"}(e.arrayValue):"mapValue"in e?function(e){let t=Object.keys(e.fields||{}).sort(),r="{",n=!0;for(let s of t)n?n=!1:r+=",",r+=`${s}:${eO(e.fields[s])}`;return r+"}"}(e.mapValue):T(61005,{value:e})}function eP(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function eU(e){return!!e&&"integerValue"in e}function eM(e){return!!e&&"doubleValue"in e}function eF(e){return eU(e)||eM(e)}function eq(e){return!!e&&"arrayValue"in e}function e$(e){return!!e&&"nullValue"in e}function eB(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function ez(e){return!!e&&"mapValue"in e}function ej(e){return(e?.mapValue?.fields||{})[eE]?.stringValue===eb}function eG(e){return(e?.mapValue?.fields||{})[eN]?.arrayValue}function eK(e){if(e.geoPointValue)return{geoPointValue:{...e.geoPointValue}};if(e.timestampValue&&"object"==typeof e.timestampValue)return{timestampValue:{...e.timestampValue}};if(e.mapValue){let t={mapValue:{fields:{}}};return j(e.mapValue.fields,(e,r)=>t.mapValue.fields[e]=eK(r)),t}if(e.arrayValue){let t={arrayValue:{values:[]}};for(let r=0;r<(e.arrayValue.values||[]).length;++r)t.arrayValue.values[r]=eK(e.arrayValue.values[r]);return t}return{...e}}function eQ(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===eT}class eW{constructor(e){this.value=e}static empty(){return new eW({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let r=0;r<e.length-1;++r)if(!ez(t=(t.mapValue.fields||{})[e.get(r)]))return null;return(t=(t.mapValue.fields||{})[e.lastSegment()])||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=eK(t)}setAll(e){let t=$.emptyPath(),r={},n=[];e.forEach((e,s)=>{if(!t.isImmediateParentOf(s)){let e=this.getFieldsMap(t);this.applyChanges(e,r,n),r={},n=[],t=s.popLast()}e?r[s.lastSegment()]=eK(e):n.push(s.lastSegment())});let s=this.getFieldsMap(t);this.applyChanges(s,r,n)}delete(e){let t=this.field(e.popLast());ez(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return eA(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let r=0;r<e.length;++r){let n=t.mapValue.fields[e.get(r)];ez(n)&&n.mapValue.fields||(n={mapValue:{fields:{}}},t.mapValue.fields[e.get(r)]=n),t=n}return t.mapValue.fields}applyChanges(e,t,r){for(let n of(j(t,(t,r)=>e[t]=r),r))delete e[n]}clone(){return new eW(eK(this.value))}}function eH(e,t){if(e.useProto3Json){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:e_(t)?"-0":t}}function eY(e){return{integerValue:""+e}}function eJ(e,t,r){return"number"==typeof t&&Number.isInteger(t)&&!e_(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER?eY(t):eH(e,t)}class eX{constructor(){this._=void 0}}class eZ extends eX{}class e0 extends eX{constructor(e){super(),this.elements=e}}function e1(e,t){let r=te(t);for(let t of e.elements)r.some(e=>eA(e,t))||r.push(t);return{arrayValue:{values:r}}}class e2 extends eX{constructor(e){super(),this.elements=e}}function e3(e,t){let r=te(t);for(let t of e.elements)r=r.filter(e=>!eA(e,t));return{arrayValue:{values:r}}}class e4 extends eX{constructor(e,t){super(),this.serializer=e,this.l=t}}class e6 extends e4{}class e8 extends e4{}class e5 extends e4{}function e9(e,t,r){if(!eF(t))return e.l;let n=r(e7(t),e7(e.l));return eU(t)&&eU(e.l)?eY(n):eH(e.serializer,n)}function e7(e){return eo(e.integerValue||e.doubleValue)}function te(e){return eq(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}class tt{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new tt}static exists(e){return new tt(void 0,e)}static updateTime(e){return new tt(e)}get isNone(){return void 0===this.updateTime&&void 0===this.exists}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function tr(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class tn{}function ts(e,t){if(!e.hasLocalMutations||t&&0===t.fields.length)return null;
1if(null===t)return e.isNoDocument()?new td(e.key,tt.none()):new to(e.key,e.data,tt.none());{let r=e.data,n=eW.empty(),s=new L($.comparator);for(let e of t.fields)if(!s.has(e)){let t=r.field(e);null===t&&e.length>1&&(e=e.popLast(),t=r.field(e)),null===t?n.delete(e):n.set(e,t),s=s.add(e)}return new tl(e.key,n,new B(s.toArray()),tt.none())}}function ti(e,t,r,n){return e instanceof to?function(e,t,r,n){if(!tr(e.precondition,t))return r;let s=e.value.clone(),i=th(e.fieldTransforms,n,t);return s.setAll(i),t.convertToFoundDocument(t.version,s).setHasLocalMutations(),null}(e,t,r,n):e instanceof tl?function(e,t,r,n){if(!tr(e.precondition,t))return r;let s=th(e.fieldTransforms,n,t),i=t.data;return(i.setAll(tu(e)),i.setAll(s),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null===r)?null:r.unionWith(e.fieldMask.fields).unionWith(e.fieldTransforms.map(e=>e.field))}(e,t,r,n):tr(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):r}function ta(e,t){var r,n;return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&(r=e.fieldTransforms,n=t.fieldTransforms,!!(void 0===r&&void 0===n||!(!r||!n)&&V(r,n,(e,t)=>{var r,n;return e.field.isEqual(t.field)&&(r=e.transform,n=t.transform,r instanceof e0&&n instanceof e0||r instanceof e2&&n instanceof e2?V(r.elements,n.elements,eA):r instanceof e6&&n instanceof e6||r instanceof e8&&n instanceof e8||r instanceof e5&&n instanceof e5?eA(r.l,n.l):r instanceof eZ&&n instanceof eZ)})))&&(0===e.type?e.value.isEqual(t.value):1!==e.type||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}class to extends tn{constructor(e,t,r,n=[]){super(),this.key=e,this.value=t,this.precondition=r,this.fieldTransforms=n,this.type=0}getFieldMask(){return null}}class tl extends tn{constructor(e,t,r,n,s=[]){super(),this.key=e,this.data=t,this.fieldMask=r,this.precondition=n,this.fieldTransforms=s,this.type=1}getFieldMask(){return this.fieldMask}}function tu(e){let t=new Map;return e.fieldMask.fields.forEach(r=>{if(!r.isEmpty()){let n=e.data.field(r);t.set(r,n)}}),t}function tc(e,t,r){let n=new Map;b(e.length===r.length,32656,{h:r.length,T:e.length});for(let i=0;i<r.length;i++){var s;let a=e[i],o=a.transform,l=t.data.field(a.field);n.set(a.field,(s=r[i],o instanceof e0?e1(o,l):o instanceof e2?e3(o,l):s))}return n}function th(e,t,r){let n=new Map;for(let s of e){let e=s.transform,i=r.data.field(s.field);n.set(s.field,function(e,t,r){var n,s,i;let a,o,l;return e instanceof eZ?(n=t,a={fields:{[ec]:{stringValue:eu},[ed]:{timestampValue:{seconds:r.seconds,nanos:r.nanoseconds}}}},n&&em(n)&&(n=ef(n)),n&&(a.fields[eh]=n),{mapValue:a}):e instanceof e0?e1(e,t):e instanceof e2?e3(e,t):e instanceof e6?(s=e,i=t,l=e7(o=s instanceof e6?eF(i)?i:{integerValue:0}:null)+e7(e.l),eU(o)&&eU(e.l)?eY(l):eH(e.serializer,l)):e instanceof e8?e9(e,t,Math.min):e instanceof e5?e9(e,t,Math.max):void 0}(e,i,t))}return n}class td extends tn{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class tm{constructor(e,t){this.position=e,this.inclusive=t}}function tf(e,t,r){let n=0;for(let s=0;s<e.position.length;s++){let i=t[s],a=e.position[s];if(n=i.field.isKeyField()?K.comparator(K.fromName(a.referenceValue),r.key):ek(a,r.data.field(i.field)),"desc"===i.dir&&(n*=-1),0!==n)break}return n}function tp(e,t){if(null===e)return null===t;if(null===t||e.inclusive!==t.inclusive||e.position.length!==t.position.length)return!1;for(let r=0;r<e.position.length;r++)if(!eA(e.position[r],t.position[r]))return!1;return!0}class tg{}class ty extends tg{constructor(e,t,r){super(),this.field=e,this.op=t,this.value=r}static create(e,t,r){return e.isKeyField()?"in"===t||"not-in"===t?this.createKeyFieldInFilter(e,t,r):new tE(e,t,r):"array-contains"===t?new tN(e,r):"in"===t?new tS(e,r):"not-in"===t?new tI(e,r):"array-contains-any"===t?new tC(e,r):new ty(e,t,r)}static createKeyFieldInFilter(e,t,r){return"in"===t?new tT(e,r):new tx(e,r)}matches(e){let t=e.data.field(this.field);return"!="===this.op?null!==t&&void 0===t.nullValue&&this.matchesComparison(ek(t,this.value)):null!==t&&eV(this.value)===eV(t)&&this.matchesComparison(ek(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return 0===e;case"!=":return 0!==e;case">":return e>0;case">=":return e>=0;default:return T(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class tw extends tg{constructor(e,t){super(),this.filters=e,this.op=t,this.P=null}static create(e,t){return new tw(e,t)}matches(e){return tv(this)?void 0===this.filters.find(t=>!t.matches(e)):void 0!==this.filters.find(t=>t.matches(e))}getFlattenedFilters(){return null!==this.P||(this.P=this.filters.reduce((e,t)=>
1e.concat(t.getFlattenedFilters()),[])),this.P}getFilters(){return Object.assign([],this.filters)}}function tv(e){return"and"===e.op}function t_(e){for(let t of e.filters)if(t instanceof tw)return!1;return!0}class tE extends ty{constructor(e,t,r){super(e,t,r),this.key=K.fromName(r.referenceValue)}matches(e){let t=K.comparator(e.key,this.key);return this.matchesComparison(t)}}class tT extends ty{constructor(e,t){super(e,"in",t),this.keys=tb("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}}class tx extends ty{constructor(e,t){super(e,"not-in",t),this.keys=tb("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}}function tb(e,t){return(t.arrayValue?.values||[]).map(e=>K.fromName(e.referenceValue))}class tN extends ty{constructor(e,t){super(e,"array-contains",t)}matches(e){let t=e.data.field(this.field);return eq(t)&&eD(t.arrayValue,this.value)}}class tS extends ty{constructor(e,t){super(e,"in",t)}matches(e){let t=e.data.field(this.field);return null!==t&&eD(this.value.arrayValue,t)}}class tI extends ty{constructor(e,t){super(e,"not-in",t)}matches(e){if(eD(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;let t=e.data.field(this.field);return null!==t&&void 0===t.nullValue&&!eD(this.value.arrayValue,t)}}class tC extends ty{constructor(e,t){super(e,"array-contains-any",t)}matches(e){let t=e.data.field(this.field);return!(!eq(t)||!t.arrayValue.values)&&t.arrayValue.values.some(e=>eD(this.value.arrayValue,e))}}class tV{constructor(e,t="asc"){this.field=e,this.dir=t}}class tA{static fromTimestamp(e){return new tA(e)}static min(){return new tA(new er(0,0))}static max(){return new tA(new er(0x3afff4417f,0x3b9ac9ff))}constructor(e){this.timestamp=e}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}class tD{constructor(e,t,r,n,s,i,a){this.key=e,this.documentType=t,this.version=r,this.readTime=n,this.createTime=s,this.data=i,this.documentState=a}static newInvalidDocument(e){return new tD(e,0,tA.min(),tA.min(),tA.min(),eW.empty(),0)}static newFoundDocument(e,t,r,n){return new tD(e,1,t,tA.min(),r,n,0)}static newNoDocument(e,t){return new tD(e,2,t,tA.min(),tA.min(),eW.empty(),0)}static newUnknownDocument(e,t){return new tD(e,3,t,tA.min(),tA.min(),eW.empty(),2)}convertToFoundDocument(e,t){return this.createTime.isEqual(tA.min())&&(2===this.documentType||0===this.documentType)&&(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=eW.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=eW.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=tA.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return 1===this.documentState}get hasCommittedMutations(){return 2===this.documentState}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return 0!==this.documentType}isFoundDocument(){return 1===this.documentType}isNoDocument(){return 2===this.documentType}isUnknownDocument(){return 3===this.documentType}isEqual(e){return e instanceof tD&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new tD(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}class tk{constructor(e,t,r,n){this.indexId=e,this.collectionGroup=t,this.fields=r,this.indexState=n}}tk.UNKNOWN_ID=-1;class tL{constructor(e,t,r){this.readTime=e,this.documentKey=t,this.largestBatchId=r}static min(){return new tL(tA.min(),K.empty(),-1)}static max(){return new tL(tA.max(),K.empty(),-1)}}class tR{constructor(e,t=null,r=[],n=[],s=null,i=null,a=null){this.path=e,this.collectionGroup=t,this.orderBy=r,this.filters=n,this.limit=s,this.startAt=i,this.endAt=a,this.R=null}}function tO(e,t=null,r=[],n=[],s=null,i=null,a=null){return new tR(e,t,r,n,s,i,a)}function tP(e){if(null===e.R){let t=e.path.canonicalString();null!==e.collectionGroup&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(e=>(function e(t){if(t instanceof ty)return t.field.canonicalString()+t.op.toString()+eO(t.value);if(t_(t)&&tv(t))return t.filters.map(t=>e(t)).join(",");{let r=t.filters.map(t=>e(t)).join(",");return`${t.op}(${r})`}})(e)).join(","),t+="|ob:",t+=e.orderBy.map(e=>e.field.canonicalString()+e.dir).join(","),null==e.limit||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(e=>eO(e)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(e=>eO(e)).join(",")),e.R=t}return e.R}function tU(e,t){if(e.limit!==t.limit||e.orderBy.length!==t.orderBy.length)return!1;for(let s=0;s<e.orderBy.length;s++){var r,n;if(r=e.orderBy[s],n=t.orderBy[s],!(r.dir===n.dir&&r.field.isEqual(n.field)))return!1}if(e.filters.length!==t.filters.length)return!1;for(let r=0;r<e.filters.length;r++)if(!function e(t,r){return t instanceof ty?r instanceof ty&&t.op===r.op&&t.field.isEqual(r.field)&&eA(t.value,r.value):t instanceof tw?r instanceof tw&&t.op===r.op&&t.filters.length===r.filters.length&&t.filters.reduce((t,n,s)=>t&&e(n,r.filters[s]),!0):void T(19439)}(e.filters[r],t.filters[r]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!tp(e.startAt,t.startAt)&&tp(e.endAt,t.endAt)}function tM(e){return!!e.isCorePipeline}function tF(e){return!!e.path&&K.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}class tq{constructor(e,t=null,r=[],n=[],s=null,i="F",a=null,o=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=n,this.limit=s,this.limitType=i,this.startAt=a,this.endAt=o,this.I=null,this.A=null,this.V=null,this.startAt,this.endAt}}function t$(e){return new tq(e)}function tB(e){return 0===e.filters.length&&null===e.limit&&null==e.startAt&&null==e.endAt&&(0===e.explicitOrderBy.length||1===e.explicitOrderBy.length&&e.explicitOrderBy[0].field.isKeyField())}function tz(e){return null!==e.collectionGroup}function tj(e){if(null===e.I){let t;e.I=[];let r=new Set;for(let t of e.explicitOrderBy)e.I.push(t),r.add(t.field.canonicalString());let n=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";
1(t=new L($.comparator),e.filters.forEach(e=>{e.getFlattenedFilters().forEach(e=>{e.isInequality()&&(t=t.add(e.field))})}),t).forEach(t=>{r.has(t.canonicalString())||t.isKeyField()||e.I.push(new tV(t,n))}),r.has($.keyField().canonicalString())||e.I.push(new tV($.keyField(),n))}return e.I}function tG(e){return e.A||(e.A=function(e,t){if("F"===e.limitType)return tO(e.path,e.collectionGroup,t,e.filters,e.limit,e.startAt,e.endAt);{t=t.map(e=>{let t="desc"===e.dir?"asc":"desc";return new tV(e.field,t)});let r=e.endAt?new tm(e.endAt.position,e.endAt.inclusive):null,n=e.startAt?new tm(e.startAt.position,e.startAt.inclusive):null;return tO(e.path,e.collectionGroup,t,e.filters,e.limit,r,n)}}(e,tj(e))),e.A}function tK(e,t){let r=e.filters.concat([t]);return new tq(e.path,e.collectionGroup,e.explicitOrderBy.slice(),r,e.limit,e.limitType,e.startAt,e.endAt)}function tQ(e,t){let r=e.explicitOrderBy.concat([t]);return new tq(e.path,e.collectionGroup,r,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}function tW(e,t,r){return new tq(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,r,e.startAt,e.endAt)}function tH(e,t){return new tq(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,t,e.endAt)}function tY(e,t){return new tq(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,t)}function tJ(e){var t;let r;return`Query(target=${r=(t=tG(e)).path.canonicalString(),null!==t.collectionGroup&&(r+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(r+=`, filters: [${t.filters.map(e=>(function e(t){return t instanceof ty?`${t.field.canonicalString()} ${t.op} ${eO(t.value)}`:t instanceof tw?t.op.toString()+" {"+t.getFilters().map(e).join(" ,")+"}":"Filter"})(e)).join(", ")}]`),null==t.limit||(r+=", limit: "+t.limit),t.orderBy.length>0&&(r+=`, orderBy: [${t.orderBy.map(e=>`${e.field.canonicalString()} (${e.dir})`).join(", ")}]`),t.startAt&&(r+=", startAt: ",r+=t.startAt.inclusive?"b:":"a:",r+=t.startAt.position.map(e=>eO(e)).join(",")),t.endAt&&(r+=", endAt: ",r+=t.endAt.inclusive?"a:":"b:",r+=t.endAt.position.map(e=>eO(e)).join(",")),`Target(${r})`}; limitType=${e.limitType})`}function tX(e,t){var r,n,s,i;let a,o,l;return t.isFoundDocument()&&(a=t.key.path,null!==e.collectionGroup?t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(a):K.isDocumentKey(e.path)?e.path.isEqual(a):e.path.isImmediateParentOf(a))&&function(e,t){for(let r of tj(e))if(!r.field.isKeyField()&&null===t.data.field(r.field))return!1;return!0}(e,t)&&function(e,t){for(let r of e.filters)if(!r.matches(t))return!1;return!0}(e,t)&&(r=e,n=t,(!r.startAt||(s=r.startAt,o=tf(s,tj(r),n),s.inclusive?!!(o<=0):!!(o<0)))&&(!r.endAt||(i=r.endAt,l=tf(i,tj(r),n),i.inclusive?!!(l>=0):!!(l>0))))}function tZ(e){return(t,r)=>{let n=!1;for(let s of tj(e)){let e=function(e,t,r){var n;let s,i,a=e.field.isKeyField()?K.comparator(t.key,r.key):(n=e.field,s=t.data.field(n),i=r.data.field(n),null!==s&&null!==i?ek(s,i):T(42886));switch(e.dir){case"asc":return a;case"desc":return -1*a;default:return T(19790,{direction:e.dir})}}(s,t,r);if(0!==e)return e;n=n||s.field.isKeyField()}return 0}}class t0{constructor(e,t){this.count=e,this.unchangedNames=t}}function t1(e){if(void 0===e)return v("GRPC error has no .code"),O.UNKNOWN;switch(e){case s.OK:return O.OK;case s.CANCELLED:return O.CANCELLED;case s.UNKNOWN:return O.UNKNOWN;case s.DEADLINE_EXCEEDED:return O.DEADLINE_EXCEEDED;case s.RESOURCE_EXHAUSTED:return O.RESOURCE_EXHAUSTED;case s.INTERNAL:return O.INTERNAL;case s.UNAVAILABLE:return O.UNAVAILABLE;case s.UNAUTHENTICATED:return O.UNAUTHENTICATED;case s.INVALID_ARGUMENT:return O.INVALID_ARGUMENT;case s.NOT_FOUND:return O.NOT_FOUND;case s.ALREADY_EXISTS:return O.ALREADY_EXISTS;case s.PERMISSION_DENIED:return O.PERMISSION_DENIED;case s.FAILED_PRECONDITION:return O.FAILED_PRECONDITION;case s.ABORTED:return O.ABORTED;case s.OUT_OF_RANGE:return O.OUT_OF_RANGE;case s.UNIMPLEMENTED:return O.UNIMPLEMENTED;case s.DATA_LOSS:return O.DATA_LOSS;default:return T(39323,{code:e})}}(i=s||(s={}))[i.OK=0]="OK",i[i.CANCELLED=1]="CANCELLED",i[i.UNKNOWN=2]="UNKNOWN",i[i.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",i[i.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",i[i.NOT_FOUND=5]="NOT_FOUND",i[i.ALREADY_EXISTS=6]="ALREADY_EXISTS",i[i.PERMISSION_DENIED=7]="PERMISSION_DENIED",i[i.UNAUTHENTICATED=16]="UNAUTHENTICATED",i[i.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",i[i.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",i[i.ABORTED=10]="ABORTED",i[i.OUT_OF_RANGE=11]="OUT_OF_RANGE",i[i.UNIMPLEMENT
1ED=12]="UNIMPLEMENTED",i[i.INTERNAL=13]="INTERNAL",i[i.UNAVAILABLE=14]="UNAVAILABLE",i[i.DATA_LOSS=15]="DATA_LOSS";class t2{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){let t=this.mapKeyFn(e),r=this.inner[t];if(void 0!==r){for(let[t,n]of r)if(this.equalsFn(t,e))return n}}has(e){return void 0!==this.get(e)}set(e,t){let r=this.mapKeyFn(e),n=this.inner[r];if(void 0===n)return this.inner[r]=[[e,t]],void this.innerSize++;for(let r=0;r<n.length;r++)if(this.equalsFn(n[r][0],e))return void(n[r]=[e,t]);n.push([e,t]),this.innerSize++}delete(e){let t=this.mapKeyFn(e),r=this.inner[t];if(void 0===r)return!1;for(let n=0;n<r.length;n++)if(this.equalsFn(r[n][0],e))return 1===r.length?delete this.inner[t]:r.splice(n,1),this.innerSize--,!0;return!1}forEach(e){j(this.inner,(t,r)=>{for(let[t,n]of r)e(t,n)})}isEmpty(){return G(this.inner)}size(){return this.innerSize}}let t3=new A(K.comparator),t4=new A(K.comparator);function t6(...e){let t=t4;for(let r of e)t=t.insert(r.key,r);return t}function t8(){return new t2(e=>e.toString(),(e,t)=>e.isEqual(t))}new A(K.comparator);let t5=new L(K.comparator);function t9(...e){let t=t5;for(let r of e)t=t.add(r);return t}let t7=new L(S),re=new u.jz([0xffffffff,0xffffffff],0);function rt(e){let t=(new TextEncoder).encode(e),r=new u.VV;return r.update(t),new Uint8Array(r.digest())}function rr(e){let t=new DataView(e.buffer),r=t.getUint32(0,!0),n=t.getUint32(4,!0),s=t.getUint32(8,!0),i=t.getUint32(12,!0);return[new u.jz([r,n],0),new u.jz([s,i],0)]}class rn{constructor(e,t,r){if(this.bitmap=e,this.padding=t,this.hashCount=r,t<0||t>=8)throw new rs(`Invalid padding: ${t}`);if(r<0||e.length>0&&0===this.hashCount)throw new rs(`Invalid hash count: ${r}`);if(0===e.length&&0!==t)throw new rs(`Invalid padding when bitmap length is 0: ${t}`);this.m=8*e.length-t,this.p=u.jz.fromNumber(this.m)}S(e,t,r){let n=e.add(t.multiply(u.jz.fromNumber(r)));return 1===n.compare(re)&&(n=new u.jz([n.getBits(0),n.getBits(1)],0)),n.modulo(this.p).toNumber()}v(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(0===this.m)return!1;let[t,r]=rr(rt(e));for(let e=0;e<this.hashCount;e++){let n=this.S(t,r,e);if(!this.v(n))return!1}return!0}static create(e,t,r){let n=new rn(new Uint8Array(Math.ceil(e/8)),e%8==0?0:8-e%8,t);return r.forEach(e=>n.insert(e)),n}insert(e){if(0===this.m)return;let[t,r]=rr(rt(e));for(let e=0;e<this.hashCount;e++){let n=this.S(t,r,e);this.D(n)}}D(e){let t=Math.floor(e/8);this.bitmap[t]|=1<<e%8}}class rs extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class ri{constructor(e,t,r,n,s,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=r,this.documentUpdates=n,this.augmentedDocumentUpdates=s,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(e,t,r){let n=new Map;return n.set(e,ra.createSynthesizedTargetChangeForCurrentChange(e,t,r)),new ri(tA.min(),n,new A(S),t3,t3,t9())}}class ra{constructor(e,t,r,n,s){this.resumeToken=e,this.current=t,this.addedDocuments=r,this.modifiedDocuments=n,this.removedDocuments=s}static createSynthesizedTargetChangeForCurrentChange(e,t,r){return new ra(r,t,t9(),t9(),t9())}}class ro{constructor(e,t,r,n){this.C=e,this.removedTargetIds=t,this.key=r,this.F=n}}class rl{constructor(e,t){this.targetId=e,this.O=t}}class ru{constructor(e,t,r=es.EMPTY_BYTE_STRING,n=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=n}}class rc{constructor(e){this.targetId=e,this.M=0,this.N=rf(),this.L=es.EMPTY_BYTE_STRING,this.B=!1,this.U=!0}get current(){return this.B}get resumeToken(){return this.L}get k(){return 0!==this.M}get q(){return this.U}$(e){e.approximateByteSize()>0&&(this.U=!0,this.L=e)}K(){let e=t9(),t=t9(),r=t9();return this.N.forEach((n,s)=>{switch(s){case 0:e=e.add(n);break;case 2:t=t.add(n);break;case 1:r=r.add(n);break;default:T(38017,{changeType:s})}}),new ra(this.L,this.B,e,t,r)}W(){this.U=!1,this.N=rf()}G(e,t){this.U=!0,this.N=this.N.insert(e,t)}j(e){this.U=!0,this.N=this.N.remove(e)}H(){this.M+=1}J(){this.M-=1,b(this.M>=0,3241,{M:this.M,targetId:this.targetId})}Y(){this.U=!0,this.B=!0}}let rh="WatchChangeAggregator";class rd{constructor(e){this.Z=e,this.X=new Map,this.ee=t3,this.te=rm(),this.ne=t3,this.re=rm(),this.ie=new A(S)}se(e){for(let t of e.C)e.F&&e.F.isFoundDocument()?this._e(t,e.F):this.oe(t,e.key,e.F);for(let t of e.removedTargetIds)this.oe(t,e.key,e.F)}ae(e){this.forEachTarget(e,t=>{let r=this.X.get(t);if(r)switch(e.state){case 0:this.ue(t)&&r.$(e.resumeToken);break;case 1:r.J(),r.k||r.W(),r.$(e.resumeToken);break;case 2:r.J(),r.k||this.removeTarget(t);break;case 3:this.ue(t)&&(r.Y(),r.$(e.resumeToken));break;case 4:this.ue(t)&&(this.ce(t),r.$(e.resumeToken));break;default:T(56790,{state:e.state})}else w(rh,`handleTargetChange received targetChange for untracked target ID (${t}) with state (${e.state})`)})}forEachTarget(e,t){e.targetIds.length>
10?e.targetIds.forEach(t):this.X.forEach((e,r)=>{this.ue(r)&&t(r)})}le(e){return tM(e)?"documents"===e.getPipelineSourceType()&&1===e.getPipelineDocuments()?.length:tF(e)}Ee(e){let t=e.targetId,r=e.O.count,n=this.he(t);if(n){let s=n.target;if(this.le(s))if(0===r){let e=new K(tM(s)?F.fromString(s.getPipelineDocuments()[0]):s.path);this.oe(t,e,tD.newNoDocument(e,tA.min()))}else b(1===r,20013,"Single document existence filter with count: "+r);else{let n=this.Te(t);if(n!==r){let r=this.Pe(e),s=r?this.Re(r,e,n):1;0!==s&&(this.ce(t),this.ie=this.ie.insert(t,2===s?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch"))}}}}Pe(e){let t,r,n=e.O.unchangedNames;if(!n||!n.bits)return null;let{bits:{bitmap:s="",padding:i=0},hashCount:a=0}=n;try{t=el(s).toUint8Array()}catch(e){if(e instanceof en)return _("Decoding the base64 bloom filter in existence filter failed ("+e.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw e}try{r=new rn(t,i,a)}catch(e){return _(e instanceof rs?"BloomFilter error: ":"Applying bloom filter failed: ",e),null}return 0===r.m?null:r}Re(e,t,r){return 2*(t.O.count!==r-this.Ve(e,t.targetId))}Ve(e,t){let r=this.Z.getRemoteKeysForTarget(t),n=0;return r.forEach(r=>{let s=this.Z.Ae(),i=`projects/${s.projectId}/databases/${s.database}/documents/${r.path.canonicalString()}`;e.mightContain(i)||(this.oe(t,r,null),n++)}),n}de(e){let t=new Map;this.X.forEach((r,n)=>{let s=this.he(n);if(s){if(r.current&&this.le(s.target)){let t=new K(tM(s.target)?F.fromString(s.target.getPipelineDocuments()[0]):s.target.path);this.fe(t).has(n)||this.me(n,t)||this.oe(n,t,tD.newNoDocument(t,e))}r.q&&(t.set(n,r.K()),r.W())}});let r=t9();this.re.forEach((e,t)=>{let n=!0;t.forEachWhile(e=>{let t=this.he(e);return!t||"TargetPurposeLimboResolution"===t.purpose||(n=!1,!1)}),n&&(r=r.add(e))}),this.ee.forEach((t,r)=>r.setReadTime(e)),this.ne.forEach((t,r)=>r.setReadTime(e));let n=new ri(e,t,this.ie,this.ee,this.ne,r);return this.ee=t3,this.te=rm(),this.ne=t3,this.re=rm(),this.ie=new A(S),n}_e(e,t){let r=this.X.get(e);if(!r||!this.ue(e))return void w(rh,`addDocumentToTarget received document for unknown inactive target (${e})`);let n=2*!!this.me(e,t.key);r.G(t.key,n),tM(this.he(e).target)&&"exact"!==this.he(e).target.getPipelineFlavor()?this.ne=this.ne.insert(t.key,t):this.ee=this.ee.insert(t.key,t),this.te=this.te.insert(t.key,this.fe(t.key).add(e)),this.re=this.re.insert(t.key,this.pe(t.key).add(e))}oe(e,t,r){let n=this.X.get(e);n&&this.ue(e)?(this.me(e,t)?n.G(t,1):n.j(t),this.re=this.re.insert(t,this.pe(t).delete(e)),this.re=this.re.insert(t,this.pe(t).add(e)),r&&(tM(this.he(e).target)&&"exact"!==this.he(e).target.getPipelineFlavor()?this.ne=this.ne.insert(t,r):this.ee=this.ee.insert(t,r))):w(rh,`removeDocumentFromTarget received document for unknown or inactive target (${e})`)}removeTarget(e){this.X.delete(e)}Te(e){let t=this.X.get(e);if(!t)return 0;let r=t.K();return this.Z.getRemoteKeysForTarget(e).size+r.addedDocuments.size-r.removedDocuments.size}H(e){let t=this.X.get(e);t||(w(rh,`recordPendingTargetRequest set up tracking for target ID ${e}`),t=new rc(e),this.X.set(e,t)),t.H()}pe(e){let t=this.re.get(e);return t||(t=new L(S),this.re=this.re.insert(e,t)),t}fe(e){let t=this.te.get(e);return t||(t=new L(S),this.te=this.te.insert(e,t)),t}ue(e){let t=null!==this.he(e);return t||w(rh,"Detected inactive target",e),t}he(e){let t=this.X.get(e);return void 0===t||t.k?null:this.Z.ge(e)}ce(e){this.X.set(e,new rc(e)),this.Z.getRemoteKeysForTarget(e).forEach(t=>{this.oe(e,t,null)})}me(e,t){return this.Z.getRemoteKeysForTarget(e).has(t)}}function rm(){return new A(K.comparator)}function rf(){return new A(K.comparator)}let rp={asc:"ASCENDING",desc:"DESCENDING"},rg={"<":"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"},ry={and:"AND",or:"OR"};class rw{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function rv(e,t){return e.useProto3Json||null==t?t:{value:t}}function r_(e,t){return e.useProto3Json?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function rE(e){let t=ea(e);return new er(t.seconds,t.nanos)}function rT(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function rx(e,t){return r_(e,t.toTimestamp())}function rb(e){return b(!!e,49232),tA.fromTimestamp(rE(e))}function rN(e,t){return rS(e,t).canonicalString()}function rS(e,t){let r=new F(["projects",e.projectId,"databases",e.database]).child("documents");return void 0===t?r:r.child(t)}function rI(e){let t=F.fromString(e);
1return b(rR(t),10190,{key:t.toString()}),t}function rC(e,t){let r=rI(t);if(r.get(1)!==e.databaseId.projectId)throw new P(O.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+r.get(1)+" vs "+e.databaseId.projectId);if(r.get(3)!==e.databaseId.database)throw new P(O.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+r.get(3)+" vs "+e.databaseId.database);return new K(rD(r))}function rV(e,t){return rN(e.databaseId,t)}function rA(e){return new F(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function rD(e){return b(e.length>4&&"documents"===e.get(4),29091,{key:e.toString()}),e.popFirst(5)}function rk(e){return{fieldPath:e.canonicalString()}}function rL(e){return $.fromServerFormat(e.fieldPath)}function rR(e){return e.length>=4&&"projects"===e.get(0)&&"databases"===e.get(2)}function rO(e){return!!e&&"function"==typeof e._toProto&&"ProtoValue"===e._protoValueType}function rP(e,t){let r={fields:{}};return t.forEach((t,n)=>{if("string"!=typeof n)throw Error(`Cannot encode map with non-string key: ${n}`);r.fields[n]=t._toProto(e)}),{mapValue:r}}function rU(e){return{stringValue:e}}function rM(e){return new rw(e,!0)}class rF{constructor(e){this._byteString=e}static fromBase64String(e){try{return new rF(es.fromBase64String(e))}catch(e){throw new P(O.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new rF(es.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}toJSON(){return{type:rF._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(et(e,rF._jsonSchema))return rF.fromBase64String(e.bytes)}}rF._jsonSchemaVersion="firestore/bytes/1.0",rF._jsonSchema={type:ee("string",rF._jsonSchemaVersion),bytes:ee("string")};class rq{constructor(...e){for(let t=0;t<e.length;++t)if(0===e[t].length)throw new P(O.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new $(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}class r${constructor(e){this._methodName=e}}class rB{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new P(O.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new P(O.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}_compareTo(e){return S(this._lat,e._lat)||S(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:rB._jsonSchemaVersion}}static fromJSON(e){if(et(e,rB._jsonSchema))return new rB(e.latitude,e.longitude)}}rB._jsonSchemaVersion="firestore/geoPoint/1.0",rB._jsonSchema={type:ee("string",rB._jsonSchemaVersion),latitude:ee("number"),longitude:ee("number")};class rz{constructor(e){this.uid=e}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}rz.UNAUTHENTICATED=new rz(null),rz.GOOGLE_CREDENTIALS=new rz("google-credentials-uid"),rz.FIRST_PARTY=new rz("first-party-uid"),rz.MOCK_USER=new rz("mock-user");class rj{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}class rG{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class rK{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(rz.UNAUTHENTICATED))}shutdown(){}}class rQ{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable(()=>t(this.token.user))}shutdown(){this.changeListener=null}}class rW{constructor(e){this.ve=e,this.currentUser=rz.UNAUTHENTICATED,this.De=0,this.forceRefresh=!1,this.auth=null}start(e,t){b(void 0===this.xe,42304);let r=this.De,n=e=>this.De!==r?(r=this.De,t(e)):Promise.resolve(),s=new rj;this.xe=()=>{this.De++,this.currentUser=this.Ce(),s.resolve(),s=new rj,e.enqueueRetryable(()=>n(this.currentUser))};let i=()=>{let t=s;e.enqueueRetryable(async()=>{await t.promise,await n(this.currentUser)})},a=e=>{w("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=e,this.xe&&(this.auth.addAuthTokenListener(this.xe),i())};this.ve.onInit(e=>a(e)),setTimeout(()=>{if(!this.auth){let e=this.ve.getImmediate({optional:!0});e?a(e):(w("FirebaseAuthCredentialsProvider","Auth not yet detected"),s.resolve(),s=new rj)}},0),i()}getToken(){let e=this.De,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(t=>this.De!==e?(w("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):t?(b("string"==typeof t.accessToken,31837,{Fe:t}),new rG(t.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.xe&&this.auth.removeAuthTokenListener(this.xe),this.xe=void 0}Ce(){let e=this.auth&&this.auth.getUid();return b(null===e||"string"==typeof e,2055,{Oe:e}),new rz(e)}}class rH{constructor(e,t,r){this.Me=e,this.Ne=t,this.Le=r,this.type="FirstParty",this.user=rz.FIRST_PARTY,this.Be=new Map}Ue(){return this.Le?this.Le():null}get headers(){this.Be.set("X-Goog-AuthUser",this.Me);let e=this.Ue();return e&&this.Be.set("Authorization",e),this.Ne&&this.Be.set("X-Goog-Iam-Authorization-Token",this.Ne),this.Be}}class rY{constructor(e,t,r){this.Me=e,this.Ne=t,this.Le=r}getToken(){return Promise.resolve(new rH(this.Me,this.Ne,this.Le))}start(e,t){e.enqueueRetryable(()=>t(rz.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class rJ{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class rX{constructor(e,t){this.ke=t,this.forceRefresh=!1,this.appCheck=null,this.qe=null,this.$e=null,(0,o.xZ)(e)&&e.settings.appCheckToken&&(this.$e=e.settings.appCheckToken)}start(e,t){b(void 0===this.xe,3512);let r=e=>{null!=e.error&&w("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`);let r=e.token!==this.qe;return this.qe=e.token,w("FirebaseAppCheckTokenProvider",`Received ${r?"new":"existing"} token.`),r?t(e.token):Promise.resolve()};this.xe=t=>{e.enqueueRetryable(()=>r(t))};let n=e=>{w("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=e,this.xe&&this.appCheck.addTokenListener(this.xe)};this.ke.onInit(e=>n(e)),setTimeout(()=>{if(!this.appCheck){let e=this.ke.getImmediate({optional:!0});e?n(e):w("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.$e)return Promise.resolve(new rJ(this.$e));let e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(e=>e?(b("string"==typeof e.token,44558,{tokenResult:e}),this.qe=e.token,new rJ(e.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.xe&&this.appCheck.removeTokenListener(this.xe),this.xe=void 0}}function rZ(e){let t={};return void 0!==e.timeoutSeconds&&(t.timeoutSeconds=e.timeoutSeconds),t}class r0{Ke(e){}shutdown(){}}let r1="ConnectivityMonitor";class r2{constructor(){this.Qe=()=>this.We(),this.Ge=()=>this.ze(),this.je=[],this.He()}Ke(e){this.je.push(e)}shutdown(){window.removeEventListener("online",this.Qe),window.removeEventListener("offline",this.Ge)}He(){window.addEventListener("online",this.Qe),window.addEventListener("offline",this.Ge)}We(){for(let e of(w(r1,"Network connectivity changed: AVAILABLE"),this.je))e(0)}ze(){for(let e of(w(r1,"Network connectivity changed: UNAVAILABLE"),this.je))e(1)}static Je(){return"u">typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}let r3=null;function r4(){return null===r3?r3=0x10000000+Math.round(0x80000000*Math.random()):r3++,"0x"+r3.toString(16)}let r6="RestConnection",r8={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregation
1Query:"runAggregationQuery",ExecutePipeline:"executePipeline"};class r5{get Ye(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),n=encodeURIComponent(this.databaseId.database);this.Ze=t+"://"+e.host,this.Xe=`projects/${r}/databases/${n}`,this.et=this.databaseId.database===ey?`project_id=${r}`:`project_id=${r}&database_id=${n}`}tt(e,t,r,n,s){let i=r4(),a=this.nt(e,t.toUriEncodedString());w(r6,`Sending RPC '${e}' ${i}:`,a,r);let o={"google-cloud-resource-prefix":this.Xe,"x-goog-request-params":this.et};this.rt(o,n,s);let{host:u}=new URL(a),c=(0,l.zJ)(u);return this.it(e,a,o,r,c).then(t=>(w(r6,`Received RPC '${e}' ${i}: `,t),t),t=>{throw _(r6,`RPC '${e}' ${i} failed with error: `,t,"url: ",a,"request:",r),t})}st(e,t,r,n,s,i){return this.tt(e,t,r,n,s)}rt(e,t,r){if(e["X-Goog-Api-Client"]="gl-js/ fire/"+f,e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach((t,r)=>e[r]=t),r&&r.headers.forEach((t,r)=>e[r]=t),this.databaseInfo._customHeaders)for(let t of Object.keys(this.databaseInfo._customHeaders))e[t]=this.databaseInfo._customHeaders[t]}nt(e,t){let r=r8[e],n=`${this.Ze}/v1/${t}:${r}`;return this.databaseInfo.apiKey&&(n=`${n}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),n}terminate(){}}class r9{constructor(e){this._t=e._t,this.ot=e.ot}ut(e){this.ct=e}lt(e){this.Et=e}ht(e){this.Tt=e}onMessage(e){this.Pt=e}close(){this.ot()}send(e){this._t(e)}Rt(){this.ct()}It(){this.Et()}At(e){this.Tt(e)}Vt(e){this.Pt(e)}}let r7="WebChannelConnection",ne=(e,t,r)=>{e.listen(t,e=>{try{r(e)}catch(e){setTimeout(()=>{throw e},0)}})};class nt extends r5{constructor(e){super(e),this.dt=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}static ft(){nt.gt||(ne((0,h.Ao)(),h.Jh.STAT_EVENT,e=>{e.stat===h.ro.PROXY?w(r7,"STAT_EVENT: detected buffering proxy"):e.stat===h.ro.NOPROXY&&w(r7,"STAT_EVENT: detected no buffering proxy")}),nt.gt=!0)}it(e,t,r,n,s){let i=r4();return new Promise((s,a)=>{let o=new h.ZS;o.setWithCredentials(!0),o.listenOnce(h.Bx.COMPLETE,()=>{try{switch(o.getLastErrorCode()){case h.O4.NO_ERROR:let t=o.getResponseJson();w(r7,`XHR for RPC '${e}' ${i} received:`,JSON.stringify(t)),s(t);break;case h.O4.TIMEOUT:w(r7,`RPC '${e}' ${i} timed out`),a(new P(O.DEADLINE_EXCEEDED,"Request time out"));break;case h.O4.HTTP_ERROR:let r=o.getStatus();if(w(r7,`RPC '${e}' ${i} failed with status:`,r,"response text:",o.getResponseText()),r>0){let e=o.getResponseJson();Array.isArray(e)&&(e=e[0]);let t=e?.error;if(t&&t.status&&t.message){let e,r=(e=t.status.toLowerCase().replace(/_/g,"-"),Object.values(O).indexOf(e)>=0?e:O.UNKNOWN);a(new P(r,t.message))}else a(new P(O.UNKNOWN,"Server responded with status "+o.getStatus()))}else a(new P(O.UNAVAILABLE,"Connection failed."));break;default:T(9055,{yt:e,streamId:i,wt:o.getLastErrorCode(),bt:o.getLastError()})}}finally{w(r7,`RPC '${e}' ${i} completed.`)}});let l=JSON.stringify(n);w(r7,`RPC '${e}' ${i} sending request:`,n),o.send(t,"POST",l,r,15)})}St(e,t,r){let n=r4(),i=[this.Ze,"/","google.firestore.v1.Firestore","/",e,"/channel"],a=this.createWebChannelTransport(),o={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},l=this.longPollingOptions.timeoutSeconds;void 0!==l&&(o.longPollingTimeout=Math.round(1e3*l)),this.useFetchStreams&&(o.useFetchStreams=!0),this.rt(o.initMessageHeaders,t,r),o.encodeInitMessageHeaders=!0;let u=i.join("");w(r7,`Creating RPC '${e}' stream ${n}: ${u}`,o);let c=a.createWebChannel(u,o);this.vt(c);let d=!1,m=!1,f=new r9({_t:t=>{m?w(r7,`Not sending because RPC '${e}' stream ${n} is closed:`,t):(d||(w(r7,`Opening RPC '${e}' stream ${n} transport.`),c.open(),d=!0),w(r7,`RPC '${e}' stream ${n} sending:`,t),c.send(t))},ot:()=>c.close()});return ne(c,h.iO.EventType.OPEN,()=>{m||(w(r7,`RPC '${e}' stream ${n} transport opened.`),f.Rt())}),ne(c,h.iO.EventType.CLOSE,()=>{m||(m=!0,w(r7,`RPC '${e}' stream ${n} transport closed`),f.At(),this.Dt(c))}
1),ne(c,h.iO.EventType.ERROR,t=>{m||(m=!0,_(r7,`RPC '${e}' stream ${n} transport errored. Name:`,t.name,"Message:",t.message),f.At(new P(O.UNAVAILABLE,"The operation could not be completed")))}),ne(c,h.iO.EventType.MESSAGE,t=>{if(!m){let r=t.data[0];b(!!r,16349);let i=r?.error||r[0]?.error;if(i){w(r7,`RPC '${e}' stream ${n} received error:`,i);let t=i.status,r=function(e){let t=s[e];if(void 0!==t)return t1(t)}(t),a=i.message;"NOT_FOUND"===t&&a.includes("database")&&a.includes("does not exist")&&a.includes(this.databaseId.database)&&_(`Database '${this.databaseId.database}' not found. Please check your project configuration.`),void 0===r&&(r=O.INTERNAL,a="Unknown error status: "+t+" with message "+i.message),m=!0,f.At(new P(r,a)),c.close()}else w(r7,`RPC '${e}' stream ${n} received:`,r),f.Vt(r)}}),nt.ft(),setTimeout(()=>{f.It()},0),f}terminate(){this.dt.forEach(e=>e.close()),this.dt=[]}vt(e){this.dt.push(e)}Dt(e){this.dt=this.dt.filter(t=>t===e)}rt(e,t,r){super.rt(e,t,r),this.databaseInfo.apiKey&&(e["x-goog-api-key"]=this.databaseInfo.apiKey)}createWebChannelTransport(){return(0,h.fF)()}}nt.gt=!1;class nr{constructor(e,t,r=1e3,n=1.5,s=6e4){this.xt=e,this.timerId=t,this.Ct=r,this.Ft=n,this.Ot=s,this.Mt=0,this.Nt=null,this.Lt=Date.now(),this.reset()}reset(){this.Mt=0}Bt(){this.Mt=this.Ot}Ut(e){this.cancel();let t=Math.floor(this.Mt+this.kt()),r=Math.max(0,Date.now()-this.Lt),n=Math.max(0,t-r);n>0&&w("ExponentialBackoff",`Backing off for ${n} ms (base delay: ${this.Mt} ms, delay with jitter: ${t} ms, last attempt: ${r} ms ago)`),this.Nt=this.xt.enqueueAfterDelay(this.timerId,n,()=>(this.Lt=Date.now(),e())),this.Mt*=this.Ft,this.Mt<this.Ct&&(this.Mt=this.Ct),this.Mt>this.Ot&&(this.Mt=this.Ot)}qt(){null!==this.Nt&&(this.Nt.skipDelay(),this.Nt=null)}cancel(){null!==this.Nt&&(this.Nt.cancel(),this.Nt=null)}kt(){return(Math.random()-.5)*this.Mt}}let nn="PersistentStream";class ns{constructor(e,t,r,n,s,i,a,o){this.xt=e,this.$t=r,this.Kt=n,this.connection=s,this.authCredentialsProvider=i,this.appCheckCredentialsProvider=a,this.listener=o,this.state=0,this.Qt=0,this.Wt=null,this.Gt=null,this.stream=null,this.zt=0,this.jt=new nr(e,t)}Ht(){return 1===this.state||5===this.state||this.Jt()}Jt(){return 2===this.state||3===this.state}start(){this.zt=0,4!==this.state?this.auth():this.Yt()}async stop(){this.Ht()&&await this.close(0)}Zt(){this.state=0,this.jt.reset()}Xt(){this.Jt()&&null===this.Wt&&(this.Wt=this.xt.enqueueAfterDelay(this.$t,6e4,()=>this.en()))}tn(e){this.nn(),this.stream.send(e)}async en(){if(this.Jt())return this.close(0)}nn(){this.Wt&&(this.Wt.cancel(),this.Wt=null)}rn(){this.Gt&&(this.Gt.cancel(),this.Gt=null)}async close(e,t){this.nn(),this.rn(),this.jt.cancel(),this.Qt++,4!==e?this.jt.reset():t&&t.code===O.RESOURCE_EXHAUSTED?(v(t.toString()),v("Using maximum backoff delay to prevent overloading the backend."),this.jt.Bt()):t&&t.code===O.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.sn(),this.stream.close(),this.stream=null),this.state=e,await this.listener.ht(t)}sn(){}auth(){this.state=1;let e=this._n(this.Qt),t=this.Qt;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([e,r])=>{this.Qt===t&&this.an(e,r)},t=>{e(()=>{let e=new P(O.UNKNOWN,"Fetching auth token failed: "+t.message);return this.un(e)})})}an(e,t){let r=this._n(this.Qt);this.stream=this.cn(e,t),this.stream.ut(()=>{r(()=>this.listener.ut())}),this.stream.lt(()=>{r(()=>(this.state=2,this.Gt=this.xt.enqueueAfterDelay(this.Kt,1e4,()=>(this.Jt()&&(this.state=3),Promise.resolve())),this.listener.lt()))}),this.stream.ht(e=>{r(()=>this.un(e))}),this.stream.onMessage(e=>{r(()=>1==++this.zt?this.En(e):this.onNext(e))})}Yt(){this.state=5,this.jt.Ut(async()=>{this.state=0,this.start()})}un(e){return w(nn,`close with error: ${e}`),this.stream=null,this.close(4,e)}_n(e){return t=>{this.xt.enqueueAndForget(()=>this.Qt===e?t():(w(nn,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class ni extends ns{constructor(e,t,r,n,s,i){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,r,n,i),this.serializer
1=s}cn(e,t){return this.connection.St("Listen",e,t)}En(e){return this.onNext(e)}onNext(e){this.jt.reset();let t=function(e,t){let r;if("targetChange"in t){var n,s;t.targetChange;let i="NO_CHANGE"===(n=t.targetChange.targetChangeType||"NO_CHANGE")?0:"ADD"===n?1:"REMOVE"===n?2:"CURRENT"===n?3:"RESET"===n?4:T(39313,{state:n}),a=t.targetChange.targetIds||[],o=(s=t.targetChange.resumeToken,e.useProto3Json?(b(void 0===s||"string"==typeof s,58123),es.fromBase64String(s||"")):(b(void 0===s||s instanceof m||s instanceof Uint8Array,16193),es.fromUint8Array(s||new Uint8Array))),l=t.targetChange.cause;r=new ru(i,a,o,l&&new P(void 0===l.code?O.UNKNOWN:t1(l.code),l.message||"")||null)}else if("documentChange"in t){t.documentChange;let n=t.documentChange;n.document,n.document.name,n.document.updateTime;let s=rC(e,n.document.name),i=rb(n.document.updateTime),a=n.document.createTime?rb(n.document.createTime):tA.min(),o=new eW({mapValue:{fields:n.document.fields}}),l=tD.newFoundDocument(s,i,a,o);r=new ro(n.targetIds||[],n.removedTargetIds||[],l.key,l)}else if("documentDelete"in t){t.documentDelete;let n=t.documentDelete;n.document;let s=rC(e,n.document),i=n.readTime?rb(n.readTime):tA.min(),a=tD.newNoDocument(s,i);r=new ro([],n.removedTargetIds||[],a.key,a)}else if("documentRemove"in t){t.documentRemove;let n=t.documentRemove;n.document;let s=rC(e,n.document);r=new ro([],n.removedTargetIds||[],s,null)}else{if(!("filter"in t))return T(11601,{ye:t});{t.filter;let e=t.filter;e.targetId;let{count:n=0,unchangedNames:s}=e,i=new t0(n,s);r=new rl(e.targetId,i)}}return r}(this.serializer,e),r=function(e){if(!("targetChange"in e))return tA.min();let t=e.targetChange;return t.targetIds&&t.targetIds.length?tA.min():t.readTime?rb(t.readTime):tA.min()}(e);return this.listener.hn(t,r)}Tn(e){let t,r={};r.database=rA(this.serializer),r.addTarget=function(e,t){var r,n;let s,i,a,o,l,u,c,h=t.target;if((s=tM(h)?{pipelineQuery:{structuredPipeline:{pipeline:{stages:h.stages.map(t=>t._toProto(e))}}}}:tF(h)?{documents:{documents:[rV(e,h.path)]}}:{query:(a={structuredQuery:{}},o=h.path,null!==h.collectionGroup?(i=o,a.structuredQuery.from=[{collectionId:h.collectionGroup,allDescendants:!0}]):(i=o.popLast(),a.structuredQuery.from=[{collectionId:o.lastSegment()}]),a.parent=rV(e,i),(l=function(e){if(0!==e.length)return function e(t){var r;let n;return t instanceof ty?function(e){if("=="===e.op){if(eB(e.value))return{unaryFilter:{field:rk(e.field),op:"IS_NAN"}};if(e$(e.value))return{unaryFilter:{field:rk(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(eB(e.value))return{unaryFilter:{field:rk(e.field),op:"IS_NOT_NAN"}};if(e$(e.value))return{unaryFilter:{field:rk(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:rk(e.field),op:rg[e.op],value:e.value}}}(t):t instanceof tw?1===(n=(r=t).getFilters().map(t=>e(t))).length?n[0]:{compositeFilter:{op:ry[r.op],filters:n}}:T(54877,{filter:t})}(tw.create(e,"and"))}(h.filters))&&(a.structuredQuery.where=l),(u=function(e){if(0!==e.length)return e.map(e=>({field:rk(e.field),direction:rp[e.dir]}))}(h.orderBy))&&(a.structuredQuery.orderBy=u),null!==(c=rv(e,h.limit))&&(a.structuredQuery.limit=c),h.startAt&&(a.structuredQuery.startAt={before:(r=h.startAt).inclusive,values:r.position}),h.endAt&&(a.structuredQuery.endAt={before:!(n=h.endAt).inclusive,values:n.position}),{be:a,parent:i}).be}).targetId=t.targetId,t.resumeToken.approximateByteSize()>0){s.resumeToken=rT(e,t.resumeToken);let r=rv(e,t.expectedCount);null!==r&&(s.expectedCount=r)}else if(t.snapshotVersion.compareTo(tA.min())>0){s.readTime=r_(e,t.snapshotVersion.toTimestamp());let r=rv(e,t.expectedCount);null!==r&&(s.expectedCount=r)}return s}(this.serializer,e);let n=(this.serializer,null==(t=function(e){switch(e){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return T(28987,{purpose:e})}}(e.purpose))?null:{"goog-listen-tags":t});n&&(r.labels=n),this.tn(r)}Pn(e){let t={};t.database=rA(this.serializer),t.removeTarget=e,this.tn(t)}}class na{}class no extends na{constructor(e,t,r,n){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer
vendor: 5,818 bytes, line 1
1=n,this.fn=!1}mn(){if(this.fn)throw new P(O.FAILED_PRECONDITION,"The client has already been terminated.")}tt(e,t,r,n){return this.mn(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([s,i])=>this.connection.tt(e,rS(t,r),n,s,i)).catch(e=>{throw"FirebaseError"===e.name?(e.code===O.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new P(O.UNKNOWN,e.toString())})}st(e,t,r,n,s){return this.mn(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([i,a])=>this.connection.st(e,rS(t,r),n,i,a,s)).catch(e=>{throw"FirebaseError"===e.name?(e.code===O.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new P(O.UNKNOWN,e.toString())})}terminate(){this.fn=!0,this.connection.terminate()}}let nl=new Map,nu={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class nc{static withCacheSize(e){return new nc(e,nc.DEFAULT_COLLECTION_PERCENTILE,nc.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,r){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=r}}nc.DEFAULT_COLLECTION_PERCENTILE=10,nc.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,nc.DEFAULT=new nc(0x2800000,nc.DEFAULT_COLLECTION_PERCENTILE,nc.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),nc.DISABLED=new nc(-1,0,0);class nh{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=e=>this.pn(e),this.gn=e=>t.writeSequenceNumber(e))}pn(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){let e=++this.previousValue;return this.gn&&this.gn(e),e}}nh.yn=-1;class nd{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}async function nm(e){if(e.code!==O.FAILED_PRECONDITION||"The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab."!==e.message)throw e;w("LocalStore","Unexpectedly lost primary lease")}class nf{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(e=>{this.isDone=!0,this.result=e,this.nextCallback&&this.nextCallback(e)},e=>{this.isDone=!0,this.error=e,this.catchCallback&&this.catchCallback(e)})}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&T(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new nf((r,n)=>{this.nextCallback=t=>{this.wrapSuccess(e,t).next(r,n)},this.catchCallback=e=>{this.wrapFailure(t,e).next(r,n)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{let t=e();return t instanceof nf?t:nf.resolve(t)}catch(e){return nf.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):nf.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):nf.reject(t)}static resolve(e){return new nf((t,r)=>{t(e)})}static reject(e){return new nf((t,r)=>{r(e)})}static waitFor(e){return new nf((t,r)=>{let n=0,s=0,i=!1;e.forEach(e=>{++n,e.next(()=>{++s,i&&s===n&&t()},e=>r(e))}),i=!0,s===n&&t()})}static or(e){let t=nf.resolve(!1);for(let r of e)t=t.next(e=>e?nf.resolve(e):r());return t}static forEach(e,t){let r=[];return e.forEach((e,n)=>{r.push(t.call(this,e,n))}),this.waitFor(r)}static mapArray(e,t){return new nf((r,n)=>{let s=e.length,i=Array(s),a=0;for(let o=0;o<s;o++){let l=o;t(e[l]).next(e=>{i[l]=e,++a===s&&r(i)},e=>n(e))}})}static doWhile(e,t){return new nf((r,n)=>{let s=()=>{!0===e()?t().next(()=>{s()},n):r()};s()})}}function np(e){return"IndexedDbTransactionError"===e.name}let ng="LruGarbageCollector";function ny([e,t],[r,n]){let s=S(e,r);return 0===s?S(t,n):s}class nw{constructor(e){this.Jn=e,this.buffer=new L(ny),this.Yn=0}Zn(){return++this.Yn}Xn(e){let t=[e,this.Zn()];if(this.buffer.size<this.Jn)this.buffer=this.buffer.add(t);else{let e=this.buffer.last();0>ny(t,e)&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}}class nv{constructor(e,t,r){this.garbageCollector=e,this.asyncQueue=t,this.localStore=r,this.er=null}start(){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.tr(6e4)}stop(){this.er&&(this.er.cancel(),this.er=null)}get started(){return null!==this.er}tr(e){w(ng,`Garbage collection scheduled in ${e}ms`),this.er=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.er=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){np(e)?w(ng,"Ignoring IndexedDB error during garbage collection: ",e):await nm(e)}await this.tr(3e5)})}}class n_{constructor(e,t){this.nr=e,this.params=t}calculateTargetCount(e,t){return this.nr.rr(e).next(e=>Math.floor(t/100*e))}nthSequenceNumber(e,t){if(0===t)return nf.resolve(nh.yn);let r=new nw(t);return this.nr.forEachTarget(e,e=>r.Xn(e.sequenceNumber)).next(()=>this.nr.ir(e,e=>r.Xn(e))).next(()=>r.maxValue)}removeTargets(e,t,r){return this.nr.removeTargets(e,t,r)}removeOrphanedDocuments(e,t){return this.nr.removeOrphanedDocuments(e,t)}collect(e,t){return -1===this.params.cacheSizeCollectionThreshold?(w("LruGarbageCollector","Garbage collection skipped; disabled"),nf.resolve(nu)):this.getCacheSize(e).next(r=>r<this.params.cacheSizeCollectionThreshold?(w("LruGarbageCollector",`Garbage collection skipped; Cache size ${r} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),nu):this.sr(e,t))}getCacheSize(e){return this.nr.getCacheSize(e)}sr(e,t){let r,n,s,i,a,o,l,u=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(t=>(t>this.params.maximumSequenceNumbersToCollect?(w("LruGarbageCollector",`C
1apping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${t}`),n=this.params.maximumSequenceNumbersToCollect):n=t,i=Date.now(),this.nthSequenceNumber(e,n))).next(n=>(r=n,a=Date.now(),this.removeTargets(e,r,t))).next(t=>(s=t,o=Date.now(),this.removeOrphanedDocuments(e,r))).next(e=>(l=Date.now(),y()<=c.$b.DEBUG&&w("LruGarbageCollector",`LRU Garbage Collection
2	Counted targets in ${i-u}ms
3	Determined least recently used ${n} in `+(a-i)+"ms\n"+`	Removed ${s} targets in `+(o-a)+"ms\n"+`	Removed ${e} documents in `+(l-o)+"ms\n"+`Total Duration: ${l-u}ms`),nf.resolve({didRun:!0,sequenceNumbersCollected:n,targetsRemoved:s,documentsRemoved:e})))}}let nE="firestore.googleapis.com";class nT{constructor(e){if(void 0===e.host){if(void 0!==e.ssl)throw new P(O.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=nE,this.ssl=!0}else this.host=e.host,this.ssl=e.ssl??!0;if(this.isUsingEmulator=void 0!==e.emulatorOptions,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e._customHeaders&&(this._customHeaders={...e._customHeaders}),void 0===e.cacheSizeBytes)this.cacheSizeBytes=0x2800000;else{if(-1!==e.cacheSizeBytes&&e.cacheSizeBytes<1048576)throw new P(O.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}if(function(e,t,r,n){if(!0===t&&!0===n)throw new P(O.INVALID_ARGUMENT,`${e} and ${r} cannot be used together.`)}("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:void 0===e.experimentalAutoDetectLongPolling?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=rZ(e.experimentalLongPollingOptions??{}),function(e){if(void 0!==e.timeoutSeconds){if(isNaN(e.timeoutSeconds))throw new P(O.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new P(O.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new P(O.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams,void 0!==e.grpcFlowControlWindow){if("number"!=typeof e.grpcFlowControlWindow||e.grpcFlowControlWindow<=0||e.grpcFlowControlWindow>0x7fffffff||!Number.isInteger(e.grpcFlowControlWindow))throw new P(O.INVALID_ARGUMENT,"grpcFlowControlWindow must be a positive integer and cannot exceed 2147483647");this.grpcFlowControlWindow=e.grpcFlowControlWindow}}isEqual(e){var t,r;return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&(t=this.experimentalLongPollingOptions,r=e.experimentalLongPollingOptions,t.timeoutSeconds===r.timeoutSeconds)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams&&this.grpcFlowControlWindow===e.grpcFlowControlWindow&&function(e,t){if(e===t)return!0;if(!e||!t)return!1;let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let n of r)if(e[n]!==t[n])return!1;return!0}(this._customHeaders,e._customHeaders)}}let nx=class{constructor(e,t,r,n){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=r,this._app=n,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new nT({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new P(O.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return"notTerminated"!==this._terminateTask}_setSettings(e){if(this._settingsFrozen)throw new P(O.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new nT(e),this._emulatorOptions=e.emulatorOptions||{},void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new rK;switch(e.type){case"firstParty":return new rY(e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new P(O.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invali
3d credential type")}}(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return"notTerminated"===this._terminateTask&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){"notTerminated"===this._terminateTask?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){let e;return(e=nl.get(this))&&(w("ComponentProvider","Removing Datastore"),nl.delete(this),e.terminate()),Promise.resolve()}};function nb(e,t,r,n={}){e=X(e,nx);let s=(0,l.zJ)(t),i=e._getSettings(),a={...i,emulatorOptions:e._getEmulatorOptions()},o=`${t}:${r}`;s&&(0,l.gE)(`https://${o}`),i.host!==nE&&i.host!==o&&_("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");let u={...i,host:o,ssl:s,emulatorOptions:n};if(!(0,l.bD)(u,a)&&(e._setSettings(u),n.mockUserToken)){let t,r;if("string"==typeof n.mockUserToken)t=n.mockUserToken,r=rz.MOCK_USER;else{t=(0,l.Fy)(n.mockUserToken,e._app?.options.projectId);let s=n.mockUserToken.sub||n.mockUserToken.user_id;if(!s)throw new P(O.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");r=new rz(s)}e._authCredentials=new rQ(new rG(t,r))}}class nN{constructor(e,t,r){this.converter=t,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new nN(this.firestore,e,this._query)}}class nS{constructor(e,t,r){this.converter=t,this._key=r,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new nI(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new nS(this.firestore,e,this._key)}toJSON(){return{type:nS._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,r){if(et(t,nS._jsonSchema))return new nS(e,r||null,new K(F.fromString(t.referencePath)))}}nS._jsonSchemaVersion="firestore/documentReference/1.0",nS._jsonSchema={type:ee("string",nS._jsonSchemaVersion),referencePath:ee("string")};class nI extends nN{constructor(e,t,r){super(e,t,t$(r)),this._path=r,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){let e=this._path.popLast();return e.isEmpty()?null:new nS(this.firestore,null,new K(e))}withConverter(e){return new nI(this.firestore,e,this._path)}}function nC(e,t,...r){if(e=(0,l.Ku)(e),Q("collection","path",t),e instanceof nx){let n=F.fromString(t,...r);return H(n),new nI(e,null,n)}{if(!(e instanceof nS||e instanceof nI))throw new P(O.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let n=e._path.child(F.fromString(t,...r));return H(n),new nI(e.firestore,null,n)}}function nV(e,t){if(e=X(e,nx),Q("collectionGroup","collection id",t),t.indexOf("/")>=0)throw new P(O.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new nN(e,null,new tq(F.emptyPath(),t))}function nA(e,t,...r){if(e=(0,l.Ku)(e),1==arguments.length&&(t=N.newId()),Q("doc","path",t),e instanceof nx){let n=F.fromString(t,...r);return W(n),new nS(e,null,new K(n))}{if(!(e instanceof nS||e instanceof nI))throw new P(O.INVALID_ARGUMENT,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let n=e._path.child(F.fromString(t,...r));return W(n),new nS(e.firestore,e instanceof nI?e.converter:null,new K(n))}}class nD{constructor(e){this._values=(e||[]).map(e=>e)}toArray(){return this._values.map(e=>e)}isEqual(e){return function(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}(this._values,e._values)}toJSON(){return{type:nD._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(et(e,nD._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every(e=>"number"==typeof e))return new nD(e.vectorValues);throw new P(O.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}nD._jsonSchemaVersion="firestore/vectorValue/1.0",nD._jsonSchema={type:ee("string",nD._jsonSchemaVersion),vectorValues:ee("object")};let nk=/^__.*__$/;class nL{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return null!==this.fieldMask?new tl(e,this.data,this.fieldMask,t,this.fieldTransforms):new to(e,this.data,t,this.fieldTransforms)}}class nR{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return new tl(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function nO(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw T(40011,{dataSource:e})}}class nP{constructor(e,t,r,n,s,i){this.settings=e,this.databaseId=t,this.serializer
3=r,this.ignoreUndefinedProperties=n,void 0===s&&this.validatePath(),this.fieldTransforms=s||[],this.fieldMask=i||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}contextWith(e){return new nP({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}childContextForField(e){let t=this.path?.child(e),r=this.contextWith({path:t,arrayElement:!1});return r.validatePathSegment(e),r}childContextForFieldPath(e){let t=this.path?.child(e),r=this.contextWith({path:t,arrayElement:!1});return r.validatePath(),r}childContextForArray(e){return this.contextWith({path:void 0,arrayElement:!0})}createError(e){return nJ(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return void 0!==this.fieldMask.find(t=>e.isPrefixOf(t))||void 0!==this.fieldTransforms.find(t=>e.isPrefixOf(t.field))}validatePath(){if(this.path)for(let e=0;e<this.path.length;e++)this.validatePathSegment(this.path.get(e))}validatePathSegment(e){if(0===e.length)throw this.createError("Document fields must not be empty");if(nO(this.dataSource)&&nk.test(e))throw this.createError('Document fields cannot begin and end with "__"')}}class nU{constructor(e,t,r){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=r||rM(e)}createContext(e,t,r,n=!1){return new nP({dataSource:e,methodName:t,targetDoc:r,path:$.emptyPath(),arrayElement:!1,hasConverter:n},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function nM(e){let t=e._freezeSettings(),r=rM(e._databaseId);return new nU(e._databaseId,!!t.ignoreUndefinedProperties,r)}function nF(e,t,r,n,s,i={}){let a,o,l=e.createContext(i.merge||i.mergeFields?2:0,t,r,s);nQ("Data must be an object, but it was:",l,n);let u=nG(n,l);if(i.merge)a=new B(l.fieldMask),o=l.fieldTransforms;else if(i.mergeFields){let e=[];for(let n of i.mergeFields){let s=nW(t,n,r);if(!l.contains(s))throw new P(O.INVALID_ARGUMENT,`Field '${s}' is specified in your field mask but missing from your input data.`);nX(e,s)||e.push(s)}a=new B(e),o=l.fieldTransforms.filter(e=>a.covers(e.field))}else a=null,o=l.fieldTransforms;return new nL(new eW(u),a,o)}class nq extends r${_toFieldTransform(e){if(2!==e.dataSource)throw 1===e.dataSource?e.createError(`${this._methodName}() can only appear at the top level of your update data`):e.createError(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof nq}}function n$(e,t,r,n){let s=e.createContext(1,t,r);nQ("Data must be an object, but it was:",s,n);let i=[],a=eW.empty();return j(n,(e,n)=>{let o=nY(t,e,r);n=(0,l.Ku)(n);let u=s.childContextForFieldPath(o);if(n instanceof nq)i.push(o);else{let e=nj(n,u);null!=e&&(i.push(o),a.set(o,e))}}),new nR(a,new B(i),s.fieldTransforms)}function nB(e,t,r,n,s,i){let a=e.createContext(1,t,r),o=[nW(t,n,r)],u=[s];if(i.length%2!=0)throw new P(O.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let e=0;e<i.length;e+=2)o.push(nW(t,i[e])),u.push(i[e+1]);let c=[],h=eW.empty();for(let e=o.length-1;e>=0;--e)if(!nX(c,o[e])){let t=o[e],r=u[e];r=(0,l.Ku)(r);let n=a.childContextForFieldPath(t);if(r instanceof nq)c.push(t);else{let e=nj(r,n);null!=e&&(c.push(t),h.set(t,e))}}return new nR(h,new B(c),a.fieldTransforms)}function nz(e,t,r,n=!1){return nj(r,e.createContext(n?4:3,t))}function nj(e,t,r){if(nK(e=(0,l.Ku)(e)))return nQ("Unsupported field value:",t,e),nG(e,t);if(e instanceof r$)return function(e,t){if(!nO(t.dataSource))throw t.createError(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.createError(`${e._methodName}() is not currently supported inside arrays`);let r=e._toFieldTransform(t);r&&t.fieldTransforms.push(r)}(e,t),null;if(void 0===e&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.arrayElement&&4!==t.dataSource)throw t.createError("Nested arrays are not supported");let r=[],n=0;for(let s of e){let e=nj(s,t.childContextForArray(n));null==e&&(e={nullValue:"NULL_VALUE"}),r.push(e),n++}return{arrayValue:{values:r}}}return function(e,t){if(null===(e=(0,l.Ku)(e)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return eJ(t.serializer,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){let r=er.fromDate(e);return{timestampValue:r_(t.serializer,r)}}if(e instanceof er){let r=new er(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:r_(t.serializer,r)}}if(e instanceof rB)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof rF)return{bytesValue:rT(t.serializer,e._byteString)};if(e instanceof nS){let r=t.databaseId,n=e.firestore._databaseId;if(!n.isEqual(r))throw t.createError(`Document reference is for database ${n.projectId}/${n.database} but should be for database ${r.projectId}/${r.database}`);return{referenceValue:rN(e.firestore._databaseId||t.databaseId,e._key.path)}}if(e instanceof nD){var r;return{mapValue:{fields:{[eE]:{stringValue:eb},[eN]:{arrayValue:{values:((r=e)instanceof nD?r.toArray():r).map(e=>{if("number"!=typeof e)throw t.createError("VectorValues must only contain numeric values.");return eH(t.serializer,e)})}}}}}}if(rO(e))return e._toProto(t.serializer);throw t.createError(`Unsupported field value: ${J(e)}`)}(e,t)}function nG(e,t){let r={};return G(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):j(e,(e,n)=>{let s=nj(n,t.childContextForField(e));null!=s&&(r[e]=s)}),{mapValue:{fields:r}}}function nK(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof er||e instanceof rB||e instanceof rF||e instanceof nS||e instanceof r$||e instanceof nD||rO(e))}function nQ(e,t,r){if(!nK(r)||!Y(r)){let n=J(r);throw"an object"===n?t.createError(e+" a custom object"):t.createError(e+" "+n)}}function nW(e,t,r){if((t=(0,l.Ku)(t))instanceof rq)return t._internalPath;if("string"==typeof t)return nY(e,t);throw nJ("Field path arguments must be of type string or ",e,!1,void 0,r)}let nH=RegExp("[~\\*/\\[\\]]");function nY(e,t,r){if(t.search(nH)>=0)throw nJ(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,r);try{return new rq(...t.split("."))._internalPath}catch(n){throw nJ(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,r)}}function nJ(e,t,r,n,s){let i=n&&!n.isEmpty(),a=void 0!==s,o=`Function ${t}
3() called with invalid data`;r&&(o+=" (via `toFirestore()`)"),o+=". ";let l="";return(i||a)&&(l+=" (found",i&&(l+=` in field ${n}`),a&&(l+=` in document ${s}`),l+=")"),new P(O.INVALID_ARGUMENT,o+e+l)}function nX(e,t){return e.some(e=>e.isEqual(t))}class nZ{constructor(e){this.optionDefinitions=e}_getKnownOptions(e,t){let r=eW.empty();for(let n in this.optionDefinitions)if(this.optionDefinitions.hasOwnProperty(n)){let s=this.optionDefinitions[n];if(n in e){let i,a=e[n];s.nestedOptions&&Y(a)?i={mapValue:{fields:new nZ(s.nestedOptions).getOptionsProto(t,a)}}:a&&(i=nj(a,t)??void 0),i&&r.set($.fromServerFormat(s.serverName),i)}}return r}getOptionsProto(e,t,r){let n=this._getKnownOptions(t,e);if(r){let t=new Map(function(e,t){let r=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.push(t(e[n],n,e));return r}(r,(t,r)=>[$.fromServerFormat(r),void 0!==t?nj(t,e):null]));n.setAll(t)}return n.value.mapValue.fields??{}}}function n0(e){return e instanceof n3?e:Y(e)?function(e){let t=[];for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)){let n=e[r];t.push(se(r)),t.push(n0(n))}return new sr("map",t,"map")}(e):e instanceof Array?function(e){return new sr("array",e.map(e=>n0(e)),"array")}(e):st(e,void 0)}function n1(e){if(e instanceof n3)return e;if(e instanceof nD)return se(e);if(Array.isArray(e))return se(new nD(e));throw Error("Unsupported value: "+typeof e)}function n2(e){var t,r;return"string"==typeof e?(r="field",new n9("string"==typeof(t=e)?U===t?new rq(U)._internalPath:nW("field",t):t._internalPath,r)):n0(e)}class n3{constructor(){this._protoValueType="ProtoValue"}add(e){return new sr("add",[this,n0(e)],"add")}asBoolean(){if(this instanceof sn)return this;if(this instanceof n7)return new si(this);if(this instanceof n9)return new sa(this);if(this instanceof sr)return new ss(this);throw new P("invalid-argument",`Conversion of type ${typeof this} to BooleanExpression not supported.`)}subtract(e){return new sr("subtract",[this,n0(e)],"subtract")}multiply(e){return new sr("multiply",[this,n0(e)],"multiply")}divide(e){return new sr("divide",[this,n0(e)],"divide")}mod(e){return new sr("mod",[this,n0(e)],"mod")}equal(e){return new sr("equal",[this,n0(e)],"equal").asBoolean()}notEqual(e){return new sr("not_equal",[this,n0(e)],"notEqual").asBoolean()}lessThan(e){return new sr("less_than",[this,n0(e)],"lessThan").asBoolean()}lessThanOrEqual(e){return new sr("less_than_or_equal",[this,n0(e)],"lessThanOrEqual").asBoolean()}greaterThan(e){return new sr("greater_than",[this,n0(e)],"greaterThan").asBoolean()}greaterThanOrEqual(e){return new sr("greater_than_or_equal",[this,n0(e)],"greaterThanOrEqual").asBoolean()}arrayConcat(e,...t){return new sr("array_concat",[this,...[e,...t].map(e=>n0(e))],"arrayConcat")}arrayContains(e){return new sr("array_contains",[this,n0(e)],"arrayContains").asBoolean()}arrayContainsAll(e){return new sr("array_contains_all",[this,Array.isArray(e)?new n5(e.map(n0),"arrayContainsAll"):e],"arrayContainsAll").asBoolean()}arrayContainsAny(e){return new sr("array_contains_any",[this,Array.isArray(e)?new n5(e.map(n0),"arrayContainsAny"):e],"arrayContainsAny").asBoolean()}arrayReverse(){return new sr("array_reverse",[this])}arrayLength(){return new sr("array_length",[this],"arrayLength")}equalAny(e){return new sr("equal_any",[this,Array.isArray(e)?new n5(e.map(n0),"equalAny"):e],"equalAny").asBoolean()}notEqualAny(e){return new sr("not_equal_any",[this,Array.isArray(e)?new n5(e.map(n0),"notEqualAny"):e],"notEqualAny").asBoolean()}exists(){return new sr("exists",[this],"exists").asBoolean()}charLength(){return new sr("char_length",[this],"charLength")}like(e){return new sr("like",[this,n0(e)],"like").asBoolean()}regexContains(e){return new sr("regex_contains",[this,n0(e)],"regexContains").asBoolean()}regexFind(e){return new sr("regex_find",[this,n0(e)],"regexFind")}regexFindAll(e){return new sr("regex_find_all",[this,n0(e)],"regexFindAll")}regexMatch(e){return new sr("regex_match",[this,n0(e)],"regexMatch").asBoolean()}stringContains(e){return new sr("string_contains",[this,n0(e)],"stringContains").asBoolean()}startsWith(e){return new sr("starts_with",[this,n0(e)],"startsWith").asBoolean()}endsWith(e){return new sr("ends_with",[this,n0(e)],"endsWith").asBoolean()}toLower(){return new sr("to_lower",[this],"toLower")}toUpper(){return new sr("to_upper",[this],"toUpper")}trim(e){let t=[this];return e&&t.push(n0(e)),new sr("trim",t,"trim")}ltrim(e){let t=[this];return e&&t.push(n0(e)),new sr("ltrim",t,"ltrim")}rtrim(e){let t=[this];return e&&t.push(n0(e)),new sr("rtrim",t,"rtrim")}type(){return new sr("type",[this])}isType(e){return new sr("is_type",[this,se(e)],"isType").asBoolean()}stringConcat(e,...t){return new sr("string_concat",[this,...[e,...t].map(n0)],"stringConcat")}stringIndexOf(e){return new sr("string_index_of",[this,n0(e)],"stringIndexOf")}stringRepeat(e){return new sr("string_repeat",[this,n0(e)],"stringRepeat")}stringReplaceAll(e,t){return new sr("string_replace_all",[this,n0(e),n0(t)],"stringReplaceAll")}stringReplaceOne(e,t){return new sr("string_replace_one",[this,n0(e),n0(t)],"stringReplaceOne")}concat(e,...t){return new sr("concat",[this,...[e,...t].map(n0)],"concat")}reverse(){return new sr("reverse",[this],"reverse")}arrayFilter(e,t){return new sr("array_filter",[this,n0(e),t],"arrayFilter")}arrayTransform(e,t){return new sr("array_transform",[this,n0(e),t],"arrayTransform")}arrayTransformWithIndex(e,t,r){return new sr("array_transform",[this,n0(e),n0(t),r],"arrayTransformWithIndex")}arraySlice(e,t){let r=[this,n0(e)];return void 0!==t&&r.push(n0(t)),new sr("array_slice",r,"arraySlice")}arrayFirst(){return new sr("array_first",[this],"arrayFirst")}arrayFirstN(e){return new sr("array_first_n",[this,n0(e)],"arrayFirstN")}arrayLast(){return new sr("array_last",[this],"arrayLast")}arrayLastN(e){return new sr("array_last_n",[this,n0(e)],"arrayLastN")}arrayMaximum(){return new sr("maximum",[this],"arrayMaximum")}arrayMaximumN(e){return new sr("maximum_n",[this,n0(e)],"arrayMaximumN")}arrayMinimum(){return new sr("minimum",[this],"arrayMinimum")}arrayMinimumN(e){return new sr("minimum_n",[this,n0(e)],"arrayMinimumN")}arrayIndexOf(e){return new sr("array_index_of",[this,n0(e),n0("first")],"arrayIndexOf")}arrayLastIndexOf(e){return new sr("array_index_of",[this,n0(e),n0("last")],"arrayLastIndexOf")}arrayIndexOfAll(e){return new sr("array_index_of_all",[this,n0(e)],"arrayIndexOfAll")}byteLength(){return new sr("byte_length",[this],"byteLength")}ceil(){return new sr("ceil",[this])}floor(){return new sr("floor",[this])}abs(){return new sr("abs",[this])}exp(){return new sr("exp",[this])}mapGet(e){return new sr("map_get",[this,se(e)],"mapGet")}mapSet(e,t,...r){return new sr("map_set",[this,n0(e),n0(t),...r.map(n0)],"mapSet")}mapKeys(){return new sr("map_keys",[this],"mapKeys")}mapValues(){return new sr("map_values",[this],"mapValues")}mapEntries(){return new sr("map_entries",[this],"mapEntries")}getField(e){return new sr("get_field",[this,n0(e)],"get_field")}count(){return n4._create("count",[this],"count")}sum(){return n4._create("sum",[this],"sum")}average(){return n4._create("average",[this],"average")}minimum(){return n4._create("minimum",[this],"minimum")}maximum(){return n4._create("maximum",[this],"maximum")}first(){return n4._create("first",[this],"first")}last(){return n4._create("last",[this],"last")}arrayAgg(){return n4._create("array_agg",[this],"arrayAgg")}arrayAggDistinct(){return n4._create("array_agg_distinct",[this],"arrayAggDistinct")}countDistinct(){return n4._create("count_distinct",[this],"countDistinct")}logicalMaximum(e,...t){return new sr("maximum",[this,...[e,...t].map(n0)],"logicalMaximum")}logicalMinimum(e,...t){return new sr("minimum",[this,...[e,...t].map(n0)],"minimum")}vectorLength(){return new sr("vector_length",[this],"vectorLength")}cosineDistance(e){return new sr("cosine_distance",[this,n1(e)],"cosineDistance")}dotProduct(e){return new sr("dot_product",[this,n1(e)],"dotProduct")}euclideanDistance(e){return new sr("euclidean_distance",[this,n1(e)],"euclideanDistance")}unixMicrosToTimestamp(){return new sr("unix_micros_to_timestamp",[this],"unixMicrosToTimestamp")}timestampToUnixMicros(){return new sr("timestamp_to_unix_micros",[this],"timestampToUnixMicros")}unixMillisToTimestamp(){return new sr("unix_millis_to_timestamp",[this],"unixMillisToTimestamp")}timestampToUnixMillis(){return new sr("timestamp_to_unix_millis",[this],"timestampToUnixMillis")}unixSecondsToTimestamp(){return new sr("unix_seconds_to_timestamp",[this],"unixSecondsToTimestamp")}timestampToUnixSeconds(){return new sr("timestamp_to_unix_seconds",[this],"timestampToUnixSeconds")}timestampAdd(e,t){return new sr("timestamp_add",[this,n0(e),n0(t)],"timestampAdd")}timestampSubtract(e,t){return new sr("timestamp_subtract",[this,n0(e),n0(t)],"timestampSubtract")}timestampDiff(e,t){return new sr("timestamp_diff",[this,n2(e),n0(t)],"timestampDiff")}timestampExtract(e,t){let r=[this,n0(e)];return t&&r.push(n0(t)),new sr("timestamp_extract",r,"timestampExtract")}documentId(){return new sr("document_id",[this],"documentId")}parent(){return new sr("parent",[this],"parent")}substring(e,t){let r=n0(e);return new sr("substring",void 0===t?[this,r]:[this,r,n0(t)],"substring")}arrayGet(e){return new sr("array_get",[this,n0(e)],"arrayGet")}isError(){return new sr("is_error",[this],"isError").asBoolean()}ifError(e){let t=new sr("if_error",[this,n0(e)],"ifError");return e instanceof sn?t.asBoolean():t}isAbsent(){return new sr("is_absent",[this],"isAbsent").asBoolean()}mapRemove(e){return new sr("map_remove",[this,n0(e)],"mapRemove")}mapMerge(e,...t){return new sr("map_merge",[this,n0(e),...t.map(n0)],"mapMerge")}pow(e){return new sr("pow",[this,n0(e)])}trunc(e){return void 0===e?new sr("trunc",[this]):new sr("trunc",[this,n0(e)],"trunc")}round(e){return void 0===e?new sr("round",[this]):new sr("round",[this,n0(e)],"round")}collectionId(){return new sr("collection_id",[this])}length(){return new sr("length",[this])}ln(){return new sr("ln",[this])}sqrt(){return new sr("sqrt",[this])}
3stringReverse(){return new sr("string_reverse",[this])}ifAbsent(e){return new sr("if_absent",[this,n0(e)],"ifAbsent")}ifNull(e){return new sr("if_null",[this,n0(e)],"ifNull")}coalesce(e,...t){return new sr("coalesce",[this,n0(e),...t.map(n0)],"coalesce")}join(e){return new sr("join",[this,n0(e)],"join")}log10(){return new sr("log10",[this])}arraySum(){return new sr("sum",[this])}split(e){return new sr("split",[this,n0(e)])}timestampTruncate(e,t){let r=[this,n0(e)];return t&&r.push(n0(t)),new sr("timestamp_trunc",r)}ascending(){var e;return e=this,new so(n2(e),"ascending","ascending")}descending(){var e;return e=this,new so(n2(e),"descending","descending")}as(e){return new n8(this,e,"as")}}class n4{constructor(e,t){this.name=e,this.params=t,this.exprType="AggregateFunction",this._protoValueType="ProtoValue"}static _create(e,t,r){let n=new n4(e,t);return n._methodName=r,n}as(e){return new n6(this,e,"as")}_toProto(e){return{functionValue:{name:this.name,args:this.params.map(t=>t._toProto(e))}}}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,this.params.forEach(t=>t._readUserData(e))}}class n6{constructor(e,t,r){this.aggregate=e,this.alias=t,this._methodName=r}_readUserData(e){this.aggregate._readUserData(e)}}class n8{constructor(e,t,r){this.expr=e,this.alias=t,this._methodName=r,this.exprType="AliasedExpression",this.selectable=!0}_readUserData(e){this.expr._readUserData(e)}}class n5 extends n3{constructor(e,t){super(),this.ur=e,this._methodName=t,this.expressionType="ListOfExpressions"}_toProto(e){return{arrayValue:{values:this.ur.map(t=>t._toProto(e))}}}_readUserData(e){this.ur.forEach(t=>t._readUserData(e))}}class n9 extends n3{constructor(e,t){super(),this.fieldPath=e,this._methodName=t,this.expressionType="Field",this.selectable=!0}get _fieldPath(){return this.fieldPath}get fieldName(){return this.fieldPath.canonicalString()}get alias(){return this.fieldName}get expr(){return this}geoDistance(e){return new sr("geo_distance",[this,n0(e)],"geoDistance")}_toProto(e){return{fieldReferenceValue:this.fieldPath.canonicalString()}}_readUserData(e){}}class n7 extends n3{constructor(e,t){super(),this.value=e,this._methodName=t,this.expressionType="Constant"}static _fromProto(e){let t=new n7(e,void 0);return t._protoValue=e,t}_toProto(e){return b(void 0!==this._protoValue,237),this._protoValue}_getValue(){return this._protoValue}_readUserData(e){var t,r,n,s,i,a,o;e=this._methodName?e.contextWith({methodName:this._methodName}):e,"object"==typeof(t=this._protoValue)&&null!==t&&("nullValue"in t&&(null===t.nullValue||"NULL_VALUE"===t.nullValue)||"booleanValue"in t&&(null===t.booleanValue||"boolean"==typeof t.booleanValue)||"integerValue"in t&&(null===t.integerValue||"number"==typeof t.integerValue||"string"==typeof t.integerValue)||"doubleValue"in t&&(null===t.doubleValue||"number"==typeof t.doubleValue)||"timestampValue"in t&&(null===t.timestampValue||"object"==typeof(r=t.timestampValue)&&null!==r&&"seconds"in r&&(null===r.seconds||"number"==typeof r.seconds||"string"==typeof r.seconds)&&"nanos"in r&&(null===r.nanos||"number"==typeof r.nanos))||"stringValue"in t&&(null===t.stringValue||"string"==typeof t.stringValue)||"bytesValue"in t&&(null===t.bytesValue||t.bytesValue instanceof Uint8Array)||"referenceValue"in t&&(null===t.referenceValue||"string"==typeof t.referenceValue)||"geoPointValue"in t&&(null===t.geoPointValue||"object"==typeof(n=t.geoPointValue)&&null!==n&&"latitude"in n&&(null===n.latitude||"number"==typeof n.latitude)&&"longitude"in n&&(null===n.longitude||"number"==typeof n.longitude))||"arrayValue"in t&&(null===t.arrayValue||"object"==typeof(s=t.arrayValue)&&null!==s&&!(!("values"in s)||null!==s.values&&!Array.isArray(s.values)))||"mapValue"in t&&(null===t.mapValue||"object"==typeof(i=t.mapValue)&&null!==i&&!(!("fields"in i)||null!==i.fields&&!Y(i.fields)))||"fieldReferenceValue"in t&&(null===t.fieldReferenceValue||"string"==typeof t.fieldReferenceValue)||"functionValue"in t&&(null===t.functionValue||"object"==typeof(a=t.functionValue)&&null!==a&&!(!("name"in a)||null!==a.name&&"string"!=typeof a.name||!("args"in a)||null!==a.args&&!Array.isArray(a.args)))||"pipelineValue"in t&&(null===t.pipelineValue||"object"==typeof(o=t.pipelineValue)&&null!==o&&!(!("stages"in o)||null!==o.stages&&!Array.isArray(o.stages))))||(this._protoValue=nj(this.value,e))}}function se(e,t){return st(e,"constant")}function st(e,t){let r=new n7(e,t);return"boolean"==typeof e?new si(r):r}class sr extends n3{constructor(e,t,r,n){super(),this.name=e,this.params=t,this.expressionType="Function",this._optionsProto=void 0,void 0!==r&&(this._methodName=r),void 0!==n&&(this._options=n)}get _optionsUtil(){return new nZ({})}_toProto(e){let t={functionValue:{name:this.name,args:this.params.map(t=>t._toProto(e))}};return this._optionsProto&&(t.functionValue.options=this._optionsProto),t}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}
vendor: 5,131 bytes, line 3
3):e,this.params.forEach(t=>t._readUserData(e)),this._options&&(this._optionsProto=this._optionsUtil.getOptionsProto(e,this._options))}}class sn extends n3{get _methodName(){return this._expr._methodName}countIf(){return n4._create("count_if",[this],"countIf")}not(){return new sr("not",[this],"not").asBoolean()}conditional(e,t){return new sr("conditional",[this,e,t],"conditional")}ifError(e){let t=n0(e),r=new sr("if_error",[this,t],"ifError");return t instanceof sn?r.asBoolean():r}_toProto(e){return this._expr._toProto(e)}_readUserData(e){this._expr._readUserData(e)}}class ss extends sn{constructor(e){super(),this._expr=e,this.expressionType="Function"}}class si extends sn{constructor(e){super(),this._expr=e,this.expressionType="Constant"}_getValue(){return this._expr._getValue()}}class sa extends sn{constructor(e){super(),this._expr=e,this.expressionType="Field"}}class so{constructor(e,t,r){this.expr=e,this.direction=t,this._methodName=r,this._protoValueType="ProtoValue"}_toProto(e){return{mapValue:{fields:{direction:rU(this.direction),expression:this.expr._toProto(e)}}}}_readUserData(e){this.expr._readUserData(e)}}class sl{constructor(e){this.optionsProto=void 0,{rawOptions:this.rawOptions,...this.knownOptions}=e}_readUserData(e){this.optionsProto=this._optionsUtil.getOptionsProto(e,this.knownOptions,this.rawOptions)}_toProto(e){return{name:this._name,options:this.optionsProto}}}class su extends sl{get _name(){return"add_fields"}get _optionsUtil(){return new nZ({})}constructor(e,t){super(t),this.fields=e}_toProto(e){return{...super._toProto(e),args:[rP(e,this.fields)]}}_readUserData(e){super._readUserData(e),sT(this.fields,e)}}class sc extends sl{get _name(){return"aggregate"}get _optionsUtil(){return new nZ({})}constructor(e,t,r){super(r),this.groups=e,this.accumulators=t}_toProto(e){return{...super._toProto(e),args:[rP(e,this.accumulators),rP(e,this.groups)]}}_readUserData(e){super._readUserData(e),sT(this.groups,e),sT(this.accumulators,e)}}class sh extends sl{get _name(){return"distinct"}get _optionsUtil(){return new nZ({})}constructor(e,t){super(t),this.groups=e}_toProto(e){return{...super._toProto(e),args:[rP(e,this.groups)]}}_readUserData(e){super._readUserData(e),sT(this.groups,e)}}class sd extends sl{get _name(){return"collection"}get _optionsUtil(){return new nZ({forceIndex:{serverName:"force_index"}})}constructor(e,t){super(t),this.Er=e.startsWith("/")?e:"/"+e}_toProto(e){return{...super._toProto(e),args:[{referenceValue:this.Er}]}}_readUserData(e){super._readUserData(e)}}class sm extends sl{get _name(){return"collection_group"}get _optionsUtil(){return new nZ({forceIndex:{serverName:"force_index"}})}constructor(e,t){super(t),this.collectionId=e}_toProto(e){return{...super._toProto(e),args:[{referenceValue:""},{stringValue:this.collectionId}]}}_readUserData(e){super._readUserData(e)}}class sf extends sl{get _name(){return"database"}get _optionsUtil(){return new nZ({})}_toProto(e){return{...super._toProto(e)}}_readUserData(e){super._readUserData(e)}}class sp extends sl{get _name(){return"documents"}get _optionsUtil(){return new nZ({})}constructor(e,t){if(super(t),!e||0===e.length)throw new P(O.INVALID_ARGUMENT,"Empty document paths are not allowed in DocumentsSource");const r=e.map(e=>e.startsWith("/")?e:"/"+e),n=new Set(r);if(n.size!==r.length)throw new P(O.INVALID_ARGUMENT,"Duplicate document paths are not allowed in DocumentsSource");this.hr=r,this.Tr=n}_toProto(e){return{...super._toProto(e),args:this.hr.map(e=>({referenceValue:e}))}}_readUserData(e){super._readUserData(e)}}class sg extends sl{get _name(){return"where"}get _optionsUtil(){return new nZ({})}constructor(e,t){super(t),this.condition=e}_toProto(e){return{...super._toProto(e),args:[this.condition._toProto(e)]}}_readUserData(e){super._readUserData(e),sT(this.condition,e)}}class sy extends sl{get _name(){return"limit"}get _optionsUtil(){return new nZ({})}constructor(e,t){b(!isNaN(e)&&e!==1/0&&e!==-1/0,34860),super(t),this.limit=e}_toProto(e){return{...super._toProto(e),args:[eJ(e,this.limit)]}}}class sw extends sl{get _name(){return"offset"}get _optionsUtil(){return new nZ({})}constructor(e,t){super(t),this.offset=e}_toProto(e){return{...super._toProto(e),args:[eJ(e,this.offset)]}}}class sv extends sl{get _name(){return"select"}get _optionsUtil(){return new nZ({})}constructor(e,t){super(t),this.selections=e}_toProto(e){return{...super._toProto(e),args:[rP(e,this.selections)]}}_readUserData(e){super._readUserData(e),sT(this.selections,e)}}class s_ extends sl{get _name(){return"sort"}get _optionsUtil(){return new nZ({})}constructor(e,t){super(t),this.orderings=e}_toProto(e){return{...super._toProto(e),args:this.orderings.map(t=>t._toProto(e))}}_readUserData(e){super._readUserData(e),sT(this.orderings,e)}}class sE extends sl{get _name(){return"replace_with"}get _optionsUtil(){return new nZ({})}constructor(e,t){super(t),this.map=e}_toProto(e){return{...super._toProto(e),args:[this.map._toProto(e),rU(sE.Pr)]}}_readUserData(e){super._readUserData(e),sT(this.map,e)}}function sT(e,t){return"function"==typeof e._readUserData?e._readUserData(t):Array.isArray(e)?e.forEach(e
3=>e._readUserData(t)):e instanceof Map?e.forEach(e=>e._readUserData(t)):Object.values(e).forEach(e=>e._readUserData(t)),e}sE.Pr="full_replace";class sx{constructor(e,t,r){this.serializer=e,this.stages=t,this.listenOptions=r,this.isCorePipeline=!0}getPipelineCollection(){return sN(this)}getPipelineCollectionGroup(){return sS(this)}getPipelineCollectionId(){var e=this;switch(sb(e)){case"collection":return F.fromString(sN(e)).lastSegment();case"collection_group":return sS(e);default:return}}getPipelineDocuments(){return sI(this)}getPipelineFlavor(){var e;let t;return e=this,t="exact",e.stages.forEach((r,n)=>{r._name!==sh.name&&r._name!==sc.name||(t="keyless"),r._name===sv.name&&"exact"===t&&(t="augmented"),r._name===su.name&&n<e.stages.length-1&&"exact"===t&&(t="augmented")}),t}getPipelineSourceType(){return sb(this)}}function sb(e){let t=e.stages[0];return t instanceof sd||t instanceof sm||t instanceof sf||t instanceof sp?t._name:"unknown"}function sN(e){if("collection"===sb(e))return e.stages[0].Er}function sS(e){if("collection_group"===sb(e))return e.stages[0].collectionId}function sI(e){if("documents"===sb(e))return e.stages[0].hr}class sC{constructor(e,t){this.type=e,this.value=t}static dr(){return new sC("ERROR",void 0)}static mr(){return new sC("UNSET",void 0)}static pr(){return new sC("NULL",eS)}static newValue(e){return e$(e)?new sC("NULL",eS):e&&"booleanValue"in e?new sC("BOOLEAN",e):eU(e)?new sC("INT",e):eM(e)?new sC("DOUBLE",e):e&&"timestampValue"in e&&e.timestampValue?new sC("TIMESTAMP",e):e&&"stringValue"in e?new sC("STRING",e):e&&"bytesValue"in e?new sC("BYTES",e):e.referenceValue?new sC("REFERENCE",e):e.geoPointValue?new sC("GEO_POINT",e):eq(e)?new sC("ARRAY",e):ej(e)?new sC("VECTOR",e):ez(e)?new sC("MAP",e):new sC("ERROR",void 0)}gr(){return"ERROR"===this.type||"UNSET"===this.type}yr(){return"NULL"===this.type}}function sV(e){if(!e.gr())return e.value}function sA(e){return e instanceof sn?e._expr:e}function sD(e){if((e=sA(e))instanceof n9)return new sk(e);if(e instanceof n7)return new sL(e);if(e instanceof n5)return new sR(e);if(e instanceof sr){if("add"===e.name)return new s$(e);if("subtract"===e.name)return new sB(e);if("multiply"===e.name)return new sz(e);if("divide"===e.name)return new sj(e);if("mod"===e.name)return new sG(e);if("and"===e.name)return new sK(e);if("equal"===e.name)return new s9(e);if("not_equal"===e.name)return new s7(e);if("less_than"===e.name)return new ie(e);if("less_than_or_equal"===e.name)return new it(e);if("greater_than"===e.name)return new ir(e);if("greater_than_or_equal"===e.name)return new is(e);if("array_concat"===e.name)return new ii(e);if("array_reverse"===e.name)return new ia(e);if("array_contains"===e.name)return new io(e);if("array_contains_all"===e.name)return new il(e);if("array_contains_any"===e.name)return new iu(e);if("array_length"===e.name)return new ic(e);if("array_element"===e.name)return new ih(e);if("equal_any"===e.name)return new sY(e);if("not_equal_any"===e.name)return new sJ(e);if("is_nan"===e.name)return new sX(e);if("is_not_nan"===e.name)return new sZ(e);if("is_null"===e.name)return new s0(e);if("is_not_null"===e.name)return new s1(e);if("is_error"===e.name)return new s2(e);if("exists"===e.name)return new s3(e);if("not"===e.name)return new sQ(e);if("or"===e.name)return new sW(e);if("xor"===e.name)return new sH(e);if("conditional"===e.name)return new s4(e);if("maximum"===e.name)return new s6(e);if("minimum"===e.name)return new s8(e);if("reverse"===e.name)return new id(e);if("replace_first"===e.name)return new im(e);if("replace_all"===e.name)return new ip(e);if("char_length"===e.name)return new ig(e);if("byte_length"===e.name)return new iy(e);if("like"===e.name)return new iv(e);if("regex_contains"===e.name)return new i_(e);if("regex_match"===e.name)return new iE(e);if("string_contains"===e.name)return new iT(e);if("starts_with"===e.name)return new ix(e);if("ends_with"===e.name)return new ib(e);if("to_lower"===e.name)return new iN(e);if("to_upper"===e.name)return new iS(e);if("trim"===e.name)return new iI(e);if("string_concat"===e.name)return new iC(e);if("map_get"===e.name)return new iV(e);if("cosine_distance"===e.name)return new iD(e);if("dot_product"===e.name)return new ik(e);if("euclidean_distance"===e.name)return new iL(e);if("vector_length"===e.name)return new iR(e);if("unix_micros_to_timestamp"===e.name)return new iW(e);
3if("timestamp_to_unix_micros"===e.name)return new iX(e);if("unix_millis_to_timestamp"===e.name)return new iH(e);if("timestamp_to_unix_millis"===e.name)return new iZ(e);if("unix_seconds_to_timestamp"===e.name)return new iY(e);if("timestamp_to_unix_seconds"===e.name)return new i0(e);if("timestamp_add"===e.name)return new i2(e);if("timestamp_subtract"===e.name)return new i3(e)}throw Error(`Unknown Expr : ${e}`)}class sk{constructor(e){this.expr=e}evaluate(e,t){if(this.expr.fieldName===U){var r,n;return sC.newValue({referenceValue:(r=e.serializer,n=t.key,rN(r.databaseId,n.path))})}if("__update_time__"===this.expr.fieldName)return sC.newValue({timestampValue:rx(e.serializer,t.version)});if("__create_time__"===this.expr.fieldName)return sC.newValue({timestampValue:rx(e.serializer,t.createTime)});let s=t.data.field(this.expr._fieldPath);return s?em(s)?sC.newValue(function(e,t){if("estimate"===e.serverTimestampBehavior)return{timestampValue:rx(e.serializer,tA.fromTimestamp(ep(t)))};if("previous"===e.serverTimestampBehavior){let e=ef(t);if(e)return e}return{nullValue:"NULL_VALUE"}}(e,s)):sC.newValue(s):sC.mr()}}class sL{constructor(e){this.expr=e}evaluate(e,t){return sC.newValue(this.expr._getValue())}}class sR{constructor(e){this.expr=e}evaluate(e,t){let r=this.expr.ur.map(r=>sD(r).evaluate(e,t));return r.some(e=>e.gr())?sC.dr():sC.newValue({arrayValue:{values:r.map(e=>e.value)}})}}function sO(e){return eM(e)?Number(e.doubleValue):Number(e.integerValue)}function sP(e){return BigInt(e.integerValue)}let sU=BigInt("0x7fffffffffffffff"),sM=-BigInt("0x8000000000000000");class sF{constructor(e){this.expr=e}evaluate(e,t){b(this.expr.params.length>=2,24778);let r=sD(this.expr.params[0]).evaluate(e,t),n=sD(this.expr.params[1]).evaluate(e,t),s=this.wr(r,n);for(let r of this.expr.params.slice(2)){let n=sD(r).evaluate(e,t);s=this.wr(s,n)}return s}wr(e,t){if(e.gr()||t.gr())return sC.dr();if(e.yr()||t.yr())return sC.pr();let r=e.value,n=t.value;if(!eM(r)&&!eU(r)||!eM(n)&&!eU(n))return sC.dr();if(eM(r)||eM(n)){let e=this.br(r,n);return e?sC.newValue(e):sC.dr()}if(eU(r)&&eU(n)){let e=this.Sr(r,n);return void 0===e?sC.dr():"number"==typeof e?sC.newValue({doubleValue:e}):e<sM||e>sU?sC.dr():sC.newValue({integerValue:`${e}`})}return sC.dr()}}function sq(e,t){return eV(e)!==eV(t)?"TYPE_MISMATCH":eB(e)||eB(t)?"NOT_EQ":e$(e)&&e$(t)?"EQ":e$(e)||e$(t)?"NULL":eq(e)&&eq(t)?function(e,t){if(e.values?.length!==t.values?.length)return"NOT_EQ";let r=!1;for(let n=0;n<(e.values?.length??0);n++){let s=e.values[n],i=t.values[n];switch(sq(s,i)){case"EQ":break;case"NOT_EQ":case"TYPE_MISMATCH":return"NOT_EQ";case"NULL":r=!0;break;default:T(44609,{vr:s,Dr:i})}}return r?"NULL":"EQ"}(e.arrayValue,t.arrayValue):ej(e)&&ej(t)||ez(e)&&ez(t)?function(e,t){let r=e.fields||{},n=t.fields||{};if(z(r)!==z(n))return"NOT_EQ";let s=!1;for(let e in r)if(r.hasOwnProperty(e)){if(void 0===n[e])return"NOT_EQ";switch(sq(r[e],n[e])){case"NOT_EQ":case"TYPE_MISMATCH":return"NOT_EQ";case"NULL":s=!0}}return s?"NULL":"EQ"}(e.mapValue,t.mapValue):eA(e,t,{o:!1,t:!0,i:!0})?"EQ":"NOT_EQ"}class s$ extends sF{Sr(e,t){return sP(e)+sP(t)}br(e,t){return{doubleValue:sO(e)+sO(t)}}}class sB extends sF{constructor(e){super(e),this.expr=e}Sr(e,t){return sP(e)-sP(t)}br(e,t){return{doubleValue:sO(e)-sO(t)}}}class sz extends sF{constructor(e){super(e),this.expr=e}Sr(e,t){return sP(e)*sP(t)}br(e,t){return{doubleValue:sO(e)*sO(t)}}}class sj extends sF{constructor(e){super(e),this.expr=e}Sr(e,t){let r=sP(t);if(r!==BigInt(0))return sP(e)/r}br(e,t){let r=sO(t);return 0===r?{doubleValue:e_(r)?-1/0:1/0}:{doubleValue:sO(e)/r}}}class sG extends sF{constructor(e){super(e),this.expr=e}Sr(e,t){let r=sP(t);if(r!==BigInt(0))return sP(e)%r}br(e,t){let r=sO(t);if(0!==r)return{doubleValue:sO(e)%r}}}class sK{constructor(e){this.expr=e}evaluate(e,t){let r=!1,n=!1;for(let s of this.expr.params){let i=sD(s).evaluate(e,t);switch(i.type){case"BOOLEAN":if(!i.value?.booleanValue)return sC.newValue(eC);break;case"NULL":n=!0;break;default:r=!0}}return r?sC.dr():n?sC.pr():sC.newValue(eI)}}class sQ{constructor(e){this.expr=e}evaluate(e,t){b(1===this.expr.params.length,9634);let r=sD(this.expr.params[0]).evaluate(e,t);switch(r.type){case"BOOLEAN":return sC.newValue({booleanValue:!r.value?.booleanValue});case"NULL":return sC.pr();default:return sC.dr()}}}class sW{constructor(e){this.expr=e}evaluate(e,t){let r=!1,n=!1;for(let s of this.expr.params){let i=sD(s).evaluate(e,t);switch(i.type){case"BOOLEAN":if(i.value?.booleanValue)return sC.newValue(eI);break;case"NULL":n=!0;break;default:r=!0}}return r?sC.dr():n?sC.pr():sC.newValue(eC)}}class sH{constructor(e){this.expr=e}evaluate(e,t){let r=!1,n=!1;for(let s of this.expr.params){let i=sD(s).evaluate(e,t);switch(i.type){case"BOOLEAN":r=sH.xor(r,!!i.value?.booleanValue);break;case"NULL":n=!0;break;default:return sC.dr()}}return n?sC.pr():sC.newValue({booleanValue:r})}static xor(e,t){return(e||t)&&!(e&&t)}}class sY{constructor(e){this.expr=e}evaluate(e,t){b(2===this.expr.params.length,55094);let r=!1,n=sD(this.expr.params[0]).evaluate(e,t);switch(n.type){case"NULL":r=!0;break;case"ERROR":case"UNSET":return sC.dr()}let s=sD(this.expr.params[1]).evaluate(e,t);switch(s.type){case"ARRAY":break;case"NULL":r=!0;break;default:return sC.dr()}if(r)return sC.pr();for(let e of s.value?.arrayValue?.values??[])switch(e$(n.value)&&e$(e)?"EQ":sq(n.value,e)){case"EQ":return sC.newValue(eI);case"NOT_EQ":case"TYPE_MISMATCH":break;case"NULL":r=!0;break;default:T(44608,{value:n.value,candidate:e})}return r?sC.pr():sC.newValue(eC)}}class sJ{constructor(e){this.expr=e}evaluate(e,t){return new sQ(new sr("not",[new sr("equal_any",this.expr.params)])).evaluate(e,t)}}class sX{constructor(e){this.expr=e}evaluate(e,t){b(1===this.expr.params.length,23322);let r=sD(this.expr.params[0]).evaluate(e,t);switch(r.type){case"INT":return sC.newValue(eC);case"DOUBLE":return sC.newValue({booleanValue:isNaN(sO(r.value))});case"NULL":return sC.pr();default:return sC.dr()}}}class sZ{constructor(e){this.expr=e}evaluate(e,t){return b(1===this.expr.params.length,50406),new sQ(new sr("not",[new sr("is_nan",this.expr.params)])).evaluate(e,t)}}class s0{constructor(e){this.expr=e}evaluate(e,t){switch(b(1===this.expr.params.length,23123),sD(this.expr.params[0]).evaluate(e,t).type){case"NULL":return sC.newValue(eI);case"UNSET":case"ERROR":return sC.dr();default:return sC.newValue(eC)}}}class s1{constructor(e){this.expr=e}evaluate(e,t){return b(1===this.expr.params.length,23167),new sQ(new sr("not",[new sr("is_null",this.expr.params)])).evaluate(e,t)}}class s2{constructor(e){this.expr=e}evaluate(e,t){return b(1===this.expr.params.length,5228),"ERROR"===sD(this.expr.params[0]).evaluate(e,t).type?sC.newValue(eI):sC.newValue(eC)}}class s3{constructor(e){this.expr=e}evaluate(e,t){switch(b(1===this.expr.params.length,6877),sD(this.expr.params[0]).evaluate(e,t).type){case"ERROR":return sC.dr();case"UNSET":return sC.newValue(eC);default:return sC.newValue(eI)}}}class s4{constructor(e){this.expr=e}evaluate(e,t){b(3===this.expr.params.length,11706);let r=sD(this.expr.params[0]).evaluate(e,t);switch(r.type){case"BOOLEAN":return r.value?.booleanValue?sD(this.expr.params[1]).evaluate(e,t):sD(this.expr.params[2]).evaluate(e,t);case"NULL":return sD(this.expr.params[2]).evaluate(e,t);default:return sC.dr()}}}class s6{constructor(e){this.expr=e}evaluate(e,t){let r;for(let n of this.expr.params.map(r=>sD(r).evaluate(e,t)))switch(n.type){case"ERROR":case"UNSET":case"NULL":continue;default:r=void 0===r||ek(n.value,r.value)>0?n:r}return void 0===r?sC.pr():r}}class s8{constructor(e){this.expr=e}evaluate(e,t){let r;for(let n of this.expr.params.map(r=>sD(r).evaluate(e,t)))switch(n.type){case"ERROR":case"UNSET":case"NULL":continue;default:r=void 0===r||0>ek(n.value,r.value)?n:r}return void 0===r?sC.pr():r}}class s5{constructor(e){this.expr=e}evaluate(e,t){b(2===this.expr.params.length,31033,`${this.expr.name}() function should have exactly 2 params`);let r=sD(this.expr.params[0]).evaluate(e,t);switch(r.type){case"ERROR":case"UNSET":return sC.dr()}let n=sD(this.expr.params[1]).evaluate(e,t);switch(n.type){case"ERROR":case"UNSET":return sC.dr()}return this.Cr(r,n)}}class s9 extends s5{constructor(e){super(e),this.expr=e}Cr(e,t){if(e.yr()&&t.yr())return sC.newValue(eI);if(e.yr()||t.yr()||eB(e.value)||eB(t.value)||eV(e.value)!==eV(t.value))return sC.newValue(eC);switch(sq(e.value,t.value)){case"EQ":return sC.newValue(eI);case"NOT_EQ":return sC.newValue(eC);case"NULL":return sC.pr();default:T(44615,{left:e,right:t})}}}class s7 extends s5{constructor(e){super(e),this.expr=e}Cr(e,t){switch(sq(e.value,t.value)){case"EQ":return sC.newValue(eC);case"NOT_EQ":case"TYPE_MISMATCH":return sC.newValue(eI);case"NULL":return sC.pr();default:T(44614,{left:e,right:t})}}}class ie extends s5{constructor(e){super(e),this.expr=e}Cr(e,t){return eV(e.value)!==eV(t.value)||eB(e.value)||eB(t.value)?sC.newValue(eC):sC.newValue({booleanValue:0>ek(e.value,t.value)})}}class it extends s5{constructor(e){super(e),this.expr=e}Cr(e,t){return eV(e.value)!==eV(t.value)||eB(e.value)||eB(t.value)?sC.newValue(eC):"EQ"===sq(e.value,t.value)?sC.newValue(eI):sC.newValue({booleanValue:0>ek(e.value,t.value)})}}class ir extends s5{constructor(e){super(e),this.expr=e}Cr(e,t){return eV(e.value)!==eV(t.value)||eB(e.value)||eB(t.value)?sC.newValue(eC):sC.newValue({booleanValue:ek(e.value,t.value)>0})}}class is extends s5{constructor(e){super(e),this.expr=e}Cr(e,t){return eV(e.value)!==eV(t.value)||eB(e.value)||eB(t.value)?sC.newValue(eC):"EQ"===sq(e.value,t.value)?sC.newValue(eI):sC.newValue({booleanValue:ek(e.value,t.value)>0})}}class ii{constructor(e){this.expr=e}evaluate(e,t){throw Error("Unimplemented")}}class ia{constructor(e){this.expr=e}evaluate(e,t){b(1===this.expr.params.length,216);let r=sD(this.expr.params[0]).evaluate(e,t);switch(r.type){case"NULL":return sC.pr();case"ARRAY":{let e=r.value.arrayValue?.values??[];return sC.newValue({arrayValue:{values:[...e].reverse()}})}default:return sC.dr()}}}class io{constructor(e){this.expr=e}evaluate(e,t){return b(2===this.expr.params.length,52884),new sY(new sr("eq_any",[this.expr.params[1],this.expr.params[0]])).evaluate(e,t)}}class il{constructor(e){this.expr=e}evaluate(e,t){b(2===this.expr.params.length,1392);let r=!1,n=sD(this.expr.params[0]).evaluate(e,t);switch(n.type){case"ARRAY":break;case"NULL":r=!0;break;default:return sC.dr()}let s=sD(this.expr.params[1]).evaluate(e,t);switch(s.type){case"ARRAY":break;case"NULL":r=!0;break;default:return sC.dr()}if(r)return sC.pr();let i=s.value?.arrayValue?.values??[],a=n.value?.arrayValue?.values??[];for(let e of i){let t=!1;for(let n of(r=!1,a)){switch(e$(e)&&e$(n)?"EQ":sq(e,n)){case"EQ":t=!0;break;case"NOT_EQ":case"TYPE_MISMATCH":break;case"NULL":r=!0;break;default:T(44613,{value:n,search:e})}if(t)break}if(!t)return sC.newValue(eC)}return sC.newValue(eI)}}class iu{constructor(e){this.expr=e}evaluate(e,t){b(2===this.expr.params.length,2680);let r=!1,n=sD(this.expr.params[0]).evaluate(e,t);switch(n.type){case"ARRAY":break;case"NULL":r=!0;break;default:return sC.dr()}let s=sD(this.expr.params[1]).evaluate(e,t);switch(s.type){case"ARRAY":break;case"NULL":r=!0;break;default:return sC.dr()}if(r)return sC.pr();let i=s.value?.arrayValue?.values??[];for(let e of n.value?.arrayValue?.values??[])for(let t of i)switch(e$(e)&&e$(t)?"EQ":sq(e,t)){case"EQ":return sC.newValue(eI);case"NOT_EQ":case"TYPE_MISMATCH":break;case"NULL":r=!0;break;default:T(60403,{value:e,search:t})}return r?sC.pr():sC.newValue(eC)}}class ic{constructor(e){this.expr=e}evaluate(e,t){b(1===this.expr.params.length,38605);let r=sD(this.expr.params[0]).evaluate(e,t);switch(r.type){case"NULL":return sC.pr();case"ARRAY":return sC.newValue({integerValue:`${r.value?.arrayValue?.values?.length??0}`});default:return sC.dr()}}}class ih{constructor(e){this.expr=e}evaluate(e,t){throw Error("Unimplemented")}}
3class id{constructor(e){this.expr=e}evaluate(e,t){b(1===this.expr.params.length,1508);let r=sD(this.expr.params[0]).evaluate(e,t);switch(r.type){case"NULL":return sC.pr();case"BYTES":{let e=r.value?.bytesValue;if("string"==typeof e){let t=es.fromBase64String(e).toUint8Array();return t.reverse(),sC.newValue({bytesValue:es.fromUint8Array(t).toBase64()})}return sC.newValue({bytesValue:new Uint8Array(e).reverse()})}case"STRING":{let e=r.value?.stringValue,t=Array.from(new Intl.__PRIVATE_Segmenter(void 0,{granularity:"grapheme"}).segment(e),e=>e.segment).reverse();return sC.newValue({stringValue:t.join("")})}default:return sC.dr()}}}class im{constructor(e){this.expr=e}evaluate(e,t){throw Error("Unimplemented")}}class ip{constructor(e){this.expr=e}evaluate(e,t){throw Error("Unimplemented")}}class ig{constructor(e){this.expr=e}evaluate(e,t){b(1===this.expr.params.length,19400);let r=sD(this.expr.params[0]).evaluate(e,t);switch(r.type){case"NULL":return sC.pr();case"STRING":{let e=function(e){let t=0;for(let r=0;r<e.length;r++){let n=e.codePointAt(r);if(void 0===n)return;if(n<=65535)if(n>=55296&&n<=57343)if(n<=56319){let n=e.codePointAt(r+1);void 0!==n&&n>=56320&&n<=57343?(t+=1,r++):t+=1}else t+=1;else t+=1;else{if(!(n<=1114111))return;t+=1,r++}}return t}(r.value.stringValue);return void 0===e?sC.dr():sC.newValue({integerValue:e})}default:return sC.dr()}}}class iy{constructor(e){this.expr=e}evaluate(e,t){b(1===this.expr.params.length,8486);let r=sD(this.expr.params[0]).evaluate(e,t);switch(r.type){case"BYTES":{let e=r.value?.bytesValue;return"string"==typeof e?sC.newValue({integerValue:es.fromBase64String(e).toUint8Array().length}):sC.newValue({integerValue:new Uint8Array(e).length})}case"STRING":{let e=function(e){let t=0;for(let r=0;r<e.length;r++){let n=e.codePointAt(r);if(void 0===n)return;if(n>=55296&&n<=57343){if(!(n<=56319))return;{let n=e.codePointAt(r+1);if(void 0===n||!(n>=56320&&n<=57343))return;t+=4,r++}}else if(n<=127)t+=1;else if(n<=2047)t+=2;else if(n<=65535)t+=3;else{if(!(n<=1114111))return;t+=4,r++}}return t}(r.value?.stringValue);return void 0===e?sC.dr():sC.newValue({integerValue:e})}case"NULL":return sC.pr();default:return sC.dr()}}}class iw{constructor(e){this.expr=e}evaluate(e,t){b(2===this.expr.params.length,39773,`${this.expr.name}() function should have exactly two parameters`);let r=!1,n=sD(this.expr.params[0]).evaluate(e,t);switch(n.type){case"STRING":break;case"NULL":r=!0;break;default:return sC.dr()}let s=sD(this.expr.params[1]).evaluate(e,t);switch(s.type){case"STRING":break;case"NULL":r=!0;break;default:return sC.dr()}return r?sC.pr():this.Fr(n.value?.stringValue,s.value?.stringValue)}}class iv extends iw{Fr(e,t){try{let r=function(e){let t="";for(let r=0;r<e.length;r++){let n=e.charAt(r);switch(n){case"_":t+=".";break;case"%":t+=".*";break;case"\\":case".":case"*":case"?":case"+":case"^":case"$":case"|":case"(":case")":case"[":case"]":case"{":case"}":t+="\\"+n;break;default:t+=n}}return"^"+t+"$"}(t),n=d.L3.compile(r);return sC.newValue({booleanValue:n.matches(e)})}catch(e){return _(`Invalid LIKE pattern converted to regex: ${t}, returning error. Error: ${e}`),sC.dr()}}}class i_ extends iw{Fr(e,t){try{let r=d.L3.compile(t);return sC.newValue({booleanValue:r.test(e)})}catch(e){return _(`Invalid regex pattern found in regex_contains: ${t}, returning error`),sC.dr()}}}class iE extends iw{Fr(e,t){try{return sC.newValue({booleanValue:d.L3.compile(t).matches(e)})}catch(e){return _(`Invalid regex pattern found in regex_match: ${t}, returning error`),sC.dr()}}}class iT extends iw{Fr(e,t){return sC.newValue({booleanValue:e.includes(t)})}}class ix extends iw{Fr(e,t){return sC.newValue({booleanValue:e.startsWith(t)})}}class ib extends iw{Fr(e,t){return sC.newValue({booleanValue:e.endsWith(t)})}}class iN{constructor(e){this.expr=e}evaluate(e,t){b(1===this.expr.params.length,29079);let r=sD(this.expr.params[0]).evaluate(e,t);switch(r.type){case"STRING":return sC.newValue({stringValue:r.value?.stringValue?.toLowerCase()});case"NULL":return sC.pr();default:return sC.dr()}}}class iS{constructor(e){this.expr=e}evaluate(e,t){b(1===this.expr.params.length,60487);let r=sD(this.expr.params[0]).evaluate(e,t);switch(r.type){case"STRING":return sC.newValue({stringValue:r.value?.stringValue?.toUpperCase()});case"NULL":return sC.pr();default:return sC.dr()}}}class iI{constructor(e){this.expr=e}evaluate(e,t){b(1===this.expr.params.length,28544);let r=sD(this.expr.params[0]).evaluate(e,t);switch(r.type){case"STRING":return sC.newValue({stringValue:r.value?.stringValue?.trim()});case"NULL":return sC.pr();default:return sC.dr()}}}class iC{constructor(e){this.expr=e}evaluate(e,t){let r=this.expr.params.map(r=>sD(r).evaluate(e,t)),n="",s=!1;for(let e of r)switch(e.type){case"STRING":n+=e.value.stringValue;break;case"NULL":s=!0;break;default:return sC.dr()}return s?sC.pr():sC.newValue({stringValue:n})}}class iV{constructor(e){this.expr=e}evaluate(e,t){b(2===this.expr.params.length,4483);let r=sD(this.expr.params[0]).evaluate(e,t);switch(r.type){case"UNSET":return sC.mr();case"MAP":break;default:return sC.dr()}let n=sD(this.expr.params[1]).evaluate(e,t);if("STRING"!==n.type)return sC.dr();let s=r.value?.mapValue?.fields?.[n.value?.stringValue];return void 0===s?sC.mr():sC.newValue(s)}}class iA{constructor(e){this.expr=e}evaluate(e,t){b(2===this.expr.params.length,25231,`${this.expr.name}() function should have exactly 2 params`);let r=!1,n=sD(this.expr.params[0]).evaluate(e,t);switch(n.type){case"VECTOR":break;case"NULL":r=!0;break;default:return sC.dr()}let s=sD(this.expr.params[1]).evaluate(e,t);switch(s.type){case"VECTOR":break;case"NULL":r=!0;break;default:return sC.dr()}if(r)return sC.pr();let i=eG(n.value),a=eG(s.value);if(void 0===i||void 0===a||i.values?.length!==a.values?.length)return sC.dr();let o=this.Or(i,a);return void 0===o||isNaN(o)?sC.dr():sC.newValue({doubleValue:o})}}class iD extends iA{Or(e,t){let r=e?.values??[],n=t?.values??[];if(0===r.length)return;let s=0,i=0,a=0;for(let e=0;e<r.length;e++){if(!eF(r[e])||!eF(n[e]))return;let t=sO(r[e]),o=sO(n[e]);s+=t*o,i+=t*t,a+=o*o}let o=Math.sqrt(i)*Math.sqrt(a);if(0!==o)return 1-Math.max(-1,Math.min(1,s/o))}}class ik extends iA{Or(e,t){let r=e?.values??[],n=t?.values??[];if(0===r.length)return 0;let s=0;for(let e=0;e<r.length;e++){if(!eF(r[e])||!eF(n[e]))return;s+=sO(r[e])*sO(n[e])}return s}}class iL extends iA{Or(e,t){let r=e?.values??[],n=t?.values??[];if(0===r.length)return 0;let s=0;for(let e=0;e<r.length;e++){if(!eF(r[e])||!eF(n[e]))return;s+=Math.pow(sO(r[e])-sO(n[e]),2)}return Math.sqrt(s)}}class iR{constructor(e){this.expr=e}evaluate(e,t){b(1===this.expr.params.length,39044);let r=sD(this.expr.params[0]).evaluate(e,t);switch(r.type){case"VECTOR":{let e=eG(r.value);return sC.newValue({integerValue:e?.values?.length??0})}case"NULL":return sC.pr();default:return sC.dr()}}}let iO=BigInt(-0xe7791f700),iP=BigInt(0x3afff4417f),iU=BigInt(1e3),iM=BigInt(1e6),iF=iO*iU,iq=iP*iU+BigInt(999),i$=iO*iM,iB=iP*iM+BigInt(999999);function iz(e){return e>=i$&&e<=iB}function ij(e,t){let r=BigInt(e);return!(r<iO||r>iP)&&!(t<0||t>=1e9)&&(r!==iO||0===t)&&!(r===iP&&t>0x3b9ac9ff)}function iG(e,t){return t<0?{seconds:e-1,nanos:t+1e9}:{seconds:e,nanos:t}}function iK(e){return BigInt(e.seconds)*iM+BigInt(Math.trunc(e.nanoseconds/1e3))}class iQ{constructor(e){this.expr=e}evaluate(e,t){b(1===this.expr.params.length,49262,`${this.expr.name}() function should have exactly one parameter`);let r=sD(this.expr.params[0]).evaluate(e,t);switch(r.type){case"INT":return this.toTimestamp(BigInt(r.value.integerValue));case"NULL":return sC.pr();default:return sC.dr()}}}class iW extends iQ{toTimestamp(e){if(!iz(e))return sC.dr();let t=Number(e/iM),r=Number(e%iM*BigInt(1e3)),n=iG(t,r);return ij(t=n.seconds,r=n.nanos)?sC.newValue({timestampValue:{seconds:t,nanos:r}}):sC.dr()}}class iH extends iQ{toTimestamp(e){if(!(e>=iF&&e<=iq))return sC.dr();let t=Number(e/iU),r=Number(e%iU*BigInt(1e6)),n=iG(t,r);return ij(t=n.seconds,r=n.nanos)?sC.newValue({timestampValue:{seconds:t,nanos:r}}):sC.dr()}}class iY extends iQ{toTimestamp(e){if(!(e>=iO&&e<=iP))return sC.dr();let t=Number(e);return sC.newValue({timestampValue:{seconds:t,nanos:0}})}}class iJ{constructor(e){this.expr=e}evaluate(e,t){b(1===this.expr.params.length,1265,`${this.expr.name}() function should have exactly one parameter`);let r=sD(this.expr.params[0]).evaluate(e,t);switch(r.type){case"TIMESTAMP":break;case"NULL":return sC.pr();default:return sC.dr()}let n=rE(r.value.timestampValue);return ij(n.seconds,n.nanoseconds)?this.Mr(n):sC.dr()}}class iX extends iJ{Mr(e){let t=iK(e);return iz(t)?sC.newValue({integerValue:`${t.toString()}`}):sC.dr()}}class iZ extends iJ{Mr(e){let t=iK(e),r=t/BigInt(1e3),n=t%BigInt(1e3);return r>BigInt(0)||n===BigInt(0)?sC.newValue({integerValue:r.toString()}):sC.newValue({integerValue:(r-BigInt(1)).toString()})}}class i0 extends iJ{Mr(e){let t=BigInt(e.seconds);return t>=iO&&t<=iP?sC.newValue({integerValue:t.toString()}):sC.dr()}}class i1{constructor(e){this.expr=e}evaluate(e,t){let r,n;b(3===this.expr.params.length,2775,`${this.expr.name}() function should have exactly 3 parameters`);let s=!1,i=sD(this.expr.params[0]).evaluate(e,t);switch(i.type){case"TIMESTAMP":break;case"NULL":s=!0;break;default:return sC.dr()}let a=sD(this.expr.params[1]).evaluate(e,t);switch(a.type){case"STRING":if(void 0===(r=function(e){switch(e){case"microsecond":return"microsecond";case"millisecond":return"millisecond";case"second":return"second";case"minute":return"minute";case"hour":return"hour";case"day":return"day";default:return}}(a.value.stringValue)))return sC.dr();break;case"NULL":s=!0;break;default:return sC.dr()}let o=sD(this.expr.params[2]).evaluate(e,t);switch(o.type){case"INT":break;case"NULL":s=!0;break;default:return sC.dr()}if(s)return sC.pr();
3let l=BigInt(o.value.integerValue);try{switch(r){case"microsecond":n=l;break;case"millisecond":n=l*BigInt(1e3);break;case"second":n=l*BigInt(1e6);break;case"minute":n=l*BigInt(6e7);break;case"hour":n=l*BigInt(36e8);break;case"day":n=l*BigInt(864e8);break;default:return sC.dr()}if("microsecond"!==r&&l!==BigInt(0)&&n/l!==BigInt(this.Nr(r)))return sC.dr()}catch(e){return _(`Error during timestamp arithmetic: ${e}`),sC.dr()}let u=rE(i.value.timestampValue);if(!ij(u.seconds,u.nanoseconds))return sC.dr();let c=iK(u),h=this.Lr(c,n);if(!iz(h))return sC.dr();let d=Number(h/iM),m=h%iM,f=Number((m<0?m+iM:m)*BigInt(1e3)),p=m<0?d-1:d;return ij(p,f)?sC.newValue({timestampValue:{seconds:p,nanos:f}}):sC.dr()}Nr(e){switch(e){case"millisecond":return 1e3;case"second":return 1e6;case"minute":return 6e7;case"hour":return 36e8;case"day":return 864e8;default:return 1}}}class i2 extends i1{Lr(e,t){return e+t}}class i3 extends i1{Lr(e,t){return e-t}}function i4(e){if((e=sA(e))instanceof n9)return`fld(${e.fieldName})`;if(e instanceof n7){var t;return`cst(${null===(t=e.value)?"null":"number"==typeof t?t.toString():"string"==typeof t?`"${t}"`:t instanceof nS?`ref(${t.path})`:t instanceof nD?`vec(${JSON.stringify(t)})`:JSON.stringify(t)})`}if(e instanceof sr)return`fn(${e.name},[${e.params.map(i4).join(",")}])`;if("ListOfExpressions"===e.expressionType)return`list([${e.ur.map(i4).join(",")}])`;throw Error(`Unrecognized expr ${JSON.stringify(e,null,2)}`)}function i6(e){return`${Array.from(e.entries()).sort().map(([e,t])=>`${e}=${i4(t)}`).join(",")}`}function i8(e){return e.stages.map(e=>(function(e){if(e instanceof su)return`${e._name}(${i6(e.fields)})`;if(e instanceof sc){let t=`${e._name}(${i6(e.accumulators)})`;return e.groups.size>0&&(t+=`grouping(${i6(e.groups)})`),t}if(e instanceof sh)return`${e._name}(${i6(e.groups)})`;if(e instanceof sd)return`${e._name}(${e.Er})`;if(e instanceof sm)return`${e._name}(${e.collectionId})`;if(e instanceof sf)return`${e._name}()`;if(e instanceof sp)return`${e._name}(${e.hr.sort()})`;if(e instanceof sg)return`${e._name}(${i4(e.condition)})`;if(e instanceof sy)return`${e._name}(${e.limit})`;if(e instanceof s_)return`${e._name}(${e.orderings.map(e=>`${i4(e.expr)}${e.direction}`).join(",")})`;throw Error(`Unrecognized stage ${e._name}`)})(e)).join("|")}function i5(e){return e instanceof sx}function i9(e){return i5(e)?i8(e):tJ(e)}function i7(e){return i5(e)?i8(e):`${tP(tG(e))}|lt:${e.limitType}`}function ae(e,t){return e instanceof sx&&t instanceof sx?i8(e)===i8(t):!(e instanceof sx&&!(t instanceof sx)||!(e instanceof sx)&&t instanceof sx)&&tU(tG(e),tG(t))&&e.limitType===t.limitType}function at(e){return tM(e)?i8(e):tP(e)}function ar(e,t){return e instanceof sx&&t instanceof sx?i8(e)===i8(t):!(e instanceof sx&&!(t instanceof sx)||!(e instanceof sx)&&t instanceof sx)&&tU(e,t)}class an{constructor(e,t,r,n){this.batchId=e,this.localWriteTime=t,this.baseMutations=r,this.mutations=n}applyToRemoteDocument(e,t){let r=t.mutationResults;for(let t=0;t<this.mutations.length;t++){let n=this.mutations[t];n.key.isEqual(e.key)&&function(e,t,r){let n,s;e instanceof to?(n=e.value.clone(),s=tc(e.fieldTransforms,t,r.transformResults),n.setAll(s),t.convertToFoundDocument(r.version,n).setHasCommittedMutations()):e instanceof tl?function(e,t,r){if(!tr(e.precondition,t))return t.convertToUnknownDocument(r.version);let n=tc(e.fieldTransforms,t,r.transformResults),s=t.data;s.setAll(tu(e)),s.setAll(n),t.convertToFoundDocument(r.version,s).setHasCommittedMutations()}(e,t,r):t.convertToNoDocument(r.version).setHasCommittedMutations()}(n,e,r[t])}}applyToLocalView(e,t){for(let r of this.baseMutations)r.key.isEqual(e.key)&&(t=ti(r,e,t,this.localWriteTime));for(let r of this.mutations)r.key.isEqual(e.key)&&(t=ti(r,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){let r=t8();return this.mutations.forEach(n=>{let s=e.get(n.key),i=s.overlayedDocument,a=this.applyToLocalView(i,s.mutatedFields),o=ts(i,a=t.has(n.key)?null:a);null!==o&&r.set(n.key,o),i.isValidDocument()||i.convertToNoDocument(tA.min())}),r}keys(){return this.mutations.reduce((e,t)=>
3e.add(t.key),t9())}isEqual(e){return this.batchId===e.batchId&&V(this.mutations,e.mutations,(e,t)=>ta(e,t))&&V(this.baseMutations,e.baseMutations,(e,t)=>ta(e,t))}}class as{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return null!==e&&this.mutation===e.mutation}toString(){return`Overlay{
4      largestBatchId: ${this.largestBatchId},
5      mutation: ${this.mutation.toString()}
6    }`}}class ai{constructor(e,t,r,n,s=tA.min(),i=tA.min(),a=es.EMPTY_BYTE_STRING,o=null){this.target=e,this.targetId=t,this.purpose=r,this.sequenceNumber=n,this.snapshotVersion=s,this.lastLimboFreeSnapshotVersion=i,this.resumeToken=a,this.expectedCount=o}withSequenceNumber(e){return new ai(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new ai(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new ai(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new ai(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class aa{constructor(e){this.qr=e}}class ao{Xr(e,t){this.ei(e,t),t.ti()}ei(e,t){if("nullValue"in e)this.ni(t,5);else if("booleanValue"in e)this.ni(t,10),t.ri(+!!e.booleanValue);else if("integerValue"in e)this.ni(t,15),t.ri(eo(e.integerValue));else if("doubleValue"in e){let r=eo(e.doubleValue);isNaN(r)?this.ni(t,13):(this.ni(t,15),e_(r)?t.ri(0):t.ri(r))}else if("timestampValue"in e){let r=e.timestampValue;this.ni(t,20),"string"==typeof r&&(r=ea(r)),t.ii(`${r.seconds||""}`),t.ri(r.nanos||0)}else if("stringValue"in e)this.si(e.stringValue,t),this._i(t);else if("bytesValue"in e)this.ni(t,30),t.oi(el(e.bytesValue)),this._i(t);else if("referenceValue"in e)this.ai(e.referenceValue,t);else if("geoPointValue"in e){let r=e.geoPointValue;this.ni(t,45),t.ri(r.latitude||0),t.ri(r.longitude||0)}else"mapValue"in e?eQ(e)?this.ni(t,Number.MAX_SAFE_INTEGER):ej(e)?this.ui(e.mapValue,t):(this.ci(e.mapValue,t),this._i(t)):"arrayValue"in e?(this.li(e.arrayValue,t),this._i(t)):T(19022,{Ei:e})}si(e,t){this.ni(t,25),this.hi(e,t)}hi(e,t){t.ii(e)}ci(e,t){let r=e.fields||{};for(let e of(this.ni(t,55),Object.keys(r)))this.si(e,t),this.ei(r[e],t)}ui(e,t){let r=e.fields||{};this.ni(t,53);let n=r[eN].arrayValue?.values?.length||0;this.ni(t,15),t.ri(eo(n)),this.si(eN,t),this.ei(r[eN],t)}li(e,t){let r=e.values||[];for(let e of(this.ni(t,50),r))this.ei(e,t)}ai(e,t){this.ni(t,37),K.fromName(e).path.forEach(e=>{this.ni(t,60),this.hi(e,t)})}ni(e,t){e.ri(t)}_i(e){e.ri(2)}}ao.Ti=new ao;class al{constructor(){this.Yi=new au}addToCollectionParentIndex(e,t){return this.Yi.add(t),nf.resolve()}getCollectionParents(e,t){return nf.resolve(this.Yi.getEntries(t))}addFieldIndex(e,t){return nf.resolve()}deleteFieldIndex(e,t){return nf.resolve()}deleteAllFieldIndexes(e){return nf.resolve()}createTargetIndexes(e,t){return nf.resolve()}getDocumentsMatchingTarget(e,t){return nf.resolve(null)}getIndexType(e,t){return nf.resolve(0)}getFieldIndexes(e,t){return nf.resolve([])}getNextCollectionGroupToUpdate(e){return nf.resolve(null)}getMinOffset(e,t){return nf.resolve(tL.min())}getMinOffsetFromCollectionGroup(e,t){return nf.resolve(tL.min())}updateCollectionGroup(e,t,r){return nf.resolve()}updateIndexEntries(e,t){return nf.resolve()}}class au{constructor(){this.index={}}add(e){let t=e.lastSegment(),r=e.popLast(),n=this.index[t]||new L(F.comparator),s=!n.has(r);return this.index[t]=n.add(r),s}has(e){let t=e.lastSegment(),r=e.popLast(),n=this.index[t];return n&&n.has(r)}getEntries(e){return(this.index[e]||new L(F.comparator)).toArray()}}new Uint8Array(0);class ac{constructor(e){this.gs=e}next(){return this.gs+=2,this.gs}static ys(){return new ac(0)}static ws(){return new ac(-1)}}function ah(e,t){let r=t;for(let t of e.stages)r=function(e,t,r){if(t instanceof sd)return r.filter(e=>e.isFoundDocument()&&`/${e.key.getCollectionPath().canonicalString()}`===t.Er);if(t instanceof sg)return r.filter(r=>{let n=sV(sD(t.condition).evaluate(e,r));return void 0!==n&&eA(n,eI)});if(t instanceof sm)return r.filter(e=>e.isFoundDocument()&&e.key.getCollectionPath().lastSegment()===t.collectionId);if(t instanceof sf)return r.filter(e=>e.isFoundDocument());if(t instanceof sp)return r.filter(e=>e.isFoundDocument()&&t.Tr.has(e.key.path.toStringWithLeadingSlash()));if(t instanceof sy)return r.slice(0,t.limit);if(t instanceof s_){let n;return n=t.orderings.map(e=>({Os:sD(e.expr),direction:e.direction})),[...r].sort((t,r)=>{for(let{Os:s,direction:i}of n){let n=ek(sV(s.evaluate(e,t))??eS,sV(s.evaluate(e,r))??eS);if(0!==n)return"ascending"===i?n:-n}return 0})}throw Error(`Unknown stage: ${t._name}`)}({serializer:e.serializer,serverTimestampBehavior:e.listenOptions?.serverTimestampBehavior},t,r);return r}function ad(e,t){return ah(e,[t]).length>0}function am(e){let t=function(e){for(let t=e.stages.length-1;t>=0;t--){let r=e.stages[t];if(r instanceof s_)return r.orderings}throw Error("Pipeline must contain at least one Sort stage")}(e);return(r,n)=>{for(let s of t){let t=ek(sV(sD(s.expr).evaluate({serializer:e.serializer},r))||eS,sV(sD(s.expr).evaluate({serializer:e.serializer},n))||eS);if(0!==t)return"ascending"===s.direction?t:-t}return 0}}function af(e){for(let t=e.stages.length-1;t>=0;t--){let r=e.stages[t];if(r instanceof sy)return{limit:r.limit}}}class ap{constructor(){this.changes=new t2(e=>e.toString(),(e,t)=>e.isEqual(t)),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,tD.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();let r=this.changes.get(t);return void 0!==r?nf.resolve(r):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}
6assertNotApplied(){}}class ag{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}class ay{constructor(e,t,r,n){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=r,this.indexManager=n}getDocument(e,t){let r=null;return this.documentOverlayCache.getOverlay(e,t).next(n=>(r=n,this.remoteDocumentCache.getEntry(e,t))).next(e=>(null!==r&&ti(r.mutation,e,B.empty(),er.now()),e))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.getLocalViewOfDocuments(e,t,t9()).next(()=>t))}getLocalViewOfDocuments(e,t,r=t9()){let n=t8();return this.populateOverlays(e,n,t).next(()=>this.computeViews(e,t,n,r).next(e=>{let t=t6();return e.forEach((e,r)=>{t=t.insert(e,r.overlayedDocument)}),t}))}getOverlayedDocuments(e,t){let r=t8();return this.populateOverlays(e,r,t).next(()=>this.computeViews(e,t,r,t9()))}populateOverlays(e,t,r){let n=[];return r.forEach(e=>{t.has(e)||n.push(e)}),this.documentOverlayCache.getOverlays(e,n).next(e=>{e.forEach((e,r)=>{t.set(e,r)})})}computeViews(e,t,r,n){let s=t3,i=t8(),a=t8();return t.forEach((e,t)=>{let a=r.get(t.key);n.has(t.key)&&(void 0===a||a.mutation instanceof tl)?s=s.insert(t.key,t):void 0!==a?(i.set(t.key,a.mutation.getFieldMask()),ti(a.mutation,t,a.mutation.getFieldMask(),er.now())):i.set(t.key,B.empty())}),this.recalculateAndSaveOverlays(e,s).next(e=>(e.forEach((e,t)=>i.set(e,t)),t.forEach((e,t)=>a.set(e,new ag(t,i.get(e)??null))),a))}recalculateAndSaveOverlays(e,t){let r=t8(),n=new A((e,t)=>e-t),s=t9();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(e=>{for(let s of e)s.keys().forEach(e=>{let i=t.get(e);if(null===i)return;let a=r.get(e)||B.empty();a=s.applyToLocalView(i,a),r.set(e,a);let o=(n.get(s.batchId)||t9()).add(e);n=n.insert(s.batchId,o)})}).next(()=>{let i=[],a=n.getReverseIterator();for(;a.hasNext();){let n=a.getNext(),o=n.key,l=n.value,u=t8();l.forEach(e=>{if(!s.has(e)){let n=ts(t.get(e),r.get(e));null!==n&&u.set(e,n),s=s.add(e)}}),i.push(this.documentOverlayCache.saveOverlays(e,o,u))}return nf.waitFor(i)}).next(()=>r)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.recalculateAndSaveOverlays(e,t))}getDocumentsMatchingQuery(e,t,r,n){return i5(t)?this.getDocumentsMatchingPipeline(e,t,r,n):K.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length?this.getDocumentsMatchingDocumentQuery(e,t.path):tz(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,r,n):this.getDocumentsMatchingCollectionQuery(e,t,r,n)}getNextDocuments(e,t,r,n){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,r,n).next(s=>{let i=n-s.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,r.largestBatchId,n-s.size):nf.resolve(t8()),a=-1,o=s;return i.next(t=>nf.forEach(t,(t,r)=>(a<r.largestBatchId&&(a=r.largestBatchId),s.get(t)?nf.resolve():this.remoteDocumentCache.getEntry(e,t).next(e=>{o=o.insert(t,e)}))).next(()=>this.populateOverlays(e,t,s)).next(()=>this.computeViews(e,o,t,t9())).next(e=>{let t;return{batchId:a,changes:(t=t4,e.forEach((e,r)=>t=t.insert(e,r.overlayedDocument)),t)}}))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new K(t)).next(e=>{let t=t6();return e.isFoundDocument()&&(t=t.insert(e.key,e)),t})}getDocumentsMatchingCollectionGroupQuery(e,t,r,n){let s=t.collectionGroup,i=t6();return this.indexManager.getCollectionParents(e,s).next(a=>nf.forEach(a,a=>{let o=new tq(a.child(s),null,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt);return this.getDocumentsMatchingCollectionQuery(e,o,r,n).next(e=>{e.forEach((e,t)=>{i=i.insert(e,t)})})}).next(()=>i))}getDocumentsMatchingCollectionQuery(e,t,r,n){let s;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,r.largestBatchId).next(i=>(s=i,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,r,s,n))).next(e=>this.retrieveMatchingLocalDocuments(s,e,e=>tX(t,e)))}getDocumentsMatchingPipeline(e,t,r,n){if("collection_group"===sb(t)){let s=sS(t),i=t6();return this.indexManager.getCollectionParents(e,s).next(a=>nf.forEach(a,a=>{var o;let l,u=(o=a.child(s),l=t.stages.map(e=>e instanceof sm?new sd(o.canonicalString(),{}):e),new sx(t.serializer,l));return this.getDocumentsMatchingPipeline(e,u,r,n).next(e=>{e.forEach((e,t)=>{i=i.insert(e,t)})})}).next(()=>i))}{let s;return this.getOverlaysForPipeline(e,t,r.largestBatchId).next(i=>
6{switch(s=i,sb(t)){case"collection":return this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,r,s,n);case"documents":let a=t9();for(let e of sI(t))a=a.add(K.fromPath(e));return this.remoteDocumentCache.getEntries(e,a);case"database":return this.remoteDocumentCache.getAllEntries(e);default:throw new P("invalid-argument",`Invalid pipeline source to execute offline: ${i8(t)}`)}}).next(e=>this.retrieveMatchingLocalDocuments(s,e,e=>ad(t,e)))}}retrieveMatchingLocalDocuments(e,t,r){e.forEach((e,r)=>{let n=r.getKey();null===t.get(n)&&(t=t.insert(n,tD.newInvalidDocument(n)))});let n=t6();return t.forEach((t,s)=>{let i=e.get(t);void 0!==i&&ti(i.mutation,s,B.empty(),er.now()),r(s)&&(n=n.insert(t,s))}),n}getOverlaysForPipeline(e,t,r){switch(sb(t)){case"collection":return this.documentOverlayCache.getOverlaysForCollection(e,F.fromString(sN(t)),r);case"collection_group":throw new P("invalid-argument",`Unexpected collection group pipeline: ${i8(t)}`);case"documents":return this.documentOverlayCache.getOverlays(e,sI(t).map(e=>K.fromPath(e)));case"database":return this.documentOverlayCache.getAllOverlays(e,r);default:throw new P("invalid-argument",`Failed to get overlays for pipeline: ${i8(t)}`)}}}class aw{constructor(e){this.serializer=e,this.Ks=new Map,this.Qs=new Map}getBundleMetadata(e,t){return nf.resolve(this.Ks.get(t))}saveBundleMetadata(e,t){return this.Ks.set(t.id,{id:t.id,version:t.version,createTime:rb(t.createTime)}),nf.resolve()}getNamedQuery(e,t){return nf.resolve(this.Qs.get(t))}saveNamedQuery(e,t){var r;let n;return this.Qs.set(t.name,{name:t.name,query:(n=function(e){var t,r,n,s;let i,a,o,l,u,c=4===(i=rI(e.parent)).length?F.emptyPath():rD(i),h=e.structuredQuery,d=h.from?h.from.length:0,m=null;if(d>0){b(1===d,65062);let e=h.from[0];e.allDescendants?m=e.collectionId:c=c.child(e.collectionId)}let f=[];h.where&&(f=(a=function e(t){return void 0!==t.unaryFilter?function(e){switch(e.unaryFilter.op){case"IS_NAN":let t=rL(e.unaryFilter.field);return ty.create(t,"==",{doubleValue:NaN});case"IS_NULL":let r=rL(e.unaryFilter.field);return ty.create(r,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":let n=rL(e.unaryFilter.field);return ty.create(n,"!=",{doubleValue:NaN});case"IS_NOT_NULL":let s=rL(e.unaryFilter.field);return ty.create(s,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return T(61313);default:return T(60726)}}(t):void 0!==t.fieldFilter?ty.create(rL(t.fieldFilter.field),function(e){switch(e){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";case"OPERATOR_UNSPECIFIED":return T(58110);default:return T(50506)}}(t.fieldFilter.op),t.fieldFilter.value):void 0!==t.compositeFilter?tw.create(t.compositeFilter.filters.map(t=>e(t)),function(e){switch(e){case"AND":return"and";case"OR":return"or";default:return T(1026)}}(t.compositeFilter.op)):T(30097,{filter:t})}(h.where))instanceof tw&&t_(t=a)&&tv(t)?a.getFilters():[a]);let p=[];h.orderBy&&(p=h.orderBy.map(e=>new tV(rL(e.field),function(e){switch(e){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(e.direction))));let g=null;h.limit&&(g=null==(o="object"==typeof(r=h.limit)?r.value:r)?null:o);let y=null;h.startAt&&(l=!!(n=h.startAt).before,y=new tm(n.values||[],l));let w=null;return h.endAt&&(u=!(s=h.endAt).before,w=new tm(s.values||[],u)),new tq(c,m,p,f,g,"F",y,w)}({parent:(r=t.bundledQuery).parent,structuredQuery:r.structuredQuery}),"LAST"===r.limitType?tW(n,n.limit,"L"):n),readTime:rb(t.readTime)}),nf.resolve()}}class av{constructor(){this.overlays=new A(K.comparator),this.Ws=new Map}getOverlay(e,t){return nf.resolve(this.overlays.get(t))}getOverlays(e,t){let r=t8();return nf.forEach(t,t=>this.getOverlay(e,t).next(e=>{null!==e&&r.set(t,e)})).next(()=>r)}getAllOverlays(e,t){let r=t8();return this.overlays.forEach((e,n)=>{n.largestBatchId>t&&r.set(e,n)}),nf.resolve(r)}saveOverlays(e,t,r){return r.forEach((r,n)=>{this.Yr(e,t,n)}),nf.resolve()}removeOverlaysForBatchId(e,t,r){let n=this.Ws.get(r);
6return void 0!==n&&(n.forEach(e=>this.overlays=this.overlays.remove(e)),this.Ws.delete(r)),nf.resolve()}getOverlaysForCollection(e,t,r){let n=t8(),s=t.length+1,i=new K(t.child("")),a=this.overlays.getIteratorFrom(i);for(;a.hasNext();){let e=a.getNext().value,i=e.getKey();if(!t.isPrefixOf(i.path))break;i.path.length===s&&e.largestBatchId>r&&n.set(e.getKey(),e)}return nf.resolve(n)}getOverlaysForCollectionGroup(e,t,r,n){let s=new A((e,t)=>e-t),i=this.overlays.getIterator();for(;i.hasNext();){let e=i.getNext().value;if(e.getKey().getCollectionGroup()===t&&e.largestBatchId>r){let t=s.get(e.largestBatchId);null===t&&(t=t8(),s=s.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}let a=t8(),o=s.getIterator();for(;o.hasNext()&&(o.getNext().value.forEach((e,t)=>a.set(e,t)),!(a.size()>=n)););return nf.resolve(a)}Yr(e,t,r){let n=this.overlays.get(r.key);if(null!==n){let e=this.Ws.get(n.largestBatchId).delete(r.key);this.Ws.set(n.largestBatchId,e)}this.overlays=this.overlays.insert(r.key,new as(t,r));let s=this.Ws.get(t);void 0===s&&(s=t9(),this.Ws.set(t,s)),this.Ws.set(t,s.add(r.key))}}class a_{constructor(){this.sessionToken=es.EMPTY_BYTE_STRING}getSessionToken(e){return nf.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,nf.resolve()}}class aE{constructor(){this.Gs=new L(aT.zs),this.js=new L(aT.Hs)}isEmpty(){return this.Gs.isEmpty()}addReference(e,t){let r=new aT(e,t);this.Gs=this.Gs.add(r),this.js=this.js.add(r)}Js(e,t){e.forEach(e=>this.addReference(e,t))}removeReference(e,t){this.Ys(new aT(e,t))}Zs(e,t){e.forEach(e=>this.removeReference(e,t))}Xs(e){let t=new K(new F([])),r=new aT(t,e),n=new aT(t,e+1),s=[];return this.js.forEachInRange([r,n],e=>{this.Ys(e),s.push(e.key)}),s}e_(){this.Gs.forEach(e=>this.Ys(e))}Ys(e){this.Gs=this.Gs.delete(e),this.js=this.js.delete(e)}t_(e){let t=new K(new F([])),r=new aT(t,e),n=new aT(t,e+1),s=t9();return this.js.forEachInRange([r,n],e=>{s=s.add(e.key)}),s}containsKey(e){let t=new aT(e,0),r=this.Gs.firstAfterOrEqual(t);return null!==r&&e.isEqual(r.key)}}class aT{constructor(e,t){this.key=e,this.n_=t}static zs(e,t){return K.comparator(e.key,t.key)||S(e.n_,t.n_)}static Hs(e,t){return S(e.n_,t.n_)||K.comparator(e.key,t.key)}}class ax{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Wr=1,this.r_=new L(aT.zs)}checkEmpty(e){return nf.resolve(0===this.mutationQueue.length)}addMutationBatch(e,t,r,n){let s=this.Wr;this.Wr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];let i=new an(s,t,r,n);for(let t of(this.mutationQueue.push(i),n))this.r_=this.r_.add(new aT(t.key,s)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return nf.resolve(i)}lookupMutationBatch(e,t){return nf.resolve(this.i_(t))}getNextMutationBatchAfterBatchId(e,t){let r=this.s_(t+1),n=r<0?0:r;return nf.resolve(this.mutationQueue.length>n?this.mutationQueue[n]:null)}getHighestUnacknowledgedBatchId(){return nf.resolve(0===this.mutationQueue.length?-1:this.Wr-1)}getAllMutationBatches(e){return nf.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let r=new aT(t,0),n=new aT(t,1/0),s=[];return this.r_.forEachInRange([r,n],e=>{let t=this.i_(e.n_);s.push(t)}),nf.resolve(s)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new L(S);return t.forEach(e=>{let t=new aT(e,0),n=new aT(e,1/0);this.r_.forEachInRange([t,n],e=>{r=r.add(e.n_)})}),nf.resolve(this.__(r))}getAllMutationBatchesAffectingQuery(e,t){let r=t.path,n=r.length+1,s=r;K.isDocumentKey(s)||(s=s.child(""));let i=new aT(new K(s),0),a=new L(S);return this.r_.forEachWhile(e=>{let t=e.key.path;return!!r.isPrefixOf(t)&&(t.length===n&&(a=a.add(e.n_)),!0)},i),nf.resolve(this.__(a))}__(e){let t=[];return e.forEach(e=>{let r=this.i_(e);null!==r&&t.push(r)}),t}removeMutationBatch(e,t){b(0===this.o_(t.batchId,"removed"),55003),this.mutationQueue.shift();let r=this.r_;return nf.forEach(t.mutations,n=>{let s=new aT(n.key,t.batchId);return r=r.delete(s),this.referenceDelegate.markPotentiallyOrphaned(e,n.key)}).next(()=>{this.r_=r})}jr(e){}containsKey(e,t){let r=new aT(t,0),n=this.r_.firstAfterOrEqual(r);return nf.resolve(t.isEqual(n&&n.key))}
6performConsistencyCheck(e){return this.mutationQueue.length,nf.resolve()}o_(e,t){return this.s_(e)}s_(e){return 0===this.mutationQueue.length?0:e-this.mutationQueue[0].batchId}i_(e){let t=this.s_(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}class ab{constructor(e){this.a_=e,this.docs=new A(K.comparator),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){let r=t.key,n=this.docs.get(r),s=n?n.size:0,i=this.a_(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:i}),this.size+=i-s,this.indexManager.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){let t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){let r=this.docs.get(t);return nf.resolve(r?r.document.mutableCopy():tD.newInvalidDocument(t))}getEntries(e,t){let r=t3;return t.forEach(e=>{let t=this.docs.get(e);r=r.insert(e,t?t.document.mutableCopy():tD.newInvalidDocument(e))}),nf.resolve(r)}getAllEntries(e){let t=t3;return this.docs.forEach((e,r)=>{t=t.insert(e,r.document)}),nf.resolve(t)}getDocumentsMatchingQuery(e,t,r,n){let s,i;i5(t)?(s=F.fromString(sN(t)),i=e=>ad(t,e)):(s=t.path,i=e=>tX(t,e));let a=t3,o=new K(s.child("__id-9223372036854775808__")),l=this.docs.getIteratorFrom(o);for(;l.hasNext();){let{key:e,value:{document:t}}=l.getNext();if(!s.isPrefixOf(e.path))break;e.path.length>s.length+1||0>=function(e,t){let r=e.readTime.compareTo(t.readTime);return 0!==r||0!==(r=K.comparator(e.documentKey,t.documentKey))?r:S(e.largestBatchId,t.largestBatchId)}(new tL(t.readTime,t.key,-1),r)||(n.has(t.key)||i(t))&&(a=a.insert(t.key,t.mutableCopy()))}return nf.resolve(a)}getAllFromCollectionGroup(e,t,r,n){T(9500)}u_(e,t){return nf.forEach(this.docs,e=>t(e))}newChangeBuffer(e){return new aN(this)}getSize(e){return nf.resolve(this.size)}}class aN extends ap{constructor(e){super(),this.qs=e}applyChanges(e){let t=[];
6return this.changes.forEach((r,n)=>{n.isValidDocument()?t.push(this.qs.addEntry(e,n)):this.qs.removeEntry(r)}),nf.waitFor(t)}getFromCache(e,t){return this.qs.getEntry(e,t)}getAllFromCache(e,t){return this.qs.getEntries(e,t)}}class aS{constructor(e){this.persistence=e,this.c_=new t2(e=>at(e),ar),this.lastRemoteSnapshotVersion=tA.min(),this.highestTargetId=0,this.l_=0,this.E_=new aE,this.targetCount=0,this.h_=ac.ys()}forEachTarget(e,t){return this.c_.forEach((e,r)=>t(r)),nf.resolve()}getLastRemoteSnapshotVersion(e){return nf.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return nf.resolve(this.l_)}allocateTargetId(e){return this.highestTargetId=this.h_.next(),nf.resolve(this.highestTargetId)}setTargetsMetadata(e,t,r){return r&&(this.lastRemoteSnapshotVersion=r),t>this.l_&&(this.l_=t),nf.resolve()}vs(e){this.c_.set(e.target,e);let t=e.targetId;t>this.highestTargetId&&(this.h_=new ac(t),this.highestTargetId=t),e.sequenceNumber>this.l_&&(this.l_=e.sequenceNumber)}addTargetData(e,t){return this.vs(t),this.targetCount+=1,nf.resolve()}updateTargetData(e,t){return this.vs(t),nf.resolve()}removeTargetData(e,t){return this.c_.delete(t.target),this.E_.Xs(t.targetId),this.targetCount-=1,nf.resolve()}removeTargets(e,t,r){let n=0,s=[];return this.c_.forEach((i,a)=>{a.sequenceNumber<=t&&null===r.get(a.targetId)&&(this.c_.delete(i),s.push(this.removeMatchingKeysForTargetId(e,a.targetId)),n++)}),nf.waitFor(s).next(()=>n)}getTargetCount(e){return nf.resolve(this.targetCount)}getTargetData(e,t){let r=this.c_.get(t)||null;return nf.resolve(r)}addMatchingKeys(e,t,r){return this.E_.Js(t,r),nf.resolve()}removeMatchingKeys(e,t,r){this.E_.Zs(t,r);let n=this.persistence.referenceDelegate,s=[];return n&&t.forEach(t=>{s.push(n.markPotentiallyOrphaned(e,t))}),nf.waitFor(s)}removeMatchingKeysForTargetId(e,t){return this.E_.Xs(t),nf.resolve()}getMatchingKeysForTargetId(e,t){let r=this.E_.t_(t);return nf.resolve(r)}containsKey(e,t){return nf.resolve(this.E_.containsKey(t))}}class aI{constructor(e,t){this.T_={},this.overlays={},this.P_=new nh(0),this.R_=!1,this.R_=!0,this.I_=new a_,this.referenceDelegate=e(this),this.A_=new aS(this),this.indexManager=new al,this.remoteDocumentCache=function(e){return new ab(e)}(e=>this.referenceDelegate.V_(e)),this.serializer=new aa(t),this.d_=new aw(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.R_=!1,Promise.resolve()}get started(){return this.R_}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new av,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let r=this.T_[e.toKey()];return r||(r=new ax(t,this.referenceDelegate),this.T_[e.toKey()]=r),r}getGlobalsCache(){return this.I_}getTargetCache(){return this.A_}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.d_}runTransaction(e,t,r){w("MemoryPersistence","Starting transaction:",e);let n=new aC(this.P_.next());return this.referenceDelegate.f_(),r(n).next(e=>this.referenceDelegate.m_(n).next(()=>e)).toPromise().then(e=>(n.raiseOnCommittedEvent(),e))}p_(e,t){return nf.or(Object.values(this.T_).map(r=>()=>r.containsKey(e,t)))}}class aC extends nd{constructor(e){super(),this.currentSequenceNumber=e}}class aV{constructor(e){this.persistence=e,this.g_=new aE,this.y_=null}static w_(e){return new aV(e)}get b_(){if(this.y_)return this.y_;throw T(60996)}addReference(e,t,r){return this.g_.addReference(r,t),this.b_.delete(r.toString()),nf.resolve()}removeReference(e,t,r){return this.g_.removeReference(r,t),this.b_.add(r.toString()),nf.resolve()}markPotentiallyOrphaned(e,t){return this.b_.add(t.toString()),nf.resolve()}removeTarget(e,t){this.g_.Xs(t.targetId).forEach(e=>this.b_.add(e.toString()));let r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next(e=>{e.forEach(e=>this.b_.add(e.toString()))}).next(()=>r.removeTargetData(e,t))}f_(){this.y_=new Set}m_(e){let t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return nf.forEach(this.b_,r=>{let n=K.fromPath(r);return this.S_(e,n).next(e=>{e||t.removeEntry(n,tA.min())})}).next(()=>(this.y_=null,t.apply(e)))}updateLimboDocument(e,t){return this.S_(e,t).next(e=>{e?this.b_.delete(t.toString()):this.b_.add(t.toString())})}V_(e){return 0}S_(e,t){return nf.or([()=>nf.resolve(this.g_.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.p_(e,t)])}}class aA{constructor(e,t){this.persistence=e,this.v_=new t2(e=>(function(e){let t="";for(let r=0;r<e.length;r++)t.length>0&&(t+="\x01\x01"),t=function(e,t){let r=t,n=e.length;for(let t=0;t<n;t++){let n=e.charAt(t);switch(n){case"\0":r+="\x01\x10";break;case"\x01":r+="\x01\x11";break;default:r+=n}}return r}(e.get(r),t);return t+"\x01\x01"})(e.path),(e,t)=>e.isEqual(t)),this.garbageCollector=function(e,t){return new n_(e,t)}(this,t)}static w_(e,t){return new aA(e,t)}f_(){}m_(e){return nf.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEac
6hTarget(e,t)}rr(e){let t=this.xs(e);return this.persistence.getTargetCache().getTargetCount(e).next(e=>t.next(t=>e+t))}xs(e){let t=0;return this.ir(e,e=>{t++}).next(()=>t)}ir(e,t){return nf.forEach(this.v_,(r,n)=>this.Fs(e,r,n).next(e=>e?nf.resolve():t(n)))}removeTargets(e,t,r){return this.persistence.getTargetCache().removeTargets(e,t,r)}removeOrphanedDocuments(e,t){let r=0,n=this.persistence.getRemoteDocumentCache(),s=n.newChangeBuffer();return n.u_(e,n=>this.Fs(e,n,t).next(e=>{e||(r++,s.removeEntry(n,tA.min()))})).next(()=>s.apply(e)).next(()=>r)}markPotentiallyOrphaned(e,t){return this.v_.set(t,e.currentSequenceNumber),nf.resolve()}removeTarget(e,t){let r=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,r)}addReference(e,t,r){return this.v_.set(r,e.currentSequenceNumber),nf.resolve()}removeReference(e,t,r){return this.v_.set(r,e.currentSequenceNumber),nf.resolve()}updateLimboDocument(e,t){return this.v_.set(t,e.currentSequenceNumber),nf.resolve()}V_(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=function e(t){switch(eV(t)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:let r=ef(t);return r?16+e(r):16;case 5:return 2*t.stringValue.length;case 6:return el(t.bytesValue).approximateByteSize();case 7:return t.referenceValue.length;case 9:return(t.arrayValue.values||[]).reduce((t,r)=>t+e(r),0);case 10:case 11:var n;let s;return n=t.mapValue,s=0,j(n.fields,(t,r)=>{s+=t.length+e(r)}),s;default:throw T(13486,{value:t})}}(e.data.value)),t}Fs(e,t,r){return nf.or([()=>this.persistence.p_(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{let e=this.v_.get(t);return nf.resolve(void 0!==e&&e>r)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}class aD{constructor(e,t,r,n){this.targetId=e,this.fromCache=t,this.Ao=r,this.Vo=n}static fo(e,t){let r=t9(),n=t9();for(let e of t.docChanges)switch(e.type){case 0:r=r.add(e.doc.key);break;case 1:n=n.add(e.doc.key)}return new aD(e,t.fromCache,r,n)}}function ak(e,t){return K.comparator(e.key,t.key)}class aL{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}class aR{constructor(){this.mo=!1,this.po=!1,this.yo=100,this.wo=function(){let e;return(0,l.nr)()?8:Number((e=(0,l.ZQ)().match(/Android ([\d.]+)/i))?e[1].split(".").slice(0,2).join("."):"-1")>0?6:4}()}initialize(e,t){this.bo=e,this.indexManager=t,this.mo=!0}getDocumentsMatchingQuery(e,t,r,n){let s={result:null};return this.So(e,t).next(e=>{s.result=e}).next(()=>{if(!s.result)return this.vo(e,t,n,r).next(e=>{s.result=e})}).next(()=>{if(s.result)return;let r=new aL;return this.Do(e,t,r).next(n=>{if(s.result=n,this.po)return this.xo(e,t,r,n.size)})}).next(()=>s.result)}xo(e,t,r,n){return i5(t)?nf.resolve():r.documentReadCount<this.yo?(y()<=c.$b.DEBUG&&w("QueryEngine","SDK will not create cache indexes for query:",tJ(t),"since it only creates cache indexes for collection contains","more than or equal to",this.yo,"documents"),nf.resolve()):(y()<=c.$b.DEBUG&&w("QueryEngine","Query:",tJ(t),"scans",r.documentReadCount,"local documents and returns",n,"documents as results."),r.documentReadCount>this.wo*n?(y()<=c.$b.DEBUG&&w("QueryEngine","The SDK decides to create cache indexes for query:",tJ(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,tG(t))):nf.resolve())}So(e,t){if(i5(t))return nf.resolve(null);let r=t;if(tB(r))return nf.resolve(null);let n=tG(r);return this.indexManager.getIndexType(e,n).next(t=>0===t?null:(null!==r.limit&&1===t&&(n=tG(r=tW(r,null,"F"))),this.indexManager.getDocumentsMatchingTarget(e,n).next(t=>{let s=t9(...t);return this.bo.getDocuments(e,s).next(t=>this.indexManager.getMinOffset(e,n).next(n=>{let i=this.Co(r,t);return this.Fo(r,i,s,n.readTime)?this.So(e,tW(r,null,"F")):this.Oo(e,i,r,n)}))})))}vo(e,t,r,n){return(i5(t)?function(e){for(let t of e.stages){if(t instanceof sy||t instanceof sw)return!1;if(t instanceof sg){if(t.condition instanceof ss&&"exists"===t.condition._expr.name&&t.condition._expr.params[0]instanceof n9&&t.condition._expr.params[0].fieldName===U)continue;return!1}}return!0}(t):tB(t))||n.isEqual(tA.min())?nf.resolve(null):this.bo.getDocuments(e,r).next(s=>{let i,a,o=this.Co(t,s);return this.Fo(t,o,r,n)?nf.resolve(null):(y()<=c.$b.DEBUG&&w("QueryEngine","Re-using previous result from %s to execute query: %s",n.toString(),i9(t)),this.Oo(e,o,t,(i=n.toTimestamp().seconds,a=n.toTimestamp().nanoseconds+1,new tL(tA.fromTimestamp(1e9===a?new er(i+1,0):new er(i,a)),K.empty(),-1))
6).next(e=>e))})}Co(e,t){let r,n;return i5(e)?(r=new L(ak),n=t=>ad(e,t)):(r=new L(tZ(e)),n=t=>tX(e,t)),t.forEach((e,t)=>{n(t)&&(r=r.add(t))}),r}Fo(e,t,r,n){if(i5(e))return e.stages.some(e=>e instanceof sy||e instanceof sw);if(null===e.limit)return!1;if(r.size!==t.size)return!0;let s="F"===e.limitType?t.last():t.first();return!!s&&(s.hasPendingWrites||s.version.compareTo(n)>0)}Do(e,t,r){return y()<=c.$b.DEBUG&&w("QueryEngine","Using full collection scan to execute query:",i9(t)),this.bo.getDocumentsMatchingQuery(e,t,tL.min(),r)}Oo(e,t,r,n){return this.bo.getDocumentsMatchingQuery(e,r,n).next(e=>(t.forEach(t=>{e=e.insert(t.key,t)}),e))}}let aO="LocalStore";class aP{constructor(e,t,r,n){this.persistence=e,this.Mo=t,this.serializer=n,this.No=new A(S),this.Lo=new t2(e=>at(e),ar),this.Bo=new Map,this.Uo=e.getRemoteDocumentCache(),this.A_=e.getTargetCache(),this.d_=e.getBundleCache(),this.ko(r)}ko(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new ay(this.Uo,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Uo.setIndexManager(this.indexManager),this.Mo.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.No))}}async function aU(e,t){return await e.persistence.runTransaction("Handle user change","readonly",r=>{let n;return e.mutationQueue.getAllMutationBatches(r).next(s=>(n=s,e.ko(t),e.mutationQueue.getAllMutationBatches(r))).next(t=>{let s=[],i=[],a=t9();for(let e of n)for(let t of(s.push(e.batchId),e.mutations))a=a.add(t.key);for(let e of t)for(let t of(i.push(e.batchId),e.mutations))a=a.add(t.key);return e.localDocuments.getDocuments(r,a).next(e=>({qo:e,removedBatchIds:s,addedBatchIds:i}))})})}function aM(e){return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.A_.getLastRemoteSnapshotVersion(t))}async function aF(e,t,r){let n=e.No.get(t);try{r||await e.persistence.runTransaction("Release target",r?"readwrite":"readwrite-primary",t=>e.persistence.referenceDelegate.removeTarget(t,n))}catch(e){if(!np(e))throw e;w(aO,`Failed to update sequence numbers for target ${t}: ${e}`)}e.No=e.No.remove(t),e.Lo.delete(n.target)}function aq(e,t,r){let n=tA.min(),s=t9();return e.persistence.runTransaction("Execute query","readwrite",i=>{var a;let o;return(a=i5(t)?t:tG(t),void 0!==(o=e.Lo.get(a))?nf.resolve(e.No.get(o)):e.A_.getTargetData(i,a)).next(t=>{if(t)return n=t.lastLimboFreeSnapshotVersion,e.A_.getMatchingKeysForTargetId(i,t.targetId).next(e=>{s=e})}).next(()=>e.Mo.getDocumentsMatchingQuery(i,t,r?n:tA.min(),r?s:t9())).next(t=>{var r;return r=e,t.forEach((e,t)=>{let n=t.key.getCollectionGroup(),s=r.Bo.get(n)||tA.min();t.readTime.compareTo(s)>0&&r.Bo.set(n,t.readTime)}),{documents:t,Qo:s}})})}class a${constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.Jo=0,this.Yo=null,this.Zo=!0}Xo(){0===this.Jo&&(this.ea("Unknown"),this.Yo=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.Yo=null,this.ta("Backend didn't respond within 10 seconds."),this.ea("Offline"),Promise.resolve())))}na(e){"Online"===this.state?this.ea("Unknown"):(this.Jo++,this.Jo>=1&&(this.ra(),this.ta(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ea("Offline")))}set(e){this.ra(),this.Jo=0,"Online"===e&&(this.Zo=!1),this.ea(e)}ea(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}ta(e){let t=`Could not reach Cloud Firestore backend. ${e}
7This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.Zo?(v(t),this.Zo=!1):w("OnlineStateTracker",t)}ra(){null!==this.Yo&&(this.Yo.cancel(),this.Yo=null)}}let aB="RemoteStore";class az{constructor(e,t,r,n,s){this.localStore=e,this.datastore=t,this.asyncQueue=r,this.remoteSyncer={},this.ia=[],this.sa=new Map,this._a=new Map,this.oa=new Map,this.aa=new ac(1e3),this.ua=new ac(1001),this.ca=new Set,this.la=[],this.Ea=s,this.Ea.Ke(e=>{r.enqueueAndForget(async()=>
7{aZ(this)&&(w(aB,"Restarting streams for network reachability change."),await async function(e){e.ca.add(4),await aG(e),e.ha.set("Unknown"),e.ca.delete(4),await aj(e)}(this))})}),this.ha=new a$(r,n)}}async function aj(e){if(aZ(e))for(let t of e.la)await t(!0)}async function aG(e){for(let t of e.la)await t(!1)}function aK(e,t){return e._a.get(t)||void 0}function aQ(e,t){var r;let n,s,i=aK(e,t.targetId);if(void 0!==i&&e.sa.has(i))return;let a=(void 0!==(n=aK(e,r=t.targetId))&&e.oa.delete(n),s=r%2!=0?e.ua.next():e.aa.next(),e._a.set(r,s),e.oa.set(s,r),s);w(aB,"remoteStoreListen mapping SDK target ID to remote",t.targetId,a);let o=new ai(t.target,a,t.purpose,t.sequenceNumber,t.snapshotVersion,t.lastLimboFreeSnapshotVersion,t.resumeToken);e.sa.set(a,o),aX(e)?aJ(e):a5(e).Jt()&&aH(e,o)}function aW(e,t){let r=a5(e),n=aK(e,t);w(aB,"remoteStoreUnlisten removing mapping of SDK target ID to remote",t,n),e.sa.delete(n),e._a.delete(t),e.oa.delete(n),r.Jt()&&aY(e,n),0===e.sa.size&&(r.Jt()?r.Xt():aZ(e)&&e.ha.set("Unknown"))}function aH(e,t){if(e.Ta.H(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(tA.min())>0){let r=e.oa.get(t.targetId);if(void 0===r)return void w(aB,"SDK target ID not found for remote ID: "+t.targetId);let n=e.remoteSyncer.getRemoteKeysForTarget(r).size;t=t.withExpectedCount(n)}a5(e).Tn(t)}function aY(e,t){e.Ta.H(t),a5(e).Pn(t)}function aJ(e){e.Ta=new rd({getRemoteKeysForTarget:t=>{let r=e.oa.get(t);return void 0!==r?e.remoteSyncer.getRemoteKeysForTarget(r):t9()},ge:t=>e.sa.get(t)||null,Ae:()=>e.datastore.serializer.databaseId}),a5(e).start(),e.ha.Xo()}function aX(e){return aZ(e)&&!a5(e).Ht()&&e.sa.size>0}function aZ(e){return 0===e.ca.size}async function a0(e){e.ha.set("Online")}async function a1(e){e.sa.forEach((t,r)=>{aH(e,t)})}async function a2(e,t){e.Ta=void 0,aX(e)?(e.ha.na(t),aJ(e)):e.ha.set("Unknown")}async function a3(e,t,r){if(e.ha.set("Online"),t instanceof ru&&2===t.state&&t.cause)try{await async function(e,t){let r=t.cause;for(let n of t.targetIds){if(e.sa.has(n)){let t=e.oa.get(n);void 0!==t&&(await e.remoteSyncer.rejectListen(t,r),e._a.delete(t),e.oa.delete(n)),e.sa.delete(n)}e.Ta.removeTarget(n)}}(e,t)}catch(r){w(aB,"Failed to remove targets %s: %s ",t.targetIds.join(","),r),await a4(e,r)}else if(t instanceof ro?e.Ta.se(t):t instanceof rl?e.Ta.Ee(t):e.Ta.ae(t),!r.isEqual(tA.min()))try{let t,n,s,i,a=await aM(e.localStore);r.compareTo(a)>
7=0&&await ((t=e.Ta.de(r)).targetChanges.forEach((t,n)=>{if(t.resumeToken.approximateByteSize()>0){let s=e.sa.get(n);s&&e.sa.set(n,s.withResumeToken(t.resumeToken,r))}}),t.targetMismatches.forEach((t,r)=>{let n=e.sa.get(t);if(!n)return;e.sa.set(t,n.withResumeToken(es.EMPTY_BYTE_STRING,n.snapshotVersion)),aY(e,t);let s=new ai(n.target,t,r,n.sequenceNumber);aH(e,s)}),n=new Map,t.targetChanges.forEach((t,r)=>{let s=e.oa.get(r);void 0!==s&&n.set(s,t)}),s=new A(S),t.targetMismatches.forEach((t,r)=>{let n=e.oa.get(t);void 0!==n&&(s=s.insert(n,r))}),i=new ri(t.snapshotVersion,n,s,t.documentUpdates,t.augmentedDocumentUpdates,t.resolvedLimboDocuments),e.remoteSyncer.applyRemoteEvent(i))}catch(t){w(aB,"Failed to raise snapshot:",t),await a4(e,t)}}async function a4(e,t,r){if(!np(t))throw t;e.ca.add(1),await aG(e),e.ha.set("Offline"),r||(r=()=>aM(e.localStore)),e.asyncQueue.enqueueRetryable(async()=>{w(aB,"Retrying IndexedDB access"),await r(),e.ca.delete(1),await aj(e)})}async function a6(e,t){e.asyncQueue.verifyOperationInProgress(),w(aB,"RemoteStore received new credentials");let r=aZ(e);e.ca.add(3),await aG(e),r&&e.ha.set("Unknown"),await e.remoteSyncer.handleCredentialChange(t),e.ca.delete(3),await aj(e)}async function a8(e,t){t?(e.ca.delete(2),await aj(e)):t||(e.ca.add(2),await aG(e),e.ha.set("Unknown"))}function a5(e){var t,r,n;return e.Pa||(t=e.datastore,r=e.asyncQueue,n={ut:a0.bind(null,e),lt:a1.bind(null,e),ht:a2.bind(null,e),hn:a3.bind(null,e)},t.mn(),e.Pa=new ni(r,t.connection,t.authCredentials,t.appCheckCredentials,t.serializer,n),e.la.push(async t=>{t?(e.Pa.Zt(),aX(e)?aJ(e):e.ha.set("Unknown")):(await e.Pa.stop(),e.Ta=void 0)})),e.Pa}class a9{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ia(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ia(this.observer.error,e):v("Uncaught Error in snapshot listener:",e.toString()))}Aa(){this.muted=!0}Ia(e,t){setTimeout(()=>{this.muted||e(t)},0)}}class a7{constructor(e,t,r,n,s){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=r,this.op=n,this.removalCallback=s,this.deferred=new rj,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(e=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,t,r,n,s){let i=new a7(e,t,Date.now()+r,n,s);return i.start(r),i}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new P(O.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>null!==this.timerHandle?(this.clearTimeout(),this.op().then(e=>this.deferred.resolve(e))):Promise.resolve())}clearTimeout(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function oe(e,t){if(v("AsyncQueue",`${t}: ${e}`),np(e))return new P(O.UNAVAILABLE,`${t}: ${e}`);throw e}class ot{constructor(){this.activeTargetIds=t7}La(e){this.activeTargetIds=this.activeTargetIds.add(e)}Ba(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Na(){return JSON.stringify({activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()})}}class or{constructor(){this.du=new ot,this.fu={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,r){}addLocalQueryTarget(e,t=!0){return t&&this.du.La(e),this.fu[e]||"not-current"}updateQueryState(e,t,r){this.fu[e]=t}removeLocalQueryTarget(e){this.du.Ba(e)}isLocalQueryTarget(e){return this.du.activeTargetIds.has(e)}clearQueryState(e){delete this.fu[e]}getAllActiveQueryTargets(){return this.du.activeTargetIds}isActiveQueryTarget(e){return this.du.activeTargetIds.has(e)}start(){return this.du=new ot,Promise.resolve()}handleUserChange(e,t,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}function on(){return"u">typeof document?document:null}class os{static emptySet(e){return new os(e.comparator)}constructor(e){this.comparator=e?(t,r)=>e(t,r)||K.comparator(t.key,r.key):(e,t)=>K.comparator(e.key,t.key),this.keyedMap=t6(),this.sortedSet=new A(this.comparator)}has(e){return null!=this.keyedMap.get(e)}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){let t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((t,r)=>(e(t),!1))}add(e){let t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){let t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof os)||this.size!==e.size)return!1;let t=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();for(;t.hasNext();){let e=t.getNext().key,n=r.getNext().key;if(!e.isEqual(n))return!1}return!0}toString(){let e=[];return this.forEach(t=>{e.push(t.toString())}),0===e.length?"DocumentSet ()":"DocumentSet (\n  "+e.join("  \n")+"\n)"}copy(e,t){let r=new os;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=t,r}}class oi{constructor(){this.mu=new A(K.comparator)}track(e){let t=e.doc.key,r=this.mu.get(t);r?0!==e.type&&3===r.type?this.mu=this.mu.insert(t,e):3===e.type&&1!==r.type?this.mu=this.mu.insert(t,{type:r.type,doc:e.doc}):2===e.type&&2===r.type?this.mu=this.mu.insert(t,{type:2,doc:e.doc}):2===e.type&&0===r.type?this.mu=this.mu.insert(t,{type:0,doc:e.doc}):1===e.type&&0===r.type?this.mu=this.mu.remove(t):1===e.type&&2===r.type?this.mu=this.mu.insert(t,{type:1,doc:r.doc}):0===e.type&&1===r.type?this.mu=this.mu.insert(t,{type:2,doc:e.doc}):T(63341,{ye:e,pu:r}):this.mu=this.mu.insert(t,e)}gu(){let e=[];return this.mu.inorderTraversal((t,r)=>{e.push(r)}),e}}class oa{constructor(e,t,r,n,s,i,a,o,l){this.query=e,this.docs=t,this.oldDocs=r,this.docChanges=n,this.mutatedKeys=s,this.fromCache=i,this.syncStateChanged=a,this.excludesMetadataChanges=o,this.hasCachedResults=l}static fromInitialDocuments(e,t,r,n,s){let i=[];
7return t.forEach(e=>{i.push({type:0,doc:e})}),new oa(e,t,os.emptySet(t),i,r,n,!0,!1,s)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&ae(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;let t=this.docChanges,r=e.docChanges;if(t.length!==r.length)return!1;for(let e=0;e<t.length;e++)if(t[e].type!==r[e].type||!t[e].doc.isEqual(r[e].doc))return!1;return!0}}class oo{constructor(){this.yu=void 0,this.wu=[]}bu(){return this.wu.some(e=>e.Su())}}class ol{constructor(){this.queries=ou(),this.onlineState="Unknown",this.vu=new Set}terminate(){var e;let t;e=new P(O.ABORTED,"Firestore shutting down"),t=this.queries,this.queries=ou(),t.forEach((t,r)=>{for(let t of r.wu)t.onError(e)})}}function ou(){return new t2(e=>i7(e),ae)}async function oc(e,t){let r=3,n=t.query,s=e.queries.get(n);s?!s.bu()&&t.Su()&&(r=2):(s=new oo,r=+!t.Su());try{switch(r){case 0:s.yu=await e.onListen(n,!0);break;case 1:s.yu=await e.onListen(n,!1);break;case 2:await e.onFirstRemoteStoreListen(n)}}catch(r){let e=oe(r,`Initialization of query '${i5(t.query)?i8(t.query):tJ(t.query)}' failed`);return void t.onError(e)}e.queries.set(n,s),s.wu.push(t),t.Du(e.onlineState),s.yu&&t.xu(s.yu)&&of(e)}async function oh(e,t){let r=t.query,n=3,s=e.queries.get(r);if(s){let e=s.wu.indexOf(t);e>=0&&(s.wu.splice(e,1),0===s.wu.length?n=+!t.Su():!s.bu()&&t.Su()&&(n=2))}switch(n){case 0:return e.queries.delete(r),e.onUnlisten(r,!0);case 1:return e.queries.delete(r),e.onUnlisten(r,!1);case 2:return e.onLastRemoteStoreUnlisten(r);default:return}}function od(e,t){let r=!1;for(let n of t){let t=n.query,s=e.queries.get(t);if(s){for(let e of s.wu)e.xu(n)&&(r=!0);s.yu=n}}r&&of(e)}function om(e,t,r){let n=e.queries.get(t);if(n)for(let e of n.wu)e.onError(r);e.queries.delete(t)}function of(e){e.vu.forEach(e=>{e.next()})}(n=a||(a={})).Default="default",n.Cache="cache";class op{constructor(e,t,r){this.query=e,this.Cu=t,this.Fu=!1,this.Ou=null,this.onlineState="Unknown",this.options=r||{}}xu(e){if(!this.options.includeMetadataChanges){let t=[];for(let r of e.docChanges)3!==r.type&&t.push(r);e=new oa(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Fu?this.Mu(e)&&(this.Cu.next(e),t=!0):this.Nu(e,this.onlineState)&&(this.Lu(e),t=!0),this.Ou=e,t}onError(e){this.Cu.error(e)}Du(e){this.onlineState=e;let t=!1;return this.Ou&&!this.Fu&&this.Nu(this.Ou,e)&&(this.Lu(this.Ou),t=!0),t}Nu(e,t){return!(e.fromCache&&this.Su())||(!this.options.waitForSyncWhenOnline||"Offline"===t)&&(!e.docs.isEmpty()||e.hasCachedResults||"Offline"===t)}Mu(e){if(e.docChanges.length>0)return!0;let t=this.Ou&&this.Ou.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}Lu(e){e=oa.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Fu=!0,this.Cu.next(e)}Su(){return this.options.source!==a.Cache}}class og{constructor(e){this.key=e}}class oy{constructor(e){this.key=e}}class ow{constructor(e,t){this.query=e,this.Gu=t,this.zu=null,this.hasCachedResults=!1,this.current=!1,this.ju=t9(),this.mutatedKeys=t9(),this.Hu=i5(e)?am(e):tZ(e),this.Ju=new os(this.Hu)}get Yu(){return this.Gu}Zu(e,t){let r=t?t.Xu:new oi,n=t?t.Ju:this.Ju,s=t?t.mutatedKeys:this.mutatedKeys,i=n,a=!1,[o,l]=this.ec(this.query,n);e.inorderTraversal((e,t)=>{var u;let c=n.get(e),h=(u=this.query,i5(u)?ad(u,t):tX(u,t))?t:null,d=!!c&&this.mutatedKeys.has(c.key),m=!!h&&(h.hasLocalMutations||this.mutatedKeys.has(h.key)&&h.hasCommittedMutations),f=!1;c&&h?c.data.isEqual(h.data)?d!==m&&(r.track({type:3,doc:h}),f=!0):this.tc(c,h)||(r.track({type:2,doc:h}),f=!0,(o&&this.Hu(h,o)>0||l&&0>this.Hu(h,l))&&(a=!0)):!c&&h?(r.track({type:0,doc:h}),f=!0):c&&!h&&(r.track({type:1,doc:c}),f=!0,(o||l)&&(a=!0)),f&&(h?(i=i.add(h),s=m?s.add(e):s.delete(e)):(i=i.delete(e),s=s.delete(e)))});let u=this.nc(this.query);if(u)if(i5(this.query)){let e=[];
7i.forEach(t=>e.push(t));let t=ah(this.query,e),n=new os(am(this.query));for(let e of t)n=n.add(e);i.forEach(e=>{n.has(e.key)||(s=s.delete(e.key),r.track({type:1,doc:e}))}),i=n}else{let e=this.rc(this.query);for(;i.size>u;){let t="F"===e?i.last():i.first();i=i.delete(t.key),s=s.delete(t.key),r.track({type:1,doc:t})}}return{Ju:i,Xu:r,Fo:a,mutatedKeys:s}}nc(e){return i5(e)?af(e)?.limit:e.limit||void 0}rc(e){if(i5(e)){let t=af(e);return t&&t.limit<0?"L":"F"}return e.limitType}ec(e,t){if(i5(e)){let r=af(e)?.limit;return[t.size===r?t.last():null,null]}return["F"===e.limitType&&t.size===this.nc(this.query)?t.last():null,"L"===e.limitType&&t.size===this.nc(this.query)?t.first():null]}tc(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,r,n){let s=this.Ju;this.Ju=e.Ju,this.mutatedKeys=e.mutatedKeys;let i=e.Xu.gu();i.sort((e,t)=>{var r,n;let s;return r=e.type,n=t.type,(s=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return T(20277,{ye:e})}})(r)-s(n)||this.Hu(e.doc,t.doc)}),this.sc(r),n=n??!1;let a=t&&!n?this._c():[],o=0===this.ju.size&&this.current&&!n?1:0,l=o!==this.zu;return(this.zu=o,0!==i.length||l)?{snapshot:new oa(this.query,e.Ju,s,i,e.mutatedKeys,0===o,l,!1,!!r&&r.resumeToken.approximateByteSize()>0),oc:a}:{oc:a}}Du(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({Ju:this.Ju,Xu:new oi,mutatedKeys:this.mutatedKeys,Fo:!1},!1)):{oc:[]}}ac(e){return!this.Gu.has(e)&&!!this.Ju.has(e)&&!this.Ju.get(e).hasLocalMutations}sc(e){e&&(e.addedDocuments.forEach(e=>this.Gu=this.Gu.add(e)),e.modifiedDocuments.forEach(e=>{}),e.removedDocuments.forEach(e=>this.Gu=this.Gu.delete(e)),this.current=e.current)}_c(){if(!this.current)return[];let e=this.ju;this.ju=t9(),this.Ju.forEach(e=>{this.ac(e.key)&&(this.ju=this.ju.add(e.key))});let t=[];return e.forEach(e=>{this.ju.has(e)||t.push(new oy(e))}),this.ju.forEach(r=>{e.has(r)||t.push(new og(r))}),t}uc(e){this.Gu=e.Qo,this.ju=t9();let t=this.Zu(e.documents);return this.applyChanges(t,!0)}cc(){return oa.fromInitialDocuments(this.query,this.Ju,this.mutatedKeys,0===this.zu,this.hasCachedResults)}}let ov="SyncEngine";class o_{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}}class oE{constructor(e){this.key=e,this.lc=!1}}class oT{constructor(e,t,r,n,s,i){this.localStore=e,this.remoteStore=t,this.eventManager=r,this.sharedClientState=n,this.currentUser=s,this.maxConcurrentLimboResolutions=i,this.Ec={},this.hc=new t2(e=>i7(e),ae),this.Tc=new Map,this.Pc=new Set,this.Rc=new A(K.comparator),this.Ic=new Map,this.Ac=new aE,this.Vc={},this.dc=new Map,this.fc=ac.ws(),this.onlineState="Unknown",this.mc=void 0}get isPrimaryClient(){return!0===this.mc}}async function ox(e,t,r=!0){let n,s=oF(e),i=s.hc.get(t);return i?(s.sharedClientState.addLocalQueryTarget(i.targetId),n=i.view.cc()):n=await oN(s,t,r,!0),n}async function ob(e,t){let r=oF(e);await oN(r,t,!0,!1)}async function oN(e,t,r,n){var s,i;let a,o=await (s=e.localStore,i=i5(t)?t:tG(t),s.persistence.runTransaction("Allocate target","readwrite",e=>{let t;return s.A_.getTargetData(e,i).next(r=>r?(t=r,nf.resolve(t)):s.A_.allocateTargetId(e).next(r=>(t=new ai(i,r,"TargetPurposeListen",e.currentSequenceNumber),s.A_.addTargetData(e,t).next(()=>t))))}).then(e=>{let t=s.No.get(e.targetId);return(null===t||e.snapshotVersion.compareTo(t.snapshotVersion)>0)&&(s.No=s.No.insert(e.targetId,e),s.Lo.set(i,e.targetId)),e})),l=o.targetId,u=e.sharedClientState.addLocalQueryTarget(l,r);return n&&(a=await oS(e,t,l,"current"===u,o.resumeToken)),e.isPrimaryClient&&r&&aQ(e.remoteStore,o),a}async function oS(e,t,r,n,s){e.gc=(t,r,n)=>(async function(e,t,r,n){let s=t.view.Zu(r);s.Fo&&(s=await aq(e.localStore,t.query,!1).then(({documents:e})=>t.view.Zu(e,s)));let i=n&&n.targetChanges.get(t.targetId),a=n&&null!=n.targetMismatches.get(t.targetId),o=t.view.applyChanges(s,e.isPrimaryClient,i,a);return oR(e,t.targetId,o.oc),o.snapshot})(e,t,r,n);let i=await aq(e.localStore,t,!0),a=new ow(t,i.Qo),o=a.Zu(i.documents),l=ra.createSynthesizedTargetChangeForCurrentChange(r,n&&"Offline"!==e.onlineState,s),u=a.applyChanges(o,e.isPrimaryClient,l);oR(e,r,u.oc);let c=new o_(t,r,a);return e.hc.set(t,c),e.Tc.has(r)?e.Tc.get(r).push(t):e.Tc.set(r,[t]),u.snapshot}async function oI(e,t,r){let n=e.hc.get(t),s=e.Tc.get(n.targetId);s.length>1?(e.Tc.set(n.targetId,s.filter(e=>
7!ae(e,t))),e.hc.delete(t)):e.isPrimaryClient?(e.sharedClientState.removeLocalQueryTarget(n.targetId),e.sharedClientState.isActiveQueryTarget(n.targetId)||await aF(e.localStore,n.targetId,!1).then(()=>{e.sharedClientState.clearQueryState(n.targetId),r&&aW(e.remoteStore,n.targetId),ok(e,n.targetId)}).catch(nm)):(ok(e,n.targetId),await aF(e.localStore,n.targetId,!0))}async function oC(e,t){let r=e.hc.get(t),n=e.Tc.get(r.targetId);e.isPrimaryClient&&1===n.length&&(e.sharedClientState.removeLocalQueryTarget(r.targetId),aW(e.remoteStore,r.targetId))}async function oV(e,t){try{var r,n;let s,i,a=await (r=e.localStore,s=(n=t).snapshotVersion,i=r.No,r.persistence.runTransaction("Apply remote event","readwrite-primary",e=>{var t,a,o;let l,u,c=r.Uo.newChangeBuffer({trackRemovals:!0});i=r.No;let h=[];n.targetChanges.forEach((t,a)=>{var o;let l=i.get(a);if(!l)return;h.push(r.A_.removeMatchingKeys(e,t.removedDocuments,a).next(()=>r.A_.addMatchingKeys(e,t.addedDocuments,a)));let u=l.withSequenceNumber(e.currentSequenceNumber);null!==n.targetMismatches.get(a)?u=u.withResumeToken(es.EMPTY_BYTE_STRING,tA.min()).withLastLimboFreeSnapshotVersion(tA.min()):t.resumeToken.approximateByteSize()>0&&(u=u.withResumeToken(t.resumeToken,s)),i=i.insert(a,u),o=u,(0===l.resumeToken.approximateByteSize()||o.snapshotVersion.toMicroseconds()-l.snapshotVersion.toMicroseconds()>=3e8||t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size>0)&&h.push(r.A_.updateTargetData(e,u))});let d=t3,m=t9();if(n.documentUpdates.forEach(t=>{n.resolvedLimboDocuments.has(t)&&h.push(r.persistence.referenceDelegate.updateLimboDocument(e,t))}),h.push((t=e,a=c,o=n.documentUpdates,l=t9(),u=t9(),o.forEach(e=>l=l.add(e)),a.getEntries(t,l).next(e=>{let t=t3;return o.forEach((r,n)=>{let s=e.get(r);n.isFoundDocument()!==s.isFoundDocument()&&(u=u.add(r)),n.isNoDocument()&&n.version.isEqual(tA.min())?(a.removeEntry(r,n.readTime),t=t.insert(r,n)):!s.isValidDocument()||n.version.compareTo(s.version)>0||0===n.version.compareTo(s.version)&&s.hasPendingWrites?(a.addEntry(n),t=t.insert(r,n)):w(aO,"Ignoring outdated watch update for ",r,". Current version:",s.version," Watch version:",n.version)}),{$o:t,Ko:u}})).next(e=>{d=e.$o,m=e.Ko})),!s.isEqual(tA.min())){let t=r.A_.getLastRemoteSnapshotVersion(e).next(t=>r.A_.setTargetsMetadata(e,e.currentSequenceNumber,s));h.push(t)}return nf.waitFor(h).next(()=>c.apply(e)).next(()=>r.localDocuments.getLocalViewOfDocuments(e,d,m)).next(()=>d)}).then(e=>(r.No=i,e)));
7t.targetChanges.forEach((t,r)=>{let n=e.Ic.get(r);n&&(b(t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size<=1,22616),t.addedDocuments.size>0?n.lc=!0:t.modifiedDocuments.size>0?b(n.lc,14607):t.removedDocuments.size>0&&(b(n.lc,42227),n.lc=!1))}),await oP(e,a,t)}catch(e){await nm(e)}}function oA(e,t,r){if(e.isPrimaryClient&&0===r||!e.isPrimaryClient&&1===r){var n;let r,s=[];e.hc.forEach((e,r)=>{let n=r.view.Du(t);n.snapshot&&s.push(n.snapshot)}),(n=e.eventManager).onlineState=t,r=!1,n.queries.forEach((e,n)=>{for(let e of n.wu)e.Du(t)&&(r=!0)}),r&&of(n),s.length&&e.Ec.hn(s),e.onlineState=t,e.isPrimaryClient&&e.sharedClientState.setOnlineState(t)}}async function oD(e,t,r){e.sharedClientState.updateQueryState(t,"rejected",r);let n=e.Ic.get(t),s=n&&n.key;if(s){let r=new A(K.comparator);r=r.insert(s,tD.newNoDocument(s,tA.min()));let n=t9().add(s),i=new ri(tA.min(),new Map,new A(S),r,t3,n);await oV(e,i),e.Rc=e.Rc.remove(s),e.Ic.delete(t),oO(e)}else await aF(e.localStore,t,!1).then(()=>ok(e,t,r)).catch(nm)}function ok(e,t,r=null){for(let n of(e.sharedClientState.removeLocalQueryTarget(t),e.Tc.get(t)))e.hc.delete(n),r&&e.Ec.yc(n,r);e.Tc.delete(t),e.isPrimaryClient&&e.Ac.Xs(t).forEach(t=>{e.Ac.containsKey(t)||oL(e,t)})}function oL(e,t){e.Pc.delete(t.path.canonicalString());let r=e.Rc.get(t);null!==r&&(aW(e.remoteStore,r),e.Rc=e.Rc.remove(t),e.Ic.delete(r),oO(e))}function oR(e,t,r){for(let n of r)n instanceof og?(e.Ac.addReference(n.key,t),function(e,t){let r=t.key,n=r.path.canonicalString();e.Rc.get(r)||e.Pc.has(n)||(w(ov,"New document in limbo: "+r),e.Pc.add(n),oO(e))}(e,n)):n instanceof oy?(w(ov,"Document no longer in limbo: "+n.key),e.Ac.removeReference(n.key,t),e.Ac.containsKey(n.key)||oL(e,n.key)):T(19791,{wc:n})}function oO(e){for(;e.Pc.size>0&&e.Rc.size<e.maxConcurrentLimboResolutions;){let t=e.Pc.values().next().value;e.Pc.delete(t);let r=new K(F.fromString(t)),n=e.fc.next();e.Ic.set(n,new oE(r)),e.Rc=e.Rc.insert(r,n),aQ(e.remoteStore,new ai(tG(t$(r.path)),n,"TargetPurposeLimboResolution",nh.yn))}}async function oP(e,t,r){let n=[],s=[],i=[];e.hc.isEmpty()||(e.hc.forEach((a,o)=>{i.push(e.gc(o,t,r).then(t=>{if((t||r)&&e.isPrimaryClient){let n=t?!t.fromCache:r?.targetChanges.get(o.targetId)?.current;e.sharedClientState.updateQueryState(o.targetId,n?"current":"not-current")}if(t){n.push(t);let e=aD.fo(o.targetId,t);s.push(e)}}))}),await Promise.all(i),e.Ec.hn(n),await async function(e,t){try{await e.persistence.runTransaction("notifyLocalViewChanges","readwrite",r=>nf.forEach(t,t=>nf.forEach(t.Ao,n=>e.persistence.referenceDelegate.addReference(r,t.targetId,n)).next(()=>nf.forEach(t.Vo,n=>e.persistence.referenceDelegate.removeReference(r,t.targetId,n)))))}catch(e){if(!np(e))throw e;w(aO,"Failed to update sequence numbers: "+e)}for(let r of t){let t=r.targetId;if(!r.fromCache){let r=e.No.get(t),n=r.snapshotVersion,s=r.withLastLimboFreeSnapshotVersion(n);e.No=e.No.insert(t,s)}}}(e.localStore,s))}async function oU(e,t){if(!e.currentUser.isEqual(t)){w(ov,"User change. New user:",t.toKey());let r=await aU(e.localStore,t);e.currentUser=t,e.dc.forEach(e=>{e.forEach(e=>{e.reject(new P(O.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))})}),e.dc.clear(),e.sharedClientState.handleUserChange(t,r.removedBatchIds,r.addedBatchIds),await oP(e,r.qo)}}function oM(e,t){let r=e.Ic.get(t);if(r&&r.lc)return t9().add(r.key);{let r=t9(),n=e.Tc.get(t);if(!n)return r;for(let t of n??[]){let n=e.hc.get(t);r=r.unionWith(n.view.Yu)}return r}}function oF(e){return e.remoteStore.remoteSyncer.applyRemoteEvent=oV.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=oM.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=oD.bind(null,e),e.Ec.hn=od.bind(null,e.eventManager),e.Ec.yc=om.bind(null,e.eventManager),e}class oq{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=rM(e.databaseInfo.databaseId),this.sharedClientState=this.Sc(e),this.persistence=this.vc(e),await this.persistence.start(),this.localStore=this.Dc(e),this.gcScheduler=this.xc(e,this.localStore),this.indexBackfillerScheduler
7=this.Cc(e,this.localStore)}xc(e,t){return null}Cc(e,t){return null}Dc(e){var t,r;return t=this.persistence,r=new aR,new aP(t,r,e.initialUser,this.serializer)}vc(e){return new aI(aV.w_,this.serializer)}Sc(e){return new or}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}oq.provider={build:()=>new oq};class o$ extends oq{constructor(e){super(),this.cacheSizeBytes=e}xc(e,t){return b(this.persistence.referenceDelegate instanceof aA,46915),new nv(this.persistence.referenceDelegate.garbageCollector,e.asyncQueue,t)}vc(e){let t=void 0!==this.cacheSizeBytes?nc.withCacheSize(this.cacheSizeBytes):nc.DEFAULT;return new aI(e=>aA.w_(e,t),this.serializer)}}class oB{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=e=>oA(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=oU.bind(null,this.syncEngine),await a8(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new ol}createDatastore(e){var t;let r=rM(e.databaseInfo.databaseId),n=new nt(e.databaseInfo);return t=e.authCredentials,new no(t,e.appCheckCredentials,n,r)}createRemoteStore(e){var t,r;return t=this.localStore,r=this.datastore,new az(t,r,e.asyncQueue,e=>oA(this.syncEngine,e,0),r2.Je()?new r2:new r0)}createSyncEngine(e,t){var r,n,s,i,a,o;let l;return r=this.localStore,n=this.remoteStore,s=this.eventManager,i=this.sharedClientState,a=e.initialUser,o=e.maxConcurrentLimboResolutions,l=new oT(r,n,s,i,a,o),t&&(l.mc=!0),l}async terminate(){await async function(e){w(aB,"RemoteStore shutting down."),e.ca.add(5),await aG(e),e.Ea.shutdown(),e.ha.set("Unknown")}(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}}oB.provider={build:()=>new oB};let oz="FirestoreClient";class oj{constructor(e,t,r,n,s){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=r,this._databaseInfo=n,this.user=rz.UNAUTHENTICATED,this.clientId=N.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=s,this.authCredentials.start(r,async e=>{w(oz,"Received user=",e.uid),await this.authCredentialListener(e),this.user=e}),this.appCheckCredentials.start(r,e=>(w(oz,"Received new app check token=",e),this.appCheckCredentialListener(e,this.user)))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this._databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();let e=new rj;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(r){let t=oe(r,"Failed to shutdown persistence");e.reject(t)}}),e.promise}}async function oG(e,t){e.asyncQueue.verifyOperationInProgress(),w(oz,"Initializing OfflineComponentProvider");let r=e.configuration;await t.initialize(r);let n=r.initialUser;e.setCredentialChangeListener(async e=>{n.isEqual(e)||(await aU(t.localStore,e),n=e)}),t.persistence.setDatabaseDeletedListener(()=>e.terminate()),e._offlineComponents=t}async function oK(e,t){e.asyncQueue.verifyOperationInProgress();let r=await oQ(e);w(oz,"Initializing OnlineComponentProvider"),await t.initialize(r,e.configuration),e.setCredentialChangeListener(e=>a6(t.remoteStore,e)),e.setAppCheckTokenChangeListener((e,r)=>a6(t.remoteStore,r)),e._onlineComponents=t}async function oQ(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){w(oz,"Using user provided OfflineComponentProvider");try{await oG(e,e._uninitializedComponentsProvider._offline)}catch(t){if(!("FirebaseError"===t.name?t.code===O.FAILED_PRECONDITION||t.code===O.UNIMPLEMENT
7ED:!("u">typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code))throw t;_("Error using user provided cache. Falling back to memory cache: "+t),await oG(e,new oq)}}else w(oz,"Using default OfflineComponentProvider"),await oG(e,new o$(void 0));return e._offlineComponents}async function oW(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(w(oz,"Using user provided OnlineComponentProvider"),await oK(e,e._uninitializedComponentsProvider._online)):(w(oz,"Using default OnlineComponentProvider"),await oK(e,new oB))),e._onlineComponents}async function oH(e){let t=await oW(e),r=t.eventManager;return r.onListen=ox.bind(null,t.syncEngine),r.onUnlisten=oI.bind(null,t.syncEngine),r.onFirstRemoteStoreListen=ob.bind(null,t.syncEngine),r.onLastRemoteStoreUnlisten=oC.bind(null,t.syncEngine),r}function oY(e,t,r,n){let s=new a9(n),i=new op(t,s,r);return e.asyncQueue.enqueueAndForget(async()=>oc(await oH(e),i)),()=>{s.Aa(),e.asyncQueue.enqueueAndForget(async()=>oh(await oH(e),i))}}let oJ=class{constructor(e,t,r,n,s){this._firestore=e,this._userDataWriter=t,this._key=r,this._document=n,this._converter=s}get id(){return this._key.path.lastSegment()}get ref(){return new nS(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){let e=new oX(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){return this._document?.data.clone().value.mapValue.fields??void 0}get(e){if(this._document){let t=this._document.data.field(nW("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}},oX=class extends oJ{data(){return super.data()}};class oZ{convertValue(e,t="none"){switch(eV(e)){case 0:return null;case 1:return e.booleanValue;case 2:return eo(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(el(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw T(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){let r={};return j(e,(e,n)=>{r[e]=this.convertValue(n,t)}),r}convertVectorValue(e){return new nD(e.fields?.[eN].arrayValue?.values?.map(e=>eo(e.doubleValue)))}convertGeoPoint(e){return new rB(eo(e.latitude),eo(e.longitude))}convertArray(e,t){return(e.values||[]).map(e=>this.convertValue(e,t))}convertServerTimestamp(e,t){switch(t){case"previous":let r=ef(e);return null==r?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(ep(e));default:return null}}convertTimestamp(e){let t=ea(e);return new er(t.seconds,t.nanos)}convertDocumentKey(e,t){let r=F.fromString(e);b(rR(r),9688,{name:e});let n=new ew(r.get(1),r.get(3)),s=new K(r.popFirst(5));return n.isEqual(t)||v(`A document reference to ${s} refers to a different database (${n.projectId}/${n.database}), which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),s}}function o0(e,t,r){return e?r&&(r.merge||r.mergeFields)?e.toFirestore(t,r):e.toFirestore(t):t}class o1 extends oZ{constructor(e){super(),this.firestore=e}convertBytes(e){return new rF(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new nS(this.firestore,null,t)}}let o2="AsyncQueue";class o3{constructor(e=Promise.resolve()){this.qc=[],this.$c=!1,this.Kc=[],this.Qc=null,this.Wc=!1,this.Gc=!1,this.zc=[],this.jt=new nr(this,"async_queue_retry"),this.jc=()=>{let e=on();e&&w(o2,"Visibility state changed to "+e.visibilityState),this.jt.qt()},this.Hc=e;const t=on();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this.jc)}get isShuttingDown(){return this.$c}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.Jc(),this.Yc(e)}enterRestrictedMode(e){if(!this.$c){this.$c=!0,this.Gc=e||!1;
7let t=on();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.jc)}}enqueue(e){if(this.Jc(),this.$c)return new Promise(()=>{});let t=new rj;return this.Yc(()=>this.$c&&this.Gc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.qc.push(e),this.Zc()))}async Zc(){if(0!==this.qc.length){try{await this.qc[0](),this.qc.shift(),this.jt.reset()}catch(e){if(!np(e))throw e;w(o2,"Operation failed with retryable error: "+e)}this.qc.length>0&&this.jt.Ut(()=>this.Zc())}}Yc(e){let t=this.Hc.then(()=>(this.Wc=!0,e().catch(e=>{throw this.Qc=e,this.Wc=!1,v("INTERNAL UNHANDLED ERROR: ",o4(e)),e}).then(e=>(this.Wc=!1,e))));return this.Hc=t,t}enqueueAfterDelay(e,t,r){this.Jc(),this.zc.indexOf(e)>-1&&(t=0);let n=a7.createAndSchedule(this,e,t,r,e=>this.Xc(e));return this.Kc.push(n),n}Jc(){this.Qc&&T(47125,{el:o4(this.Qc)})}verifyOperationInProgress(){}async tl(){let e;do e=this.Hc,await e;while(e!==this.Hc)}nl(e){for(let t of this.Kc)if(t.timerId===e)return!0;return!1}rl(e){return this.tl().then(()=>{for(let t of(this.Kc.sort((e,t)=>e.targetTimeMs-t.targetTimeMs),this.Kc))if(t.skipDelay(),"all"!==e&&t.timerId===e)break;return this.tl()})}il(e){this.zc.push(e)}Xc(e){let t=this.Kc.indexOf(e);this.Kc.splice(t,1)}}function o4(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t}class o6 extends nx{constructor(e,t,r,n){super(e,t,r,n),this.type="firestore",this._queue=new o3,this._persistenceKey=n?.name||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new o3(e),this._firestoreClient=void 0,await e}}}function o8(e,t){let r="object"==typeof e?e:(0,o.Sx)(),n=(0,o.j6)(r,"firestore").getImmediate({identifier:"string"==typeof e?e:t||ey});if(!n._initialized){let e=(0,l.yU)("firestore");e&&nb(n,...e)}return n}function o5(e){if(e._terminated)throw new P(O.FAILED_PRECONDITION,"The client has already been terminated.");return e._firestoreClient||function(e){var t,r,n,s,i;let a,o=e._freezeSettings(),l=(t=e._databaseId,r=e._app?.options.appId||"",n=e._persistenceKey,s=e._app?.options.apiKey,new eg(t,r,n,o.host,o.ssl,o.experimentalForceLongPolling,o.experimentalAutoDetectLongPolling,rZ(o.experimentalLongPollingOptions),o.useFetchStreams,o.isUsingEmulator,s,o._customHeaders,o.grpcFlowControlWindow));e._componentsProvider||o.localCache?._offlineComponentProvider&&o.localCache?._onlineComponentProvider&&(e._componentsProvider={_offline:o.localCache._offlineComponentProvider,_online:o.localCache._onlineComponentProvider}),e._firestoreClient=new oj(e._authCredentials,e._appCheckCredentials,e._queue,l,e._componentsProvider&&(i=e._componentsProvider,a=i?._online.build(),{_offline:i?._offline.build(a),_online:a}))}(e),e._firestoreClient}class o9 extends oZ{constructor(e){super(),this.firestore=e}convertBytes(e){return new rF(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new nS(this.firestore,null,t)}}class o7{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class le extends oJ{constructor(e,t,r,n,s,i){super(e,t,r,n,i),this._firestore=e,this._firestoreImpl=e,this.metadata=s}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){let t=new lt(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){let r=this._document.data.field(nW("DocumentSnapshot.get",e));if(null!==r)return this._userDataWriter.convertValue(r,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new P(O.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");let e=this._document,t={};return t.type=le._jsonSchemaVersion,t.bundle="",t.bundleSource="DocumentSnapshot",t.bundleName=this._key.toString(),e&&e.isValidDocument()&&e.isFoundDocument()&&
7(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),this._firestore,this.ref.path,t.bundle="NOT SUPPORTED"),t}}le._jsonSchemaVersion="firestore/documentSnapshot/1.0",le._jsonSchema={type:ee("string",le._jsonSchemaVersion),bundleSource:ee("string","DocumentSnapshot"),bundleName:ee("string"),bundle:ee("string")};class lt extends le{data(e={}){return super.data(e)}}class lr{constructor(e,t,r,n){this._firestore=e,this._userDataWriter=t,this._snapshot=n,this.metadata=new o7(n.hasPendingWrites,n.fromCache),this.query=r}get docs(){let e=[];return this.forEach(t=>e.push(t)),e}get size(){return this._snapshot.docs.size}get empty(){return 0===this.size}forEach(e,t){this._snapshot.docs.forEach(r=>{e.call(t,new lt(this._firestore,this._userDataWriter,r.key,r,new o7(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){let t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new P(O.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(e,t){if(e._snapshot.oldDocs.isEmpty()){let t=0;return e._snapshot.docChanges.map(r=>{i5(e._snapshot.query)?am(e._snapshot.query):tZ(e.query._query);let n=new lt(e._firestore,e._userDataWriter,r.doc.key,r.doc,new o7(e._snapshot.mutatedKeys.has(r.doc.key),e._snapshot.fromCache),e.query.converter);return r.doc,{type:"added",doc:n,oldIndex:-1,newIndex:t++}})}{let r=e._snapshot.oldDocs;return e._snapshot.docChanges.filter(e=>t||3!==e.type).map(t=>{let n=new lt(e._firestore,e._userDataWriter,t.doc.key,t.doc,new o7(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter),s=-1,i=-1;return 0!==t.type&&(s=r.indexOf(t.doc.key),r=r.delete(t.doc.key)),1!==t.type&&(i=(r=r.add(t.doc)).indexOf(t.doc.key)),{type:function(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return T(61501,{type:e})}}(t.type),doc:n,oldIndex:s,newIndex:i}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new P(O.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");let e={};e.type=lr._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=N.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;let t=[],r=[],n=[];return this.docs.forEach(e=>{null!==e._document&&(t.push(e._document),r.push(this._userDataWriter.convertObjectMap(e._document.data.value.mapValue.fields,"previous")),n.push(e.ref.path))}),this._firestore,this.query._query,e.bundleName,e.bundle="NOT SUPPORTED",e}}lr._jsonSchemaVersion="firestore/querySnapshot/1.0",lr._jsonSchema={type:ee("string",lr._jsonSchemaVersion),bundleSource:ee("string","QuerySnapshot"),bundleName:ee("string"),bundle:ee("string")}}}]);

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