import{g as Ei,i as Sh,a as Dh,b as Nh,c as Ah,d as Ch,e as kh,h as X,L as Ue,j as xh,C as Rh,f as Oh}from"./index.esm-J35DBGFx.js";import{_ as C,f as $,d as g,e as m}from"./index-2K3MavtT.js";/*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var Ti=function(e,t){return Ti=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])},Ti(e,t)};function Ph(e,t){Ti(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Ou(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}var Lh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},S,Ji=Ji||{},R=Lh||self;function lr(){}function _i(e){var t=typeof e;return t=t!="object"?t:e?Array.isArray(e)?"array":t:"null",t=="array"||t=="object"&&typeof e.length=="number"}function Ln(e){var t=typeof e;return t=="object"&&e!=null||t=="function"}function Mh(e){return Object.prototype.hasOwnProperty.call(e,ci)&&e[ci]||(e[ci]=++Fh)}var ci="closure_uid_"+(1e9*Math.random()>>>0),Fh=0;function Vh(e,t,n){return e.call.apply(e.bind,arguments)}function Uh(e,t,n){if(!e)throw Error();if(2t?null:typeof e=="string"?e.charAt(t):e[t]}function fs(e){return Array.prototype.concat.apply([],arguments)}function Zi(e){var t=e.length;if(0t?1:0}var pt;t:{var ds=R.navigator;if(ds){var ys=ds.userAgent;if(ys){pt=ys;break t}}pt=""}function to(e,t,n){for(var r in e)t.call(n,e[r],r,e)}function Mu(e){var t={};for(var n in e)t[n]=e[n];return t}var vs="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function Fu(e,t){for(var n,r,i=1;iparseFloat(li)){pr=String(pi);break t}}pr=li}var zh={};function Bu(e){return jh(e,function(){for(var t=0,n=ps(String(pr)).split("."),r=ps(String(e)).split("."),i=Math.max(n.length,r.length),o=0;t==0&&o=e.keyCode)&&(e.keyCode=-1)}catch{}};var Mn="closure_listenable_"+(1e6*Math.random()|0),Wh=0;function Xh(e,t,n,r,i){this.listener=e,this.proxy=null,this.src=t,this.type=n,this.capture=!!r,this.ca=i,this.key=++Wh,this.Y=this.Z=!1}function Mr(e){e.Y=!0,e.listener=null,e.proxy=null,e.src=null,e.ca=null}function Fr(e){this.src=e,this.a={},this.b=0}Fr.prototype.add=function(e,t,n,r,i){var o=e.toString();e=this.a[o],e||(e=this.a[o]=[],this.b++);var s=Ai(e,t,r,i);return-1>>0);function uo(e){return typeof e=="function"?e:(e[yi]||(e[yi]=function(t){return e.handleEvent(t)}),e[yi])}function At(){ue.call(this),this.c=new Fr(this),this.J=this,this.C=null}vt(At,ue);At.prototype[Mn]=!0;S=At.prototype;S.addEventListener=function(e,t,n,r){io(this,e,t,n,r)};S.removeEventListener=function(e,t,n,r){zu(this,e,t,n,r)};function rt(e,t){var n,r=e.C;if(r)for(n=[];r;r=r.C)n.push(r);if(e=e.J,r=t.type||t,typeof t=="string")t=new at(t,e);else if(t instanceof at)t.target=t.target||e;else{var i=t;t=new at(r,e),Fu(t,i)}if(i=!0,n)for(var o=n.length-1;0<=o;o--){var s=t.a=n[o];i=Zn(s,r,!0,t)&&i}if(s=t.a=e,i=Zn(s,r,!0,t)&&i,i=Zn(s,r,!1,t)&&i,n)for(o=0;ot.b&&(t.b++,e.next=t.a,t.a=e)}ki=!1}function Vr(e,t){At.call(this),this.b=e||1,this.a=t||R,this.f=ut(this.Za,this),this.g=qt()}vt(Vr,At);S=Vr.prototype;S.aa=!1;S.M=null;S.Za=function(){if(this.aa){var e=qt()-this.g;0r.length)){var i=r[1];if(Array.isArray(i)&&!(1>i.length)){var o=i[0];if(o!="noop"&&o!="stop"&&o!="close")for(var s=1;st||t==3&&!Si&&!this.a.$())){this.A||t!=4||n==7||(n==8||0>=r?In(3):In(2)),Br(this);var i=this.a.W();this.N=i;var o=this.a.$();if(this.b=i==200,ol(this.c,this.m,this.l,this.f,this.S,t,i),this.b){if(this.U&&!this.C){e:{if(this.a){var s,u=this.a;if((s=u.a?u.a.getResponseHeader("X-HTTP-Initial-Response"):null)&&!fr(s)){var a=s;break e}}a=null}if(a)Le(this.c,this.f,a,"Initial handshake response via X-HTTP-Initial-Response"),this.C=!0,Oi(this,a);else{this.b=!1,this.h=3,dt(12),Fe(this),dr(this);break t}}this.I?(ha(this,t,o),Si&&this.b&&t==3&&(Ju(this.J,this.R,"tick",this.Wa),this.R.start())):(Le(this.c,this.f,o,null),Oi(this,o)),t==4&&Fe(this),this.b&&!this.A&&(t==4?Ca(this.g,this):(this.b=!1,qn(this)))}else i==400&&0t.length?xi:(t=t.substr(r,n),e.D=r+n,t)))}S.cancel=function(){this.A=!0,Fe(this)};function qn(e){e.T=qt()+e.P,la(e,e.P)}function la(e,t){if(e.o!=null)throw Error("WatchDog timer not null");e.o=Fn(ut(e.Va,e),t)}function Br(e){e.o&&(R.clearTimeout(e.o),e.o=null)}S.Va=function(){this.o=null;var e=qt();0<=e-this.T?(sl(this.c,this.l),this.H!=2&&(In(),dt(17)),Fe(this),this.h=2,dr(this)):la(this,this.T-e)};function dr(e){e.g.v==0||e.A||Ca(e.g,e)}function Fe(e){Br(e);var t=e.F;t&&typeof t.ja=="function"&&t.ja(),e.F=null,ho(e.R),Zu(e.J),e.a&&(t=e.a,e.a=null,t.abort(),t.ja())}function Oi(e,t){try{var n=e.g;if(n.v!=0&&(n.a==e||Pi(n.b,e))){if(n.I=e.N,!e.C&&Pi(n.b,e)&&n.v==3){try{var r=n.ka.a.parse(t)}catch{r=null}if(Array.isArray(r)&&r.length==3){var i=r;if(i[0]==0){t:if(!n.j){if(n.a)if(n.a.u+3e3i[2]&&n.H&&n.o==0&&!n.m&&(n.m=Fn(ut(n.Sa,n),6e3));if(1>=ga(n.b)&&n.ea){try{n.ea()}catch{}n.ea=void 0}}else pe(n,11)}else if((e.C||n.a==e)&&gr(n),!fr(t))for(t=r=n.ka.a.parse(t),r=0;rt)throw Error("Bad port number "+t);e.h=t}else e.h=null}function Es(e,t,n){t instanceof En?(e.b=t,wl(e.b,e.a)):(n||(t=dn(t,ml)),e.b=new En(t,e.a))}function K(e,t,n){e.b.set(t,n)}function jr(e){return K(e,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^qt()).toString(36)),e}function fl(e){return e instanceof be?zt(e):new be(e,void 0)}function pl(e,t,n,r){var i=new be(null,void 0);return e&&yr(i,e),t&&vr(i,t),n&&mr(i,n),r&&(i.g=r),i}function vn(e,t){return e?t?decodeURI(e.replace(/%25/g,"%2525")):decodeURIComponent(e):""}function dn(e,t,n){return typeof e=="string"?(e=encodeURI(e).replace(t,dl),n&&(e=e.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),e):null}function dl(e){return e=e.charCodeAt(0),"%"+(e>>4&15).toString(16)+(e&15).toString(16)}var Ts=/[#\/\?@]/g,yl=/[#\?:]/g,vl=/[#\?]/g,ml=/[#\?@]/g,gl=/#/g;function En(e,t){this.b=this.a=null,this.c=e||null,this.f=!!t}function ae(e){e.a||(e.a=new nn,e.b=0,e.c&&ll(e.c,function(t,n){e.add(decodeURIComponent(t.replace(/\+/g," ")),n)}))}S=En.prototype;S.add=function(e,t){ae(this),this.c=null,e=rn(this,e);var n=this.a.get(e);return n||this.a.set(e,n=[]),n.push(t),this.b+=1,this};function pa(e,t){ae(e),t=rn(e,t),we(e.a.b,t)&&(e.c=null,e.b-=e.a.get(t).length,e=e.a,we(e.b,t)&&(delete e.b[t],e.c--,e.a.length>2*e.c&&mo(e)))}function da(e,t){return ae(e),t=rn(e,t),we(e.a.b,t)}S.forEach=function(e,t){ae(this),this.a.forEach(function(n,r){Lu(n,function(i){e.call(t,i,r,this)},this)},this)};S.L=function(){ae(this);for(var e=this.a.K(),t=this.a.L(),n=[],r=0;r=e.f:!1}function ga(e){return e.b?1:e.a?e.a.size:0}function Pi(e,t){return e.b?e.b==t:e.a?e.a.has(t):!1}function go(e,t){e.a?e.a.add(t):e.b=t}function wa(e,t){e.b&&e.b==t?e.b=null:e.a&&e.a.has(t)&&e.a.delete(t)}va.prototype.cancel=function(){var e,t;if(this.c=ba(this),this.b)this.b.cancel(),this.b=null;else if(this.a&&this.a.size!==0){try{for(var n=Ou(this.a.values()),r=n.next();!r.done;r=n.next()){var i=r.value;i.cancel()}}catch(o){e={error:o}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this.a.clear()}};function ba(e){var t,n;if(e.b!=null)return e.c.concat(e.b.s);if(e.a!=null&&e.a.size!==0){var r=e.c;try{for(var i=Ou(e.a.values()),o=i.next();!o.done;o=i.next()){var s=o.value;r=r.concat(s.s)}}catch(u){t={error:u}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r}return Zi(e.c)}function wo(){}wo.prototype.stringify=function(e){return R.JSON.stringify(e,void 0)};wo.prototype.parse=function(e){return R.JSON.parse(e,void 0)};function El(){this.a=new wo}function Tl(e,t,n){var r=n||"";try{vo(e,function(i,o){var s=i;Ln(i)&&(s=ao(i)),t.push(r+o+"="+encodeURIComponent(s))})}catch(i){throw t.push(r+"type="+encodeURIComponent("_badmap")),i}}function _l(e,t){var n=new fo;if(R.Image){var r=new Image;r.onload=Jn(tr,n,r,"TestLoadImage: loaded",!0,t),r.onerror=Jn(tr,n,r,"TestLoadImage: error",!1,t),r.onabort=Jn(tr,n,r,"TestLoadImage: abort",!1,t),r.ontimeout=Jn(tr,n,r,"TestLoadImage: timeout",!1,t),R.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=e}else t(!1)}function tr(e,t,n,r,i){try{t.onload=null,t.onerror=null,t.onabort=null,t.ontimeout=null,i(r)}catch{}}var Sl=R.JSON.parse;function Z(e){At.call(this),this.headers=new nn,this.H=e||null,this.b=!1,this.s=this.a=null,this.B="",this.h=0,this.f="",this.g=this.A=this.l=this.u=!1,this.o=0,this.m=null,this.I=Dl,this.D=this.F=!1}vt(Z,At);var Dl="",Nl=/^https?$/i,Al=["POST","PUT"];S=Z.prototype;S.ba=function(e,t,n,r){if(this.a)throw Error("[goog.net.XhrIo] Object is active with another request="+this.B+"; newUri="+e);t=t?t.toUpperCase():"GET",this.B=e,this.f="",this.h=0,this.u=!1,this.b=!0,this.a=new XMLHttpRequest,this.s=this.H?Is(this.H):Is(sa),this.a.onreadystatechange=ut(this.za,this);try{this.A=!0,this.a.open(t,String(e),!0),this.A=!1}catch(o){_s(this,o);return}e=n||"";var i=new nn(this.headers);r&&vo(r,function(o,s){i.set(s,o)}),r=Bh(i.L()),n=R.FormData&&e instanceof R.FormData,!(0<=Pu(Al,t))||r||n||i.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),i.forEach(function(o,s){this.a.setRequestHeader(s,o)},this),this.I&&(this.a.responseType=this.I),"withCredentials"in this.a&&this.a.withCredentials!==this.F&&(this.a.withCredentials=this.F);try{Ta(this),0=e.b.f-(e.h?1:0)?!1:e.h?(e.g=t.s.concat(e.g),!0):e.v==1||e.v==2||e.u>=(e.La?0:e.Ma)?!1:(e.h=Fn(ut(e.Ba,e,t),ka(e,e.u)),e.u++,!0)}S.Ba=function(e){if(this.h)if(this.h=null,this.v==1){if(!e){this.R=Math.floor(1e5*Math.random()),e=this.R++;var t=new Un(this,this.c,e,void 0),n=this.l;this.O&&(n?(n=Mu(n),Fu(n,this.O)):n=this.O),this.i===null&&(t.B=n);var r;if(this.da)t:{for(var i=r=0;ic)o=Math.max(0,i[a].b-100),u=!1;else try{Tl(h,s,"req"+c+"_")}catch{r&&r(h)}}if(u){r=s.join("&");break t}}return e=e.g.splice(0,n),t.s=e,r}function Na(e){e.a||e.j||(e.T=1,Wu(e.Aa,e),e.o=0)}function Eo(e){return e.a||e.j||3<=e.o?!1:(e.T++,e.j=Fn(ut(e.Aa,e),ka(e,e.o)),e.o++,!0)}S.Aa=function(){if(this.j=null,Aa(this),this.U&&!(this.F||this.a==null||0>=this.N)){var e=2*this.N;this.c.info("BP detection timer enabled: "+e),this.s=Fn(ut(this.Ta,this),e)}};S.Ta=function(){this.s&&(this.s=null,this.c.info("BP detection timeout reached."),this.c.info("Buffering proxy detected and switch to long-polling!"),this.H=!1,this.F=!0,dt(10),Gr(this),Aa(this))};function To(e){e.s!=null&&(R.clearTimeout(e.s),e.s=null)}function Aa(e){e.a=new Un(e,e.c,"rpc",e.T),e.i===null&&(e.a.B=e.l),e.a.O=0;var t=zt(e.la);K(t,"RID","rpc"),K(t,"SID",e.J),K(t,"CI",e.H?"0":"1"),K(t,"AID",e.P),Bn(e,t),K(t,"TYPE","xmlhttp"),e.i&&e.l&&bo(t,e.i,e.l),e.D&&e.a.setTimeout(e.D);var n=e.a;e=e.ga,n.H=1,n.i=jr(zt(t)),n.j=null,n.I=!0,ca(n,e)}S.Sa=function(){this.m!=null&&(this.m=null,Gr(this),Eo(this),dt(19))};function gr(e){e.m!=null&&(R.clearTimeout(e.m),e.m=null)}function Ca(e,t){var n=null;if(e.a==t){gr(e),To(e),e.a=null;var r=2}else if(Pi(e.b,t))n=t.s,wa(e.b,t),r=1;else return;if(e.I=t.N,e.v!=0){if(t.b)if(r==1){n=t.j?t.j.length:0,t=qt()-t.u;var i=e.u;r=Ur(),rt(r,new na(r)),zr(e)}else Na(e);else if(i=t.h,i==3||i==0&&0t?1:0}function qe(e,t,n){return e.length===t.length&&e.every(function(r,i){return n(r,t[i])})}function Va(e){return e+"\0"}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */var gt=function(){function e(t,n){if(this.seconds=t,this.nanoseconds=n,n<0)throw new w(d.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(n>=1e9)throw new w(d.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(t<-62135596800)throw new w(d.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new w(d.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}return e.now=function(){return e.fromMillis(Date.now())},e.fromDate=function(t){return e.fromMillis(t.getTime())},e.fromMillis=function(t){var n=Math.floor(t/1e3);return new e(n,1e6*(t-1e3*n))},e.prototype.toDate=function(){return new Date(this.toMillis())},e.prototype.toMillis=function(){return 1e3*this.seconds+this.nanoseconds/1e6},e.prototype._compareTo=function(t){return this.seconds===t.seconds?L(this.nanoseconds,t.nanoseconds):L(this.seconds,t.seconds)},e.prototype.isEqual=function(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds},e.prototype.toString=function(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"},e.prototype.toJSON=function(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}},e.prototype.valueOf=function(){var t=this.seconds- -62135596800;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")},e}(),P=function(){function e(t){this.timestamp=t}return e.fromTimestamp=function(t){return new e(t)},e.min=function(){return new e(new gt(0,0))},e.prototype.compareTo=function(t){return this.timestamp._compareTo(t.timestamp)},e.prototype.isEqual=function(t){return this.timestamp.isEqual(t.timestamp)},e.prototype.toMicroseconds=function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3},e.prototype.toString=function(){return"SnapshotVersion("+this.timestamp.toString()+")"},e.prototype.toTimestamp=function(){return this.timestamp},e}();/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *//** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Ns(e){var t=0;for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function jn(e,t){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function Ua(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */var qa=function(){function e(t,n,r){n===void 0?n=0:n>t.length&&D(),r===void 0?r=t.length-n:r>t.length-n&&D(),this.segments=t,this.offset=n,this.len=r}return Object.defineProperty(e.prototype,"length",{get:function(){return this.len},enumerable:!1,configurable:!0}),e.prototype.isEqual=function(t){return e.comparator(this,t)===0},e.prototype.child=function(t){var n=this.segments.slice(this.offset,this.limit());return t instanceof e?t.forEach(function(r){n.push(r)}):n.push(t),this.construct(n)},e.prototype.limit=function(){return this.offset+this.length},e.prototype.popFirst=function(t){return t=t===void 0?1:t,this.construct(this.segments,this.offset+t,this.length-t)},e.prototype.popLast=function(){return this.construct(this.segments,this.offset,this.length-1)},e.prototype.firstSegment=function(){return this.segments[this.offset]},e.prototype.lastSegment=function(){return this.get(this.length-1)},e.prototype.get=function(t){return this.segments[this.offset+t]},e.prototype.isEmpty=function(){return this.length===0},e.prototype.isPrefixOf=function(t){if(t.lengths)return 1}return t.lengthn.length?1:0},e}(),V=function(e){function t(){return e!==null&&e.apply(this,arguments)||this}return C(t,e),t.prototype.construct=function(n,r,i){return new t(n,r,i)},t.prototype.canonicalString=function(){return this.toArray().join("/")},t.prototype.toString=function(){return this.canonicalString()},t.fromString=function(){for(var n=[],r=0;r=0)throw new w(d.INVALID_ARGUMENT,"Invalid segment ("+u+"). Paths must not contain // in them.");i.push.apply(i,u.split("/").filter(function(a){return a.length>0}))}return new t(i)},t.emptyPath=function(){return new t([])},t}(qa),ql=/^[_a-zA-Z][_a-zA-Z0-9]*$/,xt=function(e){function t(){return e!==null&&e.apply(this,arguments)||this}return C(t,e),t.prototype.construct=function(n,r,i){return new t(n,r,i)},t.isValidIdentifier=function(n){return ql.test(n)},t.prototype.canonicalString=function(){return this.toArray().map(function(n){return n=n.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),t.isValidIdentifier(n)||(n="`"+n+"`"),n}).join(".")},t.prototype.toString=function(){return this.canonicalString()},t.prototype.isKeyField=function(){return this.length===1&&this.get(0)==="__name__"},t.keyField=function(){return new t(["__name__"])},t.fromServerFormat=function(n){for(var r=[],i="",o=0,s=function(){if(i.length===0)throw new w(d.INVALID_ARGUMENT,"Invalid field path ("+n+"). Paths must not be empty, begin with '.', end with '.', or contain '..'");r.push(i),i=""},u=!1;o=Number.MIN_SAFE_INTEGER}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */var N=function(){function e(t){this.path=t}return e.fromPath=function(t){return new e(V.fromString(t))},e.fromName=function(t){return new e(V.fromString(t).popFirst(5))},e.prototype.hasCollectionId=function(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t},e.prototype.isEqual=function(t){return t!==null&&V.comparator(this.path,t.path)===0},e.prototype.toString=function(){return this.path.toString()},e.comparator=function(t,n){return V.comparator(t.path,n.path)},e.isDocumentKey=function(t){return t.length%2==0},e.fromSegments=function(t){return new e(new V(t.slice()))},e}();/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function oe(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?So(e)?4:10:D()}function Vt(e,t){var n=oe(e);if(n!==oe(t))return!1;switch(n){case 0:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return Tn(e).isEqual(Tn(t));case 3:return function(r,i){if(typeof r.timestampValue=="string"&&typeof i.timestampValue=="string"&&r.timestampValue.length===i.timestampValue.length)return r.timestampValue===i.timestampValue;var o=ie(r.timestampValue),s=ie(i.timestampValue);return o.seconds===s.seconds&&o.nanos===s.nanos}(e,t);case 5:return e.stringValue===t.stringValue;case 6:return function(r,i){return je(r.bytesValue).isEqual(je(i.bytesValue))}(e,t);case 7:return e.referenceValue===t.referenceValue;case 8:return function(r,i){return H(r.geoPointValue.latitude)===H(i.geoPointValue.latitude)&&H(r.geoPointValue.longitude)===H(i.geoPointValue.longitude)}(e,t);case 2:return function(r,i){if("integerValue"in r&&"integerValue"in i)return H(r.integerValue)===H(i.integerValue);if("doubleValue"in r&&"doubleValue"in i){var o=H(r.doubleValue),s=H(i.doubleValue);return o===s?br(o)===br(s):isNaN(o)&&isNaN(s)}return!1}(e,t);case 9:return qe(e.arrayValue.values||[],t.arrayValue.values||[],Vt);case 10:return function(r,i){var o=r.mapValue.fields||{},s=i.mapValue.fields||{};if(Ns(o)!==Ns(s))return!1;for(var u in o)if(o.hasOwnProperty(u)&&(s[u]===void 0||!Vt(o[u],s[u])))return!1;return!0}(e,t);default:return D()}}function _n(e,t){return(e.values||[]).find(function(n){return Vt(n,t)})!==void 0}function Ke(e,t){var n=oe(e),r=oe(t);if(n!==r)return L(n,r);switch(n){case 0:return 0;case 1:return L(e.booleanValue,t.booleanValue);case 2:return function(i,o){var s=H(i.integerValue||i.doubleValue),u=H(o.integerValue||o.doubleValue);return su?1:s===u?0:isNaN(s)?isNaN(u)?0:-1:1}(e,t);case 3:return As(e.timestampValue,t.timestampValue);case 4:return As(Tn(e),Tn(t));case 5:return L(e.stringValue,t.stringValue);case 6:return function(i,o){var s=je(i),u=je(o);return s.compareTo(u)}(e.bytesValue,t.bytesValue);case 7:return function(i,o){for(var s=i.split("/"),u=o.split("/"),a=0;a":return n>0;case">=":return n>=0;default:return D()}},t.prototype.g=function(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0},t}(function(){}),Kl=function(e){function t(n,r,i){var o=this;return(o=e.call(this,n,r,i)||this).key=N.fromName(i.referenceValue),o}return C(t,e),t.prototype.matches=function(n){var r=N.comparator(n.key,this.key);return this.m(r)},t}(Dt),Gl=function(e){function t(n,r){var i=this;return(i=e.call(this,n,"in",r)||this).keys=Ga("in",r),i}return C(t,e),t.prototype.matches=function(n){return this.keys.some(function(r){return r.isEqual(n.key)})},t}(Dt),zl=function(e){function t(n,r){var i=this;return(i=e.call(this,n,"not-in",r)||this).keys=Ga("not-in",r),i}return C(t,e),t.prototype.matches=function(n){return!this.keys.some(function(r){return r.isEqual(n.key)})},t}(Dt);function Ga(e,t){var n;return(((n=t.arrayValue)===null||n===void 0?void 0:n.values)||[]).map(function(r){return N.fromName(r.referenceValue)})}var Ql=function(e){function t(n,r){return e.call(this,n,"array-contains",r)||this}return C(t,e),t.prototype.matches=function(n){var r=n.data.field(this.field);return No(r)&&_n(r.arrayValue,this.value)},t}(Dt),$l=function(e){function t(n,r){return e.call(this,n,"in",r)||this}return C(t,e),t.prototype.matches=function(n){var r=n.data.field(this.field);return r!==null&&_n(this.value.arrayValue,r)},t}(Dt),Hl=function(e){function t(n,r){return e.call(this,n,"not-in",r)||this}return C(t,e),t.prototype.matches=function(n){if(_n(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;var r=n.data.field(this.field);return r!==null&&!_n(this.value.arrayValue,r)},t}(Dt),Wl=function(e){function t(n,r){return e.call(this,n,"array-contains-any",r)||this}return C(t,e),t.prototype.matches=function(n){var r=this,i=n.data.field(this.field);return!(!No(i)||!i.arrayValue.values)&&i.arrayValue.values.some(function(o){return _n(r.value.arrayValue,o)})},t}(Dt),Sn=function(e,t){this.position=e,this.before=t};function Tr(e){return(e.before?"b":"a")+":"+e.position.map(function(t){return Do(t)}).join(",")}var Ve=function(e,t){t===void 0&&(t="asc"),this.field=e,this.dir=t};function Xl(e,t){return e.dir===t.dir&&e.field.isEqual(t.field)}function Rs(e,t,n){for(var r=0,i=0;i0?e.explicitOrderBy[0].field:null}function Co(e){for(var t=0,n=e.filters;t0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc";t.p.push(new Ve(xt.keyField(),a))}}}return t.p}function Ut(e){var t=_(e);if(!t.T)if(t.limitType==="F")t.T=xs(t.path,t.collectionGroup,Ge(t),t.filters,t.limit,t.startAt,t.endAt);else{for(var n=[],r=0,i=Ge(t);r0&&(n+=", orderBy: ["+t.orderBy.map(function(r){return function(i){return i.field.canonicalString()+" ("+i.dir+")"}(r)}).join(", ")+"]"),t.startAt&&(n+=", startAt: "+Tr(t.startAt)),t.endAt&&(n+=", endAt: "+Tr(t.endAt)),"Target("+n+")"}(Ut(e))+"; limitType="+e.limitType+")"}function Qn(e,t){return t.isFoundDocument()&&function(n,r){var i=r.key.path;return n.collectionGroup!==null?r.key.hasCollectionId(n.collectionGroup)&&n.path.isPrefixOf(i):N.isDocumentKey(n.path)?n.path.isEqual(i):n.path.isImmediateParentOf(i)}(e,t)&&function(n,r){for(var i=0,o=n.explicitOrderBy;i0&&(n=n.right)}return null},e.prototype.indexOf=function(t){for(var n=0,r=this.root;!r.isEmpty();){var i=this.comparator(t,r.key);if(i===0)return n+r.left.size;i<0?r=r.left:(n+=r.left.size+1,r=r.right)}return-1},e.prototype.isEmpty=function(){return this.root.isEmpty()},Object.defineProperty(e.prototype,"size",{get:function(){return this.root.size},enumerable:!1,configurable:!0}),e.prototype.minKey=function(){return this.root.minKey()},e.prototype.maxKey=function(){return this.root.maxKey()},e.prototype.inorderTraversal=function(t){return this.root.inorderTraversal(t)},e.prototype.forEach=function(t){this.inorderTraversal(function(n,r){return t(n,r),!1})},e.prototype.toString=function(){var t=[];return this.inorderTraversal(function(n,r){return t.push(n+":"+r),!1}),"{"+t.join(", ")+"}"},e.prototype.reverseTraversal=function(t){return this.root.reverseTraversal(t)},e.prototype.getIterator=function(){return new nr(this.root,null,this.comparator,!1)},e.prototype.getIteratorFrom=function(t){return new nr(this.root,t,this.comparator,!1)},e.prototype.getReverseIterator=function(){return new nr(this.root,null,this.comparator,!0)},e.prototype.getReverseIteratorFrom=function(t){return new nr(this.root,t,this.comparator,!0)},e}(),nr=function(){function e(t,n,r,i){this.isReverse=i,this.nodeStack=[];for(var o=1;!t.isEmpty();)if(o=n?r(t.key,n):1,i&&(o*=-1),o<0)t=this.isReverse?t.left:t.right;else{if(o===0){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}return e.prototype.getNext=function(){var t=this.nodeStack.pop(),n={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return n},e.prototype.hasNext=function(){return this.nodeStack.length>0},e.prototype.peek=function(){if(this.nodeStack.length===0)return null;var t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}},e}(),Xt=function(){function e(t,n,r,i,o){this.key=t,this.value=n,this.color=r??e.RED,this.left=i??e.EMPTY,this.right=o??e.EMPTY,this.size=this.left.size+1+this.right.size}return e.prototype.copy=function(t,n,r,i,o){return new e(t??this.key,n??this.value,r??this.color,i??this.left,o??this.right)},e.prototype.isEmpty=function(){return!1},e.prototype.inorderTraversal=function(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)},e.prototype.reverseTraversal=function(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)},e.prototype.min=function(){return this.left.isEmpty()?this:this.left.min()},e.prototype.minKey=function(){return this.min().key},e.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},e.prototype.insert=function(t,n,r){var i=this,o=r(t,i.key);return(i=o<0?i.copy(null,null,null,i.left.insert(t,n,r),null):o===0?i.copy(null,n,null,null,null):i.copy(null,null,null,null,i.right.insert(t,n,r))).fixUp()},e.prototype.removeMin=function(){if(this.left.isEmpty())return e.EMPTY;var t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),(t=t.copy(null,null,null,t.left.removeMin(),null)).fixUp()},e.prototype.remove=function(t,n){var r,i=this;if(n(t,i.key)<0)i.left.isEmpty()||i.left.isRed()||i.left.left.isRed()||(i=i.moveRedLeft()),i=i.copy(null,null,null,i.left.remove(t,n),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),n(t,i.key)===0){if(i.right.isEmpty())return e.EMPTY;r=i.right.min(),i=i.copy(r.key,r.value,null,null,i.right.removeMin())}i=i.copy(null,null,null,null,i.right.remove(t,n))}return i.fixUp()},e.prototype.isRed=function(){return this.color},e.prototype.fixUp=function(){var t=this;return t.right.isRed()&&!t.left.isRed()&&(t=t.rotateLeft()),t.left.isRed()&&t.left.left.isRed()&&(t=t.rotateRight()),t.left.isRed()&&t.right.isRed()&&(t=t.colorFlip()),t},e.prototype.moveRedLeft=function(){var t=this.colorFlip();return t.right.left.isRed()&&(t=(t=(t=t.copy(null,null,null,null,t.right.rotateRight())).rotateLeft()).colorFlip()),t},e.prototype.moveRedRight=function(){var t=this.colorFlip();return t.left.left.isRed()&&(t=(t=t.rotateRight()).colorFlip()),t},e.prototype.rotateLeft=function(){var t=this.copy(null,null,e.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)},e.prototype.rotateRight=function(){var t=this.copy(null,null,e.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)},e.prototype.colorFlip=function(){var t=this.left.copy(null,null,!this.left.color,null,null),n=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,n)},e.prototype.checkMaxDepth=function(){var t=this.check();return Math.pow(2,t)<=this.size+1},e.prototype.check=function(){if(this.isRed()&&this.left.isRed()||this.right.isRed())throw D();var t=this.left.check();if(t!==this.right.check())throw D();return t+(this.isRed()?0:1)},e}();Xt.EMPTY=null,Xt.RED=!0,Xt.BLACK=!1,Xt.EMPTY=new(function(){function e(){this.size=0}return Object.defineProperty(e.prototype,"key",{get:function(){throw D()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){throw D()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"color",{get:function(){throw D()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"left",{get:function(){throw D()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"right",{get:function(){throw D()},enumerable:!1,configurable:!0}),e.prototype.copy=function(t,n,r,i,o){return this},e.prototype.insert=function(t,n,r){return new Xt(t,n)},e.prototype.remove=function(t,n){return this},e.prototype.isEmpty=function(){return!0},e.prototype.inorderTraversal=function(t){return!1},e.prototype.reverseTraversal=function(t){return!1},e.prototype.minKey=function(){return null},e.prototype.maxKey=function(){return null},e.prototype.isRed=function(){return!1},e.prototype.checkMaxDepth=function(){return!0},e.prototype.check=function(){return 0},e}());/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */var J=function(){function e(t){this.comparator=t,this.data=new ht(this.comparator)}return e.prototype.has=function(t){return this.data.get(t)!==null},e.prototype.first=function(){return this.data.minKey()},e.prototype.last=function(){return this.data.maxKey()},Object.defineProperty(e.prototype,"size",{get:function(){return this.data.size},enumerable:!1,configurable:!0}),e.prototype.indexOf=function(t){return this.data.indexOf(t)},e.prototype.forEach=function(t){this.data.inorderTraversal(function(n,r){return t(n),!1})},e.prototype.forEachInRange=function(t,n){for(var r=this.data.getIteratorFrom(t[0]);r.hasNext();){var i=r.getNext();if(this.comparator(i.key,t[1])>=0)return;n(i.key)}},e.prototype.forEachWhile=function(t,n){var r;for(r=n!==void 0?this.data.getIteratorFrom(n):this.data.getIterator();r.hasNext();)if(!t(r.getNext().key))return},e.prototype.firstAfterOrEqual=function(t){var n=this.data.getIteratorFrom(t);return n.hasNext()?n.getNext().key:null},e.prototype.getIterator=function(){return new Us(this.data.getIterator())},e.prototype.getIteratorFrom=function(t){return new Us(this.data.getIteratorFrom(t))},e.prototype.add=function(t){return this.copy(this.data.remove(t).insert(t,!0))},e.prototype.delete=function(t){return this.has(t)?this.copy(this.data.remove(t)):this},e.prototype.isEmpty=function(){return this.data.isEmpty()},e.prototype.unionWith=function(t){var n=this;return n.size0&&(this.F=!0,this.C=t)},e.prototype.M=function(){var t=B(),n=B(),r=B();return this.D.forEach(function(i,o){switch(o){case 0:t=t.add(i);break;case 2:n=n.add(i);break;case 1:r=r.add(i);break;default:D()}}),new Oo(this.C,this.N,t,n,r)},e.prototype.L=function(){this.F=!1,this.D=js()},e.prototype.B=function(t,n){this.F=!0,this.D=this.D.insert(t,n)},e.prototype.q=function(t){this.F=!0,this.D=this.D.remove(t)},e.prototype.U=function(){this.S+=1},e.prototype.K=function(){this.S-=1},e.prototype.j=function(){this.F=!0,this.N=!0},e}(),lf=function(){function e(t){this.W=t,this.G=new Map,this.H=Ot(),this.J=Bs(),this.Y=new J(L)}return e.prototype.X=function(t){for(var n=0,r=t.v;n0?t.targetIds.forEach(n):this.G.forEach(function(i,o){r.st(o)&&n(o)})},e.prototype.rt=function(t){var n=t.targetId,r=t.V.count,i=this.ot(n);if(i){var o=i.target;if(Er(o))if(r===0){var s=new N(o.path);this.tt(n,s,ct.newNoDocument(s,P.min()))}else x(r===1);else this.ct(n)!==r&&(this.it(n),this.Y=this.Y.add(n))}},e.prototype.ut=function(t){var n=this,r=new Map;this.G.forEach(function(s,u){var a=n.ot(u);if(a){if(s.current&&Er(a.target)){var c=new N(a.target.path);n.H.get(c)!==null||n.at(u,c)||n.tt(u,c,ct.newNoDocument(c,t))}s.O&&(r.set(u,s.M()),s.L())}});var i=B();this.J.forEach(function(s,u){var a=!0;u.forEachWhile(function(c){var h=n.ot(c);return!h||h.purpose===2||(a=!1,!1)}),a&&(i=i.add(s))});var o=new Ro(t,r,this.Y,this.H,i);return this.H=Ot(),this.J=Bs(),this.Y=new J(L),o},e.prototype.Z=function(t,n){if(this.st(t)){var r=this.at(t,n.key)?2:0;this.nt(t).B(n.key,r),this.H=this.H.insert(n.key,n),this.J=this.J.insert(n.key,this.ht(n.key).add(t))}},e.prototype.tt=function(t,n,r){if(this.st(t)){var i=this.nt(t);this.at(t,n)?i.B(n,1):i.q(n),this.J=this.J.insert(n,this.ht(n).delete(t)),r&&(this.H=this.H.insert(n,r))}},e.prototype.removeTarget=function(t){this.G.delete(t)},e.prototype.ct=function(t){var n=this.nt(t).M();return this.W.getRemoteKeysForTarget(t).size+n.addedDocuments.size-n.removedDocuments.size},e.prototype.U=function(t){this.nt(t).U()},e.prototype.nt=function(t){var n=this.G.get(t);return n||(n=new qs,this.G.set(t,n)),n},e.prototype.ht=function(t){var n=this.J.get(t);return n||(n=new J(L),this.J=this.J.insert(t,n)),n},e.prototype.st=function(t){var n=this.ot(t)!==null;return n||I("WatchChangeAggregator","Detected inactive target",t),n},e.prototype.ot=function(t){var n=this.G.get(t);return n&&n.k?null:this.W.lt(t)},e.prototype.it=function(t){var n=this;this.G.set(t,new qs),this.W.getRemoteKeysForTarget(t).forEach(function(r){n.tt(t,r,null)})},e.prototype.at=function(t,n){return this.W.getRemoteKeysForTarget(t).has(n)},e}();function Bs(){return new ht(N.comparator)}function js(){return new ht(N.comparator)}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */var ff={asc:"ASCENDING",desc:"DESCENDING"},pf={"<":"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"},df=function(e,t){this.databaseId=e,this.I=t};function Dn(e,t){return e.I?new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")+"."+("000000000"+t.nanoseconds).slice(-9)+"Z":{seconds:""+t.seconds,nanos:t.nanoseconds}}function uc(e,t){return e.I?t.toBase64():t.toUint8Array()}function yf(e,t){return Dn(e,t.toTimestamp())}function yt(e){return x(!!e),P.fromTimestamp(function(t){var n=ie(t);return new gt(n.seconds,n.nanos)}(e))}function Po(e,t){return function(n){return new V(["projects",n.projectId,"databases",n.database])}(e).child("documents").child(t).canonicalString()}function ac(e){var t=V.fromString(e);return x(yc(t)),t}function Nn(e,t){return Po(e.databaseId,t.path)}function jt(e,t){var n=ac(t);if(n.get(1)!==e.databaseId.projectId)throw new w(d.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+e.databaseId.projectId);if(n.get(3)!==e.databaseId.database)throw new w(d.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+e.databaseId.database);return new N(hc(n))}function Ki(e,t){return Po(e.databaseId,t)}function cc(e){var t=ac(e);return t.length===4?V.emptyPath():hc(t)}function An(e){return new V(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function hc(e){return x(e.length>4&&e.get(4)==="documents"),e.popFirst(5)}function Ks(e,t,n){return{name:Nn(e,t),fields:n.toProto().mapValue.fields}}function vf(e,t,n){var r=jt(e,t.name),i=yt(t.updateTime),o=new _t({mapValue:{fields:t.fields}}),s=ct.newFoundDocument(r,i,o);return n&&s.setHasCommittedMutations(),n?s.setHasCommittedMutations():s}function Sr(e,t){var n;if(t instanceof Hn)n={update:Ks(e,t.key,t.value)};else if(t instanceof Wn)n={delete:Nn(e,t.key)};else if(t instanceof ce)n={update:Ks(e,t.key,t.data),updateMask:If(t.fieldMask)};else{if(!(t instanceof xo))return D();n={verify:Nn(e,t.key)}}return t.fieldTransforms.length>0&&(n.updateTransforms=t.fieldTransforms.map(function(r){return function(i,o){var s=o.transform;if(s instanceof ze)return{fieldPath:o.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(s instanceof Ie)return{fieldPath:o.field.canonicalString(),appendMissingElements:{values:s.elements}};if(s instanceof Ee)return{fieldPath:o.field.canonicalString(),removeAllFromArray:{values:s.elements}};if(s instanceof Qe)return{fieldPath:o.field.canonicalString(),increment:s.A};throw D()}(0,r)})),t.precondition.isNone||(n.currentDocument=function(r,i){return i.updateTime!==void 0?{updateTime:yf(r,i.updateTime)}:i.exists!==void 0?{exists:i.exists}:D()}(e,t.precondition)),n}function Gs(e,t){var n=t.currentDocument?function(c){return c.updateTime!==void 0?st.updateTime(yt(c.updateTime)):c.exists!==void 0?st.exists(c.exists):st.none()}(t.currentDocument):st.none(),r=t.updateTransforms?t.updateTransforms.map(function(c){return function(h,l){var f=null;if("setToServerValue"in l)x(l.setToServerValue==="REQUEST_TIME"),f=new ze;else if("appendMissingElements"in l){var y=l.appendMissingElements.values||[];f=new Ie(y)}else if("removeAllFromArray"in l){var p=l.removeAllFromArray.values||[];f=new Ee(p)}else"increment"in l?f=new Qe(h,l.increment):D();var v=xt.fromServerFormat(l.fieldPath);return new $n(v,f)}(e,c)}):[];if(t.update){t.update.name;var i=jt(e,t.update.name),o=new _t({mapValue:{fields:t.update.fields}});if(t.updateMask){var s=function(c){var h=c.fieldPaths||[];return new Be(h.map(function(l){return xt.fromServerFormat(l)}))}(t.updateMask);return new ce(i,o,s,n,r)}return new Hn(i,o,n,r)}if(t.delete){var u=jt(e,t.delete);return new Wn(u,n)}if(t.verify){var a=jt(e,t.verify);return new xo(a,n)}return D()}function lc(e,t){return{documents:[Ki(e,t.path)]}}function fc(e,t){var n={structuredQuery:{}},r=t.path;t.collectionGroup!==null?(n.parent=Ki(e,r),n.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(n.parent=Ki(e,r.popLast()),n.structuredQuery.from=[{collectionId:r.lastSegment()}]);var i=function(u){if(u.length!==0){var a=u.map(function(c){return function(h){if(h.op==="=="){if(ks(h.value))return{unaryFilter:{field:xe(h.field),op:"IS_NAN"}};if(Cs(h.value))return{unaryFilter:{field:xe(h.field),op:"IS_NULL"}}}else if(h.op==="!="){if(ks(h.value))return{unaryFilter:{field:xe(h.field),op:"IS_NOT_NAN"}};if(Cs(h.value))return{unaryFilter:{field:xe(h.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:xe(h.field),op:gf(h.op),value:h.value}}}(c)});return a.length===1?a[0]:{compositeFilter:{op:"AND",filters:a}}}}(t.filters);i&&(n.structuredQuery.where=i);var o=function(u){if(u.length!==0)return u.map(function(a){return function(c){return{field:xe(c.field),direction:mf(c.dir)}}(a)})}(t.orderBy);o&&(n.structuredQuery.orderBy=o);var s=function(u,a){return u.I||Se(a)?a:{value:a}}(e,t.limit);return s!==null&&(n.structuredQuery.limit=s),t.startAt&&(n.structuredQuery.startAt=zs(t.startAt)),t.endAt&&(n.structuredQuery.endAt=zs(t.endAt)),n}function pc(e){var t=cc(e.parent),n=e.structuredQuery,r=n.from?n.from.length:0,i=null;if(r>0){x(r===1);var o=n.from[0];o.allDescendants?i=o.collectionId:t=t.child(o.collectionId)}var s=[];n.where&&(s=dc(n.where));var u=[];n.orderBy&&(u=n.orderBy.map(function(l){return function(f){return new Ve(Me(f.field),function(y){switch(y){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(f.direction))}(l)}));var a=null;n.limit&&(a=function(l){var f;return Se(f=typeof l=="object"?l.value:l)?null:f}(n.limit));var c=null;n.startAt&&(c=Qs(n.startAt));var h=null;return n.endAt&&(h=Qs(n.endAt)),za(t,i,u,s,a,"F",c,h)}function dc(e){return e?e.unaryFilter!==void 0?[bf(e)]:e.fieldFilter!==void 0?[wf(e)]:e.compositeFilter!==void 0?e.compositeFilter.filters.map(function(t){return dc(t)}).reduce(function(t,n){return t.concat(n)}):D():[]}function zs(e){return{before:e.before,values:e.position}}function Qs(e){var t=!!e.before,n=e.values||[];return new Sn(n,t)}function mf(e){return ff[e]}function gf(e){return pf[e]}function xe(e){return{fieldPath:e.canonicalString()}}function Me(e){return xt.fromServerFormat(e.fieldPath)}function wf(e){return Dt.create(Me(e.fieldFilter.field),function(t){switch(t){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":default:return D()}}(e.fieldFilter.op),e.fieldFilter.value)}function bf(e){switch(e.unaryFilter.op){case"IS_NAN":var t=Me(e.unaryFilter.field);return Dt.create(t,"==",{doubleValue:NaN});case"IS_NULL":var n=Me(e.unaryFilter.field);return Dt.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":var r=Me(e.unaryFilter.field);return Dt.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":var i=Me(e.unaryFilter.field);return Dt.create(i,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":default:return D()}}function If(e){var t=[];return e.fields.forEach(function(n){return t.push(n.canonicalString())}),{fieldPaths:t}}function yc(e){return e.length>=4&&e.get(0)==="projects"&&e.get(2)==="databases"}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Pt(e){for(var t="",n=0;n0&&(t=$s(t)),t=Ef(e.get(n),t);return $s(t)}function Ef(e,t){for(var n=t,r=e.length,i=0;i=2),t===2)return x(e.charAt(0)===""&&e.charAt(1)===""),V.emptyPath();for(var n=t-2,r=[],i="",o=0;on)&&D(),e.charAt(s+1)){case"":var u=e.substring(o,s),a=void 0;i.length===0?a=u:(a=i+=u,i=""),r.push(a);break;case"":i+=e.substring(o,s),i+="\0";break;case"":i+=e.substring(o,s+1);break;default:D()}o=s+2}return new V(r)}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */var Tf=function(e,t){this.seconds=e,this.nanoseconds=t},It=function(e,t,n){this.ownerId=e,this.allowTabSynchronization=t,this.leaseTimestampMs=n};It.store="owner",It.key="owner";var ee=function(e,t,n){this.userId=e,this.lastAcknowledgedBatchId=t,this.lastStreamToken=n};ee.store="mutationQueues",ee.keyPath="userId";var j=function(e,t,n,r,i){this.userId=e,this.batchId=t,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i};j.store="mutations",j.keyPath="batchId",j.userMutationsIndex="userMutationsIndex",j.userMutationsKeyPath=["userId","batchId"];var it=function(){function e(){}return e.prefixForUser=function(t){return[t]},e.prefixForPath=function(t,n){return[t,Pt(n)]},e.key=function(t,n,r){return[t,Pt(n),r]},e}();it.store="documentMutations",it.PLACEHOLDER=new it;var _f=function(e,t){this.path=e,this.readTime=t},Sf=function(e,t){this.path=e,this.version=t},z=function(e,t,n,r,i,o){this.unknownDocument=e,this.noDocument=t,this.document=n,this.hasCommittedMutations=r,this.readTime=i,this.parentPath=o};z.store="remoteDocuments",z.readTimeIndex="readTimeIndex",z.readTimeIndexPath="readTime",z.collectionReadTimeIndex="collectionReadTimeIndex",z.collectionReadTimeIndexPath=["parentPath","readTime"];var Mt=function(e){this.byteSize=e};Mt.store="remoteDocumentGlobal",Mt.key="remoteDocumentGlobalKey";var mt=function(e,t,n,r,i,o,s){this.targetId=e,this.canonicalId=t,this.readTime=n,this.resumeToken=r,this.lastListenSequenceNumber=i,this.lastLimboFreeSnapshotVersion=o,this.query=s};mt.store="targets",mt.keyPath="targetId",mt.queryTargetsIndexName="queryTargetsIndex",mt.queryTargetsKeyPath=["canonicalId","targetId"];var nt=function(e,t,n){this.targetId=e,this.path=t,this.sequenceNumber=n};nt.store="targetDocuments",nt.keyPath=["targetId","path"],nt.documentTargetsIndex="documentTargetsIndex",nt.documentTargetsKeyPath=["path","targetId"];var Et=function(e,t,n,r){this.highestTargetId=e,this.highestListenSequenceNumber=t,this.lastRemoteSnapshotVersion=n,this.targetCount=r};Et.key="targetGlobalKey",Et.store="targetGlobal";var ve=function(e,t){this.collectionId=e,this.parent=t};ve.store="collectionParents",ve.keyPath=["collectionId","parent"];var Kt=function(e,t,n,r){this.clientId=e,this.updateTimeMs=t,this.networkEnabled=n,this.inForeground=r};Kt.store="clientMetadata",Kt.keyPath="clientId";var $e=function(e,t,n){this.bundleId=e,this.createTime=t,this.version=n};$e.store="bundles",$e.keyPath="bundleId";var He=function(e,t,n){this.name=e,this.readTime=t,this.bundledQuery=n};He.store="namedQueries",He.keyPath="name";var Df=$($([],$($([],$($([],$($([],[ee.store,j.store,it.store,z.store,mt.store,It.store,Et.store,nt.store]),[Kt.store])),[Mt.store])),[ve.store])),[$e.store,He.store]),vc="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",mc=function(){function e(){this.onCommittedListeners=[]}return e.prototype.addOnCommittedListener=function(t){this.onCommittedListeners.push(t)},e.prototype.raiseOnCommittedEvent=function(){this.onCommittedListeners.forEach(function(t){return t()})},e}(),kt=function(){var e=this;this.promise=new Promise(function(t,n){e.resolve=t,e.reject=n})},b=function(){function e(t){var n=this;this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t(function(r){n.isDone=!0,n.result=r,n.nextCallback&&n.nextCallback(r)},function(r){n.isDone=!0,n.error=r,n.catchCallback&&n.catchCallback(r)})}return e.prototype.catch=function(t){return this.next(void 0,t)},e.prototype.next=function(t,n){var r=this;return this.callbackAttached&&D(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(t,this.result):new e(function(i,o){r.nextCallback=function(s){r.wrapSuccess(t,s).next(i,o)},r.catchCallback=function(s){r.wrapFailure(n,s).next(i,o)}})},e.prototype.toPromise=function(){var t=this;return new Promise(function(n,r){t.next(n,r)})},e.prototype.wrapUserFunction=function(t){try{var n=t();return n instanceof e?n:e.resolve(n)}catch(r){return e.reject(r)}},e.prototype.wrapSuccess=function(t,n){return t?this.wrapUserFunction(function(){return t(n)}):e.resolve(n)},e.prototype.wrapFailure=function(t,n){return t?this.wrapUserFunction(function(){return t(n)}):e.reject(n)},e.resolve=function(t){return new e(function(n,r){n(t)})},e.reject=function(t){return new e(function(n,r){r(t)})},e.waitFor=function(t){return new e(function(n,r){var i=0,o=0,s=!1;t.forEach(function(u){++i,u.next(function(){++o,s&&o===i&&n()},function(a){return r(a)})}),s=!0,o===i&&n()})},e.or=function(t){for(var n=e.resolve(!1),r=function(s){n=n.next(function(u){return u?e.resolve(u):s()})},i=0,o=t;i"u")return!1;if(e.gt())return!0;var t=Ei(),n=e._t(t),r=00||t.indexOf("Trident/")>0||t.indexOf("Edge/")>0||r||o)},e.gt=function(){var t;return typeof process<"u"&&((t=Vl)===null||t===void 0?void 0:t.Tt)==="YES"},e.It=function(t,n){return t.store(n)},e._t=function(t){var n=t.match(/i(?:phone|pad|pod) os ([\d_]+)/i),r=n?n[1].split("_").slice(0,2).join("."):"-1";return Number(r)},e.Et=function(t){var n=t.match(/Android ([\d.]+)/i),r=n?n[1].split(".").slice(0,2).join("."):"-1";return Number(r)},e.prototype.At=function(t){return g(this,void 0,void 0,function(){var n,r=this;return m(this,function(i){switch(i.label){case 0:return this.db?[3,2]:(I("SimpleDb","Opening database:",this.name),n=this,[4,new Promise(function(o,s){var u=indexedDB.open(r.name,r.version);u.onsuccess=function(a){var c=a.target.result;o(c)},u.onblocked=function(){s(new mn(t,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},u.onerror=function(a){var c=a.target.error;c.name==="VersionError"?s(new w(d.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):s(new mn(t,c))},u.onupgradeneeded=function(a){I("SimpleDb",'Database "'+r.name+'" requires upgrade from version:',a.oldVersion);var c=a.target.result;r.wt.Rt(c,u.transaction,a.oldVersion,r.version).next(function(){I("SimpleDb","Database upgrade to version "+r.version+" complete")})}})]);case 1:n.db=i.sent(),i.label=2;case 2:return[2,(this.bt&&(this.db.onversionchange=function(o){return r.bt(o)}),this.db)]}})})},e.prototype.vt=function(t){this.bt=t,this.db&&(this.db.onversionchange=function(n){return t(n)})},e.prototype.runTransaction=function(t,n,r,i){return g(this,void 0,void 0,function(){var o,s,u,a,c;return m(this,function(h){switch(h.label){case 0:o=n==="readonly",s=0,u=function(){var l,f,y,p,v;return m(this,function(E){switch(E.label){case 0:++s,E.label=1;case 1:return E.trys.push([1,4,,5]),[4,a.At(t)];case 2:return a.db=E.sent(),l=gc.open(a.db,t,o?"readonly":"readwrite",r),f=i(l).catch(function(T){return l.abort(T),b.reject(T)}).toPromise(),y={},f.catch(function(){}),[4,l.dt];case 3:return[2,(y.value=(E.sent(),f),y)];case 4:return p=E.sent(),v=p.name!=="FirebaseError"&&s<3,I("SimpleDb","Transaction failed with error:",p.message,"Retrying:",v),a.close(),v?[3,5]:[2,{value:Promise.reject(p)}];case 5:return[2]}})},a=this,h.label=1;case 1:return[5,u()];case 2:if(typeof(c=h.sent())=="object")return[2,c.value];h.label=3;case 3:return[3,1];case 4:return[2]}})})},e.prototype.close=function(){this.db&&this.db.close(),this.db=void 0},e}(),Nf=function(){function e(t){this.Pt=t,this.Vt=!1,this.St=null}return Object.defineProperty(e.prototype,"isDone",{get:function(){return this.Vt},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"Dt",{get:function(){return this.St},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cursor",{set:function(t){this.Pt=t},enumerable:!1,configurable:!0}),e.prototype.done=function(){this.Vt=!0},e.prototype.Ct=function(t){this.St=t},e.prototype.delete=function(){return fe(this.Pt.delete())},e}(),mn=function(e){function t(n,r){var i=this;return(i=e.call(this,d.UNAVAILABLE,"IndexedDB transaction '"+n+"' failed: "+r)||this).name="IndexedDbTransactionError",i}return C(t,e),t}(w);function De(e){return e.name==="IndexedDbTransactionError"}var Af=function(){function e(t){this.store=t}return e.prototype.put=function(t,n){var r;return n!==void 0?(I("SimpleDb","PUT",this.store.name,t,n),r=this.store.put(n,t)):(I("SimpleDb","PUT",this.store.name,"",t),r=this.store.put(t)),fe(r)},e.prototype.add=function(t){return I("SimpleDb","ADD",this.store.name,t,t),fe(this.store.add(t))},e.prototype.get=function(t){var n=this;return fe(this.store.get(t)).next(function(r){return r===void 0&&(r=null),I("SimpleDb","GET",n.store.name,t,r),r})},e.prototype.delete=function(t){return I("SimpleDb","DELETE",this.store.name,t),fe(this.store.delete(t))},e.prototype.count=function(){return I("SimpleDb","COUNT",this.store.name),fe(this.store.count())},e.prototype.Nt=function(t,n){var r=this.cursor(this.options(t,n)),i=[];return this.xt(r,function(o,s){i.push(s)}).next(function(){return i})},e.prototype.Ft=function(t,n){I("SimpleDb","DELETE ALL",this.store.name);var r=this.options(t,n);r.kt=!1;var i=this.cursor(r);return this.xt(i,function(o,s,u){return u.delete()})},e.prototype.Ot=function(t,n){var r;n?r=t:(r={},n=t);var i=this.cursor(r);return this.xt(i,n)},e.prototype.$t=function(t){var n=this.cursor({});return new b(function(r,i){n.onerror=function(o){var s=Lo(o.target.error);i(s)},n.onsuccess=function(o){var s=o.target.result;s?t(s.primaryKey,s.value).next(function(u){u?s.continue():r()}):r()}})},e.prototype.xt=function(t,n){var r=[];return new b(function(i,o){t.onerror=function(s){o(s.target.error)},t.onsuccess=function(s){var u=s.target.result;if(u){var a=new Nf(u),c=n(u.primaryKey,u.value,a);if(c instanceof b){var h=c.catch(function(l){return a.done(),b.reject(l)});r.push(h)}a.isDone?i():a.Dt===null?u.continue():u.continue(a.Dt)}else i()}}).next(function(){return b.waitFor(r)})},e.prototype.options=function(t,n){var r;return t!==void 0&&(typeof t=="string"?r=t:n=t),{index:r,range:n}},e.prototype.cursor=function(t){var n="next";if(t.reverse&&(n="prev"),t.index){var r=this.store.index(t.index);return t.kt?r.openKeyCursor(t.range,n):r.openCursor(t.range,n)}return this.store.openCursor(t.range,n)},e}();function fe(e){return new b(function(t,n){e.onsuccess=function(r){var i=r.target.result;t(i)},e.onerror=function(r){var i=Lo(r.target.error);n(i)}})}var Hs=!1;function Lo(e){var t=We._t(Ei());if(t>=12.2&&t<13){var n="An internal error was encountered in the Indexed Database server";if(e.message.indexOf(n)>=0){var r=new w("internal","IOS_INDEXEDDB_BUG1: IndexedDb has thrown '"+n+"'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.");return Hs||(Hs=!0,setTimeout(function(){throw r},0)),r}}return e}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */var Ws=function(e){function t(n,r){var i=this;return(i=e.call(this)||this).Mt=n,i.currentSequenceNumber=r,i}return C(t,e),t}(mc);function bt(e,t){var n=_(e);return We.It(n.Mt,t)}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */var Mo=function(){function e(t,n,r,i){this.batchId=t,this.localWriteTime=n,this.baseMutations=r,this.mutations=i}return e.prototype.applyToRemoteDocument=function(t,n){for(var r=n.mutationResults,i=0;i=i),s=Oe(r.R,a)),c.done()}).next(function(){return s})},e.prototype.getHighestUnacknowledgedBatchId=function(t){var n=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),r=-1;return $t(t).Ot({index:j.userMutationsIndex,range:n,reverse:!0},function(i,o,s){r=o.batchId,s.done()}).next(function(){return r})},e.prototype.getAllMutationBatches=function(t){var n=this,r=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return $t(t).Nt(j.userMutationsIndex,r).next(function(i){return i.map(function(o){return Oe(n.R,o)})})},e.prototype.getAllMutationBatchesAffectingDocumentKey=function(t,n){var r=this,i=it.prefixForPath(this.userId,n.path),o=IDBKeyRange.lowerBound(i),s=[];return Pe(t).Ot({range:o},function(u,a,c){var h=u[0],l=u[1],f=u[2],y=Bt(l);if(h===r.userId&&n.path.isEqual(y))return $t(t).get(f).next(function(p){if(!p)throw D();x(p.userId===r.userId),s.push(Oe(r.R,p))});c.done()}).next(function(){return s})},e.prototype.getAllMutationBatchesAffectingDocumentKeys=function(t,n){var r=this,i=new J(L),o=[];return n.forEach(function(s){var u=it.prefixForPath(r.userId,s.path),a=IDBKeyRange.lowerBound(u),c=Pe(t).Ot({range:a},function(h,l,f){var y=h[0],p=h[1],v=h[2],E=Bt(p);y===r.userId&&s.path.isEqual(E)?i=i.add(v):f.done()});o.push(c)}),b.waitFor(o).next(function(){return r.Wt(t,i)})},e.prototype.getAllMutationBatchesAffectingQuery=function(t,n){var r=this,i=n.path,o=i.length+1,s=it.prefixForPath(this.userId,i),u=IDBKeyRange.lowerBound(s),a=new J(L);return Pe(t).Ot({range:u},function(c,h,l){var f=c[0],y=c[1],p=c[2],v=Bt(y);f===r.userId&&i.isPrefixOf(v)?v.length===o&&(a=a.add(p)):l.done()}).next(function(){return r.Wt(t,a)})},e.prototype.Wt=function(t,n){var r=this,i=[],o=[];return n.forEach(function(s){o.push($t(t).get(s).next(function(u){if(u===null)throw D();x(u.userId===r.userId),i.push(Oe(r.R,u))}))}),b.waitFor(o).next(function(){return i})},e.prototype.removeMutationBatch=function(t,n){var r=this;return Tc(t.Mt,this.userId,n).next(function(i){return t.addOnCommittedListener(function(){r.Gt(n.batchId)}),b.forEach(i,function(o){return r.referenceDelegate.markPotentiallyOrphaned(t,o)})})},e.prototype.Gt=function(t){delete this.Qt[t]},e.prototype.performConsistencyCheck=function(t){var n=this;return this.checkEmpty(t).next(function(r){if(!r)return b.resolve();var i=IDBKeyRange.lowerBound(it.prefixForUser(n.userId)),o=[];return Pe(t).Ot({range:i},function(s,u,a){if(s[0]===n.userId){var c=Bt(s[1]);o.push(c)}else a.done()}).next(function(){x(o.length===0)})})},e.prototype.containsKey=function(t,n){return _c(t,this.userId,n)},e.prototype.zt=function(t){var n=this;return Sc(t).get(this.userId).next(function(r){return r||new ee(n.userId,-1,"")})},e}();function _c(e,t,n){var r=it.prefixForPath(t,n.path),i=r[1],o=IDBKeyRange.lowerBound(r),s=!1;return Pe(e).Ot({range:o,kt:!0},function(u,a,c){var h=u[0],l=u[1];u[2],h===t&&l===i&&(s=!0),c.done()}).next(function(){return s})}function $t(e){return bt(e,j.store)}function Pe(e){return bt(e,it.store)}function Sc(e){return bt(e,ee.store)}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */var Nr=function(){function e(t){this.Ht=t}return e.prototype.next=function(){return this.Ht+=2,this.Ht},e.Jt=function(){return new e(0)},e.Yt=function(){return new e(-1)},e}(),Pf=function(){function e(t,n){this.referenceDelegate=t,this.R=n}return e.prototype.allocateTargetId=function(t){var n=this;return this.Xt(t).next(function(r){var i=new Nr(r.highestTargetId);return r.highestTargetId=i.next(),n.Zt(t,r).next(function(){return r.highestTargetId})})},e.prototype.getLastRemoteSnapshotVersion=function(t){return this.Xt(t).next(function(n){return P.fromTimestamp(new gt(n.lastRemoteSnapshotVersion.seconds,n.lastRemoteSnapshotVersion.nanoseconds))})},e.prototype.getHighestSequenceNumber=function(t){return this.Xt(t).next(function(n){return n.highestListenSequenceNumber})},e.prototype.setTargetsMetadata=function(t,n,r){var i=this;return this.Xt(t).next(function(o){return o.highestListenSequenceNumber=n,r&&(o.lastRemoteSnapshotVersion=r.toTimestamp()),n>o.highestListenSequenceNumber&&(o.highestListenSequenceNumber=n),i.Zt(t,o)})},e.prototype.addTargetData=function(t,n){var r=this;return this.te(t,n).next(function(){return r.Xt(t).next(function(i){return i.targetCount+=1,r.ee(n,i),r.Zt(t,i)})})},e.prototype.updateTargetData=function(t,n){return this.te(t,n)},e.prototype.removeTargetData=function(t,n){var r=this;return this.removeMatchingKeysForTargetId(t,n.targetId).next(function(){return Re(t).delete(n.targetId)}).next(function(){return r.Xt(t)}).next(function(i){return x(i.targetCount>0),i.targetCount-=1,r.Zt(t,i)})},e.prototype.removeTargets=function(t,n,r){var i=this,o=0,s=[];return Re(t).Ot(function(u,a){var c=yn(a);c.sequenceNumber<=n&&r.get(c.targetId)===null&&(o++,s.push(i.removeTargetData(t,c)))}).next(function(){return b.waitFor(s)}).next(function(){return o})},e.prototype.forEachTarget=function(t,n){return Re(t).Ot(function(r,i){var o=yn(i);n(o)})},e.prototype.Xt=function(t){return eu(t).get(Et.key).next(function(n){return x(n!==null),n})},e.prototype.Zt=function(t,n){return eu(t).put(Et.key,n)},e.prototype.te=function(t,n){return Re(t).put(Ic(this.R,n))},e.prototype.ee=function(t,n){var r=!1;return t.targetId>n.highestTargetId&&(n.highestTargetId=t.targetId,r=!0),t.sequenceNumber>n.highestListenSequenceNumber&&(n.highestListenSequenceNumber=t.sequenceNumber,r=!0),r},e.prototype.getTargetCount=function(t){return this.Xt(t).next(function(n){return n.targetCount})},e.prototype.getTargetData=function(t,n){var r=Kn(n),i=IDBKeyRange.bound([r,Number.NEGATIVE_INFINITY],[r,Number.POSITIVE_INFINITY]),o=null;return Re(t).Ot({range:i,index:mt.queryTargetsIndexName},function(s,u,a){var c=yn(u);Qr(n,c.target)&&(o=c,a.done())}).next(function(){return o})},e.prototype.addMatchingKeys=function(t,n,r){var i=this,o=[],s=Yt(t);return n.forEach(function(u){var a=Pt(u.path);o.push(s.put(new nt(r,a))),o.push(i.referenceDelegate.addReference(t,r,u))}),b.waitFor(o)},e.prototype.removeMatchingKeys=function(t,n,r){var i=this,o=Yt(t);return b.forEach(n,function(s){var u=Pt(s.path);return b.waitFor([o.delete([r,u]),i.referenceDelegate.removeReference(t,r,s)])})},e.prototype.removeMatchingKeysForTargetId=function(t,n){var r=Yt(t),i=IDBKeyRange.bound([n],[n+1],!1,!0);return r.delete(i)},e.prototype.getMatchingKeysForTargetId=function(t,n){var r=IDBKeyRange.bound([n],[n+1],!1,!0),i=Yt(t),o=B();return i.Ot({range:r,kt:!0},function(s,u,a){var c=Bt(s[1]),h=new N(c);o=o.add(h)}).next(function(){return o})},e.prototype.containsKey=function(t,n){var r=Pt(n.path),i=IDBKeyRange.bound([r],[Va(r)],!1,!0),o=0;return Yt(t).Ot({index:nt.documentTargetsIndex,kt:!0,range:i},function(s,u,a){var c=s[0];s[1],c!==0&&(o++,a.done())}).next(function(){return o>0})},e.prototype.lt=function(t,n){return Re(t).get(n).next(function(r){return r?yn(r):null})},e}();/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Re(e){return bt(e,mt.store)}function eu(e){return bt(e,Et.store)}function Yt(e){return bt(e,nt.store)}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Ne(e){return g(this,void 0,void 0,function(){return m(this,function(t){if(e.code!==d.FAILED_PRECONDITION||e.message!==vc)throw e;return I("LocalStore","Unexpectedly lost primary lease"),[2]})})}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function nu(e,t){var n=e[0],r=e[1],i=t[0],o=t[1],s=L(n,i);return s===0?L(r,o):s}var Lf=function(){function e(t){this.ne=t,this.buffer=new J(nu),this.se=0}return e.prototype.ie=function(){return++this.se},e.prototype.re=function(t){var n=[t,this.ie()];if(this.buffer.sizeh.params.maximumSequenceNumbersToCollect?(I("LruGarbageCollector","Capping sequence numbers to collect down to the maximum of "+h.params.maximumSequenceNumbersToCollect+" from "+f),i=h.params.maximumSequenceNumbersToCollect):i=f,s=Date.now(),h.nthSequenceNumber(t,i)}).next(function(f){return r=f,u=Date.now(),h.removeTargets(t,r,n)}).next(function(f){return o=f,a=Date.now(),h.removeOrphanedDocuments(t,r)}).next(function(f){return c=Date.now(),Li()<=Ue.DEBUG&&I("LruGarbageCollector",`LRU Garbage Collection Counted targets in `+(s-l)+`ms Determined least recently used `+i+" in "+(u-s)+`ms Removed `+o+" targets in "+(a-u)+`ms Removed `+f+" documents in "+(c-a)+`ms Total Duration: `+(c-l)+"ms"),b.resolve({didRun:!0,sequenceNumbersCollected:i,targetsRemoved:o,documentsRemoved:f})})},e}(),Vf=function(){function e(t,n){this.db=t,this.garbageCollector=function(r,i){return new Ff(r,i)}(this,n)}return e.prototype.he=function(t){var n=this.de(t);return this.db.getTargetCache().getTargetCount(t).next(function(r){return n.next(function(i){return r+i})})},e.prototype.de=function(t){var n=0;return this.le(t,function(r){n++}).next(function(){return n})},e.prototype.forEachTarget=function(t,n){return this.db.getTargetCache().forEachTarget(t,n)},e.prototype.le=function(t,n){return this.we(t,function(r,i){return n(i)})},e.prototype.addReference=function(t,n,r){return rr(t,r)},e.prototype.removeReference=function(t,n,r){return rr(t,r)},e.prototype.removeTargets=function(t,n,r){return this.db.getTargetCache().removeTargets(t,n,r)},e.prototype.markPotentiallyOrphaned=function(t,n){return rr(t,n)},e.prototype._e=function(t,n){return function(r,i){var o=!1;return Sc(r).$t(function(s){return _c(r,s,i).next(function(u){return u&&(o=!0),b.resolve(!u)})}).next(function(){return o})}(t,n)},e.prototype.removeOrphanedDocuments=function(t,n){var r=this,i=this.db.getRemoteDocumentCache().newChangeBuffer(),o=[],s=0;return this.we(t,function(u,a){if(a<=n){var c=r._e(t,u).next(function(h){if(!h)return s++,i.getEntry(t,u).next(function(){return i.removeEntry(u),Yt(t).delete([0,Pt(u.path)])})});o.push(c)}}).next(function(){return b.waitFor(o)}).next(function(){return i.apply(t)}).next(function(){return s})},e.prototype.removeTarget=function(t,n){var r=n.withSequenceNumber(t.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(t,r)},e.prototype.updateLimboDocument=function(t,n){return rr(t,n)},e.prototype.we=function(t,n){var r,i=Yt(t),o=St.o;return i.Ot({index:nt.documentTargetsIndex},function(s,u){var a=s[0],c=(s[1],u.path),h=u.sequenceNumber;a===0?(o!==St.o&&n(new N(Bt(r)),o),o=h,r=c):o=St.o}).next(function(){o!==St.o&&n(new N(Bt(r)),o)})},e.prototype.getCacheSize=function(t){return this.db.getRemoteDocumentCache().getSize(t)},e}();function rr(e,t){return Yt(e).put(function(n,r){return new nt(0,Pt(n.path),r)}(t,e.currentSequenceNumber))}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */var sn=function(){function e(t,n){this.mapKeyFn=t,this.equalsFn=n,this.inner={}}return e.prototype.get=function(t){var n=this.mapKeyFn(t),r=this.inner[n];if(r!==void 0)for(var i=0,o=r;i=0&&i<=11);var s=new gc("createOrUpgrade",n);r<1&&i>=1&&(function(a){a.createObjectStore(It.store)}(t),function(a){a.createObjectStore(ee.store,{keyPath:ee.keyPath}),a.createObjectStore(j.store,{keyPath:j.keyPath,autoIncrement:!0}).createIndex(j.userMutationsIndex,j.userMutationsKeyPath,{unique:!0}),a.createObjectStore(it.store)}(t),iu(t),function(a){a.createObjectStore(z.store)}(t));var u=b.resolve();return r<3&&i>=3&&(r!==0&&(function(a){a.deleteObjectStore(nt.store),a.deleteObjectStore(mt.store),a.deleteObjectStore(Et.store)}(t),iu(t)),u=u.next(function(){return function(a){var c=a.store(Et.store),h=new Et(0,0,P.min().toTimestamp(),0);return c.put(Et.key,h)}(s)})),r<4&&i>=4&&(r!==0&&(u=u.next(function(){return function(a,c){return c.store(j.store).Nt().next(function(h){a.deleteObjectStore(j.store),a.createObjectStore(j.store,{keyPath:j.keyPath,autoIncrement:!0}).createIndex(j.userMutationsIndex,j.userMutationsKeyPath,{unique:!0});var l=c.store(j.store),f=h.map(function(y){return l.put(y)});return b.waitFor(f)})}(t,s)})),u=u.next(function(){(function(a){a.createObjectStore(Kt.store,{keyPath:Kt.keyPath})})(t)})),r<5&&i>=5&&(u=u.next(function(){return o.Re(s)})),r<6&&i>=6&&(u=u.next(function(){return function(a){a.createObjectStore(Mt.store)}(t),o.be(s)})),r<7&&i>=7&&(u=u.next(function(){return o.ve(s)})),r<8&&i>=8&&(u=u.next(function(){return o.Pe(t,s)})),r<9&&i>=9&&(u=u.next(function(){(function(a){a.objectStoreNames.contains("remoteDocumentChanges")&&a.deleteObjectStore("remoteDocumentChanges")})(t),function(a){var c=a.objectStore(z.store);c.createIndex(z.readTimeIndex,z.readTimeIndexPath,{unique:!1}),c.createIndex(z.collectionReadTimeIndex,z.collectionReadTimeIndexPath,{unique:!1})}(n)})),r<10&&i>=10&&(u=u.next(function(){return o.Ve(s)})),r<11&&i>=11&&(u=u.next(function(){(function(a){a.createObjectStore($e.store,{keyPath:$e.keyPath})})(t),function(a){a.createObjectStore(He.store,{keyPath:He.keyPath})}(t)})),u},e.prototype.be=function(t){var n=0;return t.store(z.store).Ot(function(r,i){n+=Dr(i)}).next(function(){var r=new Mt(n);return t.store(Mt.store).put(Mt.key,r)})},e.prototype.Re=function(t){var n=this,r=t.store(ee.store),i=t.store(j.store);return r.Nt().next(function(o){return b.forEach(o,function(s){var u=IDBKeyRange.bound([s.userId,-1],[s.userId,s.lastAcknowledgedBatchId]);return i.Nt(j.userMutationsIndex,u).next(function(a){return b.forEach(a,function(c){x(c.userId===s.userId);var h=Oe(n.R,c);return Tc(t,s.userId,h).next(function(){})})})})})},e.prototype.ve=function(t){var n=t.store(nt.store),r=t.store(z.store);return t.store(Et.store).get(Et.key).next(function(i){var o=[];return r.Ot(function(s,u){var a=new V(s),c=function(h){return[0,Pt(h)]}(a);o.push(n.get(c).next(function(h){return h?b.resolve():function(l){return n.put(new nt(0,Pt(l),i.highestListenSequenceNumber))}(a)}))}).next(function(){return b.waitFor(o)})})},e.prototype.Pe=function(t,n){t.createObjectStore(ve.store,{keyPath:ve.keyPath});var r=n.store(ve.store),i=new Vo,o=function(s){if(i.add(s)){var u=s.lastSegment(),a=s.popLast();return r.put({collectionId:u,parent:Pt(a)})}};return n.store(z.store).Ot({kt:!0},function(s,u){var a=new V(s);return o(a.popLast())}).next(function(){return n.store(it.store).Ot({kt:!0},function(s,u){s[0];var a=s[1],c=(s[2],Bt(a));return o(c.popLast())})})},e.prototype.Ve=function(t){var n=this,r=t.store(mt.store);return r.Ot(function(i,o){var s=yn(o),u=Ic(n.R,s);return r.put(u)})},e}();function iu(e){e.createObjectStore(nt.store,{keyPath:nt.keyPath}).createIndex(nt.documentTargetsIndex,nt.documentTargetsKeyPath,{unique:!0}),e.createObjectStore(mt.store,{keyPath:mt.keyPath}).createIndex(mt.queryTargetsIndexName,mt.queryTargetsKeyPath,{unique:!0}),e.createObjectStore(Et.store)}var gi="Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.",jf=function(){function e(t,n,r,i,o,s,u,a,c,h){if(this.allowTabSynchronization=t,this.persistenceKey=n,this.clientId=r,this.Se=o,this.window=s,this.document=u,this.De=c,this.Ce=h,this.Ne=null,this.xe=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Fe=null,this.inForeground=!1,this.ke=null,this.Oe=null,this.$e=Number.NEGATIVE_INFINITY,this.Me=function(l){return Promise.resolve()},!e.yt())throw new w(d.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new Vf(this,i),this.Le=n+"main",this.R=new wc(a),this.Be=new We(this.Le,11,new Bf(this.R)),this.qe=new Pf(this.referenceDelegate,this.R),this.Ut=new Rf,this.Ue=function(l,f){return new Uf(l,f)}(this.R,this.Ut),this.Qe=new kf,this.window&&this.window.localStorage?this.Ke=this.window.localStorage:(this.Ke=null,h===!1&&W("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}return e.prototype.start=function(){var t=this;return this.je().then(function(){if(!t.isPrimary&&!t.allowTabSynchronization)throw new w(d.FAILED_PRECONDITION,gi);return t.We(),t.Ge(),t.ze(),t.runTransaction("getHighestListenSequenceNumber","readonly",function(n){return t.qe.getHighestSequenceNumber(n)})}).then(function(n){t.Ne=new St(n,t.De)}).then(function(){t.xe=!0}).catch(function(n){return t.Be&&t.Be.close(),Promise.reject(n)})},e.prototype.He=function(t){var n=this;return this.Me=function(r){return g(n,void 0,void 0,function(){return m(this,function(i){return this.started?[2,t(r)]:[2]})})},t(this.isPrimary)},e.prototype.setDatabaseDeletedListener=function(t){var n=this;this.Be.vt(function(r){return g(n,void 0,void 0,function(){return m(this,function(i){switch(i.label){case 0:return r.newVersion===null?[4,t()]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}})})})},e.prototype.setNetworkEnabled=function(t){var n=this;this.networkEnabled!==t&&(this.networkEnabled=t,this.Se.enqueueAndForget(function(){return g(n,void 0,void 0,function(){return m(this,function(r){switch(r.label){case 0:return this.started?[4,this.je()]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}})})}))},e.prototype.je=function(){var t=this;return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",function(n){return or(n).put(new Kt(t.clientId,Date.now(),t.networkEnabled,t.inForeground)).next(function(){if(t.isPrimary)return t.Je(n).next(function(r){r||(t.isPrimary=!1,t.Se.enqueueRetryable(function(){return t.Me(!1)}))})}).next(function(){return t.Ye(n)}).next(function(r){return t.isPrimary&&!r?t.Xe(n).next(function(){return!1}):!!r&&t.Ze(n).next(function(){return!0})})}).catch(function(n){if(De(n))return I("IndexedDbPersistence","Failed to extend owner lease: ",n),t.isPrimary;if(!t.allowTabSynchronization)throw n;return I("IndexedDbPersistence","Releasing owner lease after error during lease refresh",n),!1}).then(function(n){t.isPrimary!==n&&t.Se.enqueueRetryable(function(){return t.Me(n)}),t.isPrimary=n})},e.prototype.Je=function(t){var n=this;return pn(t).get(It.key).next(function(r){return b.resolve(n.tn(r))})},e.prototype.en=function(t){return or(t).delete(this.clientId)},e.prototype.nn=function(){return g(this,void 0,void 0,function(){var t,n,r,i,o=this;return m(this,function(s){switch(s.label){case 0:return!this.isPrimary||this.sn(this.$e,18e5)?[3,2]:(this.$e=Date.now(),[4,this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",function(u){var a=bt(u,Kt.store);return a.Nt().next(function(c){var h=o.rn(c,18e5),l=c.filter(function(f){return h.indexOf(f)===-1});return b.forEach(l,function(f){return a.delete(f.clientId)}).next(function(){return l})})}).catch(function(){return[]})]);case 1:if(t=s.sent(),this.Ke)for(n=0,r=t;nr&&(W("Detected an update time that is in the future: "+t+" > "+r),1))},e.prototype.We=function(){var t=this;this.document!==null&&typeof this.document.addEventListener=="function"&&(this.ke=function(){t.Se.enqueueAndForget(function(){return t.inForeground=t.document.visibilityState==="visible",t.je()})},this.document.addEventListener("visibilitychange",this.ke),this.inForeground=this.document.visibilityState==="visible")},e.prototype.an=function(){this.ke&&(this.document.removeEventListener("visibilitychange",this.ke),this.ke=null)},e.prototype.Ge=function(){var t,n=this;typeof((t=this.window)===null||t===void 0?void 0:t.addEventListener)=="function"&&(this.Fe=function(){n.un(),n.Se.enqueueAndForget(function(){return n.shutdown()})},this.window.addEventListener("unload",this.Fe))},e.prototype.hn=function(){this.Fe&&(this.window.removeEventListener("unload",this.Fe),this.Fe=null)},e.prototype.cn=function(t){var n;try{var r=((n=this.Ke)===null||n===void 0?void 0:n.getItem(this.on(t)))!==null;return I("IndexedDbPersistence","Client '"+t+"' "+(r?"is":"is not")+" zombied in LocalStorage"),r}catch(i){return W("IndexedDbPersistence","Failed to get zombied client id.",i),!1}},e.prototype.un=function(){if(this.Ke)try{this.Ke.setItem(this.on(this.clientId),String(Date.now()))}catch(t){W("Failed to set zombie client id.",t)}},e.prototype.ln=function(){if(this.Ke)try{this.Ke.removeItem(this.on(this.clientId))}catch{}},e.prototype.on=function(t){return"firestore_zombie_"+this.persistenceKey+"_"+t},e}();function pn(e){return bt(e,It.store)}function or(e){return bt(e,Kt.store)}function Uo(e,t){var n=e.projectId;return e.isDefaultDatabase||(n+="."+e.database),"firestore/"+t+"/"+n+"/"}var Nc=function(){function e(t,n,r){this.Ue=t,this._n=n,this.Ut=r}return e.prototype.mn=function(t,n){var r=this;return this._n.getAllMutationBatchesAffectingDocumentKey(t,n).next(function(i){return r.yn(t,n,i)})},e.prototype.yn=function(t,n,r){return this.Ue.getEntry(t,n).next(function(i){for(var o=0,s=r;o0)},e.prototype.Dn=function(t,n){return Li()<=Ue.DEBUG&&I("QueryEngine","Using full collection scan to execute query:",qi(n)),this.Sn.getDocumentsMatchingQuery(t,n,P.min())},e}(),Gf=function(){function e(t,n,r,i){this.persistence=t,this.xn=n,this.R=i,this.Fn=new ht(L),this.kn=new sn(function(o){return Kn(o)},Qr),this.On=P.min(),this._n=t.getMutationQueue(r),this.$n=t.getRemoteDocumentCache(),this.qe=t.getTargetCache(),this.Mn=new Nc(this.$n,this._n,this.persistence.getIndexManager()),this.Qe=t.getBundleCache(),this.xn.Vn(this.Mn)}return e.prototype.collectGarbage=function(t){var n=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary",function(r){return t.collect(r,n.Fn)})},e}();/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Cc(e,t,n,r){return new Gf(e,t,n,r)}function kc(e,t){return g(this,void 0,void 0,function(){var n,r,i,o;return m(this,function(s){switch(s.label){case 0:return n=_(e),r=n._n,i=n.Mn,[4,n.persistence.runTransaction("Handle user change","readonly",function(u){var a;return n._n.getAllMutationBatches(u).next(function(c){return a=c,r=n.persistence.getMutationQueue(t),i=new Nc(n.$n,r,n.persistence.getIndexManager()),r.getAllMutationBatches(u)}).next(function(c){for(var h=[],l=[],f=B(),y=0,p=a;y0){var p=f.withResumeToken(y,r).withSequenceNumber(o.currentSequenceNumber);i=i.insert(l,p),function(v,E,T){return x(E.resumeToken.approximateByteSize()>0),v.resumeToken.approximateByteSize()===0||E.snapshotVersion.toMicroseconds()-v.snapshotVersion.toMicroseconds()>=3e8||T.addedDocuments.size+T.modifiedDocuments.size+T.removedDocuments.size>0}(f,p,h)&&u.push(n.qe.updateTargetData(o,p))}}});var a=Ot();if(t.documentUpdates.forEach(function(h,l){t.resolvedLimboDocuments.has(h)&&u.push(n.persistence.referenceDelegate.updateLimboDocument(o,h))}),u.push($f(o,s,t.documentUpdates,r,void 0).next(function(h){a=h})),!r.isEqual(P.min())){var c=n.qe.getLastRemoteSnapshotVersion(o).next(function(h){return n.qe.setTargetsMetadata(o,o.currentSequenceNumber,r)});u.push(c)}return b.waitFor(u).next(function(){return s.apply(o)}).next(function(){return n.Mn.En(o,a)}).next(function(){return a})}).then(function(o){return n.Fn=i,o})}function $f(e,t,n,r,i){var o=B();return n.forEach(function(s){return o=o.add(s)}),t.getEntries(e,o).next(function(s){var u=Ot();return n.forEach(function(a,c){var h=s.get(a),l=(i==null?void 0:i.get(a))||r;c.isNoDocument()&&c.version.isEqual(P.min())?(t.removeEntry(a,l),u=u.insert(a,c)):!h.isValidDocument()||c.version.compareTo(h.version)>0||c.version.compareTo(h.version)===0&&h.hasPendingWrites?(t.addEntry(c,l),u=u.insert(a,c)):I("LocalStore","Ignoring outdated watch update for ",a,". Current version:",h.version," Watch version:",c.version)}),u})}function Hf(e,t){var n=_(e);return n.persistence.runTransaction("Get next mutation batch","readonly",function(r){return t===void 0&&(t=-1),n._n.getNextMutationBatchAfterBatchId(r,t)})}function Ar(e,t){var n=_(e);return n.persistence.runTransaction("Allocate target","readwrite",function(r){var i;return n.qe.getTargetData(r,t).next(function(o){return o?(i=o,b.resolve(i)):n.qe.allocateTargetId(r).next(function(s){return i=new Xr(t,s,0,r.currentSequenceNumber),n.qe.addTargetData(r,i).next(function(){return i})})})}).then(function(r){var i=n.Fn.get(r.targetId);return(i===null||r.snapshotVersion.compareTo(i.snapshotVersion)>0)&&(n.Fn=n.Fn.insert(r.targetId,r),n.kn.set(t,r.targetId)),r})}function Je(e,t,n){return g(this,void 0,void 0,function(){var r,i,o,s;return m(this,function(u){switch(u.label){case 0:r=_(e),i=r.Fn.get(t),o=n?"readwrite":"readwrite-primary",u.label=1;case 1:return u.trys.push([1,4,,5]),n?[3,3]:[4,r.persistence.runTransaction("Release target",o,function(a){return r.persistence.referenceDelegate.removeTarget(a,i)})];case 2:u.sent(),u.label=3;case 3:return[3,5];case 4:if(!De(s=u.sent()))throw s;return I("LocalStore","Failed to update sequence numbers for target "+t+": "+s),[3,5];case 5:return r.Fn=r.Fn.remove(t),r.kn.delete(i.target),[2]}})})}function Cr(e,t,n){var r=_(e),i=P.min(),o=B();return r.persistence.runTransaction("Execute query","readonly",function(s){return function(u,a,c){var h=_(u),l=h.kn.get(c);return l!==void 0?b.resolve(h.Fn.get(l)):h.qe.getTargetData(a,c)}(r,s,Ut(t)).next(function(u){if(u)return i=u.lastLimboFreeSnapshotVersion,r.qe.getMatchingKeysForTargetId(s,u.targetId).next(function(a){o=a})}).next(function(){return r.xn.getDocumentsMatchingQuery(s,t,n?i:P.min(),n?o:B())}).next(function(u){return{documents:u,Bn:o}})})}function Rc(e,t){var n=_(e),r=_(n.qe),i=n.Fn.get(t);return i?Promise.resolve(i.target):n.persistence.runTransaction("Get target data","readonly",function(o){return r.lt(o,t).next(function(s){return s?s.target:null})})}function Oc(e){var t=_(e);return t.persistence.runTransaction("Get new document changes","readonly",function(n){return function(r,i,o){var s=_(r),u=Ot(),a=Fo(o),c=Wt(i),h=IDBKeyRange.lowerBound(a,!0);return c.Ot({index:z.readTimeIndex,range:h},function(l,f){var y=Gi(s.R,f);u=u.insert(y.key,y),a=f.readTime}).next(function(){return{wn:u,readTime:bc(a)}})}(t.$n,n,t.On)}).then(function(n){var r=n.wn,i=n.readTime;return t.On=i,r})}function Wf(e){return g(this,void 0,void 0,function(){var t;return m(this,function(n){return[2,(t=_(e)).persistence.runTransaction("Synchronize last document change read time","readonly",function(r){return function(i){var o=Wt(i),s=P.min();return o.Ot({index:z.readTimeIndex,reverse:!0},function(u,a,c){a.readTime&&(s=bc(a.readTime)),c.done()}).next(function(){return s})}(r)}).then(function(r){t.On=r})]})})}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */var Xf=function(){function e(t){this.R=t,this.Kn=new Map,this.jn=new Map}return e.prototype.getBundleMetadata=function(t,n){return b.resolve(this.Kn.get(n))},e.prototype.saveBundleMetadata=function(t,n){var r;return this.Kn.set(n.id,{id:(r=n).id,version:r.version,createTime:yt(r.createTime)}),b.resolve()},e.prototype.getNamedQuery=function(t,n){return b.resolve(this.jn.get(n))},e.prototype.saveNamedQuery=function(t,n){return this.jn.set(n.name,function(r){return{name:r.name,query:Ec(r.bundledQuery),readTime:yt(r.readTime)}}(n)),b.resolve()},e}(),qo=function(){function e(){this.Wn=new J(tt.Gn),this.zn=new J(tt.Hn)}return e.prototype.isEmpty=function(){return this.Wn.isEmpty()},e.prototype.addReference=function(t,n){var r=new tt(t,n);this.Wn=this.Wn.add(r),this.zn=this.zn.add(r)},e.prototype.Jn=function(t,n){var r=this;t.forEach(function(i){return r.addReference(i,n)})},e.prototype.removeReference=function(t,n){this.Yn(new tt(t,n))},e.prototype.Xn=function(t,n){var r=this;t.forEach(function(i){return r.removeReference(i,n)})},e.prototype.Zn=function(t){var n=this,r=new N(new V([])),i=new tt(r,t),o=new tt(r,t+1),s=[];return this.zn.forEachInRange([i,o],function(u){n.Yn(u),s.push(u.key)}),s},e.prototype.ts=function(){var t=this;this.Wn.forEach(function(n){return t.Yn(n)})},e.prototype.Yn=function(t){this.Wn=this.Wn.delete(t),this.zn=this.zn.delete(t)},e.prototype.es=function(t){var n=new N(new V([])),r=new tt(n,t),i=new tt(n,t+1),o=B();return this.zn.forEachInRange([r,i],function(s){o=o.add(s.key)}),o},e.prototype.containsKey=function(t){var n=new tt(t,0),r=this.Wn.firstAfterOrEqual(n);return r!==null&&t.isEqual(r.key)},e}(),tt=function(){function e(t,n){this.key=t,this.ns=n}return e.Gn=function(t,n){return N.comparator(t.key,n.key)||L(t.ns,n.ns)},e.Hn=function(t,n){return L(t.ns,n.ns)||N.comparator(t.key,n.key)},e}(),Yf=function(){function e(t,n){this.Ut=t,this.referenceDelegate=n,this._n=[],this.ss=1,this.rs=new J(tt.Gn)}return e.prototype.checkEmpty=function(t){return b.resolve(this._n.length===0)},e.prototype.addMutationBatch=function(t,n,r,i){var o=this.ss;this.ss++,this._n.length>0&&this._n[this._n.length-1];var s=new Mo(o,n,r,i);this._n.push(s);for(var u=0,a=i;uo?this._n[o]:null)},e.prototype.getHighestUnacknowledgedBatchId=function(){return b.resolve(this._n.length===0?-1:this.ss-1)},e.prototype.getAllMutationBatches=function(t){return b.resolve(this._n.slice())},e.prototype.getAllMutationBatchesAffectingDocumentKey=function(t,n){var r=this,i=new tt(n,0),o=new tt(n,Number.POSITIVE_INFINITY),s=[];return this.rs.forEachInRange([i,o],function(u){var a=r.os(u.ns);s.push(a)}),b.resolve(s)},e.prototype.getAllMutationBatchesAffectingDocumentKeys=function(t,n){var r=this,i=new J(L);return n.forEach(function(o){var s=new tt(o,0),u=new tt(o,Number.POSITIVE_INFINITY);r.rs.forEachInRange([s,u],function(a){i=i.add(a.ns)})}),b.resolve(this.us(i))},e.prototype.getAllMutationBatchesAffectingQuery=function(t,n){var r=n.path,i=r.length+1,o=r;N.isDocumentKey(o)||(o=o.child(""));var s=new tt(new N(o),0),u=new J(L);return this.rs.forEachWhile(function(a){var c=a.key.path;return!!r.isPrefixOf(c)&&(c.length===i&&(u=u.add(a.ns)),!0)},s),b.resolve(this.us(u))},e.prototype.us=function(t){var n=this,r=[];return t.forEach(function(i){var o=n.os(i);o!==null&&r.push(o)}),r},e.prototype.removeMutationBatch=function(t,n){var r=this;x(this.hs(n.batchId,"removed")===0),this._n.shift();var i=this.rs;return b.forEach(n.mutations,function(o){var s=new tt(o.key,n.batchId);return i=i.delete(s),r.referenceDelegate.markPotentiallyOrphaned(t,o.key)}).next(function(){r.rs=i})},e.prototype.Gt=function(t){},e.prototype.containsKey=function(t,n){var r=new tt(n,0),i=this.rs.firstAfterOrEqual(r);return b.resolve(n.isEqual(i&&i.key))},e.prototype.performConsistencyCheck=function(t){return this._n.length,b.resolve()},e.prototype.hs=function(t,n){return this.cs(t)},e.prototype.cs=function(t){return this._n.length===0?0:t-this._n[0].batchId},e.prototype.os=function(t){var n=this.cs(t);return n<0||n>=this._n.length?null:this._n[n]},e}(),Jf=function(){function e(t,n){this.Ut=t,this.ls=n,this.docs=new ht(N.comparator),this.size=0}return e.prototype.addEntry=function(t,n,r){var i=n.key,o=this.docs.get(i),s=o?o.size:0,u=this.ls(n);return this.docs=this.docs.insert(i,{document:n.clone(),size:u,readTime:r}),this.size+=u-s,this.Ut.addToCollectionParentIndex(t,i.path.popLast())},e.prototype.removeEntry=function(t){var n=this.docs.get(t);n&&(this.docs=this.docs.remove(t),this.size-=n.size)},e.prototype.getEntry=function(t,n){var r=this.docs.get(n);return b.resolve(r?r.document.clone():ct.newInvalidDocument(n))},e.prototype.getEntries=function(t,n){var r=this,i=Ot();return n.forEach(function(o){var s=r.docs.get(o);i=i.insert(o,s?s.document.clone():ct.newInvalidDocument(o))}),b.resolve(i)},e.prototype.getDocumentsMatchingQuery=function(t,n,r){for(var i=Ot(),o=new N(n.path.child("")),s=this.docs.getIteratorFrom(o);s.hasNext();){var u=s.getNext(),a=u.key,c=u.value,h=c.document,l=c.readTime;if(!n.path.isPrefixOf(a.path))break;l.compareTo(r)<=0||Qn(n,h)&&(i=i.insert(h.key,h.clone()))}return b.resolve(i)},e.prototype.fs=function(t,n){return b.forEach(this.docs,function(r){return n(r)})},e.prototype.newChangeBuffer=function(t){return new Zf(this)},e.prototype.getSize=function(t){return b.resolve(this.size)},e}(),Zf=function(e){function t(n){var r=this;return(r=e.call(this)||this).Ie=n,r}return C(t,e),t.prototype.applyChanges=function(n){var r=this,i=[];return this.changes.forEach(function(o,s){s.document.isValidDocument()?i.push(r.Ie.addEntry(n,s.document,r.getReadTime(o))):r.Ie.removeEntry(o)}),b.waitFor(i)},t.prototype.getFromCache=function(n,r){return this.Ie.getEntry(n,r)},t.prototype.getAllFromCache=function(n,r){return this.Ie.getEntries(n,r)},t}(Dc),tp=function(){function e(t){this.persistence=t,this.ds=new sn(function(n){return Kn(n)},Qr),this.lastRemoteSnapshotVersion=P.min(),this.highestTargetId=0,this.ws=0,this._s=new qo,this.targetCount=0,this.ys=Nr.Jt()}return e.prototype.forEachTarget=function(t,n){return this.ds.forEach(function(r,i){return n(i)}),b.resolve()},e.prototype.getLastRemoteSnapshotVersion=function(t){return b.resolve(this.lastRemoteSnapshotVersion)},e.prototype.getHighestSequenceNumber=function(t){return b.resolve(this.ws)},e.prototype.allocateTargetId=function(t){return this.highestTargetId=this.ys.next(),b.resolve(this.highestTargetId)},e.prototype.setTargetsMetadata=function(t,n,r){return r&&(this.lastRemoteSnapshotVersion=r),n>this.ws&&(this.ws=n),b.resolve()},e.prototype.te=function(t){this.ds.set(t.target,t);var n=t.targetId;n>this.highestTargetId&&(this.ys=new Nr(n),this.highestTargetId=n),t.sequenceNumber>this.ws&&(this.ws=t.sequenceNumber)},e.prototype.addTargetData=function(t,n){return this.te(n),this.targetCount+=1,b.resolve()},e.prototype.updateTargetData=function(t,n){return this.te(n),b.resolve()},e.prototype.removeTargetData=function(t,n){return this.ds.delete(n.target),this._s.Zn(n.targetId),this.targetCount-=1,b.resolve()},e.prototype.removeTargets=function(t,n,r){var i=this,o=0,s=[];return this.ds.forEach(function(u,a){a.sequenceNumber<=n&&r.get(a.targetId)===null&&(i.ds.delete(u),s.push(i.removeMatchingKeysForTargetId(t,a.targetId)),o++)}),b.waitFor(s).next(function(){return o})},e.prototype.getTargetCount=function(t){return b.resolve(this.targetCount)},e.prototype.getTargetData=function(t,n){var r=this.ds.get(n)||null;return b.resolve(r)},e.prototype.addMatchingKeys=function(t,n,r){return this._s.Jn(n,r),b.resolve()},e.prototype.removeMatchingKeys=function(t,n,r){this._s.Xn(n,r);var i=this.persistence.referenceDelegate,o=[];return i&&n.forEach(function(s){o.push(i.markPotentiallyOrphaned(t,s))}),b.waitFor(o)},e.prototype.removeMatchingKeysForTargetId=function(t,n){return this._s.Zn(n),b.resolve()},e.prototype.getMatchingKeysForTargetId=function(t,n){var r=this._s.es(n);return b.resolve(r)},e.prototype.containsKey=function(t,n){return b.resolve(this._s.containsKey(n))},e}(),ep=function(){function e(t,n){var r=this;this.gs={},this.Ne=new St(0),this.xe=!1,this.xe=!0,this.referenceDelegate=t(this),this.qe=new tp(this),this.Ut=new xf,this.Ue=function(i,o){return new Jf(i,function(s){return r.referenceDelegate.ps(s)})}(this.Ut),this.R=new wc(n),this.Qe=new Xf(this.R)}return e.prototype.start=function(){return Promise.resolve()},e.prototype.shutdown=function(){return this.xe=!1,Promise.resolve()},Object.defineProperty(e.prototype,"started",{get:function(){return this.xe},enumerable:!1,configurable:!0}),e.prototype.setDatabaseDeletedListener=function(){},e.prototype.setNetworkEnabled=function(){},e.prototype.getIndexManager=function(){return this.Ut},e.prototype.getMutationQueue=function(t){var n=this.gs[t.toKey()];return n||(n=new Yf(this.Ut,this.referenceDelegate),this.gs[t.toKey()]=n),n},e.prototype.getTargetCache=function(){return this.qe},e.prototype.getRemoteDocumentCache=function(){return this.Ue},e.prototype.getBundleCache=function(){return this.Qe},e.prototype.runTransaction=function(t,n,r){var i=this;I("MemoryPersistence","Starting transaction:",t);var o=new np(this.Ne.next());return this.referenceDelegate.Es(),r(o).next(function(s){return i.referenceDelegate.Ts(o).next(function(){return s})}).toPromise().then(function(s){return o.raiseOnCommittedEvent(),s})},e.prototype.Is=function(t,n){return b.or(Object.values(this.gs).map(function(r){return function(){return r.containsKey(t,n)}}))},e}(),np=function(e){function t(n){var r=this;return(r=e.call(this)||this).currentSequenceNumber=n,r}return C(t,e),t}(mc),rp=function(){function e(t){this.persistence=t,this.As=new qo,this.Rs=null}return e.bs=function(t){return new e(t)},Object.defineProperty(e.prototype,"vs",{get:function(){if(this.Rs)return this.Rs;throw D()},enumerable:!1,configurable:!0}),e.prototype.addReference=function(t,n,r){return this.As.addReference(r,n),this.vs.delete(r.toString()),b.resolve()},e.prototype.removeReference=function(t,n,r){return this.As.removeReference(r,n),this.vs.add(r.toString()),b.resolve()},e.prototype.markPotentiallyOrphaned=function(t,n){return this.vs.add(n.toString()),b.resolve()},e.prototype.removeTarget=function(t,n){var r=this;this.As.Zn(n.targetId).forEach(function(o){return r.vs.add(o.toString())});var i=this.persistence.getTargetCache();return i.getMatchingKeysForTargetId(t,n.targetId).next(function(o){o.forEach(function(s){return r.vs.add(s.toString())})}).next(function(){return i.removeTargetData(t,n)})},e.prototype.Es=function(){this.Rs=new Set},e.prototype.Ts=function(t){var n=this,r=this.persistence.getRemoteDocumentCache().newChangeBuffer();return b.forEach(this.vs,function(i){var o=N.fromPath(i);return n.Ps(t,o).next(function(s){s||r.removeEntry(o)})}).next(function(){return n.Rs=null,r.apply(t)})},e.prototype.updateLimboDocument=function(t,n){var r=this;return this.Ps(t,n).next(function(i){i?r.vs.delete(n.toString()):r.vs.add(n.toString())})},e.prototype.ps=function(t){return 0},e.prototype.Ps=function(t,n){var r=this;return b.or([function(){return b.resolve(r.As.containsKey(n))},function(){return r.persistence.getTargetCache().containsKey(t,n)},function(){return r.persistence.Is(t,n)}])},e}(),Tt=function(){function e(t){this.uid=t}return e.prototype.isAuthenticated=function(){return this.uid!=null},e.prototype.toKey=function(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"},e.prototype.isEqual=function(t){return t.uid===this.uid},e}();/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function ou(e,t){return"firestore_clients_"+e+"_"+t}function su(e,t,n){var r="firestore_mutations_"+e+"_"+n;return t.isAuthenticated()&&(r+="_"+t.uid),r}function wi(e,t){return"firestore_targets_"+e+"_"+t}Tt.UNAUTHENTICATED=new Tt(null),Tt.GOOGLE_CREDENTIALS=new Tt("google-credentials-uid"),Tt.FIRST_PARTY=new Tt("first-party-uid");var uu=function(){function e(t,n,r,i){this.user=t,this.batchId=n,this.state=r,this.error=i}return e.Vs=function(t,n,r){var i,o=JSON.parse(r),s=typeof o=="object"&&["pending","acknowledged","rejected"].indexOf(o.state)!==-1&&(o.error===void 0||typeof o.error=="object");return s&&o.error&&(s=typeof o.error.message=="string"&&typeof o.error.code=="string")&&(i=new w(o.error.code,o.error.message)),s?new e(t,n,o.state,i):(W("SharedClientState","Failed to parse mutation state for ID '"+n+"': "+r),null)},e.prototype.Ss=function(){var t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)},e}(),bi=function(){function e(t,n,r){this.targetId=t,this.state=n,this.error=r}return e.Vs=function(t,n){var r,i=JSON.parse(n),o=typeof i=="object"&&["not-current","current","rejected"].indexOf(i.state)!==-1&&(i.error===void 0||typeof i.error=="object");return o&&i.error&&(o=typeof i.error.message=="string"&&typeof i.error.code=="string")&&(r=new w(i.error.code,i.error.message)),o?new e(t,i.state,r):(W("SharedClientState","Failed to parse target state for ID '"+t+"': "+n),null)},e.prototype.Ss=function(){var t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)},e}(),au=function(){function e(t,n){this.clientId=t,this.activeTargetIds=n}return e.Vs=function(t,n){for(var r=JSON.parse(n),i=typeof r=="object"&&r.activeTargetIds instanceof Array,o=Wr(),s=0;i&&s0){var f=a.getResponseJson().error;if(f&&f.status&&f.message){var y=function(p){var v=p.toLowerCase().replace(/_/g,"-");return Object.values(d).indexOf(v)>=0?v:d.UNKNOWN}(f.status);u(new w(y,f.message))}else u(new w(d.UNKNOWN,"Server responded with status "+a.getStatus()))}else u(new w(d.UNAVAILABLE,"Connection failed."));break;default:D()}}finally{I("Connection",'RPC "'+n+'" completed.')}});var c=JSON.stringify(o);a.send(r,"POST",c,i,15)})},t.prototype.$i=function(n,r){var i=[this.Di,"/","google.firestore.v1.Firestore","/",n,"/channel"],o=Ol(),s=Pl(),u={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};this.Fi(u.initMessageHeaders,r),Sh()||Dh()||Nh()||Ah()||Ch()||kh()||(u.httpHeadersOverwriteParam="$httpHeaders");var a=i.join("");I("Connection","Creating WebChannel: "+a,u);var c=o.createWebChannel(a,u),h=!1,l=!1,f=new up({Ei:function(p){l?I("Connection","Not sending because WebChannel is closed:",p):(h||(I("Connection","Opening WebChannel transport."),c.open(),h=!0),I("Connection","WebChannel sending:",p),c.send(p))},Ti:function(){return c.close()}}),y=function(p,v,E){p.listen(v,function(T){try{E(T)}catch(k){setTimeout(function(){throw k},0)}})};return y(c,er.EventType.OPEN,function(){l||I("Connection","WebChannel transport opened.")}),y(c,er.EventType.CLOSE,function(){l||(l=!0,I("Connection","WebChannel transport closed"),f.Vi())}),y(c,er.EventType.ERROR,function(p){l||(l=!0,Mi("Connection","WebChannel transport errored:",p),f.Vi(new w(d.UNAVAILABLE,"The operation could not be completed")))}),y(c,er.EventType.MESSAGE,function(p){var v;if(!l){var E=p.data[0];x(!!E);var T=E,k=T.error||((v=T[0])===null||v===void 0?void 0:v.error);if(k){I("Connection","WebChannel received error:",k);var A=k.status,O=function(q){var et=Q[q];if(et!==void 0)return ic(et)}(A),M=k.message;O===void 0&&(O=d.INTERNAL,M="Unknown error status: "+A+" with message "+k.message),l=!0,f.Vi(new w(O,M)),c.close()}else I("Connection","WebChannel received:",E),f.Si(E)}}),y(s,Ml.STAT_EVENT,function(p){p.stat===Ds.PROXY?I("Connection","Detected buffering proxy"):p.stat===Ds.NOPROXY&&I("Connection","Detected no buffering proxy")}),setTimeout(function(){f.Pi()},0),f},t}(function(){function e(t){this.databaseInfo=t,this.databaseId=t.databaseId;var n=t.ssl?"https":"http";this.Di=n+"://"+t.host,this.Ci="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}return e.prototype.Ni=function(t,n,r,i){var o=this.xi(t,n);I("RestConnection","Sending: ",o,r);var s={};return this.Fi(s,i),this.ki(t,o,s,r).then(function(u){return I("RestConnection","Received: ",u),u},function(u){throw Mi("RestConnection",t+" failed with error: ",u,"url: ",o,"request:",r),u})},e.prototype.Oi=function(t,n,r,i){return this.Ni(t,n,r,i)},e.prototype.Fi=function(t,n){if(t["X-Goog-Api-Client"]="gl-js/ fire/8.3.3",t["X-Firebase-GMPID"]=this.databaseInfo.appId,t["Content-Type"]="text/plain",n)for(var r in n.authHeaders)n.authHeaders.hasOwnProperty(r)&&(t[r]=n.authHeaders[r])},e.prototype.xi=function(t,n){var r=sp[t];return this.Di+"/v1/"+n+":"+r},e}());/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *//** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Lc(){return typeof window<"u"?window:null}function cr(){return typeof document<"u"?document:null}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Yr(e){return new df(e,!0)}var Bo=function(){function e(t,n,r,i,o){r===void 0&&(r=1e3),i===void 0&&(i=1.5),o===void 0&&(o=6e4),this.Se=t,this.timerId=n,this.Mi=r,this.Li=i,this.Bi=o,this.qi=0,this.Ui=null,this.Qi=Date.now(),this.reset()}return e.prototype.reset=function(){this.qi=0},e.prototype.Ki=function(){this.qi=this.Bi},e.prototype.ji=function(t){var n=this;this.cancel();var r=Math.floor(this.qi+this.Wi()),i=Math.max(0,Date.now()-this.Qi),o=Math.max(0,r-i);o>0&&I("ExponentialBackoff","Backing off for "+o+" ms (base delay: "+this.qi+" ms, delay with jitter: "+r+" ms, last attempt: "+i+" ms ago)"),this.Ui=this.Se.enqueueAfterDelay(this.timerId,o,function(){return n.Qi=Date.now(),t()}),this.qi*=this.Li,this.qithis.Bi&&(this.qi=this.Bi)},e.prototype.Gi=function(){this.Ui!==null&&(this.Ui.skipDelay(),this.Ui=null)},e.prototype.cancel=function(){this.Ui!==null&&(this.Ui.cancel(),this.Ui=null)},e.prototype.Wi=function(){return(Math.random()-.5)*this.qi},e}(),Mc=function(){function e(t,n,r,i,o,s){this.Se=t,this.zi=r,this.Hi=i,this.Ji=o,this.listener=s,this.state=0,this.Yi=0,this.Xi=null,this.stream=null,this.Zi=new Bo(t,n)}return e.prototype.tr=function(){return this.state===1||this.state===2||this.state===4},e.prototype.er=function(){return this.state===2},e.prototype.start=function(){this.state!==3?this.auth():this.nr()},e.prototype.stop=function(){return g(this,void 0,void 0,function(){return m(this,function(t){switch(t.label){case 0:return this.tr()?[4,this.close(0)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},e.prototype.sr=function(){this.state=0,this.Zi.reset()},e.prototype.ir=function(){var t=this;this.er()&&this.Xi===null&&(this.Xi=this.Se.enqueueAfterDelay(this.zi,6e4,function(){return t.rr()}))},e.prototype.cr=function(t){this.ur(),this.stream.send(t)},e.prototype.rr=function(){return g(this,void 0,void 0,function(){return m(this,function(t){return this.er()?[2,this.close(0)]:[2]})})},e.prototype.ur=function(){this.Xi&&(this.Xi.cancel(),this.Xi=null)},e.prototype.close=function(t,n){return g(this,void 0,void 0,function(){return m(this,function(r){switch(r.label){case 0:return this.ur(),this.Zi.cancel(),this.Yi++,t!==3?this.Zi.reset():n&&n.code===d.RESOURCE_EXHAUSTED?(W(n.toString()),W("Using maximum backoff delay to prevent overloading the backend."),this.Zi.Ki()):n&&n.code===d.UNAUTHENTICATED&&this.Ji.invalidateToken(),this.stream!==null&&(this.ar(),this.stream.close(),this.stream=null),this.state=t,[4,this.listener.Ri(n)];case 1:return r.sent(),[2]}})})},e.prototype.ar=function(){},e.prototype.auth=function(){var t=this;this.state=1;var n=this.hr(this.Yi),r=this.Yi;this.Ji.getToken().then(function(i){t.Yi===r&&t.lr(i)},function(i){n(function(){var o=new w(d.UNKNOWN,"Fetching auth token failed: "+i.message);return t.dr(o)})})},e.prototype.lr=function(t){var n=this,r=this.hr(this.Yi);this.stream=this.wr(t),this.stream.Ii(function(){r(function(){return n.state=2,n.listener.Ii()})}),this.stream.Ri(function(i){r(function(){return n.dr(i)})}),this.stream.onMessage(function(i){r(function(){return n.onMessage(i)})})},e.prototype.nr=function(){var t=this;this.state=4,this.Zi.ji(function(){return g(t,void 0,void 0,function(){return m(this,function(n){return this.state=0,this.start(),[2]})})})},e.prototype.dr=function(t){return I("PersistentStream","close with error: "+t),this.stream=null,this.close(3,t)},e.prototype.hr=function(t){var n=this;return function(r){n.Se.enqueueAndForget(function(){return n.Yi===t?r():(I("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())})}},e}(),cp=function(e){function t(n,r,i,o,s){var u=this;return(u=e.call(this,n,"listen_stream_connection_backoff","listen_stream_idle",r,i,s)||this).R=o,u}return C(t,e),t.prototype.wr=function(n){return this.Hi.$i("Listen",n)},t.prototype.onMessage=function(n){this.Zi.reset();var r=function(o,s){var u;if("targetChange"in s){s.targetChange;var a=function(E){return E==="NO_CHANGE"?0:E==="ADD"?1:E==="REMOVE"?2:E==="CURRENT"?3:E==="RESET"?4:D()}(s.targetChange.targetChangeType||"NO_CHANGE"),c=s.targetChange.targetIds||[],h=function(E,T){return E.I?(x(T===void 0||typeof T=="string"),wt.fromBase64String(T||"")):(x(T===void 0||T instanceof Uint8Array),wt.fromUint8Array(T||new Uint8Array))}(o,s.targetChange.resumeToken),l=(f=s.targetChange.cause)&&function(E){var T=E.code===void 0?d.UNKNOWN:ic(E.code);return new w(T,E.message||"")}(f);u=new sc(a,c,h,l||null)}else if("documentChange"in s){s.documentChange,(a=s.documentChange).document,a.document.name,a.document.updateTime,c=jt(o,a.document.name),h=yt(a.document.updateTime);var f=new _t({mapValue:{fields:a.document.fields}}),y=(l=ct.newFoundDocument(c,h,f),a.targetIds||[]),p=a.removedTargetIds||[];u=new ar(y,p,l.key,l)}else if("documentDelete"in s)s.documentDelete,(a=s.documentDelete).document,c=jt(o,a.document),h=a.readTime?yt(a.readTime):P.min(),f=ct.newNoDocument(c,h),l=a.removedTargetIds||[],u=new ar([],l,f.key,f);else if("documentRemove"in s)s.documentRemove,(a=s.documentRemove).document,c=jt(o,a.document),h=a.removedTargetIds||[],u=new ar([],h,c,null);else{if(!("filter"in s))return D();s.filter;var v=s.filter;v.targetId,a=v.count||0,c=new rf(a),h=v.targetId,u=new oc(h,c)}return u}(this.R,n),i=function(o){if(!("targetChange"in o))return P.min();var s=o.targetChange;return s.targetIds&&s.targetIds.length?P.min():s.readTime?yt(s.readTime):P.min()}(n);return this.listener._r(r,i)},t.prototype.mr=function(n){var r={};r.database=An(this.R),r.addTarget=function(o,s){var u,a=s.target;return(u=Er(a)?{documents:lc(o,a)}:{query:fc(o,a)}).targetId=s.targetId,s.resumeToken.approximateByteSize()>0?u.resumeToken=uc(o,s.resumeToken):s.snapshotVersion.compareTo(P.min())>0&&(u.readTime=Dn(o,s.snapshotVersion.toTimestamp())),u}(this.R,n);var i=function(o,s){var u=function(a,c){switch(c){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return D()}}(0,s.purpose);return u==null?null:{"goog-listen-tags":u}}(this.R,n);i&&(r.labels=i),this.cr(r)},t.prototype.yr=function(n){var r={};r.database=An(this.R),r.removeTarget=n,this.cr(r)},t}(Mc),hp=function(e){function t(n,r,i,o,s){var u=this;return(u=e.call(this,n,"write_stream_connection_backoff","write_stream_idle",r,i,s)||this).R=o,u.gr=!1,u}return C(t,e),Object.defineProperty(t.prototype,"pr",{get:function(){return this.gr},enumerable:!1,configurable:!0}),t.prototype.start=function(){this.gr=!1,this.lastStreamToken=void 0,e.prototype.start.call(this)},t.prototype.ar=function(){this.gr&&this.Er([])},t.prototype.wr=function(n){return this.Hi.$i("Write",n)},t.prototype.onMessage=function(n){if(x(!!n.streamToken),this.lastStreamToken=n.streamToken,this.gr){this.Zi.reset();var r=function(o,s){return o&&o.length>0?(x(s!==void 0),o.map(function(u){return function(a,c){var h=a.updateTime?yt(a.updateTime):yt(c);return h.isEqual(P.min())&&(h=yt(c)),new tf(h,a.transformResults||[])}(u,s)})):[]}(n.writeResults,n.commitTime),i=yt(n.commitTime);return this.listener.Tr(i,r)}return x(!n.writeResults||n.writeResults.length===0),this.gr=!0,this.listener.Ir()},t.prototype.Ar=function(){var n={};n.database=An(this.R),this.cr(n)},t.prototype.Er=function(n){var r=this,i={streamToken:this.lastStreamToken,writes:n.map(function(o){return Sr(r.R,o)})};this.cr(i)},t}(Mc),lp=function(e){function t(n,r,i){var o=this;return(o=e.call(this)||this).credentials=n,o.Hi=r,o.R=i,o.Rr=!1,o}return C(t,e),t.prototype.br=function(){if(this.Rr)throw new w(d.FAILED_PRECONDITION,"The client has already been terminated.")},t.prototype.Ni=function(n,r,i){var o=this;return this.br(),this.credentials.getToken().then(function(s){return o.Hi.Ni(n,r,i,s)}).catch(function(s){throw s.code===d.UNAUTHENTICATED&&o.credentials.invalidateToken(),s})},t.prototype.Oi=function(n,r,i){var o=this;return this.br(),this.credentials.getToken().then(function(s){return o.Hi.Oi(n,r,i,s)}).catch(function(s){throw s.code===d.UNAUTHENTICATED&&o.credentials.invalidateToken(),s})},t.prototype.terminate=function(){this.Rr=!1},t}(function(){}),fp=function(){function e(t,n){this.asyncQueue=t,this.onlineStateHandler=n,this.state="Unknown",this.vr=0,this.Pr=null,this.Vr=!0}return e.prototype.Sr=function(){var t=this;this.vr===0&&(this.Dr("Unknown"),this.Pr=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,function(){return t.Pr=null,t.Cr("Backend didn't respond within 10 seconds."),t.Dr("Offline"),Promise.resolve()}))},e.prototype.Nr=function(t){this.state==="Online"?this.Dr("Unknown"):(this.vr++,this.vr>=1&&(this.Fr(),this.Cr("Connection failed 1 times. Most recent error: "+t.toString()),this.Dr("Offline")))},e.prototype.set=function(t){this.Fr(),this.vr=0,t==="Online"&&(this.Vr=!1),this.Dr(t)},e.prototype.Dr=function(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))},e.prototype.Cr=function(t){var n="Could not reach Cloud Firestore backend. "+t+` This 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.Vr?(W(n),this.Vr=!1):I("OnlineStateTracker",n)},e.prototype.Fr=function(){this.Pr!==null&&(this.Pr.cancel(),this.Pr=null)},e}(),pp=function(e,t,n,r,i){var o=this;this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.kr=[],this.Or=new Map,this.$r=new Set,this.Mr=[],this.Lr=i,this.Lr.di(function(s){n.enqueueAndForget(function(){return g(o,void 0,void 0,function(){return m(this,function(u){switch(u.label){case 0:return he(this)?(I("RemoteStore","Restarting streams for network reachability change."),[4,function(a){return g(this,void 0,void 0,function(){var c;return m(this,function(h){switch(h.label){case 0:return(c=_(a)).$r.add(4),[4,un(c)];case 1:return h.sent(),c.Br.set("Unknown"),c.$r.delete(4),[4,Xn(c)];case 2:return h.sent(),[2]}})})}(this)]):[3,2];case 1:u.sent(),u.label=2;case 2:return[2]}})})})}),this.Br=new fp(n,r)};/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Xn(e){return g(this,void 0,void 0,function(){var t,n;return m(this,function(r){switch(r.label){case 0:if(!he(e))return[3,4];t=0,n=e.Mr,r.label=1;case 1:return t0}function he(e){return _(e).$r.size===0}function Vc(e){e.qr=void 0}function dp(e){return g(this,void 0,void 0,function(){return m(this,function(t){return e.Or.forEach(function(n,r){jo(e,n)}),[2]})})}function yp(e,t){return g(this,void 0,void 0,function(){return m(this,function(n){return Vc(e),Go(e)?(e.Br.Nr(t),Ko(e)):e.Br.set("Unknown"),[2]})})}function vp(e,t,n){return g(this,void 0,void 0,function(){var r,i,o;return m(this,function(s){switch(s.label){case 0:if(e.Br.set("Online"),!(t instanceof sc&&t.state===2&&t.cause))return[3,6];s.label=1;case 1:return s.trys.push([1,3,,5]),[4,function(u,a){return g(this,void 0,void 0,function(){var c,h,l,f;return m(this,function(y){switch(y.label){case 0:c=a.cause,h=0,l=a.targetIds,y.label=1;case 1:return h=0?[4,function(u,a){var c=u.qr.ut(a);return c.targetChanges.forEach(function(h,l){if(h.resumeToken.approximateByteSize()>0){var f=u.Or.get(l);f&&u.Or.set(l,f.withResumeToken(h.resumeToken,a))}}),c.targetMismatches.forEach(function(h){var l=u.Or.get(h);if(l){u.Or.set(h,l.withResumeToken(wt.EMPTY_BYTE_STRING,l.snapshotVersion)),Fc(u,h);var f=new Xr(l.target,h,1,l.sequenceNumber);jo(u,f)}}),u.remoteSyncer.applyRemoteEvent(c)}(e,n)]:[3,10];case 9:s.sent(),s.label=10;case 10:return[3,13];case 11:return I("RemoteStore","Failed to raise snapshot:",o=s.sent()),[4,kr(e,o)];case 12:return s.sent(),[3,13];case 13:return[2]}})})}function kr(e,t,n){return g(this,void 0,void 0,function(){var r=this;return m(this,function(i){switch(i.label){case 0:if(!De(t))throw t;return e.$r.add(1),[4,un(e)];case 1:return i.sent(),e.Br.set("Offline"),n||(n=function(){return xc(e.localStore)}),e.asyncQueue.enqueueRetryable(function(){return g(r,void 0,void 0,function(){return m(this,function(o){switch(o.label){case 0:return I("RemoteStore","Retrying IndexedDB access"),[4,n()];case 1:return o.sent(),e.$r.delete(1),[4,Xn(e)];case 2:return o.sent(),[2]}})})}),[2]}})})}function Uc(e,t){return t().catch(function(n){return kr(e,n,t)})}function an(e){return g(this,void 0,void 0,function(){var t,n,r,i,o;return m(this,function(s){switch(s.label){case 0:t=_(e),n=se(t),r=t.kr.length>0?t.kr[t.kr.length-1].batchId:-1,s.label=1;case 1:if(!function(u){return he(u)&&u.kr.length<10}(t))return[3,7];s.label=2;case 2:return s.trys.push([2,4,,6]),[4,Hf(t.localStore,r)];case 3:return(i=s.sent())===null?(t.kr.length===0&&n.ir(),[3,7]):(r=i.batchId,function(u,a){u.kr.push(a);var c=se(u);c.er()&&c.pr&&c.Er(a.mutations)}(t,i),[3,6]);case 4:return o=s.sent(),[4,kr(t,o)];case 5:return s.sent(),[3,6];case 6:return[3,1];case 7:return qc(t)&&Bc(t),[2]}})})}function qc(e){return he(e)&&!se(e).tr()&&e.kr.length>0}function Bc(e){se(e).start()}function mp(e){return g(this,void 0,void 0,function(){return m(this,function(t){return se(e).Ar(),[2]})})}function gp(e){return g(this,void 0,void 0,function(){var t,n,r,i;return m(this,function(o){for(t=se(e),n=0,r=e.kr;n0&&(I("RemoteStore","Stopping write stream with "+e.kr.length+" pending writes"),e.kr=[]),r.label=4;case 4:return[2]}})})})),e.Qr}var Ip=function(){function e(t,n,r,i,o){this.asyncQueue=t,this.timerId=n,this.targetTimeMs=r,this.op=i,this.removalCallback=o,this.deferred=new kt,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(function(s){})}return e.createAndSchedule=function(t,n,r,i,o){var s=new e(t,n,Date.now()+r,i,o);return s.start(r),s},e.prototype.start=function(t){var n=this;this.timerHandle=setTimeout(function(){return n.handleDelayElapsed()},t)},e.prototype.skipDelay=function(){return this.handleDelayElapsed()},e.prototype.cancel=function(t){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new w(d.CANCELLED,"Operation cancelled"+(t?": "+t:""))))},e.prototype.handleDelayElapsed=function(){var t=this;this.asyncQueue.enqueueAndForget(function(){return t.timerHandle!==null?(t.clearTimeout(),t.op().then(function(n){return t.deferred.resolve(n)})):Promise.resolve()})},e.prototype.clearTimeout=function(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)},e}();function hn(e,t){if(W("AsyncQueue",t+": "+e),De(e))return new w(d.UNAVAILABLE,t+": "+e);throw e}/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */var jc=function(){function e(t){this.comparator=t?function(n,r){return t(n,r)||N.comparator(n.key,r.key)}:function(n,r){return N.comparator(n.key,r.key)},this.keyedMap=ji(),this.sortedSet=new ht(this.comparator)}return e.emptySet=function(t){return new e(t.comparator)},e.prototype.has=function(t){return this.keyedMap.get(t)!=null},e.prototype.get=function(t){return this.keyedMap.get(t)},e.prototype.first=function(){return this.sortedSet.minKey()},e.prototype.last=function(){return this.sortedSet.maxKey()},e.prototype.isEmpty=function(){return this.sortedSet.isEmpty()},e.prototype.indexOf=function(t){var n=this.keyedMap.get(t);return n?this.sortedSet.indexOf(n):-1},Object.defineProperty(e.prototype,"size",{get:function(){return this.sortedSet.size},enumerable:!1,configurable:!0}),e.prototype.forEach=function(t){this.sortedSet.inorderTraversal(function(n,r){return t(n),!1})},e.prototype.add=function(t){var n=this.delete(t.key);return n.copy(n.keyedMap.insert(t.key,t),n.sortedSet.insert(t,null))},e.prototype.delete=function(t){var n=this.get(t);return n?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(n)):this},e.prototype.isEqual=function(t){if(!(t instanceof e)||this.size!==t.size)return!1;for(var n=this.sortedSet.getIterator(),r=t.sortedSet.getIterator();n.hasNext();){var i=n.getNext().key,o=r.getNext().key;if(!i.isEqual(o))return!1}return!0},e.prototype.toString=function(){var t=[];return this.forEach(function(n){t.push(n.toString())}),t.length===0?"DocumentSet ()":`DocumentSet ( `+t.join(` `)+` )`},e.prototype.copy=function(t,n){var r=new e;return r.comparator=this.comparator,r.keyedMap=t,r.sortedSet=n,r},e}(),hu=function(){function e(){this.Kr=new ht(N.comparator)}return e.prototype.track=function(t){var n=t.doc.key,r=this.Kr.get(n);r?t.type!==0&&r.type===3?this.Kr=this.Kr.insert(n,t):t.type===3&&r.type!==1?this.Kr=this.Kr.insert(n,{type:r.type,doc:t.doc}):t.type===2&&r.type===2?this.Kr=this.Kr.insert(n,{type:2,doc:t.doc}):t.type===2&&r.type===0?this.Kr=this.Kr.insert(n,{type:0,doc:t.doc}):t.type===1&&r.type===0?this.Kr=this.Kr.remove(n):t.type===1&&r.type===2?this.Kr=this.Kr.insert(n,{type:1,doc:r.doc}):t.type===0&&r.type===1?this.Kr=this.Kr.insert(n,{type:2,doc:t.doc}):D():this.Kr=this.Kr.insert(n,t)},e.prototype.jr=function(){var t=[];return this.Kr.inorderTraversal(function(n,r){t.push(r)}),t},e}(),xr=function(){function e(t,n,r,i,o,s,u,a){this.query=t,this.docs=n,this.oldDocs=r,this.docChanges=i,this.mutatedKeys=o,this.fromCache=s,this.syncStateChanged=u,this.excludesMetadataChanges=a}return e.fromInitialDocuments=function(t,n,r,i){var o=[];return n.forEach(function(s){o.push({type:0,doc:s})}),new e(t,n,jc.emptySet(n),o,r,i,!0,!1)},Object.defineProperty(e.prototype,"hasPendingWrites",{get:function(){return!this.mutatedKeys.isEmpty()},enumerable:!1,configurable:!0}),e.prototype.isEqual=function(t){if(!(this.fromCache===t.fromCache&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&zn(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))return!1;var n=this.docChanges,r=t.docChanges;if(n.length!==r.length)return!1;for(var i=0;i=0&&(o.listeners.splice(s,1),i=o.listeners.length===0),i?[2,(n.queries.delete(r),n.onUnlisten(r))]:[2]})})}function _p(e,t){for(var n=_(e),r=!1,i=0,o=t;i0)return!0;var n=this.Xr&&this.Xr.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!n)&&this.options.includeMetadataChanges===!0},e.prototype.no=function(t){t=xr.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache),this.Yr=!0,this.Jr.next(t)},e}();/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */var Kc=function(e){this.key=e},Gc=function(e){this.key=e},zc=function(){function e(t,n){this.query=t,this.uo=n,this.ao=null,this.current=!1,this.ho=B(),this.mutatedKeys=B(),this.lo=Ha(t),this.fo=new jc(this.lo)}return Object.defineProperty(e.prototype,"wo",{get:function(){return this.uo},enumerable:!1,configurable:!0}),e.prototype._o=function(t,n){var r=this,i=n?n.mo:new hu,o=n?n.fo:this.fo,s=n?n.mutatedKeys:this.mutatedKeys,u=o,a=!1,c=sr(this.query)&&o.size===this.query.limit?o.last():null,h=_r(this.query)&&o.size===this.query.limit?o.first():null;if(t.inorderTraversal(function(f,y){var p=o.get(f),v=Qn(r.query,y)?y:null,E=!!p&&r.mutatedKeys.has(p.key),T=!!v&&(v.hasLocalMutations||r.mutatedKeys.has(v.key)&&v.hasCommittedMutations),k=!1;p&&v?p.data.isEqual(v.data)?E!==T&&(i.track({type:3,doc:v}),k=!0):r.yo(p,v)||(i.track({type:2,doc:v}),k=!0,(c&&r.lo(v,c)>0||h&&r.lo(v,h)<0)&&(a=!0)):!p&&v?(i.track({type:0,doc:v}),k=!0):p&&!v&&(i.track({type:1,doc:p}),k=!0,(c||h)&&(a=!0)),k&&(v?(u=u.add(v),s=T?s.add(f):s.delete(f)):(u=u.delete(f),s=s.delete(f)))}),sr(this.query)||_r(this.query))for(;u.size>this.query.limit;){var l=sr(this.query)?u.last():u.first();u=u.delete(l.key),s=s.delete(l.key),i.track({type:1,doc:l})}return{fo:u,mo:i,Nn:a,mutatedKeys:s}},e.prototype.yo=function(t,n){return t.hasLocalMutations&&n.hasCommittedMutations&&!n.hasLocalMutations},e.prototype.applyChanges=function(t,n,r){var i=this,o=this.fo;this.fo=t.fo,this.mutatedKeys=t.mutatedKeys;var s=t.mo.jr();s.sort(function(h,l){return function(f,y){var p=function(v){switch(v){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return D()}};return p(f)-p(y)}(h.type,l.type)||i.lo(h.doc,l.doc)}),this.po(r);var u=n?this.Eo():[],a=this.ho.size===0&&this.current?1:0,c=a!==this.ao;return this.ao=a,s.length!==0||c?{snapshot:new xr(this.query,t.fo,o,s,t.mutatedKeys,a===0,c,!1),To:u}:{To:u}},e.prototype.zr=function(t){return this.current&&t==="Offline"?(this.current=!1,this.applyChanges({fo:this.fo,mo:new hu,mutatedKeys:this.mutatedKeys,Nn:!1},!1)):{To:[]}},e.prototype.Io=function(t){return!this.uo.has(t)&&!!this.fo.has(t)&&!this.fo.get(t).hasLocalMutations},e.prototype.po=function(t){var n=this;t&&(t.addedDocuments.forEach(function(r){return n.uo=n.uo.add(r)}),t.modifiedDocuments.forEach(function(r){}),t.removedDocuments.forEach(function(r){return n.uo=n.uo.delete(r)}),this.current=t.current)},e.prototype.Eo=function(){var t=this;if(!this.current)return[];var n=this.ho;this.ho=B(),this.fo.forEach(function(i){t.Io(i.key)&&(t.ho=t.ho.add(i.key))});var r=[];return n.forEach(function(i){t.ho.has(i)||r.push(new Gc(i))}),this.ho.forEach(function(i){n.has(i)||r.push(new Kc(i))}),r},e.prototype.Ao=function(t){this.uo=t.Bn,this.ho=B();var n=this._o(t.documents);return this.applyChanges(n,!0)},e.prototype.Ro=function(){return xr.fromInitialDocuments(this.query,this.fo,this.mutatedKeys,this.ao===0)},e}(),Dp=function(e,t,n){this.query=e,this.targetId=t,this.view=n},Np=function(e){this.key=e,this.bo=!1},Ap=function(){function e(t,n,r,i,o,s){this.localStore=t,this.remoteStore=n,this.eventManager=r,this.sharedClientState=i,this.currentUser=o,this.maxConcurrentLimboResolutions=s,this.vo={},this.Po=new sn(function(u){return $a(u)},zn),this.Vo=new Map,this.So=new Set,this.Do=new ht(N.comparator),this.Co=new Map,this.No=new qo,this.xo={},this.Fo=new Map,this.ko=Nr.Yt(),this.onlineState="Unknown",this.Oo=void 0}return Object.defineProperty(e.prototype,"isPrimaryClient",{get:function(){return this.Oo===!0},enumerable:!1,configurable:!0}),e}();function Cp(e,t){return g(this,void 0,void 0,function(){var n,r,i,o,s,u;return m(this,function(a){switch(a.label){case 0:return n=Zo(e),(o=n.Po.get(t))?(r=o.targetId,n.sharedClientState.addLocalQueryTarget(r),i=o.view.Ro(),[3,4]):[3,1];case 1:return[4,Ar(n.localStore,Ut(t))];case 2:return s=a.sent(),u=n.sharedClientState.addLocalQueryTarget(s.targetId),r=s.targetId,[4,Wo(n,t,r,u==="current")];case 3:i=a.sent(),n.isPrimaryClient&&Jr(n.remoteStore,s),a.label=4;case 4:return[2,i]}})})}function Wo(e,t,n,r){return g(this,void 0,void 0,function(){var i,o,s,u,a,c;return m(this,function(h){switch(h.label){case 0:return e.$o=function(l,f,y){return function(p,v,E,T){return g(this,void 0,void 0,function(){var k,A,O;return m(this,function(M){switch(M.label){case 0:return k=v.view._o(E),k.Nn?[4,Cr(p.localStore,v.query,!1).then(function(q){var et=q.documents;return v.view._o(et,k)})]:[3,2];case 1:k=M.sent(),M.label=2;case 2:return A=T&&T.targetChanges.get(v.targetId),O=v.view.applyChanges(k,p.isPrimaryClient,A),[2,($i(p,v.targetId,O.To),O.snapshot)]}})})}(e,l,f,y)},[4,Cr(e.localStore,t,!0)];case 1:return i=h.sent(),o=new zc(t,i.Bn),s=o._o(i.documents),u=Oo.createSynthesizedTargetChangeForCurrentChange(n,r&&e.onlineState!=="Offline"),a=o.applyChanges(s,e.isPrimaryClient,u),$i(e,n,a.To),c=new Dp(t,n,o),[2,(e.Po.set(t,c),e.Vo.has(n)?e.Vo.get(n).push(t):e.Vo.set(n,[t]),a.snapshot)]}})})}function kp(e,t){return g(this,void 0,void 0,function(){var n,r,i;return m(this,function(o){switch(o.label){case 0:return n=_(e),r=n.Po.get(t),(i=n.Vo.get(r.targetId)).length>1?[2,(n.Vo.set(r.targetId,i.filter(function(s){return!zn(s,t)})),void n.Po.delete(t))]:n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(r.targetId),n.sharedClientState.isActiveQueryTarget(r.targetId)?[3,2]:[4,Je(n.localStore,r.targetId,!1).then(function(){n.sharedClientState.clearQueryState(r.targetId),Cn(n.remoteStore,r.targetId),Ze(n,r.targetId)}).catch(Ne)]):[3,3];case 1:o.sent(),o.label=2;case 2:return[3,5];case 3:return Ze(n,r.targetId),[4,Je(n.localStore,r.targetId,!0)];case 4:o.sent(),o.label=5;case 5:return[2]}})})}function xp(e,t,n){return g(this,void 0,void 0,function(){var r,i,o,s;return m(this,function(u){switch(u.label){case 0:r=ts(e),u.label=1;case 1:return u.trys.push([1,5,,6]),[4,function(a,c){var h,l=_(a),f=gt.now(),y=c.reduce(function(p,v){return p.add(v.key)},B());return l.persistence.runTransaction("Locally write mutations","readwrite",function(p){return l.Mn.pn(p,y).next(function(v){h=v;for(var E=[],T=0,k=c;T0?u.bo=!0:o.modifiedDocuments.size>0?x(u.bo):o.removedDocuments.size>0&&(x(u.bo),u.bo=!1))}),[4,le(n,r,t)];case 3:return i.sent(),[3,6];case 4:return[4,Ne(i.sent())];case 5:return i.sent(),[3,6];case 6:return[2]}})})}function lu(e,t,n){var r=_(e);if(r.isPrimaryClient&&n===0||!r.isPrimaryClient&&n===1){var i=[];r.Po.forEach(function(o,s){var u=s.view.zr(t);u.snapshot&&i.push(u.snapshot)}),function(o,s){var u=_(o);u.onlineState=s;var a=!1;u.queries.forEach(function(c,h){for(var l=0,f=h.listeners;l0&&e.Do.size0)throw new w(d.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");return[4,function(o,s){return g(this,void 0,void 0,function(){var u,a,c,h,l,f;return m(this,function(y){switch(y.label){case 0:return u=_(o),a=An(u.R)+"/documents",c={documents:s.map(function(p){return Nn(u.R,p)})},[4,u.Oi("BatchGetDocuments",a,c)];case 1:return h=y.sent(),l=new Map,h.forEach(function(p){var v=function(E,T){return"found"in T?function(k,A){x(!!A.found),A.found.name,A.found.updateTime;var O=jt(k,A.found.name),M=yt(A.found.updateTime),q=new _t({mapValue:{fields:A.found.fields}});return ct.newFoundDocument(O,M,q)}(E,T):"missing"in T?function(k,A){x(!!A.missing),x(!!A.readTime);var O=jt(k,A.missing),M=yt(A.readTime);return ct.newNoDocument(O,M)}(E,T):D()}(u.R,p);l.set(v.key.toString(),v)}),f=[],[2,(s.forEach(function(p){var v=l.get(p.toString());x(!!v),f.push(v)}),f)]}})})}(this.datastore,t)];case 1:return[2,((n=i.sent()).forEach(function(o){return r.recordVersion(o)}),n)]}})})},e.prototype.set=function(t,n){this.write(n.toMutation(t,this.precondition(t))),this.writtenDocs.add(t.toString())},e.prototype.update=function(t,n){try{this.write(n.toMutation(t,this.preconditionForUpdate(t)))}catch(r){this.lastWriteError=r}this.writtenDocs.add(t.toString())},e.prototype.delete=function(t){this.write(new Wn(t,this.precondition(t))),this.writtenDocs.add(t.toString())},e.prototype.commit=function(){return g(this,void 0,void 0,function(){var t,n=this;return m(this,function(r){switch(r.label){case 0:if(this.ensureCommitNotCalled(),this.lastWriteError)throw this.lastWriteError;return t=this.readVersions,this.mutations.forEach(function(i){t.delete(i.key.toString())}),t.forEach(function(i,o){var s=N.fromPath(o);n.mutations.push(new xo(s,n.precondition(s)))}),[4,function(i,o){return g(this,void 0,void 0,function(){var s,u,a;return m(this,function(c){switch(c.label){case 0:return s=_(i),u=An(s.R)+"/documents",a={writes:o.map(function(h){return Sr(s.R,h)})},[4,s.Ni("Commit",u,a)];case 1:return c.sent(),[2]}})})}(this.datastore,this.mutations)];case 1:return r.sent(),this.committed=!0,[2]}})})},e.prototype.recordVersion=function(t){var n;if(t.isFoundDocument())n=t.version;else{if(!t.isNoDocument())throw D();n=P.min()}var r=this.readVersions.get(t.key.toString());if(r){if(!n.isEqual(r))throw new w(d.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(t.key.toString(),n)},e.prototype.precondition=function(t){var n=this.readVersions.get(t.toString());return!this.writtenDocs.has(t.toString())&&n?st.updateTime(n):st.none()},e.prototype.preconditionForUpdate=function(t){var n=this.readVersions.get(t.toString());if(!this.writtenDocs.has(t.toString())&&n){if(n.isEqual(P.min()))throw new w(d.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return st.updateTime(n)}return st.exists(!0)},e.prototype.write=function(t){this.ensureCommitNotCalled(),this.mutations.push(t)},e.prototype.ensureCommitNotCalled=function(){},e}(),Hp=function(){function e(t,n,r,i){this.asyncQueue=t,this.datastore=n,this.updateFunction=r,this.deferred=i,this.ec=5,this.Zi=new Bo(this.asyncQueue,"transaction_retry")}return e.prototype.run=function(){this.nc()},e.prototype.nc=function(){var t=this;this.Zi.ji(function(){return g(t,void 0,void 0,function(){var n,r,i=this;return m(this,function(o){return n=new $p(this.datastore),(r=this.sc(n))&&r.then(function(s){i.asyncQueue.enqueueAndForget(function(){return n.commit().then(function(){i.deferred.resolve(s)}).catch(function(u){i.ic(u)})})}).catch(function(s){i.ic(s)}),[2]})})})},e.prototype.sc=function(t){try{var n=this.updateFunction(t);return!Se(n)&&n.catch&&n.then?n:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(r){return this.deferred.reject(r),null}},e.prototype.ic=function(t){var n=this;this.ec>0&&this.rc(t)?(this.ec-=1,this.asyncQueue.enqueueAndForget(function(){return n.nc(),Promise.resolve()})):this.deferred.reject(t)},e.prototype.rc=function(t){if(t.name==="FirebaseError"){var n=t.code;return n==="aborted"||n==="failed-precondition"||!rc(n)}return!1},e}(),Wp=function(){function e(t,n,r){var i=this;this.credentials=t,this.asyncQueue=n,this.databaseInfo=r,this.user=Tt.UNAUTHENTICATED,this.clientId=Fa.u(),this.credentialListener=function(){},this.receivedInitialUser=new kt,this.credentials.setChangeListener(function(o){I("FirestoreClient","Received user=",o.uid),i.user=o,i.credentialListener(o),i.receivedInitialUser.resolve()})}return e.prototype.getConfiguration=function(){return g(this,void 0,void 0,function(){return m(this,function(t){switch(t.label){case 0:return[4,this.receivedInitialUser.promise];case 1:return[2,(t.sent(),{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,credentials:this.credentials,initialUser:this.user,maxConcurrentLimboResolutions:100})]}})})},e.prototype.setCredentialChangeListener=function(t){var n=this;this.credentialListener=t,this.receivedInitialUser.promise.then(function(){return n.credentialListener(n.user)})},e.prototype.verifyNotTerminated=function(){if(this.asyncQueue.isShuttingDown)throw new w(d.FAILED_PRECONDITION,"The client has already been terminated.")},e.prototype.terminate=function(){var t=this;this.asyncQueue.enterRestrictedMode();var n=new kt;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(function(){return g(t,void 0,void 0,function(){var r,i;return m(this,function(o){switch(o.label){case 0:return o.trys.push([0,5,,6]),this.onlineComponents?[4,this.onlineComponents.terminate()]:[3,2];case 1:o.sent(),o.label=2;case 2:return this.offlineComponents?[4,this.offlineComponents.terminate()]:[3,4];case 3:o.sent(),o.label=4;case 4:return this.credentials.removeChangeListener(),n.resolve(),[3,6];case 5:return r=o.sent(),i=hn(r,"Failed to shutdown persistence"),n.reject(i),[3,6];case 6:return[2]}})})}),n.promise},e}();/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Yc(e,t){return g(this,void 0,void 0,function(){var n,r,i=this;return m(this,function(o){switch(o.label){case 0:return e.asyncQueue.verifyOperationInProgress(),I("FirestoreClient","Initializing OfflineComponentProvider"),[4,e.getConfiguration()];case 1:return n=o.sent(),[4,t.initialize(n)];case 2:return o.sent(),r=n.initialUser,e.setCredentialChangeListener(function(s){r.isEqual(s)||(r=s,e.asyncQueue.enqueueRetryable(function(){return g(i,void 0,void 0,function(){return m(this,function(u){switch(u.label){case 0:return[4,kc(t.localStore,s)];case 1:return u.sent(),[2]}})})}))}),t.persistence.setDatabaseDeletedListener(function(){return e.terminate()}),e.offlineComponents=t,[2]}})})}function Jc(e,t){return g(this,void 0,void 0,function(){var n,r;return m(this,function(i){switch(i.label){case 0:return e.asyncQueue.verifyOperationInProgress(),[4,es(e)];case 1:return n=i.sent(),I("FirestoreClient","Initializing OnlineComponentProvider"),[4,e.getConfiguration()];case 2:return r=i.sent(),[4,t.initialize(n,r)];case 3:return i.sent(),e.setCredentialChangeListener(function(o){return e.asyncQueue.enqueueRetryable(function(){return function(s,u){return g(this,void 0,void 0,function(){var a,c;return m(this,function(h){switch(h.label){case 0:return(a=_(s)).asyncQueue.verifyOperationInProgress(),I("RemoteStore","RemoteStore received new credentials"),c=he(a),a.$r.add(3),[4,un(a)];case 1:return h.sent(),c&&a.Br.set("Unknown"),[4,a.remoteSyncer.handleCredentialChange(u)];case 2:return h.sent(),a.$r.delete(3),[4,Xn(a)];case 3:return h.sent(),[2]}})})}(t.remoteStore,o)})}),e.onlineComponents=t,[2]}})})}function es(e){return g(this,void 0,void 0,function(){return m(this,function(t){switch(t.label){case 0:return e.offlineComponents?[3,2]:(I("FirestoreClient","Using default OfflineComponentProvider"),[4,Yc(e,new Wc)]);case 1:t.sent(),t.label=2;case 2:return[2,e.offlineComponents]}})})}function ti(e){return g(this,void 0,void 0,function(){return m(this,function(t){switch(t.label){case 0:return e.onlineComponents?[3,2]:(I("FirestoreClient","Using default OnlineComponentProvider"),[4,Jc(e,new Hi)]);case 1:t.sent(),t.label=2;case 2:return[2,e.onlineComponents]}})})}function pu(e){return es(e).then(function(t){return t.persistence})}function Zc(e){return es(e).then(function(t){return t.localStore})}function du(e){return ti(e).then(function(t){return t.remoteStore})}function th(e){return ti(e).then(function(t){return t.syncEngine})}function tn(e){return g(this,void 0,void 0,function(){var t,n;return m(this,function(r){switch(r.label){case 0:return[4,ti(e)];case 1:return t=r.sent(),[2,((n=t.eventManager).onListen=Cp.bind(null,t.syncEngine),n.onUnlisten=kp.bind(null,t.syncEngine),n)]}})})}function yu(e,t,n){var r=this;n===void 0&&(n={});var i=new kt;return e.asyncQueue.enqueueAndForget(function(){return g(r,void 0,void 0,function(){var o;return m(this,function(s){switch(s.label){case 0:return o=function(u,a,c,h,l){var f=new Zr({next:function(p){a.enqueueAndForget(function(){return Qo(u,y)});var v=p.docs.has(c);!v&&p.fromCache?l.reject(new w(d.UNAVAILABLE,"Failed to get document because the client is offline.")):v&&p.fromCache&&h&&h.source==="server"?l.reject(new w(d.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.)')):l.resolve(p)},error:function(p){return l.reject(p)}}),y=new Ho(Gn(c.path),f,{includeMetadataChanges:!0,so:!0});return zo(u,y)},[4,tn(e)];case 1:return[2,o.apply(void 0,[s.sent(),e.asyncQueue,t,n,i])]}})})}),i.promise}function vu(e,t,n){var r=this;n===void 0&&(n={});var i=new kt;return e.asyncQueue.enqueueAndForget(function(){return g(r,void 0,void 0,function(){var o;return m(this,function(s){switch(s.label){case 0:return o=function(u,a,c,h,l){var f=new Zr({next:function(p){a.enqueueAndForget(function(){return Qo(u,y)}),p.fromCache&&h.source==="server"?l.reject(new w(d.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.)')):l.resolve(p)},error:function(p){return l.reject(p)}}),y=new Ho(c,f,{includeMetadataChanges:!0,so:!0});return zo(u,y)},[4,tn(e)];case 1:return[2,o.apply(void 0,[s.sent(),e.asyncQueue,t,n,i])]}})})}),i.promise}var Xp=function(e,t,n,r,i,o,s){this.databaseId=e,this.appId=t,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=o,this.autoDetectLongPolling=s},Rr=function(){function e(t,n){this.projectId=t,this.database=n||"(default)"}return Object.defineProperty(e.prototype,"isDefaultDatabase",{get:function(){return this.database==="(default)"},enumerable:!1,configurable:!0}),e.prototype.isEqual=function(t){return t instanceof e&&t.projectId===this.projectId&&t.database===this.database},e}(),mu=new Map,Yp=function(e,t){this.user=t,this.type="OAuth",this.authHeaders={},this.authHeaders.Authorization="Bearer "+e},gu=function(){function e(){this.changeListener=null}return e.prototype.getToken=function(){return Promise.resolve(null)},e.prototype.invalidateToken=function(){},e.prototype.setChangeListener=function(t){this.changeListener=t,t(Tt.UNAUTHENTICATED)},e.prototype.removeChangeListener=function(){this.changeListener=null},e}(),Jp=function(){function e(t){var n=this;this.oc=null,this.currentUser=Tt.UNAUTHENTICATED,this.receivedInitialUser=!1,this.cc=0,this.changeListener=null,this.forceRefresh=!1,this.oc=function(){n.cc++,n.currentUser=n.uc(),n.receivedInitialUser=!0,n.changeListener&&n.changeListener(n.currentUser)},this.cc=0,this.auth=t.getImmediate({optional:!0}),this.auth?this.auth.addAuthTokenListener(this.oc):(this.oc(null),t.get().then(function(r){n.auth=r,n.oc&&n.auth.addAuthTokenListener(n.oc)},function(){}))}return e.prototype.getToken=function(){var t=this,n=this.cc,r=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(r).then(function(i){return t.cc!==n?(I("FirebaseCredentialsProvider","getToken aborted due to token change."),t.getToken()):i?(x(typeof i.accessToken=="string"),new Yp(i.accessToken,t.currentUser)):null}):Promise.resolve(null)},e.prototype.invalidateToken=function(){this.forceRefresh=!0},e.prototype.setChangeListener=function(t){this.changeListener=t,this.receivedInitialUser&&t(this.currentUser)},e.prototype.removeChangeListener=function(){this.auth&&this.auth.removeAuthTokenListener(this.oc),this.oc=null,this.changeListener=null},e.prototype.uc=function(){var t=this.auth&&this.auth.getUid();return x(t===null||typeof t=="string"),new Tt(t)},e}(),Zp=function(){function e(t,n,r){this.ac=t,this.hc=n,this.lc=r,this.type="FirstParty",this.user=Tt.FIRST_PARTY}return Object.defineProperty(e.prototype,"authHeaders",{get:function(){var t={"X-Goog-AuthUser":this.hc},n=this.ac.auth.getAuthHeaderValueForFirstParty([]);return n&&(t.Authorization=n),this.lc&&(t["X-Goog-Iam-Authorization-Token"]=this.lc),t},enumerable:!1,configurable:!0}),e}(),td=function(){function e(t,n,r){this.ac=t,this.hc=n,this.lc=r}return e.prototype.getToken=function(){return Promise.resolve(new Zp(this.ac,this.hc,this.lc))},e.prototype.setChangeListener=function(t){t(Tt.FIRST_PARTY)},e.prototype.removeChangeListener=function(){},e.prototype.invalidateToken=function(){},e}();/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function ns(e,t,n){if(!n)throw new w(d.INVALID_ARGUMENT,"Function "+e+"() cannot be called with an empty "+t+".")}function rs(e,t){if(t===void 0)return{merge:!1};if(t.mergeFields!==void 0&&t.merge!==void 0)throw new w(d.INVALID_ARGUMENT,"Invalid options passed to function "+e+'(): You cannot specify both "merge" and "mergeFields".');return t}function eh(e,t,n,r){if(t===!0&&r===!0)throw new w(d.INVALID_ARGUMENT,e+" and "+n+" cannot be used together.")}function wu(e){if(!N.isDocumentKey(e))throw new w(d.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+e+" has "+e.length+".")}function bu(e){if(N.isDocumentKey(e))throw new w(d.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+e+" has "+e.length+".")}function ei(e){if(e===void 0)return"undefined";if(e===null)return"null";if(typeof e=="string")return e.length>20&&(e=e.substring(0,20)+"..."),JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean")return""+e;if(typeof e=="object"){if(e instanceof Array)return"an array";var t=function(n){if(n.constructor){var r=/function\s+([^\s(]+)\s*\(/.exec(n.constructor.toString());if(r&&r.length>1)return r[1]}return null}(e);return t?"a custom "+t+" object":"an object"}return typeof e=="function"?"a function":D()}function U(e,t){if("_delegate"in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new w(d.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");var n=ei(e);throw new w(d.INVALID_ARGUMENT,"Expected type '"+t.name+"', but it was: "+n)}return e}function Iu(e,t){if(t<=0)throw new w(d.INVALID_ARGUMENT,"Function "+e+"() requires a positive number, but it was: "+t+".")}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */var Eu=function(){function e(t){var n;if(t.host===void 0){if(t.ssl!==void 0)throw new w(d.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=t.host,this.ssl=(n=t.ssl)===null||n===void 0||n;if(this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,t.cacheSizeBytes===void 0)this.cacheSizeBytes=41943040;else{if(t.cacheSizeBytes!==-1&&t.cacheSizeBytes<1048576)throw new w(d.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,eh("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling)}return e.prototype.isEqual=function(t){return this.host===t.host&&this.ssl===t.ssl&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===t.experimentalAutoDetectLongPolling&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties},e}(),kn=function(){function e(t,n){this._persistenceKey="(lite)",this._settings=new Eu({}),this._settingsFrozen=!1,t instanceof Rr?(this._databaseId=t,this._credentials=new gu):(this._app=t,this._databaseId=function(r){if(!Object.prototype.hasOwnProperty.apply(r.options,["projectId"]))throw new w(d.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new Rr(r.options.projectId)}(t),this._credentials=new Jp(n))}return Object.defineProperty(e.prototype,"app",{get:function(){if(!this._app)throw new w(d.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_initialized",{get:function(){return this._settingsFrozen},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_terminated",{get:function(){return this._terminateTask!==void 0},enumerable:!1,configurable:!0}),e.prototype._setSettings=function(t){if(this._settingsFrozen)throw new w(d.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 Eu(t),t.credentials!==void 0&&(this._credentials=function(n){if(!n)return new gu;switch(n.type){case"gapi":var r=n.client;return x(!(typeof r!="object"||r===null||!r.auth||!r.auth.getAuthHeaderValueForFirstParty)),new td(r,n.sessionIndex||"0",n.iamToken||null);case"provider":return n.client;default:throw new w(d.INVALID_ARGUMENT,"makeCredentialsProvider failed due to invalid credential type")}}(t.credentials))},e.prototype._getSettings=function(){return this._settings},e.prototype._freezeSettings=function(){return this._settingsFrozen=!0,this._settings},e.prototype._delete=function(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask},e.prototype.toJSON=function(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}},e.prototype._terminate=function(){return t=this,(n=mu.get(t))&&(I("ComponentProvider","Removing Datastore"),mu.delete(t),n.terminate()),Promise.resolve();var t,n},e}(),G=function(){function e(t,n,r){this._converter=n,this._key=r,this.type="document",this.firestore=t}return Object.defineProperty(e.prototype,"_path",{get:function(){return this._key.path},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this._key.path.lastSegment()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return this._key.path.canonicalString()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return new ne(this.firestore,this._converter,this._key.path.popLast())},enumerable:!1,configurable:!0}),e.prototype.withConverter=function(t){return new e(this.firestore,t,this._key)},e}(),Nt=function(){function e(t,n,r){this._converter=n,this._query=r,this.type="query",this.firestore=t}return e.prototype.withConverter=function(t){return new e(this.firestore,t,this._query)},e}(),ne=function(e){function t(n,r,i){var o=this;return(o=e.call(this,n,r,Gn(i))||this).firestore=n,o._path=i,o.type="collection",o}return C(t,e),Object.defineProperty(t.prototype,"id",{get:function(){return this._query.path.lastSegment()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"path",{get:function(){return this._query.path.canonicalString()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){var n=this._path.popLast();return n.isEmpty()?null:new G(this.firestore,null,new N(n))},enumerable:!1,configurable:!0}),t.prototype.withConverter=function(n){return new t(this.firestore,n,this._path)},t}(Nt);/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function nh(e,t){for(var n,r=[],i=2;i0&&this.Zi.ji(function(){return n.Ac()}),r.label=5;case 5:return[2]}})})},e.prototype.Ic=function(t){var n=this,r=this.fc.then(function(){return n.yc=!0,t().catch(function(i){throw n.mc=i,n.yc=!1,W("INTERNAL UNHANDLED ERROR: ",function(o){var s=o.message||"";return o.stack&&(s=o.stack.includes(o.message)?o.stack:o.message+` `+o.stack),s}(i)),i}).then(function(i){return n.yc=!1,i})});return this.fc=r,r},e.prototype.enqueueAfterDelay=function(t,n,r){var i=this;this.Tc(),this.gc.indexOf(t)>-1&&(n=0);var o=Ip.createAndSchedule(this,t,n,r,function(s){return i.Rc(s)});return this._c.push(o),o},e.prototype.Tc=function(){this.mc&&D()},e.prototype.verifyOperationInProgress=function(){},e.prototype.bc=function(){return g(this,void 0,void 0,function(){var t;return m(this,function(n){switch(n.label){case 0:return[4,t=this.fc];case 1:n.sent(),n.label=2;case 2:if(t!==this.fc)return[3,0];n.label=3;case 3:return[2]}})})},e.prototype.vc=function(t){for(var n=0,r=this._c;n90)throw new w(d.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(n)||n<-180||n>180)throw new w(d.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+n);this._lat=t,this._long=n}return Object.defineProperty(e.prototype,"latitude",{get:function(){return this._lat},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"longitude",{get:function(){return this._long},enumerable:!1,configurable:!0}),e.prototype.isEqual=function(t){return this._lat===t._lat&&this._long===t._long},e.prototype.toJSON=function(){return{latitude:this._lat,longitude:this._long}},e.prototype._compareTo=function(t){return L(this._lat,t._lat)||L(this._long,t._long)},e}(),rd=/^__.*__$/,id=function(){function e(t,n,r){this.data=t,this.fieldMask=n,this.fieldTransforms=r}return e.prototype.toMutation=function(t,n){return this.fieldMask!==null?new ce(t,this.data,this.fieldMask,n,this.fieldTransforms):new Hn(t,this.data,n,this.fieldTransforms)},e}(),sh=function(){function e(t,n,r){this.data=t,this.fieldMask=n,this.fieldTransforms=r}return e.prototype.toMutation=function(t,n){return new ce(t,this.data,this.fieldMask,n,this.fieldTransforms)},e}();/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function uh(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw D()}}var ah=function(){function e(t,n,r,i,o,s){this.settings=t,this.databaseId=n,this.R=r,this.ignoreUndefinedProperties=i,o===void 0&&this.Sc(),this.fieldTransforms=o||[],this.fieldMask=s||[]}return Object.defineProperty(e.prototype,"path",{get:function(){return this.settings.path},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"Dc",{get:function(){return this.settings.Dc},enumerable:!1,configurable:!0}),e.prototype.Cc=function(t){return new e(Object.assign(Object.assign({},this.settings),t),this.databaseId,this.R,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)},e.prototype.Nc=function(t){var n,r=(n=this.path)===null||n===void 0?void 0:n.child(t),i=this.Cc({path:r,xc:!1});return i.Fc(t),i},e.prototype.kc=function(t){var n,r=(n=this.path)===null||n===void 0?void 0:n.child(t),i=this.Cc({path:r,xc:!1});return i.Sc(),i},e.prototype.Oc=function(t){return this.Cc({path:void 0,xc:!0})},e.prototype.$c=function(t){return Or(t,this.settings.methodName,this.settings.Mc||!1,this.path,this.settings.Lc)},e.prototype.contains=function(t){return this.fieldMask.find(function(n){return t.isPrefixOf(n)})!==void 0||this.fieldTransforms.find(function(n){return t.isPrefixOf(n.field)})!==void 0},e.prototype.Sc=function(){if(this.path)for(var t=0;t=0;--f)if(!ph(h,u[f])){var y=u[f],p=a[f];p=X(p);var v=s.kc(y);if(p instanceof is)h.push(y);else{var E=ke(p,v);E!=null&&(h.push(y),l.set(y,E))}}var T=new Be(h);return new sh(l,T,s.fieldTransforms)}function hh(e,t,n,r){return r===void 0&&(r=!1),ke(n,e.Bc(r?4:3,t))}function ke(e,t){if(fh(e=X(e)))return us("Unsupported field value:",t,e),lh(e,t);if(e instanceof Ae)return function(n,r){if(!uh(r.Dc))throw r.$c(n._methodName+"() can only be used with update() and set()");if(!r.path)throw r.$c(n._methodName+"() is not currently supported inside arrays");var i=n._toFieldTransform(r);i&&r.fieldTransforms.push(i)}(e,t),null;if(e===void 0&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.xc&&t.Dc!==4)throw t.$c("Nested arrays are not supported");return function(n,r){for(var i=[],o=0,s=0,u=n;s0&&t.fieldMask.push(t.path):jn(e,function(r,i){var o=ke(i,t.Nc(r));o!=null&&(n[r]=o)}),{mapValue:{fields:n}}}function fh(e){return!(typeof e!="object"||e===null||e instanceof Array||e instanceof Date||e instanceof gt||e instanceof ni||e instanceof Te||e instanceof G||e instanceof Ae)}function us(e,t,n){if(!fh(n)||!function(i){return typeof i=="object"&&i!==null&&(Object.getPrototypeOf(i)===Object.prototype||Object.getPrototypeOf(i)===null)}(n)){var r=ei(n);throw r==="an object"?t.$c(e+" a custom object"):t.$c(e+" "+r)}}function Wi(e,t,n){if((t=X(t))instanceof Ft)return t._internalPath;if(typeof t=="string")return as(e,t);throw Or("Field path arguments must be of type string or FieldPath.",e,!1,void 0,n)}var hd=new RegExp("[~\\*/\\[\\]]");function as(e,t,n){if(t.search(hd)>=0)throw Or("Invalid field path ("+t+"). Paths must not contain '~', '*', '/', '[', or ']'",e,!1,void 0,n);try{return new(Ft.bind.apply(Ft,$([void 0],t.split("."))))()._internalPath}catch{throw Or("Invalid field path ("+t+"). Paths must not be empty, begin with '.', end with '.', or contain '..'",e,!1,void 0,n)}}function Or(e,t,n,r,i){var o=r&&!r.isEmpty(),s=i!==void 0,u="Function "+t+"() called with invalid data";n&&(u+=" (via `toFirestore()`)");var a="";return(o||s)&&(a+=" (found",o&&(a+=" in field "+r),s&&(a+=" in document "+i),a+=")"),new w(d.INVALID_ARGUMENT,(u+=". ")+e+a)}function ph(e,t){return e.some(function(n){return n.isEqual(t)})}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */var xn=function(){function e(t,n,r,i,o){this._firestore=t,this._userDataWriter=n,this._key=r,this._document=i,this._converter=o}return Object.defineProperty(e.prototype,"id",{get:function(){return this._key.path.lastSegment()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ref",{get:function(){return new G(this._firestore,this._converter,this._key)},enumerable:!1,configurable:!0}),e.prototype.exists=function(){return this._document!==null},e.prototype.data=function(){if(this._document){if(this._converter){var t=new ld(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.toProto())}},e.prototype.get=function(t){if(this._document){var n=this._document.data.field(Pr("DocumentSnapshot.get",t));if(n!==null)return this._userDataWriter.convertValue(n)}},e}(),ld=function(e){function t(){return e!==null&&e.apply(this,arguments)||this}return C(t,e),t.prototype.data=function(){return e.prototype.data.call(this)},t}(xn);function Pr(e,t){return typeof t=="string"?as(e,t):t instanceof Ft?t._internalPath:t._delegate._internalPath}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */var de=function(){function e(t,n){this.hasPendingWrites=t,this.fromCache=n}return e.prototype.isEqual=function(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache},e}(),Gt=function(e){function t(n,r,i,o,s,u){var a=this;return(a=e.call(this,n,r,i,o,u)||this)._firestore=n,a._firestoreImpl=n,a.metadata=s,a}return C(t,e),t.prototype.exists=function(){return e.prototype.exists.call(this)},t.prototype.data=function(n){if(n===void 0&&(n={}),this._document){if(this._converter){var r=new gn(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(r,n)}return this._userDataWriter.convertValue(this._document.data.toProto(),n.serverTimestamps)}},t.prototype.get=function(n,r){if(r===void 0&&(r={}),this._document){var i=this._document.data.field(Pr("DocumentSnapshot.get",n));if(i!==null)return this._userDataWriter.convertValue(i,r.serverTimestamps)}},t}(xn),gn=function(e){function t(){return e!==null&&e.apply(this,arguments)||this}return C(t,e),t.prototype.data=function(n){return n===void 0&&(n={}),e.prototype.data.call(this,n)},t}(Gt),Jt=function(){function e(t,n,r,i){this._firestore=t,this._userDataWriter=n,this._snapshot=i,this.metadata=new de(i.hasPendingWrites,i.fromCache),this.query=r}return Object.defineProperty(e.prototype,"docs",{get:function(){var t=[];return this.forEach(function(n){return t.push(n)}),t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this._snapshot.docs.size},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"empty",{get:function(){return this.size===0},enumerable:!1,configurable:!0}),e.prototype.forEach=function(t,n){var r=this;this._snapshot.docs.forEach(function(i){t.call(n,new gn(r._firestore,r._userDataWriter,i.key,i,new de(r._snapshot.mutatedKeys.has(i.key),r._snapshot.fromCache),r.query._converter))})},e.prototype.docChanges=function(t){t===void 0&&(t={});var n=!!t.includeMetadataChanges;if(n&&this._snapshot.excludesMetadataChanges)throw new w(d.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===n||(this._cachedChanges=function(r,i){if(r._snapshot.oldDocs.isEmpty()){var o=0;return r._snapshot.docChanges.map(function(u){var a=new gn(r._firestore,r._userDataWriter,u.doc.key,u.doc,new de(r._snapshot.mutatedKeys.has(u.doc.key),r._snapshot.fromCache),r.query._converter);return u.doc,{type:"added",doc:a,oldIndex:-1,newIndex:o++}})}var s=r._snapshot.oldDocs;return r._snapshot.docChanges.filter(function(u){return i||u.type!==3}).map(function(u){var a=new gn(r._firestore,r._userDataWriter,u.doc.key,u.doc,new de(r._snapshot.mutatedKeys.has(u.doc.key),r._snapshot.fromCache),r.query._converter),c=-1,h=-1;return u.type!==0&&(c=s.indexOf(u.doc.key),s=s.delete(u.doc.key)),u.type!==1&&(h=(s=s.add(u.doc)).indexOf(u.doc.key)),{type:fd(u.type),doc:a,oldIndex:c,newIndex:h}})}(this,n),this._cachedChangesIncludeMetadataChanges=n),this._cachedChanges},e}();function fd(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return D()}}function dh(e,t){return e instanceof Gt&&t instanceof Gt?e._firestore===t._firestore&&e._key.isEqual(t._key)&&(e._document===null?t._document===null:e._document.isEqual(t._document))&&e._converter===t._converter:e instanceof Jt&&t instanceof Jt&&e._firestore===t._firestore&&ih(e.query,t.query)&&e.metadata.isEqual(t.metadata)&&e._snapshot.isEqual(t._snapshot)}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function yh(e){if(_r(e)&&e.explicitOrderBy.length===0)throw new w(d.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}var Yn=function(){};function Ht(e){for(var t=[],n=1;n, or >=) must be on the same field. But you have inequality filters on '"+O.toString()+"' and '"+A.field.toString()+"'");var M=Ao(k);M!==null&&mh(k,A.field,M)}var q=function(et,ai){for(var ln=0,hs=et.filters;ln=0)return ls.op}return null}(k,function(et){switch(et){case"!=":return["!=","not-in"];case"array-contains":return["array-contains","array-contains-any","not-in"];case"in":return["array-contains-any","in","not-in"];case"array-contains-any":return["array-contains","array-contains-any","in","not-in"];case"not-in":return["array-contains","array-contains-any","in","not-in","!="];default:return[]}}(A.op));if(q!==null)throw q===A.op?new w(d.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+A.op.toString()+"' filter."):new w(d.INVALID_ARGUMENT,"Invalid query. You cannot use '"+A.op.toString()+"' filters with '"+q.toString()+"' filters.")}(o,T),T}(n._query,0,r,n.firestore._databaseId,this.Qc,this.Kc,this.jc);return new Nt(n.firestore,n._converter,function(o,s){var u=o.filters.concat([s]);return new Qt(o.path,o.collectionGroup,o.explicitOrderBy.slice(),u,o.limit,o.limitType,o.startAt,o.endAt)}(n._query,i))},t}(Yn),dd=function(e){function t(n,r){var i=this;return(i=e.call(this)||this).Qc=n,i.Wc=r,i.type="orderBy",i}return C(t,e),t.prototype._apply=function(n){var r=function(i,o,s){if(i.startAt!==null)throw new w(d.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(i.endAt!==null)throw new w(d.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");var u=new Ve(o,s);return function(a,c){if(Ao(a)===null){var h=Co(a);h!==null&&mh(a,h,c.field)}}(i,u),u}(n._query,this.Qc,this.Wc);return new Nt(n.firestore,n._converter,function(i,o){var s=i.explicitOrderBy.concat([o]);return new Qt(i.path,i.collectionGroup,s,i.filters.slice(),i.limit,i.limitType,i.startAt,i.endAt)}(n._query,r))},t}(Yn),Su=function(e){function t(n,r,i){var o=this;return(o=e.call(this)||this).type=n,o.Gc=r,o.zc=i,o}return C(t,e),t.prototype._apply=function(n){return new Nt(n.firestore,n._converter,Qa(n._query,this.Gc,this.zc))},t}(Yn),Du=function(e){function t(n,r,i){var o=this;return(o=e.call(this)||this).type=n,o.Hc=r,o.Jc=i,o}return C(t,e),t.prototype._apply=function(n){var r=vh(n,this.type,this.Hc,this.Jc);return new Nt(n.firestore,n._converter,function(i,o){return new Qt(i.path,i.collectionGroup,i.explicitOrderBy.slice(),i.filters.slice(),i.limit,i.limitType,o,i.endAt)}(n._query,r))},t}(Yn),Nu=function(e){function t(n,r,i){var o=this;return(o=e.call(this)||this).type=n,o.Hc=r,o.Jc=i,o}return C(t,e),t.prototype._apply=function(n){var r=vh(n,this.type,this.Hc,this.Jc);return new Nt(n.firestore,n._converter,function(i,o){return new Qt(i.path,i.collectionGroup,i.explicitOrderBy.slice(),i.filters.slice(),i.limit,i.limitType,i.startAt,o)}(n._query,r))},t}(Yn);function vh(e,t,n,r){if(n[0]=X(n[0]),n[0]instanceof xn)return function(o,s,u,a,c){if(!a)throw new w(d.NOT_FOUND,"Can't use a DocumentSnapshot that doesn't exist for "+u+"().");for(var h=[],l=0,f=Ge(o);ll.length)throw new w(d.INVALID_ARGUMENT,"Too many arguments provided to "+a+"(). The number of arguments must be less than or equal to the number of orderBy() clauses");for(var f=[],y=0;y10)throw new w(d.INVALID_ARGUMENT,"Invalid Query. '"+t.toString()+"' filters support a maximum of 10 elements in the value array.")}function mh(e,t,n){if(!n.isEqual(t))throw new w(d.INVALID_ARGUMENT,"Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '"+t.toString()+"' and so you must also use '"+t.toString()+"' as your first argument to orderBy(), but your first orderBy() is on field '"+n.toString()+"' instead.")}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */var cs=function(){function e(){}return e.prototype.convertValue=function(t,n){switch(n===void 0&&(n="none"),oe(t)){case 0:return null;case 1:return t.booleanValue;case 2:return H(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,n);case 5:return t.stringValue;case 6:return this.convertBytes(je(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,n);case 10:return this.convertObject(t.mapValue,n);default:throw D()}},e.prototype.convertObject=function(t,n){var r=this,i={};return jn(t.fields||{},function(o,s){i[o]=r.convertValue(s,n)}),i},e.prototype.convertGeoPoint=function(t){return new ni(H(t.latitude),H(t.longitude))},e.prototype.convertArray=function(t,n){var r=this;return(t.values||[]).map(function(i){return r.convertValue(i,n)})},e.prototype.convertServerTimestamp=function(t,n){switch(n){case"previous":var r=Ba(t);return r==null?null:this.convertValue(r,n);case"estimate":return this.convertTimestamp(Tn(t));default:return null}},e.prototype.convertTimestamp=function(t){var n=ie(t);return new gt(n.seconds,n.nanos)},e.prototype.convertDocumentKey=function(t,n){var r=V.fromString(t);x(yc(r));var i=new Rr(r.get(1),r.get(3)),o=new N(r.popFirst(5));return i.isEqual(n)||W("Document "+o+" contains a document reference within a different database ("+i.projectId+"/"+i.database+") which is not supported. It will be treated as a reference in the current database ("+n.projectId+"/"+n.database+") instead."),o},e}();/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function ii(e,t,n){return e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t}var yd=function(e){function t(n){var r=this;return(r=e.call(this)||this).firestore=n,r}return C(t,e),t.prototype.convertBytes=function(n){return new Te(n)},t.prototype.convertReference=function(n){var r=this.convertDocumentKey(n,this.firestore._databaseId);return new G(this.firestore,null,r)},t}(cs),vd=function(){function e(t,n){this._firestore=t,this._commitHandler=n,this._mutations=[],this._committed=!1,this._dataReader=Ce(t)}return e.prototype.set=function(t,n,r){this._verifyNotCommitted();var i=Zt(t,this._firestore),o=ii(i._converter,n,r),s=ri(this._dataReader,"WriteBatch.set",i._key,o,i._converter!==null,r);return this._mutations.push(s.toMutation(i._key,st.none())),this},e.prototype.update=function(t,n,r){for(var i=[],o=3;o0?this._commitHandler(this._mutations):Promise.resolve()},e.prototype._verifyNotCommitted=function(){if(this._committed)throw new w(d.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")},e}();/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function Zt(e,t){if((e=X(e)).firestore!==t)throw new w(d.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */var me=function(e){function t(n){var r=this;return(r=e.call(this)||this).firestore=n,r}return C(t,e),t.prototype.convertBytes=function(n){return new Te(n)},t.prototype.convertReference=function(n){var r=this.convertDocumentKey(n,this.firestore._databaseId);return new G(this.firestore,null,r)},t}(cs);function ku(e,t,n){for(var r=[],i=3;i"u")throw new w(d.UNIMPLEMENTED,"Uint8Arrays are not available in this environment.")}function Ru(){if(typeof atob>"u")throw new w(d.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}var wh=function(){function e(t){this._delegate=t}return e.fromBase64String=function(t){return Ru(),new e(Te.fromBase64String(t))},e.fromUint8Array=function(t){return xu(),new e(Te.fromUint8Array(t))},e.prototype.toBase64=function(){return Ru(),this._delegate.toBase64()},e.prototype.toUint8Array=function(){return xu(),this._delegate.toUint8Array()},e.prototype.isEqual=function(t){return this._delegate.isEqual(t._delegate)},e.prototype.toString=function(){return"Blob(base64: "+this.toBase64()+")"},e}(),gd=function(){function e(){}return e.prototype.enableIndexedDbPersistence=function(t,n){return function(r,i){_u(r=U(r,Y));var o=ot(r),s=r._freezeSettings(),u=new Hi;return Tu(o,u,new Xc(u,s.cacheSizeBytes,i==null?void 0:i.forceOwnership))}(t._delegate,{forceOwnership:n})},e.prototype.enableMultiTabIndexedDbPersistence=function(t){return function(n){_u(n=U(n,Y));var r=ot(n),i=n._freezeSettings(),o=new Hi;return Tu(r,o,new Qp(o,i.cacheSizeBytes))}(t._delegate)},e.prototype.clearIndexedDbPersistence=function(t){return function(n){var r=this;if(n._initialized&&!n._terminated)throw new w(d.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");var i=new kt;return n._queue.enqueueAndForgetEvenWhileRestricted(function(){return g(r,void 0,void 0,function(){var o;return m(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,function(u){return g(this,void 0,void 0,function(){var a;return m(this,function(c){switch(c.label){case 0:return We.yt()?(a=u+"main",[4,We.delete(a)]):[2,Promise.resolve()];case 1:return c.sent(),[2]}})})}(Uo(n._databaseId,n._persistenceKey))];case 1:return s.sent(),i.resolve(),[3,3];case 2:return o=s.sent(),i.reject(o),[3,3];case 3:return[2]}})})}),i.promise}(t._delegate)},e}(),bh=function(){function e(t,n,r){var i=this;this._delegate=n,this.Yc=r,this.INTERNAL={delete:function(){return i.terminate()}},t instanceof Rr||(this.Xc=t)}return Object.defineProperty(e.prototype,"_databaseId",{get:function(){return this._delegate._databaseId},enumerable:!1,configurable:!0}),e.prototype.settings=function(t){t.merge&&delete(t=Object.assign(Object.assign({},this._delegate._getSettings()),t)).merge,this._delegate._setSettings(t)},e.prototype.useEmulator=function(t,n){(function(r,i,o){var s=(r=U(r,kn))._getSettings();s.host!=="firestore.googleapis.com"&&s.host!==i&&Mi("Host has been set in both settings() and useEmulator(), emulator host will be used"),r._setSettings(Object.assign(Object.assign({},s),{host:i+":"+o,ssl:!1}))})(this._delegate,t,n)},e.prototype.enableNetwork=function(){return function(t){var n=this;return t.asyncQueue.enqueue(function(){return g(n,void 0,void 0,function(){var r,i;return m(this,function(o){switch(o.label){case 0:return[4,pu(t)];case 1:return r=o.sent(),[4,du(t)];case 2:return i=o.sent(),[2,(r.setNetworkEnabled(!0),function(s){var u=_(s);return u.$r.delete(0),Xn(u)}(i))]}})})})}(ot(U(this._delegate,Y)))},e.prototype.disableNetwork=function(){return function(t){var n=this;return t.asyncQueue.enqueue(function(){return g(n,void 0,void 0,function(){var r,i;return m(this,function(o){switch(o.label){case 0:return[4,pu(t)];case 1:return r=o.sent(),[4,du(t)];case 2:return i=o.sent(),[2,(r.setNetworkEnabled(!1),function(s){return g(this,void 0,void 0,function(){var u;return m(this,function(a){switch(a.label){case 0:return(u=_(s)).$r.add(0),[4,un(u)];case 1:return a.sent(),u.Br.set("Offline"),[2]}})})}(i))]}})})})}(ot(U(this._delegate,Y)))},e.prototype.enablePersistence=function(t){var n=!1,r=!1;return t&&eh("synchronizeTabs",n=!!t.synchronizeTabs,"experimentalForceOwningTab",r=!!t.experimentalForceOwningTab),n?this.Yc.enableMultiTabIndexedDbPersistence(this):this.Yc.enableIndexedDbPersistence(this,r)},e.prototype.clearPersistence=function(){return this.Yc.clearIndexedDbPersistence(this)},e.prototype.terminate=function(){return this.Xc&&(this.Xc._removeServiceInstance("firestore"),this.Xc._removeServiceInstance("firestore-exp")),this._delegate._delete()},e.prototype.waitForPendingWrites=function(){return function(t){var n=this,r=new kt;return t.asyncQueue.enqueueAndForget(function(){return g(n,void 0,void 0,function(){var i;return m(this,function(o){switch(o.label){case 0:return i=Lp,[4,th(t)];case 1:return[2,i.apply(void 0,[o.sent(),r])]}})})}),r.promise}(ot(U(this._delegate,Y)))},e.prototype.onSnapshotsInSync=function(t){return function(n,r){return function(i,o){var s=this,u=new Zr(o);return i.asyncQueue.enqueueAndForget(function(){return g(s,void 0,void 0,function(){var a;return m(this,function(c){switch(c.label){case 0:return a=function(h,l){_(h).Gr.add(l),l.next()},[4,tn(i)];case 1:return[2,a.apply(void 0,[c.sent(),u])]}})})}),function(){u.Wo(),i.asyncQueue.enqueueAndForget(function(){return g(s,void 0,void 0,function(){var a;return m(this,function(c){switch(c.label){case 0:return a=function(h,l){_(h).Gr.delete(l)},[4,tn(i)];case 1:return[2,a.apply(void 0,[c.sent(),u])]}})})})}}(ot(n=U(n,Y)),en(r)?r:{next:r})}(this._delegate,t)},Object.defineProperty(e.prototype,"app",{get:function(){if(!this.Xc)throw new w(d.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this.Xc},enumerable:!1,configurable:!0}),e.prototype.collection=function(t){try{return new Lr(this,nh(this._delegate,t))}catch(n){throw lt(n,"collection()","Firestore.collection()")}},e.prototype.doc=function(t){try{return new ge(this,hr(this._delegate,t))}catch(n){throw lt(n,"doc()","Firestore.doc()")}},e.prototype.collectionGroup=function(t){try{return new ui(this,function(n,r){if(n=U(n,kn),ns("collectionGroup","collection id",r),r.indexOf("/")>=0)throw new w(d.INVALID_ARGUMENT,"Invalid collection ID '"+r+"' passed to function collectionGroup(). Collection IDs must not contain '/'.");return new Nt(n,null,function(i){return new Qt(V.emptyPath(),i)}(r))}(this._delegate,t))}catch(n){throw lt(n,"collectionGroup()","Firestore.collectionGroup()")}},e.prototype.runTransaction=function(t){var n=this;return function(r,i){return function(o,s){var u=this,a=new kt;return o.asyncQueue.enqueueAndForget(function(){return g(u,void 0,void 0,function(){var c;return m(this,function(h){switch(h.label){case 0:return[4,function(l){return ti(l).then(function(f){return f.datastore})}(o)];case 1:return c=h.sent(),new Hp(o.asyncQueue,c,s,a).run(),[2]}})})}),a.promise}(ot(r),function(o){return i(new md(r,o))})}(this._delegate,function(r){return t(new Ih(n,r))})},e.prototype.batch=function(){var t=this;return ot(this._delegate),new Eh(new vd(this._delegate,function(n){return Rn(t._delegate,n)}))},e.prototype.loadBundle=function(t){throw new w(d.FAILED_PRECONDITION,'"loadBundle()" does not exist, have you imported "firebase/firestore/bundle"?')},e.prototype.namedQuery=function(t){throw new w(d.FAILED_PRECONDITION,'"namedQuery()" does not exist, have you imported "firebase/firestore/bundle"?')},e}(),oi=function(e){function t(n){var r=this;return(r=e.call(this)||this).firestore=n,r}return C(t,e),t.prototype.convertBytes=function(n){return new wh(new Te(n))},t.prototype.convertReference=function(n){var r=this.convertDocumentKey(n,this.firestore._databaseId);return ge.Zc(r,this.firestore,null)},t}(cs);function wd(e){var t;t=e,Rt.setLogLevel(t)}var Ih=function(){function e(t,n){this._firestore=t,this._delegate=n,this._userDataWriter=new oi(t)}return e.prototype.get=function(t){var n=this,r=ye(t);return this._delegate.get(r).then(function(i){return new On(n._firestore,new Gt(n._firestore._delegate,n._userDataWriter,i._key,i._document,i.metadata,r._converter))})},e.prototype.set=function(t,n,r){var i=ye(t);return r?(rs("Transaction.set",r),this._delegate.set(i,n,r)):this._delegate.set(i,n),this},e.prototype.update=function(t,n,r){for(var i,o=[],s=3;s