PageSourceSearch

https://toolminder.com/_next/static/chunks/02df5fe5-487d328247353908.js

js toolminder.com collected 2026-10-02 01:46:28 UTC 173,597 bytes, 7 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6504],{13775:(e,t,r)=>{r.d(t,{$:()=>sJ,A:()=>s9,B:()=>sO,C:()=>ts,D:()=>sI,E:()=>em,F:()=>sV,G:()=>sy,H:()=>s7,N:()=>F,O:()=>e8,Q:()=>sC,R:()=>z,U:()=>_,W:()=>sQ,X:()=>rn,Y:()=>sF,Z:()=>sX,_:()=>g,a:()=>x,a0:()=>rm,a2:()=>sg,a4:()=>sp,a6:()=>sN,a7:()=>t_,a8:()=>sm,aO:()=>sA,aX:()=>sR,aY:()=>ae,ac:()=>sv,an:()=>tr,ao:()=>rw,az:()=>er,b:()=>O,c:()=>eP,d:()=>b,e:()=>I,f:()=>tN,g:()=>sG,h:()=>sY,i:()=>ti,j:()=>s3,k:()=>tk,l:()=>tD,m:()=>Z,n:()=>tx,o:()=>tV,p:()=>ee,q:()=>tI,r:()=>eX,s:()=>eV,t:()=>e7,u:()=>tC,v:()=>G,w:()=>X,y:()=>Y,z:()=>sL});var n,i,s,a,o=r(38277),l=r(22846),u=r(90916),c=r(80395),h=r(24052);r(95704);var d=r(15376).Buffer;class f{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}}f.UNAUTHENTICATED=new f(null),f.GOOGLE_CREDENTIALS=new f("google-credentials-uid"),f.FIRST_PARTY=new f("first-party-uid"),f.MOCK_USER=new f("mock-user");let m="12.14.0";function g(e){m=e}let p=new c.Vy("@firebase/firestore");function y(){return p.logLevel}function v(e,...t){if(p.logLevel<=c.$b.DEBUG){let r=t.map(T);p.debug(`Firestore (${m}): ${e}`,...r)}}function w(e,...t){if(p.logLevel<=c.$b.ERROR){let r=t.map(T);p.error(`Firestore (${m}): ${e}`,...r)}}function E(e,...t){if(p.logLevel<=c.$b.WARN){let r=t.map(T);p.warn(`Firestore (${m}): ${e}`,...r)}}function T(e){if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(t){return e}}function _(e,t,r){let n="Unexpected state";"string"==typeof t?n=t:r=t,S(e,n,r)}function S(e,t,r){let n=`FIRESTORE (${m}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(void 0!==r)try{n+=" CONTEXT: "+JSON.stringify(r)}catch(e){n+=" CONTEXT: "+r}throw w(n),Error(n)}function C(e,t,r,n){let i="Unexpected state";"string"==typeof r?i=r:n=r,e||S(t,i,n)}let I={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 b extends l.g{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class A{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}class N{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class k{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(f.UNAUTHENTICATED))}shutdown(){}}class D{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 x{constructor(e){this.t=e,this.currentUser=f.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){C(void 0===this.o,42304);let r=this.i,n=e=>this.i!==r?(r=this.i,t(e)):Promise.resolve(),i=new A;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new A,e.enqueueRetryable(()=>n(this.currentUser))};let s=()=>{let t=i;e.enqueueRetryable(async()=>{await t.promise,await n(this.currentUser)})},a=e=>{v("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=e,this.o&&(this.auth.addAuthTokenListener(this.o),s())};this.t.onInit(e=>a(e)),setTimeout(()=>{if(!this.auth){let e=this.t.getImmediate({optional:!0});e?a(e):(v("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new A)}},0),s()}getToken(){let e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(t=>this.i!==e?(v("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):t?(C("string"==typeof t.accessToken,31837,{l:t}),new N(t.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){let e=this.auth&&this.auth.getUid();return C(null===e||"string"==typeof e,2055,{h:e}),new f(e)}}class V{constructor(e,t,r){this.P=e,this.T=t,this.I=r,this.type="FirstParty",this.user=f.FIRST_PARTY,this.R=new Map}A(){return this.I?this.I():null}get headers(){this.R.set("X-Goog-AuthUser",this.P);let e=this.A();return e&&this.R.set("Authorization",e),this.T&&this.R.set("X-Goog-Iam-Authorization-Token",this.T),this.R}}class R{constructor(e,t,r){this.P=e,this.T=t,this.I=r}getToken(){return Promise.resolve(new V(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable(()=>t(f.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class L{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 O{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,(0,o.xZ)(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){C(void 0===this.o,3512);let r=e=>{null!=e.error&&v("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`);let r=e.token!==this.m;return this.m=e.token,v("FirebaseAppCheckTokenProvider",`Received ${r?"new":"existing"} token.`),r?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable(()=>r(t))};let n=e=>{v("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=e,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit(e=>n(e)),setTimeout(()=>{if(!this.appCheck){let e=this.V.getImmediate({optional:!0});e?n(e):v("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.p)return Promise.resolve(new L(this.p));let e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(e=>e?(C("string"==typeof e.token,44558,{tokenResult:e}),this.m=e.token,new L(e.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}class F{static newId(){let e=62*Math.floor(256/62),t="";for(;t.length<20;){let r=function(e){let t="undefined"!=typeof self&&(self.crypto||self.msCrypto),r=new 
1Uint8Array(40);if(t&&"function"==typeof t.getRandomValues)t.getRandomValues(r);else for(let e=0;e<40;e++)r[e]=Math.floor(256*Math.random());return r}(40);for(let n=0;n<r.length;++n)t.length<20&&r[n]<e&&(t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(r[n]%62))}return t}}function M(e,t){return e<t?-1:+(e>t)}function P(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++){let r=e.charAt(n),i=t.charAt(n);if(r!==i)return U(r)===U(i)?M(r,i):U(r)?1:-1}return M(e.length,t.length)}function U(e){let t=e.charCodeAt(0);return t>=55296&&t<=57343}function q(e,t,r){return e.length===t.length&&e.every((e,n)=>r(e,t[n]))}let $="__name__";class B{constructor(e,t,r){void 0===t?t=0:t>e.length&&_(637,{offset:t,range:e.length}),void 0===r?r=e.length-t:r>e.length-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===B.comparator(this,e)}child(e){let t=this.segments.slice(this.offset,this.limit());return e instanceof B?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=B.compareSegments(e.get(n),t.get(n));if(0!==r)return r}return M(e.length,t.length)}static compareSegments(e,t){let r=B.isNumericId(e),n=B.isNumericId(t);return r&&!n?-1:!r&&n?1:r&&n?B.extractNumericId(e).compare(B.extractNumericId(t)):P(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 z extends B{construct(e,t,r){return new z(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){let t=[];for(let r of e){if(r.indexOf("//")>=0)throw new b(I.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);t.push(...r.split("/").filter(e=>e.length>0))}return new z(t)}static emptyPath(){return new z([])}}let K=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class j extends B{construct(e,t,r){return new j(e,t,r)}static isValidIdentifier(e){return K.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),j.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&this.get(0)===$}static keyField(){return new j([$])}static fromServerFormat(e){let t=[],r="",n=0,i=()=>{if(0===r.length)throw new b(I.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(r),r=""},s=!1;for(;n<e.length;){let t=e[n];if("\\"===t){if(n+1===e.length)throw new b(I.INVALID_ARGUMENT,"Path has trailing escape character: "+e);let t=e[n+1];if("\\"!==t&&"."!==t&&"`"!==t)throw new b(I.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=t,n+=2}else"`"===t?s=!s:"."!==t||s?r+=t:i(),n++}if(i(),s)throw new b(I.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new j(t)}static emptyPath(){return new j([])}}class G{constructor(e){this.path=e}static fromPath(e){return new G(z.fromString(e))}static fromName(e){return new G(z.fromString(e).popFirst(5))}static empty(){return new G(z.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===z.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,t){return z.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new G(new z(e.slice()))}}function Q(e,t,r){if(!r)throw new b(I.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function H(e){if(!G.isDocumentKey(e))throw new b(I.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function W(e){if(G.isDocumentKey(e))throw new b(I.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function J(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}function X(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":_(12329,{type:typeof e})}function Y(e,t){if("_delegate"in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new b(I.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{let r=X(e);throw new b(I.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${r}`)}}return e}function Z(e,t){if(t<=0)throw new b(I.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(!J(e))throw new b(I.INVALID_ARGUMENT,"JSON must be an object");for(let n in t)if(t[n]){let i=t[n].typeString,s="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(i&&typeof a!==i){r=`JSON field '${n}' must be a ${i}.`;break}if(void 0!==s&&a!==s.value){r=`Expected '${n}' field to equal '${s.value}'`;break}}if(r)throw new b(I.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 b(I.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<-0xe7791f700||e>=0x3afff44180)throw new b(I.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?M(this.nanoseconds,e.nanoseconds):M(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{static fromTimestamp(e){return new en(e)}static min(){return new en(new er(0,0))}static max(){return new en(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 ei{constructor(e,t,r,n){this.indexId=e,this.collectionGroup=t,this.fields=r,this.indexState=n}}ei.UNKNOWN_ID=-1;class es{constructor(e,t,r){this.readTime=e,this.documentKey=t,this.largestBatchId=r}static min(){return new es(en.min(),G.empty(),-1)}static max(){return new es(en.max(),G.empty(),-1)}}class ea{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}async function eo(e){if(e.code!==I.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;v("LocalStore","Unexpectedly lost primary lease")}class el{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&&_(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new el((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 el?t:el.resolve(t)}catch(e){return el.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):el.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):el.reject(t)}static resolve(e){return new el((t,r)=>{t(e)})}static reject(e){return new el((t,r)=>{r(e)})}static waitFor(e){return new el((t,r)=>{let n=0,i=0,s=!1;e.forEach(e=>{++n,e.next(()=>{++i,s&&i===n&&t()},e=>r(e))}),s=!0,i===n&&t()})}static or(e){let t=el.resolve(!1);for(let r of e)t=t.next(e=>e?el.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 el((r,n)=>{let i=e.length,s=Array(i),a=0;for(let o=0;o<i;o++){let l=o;t(e[l]).next(e=>{s[l]=e,++a===i&&r(s)},e=>n(e))}})}static doWhile(e,t){return new el((r,n)=>{let i=()=>{!0===e()?t().next(()=>{i()},n):r()};i()})}}function eu(e){return"IndexedDbTransactionError"===e.name}class ec{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=e=>this.ae(e),this.ue=e=>t.writeSequenceNumber(e))}ae(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){let e=++this.previousValue;return this.ue&&this.ue(e),e}}ec.ce=-1;function eh(e){return 0===e&&1/e==-1/0}function ed(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}function ef(e,t){for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t(r,e[r])}function em(e,t){let r=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.push(t(e[n],n,e));return r}function eg(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}class ep{constructor(e,t){this.comparator=e,this.root=t||ev.EMPTY}insert(e,t){return new ep(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,ev.BLACK,null,null))}remove(e){return new ep(this.comparator,this.root.remove(e,this.comparator).copy(null,null,ev.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 ey(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new ey(this.root,e,this.comparator,!1)}getReverseIterator(){return new ey(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new ey(this.root,e,this.comparator,!0)}}class ey{constructor(e,t,r,n){this.isReverse=n,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?r(e.key,t):1,t&&n&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(0===i){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 ev{constructor(e,t,r,n,i){this.key=e,this.value=t,this.color=null!=r?r:ev.RED,this.left=null!=n?n:ev.EMPTY,this.right=null!=i?i:ev.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,r,n,i){return new ev(null!=e?e:this.key,null!=t?t:this.value,
1null!=r?r:this.color,null!=n?n:this.left,null!=i?i: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,i=r(e,n.key);return(n=i<0?n.copy(null,null,null,n.left.insert(e,t,r),null):0===i?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 ev.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 ev.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,ev.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){let e=this.copy(null,null,ev.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 _(43730,{key:this.key,value:this.value});if(this.right.isRed())throw _(14113,{key:this.key,value:this.value});let e=this.left.check();if(e!==this.right.check())throw _(27949);return e+ +!this.isRed()}}ev.EMPTY=null,ev.RED=!0,ev.BLACK=!1,ev.EMPTY=new class{constructor(){this.size=0}get key(){throw _(57766)}get value(){throw _(16141)}get color(){throw _(16727)}get left(){throw _(29726)}get right(){throw _(36894)}copy(e,t,r,n,i){return this}insert(e,t,r){return new ev(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 ew{constructor(e){this.comparator=e,this.data=new ep(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 eE(this.data.getIterator())}getIteratorFrom(e){return new eE(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 ew)||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 ew(this.comparator);return t.data=e,t}}
1class eE{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}class eT{constructor(e){this.fields=e,e.sort(j.comparator)}static empty(){return new eT([])}unionWith(e){let t=new ew(j.comparator);for(let e of this.fields)t=t.add(e);for(let r of e)t=t.add(r);return new eT(t.toArray())}covers(e){for(let t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return q(this.fields,e.fields,(e,t)=>e.isEqual(t))}}class e_ 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"undefined"!=typeof DOMException&&e instanceof DOMException?new e_("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 M(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}eS.EMPTY_BYTE_STRING=new eS("");let eC=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function eI(e){if(C(!!e,39018),"string"==typeof e){let t=0,r=eC.exec(e);if(C(!!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:eb(e.seconds),nanos:eb(e.nanos)}}function eb(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function eA(e){return"string"==typeof e?eS.fromBase64String(e):eS.fromUint8Array(e)}let eN="server_timestamp",ek="__type__",eD="__previous_value__",ex="__local_write_time__";function eV(e){return(e?.mapValue?.fields||{})[ek]?.stringValue===eN}function eR(e){let t=e.mapValue.fields[eD];return eV(t)?eR(t):t}function eL(e){let t=eI(e.mapValue.fields[ex].timestampValue);return new er(t.seconds,t.nanos)}class eO{constructor(e,t,r,n,i,s,a,o,l,u,c){this.databaseId=e,this.appId=t,this.persistenceKey=r,this.host=n,this.ssl=i,this.forceLongPolling=s,this.autoDetectLongPolling=a,this.longPollingOptions=o,this.useFetchStreams=l,this.isUsingEmulator=u,this.apiKey=c}}let eF="(default)";class eM{constructor(e,t){this.projectId=e,this.database=t||eF}static empty(){return new eM("","")}get isDefaultDatabase(){return this.database===eF}isEqual(e){return e instanceof eM&&e.projectId===this.projectId&&e.database===this.database}}function eP(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new b(I.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new eM(e.options.projectId,t)}let eU="__type__",eq="__max__",e$={mapValue:{fields:{__type__:{stringValue:eq}}}},eB="__vector__",ez="value";function eK(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?eV(e)?4:e5(e)?0x1fffffffffffff:e4(e)?10:11:_(28295,{value:e})}function ej(e,t){if(e===t)return!0;let r=eK(e);if(r!==eK(t))return!1;switch(r){case 0:case 0x1fffffffffffff:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return eL(e).isEqual(eL(t));case 3:if("string"==typeof e.timestampValue&&"string"==typeof t.timestampValue&&e.timestampValue.length===t.timestampValue.length)return e.timestampValue===t.timestampValue;let n=eI(e.timestampValue),i=eI(t.timestampValue);return n.seconds===i.seconds&&n.nanos===i.nanos;case 5:return e.stringValue===t.stringValue;case 6:return eA(e.bytesValue).isEqual(eA(t.bytesValue));case 7:return e.referenceValue===t.referenceValue;case 8:return eb(e.geoPointValue.latitude)===eb(t.geoPointValue.latitude)&&eb(e.geoPointValue.longitude)===eb(t.geoPointValue.longitude);case 2:if("integerValue"in e&&"integerValue"in t)return eb(e.integerValue)===eb(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){let r=eb(e.doubleValue),n=eb(t.doubleValue);return r===n?eh(r)===eh(n):isNaN(r)&&isNaN(n)}return!1;case 9:return q(e.arrayValue.values||[],t.arrayValue.values||[],ej);case 10:case 11:let s=e.mapValue.fields||{},a=t.mapValue.fields||{};if(ed(s)!==ed(a))return!1;for(let e in s)if(s.hasOwnProperty(e)&&(void 0===a[e]||!ej(s[e],a[e])))return!1;return!0;default:return _(52216,{left:e})}}function eG(e,t){return void 0!==(e.values||[]).find(e=>ej(e,t))}function eQ(e,t){if(e===t)return 0;let r=eK(e),n=eK(t);if(r!==n)return M(r,n);switch(r){case 0:case 0x1fffffffffffff:return 0;case 1:return M(e.booleanValue,t.booleanValue);case 2:let i=eb(e.integerValue||e.doubleValue),s=eb(t.integerValue||t.doubleValue);return i<s?-1:i>s?1:i===s?0:isNaN(i)?isNaN(s)?0:-1:1;case 3:return eH(e.timestampValue,t.timestampValue);case 4:return eH(eL(e),eL(t));case 5:return P(e.stringValue,t.stringValue);case 6:return function(e,t){let r=eA(e),n=eA(t);return r.compareTo(n)}(e.bytesValue,t.bytesValue);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=M(r[e],n[e]);if(0!==t)return t}return M(r.length,n.length)}(e.referenceValue,t.referenceValue);case 8:return function(e,t){let r=M(eb(e.latitude),eb(t.latitude));return 0!==r?r:M(eb(e.longitude),eb(t.longitude))}(e.geoPointValue,t.geoPointValue);case 9:return eW(e.arrayValue,t.arrayValue);case 10:return function(e,t){let r=e.fields||{},n=t.fields||{},i=r[ez]?.arrayValue,s=n[ez]?.arrayValue,a=M(i?.values?.length||0,s?.values?.length||0);return 0!==a?a:eW(i,s)}(e.mapValue,t.mapValue);case 11:return function(e,t){if(e===e$.mapValue&&t===e$.mapValue)return 0;if(e===e$.mapValue)return 1;if(t===e$.mapValue)return -1;let r=e.fields||{},n=Object.keys(r),i=t.fields||{},s=Object.keys(i);n.sort(),s.sort();for(let e=0;e<n.length&&e<s.length;++e){let t=P(n[e],s[e]);if(0!==t)return t;let a=eQ(r[n[e]],i[s[e]]);if(0!==a)return a}return M(n.length,s.length)}(e.mapValue,t.mapValue);default:throw _(23264,{he:r})}}function eH(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return M(e,t);let r=eI(e),n=eI(t),i=M(r.seconds,n.seconds);return 0!==i?i:M(r.nanos,n.nanos)}function eW(e,t){let r=e.values||[],n=t.values||[];for(let e=0;e<r.length&&e<n.length;++e){let t=eQ(r[e],n[e]);if(t)return t}return M(r.length,n.length)}function eJ(e){var t,r;return"nullValue"in e?"null":"booleanValue"in e?""+e.booleanValue:"integerValue"in e?""+e.integerValue:"doubleValue"in e?""+e.doubleValue:"timestampValue"in e?function(e){let t=eI(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?eA(e.bytesValue).toBase64():"referenceValue"in e?(t=e.referenceValue,G.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+=eJ(n);return t+"]"}(e.arrayValue):"mapValue"in e?function(e){let t=Object.keys(e.fields||{}).sort(),r="{",n=!0;for(let i of t)n?n=!1:r+=",",r+=`${i}:${eJ(e.fields[i])}`;return r+"}"}(e.mapValue):_(61005,{value:e})}function eX(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function eY(e){return!!e&&"integerValue"in e}function eZ(e){return eY(e)||!!e&&"doubleValue"in e}function e0(e){return!!e&&"arrayValue"in e}function e1(e){return!!e&&"nullValue"in e}function e2(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function e3(e){return!!e&&"mapValue"in e}function e4(e){return(e?.mapValue?.fields||{})[eU]?.stringValue===eB}function e6(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 ef(e.mapValue.fields,(e,r)=>t.mapValue.fields[e]=e6(r)),t}if(e.arrayValue){let t={arrayValue:{values:[]}};for(let r=0;r<(e.arrayValue.values||[]).length;++r)t.arrayValue.values[r]=e6(e.arrayValue.values[r]);return t}return{...e}}function e5(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===eq}class e8{constructor(e){this.value=e}static empty(){return new e8({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let r=0;r<e.length-1;++r)if(!e3(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()]=e6(t)}setAll(e){let t=j.emptyPath(),r={},n=[];e.forEach((e,i)=>{if(!t.isImmediateParentOf(i)){let e=this.getFieldsMap(t);this.applyChanges(e,r,n),r={},n=[],t=i.popLast()}e?r[i.lastSegment()]=e6(e):n.push(i.lastSegment())});let i=this.getFieldsMap(t);this.applyChanges(i,r,n)}delete(e){let t=this.field(e.popLast());e3(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return ej(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)];e3(n)&&n.mapValue.fields||(n={mapValue:{fields:{}}},t.mapValue.fields[e.get(r)]=n),t=n}return t.mapValue.fields}
1applyChanges(e,t,r){for(let n of(ef(t,(t,r)=>e[t]=r),r))delete e[n]}clone(){return new e8(e6(this.value))}}class e9{constructor(e,t,r,n,i,s,a){this.key=e,this.documentType=t,this.version=r,this.readTime=n,this.createTime=i,this.data=s,this.documentState=a}static newInvalidDocument(e){return new e9(e,0,en.min(),en.min(),en.min(),e8.empty(),0)}static newFoundDocument(e,t,r,n){return new e9(e,1,t,en.min(),r,n,0)}static newNoDocument(e,t){return new e9(e,2,t,en.min(),en.min(),e8.empty(),0)}static newUnknownDocument(e,t){return new e9(e,3,t,en.min(),en.min(),e8.empty(),2)}convertToFoundDocument(e,t){return this.createTime.isEqual(en.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=e8.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=e8.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=en.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 e9&&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 e9(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 e7{constructor(e,t){this.position=e,this.inclusive=t}}function te(e,t,r){let n=0;for(let i=0;i<e.position.length;i++){let s=t[i],a=e.position[i];if(n=s.field.isKeyField()?G.comparator(G.fromName(a.referenceValue),r.key):eQ(a,r.data.field(s.field)),"desc"===s.dir&&(n*=-1),0!==n)break}return n}function tt(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(!ej(e.position[r],t.position[r]))return!1;return!0}class tr{constructor(e,t="asc"){this.field=e,this.dir=t}}class tn{}class ti extends tn{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 tl(e,t,r):"array-contains"===t?new td(e,r):"in"===t?new tf(e,r):"not-in"===t?new tm(e,r):"array-contains-any"===t?new tg(e,r):new ti(e,t,r)}static createKeyFieldInFilter(e,t,r){return"in"===t?new tu(e,r):new tc(e,r)}matches(e){let t=e.data.field(this.field);return"!="===this.op?null!==t&&void 0===t.nullValue&&this.matchesComparison(eQ(t,this.value)):null!==t&&eK(this.value)===eK(t)&&this.matchesComparison(eQ(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 _(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class ts extends tn{constructor(e,t){super(),this.filters=e,this.op=t,this.Pe=null}static create(e,t){return new ts(e,t)}matches(e){return ta(this)?void 0===this.filters.find(t=>!t.matches(e)):void 0!==this.filters.find(t=>t.matches(e))}getFlattenedFilters(){return null!==this.Pe||(this.Pe=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.Pe}getFilters(){return Object.assign([],this.filters)}}function ta(e){return"and"===e.op}function to(e){for(let t of e.filters)if(t instanceof ts)return!1;return!0}class tl extends ti{constructor(e,t,r){super(e,t,r),this.key=G.fromName(r.referenceValue)}matches(e){let t=G.comparator(e.key,this.key);return this.matchesComparison(t)}}class tu extends ti{constructor(e,t){super(e,"in",t),this.keys=th("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}}class tc extends ti{constructor(e,t){super(e,"not-in",t),this.keys=th("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}}function th(e,t){return(t.arrayValue?.values||[]).map(e=>G.fromName(e.referenceValue))}class td extends ti{constructor(e,t){super(e,"array-contains",t)}matches(e){let t=e.data.field(this.field);return e0(t)&&eG(t.arrayValue,this.value)}}class tf extends ti{constructor(e,t){super(e,"in",t)}matches(e){let t=e.data.field(this.field);return null!==t&&eG(this.value.arrayValue,t)}}class tm extends ti{constructor(e,t){super(e,"not-in",t)}matches(e){if(eG(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;let t=e.data.field(this.field);return null!==t&&void 0===t.nullValue&&!eG(this.value.arrayValue,t)}}class tg extends ti{constructor(e,t){super(e,"array-contains-any",t)}matches(e){let t=e.data.field(this.field);return!(!e0(t)||!t.arrayValue.values)&&t.arrayValue.values.some(e=>eG(this.value.arrayValue,e))}}class tp{constructor(e,t=null,r=[],n=[],i=null,s=null,a=null){this.path=e,this.collectionGroup=t,this.orderBy=r,this.filters=n,this.limit=i,this.startAt=s,this.endAt=a,this.Te=null}}function ty(e,t=null,r=[],n=[],i=null,s=null,a=null){return new tp(e,t,r,n,i,s,a)}function tv(e){if(null===e.Te){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 ti)return t.field.canonicalString()+t.op.toString()+eJ(t.value);if(to(t)&&ta(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=>eJ(e)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(e=>eJ(e)).join(",")),e.Te=t}return e.Te}function tw(e,t){if(e.limit!==t.limit||e.orderBy.length!==t.orderBy.length)return!1;for(let i=0;i<e.orderBy.length;i++){var r,n;if(r=e.orderBy[i],n=t.orderBy[i],!(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 ti?r instanceof ti&&t.op===r.op&&t.field.isEqual(r.field)&&ej(t.value,r.value):t instanceof ts?r instanceof ts&&t.op===r.op&&t.filters.length===r.filters.length&&t.filters.reduce((t,n,i)=>t&&e(n,r.filters[i]),!0):void _(19439)}(e.filters[r],t.filters[r]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!tt(e.startAt,t.startAt)&&tt(e.endAt,t.endAt)}function tE(e){return G.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}class tT{constructor(e,t=null,r=[],n=[],i=null,s="F",a=null,o=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=n,this.limit=i,this.limitType=s,this.startAt=a,this.endAt=o,this.Ie=null,this.Ee=null,this.Re=null,this.startAt,this.endAt}}function t_(e){return new tT(e)}function tS(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 tC(e){return null!==e.collectionGroup}function tI(e){if(null===e.Ie){let t;e.Ie=[];let r=new Set;for(let t of e.explicitOrderBy)e.Ie.push(t),r.add(t.field.canonicalString());let n=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";
1(t=new ew(j.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.Ie.push(new tr(t,n))}),r.has(j.keyField().canonicalString())||e.Ie.push(new tr(j.keyField(),n))}return e.Ie}function tb(e){return e.Ee||(e.Ee=tA(e,tI(e))),e.Ee}function tA(e,t){if("F"===e.limitType)return ty(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 tr(e.field,t)});let r=e.endAt?new e7(e.endAt.position,e.endAt.inclusive):null,n=e.startAt?new e7(e.startAt.position,e.startAt.inclusive):null;return ty(e.path,e.collectionGroup,t,e.filters,e.limit,r,n)}}function tN(e,t){let r=e.filters.concat([t]);return new tT(e.path,e.collectionGroup,e.explicitOrderBy.slice(),r,e.limit,e.limitType,e.startAt,e.endAt)}function tk(e,t){let r=e.explicitOrderBy.concat([t]);return new tT(e.path,e.collectionGroup,r,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}function tD(e,t,r){return new tT(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,r,e.startAt,e.endAt)}function tx(e,t){return new tT(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,t,e.endAt)}function tV(e,t){return new tT(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,t)}function tR(e,t){return tw(tb(e),tb(t))&&e.limitType===t.limitType}function tL(e){return`${tv(tb(e))}|lt:${e.limitType}`}function tO(e){var t;let r;return`Query(target=${r=(t=tb(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 ti?`${t.field.canonicalString()} ${t.op} ${eJ(t.value)}`:t instanceof ts?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=>eJ(e)).join(",")),t.endAt&&(r+=", endAt: ",r+=t.endAt.inclusive?"a:":"b:",r+=t.endAt.position.map(e=>eJ(e)).join(",")),`Target(${r})`}; limitType=${e.limitType})`}function tF(e,t){return t.isFoundDocument()&&function(e,t){let r=t.key.path;return null!==e.collectionGroup?t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(r):G.isDocumentKey(e.path)?e.path.isEqual(r):e.path.isImmediateParentOf(r)}(e,t)&&function(e,t){for(let r of tI(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)&&(!e.startAt||!!function(e,t,r){let n=te(e,t,r);return e.inclusive?n<=0:n<0}(e.startAt,tI(e),t))&&(!e.endAt||!!function(e,t,r){let n=te(e,t,r);return e.inclusive?n>=0:n>0}(e.endAt,tI(e),t))}function tM(e){return(t,r)=>{let n=!1;for(let i of tI(e)){let e=function(e,t,r){let n=e.field.isKeyField()?G.comparator(t.key,r.key):function(e,t,r){let n=t.data.field(e),i=r.data.field(e);return null!==n&&null!==i?eQ(n,i):_(42886)}(e.field,t,r);switch(e.dir){case"asc":return n;case"desc":return -1*n;default:return _(19790,{direction:e.dir})}}(i,t,r);if(0!==e)return e;n=n||i.field.isKeyField()}return 0}}class tP{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){ef(this.inner,(t,r)=>{for(let[t,n]of r)e(t,n)})}isEmpty(){return eg(this.inner)}size(){return this.innerSize}}let tU=new ep(G.comparator),tq=new ep(G.comparator);function t$(...e){let t=tq;for(let r of e)t=t.insert(r.key,r);return t}function tB(e){let t=tq;return e.forEach((e,r)=>t=t.insert(e,r.overlayedDocument)),t}function tz(){return new tP(e=>e.toString(),(e,t)=>e.isEqual(t))}let tK=new ep(G.comparator),tj=new ew(G.comparator);function tG(...e){let t=tj;for(let r of e)t=t.add(r);return t}let tQ=new ew(M);function tH(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:eh(t)?"-0":t}}function tW(e){return{integerValue:""+e}}function tJ(e,t){return"number"==typeof t&&Number.isInteger(t)&&!eh(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER?tW(t):tH(e,t)}class tX{constructor(){this._=void 0}}function tY(e,t){return e instanceof t6?eZ(t)?t:{integerValue:0}:null}class tZ extends tX{}class t0 extends tX{constructor(e){super(),this.elements=e}}function t1(e,t){let r=re(t);for(let t of e.elements)r.some(e=>ej(e,t))||r.push(t);return{arrayValue:{values:r}}}class t2 extends tX{constructor(e){super(),this.elements=e}}function t3(e,t){let r=re(t);for(let t of e.elements)r=r.filter(e=>!ej(e,t));return{arrayValue:{values:r}}}
1class t4 extends tX{constructor(e,t){super(),this.serializer=e,this.Ae=t}}class t6 extends t4{}class t5 extends t4{}class t8 extends t4{}function t9(e,t,r){if(!eZ(t))return e.Ae;let n=r(t7(t),t7(e.Ae));return eY(t)&&eY(e.Ae)?tW(n):tH(e.serializer,n)}function t7(e){return eb(e.integerValue||e.doubleValue)}function re(e){return e0(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}class rt{constructor(e,t){this.field=e,this.transform=t}}class rr{constructor(e,t){this.version=e,this.transformResults=t}}class rn{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new rn}static exists(e){return new rn(void 0,e)}static updateTime(e){return new rn(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 ri(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class rs{}function ra(e,t){if(!e.hasLocalMutations||t&&0===t.fields.length)return null;if(null===t)return e.isNoDocument()?new rm(e.key,rn.none()):new ru(e.key,e.data,rn.none());{let r=e.data,n=e8.empty(),i=new ew(j.comparator);for(let e of t.fields)if(!i.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),i=i.add(e)}return new rc(e.key,n,new eT(i.toArray()),rn.none())}}function ro(e,t,r,n){return e instanceof ru?function(e,t,r,n){if(!ri(e.precondition,t))return r;let i=e.value.clone(),s=rf(e.fieldTransforms,n,t);return i.setAll(s),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null}(e,t,r,n):e instanceof rc?function(e,t,r,n){if(!ri(e.precondition,t))return r;let i=rf(e.fieldTransforms,n,t),s=t.data;return(s.setAll(rh(e)),s.setAll(i),t.convertToFoundDocument(t.version,s).setHasLocalMutations(),null===r)?null:r.unionWith(e.fieldMask.fields).unionWith(e.fieldTransforms.map(e=>e.field))}(e,t,r,n):ri(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):r}function rl(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)&&q(r,n,(e,t)=>{var r,n;return e.field.isEqual(t.field)&&(r=e.transform,n=t.transform,r instanceof t0&&n instanceof t0||r instanceof t2&&n instanceof t2?q(r.elements,n.elements,ej):r instanceof t6&&n instanceof t6||r instanceof t5&&n instanceof t5||r instanceof t8&&n instanceof t8?ej(r.Ae,n.Ae):r instanceof tZ&&n instanceof tZ)})))&&(0===e.type?e.value.isEqual(t.value):1!==e.type||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}class ru extends rs{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 rc extends rs{constructor(e,t,r,n,i=[]){super(),this.key=e,this.data=t,this.fieldMask=r,this.precondition=n,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function rh(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 rd(e,t,r){let n=new Map;C(e.length===r.length,32656,{Ve:r.length,de:e.length});for(let s=0;s<r.length;s++){var i;let a=e[s],o=a.transform,l=t.data.field(a.field);n.set(a.field,(i=r[s],o instanceof t0?t1(o,l):o instanceof t2?t3(o,l):i))}return n}function rf(e,t,r){let n=new Map;for(let o of e){var i,s,a;let e=o.transform,l=r.data.field(o.field);n.set(o.field,(i=e,s=l,a=t,i instanceof tZ?function(e,t){let r={fields:{[ek]:{stringValue:eN},[ex]:{timestampValue:{seconds:e.seconds,nanos:e.nanoseconds}}}};return t&&eV(t)&&(t=eR(t)),t&&(r.fields[eD]=t),{mapValue:r}}(a,s):i instanceof t0?t1(i,s):i instanceof t2?t3(i,s):i instanceof t6?function(e,t){let r=tY(e,t),n=t7(r)+t7(e.Ae);return eY(r)&&eY(e.Ae)?tW(n):tH(e.serializer,n)}(i,s):i instanceof t5?t9(i,s,Math.min):i instanceof t8?t9(i,s,Math.max):void 0))}return n}class rm extends rs{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class rg extends rs{constructor(e,t){super(),this.key=e,this.prec
1ondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}class rp{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){e instanceof ru?function(e,t,r){let n=e.value.clone(),i=rd(e.fieldTransforms,t,r.transformResults);n.setAll(i),t.convertToFoundDocument(r.version,n).setHasCommittedMutations()}(e,t,r):e instanceof rc?function(e,t,r){if(!ri(e.precondition,t))return t.convertToUnknownDocument(r.version);let n=rd(e.fieldTransforms,t,r.transformResults),i=t.data;i.setAll(rh(e)),i.setAll(n),t.convertToFoundDocument(r.version,i).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=ro(r,e,t,this.localWriteTime));for(let r of this.mutations)r.key.isEqual(e.key)&&(t=ro(r,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){let r=tz();return this.mutations.forEach(n=>{let i=e.get(n.key),s=i.overlayedDocument,a=this.applyToLocalView(s,i.mutatedFields),o=ra(s,a=t.has(n.key)?null:a);null!==o&&r.set(n.key,o),s.isValidDocument()||s.convertToNoDocument(en.min())}),r}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),tG())}isEqual(e){return this.batchId===e.batchId&&q(this.mutations,e.mutations,(e,t)=>rl(e,t))&&q(this.baseMutations,e.baseMutations,(e,t)=>rl(e,t))}}class ry{constructor(e,t,r,n){this.batch=e,this.commitVersion=t,this.mutationResults=r,this.docVersions=n}static from(e,t,r){C(e.mutations.length===r.length,58842,{me:e.mutations.length,fe:r.length});let n=tK,i=e.mutations;for(let e=0;e<i.length;e++)n=n.insert(i[e].key,r[e].version);return new ry(e,t,r,n)}}class rv{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{
2      largestBatchId: ${this.largestBatchId},
3      mutation: ${this.mutation.toString()}
4    }`}}class rw{constructor(e,t,r){this.alias=e,this.aggregateType=t,this.fieldPath=r}}class rE{constructor(e,t){this.count=e,this.unchangedNames=t}}function rT(e){if(void 0===e)return w("GRPC error has no .code"),I.UNKNOWN;switch(e){case n.OK:return I.OK;case n.CANCELLED:return I.CANCELLED;case n.UNKNOWN:return I.UNKNOWN;case n.DEADLINE_EXCEEDED:return I.DEADLINE_EXCEEDED;case n.RESOURCE_EXHAUSTED:return I.RESOURCE_EXHAUSTED;case n.INTERNAL:return I.INTERNAL;case n.UNAVAILABLE:return I.UNAVAILABLE;case n.UNAUTHENTICATED:return I.UNAUTHENTICATED;case n.INVALID_ARGUMENT:return I.INVALID_ARGUMENT;case n.NOT_FOUND:return I.NOT_FOUND;case n.ALREADY_EXISTS:return I.ALREADY_EXISTS;case n.PERMISSION_DENIED:return I.PERMISSION_DENIED;case n.FAILED_PRECONDITION:return I.FAILED_PRECONDITION;case n.ABORTED:return I.ABORTED;case n.OUT_OF_RANGE:return I.OUT_OF_RANGE;case n.UNIMPLEMENTED:return I.UNIMPLEMENTED;case n.DATA_LOSS:return I.DATA_LOSS;default:return _(39323,{code:e})}}(i=n||(n={}))[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.UNIMPLEMENTED=12]="UNIMPLEMENTED",i[i.INTERNAL=13]="INTERNAL",i[i.UNAVAILABLE=14]="UNAVAILABLE",i[i.DATA_LOSS=15]="DATA_LOSS";let r_=new u.jz([0xffffffff,0xffffffff],0);function rS(e){let t=(new TextEncoder).encode(e),r=new u.VV;return r.update(t),new Uint8Array(r.digest())}function rC(e){let t=new DataView(e.buffer),r=t.getUint32(0,!0),n=t.getUint32(4,!0),i=t.getUint32(8,!0),s=t.getUint32(12,!0);return[new u.jz([r,n],0),new u.jz([i,s],0)]}class rI{constructor(e,t,r){if(this.bitmap=e,this.padding=t,this.hashCount=r,t<0||t>=8)throw new rb(`Invalid padding: ${t}`);if(r<0||e.length>0&&0===this.hashCount)throw new rb(`Invalid hash count: ${r}`);if(0===e.length&&0!==t)throw new rb(`Invalid padding when bitmap length is 0: ${t}`);this.ge=8*e.length-t,this.pe=u.jz.fromNumber(this.ge)}ye(e,t,r){let n=e.add(t.multiply(u.jz.fromNumber(r)));return 1===n.compare(r_)&&(n=new u.jz([n.getBits(0),n.getBits(1)],0)),n.modulo(this.pe).toNumber()}we(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(0===this.ge)return!1;let[t,r]=rC(rS(e));for(let e=0;e<this.hashCount;e++){let n=this.ye(t,r,e);if(!this.we(n))return!1}return!0}static create(e,t,r){let n=new rI(new Uint8Array(Math.ceil(e/8)),e%8==0?0:8-e%8,t);
4return r.forEach(e=>n.insert(e)),n}insert(e){if(0===this.ge)return;let[t,r]=rC(rS(e));for(let e=0;e<this.hashCount;e++){let n=this.ye(t,r,e);this.Se(n)}}Se(e){let t=Math.floor(e/8);this.bitmap[t]|=1<<e%8}}class rb extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class rA{constructor(e,t,r,n,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=r,this.documentUpdates=n,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(e,t,r){let n=new Map;return n.set(e,rN.createSynthesizedTargetChangeForCurrentChange(e,t,r)),new rA(en.min(),n,new ep(M),tU,tG())}}class rN{constructor(e,t,r,n,i){this.resumeToken=e,this.current=t,this.addedDocuments=r,this.modifiedDocuments=n,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,t,r){return new rN(r,t,tG(),tG(),tG())}}class rk{constructor(e,t,r,n){this.be=e,this.removedTargetIds=t,this.key=r,this.De=n}}class rD{constructor(e,t){this.targetId=e,this.Ce=t}}class rx{constructor(e,t,r=eS.EMPTY_BYTE_STRING,n=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=n}}class rV{constructor(e){this.targetId=e,this.ve=0,this.Fe=rF(),this.Me=eS.EMPTY_BYTE_STRING,this.xe=!1,this.Oe=!0}get current(){return this.xe}get resumeToken(){return this.Me}get Ne(){return 0!==this.ve}get Be(){return this.Oe}Le(e){e.approximateByteSize()>0&&(this.Oe=!0,this.Me=e)}ke(){let e=tG(),t=tG(),r=tG();return this.Fe.forEach((n,i)=>{switch(i){case 0:e=e.add(n);break;case 2:t=t.add(n);break;case 1:r=r.add(n);break;default:_(38017,{changeType:i})}}),new rN(this.Me,this.xe,e,t,r)}qe(){this.Oe=!1,this.Fe=rF()}Ke(e,t){this.Oe=!0,this.Fe=this.Fe.insert(e,t)}Ue(e){this.Oe=!0,this.Fe=this.Fe.remove(e)}$e(){this.ve+=1}We(){this.ve-=1,C(this.ve>=0,3241,{ve:this.ve,targetId:this.targetId})}Qe(){this.Oe=!0,this.xe=!0}}let rR="WatchChangeAggregator";class rL{constructor(e){this.Ge=e,this.ze=new Map,this.je=tU,this.Je=rO(),this.He=rO(),this.Ze=new ep(M)}Xe(e){for(let t of e.be)e.De&&e.De.isFoundDocument()?this.Ye(t,e.De):this.et(t,e.key,e.De);for(let t of e.removedTargetIds)this.et(t,e.key,e.De)}tt(e){this.forEachTarget(e,t=>{let r=this.ze.get(t);if(r)switch(e.state){case 0:this.nt(t)&&r.Le(e.resumeToken);break;case 1:r.We(),r.Ne||r.qe(),r.Le(e.resumeToken);break;case 2:r.We(),r.Ne||this.removeTarget(t);break;case 3:this.nt(t)&&(r.Qe(),r.Le(e.resumeToken));break;case 4:this.nt(t)&&(this.rt(t),r.Le(e.resumeToken));break;default:_(56790,{state:e.state})}else v(rR,`handleTargetChange received targetChange for untracked target ID (${t}) with state (${e.state})`)})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.ze.forEach((e,r)=>{this.nt(r)&&t(r)})}it(e){let t=e.targetId,r=e.Ce.count,n=this.st(t);if(n){let i=n.target;if(tE(i))if(0===r){let e=new G(i.path);this.et(t,e,e9.newNoDocument(e,en.min()))}else C(1===r,20013,{expectedCount:r});else{let n=this.ot(t);if(n!==r){let r=this._t(e),i=r?this.ut(r,e,n):1;0!==i&&(this.rt(t),this.Ze=this.Ze.insert(t,2===i?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch"))}}}}_t(e){let t,r,n=e.Ce.unchangedNames;if(!n||!n.bits)return null;let{bits:{bitmap:i="",padding:s=0},hashCount:a=0}=n;try{t=eA(i).toUint8Array()}catch(e){if(e instanceof e_)return E("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 rI(t,s,a)}catch(e){return E(e instanceof rb?"BloomFilter error: ":"Applying bloom filter failed: ",e),null}return 0===r.ge?null:r}ut(e,t,r){return 2*(t.Ce.count!==r-this.ht(e,t.targetId))}ht(e,t){let r=this.Ge.getRemoteKeysForTarget(t),n=0;return r.forEach(r=>{let i=this.Ge.lt(),s=`projects/${i.projectId}/databases/${i.database}/documents/${r.path.canonicalString()}`;e.mightContain(s)||(this.et(t,r,null),n++)}),n}Pt(e){let t=new Map;this.ze.forEach((r,n)=>{let i=this.st(n);if(i){if(r.current&&tE(i.target)){let t=new G(i.target.path);this.Tt(t).has(n)||this.It(n,t)||this.et(n,t,e9.newNoDocument(t,e))}r.Be&&(t.set(n,r.ke()),r.qe())}});let r=tG();this.He.forEach((e,t)=>{let n=!0;t.forEachWhile(e=>{let t=this.st(e);return!t||"TargetPurposeLimboResolution"===t.purpose||(n=!1,!1)}),n&&(r=r.add(e))}),this.je.forEach((t,r)=>r.setReadTime(e));let n=new rA(e,t,this.Ze,this.je,r);return this.je=tU,this.Je=rO(),this.He=rO(),this.Ze=new ep(M),n}Ye(e,t){let r=this.ze.get(e);if(!r||!this.nt(e))return void v(rR,`addDocumentToTarget received document for unknown inactive target (${e})`);
4let n=2*!!this.It(e,t.key);r.Ke(t.key,n),this.je=this.je.insert(t.key,t),this.Je=this.Je.insert(t.key,this.Tt(t.key).add(e)),this.He=this.He.insert(t.key,this.Et(t.key).add(e))}et(e,t,r){let n=this.ze.get(e);n&&this.nt(e)?(this.It(e,t)?n.Ke(t,1):n.Ue(t),this.He=this.He.insert(t,this.Et(t).delete(e)),this.He=this.He.insert(t,this.Et(t).add(e)),r&&(this.je=this.je.insert(t,r))):v(rR,`removeDocumentFromTarget received document for unknown or inactive target (${e})`)}removeTarget(e){this.ze.delete(e)}ot(e){let t=this.ze.get(e);if(!t)return 0;let r=t.ke();return this.Ge.getRemoteKeysForTarget(e).size+r.addedDocuments.size-r.removedDocuments.size}$e(e){let t=this.ze.get(e);t||(v(rR,`recordPendingTargetRequest set up tracking for target ID ${e}`),t=new rV(e),this.ze.set(e,t)),t.$e()}Et(e){let t=this.He.get(e);return t||(t=new ew(M),this.He=this.He.insert(e,t)),t}Tt(e){let t=this.Je.get(e);return t||(t=new ew(M),this.Je=this.Je.insert(e,t)),t}nt(e){let t=null!==this.st(e);return t||v(rR,"Detected inactive target",e),t}st(e){let t=this.ze.get(e);return void 0===t||t.Ne?null:this.Ge.Rt(e)}rt(e){this.ze.set(e,new rV(e)),this.Ge.getRemoteKeysForTarget(e).forEach(t=>{this.et(e,t,null)})}It(e,t){return this.Ge.getRemoteKeysForTarget(e).has(t)}}function rO(){return new ep(G.comparator)}function rF(){return new ep(G.comparator)}let rM={asc:"ASCENDING",desc:"DESCENDING"},rP={"<":"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"},rU={and:"AND",or:"OR"};class rq{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function r$(e,t){return e.useProto3Json||null==t?t:{value:t}}function rB(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 rz(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function rK(e){return C(!!e,49232),en.fromTimestamp(function(e){let t=eI(e);return new er(t.seconds,t.nanos)}(e))}function rj(e,t){return rG(e,t).canonicalString()}function rG(e,t){let r=new z(["projects",e.projectId,"databases",e.database]).child("documents");return void 0===t?r:r.child(t)}function rQ(e){let t=z.fromString(e);return C(r3(t),10190,{key:t.toString()}),t}function rH(e,t){return rj(e.databaseId,t.path)}function rW(e,t){let r=rQ(t);if(r.get(1)!==e.databaseId.projectId)throw new b(I.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 b(I.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+r.get(3)+" vs "+e.databaseId.database);return new G(rY(r))}function rJ(e,t){return rj(e.databaseId,t)}function rX(e){return new z(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function rY(e){return C(e.length>4&&"documents"===e.get(4),29091,{key:e.toString()}),e.popFirst(5)}function rZ(e,t,r){return{name:rH(e,t),fields:r.value.mapValue.fields}}function r0(e,t){var r,n;let i,s={structuredQuery:{}},a=t.path;null!==t.collectionGroup?(i=a,s.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(i=a.popLast(),s.structuredQuery.from=[{collectionId:a.lastSegment()}]),s.parent=rJ(e,i);let o=function(e){if(0!==e.length)return function e(t){return t instanceof ti?function(e){if("=="===e.op){if(e2(e.value))return{unaryFilter:{field:r1(e.field),op:"IS_NAN"}};if(e1(e.value))return{unaryFilter:{field:r1(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(e2(e.value))return{unaryFilter:{field:r1(e.field),op:"IS_NOT_NAN"}};if(e1(e.value))return{unaryFilter:{field:r1(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:r1(e.field),op:rP[e.op],value:e.value}}}(t):t instanceof ts?function(t){let r=t.getFilters().map(t=>e(t));return 1===r.length?r[0]:{compositeFilter:{op:rU[t.op],filters:r}}}(t):_(54877,{filter:t})}(ts.create(e,"and"))}(t.filters);o&&(s.structuredQuery.where=o);let l=function(e){if(0!==e.length)return e.map(e=>({field:r1(e.field),direction:rM[e.dir]}))}(t.orderBy);l&&(s.structuredQuery.orderBy=l);let u=r$(e,t.limit);return null!==u&&(s.structuredQuery.limit=u),t.startAt&&(s.structuredQuery.startAt={before:(r=t.startAt).inclusive,values:r.position}),t.endAt&&(s.structuredQuery.endAt={before:!(n=t.endAt).inclusive,values:n.position}),{dt:s,parent:i}}function r1(e){return{fieldPath:e.canonicalString()}}function r2(e){return j.fromServerFormat(e.fieldPath)}function r3(e){return e.length>=4&&"projects"===e.get(0)&&"databases"===e.get(2)}function r4(e){return!!e&&"function"==typeof e._toProto&&"ProtoValue"===e._protoValueType}class r6{constructor(e,t,r,n,i=en.min(),s=en.min(),a=eS.EMPTY_BYTE_STRING,o=null){this.target=e,this.targetId=t,this.purpose=r,this.sequenceNumber=n,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=a,this.expectedCount=o}withSequenceNumber(e){return new r6(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new r6(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new r6(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new r6(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class r5{constructor(e){this.gt=e}}class r8{constructor(){}bt(e,t){this.Dt(e,t),t.Ct()}Dt(e,t){if("nullValue"in e)this.vt(t,5);else if("booleanValue"in e)this.vt(t,10),t.Ft(+!!e.booleanValue);else if("integerValue"in e)this.vt(t,15),t.Ft(eb(e.integerValue));else if("doubleValue"in e){let r=eb(e.doubleValue);isNaN(r)?this.vt(t,13):(this.vt(t,15),eh(r)?t.Ft(0):t.Ft(r))}else if("timestampValue"in e){let r=e.timestampValue;this.vt(t,20),"string"==typeof r&&(r=eI(r)),t.Mt(`${r.seconds||""}`),t.Ft(r.nanos||0)}else if("stringValue"in e)this.xt(e.stringValue,t),this.Ot(t);else if("bytesValue"in e)this.vt(t,30),t.Nt(eA(e.bytesValue)),this.Ot(t);else if("referenceValue"in e)this.Bt(e.referenceValue,t);else if("geoPointValue"in e){let r=e.geoPointValue;this.vt(t,45),t.Ft(r.latitude||0),t.Ft(r.longitude||0)}else"mapValue"in e?e5(e)?this.vt(t,Number.MAX_SAFE_INTEGER):e4(e)?this.Lt(e.mapValue,t):(this.kt(e.mapValue,t),this.Ot(t)):"arrayValue"in e?(this.qt(e.arrayValue,t),this.Ot(t)):_(19022,{Kt:e})}xt(e,t){this.vt(t,25),this.Ut(e,t)}Ut(e,t){t.Mt(e)}kt(e,t){let r=e.fields||{};for(let e of(this.vt(t,55),Object.keys(r)))this.xt(e,t),this.Dt(r[e],t)}Lt(e,t){let r=e.fields||{};this.vt(t,53);let n=r[ez].arrayValue?.values?.length||0;this.vt(t,15),t.Ft(eb(n)),this.xt(ez,t),this.Dt(r[ez],t)}qt(e,t){let r=e.values||[];for(let e of(this.vt(t,50),r))this.Dt(e,t)}
4Bt(e,t){this.vt(t,37),G.fromName(e).path.forEach(e=>{this.vt(t,60),this.Ut(e,t)})}vt(e,t){e.Ft(t)}Ot(e){e.Ft(2)}}r8.$t=new r8;class r9{constructor(){this.Sn=new r7}addToCollectionParentIndex(e,t){return this.Sn.add(t),el.resolve()}getCollectionParents(e,t){return el.resolve(this.Sn.getEntries(t))}addFieldIndex(e,t){return el.resolve()}deleteFieldIndex(e,t){return el.resolve()}deleteAllFieldIndexes(e){return el.resolve()}createTargetIndexes(e,t){return el.resolve()}getDocumentsMatchingTarget(e,t){return el.resolve(null)}getIndexType(e,t){return el.resolve(0)}getFieldIndexes(e,t){return el.resolve([])}getNextCollectionGroupToUpdate(e){return el.resolve(null)}getMinOffset(e,t){return el.resolve(es.min())}getMinOffsetFromCollectionGroup(e,t){return el.resolve(es.min())}updateCollectionGroup(e,t,r){return el.resolve()}updateIndexEntries(e,t){return el.resolve()}}class r7{constructor(){this.index={}}add(e){let t=e.lastSegment(),r=e.popLast(),n=this.index[t]||new ew(z.comparator),i=!n.has(r);return this.index[t]=n.add(r),i}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 ew(z.comparator)).toArray()}}new Uint8Array(0);let ne={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class nt{static withCacheSize(e){return new nt(e,nt.DEFAULT_COLLECTION_PERCENTILE,nt.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,r){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=r}}nt.DEFAULT_COLLECTION_PERCENTILE=10,nt.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,nt.DEFAULT=new nt(0x2800000,nt.DEFAULT_COLLECTION_PERCENTILE,nt.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),nt.DISABLED=new nt(-1,0,0);class nr{constructor(e){this.ir=e}next(){return this.ir+=2,this.ir}static sr(){return new nr(0)}static _r(){return new nr(-1)}}let nn="LruGarbageCollector";function ni([e,t],[r,n]){let i=M(e,r);return 0===i?M(t,n):i}class ns{constructor(e){this.hr=e,this.buffer=new ew(ni),this.Pr=0}Tr(){return++this.Pr}Ir(e){let t=[e,this.Tr()];if(this.buffer.size<this.hr)this.buffer=this.buffer.add(t);else{let e=this.buffer.last();0>ni(t,e)&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}}class na{constructor(e,t,r){this.garbageCollector=e,this.asyncQueue=t,this.localStore=r,this.Er=null}start(){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.Rr(6e4)}stop(){this.Er&&(this.Er.cancel(),this.Er=null)}get started(){return null!==this.Er}Rr(e){v(nn,`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){eu(e)?v(nn,"Ignoring IndexedDB error during garbage collection: ",e):await eo(e)}await this.Rr(3e5)})}}class no{constructor(e,t){this.Ar=e,this.params=t}calculateTargetCount(e,t){return this.Ar.Vr(e).next(e=>Math.floor(t/100*e))}nthSequenceNumber(e,t){if(0===t)return el.resolve(ec.ce);let r=new ns(t);return this.Ar.forEachTarget(e,e=>r.Ir(e.sequenceNumber)).next(()=>this.Ar.dr(e,e=>r.Ir(e))).next(()=>r.maxValue)}removeTargets(e,t,r){return this.Ar.removeTargets(e,t,r)}removeOrphanedDocuments(e,t){return this.Ar.removeOrphanedDocuments(e,t)}collect(e,t){return -1===this.params.cacheSizeCollectionThreshold?(v("LruGarbageCollector","Garbage collection skipped; disabled"),el.resolve(ne)):this.getCacheSize(e).next(r=>r<this.params.cacheSizeCollectionThreshold?(v("LruGarbageCollector",`Garbage collection skipped; Cache size ${r} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),ne):this.mr(e,t))}getCacheSize(e){return this.Ar.getCacheSize(e)}mr(e,t){let r,n,i,s,a,o,l,u=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(t=>(t>this.params.maximumSequenceNumbersToCollect?(v("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${t}`),n=this.params.maximumSequenceNumbersToCollect):n=t,s=Date.now(),this.nthSequenceNumber(e,n))).next(n=>(r=n,a=Date.now(),this.removeTargets(e,r,t))).next(t=>(i=t,o=Date.now(),this.removeOrphanedDocuments(e,r))).next(e=>(l=Date.now(),y()<=c.$b.DEBUG&&v("LruGarbageCollector",`LRU Garbage Collection
5	Counted targets in ${s-u}ms
6	Determined least recently used ${n} in `+(a-s)+"ms\n"+`	Removed ${i} targets in `+(o-a)+"ms\n"+`	Removed ${e} documents in `+(l-o)+"ms\n"+`Total Duration: ${l-u}ms`),el.resolve({didRun:!0,sequenceNumbersCollected:n,targetsRemoved:i,documentsRemoved:e})))}}class nl{constructor(){this.changes=new tP(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,e9.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();let r=this.changes.get(t);return void 0!==r?el.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 nu{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}class nc{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&&ro(r.mutation,e,eT.empty(),er.now()),e))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.getLocalViewOfDocuments(e,t,tG()).next(()=>t))}getLocalViewOfDocuments(e,t,r=tG()){let n=tz();return this.populateOverlays(e,n,t).next(()=>this.computeViews(e,t,n,r).next(e=>{let t=t$();return e.forEach((e,r)=>{t=t.insert(e,r.overlayedDocument)}),t}))}getOverlayedDocuments(e,t){let r=tz();return this.populateOverlays(e,r,t).next(()=>this.computeViews(e,t,r,tG()))}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 i=tU,s=tz(),a=tz();return t.forEach((e,t)=>{let a=r.get(t.key);n.has(t.key)&&(void 0===a||a.mutation instanceof rc)?i=i.insert(t.key,t):void 0!==a?(s.set(t.key,a.mutation.getFieldMask()),ro(a.mutation,t,a.mutation.getFieldMask(),er.now())):s.set(t.key,eT.empty())}),this.recalculateAndSaveOverlays(e,i).next(e=>(e.forEach((e,t)=>s.set(e,t)),t.forEach((e,t)=>a.set(e,new nu(t,s.get(e)??null))),a))}recalculateAndSaveOverlays(e,t){let r=tz(),n=new ep((e,t)=>e-t),i=tG();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(e=>{for(let i of e)i.keys().forEach(e=>{let s=t.get(e);if(null===s)return;let a=r.get(e)||eT.empty();a=i.applyToLocalView(s,a),r.set(e,a);let o=(n.get(i.batchId)||tG()).add(e);n=n.insert(i.batchId,o)})}).next(()=>{let s=[],a=n.getReverseIterator();for(;a.hasNext();){let n=a.getNext(),o=n.key,l=n.value,u=tz();l.forEach(e=>{if(!i.has(e)){let n=ra(t.get(e),r.get(e));null!==n&&u.set(e,n),i=i.add(e)}}),s.push(this.documentOverlayCache.saveOverlays(e,o,u))}return el.waitFor(s)}).next(()=>r)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.recalculateAndSaveOverlays(e,t))}getDocumentsMatchingQuery(e,t,r,n){return G.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length?this.getDocumentsMatchingDocumentQuery(e,t.path):tC(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(i=>{let s=n-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,r.largestBatchId,n-i.size):el.resolve(tz()),a=-1,o=i;return s.next(t=>el.forEach(t,(t,r)=>(a<r.largestBatchId&&(a=r.largestBatchId),i.get(t)?el.resolve():this.remoteDocumentCache.getEntry(e,t).next(e=>{o=o.insert(t,e)}))).next(()=>this.populateOverlays(e,t,i)).next(()=>this.computeViews(e,o,t,tG())).next(e=>({batchId:a,changes:tB(e)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new G(t)).next(e=>{let t=t$();return e.isFoundDocument()&&(t=t.insert(e.key,e)),t})}getDocumentsMatchingCollectionGroupQuery(e,t,r,n){let i=t.collectionGroup,s=t$();return this.indexManager.getCollectionParents(e,i).next(a=>el.forEach(a,a=>{let o=new tT(a.child(i),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)=>{s=s.insert(e,t)})})}).next(()=>s))}getDocumentsMatchingCollectionQuery(e,t,r,n){let i;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,r.largestBatchId).next(s=>(i=s,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,r,i,n))).next(e=>{i.forEach((t,r)=>{let n=r.getKey();null===e.get(n)&&(e=e.insert(n,e9.newInvalidDocument(n)))});let r=t$();return e.forEach((e,n)=>{let s=i.get(e);void 0!==s&&ro(s.mutation,n,eT.empty(),er.now()),tF(t,n)&&(r=r.insert(e,n))}),r})}}class nh{constructor(e){this.serializer=e,this.Or=new Map,this.Nr=new Map}getBundleMetadata(e,t){return el.resolve(this.Or.get(t))}
6saveBundleMetadata(e,t){return this.Or.set(t.id,{id:t.id,version:t.version,createTime:rK(t.createTime)}),el.resolve()}getNamedQuery(e,t){return el.resolve(this.Nr.get(t))}saveNamedQuery(e,t){return this.Nr.set(t.name,{name:t.name,query:function(e){let t=function(e){var t;let r,n=function(e){let t=rQ(e);return 4===t.length?z.emptyPath():rY(t)}(e.parent),i=e.structuredQuery,s=i.from?i.from.length:0,a=null;if(s>0){C(1===s,65062);let e=i.from[0];e.allDescendants?a=e.collectionId:n=n.child(e.collectionId)}let o=[];i.where&&(o=function(e){var t;let r=function e(t){return void 0!==t.unaryFilter?function(e){switch(e.unaryFilter.op){case"IS_NAN":let t=r2(e.unaryFilter.field);return ti.create(t,"==",{doubleValue:NaN});case"IS_NULL":let r=r2(e.unaryFilter.field);return ti.create(r,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":let n=r2(e.unaryFilter.field);return ti.create(n,"!=",{doubleValue:NaN});case"IS_NOT_NULL":let i=r2(e.unaryFilter.field);return ti.create(i,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return _(61313);default:return _(60726)}}(t):void 0!==t.fieldFilter?ti.create(r2(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 _(58110);default:return _(50506)}}(t.fieldFilter.op),t.fieldFilter.value):void 0!==t.compositeFilter?ts.create(t.compositeFilter.filters.map(t=>e(t)),function(e){switch(e){case"AND":return"and";case"OR":return"or";default:return _(1026)}}(t.compositeFilter.op)):_(30097,{filter:t})}(e);return r instanceof ts&&to(t=r)&&ta(t)?r.getFilters():[r]}(i.where));let l=[];i.orderBy&&(l=i.orderBy.map(e=>new tr(r2(e.field),function(e){switch(e){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(e.direction))));let u=null;i.limit&&(u=null==(r="object"==typeof(t=i.limit)?t.value:t)?null:r);let c=null;i.startAt&&(c=function(e){let t=!!e.before;return new e7(e.values||[],t)}(i.startAt));let h=null;return i.endAt&&(h=function(e){let t=!e.before;return new e7(e.values||[],t)}(i.endAt)),new tT(n,a,l,o,u,"F",c,h)}({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?tD(t,t.limit,"L"):t}(t.bundledQuery),readTime:rK(t.readTime)}),el.resolve()}}class nd{constructor(){this.overlays=new ep(G.comparator),this.Br=new Map}getOverlay(e,t){return el.resolve(this.overlays.get(t))}getOverlays(e,t){let r=tz();return el.forEach(t,t=>this.getOverlay(e,t).next(e=>{null!==e&&r.set(t,e)})).next(()=>r)}saveOverlays(e,t,r){return r.forEach((r,n)=>{this.wt(e,t,n)}),el.resolve()}removeOverlaysForBatchId(e,t,r){let n=this.Br.get(r);return void 0!==n&&(n.forEach(e=>this.overlays=this.overlays.remove(e)),this.Br.delete(r)),el.resolve()}getOverlaysForCollection(e,t,r){let n=tz(),i=t.length+1,s=new G(t.child("")),a=this.overlays.getIteratorFrom(s);for(;a.hasNext();){let e=a.getNext().value,s=e.getKey();if(!t.isPrefixOf(s.path))break;s.path.length===i&&e.largestBatchId>r&&n.set(e.getKey(),e)}return el.resolve(n)}getOverlaysForCollectionGroup(e,t,r,n){let i=new ep((e,t)=>e-t),s=this.overlays.getIterator();for(;s.hasNext();){let e=s.getNext().value;if(e.getKey().getCollectionGroup()===t&&e.largestBatchId>r){let t=i.get(e.largestBatchId);null===t&&(t=tz(),i=i.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}let a=tz(),o=i.getIterator();for(;o.hasNext()&&(o.getNext().value.forEach((e,t)=>a.set(e,t)),!(a.size()>=n)););return el.resolve(a)}wt(e,t,r){let n=this.overlays.get(r.key);if(null!==n){let e=this.Br.get(n.largestBatchId).delete(r.key);this.Br.set(n.largestBatchId,e)}this.overlays=this.overlays.insert(r.key,new rv(t,r));let i=this.Br.get(t);void 0===i&&(i=tG(),this.Br.set(t,i)),this.Br.set(t,i.add(r.key))}}class nf{constructor(){this.sessionToken=eS.EMPTY_BYTE_STRING}getSessionToken(e){return el.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,el.resolve()}}class nm{constructor(){this.Lr=new ew(ng.kr),this.qr=new ew(ng.Kr)}isEmpty(){return this.Lr.isEmpty()}addReference(e,t){let r=new ng(e,t);this.Lr=this.Lr.add(r),this.qr=this.qr.add(r)}
6Ur(e,t){e.forEach(e=>this.addReference(e,t))}removeReference(e,t){this.$r(new ng(e,t))}Wr(e,t){e.forEach(e=>this.removeReference(e,t))}Qr(e){let t=new G(new z([])),r=new ng(t,e),n=new ng(t,e+1),i=[];return this.qr.forEachInRange([r,n],e=>{this.$r(e),i.push(e.key)}),i}Gr(){this.Lr.forEach(e=>this.$r(e))}$r(e){this.Lr=this.Lr.delete(e),this.qr=this.qr.delete(e)}zr(e){let t=new G(new z([])),r=new ng(t,e),n=new ng(t,e+1),i=tG();return this.qr.forEachInRange([r,n],e=>{i=i.add(e.key)}),i}containsKey(e){let t=new ng(e,0),r=this.Lr.firstAfterOrEqual(t);return null!==r&&e.isEqual(r.key)}}class ng{constructor(e,t){this.key=e,this.jr=t}static kr(e,t){return G.comparator(e.key,t.key)||M(e.jr,t.jr)}static Kr(e,t){return M(e.jr,t.jr)||G.comparator(e.key,t.key)}}class np{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Xn=1,this.Jr=new ew(ng.kr)}checkEmpty(e){return el.resolve(0===this.mutationQueue.length)}addMutationBatch(e,t,r,n){let i=this.Xn;this.Xn++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];let s=new rp(i,t,r,n);for(let t of(this.mutationQueue.push(s),n))this.Jr=this.Jr.add(new ng(t.key,i)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return el.resolve(s)}lookupMutationBatch(e,t){return el.resolve(this.Hr(t))}getNextMutationBatchAfterBatchId(e,t){let r=this.Zr(t+1),n=r<0?0:r;return el.resolve(this.mutationQueue.length>n?this.mutationQueue[n]:null)}getHighestUnacknowledgedBatchId(){return el.resolve(0===this.mutationQueue.length?-1:this.Xn-1)}getAllMutationBatches(e){return el.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let r=new ng(t,0),n=new ng(t,1/0),i=[];return this.Jr.forEachInRange([r,n],e=>{let t=this.Hr(e.jr);i.push(t)}),el.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new ew(M);return t.forEach(e=>{let t=new ng(e,0),n=new ng(e,1/0);this.Jr.forEachInRange([t,n],e=>{r=r.add(e.jr)})}),el.resolve(this.Xr(r))}getAllMutationBatchesAffectingQuery(e,t){let r=t.path,n=r.length+1,i=r;G.isDocumentKey(i)||(i=i.child(""));let s=new ng(new G(i),0),a=new ew(M);return this.Jr.forEachWhile(e=>{let t=e.key.path;return!!r.isPrefixOf(t)&&(t.length===n&&(a=a.add(e.jr)),!0)},s),el.resolve(this.Xr(a))}Xr(e){let t=[];return e.forEach(e=>{let r=this.Hr(e);null!==r&&t.push(r)}),t}removeMutationBatch(e,t){C(0===this.Yr(t.batchId,"removed"),55003),this.mutationQueue.shift();let r=this.Jr;return el.forEach(t.mutations,n=>{let i=new ng(n.key,t.batchId);return r=r.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,n.key)}).next(()=>{this.Jr=r})}tr(e){}containsKey(e,t){let r=new ng(t,0),n=this.Jr.firstAfterOrEqual(r);return el.resolve(t.isEqual(n&&n.key))}performConsistencyCheck(e){return this.mutationQueue.length,el.resolve()}Yr(e,t){return this.Zr(e)}Zr(e){return 0===this.mutationQueue.length?0:e-this.mutationQueue[0].batchId}Hr(e){let t=this.Zr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}class ny{constructor(e){this.ei=e,this.docs=new ep(G.comparator),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){let r=t.key,n=this.docs.get(r),i=n?n.size:0,s=this.ei(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:s}),this.size+=s-i,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 el.resolve(r?r.document.mutableCopy():e9.newInvalidDocument(t))}getEntries(e,t){let r=tU;return t.forEach(e=>{let t=this.docs.get(e);r=r.insert(e,t?t.document.mutableCopy():e9.newInvalidDocument(e))}),el.resolve(r)}getDocumentsMatchingQuery(e,t,r,n){let i=tU,s=t.path,a=new G(s.child("__id-9223372036854775808__")),o=this.docs.getIteratorFrom(a);for(;o.hasNext();){let{key:e,value:{document:a}}=o.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=G.comparator(e.documentKey,t.documentKey))?r:M(e.largestBatchId,t.largestBatchId)}(new es(a.readTime,a.key,-1),r)||(n.has(a.key)||tF(t,a))&&(i=i.insert(a.key,a.mutableCopy()))}return el.resolve(i)}getAllFromCollectionGroup(e,t,r,n){_(9500)}ti(e,t){return el.forEach(this.docs,e=>t(e))}newChangeBuffer(e){return new nv(this)}getSize(e){return el.resolve(this.size)}}class nv extends nl{constructor(e){super(),this.Fr=e}applyChanges(e){let t=[];
vendor: 5,010 bytes, line 6
6return this.changes.forEach((r,n)=>{n.isValidDocument()?t.push(this.Fr.addEntry(e,n)):this.Fr.removeEntry(r)}),el.waitFor(t)}getFromCache(e,t){return this.Fr.getEntry(e,t)}getAllFromCache(e,t){return this.Fr.getEntries(e,t)}}class nw{constructor(e){this.persistence=e,this.ni=new tP(e=>tv(e),tw),this.lastRemoteSnapshotVersion=en.min(),this.highestTargetId=0,this.ri=0,this.ii=new nm,this.targetCount=0,this.si=nr.sr()}forEachTarget(e,t){return this.ni.forEach((e,r)=>t(r)),el.resolve()}getLastRemoteSnapshotVersion(e){return el.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return el.resolve(this.ri)}allocateTargetId(e){return this.highestTargetId=this.si.next(),el.resolve(this.highestTargetId)}setTargetsMetadata(e,t,r){return r&&(this.lastRemoteSnapshotVersion=r),t>this.ri&&(this.ri=t),el.resolve()}cr(e){this.ni.set(e.target,e);let t=e.targetId;t>this.highestTargetId&&(this.si=new nr(t),this.highestTargetId=t),e.sequenceNumber>this.ri&&(this.ri=e.sequenceNumber)}addTargetData(e,t){return this.cr(t),this.targetCount+=1,el.resolve()}updateTargetData(e,t){return this.cr(t),el.resolve()}removeTargetData(e,t){return this.ni.delete(t.target),this.ii.Qr(t.targetId),this.targetCount-=1,el.resolve()}removeTargets(e,t,r){let n=0,i=[];return this.ni.forEach((s,a)=>{a.sequenceNumber<=t&&null===r.get(a.targetId)&&(this.ni.delete(s),i.push(this.removeMatchingKeysForTargetId(e,a.targetId)),n++)}),el.waitFor(i).next(()=>n)}getTargetCount(e){return el.resolve(this.targetCount)}getTargetData(e,t){let r=this.ni.get(t)||null;return el.resolve(r)}addMatchingKeys(e,t,r){return this.ii.Ur(t,r),el.resolve()}removeMatchingKeys(e,t,r){this.ii.Wr(t,r);let n=this.persistence.referenceDelegate,i=[];return n&&t.forEach(t=>{i.push(n.markPotentiallyOrphaned(e,t))}),el.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.ii.Qr(t),el.resolve()}getMatchingKeysForTargetId(e,t){let r=this.ii.zr(t);return el.resolve(r)}containsKey(e,t){return el.resolve(this.ii.containsKey(t))}}class nE{constructor(e,t){this.oi={},this.overlays={},this._i=new ec(0),this.ai=!1,this.ai=!0,this.ui=new nf,this.referenceDelegate=e(this),this.ci=new nw(this),this.indexManager=new r9,this.remoteDocumentCache=new ny(e=>this.referenceDelegate.li(e)),this.serializer=new r5(t),this.hi=new nh(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ai=!1,Promise.resolve()}get started(){return this.ai}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new nd,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let r=this.oi[e.toKey()];return r||(r=new np(t,this.referenceDelegate),this.oi[e.toKey()]=r),r}getGlobalsCache(){return this.ui}getTargetCache(){return this.ci}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.hi}runTransaction(e,t,r){v("MemoryPersistence","Starting transaction:",e);let n=new nT(this._i.next());return this.referenceDelegate.Pi(),r(n).next(e=>this.referenceDelegate.Ti(n).next(()=>e)).toPromise().then(e=>(n.raiseOnCommittedEvent(),e))}Ii(e,t){return el.or(Object.values(this.oi).map(r=>()=>r.containsKey(e,t)))}}class nT extends ea{constructor(e){super(),this.currentSequenceNumber=e}}class n_{constructor(e){this.persistence=e,this.Ei=new nm,this.Ri=null}static Ai(e){return new n_(e)}get Vi(){if(this.Ri)return this.Ri;throw _(60996)}addReference(e,t,r){return this.Ei.addReference(r,t),this.Vi.delete(r.toString()),el.resolve()}removeReference(e,t,r){return this.Ei.removeReference(r,t),this.Vi.add(r.toString()),el.resolve()}markPotentiallyOrphaned(e,t){return this.Vi.add(t.toString()),el.resolve()}removeTarget(e,t){this.Ei.Qr(t.targetId).forEach(e=>this.Vi.add(e.toString()));let r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next(e=>{e.forEach(e=>this.Vi.add(e.toString()))}).next(()=>r.removeTargetData(e,t))}Pi(){this.Ri=new Set}Ti(e){let t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return el.forEach(this.Vi,r=>{let n=G.fromPath(r);return this.di(e,n).next(e=>{e||t.removeEntry(n,en.min())})}).next(()=>(this.Ri=null,t.apply(e)))}updateLimboDocument(e,t){return this.di(e,t).next(e=>{e?this.Vi.delete(t.toString()):this.Vi.add(t.toString())})}li(e){return 0}di(e,t){return el.or([()=>el.resolve(this.Ei.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ii(e,t)])}}class nS{constructor(e,t){this.persistence=e,this.mi=new tP(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=new no(this,t)}static Ai(e,t){return new nS(e,t)}Pi(){}Ti(e){return el.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEac
6hTarget(e,t)}Vr(e){let t=this.gr(e);return this.persistence.getTargetCache().getTargetCount(e).next(e=>t.next(t=>e+t))}gr(e){let t=0;return this.dr(e,e=>{t++}).next(()=>t)}dr(e,t){return el.forEach(this.mi,(r,n)=>this.yr(e,r,n).next(e=>e?el.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(),i=n.newChangeBuffer();return n.ti(e,n=>this.yr(e,n,t).next(e=>{e||(r++,i.removeEntry(n,en.min()))})).next(()=>i.apply(e)).next(()=>r)}markPotentiallyOrphaned(e,t){return this.mi.set(t,e.currentSequenceNumber),el.resolve()}removeTarget(e,t){let r=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,r)}addReference(e,t,r){return this.mi.set(r,e.currentSequenceNumber),el.resolve()}removeReference(e,t,r){return this.mi.set(r,e.currentSequenceNumber),el.resolve()}updateLimboDocument(e,t){return this.mi.set(t,e.currentSequenceNumber),el.resolve()}li(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=function e(t){switch(eK(t)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:let r=eR(t);return r?16+e(r):16;case 5:return 2*t.stringValue.length;case 6:return eA(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 i;return n=t.mapValue,i=0,ef(n.fields,(t,r)=>{i+=t.length+e(r)}),i;default:throw _(13486,{value:t})}}(e.data.value)),t}yr(e,t,r){return el.or([()=>this.persistence.Ii(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{let e=this.mi.get(t);return el.resolve(void 0!==e&&e>r)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}class nC{constructor(e,t,r,n){this.targetId=e,this.fromCache=t,this.Ps=r,this.Ts=n}static Is(e,t){let r=tG(),n=tG();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 nC(e,t.fromCache,r,n)}}class nI{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}class nb{constructor(){this.Es=!1,this.Rs=!1,this.As=100,this.Vs=(0,l.nr)()?8:function(e){let t=e.match(/Android ([\d.]+)/i);return Number(t?t[1].split(".").slice(0,2).join("."):"-1")}((0,l.ZQ)())>0?6:4}initialize(e,t){this.ds=e,this.indexManager=t,this.Es=!0}getDocumentsMatchingQuery(e,t,r,n){let i={result:null};return this.fs(e,t).next(e=>{i.result=e}).next(()=>{if(!i.result)return this.gs(e,t,n,r).next(e=>{i.result=e})}).next(()=>{if(i.result)return;let r=new nI;return this.ps(e,t,r).next(n=>{if(i.result=n,this.Rs)return this.ys(e,t,r,n.size)})}).next(()=>i.result)}ys(e,t,r,n){return r.documentReadCount<this.As?(y()<=c.$b.DEBUG&&v("QueryEngine","SDK will not create cache indexes for query:",tO(t),"since it only creates cache indexes for collection contains","more than or equal to",this.As,"documents"),el.resolve()):(y()<=c.$b.DEBUG&&v("QueryEngine","Query:",tO(t),"scans",r.documentReadCount,"local documents and returns",n,"documents as results."),r.documentReadCount>this.Vs*n?(y()<=c.$b.DEBUG&&v("QueryEngine","The SDK decides to create cache indexes for query:",tO(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,tb(t))):el.resolve())}fs(e,t){if(tS(t))return el.resolve(null);let r=tb(t);return this.indexManager.getIndexType(e,r).next(n=>0===n?null:(null!==t.limit&&1===n&&(r=tb(t=tD(t,null,"F"))),this.indexManager.getDocumentsMatchingTarget(e,r).next(n=>{let i=tG(...n);return this.ds.getDocuments(e,i).next(n=>this.indexManager.getMinOffset(e,r).next(r=>{let s=this.ws(t,n);return this.Ss(t,s,i,r.readTime)?this.fs(e,tD(t,null,"F")):this.bs(e,s,t,r)}))})))}gs(e,t,r,n){return tS(t)||n.isEqual(en.min())?el.resolve(null):this.ds.getDocuments(e,r).next(i=>{let s=this.ws(t,i);return this.Ss(t,s,r,n)?el.resolve(null):(y()<=c.$b.DEBUG&&v("QueryEngine","Re-using previous result from %s to execute query: %s",n.toString(),tO(t)),this.bs(e,s,t,function(e,t){let r=e.toTimestamp().seconds,n=e.toTimestamp().nanoseconds+1;return new es(en.fromTimestamp(1e9===n?new er(r+1,0):new er(r,n)),G.empty(),-1)}(n,0)).next(e=>e))})}ws(e,t){let r=new ew(tM(e));return t.forEach((t,n)=>{tF(e,n)&&(r=r.add(n))}),r}Ss(e,t,r,n){if(null===e.limit)return!1;if(r.size!==t.size)return!0;let i="F"===e.limitType?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(n)>0)}ps(e,t,r){return y()<=c.$b.DEBUG&&v("QueryEngine","Using full collection scan to execute query:",tO(t)),this.ds.getDocumentsMatchingQuery(e,t,es.min(),r)}bs(e,t,r,n){return this.ds.getDocumentsMatchingQuery(e,r,n).next(e=>(t.forEach(t=>{e=e.insert(t.key,t)}),e))}}let nA="LocalStore";class nN{constructor(e,t,r,n){this.persistence=e,this.Ds=t,this.serializer
6=n,this.Cs=new ep(M),this.vs=new tP(e=>tv(e),tw),this.Fs=new Map,this.Ms=e.getRemoteDocumentCache(),this.ci=e.getTargetCache(),this.hi=e.getBundleCache(),this.xs(r)}xs(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new nc(this.Ms,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Ms.setIndexManager(this.indexManager),this.Ds.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.Cs))}}async function nk(e,t){return await e.persistence.runTransaction("Handle user change","readonly",r=>{let n;return e.mutationQueue.getAllMutationBatches(r).next(i=>(n=i,e.xs(t),e.mutationQueue.getAllMutationBatches(r))).next(t=>{let i=[],s=[],a=tG();for(let e of n)for(let t of(i.push(e.batchId),e.mutations))a=a.add(t.key);for(let e of t)for(let t of(s.push(e.batchId),e.mutations))a=a.add(t.key);return e.localDocuments.getDocuments(r,a).next(e=>({Os:e,removedBatchIds:i,addedBatchIds:s}))})})}function nD(e){return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.ci.getLastRemoteSnapshotVersion(t))}async function nx(e,t,r){let n=e.Cs.get(t);try{r||await e.persistence.runTransaction("Release target",r?"readwrite":"readwrite-primary",t=>e.persistence.referenceDelegate.removeTarget(t,n))}catch(e){if(!eu(e))throw e;v(nA,`Failed to update sequence numbers for target ${t}: ${e}`)}e.Cs=e.Cs.remove(t),e.vs.delete(n.target)}function nV(e,t,r){let n=en.min(),i=tG();return e.persistence.runTransaction("Execute query","readwrite",s=>(function(e,t,r){let n=e.vs.get(r);return void 0!==n?el.resolve(e.Cs.get(n)):e.ci.getTargetData(t,r)})(e,s,tb(t)).next(t=>{if(t)return n=t.lastLimboFreeSnapshotVersion,e.ci.getMatchingKeysForTargetId(s,t.targetId).next(e=>{i=e})}).next(()=>e.Ds.getDocumentsMatchingQuery(s,t,r?n:en.min(),r?i:tG())).next(r=>{var n,s,a;let o;return n=e,s=t.collectionGroup||(t.path.length%2==1?t.path.lastSegment():t.path.get(t.path.length-2)),a=r,o=n.Fs.get(s)||en.min(),a.forEach((e,t)=>{t.readTime.compareTo(o)>0&&(o=t.readTime)}),n.Fs.set(s,o),{documents:r,Ls:i}}))}class nR{constructor(){this.activeTargetIds=tQ}Ws(e){this.activeTargetIds=this.activeTargetIds.add(e)}Qs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}$s(){return JSON.stringify({activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()})}}class nL{constructor(){this.Co=new nR,this.vo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,r){}addLocalQueryTarget(e,t=!0){return t&&this.Co.Ws(e),this.vo[e]||"not-current"}updateQueryState(e,t,r){this.vo[e]=t}removeLocalQueryTarget(e){this.Co.Qs(e)}isLocalQueryTarget(e){return this.Co.activeTargetIds.has(e)}clearQueryState(e){delete this.vo[e]}getAllActiveQueryTargets(){return this.Co.activeTargetIds}isActiveQueryTarget(e){return this.Co.activeTargetIds.has(e)}start(){return this.Co=new nR,Promise.resolve()}handleUserChange(e,t,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}class nO{Fo(e){}shutdown(){}}let nF="ConnectivityMonitor";class nM{constructor(){this.Mo=()=>this.xo(),this.Oo=()=>this.No(),this.Bo=[],this.Lo()}Fo(e){this.Bo.push(e)}shutdown(){window.removeEventListener("online",this.Mo),window.removeEventListener("offline",this.Oo)}Lo(){window.addEventListener("online",this.Mo),window.addEventListener("offline",this.Oo)}xo(){for(let e of(v(nF,"Network connectivity changed: AVAILABLE"),this.Bo))e(0)}No(){for(let e of(v(nF,"Network connectivity changed: UNAVAILABLE"),this.Bo))e(1)}static v(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}let nP=null;function nU(){return null===nP?nP=0x10000000+Math.round(0x80000000*Math.random()):nP++,"0x"+nP.toString(16)}let nq="RestConnection",n$={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregation
6Query:"runAggregationQuery",ExecutePipeline:"executePipeline"};class nB{get ko(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;let t=e.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),n=encodeURIComponent(this.databaseId.database);this.qo=t+"://"+e.host,this.Ko=`projects/${r}/databases/${n}`,this.Uo=this.databaseId.database===eF?`project_id=${r}`:`project_id=${r}&database_id=${n}`}$o(e,t,r,n,i){let s=nU(),a=this.Wo(e,t.toUriEncodedString());v(nq,`Sending RPC '${e}' ${s}:`,a,r);let o={"google-cloud-resource-prefix":this.Ko,"x-goog-request-params":this.Uo};this.Qo(o,n,i);let{host:u}=new URL(a),c=(0,l.zJ)(u);return this.Go(e,a,o,r,c).then(t=>(v(nq,`Received RPC '${e}' ${s}: `,t),t),t=>{throw E(nq,`RPC '${e}' ${s} failed with error: `,t,"url: ",a,"request:",r),t})}zo(e,t,r,n,i,s){return this.$o(e,t,r,n,i)}Qo(e,t,r){e["X-Goog-Api-Client"]="gl-js/ fire/"+m,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)}Wo(e,t){let r=n$[e],n=`${this.qo}/v1/${t}:${r}`;return this.databaseInfo.apiKey&&(n=`${n}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),n}terminate(){}}class nz{constructor(e){this.jo=e.jo,this.Jo=e.Jo}Ho(e){this.Zo=e}Xo(e){this.Yo=e}e_(e){this.t_=e}onMessage(e){this.n_=e}close(){this.Jo()}send(e){this.jo(e)}r_(){this.Zo()}i_(){this.Yo()}s_(e){this.t_(e)}o_(e){this.n_(e)}}let nK="WebChannelConnection",nj=(e,t,r)=>{e.listen(t,e=>{try{r(e)}catch(e){setTimeout(()=>{throw e},0)}})};class nG extends nB{constructor(e){super(e),this.__=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}static a_(){nG.u_||(nj((0,h.Ao)(),h.Jh.STAT_EVENT,e=>{e.stat===h.ro.PROXY?v(nK,"STAT_EVENT: detected buffering proxy"):e.stat===h.ro.NOPROXY&&v(nK,"STAT_EVENT: detected no buffering proxy")}),nG.u_=!0)}Go(e,t,r,n,i){let s=nU();return new Promise((i,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();v(nK,`XHR for RPC '${e}' ${s} received:`,JSON.stringify(t)),i(t);break;case h.O4.TIMEOUT:v(nK,`RPC '${e}' ${s} timed out`),a(new b(I.DEADLINE_EXCEEDED,"Request time out"));break;case h.O4.HTTP_ERROR:let r=o.getStatus();if(v(nK,`RPC '${e}' ${s} 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=function(e){let t=e.toLowerCase().replace(/_/g,"-");return Object.values(I).indexOf(t)>=0?t:I.UNKNOWN}(t.status);a(new b(e,t.message))}else a(new b(I.UNKNOWN,"Server responded with status "+o.getStatus()))}else a(new b(I.UNAVAILABLE,"Connection failed."));break;default:_(9055,{c_:e,streamId:s,l_:o.getLastErrorCode(),h_:o.getLastError()})}}finally{v(nK,`RPC '${e}' ${s} completed.`)}});let l=JSON.stringify(n);v(nK,`RPC '${e}' ${s} sending request:`,n),o.send(t,"POST",l,r,15)})}P_(e,t,r){let i=nU(),s=[this.qo,"/","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.Qo(o.initMessageHeaders,t,r),o.encodeInitMessageHeaders=!0;let u=s.join("");v(nK,`Creating RPC '${e}' stream ${i}: ${u}`,o);let c=a.createWebChannel(u,o);this.T_(c);let d=!1,f=!1,m=new nz({jo:t=>{f?v(nK,`Not sending because RPC '${e}' stream ${i} is closed:`,t):(d||(v(nK,`Opening RPC '${e}' stream ${i} transport.`),c.open(),d=!0),v(nK,`RPC '${e}' stream ${i} sending:`,t),c.send(t))},Jo:()=>c.close()});return nj(c,h.iO.EventType.OPEN,()=>{f||(v(nK,`RPC '${e}' stream ${i} transport opened.`),m.r_())}),nj(c,h.iO.EventType.CLOSE,()=>{f||(f=!0,v(nK,`RPC '${e}' stream ${i} transport closed`),m.s_(),this.I_(c))}
6),nj(c,h.iO.EventType.ERROR,t=>{f||(f=!0,E(nK,`RPC '${e}' stream ${i} transport errored. Name:`,t.name,"Message:",t.message),m.s_(new b(I.UNAVAILABLE,"The operation could not be completed")))}),nj(c,h.iO.EventType.MESSAGE,t=>{if(!f){let r=t.data[0];C(!!r,16349);let s=r?.error||r[0]?.error;if(s){v(nK,`RPC '${e}' stream ${i} received error:`,s);let t=s.status,r=function(e){let t=n[e];if(void 0!==t)return rT(t)}(t),a=s.message;"NOT_FOUND"===t&&a.includes("database")&&a.includes("does not exist")&&a.includes(this.databaseId.database)&&E(`Database '${this.databaseId.database}' not found. Please check your project configuration.`),void 0===r&&(r=I.INTERNAL,a="Unknown error status: "+t+" with message "+s.message),f=!0,m.s_(new b(r,a)),c.close()}else v(nK,`RPC '${e}' stream ${i} received:`,r),m.o_(r)}}),nG.a_(),setTimeout(()=>{m.i_()},0),m}terminate(){this.__.forEach(e=>e.close()),this.__=[]}T_(e){this.__.push(e)}I_(e){this.__=this.__.filter(t=>t===e)}Qo(e,t,r){super.Qo(e,t,r),this.databaseInfo.apiKey&&(e["x-goog-api-key"]=this.databaseInfo.apiKey)}createWebChannelTransport(){return(0,h.fF)()}}function nQ(){return"undefined"!=typeof document?document:null}function nH(e){return new rq(e,!0)}nG.u_=!1;class nW{constructor(e,t,r=1e3,n=1.5,i=6e4){this.Di=e,this.timerId=t,this.E_=r,this.R_=n,this.A_=i,this.V_=0,this.d_=null,this.m_=Date.now(),this.reset()}reset(){this.V_=0}f_(){this.V_=this.A_}g_(e){this.cancel();let t=Math.floor(this.V_+this.p_()),r=Math.max(0,Date.now()-this.m_),n=Math.max(0,t-r);n>0&&v("ExponentialBackoff",`Backing off for ${n} ms (base delay: ${this.V_} ms, delay with jitter: ${t} ms, last attempt: ${r} ms ago)`),this.d_=this.Di.enqueueAfterDelay(this.timerId,n,()=>(this.m_=Date.now(),e())),this.V_*=this.R_,this.V_<this.E_&&(this.V_=this.E_),this.V_>this.A_&&(this.V_=this.A_)}y_(){null!==this.d_&&(this.d_.skipDelay(),this.d_=null)}cancel(){null!==this.d_&&(this.d_.cancel(),this.d_=null)}p_(){return(Math.random()-.5)*this.V_}}let nJ="PersistentStream";class nX{constructor(e,t,r,n,i,s,a,o){this.Di=e,this.w_=r,this.S_=n,this.connection=i,this.authCredentialsProvider=s,this.appCheckCredentialsProvider=a,this.listener=o,this.state=0,this.b_=0,this.D_=null,this.C_=null,this.stream=null,this.v_=0,this.F_=new nW(e,t)}M_(){return 1===this.state||5===this.state||this.x_()}x_(){return 2===this.state||3===this.state}start(){this.v_=0,4!==this.state?this.auth():this.O_()}async stop(){this.M_()&&await this.close(0)}N_(){this.state=0,this.F_.reset()}B_(){this.x_()&&null===this.D_&&(this.D_=this.Di.enqueueAfterDelay(this.w_,6e4,()=>this.L_()))}k_(e){this.q_(),this.stream.send(e)}async L_(){if(this.x_())return this.close(0)}q_(){this.D_&&(this.D_.cancel(),this.D_=null)}K_(){this.C_&&(this.C_.cancel(),this.C_=null)}async close(e,t){this.q_(),this.K_(),this.F_.cancel(),this.b_++,4!==e?this.F_.reset():t&&t.code===I.RESOURCE_EXHAUSTED?(w(t.toString()),w("Using maximum backoff delay to prevent overloading the backend."),this.F_.f_()):t&&t.code===I.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.U_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.e_(t)}U_(){}auth(){this.state=1;let e=this.W_(this.b_),t=this.b_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([e,r])=>{this.b_===t&&this.Q_(e,r)},t=>{e(()=>{let e=new b(I.UNKNOWN,"Fetching auth token failed: "+t.message);return this.G_(e)})})}Q_(e,t){let r=this.W_(this.b_);this.stream=this.z_(e,t),this.stream.Ho(()=>{r(()=>this.listener.Ho())}),this.stream.Xo(()=>{r(()=>(this.state=2,this.C_=this.Di.enqueueAfterDelay(this.S_,1e4,()=>(this.x_()&&(this.state=3),Promise.resolve())),this.listener.Xo()))}),this.stream.e_(e=>{r(()=>this.G_(e))}),this.stream.onMessage(e=>{r(()=>1==++this.v_?this.j_(e):this.onNext(e))})}O_(){this.state=5,this.F_.g_(async()=>{this.state=0,this.start()})}G_(e){return v(nJ,`close with error: ${e}`),this.stream=null,this.close(4,e)}W_(e){return t=>{this.Di.enqueueAndForget(()=>this.b_===e?t():(v(nJ,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class nY extends nX{constructor(e,t,r,n,i,s){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,r,n,s),this.serializer
6=i}z_(e,t){return this.connection.P_("Listen",e,t)}j_(e){return this.onNext(e)}onNext(e){this.F_.reset();let t=function(e,t){let r;if("targetChange"in t){var n,i;t.targetChange;let s="NO_CHANGE"===(n=t.targetChange.targetChangeType||"NO_CHANGE")?0:"ADD"===n?1:"REMOVE"===n?2:"CURRENT"===n?3:"RESET"===n?4:_(39313,{state:n}),a=t.targetChange.targetIds||[],o=(i=t.targetChange.resumeToken,e.useProto3Json?(C(void 0===i||"string"==typeof i,58123),eS.fromBase64String(i||"")):(C(void 0===i||i instanceof d||i instanceof Uint8Array,16193),eS.fromUint8Array(i||new Uint8Array))),l=t.targetChange.cause;r=new rx(s,a,o,l&&new b(void 0===l.code?I.UNKNOWN:rT(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 i=rW(e,n.document.name),s=rK(n.document.updateTime),a=n.document.createTime?rK(n.document.createTime):en.min(),o=new e8({mapValue:{fields:n.document.fields}}),l=e9.newFoundDocument(i,s,a,o);r=new rk(n.targetIds||[],n.removedTargetIds||[],l.key,l)}else if("documentDelete"in t){t.documentDelete;let n=t.documentDelete;n.document;let i=rW(e,n.document),s=n.readTime?rK(n.readTime):en.min(),a=e9.newNoDocument(i,s);r=new rk([],n.removedTargetIds||[],a.key,a)}else if("documentRemove"in t){t.documentRemove;let n=t.documentRemove;n.document;let i=rW(e,n.document);r=new rk([],n.removedTargetIds||[],i,null)}else{if(!("filter"in t))return _(11601,{At:t});{t.filter;let e=t.filter;e.targetId;let{count:n=0,unchangedNames:i}=e,s=new rE(n,i);r=new rD(e.targetId,s)}}return r}(this.serializer,e),r=function(e){if(!("targetChange"in e))return en.min();let t=e.targetChange;return t.targetIds&&t.targetIds.length?en.min():t.readTime?rK(t.readTime):en.min()}(e);return this.listener.J_(t,r)}H_(e){let t={};t.database=rX(this.serializer),t.addTarget=function(e,t){let r,n=t.target;if((r=tE(n)?{documents:{documents:[rJ(e,n.path)]}}:{query:r0(e,n).dt}).targetId=t.targetId,t.resumeToken.approximateByteSize()>0){r.resumeToken=rz(e,t.resumeToken);let n=r$(e,t.expectedCount);null!==n&&(r.expectedCount=n)}else if(t.snapshotVersion.compareTo(en.min())>0){r.readTime=rB(e,t.snapshotVersion.toTimestamp());let n=r$(e,t.expectedCount);null!==n&&(r.expectedCount=n)}return r}(this.serializer,e);let r=function(e,t){let r=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 _(28987,{purpose:e})}}(t.purpose);return null==r?null:{"goog-listen-tags":r}}(this.serializer,e);r&&(t.labels=r),this.k_(t)}Z_(e){let t={};t.database=rX(this.serializer),t.removeTarget=e,this.k_(t)}}class nZ extends nX{constructor(e,t,r,n,i,s){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,r,n,s),this.serializer=i}get X_(){return this.v_>0}start(){this.lastStreamToken=void 0,super.start()}U_(){this.X_&&this.Y_([])}z_(e,t){return this.connection.P_("Write",e,t)}j_(e){return C(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,C(!e.writeResults||0===e.writeResults.length,55816),this.listener.ea()}onNext(e){var t,r;C(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.F_.reset();let n=(t=e.writeResults,r=e.commitTime,t&&t.length>0?(C(void 0!==r,14353),t.map(e=>{let t;return(t=e.updateTime?rK(e.updateTime):rK(r)).isEqual(en.min())&&(t=rK(r)),new rr(t,e.transformResults||[])})):[]),i=rK(e.commitTime);return this.listener.ta(i,n)}na(){let e={};e.database=rX(this.serializer),this.k_(e)}Y_(e){let t={streamToken:this.lastStreamToken,writes:e.map(e=>(function(e,t){var r;let n;if(t instanceof ru)n={update:rZ(e,t.key,t.value)};else if(t instanceof rm)n={delete:rH(e,t.key)};else if(t instanceof rc)n={update:rZ(e,t.key,t.data),updateMask:function(e){let t=[];return e.fields.forEach(e=>t.push(e.canonicalString())),{fieldPaths:t}}(t.fieldMask)};else{if(!(t instanceof rg))return _(16599,{Vt:t.type});n={verify:rH(e,t.key)}}return t.fieldTransforms.length>0&&(n.updateTransforms=t.fieldTransforms.map(e=>(function(e,t){let r=t.transform;if(r instanceof tZ)return{fieldPath:t.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(r instanceof t0)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:r.elements}};if(r instanceof t2)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:r.elements}};if(r instanceof t6)return{fieldPath:t.field.canonicalString(),increment:r.Ae};if(r instanceof t5)return{fieldPath:t.field.canonicalString(),minimum:r.Ae};if(r instanceof t8)return{fieldPath:t.field.canonicalString(),maximum:r.Ae};throw _(20930,{transform:t.transform})})(0,e))),t.precondition.isNone||(n.currentDocument=void 0!==(r=t.precondition).updateTime?{updateTime:rB(e,r.updateTime.toTimestamp())}:void 0!==r.exists?{exists:r.exists}:_(27497)),n})(this.serializer,e))};this.k_(t)}}class n0{}class n1 extends n0{constructor(e,t,r,n){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer
6=n,this.ra=!1}ia(){if(this.ra)throw new b(I.FAILED_PRECONDITION,"The client has already been terminated.")}$o(e,t,r,n){return this.ia(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([i,s])=>this.connection.$o(e,rG(t,r),n,i,s)).catch(e=>{throw"FirebaseError"===e.name?(e.code===I.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new b(I.UNKNOWN,e.toString())})}zo(e,t,r,n,i){return this.ia(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([s,a])=>this.connection.zo(e,rG(t,r),n,s,a,i)).catch(e=>{throw"FirebaseError"===e.name?(e.code===I.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new b(I.UNKNOWN,e.toString())})}terminate(){this.ra=!0,this.connection.terminate()}}class n2{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.sa=0,this.oa=null,this._a=!0}aa(){0===this.sa&&(this.ua("Unknown"),this.oa=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.oa=null,this.ca("Backend didn't respond within 10 seconds."),this.ua("Offline"),Promise.resolve())))}la(e){"Online"===this.state?this.ua("Unknown"):(this.sa++,this.sa>=1&&(this.ha(),this.ca(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ua("Offline")))}set(e){this.ha(),this.sa=0,"Online"===e&&(this._a=!1),this.ua(e)}ua(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}ca(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._a?(w(t),this._a=!1):v("OnlineStateTracker",t)}ha(){null!==this.oa&&(this.oa.cancel(),this.oa=null)}}let n3="RemoteStore";class n4{constructor(e,t,r,n,i){this.localStore=e,this.datastore=t,this.asyncQueue=r,this.remoteSyncer={},this.Pa=[],this.Ta=new Map,this.Ia=new Map,this.Ea=new Map,this.Ra=new nr(1e3),this.Aa=new nr(1001),this.Va=new Set,this.da=[],this.ma=i,this.ma.Fo(e=>{r.enqueueAndForget(async()=>{is(this)&&(v(n3,"Restarting streams for network reachability change."),await async function(e){e.Va.add(4),await n5(e),e.fa.set("Unknown"),e.Va.delete(4),await n6(e)}(this))})}),this.fa=new n2(r,n)}}async function n6(e){if(is(e))for(let t of e.da)await t(!0)}async function n5(e){for(let t of e.da)await t(!1)}function n8(e,t){return e.Ia.get(t)||void 0}function n9(e,t){let r=n8(e,t.targetId);if(void 0!==r&&e.Ta.has(r))return;let n=function(e,t){let r=n8(e,t);void 0!==r&&e.Ea.delete(r);let n=t%2!=0?e.Aa.next():e.Ra.next();return e.Ia.set(t,n),e.Ea.set(n,t),n}(e,t.targetId);v(n3,"remoteStoreListen mapping SDK target ID to remote",t.targetId,n);let i=new r6(t.target,n,t.purpose,t.sequenceNumber,t.snapshotVersion,t.lastLimboFreeSnapshotVersion,t.resumeToken);e.Ta.set(n,i),ii(e)?ir(e):i_(e).x_()&&ie(e,i)}function n7(e,t){let r=i_(e),n=n8(e,t);v(n3,"remoteStoreUnlisten removing mapping of SDK target ID to remote",t,n),e.Ta.delete(n),e.Ia.delete(t),e.Ea.delete(n),r.x_()&&it(e,n),0===e.Ta.size&&(r.x_()?r.B_():is(e)&&e.fa.set("Unknown"))}function ie(e,t){if(e.ga.$e(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(en.min())>0){let r=e.Ea.get(t.targetId);if(void 0===r)return void v(n3,"SDK target ID not found for remote ID: "+t.targetId);let n=e.remoteSyncer.getRemoteKeysForTarget(r).size;t=t.withExpectedCount(n)}i_(e).H_(t)}function it(e,t){e.ga.$e(t),i_(e).Z_(t)}function ir(e){e.ga=new rL({getRemoteKeysForTarget:t=>{let r=e.Ea.get(t);return void 0!==r?e.remoteSyncer.getRemoteKeysForTarget(r):tG()},Rt:t=>e.Ta.get(t)||null,lt:()=>e.datastore.serializer.databaseId}),i_(e).start(),e.fa.aa()}function ii(e){return is(e)&&!i_(e).M_()&&e.Ta.size>0}function is(e){return 0===e.Va.size}async function ia(e){e.fa.set("Online")}async function io(e){e.Ta.forEach((t,r)=>{ie(e,t)})}async function il(e,t){e.ga=void 0,ii(e)?(e.fa.la(t),ir(e)):e.fa.set("Unknown")}async function iu(e,t,r){if(e.fa.set("Online"),t instanceof rx&&2===t.state&&t.cause)try{await async function(e,t){let r=t.cause;for(let n of t.targetIds){if(e.Ta.has(n)){let t=e.Ea.get(n);void 0!==t&&(await e.remoteSyncer.rejectListen(t,r),e.Ia.delete(t),e.Ea.delete(n)),e.Ta.delete(n)}e.ga.removeTarget(n)}}(e,t)}catch(r){v(n3,"Failed to remove targets %s: %s ",t.targetIds.join(","),r),await ic(e,r)}else if(t instanceof rk?e.ga.Xe(t):t instanceof rD?e.ga.it(t):e.ga.tt(t),!r.isEqual(en.min()))try{let t=await nD(e.localStore);r.compareTo(t)>=0&&await function(e,t){let r=e.ga.Pt(t);
7r.targetChanges.forEach((r,n)=>{if(r.resumeToken.approximateByteSize()>0){let i=e.Ta.get(n);i&&e.Ta.set(n,i.withResumeToken(r.resumeToken,t))}}),r.targetMismatches.forEach((t,r)=>{let n=e.Ta.get(t);if(!n)return;e.Ta.set(t,n.withResumeToken(eS.EMPTY_BYTE_STRING,n.snapshotVersion)),it(e,t);let i=new r6(n.target,t,r,n.sequenceNumber);ie(e,i)});let n=function(e,t){let r=new Map;t.targetChanges.forEach((t,n)=>{let i=e.Ea.get(n);void 0!==i&&r.set(i,t)});let n=new ep(M);return t.targetMismatches.forEach((t,r)=>{let i=e.Ea.get(t);void 0!==i&&(n=n.insert(i,r))}),new rA(t.snapshotVersion,r,n,t.documentUpdates,t.resolvedLimboDocuments)}(e,r);return e.remoteSyncer.applyRemoteEvent(n)}(e,r)}catch(t){v(n3,"Failed to raise snapshot:",t),await ic(e,t)}}async function ic(e,t,r){if(!eu(t))throw t;e.Va.add(1),await n5(e),e.fa.set("Offline"),r||(r=()=>nD(e.localStore)),e.asyncQueue.enqueueRetryable(async()=>{v(n3,"Retrying IndexedDB access"),await r(),e.Va.delete(1),await n6(e)})}function ih(e,t){return t().catch(r=>ic(e,r,t))}async function id(e){var t;let r=iS(e),n=e.Pa.length>0?e.Pa[e.Pa.length-1].batchId:-1;for(;is(t=e)&&t.Pa.length<10;)try{let t=await function(e,t){return e.persistence.runTransaction("Get next mutation batch","readonly",r=>(void 0===t&&(t=-1),e.mutationQueue.getNextMutationBatchAfterBatchId(r,t)))}(e.localStore,n);if(null===t){0===e.Pa.length&&r.B_();break}n=t.batchId,function(e,t){e.Pa.push(t);let r=iS(e);r.x_()&&r.X_&&r.Y_(t.mutations)}(e,t)}catch(t){await ic(e,t)}im(e)&&ig(e)}function im(e){return is(e)&&!iS(e).M_()&&e.Pa.length>0}function ig(e){iS(e).start()}async function ip(e){iS(e).na()}async function iy(e){let t=iS(e);for(let r of e.Pa)t.Y_(r.mutations)}async function iv(e,t,r){let n=e.Pa.shift(),i=ry.from(n,t,r);await ih(e,()=>e.remoteSyncer.applySuccessfulWrite(i)),await id(e)}async function iw(e,t){t&&iS(e).X_&&await async function(e,t){var r;if(function(e){switch(e){case I.OK:return _(64938);case I.CANCELLED:case I.UNKNOWN:case I.DEADLINE_EXCEEDED:case I.RESOURCE_EXHAUSTED:case I.INTERNAL:case I.UNAVAILABLE:case I.UNAUTHENTICATED:return!1;case I.INVALID_ARGUMENT:case I.NOT_FOUND:case I.ALREADY_EXISTS:case I.PERMISSION_DENIED:case I.FAILED_PRECONDITION:case I.ABORTED:case I.OUT_OF_RANGE:case I.UNIMPLEMENTED:case I.DATA_LOSS:return!0;default:return _(15467,{code:e})}}(r=t.code)&&r!==I.ABORTED){let r=e.Pa.shift();iS(e).N_(),await ih(e,()=>e.remoteSyncer.rejectFailedWrite(r.batchId,t)),await id(e)}}(e,t),im(e)&&ig(e)}async function iE(e,t){e.asyncQueue.verifyOperationInProgress(),v(n3,"RemoteStore received new credentials");let r=is(e);e.Va.add(3),await n5(e),r&&e.fa.set("Unknown"),await e.remoteSyncer.handleCredentialChange(t),e.Va.delete(3),await n6(e)}async function iT(e,t){t?(e.Va.delete(2),await n6(e)):t||(e.Va.add(2),await n5(e),e.fa.set("Unknown"))}function i_(e){var t,r,n;return e.pa||(t=e.datastore,r=e.asyncQueue,n={Ho:ia.bind(null,e),Xo:io.bind(null,e),e_:il.bind(null,e),J_:iu.bind(null,e)},t.ia(),e.pa=new nY(r,t.connection,t.authCredentials,t.appCheckCredentials,t.serializer,n),e.da.push(async t=>{t?(e.pa.N_(),ii(e)?ir(e):e.fa.set("Unknown")):(await e.pa.stop(),e.ga=void 0)})),e.pa}function iS(e){var t,r,n;return e.ya||(t=e.datastore,r=e.asyncQueue,n={Ho:()=>Promise.resolve(),Xo:ip.bind(null,e),e_:iw.bind(null,e),ea:iy.bind(null,e),ta:iv.bind(null,e)},t.ia(),e.ya=new nZ(r,t.connection,t.authCredentials,t.appCheckCredentials,t.serializer,n),e.da.push(async t=>{t?(e.ya.N_(),await id(e)):(await e.ya.stop(),e.Pa.length>0&&(v(n3,`Stopping write stream with ${e.Pa.length} pending writes`),e.Pa=[]))})),e.ya}class iC{constructor(e,t,r,n,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=r,this.op=n,this.removalCallback=i,this.deferred=new A,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,i){let s=new iC(e,t,Date.now()+r,n,i);return s.start(r),s}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new b(I.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 iI(e,t){if(w("AsyncQueue",`${t}: ${e}`),eu(e))return new b(I.UNAVAILABLE,`${t}: ${e}`);throw e}class ib{static emptySet(e){return new ib(e.comparator)}constructor(e){this.comparator=e?(t,r)=>e(t,r)||G.comparator(t.key,r.key):(e,t)=>G.comparator(e.key,t.key),this.keyedMap=t$(),this.sortedSet=new ep(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 ib)||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 ib;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=t,r}}class iA{constructor(){this.wa=new ep(G.comparator)}track(e){let t=e.doc.key,r=this.wa.get(t);r?0!==e.type&&3===r.type?this.wa=this.wa.insert(t,e):3===e.type&&1!==r.type?this.wa=this.wa.insert(t,{type:r.type,doc:e.doc}):2===e.type&&2===r.type?this.wa=this.wa.insert(t,{type:2,doc:e.doc}):2===e.type&&0===r.type?this.wa=this.wa.insert(t,{type:0,doc:e.doc}):1===e.type&&0===r.type?this.wa=this.wa.remove(t):1===e.type&&2===r.type?this.wa=this.wa.insert(t,{type:1,doc:r.doc}):0===e.type&&1===r.type?this.wa=this.wa.insert(t,{type:2,doc:e.doc}):_(63341,{At:e,Sa:r}):this.wa=this.wa.insert(t,e)}ba(){let e=[];return this.wa.inorderTraversal((t,r)=>{e.push(r)}),e}}class iN{constructor(e,t,r,n,i,s,a,o,l){this.query=e,this.docs=t,this.oldDocs=r,this.docChanges=n,this.mutatedKeys=i,this.fromCache=s,this.syncStateChanged=a,this.excludesMetadataChanges=o,this.hasCachedResults=l}static fromInitialDocuments(e,t,r,n,i){let s=[];
7return t.forEach(e=>{s.push({type:0,doc:e})}),new iN(e,t,ib.emptySet(t),s,r,n,!0,!1,i)}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)&&tR(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 ik{constructor(){this.Da=void 0,this.Ca=[]}va(){return this.Ca.some(e=>e.Fa())}}class iD{constructor(){this.queries=ix(),this.onlineState="Unknown",this.Ma=new Set}terminate(){!function(e,t){let r=e.queries;e.queries=ix(),r.forEach((e,r)=>{for(let e of r.Ca)e.onError(t)})}(this,new b(I.ABORTED,"Firestore shutting down"))}}function ix(){return new tP(e=>tL(e),tR)}async function iV(e,t){let r=3,n=t.query,i=e.queries.get(n);i?!i.va()&&t.Fa()&&(r=2):(i=new ik,r=+!t.Fa());try{switch(r){case 0:i.Da=await e.onListen(n,!0);break;case 1:i.Da=await e.onListen(n,!1);break;case 2:await e.onFirstRemoteStoreListen(n)}}catch(r){let e=iI(r,`Initialization of query '${tO(t.query)}' failed`);return void t.onError(e)}e.queries.set(n,i),i.Ca.push(t),t.xa(e.onlineState),i.Da&&t.Oa(i.Da)&&iF(e)}async function iR(e,t){let r=t.query,n=3,i=e.queries.get(r);if(i){let e=i.Ca.indexOf(t);e>=0&&(i.Ca.splice(e,1),0===i.Ca.length?n=+!t.Fa():!i.va()&&t.Fa()&&(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 iL(e,t){let r=!1;for(let n of t){let t=n.query,i=e.queries.get(t);if(i){for(let e of i.Ca)e.Oa(n)&&(r=!0);i.Da=n}}r&&iF(e)}function iO(e,t,r){let n=e.queries.get(t);if(n)for(let e of n.Ca)e.onError(r);e.queries.delete(t)}function iF(e){e.Ma.forEach(e=>{e.next()})}(a=s||(s={})).Na="default",a.Cache="cache";class iM{constructor(e,t,r){this.query=e,this.Ba=t,this.La=!1,this.ka=null,this.onlineState="Unknown",this.options=r||{}}Oa(e){if(!this.options.includeMetadataChanges){let t=[];for(let r of e.docChanges)3!==r.type&&t.push(r);e=new iN(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.La?this.qa(e)&&(this.Ba.next(e),t=!0):this.Ka(e,this.onlineState)&&(this.Ua(e),t=!0),this.ka=e,t}onError(e){this.Ba.error(e)}xa(e){this.onlineState=e;let t=!1;return this.ka&&!this.La&&this.Ka(this.ka,e)&&(this.Ua(this.ka),t=!0),t}Ka(e,t){return!(e.fromCache&&this.Fa())||(!this.options.$a||"Offline"===t)&&(!e.docs.isEmpty()||e.hasCachedResults||"Offline"===t)}qa(e){if(e.docChanges.length>0)return!0;let t=this.ka&&this.ka.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}Ua(e){e=iN.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.La=!0,this.Ba.next(e)}Fa(){return this.options.source!==s.Cache}}class iP{constructor(e){this.key=e}}class iU{constructor(e){this.key=e}}class iq{constructor(e,t){this.query=e,this.eu=t,this.tu=null,this.hasCachedResults=!1,this.current=!1,this.nu=tG(),this.mutatedKeys=tG(),this.ru=tM(e),this.iu=new ib(this.ru)}get su(){return this.eu}ou(e,t){let r=t?t._u:new iA,n=t?t.iu:this.iu,i=t?t.mutatedKeys:this.mutatedKeys,s=n,a=!1,o="F"===this.query.limitType&&n.size===this.query.limit?n.last():null,l="L"===this.query.limitType&&n.size===this.query.limit?n.first():null;if(e.inorderTraversal((e,t)=>{let u=n.get(e),c=tF(this.query,t)?t:null,h=!!u&&this.mutatedKeys.has(u.key),d=!!c&&(c.hasLocalMutations||this.mutatedKeys.has(c.key)&&c.hasCommittedMutations),f=!1;u&&c?u.data.isEqual(c.data)?h!==d&&(r.track({type:3,doc:c}),f=!0):this.au(u,c)||(r.track({type:2,doc:c}),f=!0,(o&&this.ru(c,o)>0||l&&0>this.ru(c,l))&&(a=!0)):!u&&c?(r.track({type:0,doc:c}),f=!0):u&&!c&&(r.track({type:1,doc:u}),f=!0,(o||l)&&(a=!0)),f&&(c?(s=s.add(c),i=d?i.add(e):i.delete(e)):(s=s.delete(e),i=i.delete(e)))}),null!==this.query.limit)for(;s.size>this.query.limit;
7){let e="F"===this.query.limitType?s.last():s.first();s=s.delete(e.key),i=i.delete(e.key),r.track({type:1,doc:e})}return{iu:s,_u:r,Ss:a,mutatedKeys:i}}au(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,r,n){let i=this.iu;this.iu=e.iu,this.mutatedKeys=e.mutatedKeys;let s=e._u.ba();s.sort((e,t)=>(function(e,t){let r=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return _(20277,{At:e})}};return r(e)-r(t)})(e.type,t.type)||this.ru(e.doc,t.doc)),this.uu(r),n=n??!1;let a=t&&!n?this.cu():[],o=0===this.nu.size&&this.current&&!n?1:0,l=o!==this.tu;return(this.tu=o,0!==s.length||l)?{snapshot:new iN(this.query,e.iu,i,s,e.mutatedKeys,0===o,l,!1,!!r&&r.resumeToken.approximateByteSize()>0),lu:a}:{lu:a}}xa(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({iu:this.iu,_u:new iA,mutatedKeys:this.mutatedKeys,Ss:!1},!1)):{lu:[]}}hu(e){return!this.eu.has(e)&&!!this.iu.has(e)&&!this.iu.get(e).hasLocalMutations}uu(e){e&&(e.addedDocuments.forEach(e=>this.eu=this.eu.add(e)),e.modifiedDocuments.forEach(e=>{}),e.removedDocuments.forEach(e=>this.eu=this.eu.delete(e)),this.current=e.current)}cu(){if(!this.current)return[];let e=this.nu;this.nu=tG(),this.iu.forEach(e=>{this.hu(e.key)&&(this.nu=this.nu.add(e.key))});let t=[];return e.forEach(e=>{this.nu.has(e)||t.push(new iU(e))}),this.nu.forEach(r=>{e.has(r)||t.push(new iP(r))}),t}Pu(e){this.eu=e.Ls,this.nu=tG();let t=this.ou(e.documents);return this.applyChanges(t,!0)}Tu(){return iN.fromInitialDocuments(this.query,this.iu,this.mutatedKeys,0===this.tu,this.hasCachedResults)}}let i$="SyncEngine";class iB{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}}class iz{constructor(e){this.key=e,this.Iu=!1}}class iK{constructor(e,t,r,n,i,s){this.localStore=e,this.remoteStore=t,this.eventManager=r,this.sharedClientState=n,this.currentUser=i,this.maxConcurrentLimboResolutions=s,this.Eu={},this.Ru=new tP(e=>tL(e),tR),this.Au=new Map,this.Vu=new Set,this.du=new ep(G.comparator),this.mu=new Map,this.fu=new nm,this.gu={},this.pu=new Map,this.yu=nr._r(),this.onlineState="Unknown",this.wu=void 0}get isPrimaryClient(){return!0===this.wu}}async function ij(e,t,r=!0){let n,i=sr(e),s=i.Ru.get(t);return s?(i.sharedClientState.addLocalQueryTarget(s.targetId),n=s.view.Tu()):n=await iQ(i,t,r,!0),n}async function iG(e,t){let r=sr(e);await iQ(r,t,!0,!1)}async function iQ(e,t,r,n){var i,s;let a,o=await (i=e.localStore,s=tb(t),i.persistence.runTransaction("Allocate target","readwrite",e=>{let t;return i.ci.getTargetData(e,s).next(r=>r?(t=r,el.resolve(t)):i.ci.allocateTargetId(e).next(r=>(t=new r6(s,r,"TargetPurposeListen",e.currentSequenceNumber),i.ci.addTargetData(e,t).next(()=>t))))}).then(e=>{let t=i.Cs.get(e.targetId);return(null===t||e.snapshotVersion.compareTo(t.snapshotVersion)>0)&&(i.Cs=i.Cs.insert(e.targetId,e),i.vs.set(s,e.targetId)),e})),l=o.targetId,u=e.sharedClientState.addLocalQueryTarget(l,r);return n&&(a=await iH(e,t,l,"current"===u,o.resumeToken)),e.isPrimaryClient&&r&&n9(e.remoteStore,o),a}async function iH(e,t,r,n,i){e.Su=(t,r,n)=>(async function(e,t,r,n){let i=t.view.ou(r);i.Ss&&(i=await nV(e.localStore,t.query,!1).then(({documents:e})=>t.view.ou(e,i)));let s=n&&n.targetChanges.get(t.targetId),a=n&&null!=n.targetMismatches.get(t.targetId),o=t.view.applyChanges(i,e.isPrimaryClient,s,a);return i8(e,t.targetId,o.lu),o.snapshot})(e,t,r,n);let s=await nV(e.localStore,t,!0),a=new iq(t,s.Ls),o=a.ou(s.documents),l=rN.createSynthesizedTargetChangeForCurrentChange(r,n&&"Offline"!==e.onlineState,i),u=a.applyChanges(o,e.isPrimaryClient,l);i8(e,r,u.lu);let c=new iB(t,r,a);return e.Ru.set(t,c),e.Au.has(r)?e.Au.get(r).push(t):e.Au.set(r,[t]),u.snapshot}async function iW(e,t,r){let n=e.Ru.get(t),i=e.Au.get(n.targetId);if(i.length>1)return e.Au.set(n.targetId,i.filter(e=>!tR(e,t))),void e.Ru.delete(t);e.isPrimaryClient?(e.sharedClientState.removeLocalQueryTarget(n.targetId),e.sharedClientState.isActiveQueryTarget(n.targetId)||await nx(e.localStore,n.targetId,!1).then(()=>{e.sharedClientState.clearQueryState(n.targetId),r&&n7(e.remoteStore,n.targetId),i6(e,n.targetId)}).catch(eo)):(i6(e,n.targetId),await nx(e.localStore,n.targetId,!0))}async function iJ(e,t){let r=e.Ru.get(t),n=e.Au.get(r.targetId);
7e.isPrimaryClient&&1===n.length&&(e.sharedClientState.removeLocalQueryTarget(r.targetId),n7(e.remoteStore,r.targetId))}async function iX(e,t,r){var n,i;let s=((n=e).remoteStore.remoteSyncer.applySuccessfulWrite=i1.bind(null,n),n.remoteStore.remoteSyncer.rejectFailedWrite=i2.bind(null,n),n);try{let e,n=await function(e,t){let r,n,i=er.now(),s=t.reduce((e,t)=>e.add(t.key),tG());return e.persistence.runTransaction("Locally write mutations","readwrite",a=>{let o=tU,l=tG();return e.Ms.getEntries(a,s).next(e=>{(o=e).forEach((e,t)=>{t.isValidDocument()||(l=l.add(e))})}).next(()=>e.localDocuments.getOverlayedDocuments(a,o)).next(n=>{r=n;let s=[];for(let e of t){let t=function(e,t){let r=null;for(let n of e.fieldTransforms){let e=t.data.field(n.field),i=tY(n.transform,e||null);null!=i&&(null===r&&(r=e8.empty()),r.set(n.field,i))}return r||null}(e,r.get(e.key).overlayedDocument);null!=t&&s.push(new rc(e.key,t,function e(t){let r=[];return ef(t.fields,(t,n)=>{let i=new j([t]);if(e3(n)){let t=e(n.mapValue).fields;if(0===t.length)r.push(i);else for(let e of t)r.push(i.child(e))}else r.push(i)}),new eT(r)}(t.value.mapValue),rn.exists(!0)))}return e.mutationQueue.addMutationBatch(a,i,s,t)}).next(t=>{n=t;let i=t.applyToLocalDocumentSet(r,l);return e.documentOverlayCache.saveOverlays(a,t.batchId,i)})}).then(()=>({batchId:n.batchId,changes:tB(r)}))}(s.localStore,t);s.sharedClientState.addPendingMutation(n.batchId),i=n.batchId,(e=s.gu[s.currentUser.toKey()])||(e=new ep(M)),e=e.insert(i,r),s.gu[s.currentUser.toKey()]=e,await i7(s,n.changes),await id(s.remoteStore)}catch(t){let e=iI(t,"Failed to persist write");r.reject(e)}}async function iY(e,t){try{let r=await function(e,t){let r=t.snapshotVersion,n=e.Cs;return e.persistence.runTransaction("Apply remote event","readwrite-primary",i=>{var s,a,o;let l,u,c=e.Ms.newChangeBuffer({trackRemovals:!0});n=e.Cs;let h=[];
7t.targetChanges.forEach((s,a)=>{var o;let l=n.get(a);if(!l)return;h.push(e.ci.removeMatchingKeys(i,s.removedDocuments,a).next(()=>e.ci.addMatchingKeys(i,s.addedDocuments,a)));let u=l.withSequenceNumber(i.currentSequenceNumber);null!==t.targetMismatches.get(a)?u=u.withResumeToken(eS.EMPTY_BYTE_STRING,en.min()).withLastLimboFreeSnapshotVersion(en.min()):s.resumeToken.approximateByteSize()>0&&(u=u.withResumeToken(s.resumeToken,r)),n=n.insert(a,u),o=u,(0===l.resumeToken.approximateByteSize()||o.snapshotVersion.toMicroseconds()-l.snapshotVersion.toMicroseconds()>=3e8||s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size>0)&&h.push(e.ci.updateTargetData(i,u))});let d=tU,f=tG();if(t.documentUpdates.forEach(r=>{t.resolvedLimboDocuments.has(r)&&h.push(e.persistence.referenceDelegate.updateLimboDocument(i,r))}),h.push((s=i,a=c,o=t.documentUpdates,l=tG(),u=tG(),o.forEach(e=>l=l.add(e)),a.getEntries(s,l).next(e=>{let t=tU;return o.forEach((r,n)=>{let i=e.get(r);n.isFoundDocument()!==i.isFoundDocument()&&(u=u.add(r)),n.isNoDocument()&&n.version.isEqual(en.min())?(a.removeEntry(r,n.readTime),t=t.insert(r,n)):!i.isValidDocument()||n.version.compareTo(i.version)>0||0===n.version.compareTo(i.version)&&i.hasPendingWrites?(a.addEntry(n),t=t.insert(r,n)):v(nA,"Ignoring outdated watch update for ",r,". Current version:",i.version," Watch version:",n.version)}),{Ns:t,Bs:u}})).next(e=>{d=e.Ns,f=e.Bs})),!r.isEqual(en.min())){let t=e.ci.getLastRemoteSnapshotVersion(i).next(t=>e.ci.setTargetsMetadata(i,i.currentSequenceNumber,r));h.push(t)}return el.waitFor(h).next(()=>c.apply(i)).next(()=>e.localDocuments.getLocalViewOfDocuments(i,d,f)).next(()=>d)}).then(t=>(e.Cs=n,t))}(e.localStore,t);
7t.targetChanges.forEach((t,r)=>{let n=e.mu.get(r);n&&(C(t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size<=1,22616),t.addedDocuments.size>0?n.Iu=!0:t.modifiedDocuments.size>0?C(n.Iu,14607):t.removedDocuments.size>0&&(C(n.Iu,42227),n.Iu=!1))}),await i7(e,r,t)}catch(e){await eo(e)}}function iZ(e,t,r){var n;if(e.isPrimaryClient&&0===r||!e.isPrimaryClient&&1===r){let r,i=[];e.Ru.forEach((e,r)=>{let n=r.view.xa(t);n.snapshot&&i.push(n.snapshot)}),(n=e.eventManager).onlineState=t,r=!1,n.queries.forEach((e,n)=>{for(let e of n.Ca)e.xa(t)&&(r=!0)}),r&&iF(n),i.length&&e.Eu.J_(i),e.onlineState=t,e.isPrimaryClient&&e.sharedClientState.setOnlineState(t)}}async function i0(e,t,r){e.sharedClientState.updateQueryState(t,"rejected",r);let n=e.mu.get(t),i=n&&n.key;if(i){let r=new ep(G.comparator);r=r.insert(i,e9.newNoDocument(i,en.min()));let n=tG().add(i),s=new rA(en.min(),new Map,new ep(M),r,n);await iY(e,s),e.du=e.du.remove(i),e.mu.delete(t),i9(e)}else await nx(e.localStore,t,!1).then(()=>i6(e,t,r)).catch(eo)}async function i1(e,t){var r;let n=t.batch.batchId;try{let i=await (r=e.localStore,r.persistence.runTransaction("Acknowledge batch","readwrite-primary",e=>{let n=t.batch.keys(),i=r.Ms.newChangeBuffer({trackRemovals:!0});return(function(e,t,r,n){let i=r.batch,s=i.keys(),a=el.resolve();return s.forEach(e=>{a=a.next(()=>n.getEntry(t,e)).next(t=>{let s=r.docVersions.get(e);C(null!==s,48541),0>t.version.compareTo(s)&&(i.applyToRemoteDocument(t,r),t.isValidDocument()&&(t.setReadTime(r.commitVersion),n.addEntry(t)))})}),a.next(()=>e.mutationQueue.removeMutationBatch(t,i))})(r,e,t,i).next(()=>i.apply(e)).next(()=>r.mutationQueue.performConsistencyCheck(e)).next(()=>r.documentOverlayCache.removeOverlaysForBatchId(e,n,t.batch.batchId)).next(()=>r.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,function(e){let t=tG();for(let r=0;r<e.mutationResults.length;++r)e.mutationResults[r].transformResults.length>0&&(t=t.add(e.batch.mutations[r].key));return t}(t))).next(()=>r.localDocuments.getDocuments(e,n))}));i4(e,n,null),i3(e,n),e.sharedClientState.updateMutationState(n,"acknowledged"),await i7(e,i)}catch(e){await eo(e)}}async function i2(e,t,r){var n;try{let i=await (n=e.localStore,n.persistence.runTransaction("Reject batch","readwrite-primary",e=>{let r;
7return n.mutationQueue.lookupMutationBatch(e,t).next(t=>(C(null!==t,37113),r=t.keys(),n.mutationQueue.removeMutationBatch(e,t))).next(()=>n.mutationQueue.performConsistencyCheck(e)).next(()=>n.documentOverlayCache.removeOverlaysForBatchId(e,r,t)).next(()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,r)).next(()=>n.localDocuments.getDocuments(e,r))}));i4(e,t,r),i3(e,t),e.sharedClientState.updateMutationState(t,"rejected",r),await i7(e,i)}catch(e){await eo(e)}}function i3(e,t){(e.pu.get(t)||[]).forEach(e=>{e.resolve()}),e.pu.delete(t)}function i4(e,t,r){let n=e.gu[e.currentUser.toKey()];if(n){let i=n.get(t);i&&(r?i.reject(r):i.resolve(),n=n.remove(t)),e.gu[e.currentUser.toKey()]=n}}function i6(e,t,r=null){for(let n of(e.sharedClientState.removeLocalQueryTarget(t),e.Au.get(t)))e.Ru.delete(n),r&&e.Eu.bu(n,r);e.Au.delete(t),e.isPrimaryClient&&e.fu.Qr(t).forEach(t=>{e.fu.containsKey(t)||i5(e,t)})}function i5(e,t){e.Vu.delete(t.path.canonicalString());let r=e.du.get(t);null!==r&&(n7(e.remoteStore,r),e.du=e.du.remove(t),e.mu.delete(r),i9(e))}function i8(e,t,r){for(let n of r)n instanceof iP?(e.fu.addReference(n.key,t),function(e,t){let r=t.key,n=r.path.canonicalString();e.du.get(r)||e.Vu.has(n)||(v(i$,"New document in limbo: "+r),e.Vu.add(n),i9(e))}(e,n)):n instanceof iU?(v(i$,"Document no longer in limbo: "+n.key),e.fu.removeReference(n.key,t),e.fu.containsKey(n.key)||i5(e,n.key)):_(19791,{Du:n})}function i9(e){for(;e.Vu.size>0&&e.du.size<e.maxConcurrentLimboResolutions;){let t=e.Vu.values().next().value;e.Vu.delete(t);let r=new G(z.fromString(t)),n=e.yu.next();e.mu.set(n,new iz(r)),e.du=e.du.insert(r,n),n9(e.remoteStore,new r6(tb(t_(r.path)),n,"TargetPurposeLimboResolution",ec.ce))}}async function i7(e,t,r){let n=[],i=[],s=[];e.Ru.isEmpty()||(e.Ru.forEach((a,o)=>{s.push(e.Su(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=nC.Is(o.targetId,t);i.push(e)}}))}),await Promise.all(s),e.Eu.J_(n),await async function(e,t){try{await e.persistence.runTransaction("notifyLocalViewChanges","readwrite",r=>el.forEach(t,t=>el.forEach(t.Ps,n=>e.persistence.referenceDelegate.addReference(r,t.targetId,n)).next(()=>el.forEach(t.Ts,n=>e.persistence.referenceDelegate.removeReference(r,t.targetId,n)))))}catch(e){if(!eu(e))throw e;v(nA,"Failed to update sequence numbers: "+e)}for(let r of t){let t=r.targetId;if(!r.fromCache){let r=e.Cs.get(t),n=r.snapshotVersion,i=r.withLastLimboFreeSnapshotVersion(n);e.Cs=e.Cs.insert(t,i)}}}(e.localStore,i))}async function se(e,t){if(!e.currentUser.isEqual(t)){v(i$,"User change. New user:",t.toKey());let r=await nk(e.localStore,t);e.currentUser=t,e.pu.forEach(e=>{e.forEach(e=>{e.reject(new b(I.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))})}),e.pu.clear(),e.sharedClientState.handleUserChange(t,r.removedBatchIds,r.addedBatchIds),await i7(e,r.Os)}}function st(e,t){let r=e.mu.get(t);if(r&&r.Iu)return tG().add(r.key);{let r=tG(),n=e.Au.get(t);if(!n)return r;for(let t of n){let n=e.Ru.get(t);r=r.unionWith(n.view.su)}return r}}function sr(e){return e.remoteStore.remoteSyncer.applyRemoteEvent=iY.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=st.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=i0.bind(null,e),e.Eu.J_=iL.bind(null,e.eventManager),e.Eu.bu=iO.bind(null,e.eventManager),e}class sn{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=nH(e.databaseInfo.databaseId),this.sharedClientState=this.Fu(e),this.persistence=this.Mu(e),await this.persistence.start(),this.localStore=this.xu(e),this.gcScheduler=this.Ou(e,this.localStore),this.indexBackfillerScheduler=this.Nu(e,this.localStore)}Ou(e,t){return null}Nu(e,t){return null}xu(e){var t,r;return t=this.persistence,r=new nb,new nN(t,r,e.initialUser,this.serializer)}Mu(e){return new nE(n_.Ai,this.serializer)}Fu(e){return new nL}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedCl
7ientState.shutdown(),await this.persistence.shutdown()}}sn.provider={build:()=>new sn};class si extends sn{constructor(e){super(),this.cacheSizeBytes=e}Ou(e,t){return C(this.persistence.referenceDelegate instanceof nS,46915),new na(this.persistence.referenceDelegate.garbageCollector,e.asyncQueue,t)}Mu(e){let t=void 0!==this.cacheSizeBytes?nt.withCacheSize(this.cacheSizeBytes):nt.DEFAULT;return new nE(e=>nS.Ai(e,t),this.serializer)}}class ss{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=>iZ(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=se.bind(null,this.syncEngine),await iT(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new iD}createDatastore(e){var t;let r=nH(e.databaseInfo.databaseId),n=new nG(e.databaseInfo);return t=e.authCredentials,new n1(t,e.appCheckCredentials,n,r)}createRemoteStore(e){var t,r;return t=this.localStore,r=this.datastore,new n4(t,r,e.asyncQueue,e=>iZ(this.syncEngine,e,0),nM.v()?new nM:new nO)}createSyncEngine(e,t){return function(e,t,r,n,i,s,a){let o=new iK(e,t,r,n,i,s);return a&&(o.wu=!0),o}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){await async function(e){v(n3,"RemoteStore shutting down."),e.Va.add(5),await n5(e),e.ma.shutdown(),e.fa.set("Unknown")}(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}}ss.provider={build:()=>new ss};class sa{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Lu(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Lu(this.observer.error,e):w("Uncaught Error in snapshot listener:",e.toString()))}ku(){this.muted=!0}Lu(e,t){setTimeout(()=>{this.muted||e(t)},0)}}let so="FirestoreClient";class sl{constructor(e,t,r,n,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=r,this._databaseInfo=n,this.user=f.UNAUTHENTICATED,this.clientId=F.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(r,async e=>{v(so,"Received user=",e.uid),await this.authCredentialListener(e),this.user=e}),this.appCheckCredentials.start(r,e=>(v(so,"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 A;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=iI(r,"Failed to shutdown persistence");e.reject(t)}}),e.promise}}async function su(e,t){e.asyncQueue.verifyOperationInProgress(),v(so,"Initializing OfflineComponentProvider");let r=e.configuration;await t.initialize(r);let n=r.initialUser;e.setCredentialChangeListener(async e=>{n.isEqual(e)||(await nk(t.localStore,e),n=e)}),t.persistence.setDatabaseDeletedListener(()=>e.terminate()),e._offlineComponents=t}async function sc(e,t){e.asyncQueue.verifyOperationInProgress();let r=await sh(e);v(so,"Initializing OnlineComponentProvider"),await t.initialize(r,e.configuration),e.setCredentialChangeListener(e=>iE(t.remoteStore,e)),e.setAppCheckTokenChangeListener((e,r)=>iE(t.remoteStore,r)),e._onlineComponents=t}async function sh(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){v(so,"Using user provided OfflineComponentProvider");try{await su(e,e._uninitializedComponentsProvider._offline)}catch(t){if(!("FirebaseError"===t.name?t.code===I.FAILED_PRECONDITION||t.code===I.UNIMPLEMENT
7ED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code))throw t;E("Error using user provided cache. Falling back to memory cache: "+t),await su(e,new sn)}}else v(so,"Using default OfflineComponentProvider"),await su(e,new si(void 0));return e._offlineComponents}async function sd(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(v(so,"Using user provided OnlineComponentProvider"),await sc(e,e._uninitializedComponentsProvider._online)):(v(so,"Using default OnlineComponentProvider"),await sc(e,new ss))),e._onlineComponents}async function sf(e){let t=await sd(e),r=t.eventManager;return r.onListen=ij.bind(null,t.syncEngine),r.onUnlisten=iW.bind(null,t.syncEngine),r.onFirstRemoteStoreListen=iG.bind(null,t.syncEngine),r.onLastRemoteStoreUnlisten=iJ.bind(null,t.syncEngine),r}function sm(e,t,r,n){let i=new sa(n),s=new iM(t,i,r);return e.asyncQueue.enqueueAndForget(async()=>iV(await sf(e),s)),()=>{i.ku(),e.asyncQueue.enqueueAndForget(async()=>iR(await sf(e),s))}}function sg(e,t,r={}){let n=new A;return e.asyncQueue.enqueueAndForget(async()=>(function(e,t,r,n,i){let s=new sa({next:o=>{s.ku(),t.enqueueAndForget(()=>iR(e,a));let l=o.docs.has(r);!l&&o.fromCache?i.reject(new b(I.UNAVAILABLE,"Failed to get document because the client is offline.")):l&&o.fromCache&&n&&"server"===n.source?i.reject(new b(I.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):i.resolve(o)},error:e=>i.reject(e)}),a=new iM(t_(r.path),s,{includeMetadataChanges:!0,$a:!0});return iV(e,a)})(await sf(e),e.asyncQueue,t,r,n)),n.promise}function sp(e,t,r={}){let n=new A;return e.asyncQueue.enqueueAndForget(async()=>(function(e,t,r,n,i){let s=new sa({next:r=>{s.ku(),t.enqueueAndForget(()=>iR(e,a)),r.fromCache&&"server"===n.source?i.reject(new b(I.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):i.resolve(r)},error:e=>i.reject(e)}),a=new iM(r,s,{includeMetadataChanges:!0,$a:!0});return iV(e,a)})(await sf(e),e.asyncQueue,t,r,n)),n.promise}function sy(e,t,r){let n=new A;return e.asyncQueue.enqueueAndForget(async()=>{try{let i=await sd(e).then(e=>e.datastore);n.resolve(async function(e,t,r){let{request:n,ft:i,parent:s}=function(e,t,r,n){let{dt:i,parent:s}=r0(e,t),a={},o=[],l=0;return r.forEach(e=>{let t="aggregate_"+l++;a[t]=e.alias,"count"===e.aggregateType?o.push({alias:t,count:{}}):"avg"===e.aggregateType?o.push({alias:t,avg:{field:r1(e.fieldPath)}}):"sum"===e.aggregateType&&o.push({alias:t,sum:{field:r1(e.fieldPath)}})}),{request:{structuredAggregationQuery:{aggregations:o,structuredQuery:i.structuredQuery},parent:i.parent},ft:a,parent:s}}(e.serializer,(t.Re||(t.Re=tA(t,t.explicitOrderBy)),t.Re),r);e.connection.ko||delete n.parent;let a=(await e.zo("RunAggregationQuery",e.serializer.databaseId,s,n,1)).filter(e=>!!e.result);C(1===a.length,64727);let o=a[0].result?.aggregateFields;return Object.keys(o).reduce((e,t)=>(e[i[t]]=o[t],e),{})}(i,t,r))}catch(e){n.reject(e)}}),n.promise}function sv(e,t){let r=new A;return e.asyncQueue.enqueueAndForget(async()=>iX(await sd(e).then(e=>e.syncEngine),t,r)),r.promise}function sw(e){let t={};return void 0!==e.timeoutSeconds&&(t.timeoutSeconds=e.timeoutSeconds),t}let sE=new Map,sT="firestore.googleapis.com";class s_{constructor(e){if(void 0===e.host){if(void 0!==e.ssl)throw new b(I.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=sT,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,void 0===e.cacheSizeBytes)this.cacheSizeBytes=0x2800000;else{if(-1!==e.cacheSizeBytes&&e.cacheSizeBytes<1048576)throw new b(I.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}(function(e,t,r,n){if(!0===t&&!0===n)throw new b(I.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=sw(e.experimentalLongPollingOptions??{}),function(e){if(void 0!==e.timeoutSeconds){if(isNaN(e.timeoutSeconds))throw new b(I.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new b(I.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new b(I.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}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}}class sS{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 s_({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new b(I.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 b(I.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 s_(e),this._emulatorOptions=e.emulatorOptions||{},void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new k;switch(e.type){case"firstParty":return new R(e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new b(I.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invali
7d 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(){return function(e){let t=sE.get(e);t&&(v("ComponentProvider","Removing Datastore"),sE.delete(e),t.terminate())}(this),Promise.resolve()}}class sC{constructor(e,t,r){this.converter=t,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new sC(this.firestore,e,this._query)}}class sI{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 sb(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new sI(this.firestore,e,this._key)}toJSON(){return{type:sI._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,r){if(et(t,sI._jsonSchema))return new sI(e,r||null,new G(z.fromString(t.referencePath)))}}sI._jsonSchemaVersion="firestore/documentReference/1.0",sI._jsonSchema={type:ee("string",sI._jsonSchemaVersion),referencePath:ee("string")};class sb extends sC{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 sI(this.firestore,null,new G(e))}withConverter(e){return new sb(this.firestore,e,this._path)}}function sA(e,t,...r){if(e=(0,l.Ku)(e),Q("collection","path",t),e instanceof sS){let n=z.fromString(t,...r);return W(n),new sb(e,null,n)}{if(!(e instanceof sI||e instanceof sb))throw new b(I.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let n=e._path.child(z.fromString(t,...r));return W(n),new sb(e.firestore,null,n)}}function sN(e,t,...r){if(e=(0,l.Ku)(e),1==arguments.length&&(t=F.newId()),Q("doc","path",t),e instanceof sS){let n=z.fromString(t,...r);return H(n),new sI(e,null,new G(n))}{if(!(e instanceof sI||e instanceof sb))throw new b(I.INVALID_ARGUMENT,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let n=e._path.child(z.fromString(t,...r));return H(n),new sI(e.firestore,e instanceof sb?e.converter:null,new G(n))}}let sk="AsyncQueue";class sD{constructor(e=Promise.resolve()){this.nc=[],this.rc=!1,this.sc=[],this.oc=null,this._c=!1,this.ac=!1,this.uc=[],this.F_=new nW(this,"async_queue_retry"),this.cc=()=>{let e=nQ();e&&v(sk,"Visibility state changed to "+e.visibilityState),this.F_.y_()},this.lc=e;let t=nQ();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this.cc)}get isShuttingDown(){return this.rc}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.hc(),this.Pc(e)}enterRestrictedMode(e){if(!this.rc){this.rc=!0,this.ac=e||!1;let t=nQ();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.cc)}}enqueue(e){if(this.hc(),this.rc)return new Promise(()=>{});let t=new A;return this.Pc(()=>this.rc&&this.ac?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.nc.push(e),this.Tc()))}async Tc(){if(0!==this.nc.length){try{await this.nc[0](),this.nc.shift(),this.F_.reset()}catch(e){if(!eu(e))throw e;v(sk,"Operation failed with retryable error: "+e)}this.nc.length>0&&this.F_.g_(()=>this.Tc())}}Pc(e){let t=this.lc.then(()=>(this._c=!0,e().catch(e=>{throw this.oc=e,this._c=!1,w("INTERNAL UNHANDLED ERROR: ",sx(e)),e}).then(e=>(this._c=!1,e))));return this.lc=t,t}enqueueAfterDelay(e,t,r){this.hc(),this.uc.indexOf(e)>-1&&(t=0);let n=iC.createAndSchedule(this,e,t,r,e=>this.Ic(e));return this.sc.push(n),n}hc(){this.oc&&_(47125,{Ec:sx(this.oc)})}verifyOperationInProgress(){}async Rc(){let e;do e=this.lc,await e;while(e!==this.lc)}Ac(e){for(let t of this.sc)if(t.timerId===e)return!0;return!1}Vc(e){return this.Rc().then(()=>{for(let t of(this.sc.sort((e,t)=>
7e.targetTimeMs-t.targetTimeMs),this.sc))if(t.skipDelay(),"all"!==e&&t.timerId===e)break;return this.Rc()})}dc(e){this.uc.push(e)}Ic(e){let t=this.sc.indexOf(e);this.sc.splice(t,1)}}function sx(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t}class sV extends sS{constructor(e,t,r,n){super(e,t,r,n),this.type="firestore",this._queue=new sD,this._persistenceKey=n?.name||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new sD(e),this._firestoreClient=void 0,await e}}}function sR(e,t){let r="object"==typeof e?e:(0,o.Sx)(),n=(0,o.j6)(r,"firestore").getImmediate({identifier:"string"==typeof e?e:t||eF});if(!n._initialized){let e=(0,l.yU)("firestore");e&&function(e,t,r,n={}){e=Y(e,sS);let i=(0,l.zJ)(t),s=e._getSettings(),a={...s,emulatorOptions:e._getEmulatorOptions()},o=`${t}:${r}`;i&&(0,l.gE)(`https://${o}`),s.host!==sT&&s.host!==o&&E("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");let u={...s,host:o,ssl:i,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=f.MOCK_USER;else{t=(0,l.Fy)(n.mockUserToken,e._app?.options.projectId);let i=n.mockUserToken.sub||n.mockUserToken.user_id;if(!i)throw new b(I.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");r=new f(i)}e._authCredentials=new D(new N(t,r))}}(n,...e)}return n}function sL(e){if(e._terminated)throw new b(I.FAILED_PRECONDITION,"The client has already been terminated.");return e._firestoreClient||function(e){var t,r,n,i;let s=e._freezeSettings(),a=(t=e._databaseId,r=e._app?.options.appId||"",n=e._persistenceKey,i=e._app?.options.apiKey,new eO(t,r,n,s.host,s.ssl,s.experimentalForceLongPolling,s.experimentalAutoDetectLongPolling,sw(s.experimentalLongPollingOptions),s.useFetchStreams,s.isUsingEmulator,i));e._componentsProvider||s.localCache?._offlineComponentProvider&&s.localCache?._onlineComponentProvider&&(e._componentsProvider={_offline:s.localCache._offlineComponentProvider,_online:s.localCache._onlineComponentProvider}),e._firestoreClient=new sl(e._authCredentials,e._appCheckCredentials,e._queue,a,e._componentsProvider&&function(e){let t=e?._online.build();return{_offline:e?._offline.build(t),_online:t}}(e._componentsProvider))}(e),e._firestoreClient}class sO{constructor(e){this._byteString=e}static fromBase64String(e){try{return new sO(eS.fromBase64String(e))}catch(e){throw new b(I.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new sO(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:sO._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(et(e,sO._jsonSchema))return sO.fromBase64String(e.bytes)}}sO._jsonSchemaVersion="firestore/bytes/1.0",sO._jsonSchema={type:ee("string",sO._jsonSchemaVersion),bytes:ee("string")};class sF{constructor(...e){for(let t=0;t<e.length;++t)if(0===e[t].length)throw new b(I.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new j(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}class sM{constructor(e){this._methodName=e}}class sP{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new b(I.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new b(I.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 M(this._lat,e._lat)||M(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:sP._jsonSchemaVersion}}static fromJSON(e){if(et(e,sP._jsonSchema))return new sP(e.latitude,e.longitude)}}sP._jsonSchemaVersion="firestore/geoPoint/1.0",sP._jsonSchema={type:ee("string",sP._jsonSchemaVersion),latitude:ee("number"),longitude:ee("number")};class sU{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:sU._jsonSchemaVersion,vectorValues:this._values}}
7static fromJSON(e){if(et(e,sU._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every(e=>"number"==typeof e))return new sU(e.vectorValues);throw new b(I.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}sU._jsonSchemaVersion="firestore/vectorValue/1.0",sU._jsonSchema={type:ee("string",sU._jsonSchemaVersion),vectorValues:ee("object")};let sq=/^__.*__$/;class s${constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return null!==this.fieldMask?new rc(e,this.data,this.fieldMask,t,this.fieldTransforms):new ru(e,this.data,t,this.fieldTransforms)}}class sB{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return new rc(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function sz(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw _(40011,{dataSource:e})}}class sK{constructor(e,t,r,n,i,s){this.settings=e,this.databaseId=t,this.serializer=r,this.ignoreUndefinedProperties=n,void 0===i&&this.mc(),this.fieldTransforms=i||[],this.fieldMask=s||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}i(e){return new sK({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}gc(e){let t=this.path?.child(e),r=this.i({path:t,arrayElement:!1});return r.yc(e),r}wc(e){let t=this.path?.child(e),r=this.i({path:t,arrayElement:!1});return r.mc(),r}Sc(e){return this.i({path:void 0,arrayElement:!0})}bc(e){return s5(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))}mc(){if(this.path)for(let e=0;e<this.path.length;e++)this.yc(this.path.get(e))}yc(e){if(0===e.length)throw this.bc("Document fields must not be empty");if(sz(this.dataSource)&&sq.test(e))throw this.bc('Document fields cannot begin and end with "__"')}}class sj{constructor(e,t,r){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=r||nH(e)}V(e,t,r,n=!1){return new sK({dataSource:e,methodName:t,targetDoc:r,path:j.emptyPath(),arrayElement:!1,hasConverter:n},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function sG(e){let t=e._freezeSettings(),r=nH(e._databaseId);return new sj(e._databaseId,!!t.ignoreUndefinedProperties,r)}function sQ(e,t,r,n,i,s={}){let a,o,l=e.V(s.merge||s.mergeFields?2:0,t,r,i);s2("Data must be an object, but it was:",l,n);let u=s0(n,l);if(s.merge)a=new eT(l.fieldMask),o=l.fieldTransforms;else if(s.mergeFields){let e=[];for(let n of s.mergeFields){let i=s3(t,n,r);if(!l.contains(i))throw new b(I.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);s8(e,i)||e.push(i)}a=new eT(e),o=l.fieldTransforms.filter(e=>a.covers(e.field))}else a=null,o=l.fieldTransforms;return new s$(new e8(u),a,o)}class sH extends sM{_toFieldTransform(e){if(2!==e.dataSource)throw 1===e.dataSource?e.bc(`${this._methodName}() can only appear at the top level of your update data`):e.bc(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof sH}}class sW extends sM{constructor(e,t){super(e),this.vc=t}_toFieldTransform(e){let t=new t6(e.serializer,tJ(e.serializer,this.vc));return new rt(e.path,t)}isEqual(e){return e instanceof sW&&(this.vc===e.vc||Number.isNaN(this.vc)&&Number.isNaN(e.vc))}}function sJ(e,t,r,n){let i=e.V(1,t,r);s2("Data must be an object, but it was:",i,n);let s=[],a=e8.empty();return ef(n,(e,n)=>{let o=s6(t,e,r);n=(0,l.Ku)(n);let u=i.wc(o);if(n instanceof sH)s.push(o);else{let e=sZ(n,u);null!=e&&(s.push(o),a.set(o,e))}}),new sB(a,new eT(s),i.fieldTransforms)}function sX(e,t,r,n,i,s){let a=e.V(1,t,r),o=[s3(t,n,r)],u=[i];if(s.length%2!=0)throw new b(I.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<s.length;e+=2)o.push(s3(t,s[e])),u.push(s[e+1]);let c=[],h=e8.empty();for(let e=o.length-1;e>=0;
7--e)if(!s8(c,o[e])){let t=o[e],r=u[e];r=(0,l.Ku)(r);let n=a.wc(t);if(r instanceof sH)c.push(t);else{let e=sZ(r,n);null!=e&&(c.push(t),h.set(t,e))}}return new sB(h,new eT(c),a.fieldTransforms)}function sY(e,t,r,n=!1){return sZ(r,e.V(n?4:3,t))}function sZ(e,t){if(s1(e=(0,l.Ku)(e)))return s2("Unsupported field value:",t,e),s0(e,t);if(e instanceof sM)return function(e,t){if(!sz(t.dataSource))throw t.bc(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.bc(`${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.bc("Nested arrays are not supported");let r=[],n=0;for(let i of e){let e=sZ(i,t.Sc(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 tJ(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:rB(t.serializer,r)}}if(e instanceof er){let r=new er(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:rB(t.serializer,r)}}if(e instanceof sP)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof sO)return{bytesValue:rz(t.serializer,e._byteString)};if(e instanceof sI){let r=t.databaseId,n=e.firestore._databaseId;if(!n.isEqual(r))throw t.bc(`Document reference is for database ${n.projectId}/${n.database} but should be for database ${r.projectId}/${r.database}`);return{referenceValue:rj(e.firestore._databaseId||t.databaseId,e._key.path)}}if(e instanceof sU){var r;return{mapValue:{fields:{[eU]:{stringValue:eB},[ez]:{arrayValue:{values:((r=e)instanceof sU?r.toArray():r).map(e=>{if("number"!=typeof e)throw t.bc("VectorValues must only contain numeric values.");return tH(t.serializer,e)})}}}}}}if(r4(e))return e._toProto(t.serializer);throw t.bc(`Unsupported field value: ${X(e)}`)}(e,t)}function s0(e,t){let r={};return eg(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):ef(e,(e,n)=>{let i=sZ(n,t.gc(e));null!=i&&(r[e]=i)}),{mapValue:{fields:r}}}function s1(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof er||e instanceof sP||e instanceof sO||e instanceof sI||e instanceof sM||e instanceof sU||r4(e))}function s2(e,t,r){if(!s1(r)||!J(r)){let n=X(r);throw"an object"===n?t.bc(e+" a custom object"):t.bc(e+" "+n)}}function s3(e,t,r){if((t=(0,l.Ku)(t))instanceof sF)return t._internalPath;if("string"==typeof t)return s6(e,t);throw s5("Field path arguments must be of type string or ",e,!1,void 0,r)}let s4=RegExp("[~\\*/\\[\\]]");function s6(e,t,r){if(t.search(s4)>=0)throw s5(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,r);try{return new sF(...t.split("."))._internalPath}catch(n){throw s5(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,r)}}function s5(e,t,r,n,i){let s=n&&!n.isEmpty(),a=void 0!==i,o=`Function ${t}() called with invalid data`;r&&(o+=" (via `toFirestore()`)"),o+=". ";let l="";return(s||a)&&(l+=" (found",s&&(l+=` in field ${n}`),a&&(l+=` in document ${i}`),l+=")"),new b(I.INVALID_ARGUMENT,o+e+l)}function s8(e,t){return e.some(e=>e.isEqual(t))}class s9{convertValue(e,t="none"){switch(eK(e)){case 0:return null;case 1:return e.booleanValue;case 2:return eb(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(eA(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 _(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){let r={};return ef(e,(e,n)=>{r[e]=this.convertValue(n,t)}),r}
7convertVectorValue(e){return new sU(e.fields?.[ez].arrayValue?.values?.map(e=>eb(e.doubleValue)))}convertGeoPoint(e){return new sP(eb(e.latitude),eb(e.longitude))}convertArray(e,t){return(e.values||[]).map(e=>this.convertValue(e,t))}convertServerTimestamp(e,t){switch(t){case"previous":let r=eR(e);return null==r?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(eL(e));default:return null}}convertTimestamp(e){let t=eI(e);return new er(t.seconds,t.nanos)}convertDocumentKey(e,t){let r=z.fromString(e);C(r3(r),9688,{name:e});let n=new eM(r.get(1),r.get(3)),i=new G(r.popFirst(5));return n.isEqual(t)||w(`Document ${i} contains a document reference within 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.`),i}}class s7 extends s9{constructor(e){super(),this.firestore=e}convertBytes(e){return new sO(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new sI(this.firestore,null,t)}}function ae(e){return new sW("increment",e)}}}]);

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.