!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("@firebase/app")):"function"==typeof define&&define.amd?define(["@firebase/app"],e):e((t=t||self).firebase)}(this,function(Bd){"use strict";try{(function(){Bd=Bd&&Bd.hasOwnProperty("default")?Bd.default:Bd;var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function t(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o,e,f=function(){return(f=Object.assign||function(t){for(var e,n=1,r=arguments.length;ns[0]&&e[1]"})}(o,r):"Error",a=this.serviceName+": "+s+" ("+i+").",u=new d(i,a),h=0,c=Object.keys(r);h>>0),L=0;function q(t,e,n){return t.call.apply(t.bind,arguments)}function M(e,n,t){if(!e)throw Error();if(2parseFloat(dt)){ot=String(vt);break t}}ot=dt}var mt,gt={};function wt(a){return function(t,e){var n=gt;return Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=e(t)}(a,function(){for(var t=0,e=K(String(ot)).split("."),n=K(String(a)).split("."),r=Math.max(e.length,n.length),i=0;0==t&&i>>0);function zt(e){return"function"==_(e)?e:(e[Bt]||(e[Bt]=function(t){return e.handleEvent(t)}),e[Bt])}function Xt(){G.call(this),this.c=new Ct(this),(this.J=this).B=null}function Wt(t,e,n,r){if(!(e=t.c.a[String(e)]))return!0;e=e.concat();for(var i=!0,o=0;oe.length?Oe:(e=e.substr(r,n),t.A=r+n,e))}function je(t){t.R=j()+t.O,Fe(t,t.O)}function Fe(t,e){if(null!=t.i)throw Error("WatchDog timer not null");t.i=be(U(t.ab,t),e)}function Ge(t){t.i&&(N.clearTimeout(t.i),t.i=null)}function Be(t){t.g.Ca()||t.m||t.g.na(t)}function ze(t){Ge(t);var e=t.B;e&&"function"==typeof e.la&&e.la(),t.B=null,oe(t.P),le(t.I),t.a&&(e=t.a,t.a=null,e.abort(),e.la())}function Xe(t,e){try{t.g.Fa(t,e),ve(4)}catch(t){}}function We(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(x(t)||S(t))z(t,e,void 0);else{if(t.K&&"function"==typeof t.K)var n=t.K();else if(t.C&&"function"==typeof t.C)n=void 0;else if(x(t)||S(t)){n=[];for(var r=t.length,i=0;i2*t.c&&Ke(t))}function Ke(t){if(t.c!=t.a.length){for(var e=0,n=0;e>4&15).toString(16)+(15&t).toString(16)}$e.prototype.toString=function(){var t=[],e=this.f;e&&t.push(hn(e,fn,!0),":");var n=this.b;return!n&&"file"!=e||(t.push("//"),(e=this.j)&&t.push(hn(e,fn,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.i)&&t.push(":",String(n))),(n=this.a)&&(this.b&&"/"!=n.charAt(0)&&t.push("/"),t.push(hn(n,"/"==n.charAt(0)?pn:ln,!0))),(n=this.c.toString())&&t.push("?",n),(n=this.g)&&t.push("#",hn(n,yn)),t.join("")},$e.prototype.resolve=function(t){var e=Ze(this),n=!!t.f;n?tn(e,t.f):n=!!t.j,n?e.j=t.j:n=!!t.b,n?en(e,t.b):n=null!=t.i;var r=t.a;if(n)nn(e,t.i);else if(n=!!t.a){if("/"!=r.charAt(0))if(this.b&&!this.a)r="/"+r;else{var i=e.a.lastIndexOf("/");-1!=i&&(r=e.a.substr(0,i+1)+r)}if(".."==(i=r)||"."==i)r="";else if(Q(i,"./")||Q(i,"/.")){r=0==i.lastIndexOf("/",0),i=i.split("/");for(var o=[],s=0;s=t.f}function Pn(t){return t.b?1:t.a?t.a.a.c:0}function On(t,e){return t=t.b?t.b==e:!!t.a&&(e=Dn(e),Qe(t.a.a.b,e))}function Ln(t,e){t.a?t.a.add(e):t.b=e}function qn(t,e){var n;t.b&&t.b==e?t.b=null:((n=t.a)&&(n=Dn(e),n=Qe(t.a.a.b,n)),n&&Ye(t.a.a,Dn(e)))}function Mn(t){if(null!=t.b)return t.c.concat(t.b.j);if(null==t.a||0==t.a.a.c)return W(t.c);var e=t.c;return z(t.a.C(),function(t){e=e.concat(t.j)}),e}function Un(){}function Vn(){this.a=new Un}function jn(t,r,e){var i=e||"";try{We(t,function(t,e){var n=t;P(t)&&(n=Ht(t)),r.push(i+e+"="+encodeURIComponent(n))})}catch(t){throw r.push(i+"type="+encodeURIComponent("_badmap")),t}}function Fn(t,e,n,r,i){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,i(r)}catch(t){}}Rn.prototype.cancel=function(){this.c=Mn(this),this.b?(this.b.cancel(),this.b=null):this.a&&0!=this.a.a.c&&(z(this.a.C(),function(t){t.cancel()}),function(t){t.b={},t.a.length=0,t.c=0}(this.a.a))},Un.prototype.stringify=function(t){return N.JSON.stringify(t,void 0)},Un.prototype.parse=function(t){return N.JSON.parse(t,void 0)};var Gn=N.JSON.parse;function Bn(t){Xt.call(this),this.headers=new He,this.H=t||null,this.b=!1,this.s=this.a=null,this.A="",this.h=0,this.f="",this.g=this.w=this.l=this.v=!1,this.o=0,this.m=null,this.I=zn,this.D=this.F=!1}F(Bn,Xt);var zn="",Xn=/^https?$/i,Wn=["POST","PUT"];function Hn(t){return"content-type"==t.toLowerCase()}function Yn(t,e){t.b=!1,t.a&&(t.g=!0,t.a.abort(),t.g=!1),t.f=e,t.h=5,Kn(t),Jn(t)}function Kn(t){t.v||(t.v=!0,t.dispatchEvent("complete"),t.dispatchEvent("error"))}function Qn(t){if(t.b&&void 0!==A&&(!t.s[1]||4!=Zn(t)||2!=t.T()))if(t.l&&4==Zn(t))se(t.Ea,0,t);else if(t.dispatchEvent("readystatechange"),4==Zn(t)){t.b=!1;try{var e,n=t.T();t:switch(n){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var r=!0;break t;default:r=!1}if(!(e=r)){var i;if(i=0===n){var o=String(t.A).match(Je)[1]||null;if(!o&&N.self&&N.self.location){var s=N.self.location.protocol;o=s.substr(0,s.length-1)}i=!Xn.test(o?o.toLowerCase():"")}e=i}if(e)t.dispatchEvent("complete"),t.dispatchEvent("success");else{t.h=6;try{var a=2=t.b.f-(t.h?1:0))&&(t.h?(t.f=e.j.concat(t.f),!0):!(1==t.u||2==t.u||t.A>=(t.Oa?0:t.Pa))&&(t.h=be(U(t.Ha,t,e),dr(t,t.A)),t.A++,!0))}(this,t)||2==n&&fr(this)))switch(e&&0r)throw new oi(ii.INVALID_ARGUMENT,"Function "+t+"() requires between "+n+" and "+r+" arguments, but was called with "+Ui(e.length,"argument")+".")}function Ni(t,e,n,r){_i(t,e,Mi(n)+" argument",r)}function Si(t,e,n,r){void 0!==r&&Ni(t,e,n,r)}function Di(t,e,n,r){_i(t,e,n+" option",r)}function ki(t,e,n,r){void 0!==r&&Di(t,e,n,r)}function Ri(t,e,n,r,h){void 0!==r&&function(t,e,n,r){for(var i=[],o=0,s=h;o=t,"Can't call popFirst() with less segments"),this.$(this.segments,this.offset+t,this.length-t)},so.prototype.tt=function(){return Fr(!this.nt(),"Can't call popLast() on empty path"),this.$(this.segments,this.offset,this.length-1)},so.prototype.it=function(){return Fr(!this.nt(),"Can't call firstSegment() on empty path"),this.segments[this.offset]},so.prototype.et=function(){return this.get(this.length-1)},so.prototype.get=function(t){return Fr(te.length?1:0},so),Xi=(t(oo,ji=zi),oo.prototype.$=function(t,e,n){return new oo(t,e,n)},oo.prototype.ot=function(){return this.st().join("/")},oo.prototype.toString=function(){return this.ot()},oo.ht=function(t){if(0<=t.indexOf("//"))throw new oi(ii.INVALID_ARGUMENT,"Invalid path ("+t+"). Paths must not contain // in them.");return new oo(t.split("/").filter(function(t){return 0t.length&&jr("offset "+e+" out of range "+t.length),void 0===n?n=t.length-e:n>t.length-e&&jr("length "+n+" out of range "+(t.length-e)),this.segments=t,this.offset=e,this.Y=n}function ao(t){this.timestamp=t}function uo(t,e){if(this.seconds=t,(this.nanoseconds=e)<0)throw new oi(ii.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(1e9<=e)throw new oi(ii.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new oi(ii.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(253402300800<=t)throw new oi(ii.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}function ho(t,e){if(Ii("GeoPoint",arguments,2),Ni("GeoPoint","number",1,t),Ni("GeoPoint","number",2,e),!isFinite(t)||t<-90||90"},ta.prototype.Ln=function(){return 16+(this.previousValue?this.previousValue.Ln():0)},ta),xs=(t(Zs,Es=is),Zs.prototype.value=function(t){return this.nn},Zs.prototype.isEqual=function(t){return t instanceof Zs&&this.nn.isEqual(t.nn)},Zs.prototype.h=function(t){return t instanceof Zs?this.nn.q(t.nn):this.jn(t)},Zs.prototype.Ln=function(){return this.nn.Wn()},Zs),Ps=(t($s,bs=is),$s.prototype.value=function(t){return this.key},$s.prototype.isEqual=function(t){return t instanceof $s&&this.key.isEqual(t.key)&&this.s.isEqual(t.s)},$s.prototype.h=function(t){if(t instanceof $s){var e=this.s.h(t.s);return 0!==e?e:Yi.X(this.key,t.key)}return this.jn(t)},$s.prototype.Ln=function(){return this.s.projectId.length+this.s.database.length+this.key.toString().length},$s),Os=(t(Js,ws=is),Js.prototype.value=function(t){return this.nn},Js.prototype.isEqual=function(t){return t instanceof Js&&this.nn.isEqual(t.nn)},Js.prototype.h=function(t){return t instanceof Js?this.nn.q(t.nn):this.jn(t)},Js.prototype.Ln=function(){return 16},Js),Ls=(t(Qs,gs=is),Qs.prototype.value=function(n){var r={};return this.nn.Et(function(t,e){r[t]=e.value(n)}),r},Qs.prototype.forEach=function(t){this.nn.Et(t)},Qs.prototype.isEqual=function(t){if(t instanceof Qs){for(var e=this.nn.At(),n=t.nn.At();e.Nt()&&n.Nt();){var r=e.kt(),i=n.kt();if(r.key!==i.key||!r.value.isEqual(i.value))return!1}return!e.Nt()&&!n.Nt()}return!1},Qs.prototype.h=function(t){if(t instanceof Qs){for(var e=this.nn.At(),n=t.nn.At();e.Nt()&&n.Nt();){var r=e.kt(),i=n.kt(),o=zr(r.key,i.key)||r.value.h(i.value);if(o)return o}return zr(e.Nt(),n.Nt())}return this.jn(t)},Qs.prototype.set=function(t,e){if(Fr(!t.nt(),"Cannot set field for empty path on ObjectValue"),1===t.length)return this.zn(t.it(),e);var n=this.child(t.it());n instanceof Qs||(n=Qs.EMPTY);var r=n.set(t.Z(),e);return this.zn(t.it(),r)},Qs.prototype.delete=function(t){if(Fr(!t.nt(),"Cannot delete field for empty path on ObjectValue"),1===t.length)return new Qs(this.nn.remove(t.it()));var e=this.child(t.it());if(e instanceof Qs){var n=e.delete(t.Z());return new Qs(this.nn.bt(t.it(),n))}return this},Qs.prototype.contains=function(t){return null!==this.field(t)},Qs.prototype.field=function(t){Fr(!t.nt(),"Can't get field of empty path");var e=this;return t.forEach(function(t){e=e instanceof Qs?e.nn.get(t):null}),e},Qs.prototype.mn=function(){var i=new co(Hi.X);return this.nn.forEach(function(t,e){var n=new Hi([t]);if(e instanceof Qs){var r=e.mn().fields;r.nt()?i=i.add(n):r.forEach(function(t){i=i.add(n.child(t))})}else i=i.add(n)}),Do.in(i)},Qs.prototype.Ln=function(){var n=0;return this.nn.Et(function(t,e){n+=t.length+e.Ln()}),n},Qs.prototype.toString=function(){return this.nn.toString()},Qs.prototype.child=function(t){return this.nn.get(t)||void 0},Qs.prototype.zn=function(t,e){return new Qs(this.nn.bt(t,e))},Qs.EMPTY=new Qs(new Ki(zr)),Qs),qs=(t(Ks,ms=is),Ks.prototype.value=function(e){return this.nn.map(function(t){return t.value(e)})},Ks.prototype.contains=function(t){for(var e=0,n=this.nn;e=":return Fa.GREATER_THAN_OR_EQUAL;case">":return Fa.GREATER_THAN;case"array-contains":return Fa.ARRAY_CONTAINS;case"in":return Fa.IN;case"array-contains-any":return Fa.ARRAY_CONTAINS_ANY;default:return jr("Unknown FieldFilter operator: "+t)}},Fa.prototype.toString=function(){return this.name},Fa.prototype.isEqual=function(t){return this.name===t.name},Fa.LESS_THAN=new Fa("<"),Fa.LESS_THAN_OR_EQUAL=new Fa("<="),Fa.EQUAL=new Fa("=="),Fa.GREATER_THAN=new Fa(">"),Fa.GREATER_THAN_OR_EQUAL=new Fa(">="),Fa.ARRAY_CONTAINS=new Fa("array-contains"),Fa.IN=new Fa("in"),Fa.ARRAY_CONTAINS_ANY=new Fa("array-contains-any"),Fa),Ea=(t(ja,ga=function(){}),ja.create=function(t,e,n){if(t.ft())return e===ba.IN?(Fr(n instanceof qs,"Comparing on key with IN, but filter value not an ArrayValue"),Fr(n.nn.every(function(t){return t instanceof Ps}),"Comparing on key with IN, but an array value was not a RefValue"),new Ta(t,n)):(Fr(n instanceof Ps,"Comparing on key, but filter value not a RefValue"),Fr(e!==ba.ARRAY_CONTAINS&&e!==ba.ARRAY_CONTAINS_ANY,"'"+e.toString()+"' queries don't make sense on document keys."),new Ia(t,e,n));if(n.isEqual(os.Bn)){if(e!==ba.EQUAL)throw new oi(ii.INVALID_ARGUMENT,"Invalid query. Null supports only equality comparisons.");return new ja(t,e,n)}if(n.isEqual(ks.Qn)){if(e!==ba.EQUAL)throw new oi(ii.INVALID_ARGUMENT,"Invalid query. NaN supports only equality comparisons.");return new ja(t,e,n)}return e===ba.ARRAY_CONTAINS?new Aa(t,n):e===ba.IN?(Fr(n instanceof qs,"IN filter has invalid value: "+n.toString()),new Na(t,n)):e===ba.ARRAY_CONTAINS_ANY?(Fr(n instanceof qs,"ARRAY_CONTAINS_ANY filter has invalid value: "+n.toString()),new Sa(t,n)):new ja(t,e,n)},ja.prototype.matches=function(t){var e=t.field(this.field);return null!==e&&this.value.Un===e.Un&&this.Ci(e.h(this.value))},ja.prototype.Ci=function(t){switch(this.op){case ba.LESS_THAN:return t<0;case ba.LESS_THAN_OR_EQUAL:return t<=0;case ba.EQUAL:return 0===t;case ba.GREATER_THAN:return 0c.Bo.Po?(Mr("LruGarbageCollector","Capping sequence numbers to collect down to the maximum of "+c.Bo.Po+" from "+t),c.Bo.Po):t,s=Date.now(),c.Ko(e,i)}).next(function(t){return r=t,a=Date.now(),c.Jo(e,r,n)}).next(function(t){return o=t,u=Date.now(),c.Yo(e,r)}).next(function(t){return h=Date.now(),Lr()<=Nr.DEBUG&&Mr("LruGarbageCollector","LRU Garbage Collection\n\tCounted targets in "+(s-f)+"ms\n\tDetermined least recently used "+i+" in "+(a-s)+"ms\n\tRemoved "+o+" targets in "+(u-a)+"ms\n\tRemoved "+t+" documents in "+(h-u)+"ms\nTotal Duration: "+(h-f)+"ms"),ih.resolve({Io:!0,To:i,Eo:o,Ro:t})})},qh),Ph="LocalStore",Oh=(Lh.prototype.start=function(){return this.mh()},Lh.prototype.ph=function(i){return p(this,void 0,void 0,function(){var e,v,n,r=this;return y(this,function(t){switch(t.label){case 0:return e=this.cs,v=this.dh,[4,this.persistence.runTransaction("Handle user change","readonly-idempotent",function(d){var y;return r.cs.gh(d).next(function(t){return y=t,e=r.persistence.oh(i),v=new uh(r.hh,e,r.persistence.vh()),e.gh(d)}).next(function(t){for(var e=[],n=[],r=ou(),i=0,o=y;i=this.zh||0() instead."),ic=/^__.*__$/,oc=(uc.prototype.bc=function(t,e){var n=[];return null!==this.mn?n.push(new Bo(t,this.data,this.mn,e)):n.push(new Go(t,this.data,e)),0this.Hc&&(this.Jc=this.Hc)},Rc.prototype.cancel=function(){null!==this.Yc&&(this.Yc.cancel(),this.Yc=null)},Rc.prototype.ta=function(){return(Math.random()-.5)*this.Jc},Rc);function Rc(t,e,n,r,i){void 0===n&&(n=1e3),void 0===r&&(r=1.5),void 0===i&&(i=6e4),this.Wc=t,this.Qs=e,this.zc=n,this.Kc=r,this.Hc=i,this.Jc=0,this.Yc=null,this.Xc=Date.now(),this.reset()}(Dc=Sc=Sc||{})[Dc.na=0]="__PRIVATE_Initial",Dc[Dc.ia=1]="__PRIVATE_Starting",Dc[Dc.ea=2]="__PRIVATE_Open",Dc[Dc.Error=3]="Error",Dc[Dc.ra=4]="__PRIVATE_Backoff";var _c,Cc,xc=(Hc.prototype.fa=function(){return this.state===Sc.ia||this.state===Sc.ea||this.state===Sc.ra},Hc.prototype.la=function(){return this.state===Sc.ea},Hc.prototype.start=function(){this.state!==Sc.Error?(Fr(this.state===Sc.na,"Already started"),this.auth()):this.da()},Hc.prototype.stop=function(){return p(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.fa()?[4,this.close(Sc.na)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},Hc.prototype.va=function(){Fr(!this.fa(),"Can only inhibit backoff in a stopped state"),this.state=Sc.na,this.aa.reset()},Hc.prototype.wa=function(){var t=this;this.la()&&null===this.ca&&(this.ca=this.Wc.ao(this.ua,6e4,function(){return t.ma()}))},Hc.prototype.pa=function(t){this.ga(),this.stream.send(t)},Hc.prototype.ma=function(){return p(this,void 0,void 0,function(){return y(this,function(t){return this.la()?[2,this.close(Sc.na)]:[2]})})},Hc.prototype.ga=function(){this.ca&&(this.ca.cancel(),this.ca=null)},Hc.prototype.close=function(e,n){return p(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return Fr(this.fa(),"Only started streams should be closed."),Fr(e===Sc.Error||oa(n),"Can't provide an error when not in an error state."),this.ga(),this.aa.cancel(),this.ha++,e!==Sc.Error?this.aa.reset():n&&n.code===ii.RESOURCE_EXHAUSTED?(Ur(n.toString()),Ur("Using maximum backoff delay to prevent overloading the backend."),this.aa.$c()):n&&n.code===ii.UNAUTHENTICATED&&this.oa.P(),null!==this.stream&&(this.ba(),this.stream.close(),this.stream=null),this.state=e,[4,this.listener.ya(n)];case 1:return t.sent(),[2]}})})},Hc.prototype.ba=function(){},Hc.prototype.auth=function(){var n=this;Fr(this.state===Sc.na,"Must be in initial state to auth"),this.state=Sc.ia;var t=this._a(this.ha),e=this.ha;this.oa.getToken().then(function(t){n.ha===e&&n.Ia(t)},function(e){t(function(){var t=new oi(ii.UNKNOWN,"Fetching auth token failed: "+e.message);return n.Ta(t)})})},Hc.prototype.Ia=function(t){var e=this;Fr(this.state===Sc.ia,"Trying to start stream in a non-starting state");var n=this._a(this.ha);this.stream=this.Ea(t),this.stream.Ra(function(){n(function(){return Fr(e.state===Sc.ia,"Expected stream to be in state Starting, but was "+e.state),e.state=Sc.ea,e.listener.Ra()})}),this.stream.ya(function(t){n(function(){return e.Ta(t)})}),this.stream.onMessage(function(t){n(function(){return e.onMessage(t)})})},Hc.prototype.da=function(){var t=this;Fr(this.state===Sc.Error,"Should only perform backoff when in Error state"),this.state=Sc.ra,this.aa.Zc(function(){return p(t,void 0,void 0,function(){return y(this,function(t){return Fr(this.state===Sc.ra,"Backoff elapsed but state is now: "+this.state),this.state=Sc.na,this.start(),Fr(this.fa(),"PersistentStream should have started"),[2]})})})},Hc.prototype.Ta=function(t){return Fr(this.fa(),"Can't handle server close on non-started stream"),Mr("PersistentStream","close with error: "+t),this.stream=null,this.close(Sc.Error,t)},Hc.prototype._a=function(e){var n=this;return function(t){n.Wc.Xs(function(){return n.ha===e?t():(Mr("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())})}},Hc),Pc=(t(Wc,Cc=xc),Wc.prototype.Ea=function(t){return this.sa.Aa("Listen",t)},Wc.prototype.onMessage=function(t){this.aa.reset();var e=this.serializer.Or(t),n=this.serializer.xr(t);return this.listener.Da(e,n)},Wc.prototype.Pa=function(t){var e={};e.database=this.serializer.br,e.addTarget=this.serializer.bi(t);var n=this.serializer.eu(t);n&&(e.labels=n),this.pa(e)},Wc.prototype.Sa=function(t){var e={};e.database=this.serializer.br,e.removeTarget=t,this.pa(e)},Wc),Oc=(t(Xc,_c=xc),Object.defineProperty(Xc.prototype,"Va",{get:function(){return this.Ca},enumerable:!0,configurable:!0}),Xc.prototype.start=function(){this.Ca=!1,_c.prototype.start.call(this)},Xc.prototype.ba=function(){this.Ca&&this.ka([])},Xc.prototype.Ea=function(t){return this.sa.Aa("Write",t)},Xc.prototype.onMessage=function(t){if(Fr(!!t.streamToken,"Got a write response without a stream token"),this.lastStreamToken=t.streamToken,this.Ca){this.aa.reset();var e=this.serializer.zr(t.writeResults,t.commitTime),n=this.serializer.fromVersion(t.commitTime);return this.listener.Na(n,e)}return Fr(!t.writeResults||0===t.writeResults.length,"Got mutation results for handshake"),this.Ca=!0,this.listener.Oa()},Xc.prototype.Fa=function(){Fr(this.la(),"Writing handshake requires an opened stream"),Fr(!this.Ca,"Handshake already completed");var t={};t.database=this.serializer.br,this.pa(t)},Xc.prototype.ka=function(t){var e=this;Fr(this.la(),"Writing mutations requires an opened stream"),Fr(this.Ca,"Handshake must be complete before writing mutations"),Fr(0",t),this.store.put(t)))},Wf.prototype.add=function(t){return Mr("SimpleDb","ADD",this.store.name,t,t),Qf(this.store.add(t))},Wf.prototype.get=function(e){var n=this;return Qf(this.store.get(e)).next(function(t){return void 0===t&&(t=null),Mr("SimpleDb","GET",n.store.name,e,t),t})},Wf.prototype.delete=function(t){return Mr("SimpleDb","DELETE",this.store.name,t),Qf(this.store.delete(t))},Wf.prototype.count=function(){return Mr("SimpleDb","COUNT",this.store.name),Qf(this.store.count())},Wf.prototype.Iv=function(t,e){var n=this.cursor(this.options(t,e)),r=[];return this.Tv(n,function(t,e){r.push(e)}).next(function(){return r})},Wf.prototype.Ev=function(t,e){Mr("SimpleDb","DELETE ALL",this.store.name);var n=this.options(t,e);n.Rv=!1;var r=this.cursor(n);return this.Tv(r,function(t,e,n){return n.delete()})},Wf.prototype.Av=function(t,e){var n;e?n=t:(n={},e=t);var r=this.cursor(n);return this.Tv(r,e)},Wf.prototype.Dv=function(i){var t=this.cursor({});return new ih(function(n,r){t.onerror=function(t){var e=$f(t.target.error);r(e)},t.onsuccess=function(t){var e=t.target.result;e?i(e.primaryKey,e.value).next(function(t){t?e.continue():n()}):n()}})},Wf.prototype.Tv=function(t,s){var a=[];return new ih(function(o,e){t.onerror=function(t){e(t.target.error)},t.onsuccess=function(t){var e=t.target.result;if(e){var n=new Bf(e),r=s(e.primaryKey,e.value,n);if(r instanceof ih){var i=r.catch(function(t){return n.done(),ih.reject(t)});a.push(i)}n.Bu?o():null===n.bv?e.continue():e.continue(n.bv)}else o()}}).next(function(){return ih.zu(a)})},Wf.prototype.options=function(t,e){var n=void 0;return void 0!==t&&("string"==typeof t?n=t:(Fr(void 0===e,"3rd argument must not be defined if 2nd is a range."),e=t)),{index:n,range:e}},Wf.prototype.cursor=function(t){var e="next";if(t.reverse&&(e="prev"),t.index){var n=this.store.index(t.index);return t.Rv?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)},Wf);function Wf(t){this.store=t}function Hf(t){var n=this;this.transaction=t,this.aborted=!1,this._v=new Yu,this.transaction.oncomplete=function(){n._v.resolve()},this.transaction.onabort=function(){t.error?n._v.reject(t.error):n._v.resolve()},this.transaction.onerror=function(t){var e=$f(t.target.error);n._v.reject(e)}}function Yf(t){this.mv=t,this.pv=!1,this.gv=null}function Kf(t){this.db=t,12.2===Kf.hv(l())&&Ur("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}function Qf(t){return new ih(function(n,r){t.onsuccess=function(t){var e=t.target.result;n(e)},t.onerror=function(t){var e=$f(t.target.error);r(e)}})}var Jf=!1;function $f(t){var e=Gf.hv(l());if(12.2<=e&&e<13){var n="An internal error was encountered in the Indexed Database server";if(0<=t.message.indexOf(n)){var r=new oi("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 Jf||(Jf=!0,setTimeout(function(){throw r},0)),r}}return t}var Zf=(tl.Sv=function(t,e,n,r){return Fr(""!==t.uid,"UserID must not be an empty string."),new tl(t._()?t.uid:"",e,n,r)},tl.prototype.Cv=function(t){var r=!0,e=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return il(t).Av({index:xl.userMutationsIndex,range:e},function(t,e,n){r=!1,n.done()}).next(function(){return r})},tl.prototype.Ah=function(e,t,n){return this.Vv(e).next(function(t){return t.lastStreamToken=rl(n),sl(e).put(t)})},tl.prototype.Fh=function(t){return this.Vv(t).next(function(t){return t.lastStreamToken})},tl.prototype.xh=function(e,n){return this.Vv(e).next(function(t){return t.lastStreamToken=rl(n),sl(e).put(t)})},tl.prototype.Th=function(h,c,f,l){var p=this,d=ol(h),y=il(h);return y.add({}).next(function(t){Fr("number"==typeof t,"Auto-generated key is not a number");for(var e=new th(t,c,f,l),n=p.serializer.kv(p.userId,e),r=[],i=new co(function(t,e){return zr(t.ot(),e.ot())}),o=0,s=l;o=i,"Should have found mutation after "+i),o=r.serializer.Ov(e)),n.done()}).next(function(){return o})},tl.prototype.Oh=function(t){var e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),r=-1;return il(t).Av({index:xl.userMutationsIndex,range:e,reverse:!0},function(t,e,n){r=e.batchId,n.done()}).next(function(){return r})},tl.prototype.gh=function(t){var e=this,n=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return il(t).Iv(xl.userMutationsIndex,n).next(function(t){return t.map(function(t){return e.serializer.Ov(t)})})},tl.prototype.ls=function(a,u){var h=this,t=Ll.prefixForPath(this.userId,u.path),e=IDBKeyRange.lowerBound(t),c=[];return ol(a).Av({range:e},function(e,t,n){var r=e[0],i=e[1],o=e[2],s=Ff(i);if(r===h.userId&&u.path.isEqual(s))return il(a).get(o).next(function(t){if(!t)throw jr("Dangling document-mutation reference found: "+e+" which points to "+o);Fr(t.userId===h.userId,"Unexpected user '"+t.userId+"' for mutation batch "+o),c.push(h.serializer.Ov(t))});n.done()}).next(function(){return c})},tl.prototype.ps=function(r,t){var u=this,h=new co(zr),i=[];return t.forEach(function(a){var t=Ll.prefixForPath(u.userId,a.path),e=IDBKeyRange.lowerBound(t),n=ol(r).Av({range:e},function(t,e,n){var r=t[0],i=t[1],o=t[2],s=Ff(i);r===u.userId&&a.path.isEqual(s)?h=h.add(o):n.done()});i.push(n)}),ih.zu(i).next(function(){return u.Fv(r,h)})},tl.prototype.Ts=function(t,e){var a=this;Fr(!e.Zn(),"Document queries shouldn't go down this path"),Fr(!e.Pi(),"CollectionGroup queries should be handled in LocalDocumentsView");var u=e.path,h=u.length+1,n=Ll.prefixForPath(this.userId,u),r=IDBKeyRange.lowerBound(n),c=new co(zr);return ol(t).Av({range:r},function(t,e,n){var r=t[0],i=t[1],o=t[2],s=Ff(i);r===a.userId&&u.rt(s)?s.length===h&&(c=c.add(o)):n.done()}).next(function(){return a.Fv(t,c)})},tl.prototype.Fv=function(t,e){var n=this,r=[],i=[];return e.forEach(function(e){i.push(il(t).get(e).next(function(t){if(null===t)throw jr("Dangling document-mutation reference found, which points to "+e);Fr(t.userId===n.userId,"Unexpected user '"+t.userId+"' for mutation batch "+e),r.push(n.serializer.Ov(t))}))}),ih.zu(i).next(function(){return r})},tl.prototype.Nh=function(e,n){var r=this;return nl(e.xv,this.userId,n).next(function(t){return e.ss(function(){r.hc(n.batchId)}),ih.forEach(t,function(t){return r.sh.jv(e,t)})})},tl.prototype.hc=function(t){delete this.Pv[t]},tl.prototype.Ch=function(n){var o=this;return this.Cv(n).next(function(t){if(!t)return ih.resolve();var e=IDBKeyRange.lowerBound(Ll.prefixForUser(o.userId)),i=[];return ol(n).Av({range:e},function(t,e,n){if(t[0]===o.userId){var r=Ff(t[1]);i.push(r)}else n.done()}).next(function(){Fr(0===i.length,"Document leak -- detected dangling mutation references when queue is empty. Dangling keys: "+i.map(function(t){return t.ot()}))})})},tl.prototype.xu=function(t,e){return el(t,this.userId,e)},tl.prototype.Vv=function(t){var e=this;return sl(t).get(this.userId).next(function(t){return t||new Cl(e.userId,-1,"")})},tl);function tl(t,e,n,r){this.userId=t,this.serializer=e,this.as=n,this.sh=r,this.Pv={}}function el(t,o,e){var n=Ll.prefixForPath(o,e.path),s=n[1],r=IDBKeyRange.lowerBound(n),a=!1;return ol(t).Av({range:r,Rv:!0},function(t,e,n){var r=t[0],i=t[1];t[2],r===o&&i===s&&(a=!0),n.done()}).next(function(){return a})}function nl(t,e,n){var r=t.store(xl.store),i=t.store(Ll.store),o=[],s=IDBKeyRange.only(n.batchId),a=0,u=r.Av({range:s},function(t,e,n){return a++,n.delete()});o.push(u.next(function(){Fr(1===a,"Dangling document-mutation reference found: Missing batch "+n.batchId)}));for(var h=[],c=0,f=n.mutations;ct.highestListenSequenceNumber&&(t.highestListenSequenceNumber=n),i.Bv(e,t)})},ul.prototype.tc=function(e,n){var r=this;return this.qv(e,n).next(function(){return r.Lv(e).next(function(t){return t.targetCount+=1,r.Qv(n,t),r.Bv(e,t)})})},ul.prototype.Qh=function(t,e){return this.qv(t,e)},ul.prototype.Gv=function(e,t){var n=this;return this.Wv(e,t.targetId).next(function(){return hl(e).delete(t.targetId)}).next(function(){return n.Lv(e)}).next(function(t){return Fr(0e.highestTargetId&&(e.highestTargetId=t.targetId,n=!0),t.sequenceNumber>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=t.sequenceNumber,n=!0),n},ul.prototype.Hv=function(t){return this.Lv(t).next(function(t){return t.targetCount})},ul.prototype.$h=function(t,i){var o=this,e=i.canonicalId(),n=IDBKeyRange.bound([e,Number.NEGATIVE_INFINITY],[e,Number.POSITIVE_INFINITY]),s=null;return hl(t).Av({range:n,index:Bl.queryTargetsIndexName},function(t,e,n){var r=o.serializer.zv(e);i.isEqual(r.target)&&(s=r,n.done())}).next(function(){return s})},ul.prototype.Bh=function(n,t,r){var i=this,o=[],s=ll(n);return t.forEach(function(t){var e=Uf(t.path);o.push(s.put(new zl(r,e))),o.push(i.sh.Pu(n,t))}),ih.zu(o)},ul.prototype.Lh=function(n,t,r){var i=this,o=ll(n);return ih.forEach(t,function(t){var e=Uf(t.path);return ih.zu([o.delete([r,e]),i.sh.Cu(n,t)])})},ul.prototype.Wv=function(t,e){var n=ll(t),r=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(r)},ul.prototype.ec=function(t,e){var n=IDBKeyRange.bound([e],[e+1],!1,!0),r=ll(t),o=ou();return r.Av({range:n,Rv:!0},function(t,e,n){var r=Ff(t[1]),i=new Yi(r);o=o.add(i)}).next(function(){return o})},ul.prototype.xu=function(t,e){var n=Uf(e.path),r=IDBKeyRange.bound([n],[Wr(n)],!1,!0),i=0;return ll(t).Av({index:zl.documentTargetsIndex,Rv:!0,range:r},function(t,e,n){var r=t[0];t[1],0!==r&&(i++,n.done())}).next(function(){return 0 "+n),1))},cp.prototype.kw=function(){var t=this;null!==this.document&&"function"==typeof this.document.addEventListener&&(this._w=function(){t.Wc.Xs(function(){return t.inForeground="visible"===t.document.visibilityState,t.Vw()})},this.document.addEventListener("visibilitychange",this._w),this.inForeground="visible"===this.document.visibilityState)},cp.prototype.Yw=function(){this._w&&(Fr(null!==this.document&&"function"==typeof this.document.addEventListener,"Expected 'document.addEventListener' to be a function"),this.document.removeEventListener("visibilitychange",this._w),this._w=null)},cp.prototype.Nw=function(){var t=this;"function"==typeof this.window.addEventListener&&(this.yw=function(){t.Jw(),t.Wc.Xs(function(){return t.Af()})},this.window.addEventListener("unload",this.yw))},cp.prototype.Xw=function(){this.yw&&(Fr("function"==typeof this.window.removeEventListener,"Expected 'window.removeEventListener' to be a function"),this.window.removeEventListener("unload",this.yw),this.yw=null)},cp.prototype.Hw=function(t){try{var e=null!==this.Dw.getItem(this.Kw(t));return Mr("IndexedDbPersistence","Client '"+t+"' "+(e?"is":"is not")+" zombied in LocalStorage"),e}catch(t){return Ur("IndexedDbPersistence","Failed to get zombied client id.",t),!1}},cp.prototype.Jw=function(){try{this.Dw.setItem(this.Kw(this.clientId),String(Date.now()))}catch(t){Ur("Failed to set zombie client id.",t)}},cp.prototype.$w=function(){try{this.Dw.removeItem(this.Kw(this.clientId))}catch(t){}},cp.prototype.Kw=function(t){return"firestore_zombie_"+this.persistenceKey+"_"+t},cp.Aw="main",cp);function cp(t,e,n,r,i,o,s,a){if(this.allowTabSynchronization=t,this.persistenceKey=e,this.clientId=n,this.Wc=o,this.gw=a,this.bw=!1,this.isPrimary=!1,this.networkEnabled=!0,this.yw=null,this.inForeground=!1,this._w=null,this.Iw=null,this.Tw=Number.NEGATIVE_INFINITY,this.Ew=function(t){return Promise.resolve()},this.sh=new dp(this,i),this.Rw=e+cp.Aw,this.serializer=new ip(s),this.document=r.document,this.fh=new al(this.sh,this.serializer),this.as=new ep,this.hs=new dl(this.serializer,this.as),!r.window||!r.window.localStorage)throw new oi(ii.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");this.window=r.window,this.Dw=this.window.localStorage}function fp(t,e){var n=sp.call(this)||this;return n.xv=t,n.Mh=e,n}function lp(t){return t.store(Rl.store)}function pp(t){return t.store($l.store)}var dp=(yp.prototype.zo=function(t){var n=this.im(t);return this.db.lh().Hv(t).next(function(e){return n.next(function(t){return e+t})})},yp.prototype.im=function(t){var e=0;return this.Ho(t,function(t){e++}).next(function(){return e})},yp.prototype.qe=function(t,e){return this.db.lh().qe(t,e)},yp.prototype.Ho=function(t,n){return this.em(t,function(t,e){return n(e)})},yp.prototype.uh=function(t){this.nm=t},yp.prototype.Pu=function(t,e){return vp(t,e)},yp.prototype.Cu=function(t,e){return vp(t,e)},yp.prototype.Jo=function(t,e,n){return this.db.lh().Jo(t,e,n)},yp.prototype.jv=function(t,e){return vp(t,e)},yp.prototype.rm=function(t,e){return this.nm.xu(e)?ih.resolve(!0):(r=e,i=!1,sl(n=t).Dv(function(t){return el(n,t,r).next(function(t){return t&&(i=!0),ih.resolve(!t)})}).next(function(){return i}));var n,r,i},yp.prototype.Yo=function(r,i){var o=this,s=this.db.ah().Dh(),a=[],u=0;return this.em(r,function(e,t){if(t<=i){var n=o.rm(r,e).next(function(t){if(!t)return u++,s.ts(r,e).next(function(){return s.Zu(e),ll(r).delete([0,Uf(e.path)])})});a.push(n)}}).next(function(){return ih.zu(a)}).next(function(){return s.apply(r)}).next(function(){return u})},yp.prototype.removeTarget=function(t,e){var n=e.ji(t.Mh);return this.db.lh().Qh(t,n)},yp.prototype.Gh=function(t,e){return vp(t,e)},yp.prototype.em=function(t,o){var s,e=ll(t),a=ch.ks;return e.Av({index:zl.documentTargetsIndex},function(t,e){var n=t[0],r=(t[1],e.path),i=e.sequenceNumber;0===n?(a!==ch.ks&&o(new Yi(Ff(s)),a),a=i,s=r):a=ch.ks}).next(function(){a!==ch.ks&&o(new Yi(Ff(s)),a)})},yp.prototype.$o=function(t){return this.db.ah().ow(t)},yp);function yp(t,e){this.db=t,this.nm=null,this.xo=new xh(this,e)}function vp(t,e){return ll(t).put((n=e,r=t.Mh,new zl(0,Uf(n.path),r)));var n,r}var mp=(bp.prototype.wh=function(t){this.um=t},bp.prototype.gs=function(e,r,i,o){var s=this;return Fr(void 0!==this.um,"setLocalDocumentsView() not called"),r.gi()?this.sm(e,r):i.isEqual(Bi.MIN)?this.sm(e,r):this.um.ws(e,o).next(function(t){var n=s.om(r,t);return(r.Ri()||r.Ai())&&s.Zl(r.ei,n,o,i)?s.sm(e,r):(Lr()<=Nr.DEBUG&&Mr("IndexFreeQueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),r.toString()),s.um.gs(e,r,i).next(function(e){return n.forEach(function(t){e=e.bt(t.key,t)}),e}))})},bp.prototype.om=function(n,t){var r=new co(function(t,e){return n.yi(t,e)});return t.forEach(function(t,e){e instanceof Us&&n.matches(e)&&(r=r.add(e))}),r},bp.prototype.Zl=function(t,e,n,r){if(n.size!==e.size)return!0;var i=t===aa.ti?e.last():e.first();return!!i&&(i.hasPendingWrites||0i?this.cs[i]:null)},wp.prototype.Oh=function(){return ih.resolve(0===this.cs.length?-1:this.hm-1)},wp.prototype.gh=function(t){return ih.resolve(this.cs.slice())},wp.prototype.ls=function(t,n){var r=this,e=new rh(n,0),i=new rh(n,Number.POSITIVE_INFINITY),o=[];return this.cm.zt([e,i],function(t){Fr(n.isEqual(t.key),"Should only iterate over a single key's batches");var e=r.fm(t.ju);Fr(null!==e,"Batches in the index must exist in the main table"),o.push(e)}),ih.resolve(o)},wp.prototype.ps=function(t,e){var r=this,i=new co(zr);return e.forEach(function(e){var t=new rh(e,0),n=new rh(e,Number.POSITIVE_INFINITY);r.cm.zt([t,n],function(t){Fr(e.isEqual(t.key),"For each key, should only iterate over a single key's batches"),i=i.add(t.ju)})}),ih.resolve(this.dm(i))},wp.prototype.Ts=function(t,e){Fr(!e.Pi(),"CollectionGroup queries should be handled in LocalDocumentsView");var n=e.path,r=n.length+1,i=n;Yi.vt(i)||(i=i.child(""));var o=new rh(new Yi(i),0),s=new co(zr);return this.cm.Kt(function(t){var e=t.key.path;return!!n.rt(e)&&(e.length===r&&(s=s.add(t.ju)),!0)},o),ih.resolve(this.dm(s))},wp.prototype.dm=function(t){var n=this,r=[];return t.forEach(function(t){var e=n.fm(t);null!==e&&r.push(e)}),r},wp.prototype.Nh=function(n,r){var i=this;Fr(0===this.am(r.batchId,"removed"),"Can only remove the first entry of the mutation queue"),this.cs.shift();var o=this.cm;return ih.forEach(r.mutations,function(t){var e=new rh(t.key,r.batchId);return o=o.delete(e),i.sh.jv(n,t.key)}).next(function(){i.cm=o})},wp.prototype.hc=function(t){},wp.prototype.xu=function(t,e){var n=new rh(e,0),r=this.cm.Ht(n);return ih.resolve(e.isEqual(r&&r.key))},wp.prototype.Ch=function(t){return 0===this.cs.length&&Fr(this.cm.nt(),"Document leak -- detected dangling mutation references when queue is empty."),ih.resolve()},wp.prototype.am=function(t,e){var n=this.lm(t);return Fr(0<=n&&n=this.cs.length)return null;var n=this.cs[e];return Fr(n.batchId===t,"If found batch must match"),n},wp);function wp(t,e){this.as=t,this.sh=e,this.cs=[],this.hm=1,this.lastStreamToken=zu(),this.cm=new co(rh.Kn)}function bp(){}function Ep(){}var Ip,Tp,Ap=(Fp.prototype.Xu=function(t,e,n){Fr(!n.isEqual(Bi.MIN),"Cannot add a document with a read time of zero");var r=e.key,i=this.docs.get(r),o=i?i.size:0,s=this.vm(e);return this.docs=this.docs.bt(r,{$v:e,size:s,readTime:n}),this.size+=s-o,this.as.Nv(t,r.path.tt())},Fp.prototype.Zu=function(t){var e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)},Fp.prototype.ts=function(t,e){var n=this.docs.get(e);return ih.resolve(n?n.$v:null)},Fp.prototype.getEntries=function(t,e){var n=this,r=Za();return e.forEach(function(t){var e=n.docs.get(t);r=r.bt(t,e?e.$v:null)}),ih.resolve(r)},Fp.prototype.gs=function(t,e,n){Fr(!e.Pi(),"CollectionGroup queries should be handled in LocalDocumentsView");for(var r=eu(),i=new Yi(e.path.child("")),o=this.docs.Dt(i);o.Nt();){var s=o.kt(),a=s.key,u=s.value,h=u.$v,c=u.readTime;if(!e.path.rt(a.path))break;c.h(n)<=0||h instanceof Us&&e.matches(h)&&(r=r.bt(h.key,h))}return ih.resolve(r)},Fp.prototype.wm=function(t,e){return ih.forEach(this.docs,function(t){return e(t)})},Fp.prototype.fc=function(t,e){throw new Error("getNewDocumentChanges() is not supported with MemoryPersistence")},Fp.prototype.dc=function(t){return ih.resolve(Bi.MIN)},Fp.prototype.Dh=function(t){return new Fp.sw(this)},Fp.prototype.ow=function(t){return ih.resolve(this.size)},Fp.sw=(t(Gp,Tp=oh),Gp.prototype.rs=function(n){var r=this,i=[];return this.Hu.forEach(function(t,e){e?i.push(r.hw.Xu(n,e,r.readTime)):r.hw.Zu(t)}),ih.zu(i)},Gp.prototype.ns=function(t,e){return this.hw.ts(t,e)},Gp.prototype.es=function(t,e){return this.hw.getEntries(t,e)},Gp),Fp),Np=(jp.prototype.qe=function(t,n){return this.mm.forEach(function(t,e){return n(e)}),ih.resolve()},jp.prototype.jh=function(t){return ih.resolve(this.lastRemoteSnapshotVersion)},jp.prototype.Mv=function(t){return ih.resolve(this.pm)},jp.prototype.Zh=function(t){var e=this.Uv.after(this.highestTargetId);return this.highestTargetId=e,ih.resolve(e)},jp.prototype.Wh=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.pm&&(this.pm=e),ih.resolve()},jp.prototype.qv=function(t){this.mm.set(t.target,t);var e=t.targetId;e>this.highestTargetId&&(this.highestTargetId=e),t.sequenceNumber>this.pm&&(this.pm=t.sequenceNumber)},jp.prototype.tc=function(t,e){return Fr(!this.mm.has(e.target),"Adding a target that already exists"),this.qv(e),this.targetCount+=1,ih.resolve()},jp.prototype.Qh=function(t,e){return Fr(this.mm.has(e.target),"Updating a non-existent target"),this.qv(e),ih.resolve()},jp.prototype.Gv=function(t,e){return Fr(0=",">","array-contains","in","array-contains-any"],2,e);var i=Tc("Query.where",t),o=ba.ht(e);if(i.ft()){if(o===ba.ARRAY_CONTAINS||o===ba.ARRAY_CONTAINS_ANY)throw new oi(ii.INVALID_ARGUMENT,"Invalid Query. You can't perform '"+o.toString()+"' queries on FieldPath.documentId().");if(o===ba.IN){this.Pp(n,o);for(var s=[],a=0,u=n;ar.length)throw new oi(ii.INVALID_ARGUMENT,"Too many arguments provided to "+t+"(). The number of arguments must be less than or equal to the number of Query.orderBy() clauses");for(var i=[],o=0;o, or >=) must be on the same field. But you have inequality filters on '"+o.toString()+"' and '"+t.field.toString()+"'");var s=this.Dp.ci();null!==s&&this.xp(t.field,s)}else if(i||r){var a=null;if(i&&(a=this.Dp.Di(n)),null===a&&r&&(a=this.Dp.Di(e)),null!=a)throw a===t.op?new oi(ii.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+t.op.toString()+"' filter."):new oi(ii.INVALID_ARGUMENT,"Invalid query. You cannot use '"+t.op.toString()+"' filters with '"+a.toString()+"' filters.")}}},rd.prototype.Vp=function(t){if(null===this.Dp.ci()){var e=this.Dp.hi();null!==e&&this.xp(e,t.field)}},rd.prototype.xp=function(t,e){if(!e.isEqual(t))throw new oi(ii.INVALID_ARGUMENT,"Invalid query. You have a where filter with an inequality (<, <=, >, or >=) on field '"+t.toString()+"' and so you must also use '"+t.toString()+"' as your first Query.orderBy(), but your first Query.orderBy() is on field '"+e.toString()+"' instead.")},rd),ed=(Object.defineProperty(nd.prototype,"docs",{get:function(){var e=[];return this.forEach(function(t){return e.push(t)}),e},enumerable:!0,configurable:!0}),Object.defineProperty(nd.prototype,"empty",{get:function(){return this.Up.docs.nt()},enumerable:!0,configurable:!0}),Object.defineProperty(nd.prototype,"size",{get:function(){return this.Up.docs.size},enumerable:!0,configurable:!0}),nd.prototype.forEach=function(e,n){var r=this;Ai("QuerySnapshot.forEach",arguments,1,2),Ni("QuerySnapshot.forEach","function",1,e),this.Up.docs.forEach(function(t){e.call(n,r.Mp(t))})},Object.defineProperty(nd.prototype,"query",{get:function(){return new td(this.jp,this.dp,this.wp)},enumerable:!0,configurable:!0}),nd.prototype.docChanges=function(t){t&&(Oi("QuerySnapshot.docChanges",t,["includeMetadataChanges"]),ki("QuerySnapshot.docChanges","boolean","includeMetadataChanges",t.includeMetadataChanges));var e=!(!t||!t.includeMetadataChanges);if(e&&this.Up.te)throw new oi(ii.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this.Lp&&this.Bp===e||(this.Lp=function(i,e,o,s){if(o.Xi.nt()){var n,r=0;return o.docChanges.map(function(t){var e=new Zp(i,t.doc.key,t.doc,o.fromCache,o.$i.has(t.doc.key),s);return Fr(t.type===uu.Qi,"Invalid event type for first snapshot"),Fr(!n||o.query.yi(n,t.doc)<0,"Got added events in wrong order"),n=t.doc,{type:"added",doc:e,oldIndex:-1,newIndex:r++}})}var a=o.Xi;return o.docChanges.filter(function(t){return e||t.type!==uu.zi}).map(function(t){var e=new Zp(i,t.doc.key,t.doc,o.fromCache,o.$i.has(t.doc.key),s),n=-1,r=-1;return t.type!==uu.Qi&&(Fr(0<=(n=a.indexOf(t.doc.key)),"Index for document not found"),a=a.delete(t.doc.key)),t.type!==uu.Gi&&(r=(a=a.add(t.doc)).indexOf(t.doc.key)),{type:function(t){switch(t){case uu.Qi:return"added";case uu.Wi:case uu.zi:return"modified";case uu.Gi:return"removed";default:return jr("Unknown change type: "+t)}}(t.type),doc:e,oldIndex:n,newIndex:r}})}(this.dp,e,this.Up,this.wp),this.Bp=e),this.Lp},nd.prototype.isEqual=function(t){if(!(t instanceof nd))throw Li("isEqual","QuerySnapshot",1,t);return this.dp===t.dp&&this.jp.isEqual(t.jp)&&this.Up.isEqual(t.Up)&&this.wp===t.wp},nd.prototype.Mp=function(t){return new Zp(this.dp,t.key,t,this.metadata.fromCache,this.Up.$i.has(t.key),this.wp)},nd);function nd(t,e,n,r){this.dp=t,this.jp=e,this.Up=n,this.wp=r,this.Lp=null,this.Bp=null,this.metadata=new Jp(n.hasPendingWrites,n.fromCache)}function rd(t,e,n){this.Dp=t,this.firestore=e,this.wp=n}function id(){return null!==zp&&zp.apply(this,arguments)||this}function od(t,e,n,r,i,o){this.dp=t,this.ap=e,this._p=n,this.Ip=r,this.Tp=i,this.wp=o}function sd(t,e){this.hasPendingWrites=t,this.fromCache=e}function ad(t,e,n){this.ap=t,this.firestore=e,this.wp=n,this.Xm=this.firestore.Ym()}function ud(t){this.dp=t,this.mp=[],this.pp=!1}function hd(t,e){this.dp=t,this.vp=e}function cd(t,e){var n=this;if(this.Hm=null,this.Jm=new Ah,this.INTERNAL={delete:function(){return p(n,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.Ym(),[4,this.Xm.terminate()];case 1:return t.sent(),[2]}})})}},"object"==typeof t.options){var r=t;this.Hm=r,this.$m=cd.Zm(r),this.tp=r.name,this.np=new ai(e)}else{var i=t;if(!i.projectId)throw new oi(ii.INVALID_ARGUMENT,"Must provide projectId");this.$m=new Zr(i.projectId,i.database),this.tp="[DEFAULT]",this.np=new si}this.ip=new Wp({}),this.ep=this.rp(this.$m)}function fd(t){if(void 0===t.host){if(void 0!==t.ssl)throw new oi(ii.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else Di("settings","non-empty string","host",t.host),this.host=t.host,ki("settings","boolean","ssl",t.ssl),this.ssl=mi(t.ssl,!0);if(Oi("settings",t,["host","ssl","credentials","timestampsInSnapshots","cacheSizeBytes","experimentalForceLongPolling"]),ki("settings","object","credentials",t.credentials),this.credentials=t.credentials,ki("settings","boolean","timestampsInSnapshots",t.timestampsInSnapshots),!0===t.timestampsInSnapshots?Ur("\n The timestampsInSnapshots setting now defaults to true and you no\n longer need to explicitly set it. In a future release, the setting\n will be removed entirely and so it is recommended that you remove it\n from your firestore.settings() call now."):!1===t.timestampsInSnapshots&&Ur("\n The timestampsInSnapshots setting will soon be removed. YOU MUST UPDATE\n YOUR CODE.\n\n To hide this warning, stop using the timestampsInSnapshots setting in your\n firestore.settings({ ... }) call.\n\n Once you remove the setting, Timestamps stored in Cloud Firestore will be\n read back as Firebase Timestamp objects instead of as system Date objects.\n So you will also need to update code expecting a Date to instead expect a\n Timestamp. For example:\n\n // Old:\n const date = snapshot.get('created_at');\n // New:\n const timestamp = snapshot.get('created_at'); const date =\n timestamp.toDate();\n\n Please audit all existing usages of Date when you enable the new\n behavior."),this.timestampsInSnapshots=mi(t.timestampsInSnapshots,!0),ki("settings","number","cacheSizeBytes",t.cacheSizeBytes),void 0===t.cacheSizeBytes)this.cacheSizeBytes=_h.Oo;else{if(t.cacheSizeBytes!==Xp&&t.cacheSizeBytes<_h.No)throw new oi(ii.INVALID_ARGUMENT,"cacheSizeBytes must be at least "+_h.No);this.cacheSizeBytes=t.cacheSizeBytes}ki("settings","boolean","experimentalForceLongPolling",t.experimentalForceLongPolling),this.forceLongPolling=void 0!==t.experimentalForceLongPolling&&t.experimentalForceLongPolling}s(["length","forEach","map"],"undefined"!=typeof Symbol?[Symbol.iterator]:[]).forEach(function(t){try{Object.defineProperty(ed.prototype.docChanges,t,{get:function(){return function(){throw new oi(ii.INVALID_ARGUMENT,'QuerySnapshot.docChanges has been changed from a property into a method, so usages like "querySnapshot.docChanges" should become "querySnapshot.docChanges()"')}()}})}catch(t){}});var ld,pd=(t(dd,ld=td),Object.defineProperty(dd.prototype,"id",{get:function(){return this.Dp.path.et()},enumerable:!0,configurable:!0}),Object.defineProperty(dd.prototype,"parent",{get:function(){var t=this.Dp.path.tt();return t.nt()?null:new Qp(new Yi(t),this.firestore)},enumerable:!0,configurable:!0}),Object.defineProperty(dd.prototype,"path",{get:function(){return this.Dp.path.ot()},enumerable:!0,configurable:!0}),dd.prototype.doc=function(t){if(Ai("CollectionReference.doc",arguments,0,1),0===arguments.length&&(t=Gr.u()),Ni("CollectionReference.doc","non-empty string",1,t),""===t)throw new oi(ii.INVALID_ARGUMENT,"Document path must be a non-empty string");var e=Xi.ht(t);return Qp.fp(this.Dp.path.child(e),this.firestore,this.wp)},dd.prototype.add=function(t){Ii("CollectionReference.add",arguments,1),Ni("CollectionReference.add","object",1,t);var e=this.doc();return e.set(t).then(function(){return e})},dd.prototype.withConverter=function(t){return new dd(this.qp,this.firestore,t)},dd);function dd(t,e,n){var r=ld.call(this,wa.oi(t),e,n)||this;if((r.qp=t).length%2!=1)throw new oi(ii.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+t.ot()+" has "+t.length);return r}function yd(t,e){if(void 0===e)return{merge:!1};if(Oi(t,e,["merge","mergeFields"]),ki(t,"boolean","merge",e.merge),function(t,e,n,r,i){void 0!==r&&function(t,e,n,r,i){if(!(r instanceof Array))throw new oi(ii.INVALID_ARGUMENT,"Function "+t+"() requires its "+e+" option to be an array, but it was: "+xi(r));for(var o=0;o